const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PostcardManager-Cn1JVEbF.js","assets/usePostcardZones-DpeUsYJZ.js","assets/DirectMail-qAENArGH.js"])))=>i.map(i=>d[i]); var Mnt=Object.defineProperty;var YSe=t=>{throw TypeError(t)};var Tnt=(t,s,r)=>s in t?Mnt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var _n=(t,s,r)=>Tnt(t,typeof s!="symbol"?s+"":s,r),Uue=(t,s,r)=>s.has(t)||YSe("Cannot "+r);var us=(t,s,r)=>(Uue(t,s,"read from private field"),r?r.call(t):s.get(t)),$a=(t,s,r)=>s.has(t)?YSe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,r),$n=(t,s,r,n)=>(Uue(t,s,"write to private field"),n?n.call(t,r):s.set(t,r),r),Ui=(t,s,r)=>(Uue(t,s,"access private method"),r);var c8=(t,s,r,n)=>({set _(a){$n(t,s,a,r)},get _(){return us(t,s,n)}});function Ant(t,s){for(var r=0;rn[a]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&n(l)}).observe(document,{childList:!0,subtree:!0});function r(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(a){if(a.ep)return;a.ep=!0;const o=r(a);fetch(a.href,o)}})();var b0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function VDe(t){if(t.__esModule)return t;var s=t.default;if(typeof s=="function"){var r=function n(){return this instanceof n?Reflect.construct(s,arguments,this.constructor):s.apply(this,arguments)};r.prototype=s.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var a=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:function(){return t[n]}})}),r}var HDe={exports:{}},Yie={},WDe={exports:{}},oo={};/** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var pL=Symbol.for("react.element"),Ent=Symbol.for("react.portal"),Pnt=Symbol.for("react.fragment"),Int=Symbol.for("react.strict_mode"),Lnt=Symbol.for("react.profiler"),Dnt=Symbol.for("react.provider"),Ont=Symbol.for("react.context"),Rnt=Symbol.for("react.forward_ref"),Fnt=Symbol.for("react.suspense"),znt=Symbol.for("react.memo"),Bnt=Symbol.for("react.lazy"),XSe=Symbol.iterator;function $nt(t){return t===null||typeof t!="object"?null:(t=XSe&&t[XSe]||t["@@iterator"],typeof t=="function"?t:null)}var GDe={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},KDe=Object.assign,ZDe={};function cM(t,s,r){this.props=t,this.context=s,this.refs=ZDe,this.updater=r||GDe}cM.prototype.isReactComponent={};cM.prototype.setState=function(t,s){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,s,"setState")};cM.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function YDe(){}YDe.prototype=cM.prototype;function lve(t,s,r){this.props=t,this.context=s,this.refs=ZDe,this.updater=r||GDe}var cve=lve.prototype=new YDe;cve.constructor=lve;KDe(cve,cM.prototype);cve.isPureReactComponent=!0;var QSe=Array.isArray,XDe=Object.prototype.hasOwnProperty,dve={current:null},QDe={key:!0,ref:!0,__self:!0,__source:!0};function JDe(t,s,r){var n,a={},o=null,l=null;if(s!=null)for(n in s.ref!==void 0&&(l=s.ref),s.key!==void 0&&(o=""+s.key),s)XDe.call(s,n)&&!QDe.hasOwnProperty(n)&&(a[n]=s[n]);var i=arguments.length-2;if(i===1)a.children=r;else if(1>>1,je=le[_e];if(0>>1;_ea(we,be))Mea(Te,we)?(le[_e]=Te,le[Me]=be,_e=Me):(le[_e]=we,le[Ge]=be,_e=Ge);else if(Mea(Te,be))le[_e]=Te,le[Me]=be,_e=Me;else break e}}return he}function a(le,he){var be=le.sortIndex-he.sortIndex;return be!==0?be:le.id-he.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var l=Date,i=l.now();t.unstable_now=function(){return l.now()-i}}var d=[],u=[],p=1,f=null,y=3,_=!1,b=!1,w=!1,j=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function T(le){for(var he=r(u);he!==null;){if(he.callback===null)n(u);else if(he.startTime<=le)n(u),he.sortIndex=he.expirationTime,s(d,he);else break;he=r(u)}}function I(le){if(w=!1,T(le),!b)if(r(d)!==null)b=!0,re(L);else{var he=r(u);he!==null&&ae(I,he.startTime-le)}}function L(le,he){b=!1,w&&(w=!1,k(q),q=-1),_=!0;var be=y;try{for(T(he),f=r(d);f!==null&&(!(f.expirationTime>he)||le&&!Y());){var _e=f.callback;if(typeof _e=="function"){f.callback=null,y=f.priorityLevel;var je=_e(f.expirationTime<=he);he=t.unstable_now(),typeof je=="function"?f.callback=je:f===r(d)&&n(d),T(he)}else n(d);f=r(d)}if(f!==null)var Ne=!0;else{var Ge=r(u);Ge!==null&&ae(I,Ge.startTime-he),Ne=!1}return Ne}finally{f=null,y=be,_=!1}}var R=!1,$=null,q=-1,U=5,H=-1;function Y(){return!(t.unstable_now()-Hle||125_e?(le.sortIndex=be,s(u,le),r(d)===null&&le===r(u)&&(w?(k(q),q=-1):w=!0,ae(I,be-_e))):(le.sortIndex=je,s(d,le),b||_||(b=!0,re(L))),le},t.unstable_shouldYield=Y,t.unstable_wrapCallback=function(le){var he=y;return function(){var be=y;y=he;try{return le.apply(this,arguments)}finally{y=be}}}})(nOe);rOe.exports=nOe;var Qnt=rOe.exports;/** * @license React * react-dom.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Jnt=C,Sp=Qnt;function Gr(t){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+t,r=1;r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Kpe=Object.prototype.hasOwnProperty,eat=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,eCe={},tCe={};function tat(t){return Kpe.call(tCe,t)?!0:Kpe.call(eCe,t)?!1:eat.test(t)?tCe[t]=!0:(eCe[t]=!0,!1)}function sat(t,s,r,n){if(r!==null&&r.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return n?!1:r!==null?!r.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function rat(t,s,r,n){if(s===null||typeof s>"u"||sat(t,s,r,n))return!0;if(n)return!1;if(r!==null)switch(r.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function Jh(t,s,r,n,a,o,l){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=n,this.attributeNamespace=a,this.mustUseProperty=r,this.propertyName=t,this.type=s,this.sanitizeURL=o,this.removeEmptyString=l}var qu={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){qu[t]=new Jh(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];qu[s]=new Jh(s,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){qu[t]=new Jh(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){qu[t]=new Jh(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){qu[t]=new Jh(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){qu[t]=new Jh(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){qu[t]=new Jh(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){qu[t]=new Jh(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){qu[t]=new Jh(t,5,!1,t.toLowerCase(),null,!1,!1)});var mve=/[\-:]([a-z])/g;function pve(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var s=t.replace(mve,pve);qu[s]=new Jh(s,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var s=t.replace(mve,pve);qu[s]=new Jh(s,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var s=t.replace(mve,pve);qu[s]=new Jh(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){qu[t]=new Jh(t,1,!1,t.toLowerCase(),null,!1,!1)});qu.xlinkHref=new Jh("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){qu[t]=new Jh(t,1,!1,t.toLowerCase(),null,!0,!0)});function fve(t,s,r,n){var a=qu.hasOwnProperty(s)?qu[s]:null;(a!==null?a.type!==0:n||!(2i||a[l]!==o[i]){var d=` `+a[l].replace(" at new "," at ");return t.displayName&&d.includes("")&&(d=d.replace("",t.displayName)),d}while(1<=l&&0<=i);break}}}finally{Wue=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?TE(t):""}function nat(t){switch(t.tag){case 5:return TE(t.type);case 16:return TE("Lazy");case 13:return TE("Suspense");case 19:return TE("SuspenseList");case 0:case 2:case 15:return t=Gue(t.type,!1),t;case 11:return t=Gue(t.type.render,!1),t;case 1:return t=Gue(t.type,!0),t;default:return""}}function Qpe(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case I4:return"Fragment";case P4:return"Portal";case Zpe:return"Profiler";case gve:return"StrictMode";case Ype:return"Suspense";case Xpe:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case oOe:return(t.displayName||"Context")+".Consumer";case iOe:return(t._context.displayName||"Context")+".Provider";case xve:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case yve:return s=t.displayName||null,s!==null?s:Qpe(t.type)||"Memo";case h1:s=t._payload,t=t._init;try{return Qpe(t(s))}catch{}}return null}function aat(t){var s=t.type;switch(t.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=s.render,t=t.displayName||t.name||"",s.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Qpe(s);case 8:return s===gve?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function S_(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function cOe(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function iat(t){var s=cOe(t)?"checked":"value",r=Object.getOwnPropertyDescriptor(t.constructor.prototype,s),n=""+t[s];if(!t.hasOwnProperty(s)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var a=r.get,o=r.set;return Object.defineProperty(t,s,{configurable:!0,get:function(){return a.call(this)},set:function(l){n=""+l,o.call(this,l)}}),Object.defineProperty(t,s,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(l){n=""+l},stopTracking:function(){t._valueTracker=null,delete t[s]}}}}function h8(t){t._valueTracker||(t._valueTracker=iat(t))}function dOe(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var r=s.getValue(),n="";return t&&(n=cOe(t)?t.checked?"true":"false":t.value),t=n,t!==r?(s.setValue(t),!0):!1}function Rre(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Jpe(t,s){var r=s.checked;return Tc({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function rCe(t,s){var r=s.defaultValue==null?"":s.defaultValue,n=s.checked!=null?s.checked:s.defaultChecked;r=S_(s.value!=null?s.value:r),t._wrapperState={initialChecked:n,initialValue:r,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function uOe(t,s){s=s.checked,s!=null&&fve(t,"checked",s,!1)}function efe(t,s){uOe(t,s);var r=S_(s.value),n=s.type;if(r!=null)n==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+r):t.value!==""+r&&(t.value=""+r);else if(n==="submit"||n==="reset"){t.removeAttribute("value");return}s.hasOwnProperty("value")?tfe(t,s.type,r):s.hasOwnProperty("defaultValue")&&tfe(t,s.type,S_(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function nCe(t,s,r){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var n=s.type;if(!(n!=="submit"&&n!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+t._wrapperState.initialValue,r||s===t.value||(t.value=s),t.defaultValue=s}r=t.name,r!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,r!==""&&(t.name=r)}function tfe(t,s,r){(s!=="number"||Rre(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var AE=Array.isArray;function s5(t,s,r,n){if(t=t.options,s){s={};for(var a=0;a"+s.valueOf().toString()+"",s=m8.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function EI(t,s){if(s){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=s;return}}t.textContent=s}var WE={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},oat=["Webkit","ms","Moz","O"];Object.keys(WE).forEach(function(t){oat.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),WE[s]=WE[t]})});function fOe(t,s,r){return s==null||typeof s=="boolean"||s===""?"":r||typeof s!="number"||s===0||WE.hasOwnProperty(t)&&WE[t]?(""+s).trim():s+"px"}function gOe(t,s){t=t.style;for(var r in s)if(s.hasOwnProperty(r)){var n=r.indexOf("--")===0,a=fOe(r,s[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,a):t[r]=a}}var lat=Tc({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function nfe(t,s){if(s){if(lat[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(Gr(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(Gr(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(Gr(61))}if(s.style!=null&&typeof s.style!="object")throw Error(Gr(62))}}function afe(t,s){if(t.indexOf("-")===-1)return typeof s.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ife=null;function vve(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var ofe=null,r5=null,n5=null;function oCe(t){if(t=xL(t)){if(typeof ofe!="function")throw Error(Gr(280));var s=t.stateNode;s&&(s=toe(s),ofe(t.stateNode,t.type,s))}}function xOe(t){r5?n5?n5.push(t):n5=[t]:r5=t}function yOe(){if(r5){var t=r5,s=n5;if(n5=r5=null,oCe(t),s)for(t=0;t>>=0,t===0?32:31-(vat(t)/_at|0)|0}var p8=64,f8=4194304;function EE(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function $re(t,s){var r=t.pendingLanes;if(r===0)return 0;var n=0,a=t.suspendedLanes,o=t.pingedLanes,l=r&268435455;if(l!==0){var i=l&~a;i!==0?n=EE(i):(o&=l,o!==0&&(n=EE(o)))}else l=r&~a,l!==0?n=EE(l):o!==0&&(n=EE(o));if(n===0)return 0;if(s!==0&&s!==n&&!(s&a)&&(a=n&-n,o=s&-s,a>=o||a===16&&(o&4194240)!==0))return s;if(n&4&&(n|=r&16),s=t.entangledLanes,s!==0)for(t=t.entanglements,s&=n;0r;r++)s.push(t);return s}function fL(t,s,r){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-zg(s),t[s]=r}function Nat(t,s){var r=t.pendingLanes&~s;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=s,t.mutableReadLanes&=s,t.entangledLanes&=s,s=t.entanglements;var n=t.eventTimes;for(t=t.expirationTimes;0=KE),gCe=" ",xCe=!1;function FOe(t,s){switch(t){case"keyup":return Qat.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function zOe(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var L4=!1;function eit(t,s){switch(t){case"compositionend":return zOe(s);case"keypress":return s.which!==32?null:(xCe=!0,gCe);case"textInput":return t=s.data,t===gCe&&xCe?null:t;default:return null}}function tit(t,s){if(L4)return t==="compositionend"||!Cve&&FOe(t,s)?(t=OOe(),KR=Nve=z1=null,L4=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:r,offset:s-t};t=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=bCe(r)}}function UOe(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?UOe(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function VOe(){for(var t=window,s=Rre();s instanceof t.HTMLIFrameElement;){try{var r=typeof s.contentWindow.location.href=="string"}catch{r=!1}if(r)t=s.contentWindow;else break;s=Rre(t.document)}return s}function Mve(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s&&(s==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||s==="textarea"||t.contentEditable==="true")}function dit(t){var s=VOe(),r=t.focusedElem,n=t.selectionRange;if(s!==r&&r&&r.ownerDocument&&UOe(r.ownerDocument.documentElement,r)){if(n!==null&&Mve(r)){if(s=n.start,t=n.end,t===void 0&&(t=s),"selectionStart"in r)r.selectionStart=s,r.selectionEnd=Math.min(t,r.value.length);else if(t=(s=r.ownerDocument||document)&&s.defaultView||window,t.getSelection){t=t.getSelection();var a=r.textContent.length,o=Math.min(n.start,a);n=n.end===void 0?o:Math.min(n.end,a),!t.extend&&o>n&&(a=n,n=o,o=a),a=wCe(r,o);var l=wCe(r,n);a&&l&&(t.rangeCount!==1||t.anchorNode!==a.node||t.anchorOffset!==a.offset||t.focusNode!==l.node||t.focusOffset!==l.offset)&&(s=s.createRange(),s.setStart(a.node,a.offset),t.removeAllRanges(),o>n?(t.addRange(s),t.extend(l.node,l.offset)):(s.setEnd(l.node,l.offset),t.addRange(s)))}}for(s=[],t=r;t=t.parentNode;)t.nodeType===1&&s.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r=document.documentMode,D4=null,mfe=null,YE=null,pfe=!1;function jCe(t,s,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;pfe||D4==null||D4!==Rre(n)||(n=D4,"selectionStart"in n&&Mve(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),YE&&RI(YE,n)||(YE=n,n=Vre(mfe,"onSelect"),0F4||(t.current=_fe[F4],_fe[F4]=null,F4--)}function Al(t,s){F4++,_fe[F4]=t.current,t.current=s}var C_={},oh=B_(C_),Tm=B_(!1),Sk=C_;function c3(t,s){var r=t.type.contextTypes;if(!r)return C_;var n=t.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===s)return n.__reactInternalMemoizedMaskedChildContext;var a={},o;for(o in r)a[o]=s[o];return n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=a),a}function Am(t){return t=t.childContextTypes,t!=null}function Wre(){sc(Tm),sc(oh)}function ACe(t,s,r){if(oh.current!==C_)throw Error(Gr(168));Al(oh,s),Al(Tm,r)}function JOe(t,s,r){var n=t.stateNode;if(s=s.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var a in n)if(!(a in s))throw Error(Gr(108,aat(t)||"Unknown",a));return Tc({},r,n)}function Gre(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||C_,Sk=oh.current,Al(oh,t),Al(Tm,Tm.current),!0}function ECe(t,s,r){var n=t.stateNode;if(!n)throw Error(Gr(169));r?(t=JOe(t,s,Sk),n.__reactInternalMemoizedMergedChildContext=t,sc(Tm),sc(oh),Al(oh,t)):sc(Tm),Al(Tm,r)}var u0=null,soe=!1,ohe=!1;function e8e(t){u0===null?u0=[t]:u0.push(t)}function wit(t){soe=!0,e8e(t)}function $_(){if(!ohe&&u0!==null){ohe=!0;var t=0,s=tl;try{var r=u0;for(tl=1;t>=l,a-=l,w0=1<<32-zg(s)+a|r<q?(U=$,$=null):U=$.sibling;var H=y(k,$,T[q],I);if(H===null){$===null&&($=U);break}t&&$&&H.alternate===null&&s(k,$),S=o(H,S,q),R===null?L=H:R.sibling=H,R=H,$=U}if(q===T.length)return r(k,$),fc&&iw(k,q),L;if($===null){for(;qq?(U=$,$=null):U=$.sibling;var Y=y(k,$,H.value,I);if(Y===null){$===null&&($=U);break}t&&$&&Y.alternate===null&&s(k,$),S=o(Y,S,q),R===null?L=Y:R.sibling=Y,R=Y,$=U}if(H.done)return r(k,$),fc&&iw(k,q),L;if($===null){for(;!H.done;q++,H=T.next())H=f(k,H.value,I),H!==null&&(S=o(H,S,q),R===null?L=H:R.sibling=H,R=H);return fc&&iw(k,q),L}for($=n(k,$);!H.done;q++,H=T.next())H=_($,k,q,H.value,I),H!==null&&(t&&H.alternate!==null&&$.delete(H.key===null?q:H.key),S=o(H,S,q),R===null?L=H:R.sibling=H,R=H);return t&&$.forEach(function(se){return s(k,se)}),fc&&iw(k,q),L}function j(k,S,T,I){if(typeof T=="object"&&T!==null&&T.type===I4&&T.key===null&&(T=T.props.children),typeof T=="object"&&T!==null){switch(T.$$typeof){case u8:e:{for(var L=T.key,R=S;R!==null;){if(R.key===L){if(L=T.type,L===I4){if(R.tag===7){r(k,R.sibling),S=a(R,T.props.children),S.return=k,k=S;break e}}else if(R.elementType===L||typeof L=="object"&&L!==null&&L.$$typeof===h1&&LCe(L)===R.type){r(k,R.sibling),S=a(R,T.props),S.ref=XA(k,R,T),S.return=k,k=S;break e}r(k,R);break}else s(k,R);R=R.sibling}T.type===I4?(S=rk(T.props.children,k.mode,I,T.key),S.return=k,k=S):(I=sF(T.type,T.key,T.props,null,k.mode,I),I.ref=XA(k,S,T),I.return=k,k=I)}return l(k);case P4:e:{for(R=T.key;S!==null;){if(S.key===R)if(S.tag===4&&S.stateNode.containerInfo===T.containerInfo&&S.stateNode.implementation===T.implementation){r(k,S.sibling),S=a(S,T.children||[]),S.return=k,k=S;break e}else{r(k,S);break}else s(k,S);S=S.sibling}S=fhe(T,k.mode,I),S.return=k,k=S}return l(k);case h1:return R=T._init,j(k,S,R(T._payload),I)}if(AE(T))return b(k,S,T,I);if(WA(T))return w(k,S,T,I);w8(k,T)}return typeof T=="string"&&T!==""||typeof T=="number"?(T=""+T,S!==null&&S.tag===6?(r(k,S.sibling),S=a(S,T),S.return=k,k=S):(r(k,S),S=phe(T,k.mode,I),S.return=k,k=S),l(k)):r(k,S)}return j}var u3=n8e(!0),a8e=n8e(!1),Yre=B_(null),Xre=null,$4=null,Pve=null;function Ive(){Pve=$4=Xre=null}function Lve(t){var s=Yre.current;sc(Yre),t._currentValue=s}function jfe(t,s,r){for(;t!==null;){var n=t.alternate;if((t.childLanes&s)!==s?(t.childLanes|=s,n!==null&&(n.childLanes|=s)):n!==null&&(n.childLanes&s)!==s&&(n.childLanes|=s),t===r)break;t=t.return}}function i5(t,s){Xre=t,Pve=$4=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&s&&(Nm=!0),t.firstContext=null)}function Sf(t){var s=t._currentValue;if(Pve!==t)if(t={context:t,memoizedValue:s,next:null},$4===null){if(Xre===null)throw Error(Gr(308));$4=t,Xre.dependencies={lanes:0,firstContext:t}}else $4=$4.next=t;return s}var AN=null;function Dve(t){AN===null?AN=[t]:AN.push(t)}function i8e(t,s,r,n){var a=s.interleaved;return a===null?(r.next=r,Dve(s)):(r.next=a.next,a.next=r),s.interleaved=r,J0(t,n)}function J0(t,s){t.lanes|=s;var r=t.alternate;for(r!==null&&(r.lanes|=s),r=t,t=t.return;t!==null;)t.childLanes|=s,r=t.alternate,r!==null&&(r.childLanes|=s),r=t,t=t.return;return r.tag===3?r.stateNode:null}var m1=!1;function Ove(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function o8e(t,s){t=t.updateQueue,s.updateQueue===t&&(s.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function T0(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function J1(t,s,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,So&2){var a=n.pending;return a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s,J0(t,r)}return a=n.interleaved,a===null?(s.next=s,Dve(n)):(s.next=a.next,a.next=s),n.interleaved=s,J0(t,r)}function YR(t,s,r){if(s=s.updateQueue,s!==null&&(s=s.shared,(r&4194240)!==0)){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,bve(t,r)}}function DCe(t,s){var r=t.updateQueue,n=t.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var a=null,o=null;if(r=r.firstBaseUpdate,r!==null){do{var l={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};o===null?a=o=l:o=o.next=l,r=r.next}while(r!==null);o===null?a=o=s:o=o.next=s}else a=o=s;r={baseState:n.baseState,firstBaseUpdate:a,lastBaseUpdate:o,shared:n.shared,effects:n.effects},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=s:t.next=s,r.lastBaseUpdate=s}function Qre(t,s,r,n){var a=t.updateQueue;m1=!1;var o=a.firstBaseUpdate,l=a.lastBaseUpdate,i=a.shared.pending;if(i!==null){a.shared.pending=null;var d=i,u=d.next;d.next=null,l===null?o=u:l.next=u,l=d;var p=t.alternate;p!==null&&(p=p.updateQueue,i=p.lastBaseUpdate,i!==l&&(i===null?p.firstBaseUpdate=u:i.next=u,p.lastBaseUpdate=d))}if(o!==null){var f=a.baseState;l=0,p=u=d=null,i=o;do{var y=i.lane,_=i.eventTime;if((n&y)===y){p!==null&&(p=p.next={eventTime:_,lane:0,tag:i.tag,payload:i.payload,callback:i.callback,next:null});e:{var b=t,w=i;switch(y=s,_=r,w.tag){case 1:if(b=w.payload,typeof b=="function"){f=b.call(_,f,y);break e}f=b;break e;case 3:b.flags=b.flags&-65537|128;case 0:if(b=w.payload,y=typeof b=="function"?b.call(_,f,y):b,y==null)break e;f=Tc({},f,y);break e;case 2:m1=!0}}i.callback!==null&&i.lane!==0&&(t.flags|=64,y=a.effects,y===null?a.effects=[i]:y.push(i))}else _={eventTime:_,lane:y,tag:i.tag,payload:i.payload,callback:i.callback,next:null},p===null?(u=p=_,d=f):p=p.next=_,l|=y;if(i=i.next,i===null){if(i=a.shared.pending,i===null)break;y=i,i=y.next,y.next=null,a.lastBaseUpdate=y,a.shared.pending=null}}while(!0);if(p===null&&(d=f),a.baseState=d,a.firstBaseUpdate=u,a.lastBaseUpdate=p,s=a.shared.interleaved,s!==null){a=s;do l|=a.lane,a=a.next;while(a!==s)}else o===null&&(a.shared.lanes=0);Tk|=l,t.lanes=l,t.memoizedState=f}}function OCe(t,s,r){if(t=s.effects,s.effects=null,t!==null)for(s=0;sr?r:4,t(!0);var n=che.transition;che.transition={};try{t(!1),s()}finally{tl=r,che.transition=n}}function N8e(){return Cf().memoizedState}function Sit(t,s,r){var n=t_(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},k8e(t))S8e(s,r);else if(r=i8e(t,s,r,n),r!==null){var a=qh();Bg(r,t,n,a),C8e(r,s,n)}}function Cit(t,s,r){var n=t_(t),a={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(k8e(t))S8e(s,a);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=s.lastRenderedReducer,o!==null))try{var l=s.lastRenderedState,i=o(l,r);if(a.hasEagerState=!0,a.eagerState=i,Zg(i,l)){var d=s.interleaved;d===null?(a.next=a,Dve(s)):(a.next=d.next,d.next=a),s.interleaved=a;return}}catch{}finally{}r=i8e(t,s,a,n),r!==null&&(a=qh(),Bg(r,t,n,a),C8e(r,s,n))}}function k8e(t){var s=t.alternate;return t===Mc||s!==null&&s===Mc}function S8e(t,s){XE=ene=!0;var r=t.pending;r===null?s.next=s:(s.next=r.next,r.next=s),t.pending=s}function C8e(t,s,r){if(r&4194240){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,bve(t,r)}}var tne={readContext:Sf,useCallback:Gu,useContext:Gu,useEffect:Gu,useImperativeHandle:Gu,useInsertionEffect:Gu,useLayoutEffect:Gu,useMemo:Gu,useReducer:Gu,useRef:Gu,useState:Gu,useDebugValue:Gu,useDeferredValue:Gu,useTransition:Gu,useMutableSource:Gu,useSyncExternalStore:Gu,useId:Gu,unstable_isNewReconciler:!1},Mit={readContext:Sf,useCallback:function(t,s){return Tx().memoizedState=[t,s===void 0?null:s],t},useContext:Sf,useEffect:FCe,useImperativeHandle:function(t,s,r){return r=r!=null?r.concat([t]):null,QR(4194308,4,v8e.bind(null,s,t),r)},useLayoutEffect:function(t,s){return QR(4194308,4,t,s)},useInsertionEffect:function(t,s){return QR(4,2,t,s)},useMemo:function(t,s){var r=Tx();return s=s===void 0?null:s,t=t(),r.memoizedState=[t,s],t},useReducer:function(t,s,r){var n=Tx();return s=r!==void 0?r(s):s,n.memoizedState=n.baseState=s,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:s},n.queue=t,t=t.dispatch=Sit.bind(null,Mc,t),[n.memoizedState,t]},useRef:function(t){var s=Tx();return t={current:t},s.memoizedState=t},useState:RCe,useDebugValue:Vve,useDeferredValue:function(t){return Tx().memoizedState=t},useTransition:function(){var t=RCe(!1),s=t[0];return t=kit.bind(null,t[1]),Tx().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,r){var n=Mc,a=Tx();if(fc){if(r===void 0)throw Error(Gr(407));r=r()}else{if(r=s(),pu===null)throw Error(Gr(349));Mk&30||u8e(n,s,r)}a.memoizedState=r;var o={value:r,getSnapshot:s};return a.queue=o,FCe(m8e.bind(null,n,o,t),[t]),n.flags|=2048,HI(9,h8e.bind(null,n,o,r,s),void 0,null),r},useId:function(){var t=Tx(),s=pu.identifierPrefix;if(fc){var r=j0,n=w0;r=(n&~(1<<32-zg(n)-1)).toString(32)+r,s=":"+s+"R"+r,r=UI++,0<\/script>",t=t.removeChild(t.firstChild)):typeof n.is=="string"?t=l.createElement(r,{is:n.is}):(t=l.createElement(r),r==="select"&&(l=t,n.multiple?l.multiple=!0:n.size&&(l.size=n.size))):t=l.createElementNS(t,r),t[Bx]=s,t[BI]=n,R8e(t,s,!1,!1),s.stateNode=t;e:{switch(l=afe(r,n),r){case"dialog":Yl("cancel",t),Yl("close",t),a=n;break;case"iframe":case"object":case"embed":Yl("load",t),a=n;break;case"video":case"audio":for(a=0;ap3&&(s.flags|=128,n=!0,QA(o,!1),s.lanes=4194304)}else{if(!n)if(t=Jre(l),t!==null){if(s.flags|=128,n=!0,r=t.updateQueue,r!==null&&(s.updateQueue=r,s.flags|=4),QA(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!fc)return Ku(s),null}else 2*rd()-o.renderingStartTime>p3&&r!==1073741824&&(s.flags|=128,n=!0,QA(o,!1),s.lanes=4194304);o.isBackwards?(l.sibling=s.child,s.child=l):(r=o.last,r!==null?r.sibling=l:s.child=l,o.last=l)}return o.tail!==null?(s=o.tail,o.rendering=s,o.tail=s.sibling,o.renderingStartTime=rd(),s.sibling=null,r=Nc.current,Al(Nc,n?r&1|2:r&1),s):(Ku(s),null);case 22:case 23:return Yve(),n=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(s.flags|=8192),n&&s.mode&1?ap&1073741824&&(Ku(s),s.subtreeFlags&6&&(s.flags|=8192)):Ku(s),null;case 24:return null;case 25:return null}throw Error(Gr(156,s.tag))}function Oit(t,s){switch(Ave(s),s.tag){case 1:return Am(s.type)&&Wre(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return h3(),sc(Tm),sc(oh),zve(),t=s.flags,t&65536&&!(t&128)?(s.flags=t&-65537|128,s):null;case 5:return Fve(s),null;case 13:if(sc(Nc),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(Gr(340));d3()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return sc(Nc),null;case 4:return h3(),null;case 10:return Lve(s.type._context),null;case 22:case 23:return Yve(),null;case 24:return null;default:return null}}var N8=!1,Qu=!1,Rit=typeof WeakSet=="function"?WeakSet:Set,Yn=null;function q4(t,s){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){zc(t,s,n)}else r.current=null}function Pfe(t,s,r){try{r()}catch(n){zc(t,s,n)}}var ZCe=!1;function Fit(t,s){if(ffe=qre,t=VOe(),Mve(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var a=n.anchorOffset,o=n.focusNode;n=n.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break e}var l=0,i=-1,d=-1,u=0,p=0,f=t,y=null;t:for(;;){for(var _;f!==r||a!==0&&f.nodeType!==3||(i=l+a),f!==o||n!==0&&f.nodeType!==3||(d=l+n),f.nodeType===3&&(l+=f.nodeValue.length),(_=f.firstChild)!==null;)y=f,f=_;for(;;){if(f===t)break t;if(y===r&&++u===a&&(i=l),y===o&&++p===n&&(d=l),(_=f.nextSibling)!==null)break;f=y,y=f.parentNode}f=_}r=i===-1||d===-1?null:{start:i,end:d}}else r=null}r=r||{start:0,end:0}}else r=null;for(gfe={focusedElem:t,selectionRange:r},qre=!1,Yn=s;Yn!==null;)if(s=Yn,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,Yn=t;else for(;Yn!==null;){s=Yn;try{var b=s.alternate;if(s.flags&1024)switch(s.tag){case 0:case 11:case 15:break;case 1:if(b!==null){var w=b.memoizedProps,j=b.memoizedState,k=s.stateNode,S=k.getSnapshotBeforeUpdate(s.elementType===s.type?w:wg(s.type,w),j);k.__reactInternalSnapshotBeforeUpdate=S}break;case 3:var T=s.stateNode.containerInfo;T.nodeType===1?T.textContent="":T.nodeType===9&&T.documentElement&&T.removeChild(T.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Gr(163))}}catch(I){zc(s,s.return,I)}if(t=s.sibling,t!==null){t.return=s.return,Yn=t;break}Yn=s.return}return b=ZCe,ZCe=!1,b}function QE(t,s,r){var n=s.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var a=n=n.next;do{if((a.tag&t)===t){var o=a.destroy;a.destroy=void 0,o!==void 0&&Pfe(s,r,o)}a=a.next}while(a!==n)}}function aoe(t,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var r=s=s.next;do{if((r.tag&t)===t){var n=r.create;r.destroy=n()}r=r.next}while(r!==s)}}function Ife(t){var s=t.ref;if(s!==null){var r=t.stateNode;switch(t.tag){case 5:t=r;break;default:t=r}typeof s=="function"?s(t):s.current=t}}function B8e(t){var s=t.alternate;s!==null&&(t.alternate=null,B8e(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[Bx],delete s[BI],delete s[vfe],delete s[_it],delete s[bit])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function $8e(t){return t.tag===5||t.tag===3||t.tag===4}function YCe(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||$8e(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Lfe(t,s,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,s?r.nodeType===8?r.parentNode.insertBefore(t,s):r.insertBefore(t,s):(r.nodeType===8?(s=r.parentNode,s.insertBefore(t,r)):(s=r,s.appendChild(t)),r=r._reactRootContainer,r!=null||s.onclick!==null||(s.onclick=Hre));else if(n!==4&&(t=t.child,t!==null))for(Lfe(t,s,r),t=t.sibling;t!==null;)Lfe(t,s,r),t=t.sibling}function Dfe(t,s,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,s?r.insertBefore(t,s):r.appendChild(t);else if(n!==4&&(t=t.child,t!==null))for(Dfe(t,s,r),t=t.sibling;t!==null;)Dfe(t,s,r),t=t.sibling}var Eu=null,Sg=!1;function Qv(t,s,r){for(r=r.child;r!==null;)q8e(t,s,r),r=r.sibling}function q8e(t,s,r){if(Gx&&typeof Gx.onCommitFiberUnmount=="function")try{Gx.onCommitFiberUnmount(Xie,r)}catch{}switch(r.tag){case 5:Qu||q4(r,s);case 6:var n=Eu,a=Sg;Eu=null,Qv(t,s,r),Eu=n,Sg=a,Eu!==null&&(Sg?(t=Eu,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):Eu.removeChild(r.stateNode));break;case 18:Eu!==null&&(Sg?(t=Eu,r=r.stateNode,t.nodeType===8?ihe(t.parentNode,r):t.nodeType===1&&ihe(t,r),DI(t)):ihe(Eu,r.stateNode));break;case 4:n=Eu,a=Sg,Eu=r.stateNode.containerInfo,Sg=!0,Qv(t,s,r),Eu=n,Sg=a;break;case 0:case 11:case 14:case 15:if(!Qu&&(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){a=n=n.next;do{var o=a,l=o.destroy;o=o.tag,l!==void 0&&(o&2||o&4)&&Pfe(r,s,l),a=a.next}while(a!==n)}Qv(t,s,r);break;case 1:if(!Qu&&(q4(r,s),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(i){zc(r,s,i)}Qv(t,s,r);break;case 21:Qv(t,s,r);break;case 22:r.mode&1?(Qu=(n=Qu)||r.memoizedState!==null,Qv(t,s,r),Qu=n):Qv(t,s,r);break;default:Qv(t,s,r)}}function XCe(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new Rit),s.forEach(function(n){var a=Git.bind(null,t,n);r.has(n)||(r.add(n),n.then(a,a))})}}function mg(t,s){var r=s.deletions;if(r!==null)for(var n=0;na&&(a=l),n&=~o}if(n=a,n=rd()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*Bit(n/1960))-n,10t?16:t,B1===null)var n=!1;else{if(t=B1,B1=null,nne=0,So&6)throw Error(Gr(331));var a=So;for(So|=4,Yn=t.current;Yn!==null;){var o=Yn,l=o.child;if(Yn.flags&16){var i=o.deletions;if(i!==null){for(var d=0;drd()-Kve?sk(t,0):Gve|=r),Em(t,s)}function Y8e(t,s){s===0&&(t.mode&1?(s=f8,f8<<=1,!(f8&130023424)&&(f8=4194304)):s=1);var r=qh();t=J0(t,s),t!==null&&(fL(t,s,r),Em(t,r))}function Wit(t){var s=t.memoizedState,r=0;s!==null&&(r=s.retryLane),Y8e(t,r)}function Git(t,s){var r=0;switch(t.tag){case 13:var n=t.stateNode,a=t.memoizedState;a!==null&&(r=a.retryLane);break;case 19:n=t.stateNode;break;default:throw Error(Gr(314))}n!==null&&n.delete(s),Y8e(t,r)}var X8e;X8e=function(t,s,r){if(t!==null)if(t.memoizedProps!==s.pendingProps||Tm.current)Nm=!0;else{if(!(t.lanes&r)&&!(s.flags&128))return Nm=!1,Lit(t,s,r);Nm=!!(t.flags&131072)}else Nm=!1,fc&&s.flags&1048576&&t8e(s,Zre,s.index);switch(s.lanes=0,s.tag){case 2:var n=s.type;JR(t,s),t=s.pendingProps;var a=c3(s,oh.current);i5(s,r),a=$ve(null,s,n,t,a,r);var o=qve();return s.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Am(n)?(o=!0,Gre(s)):o=!1,s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Ove(s),a.updater=noe,s.stateNode=a,a._reactInternals=s,kfe(s,n,t,r),s=Mfe(null,s,n,!0,o,r)):(s.tag=0,fc&&o&&Tve(s),Ah(null,s,a,r),s=s.child),s;case 16:n=s.elementType;e:{switch(JR(t,s),t=s.pendingProps,a=n._init,n=a(n._payload),s.type=n,a=s.tag=Zit(n),t=wg(n,t),a){case 0:s=Cfe(null,s,n,t,r);break e;case 1:s=WCe(null,s,n,t,r);break e;case 11:s=VCe(null,s,n,t,r);break e;case 14:s=HCe(null,s,n,wg(n.type,t),r);break e}throw Error(Gr(306,n,""))}return s;case 0:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:wg(n,a),Cfe(t,s,n,a,r);case 1:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:wg(n,a),WCe(t,s,n,a,r);case 3:e:{if(L8e(s),t===null)throw Error(Gr(387));n=s.pendingProps,o=s.memoizedState,a=o.element,o8e(t,s),Qre(s,n,null,r);var l=s.memoizedState;if(n=l.element,o.isDehydrated)if(o={element:n,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},s.updateQueue.baseState=o,s.memoizedState=o,s.flags&256){a=m3(Error(Gr(423)),s),s=GCe(t,s,n,r,a);break e}else if(n!==a){a=m3(Error(Gr(424)),s),s=GCe(t,s,n,r,a);break e}else for(fp=Q1(s.stateNode.containerInfo.firstChild),xp=s,fc=!0,Eg=null,r=a8e(s,null,n,r),s.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(d3(),n===a){s=ev(t,s,r);break e}Ah(t,s,n,r)}s=s.child}return s;case 5:return l8e(s),t===null&&wfe(s),n=s.type,a=s.pendingProps,o=t!==null?t.memoizedProps:null,l=a.children,xfe(n,a)?l=null:o!==null&&xfe(n,o)&&(s.flags|=32),I8e(t,s),Ah(t,s,l,r),s.child;case 6:return t===null&&wfe(s),null;case 13:return D8e(t,s,r);case 4:return Rve(s,s.stateNode.containerInfo),n=s.pendingProps,t===null?s.child=u3(s,null,n,r):Ah(t,s,n,r),s.child;case 11:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:wg(n,a),VCe(t,s,n,a,r);case 7:return Ah(t,s,s.pendingProps,r),s.child;case 8:return Ah(t,s,s.pendingProps.children,r),s.child;case 12:return Ah(t,s,s.pendingProps.children,r),s.child;case 10:e:{if(n=s.type._context,a=s.pendingProps,o=s.memoizedProps,l=a.value,Al(Yre,n._currentValue),n._currentValue=l,o!==null)if(Zg(o.value,l)){if(o.children===a.children&&!Tm.current){s=ev(t,s,r);break e}}else for(o=s.child,o!==null&&(o.return=s);o!==null;){var i=o.dependencies;if(i!==null){l=o.child;for(var d=i.firstContext;d!==null;){if(d.context===n){if(o.tag===1){d=T0(-1,r&-r),d.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?d.next=d:(d.next=p.next,p.next=d),u.pending=d}}o.lanes|=r,d=o.alternate,d!==null&&(d.lanes|=r),jfe(o.return,r,s),i.lanes|=r;break}d=d.next}}else if(o.tag===10)l=o.type===s.type?null:o.child;else if(o.tag===18){if(l=o.return,l===null)throw Error(Gr(341));l.lanes|=r,i=l.alternate,i!==null&&(i.lanes|=r),jfe(l,r,s),l=o.sibling}else l=o.child;if(l!==null)l.return=o;else for(l=o;l!==null;){if(l===s){l=null;break}if(o=l.sibling,o!==null){o.return=l.return,l=o;break}l=l.return}o=l}Ah(t,s,a.children,r),s=s.child}return s;case 9:return a=s.type,n=s.pendingProps.children,i5(s,r),a=Sf(a),n=n(a),s.flags|=1,Ah(t,s,n,r),s.child;case 14:return n=s.type,a=wg(n,s.pendingProps),a=wg(n.type,a),HCe(t,s,n,a,r);case 15:return E8e(t,s,s.type,s.pendingProps,r);case 17:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:wg(n,a),JR(t,s),s.tag=1,Am(n)?(t=!0,Gre(s)):t=!1,i5(s,r),M8e(s,n,a),kfe(s,n,a,r),Mfe(null,s,n,!0,t,r);case 19:return O8e(t,s,r);case 22:return P8e(t,s,r)}throw Error(Gr(156,s.tag))};function Q8e(t,s){return kOe(t,s)}function Kit(t,s,r,n){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function hf(t,s,r,n){return new Kit(t,s,r,n)}function Qve(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Zit(t){if(typeof t=="function")return Qve(t)?1:0;if(t!=null){if(t=t.$$typeof,t===xve)return 11;if(t===yve)return 14}return 2}function s_(t,s){var r=t.alternate;return r===null?(r=hf(t.tag,s,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=s,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&14680064,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,s=t.dependencies,r.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r}function sF(t,s,r,n,a,o){var l=2;if(n=t,typeof t=="function")Qve(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case I4:return rk(r.children,a,o,s);case gve:l=8,a|=8;break;case Zpe:return t=hf(12,r,s,a|2),t.elementType=Zpe,t.lanes=o,t;case Ype:return t=hf(13,r,s,a),t.elementType=Ype,t.lanes=o,t;case Xpe:return t=hf(19,r,s,a),t.elementType=Xpe,t.lanes=o,t;case lOe:return ooe(r,a,o,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case iOe:l=10;break e;case oOe:l=9;break e;case xve:l=11;break e;case yve:l=14;break e;case h1:l=16,n=null;break e}throw Error(Gr(130,t==null?t:typeof t,""))}return s=hf(l,r,s,a),s.elementType=t,s.type=n,s.lanes=o,s}function rk(t,s,r,n){return t=hf(7,t,n,s),t.lanes=r,t}function ooe(t,s,r,n){return t=hf(22,t,n,s),t.elementType=lOe,t.lanes=r,t.stateNode={isHidden:!1},t}function phe(t,s,r){return t=hf(6,t,null,s),t.lanes=r,t}function fhe(t,s,r){return s=hf(4,t.children!==null?t.children:[],t.key,s),s.lanes=r,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function Yit(t,s,r,n,a){this.tag=s,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Zue(0),this.expirationTimes=Zue(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zue(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function Jve(t,s,r,n,a,o,l,i,d){return t=new Yit(t,s,r,i,d),s===1?(s=1,o===!0&&(s|=8)):s=0,o=hf(3,null,null,s),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ove(o),t}function Xit(t,s,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(sRe)}catch(t){console.error(t)}}sRe(),sOe.exports=Mp;var km=sOe.exports;const r1e=_o(km);var rRe,a4e=km;rRe=a4e.createRoot,a4e.hydrateRoot;const sot="modulepreload",rot=function(t){return"/"+t},i4e={},hh=function(s,r,n){let a=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),i=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));a=Promise.allSettled(r.map(d=>{if(d=rot(d),d in i4e)return;i4e[d]=!0;const u=d.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":sot,u||(f.as="script"),f.crossOrigin="",f.href=d,i&&f.setAttribute("nonce",i),document.head.appendChild(f),u)return new Promise((y,_)=>{f.addEventListener("load",y),f.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${d}`)))})}))}function o(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return a.then(l=>{for(const i of l||[])i.status==="rejected"&&o(i.reason);return s().catch(o)})},not=1,aot=1e6;let ghe=0;function iot(){return ghe=(ghe+1)%Number.MAX_SAFE_INTEGER,ghe.toString()}const xhe=new Map,o4e=t=>{if(xhe.has(t))return;const s=setTimeout(()=>{xhe.delete(t),tP({type:"REMOVE_TOAST",toastId:t})},aot);xhe.set(t,s)},oot=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,not)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(r=>r.id===s.toast.id?{...r,...s.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=s;return r?o4e(r):t.toasts.forEach(n=>{o4e(n.id)}),{...t,toasts:t.toasts.map(n=>n.id===r||r===void 0?{...n,open:!1}:n)}}case"REMOVE_TOAST":return s.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(r=>r.id!==s.toastId)}}},rF=[];let nF={toasts:[]};function tP(t){nF=oot(nF,t),rF.forEach(s=>{s(nF)})}function pn({...t}){const s=iot(),r=a=>tP({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>tP({type:"DISMISS_TOAST",toastId:s});return tP({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function Pa(){const[t,s]=C.useState(nF);return C.useEffect(()=>(rF.push(s),()=>{const r=rF.indexOf(s);r>-1&&rF.splice(r,1)}),[t]),{...t,toast:pn,dismiss:r=>tP({type:"DISMISS_TOAST",toastId:r})}}function Mr(t,s,{checkForDefaultPrevented:r=!0}={}){return function(a){if(t==null||t(a),r===!1||!a.defaultPrevented)return s==null?void 0:s(a)}}function l4e(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function tv(...t){return s=>{let r=!1;const n=t.map(a=>{const o=l4e(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{children:l,...i}=o,d=C.useMemo(()=>i,Object.values(i));return e.jsx(r.Provider,{value:d,children:l})};n.displayName=t+"Provider";function a(o){const l=C.useContext(r);if(l)return l;if(s!==void 0)return s;throw new Error(`\`${o}\` must be used within \`${t}\``)}return[n,a]}function Ec(t,s=[]){let r=[];function n(o,l){const i=C.createContext(l),d=r.length;r=[...r,l];const u=f=>{var k;const{scope:y,children:_,...b}=f,w=((k=y==null?void 0:y[t])==null?void 0:k[d])||i,j=C.useMemo(()=>b,Object.values(b));return e.jsx(w.Provider,{value:j,children:_})};u.displayName=o+"Provider";function p(f,y){var w;const _=((w=y==null?void 0:y[t])==null?void 0:w[d])||i,b=C.useContext(_);if(b)return b;if(l!==void 0)return l;throw new Error(`\`${f}\` must be used within \`${o}\``)}return[u,p]}const a=()=>{const o=r.map(l=>C.createContext(l));return function(i){const d=(i==null?void 0:i[t])||o;return C.useMemo(()=>({[`__scope${t}`]:{...i,[t]:d}}),[i,d])}};return a.scopeName=t,[n,cot(a,...s)]}function cot(...t){const s=t[0];if(t.length===1)return s;const r=()=>{const n=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(o){const l=n.reduce((i,{useScope:d,scopeName:u})=>{const f=d(o)[`__scope${u}`];return{...i,...f}},{});return C.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return r.scopeName=s.scopeName,r}function M_(t){const s=dot(t),r=C.forwardRef((n,a)=>{const{children:o,...l}=n,i=C.Children.toArray(o),d=i.find(uot);if(d){const u=d.props.children,p=i.map(f=>f===d?C.Children.count(u)>1?C.Children.only(null):C.isValidElement(u)?u.props.children:null:f);return e.jsx(s,{...l,ref:a,children:C.isValidElement(u)?C.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}var n1e=M_("Slot");function dot(t){const s=C.forwardRef((r,n)=>{const{children:a,...o}=r;if(C.isValidElement(a)){const l=mot(a),i=hot(o,a.props);return a.type!==C.Fragment&&(i.ref=n?tv(n,l):l),C.cloneElement(a,i)}return C.Children.count(a)>1?C.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var nRe=Symbol("radix.slottable");function aRe(t){const s=({children:r})=>e.jsx(e.Fragment,{children:r});return s.displayName=`${t}.Slottable`,s.__radixId=nRe,s}function uot(t){return C.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===nRe}function hot(t,s){const r={...s};for(const n in s){const a=t[n],o=s[n];/^on[A-Z]/.test(n)?a&&o?r[n]=(...i)=>{const d=o(...i);return a(...i),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...o}:n==="className"&&(r[n]=[a,o].filter(Boolean).join(" "))}return{...t,...r}}function mot(t){var n,a;let s=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}function vL(t){const s=t+"CollectionProvider",[r,n]=Ec(s),[a,o]=r(s,{collectionRef:{current:null},itemMap:new Map}),l=w=>{const{scope:j,children:k}=w,S=ht.useRef(null),T=ht.useRef(new Map).current;return e.jsx(a,{scope:j,itemMap:T,collectionRef:S,children:k})};l.displayName=s;const i=t+"CollectionSlot",d=M_(i),u=ht.forwardRef((w,j)=>{const{scope:k,children:S}=w,T=o(i,k),I=Ea(j,T.collectionRef);return e.jsx(d,{ref:I,children:S})});u.displayName=i;const p=t+"CollectionItemSlot",f="data-radix-collection-item",y=M_(p),_=ht.forwardRef((w,j)=>{const{scope:k,children:S,...T}=w,I=ht.useRef(null),L=Ea(j,I),R=o(p,k);return ht.useEffect(()=>(R.itemMap.set(I,{ref:I,...T}),()=>void R.itemMap.delete(I))),e.jsx(y,{[f]:"",ref:L,children:S})});_.displayName=p;function b(w){const j=o(t+"CollectionConsumer",w);return ht.useCallback(()=>{const S=j.collectionRef.current;if(!S)return[];const T=Array.from(S.querySelectorAll(`[${f}]`));return Array.from(j.itemMap.values()).sort((R,$)=>T.indexOf(R.ref.current)-T.indexOf($.ref.current))},[j.collectionRef,j.itemMap])}return[{Provider:l,Slot:u,ItemSlot:_},b,n]}var pot=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Qr=pot.reduce((t,s)=>{const r=M_(`Primitive.${s}`),n=C.forwardRef((a,o)=>{const{asChild:l,...i}=a,d=l?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(d,{...i,ref:o})});return n.displayName=`Primitive.${s}`,{...t,[s]:n}},{});function a1e(t,s){t&&km.flushSync(()=>t.dispatchEvent(s))}function Vc(t){const s=C.useRef(t);return C.useEffect(()=>{s.current=t}),C.useMemo(()=>(...r)=>{var n;return(n=s.current)==null?void 0:n.call(s,...r)},[])}function fot(t,s=globalThis==null?void 0:globalThis.document){const r=Vc(t);C.useEffect(()=>{const n=a=>{a.key==="Escape"&&r(a)};return s.addEventListener("keydown",n,{capture:!0}),()=>s.removeEventListener("keydown",n,{capture:!0})},[r,s])}var got="DismissableLayer",Bfe="dismissableLayer.update",xot="dismissableLayer.pointerDownOutside",yot="dismissableLayer.focusOutside",c4e,iRe=C.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),q_=C.forwardRef((t,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:i,...d}=t,u=C.useContext(iRe),[p,f]=C.useState(null),y=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,_]=C.useState({}),b=Ea(s,$=>f($)),w=Array.from(u.layers),[j]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),k=w.indexOf(j),S=p?w.indexOf(p):-1,T=u.layersWithOutsidePointerEventsDisabled.size>0,I=S>=k,L=_ot($=>{const q=$.target,U=[...u.branches].some(H=>H.contains(q));!I||U||(a==null||a($),l==null||l($),$.defaultPrevented||i==null||i())},y),R=bot($=>{const q=$.target;[...u.branches].some(H=>H.contains(q))||(o==null||o($),l==null||l($),$.defaultPrevented||i==null||i())},y);return fot($=>{S===u.layers.size-1&&(n==null||n($),!$.defaultPrevented&&i&&($.preventDefault(),i()))},y),C.useEffect(()=>{if(p)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(c4e=y.body.style.pointerEvents,y.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),d4e(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(y.body.style.pointerEvents=c4e)}},[p,y,r,u]),C.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),d4e())},[p,u]),C.useEffect(()=>{const $=()=>_({});return document.addEventListener(Bfe,$),()=>document.removeEventListener(Bfe,$)},[]),e.jsx(Qr.div,{...d,ref:b,style:{pointerEvents:T?I?"auto":"none":void 0,...t.style},onFocusCapture:Mr(t.onFocusCapture,R.onFocusCapture),onBlurCapture:Mr(t.onBlurCapture,R.onBlurCapture),onPointerDownCapture:Mr(t.onPointerDownCapture,L.onPointerDownCapture)})});q_.displayName=got;var vot="DismissableLayerBranch",oRe=C.forwardRef((t,s)=>{const r=C.useContext(iRe),n=C.useRef(null),a=Ea(s,n);return C.useEffect(()=>{const o=n.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),e.jsx(Qr.div,{...t,ref:a})});oRe.displayName=vot;function _ot(t,s=globalThis==null?void 0:globalThis.document){const r=Vc(t),n=C.useRef(!1),a=C.useRef(()=>{});return C.useEffect(()=>{const o=i=>{if(i.target&&!n.current){let d=function(){lRe(xot,r,u,{discrete:!0})};const u={originalEvent:i};i.pointerType==="touch"?(s.removeEventListener("click",a.current),a.current=d,s.addEventListener("click",a.current,{once:!0})):d()}else s.removeEventListener("click",a.current);n.current=!1},l=window.setTimeout(()=>{s.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(l),s.removeEventListener("pointerdown",o),s.removeEventListener("click",a.current)}},[s,r]),{onPointerDownCapture:()=>n.current=!0}}function bot(t,s=globalThis==null?void 0:globalThis.document){const r=Vc(t),n=C.useRef(!1);return C.useEffect(()=>{const a=o=>{o.target&&!n.current&&lRe(yot,r,{originalEvent:o},{discrete:!1})};return s.addEventListener("focusin",a),()=>s.removeEventListener("focusin",a)},[s,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function d4e(){const t=new CustomEvent(Bfe);document.dispatchEvent(t)}function lRe(t,s,r,{discrete:n}){const a=r.originalEvent.target,o=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:r});s&&a.addEventListener(t,s,{once:!0}),n?a1e(a,o):a.dispatchEvent(o)}var wot=q_,jot=oRe,Zc=globalThis!=null&&globalThis.document?C.useLayoutEffect:()=>{},Not="Portal",hM=C.forwardRef((t,s)=>{var i;const{container:r,...n}=t,[a,o]=C.useState(!1);Zc(()=>o(!0),[]);const l=r||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return l?r1e.createPortal(e.jsx(Qr.div,{...n,ref:s}),l):null});hM.displayName=Not;function kot(t,s){return C.useReducer((r,n)=>s[r][n]??r,t)}var ud=t=>{const{present:s,children:r}=t,n=Sot(s),a=typeof r=="function"?r({present:n.isPresent}):C.Children.only(r),o=Ea(n.ref,Cot(a));return typeof r=="function"||n.isPresent?C.cloneElement(a,{ref:o}):null};ud.displayName="Presence";function Sot(t){const[s,r]=C.useState(),n=C.useRef(null),a=C.useRef(t),o=C.useRef("none"),l=t?"mounted":"unmounted",[i,d]=kot(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return C.useEffect(()=>{const u=C8(n.current);o.current=i==="mounted"?u:"none"},[i]),Zc(()=>{const u=n.current,p=a.current;if(p!==t){const y=o.current,_=C8(u);t?d("MOUNT"):_==="none"||(u==null?void 0:u.display)==="none"?d("UNMOUNT"):d(p&&y!==_?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,d]),Zc(()=>{if(s){let u;const p=s.ownerDocument.defaultView??window,f=_=>{const w=C8(n.current).includes(_.animationName);if(_.target===s&&w&&(d("ANIMATION_END"),!a.current)){const j=s.style.animationFillMode;s.style.animationFillMode="forwards",u=p.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=j)})}},y=_=>{_.target===s&&(o.current=C8(n.current))};return s.addEventListener("animationstart",y),s.addEventListener("animationcancel",f),s.addEventListener("animationend",f),()=>{p.clearTimeout(u),s.removeEventListener("animationstart",y),s.removeEventListener("animationcancel",f),s.removeEventListener("animationend",f)}}else d("ANIMATION_END")},[s,d]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:C.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function C8(t){return(t==null?void 0:t.animationName)||"none"}function Cot(t){var n,a;let s=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var Mot=hve[" useInsertionEffect ".trim().toString()]||Zc;function vu({prop:t,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,o,l]=Tot({defaultProp:s,onChange:r}),i=t!==void 0,d=i?t:a;{const p=C.useRef(t!==void 0);C.useEffect(()=>{const f=p.current;f!==i&&console.warn(`${n} is changing from ${f?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=i},[i,n])}const u=C.useCallback(p=>{var f;if(i){const y=Aot(p)?p(t):p;y!==t&&((f=l.current)==null||f.call(l,y))}else o(p)},[i,t,o,l]);return[d,u]}function Tot({defaultProp:t,onChange:s}){const[r,n]=C.useState(t),a=C.useRef(r),o=C.useRef(s);return Mot(()=>{o.current=s},[s]),C.useEffect(()=>{var l;a.current!==r&&((l=o.current)==null||l.call(o,r),a.current=r)},[r,a]),[r,n,o]}function Aot(t){return typeof t=="function"}var cRe=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Eot="VisuallyHidden",hoe=C.forwardRef((t,s)=>e.jsx(Qr.span,{...t,ref:s,style:{...cRe,...t.style}}));hoe.displayName=Eot;var Pot=hoe,i1e="ToastProvider",[o1e,Iot,Lot]=vL("Toast"),[dRe]=Ec("Toast",[Lot]),[Dot,moe]=dRe(i1e),uRe=t=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:o=50,children:l}=t,[i,d]=C.useState(null),[u,p]=C.useState(0),f=C.useRef(!1),y=C.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${i1e}\`. Expected non-empty \`string\`.`),e.jsx(o1e.Provider,{scope:s,children:e.jsx(Dot,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:u,viewport:i,onViewportChange:d,onToastAdd:C.useCallback(()=>p(_=>_+1),[]),onToastRemove:C.useCallback(()=>p(_=>_-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:y,children:l})})};uRe.displayName=i1e;var hRe="ToastViewport",Oot=["F8"],$fe="toast.viewportPause",qfe="toast.viewportResume",mRe=C.forwardRef((t,s)=>{const{__scopeToast:r,hotkey:n=Oot,label:a="Notifications ({hotkey})",...o}=t,l=moe(hRe,r),i=Iot(r),d=C.useRef(null),u=C.useRef(null),p=C.useRef(null),f=C.useRef(null),y=Ea(s,f,l.onViewportChange),_=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),b=l.toastCount>0;C.useEffect(()=>{const j=k=>{var T;n.length!==0&&n.every(I=>k[I]||k.code===I)&&((T=f.current)==null||T.focus())};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[n]),C.useEffect(()=>{const j=d.current,k=f.current;if(b&&j&&k){const S=()=>{if(!l.isClosePausedRef.current){const R=new CustomEvent($fe);k.dispatchEvent(R),l.isClosePausedRef.current=!0}},T=()=>{if(l.isClosePausedRef.current){const R=new CustomEvent(qfe);k.dispatchEvent(R),l.isClosePausedRef.current=!1}},I=R=>{!j.contains(R.relatedTarget)&&T()},L=()=>{j.contains(document.activeElement)||T()};return j.addEventListener("focusin",S),j.addEventListener("focusout",I),j.addEventListener("pointermove",S),j.addEventListener("pointerleave",L),window.addEventListener("blur",S),window.addEventListener("focus",T),()=>{j.removeEventListener("focusin",S),j.removeEventListener("focusout",I),j.removeEventListener("pointermove",S),j.removeEventListener("pointerleave",L),window.removeEventListener("blur",S),window.removeEventListener("focus",T)}}},[b,l.isClosePausedRef]);const w=C.useCallback(({tabbingDirection:j})=>{const S=i().map(T=>{const I=T.ref.current,L=[I,...Zot(I)];return j==="forwards"?L:L.reverse()});return(j==="forwards"?S.reverse():S).flat()},[i]);return C.useEffect(()=>{const j=f.current;if(j){const k=S=>{var L,R,$;const T=S.altKey||S.ctrlKey||S.metaKey;if(S.key==="Tab"&&!T){const q=document.activeElement,U=S.shiftKey;if(S.target===j&&U){(L=u.current)==null||L.focus();return}const se=w({tabbingDirection:U?"backwards":"forwards"}),te=se.findIndex(Q=>Q===q);yhe(se.slice(te+1))?S.preventDefault():U?(R=u.current)==null||R.focus():($=p.current)==null||$.focus()}};return j.addEventListener("keydown",k),()=>j.removeEventListener("keydown",k)}},[i,w]),e.jsxs(jot,{ref:d,role:"region","aria-label":a.replace("{hotkey}",_),tabIndex:-1,style:{pointerEvents:b?void 0:"none"},children:[b&&e.jsx(Ufe,{ref:u,onFocusFromOutsideViewport:()=>{const j=w({tabbingDirection:"forwards"});yhe(j)}}),e.jsx(o1e.Slot,{scope:r,children:e.jsx(Qr.ol,{tabIndex:-1,...o,ref:y})}),b&&e.jsx(Ufe,{ref:p,onFocusFromOutsideViewport:()=>{const j=w({tabbingDirection:"backwards"});yhe(j)}})]})});mRe.displayName=hRe;var pRe="ToastFocusProxy",Ufe=C.forwardRef((t,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=t,o=moe(pRe,r);return e.jsx(hoe,{"aria-hidden":!0,tabIndex:0,...a,ref:s,style:{position:"fixed"},onFocus:l=>{var u;const i=l.relatedTarget;!((u=o.viewport)!=null&&u.contains(i))&&n()}})});Ufe.displayName=pRe;var _L="Toast",Rot="toast.swipeStart",Fot="toast.swipeMove",zot="toast.swipeCancel",Bot="toast.swipeEnd",fRe=C.forwardRef((t,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:o,...l}=t,[i,d]=vu({prop:n,defaultProp:a??!0,onChange:o,caller:_L});return e.jsx(ud,{present:r||i,children:e.jsx(Uot,{open:i,...l,ref:s,onClose:()=>d(!1),onPause:Vc(t.onPause),onResume:Vc(t.onResume),onSwipeStart:Mr(t.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Mr(t.onSwipeMove,u=>{const{x:p,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","move"),u.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${p}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${f}px`)}),onSwipeCancel:Mr(t.onSwipeCancel,u=>{u.currentTarget.setAttribute("data-swipe","cancel"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Mr(t.onSwipeEnd,u=>{const{x:p,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","end"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${p}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),d(!1)})})})});fRe.displayName=_L;var[$ot,qot]=dRe(_L,{onClose(){}}),Uot=C.forwardRef((t,s)=>{const{__scopeToast:r,type:n="foreground",duration:a,open:o,onClose:l,onEscapeKeyDown:i,onPause:d,onResume:u,onSwipeStart:p,onSwipeMove:f,onSwipeCancel:y,onSwipeEnd:_,...b}=t,w=moe(_L,r),[j,k]=C.useState(null),S=Ea(s,Q=>k(Q)),T=C.useRef(null),I=C.useRef(null),L=a||w.duration,R=C.useRef(0),$=C.useRef(L),q=C.useRef(0),{onToastAdd:U,onToastRemove:H}=w,Y=Vc(()=>{var de;(j==null?void 0:j.contains(document.activeElement))&&((de=w.viewport)==null||de.focus()),l()}),se=C.useCallback(Q=>{!Q||Q===1/0||(window.clearTimeout(q.current),R.current=new Date().getTime(),q.current=window.setTimeout(Y,Q))},[Y]);C.useEffect(()=>{const Q=w.viewport;if(Q){const de=()=>{se($.current),u==null||u()},re=()=>{const ae=new Date().getTime()-R.current;$.current=$.current-ae,window.clearTimeout(q.current),d==null||d()};return Q.addEventListener($fe,re),Q.addEventListener(qfe,de),()=>{Q.removeEventListener($fe,re),Q.removeEventListener(qfe,de)}}},[w.viewport,L,d,u,se]),C.useEffect(()=>{o&&!w.isClosePausedRef.current&&se(L)},[o,L,w.isClosePausedRef,se]),C.useEffect(()=>(U(),()=>H()),[U,H]);const te=C.useMemo(()=>j?wRe(j):null,[j]);return w.viewport?e.jsxs(e.Fragment,{children:[te&&e.jsx(Vot,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:te}),e.jsx($ot,{scope:r,onClose:Y,children:km.createPortal(e.jsx(o1e.ItemSlot,{scope:r,children:e.jsx(wot,{asChild:!0,onEscapeKeyDown:Mr(i,()=>{w.isFocusedToastEscapeKeyDownRef.current||Y(),w.isFocusedToastEscapeKeyDownRef.current=!1}),children:e.jsx(Qr.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":w.swipeDirection,...b,ref:S,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Mr(t.onKeyDown,Q=>{Q.key==="Escape"&&(i==null||i(Q.nativeEvent),Q.nativeEvent.defaultPrevented||(w.isFocusedToastEscapeKeyDownRef.current=!0,Y()))}),onPointerDown:Mr(t.onPointerDown,Q=>{Q.button===0&&(T.current={x:Q.clientX,y:Q.clientY})}),onPointerMove:Mr(t.onPointerMove,Q=>{if(!T.current)return;const de=Q.clientX-T.current.x,re=Q.clientY-T.current.y,ae=!!I.current,le=["left","right"].includes(w.swipeDirection),he=["left","up"].includes(w.swipeDirection)?Math.min:Math.max,be=le?he(0,de):0,_e=le?0:he(0,re),je=Q.pointerType==="touch"?10:2,Ne={x:be,y:_e},Ge={originalEvent:Q,delta:Ne};ae?(I.current=Ne,M8(Fot,f,Ge,{discrete:!1})):u4e(Ne,w.swipeDirection,je)?(I.current=Ne,M8(Rot,p,Ge,{discrete:!1}),Q.target.setPointerCapture(Q.pointerId)):(Math.abs(de)>je||Math.abs(re)>je)&&(T.current=null)}),onPointerUp:Mr(t.onPointerUp,Q=>{const de=I.current,re=Q.target;if(re.hasPointerCapture(Q.pointerId)&&re.releasePointerCapture(Q.pointerId),I.current=null,T.current=null,de){const ae=Q.currentTarget,le={originalEvent:Q,delta:de};u4e(de,w.swipeDirection,w.swipeThreshold)?M8(Bot,_,le,{discrete:!0}):M8(zot,y,le,{discrete:!0}),ae.addEventListener("click",he=>he.preventDefault(),{once:!0})}})})})}),w.viewport)})]}):null}),Vot=t=>{const{__scopeToast:s,children:r,...n}=t,a=moe(_L,s),[o,l]=C.useState(!1),[i,d]=C.useState(!1);return Got(()=>l(!0)),C.useEffect(()=>{const u=window.setTimeout(()=>d(!0),1e3);return()=>window.clearTimeout(u)},[]),i?null:e.jsx(hM,{asChild:!0,children:e.jsx(hoe,{...n,children:o&&e.jsxs(e.Fragment,{children:[a.label," ",r]})})})},Hot="ToastTitle",gRe=C.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Qr.div,{...n,ref:s})});gRe.displayName=Hot;var Wot="ToastDescription",xRe=C.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Qr.div,{...n,ref:s})});xRe.displayName=Wot;var yRe="ToastAction",vRe=C.forwardRef((t,s)=>{const{altText:r,...n}=t;return r.trim()?e.jsx(bRe,{altText:r,asChild:!0,children:e.jsx(l1e,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${yRe}\`. Expected non-empty \`string\`.`),null)});vRe.displayName=yRe;var _Re="ToastClose",l1e=C.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t,a=qot(_Re,r);return e.jsx(bRe,{asChild:!0,children:e.jsx(Qr.button,{type:"button",...n,ref:s,onClick:Mr(t.onClick,a.onClose)})})});l1e.displayName=_Re;var bRe=C.forwardRef((t,s)=>{const{__scopeToast:r,altText:n,...a}=t;return e.jsx(Qr.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...a,ref:s})});function wRe(t){const s=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),Kot(n)){const a=n.ariaHidden||n.hidden||n.style.display==="none",o=n.dataset.radixToastAnnounceExclude==="";if(!a)if(o){const l=n.dataset.radixToastAnnounceAlt;l&&s.push(l)}else s.push(...wRe(n))}}),s}function M8(t,s,r,{discrete:n}){const a=r.originalEvent.currentTarget,o=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:r});s&&a.addEventListener(t,s,{once:!0}),n?a1e(a,o):a.dispatchEvent(o)}var u4e=(t,s,r=0)=>{const n=Math.abs(t.x),a=Math.abs(t.y),o=n>a;return s==="left"||s==="right"?o&&n>r:!o&&a>r};function Got(t=()=>{}){const s=Vc(t);Zc(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}function Kot(t){return t.nodeType===t.ELEMENT_NODE}function Zot(t){const s=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)s.push(r.currentNode);return s}function yhe(t){const s=document.activeElement;return t.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var Yot=uRe,jRe=mRe,NRe=fRe,kRe=gRe,SRe=xRe,CRe=vRe,MRe=l1e;function TRe(t){var s,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(s=0;stypeof t=="boolean"?`${t}`:t===0?"0":t,m4e=Ii,nS=(t,s)=>r=>{var n;if((s==null?void 0:s.variants)==null)return m4e(t,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:a,defaultVariants:o}=s,l=Object.keys(a).map(u=>{const p=r==null?void 0:r[u],f=o==null?void 0:o[u];if(p===null)return null;const y=h4e(p)||h4e(f);return a[u][y]}),i=r&&Object.entries(r).reduce((u,p)=>{let[f,y]=p;return y===void 0||(u[f]=y),u},{}),d=s==null||(n=s.compoundVariants)===null||n===void 0?void 0:n.reduce((u,p)=>{let{class:f,className:y,..._}=p;return Object.entries(_).every(b=>{let[w,j]=b;return Array.isArray(j)?j.includes({...o,...i}[w]):{...o,...i}[w]===j})?[...u,f,y]:u},[]);return m4e(t,l,d,r==null?void 0:r.class,r==null?void 0:r.className)};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xot=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ARe=(...t)=>t.filter((s,r,n)=>!!s&&s.trim()!==""&&n.indexOf(s)===r).join(" ").trim();/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var Qot={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ERe=C.forwardRef(({color:t="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:l,...i},d)=>C.createElement("svg",{ref:d,...Qot,width:s,height:s,stroke:t,strokeWidth:n?Number(r)*24/Number(s):r,className:ARe("lucide",a),...i},[...l.map(([u,p])=>C.createElement(u,p)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z=(t,s)=>{const r=C.forwardRef(({className:n,...a},o)=>C.createElement(ERe,{ref:o,iconNode:s,className:ARe(`lucide-${Xot(t)}`,n),...a}));return r.displayName=`${t}`,r};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aF=Z("AArrowDown",[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 7v9",key:"pknjwm"}],["path",{d:"m14 12 4 4 4-4",key:"buelq4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iF=Z("AArrowUp",[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 16V7",key:"ty0viw"}],["path",{d:"m14 11 4-4 4 4",key:"1pu57t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oF=Z("ALargeSmall",[["path",{d:"M21 14h-5",key:"1vh23k"}],["path",{d:"M16 16v-3.5a2.5 2.5 0 0 1 5 0V16",key:"1wh10o"}],["path",{d:"M4.5 13h6",key:"dfilno"}],["path",{d:"m3 16 4.5-9 4.5 9",key:"2dxa0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lF=Z("Accessibility",[["circle",{cx:"16",cy:"4",r:"1",key:"1grugj"}],["path",{d:"m18 19 1-7-6 1",key:"r0i19z"}],["path",{d:"m5 8 3-3 5.5 3-2.36 3.5",key:"9ptxx2"}],["path",{d:"M4.24 14.5a5 5 0 0 0 6.88 6",key:"10kmtu"}],["path",{d:"M13.76 17.5a5 5 0 0 0-6.88-6",key:"2qq6rc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pm=Z("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cF=Z("AirVent",[["path",{d:"M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"larmp2"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"M18.3 17.7a2.5 2.5 0 0 1-3.16 3.83 2.53 2.53 0 0 1-1.14-2V12",key:"1bo8pg"}],["path",{d:"M6.6 15.6A2 2 0 1 0 10 17v-5",key:"t9h90c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dF=Z("Airplay",[["path",{d:"M5 17H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-1",key:"ns4c3b"}],["path",{d:"m12 15 5 6H7Z",key:"14qnn2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lw=Z("AlarmClockCheck",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"m9 13 2 2 4-4",key:"6343dt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cw=Z("AlarmClockMinus",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"M9 13h6",key:"1uhe8q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uF=Z("AlarmClockOff",[["path",{d:"M6.87 6.87a8 8 0 1 0 11.26 11.26",key:"3on8tj"}],["path",{d:"M19.9 14.25a8 8 0 0 0-9.15-9.15",key:"15ghsc"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.26 18.67 4 21",key:"yzmioq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M4 4 2 6",key:"1ycko6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dw=Z("AlarmClockPlus",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hF=Z("AlarmClock",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M12 9v4l2 2",key:"1c63tq"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mF=Z("AlarmSmoke",[["path",{d:"M11 21c0-2.5 2-2.5 2-5",key:"1sicvv"}],["path",{d:"M16 21c0-2.5 2-2.5 2-5",key:"1o3eny"}],["path",{d:"m19 8-.8 3a1.25 1.25 0 0 1-1.2 1H7a1.25 1.25 0 0 1-1.2-1L5 8",key:"1bvca4"}],["path",{d:"M21 3a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a1 1 0 0 1 1-1z",key:"x3qr1j"}],["path",{d:"M6 21c0-2.5 2-2.5 2-5",key:"i3w1gp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pF=Z("Album",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["polyline",{points:"11 3 11 11 14 8 17 11 17 3",key:"1wcwz3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fF=Z("AlignCenterHorizontal",[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4",key:"11f1s0"}],["path",{d:"M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4",key:"t14dx9"}],["path",{d:"M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1",key:"1w07xs"}],["path",{d:"M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1",key:"1apec2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gF=Z("AlignCenterVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4",key:"14d6g8"}],["path",{d:"M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4",key:"1e2lrw"}],["path",{d:"M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1",key:"1fkdwx"}],["path",{d:"M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1",key:"1euafb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l5=Z("AlignCenter",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xF=Z("AlignEndHorizontal",[["rect",{width:"6",height:"16",x:"4",y:"2",rx:"2",key:"z5wdxg"}],["rect",{width:"6",height:"9",x:"14",y:"9",rx:"2",key:"um7a8w"}],["path",{d:"M22 22H2",key:"19qnx5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yF=Z("AlignEndVertical",[["rect",{width:"16",height:"6",x:"2",y:"4",rx:"2",key:"10wcwx"}],["rect",{width:"9",height:"6",x:"9",y:"14",rx:"2",key:"4p5bwg"}],["path",{d:"M22 22V2",key:"12ipfv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vF=Z("AlignHorizontalDistributeCenter",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M17 22v-5",key:"4b6g73"}],["path",{d:"M17 7V2",key:"hnrr36"}],["path",{d:"M7 22v-3",key:"1r4jpn"}],["path",{d:"M7 5V2",key:"liy1u9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _F=Z("AlignHorizontalDistributeEnd",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M10 2v20",key:"uyc634"}],["path",{d:"M20 2v20",key:"1tx262"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bF=Z("AlignHorizontalDistributeStart",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M4 2v20",key:"gtpd5x"}],["path",{d:"M14 2v20",key:"tg6bpw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wF=Z("AlignHorizontalJustifyCenter",[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M12 2v20",key:"t6zp3m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jF=Z("AlignHorizontalJustifyEnd",[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"12",y:"7",rx:"2",key:"1ht384"}],["path",{d:"M22 2v20",key:"40qfg1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NF=Z("AlignHorizontalJustifyStart",[["rect",{width:"6",height:"14",x:"6",y:"5",rx:"2",key:"hsirpf"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M2 2v20",key:"1ivd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kF=Z("AlignHorizontalSpaceAround",[["rect",{width:"6",height:"10",x:"9",y:"7",rx:"2",key:"yn7j0q"}],["path",{d:"M4 22V2",key:"tsjzd3"}],["path",{d:"M20 22V2",key:"1bnhr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SF=Z("AlignHorizontalSpaceBetween",[["rect",{width:"6",height:"14",x:"3",y:"5",rx:"2",key:"j77dae"}],["rect",{width:"6",height:"10",x:"15",y:"7",rx:"2",key:"bq30hj"}],["path",{d:"M3 2v20",key:"1d2pfg"}],["path",{d:"M21 2v20",key:"p059bm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CF=Z("AlignJustify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c5=Z("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d5=Z("AlignRight",[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MF=Z("AlignStartHorizontal",[["rect",{width:"6",height:"16",x:"4",y:"6",rx:"2",key:"1n4dg1"}],["rect",{width:"6",height:"9",x:"14",y:"6",rx:"2",key:"17khns"}],["path",{d:"M22 2H2",key:"fhrpnj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TF=Z("AlignStartVertical",[["rect",{width:"9",height:"6",x:"6",y:"14",rx:"2",key:"lpm2y7"}],["rect",{width:"16",height:"6",x:"6",y:"4",rx:"2",key:"rdj6ps"}],["path",{d:"M2 2v20",key:"1ivd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AF=Z("AlignVerticalDistributeCenter",[["path",{d:"M22 17h-3",key:"1lwga1"}],["path",{d:"M22 7h-5",key:"o2endc"}],["path",{d:"M5 17H2",key:"1gx9xc"}],["path",{d:"M7 7H2",key:"6bq26l"}],["rect",{x:"5",y:"14",width:"14",height:"6",rx:"2",key:"1qrzuf"}],["rect",{x:"7",y:"4",width:"10",height:"6",rx:"2",key:"we8e9z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EF=Z("AlignVerticalDistributeEnd",[["rect",{width:"14",height:"6",x:"5",y:"14",rx:"2",key:"jmoj9s"}],["rect",{width:"10",height:"6",x:"7",y:"4",rx:"2",key:"aza5on"}],["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"M2 10h20",key:"1ir3d8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PF=Z("AlignVerticalDistributeStart",[["rect",{width:"14",height:"6",x:"5",y:"14",rx:"2",key:"jmoj9s"}],["rect",{width:"10",height:"6",x:"7",y:"4",rx:"2",key:"aza5on"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M2 4h20",key:"mda7wb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IF=Z("AlignVerticalJustifyCenter",[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LF=Z("AlignVerticalJustifyEnd",[["rect",{width:"14",height:"6",x:"5",y:"12",rx:"2",key:"4l4tp2"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 22h20",key:"272qi7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DF=Z("AlignVerticalJustifyStart",[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"6",rx:"2",key:"13squh"}],["path",{d:"M2 2h20",key:"1ennik"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OF=Z("AlignVerticalSpaceAround",[["rect",{width:"10",height:"6",x:"7",y:"9",rx:"2",key:"b1zbii"}],["path",{d:"M22 20H2",key:"1p1f7z"}],["path",{d:"M22 4H2",key:"1b7qnq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RF=Z("AlignVerticalSpaceBetween",[["rect",{width:"14",height:"6",x:"5",y:"15",rx:"2",key:"1w91an"}],["rect",{width:"10",height:"6",x:"7",y:"3",rx:"2",key:"17wqzy"}],["path",{d:"M2 21h20",key:"1nyx9w"}],["path",{d:"M2 3h20",key:"91anmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FF=Z("Ambulance",[["path",{d:"M10 10H6",key:"1bsnug"}],["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.28a1 1 0 0 0-.684-.948l-1.923-.641a1 1 0 0 1-.578-.502l-1.539-3.076A1 1 0 0 0 16.382 8H14",key:"lrkjwd"}],["path",{d:"M8 8v4",key:"1fwk8c"}],["path",{d:"M9 18h6",key:"x1upvd"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zF=Z("Ampersand",[["path",{d:"M17.5 12c0 4.4-3.6 8-8 8A4.5 4.5 0 0 1 5 15.5c0-6 8-4 8-8.5a3 3 0 1 0-6 0c0 3 2.5 8.5 12 13",key:"1o9ehi"}],["path",{d:"M16 12h3",key:"4uvgyw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BF=Z("Ampersands",[["path",{d:"M10 17c-5-3-7-7-7-9a2 2 0 0 1 4 0c0 2.5-5 2.5-5 6 0 1.7 1.3 3 3 3 2.8 0 5-2.2 5-5",key:"12lh1k"}],["path",{d:"M22 17c-5-3-7-7-7-9a2 2 0 0 1 4 0c0 2.5-5 2.5-5 6 0 1.7 1.3 3 3 3 2.8 0 5-2.2 5-5",key:"173c68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $F=Z("Amphora",[["path",{d:"M10 2v5.632c0 .424-.272.795-.653.982A6 6 0 0 0 6 14c.006 4 3 7 5 8",key:"1h8rid"}],["path",{d:"M10 5H8a2 2 0 0 0 0 4h.68",key:"3ezsi6"}],["path",{d:"M14 2v5.632c0 .424.272.795.652.982A6 6 0 0 1 18 14c0 4-3 7-5 8",key:"yt6q09"}],["path",{d:"M14 5h2a2 2 0 0 1 0 4h-.68",key:"8f95yk"}],["path",{d:"M18 22H6",key:"mg6kv4"}],["path",{d:"M9 2h6",key:"1jrp98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qF=Z("Anchor",[["path",{d:"M12 22V8",key:"qkxhtm"}],["path",{d:"M5 12H2a10 10 0 0 0 20 0h-3",key:"1hv3nh"}],["circle",{cx:"12",cy:"5",r:"3",key:"rqqgnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UF=Z("Angry",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["path",{d:"M7.5 8 10 9",key:"olxxln"}],["path",{d:"m14 9 2.5-1",key:"1j6cij"}],["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VF=Z("Annoyed",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 15h8",key:"45n4r"}],["path",{d:"M8 9h2",key:"1g203m"}],["path",{d:"M14 9h2",key:"116p9w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HF=Z("Antenna",[["path",{d:"M2 12 7 2",key:"117k30"}],["path",{d:"m7 12 5-10",key:"1tvx22"}],["path",{d:"m12 12 5-10",key:"ev1o1a"}],["path",{d:"m17 12 5-10",key:"1e4ti3"}],["path",{d:"M4.5 7h15",key:"vlsxkz"}],["path",{d:"M12 16v6",key:"c8a4gj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WF=Z("Anvil",[["path",{d:"M7 10H6a4 4 0 0 1-4-4 1 1 0 0 1 1-1h4",key:"1hjpb6"}],["path",{d:"M7 5a1 1 0 0 1 1-1h13a1 1 0 0 1 1 1 7 7 0 0 1-7 7H8a1 1 0 0 1-1-1z",key:"1qn45f"}],["path",{d:"M9 12v5",key:"3anwtq"}],["path",{d:"M15 12v5",key:"5xh3zn"}],["path",{d:"M5 20a3 3 0 0 1 3-3h8a3 3 0 0 1 3 3 1 1 0 0 1-1 1H6a1 1 0 0 1-1-1",key:"1fi4x8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GF=Z("Aperture",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m14.31 8 5.74 9.94",key:"1y6ab4"}],["path",{d:"M9.69 8h11.48",key:"1wxppr"}],["path",{d:"m7.38 12 5.74-9.94",key:"1grp0k"}],["path",{d:"M9.69 16 3.95 6.06",key:"libnyf"}],["path",{d:"M14.31 16H2.83",key:"x5fava"}],["path",{d:"m16.62 12-5.74 9.94",key:"1vwawt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KF=Z("AppWindowMac",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M14 8h.01",key:"1primd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sP=Z("AppWindow",[["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}],["path",{d:"M10 4v4",key:"pp8u80"}],["path",{d:"M2 8h20",key:"d11cs7"}],["path",{d:"M6 4v4",key:"1svtjw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZF=Z("Apple",[["path",{d:"M12 20.94c1.5 0 2.75 1.06 4 1.06 3 0 6-8 6-12.22A4.91 4.91 0 0 0 17 5c-2.22 0-4 1.44-5 2-1-.56-2.78-2-5-2a4.9 4.9 0 0 0-5 4.78C2 14 5 22 8 22c1.25 0 2.5-1.06 4-1.06Z",key:"3s7exb"}],["path",{d:"M10 2c1 .5 2 2 2 5",key:"fcco2y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rP=Z("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YF=Z("ArchiveX",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"m9.5 17 5-5",key:"nakeu6"}],["path",{d:"m9.5 12 5 5",key:"1hccrj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u5=Z("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XF=Z("Armchair",[["path",{d:"M19 9V6a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v3",key:"irtipd"}],["path",{d:"M3 16a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-5a2 2 0 0 0-4 0v1.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V11a2 2 0 0 0-4 0z",key:"1qyhux"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QF=Z("ArrowBigDownDash",[["path",{d:"M15 5H9",key:"1tp3ed"}],["path",{d:"M15 9v3h4l-7 7-7-7h4V9z",key:"ncdc4b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JF=Z("ArrowBigDown",[["path",{d:"M15 6v6h4l-7 7-7-7h4V6h6z",key:"1thax2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ez=Z("ArrowBigLeftDash",[["path",{d:"M19 15V9",key:"1hci5f"}],["path",{d:"M15 15h-3v4l-7-7 7-7v4h3v6z",key:"16tjna"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tz=Z("ArrowBigLeft",[["path",{d:"M18 15h-6v4l-7-7 7-7v4h6v6z",key:"lbrdak"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sz=Z("ArrowBigRightDash",[["path",{d:"M5 9v6",key:"158jrl"}],["path",{d:"M9 9h3V5l7 7-7 7v-4H9V9z",key:"1sg2xn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rz=Z("ArrowBigRight",[["path",{d:"M6 9h6V5l7 7-7 7v-4H6V9z",key:"7fvt9c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nz=Z("ArrowBigUpDash",[["path",{d:"M9 19h6",key:"456am0"}],["path",{d:"M9 15v-3H5l7-7 7 7h-4v3H9z",key:"1r2uve"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const az=Z("ArrowBigUp",[["path",{d:"M9 18v-6H5l7-7 7 7h-4v6H9z",key:"1x06kx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iz=Z("ArrowDown01",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["rect",{x:"15",y:"4",width:"4",height:"6",ry:"2",key:"1bwicg"}],["path",{d:"M17 20v-6h-2",key:"1qp1so"}],["path",{d:"M15 20h4",key:"1j968p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oz=Z("ArrowDown10",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M17 10V4h-2",key:"zcsr5x"}],["path",{d:"M15 10h4",key:"id2lce"}],["rect",{x:"15",y:"14",width:"4",height:"6",ry:"2",key:"33xykx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uw=Z("ArrowDownAZ",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lz=Z("ArrowDownFromLine",[["path",{d:"M19 3H5",key:"1236rx"}],["path",{d:"M12 21V7",key:"gj6g52"}],["path",{d:"m6 15 6 6 6-6",key:"h15q88"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cz=Z("ArrowDownLeft",[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dz=Z("ArrowDownNarrowWide",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h4",key:"6d7r33"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h10",key:"1438ji"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nP=Z("ArrowDownRight",[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uz=Z("ArrowDownToDot",[["path",{d:"M12 2v14",key:"jyx4ut"}],["path",{d:"m19 9-7 7-7-7",key:"1oe3oy"}],["circle",{cx:"12",cy:"21",r:"1",key:"o0uj5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hz=Z("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mz=Z("ArrowDownUp",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"m21 8-4-4-4 4",key:"1c9v7m"}],["path",{d:"M17 4v16",key:"7dpous"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hw=Z("ArrowDownWideNarrow",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mw=Z("ArrowDownZA",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M15 4h5l-5 6h5",key:"8asdl1"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20",key:"r6l5cz"}],["path",{d:"M20 18h-5",key:"18j1r2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sh=Z("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pz=Z("ArrowLeftFromLine",[["path",{d:"m9 6-6 6 6 6",key:"7v63n9"}],["path",{d:"M3 12h14",key:"13k4hi"}],["path",{d:"M21 19V5",key:"b4bplr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fz=Z("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gz=Z("ArrowLeftToLine",[["path",{d:"M3 19V5",key:"rwsyhb"}],["path",{d:"m13 6-6 6 6 6",key:"1yhaz7"}],["path",{d:"M7 12h14",key:"uoisry"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ti=Z("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xz=Z("ArrowRightFromLine",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M21 12H7",key:"13ipq5"}],["path",{d:"m15 18 6-6-6-6",key:"6tx3qv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A0=Z("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yz=Z("ArrowRightToLine",[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $i=Z("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vz=Z("ArrowUp01",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["rect",{x:"15",y:"4",width:"4",height:"6",ry:"2",key:"1bwicg"}],["path",{d:"M17 20v-6h-2",key:"1qp1so"}],["path",{d:"M15 20h4",key:"1j968p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _z=Z("ArrowUp10",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M17 10V4h-2",key:"zcsr5x"}],["path",{d:"M15 10h4",key:"id2lce"}],["rect",{x:"15",y:"14",width:"4",height:"6",ry:"2",key:"33xykx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pw=Z("ArrowUpAZ",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hc=Z("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bz=Z("ArrowUpFromDot",[["path",{d:"m5 9 7-7 7 7",key:"1hw5ic"}],["path",{d:"M12 16V2",key:"ywoabb"}],["circle",{cx:"12",cy:"21",r:"1",key:"o0uj5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wz=Z("ArrowUpFromLine",[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jz=Z("ArrowUpLeft",[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fw=Z("ArrowUpNarrowWide",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aP=Z("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nz=Z("ArrowUpToLine",[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kz=Z("ArrowUpWideNarrow",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h4",key:"1krc32"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gw=Z("ArrowUpZA",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M15 4h5l-5 6h5",key:"8asdl1"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20",key:"r6l5cz"}],["path",{d:"M20 18h-5",key:"18j1r2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vd=Z("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sz=Z("ArrowsUpFromLine",[["path",{d:"m4 6 3-3 3 3",key:"9aidw8"}],["path",{d:"M7 17V3",key:"19qxw1"}],["path",{d:"m14 6 3-3 3 3",key:"6iy689"}],["path",{d:"M17 17V3",key:"o0fmgi"}],["path",{d:"M4 21h16",key:"1h09gz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cz=Z("Asterisk",[["path",{d:"M12 6v12",key:"1vza4d"}],["path",{d:"M17.196 9 6.804 15",key:"1ah31z"}],["path",{d:"m6.804 9 10.392 6",key:"1b6pxd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mz=Z("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tz=Z("Atom",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z",key:"1l2ple"}],["path",{d:"M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z",key:"1wam0m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Az=Z("AudioLines",[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ez=Z("AudioWaveform",[["path",{d:"M2 13a2 2 0 0 0 2-2V7a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0V4a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0v-4a2 2 0 0 1 2-2",key:"57tc96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rc=Z("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pz=Z("Axe",[["path",{d:"m14 12-8.5 8.5a2.12 2.12 0 1 1-3-3L11 9",key:"csbz4o"}],["path",{d:"M15 13 9 7l4-4 6 6h3a8 8 0 0 1-7 7z",key:"113wfo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xw=Z("Axis3d",[["path",{d:"M4 4v16h16",key:"1s015l"}],["path",{d:"m4 20 7-7",key:"17qe9y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iz=Z("Baby",[["path",{d:"M9 12h.01",key:"157uk2"}],["path",{d:"M15 12h.01",key:"1k8ypt"}],["path",{d:"M10 16c.5.3 1.2.5 2 .5s1.5-.2 2-.5",key:"1u7htd"}],["path",{d:"M19 6.3a9 9 0 0 1 1.8 3.9 2 2 0 0 1 0 3.6 9 9 0 0 1-17.6 0 2 2 0 0 1 0-3.6A9 9 0 0 1 12 3c2 0 3.5 1.1 3.5 2.5s-.9 2.5-2 2.5c-.8 0-1.5-.4-1.5-1",key:"5yv0yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lz=Z("Backpack",[["path",{d:"M4 10a4 4 0 0 1 4-4h8a4 4 0 0 1 4 4v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z",key:"1ol0lm"}],["path",{d:"M8 10h8",key:"c7uz4u"}],["path",{d:"M8 18h8",key:"1no2b1"}],["path",{d:"M8 22v-6a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v6",key:"1fr6do"}],["path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2",key:"donm21"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dz=Z("BadgeAlert",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oz=Z("BadgeCent",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M15.4 10a4 4 0 1 0 0 4",key:"2eqtx8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yw=Z("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rz=Z("BadgeDollarSign",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fz=Z("BadgeEuro",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M7 12h5",key:"gblrwe"}],["path",{d:"M15 9.4a4 4 0 1 0 0 5.2",key:"1makmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zz=Z("BadgeHelp",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["line",{x1:"12",x2:"12.01",y1:"17",y2:"17",key:"io3f8k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bz=Z("BadgeIndianRupee",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M8 8h8",key:"1bis0t"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m13 17-5-1h1a4 4 0 0 0 0-8",key:"nu2bwa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $z=Z("BadgeInfo",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"16",y2:"12",key:"1y1yb1"}],["line",{x1:"12",x2:"12.01",y1:"8",y2:"8",key:"110wyk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qz=Z("BadgeJapaneseYen",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 8 3 3v7",key:"17yadx"}],["path",{d:"m12 11 3-3",key:"p4cfq1"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M9 16h6",key:"8wimt3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uz=Z("BadgeMinus",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vz=Z("BadgePercent",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hz=Z("BadgePlus",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"16",key:"10p56q"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wz=Z("BadgePoundSterling",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M8 12h4",key:"qz6y1c"}],["path",{d:"M10 16V9.5a2.5 2.5 0 0 1 5 0",key:"3mlbjk"}],["path",{d:"M8 16h7",key:"sbedsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gz=Z("BadgeRussianRuble",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9 16h5",key:"1syiyw"}],["path",{d:"M9 12h5a2 2 0 1 0 0-4h-3v9",key:"1ge9c1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kz=Z("BadgeSwissFranc",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M11 17V8h4",key:"1bfq6y"}],["path",{d:"M11 12h3",key:"2eqnfz"}],["path",{d:"M9 16h4",key:"1skf3a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zz=Z("BadgeX",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yz=Z("Badge",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xz=Z("BaggageClaim",[["path",{d:"M22 18H6a2 2 0 0 1-2-2V7a2 2 0 0 0-2-2",key:"4irg2o"}],["path",{d:"M17 14V4a2 2 0 0 0-2-2h-1a2 2 0 0 0-2 2v10",key:"14fcyx"}],["rect",{width:"13",height:"8",x:"8",y:"6",rx:"1",key:"o6oiis"}],["circle",{cx:"18",cy:"20",r:"2",key:"t9985n"}],["circle",{cx:"9",cy:"20",r:"2",key:"e5v82j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qz=Z("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jz=Z("Banana",[["path",{d:"M4 13c3.5-2 8-2 10 2a5.5 5.5 0 0 1 8 5",key:"1cscit"}],["path",{d:"M5.15 17.89c5.52-1.52 8.65-6.89 7-12C11.55 4 11.5 2 13 2c3.22 0 5 5.5 5 8 0 6.5-4.2 12-10.49 12C5.11 22 2 22 2 20c0-1.5 1.14-1.55 3.15-2.11Z",key:"1y1nbv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e7=Z("Bandage",[["path",{d:"M10 10.01h.01",key:"1e9xi7"}],["path",{d:"M10 14.01h.01",key:"ac23bv"}],["path",{d:"M14 10.01h.01",key:"2wfrvf"}],["path",{d:"M14 14.01h.01",key:"8tw8yn"}],["path",{d:"M18 6v11.5",key:"dkbidh"}],["path",{d:"M6 6v12",key:"vkc79e"}],["rect",{x:"2",y:"6",width:"20",height:"12",rx:"2",key:"1wpnh2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t7=Z("Banknote",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s7=Z("Barcode",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M8 5v14",key:"1ybrkv"}],["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"M17 5v14",key:"ycjyhj"}],["path",{d:"M21 5v14",key:"nzette"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r7=Z("Baseline",[["path",{d:"M4 20h16",key:"14thso"}],["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zx=Z("Bath",[["path",{d:"M10 4 8 6",key:"1rru8s"}],["path",{d:"M17 19v2",key:"ts1sot"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M7 19v2",key:"12npes"}],["path",{d:"M9 5 7.621 3.621A2.121 2.121 0 0 0 4 5v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5",key:"14ym8i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n7=Z("BatteryCharging",[["path",{d:"M15 7h1a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-2",key:"1sdynx"}],["path",{d:"M6 7H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h1",key:"1gkd3k"}],["path",{d:"m11 7-3 5h4l-3 5",key:"b4a64w"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a7=Z("BatteryFull",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}],["line",{x1:"10",x2:"10",y1:"11",y2:"13",key:"haxvl5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"13",key:"c6fn6x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i7=Z("BatteryLow",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o7=Z("BatteryMedium",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}],["line",{x1:"10",x2:"10",y1:"11",y2:"13",key:"haxvl5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l7=Z("BatteryWarning",[["path",{d:"M10 17h.01",key:"nbq80n"}],["path",{d:"M10 7v6",key:"nne03l"}],["path",{d:"M14 7h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-2",key:"1x5o8m"}],["path",{d:"M22 11v2",key:"1wo06k"}],["path",{d:"M6 7H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"1mdjgh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c7=Z("Battery",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d7=Z("Beaker",[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u7=Z("BeanOff",[["path",{d:"M9 9c-.64.64-1.521.954-2.402 1.165A6 6 0 0 0 8 22a13.96 13.96 0 0 0 9.9-4.1",key:"bq3udt"}],["path",{d:"M10.75 5.093A6 6 0 0 1 22 8c0 2.411-.61 4.68-1.683 6.66",key:"17ccse"}],["path",{d:"M5.341 10.62a4 4 0 0 0 6.487 1.208M10.62 5.341a4.015 4.015 0 0 1 2.039 2.04",key:"18zqgq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h7=Z("Bean",[["path",{d:"M10.165 6.598C9.954 7.478 9.64 8.36 9 9c-.64.64-1.521.954-2.402 1.165A6 6 0 0 0 8 22c7.732 0 14-6.268 14-14a6 6 0 0 0-11.835-1.402Z",key:"1tvzk7"}],["path",{d:"M5.341 10.62a4 4 0 1 0 5.279-5.28",key:"2cyri2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iP=Z("BedDouble",[["path",{d:"M2 20v-8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v8",key:"1k78r4"}],["path",{d:"M4 10V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"fb3tl2"}],["path",{d:"M12 4v6",key:"1dcgq2"}],["path",{d:"M2 18h20",key:"ajqnye"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m7=Z("BedSingle",[["path",{d:"M3 20v-8a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v8",key:"1wm6mi"}],["path",{d:"M5 10V6a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v4",key:"4k93s5"}],["path",{d:"M3 18h18",key:"1h113x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E0=Z("Bed",[["path",{d:"M2 4v16",key:"vw9hq8"}],["path",{d:"M2 8h18a2 2 0 0 1 2 2v10",key:"1dgv2r"}],["path",{d:"M2 17h20",key:"18nfp3"}],["path",{d:"M6 8v9",key:"1yriud"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p7=Z("Beef",[["circle",{cx:"12.5",cy:"8.5",r:"2.5",key:"9738u8"}],["path",{d:"M12.5 2a6.5 6.5 0 0 0-6.22 4.6c-1.1 3.13-.78 3.9-3.18 6.08A3 3 0 0 0 5 18c4 0 8.4-1.8 11.4-4.3A6.5 6.5 0 0 0 12.5 2Z",key:"o0f6za"}],["path",{d:"m18.5 6 2.19 4.5a6.48 6.48 0 0 1 .31 2 6.49 6.49 0 0 1-2.6 5.2C15.4 20.2 11 22 7 22a3 3 0 0 1-2.68-1.66L2.4 16.5",key:"k7p6i0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f7=Z("BeerOff",[["path",{d:"M13 13v5",key:"igwfh0"}],["path",{d:"M17 11.47V8",key:"16yw0g"}],["path",{d:"M17 11h1a3 3 0 0 1 2.745 4.211",key:"1xbt65"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 8v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2v-3",key:"c55o3e"}],["path",{d:"M7.536 7.535C6.766 7.649 6.154 8 5.5 8a2.5 2.5 0 0 1-1.768-4.268",key:"1ydug7"}],["path",{d:"M8.727 3.204C9.306 2.767 9.885 2 11 2c1.56 0 2 1.5 3 1.5s1.72-.5 2.5-.5a1 1 0 1 1 0 5c-.78 0-1.5-.5-2.5-.5a3.149 3.149 0 0 0-.842.12",key:"q81o7q"}],["path",{d:"M9 14.6V18",key:"20ek98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g7=Z("Beer",[["path",{d:"M17 11h1a3 3 0 0 1 0 6h-1",key:"1yp76v"}],["path",{d:"M9 12v6",key:"1u1cab"}],["path",{d:"M13 12v6",key:"1sugkk"}],["path",{d:"M14 7.5c-1 0-1.44.5-3 .5s-2-.5-3-.5-1.72.5-2.5.5a2.5 2.5 0 0 1 0-5c.78 0 1.57.5 2.5.5S9.44 2 11 2s2 1.5 3 1.5 1.72-.5 2.5-.5a2.5 2.5 0 0 1 0 5c-.78 0-1.5-.5-2.5-.5Z",key:"1510fo"}],["path",{d:"M5 8v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"19jb7n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x7=Z("BellDot",[["path",{d:"M19.4 14.9C20.2 16.4 21 17 21 17H3s3-2 3-9c0-3.3 2.7-6 6-6 .7 0 1.3.1 1.9.3",key:"xcehk"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["circle",{cx:"18",cy:"8",r:"3",key:"1g0gzu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y7=Z("BellElectric",[["path",{d:"M18.8 4A6.3 8.7 0 0 1 20 9",key:"xve1fh"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["circle",{cx:"9",cy:"9",r:"7",key:"p2h5vp"}],["rect",{width:"10",height:"6",x:"4",y:"16",rx:"2",key:"17f3te"}],["path",{d:"M14 19c3 0 4.6-1.6 4.6-1.6",key:"n7odp6"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v7=Z("BellMinus",[["path",{d:"M18.4 12c.8 3.8 2.6 5 2.6 5H3s3-2 3-9c0-3.3 2.7-6 6-6 1.8 0 3.4.8 4.5 2",key:"eck70s"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M15 8h6",key:"8ybuxh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r_=Z("BellOff",[["path",{d:"M8.7 3A6 6 0 0 1 18 8a21.3 21.3 0 0 0 .6 5",key:"o7mx20"}],["path",{d:"M17 17H3s3-2 3-9a4.67 4.67 0 0 1 .3-1.7",key:"16f1lm"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _7=Z("BellPlus",[["path",{d:"M19.3 14.8C20.1 16.4 21 17 21 17H3s3-2 3-9c0-3.3 2.7-6 6-6 1 0 1.9.2 2.8.7",key:"guizqy"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M15 8h6",key:"8ybuxh"}],["path",{d:"M18 5v6",key:"g5ayrv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b7=Z("BellRing",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gf=Z("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vw=Z("BetweenHorizontalEnd",[["rect",{width:"13",height:"7",x:"3",y:"3",rx:"1",key:"11xb64"}],["path",{d:"m22 15-3-3 3-3",key:"26chmm"}],["rect",{width:"13",height:"7",x:"3",y:"14",rx:"1",key:"k6ky7n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _w=Z("BetweenHorizontalStart",[["rect",{width:"13",height:"7",x:"8",y:"3",rx:"1",key:"pkso9a"}],["path",{d:"m2 9 3 3-3 3",key:"1agib5"}],["rect",{width:"13",height:"7",x:"8",y:"14",rx:"1",key:"1q5fc1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w7=Z("BetweenVerticalEnd",[["rect",{width:"7",height:"13",x:"3",y:"3",rx:"1",key:"1fdu0f"}],["path",{d:"m9 22 3-3 3 3",key:"17z65a"}],["rect",{width:"7",height:"13",x:"14",y:"3",rx:"1",key:"1squn4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j7=Z("BetweenVerticalStart",[["rect",{width:"7",height:"13",x:"3",y:"8",rx:"1",key:"1fjrkv"}],["path",{d:"m15 2-3 3-3-3",key:"1uh6eb"}],["rect",{width:"7",height:"13",x:"14",y:"8",rx:"1",key:"w3fjg8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N7=Z("BicepsFlexed",[["path",{d:"M12.409 13.017A5 5 0 0 1 22 15c0 3.866-4 7-9 7-4.077 0-8.153-.82-10.371-2.462-.426-.316-.631-.832-.62-1.362C2.118 12.723 2.627 2 10 2a3 3 0 0 1 3 3 2 2 0 0 1-2 2c-1.105 0-1.64-.444-2-1",key:"1pmlyh"}],["path",{d:"M15 14a5 5 0 0 0-7.584 2",key:"5rb254"}],["path",{d:"M9.964 6.825C8.019 7.977 9.5 13 8 15",key:"kbvsx9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k7=Z("Bike",[["circle",{cx:"18.5",cy:"17.5",r:"3.5",key:"15x4ox"}],["circle",{cx:"5.5",cy:"17.5",r:"3.5",key:"1noe27"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["path",{d:"M12 17.5V14l-3-3 4-3 2 3h2",key:"1npguv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S7=Z("Binary",[["rect",{x:"14",y:"14",width:"4",height:"6",rx:"2",key:"p02svl"}],["rect",{x:"6",y:"4",width:"4",height:"6",rx:"2",key:"xm4xkj"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 10h4",key:"ru81e7"}],["path",{d:"M6 14h2v6",key:"16z9wg"}],["path",{d:"M14 4h2v6",key:"1idq9u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C7=Z("Binoculars",[["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M19 7V4a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3",key:"3apit1"}],["path",{d:"M20 21a2 2 0 0 0 2-2v-3.851c0-1.39-2-2.962-2-4.829V8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v11a2 2 0 0 0 2 2z",key:"rhpgnw"}],["path",{d:"M 22 16 L 2 16",key:"14lkq7"}],["path",{d:"M4 21a2 2 0 0 1-2-2v-3.851c0-1.39 2-2.962 2-4.829V8a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v11a2 2 0 0 1-2 2z",key:"104b3k"}],["path",{d:"M9 7V4a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v3",key:"14fczp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M7=Z("Biohazard",[["circle",{cx:"12",cy:"11.9",r:"2",key:"e8h31w"}],["path",{d:"M6.7 3.4c-.9 2.5 0 5.2 2.2 6.7C6.5 9 3.7 9.6 2 11.6",key:"17bolr"}],["path",{d:"m8.9 10.1 1.4.8",key:"15ezny"}],["path",{d:"M17.3 3.4c.9 2.5 0 5.2-2.2 6.7 2.4-1.2 5.2-.6 6.9 1.5",key:"wtwa5u"}],["path",{d:"m15.1 10.1-1.4.8",key:"1r0b28"}],["path",{d:"M16.7 20.8c-2.6-.4-4.6-2.6-4.7-5.3-.2 2.6-2.1 4.8-4.7 5.2",key:"m7qszh"}],["path",{d:"M12 13.9v1.6",key:"zfyyim"}],["path",{d:"M13.5 5.4c-1-.2-2-.2-3 0",key:"1bi9q0"}],["path",{d:"M17 16.4c.7-.7 1.2-1.6 1.5-2.5",key:"1rhjqw"}],["path",{d:"M5.5 13.9c.3.9.8 1.8 1.5 2.5",key:"8gsud3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T7=Z("Bird",[["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M3.4 18H12a8 8 0 0 0 8-8V7a4 4 0 0 0-7.28-2.3L2 20",key:"oj1oa8"}],["path",{d:"m20 7 2 .5-2 .5",key:"12nv4d"}],["path",{d:"M10 18v3",key:"1yea0a"}],["path",{d:"M14 17.75V21",key:"1pymcb"}],["path",{d:"M7 18a6 6 0 0 0 3.84-10.61",key:"1npnn0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A7=Z("Bitcoin",[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E7=Z("Blend",[["circle",{cx:"9",cy:"9",r:"7",key:"p2h5vp"}],["circle",{cx:"15",cy:"15",r:"7",key:"19ennj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P7=Z("Blinds",[["path",{d:"M3 3h18",key:"o7r712"}],["path",{d:"M20 7H8",key:"gd2fo2"}],["path",{d:"M20 11H8",key:"1ynp89"}],["path",{d:"M10 19h10",key:"19hjk5"}],["path",{d:"M8 15h12",key:"1yqzne"}],["path",{d:"M4 3v14",key:"fggqzn"}],["circle",{cx:"4",cy:"19",r:"2",key:"p3m9r0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I7=Z("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L7=Z("BluetoothConnected",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}],["line",{x1:"18",x2:"21",y1:"12",y2:"12",key:"1rsjjs"}],["line",{x1:"3",x2:"6",y1:"12",y2:"12",key:"11yl8c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D7=Z("BluetoothOff",[["path",{d:"m17 17-5 5V12l-5 5",key:"v5aci6"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M14.5 9.5 17 7l-5-5v4.5",key:"1kddfz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O7=Z("BluetoothSearching",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}],["path",{d:"M20.83 14.83a4 4 0 0 0 0-5.66",key:"k8tn1j"}],["path",{d:"M18 12h.01",key:"yjnet6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R7=Z("Bluetooth",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h5=Z("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F7=Z("Bolt",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z7=Z("Bomb",[["circle",{cx:"11",cy:"13",r:"9",key:"hd149"}],["path",{d:"M14.35 4.65 16.3 2.7a2.41 2.41 0 0 1 3.4 0l1.6 1.6a2.4 2.4 0 0 1 0 3.4l-1.95 1.95",key:"jp4j1b"}],["path",{d:"m22 2-1.5 1.5",key:"ay92ug"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B7=Z("Bone",[["path",{d:"M17 10c.7-.7 1.69 0 2.5 0a2.5 2.5 0 1 0 0-5 .5.5 0 0 1-.5-.5 2.5 2.5 0 1 0-5 0c0 .81.7 1.8 0 2.5l-7 7c-.7.7-1.69 0-2.5 0a2.5 2.5 0 0 0 0 5c.28 0 .5.22.5.5a2.5 2.5 0 1 0 5 0c0-.81-.7-1.8 0-2.5Z",key:"w610uw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $7=Z("BookA",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m8 13 4-7 4 7",key:"4rari8"}],["path",{d:"M9.1 11h5.7",key:"1gkovt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q7=Z("BookAudio",[["path",{d:"M12 6v7",key:"1f6ttz"}],["path",{d:"M16 8v3",key:"gejaml"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 8v3",key:"1qzp49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U7=Z("BookCheck",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 9.5 2 2 4-4",key:"1dth82"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V7=Z("BookCopy",[["path",{d:"M2 16V4a2 2 0 0 1 2-2h11",key:"spzkk5"}],["path",{d:"M22 18H11a2 2 0 1 0 0 4h10.5a.5.5 0 0 0 .5-.5v-15a.5.5 0 0 0-.5-.5H11a2 2 0 0 0-2 2v12",key:"1wz07i"}],["path",{d:"M5 14H4a2 2 0 1 0 0 4h1",key:"16gqf9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bw=Z("BookDashed",[["path",{d:"M12 17h2",key:"13u4lk"}],["path",{d:"M12 22h2",key:"kn7ki6"}],["path",{d:"M12 2h2",key:"cvn524"}],["path",{d:"M18 22h1a1 1 0 0 0 1-1",key:"w6gbqz"}],["path",{d:"M18 2h1a1 1 0 0 1 1 1v1",key:"1vpra5"}],["path",{d:"M20 15v2h-2",key:"fph276"}],["path",{d:"M20 8v3",key:"deu0bs"}],["path",{d:"M4 11V9",key:"v3xsx8"}],["path",{d:"M4 19.5V15",key:"6gr39e"}],["path",{d:"M4 5v-.5A2.5 2.5 0 0 1 6.5 2H8",key:"wywhs9"}],["path",{d:"M8 22H6.5a1 1 0 0 1 0-5H8",key:"1cu73q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H7=Z("BookDown",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 10 3 3 3-3",key:"zt5b4y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W7=Z("BookHeadphones",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 12v-2a4 4 0 0 1 8 0v2",key:"1vsqkj"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G7=Z("BookHeart",[["path",{d:"M16 8.2A2.22 2.22 0 0 0 13.8 6c-.8 0-1.4.3-1.8.9-.4-.6-1-.9-1.8-.9A2.22 2.22 0 0 0 8 8.2c0 .6.3 1.2.7 1.6A226.652 226.652 0 0 0 12 13a404 404 0 0 0 3.3-3.1 2.413 2.413 0 0 0 .7-1.7",key:"1t75a8"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K7=Z("BookImage",[["path",{d:"m20 13.7-2.1-2.1a2 2 0 0 0-2.8 0L9.7 17",key:"q6ojf0"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["circle",{cx:"10",cy:"8",r:"2",key:"2qkj4p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z7=Z("BookKey",[["path",{d:"m19 3 1 1",key:"ze14oc"}],["path",{d:"m20 2-4.5 4.5",key:"1sppr8"}],["path",{d:"M20 8v13a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"1ocbpn"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H14",key:"1gfsgw"}],["circle",{cx:"14",cy:"8",r:"2",key:"u49eql"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y7=Z("BookLock",[["path",{d:"M18 6V4a2 2 0 1 0-4 0v2",key:"1aquzs"}],["path",{d:"M20 15v6a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"1rkj32"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H10",key:"18wgow"}],["rect",{x:"12",y:"6",width:"8",height:"5",rx:"1",key:"73l30o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X7=Z("BookMarked",[["path",{d:"M10 2v8l3-3 3 3V2",key:"sqw3rj"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q7=Z("BookMinus",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J7=Z("BookOpenCheck",[["path",{d:"M12 21V7",key:"gj6g52"}],["path",{d:"m16 12 2 2 4-4",key:"mdajum"}],["path",{d:"M22 6V4a1 1 0 0 0-1-1h-5a4 4 0 0 0-4 4 4 4 0 0 0-4-4H3a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h6a3 3 0 0 1 3 3 3 3 0 0 1 3-3h6a1 1 0 0 0 1-1v-1.3",key:"8arnkb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eB=Z("BookOpenText",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fu=Z("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tB=Z("BookPlus",[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sB=Z("BookText",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 11h8",key:"vwpz6n"}],["path",{d:"M8 7h6",key:"1f0q6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rB=Z("BookType",[["path",{d:"M10 13h4",key:"ytezjc"}],["path",{d:"M12 6v7",key:"1f6ttz"}],["path",{d:"M16 8V6H8v2",key:"x8j6u4"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nB=Z("BookUp2",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M18 2h1a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"161d7n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2",key:"1lorq7"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aB=Z("BookUp",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iB=Z("BookUser",[["path",{d:"M15 13a3 3 0 1 0-6 0",key:"10j68g"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oB=Z("BookX",[["path",{d:"m14.5 7-5 5",key:"dy991v"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9.5 7 5 5",key:"s45iea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lB=Z("Book",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cB=Z("BookmarkCheck",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dB=Z("BookmarkMinus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oP=Z("BookmarkPlus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"12",x2:"12",y1:"7",y2:"13",key:"1cppfj"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uB=Z("BookmarkX",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $g=Z("Bookmark",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hB=Z("BoomBox",[["path",{d:"M4 9V5a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"vvzvr1"}],["path",{d:"M8 8v1",key:"xcqmfk"}],["path",{d:"M12 8v1",key:"1rj8u4"}],["path",{d:"M16 8v1",key:"1q12zr"}],["rect",{width:"20",height:"12",x:"2",y:"9",rx:"2",key:"igpb89"}],["circle",{cx:"8",cy:"15",r:"2",key:"fa4a8s"}],["circle",{cx:"16",cy:"15",r:"2",key:"14c3ya"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mB=Z("BotMessageSquare",[["path",{d:"M12 6V2H8",key:"1155em"}],["path",{d:"m8 18-4 4V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2Z",key:"w2lp3e"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M9 11v2",key:"1ueba0"}],["path",{d:"M15 11v2",key:"i11awn"}],["path",{d:"M20 12h2",key:"1q8mjw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pB=Z("BotOff",[["path",{d:"M13.67 8H18a2 2 0 0 1 2 2v4.33",key:"7az073"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}],["path",{d:"M8 8H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 1.414-.586",key:"s09a7a"}],["path",{d:"M9 13v2",key:"rq6x2g"}],["path",{d:"M9.67 4H12v2.33",key:"110xot"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m5=Z("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fB=Z("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gB=Z("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ww=Z("Braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xB=Z("Brackets",[["path",{d:"M16 3h3v18h-3",key:"1yor1f"}],["path",{d:"M8 21H5V3h3",key:"1qrfwo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yB=Z("BrainCircuit",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vB=Z("BrainCog",[["path",{d:"M12 5a3 3 0 1 0-5.997.142 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588 4 4 0 0 0 7.636 2.106 3.2 3.2 0 0 0 .164-.546c.028-.13.306-.13.335 0a3.2 3.2 0 0 0 .163.546 4 4 0 0 0 7.636-2.106 4 4 0 0 0 .556-6.588 4 4 0 0 0-2.526-5.77A3 3 0 1 0 12 5",key:"1kgmhc"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m15.7 10.4-.9.4",key:"ayzo6p"}],["path",{d:"m9.2 13.2-.9.4",key:"1uzb3g"}],["path",{d:"m13.6 15.7-.4-.9",key:"11ifqf"}],["path",{d:"m10.8 9.2-.4-.9",key:"1pmk2v"}],["path",{d:"m15.7 13.5-.9-.4",key:"7ng02m"}],["path",{d:"m9.2 10.9-.9-.4",key:"1x66zd"}],["path",{d:"m10.5 15.7.4-.9",key:"3js94g"}],["path",{d:"m13.1 9.2.4-.9",key:"18n7mc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lP=Z("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _B=Z("BrickWall",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 9v6",key:"199k2o"}],["path",{d:"M16 15v6",key:"8rj2es"}],["path",{d:"M16 3v6",key:"1j6rpj"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M8 15v6",key:"1stoo3"}],["path",{d:"M8 3v6",key:"vlvjmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bB=Z("BriefcaseBusiness",[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2",key:"1ksdt3"}],["path",{d:"M22 13a18.15 18.15 0 0 1-20 0",key:"12hx5q"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wB=Z("BriefcaseConveyorBelt",[["path",{d:"M10 20v2",key:"1n8e1g"}],["path",{d:"M14 20v2",key:"1lq872"}],["path",{d:"M18 20v2",key:"10uadw"}],["path",{d:"M21 20H3",key:"kdqkdp"}],["path",{d:"M6 20v2",key:"a9bc87"}],["path",{d:"M8 16V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v12",key:"17n9tx"}],["rect",{x:"4",y:"6",width:"16",height:"10",rx:"2",key:"1097i5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jB=Z("BriefcaseMedical",[["path",{d:"M12 11v4",key:"a6ujw6"}],["path",{d:"M14 13h-4",key:"1pl8zg"}],["path",{d:"M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2",key:"1ksdt3"}],["path",{d:"M18 6v14",key:"1mu4gy"}],["path",{d:"M6 6v14",key:"1s15cj"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rh=Z("Briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NB=Z("BringToFront",[["rect",{x:"8",y:"8",width:"8",height:"8",rx:"2",key:"yj20xf"}],["path",{d:"M4 10a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2",key:"1ltk23"}],["path",{d:"M14 20a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2",key:"1q24h9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kB=Z("Brush",[["path",{d:"m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08",key:"1styjt"}],["path",{d:"M7.07 14.94c-1.66 0-3 1.35-3 3.02 0 1.33-2.5 1.52-2 2.02 1.08 1.1 2.49 2.02 4 2.02 2.2 0 4-1.8 4-4.04a3.01 3.01 0 0 0-3-3.02z",key:"z0l1mu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SB=Z("BugOff",[["path",{d:"M15 7.13V6a3 3 0 0 0-5.14-2.1L8 2",key:"vl8zik"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M22 13h-4v-2a4 4 0 0 0-4-4h-1.3",key:"1ou0bd"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M7.7 7.7A4 4 0 0 0 6 11v3a6 6 0 0 0 11.13 3.13",key:"1njkjs"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CB=Z("BugPlay",[["path",{d:"M12.765 21.522a.5.5 0 0 1-.765-.424v-8.196a.5.5 0 0 1 .765-.424l5.878 3.674a1 1 0 0 1 0 1.696z",key:"17shqo"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M18 11a4 4 0 0 0-4-4h-4a4 4 0 0 0-4 4v3a6.1 6.1 0 0 0 2 4.5",key:"1tjixy"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MB=Z("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ta=Z("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nk=Z("Building",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TB=Z("BusFront",[["path",{d:"M4 6 2 7",key:"1mqr15"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"m22 7-2-1",key:"1umjhc"}],["rect",{width:"16",height:"16",x:"4",y:"3",rx:"2",key:"1wxw4b"}],["path",{d:"M4 11h16",key:"mpoxn0"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M16 15h.01",key:"rnfrdf"}],["path",{d:"M6 19v2",key:"1loha6"}],["path",{d:"M18 21v-2",key:"sqyl04"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AB=Z("Bus",[["path",{d:"M8 6v6",key:"18i7km"}],["path",{d:"M15 6v6",key:"1sg6z9"}],["path",{d:"M2 12h19.6",key:"de5uta"}],["path",{d:"M18 18h3s.5-1.7.8-2.8c.1-.4.2-.8.2-1.2 0-.4-.1-.8-.2-1.2l-1.4-5C20.1 6.8 19.1 6 18 6H4a2 2 0 0 0-2 2v10h3",key:"1wwztk"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}],["path",{d:"M9 18h5",key:"lrx6i"}],["circle",{cx:"16",cy:"18",r:"2",key:"1v4tcr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EB=Z("CableCar",[["path",{d:"M10 3h.01",key:"lbucoy"}],["path",{d:"M14 2h.01",key:"1k8aa1"}],["path",{d:"m2 9 20-5",key:"1kz0j5"}],["path",{d:"M12 12V6.5",key:"1vbrij"}],["rect",{width:"16",height:"10",x:"4",y:"12",rx:"3",key:"if91er"}],["path",{d:"M9 12v5",key:"3anwtq"}],["path",{d:"M15 12v5",key:"5xh3zn"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PB=Z("Cable",[["path",{d:"M17 21v-2a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1",key:"10bnsj"}],["path",{d:"M19 15V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V9",key:"1eqmu1"}],["path",{d:"M21 21v-2h-4",key:"14zm7j"}],["path",{d:"M3 5h4V3",key:"z442eg"}],["path",{d:"M7 5a1 1 0 0 1 1 1v1a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1V3",key:"ebdjd7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IB=Z("CakeSlice",[["circle",{cx:"9",cy:"7",r:"2",key:"1305pl"}],["path",{d:"M7.2 7.9 3 11v9c0 .6.4 1 1 1h16c.6 0 1-.4 1-1v-9c0-2-3-6-7-8l-3.6 2.6",key:"xle13f"}],["path",{d:"M16 13H3",key:"1wpj08"}],["path",{d:"M16 17H3",key:"3lvfcd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zu=Z("Cake",[["path",{d:"M20 21v-8a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8",key:"1w3rig"}],["path",{d:"M4 16s.5-1 2-1 2.5 2 4 2 2.5-2 4-2 2.5 2 4 2 2-1 2-1",key:"n2jgmb"}],["path",{d:"M2 21h20",key:"1nyx9w"}],["path",{d:"M7 8v3",key:"1qtyvj"}],["path",{d:"M12 8v3",key:"hwp4zt"}],["path",{d:"M17 8v3",key:"1i6e5u"}],["path",{d:"M7 4h.01",key:"1bh4kh"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M17 4h.01",key:"1upcoc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LB=Z("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DB=Z("Calendar1",[["path",{d:"M11 14h1v4",key:"fy54vd"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OB=Z("CalendarArrowDown",[["path",{d:"m14 18 4 4 4-4",key:"1waygx"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M18 14v8",key:"irew45"}],["path",{d:"M21 11.354V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7.343",key:"bse4f3"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RB=Z("CalendarArrowUp",[["path",{d:"m14 18 4-4 4 4",key:"ftkppy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M18 22v-8",key:"su0gjh"}],["path",{d:"M21 11.343V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h9",key:"1exg90"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FB=Z("CalendarCheck2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 14V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"bce9hv"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m16 20 2 2 4-4",key:"13tcca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cP=Z("CalendarCheck",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m9 16 2 2 4-4",key:"19s6y9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dP=Z("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zB=Z("CalendarCog",[["path",{d:"m15.2 16.9-.9-.4",key:"1r0w5f"}],["path",{d:"m15.2 19.1-.9.4",key:"j188fs"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"m16.9 15.2-.4-.9",key:"699xu"}],["path",{d:"m16.9 20.8-.4.9",key:"dfjc4z"}],["path",{d:"m19.5 14.3-.4.9",key:"1eb35c"}],["path",{d:"m19.5 21.7-.4-.9",key:"1tonu5"}],["path",{d:"M21 10.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"11kmuh"}],["path",{d:"m21.7 16.5-.9.4",key:"1knoei"}],["path",{d:"m21.7 19.5-.9-.4",key:"q4dx6b"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const id=Z("CalendarDays",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BB=Z("CalendarFold",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 17V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11Z",key:"kg77oy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M15 22v-4a2 2 0 0 1 2-2h4",key:"1gnbqr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $B=Z("CalendarHeart",[["path",{d:"M3 10h18V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7",key:"136lmk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21.29 14.7a2.43 2.43 0 0 0-2.65-.52c-.3.12-.57.3-.8.53l-.34.34-.35-.34a2.43 2.43 0 0 0-2.65-.53c-.3.12-.56.3-.79.53-.95.94-1 2.53.2 3.74L17.5 22l3.6-3.55c1.2-1.21 1.14-2.8.19-3.74Z",key:"1t7hil"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qB=Z("CalendarMinus2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M10 16h4",key:"17e571"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UB=Z("CalendarMinus",[["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 15V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5",key:"1scpom"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uP=Z("CalendarOff",[["path",{d:"M4.2 4.2A2 2 0 0 0 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 1.82-1.18",key:"16swn3"}],["path",{d:"M21 15.5V6a2 2 0 0 0-2-2H9.5",key:"yhw86o"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h7",key:"1wap6i"}],["path",{d:"M21 10h-5.5",key:"quycpq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VB=Z("CalendarPlus2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M10 16h4",key:"17e571"}],["path",{d:"M12 14v4",key:"1thi36"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n_=Z("CalendarPlus",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 16v6",key:"tddt3s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HB=Z("CalendarRange",[["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M17 14h-6",key:"bkmgh3"}],["path",{d:"M13 18H7",key:"bb0bb7"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 18h.01",key:"1bdyru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WB=Z("CalendarSearch",[["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 11.75V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7.25",key:"1jrsq6"}],["path",{d:"m22 22-1.875-1.875",key:"13zax7"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GB=Z("CalendarSync",[["path",{d:"M11 10v4h4",key:"172dkj"}],["path",{d:"m11 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"vu0qm5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"m21 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"1qgeyt"}],["path",{d:"M21 22v-4h-4",key:"hrummi"}],["path",{d:"M21 8.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h4.3",key:"mctw84"}],["path",{d:"M3 10h4",key:"1el30a"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KB=Z("CalendarX2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m17 22 5-5",key:"1k6ppv"}],["path",{d:"m17 17 5 5",key:"p7ous7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZB=Z("CalendarX",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m14 14-4 4",key:"rymu2i"}],["path",{d:"m10 14 4 4",key:"3sz06r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const on=Z("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YB=Z("CameraOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16",key:"qmtpty"}],["path",{d:"M9.5 4h5L17 7h3a2 2 0 0 1 2 2v7.5",key:"1ufyfc"}],["path",{d:"M14.121 15.121A3 3 0 1 1 9.88 10.88",key:"11zox6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qg=Z("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XB=Z("CandyCane",[["path",{d:"M5.7 21a2 2 0 0 1-3.5-2l8.6-14a6 6 0 0 1 10.4 6 2 2 0 1 1-3.464-2 2 2 0 1 0-3.464-2Z",key:"isaq8g"}],["path",{d:"M17.75 7 15 2.1",key:"12x7e8"}],["path",{d:"M10.9 4.8 13 9",key:"100a87"}],["path",{d:"m7.9 9.7 2 4.4",key:"ntfhaj"}],["path",{d:"M4.9 14.7 7 18.9",key:"1x43jy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QB=Z("CandyOff",[["path",{d:"m8.5 8.5-1 1a4.95 4.95 0 0 0 7 7l1-1",key:"1ff4ui"}],["path",{d:"M11.843 6.187A4.947 4.947 0 0 1 16.5 7.5a4.947 4.947 0 0 1 1.313 4.657",key:"1sbrv4"}],["path",{d:"M14 16.5V14",key:"1maf8j"}],["path",{d:"M14 6.5v1.843",key:"1a6u6t"}],["path",{d:"M10 10v7.5",key:"80pj65"}],["path",{d:"m16 7 1-5 1.367.683A3 3 0 0 0 19.708 3H21v1.292a3 3 0 0 0 .317 1.341L22 7l-5 1",key:"11a9mt"}],["path",{d:"m8 17-1 5-1.367-.683A3 3 0 0 0 4.292 21H3v-1.292a3 3 0 0 0-.317-1.341L2 17l5-1",key:"3mjmon"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JB=Z("Candy",[["path",{d:"m9.5 7.5-2 2a4.95 4.95 0 1 0 7 7l2-2a4.95 4.95 0 1 0-7-7Z",key:"ue6khb"}],["path",{d:"M14 6.5v10",key:"5xnk7c"}],["path",{d:"M10 7.5v10",key:"1uew51"}],["path",{d:"m16 7 1-5 1.37.68A3 3 0 0 0 19.7 3H21v1.3c0 .46.1.92.32 1.33L22 7l-5 1",key:"b9cp6k"}],["path",{d:"m8 17-1 5-1.37-.68A3 3 0 0 0 4.3 21H3v-1.3a3 3 0 0 0-.32-1.33L2 17l5-1",key:"5lney8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e9=Z("Cannabis",[["path",{d:"M12 22v-4",key:"1utk9m"}],["path",{d:"M7 12c-1.5 0-4.5 1.5-5 3 3.5 1.5 6 1 6 1-1.5 1.5-2 3.5-2 5 2.5 0 4.5-1.5 6-3 1.5 1.5 3.5 3 6 3 0-1.5-.5-3.5-2-5 0 0 2.5.5 6-1-.5-1.5-3.5-3-5-3 1.5-1 4-4 4-6-2.5 0-5.5 1.5-7 3 0-2.5-.5-5-2-7-1.5 2-2 4.5-2 7-1.5-1.5-4.5-3-7-3 0 2 2.5 5 4 6",key:"1mezod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t9=Z("CaptionsOff",[["path",{d:"M10.5 5H19a2 2 0 0 1 2 2v8.5",key:"jqtk4d"}],["path",{d:"M17 11h-.5",key:"1961ue"}],["path",{d:"M19 19H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2",key:"1keqsi"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M7 11h4",key:"1o1z6v"}],["path",{d:"M7 15h2.5",key:"1ina1g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jw=Z("Captions",[["rect",{width:"18",height:"14",x:"3",y:"5",rx:"2",ry:"2",key:"12ruh7"}],["path",{d:"M7 15h4M15 15h2M7 11h2M13 11h4",key:"1ueiar"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s9=Z("CarFront",[["path",{d:"m21 8-2 2-1.5-3.7A2 2 0 0 0 15.646 5H8.4a2 2 0 0 0-1.903 1.257L5 10 3 8",key:"1imjwt"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 14h.01",key:"7oqj8z"}],["rect",{width:"18",height:"8",x:"3",y:"10",rx:"2",key:"a7itu8"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r9=Z("CarTaxiFront",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"m21 8-2 2-1.5-3.7A2 2 0 0 0 15.646 5H8.4a2 2 0 0 0-1.903 1.257L5 10 3 8",key:"1imjwt"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 14h.01",key:"7oqj8z"}],["rect",{width:"18",height:"8",x:"3",y:"10",rx:"2",key:"a7itu8"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n9=Z("Car",[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a9=Z("Caravan",[["path",{d:"M18 19V9a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v8a2 2 0 0 0 2 2h2",key:"19jm3t"}],["path",{d:"M2 9h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2",key:"13hakp"}],["path",{d:"M22 17v1a1 1 0 0 1-1 1H10v-9a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v9",key:"1crci8"}],["circle",{cx:"8",cy:"19",r:"2",key:"t8fc5s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i9=Z("Carrot",[["path",{d:"M2.27 21.7s9.87-3.5 12.73-6.36a4.5 4.5 0 0 0-6.36-6.37C5.77 11.84 2.27 21.7 2.27 21.7zM8.64 14l-2.05-2.04M15.34 15l-2.46-2.46",key:"rfqxbe"}],["path",{d:"M22 9s-1.33-2-3.5-2C16.86 7 15 9 15 9s1.33 2 3.5 2S22 9 22 9z",key:"6b25w4"}],["path",{d:"M15 2s-2 1.33-2 3.5S15 9 15 9s2-1.84 2-3.5C17 3.33 15 2 15 2z",key:"fn65lo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o9=Z("CaseLower",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l9=Z("CaseSensitive",[["path",{d:"m3 15 4-8 4 8",key:"1vwr6u"}],["path",{d:"M4 13h6",key:"1r9ots"}],["circle",{cx:"18",cy:"12",r:"3",key:"1kchzo"}],["path",{d:"M21 9v6",key:"anns31"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c9=Z("CaseUpper",[["path",{d:"m3 15 4-8 4 8",key:"1vwr6u"}],["path",{d:"M4 13h6",key:"1r9ots"}],["path",{d:"M15 11h4.5a2 2 0 0 1 0 4H15V7h4a2 2 0 0 1 0 4",key:"1sqfas"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d9=Z("CassetteTape",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["circle",{cx:"8",cy:"10",r:"2",key:"1xl4ub"}],["path",{d:"M8 12h8",key:"1wcyev"}],["circle",{cx:"16",cy:"10",r:"2",key:"r14t7q"}],["path",{d:"m6 20 .7-2.9A1.4 1.4 0 0 1 8.1 16h7.8a1.4 1.4 0 0 1 1.4 1l.7 3",key:"l01ucn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u9=Z("Cast",[["path",{d:"M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6",key:"3zrzxg"}],["path",{d:"M2 12a9 9 0 0 1 8 8",key:"g6cvee"}],["path",{d:"M2 16a5 5 0 0 1 4 4",key:"1y1dii"}],["line",{x1:"2",x2:"2.01",y1:"20",y2:"20",key:"xu2jvo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h9=Z("Castle",[["path",{d:"M22 20v-9H2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2Z",key:"109fe4"}],["path",{d:"M18 11V4H6v7",key:"mon5oj"}],["path",{d:"M15 22v-4a3 3 0 0 0-3-3a3 3 0 0 0-3 3v4",key:"1k4jtn"}],["path",{d:"M22 11V9",key:"3zbp94"}],["path",{d:"M2 11V9",key:"1x5rnq"}],["path",{d:"M6 4V2",key:"1rsq15"}],["path",{d:"M18 4V2",key:"1jsdo1"}],["path",{d:"M10 4V2",key:"75d9ly"}],["path",{d:"M14 4V2",key:"8nj3z6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m9=Z("Cat",[["path",{d:"M12 5c.67 0 1.35.09 2 .26 1.78-2 5.03-2.84 6.42-2.26 1.4.58-.42 7-.42 7 .57 1.07 1 2.24 1 3.44C21 17.9 16.97 21 12 21s-9-3-9-7.56c0-1.25.5-2.4 1-3.44 0 0-1.89-6.42-.5-7 1.39-.58 4.72.23 6.5 2.23A9.04 9.04 0 0 1 12 5Z",key:"x6xyqk"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M11.25 16.25h1.5L12 17l-.75-.75Z",key:"12kq1m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p9=Z("Cctv",[["path",{d:"M16.75 12h3.632a1 1 0 0 1 .894 1.447l-2.034 4.069a1 1 0 0 1-1.708.134l-2.124-2.97",key:"ir91b5"}],["path",{d:"M17.106 9.053a1 1 0 0 1 .447 1.341l-3.106 6.211a1 1 0 0 1-1.342.447L3.61 12.3a2.92 2.92 0 0 1-1.3-3.91L3.69 5.6a2.92 2.92 0 0 1 3.92-1.3z",key:"jlp8i1"}],["path",{d:"M2 19h3.76a2 2 0 0 0 1.8-1.1L9 15",key:"19bib8"}],["path",{d:"M2 21v-4",key:"l40lih"}],["path",{d:"M7 9h.01",key:"19b3jx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nw=Z("ChartArea",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kw=Z("ChartBarBig",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"7",y:"13",width:"9",height:"4",rx:"1",key:"1iip1u"}],["rect",{x:"7",y:"5",width:"12",height:"4",rx:"1",key:"1anskk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f9=Z("ChartBarDecreasing",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11h8",key:"1feolt"}],["path",{d:"M7 16h3",key:"ur6vzw"}],["path",{d:"M7 6h12",key:"sz5b0d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g9=Z("ChartBarIncreasing",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11h8",key:"1feolt"}],["path",{d:"M7 16h12",key:"wsnu98"}],["path",{d:"M7 6h3",key:"w9rmul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x9=Z("ChartBarStacked",[["path",{d:"M11 13v4",key:"vyy2rb"}],["path",{d:"M15 5v4",key:"1gx88a"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"7",y:"13",width:"9",height:"4",rx:"1",key:"1iip1u"}],["rect",{x:"7",y:"5",width:"12",height:"4",rx:"1",key:"1anskk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sw=Z("ChartBar",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16h8",key:"srdodz"}],["path",{d:"M7 11h12",key:"127s9w"}],["path",{d:"M7 6h3",key:"w9rmul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cw=Z("ChartCandlestick",[["path",{d:"M9 5v4",key:"14uxtq"}],["rect",{width:"4",height:"6",x:"7",y:"9",rx:"1",key:"f4fvz0"}],["path",{d:"M9 15v2",key:"r5rk32"}],["path",{d:"M17 3v2",key:"1l2re6"}],["rect",{width:"4",height:"8",x:"15",y:"5",rx:"1",key:"z38je5"}],["path",{d:"M17 13v3",key:"5l0wba"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mw=Z("ChartColumnBig",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y9=Z("ChartColumnDecreasing",[["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17v-3",key:"1sqioe"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 17V5",key:"1wzmnc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tw=Z("ChartColumnIncreasing",[["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17V5",key:"sfb6ij"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v9=Z("ChartColumnStacked",[["path",{d:"M11 13H7",key:"t0o9gq"}],["path",{d:"M19 9h-4",key:"rera1j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ol=Z("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _9=Z("ChartGantt",[["path",{d:"M10 6h8",key:"zvc2xc"}],["path",{d:"M12 16h6",key:"yi5mkt"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 11h7",key:"wz2hg0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aw=Z("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b9=Z("ChartNetwork",[["path",{d:"m13.11 7.664 1.78 2.672",key:"go2gg9"}],["path",{d:"m14.162 12.788-3.324 1.424",key:"11x848"}],["path",{d:"m20 4-6.06 1.515",key:"1wxxh7"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["circle",{cx:"12",cy:"6",r:"2",key:"1jj5th"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}],["circle",{cx:"9",cy:"15",r:"2",key:"lf2ghp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w9=Z("ChartNoAxesColumnDecreasing",[["path",{d:"M12 20V10",key:"g8npz5"}],["path",{d:"M18 20v-4",key:"8uic4z"}],["path",{d:"M6 20V4",key:"1w1bmo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ew=Z("ChartNoAxesColumnIncreasing",[["line",{x1:"12",x2:"12",y1:"20",y2:"10",key:"1vz5eb"}],["line",{x1:"18",x2:"18",y1:"20",y2:"4",key:"cun8e5"}],["line",{x1:"6",x2:"6",y1:"20",y2:"16",key:"hq0ia6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pw=Z("ChartNoAxesColumn",[["line",{x1:"18",x2:"18",y1:"20",y2:"10",key:"1xfpm4"}],["line",{x1:"12",x2:"12",y1:"20",y2:"4",key:"be30l9"}],["line",{x1:"6",x2:"6",y1:"20",y2:"14",key:"1r4le6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j9=Z("ChartNoAxesCombined",[["path",{d:"M12 16v5",key:"zza2cw"}],["path",{d:"M16 14v7",key:"1g90b9"}],["path",{d:"M20 10v11",key:"1iqoj0"}],["path",{d:"m22 3-8.646 8.646a.5.5 0 0 1-.708 0L9.354 8.354a.5.5 0 0 0-.707 0L2 15",key:"1fw8x9"}],["path",{d:"M4 18v3",key:"1yp0dc"}],["path",{d:"M8 14v7",key:"n3cwzv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iw=Z("ChartNoAxesGantt",[["path",{d:"M8 6h10",key:"9lnwnk"}],["path",{d:"M6 12h9",key:"1g9pqf"}],["path",{d:"M11 18h7",key:"c8dzvl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lw=Z("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dw=Z("ChartScatter",[["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["circle",{cx:"18.5",cy:"5.5",r:".5",fill:"currentColor",key:"lysivs"}],["circle",{cx:"11.5",cy:"11.5",r:".5",fill:"currentColor",key:"byv1b8"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["circle",{cx:"17.5",cy:"14.5",r:".5",fill:"currentColor",key:"1gjh6j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N9=Z("ChartSpline",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16c.5-2 1.5-7 4-7 2 0 2 3 4 3 2.5 0 4.5-5 5-7",key:"lw07rv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k9=Z("CheckCheck",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ha=Z("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S9=Z("ChefHat",[["path",{d:"M17 21a1 1 0 0 0 1-1v-5.35c0-.457.316-.844.727-1.041a4 4 0 0 0-2.134-7.589 5 5 0 0 0-9.186 0 4 4 0 0 0-2.134 7.588c.411.198.727.585.727 1.041V20a1 1 0 0 0 1 1Z",key:"1qvrer"}],["path",{d:"M6 17h12",key:"1jwigz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C9=Z("Cherry",[["path",{d:"M2 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z",key:"cvxqlc"}],["path",{d:"M12 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z",key:"1ostrc"}],["path",{d:"M7 14c3.22-2.91 4.29-8.75 5-12 1.66 2.38 4.94 9 5 12",key:"hqx58h"}],["path",{d:"M22 9c-4.29 0-7.14-2.33-10-7 5.71 0 10 4.67 10 7Z",key:"eykp1o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ho=Z("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M9=Z("ChevronFirst",[["path",{d:"m17 18-6-6 6-6",key:"1yerx2"}],["path",{d:"M7 6v12",key:"1p53r6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T9=Z("ChevronLast",[["path",{d:"m7 18 6-6-6-6",key:"lwmzdw"}],["path",{d:"M17 6v12",key:"1o0aio"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zl=Z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ua=Z("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ug=Z("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A9=Z("ChevronsDownUp",[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E9=Z("ChevronsDown",[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P9=Z("ChevronsLeftRightEllipsis",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I9=Z("ChevronsLeftRight",[["path",{d:"m9 7-5 5 5 5",key:"j5w590"}],["path",{d:"m15 7 5 5-5 5",key:"1bl6da"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L9=Z("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D9=Z("ChevronsRightLeft",[["path",{d:"m20 17-5-5 5-5",key:"30x0n2"}],["path",{d:"m4 17 5-5-5-5",key:"16spf4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O9=Z("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xf=Z("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R9=Z("ChevronsUp",[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F9=Z("Chrome",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["line",{x1:"21.17",x2:"12",y1:"8",y2:"8",key:"a0cw5f"}],["line",{x1:"3.95",x2:"8.54",y1:"6.06",y2:"14",key:"1kftof"}],["line",{x1:"10.88",x2:"15.46",y1:"21.94",y2:"14",key:"1ymyh8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z9=Z("Church",[["path",{d:"M10 9h4",key:"u4k05v"}],["path",{d:"M12 7v5",key:"ma6bk"}],["path",{d:"M14 22v-4a2 2 0 0 0-4 0v4",key:"1pdhuj"}],["path",{d:"M18 22V5.618a1 1 0 0 0-.553-.894l-4.553-2.277a2 2 0 0 0-1.788 0L6.553 4.724A1 1 0 0 0 6 5.618V22",key:"1rkokr"}],["path",{d:"m18 7 3.447 1.724a1 1 0 0 1 .553.894V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9.618a1 1 0 0 1 .553-.894L6 7",key:"1w6esw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B9=Z("CigaretteOff",[["path",{d:"M12 12H3a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h13",key:"1gdiyg"}],["path",{d:"M18 8c0-2.5-2-2.5-2-5",key:"1il607"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M21 12a1 1 0 0 1 1 1v2a1 1 0 0 1-.5.866",key:"166zjj"}],["path",{d:"M22 8c0-2.5-2-2.5-2-5",key:"1gah44"}],["path",{d:"M7 12v4",key:"jqww69"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $9=Z("Cigarette",[["path",{d:"M17 12H3a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h14",key:"1mb5g1"}],["path",{d:"M18 8c0-2.5-2-2.5-2-5",key:"1il607"}],["path",{d:"M21 16a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"1yl5r7"}],["path",{d:"M22 8c0-2.5-2-2.5-2-5",key:"1gah44"}],["path",{d:"M7 12v4",key:"jqww69"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ll=Z("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ow=Z("CircleArrowDown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rw=Z("CircleArrowLeft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"m12 8-4 4 4 4",key:"15vm53"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fw=Z("CircleArrowOutDownLeft",[["path",{d:"M2 12a10 10 0 1 1 10 10",key:"1yn6ov"}],["path",{d:"m2 22 10-10",key:"28ilpk"}],["path",{d:"M8 22H2v-6",key:"sulq54"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zw=Z("CircleArrowOutDownRight",[["path",{d:"M12 22a10 10 0 1 1 10-10",key:"130bv5"}],["path",{d:"M22 22 12 12",key:"131aw7"}],["path",{d:"M22 16v6h-6",key:"1gvm70"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bw=Z("CircleArrowOutUpLeft",[["path",{d:"M2 8V2h6",key:"hiwtdz"}],["path",{d:"m2 2 10 10",key:"1oh8rs"}],["path",{d:"M12 2A10 10 0 1 1 2 12",key:"rrk4fa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $w=Z("CircleArrowOutUpRight",[["path",{d:"M22 12A10 10 0 1 1 12 2",key:"1fm58d"}],["path",{d:"M22 2 12 12",key:"yg2myt"}],["path",{d:"M16 2h6v6",key:"zan5cs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qw=Z("CircleArrowRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uw=Z("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hi=Z("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ua=Z("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vw=Z("CircleChevronDown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hw=Z("CircleChevronLeft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m14 16-4-4 4-4",key:"ojs7w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ww=Z("CircleChevronRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gw=Z("CircleChevronUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m8 14 4-4 4 4",key:"fy2ptz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q9=Z("CircleDashed",[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kw=Z("CircleDivide",[["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}],["line",{x1:"12",x2:"12",y1:"16",y2:"16",key:"aqc6ln"}],["line",{x1:"12",x2:"12",y1:"8",y2:"8",key:"1mkcni"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U9=Z("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V9=Z("CircleDotDashed",[["path",{d:"M10.1 2.18a9.93 9.93 0 0 1 3.8 0",key:"1qdqn0"}],["path",{d:"M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7",key:"1bq7p6"}],["path",{d:"M21.82 10.1a9.93 9.93 0 0 1 0 3.8",key:"1rlaqf"}],["path",{d:"M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69",key:"1xk03u"}],["path",{d:"M13.9 21.82a9.94 9.94 0 0 1-3.8 0",key:"l7re25"}],["path",{d:"M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7",key:"1v18p6"}],["path",{d:"M2.18 13.9a9.93 9.93 0 0 1 0-3.8",key:"xdo6bj"}],["path",{d:"M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69",key:"1jjmaz"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H9=Z("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W9=Z("CircleEllipsis",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G9=Z("CircleEqual",[["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K9=Z("CircleFadingArrowUp",[["path",{d:"M12 2a10 10 0 0 1 7.38 16.75",key:"175t95"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}],["path",{d:"M2.5 8.875a10 10 0 0 0-.5 3",key:"1vce0s"}],["path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4",key:"o3fkw4"}],["path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857",key:"1szpfk"}],["path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38",key:"9yhvd4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z9=Z("CircleFadingPlus",[["path",{d:"M12 2a10 10 0 0 1 7.38 16.75",key:"175t95"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M2.5 8.875a10 10 0 0 0-.5 3",key:"1vce0s"}],["path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4",key:"o3fkw4"}],["path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857",key:"1szpfk"}],["path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38",key:"9yhvd4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zw=Z("CircleGauge",[["path",{d:"M15.6 2.7a10 10 0 1 0 5.7 5.7",key:"1e0p6d"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M13.4 10.6 19 5",key:"1kr7tw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h0=Z("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yw=Z("CircleMinus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y9=Z("CircleOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.35 2.69A10 10 0 0 1 21.3 15.65",key:"1pfsoa"}],["path",{d:"M19.08 19.08A10 10 0 1 1 4.92 4.92",key:"1ablyi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xw=Z("CircleParkingOff",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m5 5 14 14",key:"11anup"}],["path",{d:"M13 13a3 3 0 1 0 0-6H9v2",key:"uoagbd"}],["path",{d:"M9 17v-2.34",key:"a9qo08"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qw=Z("CircleParking",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9 17V7h4a3 3 0 0 1 0 6H9",key:"1dfk2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jw=Z("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e2=Z("CirclePercent",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bm=Z("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t2=Z("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s2=Z("CirclePower",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r2=Z("CircleSlash2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X9=Z("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n2=Z("CircleStop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a2=Z("CircleUserRound",[["path",{d:"M18 20a6 6 0 0 0-12 0",key:"1qehca"}],["circle",{cx:"12",cy:"10",r:"4",key:"1h16sb"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i2=Z("CircleUser",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kc=Z("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kc=Z("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q9=Z("CircuitBoard",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M11 9h4a2 2 0 0 0 2-2V3",key:"1ve2rv"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"M7 21v-4a2 2 0 0 1 2-2h4",key:"1fwkro"}],["circle",{cx:"15",cy:"15",r:"2",key:"3i40o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J9=Z("Citrus",[["path",{d:"M21.66 17.67a1.08 1.08 0 0 1-.04 1.6A12 12 0 0 1 4.73 2.38a1.1 1.1 0 0 1 1.61-.04z",key:"4ite01"}],["path",{d:"M19.65 15.66A8 8 0 0 1 8.35 4.34",key:"1gxipu"}],["path",{d:"m14 10-5.5 5.5",key:"92pfem"}],["path",{d:"M14 17.85V10H6.15",key:"xqmtsk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e$=Z("Clapperboard",[["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z",key:"1tn4o7"}],["path",{d:"m6.2 5.3 3.1 3.9",key:"iuk76l"}],["path",{d:"m12.4 3.4 3.1 4",key:"6hsd6n"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z",key:"ltgou9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p5=Z("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t$=Z("ClipboardCopy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a_=Z("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s$=Z("ClipboardMinus",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 14h6",key:"159ibu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r$=Z("ClipboardPaste",[["path",{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",key:"1pp7kr"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2M11 14h10",key:"2ik1ml"}],["path",{d:"m17 10 4 4-4 4",key:"vp2hj1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o2=Z("ClipboardPenLine",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",key:"1oijnt"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.5",key:"1but9f"}],["path",{d:"M16 4h2a2 2 0 0 1 1.73 1",key:"1p8n7l"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l2=Z("ClipboardPen",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",key:"1oijnt"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-5.5",key:"cereej"}],["path",{d:"M4 13.5V6a2 2 0 0 1 2-2h2",key:"5ua5vh"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n$=Z("ClipboardPlus",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 14h6",key:"159ibu"}],["path",{d:"M12 17v-6",key:"1y8rbf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a$=Z("ClipboardType",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 12v-1h6v1",key:"iehl6m"}],["path",{d:"M11 17h2",key:"12w5me"}],["path",{d:"M12 11v6",key:"1bwqyc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i$=Z("ClipboardX",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m15 11-6 6",key:"1toa9n"}],["path",{d:"m9 11 6 6",key:"wlibny"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o$=Z("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l$=Z("Clock1",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 14.5 8",key:"12zbmj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c$=Z("Clock10",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 8 10",key:"atfzqc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d$=Z("Clock11",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 9.5 8",key:"l5bg6f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u$=Z("Clock12",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12",key:"1fub01"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h$=Z("Clock2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 10",key:"1g230d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m$=Z("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p$=Z("Clock4",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f$=Z("Clock5",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 14.5 16",key:"1pcbox"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g$=Z("Clock6",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 12 16.5",key:"hb2qv6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x$=Z("Clock7",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 9.5 16",key:"ka3394"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y$=Z("Clock8",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 8 14",key:"tmc9b4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v$=Z("Clock9",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 7.5 12",key:"1k60p0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _$=Z("ClockAlert",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["path",{d:"M16 21.16a10 10 0 1 1 5-13.516",key:"cxo92l"}],["path",{d:"M20 11.5v6",key:"2ei3xq"}],["path",{d:"M20 21.5h.01",key:"1r2dzp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b$=Z("ClockArrowDown",[["path",{d:"M12.338 21.994A10 10 0 1 1 21.925 13.227",key:"1i7shu"}],["path",{d:"M12 6v6l2 1",key:"19cm8n"}],["path",{d:"m14 18 4 4 4-4",key:"1waygx"}],["path",{d:"M18 14v8",key:"irew45"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w$=Z("ClockArrowUp",[["path",{d:"M13.228 21.925A10 10 0 1 1 21.994 12.338",key:"1fzlyi"}],["path",{d:"M12 6v6l1.562.781",key:"1ujuk9"}],["path",{d:"m14 18 4-4 4 4",key:"ftkppy"}],["path",{d:"M18 22v-8",key:"su0gjh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tn=Z("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j$=Z("CloudAlert",[["path",{d:"M12 12v4",key:"tww15h"}],["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M17 18h.5a1 1 0 0 0 0-9h-1.79A7 7 0 1 0 7 17.708",key:"xsb5ju"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N$=Z("CloudCog",[["circle",{cx:"12",cy:"17",r:"3",key:"1spfwm"}],["path",{d:"M4.2 15.1A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.2",key:"zaobp"}],["path",{d:"m15.7 18.4-.9-.3",key:"4qxpbn"}],["path",{d:"m9.2 15.9-.9-.3",key:"17q7o2"}],["path",{d:"m10.6 20.7.3-.9",key:"1pf4s2"}],["path",{d:"m13.1 14.2.3-.9",key:"1mnuqm"}],["path",{d:"m13.6 20.7-.4-1",key:"1jpd1m"}],["path",{d:"m10.8 14.3-.4-1",key:"17ugyy"}],["path",{d:"m8.3 18.6 1-.4",key:"s42vdx"}],["path",{d:"m14.7 15.8 1-.4",key:"2wizun"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c2=Z("CloudDownload",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k$=Z("CloudDrizzle",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M8 19v1",key:"1dk2by"}],["path",{d:"M8 14v1",key:"84yxot"}],["path",{d:"M16 19v1",key:"v220m7"}],["path",{d:"M16 14v1",key:"g12gj6"}],["path",{d:"M12 21v1",key:"q8vafk"}],["path",{d:"M12 16v1",key:"1mx6rx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S$=Z("CloudFog",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 17H7",key:"pygtm1"}],["path",{d:"M17 21H9",key:"1u2q02"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C$=Z("CloudHail",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 14v2",key:"a1is7l"}],["path",{d:"M8 14v2",key:"1e9m6t"}],["path",{d:"M16 20h.01",key:"xwek51"}],["path",{d:"M8 20h.01",key:"1vjney"}],["path",{d:"M12 16v2",key:"z66u1j"}],["path",{d:"M12 22h.01",key:"1urd7a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M$=Z("CloudLightning",[["path",{d:"M6 16.326A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 .5 8.973",key:"1cez44"}],["path",{d:"m13 12-3 5h4l-3 5",key:"1t22er"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T$=Z("CloudMoonRain",[["path",{d:"M10.188 8.5A6 6 0 0 1 16 4a1 1 0 0 0 6 6 6 6 0 0 1-3 5.197",key:"erj67n"}],["path",{d:"M11 20v2",key:"174qtz"}],["path",{d:"M3 20a5 5 0 1 1 8.9-4H13a3 3 0 0 1 2 5.24",key:"1qmrp3"}],["path",{d:"M7 19v2",key:"12npes"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A$=Z("CloudMoon",[["path",{d:"M10.188 8.5A6 6 0 0 1 16 4a1 1 0 0 0 6 6 6 6 0 0 1-3 5.197",key:"erj67n"}],["path",{d:"M13 16a3 3 0 1 1 0 6H7a5 5 0 1 1 4.9-6Z",key:"p44pc9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E$=Z("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P$=Z("CloudRainWind",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m9.2 22 3-7",key:"sb5f6j"}],["path",{d:"m9 13-3 7",key:"500co5"}],["path",{d:"m17 13-3 7",key:"8t2fiy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I$=Z("CloudRain",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 14v6",key:"1j4efv"}],["path",{d:"M8 14v6",key:"17c4r9"}],["path",{d:"M12 16v6",key:"c8a4gj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L$=Z("CloudSnow",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M8 19h.01",key:"puxtts"}],["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M12 21h.01",key:"h35vbk"}],["path",{d:"M16 15h.01",key:"rnfrdf"}],["path",{d:"M16 19h.01",key:"1vcnzz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D$=Z("CloudSunRain",[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M3 20a5 5 0 1 1 8.9-4H13a3 3 0 0 1 2 5.24",key:"1qmrp3"}],["path",{d:"M11 20v2",key:"174qtz"}],["path",{d:"M7 19v2",key:"12npes"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O$=Z("CloudSun",[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z",key:"s09mg5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d2=Z("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R$=Z("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F$=Z("Cloudy",[["path",{d:"M17.5 21H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"gqqjvc"}],["path",{d:"M22 10a3 3 0 0 0-3-3h-2.207a5.502 5.502 0 0 0-10.702.5",key:"1p2s76"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N0=Z("Clover",[["path",{d:"M16.17 7.83 2 22",key:"t58vo8"}],["path",{d:"M4.02 12a2.827 2.827 0 1 1 3.81-4.17A2.827 2.827 0 1 1 12 4.02a2.827 2.827 0 1 1 4.17 3.81A2.827 2.827 0 1 1 19.98 12a2.827 2.827 0 1 1-3.81 4.17A2.827 2.827 0 1 1 12 19.98a2.827 2.827 0 1 1-4.17-3.81A1 1 0 1 1 4 12",key:"17k36q"}],["path",{d:"m7.83 7.83 8.34 8.34",key:"1d7sxk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z$=Z("Club",[["path",{d:"M17.28 9.05a5.5 5.5 0 1 0-10.56 0A5.5 5.5 0 1 0 12 17.66a5.5 5.5 0 1 0 5.28-8.6Z",key:"27yuqz"}],["path",{d:"M12 17.66L12 22",key:"ogfahf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u2=Z("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ak=Z("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B$=Z("Codepen",[["polygon",{points:"12 2 22 8.5 22 15.5 12 22 2 15.5 2 8.5 12 2",key:"srzb37"}],["line",{x1:"12",x2:"12",y1:"22",y2:"15.5",key:"1t73f2"}],["polyline",{points:"22 8.5 12 15.5 2 8.5",key:"ajlxae"}],["polyline",{points:"2 15.5 12 8.5 22 15.5",key:"susrui"}],["line",{x1:"12",x2:"12",y1:"2",y2:"8.5",key:"2cldga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $$=Z("Codesandbox",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}],["polyline",{points:"7.5 4.21 12 6.81 16.5 4.21",key:"fabo96"}],["polyline",{points:"7.5 19.79 7.5 14.6 3 12",key:"z377f1"}],["polyline",{points:"21 12 16.5 14.6 16.5 19.79",key:"9nrev1"}],["polyline",{points:"3.27 6.96 12 12.01 20.73 6.96",key:"1180pa"}],["line",{x1:"12",x2:"12",y1:"22.08",y2:"12",key:"3z3uq6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ik=Z("Coffee",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q$=Z("Cog",[["path",{d:"M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",key:"sobvz5"}],["path",{d:"M12 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",key:"11i496"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hP=Z("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h2=Z("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m2=Z("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U$=Z("Columns4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7.5 3v18",key:"w0wo6v"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M16.5 3v18",key:"10tjh1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V$=Z("Combine",[["path",{d:"M10 18H5a3 3 0 0 1-3-3v-1",key:"ru65g8"}],["path",{d:"M14 2a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"e30een"}],["path",{d:"M20 2a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"2ahx8o"}],["path",{d:"m7 21 3-3-3-3",key:"127cv2"}],["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",key:"1b0bso"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",key:"1x09vl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H$=Z("Command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W$=Z("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G$=Z("Component",[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K$=Z("Computer",[["rect",{width:"14",height:"8",x:"5",y:"2",rx:"2",key:"wc9tft"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h2",key:"rwmk9e"}],["path",{d:"M12 18h6",key:"aqd8w3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z$=Z("ConciergeBell",[["path",{d:"M3 20a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1Z",key:"1pvr1r"}],["path",{d:"M20 16a8 8 0 1 0-16 0",key:"1pa543"}],["path",{d:"M12 4v4",key:"1bq03y"}],["path",{d:"M10 4h4",key:"1xpv9s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y$=Z("Cone",[["path",{d:"m20.9 18.55-8-15.98a1 1 0 0 0-1.8 0l-8 15.98",key:"53pte7"}],["ellipse",{cx:"12",cy:"19",rx:"9",ry:"3",key:"1ji25f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X$=Z("Construction",[["rect",{x:"2",y:"6",width:"20",height:"8",rx:"1",key:"1estib"}],["path",{d:"M17 14v7",key:"7m2elx"}],["path",{d:"M7 14v7",key:"1cm7wv"}],["path",{d:"M17 3v3",key:"1v4jwn"}],["path",{d:"M7 3v3",key:"7o6guu"}],["path",{d:"M10 14 2.3 6.3",key:"1023jk"}],["path",{d:"m14 6 7.7 7.7",key:"1s8pl2"}],["path",{d:"m8 6 8 8",key:"hl96qh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p2=Z("ContactRound",[["path",{d:"M16 2v2",key:"scm5qe"}],["path",{d:"M17.915 22a6 6 0 0 0-12 0",key:"suqz9p"}],["path",{d:"M8 2v2",key:"pbkmx"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ok=Z("Contact",[["path",{d:"M16 2v2",key:"scm5qe"}],["path",{d:"M7 22v-2a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2",key:"1waht3"}],["path",{d:"M8 2v2",key:"pbkmx"}],["circle",{cx:"12",cy:"11",r:"3",key:"itu57m"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q$=Z("Container",[["path",{d:"M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z",key:"1t2lqe"}],["path",{d:"M10 21.9V14L2.1 9.1",key:"o7czzq"}],["path",{d:"m10 14 11.9-6.9",key:"zm5e20"}],["path",{d:"M14 19.8v-8.1",key:"159ecu"}],["path",{d:"M18 17.5V9.4",key:"11uown"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J$=Z("Contrast",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 18a6 6 0 0 0 0-12v12z",key:"j4l70d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eq=Z("Cookie",[["path",{d:"M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5",key:"laymnq"}],["path",{d:"M8.5 8.5v.01",key:"ue8clq"}],["path",{d:"M16 15.5v.01",key:"14dtrp"}],["path",{d:"M12 12v.01",key:"u5ubse"}],["path",{d:"M11 17v.01",key:"1hyl5a"}],["path",{d:"M7 14v.01",key:"uct60s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tq=Z("CookingPot",[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M20 12v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8",key:"u0tga0"}],["path",{d:"m4 8 16-4",key:"16g0ng"}],["path",{d:"m8.86 6.78-.45-1.81a2 2 0 0 1 1.45-2.43l1.94-.48a2 2 0 0 1 2.43 1.46l.45 1.8",key:"12cejc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sq=Z("CopyCheck",[["path",{d:"m12 15 2 2 4-4",key:"2c609p"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rq=Z("CopyMinus",[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nq=Z("CopyPlus",[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aq=Z("CopySlash",[["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iq=Z("CopyX",[["line",{x1:"12",x2:"18",y1:"12",y2:"18",key:"1rg63v"}],["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ai=Z("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oq=Z("Copyleft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.17 14.83a4 4 0 1 0 0-5.66",key:"1sveal"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lq=Z("Copyright",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M14.83 14.83a4 4 0 1 1 0-5.66",key:"1i56pz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cq=Z("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dq=Z("CornerDownRight",[["polyline",{points:"15 10 20 15 15 20",key:"1q7qjw"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uq=Z("CornerLeftDown",[["polyline",{points:"14 15 9 20 4 15",key:"nkc4i"}],["path",{d:"M20 4h-7a4 4 0 0 0-4 4v12",key:"nbpdq2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hq=Z("CornerLeftUp",[["polyline",{points:"14 9 9 4 4 9",key:"m9oyvo"}],["path",{d:"M20 20h-7a4 4 0 0 1-4-4V4",key:"1blwi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mq=Z("CornerRightDown",[["polyline",{points:"10 15 15 20 20 15",key:"axus6l"}],["path",{d:"M4 4h7a4 4 0 0 1 4 4v12",key:"wcbgct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pq=Z("CornerRightUp",[["polyline",{points:"10 9 15 4 20 9",key:"1lr6px"}],["path",{d:"M4 20h7a4 4 0 0 0 4-4V4",key:"1plgdj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fq=Z("CornerUpLeft",[["polyline",{points:"9 14 4 9 9 4",key:"881910"}],["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gq=Z("CornerUpRight",[["polyline",{points:"15 14 20 9 15 4",key:"1tbx3s"}],["path",{d:"M4 20v-7a4 4 0 0 1 4-4h12",key:"1lu4f8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xq=Z("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yq=Z("CreativeCommons",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M10 9.3a2.8 2.8 0 0 0-3.5 1 3.1 3.1 0 0 0 0 3.4 2.7 2.7 0 0 0 3.5 1",key:"1ss3eq"}],["path",{d:"M17 9.3a2.8 2.8 0 0 0-3.5 1 3.1 3.1 0 0 0 0 3.4 2.7 2.7 0 0 0 3.5 1",key:"1od56t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yf=Z("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vq=Z("Croissant",[["path",{d:"m4.6 13.11 5.79-3.21c1.89-1.05 4.79 1.78 3.71 3.71l-3.22 5.81C8.8 23.16.79 15.23 4.6 13.11Z",key:"1ozxlb"}],["path",{d:"m10.5 9.5-1-2.29C9.2 6.48 8.8 6 8 6H4.5C2.79 6 2 6.5 2 8.5a7.71 7.71 0 0 0 2 4.83",key:"ffuyb5"}],["path",{d:"M8 6c0-1.55.24-4-2-4-2 0-2.5 2.17-2.5 4",key:"osnpzi"}],["path",{d:"m14.5 13.5 2.29 1c.73.3 1.21.7 1.21 1.5v3.5c0 1.71-.5 2.5-2.5 2.5a7.71 7.71 0 0 1-4.83-2",key:"1vubaw"}],["path",{d:"M18 16c1.55 0 4-.24 4 2 0 2-2.17 2.5-4 2.5",key:"wxr772"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _q=Z("Crop",[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bq=Z("Cross",[["path",{d:"M4 9a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h4a1 1 0 0 1 1 1v4a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-4a1 1 0 0 1 1-1h4a2 2 0 0 0 2-2v-2a2 2 0 0 0-2-2h-4a1 1 0 0 1-1-1V4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4a1 1 0 0 1-1 1z",key:"1xbrqy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wq=Z("Crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uh=Z("Crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jq=Z("Cuboid",[["path",{d:"m21.12 6.4-6.05-4.06a2 2 0 0 0-2.17-.05L2.95 8.41a2 2 0 0 0-.95 1.7v5.82a2 2 0 0 0 .88 1.66l6.05 4.07a2 2 0 0 0 2.17.05l9.95-6.12a2 2 0 0 0 .95-1.7V8.06a2 2 0 0 0-.88-1.66Z",key:"1u2ovd"}],["path",{d:"M10 22v-8L2.25 9.15",key:"11pn4q"}],["path",{d:"m10 14 11.77-6.87",key:"1kt1wh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nq=Z("CupSoda",[["path",{d:"m6 8 1.75 12.28a2 2 0 0 0 2 1.72h4.54a2 2 0 0 0 2-1.72L18 8",key:"8166m8"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M7 15a6.47 6.47 0 0 1 5 0 6.47 6.47 0 0 0 5 0",key:"yjz344"}],["path",{d:"m12 8 1-6h2",key:"3ybfa4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kq=Z("Currency",[["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}],["line",{x1:"3",x2:"6",y1:"3",y2:"6",key:"1jkytn"}],["line",{x1:"21",x2:"18",y1:"3",y2:"6",key:"14zfjt"}],["line",{x1:"3",x2:"6",y1:"21",y2:"18",key:"iusuec"}],["line",{x1:"21",x2:"18",y1:"21",y2:"18",key:"yj2dd7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sq=Z("Cylinder",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cq=Z("Dam",[["path",{d:"M11 11.31c1.17.56 1.54 1.69 3.5 1.69 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"157kva"}],["path",{d:"M11.75 18c.35.5 1.45 1 2.75 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"d7q6m6"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M7 3a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1L10 4a1 1 0 0 0-1-1z",key:"pr6s65"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mq=Z("DatabaseBackup",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 12a9 3 0 0 0 5 2.69",key:"1ui2ym"}],["path",{d:"M21 9.3V5",key:"6k6cib"}],["path",{d:"M3 5v14a9 3 0 0 0 6.47 2.88",key:"i62tjy"}],["path",{d:"M12 12v4h4",key:"1bxaet"}],["path",{d:"M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16",key:"1f4ei9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tq=Z("DatabaseZap",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 15 21.84",key:"14ibmq"}],["path",{d:"M21 5V8",key:"1marbg"}],["path",{d:"M21 12L18 17H22L19 22",key:"zafso"}],["path",{d:"M3 12A9 3 0 0 0 14.59 14.87",key:"1y4wr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aq=Z("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eq=Z("Delete",[["path",{d:"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",key:"1yo7s0"}],["path",{d:"m12 9 6 6",key:"anjzzh"}],["path",{d:"m18 9-6 6",key:"1fp51s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pq=Z("Dessert",[["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}],["path",{d:"M10.2 3.2C5.5 4 2 8.1 2 13a2 2 0 0 0 4 0v-1a2 2 0 0 1 4 0v4a2 2 0 0 0 4 0v-4a2 2 0 0 1 4 0v1a2 2 0 0 0 4 0c0-4.9-3.5-9-8.2-9.8",key:"lfo06j"}],["path",{d:"M3.2 14.8a9 9 0 0 0 17.6 0",key:"12xarc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iq=Z("Diameter",[["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["circle",{cx:"5",cy:"5",r:"2",key:"1gwv83"}],["path",{d:"M6.48 3.66a10 10 0 0 1 13.86 13.86",key:"xr8kdq"}],["path",{d:"m6.41 6.41 11.18 11.18",key:"uhpjw7"}],["path",{d:"M3.66 6.48a10 10 0 0 0 13.86 13.86",key:"cldpwv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lq=Z("DiamondMinus",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f2=Z("DiamondPercent",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0Z",key:"1tpxz2"}],["path",{d:"M9.2 9.2h.01",key:"1b7bvt"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"M14.7 14.8h.01",key:"17nsh4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dq=Z("DiamondPlus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oq=Z("Diamond",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rq=Z("Dice1",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fq=Z("Dice2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M15 9h.01",key:"x1ddxp"}],["path",{d:"M9 15h.01",key:"fzyn71"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zq=Z("Dice3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bq=Z("Dice4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $q=Z("Dice5",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qq=Z("Dice6",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uq=Z("Dices",[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vq=Z("Diff",[["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 10h14",key:"elsbfy"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hq=Z("Disc2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wq=Z("Disc3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M6 12c0-1.7.7-3.2 1.8-4.2",key:"oqkarx"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M18 12c0 1.7-.7 3.2-1.8 4.2",key:"1eah9h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gq=Z("DiscAlbum",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"5",key:"nd82uf"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kq=Z("Disc",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zq=Z("Divide",[["circle",{cx:"12",cy:"6",r:"1",key:"1bh7o1"}],["line",{x1:"5",x2:"19",y1:"12",y2:"12",key:"13b5wn"}],["circle",{cx:"12",cy:"18",r:"1",key:"lqb9t5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yq=Z("DnaOff",[["path",{d:"M15 2c-1.35 1.5-2.092 3-2.5 4.5L14 8",key:"1bivrr"}],["path",{d:"m17 6-2.891-2.891",key:"xu6p2f"}],["path",{d:"M2 15c3.333-3 6.667-3 10-3",key:"nxix30"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m20 9 .891.891",key:"3xwk7g"}],["path",{d:"M22 9c-1.5 1.35-3 2.092-4.5 2.5l-1-1",key:"18cutr"}],["path",{d:"M3.109 14.109 4 15",key:"q76aoh"}],["path",{d:"m6.5 12.5 1 1",key:"cs35ky"}],["path",{d:"m7 18 2.891 2.891",key:"1sisit"}],["path",{d:"M9 22c1.35-1.5 2.092-3 2.5-4.5L10 16",key:"rlvei3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xq=Z("Dna",[["path",{d:"m10 16 1.5 1.5",key:"11lckj"}],["path",{d:"m14 8-1.5-1.5",key:"1ohn8i"}],["path",{d:"M15 2c-1.798 1.998-2.518 3.995-2.807 5.993",key:"80uv8i"}],["path",{d:"m16.5 10.5 1 1",key:"696xn5"}],["path",{d:"m17 6-2.891-2.891",key:"xu6p2f"}],["path",{d:"M2 15c6.667-6 13.333 0 20-6",key:"1pyr53"}],["path",{d:"m20 9 .891.891",key:"3xwk7g"}],["path",{d:"M3.109 14.109 4 15",key:"q76aoh"}],["path",{d:"m6.5 12.5 1 1",key:"cs35ky"}],["path",{d:"m7 18 2.891 2.891",key:"1sisit"}],["path",{d:"M9 22c1.798-1.998 2.518-3.995 2.807-5.993",key:"q3hbxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qq=Z("Dock",[["path",{d:"M2 8h20",key:"d11cs7"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 16h12",key:"u522kt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jq=Z("Dog",[["path",{d:"M11.25 16.25h1.5L12 17z",key:"w7jh35"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M4.42 11.247A13.152 13.152 0 0 0 4 14.556C4 18.728 7.582 21 12 21s8-2.272 8-6.444a11.702 11.702 0 0 0-.493-3.309",key:"u7s9ue"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M8.5 8.5c-.384 1.05-1.083 2.028-2.344 2.5-1.931.722-3.576-.297-3.656-1-.113-.994 1.177-6.53 4-7 1.923-.321 3.651.845 3.651 2.235A7.497 7.497 0 0 1 14 5.277c0-1.39 1.844-2.598 3.767-2.277 2.823.47 4.113 6.006 4 7-.08.703-1.725 1.722-3.656 1-1.261-.472-1.855-1.45-2.239-2.5",key:"v8hric"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const od=Z("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eU=Z("Donut",[["path",{d:"M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3",key:"19sr3x"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tU=Z("DoorClosed",[["path",{d:"M18 20V6a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v14",key:"36qu9e"}],["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"M14 12v.01",key:"xfcn54"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P0=Z("DoorOpen",[["path",{d:"M13 4h3a2 2 0 0 1 2 2v14",key:"hrm0s9"}],["path",{d:"M2 20h3",key:"1gaodv"}],["path",{d:"M13 20h9",key:"s90cdi"}],["path",{d:"M10 12v.01",key:"vx6srw"}],["path",{d:"M13 4.562v16.157a1 1 0 0 1-1.242.97L5 20V5.562a2 2 0 0 1 1.515-1.94l4-1A2 2 0 0 1 13 4.561Z",key:"199qr4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sU=Z("Dot",[["circle",{cx:"12.1",cy:"12.1",r:"1",key:"18d7e5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xi=Z("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rU=Z("DraftingCompass",[["path",{d:"m12.99 6.74 1.93 3.44",key:"iwagvd"}],["path",{d:"M19.136 12a10 10 0 0 1-14.271 0",key:"ppmlo4"}],["path",{d:"m21 21-2.16-3.84",key:"vylbct"}],["path",{d:"m3 21 8.02-14.26",key:"1ssaw4"}],["circle",{cx:"12",cy:"5",r:"2",key:"f1ur92"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nU=Z("Drama",[["path",{d:"M10 11h.01",key:"d2at3l"}],["path",{d:"M14 6h.01",key:"k028ub"}],["path",{d:"M18 6h.01",key:"1v4wsw"}],["path",{d:"M6.5 13.1h.01",key:"1748ia"}],["path",{d:"M22 5c0 9-4 12-6 12s-6-3-6-12c0-2 2-3 6-3s6 1 6 3",key:"172yzv"}],["path",{d:"M17.4 9.9c-.8.8-2 .8-2.8 0",key:"1obv0w"}],["path",{d:"M10.1 7.1C9 7.2 7.7 7.7 6 8.6c-3.5 2-4.7 3.9-3.7 5.6 4.5 7.8 9.5 8.4 11.2 7.4.9-.5 1.9-2.1 1.9-4.7",key:"rqjl8i"}],["path",{d:"M9.1 16.5c.3-1.1 1.4-1.7 2.4-1.4",key:"1mr6wy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aU=Z("Dribbble",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M19.13 5.09C15.22 9.14 10 10.44 2.25 10.94",key:"hpej1"}],["path",{d:"M21.75 12.84c-6.62-1.41-12.14 1-16.38 6.32",key:"1tr44o"}],["path",{d:"M8.56 2.75c4.37 6 6 9.42 8 17.72",key:"kbh691"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iU=Z("Drill",[["path",{d:"M10 18a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H5a3 3 0 0 1-3-3 1 1 0 0 1 1-1z",key:"ioqxb1"}],["path",{d:"M13 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1l-.81 3.242a1 1 0 0 1-.97.758H8",key:"1rs59n"}],["path",{d:"M14 4h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-3",key:"105ega"}],["path",{d:"M18 6h4",key:"66u95g"}],["path",{d:"m5 10-2 8",key:"xt2lic"}],["path",{d:"m7 18 2-8",key:"1bzku2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oU=Z("Droplet",[["path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z",key:"c7niix"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vg=Z("Droplets",[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lU=Z("Drum",[["path",{d:"m2 2 8 8",key:"1v6059"}],["path",{d:"m22 2-8 8",key:"173r8a"}],["ellipse",{cx:"12",cy:"9",rx:"10",ry:"5",key:"liohsx"}],["path",{d:"M7 13.4v7.9",key:"1yi6u9"}],["path",{d:"M12 14v8",key:"1tn2tj"}],["path",{d:"M17 13.4v7.9",key:"eqz2v3"}],["path",{d:"M2 9v8a10 5 0 0 0 20 0V9",key:"1750ul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cU=Z("Drumstick",[["path",{d:"M15.4 15.63a7.875 6 135 1 1 6.23-6.23 4.5 3.43 135 0 0-6.23 6.23",key:"1dtqwm"}],["path",{d:"m8.29 12.71-2.6 2.6a2.5 2.5 0 1 0-1.65 4.65A2.5 2.5 0 1 0 8.7 18.3l2.59-2.59",key:"1oq1fw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dU=Z("Dumbbell",[["path",{d:"M14.4 14.4 9.6 9.6",key:"ic80wn"}],["path",{d:"M18.657 21.485a2 2 0 1 1-2.829-2.828l-1.767 1.768a2 2 0 1 1-2.829-2.829l6.364-6.364a2 2 0 1 1 2.829 2.829l-1.768 1.767a2 2 0 1 1 2.828 2.829z",key:"nnl7wr"}],["path",{d:"m21.5 21.5-1.4-1.4",key:"1f1ice"}],["path",{d:"M3.9 3.9 2.5 2.5",key:"1evmna"}],["path",{d:"M6.404 12.768a2 2 0 1 1-2.829-2.829l1.768-1.767a2 2 0 1 1-2.828-2.829l2.828-2.828a2 2 0 1 1 2.829 2.828l1.767-1.768a2 2 0 1 1 2.829 2.829z",key:"yhosts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uU=Z("EarOff",[["path",{d:"M6 18.5a3.5 3.5 0 1 0 7 0c0-1.57.92-2.52 2.04-3.46",key:"1qngmn"}],["path",{d:"M6 8.5c0-.75.13-1.47.36-2.14",key:"b06bma"}],["path",{d:"M8.8 3.15A6.5 6.5 0 0 1 19 8.5c0 1.63-.44 2.81-1.09 3.76",key:"g10hsz"}],["path",{d:"M12.5 6A2.5 2.5 0 0 1 15 8.5M10 13a2 2 0 0 0 1.82-1.18",key:"ygzou7"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hU=Z("Ear",[["path",{d:"M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0",key:"1dfaln"}],["path",{d:"M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4",key:"1qnva7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mU=Z("EarthLock",[["path",{d:"M7 3.34V5a3 3 0 0 0 3 3",key:"w732o8"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"f02343"}],["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M12 2a10 10 0 1 0 9.54 13",key:"zjsr6q"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g2=Z("Earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pU=Z("Eclipse",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a7 7 0 1 0 10 10",key:"1yuj32"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fU=Z("EggFried",[["circle",{cx:"11.5",cy:"12.5",r:"3.5",key:"1cl1mi"}],["path",{d:"M3 8c0-3.5 2.5-6 6.5-6 5 0 4.83 3 7.5 5s5 2 5 6c0 4.5-2.5 6.5-7 6.5-2.5 0-2.5 2.5-6 2.5s-7-2-7-5.5c0-3 1.5-3 1.5-5C3.5 10 3 9 3 8Z",key:"165ef9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gU=Z("EggOff",[["path",{d:"M6.399 6.399C5.362 8.157 4.65 10.189 4.5 12c-.37 4.43 1.27 9.95 7.5 10 3.256-.026 5.259-1.547 6.375-3.625",key:"6et380"}],["path",{d:"M19.532 13.875A14.07 14.07 0 0 0 19.5 12c-.36-4.34-3.95-9.96-7.5-10-1.04.012-2.082.502-3.046 1.297",key:"gcdc3f"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f5=Z("Egg",[["path",{d:"M12 22c6.23-.05 7.87-5.57 7.5-10-.36-4.34-3.95-9.96-7.5-10-3.55.04-7.14 5.66-7.5 10-.37 4.43 1.27 9.95 7.5 10z",key:"1c39pg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const af=Z("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const of=Z("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xU=Z("EqualApproximately",[["path",{d:"M5 15a6.5 6.5 0 0 1 7 0 6.5 6.5 0 0 0 7 0",key:"yrdkhy"}],["path",{d:"M5 9a6.5 6.5 0 0 1 7 0 6.5 6.5 0 0 0 7 0",key:"gzkvyz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yU=Z("EqualNot",[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}],["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vU=Z("Equal",[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _U=Z("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bU=Z("EthernetPort",[["path",{d:"m15 20 3-3h2a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h2l3 3z",key:"rbahqx"}],["path",{d:"M6 8v1",key:"1636ez"}],["path",{d:"M10 8v1",key:"1talb4"}],["path",{d:"M14 8v1",key:"1rsfgr"}],["path",{d:"M18 8v1",key:"gnkwox"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wU=Z("Euro",[["path",{d:"M4 10h12",key:"1y6xl8"}],["path",{d:"M4 14h9",key:"1loblj"}],["path",{d:"M19 6a7.7 7.7 0 0 0-5.2-2A7.9 7.9 0 0 0 6 12c0 4.4 3.5 8 7.8 8 2 0 3.8-.8 5.2-2",key:"1j6lzo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jU=Z("Expand",[["path",{d:"m21 21-6-6m6 6v-4.8m0 4.8h-4.8",key:"1c15vz"}],["path",{d:"M3 16.2V21m0 0h4.8M3 21l6-6",key:"1fsnz2"}],["path",{d:"M21 7.8V3m0 0h-4.8M21 3l-6 6",key:"hawz9i"}],["path",{d:"M3 7.8V3m0 0h4.8M3 3l6 6",key:"u9ee12"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sn=Z("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NU=Z("EyeClosed",[["path",{d:"m15 18-.722-3.25",key:"1j64jw"}],["path",{d:"M2 8a10.645 10.645 0 0 0 20 0",key:"1e7gxb"}],["path",{d:"m20 15-1.726-2.05",key:"1cnuld"}],["path",{d:"m4 15 1.726-2.05",key:"1dsqqd"}],["path",{d:"m9 18 .722-3.25",key:"ypw2yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Im=Z("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xa=Z("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hd=Z("Facebook",[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kU=Z("Factory",[["path",{d:"M2 20a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8l-7 5V8l-7 5V4a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"159hny"}],["path",{d:"M17 18h1",key:"uldtlt"}],["path",{d:"M12 18h1",key:"s9uhes"}],["path",{d:"M7 18h1",key:"1neino"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SU=Z("Fan",[["path",{d:"M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z",key:"484a7f"}],["path",{d:"M12 12v.01",key:"u5ubse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CU=Z("FastForward",[["polygon",{points:"13 19 22 12 13 5 13 19",key:"587y9g"}],["polygon",{points:"2 19 11 12 2 5 2 19",key:"3pweh0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MU=Z("Feather",[["path",{d:"M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z",key:"18jl4k"}],["path",{d:"M16 8 2 22",key:"vp34q"}],["path",{d:"M17.5 15H9",key:"1oz8nu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TU=Z("Fence",[["path",{d:"M4 3 2 5v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"1n2rgs"}],["path",{d:"M6 8h4",key:"utf9t1"}],["path",{d:"M6 18h4",key:"12yh4b"}],["path",{d:"m12 3-2 2v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"3ha7mj"}],["path",{d:"M14 8h4",key:"1r8wg2"}],["path",{d:"M14 18h4",key:"1t3kbu"}],["path",{d:"m20 3-2 2v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"dfd4e2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AU=Z("FerrisWheel",[["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m6.8 15-3.5 2",key:"hjy98k"}],["path",{d:"m20.7 7-3.5 2",key:"f08gto"}],["path",{d:"M6.8 9 3.3 7",key:"1aevh4"}],["path",{d:"m20.7 17-3.5-2",key:"1liqo3"}],["path",{d:"m9 22 3-8 3 8",key:"wees03"}],["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M18 18.7a9 9 0 1 0-12 0",key:"dhzg4g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EU=Z("Figma",[["path",{d:"M5 5.5A3.5 3.5 0 0 1 8.5 2H12v7H8.5A3.5 3.5 0 0 1 5 5.5z",key:"1340ok"}],["path",{d:"M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2z",key:"1hz3m3"}],["path",{d:"M12 12.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 1 1-7 0z",key:"1oz8n2"}],["path",{d:"M5 19.5A3.5 3.5 0 0 1 8.5 16H12v3.5a3.5 3.5 0 1 1-7 0z",key:"1ff65i"}],["path",{d:"M5 12.5A3.5 3.5 0 0 1 8.5 9H12v7H8.5A3.5 3.5 0 0 1 5 12.5z",key:"pdip6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PU=Z("FileArchive",[["path",{d:"M10 12v-1",key:"v7bkov"}],["path",{d:"M10 18v-2",key:"1cjy8d"}],["path",{d:"M10 7V6",key:"dljcrl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01",key:"gkbcor"}],["circle",{cx:"10",cy:"20",r:"2",key:"1xzdoj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IU=Z("FileAudio2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2",key:"17k7jt"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"3",cy:"17",r:"1",key:"vo6nti"}],["path",{d:"M2 17v-3a4 4 0 0 1 8 0v3",key:"1ggdre"}],["circle",{cx:"9",cy:"17",r:"1",key:"bc1fq4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LU=Z("FileAudio",[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x2=Z("FileAxis3d",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 18 4-4",key:"12zab0"}],["path",{d:"M8 10v8h8",key:"tlaukw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DU=Z("FileBadge2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14 12.5 1 5.5-3-1-3 1 1-5.5",key:"14xlky"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OU=Z("FileBadge",[["path",{d:"M12 22h6a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"12ixgl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M5 17a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",key:"u0c8gj"}],["path",{d:"M7 16.5 8 22l-3-1-3 1 1-5.5",key:"5gm2nr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RU=Z("FileBox",[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"16lz6z"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 13.1a2 2 0 0 0-1 1.76v3.24a2 2 0 0 0 .97 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01Z",key:"99pj1s"}],["path",{d:"M7 17v5",key:"1yj1jh"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y2=Z("FileChartColumnIncreasing",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M12 18v-4",key:"q1q25u"}],["path",{d:"M16 18v-6",key:"15y0np"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v2=Z("FileChartColumn",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-1",key:"zg0ygc"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"M16 18v-3",key:"j5jt4h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _2=Z("FileChartLine",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m16 13-3.5 3.5-2-2L8 17",key:"zz7yod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b2=Z("FileChartPie",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3.5",key:"13ddob"}],["path",{d:"M4.017 11.512a6 6 0 1 0 8.466 8.475",key:"s6vs5t"}],["path",{d:"M9 16a1 1 0 0 1-1-1v-4c0-.552.45-1.008.995-.917a6 6 0 0 1 4.922 4.922c.091.544-.365.995-.917.995z",key:"1dl6s6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FU=Z("FileCheck2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3 15 2 2 4-4",key:"1lhrkk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zU=Z("FileCheck",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BU=Z("FileClock",[["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"37hlfg"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"8",cy:"16",r:"6",key:"10v15b"}],["path",{d:"M9.5 17.5 8 16.25V14",key:"1o80t2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $U=Z("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qU=Z("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w2=Z("FileCog",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3.2 12.9-.9-.4",key:"1i3dj5"}],["path",{d:"m3.2 15.1-.9.4",key:"1fvgj0"}],["path",{d:"M4.677 21.5a2 2 0 0 0 1.313.5H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2.5",key:"1yo3oz"}],["path",{d:"m4.9 11.2-.4-.9",key:"otmhb9"}],["path",{d:"m4.9 16.8-.4.9",key:"1b8z07"}],["path",{d:"m7.5 10.3-.4.9",key:"11k65u"}],["path",{d:"m7.5 17.7-.4-.9",key:"431x55"}],["path",{d:"m9.7 12.5-.9.4",key:"87sjan"}],["path",{d:"m9.7 15.5-.9-.4",key:"khqm91"}],["circle",{cx:"6",cy:"14",r:"3",key:"a1xfv6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UU=Z("FileDiff",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VU=Z("FileDigit",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"4",height:"6",x:"2",y:"12",rx:"2",key:"jm304g"}],["path",{d:"M10 12h2v6",key:"12zw74"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HU=Z("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WU=Z("FileHeart",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2",key:"17k7jt"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10.29 10.7a2.43 2.43 0 0 0-2.66-.52c-.29.12-.56.3-.78.53l-.35.34-.35-.34a2.43 2.43 0 0 0-2.65-.53c-.3.12-.56.3-.79.53-.95.94-1 2.53.2 3.74L6.5 18l3.6-3.55c1.2-1.21 1.14-2.8.19-3.74Z",key:"1c1fso"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i_=Z("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GU=Z("FileInput",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 15h10",key:"jfw4w8"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KU=Z("FileJson2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"fq0c9t"}],["path",{d:"M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"4gibmv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZU=Z("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YU=Z("FileKey2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v6",key:"rc0qvx"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"m10 10-4.5 4.5",key:"7fwrp6"}],["path",{d:"m9 11 1 1",key:"wa6s5q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XU=Z("FileKey",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["circle",{cx:"10",cy:"16",r:"2",key:"4ckbqe"}],["path",{d:"m16 10-4.5 4.5",key:"7p3ebg"}],["path",{d:"m15 11 1 1",key:"1bsyx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QU=Z("FileLock2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v1",key:"jmtmu2"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"8",height:"5",x:"2",y:"13",rx:"1",key:"10y5wo"}],["path",{d:"M8 13v-2a2 2 0 1 0-4 0v2",key:"1pdxzg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JU=Z("FileLock",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["rect",{width:"8",height:"6",x:"8",y:"12",rx:"1",key:"3yr8at"}],["path",{d:"M10 12v-2a2 2 0 1 1 4 0v2",key:"j4i8d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eV=Z("FileMinus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tV=Z("FileMinus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sV=Z("FileMusic",[["path",{d:"M10.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v8.4",key:"1d3kfm"}],["path",{d:"M8 18v-7.7L16 9v7",key:"1oie6o"}],["circle",{cx:"14",cy:"16",r:"2",key:"1bzzi3"}],["circle",{cx:"6",cy:"18",r:"2",key:"1fncim"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rV=Z("FileOutput",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j2=Z("FilePenLine",[["path",{d:"m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",key:"142zxg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N2=Z("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nV=Z("FilePlus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aV=Z("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iV=Z("FileQuestion",[["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oV=Z("FileScan",[["path",{d:"M20 10V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h4",key:"1rdf37"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M16 14a2 2 0 0 0-2 2",key:"ceaadl"}],["path",{d:"M20 14a2 2 0 0 1 2 2",key:"1ny6zw"}],["path",{d:"M20 22a2 2 0 0 0 2-2",key:"1l9q4k"}],["path",{d:"M16 22a2 2 0 0 1-2-2",key:"1wqh5n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lV=Z("FileSearch2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cV=Z("FileSearch",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dV=Z("FileSliders",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M10 11v2",key:"1s651w"}],["path",{d:"M8 17h8",key:"wh5c61"}],["path",{d:"M14 16v2",key:"12fp5e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I0=Z("FileSpreadsheet",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mP=Z("FileStack",[["path",{d:"M21 7h-3a2 2 0 0 1-2-2V2",key:"9rb54x"}],["path",{d:"M21 6v6.5c0 .8-.7 1.5-1.5 1.5h-7c-.8 0-1.5-.7-1.5-1.5v-9c0-.8.7-1.5 1.5-1.5H17Z",key:"1059l0"}],["path",{d:"M7 8v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H15",key:"16874u"}],["path",{d:"M3 12v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H11",key:"k2ox98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uV=Z("FileSymlink",[["path",{d:"m10 18 3-3-3-3",key:"18f6ys"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 11V4a2 2 0 0 1 2-2h9l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"50q2rw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hV=Z("FileTerminal",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 16 2-2-2-2",key:"10vzyd"}],["path",{d:"M12 18h4",key:"1wd2n7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const In=Z("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mV=Z("FileType2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 13v-1h6v1",key:"1dh9dg"}],["path",{d:"M5 12v6",key:"150t9c"}],["path",{d:"M4 18h2",key:"1xrofg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pV=Z("FileType",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fV=Z("FileUp",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gV=Z("FileUser",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 18a3 3 0 1 0-6 0",key:"16awa0"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xV=Z("FileVideo2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"8",height:"6",x:"2",y:"12",rx:"1",key:"1a6c1e"}],["path",{d:"m10 15.5 4 2.5v-6l-4 2.5",key:"t7cp39"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yV=Z("FileVideo",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m10 11 5 3-5 3v-6Z",key:"7ntvm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vV=Z("FileVolume2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M11.5 13.5a2.5 2.5 0 0 1 0 3",key:"1fccat"}],["path",{d:"M15 12a5 5 0 0 1 0 6",key:"ps46cm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _V=Z("FileVolume",[["path",{d:"M11 11a5 5 0 0 1 0 6",key:"193qb2"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 6.765V4a2 2 0 0 1 2-2h9l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-.93-.23",key:"ifyjnl"}],["path",{d:"M7 10.51a.5.5 0 0 0-.826-.38l-1.893 1.628A1 1 0 0 1 3.63 12H2.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h1.129a1 1 0 0 1 .652.242l1.893 1.63a.5.5 0 0 0 .826-.38z",key:"mk8rxu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bV=Z("FileWarning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wV=Z("FileX2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 12.5-5 5",key:"b853mi"}],["path",{d:"m3 12.5 5 5",key:"1qls4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jV=Z("FileX",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g5=Z("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NV=Z("Files",[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lu=Z("Film",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kV=Z("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yx=Z("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SV=Z("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CV=Z("FireExtinguisher",[["path",{d:"M15 6.5V3a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3.5",key:"sqyvz"}],["path",{d:"M9 18h8",key:"i7pszb"}],["path",{d:"M18 3h-3",key:"7idoqj"}],["path",{d:"M11 3a6 6 0 0 0-6 6v11",key:"1v5je3"}],["path",{d:"M5 13h4",key:"svpcxo"}],["path",{d:"M17 10a4 4 0 0 0-8 0v10a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2Z",key:"vsjego"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MV=Z("FishOff",[["path",{d:"M18 12.47v.03m0-.5v.47m-.475 5.056A6.744 6.744 0 0 1 15 18c-3.56 0-7.56-2.53-8.5-6 .348-1.28 1.114-2.433 2.121-3.38m3.444-2.088A8.802 8.802 0 0 1 15 6c3.56 0 6.06 2.54 7 6-.309 1.14-.786 2.177-1.413 3.058",key:"1j1hse"}],["path",{d:"M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33m7.48-4.372A9.77 9.77 0 0 1 16 6.07m0 11.86a9.77 9.77 0 0 1-1.728-3.618",key:"1q46z8"}],["path",{d:"m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98M8.53 3h5.27a2 2 0 0 1 1.98 1.67l.23 1.4M2 2l20 20",key:"1407gh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TV=Z("FishSymbol",[["path",{d:"M2 16s9-15 20-4C11 23 2 8 2 8",key:"h4oh4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AV=Z("Fish",[["path",{d:"M6.5 12c.94-3.46 4.94-6 8.5-6 3.56 0 6.06 2.54 7 6-.94 3.47-3.44 6-7 6s-7.56-2.53-8.5-6Z",key:"15baut"}],["path",{d:"M18 12v.5",key:"18hhni"}],["path",{d:"M16 17.93a9.77 9.77 0 0 1 0-11.86",key:"16dt7o"}],["path",{d:"M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33",key:"l9di03"}],["path",{d:"M10.46 7.26C10.2 5.88 9.17 4.24 8 3h5.8a2 2 0 0 1 1.98 1.67l.23 1.4",key:"1kjonw"}],["path",{d:"m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98",key:"1zlm23"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EV=Z("FlagOff",[["path",{d:"M8 2c3 0 5 2 8 2s4-1 4-1v11",key:"9rwyz9"}],["path",{d:"M4 22V4",key:"1plyxx"}],["path",{d:"M4 15s1-1 4-1 5 2 8 2",key:"1myooe"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PV=Z("FlagTriangleLeft",[["path",{d:"M17 22V2L7 7l10 5",key:"1rmf0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IV=Z("FlagTriangleRight",[["path",{d:"M7 22V2l10 5-10 5",key:"17n18y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L0=Z("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LV=Z("FlameKindling",[["path",{d:"M12 2c1 3 2.5 3.5 3.5 4.5A5 5 0 0 1 17 10a5 5 0 1 1-10 0c0-.3 0-.6.1-.9a2 2 0 1 0 3.3-2C8 4.5 11 2 12 2Z",key:"1ir223"}],["path",{d:"m5 22 14-4",key:"1brv4h"}],["path",{d:"m5 18 14 4",key:"lgyyje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nh=Z("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DV=Z("FlashlightOff",[["path",{d:"M16 16v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V10c0-2-2-2-2-4",key:"1r120k"}],["path",{d:"M7 2h11v4c0 2-2 2-2 4v1",key:"dz1920"}],["line",{x1:"11",x2:"18",y1:"6",y2:"6",key:"bi1vpe"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OV=Z("Flashlight",[["path",{d:"M18 6c0 2-2 2-2 4v10a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V10c0-2-2-2-2-4V2h12z",key:"1orkel"}],["line",{x1:"6",x2:"18",y1:"6",y2:"6",key:"1z11jq"}],["line",{x1:"12",x2:"12",y1:"12",y2:"12",key:"1f4yc1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RV=Z("FlaskConicalOff",[["path",{d:"M10 10 4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-1.272-2.542",key:"59ek9y"}],["path",{d:"M10 2v2.343",key:"15t272"}],["path",{d:"M14 2v6.343",key:"sxr80q"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h9",key:"t5njau"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o_=Z("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FV=Z("FlaskRound",[["path",{d:"M10 2v7.31",key:"5d1hyh"}],["path",{d:"M14 9.3V1.99",key:"14k4l0"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14 9.3a6.5 6.5 0 1 1-4 0",key:"1r8fvy"}],["path",{d:"M5.52 16h12.96",key:"46hh1i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zV=Z("FlipHorizontal2",[["path",{d:"m3 7 5 5-5 5V7",key:"couhi7"}],["path",{d:"m21 7-5 5 5 5V7",key:"6ouia7"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BV=Z("FlipHorizontal",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h3",key:"1i73f7"}],["path",{d:"M16 3h3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-3",key:"saxlbk"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $V=Z("FlipVertical2",[["path",{d:"m17 3-5 5-5-5h10",key:"1ftt6x"}],["path",{d:"m17 21-5-5-5 5h10",key:"1m0wmu"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qV=Z("FlipVertical",[["path",{d:"M21 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v3",key:"14bfxa"}],["path",{d:"M21 16v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-3",key:"14rx03"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Og=Z("Flower2",[["path",{d:"M12 5a3 3 0 1 1 3 3m-3-3a3 3 0 1 0-3 3m3-3v1M9 8a3 3 0 1 0 3 3M9 8h1m5 0a3 3 0 1 1-3 3m3-3h-1m-2 3v-1",key:"3pnvol"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M12 10v12",key:"6ubwww"}],["path",{d:"M12 22c4.2 0 7-1.667 7-5-4.2 0-7 1.667-7 5Z",key:"9hd38g"}],["path",{d:"M12 22c-4.2 0-7-1.667-7-5 4.2 0 7 1.667 7 5Z",key:"ufn41s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UV=Z("Flower",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 16.5A4.5 4.5 0 1 1 7.5 12 4.5 4.5 0 1 1 12 7.5a4.5 4.5 0 1 1 4.5 4.5 4.5 4.5 0 1 1-4.5 4.5",key:"14wa3c"}],["path",{d:"M12 7.5V9",key:"1oy5b0"}],["path",{d:"M7.5 12H9",key:"eltsq1"}],["path",{d:"M16.5 12H15",key:"vk5kw4"}],["path",{d:"M12 16.5V15",key:"k7eayi"}],["path",{d:"m8 8 1.88 1.88",key:"nxy4qf"}],["path",{d:"M14.12 9.88 16 8",key:"1lst6k"}],["path",{d:"m8 16 1.88-1.88",key:"h2eex1"}],["path",{d:"M14.12 14.12 16 16",key:"uqkrx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VV=Z("Focus",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HV=Z("FoldHorizontal",[["path",{d:"M2 12h6",key:"1wqiqv"}],["path",{d:"M22 12h-6",key:"1eg9hc"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m19 9-3 3 3 3",key:"12ol22"}],["path",{d:"m5 15 3-3-3-3",key:"1kdhjc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WV=Z("FoldVertical",[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3-3-3 3",key:"e37ymu"}],["path",{d:"m15 5-3 3-3-3",key:"19d6lf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GV=Z("FolderArchive",[["circle",{cx:"15",cy:"19",r:"2",key:"u2pros"}],["path",{d:"M20.9 19.8A2 2 0 0 0 22 18V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h5.1",key:"1jj40k"}],["path",{d:"M15 11v-1",key:"cntcp"}],["path",{d:"M15 17v-2",key:"1279jj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KV=Z("FolderCheck",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"m9 13 2 2 4-4",key:"6343dt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZV=Z("FolderClock",[["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}],["path",{d:"M7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2",key:"1urifu"}],["path",{d:"M16 14v2l1 1",key:"xth2jh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YV=Z("FolderClosed",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M2 10h20",key:"1ir3d8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XV=Z("FolderCode",[["path",{d:"M10 10.5 8 13l2 2.5",key:"m4t9c1"}],["path",{d:"m14 10.5 2 2.5-2 2.5",key:"14w2eb"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2z",key:"1u1bxd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k2=Z("FolderCog",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"M10.3 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v3.3",key:"1k8050"}],["path",{d:"m21.7 19.4-.9-.3",key:"1qgwi9"}],["path",{d:"m15.2 16.9-.9-.3",key:"1t7mvx"}],["path",{d:"m16.6 21.7.3-.9",key:"1j67ps"}],["path",{d:"m19.1 15.2.3-.9",key:"18r7jp"}],["path",{d:"m19.6 21.7-.4-1",key:"z2vh2"}],["path",{d:"m16.8 15.3-.4-1",key:"1ei7r6"}],["path",{d:"m14.3 19.6 1-.4",key:"11sv9r"}],["path",{d:"m20.7 16.8 1-.4",key:"19m87a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QV=Z("FolderDot",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["circle",{cx:"12",cy:"13",r:"1",key:"49l61u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JV=Z("FolderDown",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m15 13-3 3-3-3",key:"6j2sf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eH=Z("FolderGit2",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["path",{d:"M18 19c-2.8 0-5-2.2-5-5v8",key:"pkpw2h"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tH=Z("FolderGit",[["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M14 13h3",key:"1dgedf"}],["path",{d:"M7 13h3",key:"1pygq7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sH=Z("FolderHeart",[["path",{d:"M11 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v1.5",key:"6hud8k"}],["path",{d:"M13.9 17.45c-1.2-1.2-1.14-2.8-.2-3.73a2.43 2.43 0 0 1 3.44 0l.36.34.34-.34a2.43 2.43 0 0 1 3.45-.01c.95.95 1 2.53-.2 3.74L17.5 21Z",key:"wpff58"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rH=Z("FolderInput",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nH=Z("FolderKanban",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aH=Z("FolderKey",[["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2",key:"3hgo9p"}],["path",{d:"m22 14-4.5 4.5",key:"1ef6z8"}],["path",{d:"m21 15 1 1",key:"1ejcpy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iH=Z("FolderLock",[["rect",{width:"8",height:"5",x:"14",y:"17",rx:"1",key:"19aais"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5",key:"1w6v7t"}],["path",{d:"M20 17v-2a2 2 0 1 0-4 0v2",key:"pwaxnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oH=Z("FolderMinus",[["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lH=Z("FolderOpenDot",[["path",{d:"m6 14 1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2",key:"1nmvlm"}],["circle",{cx:"14",cy:"15",r:"1",key:"1gm4qj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vh=Z("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cH=Z("FolderOutput",[["path",{d:"M2 7.5V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-1.5",key:"1yk7aj"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m5 10-3 3 3 3",key:"1r8ie0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S2=Z("FolderPen",[["path",{d:"M2 11.5V5a2 2 0 0 1 2-2h3.9c.7 0 1.3.3 1.7.9l.8 1.2c.4.6 1 .9 1.7.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-9.5",key:"a8xqs0"}],["path",{d:"M11.378 13.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1saktj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dH=Z("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uH=Z("FolderRoot",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M12 15v5",key:"11xva1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hH=Z("FolderSearch2",[["circle",{cx:"11.5",cy:"12.5",r:"2.5",key:"1ea5ju"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M13.3 14.3 15 16",key:"1y4v1n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mH=Z("FolderSearch",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pH=Z("FolderSymlink",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"x1c07l"}],["path",{d:"m8 16 3-3-3-3",key:"rlqrt1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fH=Z("FolderSync",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5",key:"1dkoa9"}],["path",{d:"M12 10v4h4",key:"1czhmt"}],["path",{d:"m12 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"lvuxfi"}],["path",{d:"M22 22v-4h-4",key:"1ewp4q"}],["path",{d:"m22 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"14ync0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gH=Z("FolderTree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xH=Z("FolderUp",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m9 13 3-3 3 3",key:"1pxg3c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yH=Z("FolderX",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"m9.5 10.5 5 5",key:"ra9qjz"}],["path",{d:"m14.5 10.5-5 5",key:"l2rkpq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vH=Z("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _H=Z("Folders",[["path",{d:"M20 17a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3.9a2 2 0 0 1-1.69-.9l-.81-1.2a2 2 0 0 0-1.67-.9H8a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2Z",key:"4u7rpt"}],["path",{d:"M2 8v11a2 2 0 0 0 2 2h14",key:"1eicx1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bH=Z("Footprints",[["path",{d:"M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 1 1-4 0Z",key:"1dudjm"}],["path",{d:"M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 1 0 4 0Z",key:"l2t8xc"}],["path",{d:"M16 17h4",key:"1dejxt"}],["path",{d:"M4 13h4",key:"1bwh8b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wH=Z("Forklift",[["path",{d:"M12 12H5a2 2 0 0 0-2 2v5",key:"7zsz91"}],["circle",{cx:"13",cy:"19",r:"2",key:"wjnkru"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M8 19h3m5-17v17h6M6 12V7c0-1.1.9-2 2-2h3l5 5",key:"13bk1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jH=Z("Forward",[["polyline",{points:"15 17 20 12 15 7",key:"1w3sku"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NH=Z("Frame",[["line",{x1:"22",x2:"2",y1:"6",y2:"6",key:"15w7dq"}],["line",{x1:"22",x2:"2",y1:"18",y2:"18",key:"1ip48p"}],["line",{x1:"6",x2:"6",y1:"2",y2:"22",key:"a2lnyx"}],["line",{x1:"18",x2:"18",y1:"2",y2:"22",key:"8vb6jd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kH=Z("Framer",[["path",{d:"M5 16V9h14V2H5l14 14h-7m-7 0 7 7v-7m-7 0h7",key:"1a2nng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SH=Z("Frown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CH=Z("Fuel",[["line",{x1:"3",x2:"15",y1:"22",y2:"22",key:"xegly4"}],["line",{x1:"4",x2:"14",y1:"9",y2:"9",key:"xcnuvu"}],["path",{d:"M14 22V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v18",key:"16j0yd"}],["path",{d:"M14 13h2a2 2 0 0 1 2 2v2a2 2 0 0 0 2 2a2 2 0 0 0 2-2V9.83a2 2 0 0 0-.59-1.42L18 5",key:"7cu91f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MH=Z("Fullscreen",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TH=Z("GalleryHorizontalEnd",[["path",{d:"M2 7v10",key:"a2pl2d"}],["path",{d:"M6 5v14",key:"1kq3d7"}],["rect",{width:"12",height:"18",x:"10",y:"3",rx:"2",key:"13i7bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AH=Z("GalleryHorizontal",[["path",{d:"M2 3v18",key:"pzttux"}],["rect",{width:"12",height:"18",x:"6",y:"3",rx:"2",key:"btr8bg"}],["path",{d:"M22 3v18",key:"6jf3v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EH=Z("GalleryThumbnails",[["rect",{width:"18",height:"14",x:"3",y:"3",rx:"2",key:"74y24f"}],["path",{d:"M4 21h1",key:"16zlid"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M19 21h1",key:"edywat"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PH=Z("GalleryVerticalEnd",[["path",{d:"M7 2h10",key:"nczekb"}],["path",{d:"M5 6h14",key:"u2x4p"}],["rect",{width:"18",height:"12",x:"3",y:"10",rx:"2",key:"l0tzu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IH=Z("GalleryVertical",[["path",{d:"M3 2h18",key:"15qxfx"}],["rect",{width:"18",height:"12",x:"3",y:"6",rx:"2",key:"1439r6"}],["path",{d:"M3 22h18",key:"8prr45"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LH=Z("Gamepad2",[["line",{x1:"6",x2:"10",y1:"11",y2:"11",key:"1gktln"}],["line",{x1:"8",x2:"8",y1:"9",y2:"13",key:"qnk9ow"}],["line",{x1:"15",x2:"15.01",y1:"12",y2:"12",key:"krot7o"}],["line",{x1:"18",x2:"18.01",y1:"10",y2:"10",key:"1lcuu1"}],["path",{d:"M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z",key:"mfqc10"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DH=Z("Gamepad",[["line",{x1:"6",x2:"10",y1:"12",y2:"12",key:"161bw2"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"15",x2:"15.01",y1:"13",y2:"13",key:"dqpgro"}],["line",{x1:"18",x2:"18.01",y1:"11",y2:"11",key:"meh2c"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OH=Z("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RH=Z("Gavel",[["path",{d:"m14.5 12.5-8 8a2.119 2.119 0 1 1-3-3l8-8",key:"15492f"}],["path",{d:"m16 16 6-6",key:"vzrcl6"}],["path",{d:"m8 8 6-6",key:"18bi4p"}],["path",{d:"m9 7 8 8",key:"5jnvq1"}],["path",{d:"m21 11-8-8",key:"z4y7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FH=Z("Gem",[["path",{d:"M6 3h12l4 6-10 13L2 9Z",key:"1pcd5k"}],["path",{d:"M11 3 8 9l4 13 4-13-3-6",key:"1fcu3u"}],["path",{d:"M2 9h20",key:"16fsjt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lk=Z("Ghost",[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const po=Z("Gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zH=Z("GitBranchPlus",[["path",{d:"M6 3v12",key:"qpgusn"}],["path",{d:"M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"1d02ji"}],["path",{d:"M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"chk6ph"}],["path",{d:"M15 6a9 9 0 0 0-9 9",key:"or332x"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BH=Z("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C2=Z("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $H=Z("GitCommitVertical",[["path",{d:"M12 3v6",key:"1holv5"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 15v6",key:"a9ows0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qH=Z("GitCompareArrows",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UH=Z("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VH=Z("GitFork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HH=Z("GitGraph",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WH=Z("GitMerge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GH=Z("GitPullRequestArrow",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v12",key:"ih889a"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KH=Z("GitPullRequestClosed",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 9v12",key:"1sc30k"}],["path",{d:"m21 3-6 6",key:"16nqsk"}],["path",{d:"m21 9-6-6",key:"9j17rh"}],["path",{d:"M18 11.5V15",key:"65xf6f"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZH=Z("GitPullRequestCreateArrow",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v12",key:"ih889a"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v3",key:"1rbwk6"}],["path",{d:"M19 15v6",key:"10aioa"}],["path",{d:"M22 18h-6",key:"1d5gi5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YH=Z("GitPullRequestCreate",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 9v12",key:"1sc30k"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v3",key:"1jb6z3"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XH=Z("GitPullRequestDraft",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M18 6V5",key:"1oao2s"}],["path",{d:"M18 11v-1",key:"11c8tz"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QH=Z("GitPullRequest",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JH=Z("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eW=Z("Gitlab",[["path",{d:"m22 13.29-3.33-10a.42.42 0 0 0-.14-.18.38.38 0 0 0-.22-.11.39.39 0 0 0-.23.07.42.42 0 0 0-.14.18l-2.26 6.67H8.32L6.1 3.26a.42.42 0 0 0-.1-.18.38.38 0 0 0-.26-.08.39.39 0 0 0-.23.07.42.42 0 0 0-.14.18L2 13.29a.74.74 0 0 0 .27.83L12 21l9.69-6.88a.71.71 0 0 0 .31-.83Z",key:"148pdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tW=Z("GlassWater",[["path",{d:"M5.116 4.104A1 1 0 0 1 6.11 3h11.78a1 1 0 0 1 .994 1.105L17.19 20.21A2 2 0 0 1 15.2 22H8.8a2 2 0 0 1-2-1.79z",key:"p55z4y"}],["path",{d:"M6 12a5 5 0 0 1 6 0 5 5 0 0 0 6 0",key:"mjntcy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sW=Z("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rW=Z("GlobeLock",[["path",{d:"M15.686 15A14.5 14.5 0 0 1 12 22a14.5 14.5 0 0 1 0-20 10 10 0 1 0 9.542 13",key:"qkt0x6"}],["path",{d:"M2 12h8.5",key:"ovaggd"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lm=Z("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nW=Z("Goal",[["path",{d:"M12 13V2l8 4-8 4",key:"5wlwwj"}],["path",{d:"M20.561 10.222a9 9 0 1 1-12.55-5.29",key:"1c0wjv"}],["path",{d:"M8.002 9.997a5 5 0 1 0 8.9 2.02",key:"gb1g7m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aW=Z("Grab",[["path",{d:"M18 11.5V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1.4",key:"edstyy"}],["path",{d:"M14 10V8a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"19wdwo"}],["path",{d:"M10 9.9V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v5",key:"1lugqo"}],["path",{d:"M6 14a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1hbeus"}],["path",{d:"M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-4a8 8 0 0 1-8-8 2 2 0 1 1 4 0",key:"1etffm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ah=Z("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iW=Z("Grape",[["path",{d:"M22 5V2l-5.89 5.89",key:"1eenpo"}],["circle",{cx:"16.6",cy:"15.89",r:"3",key:"xjtalx"}],["circle",{cx:"8.11",cy:"7.4",r:"3",key:"u2fv6i"}],["circle",{cx:"12.35",cy:"11.65",r:"3",key:"i6i8g7"}],["circle",{cx:"13.91",cy:"5.85",r:"3",key:"6ye0dv"}],["circle",{cx:"18.15",cy:"10.09",r:"3",key:"snx9no"}],["circle",{cx:"6.56",cy:"13.2",r:"3",key:"17x4xg"}],["circle",{cx:"10.8",cy:"17.44",r:"3",key:"1hogw9"}],["circle",{cx:"5",cy:"19",r:"3",key:"1sn6vo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oW=Z("Grid2x2Check",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M2=Z("Grid2x2Plus",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 22v-6",key:"qhmiwi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lW=Z("Grid2x2X",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"m16 16 5 5",key:"8tpb07"}],["path",{d:"m16 21 5-5",key:"193jll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T2=Z("Grid2x2",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yp=Z("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cW=Z("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bu=Z("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dW=Z("Grip",[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uW=Z("Group",[["path",{d:"M3 7V5c0-1.1.9-2 2-2h2",key:"adw53z"}],["path",{d:"M17 3h2c1.1 0 2 .9 2 2v2",key:"an4l38"}],["path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2",key:"144t0e"}],["path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2",key:"rtnfgi"}],["rect",{width:"7",height:"5",x:"7",y:"7",rx:"1",key:"1eyiv7"}],["rect",{width:"7",height:"5",x:"10",y:"12",rx:"1",key:"1qlmkx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hW=Z("Guitar",[["path",{d:"m11.9 12.1 4.514-4.514",key:"109xqo"}],["path",{d:"M20.1 2.3a1 1 0 0 0-1.4 0l-1.114 1.114A2 2 0 0 0 17 4.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 17.828 7h1.344a2 2 0 0 0 1.414-.586L21.7 5.3a1 1 0 0 0 0-1.4z",key:"txyc8t"}],["path",{d:"m6 16 2 2",key:"16qmzd"}],["path",{d:"M8.2 9.9C8.7 8.8 9.8 8 11 8c2.8 0 5 2.2 5 5 0 1.2-.8 2.3-1.9 2.8l-.9.4A2 2 0 0 0 12 18a4 4 0 0 1-4 4c-3.3 0-6-2.7-6-6a4 4 0 0 1 4-4 2 2 0 0 0 1.8-1.2z",key:"1u8q3z"}],["circle",{cx:"11.5",cy:"12.5",r:".5",fill:"currentColor",key:"16onso"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mW=Z("Ham",[["path",{d:"M13.144 21.144A7.274 10.445 45 1 0 2.856 10.856",key:"1k1t7q"}],["path",{d:"M13.144 21.144A7.274 4.365 45 0 0 2.856 10.856a7.274 4.365 45 0 0 10.288 10.288",key:"153t1g"}],["path",{d:"M16.565 10.435 18.6 8.4a2.501 2.501 0 1 0 1.65-4.65 2.5 2.5 0 1 0-4.66 1.66l-2.024 2.025",key:"gzrt0n"}],["path",{d:"m8.5 16.5-1-1",key:"otr954"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pW=Z("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fW=Z("HandCoins",[["path",{d:"M11 15h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 17",key:"geh8rc"}],["path",{d:"m7 21 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"1fto5m"}],["path",{d:"m2 16 6 6",key:"1pfhp9"}],["circle",{cx:"16",cy:"9",r:"2.9",key:"1n0dlu"}],["circle",{cx:"6",cy:"5",r:"3",key:"151irh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gW=Z("HandHeart",[["path",{d:"M11 14h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 16",key:"1ifwr1"}],["path",{d:"m7 20 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"17abbs"}],["path",{d:"m2 15 6 6",key:"10dquu"}],["path",{d:"M19.5 8.5c.7-.7 1.5-1.6 1.5-2.7A2.73 2.73 0 0 0 16 4a2.78 2.78 0 0 0-5 1.8c0 1.2.8 2 1.5 2.8L16 12Z",key:"1h3036"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A2=Z("HandHelping",[["path",{d:"M11 12h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 14",key:"1j4xps"}],["path",{d:"m7 18 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"uospg8"}],["path",{d:"m2 13 6 6",key:"16e5sb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xW=Z("HandMetal",[["path",{d:"M18 12.5V10a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1.4",key:"wc6myp"}],["path",{d:"M14 11V9a2 2 0 1 0-4 0v2",key:"94qvcw"}],["path",{d:"M10 10.5V5a2 2 0 1 0-4 0v9",key:"m1ah89"}],["path",{d:"m7 15-1.76-1.76a2 2 0 0 0-2.83 2.82l3.6 3.6C7.5 21.14 9.2 22 12 22h2a8 8 0 0 0 8-8V7a2 2 0 1 0-4 0v5",key:"t1skq1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yW=Z("HandPlatter",[["path",{d:"M12 3V2",key:"ar7q03"}],["path",{d:"m15.4 17.4 3.2-2.8a2 2 0 1 1 2.8 2.9l-3.6 3.3c-.7.8-1.7 1.2-2.8 1.2h-4c-1.1 0-2.1-.4-2.8-1.2l-1.302-1.464A1 1 0 0 0 6.151 19H5",key:"n2g93r"}],["path",{d:"M2 14h12a2 2 0 0 1 0 4h-2",key:"1o2jem"}],["path",{d:"M4 10h16",key:"img6z1"}],["path",{d:"M5 10a7 7 0 0 1 14 0",key:"1ega1o"}],["path",{d:"M5 14v6a1 1 0 0 1-1 1H2",key:"1hescx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pP=Z("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fP=Z("Handshake",[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vW=Z("HardDriveDownload",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _W=Z("HardDriveUpload",[["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M12 2v8",key:"1q4o3n"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gP=Z("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bW=Z("HardHat",[["path",{d:"M10 10V5a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v5",key:"1p9q5i"}],["path",{d:"M14 6a6 6 0 0 1 6 6v3",key:"1hnv84"}],["path",{d:"M4 15v-3a6 6 0 0 1 6-6",key:"9ciidu"}],["rect",{x:"2",y:"15",width:"20",height:"4",rx:"1",key:"g3x8cw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x5=Z("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wW=Z("Haze",[["path",{d:"m5.2 6.2 1.4 1.4",key:"17imol"}],["path",{d:"M2 13h2",key:"13gyu8"}],["path",{d:"M20 13h2",key:"16rner"}],["path",{d:"m17.4 7.6 1.4-1.4",key:"t4xlah"}],["path",{d:"M22 17H2",key:"1gtaj3"}],["path",{d:"M22 21H2",key:"1gy6en"}],["path",{d:"M16 13a4 4 0 0 0-8 0",key:"1dyczq"}],["path",{d:"M12 5V2.5",key:"1vytko"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jW=Z("HdmiPort",[["path",{d:"M22 9a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v4a1 1 0 0 0 1 1h1l2 2h12l2-2h1a1 1 0 0 0 1-1Z",key:"2128wb"}],["path",{d:"M7.5 12h9",key:"1t0ckc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xP=Z("Heading1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yP=Z("Heading2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NW=Z("Heading3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kW=Z("Heading4",[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SW=Z("Heading5",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CW=Z("Heading6",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MW=Z("Heading",[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TW=Z("HeadphoneOff",[["path",{d:"M21 14h-1.343",key:"1jdnxi"}],["path",{d:"M9.128 3.47A9 9 0 0 1 21 12v3.343",key:"6kipu2"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20.414 20.414A2 2 0 0 1 19 21h-1a2 2 0 0 1-2-2v-3",key:"9x50f4"}],["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 2.636-6.364",key:"1bkxnm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AW=Z("Headphones",[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EW=Z("Headset",[["path",{d:"M3 11h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5Zm0 0a9 9 0 1 1 18 0m0 0v5a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3Z",key:"12oyoe"}],["path",{d:"M21 16v2a4 4 0 0 1-4 4h-5",key:"1x7m43"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PW=Z("HeartCrack",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"m12 13-1-1 2-2-3-3 2-2",key:"xjdxli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IW=Z("HeartHandshake",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"M12 5 9.04 7.96a2.17 2.17 0 0 0 0 3.08c.82.82 2.13.85 3 .07l2.07-1.9a2.82 2.82 0 0 1 3.79 0l2.96 2.66",key:"4oyue0"}],["path",{d:"m18 15-2-2",key:"60u0ii"}],["path",{d:"m15 18-2-2",key:"6p76be"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LW=Z("HeartOff",[["line",{x1:"2",y1:"2",x2:"22",y2:"22",key:"1w4vcy"}],["path",{d:"M16.5 16.5 12 21l-7-7c-1.5-1.45-3-3.2-3-5.5a5.5 5.5 0 0 1 2.14-4.35",key:"3mpagl"}],["path",{d:"M8.76 3.1c1.15.22 2.13.78 3.24 1.9 1.5-1.5 2.74-2 4.5-2A5.5 5.5 0 0 1 22 8.5c0 2.12-1.3 3.78-2.67 5.17",key:"1gh3v3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DW=Z("HeartPulse",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27",key:"1uw2ng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Si=Z("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OW=Z("Heater",[["path",{d:"M11 8c2-3-2-3 0-6",key:"1ldv5m"}],["path",{d:"M15.5 8c2-3-2-3 0-6",key:"1otqoz"}],["path",{d:"M6 10h.01",key:"1lbq93"}],["path",{d:"M6 14h.01",key:"zudwn7"}],["path",{d:"M10 16v-4",key:"1c25yv"}],["path",{d:"M14 16v-4",key:"1dkbt8"}],["path",{d:"M18 16v-4",key:"1yg9me"}],["path",{d:"M20 6a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h3",key:"1ubg90"}],["path",{d:"M5 20v2",key:"1abpe8"}],["path",{d:"M19 20v2",key:"kqn6ft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RW=Z("Hexagon",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FW=Z("Highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y5=Z("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zW=Z("HopOff",[["path",{d:"M10.82 16.12c1.69.6 3.91.79 5.18.85.28.01.53-.09.7-.27",key:"qyzcap"}],["path",{d:"M11.14 20.57c.52.24 2.44 1.12 4.08 1.37.46.06.86-.25.9-.71.12-1.52-.3-3.43-.5-4.28",key:"y078lb"}],["path",{d:"M16.13 21.05c1.65.63 3.68.84 4.87.91a.9.9 0 0 0 .7-.26",key:"1utre3"}],["path",{d:"M17.99 5.52a20.83 20.83 0 0 1 3.15 4.5.8.8 0 0 1-.68 1.13c-1.17.1-2.5.02-3.9-.25",key:"17o9hm"}],["path",{d:"M20.57 11.14c.24.52 1.12 2.44 1.37 4.08.04.3-.08.59-.31.75",key:"1d1n4p"}],["path",{d:"M4.93 4.93a10 10 0 0 0-.67 13.4c.35.43.96.4 1.17-.12.69-1.71 1.07-5.07 1.07-6.71 1.34.45 3.1.9 4.88.62a.85.85 0 0 0 .48-.24",key:"9uv3tt"}],["path",{d:"M5.52 17.99c1.05.95 2.91 2.42 4.5 3.15a.8.8 0 0 0 1.13-.68c.2-2.34-.33-5.3-1.57-8.28",key:"1292wz"}],["path",{d:"M8.35 2.68a10 10 0 0 1 9.98 1.58c.43.35.4.96-.12 1.17-1.5.6-4.3.98-6.07 1.05",key:"7ozu9p"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BW=Z("Hop",[["path",{d:"M10.82 16.12c1.69.6 3.91.79 5.18.85.55.03 1-.42.97-.97-.06-1.27-.26-3.5-.85-5.18",key:"18lxf1"}],["path",{d:"M11.5 6.5c1.64 0 5-.38 6.71-1.07.52-.2.55-.82.12-1.17A10 10 0 0 0 4.26 18.33c.35.43.96.4 1.17-.12.69-1.71 1.07-5.07 1.07-6.71 1.34.45 3.1.9 4.88.62a.88.88 0 0 0 .73-.74c.3-2.14-.15-3.5-.61-4.88",key:"vtfxrw"}],["path",{d:"M15.62 16.95c.2.85.62 2.76.5 4.28a.77.77 0 0 1-.9.7 16.64 16.64 0 0 1-4.08-1.36",key:"13hl71"}],["path",{d:"M16.13 21.05c1.65.63 3.68.84 4.87.91a.9.9 0 0 0 .96-.96 17.68 17.68 0 0 0-.9-4.87",key:"1sl8oj"}],["path",{d:"M16.94 15.62c.86.2 2.77.62 4.29.5a.77.77 0 0 0 .7-.9 16.64 16.64 0 0 0-1.36-4.08",key:"19c6kt"}],["path",{d:"M17.99 5.52a20.82 20.82 0 0 1 3.15 4.5.8.8 0 0 1-.68 1.13c-2.33.2-5.3-.32-8.27-1.57",key:"85ghs3"}],["path",{d:"M4.93 4.93 3 3a.7.7 0 0 1 0-1",key:"x087yj"}],["path",{d:"M9.58 12.18c1.24 2.98 1.77 5.95 1.57 8.28a.8.8 0 0 1-1.13.68 20.82 20.82 0 0 1-4.5-3.15",key:"11xdqo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $W=Z("Hospital",[["path",{d:"M12 6v4",key:"16clxf"}],["path",{d:"M14 14h-4",key:"esezmu"}],["path",{d:"M14 18h-4",key:"16mqa2"}],["path",{d:"M14 8h-4",key:"z8ypaz"}],["path",{d:"M18 12h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2h2",key:"b1k337"}],["path",{d:"M18 22V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v18",key:"16g51d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qW=Z("Hotel",[["path",{d:"M10 22v-6.57",key:"1wmca3"}],["path",{d:"M12 11h.01",key:"z322tv"}],["path",{d:"M12 7h.01",key:"1ivr5q"}],["path",{d:"M14 15.43V22",key:"1q2vjd"}],["path",{d:"M15 16a5 5 0 0 0-6 0",key:"o9wqvi"}],["path",{d:"M16 11h.01",key:"xkw8gn"}],["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 7h.01",key:"1vti4s"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2",key:"1uxh74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UW=Z("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VW=Z("HousePlug",[["path",{d:"M10 12V8.964",key:"1vll13"}],["path",{d:"M14 12V8.964",key:"1x3qvg"}],["path",{d:"M15 12a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-2a1 1 0 0 1 1-1z",key:"ppykja"}],["path",{d:"M8.5 21H5a2 2 0 0 1-2-2v-9a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2h-5a2 2 0 0 1-2-2v-2",key:"1gvg2z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HW=Z("HousePlus",[["path",{d:"M13.22 2.416a2 2 0 0 0-2.511.057l-7 5.999A2 2 0 0 0 3 10v9a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7.354",key:"5phn05"}],["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M15 6h6",key:"1jlkvy"}],["path",{d:"M18 3v6",key:"x1uolp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const On=Z("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E2=Z("IceCreamBowl",[["path",{d:"M12 17c5 0 8-2.69 8-6H4c0 3.31 3 6 8 6m-4 4h8m-4-3v3M5.14 11a3.5 3.5 0 1 1 6.71 0",key:"1uxfcu"}],["path",{d:"M12.14 11a3.5 3.5 0 1 1 6.71 0",key:"4k3m1s"}],["path",{d:"M15.5 6.5a3.5 3.5 0 1 0-7 0",key:"zmuahr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P2=Z("IceCreamCone",[["path",{d:"m7 11 4.08 10.35a1 1 0 0 0 1.84 0L17 11",key:"1v6356"}],["path",{d:"M17 7A5 5 0 0 0 7 7",key:"151p3v"}],["path",{d:"M17 7a2 2 0 0 1 0 4H7a2 2 0 0 1 0-4",key:"1sdaij"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WW=Z("IdCard",[["path",{d:"M16 10h2",key:"8sgtl7"}],["path",{d:"M16 14h2",key:"epxaof"}],["path",{d:"M6.17 15a3 3 0 0 1 5.66 0",key:"n6f512"}],["circle",{cx:"9",cy:"11",r:"2",key:"yxgjnd"}],["rect",{x:"2",y:"5",width:"20",height:"14",rx:"2",key:"qneu4z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GW=Z("ImageDown",[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19 3 3v-5.5",key:"9ldu5r"}],["path",{d:"m17 22 3-3",key:"1nkfve"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KW=Z("ImageMinus",[["path",{d:"M21 9v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"m87ecr"}],["line",{x1:"16",x2:"22",y1:"5",y2:"5",key:"ez7e4s"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZW=Z("ImageOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YW=Z("ImagePlay",[["path",{d:"m11 16-5 5",key:"j5f7ct"}],["path",{d:"M11 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6.5",key:"7s81lt"}],["path",{d:"M15.765 22a.5.5 0 0 1-.765-.424V13.38a.5.5 0 0 1 .765-.424l5.878 3.674a1 1 0 0 1 0 1.696z",key:"1omb6s"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D0=Z("ImagePlus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XW=Z("ImageUp",[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19.5 3-3 3 3",key:"9vmjn0"}],["path",{d:"M17 22v-5.5",key:"1aa6fl"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QW=Z("ImageUpscale",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M17 21h2a2 2 0 0 0 2-2",key:"130fy9"}],["path",{d:"M21 12v3",key:"1wzk3p"}],["path",{d:"m21 3-5 5",key:"1g5oa7"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2",key:"kk3yz1"}],["path",{d:"m5 21 4.144-4.144a1.21 1.21 0 0 1 1.712 0L13 19",key:"fyekpt"}],["path",{d:"M9 3h3",key:"d52fa"}],["rect",{x:"3",y:"11",width:"10",height:"10",rx:"1",key:"1wpmix"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jo=Z("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JW=Z("Images",[["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18",key:"nf6bnh"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["rect",{width:"16",height:"16",x:"6",y:"2",rx:"2",key:"12espp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eG=Z("Import",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tG=Z("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I2=Z("IndentDecrease",[["path",{d:"M21 12H11",key:"wd7e0v"}],["path",{d:"M21 18H11",key:"4wu86t"}],["path",{d:"M21 6H11",key:"6dy1d6"}],["path",{d:"m7 8-4 4 4 4",key:"o5hrat"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L2=Z("IndentIncrease",[["path",{d:"M21 12H11",key:"wd7e0v"}],["path",{d:"M21 18H11",key:"4wu86t"}],["path",{d:"M21 6H11",key:"6dy1d6"}],["path",{d:"m3 8 4 4-4 4",key:"1a3j6y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sG=Z("IndianRupee",[["path",{d:"M6 3h12",key:"ggurg9"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"m6 13 8.5 8",key:"u1kupk"}],["path",{d:"M6 13h3",key:"wdp6ag"}],["path",{d:"M9 13c6.667 0 6.667-10 0-10",key:"1nkvk2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rG=Z("Infinity",[["path",{d:"M12 12c-2-2.67-4-4-6-4a4 4 0 1 0 0 8c2 0 4-1.33 6-4Zm0 0c2 2.67 4 4 6 4a4 4 0 0 0 0-8c-2 0-4 1.33-6 4Z",key:"1z0uae"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vP=Z("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nG=Z("InspectionPanel",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7h.01",key:"7u93v4"}],["path",{d:"M17 7h.01",key:"14a9sn"}],["path",{d:"M7 17h.01",key:"19xn7k"}],["path",{d:"M17 17h.01",key:"1sd3ek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wd=Z("Instagram",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v5=Z("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aG=Z("IterationCcw",[["path",{d:"M20 10c0-4.4-3.6-8-8-8s-8 3.6-8 8 3.6 8 8 8h8",key:"4znkd0"}],["polyline",{points:"16 14 20 18 16 22",key:"11njsm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iG=Z("IterationCw",[["path",{d:"M4 10c0-4.4 3.6-8 8-8s8 3.6 8 8-3.6 8-8 8H4",key:"tuf4su"}],["polyline",{points:"8 22 4 18 8 14",key:"evkj9s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oG=Z("JapaneseYen",[["path",{d:"M12 9.5V21m0-11.5L6 3m6 6.5L18 3",key:"2ej80x"}],["path",{d:"M6 15h12",key:"1hwgt5"}],["path",{d:"M6 11h12",key:"wf4gp6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lG=Z("Joystick",[["path",{d:"M21 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-2Z",key:"jg2n2t"}],["path",{d:"M6 15v-2",key:"gd6mvg"}],["path",{d:"M12 15V9",key:"8c7uyn"}],["circle",{cx:"12",cy:"6",r:"3",key:"1gm2ql"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xx=Z("Kanban",[["path",{d:"M6 5v11",key:"mdvv1e"}],["path",{d:"M12 5v6",key:"14ar3b"}],["path",{d:"M18 5v14",key:"7ji314"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ck=Z("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cG=Z("KeySquare",[["path",{d:"M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z",key:"165ttr"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814",key:"1ubxi2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dm=Z("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dG=Z("KeyboardMusic",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 8h4",key:"utf9t1"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M6 12v4",key:"dy92yo"}],["path",{d:"M10 12v4",key:"1fxnav"}],["path",{d:"M14 12v4",key:"1hft58"}],["path",{d:"M18 12v4",key:"tjjnbz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uG=Z("KeyboardOff",[["path",{d:"M 20 4 A2 2 0 0 1 22 6",key:"1g1fkt"}],["path",{d:"M 22 6 L 22 16.41",key:"1qjg3w"}],["path",{d:"M 7 16 L 16 16",key:"n0yqwb"}],["path",{d:"M 9.69 4 L 20 4",key:"kbpcgx"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20 20H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2",key:"s23sx2"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M8 12h.01",key:"czm47f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hG=Z("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mG=Z("LampCeiling",[["path",{d:"M12 2v5",key:"nd4vlx"}],["path",{d:"M6 7h12l4 9H2l4-9Z",key:"123d64"}],["path",{d:"M9.17 16a3 3 0 1 0 5.66 0",key:"1061mw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pG=Z("LampDesk",[["path",{d:"m14 5-3 3 2 7 8-8-7-2Z",key:"1b0msb"}],["path",{d:"m14 5-3 3-3-3 3-3 3 3Z",key:"1uemms"}],["path",{d:"M9.5 6.5 4 12l3 6",key:"1bx08v"}],["path",{d:"M3 22v-2c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v2H3Z",key:"wap775"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fG=Z("LampFloor",[["path",{d:"M9 2h6l3 7H6l3-7Z",key:"wcx6mj"}],["path",{d:"M12 9v13",key:"3n1su1"}],["path",{d:"M9 22h6",key:"1rlq3v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gG=Z("LampWallDown",[["path",{d:"M11 13h6l3 7H8l3-7Z",key:"9n3qlo"}],["path",{d:"M14 13V8a2 2 0 0 0-2-2H8",key:"1hu4hb"}],["path",{d:"M4 9h2a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H4v6Z",key:"s053bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xG=Z("LampWallUp",[["path",{d:"M11 4h6l3 7H8l3-7Z",key:"11x1ee"}],["path",{d:"M14 11v5a2 2 0 0 1-2 2H8",key:"eutp5o"}],["path",{d:"M4 15h2a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2H4v-6Z",key:"1iuthr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yG=Z("Lamp",[["path",{d:"M8 2h8l4 10H4L8 2Z",key:"9dma5w"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M8 22v-2c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v2H8Z",key:"mwf4oh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vG=Z("LandPlot",[["path",{d:"m12 8 6-3-6-3v10",key:"mvpnpy"}],["path",{d:"m8 11.99-5.5 3.14a1 1 0 0 0 0 1.74l8.5 4.86a2 2 0 0 0 2 0l8.5-4.86a1 1 0 0 0 0-1.74L16 12",key:"ek95tt"}],["path",{d:"m6.49 12.85 11.02 6.3",key:"1kt42w"}],["path",{d:"M17.51 12.85 6.5 19.15",key:"v55bdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _G=Z("Landmark",[["line",{x1:"3",x2:"21",y1:"22",y2:"22",key:"j8o0r"}],["line",{x1:"6",x2:"6",y1:"18",y2:"11",key:"10tf0k"}],["line",{x1:"10",x2:"10",y1:"18",y2:"11",key:"54lgf6"}],["line",{x1:"14",x2:"14",y1:"18",y2:"11",key:"380y"}],["line",{x1:"18",x2:"18",y1:"18",y2:"11",key:"1kevvc"}],["polygon",{points:"12 2 20 7 4 7",key:"jkujk7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bG=Z("Languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wG=Z("LaptopMinimalCheck",[["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}],["rect",{x:"3",y:"4",width:"18",height:"12",rx:"2",key:"8ur36m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D2=Z("LaptopMinimal",[["rect",{width:"18",height:"12",x:"3",y:"4",rx:"2",ry:"2",key:"1qhy41"}],["line",{x1:"2",x2:"22",y1:"20",y2:"20",key:"ni3hll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jG=Z("Laptop",[["path",{d:"M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16",key:"tarvll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NG=Z("LassoSelect",[["path",{d:"M7 22a5 5 0 0 1-2-4",key:"umushi"}],["path",{d:"M7 16.93c.96.43 1.96.74 2.99.91",key:"ybbtv3"}],["path",{d:"M3.34 14A6.8 6.8 0 0 1 2 10c0-4.42 4.48-8 10-8s10 3.58 10 8a7.19 7.19 0 0 1-.33 2",key:"gt5e1w"}],["path",{d:"M5 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z",key:"bq3ynw"}],["path",{d:"M14.33 22h-.09a.35.35 0 0 1-.24-.32v-10a.34.34 0 0 1 .33-.34c.08 0 .15.03.21.08l7.34 6a.33.33 0 0 1-.21.59h-4.49l-2.57 3.85a.35.35 0 0 1-.28.14z",key:"72q637"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kG=Z("Lasso",[["path",{d:"M7 22a5 5 0 0 1-2-4",key:"umushi"}],["path",{d:"M3.3 14A6.8 6.8 0 0 1 2 10c0-4.4 4.5-8 10-8s10 3.6 10 8-4.5 8-10 8a12 12 0 0 1-5-1",key:"146dds"}],["path",{d:"M5 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z",key:"bq3ynw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SG=Z("Laugh",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M18 13a6 6 0 0 1-6 5 6 6 0 0 1-6-5h12Z",key:"b2q4dd"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CG=Z("Layers2",[["path",{d:"m16.02 12 5.48 3.13a1 1 0 0 1 0 1.74L13 21.74a2 2 0 0 1-2 0l-8.5-4.87a1 1 0 0 1 0-1.74L7.98 12",key:"1cuww1"}],["path",{d:"M13 13.74a2 2 0 0 1-2 0L2.5 8.87a1 1 0 0 1 0-1.74L11 2.26a2 2 0 0 1 2 0l8.5 4.87a1 1 0 0 1 0 1.74Z",key:"pdlvxu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MG=Z("Layers3",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m6.08 9.5-3.5 1.6a1 1 0 0 0 0 1.81l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9a1 1 0 0 0 0-1.83l-3.5-1.59",key:"1e5n1m"}],["path",{d:"m6.08 14.5-3.5 1.6a1 1 0 0 0 0 1.81l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9a1 1 0 0 0 0-1.83l-3.5-1.59",key:"1iwflc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TG=Z("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dk=Z("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yp=Z("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AG=Z("LayoutList",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EG=Z("LayoutPanelLeft",[["rect",{width:"7",height:"18",x:"3",y:"3",rx:"1",key:"2obqm"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PG=Z("LayoutPanelTop",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uk=Z("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IG=Z("Leaf",[["path",{d:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",key:"nnexq3"}],["path",{d:"M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12",key:"mt58a7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LG=Z("LeafyGreen",[["path",{d:"M2 22c1.25-.987 2.27-1.975 3.9-2.2a5.56 5.56 0 0 1 3.8 1.5 4 4 0 0 0 6.187-2.353 3.5 3.5 0 0 0 3.69-5.116A3.5 3.5 0 0 0 20.95 8 3.5 3.5 0 1 0 16 3.05a3.5 3.5 0 0 0-5.831 1.373 3.5 3.5 0 0 0-5.116 3.69 4 4 0 0 0-2.348 6.155C3.499 15.42 4.409 16.712 4.2 18.1 3.926 19.743 3.014 20.732 2 22",key:"1134nt"}],["path",{d:"M2 22 17 7",key:"1q7jp2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DG=Z("Lectern",[["path",{d:"M16 12h3a2 2 0 0 0 1.902-1.38l1.056-3.333A1 1 0 0 0 21 6H3a1 1 0 0 0-.958 1.287l1.056 3.334A2 2 0 0 0 5 12h3",key:"13jjxg"}],["path",{d:"M18 6V3a1 1 0 0 0-1-1h-3",key:"1550fe"}],["rect",{width:"8",height:"12",x:"8",y:"10",rx:"1",key:"qmu8b6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OG=Z("LetterText",[["path",{d:"M15 12h6",key:"upa0zy"}],["path",{d:"M15 6h6",key:"1jlkvy"}],["path",{d:"m3 13 3.553-7.724a.5.5 0 0 1 .894 0L11 13",key:"blevx4"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M4 11h6",key:"olkgv1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RG=Z("LibraryBig",[["rect",{width:"8",height:"18",x:"3",y:"3",rx:"1",key:"oynpb5"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M20.4 18.9c.2.5-.1 1.1-.6 1.3l-1.9.7c-.5.2-1.1-.1-1.3-.6L11.1 5.1c-.2-.5.1-1.1.6-1.3l1.9-.7c.5-.2 1.1.1 1.3.6Z",key:"1qboyk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _5=Z("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b5=Z("LifeBuoy",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.93 4.93 4.24 4.24",key:"1ymg45"}],["path",{d:"m14.83 9.17 4.24-4.24",key:"1cb5xl"}],["path",{d:"m14.83 14.83 4.24 4.24",key:"q42g0n"}],["path",{d:"m9.17 14.83-4.24 4.24",key:"bqpfvv"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FG=Z("Ligature",[["path",{d:"M8 20V8c0-2.2 1.8-4 4-4 1.5 0 2.8.8 3.5 2",key:"1rtphz"}],["path",{d:"M6 12h4",key:"a4o3ry"}],["path",{d:"M14 12h2v8",key:"c1fccl"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 20h4",key:"lzx1xo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zG=Z("LightbulbOff",[["path",{d:"M16.8 11.2c.8-.9 1.2-2 1.2-3.2a6 6 0 0 0-9.3-5",key:"1fkcox"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M6.3 6.3a4.67 4.67 0 0 0 1.2 5.2c.7.7 1.3 1.5 1.5 2.5",key:"10m8kw"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l_=Z("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BG=Z("Link2Off",[["path",{d:"M9 17H7A5 5 0 0 1 7 7",key:"10o201"}],["path",{d:"M15 7h2a5 5 0 0 1 4 8",key:"1d3206"}],["line",{x1:"8",x2:"12",y1:"12",y2:"12",key:"rvw6j4"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wo=Z("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Do=Z("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Om=Z("Linkedin",[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $G=Z("ListCheck",[["path",{d:"M11 18H3",key:"n3j2dh"}],["path",{d:"m15 18 2 2 4-4",key:"1szwhi"}],["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 6H3",key:"1wxfjs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qG=Z("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UG=Z("ListCollapse",[["path",{d:"m3 10 2.5-2.5L3 5",key:"i6eama"}],["path",{d:"m3 19 2.5-2.5L3 14",key:"w2gmor"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VG=Z("ListEnd",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M10 18H3",key:"13769t"}],["path",{d:"M21 6v10a2 2 0 0 1-2 2h-5",key:"ilrcs8"}],["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HG=Z("ListFilter",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WG=Z("ListMinus",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GG=Z("ListMusic",[["path",{d:"M21 15V6",key:"h1cx4g"}],["path",{d:"M18.5 18a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z",key:"8saifv"}],["path",{d:"M12 12H3",key:"18klou"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M12 18H3",key:"11ftsu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O0=Z("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KG=Z("ListPlus",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZG=Z("ListRestart",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M7 12H3",key:"13ou7f"}],["path",{d:"M7 18H3",key:"1sijw9"}],["path",{d:"M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14",key:"qth677"}],["path",{d:"M11 10v4h4",key:"172dkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YG=Z("ListStart",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M10 6H3",key:"lf8lx7"}],["path",{d:"M21 18V8a2 2 0 0 0-2-2h-5",key:"1hghli"}],["path",{d:"m16 8-2-2 2-2",key:"160uvd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XG=Z("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QG=Z("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JG=Z("ListVideo",[["path",{d:"M12 12H3",key:"18klou"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M12 18H3",key:"11ftsu"}],["path",{d:"m16 12 5 3-5 3v-6Z",key:"zpskkp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eK=Z("ListX",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"m19 10-4 4",key:"1tz659"}],["path",{d:"m15 10 4 4",key:"1n7nei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hh=Z("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ms=Z("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tK=Z("LoaderPinwheel",[["path",{d:"M22 12a1 1 0 0 1-10 0 1 1 0 0 0-10 0",key:"1lzz15"}],["path",{d:"M7 20.7a1 1 0 1 1 5-8.7 1 1 0 1 0 5-8.6",key:"1gnrpi"}],["path",{d:"M7 3.3a1 1 0 1 1 5 8.6 1 1 0 1 0 5 8.6",key:"u9yy5q"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sK=Z("Loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rK=Z("LocateFixed",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nK=Z("LocateOff",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["path",{d:"M7.11 7.11C5.83 8.39 5 10.1 5 12c0 3.87 3.13 7 7 7 1.9 0 3.61-.83 4.89-2.11",key:"1oh7ia"}],["path",{d:"M18.71 13.96c.19-.63.29-1.29.29-1.96 0-3.87-3.13-7-7-7-.67 0-1.33.1-1.96.29",key:"3qdecy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aK=Z("Locate",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O2=Z("LockKeyholeOpen",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{width:"18",height:"12",x:"3",y:"10",rx:"2",key:"l0tzu3"}],["path",{d:"M7 10V7a5 5 0 0 1 9.33-2.5",key:"car5b7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iK=Z("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R2=Z("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $u=Z("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w5=Z("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j5=Z("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oK=Z("Logs",[["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M3 18h1",key:"1eiwyy"}],["path",{d:"M3 6h1",key:"rgxa97"}],["path",{d:"M8 12h1",key:"1con00"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M8 6h1",key:"tn6mkg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lK=Z("Lollipop",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}],["path",{d:"M11 11a2 2 0 0 0 4 0 4 4 0 0 0-8 0 6 6 0 0 0 12 0",key:"107gwy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cK=Z("Luggage",[["path",{d:"M6 20a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2",key:"1m57jg"}],["path",{d:"M8 18V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v14",key:"1l99gc"}],["path",{d:"M10 20h4",key:"ni2waw"}],["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dK=Z("Magnet",[["path",{d:"m6 15-4-4 6.75-6.77a7.79 7.79 0 0 1 11 11L13 22l-4-4 6.39-6.36a2.14 2.14 0 0 0-3-3L6 15",key:"1i3lhw"}],["path",{d:"m5 8 4 4",key:"j6kj7e"}],["path",{d:"m12 15 4 4",key:"lnac28"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uK=Z("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hK=Z("MailMinus",[["path",{d:"M22 15V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"fuxbkv"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M16 19h6",key:"xwg31i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mK=Z("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pK=Z("MailPlus",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M16 19h6",key:"xwg31i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fK=Z("MailQuestion",[["path",{d:"M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5",key:"e61zoh"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M18 15.28c.2-.4.5-.8.9-1a2.1 2.1 0 0 1 2.6.4c.3.4.5.8.5 1.3 0 1.3-2 2-2 2",key:"7z9rxb"}],["path",{d:"M20 22v.01",key:"12bgn6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gK=Z("MailSearch",[["path",{d:"M22 12.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h7.5",key:"w80f2v"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M18 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",key:"8lzu5m"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m22 22-1.5-1.5",key:"1x83k4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xK=Z("MailWarning",[["path",{d:"M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5",key:"e61zoh"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M20 14v4",key:"1hm744"}],["path",{d:"M20 22v.01",key:"12bgn6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _P=Z("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const br=Z("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yK=Z("Mailbox",[["path",{d:"M22 17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9.5C2 7 4 5 6.5 5H18c2.2 0 4 1.8 4 4v8Z",key:"1lbycx"}],["polyline",{points:"15,9 18,9 18,11",key:"1pm9c0"}],["path",{d:"M6.5 5C9 5 11 7 11 9.5V17a2 2 0 0 1-2 2",key:"15i455"}],["line",{x1:"6",x2:"7",y1:"10",y2:"10",key:"1e2scm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vK=Z("Mails",[["rect",{width:"16",height:"13",x:"6",y:"4",rx:"2",key:"1drq3f"}],["path",{d:"m22 7-7.1 3.78c-.57.3-1.23.3-1.8 0L6 7",key:"xn252p"}],["path",{d:"M2 8v11c0 1.1.9 2 2 2h14",key:"n13cji"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _K=Z("MapPinCheckInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bK=Z("MapPinCheck",[["path",{d:"M19.43 12.935c.357-.967.57-1.955.57-2.935a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32.197 32.197 0 0 0 .813-.728",key:"1dq61d"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"m16 18 2 2 4-4",key:"1mkfmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wK=Z("MapPinHouse",[["path",{d:"M15 22a1 1 0 0 1-1-1v-4a1 1 0 0 1 .445-.832l3-2a1 1 0 0 1 1.11 0l3 2A1 1 0 0 1 22 17v4a1 1 0 0 1-1 1z",key:"1p1rcz"}],["path",{d:"M18 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 .601.2",key:"mcbcs9"}],["path",{d:"M18 22v-3",key:"1t1ugv"}],["circle",{cx:"10",cy:"10",r:"3",key:"1ns7v1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jK=Z("MapPinMinusInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NK=Z("MapPinMinus",[["path",{d:"M18.977 14C19.6 12.701 20 11.343 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32 32 0 0 0 .824-.738",key:"11uxia"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M16 18h6",key:"987eiv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kK=Z("MapPinOff",[["path",{d:"M12.75 7.09a3 3 0 0 1 2.16 2.16",key:"1d4wjd"}],["path",{d:"M17.072 17.072c-1.634 2.17-3.527 3.912-4.471 4.727a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 1.432-4.568",key:"12yil7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.475 2.818A8 8 0 0 1 20 10c0 1.183-.31 2.377-.81 3.533",key:"lhrkcz"}],["path",{d:"M9.13 9.13a3 3 0 0 0 3.74 3.74",key:"13wojd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SK=Z("MapPinPlusInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CK=Z("MapPinPlus",[["path",{d:"M19.914 11.105A7.298 7.298 0 0 0 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32 32 0 0 0 .824-.738",key:"fcdtly"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M16 18h6",key:"987eiv"}],["path",{d:"M19 15v6",key:"10aioa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MK=Z("MapPinXInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TK=Z("MapPinX",[["path",{d:"M19.752 11.901A7.78 7.78 0 0 0 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 19 19 0 0 0 .09-.077",key:"y0ewhp"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"m21.5 15.5-5 5",key:"11iqnx"}],["path",{d:"m21.5 20.5-5-5",key:"1bylgx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oi=Z("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AK=Z("MapPinned",[["path",{d:"M18 8c0 3.613-3.869 7.429-5.393 8.795a1 1 0 0 1-1.214 0C9.87 15.429 6 11.613 6 8a6 6 0 0 1 12 0",key:"11u0oz"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M8.714 14h-3.71a1 1 0 0 0-.948.683l-2.004 6A1 1 0 0 0 3 22h18a1 1 0 0 0 .948-1.316l-2-6a1 1 0 0 0-.949-.684h-3.712",key:"q8zwxj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EK=Z("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PK=Z("Martini",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M12 11v11",key:"ur9y6a"}],["path",{d:"m19 3-7 8-7-8Z",key:"1sgpiw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IK=Z("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bP=Z("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R0=Z("Medal",[["path",{d:"M7.21 15 2.66 7.14a2 2 0 0 1 .13-2.2L4.4 2.8A2 2 0 0 1 6 2h12a2 2 0 0 1 1.6.8l1.6 2.14a2 2 0 0 1 .14 2.2L16.79 15",key:"143lza"}],["path",{d:"M11 12 5.12 2.2",key:"qhuxz6"}],["path",{d:"m13 12 5.88-9.8",key:"hbye0f"}],["path",{d:"M8 7h8",key:"i86dvs"}],["circle",{cx:"12",cy:"17",r:"5",key:"qbz8iq"}],["path",{d:"M12 18v-2h-.5",key:"fawc4q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LK=Z("MegaphoneOff",[["path",{d:"M9.26 9.26 3 11v3l14.14 3.14",key:"3429n"}],["path",{d:"M21 15.34V6l-7.31 2.03",key:"4o1dh8"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rm=Z("Megaphone",[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DK=Z("Meh",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"8",x2:"16",y1:"15",y2:"15",key:"1xb1d9"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OK=Z("MemoryStick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wP=Z("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RK=Z("Merge",[["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22",key:"1hyw0i"}],["path",{d:"m20 22-5-5",key:"1m27yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FK=Z("MessageCircleCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22z",key:"k85zhp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zK=Z("MessageCircleDashed",[["path",{d:"M13.5 3.1c-.5 0-1-.1-1.5-.1s-1 .1-1.5.1",key:"16ll65"}],["path",{d:"M19.3 6.8a10.45 10.45 0 0 0-2.1-2.1",key:"1nq77a"}],["path",{d:"M20.9 13.5c.1-.5.1-1 .1-1.5s-.1-1-.1-1.5",key:"1sf7wn"}],["path",{d:"M17.2 19.3a10.45 10.45 0 0 0 2.1-2.1",key:"x1hs5g"}],["path",{d:"M10.5 20.9c.5.1 1 .1 1.5.1s1-.1 1.5-.1",key:"19m18z"}],["path",{d:"M3.5 17.5 2 22l4.5-1.5",key:"1f36qi"}],["path",{d:"M3.1 10.5c0 .5-.1 1-.1 1.5s.1 1 .1 1.5",key:"1vz3ju"}],["path",{d:"M6.8 4.7a10.45 10.45 0 0 0-2.1 2.1",key:"19f9do"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N5=Z("MessageCircleHeart",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M15.8 9.2a2.5 2.5 0 0 0-3.5 0l-.3.4-.35-.3a2.42 2.42 0 1 0-3.2 3.6l3.6 3.5 3.6-3.5c1.2-1.2 1.1-2.7.2-3.7",key:"43lnbm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BK=Z("MessageCircleMore",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $K=Z("MessageCircleOff",[["path",{d:"M20.5 14.9A9 9 0 0 0 9.1 3.5",key:"1iebmn"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.6 5.6C3 8.3 2.2 12.5 4 16l-2 6 6-2c3.4 1.8 7.6 1.1 10.3-1.7",key:"1ov8ce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qK=Z("MessageCirclePlus",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jP=Z("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UK=Z("MessageCircleReply",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}],["path",{d:"M7 12h7a2 2 0 0 1 2 2v1",key:"1gheu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VK=Z("MessageCircleWarning",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HK=Z("MessageCircleX",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xc=Z("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WK=Z("MessageSquareCode",[["path",{d:"M10 7.5 8 10l2 2.5",key:"xb17xw"}],["path",{d:"m14 7.5 2 2.5-2 2.5",key:"5rap1v"}],["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GK=Z("MessageSquareDashed",[["path",{d:"M10 17H7l-4 4v-7",key:"1r71xu"}],["path",{d:"M14 17h1",key:"nufu4t"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 14v1a2 2 0 0 1-2 2",key:"29akq3"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M9 3h1",key:"1yesri"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KK=Z("MessageSquareDiff",[["path",{d:"m5 19-2 2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2",key:"1xuzuj"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 17h6",key:"r8uit2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZK=Z("MessageSquareDot",[["path",{d:"M11.7 3H5a2 2 0 0 0-2 2v16l4-4h12a2 2 0 0 0 2-2v-2.7",key:"uodpkb"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YK=Z("MessageSquareHeart",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M14.8 7.5a1.84 1.84 0 0 0-2.6 0l-.2.3-.3-.3a1.84 1.84 0 1 0-2.4 2.8L12 13l2.7-2.7c.9-.9.8-2.1.1-2.8",key:"1blaws"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XK=Z("MessageSquareLock",[["path",{d:"M19 15v-2a2 2 0 1 0-4 0v2",key:"h3d1vz"}],["path",{d:"M9 17H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v3.5",key:"xsnnhn"}],["rect",{x:"13",y:"15",width:"8",height:"5",rx:"1",key:"1ccwuk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NP=Z("MessageSquareMore",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M16 10h.01",key:"1m94wz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QK=Z("MessageSquareOff",[["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M3.6 3.6c-.4.3-.6.8-.6 1.4v16l4-4h10",key:"pwpm4a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k5=Z("MessageSquarePlus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kP=Z("MessageSquareQuote",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 12a2 2 0 0 0 2-2V8H8",key:"1jfesj"}],["path",{d:"M14 12a2 2 0 0 0 2-2V8h-2",key:"1dq9mh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JK=Z("MessageSquareReply",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"m10 7-3 3 3 3",key:"1eugdv"}],["path",{d:"M17 13v-1a2 2 0 0 0-2-2H7",key:"ernfh3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eZ=Z("MessageSquareShare",[["path",{d:"M21 12v3a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h7",key:"tqtdkg"}],["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"m16 8 5-5",key:"15mbrl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tZ=Z("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sZ=Z("MessageSquareWarning",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v2",key:"stiyo7"}],["path",{d:"M12 13h.01",key:"y0uutt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rZ=Z("MessageSquareX",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const io=Z("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nZ=Z("MessagesSquare",[["path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z",key:"p1xzt8"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1",key:"1cx29u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aZ=Z("MicOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M18.89 13.23A7.12 7.12 0 0 0 19 12v-2",key:"80xlxr"}],["path",{d:"M5 10v2a7 7 0 0 0 12 5",key:"p2k8kg"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F2=Z("MicVocal",[["path",{d:"m11 7.601-5.994 8.19a1 1 0 0 0 .1 1.298l.817.818a1 1 0 0 0 1.314.087L15.09 12",key:"80a601"}],["path",{d:"M16.5 21.174C15.5 20.5 14.372 20 13 20c-2.058 0-3.928 2.356-6 2-2.072-.356-2.775-3.369-1.5-4.5",key:"j0ngtp"}],["circle",{cx:"16",cy:"7",r:"5",key:"d08jfb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SP=Z("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iZ=Z("Microchip",[["path",{d:"M18 12h2",key:"quuxs7"}],["path",{d:"M18 16h2",key:"zsn3lv"}],["path",{d:"M18 20h2",key:"9x5y9y"}],["path",{d:"M18 4h2",key:"1luxfb"}],["path",{d:"M18 8h2",key:"nxqzg"}],["path",{d:"M4 12h2",key:"1ltxp0"}],["path",{d:"M4 16h2",key:"8a5zha"}],["path",{d:"M4 20h2",key:"27dk57"}],["path",{d:"M4 4h2",key:"10groj"}],["path",{d:"M4 8h2",key:"18vq6w"}],["path",{d:"M8 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-1.5c-.276 0-.494.227-.562.495a2 2 0 0 1-3.876 0C9.994 2.227 9.776 2 9.5 2z",key:"1681fp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oZ=Z("Microscope",[["path",{d:"M6 18h8",key:"1borvv"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M14 22a7 7 0 1 0 0-14h-1",key:"1jwaiy"}],["path",{d:"M9 14h2",key:"197e7h"}],["path",{d:"M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z",key:"1bmzmy"}],["path",{d:"M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3",key:"1drr47"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lZ=Z("Microwave",[["rect",{width:"20",height:"15",x:"2",y:"4",rx:"2",key:"2no95f"}],["rect",{width:"8",height:"7",x:"6",y:"8",rx:"1",key:"zh9wx"}],["path",{d:"M18 8v7",key:"o5zi4n"}],["path",{d:"M6 19v2",key:"1loha6"}],["path",{d:"M18 19v2",key:"1dawf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cZ=Z("Milestone",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M12 3v3",key:"1n5kay"}],["path",{d:"M4 6a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h13a2 2 0 0 0 1.152-.365l3.424-2.317a1 1 0 0 0 0-1.635l-3.424-2.318A2 2 0 0 0 17 6z",key:"1btarq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dZ=Z("MilkOff",[["path",{d:"M8 2h8",key:"1ssgc1"}],["path",{d:"M9 2v1.343M15 2v2.789a4 4 0 0 0 .672 2.219l.656.984a4 4 0 0 1 .672 2.22v1.131M7.8 7.8l-.128.192A4 4 0 0 0 7 10.212V20a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2v-3",key:"y0ejgx"}],["path",{d:"M7 15a6.47 6.47 0 0 1 5 0 6.472 6.472 0 0 0 3.435.435",key:"iaxqsy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uZ=Z("Milk",[["path",{d:"M8 2h8",key:"1ssgc1"}],["path",{d:"M9 2v2.789a4 4 0 0 1-.672 2.219l-.656.984A4 4 0 0 0 7 10.212V20a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2v-9.789a4 4 0 0 0-.672-2.219l-.656-.984A4 4 0 0 1 15 4.788V2",key:"qtp12x"}],["path",{d:"M7 15a6.472 6.472 0 0 1 5 0 6.47 6.47 0 0 0 5 0",key:"ygeh44"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hZ=Z("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mZ=Z("Minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F0=Z("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pZ=Z("MonitorCheck",[["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fZ=Z("MonitorCog",[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m15.2 4.9-.9-.4",key:"12wd2u"}],["path",{d:"m15.2 7.1-.9.4",key:"1r2vl7"}],["path",{d:"m16.9 3.2-.4-.9",key:"3zbo91"}],["path",{d:"m16.9 8.8-.4.9",key:"1qr2dn"}],["path",{d:"m19.5 2.3-.4.9",key:"1rjrkq"}],["path",{d:"m19.5 9.7-.4-.9",key:"heryx5"}],["path",{d:"m21.7 4.5-.9.4",key:"17fqt1"}],["path",{d:"m21.7 7.5-.9-.4",key:"14zyni"}],["path",{d:"M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"1tnzv8"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gZ=Z("MonitorDot",[["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M22 12v3a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9",key:"1fet9y"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xZ=Z("MonitorDown",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"m15 10-3 3-3-3",key:"lzhmyn"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yZ=Z("MonitorOff",[["path",{d:"M17 17H4a2 2 0 0 1-2-2V5c0-1.5 1-2 1-2",key:"k0q8oc"}],["path",{d:"M22 15V5a2 2 0 0 0-2-2H9",key:"cp1ac0"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vZ=Z("MonitorPause",[["path",{d:"M10 13V7",key:"1u13u9"}],["path",{d:"M14 13V7",key:"1vj9om"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Z=Z("MonitorPlay",[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bZ=Z("MonitorSmartphone",[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wZ=Z("MonitorSpeaker",[["path",{d:"M5.5 20H8",key:"1k40s5"}],["path",{d:"M17 9h.01",key:"1j24nn"}],["rect",{width:"10",height:"16",x:"12",y:"4",rx:"2",key:"ixliua"}],["path",{d:"M8 6H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h4",key:"1mp6e1"}],["circle",{cx:"17",cy:"15",r:"1",key:"tqvash"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jZ=Z("MonitorStop",[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}],["rect",{x:"9",y:"7",width:"6",height:"6",rx:"1",key:"5m2oou"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NZ=Z("MonitorUp",[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kZ=Z("MonitorX",[["path",{d:"m14.5 12.5-5-5",key:"1jahn5"}],["path",{d:"m9.5 12.5 5-5",key:"1k2t7b"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hk=Z("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SZ=Z("MoonStar",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9",key:"4ay0iu"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CZ=Z("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MZ=Z("MountainSnow",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}],["path",{d:"M4.14 15.08c2.62-1.57 5.24-1.43 7.86.42 2.74 1.94 5.49 2 8.23.19",key:"1pvmmp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TZ=Z("Mountain",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AZ=Z("MouseOff",[["path",{d:"M12 6v.343",key:"1gyhex"}],["path",{d:"M18.218 18.218A7 7 0 0 1 5 15V9a7 7 0 0 1 .782-3.218",key:"ukzz01"}],["path",{d:"M19 13.343V9A7 7 0 0 0 8.56 2.902",key:"104jy9"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EZ=Z("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PZ=Z("MousePointerBan",[["path",{d:"M2.034 2.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.944L8.204 7.545a1 1 0 0 0-.66.66l-1.066 3.443a.5.5 0 0 1-.944.033z",key:"11pp1i"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}],["path",{d:"m11.8 11.8 8.4 8.4",key:"oogvdj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c_=Z("MousePointerClick",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const th=Z("MousePointer",[["path",{d:"M12.586 12.586 19 19",key:"ea5xo7"}],["path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z",key:"277e5u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IZ=Z("Mouse",[["rect",{x:"5",y:"2",width:"14",height:"20",rx:"7",key:"11ol66"}],["path",{d:"M12 6v4",key:"16clxf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z2=Z("Move3d",[["path",{d:"M5 3v16h16",key:"1mqmf9"}],["path",{d:"m5 19 6-6",key:"jh6hbb"}],["path",{d:"m2 6 3-3 3 3",key:"tkyvxa"}],["path",{d:"m18 16 3 3-3 3",key:"1d4glt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LZ=Z("MoveDiagonal2",[["path",{d:"M19 13v6h-6",key:"1hxl6d"}],["path",{d:"M5 11V5h6",key:"12e2xe"}],["path",{d:"m5 5 14 14",key:"11anup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DZ=Z("MoveDiagonal",[["path",{d:"M11 19H5v-6",key:"8awifj"}],["path",{d:"M13 5h6v6",key:"7voy1q"}],["path",{d:"M19 5 5 19",key:"wwaj1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OZ=Z("MoveDownLeft",[["path",{d:"M11 19H5V13",key:"1akmht"}],["path",{d:"M19 5L5 19",key:"72u4yj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RZ=Z("MoveDownRight",[["path",{d:"M19 13V19H13",key:"10vkzq"}],["path",{d:"M5 5L19 19",key:"5zm2fv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FZ=Z("MoveDown",[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zZ=Z("MoveHorizontal",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BZ=Z("MoveLeft",[["path",{d:"M6 8L2 12L6 16",key:"kyvwex"}],["path",{d:"M2 12H22",key:"1m8cig"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Z=Z("MoveRight",[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qZ=Z("MoveUpLeft",[["path",{d:"M5 11V5H11",key:"3q78g9"}],["path",{d:"M5 5L19 19",key:"5zm2fv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UZ=Z("MoveUpRight",[["path",{d:"M13 5H19V11",key:"1n1gyv"}],["path",{d:"M19 5L5 19",key:"72u4yj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VZ=Z("MoveUp",[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HZ=Z("MoveVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WZ=Z("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GZ=Z("Music2",[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KZ=Z("Music3",[["circle",{cx:"12",cy:"18",r:"4",key:"m3r9ws"}],["path",{d:"M16 18V2",key:"40x2m5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZZ=Z("Music4",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["path",{d:"m9 9 12-2",key:"1e64n2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YZ=Z("Music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XZ=Z("Navigation2Off",[["path",{d:"M9.31 9.31 5 21l7-4 7 4-1.17-3.17",key:"qoq2o2"}],["path",{d:"M14.53 8.88 12 2l-1.17 3.17",key:"k3sjzy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QZ=Z("Navigation2",[["polygon",{points:"12 2 19 21 12 17 5 21 12 2",key:"x8c0qg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JZ=Z("NavigationOff",[["path",{d:"M8.43 8.43 3 11l8 2 2 8 2.57-5.43",key:"1vdtb7"}],["path",{d:"M17.39 11.73 22 2l-9.73 4.61",key:"tya3r6"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eY=Z("Navigation",[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tY=Z("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z0=Z("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sY=Z("Nfc",[["path",{d:"M6 8.32a7.43 7.43 0 0 1 0 7.36",key:"9iaqei"}],["path",{d:"M9.46 6.21a11.76 11.76 0 0 1 0 11.58",key:"1yha7l"}],["path",{d:"M12.91 4.1a15.91 15.91 0 0 1 .01 15.8",key:"4iu2gk"}],["path",{d:"M16.37 2a20.16 20.16 0 0 1 0 20",key:"sap9u2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rY=Z("NotebookPen",[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nY=Z("NotebookTabs",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M15 2v20",key:"dcj49h"}],["path",{d:"M15 7h5",key:"1xj5lc"}],["path",{d:"M15 12h5",key:"w5shd9"}],["path",{d:"M15 17h5",key:"1qaofu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aY=Z("NotebookText",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M9.5 8h5",key:"11mslq"}],["path",{d:"M9.5 12H16",key:"ktog6x"}],["path",{d:"M9.5 16H14",key:"p1seyn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iY=Z("Notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oY=Z("NotepadTextDashed",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v2",key:"j91f56"}],["path",{d:"M20 12v2",key:"w8o0tu"}],["path",{d:"M20 18v2a2 2 0 0 1-2 2h-1",key:"1c9ggx"}],["path",{d:"M13 22h-2",key:"191ugt"}],["path",{d:"M7 22H6a2 2 0 0 1-2-2v-2",key:"1rt9px"}],["path",{d:"M4 14v-2",key:"1v0sqh"}],["path",{d:"M4 8V6a2 2 0 0 1 2-2h2",key:"1mwabg"}],["path",{d:"M8 10h6",key:"3oa6kw"}],["path",{d:"M8 14h8",key:"1fgep2"}],["path",{d:"M8 18h5",key:"17enja"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lY=Z("NotepadText",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"16",height:"18",x:"4",y:"4",rx:"2",key:"1u9h20"}],["path",{d:"M8 10h6",key:"3oa6kw"}],["path",{d:"M8 14h8",key:"1fgep2"}],["path",{d:"M8 18h5",key:"17enja"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cY=Z("NutOff",[["path",{d:"M12 4V2",key:"1k5q1u"}],["path",{d:"M5 10v4a7.004 7.004 0 0 0 5.277 6.787c.412.104.802.292 1.102.592L12 22l.621-.621c.3-.3.69-.488 1.102-.592a7.01 7.01 0 0 0 4.125-2.939",key:"1xcvy9"}],["path",{d:"M19 10v3.343",key:"163tfc"}],["path",{d:"M12 12c-1.349-.573-1.905-1.005-2.5-2-.546.902-1.048 1.353-2.5 2-1.018-.644-1.46-1.08-2-2-1.028.71-1.69.918-3 1 1.081-1.048 1.757-2.03 2-3 .194-.776.84-1.551 1.79-2.21m11.654 5.997c.887-.457 1.28-.891 1.556-1.787 1.032.916 1.683 1.157 3 1-1.297-1.036-1.758-2.03-2-3-.5-2-4-4-8-4-.74 0-1.461.068-2.15.192",key:"17914v"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dY=Z("Nut",[["path",{d:"M12 4V2",key:"1k5q1u"}],["path",{d:"M5 10v4a7.004 7.004 0 0 0 5.277 6.787c.412.104.802.292 1.102.592L12 22l.621-.621c.3-.3.69-.488 1.102-.592A7.003 7.003 0 0 0 19 14v-4",key:"1tgyif"}],["path",{d:"M12 4C8 4 4.5 6 4 8c-.243.97-.919 1.952-2 3 1.31-.082 1.972-.29 3-1 .54.92.982 1.356 2 2 1.452-.647 1.954-1.098 2.5-2 .595.995 1.151 1.427 2.5 2 1.31-.621 1.862-1.058 2.5-2 .629.977 1.162 1.423 2.5 2 1.209-.548 1.68-.967 2-2 1.032.916 1.683 1.157 3 1-1.297-1.036-1.758-2.03-2-3-.5-2-4-4-8-4Z",key:"tnsqj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m0=Z("OctagonAlert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uY=Z("OctagonMinus",[["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B2=Z("OctagonPause",[["path",{d:"M10 15V9",key:"1lckn7"}],["path",{d:"M14 15V9",key:"1muqhk"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $2=Z("OctagonX",[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hY=Z("Octagon",[["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mY=Z("Omega",[["path",{d:"M3 20h4.5a.5.5 0 0 0 .5-.5v-.282a.52.52 0 0 0-.247-.437 8 8 0 1 1 8.494-.001.52.52 0 0 0-.247.438v.282a.5.5 0 0 0 .5.5H21",key:"1x94xo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pY=Z("Option",[["path",{d:"M3 3h6l6 18h6",key:"ph9rgk"}],["path",{d:"M14 3h7",key:"16f0ms"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fY=Z("Orbit",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M10.4 21.9a10 10 0 0 0 9.941-15.416",key:"eohfx2"}],["path",{d:"M13.5 2.1a10 10 0 0 0-9.841 15.416",key:"19pvbm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gY=Z("Origami",[["path",{d:"M12 12V4a1 1 0 0 1 1-1h6.297a1 1 0 0 1 .651 1.759l-4.696 4.025",key:"1bx4vc"}],["path",{d:"m12 21-7.414-7.414A2 2 0 0 1 4 12.172V6.415a1.002 1.002 0 0 1 1.707-.707L20 20.009",key:"1h3km6"}],["path",{d:"m12.214 3.381 8.414 14.966a1 1 0 0 1-.167 1.199l-1.168 1.163a1 1 0 0 1-.706.291H6.351a1 1 0 0 1-.625-.219L3.25 18.8a1 1 0 0 1 .631-1.781l4.165.027",key:"1hj4wg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xY=Z("Package2",[["path",{d:"M3 9h18v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9Z",key:"1ront0"}],["path",{d:"m3 9 2.45-4.9A2 2 0 0 1 7.24 3h9.52a2 2 0 0 1 1.8 1.1L21 9",key:"19h2x1"}],["path",{d:"M12 3v6",key:"1holv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yY=Z("PackageCheck",[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vY=Z("PackageMinus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Y=Z("PackageOpen",[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bY=Z("PackagePlus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wY=Z("PackageSearch",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["circle",{cx:"18.5",cy:"15.5",r:"2.5",key:"b5zd12"}],["path",{d:"M20.27 17.27 22 19",key:"1l4muz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jY=Z("PackageX",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["path",{d:"m17 13 5 5m-5 0 5-5",key:"im3w4b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dl=Z("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NY=Z("PaintBucket",[["path",{d:"m19 11-8-8-8.6 8.6a2 2 0 0 0 0 2.8l5.2 5.2c.8.8 2 .8 2.8 0L19 11Z",key:"irua1i"}],["path",{d:"m5 2 5 5",key:"1lls2c"}],["path",{d:"M2 13h15",key:"1hkzvu"}],["path",{d:"M22 20a2 2 0 1 1-4 0c0-1.6 1.7-2.4 2-4 .3 1.6 2 2.4 2 4Z",key:"xk76lq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kY=Z("PaintRoller",[["rect",{width:"16",height:"6",x:"2",y:"2",rx:"2",key:"jcyz7m"}],["path",{d:"M10 16v-2a2 2 0 0 1 2-2h8a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2",key:"1b9h7c"}],["rect",{width:"4",height:"6",x:"8",y:"16",rx:"1",key:"d6e7yl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q2=Z("PaintbrushVertical",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v4",key:"qmzblu"}],["path",{d:"M17 2a1 1 0 0 1 1 1v9H6V3a1 1 0 0 1 1-1z",key:"ycvu00"}],["path",{d:"M6 12a1 1 0 0 0-1 1v1a2 2 0 0 0 2 2h2a1 1 0 0 1 1 1v2.9a2 2 0 1 0 4 0V17a1 1 0 0 1 1-1h2a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1",key:"iw4wnp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SY=Z("Paintbrush",[["path",{d:"m14.622 17.897-10.68-2.913",key:"vj2p1u"}],["path",{d:"M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z",key:"18tc5c"}],["path",{d:"M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15",key:"ytzfxy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bl=Z("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CY=Z("PanelBottomClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m15 8-3 3-3-3",key:"1oxy1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U2=Z("PanelBottomDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M14 15h1",key:"171nev"}],["path",{d:"M19 15h2",key:"1vnucp"}],["path",{d:"M3 15h2",key:"8bym0q"}],["path",{d:"M9 15h1",key:"1tg3ks"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MY=Z("PanelBottomOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TY=Z("PanelBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V2=Z("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H2=Z("PanelLeftDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 14v1",key:"askpd8"}],["path",{d:"M9 19v2",key:"16tejx"}],["path",{d:"M9 3v2",key:"1noubl"}],["path",{d:"M9 9v1",key:"19ebxg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W2=Z("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G2=Z("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AY=Z("PanelRightClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K2=Z("PanelRightDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 14v1",key:"ilsfch"}],["path",{d:"M15 19v2",key:"1fst2f"}],["path",{d:"M15 3v2",key:"z204g4"}],["path",{d:"M15 9v1",key:"z2a8b1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EY=Z("PanelRightOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PY=Z("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IY=Z("PanelTopClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m9 16 3-3 3 3",key:"1idcnm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z2=Z("PanelTopDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M14 9h1",key:"l0svgy"}],["path",{d:"M19 9h2",key:"te2zfg"}],["path",{d:"M3 9h2",key:"1h4ldw"}],["path",{d:"M9 9h1",key:"15jzuz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LY=Z("PanelTopOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m15 14-3 3-3-3",key:"g215vf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DY=Z("PanelTop",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OY=Z("PanelsLeftBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M9 15h12",key:"5ijen5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RY=Z("PanelsRightBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h12",key:"1wkqb3"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p0=Z("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mk=Z("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FY=Z("Parentheses",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zY=Z("ParkingMeter",[["path",{d:"M11 15h2",key:"199qp6"}],["path",{d:"M12 12v3",key:"158kv8"}],["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15.282 19a1 1 0 0 0 .948-.68l2.37-6.988a7 7 0 1 0-13.2 0l2.37 6.988a1 1 0 0 0 .948.68z",key:"1jofit"}],["path",{d:"M9 9a3 3 0 1 1 6 0",key:"jdoeu8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kd=Z("PartyPopper",[["path",{d:"M5.8 11.3 2 22l10.7-3.79",key:"gwxi1d"}],["path",{d:"M4 3h.01",key:"1vcuye"}],["path",{d:"M22 8h.01",key:"1mrtc2"}],["path",{d:"M15 2h.01",key:"1cjtqr"}],["path",{d:"M22 20h.01",key:"1mrys2"}],["path",{d:"m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10",key:"hbicv8"}],["path",{d:"m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17",key:"1i94pl"}],["path",{d:"m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7",key:"1cofks"}],["path",{d:"M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z",key:"4kbmks"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vp=Z("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BY=Z("PawPrint",[["circle",{cx:"11",cy:"4",r:"2",key:"vol9p0"}],["circle",{cx:"18",cy:"8",r:"2",key:"17gozi"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}],["path",{d:"M9 10a5 5 0 0 1 5 5v3.5a3.5 3.5 0 0 1-6.84 1.045Q6.52 17.48 4.46 16.84A3.5 3.5 0 0 1 5.5 10Z",key:"1ydw1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Y=Z("PcCase",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",key:"1uq1d7"}],["path",{d:"M15 14h.01",key:"1kp3bh"}],["path",{d:"M9 6h6",key:"dgm16u"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f0=Z("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qY=Z("PenOff",[["path",{d:"m10 10-6.157 6.162a2 2 0 0 0-.5.833l-1.322 4.36a.5.5 0 0 0 .622.624l4.358-1.323a2 2 0 0 0 .83-.5L14 13.982",key:"bjo8r8"}],["path",{d:"m12.829 7.172 4.359-4.346a1 1 0 1 1 3.986 3.986l-4.353 4.353",key:"16h5ne"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d_=Z("PenTool",[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fx=Z("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UY=Z("PencilLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}],["path",{d:"m15 5 3 3",key:"1w25hb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VY=Z("PencilOff",[["path",{d:"m10 10-6.157 6.162a2 2 0 0 0-.5.833l-1.322 4.36a.5.5 0 0 0 .622.624l4.358-1.323a2 2 0 0 0 .83-.5L14 13.982",key:"bjo8r8"}],["path",{d:"m12.829 7.172 4.359-4.346a1 1 0 1 1 3.986 3.986l-4.353 4.353",key:"16h5ne"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HY=Z("PencilRuler",[["path",{d:"M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13",key:"orapub"}],["path",{d:"m8 6 2-2",key:"115y1s"}],["path",{d:"m18 16 2-2",key:"ee94s4"}],["path",{d:"m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17",key:"cfq27r"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Da=Z("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WY=Z("Pentagon",[["path",{d:"M10.83 2.38a2 2 0 0 1 2.34 0l8 5.74a2 2 0 0 1 .73 2.25l-3.04 9.26a2 2 0 0 1-1.9 1.37H7.04a2 2 0 0 1-1.9-1.37L2.1 10.37a2 2 0 0 1 .73-2.25z",key:"2hea0t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S5=Z("Percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GY=Z("PersonStanding",[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["path",{d:"m9 20 3-6 3 6",key:"se2kox"}],["path",{d:"m6 8 6 2 6-2",key:"4o3us4"}],["path",{d:"M12 10v4",key:"1kjpxc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KY=Z("PhilippinePeso",[["path",{d:"M20 11H4",key:"6ut86h"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"M7 21V4a1 1 0 0 1 1-1h4a1 1 0 0 1 0 12H7",key:"1ana5r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZY=Z("PhoneCall",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}],["path",{d:"M14.05 2a9 9 0 0 1 8 7.94",key:"vmijpz"}],["path",{d:"M14.05 6A5 5 0 0 1 18 10",key:"13nbpp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YY=Z("PhoneForwarded",[["polyline",{points:"18 2 22 6 18 10",key:"6vjanh"}],["line",{x1:"14",x2:"22",y1:"6",y2:"6",key:"1jsywh"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XY=Z("PhoneIncoming",[["polyline",{points:"16 2 16 8 22 8",key:"1ygljm"}],["line",{x1:"22",x2:"16",y1:"2",y2:"8",key:"1xzwqn"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QY=Z("PhoneMissed",[["line",{x1:"22",x2:"16",y1:"2",y2:"8",key:"1xzwqn"}],["line",{x1:"16",x2:"22",y1:"2",y2:"8",key:"13zxdn"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JY=Z("PhoneOff",[["path",{d:"M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91",key:"z86iuo"}],["line",{x1:"22",x2:"2",y1:"2",y2:"22",key:"11kh81"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eX=Z("PhoneOutgoing",[["polyline",{points:"22 8 22 2 16 2",key:"1g204g"}],["line",{x1:"16",x2:"22",y1:"8",y2:"2",key:"1ggias"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qn=Z("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tX=Z("Pi",[["line",{x1:"9",x2:"9",y1:"4",y2:"20",key:"ovs5a5"}],["path",{d:"M4 7c0-1.7 1.3-3 3-3h13",key:"10pag4"}],["path",{d:"M18 20c-1.7 0-3-1.3-3-3V4",key:"1gaosr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sX=Z("Piano",[["path",{d:"M18.5 8c-1.4 0-2.6-.8-3.2-2A6.87 6.87 0 0 0 2 9v11a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-8.5C22 9.6 20.4 8 18.5 8",key:"lag0yf"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M6 14v4",key:"9ng0ue"}],["path",{d:"M10 14v4",key:"1v8uk5"}],["path",{d:"M14 14v4",key:"1tqops"}],["path",{d:"M18 14v4",key:"18uqwm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rX=Z("Pickaxe",[["path",{d:"M14.531 12.469 6.619 20.38a1 1 0 1 1-3-3l7.912-7.912",key:"we99rg"}],["path",{d:"M15.686 4.314A12.5 12.5 0 0 0 5.461 2.958 1 1 0 0 0 5.58 4.71a22 22 0 0 1 6.318 3.393",key:"1w6hck"}],["path",{d:"M17.7 3.7a1 1 0 0 0-1.4 0l-4.6 4.6a1 1 0 0 0 0 1.4l2.6 2.6a1 1 0 0 0 1.4 0l4.6-4.6a1 1 0 0 0 0-1.4z",key:"15hgfx"}],["path",{d:"M19.686 8.314a12.501 12.501 0 0 1 1.356 10.225 1 1 0 0 1-1.751-.119 22 22 0 0 0-3.393-6.319",key:"452b4h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nX=Z("PictureInPicture2",[["path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4",key:"daa4of"}],["rect",{width:"10",height:"7",x:"12",y:"13",rx:"2",key:"1nb8gs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aX=Z("PictureInPicture",[["path",{d:"M8 4.5v5H3m-1-6 6 6m13 0v-3c0-1.16-.84-2-2-2h-7m-9 9v2c0 1.05.95 2 2 2h3",key:"bcd8fb"}],["rect",{width:"10",height:"7",x:"12",y:"13.5",ry:"2",key:"136fx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iX=Z("PiggyBank",[["path",{d:"M19 5c-1.5 0-2.8 1.4-3 2-3.5-1.5-11-.3-11 5 0 1.8 0 3 2 4.5V20h4v-2h3v2h4v-4c1-.5 1.7-1 2-2h2v-4h-2c0-1-.5-1.5-1-2V5z",key:"1ivx2i"}],["path",{d:"M2 9v1c0 1.1.9 2 2 2h1",key:"nm575m"}],["path",{d:"M16 11h.01",key:"xkw8gn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oX=Z("PilcrowLeft",[["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"M14 9h-3a3 3 0 0 1 0-6h9",key:"1ulc19"}],["path",{d:"M18 3v11",key:"1phi0r"}],["path",{d:"M22 18H2l4-4",key:"yt65j9"}],["path",{d:"m6 22-4-4",key:"6jgyf5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lX=Z("PilcrowRight",[["path",{d:"M10 3v11",key:"o3l5kj"}],["path",{d:"M10 9H7a1 1 0 0 1 0-6h8",key:"1wb1nc"}],["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"m18 14 4 4H2",key:"4r8io1"}],["path",{d:"m22 18-4 4",key:"1hjjrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cX=Z("Pilcrow",[["path",{d:"M13 4v16",key:"8vvj80"}],["path",{d:"M17 4v16",key:"7dpous"}],["path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13",key:"sh4n9v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dX=Z("PillBottle",[["path",{d:"M18 11h-4a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h4",key:"17ldeb"}],["path",{d:"M6 7v13a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7",key:"nc37y6"}],["rect",{width:"16",height:"5",x:"4",y:"2",rx:"1",key:"3jeezo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uX=Z("Pill",[["path",{d:"m10.5 20.5 10-10a4.95 4.95 0 1 0-7-7l-10 10a4.95 4.95 0 1 0 7 7Z",key:"wa1lgi"}],["path",{d:"m8.5 8.5 7 7",key:"rvfmvr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CP=Z("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u_=Z("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hX=Z("Pipette",[["path",{d:"m2 22 1-1h3l9-9",key:"1sre89"}],["path",{d:"M3 21v-3l9-9",key:"hpe2y6"}],["path",{d:"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z",key:"196du1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mX=Z("Pizza",[["path",{d:"m12 14-1 1",key:"11onhr"}],["path",{d:"m13.75 18.25-1.25 1.42",key:"1yisr3"}],["path",{d:"M17.775 5.654a15.68 15.68 0 0 0-12.121 12.12",key:"1qtqk6"}],["path",{d:"M18.8 9.3a1 1 0 0 0 2.1 7.7",key:"fbbbr2"}],["path",{d:"M21.964 20.732a1 1 0 0 1-1.232 1.232l-18-5a1 1 0 0 1-.695-1.232A19.68 19.68 0 0 1 15.732 2.037a1 1 0 0 1 1.232.695z",key:"1hyfdd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pX=Z("PlaneLanding",[["path",{d:"M2 22h20",key:"272qi7"}],["path",{d:"M3.77 10.77 2 9l2-4.5 1.1.55c.55.28.9.84.9 1.45s.35 1.17.9 1.45L8 8.5l3-6 1.05.53a2 2 0 0 1 1.09 1.52l.72 5.4a2 2 0 0 0 1.09 1.52l4.4 2.2c.42.22.78.55 1.01.96l.6 1.03c.49.88-.06 1.98-1.06 2.1l-1.18.15c-.47.06-.95-.02-1.37-.24L4.29 11.15a2 2 0 0 1-.52-.38Z",key:"1ma21e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fX=Z("PlaneTakeoff",[["path",{d:"M2 22h20",key:"272qi7"}],["path",{d:"M6.36 17.4 4 17l-2-4 1.1-.55a2 2 0 0 1 1.8 0l.17.1a2 2 0 0 0 1.8 0L8 12 5 6l.9-.45a2 2 0 0 1 2.09.2l4.02 3a2 2 0 0 0 2.1.2l4.19-2.06a2.41 2.41 0 0 1 1.73-.17L21 7a1.4 1.4 0 0 1 .87 1.99l-.38.76c-.23.46-.6.84-1.07 1.08L7.58 17.2a2 2 0 0 1-1.22.18Z",key:"fkigj9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gX=Z("Plane",[["path",{d:"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z",key:"1v9wt8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ul=Z("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xX=Z("Plug2",[["path",{d:"M9 2v6",key:"17ngun"}],["path",{d:"M15 2v6",key:"s7yy2p"}],["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M6 11V8h12v3a6 6 0 1 1-12 0Z",key:"wtfw2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y2=Z("PlugZap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MP=Z("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zs=Z("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yX=Z("PocketKnife",[["path",{d:"M3 2v1c0 1 2 1 2 2S3 6 3 7s2 1 2 2-2 1-2 2 2 1 2 2",key:"19w3oe"}],["path",{d:"M18 6h.01",key:"1v4wsw"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M20.83 8.83a4 4 0 0 0-5.66-5.66l-12 12a4 4 0 1 0 5.66 5.66Z",key:"6fykxj"}],["path",{d:"M18 11.66V22a4 4 0 0 0 4-4V6",key:"1utzek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vX=Z("Pocket",[["path",{d:"M4 3h16a2 2 0 0 1 2 2v6a10 10 0 0 1-10 10A10 10 0 0 1 2 11V5a2 2 0 0 1 2-2z",key:"1mz881"}],["polyline",{points:"8 10 12 14 16 10",key:"w4mbv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _X=Z("Podcast",[["path",{d:"M16.85 18.58a9 9 0 1 0-9.7 0",key:"d71mpg"}],["path",{d:"M8 14a5 5 0 1 1 8 0",key:"fc81rn"}],["circle",{cx:"12",cy:"11",r:"1",key:"1gvufo"}],["path",{d:"M13 17a1 1 0 1 0-2 0l.5 4.5a.5.5 0 1 0 1 0Z",key:"za5kbj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bX=Z("PointerOff",[["path",{d:"M10 4.5V4a2 2 0 0 0-2.41-1.957",key:"jsi14n"}],["path",{d:"M13.9 8.4a2 2 0 0 0-1.26-1.295",key:"hirc7f"}],["path",{d:"M21.7 16.2A8 8 0 0 0 22 14v-3a2 2 0 1 0-4 0v-1a2 2 0 0 0-3.63-1.158",key:"1jxb2e"}],["path",{d:"m7 15-1.8-1.8a2 2 0 0 0-2.79 2.86L6 19.7a7.74 7.74 0 0 0 6 2.3h2a8 8 0 0 0 5.657-2.343",key:"10r7hm"}],["path",{d:"M6 6v8",key:"tv5xkp"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wX=Z("Pointer",[["path",{d:"M22 14a8 8 0 0 1-8 8",key:"56vcr3"}],["path",{d:"M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1agjmk"}],["path",{d:"M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1",key:"wdbh2u"}],["path",{d:"M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10",key:"1ibuk9"}],["path",{d:"M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"g6ys72"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jX=Z("Popcorn",[["path",{d:"M18 8a2 2 0 0 0 0-4 2 2 0 0 0-4 0 2 2 0 0 0-4 0 2 2 0 0 0-4 0 2 2 0 0 0 0 4",key:"10td1f"}],["path",{d:"M10 22 9 8",key:"yjptiv"}],["path",{d:"m14 22 1-14",key:"8jwc8b"}],["path",{d:"M20 8c.5 0 .9.4.8 1l-2.6 12c-.1.5-.7 1-1.2 1H7c-.6 0-1.1-.4-1.2-1L3.2 9c-.1-.6.3-1 .8-1Z",key:"1qo33t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NX=Z("Popsicle",[["path",{d:"M18.6 14.4c.8-.8.8-2 0-2.8l-8.1-8.1a4.95 4.95 0 1 0-7.1 7.1l8.1 8.1c.9.7 2.1.7 2.9-.1Z",key:"1o68ps"}],["path",{d:"m22 22-5.5-5.5",key:"17o70y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kX=Z("PoundSterling",[["path",{d:"M18 7c0-5.333-8-5.333-8 0",key:"1prm2n"}],["path",{d:"M10 7v14",key:"18tmcs"}],["path",{d:"M6 21h12",key:"4dkmi1"}],["path",{d:"M6 13h10",key:"ybwr4a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SX=Z("PowerOff",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TP=Z("Power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hg=Z("Presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CX=Z("PrinterCheck",[["path",{d:"M13.5 22H7a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v.5",key:"qeb09x"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}],["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v2",key:"1md90i"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AP=Z("Printer",[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MX=Z("Projector",[["path",{d:"M5 7 3 5",key:"1yys58"}],["path",{d:"M9 6V3",key:"1ptz9u"}],["path",{d:"m13 7 2-2",key:"1w3vmq"}],["circle",{cx:"9",cy:"13",r:"3",key:"1mma13"}],["path",{d:"M11.83 12H20a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h2.17",key:"2frwzc"}],["path",{d:"M16 16h2",key:"dnq2od"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TX=Z("Proportions",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M12 9v11",key:"1fnkrn"}],["path",{d:"M2 9h13a2 2 0 0 1 2 2v9",key:"11z3ex"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AX=Z("Puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EX=Z("Pyramid",[["path",{d:"M2.5 16.88a1 1 0 0 1-.32-1.43l9-13.02a1 1 0 0 1 1.64 0l9 13.01a1 1 0 0 1-.32 1.44l-8.51 4.86a2 2 0 0 1-1.98 0Z",key:"aenxs0"}],["path",{d:"M12 2v20",key:"t6zp3m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B0=Z("QrCode",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C5=Z("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PX=Z("Rabbit",[["path",{d:"M13 16a3 3 0 0 1 2.24 5",key:"1epib5"}],["path",{d:"M18 12h.01",key:"yjnet6"}],["path",{d:"M18 21h-8a4 4 0 0 1-4-4 7 7 0 0 1 7-7h.2L9.6 6.4a1 1 0 1 1 2.8-2.8L15.8 7h.2c3.3 0 6 2.7 6 6v1a2 2 0 0 1-2 2h-1a3 3 0 0 0-3 3",key:"ue9ozu"}],["path",{d:"M20 8.54V4a2 2 0 1 0-4 0v3",key:"49iql8"}],["path",{d:"M7.612 12.524a3 3 0 1 0-1.6 4.3",key:"1e33i0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IX=Z("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LX=Z("Radiation",[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7.5 4.2c-.3-.5-.9-.7-1.3-.4C3.9 5.5 2.3 8.1 2 11c-.1.5.4 1 1 1h5c0-1.5.8-2.8 2-3.4-1.1-1.9-2-3.5-2.5-4.4z",key:"wy49g3"}],["path",{d:"M21 12c.6 0 1-.4 1-1-.3-2.9-1.8-5.5-4.1-7.1-.4-.3-1.1-.2-1.3.3-.6.9-1.5 2.5-2.6 4.3 1.2.7 2 2 2 3.5h5z",key:"vklnvr"}],["path",{d:"M7.5 19.8c-.3.5-.1 1.1.4 1.3 2.6 1.2 5.6 1.2 8.2 0 .5-.2.7-.8.4-1.3-.5-.9-1.4-2.5-2.5-4.3-1.2.7-2.8.7-4 0-1.1 1.8-2 3.4-2.5 4.3z",key:"wkdf1o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DX=Z("Radical",[["path",{d:"M3 12h3.28a1 1 0 0 1 .948.684l2.298 7.934a.5.5 0 0 0 .96-.044L13.82 4.771A1 1 0 0 1 14.792 4H21",key:"1mqj8i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OX=Z("RadioReceiver",[["path",{d:"M5 16v2",key:"g5qcv5"}],["path",{d:"M19 16v2",key:"1gbaio"}],["rect",{width:"20",height:"8",x:"2",y:"8",rx:"2",key:"vjsjur"}],["path",{d:"M18 12h.01",key:"yjnet6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RX=Z("RadioTower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $0=Z("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FX=Z("Radius",[["path",{d:"M20.34 17.52a10 10 0 1 0-2.82 2.82",key:"fydyku"}],["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["path",{d:"m13.41 13.41 4.18 4.18",key:"1gqbwc"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zX=Z("RailSymbol",[["path",{d:"M5 15h14",key:"m0yey3"}],["path",{d:"M5 9h14",key:"7tsvo6"}],["path",{d:"m14 20-5-5 6-6-5-5",key:"1jo42i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BX=Z("Rainbow",[["path",{d:"M22 17a10 10 0 0 0-20 0",key:"ozegv"}],["path",{d:"M6 17a6 6 0 0 1 12 0",key:"5giftw"}],["path",{d:"M10 17a2 2 0 0 1 4 0",key:"gnsikk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $X=Z("Rat",[["path",{d:"M17 5c0-1.7-1.3-3-3-3s-3 1.3-3 3c0 .8.3 1.5.8 2H11c-3.9 0-7 3.1-7 7c0 2.2 1.8 4 4 4",key:"1wq71c"}],["path",{d:"M16.8 3.9c.3-.3.6-.5 1-.7 1.5-.6 3.3.1 3.9 1.6.6 1.5-.1 3.3-1.6 3.9l1.6 2.8c.2.3.2.7.2 1-.2.8-.9 1.2-1.7 1.1 0 0-1.6-.3-2.7-.6H17c-1.7 0-3 1.3-3 3",key:"1crdmb"}],["path",{d:"M13.2 18a3 3 0 0 0-2.2-5",key:"1ol3lk"}],["path",{d:"M13 22H4a2 2 0 0 1 0-4h12",key:"bt3f23"}],["path",{d:"M16 9h.01",key:"1bdo4e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qX=Z("Ratio",[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UX=Z("ReceiptCent",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M12 6.5v11",key:"ecfhkf"}],["path",{d:"M15 9.4a4 4 0 1 0 0 5.2",key:"1makmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VX=Z("ReceiptEuro",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 12h5",key:"1g6qi8"}],["path",{d:"M16 9.5a4 4 0 1 0 0 5.2",key:"b2px4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HX=Z("ReceiptIndianRupee",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 7h8",key:"i86dvs"}],["path",{d:"M12 17.5 8 15h1a4 4 0 0 0 0-8",key:"grpkl4"}],["path",{d:"M8 11h8",key:"vwpz6n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WX=Z("ReceiptJapaneseYen",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"m12 10 3-3",key:"1mc12w"}],["path",{d:"m9 7 3 3v7.5",key:"39i0xv"}],["path",{d:"M9 11h6",key:"1fldmi"}],["path",{d:"M9 15h6",key:"cctwl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GX=Z("ReceiptPoundSterling",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 13h5",key:"1k9z8w"}],["path",{d:"M10 17V9.5a2.5 2.5 0 0 1 5 0",key:"1dzgp0"}],["path",{d:"M8 17h7",key:"8mjdqu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KX=Z("ReceiptRussianRuble",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 15h5",key:"vxg57a"}],["path",{d:"M8 11h5a2 2 0 1 0 0-4h-3v10",key:"1usi5u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZX=Z("ReceiptSwissFranc",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M10 17V7h5",key:"k7jq18"}],["path",{d:"M10 11h4",key:"1i0mka"}],["path",{d:"M8 15h5",key:"vxg57a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YX=Z("ReceiptText",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M14 8H8",key:"1l3xfs"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M13 16H8",key:"wsln4y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XX=Z("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X2=Z("RectangleEllipsis",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QX=Z("RectangleHorizontal",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JX=Z("RectangleVertical",[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eQ=Z("Recycle",[["path",{d:"M7 19H4.815a1.83 1.83 0 0 1-1.57-.881 1.785 1.785 0 0 1-.004-1.784L7.196 9.5",key:"x6z5xu"}],["path",{d:"M11 19h8.203a1.83 1.83 0 0 0 1.556-.89 1.784 1.784 0 0 0 0-1.775l-1.226-2.12",key:"1x4zh5"}],["path",{d:"m14 16-3 3 3 3",key:"f6jyew"}],["path",{d:"M8.293 13.596 7.196 9.5 3.1 10.598",key:"wf1obh"}],["path",{d:"m9.344 5.811 1.093-1.892A1.83 1.83 0 0 1 11.985 3a1.784 1.784 0 0 1 1.546.888l3.943 6.843",key:"9tzpgr"}],["path",{d:"m13.378 9.633 4.096 1.098 1.097-4.096",key:"1oe83g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tQ=Z("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sQ=Z("RedoDot",[["circle",{cx:"12",cy:"17",r:"1",key:"1ixnty"}],["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M5=Z("Redo",[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rQ=Z("RefreshCcwDot",[["path",{d:"M3 2v6h6",key:"18ldww"}],["path",{d:"M21 12A9 9 0 0 0 6 5.3L3 8",key:"1pbrqz"}],["path",{d:"M21 22v-6h-6",key:"usdfbe"}],["path",{d:"M3 12a9 9 0 0 0 15 6.7l3-2.7",key:"1hosoe"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nQ=Z("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aQ=Z("RefreshCwOff",[["path",{d:"M21 8L18.74 5.74A9.75 9.75 0 0 0 12 3C11 3 10.03 3.16 9.13 3.47",key:"1krf6h"}],["path",{d:"M8 16H3v5",key:"1cv678"}],["path",{d:"M3 12C3 9.51 4 7.26 5.64 5.64",key:"ruvoct"}],["path",{d:"m3 16 2.26 2.26A9.75 9.75 0 0 0 12 21c2.49 0 4.74-1 6.36-2.64",key:"19q130"}],["path",{d:"M21 12c0 1-.16 1.97-.47 2.87",key:"4w8emr"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Po=Z("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iQ=Z("Refrigerator",[["path",{d:"M5 6a4 4 0 0 1 4-4h6a4 4 0 0 1 4 4v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6Z",key:"fpq118"}],["path",{d:"M5 10h14",key:"elsbfy"}],["path",{d:"M15 7v6",key:"1nx30x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oQ=Z("Regex",[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lQ=Z("RemoveFormatting",[["path",{d:"M4 7V4h16v3",key:"9msm58"}],["path",{d:"M5 20h6",key:"1h6pxn"}],["path",{d:"M13 4 8 20",key:"kqq6aj"}],["path",{d:"m15 15 5 5",key:"me55sn"}],["path",{d:"m20 15-5 5",key:"11p7ol"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cQ=Z("Repeat1",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}],["path",{d:"M11 10h1v4",key:"70cz1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dQ=Z("Repeat2",[["path",{d:"m2 9 3-3 3 3",key:"1ltn5i"}],["path",{d:"M13 18H7a2 2 0 0 1-2-2V6",key:"1r6tfw"}],["path",{d:"m22 15-3 3-3-3",key:"4rnwn2"}],["path",{d:"M11 6h6a2 2 0 0 1 2 2v10",key:"2f72bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EP=Z("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uQ=Z("ReplaceAll",[["path",{d:"M14 14a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"1yyzbs"}],["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 14a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"zfj4xr"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a 3 3 0 0 1 3-3h1",key:"1ageje"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hQ=Z("Replace",[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mQ=Z("ReplyAll",[["polyline",{points:"7 17 2 12 7 7",key:"t83bqg"}],["polyline",{points:"12 17 7 12 12 7",key:"1g4ajm"}],["path",{d:"M22 18v-2a4 4 0 0 0-4-4H7",key:"1fcyog"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PP=Z("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pQ=Z("Rewind",[["polygon",{points:"11 19 2 12 11 5 11 19",key:"14yba5"}],["polygon",{points:"22 19 13 12 22 5 22 19",key:"1pi1cj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fQ=Z("Ribbon",[["path",{d:"M12 11.22C11 9.997 10 9 10 8a2 2 0 0 1 4 0c0 1-.998 2.002-2.01 3.22",key:"1rnhq3"}],["path",{d:"m12 18 2.57-3.5",key:"116vt7"}],["path",{d:"M6.243 9.016a7 7 0 0 1 11.507-.009",key:"10dq0b"}],["path",{d:"M9.35 14.53 12 11.22",key:"tdsyp2"}],["path",{d:"M9.35 14.53C7.728 12.246 6 10.221 6 7a6 5 0 0 1 12 0c-.005 3.22-1.778 5.235-3.43 7.5l3.557 4.527a1 1 0 0 1-.203 1.43l-1.894 1.36a1 1 0 0 1-1.384-.215L12 18l-2.679 3.593a1 1 0 0 1-1.39.213l-1.865-1.353a1 1 0 0 1-.203-1.422z",key:"nmifey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qx=Z("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gQ=Z("RockingChair",[["polyline",{points:"3.5 2 6.5 12.5 18 12.5",key:"y3iy52"}],["line",{x1:"9.5",x2:"5.5",y1:"12.5",y2:"20",key:"19vg5i"}],["line",{x1:"15",x2:"18.5",y1:"12.5",y2:"20",key:"1inpmv"}],["path",{d:"M2.75 18a13 13 0 0 0 18.5 0",key:"1nquas"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xQ=Z("RollerCoaster",[["path",{d:"M6 19V5",key:"1r845m"}],["path",{d:"M10 19V6.8",key:"9j2tfs"}],["path",{d:"M14 19v-7.8",key:"10s8qv"}],["path",{d:"M18 5v4",key:"1tajlv"}],["path",{d:"M18 19v-6",key:"ielfq3"}],["path",{d:"M22 19V9",key:"158nzp"}],["path",{d:"M2 19V9a4 4 0 0 1 4-4c2 0 4 1.33 6 4s4 4 6 4a4 4 0 1 0-3-6.65",key:"1930oh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q2=Z("Rotate3d",[["path",{d:"M16.466 7.5C15.643 4.237 13.952 2 12 2 9.239 2 7 6.477 7 12s2.239 10 5 10c.342 0 .677-.069 1-.2",key:"10n0gc"}],["path",{d:"m15.194 13.707 3.814 1.86-1.86 3.814",key:"16shm9"}],["path",{d:"M19 15.57c-1.804.885-4.274 1.43-7 1.43-5.523 0-10-2.239-10-5s4.477-5 10-5c4.838 0 8.873 1.718 9.8 4",key:"1lxi77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yQ=Z("RotateCcwSquare",[["path",{d:"M20 9V7a2 2 0 0 0-2-2h-6",key:"19z8uc"}],["path",{d:"m15 2-3 3 3 3",key:"177bxs"}],["path",{d:"M20 13v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2",key:"d36hnl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q0=Z("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vQ=Z("RotateCwSquare",[["path",{d:"M12 5H6a2 2 0 0 0-2 2v3",key:"l96uqu"}],["path",{d:"m9 8 3-3-3-3",key:"1gzgc3"}],["path",{d:"M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2",key:"1w2k5h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IP=Z("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Q=Z("RouteOff",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5c.4 0 .9-.1 1.3-.2",key:"1effex"}],["path",{d:"M5.2 5.2A3.5 3.53 0 0 0 6.5 12H12",key:"k9y2ds"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M21 15.3a3.5 3.5 0 0 0-3.3-3.3",key:"11nlu2"}],["path",{d:"M15 5h-4.3",key:"6537je"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bQ=Z("Route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wQ=Z("Router",[["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6.01 18H6",key:"19vcac"}],["path",{d:"M10.01 18H10",key:"uamcmx"}],["path",{d:"M15 10v4",key:"qjz1xs"}],["path",{d:"M17.84 7.17a4 4 0 0 0-5.66 0",key:"1rif40"}],["path",{d:"M20.66 4.34a8 8 0 0 0-11.31 0",key:"6a5xfq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J2=Z("Rows2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ej=Z("Rows3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jQ=Z("Rows4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 7.5H3",key:"1hm9pq"}],["path",{d:"M21 12H3",key:"2avoz0"}],["path",{d:"M21 16.5H3",key:"n7jzkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NQ=Z("Rss",[["path",{d:"M4 11a9 9 0 0 1 9 9",key:"pv89mb"}],["path",{d:"M4 4a16 16 0 0 1 16 16",key:"k0647b"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LP=Z("Ruler",[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kQ=Z("RussianRuble",[["path",{d:"M6 11h8a4 4 0 0 0 0-8H9v18",key:"18ai8t"}],["path",{d:"M6 15h8",key:"1y8f6l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SQ=Z("Sailboat",[["path",{d:"M22 18H2a4 4 0 0 0 4 4h12a4 4 0 0 0 4-4Z",key:"1404fh"}],["path",{d:"M21 14 10 2 3 14h18Z",key:"1nzg7v"}],["path",{d:"M10 2v16",key:"1labyt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CQ=Z("Salad",[["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 21a9 9 0 0 0 9-9H3a9 9 0 0 0 9 9Z",key:"4rw317"}],["path",{d:"M11.38 12a2.4 2.4 0 0 1-.4-4.77 2.4 2.4 0 0 1 3.2-2.77 2.4 2.4 0 0 1 3.47-.63 2.4 2.4 0 0 1 3.37 3.37 2.4 2.4 0 0 1-1.1 3.7 2.51 2.51 0 0 1 .03 1.1",key:"10xrj0"}],["path",{d:"m13 12 4-4",key:"1hckqy"}],["path",{d:"M10.9 7.25A3.99 3.99 0 0 0 4 10c0 .73.2 1.41.54 2",key:"1p4srx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MQ=Z("Sandwich",[["path",{d:"m2.37 11.223 8.372-6.777a2 2 0 0 1 2.516 0l8.371 6.777",key:"f1wd0e"}],["path",{d:"M21 15a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-5.25",key:"1pfu07"}],["path",{d:"M3 15a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h9",key:"1oq9qw"}],["path",{d:"m6.67 15 6.13 4.6a2 2 0 0 0 2.8-.4l3.15-4.2",key:"1fnwu5"}],["rect",{width:"20",height:"4",x:"2",y:"11",rx:"1",key:"itshg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TQ=Z("SatelliteDish",[["path",{d:"M4 10a7.31 7.31 0 0 0 10 10Z",key:"1fzpp3"}],["path",{d:"m9 15 3-3",key:"88sc13"}],["path",{d:"M17 13a6 6 0 0 0-6-6",key:"15cc6u"}],["path",{d:"M21 13A10 10 0 0 0 11 3",key:"11nf8s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AQ=Z("Satellite",[["path",{d:"M13 7 9 3 5 7l4 4",key:"vyckw6"}],["path",{d:"m17 11 4 4-4 4-4-4",key:"rchckc"}],["path",{d:"m8 12 4 4 6-6-4-4Z",key:"1sshf7"}],["path",{d:"m16 8 3-3",key:"x428zp"}],["path",{d:"M9 21a6 6 0 0 0-6-6",key:"1iajcf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EQ=Z("SaveAll",[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5",key:"1xspal"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6",key:"1ra60u"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z",key:"1yve0x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PQ=Z("SaveOff",[["path",{d:"M13 13H8a1 1 0 0 0-1 1v7",key:"h8g396"}],["path",{d:"M14 8h1",key:"1lfen6"}],["path",{d:"M17 21v-4",key:"1yknxs"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20.41 20.41A2 2 0 0 1 19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 .59-1.41",key:"1t4vdl"}],["path",{d:"M29.5 11.5s5 5 4 5",key:"zzn4i6"}],["path",{d:"M9 3h6.2a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V15",key:"24cby9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fu=Z("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tj=Z("Scale3d",[["path",{d:"M5 7v11a1 1 0 0 0 1 1h11",key:"13dt1j"}],["path",{d:"M5.293 18.707 11 13",key:"ezgbsx"}],["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["circle",{cx:"5",cy:"5",r:"2",key:"1gwv83"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DP=Z("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IQ=Z("Scaling",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M14 15H9v-5",key:"pi4jk9"}],["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M21 3 9 15",key:"15kdhq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LQ=Z("ScanBarcode",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M8 7v10",key:"23sfjj"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M17 7v10",key:"578dap"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DQ=Z("ScanEye",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OQ=Z("ScanFace",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 9h.01",key:"x1ddxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RQ=Z("ScanLine",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 12h10",key:"b7w52i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FQ=Z("ScanQrCode",[["path",{d:"M17 12v4a1 1 0 0 1-1 1h-4",key:"uk4fdo"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M17 8V7",key:"q2g9wo"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M7 17h.01",key:"19xn7k"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{x:"7",y:"7",width:"5",height:"5",rx:"1",key:"m9kyts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zQ=Z("ScanSearch",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m16 16-1.9-1.9",key:"1dq9hf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BQ=Z("ScanText",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 8h8",key:"1jbsf9"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h6",key:"1vyc9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Q=Z("Scan",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qQ=Z("School",[["path",{d:"M14 22v-4a2 2 0 1 0-4 0v4",key:"hhkicm"}],["path",{d:"m18 10 3.447 1.724a1 1 0 0 1 .553.894V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-7.382a1 1 0 0 1 .553-.894L6 10",key:"1xqip1"}],["path",{d:"M18 5v17",key:"1sw6gf"}],["path",{d:"m4 6 7.106-3.553a2 2 0 0 1 1.788 0L20 6",key:"9d2mlk"}],["path",{d:"M6 5v17",key:"1xfsm0"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UQ=Z("ScissorsLineDashed",[["path",{d:"M5.42 9.42 8 12",key:"12pkuq"}],["circle",{cx:"4",cy:"8",r:"2",key:"107mxr"}],["path",{d:"m14 6-8.58 8.58",key:"gvzu5l"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"M10.8 14.8 14 18",key:"ax7m9r"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VQ=Z("Scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HQ=Z("ScreenShareOff",[["path",{d:"M13 3H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-3",key:"i8wdob"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WQ=Z("ScreenShare",[["path",{d:"M13 3H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-3",key:"i8wdob"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m17 8 5-5",key:"fqif7o"}],["path",{d:"M17 3h5v5",key:"1o3tu8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GQ=Z("ScrollText",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KQ=Z("Scroll",[["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZQ=Z("SearchCheck",[["path",{d:"m8 11 2 2 4-4",key:"1sed1v"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YQ=Z("SearchCode",[["path",{d:"m13 13.5 2-2.5-2-2.5",key:"1rvxrh"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}],["path",{d:"M9 8.5 7 11l2 2.5",key:"6ffwbx"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XQ=Z("SearchSlash",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OP=Z("SearchX",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gn=Z("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QQ=Z("Section",[["path",{d:"M16 5a4 3 0 0 0-8 0c0 4 8 3 8 7a4 3 0 0 1-8 0",key:"vqan6v"}],["path",{d:"M8 19a4 3 0 0 0 8 0c0-4-8-3-8-7a4 3 0 0 1 8 0",key:"wdjd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sj=Z("SendHorizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JQ=Z("SendToBack",[["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",key:"1b0bso"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",key:"1x09vl"}],["path",{d:"M7 14v1a2 2 0 0 0 2 2h1",key:"pao6x6"}],["path",{d:"M14 7h1a2 2 0 0 1 2 2v1",key:"19tdru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aa=Z("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eJ=Z("SeparatorHorizontal",[["line",{x1:"3",x2:"21",y1:"12",y2:"12",key:"10d38w"}],["polyline",{points:"8 8 12 4 16 8",key:"zo8t4w"}],["polyline",{points:"16 16 12 20 8 16",key:"1oyrid"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tJ=Z("SeparatorVertical",[["line",{x1:"12",x2:"12",y1:"3",y2:"21",key:"1efggb"}],["polyline",{points:"8 8 4 12 8 16",key:"bnfmv4"}],["polyline",{points:"16 16 20 12 16 8",key:"u90052"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sJ=Z("ServerCog",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m15.7 13.4-.9-.3",key:"1jwmzr"}],["path",{d:"m9.2 10.9-.9-.3",key:"qapnim"}],["path",{d:"m10.6 15.7.3-.9",key:"quwk0k"}],["path",{d:"m13.6 15.7-.4-1",key:"cb9xp7"}],["path",{d:"m10.8 9.3-.4-1",key:"1uaiz5"}],["path",{d:"m8.3 13.6 1-.4",key:"s6srou"}],["path",{d:"m14.7 10.8 1-.4",key:"4d31cq"}],["path",{d:"m13.4 8.3-.3.9",key:"1bm987"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rJ=Z("ServerCrash",[["path",{d:"M6 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-2",key:"4b9dqc"}],["path",{d:"M6 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-2",key:"22nnkd"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m13 6-4 6h6l-4 6",key:"14hqih"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nJ=Z("ServerOff",[["path",{d:"M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5",key:"bt2siv"}],["path",{d:"M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z",key:"1hjrv1"}],["path",{d:"M22 17v-1a2 2 0 0 0-2-2h-1",key:"1iynyr"}],["path",{d:"M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z",key:"161ggg"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aJ=Z("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RP=Z("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $l=Z("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iJ=Z("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ld=Z("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FP=Z("Share",[["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["polyline",{points:"16 6 12 2 8 6",key:"m901s6"}],["line",{x1:"12",x2:"12",y1:"2",y2:"15",key:"1p0rca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oJ=Z("Sheet",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"3",x2:"21",y1:"9",y2:"9",key:"1vqk6q"}],["line",{x1:"3",x2:"21",y1:"15",y2:"15",key:"o2sbyz"}],["line",{x1:"9",x2:"9",y1:"9",y2:"21",key:"1ib60c"}],["line",{x1:"15",x2:"15",y1:"9",y2:"21",key:"1n26ft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lJ=Z("Shell",[["path",{d:"M14 11a2 2 0 1 1-4 0 4 4 0 0 1 8 0 6 6 0 0 1-12 0 8 8 0 0 1 16 0 10 10 0 1 1-20 0 11.93 11.93 0 0 1 2.42-7.22 2 2 0 1 1 3.16 2.44",key:"1cn552"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cJ=Z("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dJ=Z("ShieldBan",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m4.243 5.21 14.39 12.472",key:"1c9a7c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zP=Z("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uJ=Z("ShieldEllipsis",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hJ=Z("ShieldHalf",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 22V2",key:"zs6s6o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mJ=Z("ShieldMinus",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9 12h6",key:"1c52cq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pJ=Z("ShieldOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fJ=Z("ShieldPlus",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M12 9v6",key:"199k2o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gJ=Z("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rj=Z("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ih=Z("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xJ=Z("ShipWheel",[["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}],["path",{d:"M12 2v7.5",key:"1e5rl5"}],["path",{d:"m19 5-5.23 5.23",key:"1ezxxf"}],["path",{d:"M22 12h-7.5",key:"le1719"}],["path",{d:"m19 19-5.23-5.23",key:"p3fmgn"}],["path",{d:"M12 14.5V22",key:"dgcmos"}],["path",{d:"M10.23 13.77 5 19",key:"qwopd4"}],["path",{d:"M9.5 12H2",key:"r7bup8"}],["path",{d:"M10.23 10.23 5 5",key:"k2y7lj"}],["circle",{cx:"12",cy:"12",r:"2.5",key:"ix0uyj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yJ=Z("Ship",[["path",{d:"M12 10.189V14",key:"1p8cqu"}],["path",{d:"M12 2v3",key:"qbqxhf"}],["path",{d:"M19 13V7a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v6",key:"qpkstq"}],["path",{d:"M19.38 20A11.6 11.6 0 0 0 21 14l-8.188-3.639a2 2 0 0 0-1.624 0L3 14a11.6 11.6 0 0 0 2.81 7.76",key:"7tigtc"}],["path",{d:"M2 21c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1s1.2 1 2.5 1c2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"1924j5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vJ=Z("Shirt",[["path",{d:"M20.38 3.46 16 2a4 4 0 0 1-8 0L3.62 3.46a2 2 0 0 0-1.34 2.23l.58 3.47a1 1 0 0 0 .99.84H6v10c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V10h2.15a1 1 0 0 0 .99-.84l.58-3.47a2 2 0 0 0-1.34-2.23z",key:"1wgbhj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jx=Z("ShoppingBag",[["path",{d:"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z",key:"hou9p0"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _J=Z("ShoppingBasket",[["path",{d:"m15 11-1 9",key:"5wnq3a"}],["path",{d:"m19 11-4-7",key:"cnml18"}],["path",{d:"M2 11h20",key:"3eubbj"}],["path",{d:"m3.5 11 1.6 7.4a2 2 0 0 0 2 1.6h9.8a2 2 0 0 0 2-1.6l1.7-7.4",key:"yiazzp"}],["path",{d:"M4.5 15.5h15",key:"13mye1"}],["path",{d:"m5 11 4-7",key:"116ra9"}],["path",{d:"m9 11 1 9",key:"1ojof7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sm=Z("ShoppingCart",[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bJ=Z("Shovel",[["path",{d:"M2 22v-5l5-5 5 5-5 5z",key:"1fh25c"}],["path",{d:"M9.5 14.5 16 8",key:"1smz5x"}],["path",{d:"m17 2 5 5-.5.5a3.53 3.53 0 0 1-5 0s0 0 0 0a3.53 3.53 0 0 1 0-5L17 2",key:"1q8uv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wJ=Z("ShowerHead",[["path",{d:"m4 4 2.5 2.5",key:"uv2vmf"}],["path",{d:"M13.5 6.5a4.95 4.95 0 0 0-7 7",key:"frdkwv"}],["path",{d:"M15 5 5 15",key:"1ag8rq"}],["path",{d:"M14 17v.01",key:"eokfpp"}],["path",{d:"M10 16v.01",key:"14uyyl"}],["path",{d:"M13 13v.01",key:"1v1k97"}],["path",{d:"M16 10v.01",key:"5169yg"}],["path",{d:"M11 20v.01",key:"cj92p8"}],["path",{d:"M17 14v.01",key:"11cswd"}],["path",{d:"M20 11v.01",key:"19e0od"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jJ=Z("Shrink",[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8",key:"17vawe"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6",key:"chjx8e"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6",key:"lav6yq"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3",key:"1pxi2q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NJ=Z("Shrub",[["path",{d:"M12 22v-7l-2-2",key:"eqv9mc"}],["path",{d:"M17 8v.8A6 6 0 0 1 13.8 20H10A6.5 6.5 0 0 1 7 8a5 5 0 0 1 10 0Z",key:"ubcgy"}],["path",{d:"m14 14-2 2",key:"847xa2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pk=Z("Shuffle",[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kJ=Z("Sigma",[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SJ=Z("SignalHigh",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CJ=Z("SignalLow",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MJ=Z("SignalMedium",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TJ=Z("SignalZero",[["path",{d:"M2 20h.01",key:"4haj6o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AJ=Z("Signal",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}],["path",{d:"M22 4v16",key:"sih9yq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EJ=Z("Signature",[["path",{d:"m21 17-2.156-1.868A.5.5 0 0 0 18 15.5v.5a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1c0-2.545-3.991-3.97-8.5-4a1 1 0 0 0 0 5c4.153 0 4.745-11.295 5.708-13.5a2.5 2.5 0 1 1 3.31 3.284",key:"y32ogt"}],["path",{d:"M3 21h18",key:"itz85i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PJ=Z("SignpostBig",[["path",{d:"M10 9H4L2 7l2-2h6",key:"1hq7x2"}],["path",{d:"M14 5h6l2 2-2 2h-6",key:"bv62ej"}],["path",{d:"M10 22V4a2 2 0 1 1 4 0v18",key:"eqpcf2"}],["path",{d:"M8 22h8",key:"rmew8v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IJ=Z("Signpost",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M12 3v3",key:"1n5kay"}],["path",{d:"M18 6a2 2 0 0 1 1.387.56l2.307 2.22a1 1 0 0 1 0 1.44l-2.307 2.22A2 2 0 0 1 18 13H6a2 2 0 0 1-1.387-.56l-2.306-2.22a1 1 0 0 1 0-1.44l2.306-2.22A2 2 0 0 1 6 6z",key:"gqqp9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LJ=Z("Siren",[["path",{d:"M7 18v-6a5 5 0 1 1 10 0v6",key:"pcx96s"}],["path",{d:"M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z",key:"1b4s83"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DJ=Z("SkipBack",[["polygon",{points:"19 20 9 12 19 4 19 20",key:"o2sva"}],["line",{x1:"5",x2:"5",y1:"19",y2:"5",key:"1ocqjk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OJ=Z("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RJ=Z("Skull",[["path",{d:"m12.5 17-.5-1-.5 1h1z",key:"3me087"}],["path",{d:"M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z",key:"1o5pge"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FJ=Z("Slack",[["rect",{width:"3",height:"8",x:"13",y:"2",rx:"1.5",key:"diqz80"}],["path",{d:"M19 8.5V10h1.5A1.5 1.5 0 1 0 19 8.5",key:"183iwg"}],["rect",{width:"3",height:"8",x:"8",y:"14",rx:"1.5",key:"hqg7r1"}],["path",{d:"M5 15.5V14H3.5A1.5 1.5 0 1 0 5 15.5",key:"76g71w"}],["rect",{width:"8",height:"3",x:"14",y:"13",rx:"1.5",key:"1kmz0a"}],["path",{d:"M15.5 19H14v1.5a1.5 1.5 0 1 0 1.5-1.5",key:"jc4sz0"}],["rect",{width:"8",height:"3",x:"2",y:"8",rx:"1.5",key:"1omvl4"}],["path",{d:"M8.5 5H10V3.5A1.5 1.5 0 1 0 8.5 5",key:"16f3cl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zJ=Z("Slash",[["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BJ=Z("Slice",[["path",{d:"M11 16.586V19a1 1 0 0 1-1 1H2L18.37 3.63a1 1 0 1 1 3 3l-9.663 9.663a1 1 0 0 1-1.414 0L8 14",key:"1sllp5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BP=Z("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nj=Z("SlidersVertical",[["line",{x1:"4",x2:"4",y1:"21",y2:"14",key:"1p332r"}],["line",{x1:"4",x2:"4",y1:"10",y2:"3",key:"gb41h5"}],["line",{x1:"12",x2:"12",y1:"21",y2:"12",key:"hf2csr"}],["line",{x1:"12",x2:"12",y1:"8",y2:"3",key:"1kfi7u"}],["line",{x1:"20",x2:"20",y1:"21",y2:"16",key:"1lhrwl"}],["line",{x1:"20",x2:"20",y1:"12",y2:"3",key:"16vvfq"}],["line",{x1:"2",x2:"6",y1:"14",y2:"14",key:"1uebub"}],["line",{x1:"10",x2:"14",y1:"8",y2:"8",key:"1yglbp"}],["line",{x1:"18",x2:"22",y1:"16",y2:"16",key:"1jxqpz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $J=Z("SmartphoneCharging",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12.667 8 10 12h4l-2.667 4",key:"h9lk2d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qJ=Z("SmartphoneNfc",[["rect",{width:"7",height:"12",x:"2",y:"6",rx:"1",key:"5nje8w"}],["path",{d:"M13 8.32a7.43 7.43 0 0 1 0 7.36",key:"1g306n"}],["path",{d:"M16.46 6.21a11.76 11.76 0 0 1 0 11.58",key:"uqvjvo"}],["path",{d:"M19.91 4.1a15.91 15.91 0 0 1 .01 15.8",key:"ujntz3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U0=Z("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UJ=Z("SmilePlus",[["path",{d:"M22 11v1a10 10 0 1 1-9-10",key:"ew0xw9"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}],["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VJ=Z("Smile",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HJ=Z("Snail",[["path",{d:"M2 13a6 6 0 1 0 12 0 4 4 0 1 0-8 0 2 2 0 0 0 4 0",key:"hneq2s"}],["circle",{cx:"10",cy:"13",r:"8",key:"194lz3"}],["path",{d:"M2 21h12c4.4 0 8-3.6 8-8V7a2 2 0 1 0-4 0v6",key:"ixqyt7"}],["path",{d:"M18 3 19.1 5.2",key:"9tjm43"}],["path",{d:"M22 3 20.9 5.2",key:"j3odrs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $1=Z("Snowflake",[["line",{x1:"2",x2:"22",y1:"12",y2:"12",key:"1dnqot"}],["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"m20 16-4-4 4-4",key:"rquw4f"}],["path",{d:"m4 8 4 4-4 4",key:"12s3z9"}],["path",{d:"m16 4-4 4-4-4",key:"1tumq1"}],["path",{d:"m8 20 4-4 4 4",key:"9p200w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WJ=Z("Sofa",[["path",{d:"M20 9V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v3",key:"1dgpiv"}],["path",{d:"M2 16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5a2 2 0 0 0-4 0v1.5a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5V11a2 2 0 0 0-4 0z",key:"xacw8m"}],["path",{d:"M4 18v2",key:"jwo5n2"}],["path",{d:"M20 18v2",key:"1ar1qi"}],["path",{d:"M12 4v9",key:"oqhhn3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GJ=Z("Soup",[["path",{d:"M12 21a9 9 0 0 0 9-9H3a9 9 0 0 0 9 9Z",key:"4rw317"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M19.5 12 22 6",key:"shfsr5"}],["path",{d:"M16.25 3c.27.1.8.53.75 1.36-.06.83-.93 1.2-1 2.02-.05.78.34 1.24.73 1.62",key:"rpc6vp"}],["path",{d:"M11.25 3c.27.1.8.53.74 1.36-.05.83-.93 1.2-.98 2.02-.06.78.33 1.24.72 1.62",key:"1lf63m"}],["path",{d:"M6.25 3c.27.1.8.53.75 1.36-.06.83-.93 1.2-1 2.02-.05.78.34 1.24.74 1.62",key:"97tijn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KJ=Z("Space",[["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZJ=Z("Spade",[["path",{d:"M5 9c-1.5 1.5-3 3.2-3 5.5A5.5 5.5 0 0 0 7.5 20c1.8 0 3-.5 4.5-2 1.5 1.5 2.7 2 4.5 2a5.5 5.5 0 0 0 5.5-5.5c0-2.3-1.5-4-3-5.5l-7-7-7 7Z",key:"40bo9n"}],["path",{d:"M12 18v4",key:"jadmvz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YJ=Z("Sparkle",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hn=Z("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XJ=Z("Speaker",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["circle",{cx:"12",cy:"14",r:"4",key:"1jruaj"}],["path",{d:"M12 14h.01",key:"1etili"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QJ=Z("Speech",[["path",{d:"M8.8 20v-4.1l1.9.2a2.3 2.3 0 0 0 2.164-2.1V8.3A5.37 5.37 0 0 0 2 8.25c0 2.8.656 3.054 1 4.55a5.77 5.77 0 0 1 .029 2.758L2 20",key:"11atix"}],["path",{d:"M19.8 17.8a7.5 7.5 0 0 0 .003-10.603",key:"yol142"}],["path",{d:"M17 15a3.5 3.5 0 0 0-.025-4.975",key:"ssbmkc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JJ=Z("SpellCheck2",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M4 21c1.1 0 1.1-1 2.3-1s1.1 1 2.3 1c1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1",key:"8mdmtu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eee=Z("SpellCheck",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m16 20 2 2 4-4",key:"13tcca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tee=Z("Spline",[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const see=Z("Split",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ree=Z("SprayCan",[["path",{d:"M3 3h.01",key:"159qn6"}],["path",{d:"M7 5h.01",key:"1hq22a"}],["path",{d:"M11 7h.01",key:"1osv80"}],["path",{d:"M3 7h.01",key:"1xzrh3"}],["path",{d:"M7 9h.01",key:"19b3jx"}],["path",{d:"M3 11h.01",key:"1eifu7"}],["rect",{width:"4",height:"4",x:"15",y:"5",key:"mri9e4"}],["path",{d:"m19 9 2 2v10c0 .6-.4 1-1 1h-6c-.6 0-1-.4-1-1V11l2-2",key:"aib6hk"}],["path",{d:"m13 14 8-2",key:"1d7bmk"}],["path",{d:"m13 19 8-2",key:"1y2vml"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nee=Z("Sprout",[["path",{d:"M7 20h10",key:"e6iznv"}],["path",{d:"M10 20c5.5-2.5.8-6.4 3-10",key:"161w41"}],["path",{d:"M9.5 9.4c1.1.8 1.8 2.2 2.3 3.7-2 .4-3.5.4-4.8-.3-1.2-.6-2.3-1.9-3-4.2 2.8-.5 4.4 0 5.5.8z",key:"9gtqwd"}],["path",{d:"M14.1 6a7 7 0 0 0-1.1 4c1.9-.1 3.3-.6 4.3-1.4 1-1 1.6-2.3 1.7-4.6-2.7.1-4 1-4.9 2z",key:"bkxnd2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aj=Z("SquareActivity",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M17 12h-2l-2 5-2-10-2 5H7",key:"15hlnc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ij=Z("SquareArrowDownLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 8-8 8",key:"166keh"}],["path",{d:"M16 16H8V8",key:"1w2ppm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oj=Z("SquareArrowDownRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m8 8 8 8",key:"1imecy"}],["path",{d:"M16 8v8H8",key:"1lbpgo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lj=Z("SquareArrowDown",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cj=Z("SquareArrowLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m12 8-4 4 4 4",key:"15vm53"}],["path",{d:"M16 12H8",key:"1fr5h0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dj=Z("SquareArrowOutDownLeft",[["path",{d:"M13 21h6a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v6",key:"14qz4y"}],["path",{d:"m3 21 9-9",key:"1jfql5"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uj=Z("SquareArrowOutDownRight",[["path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"14rsvq"}],["path",{d:"m21 21-9-9",key:"1et2py"}],["path",{d:"M21 15v6h-6",key:"1jko0i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hj=Z("SquareArrowOutUpLeft",[["path",{d:"M13 3h6a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-6",key:"14mv1t"}],["path",{d:"m3 3 9 9",key:"rks13r"}],["path",{d:"M3 9V3h6",key:"ira0h2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mj=Z("SquareArrowOutUpRight",[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pj=Z("SquareArrowRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fj=Z("SquareArrowUpLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8h8",key:"19xb1h"}],["path",{d:"M16 16 8 8",key:"1qdy8n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gj=Z("SquareArrowUpRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 8h8v8",key:"b65dnt"}],["path",{d:"m8 16 8-8",key:"13b9ih"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xj=Z("SquareArrowUp",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yj=Z("SquareAsterisk",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8.5 14 7-4",key:"12hpby"}],["path",{d:"m8.5 10 7 4",key:"wwy2dy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vj=Z("SquareBottomDashedScissors",[["path",{d:"M4 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2",key:"1vzg26"}],["path",{d:"M10 22H8",key:"euku7a"}],["path",{d:"M16 22h-2",key:"18d249"}],["circle",{cx:"8",cy:"8",r:"2",key:"14cg06"}],["path",{d:"M9.414 9.414 12 12",key:"qz4lzr"}],["path",{d:"M14.8 14.8 18 18",key:"11flf1"}],["circle",{cx:"8",cy:"16",r:"2",key:"1acxsx"}],["path",{d:"m18 6-8.586 8.586",key:"11kzk1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mx=Z("SquareChartGantt",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 8h7",key:"kbo1nt"}],["path",{d:"M8 12h6",key:"ikassy"}],["path",{d:"M11 16h5",key:"oq65wt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g0=Z("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _j=Z("SquareCheck",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bj=Z("SquareChevronDown",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wj=Z("SquareChevronLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m14 16-4-4 4-4",key:"ojs7w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jj=Z("SquareChevronRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nj=Z("SquareChevronUp",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m8 14 4-4 4 4",key:"fy2ptz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kj=Z("SquareCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aee=Z("SquareDashedBottomCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iee=Z("SquareDashedBottom",[["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 21h1",key:"v9vybs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sj=Z("SquareDashedKanban",[["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M21 14v1",key:"169vum"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M3 9v1",key:"1r0deq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cj=Z("SquareDashedMousePointer",[["path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z",key:"xwnzip"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h2",key:"1qve2z"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v2",key:"p14lih"}],["path",{d:"M3 14v1",key:"vnatye"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mj=Z("SquareDashed",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tj=Z("SquareDivide",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}],["line",{x1:"12",x2:"12",y1:"16",y2:"16",key:"aqc6ln"}],["line",{x1:"12",x2:"12",y1:"8",y2:"8",key:"1mkcni"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aj=Z("SquareDot",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ej=Z("SquareEqual",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pj=Z("SquareFunction",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3",key:"m1af9g"}],["path",{d:"M9 11.2h5.7",key:"3zgcl2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ij=Z("SquareKanban",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lj=Z("SquareLibrary",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7v10",key:"d5nglc"}],["path",{d:"M11 7v10",key:"pptsnr"}],["path",{d:"m15 7 2 10",key:"1m7qm5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dj=Z("SquareM",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8l4 4 4-4v8",key:"141u4e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oj=Z("SquareMenu",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 8h10",key:"1jw688"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rj=Z("SquareMinus",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fj=Z("SquareMousePointer",[["path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z",key:"xwnzip"}],["path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"14rsvq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zj=Z("SquareParkingOff",[["path",{d:"M3.6 3.6A2 2 0 0 1 5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-.59 1.41",key:"9l1ft6"}],["path",{d:"M3 8.7V19a2 2 0 0 0 2 2h10.3",key:"17knke"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M13 13a3 3 0 1 0 0-6H9v2",key:"uoagbd"}],["path",{d:"M9 17v-2.3",key:"1jxgo2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bj=Z("SquareParking",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 17V7h4a3 3 0 0 1 0 6H9",key:"1dfk2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rc=Z("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $j=Z("SquarePercent",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qj=Z("SquarePi",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7h10",key:"udp07y"}],["path",{d:"M10 7v10",key:"i1d9ee"}],["path",{d:"M16 17a2 2 0 0 1-2-2V7",key:"ftwdc7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uj=Z("SquarePilcrow",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 12H9.5a2.5 2.5 0 0 1 0-5H17",key:"1l9586"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M16 7v10",key:"lavkr4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vj=Z("SquarePlay",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 8 6 4-6 4Z",key:"f1r3lt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hj=Z("SquarePlus",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wj=Z("SquarePower",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oee=Z("SquareRadical",[["path",{d:"M7 12h2l2 5 2-10h4",key:"1fxv6h"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gj=Z("SquareScissors",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"2",key:"1btzen"}],["circle",{cx:"8",cy:"8",r:"2",key:"14cg06"}],["path",{d:"M9.414 9.414 12 12",key:"qz4lzr"}],["path",{d:"M14.8 14.8 18 18",key:"11flf1"}],["circle",{cx:"8",cy:"16",r:"2",key:"1acxsx"}],["path",{d:"m18 6-8.586 8.586",key:"11kzk1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kj=Z("SquareSigma",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M16 8.9V7H8l4 5-4 5h8v-1.9",key:"9nih0i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zj=Z("SquareSlash",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yj=Z("SquareSplitHorizontal",[["path",{d:"M8 19H5c-1 0-2-1-2-2V7c0-1 1-2 2-2h3",key:"lubmu8"}],["path",{d:"M16 5h3c1 0 2 1 2 2v10c0 1-1 2-2 2h-3",key:"1ag34g"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xj=Z("SquareSplitVertical",[["path",{d:"M5 8V5c0-1 1-2 2-2h10c1 0 2 1 2 2v3",key:"1pi83i"}],["path",{d:"M19 16v3c0 1-1 2-2 2H7c-1 0-2-1-2-2v-3",key:"ido5k7"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lee=Z("SquareSquare",[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cee=Z("SquareStack",[["path",{d:"M4 10c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"4i38lg"}],["path",{d:"M10 16c-1.1 0-2-.9-2-2v-4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"mlte4a"}],["rect",{width:"8",height:"8",x:"14",y:"14",rx:"2",key:"1fa9i4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qj=Z("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jj=Z("SquareUserRound",[["path",{d:"M18 21a6 6 0 0 0-12 0",key:"kaz2du"}],["circle",{cx:"12",cy:"11",r:"4",key:"1gt34v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eN=Z("SquareUser",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 21v-2a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2",key:"1m6ac2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tN=Z("SquareX",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ey=Z("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dee=Z("Squircle",[["path",{d:"M12 3c7.2 0 9 1.8 9 9s-1.8 9-9 9-9-1.8-9-9 1.8-9 9-9",key:"garfkc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uee=Z("Squirrel",[["path",{d:"M15.236 22a3 3 0 0 0-2.2-5",key:"21bitc"}],["path",{d:"M16 20a3 3 0 0 1 3-3h1a2 2 0 0 0 2-2v-2a4 4 0 0 0-4-4V4",key:"oh0fg0"}],["path",{d:"M18 13h.01",key:"9veqaj"}],["path",{d:"M18 6a4 4 0 0 0-4 4 7 7 0 0 0-7 7c0-5 4-5 4-10.5a4.5 4.5 0 1 0-9 0 2.5 2.5 0 0 0 5 0C7 10 3 11 3 17c0 2.8 2.2 5 5 5h10",key:"980v8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hee=Z("Stamp",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M19.27 13.73A2.5 2.5 0 0 0 17.5 13h-11A2.5 2.5 0 0 0 4 15.5V17a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-1.5c0-.66-.26-1.3-.73-1.77Z",key:"1sy9ra"}],["path",{d:"M14 13V8.5C14 7 15 7 15 5a3 3 0 0 0-3-3c-1.66 0-3 1-3 3s1 2 1 3.5V13",key:"cnxgux"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mee=Z("StarHalf",[["path",{d:"M12 18.338a2.1 2.1 0 0 0-.987.244L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.12 2.12 0 0 0 1.597-1.16l2.309-4.679A.53.53 0 0 1 12 2",key:"2ksp49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pee=Z("StarOff",[["path",{d:"M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43",key:"16m0ql"}],["path",{d:"M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91",key:"1vt8nq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gn=Z("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fee=Z("StepBack",[["line",{x1:"18",x2:"18",y1:"20",y2:"4",key:"cun8e5"}],["polygon",{points:"14,20 4,12 14,4",key:"ypakod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gee=Z("StepForward",[["line",{x1:"6",x2:"6",y1:"4",y2:"20",key:"fy8qot"}],["polygon",{points:"10,4 20,12 10,20",key:"1mc1pf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xee=Z("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yee=Z("Sticker",[["path",{d:"M15.5 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2V8.5L15.5 3Z",key:"1wis1t"}],["path",{d:"M14 3v4a2 2 0 0 0 2 2h4",key:"36rjfy"}],["path",{d:"M8 13h.01",key:"1sbv64"}],["path",{d:"M16 13h.01",key:"wip0gl"}],["path",{d:"M10 16s.8 1 2 1c1.3 0 2-1 2-1",key:"1vvgv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vee=Z("StickyNote",[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ee=Z("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bee=Z("StretchHorizontal",[["rect",{width:"20",height:"6",x:"2",y:"4",rx:"2",key:"qdearl"}],["rect",{width:"20",height:"6",x:"2",y:"14",rx:"2",key:"1xrn6j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wee=Z("StretchVertical",[["rect",{width:"6",height:"20",x:"4",y:"2",rx:"2",key:"19qu7m"}],["rect",{width:"6",height:"20",x:"14",y:"2",rx:"2",key:"24v0nk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jee=Z("Strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nee=Z("Subscript",[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kee=Z("SunDim",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M20 12h.01",key:"1ykeid"}],["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M4 12h.01",key:"158zrr"}],["path",{d:"M17.657 6.343h.01",key:"31pqzk"}],["path",{d:"M17.657 17.657h.01",key:"jehnf4"}],["path",{d:"M6.343 17.657h.01",key:"gdk6ow"}],["path",{d:"M6.343 6.343h.01",key:"1uurf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const See=Z("SunMedium",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 3v1",key:"1asbbs"}],["path",{d:"M12 20v1",key:"1wcdkc"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M20 12h1",key:"1vloll"}],["path",{d:"m18.364 5.636-.707.707",key:"1hakh0"}],["path",{d:"m6.343 17.657-.707.707",key:"18m9nf"}],["path",{d:"m5.636 5.636.707.707",key:"1xv1c5"}],["path",{d:"m17.657 17.657.707.707",key:"vl76zb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cee=Z("SunMoon",[["path",{d:"M12 8a2.83 2.83 0 0 0 4 4 4 4 0 1 1-4-4",key:"1fu5g2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.9 4.9 1.4 1.4",key:"b9915j"}],["path",{d:"m17.7 17.7 1.4 1.4",key:"qc3ed3"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.3 17.7-1.4 1.4",key:"5gca6"}],["path",{d:"m19.1 4.9-1.4 1.4",key:"wpu9u6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mee=Z("SunSnow",[["path",{d:"M10 9a3 3 0 1 0 0 6",key:"6zmtdl"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M14 21V3",key:"1llu3z"}],["path",{d:"M10 4V3",key:"pkzwkn"}],["path",{d:"M10 21v-1",key:"1u8rkd"}],["path",{d:"m3.64 18.36.7-.7",key:"105rm9"}],["path",{d:"m4.34 6.34-.7-.7",key:"d3unjp"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"m17 4-3 3",key:"15jcng"}],["path",{d:"m14 17 3 3",key:"6tlq38"}],["path",{d:"m21 15-3-3 3-3",key:"1nlnje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h_=Z("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tee=Z("Sunrise",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aee=Z("Sunset",[["path",{d:"M12 10V2",key:"16sf7g"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eee=Z("Superscript",[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pee=Z("SwatchBook",[["path",{d:"M11 17a4 4 0 0 1-8 0V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2Z",key:"1ldrpk"}],["path",{d:"M16.7 13H19a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H7",key:"11i5po"}],["path",{d:"M 7 17h.01",key:"1euzgo"}],["path",{d:"m11 8 2.3-2.3a2.4 2.4 0 0 1 3.404.004L18.6 7.6a2.4 2.4 0 0 1 .026 3.434L9.9 19.8",key:"o2gii7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iee=Z("SwissFranc",[["path",{d:"M10 21V3h8",key:"br2l0g"}],["path",{d:"M6 16h9",key:"2py0wn"}],["path",{d:"M10 9.5h7",key:"13dmhz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lee=Z("SwitchCamera",[["path",{d:"M11 19H4a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h5",key:"mtk2lu"}],["path",{d:"M13 5h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-5",key:"120jsl"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m18 22-3-3 3-3",key:"kgdoj7"}],["path",{d:"m6 2 3 3-3 3",key:"1fnbkv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dee=Z("Sword",[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oee=Z("Swords",[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}],["polyline",{points:"14.5 6.5 18 3 21 3 21 6 17.5 9.5",key:"hbey2j"}],["line",{x1:"5",x2:"9",y1:"14",y2:"18",key:"1hf58s"}],["line",{x1:"7",x2:"4",y1:"17",y2:"20",key:"pidxm4"}],["line",{x1:"3",x2:"5",y1:"19",y2:"21",key:"1pehsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ree=Z("Syringe",[["path",{d:"m18 2 4 4",key:"22kx64"}],["path",{d:"m17 7 3-3",key:"1w1zoj"}],["path",{d:"M19 9 8.7 19.3c-1 1-2.5 1-3.4 0l-.6-.6c-1-1-1-2.5 0-3.4L15 5",key:"1exhtz"}],["path",{d:"m9 11 4 4",key:"rovt3i"}],["path",{d:"m5 19-3 3",key:"59f2uf"}],["path",{d:"m14 4 6 6",key:"yqp9t2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T5=Z("Table2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fee=Z("TableCellsMerge",[["path",{d:"M12 21v-6",key:"lihzve"}],["path",{d:"M12 9V3",key:"da5inc"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zee=Z("TableCellsSplit",[["path",{d:"M12 15V9",key:"8c7uyn"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bee=Z("TableColumnsSplit",[["path",{d:"M14 14v2",key:"w2a1xv"}],["path",{d:"M14 20v2",key:"1lq872"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M14 8v2",key:"i67w9a"}],["path",{d:"M2 15h8",key:"82wtch"}],["path",{d:"M2 3h6a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H2",key:"up0l64"}],["path",{d:"M2 9h8",key:"yelfik"}],["path",{d:"M22 15h-4",key:"1es58f"}],["path",{d:"M22 3h-2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h2",key:"pdjoqf"}],["path",{d:"M22 9h-4",key:"1luja7"}],["path",{d:"M5 3v18",key:"14hmio"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ee=Z("TableOfContents",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M21 12h.01",key:"msek7k"}],["path",{d:"M21 18h.01",key:"1e8rq1"}],["path",{d:"M21 6h.01",key:"1koanj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qee=Z("TableProperties",[["path",{d:"M15 3v18",key:"14nvp0"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uee=Z("TableRowsSplit",[["path",{d:"M14 10h2",key:"1lstlu"}],["path",{d:"M15 22v-8",key:"1fwwgm"}],["path",{d:"M15 2v4",key:"1044rn"}],["path",{d:"M2 10h2",key:"1r8dkt"}],["path",{d:"M20 10h2",key:"1ug425"}],["path",{d:"M3 19h18",key:"awlh7x"}],["path",{d:"M3 22v-6a2 2 135 0 1 2-2h14a2 2 45 0 1 2 2v6",key:"ibqhof"}],["path",{d:"M3 2v2a2 2 45 0 0 2 2h14a2 2 135 0 0 2-2V2",key:"1uenja"}],["path",{d:"M8 10h2",key:"66od0"}],["path",{d:"M9 22v-8",key:"fmnu31"}],["path",{d:"M9 2v4",key:"j1yeou"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $P=Z("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vee=Z("TabletSmartphone",[["rect",{width:"10",height:"14",x:"3",y:"8",rx:"2",key:"1vrsiq"}],["path",{d:"M5 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2h-2.4",key:"1j4zmg"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hee=Z("Tablet",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wee=Z("Tablets",[["circle",{cx:"7",cy:"7",r:"5",key:"x29byf"}],["circle",{cx:"17",cy:"17",r:"5",key:"1op1d2"}],["path",{d:"M12 17h10",key:"ls21zv"}],["path",{d:"m3.46 10.54 7.08-7.08",key:"1rehiu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wh=Z("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gee=Z("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kee=Z("Tally1",[["path",{d:"M4 4v16",key:"6qkkli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zee=Z("Tally2",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yee=Z("Tally3",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xee=Z("Tally4",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}],["path",{d:"M19 4v16",key:"8ij5ei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qee=Z("Tally5",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}],["path",{d:"M19 4v16",key:"8ij5ei"}],["path",{d:"M22 6 2 18",key:"h9moai"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jee=Z("Tangent",[["circle",{cx:"17",cy:"4",r:"2",key:"y5j2s2"}],["path",{d:"M15.59 5.41 5.41 15.59",key:"l0vprr"}],["circle",{cx:"4",cy:"17",r:"2",key:"9p4efm"}],["path",{d:"M12 22s-4-9-1.5-11.5S22 12 22 12",key:"1twk4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gh=Z("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ete=Z("Telescope",[["path",{d:"m10.065 12.493-6.18 1.318a.934.934 0 0 1-1.108-.702l-.537-2.15a1.07 1.07 0 0 1 .691-1.265l13.504-4.44",key:"k4qptu"}],["path",{d:"m13.56 11.747 4.332-.924",key:"19l80z"}],["path",{d:"m16 21-3.105-6.21",key:"7oh9d"}],["path",{d:"M16.485 5.94a2 2 0 0 1 1.455-2.425l1.09-.272a1 1 0 0 1 1.212.727l1.515 6.06a1 1 0 0 1-.727 1.213l-1.09.272a2 2 0 0 1-2.425-1.455z",key:"m7xp4m"}],["path",{d:"m6.158 8.633 1.114 4.456",key:"74o979"}],["path",{d:"m8 21 3.105-6.21",key:"1fvxut"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tte=Z("TentTree",[["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}],["path",{d:"m14 5 3-3 3 3",key:"1sorif"}],["path",{d:"m14 10 3-3 3 3",key:"1jyi9h"}],["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M17 14H7l-5 8h20Z",key:"13ar7p"}],["path",{d:"M8 14v8",key:"1ghmqk"}],["path",{d:"m9 14 5 8",key:"13pgi6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ste=Z("Tent",[["path",{d:"M3.5 21 14 3",key:"1szst5"}],["path",{d:"M20.5 21 10 3",key:"1310c3"}],["path",{d:"M15.5 21 12 15l-3.5 6",key:"1ddtfw"}],["path",{d:"M2 21h20",key:"1nyx9w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rte=Z("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sN=Z("TestTubeDiagonal",[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nte=Z("TestTube",[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ate=Z("TestTubes",[["path",{d:"M9 2v17.5A2.5 2.5 0 0 1 6.5 22A2.5 2.5 0 0 1 4 19.5V2",key:"1hjrqt"}],["path",{d:"M20 2v17.5a2.5 2.5 0 0 1-2.5 2.5a2.5 2.5 0 0 1-2.5-2.5V2",key:"16lc8n"}],["path",{d:"M3 2h7",key:"7s29d5"}],["path",{d:"M14 2h7",key:"7sicin"}],["path",{d:"M9 16H4",key:"1bfye3"}],["path",{d:"M20 16h-5",key:"ddnjpe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ite=Z("TextCursorInput",[["path",{d:"M5 4h1a3 3 0 0 1 3 3 3 3 0 0 1 3-3h1",key:"18xjzo"}],["path",{d:"M13 20h-1a3 3 0 0 1-3-3 3 3 0 0 1-3 3H5",key:"fj48gi"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M9 7v10",key:"1vc8ob"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ote=Z("TextCursor",[["path",{d:"M17 22h-1a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4h1",key:"uvaxm9"}],["path",{d:"M7 22h1a4 4 0 0 0 4-4v-1",key:"11xy8d"}],["path",{d:"M7 2h1a4 4 0 0 1 4 4v1",key:"1uw06m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lte=Z("TextQuote",[["path",{d:"M17 6H3",key:"16j9eg"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 18H8",key:"1wfozv"}],["path",{d:"M3 12v6",key:"fv4c87"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cte=Z("TextSearch",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rN=Z("TextSelect",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}],["line",{x1:"7",x2:"15",y1:"8",y2:"8",key:"1758g8"}],["line",{x1:"7",x2:"17",y1:"12",y2:"12",key:"197423"}],["line",{x1:"7",x2:"13",y1:"16",y2:"16",key:"37cgm6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dte=Z("Text",[["path",{d:"M17 6.1H3",key:"wptmhv"}],["path",{d:"M21 12.1H3",key:"1j38uz"}],["path",{d:"M15.1 18H3",key:"1nb16a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ute=Z("Theater",[["path",{d:"M2 10s3-3 3-8",key:"3xiif0"}],["path",{d:"M22 10s-3-3-3-8",key:"ioaa5q"}],["path",{d:"M10 2c0 4.4-3.6 8-8 8",key:"16fkpi"}],["path",{d:"M14 2c0 4.4 3.6 8 8 8",key:"b9eulq"}],["path",{d:"M2 10s2 2 2 5",key:"1au1lb"}],["path",{d:"M22 10s-2 2-2 5",key:"qi2y5e"}],["path",{d:"M8 15h8",key:"45n4r"}],["path",{d:"M2 22v-1a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1",key:"1vsc2m"}],["path",{d:"M14 22v-1a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1",key:"hrha4u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hte=Z("ThermometerSnowflake",[["path",{d:"M2 12h10",key:"19562f"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"m3 9 3 3-3 3",key:"1sas0l"}],["path",{d:"M12 6 9 9 6 6",key:"pfrgxu"}],["path",{d:"m6 18 3-3 1.5 1.5",key:"1e277p"}],["path",{d:"M20 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"iof6y5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mte=Z("ThermometerSun",[["path",{d:"M12 9a4 4 0 0 0-2 7.5",key:"1jvsq6"}],["path",{d:"M12 3v2",key:"1w22ol"}],["path",{d:"m6.6 18.4-1.4 1.4",key:"w2yidj"}],["path",{d:"M20 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"iof6y5"}],["path",{d:"M4 13H2",key:"118le4"}],["path",{d:"M6.34 7.34 4.93 5.93",key:"1brd51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pte=Z("Thermometer",[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qP=Z("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gu=Z("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fte=Z("TicketCheck",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gte=Z("TicketMinus",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M9 12h6",key:"1c52cq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xte=Z("TicketPercent",[["path",{d:"M2 9a3 3 0 1 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 1 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"1l48ns"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yte=Z("TicketPlus",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M12 9v6",key:"199k2o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vte=Z("TicketSlash",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9.5 14.5 5-5",key:"qviqfa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _te=Z("TicketX",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9.5 14.5 5-5",key:"qviqfa"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UP=Z("Ticket",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bte=Z("TicketsPlane",[["path",{d:"M10.5 17h1.227a2 2 0 0 0 1.345-.52L18 12",key:"16muxl"}],["path",{d:"m12 13.5 3.75.5",key:"1i9qhk"}],["path",{d:"m4.5 8 10.58-5.06a1 1 0 0 1 1.342.488L18.5 8",key:"12lg5p"}],["path",{d:"M6 10V8",key:"1y41hn"}],["path",{d:"M6 14v1",key:"cao2tf"}],["path",{d:"M6 19v2",key:"1loha6"}],["rect",{x:"2",y:"8",width:"20",height:"13",rx:"2",key:"p3bz5l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wte=Z("Tickets",[["path",{d:"m4.5 8 10.58-5.06a1 1 0 0 1 1.342.488L18.5 8",key:"12lg5p"}],["path",{d:"M6 10V8",key:"1y41hn"}],["path",{d:"M6 14v1",key:"cao2tf"}],["path",{d:"M6 19v2",key:"1loha6"}],["rect",{x:"2",y:"8",width:"20",height:"13",rx:"2",key:"p3bz5l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jte=Z("TimerOff",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M4.6 11a8 8 0 0 0 1.7 8.7 8 8 0 0 0 8.7 1.7",key:"10he05"}],["path",{d:"M7.4 7.4a8 8 0 0 1 10.3 1 8 8 0 0 1 .9 10.2",key:"15f7sh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M12 12v-2",key:"fwoke6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nte=Z("TimerReset",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M12 14v-4",key:"1evpnu"}],["path",{d:"M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6",key:"1ts96g"}],["path",{d:"M9 17H4v5",key:"8t5av"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kte=Z("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ste=Z("ToggleLeft",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cte=Z("ToggleRight",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mte=Z("Toilet",[["path",{d:"M7 12h13a1 1 0 0 1 1 1 5 5 0 0 1-5 5h-.598a.5.5 0 0 0-.424.765l1.544 2.47a.5.5 0 0 1-.424.765H5.402a.5.5 0 0 1-.424-.765L7 18",key:"kc4kqr"}],["path",{d:"M8 18a5 5 0 0 1-5-5V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8",key:"1tqs57"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tte=Z("Tornado",[["path",{d:"M21 4H3",key:"1hwok0"}],["path",{d:"M18 8H6",key:"41n648"}],["path",{d:"M19 12H9",key:"1g4lpz"}],["path",{d:"M16 16h-6",key:"1j5d54"}],["path",{d:"M11 20H9",key:"39obr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ate=Z("Torus",[["ellipse",{cx:"12",cy:"11",rx:"3",ry:"2",key:"1b2qxu"}],["ellipse",{cx:"12",cy:"12.5",rx:"10",ry:"8.5",key:"h8emeu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ete=Z("TouchpadOff",[["path",{d:"M4 4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16",key:"lnt0bk"}],["path",{d:"M2 14h12",key:"d8icqz"}],["path",{d:"M22 14h-2",key:"jrx26d"}],["path",{d:"M12 20v-6",key:"1rm09r"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M22 16V6a2 2 0 0 0-2-2H10",key:"11y8e4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pte=Z("Touchpad",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M12 20v-6",key:"1rm09r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ite=Z("TowerControl",[["path",{d:"M18.2 12.27 20 6H4l1.8 6.27a1 1 0 0 0 .95.73h10.5a1 1 0 0 0 .96-.73Z",key:"1pledb"}],["path",{d:"M8 13v9",key:"hmv0ci"}],["path",{d:"M16 22v-9",key:"ylnf1u"}],["path",{d:"m9 6 1 7",key:"dpdgam"}],["path",{d:"m15 6-1 7",key:"ls7zgu"}],["path",{d:"M12 6V2",key:"1pj48d"}],["path",{d:"M13 2h-2",key:"mj6ths"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lte=Z("ToyBrick",[["rect",{width:"18",height:"12",x:"3",y:"8",rx:"1",key:"158fvp"}],["path",{d:"M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3",key:"s0042v"}],["path",{d:"M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3",key:"9wmeh2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dte=Z("Tractor",[["path",{d:"m10 11 11 .9a1 1 0 0 1 .8 1.1l-.665 4.158a1 1 0 0 1-.988.842H20",key:"she1j9"}],["path",{d:"M16 18h-5",key:"bq60fd"}],["path",{d:"M18 5a1 1 0 0 0-1 1v5.573",key:"1kv8ia"}],["path",{d:"M3 4h8.129a1 1 0 0 1 .99.863L13 11.246",key:"1q1ert"}],["path",{d:"M4 11V4",key:"9ft8pt"}],["path",{d:"M7 15h.01",key:"k5ht0j"}],["path",{d:"M8 10.1V4",key:"1jgyzo"}],["circle",{cx:"18",cy:"18",r:"2",key:"1emm8v"}],["circle",{cx:"7",cy:"15",r:"5",key:"ddtuc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ote=Z("TrafficCone",[["path",{d:"M9.3 6.2a4.55 4.55 0 0 0 5.4 0",key:"flyxqv"}],["path",{d:"M7.9 10.7c.9.8 2.4 1.3 4.1 1.3s3.2-.5 4.1-1.3",key:"1nlxxg"}],["path",{d:"M13.9 3.5a1.93 1.93 0 0 0-3.8-.1l-3 10c-.1.2-.1.4-.1.6 0 1.7 2.2 3 5 3s5-1.3 5-3c0-.2 0-.4-.1-.5Z",key:"vz7x1l"}],["path",{d:"m7.5 12.2-4.7 2.7c-.5.3-.8.7-.8 1.1s.3.8.8 1.1l7.6 4.5c.9.5 2.1.5 3 0l7.6-4.5c.7-.3 1-.7 1-1.1s-.3-.8-.8-1.1l-4.7-2.8",key:"1xfzlw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rte=Z("TrainFrontTunnel",[["path",{d:"M2 22V12a10 10 0 1 1 20 0v10",key:"o0fyp0"}],["path",{d:"M15 6.8v1.4a3 2.8 0 1 1-6 0V6.8",key:"m8q3n9"}],["path",{d:"M10 15h.01",key:"44in9x"}],["path",{d:"M14 15h.01",key:"5mohn5"}],["path",{d:"M10 19a4 4 0 0 1-4-4v-3a6 6 0 1 1 12 0v3a4 4 0 0 1-4 4Z",key:"hckbmu"}],["path",{d:"m9 19-2 3",key:"iij7hm"}],["path",{d:"m15 19 2 3",key:"npx8sa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fte=Z("TrainFront",[["path",{d:"M8 3.1V7a4 4 0 0 0 8 0V3.1",key:"1v71zp"}],["path",{d:"m9 15-1-1",key:"1yrq24"}],["path",{d:"m15 15 1-1",key:"1t0d6s"}],["path",{d:"M9 19c-2.8 0-5-2.2-5-5v-4a8 8 0 0 1 16 0v4c0 2.8-2.2 5-5 5Z",key:"1p0hjs"}],["path",{d:"m8 19-2 3",key:"13i0xs"}],["path",{d:"m16 19 2 3",key:"xo31yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zte=Z("TrainTrack",[["path",{d:"M2 17 17 2",key:"18b09t"}],["path",{d:"m2 14 8 8",key:"1gv9hu"}],["path",{d:"m5 11 8 8",key:"189pqp"}],["path",{d:"m8 8 8 8",key:"1imecy"}],["path",{d:"m11 5 8 8",key:"ummqn6"}],["path",{d:"m14 2 8 8",key:"1vk7dn"}],["path",{d:"M7 22 22 7",key:"15mb1i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nN=Z("TramFront",[["rect",{width:"16",height:"16",x:"4",y:"3",rx:"2",key:"1wxw4b"}],["path",{d:"M4 11h16",key:"mpoxn0"}],["path",{d:"M12 3v8",key:"1h2ygw"}],["path",{d:"m8 19-2 3",key:"13i0xs"}],["path",{d:"m18 22-2-3",key:"1p0ohu"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M16 15h.01",key:"rnfrdf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jr=Z("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bte=Z("Trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $te=Z("TreeDeciduous",[["path",{d:"M8 19a4 4 0 0 1-2.24-7.32A3.5 3.5 0 0 1 9 6.03V6a3 3 0 1 1 6 0v.04a3.5 3.5 0 0 1 3.24 5.65A4 4 0 0 1 16 19Z",key:"oadzkq"}],["path",{d:"M12 19v3",key:"npa21l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aN=Z("TreePalm",[["path",{d:"M13 8c0-2.76-2.46-5-5.5-5S2 5.24 2 8h2l1-1 1 1h4",key:"foxbe7"}],["path",{d:"M13 7.14A5.82 5.82 0 0 1 16.5 6c3.04 0 5.5 2.24 5.5 5h-3l-1-1-1 1h-3",key:"18arnh"}],["path",{d:"M5.89 9.71c-2.15 2.15-2.3 5.47-.35 7.43l4.24-4.25.7-.7.71-.71 2.12-2.12c-1.95-1.96-5.27-1.8-7.42.35",key:"ywahnh"}],["path",{d:"M11 15.5c.5 2.5-.17 4.5-1 6.5h4c2-5.5-.5-12-1-14",key:"ft0feo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m_=Z("TreePine",[["path",{d:"m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z",key:"cpyugq"}],["path",{d:"M12 22v-3",key:"kmzjlo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qte=Z("Trees",[["path",{d:"M10 10v.2A3 3 0 0 1 8.9 16H5a3 3 0 0 1-1-5.8V10a3 3 0 0 1 6 0Z",key:"1l6gj6"}],["path",{d:"M7 16v6",key:"1a82de"}],["path",{d:"M13 19v3",key:"13sx9i"}],["path",{d:"M12 19h8.3a1 1 0 0 0 .7-1.7L18 14h.3a1 1 0 0 0 .7-1.7L16 9h.2a1 1 0 0 0 .8-1.7L13 3l-1.4 1.5",key:"1sj9kv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ute=Z("Trello",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["rect",{width:"3",height:"9",x:"7",y:"7",key:"14n3xi"}],["rect",{width:"3",height:"5",x:"14",y:"7",key:"s4azjd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fk=Z("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vte=Z("TrendingUpDown",[["path",{d:"M14.828 14.828 21 21",key:"ar5fw7"}],["path",{d:"M21 16v5h-5",key:"1ck2sf"}],["path",{d:"m21 3-9 9-4-4-6 6",key:"1h02xo"}],["path",{d:"M21 8V3h-5",key:"1qoq8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ac=Z("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ju=Z("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hte=Z("TriangleRight",[["path",{d:"M22 18a2 2 0 0 1-2 2H3c-1.1 0-1.3-.6-.4-1.3L20.4 4.3c.9-.7 1.6-.4 1.6.7Z",key:"183wce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wte=Z("Triangle",[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ao=Z("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VP=Z("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gte=Z("Turtle",[["path",{d:"m12 10 2 4v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3a8 8 0 1 0-16 0v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3l2-4h4Z",key:"1lbbv7"}],["path",{d:"M4.82 7.9 8 10",key:"m9wose"}],["path",{d:"M15.18 7.9 12 10",key:"p8dp2u"}],["path",{d:"M16.93 10H20a2 2 0 0 1 0 4H2",key:"12nsm7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kte=Z("TvMinimalPlay",[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iN=Z("TvMinimal",[["path",{d:"M7 21h10",key:"1b0cd5"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zte=Z("Tv",[["rect",{width:"20",height:"15",x:"2",y:"7",rx:"2",ry:"2",key:"10ag99"}],["polyline",{points:"17 2 12 7 7 2",key:"11pgbg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yte=Z("Twitch",[["path",{d:"M21 2H3v16h5v4l4-4h5l4-4V2zm-10 9V7m5 4V7",key:"c0yzno"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xte=Z("Twitter",[["path",{d:"M22 4s-.7 2.1-2 3.4c1.6 10-9.4 17.3-18 11.6 2.2.1 4.4-.6 6-2C3 15.5.5 9.6 3 5c2.2 2.6 5.6 4.1 9 4-.9-4.2 4-6.6 7-3.8 1.1 0 3-1.2 3-1.2z",key:"pff0z6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qte=Z("TypeOutline",[["path",{d:"M14 16.5a.5.5 0 0 0 .5.5h.5a2 2 0 0 1 0 4H9a2 2 0 0 1 0-4h.5a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5V8a2 2 0 0 1-4 0V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3a2 2 0 0 1-4 0v-.5a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5Z",key:"1reda3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jte=Z("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ese=Z("UmbrellaOff",[["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"M15.5 21a1.85 1.85 0 0 1-3.5-1v-8H2a10 10 0 0 1 3.428-6.575",key:"eki10q"}],["path",{d:"M17.5 12H22A10 10 0 0 0 9.004 3.455",key:"n2ayka"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tse=Z("Umbrella",[["path",{d:"M22 12a10.06 10.06 1 0 0-20 0Z",key:"1teyop"}],["path",{d:"M12 12v8a2 2 0 0 0 4 0",key:"ulpmoc"}],["path",{d:"M12 2v1",key:"11qlp1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sse=Z("Underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rse=Z("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nse=Z("UndoDot",[["path",{d:"M21 17a9 9 0 0 0-15-6.7L3 13",key:"8mp6z9"}],["path",{d:"M3 7v6h6",key:"1v2h90"}],["circle",{cx:"12",cy:"17",r:"1",key:"1ixnty"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A5=Z("Undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ase=Z("UnfoldHorizontal",[["path",{d:"M16 12h6",key:"15xry1"}],["path",{d:"M8 12H2",key:"1jqql6"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m19 15 3-3-3-3",key:"wjy7rq"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ise=Z("UnfoldVertical",[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m15 5-3-3-3 3",key:"itvq4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ose=Z("Ungroup",[["rect",{width:"8",height:"6",x:"5",y:"4",rx:"1",key:"nzclkv"}],["rect",{width:"8",height:"6",x:"11",y:"14",rx:"1",key:"4tytwb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oN=Z("University",[["circle",{cx:"12",cy:"10",r:"1",key:"1gnqs8"}],["path",{d:"M22 20V8h-4l-6-4-6 4H2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2",key:"1qj5sn"}],["path",{d:"M6 17v.01",key:"roodi6"}],["path",{d:"M6 13v.01",key:"67c122"}],["path",{d:"M18 17v.01",key:"12ktxm"}],["path",{d:"M18 13v.01",key:"tn1rt1"}],["path",{d:"M14 22v-5a2 2 0 0 0-2-2a2 2 0 0 0-2 2v5",key:"11g7fi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lse=Z("Unlink2",[["path",{d:"M15 7h2a5 5 0 0 1 0 10h-2m-6 0H7A5 5 0 0 1 7 7h2",key:"1re2ne"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gk=Z("Unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cse=Z("Unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Za=Z("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dse=Z("Usb",[["circle",{cx:"10",cy:"7",r:"1",key:"dypaad"}],["circle",{cx:"4",cy:"20",r:"1",key:"22iqad"}],["path",{d:"M4.7 19.3 19 5",key:"1enqfc"}],["path",{d:"m21 3-3 1 2 2Z",key:"d3ov82"}],["path",{d:"M9.26 7.68 5 12l2 5",key:"1esawj"}],["path",{d:"m10 14 5 2 3.5-3.5",key:"v8oal5"}],["path",{d:"m18 12 1-1 1 1-1 1Z",key:"1bh22v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p_=Z("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HP=Z("UserCog",[["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m21.7 16.4-.9-.3",key:"12j9ji"}],["path",{d:"m15.2 13.9-.9-.3",key:"1fdjdi"}],["path",{d:"m16.6 18.7.3-.9",key:"heedtr"}],["path",{d:"m19.1 12.2.3-.9",key:"1af3ki"}],["path",{d:"m19.6 18.7-.4-1",key:"1x9vze"}],["path",{d:"m16.8 12.3-.4-1",key:"vqeiwj"}],["path",{d:"m14.3 16.6 1-.4",key:"1qlj63"}],["path",{d:"m20.7 13.8 1-.4",key:"1v5t8k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WP=Z("UserMinus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const use=Z("UserPen",[["path",{d:"M11.5 15H7a4 4 0 0 0-4 4v2",key:"15lzij"}],["path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1817ys"}],["circle",{cx:"10",cy:"7",r:"4",key:"e45bow"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yc=Z("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lN=Z("UserRoundCheck",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cN=Z("UserRoundCog",[["path",{d:"M2 21a8 8 0 0 1 10.434-7.62",key:"1yezr2"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m19.5 14.3-.4.9",key:"1eb35c"}],["path",{d:"m16.9 20.8-.4.9",key:"dfjc4z"}],["path",{d:"m21.7 19.5-.9-.4",key:"q4dx6b"}],["path",{d:"m15.2 16.9-.9-.4",key:"1r0w5f"}],["path",{d:"m21.7 16.5-.9.4",key:"1knoei"}],["path",{d:"m15.2 19.1-.9.4",key:"j188fs"}],["path",{d:"m19.5 21.7-.4-.9",key:"1tonu5"}],["path",{d:"m16.9 15.2-.4-.9",key:"699xu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dN=Z("UserRoundMinus",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 19h-6",key:"vcuq98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hse=Z("UserRoundPen",[["path",{d:"M2 21a8 8 0 0 1 10.821-7.487",key:"1c8h7z"}],["path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1817ys"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uN=Z("UserRoundPlus",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M22 19h-6",key:"vcuq98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mse=Z("UserRoundSearch",[["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M2 21a8 8 0 0 1 10.434-7.62",key:"1yezr2"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m22 22-1.9-1.9",key:"1e5ubv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hN=Z("UserRoundX",[["path",{d:"M2 21a8 8 0 0 1 11.873-7",key:"74fkxq"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"m17 17 5 5",key:"p7ous7"}],["path",{d:"m22 17-5 5",key:"gqnmv0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mN=Z("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pse=Z("UserSearch",[["circle",{cx:"10",cy:"7",r:"4",key:"e45bow"}],["path",{d:"M10.3 15H7a4 4 0 0 0-4 4v2",key:"3bnktk"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fse=Z("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yi=Z("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pN=Z("UsersRound",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hr=Z("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fN=Z("UtensilsCrossed",[["path",{d:"m16 2-2.3 2.3a3 3 0 0 0 0 4.2l1.8 1.8a3 3 0 0 0 4.2 0L22 8",key:"n7qcjb"}],["path",{d:"M15 15 3.3 3.3a4.2 4.2 0 0 0 0 6l7.3 7.3c.7.7 2 .7 2.8 0L15 15Zm0 0 7 7",key:"d0u48b"}],["path",{d:"m2.1 21.8 6.4-6.3",key:"yn04lh"}],["path",{d:"m19 5-7 7",key:"194lzd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gN=Z("Utensils",[["path",{d:"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2",key:"cjf0a3"}],["path",{d:"M7 2v20",key:"1473qp"}],["path",{d:"M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7",key:"j28e5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gse=Z("UtilityPole",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M3 3v2",key:"9imdir"}],["path",{d:"M7 3v2",key:"n0os7"}],["path",{d:"M17 3v2",key:"1l2re6"}],["path",{d:"M21 3v2",key:"1duuac"}],["path",{d:"m19 5-7 7-7-7",key:"133zxf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GP=Z("Variable",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xse=Z("Vault",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["path",{d:"m7.9 7.9 2.7 2.7",key:"hpeyl3"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}],["path",{d:"m13.4 10.6 2.7-2.7",key:"264c1n"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["path",{d:"m7.9 16.1 2.7-2.7",key:"p81g5e"}],["circle",{cx:"16.5",cy:"16.5",r:".5",fill:"currentColor",key:"fubopw"}],["path",{d:"m13.4 13.4 2.7 2.7",key:"abhel3"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yse=Z("Vegan",[["path",{d:"M16 8q6 0 6-6-6 0-6 6",key:"qsyyc4"}],["path",{d:"M17.41 3.59a10 10 0 1 0 3 3",key:"41m9h7"}],["path",{d:"M2 2a26.6 26.6 0 0 1 10 20c.9-6.82 1.5-9.5 4-14",key:"qiv7li"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vse=Z("VenetianMask",[["path",{d:"M18 11c-1.5 0-2.5.5-3 2",key:"1fod00"}],["path",{d:"M4 6a2 2 0 0 0-2 2v4a5 5 0 0 0 5 5 8 8 0 0 1 5 2 8 8 0 0 1 5-2 5 5 0 0 0 5-5V8a2 2 0 0 0-2-2h-3a8 8 0 0 0-5 2 8 8 0 0 0-5-2z",key:"d70hit"}],["path",{d:"M6 11c1.5 0 2.5.5 3 2",key:"136fht"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _se=Z("VibrateOff",[["path",{d:"m2 8 2 2-2 2 2 2-2 2",key:"sv1b1"}],["path",{d:"m22 8-2 2 2 2-2 2 2 2",key:"101i4y"}],["path",{d:"M8 8v10c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2",key:"1hbad5"}],["path",{d:"M16 10.34V6c0-.55-.45-1-1-1h-4.34",key:"1x5tf0"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bse=Z("Vibrate",[["path",{d:"m2 8 2 2-2 2 2 2-2 2",key:"sv1b1"}],["path",{d:"m22 8-2 2 2 2-2 2 2 2",key:"101i4y"}],["rect",{width:"8",height:"14",x:"8",y:"5",rx:"1",key:"1oyrl4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wse=Z("VideoOff",[["path",{d:"M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196",key:"w8jjjt"}],["path",{d:"M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"1xawa7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nn=Z("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jse=Z("Videotape",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M2 8h20",key:"d11cs7"}],["circle",{cx:"8",cy:"14",r:"2",key:"1k2qr5"}],["path",{d:"M8 12h8",key:"1wcyev"}],["circle",{cx:"16",cy:"14",r:"2",key:"14k7lr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nse=Z("View",[["path",{d:"M21 17v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2",key:"mrq65r"}],["path",{d:"M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2",key:"be3xqs"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kse=Z("Voicemail",[["circle",{cx:"6",cy:"12",r:"4",key:"1ehtga"}],["circle",{cx:"18",cy:"12",r:"4",key:"4vafl8"}],["line",{x1:"6",x2:"18",y1:"16",y2:"16",key:"pmt8us"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sse=Z("Volleyball",[["path",{d:"M11.1 7.1a16.55 16.55 0 0 1 10.9 4",key:"2880wi"}],["path",{d:"M12 12a12.6 12.6 0 0 1-8.7 5",key:"113sja"}],["path",{d:"M16.8 13.6a16.55 16.55 0 0 1-9 7.5",key:"1qmsgl"}],["path",{d:"M20.7 17a12.8 12.8 0 0 0-8.7-5 13.3 13.3 0 0 1 0-10",key:"1bmeqp"}],["path",{d:"M6.3 3.8a16.55 16.55 0 0 0 1.9 11.5",key:"iekzv9"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cse=Z("Volume1",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mse=Z("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tse=Z("VolumeOff",[["path",{d:"M16 9a5 5 0 0 1 .95 2.293",key:"1fgyg8"}],["path",{d:"M19.364 5.636a9 9 0 0 1 1.889 9.96",key:"l3zxae"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m7 7-.587.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298V11",key:"1gbwow"}],["path",{d:"M9.828 4.172A.686.686 0 0 1 11 4.657v.686",key:"s2je0y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ase=Z("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ese=Z("Volume",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pse=Z("Vote",[["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}],["path",{d:"M5 7c0-1.1.9-2 2-2h10a2 2 0 0 1 2 2v12H5V7Z",key:"1ezoue"}],["path",{d:"M22 19H2",key:"nuriw5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ise=Z("WalletCards",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2",key:"4125el"}],["path",{d:"M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21",key:"1dpki6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xN=Z("WalletMinimal",[["path",{d:"M17 14h.01",key:"7oqj8z"}],["path",{d:"M7 7h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14",key:"u1rqew"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KP=Z("Wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lse=Z("Wallpaper",[["circle",{cx:"8",cy:"9",r:"2",key:"gjzl9d"}],["path",{d:"m9 17 6.1-6.1a2 2 0 0 1 2.81.01L22 15V5a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2",key:"69xh40"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x0=Z("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dse=Z("Wand",[["path",{d:"M15 4V2",key:"z1p9b7"}],["path",{d:"M15 16v-2",key:"px0unx"}],["path",{d:"M8 9h2",key:"1g203m"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M17.8 11.8 19 13",key:"yihg8r"}],["path",{d:"M15 9h.01",key:"x1ddxp"}],["path",{d:"M17.8 6.2 19 5",key:"fd4us0"}],["path",{d:"m3 21 9-9",key:"1jfql5"}],["path",{d:"M12.2 6.2 11 5",key:"i3da3b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ose=Z("Warehouse",[["path",{d:"M22 8.35V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8.35A2 2 0 0 1 3.26 6.5l8-3.2a2 2 0 0 1 1.48 0l8 3.2A2 2 0 0 1 22 8.35Z",key:"gksnxg"}],["path",{d:"M6 18h12",key:"9pbo8z"}],["path",{d:"M6 14h12",key:"4cwo0f"}],["rect",{width:"12",height:"12",x:"6",y:"10",key:"apd30q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rse=Z("WashingMachine",[["path",{d:"M3 6h3",key:"155dbl"}],["path",{d:"M17 6h.01",key:"e2y6kg"}],["rect",{width:"18",height:"20",x:"3",y:"2",rx:"2",key:"od3kk9"}],["circle",{cx:"12",cy:"13",r:"5",key:"nlbqau"}],["path",{d:"M12 18a2.5 2.5 0 0 0 0-5 2.5 2.5 0 0 1 0-5",key:"17lach"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fse=Z("Watch",[["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["polyline",{points:"12 10 12 12 13 13",key:"19dquz"}],["path",{d:"m16.13 7.66-.81-4.05a2 2 0 0 0-2-1.61h-2.68a2 2 0 0 0-2 1.61l-.78 4.05",key:"18k57s"}],["path",{d:"m7.88 16.36.8 4a2 2 0 0 0 2 1.61h2.72a2 2 0 0 0 2-1.61l.81-4.05",key:"16ny36"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zse=Z("Waves",[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bse=Z("Waypoints",[["circle",{cx:"12",cy:"4.5",r:"2.5",key:"r5ysbb"}],["path",{d:"m10.2 6.3-3.9 3.9",key:"1nzqf6"}],["circle",{cx:"4.5",cy:"12",r:"2.5",key:"jydg6v"}],["path",{d:"M7 12h10",key:"b7w52i"}],["circle",{cx:"19.5",cy:"12",r:"2.5",key:"1piiel"}],["path",{d:"m13.8 17.7 3.9-3.9",key:"1wyg1y"}],["circle",{cx:"12",cy:"19.5",r:"2.5",key:"13o1pw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $se=Z("Webcam",[["circle",{cx:"12",cy:"10",r:"8",key:"1gshiw"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 22h10",key:"10w4w3"}],["path",{d:"M12 22v-4",key:"1utk9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qse=Z("WebhookOff",[["path",{d:"M17 17h-5c-1.09-.02-1.94.92-2.5 1.9A3 3 0 1 1 2.57 15",key:"1tvl6x"}],["path",{d:"M9 3.4a4 4 0 0 1 6.52.66",key:"q04jfq"}],["path",{d:"m6 17 3.1-5.8a2.5 2.5 0 0 0 .057-2.05",key:"azowf0"}],["path",{d:"M20.3 20.3a4 4 0 0 1-2.3.7",key:"5joiws"}],["path",{d:"M18.6 13a4 4 0 0 1 3.357 3.414",key:"cangb8"}],["path",{d:"m12 6 .6 1",key:"tpjl1n"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Use=Z("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vse=Z("Weight",[["circle",{cx:"12",cy:"5",r:"3",key:"rqqgnr"}],["path",{d:"M6.5 8a2 2 0 0 0-1.905 1.46L2.1 18.5A2 2 0 0 0 4 21h16a2 2 0 0 0 1.925-2.54L19.4 9.5A2 2 0 0 0 17.48 8Z",key:"56o5sh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hse=Z("WheatOff",[["path",{d:"m2 22 10-10",key:"28ilpk"}],["path",{d:"m16 8-1.17 1.17",key:"1qqm82"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"m8 8-.53.53a3.5 3.5 0 0 0 0 4.94L9 15l1.53-1.53c.55-.55.88-1.25.98-1.97",key:"4wz8re"}],["path",{d:"M10.91 5.26c.15-.26.34-.51.56-.73L13 3l1.53 1.53a3.5 3.5 0 0 1 .28 4.62",key:"rves66"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"m16 16-.53.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.49 3.49 0 0 1 1.97-.98",key:"ak46r"}],["path",{d:"M18.74 13.09c.26-.15.51-.34.73-.56L21 11l-1.53-1.53a3.5 3.5 0 0 0-4.62-.28",key:"1tw520"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wse=Z("Wheat",[["path",{d:"M2 22 16 8",key:"60hf96"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"M7.47 8.53 9 7l1.53 1.53a3.5 3.5 0 0 1 0 4.94L9 15l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1sdzmb"}],["path",{d:"M11.47 4.53 13 3l1.53 1.53a3.5 3.5 0 0 1 0 4.94L13 11l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"eoatbi"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"M15.47 13.47 17 15l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"2m8kc5"}],["path",{d:"M19.47 9.47 21 11l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L13 11l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"vex3ng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gse=Z("WholeWord",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kse=Z("WifiHigh",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zse=Z("WifiLow",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yse=Z("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xse=Z("WifiZero",[["path",{d:"M12 20h.01",key:"zekei9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qse=Z("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jse=Z("WindArrowDown",[["path",{d:"M10 2v8",key:"d4bbey"}],["path",{d:"M12.8 21.6A2 2 0 1 0 14 18H2",key:"19kp1d"}],["path",{d:"M17.5 10a2.5 2.5 0 1 1 2 4H2",key:"19kpjc"}],["path",{d:"m6 6 4 4 4-4",key:"k13n16"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ere=Z("Wind",[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tre=Z("WineOff",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h3m7 0h-1.343",key:"v48bem"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M7.307 7.307A12.33 12.33 0 0 0 7 10a5 5 0 0 0 7.391 4.391M8.638 2.981C8.75 2.668 8.872 2.34 9 2h6c1.5 4 2 6 2 8 0 .407-.05.809-.145 1.198",key:"1ymjlu"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sre=Z("Wine",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M12 15a5 5 0 0 0 5-5c0-2-.5-4-2-8H9c-1.5 4-2 6-2 8a5 5 0 0 0 5 5Z",key:"10ffi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rre=Z("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nre=Z("Worm",[["path",{d:"m19 12-1.5 3",key:"9bcu4o"}],["path",{d:"M19.63 18.81 22 20",key:"121v98"}],["path",{d:"M6.47 8.23a1.68 1.68 0 0 1 2.44 1.93l-.64 2.08a6.76 6.76 0 0 0 10.16 7.67l.42-.27a1 1 0 1 0-2.73-4.21l-.42.27a1.76 1.76 0 0 1-2.63-1.99l.64-2.08A6.66 6.66 0 0 0 3.94 3.9l-.7.4a1 1 0 1 0 2.55 4.34z",key:"1tij6q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const are=Z("WrapText",[["line",{x1:"3",x2:"21",y1:"6",y2:"6",key:"4m8b97"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["polyline",{points:"16 16 14 18 16 20",key:"1jznyi"}],["line",{x1:"3",x2:"10",y1:"18",y2:"18",key:"1h33wv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wg=Z("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ur=Z("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ire=Z("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ore=Z("ZapOff",[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fm=Z("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f_=Z("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E5=Z("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jot=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:aF,AArrowUp:iF,ALargeSmall:oF,Accessibility:lF,Activity:Pm,AirVent:cF,Airplay:dF,AlarmClock:hF,AlarmClockCheck:lw,AlarmClockMinus:cw,AlarmClockOff:uF,AlarmClockPlus:dw,AlarmSmoke:mF,Album:pF,AlignCenter:l5,AlignCenterHorizontal:fF,AlignCenterVertical:gF,AlignEndHorizontal:xF,AlignEndVertical:yF,AlignHorizontalDistributeCenter:vF,AlignHorizontalDistributeEnd:_F,AlignHorizontalDistributeStart:bF,AlignHorizontalJustifyCenter:wF,AlignHorizontalJustifyEnd:jF,AlignHorizontalJustifyStart:NF,AlignHorizontalSpaceAround:kF,AlignHorizontalSpaceBetween:SF,AlignJustify:CF,AlignLeft:c5,AlignRight:d5,AlignStartHorizontal:MF,AlignStartVertical:TF,AlignVerticalDistributeCenter:AF,AlignVerticalDistributeEnd:EF,AlignVerticalDistributeStart:PF,AlignVerticalJustifyCenter:IF,AlignVerticalJustifyEnd:LF,AlignVerticalJustifyStart:DF,AlignVerticalSpaceAround:OF,AlignVerticalSpaceBetween:RF,Ambulance:FF,Ampersand:zF,Ampersands:BF,Amphora:$F,Anchor:qF,Angry:UF,Annoyed:VF,Antenna:HF,Anvil:WF,Aperture:GF,AppWindow:sP,AppWindowMac:KF,Apple:ZF,Archive:u5,ArchiveRestore:rP,ArchiveX:YF,Armchair:XF,ArrowBigDown:JF,ArrowBigDownDash:QF,ArrowBigLeft:tz,ArrowBigLeftDash:ez,ArrowBigRight:rz,ArrowBigRightDash:sz,ArrowBigUp:az,ArrowBigUpDash:nz,ArrowDown:sh,ArrowDown01:iz,ArrowDown10:oz,ArrowDownAZ:uw,ArrowDownFromLine:lz,ArrowDownLeft:cz,ArrowDownNarrowWide:dz,ArrowDownRight:nP,ArrowDownToDot:uz,ArrowDownToLine:hz,ArrowDownUp:mz,ArrowDownWideNarrow:hw,ArrowDownZA:mw,ArrowLeft:ti,ArrowLeftFromLine:pz,ArrowLeftRight:fz,ArrowLeftToLine:gz,ArrowRight:$i,ArrowRightFromLine:xz,ArrowRightLeft:A0,ArrowRightToLine:yz,ArrowUp:Vd,ArrowUp01:vz,ArrowUp10:_z,ArrowUpAZ:pw,ArrowUpDown:Hc,ArrowUpFromDot:bz,ArrowUpFromLine:wz,ArrowUpLeft:jz,ArrowUpNarrowWide:fw,ArrowUpRight:aP,ArrowUpToLine:Nz,ArrowUpWideNarrow:kz,ArrowUpZA:gw,ArrowsUpFromLine:Sz,Asterisk:Cz,AtSign:Mz,Atom:Tz,AudioLines:Az,AudioWaveform:Ez,Award:rc,Axe:Pz,Axis3d:xw,Baby:Iz,Backpack:Lz,Badge:Yz,BadgeAlert:Dz,BadgeCent:Oz,BadgeCheck:yw,BadgeDollarSign:Rz,BadgeEuro:Fz,BadgeHelp:zz,BadgeIndianRupee:Bz,BadgeInfo:$z,BadgeJapaneseYen:qz,BadgeMinus:Uz,BadgePercent:Vz,BadgePlus:Hz,BadgePoundSterling:Wz,BadgeRussianRuble:Gz,BadgeSwissFranc:Kz,BadgeX:Zz,BaggageClaim:Xz,Ban:Qz,Banana:Jz,Bandage:e7,Banknote:t7,Barcode:s7,Baseline:r7,Bath:Zx,Battery:c7,BatteryCharging:n7,BatteryFull:a7,BatteryLow:i7,BatteryMedium:o7,BatteryWarning:l7,Beaker:d7,Bean:h7,BeanOff:u7,Bed:E0,BedDouble:iP,BedSingle:m7,Beef:p7,Beer:g7,BeerOff:f7,Bell:gf,BellDot:x7,BellElectric:y7,BellMinus:v7,BellOff:r_,BellPlus:_7,BellRing:b7,BetweenHorizontalEnd:vw,BetweenHorizontalStart:_w,BetweenVerticalEnd:w7,BetweenVerticalStart:j7,BicepsFlexed:N7,Bike:k7,Binary:S7,Binoculars:C7,Biohazard:M7,Bird:T7,Bitcoin:A7,Blend:E7,Blinds:P7,Blocks:I7,Bluetooth:R7,BluetoothConnected:L7,BluetoothOff:D7,BluetoothSearching:O7,Bold:h5,Bolt:F7,Bomb:z7,Bone:B7,Book:lB,BookA:$7,BookAudio:q7,BookCheck:U7,BookCopy:V7,BookDashed:bw,BookDown:H7,BookHeadphones:W7,BookHeart:G7,BookImage:K7,BookKey:Z7,BookLock:Y7,BookMarked:X7,BookMinus:Q7,BookOpen:Fu,BookOpenCheck:J7,BookOpenText:eB,BookPlus:tB,BookText:sB,BookType:rB,BookUp:aB,BookUp2:nB,BookUser:iB,BookX:oB,Bookmark:$g,BookmarkCheck:cB,BookmarkMinus:dB,BookmarkPlus:oP,BookmarkX:uB,BoomBox:hB,Bot:m5,BotMessageSquare:mB,BotOff:pB,Box:fB,Boxes:gB,Braces:ww,Brackets:xB,Brain:lP,BrainCircuit:yB,BrainCog:vB,BrickWall:_B,Briefcase:rh,BriefcaseBusiness:bB,BriefcaseConveyorBelt:wB,BriefcaseMedical:jB,BringToFront:NB,Brush:kB,Bug:MB,BugOff:SB,BugPlay:CB,Building:nk,Building2:Ta,Bus:AB,BusFront:TB,Cable:PB,CableCar:EB,Cake:zu,CakeSlice:IB,Calculator:LB,Calendar:on,Calendar1:DB,CalendarArrowDown:OB,CalendarArrowUp:RB,CalendarCheck:cP,CalendarCheck2:FB,CalendarClock:dP,CalendarCog:zB,CalendarDays:id,CalendarFold:BB,CalendarHeart:$B,CalendarMinus:UB,CalendarMinus2:qB,CalendarOff:uP,CalendarPlus:n_,CalendarPlus2:VB,CalendarRange:HB,CalendarSearch:WB,CalendarSync:GB,CalendarX:ZB,CalendarX2:KB,Camera:qg,CameraOff:YB,Candy:JB,CandyCane:XB,CandyOff:QB,Cannabis:e9,Captions:jw,CaptionsOff:t9,Car:n9,CarFront:s9,CarTaxiFront:r9,Caravan:a9,Carrot:i9,CaseLower:o9,CaseSensitive:l9,CaseUpper:c9,CassetteTape:d9,Cast:u9,Castle:h9,Cat:m9,Cctv:p9,ChartArea:Nw,ChartBar:Sw,ChartBarBig:kw,ChartBarDecreasing:f9,ChartBarIncreasing:g9,ChartBarStacked:x9,ChartCandlestick:Cw,ChartColumn:ol,ChartColumnBig:Mw,ChartColumnDecreasing:y9,ChartColumnIncreasing:Tw,ChartColumnStacked:v9,ChartGantt:_9,ChartLine:Aw,ChartNetwork:b9,ChartNoAxesColumn:Pw,ChartNoAxesColumnDecreasing:w9,ChartNoAxesColumnIncreasing:Ew,ChartNoAxesCombined:j9,ChartNoAxesGantt:Iw,ChartPie:Lw,ChartScatter:Dw,ChartSpline:N9,Check:ha,CheckCheck:k9,ChefHat:S9,Cherry:C9,ChevronDown:Ho,ChevronFirst:M9,ChevronLast:T9,ChevronLeft:zl,ChevronRight:Ua,ChevronUp:Ug,ChevronsDown:E9,ChevronsDownUp:A9,ChevronsLeft:L9,ChevronsLeftRight:I9,ChevronsLeftRightEllipsis:P9,ChevronsRight:O9,ChevronsRightLeft:D9,ChevronsUp:R9,ChevronsUpDown:xf,Chrome:F9,Church:z9,Cigarette:$9,CigaretteOff:B9,Circle:Kc,CircleAlert:ll,CircleArrowDown:Ow,CircleArrowLeft:Rw,CircleArrowOutDownLeft:Fw,CircleArrowOutDownRight:zw,CircleArrowOutUpLeft:Bw,CircleArrowOutUpRight:$w,CircleArrowRight:qw,CircleArrowUp:Uw,CircleCheck:ua,CircleCheckBig:hi,CircleChevronDown:Vw,CircleChevronLeft:Hw,CircleChevronRight:Ww,CircleChevronUp:Gw,CircleDashed:q9,CircleDivide:Kw,CircleDollarSign:U9,CircleDot:H9,CircleDotDashed:V9,CircleEllipsis:W9,CircleEqual:G9,CircleFadingArrowUp:K9,CircleFadingPlus:Z9,CircleGauge:Zw,CircleHelp:h0,CircleMinus:Yw,CircleOff:Y9,CircleParking:Qw,CircleParkingOff:Xw,CirclePause:Jw,CirclePercent:e2,CirclePlay:bm,CirclePlus:t2,CirclePower:s2,CircleSlash:X9,CircleSlash2:r2,CircleStop:n2,CircleUser:i2,CircleUserRound:a2,CircleX:kc,CircuitBoard:Q9,Citrus:J9,Clapperboard:e$,Clipboard:o$,ClipboardCheck:p5,ClipboardCopy:t$,ClipboardList:a_,ClipboardMinus:s$,ClipboardPaste:r$,ClipboardPen:l2,ClipboardPenLine:o2,ClipboardPlus:n$,ClipboardType:a$,ClipboardX:i$,Clock:Tn,Clock1:l$,Clock10:c$,Clock11:d$,Clock12:u$,Clock2:h$,Clock3:m$,Clock4:p$,Clock5:f$,Clock6:g$,Clock7:x$,Clock8:y$,Clock9:v$,ClockAlert:_$,ClockArrowDown:b$,ClockArrowUp:w$,Cloud:R$,CloudAlert:j$,CloudCog:N$,CloudDownload:c2,CloudDrizzle:k$,CloudFog:S$,CloudHail:C$,CloudLightning:M$,CloudMoon:A$,CloudMoonRain:T$,CloudOff:E$,CloudRain:I$,CloudRainWind:P$,CloudSnow:L$,CloudSun:O$,CloudSunRain:D$,CloudUpload:d2,Cloudy:F$,Clover:N0,Club:z$,Code:ak,CodeXml:u2,Codepen:B$,Codesandbox:$$,Coffee:ik,Cog:q$,Coins:hP,Columns2:h2,Columns3:m2,Columns4:U$,Combine:V$,Command:H$,Compass:W$,Component:G$,Computer:K$,ConciergeBell:Z$,Cone:Y$,Construction:X$,Contact:ok,ContactRound:p2,Container:Q$,Contrast:J$,Cookie:eq,CookingPot:tq,Copy:ai,CopyCheck:sq,CopyMinus:rq,CopyPlus:nq,CopySlash:aq,CopyX:iq,Copyleft:oq,Copyright:lq,CornerDownLeft:cq,CornerDownRight:dq,CornerLeftDown:uq,CornerLeftUp:hq,CornerRightDown:mq,CornerRightUp:pq,CornerUpLeft:fq,CornerUpRight:gq,Cpu:xq,CreativeCommons:yq,CreditCard:yf,Croissant:vq,Crop:_q,Cross:bq,Crosshair:wq,Crown:Uh,Cuboid:jq,CupSoda:Nq,Currency:kq,Cylinder:Sq,Dam:Cq,Database:Aq,DatabaseBackup:Mq,DatabaseZap:Tq,Delete:Eq,Dessert:Pq,Diameter:Iq,Diamond:Oq,DiamondMinus:Lq,DiamondPercent:f2,DiamondPlus:Dq,Dice1:Rq,Dice2:Fq,Dice3:zq,Dice4:Bq,Dice5:$q,Dice6:qq,Dices:Uq,Diff:Vq,Disc:Kq,Disc2:Hq,Disc3:Wq,DiscAlbum:Gq,Divide:Zq,Dna:Xq,DnaOff:Yq,Dock:Qq,Dog:Jq,DollarSign:od,Donut:eU,DoorClosed:tU,DoorOpen:P0,Dot:sU,Download:xi,DraftingCompass:rU,Drama:nU,Dribbble:aU,Drill:iU,Droplet:oU,Droplets:Vg,Drum:lU,Drumstick:cU,Dumbbell:dU,Ear:hU,EarOff:uU,Earth:g2,EarthLock:mU,Eclipse:pU,Egg:f5,EggFried:fU,EggOff:gU,Ellipsis:of,EllipsisVertical:af,Equal:vU,EqualApproximately:xU,EqualNot:yU,Eraser:_U,EthernetPort:bU,Euro:wU,Expand:jU,ExternalLink:sn,Eye:xa,EyeClosed:NU,EyeOff:Im,Facebook:Hd,Factory:kU,Fan:SU,FastForward:CU,Feather:MU,Fence:TU,FerrisWheel:AU,Figma:EU,File:g5,FileArchive:PU,FileAudio:LU,FileAudio2:IU,FileAxis3d:x2,FileBadge:OU,FileBadge2:DU,FileBox:RU,FileChartColumn:v2,FileChartColumnIncreasing:y2,FileChartLine:_2,FileChartPie:b2,FileCheck:zU,FileCheck2:FU,FileClock:BU,FileCode:qU,FileCode2:$U,FileCog:w2,FileDiff:UU,FileDigit:VU,FileDown:HU,FileHeart:WU,FileImage:i_,FileInput:GU,FileJson:ZU,FileJson2:KU,FileKey:XU,FileKey2:YU,FileLock:JU,FileLock2:QU,FileMinus:tV,FileMinus2:eV,FileMusic:sV,FileOutput:rV,FilePen:N2,FilePenLine:j2,FilePlus:aV,FilePlus2:nV,FileQuestion:iV,FileScan:oV,FileSearch:cV,FileSearch2:lV,FileSliders:dV,FileSpreadsheet:I0,FileStack:mP,FileSymlink:uV,FileTerminal:hV,FileText:In,FileType:pV,FileType2:mV,FileUp:fV,FileUser:gV,FileVideo:yV,FileVideo2:xV,FileVolume:_V,FileVolume2:vV,FileWarning:bV,FileX:jV,FileX2:wV,Files:NV,Film:lu,Filter:Yx,FilterX:kV,Fingerprint:SV,FireExtinguisher:CV,Fish:AV,FishOff:MV,FishSymbol:TV,Flag:L0,FlagOff:EV,FlagTriangleLeft:PV,FlagTriangleRight:IV,Flame:nh,FlameKindling:LV,Flashlight:OV,FlashlightOff:DV,FlaskConical:o_,FlaskConicalOff:RV,FlaskRound:FV,FlipHorizontal:BV,FlipHorizontal2:zV,FlipVertical:qV,FlipVertical2:$V,Flower:UV,Flower2:Og,Focus:VV,FoldHorizontal:HV,FoldVertical:WV,Folder:vH,FolderArchive:GV,FolderCheck:KV,FolderClock:ZV,FolderClosed:YV,FolderCode:XV,FolderCog:k2,FolderDot:QV,FolderDown:JV,FolderGit:tH,FolderGit2:eH,FolderHeart:sH,FolderInput:rH,FolderKanban:nH,FolderKey:aH,FolderLock:iH,FolderMinus:oH,FolderOpen:Vh,FolderOpenDot:lH,FolderOutput:cH,FolderPen:S2,FolderPlus:dH,FolderRoot:uH,FolderSearch:mH,FolderSearch2:hH,FolderSymlink:pH,FolderSync:fH,FolderTree:gH,FolderUp:xH,FolderX:yH,Folders:_H,Footprints:bH,Forklift:wH,Forward:jH,Frame:NH,Framer:kH,Frown:SH,Fuel:CH,Fullscreen:MH,GalleryHorizontal:AH,GalleryHorizontalEnd:TH,GalleryThumbnails:EH,GalleryVertical:IH,GalleryVerticalEnd:PH,Gamepad:DH,Gamepad2:LH,Gauge:OH,Gavel:RH,Gem:FH,Ghost:lk,Gift:po,GitBranch:BH,GitBranchPlus:zH,GitCommitHorizontal:C2,GitCommitVertical:$H,GitCompare:UH,GitCompareArrows:qH,GitFork:VH,GitGraph:HH,GitMerge:WH,GitPullRequest:QH,GitPullRequestArrow:GH,GitPullRequestClosed:KH,GitPullRequestCreate:YH,GitPullRequestCreateArrow:ZH,GitPullRequestDraft:XH,Github:JH,Gitlab:eW,GlassWater:tW,Glasses:sW,Globe:Lm,GlobeLock:rW,Goal:nW,Grab:aW,GraduationCap:ah,Grape:iW,Grid2x2:T2,Grid2x2Check:oW,Grid2x2Plus:M2,Grid2x2X:lW,Grid3x3:Yp,Grip:dW,GripHorizontal:cW,GripVertical:Bu,Group:uW,Guitar:hW,Ham:mW,Hammer:pW,Hand:pP,HandCoins:fW,HandHeart:gW,HandHelping:A2,HandMetal:xW,HandPlatter:yW,Handshake:fP,HardDrive:gP,HardDriveDownload:vW,HardDriveUpload:_W,HardHat:bW,Hash:x5,Haze:wW,HdmiPort:jW,Heading:MW,Heading1:xP,Heading2:yP,Heading3:NW,Heading4:kW,Heading5:SW,Heading6:CW,HeadphoneOff:TW,Headphones:AW,Headset:EW,Heart:Si,HeartCrack:PW,HeartHandshake:IW,HeartOff:LW,HeartPulse:DW,Heater:OW,Hexagon:RW,Highlighter:FW,History:y5,Hop:BW,HopOff:zW,Hospital:$W,Hotel:qW,Hourglass:UW,House:On,HousePlug:VW,HousePlus:HW,IceCreamBowl:E2,IceCreamCone:P2,IdCard:WW,Image:Jo,ImageDown:GW,ImageMinus:KW,ImageOff:ZW,ImagePlay:YW,ImagePlus:D0,ImageUp:XW,ImageUpscale:QW,Images:JW,Import:eG,Inbox:tG,IndentDecrease:I2,IndentIncrease:L2,IndianRupee:sG,Infinity:rG,Info:vP,InspectionPanel:nG,Instagram:Wd,Italic:v5,IterationCcw:aG,IterationCw:iG,JapaneseYen:oG,Joystick:lG,Kanban:Xx,Key:Dm,KeyRound:ck,KeySquare:cG,Keyboard:hG,KeyboardMusic:dG,KeyboardOff:uG,Lamp:yG,LampCeiling:mG,LampDesk:pG,LampFloor:fG,LampWallDown:gG,LampWallUp:xG,LandPlot:vG,Landmark:_G,Languages:bG,Laptop:jG,LaptopMinimal:D2,LaptopMinimalCheck:wG,Lasso:kG,LassoSelect:NG,Laugh:SG,Layers:TG,Layers2:CG,Layers3:MG,LayoutDashboard:dk,LayoutGrid:yp,LayoutList:AG,LayoutPanelLeft:EG,LayoutPanelTop:PG,LayoutTemplate:uk,Leaf:IG,LeafyGreen:LG,Lectern:DG,LetterText:OG,Library:_5,LibraryBig:RG,LifeBuoy:b5,Ligature:FG,Lightbulb:l_,LightbulbOff:zG,Link:Do,Link2:Wo,Link2Off:BG,Linkedin:Om,List:Hh,ListCheck:$G,ListChecks:qG,ListCollapse:UG,ListEnd:VG,ListFilter:HG,ListMinus:WG,ListMusic:GG,ListOrdered:O0,ListPlus:KG,ListRestart:ZG,ListStart:YG,ListTodo:XG,ListTree:QG,ListVideo:JG,ListX:eK,Loader:sK,LoaderCircle:Ms,LoaderPinwheel:tK,Locate:aK,LocateFixed:rK,LocateOff:nK,Lock:$u,LockKeyhole:iK,LockKeyholeOpen:O2,LockOpen:R2,LogIn:w5,LogOut:j5,Logs:oK,Lollipop:lK,Luggage:cK,Magnet:dK,Mail:br,MailCheck:uK,MailMinus:hK,MailOpen:mK,MailPlus:pK,MailQuestion:fK,MailSearch:gK,MailWarning:xK,MailX:_P,Mailbox:yK,Mails:vK,Map:EK,MapPin:Oi,MapPinCheck:bK,MapPinCheckInside:_K,MapPinHouse:wK,MapPinMinus:NK,MapPinMinusInside:jK,MapPinOff:kK,MapPinPlus:CK,MapPinPlusInside:SK,MapPinX:TK,MapPinXInside:MK,MapPinned:AK,Martini:PK,Maximize:bP,Maximize2:IK,Medal:R0,Megaphone:Rm,MegaphoneOff:LK,Meh:DK,MemoryStick:OK,Menu:wP,Merge:RK,MessageCircle:xc,MessageCircleCode:FK,MessageCircleDashed:zK,MessageCircleHeart:N5,MessageCircleMore:BK,MessageCircleOff:$K,MessageCirclePlus:qK,MessageCircleQuestion:jP,MessageCircleReply:UK,MessageCircleWarning:VK,MessageCircleX:HK,MessageSquare:io,MessageSquareCode:WK,MessageSquareDashed:GK,MessageSquareDiff:KK,MessageSquareDot:ZK,MessageSquareHeart:YK,MessageSquareLock:XK,MessageSquareMore:NP,MessageSquareOff:QK,MessageSquarePlus:k5,MessageSquareQuote:kP,MessageSquareReply:JK,MessageSquareShare:eZ,MessageSquareText:tZ,MessageSquareWarning:sZ,MessageSquareX:rZ,MessagesSquare:nZ,Mic:SP,MicOff:aZ,MicVocal:F2,Microchip:iZ,Microscope:oZ,Microwave:lZ,Milestone:cZ,Milk:uZ,MilkOff:dZ,Minimize:mZ,Minimize2:hZ,Minus:F0,Monitor:hk,MonitorCheck:pZ,MonitorCog:fZ,MonitorDot:gZ,MonitorDown:xZ,MonitorOff:yZ,MonitorPause:vZ,MonitorPlay:_Z,MonitorSmartphone:bZ,MonitorSpeaker:wZ,MonitorStop:jZ,MonitorUp:NZ,MonitorX:kZ,Moon:CZ,MoonStar:SZ,Mountain:TZ,MountainSnow:MZ,Mouse:IZ,MouseOff:AZ,MousePointer:th,MousePointer2:EZ,MousePointerBan:PZ,MousePointerClick:c_,Move:WZ,Move3d:z2,MoveDiagonal:DZ,MoveDiagonal2:LZ,MoveDown:FZ,MoveDownLeft:OZ,MoveDownRight:RZ,MoveHorizontal:zZ,MoveLeft:BZ,MoveRight:$Z,MoveUp:VZ,MoveUpLeft:qZ,MoveUpRight:UZ,MoveVertical:HZ,Music:YZ,Music2:GZ,Music3:KZ,Music4:ZZ,Navigation:eY,Navigation2:QZ,Navigation2Off:XZ,NavigationOff:JZ,Network:tY,Newspaper:z0,Nfc:sY,Notebook:iY,NotebookPen:rY,NotebookTabs:nY,NotebookText:aY,NotepadText:lY,NotepadTextDashed:oY,Nut:dY,NutOff:cY,Octagon:hY,OctagonAlert:m0,OctagonMinus:uY,OctagonPause:B2,OctagonX:$2,Omega:mY,Option:pY,Orbit:fY,Origami:gY,Package:dl,Package2:xY,PackageCheck:yY,PackageMinus:vY,PackageOpen:_Y,PackagePlus:bY,PackageSearch:wY,PackageX:jY,PaintBucket:NY,PaintRoller:kY,Paintbrush:SY,PaintbrushVertical:q2,Palette:Bl,PanelBottom:TY,PanelBottomClose:CY,PanelBottomDashed:U2,PanelBottomOpen:MY,PanelLeft:G2,PanelLeftClose:V2,PanelLeftDashed:H2,PanelLeftOpen:W2,PanelRight:PY,PanelRightClose:AY,PanelRightDashed:K2,PanelRightOpen:EY,PanelTop:DY,PanelTopClose:IY,PanelTopDashed:Z2,PanelTopOpen:LY,PanelsLeftBottom:OY,PanelsRightBottom:RY,PanelsTopLeft:p0,Paperclip:mk,Parentheses:FY,ParkingMeter:zY,PartyPopper:kd,Pause:vp,PawPrint:BY,PcCase:$Y,Pen:Fx,PenLine:f0,PenOff:qY,PenTool:d_,Pencil:Da,PencilLine:UY,PencilOff:VY,PencilRuler:HY,Pentagon:WY,Percent:S5,PersonStanding:GY,PhilippinePeso:KY,Phone:Qn,PhoneCall:ZY,PhoneForwarded:YY,PhoneIncoming:XY,PhoneMissed:QY,PhoneOff:JY,PhoneOutgoing:eX,Pi:tX,Piano:sX,Pickaxe:rX,PictureInPicture:aX,PictureInPicture2:nX,PiggyBank:iX,Pilcrow:cX,PilcrowLeft:oX,PilcrowRight:lX,Pill:uX,PillBottle:dX,Pin:u_,PinOff:CP,Pipette:hX,Pizza:mX,Plane:gX,PlaneLanding:pX,PlaneTakeoff:fX,Play:ul,Plug:MP,Plug2:xX,PlugZap:Y2,Plus:Zs,Pocket:vX,PocketKnife:yX,Podcast:_X,Pointer:wX,PointerOff:bX,Popcorn:jX,Popsicle:NX,PoundSterling:kX,Power:TP,PowerOff:SX,Presentation:Hg,Printer:AP,PrinterCheck:CX,Projector:MX,Proportions:TX,Puzzle:AX,Pyramid:EX,QrCode:B0,Quote:C5,Rabbit:PX,Radar:IX,Radiation:LX,Radical:DX,Radio:$0,RadioReceiver:OX,RadioTower:RX,Radius:FX,RailSymbol:zX,Rainbow:BX,Rat:$X,Ratio:qX,Receipt:XX,ReceiptCent:UX,ReceiptEuro:VX,ReceiptIndianRupee:HX,ReceiptJapaneseYen:WX,ReceiptPoundSterling:GX,ReceiptRussianRuble:KX,ReceiptSwissFranc:ZX,ReceiptText:YX,RectangleEllipsis:X2,RectangleHorizontal:QX,RectangleVertical:JX,Recycle:eQ,Redo:M5,Redo2:tQ,RedoDot:sQ,RefreshCcw:nQ,RefreshCcwDot:rQ,RefreshCw:Po,RefreshCwOff:aQ,Refrigerator:iQ,Regex:oQ,RemoveFormatting:lQ,Repeat:EP,Repeat1:cQ,Repeat2:dQ,Replace:hQ,ReplaceAll:uQ,Reply:PP,ReplyAll:mQ,Rewind:pQ,Ribbon:fQ,Rocket:Qx,RockingChair:gQ,RollerCoaster:xQ,Rotate3d:Q2,RotateCcw:q0,RotateCcwSquare:yQ,RotateCw:IP,RotateCwSquare:vQ,Route:bQ,RouteOff:_Q,Router:wQ,Rows2:J2,Rows3:ej,Rows4:jQ,Rss:NQ,Ruler:LP,RussianRuble:kQ,Sailboat:SQ,Salad:CQ,Sandwich:MQ,Satellite:AQ,SatelliteDish:TQ,Save:fu,SaveAll:EQ,SaveOff:PQ,Scale:DP,Scale3d:tj,Scaling:IQ,Scan:$Q,ScanBarcode:LQ,ScanEye:DQ,ScanFace:OQ,ScanLine:RQ,ScanQrCode:FQ,ScanSearch:zQ,ScanText:BQ,School:qQ,Scissors:VQ,ScissorsLineDashed:UQ,ScreenShare:WQ,ScreenShareOff:HQ,Scroll:KQ,ScrollText:GQ,Search:gn,SearchCheck:ZQ,SearchCode:YQ,SearchSlash:XQ,SearchX:OP,Section:QQ,Send:aa,SendHorizontal:sj,SendToBack:JQ,SeparatorHorizontal:eJ,SeparatorVertical:tJ,Server:aJ,ServerCog:sJ,ServerCrash:rJ,ServerOff:nJ,Settings:$l,Settings2:RP,Shapes:iJ,Share:FP,Share2:ld,Sheet:oJ,Shell:lJ,Shield:ih,ShieldAlert:cJ,ShieldBan:dJ,ShieldCheck:zP,ShieldEllipsis:uJ,ShieldHalf:hJ,ShieldMinus:mJ,ShieldOff:pJ,ShieldPlus:fJ,ShieldQuestion:gJ,ShieldX:rj,Ship:yJ,ShipWheel:xJ,Shirt:vJ,ShoppingBag:Jx,ShoppingBasket:_J,ShoppingCart:Sm,Shovel:bJ,ShowerHead:wJ,Shrink:jJ,Shrub:NJ,Shuffle:pk,Sigma:kJ,Signal:AJ,SignalHigh:SJ,SignalLow:CJ,SignalMedium:MJ,SignalZero:TJ,Signature:EJ,Signpost:IJ,SignpostBig:PJ,Siren:LJ,SkipBack:DJ,SkipForward:OJ,Skull:RJ,Slack:FJ,Slash:zJ,Slice:BJ,SlidersHorizontal:BP,SlidersVertical:nj,Smartphone:U0,SmartphoneCharging:$J,SmartphoneNfc:qJ,Smile:VJ,SmilePlus:UJ,Snail:HJ,Snowflake:$1,Sofa:WJ,Soup:GJ,Space:KJ,Spade:ZJ,Sparkle:YJ,Sparkles:hn,Speaker:XJ,Speech:QJ,SpellCheck:eee,SpellCheck2:JJ,Spline:tee,Split:see,SprayCan:ree,Sprout:nee,Square:ey,SquareActivity:aj,SquareArrowDown:lj,SquareArrowDownLeft:ij,SquareArrowDownRight:oj,SquareArrowLeft:cj,SquareArrowOutDownLeft:dj,SquareArrowOutDownRight:uj,SquareArrowOutUpLeft:hj,SquareArrowOutUpRight:mj,SquareArrowRight:pj,SquareArrowUp:xj,SquareArrowUpLeft:fj,SquareArrowUpRight:gj,SquareAsterisk:yj,SquareBottomDashedScissors:vj,SquareChartGantt:Mx,SquareCheck:_j,SquareCheckBig:g0,SquareChevronDown:bj,SquareChevronLeft:wj,SquareChevronRight:jj,SquareChevronUp:Nj,SquareCode:kj,SquareDashed:Mj,SquareDashedBottom:iee,SquareDashedBottomCode:aee,SquareDashedKanban:Sj,SquareDashedMousePointer:Cj,SquareDivide:Tj,SquareDot:Aj,SquareEqual:Ej,SquareFunction:Pj,SquareKanban:Ij,SquareLibrary:Lj,SquareM:Dj,SquareMenu:Oj,SquareMinus:Rj,SquareMousePointer:Fj,SquareParking:Bj,SquareParkingOff:zj,SquarePen:Rc,SquarePercent:$j,SquarePi:qj,SquarePilcrow:Uj,SquarePlay:Vj,SquarePlus:Hj,SquarePower:Wj,SquareRadical:oee,SquareScissors:Gj,SquareSigma:Kj,SquareSlash:Zj,SquareSplitHorizontal:Yj,SquareSplitVertical:Xj,SquareSquare:lee,SquareStack:cee,SquareTerminal:Qj,SquareUser:eN,SquareUserRound:Jj,SquareX:tN,Squircle:dee,Squirrel:uee,Stamp:hee,Star:Gn,StarHalf:mee,StarOff:pee,StepBack:fee,StepForward:gee,Stethoscope:xee,Sticker:yee,StickyNote:vee,Store:_ee,StretchHorizontal:bee,StretchVertical:wee,Strikethrough:jee,Subscript:Nee,Sun:h_,SunDim:kee,SunMedium:See,SunMoon:Cee,SunSnow:Mee,Sunrise:Tee,Sunset:Aee,Superscript:Eee,SwatchBook:Pee,SwissFranc:Iee,SwitchCamera:Lee,Sword:Dee,Swords:Oee,Syringe:Ree,Table:$P,Table2:T5,TableCellsMerge:Fee,TableCellsSplit:zee,TableColumnsSplit:Bee,TableOfContents:$ee,TableProperties:qee,TableRowsSplit:Uee,Tablet:Hee,TabletSmartphone:Vee,Tablets:Wee,Tag:Wh,Tags:Gee,Tally1:Kee,Tally2:Zee,Tally3:Yee,Tally4:Xee,Tally5:Qee,Tangent:Jee,Target:Gh,Telescope:ete,Tent:ste,TentTree:tte,Terminal:rte,TestTube:nte,TestTubeDiagonal:sN,TestTubes:ate,Text:dte,TextCursor:ote,TextCursorInput:ite,TextQuote:lte,TextSearch:cte,TextSelect:rN,Theater:ute,Thermometer:pte,ThermometerSnowflake:hte,ThermometerSun:mte,ThumbsDown:qP,ThumbsUp:gu,Ticket:UP,TicketCheck:fte,TicketMinus:gte,TicketPercent:xte,TicketPlus:yte,TicketSlash:vte,TicketX:_te,Tickets:wte,TicketsPlane:bte,Timer:kte,TimerOff:jte,TimerReset:Nte,ToggleLeft:Ste,ToggleRight:Cte,Toilet:Mte,Tornado:Tte,Torus:Ate,Touchpad:Pte,TouchpadOff:Ete,TowerControl:Ite,ToyBrick:Lte,Tractor:Dte,TrafficCone:Ote,TrainFront:Fte,TrainFrontTunnel:Rte,TrainTrack:zte,TramFront:nN,Trash:Bte,Trash2:jr,TreeDeciduous:$te,TreePalm:aN,TreePine:m_,Trees:qte,Trello:Ute,TrendingDown:fk,TrendingUp:ac,TrendingUpDown:Vte,Triangle:Wte,TriangleAlert:Ju,TriangleRight:Hte,Trophy:ao,Truck:VP,Turtle:Gte,Tv:Zte,TvMinimal:iN,TvMinimalPlay:Kte,Twitch:Yte,Twitter:Xte,Type:Jte,TypeOutline:Qte,Umbrella:tse,UmbrellaOff:ese,Underline:sse,Undo:A5,Undo2:rse,UndoDot:nse,UnfoldHorizontal:ase,UnfoldVertical:ise,Ungroup:ose,University:oN,Unlink:gk,Unlink2:lse,Unplug:cse,Upload:Za,Usb:dse,User:Yi,UserCheck:p_,UserCog:HP,UserMinus:WP,UserPen:use,UserPlus:yc,UserRound:mN,UserRoundCheck:lN,UserRoundCog:cN,UserRoundMinus:dN,UserRoundPen:hse,UserRoundPlus:uN,UserRoundSearch:mse,UserRoundX:hN,UserSearch:pse,UserX:fse,Users:hr,UsersRound:pN,Utensils:gN,UtensilsCrossed:fN,UtilityPole:gse,Variable:GP,Vault:xse,Vegan:yse,VenetianMask:vse,Vibrate:bse,VibrateOff:_se,Video:Nn,VideoOff:wse,Videotape:jse,View:Nse,Voicemail:kse,Volleyball:Sse,Volume:Ese,Volume1:Cse,Volume2:Mse,VolumeOff:Tse,VolumeX:Ase,Vote:Pse,Wallet:KP,WalletCards:Ise,WalletMinimal:xN,Wallpaper:Lse,Wand:Dse,WandSparkles:x0,Warehouse:Ose,WashingMachine:Rse,Watch:Fse,Waves:zse,Waypoints:Bse,Webcam:$se,Webhook:Use,WebhookOff:qse,Weight:Vse,Wheat:Wse,WheatOff:Hse,WholeWord:Gse,Wifi:Qse,WifiHigh:Kse,WifiLow:Zse,WifiOff:Yse,WifiZero:Xse,Wind:ere,WindArrowDown:Jse,Wine:sre,WineOff:tre,Workflow:rre,Worm:nre,WrapText:are,Wrench:Wg,X:Ur,Youtube:ire,Zap:Fm,ZapOff:ore,ZoomIn:f_,ZoomOut:E5},Symbol.toStringTag,{value:"Module"}));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c1e=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:aF,AArrowDownIcon:aF,AArrowUp:iF,AArrowUpIcon:iF,ALargeSmall:oF,ALargeSmallIcon:oF,Accessibility:lF,AccessibilityIcon:lF,Activity:Pm,ActivityIcon:Pm,ActivitySquare:aj,ActivitySquareIcon:aj,AirVent:cF,AirVentIcon:cF,Airplay:dF,AirplayIcon:dF,AlarmCheck:lw,AlarmCheckIcon:lw,AlarmClock:hF,AlarmClockCheck:lw,AlarmClockCheckIcon:lw,AlarmClockIcon:hF,AlarmClockMinus:cw,AlarmClockMinusIcon:cw,AlarmClockOff:uF,AlarmClockOffIcon:uF,AlarmClockPlus:dw,AlarmClockPlusIcon:dw,AlarmMinus:cw,AlarmMinusIcon:cw,AlarmPlus:dw,AlarmPlusIcon:dw,AlarmSmoke:mF,AlarmSmokeIcon:mF,Album:pF,AlbumIcon:pF,AlertCircle:ll,AlertCircleIcon:ll,AlertOctagon:m0,AlertOctagonIcon:m0,AlertTriangle:Ju,AlertTriangleIcon:Ju,AlignCenter:l5,AlignCenterHorizontal:fF,AlignCenterHorizontalIcon:fF,AlignCenterIcon:l5,AlignCenterVertical:gF,AlignCenterVerticalIcon:gF,AlignEndHorizontal:xF,AlignEndHorizontalIcon:xF,AlignEndVertical:yF,AlignEndVerticalIcon:yF,AlignHorizontalDistributeCenter:vF,AlignHorizontalDistributeCenterIcon:vF,AlignHorizontalDistributeEnd:_F,AlignHorizontalDistributeEndIcon:_F,AlignHorizontalDistributeStart:bF,AlignHorizontalDistributeStartIcon:bF,AlignHorizontalJustifyCenter:wF,AlignHorizontalJustifyCenterIcon:wF,AlignHorizontalJustifyEnd:jF,AlignHorizontalJustifyEndIcon:jF,AlignHorizontalJustifyStart:NF,AlignHorizontalJustifyStartIcon:NF,AlignHorizontalSpaceAround:kF,AlignHorizontalSpaceAroundIcon:kF,AlignHorizontalSpaceBetween:SF,AlignHorizontalSpaceBetweenIcon:SF,AlignJustify:CF,AlignJustifyIcon:CF,AlignLeft:c5,AlignLeftIcon:c5,AlignRight:d5,AlignRightIcon:d5,AlignStartHorizontal:MF,AlignStartHorizontalIcon:MF,AlignStartVertical:TF,AlignStartVerticalIcon:TF,AlignVerticalDistributeCenter:AF,AlignVerticalDistributeCenterIcon:AF,AlignVerticalDistributeEnd:EF,AlignVerticalDistributeEndIcon:EF,AlignVerticalDistributeStart:PF,AlignVerticalDistributeStartIcon:PF,AlignVerticalJustifyCenter:IF,AlignVerticalJustifyCenterIcon:IF,AlignVerticalJustifyEnd:LF,AlignVerticalJustifyEndIcon:LF,AlignVerticalJustifyStart:DF,AlignVerticalJustifyStartIcon:DF,AlignVerticalSpaceAround:OF,AlignVerticalSpaceAroundIcon:OF,AlignVerticalSpaceBetween:RF,AlignVerticalSpaceBetweenIcon:RF,Ambulance:FF,AmbulanceIcon:FF,Ampersand:zF,AmpersandIcon:zF,Ampersands:BF,AmpersandsIcon:BF,Amphora:$F,AmphoraIcon:$F,Anchor:qF,AnchorIcon:qF,Angry:UF,AngryIcon:UF,Annoyed:VF,AnnoyedIcon:VF,Antenna:HF,AntennaIcon:HF,Anvil:WF,AnvilIcon:WF,Aperture:GF,ApertureIcon:GF,AppWindow:sP,AppWindowIcon:sP,AppWindowMac:KF,AppWindowMacIcon:KF,Apple:ZF,AppleIcon:ZF,Archive:u5,ArchiveIcon:u5,ArchiveRestore:rP,ArchiveRestoreIcon:rP,ArchiveX:YF,ArchiveXIcon:YF,AreaChart:Nw,AreaChartIcon:Nw,Armchair:XF,ArmchairIcon:XF,ArrowBigDown:JF,ArrowBigDownDash:QF,ArrowBigDownDashIcon:QF,ArrowBigDownIcon:JF,ArrowBigLeft:tz,ArrowBigLeftDash:ez,ArrowBigLeftDashIcon:ez,ArrowBigLeftIcon:tz,ArrowBigRight:rz,ArrowBigRightDash:sz,ArrowBigRightDashIcon:sz,ArrowBigRightIcon:rz,ArrowBigUp:az,ArrowBigUpDash:nz,ArrowBigUpDashIcon:nz,ArrowBigUpIcon:az,ArrowDown:sh,ArrowDown01:iz,ArrowDown01Icon:iz,ArrowDown10:oz,ArrowDown10Icon:oz,ArrowDownAZ:uw,ArrowDownAZIcon:uw,ArrowDownAz:uw,ArrowDownAzIcon:uw,ArrowDownCircle:Ow,ArrowDownCircleIcon:Ow,ArrowDownFromLine:lz,ArrowDownFromLineIcon:lz,ArrowDownIcon:sh,ArrowDownLeft:cz,ArrowDownLeftFromCircle:Fw,ArrowDownLeftFromCircleIcon:Fw,ArrowDownLeftFromSquare:dj,ArrowDownLeftFromSquareIcon:dj,ArrowDownLeftIcon:cz,ArrowDownLeftSquare:ij,ArrowDownLeftSquareIcon:ij,ArrowDownNarrowWide:dz,ArrowDownNarrowWideIcon:dz,ArrowDownRight:nP,ArrowDownRightFromCircle:zw,ArrowDownRightFromCircleIcon:zw,ArrowDownRightFromSquare:uj,ArrowDownRightFromSquareIcon:uj,ArrowDownRightIcon:nP,ArrowDownRightSquare:oj,ArrowDownRightSquareIcon:oj,ArrowDownSquare:lj,ArrowDownSquareIcon:lj,ArrowDownToDot:uz,ArrowDownToDotIcon:uz,ArrowDownToLine:hz,ArrowDownToLineIcon:hz,ArrowDownUp:mz,ArrowDownUpIcon:mz,ArrowDownWideNarrow:hw,ArrowDownWideNarrowIcon:hw,ArrowDownZA:mw,ArrowDownZAIcon:mw,ArrowDownZa:mw,ArrowDownZaIcon:mw,ArrowLeft:ti,ArrowLeftCircle:Rw,ArrowLeftCircleIcon:Rw,ArrowLeftFromLine:pz,ArrowLeftFromLineIcon:pz,ArrowLeftIcon:ti,ArrowLeftRight:fz,ArrowLeftRightIcon:fz,ArrowLeftSquare:cj,ArrowLeftSquareIcon:cj,ArrowLeftToLine:gz,ArrowLeftToLineIcon:gz,ArrowRight:$i,ArrowRightCircle:qw,ArrowRightCircleIcon:qw,ArrowRightFromLine:xz,ArrowRightFromLineIcon:xz,ArrowRightIcon:$i,ArrowRightLeft:A0,ArrowRightLeftIcon:A0,ArrowRightSquare:pj,ArrowRightSquareIcon:pj,ArrowRightToLine:yz,ArrowRightToLineIcon:yz,ArrowUp:Vd,ArrowUp01:vz,ArrowUp01Icon:vz,ArrowUp10:_z,ArrowUp10Icon:_z,ArrowUpAZ:pw,ArrowUpAZIcon:pw,ArrowUpAz:pw,ArrowUpAzIcon:pw,ArrowUpCircle:Uw,ArrowUpCircleIcon:Uw,ArrowUpDown:Hc,ArrowUpDownIcon:Hc,ArrowUpFromDot:bz,ArrowUpFromDotIcon:bz,ArrowUpFromLine:wz,ArrowUpFromLineIcon:wz,ArrowUpIcon:Vd,ArrowUpLeft:jz,ArrowUpLeftFromCircle:Bw,ArrowUpLeftFromCircleIcon:Bw,ArrowUpLeftFromSquare:hj,ArrowUpLeftFromSquareIcon:hj,ArrowUpLeftIcon:jz,ArrowUpLeftSquare:fj,ArrowUpLeftSquareIcon:fj,ArrowUpNarrowWide:fw,ArrowUpNarrowWideIcon:fw,ArrowUpRight:aP,ArrowUpRightFromCircle:$w,ArrowUpRightFromCircleIcon:$w,ArrowUpRightFromSquare:mj,ArrowUpRightFromSquareIcon:mj,ArrowUpRightIcon:aP,ArrowUpRightSquare:gj,ArrowUpRightSquareIcon:gj,ArrowUpSquare:xj,ArrowUpSquareIcon:xj,ArrowUpToLine:Nz,ArrowUpToLineIcon:Nz,ArrowUpWideNarrow:kz,ArrowUpWideNarrowIcon:kz,ArrowUpZA:gw,ArrowUpZAIcon:gw,ArrowUpZa:gw,ArrowUpZaIcon:gw,ArrowsUpFromLine:Sz,ArrowsUpFromLineIcon:Sz,Asterisk:Cz,AsteriskIcon:Cz,AsteriskSquare:yj,AsteriskSquareIcon:yj,AtSign:Mz,AtSignIcon:Mz,Atom:Tz,AtomIcon:Tz,AudioLines:Az,AudioLinesIcon:Az,AudioWaveform:Ez,AudioWaveformIcon:Ez,Award:rc,AwardIcon:rc,Axe:Pz,AxeIcon:Pz,Axis3D:xw,Axis3DIcon:xw,Axis3d:xw,Axis3dIcon:xw,Baby:Iz,BabyIcon:Iz,Backpack:Lz,BackpackIcon:Lz,Badge:Yz,BadgeAlert:Dz,BadgeAlertIcon:Dz,BadgeCent:Oz,BadgeCentIcon:Oz,BadgeCheck:yw,BadgeCheckIcon:yw,BadgeDollarSign:Rz,BadgeDollarSignIcon:Rz,BadgeEuro:Fz,BadgeEuroIcon:Fz,BadgeHelp:zz,BadgeHelpIcon:zz,BadgeIcon:Yz,BadgeIndianRupee:Bz,BadgeIndianRupeeIcon:Bz,BadgeInfo:$z,BadgeInfoIcon:$z,BadgeJapaneseYen:qz,BadgeJapaneseYenIcon:qz,BadgeMinus:Uz,BadgeMinusIcon:Uz,BadgePercent:Vz,BadgePercentIcon:Vz,BadgePlus:Hz,BadgePlusIcon:Hz,BadgePoundSterling:Wz,BadgePoundSterlingIcon:Wz,BadgeRussianRuble:Gz,BadgeRussianRubleIcon:Gz,BadgeSwissFranc:Kz,BadgeSwissFrancIcon:Kz,BadgeX:Zz,BadgeXIcon:Zz,BaggageClaim:Xz,BaggageClaimIcon:Xz,Ban:Qz,BanIcon:Qz,Banana:Jz,BananaIcon:Jz,Bandage:e7,BandageIcon:e7,Banknote:t7,BanknoteIcon:t7,BarChart:Ew,BarChart2:Pw,BarChart2Icon:Pw,BarChart3:ol,BarChart3Icon:ol,BarChart4:Tw,BarChart4Icon:Tw,BarChartBig:Mw,BarChartBigIcon:Mw,BarChartHorizontal:Sw,BarChartHorizontalBig:kw,BarChartHorizontalBigIcon:kw,BarChartHorizontalIcon:Sw,BarChartIcon:Ew,Barcode:s7,BarcodeIcon:s7,Baseline:r7,BaselineIcon:r7,Bath:Zx,BathIcon:Zx,Battery:c7,BatteryCharging:n7,BatteryChargingIcon:n7,BatteryFull:a7,BatteryFullIcon:a7,BatteryIcon:c7,BatteryLow:i7,BatteryLowIcon:i7,BatteryMedium:o7,BatteryMediumIcon:o7,BatteryWarning:l7,BatteryWarningIcon:l7,Beaker:d7,BeakerIcon:d7,Bean:h7,BeanIcon:h7,BeanOff:u7,BeanOffIcon:u7,Bed:E0,BedDouble:iP,BedDoubleIcon:iP,BedIcon:E0,BedSingle:m7,BedSingleIcon:m7,Beef:p7,BeefIcon:p7,Beer:g7,BeerIcon:g7,BeerOff:f7,BeerOffIcon:f7,Bell:gf,BellDot:x7,BellDotIcon:x7,BellElectric:y7,BellElectricIcon:y7,BellIcon:gf,BellMinus:v7,BellMinusIcon:v7,BellOff:r_,BellOffIcon:r_,BellPlus:_7,BellPlusIcon:_7,BellRing:b7,BellRingIcon:b7,BetweenHorizonalEnd:vw,BetweenHorizonalEndIcon:vw,BetweenHorizonalStart:_w,BetweenHorizonalStartIcon:_w,BetweenHorizontalEnd:vw,BetweenHorizontalEndIcon:vw,BetweenHorizontalStart:_w,BetweenHorizontalStartIcon:_w,BetweenVerticalEnd:w7,BetweenVerticalEndIcon:w7,BetweenVerticalStart:j7,BetweenVerticalStartIcon:j7,BicepsFlexed:N7,BicepsFlexedIcon:N7,Bike:k7,BikeIcon:k7,Binary:S7,BinaryIcon:S7,Binoculars:C7,BinocularsIcon:C7,Biohazard:M7,BiohazardIcon:M7,Bird:T7,BirdIcon:T7,Bitcoin:A7,BitcoinIcon:A7,Blend:E7,BlendIcon:E7,Blinds:P7,BlindsIcon:P7,Blocks:I7,BlocksIcon:I7,Bluetooth:R7,BluetoothConnected:L7,BluetoothConnectedIcon:L7,BluetoothIcon:R7,BluetoothOff:D7,BluetoothOffIcon:D7,BluetoothSearching:O7,BluetoothSearchingIcon:O7,Bold:h5,BoldIcon:h5,Bolt:F7,BoltIcon:F7,Bomb:z7,BombIcon:z7,Bone:B7,BoneIcon:B7,Book:lB,BookA:$7,BookAIcon:$7,BookAudio:q7,BookAudioIcon:q7,BookCheck:U7,BookCheckIcon:U7,BookCopy:V7,BookCopyIcon:V7,BookDashed:bw,BookDashedIcon:bw,BookDown:H7,BookDownIcon:H7,BookHeadphones:W7,BookHeadphonesIcon:W7,BookHeart:G7,BookHeartIcon:G7,BookIcon:lB,BookImage:K7,BookImageIcon:K7,BookKey:Z7,BookKeyIcon:Z7,BookLock:Y7,BookLockIcon:Y7,BookMarked:X7,BookMarkedIcon:X7,BookMinus:Q7,BookMinusIcon:Q7,BookOpen:Fu,BookOpenCheck:J7,BookOpenCheckIcon:J7,BookOpenIcon:Fu,BookOpenText:eB,BookOpenTextIcon:eB,BookPlus:tB,BookPlusIcon:tB,BookTemplate:bw,BookTemplateIcon:bw,BookText:sB,BookTextIcon:sB,BookType:rB,BookTypeIcon:rB,BookUp:aB,BookUp2:nB,BookUp2Icon:nB,BookUpIcon:aB,BookUser:iB,BookUserIcon:iB,BookX:oB,BookXIcon:oB,Bookmark:$g,BookmarkCheck:cB,BookmarkCheckIcon:cB,BookmarkIcon:$g,BookmarkMinus:dB,BookmarkMinusIcon:dB,BookmarkPlus:oP,BookmarkPlusIcon:oP,BookmarkX:uB,BookmarkXIcon:uB,BoomBox:hB,BoomBoxIcon:hB,Bot:m5,BotIcon:m5,BotMessageSquare:mB,BotMessageSquareIcon:mB,BotOff:pB,BotOffIcon:pB,Box:fB,BoxIcon:fB,BoxSelect:Mj,BoxSelectIcon:Mj,Boxes:gB,BoxesIcon:gB,Braces:ww,BracesIcon:ww,Brackets:xB,BracketsIcon:xB,Brain:lP,BrainCircuit:yB,BrainCircuitIcon:yB,BrainCog:vB,BrainCogIcon:vB,BrainIcon:lP,BrickWall:_B,BrickWallIcon:_B,Briefcase:rh,BriefcaseBusiness:bB,BriefcaseBusinessIcon:bB,BriefcaseConveyorBelt:wB,BriefcaseConveyorBeltIcon:wB,BriefcaseIcon:rh,BriefcaseMedical:jB,BriefcaseMedicalIcon:jB,BringToFront:NB,BringToFrontIcon:NB,Brush:kB,BrushIcon:kB,Bug:MB,BugIcon:MB,BugOff:SB,BugOffIcon:SB,BugPlay:CB,BugPlayIcon:CB,Building:nk,Building2:Ta,Building2Icon:Ta,BuildingIcon:nk,Bus:AB,BusFront:TB,BusFrontIcon:TB,BusIcon:AB,Cable:PB,CableCar:EB,CableCarIcon:EB,CableIcon:PB,Cake:zu,CakeIcon:zu,CakeSlice:IB,CakeSliceIcon:IB,Calculator:LB,CalculatorIcon:LB,Calendar:on,Calendar1:DB,Calendar1Icon:DB,CalendarArrowDown:OB,CalendarArrowDownIcon:OB,CalendarArrowUp:RB,CalendarArrowUpIcon:RB,CalendarCheck:cP,CalendarCheck2:FB,CalendarCheck2Icon:FB,CalendarCheckIcon:cP,CalendarClock:dP,CalendarClockIcon:dP,CalendarCog:zB,CalendarCogIcon:zB,CalendarDays:id,CalendarDaysIcon:id,CalendarFold:BB,CalendarFoldIcon:BB,CalendarHeart:$B,CalendarHeartIcon:$B,CalendarIcon:on,CalendarMinus:UB,CalendarMinus2:qB,CalendarMinus2Icon:qB,CalendarMinusIcon:UB,CalendarOff:uP,CalendarOffIcon:uP,CalendarPlus:n_,CalendarPlus2:VB,CalendarPlus2Icon:VB,CalendarPlusIcon:n_,CalendarRange:HB,CalendarRangeIcon:HB,CalendarSearch:WB,CalendarSearchIcon:WB,CalendarSync:GB,CalendarSyncIcon:GB,CalendarX:ZB,CalendarX2:KB,CalendarX2Icon:KB,CalendarXIcon:ZB,Camera:qg,CameraIcon:qg,CameraOff:YB,CameraOffIcon:YB,CandlestickChart:Cw,CandlestickChartIcon:Cw,Candy:JB,CandyCane:XB,CandyCaneIcon:XB,CandyIcon:JB,CandyOff:QB,CandyOffIcon:QB,Cannabis:e9,CannabisIcon:e9,Captions:jw,CaptionsIcon:jw,CaptionsOff:t9,CaptionsOffIcon:t9,Car:n9,CarFront:s9,CarFrontIcon:s9,CarIcon:n9,CarTaxiFront:r9,CarTaxiFrontIcon:r9,Caravan:a9,CaravanIcon:a9,Carrot:i9,CarrotIcon:i9,CaseLower:o9,CaseLowerIcon:o9,CaseSensitive:l9,CaseSensitiveIcon:l9,CaseUpper:c9,CaseUpperIcon:c9,CassetteTape:d9,CassetteTapeIcon:d9,Cast:u9,CastIcon:u9,Castle:h9,CastleIcon:h9,Cat:m9,CatIcon:m9,Cctv:p9,CctvIcon:p9,ChartArea:Nw,ChartAreaIcon:Nw,ChartBar:Sw,ChartBarBig:kw,ChartBarBigIcon:kw,ChartBarDecreasing:f9,ChartBarDecreasingIcon:f9,ChartBarIcon:Sw,ChartBarIncreasing:g9,ChartBarIncreasingIcon:g9,ChartBarStacked:x9,ChartBarStackedIcon:x9,ChartCandlestick:Cw,ChartCandlestickIcon:Cw,ChartColumn:ol,ChartColumnBig:Mw,ChartColumnBigIcon:Mw,ChartColumnDecreasing:y9,ChartColumnDecreasingIcon:y9,ChartColumnIcon:ol,ChartColumnIncreasing:Tw,ChartColumnIncreasingIcon:Tw,ChartColumnStacked:v9,ChartColumnStackedIcon:v9,ChartGantt:_9,ChartGanttIcon:_9,ChartLine:Aw,ChartLineIcon:Aw,ChartNetwork:b9,ChartNetworkIcon:b9,ChartNoAxesColumn:Pw,ChartNoAxesColumnDecreasing:w9,ChartNoAxesColumnDecreasingIcon:w9,ChartNoAxesColumnIcon:Pw,ChartNoAxesColumnIncreasing:Ew,ChartNoAxesColumnIncreasingIcon:Ew,ChartNoAxesCombined:j9,ChartNoAxesCombinedIcon:j9,ChartNoAxesGantt:Iw,ChartNoAxesGanttIcon:Iw,ChartPie:Lw,ChartPieIcon:Lw,ChartScatter:Dw,ChartScatterIcon:Dw,ChartSpline:N9,ChartSplineIcon:N9,Check:ha,CheckCheck:k9,CheckCheckIcon:k9,CheckCircle:hi,CheckCircle2:ua,CheckCircle2Icon:ua,CheckCircleIcon:hi,CheckIcon:ha,CheckSquare:g0,CheckSquare2:_j,CheckSquare2Icon:_j,CheckSquareIcon:g0,ChefHat:S9,ChefHatIcon:S9,Cherry:C9,CherryIcon:C9,ChevronDown:Ho,ChevronDownCircle:Vw,ChevronDownCircleIcon:Vw,ChevronDownIcon:Ho,ChevronDownSquare:bj,ChevronDownSquareIcon:bj,ChevronFirst:M9,ChevronFirstIcon:M9,ChevronLast:T9,ChevronLastIcon:T9,ChevronLeft:zl,ChevronLeftCircle:Hw,ChevronLeftCircleIcon:Hw,ChevronLeftIcon:zl,ChevronLeftSquare:wj,ChevronLeftSquareIcon:wj,ChevronRight:Ua,ChevronRightCircle:Ww,ChevronRightCircleIcon:Ww,ChevronRightIcon:Ua,ChevronRightSquare:jj,ChevronRightSquareIcon:jj,ChevronUp:Ug,ChevronUpCircle:Gw,ChevronUpCircleIcon:Gw,ChevronUpIcon:Ug,ChevronUpSquare:Nj,ChevronUpSquareIcon:Nj,ChevronsDown:E9,ChevronsDownIcon:E9,ChevronsDownUp:A9,ChevronsDownUpIcon:A9,ChevronsLeft:L9,ChevronsLeftIcon:L9,ChevronsLeftRight:I9,ChevronsLeftRightEllipsis:P9,ChevronsLeftRightEllipsisIcon:P9,ChevronsLeftRightIcon:I9,ChevronsRight:O9,ChevronsRightIcon:O9,ChevronsRightLeft:D9,ChevronsRightLeftIcon:D9,ChevronsUp:R9,ChevronsUpDown:xf,ChevronsUpDownIcon:xf,ChevronsUpIcon:R9,Chrome:F9,ChromeIcon:F9,Church:z9,ChurchIcon:z9,Cigarette:$9,CigaretteIcon:$9,CigaretteOff:B9,CigaretteOffIcon:B9,Circle:Kc,CircleAlert:ll,CircleAlertIcon:ll,CircleArrowDown:Ow,CircleArrowDownIcon:Ow,CircleArrowLeft:Rw,CircleArrowLeftIcon:Rw,CircleArrowOutDownLeft:Fw,CircleArrowOutDownLeftIcon:Fw,CircleArrowOutDownRight:zw,CircleArrowOutDownRightIcon:zw,CircleArrowOutUpLeft:Bw,CircleArrowOutUpLeftIcon:Bw,CircleArrowOutUpRight:$w,CircleArrowOutUpRightIcon:$w,CircleArrowRight:qw,CircleArrowRightIcon:qw,CircleArrowUp:Uw,CircleArrowUpIcon:Uw,CircleCheck:ua,CircleCheckBig:hi,CircleCheckBigIcon:hi,CircleCheckIcon:ua,CircleChevronDown:Vw,CircleChevronDownIcon:Vw,CircleChevronLeft:Hw,CircleChevronLeftIcon:Hw,CircleChevronRight:Ww,CircleChevronRightIcon:Ww,CircleChevronUp:Gw,CircleChevronUpIcon:Gw,CircleDashed:q9,CircleDashedIcon:q9,CircleDivide:Kw,CircleDivideIcon:Kw,CircleDollarSign:U9,CircleDollarSignIcon:U9,CircleDot:H9,CircleDotDashed:V9,CircleDotDashedIcon:V9,CircleDotIcon:H9,CircleEllipsis:W9,CircleEllipsisIcon:W9,CircleEqual:G9,CircleEqualIcon:G9,CircleFadingArrowUp:K9,CircleFadingArrowUpIcon:K9,CircleFadingPlus:Z9,CircleFadingPlusIcon:Z9,CircleGauge:Zw,CircleGaugeIcon:Zw,CircleHelp:h0,CircleHelpIcon:h0,CircleIcon:Kc,CircleMinus:Yw,CircleMinusIcon:Yw,CircleOff:Y9,CircleOffIcon:Y9,CircleParking:Qw,CircleParkingIcon:Qw,CircleParkingOff:Xw,CircleParkingOffIcon:Xw,CirclePause:Jw,CirclePauseIcon:Jw,CirclePercent:e2,CirclePercentIcon:e2,CirclePlay:bm,CirclePlayIcon:bm,CirclePlus:t2,CirclePlusIcon:t2,CirclePower:s2,CirclePowerIcon:s2,CircleSlash:X9,CircleSlash2:r2,CircleSlash2Icon:r2,CircleSlashIcon:X9,CircleSlashed:r2,CircleSlashedIcon:r2,CircleStop:n2,CircleStopIcon:n2,CircleUser:i2,CircleUserIcon:i2,CircleUserRound:a2,CircleUserRoundIcon:a2,CircleX:kc,CircleXIcon:kc,CircuitBoard:Q9,CircuitBoardIcon:Q9,Citrus:J9,CitrusIcon:J9,Clapperboard:e$,ClapperboardIcon:e$,Clipboard:o$,ClipboardCheck:p5,ClipboardCheckIcon:p5,ClipboardCopy:t$,ClipboardCopyIcon:t$,ClipboardEdit:l2,ClipboardEditIcon:l2,ClipboardIcon:o$,ClipboardList:a_,ClipboardListIcon:a_,ClipboardMinus:s$,ClipboardMinusIcon:s$,ClipboardPaste:r$,ClipboardPasteIcon:r$,ClipboardPen:l2,ClipboardPenIcon:l2,ClipboardPenLine:o2,ClipboardPenLineIcon:o2,ClipboardPlus:n$,ClipboardPlusIcon:n$,ClipboardSignature:o2,ClipboardSignatureIcon:o2,ClipboardType:a$,ClipboardTypeIcon:a$,ClipboardX:i$,ClipboardXIcon:i$,Clock:Tn,Clock1:l$,Clock10:c$,Clock10Icon:c$,Clock11:d$,Clock11Icon:d$,Clock12:u$,Clock12Icon:u$,Clock1Icon:l$,Clock2:h$,Clock2Icon:h$,Clock3:m$,Clock3Icon:m$,Clock4:p$,Clock4Icon:p$,Clock5:f$,Clock5Icon:f$,Clock6:g$,Clock6Icon:g$,Clock7:x$,Clock7Icon:x$,Clock8:y$,Clock8Icon:y$,Clock9:v$,Clock9Icon:v$,ClockAlert:_$,ClockAlertIcon:_$,ClockArrowDown:b$,ClockArrowDownIcon:b$,ClockArrowUp:w$,ClockArrowUpIcon:w$,ClockIcon:Tn,Cloud:R$,CloudAlert:j$,CloudAlertIcon:j$,CloudCog:N$,CloudCogIcon:N$,CloudDownload:c2,CloudDownloadIcon:c2,CloudDrizzle:k$,CloudDrizzleIcon:k$,CloudFog:S$,CloudFogIcon:S$,CloudHail:C$,CloudHailIcon:C$,CloudIcon:R$,CloudLightning:M$,CloudLightningIcon:M$,CloudMoon:A$,CloudMoonIcon:A$,CloudMoonRain:T$,CloudMoonRainIcon:T$,CloudOff:E$,CloudOffIcon:E$,CloudRain:I$,CloudRainIcon:I$,CloudRainWind:P$,CloudRainWindIcon:P$,CloudSnow:L$,CloudSnowIcon:L$,CloudSun:O$,CloudSunIcon:O$,CloudSunRain:D$,CloudSunRainIcon:D$,CloudUpload:d2,CloudUploadIcon:d2,Cloudy:F$,CloudyIcon:F$,Clover:N0,CloverIcon:N0,Club:z$,ClubIcon:z$,Code:ak,Code2:u2,Code2Icon:u2,CodeIcon:ak,CodeSquare:kj,CodeSquareIcon:kj,CodeXml:u2,CodeXmlIcon:u2,Codepen:B$,CodepenIcon:B$,Codesandbox:$$,CodesandboxIcon:$$,Coffee:ik,CoffeeIcon:ik,Cog:q$,CogIcon:q$,Coins:hP,CoinsIcon:hP,Columns:h2,Columns2:h2,Columns2Icon:h2,Columns3:m2,Columns3Icon:m2,Columns4:U$,Columns4Icon:U$,ColumnsIcon:h2,Combine:V$,CombineIcon:V$,Command:H$,CommandIcon:H$,Compass:W$,CompassIcon:W$,Component:G$,ComponentIcon:G$,Computer:K$,ComputerIcon:K$,ConciergeBell:Z$,ConciergeBellIcon:Z$,Cone:Y$,ConeIcon:Y$,Construction:X$,ConstructionIcon:X$,Contact:ok,Contact2:p2,Contact2Icon:p2,ContactIcon:ok,ContactRound:p2,ContactRoundIcon:p2,Container:Q$,ContainerIcon:Q$,Contrast:J$,ContrastIcon:J$,Cookie:eq,CookieIcon:eq,CookingPot:tq,CookingPotIcon:tq,Copy:ai,CopyCheck:sq,CopyCheckIcon:sq,CopyIcon:ai,CopyMinus:rq,CopyMinusIcon:rq,CopyPlus:nq,CopyPlusIcon:nq,CopySlash:aq,CopySlashIcon:aq,CopyX:iq,CopyXIcon:iq,Copyleft:oq,CopyleftIcon:oq,Copyright:lq,CopyrightIcon:lq,CornerDownLeft:cq,CornerDownLeftIcon:cq,CornerDownRight:dq,CornerDownRightIcon:dq,CornerLeftDown:uq,CornerLeftDownIcon:uq,CornerLeftUp:hq,CornerLeftUpIcon:hq,CornerRightDown:mq,CornerRightDownIcon:mq,CornerRightUp:pq,CornerRightUpIcon:pq,CornerUpLeft:fq,CornerUpLeftIcon:fq,CornerUpRight:gq,CornerUpRightIcon:gq,Cpu:xq,CpuIcon:xq,CreativeCommons:yq,CreativeCommonsIcon:yq,CreditCard:yf,CreditCardIcon:yf,Croissant:vq,CroissantIcon:vq,Crop:_q,CropIcon:_q,Cross:bq,CrossIcon:bq,Crosshair:wq,CrosshairIcon:wq,Crown:Uh,CrownIcon:Uh,Cuboid:jq,CuboidIcon:jq,CupSoda:Nq,CupSodaIcon:Nq,CurlyBraces:ww,CurlyBracesIcon:ww,Currency:kq,CurrencyIcon:kq,Cylinder:Sq,CylinderIcon:Sq,Dam:Cq,DamIcon:Cq,Database:Aq,DatabaseBackup:Mq,DatabaseBackupIcon:Mq,DatabaseIcon:Aq,DatabaseZap:Tq,DatabaseZapIcon:Tq,Delete:Eq,DeleteIcon:Eq,Dessert:Pq,DessertIcon:Pq,Diameter:Iq,DiameterIcon:Iq,Diamond:Oq,DiamondIcon:Oq,DiamondMinus:Lq,DiamondMinusIcon:Lq,DiamondPercent:f2,DiamondPercentIcon:f2,DiamondPlus:Dq,DiamondPlusIcon:Dq,Dice1:Rq,Dice1Icon:Rq,Dice2:Fq,Dice2Icon:Fq,Dice3:zq,Dice3Icon:zq,Dice4:Bq,Dice4Icon:Bq,Dice5:$q,Dice5Icon:$q,Dice6:qq,Dice6Icon:qq,Dices:Uq,DicesIcon:Uq,Diff:Vq,DiffIcon:Vq,Disc:Kq,Disc2:Hq,Disc2Icon:Hq,Disc3:Wq,Disc3Icon:Wq,DiscAlbum:Gq,DiscAlbumIcon:Gq,DiscIcon:Kq,Divide:Zq,DivideCircle:Kw,DivideCircleIcon:Kw,DivideIcon:Zq,DivideSquare:Tj,DivideSquareIcon:Tj,Dna:Xq,DnaIcon:Xq,DnaOff:Yq,DnaOffIcon:Yq,Dock:Qq,DockIcon:Qq,Dog:Jq,DogIcon:Jq,DollarSign:od,DollarSignIcon:od,Donut:eU,DonutIcon:eU,DoorClosed:tU,DoorClosedIcon:tU,DoorOpen:P0,DoorOpenIcon:P0,Dot:sU,DotIcon:sU,DotSquare:Aj,DotSquareIcon:Aj,Download:xi,DownloadCloud:c2,DownloadCloudIcon:c2,DownloadIcon:xi,DraftingCompass:rU,DraftingCompassIcon:rU,Drama:nU,DramaIcon:nU,Dribbble:aU,DribbbleIcon:aU,Drill:iU,DrillIcon:iU,Droplet:oU,DropletIcon:oU,Droplets:Vg,DropletsIcon:Vg,Drum:lU,DrumIcon:lU,Drumstick:cU,DrumstickIcon:cU,Dumbbell:dU,DumbbellIcon:dU,Ear:hU,EarIcon:hU,EarOff:uU,EarOffIcon:uU,Earth:g2,EarthIcon:g2,EarthLock:mU,EarthLockIcon:mU,Eclipse:pU,EclipseIcon:pU,Edit:Rc,Edit2:Fx,Edit2Icon:Fx,Edit3:f0,Edit3Icon:f0,EditIcon:Rc,Egg:f5,EggFried:fU,EggFriedIcon:fU,EggIcon:f5,EggOff:gU,EggOffIcon:gU,Ellipsis:of,EllipsisIcon:of,EllipsisVertical:af,EllipsisVerticalIcon:af,Equal:vU,EqualApproximately:xU,EqualApproximatelyIcon:xU,EqualIcon:vU,EqualNot:yU,EqualNotIcon:yU,EqualSquare:Ej,EqualSquareIcon:Ej,Eraser:_U,EraserIcon:_U,EthernetPort:bU,EthernetPortIcon:bU,Euro:wU,EuroIcon:wU,Expand:jU,ExpandIcon:jU,ExternalLink:sn,ExternalLinkIcon:sn,Eye:xa,EyeClosed:NU,EyeClosedIcon:NU,EyeIcon:xa,EyeOff:Im,EyeOffIcon:Im,Facebook:Hd,FacebookIcon:Hd,Factory:kU,FactoryIcon:kU,Fan:SU,FanIcon:SU,FastForward:CU,FastForwardIcon:CU,Feather:MU,FeatherIcon:MU,Fence:TU,FenceIcon:TU,FerrisWheel:AU,FerrisWheelIcon:AU,Figma:EU,FigmaIcon:EU,File:g5,FileArchive:PU,FileArchiveIcon:PU,FileAudio:LU,FileAudio2:IU,FileAudio2Icon:IU,FileAudioIcon:LU,FileAxis3D:x2,FileAxis3DIcon:x2,FileAxis3d:x2,FileAxis3dIcon:x2,FileBadge:OU,FileBadge2:DU,FileBadge2Icon:DU,FileBadgeIcon:OU,FileBarChart:y2,FileBarChart2:v2,FileBarChart2Icon:v2,FileBarChartIcon:y2,FileBox:RU,FileBoxIcon:RU,FileChartColumn:v2,FileChartColumnIcon:v2,FileChartColumnIncreasing:y2,FileChartColumnIncreasingIcon:y2,FileChartLine:_2,FileChartLineIcon:_2,FileChartPie:b2,FileChartPieIcon:b2,FileCheck:zU,FileCheck2:FU,FileCheck2Icon:FU,FileCheckIcon:zU,FileClock:BU,FileClockIcon:BU,FileCode:qU,FileCode2:$U,FileCode2Icon:$U,FileCodeIcon:qU,FileCog:w2,FileCog2:w2,FileCog2Icon:w2,FileCogIcon:w2,FileDiff:UU,FileDiffIcon:UU,FileDigit:VU,FileDigitIcon:VU,FileDown:HU,FileDownIcon:HU,FileEdit:N2,FileEditIcon:N2,FileHeart:WU,FileHeartIcon:WU,FileIcon:g5,FileImage:i_,FileImageIcon:i_,FileInput:GU,FileInputIcon:GU,FileJson:ZU,FileJson2:KU,FileJson2Icon:KU,FileJsonIcon:ZU,FileKey:XU,FileKey2:YU,FileKey2Icon:YU,FileKeyIcon:XU,FileLineChart:_2,FileLineChartIcon:_2,FileLock:JU,FileLock2:QU,FileLock2Icon:QU,FileLockIcon:JU,FileMinus:tV,FileMinus2:eV,FileMinus2Icon:eV,FileMinusIcon:tV,FileMusic:sV,FileMusicIcon:sV,FileOutput:rV,FileOutputIcon:rV,FilePen:N2,FilePenIcon:N2,FilePenLine:j2,FilePenLineIcon:j2,FilePieChart:b2,FilePieChartIcon:b2,FilePlus:aV,FilePlus2:nV,FilePlus2Icon:nV,FilePlusIcon:aV,FileQuestion:iV,FileQuestionIcon:iV,FileScan:oV,FileScanIcon:oV,FileSearch:cV,FileSearch2:lV,FileSearch2Icon:lV,FileSearchIcon:cV,FileSignature:j2,FileSignatureIcon:j2,FileSliders:dV,FileSlidersIcon:dV,FileSpreadsheet:I0,FileSpreadsheetIcon:I0,FileStack:mP,FileStackIcon:mP,FileSymlink:uV,FileSymlinkIcon:uV,FileTerminal:hV,FileTerminalIcon:hV,FileText:In,FileTextIcon:In,FileType:pV,FileType2:mV,FileType2Icon:mV,FileTypeIcon:pV,FileUp:fV,FileUpIcon:fV,FileUser:gV,FileUserIcon:gV,FileVideo:yV,FileVideo2:xV,FileVideo2Icon:xV,FileVideoIcon:yV,FileVolume:_V,FileVolume2:vV,FileVolume2Icon:vV,FileVolumeIcon:_V,FileWarning:bV,FileWarningIcon:bV,FileX:jV,FileX2:wV,FileX2Icon:wV,FileXIcon:jV,Files:NV,FilesIcon:NV,Film:lu,FilmIcon:lu,Filter:Yx,FilterIcon:Yx,FilterX:kV,FilterXIcon:kV,Fingerprint:SV,FingerprintIcon:SV,FireExtinguisher:CV,FireExtinguisherIcon:CV,Fish:AV,FishIcon:AV,FishOff:MV,FishOffIcon:MV,FishSymbol:TV,FishSymbolIcon:TV,Flag:L0,FlagIcon:L0,FlagOff:EV,FlagOffIcon:EV,FlagTriangleLeft:PV,FlagTriangleLeftIcon:PV,FlagTriangleRight:IV,FlagTriangleRightIcon:IV,Flame:nh,FlameIcon:nh,FlameKindling:LV,FlameKindlingIcon:LV,Flashlight:OV,FlashlightIcon:OV,FlashlightOff:DV,FlashlightOffIcon:DV,FlaskConical:o_,FlaskConicalIcon:o_,FlaskConicalOff:RV,FlaskConicalOffIcon:RV,FlaskRound:FV,FlaskRoundIcon:FV,FlipHorizontal:BV,FlipHorizontal2:zV,FlipHorizontal2Icon:zV,FlipHorizontalIcon:BV,FlipVertical:qV,FlipVertical2:$V,FlipVertical2Icon:$V,FlipVerticalIcon:qV,Flower:UV,Flower2:Og,Flower2Icon:Og,FlowerIcon:UV,Focus:VV,FocusIcon:VV,FoldHorizontal:HV,FoldHorizontalIcon:HV,FoldVertical:WV,FoldVerticalIcon:WV,Folder:vH,FolderArchive:GV,FolderArchiveIcon:GV,FolderCheck:KV,FolderCheckIcon:KV,FolderClock:ZV,FolderClockIcon:ZV,FolderClosed:YV,FolderClosedIcon:YV,FolderCode:XV,FolderCodeIcon:XV,FolderCog:k2,FolderCog2:k2,FolderCog2Icon:k2,FolderCogIcon:k2,FolderDot:QV,FolderDotIcon:QV,FolderDown:JV,FolderDownIcon:JV,FolderEdit:S2,FolderEditIcon:S2,FolderGit:tH,FolderGit2:eH,FolderGit2Icon:eH,FolderGitIcon:tH,FolderHeart:sH,FolderHeartIcon:sH,FolderIcon:vH,FolderInput:rH,FolderInputIcon:rH,FolderKanban:nH,FolderKanbanIcon:nH,FolderKey:aH,FolderKeyIcon:aH,FolderLock:iH,FolderLockIcon:iH,FolderMinus:oH,FolderMinusIcon:oH,FolderOpen:Vh,FolderOpenDot:lH,FolderOpenDotIcon:lH,FolderOpenIcon:Vh,FolderOutput:cH,FolderOutputIcon:cH,FolderPen:S2,FolderPenIcon:S2,FolderPlus:dH,FolderPlusIcon:dH,FolderRoot:uH,FolderRootIcon:uH,FolderSearch:mH,FolderSearch2:hH,FolderSearch2Icon:hH,FolderSearchIcon:mH,FolderSymlink:pH,FolderSymlinkIcon:pH,FolderSync:fH,FolderSyncIcon:fH,FolderTree:gH,FolderTreeIcon:gH,FolderUp:xH,FolderUpIcon:xH,FolderX:yH,FolderXIcon:yH,Folders:_H,FoldersIcon:_H,Footprints:bH,FootprintsIcon:bH,ForkKnife:gN,ForkKnifeCrossed:fN,ForkKnifeCrossedIcon:fN,ForkKnifeIcon:gN,Forklift:wH,ForkliftIcon:wH,FormInput:X2,FormInputIcon:X2,Forward:jH,ForwardIcon:jH,Frame:NH,FrameIcon:NH,Framer:kH,FramerIcon:kH,Frown:SH,FrownIcon:SH,Fuel:CH,FuelIcon:CH,Fullscreen:MH,FullscreenIcon:MH,FunctionSquare:Pj,FunctionSquareIcon:Pj,GalleryHorizontal:AH,GalleryHorizontalEnd:TH,GalleryHorizontalEndIcon:TH,GalleryHorizontalIcon:AH,GalleryThumbnails:EH,GalleryThumbnailsIcon:EH,GalleryVertical:IH,GalleryVerticalEnd:PH,GalleryVerticalEndIcon:PH,GalleryVerticalIcon:IH,Gamepad:DH,Gamepad2:LH,Gamepad2Icon:LH,GamepadIcon:DH,GanttChart:Iw,GanttChartIcon:Iw,GanttChartSquare:Mx,GanttChartSquareIcon:Mx,Gauge:OH,GaugeCircle:Zw,GaugeCircleIcon:Zw,GaugeIcon:OH,Gavel:RH,GavelIcon:RH,Gem:FH,GemIcon:FH,Ghost:lk,GhostIcon:lk,Gift:po,GiftIcon:po,GitBranch:BH,GitBranchIcon:BH,GitBranchPlus:zH,GitBranchPlusIcon:zH,GitCommit:C2,GitCommitHorizontal:C2,GitCommitHorizontalIcon:C2,GitCommitIcon:C2,GitCommitVertical:$H,GitCommitVerticalIcon:$H,GitCompare:UH,GitCompareArrows:qH,GitCompareArrowsIcon:qH,GitCompareIcon:UH,GitFork:VH,GitForkIcon:VH,GitGraph:HH,GitGraphIcon:HH,GitMerge:WH,GitMergeIcon:WH,GitPullRequest:QH,GitPullRequestArrow:GH,GitPullRequestArrowIcon:GH,GitPullRequestClosed:KH,GitPullRequestClosedIcon:KH,GitPullRequestCreate:YH,GitPullRequestCreateArrow:ZH,GitPullRequestCreateArrowIcon:ZH,GitPullRequestCreateIcon:YH,GitPullRequestDraft:XH,GitPullRequestDraftIcon:XH,GitPullRequestIcon:QH,Github:JH,GithubIcon:JH,Gitlab:eW,GitlabIcon:eW,GlassWater:tW,GlassWaterIcon:tW,Glasses:sW,GlassesIcon:sW,Globe:Lm,Globe2:g2,Globe2Icon:g2,GlobeIcon:Lm,GlobeLock:rW,GlobeLockIcon:rW,Goal:nW,GoalIcon:nW,Grab:aW,GrabIcon:aW,GraduationCap:ah,GraduationCapIcon:ah,Grape:iW,GrapeIcon:iW,Grid:Yp,Grid2X2:T2,Grid2X2Icon:T2,Grid2X2Plus:M2,Grid2X2PlusIcon:M2,Grid2x2:T2,Grid2x2Check:oW,Grid2x2CheckIcon:oW,Grid2x2Icon:T2,Grid2x2Plus:M2,Grid2x2PlusIcon:M2,Grid2x2X:lW,Grid2x2XIcon:lW,Grid3X3:Yp,Grid3X3Icon:Yp,Grid3x3:Yp,Grid3x3Icon:Yp,GridIcon:Yp,Grip:dW,GripHorizontal:cW,GripHorizontalIcon:cW,GripIcon:dW,GripVertical:Bu,GripVerticalIcon:Bu,Group:uW,GroupIcon:uW,Guitar:hW,GuitarIcon:hW,Ham:mW,HamIcon:mW,Hammer:pW,HammerIcon:pW,Hand:pP,HandCoins:fW,HandCoinsIcon:fW,HandHeart:gW,HandHeartIcon:gW,HandHelping:A2,HandHelpingIcon:A2,HandIcon:pP,HandMetal:xW,HandMetalIcon:xW,HandPlatter:yW,HandPlatterIcon:yW,Handshake:fP,HandshakeIcon:fP,HardDrive:gP,HardDriveDownload:vW,HardDriveDownloadIcon:vW,HardDriveIcon:gP,HardDriveUpload:_W,HardDriveUploadIcon:_W,HardHat:bW,HardHatIcon:bW,Hash:x5,HashIcon:x5,Haze:wW,HazeIcon:wW,HdmiPort:jW,HdmiPortIcon:jW,Heading:MW,Heading1:xP,Heading1Icon:xP,Heading2:yP,Heading2Icon:yP,Heading3:NW,Heading3Icon:NW,Heading4:kW,Heading4Icon:kW,Heading5:SW,Heading5Icon:SW,Heading6:CW,Heading6Icon:CW,HeadingIcon:MW,HeadphoneOff:TW,HeadphoneOffIcon:TW,Headphones:AW,HeadphonesIcon:AW,Headset:EW,HeadsetIcon:EW,Heart:Si,HeartCrack:PW,HeartCrackIcon:PW,HeartHandshake:IW,HeartHandshakeIcon:IW,HeartIcon:Si,HeartOff:LW,HeartOffIcon:LW,HeartPulse:DW,HeartPulseIcon:DW,Heater:OW,HeaterIcon:OW,HelpCircle:h0,HelpCircleIcon:h0,HelpingHand:A2,HelpingHandIcon:A2,Hexagon:RW,HexagonIcon:RW,Highlighter:FW,HighlighterIcon:FW,History:y5,HistoryIcon:y5,Home:On,HomeIcon:On,Hop:BW,HopIcon:BW,HopOff:zW,HopOffIcon:zW,Hospital:$W,HospitalIcon:$W,Hotel:qW,HotelIcon:qW,Hourglass:UW,HourglassIcon:UW,House:On,HouseIcon:On,HousePlug:VW,HousePlugIcon:VW,HousePlus:HW,HousePlusIcon:HW,IceCream:P2,IceCream2:E2,IceCream2Icon:E2,IceCreamBowl:E2,IceCreamBowlIcon:E2,IceCreamCone:P2,IceCreamConeIcon:P2,IceCreamIcon:P2,Icon:ERe,IdCard:WW,IdCardIcon:WW,Image:Jo,ImageDown:GW,ImageDownIcon:GW,ImageIcon:Jo,ImageMinus:KW,ImageMinusIcon:KW,ImageOff:ZW,ImageOffIcon:ZW,ImagePlay:YW,ImagePlayIcon:YW,ImagePlus:D0,ImagePlusIcon:D0,ImageUp:XW,ImageUpIcon:XW,ImageUpscale:QW,ImageUpscaleIcon:QW,Images:JW,ImagesIcon:JW,Import:eG,ImportIcon:eG,Inbox:tG,InboxIcon:tG,Indent:L2,IndentDecrease:I2,IndentDecreaseIcon:I2,IndentIcon:L2,IndentIncrease:L2,IndentIncreaseIcon:L2,IndianRupee:sG,IndianRupeeIcon:sG,Infinity:rG,InfinityIcon:rG,Info:vP,InfoIcon:vP,Inspect:Fj,InspectIcon:Fj,InspectionPanel:nG,InspectionPanelIcon:nG,Instagram:Wd,InstagramIcon:Wd,Italic:v5,ItalicIcon:v5,IterationCcw:aG,IterationCcwIcon:aG,IterationCw:iG,IterationCwIcon:iG,JapaneseYen:oG,JapaneseYenIcon:oG,Joystick:lG,JoystickIcon:lG,Kanban:Xx,KanbanIcon:Xx,KanbanSquare:Ij,KanbanSquareDashed:Sj,KanbanSquareDashedIcon:Sj,KanbanSquareIcon:Ij,Key:Dm,KeyIcon:Dm,KeyRound:ck,KeyRoundIcon:ck,KeySquare:cG,KeySquareIcon:cG,Keyboard:hG,KeyboardIcon:hG,KeyboardMusic:dG,KeyboardMusicIcon:dG,KeyboardOff:uG,KeyboardOffIcon:uG,Lamp:yG,LampCeiling:mG,LampCeilingIcon:mG,LampDesk:pG,LampDeskIcon:pG,LampFloor:fG,LampFloorIcon:fG,LampIcon:yG,LampWallDown:gG,LampWallDownIcon:gG,LampWallUp:xG,LampWallUpIcon:xG,LandPlot:vG,LandPlotIcon:vG,Landmark:_G,LandmarkIcon:_G,Languages:bG,LanguagesIcon:bG,Laptop:jG,Laptop2:D2,Laptop2Icon:D2,LaptopIcon:jG,LaptopMinimal:D2,LaptopMinimalCheck:wG,LaptopMinimalCheckIcon:wG,LaptopMinimalIcon:D2,Lasso:kG,LassoIcon:kG,LassoSelect:NG,LassoSelectIcon:NG,Laugh:SG,LaughIcon:SG,Layers:TG,Layers2:CG,Layers2Icon:CG,Layers3:MG,Layers3Icon:MG,LayersIcon:TG,Layout:p0,LayoutDashboard:dk,LayoutDashboardIcon:dk,LayoutGrid:yp,LayoutGridIcon:yp,LayoutIcon:p0,LayoutList:AG,LayoutListIcon:AG,LayoutPanelLeft:EG,LayoutPanelLeftIcon:EG,LayoutPanelTop:PG,LayoutPanelTopIcon:PG,LayoutTemplate:uk,LayoutTemplateIcon:uk,Leaf:IG,LeafIcon:IG,LeafyGreen:LG,LeafyGreenIcon:LG,Lectern:DG,LecternIcon:DG,LetterText:OG,LetterTextIcon:OG,Library:_5,LibraryBig:RG,LibraryBigIcon:RG,LibraryIcon:_5,LibrarySquare:Lj,LibrarySquareIcon:Lj,LifeBuoy:b5,LifeBuoyIcon:b5,Ligature:FG,LigatureIcon:FG,Lightbulb:l_,LightbulbIcon:l_,LightbulbOff:zG,LightbulbOffIcon:zG,LineChart:Aw,LineChartIcon:Aw,Link:Do,Link2:Wo,Link2Icon:Wo,Link2Off:BG,Link2OffIcon:BG,LinkIcon:Do,Linkedin:Om,LinkedinIcon:Om,List:Hh,ListCheck:$G,ListCheckIcon:$G,ListChecks:qG,ListChecksIcon:qG,ListCollapse:UG,ListCollapseIcon:UG,ListEnd:VG,ListEndIcon:VG,ListFilter:HG,ListFilterIcon:HG,ListIcon:Hh,ListMinus:WG,ListMinusIcon:WG,ListMusic:GG,ListMusicIcon:GG,ListOrdered:O0,ListOrderedIcon:O0,ListPlus:KG,ListPlusIcon:KG,ListRestart:ZG,ListRestartIcon:ZG,ListStart:YG,ListStartIcon:YG,ListTodo:XG,ListTodoIcon:XG,ListTree:QG,ListTreeIcon:QG,ListVideo:JG,ListVideoIcon:JG,ListX:eK,ListXIcon:eK,Loader:sK,Loader2:Ms,Loader2Icon:Ms,LoaderCircle:Ms,LoaderCircleIcon:Ms,LoaderIcon:sK,LoaderPinwheel:tK,LoaderPinwheelIcon:tK,Locate:aK,LocateFixed:rK,LocateFixedIcon:rK,LocateIcon:aK,LocateOff:nK,LocateOffIcon:nK,Lock:$u,LockIcon:$u,LockKeyhole:iK,LockKeyholeIcon:iK,LockKeyholeOpen:O2,LockKeyholeOpenIcon:O2,LockOpen:R2,LockOpenIcon:R2,LogIn:w5,LogInIcon:w5,LogOut:j5,LogOutIcon:j5,Logs:oK,LogsIcon:oK,Lollipop:lK,LollipopIcon:lK,LucideAArrowDown:aF,LucideAArrowUp:iF,LucideALargeSmall:oF,LucideAccessibility:lF,LucideActivity:Pm,LucideActivitySquare:aj,LucideAirVent:cF,LucideAirplay:dF,LucideAlarmCheck:lw,LucideAlarmClock:hF,LucideAlarmClockCheck:lw,LucideAlarmClockMinus:cw,LucideAlarmClockOff:uF,LucideAlarmClockPlus:dw,LucideAlarmMinus:cw,LucideAlarmPlus:dw,LucideAlarmSmoke:mF,LucideAlbum:pF,LucideAlertCircle:ll,LucideAlertOctagon:m0,LucideAlertTriangle:Ju,LucideAlignCenter:l5,LucideAlignCenterHorizontal:fF,LucideAlignCenterVertical:gF,LucideAlignEndHorizontal:xF,LucideAlignEndVertical:yF,LucideAlignHorizontalDistributeCenter:vF,LucideAlignHorizontalDistributeEnd:_F,LucideAlignHorizontalDistributeStart:bF,LucideAlignHorizontalJustifyCenter:wF,LucideAlignHorizontalJustifyEnd:jF,LucideAlignHorizontalJustifyStart:NF,LucideAlignHorizontalSpaceAround:kF,LucideAlignHorizontalSpaceBetween:SF,LucideAlignJustify:CF,LucideAlignLeft:c5,LucideAlignRight:d5,LucideAlignStartHorizontal:MF,LucideAlignStartVertical:TF,LucideAlignVerticalDistributeCenter:AF,LucideAlignVerticalDistributeEnd:EF,LucideAlignVerticalDistributeStart:PF,LucideAlignVerticalJustifyCenter:IF,LucideAlignVerticalJustifyEnd:LF,LucideAlignVerticalJustifyStart:DF,LucideAlignVerticalSpaceAround:OF,LucideAlignVerticalSpaceBetween:RF,LucideAmbulance:FF,LucideAmpersand:zF,LucideAmpersands:BF,LucideAmphora:$F,LucideAnchor:qF,LucideAngry:UF,LucideAnnoyed:VF,LucideAntenna:HF,LucideAnvil:WF,LucideAperture:GF,LucideAppWindow:sP,LucideAppWindowMac:KF,LucideApple:ZF,LucideArchive:u5,LucideArchiveRestore:rP,LucideArchiveX:YF,LucideAreaChart:Nw,LucideArmchair:XF,LucideArrowBigDown:JF,LucideArrowBigDownDash:QF,LucideArrowBigLeft:tz,LucideArrowBigLeftDash:ez,LucideArrowBigRight:rz,LucideArrowBigRightDash:sz,LucideArrowBigUp:az,LucideArrowBigUpDash:nz,LucideArrowDown:sh,LucideArrowDown01:iz,LucideArrowDown10:oz,LucideArrowDownAZ:uw,LucideArrowDownAz:uw,LucideArrowDownCircle:Ow,LucideArrowDownFromLine:lz,LucideArrowDownLeft:cz,LucideArrowDownLeftFromCircle:Fw,LucideArrowDownLeftFromSquare:dj,LucideArrowDownLeftSquare:ij,LucideArrowDownNarrowWide:dz,LucideArrowDownRight:nP,LucideArrowDownRightFromCircle:zw,LucideArrowDownRightFromSquare:uj,LucideArrowDownRightSquare:oj,LucideArrowDownSquare:lj,LucideArrowDownToDot:uz,LucideArrowDownToLine:hz,LucideArrowDownUp:mz,LucideArrowDownWideNarrow:hw,LucideArrowDownZA:mw,LucideArrowDownZa:mw,LucideArrowLeft:ti,LucideArrowLeftCircle:Rw,LucideArrowLeftFromLine:pz,LucideArrowLeftRight:fz,LucideArrowLeftSquare:cj,LucideArrowLeftToLine:gz,LucideArrowRight:$i,LucideArrowRightCircle:qw,LucideArrowRightFromLine:xz,LucideArrowRightLeft:A0,LucideArrowRightSquare:pj,LucideArrowRightToLine:yz,LucideArrowUp:Vd,LucideArrowUp01:vz,LucideArrowUp10:_z,LucideArrowUpAZ:pw,LucideArrowUpAz:pw,LucideArrowUpCircle:Uw,LucideArrowUpDown:Hc,LucideArrowUpFromDot:bz,LucideArrowUpFromLine:wz,LucideArrowUpLeft:jz,LucideArrowUpLeftFromCircle:Bw,LucideArrowUpLeftFromSquare:hj,LucideArrowUpLeftSquare:fj,LucideArrowUpNarrowWide:fw,LucideArrowUpRight:aP,LucideArrowUpRightFromCircle:$w,LucideArrowUpRightFromSquare:mj,LucideArrowUpRightSquare:gj,LucideArrowUpSquare:xj,LucideArrowUpToLine:Nz,LucideArrowUpWideNarrow:kz,LucideArrowUpZA:gw,LucideArrowUpZa:gw,LucideArrowsUpFromLine:Sz,LucideAsterisk:Cz,LucideAsteriskSquare:yj,LucideAtSign:Mz,LucideAtom:Tz,LucideAudioLines:Az,LucideAudioWaveform:Ez,LucideAward:rc,LucideAxe:Pz,LucideAxis3D:xw,LucideAxis3d:xw,LucideBaby:Iz,LucideBackpack:Lz,LucideBadge:Yz,LucideBadgeAlert:Dz,LucideBadgeCent:Oz,LucideBadgeCheck:yw,LucideBadgeDollarSign:Rz,LucideBadgeEuro:Fz,LucideBadgeHelp:zz,LucideBadgeIndianRupee:Bz,LucideBadgeInfo:$z,LucideBadgeJapaneseYen:qz,LucideBadgeMinus:Uz,LucideBadgePercent:Vz,LucideBadgePlus:Hz,LucideBadgePoundSterling:Wz,LucideBadgeRussianRuble:Gz,LucideBadgeSwissFranc:Kz,LucideBadgeX:Zz,LucideBaggageClaim:Xz,LucideBan:Qz,LucideBanana:Jz,LucideBandage:e7,LucideBanknote:t7,LucideBarChart:Ew,LucideBarChart2:Pw,LucideBarChart3:ol,LucideBarChart4:Tw,LucideBarChartBig:Mw,LucideBarChartHorizontal:Sw,LucideBarChartHorizontalBig:kw,LucideBarcode:s7,LucideBaseline:r7,LucideBath:Zx,LucideBattery:c7,LucideBatteryCharging:n7,LucideBatteryFull:a7,LucideBatteryLow:i7,LucideBatteryMedium:o7,LucideBatteryWarning:l7,LucideBeaker:d7,LucideBean:h7,LucideBeanOff:u7,LucideBed:E0,LucideBedDouble:iP,LucideBedSingle:m7,LucideBeef:p7,LucideBeer:g7,LucideBeerOff:f7,LucideBell:gf,LucideBellDot:x7,LucideBellElectric:y7,LucideBellMinus:v7,LucideBellOff:r_,LucideBellPlus:_7,LucideBellRing:b7,LucideBetweenHorizonalEnd:vw,LucideBetweenHorizonalStart:_w,LucideBetweenHorizontalEnd:vw,LucideBetweenHorizontalStart:_w,LucideBetweenVerticalEnd:w7,LucideBetweenVerticalStart:j7,LucideBicepsFlexed:N7,LucideBike:k7,LucideBinary:S7,LucideBinoculars:C7,LucideBiohazard:M7,LucideBird:T7,LucideBitcoin:A7,LucideBlend:E7,LucideBlinds:P7,LucideBlocks:I7,LucideBluetooth:R7,LucideBluetoothConnected:L7,LucideBluetoothOff:D7,LucideBluetoothSearching:O7,LucideBold:h5,LucideBolt:F7,LucideBomb:z7,LucideBone:B7,LucideBook:lB,LucideBookA:$7,LucideBookAudio:q7,LucideBookCheck:U7,LucideBookCopy:V7,LucideBookDashed:bw,LucideBookDown:H7,LucideBookHeadphones:W7,LucideBookHeart:G7,LucideBookImage:K7,LucideBookKey:Z7,LucideBookLock:Y7,LucideBookMarked:X7,LucideBookMinus:Q7,LucideBookOpen:Fu,LucideBookOpenCheck:J7,LucideBookOpenText:eB,LucideBookPlus:tB,LucideBookTemplate:bw,LucideBookText:sB,LucideBookType:rB,LucideBookUp:aB,LucideBookUp2:nB,LucideBookUser:iB,LucideBookX:oB,LucideBookmark:$g,LucideBookmarkCheck:cB,LucideBookmarkMinus:dB,LucideBookmarkPlus:oP,LucideBookmarkX:uB,LucideBoomBox:hB,LucideBot:m5,LucideBotMessageSquare:mB,LucideBotOff:pB,LucideBox:fB,LucideBoxSelect:Mj,LucideBoxes:gB,LucideBraces:ww,LucideBrackets:xB,LucideBrain:lP,LucideBrainCircuit:yB,LucideBrainCog:vB,LucideBrickWall:_B,LucideBriefcase:rh,LucideBriefcaseBusiness:bB,LucideBriefcaseConveyorBelt:wB,LucideBriefcaseMedical:jB,LucideBringToFront:NB,LucideBrush:kB,LucideBug:MB,LucideBugOff:SB,LucideBugPlay:CB,LucideBuilding:nk,LucideBuilding2:Ta,LucideBus:AB,LucideBusFront:TB,LucideCable:PB,LucideCableCar:EB,LucideCake:zu,LucideCakeSlice:IB,LucideCalculator:LB,LucideCalendar:on,LucideCalendar1:DB,LucideCalendarArrowDown:OB,LucideCalendarArrowUp:RB,LucideCalendarCheck:cP,LucideCalendarCheck2:FB,LucideCalendarClock:dP,LucideCalendarCog:zB,LucideCalendarDays:id,LucideCalendarFold:BB,LucideCalendarHeart:$B,LucideCalendarMinus:UB,LucideCalendarMinus2:qB,LucideCalendarOff:uP,LucideCalendarPlus:n_,LucideCalendarPlus2:VB,LucideCalendarRange:HB,LucideCalendarSearch:WB,LucideCalendarSync:GB,LucideCalendarX:ZB,LucideCalendarX2:KB,LucideCamera:qg,LucideCameraOff:YB,LucideCandlestickChart:Cw,LucideCandy:JB,LucideCandyCane:XB,LucideCandyOff:QB,LucideCannabis:e9,LucideCaptions:jw,LucideCaptionsOff:t9,LucideCar:n9,LucideCarFront:s9,LucideCarTaxiFront:r9,LucideCaravan:a9,LucideCarrot:i9,LucideCaseLower:o9,LucideCaseSensitive:l9,LucideCaseUpper:c9,LucideCassetteTape:d9,LucideCast:u9,LucideCastle:h9,LucideCat:m9,LucideCctv:p9,LucideChartArea:Nw,LucideChartBar:Sw,LucideChartBarBig:kw,LucideChartBarDecreasing:f9,LucideChartBarIncreasing:g9,LucideChartBarStacked:x9,LucideChartCandlestick:Cw,LucideChartColumn:ol,LucideChartColumnBig:Mw,LucideChartColumnDecreasing:y9,LucideChartColumnIncreasing:Tw,LucideChartColumnStacked:v9,LucideChartGantt:_9,LucideChartLine:Aw,LucideChartNetwork:b9,LucideChartNoAxesColumn:Pw,LucideChartNoAxesColumnDecreasing:w9,LucideChartNoAxesColumnIncreasing:Ew,LucideChartNoAxesCombined:j9,LucideChartNoAxesGantt:Iw,LucideChartPie:Lw,LucideChartScatter:Dw,LucideChartSpline:N9,LucideCheck:ha,LucideCheckCheck:k9,LucideCheckCircle:hi,LucideCheckCircle2:ua,LucideCheckSquare:g0,LucideCheckSquare2:_j,LucideChefHat:S9,LucideCherry:C9,LucideChevronDown:Ho,LucideChevronDownCircle:Vw,LucideChevronDownSquare:bj,LucideChevronFirst:M9,LucideChevronLast:T9,LucideChevronLeft:zl,LucideChevronLeftCircle:Hw,LucideChevronLeftSquare:wj,LucideChevronRight:Ua,LucideChevronRightCircle:Ww,LucideChevronRightSquare:jj,LucideChevronUp:Ug,LucideChevronUpCircle:Gw,LucideChevronUpSquare:Nj,LucideChevronsDown:E9,LucideChevronsDownUp:A9,LucideChevronsLeft:L9,LucideChevronsLeftRight:I9,LucideChevronsLeftRightEllipsis:P9,LucideChevronsRight:O9,LucideChevronsRightLeft:D9,LucideChevronsUp:R9,LucideChevronsUpDown:xf,LucideChrome:F9,LucideChurch:z9,LucideCigarette:$9,LucideCigaretteOff:B9,LucideCircle:Kc,LucideCircleAlert:ll,LucideCircleArrowDown:Ow,LucideCircleArrowLeft:Rw,LucideCircleArrowOutDownLeft:Fw,LucideCircleArrowOutDownRight:zw,LucideCircleArrowOutUpLeft:Bw,LucideCircleArrowOutUpRight:$w,LucideCircleArrowRight:qw,LucideCircleArrowUp:Uw,LucideCircleCheck:ua,LucideCircleCheckBig:hi,LucideCircleChevronDown:Vw,LucideCircleChevronLeft:Hw,LucideCircleChevronRight:Ww,LucideCircleChevronUp:Gw,LucideCircleDashed:q9,LucideCircleDivide:Kw,LucideCircleDollarSign:U9,LucideCircleDot:H9,LucideCircleDotDashed:V9,LucideCircleEllipsis:W9,LucideCircleEqual:G9,LucideCircleFadingArrowUp:K9,LucideCircleFadingPlus:Z9,LucideCircleGauge:Zw,LucideCircleHelp:h0,LucideCircleMinus:Yw,LucideCircleOff:Y9,LucideCircleParking:Qw,LucideCircleParkingOff:Xw,LucideCirclePause:Jw,LucideCirclePercent:e2,LucideCirclePlay:bm,LucideCirclePlus:t2,LucideCirclePower:s2,LucideCircleSlash:X9,LucideCircleSlash2:r2,LucideCircleSlashed:r2,LucideCircleStop:n2,LucideCircleUser:i2,LucideCircleUserRound:a2,LucideCircleX:kc,LucideCircuitBoard:Q9,LucideCitrus:J9,LucideClapperboard:e$,LucideClipboard:o$,LucideClipboardCheck:p5,LucideClipboardCopy:t$,LucideClipboardEdit:l2,LucideClipboardList:a_,LucideClipboardMinus:s$,LucideClipboardPaste:r$,LucideClipboardPen:l2,LucideClipboardPenLine:o2,LucideClipboardPlus:n$,LucideClipboardSignature:o2,LucideClipboardType:a$,LucideClipboardX:i$,LucideClock:Tn,LucideClock1:l$,LucideClock10:c$,LucideClock11:d$,LucideClock12:u$,LucideClock2:h$,LucideClock3:m$,LucideClock4:p$,LucideClock5:f$,LucideClock6:g$,LucideClock7:x$,LucideClock8:y$,LucideClock9:v$,LucideClockAlert:_$,LucideClockArrowDown:b$,LucideClockArrowUp:w$,LucideCloud:R$,LucideCloudAlert:j$,LucideCloudCog:N$,LucideCloudDownload:c2,LucideCloudDrizzle:k$,LucideCloudFog:S$,LucideCloudHail:C$,LucideCloudLightning:M$,LucideCloudMoon:A$,LucideCloudMoonRain:T$,LucideCloudOff:E$,LucideCloudRain:I$,LucideCloudRainWind:P$,LucideCloudSnow:L$,LucideCloudSun:O$,LucideCloudSunRain:D$,LucideCloudUpload:d2,LucideCloudy:F$,LucideClover:N0,LucideClub:z$,LucideCode:ak,LucideCode2:u2,LucideCodeSquare:kj,LucideCodeXml:u2,LucideCodepen:B$,LucideCodesandbox:$$,LucideCoffee:ik,LucideCog:q$,LucideCoins:hP,LucideColumns:h2,LucideColumns2:h2,LucideColumns3:m2,LucideColumns4:U$,LucideCombine:V$,LucideCommand:H$,LucideCompass:W$,LucideComponent:G$,LucideComputer:K$,LucideConciergeBell:Z$,LucideCone:Y$,LucideConstruction:X$,LucideContact:ok,LucideContact2:p2,LucideContactRound:p2,LucideContainer:Q$,LucideContrast:J$,LucideCookie:eq,LucideCookingPot:tq,LucideCopy:ai,LucideCopyCheck:sq,LucideCopyMinus:rq,LucideCopyPlus:nq,LucideCopySlash:aq,LucideCopyX:iq,LucideCopyleft:oq,LucideCopyright:lq,LucideCornerDownLeft:cq,LucideCornerDownRight:dq,LucideCornerLeftDown:uq,LucideCornerLeftUp:hq,LucideCornerRightDown:mq,LucideCornerRightUp:pq,LucideCornerUpLeft:fq,LucideCornerUpRight:gq,LucideCpu:xq,LucideCreativeCommons:yq,LucideCreditCard:yf,LucideCroissant:vq,LucideCrop:_q,LucideCross:bq,LucideCrosshair:wq,LucideCrown:Uh,LucideCuboid:jq,LucideCupSoda:Nq,LucideCurlyBraces:ww,LucideCurrency:kq,LucideCylinder:Sq,LucideDam:Cq,LucideDatabase:Aq,LucideDatabaseBackup:Mq,LucideDatabaseZap:Tq,LucideDelete:Eq,LucideDessert:Pq,LucideDiameter:Iq,LucideDiamond:Oq,LucideDiamondMinus:Lq,LucideDiamondPercent:f2,LucideDiamondPlus:Dq,LucideDice1:Rq,LucideDice2:Fq,LucideDice3:zq,LucideDice4:Bq,LucideDice5:$q,LucideDice6:qq,LucideDices:Uq,LucideDiff:Vq,LucideDisc:Kq,LucideDisc2:Hq,LucideDisc3:Wq,LucideDiscAlbum:Gq,LucideDivide:Zq,LucideDivideCircle:Kw,LucideDivideSquare:Tj,LucideDna:Xq,LucideDnaOff:Yq,LucideDock:Qq,LucideDog:Jq,LucideDollarSign:od,LucideDonut:eU,LucideDoorClosed:tU,LucideDoorOpen:P0,LucideDot:sU,LucideDotSquare:Aj,LucideDownload:xi,LucideDownloadCloud:c2,LucideDraftingCompass:rU,LucideDrama:nU,LucideDribbble:aU,LucideDrill:iU,LucideDroplet:oU,LucideDroplets:Vg,LucideDrum:lU,LucideDrumstick:cU,LucideDumbbell:dU,LucideEar:hU,LucideEarOff:uU,LucideEarth:g2,LucideEarthLock:mU,LucideEclipse:pU,LucideEdit:Rc,LucideEdit2:Fx,LucideEdit3:f0,LucideEgg:f5,LucideEggFried:fU,LucideEggOff:gU,LucideEllipsis:of,LucideEllipsisVertical:af,LucideEqual:vU,LucideEqualApproximately:xU,LucideEqualNot:yU,LucideEqualSquare:Ej,LucideEraser:_U,LucideEthernetPort:bU,LucideEuro:wU,LucideExpand:jU,LucideExternalLink:sn,LucideEye:xa,LucideEyeClosed:NU,LucideEyeOff:Im,LucideFacebook:Hd,LucideFactory:kU,LucideFan:SU,LucideFastForward:CU,LucideFeather:MU,LucideFence:TU,LucideFerrisWheel:AU,LucideFigma:EU,LucideFile:g5,LucideFileArchive:PU,LucideFileAudio:LU,LucideFileAudio2:IU,LucideFileAxis3D:x2,LucideFileAxis3d:x2,LucideFileBadge:OU,LucideFileBadge2:DU,LucideFileBarChart:y2,LucideFileBarChart2:v2,LucideFileBox:RU,LucideFileChartColumn:v2,LucideFileChartColumnIncreasing:y2,LucideFileChartLine:_2,LucideFileChartPie:b2,LucideFileCheck:zU,LucideFileCheck2:FU,LucideFileClock:BU,LucideFileCode:qU,LucideFileCode2:$U,LucideFileCog:w2,LucideFileCog2:w2,LucideFileDiff:UU,LucideFileDigit:VU,LucideFileDown:HU,LucideFileEdit:N2,LucideFileHeart:WU,LucideFileImage:i_,LucideFileInput:GU,LucideFileJson:ZU,LucideFileJson2:KU,LucideFileKey:XU,LucideFileKey2:YU,LucideFileLineChart:_2,LucideFileLock:JU,LucideFileLock2:QU,LucideFileMinus:tV,LucideFileMinus2:eV,LucideFileMusic:sV,LucideFileOutput:rV,LucideFilePen:N2,LucideFilePenLine:j2,LucideFilePieChart:b2,LucideFilePlus:aV,LucideFilePlus2:nV,LucideFileQuestion:iV,LucideFileScan:oV,LucideFileSearch:cV,LucideFileSearch2:lV,LucideFileSignature:j2,LucideFileSliders:dV,LucideFileSpreadsheet:I0,LucideFileStack:mP,LucideFileSymlink:uV,LucideFileTerminal:hV,LucideFileText:In,LucideFileType:pV,LucideFileType2:mV,LucideFileUp:fV,LucideFileUser:gV,LucideFileVideo:yV,LucideFileVideo2:xV,LucideFileVolume:_V,LucideFileVolume2:vV,LucideFileWarning:bV,LucideFileX:jV,LucideFileX2:wV,LucideFiles:NV,LucideFilm:lu,LucideFilter:Yx,LucideFilterX:kV,LucideFingerprint:SV,LucideFireExtinguisher:CV,LucideFish:AV,LucideFishOff:MV,LucideFishSymbol:TV,LucideFlag:L0,LucideFlagOff:EV,LucideFlagTriangleLeft:PV,LucideFlagTriangleRight:IV,LucideFlame:nh,LucideFlameKindling:LV,LucideFlashlight:OV,LucideFlashlightOff:DV,LucideFlaskConical:o_,LucideFlaskConicalOff:RV,LucideFlaskRound:FV,LucideFlipHorizontal:BV,LucideFlipHorizontal2:zV,LucideFlipVertical:qV,LucideFlipVertical2:$V,LucideFlower:UV,LucideFlower2:Og,LucideFocus:VV,LucideFoldHorizontal:HV,LucideFoldVertical:WV,LucideFolder:vH,LucideFolderArchive:GV,LucideFolderCheck:KV,LucideFolderClock:ZV,LucideFolderClosed:YV,LucideFolderCode:XV,LucideFolderCog:k2,LucideFolderCog2:k2,LucideFolderDot:QV,LucideFolderDown:JV,LucideFolderEdit:S2,LucideFolderGit:tH,LucideFolderGit2:eH,LucideFolderHeart:sH,LucideFolderInput:rH,LucideFolderKanban:nH,LucideFolderKey:aH,LucideFolderLock:iH,LucideFolderMinus:oH,LucideFolderOpen:Vh,LucideFolderOpenDot:lH,LucideFolderOutput:cH,LucideFolderPen:S2,LucideFolderPlus:dH,LucideFolderRoot:uH,LucideFolderSearch:mH,LucideFolderSearch2:hH,LucideFolderSymlink:pH,LucideFolderSync:fH,LucideFolderTree:gH,LucideFolderUp:xH,LucideFolderX:yH,LucideFolders:_H,LucideFootprints:bH,LucideForkKnife:gN,LucideForkKnifeCrossed:fN,LucideForklift:wH,LucideFormInput:X2,LucideForward:jH,LucideFrame:NH,LucideFramer:kH,LucideFrown:SH,LucideFuel:CH,LucideFullscreen:MH,LucideFunctionSquare:Pj,LucideGalleryHorizontal:AH,LucideGalleryHorizontalEnd:TH,LucideGalleryThumbnails:EH,LucideGalleryVertical:IH,LucideGalleryVerticalEnd:PH,LucideGamepad:DH,LucideGamepad2:LH,LucideGanttChart:Iw,LucideGanttChartSquare:Mx,LucideGauge:OH,LucideGaugeCircle:Zw,LucideGavel:RH,LucideGem:FH,LucideGhost:lk,LucideGift:po,LucideGitBranch:BH,LucideGitBranchPlus:zH,LucideGitCommit:C2,LucideGitCommitHorizontal:C2,LucideGitCommitVertical:$H,LucideGitCompare:UH,LucideGitCompareArrows:qH,LucideGitFork:VH,LucideGitGraph:HH,LucideGitMerge:WH,LucideGitPullRequest:QH,LucideGitPullRequestArrow:GH,LucideGitPullRequestClosed:KH,LucideGitPullRequestCreate:YH,LucideGitPullRequestCreateArrow:ZH,LucideGitPullRequestDraft:XH,LucideGithub:JH,LucideGitlab:eW,LucideGlassWater:tW,LucideGlasses:sW,LucideGlobe:Lm,LucideGlobe2:g2,LucideGlobeLock:rW,LucideGoal:nW,LucideGrab:aW,LucideGraduationCap:ah,LucideGrape:iW,LucideGrid:Yp,LucideGrid2X2:T2,LucideGrid2X2Plus:M2,LucideGrid2x2:T2,LucideGrid2x2Check:oW,LucideGrid2x2Plus:M2,LucideGrid2x2X:lW,LucideGrid3X3:Yp,LucideGrid3x3:Yp,LucideGrip:dW,LucideGripHorizontal:cW,LucideGripVertical:Bu,LucideGroup:uW,LucideGuitar:hW,LucideHam:mW,LucideHammer:pW,LucideHand:pP,LucideHandCoins:fW,LucideHandHeart:gW,LucideHandHelping:A2,LucideHandMetal:xW,LucideHandPlatter:yW,LucideHandshake:fP,LucideHardDrive:gP,LucideHardDriveDownload:vW,LucideHardDriveUpload:_W,LucideHardHat:bW,LucideHash:x5,LucideHaze:wW,LucideHdmiPort:jW,LucideHeading:MW,LucideHeading1:xP,LucideHeading2:yP,LucideHeading3:NW,LucideHeading4:kW,LucideHeading5:SW,LucideHeading6:CW,LucideHeadphoneOff:TW,LucideHeadphones:AW,LucideHeadset:EW,LucideHeart:Si,LucideHeartCrack:PW,LucideHeartHandshake:IW,LucideHeartOff:LW,LucideHeartPulse:DW,LucideHeater:OW,LucideHelpCircle:h0,LucideHelpingHand:A2,LucideHexagon:RW,LucideHighlighter:FW,LucideHistory:y5,LucideHome:On,LucideHop:BW,LucideHopOff:zW,LucideHospital:$W,LucideHotel:qW,LucideHourglass:UW,LucideHouse:On,LucideHousePlug:VW,LucideHousePlus:HW,LucideIceCream:P2,LucideIceCream2:E2,LucideIceCreamBowl:E2,LucideIceCreamCone:P2,LucideIdCard:WW,LucideImage:Jo,LucideImageDown:GW,LucideImageMinus:KW,LucideImageOff:ZW,LucideImagePlay:YW,LucideImagePlus:D0,LucideImageUp:XW,LucideImageUpscale:QW,LucideImages:JW,LucideImport:eG,LucideInbox:tG,LucideIndent:L2,LucideIndentDecrease:I2,LucideIndentIncrease:L2,LucideIndianRupee:sG,LucideInfinity:rG,LucideInfo:vP,LucideInspect:Fj,LucideInspectionPanel:nG,LucideInstagram:Wd,LucideItalic:v5,LucideIterationCcw:aG,LucideIterationCw:iG,LucideJapaneseYen:oG,LucideJoystick:lG,LucideKanban:Xx,LucideKanbanSquare:Ij,LucideKanbanSquareDashed:Sj,LucideKey:Dm,LucideKeyRound:ck,LucideKeySquare:cG,LucideKeyboard:hG,LucideKeyboardMusic:dG,LucideKeyboardOff:uG,LucideLamp:yG,LucideLampCeiling:mG,LucideLampDesk:pG,LucideLampFloor:fG,LucideLampWallDown:gG,LucideLampWallUp:xG,LucideLandPlot:vG,LucideLandmark:_G,LucideLanguages:bG,LucideLaptop:jG,LucideLaptop2:D2,LucideLaptopMinimal:D2,LucideLaptopMinimalCheck:wG,LucideLasso:kG,LucideLassoSelect:NG,LucideLaugh:SG,LucideLayers:TG,LucideLayers2:CG,LucideLayers3:MG,LucideLayout:p0,LucideLayoutDashboard:dk,LucideLayoutGrid:yp,LucideLayoutList:AG,LucideLayoutPanelLeft:EG,LucideLayoutPanelTop:PG,LucideLayoutTemplate:uk,LucideLeaf:IG,LucideLeafyGreen:LG,LucideLectern:DG,LucideLetterText:OG,LucideLibrary:_5,LucideLibraryBig:RG,LucideLibrarySquare:Lj,LucideLifeBuoy:b5,LucideLigature:FG,LucideLightbulb:l_,LucideLightbulbOff:zG,LucideLineChart:Aw,LucideLink:Do,LucideLink2:Wo,LucideLink2Off:BG,LucideLinkedin:Om,LucideList:Hh,LucideListCheck:$G,LucideListChecks:qG,LucideListCollapse:UG,LucideListEnd:VG,LucideListFilter:HG,LucideListMinus:WG,LucideListMusic:GG,LucideListOrdered:O0,LucideListPlus:KG,LucideListRestart:ZG,LucideListStart:YG,LucideListTodo:XG,LucideListTree:QG,LucideListVideo:JG,LucideListX:eK,LucideLoader:sK,LucideLoader2:Ms,LucideLoaderCircle:Ms,LucideLoaderPinwheel:tK,LucideLocate:aK,LucideLocateFixed:rK,LucideLocateOff:nK,LucideLock:$u,LucideLockKeyhole:iK,LucideLockKeyholeOpen:O2,LucideLockOpen:R2,LucideLogIn:w5,LucideLogOut:j5,LucideLogs:oK,LucideLollipop:lK,LucideLuggage:cK,LucideMSquare:Dj,LucideMagnet:dK,LucideMail:br,LucideMailCheck:uK,LucideMailMinus:hK,LucideMailOpen:mK,LucideMailPlus:pK,LucideMailQuestion:fK,LucideMailSearch:gK,LucideMailWarning:xK,LucideMailX:_P,LucideMailbox:yK,LucideMails:vK,LucideMap:EK,LucideMapPin:Oi,LucideMapPinCheck:bK,LucideMapPinCheckInside:_K,LucideMapPinHouse:wK,LucideMapPinMinus:NK,LucideMapPinMinusInside:jK,LucideMapPinOff:kK,LucideMapPinPlus:CK,LucideMapPinPlusInside:SK,LucideMapPinX:TK,LucideMapPinXInside:MK,LucideMapPinned:AK,LucideMartini:PK,LucideMaximize:bP,LucideMaximize2:IK,LucideMedal:R0,LucideMegaphone:Rm,LucideMegaphoneOff:LK,LucideMeh:DK,LucideMemoryStick:OK,LucideMenu:wP,LucideMenuSquare:Oj,LucideMerge:RK,LucideMessageCircle:xc,LucideMessageCircleCode:FK,LucideMessageCircleDashed:zK,LucideMessageCircleHeart:N5,LucideMessageCircleMore:BK,LucideMessageCircleOff:$K,LucideMessageCirclePlus:qK,LucideMessageCircleQuestion:jP,LucideMessageCircleReply:UK,LucideMessageCircleWarning:VK,LucideMessageCircleX:HK,LucideMessageSquare:io,LucideMessageSquareCode:WK,LucideMessageSquareDashed:GK,LucideMessageSquareDiff:KK,LucideMessageSquareDot:ZK,LucideMessageSquareHeart:YK,LucideMessageSquareLock:XK,LucideMessageSquareMore:NP,LucideMessageSquareOff:QK,LucideMessageSquarePlus:k5,LucideMessageSquareQuote:kP,LucideMessageSquareReply:JK,LucideMessageSquareShare:eZ,LucideMessageSquareText:tZ,LucideMessageSquareWarning:sZ,LucideMessageSquareX:rZ,LucideMessagesSquare:nZ,LucideMic:SP,LucideMic2:F2,LucideMicOff:aZ,LucideMicVocal:F2,LucideMicrochip:iZ,LucideMicroscope:oZ,LucideMicrowave:lZ,LucideMilestone:cZ,LucideMilk:uZ,LucideMilkOff:dZ,LucideMinimize:mZ,LucideMinimize2:hZ,LucideMinus:F0,LucideMinusCircle:Yw,LucideMinusSquare:Rj,LucideMonitor:hk,LucideMonitorCheck:pZ,LucideMonitorCog:fZ,LucideMonitorDot:gZ,LucideMonitorDown:xZ,LucideMonitorOff:yZ,LucideMonitorPause:vZ,LucideMonitorPlay:_Z,LucideMonitorSmartphone:bZ,LucideMonitorSpeaker:wZ,LucideMonitorStop:jZ,LucideMonitorUp:NZ,LucideMonitorX:kZ,LucideMoon:CZ,LucideMoonStar:SZ,LucideMoreHorizontal:of,LucideMoreVertical:af,LucideMountain:TZ,LucideMountainSnow:MZ,LucideMouse:IZ,LucideMouseOff:AZ,LucideMousePointer:th,LucideMousePointer2:EZ,LucideMousePointerBan:PZ,LucideMousePointerClick:c_,LucideMousePointerSquareDashed:Cj,LucideMove:WZ,LucideMove3D:z2,LucideMove3d:z2,LucideMoveDiagonal:DZ,LucideMoveDiagonal2:LZ,LucideMoveDown:FZ,LucideMoveDownLeft:OZ,LucideMoveDownRight:RZ,LucideMoveHorizontal:zZ,LucideMoveLeft:BZ,LucideMoveRight:$Z,LucideMoveUp:VZ,LucideMoveUpLeft:qZ,LucideMoveUpRight:UZ,LucideMoveVertical:HZ,LucideMusic:YZ,LucideMusic2:GZ,LucideMusic3:KZ,LucideMusic4:ZZ,LucideNavigation:eY,LucideNavigation2:QZ,LucideNavigation2Off:XZ,LucideNavigationOff:JZ,LucideNetwork:tY,LucideNewspaper:z0,LucideNfc:sY,LucideNotebook:iY,LucideNotebookPen:rY,LucideNotebookTabs:nY,LucideNotebookText:aY,LucideNotepadText:lY,LucideNotepadTextDashed:oY,LucideNut:dY,LucideNutOff:cY,LucideOctagon:hY,LucideOctagonAlert:m0,LucideOctagonMinus:uY,LucideOctagonPause:B2,LucideOctagonX:$2,LucideOmega:mY,LucideOption:pY,LucideOrbit:fY,LucideOrigami:gY,LucideOutdent:I2,LucidePackage:dl,LucidePackage2:xY,LucidePackageCheck:yY,LucidePackageMinus:vY,LucidePackageOpen:_Y,LucidePackagePlus:bY,LucidePackageSearch:wY,LucidePackageX:jY,LucidePaintBucket:NY,LucidePaintRoller:kY,LucidePaintbrush:SY,LucidePaintbrush2:q2,LucidePaintbrushVertical:q2,LucidePalette:Bl,LucidePalmtree:aN,LucidePanelBottom:TY,LucidePanelBottomClose:CY,LucidePanelBottomDashed:U2,LucidePanelBottomInactive:U2,LucidePanelBottomOpen:MY,LucidePanelLeft:G2,LucidePanelLeftClose:V2,LucidePanelLeftDashed:H2,LucidePanelLeftInactive:H2,LucidePanelLeftOpen:W2,LucidePanelRight:PY,LucidePanelRightClose:AY,LucidePanelRightDashed:K2,LucidePanelRightInactive:K2,LucidePanelRightOpen:EY,LucidePanelTop:DY,LucidePanelTopClose:IY,LucidePanelTopDashed:Z2,LucidePanelTopInactive:Z2,LucidePanelTopOpen:LY,LucidePanelsLeftBottom:OY,LucidePanelsLeftRight:m2,LucidePanelsRightBottom:RY,LucidePanelsTopBottom:ej,LucidePanelsTopLeft:p0,LucidePaperclip:mk,LucideParentheses:FY,LucideParkingCircle:Qw,LucideParkingCircleOff:Xw,LucideParkingMeter:zY,LucideParkingSquare:Bj,LucideParkingSquareOff:zj,LucidePartyPopper:kd,LucidePause:vp,LucidePauseCircle:Jw,LucidePauseOctagon:B2,LucidePawPrint:BY,LucidePcCase:$Y,LucidePen:Fx,LucidePenBox:Rc,LucidePenLine:f0,LucidePenOff:qY,LucidePenSquare:Rc,LucidePenTool:d_,LucidePencil:Da,LucidePencilLine:UY,LucidePencilOff:VY,LucidePencilRuler:HY,LucidePentagon:WY,LucidePercent:S5,LucidePercentCircle:e2,LucidePercentDiamond:f2,LucidePercentSquare:$j,LucidePersonStanding:GY,LucidePhilippinePeso:KY,LucidePhone:Qn,LucidePhoneCall:ZY,LucidePhoneForwarded:YY,LucidePhoneIncoming:XY,LucidePhoneMissed:QY,LucidePhoneOff:JY,LucidePhoneOutgoing:eX,LucidePi:tX,LucidePiSquare:qj,LucidePiano:sX,LucidePickaxe:rX,LucidePictureInPicture:aX,LucidePictureInPicture2:nX,LucidePieChart:Lw,LucidePiggyBank:iX,LucidePilcrow:cX,LucidePilcrowLeft:oX,LucidePilcrowRight:lX,LucidePilcrowSquare:Uj,LucidePill:uX,LucidePillBottle:dX,LucidePin:u_,LucidePinOff:CP,LucidePipette:hX,LucidePizza:mX,LucidePlane:gX,LucidePlaneLanding:pX,LucidePlaneTakeoff:fX,LucidePlay:ul,LucidePlayCircle:bm,LucidePlaySquare:Vj,LucidePlug:MP,LucidePlug2:xX,LucidePlugZap:Y2,LucidePlugZap2:Y2,LucidePlus:Zs,LucidePlusCircle:t2,LucidePlusSquare:Hj,LucidePocket:vX,LucidePocketKnife:yX,LucidePodcast:_X,LucidePointer:wX,LucidePointerOff:bX,LucidePopcorn:jX,LucidePopsicle:NX,LucidePoundSterling:kX,LucidePower:TP,LucidePowerCircle:s2,LucidePowerOff:SX,LucidePowerSquare:Wj,LucidePresentation:Hg,LucidePrinter:AP,LucidePrinterCheck:CX,LucideProjector:MX,LucideProportions:TX,LucidePuzzle:AX,LucidePyramid:EX,LucideQrCode:B0,LucideQuote:C5,LucideRabbit:PX,LucideRadar:IX,LucideRadiation:LX,LucideRadical:DX,LucideRadio:$0,LucideRadioReceiver:OX,LucideRadioTower:RX,LucideRadius:FX,LucideRailSymbol:zX,LucideRainbow:BX,LucideRat:$X,LucideRatio:qX,LucideReceipt:XX,LucideReceiptCent:UX,LucideReceiptEuro:VX,LucideReceiptIndianRupee:HX,LucideReceiptJapaneseYen:WX,LucideReceiptPoundSterling:GX,LucideReceiptRussianRuble:KX,LucideReceiptSwissFranc:ZX,LucideReceiptText:YX,LucideRectangleEllipsis:X2,LucideRectangleHorizontal:QX,LucideRectangleVertical:JX,LucideRecycle:eQ,LucideRedo:M5,LucideRedo2:tQ,LucideRedoDot:sQ,LucideRefreshCcw:nQ,LucideRefreshCcwDot:rQ,LucideRefreshCw:Po,LucideRefreshCwOff:aQ,LucideRefrigerator:iQ,LucideRegex:oQ,LucideRemoveFormatting:lQ,LucideRepeat:EP,LucideRepeat1:cQ,LucideRepeat2:dQ,LucideReplace:hQ,LucideReplaceAll:uQ,LucideReply:PP,LucideReplyAll:mQ,LucideRewind:pQ,LucideRibbon:fQ,LucideRocket:Qx,LucideRockingChair:gQ,LucideRollerCoaster:xQ,LucideRotate3D:Q2,LucideRotate3d:Q2,LucideRotateCcw:q0,LucideRotateCcwSquare:yQ,LucideRotateCw:IP,LucideRotateCwSquare:vQ,LucideRoute:bQ,LucideRouteOff:_Q,LucideRouter:wQ,LucideRows:J2,LucideRows2:J2,LucideRows3:ej,LucideRows4:jQ,LucideRss:NQ,LucideRuler:LP,LucideRussianRuble:kQ,LucideSailboat:SQ,LucideSalad:CQ,LucideSandwich:MQ,LucideSatellite:AQ,LucideSatelliteDish:TQ,LucideSave:fu,LucideSaveAll:EQ,LucideSaveOff:PQ,LucideScale:DP,LucideScale3D:tj,LucideScale3d:tj,LucideScaling:IQ,LucideScan:$Q,LucideScanBarcode:LQ,LucideScanEye:DQ,LucideScanFace:OQ,LucideScanLine:RQ,LucideScanQrCode:FQ,LucideScanSearch:zQ,LucideScanText:BQ,LucideScatterChart:Dw,LucideSchool:qQ,LucideSchool2:oN,LucideScissors:VQ,LucideScissorsLineDashed:UQ,LucideScissorsSquare:Gj,LucideScissorsSquareDashedBottom:vj,LucideScreenShare:WQ,LucideScreenShareOff:HQ,LucideScroll:KQ,LucideScrollText:GQ,LucideSearch:gn,LucideSearchCheck:ZQ,LucideSearchCode:YQ,LucideSearchSlash:XQ,LucideSearchX:OP,LucideSection:QQ,LucideSend:aa,LucideSendHorizonal:sj,LucideSendHorizontal:sj,LucideSendToBack:JQ,LucideSeparatorHorizontal:eJ,LucideSeparatorVertical:tJ,LucideServer:aJ,LucideServerCog:sJ,LucideServerCrash:rJ,LucideServerOff:nJ,LucideSettings:$l,LucideSettings2:RP,LucideShapes:iJ,LucideShare:FP,LucideShare2:ld,LucideSheet:oJ,LucideShell:lJ,LucideShield:ih,LucideShieldAlert:cJ,LucideShieldBan:dJ,LucideShieldCheck:zP,LucideShieldClose:rj,LucideShieldEllipsis:uJ,LucideShieldHalf:hJ,LucideShieldMinus:mJ,LucideShieldOff:pJ,LucideShieldPlus:fJ,LucideShieldQuestion:gJ,LucideShieldX:rj,LucideShip:yJ,LucideShipWheel:xJ,LucideShirt:vJ,LucideShoppingBag:Jx,LucideShoppingBasket:_J,LucideShoppingCart:Sm,LucideShovel:bJ,LucideShowerHead:wJ,LucideShrink:jJ,LucideShrub:NJ,LucideShuffle:pk,LucideSidebar:G2,LucideSidebarClose:V2,LucideSidebarOpen:W2,LucideSigma:kJ,LucideSigmaSquare:Kj,LucideSignal:AJ,LucideSignalHigh:SJ,LucideSignalLow:CJ,LucideSignalMedium:MJ,LucideSignalZero:TJ,LucideSignature:EJ,LucideSignpost:IJ,LucideSignpostBig:PJ,LucideSiren:LJ,LucideSkipBack:DJ,LucideSkipForward:OJ,LucideSkull:RJ,LucideSlack:FJ,LucideSlash:zJ,LucideSlashSquare:Zj,LucideSlice:BJ,LucideSliders:nj,LucideSlidersHorizontal:BP,LucideSlidersVertical:nj,LucideSmartphone:U0,LucideSmartphoneCharging:$J,LucideSmartphoneNfc:qJ,LucideSmile:VJ,LucideSmilePlus:UJ,LucideSnail:HJ,LucideSnowflake:$1,LucideSofa:WJ,LucideSortAsc:fw,LucideSortDesc:hw,LucideSoup:GJ,LucideSpace:KJ,LucideSpade:ZJ,LucideSparkle:YJ,LucideSparkles:hn,LucideSpeaker:XJ,LucideSpeech:QJ,LucideSpellCheck:eee,LucideSpellCheck2:JJ,LucideSpline:tee,LucideSplit:see,LucideSplitSquareHorizontal:Yj,LucideSplitSquareVertical:Xj,LucideSprayCan:ree,LucideSprout:nee,LucideSquare:ey,LucideSquareActivity:aj,LucideSquareArrowDown:lj,LucideSquareArrowDownLeft:ij,LucideSquareArrowDownRight:oj,LucideSquareArrowLeft:cj,LucideSquareArrowOutDownLeft:dj,LucideSquareArrowOutDownRight:uj,LucideSquareArrowOutUpLeft:hj,LucideSquareArrowOutUpRight:mj,LucideSquareArrowRight:pj,LucideSquareArrowUp:xj,LucideSquareArrowUpLeft:fj,LucideSquareArrowUpRight:gj,LucideSquareAsterisk:yj,LucideSquareBottomDashedScissors:vj,LucideSquareChartGantt:Mx,LucideSquareCheck:_j,LucideSquareCheckBig:g0,LucideSquareChevronDown:bj,LucideSquareChevronLeft:wj,LucideSquareChevronRight:jj,LucideSquareChevronUp:Nj,LucideSquareCode:kj,LucideSquareDashed:Mj,LucideSquareDashedBottom:iee,LucideSquareDashedBottomCode:aee,LucideSquareDashedKanban:Sj,LucideSquareDashedMousePointer:Cj,LucideSquareDivide:Tj,LucideSquareDot:Aj,LucideSquareEqual:Ej,LucideSquareFunction:Pj,LucideSquareGanttChart:Mx,LucideSquareKanban:Ij,LucideSquareLibrary:Lj,LucideSquareM:Dj,LucideSquareMenu:Oj,LucideSquareMinus:Rj,LucideSquareMousePointer:Fj,LucideSquareParking:Bj,LucideSquareParkingOff:zj,LucideSquarePen:Rc,LucideSquarePercent:$j,LucideSquarePi:qj,LucideSquarePilcrow:Uj,LucideSquarePlay:Vj,LucideSquarePlus:Hj,LucideSquarePower:Wj,LucideSquareRadical:oee,LucideSquareScissors:Gj,LucideSquareSigma:Kj,LucideSquareSlash:Zj,LucideSquareSplitHorizontal:Yj,LucideSquareSplitVertical:Xj,LucideSquareSquare:lee,LucideSquareStack:cee,LucideSquareTerminal:Qj,LucideSquareUser:eN,LucideSquareUserRound:Jj,LucideSquareX:tN,LucideSquircle:dee,LucideSquirrel:uee,LucideStamp:hee,LucideStar:Gn,LucideStarHalf:mee,LucideStarOff:pee,LucideStars:hn,LucideStepBack:fee,LucideStepForward:gee,LucideStethoscope:xee,LucideSticker:yee,LucideStickyNote:vee,LucideStopCircle:n2,LucideStore:_ee,LucideStretchHorizontal:bee,LucideStretchVertical:wee,LucideStrikethrough:jee,LucideSubscript:Nee,LucideSubtitles:jw,LucideSun:h_,LucideSunDim:kee,LucideSunMedium:See,LucideSunMoon:Cee,LucideSunSnow:Mee,LucideSunrise:Tee,LucideSunset:Aee,LucideSuperscript:Eee,LucideSwatchBook:Pee,LucideSwissFranc:Iee,LucideSwitchCamera:Lee,LucideSword:Dee,LucideSwords:Oee,LucideSyringe:Ree,LucideTable:$P,LucideTable2:T5,LucideTableCellsMerge:Fee,LucideTableCellsSplit:zee,LucideTableColumnsSplit:Bee,LucideTableOfContents:$ee,LucideTableProperties:qee,LucideTableRowsSplit:Uee,LucideTablet:Hee,LucideTabletSmartphone:Vee,LucideTablets:Wee,LucideTag:Wh,LucideTags:Gee,LucideTally1:Kee,LucideTally2:Zee,LucideTally3:Yee,LucideTally4:Xee,LucideTally5:Qee,LucideTangent:Jee,LucideTarget:Gh,LucideTelescope:ete,LucideTent:ste,LucideTentTree:tte,LucideTerminal:rte,LucideTerminalSquare:Qj,LucideTestTube:nte,LucideTestTube2:sN,LucideTestTubeDiagonal:sN,LucideTestTubes:ate,LucideText:dte,LucideTextCursor:ote,LucideTextCursorInput:ite,LucideTextQuote:lte,LucideTextSearch:cte,LucideTextSelect:rN,LucideTextSelection:rN,LucideTheater:ute,LucideThermometer:pte,LucideThermometerSnowflake:hte,LucideThermometerSun:mte,LucideThumbsDown:qP,LucideThumbsUp:gu,LucideTicket:UP,LucideTicketCheck:fte,LucideTicketMinus:gte,LucideTicketPercent:xte,LucideTicketPlus:yte,LucideTicketSlash:vte,LucideTicketX:_te,LucideTickets:wte,LucideTicketsPlane:bte,LucideTimer:kte,LucideTimerOff:jte,LucideTimerReset:Nte,LucideToggleLeft:Ste,LucideToggleRight:Cte,LucideToilet:Mte,LucideTornado:Tte,LucideTorus:Ate,LucideTouchpad:Pte,LucideTouchpadOff:Ete,LucideTowerControl:Ite,LucideToyBrick:Lte,LucideTractor:Dte,LucideTrafficCone:Ote,LucideTrain:nN,LucideTrainFront:Fte,LucideTrainFrontTunnel:Rte,LucideTrainTrack:zte,LucideTramFront:nN,LucideTrash:Bte,LucideTrash2:jr,LucideTreeDeciduous:$te,LucideTreePalm:aN,LucideTreePine:m_,LucideTrees:qte,LucideTrello:Ute,LucideTrendingDown:fk,LucideTrendingUp:ac,LucideTrendingUpDown:Vte,LucideTriangle:Wte,LucideTriangleAlert:Ju,LucideTriangleRight:Hte,LucideTrophy:ao,LucideTruck:VP,LucideTurtle:Gte,LucideTv:Zte,LucideTv2:iN,LucideTvMinimal:iN,LucideTvMinimalPlay:Kte,LucideTwitch:Yte,LucideTwitter:Xte,LucideType:Jte,LucideTypeOutline:Qte,LucideUmbrella:tse,LucideUmbrellaOff:ese,LucideUnderline:sse,LucideUndo:A5,LucideUndo2:rse,LucideUndoDot:nse,LucideUnfoldHorizontal:ase,LucideUnfoldVertical:ise,LucideUngroup:ose,LucideUniversity:oN,LucideUnlink:gk,LucideUnlink2:lse,LucideUnlock:R2,LucideUnlockKeyhole:O2,LucideUnplug:cse,LucideUpload:Za,LucideUploadCloud:d2,LucideUsb:dse,LucideUser:Yi,LucideUser2:mN,LucideUserCheck:p_,LucideUserCheck2:lN,LucideUserCircle:i2,LucideUserCircle2:a2,LucideUserCog:HP,LucideUserCog2:cN,LucideUserMinus:WP,LucideUserMinus2:dN,LucideUserPen:use,LucideUserPlus:yc,LucideUserPlus2:uN,LucideUserRound:mN,LucideUserRoundCheck:lN,LucideUserRoundCog:cN,LucideUserRoundMinus:dN,LucideUserRoundPen:hse,LucideUserRoundPlus:uN,LucideUserRoundSearch:mse,LucideUserRoundX:hN,LucideUserSearch:pse,LucideUserSquare:eN,LucideUserSquare2:Jj,LucideUserX:fse,LucideUserX2:hN,LucideUsers:hr,LucideUsers2:pN,LucideUsersRound:pN,LucideUtensils:gN,LucideUtensilsCrossed:fN,LucideUtilityPole:gse,LucideVariable:GP,LucideVault:xse,LucideVegan:yse,LucideVenetianMask:vse,LucideVerified:yw,LucideVibrate:bse,LucideVibrateOff:_se,LucideVideo:Nn,LucideVideoOff:wse,LucideVideotape:jse,LucideView:Nse,LucideVoicemail:kse,LucideVolleyball:Sse,LucideVolume:Ese,LucideVolume1:Cse,LucideVolume2:Mse,LucideVolumeOff:Tse,LucideVolumeX:Ase,LucideVote:Pse,LucideWallet:KP,LucideWallet2:xN,LucideWalletCards:Ise,LucideWalletMinimal:xN,LucideWallpaper:Lse,LucideWand:Dse,LucideWand2:x0,LucideWandSparkles:x0,LucideWarehouse:Ose,LucideWashingMachine:Rse,LucideWatch:Fse,LucideWaves:zse,LucideWaypoints:Bse,LucideWebcam:$se,LucideWebhook:Use,LucideWebhookOff:qse,LucideWeight:Vse,LucideWheat:Wse,LucideWheatOff:Hse,LucideWholeWord:Gse,LucideWifi:Qse,LucideWifiHigh:Kse,LucideWifiLow:Zse,LucideWifiOff:Yse,LucideWifiZero:Xse,LucideWind:ere,LucideWindArrowDown:Jse,LucideWine:sre,LucideWineOff:tre,LucideWorkflow:rre,LucideWorm:nre,LucideWrapText:are,LucideWrench:Wg,LucideX:Ur,LucideXCircle:kc,LucideXOctagon:$2,LucideXSquare:tN,LucideYoutube:ire,LucideZap:Fm,LucideZapOff:ore,LucideZoomIn:f_,LucideZoomOut:E5,Luggage:cK,LuggageIcon:cK,MSquare:Dj,MSquareIcon:Dj,Magnet:dK,MagnetIcon:dK,Mail:br,MailCheck:uK,MailCheckIcon:uK,MailIcon:br,MailMinus:hK,MailMinusIcon:hK,MailOpen:mK,MailOpenIcon:mK,MailPlus:pK,MailPlusIcon:pK,MailQuestion:fK,MailQuestionIcon:fK,MailSearch:gK,MailSearchIcon:gK,MailWarning:xK,MailWarningIcon:xK,MailX:_P,MailXIcon:_P,Mailbox:yK,MailboxIcon:yK,Mails:vK,MailsIcon:vK,Map:EK,MapIcon:EK,MapPin:Oi,MapPinCheck:bK,MapPinCheckIcon:bK,MapPinCheckInside:_K,MapPinCheckInsideIcon:_K,MapPinHouse:wK,MapPinHouseIcon:wK,MapPinIcon:Oi,MapPinMinus:NK,MapPinMinusIcon:NK,MapPinMinusInside:jK,MapPinMinusInsideIcon:jK,MapPinOff:kK,MapPinOffIcon:kK,MapPinPlus:CK,MapPinPlusIcon:CK,MapPinPlusInside:SK,MapPinPlusInsideIcon:SK,MapPinX:TK,MapPinXIcon:TK,MapPinXInside:MK,MapPinXInsideIcon:MK,MapPinned:AK,MapPinnedIcon:AK,Martini:PK,MartiniIcon:PK,Maximize:bP,Maximize2:IK,Maximize2Icon:IK,MaximizeIcon:bP,Medal:R0,MedalIcon:R0,Megaphone:Rm,MegaphoneIcon:Rm,MegaphoneOff:LK,MegaphoneOffIcon:LK,Meh:DK,MehIcon:DK,MemoryStick:OK,MemoryStickIcon:OK,Menu:wP,MenuIcon:wP,MenuSquare:Oj,MenuSquareIcon:Oj,Merge:RK,MergeIcon:RK,MessageCircle:xc,MessageCircleCode:FK,MessageCircleCodeIcon:FK,MessageCircleDashed:zK,MessageCircleDashedIcon:zK,MessageCircleHeart:N5,MessageCircleHeartIcon:N5,MessageCircleIcon:xc,MessageCircleMore:BK,MessageCircleMoreIcon:BK,MessageCircleOff:$K,MessageCircleOffIcon:$K,MessageCirclePlus:qK,MessageCirclePlusIcon:qK,MessageCircleQuestion:jP,MessageCircleQuestionIcon:jP,MessageCircleReply:UK,MessageCircleReplyIcon:UK,MessageCircleWarning:VK,MessageCircleWarningIcon:VK,MessageCircleX:HK,MessageCircleXIcon:HK,MessageSquare:io,MessageSquareCode:WK,MessageSquareCodeIcon:WK,MessageSquareDashed:GK,MessageSquareDashedIcon:GK,MessageSquareDiff:KK,MessageSquareDiffIcon:KK,MessageSquareDot:ZK,MessageSquareDotIcon:ZK,MessageSquareHeart:YK,MessageSquareHeartIcon:YK,MessageSquareIcon:io,MessageSquareLock:XK,MessageSquareLockIcon:XK,MessageSquareMore:NP,MessageSquareMoreIcon:NP,MessageSquareOff:QK,MessageSquareOffIcon:QK,MessageSquarePlus:k5,MessageSquarePlusIcon:k5,MessageSquareQuote:kP,MessageSquareQuoteIcon:kP,MessageSquareReply:JK,MessageSquareReplyIcon:JK,MessageSquareShare:eZ,MessageSquareShareIcon:eZ,MessageSquareText:tZ,MessageSquareTextIcon:tZ,MessageSquareWarning:sZ,MessageSquareWarningIcon:sZ,MessageSquareX:rZ,MessageSquareXIcon:rZ,MessagesSquare:nZ,MessagesSquareIcon:nZ,Mic:SP,Mic2:F2,Mic2Icon:F2,MicIcon:SP,MicOff:aZ,MicOffIcon:aZ,MicVocal:F2,MicVocalIcon:F2,Microchip:iZ,MicrochipIcon:iZ,Microscope:oZ,MicroscopeIcon:oZ,Microwave:lZ,MicrowaveIcon:lZ,Milestone:cZ,MilestoneIcon:cZ,Milk:uZ,MilkIcon:uZ,MilkOff:dZ,MilkOffIcon:dZ,Minimize:mZ,Minimize2:hZ,Minimize2Icon:hZ,MinimizeIcon:mZ,Minus:F0,MinusCircle:Yw,MinusCircleIcon:Yw,MinusIcon:F0,MinusSquare:Rj,MinusSquareIcon:Rj,Monitor:hk,MonitorCheck:pZ,MonitorCheckIcon:pZ,MonitorCog:fZ,MonitorCogIcon:fZ,MonitorDot:gZ,MonitorDotIcon:gZ,MonitorDown:xZ,MonitorDownIcon:xZ,MonitorIcon:hk,MonitorOff:yZ,MonitorOffIcon:yZ,MonitorPause:vZ,MonitorPauseIcon:vZ,MonitorPlay:_Z,MonitorPlayIcon:_Z,MonitorSmartphone:bZ,MonitorSmartphoneIcon:bZ,MonitorSpeaker:wZ,MonitorSpeakerIcon:wZ,MonitorStop:jZ,MonitorStopIcon:jZ,MonitorUp:NZ,MonitorUpIcon:NZ,MonitorX:kZ,MonitorXIcon:kZ,Moon:CZ,MoonIcon:CZ,MoonStar:SZ,MoonStarIcon:SZ,MoreHorizontal:of,MoreHorizontalIcon:of,MoreVertical:af,MoreVerticalIcon:af,Mountain:TZ,MountainIcon:TZ,MountainSnow:MZ,MountainSnowIcon:MZ,Mouse:IZ,MouseIcon:IZ,MouseOff:AZ,MouseOffIcon:AZ,MousePointer:th,MousePointer2:EZ,MousePointer2Icon:EZ,MousePointerBan:PZ,MousePointerBanIcon:PZ,MousePointerClick:c_,MousePointerClickIcon:c_,MousePointerIcon:th,MousePointerSquareDashed:Cj,MousePointerSquareDashedIcon:Cj,Move:WZ,Move3D:z2,Move3DIcon:z2,Move3d:z2,Move3dIcon:z2,MoveDiagonal:DZ,MoveDiagonal2:LZ,MoveDiagonal2Icon:LZ,MoveDiagonalIcon:DZ,MoveDown:FZ,MoveDownIcon:FZ,MoveDownLeft:OZ,MoveDownLeftIcon:OZ,MoveDownRight:RZ,MoveDownRightIcon:RZ,MoveHorizontal:zZ,MoveHorizontalIcon:zZ,MoveIcon:WZ,MoveLeft:BZ,MoveLeftIcon:BZ,MoveRight:$Z,MoveRightIcon:$Z,MoveUp:VZ,MoveUpIcon:VZ,MoveUpLeft:qZ,MoveUpLeftIcon:qZ,MoveUpRight:UZ,MoveUpRightIcon:UZ,MoveVertical:HZ,MoveVerticalIcon:HZ,Music:YZ,Music2:GZ,Music2Icon:GZ,Music3:KZ,Music3Icon:KZ,Music4:ZZ,Music4Icon:ZZ,MusicIcon:YZ,Navigation:eY,Navigation2:QZ,Navigation2Icon:QZ,Navigation2Off:XZ,Navigation2OffIcon:XZ,NavigationIcon:eY,NavigationOff:JZ,NavigationOffIcon:JZ,Network:tY,NetworkIcon:tY,Newspaper:z0,NewspaperIcon:z0,Nfc:sY,NfcIcon:sY,Notebook:iY,NotebookIcon:iY,NotebookPen:rY,NotebookPenIcon:rY,NotebookTabs:nY,NotebookTabsIcon:nY,NotebookText:aY,NotebookTextIcon:aY,NotepadText:lY,NotepadTextDashed:oY,NotepadTextDashedIcon:oY,NotepadTextIcon:lY,Nut:dY,NutIcon:dY,NutOff:cY,NutOffIcon:cY,Octagon:hY,OctagonAlert:m0,OctagonAlertIcon:m0,OctagonIcon:hY,OctagonMinus:uY,OctagonMinusIcon:uY,OctagonPause:B2,OctagonPauseIcon:B2,OctagonX:$2,OctagonXIcon:$2,Omega:mY,OmegaIcon:mY,Option:pY,OptionIcon:pY,Orbit:fY,OrbitIcon:fY,Origami:gY,OrigamiIcon:gY,Outdent:I2,OutdentIcon:I2,Package:dl,Package2:xY,Package2Icon:xY,PackageCheck:yY,PackageCheckIcon:yY,PackageIcon:dl,PackageMinus:vY,PackageMinusIcon:vY,PackageOpen:_Y,PackageOpenIcon:_Y,PackagePlus:bY,PackagePlusIcon:bY,PackageSearch:wY,PackageSearchIcon:wY,PackageX:jY,PackageXIcon:jY,PaintBucket:NY,PaintBucketIcon:NY,PaintRoller:kY,PaintRollerIcon:kY,Paintbrush:SY,Paintbrush2:q2,Paintbrush2Icon:q2,PaintbrushIcon:SY,PaintbrushVertical:q2,PaintbrushVerticalIcon:q2,Palette:Bl,PaletteIcon:Bl,Palmtree:aN,PalmtreeIcon:aN,PanelBottom:TY,PanelBottomClose:CY,PanelBottomCloseIcon:CY,PanelBottomDashed:U2,PanelBottomDashedIcon:U2,PanelBottomIcon:TY,PanelBottomInactive:U2,PanelBottomInactiveIcon:U2,PanelBottomOpen:MY,PanelBottomOpenIcon:MY,PanelLeft:G2,PanelLeftClose:V2,PanelLeftCloseIcon:V2,PanelLeftDashed:H2,PanelLeftDashedIcon:H2,PanelLeftIcon:G2,PanelLeftInactive:H2,PanelLeftInactiveIcon:H2,PanelLeftOpen:W2,PanelLeftOpenIcon:W2,PanelRight:PY,PanelRightClose:AY,PanelRightCloseIcon:AY,PanelRightDashed:K2,PanelRightDashedIcon:K2,PanelRightIcon:PY,PanelRightInactive:K2,PanelRightInactiveIcon:K2,PanelRightOpen:EY,PanelRightOpenIcon:EY,PanelTop:DY,PanelTopClose:IY,PanelTopCloseIcon:IY,PanelTopDashed:Z2,PanelTopDashedIcon:Z2,PanelTopIcon:DY,PanelTopInactive:Z2,PanelTopInactiveIcon:Z2,PanelTopOpen:LY,PanelTopOpenIcon:LY,PanelsLeftBottom:OY,PanelsLeftBottomIcon:OY,PanelsLeftRight:m2,PanelsLeftRightIcon:m2,PanelsRightBottom:RY,PanelsRightBottomIcon:RY,PanelsTopBottom:ej,PanelsTopBottomIcon:ej,PanelsTopLeft:p0,PanelsTopLeftIcon:p0,Paperclip:mk,PaperclipIcon:mk,Parentheses:FY,ParenthesesIcon:FY,ParkingCircle:Qw,ParkingCircleIcon:Qw,ParkingCircleOff:Xw,ParkingCircleOffIcon:Xw,ParkingMeter:zY,ParkingMeterIcon:zY,ParkingSquare:Bj,ParkingSquareIcon:Bj,ParkingSquareOff:zj,ParkingSquareOffIcon:zj,PartyPopper:kd,PartyPopperIcon:kd,Pause:vp,PauseCircle:Jw,PauseCircleIcon:Jw,PauseIcon:vp,PauseOctagon:B2,PauseOctagonIcon:B2,PawPrint:BY,PawPrintIcon:BY,PcCase:$Y,PcCaseIcon:$Y,Pen:Fx,PenBox:Rc,PenBoxIcon:Rc,PenIcon:Fx,PenLine:f0,PenLineIcon:f0,PenOff:qY,PenOffIcon:qY,PenSquare:Rc,PenSquareIcon:Rc,PenTool:d_,PenToolIcon:d_,Pencil:Da,PencilIcon:Da,PencilLine:UY,PencilLineIcon:UY,PencilOff:VY,PencilOffIcon:VY,PencilRuler:HY,PencilRulerIcon:HY,Pentagon:WY,PentagonIcon:WY,Percent:S5,PercentCircle:e2,PercentCircleIcon:e2,PercentDiamond:f2,PercentDiamondIcon:f2,PercentIcon:S5,PercentSquare:$j,PercentSquareIcon:$j,PersonStanding:GY,PersonStandingIcon:GY,PhilippinePeso:KY,PhilippinePesoIcon:KY,Phone:Qn,PhoneCall:ZY,PhoneCallIcon:ZY,PhoneForwarded:YY,PhoneForwardedIcon:YY,PhoneIcon:Qn,PhoneIncoming:XY,PhoneIncomingIcon:XY,PhoneMissed:QY,PhoneMissedIcon:QY,PhoneOff:JY,PhoneOffIcon:JY,PhoneOutgoing:eX,PhoneOutgoingIcon:eX,Pi:tX,PiIcon:tX,PiSquare:qj,PiSquareIcon:qj,Piano:sX,PianoIcon:sX,Pickaxe:rX,PickaxeIcon:rX,PictureInPicture:aX,PictureInPicture2:nX,PictureInPicture2Icon:nX,PictureInPictureIcon:aX,PieChart:Lw,PieChartIcon:Lw,PiggyBank:iX,PiggyBankIcon:iX,Pilcrow:cX,PilcrowIcon:cX,PilcrowLeft:oX,PilcrowLeftIcon:oX,PilcrowRight:lX,PilcrowRightIcon:lX,PilcrowSquare:Uj,PilcrowSquareIcon:Uj,Pill:uX,PillBottle:dX,PillBottleIcon:dX,PillIcon:uX,Pin:u_,PinIcon:u_,PinOff:CP,PinOffIcon:CP,Pipette:hX,PipetteIcon:hX,Pizza:mX,PizzaIcon:mX,Plane:gX,PlaneIcon:gX,PlaneLanding:pX,PlaneLandingIcon:pX,PlaneTakeoff:fX,PlaneTakeoffIcon:fX,Play:ul,PlayCircle:bm,PlayCircleIcon:bm,PlayIcon:ul,PlaySquare:Vj,PlaySquareIcon:Vj,Plug:MP,Plug2:xX,Plug2Icon:xX,PlugIcon:MP,PlugZap:Y2,PlugZap2:Y2,PlugZap2Icon:Y2,PlugZapIcon:Y2,Plus:Zs,PlusCircle:t2,PlusCircleIcon:t2,PlusIcon:Zs,PlusSquare:Hj,PlusSquareIcon:Hj,Pocket:vX,PocketIcon:vX,PocketKnife:yX,PocketKnifeIcon:yX,Podcast:_X,PodcastIcon:_X,Pointer:wX,PointerIcon:wX,PointerOff:bX,PointerOffIcon:bX,Popcorn:jX,PopcornIcon:jX,Popsicle:NX,PopsicleIcon:NX,PoundSterling:kX,PoundSterlingIcon:kX,Power:TP,PowerCircle:s2,PowerCircleIcon:s2,PowerIcon:TP,PowerOff:SX,PowerOffIcon:SX,PowerSquare:Wj,PowerSquareIcon:Wj,Presentation:Hg,PresentationIcon:Hg,Printer:AP,PrinterCheck:CX,PrinterCheckIcon:CX,PrinterIcon:AP,Projector:MX,ProjectorIcon:MX,Proportions:TX,ProportionsIcon:TX,Puzzle:AX,PuzzleIcon:AX,Pyramid:EX,PyramidIcon:EX,QrCode:B0,QrCodeIcon:B0,Quote:C5,QuoteIcon:C5,Rabbit:PX,RabbitIcon:PX,Radar:IX,RadarIcon:IX,Radiation:LX,RadiationIcon:LX,Radical:DX,RadicalIcon:DX,Radio:$0,RadioIcon:$0,RadioReceiver:OX,RadioReceiverIcon:OX,RadioTower:RX,RadioTowerIcon:RX,Radius:FX,RadiusIcon:FX,RailSymbol:zX,RailSymbolIcon:zX,Rainbow:BX,RainbowIcon:BX,Rat:$X,RatIcon:$X,Ratio:qX,RatioIcon:qX,Receipt:XX,ReceiptCent:UX,ReceiptCentIcon:UX,ReceiptEuro:VX,ReceiptEuroIcon:VX,ReceiptIcon:XX,ReceiptIndianRupee:HX,ReceiptIndianRupeeIcon:HX,ReceiptJapaneseYen:WX,ReceiptJapaneseYenIcon:WX,ReceiptPoundSterling:GX,ReceiptPoundSterlingIcon:GX,ReceiptRussianRuble:KX,ReceiptRussianRubleIcon:KX,ReceiptSwissFranc:ZX,ReceiptSwissFrancIcon:ZX,ReceiptText:YX,ReceiptTextIcon:YX,RectangleEllipsis:X2,RectangleEllipsisIcon:X2,RectangleHorizontal:QX,RectangleHorizontalIcon:QX,RectangleVertical:JX,RectangleVerticalIcon:JX,Recycle:eQ,RecycleIcon:eQ,Redo:M5,Redo2:tQ,Redo2Icon:tQ,RedoDot:sQ,RedoDotIcon:sQ,RedoIcon:M5,RefreshCcw:nQ,RefreshCcwDot:rQ,RefreshCcwDotIcon:rQ,RefreshCcwIcon:nQ,RefreshCw:Po,RefreshCwIcon:Po,RefreshCwOff:aQ,RefreshCwOffIcon:aQ,Refrigerator:iQ,RefrigeratorIcon:iQ,Regex:oQ,RegexIcon:oQ,RemoveFormatting:lQ,RemoveFormattingIcon:lQ,Repeat:EP,Repeat1:cQ,Repeat1Icon:cQ,Repeat2:dQ,Repeat2Icon:dQ,RepeatIcon:EP,Replace:hQ,ReplaceAll:uQ,ReplaceAllIcon:uQ,ReplaceIcon:hQ,Reply:PP,ReplyAll:mQ,ReplyAllIcon:mQ,ReplyIcon:PP,Rewind:pQ,RewindIcon:pQ,Ribbon:fQ,RibbonIcon:fQ,Rocket:Qx,RocketIcon:Qx,RockingChair:gQ,RockingChairIcon:gQ,RollerCoaster:xQ,RollerCoasterIcon:xQ,Rotate3D:Q2,Rotate3DIcon:Q2,Rotate3d:Q2,Rotate3dIcon:Q2,RotateCcw:q0,RotateCcwIcon:q0,RotateCcwSquare:yQ,RotateCcwSquareIcon:yQ,RotateCw:IP,RotateCwIcon:IP,RotateCwSquare:vQ,RotateCwSquareIcon:vQ,Route:bQ,RouteIcon:bQ,RouteOff:_Q,RouteOffIcon:_Q,Router:wQ,RouterIcon:wQ,Rows:J2,Rows2:J2,Rows2Icon:J2,Rows3:ej,Rows3Icon:ej,Rows4:jQ,Rows4Icon:jQ,RowsIcon:J2,Rss:NQ,RssIcon:NQ,Ruler:LP,RulerIcon:LP,RussianRuble:kQ,RussianRubleIcon:kQ,Sailboat:SQ,SailboatIcon:SQ,Salad:CQ,SaladIcon:CQ,Sandwich:MQ,SandwichIcon:MQ,Satellite:AQ,SatelliteDish:TQ,SatelliteDishIcon:TQ,SatelliteIcon:AQ,Save:fu,SaveAll:EQ,SaveAllIcon:EQ,SaveIcon:fu,SaveOff:PQ,SaveOffIcon:PQ,Scale:DP,Scale3D:tj,Scale3DIcon:tj,Scale3d:tj,Scale3dIcon:tj,ScaleIcon:DP,Scaling:IQ,ScalingIcon:IQ,Scan:$Q,ScanBarcode:LQ,ScanBarcodeIcon:LQ,ScanEye:DQ,ScanEyeIcon:DQ,ScanFace:OQ,ScanFaceIcon:OQ,ScanIcon:$Q,ScanLine:RQ,ScanLineIcon:RQ,ScanQrCode:FQ,ScanQrCodeIcon:FQ,ScanSearch:zQ,ScanSearchIcon:zQ,ScanText:BQ,ScanTextIcon:BQ,ScatterChart:Dw,ScatterChartIcon:Dw,School:qQ,School2:oN,School2Icon:oN,SchoolIcon:qQ,Scissors:VQ,ScissorsIcon:VQ,ScissorsLineDashed:UQ,ScissorsLineDashedIcon:UQ,ScissorsSquare:Gj,ScissorsSquareDashedBottom:vj,ScissorsSquareDashedBottomIcon:vj,ScissorsSquareIcon:Gj,ScreenShare:WQ,ScreenShareIcon:WQ,ScreenShareOff:HQ,ScreenShareOffIcon:HQ,Scroll:KQ,ScrollIcon:KQ,ScrollText:GQ,ScrollTextIcon:GQ,Search:gn,SearchCheck:ZQ,SearchCheckIcon:ZQ,SearchCode:YQ,SearchCodeIcon:YQ,SearchIcon:gn,SearchSlash:XQ,SearchSlashIcon:XQ,SearchX:OP,SearchXIcon:OP,Section:QQ,SectionIcon:QQ,Send:aa,SendHorizonal:sj,SendHorizonalIcon:sj,SendHorizontal:sj,SendHorizontalIcon:sj,SendIcon:aa,SendToBack:JQ,SendToBackIcon:JQ,SeparatorHorizontal:eJ,SeparatorHorizontalIcon:eJ,SeparatorVertical:tJ,SeparatorVerticalIcon:tJ,Server:aJ,ServerCog:sJ,ServerCogIcon:sJ,ServerCrash:rJ,ServerCrashIcon:rJ,ServerIcon:aJ,ServerOff:nJ,ServerOffIcon:nJ,Settings:$l,Settings2:RP,Settings2Icon:RP,SettingsIcon:$l,Shapes:iJ,ShapesIcon:iJ,Share:FP,Share2:ld,Share2Icon:ld,ShareIcon:FP,Sheet:oJ,SheetIcon:oJ,Shell:lJ,ShellIcon:lJ,Shield:ih,ShieldAlert:cJ,ShieldAlertIcon:cJ,ShieldBan:dJ,ShieldBanIcon:dJ,ShieldCheck:zP,ShieldCheckIcon:zP,ShieldClose:rj,ShieldCloseIcon:rj,ShieldEllipsis:uJ,ShieldEllipsisIcon:uJ,ShieldHalf:hJ,ShieldHalfIcon:hJ,ShieldIcon:ih,ShieldMinus:mJ,ShieldMinusIcon:mJ,ShieldOff:pJ,ShieldOffIcon:pJ,ShieldPlus:fJ,ShieldPlusIcon:fJ,ShieldQuestion:gJ,ShieldQuestionIcon:gJ,ShieldX:rj,ShieldXIcon:rj,Ship:yJ,ShipIcon:yJ,ShipWheel:xJ,ShipWheelIcon:xJ,Shirt:vJ,ShirtIcon:vJ,ShoppingBag:Jx,ShoppingBagIcon:Jx,ShoppingBasket:_J,ShoppingBasketIcon:_J,ShoppingCart:Sm,ShoppingCartIcon:Sm,Shovel:bJ,ShovelIcon:bJ,ShowerHead:wJ,ShowerHeadIcon:wJ,Shrink:jJ,ShrinkIcon:jJ,Shrub:NJ,ShrubIcon:NJ,Shuffle:pk,ShuffleIcon:pk,Sidebar:G2,SidebarClose:V2,SidebarCloseIcon:V2,SidebarIcon:G2,SidebarOpen:W2,SidebarOpenIcon:W2,Sigma:kJ,SigmaIcon:kJ,SigmaSquare:Kj,SigmaSquareIcon:Kj,Signal:AJ,SignalHigh:SJ,SignalHighIcon:SJ,SignalIcon:AJ,SignalLow:CJ,SignalLowIcon:CJ,SignalMedium:MJ,SignalMediumIcon:MJ,SignalZero:TJ,SignalZeroIcon:TJ,Signature:EJ,SignatureIcon:EJ,Signpost:IJ,SignpostBig:PJ,SignpostBigIcon:PJ,SignpostIcon:IJ,Siren:LJ,SirenIcon:LJ,SkipBack:DJ,SkipBackIcon:DJ,SkipForward:OJ,SkipForwardIcon:OJ,Skull:RJ,SkullIcon:RJ,Slack:FJ,SlackIcon:FJ,Slash:zJ,SlashIcon:zJ,SlashSquare:Zj,SlashSquareIcon:Zj,Slice:BJ,SliceIcon:BJ,Sliders:nj,SlidersHorizontal:BP,SlidersHorizontalIcon:BP,SlidersIcon:nj,SlidersVertical:nj,SlidersVerticalIcon:nj,Smartphone:U0,SmartphoneCharging:$J,SmartphoneChargingIcon:$J,SmartphoneIcon:U0,SmartphoneNfc:qJ,SmartphoneNfcIcon:qJ,Smile:VJ,SmileIcon:VJ,SmilePlus:UJ,SmilePlusIcon:UJ,Snail:HJ,SnailIcon:HJ,Snowflake:$1,SnowflakeIcon:$1,Sofa:WJ,SofaIcon:WJ,SortAsc:fw,SortAscIcon:fw,SortDesc:hw,SortDescIcon:hw,Soup:GJ,SoupIcon:GJ,Space:KJ,SpaceIcon:KJ,Spade:ZJ,SpadeIcon:ZJ,Sparkle:YJ,SparkleIcon:YJ,Sparkles:hn,SparklesIcon:hn,Speaker:XJ,SpeakerIcon:XJ,Speech:QJ,SpeechIcon:QJ,SpellCheck:eee,SpellCheck2:JJ,SpellCheck2Icon:JJ,SpellCheckIcon:eee,Spline:tee,SplineIcon:tee,Split:see,SplitIcon:see,SplitSquareHorizontal:Yj,SplitSquareHorizontalIcon:Yj,SplitSquareVertical:Xj,SplitSquareVerticalIcon:Xj,SprayCan:ree,SprayCanIcon:ree,Sprout:nee,SproutIcon:nee,Square:ey,SquareActivity:aj,SquareActivityIcon:aj,SquareArrowDown:lj,SquareArrowDownIcon:lj,SquareArrowDownLeft:ij,SquareArrowDownLeftIcon:ij,SquareArrowDownRight:oj,SquareArrowDownRightIcon:oj,SquareArrowLeft:cj,SquareArrowLeftIcon:cj,SquareArrowOutDownLeft:dj,SquareArrowOutDownLeftIcon:dj,SquareArrowOutDownRight:uj,SquareArrowOutDownRightIcon:uj,SquareArrowOutUpLeft:hj,SquareArrowOutUpLeftIcon:hj,SquareArrowOutUpRight:mj,SquareArrowOutUpRightIcon:mj,SquareArrowRight:pj,SquareArrowRightIcon:pj,SquareArrowUp:xj,SquareArrowUpIcon:xj,SquareArrowUpLeft:fj,SquareArrowUpLeftIcon:fj,SquareArrowUpRight:gj,SquareArrowUpRightIcon:gj,SquareAsterisk:yj,SquareAsteriskIcon:yj,SquareBottomDashedScissors:vj,SquareBottomDashedScissorsIcon:vj,SquareChartGantt:Mx,SquareChartGanttIcon:Mx,SquareCheck:_j,SquareCheckBig:g0,SquareCheckBigIcon:g0,SquareCheckIcon:_j,SquareChevronDown:bj,SquareChevronDownIcon:bj,SquareChevronLeft:wj,SquareChevronLeftIcon:wj,SquareChevronRight:jj,SquareChevronRightIcon:jj,SquareChevronUp:Nj,SquareChevronUpIcon:Nj,SquareCode:kj,SquareCodeIcon:kj,SquareDashed:Mj,SquareDashedBottom:iee,SquareDashedBottomCode:aee,SquareDashedBottomCodeIcon:aee,SquareDashedBottomIcon:iee,SquareDashedIcon:Mj,SquareDashedKanban:Sj,SquareDashedKanbanIcon:Sj,SquareDashedMousePointer:Cj,SquareDashedMousePointerIcon:Cj,SquareDivide:Tj,SquareDivideIcon:Tj,SquareDot:Aj,SquareDotIcon:Aj,SquareEqual:Ej,SquareEqualIcon:Ej,SquareFunction:Pj,SquareFunctionIcon:Pj,SquareGanttChart:Mx,SquareGanttChartIcon:Mx,SquareIcon:ey,SquareKanban:Ij,SquareKanbanIcon:Ij,SquareLibrary:Lj,SquareLibraryIcon:Lj,SquareM:Dj,SquareMIcon:Dj,SquareMenu:Oj,SquareMenuIcon:Oj,SquareMinus:Rj,SquareMinusIcon:Rj,SquareMousePointer:Fj,SquareMousePointerIcon:Fj,SquareParking:Bj,SquareParkingIcon:Bj,SquareParkingOff:zj,SquareParkingOffIcon:zj,SquarePen:Rc,SquarePenIcon:Rc,SquarePercent:$j,SquarePercentIcon:$j,SquarePi:qj,SquarePiIcon:qj,SquarePilcrow:Uj,SquarePilcrowIcon:Uj,SquarePlay:Vj,SquarePlayIcon:Vj,SquarePlus:Hj,SquarePlusIcon:Hj,SquarePower:Wj,SquarePowerIcon:Wj,SquareRadical:oee,SquareRadicalIcon:oee,SquareScissors:Gj,SquareScissorsIcon:Gj,SquareSigma:Kj,SquareSigmaIcon:Kj,SquareSlash:Zj,SquareSlashIcon:Zj,SquareSplitHorizontal:Yj,SquareSplitHorizontalIcon:Yj,SquareSplitVertical:Xj,SquareSplitVerticalIcon:Xj,SquareSquare:lee,SquareSquareIcon:lee,SquareStack:cee,SquareStackIcon:cee,SquareTerminal:Qj,SquareTerminalIcon:Qj,SquareUser:eN,SquareUserIcon:eN,SquareUserRound:Jj,SquareUserRoundIcon:Jj,SquareX:tN,SquareXIcon:tN,Squircle:dee,SquircleIcon:dee,Squirrel:uee,SquirrelIcon:uee,Stamp:hee,StampIcon:hee,Star:Gn,StarHalf:mee,StarHalfIcon:mee,StarIcon:Gn,StarOff:pee,StarOffIcon:pee,Stars:hn,StarsIcon:hn,StepBack:fee,StepBackIcon:fee,StepForward:gee,StepForwardIcon:gee,Stethoscope:xee,StethoscopeIcon:xee,Sticker:yee,StickerIcon:yee,StickyNote:vee,StickyNoteIcon:vee,StopCircle:n2,StopCircleIcon:n2,Store:_ee,StoreIcon:_ee,StretchHorizontal:bee,StretchHorizontalIcon:bee,StretchVertical:wee,StretchVerticalIcon:wee,Strikethrough:jee,StrikethroughIcon:jee,Subscript:Nee,SubscriptIcon:Nee,Subtitles:jw,SubtitlesIcon:jw,Sun:h_,SunDim:kee,SunDimIcon:kee,SunIcon:h_,SunMedium:See,SunMediumIcon:See,SunMoon:Cee,SunMoonIcon:Cee,SunSnow:Mee,SunSnowIcon:Mee,Sunrise:Tee,SunriseIcon:Tee,Sunset:Aee,SunsetIcon:Aee,Superscript:Eee,SuperscriptIcon:Eee,SwatchBook:Pee,SwatchBookIcon:Pee,SwissFranc:Iee,SwissFrancIcon:Iee,SwitchCamera:Lee,SwitchCameraIcon:Lee,Sword:Dee,SwordIcon:Dee,Swords:Oee,SwordsIcon:Oee,Syringe:Ree,SyringeIcon:Ree,Table:$P,Table2:T5,Table2Icon:T5,TableCellsMerge:Fee,TableCellsMergeIcon:Fee,TableCellsSplit:zee,TableCellsSplitIcon:zee,TableColumnsSplit:Bee,TableColumnsSplitIcon:Bee,TableIcon:$P,TableOfContents:$ee,TableOfContentsIcon:$ee,TableProperties:qee,TablePropertiesIcon:qee,TableRowsSplit:Uee,TableRowsSplitIcon:Uee,Tablet:Hee,TabletIcon:Hee,TabletSmartphone:Vee,TabletSmartphoneIcon:Vee,Tablets:Wee,TabletsIcon:Wee,Tag:Wh,TagIcon:Wh,Tags:Gee,TagsIcon:Gee,Tally1:Kee,Tally1Icon:Kee,Tally2:Zee,Tally2Icon:Zee,Tally3:Yee,Tally3Icon:Yee,Tally4:Xee,Tally4Icon:Xee,Tally5:Qee,Tally5Icon:Qee,Tangent:Jee,TangentIcon:Jee,Target:Gh,TargetIcon:Gh,Telescope:ete,TelescopeIcon:ete,Tent:ste,TentIcon:ste,TentTree:tte,TentTreeIcon:tte,Terminal:rte,TerminalIcon:rte,TerminalSquare:Qj,TerminalSquareIcon:Qj,TestTube:nte,TestTube2:sN,TestTube2Icon:sN,TestTubeDiagonal:sN,TestTubeDiagonalIcon:sN,TestTubeIcon:nte,TestTubes:ate,TestTubesIcon:ate,Text:dte,TextCursor:ote,TextCursorIcon:ote,TextCursorInput:ite,TextCursorInputIcon:ite,TextIcon:dte,TextQuote:lte,TextQuoteIcon:lte,TextSearch:cte,TextSearchIcon:cte,TextSelect:rN,TextSelectIcon:rN,TextSelection:rN,TextSelectionIcon:rN,Theater:ute,TheaterIcon:ute,Thermometer:pte,ThermometerIcon:pte,ThermometerSnowflake:hte,ThermometerSnowflakeIcon:hte,ThermometerSun:mte,ThermometerSunIcon:mte,ThumbsDown:qP,ThumbsDownIcon:qP,ThumbsUp:gu,ThumbsUpIcon:gu,Ticket:UP,TicketCheck:fte,TicketCheckIcon:fte,TicketIcon:UP,TicketMinus:gte,TicketMinusIcon:gte,TicketPercent:xte,TicketPercentIcon:xte,TicketPlus:yte,TicketPlusIcon:yte,TicketSlash:vte,TicketSlashIcon:vte,TicketX:_te,TicketXIcon:_te,Tickets:wte,TicketsIcon:wte,TicketsPlane:bte,TicketsPlaneIcon:bte,Timer:kte,TimerIcon:kte,TimerOff:jte,TimerOffIcon:jte,TimerReset:Nte,TimerResetIcon:Nte,ToggleLeft:Ste,ToggleLeftIcon:Ste,ToggleRight:Cte,ToggleRightIcon:Cte,Toilet:Mte,ToiletIcon:Mte,Tornado:Tte,TornadoIcon:Tte,Torus:Ate,TorusIcon:Ate,Touchpad:Pte,TouchpadIcon:Pte,TouchpadOff:Ete,TouchpadOffIcon:Ete,TowerControl:Ite,TowerControlIcon:Ite,ToyBrick:Lte,ToyBrickIcon:Lte,Tractor:Dte,TractorIcon:Dte,TrafficCone:Ote,TrafficConeIcon:Ote,Train:nN,TrainFront:Fte,TrainFrontIcon:Fte,TrainFrontTunnel:Rte,TrainFrontTunnelIcon:Rte,TrainIcon:nN,TrainTrack:zte,TrainTrackIcon:zte,TramFront:nN,TramFrontIcon:nN,Trash:Bte,Trash2:jr,Trash2Icon:jr,TrashIcon:Bte,TreeDeciduous:$te,TreeDeciduousIcon:$te,TreePalm:aN,TreePalmIcon:aN,TreePine:m_,TreePineIcon:m_,Trees:qte,TreesIcon:qte,Trello:Ute,TrelloIcon:Ute,TrendingDown:fk,TrendingDownIcon:fk,TrendingUp:ac,TrendingUpDown:Vte,TrendingUpDownIcon:Vte,TrendingUpIcon:ac,Triangle:Wte,TriangleAlert:Ju,TriangleAlertIcon:Ju,TriangleIcon:Wte,TriangleRight:Hte,TriangleRightIcon:Hte,Trophy:ao,TrophyIcon:ao,Truck:VP,TruckIcon:VP,Turtle:Gte,TurtleIcon:Gte,Tv:Zte,Tv2:iN,Tv2Icon:iN,TvIcon:Zte,TvMinimal:iN,TvMinimalIcon:iN,TvMinimalPlay:Kte,TvMinimalPlayIcon:Kte,Twitch:Yte,TwitchIcon:Yte,Twitter:Xte,TwitterIcon:Xte,Type:Jte,TypeIcon:Jte,TypeOutline:Qte,TypeOutlineIcon:Qte,Umbrella:tse,UmbrellaIcon:tse,UmbrellaOff:ese,UmbrellaOffIcon:ese,Underline:sse,UnderlineIcon:sse,Undo:A5,Undo2:rse,Undo2Icon:rse,UndoDot:nse,UndoDotIcon:nse,UndoIcon:A5,UnfoldHorizontal:ase,UnfoldHorizontalIcon:ase,UnfoldVertical:ise,UnfoldVerticalIcon:ise,Ungroup:ose,UngroupIcon:ose,University:oN,UniversityIcon:oN,Unlink:gk,Unlink2:lse,Unlink2Icon:lse,UnlinkIcon:gk,Unlock:R2,UnlockIcon:R2,UnlockKeyhole:O2,UnlockKeyholeIcon:O2,Unplug:cse,UnplugIcon:cse,Upload:Za,UploadCloud:d2,UploadCloudIcon:d2,UploadIcon:Za,Usb:dse,UsbIcon:dse,User:Yi,User2:mN,User2Icon:mN,UserCheck:p_,UserCheck2:lN,UserCheck2Icon:lN,UserCheckIcon:p_,UserCircle:i2,UserCircle2:a2,UserCircle2Icon:a2,UserCircleIcon:i2,UserCog:HP,UserCog2:cN,UserCog2Icon:cN,UserCogIcon:HP,UserIcon:Yi,UserMinus:WP,UserMinus2:dN,UserMinus2Icon:dN,UserMinusIcon:WP,UserPen:use,UserPenIcon:use,UserPlus:yc,UserPlus2:uN,UserPlus2Icon:uN,UserPlusIcon:yc,UserRound:mN,UserRoundCheck:lN,UserRoundCheckIcon:lN,UserRoundCog:cN,UserRoundCogIcon:cN,UserRoundIcon:mN,UserRoundMinus:dN,UserRoundMinusIcon:dN,UserRoundPen:hse,UserRoundPenIcon:hse,UserRoundPlus:uN,UserRoundPlusIcon:uN,UserRoundSearch:mse,UserRoundSearchIcon:mse,UserRoundX:hN,UserRoundXIcon:hN,UserSearch:pse,UserSearchIcon:pse,UserSquare:eN,UserSquare2:Jj,UserSquare2Icon:Jj,UserSquareIcon:eN,UserX:fse,UserX2:hN,UserX2Icon:hN,UserXIcon:fse,Users:hr,Users2:pN,Users2Icon:pN,UsersIcon:hr,UsersRound:pN,UsersRoundIcon:pN,Utensils:gN,UtensilsCrossed:fN,UtensilsCrossedIcon:fN,UtensilsIcon:gN,UtilityPole:gse,UtilityPoleIcon:gse,Variable:GP,VariableIcon:GP,Vault:xse,VaultIcon:xse,Vegan:yse,VeganIcon:yse,VenetianMask:vse,VenetianMaskIcon:vse,Verified:yw,VerifiedIcon:yw,Vibrate:bse,VibrateIcon:bse,VibrateOff:_se,VibrateOffIcon:_se,Video:Nn,VideoIcon:Nn,VideoOff:wse,VideoOffIcon:wse,Videotape:jse,VideotapeIcon:jse,View:Nse,ViewIcon:Nse,Voicemail:kse,VoicemailIcon:kse,Volleyball:Sse,VolleyballIcon:Sse,Volume:Ese,Volume1:Cse,Volume1Icon:Cse,Volume2:Mse,Volume2Icon:Mse,VolumeIcon:Ese,VolumeOff:Tse,VolumeOffIcon:Tse,VolumeX:Ase,VolumeXIcon:Ase,Vote:Pse,VoteIcon:Pse,Wallet:KP,Wallet2:xN,Wallet2Icon:xN,WalletCards:Ise,WalletCardsIcon:Ise,WalletIcon:KP,WalletMinimal:xN,WalletMinimalIcon:xN,Wallpaper:Lse,WallpaperIcon:Lse,Wand:Dse,Wand2:x0,Wand2Icon:x0,WandIcon:Dse,WandSparkles:x0,WandSparklesIcon:x0,Warehouse:Ose,WarehouseIcon:Ose,WashingMachine:Rse,WashingMachineIcon:Rse,Watch:Fse,WatchIcon:Fse,Waves:zse,WavesIcon:zse,Waypoints:Bse,WaypointsIcon:Bse,Webcam:$se,WebcamIcon:$se,Webhook:Use,WebhookIcon:Use,WebhookOff:qse,WebhookOffIcon:qse,Weight:Vse,WeightIcon:Vse,Wheat:Wse,WheatIcon:Wse,WheatOff:Hse,WheatOffIcon:Hse,WholeWord:Gse,WholeWordIcon:Gse,Wifi:Qse,WifiHigh:Kse,WifiHighIcon:Kse,WifiIcon:Qse,WifiLow:Zse,WifiLowIcon:Zse,WifiOff:Yse,WifiOffIcon:Yse,WifiZero:Xse,WifiZeroIcon:Xse,Wind:ere,WindArrowDown:Jse,WindArrowDownIcon:Jse,WindIcon:ere,Wine:sre,WineIcon:sre,WineOff:tre,WineOffIcon:tre,Workflow:rre,WorkflowIcon:rre,Worm:nre,WormIcon:nre,WrapText:are,WrapTextIcon:are,Wrench:Wg,WrenchIcon:Wg,X:Ur,XCircle:kc,XCircleIcon:kc,XIcon:Ur,XOctagon:$2,XOctagonIcon:$2,XSquare:tN,XSquareIcon:tN,Youtube:ire,YoutubeIcon:ire,Zap:Fm,ZapIcon:Fm,ZapOff:ore,ZapOffIcon:ore,ZoomIn:f_,ZoomInIcon:f_,ZoomOut:E5,ZoomOutIcon:E5,createLucideIcon:Z,icons:Jot},Symbol.toStringTag,{value:"Module"})),d1e="-",elt=t=>{const s=slt(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:l=>{const i=l.split(d1e);return i[0]===""&&i.length!==1&&i.shift(),PRe(i,s)||tlt(l)},getConflictingClassGroupIds:(l,i)=>{const d=r[l]||[];return i&&n[l]?[...d,...n[l]]:d}}},PRe=(t,s)=>{var l;if(t.length===0)return s.classGroupId;const r=t[0],n=s.nextPart.get(r),a=n?PRe(t.slice(1),n):void 0;if(a)return a;if(s.validators.length===0)return;const o=t.join(d1e);return(l=s.validators.find(({validator:i})=>i(o)))==null?void 0:l.classGroupId},p4e=/^\[(.+)\]$/,tlt=t=>{if(p4e.test(t)){const s=p4e.exec(t)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},slt=t=>{const{theme:s,prefix:r}=t,n={nextPart:new Map,validators:[]};return nlt(Object.entries(t.classGroups),r).forEach(([o,l])=>{Vfe(l,n,o,s)}),n},Vfe=(t,s,r,n)=>{t.forEach(a=>{if(typeof a=="string"){const o=a===""?s:f4e(s,a);o.classGroupId=r;return}if(typeof a=="function"){if(rlt(a)){Vfe(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([o,l])=>{Vfe(l,f4e(s,o),r,n)})})},f4e=(t,s)=>{let r=t;return s.split(d1e).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},rlt=t=>t.isThemeGetter,nlt=(t,s)=>s?t.map(([r,n])=>{const a=n.map(o=>typeof o=="string"?s+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(([l,i])=>[s+l,i])):o);return[r,a]}):t,alt=t=>{if(t<1)return{get:()=>{},set:()=>{}};let s=0,r=new Map,n=new Map;const a=(o,l)=>{r.set(o,l),s++,s>t&&(s=0,n=r,r=new Map)};return{get(o){let l=r.get(o);if(l!==void 0)return l;if((l=n.get(o))!==void 0)return a(o,l),l},set(o,l){r.has(o)?r.set(o,l):a(o,l)}}},IRe="!",ilt=t=>{const{separator:s,experimentalParseClassName:r}=t,n=s.length===1,a=s[0],o=s.length,l=i=>{const d=[];let u=0,p=0,f;for(let j=0;jp?f-p:void 0;return{modifiers:d,hasImportantModifier:_,baseClassName:b,maybePostfixModifierPosition:w}};return r?i=>r({className:i,parseClassName:l}):l},olt=t=>{if(t.length<=1)return t;const s=[];let r=[];return t.forEach(n=>{n[0]==="["?(s.push(...r.sort(),n),r=[]):r.push(n)}),s.push(...r.sort()),s},llt=t=>({cache:alt(t.cacheSize),parseClassName:ilt(t),...elt(t)}),clt=/\s+/,dlt=(t,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,o=[],l=t.trim().split(clt);let i="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{modifiers:p,hasImportantModifier:f,baseClassName:y,maybePostfixModifierPosition:_}=r(u);let b=!!_,w=n(b?y.substring(0,_):y);if(!w){if(!b){i=u+(i.length>0?" "+i:i);continue}if(w=n(y),!w){i=u+(i.length>0?" "+i:i);continue}b=!1}const j=olt(p).join(":"),k=f?j+IRe:j,S=k+w;if(o.includes(S))continue;o.push(S);const T=a(w,b);for(let I=0;I0?" "+i:i)}return i};function ult(){let t=0,s,r,n="";for(;t{if(typeof t=="string")return t;let s,r="";for(let n=0;nf(p),t());return r=llt(u),n=r.cache.get,a=r.cache.set,o=i,i(d)}function i(d){const u=n(d);if(u)return u;const p=dlt(d,r);return a(d,p),p}return function(){return o(ult.apply(null,arguments))}}const Kl=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},DRe=/^\[(?:([a-z-]+):)?(.+)\]$/i,mlt=/^\d+\/\d+$/,plt=new Set(["px","full","screen"]),flt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,glt=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,xlt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,ylt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,vlt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Yy=t=>P5(t)||plt.has(t)||mlt.test(t),Jv=t=>mM(t,"length",Clt),P5=t=>!!t&&!Number.isNaN(Number(t)),vhe=t=>mM(t,"number",P5),eE=t=>!!t&&Number.isInteger(Number(t)),_lt=t=>t.endsWith("%")&&P5(t.slice(0,-1)),Bi=t=>DRe.test(t),e1=t=>flt.test(t),blt=new Set(["length","size","percentage"]),wlt=t=>mM(t,blt,ORe),jlt=t=>mM(t,"position",ORe),Nlt=new Set(["image","url"]),klt=t=>mM(t,Nlt,Tlt),Slt=t=>mM(t,"",Mlt),tE=()=>!0,mM=(t,s,r)=>{const n=DRe.exec(t);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},Clt=t=>glt.test(t)&&!xlt.test(t),ORe=()=>!1,Mlt=t=>ylt.test(t),Tlt=t=>vlt.test(t),Alt=()=>{const t=Kl("colors"),s=Kl("spacing"),r=Kl("blur"),n=Kl("brightness"),a=Kl("borderColor"),o=Kl("borderRadius"),l=Kl("borderSpacing"),i=Kl("borderWidth"),d=Kl("contrast"),u=Kl("grayscale"),p=Kl("hueRotate"),f=Kl("invert"),y=Kl("gap"),_=Kl("gradientColorStops"),b=Kl("gradientColorStopPositions"),w=Kl("inset"),j=Kl("margin"),k=Kl("opacity"),S=Kl("padding"),T=Kl("saturate"),I=Kl("scale"),L=Kl("sepia"),R=Kl("skew"),$=Kl("space"),q=Kl("translate"),U=()=>["auto","contain","none"],H=()=>["auto","hidden","clip","visible","scroll"],Y=()=>["auto",Bi,s],se=()=>[Bi,s],te=()=>["",Yy,Jv],Q=()=>["auto",P5,Bi],de=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],re=()=>["solid","dashed","dotted","double","none"],ae=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],le=()=>["start","end","center","between","around","evenly","stretch"],he=()=>["","0",Bi],be=()=>["auto","avoid","all","avoid-page","page","left","right","column"],_e=()=>[P5,Bi];return{cacheSize:500,separator:":",theme:{colors:[tE],spacing:[Yy,Jv],blur:["none","",e1,Bi],brightness:_e(),borderColor:[t],borderRadius:["none","","full",e1,Bi],borderSpacing:se(),borderWidth:te(),contrast:_e(),grayscale:he(),hueRotate:_e(),invert:he(),gap:se(),gradientColorStops:[t],gradientColorStopPositions:[_lt,Jv],inset:Y(),margin:Y(),opacity:_e(),padding:se(),saturate:_e(),scale:_e(),sepia:he(),skew:_e(),space:se(),translate:se()},classGroups:{aspect:[{aspect:["auto","square","video",Bi]}],container:["container"],columns:[{columns:[e1]}],"break-after":[{"break-after":be()}],"break-before":[{"break-before":be()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...de(),Bi]}],overflow:[{overflow:H()}],"overflow-x":[{"overflow-x":H()}],"overflow-y":[{"overflow-y":H()}],overscroll:[{overscroll:U()}],"overscroll-x":[{"overscroll-x":U()}],"overscroll-y":[{"overscroll-y":U()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[w]}],"inset-x":[{"inset-x":[w]}],"inset-y":[{"inset-y":[w]}],start:[{start:[w]}],end:[{end:[w]}],top:[{top:[w]}],right:[{right:[w]}],bottom:[{bottom:[w]}],left:[{left:[w]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",eE,Bi]}],basis:[{basis:Y()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Bi]}],grow:[{grow:he()}],shrink:[{shrink:he()}],order:[{order:["first","last","none",eE,Bi]}],"grid-cols":[{"grid-cols":[tE]}],"col-start-end":[{col:["auto",{span:["full",eE,Bi]},Bi]}],"col-start":[{"col-start":Q()}],"col-end":[{"col-end":Q()}],"grid-rows":[{"grid-rows":[tE]}],"row-start-end":[{row:["auto",{span:[eE,Bi]},Bi]}],"row-start":[{"row-start":Q()}],"row-end":[{"row-end":Q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Bi]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Bi]}],gap:[{gap:[y]}],"gap-x":[{"gap-x":[y]}],"gap-y":[{"gap-y":[y]}],"justify-content":[{justify:["normal",...le()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...le(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...le(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[S]}],px:[{px:[S]}],py:[{py:[S]}],ps:[{ps:[S]}],pe:[{pe:[S]}],pt:[{pt:[S]}],pr:[{pr:[S]}],pb:[{pb:[S]}],pl:[{pl:[S]}],m:[{m:[j]}],mx:[{mx:[j]}],my:[{my:[j]}],ms:[{ms:[j]}],me:[{me:[j]}],mt:[{mt:[j]}],mr:[{mr:[j]}],mb:[{mb:[j]}],ml:[{ml:[j]}],"space-x":[{"space-x":[$]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[$]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Bi,s]}],"min-w":[{"min-w":[Bi,s,"min","max","fit"]}],"max-w":[{"max-w":[Bi,s,"none","full","min","max","fit","prose",{screen:[e1]},e1]}],h:[{h:[Bi,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Bi,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Bi,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Bi,s,"auto","min","max","fit"]}],"font-size":[{text:["base",e1,Jv]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",vhe]}],"font-family":[{font:[tE]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Bi]}],"line-clamp":[{"line-clamp":["none",P5,vhe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Yy,Bi]}],"list-image":[{"list-image":["none",Bi]}],"list-style-type":[{list:["none","disc","decimal",Bi]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[k]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...re(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Yy,Jv]}],"underline-offset":[{"underline-offset":["auto",Yy,Bi]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:se()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Bi]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Bi]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[k]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...de(),jlt]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",wlt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},klt]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[b]}],"gradient-via-pos":[{via:[b]}],"gradient-to-pos":[{to:[b]}],"gradient-from":[{from:[_]}],"gradient-via":[{via:[_]}],"gradient-to":[{to:[_]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[i]}],"border-w-x":[{"border-x":[i]}],"border-w-y":[{"border-y":[i]}],"border-w-s":[{"border-s":[i]}],"border-w-e":[{"border-e":[i]}],"border-w-t":[{"border-t":[i]}],"border-w-r":[{"border-r":[i]}],"border-w-b":[{"border-b":[i]}],"border-w-l":[{"border-l":[i]}],"border-opacity":[{"border-opacity":[k]}],"border-style":[{border:[...re(),"hidden"]}],"divide-x":[{"divide-x":[i]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[i]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[k]}],"divide-style":[{divide:re()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...re()]}],"outline-offset":[{"outline-offset":[Yy,Bi]}],"outline-w":[{outline:[Yy,Jv]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[k]}],"ring-offset-w":[{"ring-offset":[Yy,Jv]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",e1,Slt]}],"shadow-color":[{shadow:[tE]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...ae(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ae()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[d]}],"drop-shadow":[{"drop-shadow":["","none",e1,Bi]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[f]}],saturate:[{saturate:[T]}],sepia:[{sepia:[L]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[d]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[k]}],"backdrop-saturate":[{"backdrop-saturate":[T]}],"backdrop-sepia":[{"backdrop-sepia":[L]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[l]}],"border-spacing-x":[{"border-spacing-x":[l]}],"border-spacing-y":[{"border-spacing-y":[l]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Bi]}],duration:[{duration:_e()}],ease:[{ease:["linear","in","out","in-out",Bi]}],delay:[{delay:_e()}],animate:[{animate:["none","spin","ping","pulse","bounce",Bi]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[I]}],"scale-x":[{"scale-x":[I]}],"scale-y":[{"scale-y":[I]}],rotate:[{rotate:[eE,Bi]}],"translate-x":[{"translate-x":[q]}],"translate-y":[{"translate-y":[q]}],"skew-x":[{"skew-x":[R]}],"skew-y":[{"skew-y":[R]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Bi]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Bi]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":se()}],"scroll-mx":[{"scroll-mx":se()}],"scroll-my":[{"scroll-my":se()}],"scroll-ms":[{"scroll-ms":se()}],"scroll-me":[{"scroll-me":se()}],"scroll-mt":[{"scroll-mt":se()}],"scroll-mr":[{"scroll-mr":se()}],"scroll-mb":[{"scroll-mb":se()}],"scroll-ml":[{"scroll-ml":se()}],"scroll-p":[{"scroll-p":se()}],"scroll-px":[{"scroll-px":se()}],"scroll-py":[{"scroll-py":se()}],"scroll-ps":[{"scroll-ps":se()}],"scroll-pe":[{"scroll-pe":se()}],"scroll-pt":[{"scroll-pt":se()}],"scroll-pr":[{"scroll-pr":se()}],"scroll-pb":[{"scroll-pb":se()}],"scroll-pl":[{"scroll-pl":se()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Bi]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Yy,Jv,vhe]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},Elt=hlt(Alt);function Pt(...t){return Elt(Ii(t))}function Tl(t,s=!1){return s&&t>=1e6?`$${(t/1e6).toFixed(1)}M`:s&&t>=1e3?`$${(t/1e3).toFixed(0)}K`:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(t)}function g4e(t){const s=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(s)}function poe(t){return t?t.replace(/<[^>]*>/g,""):""}const Plt=Yot,RRe=C.forwardRef(({className:t,...s},r)=>e.jsx(jRe,{ref:r,className:Pt("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...s}));RRe.displayName=jRe.displayName;const Ilt=nS("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),FRe=C.forwardRef(({className:t,variant:s,...r},n)=>e.jsx(NRe,{ref:n,className:Pt(Ilt({variant:s}),t),...r}));FRe.displayName=NRe.displayName;const Llt=C.forwardRef(({className:t,...s},r)=>e.jsx(CRe,{ref:r,className:Pt("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",t),...s}));Llt.displayName=CRe.displayName;const zRe=C.forwardRef(({className:t,...s},r)=>e.jsx(MRe,{ref:r,className:Pt("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...s,children:e.jsx(Ur,{className:"h-4 w-4"})}));zRe.displayName=MRe.displayName;const BRe=C.forwardRef(({className:t,...s},r)=>e.jsx(kRe,{ref:r,className:Pt("text-sm font-semibold",t),...s}));BRe.displayName=kRe.displayName;const $Re=C.forwardRef(({className:t,...s},r)=>e.jsx(SRe,{ref:r,className:Pt("text-sm opacity-90",t),...s}));$Re.displayName=SRe.displayName;function Dlt(){const{toasts:t}=Pa();return e.jsxs(Plt,{children:[t.map(function({id:s,title:r,description:n,action:a,...o}){return e.jsxs(FRe,{...o,children:[e.jsxs("div",{className:"grid gap-1",children:[r&&e.jsx(BRe,{children:r}),n&&e.jsx($Re,{children:n})]}),a,e.jsx(zRe,{})]},s)}),e.jsx(RRe,{})]})}var x4e=["light","dark"],Olt="(prefers-color-scheme: dark)",Rlt=C.createContext(void 0),Flt={setTheme:t=>{},themes:[]},zlt=()=>{var t;return(t=C.useContext(Rlt))!=null?t:Flt};C.memo(({forcedTheme:t,storageKey:s,attribute:r,enableSystem:n,enableColorScheme:a,defaultTheme:o,value:l,attrs:i,nonce:d})=>{let u=o==="system",p=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${i.map(b=>`'${b}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,f=a?x4e.includes(o)&&o?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${o}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",y=(b,w=!1,j=!0)=>{let k=l?l[b]:b,S=w?b+"|| ''":`'${k}'`,T="";return a&&j&&!w&&x4e.includes(b)&&(T+=`d.style.colorScheme = '${b}';`),r==="class"?w||k?T+=`c.add(${S})`:T+="null":k&&(T+=`d[s](n,${S})`),T},_=t?`!function(){${p}${y(t)}}()`:n?`!function(){try{${p}var e=localStorage.getItem('${s}');if('system'===e||(!e&&${u})){var t='${Olt}',m=window.matchMedia(t);if(m.media!==t||m.matches){${y("dark")}}else{${y("light")}}}else if(e){${l?`var x=${JSON.stringify(l)};`:""}${y(l?"x[e]":"e",!0)}}${u?"":"else{"+y(o,!1,!1)+"}"}${f}}catch(e){}}()`:`!function(){try{${p}var e=localStorage.getItem('${s}');if(e){${l?`var x=${JSON.stringify(l)};`:""}${y(l?"x[e]":"e",!0)}}else{${y(o,!1,!1)};}${f}}catch(t){}}();`;return C.createElement("script",{nonce:d,dangerouslySetInnerHTML:{__html:_}})});var Blt=t=>{switch(t){case"success":return Ult;case"info":return Hlt;case"warning":return Vlt;case"error":return Wlt;default:return null}},$lt=Array(12).fill(0),qlt=({visible:t,className:s})=>ht.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},ht.createElement("div",{className:"sonner-spinner"},$lt.map((r,n)=>ht.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),Ult=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ht.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),Vlt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ht.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Hlt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ht.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),Wlt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ht.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),Glt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ht.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ht.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Klt=()=>{let[t,s]=ht.useState(document.hidden);return ht.useEffect(()=>{let r=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},Hfe=1,Zlt=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let s=this.subscribers.indexOf(t);this.subscribers.splice(s,1)}),this.publish=t=>{this.subscribers.forEach(s=>s(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var s;let{message:r,...n}=t,a=typeof(t==null?void 0:t.id)=="number"||((s=t.id)==null?void 0:s.length)>0?t.id:Hfe++,o=this.toasts.find(i=>i.id===a),l=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),o?this.toasts=this.toasts.map(i=>i.id===a?(this.publish({...i,...t,id:a,title:r}),{...i,...t,id:a,dismissible:l,title:r}):i):this.addToast({title:r,...n,dismissible:l,id:a}),a},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(s=>{this.subscribers.forEach(r=>r({id:s.id,dismiss:!0}))}),this.subscribers.forEach(s=>s({id:t,dismiss:!0})),t),this.message=(t,s)=>this.create({...s,message:t}),this.error=(t,s)=>this.create({...s,message:t,type:"error"}),this.success=(t,s)=>this.create({...s,type:"success",message:t}),this.info=(t,s)=>this.create({...s,type:"info",message:t}),this.warning=(t,s)=>this.create({...s,type:"warning",message:t}),this.loading=(t,s)=>this.create({...s,type:"loading",message:t}),this.promise=(t,s)=>{if(!s)return;let r;s.loading!==void 0&&(r=this.create({...s,promise:t,type:"loading",message:s.loading,description:typeof s.description!="function"?s.description:void 0}));let n=t instanceof Promise?t:t(),a=r!==void 0,o,l=n.then(async d=>{if(o=["resolve",d],ht.isValidElement(d))a=!1,this.create({id:r,type:"default",message:d});else if(Xlt(d)&&!d.ok){a=!1;let u=typeof s.error=="function"?await s.error(`HTTP error! status: ${d.status}`):s.error,p=typeof s.description=="function"?await s.description(`HTTP error! status: ${d.status}`):s.description;this.create({id:r,type:"error",message:u,description:p})}else if(s.success!==void 0){a=!1;let u=typeof s.success=="function"?await s.success(d):s.success,p=typeof s.description=="function"?await s.description(d):s.description;this.create({id:r,type:"success",message:u,description:p})}}).catch(async d=>{if(o=["reject",d],s.error!==void 0){a=!1;let u=typeof s.error=="function"?await s.error(d):s.error,p=typeof s.description=="function"?await s.description(d):s.description;this.create({id:r,type:"error",message:u,description:p})}}).finally(()=>{var d;a&&(this.dismiss(r),r=void 0),(d=s.finally)==null||d.call(s)}),i=()=>new Promise((d,u)=>l.then(()=>o[0]==="reject"?u(o[1]):d(o[1])).catch(u));return typeof r!="string"&&typeof r!="number"?{unwrap:i}:Object.assign(r,{unwrap:i})},this.custom=(t,s)=>{let r=(s==null?void 0:s.id)||Hfe++;return this.create({jsx:t(r),id:r,...s}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},ym=new Zlt,Ylt=(t,s)=>{let r=(s==null?void 0:s.id)||Hfe++;return ym.addToast({title:t,...s,id:r}),r},Xlt=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",Qlt=Ylt,Jlt=()=>ym.toasts,ect=()=>ym.getActiveToasts(),fe=Object.assign(Qlt,{success:ym.success,info:ym.info,warning:ym.warning,error:ym.error,custom:ym.custom,message:ym.message,promise:ym.promise,dismiss:ym.dismiss,loading:ym.loading},{getHistory:Jlt,getToasts:ect});function tct(t,{insertAt:s}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",s==="top"&&r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}tct(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)} `);function T8(t){return t.label!==void 0}var sct=3,rct="32px",nct="16px",y4e=4e3,act=356,ict=14,oct=20,lct=200;function pg(...t){return t.filter(Boolean).join(" ")}function cct(t){let[s,r]=t.split("-"),n=[];return s&&n.push(s),r&&n.push(r),n}var dct=t=>{var s,r,n,a,o,l,i,d,u,p,f;let{invert:y,toast:_,unstyled:b,interacting:w,setHeights:j,visibleToasts:k,heights:S,index:T,toasts:I,expanded:L,removeToast:R,defaultRichColors:$,closeButton:q,style:U,cancelButtonStyle:H,actionButtonStyle:Y,className:se="",descriptionClassName:te="",duration:Q,position:de,gap:re,loadingIcon:ae,expandByDefault:le,classNames:he,icons:be,closeButtonAriaLabel:_e="Close toast",pauseWhenPageIsHidden:je}=t,[Ne,Ge]=ht.useState(null),[we,Me]=ht.useState(null),[Te,Fe]=ht.useState(!1),[Ae,Ue]=ht.useState(!1),[ut,De]=ht.useState(!1),[Rt,me]=ht.useState(!1),[Xe,ot]=ht.useState(!1),[nt,Se]=ht.useState(0),[it,$e]=ht.useState(0),ct=ht.useRef(_.duration||Q||y4e),qe=ht.useRef(null),Ze=ht.useRef(null),Qe=T===0,We=T+1<=k,He=_.type,et=_.dismissible!==!1,Tt=_.className||"",Ft=_.descriptionClassName||"",as=ht.useMemo(()=>S.findIndex(kn=>kn.toastId===_.id)||0,[S,_.id]),Xt=ht.useMemo(()=>{var kn;return(kn=_.closeButton)!=null?kn:q},[_.closeButton,q]),ss=ht.useMemo(()=>_.duration||Q||y4e,[_.duration,Q]),is=ht.useRef(0),ar=ht.useRef(0),Ct=ht.useRef(0),Is=ht.useRef(null),[qs,gr]=de.split("-"),Wn=ht.useMemo(()=>S.reduce((kn,sa,Zt)=>Zt>=as?kn:kn+sa.height,0),[S,as]),ii=Klt(),bo=_.invert||y,si=He==="loading";ar.current=ht.useMemo(()=>as*re+Wn,[as,Wn]),ht.useEffect(()=>{ct.current=ss},[ss]),ht.useEffect(()=>{Fe(!0)},[]),ht.useEffect(()=>{let kn=Ze.current;if(kn){let sa=kn.getBoundingClientRect().height;return $e(sa),j(Zt=>[{toastId:_.id,height:sa,position:_.position},...Zt]),()=>j(Zt=>Zt.filter($r=>$r.toastId!==_.id))}},[j,_.id]),ht.useLayoutEffect(()=>{if(!Te)return;let kn=Ze.current,sa=kn.style.height;kn.style.height="auto";let Zt=kn.getBoundingClientRect().height;kn.style.height=sa,$e(Zt),j($r=>$r.find(es=>es.toastId===_.id)?$r.map(es=>es.toastId===_.id?{...es,height:Zt}:es):[{toastId:_.id,height:Zt,position:_.position},...$r])},[Te,_.title,_.description,j,_.id]);let nn=ht.useCallback(()=>{Ue(!0),Se(ar.current),j(kn=>kn.filter(sa=>sa.toastId!==_.id)),setTimeout(()=>{R(_)},lct)},[_,R,j,ar]);ht.useEffect(()=>{if(_.promise&&He==="loading"||_.duration===1/0||_.type==="loading")return;let kn;return L||w||je&&ii?(()=>{if(Ct.current{var sa;(sa=_.onAutoClose)==null||sa.call(_,_),nn()},ct.current)),()=>clearTimeout(kn)},[L,w,_,He,je,ii,nn]),ht.useEffect(()=>{_.delete&&nn()},[nn,_.delete]);function ia(){var kn,sa,Zt;return be!=null&&be.loading?ht.createElement("div",{className:pg(he==null?void 0:he.loader,(kn=_==null?void 0:_.classNames)==null?void 0:kn.loader,"sonner-loader"),"data-visible":He==="loading"},be.loading):ae?ht.createElement("div",{className:pg(he==null?void 0:he.loader,(sa=_==null?void 0:_.classNames)==null?void 0:sa.loader,"sonner-loader"),"data-visible":He==="loading"},ae):ht.createElement(qlt,{className:pg(he==null?void 0:he.loader,(Zt=_==null?void 0:_.classNames)==null?void 0:Zt.loader),visible:He==="loading"})}return ht.createElement("li",{tabIndex:0,ref:Ze,className:pg(se,Tt,he==null?void 0:he.toast,(s=_==null?void 0:_.classNames)==null?void 0:s.toast,he==null?void 0:he.default,he==null?void 0:he[He],(r=_==null?void 0:_.classNames)==null?void 0:r[He]),"data-sonner-toast":"","data-rich-colors":(n=_.richColors)!=null?n:$,"data-styled":!(_.jsx||_.unstyled||b),"data-mounted":Te,"data-promise":!!_.promise,"data-swiped":Xe,"data-removed":Ae,"data-visible":We,"data-y-position":qs,"data-x-position":gr,"data-index":T,"data-front":Qe,"data-swiping":ut,"data-dismissible":et,"data-type":He,"data-invert":bo,"data-swipe-out":Rt,"data-swipe-direction":we,"data-expanded":!!(L||le&&Te),style:{"--index":T,"--toasts-before":T,"--z-index":I.length-T,"--offset":`${Ae?nt:ar.current}px`,"--initial-height":le?"auto":`${it}px`,...U,..._.style},onDragEnd:()=>{De(!1),Ge(null),Is.current=null},onPointerDown:kn=>{si||!et||(qe.current=new Date,Se(ar.current),kn.target.setPointerCapture(kn.pointerId),kn.target.tagName!=="BUTTON"&&(De(!0),Is.current={x:kn.clientX,y:kn.clientY}))},onPointerUp:()=>{var kn,sa,Zt,$r;if(Rt||!et)return;Is.current=null;let es=Number(((kn=Ze.current)==null?void 0:kn.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),an=Number(((sa=Ze.current)==null?void 0:sa.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Ra=new Date().getTime()-((Zt=qe.current)==null?void 0:Zt.getTime()),Zn=Ne==="x"?es:an,Ir=Math.abs(Zn)/Ra;if(Math.abs(Zn)>=oct||Ir>.11){Se(ar.current),($r=_.onDismiss)==null||$r.call(_,_),Me(Ne==="x"?es>0?"right":"left":an>0?"down":"up"),nn(),me(!0),ot(!1);return}De(!1),Ge(null)},onPointerMove:kn=>{var sa,Zt,$r,es;if(!Is.current||!et||((sa=window.getSelection())==null?void 0:sa.toString().length)>0)return;let an=kn.clientY-Is.current.y,Ra=kn.clientX-Is.current.x,Zn=(Zt=t.swipeDirections)!=null?Zt:cct(de);!Ne&&(Math.abs(Ra)>1||Math.abs(an)>1)&&Ge(Math.abs(Ra)>Math.abs(an)?"x":"y");let Ir={x:0,y:0};Ne==="y"?(Zn.includes("top")||Zn.includes("bottom"))&&(Zn.includes("top")&&an<0||Zn.includes("bottom")&&an>0)&&(Ir.y=an):Ne==="x"&&(Zn.includes("left")||Zn.includes("right"))&&(Zn.includes("left")&&Ra<0||Zn.includes("right")&&Ra>0)&&(Ir.x=Ra),(Math.abs(Ir.x)>0||Math.abs(Ir.y)>0)&&ot(!0),($r=Ze.current)==null||$r.style.setProperty("--swipe-amount-x",`${Ir.x}px`),(es=Ze.current)==null||es.style.setProperty("--swipe-amount-y",`${Ir.y}px`)}},Xt&&!_.jsx?ht.createElement("button",{"aria-label":_e,"data-disabled":si,"data-close-button":!0,onClick:si||!et?()=>{}:()=>{var kn;nn(),(kn=_.onDismiss)==null||kn.call(_,_)},className:pg(he==null?void 0:he.closeButton,(a=_==null?void 0:_.classNames)==null?void 0:a.closeButton)},(o=be==null?void 0:be.close)!=null?o:Glt):null,_.jsx||C.isValidElement(_.title)?_.jsx?_.jsx:typeof _.title=="function"?_.title():_.title:ht.createElement(ht.Fragment,null,He||_.icon||_.promise?ht.createElement("div",{"data-icon":"",className:pg(he==null?void 0:he.icon,(l=_==null?void 0:_.classNames)==null?void 0:l.icon)},_.promise||_.type==="loading"&&!_.icon?_.icon||ia():null,_.type!=="loading"?_.icon||(be==null?void 0:be[He])||Blt(He):null):null,ht.createElement("div",{"data-content":"",className:pg(he==null?void 0:he.content,(i=_==null?void 0:_.classNames)==null?void 0:i.content)},ht.createElement("div",{"data-title":"",className:pg(he==null?void 0:he.title,(d=_==null?void 0:_.classNames)==null?void 0:d.title)},typeof _.title=="function"?_.title():_.title),_.description?ht.createElement("div",{"data-description":"",className:pg(te,Ft,he==null?void 0:he.description,(u=_==null?void 0:_.classNames)==null?void 0:u.description)},typeof _.description=="function"?_.description():_.description):null),C.isValidElement(_.cancel)?_.cancel:_.cancel&&T8(_.cancel)?ht.createElement("button",{"data-button":!0,"data-cancel":!0,style:_.cancelButtonStyle||H,onClick:kn=>{var sa,Zt;T8(_.cancel)&&et&&((Zt=(sa=_.cancel).onClick)==null||Zt.call(sa,kn),nn())},className:pg(he==null?void 0:he.cancelButton,(p=_==null?void 0:_.classNames)==null?void 0:p.cancelButton)},_.cancel.label):null,C.isValidElement(_.action)?_.action:_.action&&T8(_.action)?ht.createElement("button",{"data-button":!0,"data-action":!0,style:_.actionButtonStyle||Y,onClick:kn=>{var sa,Zt;T8(_.action)&&((Zt=(sa=_.action).onClick)==null||Zt.call(sa,kn),!kn.defaultPrevented&&nn())},className:pg(he==null?void 0:he.actionButton,(f=_==null?void 0:_.classNames)==null?void 0:f.actionButton)},_.action.label):null))};function v4e(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function uct(t,s){let r={};return[t,s].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?nct:rct;function d(u){["top","right","bottom","left"].forEach(p=>{r[`${l}-${p}`]=typeof u=="number"?`${u}px`:u})}typeof n=="number"||typeof n=="string"?d(n):typeof n=="object"?["top","right","bottom","left"].forEach(u=>{n[u]===void 0?r[`${l}-${u}`]=i:r[`${l}-${u}`]=typeof n[u]=="number"?`${n[u]}px`:n[u]}):d(i)}),r}var hct=C.forwardRef(function(t,s){let{invert:r,position:n="bottom-right",hotkey:a=["altKey","KeyT"],expand:o,closeButton:l,className:i,offset:d,mobileOffset:u,theme:p="light",richColors:f,duration:y,style:_,visibleToasts:b=sct,toastOptions:w,dir:j=v4e(),gap:k=ict,loadingIcon:S,icons:T,containerAriaLabel:I="Notifications",pauseWhenPageIsHidden:L}=t,[R,$]=ht.useState([]),q=ht.useMemo(()=>Array.from(new Set([n].concat(R.filter(je=>je.position).map(je=>je.position)))),[R,n]),[U,H]=ht.useState([]),[Y,se]=ht.useState(!1),[te,Q]=ht.useState(!1),[de,re]=ht.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),ae=ht.useRef(null),le=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),he=ht.useRef(null),be=ht.useRef(!1),_e=ht.useCallback(je=>{$(Ne=>{var Ge;return(Ge=Ne.find(we=>we.id===je.id))!=null&&Ge.delete||ym.dismiss(je.id),Ne.filter(({id:we})=>we!==je.id)})},[]);return ht.useEffect(()=>ym.subscribe(je=>{if(je.dismiss){$(Ne=>Ne.map(Ge=>Ge.id===je.id?{...Ge,delete:!0}:Ge));return}setTimeout(()=>{r1e.flushSync(()=>{$(Ne=>{let Ge=Ne.findIndex(we=>we.id===je.id);return Ge!==-1?[...Ne.slice(0,Ge),{...Ne[Ge],...je},...Ne.slice(Ge+1)]:[je,...Ne]})})})}),[]),ht.useEffect(()=>{if(p!=="system"){re(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?re("dark"):re("light")),typeof window>"u")return;let je=window.matchMedia("(prefers-color-scheme: dark)");try{je.addEventListener("change",({matches:Ne})=>{re(Ne?"dark":"light")})}catch{je.addListener(({matches:Ge})=>{try{re(Ge?"dark":"light")}catch(we){console.error(we)}})}},[p]),ht.useEffect(()=>{R.length<=1&&se(!1)},[R]),ht.useEffect(()=>{let je=Ne=>{var Ge,we;a.every(Me=>Ne[Me]||Ne.code===Me)&&(se(!0),(Ge=ae.current)==null||Ge.focus()),Ne.code==="Escape"&&(document.activeElement===ae.current||(we=ae.current)!=null&&we.contains(document.activeElement))&&se(!1)};return document.addEventListener("keydown",je),()=>document.removeEventListener("keydown",je)},[a]),ht.useEffect(()=>{if(ae.current)return()=>{he.current&&(he.current.focus({preventScroll:!0}),he.current=null,be.current=!1)}},[ae.current]),ht.createElement("section",{ref:s,"aria-label":`${I} ${le}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},q.map((je,Ne)=>{var Ge;let[we,Me]=je.split("-");return R.length?ht.createElement("ol",{key:je,dir:j==="auto"?v4e():j,tabIndex:-1,ref:ae,className:i,"data-sonner-toaster":!0,"data-theme":de,"data-y-position":we,"data-lifted":Y&&R.length>1&&!o,"data-x-position":Me,style:{"--front-toast-height":`${((Ge=U[0])==null?void 0:Ge.height)||0}px`,"--width":`${act}px`,"--gap":`${k}px`,..._,...uct(d,u)},onBlur:Te=>{be.current&&!Te.currentTarget.contains(Te.relatedTarget)&&(be.current=!1,he.current&&(he.current.focus({preventScroll:!0}),he.current=null))},onFocus:Te=>{Te.target instanceof HTMLElement&&Te.target.dataset.dismissible==="false"||be.current||(be.current=!0,he.current=Te.relatedTarget)},onMouseEnter:()=>se(!0),onMouseMove:()=>se(!0),onMouseLeave:()=>{te||se(!1)},onDragEnd:()=>se(!1),onPointerDown:Te=>{Te.target instanceof HTMLElement&&Te.target.dataset.dismissible==="false"||Q(!0)},onPointerUp:()=>Q(!1)},R.filter(Te=>!Te.position&&Ne===0||Te.position===je).map((Te,Fe)=>{var Ae,Ue;return ht.createElement(dct,{key:Te.id,icons:T,index:Fe,toast:Te,defaultRichColors:f,duration:(Ae=w==null?void 0:w.duration)!=null?Ae:y,className:w==null?void 0:w.className,descriptionClassName:w==null?void 0:w.descriptionClassName,invert:r,visibleToasts:b,closeButton:(Ue=w==null?void 0:w.closeButton)!=null?Ue:l,interacting:te,position:je,style:w==null?void 0:w.style,unstyled:w==null?void 0:w.unstyled,classNames:w==null?void 0:w.classNames,cancelButtonStyle:w==null?void 0:w.cancelButtonStyle,actionButtonStyle:w==null?void 0:w.actionButtonStyle,removeToast:_e,toasts:R.filter(ut=>ut.position==Te.position),heights:U.filter(ut=>ut.position==Te.position),setHeights:H,expandByDefault:o,gap:k,loadingIcon:S,expanded:Y,pauseWhenPageIsHidden:L,swipeDirections:t.swipeDirections})})):null}))});const mct=({...t})=>{const{theme:s="system"}=zlt();return e.jsx(hct,{theme:s,position:"top-center",className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t})};var pct=hve[" useId ".trim().toString()]||(()=>{}),fct=0;function Gd(t){const[s,r]=C.useState(pct());return Zc(()=>{r(n=>n??String(fct++))},[t]),s?`radix-${s}`:""}const gct=["top","right","bottom","left"],T_=Math.min,lp=Math.max,one=Math.round,A8=Math.floor,ty=t=>({x:t,y:t}),xct={left:"right",right:"left",bottom:"top",top:"bottom"},yct={start:"end",end:"start"};function Wfe(t,s,r){return lp(t,T_(s,r))}function sv(t,s){return typeof t=="function"?t(s):t}function rv(t){return t.split("-")[0]}function pM(t){return t.split("-")[1]}function u1e(t){return t==="x"?"y":"x"}function h1e(t){return t==="y"?"height":"width"}const vct=new Set(["top","bottom"]);function Ux(t){return vct.has(rv(t))?"y":"x"}function m1e(t){return u1e(Ux(t))}function _ct(t,s,r){r===void 0&&(r=!1);const n=pM(t),a=m1e(t),o=h1e(a);let l=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return s.reference[o]>s.floating[o]&&(l=lne(l)),[l,lne(l)]}function bct(t){const s=lne(t);return[Gfe(t),s,Gfe(s)]}function Gfe(t){return t.replace(/start|end/g,s=>yct[s])}const _4e=["left","right"],b4e=["right","left"],wct=["top","bottom"],jct=["bottom","top"];function Nct(t,s,r){switch(t){case"top":case"bottom":return r?s?b4e:_4e:s?_4e:b4e;case"left":case"right":return s?wct:jct;default:return[]}}function kct(t,s,r,n){const a=pM(t);let o=Nct(rv(t),r==="start",n);return a&&(o=o.map(l=>l+"-"+a),s&&(o=o.concat(o.map(Gfe)))),o}function lne(t){return t.replace(/left|right|bottom|top/g,s=>xct[s])}function Sct(t){return{top:0,right:0,bottom:0,left:0,...t}}function qRe(t){return typeof t!="number"?Sct(t):{top:t,right:t,bottom:t,left:t}}function cne(t){const{x:s,y:r,width:n,height:a}=t;return{width:n,height:a,top:r,left:s,right:s+n,bottom:r+a,x:s,y:r}}function w4e(t,s,r){let{reference:n,floating:a}=t;const o=Ux(s),l=m1e(s),i=h1e(l),d=rv(s),u=o==="y",p=n.x+n.width/2-a.width/2,f=n.y+n.height/2-a.height/2,y=n[i]/2-a[i]/2;let _;switch(d){case"top":_={x:p,y:n.y-a.height};break;case"bottom":_={x:p,y:n.y+n.height};break;case"right":_={x:n.x+n.width,y:f};break;case"left":_={x:n.x-a.width,y:f};break;default:_={x:n.x,y:n.y}}switch(pM(s)){case"start":_[l]-=y*(r&&u?-1:1);break;case"end":_[l]+=y*(r&&u?-1:1);break}return _}const Cct=async(t,s,r)=>{const{placement:n="bottom",strategy:a="absolute",middleware:o=[],platform:l}=r,i=o.filter(Boolean),d=await(l.isRTL==null?void 0:l.isRTL(s));let u=await l.getElementRects({reference:t,floating:s,strategy:a}),{x:p,y:f}=w4e(u,n,d),y=n,_={},b=0;for(let w=0;w({name:"arrow",options:t,async fn(s){const{x:r,y:n,placement:a,rects:o,platform:l,elements:i,middlewareData:d}=s,{element:u,padding:p=0}=sv(t,s)||{};if(u==null)return{};const f=qRe(p),y={x:r,y:n},_=m1e(a),b=h1e(_),w=await l.getDimensions(u),j=_==="y",k=j?"top":"left",S=j?"bottom":"right",T=j?"clientHeight":"clientWidth",I=o.reference[b]+o.reference[_]-y[_]-o.floating[b],L=y[_]-o.reference[_],R=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u));let $=R?R[T]:0;(!$||!await(l.isElement==null?void 0:l.isElement(R)))&&($=i.floating[T]||o.floating[b]);const q=I/2-L/2,U=$/2-w[b]/2-1,H=T_(f[k],U),Y=T_(f[S],U),se=H,te=$-w[b]-Y,Q=$/2-w[b]/2+q,de=Wfe(se,Q,te),re=!d.arrow&&pM(a)!=null&&Q!==de&&o.reference[b]/2-(QQ<=0)){var Y,se;const Q=(((Y=o.flip)==null?void 0:Y.index)||0)+1,de=$[Q];if(de&&(!(f==="alignment"?S!==Ux(de):!1)||H.every(le=>le.overflows[0]>0&&Ux(le.placement)===S)))return{data:{index:Q,overflows:H},reset:{placement:de}};let re=(se=H.filter(ae=>ae.overflows[0]<=0).sort((ae,le)=>ae.overflows[1]-le.overflows[1])[0])==null?void 0:se.placement;if(!re)switch(_){case"bestFit":{var te;const ae=(te=H.filter(le=>{if(R){const he=Ux(le.placement);return he===S||he==="y"}return!0}).map(le=>[le.placement,le.overflows.filter(he=>he>0).reduce((he,be)=>he+be,0)]).sort((le,he)=>le[1]-he[1])[0])==null?void 0:te[0];ae&&(re=ae);break}case"initialPlacement":re=i;break}if(a!==re)return{reset:{placement:re}}}return{}}}};function j4e(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function N4e(t){return gct.some(s=>t[s]>=0)}const Act=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:r}=s,{strategy:n="referenceHidden",...a}=sv(t,s);switch(n){case"referenceHidden":{const o=await GI(s,{...a,elementContext:"reference"}),l=j4e(o,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:N4e(l)}}}case"escaped":{const o=await GI(s,{...a,altBoundary:!0}),l=j4e(o,r.floating);return{data:{escapedOffsets:l,escaped:N4e(l)}}}default:return{}}}}},URe=new Set(["left","top"]);async function Ect(t,s){const{placement:r,platform:n,elements:a}=t,o=await(n.isRTL==null?void 0:n.isRTL(a.floating)),l=rv(r),i=pM(r),d=Ux(r)==="y",u=URe.has(l)?-1:1,p=o&&d?-1:1,f=sv(s,t);let{mainAxis:y,crossAxis:_,alignmentAxis:b}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return i&&typeof b=="number"&&(_=i==="end"?b*-1:b),d?{x:_*p,y:y*u}:{x:y*u,y:_*p}}const Pct=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(s){var r,n;const{x:a,y:o,placement:l,middlewareData:i}=s,d=await Ect(s,t);return l===((r=i.offset)==null?void 0:r.placement)&&(n=i.arrow)!=null&&n.alignmentOffset?{}:{x:a+d.x,y:o+d.y,data:{...d,placement:l}}}}},Ict=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:r,y:n,placement:a}=s,{mainAxis:o=!0,crossAxis:l=!1,limiter:i={fn:j=>{let{x:k,y:S}=j;return{x:k,y:S}}},...d}=sv(t,s),u={x:r,y:n},p=await GI(s,d),f=Ux(rv(a)),y=u1e(f);let _=u[y],b=u[f];if(o){const j=y==="y"?"top":"left",k=y==="y"?"bottom":"right",S=_+p[j],T=_-p[k];_=Wfe(S,_,T)}if(l){const j=f==="y"?"top":"left",k=f==="y"?"bottom":"right",S=b+p[j],T=b-p[k];b=Wfe(S,b,T)}const w=i.fn({...s,[y]:_,[f]:b});return{...w,data:{x:w.x-r,y:w.y-n,enabled:{[y]:o,[f]:l}}}}}},Lct=function(t){return t===void 0&&(t={}),{options:t,fn(s){const{x:r,y:n,placement:a,rects:o,middlewareData:l}=s,{offset:i=0,mainAxis:d=!0,crossAxis:u=!0}=sv(t,s),p={x:r,y:n},f=Ux(a),y=u1e(f);let _=p[y],b=p[f];const w=sv(i,s),j=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(d){const T=y==="y"?"height":"width",I=o.reference[y]-o.floating[T]+j.mainAxis,L=o.reference[y]+o.reference[T]-j.mainAxis;_L&&(_=L)}if(u){var k,S;const T=y==="y"?"width":"height",I=URe.has(rv(a)),L=o.reference[f]-o.floating[T]+(I&&((k=l.offset)==null?void 0:k[f])||0)+(I?0:j.crossAxis),R=o.reference[f]+o.reference[T]+(I?0:((S=l.offset)==null?void 0:S[f])||0)-(I?j.crossAxis:0);bR&&(b=R)}return{[y]:_,[f]:b}}}},Dct=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(s){var r,n;const{placement:a,rects:o,platform:l,elements:i}=s,{apply:d=()=>{},...u}=sv(t,s),p=await GI(s,u),f=rv(a),y=pM(a),_=Ux(a)==="y",{width:b,height:w}=o.floating;let j,k;f==="top"||f==="bottom"?(j=f,k=y===(await(l.isRTL==null?void 0:l.isRTL(i.floating))?"start":"end")?"left":"right"):(k=f,j=y==="end"?"top":"bottom");const S=w-p.top-p.bottom,T=b-p.left-p.right,I=T_(w-p[j],S),L=T_(b-p[k],T),R=!s.middlewareData.shift;let $=I,q=L;if((r=s.middlewareData.shift)!=null&&r.enabled.x&&(q=T),(n=s.middlewareData.shift)!=null&&n.enabled.y&&($=S),R&&!y){const H=lp(p.left,0),Y=lp(p.right,0),se=lp(p.top,0),te=lp(p.bottom,0);_?q=b-2*(H!==0||Y!==0?H+Y:lp(p.left,p.right)):$=w-2*(se!==0||te!==0?se+te:lp(p.top,p.bottom))}await d({...s,availableWidth:q,availableHeight:$});const U=await l.getDimensions(i.floating);return b!==U.width||w!==U.height?{reset:{rects:!0}}:{}}}};function foe(){return typeof window<"u"}function fM(t){return VRe(t)?(t.nodeName||"").toLowerCase():"#document"}function _p(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function gy(t){var s;return(s=(VRe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function VRe(t){return foe()?t instanceof Node||t instanceof _p(t).Node:!1}function Yg(t){return foe()?t instanceof Element||t instanceof _p(t).Element:!1}function oy(t){return foe()?t instanceof HTMLElement||t instanceof _p(t).HTMLElement:!1}function k4e(t){return!foe()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof _p(t).ShadowRoot}const Oct=new Set(["inline","contents"]);function bL(t){const{overflow:s,overflowX:r,overflowY:n,display:a}=Xg(t);return/auto|scroll|overlay|hidden|clip/.test(s+n+r)&&!Oct.has(a)}const Rct=new Set(["table","td","th"]);function Fct(t){return Rct.has(fM(t))}const zct=[":popover-open",":modal"];function goe(t){return zct.some(s=>{try{return t.matches(s)}catch{return!1}})}const Bct=["transform","translate","scale","rotate","perspective"],$ct=["transform","translate","scale","rotate","perspective","filter"],qct=["paint","layout","strict","content"];function p1e(t){const s=f1e(),r=Yg(t)?Xg(t):t;return Bct.some(n=>r[n]?r[n]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!s&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!s&&(r.filter?r.filter!=="none":!1)||$ct.some(n=>(r.willChange||"").includes(n))||qct.some(n=>(r.contain||"").includes(n))}function Uct(t){let s=A_(t);for(;oy(s)&&!f3(s);){if(p1e(s))return s;if(goe(s))return null;s=A_(s)}return null}function f1e(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Vct=new Set(["html","body","#document"]);function f3(t){return Vct.has(fM(t))}function Xg(t){return _p(t).getComputedStyle(t)}function xoe(t){return Yg(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function A_(t){if(fM(t)==="html")return t;const s=t.assignedSlot||t.parentNode||k4e(t)&&t.host||gy(t);return k4e(s)?s.host:s}function HRe(t){const s=A_(t);return f3(s)?t.ownerDocument?t.ownerDocument.body:t.body:oy(s)&&bL(s)?s:HRe(s)}function KI(t,s,r){var n;s===void 0&&(s=[]),r===void 0&&(r=!0);const a=HRe(t),o=a===((n=t.ownerDocument)==null?void 0:n.body),l=_p(a);if(o){const i=Kfe(l);return s.concat(l,l.visualViewport||[],bL(a)?a:[],i&&r?KI(i):[])}return s.concat(a,KI(a,[],r))}function Kfe(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function WRe(t){const s=Xg(t);let r=parseFloat(s.width)||0,n=parseFloat(s.height)||0;const a=oy(t),o=a?t.offsetWidth:r,l=a?t.offsetHeight:n,i=one(r)!==o||one(n)!==l;return i&&(r=o,n=l),{width:r,height:n,$:i}}function g1e(t){return Yg(t)?t:t.contextElement}function I5(t){const s=g1e(t);if(!oy(s))return ty(1);const r=s.getBoundingClientRect(),{width:n,height:a,$:o}=WRe(s);let l=(o?one(r.width):r.width)/n,i=(o?one(r.height):r.height)/a;return(!l||!Number.isFinite(l))&&(l=1),(!i||!Number.isFinite(i))&&(i=1),{x:l,y:i}}const Hct=ty(0);function GRe(t){const s=_p(t);return!f1e()||!s.visualViewport?Hct:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function Wct(t,s,r){return s===void 0&&(s=!1),!r||s&&r!==_p(t)?!1:s}function Ek(t,s,r,n){s===void 0&&(s=!1),r===void 0&&(r=!1);const a=t.getBoundingClientRect(),o=g1e(t);let l=ty(1);s&&(n?Yg(n)&&(l=I5(n)):l=I5(t));const i=Wct(o,r,n)?GRe(o):ty(0);let d=(a.left+i.x)/l.x,u=(a.top+i.y)/l.y,p=a.width/l.x,f=a.height/l.y;if(o){const y=_p(o),_=n&&Yg(n)?_p(n):n;let b=y,w=Kfe(b);for(;w&&n&&_!==b;){const j=I5(w),k=w.getBoundingClientRect(),S=Xg(w),T=k.left+(w.clientLeft+parseFloat(S.paddingLeft))*j.x,I=k.top+(w.clientTop+parseFloat(S.paddingTop))*j.y;d*=j.x,u*=j.y,p*=j.x,f*=j.y,d+=T,u+=I,b=_p(w),w=Kfe(b)}}return cne({width:p,height:f,x:d,y:u})}function x1e(t,s){const r=xoe(t).scrollLeft;return s?s.left+r:Ek(gy(t)).left+r}function KRe(t,s,r){r===void 0&&(r=!1);const n=t.getBoundingClientRect(),a=n.left+s.scrollLeft-(r?0:x1e(t,n)),o=n.top+s.scrollTop;return{x:a,y:o}}function Gct(t){let{elements:s,rect:r,offsetParent:n,strategy:a}=t;const o=a==="fixed",l=gy(n),i=s?goe(s.floating):!1;if(n===l||i&&o)return r;let d={scrollLeft:0,scrollTop:0},u=ty(1);const p=ty(0),f=oy(n);if((f||!f&&!o)&&((fM(n)!=="body"||bL(l))&&(d=xoe(n)),oy(n))){const _=Ek(n);u=I5(n),p.x=_.x+n.clientLeft,p.y=_.y+n.clientTop}const y=l&&!f&&!o?KRe(l,d,!0):ty(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-d.scrollLeft*u.x+p.x+y.x,y:r.y*u.y-d.scrollTop*u.y+p.y+y.y}}function Kct(t){return Array.from(t.getClientRects())}function Zct(t){const s=gy(t),r=xoe(t),n=t.ownerDocument.body,a=lp(s.scrollWidth,s.clientWidth,n.scrollWidth,n.clientWidth),o=lp(s.scrollHeight,s.clientHeight,n.scrollHeight,n.clientHeight);let l=-r.scrollLeft+x1e(t);const i=-r.scrollTop;return Xg(n).direction==="rtl"&&(l+=lp(s.clientWidth,n.clientWidth)-a),{width:a,height:o,x:l,y:i}}function Yct(t,s){const r=_p(t),n=gy(t),a=r.visualViewport;let o=n.clientWidth,l=n.clientHeight,i=0,d=0;if(a){o=a.width,l=a.height;const u=f1e();(!u||u&&s==="fixed")&&(i=a.offsetLeft,d=a.offsetTop)}return{width:o,height:l,x:i,y:d}}const Xct=new Set(["absolute","fixed"]);function Qct(t,s){const r=Ek(t,!0,s==="fixed"),n=r.top+t.clientTop,a=r.left+t.clientLeft,o=oy(t)?I5(t):ty(1),l=t.clientWidth*o.x,i=t.clientHeight*o.y,d=a*o.x,u=n*o.y;return{width:l,height:i,x:d,y:u}}function S4e(t,s,r){let n;if(s==="viewport")n=Yct(t,r);else if(s==="document")n=Zct(gy(t));else if(Yg(s))n=Qct(s,r);else{const a=GRe(t);n={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return cne(n)}function ZRe(t,s){const r=A_(t);return r===s||!Yg(r)||f3(r)?!1:Xg(r).position==="fixed"||ZRe(r,s)}function Jct(t,s){const r=s.get(t);if(r)return r;let n=KI(t,[],!1).filter(i=>Yg(i)&&fM(i)!=="body"),a=null;const o=Xg(t).position==="fixed";let l=o?A_(t):t;for(;Yg(l)&&!f3(l);){const i=Xg(l),d=p1e(l);!d&&i.position==="fixed"&&(a=null),(o?!d&&!a:!d&&i.position==="static"&&!!a&&Xct.has(a.position)||bL(l)&&!d&&ZRe(t,l))?n=n.filter(p=>p!==l):a=i,l=A_(l)}return s.set(t,n),n}function edt(t){let{element:s,boundary:r,rootBoundary:n,strategy:a}=t;const l=[...r==="clippingAncestors"?goe(s)?[]:Jct(s,this._c):[].concat(r),n],i=l[0],d=l.reduce((u,p)=>{const f=S4e(s,p,a);return u.top=lp(f.top,u.top),u.right=T_(f.right,u.right),u.bottom=T_(f.bottom,u.bottom),u.left=lp(f.left,u.left),u},S4e(s,i,a));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function tdt(t){const{width:s,height:r}=WRe(t);return{width:s,height:r}}function sdt(t,s,r){const n=oy(s),a=gy(s),o=r==="fixed",l=Ek(t,!0,o,s);let i={scrollLeft:0,scrollTop:0};const d=ty(0);function u(){d.x=x1e(a)}if(n||!n&&!o)if((fM(s)!=="body"||bL(a))&&(i=xoe(s)),n){const _=Ek(s,!0,o,s);d.x=_.x+s.clientLeft,d.y=_.y+s.clientTop}else a&&u();o&&!n&&a&&u();const p=a&&!n&&!o?KRe(a,i):ty(0),f=l.left+i.scrollLeft-d.x-p.x,y=l.top+i.scrollTop-d.y-p.y;return{x:f,y,width:l.width,height:l.height}}function _he(t){return Xg(t).position==="static"}function C4e(t,s){if(!oy(t)||Xg(t).position==="fixed")return null;if(s)return s(t);let r=t.offsetParent;return gy(t)===r&&(r=r.ownerDocument.body),r}function YRe(t,s){const r=_p(t);if(goe(t))return r;if(!oy(t)){let a=A_(t);for(;a&&!f3(a);){if(Yg(a)&&!_he(a))return a;a=A_(a)}return r}let n=C4e(t,s);for(;n&&Fct(n)&&_he(n);)n=C4e(n,s);return n&&f3(n)&&_he(n)&&!p1e(n)?r:n||Uct(t)||r}const rdt=async function(t){const s=this.getOffsetParent||YRe,r=this.getDimensions,n=await r(t.floating);return{reference:sdt(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function ndt(t){return Xg(t).direction==="rtl"}const adt={convertOffsetParentRelativeRectToViewportRelativeRect:Gct,getDocumentElement:gy,getClippingRect:edt,getOffsetParent:YRe,getElementRects:rdt,getClientRects:Kct,getDimensions:tdt,getScale:I5,isElement:Yg,isRTL:ndt};function XRe(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function idt(t,s){let r=null,n;const a=gy(t);function o(){var i;clearTimeout(n),(i=r)==null||i.disconnect(),r=null}function l(i,d){i===void 0&&(i=!1),d===void 0&&(d=1),o();const u=t.getBoundingClientRect(),{left:p,top:f,width:y,height:_}=u;if(i||s(),!y||!_)return;const b=A8(f),w=A8(a.clientWidth-(p+y)),j=A8(a.clientHeight-(f+_)),k=A8(p),T={rootMargin:-b+"px "+-w+"px "+-j+"px "+-k+"px",threshold:lp(0,T_(1,d))||1};let I=!0;function L(R){const $=R[0].intersectionRatio;if($!==d){if(!I)return l();$?l(!1,$):n=setTimeout(()=>{l(!1,1e-7)},1e3)}$===1&&!XRe(u,t.getBoundingClientRect())&&l(),I=!1}try{r=new IntersectionObserver(L,{...T,root:a.ownerDocument})}catch{r=new IntersectionObserver(L,T)}r.observe(t)}return l(!0),o}function odt(t,s,r,n){n===void 0&&(n={});const{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:d=!1}=n,u=g1e(t),p=a||o?[...u?KI(u):[],...KI(s)]:[];p.forEach(k=>{a&&k.addEventListener("scroll",r,{passive:!0}),o&&k.addEventListener("resize",r)});const f=u&&i?idt(u,r):null;let y=-1,_=null;l&&(_=new ResizeObserver(k=>{let[S]=k;S&&S.target===u&&_&&(_.unobserve(s),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var T;(T=_)==null||T.observe(s)})),r()}),u&&!d&&_.observe(u),_.observe(s));let b,w=d?Ek(t):null;d&&j();function j(){const k=Ek(t);w&&!XRe(w,k)&&r(),w=k,b=requestAnimationFrame(j)}return r(),()=>{var k;p.forEach(S=>{a&&S.removeEventListener("scroll",r),o&&S.removeEventListener("resize",r)}),f==null||f(),(k=_)==null||k.disconnect(),_=null,d&&cancelAnimationFrame(b)}}const ldt=Pct,cdt=Ict,ddt=Tct,udt=Dct,hdt=Act,M4e=Mct,mdt=Lct,pdt=(t,s,r)=>{const n=new Map,a={platform:adt,...r},o={...a.platform,_c:n};return Cct(t,s,{...a,platform:o})};var fdt=typeof document<"u",gdt=function(){},lre=fdt?C.useLayoutEffect:gdt;function dne(t,s){if(t===s)return!0;if(typeof t!=typeof s)return!1;if(typeof t=="function"&&t.toString()===s.toString())return!0;let r,n,a;if(t&&s&&typeof t=="object"){if(Array.isArray(t)){if(r=t.length,r!==s.length)return!1;for(n=r;n--!==0;)if(!dne(t[n],s[n]))return!1;return!0}if(a=Object.keys(t),r=a.length,r!==Object.keys(s).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(s,a[n]))return!1;for(n=r;n--!==0;){const o=a[n];if(!(o==="_owner"&&t.$$typeof)&&!dne(t[o],s[o]))return!1}return!0}return t!==t&&s!==s}function QRe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function T4e(t,s){const r=QRe(t);return Math.round(s*r)/r}function bhe(t){const s=C.useRef(t);return lre(()=>{s.current=t}),s}function xdt(t){t===void 0&&(t={});const{placement:s="bottom",strategy:r="absolute",middleware:n=[],platform:a,elements:{reference:o,floating:l}={},transform:i=!0,whileElementsMounted:d,open:u}=t,[p,f]=C.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[y,_]=C.useState(n);dne(y,n)||_(n);const[b,w]=C.useState(null),[j,k]=C.useState(null),S=C.useCallback(le=>{le!==R.current&&(R.current=le,w(le))},[]),T=C.useCallback(le=>{le!==$.current&&($.current=le,k(le))},[]),I=o||b,L=l||j,R=C.useRef(null),$=C.useRef(null),q=C.useRef(p),U=d!=null,H=bhe(d),Y=bhe(a),se=bhe(u),te=C.useCallback(()=>{if(!R.current||!$.current)return;const le={placement:s,strategy:r,middleware:y};Y.current&&(le.platform=Y.current),pdt(R.current,$.current,le).then(he=>{const be={...he,isPositioned:se.current!==!1};Q.current&&!dne(q.current,be)&&(q.current=be,km.flushSync(()=>{f(be)}))})},[y,s,r,Y,se]);lre(()=>{u===!1&&q.current.isPositioned&&(q.current.isPositioned=!1,f(le=>({...le,isPositioned:!1})))},[u]);const Q=C.useRef(!1);lre(()=>(Q.current=!0,()=>{Q.current=!1}),[]),lre(()=>{if(I&&(R.current=I),L&&($.current=L),I&&L){if(H.current)return H.current(I,L,te);te()}},[I,L,te,H,U]);const de=C.useMemo(()=>({reference:R,floating:$,setReference:S,setFloating:T}),[S,T]),re=C.useMemo(()=>({reference:I,floating:L}),[I,L]),ae=C.useMemo(()=>{const le={position:r,left:0,top:0};if(!re.floating)return le;const he=T4e(re.floating,p.x),be=T4e(re.floating,p.y);return i?{...le,transform:"translate("+he+"px, "+be+"px)",...QRe(re.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:he,top:be}},[r,i,re.floating,p.x,p.y]);return C.useMemo(()=>({...p,update:te,refs:de,elements:re,floatingStyles:ae}),[p,te,de,re,ae])}const ydt=t=>{function s(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:t,fn(r){const{element:n,padding:a}=typeof t=="function"?t(r):t;return n&&s(n)?n.current!=null?M4e({element:n.current,padding:a}).fn(r):{}:n?M4e({element:n,padding:a}).fn(r):{}}}},vdt=(t,s)=>({...ldt(t),options:[t,s]}),_dt=(t,s)=>({...cdt(t),options:[t,s]}),bdt=(t,s)=>({...mdt(t),options:[t,s]}),wdt=(t,s)=>({...ddt(t),options:[t,s]}),jdt=(t,s)=>({...udt(t),options:[t,s]}),Ndt=(t,s)=>({...hdt(t),options:[t,s]}),kdt=(t,s)=>({...ydt(t),options:[t,s]});var Sdt="Arrow",JRe=C.forwardRef((t,s)=>{const{children:r,width:n=10,height:a=5,...o}=t;return e.jsx(Qr.svg,{...o,ref:s,width:n,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?r:e.jsx("polygon",{points:"0,0 30,0 15,10"})})});JRe.displayName=Sdt;var Cdt=JRe;function wL(t){const[s,r]=C.useState(void 0);return Zc(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const n=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const o=a[0];let l,i;if("borderBoxSize"in o){const d=o.borderBoxSize,u=Array.isArray(d)?d[0]:d;l=u.inlineSize,i=u.blockSize}else l=t.offsetWidth,i=t.offsetHeight;r({width:l,height:i})});return n.observe(t,{box:"border-box"}),()=>n.unobserve(t)}else r(void 0)},[t]),s}var y1e="Popper",[eFe,xy]=Ec(y1e),[Mdt,tFe]=eFe(y1e),sFe=t=>{const{__scopePopper:s,children:r}=t,[n,a]=C.useState(null);return e.jsx(Mdt,{scope:s,anchor:n,onAnchorChange:a,children:r})};sFe.displayName=y1e;var rFe="PopperAnchor",nFe=C.forwardRef((t,s)=>{const{__scopePopper:r,virtualRef:n,...a}=t,o=tFe(rFe,r),l=C.useRef(null),i=Ea(s,l);return C.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||l.current)}),n?null:e.jsx(Qr.div,{...a,ref:i})});nFe.displayName=rFe;var v1e="PopperContent",[Tdt,Adt]=eFe(v1e),aFe=C.forwardRef((t,s)=>{var Te,Fe,Ae,Ue,ut,De;const{__scopePopper:r,side:n="bottom",sideOffset:a=0,align:o="center",alignOffset:l=0,arrowPadding:i=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:p=0,sticky:f="partial",hideWhenDetached:y=!1,updatePositionStrategy:_="optimized",onPlaced:b,...w}=t,j=tFe(v1e,r),[k,S]=C.useState(null),T=Ea(s,Rt=>S(Rt)),[I,L]=C.useState(null),R=wL(I),$=(R==null?void 0:R.width)??0,q=(R==null?void 0:R.height)??0,U=n+(o!=="center"?"-"+o:""),H=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},Y=Array.isArray(u)?u:[u],se=Y.length>0,te={padding:H,boundary:Y.filter(Pdt),altBoundary:se},{refs:Q,floatingStyles:de,placement:re,isPositioned:ae,middlewareData:le}=xdt({strategy:"fixed",placement:U,whileElementsMounted:(...Rt)=>odt(...Rt,{animationFrame:_==="always"}),elements:{reference:j.anchor},middleware:[vdt({mainAxis:a+q,alignmentAxis:l}),d&&_dt({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?bdt():void 0,...te}),d&&wdt({...te}),jdt({...te,apply:({elements:Rt,rects:me,availableWidth:Xe,availableHeight:ot})=>{const{width:nt,height:Se}=me.reference,it=Rt.floating.style;it.setProperty("--radix-popper-available-width",`${Xe}px`),it.setProperty("--radix-popper-available-height",`${ot}px`),it.setProperty("--radix-popper-anchor-width",`${nt}px`),it.setProperty("--radix-popper-anchor-height",`${Se}px`)}}),I&&kdt({element:I,padding:i}),Idt({arrowWidth:$,arrowHeight:q}),y&&Ndt({strategy:"referenceHidden",...te})]}),[he,be]=lFe(re),_e=Vc(b);Zc(()=>{ae&&(_e==null||_e())},[ae,_e]);const je=(Te=le.arrow)==null?void 0:Te.x,Ne=(Fe=le.arrow)==null?void 0:Fe.y,Ge=((Ae=le.arrow)==null?void 0:Ae.centerOffset)!==0,[we,Me]=C.useState();return Zc(()=>{k&&Me(window.getComputedStyle(k).zIndex)},[k]),e.jsx("div",{ref:Q.setFloating,"data-radix-popper-content-wrapper":"",style:{...de,transform:ae?de.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:we,"--radix-popper-transform-origin":[(Ue=le.transformOrigin)==null?void 0:Ue.x,(ut=le.transformOrigin)==null?void 0:ut.y].join(" "),...((De=le.hide)==null?void 0:De.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(Tdt,{scope:r,placedSide:he,onArrowChange:L,arrowX:je,arrowY:Ne,shouldHideArrow:Ge,children:e.jsx(Qr.div,{"data-side":he,"data-align":be,...w,ref:T,style:{...w.style,animation:ae?void 0:"none"}})})})});aFe.displayName=v1e;var iFe="PopperArrow",Edt={top:"bottom",right:"left",bottom:"top",left:"right"},oFe=C.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,o=Adt(iFe,n),l=Edt[o.placedSide];return e.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[l]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:e.jsx(Cdt,{...a,ref:r,style:{...a.style,display:"block"}})})});oFe.displayName=iFe;function Pdt(t){return t!==null}var Idt=t=>({name:"transformOrigin",options:t,fn(s){var j,k,S;const{placement:r,rects:n,middlewareData:a}=s,l=((j=a.arrow)==null?void 0:j.centerOffset)!==0,i=l?0:t.arrowWidth,d=l?0:t.arrowHeight,[u,p]=lFe(r),f={start:"0%",center:"50%",end:"100%"}[p],y=(((k=a.arrow)==null?void 0:k.x)??0)+i/2,_=(((S=a.arrow)==null?void 0:S.y)??0)+d/2;let b="",w="";return u==="bottom"?(b=l?f:`${y}px`,w=`${-d}px`):u==="top"?(b=l?f:`${y}px`,w=`${n.floating.height+d}px`):u==="right"?(b=`${-d}px`,w=l?f:`${_}px`):u==="left"&&(b=`${n.floating.width+d}px`,w=l?f:`${_}px`),{data:{x:b,y:w}}}});function lFe(t){const[s,r="center"]=t.split("-");return[s,r]}var jL=sFe,gM=nFe,NL=aFe,kL=oFe,[yoe]=Ec("Tooltip",[xy]),voe=xy(),cFe="TooltipProvider",Ldt=700,Zfe="tooltip.open",[Ddt,_1e]=yoe(cFe),dFe=t=>{const{__scopeTooltip:s,delayDuration:r=Ldt,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=t,l=C.useRef(!0),i=C.useRef(!1),d=C.useRef(0);return C.useEffect(()=>{const u=d.current;return()=>window.clearTimeout(u)},[]),e.jsx(Ddt,{scope:s,isOpenDelayedRef:l,delayDuration:r,onOpen:C.useCallback(()=>{window.clearTimeout(d.current),l.current=!1},[]),onClose:C.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,n)},[n]),isPointerInTransitRef:i,onPointerInTransitChange:C.useCallback(u=>{i.current=u},[]),disableHoverableContent:a,children:o})};dFe.displayName=cFe;var ZI="Tooltip",[Odt,_oe]=yoe(ZI),uFe=t=>{const{__scopeTooltip:s,children:r,open:n,defaultOpen:a,onOpenChange:o,disableHoverableContent:l,delayDuration:i}=t,d=_1e(ZI,t.__scopeTooltip),u=voe(s),[p,f]=C.useState(null),y=Gd(),_=C.useRef(0),b=l??d.disableHoverableContent,w=i??d.delayDuration,j=C.useRef(!1),[k,S]=vu({prop:n,defaultProp:a??!1,onChange:$=>{$?(d.onOpen(),document.dispatchEvent(new CustomEvent(Zfe))):d.onClose(),o==null||o($)},caller:ZI}),T=C.useMemo(()=>k?j.current?"delayed-open":"instant-open":"closed",[k]),I=C.useCallback(()=>{window.clearTimeout(_.current),_.current=0,j.current=!1,S(!0)},[S]),L=C.useCallback(()=>{window.clearTimeout(_.current),_.current=0,S(!1)},[S]),R=C.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{j.current=!0,S(!0),_.current=0},w)},[w,S]);return C.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),e.jsx(jL,{...u,children:e.jsx(Odt,{scope:s,contentId:y,open:k,stateAttribute:T,trigger:p,onTriggerChange:f,onTriggerEnter:C.useCallback(()=>{d.isOpenDelayedRef.current?R():I()},[d.isOpenDelayedRef,R,I]),onTriggerLeave:C.useCallback(()=>{b?L():(window.clearTimeout(_.current),_.current=0)},[L,b]),onOpen:I,onClose:L,disableHoverableContent:b,children:r})})};uFe.displayName=ZI;var Yfe="TooltipTrigger",hFe=C.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=_oe(Yfe,r),o=_1e(Yfe,r),l=voe(r),i=C.useRef(null),d=Ea(s,i,a.onTriggerChange),u=C.useRef(!1),p=C.useRef(!1),f=C.useCallback(()=>u.current=!1,[]);return C.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),e.jsx(gM,{asChild:!0,...l,children:e.jsx(Qr.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:d,onPointerMove:Mr(t.onPointerMove,y=>{y.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:Mr(t.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:Mr(t.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Mr(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:Mr(t.onBlur,a.onClose),onClick:Mr(t.onClick,a.onClose)})})});hFe.displayName=Yfe;var Rdt="TooltipPortal",[N_s,Fdt]=yoe(Rdt,{forceMount:void 0}),g3="TooltipContent",mFe=C.forwardRef((t,s)=>{const r=Fdt(g3,t.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=t,l=_oe(g3,t.__scopeTooltip);return e.jsx(ud,{present:n||l.open,children:l.disableHoverableContent?e.jsx(pFe,{side:a,...o,ref:s}):e.jsx(zdt,{side:a,...o,ref:s})})}),zdt=C.forwardRef((t,s)=>{const r=_oe(g3,t.__scopeTooltip),n=_1e(g3,t.__scopeTooltip),a=C.useRef(null),o=Ea(s,a),[l,i]=C.useState(null),{trigger:d,onClose:u}=r,p=a.current,{onPointerInTransitChange:f}=n,y=C.useCallback(()=>{i(null),f(!1)},[f]),_=C.useCallback((b,w)=>{const j=b.currentTarget,k={x:b.clientX,y:b.clientY},S=Vdt(k,j.getBoundingClientRect()),T=Hdt(k,S),I=Wdt(w.getBoundingClientRect()),L=Kdt([...T,...I]);i(L),f(!0)},[f]);return C.useEffect(()=>()=>y(),[y]),C.useEffect(()=>{if(d&&p){const b=j=>_(j,p),w=j=>_(j,d);return d.addEventListener("pointerleave",b),p.addEventListener("pointerleave",w),()=>{d.removeEventListener("pointerleave",b),p.removeEventListener("pointerleave",w)}}},[d,p,_,y]),C.useEffect(()=>{if(l){const b=w=>{const j=w.target,k={x:w.clientX,y:w.clientY},S=(d==null?void 0:d.contains(j))||(p==null?void 0:p.contains(j)),T=!Gdt(k,l);S?y():T&&(y(),u())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[d,p,l,u,y]),e.jsx(pFe,{...t,ref:o})}),[Bdt,$dt]=yoe(ZI,{isInside:!1}),qdt=aRe("TooltipContent"),pFe=C.forwardRef((t,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=t,d=_oe(g3,r),u=voe(r),{onClose:p}=d;return C.useEffect(()=>(document.addEventListener(Zfe,p),()=>document.removeEventListener(Zfe,p)),[p]),C.useEffect(()=>{if(d.trigger){const f=y=>{const _=y.target;_!=null&&_.contains(d.trigger)&&p()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[d.trigger,p]),e.jsx(q_,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:f=>f.preventDefault(),onDismiss:p,children:e.jsxs(NL,{"data-state":d.stateAttribute,...u,...i,ref:s,style:{...i.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(qdt,{children:n}),e.jsx(Bdt,{scope:r,isInside:!0,children:e.jsx(Pot,{id:d.contentId,role:"tooltip",children:a||n})})]})})});mFe.displayName=g3;var fFe="TooltipArrow",Udt=C.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=voe(r);return $dt(fFe,r).isInside?null:e.jsx(kL,{...a,...n,ref:s})});Udt.displayName=fFe;function Vdt(t,s){const r=Math.abs(s.top-t.y),n=Math.abs(s.bottom-t.y),a=Math.abs(s.right-t.x),o=Math.abs(s.left-t.x);switch(Math.min(r,n,a,o)){case o:return"left";case a:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function Hdt(t,s,r=5){const n=[];switch(s){case"top":n.push({x:t.x-r,y:t.y+r},{x:t.x+r,y:t.y+r});break;case"bottom":n.push({x:t.x-r,y:t.y-r},{x:t.x+r,y:t.y-r});break;case"left":n.push({x:t.x+r,y:t.y-r},{x:t.x+r,y:t.y+r});break;case"right":n.push({x:t.x-r,y:t.y-r},{x:t.x-r,y:t.y+r});break}return n}function Wdt(t){const{top:s,right:r,bottom:n,left:a}=t;return[{x:a,y:s},{x:r,y:s},{x:r,y:n},{x:a,y:n}]}function Gdt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=y>n&&r<(f-u)*(n-p)/(y-p)+u&&(a=!a)}return a}function Kdt(t){const s=t.slice();return s.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),Zdt(s)}function Zdt(t){if(t.length<=1)return t.slice();const s=[];for(let n=0;n=2;){const o=s[s.length-1],l=s[s.length-2];if((o.x-l.x)*(a.y-l.y)>=(o.y-l.y)*(a.x-l.x))s.pop();else break}s.push(a)}s.pop();const r=[];for(let n=t.length-1;n>=0;n--){const a=t[n];for(;r.length>=2;){const o=r[r.length-1],l=r[r.length-2];if((o.x-l.x)*(a.y-l.y)>=(o.y-l.y)*(a.x-l.x))r.pop();else break}r.push(a)}return r.pop(),s.length===1&&r.length===1&&s[0].x===r[0].x&&s[0].y===r[0].y?s:s.concat(r)}var Ydt=dFe,Xdt=uFe,Qdt=hFe,gFe=mFe;const U_=Ydt,Wc=Xdt,Gc=Qdt,Cc=C.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(gFe,{ref:n,sideOffset:s,className:Pt("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));Cc.displayName=gFe.displayName;var xM=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Pk=typeof window>"u"||"Deno"in globalThis;function Eh(){}function Jdt(t,s){return typeof t=="function"?t(s):t}function Xfe(t){return typeof t=="number"&&t>=0&&t!==1/0}function xFe(t,s){return Math.max(t+(s||0)-Date.now(),0)}function g_(t,s){return typeof t=="function"?t(s):t}function Jp(t,s){return typeof t=="function"?t(s):t}function A4e(t,s){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:l,stale:i}=t;if(l){if(n){if(s.queryHash!==b1e(l,s.options))return!1}else if(!YI(s.queryKey,l))return!1}if(r!=="all"){const d=s.isActive();if(r==="active"&&!d||r==="inactive"&&d)return!1}return!(typeof i=="boolean"&&s.isStale()!==i||a&&a!==s.state.fetchStatus||o&&!o(s))}function E4e(t,s){const{exact:r,status:n,predicate:a,mutationKey:o}=t;if(o){if(!s.options.mutationKey)return!1;if(r){if(Ik(s.options.mutationKey)!==Ik(o))return!1}else if(!YI(s.options.mutationKey,o))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function b1e(t,s){return((s==null?void 0:s.queryKeyHashFn)||Ik)(t)}function Ik(t){return JSON.stringify(t,(s,r)=>Qfe(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function YI(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"&&typeof s=="object"?Object.keys(s).every(r=>YI(t[r],s[r])):!1}function yFe(t,s){if(t===s)return t;const r=P4e(t)&&P4e(s);if(r||Qfe(t)&&Qfe(s)){const n=r?t:Object.keys(t),a=n.length,o=r?s:Object.keys(s),l=o.length,i=r?[]:{},d=new Set(n);let u=0;for(let p=0;p{setTimeout(s,t)})}function Jfe(t,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,s):r.structuralSharing!==!1?yFe(t,s):s}function tut(t,s,r=0){const n=[...t,s];return r&&n.length>r?n.slice(1):n}function sut(t,s,r=0){const n=[s,...t];return r&&n.length>r?n.slice(0,-1):n}var w1e=Symbol();function vFe(t,s){return!t.queryFn&&(s!=null&&s.initialPromise)?()=>s.initialPromise:!t.queryFn||t.queryFn===w1e?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function _Fe(t,s){return typeof t=="function"?t(...s):!!t}var WN,T1,Y5,LDe,rut=(LDe=class extends xM{constructor(){super();$a(this,WN);$a(this,T1);$a(this,Y5);$n(this,Y5,s=>{if(!Pk&&window.addEventListener){const r=()=>s();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){us(this,T1)||this.setEventListener(us(this,Y5))}onUnsubscribe(){var s;this.hasListeners()||((s=us(this,T1))==null||s.call(this),$n(this,T1,void 0))}setEventListener(s){var r;$n(this,Y5,s),(r=us(this,T1))==null||r.call(this),$n(this,T1,s(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(s){us(this,WN)!==s&&($n(this,WN,s),this.onFocus())}onFocus(){const s=this.isFocused();this.listeners.forEach(r=>{r(s)})}isFocused(){var s;return typeof us(this,WN)=="boolean"?us(this,WN):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},WN=new WeakMap,T1=new WeakMap,Y5=new WeakMap,LDe),j1e=new rut,X5,A1,Q5,DDe,nut=(DDe=class extends xM{constructor(){super();$a(this,X5,!0);$a(this,A1);$a(this,Q5);$n(this,Q5,s=>{if(!Pk&&window.addEventListener){const r=()=>s(!0),n=()=>s(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){us(this,A1)||this.setEventListener(us(this,Q5))}onUnsubscribe(){var s;this.hasListeners()||((s=us(this,A1))==null||s.call(this),$n(this,A1,void 0))}setEventListener(s){var r;$n(this,Q5,s),(r=us(this,A1))==null||r.call(this),$n(this,A1,s(this.setOnline.bind(this)))}setOnline(s){us(this,X5)!==s&&($n(this,X5,s),this.listeners.forEach(n=>{n(s)}))}isOnline(){return us(this,X5)}},X5=new WeakMap,A1=new WeakMap,Q5=new WeakMap,DDe),hne=new nut;function ege(){let t,s;const r=new Promise((a,o)=>{t=a,s=o});r.status="pending",r.catch(()=>{});function n(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{n({status:"fulfilled",value:a}),t(a)},r.reject=a=>{n({status:"rejected",reason:a}),s(a)},r}function aut(t){return Math.min(1e3*2**t,3e4)}function bFe(t){return(t??"online")==="online"?hne.isOnline():!0}var wFe=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function whe(t){return t instanceof wFe}function jFe(t){let s=!1,r=0,n=!1,a;const o=ege(),l=w=>{var j;n||(y(new wFe(w)),(j=t.abort)==null||j.call(t))},i=()=>{s=!0},d=()=>{s=!1},u=()=>j1e.isFocused()&&(t.networkMode==="always"||hne.isOnline())&&t.canRun(),p=()=>bFe(t.networkMode)&&t.canRun(),f=w=>{var j;n||(n=!0,(j=t.onSuccess)==null||j.call(t,w),a==null||a(),o.resolve(w))},y=w=>{var j;n||(n=!0,(j=t.onError)==null||j.call(t,w),a==null||a(),o.reject(w))},_=()=>new Promise(w=>{var j;a=k=>{(n||u())&&w(k)},(j=t.onPause)==null||j.call(t)}).then(()=>{var w;a=void 0,n||(w=t.onContinue)==null||w.call(t)}),b=()=>{if(n)return;let w;const j=r===0?t.initialPromise:void 0;try{w=j??t.fn()}catch(k){w=Promise.reject(k)}Promise.resolve(w).then(f).catch(k=>{var R;if(n)return;const S=t.retry??(Pk?0:3),T=t.retryDelay??aut,I=typeof T=="function"?T(r,k):T,L=S===!0||typeof S=="number"&&ru()?void 0:_()).then(()=>{s?y(k):b()})})};return{promise:o,cancel:l,continue:()=>(a==null||a(),o),cancelRetry:i,continueRetry:d,canStart:p,start:()=>(p()?b():_().then(b),o)}}var iut=t=>setTimeout(t,0);function out(){let t=[],s=0,r=i=>{i()},n=i=>{i()},a=iut;const o=i=>{s?t.push(i):a(()=>{r(i)})},l=()=>{const i=t;t=[],i.length&&a(()=>{n(()=>{i.forEach(d=>{r(d)})})})};return{batch:i=>{let d;s++;try{d=i()}finally{s--,s||l()}return d},batchCalls:i=>(...d)=>{o(()=>{i(...d)})},schedule:o,setNotifyFunction:i=>{r=i},setBatchNotifyFunction:i=>{n=i},setScheduler:i=>{a=i}}}var zd=out(),GN,ODe,NFe=(ODe=class{constructor(){$a(this,GN)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Xfe(this.gcTime)&&$n(this,GN,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Pk?1/0:5*60*1e3))}clearGcTimeout(){us(this,GN)&&(clearTimeout(us(this,GN)),$n(this,GN,void 0))}},GN=new WeakMap,ODe),J5,KN,Qp,ZN,Zu,dL,YN,Ng,n0,RDe,lut=(RDe=class extends NFe{constructor(s){super();$a(this,Ng);$a(this,J5);$a(this,KN);$a(this,Qp);$a(this,ZN);$a(this,Zu);$a(this,dL);$a(this,YN);$n(this,YN,!1),$n(this,dL,s.defaultOptions),this.setOptions(s.options),this.observers=[],$n(this,ZN,s.client),$n(this,Qp,us(this,ZN).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,$n(this,J5,cut(this.options)),this.state=s.state??us(this,J5),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var s;return(s=us(this,Zu))==null?void 0:s.promise}setOptions(s){this.options={...us(this,dL),...s},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&us(this,Qp).remove(this)}setData(s,r){const n=Jfe(this.state.data,s,this.options);return Ui(this,Ng,n0).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(s,r){Ui(this,Ng,n0).call(this,{type:"setState",state:s,setStateOptions:r})}cancel(s){var n,a;const r=(n=us(this,Zu))==null?void 0:n.promise;return(a=us(this,Zu))==null||a.cancel(s),r?r.then(Eh).catch(Eh):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(us(this,J5))}isActive(){return this.observers.some(s=>Jp(s.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===w1e||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(s=>g_(s.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(s=>s.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(s=0){return this.state.data===void 0?!0:s==="static"?!1:this.state.isInvalidated?!0:!xFe(this.state.dataUpdatedAt,s)}onFocus(){var r;const s=this.observers.find(n=>n.shouldFetchOnWindowFocus());s==null||s.refetch({cancelRefetch:!1}),(r=us(this,Zu))==null||r.continue()}onOnline(){var r;const s=this.observers.find(n=>n.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(r=us(this,Zu))==null||r.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),us(this,Qp).notify({type:"observerAdded",query:this,observer:s}))}removeObserver(s){this.observers.includes(s)&&(this.observers=this.observers.filter(r=>r!==s),this.observers.length||(us(this,Zu)&&(us(this,YN)?us(this,Zu).cancel({revert:!0}):us(this,Zu).cancelRetry()),this.scheduleGc()),us(this,Qp).notify({type:"observerRemoved",query:this,observer:s}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ui(this,Ng,n0).call(this,{type:"invalidate"})}fetch(s,r){var u,p,f;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(us(this,Zu))return us(this,Zu).continueRetry(),us(this,Zu).promise}if(s&&this.setOptions(s),!this.options.queryFn){const y=this.observers.find(_=>_.options.queryFn);y&&this.setOptions(y.options)}const n=new AbortController,a=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>($n(this,YN,!0),n.signal)})},o=()=>{const y=vFe(this.options,r),b=(()=>{const w={client:us(this,ZN),queryKey:this.queryKey,meta:this.meta};return a(w),w})();return $n(this,YN,!1),this.options.persister?this.options.persister(y,b,this):y(b)},i=(()=>{const y={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:us(this,ZN),state:this.state,fetchFn:o};return a(y),y})();(u=this.options.behavior)==null||u.onFetch(i,this),$n(this,KN,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=i.fetchOptions)==null?void 0:p.meta))&&Ui(this,Ng,n0).call(this,{type:"fetch",meta:(f=i.fetchOptions)==null?void 0:f.meta});const d=y=>{var _,b,w,j;whe(y)&&y.silent||Ui(this,Ng,n0).call(this,{type:"error",error:y}),whe(y)||((b=(_=us(this,Qp).config).onError)==null||b.call(_,y,this),(j=(w=us(this,Qp).config).onSettled)==null||j.call(w,this.state.data,y,this)),this.scheduleGc()};return $n(this,Zu,jFe({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:y=>{var _,b,w,j;if(y===void 0){d(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(y)}catch(k){d(k);return}(b=(_=us(this,Qp).config).onSuccess)==null||b.call(_,y,this),(j=(w=us(this,Qp).config).onSettled)==null||j.call(w,y,this.state.error,this),this.scheduleGc()},onError:d,onFail:(y,_)=>{Ui(this,Ng,n0).call(this,{type:"failed",failureCount:y,error:_})},onPause:()=>{Ui(this,Ng,n0).call(this,{type:"pause"})},onContinue:()=>{Ui(this,Ng,n0).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0})),us(this,Zu).start()}},J5=new WeakMap,KN=new WeakMap,Qp=new WeakMap,ZN=new WeakMap,Zu=new WeakMap,dL=new WeakMap,YN=new WeakMap,Ng=new WeakSet,n0=function(s){const r=n=>{switch(s.type){case"failed":return{...n,fetchFailureCount:s.failureCount,fetchFailureReason:s.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...kFe(n.data,this.options),fetchMeta:s.meta??null};case"success":return $n(this,KN,void 0),{...n,data:s.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:s.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!s.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const a=s.error;return whe(a)&&a.revert&&us(this,KN)?{...us(this,KN),fetchStatus:"idle"}:{...n,error:a,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...s.state}}};this.state=r(this.state),zd.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),us(this,Qp).notify({query:this,type:"updated",action:s})})},RDe);function kFe(t,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:bFe(s.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function cut(t){const s=typeof t.initialData=="function"?t.initialData():t.initialData,r=s!==void 0,n=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:s,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Dx,FDe,dut=(FDe=class extends xM{constructor(s={}){super();$a(this,Dx);this.config=s,$n(this,Dx,new Map)}build(s,r,n){const a=r.queryKey,o=r.queryHash??b1e(a,r);let l=this.get(o);return l||(l=new lut({client:s,queryKey:a,queryHash:o,options:s.defaultQueryOptions(r),state:n,defaultOptions:s.getQueryDefaults(a)}),this.add(l)),l}add(s){us(this,Dx).has(s.queryHash)||(us(this,Dx).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const r=us(this,Dx).get(s.queryHash);r&&(s.destroy(),r===s&&us(this,Dx).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){zd.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return us(this,Dx).get(s)}getAll(){return[...us(this,Dx).values()]}find(s){const r={exact:!0,...s};return this.getAll().find(n=>A4e(r,n))}findAll(s={}){const r=this.getAll();return Object.keys(s).length>0?r.filter(n=>A4e(s,n)):r}notify(s){zd.batch(()=>{this.listeners.forEach(r=>{r(s)})})}onFocus(){zd.batch(()=>{this.getAll().forEach(s=>{s.onFocus()})})}onOnline(){zd.batch(()=>{this.getAll().forEach(s=>{s.onOnline()})})}},Dx=new WeakMap,FDe),Ox,Mh,XN,Rx,i1,zDe,uut=(zDe=class extends NFe{constructor(s){super();$a(this,Rx);$a(this,Ox);$a(this,Mh);$a(this,XN);this.mutationId=s.mutationId,$n(this,Mh,s.mutationCache),$n(this,Ox,[]),this.state=s.state||SFe(),this.setOptions(s.options),this.scheduleGc()}setOptions(s){this.options=s,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(s){us(this,Ox).includes(s)||(us(this,Ox).push(s),this.clearGcTimeout(),us(this,Mh).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){$n(this,Ox,us(this,Ox).filter(r=>r!==s)),this.scheduleGc(),us(this,Mh).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){us(this,Ox).length||(this.state.status==="pending"?this.scheduleGc():us(this,Mh).remove(this))}continue(){var s;return((s=us(this,XN))==null?void 0:s.continue())??this.execute(this.state.variables)}async execute(s){var o,l,i,d,u,p,f,y,_,b,w,j,k,S,T,I,L,R,$,q;const r=()=>{Ui(this,Rx,i1).call(this,{type:"continue"})};$n(this,XN,jFe({fn:()=>this.options.mutationFn?this.options.mutationFn(s):Promise.reject(new Error("No mutationFn found")),onFail:(U,H)=>{Ui(this,Rx,i1).call(this,{type:"failed",failureCount:U,error:H})},onPause:()=>{Ui(this,Rx,i1).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>us(this,Mh).canRun(this)}));const n=this.state.status==="pending",a=!us(this,XN).canStart();try{if(n)r();else{Ui(this,Rx,i1).call(this,{type:"pending",variables:s,isPaused:a}),await((l=(o=us(this,Mh).config).onMutate)==null?void 0:l.call(o,s,this));const H=await((d=(i=this.options).onMutate)==null?void 0:d.call(i,s));H!==this.state.context&&Ui(this,Rx,i1).call(this,{type:"pending",context:H,variables:s,isPaused:a})}const U=await us(this,XN).start();return await((p=(u=us(this,Mh).config).onSuccess)==null?void 0:p.call(u,U,s,this.state.context,this)),await((y=(f=this.options).onSuccess)==null?void 0:y.call(f,U,s,this.state.context)),await((b=(_=us(this,Mh).config).onSettled)==null?void 0:b.call(_,U,null,this.state.variables,this.state.context,this)),await((j=(w=this.options).onSettled)==null?void 0:j.call(w,U,null,s,this.state.context)),Ui(this,Rx,i1).call(this,{type:"success",data:U}),U}catch(U){try{throw await((S=(k=us(this,Mh).config).onError)==null?void 0:S.call(k,U,s,this.state.context,this)),await((I=(T=this.options).onError)==null?void 0:I.call(T,U,s,this.state.context)),await((R=(L=us(this,Mh).config).onSettled)==null?void 0:R.call(L,void 0,U,this.state.variables,this.state.context,this)),await((q=($=this.options).onSettled)==null?void 0:q.call($,void 0,U,s,this.state.context)),U}finally{Ui(this,Rx,i1).call(this,{type:"error",error:U})}}finally{us(this,Mh).runNext(this)}}},Ox=new WeakMap,Mh=new WeakMap,XN=new WeakMap,Rx=new WeakSet,i1=function(s){const r=n=>{switch(s.type){case"failed":return{...n,failureCount:s.failureCount,failureReason:s.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:s.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:s.isPaused,status:"pending",variables:s.variables,submittedAt:Date.now()};case"success":return{...n,data:s.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:s.error,failureCount:n.failureCount+1,failureReason:s.error,isPaused:!1,status:"error"}}};this.state=r(this.state),zd.batch(()=>{us(this,Ox).forEach(n=>{n.onMutationUpdate(s)}),us(this,Mh).notify({mutation:this,type:"updated",action:s})})},zDe);function SFe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var y0,kg,uL,BDe,hut=(BDe=class extends xM{constructor(s={}){super();$a(this,y0);$a(this,kg);$a(this,uL);this.config=s,$n(this,y0,new Set),$n(this,kg,new Map),$n(this,uL,0)}build(s,r,n){const a=new uut({mutationCache:this,mutationId:++c8(this,uL)._,options:s.defaultMutationOptions(r),state:n});return this.add(a),a}add(s){us(this,y0).add(s);const r=E8(s);if(typeof r=="string"){const n=us(this,kg).get(r);n?n.push(s):us(this,kg).set(r,[s])}this.notify({type:"added",mutation:s})}remove(s){if(us(this,y0).delete(s)){const r=E8(s);if(typeof r=="string"){const n=us(this,kg).get(r);if(n)if(n.length>1){const a=n.indexOf(s);a!==-1&&n.splice(a,1)}else n[0]===s&&us(this,kg).delete(r)}}this.notify({type:"removed",mutation:s})}canRun(s){const r=E8(s);if(typeof r=="string"){const n=us(this,kg).get(r),a=n==null?void 0:n.find(o=>o.state.status==="pending");return!a||a===s}else return!0}runNext(s){var n;const r=E8(s);if(typeof r=="string"){const a=(n=us(this,kg).get(r))==null?void 0:n.find(o=>o!==s&&o.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){zd.batch(()=>{us(this,y0).forEach(s=>{this.notify({type:"removed",mutation:s})}),us(this,y0).clear(),us(this,kg).clear()})}getAll(){return Array.from(us(this,y0))}find(s){const r={exact:!0,...s};return this.getAll().find(n=>E4e(r,n))}findAll(s={}){return this.getAll().filter(r=>E4e(s,r))}notify(s){zd.batch(()=>{this.listeners.forEach(r=>{r(s)})})}resumePausedMutations(){const s=this.getAll().filter(r=>r.state.isPaused);return zd.batch(()=>Promise.all(s.map(r=>r.continue().catch(Eh))))}},y0=new WeakMap,kg=new WeakMap,uL=new WeakMap,BDe);function E8(t){var s;return(s=t.options.scope)==null?void 0:s.id}function mne(t){return{onFetch:(s,r)=>{var p,f,y,_,b;const n=s.options,a=(y=(f=(p=s.fetchOptions)==null?void 0:p.meta)==null?void 0:f.fetchMore)==null?void 0:y.direction,o=((_=s.state.data)==null?void 0:_.pages)||[],l=((b=s.state.data)==null?void 0:b.pageParams)||[];let i={pages:[],pageParams:[]},d=0;const u=async()=>{let w=!1;const j=T=>{Object.defineProperty(T,"signal",{enumerable:!0,get:()=>(s.signal.aborted?w=!0:s.signal.addEventListener("abort",()=>{w=!0}),s.signal)})},k=vFe(s.options,s.fetchOptions),S=async(T,I,L)=>{if(w)return Promise.reject();if(I==null&&T.pages.length)return Promise.resolve(T);const $=(()=>{const Y={client:s.client,queryKey:s.queryKey,pageParam:I,direction:L?"backward":"forward",meta:s.options.meta};return j(Y),Y})(),q=await k($),{maxPages:U}=s.options,H=L?sut:tut;return{pages:H(T.pages,q,U),pageParams:H(T.pageParams,I,U)}};if(a&&o.length){const T=a==="backward",I=T?CFe:tge,L={pages:o,pageParams:l},R=I(n,L);i=await S(L,R,T)}else{const T=t??o.length;do{const I=d===0?l[0]??n.initialPageParam:tge(n,i);if(d>0&&I==null)break;i=await S(i,I),d++}while(d{var w,j;return(j=(w=s.options).persister)==null?void 0:j.call(w,u,{client:s.client,queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},r)}:s.fetchFn=u}}}function tge(t,{pages:s,pageParams:r}){const n=s.length-1;return s.length>0?t.getNextPageParam(s[n],s,r[n],r):void 0}function CFe(t,{pages:s,pageParams:r}){var n;return s.length>0?(n=t.getPreviousPageParam)==null?void 0:n.call(t,s[0],s,r[0],r):void 0}function mut(t,s){return s?tge(t,s)!=null:!1}function put(t,s){return!s||!t.getPreviousPageParam?!1:CFe(t,s)!=null}var Oc,E1,P1,e3,t3,I1,s3,r3,$De,fut=($De=class{constructor(t={}){$a(this,Oc);$a(this,E1);$a(this,P1);$a(this,e3);$a(this,t3);$a(this,I1);$a(this,s3);$a(this,r3);$n(this,Oc,t.queryCache||new dut),$n(this,E1,t.mutationCache||new hut),$n(this,P1,t.defaultOptions||{}),$n(this,e3,new Map),$n(this,t3,new Map),$n(this,I1,0)}mount(){c8(this,I1)._++,us(this,I1)===1&&($n(this,s3,j1e.subscribe(async t=>{t&&(await this.resumePausedMutations(),us(this,Oc).onFocus())})),$n(this,r3,hne.subscribe(async t=>{t&&(await this.resumePausedMutations(),us(this,Oc).onOnline())})))}unmount(){var t,s;c8(this,I1)._--,us(this,I1)===0&&((t=us(this,s3))==null||t.call(this),$n(this,s3,void 0),(s=us(this,r3))==null||s.call(this),$n(this,r3,void 0))}isFetching(t){return us(this,Oc).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return us(this,E1).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=us(this,Oc).get(s.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const s=this.defaultQueryOptions(t),r=us(this,Oc).build(this,s),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(g_(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(n))}getQueriesData(t){return us(this,Oc).findAll(t).map(({queryKey:s,state:r})=>{const n=r.data;return[s,n]})}setQueryData(t,s,r){const n=this.defaultQueryOptions({queryKey:t}),a=us(this,Oc).get(n.queryHash),o=a==null?void 0:a.state.data,l=Jdt(s,o);if(l!==void 0)return us(this,Oc).build(this,n).setData(l,{...r,manual:!0})}setQueriesData(t,s,r){return zd.batch(()=>us(this,Oc).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,s,r)]))}getQueryState(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=us(this,Oc).get(s.queryHash))==null?void 0:r.state}removeQueries(t){const s=us(this,Oc);zd.batch(()=>{s.findAll(t).forEach(r=>{s.remove(r)})})}resetQueries(t,s){const r=us(this,Oc);return zd.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},s)))}cancelQueries(t,s={}){const r={revert:!0,...s},n=zd.batch(()=>us(this,Oc).findAll(t).map(a=>a.cancel(r)));return Promise.all(n).then(Eh).catch(Eh)}invalidateQueries(t,s={}){return zd.batch(()=>(us(this,Oc).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},s)))}refetchQueries(t,s={}){const r={...s,cancelRefetch:s.cancelRefetch??!0},n=zd.batch(()=>us(this,Oc).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(Eh)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(Eh)}fetchQuery(t){const s=this.defaultQueryOptions(t);s.retry===void 0&&(s.retry=!1);const r=us(this,Oc).build(this,s);return r.isStaleByTime(g_(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Eh).catch(Eh)}fetchInfiniteQuery(t){return t.behavior=mne(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Eh).catch(Eh)}ensureInfiniteQueryData(t){return t.behavior=mne(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return hne.isOnline()?us(this,E1).resumePausedMutations():Promise.resolve()}getQueryCache(){return us(this,Oc)}getMutationCache(){return us(this,E1)}getDefaultOptions(){return us(this,P1)}setDefaultOptions(t){$n(this,P1,t)}setQueryDefaults(t,s){us(this,e3).set(Ik(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...us(this,e3).values()],r={};return s.forEach(n=>{YI(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,s){us(this,t3).set(Ik(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...us(this,t3).values()],r={};return s.forEach(n=>{YI(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const s={...us(this,P1).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return s.queryHash||(s.queryHash=b1e(s.queryKey,s)),s.refetchOnReconnect===void 0&&(s.refetchOnReconnect=s.networkMode!=="always"),s.throwOnError===void 0&&(s.throwOnError=!!s.suspense),!s.networkMode&&s.persister&&(s.networkMode="offlineFirst"),s.queryFn===w1e&&(s.enabled=!1),s}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...us(this,P1).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){us(this,Oc).clear(),us(this,E1).clear()}},Oc=new WeakMap,E1=new WeakMap,P1=new WeakMap,e3=new WeakMap,t3=new WeakMap,I1=new WeakMap,s3=new WeakMap,r3=new WeakMap,$De),fm,xo,hL,Th,QN,n3,L1,D1,mL,a3,i3,JN,ek,O1,o3,Vo,IE,sge,rge,nge,age,ige,oge,lge,TFe,qDe,MFe=(qDe=class extends xM{constructor(s,r){super();$a(this,Vo);$a(this,fm);$a(this,xo);$a(this,hL);$a(this,Th);$a(this,QN);$a(this,n3);$a(this,L1);$a(this,D1);$a(this,mL);$a(this,a3);$a(this,i3);$a(this,JN);$a(this,ek);$a(this,O1);$a(this,o3,new Set);this.options=r,$n(this,fm,s),$n(this,D1,null),$n(this,L1,ege()),this.options.experimental_prefetchInRender||us(this,L1).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(us(this,xo).addObserver(this),L4e(us(this,xo),this.options)?Ui(this,Vo,IE).call(this):this.updateResult(),Ui(this,Vo,age).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return cge(us(this,xo),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return cge(us(this,xo),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ui(this,Vo,ige).call(this),Ui(this,Vo,oge).call(this),us(this,xo).removeObserver(this)}setOptions(s){const r=this.options,n=us(this,xo);if(this.options=us(this,fm).defaultQueryOptions(s),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Jp(this.options.enabled,us(this,xo))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ui(this,Vo,lge).call(this),us(this,xo).setOptions(this.options),r._defaulted&&!une(this.options,r)&&us(this,fm).getQueryCache().notify({type:"observerOptionsUpdated",query:us(this,xo),observer:this});const a=this.hasListeners();a&&D4e(us(this,xo),n,this.options,r)&&Ui(this,Vo,IE).call(this),this.updateResult(),a&&(us(this,xo)!==n||Jp(this.options.enabled,us(this,xo))!==Jp(r.enabled,us(this,xo))||g_(this.options.staleTime,us(this,xo))!==g_(r.staleTime,us(this,xo)))&&Ui(this,Vo,sge).call(this);const o=Ui(this,Vo,rge).call(this);a&&(us(this,xo)!==n||Jp(this.options.enabled,us(this,xo))!==Jp(r.enabled,us(this,xo))||o!==us(this,O1))&&Ui(this,Vo,nge).call(this,o)}getOptimisticResult(s){const r=us(this,fm).getQueryCache().build(us(this,fm),s),n=this.createResult(r,s);return xut(this,n)&&($n(this,Th,n),$n(this,n3,this.options),$n(this,QN,us(this,xo).state)),n}getCurrentResult(){return us(this,Th)}trackResult(s,r){return new Proxy(s,{get:(n,a)=>(this.trackProp(a),r==null||r(a),Reflect.get(n,a))})}trackProp(s){us(this,o3).add(s)}getCurrentQuery(){return us(this,xo)}refetch({...s}={}){return this.fetch({...s})}fetchOptimistic(s){const r=us(this,fm).defaultQueryOptions(s),n=us(this,fm).getQueryCache().build(us(this,fm),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(s){return Ui(this,Vo,IE).call(this,{...s,cancelRefetch:s.cancelRefetch??!0}).then(()=>(this.updateResult(),us(this,Th)))}createResult(s,r){var U;const n=us(this,xo),a=this.options,o=us(this,Th),l=us(this,QN),i=us(this,n3),u=s!==n?s.state:us(this,hL),{state:p}=s;let f={...p},y=!1,_;if(r._optimisticResults){const H=this.hasListeners(),Y=!H&&L4e(s,r),se=H&&D4e(s,n,r,a);(Y||se)&&(f={...f,...kFe(p.data,s.options)}),r._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:b,errorUpdatedAt:w,status:j}=f;_=f.data;let k=!1;if(r.placeholderData!==void 0&&_===void 0&&j==="pending"){let H;o!=null&&o.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(H=o.data,k=!0):H=typeof r.placeholderData=="function"?r.placeholderData((U=us(this,i3))==null?void 0:U.state.data,us(this,i3)):r.placeholderData,H!==void 0&&(j="success",_=Jfe(o==null?void 0:o.data,H,r),y=!0)}if(r.select&&_!==void 0&&!k)if(o&&_===(l==null?void 0:l.data)&&r.select===us(this,mL))_=us(this,a3);else try{$n(this,mL,r.select),_=r.select(_),_=Jfe(o==null?void 0:o.data,_,r),$n(this,a3,_),$n(this,D1,null)}catch(H){$n(this,D1,H)}us(this,D1)&&(b=us(this,D1),_=us(this,a3),w=Date.now(),j="error");const S=f.fetchStatus==="fetching",T=j==="pending",I=j==="error",L=T&&S,R=_!==void 0,q={status:j,fetchStatus:f.fetchStatus,isPending:T,isSuccess:j==="success",isError:I,isInitialLoading:L,isLoading:L,data:_,dataUpdatedAt:f.dataUpdatedAt,error:b,errorUpdatedAt:w,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:S,isRefetching:S&&!T,isLoadingError:I&&!R,isPaused:f.fetchStatus==="paused",isPlaceholderData:y,isRefetchError:I&&R,isStale:N1e(s,r),refetch:this.refetch,promise:us(this,L1),isEnabled:Jp(r.enabled,s)!==!1};if(this.options.experimental_prefetchInRender){const H=te=>{q.status==="error"?te.reject(q.error):q.data!==void 0&&te.resolve(q.data)},Y=()=>{const te=$n(this,L1,q.promise=ege());H(te)},se=us(this,L1);switch(se.status){case"pending":s.queryHash===n.queryHash&&H(se);break;case"fulfilled":(q.status==="error"||q.data!==se.value)&&Y();break;case"rejected":(q.status!=="error"||q.error!==se.reason)&&Y();break}}return q}updateResult(){const s=us(this,Th),r=this.createResult(us(this,xo),this.options);if($n(this,QN,us(this,xo).state),$n(this,n3,this.options),us(this,QN).data!==void 0&&$n(this,i3,us(this,xo)),une(r,s))return;$n(this,Th,r);const n=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!us(this,o3).size)return!0;const l=new Set(o??us(this,o3));return this.options.throwOnError&&l.add("error"),Object.keys(us(this,Th)).some(i=>{const d=i;return us(this,Th)[d]!==s[d]&&l.has(d)})};Ui(this,Vo,TFe).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ui(this,Vo,age).call(this)}},fm=new WeakMap,xo=new WeakMap,hL=new WeakMap,Th=new WeakMap,QN=new WeakMap,n3=new WeakMap,L1=new WeakMap,D1=new WeakMap,mL=new WeakMap,a3=new WeakMap,i3=new WeakMap,JN=new WeakMap,ek=new WeakMap,O1=new WeakMap,o3=new WeakMap,Vo=new WeakSet,IE=function(s){Ui(this,Vo,lge).call(this);let r=us(this,xo).fetch(this.options,s);return s!=null&&s.throwOnError||(r=r.catch(Eh)),r},sge=function(){Ui(this,Vo,ige).call(this);const s=g_(this.options.staleTime,us(this,xo));if(Pk||us(this,Th).isStale||!Xfe(s))return;const n=xFe(us(this,Th).dataUpdatedAt,s)+1;$n(this,JN,setTimeout(()=>{us(this,Th).isStale||this.updateResult()},n))},rge=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(us(this,xo)):this.options.refetchInterval)??!1},nge=function(s){Ui(this,Vo,oge).call(this),$n(this,O1,s),!(Pk||Jp(this.options.enabled,us(this,xo))===!1||!Xfe(us(this,O1))||us(this,O1)===0)&&$n(this,ek,setInterval(()=>{(this.options.refetchIntervalInBackground||j1e.isFocused())&&Ui(this,Vo,IE).call(this)},us(this,O1)))},age=function(){Ui(this,Vo,sge).call(this),Ui(this,Vo,nge).call(this,Ui(this,Vo,rge).call(this))},ige=function(){us(this,JN)&&(clearTimeout(us(this,JN)),$n(this,JN,void 0))},oge=function(){us(this,ek)&&(clearInterval(us(this,ek)),$n(this,ek,void 0))},lge=function(){const s=us(this,fm).getQueryCache().build(us(this,fm),this.options);if(s===us(this,xo))return;const r=us(this,xo);$n(this,xo,s),$n(this,hL,s.state),this.hasListeners()&&(r==null||r.removeObserver(this),s.addObserver(this))},TFe=function(s){zd.batch(()=>{s.listeners&&this.listeners.forEach(r=>{r(us(this,Th))}),us(this,fm).getQueryCache().notify({query:us(this,xo),type:"observerResultsUpdated"})})},qDe);function gut(t,s){return Jp(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&s.retryOnMount===!1)}function L4e(t,s){return gut(t,s)||t.state.data!==void 0&&cge(t,s,s.refetchOnMount)}function cge(t,s,r){if(Jp(s.enabled,t)!==!1&&g_(s.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&N1e(t,s)}return!1}function D4e(t,s,r,n){return(t!==s||Jp(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&N1e(t,r)}function N1e(t,s){return Jp(s.enabled,t)!==!1&&t.isStaleByTime(g_(s.staleTime,t))}function xut(t,s){return!une(t.getCurrentResult(),s)}var yut=class extends MFe{constructor(t,s){super(t,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){super.setOptions({...t,behavior:mne()})}getOptimisticResult(t){return t.behavior=mne(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,s){var b,w;const{state:r}=t,n=super.createResult(t,s),{isFetching:a,isRefetching:o,isError:l,isRefetchError:i}=n,d=(w=(b=r.fetchMeta)==null?void 0:b.fetchMore)==null?void 0:w.direction,u=l&&d==="forward",p=a&&d==="forward",f=l&&d==="backward",y=a&&d==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:mut(s,r.data),hasPreviousPage:put(s,r.data),isFetchNextPageError:u,isFetchingNextPage:p,isFetchPreviousPageError:f,isFetchingPreviousPage:y,isRefetchError:i&&!u&&!f,isRefetching:o&&!p&&!y}}},R1,F1,gm,v0,Y0,cre,dge,UDe,vut=(UDe=class extends xM{constructor(r,n){super();$a(this,Y0);$a(this,R1);$a(this,F1);$a(this,gm);$a(this,v0);$n(this,R1,r),this.setOptions(n),this.bindMethods(),Ui(this,Y0,cre).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var a;const n=this.options;this.options=us(this,R1).defaultMutationOptions(r),une(this.options,n)||us(this,R1).getMutationCache().notify({type:"observerOptionsUpdated",mutation:us(this,gm),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Ik(n.mutationKey)!==Ik(this.options.mutationKey)?this.reset():((a=us(this,gm))==null?void 0:a.state.status)==="pending"&&us(this,gm).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=us(this,gm))==null||r.removeObserver(this)}onMutationUpdate(r){Ui(this,Y0,cre).call(this),Ui(this,Y0,dge).call(this,r)}getCurrentResult(){return us(this,F1)}reset(){var r;(r=us(this,gm))==null||r.removeObserver(this),$n(this,gm,void 0),Ui(this,Y0,cre).call(this),Ui(this,Y0,dge).call(this)}mutate(r,n){var a;return $n(this,v0,n),(a=us(this,gm))==null||a.removeObserver(this),$n(this,gm,us(this,R1).getMutationCache().build(us(this,R1),this.options)),us(this,gm).addObserver(this),us(this,gm).execute(r)}},R1=new WeakMap,F1=new WeakMap,gm=new WeakMap,v0=new WeakMap,Y0=new WeakSet,cre=function(){var n;const r=((n=us(this,gm))==null?void 0:n.state)??SFe();$n(this,F1,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},dge=function(r){zd.batch(()=>{var n,a,o,l,i,d,u,p;if(us(this,v0)&&this.hasListeners()){const f=us(this,F1).variables,y=us(this,F1).context;(r==null?void 0:r.type)==="success"?((a=(n=us(this,v0)).onSuccess)==null||a.call(n,r.data,f,y),(l=(o=us(this,v0)).onSettled)==null||l.call(o,r.data,null,f,y)):(r==null?void 0:r.type)==="error"&&((d=(i=us(this,v0)).onError)==null||d.call(i,r.error,f,y),(p=(u=us(this,v0)).onSettled)==null||p.call(u,void 0,r.error,f,y))}this.listeners.forEach(f=>{f(us(this,F1))})})},UDe),AFe=C.createContext(void 0),rs=t=>{const s=C.useContext(AFe);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},_ut=({client:t,children:s})=>(C.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(AFe.Provider,{value:t,children:s})),EFe=C.createContext(!1),but=()=>C.useContext(EFe);EFe.Provider;function wut(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var jut=C.createContext(wut()),Nut=()=>C.useContext(jut),kut=(t,s)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(s.isReset()||(t.retryOnMount=!1))},Sut=t=>{C.useEffect(()=>{t.clearReset()},[t])},Cut=({result:t,errorResetBoundary:s,throwOnError:r,query:n,suspense:a})=>t.isError&&!s.isReset()&&!t.isFetching&&n&&(a&&t.data===void 0||_Fe(r,[t.error,n])),Mut=t=>{if(t.suspense){const s=n=>n==="static"?n:Math.max(n??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...n)=>s(r(...n)):s(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},Tut=(t,s)=>t.isLoading&&t.isFetching&&!s,Aut=(t,s)=>(t==null?void 0:t.suspense)&&s.isPending,O4e=(t,s,r)=>s.fetchOptimistic(t).catch(()=>{r.clearReset()});function PFe(t,s,r){var f,y,_,b,w;const n=but(),a=Nut(),o=rs(),l=o.defaultQueryOptions(t);(y=(f=o.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||y.call(f,l),l._optimisticResults=n?"isRestoring":"optimistic",Mut(l),kut(l,a),Sut(a);const i=!o.getQueryCache().get(l.queryHash),[d]=C.useState(()=>new s(o,l)),u=d.getOptimisticResult(l),p=!n&&t.subscribed!==!1;if(C.useSyncExternalStore(C.useCallback(j=>{const k=p?d.subscribe(zd.batchCalls(j)):Eh;return d.updateResult(),k},[d,p]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),C.useEffect(()=>{d.setOptions(l)},[l,d]),Aut(l,u))throw O4e(l,d,a);if(Cut({result:u,errorResetBoundary:a,throwOnError:l.throwOnError,query:o.getQueryCache().get(l.queryHash),suspense:l.suspense}))throw u.error;if((b=(_=o.getDefaultOptions().queries)==null?void 0:_._experimental_afterQuery)==null||b.call(_,l,u),l.experimental_prefetchInRender&&!Pk&&Tut(u,n)){const j=i?O4e(l,d,a):(w=o.getQueryCache().get(l.queryHash))==null?void 0:w.promise;j==null||j.catch(Eh).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?u:d.trackResult(u)}function wt(t,s){return PFe(t,MFe)}function Dt(t,s){const r=rs(),[n]=C.useState(()=>new vut(r,t));C.useEffect(()=>{n.setOptions(t)},[n,t]);const a=C.useSyncExternalStore(C.useCallback(l=>n.subscribe(zd.batchCalls(l)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=C.useCallback((l,i)=>{n.mutate(l,i).catch(Eh)},[n]);if(a.error&&_Fe(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function Eut(t,s){return PFe(t,yut)}/** * @remix-run/router v1.23.0 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function XI(){return XI=Object.assign?Object.assign.bind():function(t){for(var s=1;s"u")throw new Error(s)}function IFe(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function Iut(){return Math.random().toString(36).substr(2,8)}function F4e(t,s){return{usr:t.state,key:t.key,idx:s}}function uge(t,s,r,n){return r===void 0&&(r=null),XI({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?yM(s):s,{state:r,key:s&&s.key||n||Iut()})}function pne(t){let{pathname:s="/",search:r="",hash:n=""}=t;return r&&r!=="?"&&(s+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(s+=n.charAt(0)==="#"?n:"#"+n),s}function yM(t){let s={};if(t){let r=t.indexOf("#");r>=0&&(s.hash=t.substr(r),t=t.substr(0,r));let n=t.indexOf("?");n>=0&&(s.search=t.substr(n),t=t.substr(0,n)),t&&(s.pathname=t)}return s}function Lut(t,s,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:o=!1}=n,l=a.history,i=q1.Pop,d=null,u=p();u==null&&(u=0,l.replaceState(XI({},l.state,{idx:u}),""));function p(){return(l.state||{idx:null}).idx}function f(){i=q1.Pop;let j=p(),k=j==null?null:j-u;u=j,d&&d({action:i,location:w.location,delta:k})}function y(j,k){i=q1.Push;let S=uge(w.location,j,k);u=p()+1;let T=F4e(S,u),I=w.createHref(S);try{l.pushState(T,"",I)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;a.location.assign(I)}o&&d&&d({action:i,location:w.location,delta:1})}function _(j,k){i=q1.Replace;let S=uge(w.location,j,k);u=p();let T=F4e(S,u),I=w.createHref(S);l.replaceState(T,"",I),o&&d&&d({action:i,location:w.location,delta:0})}function b(j){let k=a.location.origin!=="null"?a.location.origin:a.location.href,S=typeof j=="string"?j:pne(j);return S=S.replace(/ $/,"%20"),cd(k,"No window.location.(origin|href) available to create URL for href: "+S),new URL(S,k)}let w={get action(){return i},get location(){return t(a,l)},listen(j){if(d)throw new Error("A history only accepts one active listener");return a.addEventListener(R4e,f),d=j,()=>{a.removeEventListener(R4e,f),d=null}},createHref(j){return s(a,j)},createURL:b,encodeLocation(j){let k=b(j);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:y,replace:_,go(j){return l.go(j)}};return w}var z4e;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(z4e||(z4e={}));function Dut(t,s,r){return r===void 0&&(r="/"),Out(t,s,r)}function Out(t,s,r,n){let a=typeof s=="string"?yM(s):s,o=k1e(a.pathname||"/",r);if(o==null)return null;let l=LFe(t);Rut(l);let i=null;for(let d=0;i==null&&d{let d={relativePath:i===void 0?o.path||"":i,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};d.relativePath.startsWith("/")&&(cd(d.relativePath.startsWith(n),'Absolute route path "'+d.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),d.relativePath=d.relativePath.slice(n.length));let u=x_([n,d.relativePath]),p=r.concat(d);o.children&&o.children.length>0&&(cd(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),LFe(o.children,s,p,u)),!(o.path==null&&!o.index)&&s.push({path:u,score:Vut(u,o.index),routesMeta:p})};return t.forEach((o,l)=>{var i;if(o.path===""||!((i=o.path)!=null&&i.includes("?")))a(o,l);else for(let d of DFe(o.path))a(o,l,d)}),s}function DFe(t){let s=t.split("/");if(s.length===0)return[];let[r,...n]=s,a=r.endsWith("?"),o=r.replace(/\?$/,"");if(n.length===0)return a?[o,""]:[o];let l=DFe(n.join("/")),i=[];return i.push(...l.map(d=>d===""?o:[o,d].join("/"))),a&&i.push(...l),i.map(d=>t.startsWith("/")&&d===""?"/":d)}function Rut(t){t.sort((s,r)=>s.score!==r.score?r.score-s.score:Hut(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const Fut=/^:[\w-]+$/,zut=3,But=2,$ut=1,qut=10,Uut=-2,B4e=t=>t==="*";function Vut(t,s){let r=t.split("/"),n=r.length;return r.some(B4e)&&(n+=Uut),s&&(n+=But),r.filter(a=>!B4e(a)).reduce((a,o)=>a+(Fut.test(o)?zut:o===""?$ut:qut),n)}function Hut(t,s){return t.length===s.length&&t.slice(0,-1).every((n,a)=>n===s[a])?t[t.length-1]-s[s.length-1]:0}function Wut(t,s,r){let{routesMeta:n}=t,a={},o="/",l=[];for(let i=0;i{let{paramName:y,isOptional:_}=p;if(y==="*"){let w=i[f]||"";l=o.slice(0,o.length-w.length).replace(/(.)\/+$/,"$1")}const b=i[f];return _&&!b?u[y]=void 0:u[y]=(b||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:l,pattern:t}}function Kut(t,s,r){s===void 0&&(s=!1),r===void 0&&(r=!0),IFe(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let n=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,i,d)=>(n.push({paramName:i,isOptional:d!=null}),d?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(n.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,s?void 0:"i"),n]}function Zut(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return IFe(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+s+").")),t}}function k1e(t,s){if(s==="/")return t;if(!t.toLowerCase().startsWith(s.toLowerCase()))return null;let r=s.endsWith("/")?s.length-1:s.length,n=t.charAt(r);return n&&n!=="/"?null:t.slice(r)||"/"}function Yut(t,s){s===void 0&&(s="/");let{pathname:r,search:n="",hash:a=""}=typeof t=="string"?yM(t):t;return{pathname:r?r.startsWith("/")?r:Xut(r,s):s,search:eht(n),hash:tht(a)}}function Xut(t,s){let r=s.replace(/\/+$/,"").split("/");return t.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function jhe(t,s,r,n){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+s+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Qut(t){return t.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function S1e(t,s){let r=Qut(t);return s?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function C1e(t,s,r,n){n===void 0&&(n=!1);let a;typeof t=="string"?a=yM(t):(a=XI({},t),cd(!a.pathname||!a.pathname.includes("?"),jhe("?","pathname","search",a)),cd(!a.pathname||!a.pathname.includes("#"),jhe("#","pathname","hash",a)),cd(!a.search||!a.search.includes("#"),jhe("#","search","hash",a)));let o=t===""||a.pathname==="",l=o?"/":a.pathname,i;if(l==null)i=r;else{let f=s.length-1;if(!n&&l.startsWith("..")){let y=l.split("/");for(;y[0]==="..";)y.shift(),f-=1;a.pathname=y.join("/")}i=f>=0?s[f]:"/"}let d=Yut(a,i),u=l&&l!=="/"&&l.endsWith("/"),p=(o||l===".")&&r.endsWith("/");return!d.pathname.endsWith("/")&&(u||p)&&(d.pathname+="/"),d}const x_=t=>t.join("/").replace(/\/\/+/g,"/"),Jut=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),eht=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,tht=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function sht(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const OFe=["post","put","patch","delete"];new Set(OFe);const rht=["get",...OFe];new Set(rht);/** * React Router v6.30.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function QI(){return QI=Object.assign?Object.assign.bind():function(t){for(var s=1;s{i.current=!0}),C.useCallback(function(u,p){if(p===void 0&&(p={}),!i.current)return;if(typeof u=="number"){n.go(u);return}let f=C1e(u,JSON.parse(l),o,p.relative==="path");t==null&&s!=="/"&&(f.pathname=f.pathname==="/"?s:x_([s,f.pathname])),(p.replace?n.replace:n.push)(f,p.state,p)},[s,n,l,o,t])}const oht=C.createContext(null);function lht(t){let s=C.useContext(yy).outlet;return s&&C.createElement(oht.Provider,{value:t},s)}function ko(){let{matches:t}=C.useContext(yy),s=t[t.length-1];return s?s.params:{}}function zFe(t,s){let{relative:r}=s===void 0?{}:s,{future:n}=C.useContext(V_),{matches:a}=C.useContext(yy),{pathname:o}=bu(),l=JSON.stringify(S1e(a,n.v7_relativeSplatPath));return C.useMemo(()=>C1e(t,JSON.parse(l),o,r==="path"),[t,l,o,r])}function cht(t,s){return dht(t,s)}function dht(t,s,r,n){vM()||cd(!1);let{navigator:a}=C.useContext(V_),{matches:o}=C.useContext(yy),l=o[o.length-1],i=l?l.params:{};l&&l.pathname;let d=l?l.pathnameBase:"/";l&&l.route;let u=bu(),p;if(s){var f;let j=typeof s=="string"?yM(s):s;d==="/"||(f=j.pathname)!=null&&f.startsWith(d)||cd(!1),p=j}else p=u;let y=p.pathname||"/",_=y;if(d!=="/"){let j=d.replace(/^\//,"").split("/");_="/"+y.replace(/^\//,"").split("/").slice(j.length).join("/")}let b=Dut(t,{pathname:_}),w=fht(b&&b.map(j=>Object.assign({},j,{params:Object.assign({},i,j.params),pathname:x_([d,a.encodeLocation?a.encodeLocation(j.pathname).pathname:j.pathname]),pathnameBase:j.pathnameBase==="/"?d:x_([d,a.encodeLocation?a.encodeLocation(j.pathnameBase).pathname:j.pathnameBase])})),o,r,n);return s&&w?C.createElement(boe.Provider,{value:{location:QI({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:q1.Pop}},w):w}function uht(){let t=vht(),s=sht(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),r=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return C.createElement(C.Fragment,null,C.createElement("h2",null,"Unexpected Application Error!"),C.createElement("h3",{style:{fontStyle:"italic"}},s),r?C.createElement("pre",{style:a},r):null,null)}const hht=C.createElement(uht,null);class mht extends C.Component{constructor(s){super(s),this.state={location:s.location,revalidation:s.revalidation,error:s.error}}static getDerivedStateFromError(s){return{error:s}}static getDerivedStateFromProps(s,r){return r.location!==s.location||r.revalidation!=="idle"&&s.revalidation==="idle"?{error:s.error,location:s.location,revalidation:s.revalidation}:{error:s.error!==void 0?s.error:r.error,location:r.location,revalidation:s.revalidation||r.revalidation}}componentDidCatch(s,r){console.error("React Router caught the following error during render",s,r)}render(){return this.state.error!==void 0?C.createElement(yy.Provider,{value:this.props.routeContext},C.createElement(RFe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function pht(t){let{routeContext:s,match:r,children:n}=t,a=C.useContext(M1e);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),C.createElement(yy.Provider,{value:s},n)}function fht(t,s,r,n){var a;if(s===void 0&&(s=[]),r===void 0&&(r=null),n===void 0&&(n=null),t==null){var o;if(!r)return null;if(r.errors)t=r.matches;else if((o=n)!=null&&o.v7_partialHydration&&s.length===0&&!r.initialized&&r.matches.length>0)t=r.matches;else return null}let l=t,i=(a=r)==null?void 0:a.errors;if(i!=null){let p=l.findIndex(f=>f.route.id&&(i==null?void 0:i[f.route.id])!==void 0);p>=0||cd(!1),l=l.slice(0,Math.min(l.length,p+1))}let d=!1,u=-1;if(r&&n&&n.v7_partialHydration)for(let p=0;p=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((p,f,y)=>{let _,b=!1,w=null,j=null;r&&(_=i&&f.route.id?i[f.route.id]:void 0,w=f.route.errorElement||hht,d&&(u<0&&y===0?(bht("route-fallback"),b=!0,j=null):u===y&&(b=!0,j=f.route.hydrateFallbackElement||null)));let k=s.concat(l.slice(0,y+1)),S=()=>{let T;return _?T=w:b?T=j:f.route.Component?T=C.createElement(f.route.Component,null):f.route.element?T=f.route.element:T=p,C.createElement(pht,{match:f,routeContext:{outlet:p,matches:k,isDataRoute:r!=null},children:T})};return r&&(f.route.ErrorBoundary||f.route.errorElement||y===0)?C.createElement(mht,{location:r.location,revalidation:r.revalidation,component:w,error:_,children:S(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):S()},null)}var BFe=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(BFe||{}),$Fe=function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t}($Fe||{});function ght(t){let s=C.useContext(M1e);return s||cd(!1),s}function xht(t){let s=C.useContext(nht);return s||cd(!1),s}function yht(t){let s=C.useContext(yy);return s||cd(!1),s}function qFe(t){let s=yht(),r=s.matches[s.matches.length-1];return r.route.id||cd(!1),r.route.id}function vht(){var t;let s=C.useContext(RFe),r=xht(),n=qFe();return s!==void 0?s:(t=r.errors)==null?void 0:t[n]}function _ht(){let{router:t}=ght(BFe.UseNavigateStable),s=qFe($Fe.UseNavigateStable),r=C.useRef(!1);return FFe(()=>{r.current=!0}),C.useCallback(function(a,o){o===void 0&&(o={}),r.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,QI({fromRouteId:s},o)))},[t,s])}const $4e={};function bht(t,s,r){$4e[t]||($4e[t]=!0)}function wht(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Nhe(t){let{to:s,replace:r,state:n,relative:a}=t;vM()||cd(!1);let{future:o,static:l}=C.useContext(V_),{matches:i}=C.useContext(yy),{pathname:d}=bu(),u=Pr(),p=C1e(s,S1e(i,o.v7_relativeSplatPath),d,a==="path"),f=JSON.stringify(p);return C.useEffect(()=>u(JSON.parse(f),{replace:r,state:n,relative:a}),[u,f,a,r,n]),null}function jht(t){return lht(t.context)}function $s(t){cd(!1)}function Nht(t){let{basename:s="/",children:r=null,location:n,navigationType:a=q1.Pop,navigator:o,static:l=!1,future:i}=t;vM()&&cd(!1);let d=s.replace(/^\/*/,"/"),u=C.useMemo(()=>({basename:d,navigator:o,static:l,future:QI({v7_relativeSplatPath:!1},i)}),[d,i,o,l]);typeof n=="string"&&(n=yM(n));let{pathname:p="/",search:f="",hash:y="",state:_=null,key:b="default"}=n,w=C.useMemo(()=>{let j=k1e(p,d);return j==null?null:{location:{pathname:j,search:f,hash:y,state:_,key:b},navigationType:a}},[d,p,f,y,_,b,a]);return w==null?null:C.createElement(V_.Provider,{value:u},C.createElement(boe.Provider,{children:r,value:w}))}function UFe(t){let{children:s,location:r}=t;return cht(hge(s),r)}new Promise(()=>{});function hge(t,s){s===void 0&&(s=[]);let r=[];return C.Children.forEach(t,(n,a)=>{if(!C.isValidElement(n))return;let o=[...s,a];if(n.type===C.Fragment){r.push.apply(r,hge(n.props.children,o));return}n.type!==$s&&cd(!1),!n.props.index||!n.props.children||cd(!1);let l={id:n.props.id||o.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,loader:n.props.loader,action:n.props.action,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(l.children=hge(n.props.children,o)),r.push(l)}),r}/** * React Router DOM v6.30.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function mge(){return mge=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&(r[a]=t[a]);return r}function Sht(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Cht(t,s){return t.button===0&&(!s||s==="_self")&&!Sht(t)}function pge(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((s,r)=>{let n=t[r];return s.concat(Array.isArray(n)?n.map(a=>[r,a]):[[r,n]])},[]))}function Mht(t,s){let r=pge(t);return s&&s.forEach((n,a)=>{r.has(a)||s.getAll(a).forEach(o=>{r.append(a,o)})}),r}const Tht=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Aht="6";try{window.__reactRouterVersion=Aht}catch{}const Eht="startTransition",q4e=hve[Eht];function Pht(t){let{basename:s,children:r,future:n,window:a}=t,o=C.useRef();o.current==null&&(o.current=Put({window:a,v5Compat:!0}));let l=o.current,[i,d]=C.useState({action:l.action,location:l.location}),{v7_startTransition:u}=n||{},p=C.useCallback(f=>{u&&q4e?q4e(()=>d(f)):d(f)},[d,u]);return C.useLayoutEffect(()=>l.listen(p),[l,p]),C.useEffect(()=>wht(n),[n]),C.createElement(Nht,{basename:s,children:r,location:i.location,navigationType:i.action,navigator:l,future:n})}const Iht=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Lht=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,vo=C.forwardRef(function(s,r){let{onClick:n,relative:a,reloadDocument:o,replace:l,state:i,target:d,to:u,preventScrollReset:p,viewTransition:f}=s,y=kht(s,Tht),{basename:_}=C.useContext(V_),b,w=!1;if(typeof u=="string"&&Lht.test(u)&&(b=u,Iht))try{let T=new URL(window.location.href),I=u.startsWith("//")?new URL(T.protocol+u):new URL(u),L=k1e(I.pathname,_);I.origin===T.origin&&L!=null?u=L+I.search+I.hash:w=!0}catch{}let j=aht(u,{relative:a}),k=Dht(u,{replace:l,state:i,target:d,preventScrollReset:p,relative:a,viewTransition:f});function S(T){n&&n(T),T.defaultPrevented||k(T)}return C.createElement("a",mge({},y,{href:b||j,onClick:w||o?n:S,ref:r,target:d}))});var U4e;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(U4e||(U4e={}));var V4e;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(V4e||(V4e={}));function Dht(t,s){let{target:r,replace:n,state:a,preventScrollReset:o,relative:l,viewTransition:i}=s===void 0?{}:s,d=Pr(),u=bu(),p=zFe(t,{relative:l});return C.useCallback(f=>{if(Cht(f,r)){f.preventDefault();let y=n!==void 0?n:pne(u)===pne(p);d(t,{replace:y,state:a,preventScrollReset:o,relative:l,viewTransition:i})}},[u,d,p,n,a,r,t,o,l,i])}function Pc(t){let s=C.useRef(pge(t)),r=C.useRef(!1),n=bu(),a=C.useMemo(()=>Mht(n.search,r.current?null:s.current),[n.search]),o=Pr(),l=C.useCallback((i,d)=>{const u=pge(typeof i=="function"?i(a):i);r.current=!0,o("?"+u,d)},[o,a]);return[a,l]}var Oht=typeof Element<"u",Rht=typeof Map=="function",Fht=typeof Set=="function",zht=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function dre(t,s){if(t===s)return!0;if(t&&s&&typeof t=="object"&&typeof s=="object"){if(t.constructor!==s.constructor)return!1;var r,n,a;if(Array.isArray(t)){if(r=t.length,r!=s.length)return!1;for(n=r;n--!==0;)if(!dre(t[n],s[n]))return!1;return!0}var o;if(Rht&&t instanceof Map&&s instanceof Map){if(t.size!==s.size)return!1;for(o=t.entries();!(n=o.next()).done;)if(!s.has(n.value[0]))return!1;for(o=t.entries();!(n=o.next()).done;)if(!dre(n.value[1],s.get(n.value[0])))return!1;return!0}if(Fht&&t instanceof Set&&s instanceof Set){if(t.size!==s.size)return!1;for(o=t.entries();!(n=o.next()).done;)if(!s.has(n.value[0]))return!1;return!0}if(zht&&ArrayBuffer.isView(t)&&ArrayBuffer.isView(s)){if(r=t.length,r!=s.length)return!1;for(n=r;n--!==0;)if(t[n]!==s[n])return!1;return!0}if(t.constructor===RegExp)return t.source===s.source&&t.flags===s.flags;if(t.valueOf!==Object.prototype.valueOf&&typeof t.valueOf=="function"&&typeof s.valueOf=="function")return t.valueOf()===s.valueOf();if(t.toString!==Object.prototype.toString&&typeof t.toString=="function"&&typeof s.toString=="function")return t.toString()===s.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(s).length)return!1;for(n=r;n--!==0;)if(!Object.prototype.hasOwnProperty.call(s,a[n]))return!1;if(Oht&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((a[n]==="_owner"||a[n]==="__v"||a[n]==="__o")&&t.$$typeof)&&!dre(t[a[n]],s[a[n]]))return!1;return!0}return t!==t&&s!==s}var Bht=function(s,r){try{return dre(s,r)}catch(n){if((n.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw n}};const $ht=_o(Bht);var qht=function(t,s,r,n,a,o,l,i){if(!t){var d;if(s===void 0)d=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,n,a,o,l,i],p=0;d=new Error(s.replace(/%s/g,function(){return u[p++]})),d.name="Invariant Violation"}throw d.framesToPop=1,d}},Uht=qht;const H4e=_o(Uht);var Vht=function(s,r,n,a){var o=n?n.call(a,s,r):void 0;if(o!==void 0)return!!o;if(s===r)return!0;if(typeof s!="object"||!s||typeof r!="object"||!r)return!1;var l=Object.keys(s),i=Object.keys(r);if(l.length!==i.length)return!1;for(var d=Object.prototype.hasOwnProperty.bind(r),u=0;u(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(VFe||{}),khe={link:{rel:["amphtml","canonical","alternate"]},script:{type:["application/ld+json"]},meta:{charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]}},W4e=Object.values(VFe),T1e={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},Wht=Object.entries(T1e).reduce((t,[s,r])=>(t[r]=s,t),{}),Rg="data-rh",L5={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},D5=(t,s)=>{for(let r=t.length-1;r>=0;r-=1){const n=t[r];if(Object.prototype.hasOwnProperty.call(n,s))return n[s]}return null},Ght=t=>{let s=D5(t,"title");const r=D5(t,L5.TITLE_TEMPLATE);if(Array.isArray(s)&&(s=s.join("")),r&&s)return r.replace(/%s/g,()=>s);const n=D5(t,L5.DEFAULT_TITLE);return s||n||void 0},Kht=t=>D5(t,L5.ON_CHANGE_CLIENT_STATE)||(()=>{}),She=(t,s)=>s.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),Zht=(t,s)=>s.filter(r=>typeof r.base<"u").map(r=>r.base).reverse().reduce((r,n)=>{if(!r.length){const a=Object.keys(n);for(let o=0;oconsole&&typeof console.warn=="function"&&console.warn(t),sE=(t,s,r)=>{const n={};return r.filter(a=>Array.isArray(a[t])?!0:(typeof a[t]<"u"&&Yht(`Helmet: ${t} should be of type "Array". Instead found type "${typeof a[t]}"`),!1)).map(a=>a[t]).reverse().reduce((a,o)=>{const l={};o.filter(d=>{let u;const p=Object.keys(d);for(let y=0;ya.push(d));const i=Object.keys(l);for(let d=0;d{if(Array.isArray(t)&&t.length){for(let r=0;r({baseTag:Zht(["href"],t),bodyAttributes:She("bodyAttributes",t),defer:D5(t,L5.DEFER),encode:D5(t,L5.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:She("htmlAttributes",t),linkTags:sE("link",["rel","href"],t),metaTags:sE("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:sE("noscript",["innerHTML"],t),onChangeClientState:Kht(t),scriptTags:sE("script",["src","innerHTML"],t),styleTags:sE("style",["cssText"],t),title:Ght(t),titleAttributes:She("titleAttributes",t),prioritizeSeoTags:Xht(t,L5.PRIORITIZE_SEO_TAGS)}),HFe=t=>Array.isArray(t)?t.join(""):t,Jht=(t,s)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(Jht(n,s)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},G4e=(t,s)=>({...t,[s]:void 0}),emt=["noscript","script","style"],fge=(t,s=!0)=>s===!1?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),WFe=t=>Object.keys(t).reduce((s,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return s?`${s} ${n}`:n},""),tmt=(t,s,r,n)=>{const a=WFe(r),o=HFe(s);return a?`<${t} ${Rg}="true" ${a}>${fge(o,n)}`:`<${t} ${Rg}="true">${fge(o,n)}`},smt=(t,s,r=!0)=>s.reduce((n,a)=>{const o=a,l=Object.keys(o).filter(u=>!(u==="innerHTML"||u==="cssText")).reduce((u,p)=>{const f=typeof o[p]>"u"?p:`${p}="${fge(o[p],r)}"`;return u?`${u} ${f}`:f},""),i=o.innerHTML||o.cssText||"",d=emt.indexOf(t)===-1;return`${n}<${t} ${Rg}="true" ${l}${d?"/>":`>${i}`}`},""),GFe=(t,s={})=>Object.keys(t).reduce((r,n)=>{const a=T1e[n];return r[a||n]=t[n],r},s),rmt=(t,s,r)=>{const n={key:s,[Rg]:!0},a=GFe(r,n);return[ht.createElement("title",a,s)]},ure=(t,s)=>s.map((r,n)=>{const a={key:n,[Rg]:!0};return Object.keys(r).forEach(o=>{const i=T1e[o]||o;if(i==="innerHTML"||i==="cssText"){const d=r.innerHTML||r.cssText;a.dangerouslySetInnerHTML={__html:d}}else a[i]=r[o]}),ht.createElement(t,a)}),Xp=(t,s,r=!0)=>{switch(t){case"title":return{toComponent:()=>rmt(t,s.title,s.titleAttributes),toString:()=>tmt(t,s.title,s.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>GFe(s),toString:()=>WFe(s)};default:return{toComponent:()=>ure(t,s),toString:()=>smt(t,s,r)}}},nmt=({metaTags:t,linkTags:s,scriptTags:r,encode:n})=>{const a=Che(t,khe.meta),o=Che(s,khe.link),l=Che(r,khe.script);return{priorityMethods:{toComponent:()=>[...ure("meta",a.priority),...ure("link",o.priority),...ure("script",l.priority)],toString:()=>`${Xp("meta",a.priority,n)} ${Xp("link",o.priority,n)} ${Xp("script",l.priority,n)}`},metaTags:a.default,linkTags:o.default,scriptTags:l.default}},amt=t=>{const{baseTag:s,bodyAttributes:r,encode:n=!0,htmlAttributes:a,noscriptTags:o,styleTags:l,title:i="",titleAttributes:d,prioritizeSeoTags:u}=t;let{linkTags:p,metaTags:f,scriptTags:y}=t,_={toComponent:()=>{},toString:()=>""};return u&&({priorityMethods:_,linkTags:p,metaTags:f,scriptTags:y}=nmt(t)),{priority:_,base:Xp("base",s,n),bodyAttributes:Xp("bodyAttributes",r,n),htmlAttributes:Xp("htmlAttributes",a,n),link:Xp("link",p,n),meta:Xp("meta",f,n),noscript:Xp("noscript",o,n),script:Xp("script",y,n),style:Xp("style",l,n),title:Xp("title",{title:i,titleAttributes:d},n)}},gge=amt,P8=[],KFe=!!(typeof window<"u"&&window.document&&window.document.createElement),xge=class{constructor(t,s){_n(this,"instances",[]);_n(this,"canUseDOM",KFe);_n(this,"context");_n(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?P8:this.instances,add:t=>{(this.canUseDOM?P8:this.instances).push(t)},remove:t=>{const s=(this.canUseDOM?P8:this.instances).indexOf(t);(this.canUseDOM?P8:this.instances).splice(s,1)}}});this.context=t,this.canUseDOM=s||!1,s||(t.helmet=gge({baseTag:[],bodyAttributes:{},htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},imt={},ZFe=ht.createContext(imt),tk,YFe=(tk=class extends C.Component{constructor(r){super(r);_n(this,"helmetData");this.helmetData=new xge(this.props.context||{},tk.canUseDOM)}render(){return ht.createElement(ZFe.Provider,{value:this.helmetData.value},this.props.children)}},_n(tk,"canUseDOM",KFe),tk),QC=(t,s)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${Rg}]`),a=[].slice.call(n),o=[];let l;return s&&s.length&&s.forEach(i=>{const d=document.createElement(t);for(const u in i)if(Object.prototype.hasOwnProperty.call(i,u))if(u==="innerHTML")d.innerHTML=i.innerHTML;else if(u==="cssText")d.styleSheet?d.styleSheet.cssText=i.cssText:d.appendChild(document.createTextNode(i.cssText));else{const p=u,f=typeof i[p]>"u"?"":i[p];d.setAttribute(u,f)}d.setAttribute(Rg,"true"),a.some((u,p)=>(l=p,d.isEqualNode(u)))?a.splice(l,1):o.push(d)}),a.forEach(i=>{var d;return(d=i.parentNode)==null?void 0:d.removeChild(i)}),o.forEach(i=>r.appendChild(i)),{oldTags:a,newTags:o}},yge=(t,s)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(Rg),a=n?n.split(","):[],o=[...a],l=Object.keys(s);for(const i of l){const d=s[i]||"";r.getAttribute(i)!==d&&r.setAttribute(i,d),a.indexOf(i)===-1&&a.push(i);const u=o.indexOf(i);u!==-1&&o.splice(u,1)}for(let i=o.length-1;i>=0;i-=1)r.removeAttribute(o[i]);a.length===o.length?r.removeAttribute(Rg):r.getAttribute(Rg)!==l.join(",")&&r.setAttribute(Rg,l.join(","))},omt=(t,s)=>{typeof t<"u"&&document.title!==t&&(document.title=HFe(t)),yge("title",s)},K4e=(t,s)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:a,linkTags:o,metaTags:l,noscriptTags:i,onChangeClientState:d,scriptTags:u,styleTags:p,title:f,titleAttributes:y}=t;yge("body",n),yge("html",a),omt(f,y);const _={baseTag:QC("base",r),linkTags:QC("link",o),metaTags:QC("meta",l),noscriptTags:QC("noscript",i),scriptTags:QC("script",u),styleTags:QC("style",p)},b={},w={};Object.keys(_).forEach(j=>{const{newTags:k,oldTags:S}=_[j];k.length&&(b[j]=k),S.length&&(w[j]=_[j].oldTags)}),s&&s(),d(t,b,w)},rE=null,lmt=t=>{rE&&cancelAnimationFrame(rE),t.defer?rE=requestAnimationFrame(()=>{K4e(t,()=>{rE=null})}):(K4e(t),rE=null)},cmt=lmt,Z4e=class extends C.Component{constructor(){super(...arguments);_n(this,"rendered",!1)}shouldComponentUpdate(s){return!Hht(s,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:s}=this.props.context;s.remove(this),this.emitChange()}emitChange(){const{helmetInstances:s,setHelmet:r}=this.props.context;let n=null;const a=Qht(s.get().map(o=>{const l={...o.props};return delete l.context,l}));YFe.canUseDOM?cmt(a):gge&&(n=gge(a)),r(n)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:s}=this.props.context;s.add(this),this.emitChange()}render(){return this.init(),null}},Gpe,lh=(Gpe=class extends C.Component{shouldComponentUpdate(t){return!$ht(G4e(this.props,"helmetData"),G4e(t,"helmetData"))}mapNestedChildrenToProps(t,s){if(!s)return null;switch(t.type){case"script":case"noscript":return{innerHTML:s};case"style":return{cssText:s};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,s,r,n){return{...s,[t.type]:[...s[t.type]||[],{...r,...this.mapNestedChildrenToProps(t,n)}]}}mapObjectTypeChildren(t,s,r,n){switch(t.type){case"title":return{...s,[t.type]:n,titleAttributes:{...r}};case"body":return{...s,bodyAttributes:{...r}};case"html":return{...s,htmlAttributes:{...r}};default:return{...s,[t.type]:{...r}}}}mapArrayTypeChildrenToProps(t,s){let r={...s};return Object.keys(t).forEach(n=>{r={...r,[n]:t[n]}}),r}warnOnInvalidChildren(t,s){return H4e(W4e.some(r=>t.type===r),typeof t.type=="function"?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${W4e.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),H4e(!s||typeof s=="string"||Array.isArray(s)&&!s.some(r=>typeof r!="string"),`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`),!0}mapChildrenToProps(t,s){let r={};return ht.Children.forEach(t,n=>{if(!n||!n.props)return;const{children:a,...o}=n.props,l=Object.keys(o).reduce((d,u)=>(d[Wht[u]||u]=o[u],d),{});let{type:i}=n;switch(typeof i=="symbol"?i=i.toString():this.warnOnInvalidChildren(n,a),i){case"Symbol(react.fragment)":s=this.mapChildrenToProps(a,s);break;case"link":case"meta":case"noscript":case"script":case"style":r=this.flattenArrayTypeChildren(n,r,l,a);break;default:s=this.mapObjectTypeChildren(n,s,l,a);break}}),this.mapArrayTypeChildrenToProps(r,s)}render(){const{children:t,...s}=this.props;let r={...s},{helmetData:n}=s;if(t&&(r=this.mapChildrenToProps(t,r)),n&&!(n instanceof xge)){const a=n;n=new xge(a.context,!0),delete r.helmetData}return n?ht.createElement(Z4e,{...r,context:n.value}):ht.createElement(ZFe.Consumer,null,a=>ht.createElement(Z4e,{...r,context:a}))}},_n(Gpe,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),Gpe),vge=function(t,s){return vge=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(r[a]=n[a])},vge(t,s)};function XFe(t,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");vge(t,s);function r(){this.constructor=t}t.prototype=s===null?Object.create(s):(r.prototype=s.prototype,new r)}var lf=function(){return lf=Object.assign||function(s){for(var r,n=1,a=arguments.length;n=0;i--)(l=t[i])&&(o=(a<3?l(o):a>3?l(s,r,o):l(s,r))||o);return a>3&&o&&Object.defineProperty(s,r,o),o}function JFe(t,s){return function(r,n){s(r,n,t)}}function eze(t,s,r,n,a,o){function l(k){if(k!==void 0&&typeof k!="function")throw new TypeError("Function expected");return k}for(var i=n.kind,d=i==="getter"?"get":i==="setter"?"set":"value",u=!s&&t?n.static?t:t.prototype:null,p=s||(u?Object.getOwnPropertyDescriptor(u,n.name):{}),f,y=!1,_=r.length-1;_>=0;_--){var b={};for(var w in n)b[w]=w==="access"?{}:n[w];for(var w in n.access)b.access[w]=n.access[w];b.addInitializer=function(k){if(y)throw new TypeError("Cannot add initializers after decoration has completed");o.push(l(k||null))};var j=(0,r[_])(i==="accessor"?{get:p.get,set:p.set}:p[d],b);if(i==="accessor"){if(j===void 0)continue;if(j===null||typeof j!="object")throw new TypeError("Object expected");(f=l(j.get))&&(p.get=f),(f=l(j.set))&&(p.set=f),(f=l(j.init))&&a.unshift(f)}else(f=l(j))&&(i==="field"?a.unshift(f):p[d]=f)}u&&Object.defineProperty(u,n.name,p),y=!0}function tze(t,s,r){for(var n=arguments.length>2,a=0;a0&&o[o.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")}function A1e(t,s){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),a,o=[],l;try{for(;(s===void 0||s-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(i){l={error:i}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(l)throw l.error}}return o}function oze(){for(var t=[],s=0;s1||d(_,w)})},b&&(a[_]=b(a[_])))}function d(_,b){try{u(n[_](b))}catch(w){y(o[0][3],w)}}function u(_){_.value instanceof x3?Promise.resolve(_.value.v).then(p,f):y(o[0][2],_)}function p(_){d("next",_)}function f(_){d("throw",_)}function y(_,b){_(b),o.shift(),o.length&&d(o[0][0],o[0][1])}}function dze(t){var s,r;return s={},n("next"),n("throw",function(a){throw a}),n("return"),s[Symbol.iterator]=function(){return this},s;function n(a,o){s[a]=t[a]?function(l){return(r=!r)?{value:x3(t[a](l)),done:!1}:o?o(l):l}:o}}function uze(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=t[Symbol.asyncIterator],r;return s?s.call(t):(t=typeof fne=="function"?fne(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=t[o]&&function(l){return new Promise(function(i,d){l=t[o](l),a(i,d,l.done,l.value)})}}function a(o,l,i,d){Promise.resolve(d).then(function(u){o({value:u,done:i})},l)}}function hze(t,s){return Object.defineProperty?Object.defineProperty(t,"raw",{value:s}):t.raw=s,t}var dmt=Object.create?function(t,s){Object.defineProperty(t,"default",{enumerable:!0,value:s})}:function(t,s){t.default=s},_ge=function(t){return _ge=Object.getOwnPropertyNames||function(s){var r=[];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[r.length]=n);return r},_ge(t)};function mze(t){if(t&&t.__esModule)return t;var s={};if(t!=null)for(var r=_ge(t),n=0;n{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>hh(async()=>{const{default:n}=await Promise.resolve().then(()=>aS);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)};class P1e extends Error{constructor(s,r="FunctionsError",n){super(s),this.name=r,this.context=n}}class Y4e extends P1e{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class X4e extends P1e{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class Q4e extends P1e{constructor(s){super("Edge Function returned a non-2xx status code","FunctionsHttpError",s)}}var bge;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(bge||(bge={}));class fmt{constructor(s,{headers:r={},customFetch:n,region:a=bge.Any}={}){this.url=s,this.headers=r,this.region=a,this.fetch=pmt(n)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s){return da(this,arguments,void 0,function*(r,n={}){var a;try{const{headers:o,method:l,body:i,signal:d}=n;let u={},{region:p}=n;p||(p=this.region);const f=new URL(`${this.url}/${r}`);p&&p!=="any"&&(u["x-region"]=p,f.searchParams.set("forceFunctionRegion",p));let y;i&&(o&&!Object.prototype.hasOwnProperty.call(o,"Content-Type")||!o)?typeof Blob<"u"&&i instanceof Blob||i instanceof ArrayBuffer?(u["Content-Type"]="application/octet-stream",y=i):typeof i=="string"?(u["Content-Type"]="text/plain",y=i):typeof FormData<"u"&&i instanceof FormData?y=i:(u["Content-Type"]="application/json",y=JSON.stringify(i)):y=i;const _=yield this.fetch(f.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},u),this.headers),o),body:y,signal:d}).catch(k=>{throw k.name==="AbortError"?k:new Y4e(k)}),b=_.headers.get("x-relay-error");if(b&&b==="true")throw new X4e(_);if(!_.ok)throw new Q4e(_);let w=((a=_.headers.get("Content-Type"))!==null&&a!==void 0?a:"text/plain").split(";")[0].trim(),j;return w==="application/json"?j=yield _.json():w==="application/octet-stream"||w==="application/pdf"?j=yield _.blob():w==="text/event-stream"?j=_:w==="multipart/form-data"?j=yield _.formData():j=yield _.text(),{data:j,error:null,response:_}}catch(o){return o instanceof Error&&o.name==="AbortError"?{data:null,error:new Y4e(o)}:{data:null,error:o,response:o instanceof Q4e||o instanceof X4e?o.context:void 0}}})}}var wm={};const _M=VDe(mmt);var I8={},L8={},D8={},O8={},R8={},gmt=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},y3=gmt();const xmt=y3.fetch,bze=y3.fetch.bind(y3),wze=y3.Headers,ymt=y3.Request,vmt=y3.Response,aS=Object.freeze(Object.defineProperty({__proto__:null,Headers:wze,Request:ymt,Response:vmt,default:bze,fetch:xmt},Symbol.toStringTag,{value:"Module"})),_mt=VDe(aS);var F8={},J4e;function jze(){if(J4e)return F8;J4e=1,Object.defineProperty(F8,"__esModule",{value:!0});class t extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}}return F8.default=t,F8}var e5e;function Nze(){if(e5e)return R8;e5e=1,Object.defineProperty(R8,"__esModule",{value:!0});const t=_M,s=t.__importDefault(_mt),r=t.__importDefault(jze());class n{constructor(o){var l,i;this.shouldThrowOnError=!1,this.method=o.method,this.url=o.url,this.headers=new Headers(o.headers),this.schema=o.schema,this.body=o.body,this.shouldThrowOnError=(l=o.shouldThrowOnError)!==null&&l!==void 0?l:!1,this.signal=o.signal,this.isMaybeSingle=(i=o.isMaybeSingle)!==null&&i!==void 0?i:!1,o.fetch?this.fetch=o.fetch:typeof fetch>"u"?this.fetch=s.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(o,l){return this.headers=new Headers(this.headers),this.headers.set(o,l),this}then(o,l){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const i=this.fetch;let d=i(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var p,f,y,_;let b=null,w=null,j=null,k=u.status,S=u.statusText;if(u.ok){if(this.method!=="HEAD"){const R=await u.text();R===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((p=this.headers.get("Accept"))===null||p===void 0)&&p.includes("application/vnd.pgrst.plan+text"))?w=R:w=JSON.parse(R))}const I=(f=this.headers.get("Prefer"))===null||f===void 0?void 0:f.match(/count=(exact|planned|estimated)/),L=(y=u.headers.get("content-range"))===null||y===void 0?void 0:y.split("/");I&&L&&L.length>1&&(j=parseInt(L[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(w)&&(w.length>1?(b={code:"PGRST116",details:`Results contain ${w.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},w=null,j=null,k=406,S="Not Acceptable"):w.length===1?w=w[0]:w=null)}else{const I=await u.text();try{b=JSON.parse(I),Array.isArray(b)&&u.status===404&&(w=[],b=null,k=200,S="OK")}catch{u.status===404&&I===""?(k=204,S="No Content"):b={message:I}}if(b&&this.isMaybeSingle&&(!((_=b==null?void 0:b.details)===null||_===void 0)&&_.includes("0 rows"))&&(b=null,k=200,S="OK"),b&&this.shouldThrowOnError)throw new r.default(b)}return{error:b,data:w,count:j,status:k,statusText:S}});return this.shouldThrowOnError||(d=d.catch(u=>{var p,f,y;return{error:{message:`${(p=u==null?void 0:u.name)!==null&&p!==void 0?p:"FetchError"}: ${u==null?void 0:u.message}`,details:`${(f=u==null?void 0:u.stack)!==null&&f!==void 0?f:""}`,hint:"",code:`${(y=u==null?void 0:u.code)!==null&&y!==void 0?y:""}`},data:null,count:null,status:0,statusText:""}})),d.then(o,l)}returns(){return this}overrideTypes(){return this}}return R8.default=n,R8}var t5e;function kze(){if(t5e)return O8;t5e=1,Object.defineProperty(O8,"__esModule",{value:!0});const s=_M.__importDefault(Nze());class r extends s.default{select(a){let o=!1;const l=(a??"*").split("").map(i=>/\s/.test(i)&&!o?"":(i==='"'&&(o=!o),i)).join("");return this.url.searchParams.set("select",l),this.headers.append("Prefer","return=representation"),this}order(a,{ascending:o=!0,nullsFirst:l,foreignTable:i,referencedTable:d=i}={}){const u=d?`${d}.order`:"order",p=this.url.searchParams.get(u);return this.url.searchParams.set(u,`${p?`${p},`:""}${a}.${o?"asc":"desc"}${l===void 0?"":l?".nullsfirst":".nullslast"}`),this}limit(a,{foreignTable:o,referencedTable:l=o}={}){const i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(i,`${a}`),this}range(a,o,{foreignTable:l,referencedTable:i=l}={}){const d=typeof i>"u"?"offset":`${i}.offset`,u=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(d,`${a}`),this.url.searchParams.set(u,`${o-a+1}`),this}abortSignal(a){return this.signal=a,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:a=!1,verbose:o=!1,settings:l=!1,buffers:i=!1,wal:d=!1,format:u="text"}={}){var p;const f=[a?"analyze":null,o?"verbose":null,l?"settings":null,i?"buffers":null,d?"wal":null].filter(Boolean).join("|"),y=(p=this.headers.get("Accept"))!==null&&p!==void 0?p:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${u}; for="${y}"; options=${f};`),u==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(a){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${a}`),this}}return O8.default=r,O8}var s5e;function I1e(){if(s5e)return D8;s5e=1,Object.defineProperty(D8,"__esModule",{value:!0});const s=_M.__importDefault(kze()),r=new RegExp("[,()]");class n extends s.default{eq(o,l){return this.url.searchParams.append(o,`eq.${l}`),this}neq(o,l){return this.url.searchParams.append(o,`neq.${l}`),this}gt(o,l){return this.url.searchParams.append(o,`gt.${l}`),this}gte(o,l){return this.url.searchParams.append(o,`gte.${l}`),this}lt(o,l){return this.url.searchParams.append(o,`lt.${l}`),this}lte(o,l){return this.url.searchParams.append(o,`lte.${l}`),this}like(o,l){return this.url.searchParams.append(o,`like.${l}`),this}likeAllOf(o,l){return this.url.searchParams.append(o,`like(all).{${l.join(",")}}`),this}likeAnyOf(o,l){return this.url.searchParams.append(o,`like(any).{${l.join(",")}}`),this}ilike(o,l){return this.url.searchParams.append(o,`ilike.${l}`),this}ilikeAllOf(o,l){return this.url.searchParams.append(o,`ilike(all).{${l.join(",")}}`),this}ilikeAnyOf(o,l){return this.url.searchParams.append(o,`ilike(any).{${l.join(",")}}`),this}is(o,l){return this.url.searchParams.append(o,`is.${l}`),this}in(o,l){const i=Array.from(new Set(l)).map(d=>typeof d=="string"&&r.test(d)?`"${d}"`:`${d}`).join(",");return this.url.searchParams.append(o,`in.(${i})`),this}contains(o,l){return typeof l=="string"?this.url.searchParams.append(o,`cs.${l}`):Array.isArray(l)?this.url.searchParams.append(o,`cs.{${l.join(",")}}`):this.url.searchParams.append(o,`cs.${JSON.stringify(l)}`),this}containedBy(o,l){return typeof l=="string"?this.url.searchParams.append(o,`cd.${l}`):Array.isArray(l)?this.url.searchParams.append(o,`cd.{${l.join(",")}}`):this.url.searchParams.append(o,`cd.${JSON.stringify(l)}`),this}rangeGt(o,l){return this.url.searchParams.append(o,`sr.${l}`),this}rangeGte(o,l){return this.url.searchParams.append(o,`nxl.${l}`),this}rangeLt(o,l){return this.url.searchParams.append(o,`sl.${l}`),this}rangeLte(o,l){return this.url.searchParams.append(o,`nxr.${l}`),this}rangeAdjacent(o,l){return this.url.searchParams.append(o,`adj.${l}`),this}overlaps(o,l){return typeof l=="string"?this.url.searchParams.append(o,`ov.${l}`):this.url.searchParams.append(o,`ov.{${l.join(",")}}`),this}textSearch(o,l,{config:i,type:d}={}){let u="";d==="plain"?u="pl":d==="phrase"?u="ph":d==="websearch"&&(u="w");const p=i===void 0?"":`(${i})`;return this.url.searchParams.append(o,`${u}fts${p}.${l}`),this}match(o){return Object.entries(o).forEach(([l,i])=>{this.url.searchParams.append(l,`eq.${i}`)}),this}not(o,l,i){return this.url.searchParams.append(o,`not.${l}.${i}`),this}or(o,{foreignTable:l,referencedTable:i=l}={}){const d=i?`${i}.or`:"or";return this.url.searchParams.append(d,`(${o})`),this}filter(o,l,i){return this.url.searchParams.append(o,`${l}.${i}`),this}}return D8.default=n,D8}var r5e;function Sze(){if(r5e)return L8;r5e=1,Object.defineProperty(L8,"__esModule",{value:!0});const s=_M.__importDefault(I1e());class r{constructor(a,{headers:o={},schema:l,fetch:i}){this.url=a,this.headers=new Headers(o),this.schema=l,this.fetch=i}select(a,o){const{head:l=!1,count:i}=o??{},d=l?"HEAD":"GET";let u=!1;const p=(a??"*").split("").map(f=>/\s/.test(f)&&!u?"":(f==='"'&&(u=!u),f)).join("");return this.url.searchParams.set("select",p),i&&this.headers.append("Prefer",`count=${i}`),new s.default({method:d,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(a,{count:o,defaultToNull:l=!0}={}){var i;const d="POST";if(o&&this.headers.append("Prefer",`count=${o}`),l||this.headers.append("Prefer","missing=default"),Array.isArray(a)){const u=a.reduce((p,f)=>p.concat(Object.keys(f)),[]);if(u.length>0){const p=[...new Set(u)].map(f=>`"${f}"`);this.url.searchParams.set("columns",p.join(","))}}return new s.default({method:d,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}upsert(a,{onConflict:o,ignoreDuplicates:l=!1,count:i,defaultToNull:d=!0}={}){var u;const p="POST";if(this.headers.append("Prefer",`resolution=${l?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),i&&this.headers.append("Prefer",`count=${i}`),d||this.headers.append("Prefer","missing=default"),Array.isArray(a)){const f=a.reduce((y,_)=>y.concat(Object.keys(_)),[]);if(f.length>0){const y=[...new Set(f)].map(_=>`"${_}"`);this.url.searchParams.set("columns",y.join(","))}}return new s.default({method:p,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch})}update(a,{count:o}={}){var l;const i="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new s.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}delete({count:a}={}){var o;const l="DELETE";return a&&this.headers.append("Prefer",`count=${a}`),new s.default({method:l,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}}return L8.default=r,L8}var n5e;function bmt(){if(n5e)return I8;n5e=1,Object.defineProperty(I8,"__esModule",{value:!0});const t=_M,s=t.__importDefault(Sze()),r=t.__importDefault(I1e());class n{constructor(o,{headers:l={},schema:i,fetch:d}={}){this.url=o,this.headers=new Headers(l),this.schemaName=i,this.fetch=d}from(o){const l=new URL(`${this.url}/${o}`);return new s.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(o){return new n(this.url,{headers:this.headers,schema:o,fetch:this.fetch})}rpc(o,l={},{head:i=!1,get:d=!1,count:u}={}){var p;let f;const y=new URL(`${this.url}/rpc/${o}`);let _;i||d?(f=i?"HEAD":"GET",Object.entries(l).filter(([w,j])=>j!==void 0).map(([w,j])=>[w,Array.isArray(j)?`{${j.join(",")}}`:`${j}`]).forEach(([w,j])=>{y.searchParams.append(w,j)})):(f="POST",_=l);const b=new Headers(this.headers);return u&&b.set("Prefer",`count=${u}`),new r.default({method:f,url:y,headers:b,schema:this.schemaName,body:_,fetch:(p=this.fetch)!==null&&p!==void 0?p:fetch})}}return I8.default=n,I8}Object.defineProperty(wm,"__esModule",{value:!0});var Cze=wm.PostgrestError=Rze=wm.PostgrestBuilder=Dze=wm.PostgrestTransformBuilder=Ize=wm.PostgrestFilterBuilder=Eze=wm.PostgrestQueryBuilder=Tze=wm.PostgrestClient=void 0;const bM=_M,Mze=bM.__importDefault(bmt());var Tze=wm.PostgrestClient=Mze.default;const Aze=bM.__importDefault(Sze());var Eze=wm.PostgrestQueryBuilder=Aze.default;const Pze=bM.__importDefault(I1e());var Ize=wm.PostgrestFilterBuilder=Pze.default;const Lze=bM.__importDefault(kze());var Dze=wm.PostgrestTransformBuilder=Lze.default;const Oze=bM.__importDefault(Nze());var Rze=wm.PostgrestBuilder=Oze.default;const Fze=bM.__importDefault(jze());Cze=wm.PostgrestError=Fze.default;var zze=wm.default={PostgrestClient:Mze.default,PostgrestQueryBuilder:Aze.default,PostgrestFilterBuilder:Pze.default,PostgrestTransformBuilder:Lze.default,PostgrestBuilder:Oze.default,PostgrestError:Fze.default};const wmt=Object.freeze(Object.defineProperty({__proto__:null,get PostgrestBuilder(){return Rze},get PostgrestClient(){return Tze},get PostgrestError(){return Cze},get PostgrestFilterBuilder(){return Ize},get PostgrestQueryBuilder(){return Eze},get PostgrestTransformBuilder(){return Dze},default:zze},Symbol.toStringTag,{value:"Module"})),{PostgrestClient:jmt,PostgrestQueryBuilder:S_s,PostgrestFilterBuilder:C_s,PostgrestTransformBuilder:M_s,PostgrestBuilder:T_s,PostgrestError:A_s}=zze||wmt;class Nmt{static detectEnvironment(){var s;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((s=navigator.userAgent)===null||s===void 0)&&s.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(typeof process<"u"){const r=process.versions;if(r&&r.node){const n=r.node,a=parseInt(n.replace(/^v/,"").split(".")[0]);return a>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${a} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${a} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option: import ws from "ws" new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const s=this.detectEnvironment();if(s.constructor)return s.constructor;let r=s.error||"WebSocket not supported in this environment.";throw s.workaround&&(r+=` Suggested solution: ${s.workaround}`),new Error(r)}static createWebSocket(s,r){const n=this.getWebSocketConstructor();return new n(s,r)}static isWebSocketSupported(){try{const s=this.detectEnvironment();return s.type==="native"||s.type==="ws"}catch{return!1}}}const kmt="2.78.0",Smt=`realtime-js/${kmt}`,Cmt="1.0.0",wge=1e4,Mmt=1e3,Tmt=100;var ZP;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(ZP||(ZP={}));var Ld;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(Ld||(Ld={}));var Cg;(function(t){t.close="phx_close",t.error="phx_error",t.join="phx_join",t.reply="phx_reply",t.leave="phx_leave",t.access_token="access_token"})(Cg||(Cg={}));var jge;(function(t){t.websocket="websocket"})(jge||(jge={}));var NN;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(NN||(NN={}));class Amt{constructor(){this.HEADER_LENGTH=1}decode(s,r){return s.constructor===ArrayBuffer?r(this._binaryDecode(s)):r(typeof s=="string"?JSON.parse(s):{})}_binaryDecode(s){const r=new DataView(s),n=new TextDecoder;return this._decodeBroadcast(s,r,n)}_decodeBroadcast(s,r,n){const a=r.getUint8(1),o=r.getUint8(2);let l=this.HEADER_LENGTH+2;const i=n.decode(s.slice(l,l+a));l=l+a;const d=n.decode(s.slice(l,l+o));l=l+o;const u=JSON.parse(n.decode(s.slice(l,s.byteLength)));return{ref:null,topic:i,event:d,payload:u}}}class Bze{constructor(s,r){this.callback=s,this.timerCalc=r,this.timer=void 0,this.tries=0,this.callback=s,this.timerCalc=r}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var Sl;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(Sl||(Sl={}));const a5e=(t,s,r={})=>{var n;const a=(n=r.skipTypes)!==null&&n!==void 0?n:[];return s?Object.keys(s).reduce((o,l)=>(o[l]=Emt(l,t,s,a),o),{}):{}},Emt=(t,s,r,n)=>{const a=s.find(i=>i.name===t),o=a==null?void 0:a.type,l=r[t];return o&&!n.includes(o)?$ze(o,l):Nge(l)},$ze=(t,s)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return Dmt(s,r)}switch(t){case Sl.bool:return Pmt(s);case Sl.float4:case Sl.float8:case Sl.int2:case Sl.int4:case Sl.int8:case Sl.numeric:case Sl.oid:return Imt(s);case Sl.json:case Sl.jsonb:return Lmt(s);case Sl.timestamp:return Omt(s);case Sl.abstime:case Sl.date:case Sl.daterange:case Sl.int4range:case Sl.int8range:case Sl.money:case Sl.reltime:case Sl.text:case Sl.time:case Sl.timestamptz:case Sl.timetz:case Sl.tsrange:case Sl.tstzrange:return Nge(s);default:return Nge(s)}},Nge=t=>t,Pmt=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},Imt=t=>{if(typeof t=="string"){const s=parseFloat(t);if(!Number.isNaN(s))return s}return t},Lmt=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(s){return console.log(`JSON parse error: ${s}`),t}return t},Dmt=(t,s)=>{if(typeof t!="string")return t;const r=t.length-1,n=t[r];if(t[0]==="{"&&n==="}"){let o;const l=t.slice(1,r);try{o=JSON.parse("["+l+"]")}catch{o=l?l.split(","):[]}return o.map(i=>$ze(s,i))}return t},Omt=t=>typeof t=="string"?t.replace(" ","T"):t,qze=t=>{const s=new URL(t);return s.protocol=s.protocol.replace(/^ws/i,"http"),s.pathname=s.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),s.pathname===""||s.pathname==="/"?s.pathname="/api/broadcast":s.pathname=s.pathname+"/api/broadcast",s.href};class Mhe{constructor(s,r,n={},a=wge){this.channel=s,this.event=r,this.payload=n,this.timeout=a,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(s){this.timeout=s,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(s){this.payload=Object.assign(Object.assign({},this.payload),s)}receive(s,r){var n;return this._hasReceived(s)&&r((n=this.receivedResp)===null||n===void 0?void 0:n.response),this.recHooks.push({status:s,callback:r}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const s=r=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=r,this._matchReceive(r)};this.channel._on(this.refEvent,{},s),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(s,r){this.refEvent&&this.channel._trigger(this.refEvent,{status:s,response:r})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:s,response:r}){this.recHooks.filter(n=>n.status===s).forEach(n=>n.callback(r))}_hasReceived(s){return this.receivedResp&&this.receivedResp.status===s}}var i5e;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(i5e||(i5e={}));class YP{constructor(s,r){this.channel=s,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const n=(r==null?void 0:r.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(n.state,{},a=>{const{onJoin:o,onLeave:l,onSync:i}=this.caller;this.joinRef=this.channel._joinRef(),this.state=YP.syncState(this.state,a,o,l),this.pendingDiffs.forEach(d=>{this.state=YP.syncDiff(this.state,d,o,l)}),this.pendingDiffs=[],i()}),this.channel._on(n.diff,{},a=>{const{onJoin:o,onLeave:l,onSync:i}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(a):(this.state=YP.syncDiff(this.state,a,o,l),i())}),this.onJoin((a,o,l)=>{this.channel._trigger("presence",{event:"join",key:a,currentPresences:o,newPresences:l})}),this.onLeave((a,o,l)=>{this.channel._trigger("presence",{event:"leave",key:a,currentPresences:o,leftPresences:l})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(s,r,n,a){const o=this.cloneDeep(s),l=this.transformState(r),i={},d={};return this.map(o,(u,p)=>{l[u]||(d[u]=p)}),this.map(l,(u,p)=>{const f=o[u];if(f){const y=p.map(j=>j.presence_ref),_=f.map(j=>j.presence_ref),b=p.filter(j=>_.indexOf(j.presence_ref)<0),w=f.filter(j=>y.indexOf(j.presence_ref)<0);b.length>0&&(i[u]=b),w.length>0&&(d[u]=w)}else i[u]=p}),this.syncDiff(o,{joins:i,leaves:d},n,a)}static syncDiff(s,r,n,a){const{joins:o,leaves:l}={joins:this.transformState(r.joins),leaves:this.transformState(r.leaves)};return n||(n=()=>{}),a||(a=()=>{}),this.map(o,(i,d)=>{var u;const p=(u=s[i])!==null&&u!==void 0?u:[];if(s[i]=this.cloneDeep(d),p.length>0){const f=s[i].map(_=>_.presence_ref),y=p.filter(_=>f.indexOf(_.presence_ref)<0);s[i].unshift(...y)}n(i,p,d)}),this.map(l,(i,d)=>{let u=s[i];if(!u)return;const p=d.map(f=>f.presence_ref);u=u.filter(f=>p.indexOf(f.presence_ref)<0),s[i]=u,a(i,u,d),u.length===0&&delete s[i]}),s}static map(s,r){return Object.getOwnPropertyNames(s).map(n=>r(n,s[n]))}static transformState(s){return s=this.cloneDeep(s),Object.getOwnPropertyNames(s).reduce((r,n)=>{const a=s[n];return"metas"in a?r[n]=a.metas.map(o=>(o.presence_ref=o.phx_ref,delete o.phx_ref,delete o.phx_ref_prev,o)):r[n]=a,r},{})}static cloneDeep(s){return JSON.parse(JSON.stringify(s))}onJoin(s){this.caller.onJoin=s}onLeave(s){this.caller.onLeave=s}onSync(s){this.caller.onSync=s}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var o5e;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(o5e||(o5e={}));var XP;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(XP||(XP={}));var l0;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(l0||(l0={}));class L1e{constructor(s,r={config:{}},n){var a,o;if(this.topic=s,this.params=r,this.socket=n,this.bindings={},this.state=Ld.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=s.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config),this.timeout=this.socket.timeout,this.joinPush=new Mhe(this,Cg.join,this.params,this.timeout),this.rejoinTimer=new Bze(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Ld.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(l=>l.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=Ld.closed,this.socket._remove(this)}),this._onError(l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=Ld.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Ld.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=Ld.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Cg.reply,{},(l,i)=>{this._trigger(this._replyEventName(i),l)}),this.presence=new YP(this),this.broadcastEndpointURL=qze(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(!((o=(a=this.params.config)===null||a===void 0?void 0:a.broadcast)===null||o===void 0)&&o.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(s,r=this.timeout){var n,a,o;if(this.socket.isConnected()||this.socket.connect(),this.state==Ld.closed){const{config:{broadcast:l,presence:i,private:d}}=this.params,u=(a=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(_=>_.filter))!==null&&a!==void 0?a:[],p=!!this.bindings[XP.PRESENCE]&&this.bindings[XP.PRESENCE].length>0||((o=this.params.config.presence)===null||o===void 0?void 0:o.enabled)===!0,f={},y={broadcast:l,presence:Object.assign(Object.assign({},i),{enabled:p}),postgres_changes:u,private:d};this.socket.accessTokenValue&&(f.access_token=this.socket.accessTokenValue),this._onError(_=>s==null?void 0:s(l0.CHANNEL_ERROR,_)),this._onClose(()=>s==null?void 0:s(l0.CLOSED)),this.updateJoinPayload(Object.assign({config:y},f)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:_})=>{var b;if(this.socket.setAuth(),_===void 0){s==null||s(l0.SUBSCRIBED);return}else{const w=this.bindings.postgres_changes,j=(b=w==null?void 0:w.length)!==null&&b!==void 0?b:0,k=[];for(let S=0;S{this.state=Ld.errored,s==null||s(l0.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(_).join(", ")||"error")))}).receive("timeout",()=>{s==null||s(l0.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(s,r={}){return await this.send({type:"presence",event:"track",payload:s},r.timeout||this.timeout)}async untrack(s={}){return await this.send({type:"presence",event:"untrack"},s)}on(s,r,n){return this.state===Ld.joined&&s===XP.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(()=>this.subscribe())),this._on(s,r,n)}async httpSend(s,r,n={}){var a;const o=this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"";if(r==null)return Promise.reject("Payload is required for httpSend()");const l={method:"POST",headers:{Authorization:o,apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:s,payload:r,private:this.private}]})},i=await this._fetchWithTimeout(this.broadcastEndpointURL,l,(a=n.timeout)!==null&&a!==void 0?a:this.timeout);if(i.status===202)return{success:!0};let d=i.statusText;try{const u=await i.json();d=u.error||u.message||d}catch{}return Promise.reject(new Error(d))}async send(s,r={}){var n,a;if(!this._canPush()&&s.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:o,payload:l}=s,d={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:o,payload:l,private:this.private}]})};try{const u=await this._fetchWithTimeout(this.broadcastEndpointURL,d,(n=r.timeout)!==null&&n!==void 0?n:this.timeout);return await((a=u.body)===null||a===void 0?void 0:a.cancel()),u.ok?"ok":"error"}catch(u){return u.name==="AbortError"?"timed out":"error"}}else return new Promise(o=>{var l,i,d;const u=this._push(s.type,s,r.timeout||this.timeout);s.type==="broadcast"&&!(!((d=(i=(l=this.params)===null||l===void 0?void 0:l.config)===null||i===void 0?void 0:i.broadcast)===null||d===void 0)&&d.ack)&&o("ok"),u.receive("ok",()=>o("ok")),u.receive("error",()=>o("error")),u.receive("timeout",()=>o("timed out"))})}updateJoinPayload(s){this.joinPush.updatePayload(s)}unsubscribe(s=this.timeout){this.state=Ld.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Cg.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(a=>{n=new Mhe(this,Cg.leave,{},s),n.receive("ok",()=>{r(),a("ok")}).receive("timeout",()=>{r(),a("timed out")}).receive("error",()=>{a("error")}),n.send(),this._canPush()||n.trigger("ok",{})}).finally(()=>{n==null||n.destroy()})}teardown(){this.pushBuffer.forEach(s=>s.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=Ld.closed,this.bindings={}}async _fetchWithTimeout(s,r,n){const a=new AbortController,o=setTimeout(()=>a.abort(),n),l=await this.socket.fetch(s,Object.assign(Object.assign({},r),{signal:a.signal}));return clearTimeout(o),l}_push(s,r,n=this.timeout){if(!this.joinedOnce)throw`tried to push '${s}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let a=new Mhe(this,s,r,n);return this._canPush()?a.send():this._addToPushBuffer(a),a}_addToPushBuffer(s){if(s.startTimeout(),this.pushBuffer.push(s),this.pushBuffer.length>Tmt){const r=this.pushBuffer.shift();r&&(r.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${r.event}`,r.payload))}}_onMessage(s,r,n){return r}_isMember(s){return this.topic===s}_joinRef(){return this.joinPush.ref}_trigger(s,r,n){var a,o;const l=s.toLocaleLowerCase(),{close:i,error:d,leave:u,join:p}=Cg;if(n&&[i,d,u,p].indexOf(l)>=0&&n!==this._joinRef())return;let y=this._onMessage(l,r,n);if(r&&!y)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(l)?(a=this.bindings.postgres_changes)===null||a===void 0||a.filter(_=>{var b,w,j;return((b=_.filter)===null||b===void 0?void 0:b.event)==="*"||((j=(w=_.filter)===null||w===void 0?void 0:w.event)===null||j===void 0?void 0:j.toLocaleLowerCase())===l}).map(_=>_.callback(y,n)):(o=this.bindings[l])===null||o===void 0||o.filter(_=>{var b,w,j,k,S,T;if(["broadcast","presence","postgres_changes"].includes(l))if("id"in _){const I=_.id,L=(b=_.filter)===null||b===void 0?void 0:b.event;return I&&((w=r.ids)===null||w===void 0?void 0:w.includes(I))&&(L==="*"||(L==null?void 0:L.toLocaleLowerCase())===((j=r.data)===null||j===void 0?void 0:j.type.toLocaleLowerCase()))}else{const I=(S=(k=_==null?void 0:_.filter)===null||k===void 0?void 0:k.event)===null||S===void 0?void 0:S.toLocaleLowerCase();return I==="*"||I===((T=r==null?void 0:r.event)===null||T===void 0?void 0:T.toLocaleLowerCase())}else return _.type.toLocaleLowerCase()===l}).map(_=>{if(typeof y=="object"&&"ids"in y){const b=y.data,{schema:w,table:j,commit_timestamp:k,type:S,errors:T}=b;y=Object.assign(Object.assign({},{schema:w,table:j,commit_timestamp:k,eventType:S,new:{},old:{},errors:T}),this._getPayloadRecords(b))}_.callback(y,n)})}_isClosed(){return this.state===Ld.closed}_isJoined(){return this.state===Ld.joined}_isJoining(){return this.state===Ld.joining}_isLeaving(){return this.state===Ld.leaving}_replyEventName(s){return`chan_reply_${s}`}_on(s,r,n){const a=s.toLocaleLowerCase(),o={type:a,filter:r,callback:n};return this.bindings[a]?this.bindings[a].push(o):this.bindings[a]=[o],this}_off(s,r){const n=s.toLocaleLowerCase();return this.bindings[n]&&(this.bindings[n]=this.bindings[n].filter(a=>{var o;return!(((o=a.type)===null||o===void 0?void 0:o.toLocaleLowerCase())===n&&L1e.isEqual(a.filter,r))})),this}static isEqual(s,r){if(Object.keys(s).length!==Object.keys(r).length)return!1;for(const n in s)if(s[n]!==r[n])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(s){this._on(Cg.close,{},s)}_onError(s){this._on(Cg.error,{},r=>s(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(s=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Ld.joining,this.joinPush.resend(s))}_getPayloadRecords(s){const r={new:{},old:{}};return(s.type==="INSERT"||s.type==="UPDATE")&&(r.new=a5e(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(r.old=a5e(s.columns,s.old_record)),r}}const The=()=>{},z8={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},Rmt=[1e3,2e3,5e3,1e4],Fmt=1e4,zmt=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class Bmt{constructor(s,r){var n;if(this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=wge,this.transport=null,this.heartbeatIntervalMs=z8.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=The,this.ref=0,this.reconnectTimer=null,this.logger=The,this.conn=null,this.sendBuffer=[],this.serializer=new Amt,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=a=>{let o;return a?o=a:typeof fetch>"u"?o=(...l)=>hh(async()=>{const{default:i}=await Promise.resolve().then(()=>aS);return{default:i}},void 0).then(({default:i})=>i(...l)).catch(i=>{throw new Error(`Failed to load @supabase/node-fetch: ${i.message}. This is required for HTTP requests in Node.js environments without native fetch.`)}):o=fetch,(...l)=>o(...l)},!(!((n=r==null?void 0:r.params)===null||n===void 0)&&n.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=r.params.apikey,this.endPoint=`${s}/${jge.websocket}`,this.httpEndpoint=qze(s),this._initializeOptions(r),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(r==null?void 0:r.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=Nmt.createWebSocket(this.endpointURL())}catch(s){this._setConnectionState("disconnected");const r=s.message;throw r.includes("Node.js")?new Error(`${r} To use Realtime in Node.js, you need to provide a WebSocket implementation: Option 1: Use Node.js 22+ which has native WebSocket support Option 2: Install and provide the "ws" package: npm install ws import ws from "ws" const client = new RealtimeClient(url, { ...options, transport: ws })`):new Error(`WebSocket not available: ${r}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:Cmt}))}disconnect(s,r){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const n=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(n),this._setConnectionState("disconnected")},s?this.conn.close(s,r??""):this.conn.close(),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(s){const r=await s.unsubscribe();return this.channels.length===0&&this.disconnect(),r}async removeAllChannels(){const s=await Promise.all(this.channels.map(r=>r.unsubscribe()));return this.channels=[],this.disconnect(),s}log(s,r,n){this.logger(s,r,n)}connectionState(){switch(this.conn&&this.conn.readyState){case ZP.connecting:return NN.Connecting;case ZP.open:return NN.Open;case ZP.closing:return NN.Closing;default:return NN.Closed}}isConnected(){return this.connectionState()===NN.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(s,r={config:{}}){const n=`realtime:${s}`,a=this.getChannels().find(o=>o.topic===n);if(a)return a;{const o=new L1e(`realtime:${s}`,r,this);return this.channels.push(o),o}}push(s){const{topic:r,event:n,payload:a,ref:o}=s,l=()=>{this.encode(s,i=>{var d;(d=this.conn)===null||d===void 0||d.send(i)})};this.log("push",`${r} ${n} (${o})`,a),this.isConnected()?l():this.sendBuffer.push(l)}async setAuth(s=null){this._authPromise=this._performAuth(s);try{await this._authPromise}finally{this._authPromise=null}}async sendHeartbeat(){var s;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(r){this.log("error","error in heartbeat callback",r)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(r){this.log("error","error in heartbeat callback",r)}this._wasManualDisconnect=!1,(s=this.conn)===null||s===void 0||s.close(Mmt,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout()},z8.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(r){this.log("error","error in heartbeat callback",r)}this._setAuthSafely("heartbeat")}onHeartbeat(s){this.heartbeatCallback=s}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(s=>s()),this.sendBuffer=[])}_makeRef(){let s=this.ref+1;return s===this.ref?this.ref=0:this.ref=s,this.ref.toString()}_leaveOpenTopic(s){let r=this.channels.find(n=>n.topic===s&&(n._isJoined()||n._isJoining()));r&&(this.log("transport",`leaving duplicate topic "${s}"`),r.unsubscribe())}_remove(s){this.channels=this.channels.filter(r=>r.topic!==s.topic)}_onConnMessage(s){this.decode(s.data,r=>{if(r.topic==="phoenix"&&r.event==="phx_reply")try{this.heartbeatCallback(r.payload.status==="ok"?"ok":"error")}catch(u){this.log("error","error in heartbeat callback",u)}r.ref&&r.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:n,event:a,payload:o,ref:l}=r,i=l?`(${l})`:"",d=o.status||"";this.log("receive",`${d} ${n} ${a} ${i}`.trim(),o),this.channels.filter(u=>u._isMember(n)).forEach(u=>u._trigger(a,o,l)),this._triggerStateCallbacks("message",r)})}_clearTimer(s){var r;s==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):s==="reconnect"&&((r=this.reconnectTimer)===null||r===void 0||r.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=s=>this._onConnError(s),this.conn.onmessage=s=>this._onConnMessage(s),this.conn.onclose=s=>this._onConnClose(s))}_teardownConnection(){this.conn&&(this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null),this._clearAllTimers(),this.channels.forEach(s=>s.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const s=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(s),this.workerRef.onerror=r=>{this.log("worker","worker error",r.message),this.workerRef.terminate()},this.workerRef.onmessage=r=>{r.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(s){var r;this._setConnectionState("disconnected"),this.log("transport","close",s),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout(),this._triggerStateCallbacks("close",s)}_onConnError(s){this._setConnectionState("disconnected"),this.log("transport",`${s}`),this._triggerChanError(),this._triggerStateCallbacks("error",s)}_triggerChanError(){this.channels.forEach(s=>s._trigger(Cg.error))}_appendParams(s,r){if(Object.keys(r).length===0)return s;const n=s.match(/\?/)?"&":"?",a=new URLSearchParams(r);return`${s}${n}${a}`}_workerObjectUrl(s){let r;if(s)r=s;else{const n=new Blob([zmt],{type:"application/javascript"});r=URL.createObjectURL(n)}return r}_setConnectionState(s,r=!1){this._connectionState=s,s==="connecting"?this._wasManualDisconnect=!1:s==="disconnecting"&&(this._wasManualDisconnect=r)}async _performAuth(s=null){let r;s?r=s:this.accessToken?r=await this.accessToken():r=this.accessTokenValue,this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(n=>{const a={access_token:r,version:Smt};r&&n.updateJoinPayload(a),n.joinedOnce&&n._isJoined()&&n._push(Cg.access_token,{access_token:r})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(s="general"){this.setAuth().catch(r=>{this.log("error",`error setting auth in ${s}`,r)})}_triggerStateCallbacks(s,r){try{this.stateChangeCallbacks[s].forEach(n=>{try{n(r)}catch(a){this.log("error",`error in ${s} callback`,a)}})}catch(n){this.log("error",`error triggering ${s} callbacks`,n)}}_setupReconnectionTimer(){this.reconnectTimer=new Bze(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},z8.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(s){var r,n,a,o,l,i,d,u,p;if(this.transport=(r=s==null?void 0:s.transport)!==null&&r!==void 0?r:null,this.timeout=(n=s==null?void 0:s.timeout)!==null&&n!==void 0?n:wge,this.heartbeatIntervalMs=(a=s==null?void 0:s.heartbeatIntervalMs)!==null&&a!==void 0?a:z8.HEARTBEAT_INTERVAL,this.worker=(o=s==null?void 0:s.worker)!==null&&o!==void 0?o:!1,this.accessToken=(l=s==null?void 0:s.accessToken)!==null&&l!==void 0?l:null,this.heartbeatCallback=(i=s==null?void 0:s.heartbeatCallback)!==null&&i!==void 0?i:The,s!=null&&s.params&&(this.params=s.params),s!=null&&s.logger&&(this.logger=s.logger),(s!=null&&s.logLevel||s!=null&&s.log_level)&&(this.logLevel=s.logLevel||s.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(d=s==null?void 0:s.reconnectAfterMs)!==null&&d!==void 0?d:f=>Rmt[f-1]||Fmt,this.encode=(u=s==null?void 0:s.encode)!==null&&u!==void 0?u:(f,y)=>y(JSON.stringify(f)),this.decode=(p=s==null?void 0:s.decode)!==null&&p!==void 0?p:this.serializer.decode.bind(this.serializer),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=s==null?void 0:s.workerUrl}}}class D1e extends Error{constructor(s){super(s),this.__isStorageError=!0,this.name="StorageError"}}function jc(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class $mt extends D1e{constructor(s,r,n){super(s),this.name="StorageApiError",this.status=r,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class kge extends D1e{constructor(s,r){super(s),this.name="StorageUnknownError",this.originalError=r}}const O1e=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>hh(async()=>{const{default:n}=await Promise.resolve().then(()=>aS);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},qmt=()=>da(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield hh(()=>Promise.resolve().then(()=>aS),void 0)).Response:Response}),Sge=t=>{if(Array.isArray(t))return t.map(r=>Sge(r));if(typeof t=="function"||t!==Object(t))return t;const s={};return Object.entries(t).forEach(([r,n])=>{const a=r.replace(/([-_][a-z])/gi,o=>o.toUpperCase().replace(/[-_]/g,""));s[a]=Sge(n)}),s},Umt=t=>{if(typeof t!="object"||t===null)return!1;const s=Object.getPrototypeOf(t);return(s===null||s===Object.prototype||Object.getPrototypeOf(s)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},Ahe=t=>{var s;return t.msg||t.message||t.error_description||(typeof t.error=="string"?t.error:(s=t.error)===null||s===void 0?void 0:s.message)||JSON.stringify(t)},Vmt=(t,s,r)=>da(void 0,void 0,void 0,function*(){const n=yield qmt();t instanceof n&&!(r!=null&&r.noResolveJson)?t.json().then(a=>{const o=t.status||500,l=(a==null?void 0:a.statusCode)||o+"";s(new $mt(Ahe(a),o,l))}).catch(a=>{s(new kge(Ahe(a),a))}):s(new kge(Ahe(t),t))}),Hmt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"||!n?a:(Umt(n)?(a.headers=Object.assign({"Content-Type":"application/json"},s==null?void 0:s.headers),a.body=JSON.stringify(n)):a.body=n,s!=null&&s.duplex&&(a.duplex=s.duplex),Object.assign(Object.assign({},a),r))};function SL(t,s,r,n,a,o){return da(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,Hmt(s,n,a,o)).then(d=>{if(!d.ok)throw d;return n!=null&&n.noResolveJson?d:d.json()}).then(d=>l(d)).catch(d=>Vmt(d,i,n))})})}function JI(t,s,r,n){return da(this,void 0,void 0,function*(){return SL(t,"GET",s,r,n)})}function jg(t,s,r,n,a){return da(this,void 0,void 0,function*(){return SL(t,"POST",s,n,a,r)})}function Cge(t,s,r,n,a){return da(this,void 0,void 0,function*(){return SL(t,"PUT",s,n,a,r)})}function Wmt(t,s,r,n){return da(this,void 0,void 0,function*(){return SL(t,"HEAD",s,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function R1e(t,s,r,n,a){return da(this,void 0,void 0,function*(){return SL(t,"DELETE",s,n,a,r)})}class Gmt{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r}then(s,r){return this.execute().then(s,r)}execute(){return da(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(jc(s))return{data:null,error:s};throw s}})}}var Uze;class Kmt{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r,this[Uze]="BlobDownloadBuilder",this.promise=null}asStream(){return new Gmt(this.downloadFn,this.shouldThrowOnError)}then(s,r){return this.getPromise().then(s,r)}catch(s){return this.getPromise().catch(s)}finally(s){return this.getPromise().finally(s)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}execute(){return da(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(jc(s))return{data:null,error:s};throw s}})}}Uze=Symbol.toStringTag;const Zmt={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},l5e={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class Ymt{constructor(s,r={},n,a){this.shouldThrowOnError=!1,this.url=s,this.headers=r,this.bucketId=n,this.fetch=O1e(a)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(s,r,n,a){return da(this,void 0,void 0,function*(){try{let o;const l=Object.assign(Object.assign({},l5e),a);let i=Object.assign(Object.assign({},this.headers),s==="POST"&&{"x-upsert":String(l.upsert)});const d=l.metadata;typeof Blob<"u"&&n instanceof Blob?(o=new FormData,o.append("cacheControl",l.cacheControl),d&&o.append("metadata",this.encodeMetadata(d)),o.append("",n)):typeof FormData<"u"&&n instanceof FormData?(o=n,o.append("cacheControl",l.cacheControl),d&&o.append("metadata",this.encodeMetadata(d))):(o=n,i["cache-control"]=`max-age=${l.cacheControl}`,i["content-type"]=l.contentType,d&&(i["x-metadata"]=this.toBase64(this.encodeMetadata(d)))),a!=null&&a.headers&&(i=Object.assign(Object.assign({},i),a.headers));const u=this._removeEmptyFolders(r),p=this._getFinalPath(u),f=yield(s=="PUT"?Cge:jg)(this.fetch,`${this.url}/object/${p}`,o,Object.assign({headers:i},l!=null&&l.duplex?{duplex:l.duplex}:{}));return{data:{path:u,id:f.Id,fullPath:f.Key},error:null}}catch(o){if(this.shouldThrowOnError)throw o;if(jc(o))return{data:null,error:o};throw o}})}upload(s,r,n){return da(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",s,r,n)})}uploadToSignedUrl(s,r,n,a){return da(this,void 0,void 0,function*(){const o=this._removeEmptyFolders(s),l=this._getFinalPath(o),i=new URL(this.url+`/object/upload/sign/${l}`);i.searchParams.set("token",r);try{let d;const u=Object.assign({upsert:l5e.upsert},a),p=Object.assign(Object.assign({},this.headers),{"x-upsert":String(u.upsert)});typeof Blob<"u"&&n instanceof Blob?(d=new FormData,d.append("cacheControl",u.cacheControl),d.append("",n)):typeof FormData<"u"&&n instanceof FormData?(d=n,d.append("cacheControl",u.cacheControl)):(d=n,p["cache-control"]=`max-age=${u.cacheControl}`,p["content-type"]=u.contentType);const f=yield Cge(this.fetch,i.toString(),d,{headers:p});return{data:{path:o,fullPath:f.Key},error:null}}catch(d){if(this.shouldThrowOnError)throw d;if(jc(d))return{data:null,error:d};throw d}})}createSignedUploadUrl(s,r){return da(this,void 0,void 0,function*(){try{let n=this._getFinalPath(s);const a=Object.assign({},this.headers);r!=null&&r.upsert&&(a["x-upsert"]="true");const o=yield jg(this.fetch,`${this.url}/object/upload/sign/${n}`,{},{headers:a}),l=new URL(this.url+o.url),i=l.searchParams.get("token");if(!i)throw new D1e("No token returned by API");return{data:{signedUrl:l.toString(),path:s,token:i},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(jc(n))return{data:null,error:n};throw n}})}update(s,r,n){return da(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",s,r,n)})}move(s,r,n){return da(this,void 0,void 0,function*(){try{return{data:yield jg(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:s,destinationKey:r,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers}),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(jc(a))return{data:null,error:a};throw a}})}copy(s,r,n){return da(this,void 0,void 0,function*(){try{return{data:{path:(yield jg(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:s,destinationKey:r,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers})).Key},error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(jc(a))return{data:null,error:a};throw a}})}createSignedUrl(s,r,n){return da(this,void 0,void 0,function*(){try{let a=this._getFinalPath(s),o=yield jg(this.fetch,`${this.url}/object/sign/${a}`,Object.assign({expiresIn:r},n!=null&&n.transform?{transform:n.transform}:{}),{headers:this.headers});const l=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return o={signedUrl:encodeURI(`${this.url}${o.signedURL}${l}`)},{data:o,error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(jc(a))return{data:null,error:a};throw a}})}createSignedUrls(s,r,n){return da(this,void 0,void 0,function*(){try{const a=yield jg(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:r,paths:s},{headers:this.headers}),o=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return{data:a.map(l=>Object.assign(Object.assign({},l),{signedUrl:l.signedURL?encodeURI(`${this.url}${l.signedURL}${o}`):null})),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(jc(a))return{data:null,error:a};throw a}})}download(s,r){const a=typeof(r==null?void 0:r.transform)<"u"?"render/image/authenticated":"object",o=this.transformOptsToQueryString((r==null?void 0:r.transform)||{}),l=o?`?${o}`:"",i=this._getFinalPath(s),d=()=>JI(this.fetch,`${this.url}/${a}/${i}${l}`,{headers:this.headers,noResolveJson:!0});return new Kmt(d,this.shouldThrowOnError)}info(s){return da(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{const n=yield JI(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:Sge(n),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(jc(n))return{data:null,error:n};throw n}})}exists(s){return da(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{return yield Wmt(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(jc(n)&&n instanceof kge){const a=n.originalError;if([400,404].includes(a==null?void 0:a.status))return{data:!1,error:n}}throw n}})}getPublicUrl(s,r){const n=this._getFinalPath(s),a=[],o=r!=null&&r.download?`download=${r.download===!0?"":r.download}`:"";o!==""&&a.push(o);const i=typeof(r==null?void 0:r.transform)<"u"?"render/image":"object",d=this.transformOptsToQueryString((r==null?void 0:r.transform)||{});d!==""&&a.push(d);let u=a.join("&");return u!==""&&(u=`?${u}`),{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${n}${u}`)}}}remove(s){return da(this,void 0,void 0,function*(){try{return{data:yield R1e(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(jc(r))return{data:null,error:r};throw r}})}list(s,r,n){return da(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},Zmt),r),{prefix:s||""});return{data:yield jg(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},n),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(jc(a))return{data:null,error:a};throw a}})}listV2(s,r){return da(this,void 0,void 0,function*(){try{const n=Object.assign({},s);return{data:yield jg(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(jc(n))return{data:null,error:n};throw n}})}encodeMetadata(s){return JSON.stringify(s)}toBase64(s){return typeof Buffer<"u"?Buffer.from(s).toString("base64"):btoa(s)}_getFinalPath(s){return`${this.bucketId}/${s.replace(/^\/+/,"")}`}_removeEmptyFolders(s){return s.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(s){const r=[];return s.width&&r.push(`width=${s.width}`),s.height&&r.push(`height=${s.height}`),s.resize&&r.push(`resize=${s.resize}`),s.format&&r.push(`format=${s.format}`),s.quality&&r.push(`quality=${s.quality}`),r.join("&")}}const Vze="2.78.0",Hze={"X-Client-Info":`storage-js/${Vze}`};class Xmt{constructor(s,r={},n,a){this.shouldThrowOnError=!1;const o=new URL(s);a!=null&&a.useNewHostname&&/supabase\.(co|in|red)$/.test(o.hostname)&&!o.hostname.includes("storage.supabase.")&&(o.hostname=o.hostname.replace("supabase.","storage.supabase.")),this.url=o.href.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Hze),r),this.fetch=O1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(s){return da(this,void 0,void 0,function*(){try{const r=this.listBucketOptionsToQueryString(s);return{data:yield JI(this.fetch,`${this.url}/bucket${r}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(jc(r))return{data:null,error:r};throw r}})}getBucket(s){return da(this,void 0,void 0,function*(){try{return{data:yield JI(this.fetch,`${this.url}/bucket/${s}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(jc(r))return{data:null,error:r};throw r}})}createBucket(s){return da(this,arguments,void 0,function*(r,n={public:!1}){try{return{data:yield jg(this.fetch,`${this.url}/bucket`,{id:r,name:r,type:n.type,public:n.public,file_size_limit:n.fileSizeLimit,allowed_mime_types:n.allowedMimeTypes},{headers:this.headers}),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(jc(a))return{data:null,error:a};throw a}})}updateBucket(s,r){return da(this,void 0,void 0,function*(){try{return{data:yield Cge(this.fetch,`${this.url}/bucket/${s}`,{id:s,name:s,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(jc(n))return{data:null,error:n};throw n}})}emptyBucket(s){return da(this,void 0,void 0,function*(){try{return{data:yield jg(this.fetch,`${this.url}/bucket/${s}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(jc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return da(this,void 0,void 0,function*(){try{return{data:yield R1e(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(jc(r))return{data:null,error:r};throw r}})}listBucketOptionsToQueryString(s){const r={};return s&&("limit"in s&&(r.limit=String(s.limit)),"offset"in s&&(r.offset=String(s.offset)),s.search&&(r.search=s.search),s.sortColumn&&(r.sortColumn=s.sortColumn),s.sortOrder&&(r.sortOrder=s.sortOrder)),Object.keys(r).length>0?"?"+new URLSearchParams(r).toString():""}}class Qmt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Hze),r),this.fetch=O1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return da(this,void 0,void 0,function*(){try{return{data:yield jg(this.fetch,`${this.url}/bucket`,{name:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(jc(r))return{data:null,error:r};throw r}})}listBuckets(s){return da(this,void 0,void 0,function*(){try{const r=new URLSearchParams;(s==null?void 0:s.limit)!==void 0&&r.set("limit",s.limit.toString()),(s==null?void 0:s.offset)!==void 0&&r.set("offset",s.offset.toString()),s!=null&&s.sortColumn&&r.set("sortColumn",s.sortColumn),s!=null&&s.sortOrder&&r.set("sortOrder",s.sortOrder),s!=null&&s.search&&r.set("search",s.search);const n=r.toString(),a=n?`${this.url}/bucket?${n}`:`${this.url}/bucket`;return{data:yield JI(this.fetch,a,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(jc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return da(this,void 0,void 0,function*(){try{return{data:yield R1e(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(jc(r))return{data:null,error:r};throw r}})}}const F1e={"X-Client-Info":`storage-js/${Vze}`,"Content-Type":"application/json"};class Wze extends Error{constructor(s){super(s),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}}function dp(t){return typeof t=="object"&&t!==null&&"__isStorageVectorsError"in t}class Ehe extends Wze{constructor(s,r,n){super(s),this.name="StorageVectorsApiError",this.status=r,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class Jmt extends Wze{constructor(s,r){super(s),this.name="StorageVectorsUnknownError",this.originalError=r}}var c5e;(function(t){t.InternalError="InternalError",t.S3VectorConflictException="S3VectorConflictException",t.S3VectorNotFoundException="S3VectorNotFoundException",t.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",t.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",t.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded"})(c5e||(c5e={}));const z1e=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>hh(async()=>{const{default:n}=await Promise.resolve().then(()=>aS);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},ept=t=>{if(typeof t!="object"||t===null)return!1;const s=Object.getPrototypeOf(t);return(s===null||s===Object.prototype||Object.getPrototypeOf(s)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},d5e=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),tpt=(t,s,r)=>da(void 0,void 0,void 0,function*(){if(t&&typeof t=="object"&&"status"in t&&"ok"in t&&typeof t.status=="number"&&!(r!=null&&r.noResolveJson)){const a=t.status||500,o=t;if(typeof o.json=="function")o.json().then(l=>{const i=(l==null?void 0:l.statusCode)||(l==null?void 0:l.code)||a+"";s(new Ehe(d5e(l),a,i))}).catch(()=>{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new Ehe(i,a,l))});else{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new Ehe(i,a,l))}}else s(new Jmt(d5e(t),t))}),spt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return n?(ept(n)?(a.headers=Object.assign({"Content-Type":"application/json"},s==null?void 0:s.headers),a.body=JSON.stringify(n)):a.body=n,Object.assign(Object.assign({},a),r)):a};function rpt(t,s,r,n,a,o){return da(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,spt(s,n,a,o)).then(d=>{if(!d.ok)throw d;if(n!=null&&n.noResolveJson)return d;const u=d.headers.get("content-type");return!u||!u.includes("application/json")?{}:d.json()}).then(d=>l(d)).catch(d=>tpt(d,i,n))})})}function up(t,s,r,n,a){return da(this,void 0,void 0,function*(){return rpt(t,"POST",s,n,a,r)})}class npt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},F1e),r),this.fetch=z1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(s){return da(this,void 0,void 0,function*(){try{return{data:(yield up(this.fetch,`${this.url}/CreateIndex`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(dp(r))return{data:null,error:r};throw r}})}getIndex(s,r){return da(this,void 0,void 0,function*(){try{return{data:yield up(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(dp(n))return{data:null,error:n};throw n}})}listIndexes(s){return da(this,void 0,void 0,function*(){try{return{data:yield up(this.fetch,`${this.url}/ListIndexes`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(dp(r))return{data:null,error:r};throw r}})}deleteIndex(s,r){return da(this,void 0,void 0,function*(){try{return{data:(yield up(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(dp(n))return{data:null,error:n};throw n}})}}class apt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},F1e),r),this.fetch=z1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(s){return da(this,void 0,void 0,function*(){try{if(s.vectors.length<1||s.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return{data:(yield up(this.fetch,`${this.url}/PutVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(dp(r))return{data:null,error:r};throw r}})}getVectors(s){return da(this,void 0,void 0,function*(){try{return{data:yield up(this.fetch,`${this.url}/GetVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(dp(r))return{data:null,error:r};throw r}})}listVectors(s){return da(this,void 0,void 0,function*(){try{if(s.segmentCount!==void 0){if(s.segmentCount<1||s.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(s.segmentIndex!==void 0&&(s.segmentIndex<0||s.segmentIndex>=s.segmentCount))throw new Error(`segmentIndex must be between 0 and ${s.segmentCount-1}`)}return{data:yield up(this.fetch,`${this.url}/ListVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(dp(r))return{data:null,error:r};throw r}})}queryVectors(s){return da(this,void 0,void 0,function*(){try{return{data:yield up(this.fetch,`${this.url}/QueryVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(dp(r))return{data:null,error:r};throw r}})}deleteVectors(s){return da(this,void 0,void 0,function*(){try{if(s.keys.length<1||s.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return{data:(yield up(this.fetch,`${this.url}/DeleteVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(dp(r))return{data:null,error:r};throw r}})}}class ipt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},F1e),r),this.fetch=z1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return da(this,void 0,void 0,function*(){try{return{data:(yield up(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(dp(r))return{data:null,error:r};throw r}})}getBucket(s){return da(this,void 0,void 0,function*(){try{return{data:yield up(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(dp(r))return{data:null,error:r};throw r}})}listBuckets(){return da(this,arguments,void 0,function*(s={}){try{return{data:yield up(this.fetch,`${this.url}/ListVectorBuckets`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(dp(r))return{data:null,error:r};throw r}})}deleteBucket(s){return da(this,void 0,void 0,function*(){try{return{data:(yield up(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(dp(r))return{data:null,error:r};throw r}})}}class opt extends ipt{constructor(s,r={}){super(s,r.headers||{},r.fetch)}from(s){return new lpt(this.url,this.headers,s,this.fetch)}}class lpt extends npt{constructor(s,r,n,a){super(s,r,a),this.vectorBucketName=n}createIndex(s){const r=Object.create(null,{createIndex:{get:()=>super.createIndex}});return da(this,void 0,void 0,function*(){return r.createIndex.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName}))})}listIndexes(){const s=Object.create(null,{listIndexes:{get:()=>super.listIndexes}});return da(this,arguments,void 0,function*(r={}){return s.listIndexes.call(this,Object.assign(Object.assign({},r),{vectorBucketName:this.vectorBucketName}))})}getIndex(s){const r=Object.create(null,{getIndex:{get:()=>super.getIndex}});return da(this,void 0,void 0,function*(){return r.getIndex.call(this,this.vectorBucketName,s)})}deleteIndex(s){const r=Object.create(null,{deleteIndex:{get:()=>super.deleteIndex}});return da(this,void 0,void 0,function*(){return r.deleteIndex.call(this,this.vectorBucketName,s)})}index(s){return new cpt(this.url,this.headers,this.vectorBucketName,s,this.fetch)}}class cpt extends apt{constructor(s,r,n,a,o){super(s,r,o),this.vectorBucketName=n,this.indexName=a}putVectors(s){const r=Object.create(null,{putVectors:{get:()=>super.putVectors}});return da(this,void 0,void 0,function*(){return r.putVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}getVectors(s){const r=Object.create(null,{getVectors:{get:()=>super.getVectors}});return da(this,void 0,void 0,function*(){return r.getVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}listVectors(){const s=Object.create(null,{listVectors:{get:()=>super.listVectors}});return da(this,arguments,void 0,function*(r={}){return s.listVectors.call(this,Object.assign(Object.assign({},r),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}queryVectors(s){const r=Object.create(null,{queryVectors:{get:()=>super.queryVectors}});return da(this,void 0,void 0,function*(){return r.queryVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}deleteVectors(s){const r=Object.create(null,{deleteVectors:{get:()=>super.deleteVectors}});return da(this,void 0,void 0,function*(){return r.deleteVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}}class dpt extends Xmt{constructor(s,r={},n,a){super(s,r,n,a)}from(s){return new Ymt(this.url,this.headers,s,this.fetch)}get vectors(){return new opt(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new Qmt(this.url+"/iceberg",this.headers,this.fetch)}}const upt="2.78.0";let LE="";typeof Deno<"u"?LE="deno":typeof document<"u"?LE="web":typeof navigator<"u"&&navigator.product==="ReactNative"?LE="react-native":LE="node";const hpt={"X-Client-Info":`supabase-js-${LE}/${upt}`},mpt={headers:hpt},ppt={schema:"public"},fpt={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},gpt={},xpt=t=>{let s;return t?s=t:typeof fetch>"u"?s=bze:s=fetch,(...r)=>s(...r)},ypt=()=>typeof Headers>"u"?wze:Headers,vpt=(t,s,r)=>{const n=xpt(r),a=ypt();return async(o,l)=>{var i;const d=(i=await s())!==null&&i!==void 0?i:t;let u=new a(l==null?void 0:l.headers);return u.has("apikey")||u.set("apikey",t),u.has("Authorization")||u.set("Authorization",`Bearer ${d}`),n(o,Object.assign(Object.assign({},l),{headers:u}))}};function _pt(t){return t.endsWith("/")?t:t+"/"}function bpt(t,s){var r,n;const{db:a,auth:o,realtime:l,global:i}=t,{db:d,auth:u,realtime:p,global:f}=s,y={db:Object.assign(Object.assign({},d),a),auth:Object.assign(Object.assign({},u),o),realtime:Object.assign(Object.assign({},p),l),storage:{},global:Object.assign(Object.assign(Object.assign({},f),i),{headers:Object.assign(Object.assign({},(r=f==null?void 0:f.headers)!==null&&r!==void 0?r:{}),(n=i==null?void 0:i.headers)!==null&&n!==void 0?n:{})}),accessToken:async()=>""};return t.accessToken?y.accessToken=t.accessToken:delete y.accessToken,y}function wpt(t){const s=t==null?void 0:t.trim();if(!s)throw new Error("supabaseUrl is required.");if(!s.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(_pt(s))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const Gze="2.78.0",w4=30*1e3,Mge=3,Phe=Mge*w4,jpt="http://localhost:9999",Npt="supabase.auth.token",kpt={"X-Client-Info":`gotrue-js/${Gze}`},Tge="X-Supabase-Api-Version",Kze={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},Spt=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,Cpt=10*60*1e3;class e6 extends Error{constructor(s,r,n){super(s),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function Ma(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class Mpt extends e6{constructor(s,r,n){super(s,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function Tpt(t){return Ma(t)&&t.name==="AuthApiError"}class kN extends e6{constructor(s,r){super(s),this.name="AuthUnknownError",this.originalError=r}}class W_ extends e6{constructor(s,r,n,a){super(s,n,a),this.name=r,this.status=n}}class xg extends W_{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Apt(t){return Ma(t)&&t.name==="AuthSessionMissingError"}class JC extends W_{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class B8 extends W_{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class $8 extends W_{constructor(s,r=null){super(s,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function Ept(t){return Ma(t)&&t.name==="AuthImplicitGrantRedirectError"}class u5e extends W_{constructor(s,r=null){super(s,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class Age extends W_{constructor(s,r){super(s,"AuthRetryableFetchError",r,void 0)}}function Ihe(t){return Ma(t)&&t.name==="AuthRetryableFetchError"}class h5e extends W_{constructor(s,r,n){super(s,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class Ege extends W_{constructor(s){super(s,"AuthInvalidJwtError",400,"invalid_jwt")}}const gne="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),m5e=` \r=`.split(""),Ppt=(()=>{const t=new Array(128);for(let s=0;s=6;){const n=s.queue>>s.queuedBits-6&63;r(gne[n]),s.queuedBits-=6}else if(s.queuedBits>0)for(s.queue=s.queue<<6-s.queuedBits,s.queuedBits=6;s.queuedBits>=6;){const n=s.queue>>s.queuedBits-6&63;r(gne[n]),s.queuedBits-=6}}function Zze(t,s,r){const n=Ppt[t];if(n>-1)for(s.queue=s.queue<<6|n,s.queuedBits+=6;s.queuedBits>=8;)r(s.queue>>s.queuedBits-8&255),s.queuedBits-=8;else{if(n===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function f5e(t){const s=[],r=l=>{s.push(String.fromCodePoint(l))},n={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},o=l=>{Dpt(l,n,r)};for(let l=0;l>6),s(128|t&63);return}else if(t<=65535){s(224|t>>12),s(128|t>>6&63),s(128|t&63);return}else if(t<=1114111){s(240|t>>18),s(128|t>>12&63),s(128|t>>6&63),s(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function Lpt(t,s){for(let r=0;r55295&&n<=56319){const a=(n-55296)*1024&65535;n=(t.charCodeAt(r+1)-56320&65535|a)+65536,r+=1}Ipt(n,s)}}function Dpt(t,s,r){if(s.utf8seq===0){if(t<=127){r(t);return}for(let n=1;n<6;n+=1)if(!(t>>7-n&1)){s.utf8seq=n;break}if(s.utf8seq===2)s.codepoint=t&31;else if(s.utf8seq===3)s.codepoint=t&15;else if(s.utf8seq===4)s.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");s.utf8seq-=1}else if(s.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");s.codepoint=s.codepoint<<6|t&63,s.utf8seq-=1,s.utf8seq===0&&r(s.codepoint)}}function O5(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};for(let a=0;as.push(r)),new Uint8Array(s)}function PN(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};return t.forEach(a=>p5e(a,r,n)),p5e(null,r,n),s.join("")}function Rpt(t){return Math.round(Date.now()/1e3)+t}function Fpt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const s=Math.random()*16|0;return(t=="x"?s:s&3|8).toString(16)})}const Ch=()=>typeof window<"u"&&typeof document<"u",Qb={tested:!1,writable:!1},Yze=()=>{if(!Ch())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Qb.tested)return Qb.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Qb.tested=!0,Qb.writable=!0}catch{Qb.tested=!0,Qb.writable=!1}return Qb.writable};function zpt(t){const s={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((a,o)=>{s[o]=a})}catch{}return r.searchParams.forEach((n,a)=>{s[a]=n}),s}const Xze=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>hh(async()=>{const{default:n}=await Promise.resolve().then(()=>aS);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},Bpt=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",j4=async(t,s,r)=>{await t.setItem(s,JSON.stringify(r))},Jb=async(t,s)=>{const r=await t.getItem(s);if(!r)return null;try{return JSON.parse(r)}catch{return r}},t1=async(t,s)=>{await t.removeItem(s)};class joe{constructor(){this.promise=new joe.promiseConstructor((s,r)=>{this.resolve=s,this.reject=r})}}joe.promiseConstructor=Promise;function Lhe(t){const s=t.split(".");if(s.length!==3)throw new Ege("Invalid JWT structure");for(let n=0;n{setTimeout(()=>s(null),t)})}function qpt(t,s){return new Promise((n,a)=>{(async()=>{for(let o=0;o<1/0;o++)try{const l=await t(o);if(!s(o,null,l)){n(l);return}}catch(l){if(!s(o,l)){a(l);return}}})()})}function Upt(t){return("0"+t.toString(16)).substr(-2)}function Vpt(){const s=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=r.length;let a="";for(let o=0;o<56;o++)a+=r.charAt(Math.floor(Math.random()*n));return a}return crypto.getRandomValues(s),Array.from(s,Upt).join("")}async function Hpt(t){const r=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",r),a=new Uint8Array(n);return Array.from(a).map(o=>String.fromCharCode(o)).join("")}async function Wpt(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const r=await Hpt(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function e4(t,s,r=!1){const n=Vpt();let a=n;r&&(a+="/PASSWORD_RECOVERY"),await j4(t,`${s}-code-verifier`,a);const o=await Wpt(n);return[o,n===o?"plain":"s256"]}const Gpt=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function Kpt(t){const s=t.headers.get(Tge);if(!s||!s.match(Gpt))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function Zpt(t){if(!t)throw new Error("Missing exp claim");const s=Math.floor(Date.now()/1e3);if(t<=s)throw new Error("JWT has expired")}function Ypt(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const Xpt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function t4(t){if(!Xpt.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function Dhe(){const t={};return new Proxy(t,{get:(s,r)=>{if(r==="__isUserNotAvailableProxy")return!0;if(typeof r=="symbol"){const n=r.toString();if(n==="Symbol(Symbol.toPrimitive)"||n==="Symbol(Symbol.toStringTag)"||n==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${r}" property of the session object is not supported. Please use getUser() instead.`)},set:(s,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(s,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function Qpt(t,s){return new Proxy(t,{get:(r,n,a)=>{if(n==="__isInsecureUserWarningProxy")return!0;if(typeof n=="symbol"){const o=n.toString();if(o==="Symbol(Symbol.toPrimitive)"||o==="Symbol(Symbol.toStringTag)"||o==="Symbol(util.inspect.custom)"||o==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(r,n,a)}return!s.value&&typeof n=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),s.value=!0),Reflect.get(r,n,a)}})}function g5e(t){return JSON.parse(JSON.stringify(t))}const yN=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Jpt=[502,503,504];async function x5e(t){var s;if(!Bpt(t))throw new Age(yN(t),0);if(Jpt.includes(t.status))throw new Age(yN(t),t.status);let r;try{r=await t.json()}catch(o){throw new kN(yN(o),o)}let n;const a=Kpt(t);if(a&&a.getTime()>=Kze["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?n=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(n=r.error_code),n){if(n==="weak_password")throw new h5e(yN(r),t.status,((s=r.weak_password)===null||s===void 0?void 0:s.reasons)||[]);if(n==="session_not_found")throw new xg}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((o,l)=>o&&typeof l=="string",!0))throw new h5e(yN(r),t.status,r.weak_password.reasons);throw new Mpt(yN(r),t.status||500,n)}const eft=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"?a:(a.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},s==null?void 0:s.headers),a.body=JSON.stringify(n),Object.assign(Object.assign({},a),r))};async function di(t,s,r,n){var a;const o=Object.assign({},n==null?void 0:n.headers);o[Tge]||(o[Tge]=Kze["2024-01-01"].name),n!=null&&n.jwt&&(o.Authorization=`Bearer ${n.jwt}`);const l=(a=n==null?void 0:n.query)!==null&&a!==void 0?a:{};n!=null&&n.redirectTo&&(l.redirect_to=n.redirectTo);const i=Object.keys(l).length?"?"+new URLSearchParams(l).toString():"",d=await tft(t,s,r+i,{headers:o,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(d):{data:Object.assign({},d),error:null}}async function tft(t,s,r,n,a,o){const l=eft(s,n,a,o);let i;try{i=await t(r,Object.assign({},l))}catch(d){throw console.error(d),new Age(yN(d),0)}if(i.ok||await x5e(i),n!=null&&n.noResolveJson)return i;try{return await i.json()}catch(d){await x5e(d)}}function yg(t){var s;let r=null;nft(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=Rpt(t.expires_in)));const n=(s=t.user)!==null&&s!==void 0?s:t;return{data:{session:r,user:n},error:null}}function y5e(t){const s=yg(t);return!s.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((r,n)=>r&&typeof n=="string",!0)&&(s.data.weak_password=t.weak_password),s}function N1(t){var s;return{data:{user:(s=t.user)!==null&&s!==void 0?s:t},error:null}}function sft(t){return{data:t,error:null}}function rft(t){const{action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o}=t,l=H_(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),i={action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o},d=Object.assign({},l);return{data:{properties:i,user:d},error:null}}function v5e(t){return t}function nft(t){return t.access_token&&t.refresh_token&&t.expires_in}const Ohe=["global","local","others"];class aft{constructor({url:s="",headers:r={},fetch:n}){this.url=s,this.headers=r,this.fetch=Xze(n),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)}}async signOut(s,r=Ohe[0]){if(Ohe.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${Ohe.join(", ")}`);try{return await di(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:s,noResolveJson:!0}),{data:null,error:null}}catch(n){if(Ma(n))return{data:null,error:n};throw n}}async inviteUserByEmail(s,r={}){try{return await di(this.fetch,"POST",`${this.url}/invite`,{body:{email:s,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:N1})}catch(n){if(Ma(n))return{data:{user:null},error:n};throw n}}async generateLink(s){try{const{options:r}=s,n=H_(s,["options"]),a=Object.assign(Object.assign({},n),r);return"newEmail"in n&&(a.new_email=n==null?void 0:n.newEmail,delete a.newEmail),await di(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:a,headers:this.headers,xform:rft,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(Ma(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(s){try{return await di(this.fetch,"POST",`${this.url}/admin/users`,{body:s,headers:this.headers,xform:N1})}catch(r){if(Ma(r))return{data:{user:null},error:r};throw r}}async listUsers(s){var r,n,a,o,l,i,d;try{const u={nextPage:null,lastPage:0,total:0},p=await di(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=s==null?void 0:s.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(o=(a=s==null?void 0:s.perPage)===null||a===void 0?void 0:a.toString())!==null&&o!==void 0?o:""},xform:v5e});if(p.error)throw p.error;const f=await p.json(),y=(l=p.headers.get("x-total-count"))!==null&&l!==void 0?l:0,_=(d=(i=p.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&d!==void 0?d:[];return _.length>0&&(_.forEach(b=>{const w=parseInt(b.split(";")[0].split("=")[1].substring(0,1)),j=JSON.parse(b.split(";")[1].split("=")[1]);u[`${j}Page`]=w}),u.total=parseInt(y)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Ma(u))return{data:{users:[]},error:u};throw u}}async getUserById(s){t4(s);try{return await di(this.fetch,"GET",`${this.url}/admin/users/${s}`,{headers:this.headers,xform:N1})}catch(r){if(Ma(r))return{data:{user:null},error:r};throw r}}async updateUserById(s,r){t4(s);try{return await di(this.fetch,"PUT",`${this.url}/admin/users/${s}`,{body:r,headers:this.headers,xform:N1})}catch(n){if(Ma(n))return{data:{user:null},error:n};throw n}}async deleteUser(s,r=!1){t4(s);try{return await di(this.fetch,"DELETE",`${this.url}/admin/users/${s}`,{headers:this.headers,body:{should_soft_delete:r},xform:N1})}catch(n){if(Ma(n))return{data:{user:null},error:n};throw n}}async _listFactors(s){t4(s.userId);try{const{data:r,error:n}=await di(this.fetch,"GET",`${this.url}/admin/users/${s.userId}/factors`,{headers:this.headers,xform:a=>({data:{factors:a},error:null})});return{data:r,error:n}}catch(r){if(Ma(r))return{data:null,error:r};throw r}}async _deleteFactor(s){t4(s.userId),t4(s.id);try{return{data:await di(this.fetch,"DELETE",`${this.url}/admin/users/${s.userId}/factors/${s.id}`,{headers:this.headers}),error:null}}catch(r){if(Ma(r))return{data:null,error:r};throw r}}async _listOAuthClients(s){var r,n,a,o,l,i,d;try{const u={nextPage:null,lastPage:0,total:0},p=await di(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=s==null?void 0:s.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(o=(a=s==null?void 0:s.perPage)===null||a===void 0?void 0:a.toString())!==null&&o!==void 0?o:""},xform:v5e});if(p.error)throw p.error;const f=await p.json(),y=(l=p.headers.get("x-total-count"))!==null&&l!==void 0?l:0,_=(d=(i=p.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&d!==void 0?d:[];return _.length>0&&(_.forEach(b=>{const w=parseInt(b.split(";")[0].split("=")[1].substring(0,1)),j=JSON.parse(b.split(";")[1].split("=")[1]);u[`${j}Page`]=w}),u.total=parseInt(y)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Ma(u))return{data:{clients:[]},error:u};throw u}}async _createOAuthClient(s){try{return await di(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:s,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ma(r))return{data:null,error:r};throw r}}async _getOAuthClient(s){try{return await di(this.fetch,"GET",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ma(r))return{data:null,error:r};throw r}}async _updateOAuthClient(s,r){try{return await di(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${s}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Ma(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(s){try{return await di(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(Ma(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(s){try{return await di(this.fetch,"POST",`${this.url}/admin/oauth/clients/${s}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ma(r))return{data:null,error:r};throw r}}}function _5e(t={}){return{getItem:s=>t[s]||null,setItem:(s,r)=>{t[s]=r},removeItem:s=>{delete t[s]}}}const s4={debug:!!(globalThis&&Yze()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class Qze extends Error{constructor(s){super(s),this.isAcquireTimeout=!0}}class ift extends Qze{}async function oft(t,s,r){s4.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,s);const n=new globalThis.AbortController;return s>0&&setTimeout(()=>{n.abort(),s4.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},s),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,s===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async a=>{if(a){s4.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,a.name);try{return await r()}finally{s4.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,a.name)}}else{if(s===0)throw s4.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new ift(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(s4.debug)try{const o=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(o,null," "))}catch(o){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",o)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await r()}}))}function lft(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}function Jze(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function cft(t){return parseInt(t,16)}function dft(t){const s=new TextEncoder().encode(t);return"0x"+Array.from(s,n=>n.toString(16).padStart(2,"0")).join("")}function uft(t){var s;const{chainId:r,domain:n,expirationTime:a,issuedAt:o=new Date,nonce:l,notBefore:i,requestId:d,resources:u,scheme:p,uri:f,version:y}=t;{if(!Number.isInteger(r))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${r}`);if(!n)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(l&&l.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${l}`);if(!f)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(y!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${y}`);if(!((s=t.statement)===null||s===void 0)&&s.includes(` `))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const _=Jze(t.address),b=p?`${p}://${n}`:n,w=t.statement?`${t.statement} `:"",j=`${b} wants you to sign in with your Ethereum account: ${_} ${w}`;let k=`URI: ${f} Version: ${y} Chain ID: ${r}${l?` Nonce: ${l}`:""} Issued At: ${o.toISOString()}`;if(a&&(k+=` Expiration Time: ${a.toISOString()}`),i&&(k+=` Not Before: ${i.toISOString()}`),d&&(k+=` Request ID: ${d}`),u){let S=` Resources:`;for(const T of u){if(!T||typeof T!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${T}`);S+=` - ${T}`}k+=S}return`${j} ${k}`}class _d extends Error{constructor({message:s,code:r,cause:n,name:a}){var o;super(s,{cause:n}),this.__isWebAuthnError=!0,this.name=(o=a??(n instanceof Error?n.name:void 0))!==null&&o!==void 0?o:"Unknown Error",this.code=r}}class xne extends _d{constructor(s,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:s}),this.name="WebAuthnUnknownError",this.originalError=r}}function hft({error:t,options:s}){var r,n,a;const{publicKey:o}=s;if(!o)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(s.signal instanceof AbortSignal)return new _d({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((r=o.authenticatorSelection)===null||r===void 0?void 0:r.requireResidentKey)===!0)return new _d({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(s.mediation==="conditional"&&((n=o.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new _d({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((a=o.authenticatorSelection)===null||a===void 0?void 0:a.userVerification)==="required")return new _d({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new _d({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new _d({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return o.pubKeyCredParams.filter(i=>i.type==="public-key").length===0?new _d({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new _d({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const l=window.location.hostname;if(e7e(l)){if(o.rp.id!==l)return new _d({message:`The RP ID "${o.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new _d({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(o.user.id.byteLength<1||o.user.id.byteLength>64)return new _d({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new _d({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new _d({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function mft({error:t,options:s}){const{publicKey:r}=s;if(!r)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(s.signal instanceof AbortSignal)return new _d({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new _d({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const n=window.location.hostname;if(e7e(n)){if(r.rpId!==n)return new _d({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new _d({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new _d({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new _d({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class pft{createNewAbortSignal(){if(this.controller){const r=new Error("Cancelling existing WebAuthn API call for new one");r.name="AbortError",this.controller.abort(r)}const s=new AbortController;return this.controller=s,s.signal}cancelCeremony(){if(this.controller){const s=new Error("Manually cancelling existing WebAuthn API call");s.name="AbortError",this.controller.abort(s),this.controller=void 0}}}const fft=new pft;function gft(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:s,user:r,excludeCredentials:n}=t,a=H_(t,["challenge","user","excludeCredentials"]),o=O5(s).buffer,l=Object.assign(Object.assign({},r),{id:O5(r.id).buffer}),i=Object.assign(Object.assign({},a),{challenge:o,user:l});if(n&&n.length>0){i.excludeCredentials=new Array(n.length);for(let d=0;d0){o.allowCredentials=new Array(r.length);for(let l=0;la!==null&&typeof a=="object"&&!Array.isArray(a),r=a=>a instanceof ArrayBuffer||ArrayBuffer.isView(a),n={};for(const a of t)if(a)for(const o in a){const l=a[o];if(l!==void 0)if(Array.isArray(l))n[o]=l;else if(r(l))n[o]=l;else if(s(l)){const i=n[o];s(i)?n[o]=yne(i,l):n[o]=yne(l)}else n[o]=l}return n}function Nft(t,s){return yne(wft,t,s||{})}function kft(t,s){return yne(jft,t,s||{})}class Sft{constructor(s){this.client=s,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(s){return this.client.mfa.enroll(Object.assign(Object.assign({},s),{factorType:"webauthn"}))}async _challenge({factorId:s,webauthn:r,friendlyName:n,signal:a},o){try{const{data:l,error:i}=await this.client.mfa.challenge({factorId:s,webauthn:r});if(!l)return{data:null,error:i};const d=a??fft.createNewAbortSignal();if(l.webauthn.type==="create"){const{user:u}=l.webauthn.credential_options.publicKey;u.name||(u.name=`${u.id}:${n}`),u.displayName||(u.displayName=u.name)}switch(l.webauthn.type){case"create":{const u=Nft(l.webauthn.credential_options.publicKey,o==null?void 0:o.create),{data:p,error:f}=await _ft({publicKey:u,signal:d});return p?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:p}},error:null}:{data:null,error:f}}case"request":{const u=kft(l.webauthn.credential_options.publicKey,o==null?void 0:o.request),{data:p,error:f}=await bft(Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:u,signal:d}));return p?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:p}},error:null}:{data:null,error:f}}}}catch(l){return Ma(l)?{data:null,error:l}:{data:null,error:new kN("Unexpected error in challenge",l)}}}async _verify({challengeId:s,factorId:r,webauthn:n}){return this.client.mfa.verify({factorId:r,challengeId:s,webauthn:n})}async _authenticate({factorId:s,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:a}},o){if(!r)return{data:null,error:new e6("rpId is required for WebAuthn authentication")};try{if(!b5e())return{data:null,error:new kN("Browser does not support WebAuthn",null)};const{data:l,error:i}=await this.challenge({factorId:s,webauthn:{rpId:r,rpOrigins:n},signal:a},{request:o});if(!l)return{data:null,error:i};const{webauthn:d}=l;return this._verify({factorId:s,challengeId:l.challengeId,webauthn:{type:d.type,rpId:r,rpOrigins:n,credential_response:d.credential_response}})}catch(l){return Ma(l)?{data:null,error:l}:{data:null,error:new kN("Unexpected error in authenticate",l)}}}async _register({friendlyName:s,rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:a},o){if(!r)return{data:null,error:new e6("rpId is required for WebAuthn registration")};try{if(!b5e())return{data:null,error:new kN("Browser does not support WebAuthn",null)};const{data:l,error:i}=await this._enroll({friendlyName:s});if(!l)return await this.client.mfa.listFactors().then(p=>{var f;return(f=p.data)===null||f===void 0?void 0:f.all.find(y=>y.factor_type==="webauthn"&&y.friendly_name===s&&y.status!=="unverified")}).then(p=>p?this.client.mfa.unenroll({factorId:p==null?void 0:p.id}):void 0),{data:null,error:i};const{data:d,error:u}=await this._challenge({factorId:l.id,friendlyName:l.friendly_name,webauthn:{rpId:r,rpOrigins:n},signal:a},{create:o});return d?this._verify({factorId:l.id,challengeId:d.challengeId,webauthn:{rpId:r,rpOrigins:n,type:d.webauthn.type,credential_response:d.webauthn.credential_response}}):{data:null,error:u}}catch(l){return Ma(l)?{data:null,error:l}:{data:null,error:new kN("Unexpected error in register",l)}}}}lft();const Cft={url:jpt,storageKey:Npt,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:kpt,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function w5e(t,s,r){return await r()}const r4={};class t6{get jwks(){var s,r;return(r=(s=r4[this.storageKey])===null||s===void 0?void 0:s.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(s){r4[this.storageKey]=Object.assign(Object.assign({},r4[this.storageKey]),{jwks:s})}get jwks_cached_at(){var s,r;return(r=(s=r4[this.storageKey])===null||s===void 0?void 0:s.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(s){r4[this.storageKey]=Object.assign(Object.assign({},r4[this.storageKey]),{cachedAt:s})}constructor(s){var r,n;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=t6.nextInstanceID,t6.nextInstanceID+=1,this.instanceID>0&&Ch()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const a=Object.assign(Object.assign({},Cft),s);if(this.logDebugMessages=!!a.debug,typeof a.debug=="function"&&(this.logger=a.debug),this.persistSession=a.persistSession,this.storageKey=a.storageKey,this.autoRefreshToken=a.autoRefreshToken,this.admin=new aft({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=Xze(a.fetch),this.lock=a.lock||w5e,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:Ch()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=oft:this.lock=w5e,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new Sft(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this)},this.persistSession?(a.storage?this.storage=a.storage:Yze()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=_5e(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=_5e(this.memoryStorage)),Ch()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(o){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",o)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async o=>{this._debug("received broadcast notification from other tab or client",o),await this._notifyAllSubscribers(o.data.event,o.data.session,!1)})}this.initialize()}_debug(...s){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${Gze}) ${new Date().toISOString()}`,...s),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var s;try{const r=zpt(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),Ch()&&this.detectSessionInUrl&&n!=="none"){const{data:a,error:o}=await this._getSessionFromURL(r,n);if(o){if(this._debug("#_initialize()","error detecting session from URL",o),Ept(o)){const d=(s=o.details)===null||s===void 0?void 0:s.code;if(d==="identity_already_exists"||d==="identity_not_found"||d==="single_identity_not_deletable")return{error:o}}return await this._removeSession(),{error:o}}const{session:l,redirectType:i}=a;return this._debug("#_initialize()","detected session in URL",l,"redirect type",i),await this._saveSession(l),setTimeout(async()=>{i==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",l):await this._notifyAllSubscribers("SIGNED_IN",l)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return Ma(r)?{error:r}:{error:new kN("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(s){var r,n,a;try{const o=await di(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(r=s==null?void 0:s.options)===null||r===void 0?void 0:r.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(a=s==null?void 0:s.options)===null||a===void 0?void 0:a.captchaToken}},xform:yg}),{data:l,error:i}=o;if(i||!l)return{data:{user:null,session:null},error:i};const d=l.session,u=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",d)),{data:{user:u,session:d},error:null}}catch(o){if(Ma(o))return{data:{user:null,session:null},error:o};throw o}}async signUp(s){var r,n,a;try{let o;if("email"in s){const{email:p,password:f,options:y}=s;let _=null,b=null;this.flowType==="pkce"&&([_,b]=await e4(this.storage,this.storageKey)),o=await di(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:y==null?void 0:y.emailRedirectTo,body:{email:p,password:f,data:(r=y==null?void 0:y.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:y==null?void 0:y.captchaToken},code_challenge:_,code_challenge_method:b},xform:yg})}else if("phone"in s){const{phone:p,password:f,options:y}=s;o=await di(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:p,password:f,data:(n=y==null?void 0:y.data)!==null&&n!==void 0?n:{},channel:(a=y==null?void 0:y.channel)!==null&&a!==void 0?a:"sms",gotrue_meta_security:{captcha_token:y==null?void 0:y.captchaToken}},xform:yg})}else throw new B8("You must provide either an email or phone number and a password");const{data:l,error:i}=o;if(i||!l)return{data:{user:null,session:null},error:i};const d=l.session,u=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",d)),{data:{user:u,session:d},error:null}}catch(o){if(Ma(o))return{data:{user:null,session:null},error:o};throw o}}async signInWithPassword(s){try{let r;if("email"in s){const{email:o,password:l,options:i}=s;r=await di(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:o,password:l,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},xform:y5e})}else if("phone"in s){const{phone:o,password:l,options:i}=s;r=await di(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:o,password:l,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},xform:y5e})}else throw new B8("You must provide either an email or phone number and a password");const{data:n,error:a}=r;return a?{data:{user:null,session:null},error:a}:!n||!n.session||!n.user?{data:{user:null,session:null},error:new JC}:(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),{data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:a})}catch(r){if(Ma(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOAuth(s){var r,n,a,o;return await this._handleProviderSignIn(s.provider,{redirectTo:(r=s.options)===null||r===void 0?void 0:r.redirectTo,scopes:(n=s.options)===null||n===void 0?void 0:n.scopes,queryParams:(a=s.options)===null||a===void 0?void 0:a.queryParams,skipBrowserRedirect:(o=s.options)===null||o===void 0?void 0:o.skipBrowserRedirect})}async exchangeCodeForSession(s){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(s))}async signInWithWeb3(s){const{chain:r}=s;switch(r){case"ethereum":return await this.signInWithEthereum(s);case"solana":return await this.signInWithSolana(s);default:throw new Error(`@supabase/auth-js: Unsupported chain "${r}"`)}}async signInWithEthereum(s){var r,n,a,o,l,i,d,u,p,f,y;let _,b;if("message"in s)_=s.message,b=s.signature;else{const{chain:w,wallet:j,statement:k,options:S}=s;let T;if(Ch())if(typeof j=="object")T=j;else{const U=window;if("ethereum"in U&&typeof U.ethereum=="object"&&"request"in U.ethereum&&typeof U.ethereum.request=="function")T=U.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof j!="object"||!(S!=null&&S.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");T=j}const I=new URL((r=S==null?void 0:S.url)!==null&&r!==void 0?r:window.location.href),L=await T.request({method:"eth_requestAccounts"}).then(U=>U).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!L||L.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const R=Jze(L[0]);let $=(n=S==null?void 0:S.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!$){const U=await T.request({method:"eth_chainId"});$=cft(U)}const q={domain:I.host,address:R,statement:k,uri:I.href,version:"1",chainId:$,nonce:(a=S==null?void 0:S.signInWithEthereum)===null||a===void 0?void 0:a.nonce,issuedAt:(l=(o=S==null?void 0:S.signInWithEthereum)===null||o===void 0?void 0:o.issuedAt)!==null&&l!==void 0?l:new Date,expirationTime:(i=S==null?void 0:S.signInWithEthereum)===null||i===void 0?void 0:i.expirationTime,notBefore:(d=S==null?void 0:S.signInWithEthereum)===null||d===void 0?void 0:d.notBefore,requestId:(u=S==null?void 0:S.signInWithEthereum)===null||u===void 0?void 0:u.requestId,resources:(p=S==null?void 0:S.signInWithEthereum)===null||p===void 0?void 0:p.resources};_=uft(q),b=await T.request({method:"personal_sign",params:[dft(_),R]})}try{const{data:w,error:j}=await di(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:_,signature:b},!((f=s.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(y=s.options)===null||y===void 0?void 0:y.captchaToken}}:null),xform:yg});if(j)throw j;return!w||!w.session||!w.user?{data:{user:null,session:null},error:new JC}:(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session)),{data:Object.assign({},w),error:j})}catch(w){if(Ma(w))return{data:{user:null,session:null},error:w};throw w}}async signInWithSolana(s){var r,n,a,o,l,i,d,u,p,f,y,_;let b,w;if("message"in s)b=s.message,w=s.signature;else{const{chain:j,wallet:k,statement:S,options:T}=s;let I;if(Ch())if(typeof k=="object")I=k;else{const R=window;if("solana"in R&&typeof R.solana=="object"&&("signIn"in R.solana&&typeof R.solana.signIn=="function"||"signMessage"in R.solana&&typeof R.solana.signMessage=="function"))I=R.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof k!="object"||!(T!=null&&T.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");I=k}const L=new URL((r=T==null?void 0:T.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in I&&I.signIn){const R=await I.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},T==null?void 0:T.signInWithSolana),{version:"1",domain:L.host,uri:L.href}),S?{statement:S}:null));let $;if(Array.isArray(R)&&R[0]&&typeof R[0]=="object")$=R[0];else if(R&&typeof R=="object"&&"signedMessage"in R&&"signature"in R)$=R;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in $&&"signature"in $&&(typeof $.signedMessage=="string"||$.signedMessage instanceof Uint8Array)&&$.signature instanceof Uint8Array)b=typeof $.signedMessage=="string"?$.signedMessage:new TextDecoder().decode($.signedMessage),w=$.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in I)||typeof I.signMessage!="function"||!("publicKey"in I)||typeof I!="object"||!I.publicKey||!("toBase58"in I.publicKey)||typeof I.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");b=[`${L.host} wants you to sign in with your Solana account:`,I.publicKey.toBase58(),...S?["",S,""]:[""],"Version: 1",`URI: ${L.href}`,`Issued At: ${(a=(n=T==null?void 0:T.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&a!==void 0?a:new Date().toISOString()}`,...!((o=T==null?void 0:T.signInWithSolana)===null||o===void 0)&&o.notBefore?[`Not Before: ${T.signInWithSolana.notBefore}`]:[],...!((l=T==null?void 0:T.signInWithSolana)===null||l===void 0)&&l.expirationTime?[`Expiration Time: ${T.signInWithSolana.expirationTime}`]:[],...!((i=T==null?void 0:T.signInWithSolana)===null||i===void 0)&&i.chainId?[`Chain ID: ${T.signInWithSolana.chainId}`]:[],...!((d=T==null?void 0:T.signInWithSolana)===null||d===void 0)&&d.nonce?[`Nonce: ${T.signInWithSolana.nonce}`]:[],...!((u=T==null?void 0:T.signInWithSolana)===null||u===void 0)&&u.requestId?[`Request ID: ${T.signInWithSolana.requestId}`]:[],...!((f=(p=T==null?void 0:T.signInWithSolana)===null||p===void 0?void 0:p.resources)===null||f===void 0)&&f.length?["Resources",...T.signInWithSolana.resources.map($=>`- ${$}`)]:[]].join(` `);const R=await I.signMessage(new TextEncoder().encode(b),"utf8");if(!R||!(R instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");w=R}}try{const{data:j,error:k}=await di(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:b,signature:PN(w)},!((y=s.options)===null||y===void 0)&&y.captchaToken?{gotrue_meta_security:{captcha_token:(_=s.options)===null||_===void 0?void 0:_.captchaToken}}:null),xform:yg});if(k)throw k;return!j||!j.session||!j.user?{data:{user:null,session:null},error:new JC}:(j.session&&(await this._saveSession(j.session),await this._notifyAllSubscribers("SIGNED_IN",j.session)),{data:Object.assign({},j),error:k})}catch(j){if(Ma(j))return{data:{user:null,session:null},error:j};throw j}}async _exchangeCodeForSession(s){const r=await Jb(this.storage,`${this.storageKey}-code-verifier`),[n,a]=(r??"").split("/");try{const{data:o,error:l}=await di(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:s,code_verifier:n},xform:yg});if(await t1(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new JC}:(o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",o.session)),{data:Object.assign(Object.assign({},o),{redirectType:a??null}),error:l})}catch(o){if(Ma(o))return{data:{user:null,session:null,redirectType:null},error:o};throw o}}async signInWithIdToken(s){try{const{options:r,provider:n,token:a,access_token:o,nonce:l}=s,i=await di(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:a,access_token:o,nonce:l,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:yg}),{data:d,error:u}=i;return u?{data:{user:null,session:null},error:u}:!d||!d.session||!d.user?{data:{user:null,session:null},error:new JC}:(d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",d.session)),{data:d,error:u})}catch(r){if(Ma(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOtp(s){var r,n,a,o,l;try{if("email"in s){const{email:i,options:d}=s;let u=null,p=null;this.flowType==="pkce"&&([u,p]=await e4(this.storage,this.storageKey));const{error:f}=await di(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:i,data:(r=d==null?void 0:d.data)!==null&&r!==void 0?r:{},create_user:(n=d==null?void 0:d.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken},code_challenge:u,code_challenge_method:p},redirectTo:d==null?void 0:d.emailRedirectTo});return{data:{user:null,session:null},error:f}}if("phone"in s){const{phone:i,options:d}=s,{data:u,error:p}=await di(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:i,data:(a=d==null?void 0:d.data)!==null&&a!==void 0?a:{},create_user:(o=d==null?void 0:d.shouldCreateUser)!==null&&o!==void 0?o:!0,gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken},channel:(l=d==null?void 0:d.channel)!==null&&l!==void 0?l:"sms"}});return{data:{user:null,session:null,messageId:u==null?void 0:u.message_id},error:p}}throw new B8("You must provide either an email or phone number.")}catch(i){if(Ma(i))return{data:{user:null,session:null},error:i};throw i}}async verifyOtp(s){var r,n;try{let a,o;"options"in s&&(a=(r=s.options)===null||r===void 0?void 0:r.redirectTo,o=(n=s.options)===null||n===void 0?void 0:n.captchaToken);const{data:l,error:i}=await di(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},s),{gotrue_meta_security:{captcha_token:o}}),redirectTo:a,xform:yg});if(i)throw i;if(!l)throw new Error("An error occurred on token verification.");const d=l.session,u=l.user;return d!=null&&d.access_token&&(await this._saveSession(d),await this._notifyAllSubscribers(s.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",d)),{data:{user:u,session:d},error:null}}catch(a){if(Ma(a))return{data:{user:null,session:null},error:a};throw a}}async signInWithSSO(s){var r,n,a;try{let o=null,l=null;return this.flowType==="pkce"&&([o,l]=await e4(this.storage,this.storageKey)),await di(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in s?{provider_id:s.providerId}:null),"domain"in s?{domain:s.domain}:null),{redirect_to:(n=(r=s.options)===null||r===void 0?void 0:r.redirectTo)!==null&&n!==void 0?n:void 0}),!((a=s==null?void 0:s.options)===null||a===void 0)&&a.captchaToken?{gotrue_meta_security:{captcha_token:s.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:o,code_challenge_method:l}),headers:this.headers,xform:sft})}catch(o){if(Ma(o))return{data:null,error:o};throw o}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;if(n)throw n;if(!r)throw new xg;const{error:a}=await di(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:a}})}catch(s){if(Ma(s))return{data:{user:null,session:null},error:s};throw s}}async resend(s){try{const r=`${this.url}/resend`;if("email"in s){const{email:n,type:a,options:o}=s,{error:l}=await di(this.fetch,"POST",r,{headers:this.headers,body:{email:n,type:a,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},redirectTo:o==null?void 0:o.emailRedirectTo});return{data:{user:null,session:null},error:l}}else if("phone"in s){const{phone:n,type:a,options:o}=s,{data:l,error:i}=await di(this.fetch,"POST",r,{headers:this.headers,body:{phone:n,type:a,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}}});return{data:{user:null,session:null,messageId:l==null?void 0:l.message_id},error:i}}throw new B8("You must provide either an email or phone number and a type")}catch(r){if(Ma(r))return{data:{user:null,session:null},error:r};throw r}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async r=>r))}async _acquireLock(s,r){this._debug("#_acquireLock","begin",s);try{if(this.lockAcquired){const n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),a=(async()=>(await n,await r()))();return this.pendingInLock.push((async()=>{try{await a}catch{}})()),a}return await this.lock(`lock:${this.storageKey}`,s,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const n=r();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){const a=[...this.pendingInLock];await Promise.all(a),this.pendingInLock.splice(0,a.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(s){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await s(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let s=null;const r=await Jb(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?s=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!s)return{data:{session:null},error:null};const n=s.expires_at?s.expires_at*1e3-Date.now()await this._getUser()))}async _getUser(s){try{return s?await di(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:s,xform:N1}):await this._useSession(async r=>{var n,a,o;const{data:l,error:i}=r;if(i)throw i;return!(!((n=l.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new xg}:await di(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(o=(a=l.session)===null||a===void 0?void 0:a.access_token)!==null&&o!==void 0?o:void 0,xform:N1})})}catch(r){if(Ma(r))return Apt(r)&&(await this._removeSession(),await t1(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:r};throw r}}async updateUser(s,r={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(s,r))}async _updateUser(s,r={}){try{return await this._useSession(async n=>{const{data:a,error:o}=n;if(o)throw o;if(!a.session)throw new xg;const l=a.session;let i=null,d=null;this.flowType==="pkce"&&s.email!=null&&([i,d]=await e4(this.storage,this.storageKey));const{data:u,error:p}=await di(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},s),{code_challenge:i,code_challenge_method:d}),jwt:l.access_token,xform:N1});if(p)throw p;return l.user=u.user,await this._saveSession(l),await this._notifyAllSubscribers("USER_UPDATED",l),{data:{user:l.user},error:null}})}catch(n){if(Ma(n))return{data:{user:null},error:n};throw n}}async setSession(s){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(s))}async _setSession(s){try{if(!s.access_token||!s.refresh_token)throw new xg;const r=Date.now()/1e3;let n=r,a=!0,o=null;const{payload:l}=Lhe(s.access_token);if(l.exp&&(n=l.exp,a=n<=r),a){const{data:i,error:d}=await this._callRefreshToken(s.refresh_token);if(d)return{data:{user:null,session:null},error:d};if(!i)return{data:{user:null,session:null},error:null};o=i}else{const{data:i,error:d}=await this._getUser(s.access_token);if(d)throw d;o={access_token:s.access_token,refresh_token:s.refresh_token,user:i.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(o),await this._notifyAllSubscribers("SIGNED_IN",o)}return{data:{user:o.user,session:o},error:null}}catch(r){if(Ma(r))return{data:{session:null,user:null},error:r};throw r}}async refreshSession(s){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(s))}async _refreshSession(s){try{return await this._useSession(async r=>{var n;if(!s){const{data:l,error:i}=r;if(i)throw i;s=(n=l.session)!==null&&n!==void 0?n:void 0}if(!(s!=null&&s.refresh_token))throw new xg;const{data:a,error:o}=await this._callRefreshToken(s.refresh_token);return o?{data:{user:null,session:null},error:o}:a?{data:{user:a.user,session:a},error:null}:{data:{user:null,session:null},error:null}})}catch(r){if(Ma(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(s,r){try{if(!Ch())throw new $8("No browser detected.");if(s.error||s.error_description||s.error_code)throw new $8(s.error_description||"Error in URL with unspecified error_description",{error:s.error||"unspecified_error",code:s.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new u5e("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new $8("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!s.code)throw new u5e("No code detected.");const{data:S,error:T}=await this._exchangeCodeForSession(s.code);if(T)throw T;const I=new URL(window.location.href);return I.searchParams.delete("code"),window.history.replaceState(window.history.state,"",I.toString()),{data:{session:S.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:a,access_token:o,refresh_token:l,expires_in:i,expires_at:d,token_type:u}=s;if(!o||!i||!l||!u)throw new $8("No session defined in URL");const p=Math.round(Date.now()/1e3),f=parseInt(i);let y=p+f;d&&(y=parseInt(d));const _=y-p;_*1e3<=w4&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${_}s, should have been closer to ${f}s`);const b=y-f;p-b>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",b,y,p):p-b<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",b,y,p);const{data:w,error:j}=await this._getUser(o);if(j)throw j;const k={provider_token:n,provider_refresh_token:a,access_token:o,expires_in:f,expires_at:y,refresh_token:l,token_type:u,user:w.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:k,redirectType:s.type},error:null}}catch(n){if(Ma(n))return{data:{session:null,redirectType:null},error:n};throw n}}_isImplicitGrantCallback(s){return!!(s.access_token||s.error_description)}async _isPKCECallback(s){const r=await Jb(this.storage,`${this.storageKey}-code-verifier`);return!!(s.code&&r)}async signOut(s={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(s))}async _signOut({scope:s}={scope:"global"}){return await this._useSession(async r=>{var n;const{data:a,error:o}=r;if(o)return{error:o};const l=(n=a.session)===null||n===void 0?void 0:n.access_token;if(l){const{error:i}=await this.admin.signOut(l,s);if(i&&!(Tpt(i)&&(i.status===404||i.status===401||i.status===403)))return{error:i}}return s!=="others"&&(await this._removeSession(),await t1(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(s){const r=Fpt(),n={id:r,callback:s,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:n}}}async _emitInitialSession(s){return await this._useSession(async r=>{var n,a;try{const{data:{session:o},error:l}=r;if(l)throw l;await((n=this.stateChangeEmitters.get(s))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",o)),this._debug("INITIAL_SESSION","callback id",s,"session",o)}catch(o){await((a=this.stateChangeEmitters.get(s))===null||a===void 0?void 0:a.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",s,"error",o),console.error(o)}})}async resetPasswordForEmail(s,r={}){let n=null,a=null;this.flowType==="pkce"&&([n,a]=await e4(this.storage,this.storageKey,!0));try{return await di(this.fetch,"POST",`${this.url}/recover`,{body:{email:s,code_challenge:n,code_challenge_method:a,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(o){if(Ma(o))return{data:null,error:o};throw o}}async getUserIdentities(){var s;try{const{data:r,error:n}=await this.getUser();if(n)throw n;return{data:{identities:(s=r.user.identities)!==null&&s!==void 0?s:[]},error:null}}catch(r){if(Ma(r))return{data:null,error:r};throw r}}async linkIdentity(s){return"token"in s?this.linkIdentityIdToken(s):this.linkIdentityOAuth(s)}async linkIdentityOAuth(s){var r;try{const{data:n,error:a}=await this._useSession(async o=>{var l,i,d,u,p;const{data:f,error:y}=o;if(y)throw y;const _=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,s.provider,{redirectTo:(l=s.options)===null||l===void 0?void 0:l.redirectTo,scopes:(i=s.options)===null||i===void 0?void 0:i.scopes,queryParams:(d=s.options)===null||d===void 0?void 0:d.queryParams,skipBrowserRedirect:!0});return await di(this.fetch,"GET",_,{headers:this.headers,jwt:(p=(u=f.session)===null||u===void 0?void 0:u.access_token)!==null&&p!==void 0?p:void 0})});if(a)throw a;return Ch()&&!(!((r=s.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),{data:{provider:s.provider,url:n==null?void 0:n.url},error:null}}catch(n){if(Ma(n))return{data:{provider:s.provider,url:null},error:n};throw n}}async linkIdentityIdToken(s){return await this._useSession(async r=>{var n;try{const{error:a,data:{session:o}}=r;if(a)throw a;const{options:l,provider:i,token:d,access_token:u,nonce:p}=s,f=await di(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(n=o==null?void 0:o.access_token)!==null&&n!==void 0?n:void 0,body:{provider:i,id_token:d,access_token:u,nonce:p,link_identity:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:yg}),{data:y,error:_}=f;return _?{data:{user:null,session:null},error:_}:!y||!y.session||!y.user?{data:{user:null,session:null},error:new JC}:(y.session&&(await this._saveSession(y.session),await this._notifyAllSubscribers("USER_UPDATED",y.session)),{data:y,error:_})}catch(a){if(Ma(a))return{data:{user:null,session:null},error:a};throw a}})}async unlinkIdentity(s){try{return await this._useSession(async r=>{var n,a;const{data:o,error:l}=r;if(l)throw l;return await di(this.fetch,"DELETE",`${this.url}/user/identities/${s.identity_id}`,{headers:this.headers,jwt:(a=(n=o.session)===null||n===void 0?void 0:n.access_token)!==null&&a!==void 0?a:void 0})})}catch(r){if(Ma(r))return{data:null,error:r};throw r}}async _refreshAccessToken(s){const r=`#_refreshAccessToken(${s.substring(0,5)}...)`;this._debug(r,"begin");try{const n=Date.now();return await qpt(async a=>(a>0&&await $pt(200*Math.pow(2,a-1)),this._debug(r,"refreshing attempt",a),await di(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:s},headers:this.headers,xform:yg})),(a,o)=>{const l=200*Math.pow(2,a);return o&&Ihe(o)&&Date.now()+l-n{try{await i.callback(s,r)}catch(d){o.push(d)}});if(await Promise.all(l),o.length>0){for(let i=0;ithis._autoRefreshTokenTick(),w4);this.autoRefreshTicker=s,s&&typeof s=="object"&&typeof s.unref=="function"?s.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(s),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const s=this.autoRefreshTicker;this.autoRefreshTicker=null,s&&clearInterval(s)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const s=Date.now();try{return await this._useSession(async r=>{const{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const a=Math.floor((n.expires_at*1e3-s)/w4);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${w4}ms, refresh threshold is ${Mge} ticks`),a<=Mge&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(s){if(s.isAcquireTimeout||s instanceof Qze)this._debug("auto refresh token tick lock not available");else throw s}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Ch()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(s){console.error("_handleVisibilityChange",s)}}async _onVisibilityChanged(s){const r=`#_onVisibilityChanged(${s})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),s||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(s,r,n){const a=[`provider=${encodeURIComponent(r)}`];if(n!=null&&n.redirectTo&&a.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&a.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){const[o,l]=await e4(this.storage,this.storageKey),i=new URLSearchParams({code_challenge:`${encodeURIComponent(o)}`,code_challenge_method:`${encodeURIComponent(l)}`});a.push(i.toString())}if(n!=null&&n.queryParams){const o=new URLSearchParams(n.queryParams);a.push(o.toString())}return n!=null&&n.skipBrowserRedirect&&a.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${s}?${a.join("&")}`}async _unenroll(s){try{return await this._useSession(async r=>{var n;const{data:a,error:o}=r;return o?{data:null,error:o}:await di(this.fetch,"DELETE",`${this.url}/factors/${s.factorId}`,{headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(Ma(r))return{data:null,error:r};throw r}}async _enroll(s){try{return await this._useSession(async r=>{var n,a;const{data:o,error:l}=r;if(l)return{data:null,error:l};const i=Object.assign({friendly_name:s.friendlyName,factor_type:s.factorType},s.factorType==="phone"?{phone:s.phone}:s.factorType==="totp"?{issuer:s.issuer}:{}),{data:d,error:u}=await di(this.fetch,"POST",`${this.url}/factors`,{body:i,headers:this.headers,jwt:(n=o==null?void 0:o.session)===null||n===void 0?void 0:n.access_token});return u?{data:null,error:u}:(s.factorType==="totp"&&d.type==="totp"&&(!((a=d==null?void 0:d.totp)===null||a===void 0)&&a.qr_code)&&(d.totp.qr_code=`data:image/svg+xml;utf-8,${d.totp.qr_code}`),{data:d,error:null})})}catch(r){if(Ma(r))return{data:null,error:r};throw r}}async _verify(s){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:a,error:o}=r;if(o)return{data:null,error:o};const l=Object.assign({challenge_id:s.challengeId},"webauthn"in s?{webauthn:Object.assign(Object.assign({},s.webauthn),{credential_response:s.webauthn.type==="create"?yft(s.webauthn.credential_response):vft(s.webauthn.credential_response)})}:{code:s.code}),{data:i,error:d}=await di(this.fetch,"POST",`${this.url}/factors/${s.factorId}/verify`,{body:l,headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});return d?{data:null,error:d}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+i.expires_in},i)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",i),{data:i,error:d})})}catch(r){if(Ma(r))return{data:null,error:r};throw r}})}async _challenge(s){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:a,error:o}=r;if(o)return{data:null,error:o};const l=await di(this.fetch,"POST",`${this.url}/factors/${s.factorId}/challenge`,{body:s,headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});if(l.error)return l;const{data:i}=l;if(i.type!=="webauthn")return{data:i,error:null};switch(i.webauthn.type){case"create":return{data:Object.assign(Object.assign({},i),{webauthn:Object.assign(Object.assign({},i.webauthn),{credential_options:Object.assign(Object.assign({},i.webauthn.credential_options),{publicKey:gft(i.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},i),{webauthn:Object.assign(Object.assign({},i.webauthn),{credential_options:Object.assign(Object.assign({},i.webauthn.credential_options),{publicKey:xft(i.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(Ma(r))return{data:null,error:r};throw r}})}async _challengeAndVerify(s){const{data:r,error:n}=await this._challenge({factorId:s.factorId});return n?{data:null,error:n}:await this._verify({factorId:s.factorId,challengeId:r.id,code:s.code})}async _listFactors(){var s;const{data:{user:r},error:n}=await this.getUser();if(n)return{data:null,error:n};const a={all:[],phone:[],totp:[],webauthn:[]};for(const o of(s=r==null?void 0:r.factors)!==null&&s!==void 0?s:[])a.all.push(o),o.status==="verified"&&a[o.factor_type].push(o);return{data:a,error:null}}async _getAuthenticatorAssuranceLevel(){var s,r;const{data:{session:n},error:a}=await this.getSession();if(a)return{data:null,error:a};if(!n)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:o}=Lhe(n.access_token);let l=null;o.aal&&(l=o.aal);let i=l;((r=(s=n.user.factors)===null||s===void 0?void 0:s.filter(p=>p.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(i="aal2");const u=o.amr||[];return{data:{currentLevel:l,nextLevel:i,currentAuthenticationMethods:u},error:null}}async _getAuthorizationDetails(s){try{return await this._useSession(async r=>{const{data:{session:n},error:a}=r;return a?{data:null,error:a}:n?await di(this.fetch,"GET",`${this.url}/oauth/authorizations/${s}`,{headers:this.headers,jwt:n.access_token,xform:o=>({data:o,error:null})}):{data:null,error:new xg}})}catch(r){if(Ma(r))return{data:null,error:r};throw r}}async _approveAuthorization(s,r){try{return await this._useSession(async n=>{const{data:{session:a},error:o}=n;if(o)return{data:null,error:o};if(!a)return{data:null,error:new xg};const l=await di(this.fetch,"POST",`${this.url}/oauth/authorizations/${s}/consent`,{headers:this.headers,jwt:a.access_token,body:{action:"approve"},xform:i=>({data:i,error:null})});return l.data&&l.data.redirect_url&&Ch()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(Ma(n))return{data:null,error:n};throw n}}async _denyAuthorization(s,r){try{return await this._useSession(async n=>{const{data:{session:a},error:o}=n;if(o)return{data:null,error:o};if(!a)return{data:null,error:new xg};const l=await di(this.fetch,"POST",`${this.url}/oauth/authorizations/${s}/consent`,{headers:this.headers,jwt:a.access_token,body:{action:"deny"},xform:i=>({data:i,error:null})});return l.data&&l.data.redirect_url&&Ch()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(Ma(n))return{data:null,error:n};throw n}}async fetchJwk(s,r={keys:[]}){let n=r.keys.find(i=>i.kid===s);if(n)return n;const a=Date.now();if(n=this.jwks.keys.find(i=>i.kid===s),n&&this.jwks_cached_at+Cpt>a)return n;const{data:o,error:l}=await di(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(l)throw l;return!o.keys||o.keys.length===0||(this.jwks=o,this.jwks_cached_at=a,n=o.keys.find(i=>i.kid===s),!n)?null:n}async getClaims(s,r={}){try{let n=s;if(!n){const{data:_,error:b}=await this.getSession();if(b||!_.session)return{data:null,error:b};n=_.session.access_token}const{header:a,payload:o,signature:l,raw:{header:i,payload:d}}=Lhe(n);r!=null&&r.allowExpired||Zpt(o.exp);const u=!a.alg||a.alg.startsWith("HS")||!a.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(a.kid,r!=null&&r.keys?{keys:r.keys}:r==null?void 0:r.jwks);if(!u){const{error:_}=await this.getUser(n);if(_)throw _;return{data:{claims:o,header:a,signature:l},error:null}}const p=Ypt(a.alg),f=await crypto.subtle.importKey("jwk",u,p,!0,["verify"]);if(!await crypto.subtle.verify(p,f,l,Opt(`${i}.${d}`)))throw new Ege("Invalid JWT signature");return{data:{claims:o,header:a,signature:l},error:null}}catch(n){if(Ma(n))return{data:null,error:n};throw n}}}t6.nextInstanceID=0;const Mft=t6;class Tft extends Mft{constructor(s){super(s)}}class Aft{constructor(s,r,n){var a,o,l;this.supabaseUrl=s,this.supabaseKey=r;const i=wpt(s);if(!r)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",i),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",i),this.storageUrl=new URL("storage/v1",i),this.functionsUrl=new URL("functions/v1",i);const d=`sb-${i.hostname.split(".")[0]}-auth-token`,u={db:ppt,realtime:gpt,auth:Object.assign(Object.assign({},fpt),{storageKey:d}),global:mpt},p=bpt(n??{},u);this.storageKey=(a=p.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(o=p.global.headers)!==null&&o!==void 0?o:{},p.accessToken?(this.accessToken=p.accessToken,this.auth=new Proxy({},{get:(f,y)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(y)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((l=p.auth)!==null&&l!==void 0?l:{},this.headers,p.global.fetch),this.fetch=vpt(r,this._getAccessToken.bind(this),p.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},p.realtime)),this.rest=new jmt(new URL("rest/v1",i).href,{headers:this.headers,schema:p.db.schema,fetch:this.fetch}),this.storage=new dpt(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),p.accessToken||this._listenForAuthEvents()}get functions(){return new fmt(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(s){return this.rest.from(s)}schema(s){return this.rest.schema(s)}rpc(s,r={},n={head:!1,get:!1,count:void 0}){return this.rest.rpc(s,r,n)}channel(s,r={config:{}}){return this.realtime.channel(s,r)}getChannels(){return this.realtime.getChannels()}removeChannel(s){return this.realtime.removeChannel(s)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var s,r;if(this.accessToken)return await this.accessToken();const{data:n}=await this.auth.getSession();return(r=(s=n.session)===null||s===void 0?void 0:s.access_token)!==null&&r!==void 0?r:this.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,userStorage:o,storageKey:l,flowType:i,lock:d,debug:u},p,f){const y={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new Tft({url:this.authUrl.href,headers:Object.assign(Object.assign({},y),p),storageKey:l,autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,userStorage:o,flowType:i,lock:d,debug:u,fetch:f,hasCustomAuthorizationHeader:Object.keys(this.headers).some(_=>_.toLowerCase()==="authorization")})}_initRealtimeClient(s){return new Bmt(this.realtimeUrl.href,Object.assign(Object.assign({},s),{params:Object.assign({apikey:this.supabaseKey},s==null?void 0:s.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((r,n)=>{this._handleTokenChanged(r,"CLIENT",n==null?void 0:n.access_token)})}_handleTokenChanged(s,r,n){(s==="TOKEN_REFRESHED"||s==="SIGNED_IN")&&this.changedAccessToken!==n?(this.changedAccessToken=n,this.realtime.setAuth(n)):s==="SIGNED_OUT"&&(this.realtime.setAuth(),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const Eft=(t,s,r)=>new Aft(t,s,r);function Pft(){if(typeof window<"u"||typeof process>"u")return!1;const t=process.version;if(t==null)return!1;const s=t.match(/^v(\d+)\./);return s?parseInt(s[1],10)<=18:!1}Pft()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const Ift="https://relzejiswnotikjgvjhz.supabase.co",Lft="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",G=Eft(Ift,Lft,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),t7e=C.createContext(void 0),Dft=({children:t})=>{const[s,r]=C.useState(null),[n,a]=C.useState(null),[o,l]=C.useState(!0),[i,d]=C.useState(!1),[u,p]=C.useState(!1),[f,y]=C.useState(null),[_,b]=C.useState([]),[w,j]=C.useState(null),k=Pr(),S=()=>{d(!1),p(!1),y(null),b([]),j(null)},T=async $=>{try{console.log("Checking roles via RPC for user:",$);const[{data:q,error:U},{data:H,error:Y}]=await Promise.all([G.rpc("has_role",{_user_id:$,_role:"admin"}),G.rpc("has_role",{_user_id:$,_role:"brokerage_manager"})]);if(U||Y)console.error("Role RPC errors:",{isAdminError:U,isBrokerError:Y}),d(!1),p(!1);else{const Q=!!q,de=!!H;console.log("RPC roles result:",{adminValue:Q,brokerValue:de}),d(Q),p(de)}const{data:se,error:te}=await G.from("profiles").select("brokerage_id").eq("id",$).single();if(y(!te&&se?se.brokerage_id:null),H){console.log("Fetching managed brokerages for user:",$);const{data:Q,error:de}=await G.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",$);if(console.log("Managed brokerage assignments result:",{assignments:Q,assignmentsError:de}),de||!Q){console.error("Error fetching managed brokerage assignments:",de),b([]);return}const re=Array.from(new Set(Q.map(be=>be.brokerage_id).filter(Boolean)));if(re.length===0){b([]);return}const{data:ae,error:le}=await G.from("brokerages").select("id, name").in("id",re);if(console.log("Managed brokerages details result:",{brokeragesData:ae,brokeragesError:le}),le||!ae){console.error("Error fetching managed brokerages details:",le),b([]);return}const he=ae.map(be=>({id:be.id,name:be.name})).sort((be,_e)=>re.indexOf(be.id)-re.indexOf(_e.id));console.log("Parsed managed brokerages:",he),b(he),he.length>0&&j(be=>be??he[0].id)}else console.log("User is not a brokerage manager, skipping managed brokerages fetch"),b([])}catch(q){console.error("Unexpected error in checkRoles:",q),S()}};C.useEffect(()=>{let $=!0,q=!1;const U=()=>{!$||q||(q=!0,l(!1))},{data:{subscription:H}}=G.auth.onAuthStateChange((te,Q)=>{console.log("Auth event:",te),$&&(a(Q),r((Q==null?void 0:Q.user)??null),U(),te==="PASSWORD_RECOVERY"&&(console.log("Password recovery detected, redirecting to profile"),setTimeout(()=>{k("/profile?reset=true")},100)),Q!=null&&Q.user?setTimeout(()=>{T(Q.user.id)},0):S())}),Y=window.setTimeout(()=>{console.warn("Auth initialization timeout reached. Continuing without blocking UI."),U()},4e3);return(async()=>{try{const{data:{session:te}}=await G.auth.getSession();if(!$)return;a(te),r((te==null?void 0:te.user)??null),te!=null&&te.user?await T(te.user.id):S()}catch(te){console.error("Error restoring auth session:",te),$&&(a(null),r(null),S())}finally{U()}})(),()=>{$=!1,window.clearTimeout(Y),H.unsubscribe()}},[]);const I=async($,q)=>{const{error:U}=await G.auth.signInWithPassword({email:$,password:q});if(U)throw fe.error(U.message),U;fe.success("Welcome back!"),k("/dashboard")},L=async($,q,U)=>{const H=`${window.location.origin}/dashboard`,{error:Y}=await G.auth.signUp({email:$,password:q,options:{emailRedirectTo:H,data:{name:U}}});if(Y)throw fe.error(Y.message),Y;fe.success("Account created! Welcome to LevelUp."),k("/dashboard")},R=async()=>{try{const{data:{session:$}}=await G.auth.getSession();if($){const{error:q}=await G.auth.signOut();q?q.message==="Auth session missing!"?console.warn("Sign out warning (ignored):",q.message):(console.error("Sign out error:",q),fe.error(q.message)):fe.success("Signed out successfully")}else console.log("No active session found, redirecting to auth");r(null),a(null),d(!1),p(!1),y(null),b([]),j(null),k("/auth")}catch($){console.error("Unexpected sign out error:",$),k("/auth")}};return e.jsx(t7e.Provider,{value:{user:s,session:n,loading:o,signIn:I,signUp:L,signOut:R,isAdmin:i,isBrokerageManager:u,brokerageId:f,managedBrokerages:_,selectedBrokerageId:w,setSelectedBrokerageId:j},children:t})},Hs=()=>{const t=C.useContext(t7e);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},s7e=C.createContext(void 0),ew="levelup_admin_session",s1="levelup_impersonation",Oft=({children:t})=>{const[s,r]=C.useState(!1),[n,a]=C.useState(null),[o,l]=C.useState(!1);C.useEffect(()=>{const u=sessionStorage.getItem(s1);if(u)try{const p=JSON.parse(u);r(!0),a(p)}catch{sessionStorage.removeItem(s1)}},[]);const i=async u=>{l(!0);try{const{data:{session:p}}=await G.auth.getSession();if(!p)return fe.error("No active session found"),!1;const f={access_token:p.access_token,refresh_token:p.refresh_token};sessionStorage.setItem(ew,JSON.stringify(f));const y=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/impersonate-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${p.access_token}`},body:JSON.stringify({targetUserId:u})}),_=await y.json();if(!y.ok)throw new Error(_.error||"Failed to impersonate user");const b={id:_.targetUser.id,name:_.targetUser.name,email:_.targetUser.email};if(sessionStorage.setItem(s1,JSON.stringify(b)),_.method==="session"){const{error:w}=await G.auth.setSession({access_token:_.access_token,refresh_token:_.refresh_token});if(w)throw console.error("Set session error:",w),sessionStorage.removeItem(ew),sessionStorage.removeItem(s1),new Error("Failed to establish impersonation session")}else{const w=_.type||"recovery",{error:j}=await G.auth.verifyOtp({token_hash:_.token_hash,type:w});if(j)throw console.error("Verify OTP error:",j),sessionStorage.removeItem(ew),sessionStorage.removeItem(s1),new Error("Failed to establish impersonation session")}return r(!0),a(b),fe.success(`Now viewing as ${b.name}`),window.location.href="/dashboard",!0}catch(p){return console.error("Impersonation error:",p),fe.error(p.message||"Failed to impersonate user"),sessionStorage.removeItem(ew),sessionStorage.removeItem(s1),!1}finally{l(!1)}},d=async()=>{l(!0);try{const u=sessionStorage.getItem(ew);if(!u){await G.auth.signOut(),window.location.href="/auth";return}const p=JSON.parse(u);await G.auth.signOut();const{error:f}=await G.auth.setSession({access_token:p.access_token,refresh_token:p.refresh_token});if(sessionStorage.removeItem(ew),sessionStorage.removeItem(s1),f){console.error("Failed to restore admin session:",f),fe.error("Admin session expired, please sign in again"),window.location.href="/auth";return}r(!1),a(null),fe.success("Returned to admin account"),window.location.href="/admin/members"}catch(u){console.error("Stop impersonation error:",u),fe.error("Failed to restore admin session"),sessionStorage.removeItem(ew),sessionStorage.removeItem(s1),window.location.href="/auth"}finally{l(!1)}};return e.jsx(s7e.Provider,{value:{isImpersonating:s,impersonatedUser:n,startImpersonation:i,stopImpersonation:d,isLoading:o},children:t})},B1e=()=>{const t=C.useContext(s7e);if(t===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return t},s6=nS("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-full px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),K=C.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...a},o)=>{const l=n?n1e:"button";return e.jsx(l,{className:Pt(s6({variant:s,size:r,className:t})),ref:o,...a})});K.displayName="Button";const Rft=()=>{const{isImpersonating:t,impersonatedUser:s,stopImpersonation:r,isLoading:n}=B1e();return!t||!s?null:e.jsx("div",{className:"fixed top-0 left-0 right-0 z-[100] bg-amber-500 text-amber-950 px-4 py-2 shadow-lg",children:e.jsxs("div",{className:"container mx-auto flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ju,{className:"h-5 w-5 flex-shrink-0"}),e.jsxs("span",{className:"font-medium text-sm md:text-base",children:[e.jsx("span",{className:"hidden sm:inline",children:"You are viewing as "}),e.jsx("strong",{children:s.name}),e.jsxs("span",{className:"hidden md:inline text-amber-800",children:[" (",s.email,")"]})]})]}),e.jsx(K,{size:"sm",variant:"secondary",onClick:r,disabled:n,className:"bg-amber-100 hover:bg-amber-200 text-amber-950 border-0",children:n?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Ur,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Exit Impersonation"}),e.jsx("span",{className:"sm:hidden",children:"Exit"})]})})]})})},r7e=C.createContext(void 0),n4="levelup_acting_as",q8="levelup_acting_as_self",Fft=({children:t})=>{const{user:s}=Hs(),[r,n]=C.useState(!1),[a,o]=C.useState([]),[l,i]=C.useState(null),[d,u]=C.useState({}),[p,f]=C.useState(!0),[y,_]=C.useState(()=>sessionStorage.getItem(q8)==="true");C.useEffect(()=>{if(!(s!=null&&s.id)){n(!1),o([]),i(null),u({}),f(!1);return}(async()=>{f(!0);try{const{data:T}=await G.rpc("has_role",{_user_id:s.id,_role:"assistant"});if(!T){n(!1),o([]),i(null),u({}),f(!1);return}n(!0);const{data:I,error:L}=await G.from("agent_assistant_assignments").select("agent_id, permissions").eq("assistant_id",s.id);if(L||!I||I.length===0){o([]),f(!1);return}const R=I.map(U=>U.agent_id),{data:$}=await G.from("profiles").select("id, name, email, avatar_url").in("id",R),q=($||[]).map(U=>({id:U.id,name:U.name||U.email||"Unknown",email:U.email||"",avatar_url:U.avatar_url}));if(o(q),sessionStorage.getItem(q8)==="true")_(!0),i(null),u({});else{const U=sessionStorage.getItem(n4);if(U){const H=q.find(Y=>Y.id===U);if(H){i(H);const Y=I.find(se=>se.agent_id===U);u((Y==null?void 0:Y.permissions)||{})}else if(q.length>0){i(q[0]);const Y=I.find(se=>se.agent_id===q[0].id);u((Y==null?void 0:Y.permissions)||{}),sessionStorage.setItem(n4,q[0].id)}}else if(q.length>0){i(q[0]);const H=I.find(Y=>Y.agent_id===q[0].id);u((H==null?void 0:H.permissions)||{}),sessionStorage.setItem(n4,q[0].id)}}}catch(T){console.error("Error loading assistant data:",T)}finally{f(!1)}})()},[s==null?void 0:s.id]);const b=S=>{i(S),_(!1),sessionStorage.removeItem(q8),S?(sessionStorage.setItem(n4,S.id),G.from("agent_assistant_assignments").select("permissions").eq("assistant_id",(s==null?void 0:s.id)||"").eq("agent_id",S.id).single().then(({data:T})=>{u((T==null?void 0:T.permissions)||{})})):(sessionStorage.removeItem(n4),u({}))},w=()=>{_(!0),i(null),u({}),sessionStorage.setItem(q8,"true"),sessionStorage.removeItem(n4)},j=S=>!r||y?!0:d[S]===!0,k=r&&l&&!y?l.id:(s==null?void 0:s.id)||null;return e.jsx(r7e.Provider,{value:{isAssistant:r,assignedAgents:a,actingAsAgent:l,setActingAsAgent:b,effectiveUserId:k,permissions:d,hasPermission:j,isLoading:p,isActingAsSelf:y,setActingAsSelf:w},children:t})},$1e=()=>{const t=C.useContext(r7e);if(t===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return t},Ya=()=>{const{effectiveUserId:t}=$1e();return t};var n7e={exports:{}},a7e={};/** * @license React * use-sync-external-store-shim.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var v3=C;function zft(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Bft=typeof Object.is=="function"?Object.is:zft,$ft=v3.useState,qft=v3.useEffect,Uft=v3.useLayoutEffect,Vft=v3.useDebugValue;function Hft(t,s){var r=s(),n=$ft({inst:{value:r,getSnapshot:s}}),a=n[0].inst,o=n[1];return Uft(function(){a.value=r,a.getSnapshot=s,Rhe(a)&&o({inst:a})},[t,r,s]),qft(function(){return Rhe(a)&&o({inst:a}),t(function(){Rhe(a)&&o({inst:a})})},[t]),Vft(r),r}function Rhe(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!Bft(t,r)}catch{return!0}}function Wft(t,s){return s()}var Gft=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Wft:Hft;a7e.useSyncExternalStore=v3.useSyncExternalStore!==void 0?v3.useSyncExternalStore:Gft;n7e.exports=a7e;var Kft=n7e.exports;function Zft(){return Kft.useSyncExternalStore(Yft,()=>!0,()=>!1)}function Yft(){return()=>{}}var q1e="Avatar",[Xft]=Ec(q1e),[Qft,i7e]=Xft(q1e),o7e=C.forwardRef((t,s)=>{const{__scopeAvatar:r,...n}=t,[a,o]=C.useState("idle");return e.jsx(Qft,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:o,children:e.jsx(Qr.span,{...n,ref:s})})});o7e.displayName=q1e;var l7e="AvatarImage",c7e=C.forwardRef((t,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...o}=t,l=i7e(l7e,r),i=Jft(n,o),d=Vc(u=>{a(u),l.onImageLoadingStatusChange(u)});return Zc(()=>{i!=="idle"&&d(i)},[i,d]),i==="loaded"?e.jsx(Qr.img,{...o,ref:s,src:n}):null});c7e.displayName=l7e;var d7e="AvatarFallback",u7e=C.forwardRef((t,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=t,o=i7e(d7e,r),[l,i]=C.useState(n===void 0);return C.useEffect(()=>{if(n!==void 0){const d=window.setTimeout(()=>i(!0),n);return()=>window.clearTimeout(d)}},[n]),l&&o.imageLoadingStatus!=="loaded"?e.jsx(Qr.span,{...a,ref:s}):null});u7e.displayName=d7e;function j5e(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Jft(t,{referrerPolicy:s,crossOrigin:r}){const n=Zft(),a=C.useRef(null),o=n?(a.current||(a.current=new window.Image),a.current):null,[l,i]=C.useState(()=>j5e(o,t));return Zc(()=>{i(j5e(o,t))},[o,t]),Zc(()=>{const d=f=>()=>{i(f)};if(!o)return;const u=d("loaded"),p=d("error");return o.addEventListener("load",u),o.addEventListener("error",p),s&&(o.referrerPolicy=s),typeof r=="string"&&(o.crossOrigin=r),()=>{o.removeEventListener("load",u),o.removeEventListener("error",p)}},[o,r,s]),l}var h7e=o7e,m7e=c7e,p7e=u7e;const xn=C.forwardRef(({className:t,...s},r)=>e.jsx(h7e,{ref:r,className:Pt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...s}));xn.displayName=h7e.displayName;const Aa=C.forwardRef(({className:t,...s},r)=>e.jsx(m7e,{ref:r,className:Pt("aspect-square h-full w-full",t),...s}));Aa.displayName=m7e.displayName;const yn=C.forwardRef(({className:t,...s},r)=>e.jsx(p7e,{ref:r,className:Pt("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...s}));yn.displayName=p7e.displayName;const egt=nS("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function rt({className:t,variant:s,...r}){return e.jsx("div",{className:Pt(egt({variant:s}),t),...r})}var tgt=C.createContext(void 0);function G_(t){const s=C.useContext(tgt);return t||s||"ltr"}var Fhe=0;function Noe(){C.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??N5e()),document.body.insertAdjacentElement("beforeend",t[1]??N5e()),Fhe++,()=>{Fhe===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),Fhe--}},[])}function N5e(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var zhe="focusScope.autoFocusOnMount",Bhe="focusScope.autoFocusOnUnmount",k5e={bubbles:!1,cancelable:!0},sgt="FocusScope",CL=C.forwardRef((t,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[i,d]=C.useState(null),u=Vc(a),p=Vc(o),f=C.useRef(null),y=Ea(s,w=>d(w)),_=C.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;C.useEffect(()=>{if(n){let w=function(T){if(_.paused||!i)return;const I=T.target;i.contains(I)?f.current=I:o1(f.current,{select:!0})},j=function(T){if(_.paused||!i)return;const I=T.relatedTarget;I!==null&&(i.contains(I)||o1(f.current,{select:!0}))},k=function(T){if(document.activeElement===document.body)for(const L of T)L.removedNodes.length>0&&o1(i)};document.addEventListener("focusin",w),document.addEventListener("focusout",j);const S=new MutationObserver(k);return i&&S.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",j),S.disconnect()}}},[n,i,_.paused]),C.useEffect(()=>{if(i){C5e.add(_);const w=document.activeElement;if(!i.contains(w)){const k=new CustomEvent(zhe,k5e);i.addEventListener(zhe,u),i.dispatchEvent(k),k.defaultPrevented||(rgt(lgt(f7e(i)),{select:!0}),document.activeElement===w&&o1(i))}return()=>{i.removeEventListener(zhe,u),setTimeout(()=>{const k=new CustomEvent(Bhe,k5e);i.addEventListener(Bhe,p),i.dispatchEvent(k),k.defaultPrevented||o1(w??document.body,{select:!0}),i.removeEventListener(Bhe,p),C5e.remove(_)},0)}}},[i,u,p,_]);const b=C.useCallback(w=>{if(!r&&!n||_.paused)return;const j=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,k=document.activeElement;if(j&&k){const S=w.currentTarget,[T,I]=ngt(S);T&&I?!w.shiftKey&&k===I?(w.preventDefault(),r&&o1(T,{select:!0})):w.shiftKey&&k===T&&(w.preventDefault(),r&&o1(I,{select:!0})):k===S&&w.preventDefault()}},[r,n,_.paused]);return e.jsx(Qr.div,{tabIndex:-1,...l,ref:y,onKeyDown:b})});CL.displayName=sgt;function rgt(t,{select:s=!1}={}){const r=document.activeElement;for(const n of t)if(o1(n,{select:s}),document.activeElement!==r)return}function ngt(t){const s=f7e(t),r=S5e(s,t),n=S5e(s.reverse(),t);return[r,n]}function f7e(t){const s=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)s.push(r.currentNode);return s}function S5e(t,s){for(const r of t)if(!agt(r,{upTo:s}))return r}function agt(t,{upTo:s}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(s!==void 0&&t===s)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function igt(t){return t instanceof HTMLInputElement&&"select"in t}function o1(t,{select:s=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&igt(t)&&s&&t.select()}}var C5e=ogt();function ogt(){let t=[];return{add(s){const r=t[0];s!==r&&(r==null||r.pause()),t=M5e(t,s),t.unshift(s)},remove(s){var r;t=M5e(t,s),(r=t[0])==null||r.resume()}}}function M5e(t,s){const r=[...t],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function lgt(t){return t.filter(s=>s.tagName!=="A")}var $he="rovingFocusGroup.onEntryFocus",cgt={bubbles:!1,cancelable:!0},ML="RovingFocusGroup",[Pge,g7e,dgt]=vL(ML),[ugt,K_]=Ec(ML,[dgt]),[hgt,mgt]=ugt(ML),x7e=C.forwardRef((t,s)=>e.jsx(Pge.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Pge.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(pgt,{...t,ref:s})})}));x7e.displayName=ML;var pgt=C.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:p=!1,...f}=t,y=C.useRef(null),_=Ea(s,y),b=G_(o),[w,j]=vu({prop:l,defaultProp:i??null,onChange:d,caller:ML}),[k,S]=C.useState(!1),T=Vc(u),I=g7e(r),L=C.useRef(!1),[R,$]=C.useState(0);return C.useEffect(()=>{const q=y.current;if(q)return q.addEventListener($he,T),()=>q.removeEventListener($he,T)},[T]),e.jsx(hgt,{scope:r,orientation:n,dir:b,loop:a,currentTabStopId:w,onItemFocus:C.useCallback(q=>j(q),[j]),onItemShiftTab:C.useCallback(()=>S(!0),[]),onFocusableItemAdd:C.useCallback(()=>$(q=>q+1),[]),onFocusableItemRemove:C.useCallback(()=>$(q=>q-1),[]),children:e.jsx(Qr.div,{tabIndex:k||R===0?-1:0,"data-orientation":n,...f,ref:_,style:{outline:"none",...t.style},onMouseDown:Mr(t.onMouseDown,()=>{L.current=!0}),onFocus:Mr(t.onFocus,q=>{const U=!L.current;if(q.target===q.currentTarget&&U&&!k){const H=new CustomEvent($he,cgt);if(q.currentTarget.dispatchEvent(H),!H.defaultPrevented){const Y=I().filter(re=>re.focusable),se=Y.find(re=>re.active),te=Y.find(re=>re.id===w),de=[se,te,...Y].filter(Boolean).map(re=>re.ref.current);_7e(de,p)}}L.current=!1}),onBlur:Mr(t.onBlur,()=>S(!1))})})}),y7e="RovingFocusGroupItem",v7e=C.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:o,children:l,...i}=t,d=Gd(),u=o||d,p=mgt(y7e,r),f=p.currentTabStopId===u,y=g7e(r),{onFocusableItemAdd:_,onFocusableItemRemove:b,currentTabStopId:w}=p;return C.useEffect(()=>{if(n)return _(),()=>b()},[n,_,b]),e.jsx(Pge.ItemSlot,{scope:r,id:u,focusable:n,active:a,children:e.jsx(Qr.span,{tabIndex:f?0:-1,"data-orientation":p.orientation,...i,ref:s,onMouseDown:Mr(t.onMouseDown,j=>{n?p.onItemFocus(u):j.preventDefault()}),onFocus:Mr(t.onFocus,()=>p.onItemFocus(u)),onKeyDown:Mr(t.onKeyDown,j=>{if(j.key==="Tab"&&j.shiftKey){p.onItemShiftTab();return}if(j.target!==j.currentTarget)return;const k=xgt(j,p.orientation,p.dir);if(k!==void 0){if(j.metaKey||j.ctrlKey||j.altKey||j.shiftKey)return;j.preventDefault();let T=y().filter(I=>I.focusable).map(I=>I.ref.current);if(k==="last")T.reverse();else if(k==="prev"||k==="next"){k==="prev"&&T.reverse();const I=T.indexOf(j.currentTarget);T=p.loop?ygt(T,I+1):T.slice(I+1)}setTimeout(()=>_7e(T))}}),children:typeof l=="function"?l({isCurrentTabStop:f,hasTabStop:w!=null}):l})})});v7e.displayName=y7e;var fgt={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ggt(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function xgt(t,s,r){const n=ggt(t.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return fgt[n]}function _7e(t,s=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function ygt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var koe=x7e,Soe=v7e,vgt=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},a4=new WeakMap,U8=new WeakMap,V8={},qhe=0,b7e=function(t){return t&&(t.host||b7e(t.parentNode))},_gt=function(t,s){return s.map(function(r){if(t.contains(r))return r;var n=b7e(r);return n&&t.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",t,". Doing nothing"),null)}).filter(function(r){return!!r})},bgt=function(t,s,r,n){var a=_gt(s,Array.isArray(t)?t:[t]);V8[r]||(V8[r]=new WeakMap);var o=V8[r],l=[],i=new Set,d=new Set(a),u=function(f){!f||i.has(f)||(i.add(f),u(f.parentNode))};a.forEach(u);var p=function(f){!f||d.has(f)||Array.prototype.forEach.call(f.children,function(y){if(i.has(y))p(y);else try{var _=y.getAttribute(n),b=_!==null&&_!=="false",w=(a4.get(y)||0)+1,j=(o.get(y)||0)+1;a4.set(y,w),o.set(y,j),l.push(y),w===1&&b&&U8.set(y,!0),j===1&&y.setAttribute(r,"true"),b||y.setAttribute(n,"true")}catch(k){console.error("aria-hidden: cannot operate on ",y,k)}})};return p(s),i.clear(),qhe++,function(){l.forEach(function(f){var y=a4.get(f)-1,_=o.get(f)-1;a4.set(f,y),o.set(f,_),y||(U8.has(f)||f.removeAttribute(n),U8.delete(f)),_||f.removeAttribute(r)}),qhe--,qhe||(a4=new WeakMap,a4=new WeakMap,U8=new WeakMap,V8={})}},Coe=function(t,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),a=vgt(t);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),bgt(n,a,r,"aria-hidden")):function(){return null}},hre="right-scroll-bar-position",mre="width-before-scroll-bar",wgt="with-scroll-bars-hidden",jgt="--removed-body-scroll-bar-size";function Uhe(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function Ngt(t,s){var r=C.useState(function(){return{value:t,callback:s,facade:{get current(){return r.value},set current(n){var a=r.value;a!==n&&(r.value=n,r.callback(n,a))}}}})[0];return r.callback=s,r.facade}var kgt=typeof window<"u"?C.useLayoutEffect:C.useEffect,T5e=new WeakMap;function Sgt(t,s){var r=Ngt(null,function(n){return t.forEach(function(a){return Uhe(a,n)})});return kgt(function(){var n=T5e.get(r);if(n){var a=new Set(n),o=new Set(t),l=r.current;a.forEach(function(i){o.has(i)||Uhe(i,null)}),o.forEach(function(i){a.has(i)||Uhe(i,l)})}T5e.set(r,t)},[t]),r}function Cgt(t){return t}function Mgt(t,s){s===void 0&&(s=Cgt);var r=[],n=!1,a={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:t},useMedium:function(o){var l=s(o,n);return r.push(l),function(){r=r.filter(function(i){return i!==l})}},assignSyncMedium:function(o){for(n=!0;r.length;){var l=r;r=[],l.forEach(o)}r={push:function(i){return o(i)},filter:function(){return r}}},assignMedium:function(o){n=!0;var l=[];if(r.length){var i=r;r=[],i.forEach(o),l=r}var d=function(){var p=l;l=[],p.forEach(o)},u=function(){return Promise.resolve().then(d)};u(),r={push:function(p){l.push(p),u()},filter:function(p){return l=l.filter(p),r}}}};return a}function Tgt(t){t===void 0&&(t={});var s=Mgt(null);return s.options=lf({async:!0,ssr:!1},t),s}var w7e=function(t){var s=t.sideCar,r=H_(t,["sideCar"]);if(!s)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=s.read();if(!n)throw new Error("Sidecar medium not found");return C.createElement(n,lf({},r))};w7e.isSideCarExport=!0;function Agt(t,s){return t.useMedium(s),w7e}var j7e=Tgt(),Vhe=function(){},Moe=C.forwardRef(function(t,s){var r=C.useRef(null),n=C.useState({onScrollCapture:Vhe,onWheelCapture:Vhe,onTouchMoveCapture:Vhe}),a=n[0],o=n[1],l=t.forwardProps,i=t.children,d=t.className,u=t.removeScrollBar,p=t.enabled,f=t.shards,y=t.sideCar,_=t.noRelative,b=t.noIsolation,w=t.inert,j=t.allowPinchZoom,k=t.as,S=k===void 0?"div":k,T=t.gapMode,I=H_(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),L=y,R=Sgt([r,s]),$=lf(lf({},I),a);return C.createElement(C.Fragment,null,p&&C.createElement(L,{sideCar:j7e,removeScrollBar:u,shards:f,noRelative:_,noIsolation:b,inert:w,setCallbacks:o,allowPinchZoom:!!j,lockRef:r,gapMode:T}),l?C.cloneElement(C.Children.only(i),lf(lf({},$),{ref:R})):C.createElement(S,lf({},$,{className:d,ref:R}),i))});Moe.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Moe.classNames={fullWidth:mre,zeroRight:hre};var Egt=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Pgt(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=Egt();return s&&t.setAttribute("nonce",s),t}function Igt(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function Lgt(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var Dgt=function(){var t=0,s=null;return{add:function(r){t==0&&(s=Pgt())&&(Igt(s,r),Lgt(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},Ogt=function(){var t=Dgt();return function(s,r){C.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&r])}},N7e=function(){var t=Ogt(),s=function(r){var n=r.styles,a=r.dynamic;return t(n,a),null};return s},Rgt={left:0,top:0,right:0,gap:0},Hhe=function(t){return parseInt(t||"",10)||0},Fgt=function(t){var s=window.getComputedStyle(document.body),r=s[t==="padding"?"paddingLeft":"marginLeft"],n=s[t==="padding"?"paddingTop":"marginTop"],a=s[t==="padding"?"paddingRight":"marginRight"];return[Hhe(r),Hhe(n),Hhe(a)]},zgt=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Rgt;var s=Fgt(t),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:s[0],top:s[1],right:s[2],gap:Math.max(0,n-r+s[2]-s[0])}},Bgt=N7e(),R5="data-scroll-locked",$gt=function(t,s,r,n){var a=t.left,o=t.top,l=t.right,i=t.gap;return r===void 0&&(r="margin"),` .`.concat(wgt,` { overflow: hidden `).concat(n,`; padding-right: `).concat(i,"px ").concat(n,`; } body[`).concat(R5,`] { overflow: hidden `).concat(n,`; overscroll-behavior: contain; `).concat([s&&"position: relative ".concat(n,";"),r==="margin"&&` padding-left: `.concat(a,`px; padding-top: `).concat(o,`px; padding-right: `).concat(l,`px; margin-left:0; margin-top:0; margin-right: `).concat(i,"px ").concat(n,`; `),r==="padding"&&"padding-right: ".concat(i,"px ").concat(n,";")].filter(Boolean).join(""),` } .`).concat(hre,` { right: `).concat(i,"px ").concat(n,`; } .`).concat(mre,` { margin-right: `).concat(i,"px ").concat(n,`; } .`).concat(hre," .").concat(hre,` { right: 0 `).concat(n,`; } .`).concat(mre," .").concat(mre,` { margin-right: 0 `).concat(n,`; } body[`).concat(R5,`] { `).concat(jgt,": ").concat(i,`px; } `)},A5e=function(){var t=parseInt(document.body.getAttribute(R5)||"0",10);return isFinite(t)?t:0},qgt=function(){C.useEffect(function(){return document.body.setAttribute(R5,(A5e()+1).toString()),function(){var t=A5e()-1;t<=0?document.body.removeAttribute(R5):document.body.setAttribute(R5,t.toString())}},[])},Ugt=function(t){var s=t.noRelative,r=t.noImportant,n=t.gapMode,a=n===void 0?"margin":n;qgt();var o=C.useMemo(function(){return zgt(a)},[a]);return C.createElement(Bgt,{styles:$gt(o,!s,a,r?"":"!important")})},Ige=!1;if(typeof window<"u")try{var H8=Object.defineProperty({},"passive",{get:function(){return Ige=!0,!0}});window.addEventListener("test",H8,H8),window.removeEventListener("test",H8,H8)}catch{Ige=!1}var i4=Ige?{passive:!1}:!1,Vgt=function(t){return t.tagName==="TEXTAREA"},k7e=function(t,s){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!Vgt(t)&&r[s]==="visible")},Hgt=function(t){return k7e(t,"overflowY")},Wgt=function(t){return k7e(t,"overflowX")},E5e=function(t,s){var r=s.ownerDocument,n=s;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=S7e(t,n);if(a){var o=C7e(t,n),l=o[1],i=o[2];if(l>i)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},Ggt=function(t){var s=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[s,r,n]},Kgt=function(t){var s=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[s,r,n]},S7e=function(t,s){return t==="v"?Hgt(s):Wgt(s)},C7e=function(t,s){return t==="v"?Ggt(s):Kgt(s)},Zgt=function(t,s){return t==="h"&&s==="rtl"?-1:1},Ygt=function(t,s,r,n,a){var o=Zgt(t,window.getComputedStyle(s).direction),l=o*n,i=r.target,d=s.contains(i),u=!1,p=l>0,f=0,y=0;do{if(!i)break;var _=C7e(t,i),b=_[0],w=_[1],j=_[2],k=w-j-o*b;(b||k)&&S7e(t,i)&&(f+=k,y+=b);var S=i.parentNode;i=S&&S.nodeType===Node.DOCUMENT_FRAGMENT_NODE?S.host:S}while(!d&&i!==document.body||d&&(s.contains(i)||s===i));return(p&&Math.abs(f)<1||!p&&Math.abs(y)<1)&&(u=!0),u},W8=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},P5e=function(t){return[t.deltaX,t.deltaY]},I5e=function(t){return t&&"current"in t?t.current:t},Xgt=function(t,s){return t[0]===s[0]&&t[1]===s[1]},Qgt=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},Jgt=0,o4=[];function ext(t){var s=C.useRef([]),r=C.useRef([0,0]),n=C.useRef(),a=C.useState(Jgt++)[0],o=C.useState(N7e)[0],l=C.useRef(t);C.useEffect(function(){l.current=t},[t]),C.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var w=E1e([t.lockRef.current],(t.shards||[]).map(I5e),!0).filter(Boolean);return w.forEach(function(j){return j.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),w.forEach(function(j){return j.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var i=C.useCallback(function(w,j){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!l.current.allowPinchZoom;var k=W8(w),S=r.current,T="deltaX"in w?w.deltaX:S[0]-k[0],I="deltaY"in w?w.deltaY:S[1]-k[1],L,R=w.target,$=Math.abs(T)>Math.abs(I)?"h":"v";if("touches"in w&&$==="h"&&R.type==="range")return!1;var q=E5e($,R);if(!q)return!0;if(q?L=$:(L=$==="v"?"h":"v",q=E5e($,R)),!q)return!1;if(!n.current&&"changedTouches"in w&&(T||I)&&(n.current=L),!L)return!0;var U=n.current||L;return Ygt(U,j,w,U==="h"?T:I)},[]),d=C.useCallback(function(w){var j=w;if(!(!o4.length||o4[o4.length-1]!==o)){var k="deltaY"in j?P5e(j):W8(j),S=s.current.filter(function(L){return L.name===j.type&&(L.target===j.target||j.target===L.shadowParent)&&Xgt(L.delta,k)})[0];if(S&&S.should){j.cancelable&&j.preventDefault();return}if(!S){var T=(l.current.shards||[]).map(I5e).filter(Boolean).filter(function(L){return L.contains(j.target)}),I=T.length>0?i(j,T[0]):!l.current.noIsolation;I&&j.cancelable&&j.preventDefault()}}},[]),u=C.useCallback(function(w,j,k,S){var T={name:w,delta:j,target:k,should:S,shadowParent:txt(k)};s.current.push(T),setTimeout(function(){s.current=s.current.filter(function(I){return I!==T})},1)},[]),p=C.useCallback(function(w){r.current=W8(w),n.current=void 0},[]),f=C.useCallback(function(w){u(w.type,P5e(w),w.target,i(w,t.lockRef.current))},[]),y=C.useCallback(function(w){u(w.type,W8(w),w.target,i(w,t.lockRef.current))},[]);C.useEffect(function(){return o4.push(o),t.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:y}),document.addEventListener("wheel",d,i4),document.addEventListener("touchmove",d,i4),document.addEventListener("touchstart",p,i4),function(){o4=o4.filter(function(w){return w!==o}),document.removeEventListener("wheel",d,i4),document.removeEventListener("touchmove",d,i4),document.removeEventListener("touchstart",p,i4)}},[]);var _=t.removeScrollBar,b=t.inert;return C.createElement(C.Fragment,null,b?C.createElement(o,{styles:Qgt(a)}):null,_?C.createElement(Ugt,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function txt(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const sxt=Agt(j7e,ext);var TL=C.forwardRef(function(t,s){return C.createElement(Moe,lf({},t,{ref:s,sideCar:sxt}))});TL.classNames=Moe.classNames;var Lge=["Enter"," "],rxt=["ArrowDown","PageUp","Home"],M7e=["ArrowUp","PageDown","End"],nxt=[...rxt,...M7e],axt={ltr:[...Lge,"ArrowRight"],rtl:[...Lge,"ArrowLeft"]},ixt={ltr:["ArrowLeft"],rtl:["ArrowRight"]},AL="Menu",[r6,oxt,lxt]=vL(AL),[iS,T7e]=Ec(AL,[lxt,xy,K_]),Toe=xy(),A7e=K_(),[cxt,oS]=iS(AL),[dxt,EL]=iS(AL),E7e=t=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:o,modal:l=!0}=t,i=Toe(s),[d,u]=C.useState(null),p=C.useRef(!1),f=Vc(o),y=G_(a);return C.useEffect(()=>{const _=()=>{p.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>p.current=!1;return document.addEventListener("keydown",_,{capture:!0}),()=>{document.removeEventListener("keydown",_,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),e.jsx(jL,{...i,children:e.jsx(cxt,{scope:s,open:r,onOpenChange:f,content:d,onContentChange:u,children:e.jsx(dxt,{scope:s,onClose:C.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:p,dir:y,modal:l,children:n})})})};E7e.displayName=AL;var uxt="MenuAnchor",U1e=C.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=Toe(r);return e.jsx(gM,{...a,...n,ref:s})});U1e.displayName=uxt;var V1e="MenuPortal",[hxt,P7e]=iS(V1e,{forceMount:void 0}),I7e=t=>{const{__scopeMenu:s,forceMount:r,children:n,container:a}=t,o=oS(V1e,s);return e.jsx(hxt,{scope:s,forceMount:r,children:e.jsx(ud,{present:r||o.open,children:e.jsx(hM,{asChild:!0,container:a,children:n})})})};I7e.displayName=V1e;var vf="MenuContent",[mxt,H1e]=iS(vf),L7e=C.forwardRef((t,s)=>{const r=P7e(vf,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=oS(vf,t.__scopeMenu),l=EL(vf,t.__scopeMenu);return e.jsx(r6.Provider,{scope:t.__scopeMenu,children:e.jsx(ud,{present:n||o.open,children:e.jsx(r6.Slot,{scope:t.__scopeMenu,children:l.modal?e.jsx(pxt,{...a,ref:s}):e.jsx(fxt,{...a,ref:s})})})})}),pxt=C.forwardRef((t,s)=>{const r=oS(vf,t.__scopeMenu),n=C.useRef(null),a=Ea(s,n);return C.useEffect(()=>{const o=n.current;if(o)return Coe(o)},[]),e.jsx(W1e,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Mr(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),fxt=C.forwardRef((t,s)=>{const r=oS(vf,t.__scopeMenu);return e.jsx(W1e,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),gxt=M_("MenuContent.ScrollLock"),W1e=C.forwardRef((t,s)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:l,disableOutsidePointerEvents:i,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:y,onDismiss:_,disableOutsideScroll:b,...w}=t,j=oS(vf,r),k=EL(vf,r),S=Toe(r),T=A7e(r),I=oxt(r),[L,R]=C.useState(null),$=C.useRef(null),q=Ea(s,$,j.onContentChange),U=C.useRef(0),H=C.useRef(""),Y=C.useRef(0),se=C.useRef(null),te=C.useRef("right"),Q=C.useRef(0),de=b?TL:C.Fragment,re=b?{as:gxt,allowPinchZoom:!0}:void 0,ae=he=>{var Te,Fe;const be=H.current+he,_e=I().filter(Ae=>!Ae.disabled),je=document.activeElement,Ne=(Te=_e.find(Ae=>Ae.ref.current===je))==null?void 0:Te.textValue,Ge=_e.map(Ae=>Ae.textValue),we=Mxt(Ge,be,Ne),Me=(Fe=_e.find(Ae=>Ae.textValue===we))==null?void 0:Fe.ref.current;(function Ae(Ue){H.current=Ue,window.clearTimeout(U.current),Ue!==""&&(U.current=window.setTimeout(()=>Ae(""),1e3))})(be),Me&&setTimeout(()=>Me.focus())};C.useEffect(()=>()=>window.clearTimeout(U.current),[]),Noe();const le=C.useCallback(he=>{var _e,je;return te.current===((_e=se.current)==null?void 0:_e.side)&&Axt(he,(je=se.current)==null?void 0:je.area)},[]);return e.jsx(mxt,{scope:r,searchRef:H,onItemEnter:C.useCallback(he=>{le(he)&&he.preventDefault()},[le]),onItemLeave:C.useCallback(he=>{var be;le(he)||((be=$.current)==null||be.focus(),R(null))},[le]),onTriggerLeave:C.useCallback(he=>{le(he)&&he.preventDefault()},[le]),pointerGraceTimerRef:Y,onPointerGraceIntentChange:C.useCallback(he=>{se.current=he},[]),children:e.jsx(de,{...re,children:e.jsx(CL,{asChild:!0,trapped:a,onMountAutoFocus:Mr(o,he=>{var be;he.preventDefault(),(be=$.current)==null||be.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:e.jsx(q_,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:y,onDismiss:_,children:e.jsx(koe,{asChild:!0,...T,dir:k.dir,orientation:"vertical",loop:n,currentTabStopId:L,onCurrentTabStopIdChange:R,onEntryFocus:Mr(d,he=>{k.isUsingKeyboardRef.current||he.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(NL,{role:"menu","aria-orientation":"vertical","data-state":Y7e(j.open),"data-radix-menu-content":"",dir:k.dir,...S,...w,ref:q,style:{outline:"none",...w.style},onKeyDown:Mr(w.onKeyDown,he=>{const _e=he.target.closest("[data-radix-menu-content]")===he.currentTarget,je=he.ctrlKey||he.altKey||he.metaKey,Ne=he.key.length===1;_e&&(he.key==="Tab"&&he.preventDefault(),!je&&Ne&&ae(he.key));const Ge=$.current;if(he.target!==Ge||!nxt.includes(he.key))return;he.preventDefault();const Me=I().filter(Te=>!Te.disabled).map(Te=>Te.ref.current);M7e.includes(he.key)&&Me.reverse(),Sxt(Me)}),onBlur:Mr(t.onBlur,he=>{he.currentTarget.contains(he.target)||(window.clearTimeout(U.current),H.current="")}),onPointerMove:Mr(t.onPointerMove,n6(he=>{const be=he.target,_e=Q.current!==he.clientX;if(he.currentTarget.contains(be)&&_e){const je=he.clientX>Q.current?"right":"left";te.current=je,Q.current=he.clientX}}))})})})})})})});L7e.displayName=vf;var xxt="MenuGroup",G1e=C.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Qr.div,{role:"group",...n,ref:s})});G1e.displayName=xxt;var yxt="MenuLabel",D7e=C.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Qr.div,{...n,ref:s})});D7e.displayName=yxt;var vne="MenuItem",L5e="menu.itemSelect",Aoe=C.forwardRef((t,s)=>{const{disabled:r=!1,onSelect:n,...a}=t,o=C.useRef(null),l=EL(vne,t.__scopeMenu),i=H1e(vne,t.__scopeMenu),d=Ea(s,o),u=C.useRef(!1),p=()=>{const f=o.current;if(!r&&f){const y=new CustomEvent(L5e,{bubbles:!0,cancelable:!0});f.addEventListener(L5e,_=>n==null?void 0:n(_),{once:!0}),a1e(f,y),y.defaultPrevented?u.current=!1:l.onClose()}};return e.jsx(O7e,{...a,ref:d,disabled:r,onClick:Mr(t.onClick,p),onPointerDown:f=>{var y;(y=t.onPointerDown)==null||y.call(t,f),u.current=!0},onPointerUp:Mr(t.onPointerUp,f=>{var y;u.current||(y=f.currentTarget)==null||y.click()}),onKeyDown:Mr(t.onKeyDown,f=>{const y=i.searchRef.current!=="";r||y&&f.key===" "||Lge.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Aoe.displayName=vne;var O7e=C.forwardRef((t,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...o}=t,l=H1e(vne,r),i=A7e(r),d=C.useRef(null),u=Ea(s,d),[p,f]=C.useState(!1),[y,_]=C.useState("");return C.useEffect(()=>{const b=d.current;b&&_((b.textContent??"").trim())},[o.children]),e.jsx(r6.ItemSlot,{scope:r,disabled:n,textValue:a??y,children:e.jsx(Soe,{asChild:!0,...i,focusable:!n,children:e.jsx(Qr.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:u,onPointerMove:Mr(t.onPointerMove,n6(b=>{n?l.onItemLeave(b):(l.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Mr(t.onPointerLeave,n6(b=>l.onItemLeave(b))),onFocus:Mr(t.onFocus,()=>f(!0)),onBlur:Mr(t.onBlur,()=>f(!1))})})})}),vxt="MenuCheckboxItem",R7e=C.forwardRef((t,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return e.jsx(q7e,{scope:t.__scopeMenu,checked:r,children:e.jsx(Aoe,{role:"menuitemcheckbox","aria-checked":_ne(r)?"mixed":r,...a,ref:s,"data-state":Z1e(r),onSelect:Mr(a.onSelect,()=>n==null?void 0:n(_ne(r)?!0:!r),{checkForDefaultPrevented:!1})})})});R7e.displayName=vxt;var F7e="MenuRadioGroup",[_xt,bxt]=iS(F7e,{value:void 0,onValueChange:()=>{}}),z7e=C.forwardRef((t,s)=>{const{value:r,onValueChange:n,...a}=t,o=Vc(n);return e.jsx(_xt,{scope:t.__scopeMenu,value:r,onValueChange:o,children:e.jsx(G1e,{...a,ref:s})})});z7e.displayName=F7e;var B7e="MenuRadioItem",$7e=C.forwardRef((t,s)=>{const{value:r,...n}=t,a=bxt(B7e,t.__scopeMenu),o=r===a.value;return e.jsx(q7e,{scope:t.__scopeMenu,checked:o,children:e.jsx(Aoe,{role:"menuitemradio","aria-checked":o,...n,ref:s,"data-state":Z1e(o),onSelect:Mr(n.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,r)},{checkForDefaultPrevented:!1})})})});$7e.displayName=B7e;var K1e="MenuItemIndicator",[q7e,wxt]=iS(K1e,{checked:!1}),U7e=C.forwardRef((t,s)=>{const{__scopeMenu:r,forceMount:n,...a}=t,o=wxt(K1e,r);return e.jsx(ud,{present:n||_ne(o.checked)||o.checked===!0,children:e.jsx(Qr.span,{...a,ref:s,"data-state":Z1e(o.checked)})})});U7e.displayName=K1e;var jxt="MenuSeparator",V7e=C.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Qr.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});V7e.displayName=jxt;var Nxt="MenuArrow",H7e=C.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=Toe(r);return e.jsx(kL,{...a,...n,ref:s})});H7e.displayName=Nxt;var kxt="MenuSub",[E_s,W7e]=iS(kxt),DE="MenuSubTrigger",G7e=C.forwardRef((t,s)=>{const r=oS(DE,t.__scopeMenu),n=EL(DE,t.__scopeMenu),a=W7e(DE,t.__scopeMenu),o=H1e(DE,t.__scopeMenu),l=C.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:d}=o,u={__scopeMenu:t.__scopeMenu},p=C.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return C.useEffect(()=>p,[p]),C.useEffect(()=>{const f=i.current;return()=>{window.clearTimeout(f),d(null)}},[i,d]),e.jsx(U1e,{asChild:!0,...u,children:e.jsx(O7e,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":Y7e(r.open),...t,ref:tv(s,a.onTriggerChange),onClick:f=>{var y;(y=t.onClick)==null||y.call(t,f),!(t.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Mr(t.onPointerMove,n6(f=>{o.onItemEnter(f),!f.defaultPrevented&&!t.disabled&&!r.open&&!l.current&&(o.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{r.onOpenChange(!0),p()},100))})),onPointerLeave:Mr(t.onPointerLeave,n6(f=>{var _,b;p();const y=(_=r.content)==null?void 0:_.getBoundingClientRect();if(y){const w=(b=r.content)==null?void 0:b.dataset.side,j=w==="right",k=j?-5:5,S=y[j?"left":"right"],T=y[j?"right":"left"];o.onPointerGraceIntentChange({area:[{x:f.clientX+k,y:f.clientY},{x:S,y:y.top},{x:T,y:y.top},{x:T,y:y.bottom},{x:S,y:y.bottom}],side:w}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(f),f.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Mr(t.onKeyDown,f=>{var _;const y=o.searchRef.current!=="";t.disabled||y&&f.key===" "||axt[n.dir].includes(f.key)&&(r.onOpenChange(!0),(_=r.content)==null||_.focus(),f.preventDefault())})})})});G7e.displayName=DE;var K7e="MenuSubContent",Z7e=C.forwardRef((t,s)=>{const r=P7e(vf,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=oS(vf,t.__scopeMenu),l=EL(vf,t.__scopeMenu),i=W7e(K7e,t.__scopeMenu),d=C.useRef(null),u=Ea(s,d);return e.jsx(r6.Provider,{scope:t.__scopeMenu,children:e.jsx(ud,{present:n||o.open,children:e.jsx(r6.Slot,{scope:t.__scopeMenu,children:e.jsx(W1e,{id:i.contentId,"aria-labelledby":i.triggerId,...a,ref:u,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{var f;l.isUsingKeyboardRef.current&&((f=d.current)==null||f.focus()),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:Mr(t.onFocusOutside,p=>{p.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Mr(t.onEscapeKeyDown,p=>{l.onClose(),p.preventDefault()}),onKeyDown:Mr(t.onKeyDown,p=>{var _;const f=p.currentTarget.contains(p.target),y=ixt[l.dir].includes(p.key);f&&y&&(o.onOpenChange(!1),(_=i.trigger)==null||_.focus(),p.preventDefault())})})})})})});Z7e.displayName=K7e;function Y7e(t){return t?"open":"closed"}function _ne(t){return t==="indeterminate"}function Z1e(t){return _ne(t)?"indeterminate":t?"checked":"unchecked"}function Sxt(t){const s=document.activeElement;for(const r of t)if(r===s||(r.focus(),document.activeElement!==s))return}function Cxt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}function Mxt(t,s,r){const a=s.length>1&&Array.from(s).every(u=>u===s[0])?s[0]:s,o=r?t.indexOf(r):-1;let l=Cxt(t,Math.max(o,0));a.length===1&&(l=l.filter(u=>u!==r));const d=l.find(u=>u.toLowerCase().startsWith(a.toLowerCase()));return d!==r?d:void 0}function Txt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=y>n&&r<(f-u)*(n-p)/(y-p)+u&&(a=!a)}return a}function Axt(t,s){if(!s)return!1;const r={x:t.clientX,y:t.clientY};return Txt(r,s)}function n6(t){return s=>s.pointerType==="mouse"?t(s):void 0}var Ext=E7e,Pxt=U1e,Ixt=I7e,Lxt=L7e,Dxt=G1e,Oxt=D7e,Rxt=Aoe,Fxt=R7e,zxt=z7e,Bxt=$7e,$xt=U7e,qxt=V7e,Uxt=H7e,Vxt=G7e,Hxt=Z7e,Eoe="DropdownMenu",[Wxt]=Ec(Eoe,[T7e]),em=T7e(),[Gxt,X7e]=Wxt(Eoe),Q7e=t=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:o,onOpenChange:l,modal:i=!0}=t,d=em(s),u=C.useRef(null),[p,f]=vu({prop:a,defaultProp:o??!1,onChange:l,caller:Eoe});return e.jsx(Gxt,{scope:s,triggerId:Gd(),triggerRef:u,contentId:Gd(),open:p,onOpenChange:f,onOpenToggle:C.useCallback(()=>f(y=>!y),[f]),modal:i,children:e.jsx(Ext,{...d,open:p,onOpenChange:f,dir:n,modal:i,children:r})})};Q7e.displayName=Eoe;var J7e="DropdownMenuTrigger",eBe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,o=X7e(J7e,r),l=em(r);return e.jsx(Pxt,{asChild:!0,...l,children:e.jsx(Qr.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...a,ref:tv(s,o.triggerRef),onPointerDown:Mr(t.onPointerDown,i=>{!n&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:Mr(t.onKeyDown,i=>{n||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});eBe.displayName=J7e;var Kxt="DropdownMenuPortal",tBe=t=>{const{__scopeDropdownMenu:s,...r}=t,n=em(s);return e.jsx(Ixt,{...n,...r})};tBe.displayName=Kxt;var sBe="DropdownMenuContent",rBe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=X7e(sBe,r),o=em(r),l=C.useRef(!1);return e.jsx(Lxt,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...n,ref:s,onCloseAutoFocus:Mr(t.onCloseAutoFocus,i=>{var d;l.current||(d=a.triggerRef.current)==null||d.focus(),l.current=!1,i.preventDefault()}),onInteractOutside:Mr(t.onInteractOutside,i=>{const d=i.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,p=d.button===2||u;(!a.modal||p)&&(l.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});rBe.displayName=sBe;var Zxt="DropdownMenuGroup",Yxt=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=em(r);return e.jsx(Dxt,{...a,...n,ref:s})});Yxt.displayName=Zxt;var Xxt="DropdownMenuLabel",nBe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=em(r);return e.jsx(Oxt,{...a,...n,ref:s})});nBe.displayName=Xxt;var Qxt="DropdownMenuItem",aBe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=em(r);return e.jsx(Rxt,{...a,...n,ref:s})});aBe.displayName=Qxt;var Jxt="DropdownMenuCheckboxItem",iBe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=em(r);return e.jsx(Fxt,{...a,...n,ref:s})});iBe.displayName=Jxt;var eyt="DropdownMenuRadioGroup",tyt=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=em(r);return e.jsx(zxt,{...a,...n,ref:s})});tyt.displayName=eyt;var syt="DropdownMenuRadioItem",oBe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=em(r);return e.jsx(Bxt,{...a,...n,ref:s})});oBe.displayName=syt;var ryt="DropdownMenuItemIndicator",lBe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=em(r);return e.jsx($xt,{...a,...n,ref:s})});lBe.displayName=ryt;var nyt="DropdownMenuSeparator",cBe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=em(r);return e.jsx(qxt,{...a,...n,ref:s})});cBe.displayName=nyt;var ayt="DropdownMenuArrow",iyt=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=em(r);return e.jsx(Uxt,{...a,...n,ref:s})});iyt.displayName=ayt;var oyt="DropdownMenuSubTrigger",dBe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=em(r);return e.jsx(Vxt,{...a,...n,ref:s})});dBe.displayName=oyt;var lyt="DropdownMenuSubContent",uBe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=em(r);return e.jsx(Hxt,{...a,...n,ref:s,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});uBe.displayName=lyt;var cyt=Q7e,dyt=eBe,uyt=tBe,hBe=rBe,mBe=nBe,pBe=aBe,fBe=iBe,gBe=oBe,xBe=lBe,yBe=cBe,vBe=dBe,_Be=uBe;const Kd=cyt,Zd=dyt,hyt=C.forwardRef(({className:t,inset:s,children:r,...n},a)=>e.jsxs(vBe,{ref:a,className:Pt("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",s&&"pl-8",t),...n,children:[r,e.jsx(Ua,{className:"ml-auto h-4 w-4"})]}));hyt.displayName=vBe.displayName;const myt=C.forwardRef(({className:t,...s},r)=>e.jsx(_Be,{ref:r,className:Pt("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s}));myt.displayName=_Be.displayName;const Md=C.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(uyt,{children:e.jsx(hBe,{ref:n,sideOffset:s,className:Pt("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})}));Md.displayName=hBe.displayName;const Na=C.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(pBe,{ref:n,className:Pt("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",s&&"pl-8",t),...r}));Na.displayName=pBe.displayName;const pyt=C.forwardRef(({className:t,children:s,checked:r,...n},a)=>e.jsxs(fBe,{ref:a,className:Pt("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),checked:r,...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(xBe,{children:e.jsx(ha,{className:"h-4 w-4"})})}),s]}));pyt.displayName=fBe.displayName;const fyt=C.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(gBe,{ref:n,className:Pt("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(xBe,{children:e.jsx(Kc,{className:"h-2 w-2 fill-current"})})}),s]}));fyt.displayName=gBe.displayName;const Dge=C.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(mBe,{ref:n,className:Pt("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...r}));Dge.displayName=mBe.displayName;const E_=C.forwardRef(({className:t,...s},r)=>e.jsx(yBe,{ref:r,className:Pt("-mx-1 my-1 h-px bg-muted",t),...s}));E_.displayName=yBe.displayName;const gyt=()=>{const{isAssistant:t,actingAsAgent:s,assignedAgents:r,setActingAsAgent:n,isActingAsSelf:a,setActingAsSelf:o}=$1e();if(!t)return null;const l=i=>i.split(" ").map(d=>d[0]).join("").toUpperCase().slice(0,2);return e.jsx("div",{className:"fixed top-0 left-0 right-0 z-[2147483647] bg-primary text-primary-foreground px-4 py-1.5 shadow-lg",style:{height:"40px"},children:e.jsxs("div",{className:"container mx-auto flex items-center justify-between gap-4 h-full",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[a?e.jsxs(e.Fragment,{children:[e.jsx(Yi,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"My Account"})]}):e.jsxs(e.Fragment,{children:[e.jsx(hr,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"Acting as"})]}),e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsxs(K,{variant:"secondary",size:"sm",className:"gap-2 bg-primary-foreground/20 hover:bg-primary-foreground/30 text-primary-foreground border-0",children:[a?e.jsxs(e.Fragment,{children:[e.jsx(Yi,{className:"h-4 w-4"}),e.jsx("strong",{children:"My Account"})]}):s?e.jsxs(e.Fragment,{children:[e.jsxs(xn,{className:"h-5 w-5",children:[e.jsx(Aa,{src:s.avatar_url||void 0}),e.jsx(yn,{className:"text-[10px] bg-primary-foreground/30",children:l(s.name)})]}),e.jsx("strong",{children:s.name})]}):e.jsx("strong",{children:"Select..."}),e.jsx(Ho,{className:"h-3 w-3"})]})}),e.jsxs(Md,{align:"start",className:"z-[2147483647]",children:[e.jsxs(Na,{onClick:o,className:"gap-2",children:[e.jsx(Yi,{className:"h-4 w-4"}),e.jsx("span",{children:"My Account"}),a&&e.jsx(rt,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]}),e.jsx(E_,{}),r.map(i=>e.jsxs(Na,{onClick:()=>n(i),className:"gap-2",children:[e.jsxs(xn,{className:"h-6 w-6",children:[e.jsx(Aa,{src:i.avatar_url||void 0}),e.jsx(yn,{className:"text-[10px]",children:l(i.name)})]}),e.jsx("span",{children:i.name}),!a&&i.id===(s==null?void 0:s.id)&&e.jsx(rt,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},i.id))]})]})]}),e.jsx(rt,{variant:"secondary",className:"bg-primary-foreground/20 text-primary-foreground border-0 text-xs",children:a?"Personal Mode":"Assistant Mode"})]})})},lr=({children:t,requireAdmin:s=!1,requireBrokerageManager:r=!1})=>{const{user:n,loading:a,isAdmin:o,isBrokerageManager:l}=Hs();return a?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})}):n?s&&!o?e.jsx(Nhe,{to:"/dashboard",replace:!0}):r&&!l&&!o?e.jsx(Nhe,{to:"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t}):e.jsx(Nhe,{to:"/auth",replace:!0})};var Y1e={};(function t(s,r,n,a){var o=!!(s.Worker&&s.Blob&&s.Promise&&s.OffscreenCanvas&&s.OffscreenCanvasRenderingContext2D&&s.HTMLCanvasElement&&s.HTMLCanvasElement.prototype.transferControlToOffscreen&&s.URL&&s.URL.createObjectURL),l=typeof Path2D=="function"&&typeof DOMMatrix=="function",i=function(){if(!s.OffscreenCanvas)return!1;try{var be=new OffscreenCanvas(1,1),_e=be.getContext("2d");_e.fillRect(0,0,1,1);var je=be.transferToImageBitmap();_e.createPattern(je,"no-repeat")}catch{return!1}return!0}();function d(){}function u(be){var _e=r.exports.Promise,je=_e!==void 0?_e:s.Promise;return typeof je=="function"?new je(be):(be(d,d),null)}var p=function(be,_e){return{transform:function(je){if(be)return je;if(_e.has(je))return _e.get(je);var Ne=new OffscreenCanvas(je.width,je.height),Ge=Ne.getContext("2d");return Ge.drawImage(je,0,0),_e.set(je,Ne),Ne},clear:function(){_e.clear()}}}(i,new Map),f=function(){var be=Math.floor(16.666666666666668),_e,je,Ne={},Ge=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(_e=function(we){var Me=Math.random();return Ne[Me]=requestAnimationFrame(function Te(Fe){Ge===Fe||Ge+be-1{const{data:s,error:r}=await G.from("celebration_queue").select("*").eq("user_id",t.id).is("seen_at",null).order("created_at",{ascending:!0});if(r)throw r;return s},enabled:!!(t!=null&&t.id),refetchOnWindowFocus:!0,staleTime:0})}function yyt(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("celebration_queue").update({seen_at:new Date().toISOString()}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}function vyt(){const t=rs(),{user:s}=Hs();return Dt({mutationFn:async r=>{const{error:n}=await G.from("celebration_queue").insert({user_id:r.user_id,celebration_type:r.celebration_type,title:r.title,message:r.message||null,points_amount:r.points_amount||null,created_by:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}var Poe="Dialog",[bBe,wBe]=Ec(Poe),[_yt,tx]=bBe(Poe),jBe=t=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!0}=t,i=C.useRef(null),d=C.useRef(null),[u,p]=vu({prop:n,defaultProp:a??!1,onChange:o,caller:Poe});return e.jsx(_yt,{scope:s,triggerRef:i,contentRef:d,contentId:Gd(),titleId:Gd(),descriptionId:Gd(),open:u,onOpenChange:p,onOpenToggle:C.useCallback(()=>p(f=>!f),[p]),modal:l,children:r})};jBe.displayName=Poe;var NBe="DialogTrigger",kBe=C.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=tx(NBe,r),o=Ea(s,a.triggerRef);return e.jsx(Qr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":J1e(a.open),...n,ref:o,onClick:Mr(t.onClick,a.onOpenToggle)})});kBe.displayName=NBe;var X1e="DialogPortal",[byt,SBe]=bBe(X1e,{forceMount:void 0}),CBe=t=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=t,o=tx(X1e,s);return e.jsx(byt,{scope:s,forceMount:r,children:C.Children.map(n,l=>e.jsx(ud,{present:r||o.open,children:e.jsx(hM,{asChild:!0,container:a,children:l})}))})};CBe.displayName=X1e;var bne="DialogOverlay",MBe=C.forwardRef((t,s)=>{const r=SBe(bne,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=tx(bne,t.__scopeDialog);return o.modal?e.jsx(ud,{present:n||o.open,children:e.jsx(jyt,{...a,ref:s})}):null});MBe.displayName=bne;var wyt=M_("DialogOverlay.RemoveScroll"),jyt=C.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=tx(bne,r);return e.jsx(TL,{as:wyt,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(Qr.div,{"data-state":J1e(a.open),...n,ref:s,style:{pointerEvents:"auto",...n.style}})})}),Lk="DialogContent",TBe=C.forwardRef((t,s)=>{const r=SBe(Lk,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=tx(Lk,t.__scopeDialog);return e.jsx(ud,{present:n||o.open,children:o.modal?e.jsx(Nyt,{...a,ref:s}):e.jsx(kyt,{...a,ref:s})})});TBe.displayName=Lk;var Nyt=C.forwardRef((t,s)=>{const r=tx(Lk,t.__scopeDialog),n=C.useRef(null),a=Ea(s,r.contentRef,n);return C.useEffect(()=>{const o=n.current;if(o)return Coe(o)},[]),e.jsx(ABe,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Mr(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Mr(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&o.preventDefault()}),onFocusOutside:Mr(t.onFocusOutside,o=>o.preventDefault())})}),kyt=C.forwardRef((t,s)=>{const r=tx(Lk,t.__scopeDialog),n=C.useRef(!1),a=C.useRef(!1);return e.jsx(ABe,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,i;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(n.current||(i=r.triggerRef.current)==null||i.focus(),o.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:o=>{var d,u;(d=t.onInteractOutside)==null||d.call(t,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((u=r.triggerRef.current)==null?void 0:u.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),ABe=C.forwardRef((t,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=t,i=tx(Lk,r),d=C.useRef(null),u=Ea(s,d);return Noe(),e.jsxs(e.Fragment,{children:[e.jsx(CL,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(q_,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":J1e(i.open),...l,ref:u,onDismiss:()=>i.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(Cyt,{titleId:i.titleId}),e.jsx(Tyt,{contentRef:d,descriptionId:i.descriptionId})]})]})}),Q1e="DialogTitle",EBe=C.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=tx(Q1e,r);return e.jsx(Qr.h2,{id:a.titleId,...n,ref:s})});EBe.displayName=Q1e;var PBe="DialogDescription",IBe=C.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=tx(PBe,r);return e.jsx(Qr.p,{id:a.descriptionId,...n,ref:s})});IBe.displayName=PBe;var LBe="DialogClose",DBe=C.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=tx(LBe,r);return e.jsx(Qr.button,{type:"button",...n,ref:s,onClick:Mr(t.onClick,()=>a.onOpenChange(!1))})});DBe.displayName=LBe;function J1e(t){return t?"open":"closed"}var OBe="DialogTitleWarning",[Syt,RBe]=lot(OBe,{contentName:Lk,titleName:Q1e,docsSlug:"dialog"}),Cyt=({titleId:t})=>{const s=RBe(OBe),r=`\`${s.contentName}\` requires a \`${s.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${s.titleName}\`, you can wrap it with our VisuallyHidden component. For more information, see https://radix-ui.com/primitives/docs/components/${s.docsSlug}`;return C.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},Myt="DialogDescriptionWarning",Tyt=({contentRef:t,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${RBe(Myt).contentName}}.`;return C.useEffect(()=>{var o;const a=(o=t.current)==null?void 0:o.getAttribute("aria-describedby");s&&a&&(document.getElementById(s)||console.warn(n))},[n,t,s]),null},Ioe=jBe,e_e=kBe,Loe=CBe,wM=MBe,jM=TBe,PL=EBe,IL=IBe,LL=DBe;const _s=Ioe,Ei=e_e,Ayt=Loe,P_s=LL,FBe=C.forwardRef(({className:t,...s},r)=>e.jsx(wM,{ref:r,className:Pt("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));FBe.displayName=wM.displayName;const vs=C.forwardRef(({className:t,children:s,overlayClassName:r,...n},a)=>e.jsxs(Ayt,{children:[e.jsx(FBe,{className:r}),e.jsxs(jM,{ref:a,className:Pt("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...n,children:[s,e.jsxs(LL,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(Ur,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));vs.displayName=jM.displayName;const Ss=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});Ss.displayName="DialogHeader";const Un=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});Un.displayName="DialogFooter";const ks=C.forwardRef(({className:t,...s},r)=>e.jsx(PL,{ref:r,className:Pt("text-lg font-semibold leading-none tracking-tight",t),...s}));ks.displayName=PL.displayName;const Kr=C.forwardRef(({className:t,...s},r)=>e.jsx(IL,{ref:r,className:Pt("text-sm text-muted-foreground",t),...s}));Kr.displayName=IL.displayName;const Eyt={points_earned:ao,listing_created:On,deal_closed:od,custom:Gn},O5e={points_earned:"from-amber-500 to-orange-500",listing_created:"from-emerald-500 to-teal-500",deal_closed:"from-green-500 to-emerald-500",custom:"from-purple-500 to-pink-500"},R5e=()=>{const t=window.location.hostname;return t.startsWith("cards.")||t.startsWith("cardstudio.")||t.startsWith("listings.")||t.startsWith("presentations.")||t.startsWith("guestbook.")||t.startsWith("clients.")||t.startsWith("booking.")||t.startsWith("contacts.")};function Pyt(){const{user:t}=Hs(),s=rs(),{data:r}=xyt(),n=yyt(),[a,o]=C.useState(null),[l,i]=C.useState(!1),d=C.useCallback(()=>{const _=Date.now()+3e3,b={startVelocity:30,spread:360,ticks:60,zIndex:9999},w=(k,S)=>Math.random()*(S-k)+k,j=setInterval(()=>{const k=_-Date.now();if(k<=0){clearInterval(j);return}const S=50*(k/3e3);D5e({...b,particleCount:S,origin:{x:w(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),D5e({...b,particleCount:S,origin:{x:w(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);C.useEffect(()=>{R5e()||r&&r.length>0&&!a&&(o(r[0]),i(!0),setTimeout(d,100))},[r,a,d]);const u=async()=>{if(a){const y=a.id;i(!1),o(null),s.setQueryData(["celebrations","pending",t==null?void 0:t.id],_=>(_==null?void 0:_.filter(b=>b.id!==y))??[]),await n.mutateAsync(y)}};if(R5e()||!a)return null;const p=Eyt[a.celebration_type]||Gn,f=O5e[a.celebration_type]||O5e.custom;return e.jsx(_s,{open:l,onOpenChange:y=>!y&&u(),children:e.jsxs(vs,{className:"sm:max-w-md text-center border-0 overflow-hidden",children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${f} opacity-10`}),e.jsxs("div",{className:"relative z-10 py-6",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:`w-20 h-20 rounded-full bg-gradient-to-br ${f} flex items-center justify-center animate-bounce`,children:e.jsx(p,{className:"w-10 h-10 text-white"})})}),e.jsxs("div",{className:"flex justify-center gap-1 mb-4",children:[e.jsx(hn,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),e.jsx(hn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),e.jsx(hn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-150"})]}),e.jsxs("h2",{className:"text-2xl font-bold mb-2 bg-gradient-to-r from-primary to-secondary bg-clip-text text-transparent",children:["🎉 ",a.title]}),a.points_amount&&a.points_amount>0&&e.jsxs("div",{className:"text-4xl font-bold text-primary mb-2",children:["+",a.points_amount," points!"]}),a.message&&e.jsx("p",{className:"text-muted-foreground mb-6",children:a.message}),e.jsx(K,{onClick:u,className:"w-full",size:"lg",children:"Awesome! 🙌"}),r&&r.length>1&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-3",children:["+",r.length-1," more celebration",r.length>2?"s":""," waiting"]})]})]})})}const zBe="/assets/levelup-logo-horizontal-DEFNc0ms.png",t_e="/assets/levelup-logo-white-C2RAgAoG.png",Iyt="/assets/listings-hero-BI9Ki9Dq.jpg",Re=C.forwardRef(({className:t,type:s,...r},n)=>e.jsx("input",{type:s,className:Pt("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...r}));Re.displayName="Input";var BBe={exports:{}};(function(t,s){(function(r,n){t.exports=n()})(b0,function(){var r,n,a;function o(i,d){if(!r)r=d;else if(!n)n=d;else{var u="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+r+")(sharedChunk); ("+n+")(sharedChunk); self.onerror = null;",p={};r(p),a=d(p),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(a.workerUrl=window.URL.createObjectURL(new Blob([u],{type:"text/javascript"})))}}o(["exports"],function(i){var d=1e-6,u=typeof Float32Array<"u"?Float32Array:Array;function p(g,c){var m=c[0],v=c[1],N=c[2],E=c[3],P=m*E-N*v;return P?(g[0]=E*(P=1/P),g[1]=-v*P,g[2]=-N*P,g[3]=m*P,g):null}function f(){var g=new u(9);return u!=Float32Array&&(g[1]=0,g[2]=0,g[3]=0,g[5]=0,g[6]=0,g[7]=0),g[0]=1,g[4]=1,g[8]=1,g}function y(g,c){var m=c[0],v=c[1],N=c[2],E=c[3],P=c[4],O=c[5],B=c[6],W=c[7],J=c[8];return g[0]=P*J-O*W,g[1]=N*W-v*J,g[2]=v*O-N*P,g[3]=O*B-E*J,g[4]=m*J-N*B,g[5]=N*E-m*O,g[6]=E*W-P*B,g[7]=v*B-m*W,g[8]=m*P-v*E,g}function _(g,c,m){var v=c[0],N=c[1],E=c[2],P=c[3],O=c[4],B=c[5],W=c[6],J=c[7],ee=c[8],ie=m[0],ce=m[1],ue=m[2],ke=m[3],Le=m[4],Ie=m[5],Ke=m[6],Ye=m[7],at=m[8];return g[0]=ie*v+ce*P+ue*W,g[1]=ie*N+ce*O+ue*J,g[2]=ie*E+ce*B+ue*ee,g[3]=ke*v+Le*P+Ie*W,g[4]=ke*N+Le*O+Ie*J,g[5]=ke*E+Le*B+Ie*ee,g[6]=Ke*v+Ye*P+at*W,g[7]=Ke*N+Ye*O+at*J,g[8]=Ke*E+Ye*B+at*ee,g}function b(){var g=new u(16);return u!=Float32Array&&(g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[11]=0,g[12]=0,g[13]=0,g[14]=0),g[0]=1,g[5]=1,g[10]=1,g[15]=1,g}function w(g){var c=new u(16);return c[0]=g[0],c[1]=g[1],c[2]=g[2],c[3]=g[3],c[4]=g[4],c[5]=g[5],c[6]=g[6],c[7]=g[7],c[8]=g[8],c[9]=g[9],c[10]=g[10],c[11]=g[11],c[12]=g[12],c[13]=g[13],c[14]=g[14],c[15]=g[15],c}function j(g){return g[0]=1,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=1,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=1,g[11]=0,g[12]=0,g[13]=0,g[14]=0,g[15]=1,g}function k(g,c){var m=c[0],v=c[1],N=c[2],E=c[3],P=c[4],O=c[5],B=c[6],W=c[7],J=c[8],ee=c[9],ie=c[10],ce=c[11],ue=c[12],ke=c[13],Le=c[14],Ie=c[15],Ke=m*O-v*P,Ye=m*B-N*P,at=m*W-E*P,vt=v*B-N*O,pt=v*W-E*O,kt=N*W-E*B,Lt=J*ke-ee*ue,$t=J*Le-ie*ue,ls=J*Ie-ce*ue,Wt=ee*Le-ie*ke,ms=ee*Ie-ce*ke,bs=ie*Ie-ce*Le,ws=Ke*bs-Ye*ms+at*Wt+vt*ls-pt*$t+kt*Lt;return ws?(g[0]=(O*bs-B*ms+W*Wt)*(ws=1/ws),g[1]=(N*ms-v*bs-E*Wt)*ws,g[2]=(ke*kt-Le*pt+Ie*vt)*ws,g[3]=(ie*pt-ee*kt-ce*vt)*ws,g[4]=(B*ls-P*bs-W*$t)*ws,g[5]=(m*bs-N*ls+E*$t)*ws,g[6]=(Le*at-ue*kt-Ie*Ye)*ws,g[7]=(J*kt-ie*at+ce*Ye)*ws,g[8]=(P*ms-O*ls+W*Lt)*ws,g[9]=(v*ls-m*ms-E*Lt)*ws,g[10]=(ue*pt-ke*at+Ie*Ke)*ws,g[11]=(ee*at-J*pt-ce*Ke)*ws,g[12]=(O*$t-P*Wt-B*Lt)*ws,g[13]=(m*Wt-v*$t+N*Lt)*ws,g[14]=(ke*Ye-ue*vt-Le*Ke)*ws,g[15]=(J*vt-ee*Ye+ie*Ke)*ws,g):null}function S(g,c,m){var v=c[0],N=c[1],E=c[2],P=c[3],O=c[4],B=c[5],W=c[6],J=c[7],ee=c[8],ie=c[9],ce=c[10],ue=c[11],ke=c[12],Le=c[13],Ie=c[14],Ke=c[15],Ye=m[0],at=m[1],vt=m[2],pt=m[3];return g[0]=Ye*v+at*O+vt*ee+pt*ke,g[1]=Ye*N+at*B+vt*ie+pt*Le,g[2]=Ye*E+at*W+vt*ce+pt*Ie,g[3]=Ye*P+at*J+vt*ue+pt*Ke,g[4]=(Ye=m[4])*v+(at=m[5])*O+(vt=m[6])*ee+(pt=m[7])*ke,g[5]=Ye*N+at*B+vt*ie+pt*Le,g[6]=Ye*E+at*W+vt*ce+pt*Ie,g[7]=Ye*P+at*J+vt*ue+pt*Ke,g[8]=(Ye=m[8])*v+(at=m[9])*O+(vt=m[10])*ee+(pt=m[11])*ke,g[9]=Ye*N+at*B+vt*ie+pt*Le,g[10]=Ye*E+at*W+vt*ce+pt*Ie,g[11]=Ye*P+at*J+vt*ue+pt*Ke,g[12]=(Ye=m[12])*v+(at=m[13])*O+(vt=m[14])*ee+(pt=m[15])*ke,g[13]=Ye*N+at*B+vt*ie+pt*Le,g[14]=Ye*E+at*W+vt*ce+pt*Ie,g[15]=Ye*P+at*J+vt*ue+pt*Ke,g}function T(g,c,m){var v,N,E,P,O,B,W,J,ee,ie,ce,ue,ke=m[0],Le=m[1],Ie=m[2];return c===g?(g[12]=c[0]*ke+c[4]*Le+c[8]*Ie+c[12],g[13]=c[1]*ke+c[5]*Le+c[9]*Ie+c[13],g[14]=c[2]*ke+c[6]*Le+c[10]*Ie+c[14],g[15]=c[3]*ke+c[7]*Le+c[11]*Ie+c[15]):(N=c[1],E=c[2],P=c[3],O=c[4],B=c[5],W=c[6],J=c[7],ee=c[8],ie=c[9],ce=c[10],ue=c[11],g[0]=v=c[0],g[1]=N,g[2]=E,g[3]=P,g[4]=O,g[5]=B,g[6]=W,g[7]=J,g[8]=ee,g[9]=ie,g[10]=ce,g[11]=ue,g[12]=v*ke+O*Le+ee*Ie+c[12],g[13]=N*ke+B*Le+ie*Ie+c[13],g[14]=E*ke+W*Le+ce*Ie+c[14],g[15]=P*ke+J*Le+ue*Ie+c[15]),g}function I(g,c,m){var v=m[0],N=m[1],E=m[2];return g[0]=c[0]*v,g[1]=c[1]*v,g[2]=c[2]*v,g[3]=c[3]*v,g[4]=c[4]*N,g[5]=c[5]*N,g[6]=c[6]*N,g[7]=c[7]*N,g[8]=c[8]*E,g[9]=c[9]*E,g[10]=c[10]*E,g[11]=c[11]*E,g[12]=c[12],g[13]=c[13],g[14]=c[14],g[15]=c[15],g}function L(g,c,m){var v=Math.sin(m),N=Math.cos(m),E=c[4],P=c[5],O=c[6],B=c[7],W=c[8],J=c[9],ee=c[10],ie=c[11];return c!==g&&(g[0]=c[0],g[1]=c[1],g[2]=c[2],g[3]=c[3],g[12]=c[12],g[13]=c[13],g[14]=c[14],g[15]=c[15]),g[4]=E*N+W*v,g[5]=P*N+J*v,g[6]=O*N+ee*v,g[7]=B*N+ie*v,g[8]=W*N-E*v,g[9]=J*N-P*v,g[10]=ee*N-O*v,g[11]=ie*N-B*v,g}function R(g,c,m){var v=Math.sin(m),N=Math.cos(m),E=c[0],P=c[1],O=c[2],B=c[3],W=c[8],J=c[9],ee=c[10],ie=c[11];return c!==g&&(g[4]=c[4],g[5]=c[5],g[6]=c[6],g[7]=c[7],g[12]=c[12],g[13]=c[13],g[14]=c[14],g[15]=c[15]),g[0]=E*N-W*v,g[1]=P*N-J*v,g[2]=O*N-ee*v,g[3]=B*N-ie*v,g[8]=E*v+W*N,g[9]=P*v+J*N,g[10]=O*v+ee*N,g[11]=B*v+ie*N,g}function $(g,c,m){var v=Math.sin(m),N=Math.cos(m),E=c[0],P=c[1],O=c[2],B=c[3],W=c[4],J=c[5],ee=c[6],ie=c[7];return c!==g&&(g[8]=c[8],g[9]=c[9],g[10]=c[10],g[11]=c[11],g[12]=c[12],g[13]=c[13],g[14]=c[14],g[15]=c[15]),g[0]=E*N+W*v,g[1]=P*N+J*v,g[2]=O*N+ee*v,g[3]=B*N+ie*v,g[4]=W*N-E*v,g[5]=J*N-P*v,g[6]=ee*N-O*v,g[7]=ie*N-B*v,g}function q(g,c){return g[0]=c[0],g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=c[1],g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=c[2],g[11]=0,g[12]=0,g[13]=0,g[14]=0,g[15]=1,g}function U(g,c,m){var v,N,E,P=m[0],O=m[1],B=m[2],W=Math.sqrt(P*P+O*O+B*B);return W0&&(E=1/Math.sqrt(E)),g[0]=c[0]*E,g[1]=c[1]*E,g[2]=c[2]*E,g}function Ue(g,c){return g[0]*c[0]+g[1]*c[1]+g[2]*c[2]}function ut(g,c,m){var v=c[0],N=c[1],E=c[2],P=m[0],O=m[1],B=m[2];return g[0]=N*B-E*O,g[1]=E*P-v*B,g[2]=v*O-N*P,g}function De(g,c,m,v){var N=c[0],E=c[1],P=c[2];return g[0]=N+v*(m[0]-N),g[1]=E+v*(m[1]-E),g[2]=P+v*(m[2]-P),g}function Rt(g,c,m){var v=c[0],N=c[1],E=c[2],P=m[3]*v+m[7]*N+m[11]*E+m[15];return g[0]=(m[0]*v+m[4]*N+m[8]*E+m[12])/(P=P||1),g[1]=(m[1]*v+m[5]*N+m[9]*E+m[13])/P,g[2]=(m[2]*v+m[6]*N+m[10]*E+m[14])/P,g}function me(g,c,m){var v=c[0],N=c[1],E=c[2];return g[0]=v*m[0]+N*m[3]+E*m[6],g[1]=v*m[1]+N*m[4]+E*m[7],g[2]=v*m[2]+N*m[5]+E*m[8],g}function Xe(g,c,m){var v=m[0],N=m[1],E=m[2],P=m[3],O=c[0],B=c[1],W=c[2],J=N*W-E*B,ee=E*O-v*W,ie=v*B-N*O;return g[0]=O+P*(J+=J)+N*(ie+=ie)-E*(ee+=ee),g[1]=B+P*ee+E*J-v*ie,g[2]=W+P*ie+v*ee-N*J,g}function ot(g){return g[0]=0,g[1]=0,g[2]=0,g}function nt(g,c){return g[0]===c[0]&&g[1]===c[1]&&g[2]===c[2]}var Se=he,it=be,$e=de;function ct(){var g=new u(4);return u!=Float32Array&&(g[0]=0,g[1]=0,g[2]=0,g[3]=0),g}function qe(g,c,m){return g[0]=c[0]*m,g[1]=c[1]*m,g[2]=c[2]*m,g[3]=c[3]*m,g}function Ze(g,c){var m=c[0],v=c[1],N=c[2],E=c[3],P=m*m+v*v+N*N+E*E;return P>0&&(P=1/Math.sqrt(P)),g[0]=m*P,g[1]=v*P,g[2]=N*P,g[3]=E*P,g}function Qe(g,c,m){var v=c[0],N=c[1],E=c[2],P=c[3];return g[0]=m[0]*v+m[4]*N+m[8]*E+m[12]*P,g[1]=m[1]*v+m[5]*N+m[9]*E+m[13]*P,g[2]=m[2]*v+m[6]*N+m[10]*E+m[14]*P,g[3]=m[3]*v+m[7]*N+m[11]*E+m[15]*P,g}function We(){var g=new u(4);return u!=Float32Array&&(g[0]=0,g[1]=0,g[2]=0),g[3]=1,g}function He(g){return g[0]=0,g[1]=0,g[2]=0,g[3]=1,g}function et(g,c,m){m*=.5;var v=c[0],N=c[1],E=c[2],P=c[3],O=Math.sin(m),B=Math.cos(m);return g[0]=v*B+P*O,g[1]=N*B+E*O,g[2]=E*B-N*O,g[3]=P*B-v*O,g}function Tt(g,c,m){m*=.5;var v=c[0],N=c[1],E=c[2],P=c[3],O=Math.sin(m),B=Math.cos(m);return g[0]=v*B-E*O,g[1]=N*B+P*O,g[2]=E*B+v*O,g[3]=P*B-N*O,g}te(),ct();var Ft,as,Xt,ss=Ze,is=(Ft=te(),as=re(1,0,0),Xt=re(0,1,0),function(g,c,m){var v=Ue(c,m);return v<-.999999?(ut(Ft,as,c),$e(Ft)<1e-6&&ut(Ft,Xt,c),Ae(Ft,Ft),function(N,E,P){P*=.5;var O=Math.sin(P);N[0]=O*E[0],N[1]=O*E[1],N[2]=O*E[2],N[3]=Math.cos(P)}(g,Ft,Math.PI),g):v>.999999?(g[0]=0,g[1]=0,g[2]=0,g[3]=1,g):(ut(Ft,c,m),g[0]=Ft[0],g[1]=Ft[1],g[2]=Ft[2],g[3]=1+v,ss(g,g))});function ar(){var g=new u(2);return u!=Float32Array&&(g[0]=0,g[1]=0),g}function Ct(g,c){var m=new u(2);return m[0]=g,m[1]=c,m}function Is(g,c,m){return g[0]=c,g[1]=m,g}function qs(g,c,m){return g[0]=c[0]+m[0],g[1]=c[1]+m[1],g}function gr(g,c,m){return g[0]=c[0]-m[0],g[1]=c[1]-m[1],g}function Wn(g,c,m){return g[0]=c[0]*m,g[1]=c[1]*m,g}function ii(g){var c=g[0],m=g[1];return Math.sqrt(c*c+m*m)}function bo(g,c){var m=c[0],v=c[1],N=m*m+v*v;return N>0&&(N=1/Math.sqrt(N)),g[0]=c[0]*N,g[1]=c[1]*N,g}function si(g,c){return g[0]*c[0]+g[1]*c[1]}We(),We(),f();var nn,ia,kn=gr;function sa(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}ar();var Zt=function(){if(ia)return nn;function g(c,m,v,N){this.cx=3*c,this.bx=3*(v-c)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*m,this.by=3*(N-m)-this.cy,this.ay=1-this.cy-this.by,this.p1x=c,this.p1y=m,this.p2x=v,this.p2y=N}return ia=1,nn=g,g.prototype={sampleCurveX:function(c){return((this.ax*c+this.bx)*c+this.cx)*c},sampleCurveY:function(c){return((this.ay*c+this.by)*c+this.cy)*c},sampleCurveDerivativeX:function(c){return(3*this.ax*c+2*this.bx)*c+this.cx},solveCurveX:function(c,m){if(m===void 0&&(m=1e-6),c<0)return 0;if(c>1)return 1;for(var v=c,N=0;N<8;N++){var E=this.sampleCurveX(v)-c;if(Math.abs(E)E?O=v:B=v,v=.5*(B-O)+O;return v},solve:function(c,m){return this.sampleCurveY(this.solveCurveX(c,m))}},nn}(),$r=sa(Zt);function es(g,c){this.x=g,this.y=c}function an(g,c){if(Array.isArray(g)){if(!Array.isArray(c)||g.length!==c.length)return!1;for(let m=0;m=1)return 1;const c=g*g,m=c*g;return 4*(g<.5?m:3*(g-c)+m-.75)}function Vl(g,c,m,v){const N=new $r(g,c,m,v);return function(E){return N.solve(E)}}const Vt=Vl(.25,.1,.25,1);function ye(g,c,m){return Math.min(m,Math.max(c,g))}function ze(g,c,m){return(m=ye((m-g)/(c-g),0,1))*m*(3-2*m)}function Je(g,c,m){const v=m-c,N=((g-c)%v+v)%v+c;return N===c?m:N}function St(g,c,m){if(!g.length)return m(null,[]);let v=g.length;const N=new Array(g.length);let E=null;g.forEach((P,O)=>{c(P,(B,W)=>{B&&(E=B),N[O]=W,--v==0&&m(E,N)})})}let Nt=1;function Bt(){return Nt++}function Kt(g){return g<=1?1:Math.pow(2,Math.ceil(Math.log2(g)))}function qt(g,c){g.forEach(m=>{c[m]&&(c[m]=c[m].bind(c))})}function Qt(g,c,m){const v={};for(const N in g)v[N]=c.call(this,g[N],N,g);return v}function As(g,c,m){const v={};for(const N in g)c.call(this,g[N],N,g)&&(v[N]=g[N]);return v}function gs(g){return Array.isArray(g)?g.map(gs):typeof g=="object"&&g?Qt(g,gs):g}function fr(g,c){for(let m=0;m=0)return!0;return!1}const qr={};function ur(g){qr[g]||(typeof console<"u"&&console.warn(g),qr[g]=!0)}function Cn(g,c,m){return(m.y-g.y)*(c.x-g.x)>(c.y-g.y)*(m.x-g.x)}function Mn(g){let c=0;for(let m,v,N=0,E=g.length,P=E-1;N@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(m,v,N,E)=>{const P=N||E;return c[v]=!P||P.toLowerCase(),""}),c["max-age"]){const m=parseInt(c["max-age"],10);isNaN(m)?delete c["max-age"]:c["max-age"]=m}return c}let qo=null;function Va(g,c){return[g[4*c],g[4*c+1],g[4*c+2],g[4*c+3]]}function Ko(g,c,m,v){for(;c>1;g[N]>1;g[N]<=v?c=N+1:m=N}return c}function ba(g){return g>0?1/(1.001-g):1+g}function Qi(g){return g>0?1-1/(1.001-g):-g}function vi(g,c,m){return(g-c.min)*(m.max-m.min)/(c.max-c.min)+m.min}const ra={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!ra.API_URL)return null;try{const g=new URL(ra.API_URL);return g.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":g.hostname==="api.mapbox.com"?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"https://api.mapbox.com/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function Ji(g){return ra.API_URL_REGEX.test(g)}function ic(g){return ra.API_SPRITE_REGEX.test(g)}let vc,Td,Ap,vl,Nu,Xc;function sm(){return vc==null&&(vc=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),vc}const _l={now:()=>vl!==void 0?vl:performance.now(),setNow(g){vl=g},restoreNow(){vl=void 0},frame(g){const c=requestAnimationFrame(g);return{cancel:()=>cancelAnimationFrame(c)}},getImageData(g,c=0){const{width:m,height:v}=g;Nu||(Nu=document.createElement("canvas"));const N=Nu.getContext("2d",{willReadFrequently:!0});if(!N)throw new Error("failed to create canvas 2d context");return(m>Nu.width||v>Nu.height)&&(Nu.width=m,Nu.height=v),N.clearRect(-c,-c,m+2*c,v+2*c),N.drawImage(g,0,0,m,v),N.getImageData(-c,-c,m+2*c,v+2*c)},resolveURL:g=>(Td||(Td=document.createElement("a")),Td.href=g,Td.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(Ap==null&&(Ap=window.matchMedia("(prefers-reduced-motion: reduce)")),Ap.matches)},hasCanvasFingerprintNoise(){if(Xc!==void 0)return Xc;if(!sm())return Xc=!1,!1;const g=new OffscreenCanvas(85,1),c=g.getContext("2d",{willReadFrequently:!0});let m=0;for(let N=0;N0?`?${E}`:""}`}const pv="mapbox-tiles";let fv=500,gv=50;const Vm=["language","worldview","jobid"];let gh,Ad;function xh(){try{return caches}catch{}}function hd(){const g=xh();g&&gh==null&&(gh=g.open(pv))}let Qc=1/0;const Ed={supported:!1,testSupport:function(g){!rm&&Pp&&(nm?ky(g):Ep=g)}};let Ep,Pp,rm=!1,nm=!1;const Jc=typeof self<"u"?self:{};function ky(g){const c=g.createTexture();g.bindTexture(g.TEXTURE_2D,c);try{if(g.texImage2D(g.TEXTURE_2D,0,g.RGBA,g.RGBA,g.UNSIGNED_BYTE,Pp),g.isContextLost())return;Ed.supported=!0}catch{}g.deleteTexture(c),rm=!0}Jc.document&&(Pp=Jc.document.createElement("img"),Pp.onload=function(){Ep&&ky(Ep),Ep=null,nm=!0},Pp.onerror=function(){rm=!0,Ep=null},Pp.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const $f={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};typeof Object.freeze=="function"&&Object.freeze($f);class hl extends Error{constructor(c,m,v){m===401&&Ji(v)&&(c+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(c),this.status=m,this.url=v}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const xv=ma()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,qf=function(g,c){if(!(/^file:/.test(m=g.url)||/^file:/.test(xv())&&!/^\w+:/.test(m))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(v,N){const E=new AbortController,P=new Request(v.url,{method:v.method||"GET",body:v.body,credentials:v.credentials,headers:v.headers,referrer:xv(),referrerPolicy:v.referrerPolicy,signal:E.signal});let O=!1,B=!1;const W=(J=P.url).indexOf("sku=")>0&&Ji(J);var J;v.type==="json"&&P.headers.set("Accept","application/json");const ee=(ce,ue,ke)=>{if(B)return;if(ce&&ce.message!=="SecurityError"&&ur(ce.toString()),ue&&ke)return ie(ue);const Le=Date.now();fetch(P).then(Ie=>{if(Ie.ok){const Ke=W?Ie.clone():null;return ie(Ie,Ke,Le)}return N(new hl(Ie.statusText,Ie.status,v.url))}).catch(Ie=>{Ie.name!=="AbortError"&&N(new Error(`${Ie.message} ${v.url}`))})},ie=(ce,ue,ke)=>{(v.type==="arrayBuffer"?ce.arrayBuffer():v.type==="json"?ce.json():ce.text()).then(Le=>{B||(ue&&ke&&function(Ie,Ke,Ye){if(hd(),gh==null)return;const at=lo(Ke.headers.get("Cache-Control")||"");if(at["no-store"])return;const vt={status:Ke.status,statusText:Ke.statusText,headers:new Headers};Ke.headers.forEach((Lt,$t)=>vt.headers.set($t,Lt)),at["max-age"]&&vt.headers.set("Expires",new Date(Ye+1e3*at["max-age"]).toUTCString());const pt=vt.headers.get("Expires");if(!pt||new Date(pt).getTime()-Ye<42e4)return;let kt=ax(Ie.url,{persistentParams:Vm});if(Ke.status===206){const Lt=Ie.headers.get("Range");if(!Lt)return;vt.status=200,kt=Bf(kt,{range:Lt})}(function(Lt,$t){if(Ad===void 0)try{new Response(new ReadableStream),Ad=!0}catch{Ad=!1}Ad?$t(Lt.body):Lt.blob().then($t).catch(ls=>ur(ls.message))})(Ke,Lt=>{const $t=new Response((ls=Ke.status)!==200&&ls!==404&&[101,103,204,205,304].includes(ls)?null:Lt,vt);var ls;hd(),gh!=null&&gh.then(Wt=>Wt.put(kt,$t)).catch(Wt=>ur(Wt.message))})}(P,ue,ke),O=!0,N(null,Le,ce.headers))}).catch(Le=>{B||N(new Error(Le.message))})};return W?function(ce,ue){if(hd(),gh==null)return ue(null);gh.then(ke=>{let Le=ax(ce.url,{persistentParams:Vm});const Ie=ce.headers.get("Range");Ie&&(Le=Bf(Le,{range:Ie})),ke.match(Le).then(Ke=>{const Ye=function(at){if(!at)return!1;const vt=new Date(at.headers.get("Expires")||0),pt=lo(at.headers.get("Cache-Control")||"");return Number(vt)>Date.now()&&!pt["no-cache"]}(Ke);ke.delete(Le).catch(ue),Ye&&ke.put(Le,Ke.clone()).catch(ue),ue(null,Ke,Ye)}).catch(ue)}).catch(ue)}(P,ee):ee(null,null),{cancel:()=>{B=!0,O||E.abort()}}}(g,c);if(ma(self)&&self.worker.actor)return self.worker.actor.send("getResource",g,c,void 0,!0)}var m;return function(v,N){const E=new XMLHttpRequest;E.open(v.method||"GET",v.url,!0),v.type==="arrayBuffer"&&(E.responseType="arraybuffer");for(const P in v.headers)E.setRequestHeader(P,v.headers[P]);return v.type==="json"&&(E.responseType="text",E.setRequestHeader("Accept","application/json")),E.withCredentials=v.credentials==="include",E.onerror=()=>{N(new Error(E.statusText))},E.onload=()=>{if((E.status>=200&&E.status<300||E.status===0)&&E.response!==null){let P=E.response;if(v.type==="json")try{P=JSON.parse(E.response)}catch(B){return N(B)}const O=new Headers;E.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(B=>{const W=B.split(": "),J=W.shift(),ee=W.join(": ");O.append(J,ee)}),N(null,P,O)}else N(new hl(E.statusText,E.status,v.url))},E.send(v.body),{cancel:()=>E.abort()}}(g,c)},Vu=function(g,c){return qf(Object.assign(g,{type:"arrayBuffer"}),c)};function lb(g){const c=document.createElement("a");return c.href=g,c.protocol===location.protocol&&c.host===location.host}const yS="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Sy,wa;Sy=[],wa=0;const ix=function(g,c){if(Ed.supported&&(g.headers||(g.headers={}),g.headers.accept="image/webp,*/*"),wa>=ra.MAX_PARALLEL_IMAGE_REQUESTS){const E={requestParameters:g,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return Sy.push(E),E}wa++;let m=!1;const v=()=>{if(!m)for(m=!0,wa--;Sy.length&&wa{v(),E?c(E):P&&(self.createImageBitmap?function(B,W){const J=new Blob([new Uint8Array(B)],{type:"image/png"});createImageBitmap(J).then(ee=>{W(null,ee)}).catch(ee=>{W(new Error(`Could not load image because of ${ee.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(P,(B,W)=>c(B,W,O)):function(B,W){const J=new Image;J.onload=()=>{W(null,J),URL.revokeObjectURL(J.src),J.onload=null,requestAnimationFrame(()=>{J.src=yS})},J.onerror=()=>W(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const ee=new Blob([new Uint8Array(B)],{type:"image/png"});J.src=B.byteLength?URL.createObjectURL(ee):yS}(P,(B,W)=>c(B,W,O)))});return{cancel:()=>{N.cancel(),v()}}};var cb,vS,_S,yh={exports:{}},Cy={exports:{}},My={exports:{}},db=function(){if(_S)return yh.exports;_S=1;var g=(cb||(cb=1,Cy.exports=function(m,v){var N,E,P,O,B,W,J,ee;for(E=m.length-(N=3&m.length),P=v,B=3432918353,W=461845907,ee=0;ee>>16)*B&65535)<<16)&4294967295)<<15|J>>>17))*W+(((J>>>16)*W&65535)<<16)&4294967295)<<13|P>>>19))+((5*(P>>>16)&65535)<<16)&4294967295))+((58964+(O>>>16)&65535)<<16);switch(J=0,N){case 3:J^=(255&m.charCodeAt(ee+2))<<16;case 2:J^=(255&m.charCodeAt(ee+1))<<8;case 1:P^=J=(65535&(J=(J=(65535&(J^=255&m.charCodeAt(ee)))*B+(((J>>>16)*B&65535)<<16)&4294967295)<<15|J>>>17))*W+(((J>>>16)*W&65535)<<16)&4294967295}return P^=m.length,P=2246822507*(65535&(P^=P>>>16))+((2246822507*(P>>>16)&65535)<<16)&4294967295,P=3266489909*(65535&(P^=P>>>13))+((3266489909*(P>>>16)&65535)<<16)&4294967295,(P^=P>>>16)>>>0}),Cy.exports),c=(vS||(vS=1,My.exports=function(m,v){for(var N,E=m.length,P=v^E,O=0;E>=4;)N=1540483477*(65535&(N=255&m.charCodeAt(O)|(255&m.charCodeAt(++O))<<8|(255&m.charCodeAt(++O))<<16|(255&m.charCodeAt(++O))<<24))+((1540483477*(N>>>16)&65535)<<16),P=1540483477*(65535&P)+((1540483477*(P>>>16)&65535)<<16)^(N=1540483477*(65535&(N^=N>>>24))+((1540483477*(N>>>16)&65535)<<16)),E-=4,++O;switch(E){case 3:P^=(255&m.charCodeAt(O+2))<<16;case 2:P^=(255&m.charCodeAt(O+1))<<8;case 1:P=1540483477*(65535&(P^=255&m.charCodeAt(O)))+((1540483477*(P>>>16)&65535)<<16)}return P=1540483477*(65535&(P^=P>>>13))+((1540483477*(P>>>16)&65535)<<16),(P^=P>>>15)>>>0}),My.exports);return yh.exports=g,yh.exports.murmur3=g,yh.exports.murmur2=c,yh.exports}(),yv=sa(db);class am{constructor(c,...m){Object.assign(this,m[0]||{}),this.type=c}}class ox extends am{constructor(c,m={}){super("error",Object.assign({error:c},m))}}function ub(g,c,m){m[g]&&m[g].indexOf(c)!==-1||(m[g]=m[g]||[],m[g].push(c))}function xt(g,c,m){if(m&&m[g]){const v=m[g].indexOf(c);v!==-1&&m[g].splice(v,1)}}class Cs{on(c,m){return this._listeners=this._listeners||{},ub(c,m,this._listeners),this}off(c,m){return xt(c,m,this._listeners),xt(c,m,this._oneTimeListeners),this}once(c,m){return m?(this._oneTimeListeners=this._oneTimeListeners||{},ub(c,m,this._oneTimeListeners),this):new Promise(v=>{this.once(c,v)})}fire(c,m){const v=typeof c=="string"?new am(c,m):c,N=v.type;if(this.listens(N)){v.target=this;const E=this._listeners&&this._listeners[N]?this._listeners[N].slice():[];for(const B of E)B.call(this,v);const P=this._oneTimeListeners&&this._oneTimeListeners[N]?this._oneTimeListeners[N].slice():[];for(const B of P)xt(N,B,this._oneTimeListeners),B.call(this,v);const O=this._eventedParent;if(O){const B=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(v,B),O.fire(v)}}else v instanceof ox&&console.error(v.error);return this}listens(c){return!!(this._listeners&&this._listeners[c]&&this._listeners[c].length>0||this._oneTimeListeners&&this._oneTimeListeners[c]&&this._oneTimeListeners[c].length>0||this._eventedParent&&this._eventedParent.listens(c))}setEventedParent(c,m){return this._eventedParent=c,this._eventedParentData=m,this}}class Ks{constructor(c){typeof c=="string"?this.name=c:(this.name=c.name,this.iconsetId=c.iconsetId)}static from(c){return new Ks(c)}static toString(c){return c.iconsetId?`${c.name}${c.iconsetId}`:c.name}static parse(c){const[m,v]=c.split("");return new Ks({name:m,iconsetId:v})}static isEqual(c,m){return c.name===m.name&&c.iconsetId===m.iconsetId}toString(){return Ks.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var ln,cn={},ta=function(){if(ln)return cn;ln=1;var g={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function c(E){return(E=Math.round(E))<0?0:E>255?255:E}function m(E){return c(E[E.length-1]==="%"?parseFloat(E)/100*255:parseInt(E))}function v(E){return(P=E[E.length-1]==="%"?parseFloat(E)/100:parseFloat(E))<0?0:P>1?1:P;var P}function N(E,P,O){return O<0?O+=1:O>1&&(O-=1),6*O<1?E+(P-E)*O*6:2*O<1?P:3*O<2?E+(P-E)*(2/3-O)*6:E}try{cn.parseCSSColor=function(E){var P,O=E.replace(/ /g,"").toLowerCase();if(O in g)return g[O].slice();if(O[0]==="#")return O.length===4?(P=parseInt(O.substr(1),16))>=0&&P<=4095?[(3840&P)>>4|(3840&P)>>8,240&P|(240&P)>>4,15&P|(15&P)<<4,1]:null:O.length===7&&(P=parseInt(O.substr(1),16))>=0&&P<=16777215?[(16711680&P)>>16,(65280&P)>>8,255&P,1]:null;var B=O.indexOf("("),W=O.indexOf(")");if(B!==-1&&W+1===O.length){var J=O.substr(0,B),ee=O.substr(B+1,W-(B+1)).split(","),ie=1;switch(J){case"rgba":if(ee.length!==4)return null;ie=v(ee.pop());case"rgb":return ee.length!==3?null:[m(ee[0]),m(ee[1]),m(ee[2]),ie];case"hsla":if(ee.length!==4)return null;ie=v(ee.pop());case"hsl":if(ee.length!==3)return null;var ce=(parseFloat(ee[0])%360+360)%360/360,ue=v(ee[1]),ke=v(ee[2]),Le=ke<=.5?ke*(ue+1):ke+ue-ke*ue,Ie=2*ke-Le;return[c(255*N(Ie,Le,ce+1/3)),c(255*N(Ie,Le,ce)),c(255*N(Ie,Le,ce-1/3)),ie];default:return null}}return null}}catch{}return cn}();class Fr{constructor(c,m,v,N=1){this.r=c,this.g=m,this.b=v,this.a=N}static parse(c){if(!c)return;if(c instanceof Fr)return c;if(typeof c!="string")return;const m=ta.parseCSSColor(c);return m?new Fr(m[0]/255,m[1]/255,m[2]/255,m[3]):void 0}toString(){const[c,m,v,N]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*c)},${Math.round(255*m)},${Math.round(255*v)},${N})`}toNonPremultipliedRenderColor(c){const{r:m,g:v,b:N,a:E}=this;return new Uf(c,m,v,N,E)}toPremultipliedRenderColor(c){const{r:m,g:v,b:N,a:E}=this;return new Hm(c,m*E,v*E,N*E,E)}clone(){return new Fr(this.r,this.g,this.b,this.a)}}class eo{constructor(c,m,v,N,E,P=!1){if(this.premultiplied=!1,this.premultiplied=P,c){const O=c.image.height,B=O*O;this.premultiplied?(m=E===0?0:m/E*(O-1),v=E===0?0:v/E*(O-1),N=E===0?0:N/E*(O-1)):(m*=O-1,v*=O-1,N*=O-1);const W=Math.floor(m),J=Math.floor(v),ee=Math.floor(N),ie=Math.ceil(m),ce=Math.ceil(v),ue=Math.ceil(N),ke=m-W,Le=v-J,Ie=N-ee,Ke=c.image.data,Ye=4*(W+J*B+ee*O),at=4*(W+J*B+ue*O),vt=4*(W+ce*B+ee*O),pt=4*(W+ce*B+ue*O),kt=4*(ie+J*B+ee*O),Lt=4*(ie+J*B+ue*O),$t=4*(ie+ce*B+ee*O),ls=4*(ie+ce*B+ue*O);if(Ye<0||ls>=Ke.length)throw new Error("out of range");this.r=Hr(Hr(Hr(Ke[Ye],Ke[at],Ie),Hr(Ke[vt],Ke[pt],Ie),Le),Hr(Hr(Ke[kt],Ke[Lt],Ie),Hr(Ke[$t],Ke[ls],Ie),Le),ke)/255*(this.premultiplied?E:1),this.g=Hr(Hr(Hr(Ke[Ye+1],Ke[at+1],Ie),Hr(Ke[vt+1],Ke[pt+1],Ie),Le),Hr(Hr(Ke[kt+1],Ke[Lt+1],Ie),Hr(Ke[$t+1],Ke[ls+1],Ie),Le),ke)/255*(this.premultiplied?E:1),this.b=Hr(Hr(Hr(Ke[Ye+2],Ke[at+2],Ie),Hr(Ke[vt+2],Ke[pt+2],Ie),Le),Hr(Hr(Ke[kt+2],Ke[Lt+2],Ie),Hr(Ke[$t+2],Ke[ls+2],Ie),Le),ke)/255*(this.premultiplied?E:1),this.a=E}else this.r=m,this.g=v,this.b=N,this.a=E}toArray(){const{r:c,g:m,b:v,a:N}=this;return[255*c,255*m,255*v,N]}toHslaArray(){let{r:c,g:m,b:v,a:N}=this;if(this.premultiplied){if(N===0)return[0,0,0,0];const ue=1/N;c*=ue,m*=ue,v*=ue}const E=Math.min(Math.max(c,0),1),P=Math.min(Math.max(m,0),1),O=Math.min(Math.max(v,0),1),B=Math.min(E,P,O),W=Math.max(E,P,O),J=W-B,ee=.5*(B+W);if(J===0)return[0,0,100*ee,N];const ie=ee>.5?J/(2-W-B):J/(W+B);let ce;switch(W){case E:ce=60*((P-O)/J+(PHr(v,c[N],m))}Fr.black=new Fr(0,0,0,1),Fr.white=new Fr(1,1,1,1),Fr.transparent=new Fr(0,0,0,0),Fr.red=new Fr(1,0,0,1),Fr.blue=new Fr(0,0,1,1);var Ay=Object.freeze({__proto__:null,array:Ty,color:function(g,c,m){return new Fr(Hr(g.r,c.r,m),Hr(g.g,c.g,m),Hr(g.b,c.b,m),Hr(g.a,c.a,m))},number:Hr});class im extends Error{constructor(c,m){super(m),this.message=m,this.key=c}}class vv{constructor(c,m=[]){this.parent=c,this.bindings={};for(const[v,N]of m)this.bindings[v]=N}concat(c){return new vv(this,c)}get(c){if(this.bindings[c])return this.bindings[c];if(this.parent)return this.parent.get(c);throw new Error(`${c} not found in scope.`)}has(c){return!!this.bindings[c]||!!this.parent&&this.parent.has(c)}}const Wm={kind:"null"},Rr={kind:"number"},ja={kind:"string"},pi={kind:"boolean"},ku={kind:"color"},Ip={kind:"object"},ri={kind:"value"},bS={kind:"collator"},hb={kind:"formatted"},mb={kind:"resolvedImage"};function md(g,c){return{kind:"array",itemType:g,N:c}}function rl(g){if(g.kind==="array"){const c=rl(g.itemType);return typeof g.N=="number"?`array<${c}, ${g.N}>`:g.itemType.kind==="value"?"array":`array<${c}>`}return g.kind}const Hce=[Wm,Rr,ja,pi,ku,hb,Ip,md(ri),mb];function lx(g,c){if(c.kind==="error")return null;if(g.kind==="array"){if(c.kind==="array"&&(c.N===0&&c.itemType.kind==="value"||!lx(g.itemType,c.itemType))&&(typeof g.N!="number"||g.N===c.N))return null}else{if(g.kind===c.kind)return null;if(g.kind==="value"){for(const m of Hce)if(!lx(m,c))return null}}return`Expected ${rl(g)} but found ${rl(c)} instead.`}function sT(g,c){return c.some(m=>m.kind===g.kind)}function pb(g,c){return c.some(m=>m==="null"?g===null:m==="array"?Array.isArray(g):m==="object"?g&&!Array.isArray(g)&&typeof g=="object":m===typeof g)}function wS(g,c){return g.kind==="array"&&c.kind==="array"?g.N===c.N&&wS(g.itemType,c.itemType):g.kind===c.kind}class rT{constructor(c,m,v){this.sensitivity=c?m?"variant":"case":m?"accent":"base",this.locale=v,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(c,m){return this.collator.compare(c,m)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class jS{constructor(c,m,v,N,E){this.text=c.normalize?c.normalize():c,this.image=m,this.scale=v,this.fontStack=N,this.textColor=E}}class Qd{constructor(c){this.sections=c}static fromString(c){return new Qd([new jS(c,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(c=>c.text.length!==0||!!c.image&&c.image.hasPrimary())}static factory(c){return c instanceof Qd?c:Qd.fromString(c)}toString(){return this.sections.length===0?"":this.sections.map(c=>c.text).join("")}serialize(){const c=["format"];for(const m of this.sections){if(m.image){const N=m.image.getPrimary().id.toString();c.push(["image",N]);continue}c.push(m.text);const v={};m.fontStack&&(v["text-font"]=["literal",m.fontStack.split(",")]),m.scale&&(v["font-scale"]=m.scale),m.textColor&&(v["text-color"]=["rgba"].concat(m.textColor.toNonPremultipliedRenderColor(null).toArray())),c.push(v)}return c}}class Vf{constructor(c,m={}){this.id=Ks.from(c),this.params=m.params,this.sx=m.sx||1,this.sy=m.sy||1}toString(){return JSON.stringify(this)}static parse(c){let m,v,N,E;try{({id:m,params:v,sx:N,sy:E}=JSON.parse(c)||{})}catch{return null}return m?new Vf(m,{params:v,sx:N,sy:E}):null}scaleSelf(c,m=c){return this.sx*=c,this.sy*=m,this}}class Jd{constructor(c,m,v,N,E=!1){this.primaryId=Ks.from(c),this.primaryOptions=m,v&&(this.secondaryId=Ks.from(v)),this.secondaryOptions=N,this.available=E}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new Vf(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new Vf(this.secondaryId,this.secondaryOptions):null}static from(c){return typeof c=="string"?Jd.build({name:c}):c}static build(c,m,v,N){return!c||typeof c=="object"&&!("name"in c)?null:new Jd(c,v,m,N)}}function Ey(g,c,m,v){return typeof g=="number"&&g>=0&&g<=255&&typeof c=="number"&&c>=0&&c<=255&&typeof m=="number"&&m>=0&&m<=255?v===void 0||typeof v=="number"&&v>=0&&v<=1?null:`Invalid rgba value [${[g,c,m,v].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof v=="number"?[g,c,m,v]:[g,c,m]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function _v(g){if(g===null||typeof g=="string"||typeof g=="boolean"||typeof g=="number"||g instanceof Fr||g instanceof rT||g instanceof Qd||g instanceof Jd)return!0;if(Array.isArray(g)){for(const c of g)if(!_v(c))return!1;return!0}if(typeof g=="object"){for(const c in g)if(!_v(g[c]))return!1;return!0}return!1}function oc(g){if(g===null)return Wm;if(typeof g=="string")return ja;if(typeof g=="boolean")return pi;if(typeof g=="number")return Rr;if(g instanceof Fr)return ku;if(g instanceof rT)return bS;if(g instanceof Qd)return hb;if(g instanceof Jd)return mb;if(Array.isArray(g)){const c=g.length;let m;for(const v of g){const N=oc(v);if(m){if(m===N)continue;m=ri;break}m=N}return md(m||ri,c)}return Ip}function om(g){const c=typeof g;return g===null?"":c==="string"||c==="number"||c==="boolean"?String(g):g instanceof Qd||g instanceof Jd||g instanceof Fr?g.toString():JSON.stringify(g)}class Hf{constructor(c,m){this.type=c,this.value=m}static parse(c,m){if(c.length!==2)return m.error(`'literal' expression requires exactly one argument, but found ${c.length-1} instead.`);if(!_v(c[1]))return m.error("invalid value");const v=c[1];let N=oc(v);const E=m.expectedType;return N.kind!=="array"||N.N!==0||!E||E.kind!=="array"||typeof E.N=="number"&&E.N!==0||(N=E),new Hf(N,v)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Fr?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Qd?this.value.serialize():this.value}}class Hl{constructor(c){this.name="ExpressionEvaluationError",this.message=c}toJSON(){return this.message}}const nT={string:ja,number:Rr,boolean:pi,object:Ip};class Gm{constructor(c,m){this.type=c,this.args=m}static parse(c,m){if(c.length<2)return m.error("Expected at least one argument.");let v,N=1;const E=c[0];if(E==="array"){let O,B;if(c.length>2){const W=c[1];if(typeof W!="string"||!(W in nT)||W==="object")return m.error('The item type argument of "array" must be one of string, number, boolean',1);O=nT[W],N++}else O=ri;if(c.length>3){if(c[2]!==null&&(typeof c[2]!="number"||c[2]<0||c[2]!==Math.floor(c[2])))return m.error('The length argument to "array" must be a positive integer literal',2);B=c[2],N++}v=md(O,B)}else v=nT[E];const P=[];for(;Nc.outputDefined())}serialize(){const c=this.type,m=[c.kind];if(c.kind==="array"){const v=c.itemType;if(v.kind==="string"||v.kind==="number"||v.kind==="boolean"){m.push(v.kind);const N=c.N;(typeof N=="number"||this.args.length>1)&&m.push(N)}}return m.concat(this.args.map(v=>v.serialize()))}}class Lp{constructor(c){this.type=hb,this.sections=c}static parse(c,m){if(c.length<2)return m.error("Expected at least one argument.");const v=c[1];if(!Array.isArray(v)&&typeof v=="object")return m.error("First argument must be an image or text section.");const N=[];let E=!1;for(let P=1;P<=c.length-1;++P){const O=c[P];if(E&&typeof O=="object"&&!Array.isArray(O)){E=!1;let B=null;if(O["font-scale"]&&(B=m.parseObjectValue(O["font-scale"],P,"font-scale",Rr),!B))return null;let W=null;if(O["text-font"]&&(W=m.parseObjectValue(O["text-font"],P,"text-font",md(ja)),!W))return null;let J=null;if(O["text-color"]&&(J=m.parseObjectValue(O["text-color"],P,"text-color",ku),!J))return null;const ee=N[N.length-1];ee.scale=B,ee.font=W,ee.textColor=J}else{const B=m.parse(c[P],P,ri);if(!B)return null;const W=B.type.kind;if(W!=="string"&&W!=="value"&&W!=="null"&&W!=="resolvedImage")return m.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");E=!0,N.push({content:B,scale:null,font:null,textColor:null})}}return new Lp(N)}evaluate(c){return new Qd(this.sections.map(m=>{const v=m.content.evaluate(c);return wS(oc(v),mb)?new jS("",v,null,null,null):new jS(om(v),null,m.scale?m.scale.evaluate(c):null,m.font?m.font.evaluate(c).join(","):null,m.textColor?m.textColor.evaluate(c):null)}))}eachChild(c){for(const m of this.sections)c(m.content),m.scale&&c(m.scale),m.font&&c(m.font),m.textColor&&c(m.textColor)}outputDefined(){return!1}serialize(){const c=["format"];for(const m of this.sections){c.push(m.content.serialize());const v={};m.scale&&(v["font-scale"]=m.scale.serialize()),m.font&&(v["text-font"]=m.font.serialize()),m.textColor&&(v["text-color"]=m.textColor.serialize()),c.push(v)}return c}}class Dn{constructor(c,m,v,N){this._imageWarnHistory={},this.type=mb,this.namePrimary=c,this.nameSecondary=m,v&&(this.paramsPrimary=v.params,this.iconsetIdPrimary=v.iconset?v.iconset.id:void 0),N&&(this.paramsSecondary=N.params,this.iconsetIdSecondary=N.iconset?N.iconset.id:void 0)}static parse(c,m){if(c.length<2)return m.error("Expected two or more arguments.");let v=1;const N=[];function E(){if(vKs.isEqual(P,E)),N.available){const P=N.getSecondary()?N.getSecondary().id:null;P&&(N.available=c.availableImages.some(O=>Ks.isEqual(O,P)))}}return N}eachChild(c){if(c(this.namePrimary),this.paramsPrimary)for(const m in this.paramsPrimary)this.paramsPrimary[m]&&c(this.paramsPrimary[m]);if(this.nameSecondary&&(c(this.nameSecondary),this.paramsSecondary))for(const m in this.paramsSecondary)this.paramsSecondary[m]&&c(this.paramsSecondary[m])}outputDefined(){return!1}serializeOptions(c,m){const v={};if(m&&(v.iconset={id:m}),c){v.params={};for(const N in c)c[N]&&(v.params[N]=c[N].serialize())}return Object.keys(v).length>0?v:void 0}serialize(){const c=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const m=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);m&&c.push(m)}if(this.nameSecondary&&(c.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const m=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);m&&c.push(m)}return c}}function Lr(g){return dn(g)?"string":bv(g)?"number":kS(g)?"boolean":Array.isArray(g)?"array":g===null?"null":NS(g)?"object":typeof g}function NS(g){return g!=null&&!Array.isArray(g)&&typeof g!="function"&&!(g instanceof String||g instanceof Number||g instanceof Boolean)&&typeof g=="object"}function dn(g){return typeof g=="string"||g instanceof String}function bv(g){return typeof g=="number"||g instanceof Number}function kS(g){return typeof g=="boolean"||g instanceof Boolean}const rn={"to-boolean":pi,"to-color":ku,"to-number":Rr,"to-string":ja};class Dp{constructor(c,m){this.type=c,this.args=m}static parse(c,m){if(c.length<2)return m.error("Expected at least one argument.");const v=c[0],N=[];let E=Wm;if(v==="to-array"){if(!Array.isArray(c[1]))return null;const P=c[1].length;if(m.expectedType){if(m.expectedType.kind!=="array")return m.error(`Expected ${m.expectedType.kind} but found array.`);E=md(m.expectedType.itemType,P)}else{if(!(P>0&&_v(c[1][0])))return null;E=md(oc(c[1][0]),P)}for(let O=0;O4?`Invalid rbga value ${JSON.stringify(m)}: expected an array containing either three or four numeric values.`:Ey(m[0],m[1],m[2],m[3]),!v))return new Fr(m[0]/255,m[1]/255,m[2]/255,m[3])}throw new Hl(v||`Could not parse color from value '${typeof m=="string"?m:String(JSON.stringify(m))}'`)}if(this.type.kind==="number"){let m=null;for(const v of this.args){if(m=v.evaluate(c),m===null)return 0;const N=Number(m);if(!isNaN(N))return N}throw new Hl(`Could not convert ${JSON.stringify(m)} to number.`)}return this.type.kind==="formatted"?Qd.fromString(om(this.args[0].evaluate(c))):this.type.kind==="resolvedImage"?Jd.build(om(this.args[0].evaluate(c))):this.type.kind==="array"?this.args.map(m=>m.evaluate(c)):om(this.args[0].evaluate(c))}eachChild(c){this.args.forEach(c)}outputDefined(){return this.args.every(c=>c.outputDefined())}serialize(){if(this.type.kind==="formatted")return new Lp([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Dn(this.args[0]).serialize();const c=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(m=>{c.push(m.serialize())}),c}}const aT=["Unknown","Point","LineString","Polygon"];class SS{constructor(c,m,v){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=c,this.options=m,this.iconImageUseTheme=v}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?aT[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(c){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const c=this.featureDistanceData.center,m=this.featureDistanceData.scale,{x:v,y:N}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(v*m-c[0])+this.featureDistanceData.bearing[1]*(N*m-c[1])}return 0}parseColor(c){let m=this._parseColorCache[c];return m||(m=this._parseColorCache[c]=Fr.parse(c)),m}getConfig(c){return this.options?this.options.get(c):null}}class eu{constructor(c,m,v,N,E){this.name=c,this.type=m,this._evaluate=v,this.args=N,this._overloadIndex=E}evaluate(c){if(!this._evaluate){const m=eu.definitions[this.name];this._evaluate=Array.isArray(m)?m[2]:m.overloads[this._overloadIndex][1]}return this._evaluate(c,this.args)}eachChild(c){this.args.forEach(c)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(c=>c.serialize()))}static parse(c,m){const v=c[0],N=eu.definitions[v];if(!N)return m.error(`Unknown expression "${v}". If you wanted a literal array, use ["literal", [...]].`,0);const E=Array.isArray(N)?N[0]:N.type,P=Array.isArray(N)?[[N[1],N[2]]]:N.overloads,O=[];let B=null,W=-1;for(const[J,ee]of P){if(Array.isArray(J)&&J.length!==c.length-1)continue;O.push(J),W++,B=new FS(m.registry,m.path,null,m.scope,void 0,m._scope,m.options,m.iconImageUseTheme);const ie=[];let ce=!1;for(let ue=1;ueie)).map(CS).join(" | "),ee=[];for(let ie=1;iem;){if(v-m>600){const B=v-m+1,W=c-m+1,J=Math.log(B),ee=.5*Math.exp(2*J/3),ie=.5*Math.sqrt(J*ee*(B-ee)/B)*(W-B/2<0?-1:1);MS(g,c,Math.max(m,Math.floor(c-W*ee/B+ie)),Math.min(v,Math.floor(c+(B-W)*ee/B+ie)),N)}const E=g[c];let P=m,O=v;for(Km(g,m,c),N(g[v],E)>0&&Km(g,m,v);P0;)O--}N(g[m],E)===0?Km(g,m,O):(O++,Km(g,O,v)),O<=c&&(m=O+1),c<=O&&(v=O-1)}}function Km(g,c,m){const v=g[c];g[c]=g[m],g[m]=v}function iT(g,c){return gc?1:0}function cx(g){let c=0;for(let m,v,N=0,E=g.length,P=E-1;N=c[2]||g[1]<=c[1]||g[3]>=c[3])}function Wce(g,c,m){const v=g[0]-c[0],N=g[1]-c[1],E=g[0]-m[0],P=g[1]-m[1];return v*P-E*N==0&&v*E<=0&&N*P<=0}function wv(g,c,m=!1){let v=!1;for(let O=0,B=c.length;O(N=g)[1]!=(P=ue)[1]>N[1]&&N[0]<(P[0]-E[0])*(N[1]-E[1])/(P[1]-E[1])+E[0]&&(v=!v)}}var N,E,P;return v}function gb(g,c,m,v){const N=v[0]-m[0],E=v[1]-m[1],P=(g[0]-m[0])*E-N*(g[1]-m[1]),O=(c[0]-m[0])*E-N*(c[1]-m[1]);return P>0&&O<0||P<0&&O>0}function xb(g,c,m,v){return(N=[v[0]-m[0],v[1]-m[1]])[0]*(E=[c[0]-g[0],c[1]-g[1]])[1]-N[1]*E[0]!=0&&!(!gb(g,c,m,v)||!gb(m,v,g,c));var N,E}function Wf(g){const c=new es(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),m=new es(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const v of g[0])c.x>v.x&&(c.x=v.x),c.y>v.y&&(c.y=v.y),m.xm[2]){const N=.5*v;let E=g[0]-m[0]>N?-v:m[0]-g[0]>N?v:0;E===0&&(E=g[0]-m[2]>N?-v:m[2]-g[0]>N?v:0),g[0]+=E}lm(c,g)}function wD(g,c,m,v){const N=Math.pow(2,v.z)*dx,E=[v.x*dx,v.y*dx],P=[];if(!g)return P;for(const O of g)for(const B of O){const W=[B.x+E[0],B.y+E[1]];bD(W,c,m,N),P.push(W)}return P}function TS(g,c,m,v){const N=Math.pow(2,v.z)*dx,E=[v.x*dx,v.y*dx],P=[];if(!g)return P;for(const B of g){const W=[];for(const J of B){const ee=[J.x+E[0],J.y+E[1]];lm(c,ee),W.push(ee)}P.push(W)}if(c[2]-c[0]<=N/2){(O=c)[0]=O[1]=1/0,O[2]=O[3]=-1/0;for(const B of P)for(const W of B)bD(W,c,m,N)}var O;return P}class hx{constructor(c,m){this.type=pi,this.geojson=c,this.geometries=m}static parse(c,m){if(c.length!==2)return m.error(`'within' expression requires exactly one argument, but found ${c.length-1} instead.`);if(_v(c[1])){const v=c[1];if(v.type==="FeatureCollection")for(let N=0;Nm)return AS(E,P,(m-(v-O))/O)}return c[c.length-1]}pointToSegmentDistance(c,m,v){let[N,E]=m,P=vh(v[0]-N)*this.kx,O=(v[1]-E)*this.ky;if(P!==0||O!==0){const B=(vh(c[0]-N)*this.kx*P+(c[1]-E)*this.ky*O)/(P*P+O*O);B>1?(N=v[0],E=v[1]):B>0&&(N+=P/this.kx*B,E+=O/this.ky*B)}return P=vh(c[0]-N)*this.kx,O=(c[1]-E)*this.ky,Math.sqrt(P*P+O*O)}pointOnLine(c,m){let v=1/0,N=c[0][0],E=c[0][1],P=0,O=0;for(let B=0;B1?(W=c[B+1][0],J=c[B+1][1]):ce>0&&(W+=ee/this.kx*ce,J+=ie/this.ky*ce)),ee=vh(m[0]-W)*this.kx,ie=(m[1]-J)*this.ky;const ue=ee*ee+ie*ie;ueE.index||N.index===E.index&&N.t>E.t){const W=N;N=E,E=W}const P=[N.point],O=N.index+1,B=E.index;!cT(v[O],P[0])&&O<=B&&P.push(v[O]);for(let W=O+1;W<=B;W++)P.push(v[W]);return cT(v[B],E.point)||P.push(E.point),P}lineSliceAlong(c,m,v){let N=0;const E=[];for(let P=0;Pc&&E.length===0&&E.push(AS(O,B,(c-(N-W))/W)),N>=m)return E.push(AS(O,B,(m-(N-W))/W)),E;N>c&&E.push(B)}return E}bufferPoint(c,m){const v=m/this.ky,N=m/this.kx;return[c[0]-N,c[1]-v,c[0]+N,c[1]+v]}bufferBBox(c,m){const v=m/this.ky,N=m/this.kx;return[c[0]-N,c[1]-v,c[2]+N,c[3]+v]}insideBBox(c,m){return vh(c[0]-m[0])>=0&&vh(c[0]-m[2])<=0&&c[1]>=m[1]&&c[1]<=m[3]}}function cT(g,c){return g[0]===c[0]&&g[1]===c[1]}function AS(g,c,m){const v=vh(c[0]-g[0]);return[g[0]+v*m,g[1]+(c[1]-g[1])*m]}function vh(g){for(;g<-180;)g+=360;for(;g>180;)g-=360;return g}class ES{constructor(c=[],m=(v,N)=>vN?1:0){if(this.data=c,this.length=this.data.length,this.compare=m,this.length>0)for(let v=(this.length>>1)-1;v>=0;v--)this._down(v)}push(c){this.data.push(c),this._up(this.length++)}pop(){if(this.length===0)return;const c=this.data[0],m=this.data.pop();return--this.length>0&&(this.data[0]=m,this._down(0)),c}peek(){return this.data[0]}_up(c){const{data:m,compare:v}=this,N=m[c];for(;c>0;){const E=c-1>>1,P=m[E];if(v(N,P)>=0)break;m[c]=P,c=E}m[c]=N}_down(c){const{data:m,compare:v}=this,N=this.length>>1,E=m[c];for(;c=0)break;m[c]=m[P],c=P}m[c]=E}}var Xs=8192;function dT(g,c){return c.dist-g.dist}const PS=100,IS=50;function uT(g){const c=[1/0,1/0,-1/0,-1/0];if(c.length!==g.length)return!1;for(let m=0;m=g[0]&&g[1]g[1])return[null,null];const m=vb(g);if(c){if(m===2)return[g,null];const v=Math.floor(m/2);return[[g[0],g[0]+v],[g[0]+v,g[1]]]}{if(m===1)return[g,null];const v=Math.floor(m/2)-1;return[[g[0],g[0]+v],[g[0]+v+1,g[1]]]}}function Py(g,c){const m=[1/0,1/0,-1/0,-1/0];if(!Op(c,g.length))return m;for(let v=c[0];v<=c[1];++v)lm(m,g[v]);return m}function Iy(g){const c=[1/0,1/0,-1/0,-1/0];for(let m=0;mc[2]&&(v=g[0]-c[2]),g[1]>c[3]&&(N=g[1]-c[3]),g[3]=v)return v;if(fb(N,E)){if(pT(g,c))return 0}else if(pT(c,g))return 0;let P=v;for(const O of g)for(let B=0,W=O.length,J=W-1;B=E)continue;const J=W.range1;if(vb(J)<=O){if(!Op(J,g.length))return NaN;if(c){const ee=Qce(g,J,m,v);if((E=Math.min(E,ee))===0)return E}else for(let ee=J[0];ee<=J[1];++ee){const ie=Xce(g[ee],m,v);if((E=Math.min(E,ie))===0)return E}}else{const ee=hT(J,c);if(ee[0]!==null){const ie=mx(Py(g,ee[0]),B,v);ie=P)continue;const ee=J.range1,ie=J.range2;if(vb(ee)<=B&&vb(ie)<=W){if(!Op(ee,g.length)||!Op(ie,m.length))return NaN;if(c&&v?P=Math.min(P,Sa(g,ee,m,ie,N)):c||v?c&&!v?P=Math.min(P,mT(m,ie,g,ee,N)):!c&&v&&(P=Math.min(P,mT(g,ee,m,ie,N))):P=Math.min(P,Yce(g,ee,m,ie,N)),P===0)return P}else{const ce=hT(ee,c),ue=hT(ie,v);to(O,P,N,g,m,ce[0],ue[0]),to(O,P,N,g,m,ce[0],ue[1]),to(O,P,N,g,m,ce[1],ue[0]),to(O,P,N,g,m,ce[1],ue[1])}}return P}function fT(g,c,m,v,N=1/0){let E=N;const P=Py(g,[0,g.length-1]);for(const O of m)if(!(E!==1/0&&mx(P,Py(O,[0,O.length-1]),v)>=E)&&(E=Math.min(E,SD(g,c,O,!0,v,E)),E===0))return E;return E}function OS(g,c,m,v,N=1/0){let E=N;const P=Py(g,[0,g.length-1]);for(const O of m){if(E!==1/0&&mx(P,Iy(O),v)>=E)continue;const B=ede(g,c,O,v,E);if(isNaN(B))return B;if((E=Math.min(E,B))===0)return E}return E}function gT(g){return g==="Point"||g==="MultiPoint"||g==="LineString"||g==="MultiLineString"||g==="Polygon"||g==="MultiPolygon"}class Ly{constructor(c,m){this.type=Rr,this.geojson=c,this.geometries=m}static parse(c,m){if(c.length!==2)return m.error(`'distance' expression requires either one argument, but found ' ${c.length-1} instead.`);if(_v(c[1])){const v=c[1];if(v.type==="FeatureCollection"){for(let N=0;N{c&&!kv(m)&&(c=!1)}),c}function _b(g){if(g instanceof eu&&g.name==="feature-state")return!1;let c=!0;return g.eachChild(m=>{c&&!_b(m)&&(c=!1)}),c}function Sv(g,c){if(g instanceof eu&&c.indexOf(g.name)>=0)return!1;let m=!0;return g.eachChild(v=>{m&&!Sv(v,c)&&(m=!1)}),m}function CD(g,c,m){return[g,c,m].filter(Boolean).join("")}function xT(g,c){switch(g){case"string":return om(c);case"number":return+c;case"boolean":return!!c;case"color":return Fr.parse(c);case"formatted":return Qd.fromString(om(c));case"resolvedImage":return Jd.build(om(c))}return c}function MD(g,c,m,v){return v!==void 0&&(g=v*Math.round(g/v)),c!==void 0&&gm&&(g=m),g}class Cv{constructor(c,m,v,N=!1){this.type=c,this.key=m,this.scope=v,this.featureConstant=N}static parse(c,m){let v=m.expectedType;if(v==null&&(v=ri),c.length<2||c.length>3)return m.error("Invalid number of arguments for 'config' expression.");const N=m.parse(c[1],1);if(!(N instanceof Hf))return m.error("Key name of 'config' expression must be a string literal.");let E,P=!0;const O=om(N.value);if(c.length>=3){const B=m.parse(c[2],2);if(!(B instanceof Hf))return m.error("Scope of 'config' expression must be a string literal.");E=om(B.value)}if(m.options){const B=CD(O,E,m._scope),W=m.options.get(B);W&&(P=kv(W.value||W.default))}return new Cv(v,O,E,P)}evaluate(c){const m=CD(this.key,this.scope,c.scope),v=c.getConfig(m);if(!v)return null;const{type:N,value:E,values:P,minValue:O,maxValue:B,stepValue:W}=v,J=v.default.evaluate(c);let ee=J;if(E){const ie=c.scope;c.scope=(ie||"").split("").slice(1).join(""),ee=E.evaluate(c),c.scope=ie}return N&&(ee=xT(N,ee)),ee===void 0||O===void 0&&B===void 0&&W===void 0||(typeof ee=="number"?ee=MD(ee,O,B,W):Array.isArray(ee)&&(ee=ee.map(ie=>typeof ie=="number"?MD(ie,O,B,W):ie))),E!==void 0&&ee!==void 0&&P&&!P.includes(ee)&&(ee=J,N&&(ee=xT(N,ee))),(N&&N!==this.type||ee!==void 0&&!wS(oc(ee),this.type))&&(ee=xT(this.type.kind,ee)),ee}eachChild(){}outputDefined(){return!1}serialize(){const c=["config",this.key];return this.scope&&c.concat(this.scope),c}}class RS{constructor(c,m){this.type=m.type,this.name=c,this.boundExpression=m}static parse(c,m){if(c.length!==2||typeof c[1]!="string")return m.error("'var' expression requires exactly one string literal argument.");const v=c[1];return m.scope.has(v)?new RS(v,m.scope.get(v)):m.error(`Unknown variable "${v}". Make sure "${v}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(c){return this.boundExpression.evaluate(c)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class FS{constructor(c,m=[],v,N=new vv,E=[],P,O,B){this.registry=c,this.path=m,this.key=m.map(W=>typeof W=="string"?`['${W}']`:`[${W}]`).join(""),this.scope=N,this.errors=E,this.expectedType=v,this._scope=P,this.options=O,this.iconImageUseTheme=B}parse(c,m,v,N,E={}){return m||v?this.concat(m,null,v,N)._parse(c,E):this._parse(c,E)}parseObjectValue(c,m,v,N,E,P={}){return this.concat(m,v,N,E)._parse(c,P)}_parse(c,m){function v(N,E,P){return P==="assert"?new Gm(E,[N]):P==="coerce"?new Dp(E,[N]):N}if(c!==null&&typeof c!="string"&&typeof c!="boolean"&&typeof c!="number"||(c=["literal",c]),Array.isArray(c)){if(c.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const N=typeof c[0]=="string"?this.registry[c[0]]:void 0;if(N){let E=N.parse(c,this);if(!E)return null;if(this.expectedType){const P=this.expectedType,O=E.type;if(P.kind!=="string"&&P.kind!=="number"&&P.kind!=="boolean"&&P.kind!=="object"&&P.kind!=="array"||O.kind!=="value")if(P.kind!=="color"&&P.kind!=="formatted"&&P.kind!=="resolvedImage"||O.kind!=="value"&&O.kind!=="string"){if(this.checkSubtype(P,O))return null}else E=v(E,P,m.typeAnnotation||"coerce");else E=v(E,P,m.typeAnnotation||"assert")}if(!(E instanceof Hf)&&E.type.kind!=="resolvedImage"&&yT(E)){const P=new SS(this._scope,this.options,this.iconImageUseTheme);try{E=new Hf(E.type,E.evaluate(P))}catch(O){return this.error(O.message),null}}return E}return Dp.parse(["to-array",c],this)}return this.error(c===void 0?"'undefined' value invalid. Use null instead.":typeof c=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof c} instead.`)}concat(c,m,v,N){let E=typeof c=="number"?this.path.concat(c):this.path;E=typeof m=="string"?E.concat(m):E;const P=N?this.scope.concat(N):this.scope;return new FS(this.registry,E,v||null,P,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(c,...m){const v=`${this.key}${m.map(N=>`[${N}]`).join("")}`;this.errors.push(new im(v,c))}checkSubtype(c,m){const v=lx(c,m);return v&&this.error(v),v}}function yT(g){if(g instanceof RS)return yT(g.boundExpression);if(g instanceof eu&&g.name==="error"||g instanceof _c||g instanceof hx||g instanceof Ly||g instanceof Cv)return!1;const c=g instanceof Dp||g instanceof Gm;let m=!0;return g.eachChild(v=>{m=c?m&&yT(v):m&&v instanceof Hf}),!!m&&kv(g)&&Sv(g,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function zS(g,c){const m=g.length-1;let v,N,E=0,P=m,O=0;for(;E<=P;)if(O=Math.floor((E+P)/2),v=g[O],N=g[O+1],v<=c){if(O===m||cc))throw new Hl("Input is not a number.");P=O-1}return 0}class bb{constructor(c,m,v){this.type=c,this.input=m,this.labels=[],this.outputs=[];for(const[N,E]of v)this.labels.push(N),this.outputs.push(E)}static parse(c,m){if(c.length-1<4)return m.error(`Expected at least 4 arguments, but found only ${c.length-1}.`);if((c.length-1)%2!=0)return m.error("Expected an even number of arguments.");const v=m.parse(c[1],1,Rr);if(!v)return null;const N=[];let E=null;m.expectedType&&m.expectedType.kind!=="value"&&(E=m.expectedType);for(let P=1;P=O)return m.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',W);const ee=m.parse(B,J,E);if(!ee)return null;E=E||ee.type,N.push([O,ee])}return new bb(E,v,N)}evaluate(c){const m=this.labels,v=this.outputs;if(m.length===1)return v[0].evaluate(c);const N=this.input.evaluate(c);if(N<=m[0])return v[0].evaluate(c);const E=m.length;return N>=m[E-1]?v[E-1].evaluate(c):v[zS(m,N)].evaluate(c)}eachChild(c){c(this.input);for(const m of this.outputs)c(m)}outputDefined(){return this.outputs.every(c=>c.outputDefined())}serialize(){const c=["step",this.input.serialize()];for(let m=0;m0&&c.push(this.labels[m]),c.push(this.outputs[m].serialize());return c}}const TD=.95047,AD=1.08883,ED=4/29,Mv=6/29,PD=3*Mv*Mv,tde=Mv*Mv*Mv,sde=Math.PI/180,rde=180/Math.PI;function vT(g){return g>tde?Math.pow(g,1/3):g/PD+ED}function _T(g){return g>Mv?g*g*g:PD*(g-ED)}function bT(g){return 255*(g<=.0031308?12.92*g:1.055*Math.pow(g,1/2.4)-.055)}function wT(g){return(g/=255)<=.04045?g/12.92:Math.pow((g+.055)/1.055,2.4)}function ID(g){const c=wT(g.r),m=wT(g.g),v=wT(g.b),N=vT((.4124564*c+.3575761*m+.1804375*v)/TD),E=vT((.2126729*c+.7151522*m+.072175*v)/1);return{l:116*E-16,a:500*(N-E),b:200*(E-vT((.0193339*c+.119192*m+.9503041*v)/AD)),alpha:g.a}}function BS(g){let c=(g.l+16)/116,m=isNaN(g.a)?c:c+g.a/500,v=isNaN(g.b)?c:c-g.b/200;return c=1*_T(c),m=TD*_T(m),v=AD*_T(v),new Fr(bT(3.2404542*m-1.5371385*c-.4985314*v),bT(-.969266*m+1.8760108*c+.041556*v),bT(.0556434*m-.2040259*c+1.0572252*v),g.alpha)}function $S(g,c,m){const v=c-g;return g+m*(v>180||v<-180?v-360*Math.round(v/360):v)}const Tv={forward:ID,reverse:BS,interpolate:function(g,c,m){return{l:Hr(g.l,c.l,m),a:Hr(g.a,c.a,m),b:Hr(g.b,c.b,m),alpha:Hr(g.alpha,c.alpha,m)}}},wb={forward:function(g){const{l:c,a:m,b:v}=ID(g),N=Math.atan2(v,m)*rde;return{h:N<0?N+360:N,c:Math.sqrt(m*m+v*v),l:c,alpha:g.a}},reverse:function(g){const c=g.h*sde,m=g.c;return BS({l:g.l,a:Math.cos(c)*m,b:Math.sin(c)*m,alpha:g.alpha})},interpolate:function(g,c,m){return{h:$S(g.h,c.h,m),c:Hr(g.c,c.c,m),l:Hr(g.l,c.l,m),alpha:Hr(g.alpha,c.alpha,m)}}};var LD=Object.freeze({__proto__:null,hcl:wb,lab:Tv});class _h{constructor(c,m,v,N,E){this.type=c,this.operator=m,this.interpolation=v,this.input=N,this.labels=[],this.outputs=[];for(const[P,O]of E)this.labels.push(P),this.outputs.push(O)}static interpolationFactor(c,m,v,N){let E=0;if(c.name==="exponential")E=qS(m,c.base,v,N);else if(c.name==="linear")E=qS(m,1,v,N);else if(c.name==="cubic-bezier"){const P=c.controlPoints;E=new $r(P[0],P[1],P[2],P[3]).solve(qS(m,1,v,N))}return E}static parse(c,m){let[v,N,E,...P]=c;if(!Array.isArray(N)||N.length===0)return m.error("Expected an interpolation type expression.",1);if(N[0]==="linear")N={name:"linear"};else if(N[0]==="exponential"){const W=N[1];if(typeof W!="number")return m.error("Exponential interpolation requires a numeric base.",1,1);N={name:"exponential",base:W}}else{if(N[0]!=="cubic-bezier")return m.error(`Unknown interpolation type ${String(N[0])}`,1,0);{const W=N.slice(1);if(W.length!==4||W.some(J=>typeof J!="number"||J<0||J>1))return m.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);N={name:"cubic-bezier",controlPoints:W}}}if(c.length-1<4)return m.error(`Expected at least 4 arguments, but found only ${c.length-1}.`);if(c.length-1>3&&(c.length-1)%2!=0)return m.error("Expected an even number of arguments.");if(E=m.parse(E,2,Rr),!E)return null;const O=[];let B=null;v==="interpolate-hcl"||v==="interpolate-lab"?B=ku:m.expectedType&&m.expectedType.kind!=="value"&&(B=m.expectedType);for(let W=0;W=J)return m.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',ie);const ue=m.parse(ee,ce,B);if(!ue)return null;B=B||ue.type,O.push([J,ue])}return B.kind==="number"||B.kind==="color"||B.kind==="array"&&B.itemType.kind==="number"&&typeof B.N=="number"?new _h(B,v,N,E,O):m.error(`Type ${rl(B)} is not interpolatable.`)}evaluate(c){const m=this.labels,v=this.outputs;if(m.length===1)return v[0].evaluate(c);const N=this.input.evaluate(c);if(N<=m[0])return v[0].evaluate(c);const E=m.length;if(N>=m[E-1])return v[E-1].evaluate(c);const P=zS(m,N),O=_h.interpolationFactor(this.interpolation,N,m[P],m[P+1]),B=v[P].evaluate(c),W=v[P+1].evaluate(c);return this.operator==="interpolate"?Ay[this.type.kind.toLowerCase()](B,W,O):this.operator==="interpolate-hcl"?wb.reverse(wb.interpolate(wb.forward(B),wb.forward(W),O)):Tv.reverse(Tv.interpolate(Tv.forward(B),Tv.forward(W),O))}eachChild(c){c(this.input);for(const m of this.outputs)c(m)}outputDefined(){return this.outputs.every(c=>c.outputDefined())}serialize(){let c;c=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const m=[this.operator,c,this.input.serialize()];for(let v=0;vlx(N,O.type));return new jb(P?ri:v,E)}evaluate(c){let m,v=null,N=0;for(const E of this.args){if(N++,v=E.evaluate(c),v&&v instanceof Jd&&!v.available&&(m||(m=v),v=null,N===this.args.length))return m;if(v!==null)break}return v}eachChild(c){this.args.forEach(c)}outputDefined(){return this.args.every(c=>c.outputDefined())}serialize(){const c=["coalesce"];return this.eachChild(m=>{c.push(m.serialize())}),c}}class Gf{constructor(c,m){this.type=m.type,this.bindings=[].concat(c),this.result=m}evaluate(c){return this.result.evaluate(c)}eachChild(c){for(const m of this.bindings)c(m[1]);c(this.result)}static parse(c,m){if(c.length<4)return m.error(`Expected at least 3 arguments, but found ${c.length-1} instead.`);const v=[];for(let E=1;E=v.length)throw new Hl("Array index out of bounds: index exceeds array size");if(m!==Math.floor(m))throw new Hl("Array index must be an integer. Use at-interpolated for fractional indices");return v[m]}eachChild(c){c(this.index),c(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class VS{constructor(c,m,v){this.type=c,this.index=m,this.input=v}static parse(c,m){if(c.length!==3)return m.error(`Expected 2 arguments, but found ${c.length-1} instead.`);const v=m.parse(c[1],1,Rr),N=m.parse(c[2],2,md(m.expectedType||ri));return v&&N?new VS(N.type.itemType,v,N):null}evaluate(c){const m=this.index.evaluate(c),v=this.input.evaluate(c);if(m<0)throw new Hl(`Array index out of bounds: ${m} < 0.`);if(m>v.length-1)throw new Hl(`Array index out of bounds: ${m} > ${v.length-1}.`);if(m===Math.floor(m))return v[m];const N=Math.floor(m),E=Math.ceil(m),P=v[N],O=v[E];if(typeof P!="number"||typeof O!="number")throw new Hl(`Cannot interpolate between non-number values at index ${m}.`);const B=m-N;return P*(1-B)+O*B}eachChild(c){c(this.index),c(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class jT{constructor(c,m){this.type=pi,this.needle=c,this.haystack=m}static parse(c,m){if(c.length!==3)return m.error(`Expected 2 arguments, but found ${c.length-1} instead.`);const v=m.parse(c[1],1,ri),N=m.parse(c[2],2,ri);return v&&N?sT(v.type,[pi,ja,Rr,Wm,ri])?new jT(v,N):m.error(`Expected first argument to be of type boolean, string, number or null, but found ${rl(v.type)} instead`):null}evaluate(c){const m=this.needle.evaluate(c),v=this.haystack.evaluate(c);if(v==null)return!1;if(!pb(m,["boolean","string","number","null"]))throw new Hl(`Expected first argument to be of type boolean, string, number or null, but found ${rl(oc(m))} instead.`);if(!pb(v,["string","array"]))throw new Hl(`Expected second argument to be of type array or string, but found ${rl(oc(v))} instead.`);return v.indexOf(m)>=0}eachChild(c){c(this.needle),c(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class Av{constructor(c,m,v){this.type=Rr,this.needle=c,this.haystack=m,this.fromIndex=v}static parse(c,m){if(c.length<=2||c.length>=5)return m.error(`Expected 3 or 4 arguments, but found ${c.length-1} instead.`);const v=m.parse(c[1],1,ri),N=m.parse(c[2],2,ri);if(!v||!N)return null;if(!sT(v.type,[pi,ja,Rr,Wm,ri]))return m.error(`Expected first argument to be of type boolean, string, number or null, but found ${rl(v.type)} instead`);if(c.length===4){const E=m.parse(c[3],3,Rr);return E?new Av(v,N,E):null}return new Av(v,N)}evaluate(c){const m=this.needle.evaluate(c),v=this.haystack.evaluate(c);if(!pb(m,["boolean","string","number","null"]))throw new Hl(`Expected first argument to be of type boolean, string, number or null, but found ${rl(oc(m))} instead.`);if(!pb(v,["string","array"]))throw new Hl(`Expected second argument to be of type array or string, but found ${rl(oc(v))} instead.`);if(this.fromIndex){const N=this.fromIndex.evaluate(c);return v.indexOf(m,N)}return v.indexOf(m)}eachChild(c){c(this.needle),c(this.haystack),this.fromIndex&&c(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const c=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),c]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class Nb{constructor(c,m,v,N,E,P){this.inputType=c,this.type=m,this.input=v,this.cases=N,this.outputs=E,this.otherwise=P}static parse(c,m){if(c.length<5)return m.error(`Expected at least 4 arguments, but found only ${c.length-1}.`);if(c.length%2!=1)return m.error("Expected an even number of arguments.");let v,N;m.expectedType&&m.expectedType.kind!=="value"&&(N=m.expectedType);const E={},P=[];for(let W=2;WNumber.MAX_SAFE_INTEGER)return ie.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof ue=="number"&&Math.floor(ue)!==ue)return ie.error("Numeric branch labels must be integer values.");if(v){if(ie.checkSubtype(v,oc(ue)))return null}else v=oc(ue);if(E[String(ue)]!==void 0)return ie.error("Branch labels must be unique.");E[String(ue)]=P.length}const ce=m.parse(ee,W,N);if(!ce)return null;N=N||ce.type,P.push(ce)}const O=m.parse(c[1],1,ri);if(!O)return null;const B=m.parse(c[c.length-1],c.length-1,N);return B?O.type.kind!=="value"&&m.concat(1).checkSubtype(v,O.type)?null:new Nb(v,N,O,E,P,B):null}evaluate(c){const m=this.input.evaluate(c);return(wS(oc(m),this.inputType)&&this.outputs[this.cases[m]]||this.otherwise).evaluate(c)}eachChild(c){c(this.input),this.outputs.forEach(c),c(this.otherwise)}outputDefined(){return this.outputs.every(c=>c.outputDefined())&&this.otherwise.outputDefined()}serialize(){const c=["match",this.input.serialize()],m=Object.keys(this.cases).sort(),v=[],N={};for(const P of m){const O=N[this.cases[P]];O===void 0?(N[this.cases[P]]=v.length,v.push([this.cases[P],[P]])):v[O][1].push(P)}const E=P=>this.inputType.kind==="number"?Number(P):P;for(const[P,O]of v)c.push(O.length===1?E(O[0]):O.map(E)),c.push(this.outputs[P].serialize());return c.push(this.otherwise.serialize()),c}}class kb{constructor(c,m,v){this.type=c,this.branches=m,this.otherwise=v}static parse(c,m){if(c.length<4)return m.error(`Expected at least 3 arguments, but found only ${c.length-1}.`);if(c.length%2!=0)return m.error("Expected an odd number of arguments.");let v;m.expectedType&&m.expectedType.kind!=="value"&&(v=m.expectedType);const N=[];for(let P=1;Pm.outputDefined())&&this.otherwise.outputDefined()}serialize(){const c=["case"];return this.eachChild(m=>{c.push(m.serialize())}),c}}class HS{constructor(c,m,v,N){this.type=c,this.input=m,this.beginIndex=v,this.endIndex=N}static parse(c,m){if(c.length<=2||c.length>=5)return m.error(`Expected 3 or 4 arguments, but found ${c.length-1} instead.`);const v=m.parse(c[1],1,ri),N=m.parse(c[2],2,Rr);if(!v||!N)return null;if(!sT(v.type,[md(ri),ja,ri]))return m.error(`Expected first argument to be of type array or string, but found ${rl(v.type)} instead`);if(c.length===4){const E=m.parse(c[3],3,Rr);return E?new HS(v.type,v,N,E):null}return new HS(v.type,v,N)}evaluate(c){const m=this.input.evaluate(c),v=this.beginIndex.evaluate(c);if(!pb(m,["string","array"]))throw new Hl(`Expected first argument to be of type array or string, but found ${rl(oc(m))} instead.`);if(this.endIndex){const N=this.endIndex.evaluate(c);return m.slice(v,N)}return m.slice(v)}eachChild(c){c(this.input),c(this.beginIndex),this.endIndex&&c(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const c=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),c]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}class NT{constructor(c,m){this.type=md(ja),this.str=c,this.delimiter=m}static parse(c,m){if(c.length!==3)return m.error(`Expected 2 arguments, but found ${c.length-1} instead.`);const v=m.parse(c[1],1,ja),N=m.parse(c[2],2,ja);return v&&N?new NT(v,N):void 0}evaluate(c){const m=this.str.evaluate(c),v=this.delimiter.evaluate(c);return m.split(v)}eachChild(c){c(this.str),c(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function kT(g,c){return g==="=="||g==="!="?c.kind==="boolean"||c.kind==="string"||c.kind==="number"||c.kind==="null"||c.kind==="value":c.kind==="string"||c.kind==="number"||c.kind==="value"}function ST(g,c,m,v){return v.compare(c,m)===0}function Ev(g,c,m){const v=g!=="=="&&g!=="!=";return class $Be{constructor(E,P,O){this.type=pi,this.lhs=E,this.rhs=P,this.collator=O,this.hasUntypedArgument=E.type.kind==="value"||P.type.kind==="value"}static parse(E,P){if(E.length!==3&&E.length!==4)return P.error("Expected two or three arguments.");const O=E[0];let B=P.parse(E[1],1,ri);if(!B)return null;if(!kT(O,B.type))return P.concat(1).error(`"${O}" comparisons are not supported for type '${rl(B.type)}'.`);let W=P.parse(E[2],2,ri);if(!W)return null;if(!kT(O,W.type))return P.concat(2).error(`"${O}" comparisons are not supported for type '${rl(W.type)}'.`);if(B.type.kind!==W.type.kind&&B.type.kind!=="value"&&W.type.kind!=="value")return P.error(`Cannot compare types '${rl(B.type)}' and '${rl(W.type)}'.`);v&&(B.type.kind==="value"&&W.type.kind!=="value"?B=new Gm(W.type,[B]):B.type.kind!=="value"&&W.type.kind==="value"&&(W=new Gm(B.type,[W])));let J=null;if(E.length===4){if(B.type.kind!=="string"&&W.type.kind!=="string"&&B.type.kind!=="value"&&W.type.kind!=="value")return P.error("Cannot use collator to compare non-string types.");if(J=P.parse(E[3],3,bS),!J)return null}return new $Be(B,W,J)}evaluate(E){const P=this.lhs.evaluate(E),O=this.rhs.evaluate(E);if(v&&this.hasUntypedArgument){const B=oc(P),W=oc(O);if(B.kind!==W.kind||B.kind!=="string"&&B.kind!=="number")throw new Hl(`Expected arguments for "${g}" to be (string, string) or (number, number), but found (${B.kind}, ${W.kind}) instead.`)}if(this.collator&&!v&&this.hasUntypedArgument){const B=oc(P),W=oc(O);if(B.kind!=="string"||W.kind!=="string")return c(E,P,O)}return this.collator?m(E,P,O,this.collator.evaluate(E)):c(E,P,O)}eachChild(E){E(this.lhs),E(this.rhs),this.collator&&E(this.collator)}outputDefined(){return!0}serialize(){const E=[g];return this.eachChild(P=>{E.push(P.serialize())}),E}}}const nde=Ev("==",function(g,c,m){return c===m},ST),ade=Ev("!=",function(g,c,m){return c!==m},function(g,c,m,v){return!ST(0,c,m,v)}),DD=Ev("<",function(g,c,m){return c",function(g,c,m){return c>m},function(g,c,m,v){return v.compare(c,m)>0}),WS=Ev("<=",function(g,c,m){return c<=m},function(g,c,m,v){return v.compare(c,m)<=0}),ide=Ev(">=",function(g,c,m){return c>=m},function(g,c,m,v){return v.compare(c,m)>=0});class GS{constructor(c,m,v,N,E,P){this.type=ja,this.number=c,this.locale=m,this.currency=v,this.unit=N,this.minFractionDigits=E,this.maxFractionDigits=P}static parse(c,m){if(c.length!==3)return m.error("Expected two arguments.");const v=m.parse(c[1],1,Rr);if(!v)return null;const N=c[2];if(typeof N!="object"||Array.isArray(N))return m.error("NumberFormat options argument must be an object.");let E=null;if(N.locale&&(E=m.parseObjectValue(N.locale,2,"locale",ja),!E))return null;let P=null;if(N.currency&&(P=m.parseObjectValue(N.currency,2,"currency",ja),!P))return null;let O=null;if(N.unit&&(O=m.parseObjectValue(N.unit,2,"unit",ja),!O))return null;let B=null;if(N["min-fraction-digits"]&&(B=m.parseObjectValue(N["min-fraction-digits"],2,"min-fraction-digits",Rr),!B))return null;let W=null;return N["max-fraction-digits"]&&(W=m.parseObjectValue(N["max-fraction-digits"],2,"max-fraction-digits",Rr),!W)?null:new GS(v,E,P,O,B,W)}evaluate(c){return new Intl.NumberFormat(this.locale?this.locale.evaluate(c):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(c):void 0,unit:this.unit?this.unit.evaluate(c):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(c):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(c):void 0}).format(this.number.evaluate(c))}eachChild(c){c(this.number),this.locale&&c(this.locale),this.currency&&c(this.currency),this.unit&&c(this.unit),this.minFractionDigits&&c(this.minFractionDigits),this.maxFractionDigits&&c(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const c={};return this.locale&&(c.locale=this.locale.serialize()),this.currency&&(c.currency=this.currency.serialize()),this.unit&&(c.unit=this.unit.serialize()),this.minFractionDigits&&(c["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(c["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),c]}}class CT{constructor(c){this.type=Rr,this.input=c}static parse(c,m){if(c.length!==2)return m.error(`Expected 1 argument, but found ${c.length-1} instead.`);const v=m.parse(c[1],1);return v?v.type.kind!=="array"&&v.type.kind!=="string"&&v.type.kind!=="value"?m.error(`Expected argument of type string or array, but found ${rl(v.type)} instead.`):new CT(v):null}evaluate(c){const m=this.input.evaluate(c);if(typeof m=="string"||Array.isArray(m))return m.length;throw new Hl(`Expected value to be of type string or array, but found ${rl(oc(m))} instead.`)}eachChild(c){c(this.input)}outputDefined(){return!1}serialize(){const c=["length"];return this.eachChild(m=>{c.push(m.serialize())}),c}}function RD(g){return function(){g=1831565813+(g|=0)|0;let c=Math.imul(g^g>>>15,1|g);return c=c+Math.imul(c^c>>>7,61|c)^c,((c^c>>>14)>>>0)/4294967296}}const Pv={"==":nde,"!=":ade,">":OD,"<":DD,">=":ide,"<=":WS,array:Gm,at:US,"at-interpolated":VS,boolean:Gm,case:kb,coalesce:jb,collator:_c,format:Lp,image:Dn,in:jT,"index-of":Av,interpolate:_h,"interpolate-hcl":_h,"interpolate-lab":_h,length:CT,let:Gf,literal:Hf,match:Nb,number:Gm,"number-format":GS,object:Gm,slice:HS,step:bb,string:Gm,"to-boolean":Dp,"to-color":Dp,"to-number":Dp,"to-string":Dp,var:RS,within:hx,distance:Ly,config:Cv,split:NT};function MT(g,[c,m,v,N]){c=c.evaluate(g),m=m.evaluate(g),v=v.evaluate(g);const E=N?N.evaluate(g):1,P=Ey(c,m,v,E);if(P)throw new Hl(P);return new Fr(c/255,m/255,v/255,E)}function TT(g,[c,m,v,N]){c=c.evaluate(g),m=m.evaluate(g),v=v.evaluate(g);const E=N?N.evaluate(g):1,P=function(W,J,ee,ie){return typeof W=="number"&&W>=0&&W<=360?typeof J=="number"&&J>=0&&J<=100&&typeof ee=="number"&&ee>=0&&ee<=100?ie===void 0||typeof ie=="number"&&ie>=0&&ie<=1?null:`Invalid hsla value [${[W,J,ee,ie].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof ie=="number"?[W,J,ee,ie]:[W,J,ee]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof ie=="number"?[W,J,ee,ie]:[W,J,ee]).join(", ")}]: 'h' must be between 0 and 360.`}(c,m,v,E);if(P)throw new Hl(P);const O=`hsla(${c}, ${m}%, ${v}%, ${E})`,B=Fr.parse(O);if(!B)throw new Hl(`Failed to parse HSLA color: ${O}`);return B}function FD(g,c){return g in c}function AT(g,c){const m=c[g];return m===void 0?null:m}function fx(g){return{type:g}}function Dy(g){if(g instanceof Cv)return new Set([g.key]);let c=new Set;return g.eachChild(m=>{c=new Set([...c,...Dy(m)])}),c}function KS(g){if(g instanceof eu&&g.name==="is-active-floor")return!0;let c=!1;return g.eachChild(m=>{!c&&KS(m)&&(c=!0)}),c}function zD(g){return{result:"success",value:g}}function gx(g){return{result:"error",value:g}}function ET(g,c){return!!g&&!!g.parameters&&g.parameters.indexOf(c)>-1}function Sb(g){return g["property-type"]==="data-driven"}function BD(g){return ET(g.expression,"measure-light")}function $D(g){return ET(g.expression,"zoom")}function ZS(g){return!!g.expression&&g.expression.interpolated}function YS(g){return typeof g=="object"&&g!==null&&!Array.isArray(g)}function qD(g){return g}function UD(g,c){const m=c.type==="color",v=g.stops&&typeof g.stops[0][0]=="object",N=v||!(v||g.property!==void 0),E=g.type||(ZS(c)?"exponential":"interval");if(m&&((g=Object.assign({},g)).stops&&(g.stops=g.stops.map(W=>[W[0],Fr.parse(W[1])])),g.default=Fr.parse(g.default?g.default:c.default)),g.colorSpace&&g.colorSpace!=="rgb"&&!LD[g.colorSpace])throw new Error(`Unknown color space: ${g.colorSpace}`);let P,O,B;if(E==="exponential")P=VD;else if(E==="interval")P=lde;else if(E==="categorical"){P=ode,O=Object.create(null);for(const W of g.stops)O[W[0]]=W[1];B=typeof g.stops[0][0]}else{if(E!=="identity")throw new Error(`Unknown function type "${E}"`);P=HD}if(v){const W={},J=[];for(let ce=0;cece[0]),evaluate:({zoom:ce},ue)=>VD({stops:ee,base:g.base},c,ce).evaluate(ce,ue)}}if(N){const W=E==="exponential"?{name:"exponential",base:g.base!==void 0?g.base:1}:null;return{kind:"camera",interpolationType:W,interpolationFactor:_h.interpolationFactor.bind(void 0,W),zoomStops:g.stops.map(J=>J[0]),evaluate:({zoom:J})=>P(g,c,J,O,B)}}return{kind:"source",evaluate(W,J){const ee=J&&J.properties?J.properties[g.property]:void 0;return ee===void 0?Rp(g.default,c.default):P(g,c,ee,O,B)}}}function Rp(g,c,m){return g!==void 0?g:c!==void 0?c:m!==void 0?m:void 0}function ode(g,c,m,v,N){return Rp(typeof m===N?v[m]:void 0,g.default,c.default)}function lde(g,c,m){if(!bv(m))return Rp(g.default,c.default);const v=g.stops.length;if(v===1||m<=g.stops[0][0])return g.stops[0][1];if(m>=g.stops[v-1][0])return g.stops[v-1][1];const N=zS(g.stops.map(E=>E[0]),m);return g.stops[N][1]}function VD(g,c,m){const v=g.base!==void 0?g.base:1;if(!bv(m))return Rp(g.default,c.default);const N=g.stops.length;if(N===1||m<=g.stops[0][0])return g.stops[0][1];if(m>=g.stops[N-1][0])return g.stops[N-1][1];const E=zS(g.stops.map(J=>J[0]),m),P=function(J,ee,ie,ce){const ue=ce-ie,ke=J-ie;return ue===0?0:ee===1?ke/ue:(Math.pow(ee,ke)-1)/(Math.pow(ee,ue)-1)}(m,v,g.stops[E][0],g.stops[E+1][0]),O=g.stops[E][1],B=g.stops[E+1][1];let W=Ay[c.type]||qD;if(g.colorSpace&&g.colorSpace!=="rgb"){const J=LD[g.colorSpace];W=(ee,ie)=>J.reverse(J.interpolate(J.forward(ee),J.forward(ie),P))}return typeof O.evaluate=="function"?{evaluate(...J){const ee=O.evaluate.apply(void 0,J),ie=B.evaluate.apply(void 0,J);if(ee!==void 0&&ie!==void 0)return W(ee,ie,P)}}:W(O,B,P)}function HD(g,c,m){return c.type==="color"?m=Fr.parse(m):c.type==="formatted"?m=Qd.fromString(m.toString()):c.type==="resolvedImage"?m=Jd.build(m.toString()):Lr(m)===c.type||c.type==="enum"&&c.values[m]||(m=void 0),Rp(m,g.default,c.default)}eu.register(Pv,{error:[{kind:"error"},[ja],(g,[c])=>{throw new Hl(c.evaluate(g))}],typeof:[ja,[ri],(g,[c])=>rl(oc(c.evaluate(g)))],"to-rgba":[md(Rr,4),[ku],(g,[c])=>c.evaluate(g).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[md(Rr,4),[ku],(g,[c])=>c.evaluate(g).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[ku,[Rr,Rr,Rr],MT],rgba:[ku,[Rr,Rr,Rr,Rr],MT],hsl:[ku,[Rr,Rr,Rr],TT],hsla:[ku,[Rr,Rr,Rr,Rr],TT],has:{type:pi,overloads:[[[ja],(g,[c])=>FD(c.evaluate(g),g.properties())],[[ja,Ip],(g,[c,m])=>FD(c.evaluate(g),m.evaluate(g))]]},get:{type:ri,overloads:[[[ja],(g,[c])=>AT(c.evaluate(g),g.properties())],[[ja,Ip],(g,[c,m])=>AT(c.evaluate(g),m.evaluate(g))]]},"feature-state":[ri,[ja],(g,[c])=>AT(c.evaluate(g),g.featureState||{})],properties:[Ip,[],g=>g.properties()],"geometry-type":[ja,[],g=>g.geometryType()],worldview:[ja,[],g=>g.globals.worldview||""],"is-active-floor":[pi,fx(ja),(g,c)=>{if(!(g.globals.activeFloors&&g.globals.activeFloors.size>0))return!1;const m=g.globals.activeFloors;return c.some(v=>{const N=v.evaluate(g);return m.has(N)})}],id:[ri,[],g=>g.id()],zoom:[Rr,[],g=>g.globals.zoom],pitch:[Rr,[],g=>g.globals.pitch||0],"distance-from-center":[Rr,[],g=>g.distanceFromCenter()],"measure-light":[Rr,[ja],(g,[c])=>g.measureLight(c.evaluate(g))],"heatmap-density":[Rr,[],g=>g.globals.heatmapDensity||0],"line-progress":[Rr,[],g=>g.globals.lineProgress||0],"raster-value":[Rr,[],g=>g.globals.rasterValue||0],"raster-particle-speed":[Rr,[],g=>g.globals.rasterParticleSpeed||0],"sky-radial-progress":[Rr,[],g=>g.globals.skyRadialProgress||0],accumulated:[ri,[],g=>g.globals.accumulated===void 0?null:g.globals.accumulated],"+":[Rr,fx(Rr),(g,c)=>{let m=0;for(const v of c)m+=v.evaluate(g);return m}],"*":[Rr,fx(Rr),(g,c)=>{let m=1;for(const v of c)m*=v.evaluate(g);return m}],"-":{type:Rr,overloads:[[[Rr,Rr],(g,[c,m])=>c.evaluate(g)-m.evaluate(g)],[[Rr],(g,[c])=>-c.evaluate(g)]]},"/":[Rr,[Rr,Rr],(g,[c,m])=>c.evaluate(g)/m.evaluate(g)],"%":[Rr,[Rr,Rr],(g,[c,m])=>c.evaluate(g)%m.evaluate(g)],ln2:[Rr,[],()=>Math.LN2],pi:[Rr,[],()=>Math.PI],e:[Rr,[],()=>Math.E],"^":[Rr,[Rr,Rr],(g,[c,m])=>Math.pow(c.evaluate(g),m.evaluate(g))],sqrt:[Rr,[Rr],(g,[c])=>Math.sqrt(c.evaluate(g))],log10:[Rr,[Rr],(g,[c])=>Math.log(c.evaluate(g))/Math.LN10],ln:[Rr,[Rr],(g,[c])=>Math.log(c.evaluate(g))],log2:[Rr,[Rr],(g,[c])=>Math.log2(c.evaluate(g))],sin:[Rr,[Rr],(g,[c])=>Math.sin(c.evaluate(g))],cos:[Rr,[Rr],(g,[c])=>Math.cos(c.evaluate(g))],tan:[Rr,[Rr],(g,[c])=>Math.tan(c.evaluate(g))],asin:[Rr,[Rr],(g,[c])=>Math.asin(c.evaluate(g))],acos:[Rr,[Rr],(g,[c])=>Math.acos(c.evaluate(g))],atan:[Rr,[Rr],(g,[c])=>Math.atan(c.evaluate(g))],min:[Rr,fx(Rr),(g,c)=>Math.min(...c.map(m=>m.evaluate(g)))],max:[Rr,fx(Rr),(g,c)=>Math.max(...c.map(m=>m.evaluate(g)))],abs:[Rr,[Rr],(g,[c])=>Math.abs(c.evaluate(g))],round:[Rr,[Rr],(g,[c])=>{const m=c.evaluate(g);return m<0?-Math.round(-m):Math.round(m)}],floor:[Rr,[Rr],(g,[c])=>Math.floor(c.evaluate(g))],ceil:[Rr,[Rr],(g,[c])=>Math.ceil(c.evaluate(g))],"filter-==":[pi,[ja,ri],(g,[c,m])=>g.properties()[c.value]===m.value],"filter-id-==":[pi,[ri],(g,[c])=>g.id()===c.value],"filter-type-==":[pi,[ja],(g,[c])=>g.geometryType()===c.value],"filter-<":[pi,[ja,ri],(g,[c,m])=>{const v=g.properties()[c.value],N=m.value;return typeof v==typeof N&&v{const m=g.id(),v=c.value;return typeof m==typeof v&&m":[pi,[ja,ri],(g,[c,m])=>{const v=g.properties()[c.value],N=m.value;return typeof v==typeof N&&v>N}],"filter-id->":[pi,[ri],(g,[c])=>{const m=g.id(),v=c.value;return typeof m==typeof v&&m>v}],"filter-<=":[pi,[ja,ri],(g,[c,m])=>{const v=g.properties()[c.value],N=m.value;return typeof v==typeof N&&v<=N}],"filter-id-<=":[pi,[ri],(g,[c])=>{const m=g.id(),v=c.value;return typeof m==typeof v&&m<=v}],"filter->=":[pi,[ja,ri],(g,[c,m])=>{const v=g.properties()[c.value],N=m.value;return typeof v==typeof N&&v>=N}],"filter-id->=":[pi,[ri],(g,[c])=>{const m=g.id(),v=c.value;return typeof m==typeof v&&m>=v}],"filter-has":[pi,[ri],(g,[c])=>c.value in g.properties()],"filter-has-id":[pi,[],g=>g.id()!==null&&g.id()!==void 0],"filter-type-in":[pi,[md(ja)],(g,[c])=>c.value.indexOf(g.geometryType())>=0],"filter-id-in":[pi,[md(ri)],(g,[c])=>c.value.indexOf(g.id())>=0],"filter-in-small":[pi,[ja,md(ri)],(g,[c,m])=>m.value.indexOf(g.properties()[c.value])>=0],"filter-in-large":[pi,[ja,md(ri)],(g,[c,m])=>function(v,N,E,P){for(;E<=P;){const O=E+P>>1;if(N[O]===v)return!0;N[O]>v?P=O-1:E=O+1}return!1}(g.properties()[c.value],m.value,0,m.value.length-1)],all:{type:pi,overloads:[[[pi,pi],(g,[c,m])=>c.evaluate(g)&&m.evaluate(g)],[fx(pi),(g,c)=>{for(const m of c)if(!m.evaluate(g))return!1;return!0}]]},any:{type:pi,overloads:[[[pi,pi],(g,[c,m])=>c.evaluate(g)||m.evaluate(g)],[fx(pi),(g,c)=>{for(const m of c)if(m.evaluate(g))return!0;return!1}]]},"!":[pi,[pi],(g,[c])=>!c.evaluate(g)],"is-supported-script":[pi,[ja],(g,[c])=>{const m=g.globals&&g.globals.isSupportedScript;return!m||m(c.evaluate(g))}],upcase:[ja,[ja],(g,[c])=>c.evaluate(g).toUpperCase()],downcase:[ja,[ja],(g,[c])=>c.evaluate(g).toLowerCase()],concat:[ja,fx(ri),(g,c)=>c.map(m=>om(m.evaluate(g))).join("")],"resolved-locale":[ja,[bS],(g,[c])=>c.evaluate(g).resolvedLocale()],random:[Rr,[Rr,Rr,ri],(g,c)=>{const[m,v,N]=c.map(P=>P.evaluate(g));if(m>v||m===v)return m;let E;if(typeof N=="string")E=function(P){let O=0;if(P.length===0)return O;for(let B=0;BJSON.stringify(ee)).join(", ")}, but found ${JSON.stringify(J)} instead.`);return J}catch(J){const ee=J;return this._warningHistory[ee.message]||(this._warningHistory[ee.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${ee.message}`)),this._defaultValue}}}function Cb(g){return Array.isArray(g)&&g.length>0&&typeof g[0]=="string"&&g[0]in Pv}function xx(g,c,m,v,N){const E=new FS(Pv,[],c?function(O){const B={color:ku,string:ja,number:Rr,enum:ja,boolean:pi,formatted:hb,resolvedImage:mb};return O.type==="array"?md(B[O.value]||ri,O.length):B[O.type]}(c):void 0,void 0,void 0,m,v,N),P=E.parse(g,void 0,void 0,void 0,c&&c.type==="string"?{typeAnnotation:"coerce"}:void 0);return P?zD(new XS(P,c,m,v,N)):gx(E.errors)}class Iv{constructor(c,m,v,N){this.kind=c,this._styleExpression=m,this.isLightConstant=v,this.isLineProgressConstant=N,this.isStateDependent=c!=="constant"&&!_b(m.expression),this.configDependencies=Dy(m.expression),this.isIndoorDependent=KS(m.expression)}evaluateWithoutErrorHandling(c,m,v,N,E,P){return this._styleExpression.evaluateWithoutErrorHandling(c,m,v,N,E,P)}evaluate(c,m,v,N,E,P,O){return this._styleExpression.evaluate(c,m,v,N,E,P,void 0,void 0,O)}}class Oy{constructor(c,m,v,N,E,P){this.kind=c,this.zoomStops=v,this._styleExpression=m,this.isStateDependent=c!=="camera"&&!_b(m.expression),this.isIndoorDependent=KS(m.expression),this.isLightConstant=E,this.isLineProgressConstant=P,this.configDependencies=Dy(m.expression),this.interpolationType=N}evaluateWithoutErrorHandling(c,m,v,N,E,P){return this._styleExpression.evaluateWithoutErrorHandling(c,m,v,N,E,P)}evaluate(c,m,v,N,E,P){return this._styleExpression.evaluate(c,m,v,N,E,P)}interpolationFactor(c,m,v){return this.interpolationType?_h.interpolationFactor(this.interpolationType,c,m,v):0}}function PT(g,c,m,v,N){if((g=xx(g,c,m,v,N)).result==="error")return g;const E=g.value.expression,P=kv(E);if(!P&&!Sb(c))return gx([new im("","data expressions not supported")]);const O=Sv(E,["zoom","pitch","distance-from-center"]);if(!O&&!$D(c))return gx([new im("","zoom expressions not supported")]);const B=Sv(E,["measure-light"]);if(!B&&!BD(c))return gx([new im("","measure-light expression not supported")]);const W=Sv(E,["line-progress"]);if(!W&&!function(ie){return ET(ie.expression,"line-progress")}(c))return gx([new im("","line-progress expression not supported")]);const J=c.expression&&c.expression.relaxZoomRestriction,ee=Zm(E);return ee||O||J?ee instanceof im?gx([ee]):ee instanceof _h&&!ZS(c)?gx([new im("",'"interpolate" expressions cannot be used with this property')]):zD(ee?new Oy(P&&W?"camera":"composite",g.value,ee.labels,ee instanceof _h?ee.interpolation:void 0,B,W):new Iv(P&&W?"constant":"source",g.value,B,W)):gx([new im("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class QS{constructor(c,m){this._parameters=c,this._specification=m,Object.assign(this,UD(this._parameters,this._specification))}static deserialize(c){return new QS(c._parameters,c._specification)}static serialize(c){return{_parameters:c._parameters,_specification:c._specification}}}function Zm(g){let c=null;if(g instanceof Gf)c=Zm(g.result);else if(g instanceof jb){for(const m of g.args)if(c=Zm(m),c)break}else(g instanceof bb||g instanceof _h)&&g.input instanceof eu&&g.input.name==="zoom"&&(c=g);return c instanceof im||g.eachChild(m=>{const v=Zm(m);v instanceof im?c=v:c&&v&&c!==v&&(c=new im("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),c}var IT,WD,GD=function(){if(WD)return IT;WD=1,IT=c;var g=3;function c(m,v,N){var E=this.cells=[];if(m instanceof ArrayBuffer){this.arrayBuffer=m;var P=new Int32Array(this.arrayBuffer);m=P[0],this.d=(v=P[1])+2*(N=P[2]);for(var O=0;O=ie[ke+0]&&E>=ie[ke+1])?(B[ue]=!0,O.push(ee[ue])):B[ue]=!1}}},c.prototype._forEachCell=function(m,v,N,E,P,O,B,W){for(var J=this._convertToCellCoord(m),ee=this._convertToCellCoord(v),ie=this._convertToCellCoord(N),ce=this._convertToCellCoord(E),ue=J;ue<=ie;ue++)for(var ke=ee;ke<=ce;ke++){var Le=this.d*ke+ue;if((!W||W(this._convertFromCellCoord(ue),this._convertFromCellCoord(ke),this._convertFromCellCoord(ue+1),this._convertFromCellCoord(ke+1)))&&P.call(this,m,v,N,E,Le,O,B,W))return}},c.prototype._convertFromCellCoord=function(m){return(m-this.padding)/this.scale},c.prototype._convertToCellCoord=function(m){return Math.max(0,Math.min(this.d-1,Math.floor(m*this.scale)+this.padding))},c.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var m=this.cells,v=g+this.cells.length+1+1,N=0,E=0;E=0||(N[E]=Kf(g[E],c)));g instanceof Error&&(N.message=g.message)}if(N.$name)throw new Error("$name property is reserved for worker serialization logic.");return v!=="Object"&&(N.$name=v),N}throw new Error("can't serialize object of type "+typeof g)}function yx(g){if(g==null||typeof g=="boolean"||typeof g=="number"||typeof g=="string"||g instanceof Boolean||g instanceof Number||g instanceof String||g instanceof Date||g instanceof RegExp||Mb(g)||g instanceof ImageBitmap||ArrayBuffer.isView(g)||g instanceof ImageData)return g;if(Array.isArray(g))return g.map(yx);if(typeof g=="object"){const c=g.$name||"Object";if(c==="Map"){const N=g.entries||[],E=new Map;for(let P=0;Pg>=128&&g<=255,Arabic:g=>g>=1536&&g<=1791,"Arabic Supplement":g=>g>=1872&&g<=1919,"Arabic Extended-A":g=>g>=2208&&g<=2303,"Hangul Jamo":g=>g>=4352&&g<=4607,"Unified Canadian Aboriginal Syllabics":g=>g>=5120&&g<=5759,Khmer:g=>g>=6016&&g<=6143,"Unified Canadian Aboriginal Syllabics Extended":g=>g>=6320&&g<=6399,"General Punctuation":g=>g>=8192&&g<=8303,"Letterlike Symbols":g=>g>=8448&&g<=8527,"Number Forms":g=>g>=8528&&g<=8591,"Miscellaneous Technical":g=>g>=8960&&g<=9215,"Control Pictures":g=>g>=9216&&g<=9279,"Optical Character Recognition":g=>g>=9280&&g<=9311,"Enclosed Alphanumerics":g=>g>=9312&&g<=9471,"Geometric Shapes":g=>g>=9632&&g<=9727,"Miscellaneous Symbols":g=>g>=9728&&g<=9983,"Miscellaneous Symbols and Arrows":g=>g>=11008&&g<=11263,"CJK Radicals Supplement":g=>g>=11904&&g<=12031,"Kangxi Radicals":g=>g>=12032&&g<=12255,"Ideographic Description Characters":g=>g>=12272&&g<=12287,"CJK Symbols and Punctuation":g=>g>=12288&&g<=12351,Hiragana:g=>g>=12352&&g<=12447,Katakana:g=>g>=12448&&g<=12543,Bopomofo:g=>g>=12544&&g<=12591,"Hangul Compatibility Jamo":g=>g>=12592&&g<=12687,Kanbun:g=>g>=12688&&g<=12703,"Bopomofo Extended":g=>g>=12704&&g<=12735,"CJK Strokes":g=>g>=12736&&g<=12783,"Katakana Phonetic Extensions":g=>g>=12784&&g<=12799,"Enclosed CJK Letters and Months":g=>g>=12800&&g<=13055,"CJK Compatibility":g=>g>=13056&&g<=13311,"CJK Unified Ideographs Extension A":g=>g>=13312&&g<=19903,"Yijing Hexagram Symbols":g=>g>=19904&&g<=19967,"CJK Unified Ideographs":g=>g>=19968&&g<=40959,"Yi Syllables":g=>g>=40960&&g<=42127,"Yi Radicals":g=>g>=42128&&g<=42191,"Hangul Jamo Extended-A":g=>g>=43360&&g<=43391,"Hangul Syllables":g=>g>=44032&&g<=55215,"Hangul Jamo Extended-B":g=>g>=55216&&g<=55295,"Private Use Area":g=>g>=57344&&g<=63743,"CJK Compatibility Ideographs":g=>g>=63744&&g<=64255,"Arabic Presentation Forms-A":g=>g>=64336&&g<=65023,"Vertical Forms":g=>g>=65040&&g<=65055,"CJK Compatibility Forms":g=>g>=65072&&g<=65103,"Small Form Variants":g=>g>=65104&&g<=65135,"Arabic Presentation Forms-B":g=>g>=65136&&g<=65279,"Halfwidth and Fullwidth Forms":g=>g>=65280&&g<=65519,Osage:g=>g>=66736&&g<=66815,"CJK Unified Ideographs Extension B":g=>g>=131072&&g<=173791};function Tb(g){for(const c of g)if(JS(c.charCodeAt(0)))return!0;return!1}function LT(g){for(const c of g)if(!KD(c.charCodeAt(0)))return!1;return!0}function KD(g){return!(Zr.Arabic(g)||Zr["Arabic Supplement"](g)||Zr["Arabic Extended-A"](g)||Zr["Arabic Presentation Forms-A"](g)||Zr["Arabic Presentation Forms-B"](g))}function JS(g){return!(g!==746&&g!==747&&(g<4352||!(Zr["Bopomofo Extended"](g)||Zr.Bopomofo(g)||Zr["CJK Compatibility Forms"](g)&&!(g>=65097&&g<=65103)||Zr["CJK Compatibility Ideographs"](g)||Zr["CJK Compatibility"](g)||Zr["CJK Radicals Supplement"](g)||Zr["CJK Strokes"](g)||!(!Zr["CJK Symbols and Punctuation"](g)||g>=12296&&g<=12305||g>=12308&&g<=12319||g===12336)||Zr["CJK Unified Ideographs Extension A"](g)||Zr["CJK Unified Ideographs"](g)||Zr["Enclosed CJK Letters and Months"](g)||Zr["Hangul Compatibility Jamo"](g)||Zr["Hangul Jamo Extended-A"](g)||Zr["Hangul Jamo Extended-B"](g)||Zr["Hangul Jamo"](g)||Zr["Hangul Syllables"](g)||Zr.Hiragana(g)||Zr["Ideographic Description Characters"](g)||Zr.Kanbun(g)||Zr["Kangxi Radicals"](g)||Zr["Katakana Phonetic Extensions"](g)||Zr.Katakana(g)&&g!==12540||!(!Zr["Halfwidth and Fullwidth Forms"](g)||g===65288||g===65289||g===65293||g>=65306&&g<=65310||g===65339||g===65341||g===65343||g>=65371&&g<=65503||g===65507||g>=65512&&g<=65519)||!(!Zr["Small Form Variants"](g)||g>=65112&&g<=65118||g>=65123&&g<=65126)||Zr["Unified Canadian Aboriginal Syllabics"](g)||Zr["Unified Canadian Aboriginal Syllabics Extended"](g)||Zr["Vertical Forms"](g)||Zr["Yijing Hexagram Symbols"](g)||Zr["Yi Syllables"](g)||Zr["Yi Radicals"](g))))}function eC(g){return!(JS(g)||function(c){return!!(Zr["Latin-1 Supplement"](c)&&(c===167||c===169||c===174||c===177||c===188||c===189||c===190||c===215||c===247)||Zr["General Punctuation"](c)&&(c===8214||c===8224||c===8225||c===8240||c===8241||c===8251||c===8252||c===8258||c===8263||c===8264||c===8265||c===8273)||Zr["Letterlike Symbols"](c)||Zr["Number Forms"](c)||Zr["Miscellaneous Technical"](c)&&(c>=8960&&c<=8967||c>=8972&&c<=8991||c>=8996&&c<=9e3||c===9003||c>=9085&&c<=9114||c>=9150&&c<=9165||c===9167||c>=9169&&c<=9179||c>=9186&&c<=9215)||Zr["Control Pictures"](c)&&c!==9251||Zr["Optical Character Recognition"](c)||Zr["Enclosed Alphanumerics"](c)||Zr["Geometric Shapes"](c)||Zr["Miscellaneous Symbols"](c)&&!(c>=9754&&c<=9759)||Zr["Miscellaneous Symbols and Arrows"](c)&&(c>=11026&&c<=11055||c>=11088&&c<=11097||c>=11192&&c<=11243)||Zr["CJK Symbols and Punctuation"](c)||Zr.Katakana(c)||Zr["Private Use Area"](c)||Zr["CJK Compatibility Forms"](c)||Zr["Small Form Variants"](c)||Zr["Halfwidth and Fullwidth Forms"](c)||c===8734||c===8756||c===8757||c>=9984&&c<=10087||c>=10102&&c<=10131||c===65532||c===65533)}(g))}function tC(g){return Zr.Arabic(g)||Zr["Arabic Supplement"](g)||Zr["Arabic Extended-A"](g)||Zr["Arabic Presentation Forms-A"](g)||Zr["Arabic Presentation Forms-B"](g)}function DT(g){return g>=1424&&g<=2303||Zr["Arabic Presentation Forms-A"](g)||Zr["Arabic Presentation Forms-B"](g)}function Zf(g,c){return!(!c&&DT(g)||g>=2304&&g<=3583||g>=3840&&g<=4255||Zr.Khmer(g))}function cde(g){for(const c of g)if(DT(c.charCodeAt(0)))return!0;return!1}const Hu={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let OT=null,tu=Hu.unavailable,Yf=null;const Ab=function(g){g&&typeof g=="string"&&g.indexOf("NetworkError")>-1&&(tu=Hu.error),OT&&OT(g)};function sC(){rC.fire(new am("pluginStateChange",{pluginStatus:tu,pluginURL:Yf}))}const rC=new Cs,Eb=function(){return tu},ZD=function(){if(tu!==Hu.deferred||!Yf)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");tu=Hu.loading,sC(),Yf&&Vu({url:Yf},g=>{g?Ab(g):(tu=Hu.loaded,sC())})},Xf={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>tu===Hu.loaded||Xf.applyArabicShaping!=null,isLoading:()=>tu===Hu.loading,setState(g){tu=g.pluginStatus,Yf=g.pluginURL},isParsing:()=>tu===Hu.parsing,isParsed:()=>tu===Hu.parsed,getPluginURL:()=>Yf};class Fi{constructor(c,m){this.zoom=c,m?(this.now=m.now,this.fadeDuration=m.fadeDuration,this.transition=m.transition,this.pitch=m.pitch,this.brightness=m.brightness,this.worldview=m.worldview,this.activeFloors=m.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(c){return function(m,v){for(const N of m)if(!Zf(N.charCodeAt(0),v))return!1;return!0}(c,Xf.isLoaded())}}class nC{constructor(c,m,v,N,E){this.property=c,this.value=m,this.expression=function(P,O,B,W,J){if(YS(P))return new QS(P,O);if(Cb(P)||Array.isArray(P)&&P.length>0){const ee=PT(P,O,B,W,J);if(ee.result==="error")throw new Error(ee.value.map(ie=>`${ie.key}: ${ie.message}`).join(", "));return ee.value}{let ee=P;return typeof P=="string"&&O.type==="color"&&(ee=Fr.parse(P)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>ee}}}(m===void 0?c.specification.default:m,c.specification,v,N,E)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(c,m,v,N){return this.property.possiblyEvaluate(this,c,m,v,N)}}class RT{constructor(c,m,v,N){this.property=c,this.value=new nC(c,void 0,m,v,N)}transitioned(c,m){return new XD(this.property,this.value,m,Object.assign({},c.transition,this.transition),c.now)}untransitioned(){return new XD(this.property,this.value,null,{},0)}}class YD{constructor(c,m,v,N){this._properties=c,this._values=Object.create(c.defaultTransitionablePropertyValues),this._scope=m,this._options=v,this._iconImageUseTheme=N,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(c){return gs(this._values[c].value.value)}setValue(c,m){this._values.hasOwnProperty(c)||(this._values[c]=new RT(this._values[c].property,this._scope,this._options,this._iconImageUseTheme)),this._values[c].value=new nC(this._values[c].property,m===null?void 0:gs(m),this._scope,this._options,this._iconImageUseTheme),this._values[c].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[c].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[c].value.isIndoorDependent())}setTransitionOrValue(c,m){m&&(this._options=m);const v=this._properties.properties;if(c)for(const N in c){const E=c[N];if(N.endsWith("-transition")){const P=N.slice(0,-11);v[P]&&this.setTransition(P,E)}else v.hasOwnProperty(N)&&this.setValue(N,E)}}getTransition(c){return gs(this._values[c].transition)}setTransition(c,m){this._values.hasOwnProperty(c)||(this._values[c]=new RT(this._values[c].property)),this._values[c].transition=gs(m)||void 0}serialize(){const c={};for(const m of Object.keys(this._values)){const v=this.getValue(m);v!==void 0&&(c[m]=v);const N=this.getTransition(m);N!==void 0&&(c[`${m}-transition`]=N)}return c}transitioned(c,m){const v=new QD(this._properties);for(const N of Object.keys(this._values))v._values[N]=this._values[N].transitioned(c,m._values[N]);return v}untransitioned(){const c=new QD(this._properties);for(const m of Object.keys(this._values))c._values[m]=this._values[m].untransitioned();return c}isIndoorDependent(){return this._isIndoorDependent}}class XD{constructor(c,m,v,N,E){const P=N.delay||0,O=N.duration||0;E=E||0,this.property=c,this.value=m,this.begin=E+P,this.end=this.begin+O,c.specification.transition&&(N.delay||N.duration)&&(this.prior=v)}possiblyEvaluate(c,m,v){const N=c.now||0,E=this.value.possiblyEvaluate(c,m,v),P=this.prior;if(P){if(N>this.end)return this.prior=null,E;if(this.value.isDataDriven())return this.prior=null,E;if(N":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*"}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective"}},"colorTheme":{"data":{"type":"string","expression":{}}},"indoor_source":{"sourceId":{"type":"string"},"sourceLayers":{"type":"array","value":"string"}},"indoor":{"*":{"type":"indoor_source"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator"},"center":{"type":"array","length":2,"value":"number","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_building","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"flat"},"fill-extrusion-base-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"terrain"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":true},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","use-theme":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-facade-emissive-chance":{"type":"number","default":0.35,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"building-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light","line-progress"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-gradient":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["line-progress"]}},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1]},"line-trim-fade-range":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-trim-color":{"type":"color","default":"transparent","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"use-theme":true,"expression":{"interpolated":true,"parameters":["heatmap-density"]}},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{}},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-value"]}},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-particle-speed"]}},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-shadow-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-accent-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]}},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"use-theme":true,"expression":{"interpolated":true,"parameters":["sky-radial-progress"]}},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":true},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":true},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"property-type":"data-driven"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"use-theme":true,"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d"},"model-cast-shadows":{"type":"boolean","default":true},"model-receive-shadows":{"type":"boolean","default":true},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"model-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"model-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function eO(g){return g instanceof Number||g instanceof String||g instanceof Boolean?g.valueOf():g}function aC(g){if(Array.isArray(g))return g.map(aC);if(g instanceof Object&&!(g instanceof Number||g instanceof String||g instanceof Boolean)){const c={};for(const m in g)c[m]=aC(g[m]);return c}return eO(g)}function Fp(g){if(g===!0||g===!1)return!0;if(!Array.isArray(g)||g.length===0)return!1;switch(g[0]){case"has":return g.length>=2&&g[1]!=="$id"&&g[1]!=="$type";case"in":return g.length>=3&&(typeof g[1]!="string"||Array.isArray(g[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return g.length!==3||Array.isArray(g[1])||Array.isArray(g[2]);case"any":case"all":for(const c of g.slice(1))if(!Fp(c)&&typeof c!="boolean")return!1;return!0;default:return!0}}function iC(g,c="",m=null,v="fill"){if(g==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Fp(g)||(g=oC(g));const N=g;let E=!0;try{E=function(J){if(!Dv(J))return J;let ee=aC(J);return tO(ee),ee=$y(ee),ee}(N)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md and paste the contents of this message in the report. Thank you! Filter Expression: ${JSON.stringify(N,null,2)} `)}let P=null,O=null;if(v!=="background"&&v!=="sky"&&v!=="slot"){O=Gt[`filter_${v}`];const J=xx(E,O,c,m);if(J.result==="error")throw new Error(J.value.map(ee=>`${ee.key}: ${ee.message}`).join(", "));P=(ee,ie,ce)=>J.value.evaluate(ee,ie,{},ce)}let B=null,W=null;if(E!==N){const J=xx(N,O,c,m);if(J.result==="error")throw new Error(J.value.map(ee=>`${ee.key}: ${ee.message}`).join(", "));B=(ee,ie,ce,ue,ke)=>J.value.evaluate(ee,ie,{},ce,void 0,void 0,ue,ke),W=!kv(J.value.expression)}return{filter:P,dynamicFilter:B||void 0,needGeometry:sO(E),needFeature:!!W}}function $y(g){if(!Array.isArray(g))return g;const c=function(m){if(dde.has(m[0])){for(let v=1;v$y(m))}function tO(g){let c=!1;const m=[];if(g[0]==="case"){for(let v=1;v",">=","<","<=","to-boolean"]);function ude(g,c){return gc?1:0}function sO(g){if(!Array.isArray(g))return!1;if(g[0]==="within"||g[0]==="distance")return!0;for(let c=1;c"||c==="<="||c===">="?lC(g[1],g[2],c):c==="any"?(m=g.slice(1),["any"].concat(m.map(oC))):c==="all"?["all"].concat(g.slice(1).map(oC)):c==="none"?["all"].concat(g.slice(1).map(oC).map(Pb)):c==="in"?cC(g[1],g.slice(2)):c==="!in"?Pb(cC(g[1],g.slice(2))):c==="has"?dC(g[1]):c!=="!has"||Pb(dC(g[1]));var m}function lC(g,c,m){switch(g){case"$type":return[`filter-type-${m}`,c];case"$id":return[`filter-id-${m}`,c];default:return[`filter-${m}`,g,c]}}function cC(g,c){if(c.length===0)return!1;switch(g){case"$type":return["filter-type-in",["literal",c]];case"$id":return["filter-id-in",["literal",c]];default:return c.length>200&&!c.some(m=>typeof m!=typeof c[0])?["filter-in-large",g,["literal",c.sort(ude)]]:["filter-in-small",g,["literal",c]]}}function dC(g){switch(g){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",g]}}function Pb(g){return["!",g]}const qy="";function Ym(g,c){return c?`${g}${qy}${c}`:g}let rO;const nO=()=>rO||(rO=new wo({"icon-size":new nr(Gt.layout_symbol["icon-size"]),"icon-image":new nr(Gt.layout_symbol["icon-image"]),"icon-rotate":new nr(Gt.layout_symbol["icon-rotate"]),"icon-offset":new nr(Gt.layout_symbol["icon-offset"]),"text-size":new nr(Gt.layout_symbol["text-size"]),"text-rotate":new nr(Gt.layout_symbol["text-rotate"]),"text-offset":new nr(Gt.layout_symbol["text-offset"])}));class aO{constructor(c,m,v,N,E,P){const O=xx(c,Gt.appearance.condition);if(O.result==="success"&&(this.condition=O.value),this.name=m,v){this.properties=new zy(nO()),this.unevaluatedLayout=new JD(nO(),N,E,P);for(const B in v)this.unevaluatedLayout.setValue(B,v[B])}}isActive(c){return!(this.condition||!c.isHidden||this.name!=="hidden")||this.condition.evaluate(c.globals,c.feature,c.featureState,c.canonical)}getCondition(){return this.condition}getName(){return this.name}getProperty(c){return this.properties.get(c)}getUnevaluatedProperties(){return this.unevaluatedLayout}getUnevaluatedProperty(c){return this.unevaluatedLayout._values[c]}recalculate(c,m,v){this.unevaluatedLayout&&(this.properties=this.unevaluatedLayout.possiblyEvaluate(c,void 0,m,v))}serialize(){const c={};return c.condition=this.condition.expression.serialize(),this.name&&(c.name=this.name),this.unevaluatedLayout&&(c.properties=this.unevaluatedLayout.serialize()),c}hasIconProperties(){const c=this.hasProperty("icon-image"),m=this.hasProperty("icon-size"),v=this.hasProperty("icon-offset"),N=this.hasProperty("icon-rotate");return c||m||v||N}hasTextProperties(){const c=this.hasProperty("text-size"),m=this.hasProperty("text-offset"),v=this.hasProperty("text-rotate");return c||m||v}hasProperty(c){return this.getUnevaluatedProperty(c).value!==void 0}}const iO="-transition",zp=new Set(["fill","line","background","hillshade","raster"]);class su extends Cs{constructor(c,m,v,N,E,P){if(super(),this.id=c.id,this.fqid=Ym(this.id,v),this.type=c.type,this.scope=v,this.lut=N,this.options=E,this.iconImageUseTheme=P,this.appearances=new Array,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},c.type!=="custom"){if(this.metadata=c.metadata,this.minzoom=c.minzoom,this.maxzoom=c.maxzoom,c.type&&c.type!=="background"&&c.type!=="sky"&&c.type!=="slot"){this.source=c.source,this.sourceLayer=c["source-layer"],this.filter=c.filter;const O=xx(this.filter,Gt[`filter_${c.type}`]);O.result!=="error"&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...O.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||O.value.isIndoorDependent)}if(c.slot&&(this.slot=c.slot),c.appearances&&this.setAppearances(c.appearances),m.layout&&(this._unevaluatedLayout=new JD(m.layout,this.scope,E,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),m.paint){this._transitionablePaint=new YD(m.paint,this.scope,E);for(const O in c.paint)this.setPaintProperty(O,c.paint[O]);for(const O in c.layout)this.setLayoutProperty(O,c.layout[O]);this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._transitionablePaint.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._transitionablePaint.isIndoorDependent(),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new zy(m.paint)}}}onAdd(c){}onRemove(c){}isDraped(c){return!this.is3D(!0)&&zp.has(this.type)}getLayoutProperty(c){return c==="visibility"?this.visibility:this._unevaluatedLayout.getValue(c)}setLayoutProperty(c,m){if(this.type==="custom"&&c==="visibility")return void(this.visibility=m);const v=this._unevaluatedLayout;v._properties.properties[c]&&(v.setValue(c,m),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...v.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||v.isIndoorDependent(),c==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(c){this.appearances=[],c.forEach(m=>{this.appearances.push(new aO(m.condition,m.name,m.properties,this.scope,this.options,this.iconImageUseTheme))})}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(c){return c.endsWith(iO)?this._transitionablePaint.getTransition(c.slice(0,-11)):this._transitionablePaint.getValue(c)}isPaintProperty(c){return!!this._transitionablePaint._properties.properties[c]}setPaintProperty(c,m){const v=this._transitionablePaint,N=v._properties.properties;if(c.endsWith(iO)){const ee=c.slice(0,-11);return N[ee]&&v.setTransition(ee,m||void 0),!1}if(!N[c])return!1;const E=v._values[c],P=E.value.isDataDriven(),O=E.value;v.setValue(c,m),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...v.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||v.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(c);const B=v._values[c].value,W=B.isDataDriven(),J=c.endsWith("pattern")||c==="line-dasharray";return W||P||J||this._handleOverridablePaintPropertyUpdate(c,O,B)}_handleSpecialPaintPropertyUpdate(c){}getProgramIds(){return null}getDefaultProgramParams(c,m,v){return null}_handleOverridablePaintPropertyUpdate(c,m,v){return!1}isHidden(c){return!!(this.minzoom&&c=this.maxzoom)||this.visibility==="none"}updateTransitions(c){this._transitioningPaint=this._transitionablePaint.transitioned(c,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(c,m){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(c,void 0,m,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(c,void 0,m)}serialize(){const c={id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.appearances.length!==0&&(c.appearances=this.appearances.map(m=>m.serialize())),As(c,(m,v)=>!(m===void 0||v==="layout"&&!Object.keys(m).length||v==="paint"&&!Object.keys(m).length))}is3D(c){return!1}hasElevation(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}_clear(){}isStateDependent(){for(const c in this.paint._values){const m=this.paint.get(c);if(m instanceof Fy&&Sb(m.property.specification)&&(m.value.kind==="source"||m.value.kind==="composite")&&m.value.isStateDependent)return!0}for(const c of this.appearances)if(!_b(c.condition.expression))return!0;return!1}compileFilter(c){this._filterCompiled||(this._featureFilter=iC(this.filter,this.scope,c),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(c){this._stats&&(c.renderPass==="shadow"?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}getAppearances(){return this.appearances}queryRenderedFeatures(c,m,v){return{}}queryRadius(c){}queryIntersectsFeature(c,m,v,N,E,P,O,B,W){}}const oO={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Ib{constructor(c,m){this._structArray=c,this._pos1=m*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}const hde=new ArrayBuffer(0);class Wi{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(c,m){return c._trim(),m&&c.arrayBuffer&&m.add(c.arrayBuffer),{length:c.length,arrayBuffer:c.arrayBuffer}}static deserialize(c){const m=Object.create(this.prototype);return m.arrayBuffer=c.arrayBuffer,m.length=c.length,c.arrayBuffer?m.capacity=c.arrayBuffer.byteLength/m.bytesPerElement:(m.capacity=0,m.arrayBuffer=hde),m._refreshViews(),m}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(c){this.reserve(c),this.length=c}reserve(c){if(c>this.capacity){this._reallocCount++,this.capacity=Math.max(c,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const m=this.uint8;this._refreshViews(),m&&this.uint8.set(m)}}reserveForAdditional(c){this.reserve(this.length+c)}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...c){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...c){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function oa(g,c=1){let m=0,v=0;return{members:g.map(N=>{const E=oO[N.type].BYTES_PER_ELEMENT,P=m=lO(m,Math.max(c,E)),O=N.components||1;return v=Math.max(v,E),m+=E*O,{name:N.name,type:N.type,components:O,offset:P}}),size:lO(m,Math.max(v,c)),alignment:c}}function lO(g,c){return Math.ceil(g/c)*c}class vx extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m){const v=this.length;return this.resize(v+1),this.emplace(v,c,m)}emplace(c,m,v){const N=2*c;return this.int16[N+0]=m,this.int16[N+1]=v,c}}vx.prototype.bytesPerElement=4,_r(vx,"StructArrayLayout2i4");class Ov extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,v){const N=this.length;return this.resize(N+1),this.emplace(N,c,m,v)}emplace(c,m,v,N){const E=3*c;return this.int16[E+0]=m,this.int16[E+1]=v,this.int16[E+2]=N,c}}Ov.prototype.bytesPerElement=6,_r(Ov,"StructArrayLayout3i6");class Rv extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,v,N){const E=this.length;return this.resize(E+1),this.emplace(E,c,m,v,N)}emplace(c,m,v,N,E){const P=4*c;return this.int16[P+0]=m,this.int16[P+1]=v,this.int16[P+2]=N,this.int16[P+3]=E,c}}Rv.prototype.bytesPerElement=8,_r(Rv,"StructArrayLayout4i8");class Qf extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c){const m=this.length;return this.resize(m+1),this.emplace(m,c)}emplace(c,m){return this.float32[1*c+0]=m,c}}Qf.prototype.bytesPerElement=4,_r(Qf,"StructArrayLayout1f4");class FT extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,v){const N=this.length;return this.resize(N+1),this.emplace(N,c,m,v)}emplace(c,m,v,N){const E=4*c,P=2*c;return this.int16[E+0]=m,this.int16[E+1]=v,this.float32[P+1]=N,c}}FT.prototype.bytesPerElement=8,_r(FT,"StructArrayLayout2i1f8");class zT extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,v){const N=this.length;return this.resize(N+1),this.emplace(N,c,m,v)}emplace(c,m,v,N){const E=4*c;return this.int16[E+0]=m,this.int16[E+1]=v,this.int16[E+2]=N,c}}zT.prototype.bytesPerElement=8,_r(zT,"StructArrayLayout3i8");class BT extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E){const P=this.length;return this.resize(P+1),this.emplace(P,c,m,v,N,E)}emplace(c,m,v,N,E,P){const O=5*c;return this.int16[O+0]=m,this.int16[O+1]=v,this.int16[O+2]=N,this.int16[O+3]=E,this.int16[O+4]=P,c}}BT.prototype.bytesPerElement=10,_r(BT,"StructArrayLayout5i10");class uC extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,c,m,v,N,E,P,O)}emplace(c,m,v,N,E,P,O,B){const W=6*c,J=12*c,ee=3*c;return this.int16[W+0]=m,this.int16[W+1]=v,this.uint8[J+4]=N,this.uint8[J+5]=E,this.uint8[J+6]=P,this.uint8[J+7]=O,this.float32[ee+2]=B,c}}uC.prototype.bytesPerElement=12,_r(uC,"StructArrayLayout2i4ub1f12");class bh extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,v){const N=this.length;return this.resize(N+1),this.emplace(N,c,m,v)}emplace(c,m,v,N){const E=3*c;return this.float32[E+0]=m,this.float32[E+1]=v,this.float32[E+2]=N,c}}bh.prototype.bytesPerElement=12,_r(bh,"StructArrayLayout3f12");class Su extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E){const P=this.length;return this.resize(P+1),this.emplace(P,c,m,v,N,E)}emplace(c,m,v,N,E,P){const O=6*c,B=3*c;return this.uint16[O+0]=m,this.uint16[O+1]=v,this.uint16[O+2]=N,this.uint16[O+3]=E,this.float32[B+2]=P,c}}Su.prototype.bytesPerElement=12,_r(Su,"StructArrayLayout4ui1f12");class Uy extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,v,N){const E=this.length;return this.resize(E+1),this.emplace(E,c,m,v,N)}emplace(c,m,v,N,E){const P=4*c;return this.uint16[P+0]=m,this.uint16[P+1]=v,this.uint16[P+2]=N,this.uint16[P+3]=E,c}}Uy.prototype.bytesPerElement=8,_r(Uy,"StructArrayLayout4ui8");class hC extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,c,m,v,N,E,P)}emplace(c,m,v,N,E,P,O){const B=6*c;return this.int16[B+0]=m,this.int16[B+1]=v,this.int16[B+2]=N,this.int16[B+3]=E,this.int16[B+4]=P,this.int16[B+5]=O,c}}hC.prototype.bytesPerElement=12,_r(hC,"StructArrayLayout6i12");class $T extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E,P,O,B,W,J,ee,ie){const ce=this.length;return this.resize(ce+1),this.emplace(ce,c,m,v,N,E,P,O,B,W,J,ee,ie)}emplace(c,m,v,N,E,P,O,B,W,J,ee,ie,ce){const ue=12*c;return this.int16[ue+0]=m,this.int16[ue+1]=v,this.int16[ue+2]=N,this.int16[ue+3]=E,this.uint16[ue+4]=P,this.uint16[ue+5]=O,this.uint16[ue+6]=B,this.uint16[ue+7]=W,this.int16[ue+8]=J,this.int16[ue+9]=ee,this.int16[ue+10]=ie,this.int16[ue+11]=ce,c}}$T.prototype.bytesPerElement=24,_r($T,"StructArrayLayout4i4ui4i24");class qT extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,c,m,v,N,E,P)}emplace(c,m,v,N,E,P,O){const B=10*c,W=5*c;return this.int16[B+0]=m,this.int16[B+1]=v,this.int16[B+2]=N,this.float32[W+2]=E,this.float32[W+3]=P,this.float32[W+4]=O,c}}qT.prototype.bytesPerElement=20,_r(qT,"StructArrayLayout3i3f20");class _x extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,v,N){const E=this.length;return this.resize(E+1),this.emplace(E,c,m,v,N)}emplace(c,m,v,N,E){const P=4*c;return this.float32[P+0]=m,this.float32[P+1]=v,this.float32[P+2]=N,this.float32[P+3]=E,c}}_x.prototype.bytesPerElement=16,_r(_x,"StructArrayLayout4f16");class mC extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(c){const m=this.length;return this.resize(m+1),this.emplace(m,c)}emplace(c,m){return this.uint32[1*c+0]=m,c}}mC.prototype.bytesPerElement=4,_r(mC,"StructArrayLayout1ul4");class wh extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m){const v=this.length;return this.resize(v+1),this.emplace(v,c,m)}emplace(c,m,v){const N=2*c;return this.uint16[N+0]=m,this.uint16[N+1]=v,c}}wh.prototype.bytesPerElement=4,_r(wh,"StructArrayLayout2ui4");class pC extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E,P,O,B,W,J,ee,ie,ce){const ue=this.length;return this.resize(ue+1),this.emplace(ue,c,m,v,N,E,P,O,B,W,J,ee,ie,ce)}emplace(c,m,v,N,E,P,O,B,W,J,ee,ie,ce,ue){const ke=20*c,Le=10*c;return this.int16[ke+0]=m,this.int16[ke+1]=v,this.int16[ke+2]=N,this.int16[ke+3]=E,this.int16[ke+4]=P,this.float32[Le+3]=O,this.float32[Le+4]=B,this.float32[Le+5]=W,this.float32[Le+6]=J,this.int16[ke+14]=ee,this.uint32[Le+8]=ie,this.uint16[ke+18]=ce,this.uint16[ke+19]=ue,c}}pC.prototype.bytesPerElement=40,_r(pC,"StructArrayLayout5i4f1i1ul2ui40");class fC extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,c,m,v,N,E,P,O)}emplace(c,m,v,N,E,P,O,B){const W=8*c;return this.int16[W+0]=m,this.int16[W+1]=v,this.int16[W+2]=N,this.int16[W+4]=E,this.int16[W+5]=P,this.int16[W+6]=O,this.int16[W+7]=B,c}}fC.prototype.bytesPerElement=16,_r(fC,"StructArrayLayout3i2i2i16");class gC extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E){const P=this.length;return this.resize(P+1),this.emplace(P,c,m,v,N,E)}emplace(c,m,v,N,E,P){const O=4*c,B=8*c;return this.float32[O+0]=m,this.float32[O+1]=v,this.float32[O+2]=N,this.int16[B+6]=E,this.int16[B+7]=P,c}}gC.prototype.bytesPerElement=16,_r(gC,"StructArrayLayout2f1f2i16");class UT extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,c,m,v,N,E,P)}emplace(c,m,v,N,E,P,O){const B=20*c,W=5*c;return this.uint8[B+0]=m,this.uint8[B+1]=v,this.float32[W+1]=N,this.float32[W+2]=E,this.float32[W+3]=P,this.float32[W+4]=O,c}}UT.prototype.bytesPerElement=20,_r(UT,"StructArrayLayout2ub4f20");class bl extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,v){const N=this.length;return this.resize(N+1),this.emplace(N,c,m,v)}emplace(c,m,v,N){const E=3*c;return this.uint16[E+0]=m,this.uint16[E+1]=v,this.uint16[E+2]=N,c}}bl.prototype.bytesPerElement=6,_r(bl,"StructArrayLayout3ui6");class Fv extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E,P,O,B,W,J,ee,ie,ce,ue,ke,Le,Ie,Ke,Ye,at,vt){const pt=this.length;return this.resize(pt+1),this.emplace(pt,c,m,v,N,E,P,O,B,W,J,ee,ie,ce,ue,ke,Le,Ie,Ke,Ye,at,vt)}emplace(c,m,v,N,E,P,O,B,W,J,ee,ie,ce,ue,ke,Le,Ie,Ke,Ye,at,vt,pt){const kt=30*c,Lt=15*c,$t=60*c;return this.int16[kt+0]=m,this.int16[kt+1]=v,this.int16[kt+2]=N,this.float32[Lt+2]=E,this.float32[Lt+3]=P,this.uint16[kt+8]=O,this.uint16[kt+9]=B,this.uint32[Lt+5]=W,this.uint32[Lt+6]=J,this.uint32[Lt+7]=ee,this.uint16[kt+16]=ie,this.uint16[kt+17]=ce,this.uint16[kt+18]=ue,this.float32[Lt+10]=ke,this.float32[Lt+11]=Le,this.uint8[$t+48]=Ie,this.uint8[$t+49]=Ke,this.uint8[$t+50]=Ye,this.uint32[Lt+13]=at,this.int16[kt+28]=vt,this.uint8[$t+58]=pt,c}}Fv.prototype.bytesPerElement=60,_r(Fv,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class VT extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E,P,O,B,W,J,ee,ie,ce,ue,ke,Le,Ie,Ke,Ye,at,vt,pt,kt,Lt,$t,ls,Wt,ms,bs,ws,Os,Fs,Ps){const Ls=this.length;return this.resize(Ls+1),this.emplace(Ls,c,m,v,N,E,P,O,B,W,J,ee,ie,ce,ue,ke,Le,Ie,Ke,Ye,at,vt,pt,kt,Lt,$t,ls,Wt,ms,bs,ws,Os,Fs,Ps)}emplace(c,m,v,N,E,P,O,B,W,J,ee,ie,ce,ue,ke,Le,Ie,Ke,Ye,at,vt,pt,kt,Lt,$t,ls,Wt,ms,bs,ws,Os,Fs,Ps,Ls){const hs=20*c,cs=40*c,Ds=80*c;return this.float32[hs+0]=m,this.float32[hs+1]=v,this.int16[cs+4]=N,this.int16[cs+5]=E,this.int16[cs+6]=P,this.int16[cs+7]=O,this.int16[cs+8]=B,this.int16[cs+9]=W,this.int16[cs+10]=J,this.int16[cs+11]=ee,this.int16[cs+12]=ie,this.uint16[cs+13]=ce,this.uint16[cs+14]=ue,this.uint16[cs+15]=ke,this.uint16[cs+16]=Le,this.uint16[cs+17]=Ie,this.uint16[cs+18]=Ke,this.uint16[cs+19]=Ye,this.uint16[cs+20]=at,this.uint16[cs+21]=vt,this.uint16[cs+22]=pt,this.uint16[cs+23]=kt,this.uint16[cs+24]=Lt,this.uint16[cs+25]=$t,this.uint16[cs+26]=ls,this.uint16[cs+27]=Wt,this.uint32[hs+14]=ms,this.float32[hs+15]=bs,this.float32[hs+16]=ws,this.float32[hs+17]=Os,this.float32[hs+18]=Fs,this.uint8[Ds+76]=Ps,this.uint16[cs+39]=Ls,c}}VT.prototype.bytesPerElement=80,_r(VT,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class HT extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,c,m,v,N,E,P)}emplace(c,m,v,N,E,P,O){const B=6*c;return this.float32[B+0]=m,this.float32[B+1]=v,this.float32[B+2]=N,this.float32[B+3]=E,this.float32[B+4]=P,this.float32[B+5]=O,c}}HT.prototype.bytesPerElement=24,_r(HT,"StructArrayLayout6f24");class Vy extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E){const P=this.length;return this.resize(P+1),this.emplace(P,c,m,v,N,E)}emplace(c,m,v,N,E,P){const O=5*c;return this.float32[O+0]=m,this.float32[O+1]=v,this.float32[O+2]=N,this.float32[O+3]=E,this.float32[O+4]=P,c}}Vy.prototype.bytesPerElement=20,_r(Vy,"StructArrayLayout5f20");class WT extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,c,m,v,N,E,P,O)}emplace(c,m,v,N,E,P,O,B){const W=7*c;return this.float32[W+0]=m,this.float32[W+1]=v,this.float32[W+2]=N,this.float32[W+3]=E,this.float32[W+4]=P,this.float32[W+5]=O,this.float32[W+6]=B,c}}WT.prototype.bytesPerElement=28,_r(WT,"StructArrayLayout7f28");class GT extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E,P,O,B,W,J,ee){const ie=this.length;return this.resize(ie+1),this.emplace(ie,c,m,v,N,E,P,O,B,W,J,ee)}emplace(c,m,v,N,E,P,O,B,W,J,ee,ie){const ce=11*c;return this.float32[ce+0]=m,this.float32[ce+1]=v,this.float32[ce+2]=N,this.float32[ce+3]=E,this.float32[ce+4]=P,this.float32[ce+5]=O,this.float32[ce+6]=B,this.float32[ce+7]=W,this.float32[ce+8]=J,this.float32[ce+9]=ee,this.float32[ce+10]=ie,c}}GT.prototype.bytesPerElement=44,_r(GT,"StructArrayLayout11f44");class zv extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E,P,O,B,W){const J=this.length;return this.resize(J+1),this.emplace(J,c,m,v,N,E,P,O,B,W)}emplace(c,m,v,N,E,P,O,B,W,J){const ee=9*c;return this.float32[ee+0]=m,this.float32[ee+1]=v,this.float32[ee+2]=N,this.float32[ee+3]=E,this.float32[ee+4]=P,this.float32[ee+5]=O,this.float32[ee+6]=B,this.float32[ee+7]=W,this.float32[ee+8]=J,c}}zv.prototype.bytesPerElement=36,_r(zv,"StructArrayLayout9f36");class Bp extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m){const v=this.length;return this.resize(v+1),this.emplace(v,c,m)}emplace(c,m,v){const N=2*c;return this.float32[N+0]=m,this.float32[N+1]=v,c}}Bp.prototype.bytesPerElement=8,_r(Bp,"StructArrayLayout2f8");class Cu extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,v,N){const E=this.length;return this.resize(E+1),this.emplace(E,c,m,v,N)}emplace(c,m,v,N,E){const P=6*c;return this.uint32[3*c+0]=m,this.uint16[P+2]=v,this.uint16[P+3]=N,this.uint16[P+4]=E,c}}Cu.prototype.bytesPerElement=12,_r(Cu,"StructArrayLayout1ul3ui12");class bx extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c){const m=this.length;return this.resize(m+1),this.emplace(m,c)}emplace(c,m){return this.uint16[1*c+0]=m,c}}bx.prototype.bytesPerElement=2,_r(bx,"StructArrayLayout1ui2");class KT extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E,P,O,B,W,J,ee,ie,ce,ue,ke,Le){const Ie=this.length;return this.resize(Ie+1),this.emplace(Ie,c,m,v,N,E,P,O,B,W,J,ee,ie,ce,ue,ke,Le)}emplace(c,m,v,N,E,P,O,B,W,J,ee,ie,ce,ue,ke,Le,Ie){const Ke=16*c;return this.float32[Ke+0]=m,this.float32[Ke+1]=v,this.float32[Ke+2]=N,this.float32[Ke+3]=E,this.float32[Ke+4]=P,this.float32[Ke+5]=O,this.float32[Ke+6]=B,this.float32[Ke+7]=W,this.float32[Ke+8]=J,this.float32[Ke+9]=ee,this.float32[Ke+10]=ie,this.float32[Ke+11]=ce,this.float32[Ke+12]=ue,this.float32[Ke+13]=ke,this.float32[Ke+14]=Le,this.float32[Ke+15]=Ie,c}}KT.prototype.bytesPerElement=64,_r(KT,"StructArrayLayout16f64");class xC extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,v,N,E,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,c,m,v,N,E,P,O)}emplace(c,m,v,N,E,P,O,B){const W=10*c,J=5*c;return this.uint16[W+0]=m,this.uint16[W+1]=v,this.uint16[W+2]=N,this.uint16[W+3]=E,this.float32[J+2]=P,this.float32[J+3]=O,this.float32[J+4]=B,c}}xC.prototype.bytesPerElement=20,_r(xC,"StructArrayLayout4ui3f20");class ZT extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c){const m=this.length;return this.resize(m+1),this.emplace(m,c)}emplace(c,m){return this.int16[1*c+0]=m,c}}ZT.prototype.bytesPerElement=2,_r(ZT,"StructArrayLayout1i2");class yC extends Wi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(c){const m=this.length;return this.resize(m+1),this.emplace(m,c)}emplace(c,m){return this.uint8[1*c+0]=m,c}}yC.prototype.bytesPerElement=1,_r(yC,"StructArrayLayout1ub1");class vC extends Ib{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}vC.prototype.size=40;class cO extends pC{get(c){return new vC(this,c)}}_r(cO,"CollisionBoxArray");class _C extends Ib{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(c){this._structArray.uint8[this._pos1+49]=c}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(c){this._structArray.uint8[this._pos1+50]=c}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(c){this._structArray.uint32[this._pos4+13]=c}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(c){this._structArray.uint8[this._pos1+58]=c}}_C.prototype.size=60;class dO extends Fv{get(c){return new _C(this,c)}}_r(dO,"PlacedSymbolArray");class uO extends Ib{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(c){this._structArray.uint32[this._pos4+14]=c}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(c){this._structArray.float32[this._pos4+18]=c}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}uO.prototype.size=80;class YT extends VT{get(c){return new uO(this,c)}}_r(YT,"SymbolInstanceArray");class bC extends Qf{getoffsetX(c){return this.float32[1*c+0]}}_r(bC,"GlyphOffsetArray");class hO extends vx{getx(c){return this.int16[2*c+0]}gety(c){return this.int16[2*c+1]}}_r(hO,"SymbolLineVertexArray");class XT extends Ib{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}XT.prototype.size=12;class QT extends Cu{get(c){return new XT(this,c)}}_r(QT,"FeatureIndexArray");class mO extends wh{geta_centroid_pos0(c){return this.uint16[2*c+0]}geta_centroid_pos1(c){return this.uint16[2*c+1]}}_r(mO,"FillExtrusionCentroidArray");class wC extends Ib{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}wC.prototype.size=6;class Lb extends Ov{get(c){return new wC(this,c)}}_r(Lb,"FillExtrusionWallArray");const pO=oa([{name:"a_pos",components:2,type:"Int16"}],4),mde=oa([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),fO=oa([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class co{constructor(c=[]){this.segments=c}_prepareSegment(c,m,v,N){let E=this.segments[this.segments.length-1];return c>co.MAX_VERTEX_ARRAY_LENGTH&&ur(`Max vertices per segment is ${co.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${c}`),(!E||E.vertexLength+c>co.MAX_VERTEX_ARRAY_LENGTH||E.sortKey!==N)&&(E={vertexOffset:m,primitiveOffset:v,vertexLength:0,primitiveLength:0},N!==void 0&&(E.sortKey=N),this.segments.push(E)),E}prepareSegment(c,m,v,N){return this._prepareSegment(c,m.length,v.length,N)}get(){return this.segments}destroy(){for(const c of this.segments)for(const m in c.vaos)c.vaos[m].destroy()}static simpleSegment(c,m,v,N){return new co([{vertexOffset:c,primitiveOffset:m,vertexLength:v,primitiveLength:N,vaos:{},sortKey:0}])}}function jC(g,c){return 256*(g=ye(Math.floor(g),0,255))+ye(Math.floor(c),0,255)}co.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,_r(co,"SegmentVector");const pde=oa([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),fde=oa([{name:"a_pattern_b",components:4,type:"Uint16"}]),gde=oa([{name:"a_dash",components:4,type:"Uint16"}]);class Db{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(c,m,v,N){this.ids.push(JT(c)),this.positions.push(m,v,N)}eachPosition(c,m){const v=JT(c);let N=0,E=this.ids.length-1;for(;N>1;this.ids[P]>=v?E=P:N=P+1}for(;this.ids[N]===v;)m(this.positions[3*N],this.positions[3*N+1],this.positions[3*N+2]),N++}static serialize(c,m){const v=new Float64Array(c.ids),N=new Uint32Array(c.positions);return eA(v,N,0,v.length-1),m&&(m.add(v.buffer),m.add(N.buffer)),{ids:v,positions:N}}static deserialize(c){const m=new Db;let v;m.ids=c.ids,m.positions=c.positions;for(const N of m.ids)N!==v&&m.uniqueIds.push(N),v=N;return m.indexed=!0,m}}function JT(g){const c=+g;return Number.isSafeInteger(c)?c:yv(String(g))}function eA(g,c,m,v){for(;m>1];let E=m-1,P=v+1;for(;;){do E++;while(g[E]N);if(E>=P)break;NC(g,E,P),NC(c,3*E,3*P),NC(c,3*E+1,3*P+1),NC(c,3*E+2,3*P+2)}P-m`u_${E}`),this.type=v,this.context=N}setUniform(c,m,v,N,E){const P=N.constantOr(this.value);m.set(c,E,P instanceof Fr?P.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):P)}getBinding(c,m){return this.type==="color"?new Rb(c):new wl(c)}}class Bv{constructor(c,m){this.uniformNames=m.map(v=>`u_${v}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(c,m){this.pixelRatio=c.pixelRatio||1,this.pattern=c.tl.concat(c.br),this.patternTransition=m?m.tl.concat(m.br):this.pattern}setUniform(c,m,v,N,E){let P=null;E!=="u_pattern"&&E!=="u_dash"||(P=this.pattern),E==="u_pattern_b"&&(P=this.patternTransition),E==="u_pixel_ratio"&&(P=this.pixelRatio),P&&m.set(c,E,P)}getBinding(c,m){return m==="u_pattern"||m==="u_pattern_b"||m==="u_dash"?new SC(c):new wl(c)}}class eg{constructor(c,m,v,N){this.expression=c,this.type=v,this.maxValue=0,this.paintVertexAttributes=m.map(E=>({name:`a_${E}`,type:"Float32",components:v==="color"?2:1,offset:0})),this.paintVertexArray=new N}populatePaintArray(c,m,v,N,E,P,O,B){const W=this.paintVertexArray.length,J=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new Fi(0,{brightness:P,worldview:B}),m,{},E,N,O):this.expression.kind==="constant"&&this.expression.value,ee=zb(this.lutExpression,m,{},N,E,P,O,B);this.paintVertexArray.resize(c),this._setPaintValue(W,c,J,ee?null:this.context.lut)}updatePaintArray(c,m,v,N,E,P,O,B){const W=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:O,worldview:B},v,N,void 0,E):this.expression.kind==="constant"&&this.expression.value,J=zb(this.lutExpression,v,N,E,void 0,O,void 0,B);this._setPaintValue(c,m,W,J?null:this.context.lut)}_setPaintValue(c,m,v,N){if(this.type==="color"){const E=tA(v.toPremultipliedRenderColor(N));for(let P=c;P`u_${O}_t`),this.type=v,this.useIntegerZoom=N,this.context=E,this.maxValue=0,this.paintVertexAttributes=m.map(O=>({name:`a_${O}`,type:"Float32",components:v==="color"?4:2,offset:0})),this.paintVertexArray=new P}populatePaintArray(c,m,v,N,E,P,O,B){const W=this.expression.evaluate(new Fi(this.context.zoom,{brightness:P,worldview:B}),m,{},E,N,O),J=this.expression.evaluate(new Fi(this.context.zoom+1,{brightness:P,worldview:B}),m,{},E,N,O),ee=zb(this.lutExpression,m,{},N,E,P,O,B),ie=this.paintVertexArray.length;this.paintVertexArray.resize(c),this._setPaintValue(ie,c,W,J,ee?null:this.context.lut)}updatePaintArray(c,m,v,N,E,P,O,B){const W=this.expression.evaluate({zoom:this.context.zoom,brightness:O,worldview:B},v,N,void 0,E),J=this.expression.evaluate({zoom:this.context.zoom+1,brightness:O,worldview:B},v,N,void 0,E),ee=zb(this.lutExpression,v,N,E,void 0,O,void 0,B);this._setPaintValue(c,m,W,J,ee?null:this.context.lut)}_setPaintValue(c,m,v,N,E){if(this.type==="color"){const P=tA(v.toPremultipliedRenderColor(E)),O=tA(v.toPremultipliedRenderColor(E));for(let B=c;B!0){this.binders={},this._buffers=[],this.context=m;const N=[];for(const E in c.paint._values){const P=c.paint.get(E);if(E.endsWith("-use-theme")||!v(E)||!(P instanceof Fy&&Sb(P.property.specification)))continue;const O=_de(E,c.type),B=P.value,W=P.property.specification.type,J=!!P.property.useIntegerZoom,ee=E==="line-dasharray"||E.endsWith("pattern"),ie=c.paint.get(`${E}-use-theme`),ce=E==="line-dasharray"&&c.layout.get("line-cap").value.kind!=="constant"||ie&&ie.value.kind!=="constant";if(B.kind!=="constant"||ce)if(B.kind==="source"||ce||ee){const ue=sA(E,W,"source");this.binders[E]=ee?new sg(B,O,W,ue,c.id):new eg(B,O,W,ue),N.push(`/a_${E}`)}else{const ue=sA(E,W,"composite");this.binders[E]=new tg(B,O,W,J,m,ue),N.push(`/z_${E}`)}else this.binders[E]=ee?new Bv(B.value,O):new Bb(B.value,O,W,m),N.push(`/u_${E}`);ie&&(this.binders[E].lutExpression=ie.value)}this.cacheKey=N.sort().join("")}getMaxValue(c){const m=this.binders[c];return m instanceof eg||m instanceof tg?m.maxValue:0}populatePaintArrays(c,m,v,N,E,P,O,B){for(const W in this.binders){const J=this.binders[W];J.context=this.context,(J instanceof eg||J instanceof tg||J instanceof sg)&&J.populatePaintArray(c,m,v,N,E,P,O,B)}}setConstantPatternPositions(c,m){for(const v in this.binders){const N=this.binders[v];N instanceof Bv&&N.setConstantPatternPositions(c,m)}}getPatternTransitionVertexBuffer(c){const m=this.binders[c];return m instanceof sg?m.paintTransitionVertexBuffer:null}updatePaintArrays(c,m,v,N,E,P,O,B,W,J){let ee=!1;const ie=Object.keys(c),ce=ie.length!==0&&!B,ue=ce?ie:m.uniqueIds;this.context.lut=E.lut;for(const ke in this.binders){const Le=this.binders[ke];if(Le.context=this.context,(Le instanceof eg||Le instanceof tg||Le instanceof sg)&&Le.expression&&Le.expression.kind&&Le.expression.kind!=="constant"&&(Le.expression.isStateDependent===!0||Le.expression.isLightConstant===!1)){const Ie=E.paint.get(ke);Le.expression=Ie.value;for(const Ke of ue){const Ye=c[Ke.toString()];m.eachPosition(Ke,(at,vt,pt)=>{const kt=N.feature(at);Le.updatePaintArray(vt,pt,kt,Ye,P,O,W,J)})}if(!ce)for(const Ke of v.uniqueIds){const Ye=c[Ke.toString()];v.eachPosition(Ke,(at,vt,pt)=>{const kt=N.feature(at);Le.updatePaintArray(vt,pt,kt,Ye,P,O,W,J)})}ee=!0}}return ee}defines(){const c=[];for(const m in this.binders){const v=this.binders[m];(v instanceof Bb||v instanceof Bv)&&c.push(...v.uniformNames.map(N=>`#define HAS_UNIFORM_${N}`))}return c}getPaintVertexBuffers(){return this._buffers}getUniforms(c){const m=[];for(const v in this.binders){const N=this.binders[v];if(N instanceof Bb||N instanceof Bv||N instanceof tg)for(const E of N.uniformNames)m.push({name:E,property:v,binding:N.getBinding(c,E)})}return m}setUniforms(c,m,v,N,E){for(const{name:P,property:O,binding:B}of v)this.binders[O].setUniform(c,B,E,N.get(O),P)}updatePaintBuffers(){this._buffers=[];for(const c in this.binders){const m=this.binders[c];(m instanceof eg||m instanceof tg||m instanceof sg)&&m.paintVertexBuffer&&this._buffers.push(m.paintVertexBuffer),m instanceof sg&&m.paintTransitionVertexBuffer&&this._buffers.push(m.paintTransitionVertexBuffer)}}upload(c){for(const m in this.binders){const v=this.binders[m];(v instanceof eg||v instanceof tg||v instanceof sg)&&v.upload(c)}this.updatePaintBuffers()}destroy(){for(const c in this.binders){const m=this.binders[c];(m instanceof eg||m instanceof tg||m instanceof sg)&&m.destroy()}}}class Xm{constructor(c,m,v=()=>!0){this.programConfigurations={};for(const N of c)this.programConfigurations[N.id]=new wx(N,m,v);this.needsUpload=!1,this._featureMap=new Db,this._featureMapWithoutIds=new Db,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(c,m,v,N,E,P,O,B,W){for(const J in this.programConfigurations)this.programConfigurations[J].populatePaintArrays(c,m,N,E,P,O,B,W);m.id!==void 0?this._featureMap.add(m.id,v,this._bufferOffset,c):(this._featureMapWithoutIds.add(this._idlessCounter,v,this._bufferOffset,c),this._idlessCounter+=1),this._bufferOffset=c,this.needsUpload=!0}updatePaintArrays(c,m,v,N,E,P,O,B){for(const W of v)this.needsUpload=this.programConfigurations[W.id].updatePaintArrays(c,this._featureMap,this._featureMapWithoutIds,m,W,N,E,P,O||0,B)||this.needsUpload}get(c){return this.programConfigurations[c]}upload(c){if(this.needsUpload){for(const m in this.programConfigurations)this.programConfigurations[m].upload(c);this.needsUpload=!1}}destroy(){for(const c in this.programConfigurations)this.programConfigurations[c].destroy()}}const vde={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio","pattern_b"],"fill-pattern":["pattern","pixel_ratio","pattern_b"],"fill-extrusion-pattern":["pattern","pixel_ratio","pattern_b"],"line-dasharray":["dash"],"fill-bridge-guard-rail-color":["structure_color"],"fill-tunnel-structure-color":["structure_color"]};function _de(g,c){return vde[g]||[g.replace(`${c}-`,"").replace(/-/g,"_")]}const bde={"line-pattern":{source:Su,composite:Su},"fill-pattern":{source:Su,composite:Su},"fill-extrusion-pattern":{source:Su,composite:Su},"line-dasharray":{source:Uy,composite:Uy}},wde={color:{source:Bp,composite:_x},number:{source:Qf,composite:Bp}};function sA(g,c,m){const v=bde[g];return v&&v[m]||wde[c][m]}_r(Bb,"ConstantBinder"),_r(Bv,"PatternConstantBinder"),_r(eg,"SourceExpressionBinder"),_r(sg,"PatternCompositeBinder"),_r(tg,"CompositeExpressionBinder"),_r(wx,"ProgramConfiguration",{omit:["_buffers"]}),_r(Xm,"ProgramConfigurationSet");const pd=Xs/Math.PI/2,dm=5,TC=6,jde=16383,$v=64,rA=[$v,32,16],um=-pd,hm=pd;function Hy(g,c,m,v=pd){return m=Ir(m),[g*Math.sin(m)*v,-c*v,g*Math.cos(m)*v]}function qv(g,c,m){return Hy(Math.cos(Ir(g)),Math.sin(Ir(g)),c,m)}const M=63710088e-1,h=2*Math.PI*M;class x{constructor(c,m){if(isNaN(c)||isNaN(m))throw new Error(`Invalid LngLat object: (${c}, ${m})`);if(this.lng=+c,this.lat=+m,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new x(Je(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(c){const m=Math.PI/180,v=this.lat*m,N=c.lat*m,E=Math.sin(v)*Math.sin(N)+Math.cos(v)*Math.cos(N)*Math.cos((c.lng-this.lng)*m);return M*Math.acos(Math.min(E,1))}toBounds(c=0){const m=360*c/40075017,v=m/Math.cos(Math.PI/180*this.lat);return new A({lng:this.lng-v,lat:this.lat-m},{lng:this.lng+v,lat:this.lat+m})}toEcef(c){return qv(this.lat,this.lng,pd+c*pd/M)}static convert(c){if(c instanceof x)return c;if(Array.isArray(c)&&(c.length===2||c.length===3))return new x(Number(c[0]),Number(c[1]));if(!Array.isArray(c)&&typeof c=="object"&&c!==null)return new x(Number("lng"in c?c.lng:c.lon),Number(c.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class A{constructor(c,m){c&&(m?this.setSouthWest(c).setNorthEast(m):Array.isArray(c)&&c.length===4?this.setSouthWest([c[0],c[1]]).setNorthEast([c[2],c[3]]):this.setSouthWest(c[0]).setNorthEast(c[1]))}setNorthEast(c){return this._ne=c instanceof x?new x(c.lng,c.lat):x.convert(c),this}setSouthWest(c){return this._sw=c instanceof x?new x(c.lng,c.lat):x.convert(c),this}extend(c){const m=this._sw,v=this._ne;let N,E;if(c instanceof x)N=c,E=c;else{if(!(c instanceof A))return Array.isArray(c)?c.length===4||c.every(Array.isArray)?this.extend(A.convert(c)):this.extend(x.convert(c)):typeof c=="object"&&c!==null&&c.hasOwnProperty("lat")&&(c.hasOwnProperty("lon")||c.hasOwnProperty("lng"))?this.extend(x.convert(c)):this;if(N=c._sw,E=c._ne,!N||!E)return this}return m||v?(m.lng=Math.min(N.lng,m.lng),m.lat=Math.min(N.lat,m.lat),v.lng=Math.max(E.lng,v.lng),v.lat=Math.max(E.lat,v.lat)):(this._sw=new x(N.lng,N.lat),this._ne=new x(E.lng,E.lat)),this}getCenter(){return new x((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new x(this.getWest(),this.getNorth())}getSouthEast(){return new x(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(c){const{lng:m,lat:v}=x.convert(c);let N=this._sw.lng<=m&&m<=this._ne.lng;return this._sw.lng>this._ne.lng&&(N=this._sw.lng>=m&&m>=this._ne.lng),this._sw.lat<=v&&v<=this._ne.lat&&N}static convert(c){if(c)return c instanceof A?c:new A(c)}}const D=0,F=25.5;function z(g){return h*Math.cos(g*Math.PI/180)}function V(g){return(180+g)/360}function X(g){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+g*Math.PI/360)))/360}function ne(g,c){return g/z(c)}function oe(g){return 360*g-180}function ge(g){return 360/Math.PI*Math.atan(Math.exp((180-360*g)*Math.PI/180))-90}function pe(g,c){return g*z(ge(c))}const xe=85.051129;function Pe(g){return Math.cos(Ir(ye(g,-xe,xe)))}function Ce(g,c){const m=ye(c,D,F),v=Math.pow(2,m);return Pe(g)*h/(512*v)}function Ve(g){return 1/Math.cos(g*Math.PI/180)}function Be(g,c=0){const m=Math.exp(Math.PI*(1-(g.y+c/Xs)/(1<=B?(dt(g,c,m,W,J,E,ee,O,B),dt(g,W,J,v,N,ee,P,O,B)):g.push(P)}function st(g,c,m){let v=g[0],N=v.x,E=v.y;c(v);const P=[v];for(let O=1;Og.x+1||vg.y+1)&&ur("Geometry exceeds allowed extent, reduce your vector tile buffer size"),g}function Et(g,c,m){const v=g.loadGeometry(),N=g.extent,E=Xs/N;if(c&&m&&m.projection.isReprojectedInTileSpace){const P=1<{const ce=oe((c.x+ie.x/N)/P),ue=ge((c.y+ie.y/N)/P),ke=J.project(ce,ue);ie.x=(ke.x*O-B)*N,ie.y=(ke.y*O-W)*N};for(let ie=0;ie=N||ue.y<0||ue.y>=N||(ee(ue),ce.push(ue));v[ie]=ce}}for(const P of v)for(const O of P)mt(O,E);return v}function Ht(g,c){return{type:g.type,id:g.id,properties:g.properties,geometry:c?Et(g):[]}}class Ut{constructor(c,m,v,N,E){this.properties={},this.extent=v,this.type=0,this.id=void 0,this._pbf=c,this._geometry=-1,this._keys=N,this._values=E,c.readFields(ts,this,m)}loadGeometry(){const c=this._pbf;c.pos=this._geometry;const m=c.readVarint()+c.pos,v=[];let N,E=1,P=0,O=0,B=0;for(;c.pos>3}if(P--,E===1||E===2)O+=c.readSVarint(),B+=c.readSVarint(),E===1&&(N&&v.push(N),N=[]),N&&N.push(new es(O,B));else{if(E!==7)throw new Error(`unknown command ${E}`);N&&N.push(N[0].clone())}}return N&&v.push(N),v}bbox(){const c=this._pbf;c.pos=this._geometry;const m=c.readVarint()+c.pos;let v=1,N=0,E=0,P=0,O=1/0,B=-1/0,W=1/0,J=-1/0;for(;c.pos>3}if(N--,v===1||v===2)E+=c.readSVarint(),P+=c.readSVarint(),EB&&(B=E),PJ&&(J=P);else if(v!==7)throw new Error(`unknown command ${v}`)}return[O,W,B,J]}toGeoJSON(c,m,v){const N=this.extent*Math.pow(2,v),E=this.extent*c,P=this.extent*m,O=this.loadGeometry();function B(ie){return[360*(ie.x+E)/N-180,360/Math.PI*Math.atan(Math.exp((1-2*(ie.y+P)/N)*Math.PI))-90]}function W(ie){return ie.map(B)}let J;if(this.type===1){const ie=[];for(const ue of O)ie.push(ue[0]);const ce=W(ie);J=ie.length===1?{type:"Point",coordinates:ce[0]}:{type:"MultiPoint",coordinates:ce}}else if(this.type===2){const ie=O.map(W);J=ie.length===1?{type:"LineString",coordinates:ie[0]}:{type:"MultiLineString",coordinates:ie}}else{if(this.type!==3)throw new Error("unknown feature type");{const ie=function(ue){const ke=ue.length;if(ke<=1)return[ue];const Le=[];let Ie,Ke;for(let Ye=0;Ye=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[c];const m=this._pbf.readVarint()+this._pbf.pos;return new Ut(this._pbf,m,this.extent,this._keys,this._values)}}function Bs(g,c,m){g===15?c.version=m.readVarint():g===1?c.name=m.readString():g===5?c.extent=m.readVarint():g===2?c._features.push(m.pos):g===3?c._keys.push(m.readString()):g===4&&c._values.push(function(v){let N=null;const E=v.readVarint()+v.pos;for(;v.pos>3;N=P===1?v.readString():P===2?v.readFloat():P===3?v.readDouble():P===4?v.readVarint64():P===5?v.readVarint():P===6?v.readSVarint():P===7?v.readBoolean():null}if(N==null)throw new Error("unknown feature value");return N}(m))}class Yt{constructor(c,m){this.layers=c.readFields(zt,{},m)}}function zt(g,c,m){if(g===3){const v=new fs(m,m.readVarint()+m.pos);v.length&&(c[v.name]=v)}}const ds="3d_elevation_id",Jt="level";class Es{constructor(){this._valid=!1}reset(c){return this.feature=c,this._valid=!0,this._geometry=c.loadGeometry(),this._geometry.length!==0&&this._geometry[0].length!==0||(this._valid=!1),this}geometry(c,m){return this._valid&&c(m(this._geometry)),this}require(c,m,v){return this.get(c,!0,m,v)}optional(c,m,v){return this.get(c,!1,m,v)}success(){return this._valid}get(c,m,v,N){const E=this.feature.properties.hasOwnProperty(c)?+this.feature.properties[c]:void 0;return this._valid&&E!==void 0&&!Number.isNaN(E)?v(N?N(E):E):m&&(this._valid=!1),this}}class Js{constructor(c,m){this.featureFunc=c,this.vertexFunc=m}parseFeature(c,m,v){return this.featureFunc(c,m,v)}parseVertex(c,m,v){return this.vertexFunc(c,m,v)}}const mr=new Js((g,c,m)=>g.reset(c).require(ds,v=>{m.id=v}).optional("fixed_height_relative",v=>{m.constantHeight=v},Us.decodeRelativeHeight).geometry(v=>{m.bounds=v},Wf).success(),(g,c,m)=>g.reset(c).require(ds,v=>{m.id=v}).require("elevation_idx",v=>{m.idx=v}).require("extent",v=>{m.extent=v}).require("height_relative",v=>{m.height=v},Us.decodeRelativeHeight).geometry(v=>{m.position=v},Us.getPoint).success()),Ys=new Js((g,c,m)=>g.reset(c).require(ds,v=>{m.id=v}).optional("fixed_height",v=>{m.constantHeight=v},Us.decodeMetricHeight).geometry(v=>{m.bounds=v},Wf).success(),(g,c,m)=>g.reset(c).require(ds,v=>{m.id=v}).require("elevation_idx",v=>{m.idx=v}).require("extent",v=>{m.extent=v}).require("height",v=>{m.height=v},Us.decodeMetricHeight).geometry(v=>{m.position=v},Us.getPoint).success());class Us{static getPoint(c){return Ct(c[0][0].x,c[0][0].y)}static decodeRelativeHeight(c){return 1e-4*c*5}static decodeMetricHeight(c){return 1e-4*c}static getVersionSchema(c){return c?c==="1.0.1"?Ys:void 0:mr}static parse(c){const m=[],v=[],N=c.length,E=new Es;for(let P=0;P=0);if(E===0)return 0;E!==c.length&&(m=!1)}return m?2:1}function jn(g,c){for(const m of g.projections){const v=xr(c,g.points[0],m.axis);if(m.projection[1]v[1])return 0}return 1}function pa(g,c){let m=0;const v=[0,0,0,0];for(let P=0;P=0&&m++;var N,E;return m}class Ha{constructor(c,m){this.points=c||new Array(8).fill([0,0,0]),this.planes=m||new Array(6).fill([0,0,0,0]),this.bounds=Er.fromPoints(this.points),this.projections=[],this.frustumEdges=[Se([],this.points[2],this.points[3]),Se([],this.points[0],this.points[3]),Se([],this.points[4],this.points[0]),Se([],this.points[5],this.points[1]),Se([],this.points[6],this.points[2]),Se([],this.points[7],this.points[3])];for(const v of this.frustumEdges){const N=[0,-v[2],v[1]],E=[v[2],0,-v[0]];this.projections.push({axis:N,projection:xr(this.points,this.points[0],N)}),this.projections.push({axis:E,projection:xr(this.points,this.points[0],E)})}}static fromInvProjectionMatrix(c,m,v,N){const E=Math.pow(2,v),P=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(W=>{const J=Qe([],W,c),ee=1/J[3]/m*E;return(ie=J)[0]=(ce=J)[0]*(ue=[ee,ee,N?1/J[3]:ee,ee])[0],ie[1]=ce[1]*ue[1],ie[2]=ce[2]*ue[2],ie[3]=ce[3]*ue[3],ie;var ie,ce,ue}),O=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(W=>{const J=Ae([],ut([],Se([],P[W[0]],P[W[1]]),Se([],P[W[2]],P[W[1]]))),ee=-Ue(J,P[W[1]]);return J.concat(ee)}),B=[];for(let W=0;WW[1]||W[0]>B[1])return 0}return 1}containsPoint(c){for(const m of this.planes){const v=m[3];if(Ue([m[0],m[1],m[2]],c)+v<0)return!1}return!0}}class Er{static fromPoints(c){const m=[1/0,1/0,1/0],v=[-1/0,-1/0,-1/0];for(const N of c)_e(m,m,N),je(v,v,N);return new Er(m,v)}static fromTileIdAndHeight(c,m,v){const N=1<c.max[m]||c.min[m]>this.max[m])return!1;return!0}intersectsAabbXY(c){return!(this.min[0]>c.max[0]||c.min[0]>this.max[0]||this.min[1]>c.max[1]||c.min[1]>this.max[1])}encapsulate(c){for(let m=0;m<3;m++)this.min[m]=Math.min(this.min[m],c.min[m]),this.max[m]=Math.max(this.max[m],c.max[m])}encapsulatePoint(c){for(let m=0;m<3;m++)this.min[m]=Math.min(this.min[m],c[m]),this.max[m]=Math.max(this.max[m],c[m])}closestPoint(c){return[Math.max(Math.min(this.max[0],c[0]),this.min[0]),Math.max(Math.min(this.max[1],c[1]),this.min[1]),Math.max(Math.min(this.max[2],c[2]),this.min[2])]}}_r(Er,"Aabb");class Fa{constructor(c,m){this.feature=c,this.metersToTile=m,this.index=0}get(){const c=this.feature.vertices[this.index],m=this.feature.vertexProps[this.index].dir,v=m[1],N=-m[0],E=(c.extent+1)*this.metersToTile;return[new es(Math.trunc(c.position[0]+v*E),Math.trunc(c.position[1]+N*E)),new es(Math.trunc(c.position[0]-v*E),Math.trunc(c.position[1]-N*E))]}next(){this.index++}valid(){return this.index{return O.a0?Ne(B,B,1/W):ae(B,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(c){if(this.edges.length===0)return;let m=0,v=Number.POSITIVE_INFINITY,N=0;const[E,P,O,B,W,J,ee]=this._tmpVec2;Is(ee,c.x,c.y);const ie=new Cr(ee,null);for(let ce=0;ce0?si(B,O)/at:0,pt=ye(vt,0,1),kt=Math.abs((vt-pt)*this.edgeProps[ce].len);gr(W,ee,Le),Is(J,ke[1],-ke[0]);const Lt=kt+Math.abs(si(W,J));Lt=0;--P){const O=this.edges[P].a,B=this.edges[P].b,{position:W,height:J,extent:ee}=this.vertices[O],{position:ie,height:ce,extent:ue}=this.vertices[B],ke=this.vertexProps[O].dir,Le=this.vertexProps[B].dir;if(ae(m,W[0]/c,W[1]/c,J),ae(v,ie[0]/c,ie[1]/c,ce),ae(N,ke[1],-ke[0],0),Ne(N,N,ee),ae(E,Le[1],-Le[0],0),Ne(E,E,ue),this.distSqLines(re(m[0]+.5*N[0],m[1]+.5*N[1],m[2]+.5*N[2]),re(v[0]-.5*E[0],v[1]-.5*E[1],v[2]-.5*E[2]),re(m[0]-.5*N[0],m[1]-.5*N[1],m[2]-.5*N[2]),re(v[0]+.5*E[0],v[1]+.5*E[1],v[2]+.5*E[2]))<=.0025000000000000005)continue;const Ie=this.vertices.length,Ke=qs(ar(),W,ie);this.vertices.push({position:Wn(Ke,Ke,.5),height:.5*(J+ce),extent:.5*(ee+ue)});const Ye=qs(ar(),ke,Le);this.vertexProps.push({dir:bo(Ye,Ye)}),this.edges.splice(P,1),this.edgeProps.splice(P,1),this.edges.push({a:O,b:Ie}),this.edges.push({a:Ie,b:B});const at=gr(ar(),this.vertices[Ie].position,W),vt=ii(at),pt={vec:at,dir:Wn(ar(),at,1/vt),len:vt};this.edgeProps.push(pt),this.edgeProps.push(pt)}}distSqLines(c,m,v,N){const E=he(te(),m,c),P=he(te(),N,v),O=he(te(),c,v),B=Ue(E,E),W=Ue(E,P),J=Ue(E,O),ee=Ue(P,P),ie=Ue(P,O),ce=B*ee-W*W;if(ce===0)return Me(De(E,v,N,Ue(O,P)/Ue(P,P)),c);const ue=(B*ie-W*J)/ce;return Me(De(E,c,m,(W*ie-J*ee)/ce),De(P,v,N,ue))}}class Xa{static parseFrom(c,m){const v=Us.parse(c);if(!v)return[];let{vertices:N,features:E}=v;const P=1/Be(m);E.sort((J,ee)=>J.id-ee.id),N.sort((J,ee)=>J.id-ee.id||J.idx-ee.idx),N=N.filter((J,ee,ie)=>ee===ie.findIndex(ce=>ce.id===J.id&&ce.idx===J.idx));const O=new Array;let B=0;const W=N.length;for(const J of E){if(J.constantHeight){O.push(new vn(J.id,J.bounds,J.constantHeight));continue}for(;B!==W&&N[B].idN.id===v)}}class fi{constructor(c,m){this.zScale=1,this.xOffset=0,this.yOffset=0,c.equals(m)||(this.zScale=Math.pow(2,m.z-c.z),this.xOffset=(c.x*this.zScale-m.x)*Xs,this.yOffset=(c.y*this.zScale-m.y)*Xs)}constantElevation(c,m){if(c.constantHeight!=null)return this.computeBiasedHeight(c.constantHeight,m)}pointElevation(c,m,v){const N=this.constantElevation(m,v);return N??(c.x=c.x*this.zScale+this.xOffset,c.y=c.y*this.zScale+this.yOffset,this.computeBiasedHeight(m.pointElevation(c),v))}computeBiasedHeight(c,m){return m<=0?c:c+m*ze(0,m,c>=0?c:Math.abs(.5*c))}}_r(vn,"ElevationFeature");class oi{constructor(c){this.zoom=c.zoom,this.overscaling=c.overscaling,this.layers=c.layers,this.layerIds=this.layers.map(m=>m.fqid),this.index=c.index,this.hasPattern=!1,this.projection=c.projection,this.layoutVertexArray=new vx,this.indexArray=new bl,this.segments=new co,this.programConfigurations=new Xm(c.layers,{zoom:c.zoom,lut:c.lut}),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,this.elevationMode!=="none"&&(this.elevatedLayoutVertexArray=new Qf),this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,v,N){}populate(c,m,v,N){const E=this.layers[0],P=[];let O=null;E.type==="circle"&&(O=E.layout.get("circle-sort-key"));for(const{feature:W,id:J,index:ee,sourceLayerIndex:ie}of c){const ce=this.layers[0]._featureFilter.needGeometry,ue=Ht(W,ce);if(!this.layers[0]._featureFilter.filter(new Fi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ue,v))continue;const ke=O?O.evaluate(ue,{},v):void 0,Le={id:J,properties:W.properties,type:W.type,sourceLayerIndex:ie,index:ee,geometry:ce?ue.geometry:Et(W,v,N),patterns:{},sortKey:ke};P.push(Le)}O&&P.sort((W,J)=>W.sortKey-J.sortKey);let B=null;N.projection.name==="globe"&&(this.globeExtVertexArray=new hC,B=N.projection);for(const W of P){const{geometry:J,index:ee,sourceLayerIndex:ie}=W,ce=c[ee].feature;this.addFeature(W,J,ee,m.availableImages,v,B,m.brightness,m.elevationFeatures),m.featureIndex.insert(ce,J,ee,ie,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(c,m,v,N,E,P,O){this.programConfigurations.updatePaintArrays(c,m,E,v,N,P,O,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,pO.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,fO.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=c.createVertexBuffer(this.elevatedLayoutVertexArray,mde.members))),this.programConfigurations.upload(c),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy())}addFeature(c,m,v,N,E,P,O,B){let W;this.elevationMode!=="none"&&(W=Xa.getElevationFeature(c,B));for(const J of m)for(const ee of J){const ie=ee.x,ce=ee.y;if(ie<0||ie>=Xs||ce<0||ce>=Xs)continue;if(P){const Le=P.projectTilePoint(ie,ce,E),Ie=P.upVector(E,ie,ce);this.addGlobeExtVertex(Le,Ie),this.addGlobeExtVertex(Le,Ie),this.addGlobeExtVertex(Le,Ie),this.addGlobeExtVertex(Le,Ie)}const ue=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,c.sortKey),ke=ue.vertexLength;if(this.addCircleVertex(ie,ce,-1,-1),this.addCircleVertex(ie,ce,1,-1),this.addCircleVertex(ie,ce,1,1),this.addCircleVertex(ie,ce,-1,1),this.elevationMode!=="none"){const Le=W?W.pointElevation(new es(ie,ce)):0;this.hasElevation=this.hasElevation||Le!==0;for(let Ie=0;Ie<4;Ie++)this.elevatedLayoutVertexArray.emplaceBack(Le)}this.indexArray.emplaceBack(ke,ke+1,ke+2),this.indexArray.emplaceBack(ke,ke+2,ke+3),ue.vertexLength+=4,ue.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,v,{},N,E,O,void 0,this.worldview)}addCircleVertex(c,m,v,N){this.layoutVertexArray.emplaceBack(2*c+(v+1)/2,2*m+(N+1)/2)}addGlobeExtVertex(c,m){this.globeExtVertexArray.emplaceBack(c.x,c.y,c.z,m[0]*16384,m[1]*16384,m[2]*16384)}}function Oa(g,c){for(let m=0;m1){if(Gi(g,c))return!0;for(let v=0;v1?m:m.sub(c)._mult(N)._add(c))}function uo(g,c){let m,v,N,E=!1;for(let P=0;Pc.y!=N.y>c.y&&c.x<(N.x-v.x)*(c.y-v.y)/(N.y-v.y)+v.x&&(E=!E)}return E}function ji(g,c){let m=!1;for(let v=0,N=g.length-1;vc.y!=P.y>c.y&&c.x<(P.x-E.x)*(c.y-E.y)/(P.y-E.y)+E.x&&(m=!m)}return m}function ru(g,c,m,v,N){for(const P of g)if(c<=P.x&&m<=P.y&&v>=P.x&&N>=P.y)return!0;const E=[new es(c,m),new es(c,N),new es(v,N),new es(v,m)];if(g.length>2){for(const P of E)if(ji(g,P))return!0}for(let P=0;PN.x&&c.x>N.x||g.yN.y&&c.y>N.y)return!1;const E=Cn(g,c,m[0]);return E!==Cn(g,c,m[1])||E!==Cn(g,c,m[2])||E!==Cn(g,c,m[3])}function jl(g,c,m,v,N,E){let P=c.y-g.y,O=g.x-c.x;if(E=E||0){const B=P*P+O*O;if(B===0)return!0;const W=Math.sqrt(B);P/=W,O/=W}return!((m.x-g.x)*P+(m.y-g.y)*O-E<0||(v.x-g.x)*P+(v.y-g.y)*O-E<0||(N.x-g.x)*P+(N.y-g.y)*O-E<0)}function fd(g,c,m,v,N,E,P){return!(jl(g,c,v,N,E,P)||jl(c,m,v,N,E,P)||jl(m,g,v,N,E,P)||jl(v,N,g,c,m,P)||jl(N,E,g,c,m,P)||jl(E,v,g,c,m,P))}function gd(g,c,m){const v=c.paint.get(g).value;return v.kind==="constant"?v.value:m.programConfigurations.get(c.id).getMaxValue(g)}function Ic(g){return Math.sqrt(g[0]*g[0]+g[1]*g[1])}function jh(g,c,m,v,N){if(!c[0]&&!c[1])return g;const E=es.convert(c)._mult(N);m==="viewport"&&E._rotate(-v);const P=[];for(let O=0;O>m&&c.y===this.y>>m}url(c,m){const v=function(E,P,O){var B=Ro(256*E,256*(P=Math.pow(2,O)-P-1),O),W=Ro(256*(E+1),256*(P+1),O);return B[0]+","+B[1]+","+W[0]+","+W[1]}(this.x,this.y,this.z),N=function(E,P,O){let B,W="";for(let J=E;J>0;J--)B=1<this.canonical.z?new go(c,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new go(c,this.wrap,c,this.canonical.x>>m,this.canonical.y>>m)}calculateScaledKey(c,m=!0){if(this.overscaledZ===c&&m)return this.key;if(c>this.canonical.z)return ho(this.wrap*+m,c,this.canonical.z,this.canonical.x,this.canonical.y);{const v=this.canonical.z-c;return ho(this.wrap*+m,c,c,this.canonical.x>>v,this.canonical.y>>v)}}isChildOf(c){if(c.wrap!==this.wrap)return!1;const m=this.canonical.z-c.canonical.z;return c.overscaledZ===0||c.overscaledZ>m&&c.canonical.y===this.canonical.y>>m}children(c){if(this.overscaledZ>=c)return[new go(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const m=this.canonical.z+1,v=2*this.canonical.x,N=2*this.canonical.y;return[new go(m,this.wrap,m,v,N),new go(m,this.wrap,m,v+1,N),new go(m,this.wrap,m,v,N+1),new go(m,this.wrap,m,v+1,N+1)]}isLessThan(c){return this.wrapc.wrap)&&(this.overscaledZc.overscaledZ)&&(this.canonical.xc.canonical.x)&&this.canonical.y{let c=g.canonical.x-1,m=g.wrap;return c<0&&(c=(1<{let c=g.canonical.x+1,m=g.wrap;return c===1<new go(g.overscaledZ,g.wrap,g.canonical.z,g.canonical.x,(g.canonical.y===0?1<new go(g.overscaledZ,g.wrap,g.canonical.z,g.canonical.x,g.canonical.y===(1<1?null:function(v,N,E,P){const O=Math.sin(E);return v*(Math.sin((1-P)*E)/O)+N*(Math.sin(P*E)/O)}(g.a[c],g.b[c],g.angle,ye(m,0,1))+g.center[c]}function Jm(g){if(g.z<=1)return rg[g.z+2*g.y+g.x];const c=Nde(gO(g));return Er.fromPoints(c)}function ag(g,c,m){return Ne(g,g,1-m),Ge(g,g,c,m)}function eje(g,c,m){for(const v of g)Rt(v,v,c),Ne(v,v,m)}function tje(g,c,m,v){const N=c/g.worldSize,E=g.globeMatrix;if(m.z<=1){const $t=Jm(m).getCorners();return eje($t,E,N),Er.fromPoints($t)}const P=gO(m,v),O=Nde(P,pd+qp(g._tileCoverLift));eje(O,E,N);const B=Number.MAX_VALUE,W=[-B,-B,-B],J=[B,B,B];if(P.contains(g.center)){for(const Wt of O)_e(J,J,Wt),je(W,W,Wt);W[2]=0;const $t=g.point,ls=[$t.x*N,$t.y*N,0];return _e(J,J,ls),je(W,W,ls),new Er(J,W)}if(g._tileCoverLift>0){for(const $t of O)_e(J,J,$t),je(W,W,$t);return new Er(J,W)}const ee=[E[12]*N,E[13]*N,E[14]*N],ie=P.getCenter(),ce=ye(g.center.lat,-xe,xe),ue=ye(ie.lat,-xe,xe),ke=V(g.center.lng),Le=X(ce);let Ie=ke-V(ie.lng);const Ke=Le-X(ue);Ie>.5?Ie-=1:Ie<-.5&&(Ie+=1);let Ye=0;Math.abs(Ie)>Math.abs(Ke)?Ye=Ie>=0?1:3:(Ye=Ke>=0?0:2,Ge(ee,ee,[E[4]*N,E[5]*N,E[6]*N],-Math.sin(Ir(Ke>=0?P.getSouth():P.getNorth()))*pd));const at=O[Ye],vt=O[(Ye+1)%4],pt=new jx(at,vt,ee),kt=[ng(pt,0)||at[0],ng(pt,1)||at[1],ng(pt,2)||at[2]],Lt=Hv(g.zoom);if(Lt>0){const $t=function({x:Wt,y:ms,z:bs},ws,Os,Fs,Ps){const Ls=1/(1<.5?Vs=-1:Dr<-.5&&(Vs=1),hs=((hs+Vs)*ws-(Fs*=ws))*Os+Fs,cs=((cs+Vs)*ws-Fs)*Os+Fs,Ds=(Ds*ws-(Ps*=ws))*Os+Ps,Qs=(Qs*ws-Ps)*Os+Ps,[[hs,Qs,0],[cs,Qs,0],[cs,Ds,0],[hs,Ds,0]]}(m,c,g._pixelsPerMercatorPixel,ke,Le);for(let Wt=0;WtMath.PI/2*1.01}const ije=Ir(85),Vet=Math.cos(ije),Het=Math.sin(ije),Wet=b(),oje=g=>{const c=[];return g.paint.get("circle-pitch-alignment")==="map"&&c.push("PITCH_WITH_MAP"),g.paint.get("circle-pitch-scale")==="map"&&c.push("SCALE_WITH_MAP"),c};function lje(g,c,m,v,N,E,P,O,B){if(E&&g.queryGeometry.isAboveHorizon)return!1;E&&(B*=g.pixelToTileUnitsFactor);const W=g.tileID.canonical,J=m.projection.upVectorScale(W,m.center.lat,m.worldSize).metersToTile;for(const ee of c)for(const ie of ee){const ce=ie.add(O),ue=N&&m.elevation?m.elevation.exaggeration()*N.getElevationAt(ce.x,ce.y,!0):0,ke=m.projection.projectTilePoint(ce.x,ce.y,W);if(ue>0){const Ye=m.projection.upVector(W,ce.x,ce.y);ke.x+=Ye[0]*J*ue,ke.y+=Ye[1]*J*ue,ke.z+=Ye[2]*J*ue}const Le=E?ce:Get(ke.x,ke.y,ke.z,v),Ie=E?g.tilespaceRays.map(Ye=>Zet(Ye,ue)):g.queryGeometry.screenGeometry,Ke=Qe([],[ke.x,ke.y,ke.z,1],v);if(!P&&E?B*=Ke[3]/m.cameraToCenterDistance:P&&!E&&(B*=m.cameraToCenterDistance/Ke[3]),E){const Ye=ge((ie.y/Xs+W.y)/(1<g.width||N.height>g.height||m.x>g.width-N.width||m.y>g.height-N.height)throw new RangeError("out of range source coordinates for image copy");if(N.width>c.width||N.height>c.height||v.x>c.width-N.width||v.y>c.height-N.height)throw new RangeError("out of range destination coordinates for image copy");const B=g.data,W=c.data,J=E===4&&O;for(let ee=0;ee{c[g.evaluationKey]=B;const W=g.expression.evaluate(c),J=W?W.toNonPremultipliedRenderColor(null):null;J&&(N.data[P+O+0]=Math.floor(255*J.r),N.data[P+O+1]=Math.floor(255*J.g),N.data[P+O+2]=Math.floor(255*J.b),N.data[P+O+3]=Math.floor(255*J.a))};if(g.clips)for(let P=0,O=0;P80*m){O=g[0],B=g[1];let J=O,ee=B;for(let ie=m;ieJ&&(J=ce),ue>ee&&(ee=ue)}W=Math.max(J-O,ee-B),W=W!==0?32767/W:0}return iA(E,P,m,O,B,W,0),P}function yje(g,c,m,v,N){let E;if(N===function(P,O,B,W){let J=0;for(let ee=O,ie=B-W;ee0)for(let P=c;P=c;P-=v)E=wje(P/v|0,g[P],g[P+1],E);return E&&EC(E,E.next)&&(cA(E),E=E.next),E}function Ub(g,c){if(!g)return g;c||(c=g);let m,v=g;do if(m=!1,v.steiner||!EC(v,v.next)&&bc(v.prev,v,v.next)!==0)v=v.next;else{if(cA(v),v=c=v.prev,v===v.next)break;m=!0}while(m||v!==c);return c}function iA(g,c,m,v,N,E,P){if(!g)return;!P&&E&&function(B,W,J,ee){let ie=B;do ie.z===0&&(ie.z=Tde(ie.x,ie.y,W,J,ee)),ie.prevZ=ie.prev,ie.nextZ=ie.next,ie=ie.next;while(ie!==B);ie.prevZ.nextZ=null,ie.prevZ=null,function(ce){let ue,ke=1;do{let Le,Ie=ce;ce=null;let Ke=null;for(ue=0;Ie;){ue++;let Ye=Ie,at=0;for(let pt=0;pt0||vt>0&&Ye;)at!==0&&(vt===0||!Ye||Ie.z<=Ye.z)?(Le=Ie,Ie=Ie.nextZ,at--):(Le=Ye,Ye=Ye.nextZ,vt--),Ke?Ke.nextZ=Le:ce=Le,Le.prevZ=Ke,Ke=Le;Ie=Ye}Ke.nextZ=null,ke*=2}while(ue>1)}(ie)}(g,v,N,E);let O=g;for(;g.prev!==g.next;){const B=g.prev,W=g.next;if(E?ttt(g,v,N,E):ett(g))c.push(B.i,g.i,W.i),cA(g),g=W.next,O=W.next;else if((g=W)===O){P?P===1?iA(g=stt(Ub(g),c),c,m,v,N,E,2):P===2&&rtt(g,c,m,v,N,E):iA(Ub(g),c,m,v,N,E,1);break}}}function ett(g){const c=g.prev,m=g,v=g.next;if(bc(c,m,v)>=0)return!1;const N=c.x,E=m.x,P=v.x,O=c.y,B=m.y,W=v.y,J=Math.min(N,E,P),ee=Math.min(O,B,W),ie=Math.max(N,E,P),ce=Math.max(O,B,W);let ue=v.next;for(;ue!==c;){if(ue.x>=J&&ue.x<=ie&&ue.y>=ee&&ue.y<=ce&&oA(N,O,E,B,P,W,ue.x,ue.y)&&bc(ue.prev,ue,ue.next)>=0)return!1;ue=ue.next}return!0}function ttt(g,c,m,v){const N=g.prev,E=g,P=g.next;if(bc(N,E,P)>=0)return!1;const O=N.x,B=E.x,W=P.x,J=N.y,ee=E.y,ie=P.y,ce=Math.min(O,B,W),ue=Math.min(J,ee,ie),ke=Math.max(O,B,W),Le=Math.max(J,ee,ie),Ie=Tde(ce,ue,c,m,v),Ke=Tde(ke,Le,c,m,v);let Ye=g.prevZ,at=g.nextZ;for(;Ye&&Ye.z>=Ie&&at&&at.z<=Ke;){if(Ye.x>=ce&&Ye.x<=ke&&Ye.y>=ue&&Ye.y<=Le&&Ye!==N&&Ye!==P&&oA(O,J,B,ee,W,ie,Ye.x,Ye.y)&&bc(Ye.prev,Ye,Ye.next)>=0||(Ye=Ye.prevZ,at.x>=ce&&at.x<=ke&&at.y>=ue&&at.y<=Le&&at!==N&&at!==P&&oA(O,J,B,ee,W,ie,at.x,at.y)&&bc(at.prev,at,at.next)>=0))return!1;at=at.nextZ}for(;Ye&&Ye.z>=Ie;){if(Ye.x>=ce&&Ye.x<=ke&&Ye.y>=ue&&Ye.y<=Le&&Ye!==N&&Ye!==P&&oA(O,J,B,ee,W,ie,Ye.x,Ye.y)&&bc(Ye.prev,Ye,Ye.next)>=0)return!1;Ye=Ye.prevZ}for(;at&&at.z<=Ke;){if(at.x>=ce&&at.x<=ke&&at.y>=ue&&at.y<=Le&&at!==N&&at!==P&&oA(O,J,B,ee,W,ie,at.x,at.y)&&bc(at.prev,at,at.next)>=0)return!1;at=at.nextZ}return!0}function stt(g,c){let m=g;do{const v=m.prev,N=m.next.next;!EC(v,N)&&_je(v,m,m.next,N)&&lA(v,N)&&lA(N,v)&&(c.push(v.i,m.i,N.i),cA(m),cA(m.next),m=g=N),m=m.next}while(m!==g);return Ub(m)}function rtt(g,c,m,v,N,E){let P=g;do{let O=P.next.next;for(;O!==P.prev;){if(P.i!==O.i&<t(P,O)){let B=bje(P,O);return P=Ub(P,P.next),B=Ub(B,B.next),iA(P,c,m,v,N,E,0),void iA(B,c,m,v,N,E,0)}O=O.next}P=P.next}while(P!==g)}function ntt(g,c){let m=g.x-c.x;return m===0&&(m=g.y-c.y,m===0)&&(m=(g.next.y-g.y)/(g.next.x-g.x)-(c.next.y-c.y)/(c.next.x-c.x)),m}function att(g,c){const m=function(N,E){let P=E;const O=N.x,B=N.y;let W,J=-1/0;if(EC(N,P))return P;do{if(EC(N,P.next))return P.next;if(B<=P.y&&B>=P.next.y&&P.next.y!==P.y){const ke=P.x+(B-P.y)*(P.next.x-P.x)/(P.next.y-P.y);if(ke<=O&&ke>J&&(J=ke,W=P.x=P.x&&P.x>=ie&&O!==P.x&&vje(BW.x||P.x===W.x&&itt(W,P)))&&(W=P,ue=ke)}P=P.next}while(P!==ee);return W}(g,c);if(!m)return c;const v=bje(m,g);return Ub(v,v.next),Ub(m,m.next)}function itt(g,c){return bc(g.prev,g,c.prev)<0&&bc(c.next,g,g.next)<0}function Tde(g,c,m,v,N){return(g=1431655765&((g=858993459&((g=252645135&((g=16711935&((g=(g-m)*N|0)|g<<8))|g<<4))|g<<2))|g<<1))|(c=1431655765&((c=858993459&((c=252645135&((c=16711935&((c=(c-v)*N|0)|c<<8))|c<<4))|c<<2))|c<<1))<<1}function ott(g){let c=g,m=g;do(c.x=(g-P)*(E-O)&&(g-P)*(v-O)>=(m-P)*(c-O)&&(m-P)*(E-O)>=(N-P)*(v-O)}function oA(g,c,m,v,N,E,P,O){return!(g===P&&c===O)&&vje(g,c,m,v,N,E,P,O)}function ltt(g,c){return g.next.i!==c.i&&g.prev.i!==c.i&&!function(m,v){let N=m;do{if(N.i!==m.i&&N.next.i!==m.i&&N.i!==v.i&&N.next.i!==v.i&&_je(N,N.next,m,v))return!0;N=N.next}while(N!==m);return!1}(g,c)&&(lA(g,c)&&lA(c,g)&&function(m,v){let N=m,E=!1;const P=(m.x+v.x)/2,O=(m.y+v.y)/2;do N.y>O!=N.next.y>O&&N.next.y!==N.y&&P<(N.next.x-N.x)*(O-N.y)/(N.next.y-N.y)+N.x&&(E=!E),N=N.next;while(N!==m);return E}(g,c)&&(bc(g.prev,g,c.prev)||bc(g,c.prev,c))||EC(g,c)&&bc(g.prev,g,g.next)>0&&bc(c.prev,c,c.next)>0)}function bc(g,c,m){return(c.y-g.y)*(m.x-c.x)-(c.x-g.x)*(m.y-c.y)}function EC(g,c){return g.x===c.x&&g.y===c.y}function _je(g,c,m,v){const N=_O(bc(g,c,m)),E=_O(bc(g,c,v)),P=_O(bc(m,v,g)),O=_O(bc(m,v,c));return N!==E&&P!==O||!(N!==0||!vO(g,m,c))||!(E!==0||!vO(g,v,c))||!(P!==0||!vO(m,g,v))||!(O!==0||!vO(m,c,v))}function vO(g,c,m){return c.x<=Math.max(g.x,m.x)&&c.x>=Math.min(g.x,m.x)&&c.y<=Math.max(g.y,m.y)&&c.y>=Math.min(g.y,m.y)}function _O(g){return g>0?1:g<0?-1:0}function lA(g,c){return bc(g.prev,g,g.next)<0?bc(g,c,g.next)>=0&&bc(g,g.prev,c)>=0:bc(g,c,g.prev)<0||bc(g,g.next,c)<0}function bje(g,c){const m=Ade(g.i,g.x,g.y),v=Ade(c.i,c.x,c.y),N=g.next,E=c.prev;return g.next=c,c.prev=g,m.next=N,N.prev=m,v.next=m,m.prev=v,E.next=v,v.prev=E,v}function wje(g,c,m,v){const N=Ade(g,c,m);return v?(N.next=v.next,N.prev=v,v.next.prev=N,v.next=N):(N.prev=N,N.next=N),N}function cA(g){g.next.prev=g.prev,g.prev.next=g.next,g.prevZ&&(g.prevZ.nextZ=g.nextZ),g.nextZ&&(g.nextZ.prevZ=g.prevZ)}function Ade(g,c,m){return{i:g,x:c,y:m,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function dA(g,c){const m=g.length;if(m<=1)return[g];const v=[];let N,E;for(let P=0;P1)for(let P=0;P=Xs&&m>=Xs}static evaluate(c){if(c.length===0)return new Wy;let m=[];for(const B of c)m.push(...B.portals);if(m.length===0)return new Wy;for(const B of m){const W=B.va,J=B.vb;(Wy.isOnBorder(W.x,J.x)||Wy.isOnBorder(W.y,J.y))&&(B.type="border")}const v=m.filter(B=>B.type!=="unevaluated"),N=m.filter(B=>B.type==="unevaluated");if(N.length===0)return new Wy;N.sort((B,W)=>B.hash===W.hash?B.isTunnel===W.isTunnel?0:B.isTunnel?-1:1:B.hashB.hashE!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new Xm(m,{zoom:v,lut:N},E=>E!=="fill-bridge-guard-rail-color")}addVertices(c,m){const v=this.unevalVertices.length;for(let N=0;N=E.min.x&&ee.x<=E.max.x&&ee.y>=E.min.y&&ee.y<=E.max.y||ie.x>=E.min.x&&ie.x<=E.max.x&&ie.y>=E.min.y&&ie.y<=E.max.y||ed(ee,ie,O))||this.isOnBorder(ee.x,ie.x)||this.isOnBorder(ee.y,ie.y))continue;const ce=Nh.computeEdgeHash(this.unevalVertices[W],this.unevalVertices[J]);let ue,ke=this.vertexHashLookup.get(Nh.computePosHash(ee));ke!=null?ue=ke.next:(ke=this.vertexHashLookup.get(Nh.computePosHash(ie)),ue=ke!=null?ke.prev:ce),this.unevalEdges.push({polygonIdx:c,a:W,b:J,hash:ce,portalHash:ue,isTunnel:N,type:"unevaluated",featureInfo:P})}}addPortalCandidates(c,m,v,N,E){if(m.length===0)return;this.portalPolygons.add(c,{geometry:m,zLevel:E});const P=m[0];this.vertexHashLookup.clear();let O=Nh.computeEdgeHash(P[P.length-2],P[P.length-1]);for(let B=0;B({vertexOffset:0,primitiveOffset:this.indexArray.length}),v=ie=>{ie.primitiveLength=this.indexArray.length-ie.primitiveOffset},N=new dtt(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(c.portals,this.unevalEdges);const E=m(),P=m(),O=m(),B=(ie,ce)=>{ie.sort((ke,Le)=>ke.type===ce&&Le.type!==ce?-1:ke.type!==ce&&Le.type===ce?1:0);const ue=ie.findIndex(ke=>ke.type!==ce);return ue>=0?ue:ie.length};let W=0;this.unevalEdges.length>0&&(W=B(this.unevalEdges,"none"),this.constructBridgeStructures(N,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:W},this.tileToMeters)),v(O);const J=m(),ee=m();if(this.unevalEdges.length>0){const ie=this.unevalEdges.splice(W),ce=B(ie,"tunnel")+W;this.unevalEdges.push(...ie),this.constructTunnelStructures(N,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:W},{min:W,max:ce})}v(J),N.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),v(ee),N.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),v(P),N.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),v(E),this.maskSegments=co.simpleSegment(0,ee.primitiveOffset,0,ee.primitiveLength),this.depthSegments=co.simpleSegment(0,P.primitiveOffset,0,P.primitiveLength),this.renderableBridgeSegments=co.simpleSegment(0,O.primitiveOffset,0,O.primitiveLength),this.renderableTunnelSegments=co.simpleSegment(0,J.primitiveOffset,0,J.primitiveLength),this.shadowCasterSegments=co.simpleSegment(0,E.primitiveOffset,0,E.primitiveLength)}update(c,m,v,N,E,P,O,B){this.bridgeProgramConfigurations.updatePaintArrays(c,m,E,v,N,P,O,B),this.tunnelProgramConfigurations.updatePaintArrays(c,m,E,v,N,P,O,B)}upload(c){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=c.createVertexBuffer(this.vertexPositions,Qet.members),this.vertexBufferNormal=c.createVertexBuffer(this.vertexNormals,Jet.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(c),this.tunnelProgramConfigurations.upload(c))}destroy(){this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBufferNormal.destroy(),this.indexBuffer.destroy()),this.maskSegments&&(this.maskSegments.destroy(),this.depthSegments.destroy(),this.renderableBridgeSegments.destroy(),this.renderableTunnelSegments.destroy(),this.shadowCasterSegments.destroy()),this.bridgeProgramConfigurations.destroy(),this.tunnelProgramConfigurations.destroy()}populatePaintArrays(c,m,v,N,E){const P=(O,B)=>{for(let W=0;Wae(Os,m[Fs].x,m[Fs].y,v[Fs]*B),ee=te(),ie=te(),ce=te(),ue=te(),ke=te(),Le=(Os,Fs)=>{const Ps=O.get(Nh.computePosHash(m[Fs])),Ls=Ps.from,hs=Ps.to;if(!Ls||!hs)return;J(ee,Ls),J(ie,Fs),J(ce,hs),ot(ue),nt(ee,ie)||(Se(ke,ie,ee),Ae(ue,ke)),nt(ce,ie)||(Se(ke,ce,ie),le(ue,ue,Ae(ke,ke)));const cs=$e(ue);return cs>0?Ne(Os,ue,1/cs):void 0};let Ie=Number.POSITIVE_INFINITY;this.sortSubarray(N,E.min,E.max,(Os,Fs)=>Os.featureInfo.featureIndex-Fs.featureInfo.featureIndex);const Ke=te(),Ye=te(),at=te(),vt=te(),pt=te(),kt=te(),Lt=te(),$t=te(),ls=te(),Wt=[te(),te(),te(),te()],ms=[te(),te(),te(),te()],bs=[{coord:new es(0,0),height:0},{coord:new es(0,0),height:0}],ws=(Os,Fs)=>Os>Fs;for(let Os=E.min;OsIe.featureInfo.featureIndex-Ke.featureInfo.featureIndex;this.sortSubarray(N,E.min,E.max,B),this.sortSubarray(N,P.min,P.max,B);const W=Ie=>Ae(Ie,Ie),J=[{coord:new es(0,0),height:0},{coord:new es(0,0),height:0}],ee=(Ie,Ke)=>IeO.hash===B.hash?B.polygonIdx-O.polygonIdx:B.hash>O.hash?1:-1);let v=0,N=0,E=0,P=m[v].polygonIdx;do N++,(N===m.length||m[v].hash!==m[N].hash)&&((N-v==1||m[N-1].polygonIdx!==P)&&(EW.portalHashJ.hash?O++:J.hash>W.portalHash?B++:(W.type=J.type,O++)}}}isOnBorder(c,m){return c<=0&&m<=0||c>=Xs&&m>=Xs}addFeatureSection(c,m,v,N){return c!==m&&(m=c,v.push({featureIndex:c,vertexStart:N.getVertexCount()}),N.clearVertexLookup()),m}sortSubarray(c,m,v,N){const E=c.slice(m,v);E.sort(N),c.splice(m,E.length,...E)}static computeEdgeHash(c,m){return(c.y===m.y&&c.x>m.x||c.y>m.y)&&([c,m]=[m,c]),BigInt(Nh.computePosHash(c))<<32n|BigInt(Nh.computePosHash(m))}static computePosHash(c){return((65535&c.x)<<16|65535&c.y)>>>0}}var kje,Sje={exports:{}},Cje=(kje||(kje=1,function(g){function c(ft,_t){return ft>_t?1:ft<_t?-1:0}var m=function(ft,_t){ft===void 0&&(ft=c),_t===void 0&&(_t=!1),this._compare=ft,this._root=null,this._size=0,this._noDuplicates=!!_t},v={size:{configurable:!0}};function N(ft,_t,ps,Rs,ir){var or=ir-Rs;if(or>0){var Or=Rs+Math.floor(or/2),zr={key:_t[Or],data:ps[Or],parent:ft};return zr.left=N(zr,_t,ps,Rs,Or),zr.right=N(zr,_t,ps,Or+1,ir),zr}return null}function E(ft,_t,ps,Rs,ir){if(!(ps>=Rs)){for(var or=ft[ps+Rs>>1],Or=ps-1,zr=Rs+1;;){do Or++;while(ir(ft[Or],or)<0);do zr--;while(ir(ft[zr],or)>0);if(Or>=zr)break;var Sn=ft[Or];ft[Or]=ft[zr],ft[zr]=Sn,Sn=_t[Or],_t[Or]=_t[zr],_t[zr]=Sn}E(ft,_t,ps,zr,ir),E(ft,_t,zr+1,Rs,ir)}}m.prototype.rotateLeft=function(ft){var _t=ft.right;_t&&(ft.right=_t.left,_t.left&&(_t.left.parent=ft),_t.parent=ft.parent),ft.parent?ft===ft.parent.left?ft.parent.left=_t:ft.parent.right=_t:this._root=_t,_t&&(_t.left=ft),ft.parent=_t},m.prototype.rotateRight=function(ft){var _t=ft.left;_t&&(ft.left=_t.right,_t.right&&(_t.right.parent=ft),_t.parent=ft.parent),ft.parent?ft===ft.parent.left?ft.parent.left=_t:ft.parent.right=_t:this._root=_t,_t&&(_t.right=ft),ft.parent=_t},m.prototype._splay=function(ft){for(;ft.parent;){var _t=ft.parent;_t.parent?_t.left===ft&&_t.parent.left===_t?(this.rotateRight(_t.parent),this.rotateRight(_t)):_t.right===ft&&_t.parent.right===_t?(this.rotateLeft(_t.parent),this.rotateLeft(_t)):_t.left===ft&&_t.parent.right===_t?(this.rotateRight(_t),this.rotateLeft(_t)):(this.rotateLeft(_t),this.rotateRight(_t)):_t.left===ft?this.rotateRight(_t):this.rotateLeft(_t)}},m.prototype.splay=function(ft){for(var _t,ps,Rs,ir,or;ft.parent;)(ps=(_t=ft.parent).parent)&&ps.parent?((Rs=ps.parent).left===ps?Rs.left=ft:Rs.right=ft,ft.parent=Rs):(ft.parent=null,this._root=ft),ir=ft.left,or=ft.right,ft===_t.left?(ps&&(ps.left===_t?(_t.right?(ps.left=_t.right,ps.left.parent=ps):ps.left=null,_t.right=ps,ps.parent=_t):(ir?(ps.right=ir,ir.parent=ps):ps.right=null,ft.left=ps,ps.parent=ft)),or?(_t.left=or,or.parent=_t):_t.left=null,ft.right=_t,_t.parent=ft):(ps&&(ps.right===_t?(_t.left?(ps.right=_t.left,ps.right.parent=ps):ps.right=null,_t.left=ps,ps.parent=_t):(or?(ps.left=or,or.parent=ps):ps.left=null,ft.right=ps,ps.parent=ft)),ir?(_t.right=ir,ir.parent=_t):_t.right=null,ft.left=_t,_t.parent=ft)},m.prototype.replace=function(ft,_t){ft.parent?ft===ft.parent.left?ft.parent.left=_t:ft.parent.right=_t:this._root=_t,_t&&(_t.parent=ft.parent)},m.prototype.minNode=function(ft){if(ft===void 0&&(ft=this._root),ft)for(;ft.left;)ft=ft.left;return ft},m.prototype.maxNode=function(ft){if(ft===void 0&&(ft=this._root),ft)for(;ft.right;)ft=ft.right;return ft},m.prototype.insert=function(ft,_t){var ps=this._root,Rs=null,ir=this._compare;if(this._noDuplicates)for(;ps;){if(Rs=ps,ir(ps.key,ft)===0)return;ps=ir(ps.key,ft)<0?ps.right:ps.left}else for(;ps;)Rs=ps,ps=ir(ps.key,ft)<0?ps.right:ps.left;return ps={key:ft,data:_t,left:null,right:null,parent:Rs},Rs?ir(Rs.key,ps.key)<0?Rs.right=ps:Rs.left=ps:this._root=ps,this.splay(ps),this._size++,ps},m.prototype.find=function(ft){for(var _t=this._root,ps=this._compare;_t;){var Rs=ps(_t.key,ft);if(Rs<0)_t=_t.right;else{if(!(Rs>0))return _t;_t=_t.left}}return null},m.prototype.contains=function(ft){for(var _t=this._root,ps=this._compare;_t;){var Rs=ps(ft,_t.key);if(Rs===0)return!0;_t=Rs<0?_t.left:_t.right}return!1},m.prototype.remove=function(ft){var _t=this.find(ft);if(!_t)return!1;if(this.splay(_t),_t.left)if(_t.right){var ps=this.minNode(_t.right);ps.parent!==_t&&(this.replace(ps,ps.right),ps.right=_t.right,ps.right.parent=ps),this.replace(_t,ps),ps.left=_t.left,ps.left.parent=ps}else this.replace(_t,_t.left);else this.replace(_t,_t.right);return this._size--,!0},m.prototype.removeNode=function(ft){if(!ft)return!1;if(this.splay(ft),ft.left)if(ft.right){var _t=this.minNode(ft.right);_t.parent!==ft&&(this.replace(_t,_t.right),_t.right=ft.right,_t.right.parent=_t),this.replace(ft,_t),_t.left=ft.left,_t.left.parent=_t}else this.replace(ft,ft.left);else this.replace(ft,ft.right);return this._size--,!0},m.prototype.erase=function(ft){var _t=this.find(ft);if(_t){this.splay(_t);var ps=_t.left,Rs=_t.right,ir=null;ps&&(ps.parent=null,ir=this.maxNode(ps),this.splay(ir),this._root=ir),Rs&&(ps?ir.right=Rs:this._root=Rs,Rs.parent=ir),this._size--}},m.prototype.pop=function(){var ft=this._root,_t=null;if(ft){for(;ft.left;)ft=ft.left;_t={key:ft.key,data:ft.data},this.remove(ft.key)}return _t},m.prototype.next=function(ft){var _t=ft;if(_t)if(_t.right)for(_t=_t.right;_t&&_t.left;)_t=_t.left;else for(_t=ft.parent;_t&&_t.right===ft;)ft=_t,_t=_t.parent;return _t},m.prototype.prev=function(ft){var _t=ft;if(_t)if(_t.left)for(_t=_t.left;_t&&_t.right;)_t=_t.right;else for(_t=ft.parent;_t&&_t.left===ft;)ft=_t,_t=_t.parent;return _t},m.prototype.forEach=function(ft){for(var _t=this._root,ps=[],Rs=!1,ir=0;!Rs;)_t?(ps.push(_t),_t=_t.left):ps.length>0?(ft(_t=ps.pop(),ir++),_t=_t.right):Rs=!0;return this},m.prototype.range=function(ft,_t,ps,Rs){for(var ir=[],or=this._compare,Or=this._root;ir.length!==0||Or;)if(Or)ir.push(Or),Or=Or.left;else{if(or((Or=ir.pop()).key,_t)>0)break;if(or(Or.key,ft)>=0&&ps.call(Rs,Or))return this;Or=Or.right}return this},m.prototype.keys=function(){for(var ft=this._root,_t=[],ps=[],Rs=!1;!Rs;)ft?(_t.push(ft),ft=ft.left):_t.length>0?(ft=_t.pop(),ps.push(ft.key),ft=ft.right):Rs=!0;return ps},m.prototype.values=function(){for(var ft=this._root,_t=[],ps=[],Rs=!1;!Rs;)ft?(_t.push(ft),ft=ft.left):_t.length>0?(ft=_t.pop(),ps.push(ft.data),ft=ft.right):Rs=!0;return ps},m.prototype.at=function(ft){for(var _t=this._root,ps=[],Rs=!1,ir=0;!Rs;)if(_t)ps.push(_t),_t=_t.left;else if(ps.length>0){if(_t=ps.pop(),ir===ft)return _t;ir++,_t=_t.right}else Rs=!0;return null},m.prototype.load=function(ft,_t,ps){if(ft===void 0&&(ft=[]),_t===void 0&&(_t=[]),ps===void 0&&(ps=!1),this._size!==0)throw new Error("bulk-load: tree is not empty");var Rs=ft.length;return ps&&E(ft,_t,0,Rs-1,this._compare),this._root=N(null,ft,_t,0,Rs),this._size=Rs,this},m.prototype.min=function(){var ft=this.minNode(this._root);return ft?ft.key:null},m.prototype.max=function(){var ft=this.maxNode(this._root);return ft?ft.key:null},m.prototype.isEmpty=function(){return this._root===null},v.size.get=function(){return this._size},m.createTree=function(ft,_t,ps,Rs,ir){return new m(ps,ir).load(ft,_t,Rs)},Object.defineProperties(m.prototype,v);var P=0,O=1,B=2,W=3,J=0,ee=1,ie=2,ce=3;function ue(ft,_t,ps){_t===null?(ft.inOut=!1,ft.otherInOut=!0):(ft.isSubject===_t.isSubject?(ft.inOut=!_t.inOut,ft.otherInOut=_t.otherInOut):(ft.inOut=!_t.otherInOut,ft.otherInOut=_t.isVertical()?!_t.inOut:_t.inOut),_t&&(ft.prevInResult=!ke(_t,ps)||_t.isVertical()?_t.prevInResult:_t));var Rs=ke(ft,ps);ft.resultTransition=Rs?function(ir,or){var Or,zr=!ir.inOut,Sn=!ir.otherInOut;switch(or){case J:Or=zr&&Sn;break;case ee:Or=zr||Sn;break;case ce:Or=zr^Sn;break;case ie:Or=ir.isSubject?zr&&!Sn:Sn&&!zr}return Or?1:-1}(ft,ps):0}function ke(ft,_t){switch(ft.type){case P:switch(_t){case J:return!ft.otherInOut;case ee:return ft.otherInOut;case ie:return ft.isSubject&&ft.otherInOut||!ft.isSubject&&!ft.otherInOut;case ce:return!0}break;case B:return _t===J||_t===ee;case W:return _t===ie;case O:return!1}return!1}var Le=function(ft,_t,ps,Rs,ir){this.left=_t,this.point=ft,this.otherEvent=ps,this.isSubject=Rs,this.type=ir||P,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0},Ie={inResult:{configurable:!0}};function Ke(ft,_t){return ft[0]===_t[0]&&ft[1]===_t[1]}Le.prototype.isBelow=function(ft){var _t=this.point,ps=this.otherEvent.point;return this.left?(_t[0]-ft[0])*(ps[1]-ft[1])-(ps[0]-ft[0])*(_t[1]-ft[1])>0:(ps[0]-ft[0])*(_t[1]-ft[1])-(_t[0]-ft[0])*(ps[1]-ft[1])>0},Le.prototype.isAbove=function(ft){return!this.isBelow(ft)},Le.prototype.isVertical=function(){return this.point[0]===this.otherEvent.point[0]},Ie.inResult.get=function(){return this.resultTransition!==0},Le.prototype.clone=function(){var ft=new Le(this.point,this.left,this.otherEvent,this.isSubject,this.type);return ft.contourId=this.contourId,ft.resultTransition=this.resultTransition,ft.prevInResult=this.prevInResult,ft.isExteriorRing=this.isExteriorRing,ft.inOut=this.inOut,ft.otherInOut=this.otherInOut,ft},Object.defineProperties(Le.prototype,Ie);var Ye=11102230246251565e-32,at=134217729,vt=(3+8*Ye)*Ye;function pt(ft,_t,ps,Rs,ir){var or,Or,zr,Sn,zn=_t[0],Vn=Rs[0],la=0,Jr=0;Vn>zn==Vn>-zn?(or=zn,zn=_t[++la]):(or=Vn,Vn=Rs[++Jr]);var un=0;if(lazn==Vn>-zn?(zr=or-((Or=zn+or)-zn),zn=_t[++la]):(zr=or-((Or=Vn+or)-Vn),Vn=Rs[++Jr]),or=Or,zr!==0&&(ir[un++]=zr);lazn==Vn>-zn?(zr=or-((Or=or+zn)-(Sn=Or-or))+(zn-Sn),zn=_t[++la]):(zr=or-((Or=or+Vn)-(Sn=Or-or))+(Vn-Sn),Vn=Rs[++Jr]),or=Or,zr!==0&&(ir[un++]=zr);for(;la0!=la>0)return Jr;var un=Math.abs(Vn+la);return Math.abs(Jr)>=Lt*un?Jr:-function(Ia,za,Ba,li,ki,bi,Wa){var Ja,Bn,ya,so,Yr,ca,wi,Pi,zi,Fo,Li,Xr,mo,ci,Ki,Nl,cc,nl,al=Ia-ki,Gl=Ba-ki,Tu=za-bi,Di=li-bi;Wt[0]=(Ki=(Pi=al-(wi=(ca=at*al)-(ca-al)))*(Fo=Di-(zi=(ca=at*Di)-(ca-Di)))-((ci=al*Di)-wi*zi-Pi*zi-wi*Fo))-((Li=Ki-(cc=(Pi=Tu-(wi=(ca=at*Tu)-(ca-Tu)))*(Fo=Gl-(zi=(ca=at*Gl)-(ca-Gl)))-((Nl=Tu*Gl)-wi*zi-Pi*zi-wi*Fo)))+(Yr=Ki-Li))+(Yr-cc),Wt[1]=(mo=ci-((Xr=ci+Li)-(Yr=Xr-ci))+(Li-Yr))-((Li=mo-Nl)+(Yr=mo-Li))+(Yr-Nl),Wt[2]=Xr-((nl=Xr+Li)-(Yr=nl-Xr))+(Li-Yr),Wt[3]=nl;var Eo=function(Sx,td){for(var nu=td[0],Sh=1;Sh<4;Sh++)nu+=td[Sh];return nu}(0,Wt),zo=$t*Wa;if(Eo>=zo||-Eo>=zo||(Ja=Ia-(al+(Yr=Ia-al))+(Yr-ki),ya=Ba-(Gl+(Yr=Ba-Gl))+(Yr-ki),Bn=za-(Tu+(Yr=za-Tu))+(Yr-bi),so=li-(Di+(Yr=li-Di))+(Yr-bi),Ja===0&&Bn===0&&ya===0&&so===0)||(zo=ls*Wa+vt*Math.abs(Eo),(Eo+=al*so+Di*Ja-(Tu*ya+Gl*Bn))>=zo||-Eo>=zo))return Eo;Os[0]=(Ki=(Pi=Ja-(wi=(ca=at*Ja)-(ca-Ja)))*(Fo=Di-(zi=(ca=at*Di)-(ca-Di)))-((ci=Ja*Di)-wi*zi-Pi*zi-wi*Fo))-((Li=Ki-(cc=(Pi=Bn-(wi=(ca=at*Bn)-(ca-Bn)))*(Fo=Gl-(zi=(ca=at*Gl)-(ca-Gl)))-((Nl=Bn*Gl)-wi*zi-Pi*zi-wi*Fo)))+(Yr=Ki-Li))+(Yr-cc),Os[1]=(mo=ci-((Xr=ci+Li)-(Yr=Xr-ci))+(Li-Yr))-((Li=mo-Nl)+(Yr=mo-Li))+(Yr-Nl),Os[2]=Xr-((nl=Xr+Li)-(Yr=nl-Xr))+(Li-Yr),Os[3]=nl;var Wu=pt(4,Wt,4,Os,ms);Os[0]=(Ki=(Pi=al-(wi=(ca=at*al)-(ca-al)))*(Fo=so-(zi=(ca=at*so)-(ca-so)))-((ci=al*so)-wi*zi-Pi*zi-wi*Fo))-((Li=Ki-(cc=(Pi=Tu-(wi=(ca=at*Tu)-(ca-Tu)))*(Fo=ya-(zi=(ca=at*ya)-(ca-ya)))-((Nl=Tu*ya)-wi*zi-Pi*zi-wi*Fo)))+(Yr=Ki-Li))+(Yr-cc),Os[1]=(mo=ci-((Xr=ci+Li)-(Yr=Xr-ci))+(Li-Yr))-((Li=mo-Nl)+(Yr=mo-Li))+(Yr-Nl),Os[2]=Xr-((nl=Xr+Li)-(Yr=nl-Xr))+(Li-Yr),Os[3]=nl;var kl=pt(Wu,ms,4,Os,bs);Os[0]=(Ki=(Pi=Ja-(wi=(ca=at*Ja)-(ca-Ja)))*(Fo=so-(zi=(ca=at*so)-(ca-so)))-((ci=Ja*so)-wi*zi-Pi*zi-wi*Fo))-((Li=Ki-(cc=(Pi=Bn-(wi=(ca=at*Bn)-(ca-Bn)))*(Fo=ya-(zi=(ca=at*ya)-(ca-ya)))-((Nl=Bn*ya)-wi*zi-Pi*zi-wi*Fo)))+(Yr=Ki-Li))+(Yr-cc),Os[1]=(mo=ci-((Xr=ci+Li)-(Yr=Xr-ci))+(Li-Yr))-((Li=mo-Nl)+(Yr=mo-Li))+(Yr-Nl),Os[2]=Xr-((nl=Xr+Li)-(Yr=nl-Xr))+(Li-Yr),Os[3]=nl;var Vp=pt(kl,bs,4,Os,ws);return ws[Vp-1]}(ir,or,Or,zr,Sn,zn,un)}(ft[0],ft[1],_t[0],_t[1],ps[0],ps[1]);return Rs>0?-1:Rs<0?1:0}function Ps(ft,_t){var ps=ft.point,Rs=_t.point;return ps[0]>Rs[0]?1:ps[0]Rs[1]?1:-1:function(ir,or,Or,zr){return ir.left!==or.left?ir.left?1:-1:Fs(Or,ir.otherEvent.point,or.otherEvent.point)!==0?ir.isBelow(or.otherEvent.point)?-1:1:!ir.isSubject&&or.isSubject?1:-1}(ft,_t,ps)}function Ls(ft,_t,ps){var Rs=new Le(_t,!1,ft,ft.isSubject),ir=new Le(_t,!0,ft.otherEvent,ft.isSubject);return Ke(ft.point,ft.otherEvent.point)&&console.warn("what is that, a collapsed segment?",ft),Rs.contourId=ir.contourId=ft.contourId,Ps(ir,ft.otherEvent)>0&&(ft.otherEvent.left=!0,ir.left=!1),ft.otherEvent.otherEvent=ir,ft.otherEvent=Rs,ps.push(ir),ps.push(Rs),ps}function hs(ft,_t){return ft[0]*_t[1]-ft[1]*_t[0]}function cs(ft,_t){return ft[0]*_t[0]+ft[1]*_t[1]}function Ds(ft,_t,ps){var Rs=function(Sn,zn,Vn,la,Jr){var un=[zn[0]-Sn[0],zn[1]-Sn[1]],Ia=[la[0]-Vn[0],la[1]-Vn[1]];function za(ca,wi,Pi){return[ca[0]+wi*Pi[0],ca[1]+wi*Pi[1]]}var Ba=[Vn[0]-Sn[0],Vn[1]-Sn[1]],li=hs(un,Ia),ki=li*li,bi=cs(un,un);if(ki>0){var Wa=hs(Ba,Ia)/li;if(Wa<0||Wa>1)return null;var Ja=hs(Ba,un)/li;return Ja<0||Ja>1?null:Wa===0||Wa===1?[za(Sn,Wa,un)]:Ja===0||Ja===1?[za(Vn,Ja,Ia)]:[za(Sn,Wa,un)]}if((ki=(li=hs(Ba,un))*li)>0)return null;var Bn=cs(un,Ba)/bi,ya=Bn+cs(un,Ia)/bi,so=Math.min(Bn,ya),Yr=Math.max(Bn,ya);return so<=1&&Yr>=0?so===1?[za(Sn,so>0?so:0,un)]:Yr===0?[za(Sn,Yr<1?Yr:1,un)]:[za(Sn,so>0?so:0,un),za(Sn,Yr<1?Yr:1,un)]:null}(ft.point,ft.otherEvent.point,_t.point,_t.otherEvent.point),ir=Rs?Rs.length:0;if(ir===0||ir===1&&(Ke(ft.point,_t.point)||Ke(ft.otherEvent.point,_t.otherEvent.point))||ir===2&&ft.isSubject===_t.isSubject)return 0;if(ir===1)return Ke(ft.point,Rs[0])||Ke(ft.otherEvent.point,Rs[0])||Ls(ft,Rs[0],ps),Ke(_t.point,Rs[0])||Ke(_t.otherEvent.point,Rs[0])||Ls(_t,Rs[0],ps),1;var or=[],Or=!1,zr=!1;return Ke(ft.point,_t.point)?Or=!0:Ps(ft,_t)===1?or.push(_t,ft):or.push(ft,_t),Ke(ft.otherEvent.point,_t.otherEvent.point)?zr=!0:Ps(ft.otherEvent,_t.otherEvent)===1?or.push(_t.otherEvent,ft.otherEvent):or.push(ft.otherEvent,_t.otherEvent),Or&&zr||Or?(_t.type=O,ft.type=_t.inOut===ft.inOut?B:W,Or&&!zr&&Ls(or[1].otherEvent,or[0].point,ps),2):zr?(Ls(or[0],or[1].point,ps),3):or[0]!==or[3].otherEvent?(Ls(or[0],or[1].point,ps),Ls(or[1],or[2].point,ps),3):(Ls(or[0],or[1].point,ps),Ls(or[3].otherEvent,or[2].point,ps),3)}function Qs(ft,_t){if(ft===_t)return 0;if(Fs(ft.point,ft.otherEvent.point,_t.point)!==0||Fs(ft.point,ft.otherEvent.point,_t.otherEvent.point)!==0)return Ke(ft.point,_t.point)?ft.isBelow(_t.otherEvent.point)?-1:1:ft.point[0]===_t.point[0]?ft.point[1]<_t.point[1]?-1:1:Ps(ft,_t)===1?_t.isAbove(ft.point)?-1:1:ft.isBelow(_t.point)?-1:1;if(ft.isSubject!==_t.isSubject)return ft.isSubject?-1:1;var ps=ft.point,Rs=_t.point;return ps[0]===Rs[0]&&ps[1]===Rs[1]?(ps=ft.otherEvent.point)[0]===(Rs=_t.otherEvent.point)[0]&&ps[1]===Rs[1]?0:ft.contourId>_t.contourId?1:-1:Ps(ft,_t)===1?1:-1}var Vs=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function Dr(ft,_t,ps,Rs){var ir,or=ft+1,Or=_t[ft].point,zr=_t.length;for(orRs;)or--;return or}Vs.prototype.isExterior=function(){return this.holeOf==null};var dr=kr,yr=kr;function kr(ft,_t){if(!(this instanceof kr))return new kr(ft,_t);if(this.data=ft||[],this.length=this.data.length,this.compare=_t||Hn,this.length>0)for(var ps=(this.length>>1)-1;ps>=0;ps--)this._down(ps)}function Hn(ft,_t){return ft<_t?-1:ft>_t?1:0}kr.prototype={push:function(ft){this.data.push(ft),this.length++,this._up(this.length-1)},pop:function(){if(this.length!==0){var ft=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),ft}},peek:function(){return this.data[0]},_up:function(ft){for(var _t=this.data,ps=this.compare,Rs=_t[ft];ft>0;){var ir=ft-1>>1,or=_t[ir];if(ps(Rs,or)>=0)break;_t[ft]=or,ft=ir}_t[ft]=Rs},_down:function(ft){for(var _t=this.data,ps=this.compare,Rs=this.length>>1,ir=_t[ft];ft=0)break;_t[ft]=zr,ft=or}_t[ft]=ir}},dr.default=yr;var Ws=Math.max,Sr=Math.min,mn=0;function fa(ft,_t,ps,Rs,ir,or){var Or,zr,Sn,zn,Vn,la;for(Or=0,zr=ft.length-1;Or0?la.left=!0:Vn.left=!0;var Jr=Sn[0],un=Sn[1];ir[0]=Sr(ir[0],Jr),ir[1]=Sr(ir[1],un),ir[2]=Ws(ir[2],Jr),ir[3]=Ws(ir[3],un),Rs.push(Vn),Rs.push(la)}}var va=[];function Ln(ft,_t,ps){typeof ft[0][0][0]=="number"&&(ft=[ft]),typeof _t[0][0][0]=="number"&&(_t=[_t]);var Rs=function(un,Ia,za){var Ba=null;return un.length*Ia.length==0&&(za===J?Ba=va:za===ie?Ba=un:za!==ee&&za!==ce||(Ba=un.length===0?Ia:un)),Ba}(ft,_t,ps);if(Rs)return Rs===va?null:Rs;var ir=[1/0,1/0,-1/0,-1/0],or=[1/0,1/0,-1/0,-1/0],Or=function(un,Ia,za,Ba,li){var ki,bi,Wa,Ja,Bn,ya,so=new dr(null,Ps);for(Wa=0,Ja=un.length;WaBa[2]||Ba[0]>za[2]||za[1]>Ba[3]||Ba[1]>za[3])&&(li===J?ki=va:li===ie?ki=un:li!==ee&&li!==ce||(ki=un.concat(Ia))),ki}(ft,_t,ir,or,ps))return Rs===va?null:Rs;for(var zr=function(un){var Ia,za,Ba=function(Wa){var Ja,Bn,ya,so,Yr=[];for(Bn=0,ya=Wa.length;Bn0){var Li=ca[Fo];if(Li.holeOf!=null){var Xr=Li.holeOf;ca[Xr].holeIds.push(wi),Pi.holeOf=Xr,Pi.depth=ca[Fo].depth}else ca[Fo].holeIds.push(wi),Pi.holeOf=Fo,Pi.depth=ca[Fo].depth+1}else Pi.holeOf=null,Pi.depth=ca[Fo].depth}else Pi.holeOf=null,Pi.depth=0;return Pi}(Ba[Ia],ki,Wa),Bn=function(Yr){li[Yr]=!0,Yr=Ba.length)&&Ba[ya];);ki.push(Ja)}};for(Ia=0,za=Ba.length;Iaso||ki===ie&&Yr.point[0]>Ba[2])break;if(Yr.left){Wa=bi=Bn.insert(Yr),bi=bi!==(Ja=Bn.minNode())?Bn.prev(bi):null,Wa=Bn.next(Wa);var ca=bi?bi.key:null;if(ue(Yr,ca,ki),Wa&&Ds(Yr,Wa.key,un)===2&&(ue(Yr,ca,ki),ue(Wa.key,Yr,ki)),bi&&Ds(bi.key,Yr,un)===2){var wi=bi;ue(ca,(wi=wi!==Ja?Bn.prev(wi):null)?wi.key:null,ki),ue(Yr,ca,ki)}}else Wa=bi=Bn.find(Yr=Yr.otherEvent),bi&&Wa&&(bi=bi!==Ja?Bn.prev(bi):null,Wa=Bn.next(Wa),Bn.remove(Yr),Wa&&bi&&Ds(bi.key,Wa.key,un))}return ya}(Or,0,0,ir,or,ps)),Sn=[],zn=0;zn * @license MIT * @preserve */function bO(g,c,m,v){const N=[],E=v===0?(P,O,B,W,J,ee)=>{P.push(new es(ee,B+(ee-O)/(W-O)*(J-B)))}:(P,O,B,W,J,ee)=>{P.push(new es(O+(ee-B)/(J-B)*(W-O),ee))};for(const P of g){const O=[];for(const B of P){if(B.length<=2)continue;const W=[];for(let ie=0;iec&&E(W,ce,ue,ke,Le,c):Ie>m?Ke=c&&E(W,ce,ue,ke,Le,c),Ke>m&&Ie<=m&&E(W,ce,ue,ke,Le,m)}let J=B[B.length-1];const ee=v===0?J.x:J.y;ee>=c&&ee<=m&&W.push(J),W.length&&(J=W[W.length-1],W[0].x===J.x&&W[0].y===J.y||W.push(W[0]),O.push(W))}O.length&&N.push(O)}return N}function utt(g,c){const m=Ide(g),v=Ide([c]),N=Cje.intersection(m,v);return N==null?[]:Mje(N)}function htt(g,c){let v=Ide(g,65536);const N=[];for(;c.valid();c.next()){const[E,P]=c.get(),O=E.x*65536,B=E.y*65536,W=P.x*65536,J=P.y*65536,ee=W-O,ie=J-B,ce=Math.hypot(ee,ie);if(ce===0)continue;const ue=Math.trunc(ie/ce*3),ke=-Math.trunc(ee/ce*3);N.push([[[O,B],[W,J],[W+ue,J+ke],[O+ue,B+ke],[O,B]]])}return N.length>0&&(v=Cje.diff(v,N)),Mje(v,1/65536)}function Ide(g,c=1){return[g.map(m=>m.map(v=>[v.x*c,v.y*c]))]}function Mje(g,c=1){return g.map(m=>m.map((v,N)=>{const E=v.map(P=>new es(P[0]*c,P[1]*c).round());return N>0&&E.reverse(),E}))}class Lde{constructor(c,m){this.layoutVertexArray=new vx,this.indexArray=new bl,this.lineIndexArray=new wh,this.triangleSegments=new co,this.lineSegments=new co,this.programConfigurations=new Xm(c.layers,{zoom:c.zoom,lut:c.lut}),this.uploaded=!1,m&&(this.elevatedLayoutVertexArray=new Qf)}update(c,m,v,N,E,P,O,B){this.programConfigurations.updatePaintArrays(c,m,E,v,N,P,O,B)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,Yet.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.lineIndexBuffer=c.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=c.createVertexBuffer(this.elevatedLayoutVertexArray,Xet.members))),this.programConfigurations.upload(c),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy())}populatePaintArrays(c,m,v,N,E,P,O){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,m,v,N,E,P,void 0,O)}}class Dde{constructor(c){this.zoom=c.zoom,this.pixelRatio=c.pixelRatio,this.overscaling=c.overscaling,this.layers=c.layers,this.layerIds=this.layers.map(m=>m.fqid),this.index=c.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=c.lut,this.bufferData=new Lde(c,!1),this.elevationBufferData=new Lde(c,!0),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.projection=c.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=c.sourceLayerIndex,this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,v,N){}populate(c,m,v,N){this.hasPattern=Ede("fill",this.layers,this.pixelRatio,m);const E=this.layers[0].layout.get("fill-sort-key"),P=[];for(const{feature:O,id:B,index:W,sourceLayerIndex:J}of c){const ee=this.layers[0]._featureFilter.needGeometry,ie=Ht(O,ee);if(!this.layers[0]._featureFilter.filter(new Fi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ie,v))continue;const ce=E?E.evaluate(ie,{},v,m.availableImages):void 0,ue={id:B,properties:O.properties,type:O.type,sourceLayerIndex:J,index:W,geometry:ee?ie.geometry:Et(O,v,N),patterns:{},sortKey:ce};P.push(ue)}E&&P.sort((O,B)=>O.sortKey-B.sortKey);for(const O of P){const{geometry:B,index:W,sourceLayerIndex:J}=O;if(this.hasPattern){const ee=Pde("fill",this.layers,O,this.zoom,this.pixelRatio,m);this.patternFeatures.push(ee)}else this.addFeature(O,B,W,v,{},m.availableImages,m.brightness,m.elevationFeatures);m.featureIndex.insert(c[W].feature,B,W,J,this.index)}}update(c,m,v,N,E,P,O){this.bufferData.update(c,m,v,N,E,P,O,this.worldview),this.elevationBufferData.update(c,m,v,N,E,P,O,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(c,m,v,N,E,P,O,this.worldview)}addFeatures(c,m,v,N,E,P){for(const O of this.patternFeatures)this.addFeature(O,O.geometry,O.index,m,v,N,P,c.elevationFeatures)}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(c){this.bufferData.upload(c),this.elevationBufferData.upload(c),this.elevatedStructures&&this.elevatedStructures.upload(c)}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}addFeature(c,m,v,N,E,P=[],O,B){const W=dA(m,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(c,W,N,v,B):this.addGeometry(W,this.bufferData),this.bufferData.populatePaintArrays(c,v,E,P,N,O,this.worldview),this.elevationBufferData.populatePaintArrays(c,v,E,P,N,O,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(c,m,v,N,E){this.elevatedStructures&&(this.elevatedStructures.construct(c),this.elevatedStructures.populatePaintArrays(m,v,N,E,this.worldview))}addElevatedRoadFeature(c,m,v,N,E){const P=new Array,O=Xa.getElevationFeature(c,E);if(!O)return void this.addGeometry(m,this.bufferData);{const W=this.clipPolygonsToTile(m,1);W.length>0&&P.push({polygons:W,elevationFeature:O,elevationTileID:v})}const B={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(c,{},v),featureIndex:N};for(const W of P)if(W.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new Nh(W.elevationTileID,this.layers,this.zoom,this.lut));const ee=W.elevationFeature.isTunnel();let ie=0;c.properties.hasOwnProperty(Jt)&&(ie=+c.properties[Jt]);for(const ce of W.polygons)this.elevatedStructures.addPortalCandidates(W.elevationFeature.id,ce,ee,W.elevationFeature,ie)}W.elevationFeature.constantHeight==null&&(W.polygons=this.prepareElevatedPolygons(W.polygons,W.elevationFeature,W.elevationTileID));const J=new fi(v,W.elevationTileID);this.addElevatedGeometry(W.polygons,J,W.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,N,B)}}addElevatedGeometry(c,m,v,N,E,P){const O={elevation:v,elevationSampler:m,bias:N,index:E,featureInfo:P},[B,W]=this.addGeometry(c,this.elevationBufferData,O);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:B,max:W}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,B),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,W))}addGeometry(c,m,v){let N=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY,P=null;v&&(P=v.elevationSampler.constantElevation(v.elevation,v.bias),P!=null&&(N=P,E=P));const O=(B,W,J)=>{if(v!=null)if(W.push(B),P!=null)m.elevatedLayoutVertexArray.emplaceBack(P),J.push(P);else{const ee=v.elevationSampler.pointElevation(B,v.elevation,v.bias);m.elevatedLayoutVertexArray.emplaceBack(ee),J.push(ee),N=Math.min(N,ee),E=Math.max(E,ee)}};for(const B of c){let W=0;for(const Ye of B)W+=Ye.length;const J=m.triangleSegments.prepareSegment(W,m.layoutVertexArray,m.indexArray),ee=J.vertexLength,ie=[],ce=[],ue=[],ke=[],Le=[],Ie=m.layoutVertexArray.length;for(const Ye of B){if(Ye.length===0)continue;Ye!==B[0]&&ce.push(ie.length/2);const at=m.lineSegments.prepareSegment(Ye.length,m.layoutVertexArray,m.lineIndexArray),vt=at.vertexLength;v&&Le.push(m.layoutVertexArray.length-Ie),O(Ye[0],ue,ke),m.layoutVertexArray.emplaceBack(Ye[0].x,Ye[0].y),m.lineIndexArray.emplaceBack(vt+Ye.length-1,vt),ie.push(Ye[0].x),ie.push(Ye[0].y);for(let pt=1;pt0&&v&&this.elevationMode==="hd-road-base"){const Ye=v.elevation.isTunnel(),at=v.elevation.safeArea,vt=this.elevatedStructures.addVertices(ue,ke);this.elevatedStructures.addTriangles(Ke,vt,Ye);const pt=Le.length;if(pt>0){for(let kt=0;kt=v&&ce.max.x<=E&&ce.min.y>=N&&ce.max.y<=P?B:W).push(ie)}if(B.length===c.length)return c;const J=[new es(v,N),new es(E,N),new es(E,P),new es(v,P),new es(v,N)],ee=B;for(const ie of W)ee.push(...utt(ie,J));return ee}}let Tje,Aje,Eje,Pje;_r(Dde,"FillBucket",{omit:["layers","patternFeatures"]}),_r(Lde,"FillBufferData"),_r(Nh,"ElevatedStructures");class wO{constructor(c,m,v,N){if(this.triangleCount=m.length/3,this.min=new es(0,0),this.max=new es(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||c.length===0)return;const[E,P]=[c[0].clone(),c[0].clone()];for(let ee=1;eeee.cellIdx-ie.cellIdx||ee.triIdx-ie.triIdx);let J=0;for(;Jthis.max.x||this.min.x>c.x||c.y>this.max.y||this.min.y>c.y)return;const v=Nx(c.x-this.min.x,this.xScale,this.cellsX),N=Nx(c.y-this.min.y,this.yScale,this.cellsY),E=this.cells[N*this.cellsX+v];if(E){this._lazyInitLookup();for(let P=0;Pthis.max.x||this.min.x>m.x||c.y>this.max.y||this.min.y>m.y)return;this._lazyInitLookup();const N=Nx(c.x-this.min.x,this.xScale,this.cellsX),E=Nx(m.x-this.min.x,this.xScale,this.cellsX),P=Nx(c.y-this.min.y,this.yScale,this.cellsY),O=Nx(m.y-this.min.y,this.yScale,this.cellsY);for(let B=P;B<=O;B++)for(let W=N;W<=E;W++){const J=this.cells[B*this.cellsX+W];if(J)for(let ee=0;eem.fqid),this.index=c.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.footprints=[],this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){for(const v of this.footprints)m.push({footprint:v,id:c})}updateAppearances(c,m,v,N){}populate(c,m,v,N){const E=[];for(const{feature:P,id:O,index:B,sourceLayerIndex:W}of c){const J=this.layers[0]._featureFilter.needGeometry,ee=Ht(P,J);if(!this.layers[0]._featureFilter.filter(new Fi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ee,v))continue;const ie={id:O,properties:P.properties,type:P.type,sourceLayerIndex:W,index:B,geometry:J?ee.geometry:Et(P,v,N),patterns:{}};E.push(ie)}for(const P of E){const{geometry:O,index:B,sourceLayerIndex:W}=P;this.addFeature(P,O,B,v,{},m.availableImages,m.brightness),m.featureIndex.insert(c[B].feature,O,B,W,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(c){}update(c,m,v,N,E,P,O){}destroy(){}addFeature(c,m,v,N,E,P=[],O){for(const B of dA(m,2)){const W=[],J=[],ee=[],ie=new es(1/0,1/0),ce=new es(-1/0,-1/0);for(const Le of B)if(Le.length!==0){Le!==B[0]&&ee.push(J.length/2);for(let Ie=0;IeP===N)===void 0}(v,g.clipScope)}function jO(g,c){return g.x-c.x||g.y-c.y}function Oje(g,c){return jO(g.min,c.min)===0&&jO(g.max,c.max)===0}function Ode(g,c){return!(g.min.x>c.max.x||g.max.xc.max.y||g.max.ynew es((B.x+E.x*Xs)*O-P.x*Xs,(B.y+E.y*Xs)*O-P.y*Xs))}return Rde(m,N,g.indices,0,g.indices.length,0,0)}function zje(g,c,m,v){const N=Math.pow(2,v.z-m.z);return new es((g+m.x*Xs)*N-v.x*Xs,(c+m.y*Xs)*N-v.y*Xs)}function Bje(g,c){const m=[];c.grid.queryPoint(g,m);const v=c.indices,N=c.vertices;for(let E=0;E0&&(v.length>1&&m.push(v),v=[])}return v.length>1&&m.push(v),m}const zde=Ut.types,wtt=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],jtt=["fill-extrusion-flood-light-ground-radius"],Ntt=Math.pow(2,13),ktt=Math.pow(2,15)-1,qje=new es(0,1),Gy=2147483648,Uje=7,Vje=450;function hA(g,c,m,v,N,E,P,O){g.emplaceBack((c<<1)+P,(m<<1)+E,(Math.floor(v*Ntt)<<1)+N,Math.round(O))}function mA(g,c,m){g.emplaceBack(c.x*Xs,c.y*Xs,m?1:0)}function kO(g,c,m,v,N,E){g.emplaceBack(c.x,c.y,(m.x<<1)+v,(m.y<<1)+N,E)}function pA(g,c,m){g.emplaceBack(c.x,c.y,c.z,m[0]*16384,m[1]*16384,m[2]*16384)}class Hje{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class Wje{constructor(){this.centroidXY=new es(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new es(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new es(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new es(this.max.x-this.min.x,this.max.y-this.min.y)}}class Gje{constructor(){this.acc=new es(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(c,m){c.min.x===Number.MAX_VALUE&&(c.min.x=c.max.x=m.x,c.min.y=c.max.y=m.y)}appendEdge(c,m,v){this.accCount++,this.acc._add(m);let N=!!this.borders;m.xc.max.x&&(c.max.x=m.x,N=!0),m.yc.max.y&&(c.max.y=m.y,N=!0),((m.x===0||m.x===Xs)&&m.x===v.x)!=((m.y===0||m.y===Xs)&&m.y===v.y)&&this.processBorderOverlap(m,v),N&&this.checkBorderIntersection(m,v)}checkBorderIntersection(c,m){m.x<0!=c.x<0&&this.addBorderIntersection(0,Hr(m.y,c.y,(0-m.x)/(c.x-m.x))),m.x>Xs!=c.x>Xs&&this.addBorderIntersection(1,Hr(m.y,c.y,(Xs-m.x)/(c.x-m.x))),m.y<0!=c.y<0&&this.addBorderIntersection(2,Hr(m.x,c.x,(0-m.y)/(c.y-m.y))),m.y>Xs!=c.y>Xs&&this.addBorderIntersection(3,Hr(m.x,c.x,(Xs-m.y)/(c.y-m.y)))}addBorderIntersection(c,m){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const v=this.borders[c];mv[1]&&(v[1]=m)}processBorderOverlap(c,m){if(c.x===m.x){if(c.y===m.y)return;const v=c.x===0?0:1;this.addBorderIntersection(v,m.y),this.addBorderIntersection(v,c.y)}else{const v=c.y===0?2:3;this.addBorderIntersection(v,m.x),this.addBorderIntersection(v,c.x)}}centroid(){return this.accCount===0?new es(0,0):new es(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((c,m)=>c+ +(m[0]!==Number.MAX_VALUE),0):0}}function Kje(g,c){const m=g.add(c)._unit(),v=ye(g.x*m.x+g.y*m.y,-1,1);var N,E,P;return N=Math.acos(v),Math.min(4,Math.max(-4,Math.tan(N)))/4*ktt*((E=g).x*(P=c).y-E.y*P.x<0?-1:1)}const Stt=[g=>g.x<0,g=>g.x>Xs,g=>g.y<0,g=>g.y>Xs];function Ctt(g,c,m,v){const N=[4];if(v===0)return N;m._mult(v);const E=g.sub(m),P=c.sub(m),O=[g,c,E,P];for(let B=0;B<4;B++)for(const W of O)if(Stt[B](W)){N.push(B);break}return N}class Bde{constructor(c){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new BT,this.indexArray=new bl,this.programConfigurations=new Xm(c.layers,{zoom:c.zoom,lut:c.lut},m=>jtt.includes(m)),this._segments=new co,this.hiddenByLandmarkVertexArray=new yC,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new co}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(c,m,v,N=!1){const E=c.length;if(E>2){let P=Math.max(0,this._segments.get().length-1);const O=this._segments._prepareSegment(4*E,this.vertexArray.length,2*this._segmentToGroundQuads[P].length);let B;P!==this._segments.get().length-1&&(P++,this._segmentToGroundQuads[P]=[],this._segmentToRegionTriCounts[P]=[0,0,0,0,0]);{const W=c[0],J=c[1];B=Kje(W.sub(c[E-1])._perp()._unit(),J.sub(W)._perp()._unit())}for(let W=0;WN.region-E.region);for(let v=0;vB+W,0);let O=0;for(let B=0;B<=4;B++){const W=P[B];if(W!==0){let J=this.regionSegments[B];J||(J=this.regionSegments[B]=new co);const ee={vertexOffset:E.vertexOffset,primitiveOffset:E.primitiveOffset+O,vertexLength:E.vertexLength,primitiveLength:W};J.get().push(ee)}O+=W}for(let B=0;B0?this.hiddenByLandmarkVertexBuffer=c.createVertexBuffer(this.hiddenByLandmarkVertexArray,ytt.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this.groundRadiusBuffer&&this.groundRadiusBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let c=0;c<=4;c++){const m=this.regionSegments[c];m&&m.destroy()}}}}class SO{constructor(c){this.zoom=c.zoom,this.canonical=c.canonical,this.overscaling=c.overscaling,this.layers=c.layers,this.pixelRatio=c.pixelRatio,this.layerIds=this.layers.map(m=>m.fqid),this.index=c.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=c.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new bl,this.footprintVertices=new vx,this.footprintSegments=[],this.layoutVertexArray=new Rv,this.centroidVertexArray=new mO,this.wallVertexArray=new Lb,this.indexArray=new bl,this.programConfigurations=new Xm(c.layers,{zoom:c.zoom,lut:c.lut},m=>wtt.includes(m)),this.segments=new co,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.groundEffect=new Bde(c),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,v,N){}populate(c,m,v,N){this.features=[],this.hasPattern=Ede("fill-extrusion",this.layers,this.pixelRatio,m),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=Be(v),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1)!==0;for(const{feature:E,id:P,index:O,sourceLayerIndex:B}of c){const W=this.layers[0]._featureFilter.needGeometry,J=Ht(E,W);if(!this.layers[0]._featureFilter.filter(new Fi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),J,v))continue;const ee={id:P,sourceLayerIndex:B,index:O,geometry:W?J.geometry:Et(E,v,N),properties:E.properties,type:E.type,patterns:{}},ie=this.layoutVertexArray.length,ce=zde[ee.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:E.id,feature:Pde("fill-extrusion",this.layers,ee,this.zoom,this.pixelRatio,m)});else if(this.wallMode)for(const ue of ee.geometry)for(const ke of $je(ue,ce))this.addFeature(E.id,ee,[ke],O,v,{},m.availableImages,N,m.brightness);else this.addFeature(E.id,ee,ee.geometry,O,v,{},m.availableImages,N,m.brightness);m.featureIndex.insert(E,ee.geometry,O,B,this.index,ie)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(c,m,v,N,E,P){for(const{featureId:O,feature:B}of this.features){const W=zde[B.type]==="Polygon",{geometry:J}=B;if(this.wallMode)for(const ee of J)for(const ie of $je(ee,W))this.addFeature(O,B,[ie],B.index,m,v,N,E,P);else this.addFeature(O,B,J,B.index,m,v,N,E,P)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(c,m,v,N,E,P,O){this.programConfigurations.updatePaintArrays(c,m,E,v,N,P,O,this.worldview),this.groundEffect.update(c,m,E,v,N,P,O,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,_tt),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.wallVertexBuffer=c.createVertexBuffer(this.wallVertexArray,xtt.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=c.createVertexBuffer(this.layoutVertexExtArray,vtt.members,!0)),this.groundEffect.upload(c)),this.groundEffect.uploadPaintProperties(c),this.programConfigurations.upload(c),this.uploaded=!0}uploadCentroid(c){this.groundEffect.uploadHiddenByLandmark(c),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=c.createVertexBuffer(this.centroidVertexArray,gtt.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(c,m,v,N,E,P,O,B,W){const J=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(m,{})/this.tileToMeter,ee=[new es(0,0),new es(Xs,Xs)],ie=B.projection,ce=ie.name==="globe",ue=this.wallMode||zde[m.type]==="Polygon",ke=new Gje;ke.centroidDataIndex=this.centroidData.length;const Le=new Wje;Le.buildingId=c,m.properties&&m.properties.hasOwnProperty("building_id")&&(Le.buildingId=m.properties.building_id);const Ie=this.layers[0].paint.get("fill-extrusion-base").evaluate(m,{},E)<=0,Ke=this.layers[0].paint.get("fill-extrusion-height").evaluate(m,{},E);let Ye;if(Le.height=Ke,Le.vertexArrayOffset=this.layoutVertexArray.length,Le.groundVertexArrayOffset=this.groundEffect.vertexArray.length,ce&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new hC),this.wallMode){if(ce)return void ur("Non zero fill-extrusion-line-width is not yet supported on globe.");if(v.length!==1)return;Ye=function(Wt){const ms=Wt[0].x===Wt[Wt.length-1].x&&Wt[0].y===Wt[Wt.length-1].y;(function(yr){let kr=0;const Hn=yr.length;for(let Ws=0;Ws=0})(Wt)||(Wt=Wt.reverse());const ws={geometry:[],joinNormals:[],indices:[]},Os=[],Fs=[],Ps=[];let Ls=Wt.length;for(;Ls>=2&&Wt[Ls-1].equals(Wt[Ls-2]);)Ls--;if(Ls<(ms?3:2))return ws;let hs,cs,Ds,Qs,Vs,Dr=0;for(;Dr0;let mn="miter";const fa=2;mn==="miter"&&Ws>fa&&(mn="bevel"),mn==="bevel"&&(Ws>100&&(mn="flipbevel"),Ws{const ps=new es(Ln.x,Ln.y),Rs=new es(Ln.x,Ln.y);ps.x+=_i.x*_t,ps.y+=_i.y*_t,Rs.x-=_i.x*Math.max(ft,1),Rs.y-=_i.y*Math.max(ft,1),Ps.push(_i),Os.push(ps),Fs.push(Rs)};if(mn==="miter")kr._mult(Ws),va(hs,kr,0,0);else if(mn==="flipbevel")kr=Vs.mult(-1),va(hs,kr,0,0),va(hs,kr.mult(-1),0,0);else{const Ln=-Math.sqrt(Ws*Ws-1),_i=Sr?Ln:0,ft=Sr?0:Ln;cs&&va(hs,Qs,_i,ft),Ds&&va(hs,Vs,_i,ft)}}ws.geometry=[...Os,...Fs.reverse(),Os[0]],ws.joinNormals=[...Ps,...Ps.reverse(),Ps[Ps.length-1]];const dr=ws.geometry.length-1;for(let yr=0;yrWt<(ms.length-1)/2||Wt===ms.length-1,vt=this.wallMode?[v]:dA(v,500);for(let Wt=vt.length-1;Wt>=0;Wt--){const ms=vt[Wt];(ms.length===0||(pt=ms[0]).every(bs=>bs.x<=0)||pt.every(bs=>bs.x>=Xs)||pt.every(bs=>bs.y<=0)||pt.every(bs=>bs.y>=Xs))&&vt.splice(Wt,1)}var pt;let kt;if(ce)kt=tNe(vt,ee,E);else{kt=[];for(const Wt of vt)kt.push({polygon:Wt,bounds:ee})}const Lt=ue?this.edgeRadius:0,$t=Lt>0&&this.zoom<17,ls=(Wt,ms)=>{if(Wt.length===0)return!1;const bs=Wt[Wt.length-1];return ms.x===bs.x&&ms.y===bs.y};for(const{polygon:Wt,bounds:ms}of kt){let bs=0,ws=0;for(const Ls of Wt)ue&&!Ls[0].equals(Ls[Ls.length-1])&&Ls.push(Ls[0]),ws+=ue?Ls.length-1:Ls.length;const Os=this.segments.prepareSegment((ue?5:4)*ws,this.layoutVertexArray,this.indexArray);Le.footprintSegIdx<0&&(Le.footprintSegIdx=this.footprintSegments.length),Le.polygonSegIdx<0&&(Le.polygonSegIdx=this.polygonSegments.length);const Fs={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},Ps=new Hje;if(Ps.vertexOffset=this.footprintVertices.length,Ps.indexOffset=3*this.footprintIndices.length,Ps.ringIndices=[],ue){const Ls=[],hs=[];bs=Os.vertexLength;for(let Ds=0;Ds4&&Qje(hs[hs.length-2],hs[0],hs[1]),Ds=Lt?Mtt(hs[hs.length-2],hs[0],hs[1],Lt):0;const Qs=[];let Vs,Dr,dr;Dr=hs[1].sub(hs[0])._perp()._unit();let yr=!0;for(let kr=1,Hn=0;kr0?1:0,_i=Ws.dist(Sr);if(Hn+_i>32768&&(Hn=0),Lt){dr=mn.sub(Sr)._perp()._unit();let Rs=Yje(Ws,Sr,mn,Zje(Dr,dr),Lt);isNaN(Rs)&&(Rs=0);const ir=Sr.sub(Ws)._unit();Ws=Ws.add(ir.mult(Ds))._round(),Sr=Sr.add(ir.mult(-Rs))._round(),Ds=Rs,Dr=dr,Ie&&this.zoom>=17&&(ls(Qs,Ws)||Qs.push(Ws),ls(Qs,Sr)||Qs.push(Sr))}const ft=Os.vertexLength,_t=hs.length>4&&Qje(Ws,Sr,mn);let ps=Jje(Hn,cs,yr);if(hA(this.layoutVertexArray,Ws.x,Ws.y,va,Ln,0,0,ps),hA(this.layoutVertexArray,Ws.x,Ws.y,va,Ln,0,1,ps),this.wallMode){const Rs=at(kr-1,hs),ir=Ye.joinNormals[kr-1];mA(this.wallVertexArray,ir,Rs),mA(this.wallVertexArray,ir,Rs)}if(Hn+=_i,ps=Jje(Hn,_t,!yr),cs=_t,hA(this.layoutVertexArray,Sr.x,Sr.y,va,Ln,0,0,ps),hA(this.layoutVertexArray,Sr.x,Sr.y,va,Ln,0,1,ps),this.wallMode){const Rs=at(kr,hs),ir=Ye.joinNormals[kr];mA(this.wallVertexArray,ir,Rs),mA(this.wallVertexArray,ir,Rs)}if(Os.vertexLength+=4,this.indexArray.emplaceBack(ft+0,ft+1,ft+2),this.indexArray.emplaceBack(ft+1,ft+3,ft+2),Os.primitiveLength+=2,Lt){const Rs=bs+(kr===1?hs.length-2:kr-2),ir=kr===1?bs:Rs+1;if(this.indexArray.emplaceBack(ft+1,Rs,ft+3),this.indexArray.emplaceBack(Rs,ir,ft+3),Os.primitiveLength+=2,Vs===void 0&&(Vs=ft),!$de(mn,hs[kr],ms)){const or=kr===hs.length-1?Vs:Os.vertexLength;this.indexArray.emplaceBack(ft+2,ft+3,or),this.indexArray.emplaceBack(ft+3,or+1,or),this.indexArray.emplaceBack(ft+3,ir,or+1),Os.primitiveLength+=3}yr=!yr}if(ce){const Rs=this.layoutVertexExtArray,ir=ie.projectTilePoint(Ws.x,Ws.y,E),or=ie.projectTilePoint(Sr.x,Sr.y,E),Or=ie.upVector(E,Ws.x,Ws.y),zr=ie.upVector(E,Sr.x,Sr.y);pA(Rs,ir,Or),pA(Rs,ir,Or),pA(Rs,or,zr),pA(Rs,or,zr)}}ue&&(bs+=hs.length-1),Ie&&Lt&&this.zoom>=17&&(Qs.length!==0&&ls(Qs,Qs[0])&&Qs.pop(),this.groundEffect.addData(Qs,ms,J,Lt>0))}this.footprintSegments.push(Ps),Fs.triangleCount=this.indexArray.length-Fs.triangleArrayOffset,this.polygonSegments.push(Fs),++Le.footprintSegLen,++Le.polygonSegLen}if(Le.vertexCount=this.layoutVertexArray.length-Le.vertexArrayOffset,Le.groundVertexCount=this.groundEffect.vertexArray.length-Le.groundVertexArrayOffset,Le.vertexCount!==0){if(Le.centroidXY=ke.borders?qje:this.encodeCentroid(ke,Le),this.centroidData.push(Le),ke.borders){this.featuresOnBorder.push(ke);const Wt=this.featuresOnBorder.length-1;for(let ms=0;msthis.featuresOnBorder[m].borders[c][0]-this.featuresOnBorder[v].borders[c][0])}splitToSubtiles(){const c=[];for(let O=0;OXs),J=2*W+(+(B.min.x+B.max.x>Xs)^W);for(let ee=0;eeO.triangleSegmentIdx===B.triangleSegmentIdx?O.subtile-B.subtile:O.triangleSegmentIdx-B.triangleSegmentIdx);let v=0,N=0,E=0;for(const O of c){if(O.triangleSegmentIdx!==v)break;E++}const P=c.length;for(;N!==c.length;){v=c[N].triangleSegmentIdx;let O=0,B=N,W=N;for(let J=B;J0&&this.triangleSubSegments.push({segment:ce,min:ee,max:ie}),B=W;for(let ue=B;ue[ke[0]*(1-Ie[0])+Le[0]*Ie[0],ke[1]*(1-Ie[1])+Le[1]*Ie[1]],ce=[],ue=[];for(const ke of this.triangleSubSegments){ce[0]=ke.min.x/Xs,ce[1]=ke.min.y/Xs,ue[0]=ke.max.x/Xs,ue[1]=ke.max.y/Xs;const Le=ie(J,ee,ce),Ie=ie(J,ee,ue);if(new Er([Le[0],Le[1],E],[Ie[0],Ie[1],P]).intersectsPrecise(v)===0){W&&(N.segments.push(W),W=void 0);continue}const Ke=ke.segment;W&&W.vertexOffset!==Ke.vertexOffset&&(N.segments.push(W),W=void 0),W?(W.vertexLength+=Ke.vertexLength,W.primitiveLength+=Ke.primitiveLength):W={vertexOffset:Ke.vertexOffset,primitiveLength:Ke.primitiveLength,vertexLength:Ke.vertexLength,primitiveOffset:Ke.primitiveOffset,sortKey:void 0,vaos:{}}}return W&&N.segments.push(W),N}encodeCentroid(c,m){const v=c.centroid(),N=m.span(),E=Math.min(7,Math.round(N.x*this.tileToMeter/10)),P=Math.min(7,Math.round(N.y*this.tileToMeter/10));return new es(ye(v.x,1,Xs-1)<<3|E,ye(v.y,1,Xs-1)<<3|P)}encodeBorderCentroid(c){if(!c.borders)return new es(0,0);const m=c.borders,v=Number.MAX_VALUE;if(m[0][0]!==v||m[1][0]!==v){const N=m[0][0]!==v?0:1;return new es(6|(m[0][0]!==v?0:65528),(m[N][0]+m[N][1])/2<<3|6)}{const N=m[2][0]!==v?2:3;return new es((m[N][0]+m[N][1])/2<<3|6,6|(m[2][0]!==v?0:65528))}}showCentroid(c){const m=this.centroidData[c.centroidDataIndex];m.flags&=2147483647,m.centroidXY.x=0,m.centroidXY.y=0,this.writeCentroidToBuffer(m)}writeCentroidToBuffer(c){this.groundEffect.updateHiddenByLandmark(c);const m=c.vertexArrayOffset,v=c.vertexCount+c.vertexArrayOffset,N=c.flags&Gy?qje:c.centroidXY,E=this.centroidVertexArray.geta_centroid_pos0(m);if(this.centroidVertexArray.geta_centroid_pos1(m)!==N.y||E!==N.x){for(let P=m;PB.max.x||B.min.x>P.max.x||P.min.y>B.max.y||B.min.y>P.max.y||P.footprint.buildingIds.has(B.buildingId)&&(B.flags|=Gy);else for(const B of this.centroidData)if(!(B.flags&Gy||P.min.x>B.max.x||B.min.x>P.max.x||P.min.y>B.max.y||B.min.y>P.max.y))for(let W=0;Wm!=ce>m&&c<(this.footprintVertices.int16[2*(J+P.vertexOffset)+0]-ee)*(m-ie)/(ce-ie)+ee&&(N=!N)}O=B}}return N}getHeightAtTileCoord(c,m){let v=Number.NEGATIVE_INFINITY,N=!0;const E=4*(c+Xs)*Xs+(m+Xs);if(this.partLookup.hasOwnProperty(E)){const P=this.partLookup[E];return P?{height:P.height,hidden:!!(P.flags&Gy)}:void 0}for(const P of this.centroidData)c>P.max.x||P.min.x>c||m>P.max.y||P.min.y>m||P.height<=v||this.footprintContainsPoint(c,m,P)&&(v=P.height,this.partLookup[E]=P,N=!!(P.flags&Gy));if(v!==Number.NEGATIVE_INFINITY)return{height:v,hidden:N};this.partLookup[E]=void 0}}function Zje(g,c){const m=g.add(c)._unit();return g.x*m.x+g.y*m.y}function Mtt(g,c,m,v){const N=c.sub(g)._perp()._unit(),E=m.sub(c)._perp()._unit();return Yje(g,c,m,Zje(N,E),v)}function Yje(g,c,m,v,N){const E=Math.sqrt(1-v*v);return Math.min(g.dist(c)/3,c.dist(m)/3,N*E/v)}function $de(g,c,m){return g.xm[1].x&&c.x>m[1].x||g.ym[1].y&&c.y>m[1].y}function Xje(g,c){return g.xc[1].x||g.yc[1].y}function Qje(g,c,m){if(g.x<0||g.x>=Xs||c.x<0||c.x>=Xs||m.x<0||m.x>=Xs)return!1;const v=m.sub(c),N=v.perp(),E=g.sub(c);return(v.x*E.x+v.y*E.y)/Math.sqrt((v.x*v.x+v.y*v.y)*(E.x*E.x+E.y*E.y))>-.866&&N.x*E.x+N.y*E.y<0}function Jje(g,c,m){const v=c?2|g:-3&g;return m?1|v:-2&v}function eNe(){const g=Math.PI/32,c=Math.tan(g),m=M;return m*Math.sqrt(1+2*c*c)-m}function tNe(g,c,m){const v=1<{for(const Lt of pt)ue.push({polygon:Lt,bounds:kt})},Le=Math.ceil(Math.log2(J)),Ie=Math.ceil(Math.log2(ee)),Ke=Le-Ie,Ye=[];for(let pt=0;pt0?0:1);for(let pt=0;ptkt+1?vt.push({polygons:ws,bounds:Fs,depth:kt+1}):ke(ws,Fs)}if(Os.length){const Fs=[new es(Lt===0?bs:$t.x,Lt===1?bs:$t.y),ls];Ye.length>kt+1?vt.push({polygons:Os,bounds:Fs,depth:kt+1}):ke(Os,Fs)}}return ue}(g,c,Math.ceil((E-N)/11.25),Math.ceil((P-O)/11.25),1,(B,W,J)=>{if(B===0)return .5*(W+J);{const ee=ge((m.y+W/Xs)/v);return(X(.5*(ge((m.y+J/Xs)/v)+ee))*v-m.y)*Xs}})}function Ttt(g,c,m,v,N,E){const P=Math.pow(2,v.z-N.z);for(let O=0;O=B[P]&&(O=c,B=g),O[P]N&&aNe(O,B,P,N),O[P]E&&aNe(B,O,P,E)}}function CO(g,c,m,v,N,E){const P=[];for(let O=0;O=v&&ue.x>=v||(ce.x>=v?ce=new es(v,ce.y+(v-ce.x)/(ue.x-ce.x)*(ue.y-ce.y))._round():ue.x>=v&&(ue=new es(v,ce.y+(v-ce.x)/(ue.x-ce.x)*(ue.y-ce.y))._round()),ce.y>=N&&ue.y>=N||(ce.y>=N?ce=new es(ce.x+(N-ce.y)/(ue.y-ce.y)*(ue.x-ce.x),N)._round():ue.y>=N&&(ue=new es(ce.x+(N-ce.y)/(ue.y-ce.y)*(ue.x-ce.x),N)._round()),W&&ce.equals(W[W.length-1])||(W=[ce],P.push(W),E&&E.push({progress:{min:Le+oNe(Ie,Ke,ce)*ke,max:1},parentIndex:O,prevPoint:Ie,nextPoint:Ke})),W.push(ue),E&&(E[E.length-1].progress.max=Le+oNe(Ie,Ke,ue)*ke,E[E.length-1].nextPoint=Ke)))))}if(E&&ee>0)for(let ie=J;ieW.t-J.t);let P=0,O=0,B=[];for(v.push(B);P!==g.length;){if(O===E.length){for(;P!==g.length;)B.length!==0&&B[B.length-1].equals(g[P])||B.push(g[P]),P++;break}E[O].t<=P?(B.length!==0&&B[B.length-1].equals(E[O].point)||B.push(E[O].point),Math.trunc(E[O].t),O++):(B.length!==0&&B[B.length-1].equals(g[P])||B.push(g[P]),P++)}}function oNe(g,c,m){return g.x!==c.x?(m.x-g.x)/(c.x-g.x):g.y!==c.y?(m.y-g.y)/(c.y-g.y):0}function fA(g,c){return g.x*c.x+g.y*c.y}function lNe(g,c){if(g.length===1){let m=0;const v=c[m++];let N;for(;!N||v.equals(N);)if(N=c[m++],!N)return 1/0;for(;m{bs[0]=ws,bs[1]=Os,bs[2]=Fs,bs[3]=1},ms=eNe();ce>0&&(ce+=ms),ue+=ms;for(const bs of ie){const ws=[],Os=[];for(const Fs of bs){const Ps=Fs.x+ke.x,Ls=Fs.y+ke.y,hs=ee.projection.projectTilePoint(Ps,Ls,vt),cs=ee.projection.upVector(vt,Fs.x,Fs.y);let Ds=ce,Qs=ue;if(Ie){const Vs=uNe(Ps,Ls,ce,ue,Ie,Ke,Ye,at);Ds+=Vs.base,Qs+=Vs.top}ce!==0?Wt($t,hs.x+cs[0]*Lt*Ds,hs.y+cs[1]*Lt*Ds,hs.z+cs[2]*Lt*Ds):Wt($t,hs.x,hs.y,hs.z),Wt(ls,hs.x+cs[0]*Lt*Qs,hs.y+cs[1]*Lt*Qs,hs.z+cs[2]*Lt*Qs),Rt($t,$t,Le),Rt(ls,ls,Le),ws.push(new Vb($t[0],$t[1],$t[2])),Os.push(new Vb(ls[0],ls[1],ls[2]))}pt.push(ws),kt.push(Os)}return[pt,kt]}(g,c,m,v,N,E,P,O,B,W,J):P?function(ee,ie,ce,ue,ke,Le,Ie,Ke,Ye){const at=[],vt=[],pt=[0,0,0,1];for(const kt of ee){const Lt=[],$t=[];for(const ls of kt){const Wt=ls.x+ue.x,ms=ls.y+ue.y,bs=uNe(Wt,ms,ie,ce,Le,Ie,Ke,Ye);pt[0]=Wt,pt[1]=ms,pt[2]=bs.base,pt[3]=1,Qe(pt,pt,ke),pt[3]=Math.max(pt[3],1e-5);const ws=new Vb(pt[0]/pt[3],pt[1]/pt[3],pt[2]/pt[3]);pt[0]=Wt,pt[1]=ms,pt[2]=bs.top,pt[3]=1,Qe(pt,pt,ke),pt[3]=Math.max(pt[3],1e-5);const Os=new Vb(pt[0]/pt[3],pt[1]/pt[3],pt[2]/pt[3]);Lt.push(ws),$t.push(Os)}at.push(Lt),vt.push($t)}return[at,vt]}(c,m,v,N,E,P,O,B,W):function(ee,ie,ce,ue,ke){const Le=[],Ie=[],Ke=ke[8]*ie,Ye=ke[9]*ie,at=ke[10]*ie,vt=ke[11]*ie,pt=ke[8]*ce,kt=ke[9]*ce,Lt=ke[10]*ce,$t=ke[11]*ce;for(const ls of ee){const Wt=[],ms=[];for(const bs of ls){const ws=bs.x+ue.x,Os=bs.y+ue.y,Fs=ke[0]*ws+ke[4]*Os+ke[12],Ps=ke[1]*ws+ke[5]*Os+ke[13],Ls=ke[2]*ws+ke[6]*Os+ke[14],hs=ke[3]*ws+ke[7]*Os+ke[15],cs=Fs+Ke,Ds=Ps+Ye,Qs=Ls+at,Vs=Math.max(hs+vt,1e-5),Dr=Fs+pt,dr=Ps+kt,yr=Ls+Lt,kr=Math.max(hs+$t,1e-5);Wt.push(new Vb(cs/Vs,Ds/Vs,Qs/Vs)),ms.push(new Vb(Dr/kr,dr/kr,yr/kr))}Le.push(Wt),Ie.push(ms)}return[Le,Ie]}(c,m,v,N,E)}function uNe(g,c,m,v,N,E,P,O){const B=P*N.getElevationAt(g,c,!0,!0),W=E[0]!==0,J=W?E[1]===0?P*(E[0]/Uje-Vje):P*function(ee,ie,ce){const ue=Math.floor(ie[0]/8),ke=Math.floor(ie[1]/8),Le=10*(ie[0]-8*ue),Ie=10*(ie[1]-8*ke),Ke=ee.getElevationAt(ue,ke,!0,!0),Ye=ee.getMeterToDEM(ce),at=Math.floor(.5*(Le*Ye-1)),vt=Math.floor(.5*(Ie*Ye-1)),pt=ee.tileCoordToPixel(ue,ke),kt=2*at+1,Lt=2*vt+1,$t=function(Os,Fs,Ps,Ls,hs){return[Os.getElevationAtPixel(Fs,Ps,!0),Os.getElevationAtPixel(Fs+hs,Ps,!0),Os.getElevationAtPixel(Fs,Ps+hs,!0),Os.getElevationAtPixel(Fs+Ls,Ps+hs,!0)]}(ee,pt.x-at,pt.y-vt,kt,Lt),ls=Math.abs($t[0]-$t[1]),Wt=Math.abs($t[2]-$t[3]),ms=Math.abs($t[0]-$t[2])+Math.abs($t[1]-$t[3]),bs=Math.min(.25,.5*Ye*(ls+Wt)/kt),ws=Math.min(.25,.5*Ye*ms/Lt);return Ke+Math.max(bs*Le,ws*Ie)}(N,E,O):B;return{base:B+(m===0?-1:m),top:W?Math.max(J+v,B+m+2):B+v}}class Ett{constructor(c){this._callback=c,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}class Ptt{constructor(){this.tasks={},this.taskQueue=[],qt(["process"],this),this.invoker=new Ett(this.process),this.nextId=0}add(c,m){const v=this.nextId++,N=function({type:E,isSymbolTile:P,zoom:O}){return O=O||0,E==="message"?0:E!=="maybePrepare"||P?E!=="parseTile"||P?E==="parseTile"&&P?300-O:E==="maybePrepare"&&P?400-O:500:200-O:100-O}(m);if(N===0){try{c()}finally{}return null}return this.tasks[v]={fn:c,metadata:m,priority:N,id:v},this.taskQueue.push(v),this.invoker.trigger(),{cancel:()=>{delete this.tasks[v]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(v=>!!this.tasks[v]),!this.taskQueue.length)return;const c=this.pick();if(c===null)return;const m=this.tasks[c];if(delete this.tasks[c],this.taskQueue.length&&this.invoker.trigger(),!m)return;m.fn()}finally{}}pick(){let c=null,m=1/0;for(let N=0;N{v&&delete this.callbacks[O],this.target.postMessage({id:O,type:"",targetMapId:N,sourceMapId:this.mapId})}}}receive(c){const m=c.data;if(!m)return;const v=m.id;if(v&&(!m.targetMapId||this.mapId===m.targetMapId))if(m.type===""){const N=this.cancelCallbacks[v];delete this.cancelCallbacks[v],N&&N.cancel()}else if(m.mustQueue||ma(self)){const N=this.callbacks[v],E=this.scheduler.add(()=>this.processTask(v,m),N&&N.metadata||{type:"message"});E&&(this.cancelCallbacks[v]=E)}else this.processTask(v,m)}processTask(c,m){if(delete this.cancelCallbacks[c],m.type===""){const v=this.callbacks[c];delete this.callbacks[c],v&&(m.error?v(yx(m.error)):v(null,yx(m.data)))}else{const v=new Set,N=m.hasCallback?(P,O)=>{this.target.postMessage({id:c,type:"",sourceMapId:this.mapId,error:P?Kf(P):null,data:Kf(O,v)},v)}:()=>{},E=yx(m.data);if(this.parent[m.type])this.parent[m.type](m.sourceMapId,E,N);else if(this.parent.getWorkerSource){const P=m.type.split("."),{source:O,scope:B}=E;this.parent.getWorkerSource(m.sourceMapId,P[0],O,B)[P[1]](E,N)}else N(new Error(`Could not find function ${m.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var gA={workerUrl:"",workerClass:null,workerParams:void 0};const qde="mapboxgl_preloaded_worker_pool";class Hb{constructor(c){this.active={},this.name=c}acquire(c,m=Hb.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{m.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[qde]}numActive(){return Object.keys(this.active).length}}Hb.workerCount=2;class PC{constructor(c,m,v="Worker",N=Hb.workerCount){this.workerPool=c,this.actors=[],this.currentActor=0,this.id=Bt();const E=this.workerPool.acquire(this.id,N);for(let P=0;P{this.ready=!0})}broadcast(c,m,v){St(this.actors,(N,E)=>{N.send(c,m,E)},v=v||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(c=>{c.remove()}),this.actors=[],this.workerPool.release(this.id)}}let xA,Ude;function MO(){return xA||(xA=new Hb),xA}PC.Actor=hNe;const Vde=4096;class Itt{constructor(c){this.module=c,this.memoryStack=this.module.malloc(Vde),this.memoryStackNextFree=this.memoryStack}createIntArray(c){const m=this.memoryStackNextFree;return this.memoryStackNextFree+=c.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Vde?-1:(new Int32Array(this.module.heap32.buffer,m,c.length).set(c),m)}createFloatArray(c){const m=this.memoryStackNextFree;return this.memoryStackNextFree+=c.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Vde?-1:(new Float32Array(this.module.heapF32.buffer,m,c.length).set(c),m)}readStringBuffer(c){let m="";for(;this.module.heapU8[c]!==0;)m+=String.fromCharCode(this.module.heapU8[c]),++c;return m}setStyle(c){const m=c.normalScale;this.module.setStyle(m[0],m[1],m[2],c.tileToMeters)}setAOOptions(c,m){this.module.setAOOptions(c?1:0,m)}setMetricOptions(c,m){this.module.setMetricOptions(c?1:0,m)}setStructuralOptions(c){this.module.setStructuralOptions(c?1:0)}setFacadeOptions(c,m){this.module.setFacadeOptions(c,m?1:0)}setFauxFacadeOptions(c,m,v){this.module.setFauxFacadeOptions(c?1:0,m?1:0,v)}setFacadeClassifierOptions(c){this.module.setFacadeClassifierOptions(c)}generateMesh(c,m){this.memoryStackNextFree=this.memoryStack;for(const O of c){const B=this.createIntArray(O.ringIndices),W=this.createFloatArray(O.coordinates);if(B===-1||W===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(O.id,O.sourceId,O.minHeight,O.height,O.roofType,W,B,O.ringIndices.length-1)}for(const O of m){let B;B=O.entrances?JSON.parse(O.entrances):[];const W=this.createFloatArray(B),J=this.createFloatArray(O.coordinates);if(W===-1||J===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(O.sourceId,O.crossPerc,O.distanceToRoad,W,B.length,J,O.coordinates.length)}if(!this.module.generateMesh()){const O=this.module.getLastError();return this.readStringBuffer(O)}const v=this.module.getMeshCount(),N=new Array(v);for(let O=0;ON.arrayBuffer()).then(N=>{c.buffers[m]=N})}function _Ne(g,c){const m=g.json.bufferViews[c];return new Uint8Array(g.buffers[m.buffer],m.byteOffset||0,m.byteLength)}function ztt(g,c,m,v){if(g.uri){const N=vNe(g.uri,v);return fetch(N).then(E=>E.blob()).then(E=>createImageBitmap(E)).then(E=>{c.images[m]=E})}if(g.bufferView!==void 0){const N=_Ne(c,g.bufferView),E=new Blob([N],{type:g.mimeType});return createImageBitmap(E).then(P=>{c.images[m]=P})}}function bNe(g,c=0,m){const v={json:null,images:[],buffers:[]};if(new Uint32Array(g,c,1)[0]===xNe){const J=new Uint32Array(g,c);let ee=2;const ie=(J[ee++]>>2)-3,ce=J[ee++]>>2;if(ee++,v.json=JSON.parse(yNe.decode(J.subarray(ee,ee+ce))),ee+=ce,ee{const J=[],ee=O&&O.includes(Gde),ie=O&&O.includes(EO);if(ee&&J.push(function(){if(!ig)return yA??(yA=function(ce){let ue,ke=null;function Le(){ue=new Uint8Array(ke.buffer)}function Ie(){throw new Error("Unexpected Draco error.")}const Ke={a:{a:Ie,d:function(Ye,at,vt){return ue.copyWithin(Ye,at,at+vt)},c:function(Ye){const at=ue.length,vt=Math.max(Ye>>>0,Math.ceil(1.2*at)),pt=Math.ceil((vt-at)/65536);try{return ke.grow(pt),Le(),!0}catch{return!1}},b:Ie}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(ce,Ke):ce.then(Ye=>Ye.arrayBuffer()).then(Ye=>WebAssembly.instantiate(Ye,Ke))).then(Ye=>{const{Rb:at,Qb:vt,P:pt,T:kt,X:Lt,Ja:$t,La:ls,Qa:Wt,Va:ms,Wa:bs,eb:ws,jb:Os,f:Fs,e:Ps,yb:Ls,zb:hs,Ab:cs,Bb:Ds,Db:Qs,Gb:Vs}=Ye.instance.exports;ke=Ps;const Dr=(()=>{let dr=0,yr=0,kr=0,Hn=0;return Ws=>{kr&&(at(Hn),at(dr),yr+=kr,kr=dr=0),dr||(yr+=128,dr=vt(yr));const Sr=Ws.length+7&-8;let mn=dr;Sr>=yr&&(kr=Sr,mn=Hn=vt(Sr));for(let fa=0;fa{ig=ce,yA=void 0}))}()),ie&&J.push(function(){if(Wde)return;const ce=function(ue){let ke;const Le=WebAssembly.instantiateStreaming(ue,{}).then(Ye=>{ke=Ye.instance,ke.exports.__wasm_call_ctors()}),Ie={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Ke={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:Le,supported:!0,decodeGltfBuffer(Ye,at,vt,pt,kt,Lt){(function($t,ls,Wt,ms,bs,ws,Os){const Fs=$t.exports.sbrk,Ps=ms+3&-4,Ls=Fs(Ps*bs),hs=Fs(ws.length),cs=new Uint8Array($t.exports.memory.buffer);cs.set(ws,hs);const Ds=ls(Ls,ms,bs,hs,ws.length);if(Ds===0&&Os&&Os(Ls,Ps,bs),Wt.set(cs.subarray(Ls,Ls+ms*bs)),Fs(Ls-Fs(0)),Ds!==0)throw new Error(`Malformed buffer data: ${Ds}`)})(ke,ke.exports[Ke[kt]],Ye,at,vt,pt,ke.exports[Ie[Lt]])}}}(fetch(fNe()));return ce.ready.then(()=>{Wde=ce})}()),E)for(let ce=0;ce{if(ee&&P)for(const{primitives:ce}of P)for(const ue of ce)Ott(ue,v);if(ie&&P&&B)for(const ce of B)Rtt(ce,v);return v})})}function wNe(g){return fetch(g).then(c=>c.arrayBuffer()).then(c=>bNe(c,0,g))}function Kde(g){switch(g){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Zde(g){switch(g){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Yde{constructor(c,m,v,N){this.context=c,this.format=v,this.useMipmap=N&&N.useMipmap,this.texture=c.gl.createTexture(),this.update(m,{premultiply:N&&N.premultiply})}update(c,m){const v=c&&c instanceof HTMLVideoElement&&c.width===0?c.videoWidth:c.width,N=c&&c instanceof HTMLVideoElement&&c.height===0?c.videoHeight:c.height,{context:E}=this,{gl:P}=E,{x:O,y:B}=m&&m.position?m.position:{x:0,y:0},W=O+v,J=B+N;!this.size||this.size[0]===W&&this.size[1]===J||(P.bindTexture(P.TEXTURE_2D,null),P.deleteTexture(this.texture),this.texture=P.createTexture(),this.size=null),P.bindTexture(P.TEXTURE_2D,this.texture),E.pixelStoreUnpackFlipY.set(!1),E.pixelStoreUnpack.set(1),E.pixelStoreUnpackPremultiplyAlpha.set(this.format===P.RGBA8&&(!m||m.premultiply!==!1));const ee=c instanceof HTMLImageElement||c instanceof HTMLCanvasElement||c instanceof HTMLVideoElement||c instanceof ImageData||ImageBitmap&&c instanceof ImageBitmap;if(!this.size&&W>0&&J>0){const ie=this.useMipmap?Math.floor(Math.log2(Math.max(W,J)))+1:1;P.texStorage2D(P.TEXTURE_2D,ie,this.format,W,J),this.size=[W,J]}this.size&&(ee?P.texSubImage2D(P.TEXTURE_2D,0,O,B,Kde(this.format),Zde(this.format),c):"data"in c&&c.data&&P.texSubImage2D(P.TEXTURE_2D,0,O,B,v,N,Kde(this.format),Zde(this.format),c.data)),this.useMipmap&&P.generateMipmap(P.TEXTURE_2D)}bind(c,m,v=!1){const{context:N}=this,{gl:E}=N;E.bindTexture(E.TEXTURE_2D,this.texture),c!==this.minFilter&&(E.texParameteri(E.TEXTURE_2D,E.TEXTURE_MAG_FILTER,c),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_MIN_FILTER,this.useMipmap&&!v?c===E.NEAREST?E.NEAREST_MIPMAP_NEAREST:E.LINEAR_MIPMAP_LINEAR:c),this.minFilter=c),m!==this.wrapS&&(E.texParameteri(E.TEXTURE_2D,E.TEXTURE_WRAP_S,m),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_WRAP_T,m),this.wrapS=m)}bindExtraParam(c,m,v,N,E){const{context:P}=this,{gl:O}=P;O.bindTexture(O.TEXTURE_2D,this.texture),m!==this.magFilter&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_MAG_FILTER,m),this.magFilter=m),c!==this.minFilter&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_MIN_FILTER,this.useMipmap?c===O.NEAREST?O.NEAREST_MIPMAP_NEAREST:O.LINEAR_MIPMAP_LINEAR:c),this.minFilter=c),v!==this.wrapS&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_S,v),this.wrapS=v),N!==this.wrapT&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_T,N),this.wrapT=N),E!==this.compareMode&&(E?(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_COMPARE_MODE,O.COMPARE_REF_TO_TEXTURE),O.texParameteri(O.TEXTURE_2D,O.TEXTURE_COMPARE_FUNC,E)):O.texParameteri(O.TEXTURE_2D,O.TEXTURE_COMPARE_MODE,O.NONE),this.compareMode=E)}destroy(){const{gl:c}=this.context;c.deleteTexture(this.texture),this.texture=null}}class _A{constructor(c,m){this.context=c,this.texture=m}bind(c,m){const{context:v}=this,{gl:N}=v;N.bindTexture(N.TEXTURE_2D,this.texture),c!==this.minFilter&&(N.texParameteri(N.TEXTURE_2D,N.TEXTURE_MAG_FILTER,c),N.texParameteri(N.TEXTURE_2D,N.TEXTURE_MIN_FILTER,c),this.minFilter=c),m!==this.wrapS&&(N.texParameteri(N.TEXTURE_2D,N.TEXTURE_WRAP_S,m),N.texParameteri(N.TEXTURE_2D,N.TEXTURE_WRAP_T,m),this.wrapS=m)}}const Btt=oa([{name:"a_pos_3f",components:3,type:"Float32"}]),$tt=oa([{name:"a_color_3f",components:3,type:"Float32"}]),qtt=oa([{name:"a_color_4f",components:4,type:"Float32"}]),Utt=oa([{name:"a_uv_2f",components:2,type:"Float32"}]),Vtt=oa([{name:"a_normal_3f",components:3,type:"Float32"}]),Htt=oa([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Wtt=oa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function jNe(g,c){const m=PO(g.projection,g.zoom,g.width,g.height),v=function(E,P,O,B,W){const J=new x(O.lng-180*Gv,O.lat),ee=new x(O.lng+180*Gv,O.lat),ie=E.project(J.lng,J.lat),ce=E.project(ee.lng,ee.lat),ue=-Math.atan2(ce.y-ie.y,ce.x-ie.x),ke=tt.fromLngLat(O);ke.y=ye(ke.y,-1+Gv,1-Gv);const Le=ke.toLngLat(),Ie=E.project(Le.lng,Le.lat),Ke=tt.fromLngLat(Le);Ke.x+=Gv;const Ye=Ke.toLngLat(),at=E.project(Ye.lng,Ye.lat),vt=kNe(at.x-Ie.x,at.y-Ie.y,ue),pt=tt.fromLngLat(Le);pt.y+=Gv;const kt=pt.toLngLat(),Lt=E.project(kt.lng,kt.lat),$t=kNe(Lt.x-Ie.x,Lt.y-Ie.y,ue),ls=Math.abs(vt.x)/Math.abs($t.y),Wt=j([]);$(Wt,Wt,-ue*(1-(W?0:B)));const ms=j([]);return I(ms,ms,[1,1-(1-ls)*B,1]),ms[4]=-$t.x/$t.y*B,$(ms,ms,ue),S(ms,Wt,ms),ms}(g.projection,0,g.center,m,c),N=NNe(g);return I(v,v,[N,N,1]),v}function NNe(g){const c=g.projection,m=PO(g.projection,g.zoom,g.width,g.height),v=Xde(c,g.center),N=Xde(c,x.convert(c.center));return Math.pow(2,v*m+(1-m)*N)}function PO(g,c,m,v,N=1/0){const E=g.range;if(!E)return 0;const P=Math.min(N,Math.max(m,v)),O=Math.log2(P/1024);return ze(E[0]+O,E[1]+O,c)}const Gv=1/4e4;function Xde(g,c){const m=ye(c.lat,-xe,xe),v=new x(c.lng-180*Gv,m),N=new x(c.lng+180*Gv,m),E=g.project(v.lng,m),P=g.project(N.lng,m),O=tt.fromLngLat(v),B=tt.fromLngLat(N),W=P.x-E.x,J=P.y-E.y,ee=B.x-O.x,ie=B.y-O.y,ce=Math.sqrt((ee*ee+ie*ie)/(W*W+J*J));return Math.log2(ce)}function kNe(g,c,m){const v=Math.cos(m),N=Math.sin(m);return{x:g*v-c*N,y:g*N+c*v}}function SNe(g,c,m){j(g),$(g,g,Ir(c[2])),L(g,g,Ir(c[0])),R(g,g,Ir(c[1])),I(g,g,m),S(g,g,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function IO(g,c,m,v,N,E,P,O){const B=[m[0]-c[0],m[1]-c[1],0],W=[v[0]-c[0],v[1]-c[1],0];if(de(B)<1e-12||de(W)<1e-12)return He(g);const J=ut([],B,W);Ae(J,J),he(W,v,c),B[2]=(E-N)*O,W[2]=(P-N)*O;const ee=B;return ut(ee,B,W),Ae(ee,ee),is(g,J,ee)}function LO(g,c,m=!1){const v=Hv(c.zoom),N=function(E,P,O){const B=P.worldSize,W=[E[12],E[13],E[14]],J=ge(W[1]/B),ee=oe(W[0]/B),ie=j([]),ce=ne(1,J)*B,ue=ne(1,0)*B*Ce(J,P.zoom),ke=1/Sde(B);let Le=ue*ke;if(O){const at=PO(P.projection,P.zoom,P.width,P.height,1024);Le=ke*P.projection.pixelSpaceConversion(P.center.lat,B,at)}const Ie=qv(J,ee);le(Ie,Ie,Ne([],Ae([],Ie),ce*Le*W[2]));const Ke=function(at){const vt=[at[0],at[1],at[2]];let pt=[0,1,0];const kt=ut([],pt,vt);return ut(pt,vt,kt),Te(pt)===0&&(pt=[0,1,0],ut(kt,vt,pt)),Ae(kt,kt),Ae(pt,pt),Ae(vt,vt),[kt[0],kt[1],kt[2],0,pt[0],pt[1],pt[2],0,vt[0],vt[1],vt[2],0,at[0],at[1],at[2],1]}(Ie);I(ie,ie,[Le,Le,Le*ce]),T(ie,ie,[-W[0],-W[1],-W[2]]);const Ye=S([],P.globeMatrix,Ke);return S(Ye,Ye,ie),S(Ye,Ye,E),Ye}(g,c,m);if(v>0){const E=function(P,O){const B=O.worldSize,W=ne(1,0)*B*Ce(O.center.lat,O.zoom)/Sde(B),J=ne(1,O.center.lat)*B,ee=j([]);R(ee,ee,Ir(O.center.lng)),L(ee,ee,Ir(O.center.lat)),T(ee,ee,[0,0,pd]),I(ee,ee,[W,W,W*J]);const ie=O.point;return T(ee,ee,[-ie.x,-ie.y,0]),S(ee,ee,P),S(ee,O.globeMatrix,ee)}(g,c);return function(P,O,B){const W=(ue,ke,Le)=>{const Ie=de(ue),Ke=de(ke),Ye=ag(ue,ke,Le);return Ne(Ye,Ye,1/de(Ye)*Hr(Ie,Ke,Le))},J=W([P[0],P[1],P[2]],[O[0],O[1],O[2]],B),ee=W([P[4],P[5],P[6]],[O[4],O[5],O[6]],B),ie=W([P[8],P[9],P[10]],[O[8],O[9],O[10]],B),ce=ag([P[12],P[13],P[14]],[O[12],O[13],O[14]],B);return[J[0],J[1],J[2],0,ee[0],ee[1],ee[2],0,ie[0],ie[1],ie[2],0,ce[0],ce[1],ce[2],1]}(N,E,v)}return N}function Qde(g,c,m,v){const N=Er.projectAabbCorners(v,m);let E=Number.MAX_VALUE;for(let O=0;O0||Le===0&&ue[0]*ke[0]+ue[1]*ke[1]>=0&&ue[0]*ue[0]+ue[1]*ue[1]>ke[0]*ke[0]+ke[1]*ke[1])&&(J=ce)}ee=J}while(ee!==W);return B.length>0&&B.push(B[0]),B}(N);if(Oa(g,P))return E}const Wb=64,OC={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function DO(g,c,m,v,N,E,P,O,B,W=!1){const J=m.zoom,ee=m.project(v),ie=Ce(v.lat,J),ce=1/ie;j(g),T(g,g,[ee.x+P[0]*ce,ee.y+P[1]*ce,P[2]]);let ue=1,ke=1;const Le=m.worldSize;if(W){if(m.projection.name==="mercator"){let at=0;m.elevation&&(at=m.elevation.getAtPointOrZero(new tt(ee.x/Le,ee.y/Le),0));const vt=Qe([],[ee.x,ee.y,at,1],m.projMatrix)[3]/m.cameraToCenterDistance;ue=vt,ke=vt*Ce(m.center.lat,J)}else if(m.projection.name==="globe"){const at=LO(g,m),vt=[0,0,0,1];Qe(vt,vt,S([],m.projMatrix,at));const pt=vt[3]/m.cameraToCenterDistance,kt=Hv(J),Lt=m.projection.pixelsPerMeter(v.lat,Le)*Ce(v.lat,J),$t=m.projection.pixelsPerMeter(m.center.lat,Le)*Ce(m.center.lat,J);ue=pt/Hr(Lt,Pe(m.center.lat),kt),ke=pt*ie/Lt,ue*=$t,ke*=$t}}else ue=ce;I(g,g,[ue,ue,ke]);const Ie=[...g],Ke=c.orientation,Ye=[];if(SNe(Ye,[Ke[0]+(N?N[0]:0),Ke[1]+(N?N[1]:0),Ke[2]+(N?N[2]:0)],E),S(g,Ie,Ye),O&&m.elevation){let at=0;const vt=[];if(B&&m.elevation){at=function(kt,Lt,$t,ls,Wt){const ms=Lt.elevation;if(!ms)return 0;const bs=Er.projectAabbCorners($t,ls),ws=ne(1,Wt.lat)*Lt.worldSize,Os=function(yr,kr){const Hn=[0,0,1],Ws=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const Sr of Ws){const mn=yr[Sr.corners[0]],fa=yr[Sr.corners[1]],va=yr[Sr.corners[2]],Ln=[fa[0]-mn[0],fa[1]-mn[1],kr*(fa[2]-mn[2])],_i=ut(Ln,Ln,[va[0]-mn[0],va[1]-mn[1],kr*(va[2]-mn[2])]);Ae(_i,_i),Sr.dotProductWithUp=Ue(_i,Hn)}return Ws.sort((Sr,mn)=>Sr.dotProductWithUp-mn.dotProductWithUp),Ws[0].corners}(bs,ws),Fs=bs[Os[0]],Ps=bs[Os[1]],Ls=bs[Os[2]],hs=bs[Os[3]],cs=ms.getAtPointOrZero(new tt(Fs[0]/Lt.worldSize,Fs[1]/Lt.worldSize),0),Ds=ms.getAtPointOrZero(new tt(Ps[0]/Lt.worldSize,Ps[1]/Lt.worldSize),0),Qs=ms.getAtPointOrZero(new tt(Ls[0]/Lt.worldSize,Ls[1]/Lt.worldSize),0),Vs=ms.getAtPointOrZero(new tt(hs[0]/Lt.worldSize,hs[1]/Lt.worldSize),0),Dr=(cs+Vs)/2,dr=(Ds+Qs)/2;return Dr>dr?Ds=c.gl.NEAREST_MIPMAP_NEAREST}),g.uploaded=!0,g.image=null)}function Gtt(g,c,m){g.indexBuffer=c.createIndexBuffer(g.indexArray,!1,!0),g.vertexBuffer=c.createVertexBuffer(g.vertexArray,Btt.members,!1,!0),g.normalArray&&(g.normalBuffer=c.createVertexBuffer(g.normalArray,Vtt.members,!1,!0)),g.texcoordArray&&(g.texcoordBuffer=c.createVertexBuffer(g.texcoordArray,Utt.members,!1,!0)),g.colorArray&&(g.colorBuffer=c.createVertexBuffer(g.colorArray,(g.colorArray.bytesPerElement===12?$tt:qtt).members,!1,!0)),g.featureArray&&(g.pbrBuffer=c.createVertexBuffer(g.featureArray,Wtt.members,!0)),g.segments=co.simpleSegment(0,0,g.vertexArray.length,g.indexArray.length);const v=g.material;v.pbrMetallicRoughness.baseColorTexture&&bA(v.pbrMetallicRoughness.baseColorTexture,c),v.pbrMetallicRoughness.metallicRoughnessTexture&&bA(v.pbrMetallicRoughness.metallicRoughnessTexture,c),v.normalTexture&&bA(v.normalTexture,c),v.occlusionTexture&&bA(v.occlusionTexture,c,m),v.emissionTexture&&bA(v.emissionTexture,c)}function Jde(g,c,m){if(g.meshes)for(const v of g.meshes)Gtt(v,c,m);if(g.children)for(const v of g.children)Jde(v,c,m)}function OO(g){if(g.meshes)for(const c of g.meshes)c.indexArray.destroy(),c.vertexArray.destroy(),c.colorArray&&c.colorArray.destroy(),c.normalArray&&c.normalArray.destroy(),c.texcoordArray&&c.texcoordArray.destroy(),c.featureArray&&c.featureArray.destroy();if(g.children)for(const c of g.children)OO(c)}function eue(g){if(g.meshes)for(const m of g.meshes)m.vertexBuffer&&(m.vertexBuffer.destroy(),m.indexBuffer.destroy(),m.normalBuffer&&m.normalBuffer.destroy(),m.texcoordBuffer&&m.texcoordBuffer.destroy(),m.colorBuffer&&m.colorBuffer.destroy(),m.pbrBuffer&&m.pbrBuffer.destroy(),m.segments.destroy(),m.material&&((c=m.material).pbrMetallicRoughness.baseColorTexture&&c.pbrMetallicRoughness.baseColorTexture.gfxTexture&&c.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),c.pbrMetallicRoughness.metallicRoughnessTexture&&c.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&c.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),c.normalTexture&&c.normalTexture.gfxTexture&&c.normalTexture.gfxTexture.destroy(),c.emissionTexture&&c.emissionTexture.gfxTexture&&c.emissionTexture.gfxTexture.destroy(),c.occlusionTexture&&c.occlusionTexture.gfxTexture&&c.occlusionTexture.gfxTexture.destroy()));var c;if(g.children)for(const m of g.children)eue(m)}function Gb(g,c){const m=g.json.bufferViews[c.bufferView],v=AO[c.componentType];return new v(g.buffers[m.buffer],(c.byteOffset||0)+(m.byteOffset||0),c.count*(m.byteStride&&m.byteStride!==vA[c.type]*v.BYTES_PER_ELEMENT?m.byteStride/v.BYTES_PER_ELEMENT:vA[c.type]))}function tue(g,c,m,v){const N=AO[c.componentType],E=function(J){switch(J){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(N),P=g.json.bufferViews[c.bufferView],O=P.byteStride?P.byteStride/N.BYTES_PER_ELEMENT:vA[c.type],B=m.float32,W=B.length/m.capacity;for(let J=0,ee=0;J0){for(let Le=0;Le0){E.texcoordArray=new Bp;const ie=c.json.accessors[N.TEXCOORD_0];E.texcoordArray.resize(ie.count);const ce=Gb(c,ie);tue(c,ie,E.texcoordArray,ce)}if(N._FEATURE_ID_RGBA4444!==void 0){const ie=c.json.accessors[N._FEATURE_ID_RGBA4444];c.json.extensionsUsed&&c.json.extensionsUsed.includes("EXT_meshopt_compression")&&(E.featureData=Gb(c,ie))}N._FEATURE_RGBA4444!==void 0&&(E.featureData=new Uint32Array(Gb(c,c.json.accessors[N._FEATURE_RGBA4444]).buffer));const ee=g.material;return E.material=function(ie,ce){const{emissiveFactor:ue=[0,0,0],alphaMode:ke="OPAQUE",alphaCutoff:Le=.5,normalTexture:Ie,occlusionTexture:Ke,emissiveTexture:Ye,doubleSided:at,name:vt}=ie,{baseColorFactor:pt=[1,1,1,1],metallicFactor:kt=1,roughnessFactor:Lt=1,baseColorTexture:$t,metallicRoughnessTexture:ls}=ie.pbrMetallicRoughness||{},Wt=Ke?ce[Ke.index]:void 0;if(Ke&&Ke.extensions&&Ke.extensions.KHR_texture_transform&&Wt){const ms=Ke.extensions.KHR_texture_transform;Wt.offsetScale=[ms.offset[0],ms.offset[1],ms.scale[0],ms.scale[1]]}return{name:vt,pbrMetallicRoughness:{baseColorFactor:new Fr(...pt),metallicFactor:kt,roughnessFactor:Lt,baseColorTexture:$t?ce[$t.index]:void 0,metallicRoughnessTexture:ls?ce[ls.index]:void 0},doubleSided:at,emissiveFactor:new Fr(...ue),alphaMode:ke,alphaCutoff:Le,normalTexture:Ie?ce[Ie.index]:void 0,occlusionTexture:Wt,emissionTexture:Ye?ce[Ye.index]:void 0,defined:ie.defined===void 0}}(ee!==void 0?c.json.materials[ee]:{defined:!1},m),E}function MNe(g,c,m){const{matrix:v,rotation:N,translation:E,scale:P,mesh:O,extras:B,children:W,name:J}=g,ee={};if(ee.name=J,ee.localMatrix=v||function(ie,ce,ue,ke){var Le=ce[0],Ie=ce[1],Ke=ce[2],Ye=ce[3],at=Le+Le,vt=Ie+Ie,pt=Ke+Ke,kt=Le*at,Lt=Le*vt,$t=Le*pt,ls=Ie*vt,Wt=Ie*pt,ms=Ke*pt,bs=Ye*at,ws=Ye*vt,Os=Ye*pt,Fs=ke[0],Ps=ke[1],Ls=ke[2];return ie[0]=(1-(ls+ms))*Fs,ie[1]=(Lt+Os)*Fs,ie[2]=($t-ws)*Fs,ie[3]=0,ie[4]=(Lt-Os)*Ps,ie[5]=(1-(kt+ms))*Ps,ie[6]=(Wt+bs)*Ps,ie[7]=0,ie[8]=($t+ws)*Ls,ie[9]=(Wt-bs)*Ls,ie[10]=(1-(kt+ls))*Ls,ie[11]=0,ie[12]=ue[0],ie[13]=ue[1],ie[14]=ue[2],ie[15]=1,ie}([],N||[0,0,0,1],E||[0,0,0],P||[1,1,1]),ee.globalMatrix=w(ee.localMatrix),O!==void 0){ee.meshes=m[O];const ie=ee.anchor=[0,0];for(const ce of ee.meshes){const{min:ue,max:ke}=ce.aabb;ie[0]+=ue[0]+ke[0],ie[1]+=ue[1]+ke[1]}ie[0]=Math.floor(ie[0]/ee.meshes.length/2),ie[1]=Math.floor(ie[1]/ee.meshes.length/2)}if(B&&(B.id&&(ee.id=B.id),B.lights&&(ee.lights=function(ie){if(!ie.length)return[];const ce=function(Ke){const Ye=atob(Ke),at=new Uint8Array(Ye.length);for(let vt=0;vt1&&v[v.length-1].equals(v[0])&&v.pop();let N=0;for(let P=0;P0&&v.reverse();const E=AC(v.flatMap(P=>[P.x,P.y]),[]);return E.length===0?null:{vertices:v,indices:E}}function Xtt(g,c){const m=[],v=[];let N=0;const E=[];for(const P of g){N=m.length;const O=P.vertexArray.float32,B=P.indexArray.uint16;for(let W=0;W0&&([v[P+1],v[P+2]]=[v[P+2],v[P+1]])}return{vertices:m,indices:v}}function sue(g){const c=function(B,W){const J=[],ee=WebGL2RenderingContext;if(B.json.textures)for(const ie of B.json.textures){const ce={magFilter:ee.LINEAR,minFilter:ee.NEAREST,wrapS:ee.REPEAT,wrapT:ee.REPEAT};ie.sampler!==void 0&&Object.assign(ce,B.json.samplers[ie.sampler]),J.push({image:W[ie.source],sampler:ce,uploaded:!1})}return J}(g,g.images),m=function(B,W){const J=[];for(const ee of B.json.meshes){const ie=[];for(const ce of ee.primitives)ie.push(Ktt(ce,B,W));J.push(ie)}return J}(g,c),{scenes:v,scene:N,nodes:E}=g.json,P=v?v[N||0].nodes:[...E.keys()],O=[];for(const B of P)O.push(MNe(E[B],g,m));return function(B,W,J){const ee={},ie=new Set;for(let ce=0;ce0){const ce=Array.from(ie.values()).sort((ue,ke)=>ue-ke);for(let ue=ce.length-1;ue>=0;ue--)B.splice(ce[ue],1)}}(O,P,g.json.nodes),O}function Qtt(g){g.heightmap=new Float32Array(4096),g.heightmap.fill(-1);const c=g.vertexArray.float32,m=g.aabb.min[0]-1,v=g.aabb.min[1]-1,N=Wb/(g.aabb.max[0]-m+2),E=Wb/(g.aabb.max[1]-v+2);for(let P=0;Pg.heightmap[W*Wb+B]&&(g.heightmap[W*Wb+B]=O)}}function TNe(g,c,m,v,N){m.reserve(m.length+4*g.length),v.reserve(v.length+10*g.length),N.reserve(N.length+10*g.length);let E=v.length;for(const P of g){const O=Math.min(10,Math.max(4,1.3*P.height))*c,B=[-P.normal[1],P.normal[0],0],W=Math.min(.29,.1*P.width/P.depth),J=P.width-2*P.depth*c*(W+.01),ee=Ge([],P.pos,B,J/2),ie=Ge([],P.pos,B,-J/2),ce=[ee[0],ee[1],ee[2]+P.height],ue=[ie[0],ie[1],ie[2]+P.height],ke=Ge([],P.normal,B,W);Ne(ke,ke,O);const Le=Ge([],P.normal,B,-W);Ne(Le,Le,O),le(ke,ee,ke),le(Le,ie,Le),ee[2]+=.1,ie[2]+=.1,v.emplaceBack(ke[0],ke[1],ke[2]),v.emplaceBack(Le[0],Le[1],Le[2]),v.emplaceBack(ee[0],ee[1],ee[2]),v.emplaceBack(ie[0],ie[1],ie[2]),v.emplaceBack(ce[0],ce[1],ce[2]),v.emplaceBack(ue[0],ue[1],ue[2]),v.emplaceBack(ee[0],ee[1],ee[2]),v.emplaceBack(ie[0],ie[1],ie[2]),v.emplaceBack(ke[0],ke[1],ke[2]),v.emplaceBack(Le[0],Le[1],Le[2]);const Ie=J/O/2;N.emplaceBack(-Ie-W,-1,Ie,.8),N.emplaceBack(Ie+W,-1,Ie,.8),N.emplaceBack(-Ie,0,Ie,1.3),N.emplaceBack(Ie,0,Ie,1.3),N.emplaceBack(Ie+W,-.8,Ie,.7),N.emplaceBack(Ie+W,-.8,Ie,.7),N.emplaceBack(0,0,Ie,1.3),N.emplaceBack(0,0,Ie,1.3),N.emplaceBack(Ie+W,-1.2,Ie,.8),N.emplaceBack(Ie+W,-1.2,Ie,.8),m.emplaceBack(6+E,4+E,8+E),m.emplaceBack(7+E,9+E,5+E),m.emplaceBack(0+E,1+E,2+E),m.emplaceBack(1+E,3+E,2+E),E+=10}}function Jtt(g,c){const m={};m.indexArray=new bl,m.vertexArray=new bh,m.colorArray=new _x,TNe(g,c,m.indexArray,m.vertexArray,m.colorArray);const v={defined:!0};v.emissiveFactor=Fr.black;const N={};return N.baseColorFactor=Fr.white,v.pbrMetallicRoughness=N,m.material=v,m.aabb=new Er([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),m}const ANe=oa([{name:"a_pos_3f",components:3,type:"Float32"}]),est=oa([{name:"a_normal_3",components:3,type:"Int16"}]),tst=oa([{name:"a_centroid_3",components:3,type:"Int16"}]),ENe=oa([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),sst=oa([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),rst=oa([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),nst=oa([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),ast=oa([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),ist=oa([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),PNe=Ut.types,RO=32767;function ost(g,c){const m=Xs+c;for(const v of g)for(const N of v)if(N.x<-c||N.x>m||N.y<-c||N.y>m)return!1;return!0}function lst(g){switch(g){case"flat":return 3;case"hipped":return 1;case"gabled":return 2;case"parapet":return 0;case"mansard":return 4;case"skillion":return 5;case"pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${g}`)}}class rue{constructor(){this.layoutVertexArray=new bh,this.layoutAttenuationArray=new _x,this.layoutColorArray=new wh,this.indexArray=new bl,this.indexArrayForConflation=new bl,this.segmentsBucket=new co}}class nue{constructor(c){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new co,this.entranceBloom=new rue;const m=66560;this.layoutVertexArray=new bh,this.layoutVertexArray.reserve(m),this.layoutNormalArray=new Ov,this.layoutNormalArray.reserve(m),this.layoutCentroidArray=new Ov,this.layoutCentroidArray.reserve(m),this.layoutColorArray=new wh,this.layoutColorArray.reserve(m),this.layoutFloodLightDataArray=new bx,this.layoutFloodLightDataArray.reserve(m),this.layoutAOArray=new yC,this.layoutAOArray.reserve(m),this.indexArray=new bl,this.indexArray.reserve(66560),this.indexArrayForConflation=new bl,this.segmentsBucket=new co,this.entranceBloom=new rue,c&&(this.layoutFacadePaintArray=new wh,this.layoutFacadeDataArray=new Uy,this.layoutFacadeVerticalRangeArray=new wh)}reserve(c,m,v){this.layoutVertexArray.reserveForAdditional(c),this.layoutCentroidArray.reserveForAdditional(c),this.layoutFloodLightDataArray.reserveForAdditional(c),this.layoutNormalArray.reserveForAdditional(c),this.layoutAOArray.reserveForAdditional(c),this.layoutColorArray.reserveForAdditional(c),this.indexArray.reserveForAdditional(m),v&&(this.layoutFacadePaintArray.reserveForAdditional(c),this.layoutFacadeDataArray.reserveForAdditional(c),this.layoutFacadeVerticalRangeArray.reserveForAdditional(c))}}class INe{constructor(c){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Bp,this.footprintsIndices=new bx,this.footprintsMin=new es(1/0,1/0),this.footprintsMax=new es(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new nue(!1),this.buildingWithFacade=new nue(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=c.zoom,this.canonical=c.canonical,this.layers=c.layers,this.layerIds=this.layers.map(m=>m.fqid),this.index=c.index,this.hasPattern=!1,this.worldview=c.worldview,this.lut=c.lut,this.programConfigurations=new Xm(c.layers,{zoom:c.zoom,lut:c.lut}),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.projection=c.projection,this.groundEffect=new Bde(c),this.groundEffect.groundRadiusArray=new Qf,this.hasAppearances=null}updateFootprints(c,m){const v=new wO([],[],1),N={vertices:[],indices:new Uint32Array(0),grid:v,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};m.push({footprint:N,id:c})}updateAppearances(c,m,v,N){}prepare(){return function(){if(TO!=null||mNe!=null)return null;if(DC!=null)return DC;const c=fetch(ra.BUILDING_GEN_URL);return DC=function(m){let v,N,E,P,O;function B(){v=new Uint8Array(O.buffer),N=new Int16Array(O.buffer),E=new Int32Array(O.buffer),P=new Float32Array(O.buffer)}function W(){throw new Error("Unexpected BuildingGen error.")}const J=()=>{},ee={a:{a:W,f:function(ie){const ce=v.length,ue=Math.max(ie>>>0,Math.ceil(1.2*ce)),ke=Math.ceil((ue-ce)/65536);try{return O.grow(ke),B(),!0}catch{return!1}},g:W,b:J,c:J,d:J,e:J}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(m,ee):m.then(ie=>ie.arrayBuffer()).then(ie=>WebAssembly.instantiate(ie,ee))).then(ie=>{const ce=ie.instance.exports;return(0,ce.g)(),O=ce.f,B(),new Itt({setStyle:ce.h,setAOOptions:ce.i,setMetricOptions:ce.j,setStructuralOptions:ce.k,setFacadeOptions:ce.l,setFauxFacadeOptions:ce.m,setFacadeClassifierOptions:ce.n,addFeature:ce.o,addFacade:ce.p,generateMesh:ce.q,getLastError:ce.r,getOuterRingLength:ce.s,getMeshCount:ce.t,getPositionsPtr:ce.u,getPositionsLength:ce.v,getNormalsPtr:ce.w,getNormalsLength:ce.x,getAOPtr:ce.y,getAOLength:ce.z,getUVPtr:ce.A,getUVLength:ce.B,getFauxFacadePtr:ce.C,getFauxFacadeLength:ce.D,getIndicesPtr:ce.E,getIndicesLength:ce.F,getBuildingPart:ce.G,getRingCount:ce.H,getRingPtr:ce.I,getRingLength:ce.J,malloc:ce.K,free:ce.L,heapU8:v,heap16:N,heap32:E,heapF32:P})})}(c).then(m=>(DC=null,TO=m,TO)).catch(m=>{ur("Could not load building-gen"),DC=null,mNe=m}),DC}()}populate(c,m,v,N){const E=Ltt();if(!E)return;const P=Be(v);this.tileToMeter=P,this.brightness=m.brightness,E.setStyle({normalScale:[1,-1,P],tileToMeters:P}),E.setAOOptions(!1,.3),E.setMetricOptions(!1,16),E.setStructuralOptions(!0),E.setFacadeClassifierOptions(3);const O=new Map,B=new Map;let W=0;for(const{feature:Ie}of c){if(PNe[Ie.type]!=="LineString"){O.set(Ie.id,Ie.properties.source_id);continue}const Ke=this.layers[0]._featureFilter.needGeometry;if(Ke&&!this.layers[0]._featureFilter.filter(new Fi(this.zoom),Ie,v))continue;const Ye=Ht(Ie,Ke);if(!Ke&&!this.layers[0]._featureFilter.filter(new Fi(this.zoom),Ye,v))continue;const at=Ke?Ye.geometry:Et(Ie,v,N),vt=[];for(const $t of at)for(const ls of $t)vt.push(ls.x),vt.push(ls.y);const pt={coordinates:vt,crossPerc:Ie.properties.cross_perc,distanceToRoad:Ie.properties.distance_to_road,entrances:Ie.properties.entrances,sourceId:0},kt=Ie.properties.source_id;let Lt=B.get(kt);Lt||(Lt=[],B.set(kt,Lt)),Lt.push(pt),++W}this.maxHeight=0;const J=new Array,ee=new Set,ie=Ie=>{Ie!=null&&ee.add(Ie)},ce=(Ie,Ke)=>{Ie!=null&&J.push({buildingId:Ie,footprintIndex:Ke})},ue=64*(c.length-W),ke=ue/2;this.buildingWithFacade.reserve(ue,ke,!0),this.buildingWithoutFacade.reserve(2*ue,2*ke,!1),this.footprintsIndices.reserve(16*(c.length-W)),this.footprintsVertices.reserve(8*(c.length-W));for(const{feature:Ie,id:Ke,index:Ye,sourceLayerIndex:at}of c){if(PNe[Ie.type]==="LineString")continue;const vt=this.layers[0]._featureFilter.needGeometry;if(vt&&!this.layers[0]._featureFilter.filter(new Fi(this.zoom),Ie,v))continue;let pt=null;if(Ie.properties&&Ie.properties.hasOwnProperty("building_id")&&(pt=Ie.properties.building_id,ee.has(pt)))continue;const kt=Ht(Ie,vt);if(!vt&&!this.layers[0]._featureFilter.filter(new Fi(this.zoom),kt,v))continue;const Lt=vt?kt.geometry:Et(Ie,v,N),$t=dA(Lt,500);let ls=!1;for(const Xr of $t)if(Xr.length!==1){ls=!0;break}if(ls){ie(pt);continue}if(!ost(Lt,163)){ie(pt);continue}const Wt=this.layers[0],ms=lst(Wt.layout.get("building-roof-shape").evaluate(Ie,{},v)),bs=Wt.layout.get("building-base").evaluate(Ie,{},v),ws=Wt.layout.get("building-height").evaluate(Ie,{},v),Os=Wt.layout.get("building-flood-light-ground-radius").evaluate(Ie,{},v),Fs=Wt.paint.get("building-ambient-occlusion-intensity"),Ps=Os/this.tileToMeter;Ie.properties["building-part"]="roof";const Ls=Wt.paint.get("building-color").evaluate(Ie,{},this.canonical).toPremultipliedRenderColor(this.lut),hs=Wt.paint.get("building-emissive-strength").evaluate(Ie,{},this.canonical);Ie.properties["building-part"]="wall";const cs=Wt.paint.get("building-color").evaluate(Ie,{},this.canonical).toPremultipliedRenderColor(this.lut),Ds=Wt.paint.get("building-emissive-strength").evaluate(Ie,{},this.canonical);Ie.properties["building-part"]="window";const Qs=Wt.paint.get("building-color").evaluate(Ie,{},this.canonical).toPremultipliedRenderColor(this.lut),Vs=Wt.paint.get("building-emissive-strength").evaluate(Ie,{},this.canonical);Ie.properties["building-part"]="door";const Dr=Wt.paint.get("building-color").evaluate(Ie,{},this.canonical).toPremultipliedRenderColor(this.lut),dr=Wt.paint.get("building-emissive-strength").evaluate(Ie,{},this.canonical);let yr=Wt.layout.get("building-flood-light-wall-radius").evaluate(Ie,{},v);yr=ye(yr,0,2048);const kr=yr/2048*RO,Hn=O.get(Ke),Ws=B.get(Hn)||[],Sr=Ws.length!==0&&Wt.layout.get("building-facade").evaluate(Ie,{},v);E.setFacadeOptions(4,!0),E.setFauxFacadeOptions(Sr,!1,1);let mn=0,fa=0,va=0,Ln=0,_i=0,ft=0,_t=0,ps=0,Rs=0,ir=0,or=0;if(Sr){let Xr=Math.round(Wt.layout.get("building-facade-floors").evaluate(Ie,{},v));if(bs===0){Xr=Math.max(1,Xr-(Ws.length>0?1:0));let ci=4;if(ws>100){const Ki=[10,13,15];ci=Ki[Ie.id?Ie.id%Ki.length:0]}else ws<=10&&(ci=3);E.setFacadeOptions(ci,!0),_i=(ws<15?1.3:1.61803)*ci/P}else _i=bs/P;ft=ws/P,_i=Math.min(_i,ft),va=Wt.layout.get("building-facade-unit-width").evaluate(Ie,{},v)/P,Ln=(ft-_i)/Xr,E.setFauxFacadeOptions(!0,!0,va);const mo=Wt.layout.get("building-facade-window").evaluate(Ie,{},v);mn=mo[0],fa=mo[1],_t=Math.floor(65535*Math.min(1,_i/Xs)),ps=Math.floor(65535*Math.min(1,ft/Xs)),Rs=Math.floor(255*mn)<<8|Math.floor(255*fa),ir=Math.floor(65535*Math.min(1,va/Xs)),or=Math.floor(65535*Math.min(1,Ln/Xs))}const Or=Array($t.length),zr={x:1/0,y:1/0},Sn={x:-1/0,y:-1/0},zn={x:0,y:0};let Vn=0;for(let Xr=0;Xr<$t.length;Xr++){const mo=$t[Xr];if(mo.length>0){const ci=[],Ki=Array(mo.length+1);Ki[0]=0;for(let Nl=0;NlXs||zr.y<0||Sn.y>Xs)&&this.featuresOnBorder.push({featureId:Ie.id,footprintIndex:this.footprints.length});{const Xr=AC(wi,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+Xr.length),this.footprintsIndices.uint16.set(Xr,Yr),this.buildingIds.add(pt??Ie.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,Pi.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,Pi.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,zi.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,zi.y);const mo={footprintVertexOffset:ca,footprintVertexLength:this.footprintsVertices.length-ca,footprintIndexOffset:Yr,footprintIndexLength:this.footprintsIndices.length-Yr,min:Pi,max:zi,hiddenFlags:0,indicesOffset:Ja,indicesLength:so,bloomIndicesOffset:li,bloomIndicesLength:ki,groundEffectVertexOffset:Fo,groundEffectVertexLength:Li,hasFauxFacade:Sr,height:Bn,promoteId:Ke,feature:kt,parts:za,buildingBloom:Ba},ci=this.footprints.length;Ie.id!==void 0&&this.featureFootprintLookup.set(Ie.id,ci),ce(pt,ci),this.footprints.push(mo)}this.programConfigurations.populatePaintArrays(Jr.layoutVertexArray.length,Ie,Ye,{},m.availableImages,v,m.brightness),this.groundEffect.addPaintPropertiesData(Ie,Ye,{},m.availableImages,v,m.brightness),m.featureIndex.insert(Ie,Lt,Ye,at,this.index,bi)}J.forEach(({buildingId:Ie,footprintIndex:Ke})=>{ee.has(Ie)&&(this.footprints[Ke].hiddenFlags|=4)});const Le=new Set;this.buildingIds.forEach((Ie,Ke,Ye)=>{ee.has(Ie)||Le.add(Ie)}),this.buildingIds=Le,this.groundEffect.prepareBorderSegments()}update(c,m,v,N,E,P,O){this.programConfigurations.updatePaintArrays(c,m,E,v,N,P,O),this.groundEffect.update(c,m,E,v,N,P,O),this.evaluate(this.layers[0],c),this.colorBufferUploaded=!1}isEmpty(){return this.buildingWithoutFacade.layoutVertexArray.length===0&&this.buildingWithFacade.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(c){const m=v=>{v.layoutVertexBuffer=c.createVertexBuffer(v.layoutVertexArray,ANe.members),v.layoutNormalBuffer=c.createVertexBuffer(v.layoutNormalArray,est.members),v.layoutCentroidBuffer=c.createVertexBuffer(v.layoutCentroidArray,tst.members),v.layoutFloodLightDataBuffer=c.createVertexBuffer(v.layoutFloodLightDataArray,ist.members),v.layoutFacadeDataArray&&v.layoutFacadeDataArray.length&&(v.layoutFacadeDataBuffer=c.createVertexBuffer(v.layoutFacadeDataArray,rst.members)),v.layoutFacadeVerticalRangeArray&&v.layoutFacadeVerticalRangeArray.length&&(v.layoutFacadeVerticalRangeBuffer=c.createVertexBuffer(v.layoutFacadeVerticalRangeArray,nst.members)),v.entranceBloom.layoutVertexArray.length&&(v.entranceBloom.layoutVertexBuffer=c.createVertexBuffer(v.entranceBloom.layoutVertexArray,ANe.members),v.entranceBloom.layoutAttenuationBuffer=c.createVertexBuffer(v.entranceBloom.layoutAttenuationArray,ast.members)),this.uploadUpdatedColorBuffer(c),this.uploadUpdatedIndexBuffer(c)};this.uploaded||(m(this.buildingWithoutFacade),m(this.buildingWithFacade),this.groundEffect.upload(c)),this.groundEffect.uploadPaintProperties(c),this.programConfigurations.upload(c),this.uploaded=!0}destroy(){const c=m=>{m.layoutVertexBuffer&&(m.layoutVertexBuffer.destroy(),m.layoutNormalBuffer.destroy(),m.layoutColorBuffer.destroy(),m.segmentsBucket.destroy(),m.indexBuffer&&m.indexBuffer.destroy(),m.entranceBloom.layoutVertexBuffer&&(m.entranceBloom.layoutVertexBuffer.destroy(),m.entranceBloom.layoutColorBuffer.destroy(),m.entranceBloom.layoutAttenuationBuffer.destroy(),m.entranceBloom.indexBuffer.destroy(),m.entranceBloom.segmentsBucket.destroy()))};c(this.buildingWithoutFacade),c(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(c,m,v=!0){let N=!1;const E=v?m:0,P=0|(v?-1:~m);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const O of c){const B=this.footprints[O],W=B.hiddenFlags&P|E;B.hiddenFlags!==W&&(B.hiddenFlags=W,N=!0,this.groundEffect.updateHiddenByLandmarkRange(B.groundEffectVertexOffset,B.groundEffectVertexLength,B.hiddenFlags!==0))}return N&&(this.indexArrayForConflationUploaded=!1),N}uploadUpdatedIndexBuffer(c){if(this.groundEffect.uploadHiddenByLandmark(c),this.indexArrayForConflationUploaded)return;const m=N=>{N.indexArray.length!==0&&(N.indexArrayForConflation.resize(N.indexArray.length),N.indexArrayForConflation.uint16.set(N.indexArray.uint16),N.entranceBloom.indexArrayForConflation.resize(N.entranceBloom.indexArray.length),N.entranceBloom.indexArrayForConflation.uint16.set(N.entranceBloom.indexArray.uint16))};m(this.buildingWithoutFacade),m(this.buildingWithFacade);for(const N of this.footprints){const E=N.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,P=N.indicesOffset+N.indicesLength;if(N.hiddenFlags!==0){for(let B=N.indicesOffset;B{N.indexArray.length!==0&&(N.indexBuffer?N.indexBuffer.updateData(N.indexArrayForConflation):N.indexBuffer=c.createIndexBuffer(N.indexArrayForConflation,!0),N.entranceBloom.indexBuffer?N.entranceBloom.indexBuffer.updateData(N.entranceBloom.indexArrayForConflation):N.entranceBloom.indexBuffer=c.createIndexBuffer(N.entranceBloom.indexArrayForConflation,!0))};v(this.buildingWithoutFacade),v(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(c){const m=v=>{v.layoutColorBuffer?v.layoutColorBuffer.updateData(v.layoutColorArray):v.layoutColorBuffer=c.createVertexBuffer(v.layoutColorArray,ENe.members,!0),v.layoutFacadePaintArray&&(v.layoutFacadePaintBuffer?v.layoutFacadePaintBuffer.updateData(v.layoutFacadePaintArray):v.layoutFacadePaintBuffer=c.createVertexBuffer(v.layoutFacadePaintArray,sst.members,!0)),v.entranceBloom.layoutColorBuffer?v.entranceBloom.layoutColorBuffer.updateData(v.entranceBloom.layoutColorArray):v.entranceBloom.layoutColorBuffer=c.createVertexBuffer(v.entranceBloom.layoutColorArray,ENe.members,!0)};m(this.buildingWithoutFacade),m(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(c,m){const v=c.paint.get("building-ambient-occlusion-intensity");for(const N of this.footprints){if(4&N.hiddenFlags)continue;const E=m[N.promoteId],P=N.feature;P.properties["building-part"]="roof";const O=c.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),B=c.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="wall";const W=c.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),J=c.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="window";const ee=c.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),ie=c.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="door";const ce=c.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),ue=c.paint.get("building-emissive-strength").evaluate(P,E,this.canonical),ke=N.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const Ie of N.parts){let Ke,Ye=O;Ie.part===1?(Ye=O,Ke=B):Ie.part===0?(Ye=W,Ke=J):Ie.part===2?(Ye=ee,Ke=ie):Ie.part===3&&(Ye=ce,Ke=ue),Ke=ye(Ke,0,1);for(let at=0;atP.max.x||B.max.xP.max.y||B.max.yO.max.x||O.min.x>c||m>O.max.y||O.min.y>m||O.height<=v||cst(P,this.footprintsVertices.float32.subarray(2*O.footprintVertexOffset,2*(O.footprintVertexOffset+O.footprintVertexLength)),this.footprintsIndices.uint16.subarray(O.footprintIndexOffset,O.footprintIndexOffset+O.footprintIndexLength))&&(v=O.height,this.footprintLookup[E]=O,N=O.hiddenFlags!==0);if(v!==Number.NEGATIVE_INFINITY)return{height:v,hidden:N};this.footprintLookup[E]=void 0}}function cst(g,c,m){for(let v=0;v1&&(B=c[++O]);const J=Math.abs(W-B.left),ee=Math.abs(W-B.right),ie=Math.min(J,ee);let ce;const ue=E/v*(N+1);if(B.isDash){const ke=N-Math.abs(ue);ce=Math.sqrt(ie*ie+ke*ke)}else ce=N-Math.sqrt(ie*ie+ue*ue);this.image.data[P+W]=Math.max(0,Math.min(255,ce+128))}}}addRegularDash(c,m){for(let B=c.length-1;B>=0;--B){const W=c[B],J=c[B+1];W.zeroLength?c.splice(B,1):J&&J.isDash===W.isDash&&(J.left=W.left,c.splice(B,1))}const v=c[0],N=c[c.length-1];v.isDash===N.isDash&&(v.left=N.left-this.width,N.right=v.right+this.width);const E=this.width*this.nextRow;let P=0,O=c[P];for(let B=0;B1&&(O=c[++P]);const W=Math.abs(B-O.left),J=Math.abs(B-O.right),ee=Math.min(W,J);this.image.data[E+B]=Math.max(0,Math.min(255,(O.isDash?ee:-ee)+m+128))}}addDash(c,m){const v=this.getKey(c,m);if(this.positions[v])return this.positions[v];const N=m==="round",E=N?7:0,P=2*E+1;if(this.nextRow+P>this.height)return ur("LineAtlas out of space"),null;c.length===0&&c.push(1);let O=0;for(let J=0;Jm.fqid),this.index=c.index,this.projection=c.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(m=>{this.gradients[m.id]={}}),this.layoutVertexArray=new uC,this.layoutVertexArray2=new bh,this.patternVertexArray=new bh,this.indexArray=new bl,this.programConfigurations=new Xm(c.layers,{zoom:c.zoom,lut:c.lut}),this.segments=new co,this.maxLineLength=0,this.zOffsetVertexArray=new bh,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.tessellationStep=c.tessellationStep?c.tessellationStep:Xs/64,this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,v,N){}populate(c,m,v,N){this.hasPattern=Ede("line",this.layers,this.pixelRatio,m);const E=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Be(v);const P=this.layers[0].layout.get("line-elevation-reference");if(P==="hd-road-markup")this.elevationType="road";else{const ie=this.layers[0].layout.get("line-z-offset"),ce=ie.isConstant()&&!ie.constantOr(0);this.elevationType=P!=="sea"&&P!=="ground"&&ce?"none":"offset",this.elevationType==="offset"&&P==="none"&&ur(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`)}const O=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.elevationType==="offset"&&O!==void 0;const B=[];for(const{feature:ie,id:ce,index:ue,sourceLayerIndex:ke}of c){const Le=this.layers[0]._featureFilter.needGeometry,Ie=Ht(ie,Le);if(!this.layers[0]._featureFilter.filter(new Fi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),Ie,v))continue;const Ke=E?E.evaluate(Ie,{},v):void 0,Ye={id:ce,properties:ie.properties,type:ie.type,sourceLayerIndex:ke,index:ue,geometry:Le?Ie.geometry:Et(ie,v,N),patterns:{},sortKey:Ke};B.push(Ye)}E&&B.sort((ie,ce)=>ie.sortKey-ce.sortKey);const{lineAtlas:W,featureIndex:J}=m,ee=this.addConstantDashes(W);for(const ie of B){const{geometry:ce,index:ue,sourceLayerIndex:ke}=ie;if(ee&&this.addFeatureDashes(ie,W),this.hasPattern){const Le=Pde("line",this.layers,ie,this.zoom,this.pixelRatio,m);this.patternFeatures.push(Le)}else this.addFeature(ie,ce,ue,v,W.positions,m.availableImages,m.brightness,m.elevationFeatures);J.insert(c[ue].feature,ce,ue,ke,this.index)}}addConstantDashes(c){let m=!1;for(const v of this.layers){const N=v.paint.get("line-dasharray").value,E=v.layout.get("line-cap").value;if(N.kind!=="constant"||E.kind!=="constant")m=!0;else{const P=E.value,O=N.value;if(!O)continue;c.addDash(O,P)}}return m}addFeatureDashes(c,m){const v=this.zoom;for(const N of this.layers){const E=N.paint.get("line-dasharray").value,P=N.layout.get("line-cap").value;if(E.kind==="constant"&&P.kind==="constant")continue;let O,B;if(E.kind==="constant"){if(O=E.value,!O)continue}else O=E.evaluate({zoom:v},c);B=P.kind==="constant"?P.value:P.evaluate({zoom:v},c),m.addDash(O,B),c.patterns[N.id]=[m.getKey(O,B)]}}update(c,m,v,N,E,P,O,B){this.programConfigurations.updatePaintArrays(c,m,E,v,N,P,O,B)}addFeatures(c,m,v,N,E,P){for(const O of this.patternFeatures)this.addFeature(O,O.geometry,O.index,m,v,N,P,c.elevationFeatures)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=c.createVertexBuffer(this.layoutVertexArray2,fst)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=c.createVertexBuffer(this.patternVertexArray,xst)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,hst.members,!0)),this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,mst),this.indexBuffer=c.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(c),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(c,m){let v,N;if(m&&m>0?(v=`mapbox_clip_start_${m}`,N=`mapbox_clip_end_${m}`):(v="mapbox_clip_start",N="mapbox_clip_end"),c.properties&&c.properties.hasOwnProperty(v)&&c.properties.hasOwnProperty(N))return{start:+c.properties[v],end:+c.properties[N]}}addFeature(c,m,v,N,E,P,O,B){const W=this.layers[0].layout,J=W.get("line-join").evaluate(c,{}),ee=W.get("line-cap").evaluate(c,{}),ie=W.get("line-miter-limit"),ce=W.get("line-round-limit");this.lineClips=this.lineFeatureClips(c),this.lineFeature=c;const ue=!(!c.properties||!c.properties.hasOwnProperty("mapbox_line_metrics"))&&c.properties.mapbox_line_metrics;this.zOffsetValue=W.get("line-z-offset").value;const ke=this.layers[0].paint.get("line-width").value;if(ke.kind!=="constant"&&ke.isLineProgressConstant===!1&&(this.variableWidthValue=ke),this.elevationType==="road"){const Le=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(c,m,N,B,J,ee,ie,ce)){const[Ie,Ke]=this.clipRuntimeLinesToTile(m,1);for(let Ye=0;Ye0?vt.parentIndex:null)}this.fillNonElevatedRoadSegment(Le)}}else for(let Le=0;Le0?Le:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,v,E,P,N,O,void 0,this.worldview)}computeSegNextDir(c,m){return c.nextPoint.sub(m.at(-2)).unit()}computeSegPrevDir(c,m){return m[1].sub(c.prevPoint).unit()}clipLinesToTile(c,m){return CO(c,-m,-m,Xs+m,Xs+m)}clipRuntimeLinesToTile(c,m){const v=[];return[CO(c,-m,-m,Xs+m,Xs+m,v),v]}addElevatedRoadFeature(c,m,v,N,E,P,O,B){const W=[],J=Xa.getElevationFeature(c,N);if(J){const ee=this.clipLinesToTile(m,1),ie=this.prepareElevatedLines(ee,J,v);for(const ce of ie)W.push({geometry:ce,elevation:J,elevationTileID:v,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(W.length===0)return!1;for(const ee of W){const ie=this.layoutVertexArray.length;this.addLine(ee.geometry,c,v,E,P,O,B);const ce=new fi(v,ee.elevationTileID);if(ee.elevation)for(let ue=ie;ue>1,this.layoutVertexArray.int16[6*ue+1]>>1),Le=ce.pointElevation(ke,ee.elevation,.05);this.updateHeightRange(Le),this.zOffsetVertexArray.emplaceBack(Le,0,0)}else this.fillNonElevatedRoadSegment(ie)}return!0}prepareElevatedLines(c,m,v){if(m.constantHeight!=null)return c;const N=[],E=1/Be(v);for(const P of c)Att(P,new Fa(m,E),0,N);return N}fillNonElevatedRoadSegment(c){for(let m=c;m0,ie=B&&B.progress.max<1;if(this.lineClips){let $t={min:this.lineClips.start,max:this.lineClips.end},ls=1;if(B){const bs=this.lineClips.end-this.lineClips.start;$t=function(ws,Os,Fs){return{min:vi(ws.min,Os,Fs),max:vi(ws.max,Os,Fs)}}(B.progress,{min:0,max:1},$t),bs>0&&(ls=($t.max-$t.min)/bs)}const Wt=+m.properties.mapbox_clip_feature_len,ms=+m.properties.mapbox_clip_seg_len;if(Number.isNaN(Wt)||Number.isNaN(ms)){for(let ws=0;ws=2&&c[ue-1].equals(c[ue-2]);)ue--;let ke=0;for(;ke0,hs=this.overscaling<=16?15*Xs/(512*this.overscaling):0;if(ls&&Wt==="round"){if(OsP&&(Wt="bevel"),Wt==="bevel"&&(Os>2&&(Wt="flipbevel"),Os2*hs){const Qs=Ie.sub(Ie.sub(Ke)._mult(hs/cs)._round());this.updateDistance(Ke,Qs),this.addCurrentVertex(Qs,at,0,0,Le,Lt),Ke=Qs}this.updateDistance(Ke,Ie),bs._mult(Os),this.addCurrentVertex(Ie,bs,0,0,Le,Lt);const Ds=Ie.dist(Ye);if(Ds>2*hs){const Qs=Ie.add(Ye.sub(Ie)._mult(hs/Ds)._round());this.updateDistance(Ie,Qs),this.addCurrentVertex(Qs,vt,0,0,Le,Lt),Ie=Qs}}else bs._mult(Os),this.addCurrentVertex(Ie,bs,0,0,Le,Lt);else if(Wt==="flipbevel"){if(Os>100)bs=vt.mult(-1);else{const cs=Os*at.add(vt).mag()/at.sub(vt).mag();bs._perp()._mult(cs*(Ls?-1:1))}this.addCurrentVertex(Ie,bs,0,0,Le,Lt),this.addCurrentVertex(Ie,bs.mult(-1),0,0,Le,Lt)}else if(Wt==="bevel"||Wt==="fakeround"){Lt!=null&&Ke&&this.addCurrentVertex(Ie,kt||at,-1,-1,Le,Lt);const cs=Ie.dist(Ke)<=2*hs&&Wt!=="bevel",Ds=bs.mult(Ls?1:-1);Ds._mult(Os);const Qs=vt.mult(Ls?-1:1),Vs=at.mult(Ls?-1:1),Dr=this.evaluateLineProgressFeatures(this.distance);if(Lt==null&&(this.addHalfVertex(Ie,Ds.x,Ds.y,!1,!Ls,0,Le,Dr),cs||this.addHalfVertex(Ie,Ds.x+2*Vs.x,Ds.y+2*Vs.y,!1,Ls,0,Le,Dr)),Wt==="fakeround"){const dr=Math.round(180*Fs/Math.PI/20);this.addHalfVertex(Ie,Vs.x,Vs.y,!1,Ls,0,Le,Dr);for(let yr=0;yr1){this.lineSoFar=c.w;const ke=(m.x-c.x)/ee,Le=(m.y-c.y)/ee,Ie=(m.z-c.z)/ee,Ke=(m.w-c.w)/ee;for(let Ye=1;Ye=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,J),B.primitiveLength++),P?this.e2=J:this.e1=J,W!=null&&this.zOffsetVertexArray.emplaceBack(W.zOffset,W.variableWidth,W.variableWidth)}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(c,m){this.prevDistance=this.distance,this.distance+=c.dist(m),this.updateScaledDistance()}}function iue(g,c,m){return g.xm||g.ym}let RNe,FNe;function zNe(g,c,m){return c*(Xs/(g.tileSize*Math.pow(2,m-g.tileID.overscaledZ)))}_r(aue,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const BNe=(g,c,m)=>(1-m)*g+m*c;function $Ne(g,c){return 1/zNe(g,1,c.tileZoom)}function qNe(g,c,m,v){return g.translatePosMatrix(v||c.tileID.projMatrix,c,m.paint.get("line-translate"),m.paint.get("line-translate-anchor"))}const UNe=g=>{const c=[];VNe(g)&&c.push("RENDER_LINE_DASH"),g.paint.get("line-gradient")&&c.push("RENDER_LINE_GRADIENT");const m=g.paint.get("line-trim-offset");m[0]===0&&m[1]===0||c.push("RENDER_LINE_TRIM_OFFSET"),g.paint.get("line-border-width").constantOr(1)!==0&&c.push("RENDER_LINE_BORDER");const v=g.layout.get("line-join").constantOr("miter")==="none",N=!!g.paint.get("line-pattern").constantOr(1);return v&&N&&c.push("LINE_JOIN_NONE"),c};function VNe(g){const c=g.paint.get("line-dasharray").value;return c.kind!=="constant"||c.value}let oue;const HNe=()=>oue||(oue={layout:RNe||(RNe=new wo({"line-cap":new nr(Gt.layout_line["line-cap"]),"line-join":new nr(Gt.layout_line["line-join"]),"line-miter-limit":new Gs(Gt.layout_line["line-miter-limit"]),"line-round-limit":new Gs(Gt.layout_line["line-round-limit"]),"line-sort-key":new nr(Gt.layout_line["line-sort-key"]),"line-z-offset":new nr(Gt.layout_line["line-z-offset"]),"line-elevation-reference":new Gs(Gt.layout_line["line-elevation-reference"]),"line-cross-slope":new Gs(Gt.layout_line["line-cross-slope"]),visibility:new Gs(Gt.layout_line.visibility),"line-width-unit":new Gs(Gt.layout_line["line-width-unit"])})),paint:FNe||(FNe=new wo({"line-opacity":new nr(Gt.paint_line["line-opacity"]),"line-color":new nr(Gt.paint_line["line-color"]),"line-translate":new Gs(Gt.paint_line["line-translate"]),"line-translate-anchor":new Gs(Gt.paint_line["line-translate-anchor"]),"line-width":new nr(Gt.paint_line["line-width"]),"line-gap-width":new nr(Gt.paint_line["line-gap-width"]),"line-offset":new nr(Gt.paint_line["line-offset"]),"line-blur":new nr(Gt.paint_line["line-blur"]),"line-dasharray":new nr(Gt.paint_line["line-dasharray"]),"line-pattern":new nr(Gt.paint_line["line-pattern"]),"line-pattern-cross-fade":new Gs(Gt.paint_line["line-pattern-cross-fade"]),"line-gradient":new By(Gt.paint_line["line-gradient"]),"line-trim-offset":new Gs(Gt.paint_line["line-trim-offset"]),"line-trim-fade-range":new Gs(Gt.paint_line["line-trim-fade-range"]),"line-trim-color":new Gs(Gt.paint_line["line-trim-color"]),"line-emissive-strength":new nr(Gt.paint_line["line-emissive-strength"]),"line-border-width":new nr(Gt.paint_line["line-border-width"]),"line-border-color":new nr(Gt.paint_line["line-border-color"]),"line-occlusion-opacity":new Gs(Gt.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"})}))},oue);class bst extends nr{possiblyEvaluate(c,m){return m=new Fi(Math.floor(m.zoom),{now:m.now,fadeDuration:m.fadeDuration,transition:m.transition,worldview:m.worldview}),super.possiblyEvaluate(c,m)}evaluate(c,m,v,N){return m=Object.assign({},m,{zoom:Math.floor(m.zoom)}),super.evaluate(c,m,v,N)}}let wA;function WNe(g,c){return c>0?c+2*g:g}const wst=oa([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),jst=oa([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Nst=oa([{name:"a_projected_pos",components:4,type:"Float32"}],4);oa([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const kst=oa([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Sst=oa([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),Cst=oa([{name:"a_texb",components:2,type:"Uint16"}]),Mst=oa([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Tst=oa([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);oa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const GNe=oa([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ast=oa([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);oa([{name:"triangle",components:3,type:"Uint16"}]),oa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),oa([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"},{type:"Uint16",name:"elevationFeatureIndex"}]),oa([{type:"Float32",name:"offsetX"}]),oa([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var lc=24;function Est(g,c,m){return g.sections.forEach(v=>{v.text=function(N,E,P){const O=E.layout.get("text-transform").evaluate(P,{});return O==="uppercase"?N=N.toLocaleUpperCase():O==="lowercase"&&(N=N.toLocaleLowerCase()),Xf.applyArabicShaping&&(N=Xf.applyArabicShaping(N)),N}(v.text,c,m)}),g}const jA={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Pst(g){return g==="︶"||g==="﹈"||g==="︸"||g==="﹄"||g==="﹂"||g==="︾"||g==="︼"||g==="︺"||g==="︘"||g==="﹀"||g==="︐"||g==="︓"||g==="︔"||g==="`"||g===" ̄"||g==="︑"||g==="︒"}function Ist(g){return g==="︵"||g==="﹇"||g==="︷"||g==="﹃"||g==="﹁"||g==="︽"||g==="︻"||g==="︹"||g==="︗"||g==="︿"}const lue=4294967296,KNe=1/lue,ZNe=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let FO=class{constructor(g=new Uint8Array(16)){this.buf=ArrayBuffer.isView(g)?g:new Uint8Array(g),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(g,c,m=this.length){for(;this.pos>3,E=this.pos;this.type=7&v,g(N,c,this),this.pos===E&&this.skip(v)}return c}readMessage(g,c){return this.readFields(g,c,this.readVarint()+this.pos)}readFixed32(){const g=this.dataView.getUint32(this.pos,!0);return this.pos+=4,g}readSFixed32(){const g=this.dataView.getInt32(this.pos,!0);return this.pos+=4,g}readFixed64(){const g=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*lue;return this.pos+=8,g}readSFixed64(){const g=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*lue;return this.pos+=8,g}readFloat(){const g=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,g}readDouble(){const g=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,g}readVarint(g){const c=this.buf;let m,v;return v=c[this.pos++],m=127&v,v<128?m:(v=c[this.pos++],m|=(127&v)<<7,v<128?m:(v=c[this.pos++],m|=(127&v)<<14,v<128?m:(v=c[this.pos++],m|=(127&v)<<21,v<128?m:(v=c[this.pos],m|=(15&v)<<28,function(N,E,P){const O=P.buf;let B,W;if(W=O[P.pos++],B=(112&W)>>4,W<128||(W=O[P.pos++],B|=(127&W)<<3,W<128)||(W=O[P.pos++],B|=(127&W)<<10,W<128)||(W=O[P.pos++],B|=(127&W)<<17,W<128)||(W=O[P.pos++],B|=(127&W)<<24,W<128)||(W=O[P.pos++],B|=(1&W)<<31,W<128))return RC(N,B,E);throw new Error("Expected varint not more than 10 bytes")}(m,g,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const g=this.readVarint();return g%2==1?(g+1)/-2:g/2}readBoolean(){return!!this.readVarint()}readString(){const g=this.readVarint()+this.pos,c=this.pos;return this.pos=g,g-c>=12&&ZNe?ZNe.decode(this.buf.subarray(c,g)):function(m,v,N){let E="",P=v;for(;P239?4:O>223?3:O>191?2:1;if(P+ie>N)break;ie===1?O<128&&(ee=O):ie===2?(B=m[P+1],(192&B)==128&&(ee=(31&O)<<6|63&B,ee<=127&&(ee=null))):ie===3?(B=m[P+1],W=m[P+2],(192&B)==128&&(192&W)==128&&(ee=(15&O)<<12|(63&B)<<6|63&W,(ee<=2047||ee>=55296&&ee<=57343)&&(ee=null))):ie===4&&(B=m[P+1],W=m[P+2],J=m[P+3],(192&B)==128&&(192&W)==128&&(192&J)==128&&(ee=(15&O)<<18|(63&B)<<12|(63&W)<<6|63&J,(ee<=65535||ee>=1114112)&&(ee=null))),ee===null?(ee=65533,ie=1):ee>65535&&(ee-=65536,E+=String.fromCharCode(ee>>>10&1023|55296),ee=56320|1023&ee),E+=String.fromCharCode(ee),P+=ie}return E}(this.buf,c,g)}readBytes(){const g=this.readVarint()+this.pos,c=this.buf.subarray(this.pos,g);return this.pos=g,c}readPackedVarint(g=[],c){const m=this.readPackedEnd();for(;this.pos127;);else if(c===2)this.pos=this.readVarint()+this.pos;else if(c===5)this.pos+=4;else{if(c!==1)throw new Error(`Unimplemented type: ${c}`);this.pos+=8}}writeTag(g,c){this.writeVarint(g<<3|c)}realloc(g){let c=this.length||16;for(;c268435455||g<0?function(c,m){let v,N;if(c>=0?(v=c%4294967296|0,N=c/4294967296|0):(v=~(-c%4294967296),N=~(-c/4294967296),4294967295^v?v=v+1|0:(v=0,N=N+1|0)),c>=18446744073709552e3||c<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");m.realloc(10),function(E,P,O){O.buf[O.pos++]=127&E|128,E>>>=7,O.buf[O.pos++]=127&E|128,E>>>=7,O.buf[O.pos++]=127&E|128,E>>>=7,O.buf[O.pos++]=127&E|128,O.buf[O.pos]=127&(E>>>=7)}(v,0,m),function(E,P){const O=(7&E)<<4;P.buf[P.pos++]|=O|((E>>>=3)?128:0),E&&(P.buf[P.pos++]=127&E|((E>>>=7)?128:0),E&&(P.buf[P.pos++]=127&E|((E>>>=7)?128:0),E&&(P.buf[P.pos++]=127&E|((E>>>=7)?128:0),E&&(P.buf[P.pos++]=127&E|((E>>>=7)?128:0),E&&(P.buf[P.pos++]=127&E)))))}(N,m)}(g,this):(this.realloc(4),this.buf[this.pos++]=127&g|(g>127?128:0),g<=127||(this.buf[this.pos++]=127&(g>>>=7)|(g>127?128:0),g<=127||(this.buf[this.pos++]=127&(g>>>=7)|(g>127?128:0),g<=127||(this.buf[this.pos++]=g>>>7&127))))}writeSVarint(g){this.writeVarint(g<0?2*-g-1:2*g)}writeBoolean(g){this.writeVarint(+g)}writeString(g){g=String(g),this.realloc(4*g.length),this.pos++;const c=this.pos;this.pos=function(v,N,E){for(let P,O,B=0;B55295&&P<57344){if(!O){P>56319||B+1===N.length?(v[E++]=239,v[E++]=191,v[E++]=189):O=P;continue}if(P<56320){v[E++]=239,v[E++]=191,v[E++]=189,O=P;continue}P=O-55296<<10|P-56320|65536,O=null}else O&&(v[E++]=239,v[E++]=191,v[E++]=189,O=null);P<128?v[E++]=P:(P<2048?v[E++]=P>>6|192:(P<65536?v[E++]=P>>12|224:(v[E++]=P>>18|240,v[E++]=P>>12&63|128),v[E++]=P>>6&63|128),v[E++]=63&P|128)}return E}(this.buf,g,this.pos);const m=this.pos-c;m>=128&&YNe(c,m,this),this.pos=c-1,this.writeVarint(m),this.pos+=m}writeFloat(g){this.realloc(4),this.dataView.setFloat32(this.pos,g,!0),this.pos+=4}writeDouble(g){this.realloc(8),this.dataView.setFloat64(this.pos,g,!0),this.pos+=8}writeBytes(g){const c=g.length;this.writeVarint(c),this.realloc(c);for(let m=0;m=128&&YNe(m,v,this),this.pos=m-1,this.writeVarint(v),this.pos+=v}writeMessage(g,c,m){this.writeTag(g,2),this.writeRawMessage(c,m)}writePackedVarint(g,c){c.length&&this.writeMessage(g,Lst,c)}writePackedSVarint(g,c){c.length&&this.writeMessage(g,Dst,c)}writePackedBoolean(g,c){c.length&&this.writeMessage(g,Fst,c)}writePackedFloat(g,c){c.length&&this.writeMessage(g,Ost,c)}writePackedDouble(g,c){c.length&&this.writeMessage(g,Rst,c)}writePackedFixed32(g,c){c.length&&this.writeMessage(g,zst,c)}writePackedSFixed32(g,c){c.length&&this.writeMessage(g,Bst,c)}writePackedFixed64(g,c){c.length&&this.writeMessage(g,$st,c)}writePackedSFixed64(g,c){c.length&&this.writeMessage(g,qst,c)}writeBytesField(g,c){this.writeTag(g,2),this.writeBytes(c)}writeFixed32Field(g,c){this.writeTag(g,5),this.writeFixed32(c)}writeSFixed32Field(g,c){this.writeTag(g,5),this.writeSFixed32(c)}writeFixed64Field(g,c){this.writeTag(g,1),this.writeFixed64(c)}writeSFixed64Field(g,c){this.writeTag(g,1),this.writeSFixed64(c)}writeVarintField(g,c){this.writeTag(g,0),this.writeVarint(c)}writeSVarintField(g,c){this.writeTag(g,0),this.writeSVarint(c)}writeStringField(g,c){this.writeTag(g,2),this.writeString(c)}writeFloatField(g,c){this.writeTag(g,5),this.writeFloat(c)}writeDoubleField(g,c){this.writeTag(g,1),this.writeDouble(c)}writeBooleanField(g,c){this.writeVarintField(g,+c)}};function RC(g,c,m){return m?4294967296*c+(g>>>0):4294967296*(c>>>0)+(g>>>0)}function YNe(g,c,m){const v=c<=16383?1:c<=2097151?2:c<=268435455?3:Math.floor(Math.log(c)/(7*Math.LN2));m.realloc(v);for(let N=m.pos-1;N>=g;N--)m.buf[N+v]=m.buf[N]}function Lst(g,c){for(let m=0;m=0&&v>=c&&zO[this.text.charCodeAt(v)];v--)m--;this.text=this.text.substring(c,m),this.sectionIndex=this.sectionIndex.slice(c,m)}substring(c,m){const v=new FC;return v.text=this.text.substring(c,m),v.sectionIndex=this.sectionIndex.slice(c,m),v.sections=this.sections,v}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((c,m)=>Math.max(c,this.sections[m].scale),0)}addTextSection(c,m){this.text+=c.text,this.sections.push(NA.forText(c.scale,c.fontStack||m));const v=this.sections.length-1;for(let N=0;N=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function due(g,c,m,v,N,E,P,O,B,W,J,ee,ie,ce,ue,ke=1){const Le=FC.fromFeature(g,N,ke);ee===kh.vertical&&Le.verticalizePunctuation(ie);let Ie=[];const Ke=function(kt,Lt,$t,ls,Wt,ms){if(!kt)return[];const bs=[],ws=function(Ls,hs,cs,Ds,Qs,Vs){let Dr=0;for(let dr=0;dr=0;let Fs=0;for(let Ls=0;Ls0&&Ba>Ln&&(Ln=Ba)}else{const Ia=$t[Rs.fontStack];if(!Ia)continue;Ia[or]&&(Sn=Ia[or]);const za=Lt[Rs.fontStack];if(!za)continue;const Ba=za.glyphs[or];if(!Ba)continue;if(zr=Ba.metrics,Vn=or!==8203?lc:0,Vs){const li=za.ascender!==void 0?Math.abs(za.ascender):0,ki=za.descender!==void 0?Math.abs(za.descender):0,bi=(li+ki)*Or;_i-m/2;){if(P--,P<0)return!1;O-=g[P].dist(E),E=g[P]}O+=g[P].dist(g[P+1]),P++;const B=[];let W=0;for(;Ov;)W-=B.shift().angleDelta;if(W>N)return!1;P++,O+=J.dist(ee)}return!0}function oke(g){let c=0;for(let m=0;mW){const ue=(W-B)/ce,ke=Hr(ee.x,ie.x,ue),Le=Hr(ee.y,ie.y,ue),Ie=new Ky(ke,Le,0,ie.angleTo(ee),J);return!P||ike(g,Ie,O,P,c)?Ie:void 0}B+=ce}}function Zst(g,c,m,v,N,E,P,O,B){const W=lke(v,E,P),J=cke(v,N),ee=J*P,ie=g[0].x===0||g[0].x===B||g[0].y===0||g[0].y===B;return c-ee=0&&at=0&&vt=0&&ie+W<=J){const pt=new Ky(at,vt,0,Ke,ue);v&&!ike(g,pt,E,v,N)||ce.push(pt)}}ee+=Ie}return O||ce.length||P||(ce=dke(g,ee/2,m,v,N,E,P,!0,B)),ce}function uke(g){let c=0,m=0;for(const P of g)c+=P.w*P.h,m=Math.max(m,P.w);g.sort((P,O)=>O.h-P.h);const v=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(c/.95)),m),h:1/0}];let N=0,E=0;for(const P of g)for(let O=v.length-1;O>=0;O--){const B=v[O];if(!(P.w>B.w||P.h>B.h)){if(P.x=B.x,P.y=B.y,E=Math.max(E,P.y+P.h),N=Math.max(N,P.x+P.w),P.w===B.w&&P.h===B.h){const W=v.pop();W&&O1?ue-1:ue,xd.copy(ee.data,W,{x:0,y:0},{x:ke,y:Le},ee.data,v),xd.copy(ee.data,W,{x:0,y:Ke-ue},{x:ke,y:Le-ue},{width:Ie,height:ue},v),xd.copy(ee.data,W,{x:0,y:0},{x:ke,y:Le+Ke},{width:Ie,height:ue},v),xd.copy(ee.data,W,{x:Ie-ue,y:0},{x:ke-ue,y:Le},{width:ue,height:Ke},v),xd.copy(ee.data,W,{x:0,y:0},{x:ke+Ie,y:Le},{width:ue,height:Ke},v),xd.copy(ee.data,W,{x:Ie-ue,y:Ke-ue},{x:ke-ue,y:Le-ue},{width:ue,height:ue},v),xd.copy(ee.data,W,{x:0,y:Ke-ue},{x:ke+Ie,y:Le-ue},{width:ue,height:ue},v),xd.copy(ee.data,W,{x:0,y:0},{x:ke+Ie,y:Le+Ke},{width:ue,height:ue},v),xd.copy(ee.data,W,{x:Ie-ue,y:0},{x:ke-ue,y:Le+Ke},{width:ue,height:ue},v)}this.lut=v,this.image=W,this.iconPositions=N,this.patternPositions=E}addImages(c,m,v,N){for(const[E,P]of c.entries()){const{bin:O,imagePosition:B,imageVariant:W}=fue(E,P,v);m.set(E,B),N.push(O),P.hasRenderCallback&&this.haveRenderCallbacks.push(W.id)}}patchUpdatedImages(c,m,v){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(N=>c.hasImage(N,v)),c.dispatchRenderCallbacks(this.haveRenderCallbacks,v);for(const N of c.getUpdatedImages(v)){for(const E of this.iconPositions.keys()){const P=Vf.parse(E);if(Ks.isEqual(P.id,N)){const O=c.getImage(N,v);this.patchUpdatedImage(this.iconPositions.get(E),O,m,null)}}for(const E of this.patternPositions.keys()){const P=Vf.parse(E);if(Ks.isEqual(P.id,N)){const O=c.getImage(N,v);this.patchUpdatedImage(this.patternPositions.get(E),O,m,this.lut)}}}}patchUpdatedImage(c,m,v,N=null){if(!c||!m||c.version===m.version)return;c.version=m.version;const[E,P]=c.tl,O=c.sdf;if(this.lut||O){const B={width:m.data.width,height:m.data.height},W=new xd(B);xd.copy(m.data,W,{x:0,y:0},{x:0,y:0},B,N,O),v.update(W,{position:{x:E,y:P}})}else v.update(m.data,{position:{x:E,y:P}})}}_r(kA,"ImagePosition"),_r(hke,"ImageAtlas");const SA=1e20;function mke(g,c,m,v,N,E,P,O,B){for(let W=c;W-1);B++,E[B]=O,P[B]=W,P[B+1]=SA}for(let O=0,B=0;O{let B=this.entries[E];B||(B=this.entries[E]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let W=B.glyphs[P];if(W!==void 0)return void O(null,{stack:E,id:P,glyph:W});if(W=this._tinySDF(B,E,P),W)return B.glyphs[P]=W,void O(null,{stack:E,id:P,glyph:W});const J=Math.floor(P/256);if(256*J>65535)return ur("glyphs > 65535 not supported"),void O(null,{stack:E,id:P,glyph:W});if(B.ranges[J])return void O(null,{stack:E,id:P,glyph:W});let ee=B.requests[J];ee||(ee=B.requests[J]=[],$C.loadGlyphRange(E,J,N,this.requestManager,(ie,ce)=>{if(ce){B.ascender=ce.ascender,B.descender=ce.descender;for(const ue in ce.glyphs)this._doesCharSupportLocalGlyph(+ue)||(B.glyphs[+ue]=ce.glyphs[+ue]);B.ranges[J]=!0}for(const ue of ee)ue(ie,ce);delete B.requests[J]})),ee.push((ie,ce)=>{ie?O(ie):ce&&O(null,{stack:E,id:P,glyph:ce.glyphs[P]||null})})},(E,P)=>{if(E)m(E);else if(P){const O={};for(const{stack:B,id:W,glyph:J}of P)O[B]===void 0&&(O[B]={}),O[B].glyphs===void 0&&(O[B].glyphs={}),O[B].glyphs[W]=J&&{id:J.id,bitmap:J.bitmap.clone(),metrics:J.metrics},O[B].ascender=this.entries[B].ascender,O[B].descender=this.entries[B].descender;m(null,O)}})}_doesCharSupportLocalGlyph(c){return this.localGlyphMode!==gue.none&&(this.localGlyphMode===gue.all?!!this.localFontFamily:!!this.localFontFamily&&(Zr["CJK Unified Ideographs"](c)||Zr["Hangul Syllables"](c)||Zr.Hiragana(c)||Zr.Katakana(c)||Zr["CJK Symbols and Punctuation"](c)||Zr["CJK Unified Ideographs Extension A"](c)||Zr["CJK Unified Ideographs Extension B"](c)||Zr.Osage(c)))}_tinySDF(c,m,v){const N=this.localFontFamily;if(!N||!this._doesCharSupportLocalGlyph(v))return;let E=c.tinySDF;if(!E){let ke="400";/bold/i.test(m)?ke="900":/medium/i.test(m)?ke="500":/light/i.test(m)&&(ke="200"),E=c.tinySDF=new $C.TinySDF({fontFamily:N,fontWeight:ke,fontSize:24*lg,buffer:3*lg,radius:8*lg}),E.fontWeight=ke}if(this.localGlyphs[E.fontWeight][v])return this.localGlyphs[E.fontWeight][v];const P=String.fromCodePoint(v),{data:O,width:B,height:W,glyphWidth:J,glyphHeight:ee,glyphLeft:ie,glyphTop:ce,glyphAdvance:ue}=E.draw(P);return this.localGlyphs[E.fontWeight][v]={id:v,bitmap:new Wv({width:B,height:W},O),metrics:{width:J/lg,height:ee/lg,left:ie/lg,top:ce/lg-27,advance:ue/lg,localGlyph:!0}}}}$C.loadGlyphRange=function(g,c,m,v,N){const E=256*c,P=E+255,O=v.transformRequest(v.normalizeGlyphsURL(m).replace("{fontstack}",g).replace("{range}",`${E}-${P}`),$f.Glyphs);Vu(O,(B,W)=>{if(B)N(B);else if(W){const J={},ee=function(ie){return new FO(ie).readFields(Ust,{})}(W);for(const ie of ee.glyphs)J[ie.id]=ie;N(null,{glyphs:J,ascender:ee.ascender,descender:ee.descender})}})},$C.TinySDF=class{constructor({fontSize:g=24,buffer:c=3,radius:m=8,cutoff:v=.25,fontFamily:N="sans-serif",fontWeight:E="normal",fontStyle:P="normal",lang:O=null}={}){this.buffer=c,this.cutoff=v,this.radius=m,this.lang=O;const B=this.size=g+4*c,W=this._createCanvas(B),J=this.ctx=W.getContext("2d",{willReadFrequently:!0});J.font=`${P} ${E} ${g}px ${N}`,J.textBaseline="alphabetic",J.textAlign="left",J.fillStyle="black",this.gridOuter=new Float64Array(B*B),this.gridInner=new Float64Array(B*B),this.f=new Float64Array(B),this.z=new Float64Array(B+1),this.v=new Uint16Array(B)}_createCanvas(g){const c=document.createElement("canvas");return c.width=c.height=g,c}draw(g){const{width:c,actualBoundingBoxAscent:m,actualBoundingBoxDescent:v,actualBoundingBoxLeft:N,actualBoundingBoxRight:E}=this.ctx.measureText(g),P=Math.ceil(m),O=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(E-N))),B=Math.min(this.size-this.buffer,P+Math.ceil(v)),W=O+2*this.buffer,J=B+2*this.buffer,ee=Math.max(W*J,0),ie=new Uint8ClampedArray(ee),ce={data:ie,width:W,height:J,glyphWidth:O,glyphHeight:B,glyphTop:P,glyphLeft:0,glyphAdvance:c};if(O===0||B===0)return ce;const{ctx:ue,buffer:ke,gridInner:Le,gridOuter:Ie}=this;this.lang&&(ue.lang=this.lang),ue.clearRect(ke,ke,O,B),ue.fillText(g,ke,ke+P);const Ke=ue.getImageData(ke,ke,O,B);Ie.fill(SA,0,ee),Le.fill(0,0,ee);for(let Ye=0;Ye0?kt*kt:0,Le[pt]=kt<0?kt*kt:0}}mke(Ie,0,0,W,J,W,this.f,this.v,this.z),mke(Le,ke,ke,O,B,W,this.f,this.v,this.z);for(let Ye=0;Ye{const Os=qO(Wt.stretch-Ke,Ye,J,g.left*N),Fs=UO(Wt.fixed-pt,kt,Wt.stretch,ue),Ps=qO(ms.stretch-at,vt,ee,g.top*N),Ls=UO(ms.fixed-Lt,$t,ms.stretch,ke),hs=qO(bs.stretch-Ke,Ye,J,g.left*N),cs=UO(bs.fixed-pt,kt,bs.stretch,ue),Ds=qO(ws.stretch-at,vt,ee,g.top*N),Qs=UO(ws.fixed-Lt,$t,ws.stretch,ke),Vs=new es(Os,Ps),Dr=new es(hs,Ps),dr=new es(hs,Ds),yr=new es(Os,Ds),kr=new es(Fs/O,Ls/O),Hn=new es(cs/O,Qs/O),Ws=c*Math.PI/180;if(Ws){const _i=Math.sin(Ws),ft=Math.cos(Ws),_t=[ft,-_i,_i,ft];Vs._matMult(_t),Dr._matMult(_t),yr._matMult(_t),dr._matMult(_t)}const Sr=Wt.stretch+Wt.fixed,mn=bs.stretch+bs.fixed,fa=ms.stretch+ms.fixed,va=ws.stretch+ws.fixed,Ln=g.imageSecondary;return{tl:Vs,tr:Dr,bl:yr,br:dr,texPrimary:{x:P.paddedRect.x+kx+Sr,y:P.paddedRect.y+kx+fa,w:mn-Sr,h:va-fa},texSecondary:Ln?{x:Ln.paddedRect.x+kx+Sr,y:Ln.paddedRect.y+kx+fa,w:mn-Sr,h:va-fa}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:kr,pixelOffsetBR:Hn,minFontScaleX:kt/O/J,minFontScaleY:$t/O/ee,isSDF:m}};if(v&&(P.stretchX||P.stretchY)){const Wt=gke(ie,Le,ue),ms=gke(ce,Ie,ke);for(let bs=0;bsE)&&(E=ue.x),(!ce||ue.y>P)&&(P=ue.y)}const B=Math.min(E-v,P-N);let W=B/2;const J=new ES([],Jst);if(B===0)return new es(v,N);for(let ce=v;ceee.d||!ee.d)&&(ee=ce,m&&console.log("found best %d after %d probes",Math.round(1e4*ce.d)/1e4,ie)),ce.max-ee.d<=c||(W=ce.h/2,J.push(new qC(ce.p.x-W,ce.p.y-W,W,g)),J.push(new qC(ce.p.x+W,ce.p.y-W,W,g)),J.push(new qC(ce.p.x-W,ce.p.y+W,W,g)),J.push(new qC(ce.p.x+W,ce.p.y+W,W,g)),ie+=4)}return m&&(console.log(`num probes: ${ie}`),console.log(`best distance: ${ee.d}`)),ee.p}function Jst(g,c){return c.max-g.max}class qC{constructor(c,m,v,N){this.p=new es(c,m),this.h=v,this.d=function(E,P){let O=!1,B=1/0;for(let W=0;WE.y!=ke.y>E.y&&E.x<(ke.x-ue.x)*(E.y-ue.y)/(ke.y-ue.y)+ue.x&&(O=!O),B=Math.min(B,Ao(E,ue,ke))}}return(O?1:-1)*Math.sqrt(B)}(this.p,N),this.max=this.d+this.h*Math.SQRT2}}const ert=Object.keys,yue=Number.POSITIVE_INFINITY,trt=Math.sqrt(2);function Kv(g,c,m,v,N){const E=hue(g)&&g.collisionPadding?g.collisionPadding:[0,0,0,0],P={top:g.top-E[1],bottom:g.bottom+E[3],left:g.left-E[0],right:g.right+E[2],scaled:!1};return v!==void 0&&function(O,B){O.top*=B,O.bottom*=B,O.left*=B,O.right*=B,O.scaled=!0}(P,v),m&&function(O,B){if(!B)return;const W=Ir(B),J=new es(O.left,O.top),ee=new es(O.right,O.top),ie=new es(O.left,O.bottom),ce=new es(O.right,O.bottom),ue=new es(0,0);J._rotateAround(W,ue),ee._rotateAround(W,ue),ie._rotateAround(W,ue),ce._rotateAround(W,ue),O.left=Math.min(J.x,ee.x,ie.x,ce.x),O.right=Math.max(J.x,ee.x,ie.x,ce.x),O.top=Math.min(J.y,ee.y,ie.y,ce.y),O.bottom=Math.max(J.y,ee.y,ie.y,ce.y)}(P,m),N&&(P.left+=N[0],P.right+=N[0],P.top+=N[1],P.bottom+=N[1]),c?{top:Math.min(c.top,P.top),bottom:Math.max(c.bottom,P.bottom),left:Math.min(c.left,P.left),right:Math.max(c.right,P.right),scaled:c.scaled||P.scaled}:P}function yke(g,[c,m]){let v=0,N=0;if(m===yue){c<0&&(c=0);const E=c/trt;switch(g){case"top-right":case"top-left":N=E-7;break;case"bottom-right":case"bottom-left":N=7-E;break;case"bottom":N=7-c;break;case"top":N=c-7}switch(g){case"top-right":case"bottom-right":v=-E;break;case"top-left":case"bottom-left":v=E;break;case"left":v=c;break;case"right":v=-c}}else{switch(c=Math.abs(c),m=Math.abs(m),g){case"top-right":case"top-left":case"top":N=m-7;break;case"bottom-right":case"bottom-left":case"bottom":N=7-m}switch(g){case"top-right":case"bottom-right":case"right":v=-c;break;case"top-left":case"bottom-left":case"left":v=c}}return[v,N]}function srt(g,c,m,v,N,E,P,O,B,W,J,ee,ie,ce){const ue=g.layers[0],ke=ue.appearances;if(ke.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const Le={iconBBox:null,iconVerticalBBox:null},Ie={textBBox:null,textVerticalBBox:null},{baseIconRotate:Ke,baseTextRotate:Ye,iconScaleFactor:at}=function(pt,kt,Lt){const $t=pt.get("icon-rotate").evaluate(kt,{},Lt),ls=pt.get("text-rotate").evaluate(kt,{},Lt),[Wt,ms]=pt.get("icon-size-scale-range");return{baseIconRotate:$t,baseTextRotate:ls,iconScaleFactor:ye(1,Wt,ms)}}(v,N,E);c&&(Le.iconBBox=Kv(c,Le.iconBBox,Ke,P),m)&&(Le.iconVerticalBBox=Kv(m,Le.iconVerticalBBox,Ke+90,P));const vt=HO(ee.horizontal);vt&&(Ie.textBBox=Kv(vt,Ie.textBBox,Ye,1,ce)),ee.vertical&&(Ie.textVerticalBBox=Kv(ee.vertical,Ie.textVerticalBBox,Ye+90,1,ce));for(const pt of ke)pt.hasIconProperties()&&rrt(Le,g,ue,pt,N,E,O,Ke,P,B,c,W,at,J),pt.hasTextProperties()&&nrt(Ie,ue,pt,N,E,ce,Ye,ie,vt,ee.vertical);return{iconBBox:Le.iconBBox,iconVerticalBBox:Le.iconVerticalBBox,textBBox:Ie.textBBox,textVerticalBBox:Ie.textVerticalBBox}}function rrt(g,c,m,v,N,E,P,O,B,W,J,ee,ie,ce){const{appearanceIconOffset:ue,appearanceIconRotate:ke,appearanceIconSize:Le}=function(at,vt,pt,kt,Lt,$t,ls,Wt){const ms=at.hasProperty("icon-offset")?vt.getAppearanceValueAndResolveTokens(at,"icon-offset",pt,kt,[]):null,bs=ms&&Array.isArray(ms)?ms:Lt,ws=at.hasProperty("icon-rotate")?vt.getAppearanceValueAndResolveTokens(at,"icon-rotate",pt,kt,[]):null,Os=typeof ws=="number"?ws:$t,Fs=at.hasProperty("icon-size")?vt.getAppearanceValueAndResolveTokens(at,"icon-size",pt,kt,[]):null;return{appearanceIconOffset:bs,appearanceIconRotate:Os,appearanceIconSize:typeof Fs=="number"?Fs*Wt.iconScaleFactor:ls}}(v,m,N,E,P,O,B,W);let Ie=null,Ke=null,Ye=null;v.hasProperty("icon-image")?Ye=function(at,vt,pt,kt,Lt,$t,ls){let Wt=null;const ms=vt.getAppearanceValueAndResolveTokens(pt,"icon-image",kt,Lt,[]);if(ms){const bs=at.getResolvedImageFromTokens(ms),ws=pt.getUnevaluatedProperty("icon-size"),Os=CA(bs,zC(at.zoom,ws,at.worldview),ws,Lt,at.zoom,kt,at.pixelRatio,ls,at.worldview);Wt=$t.get(Os.iconPrimary.toString())}return Wt}(c,m,v,N,E,ee,ie):J&&(Ye=J.imagePrimary),Ye&&(Ie=BO(Ye,null,ue,ce),c.allowVerticalPlacement&&(Ke=BO(Ye,null,ue,ce))),Ie&&(g.iconBBox=Kv(Ie,g.iconBBox,ke,Le)),Ke&&(g.iconVerticalBBox=Kv(Ke,g.iconVerticalBBox,ke+90,Le))}function nrt(g,c,m,v,N,E,P,O,B,W){const{appearanceTextOffset:J,appearanceTextRotate:ee,appearanceTextSize:ie}=function(ue,ke,Le,Ie,Ke,Ye,at){const vt=ue.hasProperty("text-offset")?ke.getAppearanceValueAndResolveTokens(ue,"text-offset",Le,Ie,[]):null,pt=vt&&Array.isArray(vt)?[vt[0]*lc,vt[1]*lc]:Ke,kt=ue.hasProperty("text-rotate")?ke.getAppearanceValueAndResolveTokens(ue,"text-rotate",Le,Ie,[]):null,Lt=typeof kt=="number"?kt:Ye,$t=ue.hasProperty("text-size")?ke.getAppearanceValueAndResolveTokens(ue,"text-size",Le,Ie,[]):null;return{appearanceTextOffset:pt,appearanceTextRotate:Lt,appearanceTextSize:typeof $t=="number"?$t:at}}(m,c,v,N,E,P,O),ce=ie/O;B&&(g.textBBox=Kv(B,g.textBBox,ee,ce,J)),W&&(g.textVerticalBBox=Kv(W,g.textVerticalBBox,ee+90,ce,J))}function VO(g,c,m,v,N,E,P,O,B){if(!c||!c.usvg)return;const W=ake(v),J=ake(N),ee=E!=="both"&&E!=="width"||!rke(v)?1:J.width/W.width,ie=E!=="both"&&E!=="height"||!nke(v)?1:J.height/W.height;m.scaleSelf(ee,ie);const ce=m.toString();P.set(ce,m),O.set(ce,c);const{imagePosition:ue}=fue(ce,c,Kb);B.set(ce,ue)}function vke(g,c,m,v,N,E,P,O,B){if(!g)return;const W=function(J,ee,ie,ce,ue,ke){if(J.kind==="camera")return J.maxSize;if(J.kind==="composite"){const Le=ee.possiblyEvaluate(new Fi(J.maxZoom,{worldview:ke}),ie).evaluate(ue,{},ie),Ie=ee.possiblyEvaluate(new Fi(J.minZoom,{worldview:ke}),ie).evaluate(ue,{},ie);return Math.max(Le,Ie)}return ee.possiblyEvaluate(new Fi(ce,{worldview:ke})).evaluate(ue,{},ie)}(c,m,v,N,E,B);return g.scaleSelf(W*O*P)}function CA(g,c,m,v,N,E,P,O,B){return{iconPrimary:vke(g.getPrimary(),c,m,v,N,E,P,O,B),iconSecondary:vke(g.getSecondary(),c,m,v,N,E,P,O,B)}}function art(g,c,m){if(!c)return;const v=m.get(g.toString()),N=m.get(c.toString());v&&N&&(v.paddedRect.w===N.paddedRect.w&&v.paddedRect.h===N.paddedRect.h||ur(`Mismatch in icon variant sizes: ${g.toString()} and ${c.toString()}`),v.usvg!==N.usvg&&ur(`Mismatch in icon variant image types: ${g.id} and ${c.id}`))}function _ke(g,c,m,v){if(!g)return;const N=c.get(m.toString());if(g.imagePrimary=N,v){const E=c.get(v.toString());g.imageSecondary=E}}function irt(g,c){for(const m in g.horizontal)bke(g.horizontal[m],c);bke(g.vertical,c)}function bke(g,c){if(g){for(const m of g.positionedLines)for(const v of m.positionedGlyphs)if(v.image!==null){const N=v.image.toString();v.rect=c.get(N).paddedRect}}}function vue(g){switch(g){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function ort(g,c,m,v,N,E,P,O,B){const W=HO(E.horizontal)||E.vertical,J=m.get("icon-text-fit-padding").evaluate(v,{},N);let ee,ie=c;return c&&B!=="none"&&(g.allowVerticalPlacement&&E.vertical&&(ee=mue(c,E.vertical,B,J,O,P)),W&&(ie=mue(c,W,B,J,O,P))),{defaultShapedIcon:ie,verticallyShapedIcon:ee}}function lrt(g,c,m,v,N,E,P,O,B,W,J,ee,ie,ce,ue,ke,Le,Ie,Ke,Ye,at,vt,pt,kt){let Lt=P.textMaxSize.evaluate(c,{},ie);Lt===void 0?Lt=O*P.textScaleFactor:Lt*=P.textScaleFactor;const $t=g.layers[0].layout,ls=lc,Wt=O*P.textScaleFactor/ls,ms=HO(m.horizontal)||m.vertical;if(Le!=="none"&&g.appearanceFeatureData&&c.index18&&Ds>2&&(Ds>>=1),Math.max(Xs/(512*Ds),1)*$t.get("symbol-spacing")),Fs=$t.get("text-padding")*g.tilePixelRatio,Ps=$t.get("icon-padding")*g.tilePixelRatio,Ls=Ir($t.get("text-max-angle")),hs=$t.get("icon-rotation-alignment")==="map"&&Ye!=="point",cs=Os/2;var Ds;g.hasAnyIconTextFit===!1&&Le!=="none"&&(g.hasAnyIconTextFit=!0);const Qs=c.properties?+c.properties[ds]:null,Vs=Qs&&g.elevationFeatureIdToIndex?g.elevationFeatureIdToIndex.get(Qs):65535,Dr=(dr,yr,kr)=>{if(yr.x<0||yr.x>=Xs||yr.y<0||yr.y>=Xs)return;let Hn=null;if(bs){const{x:Ws,y:Sr,z:mn}=ce.projectTilePoint(yr.x,yr.y,kr);Hn={anchor:new Ky(Ws,Sr,mn,0,void 0),up:ce.upVector(kr,yr.x,yr.y)}}(function(Ws,Sr,mn,fa,va,Ln,_i,ft,_t,ps,Rs,ir,or,Or,zr,Sn,zn,Vn,la,Jr,un,Ia,za,Ba,li,ki,bi,Wa,Ja,Bn,ya,so,Yr){const ca=Ws.addToLineVertexArray(Sr,fa);let wi,Pi,zi,Fo,Li,Xr,mo,ci=0,Ki=0,Nl=0,cc=0,nl=-1,al=-1;const Gl={};let Tu=yv("");const Di=mn?mn.anchor:Sr,Eo=Wa!=="none";let zo=0,Wu=0;if(_t._unevaluatedLayout.getValue("text-radial-offset")===void 0){const td=_t.layout.get("text-offset").evaluate(un,{},li);zo=td[0]*lc,Wu=td[1]*lc}else zo=_t.layout.get("text-radial-offset").evaluate(un,{},li)*lc,Wu=yue;if(Ws.allowVerticalPlacement&&va.vertical){const td=va.vertical;if(zr)Xr=_ue(td),ft&&(mo=_ue(ft));else{const nu=_t.layout.get("text-rotate").evaluate(un,{},li)+90;zi=WO(ps,Di,Sr,Rs,ir,or,td,Or,nu,Sn,so),ft&&(Fo=WO(ps,Di,Sr,Rs,ir,or,ft,Vn,nu,null,ya))}}if(Ln){const td=Ws.iconSizeData,nu=_t.layout.get("icon-rotate").evaluate(un,{},li),Sh=xue(Ln,nu,za,Eo,Ia.iconScaleFactor),Xv=ft?xue(ft,nu,za,Eo,Ia.iconScaleFactor):void 0;Pi=WO(ps,Di,Sr,Rs,ir,or,Ln,Vn,nu,null,Bn);const ZC=function(hg,HA,BSe,_nt,$Se,qSe,bnt,wnt){const USe=hg.layers[0],VSe=USe.appearances;let YC=HA.length;if(BSe&&(YC=Math.max(YC,BSe.length)),VSe.length===0)return YC;const[jnt,Nnt]=_nt.get("icon-size-scale-range"),knt=ye(1,jnt,Nnt);for(const HSe of VSe){const WSe=HSe.getUnevaluatedProperties();if(WSe._values["icon-image"].value!==void 0){const GSe=USe.getAppearanceValueAndResolveTokens(HSe,"icon-image",$Se,qSe,[]);if(GSe){const KSe=hg.getResolvedImageFromTokens(GSe);if(KSe){const ZSe=WSe._values["icon-size"],Snt=CA(KSe,zC(hg.zoom,ZSe,hg.worldview),ZSe,qSe,hg.zoom,$Se,hg.pixelRatio,knt,hg.worldview),Cnt=bnt.get(Snt.iconPrimary.toString());YC=Math.max(YC,Yst(Cnt,wnt))}}}}return YC}(Ws,Sh,Xv,_t.layout,un,li,Ws.iconAtlasPositions,Eo);ci=4*ZC;let ug=null;td.kind==="source"?(ug=[og*_t.layout.get("icon-size").evaluate(un,{},li)*Ia.iconScaleFactor],ug[0]>Zy&&ur(`${Ws.layerIds[0]}: Value for "icon-size" is >= ${MA}. Reduce your "icon-size".`)):td.kind==="composite"&&(ug=[og*Ia.compositeIconSizes[0].evaluate(un,{},li)*Ia.iconScaleFactor,og*Ia.compositeIconSizes[1].evaluate(un,{},li)*Ia.iconScaleFactor],(ug[0]>Zy||ug[1]>Zy)&&ur(`${Ws.layerIds[0]}: Value for "icon-size" is >= ${MA}. Reduce your "icon-size".`)),Ws.addSymbols(Ws.icon,Sh,ug,Jr,la,un,void 0,mn,Sr,ca.lineStartIndex,ca.lineLength,-1,Ba,li,ki,bi,Ws.symbolInstances.length,ZC),nl=Ws.icon.placedSymbolArray.length-1,Xv&&(Ki=4*ZC,Ws.addSymbols(Ws.icon,Xv,ug,Jr,la,un,kh.vertical,mn,Sr,ca.lineStartIndex,ca.lineLength,-1,Ba,li,ki,bi,Ws.symbolInstances.length,ZC),al=Ws.icon.placedSymbolArray.length-1)}for(const td in va.horizontal){const nu=td,Sh=va.horizontal[nu];wi||(Tu=yv(Sh.text),zr?Li=_ue(Sh):wi=WO(ps,Di,Sr,Rs,ir,or,Sh,Or,_t.layout.get("text-rotate").evaluate(un,{},li),Sn,so));const Xv=Sh.positionedLines.length===1;if(Nl+=wke(Ws,mn,Sr,Sh,_i,_t,zr,un,Sn,ca,va.vertical?kh.horizontal:kh.horizontalOnly,Xv?ert(va.horizontal):[nu],Gl,nl,Ia,Ba,li,Ws.symbolInstances.length,ki),Xv)break}va.vertical&&(cc+=wke(Ws,mn,Sr,va.vertical,_i,_t,zr,un,Sn,ca,kh.vertical,["vertical"],Gl,al,Ia,Ba,li,Ws.symbolInstances.length,ki));let kl=-1;const Vp=(td,nu)=>td?Math.max(td,nu):nu;kl=Vp(Li,kl),kl=Vp(Xr,kl),kl=Vp(mo,kl);const Sx=kl>-1?1:0;Ws.glyphOffsetArray.length>=65535&&ur("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),un.sortKey!==void 0&&Ws.addToSortKeyRanges(Ws.symbolInstances.length,un.sortKey),Ws.symbolInstances.emplaceBack(Sr.x,Sr.y,Di.x,Di.y,Di.z,Gl.right>=0?Gl.right:-1,Gl.center>=0?Gl.center:-1,Gl.left>=0?Gl.left:-1,Gl.vertical>=0?Gl.vertical:-1,nl,al,Tu,wi!==void 0?wi:Ws.collisionBoxArray.length,wi!==void 0?wi+1:Ws.collisionBoxArray.length,zi!==void 0?zi:Ws.collisionBoxArray.length,zi!==void 0?zi+1:Ws.collisionBoxArray.length,Pi!==void 0?Pi:Ws.collisionBoxArray.length,Pi!==void 0?Pi+1:Ws.collisionBoxArray.length,Fo||Ws.collisionBoxArray.length,Fo?Fo+1:Ws.collisionBoxArray.length,Rs,Nl,cc,ci,Ki,Sx,0,zo,Wu,kl,0,Eo?1:0,Ja)})(g,yr,Hn,dr,m,v,E,N,g.layers[0],g.collisionBoxArray,c.index,c.sourceLayerIndex,g.index,Fs,Ke,W,0,Ps,hs,Ie,c,P,J,ee,ie,ue,ke,Le,Vs,at,vt,pt)};if(Ye==="line")for(const dr of CO(c.geometry,0,0,Xs,Xs)){const yr=Zst(dr,Os,Ls,m.vertical||ms,v,ls,ws,g.overscaling,Xs);for(const kr of yr)ms&&crt(g,ms.text,cs,kr)||Dr(dr,kr,ie)}else if(Ye==="line-center"){for(const dr of c.geometry)if(dr.length>1){const yr=Kst(dr,Ls,m.vertical||ms,v,ls,ws);yr&&Dr(dr,yr,ie)}}else if(c.type==="Polygon")for(const dr of dA(c.geometry,0)){const yr=Qst(dr,16);Dr(dr[0],new Ky(yr.x,yr.y,0,0,void 0),ie)}else if(c.type==="LineString")for(const dr of c.geometry)Dr(dr,new Ky(dr[0].x,dr[0].y,0,0,void 0),ie);else if(c.type==="Point")for(const dr of c.geometry)for(const yr of dr)Dr([yr],new Ky(yr.x,yr.y,0,0,void 0),ie)}const MA=255,Zy=MA*og;function wke(g,c,m,v,N,E,P,O,B,W,J,ee,ie,ce,ue,ke,Le,Ie,Ke){const Ye=function(pt,kt,Lt,$t,ls,Wt,ms,bs){const ws=[];if(kt.positionedLines.length===0)return ws;const Os=$t.layout.get("text-rotate").evaluate(Wt,{})*Math.PI/180,Fs=function(Ds){const Qs=Ds[0],Vs=Ds[1],Dr=Qs*Vs;return Dr>0?[Qs,-Vs]:Dr<0?[-Qs,Vs]:Qs===0?[Vs,Qs]:[Vs,-Qs]}(Lt);let Ps=Math.abs(kt.top-kt.bottom);for(const Ds of kt.positionedLines)Ps-=Ds.lineOffset;const Ls=kt.positionedLines.length,hs=Ps/Ls;let cs=kt.top-Lt[1];for(let Ds=0;DsZy&&ur(`${g.layerIds[0]}: Value for "text-size" is >= ${MA}. Reduce your "text-size".`)):at.kind==="composite"&&(vt=[og*ue.compositeTextSizes[0].evaluate(O,{},Le)*ue.textScaleFactor,og*ue.compositeTextSizes[1].evaluate(O,{},Le)*ue.textScaleFactor],(vt[0]>Zy||vt[1]>Zy)&&ur(`${g.layerIds[0]}: Value for "text-size" is >= ${MA}. Reduce your "text-size".`)),g.addSymbols(g.text,Ye,vt,B,P,O,J,c,m,W.lineStartIndex,W.lineLength,ce,ke,Le,Ke,!1,Ie,Ye.length);for(const pt of ee)ie[pt]=g.text.placedSymbolArray.length-1;return 4*Ye.length}function HO(g){for(const c in g)return g[c];return null}function WO(g,c,m,v,N,E,P,O,B,W,J){let ee,ie,ce,ue;if(ee=J?J.top:P.top,ie=J?J.bottom:P.bottom,ce=J?J.left:P.left,ue=J?J.right:P.right,hue(P)&&P.collisionPadding){const ke=P.collisionPadding;ce-=ke[0],ee-=ke[1],ue+=ke[2],ie+=ke[3]}if(B){const ke=new es(ce,ee),Le=new es(ue,ee),Ie=new es(ce,ie),Ke=new es(ue,ie),Ye=Ir(B);let at=new es(0,0);W&&(at=new es(W[0],W[1])),ke._rotateAround(Ye,at),Le._rotateAround(Ye,at),Ie._rotateAround(Ye,at),Ke._rotateAround(Ye,at),ce=Math.min(ke.x,Le.x,Ie.x,Ke.x),ue=Math.max(ke.x,Le.x,Ie.x,Ke.x),ee=Math.min(ke.y,Le.y,Ie.y,Ke.y),ie=Math.max(ke.y,Le.y,Ie.y,Ke.y)}return g.emplaceBack(c.x,c.y,c.z,m.x,m.y,ce,ee,ue,ie,O,v,N,E),g.length-1}function _ue(g){hue(g)&&g.collisionPadding&&(g.top-=g.collisionPadding[1],g.bottom+=g.collisionPadding[3]);const c=g.bottom-g.top;return c>0?Math.max(10,c):null}function crt(g,c,m,v){const N=g.compareText;if(c in N){const E=N[c];for(let P=E.length-1;P>=0;P--)if(v.dist(E[P])Ye&&(at(pt,ws,Lt,$t,ms,bs),at(ws,kt,ms,bs,ls,Wt))}at(ee,ie,v,E,N,E),at(ie,ce,N,E,N,P),at(ce,ue,N,P,v,P),at(ue,ee,v,P,v,E),ke-=Ye,Le-=Ye,Ie+=Ye,Ke+=Ye;const vt=1/Math.max(Ie-ke,Ke-Le);return{scale:vt,x:ke*vt,y:Le*vt,x2:Ie*vt,y2:Ke*vt,projection:c}}function Nke(g,{x:c,y:m},v=0){return new es(((c-v)*g.scale-g.x)*Xs,(m*g.scale-g.y)*Xs)}const drt=j(new Float32Array(16));class Zv{constructor(c){this.spec=c,this.name=c.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(c,m){return{x:0,y:0,z:0}}unproject(c,m){return new x(0,0)}projectTilePoint(c,m,v){return{x:c,y:m,z:0}}locationPoint(c,m,v,N=!0){return c._coordinatePoint(c.locationCoordinate(m,v),N)}pixelsPerMeter(c,m){return ne(1,c)*m}pixelSpaceConversion(c,m,v){return 1}farthestPixelDistance(c){return jke(c,c.pixelsPerMeter)}pointCoordinate(c,m,v,N){const E=c.horizonLineFromTop(!1),P=new es(m,Math.max(E,v));return c.rayIntersectionCoordinate(c.pointRayIntersection(P,N))}pointCoordinate3D(c,m,v){const N=new es(m,v);if(c.elevation)return c.elevation.pointCoordinate(N);{const E=this.pointCoordinate(c,N.x,N.y,0);return[E.x,E.y,E.z]}}isPointAboveHorizon(c,m){if(c.elevation&&c.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(c,m.x,m.y);const v=c.horizonLineFromTop();return m.y0?m<-UC+v&&(m=-UC+v):m>UC-v&&(m=UC-v);const P=E/Math.pow(KO(m),N);let O=P*Math.sin(N*c),B=E-P*Math.cos(N*c);return O=.5*(O/Math.PI+.5),B=.5*(B/Math.PI+.5),{x:O,y:this.southernCenter?B:1-B,z:0}}unproject(c,m){c=(2*c-.5)*Math.PI,this.southernCenter&&(m=1-m),m=(2*(1-m)-.5)*Math.PI;const{n:v,f:N}=this,E=N-m,P=Math.sign(E),O=Math.sign(v)*Math.sqrt(c*c+E*E);let B=Math.atan2(c,Math.abs(E))*P;E*v<0&&(B-=Math.PI*Math.sign(c)*P);const W=ye(mi(B/v)+this.center[0],-180,180),J=ye(mi(2*Math.atan(Math.pow(N/O,1/v))-UC),-xe,xe);return new x(W,this.southernCenter?-J:J)}}class kke extends Zv{constructor(c){super(c),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(c,m){return{x:V(c),y:X(m),z:0}}unproject(c,m){const v=oe(c),N=ge(m);return new x(v,N)}}const Ske=Ir(xe);class frt extends Zv{project(c,m){const v=(m=Ir(m))*m,N=v*v;return{x:.5*((c=Ir(c))*(.8707-.131979*v+N*(N*(.003971*v-.001529*N)-.013791))/Math.PI+.5),y:1-.5*(m*(1.007226+v*(.015085+N*(.028874*v-.044475-.005916*N)))/Math.PI+1),z:0}}unproject(c,m){c=(2*c-.5)*Math.PI;let v=m=(2*(1-m)-1)*Math.PI,N=25,E=0,P=v*v;do{P=v*v;const W=P*P;E=(v*(1.007226+P*(.015085+W*(.028874*P-.044475-.005916*W)))-m)/(1.007226+P*(.045255+W*(.259866*P-.311325-.005916*11*W))),v=ye(v-E,-Ske,Ske)}while(Math.abs(E)>1e-6&&--N>0);P=v*v;const O=ye(mi(c/(.8707+P*(P*(P*P*P*(.003971-.001529*P)-.013791)-.131979))),-180,180),B=mi(v);return new x(O,B)}}const Cke=Ir(xe);class grt extends Zv{project(c,m){m=Ir(m),c=Ir(c);const v=Math.cos(m),N=2/Math.PI,E=Math.acos(v*Math.cos(c/2)),P=Math.sin(E)/E,O=.5*(c*N+2*v*Math.sin(c/2)/P)||0,B=.5*(m+Math.sin(m)/P)||0;return{x:.5*(O/Math.PI+.5),y:1-.5*(B/Math.PI+1),z:0}}unproject(c,m){let v=c=(2*c-.5)*Math.PI,N=m=(2*(1-m)-1)*Math.PI,E=25;const P=1e-6;let O=0,B=0;do{const W=Math.cos(N),J=Math.sin(N),ee=2*J*W,ie=J*J,ce=W*W,ue=Math.cos(v/2),ke=Math.sin(v/2),Le=2*ue*ke,Ie=ke*ke,Ke=1-ce*ue*ue,Ye=Ke?1/Ke:0,at=Ke?Math.acos(W*ue)*Math.sqrt(1/Ke):0,vt=.5*(2*at*W*ke+2*v/Math.PI)-c,pt=.5*(at*J+N)-m,kt=.5*Ye*(ce*Ie+at*W*ue*ie)+1/Math.PI,Lt=Ye*(Le*ee/4-at*J*ke),$t=.125*Ye*(ee*ke-at*J*ce*Le),ls=.5*Ye*(ie*ue+at*Ie*W)+.5,Wt=Lt*$t-ls*kt;O=(pt*Lt-vt*ls)/Wt,B=(vt*$t-pt*kt)/Wt,v=ye(v-O,-Math.PI,Math.PI),N=ye(N-B,-Cke,Cke)}while((Math.abs(O)>P||Math.abs(B)>P)&&--E>0);return new x(mi(v),mi(N))}}class Mke extends Zv{constructor(c){super(c),this.center=c.center||[0,0],this.parallels=c.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ir(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(c,m){const{scale:v,cosPhi:N}=this;return{x:Ir(c)*N*v+.5,y:-Math.sin(Ir(m))/N*v+.5,z:0}}unproject(c,m){const{scale:v,cosPhi:N}=this,E=-(m-.5)/v,P=ye(mi((c-.5)/v)/N,-180,180),O=Math.asin(ye(E*N,-1,1)),B=ye(mi(O),-xe,xe);return new x(P,B)}}class xrt extends kke{constructor(c){super(c),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(c,m,v){const N=nA(c,m,v);return Rt(N,N,yO(Jm(v))),{x:N[0],y:N[1],z:N[2]}}locationPoint(c,m,v){const N=qv(m.lat,m.lng),E=Ae([],N),P=v?c._centerAltitude+v:c.elevation?c.elevation.getAtPointOrZero(c.locationCoordinate(m),c._centerAltitude):c._centerAltitude;Ge(N,N,E,ne(1,0)*Xs*P);const O=j(new Float64Array(16));return S(O,c.pixelMatrix,c.globeMatrix),Rt(N,N,O),new es(N[0],N[1])}pixelsPerMeter(c,m){return ne(1,0)*m}pixelSpaceConversion(c,m,v){const N=ne(1,c)*m,E=Hr(ne(1,45)*m,N,v);return this.pixelsPerMeter(c,m)/E}createTileMatrix(c,m,v){const N=kde(Jm(v.canonical));return S(new Float64Array(16),c.globeMatrix,N)}createInversionMatrix(c,m){const{center:v}=c,N=yO(Jm(m));return R(N,N,Ir(v.lng)),L(N,N,Ir(v.lat)),I(N,N,[c._pixelsPerMercatorPixel,c._pixelsPerMercatorPixel,1]),Float32Array.from(N)}pointCoordinate(c,m,v,N){return Vv(c,m,v,!0)||new tt(0,0)}pointCoordinate3D(c,m,v){const N=this.pointCoordinate(c,m,v,0);return[N.x,N.y,N.z]}isPointAboveHorizon(c,m){return!Vv(c,m.x,m.y,!1)}farthestPixelDistance(c){const m=function(N,E){const P=N.cameraToCenterDistance,O=N._centerAltitude*E,B=N._camera,W=N._camera.forward(),J=le([],Ne([],W,-P),[0,0,O]),ee=N.worldSize/(2*Math.PI),ie=[0,0,-ee],ce=N.width/N.height,ue=Math.tan(N.fovAboveCenter),ke=Ne([],B.up(),ue),Le=Ne([],B.right(),ue*ce),Ie=Ae([],le([],le([],W,ke),Le)),Ke=[];let Ye;if(new Nr(J,Ie).closestPointOnSphere(ie,ee,Ke)){const at=le([],Ke,ie),vt=Se([],at,J);Ye=Math.cos(N.fovAboveCenter)*de(vt)}else{const at=Se([],J,ie),vt=Se([],ie,J);Ae(vt,vt);const pt=de(at)-ee;Ye=Math.sqrt(pt*(pt+2*ee));const kt=Math.acos(Ye/(ee+pt))-Math.acos(Ue(W,vt));Ye*=Math.cos(kt)}return 1.01*Ye}(c,this.pixelsPerMeter(c.center.lat,c.worldSize)),v=Hv(c.zoom);if(v>0){const N=jke(c,ne(1,c.center.lat)*c.worldSize),E=c.worldSize/(2*Math.PI),P=Math.max(c.width,c.height)/c.worldSize*Math.PI;return Hr(m,N+E*(1-Math.cos(P)),Math.pow(v,10))}return m}upVector(c,m,v){return nA(m,v,c,1)}upVectorScale(c){return{metersToTile:qp(xO(Jm(c)))}}}function Tke(g){const c=g.parallels,m=!!c&&Math.abs(c[0]+c[1])<.01;switch(g.name){case"mercator":return new kke(g);case"equirectangular":return new mrt(g);case"naturalEarth":return new frt(g);case"equalEarth":return new hrt(g);case"winkelTripel":return new grt(g);case"albers":return m?new Mke(g):new urt(g);case"lambertConformalConic":return m?new Mke(g):new prt(g);case"globe":return new xrt(g)}throw new Error(`Invalid projection name: ${g.name}`)}const yrt=Ut.types,vrt=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function LA(g,c,m,v,N,E,P,O,B,W,J,ee,ie){const ce=O?Math.min(Zy,Math.round(O[0])):0,ue=O?Math.min(Zy,Math.round(O[1])):0;g.emplaceBack(c,m,Math.round(32*v),Math.round(32*N),E,P,(ce<<1)+(B?1:0),0+(ue<<1),16*W,16*J,256*ee,256*ie)}function DA(g,c,m){g.emplaceBack(c,m)}function OA(g,c,m,v,N,E,P){g.emplaceBack(c,m,v,N,E,P)}const ZO=(g,c,m,v)=>{for(let N=0;N0&&(this.iconTransitioningVertexBuffer=c.createVertexBuffer(this.iconTransitioningVertexArray,Cst.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,jst.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||E)&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,kst.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=c.createVertexBuffer(this.orientationVertexArray,Sst.members,!0)),this.opacityVertexBuffer.itemSize=1),(v||N)&&this.programConfigurations.upload(c))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy())}}_r(bue,"SymbolBuffers");class wue{constructor(c,m,v){this.layoutVertexArray=new c,this.layoutAttributes=m,this.indexArray=new v,this.segments=new co,this.collisionVertexArray=new UT,this.collisionVertexArrayExt=new _x}upload(c){this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=c.createVertexBuffer(this.collisionVertexArray,Mst.members,!0),this.collisionVertexBufferExt=c.createVertexBuffer(this.collisionVertexArrayExt,Tst.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}_r(wue,"CollisionBuffers");class YO{constructor(c){this.collisionBoxArray=c.collisionBoxArray,this.zoom=c.zoom,this.overscaling=c.overscaling,this.layers=c.layers,this.layerIds=this.layers.map(P=>P.fqid),this.index=c.index,this.pixelRatio=c.pixelRatio,this.sourceLayerIndex=c.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=j([]),this.placementViewportMatrix=j([]);const m=this.layers[0]._unevaluatedLayout._values;this.worldview=c.worldview,this.localizable=c.localizable,this.textSizeData=zC(this.zoom,m["text-size"],this.worldview),this.iconSizeData=zC(this.zoom,m["icon-size"],this.worldview);const v=this.layers[0].layout,N=v.get("symbol-sort-key"),E=v.get("symbol-z-order");this.lut=c.lut,this.canOverlap=v.get("text-allow-overlap")||v.get("icon-allow-overlap")||v.get("text-ignore-placement")||v.get("icon-ignore-placement"),this.sortFeaturesByKey=E!=="viewport-y"&&N.constantOr(1)!==void 0,this.sortFeaturesByY=(E==="viewport-y"||E==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=v.get("text-writing-mode").map(P=>kh[P]),this.stateDependentLayerIds=this.layers.filter(P=>P.isStateDependent()).map(P=>P.id),this.sourceID=c.sourceID,this.projection=c.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.lastActiveApperance=null,this.featureToAppearanceIndex={}}hasAnyAppearanceProperty(c){const m=this.layers[0].getAppearances();return!(!m||m.length===0)&&m.some(v=>v.getProperty(c)!=null)}createArrays(){this.text=new bue(new Xm(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("text")||c.startsWith("symbol"))),this.icon=new bue(new Xm(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("icon")||c.startsWith("symbol"))),this.glyphOffsetArray=new bC,this.lineVertexArray=new hO,this.symbolInstances=new YT}calculateGlyphDependencies(c,m,v,N,E){for(const P of c){const O=P.codePointAt(0);if(O===void 0)break;if(m[O]=!0,N&&E&&O<=65535){const B=jA[P];B&&(m[B.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(c,m,v,N,E,P){let O=1;const B=c.getUnevaluatedProperties()._values["icon-size"],W=zC(this.zoom,B,this.worldview),J=BC(W,m);if(W.kind!=="constant"&&W.kind!=="camera"||(O=J.uSize),W.kind==="composite"){const{minZoom:ee,maxZoom:ie}=W,ce=B.possiblyEvaluate(new Fi(ee,{worldview:this.worldview}),N),ue=B.possiblyEvaluate(new Fi(ie,{worldview:this.worldview}),N),ke=ce.evaluate(v,{},N,E);O=ke+(ue.evaluate(v,{},N,E)-ke)*J.uSizeT}return W.kind==="source"&&(O=B.possiblyEvaluate(new Fi(this.zoom,{worldview:this.worldview}),N).evaluate(v,{},N,E)),O*P}updateFootprints(c,m){}updateReplacement(c,m){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const v=m.getReplacementRegionsForTile(c.toUnwrapped(),!0);return!NO(this.activeReplacements,v)&&(this.activeReplacements=v,!0)}getResolvedImageFromTokens(c){return typeof c=="string"?Jd.build(c):c}populate(c,m,v,N){const E=this.layers[0],P=E.layout,O=this.projection.name==="globe",B=P.get("text-font"),W=P.get("text-field"),J=P.get("icon-image"),[ee,ie]=P.get("icon-size-scale-range"),ce=ye(m.scaleFactor||1,ee,ie),ue=(W.value.kind!=="constant"||W.value.value instanceof Qd&&!W.value.value.isEmpty()||W.value.value.toString().length>0)&&(B.value.kind!=="constant"||B.value.value.length>0),ke=J.value.kind!=="constant"||!!J.value.value||Object.keys(J.parameters).length>0,Le=this.hasAnyAppearanceProperty("icon-image"),Ie=P.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!ue&&!ke&&!Le)return;const Ke=m.iconDependencies,Ye=m.glyphDependencies,at=m.availableImages,vt=new Fi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),pt=kt=>{const Lt=kt.id.toString();Ke.has(Lt)?Ke.get(Lt).push(kt):Ke.set(Lt,[kt])};for(const kt of c){const{feature:Lt,id:$t,index:ls,sourceLayerIndex:Wt}=kt,ms=E._featureFilter.needGeometry,bs=Ht(Lt,ms);if(!E._featureFilter.filter(vt,bs,v))continue;if(ms||(bs.geometry=Et(Lt,v,N)),O&&Lt.type!==1&&v.z<=5){const Ds=bs.geometry,Qs=.98078528056,Vs=(Dr,dr)=>Ue(nA(Dr.x,Dr.y,v,1),nA(dr.x,dr.y,v,1)){if(!Ds.getProperty("icon-image"))return;const Qs=this.getCombinedIconPrimary(Ds,Fs,bs,v,at,hs,ce);Qs&&pt(Qs)}),ws){const Ds=B.evaluate(bs,{},v).join(","),Qs=P.get("text-rotation-alignment")==="map"&&P.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(kh.vertical)>=0;for(const Vs of ws.sections)if(Vs.image){const Dr=Vs.image.getPrimary().scaleSelf(this.pixelRatio),dr=Dr.id.toString(),yr=Ke.get(dr)||[];yr.push(Dr),Ke.set(dr,yr)}else{const Dr=Tb(ws.toString()),dr=Vs.fontStack||Ds,yr=Ye[dr]=Ye[dr]||{};this.calculateGlyphDependencies(Vs.text,yr,Qs,this.allowVerticalPlacement,Dr)}}}if(P.get("symbol-placement")==="line"&&(this.features=function(kt){const Lt={},$t={},ls=[];let Wt=0;function ms(Fs){ls.push(kt[Fs]),Wt++}function bs(Fs,Ps,Ls){const hs=$t[Fs];return delete $t[Fs],$t[Ps]=hs,ls[hs].geometry[0].pop(),ls[hs].geometry[0]=ls[hs].geometry[0].concat(Ls[0]),hs}function ws(Fs,Ps,Ls){const hs=Lt[Ps];return delete Lt[Ps],Lt[Fs]=hs,ls[hs].geometry[0].shift(),ls[hs].geometry[0]=Ls[0].concat(ls[hs].geometry[0]),hs}function Os(Fs,Ps,Ls){const hs=Ls?Ps[0][Ps[0].length-1]:Ps[0][0];return`${Fs}:${hs.x}:${hs.y}`}for(let Fs=0;FsFs.geometry)}(this.features)),P.get("symbol-elevation-reference")==="hd-road-markup"){if(this.elevationType="road",m.elevationFeatures){!this.elevationFeatures&&m.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const kt of m.elevationFeatures)this.elevationFeatureIdToIndex.set(kt.id,this.elevationFeatures.length),this.elevationFeatures.push(kt)}}else P.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((kt,Lt)=>kt.sortKey-Lt.sortKey)}getCombinedIconPrimary(c,m,v,N,E,P,O){let B,W;const J=c.getUnevaluatedProperties();if(J._values["icon-image"].value!==void 0){const ee=m.getAppearanceValueAndResolveTokens(c,"icon-image",v,N,E);B=this.getResolvedImageFromTokens(ee)}else{const ee=m.getValueAndResolveTokens("icon-image",v,N,E);B=this.getResolvedImageFromTokens(ee)}if(B){const ee=J._values["icon-size"]||m._unevaluatedLayout._values["icon-size"];W=CA(B,zC(this.zoom,ee,this.worldview),ee,N,this.zoom,P,this.pixelRatio,O,this.worldview).iconPrimary}return W}updateAppearanceBasedIconTextures(c,m,v,N){if(!this.appearanceFeatureData||!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)return!1;const E=this.layers[0];let P=!1,O=0;const B=E.layout,[W,J]=B.get("icon-size-scale-range"),ee=ye(1,W,J);for(let ie=0;ie=0){const Le=ke.id,Ie=m&&Le!==void 0?m[String(Le)]:void 0,Ke={type:"Point",id:ke.id,properties:ke.properties,geometry:[]},Ye=this.layers[0].appearances&&this.layers[0].appearances.find(at=>at.isActive({globals:N,feature:Ke,canonical:c,featureState:Ie}));if(ke.activeAppearance===Ye){O+=ce.numIconVertices;continue}if(Ye){ke.activeAppearance=Ye;const at=this.getCombinedIconPrimary(Ye,E,Ke,c,v,{sortKey:void 0,text:void 0,icon:null,index:ce.featureIndex,sourceLayerIndex:ce.featureIndex,geometry:[],properties:ke.properties,type:"Point",id:ke.id},ee);if(!at)continue;const vt=at.toString(),pt=this.iconAtlasPositions&&this.iconAtlasPositions.get(vt);if(pt){const kt=E.getAppearanceValueAndResolveTokens(Ye,"icon-offset",Ke,c,v),Lt=kt&&Array.isArray(kt)?kt:[0,0];let $t=BO(pt,void 0,Lt,E.layout.get("icon-anchor").evaluate(Ke,{},c));const ls=E.getAppearanceValueAndResolveTokens(Ye,"icon-rotate",Ke,c,v),Wt=typeof ls=="number"?ls:0,ms=pt.sdf,bs=E.layout.get("icon-text-fit").constantOr("none");bs!=="none"&&ke.textShaping&&ke.iconTextFitPadding&&ke.fontScale&&($t=mue($t,ke.textShaping,bs,ke.iconTextFitPadding,Lt,ke.fontScale));const ws=this.calculateEffectiveAppearanceIconSize(Ye,N.zoom,Ke,c,v,ee),Os=0,Fs=1+(Math.min(Zy,Math.round(ws*og))<<1),Ps=xue($t,Wt,ms,bs!=="none",ee);ke.isUsingAppearanceVertexData||(ke.isUsingAppearanceVertexData=!0,ke.layoutBasedVertexData=this.icon.getIconVertexData(O,ce.numIconVertices));for(let hs=0;hs0&&(this.icon.updateIconVertexData(O,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(O+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(O+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(O+3,0,0,0,0,0,0,0,0,0,0,0,0),P=!0),O+=ce.numIconVertices,ke.activeAppearance=null;else if(ke.isUsingAppearanceVertexData){const vt=ke.layoutBasedVertexData.length/12;for(let pt=0;pt0||ie>0,Le=ce>0,Ie=this.elevationFeatures[B.elevationFeatureIndex];if(Ie){const Ke=new es(B.tileAnchorX,B.tileAnchorY),Ye=.075+Ie.pointElevation(Ke);B.zOffset!==Ye&&(m=!0,B.zOffset=Ye),Ye!==0&&(this.hasAnyZOffset=!0);const at=Ie.computeSlopeNormal(Ke,N),vt=is(We(),re(0,0,1),at);Xe(W,W,vt),Xe(J,J,vt),W[2]*=v,J[2]*=v,W[0]===1&&W[1]===0&&W[2]===0&&J[0]===0&&J[1]===1&&J[2]===0||(E=E||ke,P=P||Le)}if(ke&&(ZO(this.text.orientationVertexArray,ee,W,J),ZO(this.text.orientationVertexArray,ie,W,J)),Le){const{placedIconSymbolIndex:Ke,verticalPlacedIconSymbolIndex:Ye}=B;Ke>=0&&ZO(this.icon.orientationVertexArray,ce,W,J),Ye>=0&&ZO(this.icon.orientationVertexArray,ue,W,J)}}E||(this.text.orientationVertexArray=void 0),P||(this.icon.orientationVertexArray=void 0),m&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const c=(E,P,O)=>{v+=P,v>E.length&&E.resize(v);for(let B=-P;B<0;B++)E.emplace(B+v,O)},m=(E,P,O)=>{N+=P,N>E.length&&E.resize(N);for(let B=-P;B<0;B++)E.emplace(B+N,O)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let v=0,N=0;for(let E=0;E0;if((O>0||B>0)&&(c(this.text.zOffsetVertexArray,O,J),c(this.text.zOffsetVertexArray,B,J)),ee){const{placedIconSymbolIndex:ie,verticalPlacedIconSymbolIndex:ce}=P;ie>=0&&m(this.icon.zOffsetVertexArray,W,J),ce>=0&&m(this.icon.zOffsetVertexArray,P.numVerticalIconVertices,J)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(c,m,v,N,E){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(c),this.iconCollisionBox.upload(c)),this.text.upload(c,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,!1),this.hasAppearances===null&&(this.hasAppearances=this.layers.some(P=>P.appearances&&P.appearances.length>0)),this.icon.upload(c,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(c,m,v,N){return!!(c&&m&&v)&&!(!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(c,m,v,N)&&this.icon.layoutVertexBuffer&&this.icon.layoutVertexArray.arrayBuffer!==null&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray))}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tke(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(c,m){const v=this.lineVertexArray.length;if(c.segment!==void 0)for(const{x:N,y:E}of m)this.lineVertexArray.emplaceBack(N,E);return{lineStartIndex:v,lineLength:this.lineVertexArray.length-v}}addSymbols(c,m,v,N,E,P,O,B,W,J,ee,ie,ce,ue,ke,Le,Ie,Ke){const Ye=c.indexArray,at=c.layoutVertexArray,vt=c.globeExtVertexArray,pt=c.segments.prepareSegment(4*Ke,at,Ye,this.canOverlap?P.sortKey:void 0),kt=this.glyphOffsetArray.length,Lt=pt.vertexLength,$t=this.allowVerticalPlacement&&O===kh.vertical?Math.PI/2:0,ls=P.text&&P.text.sections;for(let bs=0;bs=0?m.rightJustifiedTextSymbolIndex:m.centerJustifiedTextSymbolIndex>=0?m.centerJustifiedTextSymbolIndex:m.leftJustifiedTextSymbolIndex>=0?m.leftJustifiedTextSymbolIndex:m.verticalPlacedTextSymbolIndex>=0?m.verticalPlacedTextSymbolIndex:N),P=pue(this.textSizeData,c,E)/lc;return this.tilePixelRatio*P}getSymbolInstanceIconSize(c,m,v){const N=this.icon.placedSymbolArray.get(v),E=pue(this.iconSizeData,c,N);return this.tilePixelRatio*E}_commitDebugCollisionVertexUpdate(c,m,v,N){c.emplaceBack(m,-v,-v,N),c.emplaceBack(m,v,-v,N),c.emplaceBack(m,v,v,N),c.emplaceBack(m,-v,v,N)}_updateTextDebugCollisionBoxes(c,m,v,N,E,P,O){for(let B=N;B0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(c,m){const v=c.placedSymbolArray.get(m),N=v.vertexStartIndex+4*v.numGlyphs;for(let E=v.vertexStartIndex;EN[O]-N[B]||E[B]-E[O]),P}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let c=0;cthis.symbolInstances.get(m).zOffset-this.symbolInstances.get(c).zOffset)}addToSortKeyRanges(c,m){const v=this.sortKeyRanges[this.sortKeyRanges.length-1];v&&v.sortKey===m?v.symbolInstanceEnd=c+1:this.sortKeyRanges.push({sortKey:m,symbolInstanceStart:c,symbolInstanceEnd:c+1})}sortFeatures(c){if(this.sortFeaturesByY&&this.sortedAngle!==c&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(c),this.sortedAngle=c,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const m of this.symbolInstanceIndexes){const v=this.symbolInstances.get(m);this.featureSortOrder.push(v.featureIndex);const{rightJustifiedTextSymbolIndex:N,centerJustifiedTextSymbolIndex:E,leftJustifiedTextSymbolIndex:P,verticalPlacedTextSymbolIndex:O,placedIconSymbolIndex:B,verticalPlacedIconSymbolIndex:W}=v;N>=0&&this.addIndicesForPlacedSymbol(this.text,N),E>=0&&E!==N&&this.addIndicesForPlacedSymbol(this.text,E),P>=0&&P!==E&&P!==N&&this.addIndicesForPlacedSymbol(this.text,P),O>=0&&this.addIndicesForPlacedSymbol(this.text,O),B>=0&&this.addIndicesForPlacedSymbol(this.icon,B),W>=0&&this.addIndicesForPlacedSymbol(this.icon,W)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getElevationFeatureForText(c){const m=this.symbolInstances.get(this.text.symbolInstanceIndices[c]).elevationFeatureIndex;let v;return this.elevationFeatures&&mv in g?String(g[v]):"")}let Eke,Pke,jue;_r(YO,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),YO.addDynamicAttributes=VC;class Ike{constructor(c){this.type=c.property.overrides?c.property.overrides.runtimeType:Wm,this.defaultValue=c}evaluate(c){if(c.formattedSection){const m=this.defaultValue.property.overrides;if(m&&m.hasOverride(c.formattedSection))return m.getOverride(c.formattedSection)}return c.feature&&c.featureState?this.defaultValue.evaluate(c.feature,c.featureState):this.defaultValue.property.specification.default}eachChild(c){this.defaultValue.isConstant()||c(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}_r(Ike,"FormatSectionOverride",{omit:["defaultValue"]});const Nue=()=>jue||(jue={layout:Eke||(Eke=new wo({"symbol-placement":new Gs(Gt.layout_symbol["symbol-placement"]),"symbol-spacing":new Gs(Gt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Gs(Gt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nr(Gt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Gs(Gt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Gs(Gt.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Gs(Gt.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Gs(Gt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Gs(Gt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Gs(Gt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Gs(Gt.layout_symbol["icon-rotation-alignment"]),"icon-size":new nr(Gt.layout_symbol["icon-size"]),"icon-size-scale-range":new Gs(Gt.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new nr(Gt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nr(Gt.layout_symbol["icon-text-fit-padding"]),"icon-image":new nr(Gt.layout_symbol["icon-image"]),"icon-image-use-theme":new Gs({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new nr(Gt.layout_symbol["icon-rotate"]),"icon-padding":new Gs(Gt.layout_symbol["icon-padding"]),"icon-keep-upright":new Gs(Gt.layout_symbol["icon-keep-upright"]),"icon-offset":new nr(Gt.layout_symbol["icon-offset"]),"icon-anchor":new nr(Gt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Gs(Gt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Gs(Gt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Gs(Gt.layout_symbol["text-rotation-alignment"]),"text-field":new nr(Gt.layout_symbol["text-field"]),"text-font":new nr(Gt.layout_symbol["text-font"]),"text-size":new nr(Gt.layout_symbol["text-size"]),"text-size-scale-range":new Gs(Gt.layout_symbol["text-size-scale-range"]),"text-max-width":new nr(Gt.layout_symbol["text-max-width"]),"text-line-height":new nr(Gt.layout_symbol["text-line-height"]),"text-letter-spacing":new nr(Gt.layout_symbol["text-letter-spacing"]),"text-justify":new nr(Gt.layout_symbol["text-justify"]),"text-radial-offset":new nr(Gt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Gs(Gt.layout_symbol["text-variable-anchor"]),"text-anchor":new nr(Gt.layout_symbol["text-anchor"]),"text-max-angle":new Gs(Gt.layout_symbol["text-max-angle"]),"text-writing-mode":new Gs(Gt.layout_symbol["text-writing-mode"]),"text-rotate":new nr(Gt.layout_symbol["text-rotate"]),"text-padding":new Gs(Gt.layout_symbol["text-padding"]),"text-keep-upright":new Gs(Gt.layout_symbol["text-keep-upright"]),"text-transform":new nr(Gt.layout_symbol["text-transform"]),"text-offset":new nr(Gt.layout_symbol["text-offset"]),"text-allow-overlap":new Gs(Gt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Gs(Gt.layout_symbol["text-ignore-placement"]),"text-optional":new Gs(Gt.layout_symbol["text-optional"]),visibility:new Gs(Gt.layout_symbol.visibility)})),paint:Pke||(Pke=new wo({"icon-opacity":new nr(Gt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nr(Gt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nr(Gt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nr(Gt.paint_symbol["text-emissive-strength"]),"icon-color":new nr(Gt.paint_symbol["icon-color"]),"icon-halo-color":new nr(Gt.paint_symbol["icon-halo-color"]),"icon-halo-width":new nr(Gt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nr(Gt.paint_symbol["icon-halo-blur"]),"icon-translate":new Gs(Gt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Gs(Gt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Gs(Gt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nr(Gt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nr(Gt.paint_symbol["text-occlusion-opacity"]),"text-color":new nr(Gt.paint_symbol["text-color"],{runtimeType:ku,getOverride:g=>g.textColor,hasOverride:g=>!!g.textColor}),"text-halo-color":new nr(Gt.paint_symbol["text-halo-color"]),"text-halo-width":new nr(Gt.paint_symbol["text-halo-width"]),"text-halo-blur":new nr(Gt.paint_symbol["text-halo-blur"]),"text-translate":new Gs(Gt.paint_symbol["text-translate"]),"text-translate-anchor":new Gs(Gt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Gs(Gt.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Gs(Gt.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Gs(Gt.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Gs(Gt.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new nr(Gt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"})}))},jue);class XO extends su{constructor(c,m,v,N){super(c,Nue(),m,v,N,c.layout?c.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=j([]),this.hasOcclusionOpacityProperties=c.paint!==void 0&&("icon-occlusion-opacity"in c.paint||"text-occlusion-opacity"in c.paint)}_handleSpecialPaintPropertyUpdate(c){c!=="icon-occlusion-opacity"&&c!=="text-occlusion-opacity"||(this.hasOcclusionOpacityProperties=!0)}recalculate(c,m){super.recalculate(c,m),this.appearances&&this.appearances.forEach(N=>{N.recalculate(c,m,this.iconImageUseTheme)}),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const v=this.layout.get("text-writing-mode");if(v){const N=[];for(const E of v)N.indexOf(E)<0&&N.push(E);this.layout._values["text-writing-mode"]=N}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(c,m,v,N){return this._saturation===c&&this._contrast===m&&this._brightnessMin===v&&this._brightnessMax===N||(this._colorAdjustmentMatrix=function(E,P,O,B){E=Qi(E),P=ba(P);const W=b(),J=E/3,ee=1-2*J,ie=[ee,J,J,0,J,ee,J,0,J,J,ee,0,0,0,0,1],ce=.5-.5*P,ue=B-O;return S(W,[ue,0,0,0,0,ue,0,0,0,0,ue,0,O,O,O,1],[P,0,0,0,0,P,0,0,0,0,P,0,ce,ce,ce,1]),S(W,W,ie),W}(c,m,v,N),this._saturation=c,this._contrast=m,this._brightnessMin=v,this._brightnessMax=N),this._colorAdjustmentMatrix}getValueAndResolveTokens(c,m,v,N){const E=this.layout.get(c).evaluate(m,{},v,N),P=this._unevaluatedLayout._values[c];return P.isDataDriven()||Cb(P.value)||!E?E:Ake(m.properties,E)}getAppearanceValueAndResolveTokens(c,m,v,N,E){const P=c.getProperty(m);if(!P)return;const O=P.evaluate(v,{},N,E),B=c.getUnevaluatedProperties()._values[m];return B.isDataDriven()||Cb(B.value)||!O||typeof O!="string"?O:Ake(v.properties,O)}createBucket(c){return new YO(c)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const c of Nue().paint.overridableProperties){if(!XO.hasPaintOverride(this.layout,c))continue;const m=this.paint.get(c),v=new Ike(m),N=new XS(v,m.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let E=null;E=m.value.kind==="constant"||m.value.kind==="source"?new Iv("source",N):new Oy("composite",N,m.value.zoomStops,m.value.interpolationType),this.paint._values[c]=new Fy(m.property,E,m.parameters)}}_handleOverridablePaintPropertyUpdate(c,m,v){return!(!this.layout||m.isDataDriven()||v.isDataDriven())&&XO.hasPaintOverride(this.layout,c)}static hasPaintOverride(c,m){const v=c.get("text-field"),N=Nue().paint.properties[m];let E=!1;const P=O=>{for(const B of O)if(N.overrides&&N.overrides.hasOverride(B))return void(E=!0)};if(v.value.kind==="constant"&&v.value.value instanceof Qd)P(v.value.value.sections);else if(v.value.kind==="source"){const O=W=>{E||(W instanceof Hf&&oc(W.value)===hb?P(W.value.sections):W instanceof Lp?P(W.sections):W.eachChild(O))},B=v.value;B._styleExpression&&O(B._styleExpression.expression)}return E}getProgramIds(){return["symbol"]}getDefaultProgramParams(c,m,v){return{config:new wx(this,{zoom:m,lut:v}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let Lke,Dke,Oke,Rke;var kue=oa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function QO(g,c,m,v,N,E,P,O){const B=[g,c,1,m,v,1,N,E,1],W=[P,O,1],J=y([],B),[ee,ie,ce]=me(W,W,J);return _(B,B,[ee,0,0,0,ie,0,0,0,ce])}function Fke(g,c,m,v,N,E,P,O){const B=function(W,J,ee,ie,ce,ue,ke,Le){const Ie=QO(0,0,1,0,1,1,0,1),Ke=QO(W,J,ee,ie,ce,ue,ke,Le);return _(Ke,Ke,y([],Ie))}(g,c,m,v,N,E,P,O);return[B[2]/B[8]/Xs,B[5]/B[8]/Xs]}function JO(g){return[g[0],Math.min(Math.max(g[1],-xe),xe)]}class zke extends Cs{constructor(c,m,v,N){super(),this.id=c,this.dispatcher=v,this.coordinates=m.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(N),this.options=m,this._dirty=!1}load(c,m){if(this._loaded=m||!1,this.fire(new am("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return c&&(this.coordinates=c),this._loaded=!0,void this._finishLoading();this._imageRequest=ix(this.map._requestManager.transformRequest(this.url,$f.Image),(v,N)=>{this._imageRequest=null,this._loaded=!0,v?this.fire(new ox(v)):N&&(this.image=N instanceof HTMLImageElement?_l.getImageData(N):N,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,c&&(this.coordinates=c),this._finishLoading())})}loaded(){return this._loaded}updateImage(c){return c.url?(this._imageRequest&&c.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=c.url,this.load(c.coordinates,this._loaded),this):this}setTexture(c){if(!(c.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new _A(this.map.painter.context,c.handle),this.width=c.dimensions[0],this.height=c.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new am("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(c){this.map=c,this.load()}onRemove(c){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof _A||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(c){if(this.coordinates=c,this._boundsArray=void 0,this._unsupportedCoords=!1,!c.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let m=c[0][1],v=c[0][1];for(const E of c)E[1]>v&&(v=E[1]),E[1]xe?this.onNorthPole=!0:N<-xe&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const E=c.map(tt.fromLngLat);this.tileID=function(P){let O=1/0,B=1/0,W=-1/0,J=-1/0;for(const ke of P)O=Math.min(O,ke.x),B=Math.min(B,ke.y),W=Math.max(W,ke.x),J=Math.max(J,ke.y);const ee=Math.max(W-O,J-B),ie=Math.max(0,Math.floor(-Math.log2(ee))),ce=Math.pow(2,ie);let ue=Math.floor((O+W)/2*ce);return ue>1&&(ue-=1),new Ni(ie,ue,Math.floor((B+J)/2*ce))}(E),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new am("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof _A||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(c){for(const Ie in this.tiles){const Ke=this.tiles[Ie];Ke.state!=="loaded"&&(Ke.state="loaded",Ke.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const m=TA(new Ni(0,0,0),this.map.transform.projection),v=[m.projection.project(this.coordinates[0][0],this.coordinates[0][1]),m.projection.project(this.coordinates[1][0],this.coordinates[1][1]),m.projection.project(this.coordinates[2][0],this.coordinates[2][1]),m.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(Ie){const Ke=Ie[1].x-Ie[0].x,Ye=Ie[1].y-Ie[0].y,at=Ie[2].x-Ie[1].x,vt=Ie[2].y-Ie[1].y,pt=Ie[3].x-Ie[2].x,kt=Ie[3].y-Ie[2].y,Lt=Ie[0].x-Ie[3].x,$t=Ie[0].y-Ie[3].y,ls=Ke*vt-at*Ye,Wt=at*kt-pt*vt,ms=pt*$t-Lt*kt,bs=Lt*Ye-Ke*$t;return ls>0&&Wt>0&&ms>0&&bs>0||ls<0&&Wt<0&&ms<0&&bs<0}(v))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const N=TA(this.tileID,this.map.transform.projection),[E,P,O,B]=this.coordinates.map(Ie=>{const Ke=N.projection.project(Ie[0],Ie[1]);return Nke(N,Ke)._round()});this.perspectiveTransform=Fke(E.x,E.y,P.x,P.y,O.x,O.y,B.x,B.y);const W=this._boundsArray=new Rv;W.emplaceBack(E.x,E.y,0,0),W.emplaceBack(P.x,P.y,Xs,0),W.emplaceBack(B.x,B.y,0,Xs),W.emplaceBack(O.x,O.y,Xs,Xs),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=c.createVertexBuffer(W,kue.members),this.boundsSegments=co.simpleSegment(0,0,4,2);const J=[],ee=[JO((ie=this.coordinates)[0]),JO(ie[1]),JO(ie[2]),JO(ie[3])];var ie;const[ce,ue,ke,Le]=function(Ie){let Ke=Ie[0][0],Ye=Ke,at=Ie[0][1],vt=at;for(let pt=1;ptYe&&(Ye=Ie[pt][0]),Ie[pt][1]vt&&(vt=Ie[pt][1]);return[Ke,at,Ye-Ke,vt-at]}(ee);{const Ie=new Rv,[Ke,Ye,at,vt]=function(Ps){let Ls=Ps[0].x,hs=Ls,cs=Ps[0].y,Ds=cs;for(let Qs=1;Qshs&&(hs=Ps[Qs].x),Ps[Qs].yDs&&(Ds=Ps[Qs].y);return[Ls,cs,hs-Ls,Ds-cs]}(v),pt=Ps=>[(Ps.x-Ke)/at,(Ps.y-Ye)/vt],[kt,Lt,$t,ls]=v.map(pt),Wt=function(Ps,Ls,hs,cs,Ds,Qs,Vs,Dr){const dr=QO(0,0,1,0,1,1,0,1);return _(dr,dr,y([],QO(Ps,Ls,hs,cs,Ds,Qs,Vs,Dr)))}(kt[0],kt[1],Lt[0],Lt[1],$t[0],$t[1],ls[0],ls[1]);this.elevatedGlobePerspectiveTransform=Fke(kt[0],kt[1],Lt[0],Lt[1],$t[0],$t[1],ls[0],ls[1]);const ms=(Ps,Ls)=>{J.push(Ps.lng);const hs=Math.round((Ps.lng-ce)/ke*Xs),cs=Math.round((Ps.lat-ue)/Le*Xs),Ds=pt(Ls),Qs=me([],[Ds[0],Ds[1],1],Wt),Vs=Math.round(Qs[0]/Qs[2]*Xs),Dr=Math.round(Qs[1]/Qs[2]*Xs);Ie.emplaceBack(hs,cs,Vs,Dr)},bs=v[3].x-v[0].x,ws=v[3].y-v[0].y,Os=v[2].x-v[1].x,Fs=v[2].y-v[1].y;for(let Ps=0;Ps<65;Ps++){const Ls=Ps/64,hs=[v[0].x+Ls*bs,v[0].y+Ls*ws],cs=[v[1].x+Ls*Os,v[1].y+Ls*Fs],Ds=cs[0]-hs[0],Qs=cs[1]-hs[1];for(let Vs=0;Vs<65;Vs++){const Dr=Vs/64,dr={x:hs[0]+Ds*Dr,y:hs[1]+Qs*Dr};ms(m.projection.unproject(dr.x,dr.y),dr)}}this.elevatedGlobeVertexBuffer=c.createVertexBuffer(Ie,kue.members)}{this.maxLongitudeTriangleSize=0;let Ie=[],Ke=new bl;const Ye=(at,vt,pt)=>{Ke.emplaceBack(at,vt,pt);const kt=J[at],Lt=J[vt],$t=J[pt],ls=Math.min(Math.min(kt,Lt),$t),Wt=Math.max(Math.max(kt,Lt),$t)-ls;Wt>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Wt),Ie.push(ls+Wt/2)};for(let at=0;at<64;at++)for(let vt=0;vt<64;vt++){const pt=65*at+vt,kt=pt+1,Lt=pt+65,$t=Lt+1;Ye(pt,Lt,kt),Ye(kt,Lt,$t)}[Ie,Ke]=function(at,vt){const pt=Array.from({length:at.length},($t,ls)=>ls);pt.sort(($t,ls)=>at[$t]-at[ls]);const kt=[],Lt=new bl;for(let $t=0;$t{P.segments.push({vertexOffset:0,primitiveOffset:ee,vertexLength:m.segments[0].vertexLength,primitiveLength:ie,sortKey:void 0,vaos:{}})},B=.51*this.maxLongitudeTriangleSize;if(Math.abs(v[0]-N)<=B){const ee=Xi(v,0,v.length,N+B);return ee===v.length||O(ee,Ko(v,ee+1,v.length,N+360-B)-ee),P}NXs?N-Xs:N,new es(Math.trunc(N),Math.trunc(v[m+1]))}translationForInstance(c){const m=16*c,v=this.instancedDataArray.float32;return[v[m+4],v[m+5],v[m+6]]}rotationScaleForInstance(c){const m=16*c,v=this.instancedDataArray.float32;return[v[m+7],v[m+8],v[m+9],v[m+10],v[m+11],v[m+12],v[m+13],v[m+14],v[m+15]]}transformForInstance(c){const m=16*c,v=this.instancedDataArray.float32;return[v[m+7],v[m+8],v[m+9],v[m+4],v[m+10],v[m+11],v[m+12],v[m+5],v[m+13],v[m+14],v[m+15],v[m+6],0,0,0,1]}}class Mue{constructor(c){this.zoom=c.zoom,this.canonical=c.canonical,this.overscaledZ=this.canonical.z+Math.log2(c.overscaling),this.layers=c.layers,this.layerIds=this.layers.map(m=>m.fqid),this.projection=c.projection,this.index=c.index,this.worldview=c.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=c.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,v,N){}populate(c,m,v,N){this.tileToMeter=Be(v);const E=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:P,id:O,index:B,sourceLayerIndex:W}of c){const J=O??(P.properties&&P.properties.hasOwnProperty("id")?P.properties.id:void 0),ee=Ht(P,E);if(!this.layers[0]._featureFilter.filter(new Fi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ee,v))continue;const ie={id:J,sourceLayerIndex:W,index:B,geometry:E?ee.geometry:Et(P,v,N),properties:P.properties,type:P.type,patterns:{}},ce=this.addFeature(ie,ie.geometry,ee);ce&&m.featureIndex.insert(P,ie.geometry,B,W,this.index,this.instancesPerModel[ce].instancedDataArray.length,Xs/32)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const c=this.layers[0].modelManager,m=this.layers[0].scope;let v=0;for(const N of this.modelUris){const E=c.getModel(N,m);if(!E)continue;const P=this.instancesPerModel[N];if(P){const O=.5*we(E.aabb.max,E.aabb.min)*P.maxScale+P.maxXYTranslationDistance,B=Math.min(Xs,Math.max(O/this.tileToMeter,Xs/32));v=Math.max(B,v)}}return v}update(c,m,v,N){for(const E in this.instancesPerModel){const P=this.instancesPerModel[E];for(const O in c)P.idToFeaturesIndex.hasOwnProperty(O)&&(this.evaluate(P.features[P.idToFeaturesIndex[O]],c[O],P,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let c=!1;for(const m in this.instancesPerModel){const v=this.instancesPerModel[m];for(const N of v.features){const E=this.layers[0],P=N.feature,O=this.canonical,B=E.paint.get("model-rotation").evaluate(P,{},O),W=E.paint.get("model-scale").evaluate(P,{},O),J=E.paint.get("model-translation").evaluate(P,{},O);nt(N.rotation,B)&&nt(N.scale,W)&&nt(N.translation,J)||(this.evaluate(N,N.featureStates,v,!0),c=!0)}}return c}updateReplacement(c,m,v,N){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const E=m.getReplacementRegionsForTile(c.toUnwrapped(),!0);if(NO(this.activeReplacements,E))return!1;this.activeReplacements=E;let P=!1;for(const O in this.instancesPerModel){const B=this.instancesPerModel[O],W=B.instancedDataArray;for(const J of B.features){const ee=J.instancedDataOffset,ie=J.instancedDataCount;for(let ce=0;ceXs;ke=Le?ke-Xs:ke;const Ie=Math.floor(ke),Ke=Math.floor(W.float32[ue+1]);let Ye=!1;for(const at of this.activeReplacements)if(!Dje(at,v,Gke.Model,N)&&!(at.min.x>Ie||Ie>at.max.x||at.min.y>Ke||Ke>at.max.y)&&(Ye=Bje(zje(Ie,Ke,c.canonical,at.footprintTileId.canonical),at.footprint),Ye))break;W.float32[ue]=Ye?ke+Xs:ke,P=P||Ye!==Le}}}return P}isEmpty(){for(const c in this.instancesPerModel)if(this.instancesPerModel[c].instancedDataArray.length!==0)return!1;return!0}uploadPending(){return!this.uploaded}upload(c){if(!this.uploaded)for(const m in this.instancesPerModel){const v=this.instancesPerModel[m];v.instancedDataArray.length<0||v.instancedDataArray.length===0||(v.instancedDataBuffer?v.instancedDataBuffer.updateData(v.instancedDataArray):v.instancedDataBuffer=c.createVertexBuffer(v.instancedDataArray,Htt.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(c){for(const v in this.instancesPerModel){const N=this.instancesPerModel[v];N.instancedDataArray.length!==0&&N.instancedDataBuffer&&N.instancedDataBuffer.destroy()}const m=this.layers[0].modelManager;if(c&&m&&this.modelUris&&this.modelsRequested)for(const v of this.modelUris)m.removeModel(v,"",!0)}addFeature(c,m,v){const N=this.layers[0],E=N.layout.get("model-id").evaluate(v,{},this.canonical);if(!E)return ur(`modelId is not evaluated for layer ${N.id} and it is not going to get rendered.`),E;(Cue(E,!1)||this.styleDefinedModelURLs[E]!==void 0)&&(this.modelUris.includes(E)||this.modelUris.push(E)),this.instancesPerModel[E]||(this.instancesPerModel[E]=new Zke);const P=this.instancesPerModel[E],O=P.instancedDataArray,B=new Kke(v,O.length);for(const W of m)for(const J of W){if(J.x<0||J.x>=Xs||J.y<0||J.y>=Xs)continue;if(this.lookupDim!==0){const ie=(this.lookupDim-1)/Xs,ce=this.lookupDim*(J.y*ie|0)+J.x*ie|0;if(this.lookup){if(this.lookup[ce]!==0)continue;this.lookup[ce]=1}}this.instanceCount++;const ee=O.length;O.resize(ee+1),P.instancesEvaluatedElevation.push(0),O.float32[16*ee]=J.x,O.float32[16*ee+1]=J.y}return B.instancedDataCount=P.instancedDataArray.length-B.instancedDataOffset,B.instancedDataCount>0&&(c.id&&(P.idToFeaturesIndex[c.id]=P.features.length),P.features.push(B),this.evaluate(B,{},P,!1)),E}getModelUris(){return this.modelUris}evaluate(c,m,v,N){const E=this.layers[0],P=c.feature,O=this.canonical,B=c.rotation=E.paint.get("model-rotation").evaluate(P,m,O),W=c.scale=E.paint.get("model-scale").evaluate(P,m,O),J=c.translation=E.paint.get("model-translation").evaluate(P,m,O),ee=Object.assign({},E.paint.get("model-color").evaluate(P,m,O));ee.a=E.paint.get("model-color-mix-intensity").evaluate(P,m,O);const ie=[];this.maxVerticalOffset0?Math.sqrt(ce):0;v.maxScale=Math.max(Math.max(v.maxScale,W[0]),Math.max(W[1],W[2])),v.maxXYTranslationDistance=Math.max(v.maxXYTranslationDistance,ue),this.maxScale=Math.max(Math.max(this.maxScale,W[0]),Math.max(W[1],W[2])),SNe(ie,B,W);const ke=Math.round(100*ee.a)+ee.b/1.05;for(let Le=0;Le10?this.tileToMeter:Be(O,vt)),Ye[Ke+4]=J[0],Ye[Ke+5]=J[1],Ye[Ke+6]=J[2]+at,Ye[Ke+7]=ie[0],Ye[Ke+8]=ie[1],Ye[Ke+9]=ie[2],Ye[Ke+10]=ie[4],Ye[Ke+11]=ie[5],Ye[Ke+12]=ie[6],Ye[Ke+13]=ie[8],Ye[Ke+14]=ie[9],Ye[Ke+15]=ie[10],v.instancesEvaluatedElevation[Ie]=J[2]}}}let Yke,Xke;_r(Mue,"ModelBucket",{omit:["layers"]}),_r(Zke,"PerModelAttributes"),_r(Kke,"ModelFeature");class HC{constructor(c,m,v){this._demTile=c,this._dem=this._demTile.dem,this._scale=m,this._offset=v}static create(c,m,v){const N=v||c.findDEMTileFor(m);if(!N||!N.dem)return;const E=N.dem,P=N.tileID,O=1<W.fqid),this.stateDependentLayerIds=this.layers.filter(W=>W.isStateDependent()).map(W=>W.id),this.modelTraits|=OC.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,N&&(this.modelTraits|=OC.HasMapboxMeshFeatures),E&&(this.modelTraits|=OC.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=P,this.worldview=B,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const W of m)this.nodesInfo.push(new tSe(W)),Jke(W,O.featureIndexArray.length,O.grid),O.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,O.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(c,m){for(const v of this.getNodesInfo()){const N=v.node;N.footprint&&m.push({footprint:N.footprint,id:c})}}updateAppearances(c,m,v,N){}update(c){const m=Object.keys(c).length!==0;if(m&&!this.stateDependentLayers.length)return;const v=m?this.stateDependentLayers:this.layers;if(!an(c,this.states))for(const N of v)this.evaluate(N,c);this.states=structuredClone(c)}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(c){if(!this.needsUpload)return;const m=this.getNodesInfo();for(const v of m){const N=v.node;this.uploaded?this.updatePbrBuffer(N):Jde(N,c,!0)}for(const v of m)OO(v.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(c){let m=!1;if(!c.meshes)return m;for(const v of c.meshes)v.pbrBuffer&&(v.pbrBuffer.updateData(v.featureArray),m=!0);return m}needsReEvaluation(c,m,v){const N=c.transform.projectionOptions,E=c.style.getBrightness(),P=this.brightness!==E;if(!this.uploaded||this.dirty||N.name!==this.projection.name||RA(v.paint.get("model-color").value,P)||RA(v.paint.get("model-color-mix-intensity").value,P)||RA(v.paint.get("model-roughness").value,P)||RA(v.paint.get("model-emissive-strength").value,P)||RA(v.paint.get("model-height-based-emissive-strength-multiplier").value,P)){this.projection=N,this.brightness=E;const O=this.getNodesInfo();for(const B of O)B.state=null;return!0}return!1}evaluateTransform(c,m){if(c.transform.zoom===this.zoom)return;this.zoom=c.transform.zoom;const v=this.getNodesInfo(),N=this.id.canonical;for(const E of v){const P=E.feature;E.evaluatedTranslation=m.paint.get("model-translation").evaluate(P,{},N),E.evaluatedScale=m.paint.get("model-scale").evaluate(P,{},N)}}evaluate(c,m){const v=this.getNodesInfo();for(const N of v){if(!N.node.meshes)continue;const E=N.feature,P=m&&m[E.id];if(an(P,N.state))continue;N.state=structuredClone(P);const O=N.node.meshes&&N.node.meshes[0].featureData,B=N.evaluatedColor[2],W=N.evaluatedRMEA[2],J=this.id.canonical;if(N.hasTranslucentParts=!1,O){for(let ee=0;ee=pt)continue;const Ps=Tue[Fs],Ls=Math.abs(Ps);Ls>Wt&&(ls=Ps,Wt=Ls,ms=Os,bs=ws)}if(Wt>.1){const ws=1-(pt+.5*Math.abs(ms*bs))/ue;let Os=m._dem.get(Lt,kt)+ls*ws;const Fs=m._dem.get(Lt+ms,kt+bs),Ps=m._dem.get(Lt-ms,kt-bs,!0);(Os-Fs)*(Os-Ps)>0&&(Os=(Fs+Ps)/2),Tue[$t]=m._dem.set(Lt,kt,Os),Zb[$t]=pt}}}}}O&&(m._demTile.needsDEMTextureUpload=!0,m._dem._timestamp=_l.now())}setFilter(c){this.filter=c?iC(c):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(c=>this.filter.filter(new Fi(this.id.overscaledZ,{worldview:this.worldview}),c.feature,this.id.canonical)):this.nodesInfo}destroy(){const c=this.getNodesInfo();for(const m of c)OO(m.node),eue(m.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(c,m){if(m.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=m.updateTime;const v=m.getReplacementRegionsForTile(c.toUnwrapped());for(const N of this.getNodesInfo()){const E=N.node.footprint;N.hiddenByReplacement=!!E&&!v.find(P=>P.footprint===E)}}getHeightAtTileCoord(c,m){const v=[],N=[0,0,0],E=j([]);for(const P of this.getNodesInfo()){const O=P.node.meshes[0],B=O.transformedAabb;if(cB.max[0]||m>B.max[1])continue;if(P.node.hidden===!0)return{height:1/0,maxHeight:P.feature.properties.height,hidden:!1,verticalScale:P.evaluatedScale[2]};k(E,P.node.globalMatrix),N[0]=c,N[1]=m,Rt(N,N,E);const W=(N[0]-O.aabb.min[0])/(O.aabb.max[0]-O.aabb.min[0])*Wb|0,J=Math.min(63,(N[1]-O.aabb.min[1])/(O.aabb.max[1]-O.aabb.min[1])*Wb|0)*Wb+Math.min(63,W),ee=O.heightmap[J];if(!(ee<0&&P.node.footprint))return P.hiddenByReplacement?void 0:{height:ee,maxHeight:P.feature.properties.height,hidden:!1,verticalScale:P.evaluatedScale[2]};if(P.node.footprint.grid.query(new es(c,m),new es(c,m),v),v.length>0)return{height:void 0,maxHeight:P.feature.properties.height,hidden:P.hiddenByReplacement,verticalScale:P.evaluatedScale[2]}}}}function RA(g,c){return g instanceof Iv&&!g.isLightConstant&&c}function jrt(g,c,m,v,N,E,P,O){let B=(61440&c|(61440&c)>>4)>>8,W=(3840&c|(3840&c)>>4)>>4,J=240&c|(240&c)>>4;m[3]>0&&(B=Hr(B,255*m[0],m[3]),W=Hr(W,255*m[1],m[3]),J=Hr(J,255*m[2],m[3]));const ee=B<<8|W,ie=J<<8|Math.floor(255*v[3]),ce=function(pt){const kt=ye(pt,0,2);return Math.min(Math.round(.5*kt*255),255)}(v[2])<<8|15*v[0]<<4|15*v[1],ue=ye(N[0],0,1),ke=ye(N[1],0,1),Le=ye(N[2],0,1),Ie=ye(N[3],0,1);let Ke,Ye,at,vt;if(ue!==ke&&P!==E&&ke!==ue){const pt=P-E;Ye=1/(pt*(ke-ue)),at=-(E+pt*ue)/(pt*(ke-ue));const kt=ye(N[4],-1,1);vt=Math.pow(10,kt),Ke=255*Le<<8|255*Ie}else Ke=65535,Ye=0,at=1,vt=1;if(g.emplaceBack(ee,ie,ce,Ke,Ye,at,vt),O){const pt=O.length;O.clear();for(let kt=0;kt>16&65535,J=E?B>>16&65535:65535&B,ee=(15&J)<8?15&J:0,ie=g.evaluatedRMEA[ee],ce=g.evaluatedColor[ee],ue=g.emissionHeightBasedParams[ee];let ke;if(O&&ee===2&&v.lights&&(ke=new xC,ke.resize(10*v.lights.length)),jrt(P.featureArray,W,ce,ie,ue,P.aabb.min[2],P.aabb.max[2],ke),ke&&O){O=!1;const Le=v.meshes[v.lightMeshIndex];Le.featureArray=ke,Le.featureArray._trim()}}P.featureArray._trim(),N++}}_r(t8,"Tiled3dModelBucket",{omit:["layers"]}),_r(tSe,"Tiled3dModelFeature");const krt=["id","tile","layer","source","sourceLayer","state"];class Yb{constructor(c,m,v,N,E){this.type="Feature",this._vectorTileFeature=c,this._z=m,this._x=v,this._y=N,this.properties=c?c.properties:{},this.id=E}clone(){const c=new Yb(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(c.state=Object.assign({},this.state)),this.layer&&(c.layer=Object.assign({},this.layer)),this.source&&(c.source=this.source),this.sourceLayer&&(c.sourceLayer=this.sourceLayer),c}get geometry(){return this._geometry===void 0&&this._vectorTileFeature&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(c){this._geometry=c}toJSON(){const c={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const m of krt)this[m]!==void 0&&(c[m]=this[m]);return c}}class Xb extends Cs{constructor(c,m,v,N){super(),this.id=c,this.type="model",this.models=[],this._loaded=!1,this._options=m,this._modelsInfo=new Map}load(){const c=[];for(const m in this._options.models){const v=this._options.models[m],N=this._modelsInfo.get(m);if(N){const E=N.model;E.position=v.position!=null?new x(v.position[0],v.position[1]):new x(0,0),E.orientation=v.orientation!=null?v.orientation:[0,0,0],N.modelSpec=v,Xb.applyModelSpecification(E,v),E.computeBoundsAndApplyParent(),this.models.push(E)}else{const E=wNe(this.map._requestManager.transformRequest(v.uri,$f.Model).url).then(P=>{if(!P)return;const O=sue(P),B=new CNe(m,v.uri,v.position,v.orientation,O);Xb.applyModelSpecification(B,v),B.computeBoundsAndApplyParent(),this.models.push(B),this._modelsInfo.set(m,{modelSpec:v,model:B})}).catch(P=>{this.fire(new ox(new Error(`Could not load model ${m} from ${v.uri}: ${P.message}`)))});c.push(E)}}Promise.allSettled(c).then(()=>{this._loaded=!0,this.fire(new am("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(m=>{this._loaded=!0,this.fire(new ox(new Error(`Could not load models: ${m.message}`)))})}static applyModelSpecification(c,m){m.nodeOverrides&&Xb.convertNodeOverrides(c,m.nodeOverrides),m.materialOverrides&&Xb.convertMaterialOverrides(c,m.materialOverrides),m.nodeOverrideNames&&(c.nodeOverrideNames=[...m.nodeOverrideNames]),m.materialOverrideNames&&(c.materialOverrideNames=[...m.materialOverrideNames]),m.featureProperties&&(c.featureProperties=m.featureProperties)}static convertNodeOverrides(c,m){if(Array.isArray(m)&&m.every(v=>typeof v=="string")){c.nodeOverrideNames=[];for(const v of m)c.nodeOverrideNames.push(v)}else Object.entries(m).forEach(([v,N])=>{const E={orientation:[0,0,0]};if(N.hasOwnProperty("orientation")){const P=N.orientation;P&&(E.orientation=P)}c.nodeOverrides.set(v,E)})}static convertMaterialOverrides(c,m){if(Array.isArray(m)&&m.every(v=>typeof v=="string")){c.materialOverrideNames=[];for(const v of m)c.materialOverrideNames.push(v)}else Object.entries(m).forEach(([v,N])=>{const E={color:new Fr(1,1,1),colorMix:0,emissionStrength:0,opacity:1},P=N["model-color"];P!==void 0&&(E.color.r=P[0],E.color.g=P[1],E.color.b=P[2]);const O=N["model-color-mix-intensity"];O!==void 0&&(E.colorMix=O);const B=N["model-emissive-strength"];B!==void 0&&(E.emissionStrength=B);const W=N["model-opacity"];W!==void 0&&(E.opacity=W),c.materialOverrides.set(v,E)})}onAdd(c){this.map=c,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(c,m){}serialize(){return this._options}setProperty(c,m){return!1}reload(){const c=Ym(this.id,this.scope);this.map.style.clearSource(c),this.models=[],this._modelsInfo.clear(),this._loaded=!1,this.load()}setModels(c){this.models=[];const m=new Map;for(const v in c){const N=c[v];if(this._modelsInfo.has(v)){const E=this._modelsInfo.get(v);E&&E.modelSpec.uri===N.uri&&m.set(v,E)}}this._modelsInfo=m,this._options.models=c,this._loaded=!1,this.load()}}function Aue(g,c,m,v){const N=1<at.polygon).flat());const Le=ce?O:null,[Ie,Ke]=dNe(E,v,ee,J,W,P,Le,ie,ue,E.center.lat,g.tileID.canonical),Ye=g.queryGeometry;return cNe(Ie,Ke,Ye.isPointQuery()?Ye.screenBounds:Ye.screenGeometry)}},building:class extends su{constructor(g,c,m,v){super(g,{layout:LNe||(LNe=new wo({visibility:new Gs(Gt.layout_building.visibility),"building-facade":new nr(Gt.layout_building["building-facade"]),"building-facade-floors":new nr(Gt.layout_building["building-facade-floors"]),"building-facade-unit-width":new nr(Gt.layout_building["building-facade-unit-width"]),"building-facade-window":new nr(Gt.layout_building["building-facade-window"]),"building-roof-shape":new nr(Gt.layout_building["building-roof-shape"]),"building-height":new nr(Gt.layout_building["building-height"]),"building-base":new nr(Gt.layout_building["building-base"]),"building-flood-light-wall-radius":new nr(Gt.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new nr(Gt.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new nr(Gt.layout_building["building-flip-roof-orientation"])})),paint:DNe||(DNe=new wo({"building-opacity":new Gs(Gt.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Gs(Gt.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Gs(Gt.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Gs(Gt.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Gs(Gt.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Gs(Gt.paint_building["building-vertical-scale"]),"building-cast-shadows":new Gs(Gt.paint_building["building-cast-shadows"]),"building-color":new nr(Gt.paint_building["building-color"]),"building-emissive-strength":new nr(Gt.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Gs(Gt.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Gs(Gt.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new Gs(Gt.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Gs(Gt.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Gs(Gt.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"})}))},c,m,v),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(g){return new INe(g)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(g){return!0}queryRadius(g){return 0}queryIntersectsFeature(g,c,m,v,N,E,P,O,B){let W=this.layout.get("building-height").evaluate(c,m);const J=this.layout.get("building-base").evaluate(c,m),ee=g.tile.getBucket(this).getFootprint(c);if(ee){if(ee.hiddenFlags!==0)return!1;W=ee.height}const[ie,ce]=dNe(E,v,J,W,new es(0,0),P,null,[0,0],1,E.center.lat,g.tileID.canonical),ue=g.queryGeometry;return cNe(ie,ce,ue.isPointQuery()?ue.screenBounds:ue.screenGeometry)}},line:class extends su{constructor(g,c,m,v){const N=HNe();super(g,N,c,m,v),N.layout&&(this.layout=new zy(N.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(g){if(g==="line-gradient"){const c=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=c._styleExpression&&c._styleExpression.expression instanceof bb,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(g,c){super.recalculate(g,c),this.paint._values["line-floorwidth"]=(()=>{if(wA)return wA;const m=HNe();return wA=new bst(m.paint.properties["line-width"].specification),wA.useIntegerZoom=!0,wA})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,g)}createBucket(g){return new aue(g)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(g,c,m){const v=UNe(this);return{config:new wx(this,{zoom:c,lut:m}),defines:v,overrideFog:!1}}queryRadius(g){const c=g,m=WNe(gd("line-width",this,c),gd("line-gap-width",this,c)),v=gd("line-offset",this,c);return m/2+Math.abs(v)+Ic(this.paint.get("line-translate"))}queryIntersectsFeature(g,c,m,v,N,E){if(g.queryGeometry.isAboveHorizon)return!1;const P=jh(g.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),E.angle,g.pixelToTileUnitsFactor),O=g.pixelToTileUnitsFactor/2*WNe(this.paint.get("line-width").evaluate(c,m),this.paint.get("line-gap-width").evaluate(c,m)),B=this.paint.get("line-offset").evaluate(c,m);return B&&(v=function(W,J){const ee=[],ie=new es(0,0);for(let ce=0;ce=3){for(let ue=0;ue>16&255)/255,(g>>8&255)/255,(255&g)/255,1)}function Brt(g,c,m){g===1?(c.rgb_color=a8(m.readVarint()),c.paint="rgb_color"):g===2?(c.linear_gradient_idx=m.readVarint(),c.paint="linear_gradient_idx"):g===3?(c.radial_gradient_idx=m.readVarint(),c.paint="radial_gradient_idx"):g===5?m.readPackedFloat(c.dasharray):g===6?c.dashoffset=m.readFloat():g===7?c.miterlimit=m.readFloat():g===8?c.opacity=m.readVarint():g===9?c.width=m.readFloat():g===10?c.linecap=m.readVarint():g===11&&(c.linejoin=m.readVarint())}function $rt(g,c,m){g===1?c.transform=n8(m,m.readVarint()+m.pos):g===2?c.spread_method=m.readVarint():g===3?c.stops.push(aSe(m,m.readVarint()+m.pos)):g===4?c.x1=m.readFloat():g===5?c.y1=m.readFloat():g===6?c.x2=m.readFloat():g===7&&(c.y2=m.readFloat())}function aSe(g,c){return g.readFields(qrt,{offset:0,opacity:255,rgb_color:Eue},c)}function qrt(g,c,m){g===1?c.offset=m.readFloat():g===2?c.opacity=m.readVarint():g===3&&(c.rgb_color=a8(m.readVarint()))}function Urt(g,c,m){g===1?c.transform=n8(m,m.readVarint()+m.pos):g===2?c.spread_method=m.readVarint():g===3?c.stops.push(aSe(m,m.readVarint()+m.pos)):g===4?c.cx=m.readFloat():g===5?c.cy=m.readFloat():g===6?c.r=m.readFloat():g===7?c.fx=m.readFloat():g===8?c.fy=m.readFloat():g===9&&(c.fr=m.readFloat())}function Vrt(g,c,m){g===1?c.transform=n8(m,m.readVarint()+m.pos):g===2?c.clip_path_idx=m.readVarint():g===3&&c.children.push(r8(m,m.readVarint()+m.pos))}function Hrt(g,c,m){g===1?c.left=c.top=m.readFloat():g===2?c.width=c.height=m.readFloat():g===3?c.top=m.readFloat():g===4?c.height=m.readFloat():g===5?c.mask_type=m.readVarint():g===6?c.mask_idx=m.readVarint():g===7&&c.children.push(r8(m,m.readVarint()+m.pos))}class Wrt{static calculate(c={},m=[]){const v=new Map,N=new Map;if(Object.keys(c).length===0)return v;m.forEach(E=>{N.set(E.name,E.rgb_color||new Fr(0,0,0))});for(const[E,P]of Object.entries(c))N.has(E)?v.set(N.get(E).toString(),P):console.warn(`Ignoring unknown image variable "${E}"`);return v}}function WC(g,c=255,m){const v=c/255,N=g.toString(),E=m.has(N)?m.get(N).clone():g.clone();return E.a*=v,E.toString()}function zA(g,c){if(!sm()){const m=document.createElement("canvas");return m.width=g,m.height=c,m}return new OffscreenCanvas(g,c)}let Lue,BA=null;function Due(g,c,m,v,N){for(const E of v.children)iSe(g,c,m,E,N)}function iSe(g,c,m,v,N){v.group?(g.save(),function(E,P,O,B,W){const J=B.mask_idx!=null?O.masks[B.mask_idx]:null,ee=B.clip_path_idx!=null?O.clip_paths[B.clip_path_idx]:null;if(B.transform&&(P=GC(B.transform).preMultiplySelf(P)),!function(ue,ke,Le){return ue.opacity!==255||ke||Le}(B,ee!=null,J!=null))return void Due(E,P,O,B,W);const ie=zA(E.canvas.width,E.canvas.height),ce=ie.getContext("2d");Due(ce,P,O,B,W),ee&&mSe(ce,P,O,ee),J&&pSe(ce,P,O,J,W),E.globalAlpha=B.opacity/255,E.drawImage(ie,0,0)}(g,c,m,v.group,N),g.restore()):v.path&&(g.save(),function(E,P,O,B,W){E.setTransform(P),B.paint_order===Mrt.PAINT_ORDER_FILL_AND_STROKE?(oSe(E,O,B,W),cSe(E,O,B,W)):(cSe(E,O,B,W),oSe(E,O,B,W))}(g,c,m,v.path,N),g.restore())}function oSe(g,c,m,v){const N=m.fill;if(!N)return;const E=N.opacity/255;switch(g.save(),g.beginPath(),fSe(m,g),N.paint){case"rgb_color":g.fillStyle=WC(N.rgb_color,N.opacity,v);break;case"linear_gradient_idx":{const P=c.linear_gradients[N.linear_gradient_idx];P.transform&&g.setTransform(GC(P.transform).preMultiplySelf(g.getTransform())),g.fillStyle=dSe(g,P,E,v);break}case"radial_gradient_idx":{const P=c.radial_gradients[N.radial_gradient_idx];P.transform&&g.setTransform(GC(P.transform).preMultiplySelf(g.getTransform())),g.fillStyle=uSe(g,P,E,v)}}g.fill(lSe(m)),g.restore()}function lSe(g){return g.rule===Pue.PATH_RULE_NON_ZERO?"nonzero":g.rule===Pue.PATH_RULE_EVEN_ODD?"evenodd":void 0}function cSe(g,c,m,v){const N=m.stroke;if(!N)return;const E=gSe(m);g.lineWidth=N.width,g.miterLimit=N.miterlimit,g.setLineDash(N.dasharray),g.lineDashOffset=N.dashoffset;const P=N.opacity/255;switch(N.paint){case"rgb_color":g.strokeStyle=WC(N.rgb_color,N.opacity,v);break;case"linear_gradient_idx":g.strokeStyle=dSe(g,c.linear_gradients[N.linear_gradient_idx],P,v,!0);break;case"radial_gradient_idx":g.strokeStyle=uSe(g,c.radial_gradients[N.radial_gradient_idx],P,v,!0)}switch(N.linejoin){case s8.LINE_JOIN_MITER_CLIP:case s8.LINE_JOIN_MITER:g.lineJoin="miter";break;case s8.LINE_JOIN_ROUND:g.lineJoin="round";break;case s8.LINE_JOIN_BEVEL:g.lineJoin="bevel"}switch(N.linecap){case Iue.LINE_CAP_BUTT:g.lineCap="butt";break;case Iue.LINE_CAP_ROUND:g.lineCap="round";break;case Iue.LINE_CAP_SQUARE:g.lineCap="square"}g.stroke(E)}function dSe(g,c,m,v,N=!1){if(c.stops.length===1){const ie=c.stops[0];return WC(ie.rgb_color,ie.opacity*m,v)}const{x1:E,y1:P,x2:O,y2:B}=c;let W=new DOMPoint(E,P),J=new DOMPoint(O,B);if(N){const ie=GC(c.transform);W=ie.transformPoint(W),J=ie.transformPoint(J)}const ee=g.createLinearGradient(W.x,W.y,J.x,J.y);for(const ie of c.stops)ee.addColorStop(ie.offset,WC(ie.rgb_color,ie.opacity*m,v));return ee}function uSe(g,c,m,v,N=!1){if(c.stops.length===1){const Ie=c.stops[0];return WC(Ie.rgb_color,Ie.opacity*m,v)}const E=GC(c.transform),{fx:P,fy:O,fr:B,cx:W,cy:J,r:ee}=c;let ie=new DOMPoint(P,O),ce=new DOMPoint(W,J),ue=B,ke=ee;if(N){ie=E.transformPoint(ie),ce=E.transformPoint(ce);const Ie=(E.a+E.d)/2;ue=B*Ie,ke=c.r*Ie}const Le=g.createRadialGradient(ie.x,ie.y,ue,ce.x,ce.y,ke);for(const Ie of c.stops)Le.addColorStop(Ie.offset,WC(Ie.rgb_color,Ie.opacity*m,v));return Le}function hSe(g,c,m,v){const N=v.transform?GC(v.transform).preMultiplySelf(c):c,E=zA(g.canvas.width,g.canvas.height),P=E.getContext("2d");for(const B of v.children)if(B.group)hSe(P,N,m,B.group);else if(B.path){const W=B.path,J=new Path2D;J.addPath(gSe(W),N),P.fill(J,lSe(W))}const O=v.clip_path_idx!=null?m.clip_paths[v.clip_path_idx]:null;O&&mSe(P,N,m,O),g.globalCompositeOperation="source-over",g.drawImage(E,0,0)}function mSe(g,c,m,v){const N=zA(g.canvas.width,g.canvas.height);hSe(N.getContext("2d"),c,m,v),g.globalCompositeOperation="destination-in",g.drawImage(N,0,0)}function pSe(g,c,m,v,N){if(v.children.length===0)return;const E=v.mask_idx!=null?m.masks[v.mask_idx]:null;E&&pSe(g,c,m,E,N);const P=g.canvas.width,O=g.canvas.height,B=zA(P,O),W=B.getContext("2d"),J=v.width,ee=v.height,ie=v.left,ce=v.top,ue=new Path2D,ke=new Path2D;ke.rect(ie,ce,J,ee),ue.addPath(ke,c),W.clip(ue);for(const Ke of v.children)iSe(W,c,m,Ke,N);const Le=W.getImageData(0,0,P,O),Ie=Le.data;if(v.mask_type===sSe.MASK_TYPE_LUMINANCE)for(let Ke=0;Kec[P])return null}else{const O=1/v[P];let B=(g[P]-m[P])*O,W=(c[P]-m[P])*O;if(B>W){const J=B;B=W,W=J}if(B>N&&(N=B),WE)return null}return N}function vSe(g,c,m,v,N,E,P,O,B,W,J){const ee=v-g,ie=N-c,ce=E-m,ue=P-g,ke=O-c,Le=B-m,Ie=J[1]*Le-J[2]*ke,Ke=J[2]*ue-J[0]*Le,Ye=J[0]*ke-J[1]*ue,at=ee*Ie+ie*Ke+ce*Ye;if(Math.abs(at)<1e-15)return null;const vt=1/at,pt=W[0]-g,kt=W[1]-c,Lt=W[2]-m,$t=(pt*Ie+kt*Ke+Lt*Ye)*vt;if($t<0||$t>1)return null;const ls=kt*ce-Lt*ie,Wt=Lt*ee-pt*ce,ms=pt*ie-kt*ee,bs=(J[0]*ls+J[1]*Wt+J[2]*ms)*vt;return bs<0||$t+bs>1?null:(ue*ls+ke*Wt+Le*ms)*vt}function _Se(g,c,m){return(g-c)/(m-c)}function bSe(g,c,m,v,N,E,P,O,B){const W=1<{const Ke=Le?1:0,Ye=(ce+1)*ke-Ke,at=ue*ke,vt=(ue+1)*ke-Ke;Ie[0]=ce*ke,Ie[1]=at,Ie[2]=Ye,Ie[3]=vt};let ee=new xSe(B);const ie=[];for(let ce=0;ce=1;B/=2){const ce=O[O.length-1];ee=new xSe(B);for(let ue=0;ue0;){const{idx:ue,t:ke,nodex:Le,nodey:Ie,depth:Ke}=ce.pop();if(this.leaves[ue]){bSe(Le,Ie,Ke,c,m,v,N,ee,ie);const at=1<=Fs[2])return ke}continue}let Ye=0;for(let at=0;at=W[J[Lt]]&&(J.splice(Lt,0,at),kt=!0);kt||(J[Ye]=at),Ye++}}for(let at=0;at=this.dim+1||m<-1||m>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(m+1)*this.stride+(c+1)}static pack(c,m){const v=[0,0,0,0],N=o8.getUnpackVector(m);let E=Math.floor((c+N[3])/N[2]);return v[2]=E%256,E=Math.floor(E/256),v[1]=E%256,E=Math.floor(E/256),v[0]=E,v}getPixels(){return new xje({width:this.stride,height:this.stride},this.pixels)}backfillBorder(c,m,v){if(this.dim!==c.dim)throw new Error("dem dimension mismatch");let N=m*this.dim,E=m*this.dim+this.dim,P=v*this.dim,O=v*this.dim+this.dim;switch(m){case-1:N=E-1;break;case 1:E=N+1}switch(v){case-1:P=O-1;break;case 1:O=P+1}const B=-m*this.dim,W=-v*this.dim;for(let J=P;J=1;v--){const N=v===1?1:0,E=v===2?1:0;for(let P=0;P>>1^-(1&g[c]);return g}function int(g,c){switch(c){case"uint32":return g;case"uint16":for(let m=0;m>4|(61440&v)>>8|(240&N)<<4|61440&N,g[m+1]=15&v|(3840&v)>>4|(15&N)<<8|(3840&N)<<4}return g;case"uint8":for(let m=0;m>6|(192&N)>>4|(192&E)>>2|192&P,g[m+1]=(48&v)>>4|(48&N)>>2|48&E|(48&P)<<2,g[m+2]=(12&v)>>2|12&N|(12&E)<<2|(12&P)<<4,g[m+3]=3&v|(3&N)<<2|(3&E)<<4|(3&P)<<6}return g;default:throw new Error(`Invalid pixel format, "${c}"`)}}_r(o8,"DEMData"),_r(wSe,"DemMinMaxQuadTree",{omit:["dem"]});var ep=Uint8Array,$A=Uint16Array,ont=Int32Array,NSe=new ep([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),kSe=new ep([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),lnt=new ep([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),SSe=function(g,c){for(var m=new $A(31),v=0;v<31;++v)m[v]=c+=1<>1|(21845&Wl)<<1;TSe[Wl]=((65280&(KC=(61680&(KC=(52428&KC)>>2|(13107&KC)<<2))>>4|(3855&KC)<<4))>>8|(255&KC)<<8)>>1}var qA=function(g,c,m){for(var v=g.length,N=0,E=new $A(c);N>B]=W;return P},UA=new ep(288);for(Wl=0;Wl<144;++Wl)UA[Wl]=8;for(Wl=144;Wl<256;++Wl)UA[Wl]=9;for(Wl=256;Wl<280;++Wl)UA[Wl]=7;for(Wl=280;Wl<288;++Wl)UA[Wl]=8;var ASe=new ep(32);for(Wl=0;Wl<32;++Wl)ASe[Wl]=5;var unt=qA(UA,9),hnt=qA(ASe,5),Rue=function(g){for(var c=g[0],m=1;mc&&(c=g[m]);return c},cg=function(g,c,m){var v=c/8|0;return(g[v]|g[v+1]<<8)>>(7&c)&m},Fue=function(g,c){var m=c/8|0;return(g[m]|g[m+1]<<8|g[m+2]<<16)>>(7&c)},mnt=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],dg=function(g,c,m){var v=new Error(c||mnt[g]);if(v.code=g,Error.captureStackTrace&&Error.captureStackTrace(v,dg),!m)throw v;return v},pnt=new ep(0),fnt=typeof TextDecoder<"u"&&new TextDecoder;try{fnt.decode(pnt,{stream:!0})}catch{}const gnt={gzip_data:"gzip"};class Up extends Error{constructor(c){super(c),this.name="MRTError"}}const xnt={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},ESe={uint32:1,uint16:2,uint8:4},ynt={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let zue;class l8{constructor(c=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=c}getLayer(c){const m=this.layers[c];if(!m)throw new Up(`Layer '${c}' not found`);return m}getHeaderLength(c){const m=new Uint8Array(c),v=new DataView(c);if(m[0]!==13)throw new Up("File is not a valid MRT.");return v.getUint32(1,!0)}parseHeader(c){const m=new Uint8Array(c),v=this.getHeaderLength(c);if(m.length= ${v} but got buffer of length ${m.length}`);const N=new zue(m.subarray(0,v)).readFields(Yrt,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==N.x||this.y!==N.y||this.z!==N.z))throw new Up(`Invalid attempt to parse header ${N.z}/${N.x}/${N.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=N.x,this.y=N.y,this.z=N.z;for(const E of N.layers)this.layers[E.name]=new PSe(E,{cacheSize:this._cacheSize});return this}createDecodingTask(c){const m=[],v=this.getLayer(c.layerName);for(let N of c.blockIndices){const E=v.dataIndex[N],P=E.firstByte-c.firstByte,O=E.lastByte-c.firstByte;if(v._blocksInProgress.has(N))continue;const B={layerName:v.name,firstByte:P,lastByte:O,pixelFormat:v.pixelFormat,blockIndex:N,blockShape:[E.bands.length].concat(v.bandShape),buffer:v.buffer,codec:E.codec.codec,filters:E.filters.map(W=>W.filter)};v._blocksInProgress.add(N),m.push(B)}return new ISe(m,()=>{m.forEach(N=>v._blocksInProgress.delete(N.blockIndex))},(N,E)=>{if(m.forEach(P=>v._blocksInProgress.delete(P.blockIndex)),N)throw N;E.forEach(P=>{this.getLayer(P.layerName).processDecodedData(P)})})}}class PSe{constructor({version:c,name:m,units:v,tileSize:N,pixelFormat:E,buffer:P,dataIndex:O},B){if(this.version=c,this.version!==1)throw new Up(`Cannot parse raster layer encoded with MRT version ${c}`);this.name=m,this.units=v,this.tileSize=N,this.buffer=P,this.pixelFormat=xnt[E],this.dataIndex=O,this.bandShape=[N+2*P,N+2*P,ESe[this.pixelFormat]],this._decodedBlocks=new i8(B?B.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return ESe[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:c})=>c).flat()}processDecodedData(c){const m=c.blockIndex.toString();this._decodedBlocks.get(m)||this._decodedBlocks.put(m,c.data)}getBlockForBand(c){let m=0;switch(typeof c){case"string":for(const[v,N]of this.dataIndex.entries()){for(const[E,P]of N.bands.entries())if(P===c)return{bandIndex:m+E,blockIndex:v,blockBandIndex:E};m+=N.bands.length}break;case"number":for(const[v,N]of this.dataIndex.entries()){if(c>=m&&cthis.cacheSize)throw new Up(`Number of blocks to decode (${E.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:m,lastByte:v,blockIndices:N}}hasBand(c){const{blockIndex:m}=this.getBlockForBand(c);return m>=0}hasDataForBand(c){const{blockIndex:m}=this.getBlockForBand(c);return m>=0&&!!this._decodedBlocks.get(m.toString())}getBandView(c){const{blockIndex:m,blockBandIndex:v}=this.getBlockForBand(c);if(m<0)throw new Up(`Band not found: ${JSON.stringify(c)}`);const N=this._decodedBlocks.get(m.toString());if(!N)throw new Up(`Data for band ${JSON.stringify(c)} of layer "${this.name}" not decoded.`);const E=this.dataIndex[m],P=this.bandShape.reduce((W,J)=>W*J,1),O=v*P,B=N.subarray(O,O+P);return{data:B,bytes:new Uint8Array(B.buffer).subarray(B.byteOffset,B.byteOffset+B.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:E.offset,scale:E.scale}}}l8.setPbf=function(g){zue=g};class ISe{constructor(c,m,v){this.tasks=c,this._onCancel=m,this._onComplete=v,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(c,m){this._finalized||(this._onComplete(c,m),this._finalized=!0)}}l8.performDecoding=function(g,c){const m=new Uint8Array(g);return Promise.all(c.tasks.map(v=>{const{layerName:N,firstByte:E,lastByte:P,pixelFormat:O,blockShape:B,blockIndex:W,filters:J,codec:ee}=v,ie=m.subarray(E,P+1),ce=new Uint32Array(B[0]*B[1]*B[2]);let ue;if(ee!=="gzip_data")throw new Up(`Unhandled codec: ${ee}`);return ue=function(ke,Le){if(!globalThis.DecompressionStream&&Le==="gzip_data")return Promise.resolve(((at=function(kt){kt[0]==31&&kt[1]==139&&kt[2]==8||dg(6,"invalid gzip data");var Lt=kt[3],$t=10;4&Lt&&($t+=2+(kt[10]|kt[11]<<8));for(var ls=(Lt>>3&1)+(Lt>>4&1);ls>0;ls-=!kt[$t++]);return $t+(2&Lt)}(Ye=ke))+8>Ye.length&&dg(6,"invalid gzip data"),function(kt,Lt,$t,ls){var Wt=kt.length;if(!Wt||Lt.f&&!Lt.l)return $t||new ep(0);var ms=!$t,bs=ms||Lt.i!=2,ws=Lt.i;ms&&($t=new ep(3*Wt));var Os,Fs,Ps=function(bi){var Wa=$t.length;if(bi>Wa){var Ja=new ep(Math.max(2*Wa,bi));Ja.set($t),$t=Ja}},Ls=Lt.f||0,hs=Lt.p||0,cs=Lt.b||0,Ds=Lt.l,Qs=Lt.d,Vs=Lt.m,Dr=Lt.n,dr=8*Wt;do{if(!Ds){Ls=cg(kt,hs,1);var yr=cg(kt,hs+1,3);if(hs+=3,!yr){var kr=kt[(ps=4+((hs+7)/8|0))-4]|kt[ps-3]<<8,Hn=ps+kr;if(Hn>Wt){ws&&dg(0);break}bs&&Ps(cs+kr),$t.set(kt.subarray(ps,Hn),cs),Lt.b=cs+=kr,Lt.p=hs=8*Hn,Lt.f=Ls;continue}if(yr==1)Ds=unt,Qs=hnt,Vs=9,Dr=5;else if(yr==2){var Ws=cg(kt,hs,31)+257,Sr=cg(kt,hs+10,15)+4,mn=Ws+cg(kt,hs+5,31)+1;hs+=14;for(var fa=new ep(mn),va=new ep(19),Ln=0;Ln>4)<16)fa[Ln++]=ps;else{var ir=0,or=0;for(ps==16?(or=3+cg(kt,hs,3),hs+=2,ir=fa[Ln-1]):ps==17?(or=3+cg(kt,hs,7),hs+=3):ps==18&&(or=11+cg(kt,hs,127),hs+=7);or--;)fa[Ln++]=ir}}var Or=fa.subarray(0,Ws),zr=fa.subarray(Ws);Vs=Rue(Or),Dr=Rue(zr),Ds=qA(Or,Vs),Qs=qA(zr,Dr)}else dg(1);if(hs>dr){ws&&dg(0);break}}bs&&Ps(cs+131072);for(var Sn=(1<>4;if((hs+=15&ir)>dr){ws&&dg(0);break}if(ir||dg(2),la<256)$t[cs++]=la;else{if(la==256){Vn=hs,Ds=null;break}var Jr=la-254;la>264&&(Jr=cg(kt,hs,(1<<(za=NSe[Ln=la-257]))-1)+MSe[Ln],hs+=za);var un=Qs[Fue(kt,hs)&zn],Ia=un>>4;if(un||dg(3),hs+=15&un,zr=dnt[Ia],Ia>3){var za=kSe[Ia];zr+=Fue(kt,hs)&(1<dr){ws&&dg(0);break}bs&&Ps(cs+131072);var Ba=cs+Jr;if(csOs.length)&&(Fs=Os.length),new ep(Os.subarray(0,Fs))):$t.subarray(0,cs)}(Ye.subarray(at,-8),{i:2},new ep(((Ie=Ye)[(Ke=Ie.length)-4]|Ie[Ke-3]<<8|Ie[Ke-2]<<16|Ie[Ke-1]<<24)>>>0))));var Ie,Ke,Ye,at;const vt=gnt[Le];if(!vt)throw new Error(`Unhandled codec: ${Le}`);const pt=new globalThis.DecompressionStream(vt);return new Response(new Blob([ke]).stream().pipeThrough(pt)).arrayBuffer().then(kt=>new Uint8Array(kt))}(ie,ee).then(ke=>(function(Le,Ie){Le.readFields(snt,Ie)}(new zue(ke),ce),new ynt[O](ce.buffer))),ue.then(ke=>{for(let Le=J.length-1;Le>=0;Le--)switch(J[Le]){case"delta_filter":nnt(ke,B);break;case"zigzag_filter":ant(ke);break;case"bitshuffle_filter":int(ke,O);break;default:throw new Up(`Unhandled filter "${J[Le]}"`)}return{layerName:N,blockIndex:W,data:ke}}).catch(ke=>{throw ke})}))},_r(ISe,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),_r(l8,"MapboxRasterTile"),_r(PSe,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class LSe{constructor(c){this._stringToNumber={},this._numberToString=[];for(let m=0;m=0&&ie[3]>=0&&W.insert(B,ie[0],ie[1],ie[2],ie[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yt(new FO(this.rawTileData)).layers,this.sourceLayerCoder=new LSe(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const c in this.vtLayers)this.vtFeatures[c]=[]}return this.vtLayers}query(c,m){const{tilespaceGeometry:v,transform:N,tileTransform:E,pixelPosMatrix:P,availableImages:O,worldview:B}=m;this.loadVTLayers(),this.serializedLayersCache.clear();const W=m.queryRadius?m.queryRadius:0,J=v.bufferedTilespaceBounds,ee=this.grid.query(J.min.x,J.min.y,J.max.x,J.max.y,(ke,Le,Ie,Ke)=>ru(v.bufferedTilespaceGeometry,ke-W,Le-W,Ie+W,Ke+W));ee.sort(vnt);let ie=null;N.elevation&&ee.length>0&&(ie=HC.create(N.elevation,this.tileID));const ce={};let ue;for(let ke=0;ke(Ke||(Ke=Et(Ye,this.tileID.canonical,E)),at.queryIntersectsFeature(v,Ye,vt,Ke,this.z,N,P,ie,pt)))}return ce}loadMatchingFeature(c,m,v,N,E,P){const{featureIndex:O,bucketIndex:B,sourceLayerIndex:W,layoutVertexArrayOffset:J}=m,ee=this.bucketLayerIDs[B],ie=v.layers,ce=Object.keys(ie);if(ce.length&&!fr(ce,ee))return;const ue=v.sourceCache,ke=this.sourceLayerCoder.decode(W),Le=this.vtLayers[ke].feature(O),Ie=this.getId(Le,ke);for(let Ke=0;Ke`${O.key}: ${O.message}`).join(", ");return void ur(`Failed to create expression for promoteId: ${P}`)}this.promoteIdExpression=E.value}v=this.promoteIdExpression.evaluate({zoom:0},c)}else v=c.properties[N];typeof v=="boolean"&&(v=Number(v))}return v}}function OSe(g,c,m,v,N){return Qt(g,(E,P)=>{const O=c instanceof zy?c.get(P):null;return O&&O.evaluate?O.evaluate(m,v,void 0,N):O})}function vnt(g,c){return c-g}_r(DSe,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const RSe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Bue{static from(c){if(!(c instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[m,v]=new Uint8Array(c,0,2);if(m!==219)throw new Error("Data does not appear to be in a KDBush format.");const N=v>>4;if(N!==1)throw new Error(`Got v${N} data when expected v1.`);const E=RSe[15&v];if(!E)throw new Error("Unrecognized array type.");const[P]=new Uint16Array(c,2,1),[O]=new Uint32Array(c,4,1);return new Bue(O,P,E,c)}constructor(c,m=64,v=Float64Array,N){if(isNaN(c)||c<0)throw new Error(`Unpexpected numItems value: ${c}.`);this.numItems=+c,this.nodeSize=Math.min(Math.max(+m,2),65535),this.ArrayType=v,this.IndexArrayType=c<65536?Uint16Array:Uint32Array;const E=RSe.indexOf(this.ArrayType),P=2*c*this.ArrayType.BYTES_PER_ELEMENT,O=c*this.IndexArrayType.BYTES_PER_ELEMENT,B=(8-O%8)%8;if(E<0)throw new Error(`Unexpected typed array class: ${v}.`);N&&N instanceof ArrayBuffer?(this.data=N,this.ids=new this.IndexArrayType(this.data,8,c),this.coords=new this.ArrayType(this.data,8+O+B,2*c),this._pos=2*c,this._finished=!0):(this.data=new ArrayBuffer(8+P+O+B),this.ids=new this.IndexArrayType(this.data,8,c),this.coords=new this.ArrayType(this.data,8+O+B,2*c),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+E]),new Uint16Array(this.data,2,1)[0]=m,new Uint32Array(this.data,4,1)[0]=c)}add(c,m){const v=this._pos>>1;return this.ids[v]=v,this.coords[this._pos++]=c,this.coords[this._pos++]=m,v}finish(){const c=this._pos>>1;if(c!==this.numItems)throw new Error(`Added ${c} items when expected ${this.numItems}.`);return $ue(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(c,m,v,N){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:E,coords:P,nodeSize:O}=this,B=[0,E.length-1,0],W=[];for(;B.length;){const J=B.pop()||0,ee=B.pop()||0,ie=B.pop()||0;if(ee-ie<=O){for(let Le=ie;Le<=ee;Le++){const Ie=P[2*Le],Ke=P[2*Le+1];Ie>=c&&Ie<=v&&Ke>=m&&Ke<=N&&W.push(E[Le])}continue}const ce=ie+ee>>1,ue=P[2*ce],ke=P[2*ce+1];ue>=c&&ue<=v&&ke>=m&&ke<=N&&W.push(E[ce]),(J===0?c<=ue:m<=ke)&&(B.push(ie),B.push(ce-1),B.push(1-J)),(J===0?v>=ue:N>=ke)&&(B.push(ce+1),B.push(ee),B.push(1-J))}return W}within(c,m,v){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:N,coords:E,nodeSize:P}=this,O=[0,N.length-1,0],B=[],W=v*v;for(;O.length;){const J=O.pop()||0,ee=O.pop()||0,ie=O.pop()||0;if(ee-ie<=P){for(let Le=ie;Le<=ee;Le++)zSe(E[2*Le],E[2*Le+1],c,m)<=W&&B.push(N[Le]);continue}const ce=ie+ee>>1,ue=E[2*ce],ke=E[2*ce+1];zSe(ue,ke,c,m)<=W&&B.push(N[ce]),(J===0?c-v<=ue:m-v<=ke)&&(O.push(ie),O.push(ce-1),O.push(1-J)),(J===0?c+v>=ue:m+v>=ke)&&(O.push(ce+1),O.push(ee),O.push(1-J))}return B}}function $ue(g,c,m,v,N,E){if(N-v<=m)return;const P=v+N>>1;FSe(g,c,P,v,N,E),$ue(g,c,m,v,P-1,1-E),$ue(g,c,m,P+1,N,1-E)}function FSe(g,c,m,v,N,E){for(;N>v;){if(N-v>600){const W=N-v+1,J=m-v+1,ee=Math.log(W),ie=.5*Math.exp(2*ee/3),ce=.5*Math.sqrt(ee*ie*(W-ie)/W)*(J-W/2<0?-1:1);FSe(g,c,m,Math.max(v,Math.floor(m-J*ie/W+ce)),Math.min(N,Math.floor(m+(W-J)*ie/W+ce)),E)}const P=c[2*m+E];let O=v,B=N;for(VA(g,c,v,m),c[2*N+E]>P&&VA(g,c,v,N);OP;)B--}c[2*v+E]===P?VA(g,c,v,B):(B++,VA(g,c,B,N)),B<=m&&(v=B+1),m<=B&&(N=B-1)}}function VA(g,c,m,v){que(g,m,v),que(c,2*m,2*v),que(c,2*m+1,2*v+1)}function que(g,c,m){const v=g[c];g[c]=g[m],g[m]=v}function zSe(g,c,m,v){const N=g-m,E=c-v;return N*N+E*E}i.$=kS,i.A=Vf,i.B=Ym,i.C=2,i.D=PC,i.E=Cs,i.F=kA,i.G=uke,i.H=NS,i.I=Ks,i.J=eO,i.K=Lr,i.L=bv,i.M=ZS,i.N=Sb,i.O=$D,i.P=es,i.Q=Cb,i.R=$f,i.S=aC,i.T=Yde,i.U=xx,i.V=e8,i.W=PT,i.X=Sv,i.Y=kv,i.Z=_b,i._=eu,i.a=function(g){return ra.API_CDN_URL_REGEX.test(g)},i.a$=ge,i.a0=dn,i.a1=ta,i.a2=Fp,i.a3=class extends e8{},i.a4=YS,i.a5=BD,i.a6=Gt,i.a7=function(g){const c=g.value;return c?dn(c)?Cue(c,!0)?[]:[new e8(g.key,c,`invalid url "${c}"`)]:[new e8(g.key,c,`string expected, "${Lr(c)}" found`)]:[]},i.a8=YD,i.a9=wo,i.aA=ye,i.aB=S,i.aC=Qe,i.aD=pd,i.aE=ji,i.aF=V,i.aG=st,i.aH=function(g,c){const m={};for(let v=0;v{v(E,P)},c):v(E,P),()=>{}}return N.callbacks.push(v),N.cancel||(N.cancel=m((E,P)=>{N.result=[E,P];for(const O of N.callbacks)this.scheduler?this.scheduler.add(()=>{O(E,P)},c):O(E,P);setTimeout(()=>delete this.entries[g],3e3)})),()=>{N.result||(N.callbacks=N.callbacks.filter(E=>E!==v),N.callbacks.length||(N.cancel(),delete this.entries[g]))}}},i.aL=function(g,c,m){const v=JSON.stringify(g.request);return g.data&&(this.deduped.entries[v]={result:[null,g.data]}),this.deduped.request(v,{type:"parseTile",isSymbolTile:g.isSymbolTile,zoom:g.tileZoom},N=>{const E=Vu(g.request,(P,O,B)=>{P?N(P):O&&N(null,{rawData:O,vectorTile:m?void 0:new Yt(new FO(O)),responseHeaders:new Map(B.entries())})});return()=>{E.cancel(),N()}},c)},i.aM=function(g){return g?{cacheControl:g.get("Cache-Control"),expires:g.get("Expires")}:{cacheControl:void 0,expires:void 0}},i.aN=hl,i.aO=function(g){Qc++,Qc>gv&&(g.getActor().send("enforceCacheSizeLimit",fv),Qc=0)},i.aP=function(g){return g<=1?1:Math.pow(2,Math.floor(Math.log2(g)))},i.aQ=go,i.aR=Bke,i.aS=Wke,i.aT=x,i.aU=zke,i.aV=function(g,c){const m=document.createElement("video");m.muted=!0,m.onloadstart=function(){c(null,m)};for(let v=0;v{}}},i.aW=_A,i.aX=Xb,i.aY=qt,i.aZ=TA,i.a_=oe,i.aa=Gs,i.ab=class{constructor(g){this.specification=g}possiblyEvaluate(g,c){return wn(g.expression.evaluate(c))}interpolate(g,c,m){return{x:Hr(g.x,c.x,m),y:Hr(g.y,c.y,m),z:Hr(g.z,c.z,m),azimuthal:Hr(g.azimuthal,c.azimuthal,m),polar:Hr(g.polar,c.polar,m)}}},i.ac=Fi,i.ad=Oy,i.ae=tt,i.af=Rt,i.ag=de,i.ah=ze,i.ai=zy,i.aj=Hv,i.ak=Hr,i.al=Xs,i.am=Ty,i.an=Ir,i.ao=Fr,i.ap=class{constructor(g){this.specification=g}possiblyEvaluate(g,c){return function([m,v]){const N=wn([1,m,v]);return{x:N.x,y:N.y,z:N.z}}(g.expression.evaluate(c))}interpolate(g,c,m){return{x:Hr(g.x,c.x,m),y:Hr(g.y,c.y,m),z:Hr(g.z,c.z,m)}}},i.aq=function(g,c,m=0,v=!0){const N=new es(m,m),E=g.sub(N),P=c.add(N),O=[E,new es(P.x,E.y),P,new es(E.x,P.y)];return v&&O.push(E.clone()),O},i.ar=function(g,c){const m=[];for(let v=0;v1)return!1;const m=c.getSource().maxzoom,v=1<1)return c;const N=v.getSource().maxzoom,E=1<{const O=this.getAtTileOffset(g,N,E,P),B=v.upVector(g.canonical,N.x,N.y);return Ne(B,B,O*v.upVectorScale(g.canonical,c,m).metersToTile),B}}getForTilePoints(g,c,m,v){if(this.isUsingMockSource())return!1;const N=HC.create(this,g,v);return!!N&&(c.forEach(E=>{E[2]=this.exaggeration()*N.getElevationAt(E[0],E[1],m)}),!0)}getMinMaxForTile(g){if(this.isUsingMockSource())return null;const c=this.findDEMTileFor(g);if(!c||!c.dem)return null;const m=c.dem.tree,v=c.tileID,N=1<0&&(v+=(g[N]-0)*(g[N]-0)),c[N]<0&&(v+=(0-c[N])*(0-c[N]));return v},i.c0=Bje,i.c1=uue,i.c2=yke,i.c3=vue,i.c4=Bue,i.c5=Ne,i.c6=$e,i.c7=He,i.c8=function(g,c,m){m*=.5;var v=c[0],N=c[1],E=c[2],P=c[3],O=Math.sin(m),B=Math.cos(m);return g[0]=v*B+N*O,g[1]=N*B-v*O,g[2]=E*B+P*O,g[3]=P*B-E*O,g},i.c9=et,i.cA=te,i.cB=Ha,i.cC=NNe,i.cD=Ni,i.cE=tje,i.cF=function(g,c,m,v,N,E,P,O,B){if(B.name==="globe")return tje(g,c,new Ni(m,v,N),!1);const W=TA({z:m,x:v,y:N},B);return new Er([(E+W.x/W.scale)*c,c*(W.y/W.scale),P],[(E+W.x2/W.scale)*c,c*(W.y2/W.scale),O])},i.cG=function(g,c,m){return g[0]=Math.min(c[0],m[0]),g[1]=Math.min(c[1],m[1]),g[2]=Math.min(c[2],m[2]),g[3]=Math.min(c[3],m[3]),g},i.cH=function(g,c,m){return g[0]=Math.max(c[0],m[0]),g[1]=Math.max(c[1],m[1]),g[2]=Math.max(c[2],m[2]),g[3]=Math.max(c[3],m[3]),g},i.cI=function(g){const c=Math.round((g+45+360)%360/90)%4;return Go[c]},i.cJ=xe,i.cK=qe,i.cL=TC,i.cM=function(g){const c=j(new Float64Array(16));S(c,g.pixelMatrix,g.globeMatrix);const m=[0,um,0],v=[0,hm,0];return Rt(m,m,c),Rt(v,v,c),[m[0]>0&&m[0]<=g.width&&m[1]>0&&m[1]<=g.height&&!Cde(g,new x(g.center.lat,90)),v[0]>0&&v[0]<=g.width&&v[1]>0&&v[1]<=g.height&&!Cde(g,new x(g.center.lat,-90))]},i.cN=function(g,c){const{scale:m}=g.tileTransform,v=m*Xs/(g.tileSize*Math.pow(2,c.zoom-g.tileID.overscaledZ+g.tileID.canonical.z));return function(N,E,P){var O=E[1],B=E[2],W=E[3],J=P[0],ee=P[1];return N[0]=E[0]*J,N[1]=O*J,N[2]=B*ee,N[3]=W*ee,N}(new Float32Array(4),c.inverseAdjustmentMatrix,[v,v])},i.cO=PO,i.cP=se,i.cQ=jNe,i.cR=function(g){const c=jNe(g,!0);return p([],[c[0],c[1],c[4],c[5]])},i.cS=I,i.cT=cr,i.cU=L,i.cV=function(g){const{x:c,y:m}=g.point,{lng:v,lat:N}=g._center;return nje(c,m,g.worldSize,v,N)},i.cW=be,i.cX=mi,i.cY=ho,i.cZ=ed,i.c_=dm,i.ca=Va,i.cb=function(g,c){return g[0]=-c[0],g[1]=-c[1],g[2]=-c[2],g[3]=c[3],g},i.cc=Y,i.cd=function(g,c,m,v,N){var E=1/Math.tan(c/2);if(g[0]=E/m,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=E,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[11]=-1,g[12]=0,g[13]=0,g[15]=0,N!=null&&N!==1/0){var P=1/(v-N);g[10]=(N+v)*P,g[14]=2*N*v*P}else g[10]=-1,g[14]=-2*v;return g},i.ce=function(g,c,m,v,N,E,P){var O=1/(c-m),B=1/(v-N),W=1/(E-P);return g[0]=-2*O,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=-2*B,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=2*W,g[11]=0,g[12]=(c+m)*O,g[13]=(N+v)*B,g[14]=(P+E)*W,g[15]=1,g},i.cf=ne,i.cg=function(g,c,m){g[4*c+0]=m[0],g[4*c+1]=m[1],g[4*c+2]=m[2],g[4*c+3]=m[3]},i.ch=kC,i.ci=Ob,i.cj=wl,i.ck=$p,i.cl=Fb,i.cm=Tke,i.cn=function(){var g=new u(4);return u!=Float32Array&&(g[1]=0,g[2]=0),g[0]=1,g[3]=1,g},i.co=function(g,c,m){var v=c[0],N=c[1],E=c[2],P=c[3],O=Math.sin(m),B=Math.cos(m);return g[0]=v*B+E*O,g[1]=N*B+P*O,g[2]=v*-O+E*B,g[3]=N*-O+P*B,g},i.cp=function(g,c){return g[0]===c[0]&&g[1]===c[1]&&g[2]===c[2]&&g[3]===c[3]},i.cq=nt,i.cr=function(g){var c=g[0],m=g[1],v=g[2],N=g[3];return Math.sqrt(c*c+m*m+v*v+N*N)},i.cs=ss,i.ct=Xe,i.cu=Zo,i.cv=3,i.cw=2,i.cx=7,i.cy=6,i.cz=De,i.d=function(g){return ra.API_TILEJSON_REGEX.test(g)},i.d$=class{constructor(g,c,m,v){this.context=g,this.format=v,this.size=m,this.texture=g.gl.createTexture();const[N,E,P]=this.size,{gl:O}=g;O.bindTexture(O.TEXTURE_3D,this.texture),g.pixelStoreUnpackFlipY.set(!1),g.pixelStoreUnpack.set(1),g.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in c&&c.data&&O.texImage3D(O.TEXTURE_3D,0,this.format,N,E,P,0,Kde(this.format),Zde(this.format),c.data)}bind(g,c){const{context:m}=this,{gl:v}=m;v.bindTexture(v.TEXTURE_3D,this.texture),g!==this.minFilter&&(v.texParameteri(v.TEXTURE_3D,v.TEXTURE_MAG_FILTER,g),v.texParameteri(v.TEXTURE_3D,v.TEXTURE_MIN_FILTER,g),this.minFilter=g),c!==this.wrapS&&(v.texParameteri(v.TEXTURE_3D,v.TEXTURE_WRAP_S,c),v.texParameteri(v.TEXTURE_3D,v.TEXTURE_WRAP_T,c),this.wrapS=c)}destroy(){const{gl:g}=this.context;g.deleteTexture(this.texture),this.texture=null}},i.d0=function(g){return g*g*g*g*g},i.d1=z,i.d2=45,i.d3=SC,i.d4=function(g,c,m){const v=Math.sqrt(g*g+c*c+m*m),N=v>0?Math.acos(m/v)*Zn:0;let E=g!==0||c!==0?Math.atan2(-c,-g)*Zn+90:0;return E<0&&(E+=360),[v,E,N]},i.d5=re,i.d6=wn,i.d7=Be,i.d8=le,i.d9=Er,i.dA=function(g){return g({pluginStatus:tu,pluginURL:Yf}),rC.on("pluginStateChange",g),g},i.dB=Rb,i.dC=class extends Jf{constructor(g){super(g),this.current=CC}set(g,c,m){if(this.fetchUniformLocation(g,c)){for(let v=0;v<9;v++)if(m[v]!==this.current[v]){this.current=m,this.gl.uniformMatrix3fv(this.location,!1,m);break}}}},i.dD=yi,i.dE=function(g,c,m){const v=Hv(m.zoom),N=g.style.map._antialias,E=g.terrain&&g.terrain.exaggeration()>0;return v===0&&!N&&!E},i.dF=function(g){const c=g.pixelsPerMeter,m=c/ne(1,g.center.lat),v=j(new Float64Array(16));return T(v,v,[g.point.x,g.point.y,0]),I(v,v,[m,m,c]),Float32Array.from(v)},i.dG=gO,i.dH=function(g){const c=xe-5;g=ye(g,-c,c)/c*90;const m=Math.pow(Math.abs(Math.sin(Ir(g))),3);return Math.round(m*(rA.length-1))},i.dI=function(g,c,m,v){const N=c.getNorth(),E=c.getSouth(),P=c.getWest(),O=c.getEast(),B=1<0){const ue=180/v;_(ce,ce,[ue/W+1,0,0,0,ue/J+1,0,-.5*ue/ee,.5*ue/ie,1])}return ce[2]=B,ce[5]=g.x,ce[8]=g.y,ce},i.dJ=Jm,i.dK=function(g,c,m){const v=j(new Float64Array(16)),N=(c/(1<({u_matrix:new Fb(g),u_texsize:new $p(g),u_pixels_to_tile_units:new MC(g),u_device_pixel_ratio:new wl(g),u_width_scale:new wl(g),u_floor_width_scale:new wl(g),u_image:new kC(g),u_units_to_pixels:new $p(g),u_tile_units_to_pixels:new wl(g),u_alpha_discard_threshold:new wl(g),u_trim_offset:new $p(g),u_trim_fade_range:new $p(g),u_trim_color:new SC(g),u_zbias_factor:new wl(g),u_tile_to_meter:new wl(g),u_ground_shadow_factor:new Ob(g),u_pattern_transition:new wl(g)}),i.dX=g=>({u_matrix:new Fb(g),u_pixels_to_tile_units:new MC(g),u_device_pixel_ratio:new wl(g),u_width_scale:new wl(g),u_floor_width_scale:new wl(g),u_units_to_pixels:new $p(g),u_dash_image:new kC(g),u_gradient_image:new kC(g),u_image_height:new wl(g),u_texsize:new $p(g),u_tile_units_to_pixels:new wl(g),u_alpha_discard_threshold:new wl(g),u_trim_offset:new $p(g),u_trim_fade_range:new $p(g),u_trim_color:new SC(g),u_zbias_factor:new wl(g),u_tile_to_meter:new wl(g),u_ground_shadow_factor:new Ob(g)}),i.dY=g=>({u_camera_to_center_distance:new wl(g),u_extrude_scale:new MC(g),u_device_pixel_ratio:new wl(g),u_matrix:new Fb(g),u_inv_rot_matrix:new Fb(g),u_merc_center:new $p(g),u_tile_id:new Ob(g),u_zoom_transition:new wl(g),u_up_dir:new Ob(g),u_emissive_strength:new wl(g)}),i.dZ=gC,i.d_=Ast,i.da=he,i.db=function(g){return[Math.pow(g[0],1/2.2),Math.pow(g[1],1/2.2),Math.pow(g[2],1/2.2)]},i.dc=wNe,i.dd=sue,i.de=CNe,i.df=Cue,i.dg=function(g,c){return g.readFields(Trt,{icons:[]},c)},i.dh=MO,i.di=$C,i.dj=gue,i.dk=xv,i.dl=Ab,i.dm=ax,i.dn=yv,i.dp=gs,i.dq=function(g){const c=g.indexOf(qy);return c>=0?g.slice(0,c):g},i.dr=function(g){return g.indexOf(qy)>=0},i.ds=function(g){const c=g.lastIndexOf(qy);return c>=0?g.slice(c+1):""},i.dt=function(g){const c=[],m=g.id;return m===void 0&&c.push({message:`layers.${m}: missing required property "id"`}),g.render===void 0&&c.push({message:`layers.${m}: missing required method "render"`}),g.renderingMode&&g.renderingMode!=="2d"&&g.renderingMode!=="3d"&&c.push({message:`layers.${m}: property "renderingMode" must be either "2d" or "3d"`}),c},i.du=function(g,c,m,v){return g.type==="custom"?new wrt(g,c):new Crt[g.type](g,c,m,v)},i.dv=As,i.dw=function(g){const c=g.indexOf(qy);return c>=0?g.slice(c+1):""},i.dx=class extends Yb{constructor(g,c){super(g._vectorTileFeature,g._z,g._x,g._y,g.id),g.state&&(this.state=Object.assign({},g.state)),this.target=c.target,this.namespace=c.namespace,c.properties&&(this.properties=c.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=g.source,this.sourceLayer=g.sourceLayer,this.layer=g.layer)}toJSON(){const g=super.toJSON();return g.target=this.target,g.namespace=this.namespace,g}},i.dy=rC,i.dz=qf,i.e=ra,i.e$=ae,i.e0=oje,i.e1=(g,c,m,v,N,E)=>{const P=g.transform,O=P.projection.name==="globe";let B;if(E.paint.get("circle-pitch-alignment")==="map")if(O){const J=rje(P.zoom,c.canonical)*P._pixelsPerMercatorPixel;B=Float32Array.from([J,0,0,J])}else B=P.calculatePixelsToTileUnitsMatrix(m);else B=new Float32Array([P.pixelsToGLUnits[0],0,0,P.pixelsToGLUnits[1]]);const W={u_camera_to_center_distance:g.transform.getCameraToCenterDistance(P.projection),u_matrix:g.translatePosMatrix(c.projMatrix,m,E.paint.get("circle-translate"),E.paint.get("circle-translate-anchor")),u_device_pixel_ratio:_l.devicePixelRatio,u_extrude_scale:B,u_inv_rot_matrix:Wet,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:E.paint.get("circle-emissive-strength")};if(O){W.u_inv_rot_matrix=v,W.u_merc_center=N,W.u_tile_id=[c.canonical.x,c.canonical.y,1<{const J=g.transform,ee=J.pitch<15?BNe(.07,.7,ye((14-J.zoom)/5,0,1)):.07,ie=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:qNe(g,c,m,v),u_texsize:c.imageAtlasTexture?c.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:J.calculatePixelsToTileUnitsMatrix(c),u_device_pixel_ratio:N,u_width_scale:E,u_floor_width_scale:P,u_image:0,u_tile_units_to_pixels:$Ne(c,J),u_units_to_pixels:[1/J.pixelsToGLUnits[0],1/J.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:O,u_trim_fade_range:m.paint.get("line-trim-fade-range"),u_trim_color:m.paint.get("line-trim-color").toPremultipliedRenderColor(ie?null:m.lut).toArray01(),u_zbias_factor:ee,u_tile_to_meter:Be(c.tileID.canonical,0),u_ground_shadow_factor:B,u_pattern_transition:W}},i.e5=(g,c,m,v,N,E,P,O,B,W)=>{const J=g.transform,ee=J.calculatePixelsToTileUnitsMatrix(c),ie=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none",ce=J.pitch<15?BNe(.07,.7,ye((14-J.zoom)/5,0,1)):.07;return{u_matrix:qNe(g,c,m,v),u_pixels_to_tile_units:ee,u_device_pixel_ratio:E,u_width_scale:P,u_floor_width_scale:O,u_units_to_pixels:[1/J.pixelsToGLUnits[0],1/J.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:N,u_texsize:VNe(m)&&c.lineAtlasTexture?c.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:$Ne(c,g.transform),u_alpha_discard_threshold:0,u_trim_offset:B,u_trim_fade_range:m.paint.get("line-trim-fade-range"),u_trim_color:m.paint.get("line-trim-color").toPremultipliedRenderColor(ie?null:m.lut).toArray01(),u_zbias_factor:ce,u_tile_to_meter:Be(c.tileID.canonical,0),u_ground_shadow_factor:W}},i.e6=Kt,i.e7=aA,i.e8=pe,i.e9=pm,i.eA=function(g,c){var m=2*Math.acos(c[3]),v=Math.sin(m/2);return v>d?(g[0]=c[0]/v,g[1]=c[1]/v,g[2]=c[2]/v):(g[0]=1,g[1]=0,g[2]=0),m},i.eB=Aue,i.eC=DO,i.eD=LO,i.eE=[1,1,1],i.eF=HC,i.eG=ct,i.eH=function(g,c,m,v){var N=c[0],E=c[1],P=c[2],O=c[3];return g[0]=N+v*(m[0]-N),g[1]=E+v*(m[1]-E),g[2]=P+v*(m[2]-P),g[3]=O+v*(m[3]-O),g},i.eI=OC,i.eJ=wh,i.eK=Bp,i.eL=function(g,c,m,v,N,E,P,O,B,W,J,ee,ie,ce,ue,ke){var Le=new u(16);return Le[0]=g,Le[1]=c,Le[2]=m,Le[3]=v,Le[4]=N,Le[5]=E,Le[6]=P,Le[7]=O,Le[8]=B,Le[9]=W,Le[10]=J,Le[11]=ee,Le[12]=ie,Le[13]=ce,Le[14]=ue,Le[15]=ke,Le},i.eM=M,i.eN=zv,i.eO=GT,i.eP=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new es(1/0,1/0),max:new es(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(g,c=!1){const m=Rje(new es(0,0),new es(Xs,Xs),g),v=[];if(c&&!Ode(m,this._globalClipBounds))return v;for(const N of this._activeRegions){if(N.hiddenByOverlap||!Ode(m,N))continue;const E=btt(N.min,N.max,g);v.push({min:E.min,max:E.max,sourceId:this._sourceIds[N.priority],footprint:N.footprint,footprintTileId:N.tileId,order:N.order,clipMask:N.clipMask,clipScope:N.clipScope})}return v}setSources(g){this._setSources(g.map(c=>({getSourceId:()=>c.cache.id,getFootprints:()=>{const m=[];for(const v of c.cache.getVisibleCoordinates()){const N=c.cache.getTile(v).buckets[c.layer];N&&N.updateFootprints(v.toUnwrapped(),m)}return m},getOrder:()=>c.order,getClipMask:()=>c.clipMask,getClipScope:()=>c.clipScope})))}_addSource(g){const c=g.getFootprints();if(c.length===0)return;const m=g.getOrder(),v=g.getClipMask(),N=g.getClipScope();for(const E of c){if(!E.footprint)continue;const P=Rje(E.footprint.min,E.footprint.max,E.id);this._activeRegions.push({min:P.min,max:P.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:E.id,footprint:E.footprint,order:m,clipMask:v,clipScope:N})}this._sourceIds.push(g.getSourceId())}_computeReplacement(){this._activeRegions.sort((c,m)=>c.priority-m.priority||jO(c.min,m.min)||jO(c.max,m.max)||c.order-m.order||c.clipMask-m.clipMask||function(v,N){const E=(P,O)=>P+O;return v.length-N.length||v.reduce(E,"").localeCompare(N.reduce(E,""))}(c.clipScope,m.clipScope));let g=this._activeRegions.length!==this._prevRegions.length;if(!g){let c=0;for(;!g&&c!==this._activeRegions.length;){const m=this._activeRegions[c],v=this._prevRegions[c];g=m.priority!==v.priority||!Oje(m,v)||m.order!==v.order||m.clipMask!==v.clipMask||!an(m.clipScope,v.clipScope),this._activeRegions[c].hiddenByOverlap=v.hiddenByOverlap,++c}}if(g){++this._updateTime;for(const m of this._activeRegions)m.order!==uA&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,m.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,m.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,m.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,m.max.y));const c=m=>{const v=this._activeRegions;if(m>=v.length)return m;const N=v[m].priority;for(;m1){let m=0,v=c(m);for(;m!==v;){let N=m;const E=m;for(;N!==v;){const P=this._activeRegions[N];P.hiddenByOverlap=!1;for(let O=0;O=0;c--)this._addSource(g[c]);this._computeReplacement()}},i.eQ=uA,i.eR=class{constructor(g){this._createGrid(g),this._createPoles(g)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const g of this._poleSegments)g.destroy();for(const g of this._gridSegments)g.withSkirts.destroy(),g.withoutSkirts.destroy()}_fillGridMeshWithLods(g,c){const m=new vx,v=new bl,N=[],E=g+1+2,P=c[0]+1,O=c[0]+1+(1+c.length),B=(W,J,ee)=>{let ie=W===E-1?W-2:W===0?W:W-1;return ie+=ee?24575:0,[ie,J]};for(let W=0;W0?(Le=2*Math.sqrt(ke+1),g[3]=.25*Le,g[0]=(ee-ce)/Le,g[1]=(ie-B)/Le,g[2]=(O-W)/Le):P>J&&P>ue?(Le=2*Math.sqrt(1+P-J-ue),g[3]=(ee-ce)/Le,g[0]=.25*Le,g[1]=(O+W)/Le,g[2]=(ie+B)/Le):J>ue?(Le=2*Math.sqrt(1+J-P-ue),g[3]=(ie-B)/Le,g[0]=(O+W)/Le,g[1]=.25*Le,g[2]=(ee+ce)/Le):(Le=2*Math.sqrt(1+ue-P-J),g[3]=(O-W)/Le,g[0]=(ie+B)/Le,g[1]=(ee+ce)/Le,g[2]=.25*Le),g},i.f=function(g){return btoa(encodeURIComponent(g).replace(/%([0-9A-F]{2})/g,(c,m)=>String.fromCharCode(+("0x"+m))))},i.f0=function([g,c,m]){const v=Math.hypot(g,c,m),N=Math.atan2(g,m),E=.5*Math.PI-Math.acos(-c/v);return new x(mi(N),mi(E))},i.f1=Ze,i.f2=Xde,i.f3=function(g){const c=g.navigator?g.navigator.userAgent:null;return!!function(m){if(qo==null){const v=m.navigator?m.navigator.userAgent:null;qo=!!m.safari||!(!v||!(/\b(iPad|iPhone|iPod)\b/.test(v)||v.match("Safari")&&!v.match("Chrome")))}return qo}(g)&&!(!c||!(c.match("Version/15.4")||c.match("Version/15.5")||c.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/)))},i.f4=function(g,c){fv=g,gv=c},i.f5=Cde,i.f6=aje,i.f7=function(g){const c=[0,0,0],m=j(new Float64Array(16));return S(m,g.pixelMatrix,g.globeMatrix),Rt(c,c,m),new es(c[0],c[1])},i.f8=function(){const g=xA;g&&(g.isPreloaded()&&g.numActive()===1?(g.release(qde),xA=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},i.f9=function(){MO().acquire(qde)},i.fA=o8,i.fB=Ut,i.fC=function(g){let c=0;if(new Uint32Array(g,0,1)[0]!==xNe){const m=new Uint32Array(g,0,7),[,,v,N,E,P]=m;c=m.byteLength+N+E+P+E,(v!==g.byteLength||c>=g.byteLength)&&ur("Invalid b3dm header information.")}return bNe(g,c)},i.fD=function(g,c){const m=sue(g);for(const v of m){for(const N of v.meshes)Qtt(N);v.lights&&(v.lightMeshIndex=v.meshes.length,v.meshes.push(Jtt(v.lights,c)))}return m},i.fE=t8,i.fF=ma,i.fG=hNe,i.fH=Xf,i.fI=Hu,i.fJ=function(g){hd(),gh!=null&&gh.then(c=>{c.keys().then(m=>{for(let v=0;vur(N.message))}).catch(m=>ur(m.message))}).catch(c=>ur(c.message))},i.fa=Eb,i.fb=function(g,c,m=!1){if(tu===Hu.deferred||tu===Hu.loading||tu===Hu.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Yf=_l.resolveURL(g),tu=Hu.deferred,OT=c,sC(),m||ZD()},i.fc=function(g){IC=_l.resolveURL(g),LC||(LC=new PC(MO(),new Cs)),LC.broadcast("setMeshoptUrl",IC)},i.fd=fNe,i.fe=function(g){Hde=_l.resolveURL(g),LC||(LC=new PC(MO(),new Cs)),LC.broadcast("setDracoUrl",Hde)},i.ff=pNe,i.fg=gA,i.fh=function(g){const c=xh();if(!c)return;const m=c.delete(pv);g&&m.then(()=>g()).catch(g)},i.fi=Hb,i.fj=_r,i.fk=Wv,i.fl=lg,i.fm=LSe,i.fn=DSe,i.fo=ONe,i.fp=ds,i.fq="hd_road_elevation",i.fr=Xa,i.fs=Qt,i.ft=Wy,i.fu=fue,i.fv=Kb,i.fw=function(g,c,m,v,N,E,P,O=1,B,W,J){g.createArrays(),g.tilePixelRatio=Xs/(512*g.overscaling),g.compareText={},g.iconsNeedLinear=!1;const ee=g.layers[0].layout,ie=g.layers[0]._unevaluatedLayout._values,ce={};ce.scaleFactor=O,ce.textSizeScaleRange=ee.get("text-size-scale-range"),ce.iconSizeScaleRange=ee.get("icon-size-scale-range");const[ue,ke]=ce.textSizeScaleRange,[Le,Ie]=ce.iconSizeScaleRange;ce.textScaleFactor=ye(ce.scaleFactor,ue,ke),ce.iconScaleFactor=ye(ce.scaleFactor,Le,Ie);const Ke=ie["text-size"],Ye=ie["icon-size"];if(g.textSizeData.kind==="composite"){const{minZoom:$t,maxZoom:ls}=g.textSizeData;ce.compositeTextSizes=[Ke.possiblyEvaluate(new Fi($t,{worldview:J}),E),Ke.possiblyEvaluate(new Fi(ls,{worldview:J}),E)]}if(g.iconSizeData.kind==="composite"){const{minZoom:$t,maxZoom:ls}=g.iconSizeData;ce.compositeIconSizes=[Ye.possiblyEvaluate(new Fi($t,{worldview:J}),E),Ye.possiblyEvaluate(new Fi(ls,{worldview:J}),E)]}ce.layoutTextSize=Ke.possiblyEvaluate(new Fi(P+1,{worldview:J}),E),ce.layoutIconSize=Ye.possiblyEvaluate(new Fi(P+1,{worldview:J}),E),ce.textMaxSize=Ke.possiblyEvaluate(new Fi(18,{worldview:J}),E);const at=ee.get("symbol-placement"),vt=ee.get("text-rotation-alignment")==="map"&&at!=="point",pt=ee.get("text-size");let kt=!1;const Lt=[];for(const $t of g.features){const ls=ee.get("text-font").evaluate($t,{},E).join(","),Wt=pt.evaluate($t,{},E)*ce.textScaleFactor,ms=ce.layoutTextSize.evaluate($t,{},E)*ce.textScaleFactor,bs=ce.layoutIconSize.evaluate($t,{},E)*ce.iconScaleFactor,ws={horizontal:{},vertical:void 0},Os=$t.text;let Fs,Ps=[0,0];if(Os){const Ln=Os.toString(),_i=ee.get("text-letter-spacing").evaluate($t,{},E)*lc,ft=ee.get("text-line-height").evaluate($t,{},E)*lc,_t=LT(Ln)?_i:0,ps=ee.get("text-anchor").evaluate($t,{},E),Rs=ee.get("text-variable-anchor");if(!Rs){const Sn=ee.get("text-radial-offset").evaluate($t,{},E);if(Sn)Ps=yke(ps,[Sn*lc,yue]);else{const zn=ee.get("text-offset").evaluate($t,{},E);Ps=[zn[0]*lc,zn[1]*lc]}}let ir=vt?"center":ee.get("text-justify").evaluate($t,{},E);const or=at==="point",Or=or?ee.get("text-max-width").evaluate($t,{},E)*lc:1/0,zr=Sn=>{g.allowVerticalPlacement&&Tb(Ln)&&(ws.vertical=due(Os,c,m,N,ls,Or,ft,ps,Sn,_t,Ps,kh.vertical,!0,ms,Wt,B))};if(!vt&&Rs){const Sn=ir==="auto"?Rs.map(Vn=>vue(Vn)):[ir];let zn=!1;for(let Vn=0;Vn=0||!Tb(Ln)){const Sn=due(Os,c,m,N,ls,Or,ft,ps,ir,_t,Ps,kh.horizontal,!1,ms,Wt,B);Sn&&(ws.horizontal[ir]=Sn)}zr(or?"left":ir)}}let Ls,hs,cs,Ds,Qs,Vs,Dr=!1;const dr=ee.get("icon-text-fit").evaluate($t,{},E);if($t.icon&&$t.icon.hasPrimary()){const Ln=CA($t.icon,g.iconSizeData,ie["icon-size"],E,g.zoom,$t,B,ce.iconScaleFactor,J);Ls=Ln.iconPrimary,cs=Ln.iconSecondary;const _i=Ls.toString();if(hs=v.get(_i),hs&&(Qs=ee.get("icon-offset").evaluate($t,{},E),Vs=ee.get("icon-anchor").evaluate($t,{},E),Fs=BO(N.get(_i),cs?N.get(cs.toString()):void 0,Qs,Vs),Dr=hs.sdf,g.sdfIcons===void 0?g.sdfIcons=hs.sdf:g.sdfIcons!==hs.sdf&&ur("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(hs.pixelRatio!==g.pixelRatio||ee.get("icon-rotate").constantOr(1)!==0)&&(g.iconsNeedLinear=!0)),cs){const ft=cs.toString();Ds=v.get(ft)}}kt=kt||!(!$t.icon||!$t.icon.hasSecondary());const yr=HO(ws.horizontal)||ws.vertical;g.iconsInText||(g.iconsInText=!!yr&&yr.iconsInText);const kr=ms*ce.textScaleFactor/lc,{defaultShapedIcon:Hn,verticallyShapedIcon:Ws}=ort(g,Fs,ee,$t,E,ws,kr,Qs,dr);dr!=="none"&&Fs&&(rke(Fs)||nke(Fs))&&(VO(0,hs,Ls,Fs,Hn,dr,W,v,N),VO(0,Ds,cs,Fs,Hn,dr,W,v,N),Ws&&(VO(0,hs,Ls,Fs,Ws,dr,W,v,N),VO(0,Ds,cs,Fs,Ws,dr,W,v,N))),Fs=Hn;const{iconBBox:Sr,iconVerticalBBox:mn,textBBox:fa,textVerticalBBox:va}=srt(g,Fs,Ws,ee,$t,E,bs,Qs,ce,N,Vs,ws,ms,Ps);Lt.push({feature:$t,shapedTextOrientations:ws,shapedText:yr,shapedIcon:Fs,iconPrimary:Ls,iconSecondary:cs,iconOffset:Qs,iconAnchor:Vs,verticallyShapedIcon:Ws,layoutTextSize:ms,layoutIconSize:bs,textOffset:Ps,isSDFIcon:Dr,iconTextFit:dr,iconCollisionBounds:Sr,iconVerticalCollisionBounds:mn,textCollisionBounds:fa,textVerticalCollisionBounds:va})}return{featureData:Lt,sizes:ce,hasAnySecondaryIcon:kt,textAlongLine:vt,symbolPlacement:at}},i.fx=hke,i.fy=function(g,c,m,v,N,E,P,O,B,W){g.iconAtlasPositions=W.iconPositions;const{featureData:J,hasAnySecondaryIcon:ee,sizes:ie,textAlongLine:ce,symbolPlacement:ue}=c;for(const ke of J){const{shapedIcon:Le,verticallyShapedIcon:Ie,feature:Ke,shapedTextOrientations:Ye,shapedText:at,layoutTextSize:vt,textOffset:pt,isSDFIcon:kt,iconPrimary:Lt,iconSecondary:$t,iconTextFit:ls,iconOffset:Wt,iconCollisionBounds:ms,iconVerticalCollisionBounds:bs,textCollisionBounds:ws}=ke;_ke(Le,W.iconPositions,Lt,$t),_ke(Ie,W.iconPositions,Lt,$t),irt(Ye,W.iconPositions),art(Lt,$t,W.iconPositions),(at||Le)&&lrt(g,Ke,Ye,Le,Ie,B,ie,vt,0,pt,kt,v,N,P,O,ee,ls,Wt,ce,ue,ms,bs,ws)}m&&g.generateCollisionDebugBuffers(E,g.collisionBoxArray,ie.textScaleFactor)},i.fz=Yt,i.g=function(g,c){return qf(Object.assign(g,{method:"GET"}),c)},i.h=function(g){return g.indexOf("mapbox:")===0},i.i=function(g){return ra.API_STYLE_REGEX.test(g)&&!ic(g)},i.j=Ji,i.k=Ed,i.l=function(g){return decodeURIComponent(atob(g).split("").map(c=>"%"+("00"+c.charCodeAt(0).toString(16)).slice(-2)).join(""))},i.m=function(g,c){return qf(Object.assign(g,{type:"json"}),c)},i.n=ix,i.o=_l,i.p=function(g,c){return qf(Object.assign(g,{method:"POST"}),c)},i.q=xd,i.r=sm,i.s=function(g){try{const c=self[g];return c.setItem("_mapbox_test_",1),c.removeItem("_mapbox_test_"),!0}catch{return!1}},i.t=function(){return Ude||(Ude=new Hb("ImageRasterizer")),Ude},i.u=function(){return function g(c){return c?(c^Math.random()*(16>>c/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,g)}()},i.v=function(g){return!!g&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(g)},i.w=ur,i.x=Oue,i.y=ox,i.z=am}),o(["./shared"],function(i){function d(Vt){const ye=Vt?Vt.url.toString():void 0;return ye?performance.getEntriesByName(ye):[]}function u(Vt){if(typeof Vt=="number"||typeof Vt=="boolean"||typeof Vt=="string"||Vt==null)return JSON.stringify(Vt);if(Array.isArray(Vt)){let ze="[";for(const Je of Vt)ze+=`${u(Je)},`;return`${ze}]`}let ye="{";for(const ze of Object.keys(Vt).sort())ye+=`${ze}:${u(Vt[ze])},`;return`${ye}}`}function p(Vt){let ye="";for(const ze of i.bx)ye+=`/${u(Vt[ze])}`;return ye}class f{constructor(ye){this.keyCache={},this._layers={},this._layerConfigs={},ye&&this.replace(ye)}replace(ye,ze){this._layerConfigs={},this._layers={},this.update(ye,[],ze)}update(ye,ze,Je){this._options=Je;for(const Nt of ye)this._layerConfigs[Nt.id]=Nt,(this._layers[Nt.id]=i.du(Nt,this.scope,null,this._options)).compileFilter(Je),this.keyCache[Nt.id]&&delete this.keyCache[Nt.id];for(const Nt of ze)delete this.keyCache[Nt],delete this._layerConfigs[Nt],delete this._layers[Nt];this.familiesBySource={};const St=function(Nt,Bt){const Kt={};for(let Qt=0;Qtthis._layers[fr.id]),Kt=Bt[0];if(Kt.visibility==="none")continue;const qt=Kt.source||"";let Qt=this.familiesBySource[qt];Qt||(Qt=this.familiesBySource[qt]={});const As=Kt.sourceLayer||"_geojsonTileLayer";let gs=Qt[As];gs||(gs=Qt[As]=[]),gs.push(Bt)}}}const y=1*i.fl;class _{constructor(ye){const ze={},Je=[];for(const Kt in ye){const qt=ye[Kt],Qt=ze[Kt]={};for(const As in qt.glyphs){const gs=qt.glyphs[+As];if(!gs||gs.bitmap.width===0||gs.bitmap.height===0)continue;const fr=gs.metrics.localGlyph?y:1,qr={x:0,y:0,w:gs.bitmap.width+2*fr,h:gs.bitmap.height+2*fr};Je.push(qr),Qt[As]=qr}}const{w:St,h:Nt}=i.G(Je),Bt=new i.fk({width:St||1,height:Nt||1});for(const Kt in ye){const qt=ye[Kt];for(const Qt in qt.glyphs){const As=qt.glyphs[+Qt];if(!As||As.bitmap.width===0||As.bitmap.height===0)continue;const gs=ze[Kt][Qt],fr=As.metrics.localGlyph?y:1;i.fk.copy(As.bitmap,Bt,{x:0,y:0},{x:gs.x+fr,y:gs.y+fr},As.bitmap)}}this.image=Bt,this.positions=ze}}function b(Vt,ye,ze){Vt[ye]?ze&&(Vt[ye].center=ze):Vt[ye]={floorIds:new Set,center:ze||[0,0],floors:{}}}function w(Vt,ye,ze,Je){for(const St of ye)b(Vt,St),Vt[St].floors[ze]=Je,Vt[St].floorIds.add(ze)}function j(Vt){return{id:Vt.properties.id.toString(),center:Vt.properties.center.toString().split(";").map(Number)}}function k(Vt){return{id:Vt.properties.id.toString(),isDefault:!!Vt.properties.is_default&&Vt.properties.is_default,connections:Vt.properties.connected_floor_ids?new Set(Vt.properties.connected_floor_ids.toString().split(";")):new Set,conflicts:Vt.properties.conflicted_floor_ids?new Set(Vt.properties.conflicted_floor_ids.toString().split(";")):new Set,buildings:Vt.properties.building_ids?new Set(Vt.properties.building_ids.toString().split(";")):new Set,name:Vt.properties.name.toString(),zIndex:Vt.properties.z_index}}function S(Vt,ye){return ye.every(ze=>Vt.properties&&Vt.properties[ze]!=null)}function T(Vt){return S(Vt,["type","id","name"])&&Vt.properties.type==="building"}function I(Vt){return S(Vt,["type","id","name","z_index"])&&Vt.properties.type==="floor"}i.fj(_,"GlyphAtlas");class L{constructor(ye){this.tileID=new i.aQ(ye.tileID.overscaledZ,ye.tileID.wrap,ye.tileID.canonical.z,ye.tileID.canonical.x,ye.tileID.canonical.y),this.tileZoom=ye.tileZoom,this.uid=ye.uid,this.zoom=ye.zoom,this.lut=ye.lut,this.canonical=ye.tileID.canonical,this.pixelRatio=ye.pixelRatio,this.tileSize=ye.tileSize,this.source=ye.source,this.scope=ye.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=ye.showCollisionBoxes,this.collectResourceTiming=!!ye.request&&ye.request.collectResourceTiming,this.promoteId=ye.promoteId,this.isSymbolTile=ye.isSymbolTile,this.tileTransform=i.aZ(ye.tileID.canonical,ye.projection),this.projection=ye.projection,this.worldview=ye.worldview,this.localizableLayerIds=ye.localizableLayerIds,this.brightness=ye.brightness,this.extraShadowCaster=!!ye.extraShadowCaster,this.tessellationStep=ye.tessellationStep,this.scaleFactor=ye.scaleFactor,this.worldview=ye.worldview,this.indoor=ye.indoor}parse(ye,ze,Je,St,Nt,Bt){this.status="parsing",this.data=ye,this.collisionBoxArray=new i.b3;const Kt=new i.fm(Object.keys(ye.layers).sort()),qt=new i.fn(this.tileID,this.promoteId);qt.bucketLayerIDs=[];const Qt={},As=new i.fo(256,256),gs={featureIndex:qt,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:As,availableImages:Je,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const Cn=this.indoor.indoorState.activeFloorsVisible,Mn=function(wn,ma,lo){const qo=function(Xi,ba){if(!Xi)return i.w("No source layers defined in indoor specification"),ba;if(Xi.size===0)return ba;const Qi=Xi.difference(ba);for(const vi of Qi)i.w(`Missing source layer required in indoor specification: ${vi}`);return ba.intersection(ba)}(ma.sourceLayers,new Set(Object.keys(wn.layers))),Va=ma.indoorState,Ko=function(Xi,ba,Qi,vi){const ra=new Set,Ji=new Set,ic=new Set,vc=new Map,Td={},Ap=vl=>{const Nu=vc.get(vl)||new Set;for(const Xc of ra)if((vc.get(Xc)||new Set).has(vl)||Nu.has(Xc))return!0;return!1};for(const vl of ba){const Nu=Xi.layers[vl];if(Nu)for(let Xc=0;Xc=Qi.maxzoom||Qi.visibility==="none")continue;R(ba,this.zoom,gs.brightness,Je,this.worldview);const vi=Qt[Qi.id]=Qi.createBucket({index:qt.bucketLayerIDs.length,layers:ba,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:qo,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:St,worldview:this.worldview,localizable:Ko});qt.bucketLayerIDs.push(ba.map(Ji=>i.B(Ji.id,Ji.scope)));let ra=vi.prepare?vi.prepare():null;ra!=null?(ra=ra.then(()=>vi.populate(Va,gs,this.tileID.canonical,this.tileTransform)),fr.push(ra)):vi.populate(Va,gs,this.tileID.canonical,this.tileTransform)}}const ur=()=>{let Cn,Mn,wn,ma,lo,qo;As.trim();const Va={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},Ko=()=>{if(Cn)return this.status="done",Bt(Cn);if(this.extraShadowCaster)this.status="done",Bt(null,{buckets:Object.values(Qt).filter(ba=>!ba.isEmpty()),featureIndex:qt,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:gs.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(Mn&&wn&&ma){const ba=new _(Mn),Qi=new Map;for(const[Ji,ic]of wn.entries()){const{imagePosition:vc}=i.fu(Ji,ic,i.fv);Qi.set(Ji,vc)}const vi={};for(const Ji in Qt){const ic=Qt[Ji];ic instanceof i.b4&&(R(ic.layers,this.zoom,gs.brightness,Je,this.worldview),vi[Ji]=i.fw(ic,Mn,ba.positions,wn,Qi,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,lo,this.worldview))}const ra={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(Nt,wn,lo,()=>{ra.iconsPending=!1,Xi(vi,ba,ra)}),this.rasterizeIfNeeded(Nt,ma,qo,()=>{ra.patternsPending=!1,Xi(vi,ba,ra)})}},Xi=(ba,Qi,vi,ra)=>{if(vi.iconsPending||vi.patternsPending)return;const Ji=new i.fx(wn,ma,this.lut);for(const ic in Qt){const vc=Qt[ic];if(ic in ba)i.fy(vc,ba[ic],this.showCollisionBoxes,Je,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,wn,Ji);else if(vc.hasPattern&&(vc instanceof i.ba||vc instanceof i.bb||vc instanceof i.ea)){R(vc.layers,this.zoom,gs.brightness,Je,this.worldview);const Td=Object.fromEntries(Ji.patternPositions);vc.addFeatures(gs,this.tileID.canonical,Td,Je,this.tileTransform,this.brightness)}}this.status="done",Bt(null,{buckets:Object.values(Qt).filter(ic=>!ic.isEmpty()),featureIndex:qt,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Qi.image,lineAtlas:As,imageAtlas:Ji,brightness:gs.brightness})};if(!this.extraShadowCaster){const ba=i.fs(gs.glyphDependencies,ra=>Object.keys(ra).map(Number));Object.keys(ba).length?Nt.send("getGlyphs",{uid:this.uid,stacks:ba},(ra,Ji)=>{Cn||(Cn=ra,Mn=Ji,Ko())},void 0,!1,Va):Mn={};const Qi=Array.from(gs.iconDependencies.keys()).map(ra=>i.I.parse(ra));Qi.length?Nt.send("getImages",{images:Qi,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(ra,Ji)=>{Cn||(Cn=ra,wn=new Map,lo=this.updateImageMapAndGetImageTaskQueue(wn,Ji,gs.iconDependencies),Ko())},void 0,!1,Va):(wn=new Map,lo=new Map);const vi=Array.from(gs.patternDependencies.keys()).map(ra=>i.I.parse(ra));vi.length?Nt.send("getImages",{images:vi,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(ra,Ji)=>{Cn||(Cn=ra,ma=new Map,qo=this.updateImageMapAndGetImageTaskQueue(ma,Ji,gs.patternDependencies),Ko())},void 0,!1,Va):(ma=new Map,qo=new Map)}if(gs.elevationFeatures&&gs.elevationFeatures.length>0){const ba=[];for(const vi of Object.values(Qt))if(vi instanceof i.bb){const ra=vi.getUnevaluatedPortalGraph();ra&&ba.push(ra)}const Qi=i.ft.evaluate(ba);for(const vi of Object.values(Qt))if(vi instanceof i.bb){const ra=ye.layers[Kt.decode(vi.sourceLayerIndex)];vi.setEvaluatedPortalGraph(Qi,ra,this.tileID.canonical,gs.availableImages,gs.brightness)}}Ko()};fr.length>0?Promise.allSettled(fr).then(ur).catch(Bt):ur()}updateParameters(ye){this.scaleFactor=ye.scaleFactor,this.showCollisionBoxes=ye.showCollisionBoxes,this.projection=ye.projection,this.brightness=ye.brightness,this.tileTransform=i.aZ(ye.tileID.canonical,ye.projection),this.extraShadowCaster=ye.extraShadowCaster,this.lut=ye.lut,this.worldview=ye.worldview,this.indoor=ye.indoor}rasterizeIfNeeded(ye,ze,Je,St){Array.from(ze.values()).some(Nt=>Nt.usvg)?this.rasterize(ye,ze,Je,St):St()}updateImageMapAndGetImageTaskQueue(ye,ze,Je){const St=new Map;for(const Nt of ze.keys()){const Bt=Je.get(Nt)||[];for(const Kt of Bt){const qt=Kt.toString(),Qt=ze.get(Kt.id.toString());Qt.usvg?St.has(qt)||(St.set(qt,Kt),ye.set(qt,Object.assign({},Qt))):ye.set(qt,Qt)}}return St}rasterize(ye,ze,Je,St){this.rasterizeTask=ye.send("rasterizeImages",{scope:this.scope,tasks:Je},(Nt,Bt)=>{if(!Nt)for(const[Kt,qt]of Bt.entries()){const Qt=Object.assign(ze.get(Kt),{data:qt});ze.set(Kt,Qt)}St()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function R(Vt,ye,ze,Je,St){const Nt=new i.ac(ye,{brightness:ze,worldview:St});for(const Bt of Vt)Bt.recalculate(Nt,Je)}class $ extends i.E{constructor(ye,ze,Je,St,Nt,Bt,Kt){super(),this.actor=ye,this.layerIndex=ze,this.availableImages=Je,this.availableModels=St,this.loadVectorData=Bt||i.aL,this.loading={},this.loaded={},this.deduped=new i.aK(ye.scheduler),this.isSpriteLoaded=Nt,this.scheduler=ye.scheduler,this.brightness=Kt}loadTile(ye,ze){const Je=ye.uid,St=ye&&ye.request,Nt=St&&St.collectResourceTiming,Bt=this.loading[Je]=new L(ye);Bt.abort=this.loadVectorData(ye,(Kt,qt)=>{const Qt=!this.loading[Je];if(delete this.loading[Je],Bt.cancelRasterize(),Qt||Kt||!qt)return Bt.status="done",Qt||(this.loaded[Je]=Bt),ze(Kt);const As=qt.rawData,gs={},fr=i.aM(qt.responseHeaders);fr&&fr.expires&&(gs.expires=fr.expires),fr&&fr.cacheControl&&(gs.cacheControl=fr.cacheControl),Bt.vectorTile=qt.vectorTile||new i.fz(new i.bt(As));const qr=()=>{Bt.parse(Bt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(ur,Cn)=>{if(ur||!Cn)return ze(ur);const Mn={};if(Nt){const wn=d(St);wn.length>0&&(Mn.resourceTiming=JSON.parse(JSON.stringify(wn)))}ze(null,Object.assign({rawTileData:As.slice(0),responseHeaders:qt.responseHeaders},Cn,gs,Mn))})};this.isSpriteLoaded?qr():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(qr,{type:"parseTile",isSymbolTile:ye.isSymbolTile,zoom:ye.tileZoom}):qr()}),this.loaded=this.loaded||{},this.loaded[Je]=Bt})}reloadTile(ye,ze){const Je=this.loaded,St=ye.uid;if(Je&&Je[St]){const Nt=Je[St];Nt.updateParameters(ye);const Bt=(Kt,qt)=>{const Qt=Nt.reloadCallback;Qt&&(delete Nt.reloadCallback,Nt.parse(Nt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Qt)),ze(Kt,qt)};Nt.status==="parsing"?Nt.reloadCallback=Bt:Nt.status==="done"&&(Nt.vectorTile?Nt.parse(Nt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Bt):Bt())}else ze(null,void 0)}abortTile(ye,ze){const Je=ye.uid,St=this.loading[Je];St&&(St.abort&&St.abort(),delete this.loading[Je]),ze()}removeTile(ye,ze){const Je=this.loaded,St=ye.uid;Je&&Je[St]&&delete Je[St],ze()}}class q{loadTile(ye,ze){const{uid:Je,encoding:St,rawImageData:Nt,padding:Bt}=ye,Kt=ImageBitmap&&Nt instanceof ImageBitmap?this.getImageData(Nt,Bt):Nt;ze(null,new i.fA(Je,Kt,St,Bt<1))}reloadTile(ye,ze){ze(null,null)}abortTile(ye,ze){ze()}removeTile(ye,ze){ze()}getImageData(ye,ze){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(ye.width,ye.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=ye.width,this.offscreenCanvas.height=ye.height,this.offscreenCanvasContext.drawImage(ye,0,0,ye.width,ye.height);const Je=this.offscreenCanvasContext.getImageData(-ze,-ze,ye.width+2*ze,ye.height+2*ze);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),Je}}i.bs.setPbf(i.bt);class U{constructor(ye){this._mrt=new i.bs(ye.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=ye.uid,this.tileID=ye.tileID,this.source=ye.source}parse(ye,ze){const Je=this._mrt;this.status="parsing",this._entireBuffer=ye;try{Je.parseHeader(ye),this._isHeaderLoaded=!0;const St=[];for(const Nt in Je.layers){const Bt=Je.getLayer(Nt),Kt=Bt.getDataRange(Bt.getBandList()),qt=Je.createDecodingTask(Kt),Qt=ye.slice(Kt.firstByte,Kt.lastByte+1),As=i.bs.performDecoding(Qt,qt).then(gs=>qt.complete(null,gs)).catch(gs=>qt.complete(gs,null));St.push(As)}Promise.allSettled(St).then(()=>ze(null,Je)).catch(Nt=>ze(Nt))}catch(St){ze(St)}}}class H{constructor(ye){this.actor=ye,this.loading={},this.loaded={}}loadTile(ye,ze){const Je=ye.uid,St=ye.request,Nt=this.loading[Je]=new U(ye),{cancel:Bt}=i.bu(St,(Kt,qt,Qt)=>{const As=!this.loading[Je];if(delete this.loading[Je],As||Kt||!qt)return Nt.status="done",As||(this.loaded[Je]=Nt),ze(Kt);Nt.parse(qt,(gs,fr)=>{if(gs||!fr)return ze(gs);ze(null,fr,Qt)}),this.loaded[Je]=Nt});Nt.abort=Bt}reloadTile(ye,ze){ze(null,void 0)}abortTile(ye,ze){const Je=ye.uid,St=this.loading[Je];St&&(St.abort&&St.abort(),delete this.loading[Je]),ze()}removeTile(ye,ze){const Je=ye.uid;this.loaded[Je]&&delete this.loaded[Je],ze()}decodeRasterArray(ye,ze){i.bs.performDecoding(ye.buffer,ye.task).then(Je=>ze(null,Je)).catch(Je=>ze(Je))}}const Y=i.fB.prototype.toGeoJSON;class se{constructor(ye){this._feature=ye,this.extent=i.al,this.type=ye.type,this.properties=ye.tags,"id"in ye&&!isNaN(ye.id)&&(this.id=parseInt(ye.id,10))}loadGeometry(){if(this._feature.type===1){const ye=[];for(const ze of this._feature.geometry)ye.push([new i.P(ze[0],ze[1])]);return ye}{const ye=[];for(const ze of this._feature.geometry){const Je=[];for(const St of ze)Je.push(new i.P(St[0],St[1]));ye.push(Je)}return ye}}toGeoJSON(ye,ze,Je){return Y.call(this,ye,ze,Je)}}class te{constructor(ye,ze){this.name=ye,this.extent=i.al,this.length=ze.length,this._jsonFeatures=ze}feature(ye){return new se(this._jsonFeatures[ye])}}class Q{constructor(ye){this.layers={},this.extent=i.al;for(const ze of Object.keys(ye))this.layers[ze]=new te(ze,ye[ze])}}const de=64/4096,re=128;class ae{constructor(){this.features=new Map}clear(){this.features.clear()}load(ye=[],ze){for(const Je of ye){const St=Je.id;if(St==null)continue;let Nt=this.features.get(St);Nt&&this.updateCache(Nt,ze),Je.geometry?(Nt=he(Je),this.updateCache(Nt,ze),this.features.set(St,Nt)):this.features.delete(St),this.updateCache(Nt,ze)}}updateCache(ye,ze){for(const{canonical:Je,uid:St}of Object.values(ze)){const{z:Nt,x:Bt,y:Kt}=Je;le(ye,Math.pow(2,Nt),Bt,Kt)&&delete ze[St]}}getTile(ye,ze,Je){const St=Math.pow(2,ye),Nt=[];for(const Bt of this.features.values())le(Bt,St,ze,Je)&&Nt.push(Ne(Bt,St,ze,Je));return{features:Nt}}getFeatures(){return[...this.features.values()]}}function le({minX:Vt,minY:ye,maxX:ze,maxY:Je},St,Nt,Bt){return Vt<(Nt+1+de)/St&&ye<(Bt+1+de)/St&&ze>(Nt-de)/St&&Je>(Bt-de)/St}function he(Vt){const{id:ye,geometry:ze,properties:Je}=Vt;if(!ze)return;if(ze.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:St,coordinates:Nt}=ze,Bt={id:ye,type:1,geometry:[],tags:Je,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Kt=Bt.geometry;if(St==="Point")be(Nt,Kt,Bt);else if(St==="MultiPoint")for(const qt of Nt)be(qt,Kt,Bt);else if(St==="LineString")Bt.type=2,_e(Nt,Kt,Bt);else if(St==="MultiLineString")Bt.type=2,je(Nt,Kt,Bt);else if(St==="Polygon")Bt.type=3,je(Nt,Kt,Bt,!0);else{if(St!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");Bt.type=3;for(const qt of Nt)je(qt,Kt,Bt,!0)}return Bt}function be([Vt,ye],ze,Je){const St=i.aF(Vt);let Nt=i.aJ(ye);Nt=Nt<0?0:Nt>1?1:Nt,ze.push(St,Nt),Je.minX=Math.min(Je.minX,St),Je.minY=Math.min(Je.minY,Nt),Je.maxX=Math.max(Je.maxX,St),Je.maxY=Math.max(Je.maxY,Nt)}function _e(Vt,ye,ze,Je=!1,St=!1){const Nt=[];for(const Bt of Vt)be(Bt,Nt,ze);ye.push(Nt),Je&&function(Bt,Kt){let qt=0;for(let Qt=0,As=Bt.length,gs=As-2;Qt0===Kt)for(let Qt=0,As=Bt.length;Qt=Bt&&gs>=Bt||(Qt>=Bt?(As+=Math.round(ur*((Bt-Qt)/qr)),Qt=Bt):gs>=Bt&&(fr=As+Math.round(ur*((Bt-Qt)/qr)),gs=Bt),As>=Bt&&fr>=Bt||(As>=Bt?(Qt+=Math.round(qr*((Bt-As)/ur)),As=Bt):fr>=Bt&&(gs=Qt+Math.round(qr*((Bt-As)/ur)),fr=Bt),Kt&&Qt===Kt[Kt.length-1][0]&&As===Kt[Kt.length-1][1]||(Kt=[[Qt,As]],St.push(Kt)),Kt.push([gs,fr])))))}}function we(Vt,ye,ze,Je,St){const Nt=(ze-de)/ye,Bt=(Je-de)/ye,Kt=(ze+1+de)/ye,qt=(Je+1+de)/ye;function Qt(fr,qr){let ur=0;return frKt&&(ur|=2),qrqt&&(ur|=8),ur}let As=[];for(let fr=1;fr<=8;fr*=2){let qr=Vt[Vt.length-2],ur=Vt[Vt.length-1],Cn=!(Qt(qr,ur)&fr);for(let Mn=0;Mn>31}function ut(Vt,ye){const{geometry:ze,type:Je}=Vt;let St=0,Nt=0;if(Je===1){ye.writeVarint(Ae(1,ze.length));for(const Bt of ze){const Kt=Bt[0]-St,qt=Bt[1]-Nt;ye.writeVarint(Ue(Kt)),ye.writeVarint(Ue(qt)),St+=Kt,Nt+=qt}}else for(const Bt of ze){ye.writeVarint(Ae(1,1));const Kt=Bt.length-(Je===3?1:0);for(let qt=0;qtVt},me=Math.fround||(Xe=new Float32Array(1),Vt=>(Xe[0]=+Vt,Xe[0]));var Xe;const ot=3,nt=5,Se=6;class it{constructor(ye){this.options=Object.assign(Object.create(Rt),ye),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(ye){const{log:ze,minZoom:Je,maxZoom:St}=this.options;ze&&console.time("total time");const Nt=`prepare ${ye.length} points`;ze&&console.time(Nt),this.points=ye;const Bt=[];for(let qt=0;qt=Je;qt--){const Qt=+Date.now();Kt=this.trees[qt]=this._createTree(this._cluster(Kt,qt)),ze&&console.log("z%d: %d clusters in %dms",qt,Kt.numItems,+Date.now()-Qt)}return ze&&console.timeEnd("total time"),this}getClusters(ye,ze){let Je=((ye[0]+180)%360+360)%360-180;const St=Math.max(-90,Math.min(90,ye[1]));let Nt=ye[2]===180?180:((ye[2]+180)%360+360)%360-180;const Bt=Math.max(-90,Math.min(90,ye[3]));if(ye[2]-ye[0]>=360)Je=-180,Nt=180;else if(Je>Nt){const gs=this.getClusters([Je,St,180,Bt],ze),fr=this.getClusters([-180,St,Nt,Bt],ze);return gs.concat(fr)}const Kt=this.trees[this._limitZoom(ze)],qt=Kt.range(qe(Je),Ze(Bt),qe(Nt),Ze(St)),Qt=Kt.data,As=[];for(const gs of qt){const fr=this.stride*gs;As.push(Qt[fr+nt]>1?$e(Qt,fr,this.clusterProps):this.points[Qt[fr+ot]])}return As}getChildren(ye){const ze=this._getOriginId(ye),Je=this._getOriginZoom(ye),St="No cluster with the specified id.",Nt=this.trees[Je];if(!Nt)throw new Error(St);const Bt=Nt.data;if(ze*this.stride>=Bt.length)throw new Error(St);const Kt=this.options.radius/(this.options.extent*Math.pow(2,Je-1)),qt=Nt.within(Bt[ze*this.stride],Bt[ze*this.stride+1],Kt),Qt=[];for(const As of qt){const gs=As*this.stride;Bt[gs+4]===ye&&Qt.push(Bt[gs+nt]>1?$e(Bt,gs,this.clusterProps):this.points[Bt[gs+ot]])}if(Qt.length===0)throw new Error(St);return Qt}getLeaves(ye,ze,Je){const St=[];return this._appendLeaves(St,ye,ze=ze||10,Je=Je||0,0),St}getTile(ye,ze,Je){const St=this.trees[this._limitZoom(ye)],Nt=Math.pow(2,ye),{extent:Bt,radius:Kt}=this.options,qt=Kt/Bt,Qt=(Je-qt)/Nt,As=(Je+1+qt)/Nt,gs={features:[]};return this._addTileFeatures(St.range((ze-qt)/Nt,Qt,(ze+1+qt)/Nt,As),St.data,ze,Je,Nt,gs),ze===0&&this._addTileFeatures(St.range(1-qt/Nt,Qt,1,As),St.data,Nt,Je,Nt,gs),ze===Nt-1&&this._addTileFeatures(St.range(0,Qt,qt/Nt,As),St.data,-1,Je,Nt,gs),gs.features.length?gs:null}getClusterExpansionZoom(ye){let ze=this._getOriginZoom(ye)-1;for(;ze<=this.options.maxZoom;){const Je=this.getChildren(ye);if(ze++,Je.length!==1)break;ye=Je[0].properties.cluster_id}return ze}_appendLeaves(ye,ze,Je,St,Nt){const Bt=this.getChildren(ze);for(const Kt of Bt){const qt=Kt.properties;if(qt&&qt.cluster?Nt+qt.point_count<=St?Nt+=qt.point_count:Nt=this._appendLeaves(ye,qt.cluster_id,Je,St,Nt):Nt1;let As,gs,fr;if(Qt)As=ct(ze,qt,this.clusterProps),gs=ze[qt],fr=ze[qt+1];else{const Cn=this.points[ze[qt+ot]];As=Cn.properties;const[Mn,wn]=Cn.geometry.coordinates;gs=qe(Mn),fr=Ze(wn)}const qr={type:1,geometry:[[Math.round(this.options.extent*(gs*Nt-Je)),Math.round(this.options.extent*(fr*Nt-St))]],tags:As};let ur;ur=Qt||this.options.generateId?ze[qt+ot]:this.points[ze[qt+ot]].id,ur!==void 0&&(qr.id=ur),Bt.features.push(qr)}}_limitZoom(ye){return Math.max(this.options.minZoom,Math.min(Math.floor(+ye),this.options.maxZoom+1))}_cluster(ye,ze){const{radius:Je,extent:St,reduce:Nt,minPoints:Bt}=this.options,Kt=Je/(St*Math.pow(2,ze)),qt=ye.data,Qt=[],As=this.stride;for(let gs=0;gsze&&(Mn+=qt[ma+nt])}if(Mn>Cn&&Mn>=Bt){let wn,ma=fr*Cn,lo=qr*Cn,qo=-1;const Va=(gs/As<<5)+(ze+1)+this.points.length;for(const Ko of ur){const Xi=Ko*As;if(qt[Xi+2]<=ze)continue;qt[Xi+2]=ze;const ba=qt[Xi+nt];ma+=qt[Xi]*ba,lo+=qt[Xi+1]*ba,qt[Xi+4]=Va,Nt&&(wn||(wn=this._map(qt,gs,!0),qo=this.clusterProps.length,this.clusterProps.push(wn)),Nt(wn,this._map(qt,Xi)))}qt[gs+4]=Va,Qt.push(ma/Mn,lo/Mn,1/0,Va,-1,Mn),Nt&&Qt.push(qo)}else{for(let wn=0;wn1)for(const wn of ur){const ma=wn*As;if(!(qt[ma+2]<=ze)){qt[ma+2]=ze;for(let lo=0;lo>5}_getOriginZoom(ye){return(ye-this.points.length)%32}_map(ye,ze,Je){if(ye[ze+nt]>1){const Bt=this.clusterProps[ye[ze+Se]];return Je?Object.assign({},Bt):Bt}const St=this.points[ye[ze+ot]].properties,Nt=this.options.map(St);return Je&&Nt===St?Object.assign({},Nt):Nt}}function $e(Vt,ye,ze){return{type:"Feature",id:Vt[ye+ot],properties:ct(Vt,ye,ze),geometry:{type:"Point",coordinates:[(Je=Vt[ye],360*(Je-.5)),Qe(Vt[ye+1])]}};var Je}function ct(Vt,ye,ze){const Je=Vt[ye+nt],St=Je>=1e4?`${Math.round(Je/1e3)}k`:Je>=1e3?Math.round(Je/100)/10+"k":Je,Nt=Vt[ye+Se],Bt=Nt===-1?{}:Object.assign({},ze[Nt]);return Object.assign(Bt,{cluster:!0,cluster_id:Vt[ye+ot],point_count:Je,point_count_abbreviated:St})}function qe(Vt){return Vt/360+.5}function Ze(Vt){const ye=Math.sin(Vt*Math.PI/180),ze=.5-.25*Math.log((1+ye)/(1-ye))/Math.PI;return ze<0?0:ze>1?1:ze}function Qe(Vt){const ye=(180-360*Vt)*Math.PI/180;return 360*Math.atan(Math.exp(ye))/Math.PI-90}function We(Vt,ye,ze,Je){let St=Je;const Nt=ye+(ze-ye>>1);let Bt,Kt=ze-ye;const qt=Vt[ye],Qt=Vt[ye+1],As=Vt[ze],gs=Vt[ze+1];for(let fr=ye+3;frSt)Bt=fr,St=qr;else if(qr===St){const ur=Math.abs(fr-Nt);urJe&&(Bt-ye>3&&We(Vt,ye,Bt,Je),Vt[Bt+2]=St,ze-Bt>3&&We(Vt,Bt,ze,Je))}function He(Vt,ye,ze,Je,St,Nt){let Bt=St-ze,Kt=Nt-Je;if(Bt!==0||Kt!==0){const qt=((Vt-ze)*Bt+(ye-Je)*Kt)/(Bt*Bt+Kt*Kt);qt>1?(ze=St,Je=Nt):qt>0&&(ze+=Bt*qt,Je+=Kt*qt)}return Bt=Vt-ze,Kt=ye-Je,Bt*Bt+Kt*Kt}function et(Vt,ye,ze,Je){const St={id:Vt??null,type:ye,geometry:ze,tags:Je,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(ye==="Point"||ye==="MultiPoint"||ye==="LineString")Tt(St,ze);else if(ye==="Polygon")Tt(St,ze[0]);else if(ye==="MultiLineString")for(const Nt of ze)Tt(St,Nt);else if(ye==="MultiPolygon")for(const Nt of ze)Tt(St,Nt[0]);return St}function Tt(Vt,ye){for(let ze=0;ze0&&(Bt+=Je?(St*As-Qt*Nt)/2:Math.sqrt(Math.pow(Qt-St,2)+Math.pow(As-Nt,2))),St=Qt,Nt=As}const Kt=ye.length-3;ye[2]=1,We(ye,0,Kt,ze),ye[Kt+2]=1,ye.size=Math.abs(Bt),ye.start=0,ye.end=ye.size}function ss(Vt,ye,ze,Je){for(let St=0;St1?1:ze}function Ct(Vt,ye,ze,Je,St,Nt,Bt,Kt){if(Je/=ye,Nt>=(ze/=ye)&&Bt=Je)return null;const qt=[];for(const Qt of Vt){const As=Qt.geometry;let gs=Qt.type;const fr=St===0?Qt.minX:Qt.minY,qr=St===0?Qt.maxX:Qt.maxY;if(fr>=ze&&qr=Je)continue;let ur=[];if(gs==="Point"||gs==="MultiPoint")Is(As,ur,ze,Je,St);else if(gs==="LineString")qs(As,ur,ze,Je,St,!1,Kt.lineMetrics);else if(gs==="MultiLineString")Wn(As,ur,ze,Je,St,!1);else if(gs==="Polygon")Wn(As,ur,ze,Je,St,!0);else if(gs==="MultiPolygon")for(const Cn of As){const Mn=[];Wn(Cn,Mn,ze,Je,St,!0),Mn.length&&ur.push(Mn)}if(ur.length){if(Kt.lineMetrics&&gs==="LineString"){for(const Cn of ur)qt.push(et(Qt.id,gs,Cn,Qt.tags));continue}gs!=="LineString"&&gs!=="MultiLineString"||(ur.length===1?(gs="LineString",ur=ur[0]):gs="MultiLineString"),gs!=="Point"&&gs!=="MultiPoint"||(gs=ur.length===3?"Point":"MultiPoint"),qt.push(et(Qt.id,gs,ur,Qt.tags))}}return qt.length?qt:null}function Is(Vt,ye,ze,Je,St){for(let Nt=0;Nt=ze&&Bt<=Je&&ii(ye,Vt[Nt],Vt[Nt+1],Vt[Nt+2])}}function qs(Vt,ye,ze,Je,St,Nt,Bt){let Kt=gr(Vt);const qt=St===0?bo:si;let Qt,As,gs=Vt.start;for(let Mn=0;Mnze&&(As=qt(Kt,wn,ma,qo,Va,ze),Bt&&(Kt.start=gs+Qt*As)):Ko>Je?Xi=ze&&(As=qt(Kt,wn,ma,qo,Va,ze),ba=!0),Xi>Je&&Ko<=Je&&(As=qt(Kt,wn,ma,qo,Va,Je),ba=!0),!Nt&&ba&&(Bt&&(Kt.end=gs+Qt*As),ye.push(Kt),Kt=gr(Vt)),Bt&&(gs+=Qt)}let fr=Vt.length-3;const qr=Vt[fr],ur=Vt[fr+1],Cn=St===0?qr:ur;Cn>=ze&&Cn<=Je&&ii(Kt,qr,ur,Vt[fr+2]),fr=Kt.length-3,Nt&&fr>=3&&(Kt[fr]!==Kt[0]||Kt[fr+1]!==Kt[1])&&ii(Kt,Kt[0],Kt[1],Kt[2]),Kt.length&&ye.push(Kt)}function gr(Vt){const ye=[];return ye.size=Vt.size,ye.start=Vt.start,ye.end=Vt.end,ye}function Wn(Vt,ye,ze,Je,St,Nt){for(const Bt of Vt)qs(Bt,ye,ze,Je,St,Nt,!1)}function ii(Vt,ye,ze,Je){Vt.push(ye,ze,Je)}function bo(Vt,ye,ze,Je,St,Nt){const Bt=(Nt-ye)/(Je-ye);return ii(Vt,Nt,ze+(St-ze)*Bt,1),Bt}function si(Vt,ye,ze,Je,St,Nt){const Bt=(Nt-ze)/(St-ze);return ii(Vt,ye+(Je-ye)*Bt,Nt,1),Bt}function nn(Vt,ye){const ze=[];for(let Je=0;Je0&&ye.size<(St?Bt:Je))return void(ze.numPoints+=ye.length/3);const Kt=[];for(let qt=0;qtBt)&&(ze.numSimplified++,Kt.push(ye[qt],ye[qt+1])),ze.numPoints++;St&&function(qt,Qt){let As=0;for(let gs=0,fr=qt.length,qr=fr-2;gs0===Qt)for(let gs=0,fr=qt.length;gs24)throw new Error("maxZoom should be in the 0-24 range");if(ze.promoteId&&ze.generateId)throw new Error("promoteId and generateId cannot be used together.");let St=function(Nt,Bt){const Kt=[];if(Nt.type==="FeatureCollection")for(let qt=0;qt1&&console.time("creation"),qr=this.tiles[fr]=Zt(ye,ze,Je,St,Qt),this.tileCoords.push({z:ze,x:Je,y:St}),As)){As>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",ze,Je,St,qr.numFeatures,qr.numPoints,qr.numSimplified),console.timeEnd("creation"));const ba=`z${ze}`;this.stats[ba]=(this.stats[ba]||0)+1,this.total++}if(qr.source=ye,Nt==null){if(ze===Qt.indexMaxZoom||qr.numPoints<=Qt.indexMaxPoints)continue}else{if(ze===Qt.maxZoom||ze===Nt)continue;if(Nt!=null){const ba=Nt-ze;if(Je!==Bt>>ba||St!==Kt>>ba)continue}}if(qr.source=null,ye.length===0)continue;As>1&&console.time("clipping");const ur=.5*Qt.buffer/Qt.extent,Cn=.5-ur,Mn=.5+ur,wn=1+ur;let ma=null,lo=null,qo=null,Va=null,Ko=Ct(ye,gs,Je-ur,Je+Mn,0,qr.minX,qr.maxX,Qt),Xi=Ct(ye,gs,Je+Cn,Je+wn,0,qr.minX,qr.maxX,Qt);ye=null,Ko&&(ma=Ct(Ko,gs,St-ur,St+Mn,1,qr.minY,qr.maxY,Qt),lo=Ct(Ko,gs,St+Cn,St+wn,1,qr.minY,qr.maxY,Qt),Ko=null),Xi&&(qo=Ct(Xi,gs,St-ur,St+Mn,1,qr.minY,qr.maxY,Qt),Va=Ct(Xi,gs,St+Cn,St+wn,1,qr.minY,qr.maxY,Qt),Xi=null),As>1&&console.timeEnd("clipping"),qt.push(ma||[],ze+1,2*Je,2*St),qt.push(lo||[],ze+1,2*Je,2*St+1),qt.push(qo||[],ze+1,2*Je+1,2*St),qt.push(Va||[],ze+1,2*Je+1,2*St+1)}}getTile(ye,ze,Je){ye=+ye,ze=+ze,Je=+Je;const St=this.options,{extent:Nt,debug:Bt}=St;if(ye<0||ye>24)return null;const Kt=1<1&&console.log("drilling down to z%d-%d-%d",ye,ze,Je);let Qt,As=ye,gs=ze,fr=Je;for(;!Qt&&As>0;)As--,gs>>=1,fr>>=1,Qt=this.tiles[Zn(As,gs,fr)];return Qt&&Qt.source?(Bt>1&&(console.log("found parent tile z%d-%d-%d",As,gs,fr),console.time("drilling down")),this.splitTile(Qt.source,As,gs,fr,ye,ze,Je),Bt>1&&console.timeEnd("drilling down"),this.tiles[qt]?kn(this.tiles[qt],Nt):null):null}}function Zn(Vt,ye,ze){return 32*((1<Qt.tags&&"3d_elevation_id"in Qt.tags&&"source"in Qt.tags&&Qt.tags.source==="elevation",Nt=Je.features.filter(Qt=>St(Qt));let Bt={_geojsonTileLayer:Je.features};Nt.length>0&&(Bt={_geojsonTileLayer:Je.features.filter(Qt=>!St(Qt)),hd_road_elevation:Nt});const Kt=new Q(Bt),qt=function(Qt){const As=new i.bt;for(const gs of Object.keys(Qt))As.writeMessage(3,Me,{name:gs,features:Qt[gs]});return As.finish()}(Bt).buffer;ye(null,{vectorTile:Kt,rawData:qt})}class mi extends ${constructor(ye,ze,Je,St,Nt,Bt,Kt){super(ye,ze,Je,St,Nt,Ir,Kt),Bt&&(this.loadGeoJSON=Bt),this._dynamicIndex=new ae}loadData(ye,ze){const Je=ye&&ye.request,St=Je&&Je.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(ye,(Nt,Bt)=>{if(Nt||!Bt)return ze(Nt);if(typeof Bt!="object")return ze(new Error(`Input data given to '${ye.source}' is not a valid GeoJSON object.`));{try{if(ye.filter){const qt=i.U(ye.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(qt.result==="error")throw new Error(qt.value.map(Qt=>`${Qt.key}: ${Qt.message}`).join(", "));Bt.features=Bt.features.filter(Qt=>qt.value.evaluate({zoom:0},Qt))}ye.dynamic?(Bt.type==="Feature"&&(Bt={type:"FeatureCollection",features:[Bt]}),ye.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(Bt.features,this.loaded),ye.cluster&&(Bt.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=ye.cluster?new it(function({superclusterOptions:qt,clusterProperties:Qt}){if(!Qt||!qt)return qt;const As={},gs={},fr={accumulated:null,zoom:0},qr={properties:null},ur=Object.keys(Qt);for(const Cn of ur){const[Mn,wn]=Qt[Cn],ma=i.U(wn),lo=i.U(typeof Mn=="string"?[Mn,["accumulated"],["get",Cn]]:Mn);As[Cn]=ma.value,gs[Cn]=lo.value}return qt.map=Cn=>{qr.properties=Cn;const Mn={};for(const wn of ur)Mn[wn]=As[wn].evaluate(fr,qr);return Mn},qt.reduce=(Cn,Mn)=>{qr.properties=Mn;for(const wn of ur)fr.accumulated=Cn[wn],Cn[wn]=gs[wn].evaluate(fr,qr)},qt}(ye)).load(Bt.features):ye.dynamic?this._dynamicIndex:function(qt,Qt){return new Ra(qt,Qt)}(Bt,ye.geojsonVtOptions)}catch(qt){return ze(qt)}const Kt={};if(St){const qt=d(Je);qt&&(Kt.resourceTiming={},Kt.resourceTiming[ye.source]=JSON.parse(JSON.stringify(qt)))}ze(null,Kt)}})}reloadTile(ye,ze){const Je=this.loaded;return Je&&Je[ye.uid]?ye.partial?ze(null,void 0):super.reloadTile(ye,ze):this.loadTile(ye,ze)}loadGeoJSON(ye,ze){if(ye.request)i.m(ye.request,ze);else{if(typeof ye.data!="string")return ze(new Error(`Input data given to '${ye.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return ze(null,JSON.parse(ye.data))}catch{return ze(new Error(`Input data given to '${ye.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(ye,ze){try{ze(null,this._geoJSONIndex.getClusterExpansionZoom(ye.clusterId))}catch(Je){ze(Je)}}getClusterChildren(ye,ze){try{ze(null,this._geoJSONIndex.getChildren(ye.clusterId))}catch(Je){ze(Je)}}getClusterLeaves(ye,ze){try{ze(null,this._geoJSONIndex.getLeaves(ye.clusterId,ye.limit,ye.offset))}catch(Je){ze(Je)}}}class Go{constructor(ye,ze,Je){this.tileID=new i.aQ(ye.tileID.overscaledZ,ye.tileID.wrap,ye.tileID.canonical.z,ye.tileID.canonical.x,ye.tileID.canonical.y),this.tileZoom=ye.tileZoom,this.uid=ye.uid,this.zoom=ye.zoom,this.canonical=ye.tileID.canonical,this.pixelRatio=ye.pixelRatio,this.tileSize=ye.tileSize,this.source=ye.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=ye.projection,this.brightness=ze,this.worldview=Je}parse(ye,ze,Je,St){this.status="parsing";const Nt=new i.aQ(Je.tileID.overscaledZ,Je.tileID.wrap,Je.tileID.canonical.z,Je.tileID.canonical.x,Je.tileID.canonical.y),Bt=[],Kt=ze.familiesBySource[Je.source],qt=new i.fn(Nt,Je.promoteId);qt.bucketLayerIDs=[],qt.is3DTile=!0,i.fC(ye).then(Qt=>{if(!Qt)return St(new Error("Could not parse tile"));const As=Qt.json.extensionsUsed&&Qt.json.extensionsUsed.includes("MAPBOX_mesh_features")||Qt.json.asset.extras&&Qt.json.asset.extras.MAPBOX_mesh_features,gs=Qt.json.extensionsUsed&&Qt.json.extensionsUsed.includes("EXT_meshopt_compression"),fr=new i.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const qr in Kt)for(const ur of Kt[qr]){const Cn=ur[0];qt.bucketLayerIDs.push(ur.map(ma=>i.B(ma.id,ma.scope))),Cn.recalculate(fr,[]);const Mn=i.fD(Qt,1/i.d7(Je.tileID.canonical)),wn=new i.fE(ur,Mn,Nt,As,gs,this.brightness,qt,this.worldview);As||(wn.needsUpload=!0),Bt.push(wn),wn.evaluate(Cn)}this.status="done",St(null,{buckets:Bt,featureIndex:qt,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Qt=>St(new Error(Qt.message)))}}class yi{constructor(ye,ze,Je,St,Nt,Bt,Kt,qt){this.actor=ye,this.layerIndex=ze,this.availableImages=Je,this.availableModels=St,this.brightness=Kt,this.loading={},this.loaded={},this.worldview=qt}loadTile(ye,ze){const Je=ye.uid,St=this.loading[Je]=new Go(ye,this.brightness,this.worldview);i.bu(ye.request,(Nt,Bt)=>{const Kt=!this.loading[Je];return delete this.loading[Je],Kt||Nt?(St.status="done",Kt||(this.loaded[Je]=St),ze(Nt)):Bt&&Bt.byteLength!==0?void St.parse(Bt,this.layerIndex,ye,(qt,Qt)=>{St.status="done",this.loaded=this.loaded||{},this.loaded[Je]=St,qt||!Qt?ze(qt):ze(null,Qt)}):(St.status="done",this.loaded[Je]=St,ze())})}reloadTile(ye,ze){const Je=this.loaded,St=ye.uid;if(Je&&Je[St]){const Nt=Je[St];Nt.projection=ye.projection,Nt.brightness=ye.brightness;const Bt=(Kt,qt)=>{Nt.reloadCallback&&(delete Nt.reloadCallback,this.loadTile(ye,ze)),ze(Kt,qt)};Nt.status==="parsing"?Nt.reloadCallback=Bt:Nt.status==="done"&&this.loadTile(ye,ze)}}abortTile(ye,ze){const Je=ye.uid;this.loading[Je]&&delete this.loading[Je],ze()}removeTile(ye,ze){const Je=this.loaded,St=ye.uid;Je&&Je[St]&&delete Je[St],ze()}}class Vl{constructor(ye){this.self=ye,this.actor=new i.fG(ye,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new i.x,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=i.cm({name:"mercator"}),this.workerSourceTypes={vector:$,geojson:mi,"raster-dem":q,"raster-array":H,"batched-model":yi},this.workerSources={},this.self.registerWorkerSource=(ze,Je)=>{if(this.workerSourceTypes[ze])throw new Error(`Worker source with name "${ze}" already registered.`);this.workerSourceTypes[ze]=Je},this.self.registerRTLTextPlugin=ze=>{if(i.fH.isParsed())throw new Error("RTL text plugin already registered.");i.fH.setState({pluginStatus:i.fI.parsed,pluginURL:i.fH.getPluginURL()}),i.fH.applyArabicShaping=ze.applyArabicShaping,i.fH.processBidirectionalText=ze.processBidirectionalText,i.fH.processStyledBidirectionalText=ze.processStyledBidirectionalText;for(const Je of this.rtlPluginParsingListeners)Je(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(ye,ze,Je){delete this.layerIndexes[ye],delete this.availableImages[ye],delete this.availableModels[ye],delete this.workerSources[ye],Je()}checkIfReady(ye,ze,Je){Je()}setReferrer(ye,ze){this.referrer=ze}spriteLoaded(ye,ze){this.isSpriteLoaded[ye]||(this.isSpriteLoaded[ye]={});const{scope:Je,isLoaded:St}=ze;if(this.isSpriteLoaded[ye][Je]=St,this.workerSources[ye]&&this.workerSources[ye][Je])for(const Nt in this.workerSources[ye][Je]){const Bt=this.workerSources[ye][Je][Nt];for(const Kt in Bt){const qt=Bt[Kt];qt instanceof $&&(qt.isSpriteLoaded=St,qt.fire(new i.z("isSpriteLoaded")))}}}setImages(ye,ze,Je){this.availableImages[ye]||(this.availableImages[ye]={});const{scope:St,images:Nt}=ze;if(this.availableImages[ye][St]=Nt,this.workerSources[ye]&&this.workerSources[ye][St]){for(const Bt in this.workerSources[ye][St]){const Kt=this.workerSources[ye][St][Bt];for(const qt in Kt)Kt[qt].availableImages=Nt}Je()}else Je()}setModels(ye,{scope:ze,models:Je},St){if(this.availableModels[ye]||(this.availableModels[ye]={}),this.availableModels[ye][ze]=Je,this.workerSources[ye]&&this.workerSources[ye][ze]){for(const Nt in this.workerSources[ye][ze]){const Bt=this.workerSources[ye][ze][Nt];for(const Kt in Bt)Bt[Kt].availableModels=Je}St()}else St()}setProjection(ye,ze){this.projections[ye]=i.cm(ze)}setBrightness(ye,ze,Je){this.brightness=ze,Je()}setWorldview(ye,ze,Je){this.worldview=ze,Je()}setLayers(ye,ze,Je){this.getLayerIndex(ye,ze.scope).replace(ze.layers,ze.options),Je()}updateLayers(ye,ze,Je){this.getLayerIndex(ye,ze.scope).update(ze.layers,ze.removedIds,ze.options),Je()}loadTile(ye,ze,Je){ze.projection=this.projections[ye]||this.defaultProjection,this.getWorkerSource(ye,ze.type,ze.source,ze.scope).loadTile(ze,Je)}decodeRasterArray(ye,ze,Je){this.getWorkerSource(ye,ze.type,ze.source,ze.scope).decodeRasterArray(ze,Je)}reloadTile(ye,ze,Je){ze.projection=this.projections[ye]||this.defaultProjection,this.getWorkerSource(ye,ze.type,ze.source,ze.scope).reloadTile(ze,Je)}abortTile(ye,ze,Je){this.getWorkerSource(ye,ze.type,ze.source,ze.scope).abortTile(ze,Je)}removeTile(ye,ze,Je){this.getWorkerSource(ye,ze.type,ze.source,ze.scope).removeTile(ze,Je)}removeSource(ye,ze,Je){if(!(this.workerSources[ye]&&this.workerSources[ye][ze.scope]&&this.workerSources[ye][ze.scope][ze.type]&&this.workerSources[ye][ze.scope][ze.type][ze.source]))return;const St=this.workerSources[ye][ze.scope][ze.type][ze.source];delete this.workerSources[ye][ze.scope][ze.type][ze.source],St.removeSource!==void 0?St.removeSource(ze,Je):Je()}loadWorkerSource(ye,ze,Je){try{this.self.importScripts(ze.url),Je()}catch(St){Je(St)}}syncRTLPluginState(ye,ze,Je){if(i.fH.isParsed())Je(null,!0);else if(i.fH.isParsing())this.rtlPluginParsingListeners.push(Je);else try{i.fH.setState(ze);const St=i.fH.getPluginURL();!i.fH.isLoaded()||i.fH.isParsed()||i.fH.isParsing()||St==null||(i.fH.setState({pluginStatus:i.fI.parsing,pluginURL:i.fH.getPluginURL()}),this.self.importScripts(St),i.fH.isParsed()?Je(null,!0):this.rtlPluginParsingListeners.push(Je))}catch(St){Je(St)}}setDracoUrl(ye,ze){this.dracoUrl=ze}getAvailableImages(ye,ze){this.availableImages[ye]||(this.availableImages[ye]={});let Je=this.availableImages[ye][ze];return Je||(Je=[]),Je}getAvailableModels(ye,ze){this.availableModels[ye]||(this.availableModels[ye]={});let Je=this.availableModels[ye][ze];return Je||(Je={}),Je}getLayerIndex(ye,ze){this.layerIndexes[ye]||(this.layerIndexes[ye]={});let Je=this.layerIndexes[ye][ze];return Je||(Je=this.layerIndexes[ye][ze]=new f,Je.scope=ze),Je}getWorkerSource(ye,ze,Je,St){const Nt=this.workerSources;return Nt[ye]||(Nt[ye]={}),Nt[ye][St]||(Nt[ye][St]={}),Nt[ye][St][ze]||(Nt[ye][St][ze]={}),this.isSpriteLoaded[ye]||(this.isSpriteLoaded[ye]={}),Nt[ye][St][ze][Je]||(Nt[ye][St][ze][Je]=new this.workerSourceTypes[ze]({send:(Bt,Kt,qt,Qt,As,gs)=>this.actor.send(Bt,Kt,qt,ye,As,gs),scheduler:this.actor.scheduler},this.getLayerIndex(ye,St),this.getAvailableImages(ye,St),this.getAvailableModels(ye,St),this.isSpriteLoaded[ye][St],void 0,this.brightness,this.worldview)),Nt[ye][St][ze][Je]}rasterizeImagesWorker(ye,ze,Je){const St=new Map;for(const[Nt,{image:Bt,imageVariant:Kt}]of ze.tasks.entries()){const qt=this.imageRasterizer.rasterize(Kt,Bt,ze.scope,ye);St.set(Nt,qt)}Je(void 0,St)}removeRasterizedImages(ye,ze,Je){this.imageRasterizer.removeImagesFromCacheByIds(ze.imageIds,ze.scope,ye),Je()}enforceCacheSizeLimit(ye,ze){i.fJ(ze)}getWorkerPerformanceMetrics(ye,ze,Je){Je(void 0,void 0)}}return i.fF(self)&&(self.worker=new Vl(self)),Vl}),o(["./shared"],function(i){var d="3.17.0";const u={create:"create",load:"load",fullLoad:"fullLoad"},p={mark(M){performance.mark(M)},measure(M,h,x){performance.measure(M,h,x)}};function f(M){const h=M.name.split("?")[0];return i.a(h)&&h.includes("mapbox-gl.js")?"javascript":i.a(h)&&h.includes("mapbox-gl.css")?"css":i.b(h)?"fontRange":i.c(h)?"sprite":i.i(h)?"style":i.d(h)?"tilejson":"other"}var y,_={},b=function(){if(y)return _;function M(A){return!h(A)}function h(A){return typeof window>"u"||typeof document>"u"?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var F,z,V=new Blob([""],{type:"text/javascript"}),X=URL.createObjectURL(V);try{z=new Worker(X),F=!0}catch{F=!1}return z&&z.terminate(),URL.revokeObjectURL(X),F}()?function(){var F=document.createElement("canvas");F.width=F.height=1;var z=F.getContext("2d");if(!z)return!1;var V=z.getImageData(0,0,1,1);return V&&V.width===F.width}()?(x[D=A&&A.failIfMajorPerformanceCaveat]===void 0&&(x[D]=function(F){var z,V=function(X){var ne=document.createElement("canvas"),oe=Object.create(M.webGLContextAttributes);return oe.failIfMajorPerformanceCaveat=X,ne.getContext("webgl2",oe)}(F);if(!V)return!1;try{z=V.createShader(V.VERTEX_SHADER)}catch{return!1}return!(!z||V.isContextLost())&&(V.shaderSource(z,"void main() {}"),V.compileShader(z),V.getShaderParameter(z,V.COMPILE_STATUS)===!0)}(D)),x[D]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var D}y=1,_.supported=M,_.notSupportedReason=h;var x={};return M.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},_}();function w(M,h,x){const A=document.createElement(M);return h!=null&&(A.className=h),x&&x.appendChild(A),A}function j(M,h,x){const A=document.createElementNS("http://www.w3.org/2000/svg",M);for(const D of Object.keys(h))A.setAttributeNS(null,D,String(h[D]));return x&&x.appendChild(A),A}const k=typeof document<"u"?document.documentElement&&document.documentElement.style:null,S=k&&k.userSelect!==void 0?"userSelect":"WebkitUserSelect";let T;function I(){k&&S&&(T=k[S],k[S]="none")}function L(){k&&S&&(k[S]=T)}function R(M){M.preventDefault(),M.stopPropagation(),window.removeEventListener("click",R,!0)}function $(){window.addEventListener("click",R,!0),window.setTimeout(()=>{window.removeEventListener("click",R,!0)},0)}function q(M,h){const x=M.getBoundingClientRect();return Y(M,x,h)}function U(M,h){const x=M.getBoundingClientRect(),A=[];for(let D=0;Dthis._skuTokenExpiresAt}transformRequest(h,x){return this._transformRequestFn&&this._transformRequestFn(h,x)||{url:h}}normalizeStyleURL(h,x){if(!i.h(h))return h;const A=re(h);return A.params.push(`sdk=js-${d}`),A.path=`/styles/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||x)}normalizeGlyphsURL(h,x){if(!i.h(h))return h;const A=re(h);return A.path=`/fonts/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||x)}normalizeModelURL(h,x){if(!i.h(h))return h;const A=re(h);return A.path=`/models/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||x)}normalizeSourceURL(h,x,A,D){if(!i.h(h))return h;const F=re(h);return F.path=`/v4/${F.authority}.json`,F.params.push("secure"),A&&F.params.push(`language=${A}`),D&&F.params.push(`worldview=${D}`),this._makeAPIURL(F,this._customAccessToken||x)}normalizeIconsetURL(h,x){const A=re(h);return i.h(h)?(A.path=`/styles/v1${A.path}/iconset.pbf`,this._makeAPIURL(A,this._customAccessToken||x)):ae(A)}normalizeSpriteURL(h,x,A,D){const F=re(h);return i.h(h)?(F.path=`/styles/v1${F.path}/sprite${x}${A}`,this._makeAPIURL(F,this._customAccessToken||D)):(F.path+=`${x}${A}`,ae(F))}normalizeTileURL(h,x,A){if(this._isSkuTokenExpired()&&this._createSkuToken(),h&&!i.h(h))return h;const D=re(h);D.path=D.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${x||A&&D.authority!=="raster"&&A===512?"@2x":""}${i.k.supported?".webp":"$1"}`),D.authority==="raster"?D.path=`/${i.e.RASTER_URL_PREFIX}${D.path}`:D.authority==="rasterarrays"?D.path=`/${i.e.RASTERARRAYS_URL_PREFIX}${D.path}`:D.authority==="3dtiles"?D.path=`/${i.e.TILES3D_URL_PREFIX}${D.path}`:(D.path=D.path.replace(/^.+\/v4\//,"/"),D.path=`/${i.e.TILE_URL_VERSION}${D.path}`);const F=this._customAccessToken||function(z){for(const V of z){const X=V.match(/^access_token=(.*)$/);if(X)return X[1]}return null}(D.params)||i.e.ACCESS_TOKEN;return i.e.REQUIRE_ACCESS_TOKEN&&F&&this._skuToken&&D.params.push(`sku=${this._skuToken}`),this._makeAPIURL(D,F)}canonicalizeTileURL(h,x){const A=re(h);if(!A.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!A.path.match(/\.[\w]+$/))return h;let D="mapbox://";A.path.match(/^\/raster\/v1\//)?D+=`raster/${A.path.replace(`/${i.e.RASTER_URL_PREFIX}/`,"")}`:A.path.match(/^\/rasterarrays\/v1\//)?D+=`rasterarrays/${A.path.replace(`/${i.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:D+=`tiles/${A.path.replace(`/${i.e.TILE_URL_VERSION}/`,"")}`;let F=A.params;return x&&(F=F.filter(z=>!z.match(/^access_token=/))),F.length&&(D+=`?${F.join("&")}`),D}canonicalizeTileset(h,x){const A=!!x&&i.h(x),D=[];for(const F of h.tiles||[])i.j(F)?D.push(this.canonicalizeTileURL(F,A)):D.push(F);return D}_makeAPIURL(h,x){const A="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",D=re(i.e.API_URL);if(h.protocol=D.protocol,h.authority=D.authority,h.protocol==="http"){const F=h.params.indexOf("secure");F>=0&&h.params.splice(F,1)}if(D.path!=="/"&&(h.path=`${D.path}${h.path}`),!i.e.REQUIRE_ACCESS_TOKEN)return ae(h);if(x=x||i.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!x)throw new Error(`An API access token is required to use Mapbox GL. ${A}`);if(x[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${A}`)}return h.params=h.params.filter(F=>F.indexOf("access_token")===-1),h.params.push(`access_token=${x||""}`),ae(h)}}const de=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function re(M){const h=M.match(de);if(!h)throw new Error("Unable to parse URL object");return{protocol:h[1],authority:h[2],path:h[3]||"/",params:h[4]?h[4].split("&"):[]}}function ae(M){const h=M.params.length?`?${M.params.join("&")}`:"";return`${M.protocol}://${M.authority}${M.path}${h}`}const le="mapbox.eventData";function he(M){if(!M)return null;const h=M.split(".");if(!h||h.length!==3)return null;try{return JSON.parse(i.l(h[1]))}catch{return null}}class be{constructor(h){this.type=h,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(h){const x=he(i.e.ACCESS_TOKEN);let A="";return A=x&&x.u?i.f(x.u):i.e.ACCESS_TOKEN||"",h?`${le}.${h}:${A}`:`${le}:${A}`}fetchEventData(){const h=i.s("localStorage"),x=this.getStorageKey(),A=this.getStorageKey("uuid"),D=this.getStorageKey("uuidTimestamp");if(h)try{const F=localStorage.getItem(x);F&&(this.eventData=JSON.parse(F));const z=localStorage.getItem(A);z&&(this.anonId=z);const V=localStorage.getItem(D);V&&(this.anonIdTimestamp=Number(V));const X=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(x,JSON.stringify(this.eventData)),z&&localStorage.setItem(D,z.toString())}catch{i.w("Unable to write to LocalStorage")}}processRequests(h){}postEvent(h,x,A,D){if(!i.e.EVENTS_URL)return;const F=re(i.e.EVENTS_URL);F.params.push(`access_token=${D||i.e.ACCESS_TOKEN||""}`);const z={event:this.type,created:new Date(h).toISOString()},V=x?Object.assign(z,x):z,X={url:ae(F),headers:{"Content-Type":"text/plain"},body:JSON.stringify([V])};this.pendingRequest=i.p(X,ne=>{this.pendingRequest=null,A(ne),this.saveEventData(),this.processRequests(D)})}queueRequest(h,x){this.queue.push(h),this.processRequests(x)}}class _e extends be{constructor(h){super("metrics"),h&&(this.data=h)}postMetricsEvent(h){if(!i.e.EVENTS_URL||!h&&!i.e.ACCESS_TOKEN)return;this.anonId||this.fetchEventData(),i.v(this.anonId)||this.refreshUUID();const x=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:x},h)}processRequests(h){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:x,payload:A}=this.queue.shift();this.postEvent(x,A,()=>{},h)}}const je=new class extends be{constructor(M){super("appUserTurnstile"),this._customAccessToken=M}postTurnstileEvent(M,h){i.e.EVENTS_URL&&i.e.ACCESS_TOKEN&&Array.isArray(M)&&M.some(x=>i.h(x)||i.j(x))&&this.queueRequest(Date.now(),h)}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const h=he(i.e.ACCESS_TOKEN),x=h?h.u:i.e.ACCESS_TOKEN;let A=x!==this.eventData.tokenU;i.v(this.anonId)||(this.refreshUUID(),A=!0);const D=this.queue.shift();if(this.eventData.lastSuccess){const F=new Date(this.eventData.lastSuccess),z=new Date(D),V=(D-this.eventData.lastSuccess)/864e5;A=A||V>=1||V<-1||F.getDate()!==z.getDate()}else A=!0;A?this.postEvent(D,{sdkIdentifier:"mapbox-gl-js",sdkVersion:d,skuId:se,"enabled.telemetry":!1,userId:this.anonId},F=>{F||(this.eventData.lastSuccess=D,this.eventData.tokenU=x)},M):this.processRequests()}},Ne=je.postTurnstileEvent.bind(je),Ge=new class extends be{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(M,h,x,A){this.skuToken=h,this.errorCb=A,i.e.EVENTS_URL&&(x||i.e.ACCESS_TOKEN?this.queueRequest({id:M,timestamp:Date.now()},x):this.errorCb(new Error(te)))}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{id:h,timestamp:x}=this.queue.shift();h&&this.success[h]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),i.v(this.anonId)||this.refreshUUID(),this.postEvent(x,{sdkIdentifier:"mapbox-gl-js",sdkVersion:d,skuId:se,skuToken:this.skuToken,userId:this.anonId},A=>{A?this.errorCb(A):h&&(this.success[h]=!0)},M))}remove(){this.errorCb=null}},we=Ge.postMapLoadEvent.bind(Ge),Me=new class extends be{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(M){let h=this.mapInstanceIdMap.get(M);return h||(h=i.u(),this.mapInstanceIdMap.set(M,h)),h}getEventId(M){const h=this.eventIdPerMapInstanceMap.get(M)||0;return this.eventIdPerMapInstanceMap.set(M,h+1),h}postStyleLoadEvent(M,h){const{map:x,style:A,importedStyles:D}=h;if(!i.e.EVENTS_URL||!M&&!i.e.ACCESS_TOKEN)return;const F=this.getMapInstanceId(x),z={mapInstanceId:F,eventId:this.getEventId(F),style:A};D.length&&(z.importedStyles=D),this.queueRequest({timestamp:Date.now(),payload:z},M)}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:h,payload:x}=this.queue.shift();this.postEvent(h,x,()=>{},M)}},Te=Me.postStyleLoadEvent.bind(Me),Fe=new _e({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Ae=Fe.postMetricsEvent.bind(Fe),Ue=new _e({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),ut=Ue.postMetricsEvent.bind(Ue),De=new class extends be{constructor(){super("gljs.performance")}postPerformanceEvent(M,h){i.e.EVENTS_URL&&(M||i.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:h},M)}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:h,performanceData:x}=this.queue.shift(),A=function(D){const F=performance.getEntriesByType("resource"),z=performance.getEntriesByType("mark"),V=function(xe){const Pe={};if(xe){for(const Ce in xe)if(Ce!=="other")for(const Ve of xe[Ce]){const Be=`${Ce}ResolveRangeMin`,tt=`${Ce}ResolveRangeMax`,dt=`${Ce}RequestCount`,st=`${Ce}RequestCachedCount`;Pe[Be]=Math.min(Pe[Be]||1/0,Ve.startTime),Pe[tt]=Math.max(Pe[tt]||-1/0,Ve.responseEnd);const Mt=yt=>{Pe[yt]===void 0&&(Pe[yt]=0),++Pe[yt]};Ve.transferSize!==void 0&&Ve.transferSize===0&&Mt(st),Mt(dt)}}return Pe}(function(xe,Pe){const Ce={};if(xe)for(const Ve of xe){const Be=Pe(Ve);Ce[Be]===void 0&&(Ce[Be]=[]),Ce[Be].push(Ve)}return Ce}(F,f)),X=window.devicePixelRatio,ne=navigator.connection||navigator.mozConnection||navigator.webkitConnection,oe=ne?ne.effectiveType:void 0,ge={counters:[],metadata:[],attributes:[]},pe=(xe,Pe,Ce)=>{Ce!=null&&xe.push({name:Pe,value:Ce.toString()})};for(const xe in V)pe(ge.counters,xe,V[xe]);if(D.interactionRange[0]!==1/0&&D.interactionRange[1]!==-1/0&&(pe(ge.counters,"interactionRangeMin",D.interactionRange[0]),pe(ge.counters,"interactionRangeMax",D.interactionRange[1])),z)for(const xe of Object.values(u)){const Pe=z.find(Ce=>Ce.name===xe);Pe&&pe(ge.counters,xe,Pe.startTime)}return pe(ge.counters,"visibilityHidden",D.visibilityHidden),pe(ge.attributes,"style",function(xe){if(xe)for(const Pe of xe){const Ce=Pe.name.split("?")[0];if(i.i(Ce)){const Ve=Ce.split("/").slice(-2);if(Ve.length===2)return`mapbox://styles/${Ve[0]}/${Ve[1]}`}}}(F)),pe(ge.attributes,"terrainEnabled",D.terrainEnabled?"true":"false"),pe(ge.attributes,"fogEnabled",D.fogEnabled?"true":"false"),pe(ge.attributes,"projection",D.projection),pe(ge.attributes,"zoom",D.zoom),pe(ge.metadata,"devicePixelRatio",X),pe(ge.metadata,"connectionEffectiveType",oe),pe(ge.metadata,"navigatorUserAgent",navigator.userAgent),pe(ge.metadata,"screenWidth",window.screen.width),pe(ge.metadata,"screenHeight",window.screen.height),pe(ge.metadata,"windowWidth",window.innerWidth),pe(ge.metadata,"windowHeight",window.innerHeight),pe(ge.metadata,"mapWidth",D.width/X),pe(ge.metadata,"mapHeight",D.height/X),pe(ge.metadata,"webglRenderer",D.renderer),pe(ge.metadata,"webglVendor",D.vendor),pe(ge.metadata,"sdkVersion",d),pe(ge.metadata,"sdkIdentifier","mapbox-gl-js"),ge}(x);for(const D of A.metadata);for(const D of A.counters);for(const D of A.attributes);this.postEvent(h,A,()=>{},M)}},Rt=De.postPerformanceEvent.bind(De),me=new class extends be{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(M,h,x,A){if(!i.e.API_URL||!i.e.SESSION_PATH)return;const D=re(i.e.API_URL+i.e.SESSION_PATH);D.params.push(`sku=${h||""}`),D.params.push(`access_token=${A||i.e.ACCESS_TOKEN||""}`);const F={url:ae(D),headers:{"Content-Type":"text/plain"}};this.pendingRequest=i.g(F,z=>{this.pendingRequest=null,x(z),this.saveEventData(),this.processRequests(A)})}getSessionAPI(M,h,x,A){this.skuToken=h,this.errorCb=A,i.e.SESSION_PATH&&i.e.API_URL&&(x||i.e.ACCESS_TOKEN?this.queueRequest({id:M,timestamp:Date.now()},x):this.errorCb(new Error(te)))}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{id:h,timestamp:x}=this.queue.shift();h&&this.success[h]||this.getSession(x,this.skuToken,A=>{A?this.errorCb(A):h&&(this.success[h]=!0)},M)}remove(){this.errorCb=null}},Xe=me.getSessionAPI.bind(me),ot=new Set;function nt(M,h){h?ot.add(M):ot.delete(M)}class Se{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={}}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(h,x){this._updatedSourceCaches[h]=x,this.setDirty()}discardSourceCacheUpdate(h){delete this._updatedSourceCaches[h]}updateLayer(h){const x=h.scope;this._updatedLayers[x]=this._updatedLayers[x]||new Set,this._updatedLayers[x].add(h.id),this.setDirty()}removeLayer(h){const x=h.scope;this._removedLayers[x]=this._removedLayers[x]||{},this._updatedLayers[x]=this._updatedLayers[x]||new Set,this._removedLayers[x][h.id]=h,this._updatedLayers[x].delete(h.id),this._updatedPaintProps.delete(h.fqid),this.setDirty()}getRemovedLayer(h){return this._removedLayers[h.scope]?this._removedLayers[h.scope][h.id]:null}discardLayerRemoval(h){this._removedLayers[h.scope]&&delete this._removedLayers[h.scope][h.id]}getLayerUpdatesByScope(){const h={};for(const x in this._updatedLayers)h[x]=h[x]||{},h[x].updatedIds=Array.from(this._updatedLayers[x].values());for(const x in this._removedLayers)h[x]=h[x]||{},h[x].removedIds=Object.keys(this._removedLayers[x]);return h}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(h){this._updatedPaintProps.add(h.fqid),this.setDirty()}getUpdatedImages(h){return this._updatedImages[h]?Array.from(this._updatedImages[h].values()):[]}updateImage(h,x){this._updatedImages[x]=this._updatedImages[x]||new Set,this._updatedImages[x].add(i.I.toString(h)),this.setDirty()}resetUpdatedImages(h){this._updatedImages[h]&&this._updatedImages[h].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function it(M){const{userImage:h}=M;return!!(h&&h.render&&h.render())&&(M.data.replace(new Uint8Array(h.data.buffer)),!0)}class $e extends i.E{constructor(h){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.dirty=!0,this.spriteFormat=h,h!=="raster"&&i.r()&&(this.imageRasterizerDispatcher=new i.D(i.t(),this,"Image Rasterizer Worker",1))}addScope(h){this.loaded.set(h,!1),this.imageProviders.set(h,new Map),this.images.set(h,new Map),this.updatedImages.set(h,new Set),this.callbackDispatchedThisFrame.set(h,new Set),this.patterns.set(h,new Map),this.atlasImage.set(h,new i.q({width:1,height:1}))}removeScope(h){this.loaded.delete(h),this.imageProviders.delete(h),this.images.delete(h),this.updatedImages.delete(h),this.callbackDispatchedThisFrame.delete(h),this.patterns.delete(h),this.atlasImage.delete(h);const x=this.atlasTexture.get(h);x&&(x.destroy(),this.atlasTexture.delete(h))}addImageProvider(h,x){this.imageProviders.has(x)||this.imageProviders.set(x,new Map),this.imageProviders.get(x).set(h.id,h)}removeImageProvider(h,x){this.imageProviders.has(x)&&this.imageProviders.get(x).delete(h)}getPendingImageProviders(){const h=[];for(const x of this.imageProviders.values())for(const A of x.values())A.hasPendingRequests()&&h.push(A);return h}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new i.x),this._imageRasterizer}isLoaded(){for(const h of this.loaded.keys())if(!this.loaded.get(h))return!1;return!0}setLoaded(h,x){if(this.loaded.get(x)!==h&&(this.loaded.set(x,h),h)){for(const{ids:A,callback:D}of this.requestors)this._notify(A,x,D);this.requestors=[]}}hasImage(h,x){return!!this.getImage(h,x)}getImage(h,x){return this.images.get(x).get(h.toString())}addImage(h,x,A){this._validate(h,A)&&this.images.get(x).set(h.toString(),A)}_validate(h,x){let A=!0;return this._validateStretch(x.stretchX,x.data&&x.data.width)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "stretchX" value`))),A=!1),this._validateStretch(x.stretchY,x.data&&x.data.height)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "stretchY" value`))),A=!1),this._validateContent(x.content,x)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "content" value`))),A=!1),A}_validateStretch(h,x){if(!h)return!0;let A=0;for(const D of h){if(D[0]i.I.from(x))}getImages(h,x,A){const D=[],F=[],z=this.imageProviders.get(x);for(const oe of h){if(!oe.iconsetId){D.push(oe);continue}const ge=z.get(oe.iconsetId);ge&&(this.getImage(oe,x)?F.push(oe):ge.addPendingRequest(oe))}if(D.length===0)return void this._notify(F,x,A);let V=!0;const X=!!this.loaded.get(x),ne=this.images.get(x);if(!X)for(const oe of D)ne.has(oe.toString())||(V=!1);X||V?this._notify(D,x,A):this.requestors.push({ids:D,scope:x,callback:A})}rasterizeImages(h,x){const A=new Map,{tasks:D,scope:F}=h;for(const[z,V]of D.entries()){const X=this.getImage(V.id,F);X&&A.set(z,{image:X,imageVariant:V})}this._rasterizeImages(F,A,x)}_rasterizeImages(h,x,A){if(i.r())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:x,scope:h},A);else{const D=new Map;for(const[F,{image:z,imageVariant:V}]of x.entries())D.set(F,this.imageRasterizer.rasterize(V,z,h,0));A(void 0,D)}}getUpdatedImages(h){return this.updatedImages.get(h)||new Set}_notify(h,x,A){const D=this.images.get(x),F=new Map;for(const z of h){if(!D.get(z.toString())){if(z.iconsetId)continue;this.fire(new i.z("styleimagemissing",{id:z.name}))}const V=D.get(z.toString());if(!V){i.w(`Image "${z.name}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);continue}const X={data:V.usvg?null:V.data.clone(),pixelRatio:V.pixelRatio,sdf:V.sdf,usvg:V.usvg,version:V.version,stretchX:V.stretchX,stretchY:V.stretchY,content:V.content,hasRenderCallback:!!(V.userImage&&V.userImage.render)};V.usvg&&Object.assign(X,{width:V.icon.usvg_tree.width,height:V.icon.usvg_tree.height}),F.set(i.I.toString(z),X)}A(null,F)}getPixelSize(h){const{width:x,height:A}=this.atlasImage.get(h);return{width:x,height:A}}getPattern(h,x,A){const D=h.toString(),F=this.patterns.get(x),z=F.get(D),V=this.getImage(h,x);if(!V)return null;if(z){if(z.position.version===V.version)return z.position;z.position.version=V.version}else{if(V.usvg&&!V.data){const X=this.getPatternInFlightId(D,x);if(this.patternsInFlight.has(X))return null;this.patternsInFlight.add(X);const ne=new i.A(h).scaleSelf(i.o.devicePixelRatio),oe=new Map([[ne.toString(),{image:V,imageVariant:ne}]]);return this._rasterizeImages(x,oe,(ge,pe)=>this.storePatternImage(ne,x,V,A,pe)),null}this.storePattern(h,x,V)}return this._updatePatternAtlas(x,A),F.get(D).position}getPatternInFlightId(h,x){return i.B(h,x)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(h,x,A,D,F){const z=h.toString(),V=F?F.get(z):void 0;V&&(A.data=V,this.storePattern(h.id,x,A),this._updatePatternAtlas(x,D),this.patternsInFlight.delete(this.getPatternInFlightId(h.id.toString(),x)))}storePattern(h,x,A){const D={w:A.data.width+2*i.C,h:A.data.height+2*i.C,x:0,y:0},F=new i.F(D,A,i.C);this.patterns.get(x).set(h.toString(),{bin:D,position:F})}destroyAtlasTextures(){for(const h of this.atlasTexture.values())h&&h.destroy();this.atlasTexture.clear()}bind(h,x){const A=h.gl;let D=this.atlasTexture.get(x);D?this.dirty&&(D.update(this.atlasImage.get(x)),this.dirty=!1):(D=new i.T(h,this.atlasImage.get(x),A.RGBA8),this.atlasTexture.set(x,D)),D.bind(A.LINEAR,A.CLAMP_TO_EDGE)}_updatePatternAtlas(h,x){const A=this.patterns.get(h),D=Array.from(A.values()).map(({bin:ne})=>ne),{w:F,h:z}=i.G(D),V=this.atlasImage.get(h);V.resize({width:F||1,height:z||1});const X=this.images.get(h);for(const[ne,{bin:oe,position:ge}]of A.entries()){let pe=ge.padding;const xe=oe.x+pe,Pe=oe.y+pe,Ce=X.get(ne).data,Ve=Ce.width,Be=Ce.height;pe=pe>1?pe-1:pe,i.q.copy(Ce,V,{x:0,y:0},{x:xe,y:Pe},{width:Ve,height:Be},x),i.q.copy(Ce,V,{x:0,y:Be-pe},{x:xe,y:Pe-pe},{width:Ve,height:pe},x),i.q.copy(Ce,V,{x:0,y:0},{x:xe,y:Pe+Be},{width:Ve,height:pe},x),i.q.copy(Ce,V,{x:Ve-pe,y:0},{x:xe-pe,y:Pe},{width:pe,height:Be},x),i.q.copy(Ce,V,{x:0,y:0},{x:xe+Ve,y:Pe},{width:pe,height:Be},x),i.q.copy(Ce,V,{x:Ve-pe,y:Be-pe},{x:xe-pe,y:Pe-pe},{width:pe,height:pe},x),i.q.copy(Ce,V,{x:0,y:Be-pe},{x:xe+Ve,y:Pe-pe},{width:pe,height:pe},x),i.q.copy(Ce,V,{x:0,y:0},{x:xe+Ve,y:Pe+Be},{width:pe,height:pe},x),i.q.copy(Ce,V,{x:Ve-pe,y:0},{x:xe-pe,y:Pe+Be},{width:pe,height:pe},x)}this.dirty=!0}beginFrame(){for(const h of this.images.keys())this.callbackDispatchedThisFrame.set(h,new Set)}dispatchRenderCallbacks(h,x){const A=this.images.get(x);for(const D of h){if(this.callbackDispatchedThisFrame.get(x).has(D.toString()))continue;this.callbackDispatchedThisFrame.get(x).add(D.toString());const F=A.get(D.toString());it(F)&&this.updateImage(D,x,F)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function ct(M){const h=M.value,x=M.valueSpec,A=M.style,D=M.styleSpec,F=M.key,z=M.arrayElementValidator||nn;if(!Array.isArray(h))return[new i.V(F,h,`array expected, ${i.K(h)} found`)];if(x.length&&h.length!==x.length)return[new i.V(F,h,`array length ${x.length} expected, length ${h.length} found`)];if(x["min-length"]&&h.lengthD)return[new i.V(h,x,`${x} is greater than the maximum value ${D}`)]}return[]}function Ze(M){const h=M.key,x=M.value;if(!i.H(x))return[new i.V(h,x,`object expected, ${i.K(x)} found`)];const A=M.valueSpec,D=i.J(x.type);let F,z,V,X={};const ne=D!=="categorical"&&x.property===void 0,oe=!ne,ge=function(Ce){const Ve=Ce.stops;return Array.isArray(Ve)&&Array.isArray(Ve[0])&&i.H(Ve[0][0])}(x),pe=ia({key:M.key,value:M.value,valueSpec:M.styleSpec.function,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{stops:function(Ce){if(D==="identity")return[new i.V(Ce.key,Ce.value,'identity function may not have a "stops" property')];let Ve=[];const Be=Ce.value;return Ve=Ve.concat(ct({key:Ce.key,value:Be,valueSpec:Ce.valueSpec,style:Ce.style,styleSpec:Ce.styleSpec,arrayElementValidator:xe})),Array.isArray(Be)&&Be.length===0&&Ve.push(new i.V(Ce.key,Be,"array must have at least one stop")),Ve},default:function(Ce){return nn({key:Ce.key,value:Ce.value,valueSpec:A,style:Ce.style,styleSpec:Ce.styleSpec})}}});return D==="identity"&&ne&&pe.push(new i.V(M.key,M.value,'missing required property "property"')),D==="identity"||x.stops||pe.push(new i.V(M.key,M.value,'missing required property "stops"')),D==="exponential"&&A.expression&&!i.M(A)&&pe.push(new i.V(M.key,M.value,"exponential functions not supported")),M.styleSpec.$version>=8&&(oe&&!i.N(A)?pe.push(new i.V(M.key,M.value,"property functions not supported")):ne&&!i.O(A)&&pe.push(new i.V(M.key,M.value,"zoom functions not supported"))),D!=="categorical"&&!ge||x.property!==void 0||pe.push(new i.V(M.key,M.value,'"property" property is required')),pe;function xe(Ce){let Ve=[];const Be=Ce.value,tt=Ce.key;if(!Array.isArray(Be))return[new i.V(tt,Be,`array expected, ${i.K(Be)} found`)];if(Be.length!==2)return[new i.V(tt,Be,`array length 2 expected, length ${Be.length} found`)];if(ge){if(!i.H(Be[0]))return[new i.V(tt,Be,`object expected, ${i.K(Be[0])} found`)];const dt=Be[0];if(dt.zoom===void 0)return[new i.V(tt,Be,"object stop key must have zoom")];if(dt.value===void 0)return[new i.V(tt,Be,"object stop key must have value")];const st=i.J(dt.zoom);if(typeof st!="number")return[new i.V(tt,dt.zoom,"stop zoom values must be numbers")];if(V&&V>st)return[new i.V(tt,dt.zoom,"stop zoom values must appear in ascending order")];st!==V&&(V=st,z=void 0,X={}),Ve=Ve.concat(ia({key:`${tt}[0]`,value:Be[0],valueSpec:{zoom:{}},style:Ce.style,styleSpec:Ce.styleSpec,objectElementValidators:{zoom:qe,value:Pe}}))}else Ve=Ve.concat(Pe({key:`${tt}[0]`,value:Be[0],style:Ce.style,styleSpec:Ce.styleSpec},Be));return i.Q(i.S(Be[1]))?Ve.concat([new i.V(`${tt}[1]`,Be[1],"expressions are not allowed in function stops.")]):Ve.concat(nn({key:`${tt}[1]`,value:Be[1],valueSpec:A,style:Ce.style,styleSpec:Ce.styleSpec}))}function Pe(Ce,Ve){const Be=i.K(Ce.value),tt=i.J(Ce.value),dt=Ce.value!==null?Ce.value:Ve;if(F){if(Be!==F)return[new i.V(Ce.key,dt,`${Be} stop domain type must match previous stop domain type ${F}`)]}else F=Be;if(Be!=="number"&&Be!=="string"&&Be!=="boolean"&&typeof tt!="number"&&typeof tt!="string"&&typeof tt!="boolean")return[new i.V(Ce.key,dt,"stop domain value must be a number, string, or boolean")];if(Be!=="number"&&D!=="categorical"){let st=`number expected, ${Be} found`;return i.N(A)&&D===void 0&&(st+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new i.V(Ce.key,dt,st)]}return D!=="categorical"||Be!=="number"||typeof tt=="number"&&isFinite(tt)&&Math.floor(tt)===tt?D!=="categorical"&&Be==="number"&&typeof tt=="number"&&typeof z=="number"&&z!==void 0&&ttnew i.V(`${M.key}${A.key}`,M.value,A.message));const x=h.value.expression||h.value._styleExpression.expression;if(M.expressionContext==="property"&&M.propertyKey==="text-font"&&!x.outputDefined())return[new i.V(M.key,M.value,`Invalid data expression for "${M.propertyKey}". Output values must be contained as literals within the expression.`)];if(M.expressionContext==="property"&&M.propertyType==="layout"&&!i.Z(x))return[new i.V(M.key,M.value,'"feature-state" data expressions are not supported with layout properties.')];if(M.expressionContext==="filter")return We(x,M);if(M.expressionContext==="appearance")return He(x,M);if(M.expressionContext&&M.expressionContext.indexOf("cluster")===0){if(!i.X(x,["zoom","feature-state"]))return[new i.V(M.key,M.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(M.expressionContext==="cluster-initial"&&!i.Y(x))return[new i.V(M.key,M.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function We(M,h){const x=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(h.valueSpec&&h.valueSpec.expression)for(const D of h.valueSpec.expression.parameters)x.delete(D);if(x.size===0)return[];const A=[];return M instanceof i._&&x.has(M.name)?[new i.V(h.key,h.value,`["${M.name}"] expression is not supported in a filter for a ${h.object.type} layer with id: ${h.object.id}`)]:(M.eachChild(D=>{A.push(...We(D,h))}),A)}function He(M,h){const x=new Set;if(h.valueSpec&&h.valueSpec.expression)for(const D of h.valueSpec.expression.parameters)x.add(D);if(x.size===0)return[];const A=[];return M instanceof i._&&!x.has(M.name)?[new i.V(h.key,h.value,`["${M.name}"] is not an allowed parameter`)]:(M.eachChild(D=>{A.push(...He(D,h))}),A)}function et(M){const h=M.key,x=M.value,A=M.valueSpec,D=[];return Array.isArray(A.values)?A.values.indexOf(i.J(x))===-1&&D.push(new i.V(h,x,`expected one of [${A.values.join(", ")}], ${JSON.stringify(x)} found`)):Object.keys(A.values).indexOf(i.J(x))===-1&&D.push(new i.V(h,x,`expected one of [${Object.keys(A.values).join(", ")}], ${JSON.stringify(x)} found`)),D}function Tt(M){return i.a2(i.S(M.value))?Qe(Object.assign({},M,{expressionContext:"filter",valueSpec:M.styleSpec[`filter_${M.layerType||"fill"}`]})):Ft(M)}function Ft(M){const h=M.value,x=M.key;if(!Array.isArray(h))return[new i.V(x,h,`array expected, ${i.K(h)} found`)];if(h.length<1)return[new i.V(x,h,"filter array must have at least 1 element")];const A=M.styleSpec;let D=et({key:`${x}[0]`,value:h[0],valueSpec:A.filter_operator});const F=()=>{h.length>=2&&(i.a0(h[1])||D.push(new i.V(`${x}[1]`,h[1],`string expected, ${i.K(h[1])} found`)));for(let z=2;z":case">=":h.length>=2&&i.J(h[1])==="$type"&&D.push(new i.V(x,h,`"$type" cannot be use with operator "${h[0]}"`)),h.length!==3&&D.push(new i.V(x,h,`filter array for operator "${h[0]}" must have 3 elements`)),F();break;case"==":case"!=":h.length!==3&&D.push(new i.V(x,h,`filter array for operator "${h[0]}" must have 3 elements`)),F();break;case"in":case"!in":F();break;case"any":case"all":case"none":for(let z=1;z{ne in x&&h.push(new i.V(A,x[ne],`"${ne}" is prohibited for ref layers`))}),D.layers.forEach(ne=>{i.J(ne.id)===V&&(X=ne)}),X?X.ref?h.push(new i.V(A,x.ref,"ref cannot reference another ref layer")):z=i.J(X.type):typeof V=="string"&&h.push(new i.V(A,x.ref,`ref layer "${V}" not found`))}else if(z!=="background"&&z!=="sky"&&z!=="slot")if(x.source)if(i.a0(x.source)){const X=D.sources&&D.sources[x.source],ne=X&&i.J(X.type);X?ne==="vector"&&z==="raster"?h.push(new i.V(A,x.source,`layer "${x.id}" requires a raster source`)):ne==="raster"&&z!=="raster"?h.push(new i.V(A,x.source,`layer "${x.id}" requires a vector source`)):ne!=="vector"||x["source-layer"]?ne==="raster-dem"&&z!=="hillshade"?h.push(new i.V(A,x.source,"raster-dem source can only be used with layer type 'hillshade'.")):ne!=="raster-array"||["raster","raster-particle"].includes(z)?z==="line"&&x.paint&&(x.paint["line-gradient"]||x.paint["line-trim-offset"])&&ne==="geojson"&&!X.lineMetrics?h.push(new i.V(A,x,`layer "${x.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):z==="raster-particle"&&ne!=="raster-array"&&h.push(new i.V(A,x.source,`layer "${x.id}" requires a 'raster-array' source.`)):h.push(new i.V(A,x.source,"raster-array source can only be used with layer type 'raster'.")):h.push(new i.V(A,x,`layer "${x.id}" must specify a "source-layer"`)):h.push(new i.V(A,x.source,`source "${x.source}" not found`))}else h.push(new i.V(`${A}.source`,x.source,'"source" must be a string'));else h.push(new i.V(A,x,'missing required property "source"'));return h=h.concat(ia({key:A,value:x,valueSpec:F.layer,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{"*":()=>[],type:()=>nn({key:`${A}.type`,value:x.type,valueSpec:F.layer.type,style:M.style,styleSpec:M.styleSpec,object:x,objectKey:"type"}),filter:X=>Tt(Object.assign({layerType:z},X)),layout:X=>ia({layer:x,key:X.key,value:X.value,valueSpec:{},style:X.style,styleSpec:X.styleSpec,objectElementValidators:{"*":ne=>ss(Object.assign({layerType:z},ne))}}),paint:X=>ia({layer:x,key:X.key,value:X.value,valueSpec:{},style:X.style,styleSpec:X.styleSpec,objectElementValidators:{"*":ne=>Xt(Object.assign({layerType:z,layer:x},ne))}}),appearances(X){const ne=ct({key:X.key,value:X.value,valueSpec:X.valueSpec,style:X.style,styleSpec:X.styleSpec,arrayElementValidator:pe=>function(xe){const{key:Pe,layer:Ce,layerType:Ve}=xe,Be=i.J(xe.value),tt=i.J(Be.name),dt=i.J(Be.condition),st=ia({key:Pe,value:Be,valueSpec:xe.styleSpec.appearance,style:xe.style,styleSpec:xe.styleSpec,objectElementValidators:{condition:Mt=>function(yt){const jt=[];return jt.push(...Qe({key:yt.key,value:yt.object.condition,valueSpec:i.a6.appearance.condition,expressionContext:"appearance"})),jt}(Object.assign({layer:Ce,layerType:Ve},Mt)),properties:Mt=>function(yt){const jt=[],{styleSpec:gt,layer:mt,layerType:Et}=yt,Ht=gt[`paint_${Et}`],Ut=gt[`layout_${Et}`],ts=yt.object[yt.objectKey];for(const ns in ts){const fs=ns in Ht?"paint":ns in Ut?"layout":void 0;if(!fs){jt.push(new i.V(yt.key,ns,`unknown property "${ns}" for layer type "${Et}"`));continue}const Bs=Object.assign({},yt,{key:`${yt.key}.${ns}`,object:ts,objectKey:ns,layer:mt,layerType:Et,value:ts[ns],valueSpec:fs==="paint"?Ht[ns]:Ut[ns]});jt.push(...as(Bs,fs))}return jt}(Object.assign({layer:Ce,layerType:Ve},Mt))}});return tt!=="hidden"&&dt===void 0&&st.push(new i.V(xe.key,"name",'Appearance with name different than "hidden" must have a condition')),st}(Object.assign({layerType:z,layer:x},pe))}),oe=Array.isArray(X.value)?X.value:[],ge=new Set;return oe.forEach((pe,xe)=>{const Pe=i.J(pe.name);if(Pe)if(ge.has(Pe)){const Ce=i.J(x.id);ne.push(new i.V(X.key,Pe,`Duplicated appearance name "${Pe}" for layer "${Ce}"`))}else ge.add(Pe)}),ne}}})),h}function ar({key:M,value:h}){return i.a0(h)?[]:[new i.V(M,h,`string expected, ${i.K(h)} found`)]}const Ct={promoteId:function M({key:h,value:x}){if(i.a0(x))return ar({key:h,value:x});if(Array.isArray(x)){const D=[],F=i.S(x),z=i.U(F);return z.result==="error"&&z.value.forEach(V=>{D.push(new i.V(`${h}${V.key}`,null,`${V.message}`))}),i.X(z.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||D.push(new i.V(`${h}`,null,"promoteId expression should be only feature dependent")),D}if(!i.H(x))return[new i.V(h,x,`string, expression or object expected, "${i.K(x)}" found`)];const A=[];for(const D in x)A.push(...M({key:`${h}.${D}`,value:x[D]}));return A}};function Is(M){const h=M.value,x=M.key,A=M.styleSpec,D=M.style;if(!i.H(h))return[new i.V(x,h,`object expected, ${i.K(h)} found`)];if(!("type"in h))return[new i.V(x,h,'"type" is required')];const F=i.J(h.type);let z=[];switch(["vector","raster","raster-dem","raster-array"].includes(F)&&("url"in h||"tiles"in h||z.push(new i.a3(x,h,'Either "url" or "tiles" is required.'))),F){case"vector":case"raster":case"raster-dem":case"raster-array":return z=z.concat(ia({key:x,value:h,valueSpec:A[`source_${F.replace("-","_")}`],style:M.style,styleSpec:A,objectElementValidators:Ct})),z;case"geojson":if(z=ia({key:x,value:h,valueSpec:A.source_geojson,style:D,styleSpec:A,objectElementValidators:Ct}),"cluster"in h&&"clusterProperties"in h){if(!i.H(h.clusterProperties))return[new i.V(`${x}.clusterProperties`,h,`object expected, ${i.K(h)} found`)];for(const V in h.clusterProperties){const X=h.clusterProperties[V];if(!Array.isArray(X))return[new i.V(`${x}.clusterProperties.${V}`,X,"array expected")];const[ne,oe]=X,ge=typeof ne=="string"?[ne,["accumulated"],["get",V]]:ne;z.push(...Qe({key:`${x}.${V}.map`,value:oe,expressionContext:"cluster-map"})),z.push(...Qe({key:`${x}.${V}.reduce`,value:ge,expressionContext:"cluster-reduce"}))}}return z;case"video":return ia({key:x,value:h,valueSpec:A.source_video,style:D,styleSpec:A});case"image":return ia({key:x,value:h,valueSpec:A.source_image,style:D,styleSpec:A});case"canvas":return[new i.V(x,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return et({key:`${x}.type`,value:h.type,valueSpec:{values:qs(A)}})}}function qs(M){return M.source.reduce((h,x)=>{const A=M[x];return A.type.type==="enum"&&(h=h.concat(Object.keys(A.type.values||{}))),h},[])}function gr(M){const h=M.value,x=M.styleSpec,A=x.light,D=M.style;if(h===void 0)return[];if(!i.H(h))return[new i.V("light",h,`object expected, ${i.K(h)} found`)];let F=[];for(const z in h){const V=z.match(/^(.*)-transition$/),X=z.match(/^(.*)-use-theme$/);F=F.concat(X&&A[X[1]]?nn({key:z,value:h[z],valueSpec:{type:"string"},style:D,styleSpec:x}):V&&A[V[1]]&&A[V[1]].transition?nn({key:z,value:h[z],valueSpec:x.transition,style:D,styleSpec:x}):A[z]?nn({key:z,value:h[z],valueSpec:A[z],style:D,styleSpec:x}):[new i.V(z,h[z],`unknown property "${z}"`)])}return F}function Wn(M){const h=M.value;if(!h)return[];const x=M.key;if(!i.H(h))return[new i.V(x,h,`object expected, ${i.K(h)} found`)];let A=[];const D=M.styleSpec,F=D["light-3d"],z=M.style,V=M.style.lights;for(const oe of["type","id"])if(!(oe in h))return A=A.concat([new i.V(x,h,`missing property "${oe}"`)]),A;if(!i.a0(h.type))return A=A.concat([new i.V(`${x}.type`,h.type,"string expected")]),A;if(V)for(let oe=0;oe[],array:ct,boolean:function(M){const h=M.value,x=M.key;return i.$(h)?[]:[new i.V(x,h,`boolean expected, ${i.K(h)} found`)]},number:qe,color:function({key:M,value:h}){return i.a0(h)?i.a1.parseCSSColor(h)===null?[new i.V(M,h,`color expected, "${h}" found`)]:[]:[new i.V(M,h,`color expected, ${i.K(h)} found`)]},enum:et,filter:Tt,function:Ze,layer:is,object:ia,source:Is,model:i.a7,light:gr,"light-3d":Wn,terrain:ii,fog:bo,string:ar,formatted:function(M){return ar(M).length===0?[]:Qe(M)},resolvedImage:function(M){return ar(M).length===0?[]:Qe(M)},projection:function(M){const h=M.value,x=M.styleSpec,A=x.projection,D=M.style;if(i.H(h)){let F=[];for(const z in h)F=F.concat(nn({key:z,value:h[z],valueSpec:A[z],style:D,styleSpec:x}));return F}return i.a0(h)?[]:[new i.V("projection",h,`object or string expected, ${i.K(h)} found`)]},import:function(M){const h=M.key,{value:x,styleSpec:A}=M;if(!i.H(x))return[new i.V(h,x,"import must be an object")];const{data:D,...F}=x;Object.defineProperty(F,"__line__",{value:x.__line__,enumerable:!1});let z=ia(Object.assign({},M,{value:F,valueSpec:A.import}));return i.J(F.id)===""&&z.push(new i.V(`${M.key}.id`,F,"import id can't be an empty string")),D&&(z=z.concat(sa(D,A,{key:`${M.key}.data`}))),z},iconset:function(M){const h=M.value,x=M.key,A=M.styleSpec,D=M.style;if(!i.H(h))return[new i.V(x,h,"object expected")];if(!h.type)return[new i.V(x,h,'"type" is required')];const F=i.J(h.type);let z=[];if(z=z.concat(ia({key:x,value:h,valueSpec:A[`iconset_${F}`],style:D,styleSpec:A})),function(V,X){return!(V!=="source"||!X.source)}(F,h)){const V=D.sources&&D.sources[h.source],X=V&&i.J(V.type);V?X!=="raster-array"&&z.push(new i.V(x,h.source,`iconset cannot be used with a source of type ${String(X)}, it only be used with a "raster-array" source type`)):z.push(new i.V(x,h.source,`source "${h.source}" not found`))}return z}};function nn(M,h=!1){const x=M.value,A=M.valueSpec,D=M.styleSpec;if(A.expression){if(i.a4(i.J(x)))return Ze(M);if(i.Q(i.S(x)))return Qe(M)}if(A.type&&si[A.type]){const F=si[A.type](M);return h===!0&&F.length>0&&Array.isArray(M.value)?Qe(M):F}return ia(Object.assign({},M,{valueSpec:A.type?D[A.type]:A}))}function ia(M){const h=M.key,x=M.value,A=M.valueSpec||{},D=M.objectElementValidators||{},F=M.style,z=M.styleSpec;if(!i.H(x))return[new i.V(h,x,`object expected, ${i.K(x)} found`)];let V=[];for(const X in x){const ne=X.split(".")[0];let oe;D[ne]?oe=D[ne]:A[ne]?oe=nn:D["*"]?oe=D["*"]:A["*"]&&(oe=nn),oe?V=V.concat(oe({key:(h&&`${h}.`)+X,value:x[X],valueSpec:A[ne]||A["*"],style:F,styleSpec:z,object:x,objectKey:X},x)):V.push(new i.a3(h,x[X],`unknown property "${X}"`))}for(const X in A){if(D[X])continue;const ne=A[X];ne.required&&ne.default===void 0&&x[X]===void 0&&V.push(new i.V(h,x,`missing required property "${X}"`))}return V}function kn({key:M,value:h}){const x=ar({key:M,value:h});if(x.length)return x;const A=h;return A.indexOf("{fontstack}")===-1&&x.push(new i.V(M,h,'"glyphs" url must include a "{fontstack}" token')),A.indexOf("{range}")===-1&&x.push(new i.V(M,h,'"glyphs" url must include a "{range}" token')),x}function sa(M,h=i.a6,x={}){return ia({key:x.key||"",value:M,valueSpec:Object.assign(h.$root,{"*":{type:"*"}}),styleSpec:h,style:M,objectElementValidators:{glyphs:kn}})}function Zt(M,h=i.a6){return ze(sa(M,h))}const $r=M=>ze(Is(M)),es=M=>ze(gr(M)),an=M=>ze(Wn(M)),Ra=M=>ze(ii(M)),Zn=M=>ze(bo(M)),Ir=M=>ze(function(h){const x=h.value,A=h.style,D=h.styleSpec,F=D.snow;if(x===void 0)return[];if(!i.H(x))return[new i.V("snow",x,`object expected, ${i.K(x)} found`)];let z=[];for(const V in x){const X=V.match(/^(.*)-transition$/);z=z.concat(X&&F[X[1]]&&F[X[1]].transition?nn({key:V,value:x[V],valueSpec:D.transition,style:A,styleSpec:D}):F[V]?nn({key:V,value:x[V],valueSpec:F[V],style:A,styleSpec:D}):[new i.a3(V,x[V],`unknown property "${V}"`)])}return z}(M)),mi=M=>ze(function(h){const x=h.value,A=h.style,D=h.styleSpec,F=D.rain;if(x===void 0)return[];if(!i.H(x))return[new i.V("rain",x,`object expected, ${i.K(x)} found`)];let z=[];for(const V in x){const X=V.match(/^(.*)-transition$/);z=z.concat(X&&F[X[1]]&&F[X[1]].transition?nn({key:V,value:x[V],valueSpec:D.transition,style:A,styleSpec:D}):F[V]?nn({key:V,value:x[V],valueSpec:F[V],style:A,styleSpec:D}):[new i.a3(V,x[V],`unknown property "${V}"`)])}return z}(M)),Go=M=>ze(is(M)),yi=M=>ze(Tt(M)),Vl=M=>ze(Xt(M)),Vt=M=>ze(ss(M)),ye=M=>ze(i.a7(M));function ze(M){return M.slice().sort((h,x)=>h.line&&x.line?h.line-x.line:0)}function Je(M,h){let x=!1;if(h&&h.length)for(const A of h)A instanceof i.a3?i.w(A.message):(M.fire(new i.y(new Error(A.message))),x=!0);return x}const St=i.a6.light;let Nt;class Bt extends i.E{constructor(h,x="flat"){super(),this._transitionable=new i.a8(Nt||(Nt=new i.a9({anchor:new i.aa(St.anchor),position:new i.ab(St.position),color:new i.aa(St.color),intensity:new i.aa(St.intensity)}))),this.setLight(h,x),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(h,x,A={}){this._validate(es,h,A)||(this._transitionable.setTransitionOrValue(h),this.id=x)}updateTransitions(h){this._transitioning=this._transitionable.transitioned(h,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(h){this.properties=this._transitioning.possiblyEvaluate(h)}_validate(h,x,A){return(!A||A.validate!==!1)&&Je(this,h.call(Zt,Object.assign({value:x,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}const Kt=i.a6.terrain;let qt=class extends i.E{constructor(M,h,x,A,D){super(),this.scope=x,this._transitionable=new i.a8(new i.a9({source:new i.aa(Kt.source),exaggeration:new i.aa(Kt.exaggeration)}),x,A),this._transitionable.setTransitionOrValue(M,A),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=h,this.worldview=D}get(){return this._transitionable.serialize()}set(M,h){this._transitionable.setTransitionOrValue(M,h)}updateTransitions(M){this._transitioning=this._transitionable.transitioned(M,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(M){this.properties=this._transitioning.possiblyEvaluate(M)}getExaggeration(M){return this._transitioning.possiblyEvaluate(new i.ac(M,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const M=this._transitionable._values.exaggeration;if(!M)return null;const h=M.value.expression;if(!h)return null;let x=-1,A=-1,D=1;for(const F of h.zoomStops)D=h.evaluate(new i.ac(F,{worldview:this.worldview})),D>.01?(x=F,A=-1):A=F;return D<.01&&x>0&&A>x?[x,A]:null}isZoomDependent(){const M=this._transitionable._values.exaggeration;return M!=null&&M.value!=null&&M.value.expression!=null&&M.value.expression instanceof i.ad}};const Qt=45,As=65,gs=.05;function fr(M,h,x,A){const D=i.ah(Qt,As,x),[F,z]=qr(M,A);let V=1-Math.min(1,Math.exp((h-F)/(z-F)*-6));return V*=V*V,V=Math.min(1,1.00747*V),V*D*M.alpha}function qr(M,h){const x=.5/Math.tan(.5*h);return[M.range[0]+x,M.range[1]+x]}function ur(M,h,x,A,D){const F=i.af([],[h,x,A],D.mercatorFogMatrix);return fr(M,i.ag(F),D.pitch,D._fov)}function Cn(M,h,x,A,D,F,z){const V=[[x,A,0],[D,A,0],[D,F,0],[x,F,0]];let X=Number.MAX_VALUE,ne=-Number.MAX_VALUE;for(const oe of V){const ge=i.af([],oe,h),pe=i.ag(ge);X=Math.min(X,pe),ne=Math.max(ne,pe)}return[fr(M,X,z.pitch,z._fov),fr(M,ne,z.pitch,z._fov)]}const Mn=i.a6.fog;class wn extends i.E{constructor(h,x,A,D){super();const F=new i.a9({range:new i.aa(Mn.range),color:new i.aa(Mn.color),"color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"high-color":new i.aa(Mn["high-color"]),"high-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"space-color":new i.aa(Mn["space-color"]),"space-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new i.aa(Mn["horizon-blend"]),"star-intensity":new i.aa(Mn["star-intensity"]),"vertical-range":new i.aa(Mn["vertical-range"])});this._transitionable=new i.a8(F,A,new Map(D)),this.set(h,D),this._transitioning=this._transitionable.untransitioned(),this._transform=x,this.properties=new i.ai(F),this.scope=A}get state(){const h=this._transform,x=h.projection.name==="globe",A=i.aj(h.zoom),D=this.properties.get("range"),F=[.5,3];return{range:x?[i.ak(F[0],D[0],A),i.ak(F[1],D[1],A)]:D,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(h,x,A={}){if(this._validate(Zn,h,A))return;const D=Object.assign({},h);for(const F of Object.keys(Mn))D[F]===void 0&&(D[F]=Mn[F].default);this._options=D,this._transitionable.setTransitionOrValue(this._options,x)}getOpacity(h){if(!this._transform.projection.supportsFog)return 0;const x=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:i.ah(Qt,As,h))*x.a}getOpacityAtLatLng(h,x){return this._transform.projection.supportsFog?function(A,D,F){const z=i.ae.fromLngLat(D),V=F.elevation?F.elevation.getAtPointOrZero(z):0;return ur(A,z.x,z.y,V,F)}(this.state,h,x):0}getOpacityForTile(h){if(!this._transform.projection.supportsFog)return[1,1];const x=this._transform.calculateFogTileMatrix(h.toUnwrapped());return Cn(this.state,x,0,0,i.al,i.al,this._transform)}getOpacityForBounds(h,x,A,D,F){return this._transform.projection.supportsFog?Cn(this.state,h,x,A,D,F,this._transform):[1,1]}getFovAdjustedRange(h){return this._transform.projection.supportsFog?qr(this.state,h):[0,1]}isVisibleOnFrustum(h){if(!this._transform.projection.supportsFog)return!1;const x=[4,5,6,7];for(const A of x){const D=h.points[A];let F;if(D[2]>=0)F=D;else{const z=h.points[A-4];F=i.am(z,D,z[2]/(z[2]-D[2]))}if(ur(this.state,F[0],F[1],0,this._transform)>=gs)return!0}return!1}updateConfig(h){this._transitionable.setTransitionOrValue(this._options,new Map(h))}updateTransitions(h){this._transitioning=this._transitionable.transitioned(h,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(h){this.properties=this._transitioning.possiblyEvaluate(h)}_validate(h,x,A){return(!A||A.validate!==!1)&&Je(this,h.call(Zt,Object.assign({value:x,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}let ma,lo,qo,Va,Ko=class extends i.E{constructor(M,h,x,A){super();const D=ma||(ma=new i.a9({density:new i.aa(i.a6.snow.density),intensity:new i.aa(i.a6.snow.intensity),color:new i.aa(i.a6.snow.color),opacity:new i.aa(i.a6.snow.opacity),vignette:new i.aa(i.a6.snow.vignette),"vignette-color":new i.aa(i.a6.snow["vignette-color"]),"center-thinning":new i.aa(i.a6.snow["center-thinning"]),direction:new i.aa(i.a6.snow.direction),"flake-size":new i.aa(i.a6.snow["flake-size"])}));this._transitionable=new i.a8(D,x,new Map(A)),this.set(M,A),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(D),this.scope=x}get state(){const M=this.properties.get("opacity"),h=this.properties.get("color"),x=this.properties.get("direction"),A=i.an(x[0]),D=-Math.max(i.an(x[1]),.01),F=[Math.cos(A)*Math.cos(D),Math.sin(A)*Math.cos(D),Math.sin(D)],z=this.properties.get("vignette"),V=this.properties.get("vignette-color");return V.a=z,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.ao(h.r,h.g,h.b,h.a*M),direction:F,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:V}}get(){return this._transitionable.serialize()}set(M,h,x={}){if(this._validate(Ir,M,x))return;const A=Object.assign({},M),D=i.a6.snow;for(const F of Object.keys(D))A[F]===void 0&&(A[F]=D[F].default);this._options=A,this._transitionable.setTransitionOrValue(this._options,h)}updateConfig(M){this._transitionable.setTransitionOrValue(this._options,new Map(M))}updateTransitions(M){this._transitioning=this._transitionable.transitioned(M,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(M){this.properties=this._transitioning.possiblyEvaluate(M)}_validate(M,h,x){return(!x||x.validate!==!1)&&Je(this,M.call(Zt,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}},Xi=class extends i.E{constructor(M,h,x,A){super();const D=lo||(lo=new i.a9({density:new i.aa(i.a6.rain.density),intensity:new i.aa(i.a6.rain.intensity),color:new i.aa(i.a6.rain.color),opacity:new i.aa(i.a6.rain.opacity),vignette:new i.aa(i.a6.rain.vignette),"vignette-color":new i.aa(i.a6.rain["vignette-color"]),"center-thinning":new i.aa(i.a6.rain["center-thinning"]),direction:new i.aa(i.a6.rain.direction),"droplet-size":new i.aa(i.a6.rain["droplet-size"]),"distortion-strength":new i.aa(i.a6.rain["distortion-strength"])}));this._transitionable=new i.a8(D,x,new Map(A)),this.set(M,A),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(D),this.scope=x}get state(){const M=this.properties.get("opacity"),h=this.properties.get("color"),x=this.properties.get("direction"),A=i.an(x[0]),D=-Math.max(i.an(x[1]),.01),F=[Math.cos(A)*Math.cos(D),Math.sin(A)*Math.cos(D),Math.sin(D)],z=this.properties.get("vignette-color");return z.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.ao(h.r,h.g,h.b,h.a*M),direction:F,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:z}}get(){return this._transitionable.serialize()}set(M,h,x={}){if(this._validate(mi,M,x))return;const A=Object.assign({},M),D=i.a6.rain;for(const F of Object.keys(D))A[F]===void 0&&(A[F]=D[F].default);this._options=A,this._transitionable.setTransitionOrValue(this._options,h)}updateConfig(M){this._transitionable.setTransitionOrValue(this._options,new Map(M))}updateTransitions(M){this._transitioning=this._transitionable.transitioned(M,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(M){this.properties=this._transitioning.possiblyEvaluate(M)}_validate(M,h,x){return(!x||x.validate!==!1)&&Je(this,M.call(Zt,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}};class ba extends i.E{constructor(h,x,A,D){super(),this.scope=A,this._options=h,this.properties=new i.ai(x),this._transitionable=new i.a8(x,A,new Map(D)),this._transitionable.setTransitionOrValue(h.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(h){this._transitionable.setTransitionOrValue(this._options.properties,new Map(h))}updateTransitions(h){this._transitioning=this._transitionable.transitioned(h,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(h){this.properties=this._transitioning.possiblyEvaluate(h)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(h,x){this._options=h,this._transitionable.setTransitionOrValue(h.properties,x)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}class Qi{constructor(h,x,A){this.screenBounds=h,this.cameraPoint=A.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=x,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,A)}static createFromScreenPoints(h,x){let A,D;if(h instanceof i.P||typeof h[0]=="number"){const F=i.P.convert(h);A=[F],D=x.isPointAboveHorizon(F)}else{const F=i.P.convert(h[0]),z=i.P.convert(h[1]),V=F.add(z)._div(2);A=[F,z],D=i.aq(F,z).every(X=>x.isPointAboveHorizon(X))&&x.isPointAboveHorizon(V)}return new Qi(A,D,x)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(h){return i.aq(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],h)}bufferedCameraGeometry(h){const x=this.screenBounds[0],A=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.aq(x,A,0,!1);return this.cameraPoint.y>A.y&&(this.cameraPoint.x>x.x&&this.cameraPoint.x=A.x?D[2]=this.cameraPoint:this.cameraPoint.x<=x.x&&(D[3]=this.cameraPoint)),i.ar(D,h)}bufferedCameraGeometryGlobe(h){const x=this.screenBounds[0],A=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.aq(x,A,h),F=this.cameraPoint.clone();switch(3*((F.y>x.y)+(F.y>A.y))+((F.x>x.x)+(F.x>A.x))){case 0:D[0]=F,D[4]=F.clone();break;case 1:D.splice(1,0,F);break;case 2:D[1]=F;break;case 3:D.splice(4,0,F);break;case 5:D.splice(2,0,F);break;case 6:D[3]=F;break;case 7:D.splice(3,0,F);break;case 8:D[2]=F}return D}containsTile(h,x,A,D=0){const F=Math.max(h.queryPadding,h.evaluateQueryRenderedFeaturePadding())/x._pixelsPerMercatorPixel+1,z=A?this._bufferedCameraMercator(F,x):this._bufferedScreenMercator(F,x);let V=h.tileID.wrap+(z.unwrapped?D:0);const X=z.polygon.map(Ve=>i.as(h.tileTransform,Ve,V));if(!i.at(X,0,0,i.al,i.al))return;V=h.tileID.wrap+(this.screenGeometryMercator.unwrapped?D:0);const ne=this.screenGeometryMercator.polygon.map(Ve=>i.au(h.tileTransform,Ve,V)),oe=ne.map(Ve=>new i.P(Ve[0],Ve[1])),ge=x.getFreeCameraOptions().position||new i.ae(0,0,0),pe=i.au(h.tileTransform,ge,V),xe=ne.map(Ve=>{const Be=i.av(Ve,Ve,pe);return i.aw(Be,Be),new i.ax(pe,Be)}),Pe=i.ay(h,1,x.zoom)*x._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:oe,tilespaceRays:xe,bufferedTilespaceGeometry:X,bufferedTilespaceBounds:(Ce=i.az(X),Ce.min.x=i.aA(Ce.min.x,0,i.al),Ce.min.y=i.aA(Ce.min.y,0,i.al),Ce.max.x=i.aA(Ce.max.x,0,i.al),Ce.max.y=i.aA(Ce.max.y,0,i.al),Ce),tile:h,tileID:h.tileID,pixelToTileUnitsFactor:Pe};var Ce}_bufferedScreenMercator(h,x){const A=Ji(h);if(this._screenRaycastCache[A])return this._screenRaycastCache[A];{let D;return D=x.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(h),x):{polygon:this.bufferedScreenGeometry(h).map(F=>x.pointCoordinate3D(F)),unwrapped:!0},this._screenRaycastCache[A]=D,D}}_bufferedCameraMercator(h,x){const A=Ji(h);if(this._cameraRaycastCache[A])return this._cameraRaycastCache[A];{let D;return D=x.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(h),x):{polygon:this.bufferedCameraGeometry(h).map(F=>x.pointCoordinate3D(F)),unwrapped:!0},this._cameraRaycastCache[A]=D,D}}_projectAndResample(h,x){const A=function(F,z){const V=i.aB([],z.pixelMatrix,z.globeMatrix),X=[0,-i.aD,0,1],ne=[0,i.aD,0,1],oe=[0,0,0,1];i.aC(X,X,V),i.aC(ne,ne,V),i.aC(oe,oe,V);const ge=new i.P(X[0]/X[3],X[1]/X[3]),pe=new i.P(ne[0]/ne[3],ne[1]/ne[3]),xe=i.aE(F,ge)&&X[3]1?vi(F.slice(0,Ve),z):[],dt=Venew i.P(ra(jt.x),jt.y)),dt=dt.map(jt=>new i.P(ra(jt.x),jt.y));const st=[...tt];st.length===0&&st.push(dt[dt.length-1]);const Mt=i.ak(st[st.length-1].y,(dt.length===0?tt[0]:dt[0]).y,Be);let yt;return yt=xe?[new i.P(0,Mt),new i.P(0,0),new i.P(1,0),new i.P(1,Mt)]:[new i.P(1,Mt),new i.P(1,1),new i.P(0,1),new i.P(0,Mt)],st.push(...yt),dt.length===0?st.push(tt[0]):st.push(...dt),{polygon:st.map(jt=>new i.ae(jt.x,jt.y)),unwrapped:!1}}(h,x);if(A)return A;const D=function(F,z){let V=!1,X=-1/0,ne=0;for(let ge=0;geX&&(X=F[ge].x,ne=ge);for(let ge=0;ge.5&&(xe.x{ge.x-=1}),{polygon:F,unwrapped:V}}(vi(h,x).map(F=>new i.P(ra(F.x),F.y)),x);return{polygon:D.polygon.map(F=>new i.ae(F.x,F.y)),unwrapped:D.unwrapped}}}function vi(M,h){return i.aG(M,x=>{const A=h.pointCoordinate3D(x);x.x=A.x,x.y=A.y},1/256)}function ra(M){return M<0?1+M%1:M%1}function Ji(M){return 100*M|0}function ic(M,h,x,A,D){const F=function(V,X){if(V)return D(V);if(X){if(M.url&&X.tiles&&M.tiles&&delete M.tiles,X.variants){if(!Array.isArray(X.variants))return D(new Error("variants must be an array"));for(const oe of X.variants){if(oe==null||typeof oe!="object"||oe.constructor!==Object)return D(new Error("variant must be an object"));if(!Array.isArray(oe.capabilities))return D(new Error("capabilities must be an array"));if(oe.capabilities.length===1&&oe.capabilities[0]==="meshopt"){X=Object.assign(X,oe);break}}}const ne=i.aH(Object.assign({},X,M),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);ne.tiles=h.canonicalizeTileset(ne,M.url),D(null,ne)}},z=function(V,X,ne){if(!V)return null;if(!X&&!ne)return V;ne=ne||V.worldview_default;const oe=Object.values(V.language||{});if(oe.length===0)return null;const ge=Object.values(V.worldview||{});if(ge.length===0)return null;const pe=oe.every(Pe=>Pe===X),xe=ge.every(Pe=>Pe===ne);return pe&&xe?V:X in(V.language_options||{})||ne in(V.worldview_options||{})?null:V.language_options&&V.worldview_options?V:null}(M.data,x,A);return z?i.o.frame(()=>F(null,z)):M.url?i.m(h.transformRequest(h.normalizeSourceURL(M.url,null,x,A),i.R.Source),F):i.o.frame(()=>{const{data:V,...X}=M;F(null,X)})}function vc(M,h){const x=Math.pow(2,h.z),A=Math.floor(i.aF(M.getWest())*x),D=Math.floor(i.aJ(M.getNorth())*x),F=Math.ceil(i.aF(M.getEast())*x),z=Math.ceil(i.aJ(M.getSouth())*x);return h.x>=A&&h.x=D&&h.ythis.maxzoom||h.z{if(this._tileJSONRequest=null,this._loaded=!0,D)x&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${x}`),A&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${A}`),this.fire(new i.y(D));else if(F){if(Object.assign(this,F),this.hasWorldviews=!!F.worldview_options,F.worldview_default&&(this.worldviewDefault=F.worldview_default),F.vector_layers){this.vectorLayers=F.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const z of F.vector_layers)this.vectorLayerIds.push(z.id),F.worldview&&F.worldview[z.source]&&this.localizableLayerIds.add(z.id)}this.tileBounds=Td.fromTileJSON(F),Ne(F.tiles,this.map._requestManager._customAccessToken),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}h&&h(D)})}loaded(){return this._loaded}hasTile(h){return!this.tileBounds||this.tileBounds.contains(h.canonical)}onAdd(h){this.map=h,this.load()}reload(){this.cancelTileJSONRequest();const h=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(h))}setTiles(h){return this._options.tiles=h,this.reload(),this}setUrl(h){return this.url=h,this._options.url=h,this.reload(),this}onRemove(h){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}loadTile(h,x){const A=h.tileID.canonical.url(this.tiles,this.scheme),D=this.map._requestManager.normalizeTileURL(A),F=this.map._requestManager.transformRequest(D,i.R.Tile),z=this.map.style?this.map.style.getLut(this.scope):null,V=z?{image:z.image.clone()}:null,X={request:F,data:void 0,uid:h.uid,tileID:h.tileID,tileZoom:h.tileZoom,zoom:h.tileID.overscaledZ,maxZoom:this.maxzoom,lut:V,tileSize:this.tileSize*h.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:i.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:h.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:h.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};if(this.hasWorldviews&&i.h(A)&&(X.localizableLayerIds=this.localizableLayerIds),X.request.collectResourceTiming=this._collectResourceTiming,h.actor&&h.state!=="expired")h.state==="loading"?h.reloadCallback=x:h.request=h.actor.send("reloadTile",X,ne.bind(this));else if(h.actor=this._tileWorkers[D]=this._tileWorkers[D]||this.dispatcher.getActor(),this.dispatcher.ready)h.request=h.actor.send("loadTile",X,ne.bind(this),void 0,!0);else{const oe=i.aL.call({deduped:this._deduped},X,(ge,pe)=>{if(ge||!pe)ne.call(this,ge);else{const xe=i.aM(pe.responseHeaders);X.data={rawData:pe.rawData.slice(0),expires:xe.expires,cacheControl:xe.cacheControl},h.actor&&h.actor.send("loadTile",X,ne.bind(this),void 0,!0)}},!0);h.request={cancel:oe}}function ne(oe,ge){return delete h.request,h.aborted?x(null):oe&&oe instanceof i.aN&&oe.status!==404?x(oe):(ge&&ge.resourceTiming&&(h.resourceTiming=ge.resourceTiming),this.map._refreshExpiredTiles&&ge&&h.setExpiryData(ge),h.loadVectorData(ge,this.map.painter),i.aO(this.dispatcher),x(null,ge),void(h.reloadCallback&&(this.loadTile(h,h.reloadCallback),h.reloadCallback=null)))}}abortTile(h){h.request&&(h.request.cancel(),delete h.request),h.actor&&h.actor.send("abortTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(h,x){h.actor&&h.actor.send("removeTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope}),h.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class vl extends i.E{constructor(h,x,A,D){super(),this.id=h,this.dispatcher=A,this.setEventedParent(D),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=Object.assign({type:"raster"},x),Object.assign(this,i.aH(x,["url","scheme","tileSize"]))}load(h){this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"}));const x=this.map.getWorldview();this._tileJSONRequest=ic(this._options,this.map._requestManager,null,x,(A,D)=>{this._tileJSONRequest=null,this._loaded=!0,A?this.fire(new i.y(A)):D&&(Object.assign(this,D),D.raster_layers&&(this.rasterLayers=D.raster_layers,this.rasterLayerIds=this.rasterLayers.map(F=>F.id)),this.tileBounds=Td.fromTileJSON(D),Ne(D.tiles),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))),h&&h(A)})}loaded(){return this._loaded}onAdd(h){this.map=h,this.load()}reload(){this.cancelTileJSONRequest();const h=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(h))}setTiles(h){return this._options.tiles=h,this.reload(),this}setUrl(h){return this.url=h,this._options.url=h,this.reload(),this}onRemove(h){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}hasTile(h){return!this.tileBounds||this.tileBounds.contains(h.canonical)}loadTile(h,x){const A=i.o.devicePixelRatio>=2,D=this.map._requestManager.normalizeTileURL(h.tileID.canonical.url(this.tiles,this.scheme),A,this.tileSize);h.request=i.n(this.map._requestManager.transformRequest(D,i.R.Tile),(F,z,V)=>{if(delete h.request,h.aborted)return h.state="unloaded",x(null);if(F)return h.state="errored",x(F);if(!z)return x(null);const X=i.aM(V);this.map._refreshExpiredTiles&&h.setExpiryData(X),h.setTexture(z,this.map.painter),h.state="loaded",i.aO(this.dispatcher),x(null)})}abortTile(h,x){h.request&&(h.request.cancel(),delete h.request),x&&x()}unloadTile(h,x){h.texture&&h.texture instanceof i.T?(h.destroy(!1),h.texture&&h.texture instanceof i.T&&this.map.painter.saveTileTexture(h.texture)):h.destroy(),x&&x()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function Nu([M,h],x,A,{scaled:D=!0}={}){const{tileSize:F,buffer:z}=A,{x:V,y:X,z:ne}=x;if(!isFinite(V)||!isFinite(X)||!isFinite(ne))throw new Error("Invalid MRT header");const oe=2**ne,ge=oe*i.aF(M),pe=oe*i.aJ(h);return function([xe,Pe],Ce,{scaled:Ve=!0}={}){if(!Ce)throw new Error("bandView is undefined");const{data:Be,tileSize:tt,buffer:dt,offset:st,scale:Mt,dimension:yt}=Ce;if(xe<-dt||xe>tt+dt||Pe<-dt||Pe>tt+dt)throw new Error(`Point (${xe}, ${Pe}) out of bounds for tileSize=${tt}, buffer=${dt}`);const jt=(Pe+dt)*(tt+2*dt)+(xe+dt);if(new Uint32Array(Be.buffer)[jt]===4294967295)return null;let gt=[];gt=Ve?[]:new Ce.data.constructor(yt);for(let mt=0;mt{if(delete h.request,h.aborted)return h.state="unloaded",x(null);if(V)return V.name==="AbortError"?void 0:(h.state="errored",x(V));if(this.map._refreshExpiredTiles&&X){const oe=i.aM(ne);h.setExpiryData(oe)}if(this.partial&&h.state!=="expired")h.state="empty";else if(!this.partial){if(!X)return x(null);h.state="loaded",h._isHeaderLoaded=!0,h._mrt=X}x(null)};h.request=this.partial?h.fetchHeader(void 0,z.bind(this)):h.actor.send("loadTile",F,z.bind(this),void 0,!0)}abortTile(h){h.request&&(h.request.cancel(),delete h.request),h.actor&&h.actor.send("abortTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(h,x){const A=h.texturePerLayer;if(h.flushAllQueues(),A.size){h.destroy(!1);for(const D of A.values())this.map.painter.saveTileTexture(D)}else h.destroy()}prepareTile(h,x,A,D){h._isHeaderLoaded&&(h.state!=="empty"&&(h.state="reloading"),h.fetchBandForRender(x,A,D,(F,z)=>{if(F)return h.state="errored",this.fire(new i.y(F)),void this.triggerRepaint(h);z&&(h._isHeaderLoaded=!0,h.setTexturePerLayer(A,z,this.map.painter),h.state="loaded",this.triggerRepaint(h))}))}getInitialBand(h){if(!this.rasterLayers)return 0;const x=this.rasterLayers.find(({id:F})=>F===h),A=x&&x.fields,D=A&&A.bands&&A.bands;return D?D[0]:0}getTextureDescriptor(h,x,A){if(!h)return;const D=x.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!D)return;let F=null;x instanceof i.aR?F=x.paint.get("raster-array-band"):x instanceof i.aS&&(F=x.paint.get("raster-particle-array-band"));const z=F||this.getInitialBand(D);if(z==null)return;if(!h.textureDescriptorPerLayer.get(x.id))return void this.prepareTile(h,D,x.id,z);if(h.updateNeeded(x.id,z)&&!A)return;const V=h.textureDescriptorPerLayer.get(x.id);return Object.assign({},V,{texture:h.texturePerLayer.get(x.id)})}getImages(h,x){const A=new Map;for(const D of h)for(const F of x){const[z,V]=F.split("/"),X=D.getLayer(z);if(!X||!X.hasBand(V)||!X.hasDataForBand(V))continue;const{bytes:ne,tileSize:oe,buffer:ge}=X.getBandView(V),pe=oe+2*ge,xe={data:new i.q({width:pe,height:pe},ne),pixelRatio:2,sdf:!1,usvg:!1,version:0};A.set(F,xe)}return A}queryRasterArrayValueByBandId(h,x,A){const D=x._mrt;return new Promise(F=>{const z={},V=new Set;for(const[X,ne]of Object.entries(D.layers)){if(A.layerName&&X!==A.layerName)continue;const oe={};z[X]=oe;for(const{bands:ge}of ne.dataIndex)for(const pe of ge)A.bands&&!A.bands.includes(pe)||(V.add(i.B(X,pe)),x.fetchBand(X,null,pe,xe=>{i.o.frame(()=>{oe[pe]=xe?null:Nu([h.lng,h.lat],D,ne.getBandView(pe)),V.delete(i.B(X,pe)),V.size===0&&F(z)})},!1))}V.size===0&&F(z)})}_loadTileForQuery(h,x){if(this._loadTileLoaded[h.uid])return void x(null,h._mrt);if(this._loadTilePending[h.uid])return void this._loadTilePending[h.uid].push(x);this._loadTilePending[h.uid]=[x];const A=this.map._requestManager.normalizeTileURL(h.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),D=this.map._requestManager.transformRequest(A,i.R.Tile);h.actor.send("loadTile",{request:D,uid:h.uid,tileID:h.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(F,z,V)=>{if(F)return this._loadTilePending[h.uid].forEach(X=>X(F,null)),void delete this._loadTilePending[h.uid];if(!z)return this._loadTilePending[h.uid].forEach(X=>X(null,null)),void delete this._loadTilePending[h.uid];if(this.map._refreshExpiredTiles&&z){const X=i.aM(V);h.setExpiryData(X)}h._mrt=z,h._isHeaderLoaded=!0,h.state="loaded",this._loadTilePending[h.uid].forEach(X=>X(null,z)),this._loadTileLoaded[h.uid]=!0,delete this._loadTilePending[h.uid]},void 0,!0)}queryRasterArrayValueByAllBands(h,x,A){return new Promise((D,F)=>{this._loadTileForQuery(x,(z,V)=>{z?F(z):D(V?this.queryRasterArrayValueByBandId(h,x,A):null)})})}queryRasterArrayValue(h,x){const A=i.aT.convert(h),D=this.findLoadedParent(A);return D&&D._mrt?x.bands||!this.partial?this.queryRasterArrayValueByBandId(A,D,x):this.queryRasterArrayValueByAllBands(A,D,x):Promise.resolve(null)}findLoadedParent(h){const x=i.ae.fromLngLat(h,this.map.transform.tileSize),A=this.maxzoom+1,D=1<0&&(V[new i.aQ(M.overscaledZ,D,h.z,A,h.y-1).key]={backfilled:!1},V[new i.aQ(M.overscaledZ,M.wrap,h.z,h.x,h.y-1).key]={backfilled:!1},V[new i.aQ(M.overscaledZ,z,h.z,F,h.y-1).key]={backfilled:!1}),h.y+1{if(this._loaded=!0,this._pendingLoad=null,A)this.fire(new i.y(A));else{const F={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&D&&D.resourceTiming&&D.resourceTiming[this.id]&&(F.resourceTiming=D.resourceTiming[this.id]),M&&(this._partialReload=!0),this.fire(new i.z("data",F)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(M),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const M=i.B(this.id,this.scope);this.map.style.clearSource(M),this._updateWorkerData()}loadTile(M,h){const x=M.actor?"reloadTile":"loadTile";M.actor=this.actor;const A=this.map.style?this.map.style.getLut(this.scope):null,D=A?{image:A.image.clone()}:null,F=this._partialReload,z={type:this.type,uid:M.uid,tileID:M.tileID,tileZoom:M.tileZoom,zoom:M.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:D,scope:this.scope,pixelRatio:i.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:M.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:F,worldview:this.map.getWorldview(),indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};M.request=this.actor.send(x,z,(V,X)=>F&&!X?(M.state="loaded",h(null)):(delete M.request,M.destroy(!1),M.aborted?h(null):V?h(V):(M.loadVectorData(X,this.map.painter,x==="reloadTile"),h(null))),void 0,x==="loadTile")}abortTile(M){M.request&&(M.request.cancel(),delete M.request),M.aborted=!0}unloadTile(M,h){this.actor.send("removeTile",{uid:M.uid,type:this.type,source:this.id,scope:this.scope}),M.destroy()}onRemove(M){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends i.aU{constructor(M,h,x,A){super(M,h,x,A),this.roundZoom=!0,this.type="video",this.options=h}load(){this._loaded=!1;const M=this.options;this.urls=[];for(const h of M.urls)this.urls.push(this.map._requestManager.transformRequest(h,i.R.Source).url);i.aV(this.urls,(h,x)=>{this._loaded=!0,h?this.fire(new i.y(h)):x&&(this.video=x,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(M){if(this.video){const h=this.video.seekable;Mh.end(0)?this.fire(new i.y(new i.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${h.start(0)} and ${h.end(0)}-second mark.`))):this.video.currentTime=M}}getVideo(){return this.video}onAdd(M){this.map||(this.map=M,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const M=this.map.painter.context,h=M.gl;this.texture?this.video.paused||(this.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),h.texSubImage2D(h.TEXTURE_2D,0,0,0,h.RGBA,h.UNSIGNED_BYTE,this.video)):(this.texture=new i.T(M,this.video,h.RGBA8),this.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(M)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:i.aU,model:i.aX,"batched-model":class extends i.E{constructor(M,h,x,A){super(),this.type="batched-model",this.id=M,this.tileSize=512,this._options=h,this.tiles=this._options.tiles,this.maxzoom=h.maxzoom||19,this.minzoom=h.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=x,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(A)}onAdd(M){this.map=M,this.load()}reload(){this.cancelTileJSONRequest();const M=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(M))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(M){this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"}));const h=Array.isArray(this.map._language)?this.map._language.join():this.map._language,x=this.map.getWorldview();this._tileJSONRequest=ic(this._options,this.map._requestManager,h,x,(A,D)=>{this._tileJSONRequest=null,this._loaded=!0,A?(h&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${h}`),x&&x.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${x}`),this.fire(new i.y(A))):D&&(Object.assign(this,D),D.bounds&&(this.tileBounds=new Td(D.bounds,this.minzoom,this.maxzoom)),Ne(D.tiles,this.map._requestManager._customAccessToken),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))),M&&M(A)})}hasTransition(){return!1}hasTile(M){return!this.tileBounds||this.tileBounds.contains(M.canonical)}loaded(){return this._loaded}loadTile(M,h){const x=this.map._requestManager.normalizeTileURL(M.tileID.canonical.url(this.tiles,this.scheme)),A={request:this.map._requestManager.transformRequest(x,i.R.Tile),data:void 0,uid:M.uid,tileID:M.tileID,tileZoom:M.tileZoom,zoom:M.tileID.overscaledZ,tileSize:this.tileSize*M.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:M.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:i.o.devicePixelRatio,promoteId:this.promoteId};if(M.actor&&M.state!=="expired")if(M.state==="loading")M.reloadCallback=h;else{if(M.buckets){const F=Object.values(M.buckets);for(const z of F)z.dirty=!0;return void(M.state="loaded")}M.request=M.actor.send("reloadTile",A,D.bind(this))}else M.actor=this.dispatcher.getActor(),M.request=M.actor.send("loadTile",A,D.bind(this),void 0,!0);function D(F,z){return M.aborted?h(null):F&&F.status!==404?h(F):(this.map._refreshExpiredTiles&&z&&M.setExpiryData(z),M.loadModelData(z,this.map.painter),M.state="loaded",void h(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends i.aU{constructor(M,h,x,A){super(M,h,x,A),h.coordinates?Array.isArray(h.coordinates)&&h.coordinates.length===4&&!h.coordinates.some(D=>!Array.isArray(D)||D.length!==2||D.some(F=>typeof F!="number"))||this.fire(new i.y(new i.V(`sources.${M}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.y(new i.V(`sources.${M}`,null,'missing required property "coordinates"'))),h.animate&&typeof h.animate!="boolean"&&this.fire(new i.y(new i.V(`sources.${M}`,null,'optional "animate" property must be a boolean value'))),h.canvas?typeof h.canvas=="string"||h.canvas instanceof HTMLCanvasElement||this.fire(new i.y(new i.V(`sources.${M}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new i.y(new i.V(`sources.${M}`,null,'missing required property "canvas"'))),this.options=h,this.animate=h.animate===void 0||h.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.y(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(M){this.map=M,this.load(),this.canvas&&this.animate&&this.play()}onRemove(M){this.pause()}prepare(){let M=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,M=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,M=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const h=this.map.painter.context;this.texture?!M&&!this._playing||this.texture instanceof i.aW||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.T(h,this.canvas,h.gl.RGBA8,{premultiply:!0}),this._prepareData(h)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const M of[this.canvas.width,this.canvas.height])if(isNaN(M)||M<=0)return!0;return!1}},custom:class extends i.E{constructor(M,h,x,A){super(),this.id=M,this.type="custom",this._dataType="raster",this._dispatcher=x,this._implementation=h,this.setEventedParent(A),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new i.y(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new i.y(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Td(this._implementation.bounds,this.minzoom,this.maxzoom)),h.update=this._update.bind(this),h.clearTiles=this._clearTiles.bind(this),h.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,i.aH(h,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return i.aH(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(M){this.map=M,this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(M),this.load()}onRemove(M){this._implementation.onRemove&&this._implementation.onRemove(M)}hasTile(M){if(this._implementation.hasTile){const{x:h,y:x,z:A}=M.canonical;return this._implementation.hasTile({x:h,y:x,z:A})}return!this.tileBounds||this.tileBounds.contains(M.canonical)}loadTile(M,h){const{x,y:A,z:D}=M.tileID.canonical,F=new AbortController;M.request=Promise.resolve(this._implementation.loadTile({x,y:A,z:D},{signal:F.signal})).then((function(z){return delete M.request,M.aborted?(M.state="unloaded",h(null)):z===void 0?(M.state="errored",h(null)):z===null?(this.loadTileData(M,{width:this.tileSize,height:this.tileSize,data:null}),M.state="loaded",h(null)):function(V){return V instanceof ImageData||V instanceof HTMLCanvasElement||V instanceof ImageBitmap||V instanceof HTMLImageElement}(z)?(this.loadTileData(M,z),M.state="loaded",void h(null)):(M.state="errored",h(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}).bind(this)).catch(z=>{z.name!=="AbortError"&&(M.state="errored",h(z))}),M.request.cancel=()=>F.abort()}loadTileData(M,h){M.setTexture(h,this.map.painter)}unloadTile(M,h){if(M.texture&&M.texture instanceof i.T?(M.destroy(!1),M.texture&&M.texture instanceof i.T&&this.map.painter.saveTileTexture(M.texture)):M.destroy(),this._implementation.unloadTile){const{x,y:A,z:D}=M.tileID.canonical;this._implementation.unloadTile({x,y:A,z:D})}h&&h()}abortTile(M,h){M.request&&M.request.cancel&&(M.request.cancel(),delete M.request),h&&h()}hasTransition(){return!1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(M=>({x:M.canonical.x,y:M.canonical.y,z:M.canonical.z}))}_clearTiles(){const M=i.B(this.id,this.scope);this.map.style.clearSource(M)}_update(){this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}}},_l=function(M,h,x,A){const D=new sm[h.type](M,h,x,A);if(D.id!==M)throw new Error(`Expected Source id to be ${M} instead of ${D.id}`);return i.aY(["load","abort","unload","serialize","prepare"],D),D};function Bf(M,h,x=""){return`${x}:${h.id||""}:${h.layer.id}:${function(A){if("layerId"in A)return`layer:${A.layerId}`;{const{featuresetId:D,importId:F}=A;return`featureset:${D}${F?`:import:${F}`:""}`}}(M.target)}`}function ax(M,h,x,A=""){if(M.uniqueFeatureID){const D=Bf(M,h,A);if(x.has(D))return!0;x.add(D)}return!1}function pv(M,h,x,A,D=!1){const F=h.sourceCache.transform,z=h.sourceCache.tilesIn(M,h.has3DLayers,D);z.sort(Vm);const V=[];for(const X of z){const ne=X.tile.queryRenderedFeatures(h,X,x,A,F,D);Object.keys(ne).length&&V.push({wrappedTileID:X.tile.tileID.wrapped().key,queryResults:ne})}for(const X in h.layers){const ne=h.layers[X];if(ne.styleLayer){const oe=ne.styleLayer.queryRenderedFeatures(M,h.sourceCache,A);Object.keys(oe).length&&V.push({wrappedTileID:0,queryResults:oe})}}return V.length===0?{}:function(X){const ne={},oe={};for(const ge of X){const pe=ge.queryResults,xe=ge.wrappedTileID,Pe=oe[xe]=oe[xe]||{};for(const Ce in pe){const Ve=pe[Ce],Be=Pe[Ce]=Pe[Ce]||{},tt=ne[Ce]=ne[Ce]||[];for(const dt of Ve)Be[dt.featureIndex]||(Be[dt.featureIndex]=!0,tt.push(dt))}}return ne}(V)}function fv(M,h,x,A,D,F){const z={},V=A.queryRenderedSymbols(M),X=[];for(const ne of Object.keys(V).map(Number))X.push(D[ne]);X.sort(Vm);for(const ne of X){const oe=ne.featureIndex.lookupSymbolFeatures(V[ne.bucketInstanceId],ne.bucketIndex,ne.sourceLayerIndex,h,x,F);for(const ge in oe){const pe=z[ge]=z[ge]||[],xe=oe[ge];xe.sort((Pe,Ce)=>{const Ve=ne.featureSortOrder;if(Ve){const Be=Ve.indexOf(Pe.featureIndex);return Ve.indexOf(Ce.featureIndex)-Be}return Ce.featureIndex-Pe.featureIndex});for(const Pe of xe)pe.push(Pe)}}return z}function gv(M,h){const x=M.getRenderableIds().map(F=>M.getTileByID(F)),A=[],D={};for(let F=0;Fh.getLayer(F)).filter(Boolean);if(D.length!==0){A.layers=D,A.stateDependentLayerIds&&(A.stateDependentLayers=A.stateDependentLayerIds.map(F=>D.filter(z=>z.id===F)[0]));for(const F of D)x[F.fqid]=A}}return x}const Ad=32,xh=33,hd=new Uint16Array(8184);for(let M=0;M<2046;M++){let h=M+2,x=0,A=0,D=0,F=0,z=0,V=0;for(1&h?D=F=z=Ad:x=A=V=Ad;(h>>=1)>1;){const ne=x+D>>1,oe=A+F>>1;1&h?(D=x,F=A,x=z,A=V):(x=D,A=F,D=z,F=V),z=ne,V=oe}const X=4*M;hd[X+0]=x,hd[X+1]=A,hd[X+2]=D,hd[X+3]=F}const Qc=new Uint16Array(2178),Ed=new Uint8Array(1089),Ep=new Uint16Array(1089);function Pp(M){return M===0?-.03125:M===32?.03125:0}const rm={type:2,extent:i.al,loadGeometry:()=>[[new i.P(0,0),new i.P(i.al+1,0),new i.P(i.al+1,i.al+1),new i.P(0,i.al+1),new i.P(0,0)]]};class nm{constructor(h,x,A,D,F,z){this.tileID=h,this.uid=i.b2(),this.uses=0,this.tileSize=x,this.tileZoom=A,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=F,D&&D.style&&(this._lastUpdatedBrightness=D.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",D&&D.transform&&(this.projection=D.transform.projection),this.worldview=z,this._hasAppearances=null}registerFadeDuration(h){const x=h+this.timeAdded;xA)D=!1;else if(x)if(this.expirationTimeA.appearances&&A.appearances.length>0))return!0;return!1}updateBuckets(h,x){if(!this.latestFeatureIndex||!h.style)return;const A=h.style.listImages(),D=h.style.getBrightness();for(const F in this.buckets){if(!h.style.hasLayer(F))continue;const z=this.buckets[F],V=z.layers[0],X=V.sourceLayer||"_geojsonTileLayer",ne=h.style.getLayerSourceCache(V);let oe={};ne&&(oe=ne._state.getState(X,void 0));const ge=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},pe=Object.keys(oe).length>0&&!x;z.hasAppearances=z.layers.some(Ce=>Ce.appearances&&Ce.appearances.length>0);const xe=pe?z.stateDependentLayers:z.layers;if(pe&&z.stateDependentLayers.length!==0||x){const Ce=this.latestFeatureIndex.loadVTLayers();z.update(oe,Ce[X],A,ge,xe,x,D)}if(pe&&z.stateDependentLayers.length!==0||x||z.hasAppearances){const Ce={zoom:h.transform.zoom,pitch:h.transform.pitch,brightness:h.style.getBrightness()||0,worldview:h.worldview};z.updateAppearances(this.tileID.canonical,oe,A,Ce)}(z instanceof i.ba||z instanceof i.bb)&&h._terrain&&h._terrain.enabled&&ne&&z.uploadPending()&&h._terrain._clearRenderCacheForTile(ne.id,this.tileID);const Pe=h&&h.style&&h.style.getOwnLayer(F);Pe&&(this.queryPadding=Math.max(this.queryPadding,Pe.queryRadius(z)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;Ve--){const Be=4*Ve,tt=hd[Be+0],dt=hd[Be+1],st=hd[Be+2],Mt=hd[Be+3],yt=tt+st>>1,jt=dt+Mt>>1,gt=yt+jt-dt,mt=jt+tt-yt,Et=dt*xh+tt,Ht=Mt*xh+st,Ut=jt*xh+yt,ts=Math.hypot((Qc[2*Et+0]+Qc[2*Ht+0])/2-Qc[2*Ut+0],(Qc[2*Et+1]+Qc[2*Ht+1])/2-Qc[2*Ut+1])>=16;Ed[Ut]=Ed[Ut]||(ts?1:0),Ve<1022&&(Ed[Ut]=Ed[Ut]||Ed[(dt+mt>>1)*xh+(tt+gt>>1)]||Ed[(Mt+mt>>1)*xh+(st+gt>>1)])}const ge=new i.b1,pe=new i.b0;let xe=0;function Pe(Ve,Be){const tt=Be*xh+Ve;return Ep[tt]===0&&(ge.emplaceBack(Qc[2*tt+0],Qc[2*tt+1],Ve*i.al/Ad,Be*i.al/Ad),Ep[tt]=++xe),Ep[tt]-1}function Ce(Ve,Be,tt,dt,st,Mt){const yt=Ve+tt>>1,jt=Be+dt>>1;if(Math.abs(Ve-st)+Math.abs(Be-Mt)>1&&Ed[jt*xh+yt])Ce(st,Mt,Ve,Be,yt,jt),Ce(tt,dt,st,Mt,yt,jt);else{const gt=Pe(Ve,Be),mt=Pe(tt,dt),Et=Pe(st,Mt);pe.emplaceBack(gt,mt,Et)}}return Ce(0,0,Ad,Ad,Ad,0),Ce(Ad,Ad,0,0,0,Ad),{vertices:ge,indices:pe}}(this.tileID.canonical,x);D=z.vertices,F=z.indices}else{D=new i.b1,F=new i.b0;for(const{x:V,y:X}of A)D.emplaceBack(V,X,0,0);const z=i.bh(D.int16.subarray(0,4*D.length),void 0,4);for(let V=0;V0&&(X=i.bl(new Float64Array(16),x.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(h,D,x,z,X,V),this._makeGlobeTileDebugTextBuffer(h,D,x,z,X,V)}_globePoint(h,x,A,D,F,z,V){let X=i.bm(h,x,A);if(z){const ne=1<.5?xe=-1:pe<-.5&&(xe=1);let Pe=(h/i.al+A.x)/ne+xe,Ce=(x/i.al+A.y)/ne;Pe=(Pe-oe)*D._pixelsPerMercatorPixel+oe,Ce=(Ce-ge)*D._pixelsPerMercatorPixel+ge;const Ve=[Pe*D.worldSize,Ce*D.worldSize,0];i.af(Ve,Ve,z),X=i.bn(X,Ve,V)}return i.af(X,X,F)}_makeGlobeTileDebugBorderBuffer(h,x,A,D,F,z){const V=new i.bd,X=new i.be,ne=new i.bo,oe=(pe,xe,Pe,Ce,Ve)=>{const Be=(Pe-pe)/(Ve-1),tt=(Ce-xe)/(Ve-1),dt=V.length;for(let st=0;stge*xe+Pe;for(let xe=0;xe{if(F)x(F);else try{const X=A.getHeaderLength(z);if(X>h)return void(this.request=this.fetchHeader(X,x));A.parseHeader(z),this._isHeaderLoaded=!0;let ne=0;for(const oe of Object.values(A.layers))ne=Math.max(ne,oe.dataIndex[oe.dataIndex.length-1].lastByte);z.byteLength>=ne&&(this.entireBuffer=z),x(null,this.entireBuffer||z,V)}catch(X){x(X)}}),this.request}fetchBandForRender(h,x,A,D){this.fetchBand(h,x,A,F=>{if(F)return void D(F);this.updateTextureDescriptor(h,x,A);const z=this.textureDescriptorPerLayer.get(x);D(null,z?z.img:null)})}fetchBand(h,x,A,D,F=!0){const z=this._mrt;if(!this._isHeaderLoaded||!z)return void D(new Error("Tile header is not ready"));const V=this.actor;if(!V)return void D(new Error("Can't fetch tile band without an actor"));let X;const ne=i.B(String(A),i.B(this.tileID.key,h));let oe=this._taskQueue.get(ne);oe?oe.add(D):(oe=new Set,oe.add(D),this._taskQueue.set(ne,oe));const ge=(Ce,Ve)=>{X.complete(Ce,Ve),Ce?D(Ce):(oe.forEach(Be=>Be(null,Ve)),this._taskQueue.delete(ne))},pe=(Ce,Ve)=>{if(Ce)return D(Ce);const Be=V.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:Ve,task:X},ge,void 0,!0);if(x!==null){const tt=this._workQueuePerLayer.get(x)||[];tt.push(()=>{Be&&Be.cancel(),X.cancel()}),this._workQueuePerLayer.has(x)||this._workQueuePerLayer.set(x,tt)}};let xe;try{xe=z.getLayer(h)}catch(Ce){if(this.state==="reloading")return;throw Ce}if(!xe)return void D(new Error(`Unknown sourceLayer "${h}"`));if(xe.hasDataForBand(A))return oe.forEach(Ce=>Ce(null,null)),void this._taskQueue.delete(ne);const Pe=xe.getDataRange([A]);if(X=z.createDecodingTask(Pe),!X||X.tasks.length)if(x!==null&&this.flushQueues(x),this.entireBuffer)pe(null,this.entireBuffer.slice(Pe.firstByte,Pe.lastByte+1));else{const Ce=Object.assign({},this.requestParams,{headers:{Range:`bytes=${Pe.firstByte}-${Pe.lastByte}`}}),Ve=i.bu(Ce,pe);if(x!==null){const Be=this._fetchQueuePerLayer.get(x)||[];Be.push(()=>{Ve.cancel(),X.cancel()}),this._fetchQueuePerLayer.has(x)||this._fetchQueuePerLayer.set(x,Be)}}}updateNeeded(h,x){return(!this.textureDescriptorPerLayer.get(h)||this.textureDescriptorPerLayer.get(h).band!==x||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(h,x,A){if(!this._mrt)return;const D=this._mrt.getLayer(h);if(!D||!D.hasBand(A)||!D.hasDataForBand(A))return;const{bytes:F,tileSize:z,buffer:V,offset:X,scale:ne}=D.getBandView(A),oe=z+2*V,ge=new i.q({width:oe,height:oe},F),pe=this.texturePerLayer.get(x);pe&&pe instanceof i.T&&pe.update(ge,{premultiply:!1}),this.textureDescriptorPerLayer.set(x,{layer:h,band:A,img:ge,buffer:V,offset:X,tileSize:z,format:D.pixelFormat,mix:[ne,256*ne,65536*ne,16777216*ne]})}destroy(h=!1){if(super.destroy(h),delete this._mrt,!h)for(const x of this.texturePerLayer.values())x&&x instanceof i.T&&x.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1}}class ky{constructor(h,x){this.max=h,this.onRemove=x,this.reset()}reset(){for(const h in this.data)for(const x of this.data[h])x.timeout&&clearTimeout(x.timeout),this.onRemove(x.value);return this.data={},this.order=[],this}add(h,x,A){const D=h.wrapped().key;this.data[D]===void 0&&(this.data[D]=[]);const F={value:x,timeout:void 0};if(A!==void 0&&(F.timeout=setTimeout(()=>{this.remove(h,F)},A)),this.data[D].push(F),this.order.push(D),this.order.length>this.max){const z=this._getAndRemoveByKey(this.order[0]);z&&this.onRemove(z)}return this}has(h){return h.wrapped().key in this.data}getAndRemove(h){return this.has(h)?this._getAndRemoveByKey(h.wrapped().key):null}_getAndRemoveByKey(h){const x=this.data[h].shift();return x.timeout&&clearTimeout(x.timeout),this.data[h].length===0&&delete this.data[h],this.order.splice(this.order.indexOf(h),1),x.value}getByKey(h){const x=this.data[h];return x?x[0].value:null}get(h){return this.has(h)?this.data[h.wrapped().key][0].value:null}remove(h,x){if(!this.has(h))return this;const A=h.wrapped().key,D=x===void 0?0:this.data[A].indexOf(x),F=this.data[A][D];return this.data[A].splice(D,1),F.timeout&&clearTimeout(F.timeout),this.data[A].length===0&&delete this.data[A],this.onRemove(F.value),this.order.splice(this.order.indexOf(A),1),this}setMaxSize(h){for(this.max=h;this.order.length>this.max;){const x=this._getAndRemoveByKey(this.order[0]);x&&this.onRemove(x)}return this}filter(h){const x=[];for(const A in this.data)for(const D of this.data[A])h(D.value)||x.push(D);for(const A of x)this.remove(A.value.tileID,A)}}class $f{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(h,x,A){const D=String(x);if(this.stateChanges[h]=this.stateChanges[h]||{},this.stateChanges[h][D]=this.stateChanges[h][D]||{},Object.assign(this.stateChanges[h][D],A),this.deletedStates[h]===null){this.deletedStates[h]={};for(const F in this.state[h])F!==D&&(this.deletedStates[h][F]=null)}else if(this.deletedStates[h]&&this.deletedStates[h][D]===null){this.deletedStates[h][D]={};for(const F in this.state[h][D])A[F]||(this.deletedStates[h][D][F]=null)}else for(const F in A)this.deletedStates[h]&&this.deletedStates[h][D]&&this.deletedStates[h][D][F]===null&&delete this.deletedStates[h][D][F]}removeFeatureState(h,x,A){if(this.deletedStates[h]===null)return;const D=String(x);if(this.deletedStates[h]=this.deletedStates[h]||{},A&&x!==void 0)this.deletedStates[h][D]!==null&&(this.deletedStates[h][D]=this.deletedStates[h][D]||{},this.deletedStates[h][D][A]=null);else if(x!==void 0)if(this.stateChanges[h]&&this.stateChanges[h][D])for(A in this.deletedStates[h][D]={},this.stateChanges[h][D])this.deletedStates[h][D][A]=null;else this.deletedStates[h][D]=null;else this.deletedStates[h]=null}getState(h,x){const A=this.state[h]||{},D=this.stateChanges[h]||{},F=this.deletedStates[h];if(F===null)return{};if(x!==void 0){const V=String(x),X=Object.assign({},A[V],D[V]);if(F){const ne=F[x];if(ne===null)return{};for(const oe in ne)delete X[oe]}return X}const z=Object.assign({},A,D);if(F)for(const V in F)delete z[V];return z}initializeTileState(h,x){h.refreshFeatureState(x)}coalesceChanges(h,x){const A={};for(const D in this.stateChanges){this.state[D]=this.state[D]||{};const F={};for(const z in this.stateChanges[D])this.state[D][z]||(this.state[D][z]={}),Object.assign(this.state[D][z],this.stateChanges[D][z]),F[z]=this.state[D][z];A[D]=F}for(const D in this.deletedStates){this.state[D]=this.state[D]||{};const F={};if(this.deletedStates[D]===null)for(const z in this.state[D])F[z]={},this.state[D][z]={};else for(const z in this.deletedStates[D]){if(this.deletedStates[D][z]===null)this.state[D][z]={};else if(this.state[D][z])for(const V of Object.keys(this.deletedStates[D][z]))delete this.state[D][z][V];F[z]=this.state[D][z]}A[D]=A[D]||{},Object.assign(A[D],F)}if(this.stateChanges={},this.deletedStates={},Object.keys(A).length!==0)for(const D in h)h[D].refreshFeatureState(x)}}class hl extends i.E{constructor(h,x,A){super(),this.id=h,this._onlySymbols=A,x.on("data",D=>{D.dataType==="source"&&D.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&D.dataType==="source"&&D.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),x.on("error",()=>{this._sourceErrored=!0}),this._source=x,this._tiles={},this._cache=new ky(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=x.minTileCacheSize,this._maxTileCacheSize=x.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new $f,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="raster-array"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(h){this.map=h,this._minTileCacheSize=this._minTileCacheSize===void 0&&h?h._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&h?h._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const h in this._tiles)if(!this._tiles[h].loaded())return!1;return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const h=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,h&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(h,x){return h.isSymbolTile=this._onlySymbols,h.isExtraShadowCaster=this._shadowCasterTiles[h.tileID.key],this._source.loadTile(h,x)}_unloadTile(h){if(this._source.unloadTile)return this._source.unloadTile(h)}_abortTile(h){if(this._source.abortTile)return this._source.abortTile(h)}serialize(){return this._source.serialize()}prepare(h){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const x in this._tiles){const A=this._tiles[x];A.upload(h,this.map?this.map.painter:void 0),A.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(h=>h.tileID).sort(xv).map(h=>h.key)}getRenderableIds(h,x){const A=[];for(const D in this._tiles)this._isIdRenderable(+D,h,x)&&A.push(this._tiles[D]);return h?A.sort((D,F)=>{const z=D.tileID,V=F.tileID,X=new i.P(z.canonical.x,z.canonical.y)._rotate(this.transform.angle),ne=new i.P(V.canonical.x,V.canonical.y)._rotate(this.transform.angle);return z.overscaledZ-V.overscaledZ||ne.y-X.y||ne.x-X.x}).map(D=>D.tileID.key):A.map(D=>D.tileID).sort(xv).map(D=>D.key)}hasRenderableParent(h){const x=this.findLoadedParent(h,0);return!!x&&this._isIdRenderable(x.tileID.key)}_isIdRenderable(h,x,A){return this._tiles[h]&&this._tiles[h].hasData()&&!this._coveredTiles[h]&&(x||!this._tiles[h].holdingForFade())&&(A||!this._shadowCasterTiles[h])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const h in this._tiles)this._tiles[h].state!=="errored"&&this._reloadTile(+h,"reloading")}}_reloadTile(h,x){const A=this._tiles[h];A&&(A.state!=="loading"&&(A.state=x),this._loadTile(A,this._tileLoaded.bind(this,A,h,x)))}_tileLoaded(h,x,A,D,F){if(D){if(h.state="errored",D.status!==404)this._source.fire(new i.y(D,{tile:h}));else{if(this._source.fire(new i.z("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:h})),!(h.tileID.key in this._loadedParentTiles))return;if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const V=this.map.painter.terrain;this.update(this.transform,V.getScaledDemTileSize(),!0),V.resetTileLookupCache(this.id)}else this.update(this.transform)}return}h.timeAdded=i.o.now(),A==="expired"&&(h.refreshedUponExpiration=!0),this._setTileReloadTimer(x,h),this._source.type==="raster-dem"&&h.dem&&this._backfillDEM(h),this._state.initializeTileState(h,this.map?this.map.painter:null);let z=new Map;F&&F.responseHeaders&&(z=F.responseHeaders),this._source.fire(new i.z("data",{dataType:"source",tile:h,coord:h.tileID,sourceCacheId:this.id,responseHeaders:z}))}_backfillDEM(h){const x=this.getRenderableIds();for(let D=0;D1||(Math.abs(z)>1&&(Math.abs(z+X)===1?z+=X:Math.abs(z-X)===1&&(z-=X)),F.dem&&D.dem&&(D.dem.backfillBorder(F.dem,z,V),D.neighboringTiles&&D.neighboringTiles[ne]&&(D.neighboringTiles[ne].backfilled=!0)))}}getTile(h){return this.getTileByID(h.key)}getTileByID(h){return this._tiles[h]}_retainLoadedChildren(h,x,A,D){for(const F in this._tiles){let z=this._tiles[F];if(D[F]||!z.hasData()||z.tileID.overscaledZ<=x||z.tileID.overscaledZ>A)continue;let V=z.tileID;for(;z&&z.tileID.overscaledZ>x+1;){const ne=z.tileID.scaledTo(z.tileID.overscaledZ-1);z=this._tiles[ne.key],z&&z.hasData()&&(V=ne)}let X=V;for(;X.overscaledZ>x;)if(X=X.scaledTo(X.overscaledZ-1),h[X.key]){D[V.key]=V;break}}}findLoadedParent(h,x){if(h.key in this._loadedParentTiles){const A=this._loadedParentTiles[h.key];return A&&A.tileID.overscaledZ>=x?A:null}for(let A=h.overscaledZ-1;A>=x;A--){const D=h.scaledTo(A),F=this._getLoadedTile(D);if(F)return F}}_getLoadedTile(h){const x=this._tiles[h.key];return x&&x.hasData()?x:this._cache.getByKey(this._source.reparseOverscaled?h.wrapped().key:h.canonical.key)}updateCacheSize(h,x){x=x||this._source.tileSize;const A=Math.ceil(h.width/x)+1,D=Math.ceil(h.height/x)+1,F=Math.floor(A*D*5),z=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,F):F,V=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,z):z;this._cache.setMaxSize(V)}handleWrapJump(h){const x=Math.round((h-(this._prevLng===void 0?h:this._prevLng))/360);if(this._prevLng=h,x){const A={};for(const D in this._tiles){const F=this._tiles[D];F.tileID=F.tileID.unwrapTo(F.tileID.wrap+x),A[F.tileID.key]=F}this._tiles=A;for(const D in this._timers)clearTimeout(this._timers[D]),delete this._timers[D];for(const D in this._tiles)this._setTileReloadTimer(+D,this._tiles[D])}}update(h,x,A,D,F){if(this.transform=h,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!A)return;this.updateCacheSize(h,x),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const z=this._source.type==="batched-model";let V,X=this._source.maxzoom;const ne=this.map&&this.map.painter?this.map.painter._terrain:null;if(ne&&ne.sourceCache===this&&ne.attenuationRange()){const pe=ne.attenuationRange()[0],xe=Math.floor(pe)-Math.log2(ne.getDemUpscale());X>xe&&(X=xe)}if(this.used||this.usedForTerrain){if(this._source.tileID)V=h.getVisibleUnwrappedCoordinates(this._source.tileID).map(pe=>new i.aQ(pe.canonical.z,pe.wrap,pe.canonical.z,pe.canonical.x,pe.canonical.y));else if(this.tileCoverLift!==0){const pe=h.clone();pe.tileCoverLift=this.tileCoverLift,V=pe.coveringTiles({tileSize:x||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:X,roundZoom:this._source.roundZoom&&!A,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.minzoom<=1&&h.projection.name==="globe"&&(V.push(new i.aQ(1,0,1,0,0)),V.push(new i.aQ(1,0,1,1,0)),V.push(new i.aQ(1,0,1,0,1)),V.push(new i.aQ(1,0,1,1,1)))}else if(V=h.coveringTiles({tileSize:x||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:X,roundZoom:this._source.roundZoom&&!A,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.hasTile){const pe=this._source.hasTile.bind(this._source);V=V.filter(xe=>pe(xe))}}else V=[];if(V.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!qf(this._source.type)){const pe=h.coveringZoomLevel({tileSize:x||this._source.tileSize,roundZoom:this._source.roundZoom&&!A}),xe=Math.min(pe,this._source.maxzoom);if(z){const Pe=h.extendTileCover(V,xe);for(const Ce of Pe)V.push(Ce)}else if(F){const Pe=h.extendTileCoverToNearPlane(V,this.transform.getFrustum(xe),xe);for(const Ce of Pe)V.push(Ce)}else if(this.castsShadows&&D){const Pe=h.extendTileCover(V,xe,D,16);for(const Ce of Pe)this._shadowCasterTiles[Ce.key]=!0,V.push(Ce)}}const oe=this._updateRetainedTiles(V);if(qf(this._source.type)&&V.length!==0){const pe={},xe={},Pe=Object.keys(oe);for(const Ve of Pe){const Be=oe[Ve],tt=this._tiles[Ve];if(!tt||tt.fadeEndTime&&tt.fadeEndTime<=i.o.now())continue;const dt=this.findLoadedParent(Be,Math.max(Be.overscaledZ-hl.maxOverzooming,this._source.minzoom));dt&&(this._addTile(dt.tileID),pe[dt.tileID.key]=dt.tileID),xe[Ve]=Be}const Ce=V[V.length-1].overscaledZ;for(const Ve in this._tiles){const Be=this._tiles[Ve];if(oe[Ve]||!Be.hasData())continue;let tt=Be.tileID;for(;tt.overscaledZ>Ce;){tt=tt.scaledTo(tt.overscaledZ-1);const dt=this._tiles[tt.key];if(dt&&dt.hasData()&&xe[tt.key]){oe[Ve]=Be.tileID;break}}}for(const Ve in pe)oe[Ve]||(this._coveredTiles[Ve]=!0,oe[Ve]=pe[Ve])}for(const pe in oe)this._tiles[pe].clearFadeHold();const ge=i.bv(this._tiles,oe);for(const pe of ge){const xe=this._tiles[pe];xe.hasSymbolBuckets&&!xe.holdingForFade()?xe.setHoldDuration(this.map._fadeDuration):xe.hasSymbolBuckets&&!xe.symbolFadeFinished()||this._removeTile(+pe)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const h in this._tiles)this._tiles[h].holdingForFade()&&this._removeTile(+h)}_updateRetainedTiles(h){const x={};if(h.length===0)return x;const A={},D=h.reduce((ne,oe)=>Math.min(ne,oe.overscaledZ),1/0),F=h[0].overscaledZ,z=Math.max(F-hl.maxOverzooming,this._source.minzoom),V=Math.max(F+hl.maxUnderzooming,this._source.minzoom),X={};for(const ne of h){const oe=this._addTile(ne);x[ne.key]=ne,oe.hasData()||D=this._source.maxzoom){const pe=ne.children(this._source.maxzoom)[0],xe=this.getTile(pe);if(xe&&xe.hasData()){x[pe.key]=pe;continue}}else{const pe=ne.children(this._source.maxzoom);if(x[pe[0].key]&&x[pe[1].key]&&x[pe[2].key]&&x[pe[3].key])continue}let ge=oe.wasRequested();for(let pe=ne.overscaledZ-1;pe>=z;--pe){const xe=ne.scaledTo(pe);if(A[xe.key]||(A[xe.key]=!0,oe=this.getTile(xe),!oe&&ge&&(oe=this._addTile(xe)),oe&&(x[xe.key]=xe,ge=oe.wasRequested(),oe.hasData())))break}}return x}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const h in this._tiles){const x=[];let A,D=this._tiles[h].tileID;for(;D.overscaledZ>0;){if(D.key in this._loadedParentTiles){A=this._loadedParentTiles[D.key];break}x.push(D.key);const F=D.scaledTo(D.overscaledZ-1);if(A=this._getLoadedTile(F),A)break;D=F}for(const F of x)this._loadedParentTiles[F]=A}}_addTile(h){let x=this._tiles[h.key];if(x)return x.isExtraShadowCaster!==!0||this._shadowCasterTiles[h.key]||this._reloadTile(h.key,"reloading"),x;x=this._cache.getAndRemove(h),x&&(this._setTileReloadTimer(h.key,x),x.tileID=h,this._state.initializeTileState(x,this.map?this.map.painter:null),this._cacheTimers[h.key]&&(clearTimeout(this._cacheTimers[h.key]),delete this._cacheTimers[h.key],this._setTileReloadTimer(h.key,x)));const A=!!x;if(!A){const D=this.map?this.map.painter:null,F=this._source.tileSize*h.overscaleFactor();x=this._source.type==="raster-array"?new Jc(h,F,this.transform.tileZoom,D,this._isRaster):new nm(h,F,this.transform.tileZoom,D,this._isRaster,this._source.worldview),this._loadTile(x,this._tileLoaded.bind(this,x,h.key,x.state))}return x.uses++,this._tiles[h.key]=x,A||this._source.fire(new i.z("dataloading",{tile:x,coord:x.tileID,dataType:"source"})),x}_setTileReloadTimer(h,x){h in this._timers&&(clearTimeout(this._timers[h]),delete this._timers[h]);const A=x.getExpiryTimeout();A&&(this._timers[h]=setTimeout(()=>{this._reloadTile(h,"expired"),delete this._timers[h]},A))}_removeTile(h){const x=this._tiles[h];x&&(x.uses--,delete this._tiles[h],this._timers[h]&&(clearTimeout(this._timers[h]),delete this._timers[h]),x.uses>0||(x.hasData()&&x.state!=="reloading"||x.state==="empty"?this._cache.add(x.tileID,x,x.getExpiryTimeout()):(x.aborted=!0,this._abortTile(x),this._unloadTile(x))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const h in this._tiles)this._removeTile(+h);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(h,x,A){const D=[],F=this.transform;if(!F)return D;const z=F.projection.name==="globe",V=i.aF(F.center.lng);for(const X in this._tiles){const ne=this._tiles[X];if(A&&ne.clearQueryDebugViz(),ne.holdingForFade())continue;let oe;if(z){const ge=ne.tileID.canonical;if(ge.z===0){const pe=[Math.abs(i.aA(V,...Vu(ge,-1))-V),Math.abs(i.aA(V,...Vu(ge,1))-V)];oe=[0,2*pe.indexOf(Math.min(...pe))-1]}else{const pe=[Math.abs(i.aA(V,...Vu(ge,-1))-V),Math.abs(i.aA(V,...Vu(ge,0))-V),Math.abs(i.aA(V,...Vu(ge,1))-V)];oe=[pe.indexOf(Math.min(...pe))-1]}}else oe=[0];for(const ge of oe){const pe=h.containsTile(ne,F,x,ge);pe&&D.push(pe)}}return D}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(h){return this._getRenderableCoordinates(h)}_getRenderableCoordinates(h,x){const A=this.getRenderableIds(h,x).map(F=>this._tiles[F].tileID),D=this.transform.projection.name==="globe";for(const F of A)F.projMatrix=this.transform.calculateProjMatrix(F.toUnwrapped()),F.expandedProjMatrix=D?this.transform.calculateProjMatrix(F.toUnwrapped(),!1,!0):F.projMatrix;return A}sortCoordinatesByDistance(h){const x=h.slice(),A=this.transform._camera.position,D=this.transform._camera.forward(),F={};for(const z of x){const V=1/(1<F[z.key]-F[V.key]),x}hasTransition(){if(this._source.hasTransition())return!0;if(qf(this._source.type))for(const h in this._tiles){const x=this._tiles[h];if(x.fadeEndTime!==void 0&&x.fadeEndTime>=i.o.now())return!0}return!1}setFeatureState(h,x,A){this._state.updateState(h=h||"_geojsonTileLayer",x,A)}removeFeatureState(h,x,A){this._state.removeFeatureState(h=h||"_geojsonTileLayer",x,A)}getFeatureState(h,x){return this._state.getState(h=h||"_geojsonTileLayer",x)}setDependencies(h,x,A){const D=this._tiles[h];D&&D.setDependencies(x,A)}reloadTilesForDependencies(h,x){for(const A in this._tiles)this._tiles[A].hasDependency(h,x)&&this._reloadTile(+A,"reloading");this._cache.filter(A=>!A.hasDependency(h,x))}_preloadTiles(h,x){if(!this._sourceLoaded){const X=()=>{this._sourceLoaded&&(this._source.off("data",X),this._preloadTiles(h,x))};return void this._source.on("data",X)}const A=new Map,D=Array.isArray(h)?h:[h],F=this.map.painter.terrain,z=this.usedForTerrain&&F?F.getScaledDemTileSize():this._source.tileSize;for(const X of D){const ne=X.coveringTiles({tileSize:z,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const oe of ne)A.set(oe.key,oe);this.usedForTerrain&&X.updateElevation(!1)}const V=Array.from(A.values());i.bw(V,(X,ne)=>{const oe=new nm(X,this._source.tileSize*X.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(oe,ge=>{this._source.type==="raster-dem"&&oe.dem&&this._backfillDEM(oe),ne(ge,oe)})},x)}}function xv(M,h){const x=Math.abs(2*M.wrap)-+(M.wrap<0),A=Math.abs(2*h.wrap)-+(h.wrap<0);return M.overscaledZ-h.overscaledZ||A-x||h.canonical.y-M.canonical.y||h.canonical.x-M.canonical.x}function qf(M){return M==="raster"||M==="image"||M==="video"||M==="custom"}function Vu(M,h){const x=1<0:A.type==="building"?D=!A.isHidden(h)&&A.paint.get("building-opacity")>0:A.type==="model"&&(D=!A.isHidden(h)&&A.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!D&&x.visible,x.visible=D}}updateZOffset(h,x){this.currentBuildingBuckets=[];for(const D of this.layers){const F=D.layer,z=this.style.getLayerSourceCache(F);let V=1;F.type==="fill-extrusion"?V=D.visible?F.paint.get("fill-extrusion-vertical-scale"):0:F.type==="building"&&(V=D.visible?F.paint.get("building-vertical-scale"):0);let X=z?z.getTile(x):null;if(!X&&z)for(const ne in z._tiles){const oe=z._tiles[ne];if(x.canonical.isChildOf(oe.tileID.canonical)){X=oe;break}}this.currentBuildingBuckets.push({bucket:X?X.getBucket(F):null,tileID:X?X.tileID:x,verticalScale:V})}h.hasAnyZOffset=!1;let A=!1;for(let D=0;D{A in h&&(x[A]=h[A])}),x}function Sy(M){M=M.slice();const h=Object.create(null);for(let x=0;x0?(D-z)/V:0;return this.points[F].mult(1-X).add(this.points[x].mult(X))}}class ub{constructor(h,x,A){const D=this.boxCells=[],F=this.circleCells=[];this.xCellCount=Math.ceil(h/A),this.yCellCount=Math.ceil(x/A);for(let z=0;zthis.width||D<0||x>this.height)return!F&&[];const V=[];if(h<=0&&x<=0&&this.width<=A&&this.height<=D){if(F)return!0;for(let X=0;X0:V}_queryCircle(h,x,A,D,F){const z=h-A,V=h+A,X=x-A,ne=x+A;if(V<0||z>this.width||ne<0||X>this.height)return!D&&[];const oe=[];return this._forEachCell(z,X,V,ne,this._queryCellCircle,oe,{hitTest:D,circle:{x:h,y:x,radius:A},seenUids:{box:{},circle:{}}},F),D?oe.length>0:oe}query(h,x,A,D,F){return this._query(h,x,A,D,!1,F)}hitTest(h,x,A,D,F){return this._query(h,x,A,D,!0,F)}hitTestCircle(h,x,A,D){return this._queryCircle(h,x,A,!0,D)}_queryCell(h,x,A,D,F,z,V,X){const ne=V.seenUids,oe=this.boxCells[F];if(oe!==null){const pe=this.bboxes;for(const xe of oe)if(!ne.box[xe]){ne.box[xe]=!0;const Pe=4*xe;if(h<=pe[Pe+2]&&x<=pe[Pe+3]&&A>=pe[Pe+0]&&D>=pe[Pe+1]&&(!X||X(this.boxKeys[xe]))){if(V.hitTest)return z.push(!0),!0;z.push({key:this.boxKeys[xe],x1:pe[Pe],y1:pe[Pe+1],x2:pe[Pe+2],y2:pe[Pe+3]})}}}const ge=this.circleCells[F];if(ge!==null){const pe=this.circles;for(const xe of ge)if(!ne.circle[xe]){ne.circle[xe]=!0;const Pe=3*xe;if(this._circleAndRectCollide(pe[Pe],pe[Pe+1],pe[Pe+2],h,x,A,D)&&(!X||X(this.circleKeys[xe]))){if(V.hitTest)return z.push(!0),!0;{const Ce=pe[Pe],Ve=pe[Pe+1],Be=pe[Pe+2];z.push({key:this.circleKeys[xe],x1:Ce-Be,y1:Ve-Be,x2:Ce+Be,y2:Ve+Be})}}}}}_queryCellCircle(h,x,A,D,F,z,V,X){const ne=V.circle,oe=V.seenUids,ge=this.boxCells[F];if(ge!==null){const xe=this.bboxes;for(const Pe of ge)if(!oe.box[Pe]){oe.box[Pe]=!0;const Ce=4*Pe;if(this._circleAndRectCollide(ne.x,ne.y,ne.radius,xe[Ce+0],xe[Ce+1],xe[Ce+2],xe[Ce+3])&&(!X||X(this.boxKeys[Pe])))return z.push(!0),!0}}const pe=this.circleCells[F];if(pe!==null){const xe=this.circles;for(const Pe of pe)if(!oe.circle[Pe]){oe.circle[Pe]=!0;const Ce=3*Pe;if(this._circlesCollide(xe[Ce],xe[Ce+1],xe[Ce+2],ne.x,ne.y,ne.radius)&&(!X||X(this.circleKeys[Pe])))return z.push(!0),!0}}}_forEachCell(h,x,A,D,F,z,V,X){const ne=this._convertToXCellCoord(h),oe=this._convertToYCellCoord(x),ge=this._convertToXCellCoord(A),pe=this._convertToYCellCoord(D);for(let xe=ne;xe<=ge;xe++)for(let Pe=oe;Pe<=pe;Pe++)if(F.call(this,h,x,A,D,this.xCellCount*Pe+xe,z,V,X))return}_convertToXCellCoord(h){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(h*this.xScale)))}_convertToYCellCoord(h){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(h*this.yScale)))}_circlesCollide(h,x,A,D,F,z){const V=D-h,X=F-x,ne=A+z;return ne*ne>V*V+X*X}_circleAndRectCollide(h,x,A,D,F,z,V){const X=(z-D)/2,ne=Math.abs(h-(D+X));if(ne>X+A)return!1;const oe=(V-F)/2,ge=Math.abs(x-(F+oe));if(ge>oe+A)return!1;if(ne<=X||ge<=oe)return!0;const pe=ne-X,xe=ge-oe;return pe*pe+xe*xe<=A*A}}const xt={unknown:0,flipRequired:1,flipNotRequired:2},Cs=Math.tan(85*Math.PI/180);function Ks(M,h,x,A,D,F,z){const V=i.bC();if(x)if(F.name==="globe"){const X=i.bD(D,h);i.aB(V,V,X)}else{const X=i.bE([],z);V[0]=X[0],V[1]=X[1],V[4]=X[2],V[5]=X[3],A||i.bB(V,V,D.angle)}else i.aB(V,D.labelPlaneMatrix,M);return V}function ln(M,h,x,A,D,F,z){const V=Ks(M,h,x,A,D,F,z);return F.name==="globe"&&x||(V[2]=V[6]=V[10]=V[14]=0),V}function cn(M,h,x,A,D,F,z){if(x){if(F.name==="globe"){const V=Ks(M,h,x,A,D,F,z);return i.bl(V,V),i.aB(V,M,V),V}{const V=i.bz(M),X=i.bA([]);return X[0]=z[0],X[1]=z[1],X[4]=z[2],X[5]=z[3],i.aB(V,V,X),A||i.bB(V,V,-D.angle),V}}return D.glCoordMatrix}function ta(M,h,x,A){const D=[M,h,x,1];x?i.aC(D,D,A):Rr(D,D,A);const F=D[3];return D[0]/=F,D[1]/=F,D[2]/=F,D}function Fr(M,h){return Math.min(.5+M/h*.5,1.5)}function eo(M,h){const x=M[0]/M[3],A=M[1]/M[3];return x>=-h[0]&&x<=h[0]&&A>=-h[1]&&A<=h[1]}function Uf(M,h,x,A,D,F,z,V,X,ne,oe=1){const ge=x.transform,pe=A?M.textSizeData:M.iconSizeData,xe=i.bK(pe,x.transform.zoom,oe),Pe=ge.projection.name==="globe",Ce=[256/x.width*2+1,256/x.height*2+1],Ve=A?M.text.dynamicLayoutVertexArray:M.icon.dynamicLayoutVertexArray;Ve.clear();let Be=null;Pe&&(Be=A?M.text.globeExtVertexArray:M.icon.globeExtVertexArray);const tt=M.lineVertexArray,dt=A?M.text.placedSymbolArray:M.icon.placedSymbolArray,st=x.transform.width/x.transform.height;let Mt,yt=!1;for(let jt=0;jtMath.abs(x)?{useVertical:!0}:M===i.bL.vertical?A>0?{needsFlipping:!0}:null:h!==xt.unknown&&function(D,F){return D===0||Math.abs(F/D)>Cs}(x,A)?h===xt.flipRequired?{needsFlipping:!0}:null:x<0?{needsFlipping:!0}:null}function Ty(M,h,x,A,D,F,z,V,X,ne,oe,ge,pe,xe,Pe,Ce,Ve,Be,tt,dt){const st=h/24,Mt=M.lineOffsetX*st,yt=M.lineOffsetY*st,{lineStartIndex:jt,glyphStartIndex:gt,numGlyphs:mt,segment:Et,writingMode:Ht,flipState:Ut}=M,ts=jt+M.lineLength,ns=fs=>{if(oe){const[ds,Jt,Es]=fs.up,Js=ne.length;i.bN(oe,Js+0,ds,Jt,Es),i.bN(oe,Js+1,ds,Jt,Es),i.bN(oe,Js+2,ds,Jt,Es),i.bN(oe,Js+3,ds,Jt,Es)}const[Bs,Yt,zt]=fs.point;i.bO(ne,Bs,Yt,zt,fs.angle)};if(mt>1){const fs=Hm(st,V,Mt,yt,x,ge,pe,M,X,F,xe,Ce,!1,Ve,Be,tt,dt);if(!fs)return{notEnoughRoom:!0};if(A&&!x){let[Bs,Yt,zt]=fs.first.point,[ds,Jt,Es]=fs.last.point;[Bs,Yt]=ta(Bs,Yt,zt,z),[ds,Jt]=ta(ds,Jt,Es,z);const Js=Hr(Ht,Ut,(ds-Bs)*Pe,Jt-Yt);if(M.flipState=Js&&Js.needsFlipping?xt.flipRequired:xt.flipNotRequired,Js)return Js}ns(fs.first);for(let Bs=gt+1;Bs0?ds:im(pe,zt,Bs,1,D,void 0,Ve,Be.canonical),Es=Hr(Ht,Ut,(Jt[0]-Bs[0])*Pe,Jt[1]-Bs[1]);if(M.flipState=Es&&Es.needsFlipping?xt.flipRequired:xt.flipNotRequired,Es)return Es}const fs=vv(st*V.getoffsetX(gt),Mt,yt,x,ge,pe,Et,jt,ts,X,F,xe,Ce,!1,!1,Ve,Be,tt,dt);if(!fs)return{notEnoughRoom:!0};ns(fs)}return{}}function Ay(M,h,x,A,D){const{x:F,y:z,z:V}=A.projectTilePoint(M.x,M.y,h);if(!D)return ta(F,z,V,x);const[X,ne,oe]=D.getElevation(M,D.elevation,D.elevationFeature);return ta(F+X,z+ne,V+oe,x)}function im(M,h,x,A,D,F,z,V){const X=Ay(M.sub(h)._unit()._add(M),V,D,z,F);return i.av(X,x,X),i.aw(X,X),i.bH(X,x,X,A)}function vv(M,h,x,A,D,F,z,V,X,ne,oe,ge,pe,xe,Pe,Ce,Ve,Be,tt){const dt=A?M-h:M+h;let st=dt>0?1:-1,Mt=0;A&&(st*=-1,Mt=Math.PI),st<0&&(Mt+=Math.PI);let yt=V+z+(st>0?0:1)|0,jt=D,gt=D,mt=0,Et=0;const Ht=Math.abs(dt),Ut=[],ts=[];let ns=F,fs=ns,Bs=i.bF([]);const Yt=()=>im(fs,ns,gt,Ht-mt+1,oe,pe,Ce,Ve.canonical);for(;mt+Et<=Ht;){if(yt+=st,yt=X)return null;if(gt=jt,fs=ns,Ut.push(gt),xe&&ts.push(fs),ns=new i.P(ne.getx(yt),ne.gety(yt)),jt=ge[yt],!jt){const Nr=Ay(ns,Ve.canonical,oe,Ce,pe);jt=Nr[3]>0?ge[yt]=Nr:Yt()}mt+=Et;const Us=i.av([],jt,gt),Cr=i.bG(gt,jt);if(x&&Cr>0&&Et>0&&i.bJ(Bs,Us)/(Et*Cr)0,dt),jt=ne*yt.perspectiveRatio,gt=(A.x1*x+V.x-A.padding)*jt+yt.point.x,mt=(A.y1*x+V.y-A.padding)*jt+yt.point.y,Et=(A.x2*x+V.x+A.padding)*jt+yt.point.x,Ht=(A.y2*x+V.y+A.padding)*jt+yt.point.y,Ut=yt.perspectiveRatio<=.55||yt.occluded;return!this.isInsideGrid(gt,mt,Et,Ht)||!X&&this.grid.hitTest(gt,mt,Et,Ht,ge)||Ut?{box:[],offscreen:!1,occluded:yt.occluded}:{box:[gt,mt,Et,Ht],offscreen:this.isOffscreen(gt,mt,Et,Ht),occluded:!1}}placeCollisionCircles(h,x,A,D,F,z,V,X,ne,oe,ge,pe,xe,Pe,Ce,Ve){const Be=[],tt=this.transform.elevation,dt=h.getProjection(),st=h.elevationType==="road",Mt=!!tt||st,yt=i.bV.getAtTileOffsetFunc(Ve,this.transform.center.lat,this.transform.worldSize,dt),jt=new i.P(A.tileAnchorX,A.tileAnchorY),gt=new i.P(A.tileAnchorX,A.tileAnchorY);let{x:mt,y:Et,z:Ht}=dt.projectTilePoint(gt.x,gt.y,Ve.canonical),Ut=null;if(Mt){const Cr=st?h.getElevationFeatureForText(D):null;Ut={getElevation:yt,elevation:tt,elevationFeature:Cr};const[Nr,cr,xr]=yt(jt,tt,Cr);mt+=Nr,Et+=cr,Ht+=xr}const ts=dt.name==="globe",ns=this.projectAndGetPerspectiveRatio(X,mt,Et,Ht,Ve,ts||!!tt||this.transform.pitch>0,dt),{perspectiveRatio:fs}=ns,Bs=(pe?V/fs:V*fs)/i.bY,Yt=ta(mt,Et,Ht,ne),zt=A.lineOffsetX*Bs,ds=A.lineOffsetY*Bs,Jt=i.an(h.layers[0].layout.get("text-max-angle")),Es=Math.cos(Jt),Js=ns.signedDistanceFromCamera>0?Hm(Bs,z,zt,ds,st&&A.flipState===1,Yt,gt,A,F,ne,{},Mt&&!pe?Ut:null,pe&&Mt,dt,Ve,pe,Es):null;let mr=!1,Ys=!1,Us=!0;if(Js&&!ns.occluded){const Cr=.5*Pe*fs+Ce,Nr=new i.P(-100,-100),cr=new i.P(this.screenRightBoundary,this.screenBottomBoundary),xr=new ox,{first:Vr,last:jn}=Js,pa=Vr.path.length;let Ha=[];for(let vn=pa-1;vn>=1;vn--)Ha.push(Vr.path[vn]);for(let vn=1;vn(Mt&&!ts&&(fi=yt(oivn[3]<=0)&&(Ha=[]));let Fa=[];if(Ha.length>0){let vn=1/0,Xa=-1/0,fi=1/0,oi=-1/0;for(const Oa of Ha)vn=Math.min(vn,Oa[0]),fi=Math.min(fi,Oa[1]),Xa=Math.max(Xa,Oa[0]),oi=Math.max(oi,Oa[1]);Xa>=Nr.x&&vn<=cr.x&&oi>=Nr.y&&fi<=cr.y&&(Fa=[Ha.map(Oa=>new i.P(Oa[0],Oa[1]))],(vncr.x||ficr.y)&&(Fa=i.bW(Fa,Nr.x,Nr.y,cr.x,cr.y)))}for(const vn of Fa){xr.reset(vn,.25*Cr);let Xa=0;Xa=xr.length<=.5*Cr?1:Math.ceil(xr.paddedLength/Er)+1;for(let fi=0;fi0?(i.aC(X,X,h),this.fogState&&F&&V.name!=="globe"&&(ne=function(pe,xe,Pe,Ce,Ve,Be){const tt=Be.calculateFogTileMatrix(Ve),dt=[xe,Pe,Ce];return i.af(dt,dt,tt),fr(pe,i.ag(dt),Be.pitch,Be._fov)}(this.fogState,x,A,D,F.toUnwrapped(),this.transform)>.9)):Rr(X,X,h);const oe=X[3];return{point:new i.P((X[0]/oe+1)/2*this.transform.width+ja,(-X[1]/oe+1)/2*this.transform.height+ja),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(V)/oe*.5,1.5),signedDistanceFromCamera:oe,occluded:z&&X[2]>oe||ne}}isOffscreen(h,x,A,D){return A=this.screenRightBoundary||Dthis.screenBottomBoundary}isInsideGrid(h,x,A,D){return A>=0&&h=0&&xA.collisionGroupID===x}}return this.collisionGroups[h]}}function md(M,h,x,A,D){const{horizontalAlign:F,verticalAlign:z}=i.c1(M),V=-(F-.5)*h,X=-(z-.5)*x,ne=i.c2(M,A);return new i.P(V+ne[0]*D,X+ne[1]*D)}function rl(M,h,x,A,D){const F=new i.P(M,h);return x&&F._rotate(A?D:-D),F}class Hce{constructor(h,x,A,D,F,z){this.transform=h.clone(),this.projection=h.projection.name,this.collisionIndex=new pi(this.transform,F),this.buildingIndex=z,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=x,this.retainedQueryData={},this.collisionGroups=new mb(A),this.collisionCircleArrays={},this.prevPlacement=D,D&&(D.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(h,x,A,D,F=1){const z=A.getBucket(x),V=A.latestFeatureIndex;if(!z||!V||x.fqid!==z.layerIds[0])return;const X=z.layers[0].layout,ne=z.layers[0].paint,oe=A.collisionBoxArray,ge=Math.pow(2,this.transform.zoom-A.tileID.overscaledZ),pe=A.tileSize/i.al,xe=A.tileID.toUnwrapped();this.transform.setProjection(z.projection);const Pe=(Ce=A.tileID,Ve=z.getProjection(),Be=this.transform,Ve.name===this.projection?Be.calculateProjMatrix(Ce.toUnwrapped()):db(Be,Ve,Ce));var Ce,Ve,Be;const tt=X.get("text-pitch-alignment")==="map",dt=X.get("text-rotation-alignment")==="map";x.compileFilter(x.options);const st=x.dynamicFilter(),Mt=x.dynamicFilterNeedsFeature(),yt=this.transform.calculatePixelsToTileUnitsMatrix(A),jt=ln(Pe,A.tileID.canonical,tt,dt,this.transform,z.getProjection(),yt);let gt=null;const mt=z.getProjection().createInversionMatrix(this.transform,A.tileID.canonical);if(tt){const zt=cn(Pe,A.tileID.canonical,tt,dt,this.transform,z.getProjection(),yt);gt=i.aB([],this.transform.labelPlaneMatrix,zt)}let Et=null;st&&A.latestFeatureIndex&&(Et={unwrappedTileID:xe,dynamicFilter:st,dynamicFilterNeedsFeature:Mt}),this.retainedQueryData[z.bucketInstanceId]=new hb(z.bucketInstanceId,V,z.sourceLayerIndex,z.index,A.tileID);const[Ht,Ut]=z.layers[0].layout.get("text-size-scale-range"),ts=i.aA(F,Ht,Ut),[ns,fs]=X.get("icon-size-scale-range"),Bs=i.aA(F,ns,fs),Yt={bucket:z,layout:X,paint:ne,posMatrix:Pe,invMatrix:mt,mercatorCenter:[i.aF(this.transform.center.lng),i.aJ(this.transform.center.lat)],textLabelPlaneMatrix:jt,labelToScreenMatrix:gt,clippingData:Et,scale:ge,textPixelRatio:pe,holdingForFade:A.holdingForFade(),collisionBoxArray:oe,partiallyEvaluatedTextSize:i.bK(z.textSizeData,this.transform.zoom,ts),partiallyEvaluatedIconSize:i.bK(z.iconSizeData,this.transform.zoom,Bs),collisionGroup:this.collisionGroups.get(z.sourceID),latestFeatureIndex:A.latestFeatureIndex};if(D)for(const zt of z.sortKeyRanges){const{sortKey:ds,symbolInstanceStart:Jt,symbolInstanceEnd:Es}=zt;h.push({sortKey:ds,symbolInstanceStart:Jt,symbolInstanceEnd:Es,parameters:Yt})}else h.push({symbolInstanceStart:0,symbolInstanceEnd:z.symbolInstances.length,parameters:Yt})}attemptAnchorPlacement(h,x,A,D,F,z,V,X,ne,oe,ge,pe,xe,Pe,Ce,Ve,Be,tt,dt,st,Mt){const{textOffset0:yt,textOffset1:jt,crossTileID:gt}=Ce,mt=[yt,jt],Et=md(h,z,V,mt,X),Ht=this.collisionIndex.placeCollisionBox(Be,X,x,A,D,F,rl(Et.x,Et.y,ne,oe,this.transform.angle),Pe,ge,pe,xe.predicate);if(dt){const Ut=Be.getSymbolInstanceIconSize(Mt,this.transform.zoom,Ce.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(Be,Ut,dt,A,D,F,rl(Et.x,Et.y,ne,oe,this.transform.angle),Pe,ge,pe,xe.predicate).box.length===0)return}if(Ht.box.length>0){let Ut;return this.prevPlacement&&this.prevPlacement.variableOffsets[gt]&&this.prevPlacement.placements[gt]&&this.prevPlacement.placements[gt].text&&(Ut=this.prevPlacement.variableOffsets[gt].anchor),this.variableOffsets[gt]={textOffset:mt,width:z,height:V,anchor:h,textScale:X,prevAnchor:Ut},this.markUsedJustification(Be,h,Ce,tt),Be.allowVerticalPlacement&&(this.markUsedOrientation(Be,tt,Ce),this.placedOrientations[gt]=tt),{shift:Et,placedGlyphBoxes:Ht}}}placeLayerBucketPart(h,x,A,D,F=1){const{bucket:z,layout:V,paint:X,posMatrix:ne,textLabelPlaneMatrix:oe,labelToScreenMatrix:ge,clippingData:pe,textPixelRatio:xe,mercatorCenter:Pe,invMatrix:Ce,holdingForFade:Ve,collisionBoxArray:Be,partiallyEvaluatedTextSize:tt,partiallyEvaluatedIconSize:dt,collisionGroup:st,latestFeatureIndex:Mt}=h.parameters,yt=V.get("text-optional"),jt=V.get("icon-optional"),gt=V.get("text-allow-overlap"),mt=V.get("icon-allow-overlap"),Et=V.get("text-rotation-alignment")==="map",Ht=V.get("icon-rotation-alignment")==="map",Ut=V.get("text-pitch-alignment")==="map",ts=X.get("symbol-z-offset"),ns=V.get("symbol-elevation-reference")==="sea",fs=V.get("symbol-placement"),[Bs,Yt]=V.get("text-size-scale-range"),[zt,ds]=V.get("icon-size-scale-range"),Jt=i.aA(F,Bs,Yt),Es=i.aA(F,zt,ds),Js=V.get("text-variable-anchor"),mr=Et&&fs!=="point",Ys=Ht&&fs!=="point",Us=Js&&z.hasTextData(),Cr=z.hasIconTextFit()&&Us&&z.hasIconData();this.transform.setProjection(z.projection);const Nr=Us||mr,cr=Ys||Cr;let xr=gt&&(mt||!z.hasIconData()||jt),Vr=mt&&(gt||!z.hasTextData()||yt);const jn=!ts.isConstant();!z.collisionArrays&&Be&&z.deserializeCollisionBoxes(Be),A&&D&&z.updateCollisionDebugBuffers(this.transform.zoom,Be,Jt,Es);const pa=(Er,Fa,vn)=>{const{crossTileID:Xa,numVerticalGlyphVertices:fi}=Er;let oi=null;if(pe&&pe.dynamicFilterNeedsFeature||jn){const jo=this.retainedQueryData[z.bucketInstanceId];oi=Mt.loadFeature({featureIndex:Er.featureIndex,bucketIndex:jo.bucketIndex,sourceLayerIndex:jo.sourceLayerIndex,layoutVertexArrayOffset:0});const Ro=oi.properties?oi.properties.worldview:null;if(z.localizable&&z.worldview&&typeof Ro=="string")if(Ro==="all")oi.properties.$localized=!0;else{if(!Ro.split(",").includes(z.worldview))return;oi.properties.$localized=!0,oi.properties.worldview=z.worldview}}if(pe&&!(0,pe.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:z.worldview},oi,this.retainedQueryData[z.bucketInstanceId].tileID.canonical,new i.P(Er.tileAnchorX,Er.tileAnchorY),this.transform.calculateDistanceTileData(pe.unwrappedTileID)))return this.placements[Xa]=new ri(!1,!1,!1,!0),void x.add(Xa);const Oa=ts.evaluate(oi,{});if(x.has(Xa))return;if(Ve)return void(this.placements[Xa]=new ri(!1,!1,!1));let Rn=!1,Ka=!1,fo=!0,Gi=!1,Qa=!1,Ca=null,Fn={box:null,offscreen:null,occluded:null},qi={box:null},Ao=null,uo=null,ji=null,ru=0,ed=0,jl=0;vn.textFeatureIndex?ru=vn.textFeatureIndex:Er.useRuntimeCollisionCircles&&(ru=Er.featureIndex),vn.verticalTextFeatureIndex&&(ed=vn.verticalTextFeatureIndex);const fd=z.elevationFeatures?z.elevationFeatures[Er.elevationFeatureIndex]:void 0,gd=jo=>{jo.tileID=this.retainedQueryData[z.bucketInstanceId].tileID;const Ro=this.transform.elevation;jo.elevation=ns?Oa:Oa+i.bV.getAtTileOffset(jo.tileID,new i.P(jo.tileAnchorX,jo.tileAnchorY),Ro,fd),jo.elevation+=Er.zOffset},Ic=vn.textBox;if(Ic){gd(Ic);const jo=Ni=>{let Zo=i.bL.horizontal;if(z.allowVerticalPlacement&&!Ni&&this.prevPlacement){const go=this.prevPlacement.placedOrientations[Xa];go&&(this.placedOrientations[Xa]=go,Zo=go,this.markUsedOrientation(z,Zo,Er))}return Zo},Ro=(Ni,Zo)=>{if(z.allowVerticalPlacement&&fi>0&&vn.verticalTextBox){for(const go of z.writingModes)if(go===i.bL.vertical?(Fn=Zo(),qi=Fn):Fn=Ni(),Fn&&Fn.box&&Fn.box.length)break}else Fn=Ni()};if(Js){let Ni=Js;if(this.prevPlacement&&this.prevPlacement.variableOffsets[Xa]){const ho=this.prevPlacement.variableOffsets[Xa];Ni.indexOf(ho.anchor)>0&&(Ni=Ni.filter(pm=>pm!==ho.anchor),Ni.unshift(ho.anchor))}const Zo=(ho,pm,$b)=>{const Qm=z.getSymbolInstanceTextSize(tt,Er,this.transform.zoom,Fa),qb=(ho.x2-ho.x1)*Qm+2*ho.padding,Uv=(ho.y2-ho.y1)*Qm+2*ho.padding,qp=Er.hasIconTextFit&&!mt?pm:null;qp&&gd(qp);let rg={box:[],offscreen:!1,occluded:!1};const Vv=gt?2*Ni.length:Ni.length;for(let jx=0;jx=Ni.length,Er,Fa,z,$b,qp,tt,dt);if(ng&&(rg=ng.placedGlyphBoxes,rg&&rg.box&&rg.box.length)){Rn=!0,Ca=ng.shift;break}}return rg};Ro(()=>Zo(Ic,vn.iconBox,i.bL.horizontal),()=>{const ho=vn.verticalTextBox;return ho&&gd(ho),z.allowVerticalPlacement&&!(Fn&&Fn.box&&Fn.box.length)&&fi>0&&ho?Zo(ho,vn.verticalIconBox,i.bL.vertical):{box:null,offscreen:null,occluded:null}}),Fn&&(Rn=Fn.box,fo=Fn.offscreen,Gi=Fn.occluded);const go=jo(!(!Fn||!Fn.box));if(!Rn&&this.prevPlacement){const ho=this.prevPlacement.variableOffsets[Xa];ho&&(this.variableOffsets[Xa]=ho,this.markUsedJustification(z,ho.anchor,Er,go))}}else{const Ni=(Zo,go)=>{const ho=z.getSymbolInstanceTextSize(tt,Er,this.transform.zoom,Fa),pm=this.collisionIndex.placeCollisionBox(z,ho,Zo,Pe,Ce,Nr,new i.P(0,0),gt,xe,ne,st.predicate);return pm&&pm.box&&pm.box.length&&(this.markUsedOrientation(z,go,Er),this.placedOrientations[Xa]=go),pm};Ro(()=>Ni(Ic,i.bL.horizontal),()=>{const Zo=vn.verticalTextBox;return z.allowVerticalPlacement&&fi>0&&Zo?(gd(Zo),Ni(Zo,i.bL.vertical)):{box:null,offscreen:null,occluded:null}}),jo(!!(Fn&&Fn.box&&Fn.box.length))}}if(Ao=Fn,Rn=Ao&&Ao.box&&Ao.box.length>0,fo=Ao&&Ao.offscreen,Gi=Ao&&Ao.occluded,Er.useRuntimeCollisionCircles){const jo=Er.centerJustifiedTextSymbolIndex>=0?Er.centerJustifiedTextSymbolIndex:Er.verticalPlacedTextSymbolIndex,Ro=z.text.placedSymbolArray.get(jo),Ni=i.bM(z.textSizeData,tt,Ro),Zo=V.get("text-padding");uo=this.collisionIndex.placeCollisionCircles(z,gt,Ro,jo,z.lineVertexArray,z.glyphOffsetArray,Ni,ne,oe,ge,A,Ut,st.predicate,Er.collisionCircleDiameter*Ni/i.bY,Zo,this.retainedQueryData[z.bucketInstanceId].tileID),Rn=gt||uo.circles.length>0&&!uo.collisionDetected,fo=fo&&uo.offscreen,Gi=uo.occluded}if(vn.iconFeatureIndex&&(jl=vn.iconFeatureIndex),vn.iconBox){const jo=Ro=>{gd(Ro);const Ni=Er.hasIconTextFit&&Ca?rl(Ca.x,Ca.y,Et,Ut,this.transform.angle):new i.P(0,0),Zo=z.getSymbolInstanceIconSize(dt,this.transform.zoom,Er.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(z,Zo,Ro,Pe,Ce,cr,Ni,mt,xe,ne,st.predicate)};qi&&qi.box&&qi.box.length&&vn.verticalIconBox?(ji=jo(vn.verticalIconBox),Ka=ji.box.length>0):(ji=jo(vn.iconBox),Ka=ji.box.length>0),fo=fo&&ji.offscreen,Qa=ji.occluded}const jh=yt||Er.numHorizontalGlyphVertices===0&&fi===0,mm=jt||Er.numIconVertices===0;if(jh||mm?mm?jh||(Ka=Ka&&Rn):Rn=Ka&&Rn:Ka=Rn=Ka&&Rn,Rn&&Ao&&Ao.box&&this.collisionIndex.insertCollisionBox(Ao.box,V.get("text-ignore-placement"),z.bucketInstanceId,qi&&qi.box&&ed?ed:ru,st.ID),Ka&&ji&&this.collisionIndex.insertCollisionBox(ji.box,V.get("icon-ignore-placement"),z.bucketInstanceId,jl,st.ID),uo&&(Rn&&this.collisionIndex.insertCollisionCircles(uo.circles,V.get("text-ignore-placement"),z.bucketInstanceId,ru,st.ID),A)){const jo=z.bucketInstanceId;let Ro=this.collisionCircleArrays[jo];Ro===void 0&&(Ro=this.collisionCircleArrays[jo]=new bS);for(let Ni=0;Ni=0;--Fa){const vn=Er[Fa];pa(z.symbolInstances.get(vn),vn,z.collisionArrays[vn])}z.hasAnyZOffset&&i.w(`${z.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(z.hasAnyZOffset){const Er=z.getSortedIndexesByZOffset();for(let Fa=0;Fa=0&&(h.text.placedSymbolArray.get(F).crossTileID=ge>=0&&F!==ge?0:ne),z>=0&&(h.text.placedSymbolArray.get(z).crossTileID=ge>=0&&z!==ge?0:ne),V>=0&&(h.text.placedSymbolArray.get(V).crossTileID=ge>=0&&V!==ge?0:ne),X>=0&&(h.text.placedSymbolArray.get(X).crossTileID=ge>=0&&X!==ge?0:ne)}markUsedOrientation(h,x,A){const D=x===i.bL.horizontal||x===i.bL.horizontalOnly?x:0,F=x===i.bL.vertical?x:0,{leftJustifiedTextSymbolIndex:z,centerJustifiedTextSymbolIndex:V,rightJustifiedTextSymbolIndex:X,verticalPlacedTextSymbolIndex:ne}=A,oe=h.text.placedSymbolArray;z>=0&&(oe.get(z).placedOrientation=D),V>=0&&(oe.get(V).placedOrientation=D),X>=0&&(oe.get(X).placedOrientation=D),ne>=0&&(oe.get(ne).placedOrientation=F)}commit(h){this.commitTime=h,this.zoomAtLastRecencyCheck=this.transform.zoom;const x=this.prevPlacement;let A=!1;this.prevZoomAdjustment=x?x.zoomAdjustment(this.transform.zoom):0;const D=x?x.symbolFadeChange(h):1,F=x?x.opacities:{},z=x?x.variableOffsets:{},V=x?x.placedOrientations:{};for(const X in this.placements){const ne=this.placements[X],oe=F[X];oe?(this.opacities[X]=new Ip(oe,D,ne.text,ne.icon,null,ne.clipped),A=A||ne.text!==oe.text.placed||ne.icon!==oe.icon.placed):(this.opacities[X]=new Ip(null,D,ne.text,ne.icon,ne.skipFade,ne.clipped),A=A||ne.text||ne.icon)}for(const X in F){const ne=F[X];if(!this.opacities[X]){const oe=new Ip(ne,D,!1,!1);oe.isHidden()||(this.opacities[X]=oe,A=A||ne.text.placed||ne.icon.placed)}}for(const X in z)this.variableOffsets[X]||!this.opacities[X]||this.opacities[X].isHidden()||(this.variableOffsets[X]=z[X]);for(const X in V)this.placedOrientations[X]||!this.opacities[X]||this.opacities[X].isHidden()||(this.placedOrientations[X]=V[X]);A?this.lastPlacementChangeTime=h:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=x?x.lastPlacementChangeTime:h)}updateLayerOpacities(h,x,A,D){D&&(this.lastReplacementSourceUpdateTime=D.updateTime);const F=new Set;for(const z of x){const V=z.getBucket(h);V&&z.latestFeatureIndex&&h.fqid===V.layerIds[0]&&(this.updateBucketOpacities(V,F,z,z.collisionBoxArray,A,D,z.tileID,h.scope),V.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(V,z.tileID),V.elevationType==="road"&&V.updateRoadElevation(z.tileID.canonical),V.updateZOffset())}}updateBucketOpacities(h,x,A,D,F,z,V,X){h.hasTextData()&&h.text.opacityVertexArray.clear(),h.hasIconData()&&h.icon.opacityVertexArray.clear(),h.hasIconCollisionBoxData()&&h.iconCollisionBox.collisionVertexArray.clear(),h.hasTextCollisionBoxData()&&h.textCollisionBox.collisionVertexArray.clear();const ne=h.layers[0].layout,oe=h.layers[0].paint,ge=!!h.layers[0].dynamicFilter(),pe=new Ip(null,0,!1,!1,!0),xe=ne.get("text-allow-overlap"),Pe=ne.get("icon-allow-overlap"),Ce=ne.get("text-variable-anchor"),Ve=ne.get("text-rotation-alignment")==="map",Be=ne.get("text-pitch-alignment")==="map",tt=oe.get("symbol-z-offset"),dt=ne.get("symbol-elevation-reference")==="sea",st=!tt.isConstant(),Mt=new Ip(null,0,xe&&(Pe||!h.hasIconData()||ne.get("icon-optional")),Pe&&(xe||!h.hasTextData()||ne.get("text-optional")),!0);!h.collisionArrays&&D&&(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData())&&h.deserializeCollisionBoxes(D);const yt=(gt,mt,Et)=>{for(let Ht=0;Ht0||Ht>0,Js=ts>0,mr=this.placedOrientations[Ut],Ys=mr===i.bL.vertical,Us=mr===i.bL.horizontal||mr===i.bL.horizontalOnly;!Es&&!Js||Jt.isHidden()||jt++;let Cr=!1;if((Es||Js)&&z)for(const Nr of h.activeReplacements){if(i.bZ(Nr,F,i.b_.Symbol,X)||Nr.min.x>ns||ns>Nr.max.x||Nr.min.y>fs||fs>Nr.max.y)continue;const cr=i.b$(ns,fs,V.canonical,Nr.footprintTileId.canonical);if(Cr=i.c0(cr,Nr.footprint),Cr)break}if(Es){const Nr=Cr?Ey:Jd(Jt.text);yt(h.text,Et,Ys?Ey:Nr),yt(h.text,Ht,Us?Ey:Nr);const cr=Jt.text.isHidden(),{leftJustifiedTextSymbolIndex:xr,centerJustifiedTextSymbolIndex:Vr,rightJustifiedTextSymbolIndex:jn,verticalPlacedTextSymbolIndex:pa}=mt,Ha=h.text.placedSymbolArray,Er=cr||Ys?1:0;xr>=0&&(Ha.get(xr).hidden=Er),Vr>=0&&(Ha.get(Vr).hidden=Er),jn>=0&&(Ha.get(jn).hidden=Er),pa>=0&&(Ha.get(pa).hidden=cr||Us?1:0);const Fa=this.variableOffsets[Ut];Fa&&this.markUsedJustification(h,Fa.anchor,mt,mr);const vn=this.placedOrientations[Ut];vn&&(this.markUsedJustification(h,"left",mt,vn),this.markUsedOrientation(h,vn,mt))}if(Js){const Nr=Cr?Ey:Jd(Jt.icon),{placedIconSymbolIndex:cr,verticalPlacedIconSymbolIndex:xr}=mt,Vr=h.icon.placedSymbolArray,jn=Jt.icon.isHidden()?1:0;cr>=0&&(yt(h.icon,ts,Ys?Ey:Nr),Vr.get(cr).hidden=jn),xr>=0&&(yt(h.icon,mt.numVerticalIconVertices,Us?Ey:Nr),Vr.get(xr).hidden=jn)}if(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData()){const Nr=h.collisionArrays[gt];if(Nr){let cr=new i.P(0,0),xr=!0;if(Nr.textBox||Nr.verticalTextBox){if(Ce){const jn=this.variableOffsets[Ut];jn?(cr=md(jn.anchor,jn.width,jn.height,jn.textOffset,jn.textScale),Ve&&cr._rotate(Be?this.transform.angle:-this.transform.angle)):xr=!1}ge&&(xr=!Jt.clipped),Nr.textBox&&lx(h.textCollisionBox.collisionVertexArray,Jt.text.placed,!xr||Ys,zt,dt,cr.x,cr.y),Nr.verticalTextBox&&lx(h.textCollisionBox.collisionVertexArray,Jt.text.placed,!xr||Us,zt,dt,cr.x,cr.y)}const Vr=xr&&!!(!Us&&Nr.verticalIconBox);Nr.iconBox&&lx(h.iconCollisionBox.collisionVertexArray,Jt.icon.placed,Vr,zt,dt,mt.hasIconTextFit?cr.x:0,mt.hasIconTextFit?cr.y:0),Nr.verticalIconBox&&lx(h.iconCollisionBox.collisionVertexArray,Jt.icon.placed,!Vr,zt,dt,mt.hasIconTextFit?cr.x:0,mt.hasIconTextFit?cr.y:0)}}}if(h.fullyClipped=jt===0,h.sortFeatures(this.transform.angle),this.retainedQueryData[h.bucketInstanceId]&&(this.retainedQueryData[h.bucketInstanceId].featureSortOrder=h.featureSortOrder),h.hasTextData()&&h.text.opacityVertexBuffer&&h.text.opacityVertexBuffer.updateData(h.text.opacityVertexArray),h.hasIconData()&&h.icon.opacityVertexBuffer&&h.icon.opacityVertexBuffer.updateData(h.icon.opacityVertexArray),h.hasIconCollisionBoxData()&&h.iconCollisionBox.collisionVertexBuffer&&h.iconCollisionBox.collisionVertexBuffer.updateData(h.iconCollisionBox.collisionVertexArray),h.hasTextCollisionBoxData()&&h.textCollisionBox.collisionVertexBuffer&&h.textCollisionBox.collisionVertexBuffer.updateData(h.textCollisionBox.collisionVertexArray),h.bucketInstanceId in this.collisionCircleArrays){const gt=this.collisionCircleArrays[h.bucketInstanceId];h.placementInvProjMatrix=gt.invProjMatrix,h.placementViewportMatrix=gt.viewportMatrix,h.collisionCircleArray=gt.circles,delete this.collisionCircleArrays[h.bucketInstanceId]}}symbolFadeChange(h){return this.fadeDuration===0?1:(h-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(h){return Math.max(0,(this.transform.zoom-h)/1.5)}hasTransitions(h){return this.stale||h-this.lastPlacementChangeTimeh}isStale(){return this.stale}setStale(){this.stale=!0}}function lx(M,h,x,A,D,F,z){M.emplaceBack(h?1:0,x?1:0,F||0,z||0,A,D?1:0),M.emplaceBack(h?1:0,x?1:0,F||0,z||0,A,D?1:0),M.emplaceBack(h?1:0,x?1:0,F||0,z||0,A,D?1:0),M.emplaceBack(h?1:0,x?1:0,F||0,z||0,A,D?1:0)}const sT=Math.pow(2,25),pb=Math.pow(2,24),wS=Math.pow(2,17),rT=Math.pow(2,16),jS=Math.pow(2,9),Qd=Math.pow(2,8),Vf=Math.pow(2,1);function Jd(M){if(M.opacity===0&&!M.placed)return 0;if(M.opacity===1&&M.placed)return 4294967295;const h=M.placed?1:0,x=Math.floor(127*M.opacity);return x*sT+h*pb+x*wS+h*rT+x*jS+h*Qd+x*Vf+h}const Ey=0;class _v{constructor(h){this._sortAcrossTiles=h.layout.get("symbol-z-order")!=="viewport-y"&&h.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(h,x,A,D,F,z){const V=this._bucketParts;for(;this._currentTileIndexX.sortKey-ne.sortKey));this._currentPartIndex{const X=i.o.now()-z;return!this._forceFullPlacement&&X>2};for(;this._currentPlacementIndex>=0;){const X=x[h[this._currentPlacementIndex]],ne=this.placement.collisionIndex.transform.zoom;if(X.type==="symbol"&&X.visibility!=="none"&&(!X.minzoom||X.minzoom<=ne)&&(!X.maxzoom||X.maxzoom>ne)){const oe=X,ge=oe.layout.get("symbol-z-elevate"),pe=oe.layout.get("symbol-sort-key").constantOr(1)!==void 0,xe=oe.layout.get("symbol-z-order"),Pe=xe==="viewport-y"||xe==="auto"&&!(xe!=="viewport-y"&&pe),Ce=oe.layout.get("text-allow-overlap")||oe.layout.get("icon-allow-overlap")||oe.layout.get("text-ignore-placement")||oe.layout.get("icon-ignore-placement"),Ve=Pe&&Ce,Be=this._inProgressLayer=this._inProgressLayer||new _v(oe),tt=i.B(X.source,X.scope);if(Be.continuePlacement(ge||Ve?D[tt]:A[tt],this.placement,this._showCollisionBoxes,X,V,F))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(h){return this.placement.commit(h),this.placement}}const om=512/i.al/2;class Hf{constructor(h,x,A){this.tileID=h,this.bucketInstanceId=A,this.index=new i.c4(x.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const D=h.canonical.x*i.al,F=h.canonical.y*i.al;for(let z=0;zVe-Be);for(const Ve of Ce){const Be=this.crossTileIDs[Ve];if(this.keys[Ve]===oe&&!A.has(Be)){A.add(Be),ne.crossTileID=Be;break}}}}}class Hl{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class nT{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(h){const x=Math.round((h-this.lng)/360);if(x!==0)for(const A in this.indexes){const D=this.indexes[A],F={};for(const z in D){const V=D[z];V.tileID=V.tileID.unwrapTo(V.tileID.wrap+x),F[V.tileID.key]=V}this.indexes[A]=F}this.lng=h}addBucket(h,x,A){if(this.indexes[h.overscaledZ]&&this.indexes[h.overscaledZ][h.key]){if(this.indexes[h.overscaledZ][h.key].bucketInstanceId===x.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(h.overscaledZ,this.indexes[h.overscaledZ][h.key])}for(let F=0;Fh.overscaledZ)for(const V in z){const X=z[V];X.tileID.isChildOf(h)&&X.findMatches(x.symbolInstances,h,D)}else{const V=z[h.scaledTo(Number(F)).key];V&&V.findMatches(x.symbolInstances,h,D)}}for(let F=0;F{x[A]=!0});for(const A in this.layerIndexes)x[A]||delete this.layerIndexes[A]}}const Lp=771;class Dn{constructor(h,x,A,D){this.blendFunction=h,this.blendColor=x.toNonPremultipliedRenderColor(null),this.mask=A,this.blendEquation=D}}Dn.Replace=[1,0,1,0],Dn.disabled=new Dn(Dn.Replace,i.ao.transparent,[!1,!1,!1,!1]),Dn.unblended=new Dn(Dn.Replace,i.ao.transparent,[!0,!0,!0,!0]),Dn.alphaBlended=new Dn([1,Lp,1,Lp],i.ao.transparent,[!0,!0,!0,!0]),Dn.alphaBlendedNonPremultiplied=new Dn([770,Lp,770,Lp],i.ao.transparent,[!0,!0,!0,!0]),Dn.multiply=new Dn([774,0,774,0],i.ao.transparent,[!0,!0,!0,!0]),Dn.additive=new Dn([1,1,1,1],i.ao.transparent,[!0,!0,!0,!0]);class Lr{constructor(h,x,A){this.func=h,this.mask=x,this.range=A}}Lr.ReadOnly=!1,Lr.ReadWrite=!0,Lr.disabled=new Lr(519,Lr.ReadOnly,[0,1]);const NS=7680;class dn{constructor(h,x,A,D,F,z){this.test=h,this.ref=x,this.mask=A,this.fail=D,this.depthFail=F,this.pass=z}}dn.disabled=new dn({func:519,mask:0},0,0,NS,NS,NS);const bv=1029,kS=2305;class rn{constructor(h,x,A){this.enable=h,this.mode=x,this.frontFace=A}}function Dp(M,h){const x=i.ca(M,3);i.cc(M,h),i.cg(M,3,x)}function aT(M,h){const x=i.c7([]);return i.c8(x,x,-h),i.c9(x,x,-M),x}function SS(M,h){const x=[M[0],M[1],0],A=[h[0],h[1],0];if(i.ag(x)>=1e-15){const z=i.aw([],x);i.c5(A,z,i.bJ(A,z)),h[0]=A[0],h[1]=A[1]}const D=i.bI([],h,M);if(i.c6(D)<1e-15)return null;const F=Math.atan2(-D[1],D[0]);return aT(Math.atan2(Math.sqrt(M[0]*M[0]+M[1]*M[1]),-M[2]),F)}rn.disabled=new rn(!1,bv,kS),rn.backCCW=new rn(!0,bv,kS),rn.backCW=new rn(!0,bv,2304),rn.frontCW=new rn(!0,1028,2304),rn.frontCCW=new rn(!0,1028,kS);class eu{constructor(h,x){this.position=h,this.orientation=x}get position(){return this._position}set position(h){if(h){const x=h instanceof i.ae?h:new i.ae(h[0],h[1],h[2]);this._renderWorldCopies&&(x.x=i.bT(x.x,0,1)),this._position=x}else this._position=null}lookAtPoint(h,x,A){if(this.orientation=null,!this.position)return;const D=this.position,F=A||(this._elevation?this._elevation.getAtPointOrZero(i.ae.fromLngLat(h)):0),z=i.ae.fromLngLat(h,F),V=[z.x-D.x,z.y-D.y,z.z-D.z];x||(x=[0,0,1]),x[2]=Math.abs(x[2]),this.orientation=SS(V,x)}setPitchBearing(h,x){this.orientation=aT(i.an(h),i.an(-x))}}class CS{constructor(h,x){this._transform=i.bA([]),this.orientation=x,this.position=h}get mercatorPosition(){const h=this.position;return new i.ae(h[0],h[1],h[2])}get position(){const h=i.ca(this._transform,3);return[h[0],h[1],h[2]]}set position(h){var x;h&&i.cg(this._transform,3,[(x=h)[0],x[1],x[2],1])}get orientation(){return this._orientation}set orientation(h){this._orientation=h||i.c7([]),h&&Dp(this._transform,this._orientation)}getPitchBearing(){const h=this.forward(),x=this.right();return{bearing:Math.atan2(-x[1],x[0]),pitch:Math.atan2(Math.sqrt(h[0]*h[0]+h[1]*h[1]),-h[2])}}setPitchBearing(h,x){this._orientation=aT(h,x),Dp(this._transform,this._orientation)}forward(){const h=i.ca(this._transform,2);return[-h[0],-h[1],-h[2]]}up(){const h=i.ca(this._transform,1);return[-h[0],-h[1],-h[2]]}right(){const h=i.ca(this._transform,0);return[h[0],h[1],h[2]]}getCameraToWorld(h,x){const A=new Float64Array(16);return i.bl(A,this.getWorldToCamera(h,x)),A}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(h,x,A){const D=this.position;i.c5(D,D,-h);const F=new Float64Array(16);return i.bq(F,[A,A,A]),i.br(F,F,D),F[10]*=x,F}getWorldToCamera(h,x){const A=new Float64Array(16),D=new Float64Array(4),F=this.position;return i.cb(D,this._orientation),i.c5(F,F,-h),i.cc(A,D),i.br(A,A,F),A[1]*=-1,A[5]*=-1,A[9]*=-1,A[13]*=-1,A[8]*=x,A[9]*=x,A[10]*=x,A[11]*=x,A}getCameraToClipPerspective(h,x,A,D){const F=new Float64Array(16);return i.cd(F,h,x,A,D),F}getCameraToClipOrthographic(h,x,A,D,F,z){const V=new Float64Array(16);return i.ce(V,h,x,A,D,F,z),V}getDistanceToElevation(h,x=!1){const A=h===0?0:i.cf(h,x?i.a$(this.position[1]):this.position[1]),D=this.forward();return(A-this.position[2])/D[2]}clone(){return new CS([...this.position],[...this.orientation])}}const _c={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class MS{constructor(h=0,x=0,A=0,D=0){if(isNaN(h)||h<0||isNaN(x)||x<0||isNaN(A)||A<0||isNaN(D)||D<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=h,this.bottom=x,this.left=A,this.right=D}interpolate(h,x,A){return x.top!=null&&h.top!=null&&(this.top=i.ak(h.top,x.top,A)),x.bottom!=null&&h.bottom!=null&&(this.bottom=i.ak(h.bottom,x.bottom,A)),x.left!=null&&h.left!=null&&(this.left=i.ak(h.left,x.left,A)),x.right!=null&&h.right!=null&&(this.right=i.ak(h.right,x.right,A)),this}getCenter(h,x){const A=i.aA((this.left+h-this.right)/2,0,h),D=i.aA((this.top+x-this.bottom)/2,0,x);return new i.P(A,D)}equals(h){return this.top===h.top&&this.bottom===h.bottom&&this.left===h.left&&this.right===h.right}clone(){return new MS(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Km=15;class iT{constructor(h,x,A,D,F,z,V){this.tileSize=512,this._renderWorldCopies=F===void 0||F,this._minZoom=h||0,this._maxZoom=x||22,this._minPitch=A??0,this._maxPitch=D??60,this.setProjection(z),this.setMaxBounds(V),this.width=0,this.height=0,this._center=new i.aT(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new MS,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new CS,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1,this._allowWorldUnderZoom=!1}clone(){const h=new iT(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return h._elevation=this._elevation,h._centerAltitude=this._centerAltitude,h._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,h.tileSize=this.tileSize,h.mercatorFromTransition=this.mercatorFromTransition,h.width=this.width,h.height=this.height,h.cameraElevationReference=this.cameraElevationReference,h._center=this._center,h._setZoom(this.zoom),h._seaLevelZoom=this._seaLevelZoom,h.angle=this.angle,h._fov=this._fov,h._pitch=this._pitch,h._nearZ=this._nearZ,h._farZ=this._farZ,h._averageElevation=this._averageElevation,h._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,h._unmodified=this._unmodified,h._edgeInsets=this._edgeInsets.clone(),h._camera=this._camera.clone(),h._calcMatrices(),h.freezeTileCoverage=this.freezeTileCoverage,h.frustumCorners=this.frustumCorners,h._allowWorldUnderZoom=this._allowWorldUnderZoom,h}get isOrthographic(){return this.projection.name!=="globe"&&this._orthographicProjectionAtLowPitch&&this.pitch0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||h===Number.NEGATIVE_INFINITY&&(!x||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const A=this._elevation;x||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&A.exaggeration()&&this._centerAltitudeValidForExaggeration!==A.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*A.exaggeration(),this._centerAltitudeValidForExaggeration=A.exaggeration()):(this._centerAltitude=h||0,this._centerAltitudeValidForExaggeration=A.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){if(this._centerAltitudeValidForExaggeration===void 0)return;const h=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(h)}sampleAverageElevation(){if(!this._elevation)return 0;const h=this._elevation,x=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],A=this.horizonLineFromTop();let D=0,F=0;for(let z=0;z{const Ve=i.cY(pe,ge,xe,Pe,Ce);X.has(Ve)||(F.push(new i.aQ(ge,pe,xe,Pe,Ce)),X.add(Ve))};for(let ge=0;gepe.canonical.z)continue;const xe=pe.canonical,Pe=pe.overscaledZ,Ce=pe.wrap,Ve=1<0,dt=xe.y+10,Mt=pe.wrap-(tt?0:1),yt=pe.wrap+(Be?0:1),jt=tt?xe.x-1:Ve-1,gt=Be?xe.x+1:0;if(z)A[0]<0?(ne(Pe,yt,xe.z,gt,xe.y),A[1]<0&&dt&&(ne(Pe,Ce,xe.z,xe.x,xe.y+1),ne(Pe,yt,xe.z,gt,xe.y+1)),A[1]>0&&st&&(ne(Pe,Ce,xe.z,xe.x,xe.y-1),ne(Pe,yt,xe.z,gt,xe.y-1))):A[0]>0?(ne(Pe,Mt,xe.z,jt,xe.y),A[1]<0&&dt&&(ne(Pe,Ce,xe.z,xe.x,xe.y+1),ne(Pe,Mt,xe.z,jt,xe.y+1)),A[1]>0&&st&&(ne(Pe,Ce,xe.z,xe.x,xe.y-1),ne(Pe,Mt,xe.z,jt,xe.y-1))):A[1]<0&&dt?ne(Pe,Ce,xe.z,xe.x,xe.y+1):st&&ne(Pe,Ce,xe.z,xe.x,xe.y-1);else{const mt=pe.visibleQuadrants;1&mt&&(ne(Pe,Mt,xe.z,jt,xe.y),st&&(ne(Pe,Ce,xe.z,xe.x,xe.y-1),ne(Pe,Mt,xe.z,jt,xe.y-1))),2&mt&&(ne(Pe,yt,xe.z,gt,xe.y),st&&(ne(Pe,Ce,xe.z,xe.x,xe.y-1),ne(Pe,yt,xe.z,gt,xe.y-1))),4&mt&&(ne(Pe,Mt,xe.z,jt,xe.y),dt&&(ne(Pe,Ce,xe.z,xe.x,xe.y+1),ne(Pe,Mt,xe.z,jt,xe.y+1))),8&mt&&(ne(Pe,yt,xe.z,gt,xe.y),dt&&(ne(Pe,Ce,xe.z,xe.x,xe.y+1),ne(Pe,yt,xe.z,gt,xe.y+1)))}}const oe=[];for(const ge of F)F.some(pe=>ge.isChildOf(pe))||oe.push(ge);if(F=oe.filter(ge=>!h.some(pe=>!!(ge.overscaledZ{const Be=Ve.canonical.x+.5-xe[0],tt=Ve.canonical.y+.5-xe[1];return Be*Be+tt*tt{const jt=i.cY(dt,tt,st,Mt,yt);F.has(jt)||(D.push(new i.aQ(tt,dt,st,Mt,yt)),F.add(jt))},V=h.reduce((tt,dt)=>Math.max(tt,dt.overscaledZ),A),X=1<{const st=Math.floor(tt[0]),Mt=Math.floor(tt[1]),yt=(tt[0]-st)*i.al,jt=(tt[1]-Mt)*i.al,gt=Math.floor(dt[0]),mt=Math.floor(dt[1]),Et=(dt[0]-gt)*i.al,Ht=(dt[1]-mt)*i.al;for(let Ut=-1;Ut<=1;Ut++){const ts=st+Ut;if(!(ts<0||ts>=X)){oe.x=yt-Ut*i.al,ge.x=Et-(ts-gt)*i.al;for(let ns=-1;ns<=1;ns++){const fs=Mt+ns;oe.y=jt-ns*i.al,ge.y=Ht-(fs-mt)*i.al,i.cZ(oe,ge,ne)&&z(V,0,A,ts,fs)}}}},xe=x.points,Pe=xe[i.cv],Ce=xe[i.cw],Ve=this._projectToGround(Pe,xe[i.cx]),Be=this._projectToGround(Ce,xe[i.cy]);return pe(Pe,Ve),pe(Ce,Be),D}_projectToGround(h,x){return i.cz(i.cA(),h,x,h[2]/(h[2]-x[2]))}coveringTiles(h){let x=this.coveringZoomLevel(h);const A=x,D=this.elevation&&this.elevation.exaggeration(),F=D&&!h.isTerrainDEM,z=this.projection.name==="mercator";if(h.minzoom!==void 0&&xh.maxzoom&&(x=h.maxzoom);const V=this.locationCoordinate(this.center),X=this.center.lat,ne=1<{const Jt=new i.ae(zt.x+25e-6,zt.y,zt.z),Es=new i.ae(zt.x,zt.y+25e-6,zt.z),Js=zt.toLngLat(),mr=Jt.toLngLat(),Ys=Es.toLngLat(),Us=this.locationCoordinate(Js),Cr=this.locationCoordinate(mr),Nr=this.locationCoordinate(Ys),cr=Math.hypot(Cr.x-Us.x,Cr.y-Us.y),xr=Math.hypot(Nr.x-Us.x,Nr.y-Us.y);return Math.sqrt(cr*xr)*jt/25e-6},mt=zt=>{const ds=Mt,Jt=yt;return{aabb:i.cF(this,ne,0,0,0,zt,Jt,ds,this.projection),zoom:0,x:0,y:0,minZ:Jt,maxZ:ds,wrap:zt,fullyVisible:!1}},Et=[];let Ht=[];const Ut=x,ts=h.reparseOverscaled?A:x,ns=(Ve-this._centerAltitude)*Ce,fs=zt=>{if(!this._elevation||!zt.tileID||!z)return;const ds=this._elevation.getMinMaxForTile(zt.tileID),Jt=zt.aabb;ds?(Jt.min[2]=ds.min,Jt.max[2]=ds.max,Jt.center[2]=(Jt.min[2]+Jt.max[2])/2):(zt.shouldSplit=Yt(zt),zt.shouldSplit||(Jt.min[2]=Jt.max[2]=Jt.center[2]=this._centerAltitude))},Bs=(zt,ds)=>{if(.707*ds{if(zt.zoom=.9)return!0}else if(F&&(Es=zt.aabb.distanceZ(Be)*Ce),this.projection.isReprojectedInTileSpace&&A<=5){const xr=Math.pow(2,zt.zoom),Vr=gt(new i.ae((zt.x+.5)/xr,(zt.y+.5)/xr));Js=Vr>.85?1:Vr}if(!z&&!ge){const xr=Math.sqrt(ds*ds+Jt*Jt+Es*Es);let Vr=(1<0;){const zt=Et.pop(),ds=zt.x,Jt=zt.y;let Es=zt.fullyVisible;const Js=()=>this.projection.name==="globe"&&(zt.y===0||zt.y===(1<>1),Cr={aabb:z?zt.aabb.quadrant(mr):i.cF(this,ne,zt.zoom+1,Ys,Us,zt.wrap,zt.minZ,zt.maxZ,this.projection),zoom:zt.zoom+1,x:Ys,y:Us,wrap:zt.wrap,fullyVisible:Es,tileID:void 0,shouldSplit:void 0,minZ:zt.minZ,maxZ:zt.maxZ};F&&!ge&&(Cr.tileID=new i.aQ(zt.zoom+1===Ut?ts:zt.zoom+1,zt.wrap,zt.zoom+1,Ys,Us),fs(Cr)),Et.push(Cr)}else{const mr=zt.zoom===Ut?ts:zt.zoom;if(h.minzoom&&h.minzoom>mr)continue;let Ys=0;if(!Es){let cr=tt?zt.aabb.intersectsPrecise(xe):zt.aabb.intersectsPreciseFlat(xe);if(cr===0&&Js()){const xr=new i.cD(zt.zoom,ds,Jt);cr=i.cE(this,ne,xr,!0).intersectsPrecise(xe)}if(cr===0)continue;if(h.calculateQuadrantVisibility)if(xe.containsPoint(zt.aabb.center))Ys=15;else for(let xr=0;xr<4;xr++)zt.aabb.quadrant(xr).intersects(xe)!==0&&(Ys|=1<{const Es=[0,0,0,1],Js=[i.al,i.al,0,1],mr=this.calculateFogTileMatrix(Jt.tileID.toUnwrapped());i.aC(Es,Es,mr),i.aC(Js,Js,mr);const Ys=i.cG([],Es,Js),Us=i.cH([],Es,Js),Cr=i.c$(Ys,Us);if(Cr===0)return!0;let Nr=!1;const cr=this._elevation;if(cr&&Cr>zt&&ds!==0){const xr=this.calculateProjMatrix(Jt.tileID.toUnwrapped());let Vr;h.isTerrainDEM||(Vr=cr.getMinMaxForTile(Jt.tileID)),Vr||(Vr={min:yt,max:Mt});const jn=i.cI(this.rotation),pa=[jn[0]*i.al,jn[1]*i.al,Vr.max];i.af(pa,pa,xr),Nr=(1-pa[1])*this.height*.5zt.distanceSq-ds.distanceSq).map(zt=>zt.tileID)}resize(h,x){this.width=h,this.height=x,this.pixelsToGLUnits=[2/h,-2/x],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(h){return Math.pow(2,h)}scaleZoom(h){return Math.log2(h)}project(h){const x=i.aA(h.lat,-i.cJ,i.cJ),A=this.projection.project(h.lng,x);return new i.P(A.x*this.worldSize,A.y*this.worldSize)}unproject(h){return this.projection.unproject(h.x/this.worldSize,h.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/i.cf(1,this.center.lat)/this.worldSize}setLocationAtPoint(h,x){let A,D;const F=this.centerPoint;if(this.projection.name==="globe"){const V=this.worldSize;A=(x.x-F.x)/V,D=(x.y-F.y)/V}else{const V=this.pointCoordinate(x),X=this.pointCoordinate(F);A=V.x-X.x,D=V.y-X.y}const z=this.locationCoordinate(h);this.setLocation(new i.ae(z.x-A,z.y-D))}setLocation(h){this.center=this.coordinateLocation(h),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(h,x){return this.projection.locationPoint(this,h,x)}locationPoint3D(h,x){return this.projection.locationPoint(this,h,x,!0)}pointLocation(h){return this.coordinateLocation(this.pointCoordinate(h))}pointLocation3D(h,x){return this.coordinateLocation(this.pointCoordinate3D(h,x))}locationCoordinate(h,x){const A=x?i.cf(x,h.lat):void 0,D=this.projection.project(h.lng,h.lat);return new i.ae(D.x,D.y,A)}coordinateLocation(h){return this.projection.unproject(h.x,h.y)}pointRayIntersection(h,x){const A=x??this._centerAltitude,D=[h.x,h.y,0,1],F=[h.x,h.y,1,1];i.aC(D,D,this.pixelMatrixInverse),i.aC(F,F,this.pixelMatrixInverse);const z=F[3];i.cK(D,D,1/D[3]),i.cK(F,F,1/z);const V=D[2],X=F[2];return{p0:D,p1:F,t:V===X?0:(A-V)/(X-V)}}screenPointToMercatorRay(h){const x=[h.x,h.y,0,1],A=[h.x,h.y,1,1];return i.aC(x,x,this.pixelMatrixInverse),i.aC(A,A,this.pixelMatrixInverse),i.cK(x,x,1/x[3]),i.cK(A,A,1/A[3]),x[2]=i.cf(x[2],this._center.lat)*this.worldSize,A[2]=i.cf(A[2],this._center.lat)*this.worldSize,i.cK(x,x,1/this.worldSize),i.cK(A,A,1/this.worldSize),new i.ax([x[0],x[1],x[2]],i.aw([],i.av([],A,x)))}rayIntersectionCoordinate(h){const{p0:x,p1:A,t:D}=h,F=i.cf(x[2],this._center.lat),z=i.cf(A[2],this._center.lat);return new i.ae(i.ak(x[0],A[0],D)/this.worldSize,i.ak(x[1],A[1],D)/this.worldSize,i.ak(F,z,D))}pointCoordinate(h,x=this._centerAltitude){return this.projection.pointCoordinate(this,h.x,h.y,x)}pointCoordinate3D(h,x){if(!this.elevation)return this.pointCoordinate(h,x);let A=this.projection.pointCoordinate3D(this,h.x,h.y);if(A)return new i.ae(A[0],A[1],A[2]);let D=0,F=this.horizonLineFromTop();if(h.y>F)return this.pointCoordinate(h,x);const z=.02*F,V=h.clone();for(let X=0;X<10&&F-D>z;X++){V.y=i.ak(D,F,.66);const ne=this.projection.pointCoordinate3D(this,V.x,V.y);ne?(F=V.y,A=ne):D=V.y}return A?new i.ae(A[0],A[1],A[2]):this.pointCoordinate(h)}isPointAboveHorizon(h){return this.projection.isPointAboveHorizon(this,h)}isPointOnSurface(h){if(h.y<0||h.y>this.height||h.x<0||h.x>this.width)return!1;if(this.elevation||this.zoom>=i.cL)return!this.isPointAboveHorizon(h);const x=this.pointCoordinate(h);return x.y>=0&&x.y<=1}_coordinatePoint(h,x){const A=x&&this.elevation?this.elevation.getAtPointOrZero(h,this._centerAltitude):this._centerAltitude,D=[h.x*this.worldSize,h.y*this.worldSize,A+h.toAltitude(),1];return i.aC(D,D,this.pixelMatrix),D[3]>0?new i.P(D[0]/D[3],D[1]/D[3]):new i.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:h,left:x}=this._edgeInsets,A=this.height-this._edgeInsets.bottom,D=this.width-this._edgeInsets.right,F=this.pointLocation3D(new i.P(x,h)),z=this.pointLocation3D(new i.P(D,h)),V=this.pointLocation3D(new i.P(D,A)),X=this.pointLocation3D(new i.P(x,A));let ne=Math.min(F.lng,z.lng,V.lng,X.lng),oe=Math.max(F.lng,z.lng,V.lng,X.lng),ge=Math.min(F.lat,z.lat,V.lat,X.lat),pe=Math.max(F.lat,z.lat,V.lat,X.lat);const xe=Math.pow(2,-this.zoom)/16*270,Pe=this.projection.name==="globe"?1:4,Ce=(Ve,Be,tt,dt,st)=>{const Mt=(Ve+tt)/2,yt=(Be+dt)/2,jt=new i.P(Mt,yt),{lng:gt,lat:mt}=this.pointLocation3D(jt),Et=Math.max(0,ne-gt,ge-mt,gt-oe,mt-pe);ne=Math.min(ne,gt),oe=Math.max(oe,gt),ge=Math.min(ge,mt),pe=Math.max(pe,mt),(stxe)&&(Ce(Ve,Be,Mt,yt,st+1),Ce(Mt,yt,tt,dt,st+1))};if(Ce(x,h,D,h,1),Ce(D,h,D,A,1),Ce(D,A,x,A,1),Ce(x,A,x,h,1),this.projection.name==="globe"){const[Ve,Be]=i.cM(this);Ve?(pe=90,oe=180,ne=-180):Be&&(ge=-90,oe=180,ne=-180)}return new i.aI(new i.aT(ne,ge),new i.aT(oe,pe))}_getBoundsRectangular(h,x){const{top:A,left:D}=this._edgeInsets,F=this.height-this._edgeInsets.bottom,z=this.width-this._edgeInsets.right,V=new i.P(D,A),X=new i.P(z,A),ne=new i.P(z,F),oe=new i.P(D,F);let ge=this.pointCoordinate(V,h),pe=this.pointCoordinate(X,h);const xe=this.pointCoordinate(ne,x),Pe=this.pointCoordinate(oe,x),Ce=(Ve,Be)=>(Be.y-Ve.y)/(Be.x-Ve.x);return ge.y>1&&pe.y>=0?ge=new i.ae((1-Pe.y)/Ce(Pe,ge)+Pe.x,1):ge.y<0&&pe.y<=1&&(ge=new i.ae(-Pe.y/Ce(Pe,ge)+Pe.x,0)),pe.y>1&&ge.y>=0?pe=new i.ae((1-xe.y)/Ce(xe,pe)+xe.x,1):pe.y<0&&ge.y<=1&&(pe=new i.ae(-xe.y/Ce(xe,pe)+xe.x,0)),new i.aI().extend(this.coordinateLocation(ge)).extend(this.coordinateLocation(pe)).extend(this.coordinateLocation(Pe)).extend(this.coordinateLocation(xe))}_getBoundsRectangularTerrain(){const h=this.elevation;if(!h.visibleDemTiles.length||h.isUsingMockSource())return this._getBoundsRectangular(0,0);const x=h.visibleDemTiles.reduce((A,D)=>{if(D.dem){const F=D.dem.tree;A.min=Math.min(A.min,F.minimums[0]),A.max=Math.max(A.max,F.maximums[0])}return A},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(x.min*h.exaggeration(),x.max*h.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(h=!0){const x=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,A=this.height/2-x*(1-this._horizonShift);return h?Math.max(0,A):A}getMaxBounds(){return this.maxBounds}setMaxBounds(h){this.maxBounds=h,this.minLat=-i.cJ,this.maxLat=i.cJ,this.minLng=-180,this.maxLng=180,h&&(this.minLat=h.getSouth(),this.maxLat=h.getNorth(),this.minLng=h.getWest(),this.maxLng=h.getEast(),this.maxLngge&&(V=ge-ne),ge-oexe&&(z=xe-X),xe-pe{for(let Yt=0;Yt<16;Yt++)ts[Yt]=i.ak(ns[Yt],fs[Yt],Bs)})(V,V,X,i.d0(this.pitch>=Km?1:this.pitch/Km))}else V=X;const ne=i.cP([],X,z);let oe=i.cP([],V,z);if(this.projection.isReprojectedInTileSpace){const mt=this.locationCoordinate(this.center),Et=i.bA([]);i.br(Et,Et,[mt.x*this.worldSize,mt.y*this.worldSize,0]),i.aB(Et,Et,i.cQ(this)),i.br(Et,Et,[-mt.x*this.worldSize,-mt.y*this.worldSize,0]),i.aB(oe,oe,Et),i.aB(ne,ne,Et),this.inverseAdjustmentMatrix=i.cR(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=i.cS([],oe,[this.worldSize,this.worldSize,this.worldSize/F,1]),this.projMatrix=oe,this.invProjMatrix=i.bl(new Float64Array(16),this.projMatrix),x){const mt=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);mt[8]=2*-h.x/this.width,mt[9]=2*h.y/this.height,this.expandedFarZProjMatrix=i.cP([],mt,z)}else this.expandedFarZProjMatrix=this.projMatrix;const ge=i.bl([],V);this.frustumCorners=i.cT.fromInvProjectionMatrix(ge,this.horizonLineFromTop(),this.height),this.cameraFrustum=i.cB.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!x);const pe=new Float32Array(16);i.bA(pe),i.cS(pe,pe,[1,-1,1]),i.cU(pe,pe,this._pitch),i.bB(pe,pe,this.angle);const xe=i.cd(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=i.bz(xe);const Pe=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;xe[8]=2*-h.x/this.width,xe[9]=2*(h.y+Pe)/this.height,this.skyboxMatrix=i.aB(pe,xe,pe);const Ce=this.point,Ve=Ce.x,Be=Ce.y,tt=this.width%2/2,dt=this.height%2/2,st=Math.cos(this.angle),Mt=Math.sin(this.angle),yt=Ve-Math.round(Ve)+st*tt+Mt*dt,jt=Be-Math.round(Be)+st*dt+Mt*tt,gt=new Float64Array(oe);if(i.br(gt,gt,[yt>.5?yt-1:yt,jt>.5?jt-1:jt,0]),this.alignedProjMatrix=gt,oe=i.bC(),i.cS(oe,oe,[this.width/2,-this.height/2,1]),i.br(oe,oe,[1,-1,0]),this.labelPlaneMatrix=oe,oe=i.bC(),i.cS(oe,oe,[1,-1,1]),i.br(oe,oe,[-1,-1,0]),i.cS(oe,oe,[2/this.width,2/this.height,1]),this.glCoordMatrix=oe,this.pixelMatrix=i.aB(new Float64Array(16),this.labelPlaneMatrix,ne),this._calcFogMatrices(),this._distanceTileDataCache={},oe=i.bl(new Float64Array(16),this.pixelMatrix),!oe)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=oe,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=i.cV(this);const mt=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=i.af(mt,mt,z),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=oe;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const h=this.cameraWorldSizeForFog,x=this.cameraPixelsPerMeter,A=this._camera.position,D=1/this.height/this._pixelsPerMercatorPixel,F=[h,h,x];i.c5(F,F,D),i.c5(A,A,-1),i.cW(A,A,F);const z=i.bC();i.br(z,z,A),i.cS(z,z,F),this.mercatorFogMatrix=z,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(h,x,D)}_computeCameraPosition(h){const x=(h=h||this.pixelsPerMeter)/this.pixelsPerMeter,A=this._camera.forward(),D=this.point,F=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*x-h/this.worldSize*this._centerAltitude;return[D.x/this.worldSize-A[0]*F,D.y/this.worldSize-A[1]*F,h/this.worldSize*this._centerAltitude-A[2]*F]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(h){const x=this._maxCameraBoundsDistance()*Math.cos(this._pitch),A=this._camera.position[2],D=h[2];let F=1;this.projection.wrap&&(this.center=this.center.wrap()),D>0&&(F=Math.min((x-A)/D,1)),this._camera.position=i.bH([],this._camera.position,h,F),this._updateStateFromCamera()}_updateStateFromCamera(){const h=this._camera.position,x=this._camera.forward(),{pitch:A,bearing:D}=this._camera.getPitchBearing(),F=i.cf(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,z=this._mercatorZfromZoom(this._maxZoom)*Math.cos(i.an(this._maxPitch)),V=Math.max((h[2]-F)/Math.cos(A),z),X=this._zoomFromMercatorZ(V);i.bH(h,h,x,V),this._pitch=i.aA(A,i.an(this.minPitch),i.an(this.maxPitch)),this.angle=i.bT(D,-Math.PI,Math.PI),this._setZoom(i.aA(X,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new i.ae(h[0],h[1],h[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(h){return Math.pow(2,h)*this.tileSize}_mercatorZfromZoom(h){return this.cameraToCenterDistance/this._worldSizeFromZoom(h)}_minimumHeightOverTerrain(){const h=Math.min(this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(h)}_zoomFromMercatorZ(h){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,h)*this.tileSize))}zoomFromMercatorZAdjusted(h){let x=0,A=i.cL,D=0,F=1/0;for(;A-x>1e-6&&A>x;){const z=x+.5*(A-x),V=this.tileSize*Math.pow(2,z),X=this.getCameraToCenterDistance(this.projection,z,V),ne=this.scaleZoom(X/(Math.max(0,h)*this.tileSize)),oe=Math.abs(z-ne);oene||pe.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+i.cX(this.fovAboveCenter)>88||this.anyCornerOffEdge(new i.P(0,0),new i.P(this.width,this.height))}zoomDeltaToMovement(h,x){const A=i.ag(i.av([],this._camera.position,h)),D=this._zoomFromMercatorZ(A)+x;return A-this._mercatorZfromZoom(D)}getCameraPoint(){if(this.projection.name==="globe"){const h=function([x,A,D],F){const z=[x,A,D,1];i.aC(z,z,F);const V=z[3]=Math.max(z[3],1e-6);return z[0]/=V,z[1]/=V,z[2]/=V,z}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new i.P(h[0],h[1])}{const h=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i.P(0,h))}}getCameraToCenterDistance(h,x=this.zoom,A=this.worldSize){const D=i.cO(h,x,this.width,this.height,1024),F=h.pixelSpaceConversion(this.center.lat,A,D);let z=.5/Math.tan(.5*this._fov)*this.height*F;return this.isOrthographic&&(z=i.ak(1,z,i.d0(this.pitch>=Km?1:this.pitch/Km))),z}getWorldToCameraMatrix(){const h=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&i.aB(h,h,this.globeMatrix),h}getFrustum(h){return i.cB.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,h,this.projection.zAxisUnit==="meters")}}const cx=(M,h)=>{if(h>0&&M.terrain&&i.w("Cutoff is currently disabled on terrain"),h<=0||M.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const x=M.transform,A=Math.max(Math.abs(x._zoom-(M.minCutoffZoom-1)),1),D=x.isLODDisabled(!1)?i.ah(60,45,x.pitch):i.ah(30,15,x.pitch),F=x._farZ-x._nearZ,z=h*x.height,V=((1-(X=D))*x.cameraToCenterDistance+X*(x._farZ+z))*A;var X;return{shouldRenderCutoff:D<1,uniformValues:{u_cutoff_params:[x._nearZ,x._farZ,(V-x._nearZ)/F,(V-z-x._nearZ)/F]}}},lm=2048;class fb{constructor(h,x){this.aabb=h,this.lastCascade=x}}class Wce{add(h,x){const A=this.receivers[h.key];A!==void 0?(A.aabb.min[0]=Math.min(A.aabb.min[0],x.min[0]),A.aabb.min[1]=Math.min(A.aabb.min[1],x.min[1]),A.aabb.min[2]=Math.min(A.aabb.min[2],x.min[2]),A.aabb.max[0]=Math.max(A.aabb.max[0],x.max[0]),A.aabb.max[1]=Math.max(A.aabb.max[1],x.max[1]),A.aabb.max[2]=Math.max(A.aabb.max[2],x.max[2])):this.receivers[h.key]=new fb(x,null)}clear(){this.receivers={}}get(h){return this.receivers[h.key]}computeRequiredCascades(h,x,A){const D=i.d9.fromPoints(h.points);let F=0;for(const z in this.receivers){const V=this.receivers[z];if(!V||!D.intersectsAabb(V.aabb))continue;V.aabb.min=D.closestPoint(V.aabb.min),V.aabb.max=D.closestPoint(V.aabb.max);const X=V.aabb.getCorners();for(let ne=0;ne1||pe[1]<-1||pe[1]>1){oe=!1;break}}if(V.lastCascade=ne,F=Math.max(F,ne),oe)break}}return F+1}}class wv{constructor(h){this.painter=h,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new Wce,this._depthMode=new Lr(h.context.gl.LEQUAL,Lr.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this.useNormalOffset=!1}destroy(){for(const h of this._cascades)h.texture.destroy(),h.framebuffer.destroy();this._cascades=[]}updateShadowParameters(h,x){const A=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!x||!x.properties)return;const D=x.properties.get("shadow-intensity");if(!x.shadowsEnabled()||D<=0||(this._shadowLayerCount=A.style.order.reduce((Pe,Ce)=>{const Ve=A.style._mergedLayers[Ce];return Pe+(Ve.hasShadowPass()&&!Ve.isHidden(h.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled))return;const F=A.context,z=lm,V=lm;if(this._cascades.length===0||lm!==this._cascades[0].texture.size[0]){this._cascades=[];for(let Pe=0;Pe<2;++Pe){const Ce=A._shadowMapDebug,Ve=F.gl,Be=F.createFramebuffer(z,V,Ce?1:0,"texture"),tt=new i.T(F,{width:z,height:V,data:null},Ve.DEPTH_COMPONENT16);if(Be.depthAttachment.set(tt.texture),Ce){const dt=new i.T(F,{width:z,height:V,data:null},Ve.RGBA8);Be.colorAttachment0.set(dt.texture)}this._cascades.push({framebuffer:Be,texture:tt,matrix:[],far:0,boundingSphereRadius:0,frustum:new i.cB,scale:0})}}this.shadowDirection=xb(x);let X=0;if(h.elevation){const Pe=h.elevation,Ce=[1e4,-1e4];Pe.visibleDemTiles.filter(Ve=>Ve.dem).forEach(Ve=>{const Be=Ve.dem.tree;Ce[0]=Math.min(Ce[0],Be.minimums[0]),Ce[1]=Math.max(Ce[1],Be.maximums[0])}),Ce[0]!==1e4&&(X=(Ce[1]-Ce[0])*Pe.exaggeration())}const ne=1.5*h.cameraToCenterDistance,oe=3*ne,ge=new Float64Array(16);for(let Pe=0;Pe=0)return{};const F=function(X,ne,oe){const ge=oe/(1<0&&(i.d8(F[1],F[1],[D[0]*z,0,0]),i.d8(F[2],F[2],[D[0]*z,0,0])),D[1]<0?(i.d8(F[0],F[0],[0,D[1]*z,0]),i.d8(F[1],F[1],[0,D[1]*z,0])):D[1]>0&&(i.d8(F[2],F[2],[0,D[1]*z,0]),i.d8(F[3],F[3],[0,D[1]*z,0]));const V={};return V.vertices=F,V.planes=[gb(F[1],F[0],F[4]),gb(F[2],F[1],F[5]),gb(F[3],F[2],F[6]),gb(F[0],F[3],F[7])],V}addShadowReceiver(h,x,A){this._receivers.add(h,i.d9.fromTileIdAndHeight(h,x,A))}getMaxCascadeForTile(h){const x=this._receivers.get(h);return x&&x.lastCascade?x.lastCascade:0}}function gb(M,h,x){const A=i.av([],x,h),D=i.av([],M,h),F=i.bI([],A,D),z=i.ag(F);return z===0?[0,0,1,0]:(i.c5(F,F,1/z),[F[0],F[1],F[2],-i.bJ(F,h)])}function xb(M){const h=M.properties.get("direction"),x=i.d4(h.x,h.y,h.z);x[2]=i.aA(x[2],0,75);const A=i.d6([x[0],x[1],x[2]]);return i.d5(A.x,A.y,A.z)}function Wf(M,h,x){const A=h.properties.get("color-use-theme")==="none",D=h.properties.get("color"),F=h.properties.get("intensity"),z=h.properties.get("direction"),V=[z.x,z.y,z.z],X=x.properties.get("color-use-theme")==="none",ne=x.properties.get("color"),oe=x.properties.get("intensity"),ge=Math.max(i.bJ([0,0,1],V),0),pe=[0,0,0];i.c5(pe,ne.toPremultipliedRenderColor(X?null:M.getLut(h.scope)).toArray01Linear().slice(0,3),oe);const xe=[0,0,0];return i.c5(xe,D.toPremultipliedRenderColor(A?null:M.getLut(x.scope)).toArray01Linear().slice(0,3),ge*F),i.db([pe[0]>0?pe[0]/(pe[0]+xe[0]):0,pe[1]>0?pe[1]/(pe[1]+xe[1]):0,pe[2]>0?pe[2]/(pe[2]+xe[2]):0])}function dx(M,h,x,A,D,F){const z=M.zoom,V=M.scale,X=M.worldSize,ne=1/X,oe=M.aspect,ge=Math.sqrt(1+oe*oe)*Math.tan(.5*M.fovX),pe=ge*ge,xe=A-x,Pe=A+x;let Ce,Ve;pe>xe/Pe?(Ce=A,Ve=A*ge):(Ce=.5*Pe*(1+pe),Ve=.5*Math.sqrt(xe*xe+2*(A*A+x*x)*pe+Pe*Pe*pe*pe));const Be=M.projection.pixelsPerMeter(M.center.lat,X),tt=M._camera.getCameraToWorldMercator(),dt=[0,0,-Ce*ne];i.af(dt,dt,tt);let st=Ve*ne;const Mt=M._edgeInsets;if(!(Mt.left===0&&Mt.top===0&&Mt.right===0&&Mt.bottom===0||Mt.left===Mt.right&&Mt.top===Mt.bottom)){const Es=M._camera.getWorldToCamera(M.worldSize,M.projection.zAxisUnit==="meters"?Be:1),Js=M._camera.getCameraToClipPerspective(M._fov,M.width/M.height,x,A);Js[8]=2*-M.centerOffset.x/M.width,Js[9]=2*M.centerOffset.y/M.height;const mr=new Float64Array(16);i.cP(mr,Js,Es);const Ys=new Float64Array(16);i.bl(Ys,mr);const Us=i.cB.fromInvProjectionMatrix(Ys,X,z,!0);for(const Cr of Us.points){const Nr=((yt=Cr)[0]/=V,yt[1]/=V,yt[2]=i.cf(yt[2],M._center.lat),yt);st=Math.max(st,i.c6(i.da([],dt,Nr)))}}var yt;st*=D/(D-1);const jt=Math.acos(h[2]),gt=Math.atan2(-h[0],-h[1]),mt=new CS;mt.position=dt,mt.setPitchBearing(jt,gt);const Et=mt.getWorldToCamera(X,Be),Ht=st*X,Ut=Math.min(M._mercatorZfromZoom(17)*X*-2,-2*Ht),ts=mt.getCameraToClipOrthographic(-Ht,Ht,-Ht,Ht,Ut,(Ht+F*Be)/h[2]),ns=new Float64Array(16);i.aB(ns,ts,Et);const fs=i.d5(Math.floor(1e6*dt[0])/1e6*X,Math.floor(1e6*dt[1])/1e6*X,0),Bs=.5*D,Yt=[0,0,0];i.af(Yt,fs,ns),i.c5(Yt,Yt,Bs);const zt=[Math.floor(Yt[0]),Math.floor(Yt[1]),Math.floor(Yt[2])],ds=[0,0,0];i.av(ds,Yt,zt),i.c5(ds,ds,-1/Bs);const Jt=new Float64Array(16);return i.bA(Jt),i.br(Jt,Jt,ds),i.aB(ns,Jt,ns),[ns,Ht]}class Gce extends i.E{constructor(h){super(),this.requestManager=h,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(h,x){return i.dc(this.requestManager.transformRequest(x,i.R.Model).url).then(A=>{if(!A)return;const D=i.dd(A),F=new i.de(h,x,void 0,void 0,D);return F.computeBoundsAndApplyParent(),F}).catch(A=>{if(A&&A.status===404)return null;this.fire(new i.y(new Error(`Could not load model ${h} from ${x}: ${A.message}`)))})}load(h,x,A={forceReload:!1}){this.models[x]||(this.models[x]={});const D=Object.keys(h),F=[],z=[];for(const V of D){const X=h[V];this.hasURLBeenRequested(X)&&!A.forceReload||(this.modelByURL[X]={modelId:V,scope:x},F.push(this.loadModel(V,X)),z.push(V)),this.models[x][V]||(this.models[x][V]={model:null,numReferences:1})}this.numModelsLoading[x]=(this.numModelsLoading[x]||0)+z.length,Promise.allSettled(F).then(V=>{for(let X=0;X{this.fire(new i.y(new Error(`Could not load models: ${V.message}`)))})}isLoaded(){for(const h in this.numModelsLoading)if(this.numModelsLoading[h]>0)return!1;return!0}hasModel(h,x,A={exactIdMatch:!1}){return!!(A.exactIdMatch?this.getModel(h,x):this.getModelByURL(this.modelUris[x][h]))}getModel(h,x){return this.models[x]||(this.models[x]={}),this.models[x][h]?this.models[x][h].model:void 0}getModelByURL(h){if(!h)return null;const x=this.modelByURL[h];return x?this.models[x.scope][x.modelId].model:null}hasModelBeenAdded(h,x){return this.models[x]&&this.models[x][h]!==void 0}getModelURIs(h){return this.modelUris[h]||{}}addModel(h,x,A){this.models[A]||(this.models[A]={}),this.modelUris[A]||(this.modelUris[A]={});const D=this.requestManager.normalizeModelURL(x);if((this.hasModel(h,A,{exactIdMatch:!0})||this.hasModelBeenAdded(h,A))&&this.modelUris[A][h]===D)this.models[A][h].numReferences++;else if(this.hasURLBeenRequested(D)){const{scope:F,modelId:z}=this.modelByURL[D];this.models[F][z].numReferences++}else this.modelUris[A][h]=D,this.load({[h]:this.modelUris[A][h]},A)}addModelURLs(h,x){this.models[x]||(this.models[x]={}),this.modelUris[x]||(this.modelUris[x]={});const A=this.modelUris[x];for(const D in h)A[D]=this.requestManager.normalizeModelURL(h[D])}reloadModels(h){this.load(this.modelUris[h],h,{forceReload:!0})}addModelsFromBucket(h,x){this.models[x]||(this.models[x]={}),this.modelUris[x]||(this.modelUris[x]={});const A={};for(const D of h)this.hasModel(D,x,{exactIdMatch:!0})||this.hasURLBeenRequested(D)?this.models[x][D].numReferences++:this.modelUris[x][D]&&!this.hasURLBeenRequested(D)?A[D]=this.modelUris[x][D]:!this.hasURLBeenRequested(D)&&i.df(D,!1)&&(this.modelUris[x][D]=this.requestManager.normalizeModelURL(D),A[D]=this.modelUris[x][D]);this.load(A,x)}hasURLBeenRequested(h){return this.modelByURL[h]!==void 0}removeModel(h,x,A=!1,D=!1){if(this.models[x]&&this.models[x][h]&&(this.models[x][h].numReferences--,this.models[x][h].numReferences===0||D)){const F=this.modelUris[x][h];A||delete this.modelUris[x][h],delete this.modelByURL[F];const z=this.models[x][h].model;if(!z)return;delete this.models[x][h],z.destroy()}}destroy(){for(const h of Object.keys(this.models))for(const x of Object.keys(this.models[h])){const A=this.models[h][x].model;delete this.models[h][x],A&&A.destroy()}this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}listModels(h){return this.models[h]||(this.models[h]={}),Object.keys(this.models[h])}upload(h,x){this.models[x]||(this.models[x]={});for(const A in this.models[x])this.models[x][A].model&&this.models[x][A].model.upload(h.context)}}const oT=i.a6.colorTheme,Kce=new i.a9({data:new i.aa(oT.data)});function vD(M){if(!M.metadata||!M.metadata.content_area)return;const h=i.o.devicePixelRatio,{left:x,top:A,width:D,height:F}=M.metadata.content_area,z=x*h,V=A*h;return[z,V,z+D*h,V+F*h]}function _D(M){if(M)return M.map(([h,x])=>[h*i.o.devicePixelRatio,x*i.o.devicePixelRatio])}class lT{constructor(h,x,A){this.id=h,this.scope=x,this.sourceCache=A,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(h){this.missingRequests.has(h.name)||this.pendingRequests.has(h.name)||this.pendingRequests.add(h.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const h=new Map;if(!this.sourceCache.loaded())return h;const x=this.sourceCache.getVisibleCoordinates();if(x.length===0)return h;const A=this.sourceCache.getSource();if(!(A instanceof Xc))return h;const D=x.map(z=>this.sourceCache.getTile(z)),F=A.getImages(D,Array.from(this.pendingRequests));for(const[z,V]of F)h.set(i.I.from({name:z,iconsetId:this.id}),V),this.pendingRequests.delete(z);for(const z of this.pendingRequests)this.missingRequests.add(z);return this.pendingRequests.clear(),h}}const ux=(M,h)=>Je(M,h&&h.filter(x=>x.identifier!=="source.canvas")),bD=i.aH(wa,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),wD=i.aH(wa,["setCenter","setZoom","setBearing","setPitch"]),TS=new Set(["background","sky","slot","custom"]),hx={version:8,layers:[],sources:{}},yb={duration:300,delay:0};class cm extends i.E{constructor(h,x={}){super(),this.map=h,this.scope=x.scope||"",this.globalId=null,this.fragments=[],this.importDepth=x.importDepth||0,this.importsCache=x.importsCache||new Map,this.resolvedImports=x.resolvedImports||new Set,this.transition=Object.assign({},yb),this._buildingIndex=new lb(this),this.crossTileSymbolIndex=new Gm,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=x.styleChanges||new Se,this._hasDataDrivenEmissive=!1,this.dispatcher=x.dispatcher?x.dispatcher:new i.D(i.dh(),this),x.imageManager?this.imageManager=x.imageManager:(this.imageManager=new $e(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=x.glyphManager?x.glyphManager:new i.di(h._requestManager,x.localFontFamily?i.dj.all:x.localIdeographFontFamily?i.dj.ideographs:i.dj.none,x.localFontFamily||x.localIdeographFontFamily),x.modelManager?this.modelManager=x.modelManager:(this.modelManager=new Gce(h._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=x.configOptions?x.configOptions:new Map,this._configDependentLayers=x.configDependentLayers?x.configDependentLayers:new Set,this._indoorDependentLayers=x.indoorDependentLayers?x.indoorDependentLayers:new Set,this._config=x.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:x.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=x.initialConfig,this.dispatcher.broadcast("setReferrer",i.dk());const A=this;this._rtlTextPluginCallback=cm.registerForPluginStateChange(D=>{A.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:D.pluginStatus,pluginURL:D.pluginURL},(F,z)=>{if(i.dl(F),z&&z.every(V=>V))for(const V in A._sourceCaches){const X=A._sourceCaches[V],ne=X.getSource().type;ne!=="vector"&&ne!=="geojson"||X.reload()}})}),this.on("data",D=>{if(D.dataType!=="source"||D.sourceDataType!=="metadata")return;const F=this.getOwnSource(D.sourceId);if(F&&F.vectorLayerIds)for(const z in this._layers){const V=this._layers[z];V.source===F.id&&this._validateLayer(V)}})}load(h){return h?(typeof h=="string"?this.loadURL(h):this.loadJSON(h),this):this}_getGlobalId(h){if(!h)return null;if(typeof h=="string"){if(i.h(h))return h;const x=i.dm(h);if(!x.startsWith("http"))try{return new URL(x,location.href).toString()}catch{return x}return x}return`json://${i.dn(JSON.stringify(h))}`}_diffStyle(h,x,A){this.globalId=this._getGlobalId(h);const D=(F,z)=>{try{z(null,this.setState(F,A))}catch(V){z(V,!1)}};if(typeof h=="string"){const F=this.map._requestManager.normalizeStyleURL(h),z=this.map._requestManager.transformRequest(F,i.R.Style);i.m(z,(V,X)=>{V?this.fire(new i.y(V)):X&&D(X,x)})}else typeof h=="object"&&D(h,x)}loadURL(h,x={}){this.fire(new i.z("dataloading",{dataType:"style"}));const A=typeof x.validate=="boolean"?x.validate:!i.h(h);this.globalId=this._getGlobalId(h),h=this.map._requestManager.normalizeStyleURL(h,x.accessToken),this.resolvedImports.add(h);const D=this.importsCache.get(h);if(D)return this._load(D,A);const F=this.map._requestManager.transformRequest(h,i.R.Style);this._request=i.m(F,(z,V)=>{if(this._request=null,z)this.fire(new i.y(z));else if(V)return this.importsCache.set(h,V),this._load(V,A)})}loadJSON(h,x={}){this.fire(new i.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(h),this._request=i.o.frame(()=>{this._request=null,this._load(h,x.validate!==!1)})}loadEmpty(){this.fire(new i.z("dataloading",{dataType:"style"})),this._load(hx,!1)}_loadImports(h,x,A){if(this.importDepth>=4)return i.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const D=[];for(const F of h){const z=this._createFragmentStyle(F),V=new Promise(oe=>{z.once("style.import.load",oe),z.once("error",oe)}).then(()=>this.mergeAll());if(D.push(V),this.resolvedImports.has(F.url)){z.loadEmpty();continue}const X=F.data||this.importsCache.get(F.url);X?(z.loadJSON(X,{validate:x}),this._isInternalStyle(X)&&(z.globalId=null)):F.url?z.loadURL(F.url,{validate:x}):z.loadEmpty();const ne={style:z,id:F.id,config:F.config};if(A){const oe=this.fragments.findIndex(({id:ge})=>ge===A);this.fragments=this.fragments.slice(0,oe).concat(ne).concat(this.fragments.slice(oe))}else this.fragments.push(ne)}return Promise.allSettled(D)}getImportGlobalIds(h=this,x=new Set){for(const A of h.fragments)A.style.globalId&&x.add(A.style.globalId),this.getImportGlobalIds(A.style,x);return[...x.values()]}_createFragmentStyle(h){const x=this.scope?i.B(h.id,this.scope):h.id;let A;const D=this._initialConfig&&this._initialConfig[x];(h.config||D)&&(A=Object.assign({},h.config,D));const F=new cm(this.map,{scope:x,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:A,configOptions:this.options,colorThemeOverride:h["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return F.setEventedParent(this.map,{style:F}),F}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.map._precompilePrograms&&this.isRootStyle()}_isInternalStyle(h){return this.isRootStyle()&&(h.fragment||!!h.schema&&h.fragment!==!1)}_load(h,x){if(this._isInternalStyle(h)){const F=Object.assign({},hx,{imports:[{id:"basemap",data:h,url:""}]},h.center?{center:h.center}:{},h.bearing?{bearing:h.bearing}:{},h.pitch?{pitch:h.pitch}:{},h.zoom?{zoom:h.zoom}:{},h.light?{light:h.light}:{});return this._importedAsBasemap=!0,void this._load(F,x)}if(this.updateConfig(this._config,h.schema),x&&ux(this,Zt(h)))return;this._loaded=!0,this.stylesheet=i.dp(h);const A=()=>{for(const X in h.sources)this.addSource(X,h.sources[X],{validate:!1,isInitialLoad:!0});if(h.iconsets)for(const X in h.iconsets)this.addIconset(X,h.iconsets[X]);h.sprite?this._loadIconset(h.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&h.glyphs&&this.glyphManager.setURL(h.glyphs);const F=Sy(this.stylesheet.layers);if(this._order=F.map(X=>X.id),this.stylesheet.light&&i.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(this.stylesheet.lights.length===1&&this.stylesheet.lights[0].type==="flat"){const X=this.stylesheet.lights[0];this.light=new Bt(X.properties,X.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Bt(this.stylesheet.light)),this._layers={};for(const X of F){const ne=i.du(X,this.scope,this._styleColorTheme.lut,this.options);ne.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(ne.fqid),ne.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(ne.fqid),this._hasAppearances=this._hasAppearances||ne.getAppearances().length!==0,ne.setEventedParent(this,{layer:{id:ne.id}}),this._layers[ne.id]=ne;const oe=this.getOwnLayerSourceCache(ne),ge=!!this.directionalLight&&this.directionalLight.shadowsEnabled();oe&&ne.canCastShadows()&&ge&&(oe.castsShadows=!0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const z=this.stylesheet.terrain;z&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(z,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new i.z("data",{dataType:"style"}));const V=this.isRootStyle();h.imports?this._loadImports(h.imports,x).then(()=>{this._reloadImports(),this.fire(new i.z(V?"style.load":"style.import.load"))}).catch(X=>{this.fire(new i.y(new Error("Failed to load imports",X))),this.fire(new i.z(V?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new i.z(V?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const D=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(D){const F=this._evaluateColorThemeData(D);this._loadColorTheme(F).then(()=>{A()}).catch(z=>{i.w(`Couldn't load color theme from the stylesheet: ${z}`),A()})}else this._styleColorTheme.lut=null,A()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(h=>h.style.hasAppearances())}mergeAll(){let h,x,A,D,F,z,V,X,ne,oe;const ge={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(pe=>{if(pe.stylesheet){if(pe.light!=null&&(h=pe.light),pe.stylesheet.lights)for(const xe of pe.stylesheet.lights)xe.type==="ambient"&&pe.ambientLight!=null&&(x=pe.ambientLight),xe.type==="directional"&&pe.directionalLight!=null&&(A=pe.directionalLight);D=this._prioritizeTerrain(D,pe.terrain,pe.stylesheet.terrain),pe.stylesheet.fog&&pe.fog!=null&&(F=pe.fog),pe.stylesheet.snow&&pe.snow!=null&&(z=pe.snow),pe.stylesheet.rain&&pe.rain!=null&&(V=pe.rain),pe.stylesheet.camera!=null&&(oe=pe.stylesheet.camera),pe.stylesheet.projection!=null&&(X=pe.stylesheet.projection),pe.stylesheet.transition!=null&&(ne=pe.stylesheet.transition),ge[pe.scope]=pe._styleColorTheme}}),this.light=h,this.ambientLight=x,this.directionalLight=A,this.fog=F,this.snow=z,this.rain=V,this._styleColorThemeForScope=ge,D===null?delete this.terrain:this.terrain=D,this.camera=oe||{"camera-projection":"perspective"},this.projection=X||{name:"mercator"},this.transition=Object.assign({},yb,ne),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(h){const x=A=>{for(const D of A.fragments)x(D.style);h(A)};x(this)}_prioritizeTerrain(h,x,A){const D=h&&h.drapeRenderMode===0;return A===null?x&&x.drapeRenderMode===0?x:D?h:null:x!=null&&(!h||D||x&&x.drapeRenderMode===1)?x:h}mergeTerrain(){let h;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(x=>{h=this._prioritizeTerrain(h,x.terrain,x.stylesheet.terrain)}),h===null?delete this.terrain:this.terrain=h}mergeProjection(){let h;this.forEachFragmentStyle(x=>{x.stylesheet.projection!=null&&(h=x.stylesheet.projection)}),this.projection=h||{name:"mercator"}}mergeSources(){const h={},x={},A={};this.forEachFragmentStyle(D=>{for(const F in D._sourceCaches){const z=i.B(F,D.scope);h[z]=D._sourceCaches[F]}for(const F in D._otherSourceCaches){const z=i.B(F,D.scope);x[z]=D._otherSourceCaches[F]}for(const F in D._symbolSourceCaches){const z=i.B(F,D.scope);A[z]=D._symbolSourceCaches[F]}}),this._mergedSourceCaches=h,this._mergedOtherSourceCaches=x,this._mergedSymbolSourceCaches=A}mergeIndoor(){this.forEachFragmentStyle(h=>{if(h.stylesheet&&h.stylesheet.indoor)for(const x of Object.values(h.stylesheet.indoor)){const A=x,D=i.B(A.sourceId,h.scope);this._mergedIndoor[D]=new Set(A.sourceLayers||[])}})}mergeLayers(){const h={},x=[],A={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(z=>{for(const V of z._order){const X=z._layers[V];if(X.type==="slot"){const ne=i.dq(V);if(h[ne])continue;h[ne]=[]}X.slot&&h[X.slot]?h[X.slot].push(X):x.push(X)}}),this._mergedOrder=[];let D=-1;const F=(z=[])=>{for(const V of z)if(V.type==="slot"){const X=i.dq(V.id);h[X]&&F(h[X]),this._mergedSlots.push(X)}else{const X=i.B(V.id,V.scope);this._mergedOrder.push(X),A[X]=V,V.is3D(!!this.terrain)&&(this._has3DLayers=!0,D=this._mergedOrder.length-1),V.type==="circle"&&(this._hasCircleLayers=!0),V.type==="symbol"&&(this._hasSymbolLayers=!0),V.type==="clip"&&(this._clipLayerPresent=!0)}};if(F(x),this._has3DLayers){const z={};for(let V=0;Vz[V]-z[X])}this._mergedLayers=A,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength()}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}getCamera(){return this.stylesheet.camera}setCamera(h){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,h),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(h){return h.data?function(x,A,D,F){const z=Object.assign({},A);for(const X of Object.keys(oT))z[X]===void 0&&(z[X]=oT[X].default);const V=new i.a8(Kce,x,new Map(D));return V.setTransitionOrValue(z,D),V.untransitioned().possiblyEvaluate(new i.ac(0,{worldview:void 0}))}(this.scope,h,this.options).get("data"):null}_loadColorTheme(h){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const x=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((A,D)=>{const F="data:image/png;base64,";if(!h||h.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void A();let z=h;z.startsWith(F)||(z=F+z);const V=i.I.from("mapbox-reserved-lut"),X=new Image;X.src=z,X.onerror=()=>{this._styleColorTheme.lutLoading=!1,D(new Error("Failed to load image data"))},X.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==x)return void A();this._styleColorTheme.lutLoading=!1;const{width:ne,height:oe,data:ge}=i.o.getImageData(X);if(oe>32)return void D(new Error("The height of the image must be less than or equal to 32 pixels."));if(ne!==oe*oe)return void D(new Error("The width of the image must be equal to the height squared."));this.getImage(V)&&this.removeImage(V),this.addImage(V,{data:new i.q({width:ne,height:oe},ge),pixelRatio:1,sdf:!1,usvg:!1,version:0});const pe=this.imageManager.getImage(V,this.scope);pe?(this._styleColorTheme.lut={image:pe.data,data:h},A()):D(new Error("Missing LUT image."))}})}getLut(h){const x=this._styleColorThemeForScope[h];return x?x.lut:null}setProjection(h){h?this.stylesheet.projection=h:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(h){this._spriteRequest=function(x,A,D){let F,z,V;const X=i.o.devicePixelRatio>1?"@2x":"";let ne=i.m(A.transformRequest(A.normalizeSpriteURL(x,X,".json"),i.R.SpriteJSON),(pe,xe)=>{ne=null,V||(V=pe,F=xe,ge())}),oe=i.n(A.transformRequest(A.normalizeSpriteURL(x,X,".png"),i.R.SpriteImage),(pe,xe)=>{oe=null,V||(V=pe,z=xe,ge())});function ge(){if(V)D(V);else if(F&&z){const pe=i.o.getImageData(z),xe={};for(const Pe in F){const{width:Ce,height:Ve,x:Be,y:tt,sdf:dt,pixelRatio:st,stretchX:Mt,stretchY:yt,content:jt}=F[Pe],gt=new i.q({width:Ce,height:Ve});i.q.copy(pe,gt,{x:Be,y:tt},{x:0,y:0},{width:Ce,height:Ve},null),xe[Pe]={data:gt,pixelRatio:st!==void 0?st:1,sdf:dt!==void 0&&dt,stretchX:Mt,stretchY:yt,content:jt,usvg:!1,version:0}}D(null,xe)}}return{cancel(){ne&&(ne.cancel(),ne=null),oe&&(oe.cancel(),oe=null)}}}(h,this.map._requestManager,(x,A)=>{if(this._spriteRequest=null,x)this.fire(new i.y(x));else if(A){const D=new Map;for(const F in A)D.set(i.I.from(F),A[F]);this.addImages(D)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new i.z("data",{dataType:"style"}))})}addIconset(h,x){if(x.type==="sprite")return void this._loadSprite(x.url);const A=this.getOwnSourceCache(x.source);if(!A)return void this.fire(new i.y(new Error(`Source "${x.source}" as specified by iconset "${h}" does not exist and cannot be used as an iconset source`)));const D=A.getSource();if(D.type!=="raster-array")return void this.fire(new i.y(new Error(`Source "${x.source}" as specified by iconset "${h}" is not a "raster-array" source and cannot be used as an iconset source`)));D.partial=!1;const F=new lT(h,this.scope,A);this.imageManager.addImageProvider(F,this.scope)}removeIconset(h){this.imageManager.removeImageProvider(h,this.scope)}_loadIconset(h){if(!i.h(h)&&this.map._spriteFormat!=="icon_set"||this.map._spriteFormat==="raster")return void this._loadSprite(h);const x=this.map._spriteFormat==="auto";var A,D;this._spriteRequest=(D=(F,z)=>{if(this._spriteRequest=null,F)x?this._loadSprite(h):this.fire(new i.y(F));else if(z){const V=new Map;for(const X in z)V.set(i.I.from(X),z[X]);this.addImages(V)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new i.z("data",{dataType:"style"}))},i.bu((A=this.map._requestManager).transformRequest(A.normalizeIconsetURL(h),i.R.Iconset),(F,z)=>{if(F)return void D(F);const V={},X=i.dg(new i.bt(z));for(const ne of X.icons){const oe={version:1,pixelRatio:i.o.devicePixelRatio,content:vD(ne),stretchX:ne.metadata?_D(ne.metadata.stretch_x_areas):void 0,stretchY:ne.metadata?_D(ne.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:ne};V[ne.name]=oe}D(null,V)}))}_validateLayer(h){const x=this.getOwnSource(h.source);if(!x)return;const A=h.sourceLayer;A&&(x.type==="geojson"||x.vectorLayerIds&&x.vectorLayerIds.indexOf(A)===-1)&&this.fire(new i.y(new Error(`Source layer "${A}" does not exist on source "${x.id}" as specified by style layer "${h.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const h in this._sourceCaches)if(!this._sourceCaches[h].loaded())return!1;if(!this.imageManager.isLoaded()||this.imageManager.hasPatternsInFlight()||!this.modelManager.isLoaded()||this._styleColorTheme.lutLoading)return!1;for(const{style:h}of this.fragments)if(!h.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((h,x)=>{const A=this.fragments[x];return A&&A.style&&(h.data=A.style.serialize()),h})}_serializeSources(){const h={};for(const x in this._sourceCaches){const A=this._sourceCaches[x].getSource();h[A.id]||(h[A.id]=A.serialize())}return h}_serializeLayers(h){const x=[];for(const A of h){const D=this._layers[A];D&&D.type!=="custom"&&x.push(D.serialize())}return x}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasSnowTransition(){return!!this.snow&&this.snow.hasTransition()}hasRainTransition(){return!!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions()||this.hasFogTransition()||this.hasSnowTransition()||this.hasRainTransition())return!0;for(const h in this._sourceCaches)if(this._sourceCaches[h].hasTransition())return!0;for(const h in this._layers)if(this._layers[h].hasTransition())return!0;return!1}_updateDataDrivenEmissiveStrength(){for(const h in this._mergedLayers){const x=this._mergedLayers[h];if(x._transitionablePaint&&x._transitionablePaint._values){const A=x._transitionablePaint._values["line-emissive-strength"];if(A&&A.value&&A.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(h){return h?this.order:this._mergedOrder}isLayerDraped(h){return!!this.terrain&&h.isDraped(this.getLayerSourceCache(h))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(h){const x=this.getOwnLayer(h);if(x)return x;this.fire(new i.y(new Error(`The layer '${h}' does not exist in the map's style.`)))}_checkSource(h){const x=this.getOwnSource(h);if(x)return x;this.fire(new i.y(new Error(`The source '${h}' does not exist in the map's style.`)))}precompilePrograms(h,x){const A=this.map.painter;if(A)for(let D=h.minzoom||0;D<(h.maxzoom||25.5);D++){const F=h.getProgramIds();if(F)for(const z of F){const V=h.getDefaultProgramParams(z,x.zoom,this._styleColorTheme.lut);V&&(A.style=this,this.fog&&(A._fogVisible=!0,V.overrideFog=!0,A.getOrCreateProgram(z,V)),A._fogVisible=!1,V.overrideFog=!1,A.getOrCreateProgram(z,V),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(V.overrideRtt=!0,A.getOrCreateProgram(z,V)))}}}update(h){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(h),this.directionalLight&&this.directionalLight.recalculate(h);const x=this.calculateLightsBrightness();h.brightness=x||0,x!==this._brightness&&(this._brightness=x,this.dispatcher.broadcast("setBrightness",x)),h.worldview!==this._worldview&&(this._worldview=h.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const A=this._changes.isDirty();let D=!1;if(this._changes.isDirty()){const V=this._changes.getLayerUpdatesByScope();for(const X in V){const{updatedIds:ne,removedIds:oe}=V[X];(ne||oe)&&(this._updateWorkerLayers(X,ne,oe),D=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(h),this.light&&this.light.updateTransitions(h),this.ambientLight&&this.ambientLight.updateTransitions(h),this.directionalLight&&this.directionalLight.updateTransitions(h),this.fog&&this.fog.updateTransitions(h),this.snow&&this.snow.updateTransitions(h),this.rain&&this.rain.updateTransitions(h),this._changes.reset()}const F={};for(const V in this._mergedSourceCaches){const X=this._mergedSourceCaches[V];F[V]=X.used,X.used=!1,X.tileCoverLift=0}for(const V of this._mergedOrder){const X=this._mergedLayers[V];if(X.visibility!=="none"&&X.recalculate(h,this._availableImages),!X.isHidden(h.zoom)){const ne=this.getLayerSourceCache(X);ne&&(ne.used=!0,ne.tileCoverLift=Math.max(ne.tileCoverLift,X.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(X,h)}):this.precompilePrograms(X,h))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&D&&this.mergeLayers();const z=this.imageManager.getPendingImageProviders();for(const V of z)V.sourceCache.used=!0;for(const V in F){const X=this._mergedSourceCaches[V];F[V]!==X.used&&X.getSource().fire(new i.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:X.getSource().id}))}this.light&&this.light.recalculate(h),this.terrain&&this.terrain.recalculate(h),this.fog&&this.fog.recalculate(h),this.snow&&this.snow.recalculate(h),this.rain&&this.rain.recalculate(h),this.z=h.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),A&&this.fire(new i.z("data",{dataType:"style"}))}updateImageProviders(){const h=this.imageManager.getPendingImageProviders();for(const x of h){const A=x.resolvePendingRequests(),D=this.getFragmentStyle(x.scope);D&&D.addImages(A)}}_updateTilesForChangedImages(){const h={};for(const x in this._mergedSourceCaches){const A=this._mergedSourceCaches[x].getSource().scope;h[A]=h[A]||this._changes.getUpdatedImages(A),h[A].length!==0&&this._mergedSourceCaches[x].reloadTilesForDependencies(["icons","patterns"],h[A])}for(const x in h)this._changes.resetUpdatedImages(x)}_updateWorkerLayers(h,x,A){const D=this.getFragmentStyle(h);D&&this.dispatcher.broadcast("updateLayers",{layers:x?D._serializeLayers(x):[],scope:h,removedIds:A||[],options:D.options})}setState(h,x){if(this._checkLoaded(),ux(this,Zt(h)))return!1;(h=i.dp(h)).layers=Sy(h.layers);const A=function(z,V){if(!z)return[{command:wa.setStyle,args:[V]}];let X=[];try{if(!i.by(z.version,V.version))return[{command:wa.setStyle,args:[V]}];if(i.by(z.center,V.center)||X.push({command:wa.setCenter,args:[V.center]}),i.by(z.zoom,V.zoom)||X.push({command:wa.setZoom,args:[V.zoom]}),i.by(z.bearing,V.bearing)||X.push({command:wa.setBearing,args:[V.bearing]}),i.by(z.pitch,V.pitch)||X.push({command:wa.setPitch,args:[V.pitch]}),i.by(z.sprite,V.sprite)||X.push({command:wa.setSprite,args:[V.sprite]}),i.by(z.glyphs,V.glyphs)||X.push({command:wa.setGlyphs,args:[V.glyphs]}),i.by(z.imports,V.imports)||function(xe=[],Pe=[],Ce){Pe=Pe||[];const Ve=(xe=xe||[]).map(Cy),Be=Pe.map(Cy),tt=xe.reduce(My,{}),dt=Pe.reduce(My,{}),st=Ve.slice();let Mt,yt,jt,gt;for(Mt=0,yt=0;Mt{xe.source&&ne[xe.source]?X.push({command:wa.removeLayer,args:[xe.id]}):ge.push(xe)});let pe=z.terrain;pe&&ne[pe.source]&&(X.push({command:wa.setTerrain,args:[void 0]}),pe=void 0),X=X.concat(oe),i.by(pe,V.terrain)||X.push({command:wa.setTerrain,args:[V.terrain]}),function(xe,Pe,Ce){Pe=Pe||[];const Ve=(xe=xe||[]).map(Cy),Be=Pe.map(Cy),tt=xe.reduce(My,{}),dt=Pe.reduce(My,{}),st=Ve.slice(),Mt=Object.create(null);let yt,jt,gt,mt,Et,Ht,Ut;for(yt=0,jt=0;yt!(z.command in wD));if(A.length===0)return!1;const D=A.filter(z=>!(z.command in bD));if(D.length>0)throw new Error(`Unimplemented: ${D.map(z=>z.command).join(", ")}.`);const F=[];return A.forEach(z=>{F.push(this[z.command](...z.args))}),x&&Promise.all(F).then(x).catch(x),this.stylesheet=h,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages})}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(h){if(h.size===0)return this;for(const[x,A]of h.entries()){if(this.getImage(x))return this.fire(new i.y(new Error(`An image with the name "${x.name}" already exists.`)));this.imageManager.addImage(x,this.scope,A),this._changes.updateImage(x,this.scope)}return this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this}addImage(h,x){return this.getImage(h)?this.fire(new i.y(new Error(`An image with the name "${h.name}" already exists.`))):(this.imageManager.addImage(h,this.scope,x),this._changes.updateImage(h,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this)}updateImage(h,x,A=!1){this.imageManager.updateImage(h,this.scope,x),A&&(this._changes.updateImage(h,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})))}getImage(h){return this.imageManager.getImage(h,this.scope)}removeImage(h){return this.getImage(h)?(this.imageManager.removeImage(h,this.scope),this._changes.updateImage(h,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this):this.fire(new i.y(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(h){return this.modelManager.addModelURLs(h,this.getActualScope()),this._updateWorkerModels(),this.fire(new i.z("data",{dataType:"style"})),this}addModel(h,x,A={}){return this._checkLoaded(),this._validate(ye,`models.${h}`,x,null,A)||(this.modelManager.addModel(h,x,this.getActualScope()),this.fire(new i.z("data",{dataType:"style"}))),this}hasModel(h){return this.modelManager.hasModel(h,this.getActualScope())}removeModel(h){return this.hasModel(h)?(this.modelManager.removeModel(h,this.getActualScope(),!1,!0),this.fire(new i.z("data",{dataType:"style"})),this):this.fire(new i.y(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(h,x,A={}){if(this._checkLoaded(),this.getOwnSource(h)!==void 0)throw new Error(`There is already a source with ID "${h}".`);if(!x.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(x).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(x.type)>=0&&this._validate($r,`sources.${h}`,x,null,A))return;this.map&&this.map._collectResourceTiming&&(x.collectResourceTiming=!0);const D=_l(h,x,this.dispatcher,this);D.scope=this.scope,D.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(D.id),source:D.serialize(),sourceId:D.id}));const F=z=>{const V=(z?"symbol:":"other:")+D.id,X=i.B(V,this.scope),ne=this._sourceCaches[V]=new hl(X,D,z);(z?this._symbolSourceCaches:this._otherSourceCaches)[D.id]=ne,ne.onAdd(this.map)};F(!1),x.type!=="vector"&&x.type!=="geojson"||F(!0),D.onAdd&&D.onAdd(this.map),A.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(h){this._checkLoaded();const x=this.getOwnSource(h);if(!x)throw new Error("There is no source with this ID");for(const D in this._layers)if(this._layers[D].source===h)return this.fire(new i.y(new Error(`Source "${h}" cannot be removed while layer "${D}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===h)return this.fire(new i.y(new Error(`Source "${h}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const D=Object.entries(this.stylesheet.iconsets).find(([F,z])=>z.type==="source"&&z.source===h);if(D)return this.fire(new i.y(new Error(`Source "${h}" cannot be removed while iconset "${D[0]}" is using it.`)))}const A=this.getOwnSourceCaches(h);for(const D of A){const F=i.dq(D.id);delete this._sourceCaches[F],this._changes.discardSourceCacheUpdate(D.id),D.fire(new i.z("data",{sourceDataType:"metadata",dataType:"source",sourceId:D.getSource().id})),D.setEventedParent(null),D.clearTiles()}return delete this._otherSourceCaches[h],delete this._symbolSourceCaches[h],this.mergeSources(),x.setEventedParent(null),x.onRemove&&x.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(h,x){this._checkLoaded(),this.getOwnSource(h).setData(x),this._changes.setDirty()}getOwnSource(h){const x=this.getOwnSourceCache(h);return x&&x.getSource()}getOwnSources(){const h=[];for(const x in this._otherSourceCaches){const A=this.getOwnSourceCache(x);A&&h.push(A.getSource())}return h}areTilesLoaded(){const h=this._mergedSourceCaches;for(const x in h){const A=h[x]._tiles;for(const D in A){const F=A[D];if(F.state!=="loaded"&&F.state!=="errored")return!1}}return!0}setLights(h){if(this._checkLoaded(),!h)return delete this.ambientLight,void delete this.directionalLight;const x=this._getTransitionParameters();for(const F of h){if(this._validate(an,"lights",F))return;switch(F.type){case"ambient":if(this.ambientLight){const z=this.ambientLight;z.set(F),z.updateTransitions(x)}else this.ambientLight=new ba(F,qo||(qo=new i.a9({color:new i.aa(i.a6.properties_light_ambient.color),"color-use-theme":new i.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new i.aa(i.a6.properties_light_ambient.intensity)})),this.scope,this.options);break;case"directional":if(this.directionalLight){const z=this.directionalLight;z.set(F),z.updateTransitions(x)}else this.directionalLight=new ba(F,Va||(Va=new i.a9({direction:new i.ap(i.a6.properties_light_directional.direction),color:new i.aa(i.a6.properties_light_directional.color),"color-use-theme":new i.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new i.aa(i.a6.properties_light_directional.intensity),"cast-shadows":new i.aa(i.a6.properties_light_directional["cast-shadows"]),"shadow-quality":new i.aa(i.a6.properties_light_directional["shadow-quality"]),"shadow-intensity":new i.aa(i.a6.properties_light_directional["shadow-intensity"])})),this.scope,this.options)}}const A=Object.assign(x,{worldview:this.map.getWorldview()}),D=new i.ac(this.z||0,A);this.ambientLight&&this.ambientLight.recalculate(D),this.directionalLight&&this.directionalLight.recalculate(D),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const h=this.directionalLight,x=this.ambientLight;if(!h||!x)return;const A=pe=>.2126*(pe[0]<=.03928?pe[0]/12.92:Math.pow((pe[0]+.055)/1.055,2.4))+.7152*(pe[1]<=.03928?pe[1]/12.92:Math.pow((pe[1]+.055)/1.055,2.4))+.0722*(pe[2]<=.03928?pe[2]/12.92:Math.pow((pe[2]+.055)/1.055,2.4)),D=h.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),F=h.properties.get("intensity"),z=h.properties.get("direction"),V=1-i.d4(z.x,z.y,z.z)[2]/90,X=A(D)*F*V,ne=x.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),oe=x.properties.get("intensity"),ge=A(ne)*oe;return Number(((X+ge)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const h=[];return this.directionalLight&&h.push(this.directionalLight.get()),this.ambientLight&&h.push(this.ambientLight.get()),h}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(h){if(h==null||h===""&&this.isRootStyle())return this;if(i.dr(h)){const x=i.ds(h),A=this.fragments.find(({id:F})=>F===x);if(!A)return;const D=i.dq(h);return A.style.getFragmentStyle(D)}{const x=this.fragments.find(({id:A})=>A===h);return x?x.style:void 0}}setFeaturesetSelectors(h){if(!h)return;const x={},A=(D,F="")=>`${D}::${F}`;this._featuresetSelectors={};for(const D in h){const F=this._featuresetSelectors[D]=[];for(const z of h[D].selectors){if(z.featureNamespace){const X=this.getOwnLayer(z.layer);if(!X){i.w(`Layer is undefined for selector: ${z.layer}`);continue}const ne=A(X.source,X.sourceLayer);if(ne in x&&x[ne]!==z.featureNamespace){i.w(`"featureNamespace ${z.featureNamespace} of featureset ${D}'s selector is not associated to the same source, skip this selector`);continue}x[ne]=z.featureNamespace}let V;if(z.properties)for(const X in z.properties){const ne=i.U(z.properties[X]);ne.result==="success"&&(V=V||{},V[X]=ne.value)}F.push({layerId:z.layer,namespace:z.featureNamespace,properties:V,uniqueFeatureID:z._uniqueFeatureID})}}}getFeaturesetDescriptors(h){const x=this.getFragmentStyle(h);if(!x||!x.stylesheet.featuresets)return[];const A=[];for(const D in x.stylesheet.featuresets)A.push({featuresetId:D,importId:x.scope?x.scope:void 0});return A}getFeaturesetLayers(h,x){const A=this.getFragmentStyle(x),D=A.stylesheet.featuresets;if(!D||!D[h])return this.fire(new i.y(new Error(`The featureset '${h}' does not exist in the map's style and cannot be queried.`))),[];const F=[];for(const z of D[h].selectors){const V=A.getOwnLayer(z.layer);V&&F.push(V)}return F}getConfigProperty(h,x){const A=this.getFragmentStyle(h);if(!A)return null;const D=i.B(x,A.scope),F=A.options.get(D),z=F?F.value||F.default:null;return z?z.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(h,x){const A=i.B(h,x);return this._mergedIndoor[A]}setIndoorData(h,x){this.map.indoor.setIndoorData(x)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(h,x,A){const D=this.getFragmentStyle(h);if(!D)return;const F=D.stylesheet.schema;if(!F||!F[x])return;const z=i.U(A);if(z.result!=="success")return void ux(this,z.value);const V=z.value.expression,X=i.B(x,D.scope),ne=D.options.get(X);if(!ne)return;let oe;const{minValue:ge,maxValue:pe,stepValue:xe,type:Pe,values:Ce}=F[x],Ve=i.U(F[x].default);Ve.result==="success"&&(oe=Ve.value.expression),oe?(this.options.set(X,Object.assign({},ne,{value:V,default:oe,minValue:ge,maxValue:pe,stepValue:xe,type:Pe,values:Ce})),this.updateConfigDependencies(x)):this.fire(new i.y(new Error(`No schema defined for the config option "${x}" in the "${h}" fragment.`)))}getConfig(h){const x=this.getFragmentStyle(h);if(!x)return null;const A=x.stylesheet.schema;if(!A)return null;const D={};for(const F in A){const z=i.B(F,x.scope),V=x.options.get(z),X=V?V.value||V.default:null;D[F]=X?X.serialize():null}return D}setConfig(h,x){const A=this.getFragmentStyle(h);A&&(A.updateConfig(x,A.stylesheet.schema),this.updateConfigDependencies())}getSchema(h){const x=this.getFragmentStyle(h);return x?x.stylesheet.schema:null}setSchema(h,x){const A=this.getFragmentStyle(h);A&&(A.stylesheet.schema=x,A.updateConfig(A._config,x),this.updateConfigDependencies())}updateConfig(h,x){if(this._config=h,h||x)if(x)for(const A in x){let D,F;const z=i.U(x[A].default);if(z.result==="success"&&(D=z.value.expression),h&&h[A]!==void 0){const pe=i.U(h[A]);pe.result==="success"&&(F=pe.value.expression)}const{minValue:V,maxValue:X,stepValue:ne,type:oe,values:ge}=x[A];if(D){const pe=i.B(A,this.scope);this.options.set(pe,{default:D,value:F,minValue:V,maxValue:X,stepValue:ne,type:oe,values:ge})}else this.fire(new i.y(new Error(`No schema defined for config option "${A}".`)))}else this.fire(new i.y(new Error("Attempting to set config for a style without schema.")))}_updateLayers(h,x=()=>!0){for(const A of h){const D=this.getLayer(A);D&&x(D)&&(D.possiblyEvaluateVisibility(),this._updateLayer(D),this._changes.setDirty())}}updateConfigDependencies(h){this._updateLayers(this._configDependentLayers,x=>!h||x.expressionDependencies.configDependencies.has(h)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(x=>{const A=x._styleColorTheme.colorThemeOverride?x._styleColorTheme.colorThemeOverride:x._styleColorTheme.colorTheme;if(A){const D=x._evaluateColorThemeData(A);(!x._styleColorTheme.lut&&D!==""||x._styleColorTheme.lut&&D!==x._styleColorTheme.lut.data)&&x.setColorTheme(A)}}),this._changes.setDirty()}addLayer(h,x,A={}){this._checkLoaded();const D=h.id;if(this._layers[D])return void this.fire(new i.y(new Error(`Layer with id "${D}" already exists on this map`)));let F;if(h.type==="custom"){if(ux(this,i.dt(h)))return;F=i.du(h,this.scope,this._styleColorTheme.lut,this.options)}else{if(typeof h.source=="object"&&(this.addSource(D,h.source),h=i.dp(h),h=Object.assign(h,{source:D})),this._validate(Go,`layers.${D}`,h,{arrayIndex:-1},A))return;F=i.du(h,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(F),F.setEventedParent(this,{layer:{id:D}})}const z=i.B(F.source,F.scope);F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(z),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(z);let V=this._order.length;if(x){const ge=this._order.indexOf(x);if(ge===-1)return void this.fire(new i.y(new Error(`Layer with id "${x}" does not exist on this map.`)));F.slot===this._layers[x].slot?V=ge:i.w(`Layer with id "${x}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(V,0,D),this._layerOrderChanged=!0,this._layers[D]=F;const X=this.getOwnLayerSourceCache(F),ne=!!this.directionalLight&&this.directionalLight.shadowsEnabled();X&&F.canCastShadows()&&ne&&(X.castsShadows=!0);const oe=this._changes.getRemovedLayer(F);if(oe&&F.source&&X&&F.type!=="custom"){this._changes.discardLayerRemoval(F);const ge=i.B(F.source,F.scope);oe.type!==F.type?this._changes.updateSourceCache(ge,"clear"):(this._changes.updateSourceCache(ge,"reload"),X.pause())}this._updateLayer(F),F.onAdd&&F.onAdd(this.map),F.scope=this.scope,this.mergeLayers()}moveLayer(h,x){this._checkLoaded();const A=this._checkLayer(h);if(!A||h===x)return;const D=this._order.indexOf(h);this._order.splice(D,1);let F=this._order.length;if(x){const z=this._order.indexOf(x);if(z===-1)return void this.fire(new i.y(new Error(`Layer with id "${x}" does not exist on this map.`)));A.slot===this._layers[x].slot?F=z:i.w(`Layer with id "${x}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(F,0,h),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(h){this._checkLoaded();const x=this._checkLayer(h);if(!x)return;x.setEventedParent(null);const A=this._order.indexOf(h);this._order.splice(A,1),delete this._layers[h],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(x.fqid),this._indoorDependentLayers.delete(x.fqid),this._changes.removeLayer(x);const D=this.getOwnLayerSourceCache(x);if(D&&D.castsShadows){let F=!1;for(const z in this._layers)if(this._layers[z].source===x.source&&this._layers[z].canCastShadows()){F=!0;break}D.castsShadows=F}x.onRemove&&x.onRemove(this.map),this.mergeLayers()}getOwnLayer(h){return this._layers[h]}hasLayer(h){return h in this._mergedLayers}hasLayerType(h){for(const x in this._layers)if(this._layers[x].type===h)return!0;return!1}setLayerZoomRange(h,x,A){this._checkLoaded();const D=this._checkLayer(h);D&&(D.minzoom===x&&D.maxzoom===A||(x!=null&&(D.minzoom=x),A!=null&&(D.maxzoom=A),this._updateLayer(D)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(h,x){this._checkLoaded();const A=this._checkLayer(h);A&&A.slot!==x&&(A.slot=x,this._updateLayer(A))}setFilter(h,x,A={}){this._checkLoaded();const D=this._checkLayer(h);if(D&&!i.by(D.filter,x))return x==null?(D.filter=void 0,void this._updateLayer(D)):void(this._validate(yi,`layers.${D.id}.filter`,x,{layerType:D.type},A)||(D.filter=i.dp(x),this._updateLayer(D)))}getFilter(h){const x=this._checkLayer(h);if(x)return i.dp(x.filter)}setLayoutProperty(h,x,A,D={}){this._checkLoaded();const F=this._checkLayer(h);if(F&&!i.by(F.getLayoutProperty(x),A)){if(A!=null&&(!D||D.validate!==!1)&&ux(F,Vt.call(Zt,{key:`layers.${h}.layout.${x}`,layerType:F.type,objectKey:x,value:A,styleSpec:i.a6,style:{glyphs:!0,sprite:!0}})))return;F.setLayoutProperty(x,A),F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(F.fqid),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(F.fqid),this._updateLayer(F)}}setLayerProperty(h,x,A,D={}){this._checkLoaded();const F=this._checkLayer(h);F&&(x==="appearances"?(F.setAppearances(A),this._changes.setDirty()):F.isPaintProperty(x)?this.setPaintProperty(h,x,A,D):this.setLayoutProperty(h,x,A,D))}getLayoutProperty(h,x){const A=this._checkLayer(h);if(A)return A.getLayoutProperty(x)}setPaintProperty(h,x,A,D={}){this._checkLoaded();const F=this._checkLayer(h);if(!F||i.by(F.getPaintProperty(x),A)||A!=null&&(!D||D.validate!==!1)&&ux(F,Vl.call(Zt,{key:`layers.${h}.paint.${x}`,layerType:F.type,objectKey:x,value:A,styleSpec:i.a6})))return;const z=F.setPaintProperty(x,A);F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(F.fqid),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(F.fqid),z&&this._updateLayer(F),this._changes.updatePaintProperties(F)}getPaintProperty(h,x){const A=this._checkLayer(h);if(A)return A.getPaintProperty(x)}setFeatureState(h,x){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:X,importId:ne}=h.target,oe=this.getFragmentStyle(ne),ge=oe.getFeaturesetLayers(X);for(const{source:pe,sourceLayer:xe}of ge)oe.setFeatureState({id:h.id,source:pe,sourceLayer:xe},x)}else if("layerId"in h.target){const{layerId:X}=h.target,ne=this.getLayer(X);this.setFeatureState({id:h.id,source:ne.source,sourceLayer:ne.sourceLayer},x)}return}const A=h.source,D=h.sourceLayer,F=this._checkSource(A);if(!F)return;const z=F.type;if(z==="geojson"&&D)return void this.fire(new i.y(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(z==="vector"&&!D)return void this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")));h.id===void 0&&this.fire(new i.y(new Error("The feature id parameter must be provided.")));const V=this.getOwnSourceCaches(A);for(const X of V)X.setFeatureState(D,h.id,x)}removeFeatureState(h,x){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:X,importId:ne}=h.target,oe=this.getFragmentStyle(ne),ge=oe.getFeaturesetLayers(X);for(const{source:pe,sourceLayer:xe}of ge)oe.removeFeatureState({id:h.id,source:pe,sourceLayer:xe},x)}else if("layerId"in h.target){const{layerId:X}=h.target,ne=this.getLayer(X);this.removeFeatureState({id:h.id,source:ne.source,sourceLayer:ne.sourceLayer},x)}return}const A=h.source,D=this._checkSource(A);if(!D)return;const F=D.type,z=F==="vector"?h.sourceLayer:void 0;if(F==="vector"&&!z)return void this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")));if(x&&typeof h.id!="string"&&typeof h.id!="number")return void this.fire(new i.y(new Error("A feature id is required to remove its specific state property.")));const V=this.getOwnSourceCaches(A);for(const X of V)X.removeFeatureState(z,h.id,x)}getFeatureState(h){if(this._checkLoaded(),"target"in h){let F;if("featuresetId"in h.target){const{featuresetId:z,importId:V}=h.target,X=this.getFragmentStyle(V),ne=X.getFeaturesetLayers(z);for(const{source:oe,sourceLayer:ge}of ne){const pe=X.getFeatureState({id:h.id,source:oe,sourceLayer:ge});if(pe&&!F)F=pe;else if(!i.by(F,pe))return void this.fire(new i.y(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in h.target){const{layerId:z}=h.target,V=this.getLayer(z);F=this.getFeatureState({id:h.id,source:V.source,sourceLayer:V.sourceLayer})}return F}const x=h.source,A=h.sourceLayer,D=this._checkSource(x);if(D){if(D.type!=="vector"||A)return h.id===void 0&&this.fire(new i.y(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(x)[0].getFeatureState(A,h.id);this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(h){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,h),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}serialize(){this._checkLoaded();const h=this.getTerrain(),x=h&&this.terrain&&this.terrain.scope===this.scope?h:this.stylesheet.terrain;return i.dv({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:x,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},A=>A!==void 0)}_updateFilteredLayers(h){for(const x of Object.values(this._mergedLayers))h(x)&&this._updateLayer(x)}_updateLayer(h){this._changes.updateLayer(h);const x=this.getLayerSourceCache(h),A=i.B(h.source,h.scope),D=this._changes.getUpdatedSourceCaches();h.source&&!D[A]&&x&&x.getSource().type!=="raster"&&(this._changes.updateSourceCache(A,"reload"),x.pause()),h.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(h){const x=V=>this._mergedLayers[V].is3D(!!this.terrain),A=this.order,D={},F=[];for(let V=A.length-1;V>=0;V--){const X=A[V];if(x(X)){D[X]=V;for(const ne of h){const oe=ne[X];if(oe)for(const ge of oe)F.push(ge)}}}F.sort((V,X)=>X.intersectionZ-V.intersectionZ);const z=[];for(let V=A.length-1;V>=0;V--){const X=A[V];if(x(X))for(let ne=F.length-1;ne>=0;ne--){const oe=F[ne].feature;if(oe.layer&&D[oe.layer.id]{if(TS.has(oe.type))return;const ge=this.getOwnLayerSourceCache(oe),pe=F[ge.id]=F[ge.id]||{sourceCache:ge,layers:{},has3DLayers:!1};oe.is3D(!!this.terrain)&&(pe.has3DLayers=!0),pe.layers[oe.fqid]=pe.layers[oe.fqid]||{styleLayer:oe,targets:[]},pe.layers[oe.fqid].targets.push({filter:D})};if(x&&x.layers){if(!Array.isArray(x.layers))return this.fire(new i.y(new Error("parameters.layers must be an Array."))),[];for(const oe of x.layers){const ge=this._layers[oe];if(!ge)return this.fire(new i.y(new Error(`The layer '${oe}' does not exist in the map's style and cannot be queried for features.`))),[];z(ge)}}else for(const oe in this._layers)z(this._layers[oe]);const V=this._queryRenderedFeatures(h,F,A),X=this._flattenAndSortRenderedFeatures(V),ne=[];for(const oe of X)i.dw(oe.layer.id)===this.scope&&ne.push(oe);return ne}queryRenderedFeatureset(h,x,A){let D;x&&!Array.isArray(x)&&x.filter&&(this._validate(yi,"queryRenderedFeatures.filter",x.filter,null,x),D=i.b6(x.filter));const F="mock",z=[];if(x&&x.target)z.push(Object.assign({},x,{targetId:F,filter:D}));else{const oe=this.getFeaturesetDescriptors();for(const ge of oe)z.push({targetId:F,filter:D,target:ge});for(const{style:ge}of this.fragments){const pe=ge.getFeaturesetDescriptors();for(const xe of pe)z.push({targetId:F,filter:D,target:xe})}}const V=this.queryRenderedTargets(h,z,A),X=[],ne=new Set;for(const oe of V)for(const ge of oe.variants[F])ax(ge,oe,ne)||X.push(new i.dx(oe,ge));return X}queryRenderedTargets(h,x,A){const D={},F=(V,X,ne,oe)=>{const ge=D[X.id]=D[X.id]||{sourceCache:X,layers:{},has3DLayers:!1};if(ge.layers[V.fqid]=ge.layers[V.fqid]||{styleLayer:V,targets:[]},V.is3D(!!this.terrain)&&(ge.has3DLayers=!0),!oe)return ne.uniqueFeatureID=!1,void ge.layers[V.fqid].targets.push(ne);ge.layers[V.fqid].targets.push(Object.assign({},ne,{namespace:oe.namespace,properties:oe.properties,uniqueFeatureID:oe.uniqueFeatureID}))};for(const V of x)if("featuresetId"in V.target){const{featuresetId:X,importId:ne}=V.target,oe=this.getFragmentStyle(ne);if(!oe||!oe._featuresetSelectors)continue;const ge=oe._featuresetSelectors[X];if(!ge){this.fire(new i.y(new Error(`The featureset '${X}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const pe of ge){const xe=oe.getOwnLayer(pe.layerId);xe&&!TS.has(xe.type)&&F(xe,oe.getOwnLayerSourceCache(xe),V,pe)}}else if("layerId"in V.target){const{layerId:X}=V.target,ne=this.getLayer(X);if(!ne||TS.has(ne.type))continue;F(ne,this.getLayerSourceCache(ne),V)}const z=this._queryRenderedFeatures(h,D,A);return this._flattenAndSortRenderedFeatures(z)}_queryRenderedFeatures(h,x,A){const D=[],F=!!this.map._showQueryGeometry,z=Qi.createFromScreenPoints(h,A);for(const V in x){const X=pv(z,x[V],this._availableImages,A,F);Object.keys(X).length&&D.push(X)}if(this.placement)for(const V in x){if(!x[V].sourceCache._onlySymbols)continue;const X=fv(z.screenGeometry,x[V],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(X).length&&D.push(X)}return D}querySourceFeatures(h,x){const A=x&&x.filter;A&&this._validate(yi,"querySourceFeatures.filter",A,null,x);let D=[];const F=this.getOwnSourceCaches(h);for(const z of F)D=D.concat(gv(z,x));return D}addSourceType(h,x,A){return cm.getSourceType(h)?A(new Error(`A source type called "${h}" already exists.`)):(cm.setSourceType(h,x),x.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:h,url:x.workerSourceURL},A):A(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(h,x,A={}){this._checkLoaded();const D=this.light.getLight();let F=!1;for(const V in h)if(!i.by(h[V],D[V])){F=!0;break}if(!F)return;const z=this._getTransitionParameters();this.light.setLight(h,x,A),this.light.updateTransitions(z)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){this.disableElevatedTerrain===void 0&&(this.disableElevatedTerrain=i.o.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&i.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(h,x=1){if(this._checkLoaded(),!h)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),x===0&&delete this.terrain,h===null?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let A=h;const D=!("source"in h)||h.source==null;if(x===1){if(this.disableElevatedTerrain)return;if("source"in A&&typeof A.source=="object"){const V="terrain-dem-src";this.addSource(V,A.source),A=i.dp(A),A=Object.assign(A,{source:V})}const F=Object.assign({},A),z={};if(this.terrain&&D){F.source=this.terrain.get().source;const V=this.terrain?this.getFragmentStyle(this.terrain.scope):null;V&&(z.style=V.serialize())}if(this._validate(Ra,"terrain",F,z))return}if(!this.terrain||this.terrain.scope!==this.scope&&!D||this.terrain&&x!==this.terrain.drapeRenderMode){if(!A)return;this._createTerrain(A,x),this.fire(new i.z("data",{dataType:"style"}))}else{const F=this.terrain,z=F.get();for(const V of Object.keys(i.a6.terrain))!A.hasOwnProperty(V)&&i.a6.terrain[V].default&&(A[V]=i.a6.terrain[V].default);for(const V in h)if(!i.by(h[V],z[V])){F.set(h,this.options),this.stylesheet.terrain=h;const X=this._getTransitionParameters({duration:0});F.updateTransitions(X),this.fire(new i.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(h){const x=this.fog=new wn(h,this.map.transform,this.scope,this.options);this.stylesheet.fog=x.get();const A=this._getTransitionParameters({duration:0});x.updateTransitions(A)}_createSnow(h){const x=this.snow=new Ko(h,this.map.transform,this.scope,this.options);this.stylesheet.snow=x.get();const A=this._getTransitionParameters({duration:0});x.updateTransitions(A)}_createRain(h){const x=this.rain=new Xi(h,this.map.transform,this.scope,this.options);this.stylesheet.rain=x.get();const A=this._getTransitionParameters({duration:0});x.updateTransitions(A)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const h of this.map._markers)h._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(h){if(this._checkLoaded(),!h)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const x=this.fog;if(!i.by(x.get(),h)){x.set(h,this.options),this.stylesheet.fog=x.get();const A=this._getTransitionParameters({duration:0});x.updateTransitions(A)}}else this._createFog(h);this._markersNeedUpdate=!0}getSnow(){return this.snow?this.snow.get():null}setSnow(h){if(this._checkLoaded(),!h)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const x=this.snow;if(!i.by(x.get(),h)){x.set(h,this.options),this.stylesheet.snow=x.get();const A=this._getTransitionParameters({duration:0});x.updateTransitions(A)}}else this._createSnow(h);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(h){if(this._checkLoaded(),!h)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const x=this.rain;if(!i.by(x.get(),h)){x.set(h,this.options),this.stylesheet.rain=x.get();const A=this._getTransitionParameters({duration:0});x.updateTransitions(A)}}else this._createRain(h);this._markersNeedUpdate=!0}_reloadColorTheme(){const h=()=>{for(const D in this._layers)this._layers[D].lut=this._styleColorTheme.lut;for(const D in this._sourceCaches)this._sourceCaches[D].clearTiles()},x=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!x)return this._styleColorTheme.lut=null,void h();const A=this._evaluateColorThemeData(x);this._loadColorTheme(A).then(()=>{this.fire(new i.z("colorthemeset")),h()}).catch(D=>{i.w(`Couldn't set color theme: ${D}`)})}setColorTheme(h){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&i.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=h,this._reloadColorTheme()}setImportColorTheme(h,x){const A=this.getFragmentStyle(h);A&&(A._styleColorTheme.colorThemeOverride=x,A._reloadColorTheme())}_getTransitionParameters(h){return{now:i.o.now(),transition:Object.assign(this.transition,h)}}updateDrapeFirstLayers(){if(!this.terrain)return;const h=[],x=[];for(const A of this._mergedOrder)this.isLayerDraped(this._mergedLayers[A])?h.push(A):x.push(A);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...h),this._drapedFirstOrder.push(...x)}_createTerrain(h,x){const A=this.terrain=new qt(h,x,this.scope,this.options,this.map.getWorldview());x===1&&(this.stylesheet.terrain=h),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const D=this._getTransitionParameters({duration:0});A.updateTransitions(D)}_force3DLayerUpdate(){for(const h in this._layers){const x=this._layers[h];x.type==="fill-extrusion"&&this._updateLayer(x)}}_forceSymbolLayerUpdate(){for(const h in this._layers){const x=this._layers[h];x.type==="symbol"&&this._updateLayer(x)}}_validate(h,x,A,D,F={}){if(F&&F.validate===!1)return!1;const z=Object.assign({},this.serialize());return ux(this,h.call(Zt,Object.assign({key:x,style:z,value:A,styleSpec:i.a6},D)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.dy.off("pluginStateChange",this._rtlTextPluginCallback);for(const h in this._mergedLayers)this._mergedLayers[h].setEventedParent(null);for(const h in this._mergedSourceCaches)this._mergedSourceCaches[h].clearTiles(),this._mergedSourceCaches[h].setEventedParent(null);this.imageManager.removeScope(this.scope),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove())}clearSource(h){const x=this.getSourceCaches(h);for(const A of x)A.clearTiles()}clearSources(){for(const h in this._mergedSourceCaches)this._mergedSourceCaches[h].clearTiles()}clearLayers(){for(const h in this._mergedLayers){const x=this._mergedLayers[h];x._clear&&x._clear()}}reloadSource(h){const x=this.getSourceCaches(h);for(const A of x)A.resume(),A.reload()}reloadSources(){for(const h of this.getSources())h.reload&&h.reload()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(h=>{h.modelManager.reloadModels(h.scope)})}updateSources(h){let x;this.directionalLight&&(x=xb(this.directionalLight));const A=new Set,D=new Set;for(const F in this._mergedLayers){const z=this._mergedLayers[F];z.type==="building"&&A.add(z.source),z.hasElevation()&&!D.has(z.source)&&D.add(z.source)}for(const F in this._mergedSourceCaches){const z=this._mergedSourceCaches[F],V=D.has(z._source.id);A.has(z._source.id)&&(z._source.reparseOverscaled=!1),z.update(h,void 0,void 0,x,V)}}_generateCollisionBoxes(){for(const h in this._sourceCaches){const x=this._sourceCaches[h];x.resume(),x.reload()}}_updatePlacement(h,x,A,D,F,z,V=!1){let X=!1,ne=!1;const oe={},ge={};for(const Ce of this._mergedOrder){const Ve=this._mergedLayers[Ce];if(Ve.type!=="symbol")continue;const Be=i.B(Ve.source,Ve.scope);let tt=oe[Be];if(!tt){const st=this.getLayerSourceCache(Ve);if(!st)continue;const Mt=st.getRenderableIds(!0).map(yt=>st.getTileByID(yt));ge[Be]=Mt.slice(),tt=oe[Be]=Mt.sort((yt,jt)=>jt.tileID.overscaledZ-yt.tileID.overscaledZ||(yt.tileID.isLessThan(jt.tileID)?-1:1))}const dt=this.crossTileSymbolIndex.addLayer(Ve,tt,x.center.lng,x.projection);X=X||dt}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),V=V||this._layerOrderChanged,this._layerOrderChanged&&this.fire(new i.z("neworder"));const pe=!!(this.placement&&!x.equals(this.placement.transform)),xe=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!z||this.placement.lastReplacementSourceUpdateTime!==z.updateTime)),Pe=(pe||xe||X||this.placement&&this.placement.isStale())&&D===0;if((V||!this.pauseablePlacement||Pe||D!==0&&this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.o.now(),x.zoom))&&(this.pauseablePlacement=new oc(x,this._mergedOrder,V||D===0,A,D,F,this.placement,this.fog&&x.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,oe,ge,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.o.now()),ne=!0),X&&this.pauseablePlacement.placement.setStale()),ne||X){this._buildingIndex.onNewFrame(x.zoom);for(let Ce=0;CeF===h.id)!==-1)return void this.fire(new i.y(new Error(`Import with id '${h.id}' already exists in the map's style.`)));if(!x)return A.push(h),this._loadImports([h],!0);const D=A.findIndex(({id:F})=>F===x);return D===-1&&this.fire(new i.y(new Error(`Import with id "${x}" does not exist on this map.`))),this.stylesheet.imports=A.slice(0,D).concat(h).concat(A.slice(D)),this._loadImports([h],!0,x)}updateImport(h,x){this._checkLoaded();const A=this.stylesheet.imports||[],D=this.getImportIndex(h);return D===-1?this:typeof x=="string"?(this.setImportUrl(h,x),this):(x.url&&x.url!==A[D].url&&this.setImportUrl(h,x.url),i.by(x.config,A[D].config)||this.setImportConfig(h,x.config,x.data.schema),i.by(x.data,A[D].data)||this.setImportData(h,x.data),this)}moveImport(h,x){this._checkLoaded();let A=this.stylesheet.imports||[];const D=this.getImportIndex(h);if(D===-1)return this;const F=this.getImportIndex(x);if(F===-1)return this;const z=A[D],V=this.fragments[D];return A=A.filter(({id:X})=>X!==h),this.fragments=this.fragments.filter(({id:X})=>X!==h),this.stylesheet.imports=A.slice(0,F).concat(z).concat(A.slice(F)),this.fragments=this.fragments.slice(0,F).concat(V).concat(this.fragments.slice(F)),this.mergeLayers(),this}setImportUrl(h,x){this._checkLoaded();const A=this.stylesheet.imports||[],D=this.getImportIndex(h);if(D===-1)return this;A[D].url=x;const F=this.fragments[D];return F.style=this._createFragmentStyle(A[D]),F.style.on("style.import.load",()=>this.mergeAll()),F.style.loadURL(x),this}setImportData(h,x){this._checkLoaded();const A=this.getImportIndex(h),D=this.stylesheet.imports||[];return A===-1?this:x?(this.fragments[A].style.setState(x),this._reloadImports(),this):(delete D[A].data,this.setImportUrl(h,D[A].url))}setImportConfig(h,x,A){this._checkLoaded();const D=this.getImportIndex(h),F=this.stylesheet.imports||[];if(D===-1)return this;x?F[D].config=x:delete F[D].config;const z=this.fragments[D];A&&z.style.stylesheet&&(z.style.stylesheet.schema=A);const V=z.style.stylesheet&&z.style.stylesheet.schema;return z.config=x,z.style.updateConfig(x,V),this.updateConfigDependencies(),this}removeImport(h){this._checkLoaded();const x=this.stylesheet.imports||[],A=this.getImportIndex(h);A!==-1&&(x.splice(A,1),this.fragments[A].style._remove(),this.fragments.splice(A,1),this._reloadImports())}getImportIndex(h){const x=(this.stylesheet.imports||[]).findIndex(A=>A.id===h);return x===-1&&this.fire(new i.y(new Error(`Import '${h}' does not exist in the map's style and cannot be updated.`))),x}getLayer(h){return this._mergedLayers[h]}getSources(){const h=[];for(const x in this._mergedOtherSourceCaches){const A=this._mergedOtherSourceCaches[x];A&&h.push(A.getSource())}return h}getSource(h,x){const A=this.getSourceCache(h,x);return A&&A.getSource()}getLayerSource(h){const x=this.getLayerSourceCache(h);return x&&x.getSource()}getSourceCache(h,x){const A=i.B(h,x);return this._mergedOtherSourceCaches[A]}getLayerSourceCache(h){const x=i.B(h.source,h.scope);return h.type==="symbol"?this._mergedSymbolSourceCaches[x]:this._mergedOtherSourceCaches[x]}getSourceCaches(h){if(h==null)return Object.values(this._mergedSourceCaches);const x=[];return this._mergedOtherSourceCaches[h]&&x.push(this._mergedOtherSourceCaches[h]),this._mergedSymbolSourceCaches[h]&&x.push(this._mergedSymbolSourceCaches[h]),x}updateSourceCaches(){const h=this._changes.getUpdatedSourceCaches();for(const x in h){const A=h[x];A==="reload"?this.reloadSource(x):A==="clear"&&this.clearSource(x)}}updateLayers(h){const x=this._changes.getUpdatedPaintProperties();for(const A of x){const D=this.getLayer(A);D&&D.updateTransitions(h)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(h){this.stylesheet.glyphs=h,this.glyphManager.setURL(h)}getImages(h,x,A){this.imageManager.getImages(x.images,x.scope,A),this._updateTilesForChangedImages();const D=z=>{if(z){const V=x.images.map(X=>i.I.toString(X));z.setDependencies(x.tileID.key,x.type,V)}},F=i.B(x.source,x.scope);D(this._mergedOtherSourceCaches[F]),D(this._mergedSymbolSourceCaches[F]),x.images.some(z=>z.iconsetId)&&this.fire(new i.z("data",{dataType:"style"}))}rasterizeImages(h,x,A){this.imageManager.rasterizeImages(x,A)}getGlyphs(h,x,A){this.glyphManager.getGlyphs(x.stacks,A)}getResource(h,x,A){return i.dz(x,A)}getOwnSourceCache(h){return this._otherSourceCaches[h]}getOwnLayerSourceCache(h){return h.type==="symbol"?this._symbolSourceCaches[h.source]:this._otherSourceCaches[h.source]}getOwnSourceCaches(h){const x=[];return this._otherSourceCaches[h]&&x.push(this._otherSourceCaches[h]),this._symbolSourceCaches[h]&&x.push(this._symbolSourceCaches[h]),x}_isSourceCacheLoaded(h){const x=this.getOwnSourceCaches(h);return x.length===0?(this.fire(new i.y(new Error(`There is no source with ID '${h}'`))),!1):x.every(A=>A.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(h,x){if(!this._clipLayerPresent&&h.type!=="fill-extrusion"&&h.type!=="building")return!1;const A=h.type==="fill-extrusion"&&(h.sourceLayer==="building"||h.sourceLayer==="procedural_buildings"),D=h.type==="building";if(h.is3D(!!this.terrain)){if(A||D||x&&x.type==="batched-model"||h.type==="model")return!0}else if(h.type==="symbol")return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.fragments.forEach(h=>{h.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}cm.getSourceType=function(M){return sm[M]},cm.setSourceType=function(M,h){sm[M]=h},cm.registerForPluginStateChange=i.dA;class jD extends i.E{constructor(h){super(),this._style=h,this._buildings={},this._activeFloors=new Set,this._activeFloorsVisible=!0,this._indoorState={selectedFloorId:null,lastActiveFloors:null,activeFloorsVisible:!0},i.aY(["_updateUI"],this)}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(h){h===this._selectedFloorId&&this._activeFloorsVisible||(this._selectedFloorId=h,this._activeFloorsVisible=!0,this._updateActiveFloors())}setActiveFloorsVisibility(h){this._activeFloorsVisible=h,this._updateActiveFloors(),this._updateIndoorSelector()}setIndoorData(h){for(const[x,A]of Object.entries(h.buildings))if(this._buildings[x])for(const D of A.floorIds)this._buildings[x].floors[D]||(this._buildings[x].floors[D]=A.floors[D]);else this._buildings[x]=A;for(const x of h.activeFloors)this._activeFloors.add(x);this._updateIndoorSelector()}getIndoorTileOptions(h,x){const A=this._style.getIndoorSourceLayers(h,x);return A&&this._indoorState?{sourceLayers:A,indoorState:this._indoorState}:null}_updateUI(h,x,A){const D=function(F,z,V,X){let ne=null,oe=Number.MAX_SAFE_INTEGER;if(X<16)return null;for(const[ge,pe]of Object.entries(F)){const xe=pe.center;if(xe){const Pe=z.distanceTo(i.aT.convert(xe));Pe({id:z,name:A.floors[z].name,zIndex:A.floors[z].zIndex})).sort((z,V)=>V.zIndex-z.zIndex);this.fire(new i.z("selector-update",{selectedFloorId:D,activeFloorsVisible:this._activeFloorsVisible,floors:F}))}_updateActiveFloors(){const h=this._activeFloors;this._activeFloors=new Set,this._indoorState={selectedFloorId:this._selectedFloorId,lastActiveFloors:h,activeFloorsVisible:this._activeFloorsVisible},this._style.updateIndoorDependentLayers()}}var jv=` #define EPSILON 0.0000001 #define PI 3.141592653589793 #ifdef RENDER_CUTOFF float cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);} #endif`,Nv=` #ifdef DUAL_SOURCE_BLENDING layout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1; #else layout(location=0) out vec4 glFragColor; #endif #ifdef USE_MRT1 layout(location=1) out vec4 out_Target1; #endif highp float unpack_depth(highp vec4 rgba_depth) {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;} #ifdef INDICATOR_CUTOUT uniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params; #endif vec4 applyCutout(vec4 color,float height) { #ifdef INDICATOR_CUTOUT float verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0); #else return color; #endif } #ifdef DEBUG_WIREFRAME #define HANDLE_WIREFRAME_DEBUG \\ glFragColor=vec4(0.7,0.0,0.0,0.7); \\ gl_FragDepth=gl_FragCoord.z-0.0001; #else #define HANDLE_WIREFRAME_DEBUG #endif #ifdef RENDER_CUTOFF uniform highp vec4 u_cutoff_params;in float v_cutoff_opacity; #endif vec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 applyLUT(highp sampler3D lut,vec4 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return vec4(texture(lut,uvw).rgb*col.a,col.a);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}`,cT=` #define EXTENT 8192.0 #define RAD_TO_DEG 180.0/PI #define DEG_TO_RAD PI/180.0 #define GLOBE_RADIUS EXTENT/PI/2.0 float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;} #ifdef PROJECTION_GLOBE_VIEW vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) { #ifndef PROJECTED_POS_ON_VIEWPORT float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz; #else return vec3(0.0); #endif }vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);} #endif vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4( unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0 );}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const vec2 units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (units_to_pixels*pos+offset)/pattern_size;}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {return get_pattern_pos(pixel_coord_upper,pixel_coord_lower,pattern_size,vec2(tile_units_to_pixels),pos);}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);} #ifdef RENDER_CUTOFF uniform vec4 u_cutoff_params;out float v_cutoff_opacity; #endif const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt) {float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);} #ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer #define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib #define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib #define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib #define DECLARE_MATERIAL_TABLE_INFO #endif`,AS="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",vh=` #define ELEVATION_SCALE 7.0 #define ELEVATION_OFFSET 450.0 #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix( mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;} #else vec3 elevationVector(vec2 pos) { return vec3(0,0,1); } #endif #ifdef TERRAIN uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float currentElevation(vec2 apos) { #ifdef TERRAIN_DEM_FLOAT_FORMAT vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r; #else float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y); #endif }float prevElevation(vec2 apos) { #ifdef TERRAIN_DEM_FLOAT_FORMAT vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem_prev,pos).r; #else float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y); #endif } #ifdef TERRAIN_VERTEX_MORPHING float elevation(vec2 apos) { #ifdef ZERO_EXAGGERATION return 0.0; #endif float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);} #else float elevation(vec2 apos) { #ifdef ZERO_EXAGGERATION return 0.0; #endif return currentElevation(apos);} #endif vec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);} #else float elevation(vec2 pos) { return 0.0; } #endif #ifdef DEPTH_OCCLUSION uniform highp sampler2D u_depth;uniform highp vec2 u_depth_size_inv;uniform highp vec2 u_depth_range_unpack;uniform highp float u_occluder_half_size;uniform highp float u_occlusion_depth_offset; #ifdef DEPTH_D24 float unpack_depth(float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}vec4 unpack_depth4(vec4 depth) {return depth*u_depth_range_unpack.x+vec4(u_depth_range_unpack.y);} #else highp float unpack_depth_rgba(vec4 rgba_depth) {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;} #endif bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w; #ifdef CLIP_ZERO_TO_ONE coord.z=-1.0+2.0*coord.z; #endif #ifdef DEPTH_D24 float depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r); #else float depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5)); #endif return coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5; #ifdef DEPTH_D24 highp vec4 depth=vec4( texture(u_depth,uv-df.xz).r,texture(u_depth,uv+df.xz).r,texture(u_depth,uv-df.zy).r,texture(u_depth,uv+df.zy).r );depth=unpack_depth4(depth); #else highp vec4 depth=vec4( unpack_depth_rgba(texture(u_depth,uv-df.xz)),unpack_depth_rgba(texture(u_depth,uv+df.xz)),unpack_depth_rgba(texture(u_depth,uv-df.zy)),unpack_depth_rgba(texture(u_depth,uv+df.zy)) ); #endif return depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5; #ifdef CLIP_ZERO_TO_ONE coord.z=-1.0+2.0*coord.z; #endif int NX=3;int NY=4;highp vec2 df=u_occluder_half_size*u_depth_size_inv;highp vec2 oneStep=2.0*u_occluder_half_size*u_depth_size_inv/vec2(NX-1,NY-1);highp float res=0.0;for (int y=0; y < NY;++y) {for (int x=0; x < NX;++x) { #ifdef DEPTH_D24 highp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r); #else highp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y))); #endif res+=1.0-clamp(300.0*(coord.z+u_occlusion_depth_offset-depth),0.0,1.0);}}res=clamp(2.0*res/float(NX*NY)-0.5,0.0,1.0);return res;}highp float occlusionFade(vec4 frag) {highp vec3 coord=frag.xyz/frag.w; #ifdef CLIP_ZERO_TO_ONE coord.z=-1.0+2.0*coord.z; #endif highp vec4 depth=getCornerDepths(coord.xy);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z+u_occlusion_depth_offset)-depth),0.0,1.0));} #else bool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; } #endif`,ES=`#ifdef FOG uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;out vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);} #endif`,Xs=`#ifdef FOG uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport; #ifdef FLIP_Y uv.y=1.0-uv.y; #endif highp vec3 ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {return color;}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);} #endif`,dT=`#ifdef RASTER_ARRAY uniform highp sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0) );}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0) );}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);} #endif`,PS=`#ifdef RASTER_ARRAY uniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec2 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;} #endif uniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}`,IS=`#ifdef RENDER_SHADOWS uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];} #endif`,uT=`#ifdef RENDER_SHADOWS precision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) { #ifdef CLIP_ZERO_TO_ONE highp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias); #else highp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z*0.5+0.5-bias); #endif return texture(shadowmap,coord);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {light_view_pos0.xyz/=light_view_pos0.w; #ifdef SHADOWS_SINGLE_CASCADE vec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias); #else light_view_pos1.xyz/=light_view_pos1.w;vec4 abs_bounds=abs(vec4(light_view_pos0.xy,light_view_pos1.xy));if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}float occlusion1=shadow_sample(u_shadowmap_1,light_view_pos1.xyz,bias);return clamp(mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth)),0.0,1.0); #endif }highp float calculate_shadow_bias(float NDotL) { #ifdef NORMAL_OFFSET return 0.5*u_shadow_bias.x; #else return 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z)); #endif }float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias)*shadow_opacity;return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy) {highp vec2 biasUV=vec2( pos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);} #endif`;const vb=/#include\s+"([^"]+)"/g,Op=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,hT=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,Py=new Set(["ifdef","ifndef","elif","if","defined"]),Iy=new Set;px(jv,Iy),px(cT,Iy),px(Nv,Iy);const mx={"_prelude_fog.vertex.glsl":ES,"_prelude_terrain.vertex.glsl":vh,"_prelude_shadow.vertex.glsl":IS,"_prelude_material_table.vertex.glsl":`#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer #define MATERIAL_TABLE_DEBUG 0 uniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset; #if MATERIAL_TABLE_DEBUG vec4 colorDebug; #endif };uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) { if (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u; }uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else { iRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info; #if MATERIAL_TABLE_DEBUG const vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green; #endif uint offset=0u; #if MATERIAL_TABLE_DEBUG bool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;} #endif offset++; #if MATERIAL_TABLE_DEBUG uint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;} #endif offset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++); #if MATERIAL_TABLE_DEBUG if(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;} #endif uint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset); #if MATERIAL_TABLE_DEBUG if(keepFinding) {uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}} #endif offset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup; #if MATERIAL_TABLE_DEBUG if(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}} #endif info.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes) {uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);} #define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset) #define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset) #define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset) #define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); #define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug; #endif`,"_prelude_fog.fragment.glsl":Xs,"_prelude_shadow.fragment.glsl":uT,"_prelude_lighting.glsl":` #ifdef LIGHTING_3D_MODE uniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);} #endif`,"_prelude_raster_array.glsl":dT,"_prelude_raster_particle.glsl":PS},LS={};Sa("",vh),Sa(Xs,ES),Sa(uT,IS),Sa(dT,""),Sa(PS,"");const ND=Sa(Nv,cT),DS=jv,Zce=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",DS,ND.fragmentSource].join(` `),kD=["precision highp float;",DS,ND.vertexSource].join(` `);var mT={background:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength; #ifdef LIGHTING_3D_MODE in vec4 v_color; #endif void main() {vec4 out_color; #ifdef LIGHTING_3D_MODE out_color=v_color; #else out_color=u_color; #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif glFragColor=out_color*u_opacity; #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_lighting.glsl" in vec2 a_pos;uniform mat4 u_matrix;uniform mediump float u_emissive_strength; #ifdef LIGHTING_3D_MODE uniform mediump vec4 u_color;out vec4 v_color; #endif void main() {gl_Position=u_matrix*vec4(a_pos,0,1); #ifdef LIGHTING_3D_MODE v_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength); #endif #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),backgroundPattern:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos); #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif glFragColor=out_color*u_opacity; #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec2 u_pattern_units_to_pixels;in vec2 a_pos;out highp vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,a_pos); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),building:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" const float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos; #ifdef BUILDING_FAUX_FACADE in lowp float v_faux_facade;in highp float v_faux_facade_ed;in highp vec2 v_faux_facade_window;in highp vec2 v_faux_facade_floor;in highp vec2 v_faux_facade_range;in highp float v_aspect;in highp vec3 v_tbn_0;in highp vec3 v_tbn_1;in highp vec3 v_tbn_2;in highp vec4 v_faux_color_emissive;uniform float u_faux_facade_ao_intensity; #endif #ifdef RENDER_SHADOWS in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1; #endif #ifdef FLOOD_LIGHT in highp float v_flood_radius;in float v_has_flood_light; #endif uniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));} #ifdef BUILDING_FAUX_FACADE float hash12(in vec2 p) {vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}vec2 get_uv_mask_id(in vec2 q,out float mask,out vec2 id) {vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;vec2 uv=modf(p/v_faux_facade_floor,id);vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;vec4 edge=d/v_faux_facade_floor.xyxy;vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}float ray_unit_box(in vec3 ray_o,in vec3 ray_d,in vec3 bmin,in vec3 bmax) {vec3 planes=mix(bmin,bmax,step(0.0,ray_d));vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in vec3 v,in vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y; #if 0 if (x_major) {out_color=v.x > 0.0 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,1.0);} else if (y_major) {out_color=v.y > 0.0 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,1.0);} else if (z_major) {out_color=v.z > 0.0 ? vec3(0.0,0.0,1.0) : vec3(1.0,1.0,0.0);}out_emissive=1.0; #else if (x_major) {out_normal=sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao; #endif return out_color;} #endif vec3 apply_lighting_linear(in vec3 color,in vec3 normal,in float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return color*(ambient_contrib+directional_contrib);}void main() {vec3 normal=normalize(v_normal);vec3 base_color=v_color.rgb;float emissive=v_color.a; #ifdef BUILDING_FAUX_FACADE if (v_faux_facade > 0.0) {mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;vec3 view_tangent=transpose(tbn)*v;vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;vec3 bmin=vec3(0.0,0.0,-window_depth);vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);vec3 ray_o=vec3(uv,0.0);vec3 ray_d=normalize(view_tangent);float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);vec3 hit=ray_o+t_min*ray_d;vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);} #endif vec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0; #ifdef RENDER_SHADOWS #ifdef RENDER_CUTOFF shadowed_lighting_factor=shadowed_light_factor_normal_opacity(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;} #else shadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w); #endif #else shadowed_lighting_factor=dot(xy_flipped_normal,u_lighting_directional_dir); #endif color.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb); #ifdef FLOOD_LIGHT float flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance); #endif color.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive); #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z)); #endif color*=u_opacity; #ifdef INDICATOR_CUTOUT color=applyCutout(color,v_pos.z); #endif #ifdef FEATURE_CUTOUT color=apply_feature_cutout(color,gl_FragCoord); #endif glFragColor=color; #ifdef DEBUG_SHOW_NORMALS color.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color; #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in vec3 a_pos_3f;in vec3 a_normal_3;in vec3 a_centroid_3;in float a_flood_light_wall_radius_1i16;in vec4 a_faux_facade_data;in vec2 a_faux_facade_vertical_range;uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;out vec4 v_color;out vec3 v_normal;out highp vec3 v_pos; #ifdef BUILDING_FAUX_FACADE out lowp float v_faux_facade;out highp float v_faux_facade_ed;out highp vec2 v_faux_facade_window;out highp vec2 v_faux_facade_floor;out highp vec2 v_faux_facade_range;out highp float v_aspect;out highp vec3 v_tbn_0;out highp vec3 v_tbn_1;out highp vec3 v_tbn_2;out highp vec4 v_faux_color_emissive; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1; #endif #ifdef FLOOD_LIGHT out highp float v_flood_radius;out float v_has_flood_light; #endif const float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));} #ifdef BUILDING_FAUX_FACADE mat3 get_tbn(in vec3 normal) {const vec3 bitangent=vec3(0.0,0.0,1.0);vec3 tangent=normalize(vec3(normal.y,-normal.x,0.0));return mat3(tangent,bitangent,normal);} #endif #pragma mapbox: define-attribute-vertex-shader-only highp vec2 part_color_emissive #pragma mapbox: define-attribute-vertex-shader-only highp vec2 faux_facade_color_emissive void main() { #pragma mapbox: initialize-attribute-custom highp vec2 part_color_emissive #pragma mapbox: initialize-attribute-custom highp vec2 faux_facade_color_emissive #ifdef FLOOD_LIGHT v_flood_radius=(a_flood_light_wall_radius_1i16/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius); #endif vec4 color_emissive=decode_color(part_color_emissive);v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=a_normal_3/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;float depth_offset=0.0; #ifdef BUILDING_FAUX_FACADE v_faux_facade=a_faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=a_faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(a_faux_facade_data.y/TWO_POW_8);float window_y_perc=a_faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(a_faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(a_faux_facade_vertical_range/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(faux_facade_color_emissive);v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);float height=a_centroid_3.z;depth_offset=min(1000.0,height)*0.0000002;} #endif v_pos=a_pos_3f; #ifdef RENDER_CUTOFF vec4 ground=u_matrix*vec4(a_centroid_3,1.0);v_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity; #endif #ifdef RENDER_SHADOWS vec3 shadow_pos=v_pos; #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1.0); #endif #ifdef FOG v_fog_pos=fog_position(v_pos); #endif gl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w;}`),buildingBloom:Sa(`in vec4 v_color_emissive; #pragma mapbox: define-attribute highp vec4 bloom_attenuation #pragma mapbox: initialize-attribute highp vec4 bloom_attenuation float saturate(float val) {return clamp(val,0.0,1.0);}void main() {float emission=v_color_emissive.a;float opacity=1.0; #ifdef HAS_ATTRIBUTE_a_bloom_attenuation float distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance); #endif #ifdef RENDER_CUTOFF opacity*=v_cutoff_opacity; #endif glFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}`,`in vec3 a_pos_3f; #pragma mapbox: define-attribute-vertex-shader-only highp vec2 part_color_emissive #pragma mapbox: define-attribute highp vec4 bloom_attenuation out vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() { #pragma mapbox: initialize-attribute-custom highp vec2 part_color_emissive #pragma mapbox: initialize-attribute highp vec4 bloom_attenuation #ifdef HAS_ATTRIBUTE_a_part_color_emissive vec4 color_emissive=decode_color(part_color_emissive);float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive); #else v_color_emissive=vec4(1.0); #endif gl_Position=u_matrix*vec4(a_pos_3f,1.0); #ifdef RENDER_CUTOFF v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z); #endif }`),buildingDepth:Sa(`in highp float v_depth;void main() { #ifndef DEPTH_TEXTURE glFragColor=pack_depth(v_depth); #endif }`,"in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);v_depth=gl_Position.z/gl_Position.w;}"),circle:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" in vec3 v_data;in float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity uniform float u_emissive_strength;void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=v_data.xy;float blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float antialiase_blur_opacity=smoothstep(0.0,antialiasblur,extrude_length-1.0);float opacity_t=blur_positive==1.0 ? smoothstep(0.0,-antialiased_blur,1.0-extrude_length) : smoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;float color_t=stroke_width < 0.01 ? 0.0 : smoothstep( antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width) );vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t); #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #endif #ifdef FOG out_color=fog_apply_premultiplied(out_color,v_fog_pos); #endif glFragColor=out_color*(v_visibility*opacity_t); #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif }`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" #define NUM_VISIBILITY_RINGS 2 #define INV_SQRT2 0.70710678 #define ELEVATION_BIAS 0.0001 #define NUM_SAMPLES_PER_RING 16 uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in vec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW in vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir; #endif #ifdef ELEVATED_ROADS in float a_circle_z_offset; #endif out vec3 v_data;out float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) { #if defined(TERRAIN) return elevation(pos)+ELEVATION_BIAS; #else return 0.0; #endif }vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale); #ifdef PITCH_WITH_MAP #ifdef PROJECTION_GLOBE_VIEW return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) ); #else return u_matrix*( world_center+vec4(sample_offset,0,0) ); #endif #else return projected_center+vec4(sample_offset,0,0); #endif }float get_sample_step() { #ifdef PITCH_WITH_MAP return 2.0*PI/float(NUM_SAMPLES_PER_RING); #else return PI/float(NUM_SAMPLES_PER_RING); #endif }void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors; #ifdef PROJECTION_GLOBE_VIEW vec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1); #else surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1); #endif #ifdef ELEVATED_ROADS world_center.z+=a_circle_z_offset+ELEVATION_BIAS; #endif vec4 projected_center=u_matrix*world_center;float view_scale=0.0; #ifdef PITCH_WITH_MAP #ifdef SCALE_WITH_MAP view_scale=1.0; #else view_scale=projected_center.w/u_camera_to_center_distance; #endif #else #ifdef SCALE_WITH_MAP view_scale=u_camera_to_center_distance; #else view_scale=projected_center.w; #endif #endif gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0; #ifdef TERRAIN float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center; #ifdef PITCH_WITH_MAP float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center; #else occlusion_world_center=world_center;occlusion_projected_center=projected_center; #endif for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING); #else visibility=1.0; #endif #ifdef PROJECTION_GLOBE_VIEW visibility=1.0; #endif v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur); #ifdef FOG v_fog_pos=fog_position(world_center.xyz); #endif }`),clippingMask:Sa("void main() {glFragColor=vec4(1.0);}","in vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Sa(`#include "_prelude_fog.fragment.glsl" uniform highp float u_intensity;in vec2 v_extrude; #pragma mapbox: define highp float weight #define GAUSS_COEF 0.3989422804014327 void main() { #pragma mapbox: initialize highp float weight float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0); #ifdef FOG if (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);} #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl" #include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in vec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW in vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir; #endif out vec2 v_extrude; #pragma mapbox: define highp float weight #pragma mapbox: define mediump float radius const highp float ZERO=1.0/255.0/16.0; #define GAUSS_COEF 0.3989422804014327 void main() { #pragma mapbox: initialize highp float weight #pragma mapbox: initialize mediump float radius vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos; #ifdef PROJECTION_GLOBE_VIEW vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #else pos=vec3(tilePos+extrude,elevation(tilePos)); #endif gl_Position=u_matrix*vec4(pos,1); #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),heatmapTexture:Sa(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));glFragColor=color*u_opacity; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(0.0); #endif HANDLE_WIREFRAME_DEBUG;}`,"in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Sa("in float v_placed;in float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`#include "_prelude_terrain.vertex.glsl" in vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 a_placed;in vec2 a_shift;in vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance; #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition; #endif out float v_placed;out float v_notUsed;void main() {float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(a_anchor_pos));vec3 proj_pos=a_pos+elevationVector(a_anchor_pos)*(feature_elevation+terrain_elevation); #ifdef PROJECTION_GLOBE_VIEW #ifndef PROJECTED_POS_ON_VIEWPORT vec3 globe_pos=proj_pos;vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,a_anchor_pos,u_tile_id,u_merc_center);proj_pos=mix_globe_mercator(globe_pos,mercator_pos,u_zoom_transition); #endif #endif vec4 projectedPoint=u_matrix*vec4(proj_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp( 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:Sa("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);glFragColor=color*alpha*opacity_t;}",`in vec2 a_pos_2f;in float a_radius;in vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2( mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp( 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:Sa("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",`#include "_prelude_terrain.vertex.glsl" in vec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW in vec3 a_pos_3; #endif out vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0; #ifdef PROJECTION_GLOBE_VIEW gl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1); #else gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1); #endif }`),elevatedStructuresDepth:Sa(`void main() { #ifndef DEPTH_TEXTURE glFragColor=vec4(0.); #endif }`,"in vec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructuresDepthReconstruct:Sa(`#ifdef DEPTH_RECONSTRUCTION in float v_height; #endif void main() { #ifdef DEPTH_RECONSTRUCTION if (v_height >=0.0) discard; #else #ifdef FEATURE_CUTOUT apply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord); #endif #endif glFragColor=vec4(1.0,0.0,0.0,1.0);}`,`in vec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth; #ifdef DEPTH_RECONSTRUCTION out float v_height; #endif void main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale); #ifdef DEPTH_RECONSTRUCTION if (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height; #endif gl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}`),elevatedStructures:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" in vec3 v_normal;in float v_height; #ifdef RENDER_SHADOWS in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth; #endif vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color) {color=sRGBToLinear(color);color=color*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);color=linearTosRGB(color.rgb);return color;}uniform float u_emissive_strength; #pragma mapbox: define highp vec4 structure_color void main() { #pragma mapbox: initialize highp vec4 structure_color vec3 color=structure_color.xyz; #ifdef LIGHTING_3D_MODE vec3 normal=normalize(v_normal);vec3 transformed_normal=vec3(-normal.xy,normal.z);float ndotl=calculate_NdotL(transformed_normal);float emissive_strength=u_emissive_strength;emissive_strength=0.0;vec3 emissive_color=compute_view_dependent_emissive_color(ndotl,emissive_strength,color.xyz); #ifdef RENDER_SHADOWS float shadowed_lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color.rgb=apply_lighting(color.rgb,transformed_normal,shadowed_lighting_factor); #else color=apply_lighting(color,transformed_normal); #endif color=mix(color,emissive_color,emissive_strength);if (v_height < 0.0) {float penetration=max(v_height+7.5,0.0);float occlusion=1.0-1.0/PI*acos(1.0-penetration/4.0);color=color*(1.0-pow(occlusion,2.0)*0.3);} #endif #ifdef FOG color=fog_apply(color,v_fog_pos); #endif vec4 out_color=vec4(color,1.0); #ifdef INDICATOR_CUTOUT out_color=applyCutout(out_color,v_height); #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord); #endif glFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in vec2 a_pos;in float a_height;in vec3 a_pos_normal_3;uniform mat4 u_matrix;out vec3 v_normal;out float v_height; #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth; #endif #pragma mapbox: define highp vec4 structure_color void main() { #pragma mapbox: initialize highp vec4 structure_color v_normal=a_pos_normal_3/16384.0;v_height=a_height;vec3 pos=vec3(a_pos,a_height);gl_Position=u_matrix*vec4(pos,1); #ifdef RENDER_SHADOWS vec3 shd_pos0=pos;vec3 shd_pos1=pos; #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(vec3(-v_normal.xy,v_normal.z));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fill:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity uniform float u_emissive_strength; #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #ifdef ELEVATED_ROADS in highp float v_road_z_offset; #endif #ifdef INDICATOR_CUTOUT in highp float v_z_offset; #endif void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity vec4 out_color=color; #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif out_color*=opacity; #ifdef INDICATOR_CUTOUT if (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);} #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord); #endif glFragColor=out_color; #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in vec2 a_pos; #ifdef ELEVATED_ROADS in float a_road_z_offset;out highp float v_road_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif #ifdef INDICATOR_CUTOUT out highp float v_z_offset; #endif uniform mat4 u_matrix; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity #pragma mapbox: define highp float z_offset void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp float z_offset #ifdef ELEVATED_ROADS z_offset+=a_road_z_offset;v_road_z_offset=z_offset; #endif float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden); #ifdef RENDER_SHADOWS vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset); #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef FOG v_fog_pos=fog_position(a_pos); #endif #ifdef INDICATOR_CUTOUT v_z_offset=z_offset; #endif }`),fillOutline:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" in highp vec2 v_pos;uniform float u_emissive_strength; #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color; #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord); #endif glFragColor=out_color*(alpha*opacity); #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in vec2 a_pos; #ifdef ELEVATED_ROADS in float a_road_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif uniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity #pragma mapbox: define highp float z_offset void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp float z_offset #ifdef ELEVATED_ROADS z_offset+=a_road_z_offset; #endif float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden); #ifdef FLIP_Y v_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world; #else v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; #endif #ifdef RENDER_SHADOWS vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset); #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillOutlinePattern:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" uniform vec2 u_texsize;uniform sampler2D u_image; #ifdef FILL_PATTERN_TRANSITION uniform float u_pattern_transition; #endif uniform float u_emissive_strength; #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif in highp vec2 v_pos;in highp vec2 v_pos_world; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump vec4 pattern_b #endif void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump vec4 pattern_b #endif vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos); #ifdef APPLY_LUT_ON_GPU out_color=applyLUT(u_lutTexture,out_color); #endif #ifdef FILL_PATTERN_TRANSITION vec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition; #endif #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif glFragColor=out_color*(alpha*opacity); #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos; #ifdef ELEVATED_ROADS in float a_road_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif out highp vec2 v_pos;out highp vec2 v_pos_world; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump vec4 pattern_b #endif #pragma mapbox: define lowp float pixel_ratio #pragma mapbox: define highp float z_offset void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump vec4 pattern_b #endif #pragma mapbox: initialize lowp float pixel_ratio #pragma mapbox: initialize highp float z_offset vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw; #ifdef ELEVATED_ROADS z_offset+=a_road_z_offset; #endif float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos); #ifdef FLIP_Y v_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world; #else v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; #endif #ifdef RENDER_SHADOWS vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset); #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillPattern:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" uniform vec2 u_texsize;uniform sampler2D u_image; #ifdef FILL_PATTERN_TRANSITION uniform float u_pattern_transition; #endif in highp vec2 v_pos;uniform float u_emissive_strength; #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #ifdef ELEVATED_ROADS in highp float v_road_z_offset; #endif #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump vec4 pattern_b #endif void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump vec4 pattern_b #endif vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos); #ifdef APPLY_LUT_ON_GPU out_color=applyLUT(u_lutTexture,out_color); #endif #ifdef FILL_PATTERN_TRANSITION vec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition; #endif #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth); #ifdef ELEVATED_ROADS out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light); #else out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif glFragColor=out_color*opacity; #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos; #ifdef ELEVATED_ROADS in float a_road_z_offset;out highp float v_road_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif out highp vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump vec4 pattern_b #endif #pragma mapbox: define lowp float pixel_ratio #pragma mapbox: define highp float z_offset void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio #pragma mapbox: initialize highp float z_offset #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump vec4 pattern_b #endif vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio; #ifdef ELEVATED_ROADS z_offset+=a_road_z_offset;v_road_z_offset=z_offset; #endif float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos); #ifdef RENDER_SHADOWS vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset); #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillExtrusion:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" in vec4 v_color;in vec4 v_flat; #ifdef RENDER_SHADOWS in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1; #endif uniform lowp float u_opacity; #ifdef FAUX_AO uniform lowp vec2 u_ao;in vec2 v_ao; #endif #if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE) in vec4 v_roof_color; #endif #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE) in highp vec3 v_normal; #endif uniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor; #if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT) in float v_flood_radius;in float v_has_floodlight; #endif in float v_height; #pragma mapbox: define highp float emissive_strength void main() { #pragma mapbox: initialize highp float emissive_strength #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE) vec3 normal=normalize(v_normal); #endif float z;vec4 color=v_color; #ifdef ZERO_ROOF_RADIUS z=float(normal.z > 0.00001); #ifdef LIGHTING_3D_MODE normal=mix(normal,vec3(0.0,0.0,1.0),z); #else color=mix(v_color,v_roof_color,z); #endif #endif float h=max(0.0,v_height);float ao_shade=1.0; #ifdef FAUX_AO float intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x; #ifdef ZERO_ROOF_RADIUS concave*=(1.0-z); #endif float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave); #ifdef LIGHTING_3D_MODE #ifdef FLOOD_LIGHT color.rgb*=mix(ao_shade,1.0,v_has_floodlight); #else color.rgb*=ao_shade; #endif #else color.rgb*=ao_shade; #endif #endif #ifdef LIGHTING_3D_MODE float flood_radiance=0.0; #ifdef FLOOD_LIGHT flood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight; #endif #ifdef RENDER_SHADOWS #ifdef FLOOD_LIGHT float ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance); #else float shadowed_lighting_factor; #ifdef RENDER_CUTOFF shadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;} #else shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w); #endif color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor); #endif #else color.rgb=apply_lighting(color.rgb,normal); #ifdef FLOOD_LIGHT color.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance); #endif #endif color.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity; #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h)); #endif #ifdef INDICATOR_CUTOUT color=applyCutout(color,h); #endif #ifdef FEATURE_CUTOUT color=apply_feature_cutout(color,gl_FragCoord); #endif glFragColor=color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" #include "_prelude_shadow.vertex.glsl" #include "_prelude_lighting.glsl" #include "_prelude_material_table.vertex.glsl" uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos; #ifdef RENDER_WALL_MODE in vec3 a_join_normal_inside; #endif #ifdef PROJECTION_GLOBE_VIEW in vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift; #endif #ifdef TERRAIN uniform int u_height_type;uniform int u_base_type; #endif uniform highp float u_vertical_scale;out vec4 v_color;out vec4 v_flat; #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1; #endif #if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE) out vec4 v_roof_color; #endif #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE) out highp vec3 v_normal; #endif #ifdef FAUX_AO uniform lowp vec2 u_ao;out vec2 v_ao; #endif #if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT) out float v_flood_radius;out float v_has_floodlight; #endif out float v_height;vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));} #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp vec4 color #pragma mapbox: define highp float flood_light_wall_radius #pragma mapbox: define highp float line_width #pragma mapbox: define highp float emissive_strength void main() {DECLARE_MATERIAL_TABLE_INFO #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize highp float flood_light_wall_radius #pragma mapbox: initialize highp float line_width #pragma mapbox: initialize highp float emissive_strength base*=u_vertical_scale;height*=u_vertical_scale;vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0)); #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE) v_normal=normal; #endif base=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=a_centroid_pos; #endif float ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos; #ifdef TERRAIN bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h); #else h=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h); #endif #ifdef PROJECTION_GLOBE_VIEW float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #endif float cutoff=1.0;vec3 scaled_pos=pos; #ifdef RENDER_CUTOFF vec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_pos.x==0.0 ? pos.xyz : (centroid_random/8.0);vec4 ground=u_matrix*vec4(ground_pos.xy,ele,1.0); #ifdef CLIP_ZERO_TO_ONE cutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w); #else cutoff=cutoff_opacity(u_cutoff_params,ground.z); #endif if (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale); #endif float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0)); #ifdef RENDER_WALL_MODE vec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=a_join_normal_inside.z*wall_offset*0.5; #endif gl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h; #ifdef RENDER_SHADOWS vec3 shd_pos0=pos;vec3 shd_pos1=pos; #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1); #endif float NdotL=0.0;float colorvalue=0.0; #ifndef LIGHTING_3D_MODE colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=( (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));} #endif #ifdef FAUX_AO float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height; #ifdef TERRAIN top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height); #endif v_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]); #ifdef PROJECTION_GLOBE_VIEW top_height+=u_height_lift; #endif gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w; #endif #ifdef LIGHTING_3D_MODE #ifdef FLOOD_LIGHT float is_wall=1.0-float(t > 0.0 && top_up_ny.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale; #endif v_color=vec4(color.rgb,1.0);float ndotl=calculate_NdotL(normal);v_flat.rgb=sRGBToLinear(color.rgb);v_flat.rgb=v_flat.rgb*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);v_flat=vec4(linearTosRGB(v_flat.rgb),1.0); #else v_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity; #endif #if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE) float roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity; #endif #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),fillExtrusionDepth:Sa(`in highp float v_depth;void main() { #ifndef DEPTH_TEXTURE glFragColor=pack_depth(v_depth); #endif }`,`#include "_prelude_terrain.vertex.glsl" #include "_prelude_material_table.vertex.glsl" uniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale; #ifdef TERRAIN uniform int u_height_type;uniform int u_base_type; #endif in vec4 a_pos_normal_ed;in vec2 a_centroid_pos; #ifdef RENDER_WALL_MODE in vec3 a_join_normal_inside; #endif #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp float line_width #pragma mapbox: define highp vec4 color out highp float v_depth;void main() {DECLARE_MATERIAL_TABLE_INFO #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp float line_width #pragma mapbox: initialize highp vec4 color base*=u_vertical_scale;height*=u_vertical_scale;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=a_centroid_pos; #endif vec3 pos; #ifdef TERRAIN bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);float c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h); #else pos=vec3(pos_nx.xy,t > 0.0 ? height : base); #endif #ifdef RENDER_WALL_MODE vec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;pos.xy-=a_join_normal_inside.z*wall_offset*0.5; #endif float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}`),fillExtrusionPattern:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform vec2 u_texsize;uniform sampler2D u_image; #ifdef FILL_EXTRUSION_PATTERN_TRANSITION uniform float u_pattern_transition; #endif #ifdef FAUX_AO uniform lowp vec2 u_ao;in vec3 v_ao; #endif #ifdef LIGHTING_3D_MODE in vec3 v_normal; #endif #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif in highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity; #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define mediump vec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: define mediump vec4 pattern_b #endif #pragma mapbox: define highp float pixel_ratio void main() { #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize mediump vec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: initialize mediump vec4 pattern_b #endif #pragma mapbox: initialize highp float pixel_ratio vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos); #ifdef APPLY_LUT_ON_GPU out_color=applyLUT(u_lutTexture,out_color); #endif #ifdef FILL_EXTRUSION_PATTERN_TRANSITION vec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition; #endif #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color,normalize(v_normal))*u_opacity; #else out_color=out_color*v_lighting; #endif #ifdef FAUX_AO float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade; #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif #ifdef INDICATOR_CUTOUT out_color=applyCutout(out_color,height); #endif glFragColor=out_color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" #include "_prelude_lighting.glsl" #include "_prelude_material_table.vertex.glsl" uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos; #ifdef RENDER_WALL_MODE in vec3 a_join_normal_inside; #endif #ifdef PROJECTION_GLOBE_VIEW in vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift; #endif #ifdef TERRAIN uniform int u_height_type;uniform int u_base_type; #endif out highp vec2 v_pos;out vec4 v_lighting; #ifdef FAUX_AO uniform lowp vec2 u_ao;out vec3 v_ao; #endif #ifdef LIGHTING_3D_MODE out vec3 v_normal; #endif #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump vec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: define mediump vec4 pattern_b #endif #pragma mapbox: define highp float pixel_ratio #pragma mapbox: define highp float line_width void main() {DECLARE_MATERIAL_TABLE_INFO #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump vec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: initialize mediump vec4 pattern_b #endif #pragma mapbox: initialize highp float pixel_ratio #pragma mapbox: initialize highp float line_width vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=a_centroid_pos; #endif float ele=0.0;float h=z;vec3 p;float c_ele; #ifdef TERRAIN bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;p=vec3(pos_nx.xy,h); #else p=vec3(pos_nx.xy,z); #endif #ifdef PROJECTION_GLOBE_VIEW float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #endif #ifdef RENDER_WALL_MODE vec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);p.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;p.xy-=a_join_normal_inside.z*wall_offset*0.5; #endif float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0 ? pos_nx.xy : vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0; #ifdef LIGHTING_3D_MODE NdotL=calculate_NdotL(normal); #else NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL); #endif if (normal.y !=0.0) {float r=0.84; #ifndef LIGHTING_3D_MODE r=mix(0.7,0.98,1.0-u_lightintensity); #endif NdotL*=( (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));} #ifdef FAUX_AO float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height; #ifdef TERRAIN top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height); #endif v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]); #ifdef PROJECTION_GLOBE_VIEW top_height+=u_height_lift; #endif gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w; #endif #ifdef LIGHTING_3D_MODE v_normal=normal; #else v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity; #endif #ifdef FOG v_fog_pos=fog_position(p); #endif }`),groundShadow:Sa(`#include "_prelude_shadow.fragment.glsl" precision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1; #ifdef FOG in float v_fog_opacity; #endif void main() {float light=shadowed_light_factor_plane_bias(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light); #ifdef RENDER_CUTOFF shadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w)); #endif #ifdef FOG shadow=mix(shadow,vec3(1.0),v_fog_opacity); #endif #ifdef INDICATOR_CUTOUT shadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r); #endif glFragColor=vec4(shadow,1.0);}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in vec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1; #ifdef FOG out float v_fog_opacity; #endif void main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0); #ifdef FOG v_fog_pos=fog_position(a_pos);v_fog_opacity=fog(v_fog_pos); #endif }`),fillExtrusionGroundEffect:Sa(`uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size; #ifdef SDF_SUBPASS in highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);} #ifdef FOG in highp float v_fog; #endif #endif void main() { #ifdef CLEAR_SUBPASS vec4 color=vec4(1.0); #ifdef CLEAR_FROM_TEXTURE color=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)); #endif glFragColor=color; #else #ifdef SDF_SUBPASS highp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0; #ifdef FOG fog=v_fog; #endif #ifdef RENDER_CUTOFF fog*=v_cutoff_opacity; #endif glFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog)); #else #ifdef USE_MRT1 out_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0); #else vec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass); #ifdef OVERDRAW_INSPECTOR color=vec4(1.0); #endif glFragColor=color; #endif #endif HANDLE_WIREFRAME_DEBUG; #endif }`,`#include "_prelude_fog.vertex.glsl" in highp vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float a_hidden_by_landmark; #ifdef SDF_SUBPASS out highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao; #ifdef FOG out highp float v_fog; #endif #endif uniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp float u_dynamic_offset;uniform highp vec2 u_ao; #pragma mapbox: define highp float flood_light_ground_radius const float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() { #pragma mapbox: initialize highp float flood_light_ground_radius vec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=a_angular_offset_factor/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(u_dynamic_offset,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp; #ifdef SDF_SUBPASS v_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius); #ifdef FOG v_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos); #endif #endif float hidden_by_landmark=0.0; #ifdef HAS_CENTROID hidden_by_landmark=a_hidden_by_landmark; #endif float isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0)); #ifdef RENDER_CUTOFF v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z); #endif }`),hillshadePrepare:Sa(`precision highp float;uniform highp sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2( (c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c) )/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4( deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);glFragColor=accent_color*(1.0-shade_color.a)+shade_color; #ifdef LIGHTING_3D_MODE glFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength); #endif #ifdef FOG glFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos)); #endif #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),line:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" uniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec3 v_uv; #ifdef ELEVATED_ROADS in highp float v_road_z_offset; #endif #ifdef RENDER_LINE_DASH uniform sampler2D u_dash_image;in vec2 v_tex; #endif #ifdef RENDER_LINE_GRADIENT uniform sampler2D u_gradient_image; #endif #ifdef INDICATOR_CUTOUT in highp float v_z_offset; #endif #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;} #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 dash #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float side_z_offset #pragma mapbox: define lowp float border_width #pragma mapbox: define lowp vec4 border_color #pragma mapbox: define lowp float emissive_strength float linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize lowp vec4 dash #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float side_z_offset #pragma mapbox: initialize lowp float border_width #pragma mapbox: initialize lowp vec4 border_color #pragma mapbox: initialize lowp float emissive_strength float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);alpha=side_z_offset > 0.0 ? 1.0-alpha : alpha; #ifdef RENDER_LINE_DASH float sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist); #endif highp vec4 out_color; #ifdef RENDER_LINE_GRADIENT out_color=texture(u_gradient_image,v_uv.xy); #ifdef MULTIPLY_LINE_GRADIENT_COLOR out_color*=color; #endif #else out_color=color; #endif float trim_alpha=1.0; #ifdef RENDER_LINE_TRIM_OFFSET highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);out_color=mix(out_color,u_trim_color,transition_factor);trim_alpha=1.0-transition_factor;} #endif if (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}} #ifdef RENDER_LINE_BORDER float edgeBlur=((border_width*u_width_scale)+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color=mix(border_color*trim_alpha,out_color,smoothAlpha);}} #endif #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth); #ifdef ELEVATED_ROADS out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light); #else out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif out_color*=(alpha*opacity); #ifdef INDICATOR_CUTOUT out_color=applyCutout(out_color,v_z_offset); #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord); #endif glFragColor=out_color; #ifdef DUAL_SOURCE_BLENDING glFragColorSrc1=vec4(vec3(0.0),emissive_strength); #else #ifdef USE_MRT1 out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" #include "_prelude_terrain.vertex.glsl" #define EXTRUDE_SCALE 0.015873016 in vec2 a_pos_normal;in vec4 a_data; #if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH) in vec3 a_z_offset_width; #endif #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) in highp vec3 a_packed; #endif #ifdef RENDER_LINE_DASH in float a_linesofar; #endif uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;uniform float u_width_scale;uniform highp float u_floor_width_scale; #ifdef ELEVATED uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) { #ifdef ELEVATION_REFERENCE_SEA return 0.0; #else return elevation(apos); #endif } #endif out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec3 v_uv; #ifdef ELEVATED_ROADS out highp float v_road_z_offset; #endif #ifdef RENDER_LINE_DASH uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex; #endif #ifdef RENDER_LINE_GRADIENT uniform float u_image_height; #endif #ifdef INDICATOR_CUTOUT out highp float v_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 dash #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width #pragma mapbox: define mediump float side_z_offset #pragma mapbox: define lowp float border_width #pragma mapbox: define lowp vec4 border_color #pragma mapbox: define lowp float emissive_strength void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize lowp vec4 dash #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width #pragma mapbox: initialize mediump float side_z_offset #pragma mapbox: initialize lowp float border_width #pragma mapbox: initialize lowp vec4 border_color #pragma mapbox: initialize lowp float emissive_strength float a_z_offset; #if defined(ELEVATED) || defined(ELEVATED_ROADS) a_z_offset=a_z_offset_width.x; #endif float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth; #ifdef VARIABLE_LINE_WIDTH bool left=normal.y==1.0;halfwidth=(u_width_scale*(left ? a_z_offset_width.y : a_z_offset_width.z))/2.0;a_z_offset+=left ? side_z_offset : 0.0;v_normal=side_z_offset > 0.0 && left ? vec2(0.0) : v_normal; #else halfwidth=(u_width_scale*width)/2.0; #endif offset=-1.0*offset*u_width_scale;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy; #ifdef ELEVATED_ROADS v_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude; #else #ifdef ELEVATED vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0; #ifdef CROSS_SLOPE_VERTICAL float top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0); #else #ifdef CROSS_SLOPE_HORIZONTAL float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+a_z_offset; #else float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+a_z_offset; #endif #endif gl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden); #else gl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden); #endif #endif #ifdef ELEVATED_ROADS #ifdef RENDER_SHADOWS vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos; #ifdef NORMAL_OFFSET vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #endif #ifndef RENDER_TO_TEXTURE float epsilon=0.0001;float extrude_length_without_perspective=max(length(dist),epsilon);float extrude_length_with_perspective=max(length(projected_extrude_xy/gl_Position.w*u_units_to_pixels),epsilon);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur)); #else v_gamma_scale=1.0; #endif #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) highp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float line_progress=a_packed[2]; #ifdef RENDER_LINE_GRADIENT highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec3(a_uv_x,a_split_index*texel_height-half_texel_height,line_progress); #else v_uv=vec3(a_uv_x,0.0,line_progress); #endif #endif #ifdef RENDER_LINE_DASH float scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*height+dash.x+0.5)/u_texsize.y); #endif v_width2=vec2(outset,inset); #ifdef FOG v_fog_pos=fog_position(pos); #endif #ifdef INDICATOR_CUTOUT v_z_offset=a_z_offset; #endif }`),linePattern:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" uniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image; #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #ifdef LINE_PATTERN_TRANSITION uniform float u_pattern_transition; #endif in vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width; #ifdef RENDER_LINE_TRIM_OFFSET in highp vec3 v_uv; #endif #ifdef ELEVATED_ROADS in highp float v_road_z_offset; #endif #ifdef LINE_JOIN_NONE in vec2 v_pattern_data; #endif #ifdef INDICATOR_CUTOUT in highp float v_z_offset; #endif #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #pragma mapbox: define mediump vec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: define mediump vec4 pattern_b #endif #pragma mapbox: define mediump float pixel_ratio #pragma mapbox: define mediump float blur #pragma mapbox: define mediump float opacity #pragma mapbox: define lowp float emissive_strength void main() { #pragma mapbox: initialize mediump vec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: initialize mediump vec4 pattern_b #endif #pragma mapbox: initialize mediump float pixel_ratio #pragma mapbox: initialize mediump float blur #pragma mapbox: initialize mediump float opacity #pragma mapbox: initialize lowp float emissive_strength vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos); #ifdef APPLY_LUT_ON_GPU color=applyLUT(u_lutTexture,color); #endif #ifdef LINE_PATTERN_TRANSITION vec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl*texel_size-texel_size,pattern_b_br*texel_size+texel_size,vec2(x,y));vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);color=color*(1.0-u_pattern_transition)+color_b*u_pattern_transition; #endif #ifdef RENDER_LINE_TRIM_OFFSET highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);color=mix(color,color.a*u_trim_color,transition_factor);} #endif #ifdef LINE_JOIN_NONE highp float pattern_len=pattern_size/aspect;highp float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);highp float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;highp float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);} #endif #ifdef LIGHTING_3D_MODE color=apply_lighting_with_emission_ground(color,emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth); #ifdef ELEVATED_ROADS color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light); #else color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif color*=(alpha*opacity);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}} #ifdef INDICATOR_CUTOUT color=applyCutout(color,v_z_offset); #endif glFragColor=color; #ifdef DUAL_SOURCE_BLENDING glFragColorSrc1=vec4(vec3(0.0),emissive_strength); #else #ifdef USE_MRT1 out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" #include "_prelude_terrain.vertex.glsl" #define scale 0.015873016 in vec2 a_pos_normal;in vec4 a_data; #if defined(ELEVATED) || defined(ELEVATED_ROADS) in vec3 a_z_offset_width; #endif #ifdef RENDER_LINE_TRIM_OFFSET in highp vec3 a_packed; #endif in highp float a_linesofar; #ifdef LINE_JOIN_NONE in highp vec3 a_pattern_data;out vec2 v_pattern_data; #endif #ifdef INDICATOR_CUTOUT out highp float v_z_offset; #endif uniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_floor_width_scale; #ifdef ELEVATED uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) { #ifdef ELEVATION_REFERENCE_SEA return 0.0; #else return elevation(apos); #endif } #endif out vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width; #ifdef RENDER_LINE_TRIM_OFFSET out highp vec3 v_uv; #endif #ifdef ELEVATED_ROADS out highp float v_road_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif #pragma mapbox: define mediump float blur #pragma mapbox: define mediump float opacity #pragma mapbox: define mediump float offset #pragma mapbox: define mediump float gapwidth #pragma mapbox: define mediump float width #pragma mapbox: define mediump float floorwidth #pragma mapbox: define mediump vec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: define mediump vec4 pattern_b #endif #pragma mapbox: define mediump float pixel_ratio #pragma mapbox: define lowp float emissive_strength void main() { #pragma mapbox: initialize mediump float blur #pragma mapbox: initialize mediump float opacity #pragma mapbox: initialize mediump float offset #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize mediump float width #pragma mapbox: initialize mediump float floorwidth #pragma mapbox: initialize mediump vec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: initialize mediump vec4 pattern_b #endif #pragma mapbox: initialize mediump float pixel_ratio #pragma mapbox: initialize lowp float emissive_strength float a_z_offset; #if defined(ELEVATED) || defined(ELEVATED_ROADS) a_z_offset=a_z_offset_width.x; #endif float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy; #ifdef ELEVATED_ROADS v_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude; #else #ifdef ELEVATED vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0; #ifdef CROSS_SLOPE_VERTICAL float top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0); #else #ifdef CROSS_SLOPE_HORIZONTAL float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+a_z_offset; #else float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+a_z_offset; #endif #endif gl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden); #else gl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden); #endif #endif #ifdef ELEVATED_ROADS #ifdef RENDER_SHADOWS vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos; #ifdef NORMAL_OFFSET vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #endif #ifndef RENDER_TO_TEXTURE float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude_xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur)); #else v_gamma_scale=1.0; #endif #ifdef RENDER_LINE_TRIM_OFFSET highp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress); #endif v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale); #ifdef LINE_JOIN_NONE v_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/((pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y); #endif #ifdef FOG v_fog_pos=fog_position(pos); #endif #ifdef INDICATOR_CUTOUT v_z_offset=a_z_offset; #endif }`),raster:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_raster_array.glsl" uniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth; #ifdef PROJECTION_GLOBE_VIEW in float v_split_fade; #endif uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength; #ifndef RASTER_ARRAY uniform highp sampler2D u_image0;uniform sampler2D u_image1; #endif #ifdef RASTER_COLOR uniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res; #endif void main() {vec4 color0,color1,color;vec2 value; #ifdef RASTER_COLOR #ifdef RASTER_ARRAY #ifdef RASTER_ARRAY_LINEAR value=mix( raTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t ); #else value=mix( raTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t ); #endif if (value.y > 0.0) value.x/=value.y; #else color=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a); #endif color=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y; #else color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t); #endif color.a*=u_opacity; #ifdef GLOBE_POLES color.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition); #endif vec3 rgb=color.rgb;rgb=vec3( dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb); #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb; #endif #ifdef FOG highp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit)); #endif glFragColor=vec4(out_color*color.a,color.a); #ifdef PROJECTION_GLOBE_VIEW glFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade)); #endif #ifdef RENDER_CUTOFF glFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center; #define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8 #ifdef GLOBE_POLES in vec3 a_globe_pos;in vec2 a_uv; #else in vec2 a_pos;in vec2 a_texture_pos; #endif out vec2 v_pos0;out vec2 v_pos1;out float v_depth; #ifdef PROJECTION_GLOBE_VIEW out float v_split_fade; #endif void main() {vec2 uv; #ifdef GLOBE_POLES vec3 globe_pos=a_globe_pos;globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);uv=a_uv; #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz); #endif #else float w=1.0+dot(a_texture_pos,u_perspective_transform);uv=a_texture_pos/8192.0; #ifdef PROJECTION_GLOBE_VIEW vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); v_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}float tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos; #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); #endif #else gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif #endif #endif v_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1; #ifdef RENDER_CUTOFF v_depth=gl_Position.z; #endif }`),rasterParticle:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb; #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb; #endif #ifdef FOG highp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit)); #endif glFragColor=vec4(out_color*color.a,color.a); #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center; #define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8 in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv; #ifdef PROJECTION_GLOBE_VIEW vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos; #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); #endif #else uv=a_texture_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif #endif v_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),rasterParticleDraw:Sa("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",`#include "_prelude_raster_particle.glsl" in float a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2( mod(a_index,u_particle_texture_side_len),a_index/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}`),rasterParticleTexture:Sa("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in vec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*a_pos+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:Sa(`#include "_prelude_raster_particle.glsl" uniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow( linearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4) );highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}`,"in vec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*(a_pos+vec2(1.0));gl_Position=vec4(a_pos,0.0,1.0);}"),symbol:Sa(`#include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" #define SDF_PX 8.0 #define SDF 1.0 #define ICON 0.0 uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;uniform lowp float u_scale_factor; #ifdef ICON_TRANSITION uniform float u_icon_transition; #endif #ifdef COLOR_ADJUSTMENT uniform mat4 u_color_adj_mat; #endif #ifdef INDICATOR_CUTOUT in highp float v_z_offset; #else #ifdef RENDER_SHADOWS in highp float v_z_offset; #endif #endif in vec2 v_tex_a; #ifdef ICON_TRANSITION in vec2 v_tex_b; #endif in float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity; #ifdef RENDER_TEXT_AND_SYMBOL in float is_sdf;in vec2 v_tex_a_icon; #endif #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur #pragma mapbox: define lowp float emissive_strength void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur #pragma mapbox: initialize lowp float emissive_strength vec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2]; #ifdef RENDER_TEXT_AND_SYMBOL if (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif return;} #endif #ifdef RENDER_SDF float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {out_color=halo_color;gamma=(halo_blur*u_scale_factor*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width*u_scale_factor/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha; #else #ifdef ICON_TRANSITION vec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b); #else out_color=texture(u_texture,v_tex_a); #endif #ifdef APPLY_LUT_ON_GPU out_color=applyLUT(u_lutTexture,out_color); #endif #ifdef COLOR_ADJUSTMENT out_color=u_color_adj_mat*out_color; #endif #endif out_color*=opacity*fade_opacity; #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth); #ifdef TERRAIN out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #else out_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light); #endif #endif #endif #ifdef INDICATOR_CUTOUT out_color=applyCutout(out_color,v_z_offset); #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord); #endif glFragColor=out_color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl" #include "_prelude_shadow.vertex.glsl" #define APPEARANCE_ICON 1.0 in vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity; #ifdef Z_OFFSET in float a_auto_z_offset; #endif #ifdef PROJECTION_GLOBE_VIEW in vec3 a_globe_anchor;in vec3 a_globe_normal; #endif #ifdef ICON_TRANSITION in vec2 a_texb; #endif #ifdef OCCLUSION_QUERIES in float a_occlusion_query_opacity; #endif #ifdef ELEVATED_ROADS in vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale; #endif #ifdef INDICATOR_CUTOUT out highp float v_z_offset; #else #ifdef RENDER_SHADOWS out highp float v_z_offset; #endif #endif uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo; #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix; #endif out vec2 v_tex_a; #ifdef ICON_TRANSITION out vec2 v_tex_b; #endif out float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity; #ifdef RENDER_TEXT_AND_SYMBOL out float is_sdf;out vec2 v_tex_a_icon; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur #pragma mapbox: define lowp float emissive_strength #pragma mapbox: define lowp float occlusion_opacity #pragma mapbox: define lowp float z_offset void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur #pragma mapbox: initialize lowp float emissive_strength #pragma mapbox: initialize lowp float occlusion_opacity #pragma mapbox: initialize lowp float z_offset vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float a_size_max= floor(a_size[1]*0.5);float a_apperance_icon=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance_icon==APPEARANCE_ICON) {size=a_size_max/128.0;} else if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size_max,u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor); #ifdef Z_OFFSET e+=a_auto_z_offset; #endif vec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe; #ifdef PROJECTION_GLOBE_VIEW mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=a_globe_anchor+h;world_pos=mix_globe_mercator(world_pos_globe,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0; #else world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0; #endif vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp( 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;vec2 a; #ifdef PROJECTION_GLOBE_VIEW vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w; #else offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w; #endif vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos; #ifdef PROJECTION_GLOBE_VIEW #ifdef PROJECTED_POS_ON_VIEWPORT projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0); #else vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz,mercator_pos,u_zoom_transition)+h;projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); #endif #else projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0); #endif highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0); #ifdef TERRAIN #ifdef PITCH_WITH_MAP_TERRAIN vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy); #endif #endif #ifdef Z_OFFSET z+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0; #else z+=u_pitch_with_map ? z_offset : 0.0; #endif float occlusion_fade=globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change)); #ifdef DEPTH_OCCLUSION float depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier; #endif #ifdef OCCLUSION_QUERIES float occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier; #endif #ifdef Z_TEST_OCCLUSION out_fade_opacity*=occlusion_opacity; #endif float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos; #ifdef PROJECTION_GLOBE_VIEW vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y; #else #ifdef ELEVATED_ROADS vec3 xAxis=vec3(a_x_axis.xy,a_x_axis.z*u_normal_scale);vec3 yAxis=vec3(a_y_axis.xy,a_y_axis.z*u_normal_scale);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y; #else pos=vec3(projected_pos.xy/projected_pos.w+offset,z); #endif #endif gl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden);float gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize; #ifdef RENDER_TEXT_AND_SYMBOL is_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon; #endif #ifdef ICON_TRANSITION v_tex_b=a_texb/u_texsize; #endif #ifdef RENDER_SHADOWS vec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz; #ifdef NORMAL_OFFSET vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef INDICATOR_CUTOUT v_z_offset=e; #else #ifdef RENDER_SHADOWS v_z_offset=e; #endif #endif }`),terrainRaster:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" uniform sampler2D u_image0; #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS uniform sampler2D u_image1;uniform float u_emissive_texture_available; #endif in vec2 v_pos0; #ifdef FOG in float v_fog_opacity; #endif #ifdef RENDER_SHADOWS in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1; #endif uniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color; #ifdef LIGHTING_3D_MODE const vec3 normal=vec3(0.0,0.0,1.0); #ifdef RENDER_SHADOWS float cutoffOpacity=1.0; #ifdef RENDER_CUTOFF cutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w); #endif #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;vec3 unlit_base=image_color.rgb*(1.0-emissive_strength);vec3 emissive_base=image_color.rgb*emissive_strength;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0; #else float lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity)); #endif #else float lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor); #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;color.rgb=mix(color.rgb,image_color.rgb,emissive_strength);color.a=1.0; #endif #endif #else color=image_color; #endif #ifdef FOG #ifdef ZERO_EXAGGERATION color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #else color=fog_dither(fog_apply_from_vert(color,v_fog_opacity)); #endif #endif glFragColor=color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" uniform mat4 u_matrix;uniform float u_skirt_height;in vec2 a_pos;out vec2 v_pos0; #ifdef FOG out float v_fog_opacity; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1; #endif void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0); #ifdef FOG #ifdef ZERO_EXAGGERATION v_fog_pos=fog_position(decodedPos); #else v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation))); #endif #endif #ifdef RENDER_SHADOWS vec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.); #endif }`),terrainDepth:Sa("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",`#include "_prelude_terrain.vertex.glsl" uniform mat4 u_matrix;in vec2 a_pos;out float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}`),skybox:Sa(`#include "_prelude_fog.fragment.glsl" in lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep( cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=texture(u_cubemap,uv).rgb; #ifdef FOG sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color); #endif sky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity); #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif }`,AS),skyboxGradient:Sa(`#include "_prelude_fog.fragment.glsl" in highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture(u_color_ramp,vec2(progress,0.5)); #ifdef FOG color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a; #endif color*=u_opacity;glFragColor=color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif }`,AS),skyboxCapture:Sa(` in highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;precision highp float; #define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6) #define BETA_M vec3(21e-6,21e-6,21e-6) #define MIE_G 0.76 #define DENSITY_HEIGHT_SCALE_R 8000.0 #define DENSITY_HEIGHT_SCALE_M 1200.0 #define PLANET_RADIUS 6360e3 #define ATMOSPHERE_RADIUS 6420e3 #define SAMPLE_STEPS 10 #define DENSITY_STEPS 4 float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;glFragColor=vec4(color,1.0);}`,"in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform sampler2D u_image0; #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS uniform sampler2D u_image1;uniform float u_emissive_texture_available; #endif uniform float u_far_z_cutoff;in vec2 v_pos0; #ifndef FOG uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport; #endif void main() {vec4 color; #ifdef CUSTOM_ANTIALIASING highp vec2 uv=gl_FragCoord.xy/u_viewport; #ifdef FLIP_Y uv.y=1.0-uv.y; #endif highp vec3 ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;highp float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);highp float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0); #ifdef LIGHTING_3D_MODE #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : raster.a;raster=apply_lighting_with_emission_ground(raster,emissive_strength);color=vec4(clamp(raster.rgb,vec3(0),vec3(1))*antialias,antialias); #else raster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias); #endif #else color=vec4(raster.rgb*antialias,raster.a*antialias); #endif #else color=texture(u_image0,v_pos0); #ifdef LIGHTING_3D_MODE #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : color.a;color=apply_lighting_with_emission_ground(color,emissive_strength);color.a=1.0; #else color=apply_lighting_ground(color); #endif #endif #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif color*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height; #ifdef GLOBE_POLES in vec3 a_globe_pos;in vec2 a_uv; #else in vec2 a_pos; #endif out vec2 v_pos0;void main() { #ifdef GLOBE_POLES vec3 globe_pos=a_globe_pos;vec2 uv=a_uv; #else float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY); #endif v_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale; #ifdef GLOBE_POLES vec3 up_vector=globe_derived_up_vector; #else vec3 up_vector=elevationVector(tile_pos); #endif float height=elevation(tile_pos);globe_pos+=up_vector*height; #ifndef GLOBE_POLES globe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z; #endif #ifdef GLOBE_POLES vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0); #else vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0); #endif gl_Position=u_proj_matrix*interpolated_pos; #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); #endif }`),globeAtmosphere:Sa(`#include "_prelude_fog.fragment.glsl" uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_atmosphere_fog_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir; #ifdef PROJECTION_GLOBE_VIEW globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) { #ifdef ALPHA_PASS glFragColor=vec4(0,0,0,0);return; #else #ifdef NATIVE glFragColor=vec4(1,1,1,1); #else glFragColor=vec4(0,0,0,1); #endif return; #endif } #endif highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ? 0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle; #ifdef PROJECTION_GLOBE_VIEW highp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ? PI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t); #else horizon_angle=horizon_angle_mercator; #endif horizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_atmosphere_fog_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_atmosphere_fog_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb; #ifdef ALPHA_PASS float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);glFragColor=vec4(1.0,1.0,1.0,a); #else vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;glFragColor=vec4(c*t,t); #endif }`,`in vec3 a_pos;in vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;out highp vec3 v_ray_dir;out highp vec3 v_horizon_dir;void main() {v_ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix( mix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}`),model:Sa(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" uniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix; #ifdef RENDER_SHADOWS in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows; #endif #ifdef OCCLUSION_TEXTURE_TRANSFORM uniform vec4 u_occlusionTextureTransform; #endif #pragma mapbox: define-attribute highp vec3 normal_3f #pragma mapbox: define-attribute highp vec3 color_3f #pragma mapbox: define-attribute highp vec4 color_4f #pragma mapbox: define-attribute highp vec2 uv_2f #pragma mapbox: initialize-attribute highp vec3 normal_3f #pragma mapbox: initialize-attribute highp vec3 color_3f #pragma mapbox: initialize-attribute highp vec4 color_4f #pragma mapbox: initialize-attribute highp vec2 uv_2f #ifdef HAS_ATTRIBUTE_a_pbr in lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params; #endif #ifdef HAS_TEXTURE_u_baseColorTexture uniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff; #endif #ifdef HAS_TEXTURE_u_metallicRoughnessTexture uniform sampler2D u_metallicRoughnessTexture; #endif #ifdef HAS_TEXTURE_u_occlusionTexture uniform sampler2D u_occlusionTexture;uniform float u_aoIntensity; #endif #ifdef HAS_TEXTURE_u_normalTexture uniform sampler2D u_normalTexture; #endif #ifdef HAS_TEXTURE_u_emissionTexture uniform sampler2D u_emissionTexture; #endif #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #ifdef TERRAIN_FRAGMENT_OCCLUSION in highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack; #ifdef DEPTH_D24 highp float unpack_depth(highp float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;} #else highp float unpack_depth_rgba(highp vec4 rgba_depth) {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;} #endif bool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size; #ifdef FLIP_Y coord.y=1.0-coord.y; #endif #ifdef DEPTH_D24 highp float depth=unpack_depth(texture(u_depthTexture,coord).r); #else highp float depth=unpack_depth_rgba(texture(u_depthTexture,coord)); #endif return v_depth > depth+0.0005;} #endif #define saturate(_x) clamp(_x,0.,1.) vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor) { #ifdef LIGHTING_3D_MODE vec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor; #ifdef RENDER_SHADOWS lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows); #else lighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir)); #endif return apply_lighting(albedo,transformed_normal,lighting_factor); #else vec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3; #endif }vec4 getBaseColor() {vec4 albedo=u_baseColorFactor; #ifdef HAS_ATTRIBUTE_a_color_3f albedo*=vec4(color_3f,1.0); #endif #ifdef HAS_ATTRIBUTE_a_pbr #else #ifdef HAS_ATTRIBUTE_a_color_4f albedo*=color_4f; #endif #endif #if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f) vec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}} #ifdef UNPREMULT_TEXTURE_IN_SHADER if(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0; #endif if(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;} #endif vec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a); #ifdef APPLY_LUT_ON_GPU color=applyLUT(u_lutTexture,color); #endif return color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) { #ifdef HAS_TEXTURE_u_normalTexture highp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y; #ifdef FLIP_Y T=-T;B=-B; #endif highp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res; #else return mat3(1.0); #endif }highp vec3 getNormal(){highp vec3 n; #ifdef HAS_ATTRIBUTE_a_normal_3f n=normalize(normal_3f); #else highp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z)); #ifdef FLIP_Y n=normalize(cross(fdx,fdy)); #else n=normalize(cross(fdx,fdy))*-1.0; #endif #endif #if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) vec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap); #endif return n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor; #ifdef HAS_ATTRIBUTE_a_pbr mat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w; #endif #if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) vec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b; #endif const float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness) {float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH) {return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH) {float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness) {highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV) {float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat) { #ifdef LIGHTING_3D_MODE return mat.diffuseColor; #else return mat.diffuseColor/PI; #endif }vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV) {vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal) {vec3 env_light=vec3(0.65,0.65,0.65); #ifdef LIGHTING_3D_MODE float ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor; #endif vec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor) {highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor; #ifdef RENDER_SHADOWS lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows); #else lighting_factor=NdotL; #endif vec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0; #if !defined(LIGHTING_3D_MODE) const vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL); #endif color*=intensityFactor;return color;}void main() { #ifdef TERRAIN_FRAGMENT_OCCLUSION if (isOccluded()) {discard;} #endif vec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor; #ifdef LIGHTING_3D_MODE lightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color; #endif vec4 finalColor; #ifdef DIFFUSE_SHADED vec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor); #ifdef HAS_TEXTURE_u_occlusionTexture float ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao; #endif finalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity; #else Material mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0; #if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) #ifdef OCCLUSION_TEXTURE_TRANSFORM vec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy; #else vec2 uv=uv_2f; #endif ao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao; #endif vec4 emissive=u_emissiveFactor; #if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) emissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb); #endif #ifdef APPLY_LUT_ON_GPU float emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength; #endif color+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity; #ifdef HAS_ATTRIBUTE_a_pbr float resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);vec3 color_mix=v_color_mix.rgb; #ifdef APPLY_LUT_ON_GPU color_mix=applyLUT(u_lutTexture,color_mix); #endif color=mix(color,color_mix,min(1.0,resEmission)); #ifdef HAS_ATTRIBUTE_a_color_4f float distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance); #endif #endif vec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity); #endif #ifdef FOG finalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w)); #endif #ifdef RENDER_CUTOFF finalColor*=v_cutoff_opacity; #endif #ifdef INDICATOR_CUTOUT finalColor=applyCutout(finalColor,v_position_height.w); #endif #ifdef FEATURE_CUTOUT finalColor=apply_feature_cutout(finalColor,gl_FragCoord); #endif glFragColor=finalColor; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in vec3 a_pos_3f; #pragma mapbox: define-attribute highp vec3 normal_3f #pragma mapbox: define-attribute highp vec2 uv_2f #pragma mapbox: define-attribute highp vec3 color_3f #pragma mapbox: define-attribute highp vec4 color_4f #pragma mapbox: define-attribute-vertex-shader-only highp vec4 pbr #pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength uniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix; #ifdef INSTANCED_ARRAYS in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3; #else uniform highp mat4 u_normal_matrix; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth_shadows; #endif out vec4 v_position_height;out lowp vec4 v_color_mix; #ifdef TERRAIN_FRAGMENT_OCCLUSION out highp float v_depth; #endif #ifdef HAS_ATTRIBUTE_a_pbr out lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params; #endif vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() { #pragma mapbox: initialize-attribute highp vec3 normal_3f #pragma mapbox: initialize-attribute highp vec2 uv_2f #pragma mapbox: initialize-attribute highp vec3 color_3f #pragma mapbox: initialize-attribute highp vec4 color_4f #pragma mapbox: initialize-attribute-custom highp vec4 pbr #pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength highp mat4 normal_matrix; #ifdef INSTANCED_ARRAYS normal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3); #else normal_matrix=u_normal_matrix; #endif vec3 local_pos;mat3 rs; #ifdef MODEL_POSITION_ON_GPU vec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float hidden=float(pos_a.x > EXTENT);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=mix(u_matrix*pos,AWAY,hidden);pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos; #else local_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a); #endif v_position_height.w=a_pos_3f.z; #ifdef HAS_ATTRIBUTE_a_pbr vec4 albedo_c=decode_color(pbr.xy);vec2 e_r_m=unpack_float(pbr.z);vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(pbr.w)/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x; #endif #ifdef FOG v_fog_pos=fog_position(local_pos); #endif #ifdef RENDER_CUTOFF v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z); #endif #ifdef TERRAIN_FRAGMENT_OCCLUSION v_depth=gl_Position.z/gl_Position.w; #ifdef CLIP_ZERO_TO_ONE v_depth=-1.0+2.0*v_depth; #endif #endif #ifdef HAS_ATTRIBUTE_a_normal_3f #ifdef MODEL_POSITION_ON_GPU float x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f); #else normal_3f=vec3(normal_matrix*vec4(normal_3f,0)); #endif #endif #ifdef HAS_ATTRIBUTE_a_pbr #ifdef HAS_ATTRIBUTE_a_color_4f v_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0); #endif #endif #ifdef RENDER_SHADOWS vec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0); #ifdef NORMAL_OFFSET #ifdef HAS_ATTRIBUTE_a_normal_3f #ifdef MODEL_POSITION_ON_GPU vec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0(); #else vec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0(); #endif #endif #endif v_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w; #endif }`),modelDepth:Sa(`in highp float v_depth;void main() { #ifndef DEPTH_TEXTURE glFragColor=pack_depth(v_depth); #endif }`,`in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth; #ifdef MODEL_POSITION_ON_GPU #ifdef INSTANCED_ARRAYS in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3; #else uniform highp mat4 u_instance; #endif uniform highp mat4 u_node_matrix; #endif void main() { #ifdef MODEL_POSITION_ON_GPU highp mat4 instance; #ifdef INSTANCED_ARRAYS instance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3); #else instance=u_instance; #endif vec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float hidden=float(pos_a.x > EXTENT);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=mix(u_matrix*pos,AWAY,hidden); #else gl_Position=u_matrix*vec4(a_pos_3f,1); #endif v_depth=gl_Position.z/gl_Position.w;}`),stars:Sa(`in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv) {float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}`,` in vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_fade_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_fade_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}`),snowParticle:Sa("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}",` in highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; uniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; uniform float u_horizontalOscillationRate; uniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+ localY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}`),rainParticle:Sa("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}",` in highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; uniform float u_velocity; uniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+ localY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}`),vignette:Sa("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}"),occlusion:Sa("uniform vec4 u_color;void main() {glFragColor=u_color;}",`#include "_prelude_terrain.vertex.glsl" in highp vec2 a_offset_xy;uniform highp vec3 u_anchorPos;uniform mat4 u_matrix;uniform vec2 u_screenSizePx;uniform vec2 u_occluderSizePx;void main() {vec3 world_pos=u_anchorPos; #ifdef TERRAIN float e=elevation(world_pos.xy);world_pos.z+=e; #endif vec4 projected_point=u_matrix*vec4(world_pos,1.0);projected_point.xy+=projected_point.w*a_offset_xy*0.5*u_occluderSizePx/u_screenSizePx;gl_Position=projected_point;}`)};function px(M,h){const x=M.split(` `);for(let A of x){if(A=A.trimStart(),A[0]!=="#"||!A.includes("if")||A.startsWith("#endif"))continue;const D=A.match(hT);if(D)for(const F of D)Py.has(F)||h.add(F)}}function Sa(M,h){const x=new Set,A=[],D=[];M=M.replace(vb,(z,V)=>(D.push(V),"")),h=h.replace(vb,(z,V)=>(A.push(V),""));let F=new Set(Iy);px(M,F),px(h,F);for(const z of[...A,...D])LS[z]||(LS[z]=new Set,px(mx[z],LS[z])),F=new Set([...F,...LS[z]]);return{fragmentSource:M=M.replace(Op,(z,V,X,ne,oe)=>(x.add(oe),V==="define"?` #ifndef HAS_UNIFORM_u_${oe} in ${X} ${ne} ${oe}; #else uniform ${X} ${ne} u_${oe}; #endif `:V==="initialize"?` #ifdef HAS_UNIFORM_u_${oe} ${X} ${ne} ${oe} = u_${oe}; #endif `:V==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${oe} in ${X} ${ne} ${oe}; #endif `:V==="initialize-attribute"?"":void 0)),vertexSource:h=h.replace(Op,(z,V,X,ne,oe)=>{const ge=`MATERIAL_ATTRIBUTE_OFFSET_${oe}`,pe=ne==="float"?"vec2":ne,xe=`GET_ATTRIBUTE_${pe}(a_${oe}, materialInfo, ${ge})`,Pe=oe.match(/color/)?"color":pe;return V==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${oe} in ${X} ${ne} a_${oe}; #endif `:x.has(oe)?V==="define"?` #ifndef HAS_UNIFORM_u_${oe} uniform lowp float u_${oe}_t; #if !defined(${ge}) in ${X} ${pe} a_${oe}; #endif out ${X} ${ne} ${oe}; #else uniform ${X} ${ne} u_${oe}; #endif `:V==="initialize"?Pe==="vec4"?` #ifndef HAS_UNIFORM_u_${oe} ${oe} = a_${oe}; #else ${X} ${ne} ${oe} = u_${oe}; #endif `:` #if !defined(HAS_UNIFORM_u_${oe}) #ifdef ${ge} ${oe} = unpack_mix_${Pe}(${xe}, u_${oe}_t); #else ${oe} = unpack_mix_${Pe}(a_${oe}, u_${oe}_t); #endif #else ${X} ${ne} ${oe} = u_${oe}; #endif `:V==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${oe} in ${X} ${ne} a_${oe}; out ${X} ${ne} ${oe}; #endif `:V==="initialize-attribute"?` #ifdef HAS_ATTRIBUTE_a_${oe} ${oe} = a_${oe}; #endif `:void 0:V==="define"?` #ifndef HAS_UNIFORM_u_${oe} uniform lowp float u_${oe}_t; #if !defined(${ge}) in ${X} ${pe} a_${oe}; #endif #else uniform ${X} ${ne} u_${oe}; #endif `:V==="define-instanced"?Pe==="mat4"?` #ifdef INSTANCED_ARRAYS in vec4 a_${oe}0; in vec4 a_${oe}1; in vec4 a_${oe}2; in vec4 a_${oe}3; #else uniform ${X} ${ne} u_${oe}; #endif `:` #ifdef INSTANCED_ARRAYS in ${X} ${pe} a_${oe}; #else uniform ${X} ${ne} u_${oe}; #endif `:V==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${oe} ${X} ${ne} ${oe} = a_${oe}; #endif `:Pe==="vec4"?` #ifndef HAS_UNIFORM_u_${oe} #ifdef ${ge} ${X} ${ne} ${oe} = ${xe}; #else ${X} ${ne} ${oe} = a_${oe}; #endif #else ${X} ${ne} ${oe} = u_${oe}; #endif `:` #ifndef HAS_UNIFORM_u_${oe} #ifdef ${ge} ${X} ${ne} ${oe} = unpack_mix_${Pe}(${xe}, u_${oe}_t); #else ${X} ${ne} ${oe} = unpack_mix_${Pe}(a_${oe}, u_${oe}_t); #endif #else ${X} ${ne} ${oe} = u_${oe}; #endif `}),usedDefines:F,vertexIncludes:A,fragmentIncludes:D}}class Yce{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(h,x,A,D,F,z,V,X){this.context=h;let ne=this.boundPaintVertexBuffers.length!==D.length;for(let ge=0;!ne&&ge{const Mt=dt.paint.get("hillshade-shadow-color"),yt=dt.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",jt=dt.paint.get("hillshade-highlight-color"),gt=dt.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",mt=dt.paint.get("hillshade-accent-color"),Et=dt.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Ht=dt.paint.get("hillshade-emissive-strength");let Ut=i.an(dt.paint.get("hillshade-illumination-direction"));if(dt.paint.get("hillshade-illumination-anchor")==="viewport")Ut-=Be.transform.angle;else if(Be.style&&Be.style.enable3dLights()&&Be.style.directionalLight){const ns=Be.style.directionalLight.properties.get("direction"),fs=i.d4(ns.x,ns.y,ns.z);Ut=i.an(fs[1])}const ts=!Be.options.moving;return{u_matrix:st||Be.transform.calculateProjMatrix(tt.tileID.toUnwrapped(),ts),u_image:0,u_latrange:Xce(0,tt.tileID),u_light:[dt.paint.get("hillshade-exaggeration"),Ut],u_shadow:Mt.toPremultipliedRenderColor(yt?null:dt.lut),u_highlight:jt.toPremultipliedRenderColor(gt?null:dt.lut),u_emissive_strength:Ht,u_accent:mt.toPremultipliedRenderColor(Et?null:dt.lut)}})(M,x,A,M.terrain?h.projMatrix:null);M.uploadCommonUniforms(V,pe,h.toUnwrapped());const{tileBoundsBuffer:Pe,tileBoundsIndexBuffer:Ce,tileBoundsSegments:Ve}=M.getTileBoundsBuffers(x);pe.draw(M,X.TRIANGLES,D,F,z,rn.disabled,xe,A.id,Pe,Ce,Ve)}function pT(M,h,x){if(!h.needsDEMTextureUpload)return;const A=M.context,D=A.gl;A.pixelStoreUnpackPremultiplyAlpha.set(!1),h.demTexture=h.demTexture||M.getTileTexture(x.stride);const F=x.getPixels();h.demTexture?h.demTexture.update(F,{premultiply:!1}):h.demTexture=new i.T(A,F,D.R32F,{premultiply:!1}),h.needsDEMTextureUpload=!1}function Jce(M,h,x){const A=M.context,D=A.gl;if(!h.dem)return;const F=h.dem;if(A.activeTexture.set(D.TEXTURE1),pT(M,h,F),!h.demTexture)return;h.demTexture.bind(D.NEAREST,D.CLAMP_TO_EDGE);const z=F.dim;A.activeTexture.set(D.TEXTURE0);let V=h.hillshadeFBO;if(!V){const pe=new i.T(A,{width:z,height:z,data:null},D.RGBA8);pe.bind(D.LINEAR,D.CLAMP_TO_EDGE),V=h.hillshadeFBO=A.createFramebuffer(z,z,1,"renderbuffer"),V.colorAttachment0.set(pe.texture)}A.bindFramebuffer.set(V.framebuffer),A.viewport.set([0,0,z,z]);const{tileBoundsBuffer:X,tileBoundsIndexBuffer:ne,tileBoundsSegments:oe}=M.getMercatorTileBoundsBuffers(),ge=[];M.linearFloatFilteringSupported()&&ge.push("TERRAIN_DEM_FLOAT_FORMAT"),M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback"&&ge.push("USE_MRT1"),M.getOrCreateProgram("hillshadePrepare",{defines:ge}).draw(M,D.TRIANGLES,Lr.disabled,dn.disabled,Dn.unblended,rn.disabled,((pe,xe)=>{const Pe=xe.stride,Ce=i.bC();return i.ce(Ce,0,i.al,-i.al,0,0,1),i.br(Ce,Ce,[0,-i.al,0]),{u_matrix:Ce,u_image:1,u_dimension:[Pe,Pe],u_zoom:pe.overscaledZ}})(h.tileID,F),x.id,X,ne,oe),h.needsHillshadePrepare=!1}class to{constructor(h){this.gl=h.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(h){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class ede extends to{getDefault(){return i.ao.transparent.toNonPremultipliedRenderColor(null)}set(h){const x=this.current;(h.r!==x.r||h.g!==x.g||h.b!==x.b||h.a!==x.a||this.dirty)&&(this.gl.clearColor(h.r,h.g,h.b,h.a),this.current=h,this.dirty=!1)}}class SD extends to{getDefault(){return 1}set(h){(h!==this.current||this.dirty)&&(this.gl.clearDepth(h),this.current=h,this.dirty=!1)}}class fT extends to{getDefault(){return 0}set(h){(h!==this.current||this.dirty)&&(this.gl.clearStencil(h),this.current=h,this.dirty=!1)}}class OS extends to{getDefault(){return[!0,!0,!0,!0]}set(h){const x=this.current;(h[0]!==x[0]||h[1]!==x[1]||h[2]!==x[2]||h[3]!==x[3]||this.dirty)&&(this.gl.colorMask(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class gT extends to{getDefault(){return!0}set(h){(h!==this.current||this.dirty)&&(this.gl.depthMask(h),this.current=h,this.dirty=!1)}}class Ly extends to{getDefault(){return 255}set(h){(h!==this.current||this.dirty)&&(this.gl.stencilMask(h),this.current=h,this.dirty=!1)}}class kv extends to{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(h){const x=this.current;(h.func!==x.func||h.ref!==x.ref||h.mask!==x.mask||this.dirty)&&(this.gl.stencilFunc(h.func,h.ref,h.mask),this.current=h,this.dirty=!1)}}class _b extends to{getDefault(){const h=this.gl;return[h.KEEP,h.KEEP,h.KEEP]}set(h){const x=this.current;(h[0]!==x[0]||h[1]!==x[1]||h[2]!==x[2]||this.dirty)&&(this.gl.stencilOp(h[0],h[1],h[2]),this.current=h,this.dirty=!1)}}class Sv extends to{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;h?x.enable(x.STENCIL_TEST):x.disable(x.STENCIL_TEST),this.current=h,this.dirty=!1}}class CD extends to{getDefault(){return[0,1]}set(h){const x=this.current;(h[0]!==x[0]||h[1]!==x[1]||this.dirty)&&(this.gl.depthRange(h[0],h[1]),this.current=h,this.dirty=!1)}}class xT extends to{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;h?x.enable(x.DEPTH_TEST):x.disable(x.DEPTH_TEST),this.current=h,this.dirty=!1}}class MD extends to{getDefault(){return this.gl.LESS}set(h){(h!==this.current||this.dirty)&&(this.gl.depthFunc(h),this.current=h,this.dirty=!1)}}class Cv extends to{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;h?x.enable(x.BLEND):x.disable(x.BLEND),this.current=h,this.dirty=!1}}class RS extends to{getDefault(){const h=this.gl;return[h.ONE,h.ZERO,h.ONE,h.ZERO]}set(h){const x=this.current;(h[0]!==x[0]||h[1]!==x[1]||h[2]!==x[2]||h[3]!==x[3]||this.dirty)&&(this.gl.blendFuncSeparate(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class FS extends to{getDefault(){return i.ao.transparent.toNonPremultipliedRenderColor(null)}set(h){const x=this.current;(h.r!==x.r||h.g!==x.g||h.b!==x.b||h.a!==x.a||this.dirty)&&(this.gl.blendColor(h.r,h.g,h.b,h.a),this.current=h,this.dirty=!1)}}class yT extends to{getDefault(){return this.gl.FUNC_ADD}set(h){(h!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(h,h),this.current=h,this.dirty=!1)}}class zS extends to{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;h?x.enable(x.CULL_FACE):x.disable(x.CULL_FACE),this.current=h,this.dirty=!1}}class bb extends to{getDefault(){return this.gl.BACK}set(h){(h!==this.current||this.dirty)&&(this.gl.cullFace(h),this.current=h,this.dirty=!1)}}class TD extends to{getDefault(){return this.gl.CCW}set(h){(h!==this.current||this.dirty)&&(this.gl.frontFace(h),this.current=h,this.dirty=!1)}}let AD=class extends to{getDefault(){return null}set(M){(M!==this.current||this.dirty)&&(this.gl.useProgram(M),this.current=M,this.dirty=!1)}};class ED extends to{getDefault(){return this.gl.TEXTURE0}set(h){(h!==this.current||this.dirty)&&(this.gl.activeTexture(h),this.current=h,this.dirty=!1)}}class Mv extends to{getDefault(){const h=this.gl;return[0,0,h.drawingBufferWidth,h.drawingBufferHeight]}set(h){const x=this.current;(h[0]!==x[0]||h[1]!==x[1]||h[2]!==x[2]||h[3]!==x[3]||this.dirty)&&(this.gl.viewport(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class PD extends to{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.bindFramebuffer(x.FRAMEBUFFER,h),this.current=h,this.dirty=!1}}class tde extends to{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.bindRenderbuffer(x.RENDERBUFFER,h),this.current=h,this.dirty=!1}}class sde extends to{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.bindTexture(x.TEXTURE_2D,h),this.current=h,this.dirty=!1}}class rde extends to{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.bindBuffer(x.ARRAY_BUFFER,h),this.current=h,this.dirty=!1}}class vT extends to{getDefault(){return null}set(h){const x=this.gl;x.bindBuffer(x.ELEMENT_ARRAY_BUFFER,h),this.current=h,this.dirty=!1}}class _T extends to{getDefault(){return null}set(h){this.gl&&(h!==this.current||this.dirty)&&(this.gl.bindVertexArray(h),this.current=h,this.dirty=!1)}}class bT extends to{getDefault(){return 4}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.pixelStorei(x.UNPACK_ALIGNMENT,h),this.current=h,this.dirty=!1}}class wT extends to{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.pixelStorei(x.UNPACK_PREMULTIPLY_ALPHA_WEBGL,h),this.current=h,this.dirty=!1}}class ID extends to{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.pixelStorei(x.UNPACK_FLIP_Y_WEBGL,h),this.current=h,this.dirty=!1}}class BS extends to{constructor(h,x){super(h),this.context=h,this.parent=x}getDefault(){return null}}class $S extends BS{constructor(h,x,A=0){super(h,x),this.attachmentPoint=h.gl.COLOR_ATTACHMENT0+A}setDirty(){this.dirty=!0}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const x=this.gl;x.framebufferTexture2D(x.FRAMEBUFFER,this.attachmentPoint,x.TEXTURE_2D,h,0),this.current=h,this.dirty=!1}}class Tv extends BS{attachment(){return this.gl.DEPTH_ATTACHMENT}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const x=this.gl;x.framebufferRenderbuffer(x.FRAMEBUFFER,this.attachment(),x.RENDERBUFFER,h),this.current=h,this.dirty=!1}}class wb extends BS{attachment(){return this.gl.DEPTH_ATTACHMENT}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const x=this.gl;x.framebufferTexture2D(x.FRAMEBUFFER,this.attachment(),x.TEXTURE_2D,h,0),this.current=h,this.dirty=!1}}class LD extends Tv{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const _h=(M,h,x,A)=>({u_matrix:M,u_image0:0,u_image1:1,u_skirt_height:h,u_ground_shadow_factor:x,u_emissive_texture_available:A}),qS=(M,h,x,A,D,F,z,V,X,ne,oe,ge,pe,xe,Pe,Ce,Ve)=>({u_proj_matrix:Float32Array.from(M),u_globe_matrix:h,u_normalize_matrix:Float32Array.from(A),u_merc_matrix:x,u_zoom_transition:D,u_merc_center:F,u_image0:0,u_image1:1,u_frustum_tl:z,u_frustum_tr:V,u_frustum_br:X,u_frustum_bl:ne,u_globe_pos:oe,u_globe_radius:ge,u_viewport:pe,u_grid_matrix:Ve?Float32Array.from(Ve):new Float32Array(9),u_skirt_height:xe,u_far_z_cutoff:Pe,u_emissive_texture_available:Ce});function jb(M,h){return M!=null&&h!=null&&!(!M.hasData()||!h.hasData())&&M.demTexture!=null&&h.demTexture!=null&&M.tileID.key!==h.tileID.key}const Gf=new class{constructor(){this.operations={}}newMorphing(M,h,x,A,D){if(M in this.operations){const F=this.operations[M];F.to.tileID.key!==x.tileID.key&&(F.queued=x)}else this.operations[M]={startTime:A,phase:0,duration:D,from:h,to:x,queued:null}}getMorphValuesForProxy(M){if(!(M in this.operations))return null;const h=this.operations[M];return{from:h.from,to:h.to,phase:h.phase}}update(M){for(const h in this.operations){const x=this.operations[h];for(x.phase=(M-x.startTime)/x.duration;x.phase>=1||!this._validOp(x);)if(!this._nextOp(x,M)){delete this.operations[h];break}}}_nextOp(M,h){return!!M.queued&&(M.from=M.to,M.to=M.queued,M.queued=null,M.phase=0,M.startTime=h,!0)}_validOp(M){return M.from.hasData()&&M.to.hasData()}},US={0:null,1:"TERRAIN_VERTEX_MORPHING"};function VS(M,h,x){if(h===0)return 0;const A=h<1&&x===514?.25/h:1;return 6*Math.pow(1.5,22-M)*Math.max(h,1)*A}function jT(M,h){const x=1<({u_matrix:M});function kb(M,h,x,A,D){if(D>0){const F=i.o.now(),z=(F-M.timeAdded)/D,V=h?(F-h.timeAdded)/D:-1,X=x.getSource(),ne=A.coveringZoomLevel({tileSize:X.tileSize,roundZoom:X.roundZoom}),oe=!h||Math.abs(h.tileID.overscaledZ-ne)>Math.abs(M.tileID.overscaledZ-ne),ge=oe&&M.refreshedUponExpiration?1:i.aA(oe?z:1-V,0,1);return h?{opacity:1,mix:1-ge,isFading:z<1}:{opacity:ge,mix:0,isFading:z<1}}return{opacity:1,mix:0,isFading:!1}}class HS extends hl{constructor(h){const x=_l("mock-dem",{type:"raster-dem",maxzoom:h.transform.maxZoom},h.style.dispatcher,h.style);super("mock-dem",x,!1),x.setEventedParent(this),this._sourceLoaded=!0}_loadTile(h,x){h.state="loaded",x(null)}}class NT extends hl{constructor(h){const x=_l("proxy",{type:"geojson",maxzoom:h.transform.maxZoom},h.style.dispatcher,h.style);super("proxy",x,!1),x.setEventedParent(this),this.map=this.getSource().map=h,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(h,x,A){if(h.freezeTileCoverage)return;this.transform=h;const D=h.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((F,z)=>{if(F[z.key]="",!this._tiles[z.key]){const V=new nm(z,this._source.tileSize*z.overscaleFactor(),h.tileZoom,void 0,void 0,this._source.worldview);V.state="loaded",this._tiles[z.key]=V}return F},{});for(const F in this._tiles)F in D||(this.freeFBO(F),this._tiles[F].unloadVectorData(),delete this._tiles[F])}freeFBO(h){const x=this.proxyCachedFBO[h];if(x!==void 0){const A=Object.values(x);this.renderCachePool.push(...A),delete this.proxyCachedFBO[h]}}deallocRenderCache(){this.renderCache.forEach(h=>h.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class kT extends i.aQ{constructor(h,x,A){super(h.overscaledZ,h.wrap,h.canonical.z,h.canonical.x,h.canonical.y),this.proxyTileKey=x,this.projMatrix=A}}class ST extends i.bV{constructor(h,x){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=h,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[A,D,F]=function(X){const ne=new i.bd,oe=new i.b0,ge=131;ne.reserve(17161),oe.reserve(33800);const pe=i.al/128,xe=i.al+pe/2,Pe=xe+pe;for(let Ve=-pe;Vexe||Ve<0||Ve>xe?24575:0,dt=i.aA(Math.round(Be),0,i.al),st=i.aA(Math.round(Ve),0,i.al);ne.emplaceBack(dt+tt,st)}const Ce=(Ve,Be)=>{const tt=Be*ge+Ve;oe.emplaceBack(tt+1,tt,tt+ge),oe.emplaceBack(tt+ge,tt+ge+1,tt+1)};for(let Ve=1;Ve<129;Ve++)for(let Be=1;Be<129;Be++)Ce(Be,Ve);return[0,129].forEach(Ve=>{for(let Be=0;Be<130;Be++)Ce(Be,Ve),Ce(Ve,Be)}),[ne,oe,32768]}(),z=h.context;this.gridBuffer=z.createVertexBuffer(A,i.bf.members),this.gridIndexBuffer=z.createIndexBuffer(D),this.gridSegments=i.bg.simpleSegment(0,0,A.length,D.length),this.gridNoSkirtSegments=i.bg.simpleSegment(0,0,A.length,F),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new NT(x.map),this.orthoMatrix=i.bC(),i.ce(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,i.al,0,i.al,0,1);const V=z.gl;this._overlapStencilMode=new dn({func:V.GEQUAL,mask:255},0,255,V.KEEP,V.KEEP,V.REPLACE),this._previousZoom=h.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=x,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new HS(x.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1}set style(h){h.on("data",this._onStyleDataEvent.bind(this)),this._style=h,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(h,x,A){if(h&&h.terrain){this._style!==h&&(this.style=h,this._evaluationZoom=void 0);const D=h.terrain.properties,F=h.terrain.drapeRenderMode===0,z=h.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=i.o.now();const V=h.terrain&&h.terrain.scope,X=D.get("source"),ne=F?this._mockSourceCache:h.getSourceCache(X,V);if(!ne)return void i.w(`Couldn't find terrain source "${X}".`);if(this.sourceCache=ne,this._attenuationRange=h.terrain.getAttenuationRange(),this._exaggeration=z?this.calculateExaggeration(x):D.get("exaggeration"),!x.projection.requiresDraping&&z&&this._exaggeration===0)return void this._disable();this.enabled=!0;const oe=()=>{this.sourceCache.used&&i.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source. This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const ge=this.getScaledDemTileSize();this.sourceCache.update(x,ge,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,oe(),this._initializing=!0),oe(),x.updateElevation(!0,A),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(x),this._emptyDEMTextureDirty=!0,this._previousZoom=x.zoom}else this._disable()}calculateExaggeration(h){if(this._attenuationRange&&h.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(h.zoom);const x=this._previousCameraAltitude,A=h.getFreeCameraOptions().position.z/h.pixelsPerMeter*h.worldSize;this._previousCameraAltitude=A;const D=x!=null?A-x:Number.MAX_VALUE;if(Math.abs(D)<2)return this._exaggeration;const F=h.zoom,z=this._style.terrain;if(!this._previousUpdateTimestamp)return z.getExaggeration(F);let V=F-this._previousZoom;const X=this._previousUpdateTimestamp;let ne=F;this._evaluationZoom!=null&&(ne=this._evaluationZoom,Math.abs(F-ne)>.5&&(V=.5*(F-ne+V)),V*D<0&&(ne+=V)),this._evaluationZoom=ne;const oe=z.getExaggeration(ne),ge=oe===z.getExaggeration(Math.max(0,ne-.1));if(ge&&Math.abs(oe-this._exaggeration)<.01)return oe;let pe=Math.min(.1,.00375*(this._updateTimestamp-X));return(ge||oe<.1||Math.abs(V)<1e-4)&&(pe=Math.min(.2,4*pe)),i.ak(this._exaggeration,oe,pe)}resetTileLookupCache(h){this._findCoveringTileCache[h]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(h){h.dataType==="source"&&h.coord?this._clearRenderCacheForTile(h.sourceCacheId,h.coord):h.dataType==="style"&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const h in this._style._mergedSourceCaches)this._style._mergedSourceCaches[h].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(h=>h.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const h=2*this.proxySourceCache.getSource().tileSize;return[h,h]}set useVertexMorphing(h){this._useVertexMorphing=h}updateTileBinding(h){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const x=this.proxySourceCache,A=this.painter.transform;this._initializing&&(this._initializing=A._centerAltitude===0&&this.getAtPointOrZero(i.ae.fromLngLat(A.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const D=this.proxyCoords=x.getIds().map(X=>{const ne=x.getTileByID(X).tileID;return ne.projMatrix=A.calculateProjMatrix(ne.toUnwrapped()),ne});(function(X,ne){const oe=ne.transform.pointCoordinate(ne.transform.getCameraPoint()),ge=new i.P(oe.x,oe.y);X.sort((pe,xe)=>{if(xe.overscaledZ-pe.overscaledZ)return xe.overscaledZ-pe.overscaledZ;const Pe=new i.P(pe.canonical.x+(1<{this.proxyToSource[X.key]={}}),this.terrainTileForTile={};const z=this._style._mergedSourceCaches;for(const X in z){const ne=z[X];if(!ne.used||(ne!==this.sourceCache&&this.resetTileLookupCache(ne.id),this._setupProxiedCoordsForOrtho(ne,h[X],F),ne.usedForTerrain))continue;const oe=h[X];ne.getSource().reparseOverscaled&&this._assignTerrainTiles(oe)}this.proxiedCoords[x.id]=D.map(X=>new kT(X,X.key,this.orthoMatrix)),this._assignTerrainTiles(D),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(F),this.renderingToTexture=!1;const V={};this._visibleDemTiles=[];for(const X of this.proxyCoords){const ne=this.terrainTileForTile[X.key];if(!ne)continue;const oe=ne.tileID.key;oe in V||(this._visibleDemTiles.push(ne),V[oe]=oe)}}_assignTerrainTiles(h){this._initializing||h.forEach(x=>{if(this.terrainTileForTile[x.key])return;const A=this._findTileCoveringTileID(x,this.sourceCache);A&&(this.terrainTileForTile[x.key]=A)})}_prepareDEMTextures(){const h=this.painter.context,x=h.gl;for(const A in this.terrainTileForTile){const D=this.terrainTileForTile[A],F=D.dem;!F||D.demTexture&&!D.needsDEMTextureUpload||(h.activeTexture.set(x.TEXTURE1),pT(this.painter,D,F))}}_prepareDemTileUniforms(h,x,A,D){if(!x||x.demTexture==null)return!1;const F=h.tileID.canonical,z=Math.pow(2,x.tileID.canonical.z-F.z),V=D||"";return A[`u_dem_tl${V}`]=[F.x*z%1,F.y*z%1],A[`u_dem_scale${V}`]=z,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let h=0;const x=this._visibleDemTiles.reduce((A,D)=>{if(!D.dem)return A;const F=D.dem.tree.minimums[0];return F>0&&h++,A+F},0);return h?x/h:0}_updateEmptyDEMTexture(){const h=this.painter.context,x=h.gl;h.activeTexture.set(x.TEXTURE2);const A=this._getLoadedAreaMinimum(),D=new i.dL({width:1,height:1},new Float32Array([A]));this._emptyDEMTextureDirty=!1;let F=this._emptyDEMTexture;return F?F.update(D,{premultiply:!1}):F=this._emptyDEMTexture=new i.T(h,D,x.R32F,{premultiply:!1}),F}setupElevationDraw(h,x,A){const D=this.painter.context,F=D.gl,z={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};z.u_exaggeration=this.exaggeration();let V=null,X=null,ne=1;if(A&&A.morphing&&this._useVertexMorphing){const xe=A.morphing.srcDemTile,Pe=A.morphing.dstDemTile;ne=A.morphing.phase,xe&&Pe&&(this._prepareDemTileUniforms(h,xe,z,"_prev")&&(X=xe),this._prepareDemTileUniforms(h,Pe,z)&&(V=Pe))}const oe=xe=>xe&&xe.demTexture&&this.painter.linearFloatFilteringSupported()?F.LINEAR:F.NEAREST;let ge=null;var pe;if(this.enabled?X&&V?(ge=V.demTexture,D.activeTexture.set(F.TEXTURE4),X.demTexture.bind(oe(X),F.CLAMP_TO_EDGE),z.u_dem_lerp=ne):(V=this.terrainTileForTile[h.tileID.key],ge=this._prepareDemTileUniforms(h,V,z)?V.demTexture:this.emptyDEMTexture):ge=this.emptyDEMTexture,D.activeTexture.set(F.TEXTURE2),ge&&(z.u_dem_size=(pe=ge).size[0]===1?1:pe.size[0]-2,ge.bind(oe(V),F.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(A&&A.useDepthForOcclusion,x,z),A&&A.useMeterToDem&&V){const xe=(1<{if(Be===ns)return;const fs=[US[ns],"PROJECTION_GLOBE_VIEW"];dt&&fs.push("CUSTOM_ANTIALIASING");const Bs=ne.isTileAffectedByFog(ts);Ve=ne.getOrCreateProgram("globeRaster",{defines:fs,overrideFog:Bs}),Be=ns},Mt=ne.colorModeForRenderPass(),yt=new Lr(Ce.LEQUAL,Lr.ReadWrite,ne.depthRangeFor3D);Gf.update(xe);const jt=i.dF(tt),gt=[i.aF(tt.center.lng),i.aJ(tt.center.lat)],mt=ne.globeSharedBuffers,Et=[tt.width*i.o.devicePixelRatio,tt.height*i.o.devicePixelRatio],Ht=Float32Array.from(tt.globeMatrix),Ut={useDenormalizedUpVectorScale:!0};{const ts=ne.transform,ns=VS(ts.zoom,oe.exaggeration(),oe.sourceCache._source.tileSize);Be=-1;const fs=Ce.TRIANGLES;for(const Bs of pe){const Yt=ge.getTile(Bs),zt=dn.disabled,ds=oe.prevTerrainTileForTile[Bs.key],Jt=oe.terrainTileForTile[Bs.key];jb(ds,Jt)&&Gf.newMorphing(Bs.key,ds,Jt,xe,250),Av(ne,Yt.emissiveTexture),Pe.activeTexture.set(Ce.TEXTURE0),Yt.texture&&Yt.texture.bind(Ce.LINEAR,Ce.CLAMP_TO_EDGE);const Es=Gf.getMorphValuesForProxy(Bs.key),Js=Es?1:0;Es&&Object.assign(Ut,{morphing:{srcDemTile:Es.from,dstDemTile:Es.to,phase:i.dD(Es.phase)}});const mr=i.dG(Bs.canonical),Ys=i.dH(mr.getCenter().lat),Us=i.dI(Bs.canonical,mr,Ys,ts.worldSize/ts._pixelsPerMercatorPixel),Cr=i.bk(i.dJ(Bs.canonical)),Nr=ne.emissiveMode==="mrt-fallback"?1:0,cr=qS(ts.expandedFarZProjMatrix,Ht,jt,Cr,i.aj(ts.zoom),gt,ts.frustumCorners.TL,ts.frustumCorners.TR,ts.frustumCorners.BR,ts.frustumCorners.BL,ts.globeCenterInViewSpace,ts.globeRadius,Et,ns,ts._farZ,Nr,Us);if(st(Bs,Js),Ve&&(oe.setupElevationDraw(Yt,Ve,Ut),ne.uploadCommonUniforms(Pe,Ve,Bs.toUnwrapped()),mt)){const[xr,Vr,jn]=mt.getGridBuffers(Ys,ns!==0);Ve.draw(ne,fs,yt,zt,Mt,rn.backCCW,cr,"globe_raster",xr,Vr,jn)}}}if(mt&&(ne.renderDefaultNorthPole||ne.renderDefaultSouthPole)){const ts=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];dt&&ts.push("CUSTOM_ANTIALIASING"),Ve=ne.getOrCreateProgram("globeRaster",{defines:ts});for(const ns of pe){const{x:fs,y:Bs,z:Yt}=ns.canonical,zt=Bs===0,ds=Bs===(1<xr.draw(ne,Ce.TRIANGLES,yt,dn.disabled,Mt,rn.disabled,qS(tt.expandedFarZProjMatrix,Us,Us,Cr,0,gt,tt.frustumCorners.TL,tt.frustumCorners.TR,tt.frustumCorners.BR,tt.frustumCorners.BL,tt.globeCenterInViewSpace,tt.globeRadius,Et,0,tt._farZ,Nr),"globe_pole_raster",Vr,Js,mr);oe.setupElevationDraw(Ys,Ve,Ut),ne.uploadCommonUniforms(Pe,Ve,ns.toUnwrapped()),zt&&ne.renderDefaultNorthPole&&cr(Ve,Jt),ds&&ne.renderDefaultSouthPole&&(Us=i.cS(i.bC(),Us,[1,-1,1]),cr(Ve,Es))}}}})(D,F,z,V,X);else{const ne=D.context,oe=ne.gl;let ge,pe;const xe=D.shadowRenderer,Pe=cx(D,D.longestCutoffRange),Ce=Mt=>{if(pe===Mt)return;const yt=[];yt.push(US[Mt]),Pe.shouldRenderCutoff&&yt.push("RENDER_CUTOFF"),xe&&(yt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),xe.useNormalOffset&&yt.push("NORMAL_OFFSET")),ge=D.getOrCreateProgram("terrainRaster",{defines:yt}),pe=Mt},Ve=D.colorModeForRenderPass(),Be=new Lr(oe.LEQUAL,Lr.ReadWrite,D.depthRangeFor3D);Gf.update(X);const tt=D.transform,dt=VS(tt.zoom,F.exaggeration(),F.sourceCache._source.tileSize);let st=[0,0,0];if(xe){const Mt=D.style.directionalLight,yt=D.style.ambientLight;Mt&&yt&&(st=Wf(D.style,Mt,yt))}{pe=-1;const Mt=oe.TRIANGLES,[yt,jt]=[F.gridIndexBuffer,F.gridSegments];for(const gt of V){const mt=z.getTile(gt),Et=dn.disabled,Ht=F.prevTerrainTileForTile[gt.key],Ut=F.terrainTileForTile[gt.key];jb(Ht,Ut)&&Gf.newMorphing(gt.key,Ht,Ut,X,250),Av(D,mt.emissiveTexture),ne.activeTexture.set(oe.TEXTURE0),mt.texture&&mt.texture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE);const ts=Gf.getMorphValuesForProxy(gt.key),ns=ts?1:0;let fs;ts&&(fs={morphing:{srcDemTile:ts.from,dstDemTile:ts.to,phase:i.dD(ts.phase)}});const Bs=D.emissiveMode==="mrt-fallback"?1:0,Yt=_h(gt.projMatrix,jT(gt.canonical,tt.renderWorldCopies)?dt/10:dt,st,Bs);if(Ce(ns),!ge)continue;F.setupElevationDraw(mt,ge,fs);const zt=gt.toUnwrapped();xe&&xe.setupShadows(zt,ge),D.uploadCommonUniforms(ne,ge,zt,null,Pe),ge.draw(D,Mt,Be,Et,Ve,rn.backCCW,Yt,"terrain_raster",F.gridBuffer,yt,jt)}}}}(x,this,this.proxySourceCache,h,this._updateTimestamp),this.renderingToTexture=!0,x.gpuTimingDeferredRenderEnd(),h.splice(0,h.length))}renderBatch(h){if(this._drapedRenderBatches.length===0)return h+1;this.renderingToTexture=!0;const x=this.painter,A=this.painter.context,D=this.proxySourceCache,F=this.proxiedCoords[D.id],z=this._drapedRenderBatches.shift(),V=x.style.order,X=[];this._updateFBOs(x.emissiveMode==="mrt-fallback");let ne=0;for(const oe of F){const ge=D.getTileByID(oe.proxyTileKey),pe=D.proxyCachedFBO[oe.key]?D.proxyCachedFBO[oe.key][h]:void 0,xe=pe!==void 0?D.renderCache[pe]:this.pool[ne++],Pe=pe!==void 0;if(ge.texture=xe.tex,ge.emissiveTexture=xe.emissiveTex,Pe&&!xe.dirty){X.push(ge.tileID);continue}A.bindFramebuffer.set(xe.fb.framebuffer);const Ce=A.gl;let Ve;Ce.drawBuffers(x.emissiveMode==="mrt-fallback"?[Ce.COLOR_ATTACHMENT0,Ce.COLOR_ATTACHMENT1]:[Ce.COLOR_ATTACHMENT0]),this.renderedToTile=!1,xe.dirty&&(A.clear({color:i.ao.transparent,stencil:0}),xe.dirty=!1);for(let Be=z.start;Be<=z.end;++Be){const tt=x.style._mergedLayers[V[Be]];if(tt.isHidden(x.transform.zoom))continue;const dt=x.style.getLayerSourceCache(tt),st=dt?this.proxyToSource[oe.key][dt.id]:[oe];if(!st)continue;const Mt=st;A.viewport.set([0,0,xe.fb.width,xe.fb.height]),Ve!==(dt?dt.id:null)&&(this._setupStencil(xe,st,tt,dt),Ve=dt?dt.id:null),x.renderLayer(x,dt,tt,Mt)}if(Ce.drawBuffers([Ce.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const Be of this._pendingGroundEffectLayers){const tt=x.style._mergedLayers[V[Be]];if(tt.isHidden(x.transform.zoom))continue;const dt=x.style.getLayerSourceCache(tt),st=dt?this.proxyToSource[oe.key][dt.id]:[oe];if(!st)continue;const Mt=st;A.viewport.set([0,0,xe.fb.width,xe.fb.height]),Ve!==(dt?dt.id:null)&&(this._setupStencil(xe,st,tt,dt),Ve=dt?dt.id:null),x.renderLayer(x,dt,tt,Mt)}this.renderedToTile?(xe.dirty=!0,X.push(ge.tileID)):Pe||--ne,ne===5&&(ne=0,this.renderToBackBuffer(X))}return this.renderToBackBuffer(X),this.renderingToTexture=!1,A.bindFramebuffer.set(null),A.viewport.set([0,0,x.width,x.height]),z.end+1}postRender(){}isLayerOrderingCorrect(h){const x=h.order.length;let A=-1,D=x;for(let F=0;FA}getMinElevationBelowMSL(){let h=0;return this._visibleDemTiles.filter(x=>x.dem).forEach(x=>{h=Math.min(h,x.dem.tree.minimums[0])}),h===0?h:(h-30)*this._exaggeration}raycast(h,x,A){if(!this._visibleDemTiles)return null;const D=this._visibleDemTiles.filter(F=>F.dem).map(F=>{const z=F.tileID,V=1<(F.t!==null?F.t:Number.MAX_VALUE)-(z.t!==null?z.t:Number.MAX_VALUE));for(const F of D){if(F.t==null)return null;const z=F.tile.dem.tree.raycast(F.minx,F.miny,F.maxx,F.maxy,h,x,A);if(z!=null)return z}return null}_createFBO(){const h=this.painter.context,x=h.gl,A=this.drapeBufferSize;h.activeTexture.set(x.TEXTURE0);const D=new i.T(h,{width:A[0],height:A[1],data:null},x.RGBA8);D.bind(x.LINEAR,x.CLAMP_TO_EDGE);const F=h.createFramebuffer(A[0],A[1],1,null);let z;return F.colorAttachment0.set(D.texture),this._emissiveTexture&&(z=new i.T(h,{width:A[0],height:A[1],data:null},x.R8),z.bind(x.LINEAR,x.CLAMP_TO_EDGE),F.createColorAttachment(h,1),F.colorAttachment1.set(z.texture)),F.depthAttachment=new LD(h,F.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=h.createRenderbuffer(h.gl.DEPTH_STENCIL,A[0],A[1]),this._stencilRef=0,F.depthAttachment.set(this._sharedDepthStencil),h.clear({stencil:0})):F.depthAttachment.set(this._sharedDepthStencil),h.extTextureFilterAnisotropic&&x.texParameterf(x.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax),{fb:F,tex:D,emissiveTex:z,dirty:!1}}_updateFBOs(h){if(this._emissiveTexture!==h){for(const x of this.pool)this._updateFBO(x,h);for(const x of this.proxySourceCache.renderCache)this._updateFBO(x,h);this._emissiveTexture=h}}_updateFBO(h,x){const A=h.fb,D=this.painter.context,F=D.gl,z=this.drapeBufferSize;if(x){const V=new i.T(D,{width:z[0],height:z[1],data:null},F.R8);V.bind(F.LINEAR,F.CLAMP_TO_EDGE),h.emissiveTex=V,A.createColorAttachment(D,1),A.colorAttachment1.set(V.texture)}else h.emissiveTex=void 0,A.removeColorAttachment(D,1);h.dirty=!0}_initFBOPool(){for(;this.pool.length{const x=this._style._mergedLayers[h],A=x.isHidden(this.painter.transform.zoom);return x.type==="hillshade"||x.type==="custom"?!A&&x.shouldRedrape():!A&&x.hasTransition()})}_clearLineLayersFromRenderCache(){let h=!1;for(const A of this._style.getSources())if(A instanceof Ap){h=!0;break}if(!h)return;const x={};for(let A=0;AX>V.end)||i.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=A}_setupRenderCache(h){const x=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,x.renderCache.length>x.renderCachePool.length){const z=Object.values(x.proxyCachedFBO);x.proxyCachedFBO={};for(let V=0;V=0;z--){const V=A[z];if(x.getTileByID(V.key),x.proxyCachedFBO[V.key]!==void 0){const X=h[V.key],ne=this.proxyToSource[V.key];let oe=0;for(const ge in ne){const pe=ne[ge],xe=X[ge];if(!xe||xe.length!==pe.length||pe.some((Pe,Ce)=>Pe!==xe[Ce]||D[ge]&&D[ge].hasOwnProperty(Pe.key))){oe=-1;break}++oe}for(const ge in x.proxyCachedFBO[V.key])x.renderCache[x.proxyCachedFBO[V.key][ge]].dirty=oe<0||oe!==Object.values(X).length}}const F=[...this._drapedRenderBatches];F.sort((z,V)=>V.end-V.start-(z.end-z.start));for(const z of F)for(const V of A){if(x.proxyCachedFBO[V.key])continue;let X=x.renderCachePool.pop();X===void 0&&x.renderCache.length<50&&(X=x.renderCache.length,x.renderCache.push(this._createFBO())),X!==void 0&&(x.proxyCachedFBO[V.key]={},x.proxyCachedFBO[V.key][z.start]=X,x.renderCache[X].dirty=!0)}this._tilesDirty={}}_setupStencil(h,x,A,D){if(!D||!this._sourceTilesOverlap[D.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const F=this.painter.context,z=F.gl;if(x.length<=1)return void(this._overlapStencilType=!1);let V;if(A.isTileClipped())V=x.length,this._overlapStencilMode.test={func:z.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(x[0].overscaledZ>x[x.length-1].overscaledZ))return void(this._overlapStencilType=!1);V=1,this._overlapStencilMode.test={func:z.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+V>255&&(F.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=V,this._overlapStencilMode.ref=this._stencilRef,A.isTileClipped()&&this._renderTileClippingMasks(x,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(h){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[h.key]),this._overlapStencilMode):dn.disabled}_renderTileClippingMasks(h,x){const A=this.painter,D=this.painter.context,F=D.gl;A._tileClippingMaskIDs={},D.setColorMode(Dn.disabled),D.setDepthMode(Lr.disabled);const z=A.getOrCreateProgram("clippingMask");for(const V of h){const X=A._tileClippingMaskIDs[V.key]=--x;z.draw(A,F.TRIANGLES,Lr.disabled,new dn({func:F.ALWAYS,mask:0},X,255,F.KEEP,F.KEEP,F.REPLACE),Dn.disabled,rn.disabled,Nb(V.projMatrix),"$clipping",A.tileExtentBuffer,A.quadTriangleIndexBuffer,A.tileExtentSegments)}}pointCoordinate(h){const x=this.painter.transform;if(h.x<0||h.x>x.width||h.y<0||h.y>x.height)return null;const A=[h.x,h.y,1,1];i.aC(A,A,x.pixelMatrixInverse),i.cK(A,A,1/A[3]),A[0]/=x.worldSize,A[1]/=x.worldSize;const D=x._camera.position,F=i.cf(1,x.center.lat),z=[D[0],D[1],D[2]/F,0],V=i.da([],A.slice(0,3),z);i.aw(V,V);const X=this.raycast(z,V,this._exaggeration);return X!==null&&X?(i.bH(z,z,V,X),z[3]=z[2],z[2]*=F,z):null}_setupProxiedCoordsForOrtho(h,x,A){if(h.getSource()instanceof i.aU)return this._setupProxiedCoordsForImageSource(h,x,A);this._findCoveringTileCache[h.id]=this._findCoveringTileCache[h.id]||{};const D=this.proxiedCoords[h.id]=[],F=this.proxyCoords;for(let X=0;Xoe.overscaledZ-ne.overscaledZ)}_setupProxiedCoordsForImageSource(h,x,A){if(!h.getSource().loaded())return;const D=this.proxiedCoords[h.id]=[],F=this.proxyCoords,z=h.getSource(),V=z.tileID;if(!V)return;const X=new i.P(V.x,V.y)._div(1<(ge.min.x=Math.min(ge.min.x,pe.x-X.x),ge.min.y=Math.min(ge.min.y,pe.y-X.y),ge.max.x=Math.max(ge.max.x,pe.x-X.x),ge.max.y=Math.max(ge.max.y,pe.y-X.y),ge),{min:new i.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),oe=(ge,pe)=>{const xe=ge.wrap+ge.canonical.x/(1<Ve+ne.max.x||Pe+CeBe+ne.max.y};for(let ge=0;gez.key===x.tileID.key);if(F)return F}if(x.tileID.key!==h.key){const F=h.canonical.z-x.tileID.canonical.z;let z,V,X;D=i.bC();const ne=x.tileID.wrap-h.wrap<0?(z=i.al>>F,V=z*((x.tileID.canonical.x<=ge){const pe=h.canonical.z-ge;x.getSource().reparseOverscaled?(V=Math.max(h.canonical.z+2,x.transform.tileZoom),z=new i.aQ(V,h.wrap,ge,h.canonical.x>>pe,h.canonical.y>>pe)):pe!==0&&(V=ge,z=new i.aQ(V,h.wrap,ge,h.canonical.x>>pe,h.canonical.y>>pe))}z.key!==h.key&&(ne.push(z.key),A=x.getTile(z))}const oe=ge=>{ne.forEach(pe=>{D[pe]=ge}),ne.length=0};for(V-=1;V>=X&&(!A||!A.hasData());V--){A&&oe(A.tileID.key);const ge=z.calculateScaledKey(V);if(A=x.getTileByID(ge),A&&A.hasData())break;const pe=D[ge];if(pe===null)break;pe===void 0?ne.push(ge):A=x.getTileByID(pe)}return oe(A?A.tileID.key:null),A&&A.hasData()?A:null}findDEMTileFor(h){return this.enabled?this._findTileCoveringTileID(h,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(h,x){let A=this._tilesDirty[h];A||(A=this._tilesDirty[h]={}),A[x.key]=!0}}function Ev(M,h,x){const A=function(V,X,ne){const oe=i.bJ(X,V),ge=i.bJ(ne,[.2126,.7152,.0722]),pe=(Pe,Ce,Ve)=>(1-Ve)*Pe+Ve*Ce,xe=pe(1-.3*Math.min(ge,1),1,Math.min(oe+1,1));return pe(.92,1,Math.asin(i.aA(X[2],-1,1))/Math.PI+.5)*xe}(M,[0,0,1],h),D=[0,0,0];i.c5(D,x.slice(0,3),A);const F=[0,0,0];i.c5(F,h.slice(0,3),M[2]);const z=[0,0,0];return i.d8(z,D,F),i.db(z)}const nde=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],ade=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class DD{static cacheKey(h,x,A,D){const F=[x];D&&F.push(D.cacheKey);for(const z of A)h.usedDefines.has(z)&&F.push(z);return F.join("/")}constructor(h,x,A,D,F,z){const V=h.gl;this.program=V.createProgram(),this.configuration=D,this.name=x,this.fixedDefines=[...z];const X=`#version 300 es ${(D?D.defines():[]).concat(z.map(Ce=>`#define ${Ce}`)).join(` `)}`,ne=[X,Zce];for(const Ce of A.fragmentIncludes)ne.push(mx[Ce]);ne.push(A.fragmentSource);const oe=ne.join(` `),ge=[X,kD];for(const Ce of A.vertexIncludes)ge.push(mx[Ce]);this.forceManualRenderingForInstanceIDShaders=h.forceManualRenderingForInstanceIDShaders&&A.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&ge.push("uniform int u_instanceID;"),ge.push(A.vertexSource);let pe=ge.join(` `);this.forceManualRenderingForInstanceIDShaders&&(pe=pe.replaceAll("gl_InstanceID","u_instanceID"));const xe=V.createShader(V.FRAGMENT_SHADER);if(V.isContextLost())return void(this.failedToCreate=!0);V.shaderSource(xe,oe),V.compileShader(xe),V.attachShader(this.program,xe);const Pe=V.createShader(V.VERTEX_SHADER);V.isContextLost()?this.failedToCreate=!0:(V.shaderSource(Pe,pe),V.compileShader(Pe),V.attachShader(this.program,Pe),this.attributes={},V.linkProgram(this.program),V.deleteShader(Pe),V.deleteShader(xe),this.fixedUniforms=F(h),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=D?D.getUniforms(h):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(Ce=>({u_instanceID:new i.ch(Ce)}))(h)),(z.includes("TERRAIN")||x.includes("symbol")||x.includes("circle"))&&(this.terrainUniforms=(Ce=>({u_dem:new i.ch(Ce),u_dem_prev:new i.ch(Ce),u_dem_tl:new i.ck(Ce),u_dem_scale:new i.cj(Ce),u_dem_tl_prev:new i.ck(Ce),u_dem_scale_prev:new i.cj(Ce),u_dem_size:new i.cj(Ce),u_dem_lerp:new i.cj(Ce),u_exaggeration:new i.cj(Ce),u_depth:new i.ch(Ce),u_depth_size_inv:new i.ck(Ce),u_depth_range_unpack:new i.ck(Ce),u_occluder_half_size:new i.cj(Ce),u_occlusion_depth_offset:new i.cj(Ce),u_meter_to_dem:new i.cj(Ce),u_label_plane_matrix_inv:new i.cl(Ce)}))(h)),z.includes("GLOBE")&&(this.globeUniforms=(Ce=>({u_tile_tl_up:new i.ci(Ce),u_tile_tr_up:new i.ci(Ce),u_tile_br_up:new i.ci(Ce),u_tile_bl_up:new i.ci(Ce),u_tile_up_scale:new i.cj(Ce)}))(h)),z.includes("FOG")&&(this.fogUniforms=(Ce=>({u_fog_matrix:new i.cl(Ce),u_fog_range:new i.ck(Ce),u_fog_color:new i.d3(Ce),u_fog_horizon_blend:new i.cj(Ce),u_fog_vertical_limit:new i.ck(Ce),u_fog_temporal_offset:new i.cj(Ce),u_frustum_tl:new i.ci(Ce),u_frustum_tr:new i.ci(Ce),u_frustum_br:new i.ci(Ce),u_frustum_bl:new i.ci(Ce),u_globe_pos:new i.ci(Ce),u_globe_radius:new i.cj(Ce),u_globe_transition:new i.cj(Ce),u_is_globe:new i.ch(Ce),u_viewport:new i.ck(Ce)}))(h)),z.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(Ce=>({u_cutoff_params:new i.d3(Ce)}))(h)),z.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(Ce=>({u_lighting_ambient_color:new i.ci(Ce),u_lighting_directional_dir:new i.ci(Ce),u_lighting_directional_color:new i.ci(Ce),u_ground_radiance:new i.ci(Ce)}))(h)),z.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(Ce=>({u_light_matrix_0:new i.cl(Ce),u_light_matrix_1:new i.cl(Ce),u_fade_range:new i.ck(Ce),u_shadow_normal_offset:new i.ci(Ce),u_shadow_intensity:new i.cj(Ce),u_shadow_texel_size:new i.cj(Ce),u_shadow_map_resolution:new i.cj(Ce),u_shadow_direction:new i.ci(Ce),u_shadow_bias:new i.ci(Ce),u_shadowmap_0:new i.ch(Ce),u_shadowmap_1:new i.ch(Ce)}))(h)))}getAttributeLocation(h,x){let A=this.attributes[x];return A===void 0&&(A=this.attributes[x]=h.getAttribLocation(this.program,x)),A}setTerrainUniformValues(h,x){if(!this.terrainUniforms)return;const A=this.terrainUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)A[D]&&A[D].set(this.program,D,x[D])}}setGlobeUniformValues(h,x){if(!this.globeUniforms)return;const A=this.globeUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)A[D]&&A[D].set(this.program,D,x[D])}}setFogUniformValues(h,x){if(!this.fogUniforms)return;const A=this.fogUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)A[D].set(this.program,D,x[D])}}setCutoffUniformValues(h,x){if(!this.cutoffUniforms)return;const A=this.cutoffUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)A[D].set(this.program,D,x[D])}}setLightsUniformValues(h,x){if(!this.lightsUniforms)return;const A=this.lightsUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)A[D].set(this.program,D,x[D])}}setShadowUniformValues(h,x){if(this.failedToCreate||!this.shadowUniforms)return;const A=this.shadowUniforms;h.program.set(this.program);for(const D in x)A[D].set(this.program,D,x[D])}_drawDebugWireframe(h,x,A,D,F,z,V,X,ne,oe){const ge=h.options.wireframe;if(ge.terrain===!1&&ge.layers2D===!1&&ge.layers3D===!1)return;const pe=h.context;if(!(!(!ge.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!ge.layers2D||h._terrain&&h._terrain.renderingToTexture||!nde.includes(this.name))||!(!ge.layers3D||!ade.includes(this.name))))return;const xe=pe.gl,Pe=h.wireframeDebugCache.getLinesFromTrianglesBuffer(h.frameCounter,F,pe);if(!Pe)return;const Ce=[...this.fixedDefines,"DEBUG_WIREFRAME"],Ve=h.getOrCreateProgram(this.name,{config:this.configuration,defines:Ce});pe.program.set(Ve.program);const Be=(st,Mt,yt)=>{if(Mt[st]&&yt[st])for(const jt in Mt[st])yt[st][jt]&&yt[st][jt].set(yt.program,jt,Mt[st][jt].current)};ne&&ne.setUniforms(Ve.program,pe,Ve.binderUniforms,V,{zoom:X}),Be("fixedUniforms",this,Ve),Be("terrainUniforms",this,Ve),Be("globeUniforms",this,Ve),Be("fogUniforms",this,Ve),Be("lightsUniforms",this,Ve),Be("shadowUniforms",this,Ve),Pe.bind(),pe.setColorMode(new Dn([xe.ONE,xe.ONE_MINUS_SRC_ALPHA,xe.ZERO,xe.ONE],i.ao.transparent,[!0,!0,!0,!1])),pe.setDepthMode(new Lr(x.func===xe.LESS?xe.LEQUAL:x.func,Lr.ReadOnly,x.range)),pe.setStencilMode(dn.disabled);const tt=3*z.primitiveLength*2,dt=3*z.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const st=oe||1;for(let Mt=0;Mt1?xe.drawElementsInstanced(xe.LINES,tt,xe.UNSIGNED_SHORT,dt,oe):xe.drawElements(xe.LINES,tt,xe.UNSIGNED_SHORT,dt);F.bind(),pe.program.set(this.program),pe.setDepthMode(x),pe.setStencilMode(A),pe.setColorMode(D)}checkUniforms(h,x,A){if(this.fixedDefines.includes(x)){for(const D of Object.keys(A))if(!A[D].initialized)throw new Error(`Program '${this.name}', from draw '${h}': uniform ${D} not set but required by ${x} being defined`)}}draw(h,x,A,D,F,z,V,X,ne,oe,ge,pe,xe,Pe,Ce,Ve){const Be=h.context,tt=Be.gl;if(this.failedToCreate)return;Be.program.set(this.program),Be.setDepthMode(A),Be.setStencilMode(D),Be.setColorMode(F),Be.setCullFace(z);for(const[gt,mt]of this.fixedUniformsEntries)mt.set(this.program,gt,V[gt]);Pe&&Pe.setUniforms(this.program,Be,this.binderUniforms,pe,{zoom:xe});const dt={[tt.POINTS]:1,[tt.LINES]:2,[tt.TRIANGLES]:3,[tt.LINE_STRIP]:1}[x];this.checkUniforms(X,"RENDER_SHADOWS",this.shadowUniforms);const st=Ce||[],Mt=Pe?Pe.getPaintVertexBuffers():[],yt=x===tt.TRIANGLES&&oe,jt=Ve&&Ve>0?1:void 0;for(const gt of ge.get()){const mt=gt.vaos||(gt.vaos={});if((mt[X]||(mt[X]=new Yce)).bind(Be,this,ne,Mt,oe,gt.vertexOffset,st,jt),this.forceManualRenderingForInstanceIDShaders){const Et=Ve||1;for(let Ht=0;Ht1?tt.drawElementsInstanced(x,gt.primitiveLength*dt,tt.UNSIGNED_SHORT,gt.primitiveOffset*dt*2,Ve):oe?tt.drawElements(x,gt.primitiveLength*dt,tt.UNSIGNED_SHORT,gt.primitiveOffset*dt*2):tt.drawArrays(x,gt.vertexOffset,gt.vertexLength);yt&&this._drawDebugWireframe(h,A,D,F,oe,gt,pe,xe,Pe,Ve)}}}function OD(M,h,x=0){const A=Math.pow(2,h.tileID.overscaledZ),D=h.tileSize*Math.pow(2,M.transform.tileZoom)/A,F=D*(h.tileID.canonical.x+h.tileID.wrap*A),z=D*h.tileID.canonical.y;return{u_image:0,u_texsize:h.imageAtlasTexture?h.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/i.ay(h,1,M.transform.tileZoom),u_pixel_coord_upper:[F>>16,z>>16],u_pixel_coord_lower:[65535&F,65535&z],u_pattern_transition:x}}const WS={terrain:0,flat:1},ide=i.bC(),GS=(M,h,x,A,D,F,z,V,X,ne,oe,ge,pe,xe,Pe,Ce,Ve,Be)=>{const tt=h.style.light,dt=tt.properties.get("position"),st=[dt.x,dt.y,dt.z],Mt=i.dO();tt.properties.get("anchor")==="viewport"&&(i.dP(Mt,-h.transform.angle),i.dQ(st,st,Mt));const yt=tt.properties.get("color").toPremultipliedRenderColor(null),jt=h.transform,gt={u_matrix:M,u_lightpos:st,u_lightintensity:tt.properties.get("intensity"),u_lightcolor:[yt.r,yt.g,yt.b],u_vertical_gradient:+x,u_opacity:A,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:ide,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:WS[ne],u_base_type:WS[oe],u_ao:D,u_edge_radius:F,u_width_scale:z,u_flood_light_color:Pe,u_vertical_scale:Ce,u_flood_light_intensity:Ve,u_ground_shadow_factor:Be};return jt.projection.name==="globe"&&(gt.u_tile_id=[V.canonical.x,V.canonical.y,1<({u_matrix:M,u_edge_radius:h,u_width_scale:x,u_vertical_scale:A,u_height_type:WS[D],u_base_type:WS[F]}),RD=(M,h,x,A,D,F,z,V,X,ne,oe,ge,pe,xe,Pe,Ce,Ve,Be)=>{const tt=GS(M,h,x,A,D,F,z,V,ne,oe,ge,pe,xe,Pe,Ce,Ve,1,[0,0,0]),dt={u_height_factor:-Math.pow(2,V.overscaledZ)/X.tileSize/8};return Object.assign(tt,OD(h,X,Be),dt)},Pv=(M,h,x,A,D,F,z,V,X,ne,oe)=>({u_matrix:h,u_opacity:x,u_ao_pass:A?1:0,u_meter_to_tile:D,u_ao:F,u_flood_light_intensity:z,u_flood_light_color:V,u_attenuation:X,u_edge_radius:ne,u_fb:0,u_fb_size:oe,u_dynamic_offset:1}),MT=(M,h,x)=>({u_matrix:M,u_emissive_strength:h,u_ground_shadow_factor:x}),TT=(M,h,x,A,D,F=0)=>Object.assign(MT(M,h,D),OD(x,A,F)),FD=(M,h,x,A)=>({u_matrix:M,u_world:x,u_emissive_strength:h,u_ground_shadow_factor:A}),AT=(M,h,x,A,D,F,z=0)=>Object.assign(TT(M,h,x,A,F,z),{u_world:D}),fx=(M,h)=>({u_matrix:M,u_ground_shadow_factor:h}),Dy=(M,h,x,A,D)=>({u_matrix:M,u_camera_pos:[h[0],h[1],h[2]],u_depth_bias:x,u_height_scale:A,u_reset_depth:D}),KS=(M,h,x,A,D,F,z,V,X)=>({u_matrix:M,u_normal_matrix:h,u_opacity:x,u_faux_facade_ao_intensity:A,u_camera_pos:D,u_tile_to_meter:F,u_facade_emissive_chance:z,u_flood_light_color:V,u_flood_light_intensity:X}),zD=M=>({u_matrix:M}),gx=M=>({u_matrix:M}),ET=(M,h,x,A,D,F,z,V)=>{const X=i.al/F.tileSize;return{u_matrix:M,u_inv_rot_matrix:h,u_camera_to_center_distance:x.getCameraToCenterDistance(V),u_extrude_scale:[x.pixelsToGLUnits[0]/X,x.pixelsToGLUnits[1]/X],u_zoom_transition:A,u_tile_id:z,u_merc_center:D}},Sb=(M,h,x=1)=>({u_matrix:M,u_color:h,u_overlay:0,u_overlay_scale:x}),BD=i.bC(),$D=(M,h,x,A,D,F,z)=>{const V=M.transform,X=V.projection.name==="globe",ne=X?i.dR(V.zoom,h.canonical)*V._pixelsPerMercatorPixel:i.ay(x,1,F),oe={u_matrix:h.projMatrix,u_extrude_scale:ne,u_intensity:z,u_inv_rot_matrix:BD,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(X){oe.u_inv_rot_matrix=A,oe.u_merc_center=D,oe.u_tile_id=[h.canonical.x,h.canonical.y,1<({u_matrix:M,u_normalize_matrix:h,u_globe_matrix:x,u_merc_matrix:A,u_grid_matrix:D,u_tl_parent:F,u_scale_parent:ne,u_fade_t:oe.mix,u_opacity:oe.opacity*ge.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:ge.paint.get("raster-brightness-min"),u_brightness_high:ge.paint.get("raster-brightness-max"),u_saturation_factor:i.dT(ge.paint.get("raster-saturation")),u_contrast_factor:i.dS(ge.paint.get("raster-contrast")),u_spin_weights:UD(ge.paint.get("raster-hue-rotate")),u_perspective_transform:pe,u_raster_elevation:xe,u_zoom_transition:z,u_merc_center:V,u_cutoff_params:X,u_colorization_mix:ZS(i.dU,Ce,Be),u_colorization_offset:YS(i.dU,Ve,Be),u_color_ramp:Pe,u_texture_offset:[dt/(tt+2*dt),tt/(tt+2*dt)],u_texture_res:[tt+2*dt,tt+2*dt],u_emissive_strength:st});function UD(M){M*=Math.PI/180;const h=Math.sin(M),x=Math.cos(M);return[(2*x+1)/3,(-Math.sqrt(3)*h-x+1)/3,(Math.sqrt(3)*h-x+1)/3]}const Rp=.05,ode=(M,h,x,A,D,F,z,V,X,ne,oe,ge)=>({u_matrix:M,u_normalize_matrix:h,u_globe_matrix:x,u_merc_matrix:A,u_grid_matrix:D,u_tl_parent:F,u_scale_parent:ne,u_fade_t:oe.mix,u_opacity:oe.opacity,u_image0:0,u_image1:1,u_raster_elevation:ge,u_zoom_transition:z,u_merc_center:V,u_cutoff_params:X}),lde=(M,h,x,A,D,F,z,V,X,ne)=>({u_particle_texture:M,u_particle_texture_side_len:h,u_tile_offset:x,u_velocity:A,u_color_ramp:F,u_velocity_res:D,u_max_speed:z,u_uv_offset:V,u_data_scale:[255*X[0],255*X[1]],u_data_offset:ne,u_particle_pos_scale:1.1,u_particle_pos_offset:[Rp,Rp]}),VD=(M,h,x,A,D,F,z,V,X,ne)=>({u_particle_texture:M,u_particle_texture_side_len:h,u_velocity:x,u_velocity_res:A,u_max_speed:D,u_speed_factor:F,u_reset_rate:z,u_rand_seed:Math.random(),u_uv_offset:V,u_data_scale:[255*X[0],255*X[1]],u_data_offset:ne,u_particle_pos_scale:1.1,u_particle_pos_offset:[Rp,Rp]}),HD=i.bC(),XS=(M,h,x,A,D,F,z,V,X,ne,oe,ge,pe,xe,Pe,Ce,Ve,Be,tt,dt,st,Mt,yt,jt)=>{const gt=D.transform,mt={u_is_size_zoom_constant:+(M==="constant"||M==="source"),u_is_size_feature_constant:+(M==="constant"||M==="camera"),u_size_t:h?h.uSizeT:0,u_size:h?h.uSize:0,u_camera_to_center_distance:gt.getCameraToCenterDistance(tt),u_rotate_symbol:+x,u_aspect_ratio:gt.width/gt.height,u_fade_change:D.options.fadeDuration?D.symbolFadeChange:1,u_matrix:F,u_label_plane_matrix:z,u_coord_matrix:V,u_is_text:+ne,u_elevation_from_sea:X?1:0,u_pitch_with_map:+A,u_texsize:oe,u_texsize_icon:ge,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:HD,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:HD,u_up_vector:[0,-1,0],u_color_adj_mat:Mt,u_icon_transition:yt||0,u_gamma_scale:A?D.transform.getCameraToCenterDistance(tt)*Math.cos(D.terrain?0:D.transform._pitch):1,u_device_pixel_ratio:i.o.devicePixelRatio,u_is_halo:1,u_scale_factor:jt||1,u_ground_shadow_factor:dt,u_inv_matrix:i.bl(i.bC(),z),u_normal_scale:st,u_lutTexture:_c.LUT};return tt.name==="globe"&&(mt.u_tile_id=[xe.canonical.x,xe.canonical.y,1<({u_matrix:M,u_emissive_strength:h,u_opacity:x,u_color:A}),xx=(M,h,x,A,D,F,z,V,X)=>Object.assign(function(ne,oe,ge,pe,xe,Pe){const{width:Ce,height:Ve}=pe.imageManager.getPixelSize(oe),Be=Math.pow(2,Pe.tileID.overscaledZ),tt=Pe.tileSize*Math.pow(2,pe.transform.tileZoom)/Be,dt=tt*(Pe.tileID.canonical.x+Pe.tileID.wrap*Be),st=tt*Pe.tileID.canonical.y;return{u_image:0,u_pattern_tl:ge.tl,u_pattern_br:ge.br,u_texsize:[Ce,Ve],u_pattern_size:ge.displaySize,u_pattern_units_to_pixels:xe?[pe.transform.width,-1*pe.transform.height]:[1/i.ay(Pe,1,pe.transform.tileZoom),1/i.ay(Pe,1,pe.transform.tileZoom)],u_pixel_coord_upper:[dt>>16,st>>16],u_pixel_coord_lower:[65535&dt,65535&st]}}(0,F,z,A,V,X),{u_matrix:M,u_emissive_strength:h,u_opacity:x}),Iv=new Float32Array(i.bA([])),Oy=(M,h,x,A,D,F,z,V,X,ne,oe,ge,pe,xe=[0,0,0],Pe,Ce,Ve)=>{const Be=D.style.light,tt=Be.properties.get("position"),dt=[-tt.x,-tt.y,tt.z],st=i.dO();Be.properties.get("anchor")==="viewport"&&(i.dP(st,-D.transform.angle),i.dQ(dt,dt,st));const Mt=oe.alphaMode==="MASK",yt=Be.properties.get("color").toNonPremultipliedRenderColor(null),jt=pe.paint.get("model-ambient-occlusion-intensity"),gt=pe.paint.get("model-color").constantOr(i.ao.white).toNonPremultipliedRenderColor(null);return gt.a=pe.paint.get("model-color-mix-intensity").constantOr(0),Ve&&(gt.r=Ve[0],gt.g=Ve[1],gt.b=Ve[2],gt.a=Ve[3]),Ce&&(gt.r=Ce.color.r,gt.g=Ce.color.g,gt.b=Ce.color.b,gt.a=Ce.colorMix,ge=Ce.emissionStrength,F*=Ce.opacity),{u_matrix:M,u_lighting_matrix:h,u_normal_matrix:x,u_node_matrix:A||Iv,u_lightpos:dt,u_lightintensity:Be.properties.get("intensity"),u_lightcolor:[yt.r,yt.g,yt.b],u_camera_pos:xe,u_opacity:F,u_baseTextureIsAlpha:0,u_alphaMask:+Mt,u_alphaCutoff:oe.alphaCutoff,u_baseColorFactor:z.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:V.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:X,u_roughnessFactor:ne,u_baseColorTexture:_c.BaseColor,u_metallicRoughnessTexture:_c.MetallicRoughness,u_normalTexture:_c.Normal,u_occlusionTexture:_c.Occlusion,u_emissionTexture:_c.Emission,u_lutTexture:_c.LUT,u_color_mix:gt.toArray01(),u_aoIntensity:jt,u_emissive_strength:ge,u_occlusionTextureTransform:Pe||[0,0,0,0]}},PT=(M,h=Iv,x=Iv)=>({u_matrix:M,u_instance:h,u_node_matrix:x}),QS={fillExtrusion:M=>({u_matrix:new i.cl(M),u_lightpos:new i.ci(M),u_lightintensity:new i.cj(M),u_lightcolor:new i.ci(M),u_vertical_gradient:new i.cj(M),u_opacity:new i.cj(M),u_edge_radius:new i.cj(M),u_width_scale:new i.cj(M),u_ao:new i.ck(M),u_height_type:new i.ch(M),u_base_type:new i.ch(M),u_tile_id:new i.ci(M),u_zoom_transition:new i.cj(M),u_inv_rot_matrix:new i.cl(M),u_merc_center:new i.ck(M),u_up_dir:new i.ci(M),u_height_lift:new i.cj(M),u_flood_light_color:new i.ci(M),u_vertical_scale:new i.cj(M),u_flood_light_intensity:new i.cj(M),u_ground_shadow_factor:new i.ci(M)}),fillExtrusionDepth:M=>({u_matrix:new i.cl(M),u_edge_radius:new i.cj(M),u_width_scale:new i.cj(M),u_vertical_scale:new i.cj(M),u_height_type:new i.ch(M),u_base_type:new i.ch(M)}),fillExtrusionPattern:M=>({u_matrix:new i.cl(M),u_lightpos:new i.ci(M),u_lightintensity:new i.cj(M),u_lightcolor:new i.ci(M),u_vertical_gradient:new i.cj(M),u_height_factor:new i.cj(M),u_edge_radius:new i.cj(M),u_width_scale:new i.cj(M),u_ao:new i.ck(M),u_height_type:new i.ch(M),u_base_type:new i.ch(M),u_tile_id:new i.ci(M),u_zoom_transition:new i.cj(M),u_inv_rot_matrix:new i.cl(M),u_merc_center:new i.ck(M),u_up_dir:new i.ci(M),u_height_lift:new i.cj(M),u_image:new i.ch(M),u_texsize:new i.ck(M),u_pixel_coord_upper:new i.ck(M),u_pixel_coord_lower:new i.ck(M),u_tile_units_to_pixels:new i.cj(M),u_opacity:new i.cj(M),u_pattern_transition:new i.cj(M)}),fillExtrusionGroundEffect:M=>({u_matrix:new i.cl(M),u_opacity:new i.cj(M),u_ao_pass:new i.cj(M),u_meter_to_tile:new i.cj(M),u_ao:new i.ck(M),u_flood_light_intensity:new i.cj(M),u_flood_light_color:new i.ci(M),u_attenuation:new i.cj(M),u_edge_radius:new i.cj(M),u_fb:new i.ch(M),u_fb_size:new i.cj(M),u_dynamic_offset:new i.cj(M)}),fill:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_ground_shadow_factor:new i.ci(M)}),fillPattern:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_image:new i.ch(M),u_texsize:new i.ck(M),u_pixel_coord_upper:new i.ck(M),u_pixel_coord_lower:new i.ck(M),u_tile_units_to_pixels:new i.cj(M),u_ground_shadow_factor:new i.ci(M),u_pattern_transition:new i.cj(M)}),fillOutline:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_world:new i.ck(M),u_ground_shadow_factor:new i.ci(M)}),fillOutlinePattern:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_world:new i.ck(M),u_image:new i.ch(M),u_texsize:new i.ck(M),u_pixel_coord_upper:new i.ck(M),u_pixel_coord_lower:new i.ck(M),u_tile_units_to_pixels:new i.cj(M),u_ground_shadow_factor:new i.ci(M),u_pattern_transition:new i.cj(M)}),building:M=>({u_matrix:new i.cl(M),u_normal_matrix:new i.cl(M),u_opacity:new i.cj(M),u_faux_facade_ao_intensity:new i.cj(M),u_camera_pos:new i.ci(M),u_tile_to_meter:new i.cj(M),u_facade_emissive_chance:new i.cj(M),u_flood_light_color:new i.ci(M),u_flood_light_intensity:new i.cj(M)}),buildingBloom:M=>({u_matrix:new i.cl(M)}),buildingDepth:M=>({u_matrix:new i.cl(M)}),elevatedStructuresDepth:M=>({u_matrix:new i.cl(M),u_depth_bias:new i.cj(M)}),elevatedStructures:M=>({u_matrix:new i.cl(M),u_ground_shadow_factor:new i.ci(M)}),elevatedStructuresDepthReconstruct:M=>({u_matrix:new i.cl(M),u_camera_pos:new i.ci(M),u_depth_bias:new i.cj(M),u_height_scale:new i.cj(M),u_reset_depth:new i.cj(M)}),circle:i.dY,collisionBox:M=>({u_matrix:new i.cl(M),u_inv_rot_matrix:new i.cl(M),u_camera_to_center_distance:new i.cj(M),u_extrude_scale:new i.ck(M),u_zoom_transition:new i.cj(M),u_merc_center:new i.ck(M),u_tile_id:new i.ci(M)}),collisionCircle:M=>({u_matrix:new i.cl(M),u_inv_matrix:new i.cl(M),u_camera_to_center_distance:new i.cj(M),u_viewport_size:new i.ck(M)}),debug:M=>({u_color:new i.dB(M),u_matrix:new i.cl(M),u_overlay:new i.ch(M),u_overlay_scale:new i.cj(M)}),clippingMask:M=>({u_matrix:new i.cl(M)}),heatmap:M=>({u_extrude_scale:new i.cj(M),u_intensity:new i.cj(M),u_matrix:new i.cl(M),u_inv_rot_matrix:new i.cl(M),u_merc_center:new i.ck(M),u_tile_id:new i.ci(M),u_zoom_transition:new i.cj(M),u_up_dir:new i.ci(M)}),heatmapTexture:M=>({u_image:new i.ch(M),u_color_ramp:new i.ch(M),u_opacity:new i.cj(M)}),hillshade:M=>({u_matrix:new i.cl(M),u_image:new i.ch(M),u_latrange:new i.ck(M),u_light:new i.ck(M),u_shadow:new i.dB(M),u_highlight:new i.dB(M),u_emissive_strength:new i.cj(M),u_accent:new i.dB(M)}),hillshadePrepare:M=>({u_matrix:new i.cl(M),u_image:new i.ch(M),u_dimension:new i.ck(M),u_zoom:new i.cj(M)}),line:i.dX,linePattern:i.dW,raster:M=>({u_matrix:new i.cl(M),u_normalize_matrix:new i.cl(M),u_globe_matrix:new i.cl(M),u_merc_matrix:new i.cl(M),u_grid_matrix:new i.dC(M),u_tl_parent:new i.ck(M),u_scale_parent:new i.cj(M),u_fade_t:new i.cj(M),u_opacity:new i.cj(M),u_image0:new i.ch(M),u_image1:new i.ch(M),u_brightness_low:new i.cj(M),u_brightness_high:new i.cj(M),u_saturation_factor:new i.cj(M),u_contrast_factor:new i.cj(M),u_spin_weights:new i.ci(M),u_perspective_transform:new i.ck(M),u_raster_elevation:new i.cj(M),u_zoom_transition:new i.cj(M),u_merc_center:new i.ck(M),u_cutoff_params:new i.d3(M),u_colorization_mix:new i.d3(M),u_colorization_offset:new i.cj(M),u_color_ramp:new i.ch(M),u_texture_offset:new i.ck(M),u_texture_res:new i.ck(M),u_emissive_strength:new i.cj(M)}),rasterParticle:M=>({u_matrix:new i.cl(M),u_normalize_matrix:new i.cl(M),u_globe_matrix:new i.cl(M),u_merc_matrix:new i.cl(M),u_grid_matrix:new i.dC(M),u_tl_parent:new i.ck(M),u_scale_parent:new i.cj(M),u_fade_t:new i.cj(M),u_opacity:new i.cj(M),u_image0:new i.ch(M),u_image1:new i.ch(M),u_raster_elevation:new i.cj(M),u_zoom_transition:new i.cj(M),u_merc_center:new i.ck(M),u_cutoff_params:new i.d3(M)}),rasterParticleTexture:M=>({u_texture:new i.ch(M),u_opacity:new i.cj(M)}),rasterParticleDraw:M=>({u_particle_texture:new i.ch(M),u_particle_texture_side_len:new i.cj(M),u_tile_offset:new i.ck(M),u_velocity:new i.ch(M),u_color_ramp:new i.ch(M),u_velocity_res:new i.ck(M),u_max_speed:new i.cj(M),u_uv_offset:new i.ck(M),u_data_scale:new i.ck(M),u_data_offset:new i.cj(M),u_particle_pos_scale:new i.cj(M),u_particle_pos_offset:new i.ck(M)}),rasterParticleUpdate:M=>({u_particle_texture:new i.ch(M),u_particle_texture_side_len:new i.cj(M),u_velocity:new i.ch(M),u_velocity_res:new i.ck(M),u_max_speed:new i.cj(M),u_speed_factor:new i.cj(M),u_reset_rate:new i.cj(M),u_rand_seed:new i.cj(M),u_uv_offset:new i.ck(M),u_data_scale:new i.ck(M),u_data_offset:new i.cj(M),u_particle_pos_scale:new i.cj(M),u_particle_pos_offset:new i.ck(M)}),symbol:M=>({u_is_size_zoom_constant:new i.ch(M),u_is_size_feature_constant:new i.ch(M),u_size_t:new i.cj(M),u_size:new i.cj(M),u_camera_to_center_distance:new i.cj(M),u_rotate_symbol:new i.ch(M),u_aspect_ratio:new i.cj(M),u_fade_change:new i.cj(M),u_matrix:new i.cl(M),u_label_plane_matrix:new i.cl(M),u_coord_matrix:new i.cl(M),u_is_text:new i.ch(M),u_elevation_from_sea:new i.ch(M),u_pitch_with_map:new i.ch(M),u_texsize:new i.ck(M),u_texsize_icon:new i.ck(M),u_texture:new i.ch(M),u_texture_icon:new i.ch(M),u_gamma_scale:new i.cj(M),u_device_pixel_ratio:new i.cj(M),u_tile_id:new i.ci(M),u_zoom_transition:new i.cj(M),u_inv_rot_matrix:new i.cl(M),u_merc_center:new i.ck(M),u_camera_forward:new i.ci(M),u_tile_matrix:new i.cl(M),u_up_vector:new i.ci(M),u_ecef_origin:new i.ci(M),u_is_halo:new i.ch(M),u_icon_transition:new i.cj(M),u_color_adj_mat:new i.cl(M),u_scale_factor:new i.cj(M),u_ground_shadow_factor:new i.ci(M),u_inv_matrix:new i.cl(M),u_normal_scale:new i.cj(M),u_lutTexture:new i.ch(M)}),background:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_opacity:new i.cj(M),u_color:new i.dB(M)}),backgroundPattern:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_opacity:new i.cj(M),u_image:new i.ch(M),u_pattern_tl:new i.ck(M),u_pattern_br:new i.ck(M),u_texsize:new i.ck(M),u_pattern_size:new i.ck(M),u_pixel_coord_upper:new i.ck(M),u_pixel_coord_lower:new i.ck(M),u_pattern_units_to_pixels:new i.ck(M)}),terrainRaster:M=>({u_matrix:new i.cl(M),u_image0:new i.ch(M),u_image1:new i.ch(M),u_skirt_height:new i.cj(M),u_ground_shadow_factor:new i.ci(M),u_emissive_texture_available:new i.cj(M)}),skybox:M=>({u_matrix:new i.cl(M),u_sun_direction:new i.ci(M),u_cubemap:new i.ch(M),u_opacity:new i.cj(M),u_temporal_offset:new i.cj(M)}),skyboxGradient:M=>({u_matrix:new i.cl(M),u_color_ramp:new i.ch(M),u_center_direction:new i.ci(M),u_radius:new i.cj(M),u_opacity:new i.cj(M),u_temporal_offset:new i.cj(M)}),skyboxCapture:M=>({u_matrix_3f:new i.dC(M),u_sun_direction:new i.ci(M),u_sun_intensity:new i.cj(M),u_color_tint_r:new i.d3(M),u_color_tint_m:new i.d3(M),u_luminance:new i.cj(M)}),globeRaster:M=>({u_proj_matrix:new i.cl(M),u_globe_matrix:new i.cl(M),u_normalize_matrix:new i.cl(M),u_merc_matrix:new i.cl(M),u_zoom_transition:new i.cj(M),u_merc_center:new i.ck(M),u_image0:new i.ch(M),u_image1:new i.ch(M),u_grid_matrix:new i.dC(M),u_skirt_height:new i.cj(M),u_far_z_cutoff:new i.cj(M),u_frustum_tl:new i.ci(M),u_frustum_tr:new i.ci(M),u_frustum_br:new i.ci(M),u_frustum_bl:new i.ci(M),u_globe_pos:new i.ci(M),u_globe_radius:new i.cj(M),u_viewport:new i.ck(M),u_emissive_texture_available:new i.cj(M)}),globeAtmosphere:M=>({u_frustum_tl:new i.ci(M),u_frustum_tr:new i.ci(M),u_frustum_br:new i.ci(M),u_frustum_bl:new i.ci(M),u_horizon:new i.cj(M),u_transition:new i.cj(M),u_fadeout_range:new i.cj(M),u_atmosphere_fog_color:new i.d3(M),u_high_color:new i.d3(M),u_space_color:new i.d3(M),u_temporal_offset:new i.cj(M),u_horizon_angle:new i.cj(M)}),model:M=>({u_matrix:new i.cl(M),u_lighting_matrix:new i.cl(M),u_normal_matrix:new i.cl(M),u_node_matrix:new i.cl(M),u_lightpos:new i.ci(M),u_lightintensity:new i.cj(M),u_lightcolor:new i.ci(M),u_camera_pos:new i.ci(M),u_opacity:new i.cj(M),u_baseColorFactor:new i.d3(M),u_emissiveFactor:new i.d3(M),u_metallicFactor:new i.cj(M),u_roughnessFactor:new i.cj(M),u_baseTextureIsAlpha:new i.ch(M),u_alphaMask:new i.ch(M),u_alphaCutoff:new i.cj(M),u_baseColorTexture:new i.ch(M),u_metallicRoughnessTexture:new i.ch(M),u_normalTexture:new i.ch(M),u_occlusionTexture:new i.ch(M),u_emissionTexture:new i.ch(M),u_lutTexture:new i.ch(M),u_color_mix:new i.d3(M),u_aoIntensity:new i.cj(M),u_emissive_strength:new i.cj(M),u_occlusionTextureTransform:new i.d3(M)}),modelDepth:M=>({u_matrix:new i.cl(M),u_instance:new i.cl(M),u_node_matrix:new i.cl(M)}),groundShadow:M=>({u_matrix:new i.cl(M),u_ground_shadow_factor:new i.ci(M)}),stars:M=>({u_matrix:new i.cl(M),u_up:new i.ci(M),u_right:new i.ci(M),u_intensity_multiplier:new i.cj(M)}),snowParticle:M=>({u_modelview:new i.cl(M),u_projection:new i.cl(M),u_time:new i.cj(M),u_cam_pos:new i.ci(M),u_velocityConeAperture:new i.cj(M),u_velocity:new i.cj(M),u_horizontalOscillationRadius:new i.cj(M),u_horizontalOscillationRate:new i.cj(M),u_boxSize:new i.cj(M),u_billboardSize:new i.cj(M),u_simpleShapeParameters:new i.ck(M),u_screenSize:new i.ck(M),u_thinningCenterPos:new i.ck(M),u_thinningShape:new i.ci(M),u_thinningAffectedRatio:new i.cj(M),u_thinningParticleOffset:new i.cj(M),u_particleColor:new i.d3(M),u_direction:new i.ci(M)}),rainParticle:M=>({u_modelview:new i.cl(M),u_projection:new i.cl(M),u_time:new i.cj(M),u_cam_pos:new i.ci(M),u_texScreen:new i.ch(M),u_velocityConeAperture:new i.cj(M),u_velocity:new i.cj(M),u_boxSize:new i.cj(M),u_rainDropletSize:new i.ck(M),u_distortionStrength:new i.cj(M),u_rainDirection:new i.ci(M),u_color:new i.d3(M),u_screenSize:new i.ck(M),u_thinningCenterPos:new i.ck(M),u_thinningShape:new i.ci(M),u_thinningAffectedRatio:new i.cj(M),u_thinningParticleOffset:new i.cj(M),u_shapeDirectionalPower:new i.cj(M),u_shapeNormalPower:new i.cj(M),u_mode:new i.cj(M)}),vignette:M=>({u_vignetteShape:new i.ci(M),u_vignetteColor:new i.d3(M)}),occlusion:M=>({u_matrix:new i.cl(M),u_anchorPos:new i.ci(M),u_screenSizePx:new i.ck(M),u_occluderSizePx:new i.ck(M),u_color:new i.d3(M)})};class Zm{constructor(h,x,A,D){this.id=Zm.uniqueIdxCounter,Zm.uniqueIdxCounter++,this.context=h;const F=h.gl;this.buffer=F.createBuffer(),this.dynamicDraw=!!A,this.context.unbindVAO(),h.bindElementBuffer.set(this.buffer),F.bufferData(F.ELEMENT_ARRAY_BUFFER,x.arrayBuffer,this.dynamicDraw?F.DYNAMIC_DRAW:F.STATIC_DRAW),this.dynamicDraw||D||x.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(h){this.id=Zm.uniqueIdxCounter,Zm.uniqueIdxCounter++;const x=this.context.gl;this.context.unbindVAO(),this.bind(),x.bufferSubData(x.ELEMENT_ARRAY_BUFFER,0,h.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}Zm.uniqueIdxCounter=0;const IT={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class WD{constructor(h,x,A,D,F,z){this.length=x.length,this.attributes=A,this.itemSize=x.bytesPerElement,this.dynamicDraw=D,this.instanceCount=z,this.context=h;const V=h.gl;this.buffer=V.createBuffer(),h.bindVertexBuffer.set(this.buffer),V.bufferData(V.ARRAY_BUFFER,x.arrayBuffer,this.dynamicDraw?V.DYNAMIC_DRAW:V.STATIC_DRAW),this.dynamicDraw||F||x.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(h){const x=this.context.gl;this.bind(),x.bufferSubData(x.ARRAY_BUFFER,0,h.arrayBuffer)}enableAttributes(h,x){for(let A=0;A0&&h.vertexAttribDivisor(F,A)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class GD{constructor(h,x,A,D,F){this.context=h,this.width=x,this.height=A;const z=this.framebuffer=h.gl.createFramebuffer();D>0&&(this.colorAttachment0=new $S(h,z,0)),D>1&&(this.colorAttachment1=new $S(h,z,1)),F&&(this.depthAttachmentType=F,this.depthAttachment=F==="renderbuffer"?new Tv(h,z):new wb(h,z))}createColorAttachment(h,x){x===0?this.colorAttachment0=new $S(h,this.framebuffer,0):x===1&&(this.colorAttachment1=new $S(h,this.framebuffer,1))}removeColorAttachment(h,x){const A=this.context.gl;let D;x===0?(D=this.colorAttachment0.get(),this.colorAttachment0=void 0):x===1&&(D=this.colorAttachment1.get(),this.colorAttachment1=void 0),D&&A.deleteTexture(D)}destroy(){const h=this.context.gl;if(this.colorAttachment0){const x=this.colorAttachment0.get();x&&h.deleteTexture(x)}if(this.colorAttachment1){const x=this.colorAttachment1.get();x&&h.deleteTexture(x)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){const x=this.depthAttachment.get();x&&h.deleteRenderbuffer(x)}else{const x=this.depthAttachment.get();x&&h.deleteTexture(x)}h.deleteFramebuffer(this.framebuffer)}}class Lv{constructor(h,x){this.gl=h,this.clearColor=new ede(this),this.clearDepth=new SD(this),this.clearStencil=new fT(this),this.colorMask=new OS(this),this.depthMask=new gT(this),this.stencilMask=new Ly(this),this.stencilFunc=new kv(this),this.stencilOp=new _b(this),this.stencilTest=new Sv(this),this.depthRange=new CD(this),this.depthTest=new xT(this),this.depthFunc=new MD(this),this.blend=new Cv(this),this.blendFunc=new RS(this),this.blendColor=new FS(this),this.blendEquation=new yT(this),this.cullFace=new zS(this),this.cullFaceSide=new bb(this),this.frontFace=new TD(this),this.program=new AD(this),this.activeTexture=new ED(this),this.viewport=new Mv(this),this.bindFramebuffer=new PD(this),this.bindRenderbuffer=new tde(this),this.bindTexture=new sde(this),this.bindVertexBuffer=new rde(this),this.bindElementBuffer=new vT(this),this.bindVertexArrayOES=new _T(this),this.pixelStoreUnpack=new bT(this),this.pixelStoreUnpackPremultiplyAlpha=new wT(this),this.pixelStoreUnpackFlipY=new ID(this),this.options=x?Object.assign({},x):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=h.getExtension("EXT_texture_filter_anisotropic")||h.getExtension("MOZ_EXT_texture_filter_anisotropic")||h.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=h.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=h.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=h.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=h.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=x&&!!x.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.indexOf("PowerVR")!==-1,this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=h.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=h.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=h.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=h.getParameter(h.MAX_TEXTURE_SIZE),this.extBlendFuncExtended=h.getExtension("WEBGL_blend_func_extended")}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(h,x,A){return new Zm(this,h,x,A)}createVertexBuffer(h,x,A,D,F){return new WD(this,h,x,A,D,F)}createRenderbuffer(h,x,A){const D=this.gl,F=D.createRenderbuffer();return this.bindRenderbuffer.set(F),D.renderbufferStorage(D.RENDERBUFFER,h,x,A),this.bindRenderbuffer.set(null),F}createFramebuffer(h,x,A,D){return new GD(this,h,x,A,D)}clear({color:h,depth:x,stencil:A,colorMask:D}){const F=this.gl;let z=0;h&&(z|=F.COLOR_BUFFER_BIT,this.clearColor.set(h.toNonPremultipliedRenderColor(null)),this.colorMask.set(D||[!0,!0,!0,!0])),x!==void 0&&(z|=F.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(x),this.depthMask.set(!0)),A!==void 0&&(z|=F.STENCIL_BUFFER_BIT,this.clearStencil.set(A),this.stencilMask.set(255)),F.clear(z)}setCullFace(h){h.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(h.mode),this.frontFace.set(h.frontFace))}setDepthMode(h){h.func!==this.gl.ALWAYS||h.mask?(this.depthTest.set(!0),this.depthFunc.set(h.func),this.depthMask.set(h.mask),this.depthRange.set(h.range)):this.depthTest.set(!1)}setStencilMode(h){h.test.func!==this.gl.ALWAYS||h.mask?(this.stencilTest.set(!0),this.stencilMask.set(h.mask),this.stencilOp.set([h.fail,h.depthFail,h.pass]),this.stencilFunc.set({func:h.test.func,ref:h.ref,mask:h.test.mask})):this.stencilTest.set(!1)}setColorMode(h){i.by(h.blendFunction,Dn.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(h.blendFunction),this.blendColor.set(h.blendColor),h.blendEquation?this.blendEquation.set(h.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(h.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}let Ry;function _r(M,h,x,A,D,F,z){const V=M.context,X=V.gl,ne=M.transform,oe=[i.aF(ne.center.lng),i.aJ(ne.center.lat)],ge=x.layout.get("symbol-placement"),pe=x.layout.get("text-variable-anchor"),xe=x.layout.get("icon-rotation-alignment")==="map",Pe=x.layout.get("text-rotation-alignment")==="map",Ce=ge!=="point",Ve=[];let Be=0,tt=0;for(let mt=0;mt0){const cr=i.bC(),xr=Ys;i.cP(cr,Ut.placementInvProjMatrix,ne.glCoordMatrix),i.cP(cr,cr,Ut.placementViewportMatrix),Ve.push({circleArray:Cr,circleOffset:tt,transform:xr,invTransform:cr,projection:Ut.getProjection()}),Be+=Cr.length/4,tt=Be}if(!Us)continue;M.terrain&&M.terrain.setupElevationDraw(Ht,mr);const Nr=Es?[Et.canonical.x,Et.canonical.y,1<=0&&(xe[dt.associatedIconIndex]={x:Ut,y:ts,z:ns,angle:ds})}else Wm(yt,ge)}if(ne){pe.clear();const tt=M.icon.placedSymbolArray;for(let dt=0;dt{let Ca=[0,0,0];if(Qa){const Fn=M.style.directionalLight,qi=M.style.ambientLight;Fn&&qi&&(Ca=Wf(M.style,Fn,qi))}return Ca},Fa=Qa=>{mt.depthOcclusionForSymbolsAndCircles&&(x.hasOcclusionOpacityProperties||M.terrain)&&(Qa.push("DEPTH_D24"),Qa.push("DEPTH_OCCLUSION"))},vn=Qa=>{x.lut&&!yt&&(x.lut.texture||(x.lut.texture=new i.d$(M.context,x.lut.image,[x.lut.image.height,x.lut.image.height,x.lut.image.height],jt.gl.RGBA8)),jt.activeTexture.set(jt.gl.TEXTURE0+_c.LUT),x.lut.texture&&x.lut.texture.bind(jt.gl.LINEAR,jt.gl.CLAMP_TO_EDGE),Qa.push("APPLY_LUT_ON_GPU"))},Xa=()=>{const Qa=Et&&x.layout.get("symbol-placement")!=="point",Ca=[];Fa(Ca),vn(Ca);const Fn=Qa||jn,qi=Us.elevationType==="road",Ao=M.shadowRenderer,uo=qi&&Ut&&!!Ao&&Ao.enabled,ji=Er(uo),ru=qi&&Ut&&!M.terrain?Yt:Bs,ed=x.paint.get("icon-image-cross-fade");M.terrainRenderModeElevated()&&Ut&&Ca.push("PITCH_WITH_MAP_TERRAIN"),Cr&&(Ca.push("PROJECTION_GLOBE_VIEW"),Fn&&Ca.push("PROJECTED_POS_ON_VIEWPORT")),ed>0&&Us.hasAnySecondaryIcon&&Ca.push("ICON_TRANSITION"),!Us.icon.zOffsetVertexBuffer||qi&&M.terrain||Ca.push("Z_OFFSET"),Be===0&&tt===0&&dt===0&&st===1||Ca.push("COLOR_ADJUSTMENT"),Us.sdfIcons&&Ca.push("RENDER_SDF"),uo&&Ca.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),qi&&Ut&&!M.terrain&&Us.icon.orientationVertexBuffer&&Ca.push("ELEVATED_ROADS");const jl=Us.icon.programConfigurations.get(x.id),fd=M.getOrCreateProgram("symbol",{config:jl,defines:Ca}),gd=Ys.imageAtlasTexture?Ys.imageAtlasTexture.size:[0,0],Ic=Us.iconSizeData,jh=i.bK(Ic,mt.zoom),mm=Ut||!mt.isOrthographic,Mu=Ks(cr,Ys.tileID.canonical,Ut,Et,mt,Us.getProjection(),xr),jo=cn(cr,Ys.tileID.canonical,Ut,Et,mt,Us.getProjection(),xr),Ro=M.translatePosMatrix(jo,Ys,V,ne,!0),Ni=M.translatePosMatrix(cr,Ys,V,ne),Zo=Fn?Mb:Mu,go=Et&&!Ut&&!Qa;let ho=Js;!Jt&&!mt.mercatorFromTransition||Et||(ho=Kf(mt));const pm=Cr?ho:Js,$b=x.getColorAdjustmentMatrix(Be,tt,dt,st),Qm=XS(Ic.kind,jh,go,Ut,M,Ni,Zo,Ro,Mt,!1,gd,[0,0],0,mr,Nr,zt,pa,pm,Us.getProjection(),ji,Ha,$b,ed,null),qb=Ys.imageAtlasTexture?Ys.imageAtlasTexture:null,Uv=x.layout.get("icon-size").constantOr(0)!==1||Us.iconsNeedLinear,qp=Us.sdfIcons||M.options.rotating||M.options.zooming||Uv||mm?gt.LINEAR:gt.NEAREST,rg=Us.sdfIcons&&x.paint.get("icon-halo-width").constantOr(1)!==0,Vv=M.terrain&&Ut&&Qa?i.bl(i.bC(),Mu):Mb;if(Qa&&Us.icon){const jx=i.bV.getAtTileOffsetFunc(mr,mt.center.lat,mt.worldSize,Us.getProjection()),ng=ln(cr,Ys.tileID.canonical,Ut,Et,mt,Us.getProjection(),xr),Jm=x.layout.get("icon-size-scale-range"),ag=i.aA(M.scaleFactor,Jm[0],Jm[1]);Uf(Us,cr,M,!1,ng,jo,Ut,Ce,jx,mr,ag)}return{program:fd,buffers:Us.icon,uniformValues:Qm,atlasTexture:qb,atlasTextureIcon:null,atlasInterpolation:qp,atlasInterpolationIcon:null,isSDF:Us.sdfIcons,hasHalo:rg,depthMode:ru,tile:Ys,renderWithShadows:uo,labelPlaneMatrixInv:Vv}},fi=()=>{const Qa=Ht&&x.layout.get("symbol-placement")!=="point",Ca=[],Fn=Qa||ds||jn,qi=Us.elevationType==="road",Ao=M.shadowRenderer,uo=qi&&ts&&!!Ao&&Ao.enabled,ji=Er(uo),ru=qi&&ts&&!M.terrain?Yt:Bs;M.terrainRenderModeElevated()&&ts&&Ca.push("PITCH_WITH_MAP_TERRAIN"),Cr&&(Ca.push("PROJECTION_GLOBE_VIEW"),Fn&&Ca.push("PROJECTED_POS_ON_VIEWPORT")),!Us.text.zOffsetVertexBuffer||qi&&M.terrain||Ca.push("Z_OFFSET"),Us.iconsInText&&Ca.push("RENDER_TEXT_AND_SYMBOL"),Ca.push("RENDER_SDF"),uo&&Ca.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),qi&&ts&&!M.terrain&&Us.text.orientationVertexBuffer&&Ca.push("ELEVATED_ROADS"),Fa(Ca);const ed=Us.text.programConfigurations.get(x.id),jl=M.getOrCreateProgram("symbol",{config:ed,defines:Ca});let fd,gd=[0,0],Ic=null;const jh=Us.textSizeData;Us.iconsInText&&(gd=Ys.imageAtlasTexture?Ys.imageAtlasTexture.size:[0,0],Ic=Ys.imageAtlasTexture?Ys.imageAtlasTexture:null,fd=ts||!mt.isOrthographic||M.options.rotating||M.options.zooming||jh.kind==="composite"||jh.kind==="camera"?gt.LINEAR:gt.NEAREST);const mm=Ys.glyphAtlasTexture?Ys.glyphAtlasTexture.size:[0,0],Mu=x.layout.get("text-size-scale-range"),jo=i.aA(M.scaleFactor,Mu[0],Mu[1]),Ro=i.bK(jh,mt.zoom,jo),Ni=Ks(cr,Ys.tileID.canonical,ts,Ht,mt,Us.getProjection(),xr),Zo=cn(cr,Ys.tileID.canonical,ts,Ht,mt,Us.getProjection(),xr),go=M.translatePosMatrix(Zo,Ys,X,oe,!0),ho=M.translatePosMatrix(cr,Ys,X,oe),pm=Fn?Mb:Ni,$b=Ht&&!ts&&!Qa;let Qm=Js;!Jt&&!mt.mercatorFromTransition||Ht||(Qm=Kf(mt));const qb=XS(jh.kind,Ro,$b,ts,M,ho,pm,go,Mt,!0,mm,gd,0,mr,Nr,zt,pa,Cr?Qm:Js,Us.getProjection(),ji,Ha,null,null,jo),Uv=Ys.glyphAtlasTexture?Ys.glyphAtlasTexture:null,qp=gt.LINEAR,rg=x.paint.get("text-halo-width").constantOr(1)!==0,Vv=M.terrain&&ts&&Qa?i.bl(i.bC(),Ni):Mb;if(Qa&&Us.text){const jx=i.bV.getAtTileOffsetFunc(mr,mt.center.lat,mt.worldSize,Us.getProjection()),ng=ln(cr,Ys.tileID.canonical,ts,Ht,mt,Us.getProjection(),xr);Uf(Us,cr,M,!0,ng,Zo,ts,Ve,jx,mr,jo)}return{program:jl,buffers:Us.text,uniformValues:qb,atlasTexture:Uv,atlasTextureIcon:Ic,atlasInterpolation:qp,atlasInterpolationIcon:fd,isSDF:!0,hasHalo:rg,depthMode:ru,tile:Ys,renderWithShadows:uo,labelPlaneMatrixInv:Vv}},oi=Us.icon.segments.get().length,Oa=Us.text.segments.get().length,Rn=oi&&!z.onlyText?Xa():null,Ka=Oa&&!z.onlyIcons?fi():null,fo=x.paint.get("icon-opacity").constantOr(1),Gi=x.paint.get("text-opacity").constantOr(1);if(ns&&Us.canOverlap){fs=!0;const Qa=fo&&!z.onlyText?Us.icon.segments.get():[],Ca=Gi&&!z.onlyIcons?Us.text.segments.get():[];for(const Fn of Qa)Es.push({segments:new i.bg([Fn]),sortKey:Fn.sortKey,state:Rn});for(const Fn of Ca)Es.push({segments:new i.bg([Fn]),sortKey:Fn.sortKey,state:Ka})}else z.onlyText||Es.push({segments:fo?Us.icon.segments:new i.bg([]),sortKey:0,state:Rn}),z.onlyIcons||Es.push({segments:Gi?Us.text.segments:new i.bg([]),sortKey:0,state:Ka})}fs&&Es.sort((mr,Ys)=>mr.sortKey-Ys.sortKey);for(const mr of Es){const Ys=mr.state;if(Ys)if(M.terrain?M.terrain.setupElevationDraw(Ys.tile,Ys.program,{useDepthForOcclusion:mt.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Ys.labelPlaneMatrixInv}):M.setupDepthForOcclusion(mt.depthOcclusionForSymbolsAndCircles,Ys.program),jt.activeTexture.set(gt.TEXTURE0),Ys.atlasTexture&&Ys.atlasTexture.bind(Ys.atlasInterpolation,gt.CLAMP_TO_EDGE,!0),Ys.atlasTextureIcon&&(jt.activeTexture.set(gt.TEXTURE1),Ys.atlasTextureIcon&&Ys.atlasTextureIcon.bind(Ys.atlasInterpolationIcon,gt.CLAMP_TO_EDGE,!0)),Ys.renderWithShadows&&M.shadowRenderer.setupShadows(Ys.tile.tileID.toUnwrapped(),Ys.program,"vector-tile"),M.uploadCommonLightUniforms(M.context,Ys.program),Ys.hasHalo){const Us=Ys.uniformValues;Us.u_is_halo=1,LT(Ys.buffers,mr.segments,x,M,Ys.program,Ys.depthMode,D,F,Us,2),Us.u_is_halo=0}else{if(Ys.isSDF){const Us=Ys.uniformValues;Ys.hasHalo&&(Us.u_is_halo=1,LT(Ys.buffers,mr.segments,x,M,Ys.program,Ys.depthMode,D,F,Us,1)),Us.u_is_halo=0}LT(Ys.buffers,mr.segments,x,M,Ys.program,Ys.depthMode,D,F,Ys.uniformValues,1)}}}function LT(M,h,x,A,D,F,z,V,X,ne){const oe=[M.dynamicLayoutVertexBuffer,M.opacityVertexBuffer,M.iconTransitioningVertexBuffer,M.globeExtVertexBuffer,M.zOffsetVertexBuffer,M.orientationVertexBuffer];D.draw(A,A.context.gl.TRIANGLES,F,z,V,rn.disabled,X,x.id,M.layoutVertexBuffer,M.indexBuffer,h,x.paint,A.transform.zoom,M.programConfigurations.get(x.id),oe,ne)}function KD(M,h){const x=1<=Km?1:xe.pitch/Km))),2*Pe}(M.transform),ne=M.transform.getFreeCameraOptions().position,oe="elevatedStructuresDepthReconstruct",ge=M.getOrCreateProgram(oe,{defines:["DEPTH_RECONSTRUCTION"]}),pe=M.getOrCreateProgram(oe);for(const xe of A){const Pe=h.getTile(xe),Ce=Pe.getBucket(x);if(!Ce)continue;const Ve=Ce.elevatedStructures;if(!Ve)continue;const Be=Ce.elevationBufferData.heightRange,tt=KD(xe.toUnwrapped(),ne),dt=M.translatePosMatrix(xe.projMatrix,Pe,x.paint.get("fill-translate"),x.paint.get("fill-translate-anchor"));let st,Mt,yt,jt;if(D==="initialize"){if(!Be||Be.min>=1||Ve.depthSegments.segments[0].primitiveLength===0)continue;st=Dy(dt,tt,X,1,0),Mt=z,yt=Ve.depthSegments,jt=ge}else if(D==="reset"){if(!Be||Be.min>=0||Ve.maskSegments.segments[0].primitiveLength===0)continue;st=Dy(dt,tt,0,0,1),Mt=V,yt=Ve.maskSegments,jt=ge}else if(D==="geometry"){if(Ve.depthSegments.segments[0].primitiveLength===0)continue;st=Dy(dt,tt,X,1,0),Mt=z,yt=Ve.depthSegments,jt=pe}jt.draw(M,F.TRIANGLES,Mt,dn.disabled,Dn.disabled,rn.disabled,st,x.id,Ve.vertexBuffer,Ve.indexBuffer,yt,x.paint,M.transform.zoom)}}function eC(M,h,x,A){const{painter:D,sourceCache:F,layer:z,coords:V,colorMode:X,elevationType:ne,terrainEnabled:oe,pass:ge}=M,pe=D.context.gl,xe=z.paint.get("fill-pattern"),Pe=z.paint.get("fill-pattern-cross-fade"),Ce=xe.constantOr(null);let Ve=ne;ne!=="road"||h&&!oe||(Ve="none");const Be=Ve==="road",tt=M.painter.shadowRenderer,dt=Be&&!!tt&&tt.enabled,st=new Lr(D.context.gl.LEQUAL,Lr.ReadOnly,D.depthRangeFor3D);let Mt=[0,0,0];if(dt){const mt=D.style.directionalLight,Et=D.style.ambientLight;mt&&Et&&(Mt=Wf(D.style,mt,Et))}const yt=xe&&xe.constantOr(1),jt=D.terrain&&D.terrain.renderingToTexture,gt=(mt,Et)=>{let Ht,Ut,ts,ns,fs;Et?(Ht=yt&&!z.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",ts=pe.LINES):(Ht=yt?"fillPattern":"fill",ts=pe.TRIANGLES);for(const Bs of V){const Yt=F.getTile(Bs);if(yt&&!Yt.patternsLoaded())continue;const zt=Yt.getBucket(z);if(!zt)continue;const ds=h?zt.elevationBufferData:zt.bufferData;if(ds.isEmpty())continue;D.prepareDrawTile();const Jt=ds.programConfigurations.get(z.id),Es=D.isTileAffectedByFog(Bs),Js=[],mr=[];Be&&(Js.push("ELEVATED_ROADS"),mr.push(ds.elevatedLayoutVertexBuffer)),dt&&Js.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),jt&&x&&Js.push("USE_MRT1"),yt&&(D.context.activeTexture.set(pe.TEXTURE0),Yt.imageAtlasTexture&&Yt.imageAtlasTexture.bind(pe.LINEAR,pe.CLAMP_TO_EDGE),Jt.updatePaintBuffers());let Ys=!1;if(Ce&&Yt.imageAtlas){const xr=Yt.imageAtlas,Vr=i.e3.from(Ce),jn=Vr.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),pa=Vr.getSecondary(),Ha=xr.patternPositions.get(jn),Er=pa?xr.patternPositions.get(pa.scaleSelf(i.o.devicePixelRatio).toString()):null;Ys=!!Ha&&!!Er,Ha&&Jt.setConstantPatternPositions(Ha,Er)}Pe>0&&(Ys||Jt.getPatternTransitionVertexBuffer("fill-pattern"))&&Js.push("FILL_PATTERN_TRANSITION");const Us=D.getOrCreateProgram(Ht,{config:Jt,overrideFog:Es,defines:Js}),Cr=D.translatePosMatrix(Bs.projMatrix,Yt,z.paint.get("fill-translate"),z.paint.get("fill-translate-anchor"));dt&&tt.setupShadows(Yt.tileID.toUnwrapped(),Us,"vector-tile");const Nr=z.paint.get("fill-emissive-strength");if(Et){ns=ds.lineIndexBuffer,fs=ds.lineSegments;const xr=D.terrain&&D.terrain.renderingToTexture?D.terrain.drapeBufferSize:[pe.drawingBufferWidth,pe.drawingBufferHeight];Ut=Ht==="fillOutlinePattern"&&yt?AT(Cr,Nr,D,Yt,xr,Mt,Pe):FD(Cr,Nr,xr,Mt)}else ns=ds.indexBuffer,fs=ds.triangleSegments,Ut=yt?TT(Cr,Nr,D,Yt,Mt,Pe):MT(Cr,Nr,Mt);D.uploadCommonUniforms(D.context,Us,Bs.toUnwrapped());let cr=mt;(ne==="road"&&!oe||ne==="offset")&&(cr=st),Us.draw(D,ts,cr,A||D.stencilModeForClipping(Bs),X,rn.disabled,Ut,z.id,ds.layoutVertexBuffer,ns,fs,z.paint,D.transform.zoom,Jt,mr)}};D.renderPass===ge&>(D.depthModeForSublayer(1,D.renderPass==="opaque"?Lr.ReadWrite:Lr.ReadOnly),!1),Ve==="none"&&D.renderPass==="translucent"&&z.paint.get("fill-antialias")&>(D.depthModeForSublayer(z.getPaintProperty("fill-outline-color")?2:0,Lr.ReadOnly),!0)}function tC(M,h,x,A,D,F,z,V){x.resetLayerRenderingStats(M);const X=M.context,ne=X.gl,oe=M.transform,ge=x.paint.get("fill-extrusion-pattern"),pe=x.paint.get("fill-extrusion-pattern-cross-fade"),xe=ge.constantOr(null),Pe=ge.constantOr(1),Ce=x.paint.get("fill-extrusion-opacity"),Ve=M.style.enable3dLights(),Be=x.paint.get(Ve&&!Pe?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),tt=[x.paint.get("fill-extrusion-ambient-occlusion-intensity"),Be],dt=x.layout.get("fill-extrusion-edge-radius"),st=dt>0&&!x.paint.get("fill-extrusion-rounded-roof"),Mt=st?0:dt,yt=oe.projection.name==="globe"?i.eb():0,jt=oe.projection.name==="globe",gt=jt?i.aj(oe.zoom):0,mt=[i.aF(oe.center.lng),i.aJ(oe.center.lat)],Et=x.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Ht=x.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Et?null:x.lut).toArray01().slice(0,3),Ut=x.paint.get("fill-extrusion-flood-light-intensity"),ts=x.paint.get("fill-extrusion-vertical-scale"),ns=x.paint.get("fill-extrusion-line-width").constantOr(1)!==0,fs=x.paint.get("fill-extrusion-height-alignment"),Bs=x.paint.get("fill-extrusion-base-alignment"),Yt=cx(M,x.paint.get("fill-extrusion-cutoff-fade-range")),zt=[];let ds;jt&&zt.push("PROJECTION_GLOBE_VIEW"),tt[0]>0&&zt.push("FAUX_AO"),st&&zt.push("ZERO_ROOF_RADIUS"),V&&zt.push("HAS_CENTROID"),Ut>0&&zt.push("FLOOD_LIGHT"),Yt.shouldRenderCutoff&&zt.push("RENDER_CUTOFF"),ns&&zt.push("RENDER_WALL_MODE");const Jt=M.renderPass==="shadow",Es=M.shadowRenderer,Js=Jt&&!!Es,mr=Jt?rn.disabled:rn.backCCW;M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!0);let Ys=[0,0,0];if(Es){const Nr=M.style.directionalLight,cr=M.style.ambientLight;Nr&&cr&&(Ys=Wf(M.style,Nr,cr)),Jt||(zt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),Es.useNormalOffset&&zt.push("NORMAL_OFFSET")),ds=zt.concat(["SHADOWS_SINGLE_CASCADE"])}const Us=Js?"fillExtrusionDepth":Pe?"fillExtrusionPattern":"fillExtrusion",Cr=x.getLayerRenderingStats();for(const Nr of A){const cr=h.getTile(Nr),xr=cr.getBucket(x);if(!xr||xr.projection.name!==oe.projection.name)continue;let Vr=!1;Es&&(Vr=Es.getMaxCascadeForTile(Nr.toUnwrapped())===0);const jn=M.isTileAffectedByFog(Nr),pa=xr.programConfigurations.get(x.id);let Ha=!1;if(xe&&cr.imageAtlas){const Oa=cr.imageAtlas,Rn=i.e3.from(xe),Ka=Rn.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),fo=Rn.getSecondary(),Gi=Oa.patternPositions.get(Ka),Qa=fo?Oa.patternPositions.get(fo.scaleSelf(i.o.devicePixelRatio).toString()):null;Ha=!!Gi&&!!Qa,Gi&&pa.setConstantPatternPositions(Gi,Qa)}pe>0&&(Ha||pa.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&zt.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Er=M.getOrCreateProgram(Us,{config:pa,defines:Vr?ds:zt,overrideFog:jn});if(M.terrain&&M.terrain.setupElevationDraw(cr,Er,{useMeterToDem:!0}),!xr.centroidVertexBuffer){const Oa=Er.getAttributeLocation(ne,"a_centroid_pos");Oa!==-1&&ne.vertexAttrib2f(Oa,0,0)}!Jt&&Es&&Es.setupShadows(cr.tileID.toUnwrapped(),Er,"vector-tile"),Pe&&(M.context.activeTexture.set(ne.TEXTURE0),cr.imageAtlasTexture&&cr.imageAtlasTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE),pa.updatePaintBuffers());const Fa=x.paint.get("fill-extrusion-vertical-gradient"),vn=1/xr.tileToMeter;let Xa;if(Jt&&Es){if(Yf(cr.tileID,xr.maxHeight,M))continue;const Oa=Es.calculateShadowPassMatrixFromTile(cr.tileID.toUnwrapped());Xa=CT(Oa,Mt,vn,ts,fs,Bs)}else{const Oa=M.translatePosMatrix(Nr.expandedProjMatrix,cr,x.paint.get("fill-extrusion-translate"),x.paint.get("fill-extrusion-translate-anchor")),Rn=oe.projection.createInversionMatrix(oe,Nr.canonical);Xa=Pe?RD(Oa,M,Fa,Ce,tt,Mt,vn,Nr,cr,yt,fs,Bs,gt,mt,Rn,Ht,ts,pe):GS(Oa,M,Fa,Ce,tt,Mt,vn,Nr,yt,fs,Bs,gt,mt,Rn,Ht,ts,Ut,Ys)}M.uploadCommonUniforms(X,Er,Nr.toUnwrapped(),null,Yt);let fi=xr.segments;if(oe.projection.name==="mercator"&&!Jt&&(fi=xr.getVisibleSegments(cr.tileID,M.terrain,M.transform.getFrustum(0)),!fi.get().length))continue;if(Cr)if(Jt)for(const Oa of fi.get())Cr.numRenderedVerticesInShadowPass+=Oa.primitiveLength;else for(const Oa of fi.get())Cr.numRenderedVerticesInTransparentPass+=Oa.primitiveLength;const oi=[];(M.terrain||V)&&oi.push(xr.centroidVertexBuffer),jt&&oi.push(xr.layoutVertexExtBuffer),ns&&oi.push(xr.wallVertexBuffer),Er.draw(M,X.gl.TRIANGLES,D,F,z,mr,Xa,x.id,xr.layoutVertexBuffer,xr.indexBuffer,fi,x.paint,M.transform.zoom,pa,oi)}M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!1)}class DT{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function Zf(M,h,x,A,D,F,z,V,X,ne,oe,ge,pe,xe,Pe,Ce,Ve,Be,tt,dt){const st=h.context,Mt=st.gl,yt=h.transform,jt=h.transform.zoom,gt=[],mt=M.translate,Et=M.translateAnchor,Ht=M.edgeRadius,Ut=cx(h,M.cutoffFadeRange);oe==="clear"?(gt.push("CLEAR_SUBPASS"),dt&&(gt.push("CLEAR_FROM_TEXTURE"),st.activeTexture.set(Mt.TEXTURE0),dt.bind(Mt.LINEAR,Mt.CLAMP_TO_EDGE))):oe==="sdf"?gt.push("SDF_SUBPASS"):oe==="emissive"&&(gt.push("USE_MRT1"),st.activeTexture.set(Mt.TEXTURE0),dt.bind(Mt.LINEAR,Mt.CLAMP_TO_EDGE)),Be&>.push("HAS_CENTROID"),Ut.shouldRenderCutoff&>.push("RENDER_CUTOFF");const ts=(ns,fs,Bs,Yt,zt)=>{let ds=gt;fs.groundRadiusBuffer!=null&&(ds=gt.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const Jt=fs.programConfigurations.get(A.id),Es=h.isTileAffectedByFog(ns),Js=h.getOrCreateProgram("fillExtrusionGroundEffect",{config:Jt,defines:ds,overrideFog:Es}),mr=Pv(h,Yt,ge,ne,zt,[pe,xe*zt],Pe,Ce,Ve,jt>=17?0:Ht*zt,dt?dt.size[0]:0),Ys=[];Be&&Ys.push(fs.hiddenByLandmarkVertexBuffer),fs.groundRadiusBuffer!=null&&Ys.push(fs.groundRadiusBuffer),h.uploadCommonUniforms(st,Js,ns.toUnwrapped(),null,Ut),Js.draw(h,st.gl.TRIANGLES,F,z,V,X,mr,A.id,fs.vertexBuffer,fs.indexBuffer,Bs,A.paint,jt,Jt,Ys)};for(const ns of D){const fs=x.getTile(ns),Bs=fs.getBucket(A);if(!Bs||Bs.projection.name!==yt.projection.name||!Bs.groundEffect||Bs.groundEffect&&!Bs.groundEffect.hasData())continue;const Yt=Bs.groundEffect,zt=1/Bs.tileToMeter;{const ds=h.translatePosMatrix(ns.projMatrix,fs,mt,Et),Jt=Yt.getDefaultSegment();ts(ns,Yt,Jt,ds,zt)}if(tt)for(let ds=0;ds<4;ds++){const Jt=i.e9[ds](ns),Es=x.getTile(Jt);if(!Es)continue;const Js=Es.getBucket(A);if(!Js||Js.projection.name!==yt.projection.name||!Js.groundEffect||Js.groundEffect&&!Js.groundEffect.hasData())continue;const mr=Js.groundEffect;let Ys,Us;ds===0?(Ys=[-i.al,0,0],Us=1):ds===1?(Ys=[i.al,0,0],Us=0):ds===2?(Ys=[0,-i.al,0],Us=3):(Ys=[0,i.al,0],Us=2);const Cr=mr.regionSegments[Us];if(!Cr)continue;const Nr=new Float32Array(16);i.br(Nr,ns.projMatrix,Ys),ts(ns,mr,Cr,h.translatePosMatrix(Nr,fs,mt,Et),zt)}}}function cde(M,h,x,A,D,F,z){A.centroidVertexArray.length===0&&A.createCentroidsBuffer();const V=F?F.findDEMTileFor(x):null;if(!(V&&V.dem||z))return;F&&V&&V.dem&&A.selfDEMTileTimestamp!==V.dem._timestamp&&(A.borderDoneWithNeighborZ=[-1,-1,-1,-1],A.selfDEMTileTimestamp=V.dem._timestamp);const X=Be=>new i.P(Math.ceil((Be+i.ed)*i.ee),0),ne=Be=>{const tt=h.getSource().minzoom,dt=Mt=>{const yt=h.getTileByID(Mt);if(yt&&yt.hasData())return yt.getBucket(D)},st=[0,-1,1];for(const Mt of st){if(Be.overscaledZ+Mt(oe[0]=Math.min(Be.min.y,tt.min.y),oe[1]=Math.max(Be.max.y,tt.max.y),oe[2]=i.al-tt.min.x>Be.max.x?tt.min.x-i.al:Be.max.x,oe),pe=(Be,tt)=>(oe[0]=Math.min(Be.min.x,tt.min.x),oe[1]=Math.max(Be.max.x,tt.max.x),oe[2]=i.al-tt.min.y>Be.max.y?tt.min.y-i.al:Be.max.y,oe),xe=[(Be,tt)=>ge(Be,tt),(Be,tt)=>ge(tt,Be),(Be,tt)=>pe(Be,tt),(Be,tt)=>pe(tt,Be)],Pe=(Be,tt,dt,st,Mt,yt,jt)=>{if(!F)return 0;const gt=[[yt?dt:Be,yt?Be:dt,0],[yt?dt:tt,yt?tt:dt,0]],mt=jt<0?i.al+jt:jt,Et=[yt?mt:(Be+tt)/2,yt?(Be+tt)/2:mt,0];return dt===0&&jt<0||dt!==0&&jt>0?F.getForTilePoints(Mt,[Et],!0,st):gt.push(Et),F.getForTilePoints(x,gt,!0,V),Math.max(gt[0][2],gt[1][2],Et[2])/F.exaggeration()};for(let Be=0;Be<4;Be++){const tt=A.borderFeatureIndices[Be];if(tt.length===0)continue;const dt=i.e9[Be](x),st=ne(dt);if(!(st&&st instanceof i.ea))continue;const Mt=F?F.findDEMTileFor(dt):null;if(!(Mt&&Mt.dem||z)||(F&&Mt&&Mt.dem&&A.borderDEMTileTimestamp[Be]!==Mt.dem._timestamp&&(A.borderDoneWithNeighborZ[Be]=-1,A.borderDEMTileTimestamp[Be]=Mt.dem._timestamp),A.borderDoneWithNeighborZ[Be]===st.canonical.z))continue;st.centroidVertexArray.length===0&&st.createCentroidsBuffer();const yt=(Be<2?1:5)-Be,jt=st.borderDoneWithNeighborZ[yt]!==A.canonical.z,gt=st.borderFeatureIndices[yt];let mt=0;if(A.canonical.z!==st.canonical.z){for(const Et of tt)A.showCentroid(A.featuresOnBorder[Et]);if(jt)for(const Et of gt)st.showCentroid(st.featuresOnBorder[Et]);A.borderDoneWithNeighborZ[Be]=st.canonical.z,st.borderDoneWithNeighborZ[yt]=A.canonical.z}for(const Et of tt){const Ht=A.featuresOnBorder[Et],Ut=A.centroidData[Ht.centroidDataIndex],ts=Ht.borders[Be];let ns;for(;mtts[0]+3||fs[0]>ts[0]-3)break;st.showCentroid(ns),mt++}if(ns&&mtts[1]-3)&&(Bs++,++mt!==gt.length);)ns=st.featuresOnBorder[gt[mt]];ns=st.featuresOnBorder[gt[fs]];let Yt=!1;if(Bs>=1){const Jt=ns.borders[yt];Math.abs(ts[0]-Jt[0])<3&&Math.abs(ts[1]-Jt[1])<3&&(Bs=1,Yt=!0,mt=fs+1)}else if(Bs===0){A.showCentroid(Ht);continue}const zt=st.centroidData[ns.centroidDataIndex];z&&Yt&&(((Ce=Ut).flags|(Ve=zt).flags)&i.ec?(Ce.flags|=i.ec,Ve.flags|=i.ec):(Ce.flags&=~i.ec,Ve.flags&=~i.ec));const ds=Ht.intersectsCount()>1||ns.intersectsCount()>1;if(Bs>1)mt=fs,Ut.centroidXY=zt.centroidXY=new i.P(0,0);else if(Mt&&Mt.dem&&!ds){const Jt=xe[Be](Ut,zt),Es=Be%2?i.al-1:0,Js=Pe(Jt[0],Math.min(i.al-1,Jt[1]),Es,Mt,dt,Be<2,Jt[2]);Ut.centroidXY=zt.centroidXY=X(Js)}else ds?Ut.centroidXY=zt.centroidXY=new i.P(0,0):(Ut.centroidXY=A.encodeBorderCentroid(Ht),zt.centroidXY=st.encodeBorderCentroid(ns));A.writeCentroidToBuffer(Ut),st.writeCentroidToBuffer(zt)}else A.showCentroid(Ht)}A.borderDoneWithNeighborZ[Be]=st.canonical.z,st.borderDoneWithNeighborZ[yt]=A.canonical.z}var Ce,Ve;(A.needsCentroidUpdate||!A.centroidVertexBuffer&&A.centroidVertexArray.length!==0)&&A.uploadCentroid(M)}const Hu=[1,0,0],OT=[0,1,0],tu=[0,0,1];function Yf(M,h,x){const A=x.transform,D=x.shadowRenderer;if(!D)return!0;const F=M.toUnwrapped(),z=A.tileSize*D._cascades[x.currentShadowCascade].scale;let V=h;if(A.elevation){const Ce=A.elevation.getMinMaxForTile(M);Ce&&(V+=Ce.max)}const X=[...D.shadowDirection];X[2]=-X[2];const ne=D.computeSimplifiedTileShadowVolume(F,V,z,X);if(!ne)return!1;const oe=[Hu,OT,tu,X,[X[0],0,X[2]],[0,X[1],X[2]]],ge=A.projection.name==="globe",pe=A.scaleZoom(z),xe=i.cB.fromInvProjectionMatrix(A.invProjMatrix,A.worldSize,pe,!ge),Pe=D.getCurrentCascadeFrustum();return xe.intersectsPrecise(ne.vertices,ne.planes,oe)===0||Pe.intersectsPrecise(ne.vertices,ne.planes,oe)===0}function Ab(M){const{painter:h,source:x,layer:A,coords:D}=M;let F=M.defines;const z=h.context,V=h.renderPass==="shadow",X=h.renderPass==="light-beam",ne=h.shadowRenderer,oe=i.ef(h.transform.center.lat,h.transform.zoom),ge=cx(h,A.paint.get("building-cutoff-fade-range"));ge.shouldRenderCutoff&&(F=F.concat("RENDER_CUTOFF")),M.floodLightIntensity>0&&(F=F.concat("FLOOD_LIGHT"));for(const pe of D){const xe=x.getTile(pe),Pe=xe.getBucket(A);if(!Pe)continue;ne&&ne.getMaxCascadeForTile(pe.toUnwrapped())===0&&(F=F.concat("SHADOWS_SINGLE_CASCADE"));const Ce=Pe.programConfigurations.get(A.id);let Ve,Be,tt,dt=h.translatePosMatrix(pe.expandedProjMatrix,xe,[0,0],"map");if(dt=i.cS(i.bC(),dt,[1,1,M.verticalScale]),V&&ne){if(Yf(xe.tileID,Pe.maxHeight*oe,h))continue;let Mt=ne.calculateShadowPassMatrixFromTile(xe.tileID.toUnwrapped());Mt=i.cS(i.bC(),Mt,[1,1,M.verticalScale]),tt=gx(Mt),Ve=Be=h.getOrCreateProgram("buildingDepth",{config:Ce,defines:F,overrideFog:!1})}else if(X)Ve=Be=h.getOrCreateProgram("buildingBloom",{config:Ce,defines:F,overrideFog:!1}),tt=zD(dt);else{const Mt=h.transform.calculatePosMatrix(pe.toUnwrapped(),h.transform.worldSize);i.cS(Mt,Mt,[1,1,M.verticalScale]);const yt=i.bC();i.cS(yt,Mt,[1,-1,1/oe]),i.bl(yt,yt),i.eg(yt,yt);const jt=h.transform.getFreeCameraOptions().position,gt=1<{if(X){const jt=Mt.entranceBloom;yt.draw(h,z.gl.TRIANGLES,M.depthMode,dn.disabled,M.blendMode,rn.disabled,tt,A.id,jt.layoutVertexBuffer,jt.indexBuffer,jt.segmentsBucket,A.paint,h.transform.zoom,Ce,[jt.layoutAttenuationBuffer,jt.layoutColorBuffer])}else{const jt=Mt.segmentsBucket;let gt=[Mt.layoutNormalBuffer,Mt.layoutCentroidBuffer,Mt.layoutColorBuffer,Mt.layoutFloodLightDataBuffer];Mt.layoutFacadePaintBuffer&&(gt=gt.concat([Mt.layoutFacadeDataBuffer,Mt.layoutFacadeVerticalRangeBuffer,Mt.layoutFacadePaintBuffer])),yt.draw(h,z.gl.TRIANGLES,M.depthMode,dn.disabled,M.blendMode,V?rn.disabled:rn.backCW,tt,A.id,Mt.layoutVertexBuffer,Mt.indexBuffer,jt,A.paint,h.transform.zoom,Ce,gt)}};h.uploadCommonUniforms(z,Be,pe.toUnwrapped(),null,ge),Pe.buildingWithoutFacade&&st(Pe.buildingWithoutFacade,Be),Pe.buildingWithFacade&&(Ve!==Be&&h.uploadCommonUniforms(z,Ve,pe.toUnwrapped(),null,ge),st(Pe.buildingWithFacade,Ve))}}function sC(M,h,x,A,D,F,z,V,X,ne,oe,ge,pe){const xe=M.context.gl,Pe=M.depthModeForSublayer(1,Lr.ReadOnly,xe.LEQUAL,!0),Ce=.1*(1-(Ve=oe))+3*Ve;var Ve;const Be=M._showOverdrawInspector,tt=ge,dt=new DT;Be||Zf(dt,M,h,x,A,Pe,new dn({func:xe.ALWAYS,mask:255},255,255,xe.KEEP,xe.KEEP,xe.REPLACE),new Dn([xe.ONE,xe.ONE,xe.ONE,xe.ONE],i.ao.transparent,[!1,!1,!1,!0],xe.MIN),rn.disabled,D,"sdf",F,z,V,X,ne,Ce,tt,!1);{const st=Be?dn.disabled:new dn({func:xe.EQUAL,mask:255},255,255,xe.KEEP,xe.DECR,xe.DECR),Mt=Be?M.colorModeForRenderPass():new Dn([xe.ONE_MINUS_DST_ALPHA,xe.DST_ALPHA,xe.ONE,xe.ONE],i.ao.transparent,[!0,!0,!0,!0]);Zf(dt,M,h,x,A,Pe,st,Mt,rn.disabled,D,"color",F,z,V,X,ne,Ce,tt,!1)}}function rC(M){return[M[0]*i.eh,M[1]*i.eh,M[2]*i.eh,0]}function Eb(M,h,x,A,D,F,z,V,X){const ne=A.getSource(),oe=x.globeSharedBuffers;if(!oe)return;let ge,pe,xe;if(h&&(ge=A.getTile(h)),ne instanceof i.aU?(pe=ne.texture,xe=i.dK(0,0,x.transform)):ge&&h&&(pe=ge.texture,xe=i.dK(h.canonical.z,h.canonical.x,x.transform)),!pe||!xe)return;M||(xe=i.cS(i.bC(),xe,[1,-1,1]));const Pe=x.context,Ce=Pe.gl,Ve=D.paint.get("raster-resampling")==="nearest"?Ce.NEAREST:Ce.LINEAR,Be=x.colorModeForDrapableLayerRenderPass(F),tt=z.defines;tt.push("GLOBE_POLES");const dt=new Lr(Ce.LEQUAL,Lr.ReadWrite,x.depthRangeFor3D),st=Float32Array.from(x.transform.expandedFarZProjMatrix),Mt=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0))));x.terrain&&x.terrain.prepareDrawTile(),Pe.activeTexture.set(Ce.TEXTURE0),pe.bind(Ve,Ce.CLAMP_TO_EDGE),Pe.activeTexture.set(Ce.TEXTURE1),pe.bind(Ve,Ce.CLAMP_TO_EDGE),"useMipmap"in pe&&Pe.extTextureFilterAnisotropic&&x.transform.pitch>20&&Ce.texParameterf(Ce.TEXTURE_2D,Pe.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,Pe.extTextureFilterAnisotropicMax);const[yt,jt,gt,mt]=h?oe.getPoleBuffers(h.canonical.z,!1):oe.getPoleBuffers(0,!0),Et=D.paint.get("raster-elevation");let Ht;M?(Ht=yt,x.renderDefaultNorthPole=Et!==0):(Ht=jt,x.renderDefaultSouthPole=Et!==0);const Ut=rC(z.mix),ts=((fs,Bs,Yt,zt,ds,Jt,Es,Js,mr,Ys,Us,Cr,Nr)=>qD(fs,Bs,Yt,new Float32Array(16),new Float32Array(9),[0,0],zt,[0,0],[0,0,0,0],1,{opacity:1,mix:0},Jt,[0,0],Js,2,Ys,Us,Cr,1,0,Nr))(st,Mt,xe,i.aj(x.transform.zoom),0,D,0,Et,0,Ut,z.offset,z.range,F),ns=x.getOrCreateProgram("raster",{defines:tt});x.uploadCommonUniforms(Pe,ns,null),ns.draw(x,Ce.TRIANGLES,dt,X,Be,V,ts,D.id,Ht,gt,mt)}function ZD(M){const h=M._nearZ,x=M.projection.farthestPixelDistance(M),A=x-h,D=.2*M.height,F=h+D;return[h,x,(F-D-h)/A,(F-h)/A]}function Xf(M,h,x,A){if(M)return h instanceof Xc&&M instanceof Jc?h.getTextureDescriptor(M,x,!0):{texture:M.texture,mix:rC(A.mix),offset:A.offset,buffer:0,tileSize:1}}var Fi=i.ei([{name:"a_index",type:"Int16",components:1}]);class nC{constructor(h,x,A,D){const F={width:A[0],height:A[1],data:null},z=h.gl;this.targetColorTexture=new i.T(h,F,z.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new i.T(h,F,z.RGBA8,{useMipmap:!1}),this.context=h,this.updateParticleTexture(x,D),this.lastInvalidatedAt=0}updateParticleTexture(h,x){if(this.particleTextureDimension===x.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const A=this.context.gl,D=x.width*x.height;this.particleTexture0=new i.T(this.context,x,A.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new i.T(this.context,x,A.RGBA8,{premultiply:!1,useMipmap:!1});const F=new i.ej;F.reserve(D);for(let z=0;z0){const Ut=i.bj(x.canonical,X),ts=i.el(Ut);pe=i.aB(new Float32Array(16),X.globeMatrix,ts),i.aB(pe,X.projMatrix,pe)}const xe=i.bC();xe[12]+=2*D/(i.o.devicePixelRatio*X.width),xe[13]+=2*F/(i.o.devicePixelRatio*X.height),i.aB(pe,xe,pe);const Pe=M.getOrCreateProgram("debug",{defines:ge}),Ce=h.getTileByID(x.key);M.terrain&&M.terrain.setupElevationDraw(Ce,Pe);const Ve=Lr.disabled,Be=dn.disabled,tt=M.colorModeForRenderPass(),dt="$debug";V.activeTexture.set(ne.TEXTURE0),M.emptyTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE),oe?Ce._makeGlobeTileDebugBuffers(M.context,X):Ce._makeDebugTileBoundsBuffers(M.context,X.projection);const st=Ce._tileDebugBuffer||M.debugBuffer,Mt=Ce._tileDebugIndexBuffer||M.debugIndexBuffer,yt=Ce._tileDebugSegments||M.debugSegments;if(Pe.draw(M,ne.LINE_STRIP,Ve,Be,tt,rn.disabled,Sb(pe,A.toPremultipliedRenderColor(null)),dt,st,Mt,yt,null,null,null,[Ce._globeTileDebugBorderBuffer]),z){const Ut=Ce.latestRawTileData,ts=Math.floor((Ut&&Ut.byteLength||0)/1024);let ns=x.canonical.toString();x.overscaledZ!==x.canonical.z&&(ns+=` => ${x.overscaledZ}`),ns+=` ${Ce.state}`,ns+=` ${ts}kb`,function(fs,Bs){fs.initDebugOverlayCanvas();const Yt=fs.debugOverlayCanvas,zt=fs.context.gl,ds=fs.debugOverlayCanvas.getContext("2d");ds.clearRect(0,0,Yt.width,Yt.height),ds.shadowColor="white",ds.shadowBlur=2,ds.lineWidth=1.5,ds.strokeStyle="white",ds.textBaseline="top",ds.font="bold 36px Open Sans, sans-serif",ds.fillText(Bs,5,5),ds.strokeText(Bs,5,5),fs.debugOverlayTexture.update(Yt),fs.debugOverlayTexture.bind(zt.LINEAR,zt.CLAMP_TO_EDGE)}(M,ns)}const jt=h.getTile(x).tileSize,gt=512/Math.min(jt,512)*(x.overscaledZ/X.zoom)*.5,mt=Ce._tileDebugTextBuffer||M.debugBuffer,Et=Ce._tileDebugTextIndexBuffer||M.quadTriangleIndexBuffer,Ht=Ce._tileDebugTextSegments||M.debugSegments;Pe.draw(M,ne.TRIANGLES,Ve,Be,Dn.alphaBlended,rn.disabled,Sb(pe,i.ao.transparent.toPremultipliedRenderColor(null),gt),dt,mt,Et,Ht,null,null,null,[Ce._globeTileDebugTextBuffer])}function By(M,h,x,A){Gt(M,0,h+x/2,M.transform.width,x,A)}function wo(M,h,x,A){Gt(M,h-x/2,0,x,M.transform.height,A)}function Gt(M,h,x,A,D,F){const z=M.context,V=z.gl;V.enable(V.SCISSOR_TEST),V.scissor(h*i.o.devicePixelRatio,x*i.o.devicePixelRatio,A*i.o.devicePixelRatio,D*i.o.devicePixelRatio),z.clear({color:F}),V.disable(V.SCISSOR_TEST)}const eO=i.ei([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:aC}=eO;function Fp(M,h,x,A){M.emplaceBack(h,x,A)}class iC{constructor(h){this.vertexArray=new i.em,this.indices=new i.b0,Fp(this.vertexArray,-1,-1,1),Fp(this.vertexArray,1,-1,1),Fp(this.vertexArray,-1,1,1),Fp(this.vertexArray,1,1,1),Fp(this.vertexArray,-1,-1,-1),Fp(this.vertexArray,1,-1,-1),Fp(this.vertexArray,-1,1,-1),Fp(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=h.createVertexBuffer(this.vertexArray,aC),this.indexBuffer=h.createIndexBuffer(this.indices),this.segment=i.bg.simpleSegment(0,0,36,12)}}function $y(M,h,x,A,D,F){const z=M.context.gl,V=h.paint.get("sky-atmosphere-color"),X=h.paint.get("sky-atmosphere-halo-color"),ne=h.paint.get("sky-atmosphere-sun-intensity"),oe=((ge,pe,xe,Pe,Ce)=>({u_matrix_3f:ge,u_sun_direction:pe,u_sun_intensity:xe,u_color_tint_r:[Pe.r,Pe.g,Pe.b,Pe.a],u_color_tint_m:[Ce.r,Ce.g,Ce.b,Ce.a],u_luminance:5e-5}))(i.eo(i.dO(),A),D,ne,V.toPremultipliedRenderColor(null),X.toPremultipliedRenderColor(null));z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+F,h.skyboxTexture,0),x.draw(M,z.TRIANGLES,Lr.disabled,dn.disabled,Dn.unblended,rn.frontCW,oe,"skyboxCapture",h.skyboxGeometry.vertexBuffer,h.skyboxGeometry.indexBuffer,h.skyboxGeometry.segment)}const tO=i.ei([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Dv{constructor(h){const x=new i.ep;x.emplaceBack(-1,1,1,0,0),x.emplaceBack(1,1,1,1,0),x.emplaceBack(1,-1,1,1,1),x.emplaceBack(-1,-1,1,0,1);const A=new i.b0;A.emplaceBack(0,1,2),A.emplaceBack(2,3,0),this.vertexBuffer=h.createVertexBuffer(x,tO.members),this.indexBuffer=h.createIndexBuffer(A),this.segments=i.bg.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const dde=i.ei([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_fade_opacity",components:1}]);class ude{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class sO{constructor(h){this.colorModeAlphaBlendedWriteRGB=new Dn([1,Lp,1,Lp],i.ao.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Dn([1,0,1,0],i.ao.transparent,[!1,!1,!1,!0]),this.params=new ude,this.updateNeeded=!0}update(h){const x=h.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Dv(x);const A=this.params.sizeRange,D=this.params.intensityRange,F=function(oe){const ge=i.eq(30),pe=[];for(let xe=0;xe{const gt=F.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];jt&>.push("ALPHA_PASS");const mt=h.getOrCreateProgram("globeAtmosphere",{defines:gt}),Et=((Ut,ts,ns,fs,Bs,Yt,zt,ds,Jt,Es,Js,mr)=>({u_frustum_tl:Ut,u_frustum_tr:ts,u_frustum_br:ns,u_frustum_bl:fs,u_horizon:Bs,u_transition:Yt,u_fadeout_range:zt,u_atmosphere_fog_color:ds.toArray01(),u_high_color:Jt.toArray01(),u_space_color:Es.toArray01(),u_temporal_offset:Js,u_horizon_angle:mr}))(F.frustumCorners.TL,F.frustumCorners.TR,F.frustumCorners.BR,F.frustumCorners.BL,F.frustumCorners.horizon,V,Ve,oe,pe,Pe,tt,Mt);h.uploadCommonUniforms(A,mt);const Ht=this.atmosphereBuffer;Ht&&mt.draw(h,D.TRIANGLES,z,dn.disabled,jt?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,rn.backCW,Et,jt?"atmosphere_glow_alpha":"atmosphere_glow",Ht.vertexBuffer,Ht.indexBuffer,Ht.segments)};yt(!1),yt(!0)}drawStars(h,x){const A=i.aA(x.properties.get("star-intensity"),0,1);if(A===0)return;const D=h.context,F=D.gl,z=h.transform,V=h.getOrCreateProgram("stars"),X=i.c7([]);i.c9(X,X,-z._pitch),i.c8(X,X,-z.angle),i.c9(X,X,i.an(z._center.lat)),i.et(X,X,-i.an(z._center.lng));const ne=i.cc(new Float32Array(16),X),oe=i.aB([],z.starsProjMatrix,ne),ge=i.eo([],ne),pe=i.eu([],ge),xe=[0,1,0];i.dQ(xe,xe,pe),i.c5(xe,xe,this.params.sizeMultiplier);const Pe=[1,0,0];i.dQ(Pe,Pe,pe),i.c5(Pe,Pe,this.params.sizeMultiplier);const Ce=(Ve=xe,Be=Pe,tt=A,{u_matrix:Float32Array.from(oe),u_up:Ve,u_right:Be,u_intensity_multiplier:tt});var Ve,Be,tt;h.uploadCommonUniforms(D,V),this.starsVx&&this.starsIdx&&V.draw(h,F.TRIANGLES,Lr.disabled,dn.disabled,this.colorModeAlphaBlendedWriteRGB,rn.disabled,Ce,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class oC{constructor(){this.visibleTiles=[]}updateBorders(h,x){const A=[],D=[],F=h._getRenderableCoordinates(!1,!0);for(const X of F){const ne=h.getTile(X);if(!ne.hasData())continue;const oe=ne.getBucket(x);oe&&(oe.isEmpty()||(A.push(X.key),D.push({bucket:oe,tileID:X.canonical})))}let z=A.length!==this.visibleTiles.length;if(!z){A.sort();for(let X=0;XX.tileID.z-ne.tileID.z||X.tileID.x-ne.tileID.x||X.tileID.y-ne.tileID.y);for(const X of D){const ne=new Array,oe=new Array,ge=X.bucket;for(const pe of ge.featuresOnBorder)V.has(pe.featureId)?oe.push(pe.footprintIndex):(V.add(pe.featureId),ne.push(pe.footprintIndex));ge.updateFootprintHiddenFlags(ne,i.ev,!1),ge.updateFootprintHiddenFlags(oe,i.ev,!0)}}}function lC(M,h){const x=[...M],A=h.cameraWorldSizeForFog/h.worldSize,D=i.bA([]);return i.cS(D,D,[A,A,1]),i.aB(x,D,x),i.aB(x,h.worldToFogMatrix,x),x}function cC(M,h,x,A,D){const F=x.material,z=A.context,{baseColorTexture:V,metallicRoughnessTexture:X}=F.pbrMetallicRoughness,{normalTexture:ne,occlusionTexture:oe,emissionTexture:ge}=F;function pe(Pe,Ce,Ve){if(Pe&&(M.push(Ce),z.activeTexture.set(z.gl.TEXTURE0+Ve),Pe.gfxTexture)){const{minFilter:Be,magFilter:tt,wrapS:dt,wrapT:st}=Pe.sampler;Pe.gfxTexture.bindExtraParam(Be,tt,dt,st)}}pe(V,"HAS_TEXTURE_u_baseColorTexture",_c.BaseColor),pe(X,"HAS_TEXTURE_u_metallicRoughnessTexture",_c.MetallicRoughness),pe(ne,"HAS_TEXTURE_u_normalTexture",_c.Normal),pe(oe,"HAS_TEXTURE_u_occlusionTexture",_c.Occlusion),pe(ge,"HAS_TEXTURE_u_emissionTexture",_c.Emission),D&&(D.texture||(D.texture=new i.d$(A.context,D.image,[D.image.height,D.image.height,D.image.height],z.gl.RGBA8)),z.activeTexture.set(z.gl.TEXTURE0+_c.LUT),D.texture&&D.texture.bind(z.gl.LINEAR,z.gl.CLAMP_TO_EDGE),M.push("APPLY_LUT_ON_GPU")),x.texcoordBuffer&&(M.push("HAS_ATTRIBUTE_a_uv_2f"),h.push(x.texcoordBuffer)),x.colorBuffer&&(M.push(x.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),h.push(x.colorBuffer)),x.normalBuffer&&(M.push("HAS_ATTRIBUTE_a_normal_3f"),h.push(x.normalBuffer)),x.pbrBuffer&&(M.push("HAS_ATTRIBUTE_a_pbr"),M.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),h.push(x.pbrBuffer)),F.alphaMode!=="OPAQUE"&&F.alphaMode!=="MASK"||M.push("UNPREMULT_TEXTURE_IN_SHADER"),F.defined||M.push("DIFFUSE_SHADED");const xe=A.shadowRenderer;xe&&(M.push("RENDER_SHADOWS","DEPTH_TEXTURE"),xe.useNormalOffset&&M.push("NORMAL_OFFSET"))}function dC(M,h,x,A,D,F){const z=M.modelOpacity,V=h.context,X=new Lr(h.context.gl.LEQUAL,M.isLightMesh?Lr.ReadOnly:Lr.ReadWrite,h.depthRangeFor3D),ne=h.transform,oe=M.mesh,ge=oe.material,pe=ge.pbrMetallicRoughness,xe=h.style.fog;let Pe;Pe=h.transform.projection.zAxisUnit==="pixels"?[...M.nodeModelMatrix]:i.aB([],A.zScaleMatrix,M.nodeModelMatrix),i.aB(Pe,A.negCameraPosMatrix,Pe);const Ce=i.bl([],Pe);i.eg(Ce,Ce);const Ve=x.paint.get("model-color-use-theme").constantOr("default")==="none",Be=x.paint.get("model-emissive-strength").constantOr(0),tt=Oy(new Float32Array(M.worldViewProjection),new Float32Array(Pe),new Float32Array(Ce),null,h,z,pe.baseColorFactor,ge.emissiveFactor,pe.metallicFactor,pe.roughnessFactor,ge,Be,x,void 0,void 0,M.materialOverride,M.modelColor),dt={defines:[]},st=[],Mt=h.shadowRenderer;Mt&&(Mt.useNormalOffset=!1),cC(dt.defines,st,oe,h,Ve?null:x.lut);let yt=null;if(xe){const mt=lC(M.nodeModelMatrix,h.transform);if(yt=new Float32Array(mt),ne.projection.name!=="globe"){const Et=oe.aabb.min,Ht=oe.aabb.max,[Ut,ts]=xe.getOpacityForBounds(mt,Et[0],Et[1],Ht[0],Ht[1]);dt.overrideFog=Ut>=gs||ts>=gs}}const jt=cx(h,x.paint.get("model-cutoff-fade-range"));jt.shouldRenderCutoff&&dt.defines.push("RENDER_CUTOFF");const gt=h.getOrCreateProgram("model",dt);h.uploadCommonUniforms(V,gt,null,yt,jt),h.renderPass!=="shadow"&&Mt&&Mt.setupShadowsFromMatrix(M.nodeModelMatrix,gt),gt.draw(h,V.gl.TRIANGLES,X,D,F,oe.material.doubleSided?rn.disabled:rn.backCCW,tt,x.id,oe.vertexBuffer,oe.indexBuffer,oe.segments,x.paint,h.transform.zoom,void 0,st)}function Pb(M,h){return M.style._importedAsBasemap?"basemap":h.scope}function qy(M,h,x,A,D,F,z,V,X,ne){const oe=M.transform,ge=!!h.isGeometryBloom&&h.isGeometryBloom;if(ge&&M.renderPass==="shadow")return;const pe=oe.projection.name==="globe"?i.eD(x,oe):[...x];i.aB(pe,pe,h.globalMatrix);const xe=i.aB([],A,pe);if(h.meshes)for(const Pe of h.meshes){const Ce=V.get(Pe.material.name);if(Ce&&Ce.opacity<=0)continue;if(Pe.material.alphaMode!=="BLEND"){z.push({mesh:Pe,depth:0,modelIndex:D,worldViewProjection:xe,nodeModelMatrix:pe,isLightMesh:ge,materialOverride:Ce,modelOpacity:X,modelColor:ne});continue}const Ve=i.af([],Pe.centroid,xe);!oe.isOrthographic&&Ve[2]<=0||F.push({mesh:Pe,depth:Ve[2],modelIndex:D,worldViewProjection:xe,nodeModelMatrix:pe,isLightMesh:ge,materialOverride:Ce,modelOpacity:X,modelColor:ne})}if(h.children)for(const Pe of h.children)qy(M,Pe,x,A,D,F,z,V,X,ne)}function Ym(M,h,x,A){const D=x.shadowRenderer;if(!D)return;const F=D.getShadowPassDepthMode(),z=D.getShadowPassColorMode(),V=D.calculateShadowPassMatrixFromMatrix(h),X=PT(V);x.getOrCreateProgram("modelDepth",{defines:x._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(x,x.context.gl.TRIANGLES,F,dn.disabled,z,rn.disabled,X,A.id,M.vertexBuffer,M.indexBuffer,M.segments,A.paint,x.transform.zoom,void 0,void 0)}function rO(M,h,x,A,D,F){for(const z of D){const V=Object.assign({},A);V.part=z;const X={type:"Unknown",id:h,properties:V},ne={orientation:M.paint.get("model-rotation").evaluate(X,x)};F.set(z,ne)}}function nO(M,h,x,A,D,F){for(const z of D){const V=Object.assign({},A);V.part=z;const X={type:"Unknown",id:h,properties:V},ne={color:M.paint.get("model-color").evaluate(X,x),colorMix:M.paint.get("model-color-mix-intensity").evaluate(X,x),opacity:M.paint.get("model-opacity").evaluate(X,x),emissionStrength:M.paint.get("model-emissive-strength").evaluate(X,x)};F.set(z,ne)}}function aO(M,h,x,A,D){let F=!1;for(const V of A)V.modelOpacity!==1&&(dC(V,M,h,D[V.modelIndex],dn.disabled,Dn.disabled),F=!0);for(const V of A)dC(V,M,h,D[V.modelIndex],V.modelOpacity!==1?M.stencilModeFor3D():dn.disabled,M.colorModeForRenderPass());F&&M.resetStencilClippingMasks();const z=Dn.additive;for(const V of x)dC(V,M,h,D[V.modelIndex],dn.disabled,V.isLightMesh?z:M.colorModeForRenderPass())}function iO(M,h,x){const A=h.updateZoomBasedPaintProperties(),D=function(F,z,V){let X,ne,oe,ge=F.terrain?F.terrain.exaggeration():0;if(F.terrain&&ge>0){const pe=F.terrain,xe=pe.findDEMTileFor(V);xe&&xe.dem?X=i.eF.create(pe,V,xe):ge=0}if(ge===0&&(z.terrainElevationMin=0,z.terrainElevationMax=0),ge===z.validForExaggeration&&(ge===0||X&&X._demTile&&X._demTile.tileID===z.validForDEMTile.id&&X._dem._timestamp===z.validForDEMTile.timestamp))return!1;for(const pe in z.instancesPerModel){const xe=z.instancesPerModel[pe];for(let Pe=0;Pene&&(ne=xe.max)}const oe=i.aA(A.x,F,z)-A.x,ge=i.aA(A.y,V,X)-A.y,pe=i.cf(ne,h.center.lat)-A.z;return h._zoomFromMercatorZ(Math.sqrt(oe*oe+ge*ge+pe*pe))}function oO(M,h,x,A,D,F,z){const V=M.context,X=M.renderPass==="shadow",ne=M.shadowRenderer,oe=X&&ne?ne.getShadowPassDepthMode():new Lr(V.gl.LEQUAL,Lr.ReadWrite,M.depthRangeFor3D),ge=M.isTileAffectedByFog(F),pe=M.transform.projection.name==="globe";if(x.meshes)for(const xe of x.meshes){const Pe=pe?[]:["MODEL_POSITION_ON_GPU"],Ce=[];let Ve,Be,tt;const dt=!pe&&A.instancedDataArray.length>20;dt&&Pe.push("INSTANCED_ARRAYS");const st=cx(M,h.paint.get("model-cutoff-fade-range"));if(st.shouldRenderCutoff&&Pe.push("RENDER_CUTOFF"),X&&ne)Ve=M.getOrCreateProgram("modelDepth",{defines:Pe}),Be=PT(z.shadowTileMatrix,z.shadowTileMatrix,Float32Array.from(x.globalMatrix)),tt=ne.getShadowPassColorMode();else{cC(Pe,Ce,xe,M,h.paint.get("model-color-use-theme").constantOr("default")==="none"?null:h.lut),Ve=M.getOrCreateProgram("model",{defines:Pe,overrideFog:ge});const yt=xe.material,jt=yt.pbrMetallicRoughness,gt=h.paint.get("model-opacity").constantOr(1),mt=h.paint.get("model-emissive-strength").constantOr(0);Be=Oy(F.expandedProjMatrix,Float32Array.from(x.globalMatrix),new Float32Array(16),null,M,gt,jt.baseColorFactor,yt.emissiveFactor,jt.metallicFactor,jt.roughnessFactor,yt,mt,h,D),ne&&(z.shadowUniformsInitialized?Ve.setShadowUniformValues(V,ne.getShadowUniformValues()):(ne.setupShadows(F.toUnwrapped(),Ve,"model-tile"),z.shadowUniformsInitialized=!0)),tt=st.shouldRenderCutoff||gt<1||yt.alphaMode!=="OPAQUE"?Dn.alphaBlended:Dn.unblended}M.uploadCommonUniforms(V,Ve,F.toUnwrapped(),null,st);const Mt=xe.material.doubleSided?rn.disabled:rn.backCCW;if(dt)Ce.push(A.instancedDataBuffer),Ve.draw(M,V.gl.TRIANGLES,oe,dn.disabled,tt,Mt,Be,h.id,xe.vertexBuffer,xe.indexBuffer,xe.segments,h.paint,M.transform.zoom,void 0,Ce,A.instancedDataArray.length);else{const yt=X?"u_instance":"u_normal_matrix";for(let jt=0;jtX[1]?z:X,F[0]=x.max[0],z=i.aC(i.eG(),F,D),V=z[1]X[1]?z:X,F[1]=x.min[1],z=i.aC(i.eG(),F,D),V=z[1]X[1]?z:X;const ne=i.aA(A[0],0,1),oe=100*h.pixelsPerMeter*i.aA(A[1],0,1),ge=i.aA(A[2],0,1),pe=i.eH(i.eG(),V,X,ne),xe=Math.tan(.5*h.fovX),Pe=-pe[2]*xe;if(oe===0)return pe[1]<-Math.abs(Pe)?ge:1;const Ce=(-Math.abs(Pe)-pe[1])/oe,Ve=(tt,dt,st)=>(1-st)*tt+st*dt,Be=i.aA(Ve(1,ge,Ce),ge,1);return Ve(1,Be,i.aA((h.pitch-20)/20,0,1))}class lO{}class vx{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(h,x,A){{const ge=this._storage.get(x.id);if(ge)return ge.lastUsedFrameIdx=h,ge.buf}const D=A.gl,F=D.getBufferParameter(D.ELEMENT_ARRAY_BUFFER,D.BUFFER_SIZE),z=new ArrayBuffer(F),V=new Int16Array(z);D.getBufferSubData(D.ELEMENT_ARRAY_BUFFER,0,new Int16Array(z));const X=new i.eJ;for(let ge=0;ge30&&(A.buf.destroy(),this._storage.delete(x))}destroy(){for(const[h,x]of this._storage)x.buf.destroy(),this._storage.delete(h)}}class Ov{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const Rv=i.ei([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]);class Qf{constructor(h){this.revealStart=11,this.revealRange=2}}const FT=i.ei([{type:"Float32",name:"a_pos_2f",components:2}]);class zT{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(h,x){const A=h.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const z=new i.eK,V=new i.b0;z.emplaceBack(-1,-1),z.emplaceBack(1,-1),z.emplaceBack(1,1),z.emplaceBack(-1,1),V.emplaceBack(0,1,2),V.emplaceBack(0,2,3),this.vignetteVx=h.context.createVertexBuffer(z,FT.members),this.vignetteIdx=h.context.createIndexBuffer(V)}const D=i.bg.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){h.uploadCommonUniforms(h.context,A);const z={u_vignetteShape:(F={vignetteShape:[x.start,x.range,Math.pow(10,x.fadePower)],vignetteColor:[x.color.r,x.color.g,x.color.b,x.color.a*x.strength]}).vignetteShape,u_vignetteColor:F.vignetteColor};A.draw(h,h.context.gl.TRIANGLES,Lr.disabled,dn.disabled,Dn.alphaBlended,rn.disabled,z,"vignette",this.vignetteVx,this.vignetteIdx,D)}var F}}class BT{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(h,x){const A=h.getFreeCameraOptions().position,D=A.toAltitude(),F=A.toLngLat(),z=i.an(F.lng),V=i.an(F.lat),X=h.pixelsPerMeter/x,ne=z*i.eM,oe=i.eM*Math.log(Math.tan(Math.PI/4+V/2));if(this._offsetXPrev===void 0)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{const ge=-this._offsetYPrev+oe,pe=-this._elevationPrev+D;this._accumulatedOffsetX+=(-this._offsetXPrev+ne)*X,this._accumulatedOffsetY+=ge*X,this._accumulatedElevation+=pe*X,this._offsetXPrev=ne,this._offsetYPrev=oe,this._elevationPrev=D}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function uC(M,h){return[-(M[0]-Math.floor(M[0]/h)*h),-(M[1]-Math.floor(M[1]/h)*h),-(M[2]-Math.floor(M[2]/h)*h)]}function bh(M){const h=i.eq(1323123451230),x=[];for(let A=0;A Rain"),this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3}update(h){const x=h.context;if(!this.particlesVx){const A=bh(this.particlesCount),D=new i.eN,F=new i.b0;let z=0;const V=i.eq(1323123451230);for(let X=0;XA)return;const D=Su(0,1,x.revealStart,x.revealStart+x.revealRange,A);if(!this.particlesVx||!this.particlesIdx)return;const F=structuredClone(this._params);let z=[-F.direction.x,F.direction.y,-100];i.aw(z,z);const V=structuredClone(this._vignetteParams);V.strength*=D,F.overrideStyleParameters||(F.intensity=h.style.rain.state.density,F.timeFactor=h.style.rain.state.intensity,F.color=structuredClone(h.style.rain.state.color),z=structuredClone(h.style.rain.state.direction),F.screenThinning.intensity=h.style.rain.state.centerThinning,F.dropletSizeX=h.style.rain.state.dropletSize[0],F.dropletSizeYScale=h.style.rain.state.dropletSize[1]/h.style.rain.state.dropletSize[0],F.distortionStrength=100*h.style.rain.state.distortionStrength,V.strength=1,V.color=structuredClone(h.style.rain.state.vignetteColor));const X=this.updateOnRender(h,F.timeFactor),ne=h.context,oe=ne.gl,ge=h.transform;this.screenTexture&&this.screenTexture.size[0]===h.width&&this.screenTexture.size[1]===h.height||(this.screenTexture=new i.T(ne,{width:h.width,height:h.height,data:null},oe.RGBA8)),F.distortionStrength>0&&(ne.activeTexture.set(oe.TEXTURE0),this.screenTexture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE),oe.copyTexSubImage2D(oe.TEXTURE_2D,0,0,0,0,0,h.width,h.height));const pe=h.getOrCreateProgram("rainParticle");h.uploadCommonUniforms(ne,pe),ne.activeTexture.set(oe.TEXTURE0),this.screenTexture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE);const xe=[F.color.r,F.color.g,F.color.b,F.color.a],Pe=(Ce,Ve)=>{const Be=uC(this._movement.getPosition(),Ce),tt=F.dropletSizeX,dt=F.dropletSizeX*F.dropletSizeYScale,st=h.width/2,Mt=h.height/2,yt=Su(0,F.screenThinning.start,0,1,F.screenThinning.intensity),jt=Su(.001,F.screenThinning.range,0,1,F.screenThinning.intensity),gt=Su(0,F.screenThinning.particleOffset,0,1,F.screenThinning.intensity),mt=(Et={modelview:X.modelviewMatrix,projection:X.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Be,velocityConeAperture:F.velocityConeAperture,velocity:F.velocity,boxSize:Ce,rainDropletSize:[tt,dt],distortionStrength:F.distortionStrength,rainDirection:z,color:xe,screenSize:[ge.width,ge.height],thinningCenterPos:[st,Mt],thinningShape:[yt,jt,Math.pow(10,F.screenThinning.fadePower)],thinningAffectedRatio:F.screenThinning.affectedRatio,thinningParticleOffset:gt,shapeDirectionalPower:F.shapeDirPower,shapeNormalPower:F.shapeNormalPower,mode:Ve?0:1},{u_modelview:Float32Array.from(Et.modelview),u_projection:Float32Array.from(Et.projection),u_time:Et.time,u_cam_pos:Et.camPos,u_texScreen:0,u_velocityConeAperture:Et.velocityConeAperture,u_velocity:Et.velocity,u_boxSize:Et.boxSize,u_rainDropletSize:Et.rainDropletSize,u_distortionStrength:Et.distortionStrength,u_rainDirection:Et.rainDirection,u_color:Et.color,u_screenSize:Et.screenSize,u_thinningCenterPos:Et.thinningCenterPos,u_thinningShape:Et.thinningShape,u_thinningAffectedRatio:Et.thinningAffectedRatio,u_thinningParticleOffset:Et.thinningParticleOffset,u_shapeDirectionalPower:Et.shapeDirectionalPower,u_shapeNormalPower:Et.shapeNormalPower,u_mode:Et.mode});var Et;const Ht=Math.round(F.intensity*this.particlesCount),Ut=i.bg.simpleSegment(0,0,4*Ht,2*Ht);pe.draw(h,oe.TRIANGLES,Lr.disabled,dn.disabled,Dn.alphaBlended,rn.disabled,mt,"rain_particles",this.particlesVx,this.particlesIdx,Ut)};F.distortionStrength>0&&Pe(F.boxSize,!0),Pe(F.boxSize,!1),this._vignette.draw(h,V)}}const $T=i.ei([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_snowParticleData",components:4},{type:"Float32",name:"a_snowParticleDataHorizontalOscillation",components:2}]);class qT extends Uy{constructor(h){super(2.25),this._params={overrideStyleParameters:!1,intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._revealParams=new Qf("Precipitation > Snow"),this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3}update(h){const x=h.context;if(!this.particlesVx){const A=bh(this.particlesCount),D=new i.eO,F=new i.b0;let z=0;const V=i.eq(1323123451230);for(let X=0;Xz)return;const V=Su(0,1,F.revealStart,F.revealStart+F.revealRange,z);D.strength*=V,x.overrideStyleParameters||(x.intensity=h.style.snow.state.density,x.timeFactor=h.style.snow.state.intensity,x.color=structuredClone(h.style.snow.state.color),A=structuredClone(h.style.snow.state.direction),x.screenThinning.intensity=h.style.snow.state.centerThinning,x.billboardSize=2.79*h.style.snow.state.flakeSize,D.strength=1,D.color=structuredClone(h.style.snow.state.vignetteColor));const X=this.updateOnRender(h,x.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const ne=h.context,oe=ne.gl,ge=h.transform,pe=h.getOrCreateProgram("snowParticle");h.uploadCommonUniforms(ne,pe),((xe,Pe,Ce)=>{const Ve=uC(this._movement.getPosition(),xe),Be=ge.width/2,tt=ge.height/2,dt=Su(0,Ce.screenThinning.start,0,1,Ce.screenThinning.intensity),st=Su(.001,Ce.screenThinning.range,0,1,Ce.screenThinning.intensity),Mt=Su(0,Ce.screenThinning.particleOffset,0,1,Ce.screenThinning.intensity),yt=(jt={modelview:X.modelviewMatrix,projection:X.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Ve,velocityConeAperture:Ce.velocityConeAperture,velocity:Ce.velocity,horizontalOscillationRadius:Ce.horizontalOscillationRadius,horizontalOscillationRate:Ce.horizontalOscillationRate,boxSize:xe,billboardSize:1*Ce.billboardSize,simpleShapeParameters:[Ce.shapeFadeStart,Ce.shapeFadePower],screenSize:[ge.width,ge.height],thinningCenterPos:[Be,tt],thinningShape:[dt,st,Math.pow(10,Ce.screenThinning.fadePower)],thinningAffectedRatio:Ce.screenThinning.affectedRatio,thinningParticleOffset:Mt,color:[Ce.color.r,Ce.color.g,Ce.color.b,Ce.color.a],direction:A},{u_modelview:Float32Array.from(jt.modelview),u_projection:Float32Array.from(jt.projection),u_time:jt.time,u_cam_pos:jt.camPos,u_velocityConeAperture:jt.velocityConeAperture,u_velocity:jt.velocity,u_horizontalOscillationRadius:jt.horizontalOscillationRadius,u_horizontalOscillationRate:jt.horizontalOscillationRate,u_boxSize:jt.boxSize,u_billboardSize:jt.billboardSize,u_simpleShapeParameters:jt.simpleShapeParameters,u_screenSize:jt.screenSize,u_thinningCenterPos:jt.thinningCenterPos,u_thinningShape:jt.thinningShape,u_thinningAffectedRatio:jt.thinningAffectedRatio,u_thinningParticleOffset:jt.thinningParticleOffset,u_particleColor:jt.color,u_direction:jt.direction});var jt;const gt=Math.round(Ce.intensity*this.particlesCount),mt=i.bg.simpleSegment(0,0,4*gt,2*gt);this.particlesVx&&this.particlesIdx&&pe.draw(h,oe.TRIANGLES,Lr.disabled,dn.disabled,Dn.alphaBlended,rn.disabled,yt,"snow_particles",this.particlesVx,this.particlesIdx,mt)})(x.boxSize,0,x),this._vignette.draw(h,D)}}const _x={symbol:function(M,h,x,A,D){if(M.renderPass!=="translucent")return;const F=dn.disabled,z=M.colorModeForRenderPass(),V=x.layout.get("text-variable-anchor"),X=x.layout.get("text-size-scale-range"),ne=i.aA(M.scaleFactor,X[0],X[1]);V&&function(pe,xe,Pe,Ce,Ve,Be,tt,dt){const st=xe.transform,Mt=Ve==="map",yt=Be==="map";for(const jt of pe){const gt=Ce.getTile(jt),mt=gt.getBucket(Pe);if(!mt||!mt.text||!mt.text.segments.get().length)continue;const Et=i.bK(mt.textSizeData,st.zoom,dt),Ht=am(jt,mt.getProjection(),st),Ut=st.calculatePixelsToTileUnitsMatrix(gt),ts=Ks(Ht,gt.tileID.canonical,yt,Mt,st,mt.getProjection(),Ut),ns=mt.hasIconTextFit()&&mt.hasIconData();Et&&Zr(mt,Mt,yt,tt,st,ts,jt,Math.pow(2,st.zoom-gt.tileID.overscaledZ),Et,ns)}}(A,M,x,h,x.layout.get("text-rotation-alignment"),x.layout.get("text-pitch-alignment"),D,ne);const oe=x.paint.get("icon-opacity").constantOr(1)!==0,ge=x.paint.get("text-opacity").constantOr(1)!==0;x.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(oe||ge)?Tb(M,h,x,A,F,z):(oe&&Tb(M,h,x,A,F,z,{onlyIcons:!0}),ge&&Tb(M,h,x,A,F,z,{onlyText:!0})),h.map.showCollisionBoxes&&(_r(M,h,x,A,x.paint.get("text-translate"),x.paint.get("text-translate-anchor"),!0),_r(M,h,x,A,x.paint.get("icon-translate"),x.paint.get("icon-translate-anchor"),!1))},circle:function(M,h,x,A){if(M.renderPass!=="translucent")return;const D=x.paint.get("circle-opacity"),F=x.paint.get("circle-stroke-width"),z=x.paint.get("circle-stroke-opacity"),V=x.layout.get("circle-sort-key").constantOr(1)!==void 0,X=x.paint.get("circle-emissive-strength");if(D.constantOr(1)===0&&(F.constantOr(1)===0||z.constantOr(1)===0))return;const ne=M.context,oe=ne.gl,ge=M.transform,pe=!(!M.terrain||!M.terrain.enabled),xe=x.layout.get("circle-elevation-reference"),Pe=M.depthModeForSublayer(0,Lr.ReadOnly),Ce=new Lr(M.context.gl.LEQUAL,Lr.ReadOnly,M.depthRangeFor3D),Ve=xe==="none"||pe?Pe:Ce,Be=dn.disabled,tt=M.colorModeForDrapableLayerRenderPass(X),dt=ge.projection.name==="globe",st=[i.aF(ge.center.lng),i.aJ(ge.center.lat)],Mt=[];for(let jt=0;jtjt.sortKey-gt.sortKey);const yt={useDepthForOcclusion:ge.depthOcclusionForSymbolsAndCircles};for(const jt of Mt){const{programConfiguration:gt,program:mt,layoutVertexBuffer:Et,dynamicBuffers:Ht,indexBuffer:Ut,uniformValues:ts,tile:ns}=jt.state,fs=jt.segments;M.terrain&&M.terrain.setupElevationDraw(ns,mt,yt),M.uploadCommonUniforms(ne,mt,ns.tileID.toUnwrapped()),mt.draw(M,oe.TRIANGLES,Ve,Be,tt,rn.disabled,ts,x.id,Et,Ut,fs,x.paint,ge.zoom,gt,Ht)}},heatmap:function(M,h,x,A){if(x.paint.get("heatmap-opacity")!==0)if(M.renderPass==="offscreen"){const D=M.context,F=D.gl,z=dn.disabled,V=new Dn([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!0,!0,!0,!0]);(function(xe,Pe,Ce,Ve){const Be=xe.gl,tt=Pe.width*Ve,dt=Pe.height*Ve;xe.activeTexture.set(Be.TEXTURE1),xe.viewport.set([0,0,tt,dt]);let st=Ce.heatmapFbo;if(!st||st&&(st.width!==tt||st.height!==dt)){st&&st.destroy();const Mt=Be.createTexture();Be.bindTexture(Be.TEXTURE_2D,Mt),Be.texParameteri(Be.TEXTURE_2D,Be.TEXTURE_WRAP_S,Be.CLAMP_TO_EDGE),Be.texParameteri(Be.TEXTURE_2D,Be.TEXTURE_WRAP_T,Be.CLAMP_TO_EDGE),Be.texParameteri(Be.TEXTURE_2D,Be.TEXTURE_MIN_FILTER,Be.LINEAR),Be.texParameteri(Be.TEXTURE_2D,Be.TEXTURE_MAG_FILTER,Be.LINEAR),st=Ce.heatmapFbo=xe.createFramebuffer(tt,dt,1,null),function(yt,jt,gt,mt,Et,Ht){const Ut=yt.gl;Ut.texImage2D(Ut.TEXTURE_2D,0,yt.extRenderToTextureHalfFloat?Ut.RGBA16F:Ut.RGBA,Et,Ht,0,Ut.RGBA,yt.extRenderToTextureHalfFloat?Ut.HALF_FLOAT:Ut.UNSIGNED_BYTE,null),mt.colorAttachment0.set(gt)}(xe,0,Mt,st,tt,dt)}else Be.bindTexture(Be.TEXTURE_2D,st.colorAttachment0.get()),xe.bindFramebuffer.set(st.framebuffer)})(D,M,x,M.transform.projection.name==="globe"?.5:.25),D.clear({color:i.ao.transparent});const X=M.transform,ne=X.projection.name==="globe",oe=ne?["PROJECTION_GLOBE_VIEW"]:[],ge=ne?rn.frontCCW:rn.disabled,pe=[i.aF(X.center.lng),i.aJ(X.center.lat)];for(let xe=0;xe({u_image:0,u_color_ramp:1,u_opacity:ge.paint.get("heatmap-opacity")}))(0,F),F.id,D.viewportBuffer,D.quadTriangleIndexBuffer,D.viewportSegments,F.paint,D.transform.zoom)}(M,x))},line:function(M,h,x,A){if(M.renderPass!=="translucent")return;const D=x.paint.get("line-opacity"),F=x.paint.get("line-width");if(D.constantOr(1)===0||F.constantOr(1)===0)return;const z=x.paint.get("line-emissive-strength").isConstant(),V=x.paint.get("line-emissive-strength").constantOr(0),X=x.paint.get("line-occlusion-opacity"),ne=x.layout.get("line-elevation-reference"),oe=x.layout.get("line-width-unit")==="meters",ge=ne==="sea",pe=!(!M.terrain||!M.terrain.enabled),xe=M.context,Pe=xe.gl;if(x.hasElevatedBuckets&&M.transform.projection.name==="globe")return;const Ce=x.layout.get("line-cross-slope"),Ve=Ce!==void 0,Be=Ce<1,tt=M.colorModeForDrapableLayerRenderPass(z?V:null),dt=M.terrain&&M.terrain.renderingToTexture,st=dt?1:i.o.devicePixelRatio,Mt=x.paint.get("line-dasharray"),yt=Mt.constantOr(1),jt=x.layout.get("line-cap"),gt=Mt.constantOr(null),mt=jt.constantOr(null),Et=x.paint.get("line-pattern"),Ht=Et.constantOr(1),Ut=x.paint.get("line-pattern-cross-fade"),ts=Et.constantOr(null),ns=x.paint.get("line-opacity").constantOr(1);let fs=!Ht&&ns!==1||M.depthOcclusion&&X>0&&X<1;const Bs=x.paint.get("line-gradient"),Yt=Ht?"linePattern":"line",zt=i.e2(x);let ds;if(dt&&M.terrain&&M.terrain.clipOrMaskOverlapStencilType()&&(fs=!1),X!==0&&M.depthOcclusion){const mr=x.paint._values["line-opacity"];mr&&mr.value&&mr.value.kind==="constant"?ds=mr.value:i.w(`Occlusion opacity for layer ${x.id} is supported only when line-opacity isn't data-driven.`)}F.value.kind!=="constant"&&F.value.isLineProgressConstant===!1&&zt.push("VARIABLE_LINE_WIDTH"),dt&&(M.emissiveMode!=="dual-source-blending"||z?M.emissiveMode==="mrt-fallback"&&zt.push("USE_MRT1"):zt.push("DUAL_SOURCE_BLENDING"));const Jt=(mr,Ys,Us,Cr,Nr,cr)=>{for(const xr of mr){const Vr=h.getTile(xr);if(Ht&&!Vr.patternsLoaded())continue;const jn=Vr.getBucket(x);if(!jn||jn.elevationType!=="none"&&!Nr||jn.elevationType==="none"&&Nr)continue;M.prepareDrawTile();const pa=[...Ys],Ha=M.shadowRenderer,Er=jn.elevationType==="road"&&!!Ha&&Ha.enabled;let Fa=[0,0,0];if(Er){const Fn=M.style.directionalLight,qi=M.style.ambientLight;Fn&&qi&&(Fa=Wf(M.style,Fn,qi)),pa.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const vn=jn.programConfigurations.get(x.id);let Xa=!1;if(ts&&Vr.imageAtlas){const Fn=i.e3.from(ts),qi=Fn.getPrimary().scaleSelf(st).toString(),Ao=Vr.imageAtlas.patternPositions.get(qi),uo=Fn.getSecondary(),ji=uo?Vr.imageAtlas.patternPositions.get(uo.scaleSelf(st).toString()):null;Xa=!!Ao&&!!ji,Ao&&vn.setConstantPatternPositions(Ao,ji)}Ut>0&&(Xa||vn.getPatternTransitionVertexBuffer("line-pattern"))&&pa.push("LINE_PATTERN_TRANSITION");const fi=M.isTileAffectedByFog(xr),oi=M.getOrCreateProgram(Yt,{config:vn,defines:pa,overrideFog:fi});if(!Ht&>&&mt&&Vr.lineAtlas){const Fn=Vr.lineAtlas.getDash(gt,mt);Fn&&vn.setConstantPatternPositions(Fn)}Er&&Ha.setupShadows(Vr.tileID.toUnwrapped(),oi,"vector-tile");let[Oa,Rn]=x.paint.get("line-trim-offset");(mt==="round"||mt==="square")&&Oa!==Rn&&(Oa===0&&(Oa-=1),Rn===1&&(Rn+=1));const Ka=dt?xr.projMatrix:null,fo=oe?1/jn.tileToMeter/i.ay(Vr,1,M.transform.zoom):1,Gi=oe?1/jn.tileToMeter/i.ay(Vr,1,Math.floor(M.transform.zoom)):1,Qa=Ht?i.e4(M,Vr,x,Ka,st,fo,Gi,[Oa,Rn],Fa,Ut):i.e5(M,Vr,x,Ka,jn.lineClipsArray.length,st,fo,Gi,[Oa,Rn],Fa);if(Bs){const Fn=jn.gradients[x.id];let qi=Fn.texture;if(x.gradientVersion!==Fn.version){let Ao=256;if(x.stepInterpolant){const uo=h.getSource().maxzoom,ji=xr.canonical.z===uo?Math.ceil(1<{ds!=null&&(ds.value=ns*X),oi.draw(M,Pe.TRIANGLES,Us,Fn,tt,rn.disabled,Qa,x.id,jn.layoutVertexBuffer,jn.indexBuffer,jn.segments,x.paint,M.transform.zoom,vn,[jn.layoutVertexBuffer2,jn.patternVertexBuffer,jn.zOffsetVertexBuffer]),ds!=null&&(ds.value=ns)};if(fs&&!Nr){const Fn=M.stencilModeForClipping(xr).ref;Fn===0&&dt&&xe.clear({stencil:0});const qi={func:Pe.EQUAL,mask:255};Qa.u_alpha_discard_threshold=.8,Ca(new dn(qi,Fn,255,Pe.KEEP,Pe.KEEP,Pe.INVERT)),Qa.u_alpha_discard_threshold=0,Ca(new dn(qi,Fn,255,Pe.KEEP,Pe.KEEP,Pe.KEEP))}else Qa.u_alpha_discard_threshold=fs&&Nr&&cr?.8:0,Ca(Nr?Cr:M.stencilModeForClipping(xr))}};let Es=M.depthModeForSublayer(0,Lr.ReadOnly);const Js=new Lr(M.depthOcclusion?Pe.GREATER:Pe.LEQUAL,Lr.ReadOnly,M.depthRangeFor3D);if(x.hasNonElevatedBuckets){const mr=!dt&&M.terrain;X!==0&&mr?i.w(`Occlusion opacity for layer ${x.id} is supported on terrain only if the layer has line-z-offset enabled.`):mr?i.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${x.id}.`):Jt(A,zt,Es,dn.disabled,!1,!0)}if(x.hasElevatedBuckets){ne==="hd-road-markup"?pe||(Es=Js,zt.push("ELEVATED_ROADS")):(zt.push("ELEVATED"),Es=Js,Ve&&zt.push(Be?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),ge&&zt.push("ELEVATION_REFERENCE_SEA"));const mr=fs?M.stencilModeFor3D():dn.disabled;M.forceTerrainMode=!0,Jt(A,zt,Es,mr,!0,!0),fs&&Jt(A,zt,Es,mr,!0,!1),M.forceTerrainMode=!1}fs&&(M.resetStencilClippingMasks(),dt&&xe.clear({stencil:0})),X===0||M.depthOcclusion||dt||M.layersWithOcclusionOpacity.push(M.currentLayer)},fill:function(M,h,x,A){const D=x.paint.get("fill-color"),F=x.paint.get("fill-opacity");if(F.constantOr(1)===0)return;const z=x.paint.get("fill-emissive-strength"),V=M.colorModeForDrapableLayerRenderPass(z),X=x.paint.get("fill-pattern"),ne=M.opaquePassEnabledForLayer()&&!X.constantOr(1)&&D.constantOr(i.ao.transparent).a===1&&F.constantOr(0)===1?"opaque":"translucent";let oe="none";x.layout.get("fill-elevation-reference")!=="none"?oe="road":x.paint.get("fill-z-offset").constantOr(1)!==0&&(oe="offset");const ge=!(!M.terrain||!M.terrain.enabled),pe={painter:M,sourceCache:h,layer:x,coords:A,colorMode:V,elevationType:oe,terrainEnabled:ge,pass:ne};if(M.renderPass==="shadow")return void(M.shadowRenderer&&oe==="road"&&!ge&&function(Pe){const{painter:Ce,sourceCache:Ve,layer:Be,coords:tt}=Pe,dt=Ce.context.gl,st=Pe.painter.shadowRenderer;for(const Mt of tt){const yt=Ve.getTile(Mt),jt=yt.getBucket(Be);if(!jt)continue;const gt=jt.elevatedStructures;if(!gt||!gt.shadowCasterSegments||gt.shadowCasterSegments.segments[0].primitiveLength===0)continue;Ce.prepareDrawTile();const mt=jt.bufferData.programConfigurations.get(Be.id),Et=Ce.isTileAffectedByFog(Mt),Ht=Ce.getOrCreateProgram("elevatedStructuresDepth",{config:mt,overrideFog:Et}),Ut=st.calculateShadowPassMatrixFromTile(yt.tileID.toUnwrapped());Ce.uploadCommonUniforms(Ce.context,Ht,Mt.toUnwrapped());const ts={u_matrix:Ut,u_depth_bias:0};Ht.draw(Ce,dt.TRIANGLES,st.getShadowPassDepthMode(),dn.disabled,st.getShadowPassColorMode(),rn.disabled,ts,Be.id,gt.vertexBuffer,gt.indexBuffer,gt.shadowCasterSegments,Be.paint,Ce.transform.zoom,mt)}}(pe));const xe=M.emissiveMode==="mrt-fallback";if(oe!=="offset"){if(eC(pe,!1,xe),oe==="road"){const Pe=!ge&&M.renderPass==="translucent";Pe&&JS(M,h,x,A,"geometry"),eC(pe,!0,xe,dn.disabled),Pe&&function(Ce){const{painter:Ve,sourceCache:Be,layer:tt,coords:dt,colorMode:st}=Ce,Mt=Ve.context.gl,yt=Ce.painter.shadowRenderer,jt=!!yt&&yt.enabled,gt=new Lr(Ve.context.gl.LEQUAL,Lr.ReadOnly,Ve.depthRangeFor3D);let mt=[0,0,0];if(jt){const Ht=Ve.style.directionalLight,Ut=Ve.style.ambientLight;Ht&&Ut&&(mt=Wf(Ve.style,Ht,Ut))}const Et=Ht=>{for(const Ut of dt){const ts=Be.getTile(Ut),ns=ts.getBucket(tt);if(!ns)continue;const fs=ns.elevatedStructures;if(!fs)continue;let Bs,Yt;if(Ht?(Bs=fs.renderableBridgeSegments,Yt=fs.bridgeProgramConfigurations.get(tt.id)):(Bs=fs.renderableTunnelSegments,Yt=fs.tunnelProgramConfigurations.get(tt.id)),!Bs||Bs.segments[0].primitiveLength===0)continue;Yt.updatePaintBuffers(),Ve.prepareDrawTile();const zt=Ve.isTileAffectedByFog(Ut),ds=[];jt&&ds.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const Jt=Ve.getOrCreateProgram("elevatedStructures",{config:Yt,overrideFog:zt,defines:ds}),Es=Ve.translatePosMatrix(Ut.projMatrix,ts,tt.paint.get("fill-translate"),tt.paint.get("fill-translate-anchor"));jt&&yt.setupShadows(ts.tileID.toUnwrapped(),Jt,"vector-tile");const Js=fx(Es,mt);Ve.uploadCommonUniforms(Ve.context,Jt,Ut.toUnwrapped()),Jt.draw(Ve,Mt.TRIANGLES,gt,dn.disabled,st,rn.backCCW,Js,tt.id,fs.vertexBuffer,fs.indexBuffer,Bs,tt.paint,Ve.transform.zoom,Yt,[fs.vertexBufferNormal])}};Et(!0),Et(!1)}(pe)}}else eC(pe,!1,xe,M.stencilModeFor3D())},"fill-extrusion":function(M,h,x,A){const D=x.paint.get("fill-extrusion-opacity"),F=M.context,z=F.gl,V=M.terrain,X=V&&V.renderingToTexture;if(D===0)return;const ne=M.emissiveMode==="mrt-fallback",oe=M.conflationActive&&M.style.isLayerClipped(x,h.getSource()),ge=M.style.order.indexOf(x.fqid);if(oe&&function(pe,xe,Pe,Ce,Ve){for(const Be of Ce){const tt=xe.getTile(Be).getBucket(Pe);tt&&(tt.updateReplacement(Be,pe.replacementSource,Ve),tt.uploadCentroid(pe.context))}}(M,h,x,A,ge),V||oe)for(const pe of A){const xe=h.getTile(pe).getBucket(x);xe&&cde(M.context,h,pe,xe,x,V,oe)}if(M.renderPass==="shadow"&&M.shadowRenderer){const pe=M.shadowRenderer;if(V&&D<.65&&x._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof i.ad)return;const xe=pe.getShadowPassDepthMode(),Pe=pe.getShadowPassColorMode();tC(M,h,x,A,xe,dn.disabled,Pe,oe)}else if(M.renderPass==="translucent"){const pe=!x.paint.get("fill-extrusion-pattern").constantOr(1),xe=x.paint.get("fill-extrusion-color").constantOr(i.ao.white);if(!X&&xe.a!==0){const Pe=new Lr(M.context.gl.LEQUAL,Lr.ReadWrite,M.depthRangeFor3D);D===1&&pe?tC(M,h,x,A,Pe,dn.disabled,Dn.unblended,oe):(tC(M,h,x,A,Pe,dn.disabled,Dn.disabled,oe),tC(M,h,x,A,Pe,M.stencilModeFor3D(),M.colorModeForRenderPass(),oe),M.resetStencilClippingMasks())}if(M.style.enable3dLights()&&pe&&(!V&&M.transform.projection.name!=="globe"||X)){const Pe=x.paint.get("fill-extrusion-opacity"),Ce=x.paint.get("fill-extrusion-ambient-occlusion-intensity"),Ve=x.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),Be=x.paint.get("fill-extrusion-flood-light-intensity"),tt=x.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",dt=x.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(tt?null:x.lut).toArray01().slice(0,3),st=Ce>0&&Ve>0,Mt=Be>0,yt=(mt,Et,Ht)=>(1-Ht)*mt+Ht*Et,jt=new DT;jt.translate=x.paint.get("fill-extrusion-translate"),jt.translateAnchor=x.paint.get("fill-extrusion-translate-anchor"),jt.edgeRadius=x.layout.get("fill-extrusion-edge-radius"),jt.cutoffFadeRange=x.paint.get("fill-extrusion-cutoff-fade-range");const gt=mt=>{const Et=M.depthModeForSublayer(1,Lr.ReadOnly,z.LEQUAL,!0),Ht=x.paint.get(mt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Ut=yt(.1,3,Ht),ts=M._showOverdrawInspector;if(!ts){const ns=new dn({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),fs=new Dn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);Zf(jt,M,h,x,A,Et,ns,fs,rn.disabled,mt,"sdf",Pe,Ce,Ve,Be,dt,Ut,oe,!1)}{const ns=ts?dn.disabled:new dn({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),fs=ts?M.colorModeForRenderPass():new Dn([z.ONE_MINUS_DST_ALPHA,z.DST_ALPHA,z.ONE,z.ONE],i.ao.transparent,[!0,!0,!0,!0]);Zf(jt,M,h,x,A,Et,ns,fs,rn.disabled,mt,"color",Pe,Ce,Ve,Be,dt,Ut,oe,!1)}};if(X){const mt=()=>{const Ht=V.drapeBufferSize[0],Ut=V.drapeBufferSize[1];let ts=V.framebufferCopyTexture;return ts&&(!ts||ts.size[0]===Ht&&ts.size[1]===Ut)||(ts&&ts.destroy(),ts=V.framebufferCopyTexture=new i.T(F,new i.q({width:Ht,height:Ut}),z.RGBA8)),ts.bind(z.LINEAR,z.CLAMP_TO_EDGE),z.copyTexSubImage2D(z.TEXTURE_2D,0,0,0,0,0,Ht,Ut),ts},Et=(Ht,Ut,ts)=>{const ns=M.depthModeForSublayer(1,Lr.ReadOnly,z.LEQUAL,!1),fs=x.paint.get(Ht?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Bs=yt(.1,3,fs);{const Yt=new Dn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0]);Zf(jt,M,h,x,A,ns,dn.disabled,Yt,rn.disabled,Ht,"clear",Pe,Ce,Ve,Be,dt,Bs,oe,Ut)}{const Yt=new dn({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),zt=new Dn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);Zf(jt,M,h,x,A,ns,Yt,zt,rn.disabled,Ht,"sdf",Pe,Ce,Ve,Be,dt,Bs,oe,Ut)}ne&&!Ht&&(ts=mt());{const Yt=Ht?z.ZERO:z.ONE_MINUS_DST_ALPHA,zt=new dn({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),ds=new Dn([Yt,z.DST_ALPHA,z.ONE_MINUS_DST_ALPHA,z.ZERO],i.ao.transparent,[!0,!0,!0,!0]);Zf(jt,M,h,x,A,ns,zt,ds,rn.disabled,Ht,"color",Pe,Ce,Ve,Be,dt,Bs,oe,Ut)}if(!ne||Ht){const Yt=new Dn([z.ONE,z.ONE,z.ONE,Ht?z.ZERO:z.ONE],i.ao.transparent,[!1,!1,!1,!0],Ht?z.FUNC_ADD:z.MAX);Zf(jt,M,h,x,A,ns,dn.disabled,Yt,rn.disabled,Ht,"clear",Pe,Ce,Ve,Be,dt,Bs,oe,Ut,ts)}else{z.drawBuffers([z.NONE,z.COLOR_ATTACHMENT1]);const Yt=new dn({func:z.EQUAL,mask:255},254,255,z.KEEP,z.DECR,z.DECR),zt=new Dn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!0,!1,!1,!1],z.MAX);Zf(jt,M,h,x,A,ns,Yt,zt,rn.disabled,Ht,"emissive",Pe,Ce,Ve,Be,dt,Bs,oe,Ut,ts),z.drawBuffers([z.COLOR_ATTACHMENT0])}};if(st||Mt){let Ht;M.prepareDrawTile(),ne&&!st||(Ht=mt()),st&&Et(!0,!1,Ht),Mt&&Et(!1,!0,Ht)}}else st&>(!0),Mt&>(!1),(st||Mt)&&M.resetStencilClippingMasks()}}},building:function(M,h,x,A){M.currentLayer0&&F>0,ne=!0;const oe=x.paint.get("building-vertical-scale");if(oe<=0)return;M.shadowRenderer||(ne=!1);const ge=M.conflationActive&&M.style.isLayerClipped(x,h.getSource()),pe=M.style.order.indexOf(x.fqid);if(function(xe,Pe,Ce,Ve,Be,tt){for(const dt of tt){const st=Pe.getTile(dt).getBucket(Ce);st&&(Be&&st.updateReplacement(dt,xe.replacementSource,Ve),st.uploadUpdatedIndexBuffer(xe.context))}}(M,h,x,pe,ge,A),function(xe,Pe,Ce,Ve){for(const Be of Ve){const tt=Pe.getTile(Be).getBucket(Ce);tt&&tt.needsEvaluation()&&tt.uploadUpdatedColorBuffer(xe.context)}}(M,h,x,A),x.resetLayerRenderingStats(M),M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!0),M.renderPass==="shadow"&&M.shadowRenderer){const xe=M.shadowRenderer,Pe=[],Ce=xe.getShadowPassDepthMode();Ab({painter:M,source:h,layer:x,coords:A,defines:Pe,blendMode:xe.getShadowPassColorMode(),depthMode:Ce,opacity:V,verticalScale:oe,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(M.renderPass==="translucent"){let xe=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];ne&&(xe=xe.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),M.shadowRenderer&&M.shadowRenderer.useNormalOffset&&(xe=xe.concat("NORMAL_OFFSET"));const Pe=x.paint.get("building-facade-emissive-chance"),Ce=x.paint.get("building-ambient-occlusion-intensity"),Ve=x.paint.get("building-flood-light-intensity"),Be=x.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",tt=x.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(Be?null:x.lut).toArray01().slice(0,3),dt=x.paint.get("building-flood-light-ground-attenuation"),st=Ve>0,Mt=new Lr(M.context.gl.LEQUAL,Lr.ReadWrite,M.depthRangeFor3D);V<1&&Ab({painter:M,source:h,layer:x,coords:A,defines:xe,blendMode:Dn.disabled,depthMode:Mt,opacity:V,verticalScale:oe,facadeEmissiveChance:Pe,facadeAOIntensity:Ce,floodLightIntensity:Ve,floodLightColor:tt,depthOnly:!0});const yt=M.colorModeForRenderPass();Ab({painter:M,source:h,layer:x,coords:A,defines:xe,blendMode:yt,depthMode:Mt,opacity:V,verticalScale:oe,facadeEmissiveChance:Pe,facadeAOIntensity:Ce,floodLightIntensity:Ve,floodLightColor:tt}),X&&sC(M,h,x,A,!0,V,D,F,Ve,tt,z,ge),st&&sC(M,h,x,A,!1,V,D,F,Ve,tt,dt,ge)}else if(M.renderPass==="light-beam"){const xe=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],Pe=new Lr(M.context.gl.LEQUAL,Lr.ReadOnly,M.depthRangeFor3D);Ab({painter:M,source:h,layer:x,coords:A,defines:xe,blendMode:Dn.alphaBlended,depthMode:Pe,opacity:V,verticalScale:oe,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!1),M.resetStencilClippingMasks()},hillshade:function(M,h,x,A){if(M.renderPass!=="offscreen"&&M.renderPass!=="translucent"||M.style.disableElevatedTerrain)return;const D=M.context,F=M.terrain&&M.terrain.renderingToTexture,[z,V]=M.renderPass!=="translucent"||F?[{},A]:M.stencilConfigForOverlap(A);for(const X of V){const ne=h.getTile(X);if(ne.needsHillshadePrepare&&M.renderPass==="offscreen")Jce(M,ne,x);else if(M.renderPass==="translucent"){const oe=M.depthModeForSublayer(0,Lr.ReadOnly),ge=x.paint.get("hillshade-emissive-strength"),pe=M.colorModeForDrapableLayerRenderPass(ge),xe=F&&M.terrain?M.terrain.stencilModeForRTTOverlap(X):z[X.overscaledZ];Qce(M,X,ne,x,oe,xe,pe)}}D.viewport.set([0,0,M.width,M.height]),M.resetStencilClippingMasks()},raster:function(M,h,x,A,D,F){if(M.renderPass!=="translucent"||x.paint.get("raster-opacity")===0)return;const z=M.transform.projection.name==="globe",V=x.paint.get("raster-elevation")!==0,X=V&&z;if(M.renderElevatedRasterBackface&&!X)return;const ne=M.context,oe=ne.gl,ge=h.getSource(),pe=function(yt,jt,gt,mt,Et){const Ht=jt.paint.get("raster-color"),Ut=yt.type==="raster-array",ts=[],ns=jt.paint.get("raster-resampling"),fs=jt.paint.get("raster-color-mix");let Bs=jt.paint.get("raster-color-range");const Yt=[fs[0],fs[1],fs[2],0],zt=fs[3];let ds=ns==="nearest"?mt.NEAREST:mt.LINEAR;if(Ut&&(ts.push("RASTER_ARRAY"),Ht||ts.push("RASTER_COLOR"),ns==="linear"&&ts.push("RASTER_ARRAY_LINEAR"),ds=mt.NEAREST,!Bs&&yt.rasterLayers)){const Jt=yt.rasterLayers.find(({id:Es})=>Es===jt.sourceLayer);Jt&&Jt.fields&&Jt.fields.range&&(Bs=Jt.fields.range)}if(Bs=Bs||[0,1],Ht){ts.push("RASTER_COLOR"),gt.activeTexture.set(mt.TEXTURE2),jt.updateColorRamp(Bs);let Jt=jt.colorRampTexture;Jt||(Jt=jt.colorRampTexture=new i.T(gt,jt.colorRamp,mt.RGBA8)),Jt.bind(mt.LINEAR,mt.CLAMP_TO_EDGE)}return Et&&ts.push("USE_MRT1"),{mix:Yt,range:Bs,offset:zt,defines:ts,resampling:ds}}(ge,x,ne,oe,M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback");if(ge instanceof i.aU&&!A.length&&!z)return;const xe=x.paint.get("raster-emissive-strength"),Pe=M.colorModeForDrapableLayerRenderPass(xe),Ce=M.terrain&&M.terrain.renderingToTexture,Ve=!M.options.moving,Be=x.paint.get("raster-resampling")==="nearest"?oe.NEAREST:oe.LINEAR;if(ge instanceof i.aU&&!A.length&&(ge.onNorthPole||ge.onSouthPole)){const yt=V?M.stencilModeFor3D():dn.disabled;return void Eb(!!ge.onNorthPole,null,M,h,x,xe,pe,rn.disabled,yt)}if(!A.length)return;const[tt,dt]=ge instanceof i.aU||Ce?[{},A]:M.stencilConfigForOverlap(A),st=dt[dt.length-1].overscaledZ;X&&pe.defines.push("PROJECTION_GLOBE_VIEW"),V&&pe.defines.push("RENDER_CUTOFF");const Mt=(yt,jt,gt)=>{for(const mt of yt){const Et=mt.toUnwrapped(),Ht=h.getTile(mt);if(Ce&&(!Ht||!Ht.hasData()))continue;ne.activeTexture.set(oe.TEXTURE0);const Ut=Xf(Ht,ge,x,pe);if(!Ut||!Ut.texture)continue;const{texture:ts,mix:ns,offset:fs,tileSize:Bs,buffer:Yt}=Ut;let zt,ds;Ce?(zt=Lr.disabled,ds=mt.projMatrix):V?(zt=new Lr(oe.LEQUAL,Lr.ReadWrite,M.depthRangeFor3D),ds=z?Float32Array.from(M.transform.expandedFarZProjMatrix):M.transform.calculateProjMatrix(Et,Ve)):(zt=M.depthModeForSublayer(mt.overscaledZ-st,x.paint.get("raster-opacity")===1?Lr.ReadWrite:Lr.ReadOnly,oe.LESS),ds=M.transform.calculateProjMatrix(Et,Ve));const Jt=M.terrain&&Ce?M.terrain.stencilModeForRTTOverlap(mt):tt[mt.overscaledZ],Es=F?0:x.paint.get("raster-fade-duration");Ht.registerFadeDuration(Es);const Js=h.findLoadedParent(mt,0),mr=kb(Ht,Js,h,M.transform,Es);let Ys,Us;!mr.isFading&&Ht.refreshedUponExpiration&&(Ht.refreshedUponExpiration=!1),M.terrain&&M.terrain.prepareDrawTile(),ne.activeTexture.set(oe.TEXTURE0),ts.bind(Be,oe.CLAMP_TO_EDGE),ne.activeTexture.set(oe.TEXTURE1),Js?(Js.texture&&Js.texture.bind(Be,oe.CLAMP_TO_EDGE),Ys=Math.pow(2,Js.tileID.overscaledZ-Ht.tileID.overscaledZ),Us=[Ht.tileID.canonical.x*Ys%1,Ht.tileID.canonical.y*Ys%1]):ts.bind(Be,oe.CLAMP_TO_EDGE),"useMipmap"in ts&&ne.extTextureFilterAnisotropic&&M.transform.pitch>20&&oe.texParameterf(oe.TEXTURE_2D,ne.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,ne.extTextureFilterAnisotropicMax);const Cr=M.transform;let Nr;const cr=V?ZD(Cr):[0,0,0,0];let xr,Vr,jn,pa,Ha,Er=0;if(X&&ge instanceof i.aU&&ge.coordinates.length>3)xr=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0)))),Vr=Float32Array.from(Cr.globeMatrix),jn=Float32Array.from(i.dF(Cr)),pa=[i.aF(Cr.center.lng),i.aJ(Cr.center.lat)],Nr=ge.elevatedGlobePerspectiveTransform,Ha=ge.elevatedGlobeGridMatrix||new Float32Array(9);else if(X){const fi=i.dG(mt.canonical);Er=i.dH(fi.getCenter().lat),xr=Float32Array.from(i.bk(i.dJ(mt.canonical))),Vr=Float32Array.from(Cr.globeMatrix),jn=Float32Array.from(i.dF(Cr)),pa=[i.aF(Cr.center.lng),i.aJ(Cr.center.lat)],Nr=[0,0],Ha=Float32Array.from(i.dI(mt.canonical,fi,Er,Cr.worldSize/Cr._pixelsPerMercatorPixel))}else Nr=ge instanceof i.aU?ge.perspectiveTransform:[0,0],xr=new Float32Array(16),Vr=new Float32Array(9),jn=new Float32Array(16),pa=[0,0],Ha=new Float32Array(9);const Fa=qD(ds,xr,Vr,jn,Ha,Us||[0,0],i.aj(M.transform.zoom),pa,cr,Ys||1,mr,x,Nr,V?x.paint.get("raster-elevation"):0,2,ns,fs,pe.range,Bs,Yt,xe),vn=M.isTileAffectedByFog(mt),Xa=M.getOrCreateProgram("raster",{defines:pe.defines,overrideFog:vn});if(M.uploadCommonUniforms(ne,Xa,Et),ge instanceof i.aU){const fi=ge.elevatedGlobeVertexBuffer,oi=ge.elevatedGlobeIndexBuffer;if(Ce||!z)ge.boundsBuffer&&ge.boundsSegments&&Xa.draw(M,oe.TRIANGLES,zt,dn.disabled,Pe,rn.disabled,Fa,x.id,ge.boundsBuffer,M.quadTriangleIndexBuffer,ge.boundsSegments);else if(fi&&oi){const Oa=Cr.zoom<=i.c_?ge.elevatedGlobeSegments:ge.getSegmentsForLongitude(Cr.center.lng);Oa&&Xa.draw(M,oe.TRIANGLES,zt,dn.disabled,Pe,jt,Fa,x.id,fi,oi,Oa)}}else if(X){zt=new Lr(oe.LEQUAL,Lr.ReadOnly,M.depthRangeFor3D);const fi=M.globeSharedBuffers;if(fi){const[oi,Oa,Rn]=fi.getGridBuffers(Er,!1);Xa.draw(M,oe.TRIANGLES,zt,gt||Jt,M.colorModeForRenderPass(),jt,Fa,x.id,oi,Oa,Rn)}}else{const{tileBoundsBuffer:fi,tileBoundsIndexBuffer:oi,tileBoundsSegments:Oa}=M.getTileBoundsBuffers(Ht);Xa.draw(M,oe.TRIANGLES,zt,Jt,Pe,rn.disabled,Fa,x.id,fi,oi,Oa)}}if(!(ge instanceof i.aU)&&X)for(const mt of yt){const Et=mt.canonical.y===(1<>>16,2654435769),((mt=Math.imul(mt^mt>>>16,2654435769))>>>0)/4294967296},gt=1/1.1;for(let mt=0;mti.e9[Jt](ts));Yt.push(ts);const zt=ts.canonical.x,ds=ts.canonical.y;for(const Jt of Yt){const Es=st.getTile(Et?Jt.wrapped():Jt);if(!Es)continue;const Js=Es.rasterParticleState;if(!Js)continue;const mr=Jt.canonical.x+(1<jt.tileID)),xe&&(ne.activeTexture.set(oe.TEXTURE0),M.imageManager.bind(M.context,x.scope));const yt=[];if(M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback"&&yt.push("USE_MRT1"),X){const jt=M.getOrCreateProgram(dt,{overrideFog:!1,overrideRtt:!0,defines:yt}),gt=new Float32Array(i.bA([])),mt=new i.aQ(0,0,0,0,0),Et=xe?xx(gt,V,z,M,0,x.scope,Pe,X,{tileID:mt,tileSize:pe}):Cb(gt,V,z,D.toPremultipliedRenderColor(F?null:x.lut));jt.draw(M,oe.TRIANGLES,Be,Ve,tt,rn.disabled,Et,x.id,M.viewportBuffer,M.quadTriangleIndexBuffer,M.viewportSegments)}else for(const jt of Mt){const gt=M.isTileAffectedByFog(jt),mt=M.getOrCreateProgram(dt,{overrideFog:gt,defines:yt}),Et=jt.toUnwrapped(),Ht=A?jt.projMatrix:M.transform.calculateProjMatrix(Et);M.prepareDrawTile();const Ut=h?h.getTile(jt):st?st[jt.key]:new nm(jt,pe,ge.zoom,M),ts=xe?xx(Ht,V,z,M,0,x.scope,Pe,X,{tileID:jt,tileSize:pe}):Cb(Ht,V,z,D.toPremultipliedRenderColor(F?null:x.lut));M.uploadCommonUniforms(ne,mt,Et);const{tileBoundsBuffer:ns,tileBoundsIndexBuffer:fs,tileBoundsSegments:Bs}=M.getTileBoundsBuffers(Ut);mt.draw(M,oe.TRIANGLES,Be,Ve,tt,rn.disabled,ts,x.id,ns,fs,Bs)}},sky:function(M,h,x){const A=M._atmosphere?i.aj(M.transform.zoom):1,D=x.paint.get("sky-opacity")*A;if(D===0)return;const F=M.context,z=x.paint.get("sky-type"),V=new Lr(F.gl.LEQUAL,Lr.ReadOnly,[0,1]),X=M.frameCounter/1e3%1;z==="atmosphere"?M.renderPass==="offscreen"?x.needsSkyboxCapture(M)&&(function(ne,oe,ge,pe){const xe=ne.context,Pe=xe.gl;let Ce=oe.skyboxFbo;if(!Ce){Ce=oe.skyboxFbo=xe.createFramebuffer(32,32,1,null),oe.skyboxGeometry=new iC(xe),oe.skyboxTexture=xe.gl.createTexture(),Pe.bindTexture(Pe.TEXTURE_CUBE_MAP,oe.skyboxTexture),Pe.texParameteri(Pe.TEXTURE_CUBE_MAP,Pe.TEXTURE_WRAP_S,Pe.CLAMP_TO_EDGE),Pe.texParameteri(Pe.TEXTURE_CUBE_MAP,Pe.TEXTURE_WRAP_T,Pe.CLAMP_TO_EDGE),Pe.texParameteri(Pe.TEXTURE_CUBE_MAP,Pe.TEXTURE_MIN_FILTER,Pe.LINEAR),Pe.texParameteri(Pe.TEXTURE_CUBE_MAP,Pe.TEXTURE_MAG_FILTER,Pe.LINEAR);for(let dt=0;dt<6;++dt)Pe.texImage2D(Pe.TEXTURE_CUBE_MAP_POSITIVE_X+dt,0,Pe.RGBA,32,32,0,Pe.RGBA,Pe.UNSIGNED_BYTE,null)}xe.bindFramebuffer.set(Ce.framebuffer),xe.viewport.set([0,0,32,32]);const Ve=oe.getCenter(ne,!0),Be=ne.getOrCreateProgram("skyboxCapture"),tt=new Float64Array(16);i.bA(tt),i.en(tt,tt,.5*-Math.PI),$y(ne,oe,Be,tt,Ve,0),i.bA(tt),i.en(tt,tt,.5*Math.PI),$y(ne,oe,Be,tt,Ve,1),i.bA(tt),i.cU(tt,tt,.5*-Math.PI),$y(ne,oe,Be,tt,Ve,2),i.bA(tt),i.cU(tt,tt,.5*Math.PI),$y(ne,oe,Be,tt,Ve,3),i.bA(tt),$y(ne,oe,Be,tt,Ve,4),i.bA(tt),i.en(tt,tt,Math.PI),$y(ne,oe,Be,tt,Ve,5),xe.viewport.set([0,0,ne.width,ne.height])}(M,x),x.markSkyboxValid(M)):M.renderPass==="sky"&&function(ne,oe,ge,pe,xe){const Pe=ne.context,Ce=Pe.gl,Ve=ne.transform,Be=ne.getOrCreateProgram("skybox");Pe.activeTexture.set(Ce.TEXTURE0),Ce.bindTexture(Ce.TEXTURE_CUBE_MAP,oe.skyboxTexture);const tt=((dt,st,Mt,yt,jt)=>({u_matrix:dt,u_sun_direction:st,u_cubemap:0,u_opacity:yt,u_temporal_offset:jt}))(Ve.skyboxMatrix,oe.getCenter(ne,!1),0,pe,xe);ne.uploadCommonUniforms(Pe,Be),Be.draw(ne,Ce.TRIANGLES,ge,dn.disabled,ne.colorModeForRenderPass(),rn.backCW,tt,"skybox",oe.skyboxGeometry.vertexBuffer,oe.skyboxGeometry.indexBuffer,oe.skyboxGeometry.segment)}(M,x,V,D,X):z==="gradient"&&M.renderPass==="sky"&&function(ne,oe,ge,pe,xe){const Pe=ne.context,Ce=Pe.gl,Ve=ne.transform,Be=ne.getOrCreateProgram("skyboxGradient");oe.skyboxGeometry||(oe.skyboxGeometry=new iC(Pe)),Pe.activeTexture.set(Ce.TEXTURE0);let tt=oe.colorRampTexture;tt||(tt=oe.colorRampTexture=new i.T(Pe,oe.colorRamp,Ce.RGBA8)),tt.bind(Ce.LINEAR,Ce.CLAMP_TO_EDGE);const dt=((st,Mt,yt,jt,gt)=>({u_matrix:st,u_color_ramp:0,u_center_direction:Mt,u_radius:i.an(yt),u_opacity:jt,u_temporal_offset:gt}))(Ve.skyboxMatrix,oe.getCenter(ne,!1),oe.paint.get("sky-gradient-radius"),pe,xe);ne.uploadCommonUniforms(Pe,Be),Be.draw(ne,Ce.TRIANGLES,ge,dn.disabled,ne.colorModeForRenderPass(),rn.backCW,dt,"skyboxGradient",oe.skyboxGeometry.vertexBuffer,oe.skyboxGeometry.indexBuffer,oe.skyboxGeometry.segment)}(M,x,V,D,X)},custom:function(M,h,x,A){const D=M.context,F=x.implementation;if(!M.transform.projection.unsupportedLayers||!M.transform.projection.unsupportedLayers.includes("custom")||M.terrain&&(M.terrain.renderingToTexture||M.renderPass==="offscreen")&&x.isDraped(h)){if(M.renderPass==="offscreen"){const z=F.prerender;if(z){if(M.setCustomLayerDefaults(),D.setColorMode(M.colorModeForRenderPass()),M.transform.projection.name==="globe"){const V=M.transform.pointMerc;z.call(F,D.gl,M.transform.customLayerMatrix(),M.transform.getProjection(),M.transform.globeToMercatorMatrix(),i.aj(M.transform.zoom),[V.x,V.y],M.transform.pixelsPerMeterRatio)}else z.call(F,D.gl,M.transform.customLayerMatrix());D.setDirty(),M.setBaseState()}}else if(M.renderPass==="translucent"){if(M.terrain&&M.terrain.renderingToTexture){const V=F.renderToTile;if(V){const X=A[0].canonical,ne={x:X.x+A[0].wrap*(F.wrapTileId?0:1<{ne&&(ne.useNormalOffset=!0,oe||(ne.enabled=!0))},pe=h.getSource();if(M.renderPass==="light-beam"&&pe.type!=="batched-model")return;if(pe.type==="vector"||pe.type==="geojson")return function(st,Mt,yt,jt,gt){const mt=st.transform,Et=mt.projection.name==="globe",Ht=mt.getFreeCameraOptions().position;if(!st.modelManager)return;const Ut=st.modelManager;yt.modelManager=Ut;const ts=st.shadowRenderer;if(!yt._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const ns=yt._unevaluatedLayout._values["model-id"],fs=Object.assign({},yt.layout.get("model-id").parameters),Bs=st.style.order.indexOf(yt.fqid),Yt=yt.paint.get("model-opacity").constantOr(1);for(const zt of jt){const ds=Mt.getTile(zt).getBucket(yt);if(!ds||ds.projection.name!==mt.projection.name)continue;const Jt=ds.getModelUris();if(Jt&&!ds.modelsRequested&&(Ut.addModelsFromBucket(Jt,gt),ds.modelsRequested=!0),Et)fs.zoom=zt.overscaledZ;else{const cr=su(zt,mt);fs.zoom=cr}const Es=ns.possiblyEvaluate(fs);if(iO(st,ds,zt),zp.shadowUniformsInitialized=!1,zp.useSingleShadowCascade=!!ts&&ts.getMaxCascadeForTile(zt.toUnwrapped())===0,st.renderPass==="shadow"&&ts){if(st.currentShadowCascade===1&&ds.isInsideFirstShadowMapFrustum)continue;const cr=mt.calculatePosMatrix(zt.toUnwrapped(),mt.worldSize);if(zp.tileMatrix.set(cr),zp.shadowTileMatrix=Float32Array.from(ts.calculateShadowPassMatrixFromMatrix(cr)),zp.aabb.min=[0,0,0],zp.aabb.max[0]=zp.aabb.max[1]=i.al,zp.aabb.max[2]=0,hde(ds,zp,st,yt.scope))continue}const Js=1<0&&st.style.isLayerClipped(yt,Mt.getSource())&&ds.updateReplacement(zt,st.replacementSource,Bs,yt.scope)&&(ds.uploaded=!1,ds.upload(st.context));let Ys=0;const Us=new Array,Cr=new Array,Nr=new Array;for(let cr in ds.instancesPerModel){const xr=ds.instancesPerModel[cr];xr.features.length>0&&!Et&&(cr=Es.evaluate(xr.features[0].feature,{}));const Vr=Ut.getModel(cr,gt);if(Vr||Ut.hasURLBeenRequested(cr)||ds.modelUris.includes(cr)||(ds.modelUris.push(cr),ds.modelsRequested=!1),Vr&&Vr.uploaded)if(Et){const jn=i.c5([],[Ht.x,Ht.y,Ht.z],st.transform.worldSize);i.ew(jn,jn);for(let pa=0;pa0&&Fa.elevationUpdate(cr.terrain,pa,Er,Vr.source),Fa.needsReEvaluation(cr,Ha,Vr)&&Fa.evaluate(Vr))}})(st,Mt,yt,jt),function(){let cr,xr,Vr;Us?(cr=jt.length-1,xr=-1,Vr=-1):(cr=0,xr=jt.length,Vr=1);const jn=new Float64Array(16),pa=i.cA(),Ha=new i.P(0,0);for(let Er=cr;Er!==xr;Er+=Vr){const Fa=jt[Er],vn=Mt.getTile(Fa).getBucket(yt);if(!vn||!vn.uploaded)continue;let Xa=!1;Ht&&(Xa=Ht.getMaxCascadeForTile(Fa.toUnwrapped())===0);const fi=mt.calculatePosMatrix(Fa.toUnwrapped(),mt.worldSize),oi=vn.modelTraits;!Js&&Us&&(i.bl(jn,fi),i.af(pa,ts,jn),Ha.x=pa[0],Ha.y=pa[1]);const Oa=[];vn.setFilter(yt.filter);for(const Rn of vn.getNodesInfo()){if(Rn.hiddenByReplacement||!Rn.node.meshes)continue;const Ka=Rn.node;let fo=0;st.terrain&&Ka.elevation&&(fo=Ka.elevation*st.terrain.exaggeration());const Gi=(()=>{const fd=Rn.aabb;return Es.min=[...fd.min],Es.max=[...fd.max],Es.min[2]+=fo,Es.max[2]+=fo,i.af(Es.min,Es.min,fi),i.af(Es.max,Es.max,fi),Es})(),Qa=Rn.evaluatedScale;if(Qa[0]<=1&&Qa[1]<=1&&Qa[2]<=1&&Gi.intersects(mr)===0)continue;if(!Js&&Us){const fd=.16666666666666666;Rn.cameraCollisionOpacity=ts[0]>Gi.min[0]&&ts[0]Gi.min[1]&&ts[1]!Us||Rn.opacity===1&&Ka.opacity===1?Rn.depthKa.depth?-1:1);for(const Rn of Oa){const Ka=Rn.nodeInfo,fo=Ka.node;let Gi=i.aB([],Yt,Rn.tileModelMatrix);i.aB(Gi,fs,Gi);const Qa=i.bl([],Gi);i.eg(Qa,Qa),i.cS(Qa,Qa,Ib),Gi=i.aB(Gi,Gi,fo.globalMatrix);const Ca=st.renderPass==="light-beam",Fn=yt.paint.get("model-color-use-theme").constantOr("default")==="none",qi=oi&i.eI.HasMapboxMeshFeatures,Ao=qi?0:Ka.evaluatedRMEA[0][2];for(let uo=0;uo=gs||ho>=gs}}const Ic=ji.material;let jh;Ic.occlusionTexture&&Ic.occlusionTexture.offsetScale&&(jh=Ic.occlusionTexture.offsetScale,jl.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const mm=st.getOrCreateProgram("model",jl);!Js&&Ht&&Ht.setupShadowsFromMatrix(Rn.tileModelMatrix,mm,Ht.useNormalOffset),st.uploadCommonUniforms(gt,mm,null,gd);const Mu=Ic.pbrMetallicRoughness;Mu.metallicFactor=.9,Mu.roughnessFactor=.5;const jo=Oy(new Float32Array(ed),new Float32Array(Gi),new Float32Array(Qa),new Float32Array(fo.globalMatrix),st,Rn.opacity,Mu.baseColorFactor,Ic.emissiveFactor,Mu.metallicFactor,Mu.roughnessFactor,Ic,Ao,yt,[0,0,0],jh);!ru&&(Ka.hasTranslucentParts||Rn.opacity<1)&&mm.draw(st,gt.gl.TRIANGLES,ds,dn.disabled,Dn.disabled,rn.backCCW,jo,yt.id,ji.vertexBuffer,ji.indexBuffer,ji.segments,yt.paint,st.transform.zoom,void 0,fd),mm.draw(st,gt.gl.TRIANGLES,ru?Jt:ds,dn.disabled,ru||Rn.opacity<1||Ka.hasTranslucentParts?Dn.alphaBlended:Dn.unblended,rn.backCCW,jo,yt.id,ji.vertexBuffer,ji.indexBuffer,ji.segments,yt.paint,st.transform.zoom,void 0,fd)}}}}()}(M,h,x,A),void ge();if(pe.type!=="model")return;const xe=pe.getModels(),Pe=[],Ce=M.transform.getFreeCameraOptions().position,Ve=i.c5([],[Ce.x,Ce.y,Ce.z],M.transform.worldSize);i.ew(Ve,Ve);const Be=[],tt=[];let dt=0;for(const st of xe){const Mt=h.getFeatureState("",st.id),yt={type:"Unknown",id:st.id,properties:st.featureProperties},jt=x.paint.get("model-rotation").evaluate(yt,Mt),gt=x.paint.get("model-scale").evaluate(yt,Mt),mt=x.paint.get("model-translation").evaluate(yt,Mt),Et=x.paint.get("model-opacity").evaluate(yt,Mt);rO(x,st.id,Mt,st.featureProperties,st.nodeOverrideNames,st.nodeOverrides),nO(x,st.id,Mt,st.featureProperties,st.materialOverrideNames,st.materialOverrides),st.nodeOverrides.size>0&&st.computeBoundsAndApplyParent(),st.computeModelMatrix(M,jt,gt,mt,V,z,!1);const Ht=i.bA([]),Ut=i.ef(st.position.lat,M.transform.zoom),ts=i.bq([],[1,1,1/Ut]);i.br(Ht,Ht,Ve),Pe.push({zScaleMatrix:ts,negCameraPosMatrix:Ht});for(const ns of st.nodes)qy(M,ns,st.matrix,M.transform.expandedFarZProjMatrix,dt,Be,tt,st.materialOverrides,Et);dt++}if(Be.sort((st,Mt)=>Mt.depth-st.depth),M.renderPass!=="shadow")aO(M,x,Be,tt,Pe),ge();else{for(const st of tt)Ym(st.mesh,st.nodeModelMatrix,M,x);for(const st of Be)Ym(st.mesh,st.nodeModelMatrix,M,x);ge()}}},mC={line:function(M,h,x){if(M.hasElevatedBuckets=!1,M.hasNonElevatedBuckets=!1,M._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||M._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(h){const A=h.getVisibleCoordinates();for(const D of A){const F=h.getTile(D).getBucket(M);if(F&&(F.elevationType!=="none"?M.hasElevatedBuckets=!0:M.hasNonElevatedBuckets=!0,M.hasElevatedBuckets&&M.hasNonElevatedBuckets))break}}}else M.hasNonElevatedBuckets=!0},model:function(M,h,x){const A=h.getSource();if(!A.loaded())return;if(A.type==="vector"||A.type==="geojson")return void(x.modelManager&&x.modelManager.upload(x,Pb(x,M)));if(A.type==="batched-model"||A.type!=="model")return;const D=A.getModels();for(const F of D)F.upload(x.context)},raster:function(M,h,x){const A=h.getSource();if(!(A instanceof Xc&&A.loaded()))return;const D=M.sourceLayer||A.rasterLayerIds&&A.rasterLayerIds[0];if(!D)return;const F=M.paint.get("raster-array-band")||A.getInitialBand(D);if(F==null)return;const z=h.getIds().map(V=>h.getTileByID(V));for(const V of z)V.updateNeeded(M.id,F)&&A.prepareTile(V,D,M.id,F)},"raster-particle":function(M,h,x){const A=h.getSource();if(!(A instanceof Xc&&A.loaded()))return;const D=M.sourceLayer||A.rasterLayerIds&&A.rasterLayerIds[0];if(!D)return;const F=M.paint.get("raster-particle-array-band")||A.getInitialBand(D);if(F==null)return;const z=h.getIds().map(V=>h.getTileByID(V));for(const V of z)V.updateNeeded(M.id,F)&&A.prepareTile(V,D,M.id,F)}},wh={fill:JS},pC={fill:function(M,h,x,A){if(!x.layout||x.layout.get("fill-elevation-reference")==="none"||x.paint.get("fill-opacity").constantOr(1)===0)return;const D=M.context.gl,F=new Lr(D.LEQUAL,Lr.ReadOnly,M.depthRangeFor3D),z=new dn({func:D.ALWAYS,mask:255},255,255,D.KEEP,D.KEEP,D.REPLACE),V=M.transform.getFreeCameraOptions().position,X=M.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const ne of A){const oe=h.getTile(ne),ge=oe.getBucket(x);if(!ge)continue;const pe=ge.elevatedStructures;if(!pe||pe.depthSegments.segments[0].primitiveLength===0)continue;const xe=KD(ne.toUnwrapped(),V),Pe=M.translatePosMatrix(ne.projMatrix,oe,x.paint.get("fill-translate"),x.paint.get("fill-translate-anchor")),Ce=Dy(Pe,xe,0,1,0);X.draw(M,D.TRIANGLES,F,z,Dn.disabled,rn.disabled,Ce,x.id,pe.vertexBuffer,pe.indexBuffer,pe.depthSegments,x.paint,M.transform.zoom)}}};class fC{constructor(h,x,A,D,F){this.context=new Lv(h,x),this.transform=A,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this._timeStamp=i.o.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const z=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const X of z)this._debugParams.enabledLayers[X]=!0;for(const X of z);this.occlusionParams=new Ov,this.setup(),this.numSublayers=hl.maxUnderzooming+hl.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new i.eP,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new wv(this),this._wireframeDebugCache=new vx,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const V=new i.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new i.T(this.context,V,h.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=D,this.worldview=F,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(h,x){const A=!!h&&!!h.terrain&&this.transform.projection.supportsTerrain;if(!(A||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new ST(this,h));const D=this._terrain;this.transform.elevation=A?D:null,D.update(h,this.transform,x),this.transform.elevation&&!D.enabled&&(this.transform.elevation=null)}_updateFog(h){const x=h.fog;if(!x||this.transform.projection.name==="globe"||x.getOpacity(this.transform.pitch)<1||x.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[A,D]=x.getFovAdjustedRange(this.transform._fov);if(A>D)return void(this.transform.fogCullDistSq=null);const F=A+.78*(D-A);this.transform.fogCullDistSq=F*F}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(h){h&&!this._terrain&&(this._terrain=new ST(this,this.style)),this._forceTerrainMode=h}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(h,x){if(this.width=h*i.o.devicePixelRatio,this.height=x*i.o.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const A of this.style.order)this.style._mergedLayers[A].resize()}setup(){const h=this.context,x=new i.bd;x.emplaceBack(0,0),x.emplaceBack(i.al,0),x.emplaceBack(0,i.al),x.emplaceBack(i.al,i.al),this.tileExtentBuffer=h.createVertexBuffer(x,i.bf.members),this.tileExtentSegments=i.bg.simpleSegment(0,0,4,2);const A=new i.bd;A.emplaceBack(0,0),A.emplaceBack(i.al,0),A.emplaceBack(0,i.al),A.emplaceBack(i.al,i.al),this.debugBuffer=h.createVertexBuffer(A,i.bf.members),this.debugSegments=i.bg.simpleSegment(0,0,4,5);const D=new i.bd;D.emplaceBack(-1,-1),D.emplaceBack(1,-1),D.emplaceBack(-1,1),D.emplaceBack(1,1),this.viewportBuffer=h.createVertexBuffer(D,i.bf.members),this.viewportSegments=i.bg.simpleSegment(0,0,4,2);const F=new i.b1;F.emplaceBack(0,0,0,0),F.emplaceBack(i.al,0,i.al,0),F.emplaceBack(0,i.al,0,i.al),F.emplaceBack(i.al,i.al,i.al,i.al),this.mercatorBoundsBuffer=h.createVertexBuffer(F,i.bi.members),this.mercatorBoundsSegments=i.bg.simpleSegment(0,0,4,2);const z=new i.b0;z.emplaceBack(0,1,2),z.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=h.createIndexBuffer(z);const V=new i.be;for(const ne of[0,1,3,2,0])V.emplaceBack(ne);this.debugIndexBuffer=h.createIndexBuffer(V),this.emptyTexture=new i.T(h,new i.q({width:1,height:1},Uint8Array.of(0,0,0,0)),h.gl.RGBA8),this.identityMat=i.bC();const X=this.context.gl;this.stencilClearMode=new dn({func:X.ALWAYS,mask:0},0,255,X.ZERO,X.ZERO,X.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(h){return h._makeTileBoundsBuffers(this.context,this.transform.projection),h._tileBoundsBuffer?{tileBoundsBuffer:h._tileBoundsBuffer,tileBoundsIndexBuffer:h._tileBoundsIndexBuffer,tileBoundsSegments:h._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const h=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,h.TRIANGLES,Lr.disabled,this.stencilClearMode,Dn.disabled,rn.disabled,Nb(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(h,x,A){if(!x||this.currentStencilSource===x.id||!h.isTileClipped()||!A||A.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let V=!1;for(const X of A)if(this._tileClippingMaskIDs[X.key]===void 0){V=!0;break}if(!V)return}this.currentStencilSource=x.id;const D=this.context,F=D.gl;this.nextStencilID+A.length>256&&this.clearStencil(),D.setColorMode(Dn.disabled),D.setDepthMode(Lr.disabled);const z=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const V of A){const X=x.getTile(V),ne=this._tileClippingMaskIDs[V.key]=this.nextStencilID++,{tileBoundsBuffer:oe,tileBoundsIndexBuffer:ge,tileBoundsSegments:pe}=this.getTileBoundsBuffers(X);z.draw(this,F.TRIANGLES,Lr.disabled,new dn({func:F.ALWAYS,mask:0},ne,255,F.KEEP,F.KEEP,F.REPLACE),Dn.disabled,rn.disabled,Nb(V.projMatrix),"$clipping",oe,ge,pe)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const h=this.nextStencilID++,x=this.context.gl;return new dn({func:x.NOTEQUAL,mask:255},h,255,x.KEEP,x.KEEP,x.REPLACE)}stencilModeForClipping(h){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(h);const x=this.context.gl;return new dn({func:x.EQUAL,mask:255},this._tileClippingMaskIDs[h.key],0,x.KEEP,x.KEEP,x.REPLACE)}stencilConfigForOverlap(h){const x=this.context.gl,A=h.sort((z,V)=>V.overscaledZ-z.overscaledZ),D=A[A.length-1].overscaledZ,F=A[0].overscaledZ-D+1;if(F>1){this.currentStencilSource=void 0,this.nextStencilID+F>256&&this.clearStencil();const z={};for(let V=0;Vthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((h,x)=>h+x/this._fpsHistory.length,0))}render(h,x){const A=i.o.now();this._dt=A-this._timeStamp,this._timeStamp=A,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=h.map.repaint,this.style=h,this.options=x;const D=this.style._mergedLayers,F=!(!this.terrain||!this.terrain.enabled),z=()=>this.style._getOrder(F).filter(Yt=>{const zt=D[Yt];return!(zt.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[zt.type]});let V=z(),X=!1,ne=!1,oe=null,ge=0,pe=!1;for(const Yt of V){const zt=D[Yt];zt.visibility!=="none"&&(zt.type==="circle"?X=!0:zt.type==="building"?(oe=zt,++ge):zt.type==="symbol"&&(zt.hasOcclusionOpacityProperties?ne=!0:X=!0))}this.updateEmissiveMode();let xe=V.map(Yt=>D[Yt]);const Pe=this.style._mergedSourceCaches;this.imageManager=h.imageManager,this.modelManager=h.modelManager,this.symbolFadeChange=h.placement.symbolFadeChange(i.o.now()),this.imageManager.beginFrame();for(const Yt in Pe){const zt=Pe[Yt];zt.used&&(zt.prepare(this.context),zt.getSource().usedInConflation&&++ge)}let Ce=!1;for(const Yt of xe)Yt.isHidden(this.transform.zoom)||(Yt.type==="clip"&&(Ce=!0),this.prepareLayer(Yt));const Ve={},Be={},tt={},dt={},st={};for(const Yt in Pe){const zt=Pe[Yt];Ve[Yt]=zt.getVisibleCoordinates(),Be[Yt]=Ve[Yt].slice().reverse(),tt[Yt]=zt.getVisibleCoordinates(!0).reverse(),dt[Yt]=zt.getShadowCasterCoordinates(),st[Yt]=zt.sortCoordinatesByDistance(Ve[Yt])}const Mt=Yt=>{const zt=this.style.getLayerSourceCache(Yt);return zt&&zt.used?zt.getSource():null};if(ge||Ce||this._clippingActiveLastFrame){const Yt=[],zt=[];let ds=0;for(const Jt of xe)this.isSourceForClippingOrConflation(Jt,Mt(Jt))&&(Yt.push(Jt),zt.push(ds)),ds++;if(Yt&&(Ce||Yt.length>1)||this._clippingActiveLastFrame){Ce=!1;const Jt=[];for(let Es=0;Es0){const Jt=Mt(zt);Jt&&(this.minCutoffZoom=Math.max(Jt.minzoom,this.minCutoffZoom)),zt.minzoom&&(this.minCutoffZoom=Math.max(zt.minzoom,this.minCutoffZoom))}zt.is3D(F)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=Yt),this._lastOcclusionLayer=Yt)}const yt=this.style&&this.style.fog;yt?(this._fogVisible=yt.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=yt.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(tt),this.opaquePassCutoff=0,V=z(),xe=V.map(Yt=>D[Yt]));const jt=this._shadowRenderer;if(jt){jt.updateShadowParameters(this.transform,this.style.directionalLight);for(const Yt in Pe)for(const zt of Ve[Yt]){let ds={min:0,max:0};this.terrain&&(ds=this.terrain.getMinMaxForTile(zt)||ds),jt.addShadowReceiver(zt.toUnwrapped(),ds.min,ds.max)}}this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new i.eR(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new sO(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const gt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),mt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(gt&&!this._snow&&(this._snow=new qT(this)),!gt&&this._snow&&(this._snow.destroy(),delete this._snow),mt&&!this._rain&&(this._rain=new hC(this)),!mt&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),oe){this.buildingTileBorderManager||(this.buildingTileBorderManager=new oC);const Yt=this.style.getLayerSourceCache(oe);this.buildingTileBorderManager.updateBorders(Yt,oe)}if(!ot.has(this.context.gl))return;this.renderPass="offscreen";for(const Yt of xe){const zt=h.getLayerSourceCache(Yt);if(!Yt.hasOffscreenPass()||Yt.isHidden(this.transform.zoom))continue;const ds=zt?Be[zt.id]:void 0;(Yt.type==="custom"||Yt.type==="raster"||Yt.type==="raster-particle"||Yt.isSky()||ds&&ds.length)&&this.renderLayer(this,zt,Yt,ds)}this.depthRangeFor3D=[0,1-(xe.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,dt)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const Et=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),Ht=(()=>{if(x.showOverdrawInspector)return i.ao.black;const Yt=this.style.fog;if(Yt&&this.transform.projection.supportsFog){const zt=this.style.getLut(Yt.scope);if(!Et){const ds=Yt.properties.get("color-use-theme")==="none",Jt=Yt.properties.get("color").toNonPremultipliedRenderColor(ds?null:zt).toArray01();return new i.ao(...Jt)}if(Et){const ds=Yt.properties.get("space-color-use-theme")==="none",Jt=Yt.properties.get("space-color").toNonPremultipliedRenderColor(ds?null:zt).toArray01();return new i.ao(...Jt)}}return i.ao.transparent})();if(this.context.clear({color:Ht,depth:1}),this.clearStencil(),this._showOverdrawInspector=x.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Et&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=V.length-1;this.currentLayer>=0;this.currentLayer--){const Yt=xe[this.currentLayer],zt=h.getLayerSourceCache(Yt);if(Yt.isSky())continue;const ds=zt?(Yt.is3D(F)?st:Be)[zt.id]:void 0;this._renderTileClippingMasks(Yt,zt,ds),this.renderLayer(this,zt,Yt,ds)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Et&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||i.aj(this.transform.zoom)>0)&&(this.transform.projection.name==="globe"||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer{for(this.currentLayer=0;this.currentLayer0&&Yt.hasShadowPass()&&--ts==0){{this.clearStencil(),this.resetStencilClippingMasks();const ds=this.currentLayer;for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const ds=this.currentLayer;this.depthOcclusion=!0;for(const Jt of this.layersWithOcclusionOpacity){this.currentLayer=Jt;const Es=xe[this.currentLayer],Js=h.getLayerSourceCache(Es),mr=Js?Be[Js.id]:void 0;this.terrain||this._renderTileClippingMasks(Es,Js,Js?Ve[Js.id]:void 0),this.renderLayer(this,Js,Es,mr)}this.depthOcclusion=!1,this.currentLayer=ds,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let Yt=null;xe.forEach(zt=>{const ds=h.getLayerSourceCache(zt);ds&&!zt.isHidden(this.transform.zoom)&&ds.getVisibleCoordinates().length&&(!Yt||Yt.getSource().maxzoom0?x.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return this.context.extTextureFloatLinear!=null}currentGlobalDefines(h,x,A){const D=A===void 0?this.terrain&&this.terrain.renderingToTexture:A,F=[];return this.style&&this.style.enable3dLights()&&(h==="globeRaster"||h==="terrainRaster"?(F.push("LIGHTING_3D_MODE"),F.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):D||F.push("LIGHTING_3D_MODE")),this.renderPass==="shadow"&&(this._shadowMapDebug||F.push("DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(F.push("TERRAIN"),this.linearFloatFilteringSupported()&&F.push("TERRAIN_DEM_FLOAT_FORMAT")),this.transform.projection.name==="globe"&&F.push("GLOBE"),!this._fogVisible||D||x!==void 0&&!x||F.push("FOG","FOG_DITHERING"),D&&F.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&F.push("OVERDRAW_INSPECTOR"),F}getOrCreateProgram(h,x){this.cache=this.cache||{};const A=x&&x.defines||[],D=x&&x.config,F=this.currentGlobalDefines(h,x&&x.overrideFog,x&&x.overrideRtt).concat(A),z=DD.cacheKey(mT[h],h,F,D);return this.cache[z]||(this.cache[z]=new DD(this.context,h,mT[h],D,QS[h],F)),this.cache[z]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const h=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(h.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new i.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(h,x){if(this.style.enable3dLights()){const A=this.style.directionalLight,D=this.style.ambientLight;if(A&&D){const F=((z,V,X)=>{const ne=z.properties.get("direction"),oe=z.properties.get("color-use-theme")==="none",ge=z.properties.get("color").toNonPremultipliedRenderColor(oe?null:X.getLut(z.scope)).toArray01(),pe=z.properties.get("intensity"),xe=V.properties.get("color-use-theme")==="none",Pe=V.properties.get("color").toNonPremultipliedRenderColor(xe?null:X.getLut(V.scope)).toArray01(),Ce=V.properties.get("intensity"),Ve=[ne.x,ne.y,ne.z],Be=i.dN(Pe,Ce),tt=i.dN(ge,pe);return{u_lighting_ambient_color:Be,u_lighting_directional_dir:Ve,u_lighting_directional_color:tt,u_ground_radiance:Ev(Ve,tt,Be)}})(A,D,this.style);x.setLightsUniformValues(h,F)}}}uploadCommonUniforms(h,x,A,D,F){if(this.uploadCommonLightUniforms(h,x),this.terrain&&this.terrain.renderingToTexture)return;const z=this.style.fog;if(z){const V=z.getOpacity(this.transform.pitch),X=((ne,oe,ge,pe,xe,Pe,Ce,Ve,Be,tt,dt,st)=>{const Mt=ne.transform,yt=oe.properties.get("color-use-theme")==="none",jt=oe.properties.get("color").toNonPremultipliedRenderColor(yt?null:ne.style.getLut(oe.scope)).toArray01();jt[3]=pe;const gt=ne.frameCounter/1e3%1,[mt,Et]=oe.properties.get("vertical-range");return{u_fog_matrix:ge?Mt.calculateFogTileMatrix(ge):st||ne.identityMat,u_fog_range:oe.getFovAdjustedRange(Mt._fov),u_fog_color:jt,u_fog_horizon_blend:oe.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(mt,Et),Et],u_fog_temporal_offset:gt,u_frustum_tl:xe,u_frustum_tr:Pe,u_frustum_br:Ce,u_frustum_bl:Ve,u_globe_pos:Be,u_globe_radius:tt,u_viewport:dt,u_globe_transition:i.aj(Mt.zoom),u_is_globe:+(Mt.projection.name==="globe")}})(this,z,A,V,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*i.o.devicePixelRatio,this.transform.height*i.o.devicePixelRatio],D);x.setFogUniformValues(h,X)}F&&x.setCutoffUniformValues(h,F.uniformValues)}setTileLoadedFlag(h){this.tileLoaded=h}saveCanvasCopy(){const h=this.canvasCopy();h&&(this.frameCopies.push(h),this.tileLoaded=!1)}canvasCopy(){const h=this.context.gl,x=h.createTexture();return h.bindTexture(h.TEXTURE_2D,x),h.copyTexImage2D(h.TEXTURE_2D,0,h.RGBA,0,0,h.drawingBufferWidth,h.drawingBufferHeight,0),x}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const h=this.style&&this.style.fog;return!!h&&h.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const h=this._backgroundTiles,x=this._backgroundTiles={},A=this.transform.coveringTiles({tileSize:512});for(const D of A)x[D.key]=h[D.key]||new nm(D,512,this.transform.tileZoom,this,void 0,this.worldview);return x}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(h,x){return!(!h.is3D(!(!this.terrain||!this.terrain.enabled))||h.type!=="clip"&&h.type!=="building"&&(h.minzoom&&h.minzoom>this.transform.zoom||(this.style._clipLayerPresent||h.sourceLayer!=="building"&&h.sourceLayer!=="procedural_buildings")&&(!x||x.type!=="batched-model")))}isTileAffectedByFog(h){if(!this.style||!this.style.fog)return!1;if(this.transform.projection.name==="globe")return!0;let x=this._cachedTileFogOpacities[h.key];return x||(this._cachedTileFogOpacities[h.key]=x=this.style.fog.getOpacityForTile(h)),x[0]>=gs||x[1]>=gs}setupDepthForOcclusion(h,x,A){const D=this.context,F=D.gl,z=!!A;var V;A||(A={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),D.activeTexture.set(F.TEXTURE3),h&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(F.NEAREST,F.CLAMP_TO_EDGE),A.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],A.u_depth_range_unpack=[2/((V=this.depthRangeFor3D)[1]-V[0]),-1-2*V[0]/(V[1]-V[0])],A.u_occluder_half_size=.5*this.occlusionParams.occluderSize,A.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(F.NEAREST,F.CLAMP_TO_EDGE),D.activeTexture.set(F.TEXTURE0),z||x.setTerrainUniformValues(D,A)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const h=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=h?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function gC(M,h){let x=!1,A=null;const D=()=>{A=null,x&&(M(),A=setTimeout(D,h),x=!1)};return()=>(x=!0,A||D(),A)}class UT{constructor(h){this._hashName=h&&encodeURIComponent(h),i.aY(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=gC(this._updateHashUnthrottled.bind(this),300)}addTo(h){return this._map=h,window.addEventListener("hashchange",this._onHashChange,!1),h.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const h=this._map;if(!h)return"";const x=bl(h);if(this._hashName){const A=this._hashName;let D=!1;const F=location.hash.slice(1).split("&").map(z=>{const V=z.split("=")[0];return V===A?(D=!0,`${V}=${x}`):z}).filter(z=>z);return D||F.push(`${A}=${x}`),`#${F.join("&")}`}return`#${x}`}_getCurrentHash(){const h=location.hash.replace("#","");if(this._hashName){let x;return h.split("&").map(A=>A.split("=")).forEach(A=>{A[0]===this._hashName&&(x=A)}),(x&&x[1]||"").split("/")}return h.split("/")}_onHashChange(){const h=this._map;if(!h)return!1;const x=this._getCurrentHash();if(x.length>=3&&!x.some(A=>isNaN(Number(A)))){const A=h.dragRotate.isEnabled()&&h.touchZoomRotate.isEnabled()?+(x[3]||0):h.getBearing();return h.jumpTo({center:[+x[2],+x[1]],zoom:+x[0],bearing:A,pitch:+(x[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function bl(M,h){const x=M.getCenter(),A=Math.round(100*M.getZoom())/100,D=Math.ceil((A*Math.LN2+Math.log(512/360/.5))/Math.LN10),F=Math.pow(10,D),z=Math.round(x.lng*F)/F,V=Math.round(x.lat*F)/F,X=M.getBearing(),ne=M.getPitch();let oe=h?`/${z}/${V}/${A}`:`${A}/${V}/${z}`;return(X||ne)&&(oe+="/"+Math.round(10*X)/10),ne&&(oe+=`/${Math.round(ne)}`),oe}const Fv={linearity:.3,easing:i.eT(0,0,.3,1)},VT=Object.assign({deceleration:2500,maxSpeed:1400},Fv),HT=Object.assign({deceleration:20,maxSpeed:1400},Fv),Vy=Object.assign({deceleration:1e3,maxSpeed:360},Fv),WT=Object.assign({deceleration:1e3,maxSpeed:90},Fv);class GT{constructor(h){this._map=h,this.clear()}clear(){this._inertiaBuffer=[]}record(h){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:i.o.now(),settings:h})}_drainInertiaBuffer(){const h=this._inertiaBuffer,x=i.o.now();for(;h.length>0&&x-h[0].time>160;)h.shift()}_onMoveEnd(h){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const x={zoom:0,bearing:0,pitch:0,pan:new i.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:F}of this._inertiaBuffer)x.zoom+=F.zoomDelta||0,x.bearing+=F.bearingDelta||0,x.pitch+=F.pitchDelta||0,F.panDelta&&x.pan._add(F.panDelta),F.around&&(x.around=F.around),F.pinchAround&&(x.pinchAround=F.pinchAround);const A=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,D={};if(x.pan.mag()){const F=Bp(x.pan.mag(),A,Object.assign({},VT,h||{}));D.offset=x.pan.mult(F.amount/x.pan.mag()),D.center=this._map.transform.center,zv(D,F)}if(x.zoom){const F=Bp(x.zoom,A,HT);D.zoom=this._map.transform.zoom+F.amount,zv(D,F)}if(x.bearing){const F=Bp(x.bearing,A,Vy);D.bearing=this._map.transform.bearing+i.aA(F.amount,-179,179),zv(D,F)}if(x.pitch){const F=Bp(x.pitch,A,WT);D.pitch=this._map.transform.pitch+F.amount,zv(D,F)}if(D.zoom||D.bearing){const F=x.pinchAround===void 0?x.around:x.pinchAround;D.around=F?this._map.unproject(F):this._map.getCenter()}return this.clear(),D.noMoveStart=!0,D}}function zv(M,h){(!M.duration||M.durationx.unproject(X)),V=F.reduce((X,ne,oe,ge)=>X.add(ne.div(ge.length)),new i.P(0,0));super(h,{points:F,point:V,lngLats:z,lngLat:x.unproject(V),originalEvent:A}),this._defaultPrevented=!1}}class KT extends i.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(h,x){super("wheel",{originalEvent:x}),this._defaultPrevented=!1}}class xC{constructor(h,x){this._map=h,this._clickTolerance=x.clickTolerance}reset(){this._mousedownPos=void 0}wheel(h){return this._firePreventable(new KT(this._map,h))}mousedown(h,x){return this._mousedownPos=x,this._firePreventable(new Cu(h.type,this._map,h))}mouseup(h){this._map.fire(new Cu(h.type,this._map,h))}preclick(h){const x=new MouseEvent("preclick",h);this._map.fire(new Cu(x.type,this._map,x))}click(h,x){this._mousedownPos&&this._mousedownPos.dist(x)>=this._clickTolerance||(this.preclick(h),this._map.fire(new Cu(h.type,this._map,h)))}dblclick(h){return this._firePreventable(new Cu(h.type,this._map,h))}mouseover(h){this._map.fire(new Cu(h.type,this._map,h))}mouseout(h){this._map.fire(new Cu(h.type,this._map,h))}touchstart(h){return this._firePreventable(new bx(h.type,this._map,h))}touchmove(h){this._map.fire(new bx(h.type,this._map,h))}touchend(h){this._map.fire(new bx(h.type,this._map,h))}touchcancel(h){this._map.fire(new bx(h.type,this._map,h))}_firePreventable(h){if(this._map.fire(h),h.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ZT{constructor(h){this._map=h}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(h){this._map.fire(new Cu(h.type,this._map,h))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Cu("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(h){this._delayContextMenu?this._contextMenuEvent=h:this._map.fire(new Cu(h.type,this._map,h)),this._map.listens("contextmenu")&&h.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class yC{constructor(h,x){this._map=h,this._el=h.getCanvasContainer(),this._container=h.getContainer(),this._clickTolerance=x.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(h,x){this.isEnabled()&&h.shiftKey&&h.button===0&&(I(),this._startPos=this._lastPos=x,this._active=!0)}mousemoveWindow(h,x){if(!this._active)return;const A=x,D=this._startPos,F=this._lastPos;if(!D||!F||F.equals(A)||!this._box&&A.dist(D){this._box&&(this._box.style.transform=`translate(${z}px,${X}px)`,this._box.style.width=V-z+"px",this._box.style.height=ne-X+"px")})}mouseupWindow(h,x){if(!this._active)return;const A=this._startPos,D=x;if(A&&h.button===0){if(this.reset(),$(),A.x!==D.x||A.y!==D.y)return this._map.fire(new i.z("boxzoomend",{originalEvent:h})),{cameraAnimation:F=>F.fitScreenCoordinates(A,D,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",h)}}keydown(h){this._active&&h.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",h))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),L(),delete this._startPos,delete this._lastPos}_fireEvent(h,x){return this._map.fire(new i.z(h,{originalEvent:x}))}}function vC(M,h){const x={};for(let A=0;Athis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=h.timeStamp),A.length===this.numTouches&&(this.centroid=function(D){const F=new i.P(0,0);for(const z of D)F._add(z);return F.div(D.length)}(x),this.touches=vC(A,x)))}touchmove(h,x,A){if(this.aborted||!this.centroid)return;const D=vC(A,x);for(const F in this.touches){const z=D[F];(!z||z.dist(this.touches[F])>30)&&(this.aborted=!0)}}touchend(h,x,A){if((!this.centroid||h.timeStamp-this.startTime>500)&&(this.aborted=!0),A.length===0){const D=!this.aborted&&this.centroid;if(this.reset(),D)return D}}}class _C{constructor(h){this.singleTap=new cO(h),this.numTaps=h.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(h,x,A){this.singleTap.touchstart(h,x,A)}touchmove(h,x,A){this.singleTap.touchmove(h,x,A)}touchend(h,x,A){const D=this.singleTap.touchend(h,x,A);if(D){const F=h.timeStamp-this.lastTime<500,z=!this.lastTap||this.lastTap.dist(D)<30;if(F&&z||this.reset(),this.count++,this.lastTime=h.timeStamp,this.lastTap=D,this.count===this.numTaps)return this.reset(),D}}}class dO{constructor(){this._zoomIn=new _C({numTouches:1,numTaps:2}),this._zoomOut=new _C({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(h,x,A){this._zoomIn.touchstart(h,x,A),this._zoomOut.touchstart(h,x,A)}touchmove(h,x,A){this._zoomIn.touchmove(h,x,A),this._zoomOut.touchmove(h,x,A)}touchend(h,x,A){const D=this._zoomIn.touchend(h,x,A),F=this._zoomOut.touchend(h,x,A);return D?(this._active=!0,h.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:z=>z.easeTo({duration:300,zoom:z.getZoom()+1,around:z.unproject(D)},{originalEvent:h})}):F?(this._active=!0,h.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:z=>z.easeTo({duration:300,zoom:z.getZoom()-1,around:z.unproject(F)},{originalEvent:h})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const uO={0:1,2:2},YT={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class bC{constructor(h){this.reset(),this._clickTolerance=h.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(h,x){return!1}_move(h,x){return{}}mousedown(h,x){if(this._lastPoint)return;const A=H(h);this._correctButton(h,A)&&(this._lastPoint=x,this._eventButton=A)}mousemoveWindow(h,x){const A=this._lastPoint;if(A){if(h.preventDefault(),this._eventButton!=null&&function(D,F){const z=uO[F];return D.buttons===void 0||(D.buttons&z)!==z}(h,this._eventButton))this.reset();else if(this._moved||!(x.dist(A)0&&(this._active=!0);const D=vC(A,x),F=new i.P(0,0),z=new i.P(0,0);let V=0;for(const ne in D){const oe=D[ne],ge=this._touches[ne];ge&&(F._add(oe),z._add(oe.sub(ge)),V++,D[ne]=oe)}if(this._touches=D,V{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class wC{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(h){}_move(h,x,A){return{}}touchstart(h,x,A){this._firstTwoTouches||A.length<2||(this._firstTwoTouches=[A[0].identifier,A[1].identifier],this._start([x[0],x[1]]))}touchmove(h,x,A){const D=this._firstTwoTouches;if(!D)return;h.preventDefault();const[F,z]=D,V=Lb(A,x,F),X=Lb(A,x,z);if(!V||!X)return;const ne=this._aroundCenter?null:V.add(X).div(2);return this._move([V,X],ne,h)}touchend(h,x,A){if(!this._firstTwoTouches)return;const[D,F]=this._firstTwoTouches,z=Lb(A,x,D),V=Lb(A,x,F);z&&V||(this._active&&$(),this.reset())}touchcancel(){this.reset()}enable(h){this._enabled=!0,this._aroundCenter=!!h&&h.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Lb(M,h,x){for(let A=0;AMath.abs(M.x)}class pde extends wC{constructor(h){super(),this._map=h}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(h){this._lastPoints=h,jC(h[0].sub(h[1]))&&(this._valid=!1)}_move(h,x,A){const D=this._lastPoints;if(!D)return;const F=h[0].sub(D[0]),z=h[1].sub(D[1]);return this._map._cooperativeGestures&&!i.eU()&&A.touches.length<3||(this._valid=this.gestureBeginsVertically(F,z,A.timeStamp),!this._valid)?void 0:(this._lastPoints=h,this._active=!0,{pitchDelta:(F.y+z.y)/2*-.5})}gestureBeginsVertically(h,x,A){if(this._valid!==void 0)return this._valid;const D=h.mag()>=2,F=x.mag()>=2;if(!D&&!F)return;if(!D||!F)return this._firstMove==null&&(this._firstMove=A),A-this._firstMove<100&&void 0;const z=h.y>0==x.y>0;return jC(h)&&jC(x)&&z}}const fde={panStep:100,bearingStep:15,pitchStep:10};class gde{constructor(){const h=fde;this._panStep=h.panStep,this._bearingStep=h.bearingStep,this._pitchStep=h.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(h){if(h.altKey||h.ctrlKey||h.metaKey)return;let x=0,A=0,D=0,F=0,z=0;switch(h.keyCode){case 61:case 107:case 171:case 187:x=1;break;case 189:case 109:case 173:x=-1;break;case 37:h.shiftKey?A=-1:(h.preventDefault(),F=-1);break;case 39:h.shiftKey?A=1:(h.preventDefault(),F=1);break;case 38:h.shiftKey?D=1:(h.preventDefault(),z=-1);break;case 40:h.shiftKey?D=-1:(h.preventDefault(),z=1);break;default:return}return this._rotationDisabled&&(A=0,D=0),{cameraAnimation:V=>{const X=V.getZoom();V.easeTo({duration:300,easeId:"keyboardHandler",easing:Db,zoom:x?Math.round(X)+x*(h.shiftKey?2:1):X,bearing:V.getBearing()+A*this._bearingStep,pitch:V.getPitch()+D*this._pitchStep,offset:[-F*this._panStep,-z*this._panStep],center:V.getCenter()},{originalEvent:h})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Db(M){return M*(2-M)}const JT=4.000244140625,eA=1/450;class NC{constructor(h,x){this._map=h,this._el=h.getCanvasContainer(),this._handler=x,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=eA,i.aY(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(h){this._defaultZoomRate=h}setWheelZoomRate(h){this._wheelZoomRate=h}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(h){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!h&&h.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(h){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(h.ctrlKey||h.metaKey||this.isZooming()||i.eU()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let x=h.deltaMode===WheelEvent.DOM_DELTA_LINE?40*h.deltaY:h.deltaY;const A=i.o.now(),D=A-(this._lastWheelEventTime||0);this._lastWheelEventTime=A,x!==0&&x%JT==0?this._type="wheel":x!==0&&Math.abs(x)<4?this._type="trackpad":D>400?(this._type=null,this._lastValue=x,this._timeout=window.setTimeout(this._onTimeout,40,h)):this._type||(this._type=Math.abs(D*x)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,x+=this._lastValue)),h.shiftKey&&x&&(x/=4),this._type&&(this._lastWheelEvent=h,this._delta-=x,this._active||this._start(h)),h.preventDefault()}_onTimeout(h){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(h)}_start(h){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const x=q(this._el,h);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:x,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const h=this._map.transform;this._type==="wheel"&&h.projection.wrap&&(h._center.lng>=180||h._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const x=()=>h._terrainEnabled()&&this._aroundCoord?h.computeZoomRelativeTo(this._aroundCoord):h.zoom;if(this._delta!==0){const ne=this._type==="wheel"&&Math.abs(this._delta)>JT?this._wheelZoomRate:this._defaultZoomRate;let oe=2/(1+Math.exp(-Math.abs(this._delta*ne)));this._delta<0&&oe!==0&&(oe=1/oe);const ge=x(),pe=Math.pow(2,ge),xe=typeof this._targetZoom=="number"?h.zoomScale(this._targetZoom):pe;this._targetZoom=Math.min(h.maxZoom,Math.max(h.minZoom,h.scaleZoom(xe*oe))),this._type==="wheel"&&(this._startZoom=ge,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const A=typeof this._targetZoom=="number"?this._targetZoom:x(),D=this._startZoom,F=this._easing;let z,V=!1;if(this._type==="wheel"&&D&&F){const ne=Math.min((i.o.now()-this._lastWheelEventTime)/200,1),oe=F(ne);z=i.ak(D,A,oe),ne<1?this._frameId||(this._frameId=!0):V=!0}else z=A,V=!0;this._active=!0,V&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let X=z-x();return X*this._lastDelta<0&&(X=0),{noInertia:!0,needsRenderFrame:!V,zoomDelta:X,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(h){let x=i.eV;if(this._prevEase){const A=this._prevEase,D=(i.o.now()-A.start)/A.duration,F=A.easing(D+.01)-A.easing(D),z=.27/Math.sqrt(F*F+1e-4)*.01,V=Math.sqrt(.0729-z*z);x=i.eT(z,V,.25,1)}return this._prevEase={start:i.o.now(),duration:h,easing:x},x}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=w("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class Jf{constructor(h,x){this._clickZoom=h,this._tapZoom=x}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class kC{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(h,x){return h.preventDefault(),{cameraAnimation:A=>{A.easeTo({duration:300,zoom:A.getZoom()+(h.shiftKey?-1:1),around:A.unproject(x)},{originalEvent:h})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class wl{constructor(){this._tap=new _C({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(h,x,A){this._swipePoint||(this._tapTime&&h.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?A.length>0&&(this._swipePoint=x[0],this._swipeTouch=A[0].identifier):this._tap.touchstart(h,x,A))}touchmove(h,x,A){if(this._tapTime){if(this._swipePoint){if(A[0].identifier!==this._swipeTouch)return;const D=x[0],F=D.y-this._swipePoint.y;return this._swipePoint=D,h.preventDefault(),this._active=!0,{zoomDelta:F/128}}}else this._tap.touchmove(h,x,A)}touchend(h,x,A){this._tapTime?this._swipePoint&&A.length===0&&this.reset():this._tap.touchend(h,x,A)&&(this._tapTime=h.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class $p{constructor(h,x,A){this._el=h,this._mousePan=x,this._touchPan=A}enable(h){this._inertiaOptions=h||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Ob{constructor(h,x,A){this._pitchWithRotate=h.pitchWithRotate,this._mouseRotate=x,this._mousePitch=A}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class SC{constructor(h,x,A,D){this._el=h,this._touchZoom=x,this._touchRotate=A,this._tapDragZoom=D,this._rotationDisabled=!1,this._enabled=!0}enable(h){this._touchZoom.enable(h),this._rotationDisabled||this._touchRotate.enable(h),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Rb=M=>M.zoom||M.drag||M.pitch||M.rotate;class xde extends i.z{}class Fb{constructor(){this.constants=[1,1,.01],this.radius=0}setup(h,x){const A=i.av([],x,h);this.radius=i.ag(A[2]<0?i.eX([],A,this.constants):[A[0],A[1],0])}projectRay(h){i.eX(h,h,this.constants),i.aw(h,h),i.eY(h,h,this.constants);const x=i.c5([],h,this.radius);if(x[2]>0){const A=i.c5([],[0,0,1],i.bJ(x,[0,0,1])),D=i.c5([],i.aw([],[x[0],x[1],0]),this.radius),F=i.d8([],x,i.c5([],i.av([],i.d8([],D,A),x),2));x[0]=F[0],x[1]=F[1]}return x}}function CC(M){return M.panDelta&&M.panDelta.mag()||M.zoomDelta||M.bearingDelta||M.pitchDelta}class yde{constructor(h,x){this._map=h,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new GT(h),this._bearingSnap=x.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Fb,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(x),i.aY(["handleEvent","handleWindowEvent"],this);const A=this._el;this._listeners=[[A,"touchstart",{passive:!0}],[A,"touchmove",{passive:!1}],[A,"touchend",void 0],[A,"touchcancel",void 0],[A,"mousedown",void 0],[A,"mousemove",void 0],[A,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[A,"mouseover",void 0],[A,"mouseout",void 0],[A,"dblclick",void 0],[A,"click",void 0],[A,"keydown",{capture:!1}],[A,"keyup",void 0],[A,"wheel",{passive:!1}],[A,"contextmenu",void 0],[window,"blur",void 0]];for(const[D,F,z]of this._listeners){const V=D===document?this.handleWindowEvent:this.handleEvent;D.addEventListener(F,V,z)}}destroy(){for(const[h,x,A]of this._listeners){const D=h===document?this.handleWindowEvent:this.handleEvent;h.removeEventListener(x,D,A)}}_addDefaultHandlers(h){const x=this._map,A=x.getCanvasContainer();this._add("mapEvent",new xC(x,h));const D=x.boxZoom=new yC(x,h);this._add("boxZoom",D);const F=new dO,z=new kC;x.doubleClickZoom=new Jf(z,F),this._add("tapZoom",F),this._add("clickZoom",z);const V=new wl;this._add("tapDragZoom",V);const X=x.touchPitch=new pde(x);this._add("touchPitch",X);const ne=new XT(h),oe=new QT(h);x.dragRotate=new Ob(h,ne,oe),this._add("mouseRotate",ne,["mousePitch"]),this._add("mousePitch",oe,["mouseRotate"]);const ge=new hO(h),pe=new mO(x,h);x.dragPan=new $p(A,ge,pe),this._add("mousePan",ge),this._add("touchPan",pe,["touchZoom","touchRotate"]);const xe=new co,Pe=new mde;x.touchZoomRotate=new SC(A,Pe,xe,V),this._add("touchRotate",xe,["touchPan","touchZoom"]),this._add("touchZoom",Pe,["touchPan","touchRotate"]),this._add("blockableMapEvent",new ZT(x));const Ce=x.scrollZoom=new NC(x,this);this._add("scrollZoom",Ce,["mousePan"]);const Ve=x.keyboard=new gde;this._add("keyboard",Ve);for(const Be of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])h.interactive&&h[Be]&&x[Be].enable(h[Be])}_add(h,x,A){this._handlers.push({handlerName:h,handler:x,allowed:A}),this._handlersById[h]=x}stop(h){if(!this._updatingCamera){for(const{handler:x}of this._handlers)x.reset();this._inertia.clear(),this._fireEvents({},{},h),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:h}of this._handlers)if(h.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Rb(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(h,x,A){for(const D in h)if(D!==A&&(!x||x.indexOf(D)<0))return!0;return!1}handleWindowEvent(h){this.handleEvent(h,`${h.type}Window`)}_getMapTouches(h){const x=[];for(const A of h)this._el.contains(A.target)&&x.push(A);return x}handleEvent(h,x){this._updatingCamera=!0;const A=h.type==="renderFrame",D=A?void 0:h,F={needsRenderFrame:!1},z={},V={},X=h.touches?this._getMapTouches(h.touches):void 0,ne=X?U(this._el,X):A?void 0:q(this._el,h);for(const{handlerName:pe,handler:xe,allowed:Pe}of this._handlers){if(!xe.isEnabled())continue;let Ce;this._blockedByActive(V,Pe,pe)?xe.reset():xe[x||h.type]&&(Ce=xe[x||h.type](h,ne,X),this.mergeHandlerResult(F,z,Ce,pe,D),Ce&&Ce.needsRenderFrame&&this._triggerRenderFrame()),(Ce||xe.isActive())&&(V[pe]=xe)}const oe={};for(const pe in this._previousActiveHandlers)V[pe]||(oe[pe]=D);this._previousActiveHandlers=V,(Object.keys(oe).length||CC(F))&&(this._changes.push([F,z,oe]),this._triggerRenderFrame()),(Object.keys(V).length||CC(F))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:ge}=F;ge&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],ge(this._map))}mergeHandlerResult(h,x,A,D,F){if(!A)return;Object.assign(h,A);const z={handlerName:D,originalEvent:A.originalEvent||F};A.zoomDelta!==void 0&&(x.zoom=z),A.panDelta!==void 0&&(x.drag=z),A.pitchDelta!==void 0&&(x.pitch=z),A.bearingDelta!==void 0&&(x.rotate=z)}_applyChanges(){const h={},x={},A={};for(const[D,F,z]of this._changes)D.panDelta&&(h.panDelta=(h.panDelta||new i.P(0,0))._add(D.panDelta)),D.zoomDelta&&(h.zoomDelta=(h.zoomDelta||0)+D.zoomDelta),D.bearingDelta&&(h.bearingDelta=(h.bearingDelta||0)+D.bearingDelta),D.pitchDelta&&(h.pitchDelta=(h.pitchDelta||0)+D.pitchDelta),D.around!==void 0&&(h.around=D.around),D.aroundCoord!==void 0&&(h.aroundCoord=D.aroundCoord),D.pinchAround!==void 0&&(h.pinchAround=D.pinchAround),D.noInertia&&(h.noInertia=D.noInertia),Object.assign(x,F),Object.assign(A,z);this._updateMapTransform(h,x,A),this._changes=[]}_updateMapTransform(h,x,A){const D=this._map,F=D.transform,z=tt=>[tt.x,tt.y,tt.z];if((tt=>{const dt=this._eventsInProgress.drag;return dt&&!this._handlersById[dt.handlerName].isActive()})()&&!CC(h)){const tt=F.zoom;F.cameraElevationReference="sea",this._originalZoom!=null&&F._orthographicProjectionAtLowPitch&&F.projection.name!=="globe"&&F.pitch===0?(F.cameraElevationReference="ground",F.zoom=this._originalZoom):(F.recenterOnTerrain(),F.cameraElevationReference="ground"),tt!==F.zoom&&this._map._update(!0)}if(F._isCameraConstrained&&D._stop(!0),!CC(h))return void this._fireEvents(x,A,!0);let{panDelta:V,zoomDelta:X,bearingDelta:ne,pitchDelta:oe,around:ge,aroundCoord:pe,pinchAround:xe}=h;F._isCameraConstrained&&(X>0&&(X=0),F._isCameraConstrained=!1),xe!==void 0&&(ge=xe),(X||(tt=>x[tt]&&!this._eventsInProgress[tt])("drag"))&&ge&&(this._dragOrigin=z(F.pointCoordinate3D(ge)),this._originalZoom=F.zoom,this._trackingEllipsoid.setup(F._camera.position,this._dragOrigin)),F.cameraElevationReference="sea",D._stop(!0),ge=ge||D.transform.centerPoint,ne&&(F.bearing+=ne),oe&&(F.pitch+=oe),F._updateCameraState();const Pe=[0,0,0];if(V)if(F.projection.name==="mercator"){const tt=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(ge).dir),dt=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(ge.sub(V)).dir);Pe[0]=dt[0]-tt[0],Pe[1]=dt[1]-tt[1]}else{const tt=F.pointCoordinate(ge);if(F.projection.name==="globe"){V=V.rotate(-F.angle);const dt=F._pixelsPerMercatorPixel/F.worldSize;Pe[0]=-V.x*i.eW(i.a$(tt.y))*dt,Pe[1]=-V.y*i.eW(F.center.lat)*dt}else{const dt=F.pointCoordinate(ge.sub(V));tt&&dt&&(Pe[0]=dt.x-tt.x,Pe[1]=dt.y-tt.y)}}const Ce=F.zoom,Ve=[0,0,0];if(X){const tt=z(pe||F.pointCoordinate3D(ge)),dt={dir:i.aw([],i.av([],tt,F._camera.position))};if(dt.dir[2]<0){const st=F.zoomDeltaToMovement(tt,X);i.c5(Ve,dt.dir,st)}}const Be=i.d8(Pe,Pe,Ve);F._translateCameraConstrained(Be),X&&Math.abs(F.zoom-Ce)>1e-4&&F.recenterOnTerrain(),F.cameraElevationReference="ground",this._map._update(),h.noInertia||this._inertia.record(h),this._fireEvents(x,A,!0)}_fireEvents(h,x,A){const D=Rb(this._eventsInProgress),F=Rb(h),z={};for(const oe in h){const{originalEvent:ge}=h[oe];this._eventsInProgress[oe]||(z[`${oe}start`]=ge),this._eventsInProgress[oe]=h[oe]}!D&&F&&this._fireEvent("movestart",F.originalEvent);for(const oe in z)this._fireEvent(oe,z[oe]);F&&this._fireEvent("move",F.originalEvent);for(const oe in h){const{originalEvent:ge}=h[oe];this._fireEvent(oe,ge)}const V={};let X;for(const oe in this._eventsInProgress){const{handlerName:ge,originalEvent:pe}=this._eventsInProgress[oe];this._handlersById[ge].isActive()||(delete this._eventsInProgress[oe],X=x[ge]||pe,V[`${oe}end`]=X)}for(const oe in V)this._fireEvent(oe,V[oe]);const ne=Rb(this._eventsInProgress);if(A&&(D||F)&&!ne){this._updatingCamera=!0;const oe=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),ge=pe=>pe!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new xde("renderFrame",{timeStamp:h})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const MC="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class tA extends i.E{constructor(h,x){super(),this._moving=!1,this._zooming=!1,this.transform=h,this._bearingSnap=x.bearingSnap,this._respectPrefersReducedMotion=x.respectPrefersReducedMotion!==!1,i.aY(["_renderFrameCallback"],this)}getCenter(){return new i.aT(this.transform.center.lng,this.transform.center.lat)}setCenter(h,x){return this.jumpTo({center:h},x)}panBy(h,x,A){return h=i.P.convert(h).mult(-1),this.panTo(this.transform.center,Object.assign({offset:h},x),A)}panTo(h,x,A){return this.easeTo(Object.assign({center:h},x),A)}getZoom(){return this.transform.zoom}setZoom(h,x){return this.jumpTo({zoom:h},x),this}zoomTo(h,x,A){return this.easeTo(Object.assign({zoom:h},x),A)}zoomIn(h,x){return this.zoomTo(this.getZoom()+1,h,x),this}zoomOut(h,x){return this.zoomTo(this.getZoom()-1,h,x),this}getBearing(){return this.transform.bearing}setBearing(h,x){return this.jumpTo({bearing:h},x),this}getPadding(){return this.transform.padding}setPadding(h,x){return this.jumpTo({padding:h},x),this}rotateTo(h,x,A){return this.easeTo(Object.assign({bearing:h},x),A)}resetNorth(h,x){return this.rotateTo(0,Object.assign({duration:1e3},h),x),this}resetNorthPitch(h,x){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},h),x),this}snapToNorth(h,x){return Math.abs(this.getBearing())h.aspect?A/(2*Math.tan(.5*h.fovX)*h.aspect):D/(2*Math.tan(.5*h.fovY)*h.aspect)}_cameraForBoundsOnGlobe(h,x,A,D,F,z){const V=h.clone(),X=this._extendCameraOptions(z);V.bearing=D,V.pitch=F;const ne=i.aT.convert(x),oe=i.aT.convert(A),ge=.5*(ne.lat+oe.lat),pe=.5*(ne.lng+oe.lng),xe=i.eZ(ge,pe),Pe=i.aw([],xe),Ce=i.aw([],i.bI([],Pe,[0,1,0])),Ve=i.bI([],Ce,Pe),Be=[Ce[0],Ce[1],Ce[2],0,Ve[0],Ve[1],Ve[2],0,Pe[0],Pe[1],Pe[2],0,0,0,0,1],tt=[xe,i.eZ(ne.lat,ne.lng),i.eZ(oe.lat,ne.lng),i.eZ(oe.lat,oe.lng),i.eZ(ne.lat,oe.lng),i.eZ(ge,ne.lng),i.eZ(ge,oe.lng),i.eZ(ne.lat,pe),i.eZ(oe.lat,pe)];let dt=i.d9.fromPoints(tt.map(Jt=>[i.bJ(Ce,Jt),i.bJ(Ve,Jt),i.bJ(Pe,Jt)]));const st=i.af([],dt.center,Be);i.e_(st)===0&&i.e$(st,0,0,1),i.aw(st,st),i.c5(st,st,i.aD),V.center=i.f0(st);const Mt=V.getWorldToCameraMatrix(),yt=i.bl(new Float64Array(16),Mt);dt=i.d9.applyTransform(dt,i.aB([],Mt,Be));const jt=this._extendAABB(dt,V,X,D);if(!jt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");dt=jt,i.af(st,st,Mt);const gt=.5*(dt.max[2]-dt.min[2]),mt=this._minimumAABBFrustumDistance(V,dt),Et=i.c5([],[0,0,1],gt),Ht=i.d8(Et,st,Et),Ut=mt+(V.pitch===0?0:i.bG(st,Ht)),ts=V.globeCenterInViewSpace,ns=i.av([],st,[ts[0],ts[1],ts[2]]);i.aw(ns,ns),i.c5(ns,ns,Ut);const fs=i.d8([],st,ns);i.af(fs,fs,yt);const Bs=i.eM/i.aD,Yt=i.ag(fs),zt=i.cf(Math.max(Yt*Bs-i.eM,Number.EPSILON),0),ds=Math.min(V.zoomFromMercatorZAdjusted(zt),X.maxZoom);return ds>.5*(i.c_+i.cL)?(V.setProjection({name:"mercator"}),V.zoom=ds,this._cameraForBounds(V,x,A,D,F,z)):{center:V.center,zoom:ds,bearing:D,pitch:F}}_extendAABB(h,x,A,D){const F=.5*((A.padding.left||0)+(A.padding.right||0)),z=.5*((A.padding.top||0)+(A.padding.bottom||0)),V=z,X=F,ne=F,oe=z,ge=x.width-(X+ne),pe=x.height-(V+oe),xe=i.av([],h.max,h.min),Pe=Math.min(ge/xe[0],pe/xe[1]),Ce=Math.min(x.scaleZoom(x.scale*Pe),A.maxZoom);if(isNaN(Ce))return null;const Ve=x.scale/x.zoomScale(Ce),Be=new i.d9([h.min[0]-X*Ve,h.min[1]-oe*Ve,h.min[2]],[h.max[0]+ne*Ve,h.max[1]+V*Ve,h.max[2]]),tt=(typeof A.offset.x=="number"&&typeof A.offset.y=="number"?new i.P(A.offset.x,A.offset.y):i.P.convert(A.offset)).rotate(-i.an(D));return Be.center[0]-=tt.x*Ve,Be.center[1]+=tt.y*Ve,Be}queryTerrainElevation(h,x){const A=this.transform.elevation;return A?(x=Object.assign({},{exaggerated:!0},x),A.getAtPoint(i.ae.fromLngLat(h),null,x.exaggerated)):null}_cameraForBounds(h,x,A,D,F,z){if(h.projection.name==="globe")return this._cameraForBoundsOnGlobe(h,x,A,D,F,z);const V=h.clone(),X=this._extendCameraOptions(z);V.bearing=D,V.pitch=F;const ne=i.aT.convert(x),oe=i.aT.convert(A),ge=new i.aT(ne.lng,oe.lat),pe=new i.aT(oe.lng,ne.lat),xe=V.project(ne),Pe=V.project(oe),Ce=this.queryTerrainElevation(ne),Ve=this.queryTerrainElevation(oe),Be=this.queryTerrainElevation(ge),tt=this.queryTerrainElevation(pe),dt=[[xe.x,xe.y,Math.min(Ce||0,Ve||0,Be||0,tt||0)],[Pe.x,Pe.y,Math.max(Ce||0,Ve||0,Be||0,tt||0)]];let st=i.d9.fromPoints(dt);const Mt=V.getWorldToCameraMatrix(),yt=i.bl(new Float64Array(16),Mt);st=i.d9.applyTransform(st,Mt);const jt=this._extendAABB(st,V,X,D);if(!jt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");st=jt;const gt=.5*i.av([],st.max,st.min)[2],mt=this._minimumAABBFrustumDistance(V,st),Et=[0,0,1,0];i.aC(Et,Et,Mt),i.f1(Et,Et);const Ht=i.c5([],Et,mt+gt),Ut=i.d8([],st.center,Ht);i.af(st.center,st.center,yt),i.af(Ut,Ut,yt);const ts=V.unproject(new i.P(st.center[0],st.center[1])),ns=i.f2(V.projection,ts),fs=Math.pow(2,ns),Bs=Math.min(V._zoomFromMercatorZ(Ut[2]*V.pixelsPerMeter*fs/V.worldSize),X.maxZoom);return V.mercatorFromTransition&&Bs<.5*(i.c_+i.cL)?(V.setProjection({name:"globe"}),V.zoom=Bs,this._cameraForBounds(V,x,A,D,F,z)):{center:ts,zoom:Bs,bearing:D,pitch:F}}fitBounds(h,x,A){const D=this.cameraForBounds(h,x);return this._fitInternal(D,x,A)}fitScreenCoordinates(h,x,A,D,F){const z=i.P.convert(h),V=i.P.convert(x),X=new i.P(Math.min(z.x,V.x),Math.min(z.y,V.y)),ne=new i.P(Math.max(z.x,V.x),Math.max(z.y,V.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(z,V))return this;const oe=this.transform.pointLocation3D(X),ge=this.transform.pointLocation3D(ne),pe=this.transform.pointLocation3D(new i.P(X.x,ne.y)),xe=this.transform.pointLocation3D(new i.P(ne.x,X.y)),Pe=[Math.min(oe.lng,ge.lng,pe.lng,xe.lng),Math.min(oe.lat,ge.lat,pe.lat,xe.lat)],Ce=[Math.max(oe.lng,ge.lng,pe.lng,xe.lng),Math.max(oe.lat,ge.lat,pe.lat,xe.lat)],Ve=D&&D.pitch?D.pitch:this.getPitch(),Be=this._cameraForBounds(this.transform,Pe,Ce,A,Ve,D);return this._fitInternal(Be,D,F)}_fitInternal(h,x,A){return h?(x=Object.assign(h,x)).linear?this.easeTo(x,A):this.flyTo(x,A):this}jumpTo(h,x){this.stop();const A=h.preloadOnly?this.transform.clone():this.transform;let D=!1,F=!1,z=!1;"zoom"in h&&A.zoom!==+h.zoom&&(D=!0,A.zoom=+h.zoom),h.center!==void 0&&(A.center=i.aT.convert(h.center)),"bearing"in h&&A.bearing!==+h.bearing&&(F=!0,A.bearing=+h.bearing),"pitch"in h&&A.pitch!==+h.pitch&&(z=!0,A.pitch=+h.pitch);const V=typeof h.padding=="number"?this._extendPadding(h.padding):h.padding;if(h.padding!=null&&!A.isPaddingEqual(V))if(h.retainPadding===!1){const X=A.clone();X.padding=V,A.setLocationAtPoint(A.center,X.centerPoint)}else A.padding=V;return h.preloadOnly?(this._preloadTiles(A),this):(this.fire(new i.z("movestart",x)).fire(new i.z("move",x)),D&&this.fire(new i.z("zoomstart",x)).fire(new i.z("zoom",x)).fire(new i.z("zoomend",x)),F&&this.fire(new i.z("rotatestart",x)).fire(new i.z("rotate",x)).fire(new i.z("rotateend",x)),z&&this.fire(new i.z("pitchstart",x)).fire(new i.z("pitch",x)).fire(new i.z("pitchend",x)),this.fire(new i.z("moveend",x)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||i.w(MC),this.transform.getFreeCameraOptions()}setFreeCameraOptions(h,x){const A=this.transform;if(!A.projection.supportsFreeCamera)return i.w(MC),this;this.stop();const D=A.zoom,F=A.pitch,z=A.bearing;A.setFreeCameraOptions(h);const V=D!==A.zoom,X=F!==A.pitch,ne=z!==A.bearing;return this.fire(new i.z("movestart",x)).fire(new i.z("move",x)),V&&this.fire(new i.z("zoomstart",x)).fire(new i.z("zoom",x)).fire(new i.z("zoomend",x)),ne&&this.fire(new i.z("rotatestart",x)).fire(new i.z("rotate",x)).fire(new i.z("rotateend",x)),X&&this.fire(new i.z("pitchstart",x)).fire(new i.z("pitch",x)).fire(new i.z("pitchend",x)),this.fire(new i.z("moveend",x)),this}easeTo(h,x){this._stop(!1,h.easeId),((h=Object.assign({offset:[0,0],duration:500,easing:i.eV},h)).animate===!1||this._prefersReducedMotion(h))&&(h.duration=0);const A=this.transform,D=this.getZoom(),F=this.getBearing(),z=this.getPitch(),V=this.getPadding(),X="zoom"in h?+h.zoom:D,ne="bearing"in h?this._normalizeBearing(h.bearing,F):F,oe="pitch"in h?+h.pitch:z,ge=this._extendPadding(h.padding),pe=i.P.convert(h.offset);let xe,Pe,Ce;if(A.projection.name==="globe"){const Et=i.ae.fromLngLat(A.center),Ht=pe.rotate(-A.angle);Et.x+=Ht.x/A.worldSize,Et.y+=Ht.y/A.worldSize;const Ut=Et.toLngLat(),ts=i.aT.convert(h.center||Ut);this._normalizeCenter(ts),xe=A.centerPoint.add(Ht),Pe=new i.P(Et.x,Et.y).mult(A.worldSize),Ce=new i.P(i.aF(ts.lng),i.aJ(ts.lat)).mult(A.worldSize).sub(Pe)}else{xe=A.centerPoint.add(pe);const Et=A.pointLocation(xe),Ht=i.aT.convert(h.center||Et);this._normalizeCenter(Ht),Pe=A.project(Et),Ce=A.project(Ht).sub(Pe)}const Ve=A.zoomScale(X-D);let Be,tt;h.around&&(Be=i.aT.convert(h.around),tt=A.locationPoint(Be));const dt=this._zooming||X!==D,st=this._rotating||F!==ne,Mt=this._pitching||oe!==z,yt=!A.isPaddingEqual(ge),jt=h.retainPadding===!1?A.clone():A,gt=Et=>Ht=>{if(dt&&(Et.zoom=i.ak(D,X,Ht)),st&&(Et.bearing=i.ak(F,ne,Ht)),Mt&&(Et.pitch=i.ak(z,oe,Ht)),yt&&(jt.interpolatePadding(V,ge,Ht),xe=jt.centerPoint.add(pe)),Be)Et.setLocationAtPoint(Be,tt);else{const Ut=Et.zoomScale(Et.zoom-D),ts=X>D?Math.min(2,Ve):Math.max(.5,Ve),ns=Math.pow(ts,1-Ht),fs=Et.unproject(Pe.add(Ce.mult(Ht*ns)).mult(Ut));Et.setLocationAtPoint(Et.renderWorldCopies?fs.wrap():fs,xe)}return h.preloadOnly||this._fireMoveEvents(x),Et};if(h.preloadOnly){const Et=this._emulate(gt,h.duration,A);return this._preloadTiles(Et),this}const mt={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=dt,this._rotating=st,this._pitching=Mt,this._padding=yt,this._easeId=h.easeId,this._prepareEase(x,h.noMoveStart,mt),this._ease(gt(A),Et=>{A.cameraElevationReference==="sea"&&A.recenterOnTerrain(),this._afterEase(x,Et)},h),this}_prepareEase(h,x,A={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),x||A.moving||this.fire(new i.z("movestart",h)),this._zooming&&!A.zooming&&this.fire(new i.z("zoomstart",h)),this._rotating&&!A.rotating&&this.fire(new i.z("rotatestart",h)),this._pitching&&!A.pitching&&this.fire(new i.z("pitchstart",h))}_fireMoveEvents(h){this.fire(new i.z("move",h)),this._zooming&&this.fire(new i.z("zoom",h)),this._rotating&&this.fire(new i.z("rotate",h)),this._pitching&&this.fire(new i.z("pitch",h))}_afterEase(h,x){if(this._easeId&&x&&this._easeId===x)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const A=this._zooming,D=this._rotating,F=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,A&&this.fire(new i.z("zoomend",h)),D&&this.fire(new i.z("rotateend",h)),F&&this.fire(new i.z("pitchend",h)),this.fire(new i.z("moveend",h))}flyTo(h,x){if(this._prefersReducedMotion(h)){const Jt=i.aH(h,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(Jt,x)}this.stop(),h=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:i.eV},h);const A=this.transform,D=this.getZoom(),F=this.getBearing(),z=this.getPitch(),V=this.getPadding(),X="zoom"in h?i.aA(+h.zoom,A.minZoom,A.maxZoom):D,ne="bearing"in h?this._normalizeBearing(h.bearing,F):F,oe="pitch"in h?+h.pitch:z,ge=this._extendPadding(h.padding),pe=A.zoomScale(X-D),xe=i.P.convert(h.offset);let Pe=A.centerPoint.add(xe);const Ce=A.pointLocation(Pe),Ve=i.aT.convert(h.center||Ce);this._normalizeCenter(Ve);const Be=A.project(Ce),tt=A.project(Ve).sub(Be);let dt=h.curve;const st=Math.max(A.width,A.height),Mt=st/pe,yt=tt.mag();if("minZoom"in h){const Jt=i.aA(Math.min(h.minZoom,D,X),A.minZoom,A.maxZoom),Es=st/A.zoomScale(Jt-D);dt=Math.sqrt(Es/yt*2)}const jt=dt*dt;function gt(Jt){const Es=(Mt*Mt-st*st+(Jt?-1:1)*jt*jt*yt*yt)/(2*(Jt?Mt:st)*jt*yt);return Math.log(Math.sqrt(Es*Es+1)-Es)}function mt(Jt){return(Math.exp(Jt)-Math.exp(-Jt))/2}function Et(Jt){return(Math.exp(Jt)+Math.exp(-Jt))/2}const Ht=gt(0);let Ut=function(Jt){return Et(Ht)/Et(Ht+dt*Jt)},ts=function(Jt){return st*((Et(Ht)*(mt(Es=Ht+dt*Jt)/Et(Es))-mt(Ht))/jt)/yt;var Es},ns=(gt(1)-Ht)/dt;if(Math.abs(yt)<1e-6||!isFinite(ns)){if(Math.abs(st-Mt)<1e-6)return this.easeTo(h,x);const Jt=Mth.maxDuration&&(h.duration=0);const fs=F!==ne,Bs=oe!==z,Yt=!A.isPaddingEqual(ge),zt=h.retainPadding===!1?A.clone():A,ds=Jt=>Es=>{const Js=Es*ns,mr=1/Ut(Js);Jt.zoom=Es===1?X:D+Jt.scaleZoom(mr),fs&&(Jt.bearing=i.ak(F,ne,Es)),Bs&&(Jt.pitch=i.ak(z,oe,Es)),Yt&&(zt.interpolatePadding(V,ge,Es),Pe=zt.centerPoint.add(xe));const Ys=Es===1?Ve:Jt.unproject(Be.add(tt.mult(ts(Js))).mult(mr));return Jt.setLocationAtPoint(Jt.renderWorldCopies?Ys.wrap():Ys,Pe),Jt._updateCameraOnTerrain(),h.preloadOnly||this._fireMoveEvents(x),Jt};if(h.preloadOnly){const Jt=this._emulate(ds,h.duration,A);return this._preloadTiles(Jt),this}return this._zooming=!0,this._rotating=fs,this._pitching=Bs,this._padding=Yt,this._prepareEase(x,!1),this._ease(ds(A),()=>this._afterEase(x),h),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(h){}_cancelRenderFrame(h){}_stop(h,x){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const A=this._onEaseEnd;this._onEaseEnd=void 0,A.call(this,x)}if(!h){const A=this.handlers;A&&A.stop(!1)}return this}_ease(h,x,A){A.animate===!1||A.duration===0?(h(1),x()):(this._easeStart=i.o.now(),this._easeOptions=A,this._onEaseFrame=h,this._onEaseEnd=x,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const h=Math.min((i.o.now()-this._easeStart)/this._easeOptions.duration,1),x=this._onEaseFrame;x&&x(this._easeOptions.easing(h)),h<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(h,x){h=i.bT(h,-180,180);const A=Math.abs(h-x);return Math.abs(h-360-x)180?-360:A<-180?360:0}_prefersReducedMotion(h){return this._respectPrefersReducedMotion&&i.o.prefersReducedMotion&&!(h&&h.essential)}_emulate(h,x,A){const D=Math.ceil(15*x/1e3),F=[],z=h(A.clone());for(let V=0;V<=D;V++){const X=z(V/D);F.push(X.clone())}return F}_preloadTiles(h,x){}}class zb{constructor(h={}){this.options=h,i.aY(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(h){const x=this.options&&this.options.compact,A=h._getUIString("AttributionControl.ToggleAttribution");this._map=h,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=w("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",A);const D=w("span","mapboxgl-ctrl-icon",this._compactButton);return D.setAttribute("aria-hidden","true"),D.setAttribute("title",A),this._innerContainer=w("div","mapboxgl-ctrl-attrib-inner",this._container),x&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),x===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let h=this._editLink;h||(h=this._editLink=this._container.querySelector(".mapbox-improve-map"));const x=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||i.e.ACCESS_TOKEN}];if(h){const A=x.reduce((D,F,z)=>(F.value&&(D+=`${F.key}=${F.value}${zD.length-F.length),h=h.filter((D,F)=>{for(let z=F+1;z=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?h=[...this.options.customAttribution,...h]:h.unshift(this.options.customAttribution));const A=h.map(D=>function(F){const z=new DOMParser().parseFromString(F,"text/html");return Array.from(z.body.querySelectorAll("*")).forEach(V=>{const X=V.textContent||"";if(V.tagName!=="A")return void V.replaceWith(z.createTextNode(X));const ne=V.getAttribute("href");if(!ne||!/^(https?:|mailto:)/i.test(ne))return void V.replaceWith(z.createTextNode(X));const oe=z.createElement("a");oe.href=ne,oe.textContent=X,oe.rel="noopener nofollow";const ge=V.getAttribute("class");ge&&(oe.className=ge),V.replaceWith(oe)}),z.body.innerHTML}(D)).join(" | ");A!==this._attribHTML&&(this._attribHTML=A,h.length?(this._innerContainer.innerHTML=A,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class Bb{constructor(){i.aY(["_updateLogo","_updateCompact"],this)}onAdd(h){this._map=h,this._container=w("div","mapboxgl-ctrl");const x=w("a","mapboxgl-ctrl-logo");return x.target="_blank",x.rel="noopener nofollow",x.href="https://www.mapbox.com/",x.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),x.setAttribute("rel","noopener nofollow"),this._container.appendChild(x),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(h){h&&h.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const h=this._map.style._sourceCaches;if(Object.entries(h).length===0)return!0;for(const x in h){const A=h[x].getSource();if(A.hasOwnProperty("mapbox_logo")&&!A.mapbox_logo)return!1}return!0}_updateCompact(){const h=this._container.children;if(h.length){const x=h[0];this._map.getCanvasContainer().offsetWidth<250?x.classList.add("mapboxgl-compact"):x.classList.remove("mapboxgl-compact")}}}class Bv{constructor(){i.aY(["_onIndoorUpdate"],this)}onAdd(h){return this._map=h,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("selector-update",x=>this._onIndoorUpdate(x)),this._container}_createButton(h,x){const A=w("button",h,this._container);return A.type="button",A.addEventListener("click",x),A}_createSeparator(){return w("div","mapboxgl-ctrl-separator",this._container)}_setButtonTitle(h,x){this._map&&(h.setAttribute("aria-label",x),h.textContent=x)}onRemove(){this._container&&this._container.remove(),this._map&&this._map.indoor&&(this._map.indoor.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"right"}_onIndoorUpdate(h){if(!h||!h.floors)return this._model=h,void(this._container.style.display="none");const x=this._model;this._model=h,this._container.style.display="inline-block",this._container.style.borderRadius="8px",x&&Array.from(this._container.children).forEach(A=>A.remove()),h.floors.length>0&&(this.addBuildingsToggleButton(),this.addCurrentFloors(h.floors,h.activeFloorsVisible),this._updateBuildingsButtonState())}addBuildingsToggleButton(){const h=this._createButton("mapboxgl-ctrl-buildings-toggle",()=>{const x=this._map;this._model&&x&&x._setIndoorActiveFloorsVisibility(!this._model.activeFloorsVisible)});w("span","mapboxgl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.classList.add("mapboxgl-ctrl-level-button","mapboxgl-ctrl-buildings-toggle"),this._model&&!this._model.activeFloorsVisible&&h.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(h),this._createSeparator()}_updateBuildingsButtonState(){const h=this._container.querySelector(".mapboxgl-ctrl-buildings-toggle");h&&this._model&&(this._model.activeFloorsVisible?h.classList.remove("mapboxgl-ctrl-level-button-selected"):h.classList.add("mapboxgl-ctrl-level-button-selected"))}addCurrentFloors(h,x){for(let A=0;A{this._map._selectIndoorFloor(D.id)});this._setButtonTitle(F,D.zIndex.toString()),this._model&&D.id===this._model.selectedFloorId&&x&&F.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(F),A=this._endTime)return this._end;const x=i.dD((h-this._startTime)/(this._endTime-this._startTime));return this._start*(1-x)+this._end*x}isEasing(h){return h>=this._startTime&&h<=this._endTime}jumpTo(h){this._startTime=-1/0,this._endTime=-1/0,this._start=h,this._end=h}easeTo(h,x,A){this._start=this.getValue(x),this._end=h,this._startTime=x,this._endTime=x+A}}const sg={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"};class wx extends i.z{constructor(h,x,A,D){const{point:F,lngLat:z,originalEvent:V,target:X}=h;super(h.type,{point:F,lngLat:z,originalEvent:V,target:X}),this.preventDefault=()=>{h.preventDefault()},this.id=x,this.interaction=A,this.feature=D}}class Xm{constructor(h){this.map=h,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map}add(h,x){if(this.typeById.has(h))throw new Error(`Interaction id "${h}" already exists.`);const A=x.filter;let D=x.type;A&&this.filters.set(h,i.b6(A)),D==="mouseover"&&(D="mouseenter"),D==="mouseout"&&(D="mouseleave");const F=this.interactionsByType.get(D)||new Map;D==="mouseenter"||D==="mouseleave"?(this.delegatedInteractions.size===0&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(h,x)):F.size===0&&this.map.on(D,this.handleType),F.size===0&&this.interactionsByType.set(D,F),F.set(h,x),this.typeById.set(h,D)}get(h){const x=this.typeById.get(h);if(!x)return;const A=this.interactionsByType.get(x);return A?A.get(h):void 0}remove(h){const x=this.typeById.get(h);if(!x)return;this.typeById.delete(h),this.filters.delete(h);const A=this.interactionsByType.get(x);A&&(A.delete(h),x==="mouseenter"||x==="mouseleave"?(this.delegatedInteractions.delete(h),this.delegatedInteractions.size===0&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):A.size===0&&this.map.off(x,this.handleType))}queryTargets(h,x){const A=[];for(const[D,F]of x)F.target&&A.push({targetId:D,target:F.target,filter:this.filters.get(D)});return this.map.style.queryRenderedTargets(h,A,this.map.transform)}handleMove(h){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const x=this.queryTargets(h.point,Array.from(this.delegatedInteractions).reverse());x.length&&(h.type="mouseenter",this.handleType(h,x));const A=new Map;for(const[D,{feature:F}]of this.prevHoveredFeatures)this.hoveredFeatures.has(D)||A.set(F.id,F);A.size&&(h.type="mouseleave",this.handleType(h,Array.from(A.values())))}handleOut(h){const x=Array.from(this.hoveredFeatures.values()).map(({feature:A})=>A);x.length&&(h.type="mouseleave",this.handleType(h,x)),this.hoveredFeatures.clear()}handleType(h,x){const A=h.type==="mouseenter";if(A&&!this.interactionsByType.has(h.type))return void i.w("mouseenter interaction required for mouseleave to work.");const D=Array.from(this.interactionsByType.get(h.type)).reverse(),F=!!x;x=x||this.queryTargets(h.point,D);let z=!1;const V=new Set;for(const X of x){for(const[ne,oe]of D){if(!oe.target)continue;const ge=X.variants?X.variants[ne]:null;if(ge){for(const pe of ge){if(ax(pe,X,V,ne))continue;const xe=new i.dx(X,pe),Pe=Bf(pe,X,ne);F&&xe.id!==void 0&&(xe.state=this.map.getFeatureState(xe));const Ce=A?this.prevHoveredFeatures.get(Pe):null,Ve=new wx(h,ne,oe,xe),Be=Ce?Ce.stop:oe.handler(Ve);if(A&&this.hoveredFeatures.set(Pe,{feature:X,stop:Be}),Be!==!1){z=!0;break}}if(z)break}}if(z)break}if(!z)for(const[X,ne]of D){const{handler:oe,target:ge}=ne;if(!ge&&oe(new wx(h,X,ne,null))!==!1)break}}}function vde(M,h){if(Array.isArray(M)&&Array.isArray(h)){const x=new Set(M),A=new Set(h);return x.size===A.size&&M.every(D=>A.has(D))}return i.by(M,h)}const _de={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1,spriteFormat:"auto"},bde={showCompass:!0,showZoom:!0,visualizePitch:!1};class wde{constructor(h,x,A=!1){this._clickTolerance=10,this.element=x,this.mouseRotate=new XT({clickTolerance:h.dragRotate._mouseRotate._clickTolerance}),this.map=h,A&&(this.mousePitch=new QT({clickTolerance:h.dragRotate._mousePitch._clickTolerance})),i.aY(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),x.addEventListener("mousedown",this.mousedown),x.addEventListener("touchstart",this.touchstart,{passive:!1}),x.addEventListener("touchmove",this.touchmove),x.addEventListener("touchend",this.touchend),x.addEventListener("touchcancel",this.reset)}down(h,x){this.mouseRotate.mousedown(h,x),this.mousePitch&&this.mousePitch.mousedown(h,x),I()}move(h,x){const A=this.map,D=this.mouseRotate.mousemoveWindow(h,x),F=D&&D.bearingDelta;if(F&&A.setBearing(A.getBearing()+F),this.mousePitch){const z=this.mousePitch.mousemoveWindow(h,x),V=z&&z.pitchDelta;V&&A.setPitch(A.getPitch()+V)}}off(){const h=this.element;h.removeEventListener("mousedown",this.mousedown),h.removeEventListener("touchstart",this.touchstart),h.removeEventListener("touchmove",this.touchmove),h.removeEventListener("touchend",this.touchend),h.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){L(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(h){this.down(Object.assign({},h,{ctrlKey:!0,preventDefault:()=>h.preventDefault()}),q(this.element,h)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(h){this.move(h,q(this.element,h))}mouseup(h){this.mouseRotate.mouseupWindow(h),this.mousePitch&&this.mousePitch.mouseupWindow(h),this.offTemp()}touchstart(h){h.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=U(this.element,h.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>h.preventDefault()},this._startPos))}touchmove(h){h.targetTouches.length!==1?this.reset():(this._lastPos=U(this.element,h.targetTouches)[0],this.move({preventDefault:()=>h.preventDefault()},this._lastPos))}touchend(h){h.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)x.width||h.y>x.height;x.locationPoint3D(A).distSqr(h)180;){const A=x.locationPoint3D(M);if(A.x>=0&&A.y>=0&&A.x<=x.width&&A.y<=x.height)break;M.lng>x.center.lng?M.lng-=360:M.lng+=360}return M}const pd={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"},dm={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class TC extends i.E{constructor(h,x){super(),(h instanceof HTMLElement||x)&&(h=Object.assign({element:h},x)),i.aY(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:A="center",color:D="#3FB1CE",scale:F=1,draggable:z=!1,clickTolerance:V=0,rotation:X=dm.rotation,rotationAlignment:ne=dm.rotationAlignment,pitchAlignment:oe=dm.pitchAlignment,occludedOpacity:ge=dm.occludedOpacity,altitude:pe=dm.altitude}=h||{};this._anchor=A,this._color=D,this._scale=F,this._draggable=z,this._clickTolerance=V,this._rotation=X,this._rotationAlignment=ne,this._pitchAlignment=oe,this._occludedOpacity=ge,this._altitude=pe,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),h&&h.element?(this._element=h.element,this._offset=i.P.convert(h&&h.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=i.P.convert(h&&h.offset||[0,-14])),this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",Ce=>{Ce.preventDefault()}),this._element.addEventListener("mousedown",Ce=>{Ce.preventDefault()});const xe=this._element.classList;for(const Ce in pd)xe.remove(`mapboxgl-marker-anchor-${Ce}`);xe.add(`mapboxgl-marker-anchor-${this._anchor}`);const Pe=h&&h.className?h.className.trim().split(/\s+/):[];xe.add(...Pe),this._popup=null}_createDefaultMarker(){const h=w("div"),x=j("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},h);if(this._altitude===0){const A=j("radialGradient",{id:"shadowGradient"},j("defs",{},x));j("stop",{offset:"10%","stop-opacity":.4},A),j("stop",{offset:"100%","stop-opacity":.05},A),j("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},x)}return j("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},x),j("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},x),j("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},x),h}addTo(h){return h===this._map||(this.remove(),this._map=h,h.getCanvasContainer().appendChild(this._element),h.on("move",this._updateMoving),h.on("moveend",this._update),h.on("remove",this._clearFadeTimer),h._addMarker(this),this.setDraggable(this._draggable),this._update(),h.on("click",this._onMapClick)),this}remove(){const h=this._map;return h&&(h.off("click",this._onMapClick),h.off("move",this._updateMoving),h.off("moveend",this._update),h.off("mousedown",this._addDragHandler),h.off("touchstart",this._addDragHandler),h.off("mouseup",this._onUp),h.off("touchend",this._onUp),h.off("mousemove",this._onMove),h.off("touchmove",this._onMove),h.off("remove",this._clearFadeTimer),h._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=i.aT.convert(h),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(h){return h===this._altitude||(this._defaultMarker&&(this._altitude===0&&h!==0||this._altitude!==0&&h===0)&&(this._element=this._createDefaultMarker()),this._altitude=h||dm.altitude,this._update()),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(h){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),h){if(!("offset"in h.options)){const D=Math.sqrt(Math.pow(13.5,2)/2);h.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[D,-1*(38.1-13.5+D)],"bottom-right":[-D,-1*(38.1-13.5+D)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=h,h._marker=this,h._altitude=this._altitude,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(h){const x=h.code,A=h.charCode||h.keyCode;x!=="Space"&&x!=="Enter"&&A!==32&&A!==13||this.togglePopup()}_onMapClick(h){const x=h.originalEvent.target,A=this._element;this._popup&&(x===A||A.contains(x))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const h=this._popup;return h?(h.isOpen()?(h.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(h.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const h=this._map,x=this._pos;if(!h||!x)return!1;const A=h.unproject(x,this._altitude),D=h.getFreeCameraOptions();if(!D.position)return!1;const F=D.position.toLngLat();return F.distanceTo(A)<.9*F.distanceTo(this._lngLat)}_evaluateOpacity(){const h=this._map;if(!h)return;const x=this._pos;if(!x||x.x<0||x.x>h.transform.width||x.y<0||x.y>h.transform.height)return void this._clearFadeTimer();const A=h.unproject(x,this._altitude);let D;h._showingGlobe()&&i.f5(h.transform,this._lngLat)?D=0:(D=1-h._queryFogOpacity(A),h.transform._terrainEnabled()&&h.getTerrain()&&this._behindTerrain()&&(D*=this._occludedOpacity)),this._element.style.opacity=`${D}`,this._element.style.pointerEvents=D>0?"auto":"none",this._popup&&this._popup._setOpacity(D),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const h=this._pos;if(!h||!this._map)return;const x=this._offset.mult(this._scale);this._element.style.transform=` translate(${h.x}px,${h.y}px) ${pd[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${x.x}px,${x.y}px) `}_calculateXYTransform(){const h=this._pos,x=this._map,A=this.getPitchAlignment();if(!x||!h||A!=="map")return"";if(!x._showingGlobe()){const X=x.getPitch();return X?`rotateX(${X}deg)`:""}const D=i.cX(i.f6(x.transform,this._lngLat)),F=h.sub(i.f7(x.transform)),z=Math.abs(F.x)+Math.abs(F.y);if(z===0)return"";const V=D/z;return`rotateX(${-F.y*V}deg) rotateY(${F.x*V}deg)`}_calculateZTransform(){const h=this._pos,x=this._map;if(!x||!h)return"";let A=0;const D=this.getRotationAlignment();if(D==="map")if(x._showingGlobe()){const F=x.project(new i.aT(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),z=x.project(new i.aT(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(F);A=i.cX(Math.atan2(z.y,z.x))-90}else A=-x.getBearing();else if(D==="horizon"){const F=i.ah(4,6,x.getZoom()),z=i.f7(x.transform);z.y+=F*x.transform.height;const V=h.sub(z),X=i.cX(Math.atan2(V.y,V.x));A=(X>90?X-270:X+90)*(1-F)}return A+=this._rotation,A?`rotateZ(${A}deg)`:""}_update(h){cancelAnimationFrame(this._updateFrameId);const x=this._map;x&&(x.transform.renderWorldCopies&&(this._lngLat=sA(this._lngLat,this._pos,x.transform)),this._pos=x.project(this._lngLat,this._altitude),h===!0?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),x._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(x._showingGlobe()||x.getTerrain()||x.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(h){return this._offset=i.P.convert(h),this._update(),this}addClassName(h){return this._element.classList.add(h),this}removeClassName(h){return this._element.classList.remove(h),this}toggleClassName(h){return this._element.classList.toggle(h)}_onMove(h){const x=this._map;if(!x)return;const A=this._pointerdownPos,D=this._positionDelta;if(A&&D){if(!this._isDragging){const F=this._clickTolerance||x._clickTolerance;if(h.point.dist(A)M.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(M.minPitch!=null&&M.maxPitch!=null&&M.minPitch>M.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(M.minPitch!=null&&M.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(M.maxPitch!=null&&M.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(M.antialias&&i.f3(window)&&(M.antialias=!1,i.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new iT(M.minZoom,M.maxZoom,M.minPitch,M.maxPitch,M.renderWorldCopies,null,null),M),this._repaint=!!M.repaint,this._interactive=M.interactive,this._minTileCacheSize=M.minTileCacheSize,this._maxTileCacheSize=M.maxTileCacheSize,this._failIfMajorPerformanceCaveat=M.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=M.preserveDrawingBuffer,this._antialias=M.antialias,this._trackResize=M.trackResize,this._bearingSnap=M.bearingSnap,this._refreshExpiredTiles=M.refreshExpiredTiles,this._fadeDuration=M.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=M.crossSourceCollisions,this._collectResourceTiming=M.collectResourceTiming,this._language=this._parseLanguage(M.language),this._worldview=M.worldview,this._renderTaskQueue=new eg,this._domRenderTaskQueue=new eg,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.b2(),this._locale=Object.assign({},sg,M.locale),this._clickTolerance=M.clickTolerance,this._cooperativeGestures=M.cooperativeGestures,this._performanceMetricsCollection=M.performanceMetricsCollection,this._tessellationStep=M.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=M.precompilePrograms,this._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new tg(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=M.scaleFactor,this._requestManager=new Q(M.transformRequest,M.accessToken,M.testMode),this._silenceAuthErrors=!!M.testMode,this._contextCreateOptions=M.contextCreateOptions?Object.assign({},M.contextCreateOptions):{},typeof M.container=="string"){const x=document.getElementById(M.container);if(!x)throw new Error(`Container '${M.container.toString()}' not found.`);this._container=x}else{if(!(M.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=M.container}if(this._container.childNodes.length>0&&i.w("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),M.maxBounds&&this.setMaxBounds(M.maxBounds),this._spriteFormat=M.spriteFormat,i.aY(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");if(this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new yde(this,M),this._localFontFamily=M.localFontFamily,this._localIdeographFontFamily=M.localIdeographFontFamily,(M.style||!M.testMode)&&this.setStyle(M.style||i.e.DEFAULT_STYLE,{config:M.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),M.projection&&this.setProjection(M.projection),M.hash&&(this._hash=new UT(typeof M.hash=="string"&&M.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){h.center==null&&h.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:M.center,zoom:M.zoom,bearing:M.bearing,pitch:M.pitch});const x=M.bounds;x&&(this.resize(),this.fitBounds(x,Object.assign({},M.fitBoundsOptions,{duration:0})))}this.resize(),M.attributionControl&&this.addControl(new zb({customAttribution:M.customAttribution})),this._logoControl=new Bb,this.addControl(this._logoControl,M.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent(),this._setupIndoor()}),this.on("data",x=>{this._update(x.dataType==="style"),this.fire(new i.z(`${x.dataType}data`,x))}),this.on("dataloading",x=>{this.fire(new i.z(`${x.dataType}dataloading`,x))}),this._interactions=new Xm(this)}_getMapId(){return this._mapId}addControl(M,h){if(h===void 0&&(h=M.getDefaultPosition?M.getDefaultPosition():"top-right"),!M||!M.onAdd)return this.fire(new i.y(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const x=M.onAdd(this);this._controls.push(M);const A=this._controlPositions[h];return h.indexOf("bottom")!==-1?A.insertBefore(x,A.firstChild):A.appendChild(x),this}removeControl(M){if(!M||!M.onRemove)return this.fire(new i.y(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const h=this._controls.indexOf(M);return h>-1&&this._controls.splice(h,1),M.onRemove(this),this}hasControl(M){return this._controls.indexOf(M)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(M){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const h=!this._moving;return h&&this.fire(new i.z("movestart",M)).fire(new i.z("move",M)),this.fire(new i.z("resize",M)),h&&this.fire(new i.z("moveend",M)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(M){return this.transform.setMaxBounds(i.aI.convert(M)),this._update()}setMinZoom(M){if((M=M??-2)>=-2&&M<=this.transform.maxZoom)return this.transform.minZoom=M,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=M,this._update(),this.getZoom()>M?this.setZoom(M):this.fire(new i.z("zoomstart")).fire(new i.z("zoom")).fire(new i.z("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(M){if((M=M??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(M>=0&&M<=this.transform.maxPitch)return this.transform.minPitch=M,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(M>=this.transform.minPitch)return this.transform.maxPitch=M,this._update(),this.getPitch()>M?this.setPitch(M):this.fire(new i.z("pitchstart")).fire(new i.z("pitch")).fire(new i.z("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(M){return this._scaleFactor=M,this.painter.scaleFactor=M,this._scaleFactorChanged=!0,this.style._updateFilteredLayers(h=>h.type==="symbol"),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(M){return this.transform.renderWorldCopies=M,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(M){return M==="auto"?navigator.language:Array.isArray(M)?M.length===0?void 0:M.map(h=>h==="auto"?navigator.language:h):M}setLanguage(M){const h=this._parseLanguage(M);if(!this.style||h===this._language)return this;this._language=h,this.style.reloadSources();for(const x of this._controls)x._setLanguage&&x._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(M){return this.style&&M!==this._worldview?(this._worldview=M,this._styleDirty=!0,this.style.reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(M){return this._lazyInitEmptyStyle(),M?typeof M=="string"&&(M={name:M}):M=null,this._useExplicitProjection=!!M,this._prioritizeAndUpdateProjection(M,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const M=this.transform,h=M.projection.name;let x;h==="globe"&&M.zoom>=i.cL?(M.setMercatorFromTransition(),x=!0):h==="mercator"&&M.zoom=i.cL?this.transform.setMercatorFromTransition():this.transform.setProjection(M),this.style.applyProjectionUpdate();const A=this.transform.getProjection().name==="mercator"&&x!==this.transform.mercatorFromTransition;return(h||A)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(M,h){return this.transform.locationPoint3D(i.aT.convert(M),h)}unproject(M,h){return this.transform.pointLocation3D(i.P.convert(M),h)}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(M,h,x){const A=D=>{let F=[];if(Array.isArray(h)){const z=h.filter(V=>this.getLayer(V));F=z.length?this.queryRenderedFeatures(D,{layers:z}):[]}else F=this.queryRenderedFeatures(D,{target:h});return F};if(M==="mouseenter"||M==="mouseover"){let D=!1;return{listener:x,targets:h,delegates:{mousemove:z=>{const V=A(z.point);V.length?D||(D=!0,x.call(this,new Cu(M,this,z.originalEvent,{features:V}))):D=!1},mouseout:()=>{D=!1}}}}if(M==="mouseleave"||M==="mouseout"){let D=!1;return{listener:x,targets:h,delegates:{mousemove:V=>{A(V.point).length?D=!0:D&&(D=!1,x.call(this,new Cu(M,this,V.originalEvent)))},mouseout:V=>{D&&(D=!1,x.call(this,new Cu(M,this,V.originalEvent)))}}}}{const D=F=>{const z=A(F.point);z.length&&(F.features=z,x.call(this,F),delete F.features)};return{listener:x,targets:h,delegates:{[M]:D}}}}on(M,h,x){if(typeof h=="function"||x===void 0)return super.on(M,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._createDelegatedListener(M,h,x);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[M]=this._delegatedListeners[M]||[],this._delegatedListeners[M].push(A);for(const D in A.delegates)this.on(D,A.delegates[D]);return this}once(M,h,x){if(typeof h=="function"||x===void 0)return super.once(M,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._createDelegatedListener(M,h,x);for(const D in A.delegates)this.once(D,A.delegates[D]);return this}off(M,h,x){if(typeof h=="function"||x===void 0)return super.off(M,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._delegatedListeners?this._delegatedListeners[M]:void 0;return A&&(D=>{for(let F=0;F{if(x){const D=typeof x=="string"?x:x instanceof Error?x.message:x.error;i.w(`Unable to perform style diff: ${D}. Rebuilding the style from scratch.`),this._updateStyle(M,h)}else A&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=h.localIdeographFontFamily,this._localFontFamily=h.localFontFamily,this._updateStyle(M,h))}_getUIString(M){const h=this._locale[M];if(h==null)throw new Error(`Missing UI string '${M}'`);return h}_updateStyle(M,h){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),M){const x=Object.assign({},h);h&&h.config&&(x.initialConfig=h.config,delete x.config),this.style=new cm(this,x).load(M),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new cm(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(i.w("There is no style added to the map."),!1)}_isValidId(M){return M==null?(this.fire(new i.y(new Error("IDs can't be empty."))),!1):!i.dr(M)||(this.fire(new i.y(new Error(`IDs can't contain special symbols: "${M}".`))),!1)}_isTargetValid(M){return"featuresetId"in M?this._isValidId("importId"in M?M.importId:M.featuresetId):"layerId"in M&&this._isValidId(M.layerId)}_areTargetsValid(M){if(Array.isArray(M)){for(const h of M)if(!this._isValidId(h))return!1;return!0}return this._isTargetValid(M)}addSource(M,h){return this._isValidId(M)?(this._lazyInitEmptyStyle(),this.style.addSource(M,h),this._update(!0)):this}isSourceLoaded(M){return!!this._isValidId(M)&&!!this.style&&this.style._isSourceCacheLoaded(M)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(M,h,x){this._lazyInitEmptyStyle(),this.style.addSourceType(M,h,x)}removeSource(M){return this._isValidId(M)?(this.style.removeSource(M),this._updateTerrain(),this._update(!0)):this}getSource(M){return this._isValidId(M)?this.style.getOwnSource(M):null}addImage(M,h,{pixelRatio:x=1,sdf:A=!1,stretchX:D,stretchY:F,content:z}={}){this._lazyInitEmptyStyle();const V=i.I.from(M);if(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap){const{width:X,height:ne,data:oe}=i.o.getImageData(h);this.style.addImage(V,{data:new i.q({width:X,height:ne},oe),pixelRatio:x,stretchX:D,stretchY:F,content:z,sdf:A,version:0,usvg:!1})}else if(h.width===void 0||h.height===void 0)this.fire(new i.y(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:X,height:ne}=h,oe=h;this.style.addImage(V,{data:new i.q({width:X,height:ne},new Uint8Array(oe.data)),pixelRatio:x,stretchX:D,stretchY:F,content:z,sdf:A,usvg:!1,version:0,userImage:oe}),oe.onAdd&&oe.onAdd(this,M)}}updateImage(M,h){this._lazyInitEmptyStyle();const x=i.I.from(M),A=this.style.getImage(x);if(!A)return void this.fire(new i.y(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const D=h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap?i.o.getImageData(h):h,{width:F,height:z,data:V}=D;if(F===void 0||z===void 0)return void this.fire(new i.y(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(F!==(A.usvg?A.icon.usvg_tree.width:A.data.width)||z!==(A.usvg?A.icon.usvg_tree.height:A.data.height))return void this.fire(new i.y(new Error(`The width and height of the updated image (${F}, ${z}) must be that same as the previous version of the image (${A.data.width}, ${A.data.height})`)));const X=!(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap);let ne=!1;A.usvg?(A.data=new i.q({width:F,height:z},new Uint8Array(V)),A.usvg=!1,A.icon=void 0,ne=!0):A.data.replace(V,X),this.style.updateImage(x,A,ne)}hasImage(M){return M?!!this.style&&!!this.style.getImage(i.I.from(M)):(this.fire(new i.y(new Error("Missing required image id"))),!1)}removeImage(M){this.style.removeImage(i.I.from(M))}loadImage(M,h){i.n(this._requestManager.transformRequest(M,i.R.Image),(x,A)=>{h(x,A instanceof HTMLImageElement?i.o.getImageData(A):A)})}listImages(){return this.style.listImages().map(M=>M.name)}addModel(M,h){this._lazyInitEmptyStyle(),this.style.addModel(M,h)}hasModel(M){return M?this.style.hasModel(M):(this.fire(new i.y(new Error("Missing required model id"))),!1)}removeModel(M){this.style.removeModel(M)}listModels(){return this.style.listModels()}addLayer(M,h){return this._isValidId(M.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(M,h),this._update(!0)):this}getSlot(M){const h=this.getLayer(M);return h&&h.slot||null}setSlot(M,h){return this.style.setSlot(M,h),this.style.mergeLayers(),this._update(!0)}addImport(M,h){return this.style.addImport(M,h).catch(x=>this.fire(new i.y(new Error("Failed to add import",x)))),this}updateImport(M,h){return typeof h!="string"&&h.id!==M?(this.removeImport(M),this.addImport(h)):(this.style.updateImport(M,h),this._update(!0))}removeImport(M){return this.style.removeImport(M),this}moveImport(M,h){return this.style.moveImport(M,h),this._update(!0)}moveLayer(M,h){return this._isValidId(M)?(this.style.moveLayer(M,h),this._update(!0)):this}removeLayer(M){return this._isValidId(M)?(this.style.removeLayer(M),this._update(!0)):this}getLayer(M){if(!this._isValidId(M))return null;const h=this.style.getOwnLayer(M);return h?h.type==="custom"?h.implementation:h.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(M,h,x){return this._isValidId(M)?(this.style.setLayerZoomRange(M,h,x),this._update(!0)):this}setFilter(M,h,x={}){return this._isValidId(M)?(this.style.setFilter(M,h,x),this._update(!0)):this}getFilter(M){return this._isValidId(M)?this.style.getFilter(M):null}setPaintProperty(M,h,x,A={}){return this._isValidId(M)?(this.style.setPaintProperty(M,h,x,A),this._update(!0)):this}getPaintProperty(M,h){return this._isValidId(M)?this.style.getPaintProperty(M,h):null}setLayoutProperty(M,h,x,A={}){return this._isValidId(M)?(this.style.setLayoutProperty(M,h,x,A),this._update(!0)):this}getLayoutProperty(M,h){return this._isValidId(M)?this.style.getLayoutProperty(M,h):null}setLayerProperty(M,h,x,A={}){return this._isValidId(M)?(h==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(M,h,x,A),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(M){return this.style.setGlyphsUrl(M),this._update(!0)}getSchema(M){return this.style.getSchema(M)}setSchema(M,h){return this.style.setSchema(M,h),this._update(!0)}getConfig(M){return this.style.getConfig(M)}setConfig(M,h){return this.style.setConfig(M,h),this._update(!0)}getConfigProperty(M,h){return this.style.getConfigProperty(M,h)}setConfigProperty(M,h,x){return this.style.setConfigProperty(M,h,x),this._update(!0)}getFeaturesetDescriptors(M){return this.style.getFeaturesetDescriptors(M)}setLights(M){if(this._lazyInitEmptyStyle(),M&&M.length===1&&M[0].type==="flat"){const h=M[0];h.properties?this.style.setFlatLight(h.properties,h.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(M),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const M=this.style.getLights()||[];return M.length===0&&M.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),M}setLight(M,h={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:M}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(M){return this._lazyInitEmptyStyle(),!M&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(M),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(M){return this._lazyInitEmptyStyle(),this.style.setFog(M),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(M){return this._lazyInitEmptyStyle(),this.style.setSnow(M),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(M){return this._lazyInitEmptyStyle(),this.style.setRain(M),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(M){return this._lazyInitEmptyStyle(),this.style.setColorTheme(M),this._update(!0)}setImportColorTheme(M,h){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(M,h),this._update(!0)}setCamera(M){return this.style.setCamera(M),this._triggerCameraUpdate(M)}_triggerCameraUpdate(M){return this._update(this.transform.setOrthographicProjectionAtLowPitch(M["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(M){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(i.aT.convert(M),this.transform):0}setFeatureState(M,h){return M.source&&!this._isValidId(M.source)?this:(this.style.setFeatureState(M,h),this._update())}removeFeatureState(M,h){return M.source&&!this._isValidId(M.source)?this:(this.style.removeFeatureState(M,h),this._update())}getFeatureState(M){return M.source&&!this._isValidId(M.source)?null:this.style.getFeatureState(M)}_selectIndoorFloor(M){this.indoor.selectFloor(M)}_setIndoorActiveFloorsVisibility(M){this.indoor.setActiveFloorsVisibility(M)}_addIndoorControl(){this._indoorControl||(this._indoorControl=new Bv),this.addControl(this._indoorControl,"right")}_removeIndoorControl(){this._indoorControl&&this.removeControl(this._indoorControl)}_updateContainerDimensions(){if(!this._container)return;const M=this._container.getBoundingClientRect().width||400,h=this._container.getBoundingClientRect().height||300;let x,A,D,F=this._container;for(;F&&(!A||!D);){const z=window.getComputedStyle(F).transform;z&&z!=="none"&&(x=z.match(/matrix.*\((.+)\)/)[1].split(", "),x[0]&&x[0]!=="0"&&x[0]!=="1"&&(A=x[0]),x[3]&&x[3]!=="0"&&x[3]!=="1"&&(D=x[3])),F=F.parentElement}this._containerWidth=A?Math.abs(M/A):M,this._containerHeight=D?Math.abs(h/D):h}_detectMissingCSS(){window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&i.w("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupIndoor(){this.style.isIndoorEnabled()&&(this.indoor=new jD(this.style),this.on("load",()=>{this._addIndoorControl(),this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds()),this.on("move",()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())}),this.on("idle",()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())})}))}_setupContainer(){const M=this._container;M.classList.add("mapboxgl-map"),(this._missingCSSCanary=w("div","mapboxgl-canary",M)).style.visibility="hidden",this._detectMissingCSS();const h=this._canvasContainer=w("div","mapboxgl-canvas-container",M);this._canvas=w("canvas","mapboxgl-canvas",h),this._interactive&&(h.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const x=this._controlContainer=w("div","mapboxgl-control-container",M),A=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(D=>{A[D]=w("div",`mapboxgl-ctrl-${D}`,x)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(M,h){const x=i.o.devicePixelRatio||1;this._canvas.width=x*Math.ceil(M),this._canvas.height=x*Math.ceil(h),this._canvas.style.width=`${M}px`,this._canvas.style.height=`${h}px`}_addMarker(M){this._markers.push(M)}_removeMarker(M){const h=this._markers.indexOf(M);h!==-1&&this._markers.splice(h,1)}_addPopup(M){this._popups.push(M)}_removePopup(M){const h=this._popups.indexOf(M);h!==-1&&this._popups.splice(h,1)}_setupPainter(){const M=Object.assign({},b.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),h=this._canvas.getContext("webgl2",M);h?(nt(h,!0),this.painter=new fC(h,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",x=>{x.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),i.k.testSupport(h)):this.fire(new i.y(new Error("Failed to initialize WebGL")))}_contextLost(M){M.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.z("webglcontextlost",{originalEvent:M}))}_contextRestored(M){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new i.z("webglcontextrestored",{originalEvent:M}))}_onMapScroll(M){if(M.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return!this.isMoving()&&this.loaded()}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_update(M){return this.style?(this._styleDirty=this._styleDirty||M,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(M){return this._update(),this._renderTaskQueue.add(M)}_cancelRenderFrame(M){this._renderTaskQueue.remove(M)}_requestDomTask(M){!this.loaded()||this.loaded()&&!this.isMoving()?M():this._domRenderTaskQueue.add(M)}_render(M){let h;this.fire(new i.z("renderstart")),++this._frameId;const x=this.painter.context.extTimerQuery,A=i.o.now(),D=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(h=D.createQuery(),D.beginQuery(x.TIME_ELAPSED_EXT,h)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(M),this._domRenderTaskQueue.run(M),this._removed)return;this._updateProjectionTransition();const F=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const ne=this.transform.zoom,oe=this.transform.pitch,ge=i.o.now(),pe=new i.ac(ne,{now:ge,fadeDuration:F,pitch:oe,transition:this.style.transition,worldview:this._worldview});this.style.update(pe)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let z=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),z=this._updateAverageElevation(A),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):z=this._updateAverageElevation(A);const V=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,F,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),V&&(this._placementDirty=V.needsRerender),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:F,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new i.z("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.mark(u.load),this.fire(new i.z("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),h){const ne=i.o.now()-A;D.endQuery(x.TIME_ELAPSED_EXT),setTimeout(()=>{const oe=D.getQueryParameter(h,D.QUERY_RESULT)/1e6;D.deleteQuery(h),this.fire(new i.z("gpu-timing-frame",{cpuTime:ne,gpuTime:oe}))},50)}if(this.listens("gpu-timing-layer")){const ne=this.painter.collectGpuTimers();setTimeout(()=>{const oe=this.painter.queryGpuTimers(ne);this.fire(new i.z("gpu-timing-layer",{layerTimes:oe}))},50)}if(this.listens("gpu-timing-deferred-render")){const ne=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const oe=this.painter.queryGpuTimeDeferredRender(ne);this.fire(new i.z("gpu-timing-deferred-render",{gpuTime:oe}))},50)}const X=this._sourcesDirty||this._styleDirty||this._placementDirty||z;if(X||this._repaint)this.triggerRepaint();else{const ne=this.idle();if(ne&&(z=this._updateAverageElevation(A,!0)),z)this.triggerRepaint();else if(this._triggerFrame(!1),ne&&(this.fire(new i.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const oe=this._calculateSpeedIndex();this.fire(new i.z("speedindexcompleted",{speedIndex:oe})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||X||(this._fullyLoaded=!0,p.mark(u.fullLoad),this._performanceMetricsCollection&&Rt(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(M){for(const h of this._markers)M&&!this.getRenderWorldCopies()&&(h._lngLat=h._lngLat.wrap()),h._update();for(const h of this._popups)!M||this.getRenderWorldCopies()||h._trackPointer||(h._lngLat=h._lngLat.wrap()),h._update()}_updateAverageElevation(M,h=!1){const x=D=>(this.transform.averageElevation=D,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&x(0);const A=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(A||(h||M-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(M)){const D=this.transform.averageElevation;let F=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(F)?F=0:this._averageElevationLastSampledAt=M;const z=Math.abs(D-F);if(z>1){if(this._isInitialLoad||A)return this._averageElevation.jumpTo(F),x(F);this._averageElevation.easeTo(F,M,300)}else if(z>1e-4)return this._averageElevation.jumpTo(F),x(F)}return!!this._averageElevation.isEasing(M)&&x(this._averageElevation.getValue(M))}_authenticate(){Xe(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,M=>{if(M&&(M.message===te||M.status===401)){const h=this.painter.context.gl;nt(h,!1),this._logoControl instanceof Bb&&this._logoControl._updateLogo(),h&&h.clear(h.DEPTH_BUFFER_BIT|h.COLOR_BUFFER_BIT|h.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new i.y(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),we(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&Te(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&Ae(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){ut(this._requestManager._customAccessToken)}_updateTerrain(){const M=this._isDragging();this.painter.updateTerrain(this.style,M)}_calculateSpeedIndex(){const M=this.painter.canvasCopy(),h=this.painter.getCanvasCopiesAndTimestamps();h.timeStamps.push(performance.now());const x=this.painter.context.gl,A=x.createFramebuffer();function D(F){x.framebufferTexture2D(x.FRAMEBUFFER,x.COLOR_ATTACHMENT0,x.TEXTURE_2D,F,0);const z=new Uint8Array(x.drawingBufferWidth*x.drawingBufferHeight*4);return x.readPixels(0,0,x.drawingBufferWidth,x.drawingBufferHeight,x.RGBA,x.UNSIGNED_BYTE,z),z}return x.bindFramebuffer(x.FRAMEBUFFER,A),this._canvasPixelComparison(D(M),h.canvasCopies.map(D),h.timeStamps)}_canvasPixelComparison(M,h,x){let A=x[1]-x[0];const D=M.length/4;for(let F=0;F{const x=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,x&&this._render(h)}))}_preloadTiles(M){const h=this.style?this.style.getSourceCaches():[];return i.bw(h,(x,A)=>x._preloadTiles(M,A),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(M){this._trackResize&&this.resize({originalEvent:M})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(M){this._showTileBoundaries!==M&&(this._showTileBoundaries=M,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(M){this._showParseStatus!==M&&(this._showParseStatus=M,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(M){this._showTerrainWireframe!==M&&(this._showTerrainWireframe=M,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(M){this._showLayers2DWireframe!==M&&(this._showLayers2DWireframe=M,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(M){this._showLayers3DWireframe!==M&&(this._showLayers3DWireframe=M,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(M){this._speedIndexTiming!==M&&(this._speedIndexTiming=M,this._update())}get showPadding(){return!!this._showPadding}set showPadding(M){this._showPadding!==M&&(this._showPadding=M,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(M){this._showCollisionBoxes!==M&&(this._showCollisionBoxes=M,this.style&&M?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(M){this._showOverdrawInspector!==M&&(this._showOverdrawInspector=M,this._update())}get repaint(){return!!this._repaint}set repaint(M){this._repaint!==M&&(this._repaint=M,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(M){this._vertices=M,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(M){this._showTileAABBs!==M&&(this._showTileAABBs=M,M&&this._update())}_setCacheLimits(M,h){i.f4(M,h)}get version(){return d}},NavigationControl:class{constructor(M={}){this.options=Object.assign({},bde,M),this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",h=>h.preventDefault()),this.options.showZoom&&(i.aY(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",h=>{this._map&&this._map.zoomIn({},{originalEvent:h})}),w("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",h=>{this._map&&this._map.zoomOut({},{originalEvent:h})}),w("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(i.aY(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",h=>{const x=this._map;x&&(this.options.visualizePitch?x.resetNorthPitch({},{originalEvent:h}):x.resetNorth({},{originalEvent:h}))}),this._compassIcon=w("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const M=this._map;if(!M)return;const h=M.getZoom(),x=h===M.getMaxZoom(),A=h===M.getMinZoom();this._zoomInButton.disabled=x,this._zoomOutButton.disabled=A,this._zoomInButton.setAttribute("aria-disabled",x.toString()),this._zoomOutButton.setAttribute("aria-disabled",A.toString())}_rotateCompassArrow(){const M=this._map;if(!M)return;const h=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(M.transform.pitch*(Math.PI/180)),.5)}) rotateX(${M.transform.pitch}deg) rotateZ(${M.transform.angle*(180/Math.PI)}deg)`:`rotate(${M.transform.angle*(180/Math.PI)}deg)`;M._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=h)})}onAdd(M){return this._map=M,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),M.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&M.on("pitch",this._rotateCompassArrow),M.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new wde(M,this._compass,this.options.visualizePitch)),this._container}onRemove(){const M=this._map;M&&(this._container.remove(),this.options.showZoom&&M.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&M.off("pitch",this._rotateCompassArrow),M.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(M,h){const x=w("button",M,this._container);return x.type="button",x.addEventListener("click",h),x}_setButtonTitle(M,h){if(!this._map)return;const x=this._map._getUIString(`NavigationControl.${h}`);M.setAttribute("aria-label",x),M.firstElementChild&&M.firstElementChild.setAttribute("title",x)}},GeolocateControl:class extends i.E{constructor(M={}){super();const h=navigator.geolocation;this.options=Object.assign({geolocation:h},jde,M),i.aY(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=gC(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(M){return this._map=M,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(M){const h=(x=!!this.options.geolocation)=>{this._supportsGeolocation=x,M(x)};this._supportsGeolocation!==void 0?M(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(x=>h(x.state!=="denied")).catch(()=>h()):h()}_isOutOfMapMaxBounds(M){const h=this._map.getMaxBounds(),x=M.coords;return!!h&&(x.longitudeh.getEast()||x.latitudeh.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(M){if(this._map){if(this._isOutOfMapMaxBounds(M))return this._setErrorState(),this.fire(new i.z("outofmaxbounds",M)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=M,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(M),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(M),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new i.z("geolocate",Object.assign({coords:M.coords,timestamp:M.timestamp},M.toJSON?{toJSON:M.toJSON.bind(M)}:{}))),this._finish()}}_updateCamera(M){const h=new i.aT(M.coords.longitude,M.coords.latitude),x=M.coords.accuracy,A=this._map.getBearing(),D=Object.assign({bearing:A},this.options.fitBoundsOptions);this._map.fitBounds(h.toBounds(x),D,{geolocateSource:!0})}_updateMarker(M){if(M){const h=new i.aT(M.coords.longitude,M.coords.latitude);this._accuracyCircleMarker.setLngLat(h).addTo(this._map),this._userLocationDotMarker.setLngLat(h).addTo(this._map),this._accuracy=M.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const M=this._map.transform,h=i.cf(1,M._center.lat)*M.worldSize,x=Math.ceil(2*this._accuracy*h);this._circleElement.style.width=`${x}px`,this._circleElement.style.height=`${x}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(M){if(this._map){if(this.options.trackUserLocation)if(M.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const h=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(M.code===3&&this._noTimeout)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new i.z("error",M)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(M){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",h=>h.preventDefault()),this._geolocateButton=w("button","mapboxgl-ctrl-geolocate",this._container),w("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",M===!1){i.w("Geolocation support is not available so the GeolocateControl will be disabled.");const h=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h)}else{const h=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=w("div","mapboxgl-user-location"),this._dotElement.appendChild(w("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(w("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new TC({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=w("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new TC({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",h=>{h.geolocateSource||this._watchState!=="ACTIVE_LOCK"||h.originalEvent&&h.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new i.z("trackuserlocationend")))})}}_onDeviceOrientation(M){this._userLocationDotMarker&&(M.webkitCompassHeading?this._heading=M.webkitCompassHeading:M.absolute===!0&&(this._heading=-1*M.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return i.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new i.z("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new i.z("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new i.z("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let M;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(M={maximumAge:6e5,timeout:0},this._noTimeout=!0):(M=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,M),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const M=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};typeof DeviceMotionEvent<"u"&&typeof DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(h=>{h==="granted"&&M()}).catch(console.error):M()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:zb,ScaleControl:class{constructor(M={}){this.options=Object.assign({},$v,M),i.aY(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const M=this.options.maxWidth||100,h=this._map,x=h._containerHeight/2,A=h._containerWidth/2-M/2,D=h.unproject([A,x]),F=h.unproject([A+M,x]),z=D.distanceTo(F);if(this.options.unit==="imperial"){const V=3.2808*z;V>5280?this._setScale(M,V/5280,"mile"):this._setScale(M,V,"foot")}else this.options.unit==="nautical"?this._setScale(M,z/1852,"nautical-mile"):z>=1e3?this._setScale(M,z/1e3,"kilometer"):this._setScale(M,z,"meter")}_setScale(M,h,x){this._map._requestDomTask(()=>{const A=function(F){const z=Math.pow(10,`${Math.floor(F)}`.length-1);let V=F/z;return V=V>=10?10:V>=5?5:V>=3?3:V>=2?2:V>=1?1:function(X){const ne=Math.pow(10,Math.ceil(-Math.log(X)/Math.LN10));return Math.round(X*ne)/ne}(V),z*V}(h),D=A/h;this._container.innerHTML=x!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:x}).format(A):`${A} ${rA[x]}`,this._container.style.width=M*D+"px"})}onAdd(M){return this._map=M,this._language=M.getLanguage(),this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-scale",M.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(M){this._language=M,this._update()}setUnit(M){this.options.unit=M,this._update()}},FullscreenControl:class{constructor(M={}){this._fullscreen=!1,M&&M.container&&(M.container instanceof HTMLElement?this._container=M.container:i.w("Full screen control 'container' must be a DOM element.")),i.aY(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(M){return this._map=M,this._container||(this._container=this._map.getContainer()),this._controlContainer=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const M=this._fullscreenButton=w("button","mapboxgl-ctrl-fullscreen",this._controlContainer);w("span","mapboxgl-ctrl-icon",M).setAttribute("aria-hidden","true"),M.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const M=this._getTitle();this._fullscreenButton.setAttribute("aria-label",M),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",M)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},IndoorControl:Bv,Popup:class extends i.E{constructor(M){super(),this.options=Object.assign(Object.create(um),M),this._altitude=this.options.altitude,i.aY(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(M&&M.className?M.className.trim().split(/\s+/):[])}addTo(M){return this._map&&this.remove(),this._map=M,this.options.closeOnClick&&M.on("preclick",this._onClose),this.options.closeOnMove&&M.on("move",this._onClose),M.on("remove",this.remove),this._update(),M._addPopup(this),this._focusFirstElement(),this._trackPointer?(M.on("mousemove",this._onMouseEvent),M.on("mouseup",this._onMouseEvent),M._canvasContainer.classList.add("mapboxgl-track-pointer")):M.on("move",this._update),this.fire(new i.z("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const M=this._map;return M&&(M.off("move",this._update),M.off("move",this._onClose),M.off("preclick",this._onClose),M.off("click",this._onClose),M.off("remove",this.remove),M.off("mousemove",this._onMouseEvent),M.off("mouseup",this._onMouseEvent),M.off("drag",this._onMouseEvent),M._canvasContainer&&M._canvasContainer.classList.remove("mapboxgl-track-pointer"),M._removePopup(this),this._map=void 0),this.fire(new i.z("close")),this}getLngLat(){return this._lngLat}setLngLat(M){this._lngLat=i.aT.convert(M),this._pos=null,this._trackPointer=!1,this._update();const h=this._map;return h&&(h.on("move",this._update),h.off("mousemove",this._onMouseEvent),h._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(M){return this._altitude=M,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const M=this._map;return M&&(M.off("move",this._update),M.on("mousemove",this._onMouseEvent),M.on("drag",this._onMouseEvent),M._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(M){return this.setDOMContent(document.createTextNode(M))}setHTML(M){const h=document.createDocumentFragment(),x=document.createElement("body");let A;for(x.innerHTML=M;A=x.firstChild,A;)h.appendChild(A);return this.setDOMContent(h)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(M){return this.options.maxWidth=M,this._update(),this}setDOMContent(M){let h=this._content;if(h)for(;h.hasChildNodes();)h.firstChild&&h.removeChild(h.firstChild);else h=this._content=w("div","mapboxgl-popup-content",this._container||void 0);if(h.appendChild(M),this.options.closeButton){const x=this._closeButton=w("button","mapboxgl-popup-close-button",h);x.type="button",x.setAttribute("aria-label","Close popup"),x.innerHTML='',x.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(M){return this._classList.add(M),this._updateClassList(),this}removeClassName(M){return this._classList.delete(M),this._updateClassList(),this}setOffset(M){return this.options.offset=M,this._update(),this}toggleClassName(M){let h;return this._classList.delete(M)?h=!1:(this._classList.add(M),h=!0),this._updateClassList(),h}_onMouseEvent(M){this._update(M.point)}_getAnchor(M){if(this.options.anchor)return this.options.anchor;const h=this._map,x=this._container,A=this._pos;if(!h||!x||!A)return"bottom";const D=x.offsetWidth,F=x.offsetHeight,z=A.xh.transform.width-D/2;if(A.y+Mh.transform.height-F){if(z)return"bottom-left";if(V)return"bottom-right"}return z?"left":V?"right":"bottom"}_updateClassList(){const M=this._container;if(!M)return;const h=[...this._classList];h.push("mapboxgl-popup"),this._anchor&&h.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&h.push("mapboxgl-popup-track-pointer"),M.className=h.join(" ")}_update(M){const h=this._map,x=this._content;if(!h||!this._lngLat&&!this._trackPointer||!x)return;let A=this._container;if(A||(A=this._container=w("div","mapboxgl-popup",h.getContainer()),this._tip=w("div","mapboxgl-popup-tip",A),A.appendChild(x)),this.options.maxWidth&&A.style.maxWidth!==this.options.maxWidth&&(A.style.maxWidth=this.options.maxWidth),h.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=sA(this._lngLat,this._pos,h.transform)),!this._trackPointer||M){const D=this._pos=this._trackPointer&&M instanceof i.P?M:h.project(this._lngLat,this._altitude),F=Hy(this.options.offset),z=this._anchor=this._getAnchor(F.y),V=Hy(this.options.offset,z),X=D.add(V).round();h._requestDomTask(()=>{this._container&&z&&(this._container.style.transform=`${pd[z]} translate(${X.x}px,${X.y}px)`)})}if(!this._marker&&h._showingGlobe()){const D=i.f5(h.transform,this._lngLat)?0:1;this._setOpacity(D)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const M=this._container.querySelector(hm);M&&M.focus()}_onClose(){this.remove()}_setOpacity(M){this._container&&(this._container.style.opacity=`${M}`),this._content&&(this._content.style.pointerEvents=M?"auto":"none")}},Marker:TC,Style:cm,LngLat:i.aT,LngLatBounds:i.aI,Point:i.P,MercatorCoordinate:i.ae,FreeCameraOptions:eu,Evented:i.E,config:i.e,prewarm:i.f9,clearPrewarmedResources:i.f8,get accessToken(){return i.e.ACCESS_TOKEN},set accessToken(M){i.e.ACCESS_TOKEN=M},get baseApiUrl(){return i.e.API_URL},set baseApiUrl(M){i.e.API_URL=M},get workerCount(){return i.fi.workerCount},set workerCount(M){i.fi.workerCount=M},get maxParallelImageRequests(){return i.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(M){i.e.MAX_PARALLEL_IMAGE_REQUESTS=M},clearStorage(M){i.fh(M)},get workerUrl(){return i.fg.workerUrl},set workerUrl(M){i.fg.workerUrl=M},get workerClass(){return i.fg.workerClass},set workerClass(M){i.fg.workerClass=M},get workerParams(){return i.fg.workerParams},set workerParams(M){i.fg.workerParams=M},get dracoUrl(){return i.ff()},set dracoUrl(M){i.fe(M)},get meshoptUrl(){return i.fd()},set meshoptUrl(M){i.fc(M)},setNow:i.o.setNow,restoreNow:i.o.restoreNow}});var l=a;return l})})(BBe);var Lyt=BBe.exports;const du=_o(Lyt);function xs({className:t,...s}){return e.jsx("div",{className:Pt("animate-pulse rounded-md bg-muted",t),...s})}const F5e={coming_soon:"#3B82F6",active:"#10B981",price_improvement:"#F97316",under_contract:"#8B5CF6",sold:"#6B7280"},z5e={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function Dyt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function Oyt({listings:t,isLoading:s}){const r=Pr(),n=C.useRef(null),a=C.useRef(null),o=C.useRef([]),[l,i]=C.useState(""),[d,u]=C.useState(!0);return C.useEffect(()=>{(async()=>{u(!0);try{const{data:y}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();y!=null&&y.value&&i(y.value)}catch(y){console.error("Error fetching mapbox token:",y)}u(!1)})()},[]),C.useEffect(()=>{if(!n.current||!l||a.current)return;du.accessToken=l;const f=t.filter(b=>b.latitude!=null&&b.longitude!=null);let y=[-98.5795,39.8283],_=4;if(f.length>0){const b=f.reduce((j,k)=>j+k.longitude,0)/f.length,w=f.reduce((j,k)=>j+k.latitude,0)/f.length;y=[b,w],_=f.length===1?12:10}return a.current=new du.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:_,center:y}),a.current.addControl(new du.NavigationControl,"top-right"),()=>{var b;(b=a.current)==null||b.remove(),a.current=null}},[l]),C.useEffect(()=>{if(!a.current||!l)return;o.current.forEach(y=>y.remove()),o.current=[];const f=t.filter(y=>y.latitude!=null&&y.longitude!=null);if(f.forEach(y=>{var I,L,R;const _=F5e[y.status]||"#10B981",b=((I=y.photos)==null?void 0:I.find($=>$.is_primary))||((L=y.photos)==null?void 0:L[0]),j=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${y.slug||y.id}`:`/public/listing/${y.slug||y.id}`,k=document.createElement("div");k.className="cursor-pointer",k.innerHTML=`
`;const S=new du.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${b!=null&&b.photo_url?``:""}
${Dyt(y.price)}
${y.property_address||""}
${y.city}, ${y.state}
${z5e[y.status]||y.status} ${y.bedrooms?`${y.bedrooms} bed`:""} ${y.bathrooms?`${y.bathrooms} bath`:""}
${(R=y.agent)!=null&&R.name?`
Listed by ${y.agent.name}
`:""}
Click to view details →
`),T=new du.Marker(k).setLngLat([y.longitude,y.latitude]).setPopup(S).addTo(a.current);o.current.push(T)}),f.length>1){const y=new du.LngLatBounds;f.forEach(_=>y.extend([_.longitude,_.latitude])),a.current.fitBounds(y,{padding:60,maxZoom:13})}else f.length===1&&a.current.flyTo({center:[f[0].longitude,f[0].latitude],zoom:12})},[t,l]),C.useEffect(()=>(window.__navigateToPublicListing__=f=>{r(f)},()=>{delete window.__navigateToPublicListing__}),[r]),d||s?e.jsx(xs,{className:"w-full h-[500px] rounded-lg"}):!l||t.filter(f=>f.latitude!=null&&f.longitude!=null).length===0?null:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:Object.entries(F5e).map(([f,y])=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-white shadow",style:{background:y}}),e.jsx("span",{className:"text-xs text-gray-600",children:z5e[f]})]},f))}),e.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}function a6(t,[s,r]){return Math.min(r,Math.max(s,t))}function DL(t){const s=C.useRef({value:t,previous:t});return C.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}var Ryt=[" ","Enter","ArrowUp","ArrowDown"],Fyt=[" ","Enter"],Dk="Select",[Doe,Ooe,zyt]=vL(Dk),[NM]=Ec(Dk,[zyt,xy]),Roe=xy(),[Byt,Z_]=NM(Dk),[$yt,qyt]=NM(Dk),qBe=t=>{const{__scopeSelect:s,children:r,open:n,defaultOpen:a,onOpenChange:o,value:l,defaultValue:i,onValueChange:d,dir:u,name:p,autoComplete:f,disabled:y,required:_,form:b}=t,w=Roe(s),[j,k]=C.useState(null),[S,T]=C.useState(null),[I,L]=C.useState(!1),R=G_(u),[$,q]=vu({prop:n,defaultProp:a??!1,onChange:o,caller:Dk}),[U,H]=vu({prop:l,defaultProp:i,onChange:d,caller:Dk}),Y=C.useRef(null),se=j?b||!!j.closest("form"):!0,[te,Q]=C.useState(new Set),de=Array.from(te).map(re=>re.props.value).join(";");return e.jsx(jL,{...w,children:e.jsxs(Byt,{required:_,scope:s,trigger:j,onTriggerChange:k,valueNode:S,onValueNodeChange:T,valueNodeHasChildren:I,onValueNodeHasChildrenChange:L,contentId:Gd(),value:U,onValueChange:H,open:$,onOpenChange:q,dir:R,triggerPointerDownPosRef:Y,disabled:y,children:[e.jsx(Doe.Provider,{scope:s,children:e.jsx($yt,{scope:t.__scopeSelect,onNativeOptionAdd:C.useCallback(re=>{Q(ae=>new Set(ae).add(re))},[]),onNativeOptionRemove:C.useCallback(re=>{Q(ae=>{const le=new Set(ae);return le.delete(re),le})},[]),children:r})}),se?e.jsxs(h9e,{"aria-hidden":!0,required:_,tabIndex:-1,name:p,autoComplete:f,value:U,onChange:re=>H(re.target.value),disabled:y,form:b,children:[U===void 0?e.jsx("option",{value:""}):null,Array.from(te)]},de):null]})})};qBe.displayName=Dk;var UBe="SelectTrigger",VBe=C.forwardRef((t,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=t,o=Roe(r),l=Z_(UBe,r),i=l.disabled||n,d=Ea(s,l.onTriggerChange),u=Ooe(r),p=C.useRef("touch"),[f,y,_]=p9e(w=>{const j=u().filter(T=>!T.disabled),k=j.find(T=>T.value===l.value),S=f9e(j,w,k);S!==void 0&&l.onValueChange(S.value)}),b=w=>{i||(l.onOpenChange(!0),_()),w&&(l.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return e.jsx(gM,{asChild:!0,...o,children:e.jsx(Qr.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:i,"data-disabled":i?"":void 0,"data-placeholder":m9e(l.value)?"":void 0,...a,ref:d,onClick:Mr(a.onClick,w=>{w.currentTarget.focus(),p.current!=="mouse"&&b(w)}),onPointerDown:Mr(a.onPointerDown,w=>{p.current=w.pointerType;const j=w.target;j.hasPointerCapture(w.pointerId)&&j.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(b(w),w.preventDefault())}),onKeyDown:Mr(a.onKeyDown,w=>{const j=f.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&y(w.key),!(j&&w.key===" ")&&Ryt.includes(w.key)&&(b(),w.preventDefault())})})})});VBe.displayName=UBe;var HBe="SelectValue",WBe=C.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,children:o,placeholder:l="",...i}=t,d=Z_(HBe,r),{onValueNodeHasChildrenChange:u}=d,p=o!==void 0,f=Ea(s,d.onValueNodeChange);return Zc(()=>{u(p)},[u,p]),e.jsx(Qr.span,{...i,ref:f,style:{pointerEvents:"none"},children:m9e(d.value)?e.jsx(e.Fragment,{children:l}):o})});WBe.displayName=HBe;var Uyt="SelectIcon",GBe=C.forwardRef((t,s)=>{const{__scopeSelect:r,children:n,...a}=t;return e.jsx(Qr.span,{"aria-hidden":!0,...a,ref:s,children:n||"▼"})});GBe.displayName=Uyt;var Vyt="SelectPortal",KBe=t=>e.jsx(hM,{asChild:!0,...t});KBe.displayName=Vyt;var Ok="SelectContent",ZBe=C.forwardRef((t,s)=>{const r=Z_(Ok,t.__scopeSelect),[n,a]=C.useState();if(Zc(()=>{a(new DocumentFragment)},[]),!r.open){const o=n;return o?km.createPortal(e.jsx(YBe,{scope:t.__scopeSelect,children:e.jsx(Doe.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),o):null}return e.jsx(XBe,{...t,ref:s})});ZBe.displayName=Ok;var _g=10,[YBe,Y_]=NM(Ok),Hyt="SelectContentImpl",Wyt=M_("SelectContent.RemoveScroll"),XBe=C.forwardRef((t,s)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:i,sideOffset:d,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:y,collisionPadding:_,sticky:b,hideWhenDetached:w,avoidCollisions:j,...k}=t,S=Z_(Ok,r),[T,I]=C.useState(null),[L,R]=C.useState(null),$=Ea(s,Te=>I(Te)),[q,U]=C.useState(null),[H,Y]=C.useState(null),se=Ooe(r),[te,Q]=C.useState(!1),de=C.useRef(!1);C.useEffect(()=>{if(T)return Coe(T)},[T]),Noe();const re=C.useCallback(Te=>{const[Fe,...Ae]=se().map(De=>De.ref.current),[Ue]=Ae.slice(-1),ut=document.activeElement;for(const De of Te)if(De===ut||(De==null||De.scrollIntoView({block:"nearest"}),De===Fe&&L&&(L.scrollTop=0),De===Ue&&L&&(L.scrollTop=L.scrollHeight),De==null||De.focus(),document.activeElement!==ut))return},[se,L]),ae=C.useCallback(()=>re([q,T]),[re,q,T]);C.useEffect(()=>{te&&ae()},[te,ae]);const{onOpenChange:le,triggerPointerDownPosRef:he}=S;C.useEffect(()=>{if(T){let Te={x:0,y:0};const Fe=Ue=>{var ut,De;Te={x:Math.abs(Math.round(Ue.pageX)-(((ut=he.current)==null?void 0:ut.x)??0)),y:Math.abs(Math.round(Ue.pageY)-(((De=he.current)==null?void 0:De.y)??0))}},Ae=Ue=>{Te.x<=10&&Te.y<=10?Ue.preventDefault():T.contains(Ue.target)||le(!1),document.removeEventListener("pointermove",Fe),he.current=null};return he.current!==null&&(document.addEventListener("pointermove",Fe),document.addEventListener("pointerup",Ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Fe),document.removeEventListener("pointerup",Ae,{capture:!0})}}},[T,le,he]),C.useEffect(()=>{const Te=()=>le(!1);return window.addEventListener("blur",Te),window.addEventListener("resize",Te),()=>{window.removeEventListener("blur",Te),window.removeEventListener("resize",Te)}},[le]);const[be,_e]=p9e(Te=>{const Fe=se().filter(ut=>!ut.disabled),Ae=Fe.find(ut=>ut.ref.current===document.activeElement),Ue=f9e(Fe,Te,Ae);Ue&&setTimeout(()=>Ue.ref.current.focus())}),je=C.useCallback((Te,Fe,Ae)=>{const Ue=!de.current&&!Ae;(S.value!==void 0&&S.value===Fe||Ue)&&(U(Te),Ue&&(de.current=!0))},[S.value]),Ne=C.useCallback(()=>T==null?void 0:T.focus(),[T]),Ge=C.useCallback((Te,Fe,Ae)=>{const Ue=!de.current&&!Ae;(S.value!==void 0&&S.value===Fe||Ue)&&Y(Te)},[S.value]),we=n==="popper"?Oge:QBe,Me=we===Oge?{side:i,sideOffset:d,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:y,collisionPadding:_,sticky:b,hideWhenDetached:w,avoidCollisions:j}:{};return e.jsx(YBe,{scope:r,content:T,viewport:L,onViewportChange:R,itemRefCallback:je,selectedItem:q,onItemLeave:Ne,itemTextRefCallback:Ge,focusSelectedItem:ae,selectedItemText:H,position:n,isPositioned:te,searchRef:be,children:e.jsx(TL,{as:Wyt,allowPinchZoom:!0,children:e.jsx(CL,{asChild:!0,trapped:S.open,onMountAutoFocus:Te=>{Te.preventDefault()},onUnmountAutoFocus:Mr(a,Te=>{var Fe;(Fe=S.trigger)==null||Fe.focus({preventScroll:!0}),Te.preventDefault()}),children:e.jsx(q_,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Te=>Te.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:e.jsx(we,{role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:Te=>Te.preventDefault(),...k,...Me,onPlaced:()=>Q(!0),ref:$,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:Mr(k.onKeyDown,Te=>{const Fe=Te.ctrlKey||Te.altKey||Te.metaKey;if(Te.key==="Tab"&&Te.preventDefault(),!Fe&&Te.key.length===1&&_e(Te.key),["ArrowUp","ArrowDown","Home","End"].includes(Te.key)){let Ue=se().filter(ut=>!ut.disabled).map(ut=>ut.ref.current);if(["ArrowUp","End"].includes(Te.key)&&(Ue=Ue.slice().reverse()),["ArrowUp","ArrowDown"].includes(Te.key)){const ut=Te.target,De=Ue.indexOf(ut);Ue=Ue.slice(De+1)}setTimeout(()=>re(Ue)),Te.preventDefault()}})})})})})})});XBe.displayName=Hyt;var Gyt="SelectItemAlignedPosition",QBe=C.forwardRef((t,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=t,o=Z_(Ok,r),l=Y_(Ok,r),[i,d]=C.useState(null),[u,p]=C.useState(null),f=Ea(s,$=>p($)),y=Ooe(r),_=C.useRef(!1),b=C.useRef(!0),{viewport:w,selectedItem:j,selectedItemText:k,focusSelectedItem:S}=l,T=C.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&w&&j&&k){const $=o.trigger.getBoundingClientRect(),q=u.getBoundingClientRect(),U=o.valueNode.getBoundingClientRect(),H=k.getBoundingClientRect();if(o.dir!=="rtl"){const ut=H.left-q.left,De=U.left-ut,Rt=$.left-De,me=$.width+Rt,Xe=Math.max(me,q.width),ot=window.innerWidth-_g,nt=a6(De,[_g,Math.max(_g,ot-Xe)]);i.style.minWidth=me+"px",i.style.left=nt+"px"}else{const ut=q.right-H.right,De=window.innerWidth-U.right-ut,Rt=window.innerWidth-$.right-De,me=$.width+Rt,Xe=Math.max(me,q.width),ot=window.innerWidth-_g,nt=a6(De,[_g,Math.max(_g,ot-Xe)]);i.style.minWidth=me+"px",i.style.right=nt+"px"}const Y=y(),se=window.innerHeight-_g*2,te=w.scrollHeight,Q=window.getComputedStyle(u),de=parseInt(Q.borderTopWidth,10),re=parseInt(Q.paddingTop,10),ae=parseInt(Q.borderBottomWidth,10),le=parseInt(Q.paddingBottom,10),he=de+re+te+le+ae,be=Math.min(j.offsetHeight*5,he),_e=window.getComputedStyle(w),je=parseInt(_e.paddingTop,10),Ne=parseInt(_e.paddingBottom,10),Ge=$.top+$.height/2-_g,we=se-Ge,Me=j.offsetHeight/2,Te=j.offsetTop+Me,Fe=de+re+Te,Ae=he-Fe;if(Fe<=Ge){const ut=Y.length>0&&j===Y[Y.length-1].ref.current;i.style.bottom="0px";const De=u.clientHeight-w.offsetTop-w.offsetHeight,Rt=Math.max(we,Me+(ut?Ne:0)+De+ae),me=Fe+Rt;i.style.height=me+"px"}else{const ut=Y.length>0&&j===Y[0].ref.current;i.style.top="0px";const Rt=Math.max(Ge,de+w.offsetTop+(ut?je:0)+Me)+Ae;i.style.height=Rt+"px",w.scrollTop=Fe-Ge+w.offsetTop}i.style.margin=`${_g}px 0`,i.style.minHeight=be+"px",i.style.maxHeight=se+"px",n==null||n(),requestAnimationFrame(()=>_.current=!0)}},[y,o.trigger,o.valueNode,i,u,w,j,k,o.dir,n]);Zc(()=>T(),[T]);const[I,L]=C.useState();Zc(()=>{u&&L(window.getComputedStyle(u).zIndex)},[u]);const R=C.useCallback($=>{$&&b.current===!0&&(T(),S==null||S(),b.current=!1)},[T,S]);return e.jsx(Zyt,{scope:r,contentWrapper:i,shouldExpandOnScrollRef:_,onScrollButtonChange:R,children:e.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:I},children:e.jsx(Qr.div,{...a,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});QBe.displayName=Gyt;var Kyt="SelectPopperPosition",Oge=C.forwardRef((t,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=_g,...o}=t,l=Roe(r);return e.jsx(NL,{...l,...o,ref:s,align:n,collisionPadding:a,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Oge.displayName=Kyt;var[Zyt,s_e]=NM(Ok,{}),Rge="SelectViewport",JBe=C.forwardRef((t,s)=>{const{__scopeSelect:r,nonce:n,...a}=t,o=Y_(Rge,r),l=s_e(Rge,r),i=Ea(s,o.onViewportChange),d=C.useRef(0);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),e.jsx(Doe.Slot,{scope:r,children:e.jsx(Qr.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Mr(a.onScroll,u=>{const p=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:y}=l;if(y!=null&&y.current&&f){const _=Math.abs(d.current-p.scrollTop);if(_>0){const b=window.innerHeight-_g*2,w=parseFloat(f.style.minHeight),j=parseFloat(f.style.height),k=Math.max(w,j);if(k0?I:0,f.style.justifyContent="flex-end")}}}d.current=p.scrollTop})})})]})});JBe.displayName=Rge;var e9e="SelectGroup",[Yyt,Xyt]=NM(e9e),Qyt=C.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Gd();return e.jsx(Yyt,{scope:r,id:a,children:e.jsx(Qr.div,{role:"group","aria-labelledby":a,...n,ref:s})})});Qyt.displayName=e9e;var t9e="SelectLabel",s9e=C.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Xyt(t9e,r);return e.jsx(Qr.div,{id:a.id,...n,ref:s})});s9e.displayName=t9e;var wne="SelectItem",[Jyt,r9e]=NM(wne),n9e=C.forwardRef((t,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:o,...l}=t,i=Z_(wne,r),d=Y_(wne,r),u=i.value===n,[p,f]=C.useState(o??""),[y,_]=C.useState(!1),b=Ea(s,S=>{var T;return(T=d.itemRefCallback)==null?void 0:T.call(d,S,n,a)}),w=Gd(),j=C.useRef("touch"),k=()=>{a||(i.onValueChange(n),i.onOpenChange(!1))};if(n==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return e.jsx(Jyt,{scope:r,value:n,disabled:a,textId:w,isSelected:u,onItemTextChange:C.useCallback(S=>{f(T=>T||((S==null?void 0:S.textContent)??"").trim())},[]),children:e.jsx(Doe.ItemSlot,{scope:r,value:n,disabled:a,textValue:p,children:e.jsx(Qr.div,{role:"option","aria-labelledby":w,"data-highlighted":y?"":void 0,"aria-selected":u&&y,"data-state":u?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...l,ref:b,onFocus:Mr(l.onFocus,()=>_(!0)),onBlur:Mr(l.onBlur,()=>_(!1)),onClick:Mr(l.onClick,()=>{j.current!=="mouse"&&k()}),onPointerUp:Mr(l.onPointerUp,()=>{j.current==="mouse"&&k()}),onPointerDown:Mr(l.onPointerDown,S=>{j.current=S.pointerType}),onPointerMove:Mr(l.onPointerMove,S=>{var T;j.current=S.pointerType,a?(T=d.onItemLeave)==null||T.call(d):j.current==="mouse"&&S.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Mr(l.onPointerLeave,S=>{var T;S.currentTarget===document.activeElement&&((T=d.onItemLeave)==null||T.call(d))}),onKeyDown:Mr(l.onKeyDown,S=>{var I;((I=d.searchRef)==null?void 0:I.current)!==""&&S.key===" "||(Fyt.includes(S.key)&&k(),S.key===" "&&S.preventDefault())})})})})});n9e.displayName=wne;var OE="SelectItemText",a9e=C.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,...o}=t,l=Z_(OE,r),i=Y_(OE,r),d=r9e(OE,r),u=qyt(OE,r),[p,f]=C.useState(null),y=Ea(s,k=>f(k),d.onItemTextChange,k=>{var S;return(S=i.itemTextRefCallback)==null?void 0:S.call(i,k,d.value,d.disabled)}),_=p==null?void 0:p.textContent,b=C.useMemo(()=>e.jsx("option",{value:d.value,disabled:d.disabled,children:_},d.value),[d.disabled,d.value,_]),{onNativeOptionAdd:w,onNativeOptionRemove:j}=u;return Zc(()=>(w(b),()=>j(b)),[w,j,b]),e.jsxs(e.Fragment,{children:[e.jsx(Qr.span,{id:d.textId,...o,ref:y}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren?km.createPortal(o.children,l.valueNode):null]})});a9e.displayName=OE;var i9e="SelectItemIndicator",o9e=C.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return r9e(i9e,r).isSelected?e.jsx(Qr.span,{"aria-hidden":!0,...n,ref:s}):null});o9e.displayName=i9e;var Fge="SelectScrollUpButton",l9e=C.forwardRef((t,s)=>{const r=Y_(Fge,t.__scopeSelect),n=s_e(Fge,t.__scopeSelect),[a,o]=C.useState(!1),l=Ea(s,n.onScrollButtonChange);return Zc(()=>{if(r.viewport&&r.isPositioned){let i=function(){const u=d.scrollTop>0;o(u)};const d=r.viewport;return i(),d.addEventListener("scroll",i),()=>d.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(d9e,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=r;i&&d&&(i.scrollTop=i.scrollTop-d.offsetHeight)}}):null});l9e.displayName=Fge;var zge="SelectScrollDownButton",c9e=C.forwardRef((t,s)=>{const r=Y_(zge,t.__scopeSelect),n=s_e(zge,t.__scopeSelect),[a,o]=C.useState(!1),l=Ea(s,n.onScrollButtonChange);return Zc(()=>{if(r.viewport&&r.isPositioned){let i=function(){const u=d.scrollHeight-d.clientHeight,p=Math.ceil(d.scrollTop)d.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(d9e,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=r;i&&d&&(i.scrollTop=i.scrollTop+d.offsetHeight)}}):null});c9e.displayName=zge;var d9e=C.forwardRef((t,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=t,o=Y_("SelectScrollButton",r),l=C.useRef(null),i=Ooe(r),d=C.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return C.useEffect(()=>()=>d(),[d]),Zc(()=>{var p;const u=i().find(f=>f.ref.current===document.activeElement);(p=u==null?void 0:u.ref.current)==null||p.scrollIntoView({block:"nearest"})},[i]),e.jsx(Qr.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Mr(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(n,50))}),onPointerMove:Mr(a.onPointerMove,()=>{var u;(u=o.onItemLeave)==null||u.call(o),l.current===null&&(l.current=window.setInterval(n,50))}),onPointerLeave:Mr(a.onPointerLeave,()=>{d()})})}),e0t="SelectSeparator",u9e=C.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return e.jsx(Qr.div,{"aria-hidden":!0,...n,ref:s})});u9e.displayName=e0t;var Bge="SelectArrow",t0t=C.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Roe(r),o=Z_(Bge,r),l=Y_(Bge,r);return o.open&&l.position==="popper"?e.jsx(kL,{...a,...n,ref:s}):null});t0t.displayName=Bge;var s0t="SelectBubbleInput",h9e=C.forwardRef(({__scopeSelect:t,value:s,...r},n)=>{const a=C.useRef(null),o=Ea(n,a),l=DL(s);return C.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==s&&p){const f=new Event("change",{bubbles:!0});p.call(i,s),i.dispatchEvent(f)}},[l,s]),e.jsx(Qr.select,{...r,style:{...cRe,...r.style},ref:o,defaultValue:s})});h9e.displayName=s0t;function m9e(t){return t===""||t===void 0}function p9e(t){const s=Vc(t),r=C.useRef(""),n=C.useRef(0),a=C.useCallback(l=>{const i=r.current+l;s(i),function d(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>d(""),1e3))}(i)},[s]),o=C.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return C.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,o]}function f9e(t,s,r){const a=s.length>1&&Array.from(s).every(u=>u===s[0])?s[0]:s,o=r?t.indexOf(r):-1;let l=r0t(t,Math.max(o,0));a.length===1&&(l=l.filter(u=>u!==r));const d=l.find(u=>u.textValue.toLowerCase().startsWith(a.toLowerCase()));return d!==r?d:void 0}function r0t(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var n0t=qBe,g9e=VBe,a0t=WBe,i0t=GBe,o0t=KBe,x9e=ZBe,l0t=JBe,y9e=s9e,v9e=n9e,c0t=a9e,d0t=o9e,_9e=l9e,b9e=c9e,w9e=u9e;const sr=n0t,rr=a0t,er=C.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(g9e,{ref:n,className:Pt("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...r,children:[s,e.jsx(i0t,{asChild:!0,children:e.jsx(Ho,{className:"h-4 w-4 opacity-50"})})]}));er.displayName=g9e.displayName;const j9e=C.forwardRef(({className:t,...s},r)=>e.jsx(_9e,{ref:r,className:Pt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Ug,{className:"h-4 w-4"})}));j9e.displayName=_9e.displayName;const N9e=C.forwardRef(({className:t,...s},r)=>e.jsx(b9e,{ref:r,className:Pt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Ho,{className:"h-4 w-4"})}));N9e.displayName=b9e.displayName;const tr=C.forwardRef(({className:t,children:s,position:r="popper",...n},a)=>e.jsx(o0t,{children:e.jsxs(x9e,{ref:a,className:Pt("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:r,...n,children:[e.jsx(j9e,{}),e.jsx(l0t,{className:Pt("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(N9e,{})]})}));tr.displayName=x9e.displayName;const u0t=C.forwardRef(({className:t,...s},r)=>e.jsx(y9e,{ref:r,className:Pt("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));u0t.displayName=y9e.displayName;const At=C.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(v9e,{ref:n,className:Pt("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(d0t,{children:e.jsx(ha,{className:"h-4 w-4"})})}),e.jsx(c0t,{children:s})]}));At.displayName=v9e.displayName;const h0t=C.forwardRef(({className:t,...s},r)=>e.jsx(w9e,{ref:r,className:Pt("-mx-1 my-1 h-px bg-muted",t),...s}));h0t.displayName=w9e.displayName;const m0t=t=>wt({queryKey:["public-listings",t],queryFn:async()=>{let s=G.from("listings").select(` id, slug, agent_id, property_address, city, state, neighborhood, price, property_type, status, bedrooms, bathrooms, square_footage, lot_size, year_built, has_hoa, description, latitude, longitude, created_at, updated_at, photos:listing_photos(id, photo_url, is_primary), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("is_public",!0).order("created_at",{ascending:!1});t!=null&&t.status&&(s=s.eq("status",t.status)),t!=null&&t.propertyType&&(s=s.eq("property_type",t.propertyType)),t!=null&&t.city&&(s=s.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(s=s.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(s=s.lte("price",t.maxPrice));const{data:r,error:n}=await s;if(n)throw n;return r}}),k9e=t=>wt({queryKey:["public-listing",t],queryFn:async()=>{const s=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t);let r=G.from("listings").select(` id, slug, agent_id, property_address, city, state, neighborhood, price, property_type, status, bedrooms, bathrooms, square_footage, lot_size, year_built, has_hoa, description, agent_notes, agent_notes_public, mls_link, video_link, video_id, latitude, longitude, created_at, updated_at, photos:listing_photos(id, photo_url, is_primary, sort_order), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage:brokerages(name)), video:agent_videos!listings_video_id_fkey(id, playback_url, thumbnail_url, title, duration_seconds, bunny_video_id) `).eq("is_approved",!0).eq("is_public",!0);s?r=r.eq("id",t):r=r.eq("slug",t);const{data:n,error:a}=await r.single();if(a)throw a;return n},enabled:!!t}),S9e=()=>Dt({mutationFn:async({listingId:t,agentId:s,firstName:r,lastName:n,email:a,phone:o,shareToken:l})=>{let i=null,d=null;if(l){const{data:y}=await G.from("listing_shares").select("id, sharing_agent_id").eq("share_token",l).eq("listing_id",t).maybeSingle();y&&(i=y.id,d=y.sharing_agent_id)}const{data:u,error:p}=await G.from("listing_leads").insert({listing_id:t,agent_id:d||s,first_name:r,last_name:n,email:a,phone:o,share_id:i,referred_by_agent_id:d}).select().single();if(p)throw p;const{error:f}=await G.functions.invoke("process-listing-lead",{body:{leadId:u.id}});return f&&console.error("Error processing lead:",f),u}}),p0t=()=>Dt({mutationFn:async t=>{const{error:s}=await G.rpc("increment_listing_share_click",{p_share_token:t});if(s)throw s}}),f0t={active:"bg-emerald-500",coming_soon:"bg-blue-600",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},B5e={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},g0t={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function C9e(){const[t,s]=C.useState(""),[r,n]=C.useState(!1),[a,o]=C.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:l,isLoading:i}=m0t({city:t||void 0,status:a.status||void 0,propertyType:a.propertyType||void 0,minPrice:a.minPrice?Number(a.minPrice):void 0,maxPrice:a.maxPrice?Number(a.maxPrice):void 0}),d=f=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(f),u=()=>{o({status:"",propertyType:"",minPrice:"",maxPrice:""}),s("")},p=t||a.status||a.propertyType||a.minPrice||a.maxPrice;return e.jsxs(e.Fragment,{children:[e.jsxs(lh,{children:[e.jsx("title",{children:"LevelUp Listings - Find Your Dream Home | Real Estate for Sale"}),e.jsx("meta",{name:"description",content:"Browse exclusive property listings from LevelUp real estate agents. Find homes for sale, condos, townhouses, and luxury properties. View photos, prices, and connect with agents."}),e.jsx("link",{rel:"canonical",href:"https://listings.relevelup.com"}),e.jsx("meta",{property:"og:title",content:"LevelUp Listings - Find Your Dream Home"}),e.jsx("meta",{property:"og:description",content:"Browse exclusive property listings from LevelUp real estate agents. Find homes for sale, view photos, and connect with agents."}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:"https://listings.relevelup.com"}),e.jsx("meta",{property:"og:site_name",content:"LevelUp Listings"}),e.jsx("meta",{property:"og:locale",content:"en_US"}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:"LevelUp Listings - Find Your Dream Home"}),e.jsx("meta",{name:"twitter:description",content:"Browse exclusive property listings from LevelUp real estate agents."}),e.jsx("meta",{name:"robots",content:"index, follow"}),e.jsx("meta",{name:"keywords",content:"homes for sale, real estate, property listings, houses, condos, townhouses, luxury homes, LevelUp"}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"WebSite",name:"LevelUp Listings",url:"https://listings.relevelup.com",description:"Browse exclusive property listings from LevelUp real estate agents",potentialAction:{"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:"https://listings.relevelup.com?q={search_term_string}"},"query-input":"required name=search_term_string"}})}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"RealEstateAgent",name:"LevelUp",url:"https://relevelup.com",logo:"https://listings.relevelup.com/assets/levelup-logo-color.png"})})]}),e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("header",{className:"bg-white border-b border-gray-200 sticky top-0 z-50",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(vo,{to:"/public/listings",className:"flex items-center",children:e.jsx("img",{src:zBe,alt:"LevelUp",className:"h-8"})}),e.jsx("nav",{className:"hidden md:flex items-center gap-6",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium text-gray-600 hover:text-gray-900 transition-colors",children:"About LevelUp"})})]})})}),e.jsxs("section",{className:"relative bg-cover bg-center py-20 md:py-32",style:{backgroundImage:`url(${Iyt})`},children:[e.jsx("div",{className:"absolute inset-0 bg-black/40"}),e.jsxs("div",{className:"relative max-w-7xl mx-auto px-4",children:[e.jsx("h1",{className:"text-4xl md:text-5xl lg:text-6xl font-bold text-white mb-3 text-center drop-shadow-lg",children:"Find Your Perfect Home"}),e.jsx("p",{className:"text-white/90 text-center mb-10 text-lg md:text-xl drop-shadow",children:"Exclusive listings from LevelUp agents"}),e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs("div",{className:"flex gap-0 shadow-2xl rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"relative flex-1 bg-white",children:[e.jsx(gn,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400"}),e.jsx(Re,{placeholder:"Enter an address, neighborhood, city, or ZIP code",value:t,onChange:f=>s(f.target.value),className:"pl-12 h-14 md:h-16 text-base md:text-lg border-0 focus-visible:ring-0 rounded-none bg-white"})]}),e.jsx(K,{className:"h-14 md:h-16 px-6 md:px-8 rounded-none bg-blue-600 hover:bg-blue-700",children:e.jsx(gn,{className:"h-5 w-5 md:h-6 md:w-6"})})]}),e.jsx("div",{className:"flex justify-center mt-6",children:e.jsxs(K,{variant:"secondary",size:"sm",onClick:()=>n(!r),className:"gap-2 bg-white/90 hover:bg-white text-gray-700 shadow-lg",children:[e.jsx(BP,{className:"h-4 w-4"}),r?"Hide Filters":"More Filters"]})}),r&&e.jsxs("div",{className:"mt-4 p-6 bg-white rounded-lg shadow-xl",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Status"}),e.jsxs(sr,{value:a.status||"all",onValueChange:f=>o({...a,status:f==="all"?"":f}),children:[e.jsx(er,{className:"bg-white",children:e.jsx(rr,{placeholder:"Any status"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"Any status"}),Object.entries(B5e).map(([f,y])=>e.jsx(At,{value:f,children:y},f))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Property Type"}),e.jsxs(sr,{value:a.propertyType||"all",onValueChange:f=>o({...a,propertyType:f==="all"?"":f}),children:[e.jsx(er,{className:"bg-white",children:e.jsx(rr,{placeholder:"Any type"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"Any type"}),Object.entries(g0t).map(([f,y])=>e.jsx(At,{value:f,children:y},f))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Min Price"}),e.jsx(Re,{type:"number",placeholder:"No min",value:a.minPrice,onChange:f=>o({...a,minPrice:f.target.value}),className:"bg-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Max Price"}),e.jsx(Re,{type:"number",placeholder:"No max",value:a.maxPrice,onChange:f=>o({...a,maxPrice:f.target.value}),className:"bg-white"})]})]}),p&&e.jsx("div",{className:"flex justify-end mt-4",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:u,className:"gap-1 text-gray-500",children:[e.jsx(Ur,{className:"h-4 w-4"}),"Clear all"]})})]})]})]})]}),l&&l.length>0&&e.jsx("section",{className:"py-8 bg-white border-b border-gray-200",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"Explore on Map"}),e.jsx(Oyt,{listings:l,isLoading:i})]})}),e.jsx("section",{className:"py-8",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4",children:i?e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-5",children:[...Array(8)].map((f,y)=>e.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm",children:[e.jsx(xs,{className:"aspect-[4/3]"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(xs,{className:"h-7 w-28"}),e.jsx(xs,{className:"h-4 w-full"}),e.jsx(xs,{className:"h-4 w-3/4"})]})]},y))}):l&&l.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("h2",{className:"text-xl font-semibold text-gray-900",children:[l.length," ",l.length===1?"Home":"Homes"," Available"]})}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-5",children:l.map(f=>{var w,j,k;const y=((w=f.photos)==null?void 0:w.find(S=>S.is_primary))||((j=f.photos)==null?void 0:j[0]),b=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${f.slug||f.id}`:`/public/listing/${f.slug||f.id}`;return e.jsx(vo,{to:b,children:e.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm hover:shadow-lg transition-shadow cursor-pointer group border border-gray-100",children:[e.jsxs("div",{className:"aspect-[4/3] relative overflow-hidden bg-gray-100",children:[y?e.jsx("img",{src:y.photo_url,alt:f.property_address||f.city,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(On,{className:"h-12 w-12 text-gray-300"})}),e.jsx(rt,{className:`absolute top-2 left-2 ${f0t[f.status]} text-white border-0 text-xs font-medium px-2 py-0.5`,children:B5e[f.status]}),e.jsx("button",{className:"absolute top-2 right-2 p-2 rounded-full bg-white/80 hover:bg-white transition-colors",onClick:S=>S.preventDefault(),children:e.jsx(Si,{className:"h-5 w-5 text-gray-600"})})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("p",{className:"text-xl font-bold text-gray-900 mb-1",children:d(f.price)}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-gray-700 mb-2",children:[f.bedrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.bedrooms}),e.jsx("span",{className:"text-gray-500",children:"bds"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),f.bathrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.bathrooms}),e.jsx("span",{className:"text-gray-500",children:"ba"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),f.square_footage&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.square_footage.toLocaleString()}),e.jsx("span",{className:"text-gray-500",children:"sqft"})]})]}),f.property_address&&e.jsx("p",{className:"text-sm text-gray-700 truncate",children:f.property_address}),e.jsxs("p",{className:"text-sm text-gray-500 truncate",children:[f.city,", ",f.state]}),f.agent&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-100",children:[e.jsx("p",{className:"text-xs text-gray-500 truncate",children:f.agent.name}),((k=f.agent.brokerage)==null?void 0:k.name)&&e.jsx("p",{className:"text-xs text-gray-400 truncate",children:f.agent.brokerage.name})]})]})]})},f.id)})})]}):e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-4 rounded-full bg-gray-100 flex items-center justify-center",children:e.jsx(On,{className:"h-10 w-10 text-gray-400"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"No listings found"}),e.jsx("p",{className:"text-gray-500 mb-6",children:p?"Try adjusting your search or filters":"Check back soon for new listings"}),p&&e.jsx(K,{variant:"outline",onClick:u,children:"Clear filters"})]})})}),e.jsx("footer",{className:"bg-gray-900 text-white py-10 mt-auto",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("img",{src:t_e,alt:"LevelUp",className:"h-6"})}),e.jsxs("p",{className:"text-gray-400 text-sm",children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"text-gray-400 hover:text-white text-sm transition-colors",children:"relevelup.com"})]})})})]})]})}const Ee=C.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Ee.displayName="Card";const It=C.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("flex flex-col space-y-1.5 p-6",t),...s}));It.displayName="CardHeader";const Ot=C.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:Pt("text-2xl font-semibold leading-none tracking-tight",t),...s}));Ot.displayName="CardTitle";const pr=C.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:Pt("text-sm text-muted-foreground",t),...s}));pr.displayName="CardDescription";const Oe=C.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("p-6 pt-0",t),...s}));Oe.displayName="CardContent";const QP=C.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("flex items-center p-6 pt-0",t),...s}));QP.displayName="CardFooter";var x0t="Label",M9e=C.forwardRef((t,s)=>e.jsx(Qr.label,{...t,ref:s,onMouseDown:r=>{var a;r.target.closest("button, input, select, textarea")||((a=t.onMouseDown)==null||a.call(t,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));M9e.displayName=x0t;var T9e=M9e;const y0t=nS("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ve=C.forwardRef(({className:t,...s},r)=>e.jsx(T9e,{ref:r,className:Pt(y0t(),t),...s}));ve.displayName=T9e.displayName;const jne="/assets/levelup-logo-color-D3mY9gCJ.png";function v0t(){const t=bu(),s=window.location.hostname;if(!(s==="listings.relevelup.com"||s.startsWith("listings.")))return null;const n=t.pathname.slice(1);return!n||n===""?e.jsx(C9e,{}):n.startsWith("public/")?null:e.jsx(_0t,{slug:n})}function _0t({slug:t}){return e.jsx(j0t,{slug:t})}const b0t={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},w0t={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},$5e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function j0t({slug:t}){var U,H;const{data:s,isLoading:r}=k9e(t),n=S9e(),[a,o]=C.useState(""),[l,i]=C.useState(""),[d,u]=C.useState(""),[p,f]=C.useState(""),[y,_]=C.useState(!1),[b,w]=C.useState(!1),[j,k]=C.useState(null),S=Y=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Y),T=async Y=>{if(Y.preventDefault(),!(!a.trim()||!d.trim()||!s)){_(!0);try{await n.mutateAsync({listingId:s.id,agentId:s.agent_id,firstName:a.trim(),lastName:l.trim(),email:d.trim(),phone:p.trim()}),w(!0),fe.success("Thanks! The agent will be in touch soon.")}catch(se){console.error("Lead submission error:",se),fe.error(`Failed to submit: ${se.message||"Please try again"}`)}finally{_(!1)}}},I=(s==null?void 0:s.photos)||[],L=I.find(Y=>Y.is_primary)||I[0],R=()=>{j!==null&&k(j===0?I.length-1:j-1)},$=()=>{j!==null&&k(j===I.length-1?0:j+1)};if(r)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(xs,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(xs,{className:"h-10 w-48 mb-6"}),e.jsx(xs,{className:"aspect-video mb-6"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-4",children:[e.jsx(xs,{className:"h-12 w-48"}),e.jsx(xs,{className:"h-6 w-full"}),e.jsx(xs,{className:"h-6 w-3/4"})]}),e.jsx(xs,{className:"h-64"})]})]})]});if(!s)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("a",{href:"/",className:"flex items-center gap-2",children:e.jsx("img",{src:jne,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(On,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Listing Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing may no longer be available."}),e.jsx(K,{asChild:!0,children:e.jsx("a",{href:"/",children:"Browse All Listings"})})]})]});const q=s.property_address?`${s.property_address} - ${s.city}, ${s.state}`:`${s.city}, ${s.state} Home for Sale`;return e.jsxs(e.Fragment,{children:[e.jsxs(lh,{children:[e.jsxs("title",{children:[q," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${S(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA ${s.square_footage?s.square_footage.toLocaleString()+" sqft":""} ${$5e[s.property_type]} in ${s.city}, ${s.state}. ${((U=s.description)==null?void 0:U.slice(0,150))||""}`}),e.jsx("meta",{property:"og:title",content:q}),e.jsx("meta",{property:"og:description",content:`${S(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA in ${s.city}, ${s.state}`}),e.jsx("meta",{property:"og:type",content:"website"}),L&&e.jsx("meta",{property:"og:image",content:L.photo_url})]}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card sticky top-0 z-50",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("a",{href:"/",className:"flex items-center gap-2",children:e.jsx("img",{src:jne,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs("a",{href:"/",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(ti,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),I.length>0&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>k(0),children:e.jsx("img",{src:L==null?void 0:L.photo_url,alt:"Primary",className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:I.slice(1,5).map((Y,se)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>k(se+1),children:[e.jsx("img",{src:Y.photo_url,alt:`Photo ${se+2}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),se===3&&I.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",I.length-5," more"]})]},Y.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx(rt,{className:`${b0t[s.status]} text-white border-0`,children:w0t[s.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:S(s.price)}),s.property_address&&e.jsx("p",{className:"text-xl font-medium",children:s.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(Oi,{className:"h-4 w-4"}),s.city,", ",s.state,s.neighborhood&&` • ${s.neighborhood}`]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 py-4 border-y",children:[s.bedrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(E0,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.bedrooms}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Beds"})]}),s.bathrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(Zx,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.bathrooms}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Baths"})]}),s.square_footage&&e.jsxs("div",{className:"text-center",children:[e.jsx(ey,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.square_footage.toLocaleString()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sq Ft"})]}),s.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(on,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.year_built}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(rt,{variant:"secondary",children:[e.jsx(Ta,{className:"h-3 w-3 mr-1"}),$5e[s.property_type]]}),s.lot_size&&e.jsxs(rt,{variant:"secondary",children:["Lot: ",s.lot_size]}),s.has_hoa&&e.jsx(rt,{variant:"secondary",children:"HOA"})]}),s.description&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"About This Property"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})]}),s.agent_notes&&s.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.agent_notes})]}),s.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:s.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[s.agent&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(Yi,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-semibold text-lg",children:s.agent.name}),((H=s.agent.brokerage)==null?void 0:H.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:s.agent.brokerage.name})]})]}),e.jsxs(Ee,{className:"border-primary",children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Oe,{children:b?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-3",children:e.jsx(br,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"font-medium",children:"Thanks for your interest!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The listing agent will contact you soon."})]}):e.jsxs("form",{onSubmit:T,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"firstName",children:"First Name *"}),e.jsx(Re,{id:"firstName",type:"text",placeholder:"John",value:a,onChange:Y=>o(Y.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lastName",children:"Last Name"}),e.jsx(Re,{id:"lastName",type:"text",placeholder:"Doe",value:l,onChange:Y=>i(Y.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email *"}),e.jsx(Re,{id:"email",type:"email",placeholder:"you@example.com",value:d,onChange:Y=>u(Y.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone"}),e.jsx(Re,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:p,onChange:Y=>f(Y.target.value)})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:y,children:y?"Submitting...":"Get More Info"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"The listing agent will reach out to you directly."})]})})]})]})]})]}),e.jsx(_s,{open:j!==null,onOpenChange:()=>k(null),children:e.jsxs(vs,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(Ss,{className:"sr-only",children:e.jsx(ks,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>k(null),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Ur,{className:"h-5 w-5"})}),j!==null&&I[j]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:I[j].photo_url,alt:`Photo ${j+1}`,className:"w-full max-h-[80vh] object-contain"}),I.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:R,className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(zl,{className:"h-6 w-6"})}),e.jsx("button",{onClick:$,className:"absolute right-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Ua,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white bg-black/50 px-3 py-1 rounded-full text-sm",children:[j+1," / ",I.length]})]})]})]})}),e.jsx("footer",{className:"border-t py-8 mt-16",children:e.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[e.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("p",{className:"mt-2",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function Foe({card:t,variant:s}){const r=t.brokerage_display_name||t.brokerage_logo_url,n=t.team_name||t.team_logo_url;if(!r&&!n)return null;const a={standard:{container:"bg-slate-50 border border-slate-100",text:"text-slate-600",subtext:"text-slate-400"},luxury:{container:"bg-[#1e2636] border border-[#c9a84c]/10",text:"text-[#e2e8f0]",subtext:"text-[#4a5568]"},bold:{container:"bg-gray-50 border border-gray-100",text:"text-[#1a1a2e]",subtext:"text-gray-400"},classic:{container:"bg-white border border-[#d4cfc5] shadow-sm",text:"text-[#1b3a4b]",subtext:"text-[#a0aec0]"}}[s];return e.jsx("div",{className:`rounded-2xl p-4 mb-6 ${a.container}`,children:e.jsxs("div",{className:`flex flex-col items-center gap-3 ${r&&n?"divide-y divide-current/10":""}`,children:[r&&e.jsxs("div",{className:"flex flex-col items-center gap-1.5 w-full",children:[t.brokerage_logo_url&&e.jsx("img",{src:t.brokerage_logo_url,alt:t.brokerage_display_name||"Brokerage",style:{height:`${t.brokerage_logo_size||56}px`},className:"max-w-[280px] object-contain"}),t.brokerage_display_name&&!t.brokerage_logo_url&&e.jsx("p",{className:`text-sm font-medium ${a.text}`,children:t.brokerage_display_name})]}),n&&e.jsxs("div",{className:`flex flex-col items-center gap-1.5 w-full ${r?"pt-3":""}`,children:[t.team_logo_url&&e.jsx("img",{src:t.team_logo_url,alt:t.team_name||"Team",style:{height:`${t.team_logo_size||56}px`},className:"max-w-[280px] object-contain"}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:`text-sm font-medium ${a.text}`,children:t.team_name})]})]})})}const A9e=t=>wt({queryKey:["agent-card-public",t],queryFn:async()=>{if(!t)throw new Error("No slug provided");const{data:s,error:r}=await G.from("agent_cards").select("*").eq("slug",t).eq("is_published",!0).single();if(r)throw r;const{data:n}=await G.from("profiles").select("name, email, phone, brokerage_id").eq("id",s.user_id).single();let a=null;if(n!=null&&n.brokerage_id){const{data:i}=await G.from("brokerages").select("name").eq("id",n.brokerage_id).single();a=(i==null?void 0:i.name)||null}let o=null;try{const{data:i}=await G.from("profiles").select("avatar_url").eq("id",s.user_id).single();if(i!=null&&i.avatar_url)o=i.avatar_url;else{const{data:d}=await G.storage.from("avatars").list(`${s.user_id}`);if(d&&d.length>0){const{data:u}=G.storage.from("avatars").getPublicUrl(`${s.user_id}/${d[0].name}`);o=`${u.publicUrl}?t=${Date.now()}`}}}catch{}const l={...n||{name:null,email:null,phone:null,brokerage_id:null},email:s.display_email||(n==null?void 0:n.email)||null};return{...s,social_links:s.social_links||[],profile:l,brokerage_name:s.brokerage_display_name||a,avatar_url:o}},enabled:!!t}),N0t=()=>wt({queryKey:["agent-cards-admin"],queryFn:async()=>{const{data:t,error:s}=await G.from("agent_cards").select("*").order("created_at",{ascending:!1});if(s)throw s;return t}}),k0t=t=>wt({queryKey:["agent-card",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("agent_cards").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t}),E9e=()=>{const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("agent_cards").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-cards-admin"]}),t.invalidateQueries({queryKey:["agent-card"]}),fe.success("Agent card created")},onError:s=>fe.error(s.message)})},P9e=()=>{const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("agent_cards").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["agent-cards-admin"]}),t.invalidateQueries({queryKey:["agent-card"]}),fe.success("Agent card updated")},onError:s=>fe.error(s.message)})},no=async(t,s,r,n)=>{const a=new URLSearchParams(window.location.search);await G.from("agent_card_interactions").insert({card_id:t,interaction_type:s,interaction_detail:r||null,referrer:document.referrer||null,user_agent:navigator.userAgent||null,utm_source:a.get("utm_source")||null,utm_medium:a.get("utm_medium")||null,utm_campaign:a.get("utm_campaign")||null,metadata:{}})},S0t=async(t,s)=>{const{error:r}=await G.from("agent_card_leads").insert({card_id:t,...s});if(r)throw r},I9e=t=>wt({queryKey:["agent-card-analytics",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("agent_card_interactions").select("interaction_type, interaction_detail, created_at").eq("card_id",t).order("created_at",{ascending:!1}).limit(500);if(r)throw r;const{data:n,error:a}=await G.from("agent_card_leads").select("*").eq("card_id",t).order("created_at",{ascending:!1});if(a)throw a;const o=(s==null?void 0:s.filter(d=>d.interaction_type==="card_view").length)||0,l=(s==null?void 0:s.filter(d=>d.interaction_type==="button_click").length)||0,i=(s==null?void 0:s.filter(d=>d.interaction_type==="contact_saved").length)||0;return{views:o,clicks:l,saves:i,leads:n||[],interactions:s||[]}},enabled:!!t});function zoe({open:t,onOpenChange:s,cardId:r,type:n,agentName:a}){const[o,l]=C.useState(""),[i,d]=C.useState(""),[u,p]=C.useState(""),[f,y]=C.useState(""),[_,b]=C.useState(""),[w,j]=C.useState(!1),k=async S=>{if(S.preventDefault(),!o.trim()){fe.error("Please enter your name");return}j(!0);try{await S0t(r,{lead_type:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:_.trim()||void 0,intent:f||void 0}),no(r,"lead_submitted",n),G.functions.invoke("card-lead-notify",{body:{cardId:r,leadType:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:_.trim()||void 0,intent:f||void 0}}).catch(T=>console.error("Card lead notify failed:",T)),fe.success(n==="booking"?"Request sent! They'll be in touch soon.":n==="connect"?"Info shared! They'll be in touch soon.":"Referral submitted! Thank you."),s(!1),l(""),d(""),p(""),y(""),b("")}catch{fe.error("Something went wrong. Please try again.")}finally{j(!1)}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-md rounded-2xl",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:n==="booking"?"Book a Call":n==="connect"?"Connect with Me":"Refer a Friend"}),e.jsx(Kr,{children:n==="booking"?`Let ${a} know you'd like to connect.`:n==="connect"?`Share your info and ${a} will reach out.`:`Know someone who could use ${a}'s help?`})]}),e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lead-name",children:"Name *"}),e.jsx(Re,{id:"lead-name",value:o,onChange:S=>l(S.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lead-phone",children:"Phone"}),e.jsx(Re,{id:"lead-phone",type:"tel",value:u,onChange:S=>p(S.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lead-email",children:"Email"}),e.jsx(Re,{id:"lead-email",type:"email",value:i,onChange:S=>d(S.target.value),placeholder:"you@example.com"})]}),n==="booking"&&e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lead-intent",children:"I'm looking to..."}),e.jsxs(sr,{value:f,onValueChange:y,children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select one"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"buy",children:"Buy a home"}),e.jsx(At,{value:"sell",children:"Sell my home"}),e.jsx(At,{value:"both",children:"Buy & Sell"}),e.jsx(At,{value:"other",children:"Something else"})]})]})]}),n!=="connect"&&e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lead-message",children:n==="referral"?"Tell us about them":"Message (optional)"}),e.jsx(Re,{id:"lead-message",value:_,onChange:S=>b(S.target.value),placeholder:n==="referral"?"Their name, phone, situation...":"Anything you'd like us to know"})]}),e.jsx(K,{type:"submit",className:"w-full rounded-2xl",disabled:w,children:w?"Sending...":"Submit"})]})]})})}const C0t=t=>wt({queryKey:["card-blocks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("card_blocks").select("*").eq("card_id",t).eq("is_visible",!0).order("sort_order",{ascending:!0});if(r)throw r;return s||[]},enabled:!!t}),M0t=t=>wt({queryKey:["card-blocks-all",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("card_blocks").select("*").eq("card_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s||[]},enabled:!!t}),T0t=()=>{const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("card_blocks").insert(s).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["card-blocks",r.card_id]}),t.invalidateQueries({queryKey:["card-blocks-all",r.card_id]}),fe.success("Block added")},onError:s=>fe.error(s.message)})},A0t=()=>{const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("card_blocks").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),fe.success("Block updated")},onError:s=>fe.error(s.message)})},E0t=()=>{const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("card_blocks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),fe.success("Block removed")},onError:s=>fe.error(s.message)})};function P0t(t){const s=t.match(/(?:iframe\.mediadelivery\.net\/embed\/|video\.bunnycdn\.com\/play\/)(\d+)\/([a-f0-9-]+)/i);return s?`https://iframe.mediadelivery.net/embed/${s[1]}/${s[2]}?autoplay=false&responsive=true`:(t.includes("iframe.mediadelivery.net"),t)}function I0t(t){const s=t.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/);return s?`https://www.youtube.com/embed/${s[1]}`:null}const L0t={standard:"rounded-2xl overflow-hidden mb-6 bg-slate-100",luxury:"rounded-xl overflow-hidden mb-6 bg-[#1e2636] border border-[#c9a84c]/10",bold:"rounded-2xl overflow-hidden mb-6",classic:"rounded-lg overflow-hidden mb-6 border border-[#d4cfc5] shadow-sm"};function D0t({block:t,variant:s}){const r=t.config;if(!r.video_url)return null;const n=r.video_url.includes("mediadelivery.net")||r.video_url.includes("bunnycdn.com"),a=I0t(r.video_url),o=n||!!a,l=n?P0t(r.video_url):a||r.video_url;return e.jsx("div",{className:L0t[s],children:o?e.jsx("div",{style:{position:"relative",paddingTop:"56.25%"},children:e.jsx("iframe",{src:l,loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,width:"100%",height:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})}):e.jsx("video",{src:r.video_url,controls:!0,className:"w-full",preload:"metadata"})})}const O0t={standard:{container:"mb-6",card:"bg-slate-50 rounded-2xl p-5 border border-slate-100",quote:"text-sm text-slate-600 italic",name:"text-sm font-semibold text-slate-800",role:"text-xs text-slate-500",dot:"bg-primary",dotInactive:"bg-slate-300",nav:"text-slate-400 hover:text-slate-600"},luxury:{container:"mb-6",card:"bg-[#1e2636] rounded-xl p-5 border border-[#c9a84c]/10",quote:"text-sm text-[#a0aec0] italic font-serif",name:"text-sm font-semibold text-white",role:"text-xs text-[#c9a84c]",dot:"bg-[#c9a84c]",dotInactive:"bg-[#2a3040]",nav:"text-[#4a5568] hover:text-[#c9a84c]"},bold:{container:"mb-6",card:"bg-[#fff3e0] rounded-2xl p-5",quote:"text-sm text-[#1a1a2e] font-medium",name:"text-sm font-black text-[#1a1a2e]",role:"text-xs text-[#ff5722] font-bold",dot:"bg-[#ff5722]",dotInactive:"bg-gray-300",nav:"text-gray-400 hover:text-[#ff5722]"},classic:{container:"mb-6",card:"bg-white rounded-lg p-5 border border-[#d4cfc5] shadow-sm",quote:"text-sm text-[#4a5568] italic font-serif",name:"text-sm font-semibold text-[#1b3a4b]",role:"text-xs text-[#5a7a6f]",dot:"bg-[#1b3a4b]",dotInactive:"bg-[#d4cfc5]",nav:"text-[#a0aec0] hover:text-[#1b3a4b]"}};function R0t({block:t,variant:s}){const n=t.config.testimonials||[],[a,o]=C.useState(0);if(n.length===0)return null;const l=O0t[s],i=n[a];return e.jsxs("div",{className:l.container,children:[e.jsxs("div",{className:l.card,children:[e.jsx(C5,{className:"h-4 w-4 mb-2 opacity-30"}),e.jsxs("p",{className:`${l.quote} mb-3`,children:['"',i.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:l.name,children:i.name}),i.role&&e.jsx("p",{className:l.role,children:i.role})]})]}),n.length>1&&e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-3",children:[e.jsx("button",{onClick:()=>o(d=>(d-1+n.length)%n.length),className:l.nav,children:e.jsx(zl,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex gap-1.5",children:n.map((d,u)=>e.jsx("div",{className:`h-1.5 w-1.5 rounded-full transition-colors cursor-pointer ${u===a?l.dot:l.dotInactive}`,onClick:()=>o(u)},u))}),e.jsx("button",{onClick:()=>o(d=>(d+1)%n.length),className:l.nav,children:e.jsx(Ua,{className:"h-4 w-4"})})]})]})}const F0t={standard:{container:"flex flex-wrap gap-2 mb-6 justify-center",tag:"px-3 py-1.5 text-xs font-medium rounded-full bg-primary/10 text-primary"},luxury:{container:"flex flex-wrap gap-2 mb-6 justify-center",tag:"px-3 py-1.5 text-xs font-medium rounded-full bg-[#c9a84c]/10 text-[#e8d48b] border border-[#c9a84c]/20"},bold:{container:"flex flex-wrap gap-2 mb-6 justify-center",tag:"px-3 py-1.5 text-xs font-black rounded-full bg-[#1a1a2e] text-white uppercase tracking-wide"},classic:{container:"flex flex-wrap gap-2 mb-6 justify-center",tag:"px-3 py-1.5 text-xs font-medium rounded-md bg-[#1b3a4b]/10 text-[#1b3a4b] border border-[#d4cfc5]"}};function z0t({block:t,variant:s}){const n=t.config.tags||[];if(n.length===0)return null;const a=F0t[s];return e.jsx("div",{className:a.container,children:n.map((o,l)=>e.jsx("span",{className:a.tag,children:o},l))})}const B0t={standard:{container:"space-y-2 mb-6",link:"w-full flex items-center justify-between h-12 px-4 rounded-2xl bg-slate-50 hover:bg-slate-100 border border-slate-100 transition-colors text-sm font-medium text-slate-700",icon:"text-primary"},luxury:{container:"space-y-2 mb-6",link:"w-full flex items-center justify-between h-12 px-4 rounded-xl bg-[#1e2636] hover:bg-[#252d3f] border border-[#c9a84c]/10 transition-colors text-sm font-medium text-[#e2e8f0]",icon:"text-[#c9a84c]"},bold:{container:"space-y-2 mb-6",link:"w-full flex items-center justify-between h-12 px-4 rounded-2xl bg-gray-50 hover:bg-gray-100 transition-colors text-sm font-bold text-[#1a1a2e]",icon:"text-[#ff5722]"},classic:{container:"space-y-2 mb-6",link:"w-full flex items-center justify-between h-12 px-4 rounded-lg bg-white hover:bg-[#f5f1eb] border border-[#d4cfc5] shadow-sm transition-colors text-sm font-medium text-[#1b3a4b]",icon:"text-[#5a7a6f]"}};function $0t({block:t,cardId:s,variant:r}){const a=t.config.links||[];if(a.length===0)return null;const o=B0t[r];return e.jsx("div",{className:o.container,children:a.map((l,i)=>e.jsxs("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>no(s,"button_click",`custom_link_${l.label}`),className:o.link,children:[e.jsx("span",{children:l.label}),e.jsx(sn,{className:`h-4 w-4 ${o.icon}`})]},i))})}const $ge={instagram:{label:"Instagram",icon:"M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z",color:"#E4405F",hoverBg:"hover:bg-[#E4405F]/10"},facebook:{label:"Facebook",icon:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z",color:"#1877F2",hoverBg:"hover:bg-[#1877F2]/10"},linkedin:{label:"LinkedIn",icon:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z",color:"#0A66C2",hoverBg:"hover:bg-[#0A66C2]/10"},twitter:{label:"X",icon:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z",color:"#000000",hoverBg:"hover:bg-black/10"},youtube:{label:"YouTube",icon:"M23.498 6.186a3.016 3.016 0 00-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 00.502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 002.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 002.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814z M9.545 15.568V8.432L15.818 12z",color:"#FF0000",hoverBg:"hover:bg-[#FF0000]/10"},tiktok:{label:"TikTok",icon:"M12.525.02c1.31-.02 2.61-.01 3.91-.02.08 1.53.63 3.09 1.75 4.17 1.12 1.11 2.7 1.62 4.24 1.79v4.03c-1.44-.05-2.89-.35-4.2-.97-.57-.26-1.1-.59-1.62-.93-.01 2.92.01 5.84-.02 8.75-.08 1.4-.54 2.79-1.35 3.94-1.31 1.92-3.58 3.17-5.91 3.21-1.43.08-2.86-.31-4.08-1.03-2.02-1.19-3.44-3.37-3.65-5.71-.02-.5-.03-1-.01-1.49.18-1.9 1.12-3.72 2.58-4.96 1.66-1.44 3.98-2.13 6.15-1.72.02 1.48-.04 2.96-.04 4.44-.99-.32-2.15-.23-3.02.37-.63.41-1.11 1.04-1.36 1.75-.21.51-.15 1.07-.14 1.61.24 1.64 1.82 3.02 3.5 2.87 1.12-.01 2.19-.66 2.77-1.61.19-.33.4-.67.41-1.06.1-1.79.06-3.57.07-5.36.01-4.03-.01-8.05.02-12.07z",color:"#000000",hoverBg:"hover:bg-black/10"},zillow:{label:"Zillow",icon:"M12 0L1 6v12l11 6 11-6V6L12 0zm0 2.18L21 7.5v9L12 21.82 3 16.5v-9L12 2.18z",color:"#006AFF",hoverBg:"hover:bg-[#006AFF]/10"},realtor:{label:"Realtor",icon:"M12 2L2 7v10l10 5 10-5V7L12 2zm0 2.18l8 4v8l-8 4-8-4v-8l8-4z",color:"#D92228",hoverBg:"hover:bg-[#D92228]/10"},spotify:{label:"Spotify",icon:"M12 0C5.4 0 0 5.4 0 12s5.4 12 12 12 12-5.4 12-12S18.66 0 12 0zm5.521 17.34c-.24.359-.66.48-1.021.24-2.82-1.74-6.36-2.101-10.561-1.141-.418.122-.779-.179-.899-.539-.12-.421.18-.78.54-.9 4.56-1.021 8.52-.6 11.64 1.32.42.18.479.659.301 1.02zm1.44-3.3c-.301.42-.841.6-1.262.3-3.239-1.98-8.159-2.58-11.939-1.38-.479.12-1.02-.12-1.14-.6-.12-.48.12-1.021.6-1.141C9.6 9.9 15 10.561 18.72 12.84c.361.181.54.78.241 1.2zm.12-3.36C15.24 8.4 8.82 8.16 5.16 9.301c-.6.179-1.2-.181-1.38-.721-.18-.601.18-1.2.72-1.381 4.26-1.26 11.28-1.02 15.721 1.621.539.3.719 1.02.419 1.56-.299.421-1.02.599-1.559.3z",color:"#1DB954",hoverBg:"hover:bg-[#1DB954]/10"},apple_music:{label:"Apple Music",icon:"M23.994 6.124a9.23 9.23 0 00-.24-2.19c-.317-1.31-1.062-2.31-2.18-3.043A5.022 5.022 0 0019.7.198a10.7 10.7 0 00-1.564-.15C17.637.017 17.14 0 12.002 0h-.004C6.858 0 6.362.017 5.862.047 5.34.08 4.82.13 4.309.325a5.017 5.017 0 00-1.874.826C1.317 2.07.573 3.07.255 4.38A9.234 9.234 0 00.02 6.57C-.013 7.068-.03 7.564 0 12.002v.004c-.03 4.438.013 4.934.047 5.432.033.522.083 1.042.278 1.554a5.017 5.017 0 00.826 1.874c.92 1.118 1.92 1.862 3.23 2.18a9.23 9.23 0 002.19.24c.498.03.994.013 5.432.047h.004c4.438.034 4.934-.013 5.432-.047a9.23 9.23 0 002.19-.24c1.31-.317 2.31-1.062 3.043-2.18a5.022 5.022 0 00.627-1.874c.195-.492.245-1.012.278-1.534.03-.498.047-.994.047-5.432v-.004c.034-4.438-.013-4.934-.047-5.432zM17.42 16.41c0 .612-.15 1.21-.44 1.758a3.58 3.58 0 01-1.207 1.31c-.518.339-1.09.521-1.705.545-.13.005-.26 0-.39-.017a2.617 2.617 0 01-1.653-.772 2.305 2.305 0 01-.668-1.653c-.005-.13 0-.26.017-.39.07-.52.275-.986.602-1.39a2.998 2.998 0 011.218-.94 3.14 3.14 0 011.12-.282c.17-.009.336.002.502.034V9.472L10.2 10.637v7.093c0 .612-.15 1.21-.44 1.758a3.58 3.58 0 01-1.207 1.31c-.518.339-1.09.521-1.705.545-.13.005-.26 0-.39-.017a2.617 2.617 0 01-1.653-.772A2.305 2.305 0 014.137 18.9c-.005-.13 0-.26.017-.39.07-.52.275-.986.602-1.39a2.998 2.998 0 011.218-.94 3.14 3.14 0 011.12-.282c.17-.009.336.002.502.034V8.377c0-.453.066-.903.195-1.34a3.2 3.2 0 01.694-1.204 2.62 2.62 0 011.063-.738c.39-.14.793-.208 1.196-.196l4.84-1.01v10.52z",color:"#FA243C",hoverBg:"hover:bg-[#FA243C]/10"}};function q0t({path:t,color:s,size:r=20}){return e.jsx("svg",{viewBox:"0 0 24 24",width:r,height:r,fill:s,children:e.jsx("path",{d:t})})}const U0t={standard:{container:"bg-white rounded-2xl border border-slate-100 p-5 mb-6 shadow-sm",title:"text-sm font-semibold text-slate-800 mb-3",linkClass:"h-11 w-11 rounded-xl bg-slate-50 border border-slate-100 flex items-center justify-center transition-all duration-200 hover:scale-110 hover:shadow-md"},luxury:{container:"bg-zinc-900/50 backdrop-blur rounded-2xl border border-amber-900/20 p-5 mb-6",title:"text-sm font-semibold text-amber-200/80 mb-3",linkClass:"h-11 w-11 rounded-xl bg-zinc-800/80 border border-amber-900/20 flex items-center justify-center transition-all duration-200 hover:scale-110 hover:border-amber-500/40 hover:shadow-md hover:shadow-amber-500/10"},bold:{container:"bg-white/10 backdrop-blur rounded-2xl border border-white/20 p-5 mb-6",title:"text-sm font-semibold text-white/90 mb-3",linkClass:"h-11 w-11 rounded-xl bg-white/10 border border-white/20 flex items-center justify-center transition-all duration-200 hover:scale-110 hover:bg-white/20 hover:shadow-md"},classic:{container:"bg-stone-50 rounded-2xl border border-stone-200 p-5 mb-6",title:"text-sm font-semibold text-stone-800 mb-3",linkClass:"h-11 w-11 rounded-xl bg-white border border-stone-200 flex items-center justify-center transition-all duration-200 hover:scale-110 hover:shadow-md"}};function V0t({block:t,cardId:s,variant:r}){const a=t.config.platforms||[],o=U0t[r];return a.length===0?null:e.jsxs("div",{className:o.container,children:[e.jsx("h3",{className:o.title,children:"Follow Me"}),e.jsx("div",{className:"flex flex-wrap gap-3 justify-center",children:a.map((l,i)=>{const d=$ge[l.platform.toLowerCase()];return!d||!l.url?null:e.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>no(s,"button_click",`social_${l.platform}`),className:o.linkClass,title:d.label,children:e.jsx(q0t,{path:d.icon,color:d.color})},i)})})]})}function Boe({cardId:t,variant:s}){const{data:r}=C0t(t);if(!r||r.length===0)return null;const n=r.filter(l=>l.block_type==="social_media"&&l.is_visible),a=r.filter(l=>l.block_type!=="social_media"),o=n.length>0?{...n[0],config:{platforms:n.flatMap(l=>l.config.platforms||[])}}:null;return r.findIndex(l=>l.block_type==="social_media"),e.jsxs(e.Fragment,{children:[a.map(l=>{switch(l.block_type){case"video_intro":return e.jsx(D0t,{block:l,variant:s},l.id);case"testimonials":return e.jsx(R0t,{block:l,variant:s},l.id);case"specialties":return e.jsx(z0t,{block:l,variant:s},l.id);case"custom_links":return e.jsx($0t,{block:l,cardId:t,variant:s},l.id);default:return null}}),o&&e.jsx(V0t,{block:o,cardId:t,variant:s})]})}async function H0t(t){try{const s=await fetch(t);if(!s.ok)return null;const r=await s.blob(),n=r.type||"image/jpeg";return new Promise(a=>{const o=new FileReader;o.onloadend=()=>{const i=o.result.split(",")[1];a({base64:i,mimeType:n})},o.onerror=()=>a(null),o.readAsDataURL(r)})}catch{return null}}function W0t(t){const s=t.trim().split(/\s+/);if(s.length<=1)return{first:s[0]||"",last:""};const r=s.pop();return{first:s.join(" "),last:r}}async function $oe(t){const{first:s,last:r}=W0t(t.name),n=["BEGIN:VCARD","VERSION:3.0",`FN:${t.name}`,`N:${r};${s};;;`];if(t.phone&&n.push(`TEL;TYPE=CELL:${t.phone}`),t.email&&n.push(`EMAIL;TYPE=INTERNET:${t.email}`),t.brokerage&&n.push(`ORG:${t.brokerage}`),n.push(`URL:${t.cardUrl}`),t.avatarUrl){const i=await H0t(t.avatarUrl);if(i){const u={"image/jpeg":"JPEG","image/jpg":"JPEG","image/png":"PNG","image/gif":"GIF","image/webp":"JPEG"}[i.mimeType]||"JPEG";n.push(`PHOTO;ENCODING=b;TYPE=${u}:${i.base64}`)}}n.push("END:VCARD");const a=new Blob([n.join(`\r `)],{type:"text/vcard"}),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=`${t.name.replace(/\s+/g,"_")}.vcf`,l.click(),URL.revokeObjectURL(o),fe.success("Contact saved!")}function G0t({card:t}){var k;const[s,r]=C.useState(!1),[n,a]=C.useState("booking"),o=((k=t.profile)==null?void 0:k.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,T)=>{no(t.id,"button_click",S),T()},d=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:fe.error("Phone number not available")}),u=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:fe.error("Phone number not available")}),p=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:fe.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),no(t.id,"button_click","book"))},y=()=>{var S,T;no(t.id,"contact_saved"),$oe({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(T=t.profile)==null?void 0:T.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{if(no(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o} - Real Estate Agent`,text:t.positioning_statement||`Connect with ${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),fe.success("Link copied!")},b=()=>{a("referral"),r(!0),no(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),no(t.id,"button_click","connect")},j={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-white to-slate-50",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(xn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(Aa,{src:t.avatar_url||void 0,alt:o}),e.jsx(yn,{className:"text-2xl font-semibold bg-primary text-primary-foreground",children:l})]}),e.jsx("h1",{className:"text-2xl font-bold text-slate-900 mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-primary mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-slate-500 mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-slate-400 mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-slate-600 italic leading-relaxed max-w-xs mx-auto",children:['"',t.positioning_statement,'"']})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs(K,{onClick:d,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(Qn,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Call"})]}),e.jsxs(K,{onClick:u,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(io,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Text"})]}),e.jsxs(K,{onClick:p,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(br,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Email"})]})]}),e.jsxs(K,{onClick:f,className:"w-full h-12 text-base font-semibold rounded-2xl shadow-sm mb-6",variant:"outline",children:[e.jsx(on,{className:"h-5 w-5 mr-2"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm text-slate-600",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Gn,{className:"h-4 w-4 text-amber-500 fill-amber-500"}),e.jsx("span",{className:"font-bold text-slate-900",children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"bg-slate-50 rounded-2xl p-4 mb-6 border border-slate-100",children:e.jsxs("p",{className:"text-sm text-slate-600 italic text-center",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-2",children:"About Me"}),e.jsx("p",{className:"text-sm text-slate-600 leading-relaxed",children:t.bio})]}),e.jsx(Foe,{card:t,variant:"standard"}),e.jsx(Boe,{cardId:t.id,variant:"standard"}),e.jsxs("div",{className:"space-y-2 mb-6",children:[t.show_save_contact&&e.jsxs(K,{variant:"ghost",onClick:y,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(xi,{className:"h-4 w-4 mr-3 text-primary"}),"Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs(K,{variant:"ghost",onClick:()=>{no(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(Gn,{className:"h-4 w-4 mr-3 text-amber-500"}),"Leave a Review"]}),t.show_refer_friend&&e.jsxs(K,{variant:"ghost",onClick:b,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(hr,{className:"h-4 w-4 mr-3 text-primary"}),"Refer a Friend"]}),e.jsxs(K,{variant:"ghost",onClick:w,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(yc,{className:"h-4 w-4 mr-3 text-primary"}),"Connect with Me"]}),e.jsxs(K,{variant:"ghost",onClick:_,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(ld,{className:"h-4 w-4 mr-3 text-primary"}),"Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,T)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>no(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-slate-100 hover:bg-slate-200 flex items-center justify-center text-lg transition-colors",children:j[S.platform.toLowerCase()]||"🔗"},T))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-slate-400",children:"Powered by LevelUp"})})]}),e.jsx(zoe,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function K0t({card:t}){var k;const[s,r]=C.useState(!1),[n,a]=C.useState("booking"),o=((k=t.profile)==null?void 0:k.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,T)=>{no(t.id,"button_click",S),T()},d=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:fe.error("Phone number not available")}),u=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:fe.error("Phone number not available")}),p=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:fe.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),no(t.id,"button_click","book"))},y=()=>{var S,T;no(t.id,"contact_saved"),$oe({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(T=t.profile)==null?void 0:T.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{if(no(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o} - Real Estate Agent`,text:t.positioning_statement||`Connect with ${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),fe.success("Link copied!")},b=()=>{a("referral"),r(!0),no(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),no(t.id,"button_click","connect")},j={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-[#0f1419] via-[#1a1f2e] to-[#0f1419]",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsx("div",{className:"w-16 h-0.5 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] mx-auto mb-8"}),e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(xn,{className:"h-32 w-32 mx-auto mb-5 ring-2 ring-[#c9a84c]/40 shadow-2xl",children:[e.jsx(Aa,{src:t.avatar_url||void 0,alt:o}),e.jsx(yn,{className:"text-2xl font-serif bg-[#c9a84c]/20 text-[#e8d48b]",children:l})]}),e.jsx("h1",{className:"text-2xl font-serif font-bold text-white tracking-wide mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-[#e8d48b] mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-[#c9a84c] tracking-widest uppercase mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-[#a0aec0] mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-[#a0aec0] italic leading-relaxed max-w-xs mx-auto font-serif",children:['"',t.positioning_statement,'"']})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:Qn,label:"Call",handler:d},{icon:io,label:"Text",handler:u},{icon:br,label:"Email",handler:p}].map(({icon:S,label:T,handler:I})=>e.jsxs("button",{onClick:I,className:"flex flex-col items-center gap-1.5 py-4 bg-[#1e2636] hover:bg-[#252d3f] border border-[#c9a84c]/20 rounded-xl transition-colors",children:[e.jsx(S,{className:"h-5 w-5 text-[#c9a84c]"}),e.jsx("span",{className:"text-xs font-medium text-[#e2e8f0]",children:T})]},T))}),e.jsxs("button",{onClick:f,className:"w-full h-12 text-base font-semibold rounded-xl mb-6 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] text-[#0f1419] hover:opacity-90 transition-opacity flex items-center justify-center gap-2",children:[e.jsx(on,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Gn,{className:"h-4 w-4 text-[#c9a84c] fill-[#c9a84c]"}),e.jsx("span",{className:"font-bold text-white",children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"bg-[#1e2636] rounded-xl p-4 mb-6 border border-[#c9a84c]/10",children:e.jsxs("p",{className:"text-sm text-[#a0aec0] italic text-center font-serif",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-[#c9a84c] mb-2 tracking-wide uppercase",children:"About"}),e.jsx("p",{className:"text-sm text-[#a0aec0] leading-relaxed",children:t.bio})]}),e.jsx(Foe,{card:t,variant:"luxury"}),e.jsx(Boe,{cardId:t.id,variant:"luxury"}),e.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&e.jsxs("button",{onClick:y,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(xi,{className:"h-4 w-4 text-[#c9a84c]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{no(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(Gn,{className:"h-4 w-4 text-[#c9a84c]"})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:b,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(hr,{className:"h-4 w-4 text-[#c9a84c]"})," Refer a Friend"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(yc,{className:"h-4 w-4 text-[#c9a84c]"})," Connect with Me"]}),e.jsxs("button",{onClick:_,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(ld,{className:"h-4 w-4 text-[#c9a84c]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,T)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>no(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-[#1e2636] border border-[#c9a84c]/20 hover:border-[#c9a84c]/50 flex items-center justify-center text-lg transition-colors",children:j[S.platform.toLowerCase()]||"🔗"},T))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#4a5568]",children:"Powered by LevelUp"})})]}),e.jsx(zoe,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Z0t({card:t}){var T,I,L,R;const[s,r]=C.useState(!1),[n,a]=C.useState("booking"),o=((T=t.profile)==null?void 0:T.name)||"Agent",l=o.split(" ").map($=>$[0]).join("").toUpperCase().slice(0,2),i={accent:((I=t.bold_theme_colors)==null?void 0:I.accent)||"#ff5722",dark:((L=t.bold_theme_colors)==null?void 0:L.dark)||"#1a1a2e",button:((R=t.bold_theme_colors)==null?void 0:R.button)||"#ff5722"},d=($,q)=>{const U=parseInt($.replace("#",""),16),H=Math.max(0,(U>>16)-q),Y=Math.max(0,(U>>8&255)-q),se=Math.max(0,(U&255)-q);return`#${(H<<16|Y<<8|se).toString(16).padStart(6,"0")}`};d(i.accent,25),d(i.dark,-20),d(i.button,25);const u=($,q)=>{no(t.id,"button_click",$),q()},p=()=>u("call",()=>{var $;($=t.profile)!=null&&$.phone?window.location.href=`tel:${t.profile.phone}`:fe.error("Phone number not available")}),f=()=>u("text",()=>{var $;($=t.profile)!=null&&$.phone?window.location.href=`sms:${t.profile.phone}`:fe.error("Phone number not available")}),y=()=>u("email",()=>{var $;($=t.profile)!=null&&$.email?window.location.href=`mailto:${t.profile.email}`:fe.error("Email not available")}),_=()=>{t.booking_url?u("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),no(t.id,"button_click","book"))},b=()=>{var $,q;no(t.id,"contact_saved"),$oe({name:o,phone:($=t.profile)==null?void 0:$.phone,email:(q=t.profile)==null?void 0:q.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},w=async()=>{if(no(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),fe.success("Link copied!")},j=()=>{a("referral"),r(!0),no(t.id,"button_click","refer")},k=()=>{a("connect"),r(!0),no(t.id,"button_click","connect")},S={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:i.accent},children:[e.jsxs("div",{className:"px-5 pt-10 pb-14 text-center relative",style:{backgroundColor:i.dark},children:[t.show_photo&&e.jsxs(xn,{className:"h-28 w-28 mx-auto mb-4 shadow-2xl",style:{boxShadow:`0 0 0 4px ${i.accent}`},children:[e.jsx(Aa,{src:t.avatar_url||void 0,alt:o}),e.jsx(yn,{className:"text-2xl font-black text-white",style:{backgroundColor:i.accent},children:l})]}),e.jsx("h1",{className:"text-3xl font-black text-white tracking-tight mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-bold mb-1",style:{color:`${i.accent}cc`},children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-bold uppercase tracking-wider mb-1",style:{color:i.accent},children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-bold text-white/60 uppercase tracking-wider",children:t.team_name})]}),e.jsxs("div",{className:"max-w-md mx-auto px-5 -mt-6",children:[e.jsxs("div",{className:"bg-white rounded-3xl shadow-2xl px-5 py-8",children:[t.positioning_statement&&e.jsx("p",{className:"text-center font-bold text-lg leading-snug mb-6 max-w-xs mx-auto",style:{color:i.dark},children:t.positioning_statement}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:Qn,label:"Call",handler:p},{icon:io,label:"Text",handler:f},{icon:br,label:"Email",handler:y}].map(({icon:$,label:q,handler:U})=>e.jsxs("button",{onClick:U,className:"flex flex-col items-center gap-1.5 py-4 text-white rounded-2xl transition-opacity font-bold hover:opacity-85",style:{backgroundColor:i.dark},children:[e.jsx($,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:q})]},q))}),e.jsxs("button",{onClick:_,className:"w-full h-14 text-base font-black rounded-2xl mb-6 text-white transition-opacity hover:opacity-90 flex items-center justify-center gap-2 uppercase tracking-wide",style:{backgroundColor:i.button},children:[e.jsx(on,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-5 mb-6",children:t.review_snippet&&e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Gn,{className:"h-5 w-5",style:{color:i.accent,fill:i.accent}}),e.jsx("span",{className:"font-black text-2xl",style:{color:i.dark},children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"rounded-2xl p-4 mb-6",style:{backgroundColor:`${i.accent}15`},children:e.jsxs("p",{className:"text-sm font-medium text-center",style:{color:i.dark},children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xs font-black mb-2 uppercase tracking-wider",style:{color:i.accent},children:"About Me"}),e.jsx("p",{className:"text-sm text-gray-600 leading-relaxed",children:t.bio})]}),e.jsx(Foe,{card:t,variant:"bold"}),e.jsx(Boe,{cardId:t.id,variant:"bold"}),e.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&e.jsxs("button",{onClick:b,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(xi,{className:"h-4 w-4",style:{color:i.accent}})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{no(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(Gn,{className:"h-4 w-4",style:{color:i.accent}})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:j,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(hr,{className:"h-4 w-4",style:{color:i.accent}})," Refer a Friend"]}),e.jsxs("button",{onClick:k,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(yc,{className:"h-4 w-4",style:{color:i.accent}})," Connect with Me"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(ld,{className:"h-4 w-4",style:{color:i.accent}})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-6",children:t.social_links.slice(0,3).map(($,q)=>e.jsx("a",{href:$.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>no(t.id,"button_click",`social_${$.platform}`),className:"h-10 w-10 rounded-full flex items-center justify-center text-lg transition-opacity hover:opacity-85",style:{backgroundColor:i.dark},children:S[$.platform.toLowerCase()]||"🔗"},q))})]}),e.jsx("div",{className:"text-center py-6",children:e.jsx("p",{className:"text-xs text-white/50",children:"Powered by LevelUp"})})]}),e.jsx(zoe,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Y0t({card:t}){var k;const[s,r]=C.useState(!1),[n,a]=C.useState("booking"),o=((k=t.profile)==null?void 0:k.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,T)=>{no(t.id,"button_click",S),T()},d=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:fe.error("Phone number not available")}),u=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:fe.error("Phone number not available")}),p=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:fe.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),no(t.id,"button_click","book"))},y=()=>{var S,T;no(t.id,"contact_saved"),$oe({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(T=t.profile)==null?void 0:T.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{if(no(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),fe.success("Link copied!")},b=()=>{a("referral"),r(!0),no(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),no(t.id,"button_click","connect")},j={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-[#f5f1eb]",children:[e.jsx("div",{className:"bg-[#1b3a4b] h-2"}),e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(xn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(Aa,{src:t.avatar_url||void 0,alt:o}),e.jsx(yn,{className:"text-2xl font-serif bg-[#1b3a4b] text-white",children:l})]}),e.jsx("h1",{className:"text-2xl font-serif font-bold text-[#1b3a4b] mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-[#5a7a6f] mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-[#5a7a6f] mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-[#a0aec0] mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-[#4a5568] italic leading-relaxed max-w-xs mx-auto font-serif",children:['"',t.positioning_statement,'"']})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:Qn,label:"Call",handler:d},{icon:io,label:"Text",handler:u},{icon:br,label:"Email",handler:p}].map(({icon:S,label:T,handler:I})=>e.jsxs("button",{onClick:I,className:"flex flex-col items-center gap-1.5 py-4 bg-white hover:bg-[#e8e3db] border border-[#d4cfc5] rounded-lg transition-colors shadow-sm",children:[e.jsx(S,{className:"h-5 w-5 text-[#1b3a4b]"}),e.jsx("span",{className:"text-xs font-semibold text-[#1b3a4b]",children:T})]},T))}),e.jsxs("button",{onClick:f,className:"w-full h-12 text-base font-semibold rounded-lg mb-6 bg-[#1b3a4b] hover:bg-[#264d61] text-white transition-colors flex items-center justify-center gap-2 shadow-sm",children:[e.jsx(on,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:e.jsx("div",{className:"flex items-center justify-center gap-6",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Gn,{className:"h-4 w-4 text-[#d4a843] fill-[#d4a843]"}),e.jsx("span",{className:"font-bold text-[#1b3a4b] font-serif",children:"5.0"})]})})}),t.review_snippet&&e.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:e.jsxs("p",{className:"text-sm text-[#4a5568] italic text-center font-serif",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-[#1b3a4b] mb-2 font-serif",children:"About"}),e.jsx("p",{className:"text-sm text-[#4a5568] leading-relaxed",children:t.bio})]}),e.jsx(Foe,{card:t,variant:"classic"}),e.jsx(Boe,{cardId:t.id,variant:"classic"}),e.jsxs("div",{className:"bg-white rounded-lg border border-[#d4cfc5] shadow-sm divide-y divide-[#e8e3db] mb-6",children:[t.show_save_contact&&e.jsxs("button",{onClick:y,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(xi,{className:"h-4 w-4 text-[#5a7a6f]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{no(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(Gn,{className:"h-4 w-4 text-[#d4a843]"})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:b,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(hr,{className:"h-4 w-4 text-[#5a7a6f]"})," Refer a Friend"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(yc,{className:"h-4 w-4 text-[#5a7a6f]"})," Connect with Me"]}),e.jsxs("button",{onClick:_,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(ld,{className:"h-4 w-4 text-[#5a7a6f]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,T)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>no(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-white border border-[#d4cfc5] hover:bg-[#e8e3db] flex items-center justify-center text-lg transition-colors shadow-sm",children:j[S.platform.toLowerCase()]||"🔗"},T))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Powered by LevelUp"})})]}),e.jsx(zoe,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function r_e({card:t}){switch(t.theme){case"luxury":return e.jsx(K0t,{card:t});case"bold":return e.jsx(Z0t,{card:t});case"classic":return e.jsx(Y0t,{card:t});case"standard":default:return e.jsx(G0t,{card:t})}}function X0t(){const t=bu();C.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]);const s=t.pathname.slice(1);return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Agent Cards"}),e.jsx("p",{className:"text-slate-500",children:"Visit a specific agent's card URL to view their digital business card."})]})}):e.jsx(Q0t,{slug:s})}function Q0t({slug:t}){return e.jsx(J0t,{slug:t})}function J0t({slug:t}){var o;const{data:s,isLoading:r,error:n}=A9e(t);if(C.useEffect(()=>{s!=null&&s.id&&no(s.id,"card_view")},[s==null?void 0:s.id]),r)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md mx-auto p-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(xs,{className:"h-28 w-28 rounded-full"}),e.jsx(xs,{className:"h-6 w-48"}),e.jsx(xs,{className:"h-4 w-36"})]}),e.jsx(xs,{className:"h-12 w-full"}),e.jsx(xs,{className:"h-12 w-full"})]})});if(n||!s)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Card Not Found"}),e.jsx("p",{className:"text-slate-500",children:"This agent card doesn't exist or isn't published yet."})]})});const a=((o=s.profile)==null?void 0:o.name)||"Agent";return e.jsxs(e.Fragment,{children:[e.jsxs(lh,{children:[e.jsxs("title",{children:[a," | Real Estate Agent"]}),e.jsx("meta",{name:"description",content:s.positioning_statement||`Connect with ${a}, your trusted real estate professional.`}),e.jsx("meta",{property:"og:title",content:`${a} | Real Estate Agent`}),e.jsx("meta",{property:"og:description",content:s.positioning_statement||`Connect with ${a}`}),s.avatar_url&&e.jsx("meta",{property:"og:image",content:s.avatar_url})]}),e.jsx(r_e,{card:s})]})}function L9e({presentationId:t,ctaLabel:s,agentName:r,prefillName:n,prefillEmail:a,prefillPhone:o}){const[l,i]=C.useState(n||""),[d,u]=C.useState(a||""),[p,f]=C.useState(o||""),[y,_]=C.useState(""),[b,w]=C.useState(""),[j,k]=C.useState(!1),[S,T]=C.useState(!1),I=async L=>{if(L.preventDefault(),!l.trim()){fe.error("Please enter your name");return}k(!0);try{const{error:R}=await G.from("smart_presentation_leads").insert({presentation_id:t,name:l.trim(),email:d.trim()||null,phone:p.trim()||null,intent:y||null,message:b.trim()||null});if(R)throw R;try{await G.rpc("log_presentation_view",{p_presentation_id:t,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}G.functions.invoke("presentation-lead-notify",{body:{presentationId:t,name:l.trim(),email:d.trim()||void 0,phone:p.trim()||void 0,intent:y||void 0,message:b.trim()||void 0}}).catch($=>console.error("Presentation lead notify failed:",$)),T(!0)}catch{fe.error("Something went wrong. Please try again.")}finally{k(!1)}};return S?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(ha,{className:"h-8 w-8 text-emerald-600"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Thank you!"}),e.jsx("p",{className:"text-gray-500",children:r?`${r} will be in touch soon.`:"We'll be in touch soon."})]}):e.jsxs("form",{onSubmit:I,className:"space-y-4 max-w-md mx-auto",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"pres-lead-name",children:"Name *"}),e.jsx(Re,{id:"pres-lead-name",value:l,onChange:L=>i(L.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"pres-lead-phone",children:"Phone"}),e.jsx(Re,{id:"pres-lead-phone",type:"tel",value:p,onChange:L=>f(L.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"pres-lead-email",children:"Email"}),e.jsx(Re,{id:"pres-lead-email",type:"email",value:d,onChange:L=>u(L.target.value),placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"pres-lead-intent",children:"I'm looking to..."}),e.jsxs(sr,{value:y,onValueChange:_,children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select one"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"buy",children:"Buy a home"}),e.jsx(At,{value:"sell",children:"Sell my home"}),e.jsx(At,{value:"both",children:"Buy & Sell"}),e.jsx(At,{value:"other",children:"Something else"})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"pres-lead-message",children:"Message (optional)"}),e.jsx(Re,{id:"pres-lead-message",value:b,onChange:L=>w(L.target.value),placeholder:"Anything you'd like us to know"})]}),e.jsx(K,{type:"submit",className:"w-full text-lg py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",disabled:j,children:j?"Sending...":s})]})}function evt(){const t=bu();C.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]);const s=t.pathname.slice(1);return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Smart Presentations"}),e.jsx("p",{className:"text-slate-500",children:"Visit a specific presentation URL to view it."})]})}):e.jsx(tvt,{shareToken:s})}function tvt({shareToken:t}){var b;const[s,r]=C.useState(null),[n,a]=C.useState(!0),[o,l]=C.useState(0),[i,d]=C.useState(!1);C.useEffect(()=>{u()},[t]);const u=async()=>{const{data:w,error:j}=await G.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(j||!w){d(!0),a(!1);return}const{data:k}=await G.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",w.owner_user_id).single();let S;if(k!=null&&k.brokerage_id){const{data:I}=await G.from("brokerages").select("name").eq("id",k.brokerage_id).single();S=(I==null?void 0:I.name)||void 0}let T=null;if(w.contact_id){const{data:I}=await G.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",w.contact_id).single();T=I}r({...w,owner_name:k==null?void 0:k.name,owner_email:k==null?void 0:k.email,owner_phone:k==null?void 0:k.phone,owner_avatar:k==null?void 0:k.avatar_url,owner_title:(k==null?void 0:k.title)||void 0,brokerage_name:S,contact_name:T?[T.first_name,T.last_name].filter(Boolean).join(" "):void 0,contact_email:(T==null?void 0:T.email)||void 0,contact_phone:(T==null?void 0:T.phone)||void 0}),a(!1);try{await G.rpc("log_presentation_view",{p_presentation_id:w.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(s){try{await G.rpc("log_presentation_view",{p_presentation_id:s.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}s.cta_url&&window.open(s.cta_url,"_blank")}},f=w=>{const j=w.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(j)return`https://www.youtube.com/embed/${j[1]}?rel=0`;if(w.includes("iframe.mediadelivery.net/play/")){const T=w.replace("/play/","/embed/"),I=T.includes("?")?"&":"?";return`${T}${I}responsive=true`}if(w.includes("iframe.mediadelivery.net")){const T=w.includes("?")?"&":"?";return`${w}${T}responsive=true`}const k=w.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(k)return`https://www.loom.com/embed/${k[1]}`;const S=w.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return S?`https://iframe.mediadelivery.net/embed/${S[1]}/${S[2]}?responsive=true`:w};if(n)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[e.jsx(xs,{className:"h-12 w-3/4 mx-auto"}),e.jsx(xs,{className:"h-64 w-full"}),e.jsx(xs,{className:"h-8 w-1/2 mx-auto"})]})});if(i||!s)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Presentation Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This presentation may have been removed or is no longer available."})]})});const y=s.sections.filter(w=>w.is_visible!==!1),_=y[o];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[e.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:e.jsx("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-end",children:e.jsxs("div",{className:"flex items-center gap-3",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),e.jsxs("div",{className:"text-right text-sm",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.owner_title}),s.brokerage_name&&!s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.brokerage_name})]})]})})}),e.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:s.heading||(s.client_name?`Welcome, ${s.client_name}!`:s.title)}),s.property_address&&e.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",e.jsx("strong",{children:s.property_address}),"."]})]}),e.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[e.jsxs("div",{className:"md:col-span-3",children:[_!=null&&_.video_url?e.jsx("div",{className:"relative w-full rounded-xl overflow-hidden shadow-lg bg-gray-900",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:f(_.video_url),className:"absolute inset-0 w-full h-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,loading:"lazy"})}):_!=null&&_.image_url?e.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:e.jsx("img",{src:_.image_url,alt:_.title,className:"w-full h-auto object-cover",loading:"lazy"})}):e.jsxs("div",{className:"aspect-video bg-gradient-to-br from-blue-50 to-slate-100 rounded-xl flex flex-col items-center justify-center shadow-lg",children:[e.jsx("span",{className:"text-5xl mb-3",children:_==null?void 0:_.icon}),e.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:_==null?void 0:_.title}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:_==null?void 0:_.description})]}),(_==null?void 0:_.text)&&e.jsx("div",{className:"mt-4 p-4 bg-white rounded-lg border text-gray-700 text-sm leading-relaxed prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:_.text}})]}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:y.map((w,j)=>e.jsx("button",{onClick:()=>l(j),className:Pt("w-full text-left p-4 rounded-xl border transition-all",o===j?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(j+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:w.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:w.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:w.description})]})]})},j))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),(b=s.cta_url)!=null&&b.trim()?e.jsxs(K,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(sn,{className:"h-5 w-5 ml-2"})]}):e.jsx("div",{className:"max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6",children:e.jsx(L9e,{presentationId:s.id,ctaLabel:s.cta_label,agentName:s.owner_name||void 0,prefillName:s.contact_name,prefillEmail:s.contact_email,prefillPhone:s.contact_phone})})]})]}),e.jsx("footer",{className:"border-t border-gray-100 bg-white mt-12 py-6 text-center text-xs text-gray-400",children:"Powered by LevelUp"})]})}const Lf=()=>{const t=Ya();return wt({queryKey:["user-team",t],queryFn:async()=>{const{data:s,error:r}=await G.from("team_members").select("id, team_id, role").eq("user_id",t).maybeSingle();if(console.log("[useUserTeam] membership query:",{userId:t,membership:s,error:r}),r)throw r;if(!s)return null;const{data:n,error:a}=await G.from("teams").select("*").eq("id",s.team_id).single();if(a)throw a;return{membershipId:s.id,teamId:s.team_id,role:s.role,team:n}},enabled:!!t,staleTime:5*60*1e3})};function svt(){const{user:t}=Hs(),s=Ya(),{data:r}=Lf();return wt({queryKey:["open-houses",s,r==null?void 0:r.teamId,r==null?void 0:r.role],queryFn:async()=>{const{data:n,error:a}=await G.from("open_houses").select("*").eq("agent_id",s).order("event_date",{ascending:!1});if(a)throw a;let o=n||[];if((r==null?void 0:r.role)==="team_leader"&&r.teamId){const{data:l,error:i}=await G.rpc("get_team_open_houses",{_user_id:s});if(!i&&l){const d=[...new Set(l.map(f=>f.agent_id))],u={};if(d.length>0){const{data:f}=await G.from("profiles").select("id, name").in("id",d);f==null||f.forEach(y=>{y.name&&(u[y.id]=y.name)})}const p=l.map(f=>({...f,agent_name:u[f.agent_id]||void 0}));o=[...o,...p]}}return o.sort((l,i)=>i.event_date.localeCompare(l.event_date)),o},enabled:!!t&&!!s})}function I_s(t){const{user:s}=Hs();return wt({queryKey:["open-house",t],queryFn:async()=>{const{data:r,error:n}=await G.from("open_houses").select("*").eq("id",t).single();if(n)throw n;return r},enabled:!!s&&!!t})}function D9e(t){const{user:s}=Hs(),r=rs();return C.useEffect(()=>{if(!t)return;const n=G.channel(`visitors-${t}`).on("postgres_changes",{event:"*",schema:"public",table:"open_house_visitors",filter:`open_house_id=eq.${t}`},()=>{r.invalidateQueries({queryKey:["open-house-visitors",t]}),r.invalidateQueries({queryKey:["open-houses"]})}).subscribe();return()=>{G.removeChannel(n)}},[t,r]),wt({queryKey:["open-house-visitors",t],queryFn:async()=>{const{data:n,error:a}=await G.from("open_house_visitors").select("*").eq("open_house_id",t).order("created_at",{ascending:!1});if(a)throw a;return n},enabled:!!s&&!!t})}function rvt(){const t=rs(),s=Ya();return Dt({mutationFn:async r=>{const{data:n,error:a}=await G.from("open_houses").insert({...r,agent_id:s}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),pn({title:"Open house created!"})},onError:r=>{pn({title:"Error",description:r.message,variant:"destructive"})}})}function O9e(){const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{error:n}=await G.from("open_houses").update(r).eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["open-houses"]}),t.invalidateQueries({queryKey:["open-house",r.id]})}})}function nvt(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("open_houses").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),pn({title:"Open house deleted"})}})}function avt(t){return wt({queryKey:["public-open-house",t],queryFn:async()=>{const{data:s,error:r}=await G.from("open_houses").select("*, profiles:agent_id(name, avatar_url, title)").eq("slug",t).eq("is_active",!0).single();if(r)throw r;let n=null;if(s.agent_id){const{data:a}=await G.from("agent_cards").select("slug").eq("user_id",s.agent_id).eq("is_published",!0).maybeSingle();a&&(n=a.slug)}return{...s,agent_card_slug:n}},enabled:!!t})}function ivt(t){const{user:s}=Hs();return wt({queryKey:["survey-questions",t],queryFn:async()=>{const{data:r,error:n}=await G.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;return r},enabled:!!s&&!!t})}function ovt(t){return wt({queryKey:["public-survey-questions",t],queryFn:async()=>{const{data:s,error:r}=await G.from("open_house_survey_questions").select("*").eq("open_house_id",t).eq("is_active",!0).order("sort_order");if(r)throw r;return s},enabled:!!t})}function lvt(){return Dt({mutationFn:async t=>{const{error:s}=await G.from("open_house_survey_responses").insert(t);if(s)throw s}})}function cvt(t){const{user:s}=Hs();return wt({queryKey:["survey-responses",t],queryFn:async()=>{const{data:r,error:n}=await G.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;const a=(r||[]).map(i=>i.id);if(a.length===0)return{questions:[],responses:[]};const{data:o,error:l}=await G.from("open_house_survey_responses").select("*").in("question_id",a).order("created_at",{ascending:!1});if(l)throw l;return{questions:r,responses:o||[]}},enabled:!!s&&!!t})}function dvt(){const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("open_house_survey_questions").insert(s).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function uvt(){const t=rs();return Dt({mutationFn:async({id:s,open_house_id:r,...n})=>{const{error:a}=await G.from("open_house_survey_questions").update(n).eq("id",s);if(a)throw a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function hvt(){const t=rs();return Dt({mutationFn:async({id:s,open_house_id:r})=>{const{error:n}=await G.from("open_house_survey_questions").delete().eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function mvt(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.rpc("seed_default_survey_questions",{_open_house_id:s});if(r)throw r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r]})}})}function pvt(){return Dt({mutationFn:async t=>{const{data:s,error:r}=await G.from("open_house_visitors").insert(t).select("id").single();if(r)throw r;return s}})}var qoe="Switch",[fvt]=Ec(qoe),[gvt,xvt]=fvt(qoe),R9e=C.forwardRef((t,s)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d="on",onCheckedChange:u,form:p,...f}=t,[y,_]=C.useState(null),b=Ea(s,T=>_(T)),w=C.useRef(!1),j=y?p||!!y.closest("form"):!0,[k,S]=vu({prop:a,defaultProp:o??!1,onChange:u,caller:qoe});return e.jsxs(gvt,{scope:r,checked:k,disabled:i,children:[e.jsx(Qr.button,{type:"button",role:"switch","aria-checked":k,"aria-required":l,"data-state":$9e(k),"data-disabled":i?"":void 0,disabled:i,value:d,...f,ref:b,onClick:Mr(t.onClick,T=>{S(I=>!I),j&&(w.current=T.isPropagationStopped(),w.current||T.stopPropagation())})}),j&&e.jsx(B9e,{control:y,bubbles:!w.current,name:n,value:d,checked:k,required:l,disabled:i,form:p,style:{transform:"translateX(-100%)"}})]})});R9e.displayName=qoe;var F9e="SwitchThumb",z9e=C.forwardRef((t,s)=>{const{__scopeSwitch:r,...n}=t,a=xvt(F9e,r);return e.jsx(Qr.span,{"data-state":$9e(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});z9e.displayName=F9e;var yvt="SwitchBubbleInput",B9e=C.forwardRef(({__scopeSwitch:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=C.useRef(null),i=Ea(l,o),d=DL(r),u=wL(s);return C.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==r&&_){const b=new Event("click",{bubbles:n});_.call(p,r),p.dispatchEvent(b)}},[d,r,n]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:i,style:{...a.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});B9e.displayName=yvt;function $9e(t){return t?"checked":"unchecked"}var q9e=R9e,vvt=z9e;const Br=C.forwardRef(({className:t,...s},r)=>e.jsx(q9e,{className:Pt("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",t),...s,ref:r,children:e.jsx(vvt,{className:Pt("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Br.displayName=q9e.displayName;function Kn(t){const s=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&s==="[object Date]"?new t.constructor(+t):typeof t=="number"||s==="[object Number]"||typeof t=="string"||s==="[object String]"?new Date(t):new Date(NaN)}function Qo(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function ml(t,s){const r=Kn(t);return isNaN(s)?Qo(t,NaN):(s&&r.setDate(r.getDate()+s),r)}function Kh(t,s){const r=Kn(t);if(isNaN(s))return Qo(t,NaN);if(!s)return r;const n=r.getDate(),a=Qo(t,r.getTime());a.setMonth(r.getMonth()+s+1,0);const o=a.getDate();return n>=o?a:(r.setFullYear(a.getFullYear(),a.getMonth(),n),r)}function U9e(t,s){const r=+Kn(t);return Qo(t,r+s)}const n_e=6048e5,_vt=864e5,Uoe=6e4,OL=36e5,bvt=1e3,G8=43200,q5e=1440;function U5e(t,s){return U9e(t,s*OL)}let wvt={};function X_(){return wvt}function ch(t,s){var i,d,u,p;const r=X_(),n=(s==null?void 0:s.weekStartsOn)??((d=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:d.weekStartsOn)??r.weekStartsOn??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.weekStartsOn)??0,a=Kn(t),o=a.getDay(),l=(o=a.getTime()?r+1:s.getTime()>=l.getTime()?r:r-1}function Zh(t){const s=Kn(t);return s.setHours(0,0,0,0),s}function P_(t){const s=Kn(t),r=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds()));return r.setUTCFullYear(s.getFullYear()),+t-+r}function gp(t,s){const r=Zh(t),n=Zh(s),a=+r-P_(r),o=+n-P_(n);return Math.round((a-o)/_vt)}function jvt(t){const s=V9e(t),r=Qo(t,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),nv(r)}function V4(t,s){return U9e(t,s*Uoe)}function IN(t,s){const r=s*7;return ml(t,r)}function Nvt(t,s){return Kh(t,s*12)}function kvt(t){let s;return t.forEach(function(r){const n=Kn(r);(s===void 0||s{const n=Kn(r);(!s||s>n||isNaN(+n))&&(s=n)}),s||new Date(NaN)}function pre(t,s){const r=Kn(t),n=Kn(s),a=r.getTime()-n.getTime();return a<0?-1:a>0?1:a}function a_e(t){return Qo(t,Date.now())}function cl(t,s){const r=Zh(t),n=Zh(s);return+r==+n}function i_e(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function qge(t){if(!i_e(t)&&typeof t!="number")return!1;const s=Kn(t);return!isNaN(Number(s))}function _3(t,s){const r=Kn(t),n=Kn(s),a=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return a*12+o}function Cvt(t,s,r){const n=ch(t,r),a=ch(s,r),o=+n-P_(n),l=+a-P_(a);return Math.round((o-l)/n_e)}function Qg(t,s){const r=Kn(t),n=Kn(s),a=V5e(r,n),o=Math.abs(gp(r,n));r.setDate(r.getDate()-a*o);const l=+(V5e(r,n)===-a),i=a*(o-l);return i===0?0:i}function V5e(t,s){const r=t.getFullYear()-s.getFullYear()||t.getMonth()-s.getMonth()||t.getDate()-s.getDate()||t.getHours()-s.getHours()||t.getMinutes()-s.getMinutes()||t.getSeconds()-s.getSeconds()||t.getMilliseconds()-s.getMilliseconds();return r<0?-1:r>0?1:r}function H9e(t){return s=>{const n=(t?Math[t]:Math.trunc)(s);return n===0?0:n}}function W9e(t,s){return+Kn(t)-+Kn(s)}function Mvt(t,s,r){const n=W9e(t,s)/OL;return H9e(r==null?void 0:r.roundingMethod)(n)}function Tvt(t){const s=Kn(t);return s.setHours(23,59,59,999),s}function ef(t){const s=Kn(t),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function Avt(t){const s=Kn(t);return+Tvt(s)==+ef(s)}function Evt(t,s){const r=Kn(t),n=Kn(s),a=pre(r,n),o=Math.abs(_3(r,n));let l;if(o<1)l=0;else{r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-a*o);let i=pre(r,n)===-a;Avt(Kn(t))&&o===1&&pre(t,n)===1&&(i=!1),l=a*(o-Number(i))}return l===0?0:l}function Pvt(t,s,r){const n=W9e(t,s)/1e3;return H9e(r==null?void 0:r.roundingMethod)(n)}function Ivt(t,s){const r=Kn(t.start),n=Kn(t.end);let a=+r>+n;const o=a?+r:+n,l=a?n:r;l.setHours(0,0,0,0);let i=1;const d=[];for(;+l<=o;)d.push(Kn(l)),l.setDate(l.getDate()+i),l.setHours(0,0,0,0);return a?d.reverse():d}function pc(t){const s=Kn(t);return s.setDate(1),s.setHours(0,0,0,0),s}function G9e(t){const s=Kn(t),r=Qo(t,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}function Voe(t,s){var i,d,u,p;const r=X_(),n=(s==null?void 0:s.weekStartsOn)??((d=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:d.weekStartsOn)??r.weekStartsOn??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.weekStartsOn)??0,a=Kn(t),o=a.getDay(),l=(o{let n;const a=Lvt[t];return typeof a=="string"?n=a:s===1?n=a.one:n=a.other.replace("{{count}}",s.toString()),r!=null&&r.addSuffix?r.comparison&&r.comparison>0?"in "+n:n+" ago":n};function Whe(t){return(s={})=>{const r=s.width?String(s.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const Ovt={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Rvt={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Fvt={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},zvt={date:Whe({formats:Ovt,defaultWidth:"full"}),time:Whe({formats:Rvt,defaultWidth:"full"}),dateTime:Whe({formats:Fvt,defaultWidth:"full"})},Bvt={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},$vt=(t,s,r,n)=>Bvt[t];function nE(t){return(s,r)=>{const n=r!=null&&r.context?String(r.context):"standalone";let a;if(n==="formatting"&&t.formattingValues){const l=t.defaultFormattingWidth||t.defaultWidth,i=r!=null&&r.width?String(r.width):l;a=t.formattingValues[i]||t.formattingValues[l]}else{const l=t.defaultWidth,i=r!=null&&r.width?String(r.width):t.defaultWidth;a=t.values[i]||t.values[l]}const o=t.argumentCallback?t.argumentCallback(s):s;return a[o]}}const qvt={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Uvt={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Vvt={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Hvt={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Wvt={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Gvt={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Kvt=(t,s)=>{const r=Number(t),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},Zvt={ordinalNumber:Kvt,era:nE({values:qvt,defaultWidth:"wide"}),quarter:nE({values:Uvt,defaultWidth:"wide",argumentCallback:t=>t-1}),month:nE({values:Vvt,defaultWidth:"wide"}),day:nE({values:Hvt,defaultWidth:"wide"}),dayPeriod:nE({values:Wvt,defaultWidth:"wide",formattingValues:Gvt,defaultFormattingWidth:"wide"})};function aE(t){return(s,r={})=>{const n=r.width,a=n&&t.matchPatterns[n]||t.matchPatterns[t.defaultMatchWidth],o=s.match(a);if(!o)return null;const l=o[0],i=n&&t.parsePatterns[n]||t.parsePatterns[t.defaultParseWidth],d=Array.isArray(i)?Xvt(i,f=>f.test(l)):Yvt(i,f=>f.test(l));let u;u=t.valueCallback?t.valueCallback(d):d,u=r.valueCallback?r.valueCallback(u):u;const p=s.slice(l.length);return{value:u,rest:p}}}function Yvt(t,s){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&s(t[r]))return r}function Xvt(t,s){for(let r=0;r{const n=s.match(t.matchPattern);if(!n)return null;const a=n[0],o=s.match(t.parsePattern);if(!o)return null;let l=t.valueCallback?t.valueCallback(o[0]):o[0];l=r.valueCallback?r.valueCallback(l):l;const i=s.slice(a.length);return{value:l,rest:i}}}const Jvt=/^(\d+)(th|st|nd|rd)?/i,e1t=/\d+/i,t1t={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},s1t={any:[/^b/i,/^(a|c)/i]},r1t={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},n1t={any:[/1/i,/2/i,/3/i,/4/i]},a1t={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},i1t={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},o1t={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},l1t={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},c1t={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},d1t={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},u1t={ordinalNumber:Qvt({matchPattern:Jvt,parsePattern:e1t,valueCallback:t=>parseInt(t,10)}),era:aE({matchPatterns:t1t,defaultMatchWidth:"wide",parsePatterns:s1t,defaultParseWidth:"any"}),quarter:aE({matchPatterns:r1t,defaultMatchWidth:"wide",parsePatterns:n1t,defaultParseWidth:"any",valueCallback:t=>t+1}),month:aE({matchPatterns:a1t,defaultMatchWidth:"wide",parsePatterns:i1t,defaultParseWidth:"any"}),day:aE({matchPatterns:o1t,defaultMatchWidth:"wide",parsePatterns:l1t,defaultParseWidth:"any"}),dayPeriod:aE({matchPatterns:c1t,defaultMatchWidth:"any",parsePatterns:d1t,defaultParseWidth:"any"})},Hoe={code:"en-US",formatDistance:Dvt,formatLong:zvt,formatRelative:$vt,localize:Zvt,match:u1t,options:{weekStartsOn:0,firstWeekContainsDate:1}};function h1t(t){const s=Kn(t);return gp(s,G9e(s))+1}function o_e(t){const s=Kn(t),r=+nv(s)-+jvt(s);return Math.round(r/n_e)+1}function l_e(t,s){var p,f,y,_;const r=Kn(t),n=r.getFullYear(),a=X_(),o=(s==null?void 0:s.firstWeekContainsDate)??((f=(p=s==null?void 0:s.locale)==null?void 0:p.options)==null?void 0:f.firstWeekContainsDate)??a.firstWeekContainsDate??((_=(y=a.locale)==null?void 0:y.options)==null?void 0:_.firstWeekContainsDate)??1,l=Qo(t,0);l.setFullYear(n+1,0,o),l.setHours(0,0,0,0);const i=ch(l,s),d=Qo(t,0);d.setFullYear(n,0,o),d.setHours(0,0,0,0);const u=ch(d,s);return r.getTime()>=i.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function m1t(t,s){var i,d,u,p;const r=X_(),n=(s==null?void 0:s.firstWeekContainsDate)??((d=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:d.firstWeekContainsDate)??r.firstWeekContainsDate??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.firstWeekContainsDate)??1,a=l_e(t,s),o=Qo(t,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),ch(o,s)}function c_e(t,s){const r=Kn(t),n=+ch(r,s)-+m1t(r,s);return Math.round(n/n_e)+1}function Xo(t,s){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(s,"0");return r+n}const r1={y(t,s){const r=t.getFullYear(),n=r>0?r:1-r;return Xo(s==="yy"?n%100:n,s.length)},M(t,s){const r=t.getMonth();return s==="M"?String(r+1):Xo(r+1,2)},d(t,s){return Xo(t.getDate(),s.length)},a(t,s){const r=t.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(t,s){return Xo(t.getHours()%12||12,s.length)},H(t,s){return Xo(t.getHours(),s.length)},m(t,s){return Xo(t.getMinutes(),s.length)},s(t,s){return Xo(t.getSeconds(),s.length)},S(t,s){const r=s.length,n=t.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return Xo(a,s.length)}},l4={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},H5e={G:function(t,s,r){const n=t.getFullYear()>0?1:0;switch(s){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});case"GGGG":default:return r.era(n,{width:"wide"})}},y:function(t,s,r){if(s==="yo"){const n=t.getFullYear(),a=n>0?n:1-n;return r.ordinalNumber(a,{unit:"year"})}return r1.y(t,s)},Y:function(t,s,r,n){const a=l_e(t,n),o=a>0?a:1-a;if(s==="YY"){const l=o%100;return Xo(l,2)}return s==="Yo"?r.ordinalNumber(o,{unit:"year"}):Xo(o,s.length)},R:function(t,s){const r=V9e(t);return Xo(r,s.length)},u:function(t,s){const r=t.getFullYear();return Xo(r,s.length)},Q:function(t,s,r){const n=Math.ceil((t.getMonth()+1)/3);switch(s){case"Q":return String(n);case"QQ":return Xo(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(t,s,r){const n=Math.ceil((t.getMonth()+1)/3);switch(s){case"q":return String(n);case"qq":return Xo(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(t,s,r){const n=t.getMonth();switch(s){case"M":case"MM":return r1.M(t,s);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(t,s,r){const n=t.getMonth();switch(s){case"L":return String(n+1);case"LL":return Xo(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(t,s,r,n){const a=c_e(t,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):Xo(a,s.length)},I:function(t,s,r){const n=o_e(t);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):Xo(n,s.length)},d:function(t,s,r){return s==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):r1.d(t,s)},D:function(t,s,r){const n=h1t(t);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):Xo(n,s.length)},E:function(t,s,r){const n=t.getDay();switch(s){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});case"EEEE":default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(t,s,r,n){const a=t.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(s){case"e":return String(o);case"ee":return Xo(o,2);case"eo":return r.ordinalNumber(o,{unit:"day"});case"eee":return r.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(a,{width:"short",context:"formatting"});case"eeee":default:return r.day(a,{width:"wide",context:"formatting"})}},c:function(t,s,r,n){const a=t.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(s){case"c":return String(o);case"cc":return Xo(o,s.length);case"co":return r.ordinalNumber(o,{unit:"day"});case"ccc":return r.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(a,{width:"narrow",context:"standalone"});case"cccccc":return r.day(a,{width:"short",context:"standalone"});case"cccc":default:return r.day(a,{width:"wide",context:"standalone"})}},i:function(t,s,r){const n=t.getDay(),a=n===0?7:n;switch(s){case"i":return String(a);case"ii":return Xo(a,s.length);case"io":return r.ordinalNumber(a,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});case"iiii":default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(t,s,r){const a=t.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(t,s,r){const n=t.getHours();let a;switch(n===12?a=l4.noon:n===0?a=l4.midnight:a=n/12>=1?"pm":"am",s){case"b":case"bb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(t,s,r){const n=t.getHours();let a;switch(n>=17?a=l4.evening:n>=12?a=l4.afternoon:n>=4?a=l4.morning:a=l4.night,s){case"B":case"BB":case"BBB":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(t,s,r){if(s==="ho"){let n=t.getHours()%12;return n===0&&(n=12),r.ordinalNumber(n,{unit:"hour"})}return r1.h(t,s)},H:function(t,s,r){return s==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):r1.H(t,s)},K:function(t,s,r){const n=t.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):Xo(n,s.length)},k:function(t,s,r){let n=t.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):Xo(n,s.length)},m:function(t,s,r){return s==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):r1.m(t,s)},s:function(t,s,r){return s==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):r1.s(t,s)},S:function(t,s){return r1.S(t,s)},X:function(t,s,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return G5e(n);case"XXXX":case"XX":return vN(n);case"XXXXX":case"XXX":default:return vN(n,":")}},x:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"x":return G5e(n);case"xxxx":case"xx":return vN(n);case"xxxxx":case"xxx":default:return vN(n,":")}},O:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+W5e(n,":");case"OOOO":default:return"GMT"+vN(n,":")}},z:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+W5e(n,":");case"zzzz":default:return"GMT"+vN(n,":")}},t:function(t,s,r){const n=Math.trunc(t.getTime()/1e3);return Xo(n,s.length)},T:function(t,s,r){const n=t.getTime();return Xo(n,s.length)}};function W5e(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=Math.trunc(n/60),o=n%60;return o===0?r+String(a):r+String(a)+s+Xo(o,2)}function G5e(t,s){return t%60===0?(t>0?"-":"+")+Xo(Math.abs(t)/60,2):vN(t,s)}function vN(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=Xo(Math.trunc(n/60),2),o=Xo(n%60,2);return r+a+s+o}const K5e=(t,s)=>{switch(t){case"P":return s.date({width:"short"});case"PP":return s.date({width:"medium"});case"PPP":return s.date({width:"long"});case"PPPP":default:return s.date({width:"full"})}},Z9e=(t,s)=>{switch(t){case"p":return s.time({width:"short"});case"pp":return s.time({width:"medium"});case"ppp":return s.time({width:"long"});case"pppp":default:return s.time({width:"full"})}},p1t=(t,s)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return K5e(t,s);let o;switch(n){case"P":o=s.dateTime({width:"short"});break;case"PP":o=s.dateTime({width:"medium"});break;case"PPP":o=s.dateTime({width:"long"});break;case"PPPP":default:o=s.dateTime({width:"full"});break}return o.replace("{{date}}",K5e(n,s)).replace("{{time}}",Z9e(a,s))},Uge={p:Z9e,P:p1t},f1t=/^D+$/,g1t=/^Y+$/,x1t=["D","DD","YY","YYYY"];function Y9e(t){return f1t.test(t)}function X9e(t){return g1t.test(t)}function Vge(t,s,r){const n=y1t(t,s,r);if(console.warn(n),x1t.includes(t))throw new RangeError(n)}function y1t(t,s,r){const n=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${s}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const v1t=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,_1t=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,b1t=/^'([^]*?)'?$/,w1t=/''/g,j1t=/[a-zA-Z]/;function ys(t,s,r){var p,f,y,_,b,w,j,k;const n=X_(),a=(r==null?void 0:r.locale)??n.locale??Hoe,o=(r==null?void 0:r.firstWeekContainsDate)??((f=(p=r==null?void 0:r.locale)==null?void 0:p.options)==null?void 0:f.firstWeekContainsDate)??n.firstWeekContainsDate??((_=(y=n.locale)==null?void 0:y.options)==null?void 0:_.firstWeekContainsDate)??1,l=(r==null?void 0:r.weekStartsOn)??((w=(b=r==null?void 0:r.locale)==null?void 0:b.options)==null?void 0:w.weekStartsOn)??n.weekStartsOn??((k=(j=n.locale)==null?void 0:j.options)==null?void 0:k.weekStartsOn)??0,i=Kn(t);if(!qge(i))throw new RangeError("Invalid time value");let d=s.match(_1t).map(S=>{const T=S[0];if(T==="p"||T==="P"){const I=Uge[T];return I(S,a.formatLong)}return S}).join("").match(v1t).map(S=>{if(S==="''")return{isToken:!1,value:"'"};const T=S[0];if(T==="'")return{isToken:!1,value:N1t(S)};if(H5e[T])return{isToken:!0,value:S};if(T.match(j1t))throw new RangeError("Format string contains an unescaped latin alphabet character `"+T+"`");return{isToken:!1,value:S}});a.localize.preprocessor&&(d=a.localize.preprocessor(i,d));const u={firstWeekContainsDate:o,weekStartsOn:l,locale:a};return d.map(S=>{if(!S.isToken)return S.value;const T=S.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&X9e(T)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&Y9e(T))&&Vge(T,s,String(t));const I=H5e[T[0]];return I(i,T,a.localize,u)}).join("")}function N1t(t){const s=t.match(b1t);return s?s[1].replace(w1t,"'"):t}function k1t(t,s,r){const n=X_(),a=(r==null?void 0:r.locale)??n.locale??Hoe,o=2520,l=pre(t,s);if(isNaN(l))throw new RangeError("Invalid time value");const i=Object.assign({},r,{addSuffix:r==null?void 0:r.addSuffix,comparison:l});let d,u;l>0?(d=Kn(s),u=Kn(t)):(d=Kn(t),u=Kn(s));const p=Pvt(u,d),f=(P_(u)-P_(d))/1e3,y=Math.round((p-f)/60);let _;if(y<2)return r!=null&&r.includeSeconds?p<5?a.formatDistance("lessThanXSeconds",5,i):p<10?a.formatDistance("lessThanXSeconds",10,i):p<20?a.formatDistance("lessThanXSeconds",20,i):p<40?a.formatDistance("halfAMinute",0,i):p<60?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",1,i):y===0?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",y,i);if(y<45)return a.formatDistance("xMinutes",y,i);if(y<90)return a.formatDistance("aboutXHours",1,i);if(yn.getTime()}function Fk(t,s){const r=Kn(t),n=Kn(s);return+r<+n}function P1t(t){return+Kn(t)>Date.now()}function I1t(t,s){const r=s instanceof Date?Qo(s,0):new s(0);return r.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),r.setHours(t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()),r}const L1t=10;class Q9e{constructor(){_n(this,"subPriority",0)}validate(s,r){return!0}}class D1t extends Q9e{constructor(s,r,n,a,o){super(),this.value=s,this.validateValue=r,this.setValue=n,this.priority=a,o&&(this.subPriority=o)}validate(s,r){return this.validateValue(s,this.value,r)}set(s,r,n){return this.setValue(s,r,this.value,n)}}class O1t extends Q9e{constructor(){super(...arguments);_n(this,"priority",L1t);_n(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:Qo(r,I1t(r,Date))}}class $o{run(s,r,n,a){const o=this.parse(s,r,n,a);return o?{setter:new D1t(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(s,r,n){return!0}}class R1t extends $o{constructor(){super(...arguments);_n(this,"priority",140);_n(this,"incompatibleTokens",["R","u","t","T"])}parse(r,n,a){switch(n){case"G":case"GG":case"GGG":return a.era(r,{width:"abbreviated"})||a.era(r,{width:"narrow"});case"GGGGG":return a.era(r,{width:"narrow"});case"GGGG":default:return a.era(r,{width:"wide"})||a.era(r,{width:"abbreviated"})||a.era(r,{width:"narrow"})}}set(r,n,a){return n.era=a,r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}const nd={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},$x={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function ad(t,s){return t&&{value:s(t.value),rest:t.rest}}function Sc(t,s){const r=s.match(t);return r?{value:parseInt(r[0],10),rest:s.slice(r[0].length)}:null}function qx(t,s){const r=s.match(t);if(!r)return null;if(r[0]==="Z")return{value:0,rest:s.slice(1)};const n=r[1]==="+"?1:-1,a=r[2]?parseInt(r[2],10):0,o=r[3]?parseInt(r[3],10):0,l=r[5]?parseInt(r[5],10):0;return{value:n*(a*OL+o*Uoe+l*bvt),rest:s.slice(r[0].length)}}function J9e(t){return Sc(nd.anyDigitsSigned,t)}function Yc(t,s){switch(t){case 1:return Sc(nd.singleDigit,s);case 2:return Sc(nd.twoDigits,s);case 3:return Sc(nd.threeDigits,s);case 4:return Sc(nd.fourDigits,s);default:return Sc(new RegExp("^\\d{1,"+t+"}"),s)}}function Nne(t,s){switch(t){case 1:return Sc(nd.singleDigitSigned,s);case 2:return Sc(nd.twoDigitsSigned,s);case 3:return Sc(nd.threeDigitsSigned,s);case 4:return Sc(nd.fourDigitsSigned,s);default:return Sc(new RegExp("^-?\\d{1,"+t+"}"),s)}}function d_e(t){switch(t){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;case"am":case"midnight":case"night":default:return 0}}function e$e(t,s){const r=s>0,n=r?s:1-s;let a;if(n<=50)a=t||100;else{const o=n+50,l=Math.trunc(o/100)*100,i=t>=o%100;a=t+l-(i?100:0)}return r?a:1-a}function t$e(t){return t%400===0||t%4===0&&t%100!==0}class F1t extends $o{constructor(){super(...arguments);_n(this,"priority",130);_n(this,"incompatibleTokens",["Y","R","u","w","I","i","e","c","t","T"])}parse(r,n,a){const o=l=>({year:l,isTwoDigitYear:n==="yy"});switch(n){case"y":return ad(Yc(4,r),o);case"yo":return ad(a.ordinalNumber(r,{unit:"year"}),o);default:return ad(Yc(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a){const o=r.getFullYear();if(a.isTwoDigitYear){const i=e$e(a.year,o);return r.setFullYear(i,0,1),r.setHours(0,0,0,0),r}const l=!("era"in n)||n.era===1?a.year:1-a.year;return r.setFullYear(l,0,1),r.setHours(0,0,0,0),r}}class z1t extends $o{constructor(){super(...arguments);_n(this,"priority",130);_n(this,"incompatibleTokens",["y","R","u","Q","q","M","L","I","d","D","i","t","T"])}parse(r,n,a){const o=l=>({year:l,isTwoDigitYear:n==="YY"});switch(n){case"Y":return ad(Yc(4,r),o);case"Yo":return ad(a.ordinalNumber(r,{unit:"year"}),o);default:return ad(Yc(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a,o){const l=l_e(r,o);if(a.isTwoDigitYear){const d=e$e(a.year,l);return r.setFullYear(d,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),ch(r,o)}const i=!("era"in n)||n.era===1?a.year:1-a.year;return r.setFullYear(i,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),ch(r,o)}}class B1t extends $o{constructor(){super(...arguments);_n(this,"priority",130);_n(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(r,n){return Nne(n==="R"?4:n.length,r)}set(r,n,a){const o=Qo(r,0);return o.setFullYear(a,0,4),o.setHours(0,0,0,0),nv(o)}}class $1t extends $o{constructor(){super(...arguments);_n(this,"priority",130);_n(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(r,n){return Nne(n==="u"?4:n.length,r)}set(r,n,a){return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}class q1t extends $o{constructor(){super(...arguments);_n(this,"priority",120);_n(this,"incompatibleTokens",["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"Q":case"QQ":return Yc(n.length,r);case"Qo":return a.ordinalNumber(r,{unit:"quarter"});case"QQQ":return a.quarter(r,{width:"abbreviated",context:"formatting"})||a.quarter(r,{width:"narrow",context:"formatting"});case"QQQQQ":return a.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return a.quarter(r,{width:"wide",context:"formatting"})||a.quarter(r,{width:"abbreviated",context:"formatting"})||a.quarter(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=1&&n<=4}set(r,n,a){return r.setMonth((a-1)*3,1),r.setHours(0,0,0,0),r}}class U1t extends $o{constructor(){super(...arguments);_n(this,"priority",120);_n(this,"incompatibleTokens",["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"q":case"qq":return Yc(n.length,r);case"qo":return a.ordinalNumber(r,{unit:"quarter"});case"qqq":return a.quarter(r,{width:"abbreviated",context:"standalone"})||a.quarter(r,{width:"narrow",context:"standalone"});case"qqqqq":return a.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return a.quarter(r,{width:"wide",context:"standalone"})||a.quarter(r,{width:"abbreviated",context:"standalone"})||a.quarter(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=1&&n<=4}set(r,n,a){return r.setMonth((a-1)*3,1),r.setHours(0,0,0,0),r}}class V1t extends $o{constructor(){super(...arguments);_n(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);_n(this,"priority",110)}parse(r,n,a){const o=l=>l-1;switch(n){case"M":return ad(Sc(nd.month,r),o);case"MM":return ad(Yc(2,r),o);case"Mo":return ad(a.ordinalNumber(r,{unit:"month"}),o);case"MMM":return a.month(r,{width:"abbreviated",context:"formatting"})||a.month(r,{width:"narrow",context:"formatting"});case"MMMMM":return a.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return a.month(r,{width:"wide",context:"formatting"})||a.month(r,{width:"abbreviated",context:"formatting"})||a.month(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=11}set(r,n,a){return r.setMonth(a,1),r.setHours(0,0,0,0),r}}class H1t extends $o{constructor(){super(...arguments);_n(this,"priority",110);_n(this,"incompatibleTokens",["Y","R","q","Q","M","w","I","D","i","e","c","t","T"])}parse(r,n,a){const o=l=>l-1;switch(n){case"L":return ad(Sc(nd.month,r),o);case"LL":return ad(Yc(2,r),o);case"Lo":return ad(a.ordinalNumber(r,{unit:"month"}),o);case"LLL":return a.month(r,{width:"abbreviated",context:"standalone"})||a.month(r,{width:"narrow",context:"standalone"});case"LLLLL":return a.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return a.month(r,{width:"wide",context:"standalone"})||a.month(r,{width:"abbreviated",context:"standalone"})||a.month(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=0&&n<=11}set(r,n,a){return r.setMonth(a,1),r.setHours(0,0,0,0),r}}function W1t(t,s,r){const n=Kn(t),a=c_e(n,r)-s;return n.setDate(n.getDate()-a*7),n}class G1t extends $o{constructor(){super(...arguments);_n(this,"priority",100);_n(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(r,n,a){switch(n){case"w":return Sc(nd.week,r);case"wo":return a.ordinalNumber(r,{unit:"week"});default:return Yc(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a,o){return ch(W1t(r,a,o),o)}}function K1t(t,s){const r=Kn(t),n=o_e(r)-s;return r.setDate(r.getDate()-n*7),r}class Z1t extends $o{constructor(){super(...arguments);_n(this,"priority",100);_n(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"])}parse(r,n,a){switch(n){case"I":return Sc(nd.week,r);case"Io":return a.ordinalNumber(r,{unit:"week"});default:return Yc(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a){return nv(K1t(r,a))}}const Y1t=[31,28,31,30,31,30,31,31,30,31,30,31],X1t=[31,29,31,30,31,30,31,31,30,31,30,31];class Q1t extends $o{constructor(){super(...arguments);_n(this,"priority",90);_n(this,"subPriority",1);_n(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"d":return Sc(nd.date,r);case"do":return a.ordinalNumber(r,{unit:"date"});default:return Yc(n.length,r)}}validate(r,n){const a=r.getFullYear(),o=t$e(a),l=r.getMonth();return o?n>=1&&n<=X1t[l]:n>=1&&n<=Y1t[l]}set(r,n,a){return r.setDate(a),r.setHours(0,0,0,0),r}}class J1t extends $o{constructor(){super(...arguments);_n(this,"priority",90);_n(this,"subpriority",1);_n(this,"incompatibleTokens",["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"])}parse(r,n,a){switch(n){case"D":case"DD":return Sc(nd.dayOfYear,r);case"Do":return a.ordinalNumber(r,{unit:"date"});default:return Yc(n.length,r)}}validate(r,n){const a=r.getFullYear();return t$e(a)?n>=1&&n<=366:n>=1&&n<=365}set(r,n,a){return r.setMonth(0,a),r.setHours(0,0,0,0),r}}function u_e(t,s,r){var f,y,_,b;const n=X_(),a=(r==null?void 0:r.weekStartsOn)??((y=(f=r==null?void 0:r.locale)==null?void 0:f.options)==null?void 0:y.weekStartsOn)??n.weekStartsOn??((b=(_=n.locale)==null?void 0:_.options)==null?void 0:b.weekStartsOn)??0,o=Kn(t),l=o.getDay(),d=(s%7+7)%7,u=7-a,p=s<0||s>6?s-(l+u)%7:(d+u)%7-(l+u)%7;return ml(o,p)}class e_t extends $o{constructor(){super(...arguments);_n(this,"priority",90);_n(this,"incompatibleTokens",["D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"E":case"EE":case"EEE":return a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"EEEEE":return a.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"EEEE":default:return a.day(r,{width:"wide",context:"formatting"})||a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=6}set(r,n,a,o){return r=u_e(r,a,o),r.setHours(0,0,0,0),r}}class t_t extends $o{constructor(){super(...arguments);_n(this,"priority",90);_n(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"])}parse(r,n,a,o){const l=i=>{const d=Math.floor((i-1)/7)*7;return(i+o.weekStartsOn+6)%7+d};switch(n){case"e":case"ee":return ad(Yc(n.length,r),l);case"eo":return ad(a.ordinalNumber(r,{unit:"day"}),l);case"eee":return a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"eeeee":return a.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"eeee":default:return a.day(r,{width:"wide",context:"formatting"})||a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=6}set(r,n,a,o){return r=u_e(r,a,o),r.setHours(0,0,0,0),r}}class s_t extends $o{constructor(){super(...arguments);_n(this,"priority",90);_n(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"])}parse(r,n,a,o){const l=i=>{const d=Math.floor((i-1)/7)*7;return(i+o.weekStartsOn+6)%7+d};switch(n){case"c":case"cc":return ad(Yc(n.length,r),l);case"co":return ad(a.ordinalNumber(r,{unit:"day"}),l);case"ccc":return a.day(r,{width:"abbreviated",context:"standalone"})||a.day(r,{width:"short",context:"standalone"})||a.day(r,{width:"narrow",context:"standalone"});case"ccccc":return a.day(r,{width:"narrow",context:"standalone"});case"cccccc":return a.day(r,{width:"short",context:"standalone"})||a.day(r,{width:"narrow",context:"standalone"});case"cccc":default:return a.day(r,{width:"wide",context:"standalone"})||a.day(r,{width:"abbreviated",context:"standalone"})||a.day(r,{width:"short",context:"standalone"})||a.day(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=0&&n<=6}set(r,n,a,o){return r=u_e(r,a,o),r.setHours(0,0,0,0),r}}function r_t(t,s){const r=Kn(t),n=M1t(r),a=s-n;return ml(r,a)}class n_t extends $o{constructor(){super(...arguments);_n(this,"priority",90);_n(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"])}parse(r,n,a){const o=l=>l===0?7:l;switch(n){case"i":case"ii":return Yc(n.length,r);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return ad(a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiii":return ad(a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return ad(a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return ad(a.day(r,{width:"wide",context:"formatting"})||a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o)}}validate(r,n){return n>=1&&n<=7}set(r,n,a){return r=r_t(r,a),r.setHours(0,0,0,0),r}}class a_t extends $o{constructor(){super(...arguments);_n(this,"priority",80);_n(this,"incompatibleTokens",["b","B","H","k","t","T"])}parse(r,n,a){switch(n){case"a":case"aa":case"aaa":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"});case"aaaaa":return a.dayPeriod(r,{width:"narrow",context:"formatting"});case"aaaa":default:return a.dayPeriod(r,{width:"wide",context:"formatting"})||a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,a){return r.setHours(d_e(a),0,0,0),r}}class i_t extends $o{constructor(){super(...arguments);_n(this,"priority",80);_n(this,"incompatibleTokens",["a","B","H","k","t","T"])}parse(r,n,a){switch(n){case"b":case"bb":case"bbb":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"});case"bbbbb":return a.dayPeriod(r,{width:"narrow",context:"formatting"});case"bbbb":default:return a.dayPeriod(r,{width:"wide",context:"formatting"})||a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,a){return r.setHours(d_e(a),0,0,0),r}}class o_t extends $o{constructor(){super(...arguments);_n(this,"priority",80);_n(this,"incompatibleTokens",["a","b","t","T"])}parse(r,n,a){switch(n){case"B":case"BB":case"BBB":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"});case"BBBBB":return a.dayPeriod(r,{width:"narrow",context:"formatting"});case"BBBB":default:return a.dayPeriod(r,{width:"wide",context:"formatting"})||a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,a){return r.setHours(d_e(a),0,0,0),r}}class l_t extends $o{constructor(){super(...arguments);_n(this,"priority",70);_n(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,a){switch(n){case"h":return Sc(nd.hour12h,r);case"ho":return a.ordinalNumber(r,{unit:"hour"});default:return Yc(n.length,r)}}validate(r,n){return n>=1&&n<=12}set(r,n,a){const o=r.getHours()>=12;return o&&a<12?r.setHours(a+12,0,0,0):!o&&a===12?r.setHours(0,0,0,0):r.setHours(a,0,0,0),r}}class c_t extends $o{constructor(){super(...arguments);_n(this,"priority",70);_n(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(r,n,a){switch(n){case"H":return Sc(nd.hour23h,r);case"Ho":return a.ordinalNumber(r,{unit:"hour"});default:return Yc(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,a){return r.setHours(a,0,0,0),r}}class d_t extends $o{constructor(){super(...arguments);_n(this,"priority",70);_n(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,a){switch(n){case"K":return Sc(nd.hour11h,r);case"Ko":return a.ordinalNumber(r,{unit:"hour"});default:return Yc(n.length,r)}}validate(r,n){return n>=0&&n<=11}set(r,n,a){return r.getHours()>=12&&a<12?r.setHours(a+12,0,0,0):r.setHours(a,0,0,0),r}}class u_t extends $o{constructor(){super(...arguments);_n(this,"priority",70);_n(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(r,n,a){switch(n){case"k":return Sc(nd.hour24h,r);case"ko":return a.ordinalNumber(r,{unit:"hour"});default:return Yc(n.length,r)}}validate(r,n){return n>=1&&n<=24}set(r,n,a){const o=a<=24?a%24:a;return r.setHours(o,0,0,0),r}}class h_t extends $o{constructor(){super(...arguments);_n(this,"priority",60);_n(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"m":return Sc(nd.minute,r);case"mo":return a.ordinalNumber(r,{unit:"minute"});default:return Yc(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setMinutes(a,0,0),r}}class m_t extends $o{constructor(){super(...arguments);_n(this,"priority",50);_n(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"s":return Sc(nd.second,r);case"so":return a.ordinalNumber(r,{unit:"second"});default:return Yc(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setSeconds(a,0),r}}class p_t extends $o{constructor(){super(...arguments);_n(this,"priority",30);_n(this,"incompatibleTokens",["t","T"])}parse(r,n){const a=o=>Math.trunc(o*Math.pow(10,-n.length+3));return ad(Yc(n.length,r),a)}set(r,n,a){return r.setMilliseconds(a),r}}class f_t extends $o{constructor(){super(...arguments);_n(this,"priority",10);_n(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return qx($x.basicOptionalMinutes,r);case"XX":return qx($x.basic,r);case"XXXX":return qx($x.basicOptionalSeconds,r);case"XXXXX":return qx($x.extendedOptionalSeconds,r);case"XXX":default:return qx($x.extended,r)}}set(r,n,a){return n.timestampIsSet?r:Qo(r,r.getTime()-P_(r)-a)}}class g_t extends $o{constructor(){super(...arguments);_n(this,"priority",10);_n(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return qx($x.basicOptionalMinutes,r);case"xx":return qx($x.basic,r);case"xxxx":return qx($x.basicOptionalSeconds,r);case"xxxxx":return qx($x.extendedOptionalSeconds,r);case"xxx":default:return qx($x.extended,r)}}set(r,n,a){return n.timestampIsSet?r:Qo(r,r.getTime()-P_(r)-a)}}class x_t extends $o{constructor(){super(...arguments);_n(this,"priority",40);_n(this,"incompatibleTokens","*")}parse(r){return J9e(r)}set(r,n,a){return[Qo(r,a*1e3),{timestampIsSet:!0}]}}class y_t extends $o{constructor(){super(...arguments);_n(this,"priority",20);_n(this,"incompatibleTokens","*")}parse(r){return J9e(r)}set(r,n,a){return[Qo(r,a),{timestampIsSet:!0}]}}const v_t={G:new R1t,y:new F1t,Y:new z1t,R:new B1t,u:new $1t,Q:new q1t,q:new U1t,M:new V1t,L:new H1t,w:new G1t,I:new Z1t,d:new Q1t,D:new J1t,E:new e_t,e:new t_t,c:new s_t,i:new n_t,a:new a_t,b:new i_t,B:new o_t,h:new l_t,H:new c_t,K:new d_t,k:new u_t,m:new h_t,s:new m_t,S:new p_t,X:new f_t,x:new g_t,t:new x_t,T:new y_t},__t=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,b_t=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,w_t=/^'([^]*?)'?$/,j_t=/''/g,N_t=/\S/,k_t=/[a-zA-Z]/;function h_e(t,s,r,n){var w,j,k,S;const a=C1t(),o=a.locale??Hoe,l=a.firstWeekContainsDate??((j=(w=a.locale)==null?void 0:w.options)==null?void 0:j.firstWeekContainsDate)??1,i=a.weekStartsOn??((S=(k=a.locale)==null?void 0:k.options)==null?void 0:S.weekStartsOn)??0;if(s==="")return t===""?Kn(r):Qo(r,NaN);const d={firstWeekContainsDate:l,weekStartsOn:i,locale:o},u=[new O1t],p=s.match(b_t).map(T=>{const I=T[0];if(I in Uge){const L=Uge[I];return L(T,o.formatLong)}return T}).join("").match(__t),f=[];for(let T of p){X9e(T)&&Vge(T,s,t),Y9e(T)&&Vge(T,s,t);const I=T[0],L=v_t[I];if(L){const{incompatibleTokens:R}=L;if(Array.isArray(R)){const q=f.find(U=>R.includes(U.token)||U.token===I);if(q)throw new RangeError(`The format string mustn't contain \`${q.fullToken}\` and \`${T}\` at the same time`)}else if(L.incompatibleTokens==="*"&&f.length>0)throw new RangeError(`The format string mustn't contain \`${T}\` and any other token at the same time`);f.push({token:I,fullToken:T});const $=L.run(t,T,o.match,d);if(!$)return Qo(r,NaN);u.push($.setter),t=$.rest}else{if(I.match(k_t))throw new RangeError("Format string contains an unescaped latin alphabet character `"+I+"`");if(T==="''"?T="'":I==="'"&&(T=S_t(T)),t.indexOf(T)===0)t=t.slice(T.length);else return Qo(r,NaN)}}if(t.length>0&&N_t.test(t))return Qo(r,NaN);const y=u.map(T=>T.priority).sort((T,I)=>I-T).filter((T,I,L)=>L.indexOf(T)===I).map(T=>u.filter(I=>I.priority===T).sort((I,L)=>L.subPriority-I.subPriority)).map(T=>T[0]);let _=Kn(r);if(isNaN(_.getTime()))return Qo(r,NaN);const b={};for(const T of y){if(!T.validate(_,d))return Qo(r,NaN);const I=T.set(_,b,d);Array.isArray(I)?(_=I[0],Object.assign(b,I[1])):_=I}return Qo(r,_)}function S_t(t){return t.match(w_t)[1].replace(j_t,"'")}function sy(t){return+Kn(t)o-l);return r>=n&&r<=a}function fre(t,s){return ml(t,-s)}function Ih(t,s){const n=I_t(t);let a;if(n.date){const d=L_t(n.date,2);a=D_t(d.restDateString,d.year)}if(!a||isNaN(a.getTime()))return new Date(NaN);const o=a.getTime();let l=0,i;if(n.time&&(l=O_t(n.time),isNaN(l)))return new Date(NaN);if(n.timezone){if(i=R_t(n.timezone),isNaN(i))return new Date(NaN)}else{const d=new Date(o+l),u=new Date(0);return u.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),u.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),u}return new Date(o+l+i)}const K8={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},A_t=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,E_t=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,P_t=/^([+-])(\d{2})(?::?(\d{2}))?$/;function I_t(t){const s={},r=t.split(K8.dateTimeDelimiter);let n;if(r.length>2)return s;if(/:/.test(r[0])?n=r[0]:(s.date=r[0],n=r[1],K8.timeZoneDelimiter.test(s.date)&&(s.date=t.split(K8.timeZoneDelimiter)[0],n=t.substr(s.date.length,t.length))),n){const a=K8.timezone.exec(n);a?(s.time=n.replace(a[1],""),s.timezone=a[1]):s.time=n}return s}function L_t(t,s){const r=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+s)+"})|(\\d{2}|[+-]\\d{"+(2+s)+"})$)"),n=t.match(r);if(!n)return{year:NaN,restDateString:""};const a=n[1]?parseInt(n[1]):null,o=n[2]?parseInt(n[2]):null;return{year:o===null?a:o*100,restDateString:t.slice((n[1]||n[2]).length)}}function D_t(t,s){if(s===null)return new Date(NaN);const r=t.match(A_t);if(!r)return new Date(NaN);const n=!!r[4],a=iE(r[1]),o=iE(r[2])-1,l=iE(r[3]),i=iE(r[4]),d=iE(r[5])-1;if(n)return q_t(s,i,d)?F_t(s,i,d):new Date(NaN);{const u=new Date(0);return!B_t(s,o,l)||!$_t(s,a)?new Date(NaN):(u.setUTCFullYear(s,o,Math.max(a,l)),u)}}function iE(t){return t?parseInt(t):1}function O_t(t){const s=t.match(E_t);if(!s)return NaN;const r=Ghe(s[1]),n=Ghe(s[2]),a=Ghe(s[3]);return U_t(r,n,a)?r*OL+n*Uoe+a*1e3:NaN}function Ghe(t){return t&&parseFloat(t.replace(",","."))||0}function R_t(t){if(t==="Z")return 0;const s=t.match(P_t);if(!s)return 0;const r=s[1]==="+"?-1:1,n=parseInt(s[2]),a=s[3]&&parseInt(s[3])||0;return V_t(n,a)?r*(n*OL+a*Uoe):NaN}function F_t(t,s,r){const n=new Date(0);n.setUTCFullYear(t,0,4);const a=n.getUTCDay()||7,o=(s-1)*7+r+1-a;return n.setUTCDate(n.getUTCDate()+o),n}const z_t=[31,null,31,30,31,30,31,31,30,31,30,31];function s$e(t){return t%400===0||t%4===0&&t%100!==0}function B_t(t,s,r){return s>=0&&s<=11&&r>=1&&r<=(z_t[s]||(s$e(t)?29:28))}function $_t(t,s){return s>=1&&s<=(s$e(t)?366:365)}function q_t(t,s,r){return s>=1&&s<=53&&r>=0&&r<=6}function U_t(t,s,r){return t===24?s===0&&r===0:r>=0&&r<60&&s>=0&&s<60&&t>=0&&t<25}function V_t(t,s){return s>=0&&s<=59}function Khe(t,s){const r=Kn(t),n=r.getFullYear(),a=r.getDate(),o=Qo(t,0);o.setFullYear(n,s,15),o.setHours(0,0,0,0);const l=S1t(o);return r.setMonth(s,Math.min(a,l)),r}function JP(t,s){const r=Kn(t);return r.setHours(s),r}function eI(t,s){const r=Kn(t);return r.setMinutes(s),r}function Y5e(t,s){const r=Kn(t);return isNaN(+r)?Qo(t,NaN):(r.setFullYear(s),r)}function LN(t,s){return Kh(t,-s)}var Io;(function(t){t.assertEqual=a=>{};function s(a){}t.assertIs=s;function r(a){throw new Error}t.assertNever=r,t.arrayToEnum=a=>{const o={};for(const l of a)o[l]=l;return o},t.getValidEnumValues=a=>{const o=t.objectKeys(a).filter(i=>typeof a[a[i]]!="number"),l={};for(const i of o)l[i]=a[i];return t.objectValues(l)},t.objectValues=a=>t.objectKeys(a).map(function(o){return a[o]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const o=[];for(const l in a)Object.prototype.hasOwnProperty.call(a,l)&&o.push(l);return o},t.find=(a,o)=>{for(const l of a)if(o(l))return l},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,o=" | "){return a.map(l=>typeof l=="string"?`'${l}'`:l).join(o)}t.joinValues=n,t.jsonStringifyReplacer=(a,o)=>typeof o=="bigint"?o.toString():o})(Io||(Io={}));var X5e;(function(t){t.mergeShapes=(s,r)=>({...s,...r})})(X5e||(X5e={}));const na=Io.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),p1=t=>{switch(typeof t){case"undefined":return na.undefined;case"string":return na.string;case"number":return Number.isNaN(t)?na.nan:na.number;case"boolean":return na.boolean;case"function":return na.function;case"bigint":return na.bigint;case"symbol":return na.symbol;case"object":return Array.isArray(t)?na.array:t===null?na.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?na.promise:typeof Map<"u"&&t instanceof Map?na.map:typeof Set<"u"&&t instanceof Set?na.set:typeof Date<"u"&&t instanceof Date?na.date:na.object;default:return na.unknown}},en=Io.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class ly extends Error{get errors(){return this.issues}constructor(s){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=s}format(s){const r=s||function(o){return o.message},n={_errors:[]},a=o=>{for(const l of o.issues)if(l.code==="invalid_union")l.unionErrors.map(a);else if(l.code==="invalid_return_type")a(l.returnTypeError);else if(l.code==="invalid_arguments")a(l.argumentsError);else if(l.path.length===0)n._errors.push(r(l));else{let i=n,d=0;for(;dr.message){const r={},n=[];for(const a of this.issues)if(a.path.length>0){const o=a.path[0];r[o]=r[o]||[],r[o].push(s(a))}else n.push(s(a));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}ly.create=t=>new ly(t);const Hge=(t,s)=>{let r;switch(t.code){case en.invalid_type:t.received===na.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case en.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Io.jsonStringifyReplacer)}`;break;case en.unrecognized_keys:r=`Unrecognized key(s) in object: ${Io.joinValues(t.keys,", ")}`;break;case en.invalid_union:r="Invalid input";break;case en.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Io.joinValues(t.options)}`;break;case en.invalid_enum_value:r=`Invalid enum value. Expected ${Io.joinValues(t.options)}, received '${t.received}'`;break;case en.invalid_arguments:r="Invalid function arguments";break;case en.invalid_return_type:r="Invalid function return type";break;case en.invalid_date:r="Invalid date";break;case en.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Io.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case en.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case en.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case en.custom:r="Invalid input";break;case en.invalid_intersection_types:r="Intersection results could not be merged";break;case en.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case en.not_finite:r="Number must be finite";break;default:r=s.defaultError,Io.assertNever(t)}return{message:r}};let H_t=Hge;function W_t(){return H_t}const G_t=t=>{const{data:s,path:r,errorMaps:n,issueData:a}=t,o=[...r,...a.path||[]],l={...a,path:o};if(a.message!==void 0)return{...a,path:o,message:a.message};let i="";const d=n.filter(u=>!!u).slice().reverse();for(const u of d)i=u(l,{data:s,defaultError:i}).message;return{...a,path:o,message:i}};function qn(t,s){const r=W_t(),n=G_t({issueData:s,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Hge?void 0:Hge].filter(a=>!!a)});t.common.issues.push(n)}class Cp{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(s,r){const n=[];for(const a of r){if(a.status==="aborted")return Ci;a.status==="dirty"&&s.dirty(),n.push(a.value)}return{status:s.value,value:n}}static async mergeObjectAsync(s,r){const n=[];for(const a of r){const o=await a.key,l=await a.value;n.push({key:o,value:l})}return Cp.mergeObjectSync(s,n)}static mergeObjectSync(s,r){const n={};for(const a of r){const{key:o,value:l}=a;if(o.status==="aborted"||l.status==="aborted")return Ci;o.status==="dirty"&&s.dirty(),l.status==="dirty"&&s.dirty(),o.value!=="__proto__"&&(typeof l.value<"u"||a.alwaysSet)&&(n[o.value]=l.value)}return{status:s.value,value:n}}}const Ci=Object.freeze({status:"aborted"}),RE=t=>({status:"dirty",value:t}),Df=t=>({status:"valid",value:t}),Q5e=t=>t.status==="aborted",J5e=t=>t.status==="dirty",b3=t=>t.status==="valid",kne=t=>typeof Promise<"u"&&t instanceof Promise;var ga;(function(t){t.errToObj=s=>typeof s=="string"?{message:s}:s||{},t.toString=s=>typeof s=="string"?s:s==null?void 0:s.message})(ga||(ga={}));class I_{constructor(s,r,n,a){this._cachedPath=[],this.parent=s,this.data=r,this._path=n,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const e3e=(t,s)=>{if(b3(s))return{success:!0,data:s.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new ly(t.common.issues);return this._error=r,this._error}}};function Zi(t){if(!t)return{};const{errorMap:s,invalid_type_error:r,required_error:n,description:a}=t;if(s&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return s?{errorMap:s,description:a}:{errorMap:(l,i)=>{const{message:d}=t;return l.code==="invalid_enum_value"?{message:d??i.defaultError}:typeof i.data>"u"?{message:d??n??i.defaultError}:l.code!=="invalid_type"?{message:i.defaultError}:{message:d??r??i.defaultError}},description:a}}class To{get description(){return this._def.description}_getType(s){return p1(s.data)}_getOrReturnCtx(s,r){return r||{common:s.parent.common,data:s.data,parsedType:p1(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}_processInputParams(s){return{status:new Cp,ctx:{common:s.parent.common,data:s.data,parsedType:p1(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const r=this._parse(s);if(kne(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(s){const r=this._parse(s);return Promise.resolve(r)}parse(s,r){const n=this.safeParse(s,r);if(n.success)return n.data;throw n.error}safeParse(s,r){const n={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:p1(s)},a=this._parseSync({data:s,path:n.path,parent:n});return e3e(n,a)}"~validate"(s){var n,a;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:p1(s)};if(!this["~standard"].async)try{const o=this._parseSync({data:s,path:[],parent:r});return b3(o)?{value:o.value}:{issues:r.common.issues}}catch(o){(a=(n=o==null?void 0:o.message)==null?void 0:n.toLowerCase())!=null&&a.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:s,path:[],parent:r}).then(o=>b3(o)?{value:o.value}:{issues:r.common.issues})}async parseAsync(s,r){const n=await this.safeParseAsync(s,r);if(n.success)return n.data;throw n.error}async safeParseAsync(s,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:p1(s)},a=this._parse({data:s,path:n.path,parent:n}),o=await(kne(a)?a:Promise.resolve(a));return e3e(n,o)}refine(s,r){const n=a=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(a):r;return this._refinement((a,o)=>{const l=s(a),i=()=>o.addIssue({code:en.custom,...n(a)});return typeof Promise<"u"&&l instanceof Promise?l.then(d=>d?!0:(i(),!1)):l?!0:(i(),!1)})}refinement(s,r){return this._refinement((n,a)=>s(n)?!0:(a.addIssue(typeof r=="function"?r(n,a):r),!1))}_refinement(s){return new N3({schema:this,typeName:Mi.ZodEffects,effect:{type:"refinement",refinement:s}})}superRefine(s){return this._refinement(s)}constructor(s){this.spa=this.safeParseAsync,this._def=s,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return y_.create(this,this._def)}nullable(){return k3.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ry.create(this)}promise(){return Tne.create(this,this._def)}or(s){return Cne.create([this,s],this._def)}and(s){return Mne.create(this,s,this._def)}transform(s){return new N3({...Zi(this._def),schema:this,typeName:Mi.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new Zge({...Zi(this._def),innerType:this,defaultValue:r,typeName:Mi.ZodDefault})}brand(){return new gbt({typeName:Mi.ZodBranded,type:this,...Zi(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new Yge({...Zi(this._def),innerType:this,catchValue:r,typeName:Mi.ZodCatch})}describe(s){const r=this.constructor;return new r({...this._def,description:s})}pipe(s){return m_e.create(this,s)}readonly(){return Xge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const K_t=/^c[^\s-]{8,}$/i,Z_t=/^[0-9a-z]+$/,Y_t=/^[0-9A-HJKMNP-TV-Z]{26}$/i,X_t=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Q_t=/^[a-z0-9_-]{21}$/i,J_t=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ebt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,tbt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,sbt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Zhe;const rbt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,nbt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,abt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ibt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,obt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,lbt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,r$e="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",cbt=new RegExp(`^${r$e}$`);function n$e(t){let s="[0-5]\\d";t.precision?s=`${s}\\.\\d{${t.precision}}`:t.precision==null&&(s=`${s}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${s})${r}`}function dbt(t){return new RegExp(`^${n$e(t)}$`)}function ubt(t){let s=`${r$e}T${n$e(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),s=`${s}(${r.join("|")})`,new RegExp(`^${s}$`)}function hbt(t,s){return!!((s==="v4"||!s)&&rbt.test(t)||(s==="v6"||!s)&&abt.test(t))}function mbt(t,s){if(!J_t.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||s&&a.alg!==s)}catch{return!1}}function pbt(t,s){return!!((s==="v4"||!s)&&nbt.test(t)||(s==="v6"||!s)&&ibt.test(t))}class U1 extends To{_parse(s){if(this._def.coerce&&(s.data=String(s.data)),this._getType(s)!==na.string){const o=this._getOrReturnCtx(s);return qn(o,{code:en.invalid_type,expected:na.string,received:o.parsedType}),Ci}const n=new Cp;let a;for(const o of this._def.checks)if(o.kind==="min")s.data.lengtho.value&&(a=this._getOrReturnCtx(s,a),qn(a,{code:en.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){const l=s.data.length>o.value,i=s.data.lengths.test(a),{validation:r,code:en.invalid_string,...ga.errToObj(n)})}_addCheck(s){return new U1({...this._def,checks:[...this._def.checks,s]})}email(s){return this._addCheck({kind:"email",...ga.errToObj(s)})}url(s){return this._addCheck({kind:"url",...ga.errToObj(s)})}emoji(s){return this._addCheck({kind:"emoji",...ga.errToObj(s)})}uuid(s){return this._addCheck({kind:"uuid",...ga.errToObj(s)})}nanoid(s){return this._addCheck({kind:"nanoid",...ga.errToObj(s)})}cuid(s){return this._addCheck({kind:"cuid",...ga.errToObj(s)})}cuid2(s){return this._addCheck({kind:"cuid2",...ga.errToObj(s)})}ulid(s){return this._addCheck({kind:"ulid",...ga.errToObj(s)})}base64(s){return this._addCheck({kind:"base64",...ga.errToObj(s)})}base64url(s){return this._addCheck({kind:"base64url",...ga.errToObj(s)})}jwt(s){return this._addCheck({kind:"jwt",...ga.errToObj(s)})}ip(s){return this._addCheck({kind:"ip",...ga.errToObj(s)})}cidr(s){return this._addCheck({kind:"cidr",...ga.errToObj(s)})}datetime(s){return typeof s=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:s}):this._addCheck({kind:"datetime",precision:typeof(s==null?void 0:s.precision)>"u"?null:s==null?void 0:s.precision,offset:(s==null?void 0:s.offset)??!1,local:(s==null?void 0:s.local)??!1,...ga.errToObj(s==null?void 0:s.message)})}date(s){return this._addCheck({kind:"date",message:s})}time(s){return typeof s=="string"?this._addCheck({kind:"time",precision:null,message:s}):this._addCheck({kind:"time",precision:typeof(s==null?void 0:s.precision)>"u"?null:s==null?void 0:s.precision,...ga.errToObj(s==null?void 0:s.message)})}duration(s){return this._addCheck({kind:"duration",...ga.errToObj(s)})}regex(s,r){return this._addCheck({kind:"regex",regex:s,...ga.errToObj(r)})}includes(s,r){return this._addCheck({kind:"includes",value:s,position:r==null?void 0:r.position,...ga.errToObj(r==null?void 0:r.message)})}startsWith(s,r){return this._addCheck({kind:"startsWith",value:s,...ga.errToObj(r)})}endsWith(s,r){return this._addCheck({kind:"endsWith",value:s,...ga.errToObj(r)})}min(s,r){return this._addCheck({kind:"min",value:s,...ga.errToObj(r)})}max(s,r){return this._addCheck({kind:"max",value:s,...ga.errToObj(r)})}length(s,r){return this._addCheck({kind:"length",value:s,...ga.errToObj(r)})}nonempty(s){return this.min(1,ga.errToObj(s))}trim(){return new U1({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new U1({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new U1({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(s=>s.kind==="datetime")}get isDate(){return!!this._def.checks.find(s=>s.kind==="date")}get isTime(){return!!this._def.checks.find(s=>s.kind==="time")}get isDuration(){return!!this._def.checks.find(s=>s.kind==="duration")}get isEmail(){return!!this._def.checks.find(s=>s.kind==="email")}get isURL(){return!!this._def.checks.find(s=>s.kind==="url")}get isEmoji(){return!!this._def.checks.find(s=>s.kind==="emoji")}get isUUID(){return!!this._def.checks.find(s=>s.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(s=>s.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(s=>s.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(s=>s.kind==="cuid2")}get isULID(){return!!this._def.checks.find(s=>s.kind==="ulid")}get isIP(){return!!this._def.checks.find(s=>s.kind==="ip")}get isCIDR(){return!!this._def.checks.find(s=>s.kind==="cidr")}get isBase64(){return!!this._def.checks.find(s=>s.kind==="base64")}get isBase64url(){return!!this._def.checks.find(s=>s.kind==="base64url")}get minLength(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxLength(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.valuenew U1({checks:[],typeName:Mi.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Zi(t)});function fbt(t,s){const r=(t.toString().split(".")[1]||"").length,n=(s.toString().split(".")[1]||"").length,a=r>n?r:n,o=Number.parseInt(t.toFixed(a).replace(".","")),l=Number.parseInt(s.toFixed(a).replace(".",""));return o%l/10**a}class w3 extends To{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(s){if(this._def.coerce&&(s.data=Number(s.data)),this._getType(s)!==na.number){const o=this._getOrReturnCtx(s);return qn(o,{code:en.invalid_type,expected:na.number,received:o.parsedType}),Ci}let n;const a=new Cp;for(const o of this._def.checks)o.kind==="int"?Io.isInteger(s.data)||(n=this._getOrReturnCtx(s,n),qn(n,{code:en.invalid_type,expected:"integer",received:"float",message:o.message}),a.dirty()):o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),qn(n,{code:en.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?fbt(s.data,o.value)!==0&&(n=this._getOrReturnCtx(s,n),qn(n,{code:en.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(s.data)||(n=this._getOrReturnCtx(s,n),qn(n,{code:en.not_finite,message:o.message}),a.dirty()):Io.assertNever(o);return{status:a.value,value:s.data}}gte(s,r){return this.setLimit("min",s,!0,ga.toString(r))}gt(s,r){return this.setLimit("min",s,!1,ga.toString(r))}lte(s,r){return this.setLimit("max",s,!0,ga.toString(r))}lt(s,r){return this.setLimit("max",s,!1,ga.toString(r))}setLimit(s,r,n,a){return new w3({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:ga.toString(a)}]})}_addCheck(s){return new w3({...this._def,checks:[...this._def.checks,s]})}int(s){return this._addCheck({kind:"int",message:ga.toString(s)})}positive(s){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ga.toString(s)})}negative(s){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ga.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ga.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ga.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:ga.toString(r)})}finite(s){return this._addCheck({kind:"finite",message:ga.toString(s)})}safe(s){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ga.toString(s)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ga.toString(s)})}get minValue(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxValue(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.values.kind==="int"||s.kind==="multipleOf"&&Io.isInteger(s.value))}get isFinite(){let s=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(s===null||n.valuenew w3({checks:[],typeName:Mi.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Zi(t)});class i6 extends To{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(s){if(this._def.coerce)try{s.data=BigInt(s.data)}catch{return this._getInvalidInput(s)}if(this._getType(s)!==na.bigint)return this._getInvalidInput(s);let n;const a=new Cp;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),qn(n,{code:en.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="multipleOf"?s.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(s,n),qn(n,{code:en.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):Io.assertNever(o);return{status:a.value,value:s.data}}_getInvalidInput(s){const r=this._getOrReturnCtx(s);return qn(r,{code:en.invalid_type,expected:na.bigint,received:r.parsedType}),Ci}gte(s,r){return this.setLimit("min",s,!0,ga.toString(r))}gt(s,r){return this.setLimit("min",s,!1,ga.toString(r))}lte(s,r){return this.setLimit("max",s,!0,ga.toString(r))}lt(s,r){return this.setLimit("max",s,!1,ga.toString(r))}setLimit(s,r,n,a){return new i6({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:ga.toString(a)}]})}_addCheck(s){return new i6({...this._def,checks:[...this._def.checks,s]})}positive(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ga.toString(s)})}negative(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ga.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ga.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ga.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:ga.toString(r)})}get minValue(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxValue(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.valuenew i6({checks:[],typeName:Mi.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Zi(t)});class Wge extends To{_parse(s){if(this._def.coerce&&(s.data=!!s.data),this._getType(s)!==na.boolean){const n=this._getOrReturnCtx(s);return qn(n,{code:en.invalid_type,expected:na.boolean,received:n.parsedType}),Ci}return Df(s.data)}}Wge.create=t=>new Wge({typeName:Mi.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Zi(t)});class Sne extends To{_parse(s){if(this._def.coerce&&(s.data=new Date(s.data)),this._getType(s)!==na.date){const o=this._getOrReturnCtx(s);return qn(o,{code:en.invalid_type,expected:na.date,received:o.parsedType}),Ci}if(Number.isNaN(s.data.getTime())){const o=this._getOrReturnCtx(s);return qn(o,{code:en.invalid_date}),Ci}const n=new Cp;let a;for(const o of this._def.checks)o.kind==="min"?s.data.getTime()o.value&&(a=this._getOrReturnCtx(s,a),qn(a,{code:en.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Io.assertNever(o);return{status:n.value,value:new Date(s.data.getTime())}}_addCheck(s){return new Sne({...this._def,checks:[...this._def.checks,s]})}min(s,r){return this._addCheck({kind:"min",value:s.getTime(),message:ga.toString(r)})}max(s,r){return this._addCheck({kind:"max",value:s.getTime(),message:ga.toString(r)})}get minDate(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s!=null?new Date(s):null}get maxDate(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.valuenew Sne({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Mi.ZodDate,...Zi(t)});class t3e extends To{_parse(s){if(this._getType(s)!==na.symbol){const n=this._getOrReturnCtx(s);return qn(n,{code:en.invalid_type,expected:na.symbol,received:n.parsedType}),Ci}return Df(s.data)}}t3e.create=t=>new t3e({typeName:Mi.ZodSymbol,...Zi(t)});class s3e extends To{_parse(s){if(this._getType(s)!==na.undefined){const n=this._getOrReturnCtx(s);return qn(n,{code:en.invalid_type,expected:na.undefined,received:n.parsedType}),Ci}return Df(s.data)}}s3e.create=t=>new s3e({typeName:Mi.ZodUndefined,...Zi(t)});class r3e extends To{_parse(s){if(this._getType(s)!==na.null){const n=this._getOrReturnCtx(s);return qn(n,{code:en.invalid_type,expected:na.null,received:n.parsedType}),Ci}return Df(s.data)}}r3e.create=t=>new r3e({typeName:Mi.ZodNull,...Zi(t)});class n3e extends To{constructor(){super(...arguments),this._any=!0}_parse(s){return Df(s.data)}}n3e.create=t=>new n3e({typeName:Mi.ZodAny,...Zi(t)});class a3e extends To{constructor(){super(...arguments),this._unknown=!0}_parse(s){return Df(s.data)}}a3e.create=t=>new a3e({typeName:Mi.ZodUnknown,...Zi(t)});class L_ extends To{_parse(s){const r=this._getOrReturnCtx(s);return qn(r,{code:en.invalid_type,expected:na.never,received:r.parsedType}),Ci}}L_.create=t=>new L_({typeName:Mi.ZodNever,...Zi(t)});class i3e extends To{_parse(s){if(this._getType(s)!==na.undefined){const n=this._getOrReturnCtx(s);return qn(n,{code:en.invalid_type,expected:na.void,received:n.parsedType}),Ci}return Df(s.data)}}i3e.create=t=>new i3e({typeName:Mi.ZodVoid,...Zi(t)});class ry extends To{_parse(s){const{ctx:r,status:n}=this._processInputParams(s),a=this._def;if(r.parsedType!==na.array)return qn(r,{code:en.invalid_type,expected:na.array,received:r.parsedType}),Ci;if(a.exactLength!==null){const l=r.data.length>a.exactLength.value,i=r.data.lengtha.maxLength.value&&(qn(r,{code:en.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((l,i)=>a.type._parseAsync(new I_(r,l,r.path,i)))).then(l=>Cp.mergeArray(n,l));const o=[...r.data].map((l,i)=>a.type._parseSync(new I_(r,l,r.path,i)));return Cp.mergeArray(n,o)}get element(){return this._def.type}min(s,r){return new ry({...this._def,minLength:{value:s,message:ga.toString(r)}})}max(s,r){return new ry({...this._def,maxLength:{value:s,message:ga.toString(r)}})}length(s,r){return new ry({...this._def,exactLength:{value:s,message:ga.toString(r)}})}nonempty(s){return this.min(1,s)}}ry.create=(t,s)=>new ry({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Mi.ZodArray,...Zi(s)});function N4(t){if(t instanceof bd){const s={};for(const r in t.shape){const n=t.shape[r];s[r]=y_.create(N4(n))}return new bd({...t._def,shape:()=>s})}else return t instanceof ry?new ry({...t._def,type:N4(t.element)}):t instanceof y_?y_.create(N4(t.unwrap())):t instanceof k3?k3.create(N4(t.unwrap())):t instanceof zk?zk.create(t.items.map(s=>N4(s))):t}class bd extends To{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const s=this._def.shape(),r=Io.objectKeys(s);return this._cached={shape:s,keys:r},this._cached}_parse(s){if(this._getType(s)!==na.object){const u=this._getOrReturnCtx(s);return qn(u,{code:en.invalid_type,expected:na.object,received:u.parsedType}),Ci}const{status:n,ctx:a}=this._processInputParams(s),{shape:o,keys:l}=this._getCached(),i=[];if(!(this._def.catchall instanceof L_&&this._def.unknownKeys==="strip"))for(const u in a.data)l.includes(u)||i.push(u);const d=[];for(const u of l){const p=o[u],f=a.data[u];d.push({key:{status:"valid",value:u},value:p._parse(new I_(a,f,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof L_){const u=this._def.unknownKeys;if(u==="passthrough")for(const p of i)d.push({key:{status:"valid",value:p},value:{status:"valid",value:a.data[p]}});else if(u==="strict")i.length>0&&(qn(a,{code:en.unrecognized_keys,keys:i}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const p of i){const f=a.data[p];d.push({key:{status:"valid",value:p},value:u._parse(new I_(a,f,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of d){const f=await p.key,y=await p.value;u.push({key:f,value:y,alwaysSet:p.alwaysSet})}return u}).then(u=>Cp.mergeObjectSync(n,u)):Cp.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(s){return ga.errToObj,new bd({...this._def,unknownKeys:"strict",...s!==void 0?{errorMap:(r,n)=>{var o,l;const a=((l=(o=this._def).errorMap)==null?void 0:l.call(o,r,n).message)??n.defaultError;return r.code==="unrecognized_keys"?{message:ga.errToObj(s).message??a}:{message:a}}}:{}})}strip(){return new bd({...this._def,unknownKeys:"strip"})}passthrough(){return new bd({...this._def,unknownKeys:"passthrough"})}extend(s){return new bd({...this._def,shape:()=>({...this._def.shape(),...s})})}merge(s){return new bd({unknownKeys:s._def.unknownKeys,catchall:s._def.catchall,shape:()=>({...this._def.shape(),...s._def.shape()}),typeName:Mi.ZodObject})}setKey(s,r){return this.augment({[s]:r})}catchall(s){return new bd({...this._def,catchall:s})}pick(s){const r={};for(const n of Io.objectKeys(s))s[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new bd({...this._def,shape:()=>r})}omit(s){const r={};for(const n of Io.objectKeys(this.shape))s[n]||(r[n]=this.shape[n]);return new bd({...this._def,shape:()=>r})}deepPartial(){return N4(this)}partial(s){const r={};for(const n of Io.objectKeys(this.shape)){const a=this.shape[n];s&&!s[n]?r[n]=a:r[n]=a.optional()}return new bd({...this._def,shape:()=>r})}required(s){const r={};for(const n of Io.objectKeys(this.shape))if(s&&!s[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof y_;)o=o._def.innerType;r[n]=o}return new bd({...this._def,shape:()=>r})}keyof(){return a$e(Io.objectKeys(this.shape))}}bd.create=(t,s)=>new bd({shape:()=>t,unknownKeys:"strip",catchall:L_.create(),typeName:Mi.ZodObject,...Zi(s)});bd.strictCreate=(t,s)=>new bd({shape:()=>t,unknownKeys:"strict",catchall:L_.create(),typeName:Mi.ZodObject,...Zi(s)});bd.lazycreate=(t,s)=>new bd({shape:t,unknownKeys:"strip",catchall:L_.create(),typeName:Mi.ZodObject,...Zi(s)});class Cne extends To{_parse(s){const{ctx:r}=this._processInputParams(s),n=this._def.options;function a(o){for(const i of o)if(i.result.status==="valid")return i.result;for(const i of o)if(i.result.status==="dirty")return r.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(i=>new ly(i.ctx.common.issues));return qn(r,{code:en.invalid_union,unionErrors:l}),Ci}if(r.common.async)return Promise.all(n.map(async o=>{const l={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:l}),ctx:l}})).then(a);{let o;const l=[];for(const d of n){const u={...r,common:{...r.common,issues:[]},parent:null},p=d._parseSync({data:r.data,path:r.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!o&&(o={result:p,ctx:u}),u.common.issues.length&&l.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;const i=l.map(d=>new ly(d));return qn(r,{code:en.invalid_union,unionErrors:i}),Ci}}get options(){return this._def.options}}Cne.create=(t,s)=>new Cne({options:t,typeName:Mi.ZodUnion,...Zi(s)});function Gge(t,s){const r=p1(t),n=p1(s);if(t===s)return{valid:!0,data:t};if(r===na.object&&n===na.object){const a=Io.objectKeys(s),o=Io.objectKeys(t).filter(i=>a.indexOf(i)!==-1),l={...t,...s};for(const i of o){const d=Gge(t[i],s[i]);if(!d.valid)return{valid:!1};l[i]=d.data}return{valid:!0,data:l}}else if(r===na.array&&n===na.array){if(t.length!==s.length)return{valid:!1};const a=[];for(let o=0;o{if(Q5e(o)||Q5e(l))return Ci;const i=Gge(o.value,l.value);return i.valid?((J5e(o)||J5e(l))&&r.dirty(),{status:r.value,value:i.data}):(qn(n,{code:en.invalid_intersection_types}),Ci)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,l])=>a(o,l)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Mne.create=(t,s,r)=>new Mne({left:t,right:s,typeName:Mi.ZodIntersection,...Zi(r)});class zk extends To{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==na.array)return qn(n,{code:en.invalid_type,expected:na.array,received:n.parsedType}),Ci;if(n.data.lengththis._def.items.length&&(qn(n,{code:en.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const o=[...n.data].map((l,i)=>{const d=this._def.items[i]||this._def.rest;return d?d._parse(new I_(n,l,n.path,i)):null}).filter(l=>!!l);return n.common.async?Promise.all(o).then(l=>Cp.mergeArray(r,l)):Cp.mergeArray(r,o)}get items(){return this._def.items}rest(s){return new zk({...this._def,rest:s})}}zk.create=(t,s)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new zk({items:t,typeName:Mi.ZodTuple,rest:null,...Zi(s)})};class o3e extends To{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==na.map)return qn(n,{code:en.invalid_type,expected:na.map,received:n.parsedType}),Ci;const a=this._def.keyType,o=this._def.valueType,l=[...n.data.entries()].map(([i,d],u)=>({key:a._parse(new I_(n,i,n.path,[u,"key"])),value:o._parse(new I_(n,d,n.path,[u,"value"]))}));if(n.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const d of l){const u=await d.key,p=await d.value;if(u.status==="aborted"||p.status==="aborted")return Ci;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}})}else{const i=new Map;for(const d of l){const u=d.key,p=d.value;if(u.status==="aborted"||p.status==="aborted")return Ci;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}}}}o3e.create=(t,s,r)=>new o3e({valueType:s,keyType:t,typeName:Mi.ZodMap,...Zi(r)});class o6 extends To{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==na.set)return qn(n,{code:en.invalid_type,expected:na.set,received:n.parsedType}),Ci;const a=this._def;a.minSize!==null&&n.data.sizea.maxSize.value&&(qn(n,{code:en.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());const o=this._def.valueType;function l(d){const u=new Set;for(const p of d){if(p.status==="aborted")return Ci;p.status==="dirty"&&r.dirty(),u.add(p.value)}return{status:r.value,value:u}}const i=[...n.data.values()].map((d,u)=>o._parse(new I_(n,d,n.path,u)));return n.common.async?Promise.all(i).then(d=>l(d)):l(i)}min(s,r){return new o6({...this._def,minSize:{value:s,message:ga.toString(r)}})}max(s,r){return new o6({...this._def,maxSize:{value:s,message:ga.toString(r)}})}size(s,r){return this.min(s,r).max(s,r)}nonempty(s){return this.min(1,s)}}o6.create=(t,s)=>new o6({valueType:t,minSize:null,maxSize:null,typeName:Mi.ZodSet,...Zi(s)});class l3e extends To{get schema(){return this._def.getter()}_parse(s){const{ctx:r}=this._processInputParams(s);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}l3e.create=(t,s)=>new l3e({getter:t,typeName:Mi.ZodLazy,...Zi(s)});class Kge extends To{_parse(s){if(s.data!==this._def.value){const r=this._getOrReturnCtx(s);return qn(r,{received:r.data,code:en.invalid_literal,expected:this._def.value}),Ci}return{status:"valid",value:s.data}}get value(){return this._def.value}}Kge.create=(t,s)=>new Kge({value:t,typeName:Mi.ZodLiteral,...Zi(s)});function a$e(t,s){return new j3({values:t,typeName:Mi.ZodEnum,...Zi(s)})}class j3 extends To{_parse(s){if(typeof s.data!="string"){const r=this._getOrReturnCtx(s),n=this._def.values;return qn(r,{expected:Io.joinValues(n),received:r.parsedType,code:en.invalid_type}),Ci}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(s.data)){const r=this._getOrReturnCtx(s),n=this._def.values;return qn(r,{received:r.data,code:en.invalid_enum_value,options:n}),Ci}return Df(s.data)}get options(){return this._def.values}get enum(){const s={};for(const r of this._def.values)s[r]=r;return s}get Values(){const s={};for(const r of this._def.values)s[r]=r;return s}get Enum(){const s={};for(const r of this._def.values)s[r]=r;return s}extract(s,r=this._def){return j3.create(s,{...this._def,...r})}exclude(s,r=this._def){return j3.create(this.options.filter(n=>!s.includes(n)),{...this._def,...r})}}j3.create=a$e;class c3e extends To{_parse(s){const r=Io.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(s);if(n.parsedType!==na.string&&n.parsedType!==na.number){const a=Io.objectValues(r);return qn(n,{expected:Io.joinValues(a),received:n.parsedType,code:en.invalid_type}),Ci}if(this._cache||(this._cache=new Set(Io.getValidEnumValues(this._def.values))),!this._cache.has(s.data)){const a=Io.objectValues(r);return qn(n,{received:n.data,code:en.invalid_enum_value,options:a}),Ci}return Df(s.data)}get enum(){return this._def.values}}c3e.create=(t,s)=>new c3e({values:t,typeName:Mi.ZodNativeEnum,...Zi(s)});class Tne extends To{unwrap(){return this._def.type}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==na.promise&&r.common.async===!1)return qn(r,{code:en.invalid_type,expected:na.promise,received:r.parsedType}),Ci;const n=r.parsedType===na.promise?r.data:Promise.resolve(r.data);return Df(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Tne.create=(t,s)=>new Tne({type:t,typeName:Mi.ZodPromise,...Zi(s)});class N3 extends To{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Mi.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(s){const{status:r,ctx:n}=this._processInputParams(s),a=this._def.effect||null,o={addIssue:l=>{qn(n,l),l.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),a.type==="preprocess"){const l=a.transform(n.data,o);if(n.common.async)return Promise.resolve(l).then(async i=>{if(r.value==="aborted")return Ci;const d=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return d.status==="aborted"?Ci:d.status==="dirty"||r.value==="dirty"?RE(d.value):d});{if(r.value==="aborted")return Ci;const i=this._def.schema._parseSync({data:l,path:n.path,parent:n});return i.status==="aborted"?Ci:i.status==="dirty"||r.value==="dirty"?RE(i.value):i}}if(a.type==="refinement"){const l=i=>{const d=a.refinement(i,o);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Ci:(i.status==="dirty"&&r.dirty(),l(i.value),{status:r.value,value:i.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"?Ci:(i.status==="dirty"&&r.dirty(),l(i.value).then(()=>({status:r.value,value:i.value}))))}if(a.type==="transform")if(n.common.async===!1){const l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!b3(l))return Ci;const i=a.transform(l.value,o);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:i}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>b3(l)?Promise.resolve(a.transform(l.value,o)).then(i=>({status:r.value,value:i})):Ci);Io.assertNever(a)}}N3.create=(t,s,r)=>new N3({schema:t,typeName:Mi.ZodEffects,effect:s,...Zi(r)});N3.createWithPreprocess=(t,s,r)=>new N3({schema:s,effect:{type:"preprocess",transform:t},typeName:Mi.ZodEffects,...Zi(r)});class y_ extends To{_parse(s){return this._getType(s)===na.undefined?Df(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}y_.create=(t,s)=>new y_({innerType:t,typeName:Mi.ZodOptional,...Zi(s)});class k3 extends To{_parse(s){return this._getType(s)===na.null?Df(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}k3.create=(t,s)=>new k3({innerType:t,typeName:Mi.ZodNullable,...Zi(s)});class Zge extends To{_parse(s){const{ctx:r}=this._processInputParams(s);let n=r.data;return r.parsedType===na.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Zge.create=(t,s)=>new Zge({innerType:t,typeName:Mi.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...Zi(s)});class Yge extends To{_parse(s){const{ctx:r}=this._processInputParams(s),n={...r,common:{...r.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return kne(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new ly(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new ly(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Yge.create=(t,s)=>new Yge({innerType:t,typeName:Mi.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...Zi(s)});class d3e extends To{_parse(s){if(this._getType(s)!==na.nan){const n=this._getOrReturnCtx(s);return qn(n,{code:en.invalid_type,expected:na.nan,received:n.parsedType}),Ci}return{status:"valid",value:s.data}}}d3e.create=t=>new d3e({typeName:Mi.ZodNaN,...Zi(t)});class gbt extends To{_parse(s){const{ctx:r}=this._processInputParams(s),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class m_e extends To{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Ci:o.status==="dirty"?(r.dirty(),RE(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?Ci:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(s,r){return new m_e({in:s,out:r,typeName:Mi.ZodPipeline})}}class Xge extends To{_parse(s){const r=this._def.innerType._parse(s),n=a=>(b3(a)&&(a.value=Object.freeze(a.value)),a);return kne(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}Xge.create=(t,s)=>new Xge({innerType:t,typeName:Mi.ZodReadonly,...Zi(s)});var Mi;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Mi||(Mi={}));const Jl=U1.create,tI=w3.create,xbt=Wge.create;L_.create;ry.create;const lS=bd.create;Cne.create;Mne.create;zk.create;const Ane=Kge.create,i$e=j3.create;Tne.create;y_.create;k3.create;const Ar=C.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{className:Pt("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:r,...s}));Ar.displayName="Textarea";const ybt=["Excellent","Good","Neutral","Bad","Very Bad"],vbt=[5,4,3,2,1];function _bt({questions:t,visitorId:s,onComplete:r,onSkip:n}){const a=lvt(),[o,l]=C.useState({}),i=t.filter(y=>y.question_type==="rating"),d=t.filter(y=>y.question_type!=="rating"),u=(y,_)=>{l(b=>({...b,[y]:{rating_value:_}}))},p=(y,_)=>{l(b=>({...b,[y]:{text_value:_}}))},f=async()=>{const y=Object.entries(o).filter(([,_])=>_.rating_value!=null||_.text_value&&_.text_value.trim()).map(([_,b])=>{var w;return{visitor_id:s,question_id:_,rating_value:b.rating_value??null,text_value:((w=b.text_value)==null?void 0:w.trim())||null}});if(y.length>0)try{await a.mutateAsync(y)}catch{}r()};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"Quick Feedback"}),e.jsx("button",{onClick:n,className:"text-sm text-slate-400 hover:text-slate-600 underline",children:"Skip"})]}),e.jsx("p",{className:"text-sm text-slate-500 -mt-2",children:"Your feedback helps the agent — totally optional!"}),i.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"flex-1"}),ybt.map(y=>e.jsx("div",{className:"w-12 text-center",children:e.jsx("span",{className:"text-[10px] text-slate-400 leading-tight block",children:y})},y))]}),i.map(y=>e.jsxs("div",{className:"flex items-center gap-1 py-1.5 border-b border-slate-100 last:border-0",children:[e.jsx("span",{className:"flex-1 text-sm text-slate-700 pr-2",children:y.question_text}),vbt.map(_=>{var b;return e.jsx("div",{className:"w-12 flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>u(y.id,_),className:`w-6 h-6 rounded-full border-2 transition-all ${((b=o[y.id])==null?void 0:b.rating_value)===_?"bg-slate-900 border-slate-900":"border-slate-300 hover:border-slate-500"}`})},_)})]},y.id))]}),d.map(y=>{var _;return e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 block mb-1",children:y.question_text}),e.jsx(Ar,{value:((_=o[y.id])==null?void 0:_.text_value)||"",onChange:b=>p(y.id,b.target.value),placeholder:"Your thoughts...",className:"h-16 text-sm resize-none rounded-xl border-slate-200"})]},y.id)}),e.jsx(K,{onClick:f,disabled:a.isPending,className:"w-full h-12 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:a.isPending?e.jsx(Ms,{className:"h-5 w-5 animate-spin"}):"Submit Feedback"})]})}const bbt=lS({first_name:Jl().trim().min(1,"First name is required").max(50),last_name:Jl().trim().max(50).optional(),email:Jl().trim().email("Please enter a valid email").max(255).optional().or(Ane("")),phone:Jl().trim().max(20).optional().or(Ane(""))}),wbt=[{value:"buying",label:"Looking to Buy",emoji:"🏠"},{value:"selling",label:"Thinking of Selling",emoji:"📋"},{value:"browsing",label:"Just Browsing",emoji:"👀"},{value:"neighbor",label:"I'm a Neighbor",emoji:"👋"}];function o$e({slug:t}={}){var re;const s=ko(),r=t||s.slug,{data:n,isLoading:a,error:o}=avt(r),l=pvt(),[i,d]=C.useState("welcome"),[u,p]=C.useState(null),[f,y]=C.useState({first_name:"",last_name:"",email:"",phone:""}),[_,b]=C.useState(""),[w,j]=C.useState(!1),[k,S]=C.useState(!1),[T,I]=C.useState(""),[L,R]=C.useState(""),{data:$,isLoading:q}=ovt(n==null?void 0:n.id),U=!!(n!=null&&n.enable_survey);C.useEffect(()=>{i==="pending_survey"&&(q||d(U&&(($==null?void 0:$.length)??0)>0?"survey":"done"))},[i,q,U,$]);const H=ae=>{if(!ae)return"";const[le,he]=ae.split(":"),be=parseInt(le),_e=be>=12?"PM":"AM";return`${be>12?be-12:be||12}:${he} ${_e}`},Y=()=>{R("");const ae=bbt.safeParse(f);if(!ae.success){R(ae.error.issues[0].message);return}if(!f.email&&!f.phone){R("Please provide either an email or phone number");return}d("intent")},se=async ae=>{b(ae);try{const le=await l.mutateAsync({open_house_id:n.id,first_name:f.first_name.trim(),last_name:f.last_name.trim()||void 0,email:f.email.trim()||void 0,phone:f.phone.trim()||void 0,visitor_intent:ae,wants_market_updates:w,has_agent:k,working_with_agent_name:k&&T.trim()?T.trim():void 0});p(le.id),U?!q&&$&&$.length>0?d("survey"):d("pending_survey"):d("done")}catch{R("Something went wrong. Please try again.")}};if(a)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center",children:e.jsx("div",{className:"w-10 h-10 border-4 border-white/20 border-t-white rounded-full animate-spin"})});if(o||!n)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(On,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Open House Not Found"}),e.jsx("p",{className:"text-white/60",children:"This sign-in page doesn't exist or is no longer active."})]})});const te=n.profiles,Q=((re=te==null?void 0:te.name)==null?void 0:re.split(" ").map(ae=>ae[0]).join("").slice(0,2))||"?",de=n.event_type==="community";return e.jsxs(e.Fragment,{children:[e.jsxs(lh,{children:[e.jsxs("title",{children:[de?"Community Event":"Open House"," | ",n.property_address]}),e.jsx("meta",{name:"description",content:`Sign in to the ${de?"community event":"open house"} at ${n.property_address}`}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsxs(xn,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[e.jsx(Aa,{src:(te==null?void 0:te.avatar_url)||"",alt:(te==null?void 0:te.name)||""}),e.jsx(yn,{className:"bg-white/10 text-white text-lg",children:Q})]}),e.jsx("p",{className:"text-white/60 text-sm",children:te==null?void 0:te.name}),(te==null?void 0:te.title)&&e.jsx("p",{className:"text-white/40 text-xs",children:te.title})]}),e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl overflow-hidden",children:[n.photo_url&&e.jsxs("div",{className:"relative h-44 sm:h-52 overflow-hidden",children:[e.jsx("img",{src:n.photo_url,alt:n.property_address,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-900/80 via-slate-900/20 to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 px-6 pb-4",children:[e.jsx("h1",{className:"text-white font-bold text-lg leading-tight drop-shadow-md",children:n.property_address}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-1.5 text-white/70 text-xs",children:[n.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Oi,{className:"h-3 w-3"}),n.city,n.state?`, ${n.state}`:""," ",n.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ys(new Date(n.event_date+"T00:00:00"),"MMM d, yyyy")]}),n.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),H(n.start_time),n.end_time?` – ${H(n.end_time)}`:""]})]})]})]}),!n.photo_url&&e.jsx("div",{className:"bg-gradient-to-r from-slate-800 to-slate-700 px-6 py-5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/10 flex items-center justify-center shrink-0 mt-0.5",children:de?e.jsx(Ta,{className:"h-5 w-5 text-white"}):e.jsx(On,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-white font-bold text-lg leading-tight",children:n.property_address}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-2 text-white/60 text-xs",children:[n.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Oi,{className:"h-3 w-3"}),n.city,n.state?`, ${n.state}`:""," ",n.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ys(new Date(n.event_date+"T00:00:00"),"MMM d, yyyy")]}),n.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),H(n.start_time),n.end_time?` – ${H(n.end_time)}`:""]})]})]})]})}),e.jsxs("div",{className:"p-6",children:[i==="welcome"&&e.jsxs("div",{className:"text-center space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-slate-900 mb-2",children:"Welcome!"}),e.jsx("p",{className:"text-slate-500 text-sm",children:n.agent_greeting||"Please sign in below."})]}),e.jsxs(K,{onClick:()=>d("info"),className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Sign In ",e.jsx($i,{className:"h-5 w-5 ml-2"})]}),e.jsx("p",{className:"text-xs text-slate-400",children:"Quick & easy — takes 30 seconds"})]}),i==="info"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("button",{onClick:()=>d("welcome"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(ti,{className:"h-4 w-4"})}),e.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"Your Info"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-slate-600 text-xs",children:"First Name *"}),e.jsx(Re,{value:f.first_name,onChange:ae=>y(le=>({...le,first_name:ae.target.value})),placeholder:"First",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-slate-600 text-xs",children:"Last Name"}),e.jsx(Re,{value:f.last_name,onChange:ae=>y(le=>({...le,last_name:ae.target.value})),placeholder:"Last",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-slate-600 text-xs",children:"Email"}),e.jsx(Re,{type:"email",value:f.email,onChange:ae=>y(le=>({...le,email:ae.target.value})),placeholder:"your@email.com",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-slate-600 text-xs",children:"Phone"}),e.jsx(Re,{type:"tel",value:f.phone,onChange:ae=>y(le=>({...le,phone:ae.target.value})),placeholder:"(555) 123-4567",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer pt-1",children:[e.jsx("input",{type:"checkbox",checked:w,onChange:ae=>j(ae.target.checked),className:"rounded border-slate-300 text-slate-900 focus:ring-slate-500"}),e.jsx("span",{className:"text-sm text-slate-600",children:"Send me market updates for this area"})]}),e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-slate-600",children:"Already working with an agent?"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium text-slate-400",children:k?"Yes":"No"}),e.jsx(Br,{checked:k,onCheckedChange:S})]})]}),k&&e.jsx(Re,{value:T,onChange:ae=>I(ae.target.value),placeholder:"Agent's name",className:"mt-1 h-10 rounded-xl border-slate-200 text-sm"})]}),L&&e.jsx("p",{className:"text-destructive text-sm",children:L}),e.jsxs(K,{onClick:Y,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",e.jsx($i,{className:"h-5 w-5 ml-2"})]})]}),i==="intent"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("button",{onClick:()=>d("info"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(ti,{className:"h-4 w-4"})}),e.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"What brings you here?"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:wbt.map(ae=>e.jsxs("button",{onClick:()=>se(ae.value),disabled:l.isPending,className:"flex flex-col items-center gap-2 p-5 rounded-xl border-2 border-slate-200 hover:border-slate-900 hover:bg-slate-50 transition-all text-center group",children:[e.jsx("span",{className:"text-2xl",children:ae.emoji}),e.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:ae.label})]},ae.value))}),L&&e.jsx("p",{className:"text-destructive text-sm text-center",children:L})]}),i==="pending_survey"&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-3",children:[e.jsx("div",{className:"w-8 h-8 border-[3px] border-slate-200 border-t-slate-900 rounded-full animate-spin"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading survey..."})]}),i==="survey"&&u&&$&&e.jsx(_bt,{questions:$,visitorId:u,onComplete:()=>d("done"),onSkip:()=>d("done")}),i==="done"&&e.jsxs("div",{className:"text-center space-y-4 py-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-green-100 flex items-center justify-center mx-auto",children:e.jsx(ua,{className:"h-8 w-8 text-green-600"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-slate-900",children:"You're all set!"}),e.jsxs("p",{className:"text-slate-500 text-sm mt-1",children:["Thanks for signing in, ",f.first_name,". ",de?"Enjoy the event!":"Enjoy the open house!"]})]}),(te==null?void 0:te.name)&&e.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",e.jsx("strong",{className:"text-slate-600",children:te.name})]})]})]})]}),e.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function L_s(t){const{user:s}=Hs();return wt({queryKey:["cohost-tokens",t],queryFn:async()=>{const{data:r,error:n}=await G.from("open_house_cohost_tokens").select("*").eq("open_house_id",t).order("created_at",{ascending:!1});if(n)throw n;return r},enabled:!!s&&!!t})}function D_s(){const t=rs(),{user:s}=Hs();return Dt({mutationFn:async({openHouseId:r,label:n})=>{const{data:a,error:o}=await G.from("open_house_cohost_tokens").insert({open_house_id:r,label:n||null,created_by:s.id,expires_at:new Date(Date.now()+864e5).toISOString()}).select().single();if(o)throw o;return a},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["cohost-tokens",n.openHouseId]})}})}function O_s(){const t=rs();return Dt({mutationFn:async({id:s,openHouseId:r})=>{const{error:n}=await G.from("open_house_cohost_tokens").update({is_active:!1}).eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["cohost-tokens",r.openHouseId]})}})}function jbt(t){return wt({queryKey:["cohost-validate",t],queryFn:async()=>{const{data:s,error:r}=await G.from("open_house_cohost_tokens").select("*, open_houses(*)").eq("token",t).eq("is_active",!0).single();if(r)throw r;if(s.expires_at&&new Date(s.expires_at)s[r][n]??r,t)}var p_e="ScrollArea",[l$e]=Ec(p_e),[kbt,Of]=l$e(p_e),c$e=C.forwardRef((t,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=t,[i,d]=C.useState(null),[u,p]=C.useState(null),[f,y]=C.useState(null),[_,b]=C.useState(null),[w,j]=C.useState(null),[k,S]=C.useState(0),[T,I]=C.useState(0),[L,R]=C.useState(!1),[$,q]=C.useState(!1),U=Ea(s,Y=>d(Y)),H=G_(a);return e.jsx(kbt,{scope:r,type:n,dir:H,scrollHideDelay:o,scrollArea:i,viewport:u,onViewportChange:p,content:f,onContentChange:y,scrollbarX:_,onScrollbarXChange:b,scrollbarXEnabled:L,onScrollbarXEnabledChange:R,scrollbarY:w,onScrollbarYChange:j,scrollbarYEnabled:$,onScrollbarYEnabledChange:q,onCornerWidthChange:S,onCornerHeightChange:I,children:e.jsx(Qr.div,{dir:H,...l,ref:U,style:{position:"relative","--radix-scroll-area-corner-width":k+"px","--radix-scroll-area-corner-height":T+"px",...t.style}})})});c$e.displayName=p_e;var d$e="ScrollAreaViewport",u$e=C.forwardRef((t,s)=>{const{__scopeScrollArea:r,children:n,nonce:a,...o}=t,l=Of(d$e,r),i=C.useRef(null),d=Ea(s,i,l.onViewportChange);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),e.jsx(Qr.div,{"data-radix-scroll-area-viewport":"",...o,ref:d,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...t.style},children:e.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});u$e.displayName=d$e;var vy="ScrollAreaScrollbar",f_e=C.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Of(vy,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=a,i=t.orientation==="horizontal";return C.useEffect(()=>(i?o(!0):l(!0),()=>{i?o(!1):l(!1)}),[i,o,l]),a.type==="hover"?e.jsx(Sbt,{...n,ref:s,forceMount:r}):a.type==="scroll"?e.jsx(Cbt,{...n,ref:s,forceMount:r}):a.type==="auto"?e.jsx(h$e,{...n,ref:s,forceMount:r}):a.type==="always"?e.jsx(g_e,{...n,ref:s}):null});f_e.displayName=vy;var Sbt=C.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Of(vy,t.__scopeScrollArea),[o,l]=C.useState(!1);return C.useEffect(()=>{const i=a.scrollArea;let d=0;if(i){const u=()=>{window.clearTimeout(d),l(!0)},p=()=>{d=window.setTimeout(()=>l(!1),a.scrollHideDelay)};return i.addEventListener("pointerenter",u),i.addEventListener("pointerleave",p),()=>{window.clearTimeout(d),i.removeEventListener("pointerenter",u),i.removeEventListener("pointerleave",p)}}},[a.scrollArea,a.scrollHideDelay]),e.jsx(ud,{present:r||o,children:e.jsx(h$e,{"data-state":o?"visible":"hidden",...n,ref:s})})}),Cbt=C.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Of(vy,t.__scopeScrollArea),o=t.orientation==="horizontal",l=Koe(()=>d("SCROLL_END"),100),[i,d]=Nbt("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return C.useEffect(()=>{if(i==="idle"){const u=window.setTimeout(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,a.scrollHideDelay,d]),C.useEffect(()=>{const u=a.viewport,p=o?"scrollLeft":"scrollTop";if(u){let f=u[p];const y=()=>{const _=u[p];f!==_&&(d("SCROLL"),l()),f=_};return u.addEventListener("scroll",y),()=>u.removeEventListener("scroll",y)}},[a.viewport,o,d,l]),e.jsx(ud,{present:r||i!=="hidden",children:e.jsx(g_e,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:s,onPointerEnter:Mr(t.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Mr(t.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),h$e=C.forwardRef((t,s)=>{const r=Of(vy,t.__scopeScrollArea),{forceMount:n,...a}=t,[o,l]=C.useState(!1),i=t.orientation==="horizontal",d=Koe(()=>{if(r.viewport){const u=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,a=Of(vy,t.__scopeScrollArea),o=C.useRef(null),l=C.useRef(0),[i,d]=C.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=x$e(i.viewport,i.content),p={...n,sizes:i,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:y=>o.current=y,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:y=>l.current=y};function f(y,_){return Ibt(y,l.current,i,_)}return r==="horizontal"?e.jsx(Mbt,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const y=a.viewport.scrollLeft,_=u3e(y,i,a.dir);o.current.style.transform=`translate3d(${_}px, 0, 0)`}},onWheelScroll:y=>{a.viewport&&(a.viewport.scrollLeft=y)},onDragScroll:y=>{a.viewport&&(a.viewport.scrollLeft=f(y,a.dir))}}):r==="vertical"?e.jsx(Tbt,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const y=a.viewport.scrollTop,_=u3e(y,i);o.current.style.transform=`translate3d(0, ${_}px, 0)`}},onWheelScroll:y=>{a.viewport&&(a.viewport.scrollTop=y)},onDragScroll:y=>{a.viewport&&(a.viewport.scrollTop=f(y))}}):null}),Mbt=C.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Of(vy,t.__scopeScrollArea),[l,i]=C.useState(),d=C.useRef(null),u=Ea(s,d,o.onScrollbarXChange);return C.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),e.jsx(p$e,{"data-orientation":"horizontal",...a,ref:u,sizes:r,style:{bottom:0,left:o.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:o.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Goe(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.x),onDragScroll:p=>t.onDragScroll(p.x),onWheelScroll:(p,f)=>{if(o.viewport){const y=o.viewport.scrollLeft+p.deltaX;t.onWheelScroll(y),v$e(y,f)&&p.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:Pne(l.paddingLeft),paddingEnd:Pne(l.paddingRight)}})}})}),Tbt=C.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Of(vy,t.__scopeScrollArea),[l,i]=C.useState(),d=C.useRef(null),u=Ea(s,d,o.onScrollbarYChange);return C.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),e.jsx(p$e,{"data-orientation":"vertical",...a,ref:u,sizes:r,style:{top:0,right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Goe(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.y),onDragScroll:p=>t.onDragScroll(p.y),onWheelScroll:(p,f)=>{if(o.viewport){const y=o.viewport.scrollTop+p.deltaY;t.onWheelScroll(y),v$e(y,f)&&p.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:Pne(l.paddingTop),paddingEnd:Pne(l.paddingBottom)}})}})}),[Abt,m$e]=l$e(vy),p$e=C.forwardRef((t,s)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:i,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:p,onResize:f,...y}=t,_=Of(vy,r),[b,w]=C.useState(null),j=Ea(s,U=>w(U)),k=C.useRef(null),S=C.useRef(""),T=_.viewport,I=n.content-n.viewport,L=Vc(p),R=Vc(d),$=Koe(f,10);function q(U){if(k.current){const H=U.clientX-k.current.left,Y=U.clientY-k.current.top;u({x:H,y:Y})}}return C.useEffect(()=>{const U=H=>{const Y=H.target;(b==null?void 0:b.contains(Y))&&L(H,I)};return document.addEventListener("wheel",U,{passive:!1}),()=>document.removeEventListener("wheel",U,{passive:!1})},[T,b,I,L]),C.useEffect(R,[n,R]),S3(b,$),S3(_.content,$),e.jsx(Abt,{scope:r,scrollbar:b,hasThumb:a,onThumbChange:Vc(o),onThumbPointerUp:Vc(l),onThumbPositionChange:R,onThumbPointerDown:Vc(i),children:e.jsx(Qr.div,{...y,ref:j,style:{position:"absolute",...y.style},onPointerDown:Mr(t.onPointerDown,U=>{U.button===0&&(U.target.setPointerCapture(U.pointerId),k.current=b.getBoundingClientRect(),S.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",_.viewport&&(_.viewport.style.scrollBehavior="auto"),q(U))}),onPointerMove:Mr(t.onPointerMove,q),onPointerUp:Mr(t.onPointerUp,U=>{const H=U.target;H.hasPointerCapture(U.pointerId)&&H.releasePointerCapture(U.pointerId),document.body.style.webkitUserSelect=S.current,_.viewport&&(_.viewport.style.scrollBehavior=""),k.current=null})})})}),Ene="ScrollAreaThumb",f$e=C.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=m$e(Ene,t.__scopeScrollArea);return e.jsx(ud,{present:r||a.hasThumb,children:e.jsx(Ebt,{ref:s,...n})})}),Ebt=C.forwardRef((t,s)=>{const{__scopeScrollArea:r,style:n,...a}=t,o=Of(Ene,r),l=m$e(Ene,r),{onThumbPositionChange:i}=l,d=Ea(s,f=>l.onThumbChange(f)),u=C.useRef(void 0),p=Koe(()=>{u.current&&(u.current(),u.current=void 0)},100);return C.useEffect(()=>{const f=o.viewport;if(f){const y=()=>{if(p(),!u.current){const _=Lbt(f,i);u.current=_,i()}};return i(),f.addEventListener("scroll",y),()=>f.removeEventListener("scroll",y)}},[o.viewport,p,i]),e.jsx(Qr.div,{"data-state":l.hasThumb?"visible":"hidden",...a,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Mr(t.onPointerDownCapture,f=>{const _=f.target.getBoundingClientRect(),b=f.clientX-_.left,w=f.clientY-_.top;l.onThumbPointerDown({x:b,y:w})}),onPointerUp:Mr(t.onPointerUp,l.onThumbPointerUp)})});f$e.displayName=Ene;var x_e="ScrollAreaCorner",g$e=C.forwardRef((t,s)=>{const r=Of(x_e,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?e.jsx(Pbt,{...t,ref:s}):null});g$e.displayName=x_e;var Pbt=C.forwardRef((t,s)=>{const{__scopeScrollArea:r,...n}=t,a=Of(x_e,r),[o,l]=C.useState(0),[i,d]=C.useState(0),u=!!(o&&i);return S3(a.scrollbarX,()=>{var f;const p=((f=a.scrollbarX)==null?void 0:f.offsetHeight)||0;a.onCornerHeightChange(p),d(p)}),S3(a.scrollbarY,()=>{var f;const p=((f=a.scrollbarY)==null?void 0:f.offsetWidth)||0;a.onCornerWidthChange(p),l(p)}),u?e.jsx(Qr.div,{...n,ref:s,style:{width:o,height:i,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function Pne(t){return t?parseInt(t,10):0}function x$e(t,s){const r=t/s;return isNaN(r)?0:r}function Goe(t){const s=x$e(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*s;return Math.max(n,18)}function Ibt(t,s,r,n="ltr"){const a=Goe(r),o=a/2,l=s||o,i=a-l,d=r.scrollbar.paddingStart+l,u=r.scrollbar.size-r.scrollbar.paddingEnd-i,p=r.content-r.viewport,f=n==="ltr"?[0,p]:[p*-1,0];return y$e([d,u],f)(t)}function u3e(t,s,r="ltr"){const n=Goe(s),a=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,o=s.scrollbar.size-a,l=s.content-s.viewport,i=o-n,d=r==="ltr"?[0,l]:[l*-1,0],u=a6(t,d);return y$e([0,l],[0,i])(u)}function y$e(t,s){return r=>{if(t[0]===t[1]||s[0]===s[1])return s[0];const n=(s[1]-s[0])/(t[1]-t[0]);return s[0]+n*(r-t[0])}}function v$e(t,s){return t>0&&t{})=>{let r={left:t.scrollLeft,top:t.scrollTop},n=0;return function a(){const o={left:t.scrollLeft,top:t.scrollTop},l=r.left!==o.left,i=r.top!==o.top;(l||i)&&s(),r=o,n=window.requestAnimationFrame(a)}(),()=>window.cancelAnimationFrame(n)};function Koe(t,s){const r=Vc(t),n=C.useRef(0);return C.useEffect(()=>()=>window.clearTimeout(n.current),[]),C.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,s)},[r,s])}function S3(t,s){const r=Vc(s);Zc(()=>{let n=0;if(t){const a=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return a.observe(t),()=>{window.cancelAnimationFrame(n),a.unobserve(t)}}},[t,r])}var _$e=c$e,Dbt=u$e,Obt=g$e;const Ri=C.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(_$e,{ref:n,className:Pt("relative overflow-hidden",t),...r,children:[e.jsx(Dbt,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(Zoe,{}),e.jsx(Obt,{})]}));Ri.displayName=_$e.displayName;const Zoe=C.forwardRef(({className:t,orientation:s="vertical",...r},n)=>e.jsx(f_e,{ref:n,orientation:s,className:Pt("flex touch-none select-none transition-colors",s==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",s==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...r,children:e.jsx(f$e,{className:"relative flex-1 rounded-full bg-border"})}));Zoe.displayName=f_e.displayName;const y_e=C.createContext({});function v_e(t){const s=C.useRef(null);return s.current===null&&(s.current=t()),s.current}const Rbt=typeof window<"u",b$e=Rbt?C.useLayoutEffect:C.useEffect,Yoe=C.createContext(null);function __e(t,s){t.indexOf(s)===-1&&t.push(s)}function Ine(t,s){const r=t.indexOf(s);r>-1&&t.splice(r,1)}const cy=(t,s,r)=>r>s?s:r{};const D_={},w$e=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function j$e(t){return typeof t=="object"&&t!==null}const N$e=t=>/^0[^.\s]+$/u.test(t);function k$e(t){let s;return()=>(s===void 0&&(s=t()),s)}const _f=t=>t,Fbt=(t,s)=>r=>s(t(r)),RL=(...t)=>t.reduce(Fbt),l6=(t,s,r)=>{const n=s-t;return n===0?1:(r-t)/n};class w_e{constructor(){this.subscriptions=[]}add(s){return __e(this.subscriptions,s),()=>Ine(this.subscriptions,s)}notify(s,r,n){const a=this.subscriptions.length;if(a)if(a===1)this.subscriptions[0](s,r,n);else for(let o=0;ot*1e3,mf=t=>t/1e3;function S$e(t,s){return s?t*(1e3/s):0}const C$e=(t,s,r)=>(((1-3*r+3*s)*t+(3*r-6*s))*t+3*s)*t,zbt=1e-7,Bbt=12;function $bt(t,s,r,n,a){let o,l,i=0;do l=s+(r-s)/2,o=C$e(l,n,a)-t,o>0?r=l:s=l;while(Math.abs(o)>zbt&&++i$bt(o,0,1,t,r);return o=>o===0||o===1?o:C$e(a(o),s,n)}const M$e=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,T$e=t=>s=>1-t(1-s),A$e=FL(.33,1.53,.69,.99),j_e=T$e(A$e),E$e=M$e(j_e),P$e=t=>t>=1?1:(t*=2)<1?.5*j_e(t):.5*(2-Math.pow(2,-10*(t-1))),N_e=t=>1-Math.sin(Math.acos(t)),I$e=T$e(N_e),L$e=M$e(N_e),qbt=FL(.42,0,1,1),Ubt=FL(0,0,.58,1),D$e=FL(.42,0,.58,1),Vbt=t=>Array.isArray(t)&&typeof t[0]!="number",O$e=t=>Array.isArray(t)&&typeof t[0]=="number",Hbt={linear:_f,easeIn:qbt,easeInOut:D$e,easeOut:Ubt,circIn:N_e,circInOut:L$e,circOut:I$e,backIn:j_e,backInOut:E$e,backOut:A$e,anticipate:P$e},Wbt=t=>typeof t=="string",h3e=t=>{if(O$e(t)){b_e(t.length===4);const[s,r,n,a]=t;return FL(s,r,n,a)}else if(Wbt(t))return Hbt[t];return t},Z8=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Gbt(t,s){let r=new Set,n=new Set,a=!1,o=!1;const l=new WeakSet;let i={delta:0,timestamp:0,isProcessing:!1};function d(p){l.has(p)&&(u.schedule(p),t()),p(i)}const u={schedule:(p,f=!1,y=!1)=>{const b=y&&a?r:n;return f&&l.add(p),b.add(p),p},cancel:p=>{n.delete(p),l.delete(p)},process:p=>{if(i=p,a){o=!0;return}a=!0;const f=r;r=n,n=f,r.forEach(d),r.clear(),a=!1,o&&(o=!1,u.process(p))}};return u}const Kbt=40;function R$e(t,s){let r=!1,n=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,l=Z8.reduce((T,I)=>(T[I]=Gbt(o),T),{}),{setup:i,read:d,resolveKeyframes:u,preUpdate:p,update:f,preRender:y,render:_,postRender:b}=l,w=()=>{const T=D_.useManualTiming,I=T?a.timestamp:performance.now();r=!1,T||(a.delta=n?1e3/60:Math.max(Math.min(I-a.timestamp,Kbt),1)),a.timestamp=I,a.isProcessing=!0,i.process(a),d.process(a),u.process(a),p.process(a),f.process(a),y.process(a),_.process(a),b.process(a),a.isProcessing=!1,r&&s&&(n=!1,t(w))},j=()=>{r=!0,n=!0,a.isProcessing||t(w)};return{schedule:Z8.reduce((T,I)=>{const L=l[I];return T[I]=(R,$=!1,q=!1)=>(r||j(),L.schedule(R,$,q)),T},{}),cancel:T=>{for(let I=0;I(gre===void 0&&Lh.set(Iu.isProcessing||D_.useManualTiming?Iu.timestamp:performance.now()),gre),set:t=>{gre=t,queueMicrotask(Zbt)}},F$e=t=>s=>typeof s=="string"&&s.startsWith(t),z$e=F$e("--"),Ybt=F$e("var(--"),k_e=t=>Ybt(t)?Xbt.test(t.split("/*")[0].trim()):!1,Xbt=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function m3e(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const kM={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},c6={...kM,transform:t=>cy(0,1,t)},Y8={...kM,default:1},sI=t=>Math.round(t*1e5)/1e5,S_e=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Qbt(t){return t==null}const Jbt=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,C_e=(t,s)=>r=>!!(typeof r=="string"&&Jbt.test(r)&&r.startsWith(t)||s&&!Qbt(r)&&Object.prototype.hasOwnProperty.call(r,s)),B$e=(t,s,r)=>n=>{if(typeof n!="string")return n;const[a,o,l,i]=n.match(S_e);return{[t]:parseFloat(a),[s]:parseFloat(o),[r]:parseFloat(l),alpha:i!==void 0?parseFloat(i):1}},ewt=t=>cy(0,255,t),Xhe={...kM,transform:t=>Math.round(ewt(t))},DN={test:C_e("rgb","red"),parse:B$e("red","green","blue"),transform:({red:t,green:s,blue:r,alpha:n=1})=>"rgba("+Xhe.transform(t)+", "+Xhe.transform(s)+", "+Xhe.transform(r)+", "+sI(c6.transform(n))+")"};function twt(t){let s="",r="",n="",a="";return t.length>5?(s=t.substring(1,3),r=t.substring(3,5),n=t.substring(5,7),a=t.substring(7,9)):(s=t.substring(1,2),r=t.substring(2,3),n=t.substring(3,4),a=t.substring(4,5),s+=s,r+=r,n+=n,a+=a),{red:parseInt(s,16),green:parseInt(r,16),blue:parseInt(n,16),alpha:a?parseInt(a,16)/255:1}}const Qge={test:C_e("#"),parse:twt,transform:DN.transform},zL=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),l1=zL("deg"),ny=zL("%"),Jn=zL("px"),swt=zL("vh"),rwt=zL("vw"),p3e={...ny,parse:t=>ny.parse(t)/100,transform:t=>ny.transform(t*100)},H4={test:C_e("hsl","hue"),parse:B$e("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+ny.transform(sI(s))+", "+ny.transform(sI(r))+", "+sI(c6.transform(n))+")"},wd={test:t=>DN.test(t)||Qge.test(t)||H4.test(t),parse:t=>DN.test(t)?DN.parse(t):H4.test(t)?H4.parse(t):Qge.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?DN.transform(t):H4.transform(t),getAnimatableNone:t=>{const s=wd.parse(t);return s.alpha=0,wd.transform(s)}},nwt=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function awt(t){var s,r;return isNaN(t)&&typeof t=="string"&&(((s=t.match(S_e))==null?void 0:s.length)||0)+(((r=t.match(nwt))==null?void 0:r.length)||0)>0}const $$e="number",q$e="color",iwt="var",owt="var(",f3e="${}",lwt=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function C3(t){const s=t.toString(),r=[],n={color:[],number:[],var:[]},a=[];let o=0;const i=s.replace(lwt,d=>(wd.test(d)?(n.color.push(o),a.push(q$e),r.push(wd.parse(d))):d.startsWith(owt)?(n.var.push(o),a.push(iwt),r.push(d)):(n.number.push(o),a.push($$e),r.push(parseFloat(d))),++o,f3e)).split(f3e);return{values:r,split:i,indexes:n,types:a}}function cwt(t){return C3(t).values}function U$e({split:t,types:s}){const r=t.length;return n=>{let a="";for(let o=0;otypeof t=="number"?0:wd.test(t)?wd.getAnimatableNone(t):t,hwt=(t,s)=>typeof t=="number"?s!=null&&s.trim().endsWith("/")?t:0:uwt(t);function mwt(t){const s=C3(t);return U$e(s)(s.values.map((n,a)=>hwt(n,s.split[a])))}const Gg={test:awt,parse:cwt,createTransformer:dwt,getAnimatableNone:mwt};function Qhe(t,s,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+(s-t)*6*r:r<1/2?s:r<2/3?t+(s-t)*(2/3-r)*6:t}function pwt({hue:t,saturation:s,lightness:r,alpha:n}){t/=360,s/=100,r/=100;let a=0,o=0,l=0;if(!s)a=o=l=r;else{const i=r<.5?r*(1+s):r+s-r*s,d=2*r-i;a=Qhe(d,i,t+1/3),o=Qhe(d,i,t),l=Qhe(d,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:n}}function Lne(t,s){return r=>r>0?s:t}const tc=(t,s,r)=>t+(s-t)*r,Jhe=(t,s,r)=>{const n=t*t,a=r*(s*s-n)+n;return a<0?0:Math.sqrt(a)},fwt=[Qge,DN,H4],gwt=t=>fwt.find(s=>s.test(t));function g3e(t){const s=gwt(t);if(!s)return!1;let r=s.parse(t);return s===H4&&(r=pwt(r)),r}const x3e=(t,s)=>{const r=g3e(t),n=g3e(s);if(!r||!n)return Lne(t,s);const a={...r};return o=>(a.red=Jhe(r.red,n.red,o),a.green=Jhe(r.green,n.green,o),a.blue=Jhe(r.blue,n.blue,o),a.alpha=tc(r.alpha,n.alpha,o),DN.transform(a))},Jge=new Set(["none","hidden"]);function xwt(t,s){return Jge.has(t)?r=>r<=0?t:s:r=>r>=1?s:t}function ywt(t,s){return r=>tc(t,s,r)}function M_e(t){return typeof t=="number"?ywt:typeof t=="string"?k_e(t)?Lne:wd.test(t)?x3e:bwt:Array.isArray(t)?V$e:typeof t=="object"?wd.test(t)?x3e:vwt:Lne}function V$e(t,s){const r=[...t],n=r.length,a=t.map((o,l)=>M_e(o)(o,s[l]));return o=>{for(let l=0;l{for(const o in n)r[o]=n[o](a);return r}}function _wt(t,s){const r=[],n={color:0,var:0,number:0};for(let a=0;a{const r=Gg.createTransformer(s),n=C3(t),a=C3(s);return n.indexes.var.length===a.indexes.var.length&&n.indexes.color.length===a.indexes.color.length&&n.indexes.number.length>=a.indexes.number.length?Jge.has(t)&&!a.values.length||Jge.has(s)&&!n.values.length?xwt(t,s):RL(V$e(_wt(n,a),a.values),r):Lne(t,s)};function H$e(t,s,r){return typeof t=="number"&&typeof s=="number"&&typeof r=="number"?tc(t,s,r):M_e(t)(t,s)}const wwt=t=>{const s=({timestamp:r})=>t(r);return{start:(r=!0)=>fl.update(s,r),stop:()=>O_(s),now:()=>Iu.isProcessing?Iu.timestamp:Lh.now()}},W$e=(t,s,r=10)=>{let n="";const a=Math.max(Math.round(s/r),2);for(let o=0;o=Dne?1/0:s}function jwt(t,s=100,r){const n=r({...t,keyframes:[0,s]}),a=Math.min(T_e(n),Dne);return{type:"keyframes",ease:o=>n.next(a*o).value/s,duration:mf(a)}}const Fc={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function exe(t,s){return t*Math.sqrt(1-s*s)}const Nwt=12;function kwt(t,s,r){let n=r;for(let a=1;a{const p=u*l,f=p*t,y=p-r,_=exe(u,l),b=Math.exp(-f);return eme-y/_*b},o=u=>{const f=u*l*t,y=f*r+r,_=Math.pow(l,2)*Math.pow(u,2)*t,b=Math.exp(-f),w=exe(Math.pow(u,2),l);return(-a(u)+eme>0?-1:1)*((y-_)*b)/w}):(a=u=>{const p=Math.exp(-u*t),f=(u-r)*t+1;return-eme+p*f},o=u=>{const p=Math.exp(-u*t),f=(r-u)*(t*t);return p*f});const i=5/t,d=kwt(a,o,i);if(t=bp(t),isNaN(d))return{stiffness:Fc.stiffness,damping:Fc.damping,duration:t};{const u=Math.pow(d,2)*n;return{stiffness:u,damping:l*2*Math.sqrt(n*u),duration:t}}}const Cwt=["duration","bounce"],Mwt=["stiffness","damping","mass"];function y3e(t,s){return s.some(r=>t[r]!==void 0)}function Twt(t){let s={velocity:Fc.velocity,stiffness:Fc.stiffness,damping:Fc.damping,mass:Fc.mass,isResolvedFromDuration:!1,...t};if(!y3e(t,Mwt)&&y3e(t,Cwt))if(s.velocity=0,t.visualDuration){const r=t.visualDuration,n=2*Math.PI/(r*1.2),a=n*n,o=2*cy(.05,1,1-(t.bounce||0))*Math.sqrt(a);s={...s,mass:Fc.mass,stiffness:a,damping:o}}else{const r=Swt({...t,velocity:0});s={...s,...r,mass:Fc.mass},s.isResolvedFromDuration=!0}return s}function One(t=Fc.visualDuration,s=Fc.bounce){const r=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:s}:t;let{restSpeed:n,restDelta:a}=r;const o=r.keyframes[0],l=r.keyframes[r.keyframes.length-1],i={done:!1,value:o},{stiffness:d,damping:u,mass:p,duration:f,velocity:y,isResolvedFromDuration:_}=Twt({...r,velocity:-mf(r.velocity||0)}),b=y||0,w=u/(2*Math.sqrt(d*p)),j=l-o,k=mf(Math.sqrt(d/p)),S=Math.abs(j)<5;n||(n=S?Fc.restSpeed.granular:Fc.restSpeed.default),a||(a=S?Fc.restDelta.granular:Fc.restDelta.default);let T,I,L,R,$,q;if(w<1)L=exe(k,w),R=(b+w*k*j)/L,T=H=>{const Y=Math.exp(-w*k*H);return l-Y*(R*Math.sin(L*H)+j*Math.cos(L*H))},$=w*k*R+j*L,q=w*k*j-R*L,I=H=>Math.exp(-w*k*H)*($*Math.sin(L*H)+q*Math.cos(L*H));else if(w===1){T=Y=>l-Math.exp(-k*Y)*(j+(b+k*j)*Y);const H=b+k*j;I=Y=>Math.exp(-k*Y)*(k*H*Y-b)}else{const H=k*Math.sqrt(w*w-1);T=Q=>{const de=Math.exp(-w*k*Q),re=Math.min(H*Q,300);return l-de*((b+w*k*j)*Math.sinh(re)+H*j*Math.cosh(re))/H};const Y=(b+w*k*j)/H,se=w*k*Y-j*H,te=w*k*j-Y*H;I=Q=>{const de=Math.exp(-w*k*Q),re=Math.min(H*Q,300);return de*(se*Math.sinh(re)+te*Math.cosh(re))}}const U={calculatedDuration:_&&f||null,velocity:H=>bp(I(H)),next:H=>{if(!_&&w<1){const se=Math.exp(-w*k*H),te=Math.sin(L*H),Q=Math.cos(L*H),de=l-se*(R*te+j*Q),re=bp(se*($*te+q*Q));return i.done=Math.abs(re)<=n&&Math.abs(l-de)<=a,i.value=i.done?l:de,i}const Y=T(H);if(_)i.done=H>=f;else{const se=bp(I(H));i.done=Math.abs(se)<=n&&Math.abs(l-Y)<=a}return i.value=i.done?l:Y,i},toString:()=>{const H=Math.min(T_e(U),Dne),Y=W$e(se=>U.next(H*se).value,H,30);return H+"ms "+Y},toTransition:()=>{}};return U}One.applyToOptions=t=>{const s=jwt(t,100,One);return t.ease=s.ease,t.duration=bp(s.duration),t.type="keyframes",t};const Awt=5;function G$e(t,s,r){const n=Math.max(s-Awt,0);return S$e(r-t(n),s-n)}function txe({keyframes:t,velocity:s=0,power:r=.8,timeConstant:n=325,bounceDamping:a=10,bounceStiffness:o=500,modifyTarget:l,min:i,max:d,restDelta:u=.5,restSpeed:p}){const f=t[0],y={done:!1,value:f},_=q=>i!==void 0&&qd,b=q=>i===void 0?d:d===void 0||Math.abs(i-q)-w*Math.exp(-q/n),T=q=>k+S(q),I=q=>{const U=S(q),H=T(q);y.done=Math.abs(U)<=u,y.value=y.done?k:H};let L,R;const $=q=>{_(y.value)&&(L=q,R=One({keyframes:[y.value,b(y.value)],velocity:G$e(T,q,y.value),damping:a,stiffness:o,restDelta:u,restSpeed:p}))};return $(0),{calculatedDuration:null,next:q=>{let U=!1;return!R&&L===void 0&&(U=!0,I(q),$(q)),L!==void 0&&q>=L?R.next(q-L):(!U&&I(q),y)}}}function Ewt(t,s,r){const n=[],a=r||D_.mix||H$e,o=t.length-1;for(let l=0;ls[0];if(o===2&&s[0]===s[1])return()=>s[1];const l=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),s=[...s].reverse());const i=Ewt(s,n,a),d=i.length,u=p=>{if(l&&p1)for(;fu(cy(t[0],t[o-1],p)):u}function Iwt(t,s){const r=t[t.length-1];for(let n=1;n<=s;n++){const a=l6(0,s,n);t.push(tc(r,1,a))}}function Lwt(t){const s=[0];return Iwt(s,t.length-1),s}function Dwt(t,s){return t.map(r=>r*s)}function Owt(t,s){return t.map(()=>s||D$e).splice(0,t.length-1)}function rI({duration:t=300,keyframes:s,times:r,ease:n="easeInOut"}){const a=Vbt(n)?n.map(h3e):h3e(n),o={done:!1,value:s[0]},l=Dwt(r&&r.length===s.length?r:Lwt(s),t),i=Pwt(l,s,{ease:Array.isArray(a)?a:Owt(s,a)});return{calculatedDuration:t,next:d=>(o.value=i(d),o.done=d>=t,o)}}const Rwt=t=>t!==null;function Xoe(t,{repeat:s,repeatType:r="loop"},n,a=1){const o=t.filter(Rwt),i=a<0||s&&r!=="loop"&&s%2===1?0:o.length-1;return!i||n===void 0?o[i]:n}const Fwt={decay:txe,inertia:txe,tween:rI,keyframes:rI,spring:One};function K$e(t){typeof t.type=="string"&&(t.type=Fwt[t.type])}class A_e{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(s=>{this.resolve=s})}notifyFinished(){this.resolve()}then(s,r){return this.finished.then(s,r)}}const zwt=t=>t/100;class Rne extends A_e{constructor(s){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{var n,a;const{motionValue:r}=this.options;r&&r.updatedAt!==Lh.now()&&this.tick(Lh.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(a=(n=this.options).onStop)==null||a.call(n))},this.options=s,this.initAnimation(),this.play(),s.autoplay===!1&&this.pause()}initAnimation(){const{options:s}=this;K$e(s);const{type:r=rI,repeat:n=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=s;let{keyframes:i}=s;const d=r||rI;d!==rI&&typeof i[0]!="number"&&(this.mixKeyframes=RL(zwt,H$e(i[0],i[1])),i=[0,100]);const u=d({...s,keyframes:i});o==="mirror"&&(this.mirroredGenerator=d({...s,keyframes:[...i].reverse(),velocity:-l})),u.calculatedDuration===null&&(u.calculatedDuration=T_e(u));const{calculatedDuration:p}=u;this.calculatedDuration=p,this.resolvedDuration=p+a,this.totalDuration=this.resolvedDuration*(n+1)-a,this.generator=u}updateTime(s){const r=Math.round(s-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=r}tick(s,r=!1){const{generator:n,totalDuration:a,mixKeyframes:o,mirroredGenerator:l,resolvedDuration:i,calculatedDuration:d}=this;if(this.startTime===null)return n.next(0);const{delay:u=0,keyframes:p,repeat:f,repeatType:y,repeatDelay:_,type:b,onUpdate:w,finalKeyframe:j}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,s):this.speed<0&&(this.startTime=Math.min(s-a/this.speed,this.startTime)),r?this.currentTime=s:this.updateTime(s);const k=this.currentTime-u*(this.playbackSpeed>=0?1:-1),S=this.playbackSpeed>=0?k<0:k>a;this.currentTime=Math.max(k,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let T=this.currentTime,I=n;if(f){const q=Math.min(this.currentTime,a)/i;let U=Math.floor(q),H=q%1;!H&&q>=1&&(H=1),H===1&&U--,U=Math.min(U,f+1),!!(U%2)&&(y==="reverse"?(H=1-H,_&&(H-=_/i)):y==="mirror"&&(I=l)),T=cy(0,1,H)*i}let L;S?(this.delayState.value=p[0],L=this.delayState):L=I.next(T),o&&!S&&(L.value=o(L.value));let{done:R}=L;!S&&d!==null&&(R=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const $=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&R);return $&&b!==txe&&(L.value=Xoe(p,this.options,j,this.speed)),w&&w(L.value),$&&this.finish(),L}then(s,r){return this.finished.then(s,r)}get duration(){return mf(this.calculatedDuration)}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+mf(s)}get time(){return mf(this.currentTime)}set time(s){s=bp(s),this.currentTime=s,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=s:this.driver&&(this.startTime=this.driver.now()-s/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=s,this.tick(s))}getGeneratorVelocity(){const s=this.currentTime;if(s<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(s);const r=this.generator.next(s).value;return G$e(n=>this.generator.next(n).value,s,r)}get speed(){return this.playbackSpeed}set speed(s){const r=this.playbackSpeed!==s;r&&this.driver&&this.updateTime(Lh.now()),this.playbackSpeed=s,r&&this.driver&&(this.time=mf(this.currentTime))}play(){var a,o;if(this.isStopped)return;const{driver:s=wwt,startTime:r}=this.options;this.driver||(this.driver=s(l=>this.tick(l))),(o=(a=this.options).onPlay)==null||o.call(a);const n=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=n):this.holdTime!==null?this.startTime=n-this.holdTime:this.startTime||(this.startTime=r??n),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Lh.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var s,r;this.notifyFinished(),this.teardown(),this.state="finished",(r=(s=this.options).onComplete)==null||r.call(s)}cancel(){var s,r;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(r=(s=this.options).onCancel)==null||r.call(s)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(s){return this.startTime=0,this.tick(s,!0)}attachTimeline(s){var r;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(r=this.driver)==null||r.stop(),s.observe(this)}}function Bwt(t){for(let s=1;st*180/Math.PI,sxe=t=>{const s=ON(Math.atan2(t[1],t[0]));return rxe(s)},$wt={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:sxe,rotateZ:sxe,skewX:t=>ON(Math.atan(t[1])),skewY:t=>ON(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},rxe=t=>(t=t%360,t<0&&(t+=360),t),v3e=sxe,_3e=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),b3e=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),qwt={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:_3e,scaleY:b3e,scale:t=>(_3e(t)+b3e(t))/2,rotateX:t=>rxe(ON(Math.atan2(t[6],t[5]))),rotateY:t=>rxe(ON(Math.atan2(-t[2],t[0]))),rotateZ:v3e,rotate:v3e,skewX:t=>ON(Math.atan(t[4])),skewY:t=>ON(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function nxe(t){return t.includes("scale")?1:0}function axe(t,s){if(!t||t==="none")return nxe(s);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,a;if(r)n=qwt,a=r;else{const i=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=$wt,a=i}if(!a)return nxe(s);const o=n[s],l=a[1].split(",").map(Vwt);return typeof o=="function"?o(l):l[o]}const Uwt=(t,s)=>{const{transform:r="none"}=getComputedStyle(t);return axe(r,s)};function Vwt(t){return parseFloat(t.trim())}const SM=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],CM=new Set(SM),w3e=t=>t===kM||t===Jn,Hwt=new Set(["x","y","z"]),Wwt=SM.filter(t=>!Hwt.has(t));function Gwt(t){const s=[];return Wwt.forEach(r=>{const n=t.getValue(r);n!==void 0&&(s.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),s}const V1={width:({x:t},{paddingLeft:s="0",paddingRight:r="0",boxSizing:n})=>{const a=t.max-t.min;return n==="border-box"?a:a-parseFloat(s)-parseFloat(r)},height:({y:t},{paddingTop:s="0",paddingBottom:r="0",boxSizing:n})=>{const a=t.max-t.min;return n==="border-box"?a:a-parseFloat(s)-parseFloat(r)},top:(t,{top:s})=>parseFloat(s),left:(t,{left:s})=>parseFloat(s),bottom:({y:t},{top:s})=>parseFloat(s)+(t.max-t.min),right:({x:t},{left:s})=>parseFloat(s)+(t.max-t.min),x:(t,{transform:s})=>axe(s,"x"),y:(t,{transform:s})=>axe(s,"y")};V1.translateX=V1.x;V1.translateY=V1.y;const xk=new Set;let ixe=!1,oxe=!1,lxe=!1;function Z$e(){if(oxe){const t=Array.from(xk).filter(n=>n.needsMeasurement),s=new Set(t.map(n=>n.element)),r=new Map;s.forEach(n=>{const a=Gwt(n);a.length&&(r.set(n,a),n.render())}),t.forEach(n=>n.measureInitialState()),s.forEach(n=>{n.render();const a=r.get(n);a&&a.forEach(([o,l])=>{var i;(i=n.getValue(o))==null||i.set(l)})}),t.forEach(n=>n.measureEndState()),t.forEach(n=>{n.suspendedScrollY!==void 0&&window.scrollTo(0,n.suspendedScrollY)})}oxe=!1,ixe=!1,xk.forEach(t=>t.complete(lxe)),xk.clear()}function Y$e(){xk.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(oxe=!0)})}function Kwt(){lxe=!0,Y$e(),Z$e(),lxe=!1}class E_e{constructor(s,r,n,a,o,l=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...s],this.onComplete=r,this.name=n,this.motionValue=a,this.element=o,this.isAsync=l}scheduleResolve(){this.state="scheduled",this.isAsync?(xk.add(this),ixe||(ixe=!0,fl.read(Y$e),fl.resolveKeyframes(Z$e))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:s,name:r,element:n,motionValue:a}=this;if(s[0]===null){const o=a==null?void 0:a.get(),l=s[s.length-1];if(o!==void 0)s[0]=o;else if(n&&r){const i=n.readValue(r,l);i!=null&&(s[0]=i)}s[0]===void 0&&(s[0]=l),a&&o===void 0&&a.set(s[0])}Bwt(s)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(s=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,s),xk.delete(this)}cancel(){this.state==="scheduled"&&(xk.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Zwt=t=>t.startsWith("--");function X$e(t,s,r){Zwt(s)?t.style.setProperty(s,r):t.style[s]=r}const Ywt={};function Q$e(t,s){const r=k$e(t);return()=>Ywt[s]??r()}const Xwt=Q$e(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),J$e=Q$e(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),FE=([t,s,r,n])=>`cubic-bezier(${t}, ${s}, ${r}, ${n})`,j3e={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:FE([0,.65,.55,1]),circOut:FE([.55,0,1,.45]),backIn:FE([.31,.01,.66,-.59]),backOut:FE([.33,1.53,.69,.99])};function eqe(t,s){if(t)return typeof t=="function"?J$e()?W$e(t,s):"ease-out":O$e(t)?FE(t):Array.isArray(t)?t.map(r=>eqe(r,s)||j3e.easeOut):j3e[t]}function Qwt(t,s,r,{delay:n=0,duration:a=300,repeat:o=0,repeatType:l="loop",ease:i="easeOut",times:d}={},u=void 0){const p={[s]:r};d&&(p.offset=d);const f=eqe(i,a);Array.isArray(f)&&(p.easing=f);const y={delay:n,duration:a,easing:Array.isArray(f)?"linear":f,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"};return u&&(y.pseudoElement=u),t.animate(p,y)}function tqe(t){return typeof t=="function"&&"applyToOptions"in t}function Jwt({type:t,...s}){return tqe(t)&&J$e()?t.applyToOptions(s):(s.duration??(s.duration=300),s.ease??(s.ease="easeOut"),s)}class sqe extends A_e{constructor(s){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!s)return;const{element:r,name:n,keyframes:a,pseudoElement:o,allowFlatten:l=!1,finalKeyframe:i,onComplete:d}=s;this.isPseudoElement=!!o,this.allowFlatten=l,this.options=s,b_e(typeof s.type!="string");const u=Jwt(s);this.animation=Qwt(r,n,a,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=Xoe(a,this.options,i,this.speed);this.updateMotionValue&&this.updateMotionValue(p),X$e(r,n,p),this.animation.cancel()}d==null||d(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var s,r;(r=(s=this.animation).finish)==null||r.call(s)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:s}=this;s==="idle"||s==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var r,n,a;const s=(r=this.options)==null?void 0:r.element;!this.isPseudoElement&&(s!=null&&s.isConnected)&&((a=(n=this.animation).commitStyles)==null||a.call(n))}get duration(){var r,n;const s=((n=(r=this.animation.effect)==null?void 0:r.getComputedTiming)==null?void 0:n.call(r).duration)||0;return mf(Number(s))}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+mf(s)}get time(){return mf(Number(this.animation.currentTime)||0)}set time(s){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=bp(s),r&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(s){s<0&&(this.finishedTime=null),this.animation.playbackRate=s}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(s){this.manualStartTime=this.animation.startTime=s}attachTimeline({timeline:s,rangeStart:r,rangeEnd:n,observe:a}){var o;return this.allowFlatten&&((o=this.animation.effect)==null||o.updateTiming({easing:"linear"})),this.animation.onfinish=null,s&&Xwt()?(this.animation.timeline=s,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),_f):a(this)}}const rqe={anticipate:P$e,backInOut:E$e,circInOut:L$e};function e2t(t){return t in rqe}function t2t(t){typeof t.ease=="string"&&e2t(t.ease)&&(t.ease=rqe[t.ease])}const tme=10;class s2t extends sqe{constructor(s){t2t(s),K$e(s),super(s),s.startTime!==void 0&&s.autoplay!==!1&&(this.startTime=s.startTime),this.options=s}updateMotionValue(s){const{motionValue:r,onUpdate:n,onComplete:a,element:o,...l}=this.options;if(!r)return;if(s!==void 0){r.set(s);return}const i=new Rne({...l,autoplay:!1}),d=Math.max(tme,Lh.now()-this.startTime),u=cy(0,tme,d-tme),p=i.sample(d).value,{name:f}=this.options;o&&f&&X$e(o,f,p),r.setWithVelocity(i.sample(Math.max(0,d-u)).value,p,u),i.stop()}}const N3e=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Gg.test(t)||t==="0")&&!t.startsWith("url("));function r2t(t){const s=t[0];if(t.length===1)return!0;for(let r=0;rObject.hasOwnProperty.call(Element.prototype,"animate"));function c2t(t){var f;const{motionValue:s,name:r,repeatDelay:n,repeatType:a,damping:o,type:l,keyframes:i}=t;if(!(((f=s==null?void 0:s.owner)==null?void 0:f.current)instanceof HTMLElement))return!1;const{onUpdate:u,transformTemplate:p}=s.owner.getProps();return l2t()&&r&&(nqe.has(r)||o2t.has(r)&&i2t(i))&&(r!=="transform"||!p)&&!u&&!n&&a!=="mirror"&&o!==0&&l!=="inertia"}const d2t=40;class u2t extends A_e{constructor({autoplay:s=!0,delay:r=0,type:n="keyframes",repeat:a=0,repeatDelay:o=0,repeatType:l="loop",keyframes:i,name:d,motionValue:u,element:p,...f}){var b;super(),this.stop=()=>{var w,j;this._animation&&(this._animation.stop(),(w=this.stopTimeline)==null||w.call(this)),(j=this.keyframeResolver)==null||j.cancel()},this.createdAt=Lh.now();const y={autoplay:s,delay:r,type:n,repeat:a,repeatDelay:o,repeatType:l,name:d,motionValue:u,element:p,...f},_=(p==null?void 0:p.KeyframeResolver)||E_e;this.keyframeResolver=new _(i,(w,j,k)=>this.onKeyframesResolved(w,j,y,!k),d,u,p),(b=this.keyframeResolver)==null||b.scheduleResolve()}onKeyframesResolved(s,r,n,a){var k,S;this.keyframeResolver=void 0;const{name:o,type:l,velocity:i,delay:d,isHandoff:u,onUpdate:p}=n;this.resolvedAt=Lh.now();let f=!0;n2t(s,o,l,i)||(f=!1,(D_.instantAnimations||!d)&&(p==null||p(Xoe(s,n,r))),s[0]=s[s.length-1],cxe(n),n.repeat=0);const _={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>d2t?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:s},b=f&&!u&&c2t(_),w=(S=(k=_.motionValue)==null?void 0:k.owner)==null?void 0:S.current;let j;if(b)try{j=new s2t({..._,element:w})}catch{j=new Rne(_)}else j=new Rne(_);j.finished.then(()=>{this.notifyFinished()}).catch(_f),this.pendingTimeline&&(this.stopTimeline=j.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=j}get finished(){return this._animation?this.animation.finished:this._finished}then(s,r){return this.finished.finally(s).then(()=>{})}get animation(){var s;return this._animation||((s=this.keyframeResolver)==null||s.resume(),Kwt()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(s){this.animation.time=s}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(s){this.animation.speed=s}get startTime(){return this.animation.startTime}attachTimeline(s){return this._animation?this.stopTimeline=this.animation.attachTimeline(s):this.pendingTimeline=s,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var s;this._animation&&this.animation.cancel(),(s=this.keyframeResolver)==null||s.cancel()}}function aqe(t,s,r,n=0,a=1){const o=Array.from(t).sort((u,p)=>u.sortNodePosition(p)).indexOf(s),l=t.size,i=(l-1)*n;return typeof r=="function"?r(o,l):a===1?o*n:i-o*n}const h2t=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function m2t(t){const s=h2t.exec(t);if(!s)return[,];const[,r,n,a]=s;return[`--${r??n}`,a]}function iqe(t,s,r=1){const[n,a]=m2t(t);if(!n)return;const o=window.getComputedStyle(s).getPropertyValue(n);if(o){const l=o.trim();return w$e(l)?parseFloat(l):l}return k_e(a)?iqe(a,s,r+1):a}const p2t={type:"spring",stiffness:500,damping:25,restSpeed:10},f2t=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),g2t={type:"keyframes",duration:.8},x2t={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},y2t=(t,{keyframes:s})=>s.length>2?g2t:CM.has(t)?t.startsWith("scale")?f2t(s[1]):p2t:x2t;function oqe(t,s){if(t!=null&&t.inherit&&s){const{inherit:r,...n}=t;return{...s,...n}}return t}function P_e(t,s){const r=(t==null?void 0:t[s])??(t==null?void 0:t.default)??t;return r!==t?oqe(r,t):r}const v2t=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function _2t(t){for(const s in t)if(!v2t.has(s))return!0;return!1}const I_e=(t,s,r,n={},a,o)=>l=>{const i=P_e(n,t)||{},d=i.delay||n.delay||0;let{elapsed:u=0}=n;u=u-bp(d);const p={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:s.getVelocity(),...i,delay:-u,onUpdate:y=>{s.set(y),i.onUpdate&&i.onUpdate(y)},onComplete:()=>{l(),i.onComplete&&i.onComplete()},name:t,motionValue:s,element:o?void 0:a};_2t(i)||Object.assign(p,y2t(t,p)),p.duration&&(p.duration=bp(p.duration)),p.repeatDelay&&(p.repeatDelay=bp(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let f=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(cxe(p),p.delay===0&&(f=!0)),(D_.instantAnimations||D_.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(f=!0,cxe(p),p.delay=0),p.allowFlatten=!i.type&&!i.ease,f&&!o&&s.get()!==void 0){const y=Xoe(p.keyframes,i);if(y!==void 0){fl.update(()=>{p.onUpdate(y),p.onComplete()});return}}return i.isSync?new Rne(p):new u2t(p)};function k3e(t){const s=[{},{}];return t==null||t.values.forEach((r,n)=>{s[0][n]=r.get(),s[1][n]=r.getVelocity()}),s}function L_e(t,s,r,n){if(typeof s=="function"){const[a,o]=k3e(n);s=s(r!==void 0?r:t.custom,a,o)}if(typeof s=="string"&&(s=t.variants&&t.variants[s]),typeof s=="function"){const[a,o]=k3e(n);s=s(r!==void 0?r:t.custom,a,o)}return s}function yk(t,s,r){const n=t.getProps();return L_e(n,s,r!==void 0?r:n.custom,t)}const lqe=new Set(["width","height","top","left","right","bottom",...SM]),S3e=30,b2t=t=>!isNaN(parseFloat(t));class w2t{constructor(s,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const a=Lh.now();if(this.updatedAt!==a&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(n),this.current!==this.prev&&((o=this.events.change)==null||o.notify(this.current),this.dependents))for(const l of this.dependents)l.dirty()},this.hasAnimated=!1,this.setCurrent(s),this.owner=r.owner}setCurrent(s){this.current=s,this.updatedAt=Lh.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=b2t(this.current))}setPrevFrameValue(s=this.current){this.prevFrameValue=s,this.prevUpdatedAt=this.updatedAt}onChange(s){return this.on("change",s)}on(s,r){this.events[s]||(this.events[s]=new w_e);const n=this.events[s].add(r);return s==="change"?()=>{n(),fl.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(const s in this.events)this.events[s].clear()}attach(s,r){this.passiveEffect=s,this.stopPassiveEffect=r}set(s){this.passiveEffect?this.passiveEffect(s,this.updateAndNotify):this.updateAndNotify(s)}setWithVelocity(s,r,n){this.set(r),this.prev=void 0,this.prevFrameValue=s,this.prevUpdatedAt=this.updatedAt-n}jump(s,r=!0){this.updateAndNotify(s),this.prev=s,this.prevUpdatedAt=this.prevFrameValue=void 0,r&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var s;(s=this.events.change)==null||s.notify(this.current)}addDependent(s){this.dependents||(this.dependents=new Set),this.dependents.add(s)}removeDependent(s){this.dependents&&this.dependents.delete(s)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const s=Lh.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>S3e)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,S3e);return S$e(parseFloat(this.current)-parseFloat(this.prevFrameValue),r)}start(s){return this.stop(),new Promise(r=>{this.hasAnimated=!0,this.animation=s(r),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var s,r;(s=this.dependents)==null||s.clear(),(r=this.events.destroy)==null||r.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function M3(t,s){return new w2t(t,s)}const dxe=t=>Array.isArray(t);function j2t(t,s,r){t.hasValue(s)?t.getValue(s).set(r):t.addValue(s,M3(r))}function N2t(t){return dxe(t)?t[t.length-1]||0:t}function k2t(t,s){const r=yk(t,s);let{transitionEnd:n={},transition:a={},...o}=r||{};o={...o,...n};for(const l in o){const i=N2t(o[l]);j2t(t,l,i)}}const Ou=t=>!!(t&&t.getVelocity);function S2t(t){return!!(Ou(t)&&t.add)}function uxe(t,s){const r=t.getValue("willChange");if(S2t(r))return r.add(s);if(!r&&D_.WillChange){const n=new D_.WillChange("auto");t.addValue("willChange",n),n.add(s)}}function D_e(t){return t.replace(/([A-Z])/g,s=>`-${s.toLowerCase()}`)}const C2t="framerAppearId",cqe="data-"+D_e(C2t);function dqe(t){return t.props[cqe]}function M2t({protectedKeys:t,needsAnimating:s},r){const n=t.hasOwnProperty(r)&&s[r]!==!0;return s[r]=!1,n}function uqe(t,s,{delay:r=0,transitionOverride:n,type:a}={}){let{transition:o,transitionEnd:l,...i}=s;const d=t.getDefaultTransition();o=o?oqe(o,d):d;const u=o==null?void 0:o.reduceMotion;n&&(o=n);const p=[],f=a&&t.animationState&&t.animationState.getState()[a];for(const y in i){const _=t.getValue(y,t.latestValues[y]??null),b=i[y];if(b===void 0||f&&M2t(f,y))continue;const w={delay:r,...P_e(o||{},y)},j=_.get();if(j!==void 0&&!_.isAnimating()&&!Array.isArray(b)&&b===j&&!w.velocity){fl.update(()=>_.set(b));continue}let k=!1;if(window.MotionHandoffAnimation){const I=dqe(t);if(I){const L=window.MotionHandoffAnimation(I,y,fl);L!==null&&(w.startTime=L,k=!0)}}uxe(t,y);const S=u??t.shouldReduceMotion;_.start(I_e(y,_,b,S&&lqe.has(y)?{type:!1}:w,t,k));const T=_.animation;T&&p.push(T)}if(l){const y=()=>fl.update(()=>{l&&k2t(t,l)});p.length?Promise.all(p).then(y):y()}return p}function hxe(t,s,r={}){var d;const n=yk(t,s,r.type==="exit"?(d=t.presenceContext)==null?void 0:d.custom:void 0);let{transition:a=t.getDefaultTransition()||{}}=n||{};r.transitionOverride&&(a=r.transitionOverride);const o=n?()=>Promise.all(uqe(t,n,r)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:p=0,staggerChildren:f,staggerDirection:y}=a;return T2t(t,s,u,p,f,y,r)}:()=>Promise.resolve(),{when:i}=a;if(i){const[u,p]=i==="beforeChildren"?[o,l]:[l,o];return u().then(()=>p())}else return Promise.all([o(),l(r.delay)])}function T2t(t,s,r=0,n=0,a=0,o=1,l){const i=[];for(const d of t.variantChildren)d.notify("AnimationStart",s),i.push(hxe(d,s,{...l,delay:r+(typeof n=="function"?0:n)+aqe(t.variantChildren,d,n,a,o)}).then(()=>d.notify("AnimationComplete",s)));return Promise.all(i)}function A2t(t,s,r={}){t.notify("AnimationStart",s);let n;if(Array.isArray(s)){const a=s.map(o=>hxe(t,o,r));n=Promise.all(a)}else if(typeof s=="string")n=hxe(t,s,r);else{const a=typeof s=="function"?yk(t,s,r.custom):s;n=Promise.all(uqe(t,a,r))}return n.then(()=>{t.notify("AnimationComplete",s)})}const E2t={test:t=>t==="auto",parse:t=>t},hqe=t=>s=>s.test(t),mqe=[kM,Jn,ny,l1,rwt,swt,E2t],C3e=t=>mqe.find(hqe(t));function P2t(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||N$e(t):!0}const I2t=new Set(["brightness","contrast","saturate","opacity"]);function L2t(t){const[s,r]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[n]=r.match(S_e)||[];if(!n)return t;const a=r.replace(n,"");let o=I2t.has(s)?1:0;return n!==r&&(o*=100),s+"("+o+a+")"}const D2t=/\b([a-z-]*)\(.*?\)/gu,mxe={...Gg,getAnimatableNone:t=>{const s=t.match(D2t);return s?s.map(L2t).join(" "):t}},pxe={...Gg,getAnimatableNone:t=>{const s=Gg.parse(t);return Gg.createTransformer(t)(s.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},M3e={...kM,transform:Math.round},O2t={rotate:l1,rotateX:l1,rotateY:l1,rotateZ:l1,scale:Y8,scaleX:Y8,scaleY:Y8,scaleZ:Y8,skew:l1,skewX:l1,skewY:l1,distance:Jn,translateX:Jn,translateY:Jn,translateZ:Jn,x:Jn,y:Jn,z:Jn,perspective:Jn,transformPerspective:Jn,opacity:c6,originX:p3e,originY:p3e,originZ:Jn},O_e={borderWidth:Jn,borderTopWidth:Jn,borderRightWidth:Jn,borderBottomWidth:Jn,borderLeftWidth:Jn,borderRadius:Jn,borderTopLeftRadius:Jn,borderTopRightRadius:Jn,borderBottomRightRadius:Jn,borderBottomLeftRadius:Jn,width:Jn,maxWidth:Jn,height:Jn,maxHeight:Jn,top:Jn,right:Jn,bottom:Jn,left:Jn,inset:Jn,insetBlock:Jn,insetBlockStart:Jn,insetBlockEnd:Jn,insetInline:Jn,insetInlineStart:Jn,insetInlineEnd:Jn,padding:Jn,paddingTop:Jn,paddingRight:Jn,paddingBottom:Jn,paddingLeft:Jn,paddingBlock:Jn,paddingBlockStart:Jn,paddingBlockEnd:Jn,paddingInline:Jn,paddingInlineStart:Jn,paddingInlineEnd:Jn,margin:Jn,marginTop:Jn,marginRight:Jn,marginBottom:Jn,marginLeft:Jn,marginBlock:Jn,marginBlockStart:Jn,marginBlockEnd:Jn,marginInline:Jn,marginInlineStart:Jn,marginInlineEnd:Jn,fontSize:Jn,backgroundPositionX:Jn,backgroundPositionY:Jn,...O2t,zIndex:M3e,fillOpacity:c6,strokeOpacity:c6,numOctaves:M3e},R2t={...O_e,color:wd,backgroundColor:wd,outlineColor:wd,fill:wd,stroke:wd,borderColor:wd,borderTopColor:wd,borderRightColor:wd,borderBottomColor:wd,borderLeftColor:wd,filter:mxe,WebkitFilter:mxe,mask:pxe,WebkitMask:pxe},pqe=t=>R2t[t],F2t=new Set([mxe,pxe]);function fqe(t,s){let r=pqe(t);return F2t.has(r)||(r=Gg),r.getAnimatableNone?r.getAnimatableNone(s):void 0}const z2t=new Set(["auto","none","0"]);function B2t(t,s,r){let n=0,a;for(;n{s.getValue(d).set(u)}),this.resolveNoneKeyframes()}}function gqe(t,s,r){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){let n=document;const a=(r==null?void 0:r[t])??n.querySelectorAll(t);return a?Array.from(a):[]}return Array.from(t).filter(n=>n!=null)}const xqe=(t,s)=>s&&typeof t=="number"?s.transform(t):t;function xre(t){return j$e(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:R_e}=R$e(queueMicrotask,!1),bg={x:!1,y:!1};function yqe(){return bg.x||bg.y}function q2t(t){return t==="x"||t==="y"?bg[t]?null:(bg[t]=!0,()=>{bg[t]=!1}):bg.x||bg.y?null:(bg.x=bg.y=!0,()=>{bg.x=bg.y=!1})}function vqe(t,s){const r=gqe(t),n=new AbortController,a={passive:!0,...s,signal:n.signal};return[r,a,()=>n.abort()]}function U2t(t){return!(t.pointerType==="touch"||yqe())}function V2t(t,s,r={}){const[n,a,o]=vqe(t,r);return n.forEach(l=>{let i=!1,d=!1,u;const p=()=>{l.removeEventListener("pointerleave",b)},f=j=>{u&&(u(j),u=void 0),p()},y=j=>{i=!1,window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),d&&(d=!1,f(j))},_=()=>{i=!0,window.addEventListener("pointerup",y,a),window.addEventListener("pointercancel",y,a)},b=j=>{if(j.pointerType!=="touch"){if(i){d=!0;return}f(j)}},w=j=>{if(!U2t(j))return;d=!1;const k=s(l,j);typeof k=="function"&&(u=k,l.addEventListener("pointerleave",b,a))};l.addEventListener("pointerenter",w,a),l.addEventListener("pointerdown",_,a)}),o}const _qe=(t,s)=>s?t===s?!0:_qe(t,s.parentElement):!1,F_e=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,H2t=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function W2t(t){return H2t.has(t.tagName)||t.isContentEditable===!0}const G2t=new Set(["INPUT","SELECT","TEXTAREA"]);function K2t(t){return G2t.has(t.tagName)||t.isContentEditable===!0}const yre=new WeakSet;function T3e(t){return s=>{s.key==="Enter"&&t(s)}}function sme(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const Z2t=(t,s)=>{const r=t.currentTarget;if(!r)return;const n=T3e(()=>{if(yre.has(r))return;sme(r,"down");const a=T3e(()=>{sme(r,"up")}),o=()=>sme(r,"cancel");r.addEventListener("keyup",a,s),r.addEventListener("blur",o,s)});r.addEventListener("keydown",n,s),r.addEventListener("blur",()=>r.removeEventListener("keydown",n),s)};function A3e(t){return F_e(t)&&!yqe()}const E3e=new WeakSet;function Y2t(t,s,r={}){const[n,a,o]=vqe(t,r),l=i=>{const d=i.currentTarget;if(!A3e(i)||E3e.has(i))return;yre.add(d),r.stopPropagation&&E3e.add(i);const u=s(d,i),p=(_,b)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",y),yre.has(d)&&yre.delete(d),A3e(_)&&typeof u=="function"&&u(_,{success:b})},f=_=>{p(_,d===window||d===document||r.useGlobalTarget||_qe(d,_.target))},y=_=>{p(_,!1)};window.addEventListener("pointerup",f,a),window.addEventListener("pointercancel",y,a)};return n.forEach(i=>{(r.useGlobalTarget?window:i).addEventListener("pointerdown",l,a),xre(i)&&(i.addEventListener("focus",u=>Z2t(u,a)),!W2t(i)&&!i.hasAttribute("tabindex")&&(i.tabIndex=0))}),o}function z_e(t){return j$e(t)&&"ownerSVGElement"in t}const vre=new WeakMap;let c1;const bqe=(t,s,r)=>(n,a)=>a&&a[0]?a[0][t+"Size"]:z_e(n)&&"getBBox"in n?n.getBBox()[s]:n[r],X2t=bqe("inline","width","offsetWidth"),Q2t=bqe("block","height","offsetHeight");function J2t({target:t,borderBoxSize:s}){var r;(r=vre.get(t))==null||r.forEach(n=>{n(t,{get width(){return X2t(t,s)},get height(){return Q2t(t,s)}})})}function ejt(t){t.forEach(J2t)}function tjt(){typeof ResizeObserver>"u"||(c1=new ResizeObserver(ejt))}function sjt(t,s){c1||tjt();const r=gqe(t);return r.forEach(n=>{let a=vre.get(n);a||(a=new Set,vre.set(n,a)),a.add(s),c1==null||c1.observe(n)}),()=>{r.forEach(n=>{const a=vre.get(n);a==null||a.delete(s),a!=null&&a.size||c1==null||c1.unobserve(n)})}}const _re=new Set;let W4;function rjt(){W4=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};_re.forEach(s=>s(t))},window.addEventListener("resize",W4)}function njt(t){return _re.add(t),W4||rjt(),()=>{_re.delete(t),!_re.size&&typeof W4=="function"&&(window.removeEventListener("resize",W4),W4=void 0)}}function P3e(t,s){return typeof t=="function"?njt(t):sjt(t,s)}function ajt(t){return z_e(t)&&t.tagName==="svg"}const ijt=[...mqe,wd,Gg],ojt=t=>ijt.find(hqe(t)),I3e=()=>({translate:0,scale:1,origin:0,originPoint:0}),G4=()=>({x:I3e(),y:I3e()}),L3e=()=>({min:0,max:0}),Od=()=>({x:L3e(),y:L3e()}),ljt=new WeakMap;function Qoe(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function d6(t){return typeof t=="string"||Array.isArray(t)}const B_e=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],$_e=["initial",...B_e];function Joe(t){return Qoe(t.animate)||$_e.some(s=>d6(t[s]))}function wqe(t){return!!(Joe(t)||t.variants)}function cjt(t,s,r){for(const n in s){const a=s[n],o=r[n];if(Ou(a))t.addValue(n,a);else if(Ou(o))t.addValue(n,M3(a,{owner:t}));else if(o!==a)if(t.hasValue(n)){const l=t.getValue(n);l.liveStyle===!0?l.jump(a):l.hasAnimated||l.set(a)}else{const l=t.getStaticValue(n);t.addValue(n,M3(l!==void 0?l:a,{owner:t}))}}for(const n in r)s[n]===void 0&&t.removeValue(n);return s}const fxe={current:null},jqe={current:!1},djt=typeof window<"u";function ujt(){if(jqe.current=!0,!!djt)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>fxe.current=t.matches;t.addEventListener("change",s),s()}else fxe.current=!1}const D3e=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Fne={};function Nqe(t){Fne=t}function hjt(){return Fne}class mjt{scrapeMotionValuesFromProps(s,r,n){return{}}constructor({parent:s,props:r,presenceContext:n,reducedMotionConfig:a,skipAnimations:o,blockInitialAnimation:l,visualState:i},d={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=E_e,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const _=Lh.now();this.renderScheduledAt<_&&(this.renderScheduledAt=_,fl.render(this.render,!1,!0))};const{latestValues:u,renderState:p}=i;this.latestValues=u,this.baseTarget={...u},this.initialValues=r.initial?{...u}:{},this.renderState=p,this.parent=s,this.props=r,this.presenceContext=n,this.depth=s?s.depth+1:0,this.reducedMotionConfig=a,this.skipAnimationsConfig=o,this.options=d,this.blockInitialAnimation=!!l,this.isControllingVariants=Joe(r),this.isVariantNode=wqe(r),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(s&&s.current);const{willChange:f,...y}=this.scrapeMotionValuesFromProps(r,{},this);for(const _ in y){const b=y[_];u[_]!==void 0&&Ou(b)&&b.set(u[_])}}mount(s){var r,n;if(this.hasBeenMounted)for(const a in this.initialValues)(r=this.values.get(a))==null||r.jump(this.initialValues[a]),this.latestValues[a]=this.initialValues[a];this.current=s,ljt.set(s,this),this.projection&&!this.projection.instance&&this.projection.mount(s),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((a,o)=>this.bindToMotionValue(o,a)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(jqe.current||ujt(),this.shouldReduceMotion=fxe.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(n=this.parent)==null||n.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var s;this.projection&&this.projection.unmount(),O_(this.notifyUpdate),O_(this.render),this.valueSubscriptions.forEach(r=>r()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(s=this.parent)==null||s.removeChild(this);for(const r in this.events)this.events[r].clear();for(const r in this.features){const n=this.features[r];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(s){this.children.add(s),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(s)}removeChild(s){this.children.delete(s),this.enteringChildren&&this.enteringChildren.delete(s)}bindToMotionValue(s,r){if(this.valueSubscriptions.has(s)&&this.valueSubscriptions.get(s)(),r.accelerate&&nqe.has(s)&&this.current instanceof HTMLElement){const{factory:l,keyframes:i,times:d,ease:u,duration:p}=r.accelerate,f=new sqe({element:this.current,name:s,keyframes:i,times:d,ease:u,duration:bp(p)}),y=l(f);this.valueSubscriptions.set(s,()=>{y(),f.cancel()});return}const n=CM.has(s);n&&this.onBindTransform&&this.onBindTransform();const a=r.on("change",l=>{this.latestValues[s]=l,this.props.onUpdate&&fl.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;typeof window<"u"&&window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,s,r)),this.valueSubscriptions.set(s,()=>{a(),o&&o(),r.owner&&r.stop()})}sortNodePosition(s){return!this.current||!this.sortInstanceNodePosition||this.type!==s.type?0:this.sortInstanceNodePosition(this.current,s.current)}updateFeatures(){let s="animation";for(s in Fne){const r=Fne[s];if(!r)continue;const{isEnabled:n,Feature:a}=r;if(!this.features[s]&&a&&n(this.props)&&(this.features[s]=new a(this)),this.features[s]){const o=this.features[s];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Od()}getStaticValue(s){return this.latestValues[s]}setStaticValue(s,r){this.latestValues[s]=r}update(s,r){(s.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=s,this.prevPresenceContext=this.presenceContext,this.presenceContext=r;for(let n=0;nr.variantChildren.delete(s)}addValue(s,r){const n=this.values.get(s);r!==n&&(n&&this.removeValue(s),this.bindToMotionValue(s,r),this.values.set(s,r),this.latestValues[s]=r.get())}removeValue(s){this.values.delete(s);const r=this.valueSubscriptions.get(s);r&&(r(),this.valueSubscriptions.delete(s)),delete this.latestValues[s],this.removeValueFromRenderState(s,this.renderState)}hasValue(s){return this.values.has(s)}getValue(s,r){if(this.props.values&&this.props.values[s])return this.props.values[s];let n=this.values.get(s);return n===void 0&&r!==void 0&&(n=M3(r===null?void 0:r,{owner:this}),this.addValue(s,n)),n}readValue(s,r){let n=this.latestValues[s]!==void 0||!this.current?this.latestValues[s]:this.getBaseTargetFromProps(this.props,s)??this.readValueFromInstance(this.current,s,this.options);return n!=null&&(typeof n=="string"&&(w$e(n)||N$e(n))?n=parseFloat(n):!ojt(n)&&Gg.test(r)&&(n=fqe(s,r)),this.setBaseTarget(s,Ou(n)?n.get():n)),Ou(n)?n.get():n}setBaseTarget(s,r){this.baseTarget[s]=r}getBaseTarget(s){var o;const{initial:r}=this.props;let n;if(typeof r=="string"||typeof r=="object"){const l=L_e(this.props,r,(o=this.presenceContext)==null?void 0:o.custom);l&&(n=l[s])}if(r&&n!==void 0)return n;const a=this.getBaseTargetFromProps(this.props,s);return a!==void 0&&!Ou(a)?a:this.initialValues[s]!==void 0&&n===void 0?void 0:this.baseTarget[s]}on(s,r){return this.events[s]||(this.events[s]=new w_e),this.events[s].add(r)}notify(s,...r){this.events[s]&&this.events[s].notify(...r)}scheduleRenderMicrotask(){R_e.render(this.render)}}class kqe extends mjt{constructor(){super(...arguments),this.KeyframeResolver=$2t}sortInstanceNodePosition(s,r){return s.compareDocumentPosition(r)&2?1:-1}getBaseTargetFromProps(s,r){const n=s.style;return n?n[r]:void 0}removeValueFromRenderState(s,{vars:r,style:n}){delete r[s],delete n[s]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:s}=this.props;Ou(s)&&(this.childSubscription=s.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class Q_{constructor(s){this.isMounted=!1,this.node=s}update(){}}function Sqe({top:t,left:s,right:r,bottom:n}){return{x:{min:s,max:r},y:{min:t,max:n}}}function pjt({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function fjt(t,s){if(!s)return t;const r=s({x:t.left,y:t.top}),n=s({x:t.right,y:t.bottom});return{top:r.y,left:r.x,bottom:n.y,right:n.x}}function rme(t){return t===void 0||t===1}function gxe({scale:t,scaleX:s,scaleY:r}){return!rme(t)||!rme(s)||!rme(r)}function _N(t){return gxe(t)||Cqe(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Cqe(t){return O3e(t.x)||O3e(t.y)}function O3e(t){return t&&t!=="0%"}function zne(t,s,r){const n=t-r,a=s*n;return r+a}function R3e(t,s,r,n,a){return a!==void 0&&(t=zne(t,a,n)),zne(t,r,n)+s}function xxe(t,s=0,r=1,n,a){t.min=R3e(t.min,s,r,n,a),t.max=R3e(t.max,s,r,n,a)}function Mqe(t,{x:s,y:r}){xxe(t.x,s.translate,s.scale,s.originPoint),xxe(t.y,r.translate,r.scale,r.originPoint)}const F3e=.999999999999,z3e=1.0000000000001;function gjt(t,s,r,n=!1){var i;const a=r.length;if(!a)return;s.x=s.y=1;let o,l;for(let d=0;dF3e&&(s.x=1),s.yF3e&&(s.y=1)}function zx(t,s){t.min+=s,t.max+=s}function B3e(t,s,r,n,a=.5){const o=tc(t.min,t.max,a);xxe(t,s,r,o,n)}function $3e(t,s){return typeof t=="string"?parseFloat(t)/100*(s.max-s.min):t}function bre(t,s,r){const n=r??t;B3e(t.x,$3e(s.x,n.x),s.scaleX,s.scale,s.originX),B3e(t.y,$3e(s.y,n.y),s.scaleY,s.scale,s.originY)}function Tqe(t,s){return Sqe(fjt(t.getBoundingClientRect(),s))}function xjt(t,s,r){const n=Tqe(t,r),{scroll:a}=s;return a&&(zx(n.x,a.offset.x),zx(n.y,a.offset.y)),n}const yjt={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},vjt=SM.length;function _jt(t,s,r){let n="",a=!0;for(let o=0;o{if(!s.target)return t;if(typeof t=="string")if(Jn.test(t))t=parseFloat(t);else return t;const r=q3e(t,s.target.x),n=q3e(t,s.target.y);return`${r}% ${n}%`}},bjt={correct:(t,{treeScale:s,projectionDelta:r})=>{const n=t,a=Gg.parse(t);if(a.length>5)return n;const o=Gg.createTransformer(t),l=typeof a[0]!="number"?1:0,i=r.x.scale*s.x,d=r.y.scale*s.y;a[0+l]/=i,a[1+l]/=d;const u=tc(i,d,.5);return typeof a[2+l]=="number"&&(a[2+l]/=u),typeof a[3+l]=="number"&&(a[3+l]/=u),o(a)}},yxe={borderRadius:{...oE,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:oE,borderTopRightRadius:oE,borderBottomLeftRadius:oE,borderBottomRightRadius:oE,boxShadow:bjt};function Eqe(t,{layout:s,layoutId:r}){return CM.has(t)||t.startsWith("origin")||(s||r!==void 0)&&(!!yxe[t]||t==="opacity")}function U_e(t,s,r){var l;const n=t.style,a=s==null?void 0:s.style,o={};if(!n)return o;for(const i in n)(Ou(n[i])||a&&Ou(a[i])||Eqe(i,t)||((l=r==null?void 0:r.getValue(i))==null?void 0:l.liveStyle)!==void 0)&&(o[i]=n[i]);return o}function wjt(t){return window.getComputedStyle(t)}class jjt extends kqe{constructor(){super(...arguments),this.type="html",this.renderInstance=Aqe}readValueFromInstance(s,r){var n;if(CM.has(r))return(n=this.projection)!=null&&n.isProjecting?nxe(r):Uwt(s,r);{const a=wjt(s),o=(z$e(r)?a.getPropertyValue(r):a[r])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(s,{transformPagePoint:r}){return Tqe(s,r)}build(s,r,n){q_e(s,r,n.transformTemplate)}scrapeMotionValuesFromProps(s,r,n){return U_e(s,r,n)}}const Njt={offset:"stroke-dashoffset",array:"stroke-dasharray"},kjt={offset:"strokeDashoffset",array:"strokeDasharray"};function Sjt(t,s,r=1,n=0,a=!0){t.pathLength=1;const o=a?Njt:kjt;t[o.offset]=`${-n}`,t[o.array]=`${s} ${r}`}const Cjt=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function Pqe(t,{attrX:s,attrY:r,attrScale:n,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...i},d,u,p){if(q_e(t,i,u),d){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:f,style:y}=t;f.transform&&(y.transform=f.transform,delete f.transform),(y.transform||f.transformOrigin)&&(y.transformOrigin=f.transformOrigin??"50% 50%",delete f.transformOrigin),y.transform&&(y.transformBox=(p==null?void 0:p.transformBox)??"fill-box",delete f.transformBox);for(const _ of Cjt)f[_]!==void 0&&(y[_]=f[_],delete f[_]);s!==void 0&&(f.x=s),r!==void 0&&(f.y=r),n!==void 0&&(f.scale=n),a!==void 0&&Sjt(f,a,o,l,!1)}const Iqe=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),Lqe=t=>typeof t=="string"&&t.toLowerCase()==="svg";function Mjt(t,s,r,n){Aqe(t,s,void 0,n);for(const a in s.attrs)t.setAttribute(Iqe.has(a)?a:D_e(a),s.attrs[a])}function Dqe(t,s,r){const n=U_e(t,s,r);for(const a in t)if(Ou(t[a])||Ou(s[a])){const o=SM.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;n[o]=t[a]}return n}class Tjt extends kqe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Od}getBaseTargetFromProps(s,r){return s[r]}readValueFromInstance(s,r){if(CM.has(r)){const n=pqe(r);return n&&n.default||0}return r=Iqe.has(r)?r:D_e(r),s.getAttribute(r)}scrapeMotionValuesFromProps(s,r,n){return Dqe(s,r,n)}build(s,r,n){Pqe(s,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(s,r,n,a){Mjt(s,r,n,a)}mount(s){this.isSVGTag=Lqe(s.tagName),super.mount(s)}}const Ajt=$_e.length;function Oqe(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?Oqe(t.parent)||{}:{};return t.props.initial!==void 0&&(r.initial=t.props.initial),r}const s={};for(let r=0;rPromise.all(s.map(({animation:r,options:n})=>A2t(t,r,n)))}function Ljt(t){let s=Ijt(t),r=U3e(),n=!0,a=!1;const o=u=>(p,f)=>{var _;const y=yk(t,f,u==="exit"?(_=t.presenceContext)==null?void 0:_.custom:void 0);if(y){const{transition:b,transitionEnd:w,...j}=y;p={...p,...j,...w}}return p};function l(u){s=u(t)}function i(u){const{props:p}=t,f=Oqe(t.parent)||{},y=[],_=new Set;let b={},w=1/0;for(let k=0;kw&&L,H=!1;const Y=Array.isArray(I)?I:[I];let se=Y.reduce(o(S),{});R===!1&&(se={});const{prevResolvedValues:te={}}=T,Q={...te,...se},de=le=>{U=!0,_.has(le)&&(H=!0,_.delete(le)),T.needsAnimating[le]=!0;const he=t.getValue(le);he&&(he.liveStyle=!1)};for(const le in Q){const he=se[le],be=te[le];if(b.hasOwnProperty(le))continue;let _e=!1;dxe(he)&&dxe(be)?_e=!Rqe(he,be):_e=he!==be,_e?he!=null?de(le):_.add(le):he!==void 0&&_.has(le)?de(le):T.protectedKeys[le]=!0}T.prevProp=I,T.prevResolvedValues=se,T.isActive&&(b={...b,...se}),(n||a)&&t.blockInitialAnimation&&(U=!1);const re=$&&q;U&&(!re||H)&&y.push(...Y.map(le=>{const he={type:S};if(typeof le=="string"&&(n||a)&&!re&&t.manuallyAnimateOnMount&&t.parent){const{parent:be}=t,_e=yk(be,le);if(be.enteringChildren&&_e){const{delayChildren:je}=_e.transition||{};he.delay=aqe(be.enteringChildren,t,je)}}return{animation:le,options:he}}))}if(_.size){const k={};if(typeof p.initial!="boolean"){const S=yk(t,Array.isArray(p.initial)?p.initial[0]:p.initial);S&&S.transition&&(k.transition=S.transition)}_.forEach(S=>{const T=t.getBaseTarget(S),I=t.getValue(S);I&&(I.liveStyle=!0),k[S]=T??null}),y.push({animation:k})}let j=!!y.length;return n&&(p.initial===!1||p.initial===p.animate)&&!t.manuallyAnimateOnMount&&(j=!1),n=!1,a=!1,j?s(y):Promise.resolve()}function d(u,p){var y;if(r[u].isActive===p)return Promise.resolve();(y=t.variantChildren)==null||y.forEach(_=>{var b;return(b=_.animationState)==null?void 0:b.setActive(u,p)}),r[u].isActive=p;const f=i(u);for(const _ in r)r[_].protectedKeys={};return f}return{animateChanges:i,setActive:d,setAnimateFunction:l,getState:()=>r,reset:()=>{r=U3e(),a=!0}}}function Djt(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!Rqe(s,t):!1}function tw(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function U3e(){return{animate:tw(!0),whileInView:tw(),whileHover:tw(),whileTap:tw(),whileDrag:tw(),whileFocus:tw(),exit:tw()}}function vxe(t,s){t.min=s.min,t.max=s.max}function fg(t,s){vxe(t.x,s.x),vxe(t.y,s.y)}function V3e(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}const Fqe=1e-4,Ojt=1-Fqe,Rjt=1+Fqe,zqe=.01,Fjt=0-zqe,zjt=0+zqe;function Dh(t){return t.max-t.min}function Bjt(t,s,r){return Math.abs(t-s)<=r}function H3e(t,s,r,n=.5){t.origin=n,t.originPoint=tc(s.min,s.max,t.origin),t.scale=Dh(r)/Dh(s),t.translate=tc(r.min,r.max,t.origin)-t.originPoint,(t.scale>=Ojt&&t.scale<=Rjt||isNaN(t.scale))&&(t.scale=1),(t.translate>=Fjt&&t.translate<=zjt||isNaN(t.translate))&&(t.translate=0)}function nI(t,s,r,n){H3e(t.x,s.x,r.x,n?n.originX:void 0),H3e(t.y,s.y,r.y,n?n.originY:void 0)}function W3e(t,s,r,n=0){const a=n?tc(r.min,r.max,n):r.min;t.min=a+s.min,t.max=t.min+Dh(s)}function $jt(t,s,r,n){W3e(t.x,s.x,r.x,n==null?void 0:n.x),W3e(t.y,s.y,r.y,n==null?void 0:n.y)}function G3e(t,s,r,n=0){const a=n?tc(r.min,r.max,n):r.min;t.min=s.min-a,t.max=t.min+Dh(s)}function Bne(t,s,r,n){G3e(t.x,s.x,r.x,n==null?void 0:n.x),G3e(t.y,s.y,r.y,n==null?void 0:n.y)}function K3e(t,s,r,n,a){return t-=s,t=zne(t,1/r,n),a!==void 0&&(t=zne(t,1/a,n)),t}function qjt(t,s=0,r=1,n=.5,a,o=t,l=t){if(ny.test(s)&&(s=parseFloat(s),s=tc(l.min,l.max,s/100)-l.min),typeof s!="number")return;let i=tc(o.min,o.max,n);t===o&&(i-=s),t.min=K3e(t.min,s,r,i,a),t.max=K3e(t.max,s,r,i,a)}function Z3e(t,s,[r,n,a],o,l){qjt(t,s[r],s[n],s[a],s.scale,o,l)}const Ujt=["x","scaleX","originX"],Vjt=["y","scaleY","originY"];function Y3e(t,s,r,n){Z3e(t.x,s,Ujt,r?r.x:void 0,n?n.x:void 0),Z3e(t.y,s,Vjt,r?r.y:void 0,n?n.y:void 0)}function X3e(t){return t.translate===0&&t.scale===1}function Bqe(t){return X3e(t.x)&&X3e(t.y)}function Q3e(t,s){return t.min===s.min&&t.max===s.max}function Hjt(t,s){return Q3e(t.x,s.x)&&Q3e(t.y,s.y)}function J3e(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function $qe(t,s){return J3e(t.x,s.x)&&J3e(t.y,s.y)}function eMe(t){return Dh(t.x)/Dh(t.y)}function tMe(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}function Ax(t){return[t("x"),t("y")]}function Wjt(t,s,r){let n="";const a=t.x.translate/s.x,o=t.y.translate/s.y,l=(r==null?void 0:r.z)||0;if((a||o||l)&&(n=`translate3d(${a}px, ${o}px, ${l}px) `),(s.x!==1||s.y!==1)&&(n+=`scale(${1/s.x}, ${1/s.y}) `),r){const{transformPerspective:u,rotate:p,rotateX:f,rotateY:y,skewX:_,skewY:b}=r;u&&(n=`perspective(${u}px) ${n}`),p&&(n+=`rotate(${p}deg) `),f&&(n+=`rotateX(${f}deg) `),y&&(n+=`rotateY(${y}deg) `),_&&(n+=`skewX(${_}deg) `),b&&(n+=`skewY(${b}deg) `)}const i=t.x.scale*s.x,d=t.y.scale*s.y;return(i!==1||d!==1)&&(n+=`scale(${i}, ${d})`),n||"none"}const qqe=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],Gjt=qqe.length,sMe=t=>typeof t=="string"?parseFloat(t):t,rMe=t=>typeof t=="number"||Jn.test(t);function Kjt(t,s,r,n,a,o){a?(t.opacity=tc(0,r.opacity??1,Zjt(n)),t.opacityExit=tc(s.opacity??1,0,Yjt(n))):o&&(t.opacity=tc(s.opacity??1,r.opacity??1,n));for(let l=0;lns?1:r(l6(t,s,n))}function Xjt(t,s,r){const n=Ou(t)?t:M3(t);return n.start(I_e("",n,s,r)),n.animation}function u6(t,s,r,n={passive:!0}){return t.addEventListener(s,r,n),()=>t.removeEventListener(s,r)}const Qjt=(t,s)=>t.depth-s.depth;class Jjt{constructor(){this.children=[],this.isDirty=!1}add(s){__e(this.children,s),this.isDirty=!0}remove(s){Ine(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(Qjt),this.isDirty=!1,this.children.forEach(s)}}function eNt(t,s){const r=Lh.now(),n=({timestamp:a})=>{const o=a-r;o>=s&&(O_(n),t(o-s))};return fl.setup(n,!0),()=>O_(n)}function wre(t){return Ou(t)?t.get():t}class tNt{constructor(){this.members=[]}add(s){__e(this.members,s);for(let r=this.members.length-1;r>=0;r--){const n=this.members[r];if(n===s||n===this.lead||n===this.prevLead)continue;const a=n.instance;(!a||a.isConnected===!1)&&!n.snapshot&&(Ine(this.members,n),n.unmount())}s.scheduleRender()}remove(s){if(Ine(this.members,s),s===this.prevLead&&(this.prevLead=void 0),s===this.lead){const r=this.members[this.members.length-1];r&&this.promote(r)}}relegate(s){var r;for(let n=this.members.indexOf(s)-1;n>=0;n--){const a=this.members[n];if(a.isPresent!==!1&&((r=a.instance)==null?void 0:r.isConnected)!==!1)return this.promote(a),!0}return!1}promote(s,r){var a;const n=this.lead;if(s!==n&&(this.prevLead=n,this.lead=s,s.show(),n)){n.updateSnapshot(),s.scheduleRender();const{layoutDependency:o}=n.options,{layoutDependency:l}=s.options;(o===void 0||o!==l)&&(s.resumeFrom=n,r&&(n.preserveOpacity=!0),n.snapshot&&(s.snapshot=n.snapshot,s.snapshot.latestValues=n.animationValues||n.latestValues),(a=s.root)!=null&&a.isUpdating&&(s.isLayoutDirty=!0)),s.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(s=>{var r,n,a,o,l;(n=(r=s.options).onExitComplete)==null||n.call(r),(l=(a=s.resumingFrom)==null?void 0:(o=a.options).onExitComplete)==null||l.call(o)})}scheduleRender(){this.members.forEach(s=>s.instance&&s.scheduleRender(!1))}removeLeadSnapshot(){var s;(s=this.lead)!=null&&s.snapshot&&(this.lead.snapshot=void 0)}}const jre={hasAnimatedSinceResize:!0,hasEverUpdated:!1},nme=["","X","Y","Z"],sNt=1e3;let rNt=0;function ame(t,s,r,n){const{latestValues:a}=s;a[t]&&(r[t]=a[t],s.setStaticValue(t,0),n&&(n[t]=0))}function Vqe(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const r=dqe(s);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:a,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",fl,!(a||o))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&Vqe(n)}function Hqe({attachResizeListener:t,defaultParent:s,measureScroll:r,checkIsScrollRoot:n,resetTransform:a}){return class{constructor(l={},i=s==null?void 0:s()){this.id=rNt++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(iNt),this.nodes.forEach(hNt),this.nodes.forEach(mNt),this.nodes.forEach(oNt)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=l,this.root=i?i.root||i:this,this.path=i?[...i.path,i]:[],this.parent=i,this.depth=i?i.depth+1:0;for(let d=0;dthis.root.updateBlockedByResize=!1;fl.read(()=>{f=window.innerWidth}),t(l,()=>{const _=window.innerWidth;_!==f&&(f=_,this.root.updateBlockedByResize=!0,p&&p(),p=eNt(y,250),jre.hasAnimatedSinceResize&&(jre.hasAnimatedSinceResize=!1,this.nodes.forEach(oMe)))})}i&&this.root.registerSharedNode(i,this),this.options.animate!==!1&&u&&(i||d)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:f,hasRelativeLayoutChanged:y,layout:_})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const b=this.options.transition||u.getDefaultTransition()||yNt,{onLayoutAnimationStart:w,onLayoutAnimationComplete:j}=u.getProps(),k=!this.targetLayout||!$qe(this.targetLayout,_),S=!f&&y;if(this.options.layoutRoot||this.resumeFrom||S||f&&(k||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const T={...P_e(b,"layout"),onPlay:w,onComplete:j};(u.shouldReduceMotion||this.options.layoutRoot)&&(T.delay=0,T.type=!1),this.startAnimation(T),this.setAnimationOrigin(p,S)}else f||oMe(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=_})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const l=this.getStack();l&&l.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),O_(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(pNt),this.animationId++)}getTransformTemplate(){const{visualElement:l}=this.options;return l&&l.getProps().transformTemplate}willUpdate(l=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Vqe(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let p=0;p{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Dh(this.snapshot.measuredBox.x)&&!Dh(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let d=0;d{const L=I/1e3;lMe(f.x,l.x,L),lMe(f.y,l.y,L),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Bne(y,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),gNt(this.relativeTarget,this.relativeTargetOrigin,y,L),T&&Hjt(this.relativeTarget,T)&&(this.isProjectionDirty=!1),T||(T=Od()),fg(T,this.relativeTarget)),w&&(this.animationValues=p,Kjt(p,u,this.latestValues,L,S,k)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=L},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){var i,d,u;this.notifyListeners("animationStart"),(i=this.currentAnimation)==null||i.stop(),(u=(d=this.resumingFrom)==null?void 0:d.currentAnimation)==null||u.stop(),this.pendingAnimation&&(O_(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=fl.update(()=>{jre.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=M3(0)),this.motionValue.jump(0,!1),this.currentAnimation=Xjt(this.motionValue,[0,1e3],{...l,velocity:0,isSync:!0,onUpdate:p=>{this.mixTargetDelta(p),l.onUpdate&&l.onUpdate(p)},onStop:()=>{},onComplete:()=>{l.onComplete&&l.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const l=this.getStack();l&&l.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(sNt),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:i,target:d,layout:u,latestValues:p}=l;if(!(!i||!d||!u)){if(this!==l&&this.layout&&u&&Wqe(this.options.animationType,this.layout.layoutBox,u.layoutBox)){d=this.target||Od();const f=Dh(this.layout.layoutBox.x);d.x.min=l.target.x.min,d.x.max=d.x.min+f;const y=Dh(this.layout.layoutBox.y);d.y.min=l.target.y.min,d.y.max=d.y.min+y}fg(i,d),bre(i,p),nI(this.projectionDeltaWithTransform,this.layoutCorrected,i,p)}}registerSharedNode(l,i){this.sharedNodes.has(l)||this.sharedNodes.set(l,new tNt),this.sharedNodes.get(l).add(i);const u=i.options.initialPromotionConfig;i.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(i):void 0})}isLead(){const l=this.getStack();return l?l.lead===this:!0}getLead(){var i;const{layoutId:l}=this.options;return l?((i=this.getStack())==null?void 0:i.lead)||this:this}getPrevLead(){var i;const{layoutId:l}=this.options;return l?(i=this.getStack())==null?void 0:i.prevLead:void 0}getStack(){const{layoutId:l}=this.options;if(l)return this.root.sharedNodes.get(l)}promote({needsReset:l,transition:i,preserveFollowOpacity:d}={}){const u=this.getStack();u&&u.promote(this,d),l&&(this.projectionDelta=void 0,this.needsReset=!0),i&&this.setOptions({transition:i})}relegate(){const l=this.getStack();return l?l.relegate(this):!1}resetSkewAndRotation(){const{visualElement:l}=this.options;if(!l)return;let i=!1;const{latestValues:d}=l;if((d.z||d.rotate||d.rotateX||d.rotateY||d.rotateZ||d.skewX||d.skewY)&&(i=!0),!i)return;const u={};d.z&&ame("z",l,u,this.animationValues);for(let p=0;p{var i;return(i=l.currentAnimation)==null?void 0:i.stop()}),this.root.nodes.forEach(aMe),this.root.sharedNodes.clear()}}}function nNt(t){t.updateLayout()}function aNt(t){var r;const s=((r=t.resumeFrom)==null?void 0:r.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&s&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:a}=t.layout,{animationType:o}=t.options,l=s.source!==t.layout.source;if(o==="size")Ax(f=>{const y=l?s.measuredBox[f]:s.layoutBox[f],_=Dh(y);y.min=n[f].min,y.max=y.min+_});else if(o==="x"||o==="y"){const f=o==="x"?"y":"x";vxe(l?s.measuredBox[f]:s.layoutBox[f],n[f])}else Wqe(o,s.layoutBox,n)&&Ax(f=>{const y=l?s.measuredBox[f]:s.layoutBox[f],_=Dh(n[f]);y.max=y.min+_,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[f].max=t.relativeTarget[f].min+_)});const i=G4();nI(i,n,s.layoutBox);const d=G4();l?nI(d,t.applyTransform(a,!0),s.measuredBox):nI(d,n,s.layoutBox);const u=!Bqe(i);let p=!1;if(!t.resumeFrom){const f=t.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:y,layout:_}=f;if(y&&_){const b=t.options.layoutAnchor||void 0,w=Od();Bne(w,s.layoutBox,y.layoutBox,b);const j=Od();Bne(j,n,_.layoutBox,b),$qe(w,j)||(p=!0),f.options.layoutRoot&&(t.relativeTarget=j,t.relativeTargetOrigin=w,t.relativeParent=f)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:s,delta:d,layoutDelta:i,hasLayoutChanged:u,hasRelativeLayoutChanged:p})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function iNt(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function oNt(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function lNt(t){t.clearSnapshot()}function aMe(t){t.clearMeasurements()}function cNt(t){t.isLayoutDirty=!0,t.updateLayout()}function iMe(t){t.isLayoutDirty=!1}function dNt(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function uNt(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function oMe(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function hNt(t){t.resolveTargetDelta()}function mNt(t){t.calcProjection()}function pNt(t){t.resetSkewAndRotation()}function fNt(t){t.removeLeadSnapshot()}function lMe(t,s,r){t.translate=tc(s.translate,0,r),t.scale=tc(s.scale,1,r),t.origin=s.origin,t.originPoint=s.originPoint}function cMe(t,s,r,n){t.min=tc(s.min,r.min,n),t.max=tc(s.max,r.max,n)}function gNt(t,s,r,n){cMe(t.x,s.x,r.x,n),cMe(t.y,s.y,r.y,n)}function xNt(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const yNt={duration:.45,ease:[.4,0,.1,1]},dMe=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),uMe=dMe("applewebkit/")&&!dMe("chrome/")?Math.round:_f;function hMe(t){t.min=uMe(t.min),t.max=uMe(t.max)}function vNt(t){hMe(t.x),hMe(t.y)}function Wqe(t,s,r){return t==="position"||t==="preserve-aspect"&&!Bjt(eMe(s),eMe(r),.2)}function _Nt(t){var s;return t!==t.root&&((s=t.scroll)==null?void 0:s.wasRoot)}const bNt=Hqe({attachResizeListener:(t,s)=>u6(t,"resize",s),measureScroll:()=>{var t,s;return{x:document.documentElement.scrollLeft||((t=document.body)==null?void 0:t.scrollLeft)||0,y:document.documentElement.scrollTop||((s=document.body)==null?void 0:s.scrollTop)||0}},checkIsScrollRoot:()=>!0}),ime={current:void 0},Gqe=Hqe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!ime.current){const t=new bNt({});t.mount(window),t.setOptions({layoutScroll:!0}),ime.current=t}return ime.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),V_e=C.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function mMe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function wNt(...t){return s=>{let r=!1;const n=t.map(a=>{const o=mMe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{width:_,height:b,top:w,left:j,right:k,bottom:S}=d.current;if(s||o===!1||!i.current||!_||!b)return;const T=r==="left"?`left: ${j}`:`right: ${k}`,I=n==="bottom"?`bottom: ${S}`:`top: ${w}`;i.current.dataset.motionPopId=l;const L=document.createElement("style");u&&(L.nonce=u);const R=a??document.head;return R.appendChild(L),L.sheet&&L.sheet.insertRule(` [data-motion-pop-id="${l}"] { position: absolute !important; width: ${_}px !important; height: ${b}px !important; ${T}px !important; ${I}px !important; } `),()=>{var $;($=i.current)==null||$.removeAttribute("data-motion-pop-id"),R.contains(L)&&R.removeChild(L)}},[s]),e.jsx(NNt,{isPresent:s,childRef:i,sizeRef:d,pop:o,children:o===!1?t:C.cloneElement(t,{ref:f})})}const SNt=({children:t,initial:s,isPresent:r,onExitComplete:n,custom:a,presenceAffectsLayout:o,mode:l,anchorX:i,anchorY:d,root:u})=>{const p=v_e(CNt),f=C.useId();let y=!0,_=C.useMemo(()=>(y=!1,{id:f,initial:s,isPresent:r,custom:a,onExitComplete:b=>{p.set(b,!0);for(const w of p.values())if(!w)return;n&&n()},register:b=>(p.set(b,!1),()=>p.delete(b))}),[r,p,n]);return o&&y&&(_={..._}),C.useMemo(()=>{p.forEach((b,w)=>p.set(w,!1))},[r]),C.useEffect(()=>{!r&&!p.size&&n&&n()},[r]),t=e.jsx(kNt,{pop:l==="popLayout",isPresent:r,anchorX:i,anchorY:d,root:u,children:t}),e.jsx(Yoe.Provider,{value:_,children:t})};function CNt(){return new Map}function Kqe(t=!0){const s=C.useContext(Yoe);if(s===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:a}=s,o=C.useId();C.useEffect(()=>{if(t)return a(o)},[t]);const l=C.useCallback(()=>t&&n&&n(o),[o,n,t]);return!r&&n?[!1,l]:[!0]}const X8=t=>t.key||"";function pMe(t){const s=[];return C.Children.forEach(t,r=>{C.isValidElement(r)&&s.push(r)}),s}const Zqe=({children:t,custom:s,initial:r=!0,onExitComplete:n,presenceAffectsLayout:a=!0,mode:o="sync",propagate:l=!1,anchorX:i="left",anchorY:d="top",root:u})=>{const[p,f]=Kqe(l),y=C.useMemo(()=>pMe(t),[t]),_=l&&!p?[]:y.map(X8),b=C.useRef(!0),w=C.useRef(y),j=v_e(()=>new Map),k=C.useRef(new Set),[S,T]=C.useState(y),[I,L]=C.useState(y);b$e(()=>{b.current=!1,w.current=y;for(let q=0;q{const U=X8(q),H=l&&!p?!1:y===I||_.includes(U),Y=()=>{if(k.current.has(U))return;if(j.has(U))k.current.add(U),j.set(U,!0);else return;let se=!0;j.forEach(te=>{te||(se=!1)}),se&&($==null||$(),L(w.current),l&&(f==null||f()),n&&n())};return e.jsx(SNt,{isPresent:H,initial:!b.current||r?void 0:!1,custom:s,presenceAffectsLayout:a,mode:o,root:u,onExitComplete:H?void 0:Y,anchorX:i,anchorY:d,children:q},U)})})},Yqe=C.createContext({strict:!1}),fMe={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let gMe=!1;function MNt(){if(gMe)return;const t={};for(const s in fMe)t[s]={isEnabled:r=>fMe[s].some(n=>!!r[n])};Nqe(t),gMe=!0}function Xqe(){return MNt(),hjt()}function TNt(t){const s=Xqe();for(const r in t)s[r]={...s[r],...t[r]};Nqe(s)}const ANt=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function $ne(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||ANt.has(t)}let Qqe=t=>!$ne(t);function ENt(t){typeof t=="function"&&(Qqe=s=>s.startsWith("on")?!$ne(s):t(s))}try{ENt(require("@emotion/is-prop-valid").default)}catch{}function PNt(t,s,r){const n={};for(const a in t)a==="values"&&typeof t.values=="object"||Ou(t[a])||(Qqe(a)||r===!0&&$ne(a)||!s&&!$ne(a)||t.draggable&&a.startsWith("onDrag"))&&(n[a]=t[a]);return n}const ele=C.createContext({});function INt(t,s){if(Joe(t)){const{initial:r,animate:n}=t;return{initial:r===!1||d6(r)?r:void 0,animate:d6(n)?n:void 0}}return t.inherit!==!1?s:{}}function LNt(t){const{initial:s,animate:r}=INt(t,C.useContext(ele));return C.useMemo(()=>({initial:s,animate:r}),[xMe(s),xMe(r)])}function xMe(t){return Array.isArray(t)?t.join(" "):t}const H_e=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Jqe(t,s,r){for(const n in s)!Ou(s[n])&&!Eqe(n,r)&&(t[n]=s[n])}function DNt({transformTemplate:t},s){return C.useMemo(()=>{const r=H_e();return q_e(r,s,t),Object.assign({},r.vars,r.style)},[s])}function ONt(t,s){const r=t.style||{},n={};return Jqe(n,r,t),Object.assign(n,DNt(t,s)),n}function RNt(t,s){const r={},n=ONt(t,s);return t.drag&&t.dragListener!==!1&&(r.draggable=!1,n.userSelect=n.WebkitUserSelect=n.WebkitTouchCallout="none",n.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(r.tabIndex=0),r.style=n,r}const eUe=()=>({...H_e(),attrs:{}});function FNt(t,s,r,n){const a=C.useMemo(()=>{const o=eUe();return Pqe(o,s,Lqe(n),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[s]);if(t.style){const o={};Jqe(o,t.style,t),a.style={...o,...a.style}}return a}const zNt=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function W_e(t){return typeof t!="string"||t.includes("-")?!1:!!(zNt.indexOf(t)>-1||/[A-Z]/u.test(t))}function BNt(t,s,r,{latestValues:n},a,o=!1,l){const d=(l??W_e(t)?FNt:RNt)(s,n,a,t),u=PNt(s,typeof t=="string",o),p=t!==C.Fragment?{...u,...d,ref:r}:{},{children:f}=s,y=C.useMemo(()=>Ou(f)?f.get():f,[f]);return C.createElement(t,{...p,children:y})}function $Nt({scrapeMotionValuesFromProps:t,createRenderState:s},r,n,a){return{latestValues:qNt(r,n,a,t),renderState:s()}}function qNt(t,s,r,n){const a={},o=n(t,{});for(const y in o)a[y]=wre(o[y]);let{initial:l,animate:i}=t;const d=Joe(t),u=wqe(t);s&&u&&!d&&t.inherit!==!1&&(l===void 0&&(l=s.initial),i===void 0&&(i=s.animate));let p=r?r.initial===!1:!1;p=p||l===!1;const f=p?i:l;if(f&&typeof f!="boolean"&&!Qoe(f)){const y=Array.isArray(f)?f:[f];for(let _=0;_(s,r)=>{const n=C.useContext(ele),a=C.useContext(Yoe),o=()=>$Nt(t,s,n,a);return r?o():v_e(o)},UNt=tUe({scrapeMotionValuesFromProps:U_e,createRenderState:H_e}),VNt=tUe({scrapeMotionValuesFromProps:Dqe,createRenderState:eUe}),HNt=Symbol.for("motionComponentSymbol");function WNt(t,s,r){const n=C.useRef(r);C.useInsertionEffect(()=>{n.current=r});const a=C.useRef(null);return C.useCallback(o=>{var i;o&&((i=t.onMount)==null||i.call(t,o));const l=n.current;if(typeof l=="function")if(o){const d=l(o);typeof d=="function"&&(a.current=d)}else a.current?(a.current(),a.current=null):l(o);else l&&(l.current=o);s&&(o?s.mount(o):s.unmount())},[s])}const sUe=C.createContext({});function k4(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function GNt(t,s,r,n,a,o){var T,I;const{visualElement:l}=C.useContext(ele),i=C.useContext(Yqe),d=C.useContext(Yoe),u=C.useContext(V_e),p=u.reducedMotion,f=u.skipAnimations,y=C.useRef(null),_=C.useRef(!1);n=n||i.renderer,!y.current&&n&&(y.current=n(t,{visualState:s,parent:l,props:r,presenceContext:d,blockInitialAnimation:d?d.initial===!1:!1,reducedMotionConfig:p,skipAnimations:f,isSVG:o}),_.current&&y.current&&(y.current.manuallyAnimateOnMount=!0));const b=y.current,w=C.useContext(sUe);b&&!b.projection&&a&&(b.type==="html"||b.type==="svg")&&KNt(y.current,r,a,w);const j=C.useRef(!1);C.useInsertionEffect(()=>{b&&j.current&&b.update(r,d)});const k=r[cqe],S=C.useRef(!!k&&typeof window<"u"&&!((T=window.MotionHandoffIsComplete)!=null&&T.call(window,k))&&((I=window.MotionHasOptimisedAnimation)==null?void 0:I.call(window,k)));return b$e(()=>{_.current=!0,b&&(j.current=!0,window.MotionIsMounted=!0,b.updateFeatures(),b.scheduleRenderMicrotask(),S.current&&b.animationState&&b.animationState.animateChanges())}),C.useEffect(()=>{b&&(!S.current&&b.animationState&&b.animationState.animateChanges(),S.current&&(queueMicrotask(()=>{var L;(L=window.MotionHandoffMarkAsComplete)==null||L.call(window,k)}),S.current=!1),b.enteringChildren=void 0)}),b}function KNt(t,s,r,n){const{layoutId:a,layout:o,drag:l,dragConstraints:i,layoutScroll:d,layoutRoot:u,layoutAnchor:p,layoutCrossfade:f}=s;t.projection=new r(t.latestValues,s["data-framer-portal-id"]?void 0:rUe(t.parent)),t.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||i&&k4(i),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:f,layoutScroll:d,layoutRoot:u,layoutAnchor:p})}function rUe(t){if(t)return t.options.allowProjection!==!1?t.projection:rUe(t.parent)}function ome(t,{forwardMotionProps:s=!1,type:r}={},n,a){n&&TNt(n);const o=r?r==="svg":W_e(t),l=o?VNt:UNt;function i(u,p){let f;const y={...C.useContext(V_e),...u,layoutId:ZNt(u)},{isStatic:_}=y,b=LNt(u),w=l(u,_);if(!_&&typeof window<"u"){YNt();const j=XNt(y);f=j.MeasureLayout,b.visualElement=GNt(t,w,y,a,j.ProjectionNode,o)}return e.jsxs(ele.Provider,{value:b,children:[f&&b.visualElement?e.jsx(f,{visualElement:b.visualElement,...y}):null,BNt(t,u,WNt(w,b.visualElement,p),w,_,s,o)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const d=C.forwardRef(i);return d[HNt]=t,d}function ZNt({layoutId:t}){const s=C.useContext(y_e).id;return s&&t!==void 0?s+"-"+t:t}function YNt(t,s){C.useContext(Yqe).strict}function XNt(t){const s=Xqe(),{drag:r,layout:n}=s;if(!r&&!n)return{};const a={...r,...n};return{MeasureLayout:r!=null&&r.isEnabled(t)||n!=null&&n.isEnabled(t)?a.MeasureLayout:void 0,ProjectionNode:a.ProjectionNode}}function QNt(t,s){if(typeof Proxy>"u")return ome;const r=new Map,n=(o,l)=>ome(o,l,t,s),a=(o,l)=>n(o,l);return new Proxy(a,{get:(o,l)=>l==="create"?n:(r.has(l)||r.set(l,ome(l,void 0,t,s)),r.get(l))})}const JNt=(t,s)=>s.isSVG??W_e(t)?new Tjt(s):new jjt(s,{allowProjection:t!==C.Fragment});class ekt extends Q_{constructor(s){super(s),s.animationState||(s.animationState=Ljt(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();Qoe(s)&&(this.unmountControls=s.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:s}=this.node.getProps(),{animate:r}=this.node.prevProps||{};s!==r&&this.updateAnimationControlsSubscription()}unmount(){var s;this.node.animationState.reset(),(s=this.unmountControls)==null||s.call(this)}}let tkt=0;class skt extends Q_{constructor(){super(...arguments),this.id=tkt++,this.isExitComplete=!1}update(){var o;if(!this.node.presenceContext)return;const{isPresent:s,onExitComplete:r}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||s===n)return;if(s&&n===!1){if(this.isExitComplete){const{initial:l,custom:i}=this.node.getProps();if(typeof l=="string"){const d=yk(this.node,l,i);if(d){const{transition:u,transitionEnd:p,...f}=d;for(const y in f)(o=this.node.getValue(y))==null||o.jump(f[y])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const a=this.node.animationState.setActive("exit",!s);r&&!s&&a.then(()=>{this.isExitComplete=!0,r(this.id)})}mount(){const{register:s,onExitComplete:r}=this.node.presenceContext||{};r&&r(this.id),s&&(this.unmount=s(this.id))}unmount(){}}const rkt={animation:{Feature:ekt},exit:{Feature:skt}};function BL(t){return{point:{x:t.pageX,y:t.pageY}}}const nkt=t=>s=>F_e(s)&&t(s,BL(s));function aI(t,s,r,n){return u6(t,s,nkt(r),n)}const nUe=({current:t})=>t?t.ownerDocument.defaultView:null,yMe=(t,s)=>Math.abs(t-s);function akt(t,s){const r=yMe(t.x,s.x),n=yMe(t.y,s.y);return Math.sqrt(r**2+n**2)}const vMe=new Set(["auto","scroll"]);class aUe{constructor(s,r,{transformPagePoint:n,contextWindow:a=window,dragSnapToOrigin:o=!1,distanceThreshold:l=3,element:i}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=_=>{this.handleScroll(_.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Q8(this.lastRawMoveEventInfo,this.transformPagePoint));const _=lme(this.lastMoveEventInfo,this.history),b=this.startEvent!==null,w=akt(_.offset,{x:0,y:0})>=this.distanceThreshold;if(!b&&!w)return;const{point:j}=_,{timestamp:k}=Iu;this.history.push({...j,timestamp:k});const{onStart:S,onMove:T}=this.handlers;b||(S&&S(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent),T&&T(this.lastMoveEvent,_)},this.handlePointerMove=(_,b)=>{this.lastMoveEvent=_,this.lastRawMoveEventInfo=b,this.lastMoveEventInfo=Q8(b,this.transformPagePoint),fl.update(this.updatePoint,!0)},this.handlePointerUp=(_,b)=>{this.end();const{onEnd:w,onSessionEnd:j,resumeAnimation:k}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&k&&k(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const S=lme(_.type==="pointercancel"?this.lastMoveEventInfo:Q8(b,this.transformPagePoint),this.history);this.startEvent&&w&&w(_,S),j&&j(_,S)},!F_e(s))return;this.dragSnapToOrigin=o,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=l,this.contextWindow=a||window;const d=BL(s),u=Q8(d,this.transformPagePoint),{point:p}=u,{timestamp:f}=Iu;this.history=[{...p,timestamp:f}];const{onSessionStart:y}=r;y&&y(s,lme(u,this.history)),this.removeListeners=RL(aI(this.contextWindow,"pointermove",this.handlePointerMove),aI(this.contextWindow,"pointerup",this.handlePointerUp),aI(this.contextWindow,"pointercancel",this.handlePointerUp)),i&&this.startScrollTracking(i)}startScrollTracking(s){let r=s.parentElement;for(;r;){const n=getComputedStyle(r);(vMe.has(n.overflowX)||vMe.has(n.overflowY))&&this.scrollPositions.set(r,{x:r.scrollLeft,y:r.scrollTop}),r=r.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(s){const r=this.scrollPositions.get(s);if(!r)return;const n=s===window,a=n?{x:window.scrollX,y:window.scrollY}:{x:s.scrollLeft,y:s.scrollTop},o={x:a.x-r.x,y:a.y-r.y};o.x===0&&o.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=o.x,this.lastMoveEventInfo.point.y+=o.y):this.history.length>0&&(this.history[0].x-=o.x,this.history[0].y-=o.y),this.scrollPositions.set(s,a),fl.update(this.updatePoint,!0))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),O_(this.updatePoint)}}function Q8(t,s){return s?{point:s(t.point)}:t}function _Me(t,s){return{x:t.x-s.x,y:t.y-s.y}}function lme({point:t},s){return{point:t,delta:_Me(t,iUe(s)),offset:_Me(t,ikt(s)),velocity:okt(s,.1)}}function ikt(t){return t[0]}function iUe(t){return t[t.length-1]}function okt(t,s){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const a=iUe(t);for(;r>=0&&(n=t[r],!(a.timestamp-n.timestamp>bp(s)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&a.timestamp-n.timestamp>bp(s)*2&&(n=t[1]);const o=mf(a.timestamp-n.timestamp);if(o===0)return{x:0,y:0};const l={x:(a.x-n.x)/o,y:(a.y-n.y)/o};return l.x===1/0&&(l.x=0),l.y===1/0&&(l.y=0),l}function lkt(t,{min:s,max:r},n){return s!==void 0&&tr&&(t=n?tc(r,t,n.max):Math.min(t,r)),t}function bMe(t,s,r){return{min:s!==void 0?t.min+s:void 0,max:r!==void 0?t.max+r-(t.max-t.min):void 0}}function ckt(t,{top:s,left:r,bottom:n,right:a}){return{x:bMe(t.x,r,a),y:bMe(t.y,s,n)}}function wMe(t,s){let r=s.min-t.min,n=s.max-t.max;return s.max-s.minn?r=l6(s.min,s.max-n,t.min):n>a&&(r=l6(t.min,t.max-a,s.min)),cy(0,1,r)}function hkt(t,s){const r={};return s.min!==void 0&&(r.min=s.min-t.min),s.max!==void 0&&(r.max=s.max-t.min),r}const _xe=.35;function mkt(t=_xe){return t===!1?t=0:t===!0&&(t=_xe),{x:jMe(t,"left","right"),y:jMe(t,"top","bottom")}}function jMe(t,s,r){return{min:NMe(t,s),max:NMe(t,r)}}function NMe(t,s){return typeof t=="number"?t:t[s]||0}const pkt=new WeakMap;class fkt{constructor(s){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Od(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=s}start(s,{snapToCursor:r=!1,distanceThreshold:n}={}){const{presenceContext:a}=this.visualElement;if(a&&a.isPresent===!1)return;const o=f=>{r&&this.snapToCursor(BL(f).point),this.stopAnimation()},l=(f,y)=>{const{drag:_,dragPropagation:b,onDragStart:w}=this.getProps();if(_&&!b&&(this.openDragLock&&this.openDragLock(),this.openDragLock=q2t(_),!this.openDragLock))return;this.latestPointerEvent=f,this.latestPanInfo=y,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Ax(k=>{let S=this.getAxisMotionValue(k).get()||0;if(ny.test(S)){const{projection:T}=this.visualElement;if(T&&T.layout){const I=T.layout.layoutBox[k];I&&(S=Dh(I)*(parseFloat(S)/100))}}this.originPoint[k]=S}),w&&fl.update(()=>w(f,y),!1,!0),uxe(this.visualElement,"transform");const{animationState:j}=this.visualElement;j&&j.setActive("whileDrag",!0)},i=(f,y)=>{this.latestPointerEvent=f,this.latestPanInfo=y;const{dragPropagation:_,dragDirectionLock:b,onDirectionLock:w,onDrag:j}=this.getProps();if(!_&&!this.openDragLock)return;const{offset:k}=y;if(b&&this.currentDirection===null){this.currentDirection=xkt(k),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",y.point,k),this.updateAxis("y",y.point,k),this.visualElement.render(),j&&fl.update(()=>j(f,y),!1,!0)},d=(f,y)=>{this.latestPointerEvent=f,this.latestPanInfo=y,this.stop(f,y),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:f}=this.getProps();(f||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:p}=this.getProps();this.panSession=new aUe(s,{onSessionStart:o,onStart:l,onMove:i,onSessionEnd:d,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:n,contextWindow:nUe(this.visualElement),element:this.visualElement.current})}stop(s,r){const n=s||this.latestPointerEvent,a=r||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!a||!n)return;const{velocity:l}=a;this.startAnimation(l);const{onDragEnd:i}=this.getProps();i&&fl.postRender(()=>i(n,a))}cancel(){this.isDragging=!1;const{projection:s,animationState:r}=this.visualElement;s&&(s.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),r&&r.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(s,r,n){const{drag:a}=this.getProps();if(!n||!J8(s,a,this.currentDirection))return;const o=this.getAxisMotionValue(s);let l=this.originPoint[s]+n[s];this.constraints&&this.constraints[s]&&(l=lkt(l,this.constraints[s],this.elastic[s])),o.set(l)}resolveConstraints(){var o;const{dragConstraints:s,dragElastic:r}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(o=this.visualElement.projection)==null?void 0:o.layout,a=this.constraints;s&&k4(s)?this.constraints||(this.constraints=this.resolveRefConstraints()):s&&n?this.constraints=ckt(n.layoutBox,s):this.constraints=!1,this.elastic=mkt(r),a!==this.constraints&&!k4(s)&&n&&this.constraints&&!this.hasMutatedConstraints&&Ax(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=hkt(n.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:r}=this.getProps();if(!s||!k4(s))return!1;const n=s.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=xjt(n,a.root,this.visualElement.getTransformPagePoint());let l=dkt(a.layout.layoutBox,o);if(r){const i=r(pjt(l));this.hasMutatedConstraints=!!i,i&&(l=Sqe(i))}return l}startAnimation(s){const{drag:r,dragMomentum:n,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:i}=this.getProps(),d=this.constraints||{},u=Ax(p=>{if(!J8(p,r,this.currentDirection))return;let f=d&&d[p]||{};(l===!0||l===p)&&(f={min:0,max:0});const y=a?200:1e6,_=a?40:1e7,b={type:"inertia",velocity:n?s[p]:0,bounceStiffness:y,bounceDamping:_,timeConstant:750,restDelta:1,restSpeed:10,...o,...f};return this.startAxisValueAnimation(p,b)});return Promise.all(u).then(i)}startAxisValueAnimation(s,r){const n=this.getAxisMotionValue(s);return uxe(this.visualElement,s),n.start(I_e(s,n,0,r,this.visualElement,!1))}stopAnimation(){Ax(s=>this.getAxisMotionValue(s).stop())}getAxisMotionValue(s){const r=`_drag${s.toUpperCase()}`,n=this.visualElement.getProps(),a=n[r];return a||this.visualElement.getValue(s,(n.initial?n.initial[s]:void 0)||0)}snapToCursor(s){Ax(r=>{const{drag:n}=this.getProps();if(!J8(r,n,this.currentDirection))return;const{projection:a}=this.visualElement,o=this.getAxisMotionValue(r);if(a&&a.layout){const{min:l,max:i}=a.layout.layoutBox[r],d=o.get()||0;o.set(s[r]-tc(l,i,.5)+d)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!k4(r)||!n||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Ax(l=>{const i=this.getAxisMotionValue(l);if(i&&this.constraints!==!1){const d=i.get();a[l]=ukt({min:d,max:d},this.constraints[l])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),Ax(l=>{if(!J8(l,s,null))return;const i=this.getAxisMotionValue(l),{min:d,max:u}=this.constraints[l];i.set(tc(d,u,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;pkt.set(this.visualElement,this);const s=this.visualElement.current,r=aI(s,"pointerdown",u=>{const{drag:p,dragListener:f=!0}=this.getProps(),y=u.target,_=y!==s&&K2t(y);p&&f&&!_&&this.start(u)});let n;const a=()=>{const{dragConstraints:u}=this.getProps();k4(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),n||(n=gkt(s,u.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),fl.read(a);const i=u6(window,"resize",()=>this.scalePositionWithinConstraints()),d=o.addEventListener("didUpdate",({delta:u,hasLayoutChanged:p})=>{this.isDragging&&p&&(Ax(f=>{const y=this.getAxisMotionValue(f);y&&(this.originPoint[f]+=u[f].translate,y.set(y.get()+u[f].translate))}),this.visualElement.render())});return()=>{i(),r(),l(),d&&d(),n&&n()}}getProps(){const s=this.visualElement.getProps(),{drag:r=!1,dragDirectionLock:n=!1,dragPropagation:a=!1,dragConstraints:o=!1,dragElastic:l=_xe,dragMomentum:i=!0}=s;return{...s,drag:r,dragDirectionLock:n,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:i}}}function kMe(t){let s=!0;return()=>{if(s){s=!1;return}t()}}function gkt(t,s,r){const n=P3e(t,kMe(r)),a=P3e(s,kMe(r));return()=>{n(),a()}}function J8(t,s,r){return(s===!0||s===t)&&(r===null||r===t)}function xkt(t,s=10){let r=null;return Math.abs(t.y)>s?r="y":Math.abs(t.x)>s&&(r="x"),r}class ykt extends Q_{constructor(s){super(s),this.removeGroupControls=_f,this.removeListeners=_f,this.controls=new fkt(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||_f}update(){const{dragControls:s}=this.node.getProps(),{dragControls:r}=this.node.prevProps||{};s!==r&&(this.removeGroupControls(),s&&(this.removeGroupControls=s.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const cme=t=>(s,r)=>{t&&fl.update(()=>t(s,r),!1,!0)};class vkt extends Q_{constructor(){super(...arguments),this.removePointerDownListener=_f}onPointerDown(s){this.session=new aUe(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:nUe(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:r,onPan:n,onPanEnd:a}=this.node.getProps();return{onSessionStart:cme(s),onStart:cme(r),onMove:cme(n),onEnd:(o,l)=>{delete this.session,a&&fl.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=aI(this.node.current,"pointerdown",s=>this.onPointerDown(s))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let dme=!1;class _kt extends C.Component{componentDidMount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n,layoutId:a}=this.props,{projection:o}=s;o&&(r.group&&r.group.add(o),n&&n.register&&a&&n.register(o),dme&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),jre.hasEverUpdated=!0}getSnapshotBeforeUpdate(s){const{layoutDependency:r,visualElement:n,drag:a,isPresent:o}=this.props,{projection:l}=n;return l&&(l.isPresent=o,s.layoutDependency!==r&&l.setOptions({...l.options,layoutDependency:r}),dme=!0,a||s.layoutDependency!==r||r===void 0||s.isPresent!==o?l.willUpdate():this.safeToRemove(),s.isPresent!==o&&(o?l.promote():l.relegate()||fl.postRender(()=>{const i=l.getStack();(!i||!i.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:s,layoutAnchor:r}=this.props,{projection:n}=s;n&&(n.options.layoutAnchor=r,n.root.didUpdate(),R_e.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:a}=s;dme=!0,a&&(a.scheduleCheckAfterUnmount(),r&&r.group&&r.group.remove(a),n&&n.deregister&&n.deregister(a))}safeToRemove(){const{safeToRemove:s}=this.props;s&&s()}render(){return null}}function oUe(t){const[s,r]=Kqe(),n=C.useContext(y_e);return e.jsx(_kt,{...t,layoutGroup:n,switchLayoutGroup:C.useContext(sUe),isPresent:s,safeToRemove:r})}const bkt={pan:{Feature:vkt},drag:{Feature:ykt,ProjectionNode:Gqe,MeasureLayout:oUe}};function SMe(t,s,r){const{props:n}=t;t.animationState&&n.whileHover&&t.animationState.setActive("whileHover",r==="Start");const a="onHover"+r,o=n[a];o&&fl.postRender(()=>o(s,BL(s)))}class wkt extends Q_{mount(){const{current:s}=this.node;s&&(this.unmount=V2t(s,(r,n)=>(SMe(this.node,n,"Start"),a=>SMe(this.node,a,"End"))))}unmount(){}}class jkt extends Q_{constructor(){super(...arguments),this.isActive=!1}onFocus(){let s=!1;try{s=this.node.current.matches(":focus-visible")}catch{s=!0}!s||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=RL(u6(this.node.current,"focus",()=>this.onFocus()),u6(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function CMe(t,s,r){const{props:n}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&n.whileTap&&t.animationState.setActive("whileTap",r==="Start");const a="onTap"+(r==="End"?"":r),o=n[a];o&&fl.postRender(()=>o(s,BL(s)))}class Nkt extends Q_{mount(){const{current:s}=this.node;if(!s)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=Y2t(s,(a,o)=>(CMe(this.node,o,"Start"),(l,{success:i})=>CMe(this.node,l,i?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const bxe=new WeakMap,ume=new WeakMap,kkt=t=>{const s=bxe.get(t.target);s&&s(t)},Skt=t=>{t.forEach(kkt)};function Ckt({root:t,...s}){const r=t||document;ume.has(r)||ume.set(r,{});const n=ume.get(r),a=JSON.stringify(s);return n[a]||(n[a]=new IntersectionObserver(Skt,{root:t,...s})),n[a]}function Mkt(t,s,r){const n=Ckt(s);return bxe.set(t,r),n.observe(t),()=>{bxe.delete(t),n.unobserve(t)}}const Tkt={some:0,all:1};class Akt extends Q_{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var d;(d=this.stopObserver)==null||d.call(this);const{viewport:s={}}=this.node.getProps(),{root:r,margin:n,amount:a="some",once:o}=s,l={root:r?r.current:void 0,rootMargin:n,threshold:typeof a=="number"?a:Tkt[a]},i=u=>{const{isIntersecting:p}=u;if(this.isInView===p||(this.isInView=p,o&&!p&&this.hasEnteredView))return;p&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",p);const{onViewportEnter:f,onViewportLeave:y}=this.node.getProps(),_=p?f:y;_&&_(u)};this.stopObserver=Mkt(this.node.current,l,i)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:s,prevProps:r}=this.node;["amount","margin","root"].some(Ekt(s,r))&&this.startObserver()}unmount(){var s;(s=this.stopObserver)==null||s.call(this),this.hasEnteredView=!1,this.isInView=!1}}function Ekt({viewport:t={}},{viewport:s={}}={}){return r=>t[r]!==s[r]}const Pkt={inView:{Feature:Akt},tap:{Feature:Nkt},focus:{Feature:jkt},hover:{Feature:wkt}},Ikt={layout:{ProjectionNode:Gqe,MeasureLayout:oUe}},Lkt={...rkt,...Pkt,...bkt,...Ikt},wr=QNt(Lkt,JNt);function Dkt(t){switch(t){case"buying":return{label:"Buying",emoji:"🏠",color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30"};case"selling":return{label:"Selling",emoji:"📋",color:"bg-blue-500/15 text-blue-400 border-blue-500/30"};case"neighbor":return{label:"Neighbor",emoji:"👋",color:"bg-amber-500/15 text-amber-400 border-amber-500/30"};case"browsing":return{label:"Browsing",emoji:"👀",color:"bg-slate-500/15 text-slate-300 border-slate-500/30"};default:return{label:"Visitor",emoji:"🙂",color:"bg-slate-500/15 text-slate-300 border-slate-500/30"}}}function MMe(t){return t.visitor_intent==="buying"&&!t.has_agent}function Okt({token:t}={}){var b;const s=ko(),r=t||s.token,{data:n,isLoading:a,isError:o}=jbt(r),l=rs(),i=(b=n==null?void 0:n.open_houses)==null?void 0:b.id,{data:d}=wt({queryKey:["cohost-visitors",i],queryFn:async()=>{const{data:w,error:j}=await G.from("open_house_visitors").select("*").eq("open_house_id",i).order("created_at",{ascending:!1});if(j)throw j;return w},enabled:!!i});if(C.useEffect(()=>{if(!i)return;const w=G.channel(`cohost-visitors-${i}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"open_house_visitors",filter:`open_house_id=eq.${i}`},()=>{l.invalidateQueries({queryKey:["cohost-visitors",i]})}).subscribe();return()=>{G.removeChannel(w)}},[i,l]),a)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex items-center justify-center",children:e.jsx("div",{className:"animate-pulse text-white/40",children:"Validating access..."})});if(o||!n)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx("h1",{className:"text-xl font-bold mb-2",children:"Link Expired or Invalid"}),e.jsx("p",{className:"text-white/40 text-sm",children:"This co-host link is no longer active. Ask the host for a new one."})]})});const u=n.open_houses,p=(d==null?void 0:d.length)||0,f=(d==null?void 0:d.filter(w=>w.visitor_intent==="buying").length)||0,y=(d==null?void 0:d.filter(MMe).length)||0,_=w=>{if(!w)return"";const[j,k]=w.split(":"),S=parseInt(j);return`${S>12?S-12:S||12}:${k} ${S>=12?"PM":"AM"}`};return e.jsxs("div",{className:"fixed inset-0 bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex flex-col",children:[e.jsxs("div",{className:"border-b border-white/10 px-4 sm:px-6 py-3 flex items-center justify-between bg-black/30 backdrop-blur-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{className:"text-xs font-medium text-emerald-400 uppercase tracking-wider",children:"Live · Co-Host View"})]}),e.jsx("h1",{className:"text-white font-bold text-sm sm:text-base truncate",children:u.property_address})]}),e.jsxs("div",{className:"flex items-center gap-4 sm:gap-6 text-white/70",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:p})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-orange-400",children:[e.jsx(nh,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:y})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(On,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:f})]})]})]}),e.jsxs("div",{className:"px-4 sm:px-6 py-2 flex items-center gap-4 text-xs text-white/40 border-b border-white/5",children:[e.jsx("span",{children:ys(new Date(u.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy")}),u.start_time&&e.jsxs("span",{children:[_(u.start_time),u.end_time?` – ${_(u.end_time)}`:""]})]}),e.jsx(Ri,{className:"flex-1 p-4 sm:p-6",children:d!=null&&d.length?e.jsx("div",{className:"space-y-2 max-w-3xl mx-auto",children:e.jsx(Zqe,{children:d.map((w,j)=>{var T;const k=Dkt(w.visitor_intent),S=MMe(w);return e.jsxs(wr.div,{initial:{opacity:0,x:-40,scale:.95},animate:{opacity:1,x:0,scale:1},transition:{duration:.4,delay:j*.05},className:`flex items-center gap-4 p-4 rounded-xl border ${S?"bg-orange-500/10 border-orange-500/30":"bg-white/5 border-white/10"}`,children:[e.jsx("div",{className:`w-11 h-11 rounded-full flex items-center justify-center text-lg font-bold shrink-0 ${S?"bg-gradient-to-br from-orange-500 to-amber-500 text-white":"bg-white/10 text-white/80"}`,children:(T=w.first_name[0])==null?void 0:T.toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"font-semibold text-white truncate",children:[w.first_name," ",w.last_name||""]}),S&&e.jsx(rt,{className:"bg-orange-500/20 text-orange-300 border-orange-500/40 text-[10px] px-1.5 py-0",children:"🔥 HOT"}),w.has_agent&&e.jsx(rt,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-yellow-500/40 text-yellow-400",children:"⚠️ Has Agent"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsxs(rt,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${k.color}`,children:[k.emoji," ",k.label]}),e.jsx("span",{className:"text-white/30 text-xs",children:ys(new Date(w.created_at),"h:mm a")})]})]})]},w.id)})})}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center py-20",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-white/5 flex items-center justify-center mb-4",children:e.jsx($0,{className:"h-10 w-10 text-white/20"})}),e.jsx("h2",{className:"text-xl font-bold text-white/60 mb-1",children:"Waiting for visitors..."}),e.jsx("p",{className:"text-white/30 text-sm",children:"New sign-ins will appear here in real-time"})]})})]})}function Rkt(){const s=bu().pathname.slice(1);if(C.useEffect(()=>(document.body.classList.add("guestbook-page"),()=>{document.body.classList.remove("guestbook-page")}),[]),s.startsWith("live/")){const r=s.slice(5);if(r)return e.jsx(Okt,{token:r})}return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Guest Book"}),e.jsx("p",{className:"text-white/60",children:"The modern open house sign-in experience."}),e.jsx("p",{className:"text-white/40 text-sm mt-2",children:"Visit a specific open house link to sign in."})]})}):e.jsx(o$e,{slug:s})}function Fkt({dealData:t,agentProfile:s,welcomeMessage:r,isWon:n}){var o;const a=t!=null&&t.property_address?`${t.property_address}, ${t.city||""}, ${t.state||""}`.replace(/,\s*,/g,",").replace(/,\s*$/,""):null;return e.jsxs("div",{className:"relative overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-br from-[#2a4c64] via-[#345e7a] to-[#406E71] text-white px-4 pt-10 pb-16",children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.04]",style:{backgroundImage:"radial-gradient(circle at 25% 25%, white 1px, transparent 1px)",backgroundSize:"24px 24px"}}),e.jsxs("div",{className:"relative text-center max-w-lg mx-auto",children:[s&&e.jsxs("div",{className:"mb-6",children:[s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:s.name,className:"w-20 h-20 rounded-full border-[3px] border-white/30 shadow-xl mx-auto mb-3 object-cover"}):e.jsx("div",{className:"w-20 h-20 rounded-full border-[3px] border-white/30 shadow-xl mx-auto mb-3 bg-white/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl font-bold text-white/70",children:((o=s.name)==null?void 0:o.charAt(0))||"?"})}),e.jsx("p",{className:"text-sm font-medium text-white/90",children:s.name}),e.jsx("p",{className:"text-xs text-white/50 mt-0.5",children:"Your Real Estate Agent"})]}),e.jsxs("div",{className:"inline-flex items-center gap-1.5 bg-white/10 backdrop-blur-sm rounded-full px-3 py-1 text-xs font-medium text-white/80 mb-3",children:[e.jsx(On,{className:"w-3 h-3"}),(t==null?void 0:t.deal_type)==="listing"?"Listing":(t==null?void 0:t.deal_type)==="buy-side"?"Purchase":"Transaction"]}),e.jsx("h1",{className:"text-2xl font-bold tracking-tight mb-1.5 font-serif",children:(t==null?void 0:t.deal_name)||"Your Transaction Portal"}),a&&e.jsxs("div",{className:"flex items-center justify-center gap-1 text-white/60 text-sm",children:[e.jsx(Oi,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:a})]}),r&&e.jsx("p",{className:"mt-4 text-sm text-white/70 leading-relaxed max-w-sm mx-auto",children:r})]})]}),s&&e.jsx("div",{className:"max-w-lg mx-auto px-4 -mt-8 relative z-10",children:e.jsx("div",{className:"bg-white rounded-2xl shadow-lg border border-slate-100 p-4",children:e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[s.phone&&e.jsxs("a",{href:`tel:${s.phone}`,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-[#406E71]/10 hover:bg-[#406E71]/20 transition-colors",children:[e.jsx(Qn,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Call"})]}),s.email&&e.jsxs("a",{href:`mailto:${s.email}`,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-[#406E71]/10 hover:bg-[#406E71]/20 transition-colors",children:[e.jsx(br,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Email"})]}),s.phone&&e.jsxs("a",{href:`sms:${s.phone}`,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-[#406E71]/10 hover:bg-[#406E71]/20 transition-colors",children:[e.jsx(xc,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Text"})]})]})})})]})}function zkt({journeyStages:t,currentIndex:s}){return t.length===0?null:e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-base font-semibold text-slate-800 mb-1",children:"Your Home Journey"}),e.jsx("p",{className:"text-xs text-slate-400 mb-5",children:"Follow along as your transaction progresses"}),e.jsx("div",{className:"relative",children:t.map((r,n)=>{const a=ns;return e.jsxs("div",{className:"flex items-start gap-3.5 relative",children:[n{var l,i;if(o.includes("youtube.com/watch")){const d=new URL(o).searchParams.get("v");return d?`https://www.youtube.com/embed/${d}`:null}if(o.includes("youtu.be/")){const d=(l=o.split("youtu.be/")[1])==null?void 0:l.split("?")[0];return d?`https://www.youtube.com/embed/${d}`:null}if(o.includes("loom.com/share/")){const d=(i=o.split("loom.com/share/")[1])==null?void 0:i.split("?")[0];return d?`https://www.loom.com/embed/${d}`:null}return o};return e.jsxs("div",{className:"bg-gradient-to-br from-[#406E71]/5 via-white to-[#406E71]/5 rounded-2xl border border-[#406E71]/15 overflow-hidden",children:[e.jsx("div",{className:"bg-[#406E71] px-5 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($i,{className:"w-4 h-4 text-white/80"}),e.jsx("h3",{className:"text-sm font-semibold text-white",children:"Current Stage"})]})}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-lg font-bold text-slate-800",children:t.label}),e.jsx("p",{className:"text-sm text-slate-500 mt-1 leading-relaxed",children:t.description})]}),s&&e.jsxs("div",{className:"bg-slate-50 rounded-xl p-4 border border-slate-100",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1.5",children:"Update from your agent"}),e.jsx("p",{className:"text-sm text-slate-700 leading-relaxed",children:s})]}),r&&e.jsxs("div",{className:"bg-blue-50/60 rounded-xl p-4 border border-blue-100",children:[e.jsx("p",{className:"text-xs font-semibold text-blue-600 uppercase tracking-wider mb-1.5",children:"What's Next"}),e.jsx("p",{className:"text-sm text-blue-800 leading-relaxed",children:r})]}),n&&e.jsx("div",{className:"rounded-xl overflow-hidden bg-slate-900 aspect-video shadow-md",children:e.jsx("iframe",{src:a(n)||n,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Next step video"})})]})]})}function gl(t){const s=t.split(/[-/T]/);if(s.length>=3){const r=Number(s[0]);return r>99?new Date(r,Number(s[1])-1,Number(s[2])):new Date(Number(s[2]),Number(s[0])-1,Number(s[1]))}return new Date(`${t}T12:00:00`)}function qkt(t,s){const r=ys(s,"yyyyMMdd");return`https://calendar.google.com/calendar/render?${new URLSearchParams({action:"TEMPLATE",text:t,dates:`${r}/${r}`,details:"Added from your Client Portal"}).toString()}`}function Ukt(t,s){const r=ys(s,"yyyyMMdd");return`data:text/calendar;charset=utf-8,${encodeURIComponent(`BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT DTSTART;VALUE=DATE:${r} DTEND;VALUE=DATE:${r} SUMMARY:${t} DESCRIPTION:Added from your Client Portal END:VEVENT END:VCALENDAR`)}`}function Vkt({targetCloseDate:t,contractDate:s,inspectionDate:r,appraisalDate:n,actualCloseDate:a}){const o=[{label:"Contract Date",date:s,icon:p5,color:"text-blue-600 bg-blue-50"},{label:"Inspection",date:r,icon:gn,color:"text-amber-600 bg-amber-50"},{label:"Appraisal",date:n,icon:On,color:"text-purple-600 bg-purple-50"},{label:a?"Closed":"Target Close",date:a||t,icon:on,color:"text-emerald-600 bg-emerald-50"}].filter(i=>i.date);if(o.length===0)return null;const l=(i,d,u)=>{const p=gl(d);if(u==="google")window.open(qkt(i,p),"_blank");else{const f=Ukt(i,p),y=document.createElement("a");y.href=f,y.download=`${i.replace(/\s+/g,"-").toLowerCase()}.ics`,y.click()}};return e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-3",children:"Key Dates"}),e.jsx("div",{className:"space-y-3",children:o.map(({label:i,date:d,icon:u,color:p})=>{const f=gl(d),y=sy(f)&&!Bd(f),_=Bd(f),b=!y&&!_;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${p}`,children:e.jsx(u,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs text-slate-500",children:i}),e.jsxs("p",{className:`text-sm font-medium ${_?"text-emerald-600":y?"text-slate-400":"text-slate-800"}`,children:[ys(f,"MMM d, yyyy"),_&&e.jsx("span",{className:"ml-1.5 text-xs bg-emerald-100 text-emerald-700 px-1.5 py-0.5 rounded-full",children:"Today"})]})]}),y&&e.jsx("span",{className:"text-xs text-slate-400",children:"✓"}),b&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>l(i,d,"google"),className:"text-xs text-slate-400 hover:text-blue-500 transition-colors px-1.5 py-1 rounded hover:bg-blue-50",title:"Add to Google Calendar",children:e.jsx(n_,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>l(i,d,"apple"),className:"text-[10px] text-slate-400 hover:text-slate-600 transition-colors px-1.5 py-1 rounded hover:bg-slate-100",title:"Download .ics file",children:".ics"})]})]},i)})})]})}function Hkt({documents:t}){const s=n=>n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(0)} KB`:`${(n/1048576).toFixed(1)} MB`,r=async n=>{const{data:a}=await G.storage.from("deal-files").createSignedUrl(n.storage_path,300);a!=null&&a.signedUrl&&window.open(a.signedUrl,"_blank")};return e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-3",children:"Documents"}),e.jsx("div",{className:"space-y-2",children:t.map(n=>e.jsxs("button",{onClick:()=>r(n),className:"w-full flex items-center gap-3 p-3 rounded-xl hover:bg-slate-50 transition-colors text-left group",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-slate-100 flex items-center justify-center flex-shrink-0 group-hover:bg-blue-50 transition-colors",children:e.jsx(In,{className:"w-4 h-4 text-slate-500 group-hover:text-blue-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-slate-700 truncate",children:n.file_name}),e.jsx("p",{className:"text-xs text-slate-400",children:s(n.file_size)})]}),e.jsx(xi,{className:"w-4 h-4 text-slate-300 group-hover:text-blue-500 transition-colors"})]},n.id))})]})}function Wkt({updates:t}){const s=r=>{var n,a;if(r.includes("youtube.com/watch")){const o=new URL(r).searchParams.get("v");return o?`https://www.youtube.com/embed/${o}`:null}if(r.includes("youtu.be/")){const o=(n=r.split("youtu.be/")[1])==null?void 0:n.split("?")[0];return o?`https://www.youtube.com/embed/${o}`:null}if(r.includes("loom.com/share/")){const o=(a=r.split("loom.com/share/")[1])==null?void 0:a.split("?")[0];return o?`https://www.loom.com/embed/${o}`:null}return r};return e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-4",children:"Updates from Your Agent"}),e.jsx("div",{className:"space-y-4",children:t.map((r,n)=>e.jsx("div",{className:`${n>0?"pt-4 border-t border-slate-100":""}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center flex-shrink-0 ${r.is_stage_change?"bg-emerald-100":"bg-blue-100"}`,children:r.is_stage_change?e.jsx(Hc,{className:"w-3.5 h-3.5 text-emerald-600"}):e.jsx(gf,{className:"w-3.5 h-3.5 text-blue-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("h3",{className:"text-sm font-medium text-slate-800",children:r.title}),e.jsx("span",{className:"text-xs text-slate-400 flex-shrink-0",children:ys(new Date(r.created_at),"MMM d")})]}),r.content&&e.jsx("p",{className:"text-sm text-slate-500 mt-1 leading-relaxed",children:r.content}),r.video_url&&e.jsx("div",{className:"mt-3 rounded-xl overflow-hidden bg-slate-900 aspect-video",children:e.jsx("iframe",{src:s(r.video_url)||r.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:r.title})})]})]})},r.id))})]})}function Gkt({portal:t,dealData:s,agentProfile:r,customQuestions:n,deviceFingerprint:a,onComplete:o}){var b,w;const[l,i]=C.useState({first_name:((b=t.client_name)==null?void 0:b.split(" ")[0])||"",last_name:((w=t.client_name)==null?void 0:w.split(" ").slice(1).join(" "))||"",email:t.client_email||"",phone:t.client_phone||"",preferred_contact_method:"email",client_role:"buyer",notes:"",spouse_first_name:"",spouse_last_name:"",spouse_email:"",spouse_phone:""}),[d,u]=C.useState({}),[p,f]=C.useState(!1),y=Dt({mutationFn:async()=>{const{error:j}=await G.from("portal_onboarding_submissions").insert({portal_id:t.id,first_name:l.first_name,last_name:l.last_name||null,email:l.email||null,phone:l.phone||null,preferred_contact_method:l.preferred_contact_method,client_role:l.client_role,notes:l.notes||null,device_fingerprint:a,custom_answers:Object.keys(d).length>0?d:null,spouse_first_name:p&&l.spouse_first_name||null,spouse_last_name:p&&l.spouse_last_name||null,spouse_email:p&&l.spouse_email||null,spouse_phone:p&&l.spouse_phone||null});if(j)throw j},onSuccess:o,onError:j=>{console.error("[PortalOnboarding] Submit failed:",j),fe.error("Something went wrong. Please try again.")}}),_=s!=null&&s.property_address?`${s.property_address}, ${s.city||""}, ${s.state||""}`:null;return e.jsxs("div",{className:"max-w-md mx-auto px-4 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[(r==null?void 0:r.avatar_url)&&e.jsx("img",{src:r.avatar_url,alt:r.name,className:"w-14 h-14 rounded-full border-2 border-slate-200 mx-auto mb-3 object-cover"}),e.jsx("h1",{className:"text-xl font-bold text-slate-800",children:"Welcome to Your Portal"}),_&&e.jsxs("div",{className:"flex items-center justify-center gap-1 text-slate-500 text-sm mt-1",children:[e.jsx(Oi,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:_.replace(/,\s*,/g,",").replace(/,\s*$/,"")})]}),e.jsx("p",{className:"text-sm text-slate-500 mt-2",children:"Please fill in your details to access your transaction portal."})]}),e.jsxs("form",{onSubmit:j=>{j.preventDefault(),y.mutate()},className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"First Name *"}),e.jsx(Re,{required:!0,value:l.first_name,onChange:j=>i(k=>({...k,first_name:j.target.value})),className:"mt-1 rounded-xl",placeholder:"John"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(Re,{value:l.last_name,onChange:j=>i(k=>({...k,last_name:j.target.value})),className:"mt-1 rounded-xl",placeholder:"Doe"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(Re,{type:"email",value:l.email,onChange:j=>i(k=>({...k,email:j.target.value})),className:"mt-1 rounded-xl",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(Re,{type:"tel",value:l.phone,onChange:j=>i(k=>({...k,phone:j.target.value})),className:"mt-1 rounded-xl",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Preferred Contact Method"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:[{value:"email",label:"Email"},{value:"call",label:"Phone"},{value:"text",label:"Text"}].map(j=>e.jsx("button",{type:"button",onClick:()=>i(k=>({...k,preferred_contact_method:j.value})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.preferred_contact_method===j.value?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:j.label},j.value))})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Your Role"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:["buyer","seller","both"].map(j=>e.jsx("button",{type:"button",onClick:()=>i(k=>({...k,client_role:j})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.client_role===j?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:j.charAt(0).toUpperCase()+j.slice(1)},j))})]}),n.map(j=>e.jsxs("div",{children:[e.jsxs(ve,{className:"text-xs text-slate-600",children:[j.question_text," ",j.is_required&&"*"]}),j.field_type==="text"&&e.jsx(Re,{required:j.is_required,value:d[j.id]||"",onChange:k=>u(S=>({...S,[j.id]:k.target.value})),className:"mt-1 rounded-xl"}),j.field_type==="textarea"&&e.jsx("textarea",{required:j.is_required,value:d[j.id]||"",onChange:k=>u(S=>({...S,[j.id]:k.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[80px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),j.field_type==="dropdown"&&e.jsxs("select",{required:j.is_required,value:d[j.id]||"",onChange:k=>u(S=>({...S,[j.id]:k.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm h-10",children:[e.jsx("option",{value:"",children:"Select..."}),(j.options||[]).map(k=>e.jsx("option",{value:k,children:k},k))]}),j.field_type==="toggle"&&e.jsx("div",{className:"mt-1.5 flex gap-2",children:["Yes","No"].map(k=>e.jsx("button",{type:"button",onClick:()=>u(S=>({...S,[j.id]:k})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${d[j.id]===k?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200"}`,children:k},k))})]},j.id)),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Notes for your agent"}),e.jsx("textarea",{value:l.notes,onChange:j=>i(k=>({...k,notes:j.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Anything you'd like your agent to know..."})]}),t.allow_spouse&&e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>f(!p),className:"text-sm text-blue-600 hover:text-blue-700 font-medium",children:p?"− Remove spouse/partner":"+ Add spouse/partner"}),p&&e.jsxs("div",{className:"mt-3 p-4 bg-slate-50 rounded-xl space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"First Name"}),e.jsx(Re,{value:l.spouse_first_name,onChange:j=>i(k=>({...k,spouse_first_name:j.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(Re,{value:l.spouse_last_name,onChange:j=>i(k=>({...k,spouse_last_name:j.target.value})),className:"mt-1 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(Re,{type:"email",value:l.spouse_email,onChange:j=>i(k=>({...k,spouse_email:j.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(Re,{type:"tel",value:l.spouse_phone,onChange:j=>i(k=>({...k,spouse_phone:j.target.value})),className:"mt-1 rounded-xl"})]})]})]}),e.jsx(K,{type:"submit",disabled:y.isPending||!l.first_name,className:"w-full h-12 rounded-full text-sm font-semibold bg-slate-900 hover:bg-slate-800",children:y.isPending?"Submitting...":"Access My Portal"})]})]})}function Kkt(t){return t==="buy-side"?"Home Search in Progress":t==="listing"?"Your Home Is On The Market":"Active Phase"}function Zkt(t){return t==="buy-side"?"We're actively searching for homes that match your criteria.":t==="listing"?"Your property is now being marketed to potential buyers.":"Your transaction is actively moving forward."}const Ykt={Lead:{label:"Getting Started",description:"We're beginning your home journey and preparing the next steps."},Consultation:{label:"Planning Your Move",description:"We're discussing your goals and building a plan for buying or selling."},"Agreement Signed":{label:"Officially Working Together",description:"We've signed the agreement and are moving forward together."},"Under Contract":{label:"Under Contract",description:"Your offer has been accepted and we are now moving through inspections and due diligence."},Closing:{label:"Final Steps to Closing",description:"We're finalizing documents and preparing for closing day."},"Closed Won":{label:"Closing Day",description:"Congratulations! Your transaction is complete. 🎉"}},lUe=["Lead","Consultation","Agreement Signed","Active","Under Contract","Closing","Closed Won"];function G_e(t){return lUe.map(s=>{if(s==="Active")return{key:"Active",label:Kkt(t),description:Zkt(t)};const r=Ykt[s];return{key:s,label:r.label,description:r.description}})}function TMe(t){if(!t)return 0;const s=lUe.indexOf(t);return s>=0?s:0}function Xkt(t,s){return wt({queryKey:["client-portal-public",t],queryFn:async()=>{if(!t)return null;const{data:r,error:n}=await G.from("client_portals").select(` *, deal_pipeline ( id, deal_name, property_address, city, state, deal_type, target_close_date, contract_date, expected_price, actual_close_date, stage_id, owner_user_id, deal_pipeline_stages (id, name, color, icon, sort_order, is_won_stage, is_lost_stage) ) `).eq("slug",t).eq("is_enabled",!0).maybeSingle();if(n)throw n;return r},enabled:s})}function Qkt(t){return wt({queryKey:["client-portal-by-id",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("client_portals").select(` *, deal_pipeline ( id, deal_name, property_address, city, state, deal_type, target_close_date, contract_date, expected_price, actual_close_date, stage_id, owner_user_id, deal_pipeline_stages (id, name, color, icon, sort_order, is_won_stage, is_lost_stage) ) `).eq("id",t).eq("is_enabled",!0).maybeSingle();if(r)throw r;return s},enabled:!!t})}function cUe({slug:t}){var te,Q,de,re,ae,le;const[s,r]=C.useState(!1),[n,a]=C.useState("primary"),[o]=C.useState(()=>{const he=`portal_fp_${t}`;let be=localStorage.getItem(he);return be||(be=localStorage.getItem("portal_fp"),be?localStorage.setItem(he,be):(be=crypto.randomUUID(),localStorage.setItem(he,be),localStorage.setItem("portal_fp",be))),be});C.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:l,isLoading:i,error:d}=Xkt(t,!0),u=l==null?void 0:l.linked_portal_id,{data:p}=Qkt(u),f=(te=l==null?void 0:l.deal_pipeline)==null?void 0:te.owner_user_id,{data:y}=wt({queryKey:["portal-stages",f],queryFn:async()=>{const{data:he,error:be}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",f).order("sort_order",{ascending:!0});if(be)throw be;return he},enabled:!!f}),{data:_}=wt({queryKey:["portal-agent",f],queryFn:async()=>{const{data:he,error:be}=await G.from("profiles").select("id, name, avatar_url, phone, email").eq("id",f).single();if(be)throw be;return he},enabled:!!f}),b=n==="linked"&&p?p:l,w=b==null?void 0:b.id,{data:j}=wt({queryKey:["portal-updates-public",w],queryFn:async()=>{const{data:he,error:be}=await G.from("portal_updates").select("*").eq("portal_id",w).order("created_at",{ascending:!1});if(be)throw be;return he},enabled:!!w}),k=(Q=b==null?void 0:b.deal_pipeline)==null?void 0:Q.id,{data:S}=wt({queryKey:["portal-documents",k],queryFn:async()=>{const{data:he,error:be}=await G.from("deal_files").select("*").eq("deal_id",k).eq("visible_on_portal",!0).order("created_at",{ascending:!1});if(be)throw be;return he},enabled:!!k}),T=l==null?void 0:l.id,{data:I,isLoading:L}=wt({queryKey:["portal-onboarding-check",T,o],queryFn:async()=>{const{data:he,error:be}=await G.from("portal_onboarding_submissions").select("id").eq("portal_id",T).eq("device_fingerprint",o).maybeSingle();if(be)throw be;return he},enabled:!!T&&!!(l!=null&&l.require_onboarding)}),{data:R}=wt({queryKey:["portal-custom-questions-public",f],queryFn:async()=>{const{data:he,error:be}=await G.from("portal_custom_questions").select("*").eq("owner_user_id",f).eq("is_active",!0).order("sort_order",{ascending:!0});if(be)throw be;return he},enabled:!!f&&!!(l!=null&&l.require_onboarding)}),$=!!I||s||!(l!=null&&l.require_onboarding);if(i||l!=null&&l.require_onboarding&&L)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-lg mx-auto p-6 space-y-6",children:[e.jsx(xs,{className:"h-48 w-full rounded-2xl"}),e.jsx(xs,{className:"h-10 w-48 mx-auto"}),e.jsx(xs,{className:"h-32 w-full rounded-2xl"}),e.jsx(xs,{className:"h-24 w-full rounded-2xl"})]})});if(d||!l)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("span",{className:"text-2xl",children:"🔒"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Portal Not Available"}),e.jsx("p",{className:"text-slate-500",children:"This portal is no longer active or doesn't exist."})]})});if(!$){const he=l==null?void 0:l.deal_pipeline;return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:e.jsx(Gkt,{portal:l,dealData:he,agentProfile:_,customQuestions:R||[],deviceFingerprint:o,onComplete:()=>r(!0)})})}const q=(de=l==null?void 0:l.deal_pipeline)==null?void 0:de.deal_type,U=(re=p==null?void 0:p.deal_pipeline)==null?void 0:re.deal_type,H=!!p,Y=he=>he==="listing"?"Your Sale":he==="buy-side"?"Your Purchase":"Transaction",se=he=>he==="listing"?e.jsx(On,{className:"w-3.5 h-3.5"}):e.jsx(Dm,{className:"w-3.5 h-3.5"});return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white pb-12",children:[e.jsx(Fkt,{dealData:b==null?void 0:b.deal_pipeline,agentProfile:_,welcomeMessage:b==null?void 0:b.welcome_message,isWon:(le=(ae=b==null?void 0:b.deal_pipeline)==null?void 0:ae.deal_pipeline_stages)==null?void 0:le.is_won_stage}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 space-y-5 mt-6",children:[H&&e.jsxs("div",{className:"flex gap-1 bg-slate-100 rounded-xl p-1",children:[e.jsxs("button",{onClick:()=>a("primary"),className:`flex-1 flex items-center justify-center gap-1.5 rounded-lg py-2.5 text-sm font-medium transition-all ${n==="primary"?"bg-white text-slate-800 shadow-sm":"text-slate-500 hover:text-slate-700"}`,children:[se(q),Y(q)]}),e.jsxs("button",{onClick:()=>a("linked"),className:`flex-1 flex items-center justify-center gap-1.5 rounded-lg py-2.5 text-sm font-medium transition-all ${n==="linked"?"bg-white text-slate-800 shadow-sm":"text-slate-500 hover:text-slate-700"}`,children:[se(U),Y(U)]})]}),e.jsx(Jkt,{portal:b,updates:j,documents:S}),e.jsxs("div",{className:"text-center pt-6 pb-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-slate-400",children:[e.jsx(ih,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-xs",children:"Secure Client Portal"})]}),_&&e.jsxs("p",{className:"text-xs text-slate-400",children:["Managed by ",e.jsx("span",{className:"font-medium text-slate-500",children:_.name})]}),e.jsx("p",{className:"text-[10px] text-slate-300",children:"Powered by ReLevelUp"})]})]})]})}function Jkt({portal:t,updates:s,documents:r}){const n=t,a=n==null?void 0:n.deal_pipeline,o=a==null?void 0:a.deal_pipeline_stages,l=o==null?void 0:o.is_won_stage,i=a==null?void 0:a.deal_type,d=t.stage_mapping;let u=G_e(i);d&&d.length>0&&(u=d.map((_,b)=>{var w,j;return{key:`custom-${b}`,label:_.label||((w=u[b])==null?void 0:w.label)||`Stage ${b+1}`,description:_.description||((j=u[b])==null?void 0:j.description)||"",video_url:_.video_url||void 0}}));const p=d&&d.length>0?Math.min(TMe(o==null?void 0:o.name),u.length-1):TMe(o==null?void 0:o.name),f=u[p],y=f==null?void 0:f.video_url;return e.jsxs(e.Fragment,{children:[e.jsx(Bkt,{targetCloseDate:a==null?void 0:a.target_close_date,actualCloseDate:a==null?void 0:a.actual_close_date,clientName:t.client_name}),e.jsx(zkt,{journeyStages:u,currentIndex:p}),f&&e.jsx($kt,{currentStage:f,nextStepText:t.next_step_text,nextStepVideoUrl:y||t.next_step_video_url}),e.jsx(Vkt,{targetCloseDate:a==null?void 0:a.target_close_date,contractDate:a==null?void 0:a.contract_date,inspectionDate:t.inspection_date,appraisalDate:t.appraisal_date,actualCloseDate:a==null?void 0:a.actual_close_date}),r&&r.length>0&&e.jsx(Hkt,{documents:r}),s&&s.length>0&&e.jsx(Wkt,{updates:s}),l&&t.show_post_close_tips&&e.jsxs("div",{className:"bg-gradient-to-br from-emerald-50 to-teal-50 rounded-2xl p-6 border border-emerald-100 text-center",children:[e.jsx("span",{className:"text-4xl mb-3 block",children:"🎉"}),e.jsx("h3",{className:"text-lg font-bold text-emerald-900 mb-2",children:"Congratulations!"}),e.jsx("p",{className:"text-sm text-emerald-700",children:"Your transaction has been completed. Welcome to your new home!"}),t.review_url&&e.jsx("a",{href:t.review_url,target:"_blank",rel:"noopener noreferrer",className:"mt-4 inline-block bg-emerald-600 text-white text-sm font-medium px-6 py-2.5 rounded-full hover:bg-emerald-700 transition-colors",children:"Leave a Review ⭐"})]})]})}function eSt(){const s=bu().pathname.slice(1);return C.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>{document.body.classList.remove("client-portal-page")}),[]),!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Client Portal"}),e.jsx("p",{className:"text-slate-500",children:"Visit your personalized portal link to view your transaction details."})]})}):e.jsx(cUe,{slug:s})}const wxe="levelup_affiliate_ref",tSt=30,sSt=()=>{const[t]=Pc();C.useEffect(()=>{const s=t.get("ref");if(s){const r={code:s.toUpperCase(),timestamp:Date.now()};localStorage.setItem(wxe,JSON.stringify(r)),console.log("[Affiliate] Stored referral code:",s)}},[t])},rSt=()=>{try{const t=localStorage.getItem(wxe);if(!t)return null;const s=JSON.parse(t),r=tSt*24*60*60*1e3;return Date.now()-s.timestamp>r?(localStorage.removeItem(wxe),console.log("[Affiliate] Referral code expired"),null):s.code}catch{return null}},qne="/assets/levelup-logo-header-_ZX7DvlA.png",nSt="/assets/scale-your-team-ku4MPatU.png";function aSt({open:t,onOpenChange:s}){return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Ss,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-[#4a6b6d]/10 rounded-lg",children:e.jsx(Ta,{className:"h-5 w-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(ks,{children:"Schedule a Brokerage Interest Meeting"}),e.jsx(Kr,{children:"Learn how LevelUp can empower your entire team"})]})]})}),t&&e.jsx("iframe",{src:"https://tidycal.com/jeremycollins/brokerinterestmeeting",className:"w-full border-0 rounded-lg",style:{height:"600px",minHeight:"500px"},title:"Schedule Brokerage Interest Meeting"})]})})}const au={individual_agent:{name:"Individual Agent",price:"$39",period:"/month",description:"Perfect for independent agents ready to level up",features:["Full dashboard access","300+ professional templates","Academy training library","Community & networking","Live events & workshops","Social media content","Newsletter resources","Email support"],trial:"7-day free trial"},brokerage_under_25:{name:"Brokerage",subtitle:"Under 25 Agents",price:"$299",period:"/month",description:"Empower your entire team to succeed",features:["Everything in Individual","Brokerage manager dashboard","Invite & manage up to 25 agents","Exclusive brokerage resources","Team performance analytics","Agent onboarding tools","Resource sharing","Priority support"]},brokerage_over_25:{name:"Brokerage",subtitle:"Over 25 Agents",price:"$499",period:"/month",description:"Scale your brokerage without limits",features:["Everything in Brokerage","Unlimited agents","Advanced team analytics","Dedicated account manager","Custom onboarding sessions","White-glove support"]}},iSt=[{icon:bm,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:Bl,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:on,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:xc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:In,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:po,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],oSt=[{icon:hr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:hn,title:"Smart Touchpoint Plans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Qn,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:zu,title:"Birthday & Anniversary Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Oi,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:ol,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Si,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Fm,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],lSt=[{name:"Sarah M.",role:"Top Producer, RE/MAX",quote:"LevelUp completely transformed how I run my business. The templates alone save me hours every week."},{name:"Mike T.",role:"Brokerage Owner",quote:"Onboarding new agents used to take weeks. Now they're productive from day one with all the training resources."},{name:"Jessica L.",role:"Team Lead",quote:"The community is incredible. I've learned more from other agents here than any conference I've attended."}],cSt=()=>{const{user:t,loading:s}=Hs(),r=Pr(),[n]=Pc();C.useEffect(()=>{const $=window.location.host==="listings.relevelup.com",q=window.location.pathname==="/";if($&&q){r("/public/listings",{replace:!0});return}},[r]);const[a,o]=C.useState(null),[l,i]=C.useState(null),[d,u]=C.useState(!1),[p,f]=C.useState(""),[y,_]=C.useState(""),[b,w]=C.useState(""),[j,k]=C.useState(!1),[S,T]=C.useState(!1),I=($,q=!1)=>{i({tier:$,skipTrial:q}),u(!0)};sSt(),C.useEffect(()=>{const $=window.location.host==="listings.relevelup.com",q=location.pathname.startsWith("/public/");!s&&t&&!$&&!q&&r("/dashboard")},[t,s,r,location.pathname]),C.useEffect(()=>{n.get("canceled")==="true"&&fe.error("Checkout was canceled. Feel free to try again when you're ready!")},[n]);const L=async($,q=!1)=>{if(!p){fe.error("Please enter your email address");return}if(!y.trim()){fe.error("Please enter your full name");return}k(!0),o($+(q?"_direct":""));const U=rSt();try{const{data:H,error:Y}=await G.functions.invoke("create-checkout",{body:{tier:$,email:p,name:y.trim(),couponCode:b.trim()||void 0,skipTrial:q,referralCode:U}});if(Y)throw Y;if(H!=null&&H.url)window.open(H.url,"_blank","noopener,noreferrer"),fe.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(H){console.error("Checkout error:",H),fe.error(H.message||"Failed to start checkout. Please try again.")}finally{k(!1),o(null),u(!1),i(null)}},R=()=>{l&&L(l.tier,l.skipTrial)};return s?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[#4a6b6d]",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-white border-t-transparent"})}):e.jsxs("div",{className:"min-h-screen bg-background overflow-hidden",children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 bg-[#4a6b6d] shadow-md",children:e.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("img",{src:qne,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var $;return($=document.getElementById("features"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},children:"Pricing"}),e.jsx(K,{onClick:()=>r("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})]})}),e.jsxs("section",{className:"relative pt-24 pb-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-8",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsx("img",{alt:"LevelUp Consulting Group",className:"h-[136px] md:h-[164px] drop-shadow-lg",src:"/lovable-uploads/3a0c7ef9-9e79-411f-a9af-6f2a99e8bd7b.webp"})}),e.jsxs("p",{className:"text-lg text-white/80 max-w-3xl mx-auto leading-relaxed font-sans font-bold md:text-4xl",children:["The tools you need to get it done.",e.jsx("br",{}),e.jsx("em",{children:"The platform you need to keep it going."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center items-center pt-4",children:[e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("free-trial"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"px-8 py-7 text-lg font-semibold bg-white text-[#1e3a4c] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 group rounded-full",children:["Start Your Free Trial",e.jsx($i,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]}),e.jsx(K,{size:"lg",variant:"outline",onClick:()=>{var $;return($=document.getElementById("features"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"px-8 py-7 text-lg font-semibold border-2 border-white text-white bg-transparent hover:bg-white hover:text-[#1e3a4c] rounded-full",children:"See What's Included"})]})]})})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl md:text-5xl leading-tight font-sans font-semibold text-secondary",children:"We help brokerages and agents grow with training, tools, and built-in execution."}),e.jsxs("div",{className:"space-y-2 text-lg text-muted-foreground",children:[e.jsx("p",{children:"Agents get weekly coaching + plug-and-play marketing."}),e.jsx("p",{children:"Brokerages get higher adoption, consistency, and real engagement."})]}),e.jsx("p",{className:"text-2xl md:text-4xl text-[#4a6b6d] pt-4 font-sans font-bold",children:"LEVELUP EQUIPS BOTH TO THRIVE."}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Learn how we support agents and empower brokerages to grow—together."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center pt-4",children:[e.jsxs(K,{size:"lg",variant:"outline",onClick:()=>{var $;return($=document.getElementById("brokerage"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/5",children:[e.jsx(Ta,{className:"mr-2 h-5 w-5"}),"Brokerage Partnership"]}),e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:[e.jsx(Yi,{className:"mr-2 h-5 w-5"}),"Individual Membership"]})]})]})})}),e.jsx("section",{id:"features",className:"py-20 bg-muted/30",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl mb-6 font-sans font-bold",children:"What's inside our members only portal?"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Everything you need to grow your business, all in one place."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 max-w-6xl mx-auto",children:iSt.map(($,q)=>e.jsxs(Ee,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(It,{children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:e.jsx($.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(Ot,{className:"text-xl font-sans",children:$.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:$.description})})]},q))})]})}),e.jsxs("section",{id:"agent-os",className:"py-20 bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs("div",{className:"container mx-auto px-4 relative",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium mb-6",children:[e.jsx(hn,{className:"w-4 h-4"}),"Included with Membership"]}),e.jsxs("h2",{className:"text-3xl mb-6 text-white font-sans font-bold md:text-6xl",children:["Meet ",e.jsx("span",{className:"italic",children:"Agent OS"})]}),e.jsx("p",{className:"text-lg text-white/80",children:"Your relationship-first operating system. Never forget a follow-up, track every touchpoint, and turn your sphere into a referral machine."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 max-w-6xl mx-auto",children:oSt.map(($,q)=>e.jsxs(Ee,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(It,{className:"pb-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-white/20 flex items-center justify-center mb-3",children:e.jsx($.icon,{className:"w-6 h-6 text-white"})}),e.jsx(Ot,{className:"text-lg font-semibold text-white",children:$.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:$.description})})]},q))}),e.jsx("div",{className:"text-center mt-12",children:e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-white text-[#4a6b6d] hover:bg-white/90 shadow-xl transition-all hover:scale-105",children:["Get Agent OS with Your Membership",e.jsx($i,{className:"ml-2 w-5 h-5"})]})})]})]}),e.jsx("section",{id:"brokerage",className:"py-20 bg-[#4a6b6d]/5",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsx("div",{className:"max-w-6xl mx-auto",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-12 items-center",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-[#4a6b6d]/10 text-[#4a6b6d] text-sm font-medium",children:[e.jsx(Ta,{className:"w-4 h-4"}),"For Brokerages"]}),e.jsxs("h2",{className:"text-3xl font-sans font-bold md:text-6xl",children:["Empower Your"," ",e.jsx("span",{className:"italic text-[#4a6b6d]",children:"Entire Team"})]}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Give every agent on your team access to world-class training and resources. Track performance, streamline onboarding, and watch your brokerage thrive."}),e.jsx("ul",{className:"space-y-4",children:["Dedicated brokerage manager dashboard","Invite and manage agents with one click","Exclusive brokerage-only resources","Team analytics and performance tracking","Simplified agent onboarding","Share resources across your team"].map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center flex-shrink-0",children:e.jsx(ha,{className:"w-4 h-4 text-[#4a6b6d]"})}),e.jsx("span",{className:"text-foreground",children:$})]},q))}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-4",children:[e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["See Brokerage Plans",e.jsx(Ua,{className:"ml-2 w-5 h-5"})]}),e.jsxs(K,{size:"lg",variant:"outline",onClick:()=>T(!0),className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/10",children:[e.jsx(on,{className:"mr-2 w-5 h-5"}),"Schedule Info Session"]})]})]}),e.jsx("div",{className:"relative hidden md:block",children:e.jsx("img",{src:nSt,alt:"Scale Your Team from 5 to 500 Agents",className:"w-full rounded-3xl shadow-lg"})})]})})})}),e.jsx("section",{className:"py-20 bg-background",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsxs("h2",{className:"text-3xl mb-6 font-sans md:text-5xl font-bold",children:["Agents Love ",e.jsx("span",{className:"italic text-[#4a6b6d]",children:"LevelUp"})]}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"See what top producers are saying about the platform."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 max-w-6xl mx-auto",children:lSt.map(($,q)=>e.jsx(Ee,{className:"bg-muted/30 border-0",children:e.jsxs(Oe,{className:"pt-8",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(U=>e.jsx(Gn,{className:"w-5 h-5 fill-yellow-400 text-yellow-400"},U))}),e.jsxs("p",{className:"text-lg mb-6 italic text-muted-foreground",children:['"',$.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:$.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:$.role})]})]})},q))})]})}),e.jsxs("section",{id:"free-trial",className:"py-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-8",children:[e.jsxs("h2",{className:"text-3xl md:text-5xl font-bold text-white",children:["Start Your Free Trial ",e.jsx("span",{className:"italic",children:"Today"})]}),e.jsx("p",{className:"text-lg md:text-xl text-white/80 leading-relaxed",children:"Get instant access to 7 days of trainings, templates, and tools — designed to give you quick wins now and resources you'll keep forever."}),e.jsx("div",{className:"pt-4",children:e.jsxs(K,{size:"lg",className:"px-12 py-7 text-lg font-semibold bg-white text-[#4a6b6d] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 group rounded-full",onClick:()=>I("individual_agent"),children:["Start Free Trial",e.jsx($i,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]})})]})})]}),e.jsx("section",{id:"pricing",className:"py-20 bg-muted/30",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("h2",{className:"text-3xl mb-6 font-sans md:text-5xl font-bold",children:["Simple, Transparent ",e.jsx("span",{className:"italic text-[#4a6b6d]",children:"Pricing"})]}),e.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:"Choose the plan that fits your needs. All plans include everything you need to succeed."})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8 max-w-6xl mx-auto",children:[e.jsxs(Ee,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(It,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(Yi,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsx(Ot,{className:"text-xl font-sans",children:au.individual_agent.name})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:au.individual_agent.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:au.individual_agent.period})]}),e.jsx(pr,{className:"text-base mt-2",children:au.individual_agent.description}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-green-500/10 text-green-600 text-sm font-medium mt-4",children:[e.jsx(Tn,{className:"w-4 h-4"}),au.individual_agent.trial]})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:au.individual_agent.features.map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ha,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},q))})}),e.jsxs(QP,{className:"flex flex-col gap-3 pt-4",children:[e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("individual_agent"),children:"Start Free Trial"}),e.jsx(K,{variant:"outline",className:"w-full rounded-full border-2 border-[#4a6b6d] text-[#4a6b6d] bg-white hover:bg-[#4a6b6d]/5 uppercase text-sm font-medium tracking-wide",onClick:()=>I("individual_agent",!0),children:"Skip Trial, Subscribe Now"})]})]}),e.jsxs(Ee,{className:"relative flex flex-col border-2 border-[#4a6b6d] shadow-2xl scale-105 bg-background",children:[e.jsx("div",{className:"absolute -top-4 left-1/2 -translate-x-1/2 px-6 py-2 bg-[#4a6b6d] text-white text-sm font-semibold rounded-full shadow-lg",children:"Most Popular"}),e.jsxs(It,{className:"pb-4 pt-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/20 flex items-center justify-center",children:e.jsx(Ta,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-xl font-sans",children:au.brokerage_under_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:au.brokerage_under_25.subtitle})]})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:au.brokerage_under_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:au.brokerage_under_25.period})]}),e.jsx(pr,{className:"text-base mt-2",children:au.brokerage_under_25.description})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:au.brokerage_under_25.features.map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ha,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},q))})}),e.jsx(QP,{className:"pt-4",children:e.jsx(K,{className:"w-full py-6 text-lg shadow-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("brokerage_under_25"),children:"Get Started"})})]}),e.jsxs(Ee,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(It,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(Ta,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-xl font-sans",children:au.brokerage_over_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:au.brokerage_over_25.subtitle})]})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:au.brokerage_over_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:au.brokerage_over_25.period})]}),e.jsx(pr,{className:"text-base mt-2",children:au.brokerage_over_25.description})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:au.brokerage_over_25.features.map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ha,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},q))})}),e.jsx(QP,{className:"pt-4",children:e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("brokerage_over_25"),children:"Get Started"})})]})]})]})}),e.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl text-white font-sans md:text-5xl",children:"Ready to Level Up?"}),e.jsx("p",{className:"text-lg text-white/80 max-w-2xl mx-auto",children:"Join thousands of agents who are closing more deals, saving time, and growing their business with LevelUp."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"px-10 py-7 text-lg font-semibold bg-white text-[#4a6b6d] hover:bg-white/90 shadow-2xl transition-all hover:scale-105",children:["Start Your Free Trial",e.jsx($i,{className:"ml-2 w-5 h-5"})]}),e.jsx(K,{size:"lg",onClick:()=>r("/auth"),className:"px-10 py-7 text-lg font-semibold border-2 border-white text-white bg-transparent hover:bg-white hover:text-[#4a6b6d]",children:"Sign In"})]})]})})]}),e.jsx("footer",{className:"py-12 bg-[#3d5a5c] text-white/80",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsx("img",{src:qne,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm",children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx("a",{href:"/privacy-policy",className:"text-white/60 hover:text-white transition-colors text-sm",children:"Privacy Policy"}),e.jsx("a",{href:"mailto:support@relevelup.com",className:"text-white/60 hover:text-white transition-colors text-sm",children:"Contact Support"})]})]})})}),e.jsx(aSt,{open:S,onOpenChange:T}),e.jsx(_s,{open:d,onOpenChange:u,children:e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsx(ks,{className:"text-xl font-sans font-semibold",children:"Enter your details to get started"}),e.jsx(Kr,{children:(l==null?void 0:l.tier)==="individual_agent"&&!(l!=null&&l.skipTrial)?"Start your 7-day free trial":(l==null?void 0:l.tier)==="individual_agent"?"Subscribe to Individual Agent":(l==null?void 0:l.tier)==="brokerage_under_25"?"Subscribe to Brokerage (Under 25 Agents)":"Subscribe to Brokerage (Over 25 Agents)"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsxs(ve,{htmlFor:"dialog-name",children:["Full Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Re,{id:"dialog-name",type:"text",placeholder:"John Smith",value:y,onChange:$=>_($.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(ve,{htmlFor:"dialog-email",children:["Email Address ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Re,{id:"dialog-email",type:"email",placeholder:"you@example.com",value:p,onChange:$=>f($.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(ve,{htmlFor:"dialog-coupon",children:["Discount Code ",e.jsx("span",{className:"text-muted-foreground",children:"(Optional)"})]}),e.jsx(Re,{id:"dialog-coupon",type:"text",placeholder:"Enter discount code",value:b,onChange:$=>w($.target.value),className:"mt-1"})]})]}),e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:R,disabled:j,children:j?"Loading...":"Continue to Checkout"})]})})]})},dSt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(lh,{children:[e.jsx("title",{children:"Privacy Policy | LevelUp"}),e.jsx("meta",{name:"description",content:"Privacy Policy for LevelUp platform"})]}),e.jsx("div",{className:"min-h-screen bg-background py-12 px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-8",children:"Privacy Policy"}),e.jsxs("div",{className:"prose prose-sm max-w-none text-muted-foreground space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last updated: January 17, 2026"}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"1. Introduction"}),e.jsx("p",{children:'Welcome to LevelUp ("we," "our," or "us"). We are committed to protecting your personal information and your right to privacy. This Privacy Policy explains how we collect, use, disclose, and safeguard your information when you use our platform.'})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"2. Information We Collect"}),e.jsx("p",{children:"We collect information that you provide directly to us, including:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Name and contact information (email address, phone number)"}),e.jsx("li",{children:"Account credentials"}),e.jsx("li",{children:"Profile information"}),e.jsx("li",{children:"Transaction and billing information"}),e.jsx("li",{children:"Communications you send to us"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"3. How We Use Your Information"}),e.jsx("p",{children:"We use the information we collect to:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Provide, maintain, and improve our services"}),e.jsx("li",{children:"Process transactions and send related information"}),e.jsx("li",{children:"Send you technical notices and support messages"}),e.jsx("li",{children:"Respond to your comments and questions"}),e.jsx("li",{children:"Communicate with you about products, services, and events"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"4. Information Sharing"}),e.jsx("p",{children:"We do not sell, trade, or otherwise transfer your personal information to third parties without your consent, except as described in this policy or as required by law."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"5. Data Security"}),e.jsx("p",{children:"We implement appropriate technical and organizational measures to protect the security of your personal information. However, no method of transmission over the Internet is 100% secure."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"6. Your Rights"}),e.jsx("p",{children:"You have the right to:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Access your personal information"}),e.jsx("li",{children:"Correct inaccurate data"}),e.jsx("li",{children:"Request deletion of your data"}),e.jsx("li",{children:"Opt-out of marketing communications"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"7. Third-Party Services"}),e.jsx("p",{children:"Our platform may integrate with third-party services such as Facebook and Instagram for social media posting features. When you connect these accounts, you are subject to their respective privacy policies."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"8. Contact Us"}),e.jsxs("p",{children:["If you have questions about this Privacy Policy, please contact us at"," ",e.jsx("a",{href:"mailto:support@relevelup.com",className:"text-primary hover:underline",children:"support@relevelup.com"})]})]})]})]})})]}),uSt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(lh,{children:[e.jsx("title",{children:"Terms of Service | LevelUp"}),e.jsx("meta",{name:"description",content:"Terms of Service for LevelUp platform"})]}),e.jsx("div",{className:"min-h-screen bg-background py-12 px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-8",children:"Terms of Service"}),e.jsxs("div",{className:"prose prose-sm max-w-none text-muted-foreground space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last updated: January 17, 2026"}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"1. Acceptance of Terms"}),e.jsx("p",{children:'By accessing or using the LevelUp platform ("Service"), you agree to be bound by these Terms of Service. If you do not agree to these terms, please do not use our Service.'})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"2. Description of Service"}),e.jsx("p",{children:"LevelUp provides a platform for real estate professionals to access training, resources, marketing tools, and community features. We reserve the right to modify or discontinue the Service at any time."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"3. User Accounts"}),e.jsx("p",{children:"To use certain features, you must create an account. You agree to:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Provide accurate and complete information"}),e.jsx("li",{children:"Maintain the security of your account credentials"}),e.jsx("li",{children:"Notify us immediately of any unauthorized access"}),e.jsx("li",{children:"Accept responsibility for all activities under your account"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"4. Acceptable Use"}),e.jsx("p",{children:"You agree not to:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Violate any applicable laws or regulations"}),e.jsx("li",{children:"Infringe on the rights of others"}),e.jsx("li",{children:"Upload malicious code or interfere with the Service"}),e.jsx("li",{children:"Attempt to gain unauthorized access to any part of the Service"}),e.jsx("li",{children:"Use the Service for any unlawful purpose"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"5. Intellectual Property"}),e.jsx("p",{children:"The Service and its original content, features, and functionality are owned by LevelUp and are protected by international copyright, trademark, and other intellectual property laws."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"6. Third-Party Integrations"}),e.jsx("p",{children:"Our Service may integrate with third-party platforms such as Facebook and Instagram. Your use of these integrations is subject to the terms and policies of those third parties. We are not responsible for the content or practices of any third-party services."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"7. Payment Terms"}),e.jsx("p",{children:"Certain features may require payment. By subscribing to paid features, you agree to pay all applicable fees. All payments are non-refundable unless otherwise specified."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"8. Limitation of Liability"}),e.jsx("p",{children:"To the maximum extent permitted by law, LevelUp shall not be liable for any indirect, incidental, special, consequential, or punitive damages resulting from your use of the Service."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"9. Termination"}),e.jsx("p",{children:"We may terminate or suspend your account at any time, without prior notice, for conduct that we believe violates these Terms or is harmful to other users, us, or third parties."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"10. Changes to Terms"}),e.jsx("p",{children:"We reserve the right to modify these Terms at any time. We will notify you of significant changes by posting a notice on our platform. Continued use of the Service constitutes acceptance of the modified terms."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"11. Contact Us"}),e.jsxs("p",{children:["If you have questions about these Terms, please contact us at"," ",e.jsx("a",{href:"mailto:support@relevelup.com",className:"text-primary hover:underline",children:"support@relevelup.com"})]})]})]})]})})]}),hSt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(lh,{children:[e.jsx("title",{children:"Data Deletion | LevelUp"}),e.jsx("meta",{name:"description",content:"Data deletion instructions for LevelUp platform"})]}),e.jsx("div",{className:"min-h-screen bg-background py-12 px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-8",children:"Data Deletion Instructions"}),e.jsxs("div",{className:"prose prose-sm max-w-none text-muted-foreground space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last updated: January 17, 2026"}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"How to Request Data Deletion"}),e.jsx("p",{children:"If you wish to have your data deleted from LevelUp, you can request deletion through one of the following methods:"})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Option 1: Email Request"}),e.jsxs("p",{children:["Send an email to"," ",e.jsx("a",{href:"mailto:support@relevelup.com",className:"text-primary hover:underline",children:"support@relevelup.com"})," ",'with the subject line "Data Deletion Request" and include:']}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Your full name"}),e.jsx("li",{children:"The email address associated with your account"}),e.jsx("li",{children:"A clear statement requesting deletion of your data"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Option 2: Account Settings"}),e.jsx("p",{children:"If you have an active account, you can request data deletion through your account settings:"}),e.jsxs("ol",{className:"list-decimal pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Log in to your LevelUp account"}),e.jsx("li",{children:"Navigate to your Profile settings"}),e.jsx("li",{children:"Contact support through the Support page to request account deletion"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"What Data Will Be Deleted"}),e.jsx("p",{children:"Upon a valid deletion request, we will delete:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Your account information (name, email, profile data)"}),e.jsx("li",{children:"Any content you have created or uploaded"}),e.jsx("li",{children:"Your activity history and preferences"}),e.jsx("li",{children:"Connected social media account tokens and data"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Data Retention"}),e.jsx("p",{children:"Some data may be retained for legal or legitimate business purposes, such as:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Transaction records required for financial reporting"}),e.jsx("li",{children:"Data necessary to comply with legal obligations"}),e.jsx("li",{children:"Anonymized or aggregated data that cannot identify you"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Facebook/Instagram Data"}),e.jsx("p",{children:"If you have connected your Facebook or Instagram account to LevelUp, you can also manage your data through Facebook's settings:"}),e.jsxs("ol",{className:"list-decimal pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Go to your Facebook Settings & Privacy → Settings"}),e.jsx("li",{children:'Click on "Apps and Websites"'}),e.jsx("li",{children:'Find LevelUp and click "Remove"'}),e.jsx("li",{children:"This will revoke our access to your Facebook/Instagram data"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Processing Time"}),e.jsx("p",{children:"We will process your data deletion request within 30 days of receiving it. You will receive a confirmation email once your data has been deleted."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Contact Us"}),e.jsxs("p",{children:["If you have questions about data deletion, please contact us at"," ",e.jsx("a",{href:"mailto:support@relevelup.com",className:"text-primary hover:underline",children:"support@relevelup.com"})]})]})]})]})})]}),mSt=lS({email:Jl().email("Invalid email address"),password:Jl().min(6,"Password must be at least 6 characters")}),pSt=()=>{const{signIn:t,user:s}=Hs(),r=Pr(),[n,a]=C.useState(!1),[o,l]=C.useState({}),[i,d]=C.useState(""),[u,p]=C.useState(!1),[f,y]=C.useState(!1);C.useEffect(()=>{s&&r("/dashboard")},[s,r]);const _=async w=>{w.preventDefault(),l({}),a(!0);const j=new FormData(w.currentTarget),k=j.get("email"),S=j.get("password");try{mSt.parse({email:k,password:S}),await t(k,S)}catch(T){if(T instanceof ly){const I={};T.errors.forEach(L=>{L.path[0]&&(I[L.path[0]]=L.message)}),l(I)}}finally{a(!1)}},b=async()=>{if(!i){fe.error("Please enter your email address");return}p(!0);try{const{error:w}=await G.functions.invoke("send-password-reset",{body:{email:i,redirectTo:"https://dashboard.relevelup.com/profile?reset=true"}});if(w)throw w;fe.success("Password reset email sent! Check your inbox."),y(!1),d("")}catch(w){fe.error(w.message||"Failed to send reset email")}finally{p(!1)}};return e.jsxs("div",{className:"min-h-screen relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-[#4a6b6d] via-[#3d5a5c] to-[#2a4347]",children:e.jsxs("div",{className:"absolute inset-0 opacity-30",children:[e.jsx("div",{className:"absolute top-0 left-0 w-96 h-96 bg-white/10 rounded-full blur-3xl animate-pulse"}),e.jsx("div",{className:"absolute bottom-0 right-0 w-96 h-96 bg-white/5 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-1/2 left-1/2 w-64 h-64 bg-white/5 rounded-full blur-3xl animate-pulse",style:{animationDelay:"2s"}})]})}),e.jsxs("div",{className:"relative z-10 flex flex-col min-h-screen",children:[e.jsx("header",{className:"p-6",children:e.jsxs(vo,{to:"/",className:"inline-flex items-center gap-2 text-sm text-white/80 hover:text-white transition-colors",children:[e.jsx(ti,{className:"h-4 w-4"}),"Back to Home"]})}),e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsx("div",{className:"bg-white rounded-xl p-4 shadow-2xl",children:e.jsx("img",{src:zBe,alt:"LevelUp",className:"h-12 w-auto"})})}),e.jsxs(Ee,{className:"border-0 shadow-2xl bg-white/95 backdrop-blur-sm",children:[e.jsxs(It,{className:"space-y-1 text-center pb-4",children:[e.jsx(Ot,{className:"text-3xl font-bold text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Welcome Back"}),e.jsx(pr,{className:"text-gray-600",children:"Sign in to access your dashboard"})]}),e.jsx(Oe,{children:e.jsxs("form",{onSubmit:_,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"signin-email",className:"text-gray-700",children:"Email"}),e.jsx(Re,{id:"signin-email",name:"email",type:"email",placeholder:"your@email.com",required:!0,className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"}),o.email&&e.jsx("p",{className:"text-sm text-red-600",children:o.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"signin-password",className:"text-gray-700",children:"Password"}),e.jsx(Re,{id:"signin-password",name:"password",type:"password",required:!0,className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"}),o.password&&e.jsx("p",{className:"text-sm text-red-600",children:o.password})]}),e.jsx(K,{type:"submit",className:"w-full bg-[#4a6b6d] hover:bg-[#3d5a5c] text-white font-semibold py-6 text-lg transition-all duration-200 shadow-lg hover:shadow-xl",disabled:n,children:n?"Signing in...":"Sign In"}),e.jsxs(_s,{open:f,onOpenChange:y,children:[e.jsx(Ei,{asChild:!0,children:e.jsx(K,{variant:"link",className:"w-full text-sm text-[#4a6b6d] hover:text-[#3d5a5c]",children:"Forgot password?"})}),e.jsxs(vs,{className:"bg-white",children:[e.jsxs(Ss,{children:[e.jsx(ks,{className:"text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Reset Password"}),e.jsx(Kr,{className:"text-gray-600",children:"Enter your email address and we'll send you a link to reset your password."})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"reset-email",className:"text-gray-700",children:"Email"}),e.jsx(Re,{id:"reset-email",type:"email",placeholder:"your@email.com",value:i,onChange:w=>d(w.target.value),className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"})]}),e.jsx(K,{onClick:b,className:"w-full bg-[#4a6b6d] hover:bg-[#3d5a5c] text-white",disabled:u,children:u?"Sending...":"Send Reset Link"})]})]})]})]})})]}),e.jsxs("p",{className:"text-center text-white/70 text-sm mt-6",children:["Don't have an account?"," ",e.jsx(vo,{to:"/",className:"text-white hover:underline font-medium",children:"View Plans"})]})]})})]})]})},fSt=()=>{const[t]=Pc(),s=t.get("tier"),r=s==null?void 0:s.includes("brokerage");return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Ee,{className:"max-w-lg w-full",children:[e.jsxs(It,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-green-500/10 flex items-center justify-center mb-4",children:e.jsx(hi,{className:"w-10 h-10 text-green-500"})}),e.jsx(Ot,{className:"text-2xl",children:"Welcome to LevelUp!"}),e.jsx(pr,{className:"text-lg",children:"Your subscription has been activated successfully."})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"p-4 rounded-lg bg-primary/10 border border-primary/20 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(br,{className:"w-5 h-5"}),e.jsx("span",{className:"font-semibold",children:"Check your email to sign in"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"We've sent you an email with a secure link to access your account. Click the link in your email to get started."})]}),r?e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-semibold",children:"What's next?"}),e.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"1."}),"Click the link in your email to sign in"]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"2."}),"Create and name your brokerage"]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"3."}),"Set your password and complete your profile"]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"4."}),"Start inviting agents to join your team"]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-semibold",children:"What's next?"}),e.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"1."}),"Click the link in your email to sign in"]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"2."}),"Set your password and complete your profile"]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"3."}),"Start exploring templates, training videos, and more!"]})]}),e.jsx("p",{className:"text-sm text-green-600 font-medium mt-4",children:"🎉 Your 7-day free trial has started!"})]}),e.jsx("div",{className:"p-3 rounded-lg bg-muted/50 text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Didn't receive the email? Check your spam folder or contact support."})})]})]})})},dUe=t=>{const[s,r]=C.useState(null),[n,a]=C.useState(!0);return C.useEffect(()=>{if(!t){a(!1);return}(async()=>{try{const{data:i}=await G.storage.from("avatars").list(`${t}`);if(i&&i.length>0){const{data:d}=G.storage.from("avatars").getPublicUrl(`${t}/${i[0].name}`);r(`${d.publicUrl}?t=${Date.now()}`)}else r(null)}catch(i){console.error("Error fetching avatar:",i),r(null)}finally{a(!1)}})()},[t]),{avatarUrl:s,loading:n,refreshAvatar:async()=>{if(t)try{const{data:l}=await G.storage.from("avatars").list(`${t}`);if(l&&l.length>0){const{data:i}=G.storage.from("avatars").getPublicUrl(`${t}/${l[0].name}`);r(`${i.publicUrl}?t=${Date.now()}`)}}catch(l){console.error("Error refreshing avatar:",l)}}}},uUe=async t=>{const s=new Map;return await Promise.all(t.map(async r=>{try{const{data:n}=await G.storage.from("avatars").list(`${r}`);if(n&&n.length>0){const{data:a}=G.storage.from("avatars").getPublicUrl(`${r}/${n[0].name}`);s.set(r,a.publicUrl)}}catch{}})),s},gSt=t=>{const[s,r]=C.useState({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!0});return C.useEffect(()=>{if(!t){r(a=>({...a,loading:!1}));return}(async()=>{try{const{data:a,error:o}=await G.from("profiles").select("is_trial, trial_expires_at, subscription_status, subscription_end_date").eq("id",t).single();if(o){console.error("Error fetching trial status:",o),r(d=>({...d,loading:!1}));return}const l=(a==null?void 0:a.subscription_status)==="trialing"&&(a==null?void 0:a.subscription_end_date),i=(a==null?void 0:a.is_trial)&&(a==null?void 0:a.trial_expires_at);if(l){const d=new Date().getTime(),u=new Date(a.subscription_end_date).getTime(),p=Math.ceil((u-d)/(1e3*60*60*24)),f=p<=0;r({isTrial:!0,isExpired:f,expiresAt:a.subscription_end_date,daysLeft:f?0:p,loading:!1})}else if(i){const d=new Date().getTime(),u=new Date(a.trial_expires_at).getTime(),p=Math.ceil((u-d)/(1e3*60*60*24)),f=p<=0;r({isTrial:!0,isExpired:f,expiresAt:a.trial_expires_at,daysLeft:f?0:p,loading:!1})}else r({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!1})}catch(a){console.error("Error in useTrialStatus:",a),r(o=>({...o,loading:!1}))}})()},[t]),s},hUe=()=>{const{data:t,isLoading:s}=wt({queryKey:["feature-flags"],queryFn:async()=>{const{data:n,error:a}=await G.from("feature_flags").select("*");if(a)throw a;return n}}),r=n=>{if(!t)return!1;const a=t.find(o=>o.key===n);return(a==null?void 0:a.enabled)??!1};return{flags:t,isLoading:s,isFeatureEnabled:r,isAgentOSEnabled:r("agent_os_enabled"),isInnerCircleEnabled:r("innercircle_enabled"),isMarketplaceEnabled:r("marketplace")}},AMe="community_last_seen_post_at";function xSt(){const{user:t}=Hs(),s=bu(),[r,n]=C.useState(0),[a,o]=C.useState(null);C.useEffect(()=>{if(!t)return;const i=localStorage.getItem(`${AMe}_${t.id}`);o(i)},[t]),C.useEffect(()=>{if(!t)return;(async()=>{let d=G.from("community_posts").select("id",{count:"exact",head:!0});a&&(d=d.gt("created_at",a));const{data:u}=await G.from("profiles").select("brokerage_id").eq("id",t.id).single(),{count:p,error:f}=await d;!f&&p!==null&&n(p)})()},[t,a]),C.useEffect(()=>{if(!t)return;const i=G.channel("community-new-posts").on("postgres_changes",{event:"INSERT",schema:"public",table:"community_posts"},async d=>{const u=d.new;if(u.user_id===t.id)return;const p=s.pathname==="/community";p||n(w=>w+1);const{data:f}=await G.from("profiles").select("name").eq("id",u.user_id).single(),y=(f==null?void 0:f.name)||"Someone",_=u.content.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),b=_.length>50?_.substring(0,50)+"...":_;p||fe("New Community Post",{description:`${y}: ${b}`,action:{label:"View",onClick:()=>{window.location.href="/community"}}})}).subscribe();return()=>{G.removeChannel(i)}},[t,s.pathname]);const l=C.useCallback(()=>{if(!t)return;const i=new Date().toISOString();localStorage.setItem(`${AMe}_${t.id}`,i),o(i),n(0)},[t]);return C.useEffect(()=>{s.pathname==="/community"&&r>0&&l()},[s.pathname,r,l]),{unreadCount:r,markAsRead:l}}function ySt(){const{isAdmin:t}=Hs(),{data:s=0}=wt({queryKey:["wishlist-open-count"],queryFn:async()=>{const{count:r,error:n}=await G.from("wishlist_items").select("*",{count:"exact",head:!0}).eq("status","open");if(n)throw n;return r||0},enabled:t,staleTime:6e4});return{openCount:t?s:0}}const MM=Ioe,K_e=e_e,vSt=Loe,mUe=C.forwardRef(({className:t,...s},r)=>e.jsx(wM,{className:Pt("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:r}));mUe.displayName=wM.displayName;const _St=nS("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),cS=C.forwardRef(({side:t="right",className:s,children:r,...n},a)=>e.jsxs(vSt,{children:[e.jsx(mUe,{}),e.jsxs(jM,{ref:a,className:Pt(_St({side:t}),s),...n,children:[r,e.jsxs(LL,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(Ur,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));cS.displayName=jM.displayName;const TM=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col space-y-2 text-center sm:text-left",t),...s});TM.displayName="SheetHeader";const AM=C.forwardRef(({className:t,...s},r)=>e.jsx(PL,{ref:r,className:Pt("text-lg font-semibold text-foreground",t),...s}));AM.displayName=PL.displayName;const pUe=C.forwardRef(({className:t,...s},r)=>e.jsx(IL,{ref:r,className:Pt("text-sm text-muted-foreground",t),...s}));pUe.displayName=IL.displayName;var tle="Collapsible",[bSt]=Ec(tle),[wSt,Z_e]=bSt(tle),fUe=C.forwardRef((t,s)=>{const{__scopeCollapsible:r,open:n,defaultOpen:a,disabled:o,onOpenChange:l,...i}=t,[d,u]=vu({prop:n,defaultProp:a??!1,onChange:l,caller:tle});return e.jsx(wSt,{scope:r,disabled:o,contentId:Gd(),open:d,onOpenToggle:C.useCallback(()=>u(p=>!p),[u]),children:e.jsx(Qr.div,{"data-state":X_e(d),"data-disabled":o?"":void 0,...i,ref:s})})});fUe.displayName=tle;var gUe="CollapsibleTrigger",xUe=C.forwardRef((t,s)=>{const{__scopeCollapsible:r,...n}=t,a=Z_e(gUe,r);return e.jsx(Qr.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":X_e(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:s,onClick:Mr(t.onClick,a.onOpenToggle)})});xUe.displayName=gUe;var Y_e="CollapsibleContent",yUe=C.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Z_e(Y_e,t.__scopeCollapsible);return e.jsx(ud,{present:r||a.open,children:({present:o})=>e.jsx(jSt,{...n,ref:s,present:o})})});yUe.displayName=Y_e;var jSt=C.forwardRef((t,s)=>{const{__scopeCollapsible:r,present:n,children:a,...o}=t,l=Z_e(Y_e,r),[i,d]=C.useState(n),u=C.useRef(null),p=Ea(s,u),f=C.useRef(0),y=f.current,_=C.useRef(0),b=_.current,w=l.open||i,j=C.useRef(w),k=C.useRef(void 0);return C.useEffect(()=>{const S=requestAnimationFrame(()=>j.current=!1);return()=>cancelAnimationFrame(S)},[]),Zc(()=>{const S=u.current;if(S){k.current=k.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const T=S.getBoundingClientRect();f.current=T.height,_.current=T.width,j.current||(S.style.transitionDuration=k.current.transitionDuration,S.style.animationName=k.current.animationName),d(n)}},[l.open,n]),e.jsx(Qr.div,{"data-state":X_e(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!w,...o,ref:p,style:{"--radix-collapsible-content-height":y?`${y}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...t.style},children:w&&a})});function X_e(t){return t?"open":"closed"}var NSt=fUe;const bf=NSt,wf=xUe,jf=yUe,kSt="/assets/levelup-logo-Eif24dqY.png",SSt="/assets/levelup-logo-icon-C-7iromj.png",CSt="/assets/levelup-logo-mobile-B9skSjUG.png";var $L=t=>t.type==="checkbox",RN=t=>t instanceof Date,Ph=t=>t==null;const vUe=t=>typeof t=="object";var dd=t=>!Ph(t)&&!Array.isArray(t)&&vUe(t)&&!RN(t),_Ue=t=>dd(t)&&t.target?$L(t.target)?t.target.checked:t.target.value:t,MSt=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,bUe=(t,s)=>t.has(MSt(s)),TSt=t=>{const s=t.constructor&&t.constructor.prototype;return dd(s)&&s.hasOwnProperty("isPrototypeOf")},Q_e=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Dd(t){let s;const r=Array.isArray(t),n=typeof FileList<"u"?t instanceof FileList:!1;if(t instanceof Date)s=new Date(t);else if(!(Q_e&&(t instanceof Blob||n))&&(r||dd(t)))if(s=r?[]:{},!r&&!TSt(t))s=t;else for(const a in t)t.hasOwnProperty(a)&&(s[a]=Dd(t[a]));else return t;return s}var sle=t=>/^\w*$/.test(t),sd=t=>t===void 0,J_e=t=>Array.isArray(t)?t.filter(Boolean):[],ebe=t=>J_e(t.replace(/["|']|\]/g,"").split(/\.|\[/)),bn=(t,s,r)=>{if(!s||!dd(t))return r;const n=(sle(s)?[s]:ebe(s)).reduce((a,o)=>Ph(a)?a:a[o],t);return sd(n)||n===t?sd(t[s])?r:t[s]:n},op=t=>typeof t=="boolean",Yo=(t,s,r)=>{let n=-1;const a=sle(s)?[s]:ebe(s),o=a.length,l=o-1;for(;++nht.useContext(tbe),ASt=t=>{const{children:s,...r}=t;return ht.createElement(tbe.Provider,{value:r},s)};var wUe=(t,s,r,n=!0)=>{const a={defaultValues:s._defaultValues};for(const o in t)Object.defineProperty(a,o,{get:()=>{const l=o;return s._proxyFormState[l]!==Pg.all&&(s._proxyFormState[l]=!n||Pg.all),r&&(r[l]=!0),t[l]}});return a};const sbe=typeof window<"u"?ht.useLayoutEffect:ht.useEffect;function ESt(t){const s=rle(),{control:r=s.control,disabled:n,name:a,exact:o}=t||{},[l,i]=ht.useState(r._formState),d=ht.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return sbe(()=>r._subscribe({name:a,formState:d.current,exact:o,callback:u=>{!n&&i({...r._formState,...u})}}),[a,n,o]),ht.useEffect(()=>{d.current.isValid&&r._setValid(!0)},[r]),ht.useMemo(()=>wUe(l,r,d.current,!1),[l,r])}var Vx=t=>typeof t=="string",jUe=(t,s,r,n,a)=>Vx(t)?(n&&s.watch.add(t),bn(r,t,a)):Array.isArray(t)?t.map(o=>(n&&s.watch.add(o),bn(r,o))):(n&&(s.watchAll=!0),r),jxe=t=>Ph(t)||!vUe(t);function _0(t,s,r=new WeakSet){if(jxe(t)||jxe(s))return t===s;if(RN(t)&&RN(s))return t.getTime()===s.getTime();const n=Object.keys(t),a=Object.keys(s);if(n.length!==a.length)return!1;if(r.has(t)||r.has(s))return!0;r.add(t),r.add(s);for(const o of n){const l=t[o];if(!a.includes(o))return!1;if(o!=="ref"){const i=s[o];if(RN(l)&&RN(i)||dd(l)&&dd(i)||Array.isArray(l)&&Array.isArray(i)?!_0(l,i,r):l!==i)return!1}}return!0}function PSt(t){const s=rle(),{control:r=s.control,name:n,defaultValue:a,disabled:o,exact:l,compute:i}=t||{},d=ht.useRef(a),u=ht.useRef(i),p=ht.useRef(void 0);u.current=i;const f=ht.useMemo(()=>r._getWatch(n,d.current),[r,n]),[y,_]=ht.useState(u.current?u.current(f):f);return sbe(()=>r._subscribe({name:n,formState:{values:!0},exact:l,callback:b=>{if(!o){const w=jUe(n,r._names,b.values||r._formValues,!1,d.current);if(u.current){const j=u.current(w);_0(j,p.current)||(_(j),p.current=j)}else _(w)}}}),[r,o,n,l]),ht.useEffect(()=>r._removeUnmounted()),y}function ISt(t){const s=rle(),{name:r,disabled:n,control:a=s.control,shouldUnregister:o,defaultValue:l}=t,i=bUe(a._names.array,r),d=ht.useMemo(()=>bn(a._formValues,r,bn(a._defaultValues,r,l)),[a,r,l]),u=PSt({control:a,name:r,defaultValue:d,exact:!0}),p=ESt({control:a,name:r,exact:!0}),f=ht.useRef(t),y=ht.useRef(a.register(r,{...t.rules,value:u,...op(t.disabled)?{disabled:t.disabled}:{}}));f.current=t;const _=ht.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!bn(p.errors,r)},isDirty:{enumerable:!0,get:()=>!!bn(p.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!bn(p.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!bn(p.validatingFields,r)},error:{enumerable:!0,get:()=>bn(p.errors,r)}}),[p,r]),b=ht.useCallback(S=>y.current.onChange({target:{value:_Ue(S),name:r},type:Une.CHANGE}),[r]),w=ht.useCallback(()=>y.current.onBlur({target:{value:bn(a._formValues,r),name:r},type:Une.BLUR}),[r,a._formValues]),j=ht.useCallback(S=>{const T=bn(a._fields,r);T&&S&&(T._f.ref={focus:()=>S.focus&&S.focus(),select:()=>S.select&&S.select(),setCustomValidity:I=>S.setCustomValidity(I),reportValidity:()=>S.reportValidity()})},[a._fields,r]),k=ht.useMemo(()=>({name:r,value:u,...op(n)||p.disabled?{disabled:p.disabled||n}:{},onChange:b,onBlur:w,ref:j}),[r,n,p.disabled,b,w,j,u]);return ht.useEffect(()=>{const S=a._options.shouldUnregister||o;a.register(r,{...f.current.rules,...op(f.current.disabled)?{disabled:f.current.disabled}:{}});const T=(I,L)=>{const R=bn(a._fields,I);R&&R._f&&(R._f.mount=L)};if(T(r,!0),S){const I=Dd(bn(a._options.defaultValues,r));Yo(a._defaultValues,r,I),sd(bn(a._formValues,r))&&Yo(a._formValues,r,I)}return!i&&a.register(r),()=>{(i?S&&!a._state.action:S)?a.unregister(r):T(r,!1)}},[r,a,i,o]),ht.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),ht.useMemo(()=>({field:k,formState:p,fieldState:_}),[k,p,_])}const LSt=t=>t.render(ISt(t));var NUe=(t,s,r,n,a)=>s?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:a||!0}}:{},iI=t=>Array.isArray(t)?t:[t],EMe=()=>{let t=[];return{get observers(){return t},next:a=>{for(const o of t)o.next&&o.next(a)},subscribe:a=>(t.push(a),{unsubscribe:()=>{t=t.filter(o=>o!==a)}}),unsubscribe:()=>{t=[]}}},xm=t=>dd(t)&&!Object.keys(t).length,rbe=t=>t.type==="file",Ig=t=>typeof t=="function",Vne=t=>{if(!Q_e)return!1;const s=t?t.ownerDocument:0;return t instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},kUe=t=>t.type==="select-multiple",nbe=t=>t.type==="radio",DSt=t=>nbe(t)||$L(t),hme=t=>Vne(t)&&t.isConnected;function OSt(t,s){const r=s.slice(0,-1).length;let n=0;for(;n{for(const s in t)if(Ig(t[s]))return!0;return!1};function Hne(t,s={}){const r=Array.isArray(t);if(dd(t)||r)for(const n in t)Array.isArray(t[n])||dd(t[n])&&!SUe(t[n])?(s[n]=Array.isArray(t[n])?[]:{},Hne(t[n],s[n])):Ph(t[n])||(s[n]=!0);return s}function CUe(t,s,r){const n=Array.isArray(t);if(dd(t)||n)for(const a in t)Array.isArray(t[a])||dd(t[a])&&!SUe(t[a])?sd(s)||jxe(r[a])?r[a]=Array.isArray(t[a])?Hne(t[a],[]):{...Hne(t[a])}:CUe(t[a],Ph(s)?{}:s[a],r[a]):r[a]=!_0(t[a],s[a]);return r}var lE=(t,s)=>CUe(t,s,Hne(s));const PMe={value:!1,isValid:!1},IMe={value:!0,isValid:!0};var MUe=t=>{if(Array.isArray(t)){if(t.length>1){const s=t.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:s,isValid:!!s.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!sd(t[0].attributes.value)?sd(t[0].value)||t[0].value===""?IMe:{value:t[0].value,isValid:!0}:IMe:PMe}return PMe},TUe=(t,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>sd(t)?t:s?t===""?NaN:t&&+t:r&&Vx(t)?new Date(t):n?n(t):t;const LMe={isValid:!1,value:null};var AUe=t=>Array.isArray(t)?t.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,LMe):LMe;function DMe(t){const s=t.ref;return rbe(s)?s.files:nbe(s)?AUe(t.refs).value:kUe(s)?[...s.selectedOptions].map(({value:r})=>r):$L(s)?MUe(t.refs).value:TUe(sd(s.value)?t.ref.value:s.value,t)}var FSt=(t,s,r,n)=>{const a={};for(const o of t){const l=bn(s,o);l&&Yo(a,o,l._f)}return{criteriaMode:r,names:[...t],fields:a,shouldUseNativeValidation:n}},Wne=t=>t instanceof RegExp,cE=t=>sd(t)?t:Wne(t)?t.source:dd(t)?Wne(t.value)?t.value.source:t.value:t,OMe=t=>({isOnSubmit:!t||t===Pg.onSubmit,isOnBlur:t===Pg.onBlur,isOnChange:t===Pg.onChange,isOnAll:t===Pg.all,isOnTouch:t===Pg.onTouched});const RMe="AsyncFunction";var zSt=t=>!!t&&!!t.validate&&!!(Ig(t.validate)&&t.validate.constructor.name===RMe||dd(t.validate)&&Object.values(t.validate).find(s=>s.constructor.name===RMe)),BSt=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),FMe=(t,s,r)=>!r&&(s.watchAll||s.watch.has(t)||[...s.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const oI=(t,s,r,n)=>{for(const a of r||Object.keys(t)){const o=bn(t,a);if(o){const{_f:l,...i}=o;if(l){if(l.refs&&l.refs[0]&&s(l.refs[0],a)&&!n)return!0;if(l.ref&&s(l.ref,l.name)&&!n)return!0;if(oI(i,s))break}else if(dd(i)&&oI(i,s))break}}};function zMe(t,s,r){const n=bn(t,r);if(n||sle(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const o=a.join("."),l=bn(s,o),i=bn(t,o);if(l&&!Array.isArray(l)&&r!==o)return{name:r};if(i&&i.type)return{name:o,error:i};if(i&&i.root&&i.root.type)return{name:`${o}.root`,error:i.root};a.pop()}return{name:r}}var $St=(t,s,r,n)=>{r(t);const{name:a,...o}=t;return xm(o)||Object.keys(o).length>=Object.keys(s).length||Object.keys(o).find(l=>s[l]===(!n||Pg.all))},qSt=(t,s,r)=>!t||!s||t===s||iI(t).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n))),USt=(t,s,r,n,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(s||t):(r?n.isOnBlur:a.isOnBlur)?!t:(r?n.isOnChange:a.isOnChange)?t:!0,VSt=(t,s)=>!J_e(bn(t,s)).length&&yd(t,s),HSt=(t,s,r)=>{const n=iI(bn(t,r));return Yo(n,"root",s[r]),Yo(t,r,n),t},Nre=t=>Vx(t);function BMe(t,s,r="validate"){if(Nre(t)||Array.isArray(t)&&t.every(Nre)||op(t)&&!t)return{type:r,message:Nre(t)?t:"",ref:s}}var c4=t=>dd(t)&&!Wne(t)?t:{value:t,message:""},$Me=async(t,s,r,n,a,o)=>{const{ref:l,refs:i,required:d,maxLength:u,minLength:p,min:f,max:y,pattern:_,validate:b,name:w,valueAsNumber:j,mount:k}=t._f,S=bn(r,w);if(!k||s.has(w))return{};const T=i?i[0]:l,I=se=>{a&&T.reportValidity&&(T.setCustomValidity(op(se)?"":se||""),T.reportValidity())},L={},R=nbe(l),$=$L(l),q=R||$,U=(j||rbe(l))&&sd(l.value)&&sd(S)||Vne(l)&&l.value===""||S===""||Array.isArray(S)&&!S.length,H=NUe.bind(null,w,n,L),Y=(se,te,Q,de=Xy.maxLength,re=Xy.minLength)=>{const ae=se?te:Q;L[w]={type:se?de:re,message:ae,ref:l,...H(se?de:re,ae)}};if(o?!Array.isArray(S)||!S.length:d&&(!q&&(U||Ph(S))||op(S)&&!S||$&&!MUe(i).isValid||R&&!AUe(i).isValid)){const{value:se,message:te}=Nre(d)?{value:!!d,message:d}:c4(d);if(se&&(L[w]={type:Xy.required,message:te,ref:T,...H(Xy.required,te)},!n))return I(te),L}if(!U&&(!Ph(f)||!Ph(y))){let se,te;const Q=c4(y),de=c4(f);if(!Ph(S)&&!isNaN(S)){const re=l.valueAsNumber||S&&+S;Ph(Q.value)||(se=re>Q.value),Ph(de.value)||(te=renew Date(new Date().toDateString()+" "+be),le=l.type=="time",he=l.type=="week";Vx(Q.value)&&S&&(se=le?ae(S)>ae(Q.value):he?S>Q.value:re>new Date(Q.value)),Vx(de.value)&&S&&(te=le?ae(S)+se.value,de=!Ph(te.value)&&S.length<+te.value;if((Q||de)&&(Y(Q,se.message,te.message),!n))return I(L[w].message),L}if(_&&!U&&Vx(S)){const{value:se,message:te}=c4(_);if(Wne(se)&&!S.match(se)&&(L[w]={type:Xy.pattern,message:te,ref:l,...H(Xy.pattern,te)},!n))return I(te),L}if(b){if(Ig(b)){const se=await b(S,r),te=BMe(se,T);if(te&&(L[w]={...te,...H(Xy.validate,te.message)},!n))return I(te.message),L}else if(dd(b)){let se={};for(const te in b){if(!xm(se)&&!n)break;const Q=BMe(await b[te](S,r),T,te);Q&&(se={...Q,...H(te,Q.message)},I(Q.message),n&&(L[w]=se))}if(!xm(se)&&(L[w]={ref:T,...se},!n))return L}}return I(!0),L};const WSt={mode:Pg.onSubmit,reValidateMode:Pg.onChange,shouldFocusError:!0};function GSt(t={}){let s={...WSt,...t},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:Ig(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1},n={},a=dd(s.defaultValues)||dd(s.values)?Dd(s.defaultValues||s.values)||{}:{},o=s.shouldUnregister?{}:Dd(a),l={action:!1,mount:!1,watch:!1},i={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},d,u=0;const p={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let f={...p};const y={array:EMe(),state:EMe()},_=s.criteriaMode===Pg.all,b=$e=>ct=>{clearTimeout(u),u=setTimeout($e,ct)},w=async $e=>{if(!s.disabled&&(p.isValid||f.isValid||$e)){const ct=s.resolver?xm((await $()).errors):await U(n,!0);ct!==r.isValid&&y.state.next({isValid:ct})}},j=($e,ct)=>{!s.disabled&&(p.isValidating||p.validatingFields||f.isValidating||f.validatingFields)&&(($e||Array.from(i.mount)).forEach(qe=>{qe&&(ct?Yo(r.validatingFields,qe,ct):yd(r.validatingFields,qe))}),y.state.next({validatingFields:r.validatingFields,isValidating:!xm(r.validatingFields)}))},k=($e,ct=[],qe,Ze,Qe=!0,We=!0)=>{if(Ze&&qe&&!s.disabled){if(l.action=!0,We&&Array.isArray(bn(n,$e))){const He=qe(bn(n,$e),Ze.argA,Ze.argB);Qe&&Yo(n,$e,He)}if(We&&Array.isArray(bn(r.errors,$e))){const He=qe(bn(r.errors,$e),Ze.argA,Ze.argB);Qe&&Yo(r.errors,$e,He),VSt(r.errors,$e)}if((p.touchedFields||f.touchedFields)&&We&&Array.isArray(bn(r.touchedFields,$e))){const He=qe(bn(r.touchedFields,$e),Ze.argA,Ze.argB);Qe&&Yo(r.touchedFields,$e,He)}(p.dirtyFields||f.dirtyFields)&&(r.dirtyFields=lE(a,o)),y.state.next({name:$e,isDirty:Y($e,ct),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Yo(o,$e,ct)},S=($e,ct)=>{Yo(r.errors,$e,ct),y.state.next({errors:r.errors})},T=$e=>{r.errors=$e,y.state.next({errors:r.errors,isValid:!1})},I=($e,ct,qe,Ze)=>{const Qe=bn(n,$e);if(Qe){const We=bn(o,$e,sd(qe)?bn(a,$e):qe);sd(We)||Ze&&Ze.defaultChecked||ct?Yo(o,$e,ct?We:DMe(Qe._f)):Q($e,We),l.mount&&w()}},L=($e,ct,qe,Ze,Qe)=>{let We=!1,He=!1;const et={name:$e};if(!s.disabled){if(!qe||Ze){(p.isDirty||f.isDirty)&&(He=r.isDirty,r.isDirty=et.isDirty=Y(),We=He!==et.isDirty);const Tt=_0(bn(a,$e),ct);He=!!bn(r.dirtyFields,$e),Tt?yd(r.dirtyFields,$e):Yo(r.dirtyFields,$e,!0),et.dirtyFields=r.dirtyFields,We=We||(p.dirtyFields||f.dirtyFields)&&He!==!Tt}if(qe){const Tt=bn(r.touchedFields,$e);Tt||(Yo(r.touchedFields,$e,qe),et.touchedFields=r.touchedFields,We=We||(p.touchedFields||f.touchedFields)&&Tt!==qe)}We&&Qe&&y.state.next(et)}return We?et:{}},R=($e,ct,qe,Ze)=>{const Qe=bn(r.errors,$e),We=(p.isValid||f.isValid)&&op(ct)&&r.isValid!==ct;if(s.delayError&&qe?(d=b(()=>S($e,qe)),d(s.delayError)):(clearTimeout(u),d=null,qe?Yo(r.errors,$e,qe):yd(r.errors,$e)),(qe?!_0(Qe,qe):Qe)||!xm(Ze)||We){const He={...Ze,...We&&op(ct)?{isValid:ct}:{},errors:r.errors,name:$e};r={...r,...He},y.state.next(He)}},$=async $e=>{j($e,!0);const ct=await s.resolver(o,s.context,FSt($e||i.mount,n,s.criteriaMode,s.shouldUseNativeValidation));return j($e),ct},q=async $e=>{const{errors:ct}=await $($e);if($e)for(const qe of $e){const Ze=bn(ct,qe);Ze?Yo(r.errors,qe,Ze):yd(r.errors,qe)}else r.errors=ct;return ct},U=async($e,ct,qe={valid:!0})=>{for(const Ze in $e){const Qe=$e[Ze];if(Qe){const{_f:We,...He}=Qe;if(We){const et=i.array.has(We.name),Tt=Qe._f&&zSt(Qe._f);Tt&&p.validatingFields&&j([Ze],!0);const Ft=await $Me(Qe,i.disabled,o,_,s.shouldUseNativeValidation&&!ct,et);if(Tt&&p.validatingFields&&j([Ze]),Ft[We.name]&&(qe.valid=!1,ct))break;!ct&&(bn(Ft,We.name)?et?HSt(r.errors,Ft,We.name):Yo(r.errors,We.name,Ft[We.name]):yd(r.errors,We.name))}!xm(He)&&await U(He,ct,qe)}}return qe.valid},H=()=>{for(const $e of i.unMount){const ct=bn(n,$e);ct&&(ct._f.refs?ct._f.refs.every(qe=>!hme(qe)):!hme(ct._f.ref))&&Te($e)}i.unMount=new Set},Y=($e,ct)=>!s.disabled&&($e&&ct&&Yo(o,$e,ct),!_0(be(),a)),se=($e,ct,qe)=>jUe($e,i,{...l.mount?o:sd(ct)?a:Vx($e)?{[$e]:ct}:ct},qe,ct),te=$e=>J_e(bn(l.mount?o:a,$e,s.shouldUnregister?bn(a,$e,[]):[])),Q=($e,ct,qe={})=>{const Ze=bn(n,$e);let Qe=ct;if(Ze){const We=Ze._f;We&&(!We.disabled&&Yo(o,$e,TUe(ct,We)),Qe=Vne(We.ref)&&Ph(ct)?"":ct,kUe(We.ref)?[...We.ref.options].forEach(He=>He.selected=Qe.includes(He.value)):We.refs?$L(We.ref)?We.refs.forEach(He=>{(!He.defaultChecked||!He.disabled)&&(Array.isArray(Qe)?He.checked=!!Qe.find(et=>et===He.value):He.checked=Qe===He.value||!!Qe)}):We.refs.forEach(He=>He.checked=He.value===Qe):rbe(We.ref)?We.ref.value="":(We.ref.value=Qe,We.ref.type||y.state.next({name:$e,values:Dd(o)})))}(qe.shouldDirty||qe.shouldTouch)&&L($e,Qe,qe.shouldTouch,qe.shouldDirty,!0),qe.shouldValidate&&he($e)},de=($e,ct,qe)=>{for(const Ze in ct){if(!ct.hasOwnProperty(Ze))return;const Qe=ct[Ze],We=$e+"."+Ze,He=bn(n,We);(i.array.has($e)||dd(Qe)||He&&!He._f)&&!RN(Qe)?de(We,Qe,qe):Q(We,Qe,qe)}},re=($e,ct,qe={})=>{const Ze=bn(n,$e),Qe=i.array.has($e),We=Dd(ct);Yo(o,$e,We),Qe?(y.array.next({name:$e,values:Dd(o)}),(p.isDirty||p.dirtyFields||f.isDirty||f.dirtyFields)&&qe.shouldDirty&&y.state.next({name:$e,dirtyFields:lE(a,o),isDirty:Y($e,We)})):Ze&&!Ze._f&&!Ph(We)?de($e,We,qe):Q($e,We,qe),FMe($e,i)&&y.state.next({...r,name:$e}),y.state.next({name:l.mount?$e:void 0,values:Dd(o)})},ae=async $e=>{l.mount=!0;const ct=$e.target;let qe=ct.name,Ze=!0;const Qe=bn(n,qe),We=Tt=>{Ze=Number.isNaN(Tt)||RN(Tt)&&isNaN(Tt.getTime())||_0(Tt,bn(o,qe,Tt))},He=OMe(s.mode),et=OMe(s.reValidateMode);if(Qe){let Tt,Ft;const as=ct.type?DMe(Qe._f):_Ue($e),Xt=$e.type===Une.BLUR||$e.type===Une.FOCUS_OUT,ss=!BSt(Qe._f)&&!s.resolver&&!bn(r.errors,qe)&&!Qe._f.deps||USt(Xt,bn(r.touchedFields,qe),r.isSubmitted,et,He),is=FMe(qe,i,Xt);Yo(o,qe,as),Xt?(Qe._f.onBlur&&Qe._f.onBlur($e),d&&d(0)):Qe._f.onChange&&Qe._f.onChange($e);const ar=L(qe,as,Xt),Ct=!xm(ar)||is;if(!Xt&&y.state.next({name:qe,type:$e.type,values:Dd(o)}),ss)return(p.isValid||f.isValid)&&(s.mode==="onBlur"?Xt&&w():Xt||w()),Ct&&y.state.next({name:qe,...is?{}:ar});if(!Xt&&is&&y.state.next({...r}),s.resolver){const{errors:Is}=await $([qe]);if(We(as),Ze){const qs=zMe(r.errors,n,qe),gr=zMe(Is,n,qs.name||qe);Tt=gr.error,qe=gr.name,Ft=xm(Is)}}else j([qe],!0),Tt=(await $Me(Qe,i.disabled,o,_,s.shouldUseNativeValidation))[qe],j([qe]),We(as),Ze&&(Tt?Ft=!1:(p.isValid||f.isValid)&&(Ft=await U(n,!0)));Ze&&(Qe._f.deps&&he(Qe._f.deps),R(qe,Ft,Tt,ar))}},le=($e,ct)=>{if(bn(r.errors,ct)&&$e.focus)return $e.focus(),1},he=async($e,ct={})=>{let qe,Ze;const Qe=iI($e);if(s.resolver){const We=await q(sd($e)?$e:Qe);qe=xm(We),Ze=$e?!Qe.some(He=>bn(We,He)):qe}else $e?(Ze=(await Promise.all(Qe.map(async We=>{const He=bn(n,We);return await U(He&&He._f?{[We]:He}:He)}))).every(Boolean),!(!Ze&&!r.isValid)&&w()):Ze=qe=await U(n);return y.state.next({...!Vx($e)||(p.isValid||f.isValid)&&qe!==r.isValid?{}:{name:$e},...s.resolver||!$e?{isValid:qe}:{},errors:r.errors}),ct.shouldFocus&&!Ze&&oI(n,le,$e?Qe:i.mount),Ze},be=$e=>{const ct={...l.mount?o:a};return sd($e)?ct:Vx($e)?bn(ct,$e):$e.map(qe=>bn(ct,qe))},_e=($e,ct)=>({invalid:!!bn((ct||r).errors,$e),isDirty:!!bn((ct||r).dirtyFields,$e),error:bn((ct||r).errors,$e),isValidating:!!bn(r.validatingFields,$e),isTouched:!!bn((ct||r).touchedFields,$e)}),je=$e=>{$e&&iI($e).forEach(ct=>yd(r.errors,ct)),y.state.next({errors:$e?r.errors:{}})},Ne=($e,ct,qe)=>{const Ze=(bn(n,$e,{_f:{}})._f||{}).ref,Qe=bn(r.errors,$e)||{},{ref:We,message:He,type:et,...Tt}=Qe;Yo(r.errors,$e,{...Tt,...ct,ref:Ze}),y.state.next({name:$e,errors:r.errors,isValid:!1}),qe&&qe.shouldFocus&&Ze&&Ze.focus&&Ze.focus()},Ge=($e,ct)=>Ig($e)?y.state.subscribe({next:qe=>"values"in qe&&$e(se(void 0,ct),qe)}):se($e,ct,!0),we=$e=>y.state.subscribe({next:ct=>{qSt($e.name,ct.name,$e.exact)&&$St(ct,$e.formState||p,nt,$e.reRenderRoot)&&$e.callback({values:{...o},...r,...ct,defaultValues:a})}}).unsubscribe,Me=$e=>(l.mount=!0,f={...f,...$e.formState},we({...$e,formState:f})),Te=($e,ct={})=>{for(const qe of $e?iI($e):i.mount)i.mount.delete(qe),i.array.delete(qe),ct.keepValue||(yd(n,qe),yd(o,qe)),!ct.keepError&&yd(r.errors,qe),!ct.keepDirty&&yd(r.dirtyFields,qe),!ct.keepTouched&&yd(r.touchedFields,qe),!ct.keepIsValidating&&yd(r.validatingFields,qe),!s.shouldUnregister&&!ct.keepDefaultValue&&yd(a,qe);y.state.next({values:Dd(o)}),y.state.next({...r,...ct.keepDirty?{isDirty:Y()}:{}}),!ct.keepIsValid&&w()},Fe=({disabled:$e,name:ct})=>{(op($e)&&l.mount||$e||i.disabled.has(ct))&&($e?i.disabled.add(ct):i.disabled.delete(ct))},Ae=($e,ct={})=>{let qe=bn(n,$e);const Ze=op(ct.disabled)||op(s.disabled);return Yo(n,$e,{...qe||{},_f:{...qe&&qe._f?qe._f:{ref:{name:$e}},name:$e,mount:!0,...ct}}),i.mount.add($e),qe?Fe({disabled:op(ct.disabled)?ct.disabled:s.disabled,name:$e}):I($e,!0,ct.value),{...Ze?{disabled:ct.disabled||s.disabled}:{},...s.progressive?{required:!!ct.required,min:cE(ct.min),max:cE(ct.max),minLength:cE(ct.minLength),maxLength:cE(ct.maxLength),pattern:cE(ct.pattern)}:{},name:$e,onChange:ae,onBlur:ae,ref:Qe=>{if(Qe){Ae($e,ct),qe=bn(n,$e);const We=sd(Qe.value)&&Qe.querySelectorAll&&Qe.querySelectorAll("input,select,textarea")[0]||Qe,He=DSt(We),et=qe._f.refs||[];if(He?et.find(Tt=>Tt===We):We===qe._f.ref)return;Yo(n,$e,{_f:{...qe._f,...He?{refs:[...et.filter(hme),We,...Array.isArray(bn(a,$e))?[{}]:[]],ref:{type:We.type,name:$e}}:{ref:We}}}),I($e,!1,void 0,We)}else qe=bn(n,$e,{}),qe._f&&(qe._f.mount=!1),(s.shouldUnregister||ct.shouldUnregister)&&!(bUe(i.array,$e)&&l.action)&&i.unMount.add($e)}}},Ue=()=>s.shouldFocusError&&oI(n,le,i.mount),ut=$e=>{op($e)&&(y.state.next({disabled:$e}),oI(n,(ct,qe)=>{const Ze=bn(n,qe);Ze&&(ct.disabled=Ze._f.disabled||$e,Array.isArray(Ze._f.refs)&&Ze._f.refs.forEach(Qe=>{Qe.disabled=Ze._f.disabled||$e}))},0,!1))},De=($e,ct)=>async qe=>{let Ze;qe&&(qe.preventDefault&&qe.preventDefault(),qe.persist&&qe.persist());let Qe=Dd(o);if(y.state.next({isSubmitting:!0}),s.resolver){const{errors:We,values:He}=await $();r.errors=We,Qe=Dd(He)}else await U(n);if(i.disabled.size)for(const We of i.disabled)yd(Qe,We);if(yd(r.errors,"root"),xm(r.errors)){y.state.next({errors:{}});try{await $e(Qe,qe)}catch(We){Ze=We}}else ct&&await ct({...r.errors},qe),Ue(),setTimeout(Ue);if(y.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:xm(r.errors)&&!Ze,submitCount:r.submitCount+1,errors:r.errors}),Ze)throw Ze},Rt=($e,ct={})=>{bn(n,$e)&&(sd(ct.defaultValue)?re($e,Dd(bn(a,$e))):(re($e,ct.defaultValue),Yo(a,$e,Dd(ct.defaultValue))),ct.keepTouched||yd(r.touchedFields,$e),ct.keepDirty||(yd(r.dirtyFields,$e),r.isDirty=ct.defaultValue?Y($e,Dd(bn(a,$e))):Y()),ct.keepError||(yd(r.errors,$e),p.isValid&&w()),y.state.next({...r}))},me=($e,ct={})=>{const qe=$e?Dd($e):a,Ze=Dd(qe),Qe=xm($e),We=Qe?a:Ze;if(ct.keepDefaultValues||(a=qe),!ct.keepValues){if(ct.keepDirtyValues){const He=new Set([...i.mount,...Object.keys(lE(a,o))]);for(const et of Array.from(He))bn(r.dirtyFields,et)?Yo(We,et,bn(o,et)):re(et,bn(We,et))}else{if(Q_e&&sd($e))for(const He of i.mount){const et=bn(n,He);if(et&&et._f){const Tt=Array.isArray(et._f.refs)?et._f.refs[0]:et._f.ref;if(Vne(Tt)){const Ft=Tt.closest("form");if(Ft){Ft.reset();break}}}}if(ct.keepFieldsRef)for(const He of i.mount)re(He,bn(We,He));else n={}}o=s.shouldUnregister?ct.keepDefaultValues?Dd(a):{}:Dd(We),y.array.next({values:{...We}}),y.state.next({values:{...We}})}i={mount:ct.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!p.isValid||!!ct.keepIsValid||!!ct.keepDirtyValues,l.watch=!!s.shouldUnregister,y.state.next({submitCount:ct.keepSubmitCount?r.submitCount:0,isDirty:Qe?!1:ct.keepDirty?r.isDirty:!!(ct.keepDefaultValues&&!_0($e,a)),isSubmitted:ct.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:Qe?{}:ct.keepDirtyValues?ct.keepDefaultValues&&o?lE(a,o):r.dirtyFields:ct.keepDefaultValues&&$e?lE(a,$e):ct.keepDirty?r.dirtyFields:{},touchedFields:ct.keepTouched?r.touchedFields:{},errors:ct.keepErrors?r.errors:{},isSubmitSuccessful:ct.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Xe=($e,ct)=>me(Ig($e)?$e(o):$e,ct),ot=($e,ct={})=>{const qe=bn(n,$e),Ze=qe&&qe._f;if(Ze){const Qe=Ze.refs?Ze.refs[0]:Ze.ref;Qe.focus&&(Qe.focus(),ct.shouldSelect&&Ig(Qe.select)&&Qe.select())}},nt=$e=>{r={...r,...$e}},it={control:{register:Ae,unregister:Te,getFieldState:_e,handleSubmit:De,setError:Ne,_subscribe:we,_runSchema:$,_focusError:Ue,_getWatch:se,_getDirty:Y,_setValid:w,_setFieldArray:k,_setDisabledField:Fe,_setErrors:T,_getFieldArray:te,_reset:me,_resetDefaultValues:()=>Ig(s.defaultValues)&&s.defaultValues().then($e=>{Xe($e,s.resetOptions),y.state.next({isLoading:!1})}),_removeUnmounted:H,_disableForm:ut,_subjects:y,_proxyFormState:p,get _fields(){return n},get _formValues(){return o},get _state(){return l},set _state($e){l=$e},get _defaultValues(){return a},get _names(){return i},set _names($e){i=$e},get _formState(){return r},get _options(){return s},set _options($e){s={...s,...$e}}},subscribe:Me,trigger:he,register:Ae,handleSubmit:De,watch:Ge,setValue:re,getValues:be,reset:Xe,resetField:Rt,clearErrors:je,unregister:Te,setError:Ne,setFocus:ot,getFieldState:_e};return{...it,formControl:it}}function nle(t={}){const s=ht.useRef(void 0),r=ht.useRef(void 0),[n,a]=ht.useState({isDirty:!1,isValidating:!1,isLoading:Ig(t.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1,isReady:!1,defaultValues:Ig(t.defaultValues)?void 0:t.defaultValues});if(!s.current)if(t.formControl)s.current={...t.formControl,formState:n},t.defaultValues&&!Ig(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...i}=GSt(t);s.current={...i,formState:n}}const o=s.current.control;return o._options=t,sbe(()=>{const l=o._subscribe({formState:o._proxyFormState,callback:()=>a({...o._formState}),reRenderRoot:!0});return a(i=>({...i,isReady:!0})),o._formState.isReady=!0,l},[o]),ht.useEffect(()=>o._disableForm(t.disabled),[o,t.disabled]),ht.useEffect(()=>{t.mode&&(o._options.mode=t.mode),t.reValidateMode&&(o._options.reValidateMode=t.reValidateMode)},[o,t.mode,t.reValidateMode]),ht.useEffect(()=>{t.errors&&(o._setErrors(t.errors),o._focusError())},[o,t.errors]),ht.useEffect(()=>{t.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,t.shouldUnregister]),ht.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==n.isDirty&&o._subjects.state.next({isDirty:l})}},[o,n.isDirty]),ht.useEffect(()=>{t.values&&!_0(t.values,r.current)?(o._reset(t.values,{keepFieldsRef:!0,...o._options.resetOptions}),r.current=t.values,a(l=>({...l}))):o._resetDefaultValues()},[o,t.values]),ht.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),s.current.formState=wUe(n,o),s.current}const qMe=(t,s,r)=>{if(t&&"reportValidity"in t){const n=bn(r,s);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},EUe=(t,s)=>{for(const r in s.fields){const n=s.fields[r];n&&n.ref&&"reportValidity"in n.ref?qMe(n.ref,r,t):n.refs&&n.refs.forEach(a=>qMe(a,r,t))}},KSt=(t,s)=>{s.shouldUseNativeValidation&&EUe(t,s);const r={};for(const n in t){const a=bn(s.fields,n),o=Object.assign(t[n]||{},{ref:a&&a.ref});if(ZSt(s.names||Object.keys(t),n)){const l=Object.assign({},bn(r,n));Yo(l,"root",o),Yo(r,n,l)}else Yo(r,n,o)}return r},ZSt=(t,s)=>t.some(r=>r.startsWith(s+"."));var YSt=function(t,s){for(var r={};t.length;){var n=t[0],a=n.code,o=n.message,l=n.path.join(".");if(!r[l])if("unionErrors"in n){var i=n.unionErrors[0].errors[0];r[l]={message:i.message,type:i.code}}else r[l]={message:o,type:a};if("unionErrors"in n&&n.unionErrors.forEach(function(p){return p.errors.forEach(function(f){return t.push(f)})}),s){var d=r[l].types,u=d&&d[n.code];r[l]=NUe(l,s,r,a,u?[].concat(u,n.message):n.message)}t.shift()}return r},ale=function(t,s,r){return r===void 0&&(r={}),function(n,a,o){try{return Promise.resolve(function(l,i){try{var d=Promise.resolve(t[r.mode==="sync"?"parse":"parseAsync"](n,s)).then(function(u){return o.shouldUseNativeValidation&&EUe({},o),{errors:{},values:r.raw?n:u}})}catch(u){return i(u)}return d&&d.then?d.then(void 0,i):d}(0,function(l){if(function(i){return Array.isArray(i==null?void 0:i.errors)}(l))return{values:{},errors:KSt(YSt(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const ile=ASt,PUe=C.createContext({}),wc=({...t})=>e.jsx(PUe.Provider,{value:{name:t.name},children:e.jsx(LSt,{...t})}),ole=()=>{const t=C.useContext(PUe),s=C.useContext(IUe),{getFieldState:r,formState:n}=rle(),a=r(t.name,n);if(!t)throw new Error("useFormField should be used within ");const{id:o}=s;return{id:o,name:t.name,formItemId:`${o}-form-item`,formDescriptionId:`${o}-form-item-description`,formMessageId:`${o}-form-item-message`,...a}},IUe=C.createContext({}),uc=C.forwardRef(({className:t,...s},r)=>{const n=C.useId();return e.jsx(IUe.Provider,{value:{id:n},children:e.jsx("div",{ref:r,className:Pt("space-y-2",t),...s})})});uc.displayName="FormItem";const hc=C.forwardRef(({className:t,...s},r)=>{const{error:n,formItemId:a}=ole();return e.jsx(ve,{ref:r,className:Pt(n&&"text-destructive",t),htmlFor:a,...s})});hc.displayName="FormLabel";const mc=C.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:o}=ole();return e.jsx(n1e,{ref:s,id:n,"aria-describedby":r?`${a} ${o}`:`${a}`,"aria-invalid":!!r,...t})});mc.displayName="FormControl";const kre=C.forwardRef(({className:t,...s},r)=>{const{formDescriptionId:n}=ole();return e.jsx("p",{ref:r,id:n,className:Pt("text-sm text-muted-foreground",t),...s})});kre.displayName="FormDescription";const Oh=C.forwardRef(({className:t,children:s,...r},n)=>{const{error:a,formMessageId:o}=ole(),l=a?String(a==null?void 0:a.message):s;return l?e.jsx("p",{ref:n,id:o,className:Pt("text-sm font-medium text-destructive",t),...r,children:l}):null});Oh.displayName="FormMessage";const XSt=lS({category:i$e(["general","technology","crm","marketing"]),subject:Jl().min(5,"Subject must be at least 5 characters").max(200),description:Jl().min(20,"Please provide more details (at least 20 characters)").max(2e3)}),QSt={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function Nxe({trigger:t}){const[s,r]=C.useState(!1),[n,a]=C.useState(!1),{user:o}=Hs(),l=nle({resolver:ale(XSt),defaultValues:{category:"general",subject:"",description:""}}),i=async d=>{if(!o){fe.error("You must be logged in to submit a ticket");return}a(!0);try{const{error:u}=await G.from("support_tickets").insert({user_id:o.id,category:d.category,subject:d.subject,description:d.description});if(u)throw u;try{await G.functions.invoke("support-ticket-notify",{body:{category:QSt[d.category],subject:d.subject}})}catch(p){console.log("Notification send attempted:",p)}fe.success("Support ticket submitted successfully!"),l.reset(),r(!1)}catch(u){console.error("Error submitting ticket:",u),fe.error("Failed to submit ticket. Please try again.")}finally{a(!1)}};return e.jsxs(_s,{open:s,onOpenChange:r,children:[e.jsx(Ei,{asChild:!0,children:t||e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(jP,{className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:"Support"})]})}),e.jsxs(vs,{className:"sm:max-w-[500px]",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Need Help?"}),e.jsx(Kr,{children:"Submit a support ticket and we'll get back to you as soon as possible."})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-lg mb-4",children:[e.jsx(Qn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["You can also text us at: ",e.jsx("span",{className:"font-medium text-foreground",children:"1-866-527-8668"})]})]}),e.jsx(ile,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(i),className:"space-y-4",children:[e.jsx(wc,{control:l.control,name:"category",render:({field:d})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Category"}),e.jsxs(sr,{onValueChange:d.onChange,defaultValue:d.value,children:[e.jsx(mc,{children:e.jsx(er,{children:e.jsx(rr,{placeholder:"Select a category"})})}),e.jsxs(tr,{children:[e.jsx(At,{value:"general",children:"General Support"}),e.jsx(At,{value:"technology",children:"Technology Support"}),e.jsx(At,{value:"crm",children:"CRM Support"}),e.jsx(At,{value:"marketing",children:"Marketing Support"})]})]}),e.jsx(Oh,{})]})}),e.jsx(wc,{control:l.control,name:"subject",render:({field:d})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Subject"}),e.jsx(mc,{children:e.jsx(Re,{placeholder:"Brief description of your issue",...d})}),e.jsx(Oh,{})]})}),e.jsx(wc,{control:l.control,name:"description",render:({field:d})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Description"}),e.jsx(mc,{children:e.jsx(Ar,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...d})}),e.jsx(Oh,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:n,children:n?"Submitting...":"Submit Ticket"})]})]})})]})]})}const JSt=()=>{const{user:t}=Hs(),s=Pr(),[r,n]=C.useState([]),[a,o]=C.useState(0),[l,i]=C.useState(!1),[d,u]=C.useState(null);C.useEffect(()=>{if(!t)return;const b=`notification_last_read_${t.id}`;let w=d;if(!w){const S=localStorage.getItem(b);S&&(w=S,u(S))}(async()=>{const{data:S,error:T}=await G.from("push_notifications").select("*").order("created_at",{ascending:!1}).limit(20);if(!T&&S){n(S);const I=w?new Date(w):null,L=S.filter(R=>I?new Date(R.created_at)>I:!0);o(L.length)}})();const k=G.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},S=>{const T=S.new;n(L=>[T,...L].slice(0,20));const I=w?new Date(w):null;(!I||new Date(T.created_at)>I)&&o(L=>L+1),Notification.permission==="granted"&&new Notification(T.title,{body:T.body,icon:"/favicon.ico"})}).subscribe();return()=>{G.removeChannel(k)}},[t,d]);const p=b=>{const w=b.toLowerCase();return w.includes("community")||w.includes("post")?io:w.includes("academy")||w.includes("video")?Nn:w.includes("template")?Bl:w.includes("event")?on:w.includes("newsletter")?z0:w.includes("brokerage")?rh:w.includes("swag")||w.includes("social")?po:w.includes("toolbox")||w.includes("tool")?Wg:w.includes("brief")?hn:io},f=b=>{i(!1),b.url&&b.url!=="/"&&s(b.url)},y=()=>{if(!t)return;const b=new Date().toISOString(),w=`notification_last_read_${t.id}`;localStorage.setItem(w,b),u(b),o(0)},_=b=>{i(b),b&&a>0&&y()};return e.jsxs(Kd,{open:l,onOpenChange:_,children:[e.jsx(Zd,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(gf,{className:"h-5 w-5"}),a>0&&e.jsx(rt,{variant:"destructive",className:"absolute -top-1 -right-1 h-5 w-5 flex items-center justify-center p-0 text-xs",children:a>9?"9+":a})]})}),e.jsxs(Md,{align:"end",className:"w-80",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b",children:[e.jsx("span",{className:"font-semibold",children:"Notifications"}),r.length>0&&e.jsx(K,{variant:"ghost",size:"sm",className:"text-xs h-6",onClick:y,children:"Mark all read"})]}),e.jsx(Ri,{className:"h-[300px]",children:r.length===0?e.jsx("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No notifications yet"}):r.map(b=>{const w=p(b.title);return e.jsxs(Na,{className:"group flex items-start gap-3 p-3 cursor-pointer data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",onClick:()=>f(b),children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx(w,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-sm",children:b.title}),e.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2 group-data-[highlighted]:text-accent-foreground/80",children:b.body}),e.jsx("span",{className:"text-xs text-muted-foreground group-data-[highlighted]:text-accent-foreground/80",children:Sd(new Date(b.created_at),{addSuffix:!0})})]})]},b.id)})})]})]})};var UMe=1,eCt=.9,tCt=.8,sCt=.17,mme=.1,pme=.999,rCt=.9999,nCt=.99,aCt=/[\\\/_+.#"@\[\(\{&]/,iCt=/[\\\/_+.#"@\[\(\{&]/g,oCt=/[\s-]/,LUe=/[\s-]/g;function kxe(t,s,r,n,a,o,l){if(o===s.length)return a===t.length?UMe:nCt;var i=`${a},${o}`;if(l[i]!==void 0)return l[i];for(var d=n.charAt(o),u=r.indexOf(d,a),p=0,f,y,_,b;u>=0;)f=kxe(t,s,r,n,u+1,o+1,l),f>p&&(u===a?f*=UMe:aCt.test(t.charAt(u-1))?(f*=tCt,_=t.slice(a,u-1).match(iCt),_&&a>0&&(f*=Math.pow(pme,_.length))):oCt.test(t.charAt(u-1))?(f*=eCt,b=t.slice(a,u-1).match(LUe),b&&a>0&&(f*=Math.pow(pme,b.length))):(f*=sCt,a>0&&(f*=Math.pow(pme,u-a))),t.charAt(u)!==s.charAt(o)&&(f*=rCt)),(ff&&(f=y*mme)),f>p&&(p=f),u=r.indexOf(d,u+1);return l[i]=p,p}function VMe(t){return t.toLowerCase().replace(LUe," ")}function lCt(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,kxe(t,s,VMe(t),VMe(s),0,0,{})}var dE='[cmdk-group=""]',fme='[cmdk-group-items=""]',cCt='[cmdk-group-heading=""]',DUe='[cmdk-item=""]',HMe=`${DUe}:not([aria-disabled="true"])`,Sxe="cmdk-item-select",S4="data-value",dCt=(t,s,r)=>lCt(t,s,r),OUe=C.createContext(void 0),qL=()=>C.useContext(OUe),RUe=C.createContext(void 0),abe=()=>C.useContext(RUe),FUe=C.createContext(void 0),zUe=C.forwardRef((t,s)=>{let r=C4(()=>{var je,Ne;return{search:"",value:(Ne=(je=t.value)!=null?je:t.defaultValue)!=null?Ne:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=C4(()=>new Set),a=C4(()=>new Map),o=C4(()=>new Map),l=C4(()=>new Set),i=BUe(t),{label:d,children:u,value:p,onValueChange:f,filter:y,shouldFilter:_,loop:b,disablePointerSelection:w=!1,vimBindings:j=!0,...k}=t,S=Gd(),T=Gd(),I=Gd(),L=C.useRef(null),R=bCt();Bk(()=>{if(p!==void 0){let je=p.trim();r.current.value=je,$.emit()}},[p]),Bk(()=>{R(6,te)},[]);let $=C.useMemo(()=>({subscribe:je=>(l.current.add(je),()=>l.current.delete(je)),snapshot:()=>r.current,setState:(je,Ne,Ge)=>{var we,Me,Te,Fe;if(!Object.is(r.current[je],Ne)){if(r.current[je]=Ne,je==="search")se(),H(),R(1,Y);else if(je==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Ae=document.getElementById(I);Ae?Ae.focus():(we=document.getElementById(S))==null||we.focus()}if(R(7,()=>{var Ae;r.current.selectedItemId=(Ae=Q())==null?void 0:Ae.id,$.emit()}),Ge||R(5,te),((Me=i.current)==null?void 0:Me.value)!==void 0){let Ae=Ne??"";(Fe=(Te=i.current).onValueChange)==null||Fe.call(Te,Ae);return}}$.emit()}},emit:()=>{l.current.forEach(je=>je())}}),[]),q=C.useMemo(()=>({value:(je,Ne,Ge)=>{var we;Ne!==((we=o.current.get(je))==null?void 0:we.value)&&(o.current.set(je,{value:Ne,keywords:Ge}),r.current.filtered.items.set(je,U(Ne,Ge)),R(2,()=>{H(),$.emit()}))},item:(je,Ne)=>(n.current.add(je),Ne&&(a.current.has(Ne)?a.current.get(Ne).add(je):a.current.set(Ne,new Set([je]))),R(3,()=>{se(),H(),r.current.value||Y(),$.emit()}),()=>{o.current.delete(je),n.current.delete(je),r.current.filtered.items.delete(je);let Ge=Q();R(4,()=>{se(),(Ge==null?void 0:Ge.getAttribute("id"))===je&&Y(),$.emit()})}),group:je=>(a.current.has(je)||a.current.set(je,new Set),()=>{o.current.delete(je),a.current.delete(je)}),filter:()=>i.current.shouldFilter,label:d||t["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:S,inputId:I,labelId:T,listInnerRef:L}),[]);function U(je,Ne){var Ge,we;let Me=(we=(Ge=i.current)==null?void 0:Ge.filter)!=null?we:dCt;return je?Me(je,r.current.search,Ne):0}function H(){if(!r.current.search||i.current.shouldFilter===!1)return;let je=r.current.filtered.items,Ne=[];r.current.filtered.groups.forEach(we=>{let Me=a.current.get(we),Te=0;Me.forEach(Fe=>{let Ae=je.get(Fe);Te=Math.max(Ae,Te)}),Ne.push([we,Te])});let Ge=L.current;de().sort((we,Me)=>{var Te,Fe;let Ae=we.getAttribute("id"),Ue=Me.getAttribute("id");return((Te=je.get(Ue))!=null?Te:0)-((Fe=je.get(Ae))!=null?Fe:0)}).forEach(we=>{let Me=we.closest(fme);Me?Me.appendChild(we.parentElement===Me?we:we.closest(`${fme} > *`)):Ge.appendChild(we.parentElement===Ge?we:we.closest(`${fme} > *`))}),Ne.sort((we,Me)=>Me[1]-we[1]).forEach(we=>{var Me;let Te=(Me=L.current)==null?void 0:Me.querySelector(`${dE}[${S4}="${encodeURIComponent(we[0])}"]`);Te==null||Te.parentElement.appendChild(Te)})}function Y(){let je=de().find(Ge=>Ge.getAttribute("aria-disabled")!=="true"),Ne=je==null?void 0:je.getAttribute(S4);$.setState("value",Ne||void 0)}function se(){var je,Ne,Ge,we;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let Me=0;for(let Te of n.current){let Fe=(Ne=(je=o.current.get(Te))==null?void 0:je.value)!=null?Ne:"",Ae=(we=(Ge=o.current.get(Te))==null?void 0:Ge.keywords)!=null?we:[],Ue=U(Fe,Ae);r.current.filtered.items.set(Te,Ue),Ue>0&&Me++}for(let[Te,Fe]of a.current)for(let Ae of Fe)if(r.current.filtered.items.get(Ae)>0){r.current.filtered.groups.add(Te);break}r.current.filtered.count=Me}function te(){var je,Ne,Ge;let we=Q();we&&(((je=we.parentElement)==null?void 0:je.firstChild)===we&&((Ge=(Ne=we.closest(dE))==null?void 0:Ne.querySelector(cCt))==null||Ge.scrollIntoView({block:"nearest"})),we.scrollIntoView({block:"nearest"}))}function Q(){var je;return(je=L.current)==null?void 0:je.querySelector(`${DUe}[aria-selected="true"]`)}function de(){var je;return Array.from(((je=L.current)==null?void 0:je.querySelectorAll(HMe))||[])}function re(je){let Ne=de()[je];Ne&&$.setState("value",Ne.getAttribute(S4))}function ae(je){var Ne;let Ge=Q(),we=de(),Me=we.findIndex(Fe=>Fe===Ge),Te=we[Me+je];(Ne=i.current)!=null&&Ne.loop&&(Te=Me+je<0?we[we.length-1]:Me+je===we.length?we[0]:we[Me+je]),Te&&$.setState("value",Te.getAttribute(S4))}function le(je){let Ne=Q(),Ge=Ne==null?void 0:Ne.closest(dE),we;for(;Ge&&!we;)Ge=je>0?vCt(Ge,dE):_Ct(Ge,dE),we=Ge==null?void 0:Ge.querySelector(HMe);we?$.setState("value",we.getAttribute(S4)):ae(je)}let he=()=>re(de().length-1),be=je=>{je.preventDefault(),je.metaKey?he():je.altKey?le(1):ae(1)},_e=je=>{je.preventDefault(),je.metaKey?re(0):je.altKey?le(-1):ae(-1)};return C.createElement(Qr.div,{ref:s,tabIndex:-1,...k,"cmdk-root":"",onKeyDown:je=>{var Ne;(Ne=k.onKeyDown)==null||Ne.call(k,je);let Ge=je.nativeEvent.isComposing||je.keyCode===229;if(!(je.defaultPrevented||Ge))switch(je.key){case"n":case"j":{j&&je.ctrlKey&&be(je);break}case"ArrowDown":{be(je);break}case"p":case"k":{j&&je.ctrlKey&&_e(je);break}case"ArrowUp":{_e(je);break}case"Home":{je.preventDefault(),re(0);break}case"End":{je.preventDefault(),he();break}case"Enter":{je.preventDefault();let we=Q();if(we){let Me=new Event(Sxe);we.dispatchEvent(Me)}}}}},C.createElement("label",{"cmdk-label":"",htmlFor:q.inputId,id:q.labelId,style:jCt},d),lle(t,je=>C.createElement(RUe.Provider,{value:$},C.createElement(OUe.Provider,{value:q},je))))}),uCt=C.forwardRef((t,s)=>{var r,n;let a=Gd(),o=C.useRef(null),l=C.useContext(FUe),i=qL(),d=BUe(t),u=(n=(r=d.current)==null?void 0:r.forceMount)!=null?n:l==null?void 0:l.forceMount;Bk(()=>{if(!u)return i.item(a,l==null?void 0:l.id)},[u]);let p=$Ue(a,o,[t.value,t.children,o],t.keywords),f=abe(),y=R_(R=>R.value&&R.value===p.current),_=R_(R=>u||i.filter()===!1?!0:R.search?R.filtered.items.get(a)>0:!0);C.useEffect(()=>{let R=o.current;if(!(!R||t.disabled))return R.addEventListener(Sxe,b),()=>R.removeEventListener(Sxe,b)},[_,t.onSelect,t.disabled]);function b(){var R,$;w(),($=(R=d.current).onSelect)==null||$.call(R,p.current)}function w(){f.setState("value",p.current,!0)}if(!_)return null;let{disabled:j,value:k,onSelect:S,forceMount:T,keywords:I,...L}=t;return C.createElement(Qr.div,{ref:tv(o,s),...L,id:a,"cmdk-item":"",role:"option","aria-disabled":!!j,"aria-selected":!!y,"data-disabled":!!j,"data-selected":!!y,onPointerMove:j||i.getDisablePointerSelection()?void 0:w,onClick:j?void 0:b},t.children)}),hCt=C.forwardRef((t,s)=>{let{heading:r,children:n,forceMount:a,...o}=t,l=Gd(),i=C.useRef(null),d=C.useRef(null),u=Gd(),p=qL(),f=R_(_=>a||p.filter()===!1?!0:_.search?_.filtered.groups.has(l):!0);Bk(()=>p.group(l),[]),$Ue(l,i,[t.value,t.heading,d]);let y=C.useMemo(()=>({id:l,forceMount:a}),[a]);return C.createElement(Qr.div,{ref:tv(i,s),...o,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},r&&C.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:u},r),lle(t,_=>C.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},C.createElement(FUe.Provider,{value:y},_))))}),mCt=C.forwardRef((t,s)=>{let{alwaysRender:r,...n}=t,a=C.useRef(null),o=R_(l=>!l.search);return!r&&!o?null:C.createElement(Qr.div,{ref:tv(a,s),...n,"cmdk-separator":"",role:"separator"})}),pCt=C.forwardRef((t,s)=>{let{onValueChange:r,...n}=t,a=t.value!=null,o=abe(),l=R_(u=>u.search),i=R_(u=>u.selectedItemId),d=qL();return C.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),C.createElement(Qr.input,{ref:s,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":d.listId,"aria-labelledby":d.labelId,"aria-activedescendant":i,id:d.inputId,type:"text",value:a?t.value:l,onChange:u=>{a||o.setState("search",u.target.value),r==null||r(u.target.value)}})}),fCt=C.forwardRef((t,s)=>{let{children:r,label:n="Suggestions",...a}=t,o=C.useRef(null),l=C.useRef(null),i=R_(u=>u.selectedItemId),d=qL();return C.useEffect(()=>{if(l.current&&o.current){let u=l.current,p=o.current,f,y=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let _=u.offsetHeight;p.style.setProperty("--cmdk-list-height",_.toFixed(1)+"px")})});return y.observe(u),()=>{cancelAnimationFrame(f),y.unobserve(u)}}},[]),C.createElement(Qr.div,{ref:tv(o,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":n,id:d.listId},lle(t,u=>C.createElement("div",{ref:tv(l,d.listInnerRef),"cmdk-list-sizer":""},u)))}),gCt=C.forwardRef((t,s)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=t;return C.createElement(Ioe,{open:r,onOpenChange:n},C.createElement(Loe,{container:l},C.createElement(wM,{"cmdk-overlay":"",className:a}),C.createElement(jM,{"aria-label":t.label,"cmdk-dialog":"",className:o},C.createElement(zUe,{ref:s,...i}))))}),xCt=C.forwardRef((t,s)=>R_(r=>r.filtered.count===0)?C.createElement(Qr.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),yCt=C.forwardRef((t,s)=>{let{progress:r,children:n,label:a="Loading...",...o}=t;return C.createElement(Qr.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},lle(t,l=>C.createElement("div",{"aria-hidden":!0},l)))}),$m=Object.assign(zUe,{List:fCt,Item:uCt,Input:pCt,Group:hCt,Separator:mCt,Dialog:gCt,Empty:xCt,Loading:yCt});function vCt(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function _Ct(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function BUe(t){let s=C.useRef(t);return Bk(()=>{s.current=t}),s}var Bk=typeof window>"u"?C.useEffect:C.useLayoutEffect;function C4(t){let s=C.useRef();return s.current===void 0&&(s.current=t()),s}function R_(t){let s=abe(),r=()=>t(s.snapshot());return C.useSyncExternalStore(s.subscribe,r,r)}function $Ue(t,s,r,n=[]){let a=C.useRef(),o=qL();return Bk(()=>{var l;let i=(()=>{var u;for(let p of r){if(typeof p=="string")return p.trim();if(typeof p=="object"&&"current"in p)return p.current?(u=p.current.textContent)==null?void 0:u.trim():a.current}})(),d=n.map(u=>u.trim());o.value(t,i,d),(l=s.current)==null||l.setAttribute(S4,i),a.current=i}),a}var bCt=()=>{let[t,s]=C.useState(),r=C4(()=>new Map);return Bk(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,a)=>{r.current.set(n,a),s({})}};function wCt(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function lle({asChild:t,children:s},r){return t&&C.isValidElement(s)?C.cloneElement(wCt(s),{ref:s.ref},r(s.props.children)):r(s)}var jCt={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Mf=C.forwardRef(({className:t,...s},r)=>e.jsx($m,{ref:r,className:Pt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));Mf.displayName=$m.displayName;const NCt=({children:t,...s})=>e.jsx(_s,{...s,children:e.jsx(vs,{className:"overflow-hidden p-0 shadow-lg",children:e.jsx(Mf,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:t})})}),Tf=C.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(gn,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx($m.Input,{ref:r,className:Pt("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));Tf.displayName=$m.Input.displayName;const Af=C.forwardRef(({className:t,...s},r)=>e.jsx($m.List,{ref:r,className:Pt("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));Af.displayName=$m.List.displayName;const Ef=C.forwardRef((t,s)=>e.jsx($m.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));Ef.displayName=$m.Empty.displayName;const Pf=C.forwardRef(({className:t,...s},r)=>e.jsx($m.Group,{ref:r,className:Pt("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));Pf.displayName=$m.Group.displayName;const kCt=C.forwardRef(({className:t,...s},r)=>e.jsx($m.Separator,{ref:r,className:Pt("-mx-1 h-px bg-border",t),...s}));kCt.displayName=$m.Separator.displayName;const Cm=C.forwardRef(({className:t,...s},r)=>e.jsx($m.Item,{ref:r,className:Pt("group relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-primary/80 data-[selected=true]:text-primary-foreground data-[disabled=true]:opacity-50",t),...s}));Cm.displayName=$m.Item.displayName;const SCt={event:{label:"Events",icon:id,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:Bl,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:ah,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:Wg,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:hn,color:"bg-fuchsia-500/10 text-fuchsia-600"}},WMe=()=>{const[t,s]=C.useState(!1),[r,n]=C.useState(""),[a,o]=C.useState([]),[l,i]=C.useState(!1),d=Pr();C.useEffect(()=>{const y=_=>{_.key==="k"&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),s(b=>!b))};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[]);const u=C.useCallback(async y=>{if(!y.trim()){o([]);return}i(!0);const _=`%${y}%`;try{const[b,w,j,k,S]=await Promise.all([G.from("events").select("id, title, description, event_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5),G.from("canva_templates").select("id, name, description, publish_date").or(`name.ilike.${_},description.ilike.${_}`).limit(5),G.from("academy_videos").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5),G.from("resource_kits").select("id, name, description, publish_date").eq("is_published",!0).or(`name.ilike.${_},description.ilike.${_}`).limit(5),G.from("social_swag").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5)]),T=[];b.data&&b.data.forEach(I=>{T.push({id:I.id,title:I.title,description:I.description,type:"event",date:I.event_date,path:`/event/${I.id}`})}),w.data&&w.data.forEach(I=>{T.push({id:I.id,title:I.name,description:I.description,type:"template",date:I.publish_date,path:`/templates/${I.id}`})}),j.data&&j.data.forEach(I=>{T.push({id:I.id,title:I.title,description:I.description,type:"academy",date:I.publish_date,path:`/academy/${I.id}`})}),k.data&&k.data.forEach(I=>{T.push({id:I.id,title:I.name,description:I.description,type:"toolbox",date:I.publish_date,path:`/toolbox/${I.id}`})}),S.data&&S.data.forEach(I=>{T.push({id:I.id,title:I.title,description:I.description,type:"social-swag",date:I.publish_date,path:`/social-swag/${I.id}`})}),o(T)}catch(b){console.error("Search error:",b)}finally{i(!1)}},[]);C.useEffect(()=>{const y=setTimeout(()=>{u(r)},300);return()=>clearTimeout(y)},[r,u]);const p=y=>{s(!1),n(""),d(y)},f=a.reduce((y,_)=>(y[_.type]||(y[_.type]=[]),y[_.type].push(_),y),{});return e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",className:"relative h-9 w-9 p-0 xl:h-9 xl:w-60 xl:justify-start xl:px-3 xl:py-2",onClick:()=>s(!0),children:[e.jsx(gn,{className:"h-4 w-4 xl:mr-2"}),e.jsx("span",{className:"hidden xl:inline-flex text-muted-foreground text-sm",children:"Search..."}),e.jsxs("kbd",{className:"pointer-events-none absolute right-1.5 top-1.5 hidden h-6 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 xl:flex",children:[e.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]}),e.jsxs(NCt,{open:t,onOpenChange:s,children:[e.jsx(Tf,{placeholder:"Search events, templates, academy, toolbox, social swag...",value:r,onValueChange:n}),e.jsxs(Af,{children:[l&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!l&&r&&a.length===0&&e.jsxs(Ef,{children:['No results found for "',r,'"']}),!l&&!r&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Start typing to search across all content..."}),Object.entries(f).map(([y,_])=>{const b=SCt[y],w=b.icon;return e.jsx(Pf,{heading:b.label,children:_.map(j=>e.jsxs(Cm,{value:`${j.type}-${j.id}-${j.title}`,onSelect:()=>p(j.path),className:"flex items-start gap-3 py-3 cursor-pointer",children:[e.jsx("div",{className:`p-2 rounded-md ${b.color}`,children:e.jsx(w,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:j.title}),j.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate group-data-[selected=true]:text-primary-foreground/80",children:j.description})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(rt,{variant:"secondary",className:"text-xs",children:b.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Sd(new Date(j.date),{addSuffix:!0})})]})]},`${j.type}-${j.id}`))},y)})]})]})]})},CCt=({expiresAt:t,className:s,showUpgradeButton:r=!0})=>{const[n,a]=C.useState(null),o=Pr();if(C.useEffect(()=>{const u=()=>{const f=new Date().getTime(),_=new Date(t).getTime()-f;if(_<=0){a({days:0,hours:0,minutes:0});return}const b=Math.floor(_/(1e3*60*60*24)),w=Math.floor(_%(1e3*60*60*24)/(1e3*60*60)),j=Math.floor(_%(1e3*60*60)/(1e3*60));a({days:b,hours:w,minutes:j})};u();const p=setInterval(u,6e4);return()=>clearInterval(p)},[t]),!n)return null;const l=n.days===0&&n.hours===0&&n.minutes===0,i=n.days<=1,d=n.days<=3&&!i;return l?e.jsxs("div",{className:Pt("flex items-center justify-between gap-3 px-4 py-2 rounded-lg bg-destructive/10 border border-destructive/20",s),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ju,{className:"h-4 w-4 text-destructive"}),e.jsx("span",{className:"text-sm font-medium text-destructive",children:"Your free trial has expired"})]}),r&&e.jsxs(K,{size:"sm",onClick:()=>o("/subscription"),className:"bg-primary hover:bg-primary/90 text-xs h-7 px-3",children:[e.jsx(hn,{className:"h-3 w-3 mr-1"}),"Upgrade Now"]})]}):e.jsxs("div",{className:Pt("flex items-center justify-between gap-3 px-4 py-2 rounded-lg border transition-colors",i?"bg-destructive/10 border-destructive/20":d?"bg-amber-500/10 border-amber-500/20":"bg-primary/10 border-primary/20",s),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Tn,{className:Pt("h-4 w-4",i?"text-destructive":d?"text-amber-500":"text-primary")}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:Pt("text-sm font-medium",i?"text-destructive":d?"text-amber-600":"text-primary"),children:"Free Trial:"}),e.jsxs("div",{className:"flex items-center gap-1",children:[n.days>0&&e.jsxs("span",{className:Pt("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.days,"d"]}),e.jsxs("span",{className:Pt("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),e.jsxs("span",{className:Pt("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),e.jsx("span",{className:Pt("text-xs",i?"text-destructive/70":d?"text-amber-600/70":"text-primary/70"),children:"remaining"})]})]})]}),r&&e.jsxs(K,{size:"sm",onClick:()=>o("/subscription"),variant:i?"destructive":d?"default":"outline",className:Pt("text-xs h-7 px-3",d&&"bg-amber-500 hover:bg-amber-600 text-white"),children:[e.jsx(hn,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},MCt=()=>{const t=Pr();return e.jsx("div",{className:"fixed inset-0 bg-background/95 backdrop-blur-sm z-50 flex items-center justify-center p-4 overflow-y-auto",children:e.jsxs(Ee,{className:"w-full max-w-2xl shadow-2xl border-destructive/20 my-8",children:[e.jsxs(It,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-4 h-16 w-16 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(Ju,{className:"h-8 w-8 text-destructive"})}),e.jsx(Ot,{className:"text-2xl",children:"Your Free Trial Has Ended"}),e.jsx(pr,{className:"text-base",children:"Your 7-day free trial has expired. Upgrade now to continue accessing all the powerful tools and resources LevelUp has to offer!"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsx(Ee,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Oe,{className:"p-5 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(hr,{className:"h-6 w-6 text-primary"})}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"Individual Agent"}),e.jsxs("p",{className:"text-2xl font-bold text-primary mb-2",children:["$39",e.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:"/mo"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Perfect for solo agents ready to level up"}),e.jsxs(K,{className:"w-full",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Choose Individual"]})]})}),e.jsx(Ee,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Oe,{className:"p-5 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(Ta,{className:"h-6 w-6 text-amber-600"})}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"Brokerage"}),e.jsxs("p",{className:"text-2xl font-bold text-amber-600 mb-2",children:["$299",e.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:"/mo"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"For teams and brokerages"}),e.jsxs(K,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Choose Brokerage"]})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"With a full membership, you'll get:"}),e.jsxs("ul",{className:"text-sm space-y-1 text-muted-foreground grid sm:grid-cols-2 gap-x-4",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Unlimited access to all marketing templates"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Complete Academy training library"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," AI-powered tools and resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Community forums and support"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Exclusive member events and workshops"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Deal pipeline & scorecard tracking"]})]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-3",children:[e.jsx("p",{className:"text-sm font-medium text-center",children:"Questions? Contact us:"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-center",children:[e.jsxs("a",{href:"tel:1-866-527-8668",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(Qn,{className:"h-4 w-4"}),e.jsx("span",{children:"1-866-527-8668"})]}),e.jsxs("a",{href:"mailto:support@relevelup.com",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(br,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})]})]})})},TCt=({hasUnseenBrief:t,onClick:s,className:r})=>e.jsxs(Wc,{children:[e.jsx(Gc,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",onClick:s,className:Pt("relative transition-colors",t&&"text-primary hover:text-primary",r),children:[e.jsx(Rm,{className:"h-5 w-5"}),t&&e.jsx("span",{className:"absolute top-1 right-1 h-2 w-2 rounded-full bg-primary animate-pulse"})]})}),e.jsx(Cc,{children:e.jsx("p",{children:"The LevelUp Brief"})})]});var cle="Checkbox",[ACt]=Ec(cle),[ECt,ibe]=ACt(cle);function PCt(t){const{__scopeCheckbox:s,checked:r,children:n,defaultChecked:a,disabled:o,form:l,name:i,onCheckedChange:d,required:u,value:p="on",internal_do_not_use_render:f}=t,[y,_]=vu({prop:r,defaultProp:a??!1,onChange:d,caller:cle}),[b,w]=C.useState(null),[j,k]=C.useState(null),S=C.useRef(!1),T=b?!!l||!!b.closest("form"):!0,I={checked:y,disabled:o,setChecked:_,control:b,setControl:w,name:i,form:l,value:p,hasConsumerStoppedPropagationRef:S,required:u,defaultChecked:v_(a)?!1:a,isFormControl:T,bubbleInput:j,setBubbleInput:k};return e.jsx(ECt,{scope:s,...I,children:ICt(f)?f(I):n})}var qUe="CheckboxTrigger",UUe=C.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:r,...n},a)=>{const{control:o,value:l,disabled:i,checked:d,required:u,setControl:p,setChecked:f,hasConsumerStoppedPropagationRef:y,isFormControl:_,bubbleInput:b}=ibe(qUe,t),w=Ea(a,p),j=C.useRef(d);return C.useEffect(()=>{const k=o==null?void 0:o.form;if(k){const S=()=>f(j.current);return k.addEventListener("reset",S),()=>k.removeEventListener("reset",S)}},[o,f]),e.jsx(Qr.button,{type:"button",role:"checkbox","aria-checked":v_(d)?"mixed":d,"aria-required":u,"data-state":KUe(d),"data-disabled":i?"":void 0,disabled:i,value:l,...n,ref:w,onKeyDown:Mr(s,k=>{k.key==="Enter"&&k.preventDefault()}),onClick:Mr(r,k=>{f(S=>v_(S)?!0:!S),b&&_&&(y.current=k.isPropagationStopped(),y.current||k.stopPropagation())})})});UUe.displayName=qUe;var obe=C.forwardRef((t,s)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d,onCheckedChange:u,form:p,...f}=t;return e.jsx(PCt,{__scopeCheckbox:r,checked:a,defaultChecked:o,disabled:i,required:l,onCheckedChange:u,name:n,form:p,value:d,internal_do_not_use_render:({isFormControl:y})=>e.jsxs(e.Fragment,{children:[e.jsx(UUe,{...f,ref:s,__scopeCheckbox:r}),y&&e.jsx(GUe,{__scopeCheckbox:r})]})})});obe.displayName=cle;var VUe="CheckboxIndicator",HUe=C.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=t,o=ibe(VUe,r);return e.jsx(ud,{present:n||v_(o.checked)||o.checked===!0,children:e.jsx(Qr.span,{"data-state":KUe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});HUe.displayName=VUe;var WUe="CheckboxBubbleInput",GUe=C.forwardRef(({__scopeCheckbox:t,...s},r)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:i,disabled:d,name:u,value:p,form:f,bubbleInput:y,setBubbleInput:_}=ibe(WUe,t),b=Ea(r,_),w=DL(o),j=wL(n);C.useEffect(()=>{const S=y;if(!S)return;const T=window.HTMLInputElement.prototype,L=Object.getOwnPropertyDescriptor(T,"checked").set,R=!a.current;if(w!==o&&L){const $=new Event("click",{bubbles:R});S.indeterminate=v_(o),L.call(S,v_(o)?!1:o),S.dispatchEvent($)}},[y,w,o,a]);const k=C.useRef(v_(o)?!1:o);return e.jsx(Qr.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??k.current,required:i,disabled:d,name:u,value:p,form:f,...s,tabIndex:-1,ref:b,style:{...s.style,...j,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});GUe.displayName=WUe;function ICt(t){return typeof t=="function"}function v_(t){return t==="indeterminate"}function KUe(t){return v_(t)?"indeterminate":t?"checked":"unchecked"}const Bo=C.forwardRef(({className:t,...s},r)=>e.jsx(obe,{ref:r,className:Pt("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(HUe,{className:Pt("flex items-center justify-center text-current"),children:e.jsx(ha,{className:"h-4 w-4"})})}));Bo.displayName=obe.displayName;var lbe="Radio",[LCt,ZUe]=Ec(lbe),[DCt,OCt]=LCt(lbe),YUe=C.forwardRef((t,s)=>{const{__scopeRadio:r,name:n,checked:a=!1,required:o,disabled:l,value:i="on",onCheck:d,form:u,...p}=t,[f,y]=C.useState(null),_=Ea(s,j=>y(j)),b=C.useRef(!1),w=f?u||!!f.closest("form"):!0;return e.jsxs(DCt,{scope:r,checked:a,disabled:l,children:[e.jsx(Qr.button,{type:"button",role:"radio","aria-checked":a,"data-state":eVe(a),"data-disabled":l?"":void 0,disabled:l,value:i,...p,ref:_,onClick:Mr(t.onClick,j=>{a||d==null||d(),w&&(b.current=j.isPropagationStopped(),b.current||j.stopPropagation())})}),w&&e.jsx(JUe,{control:f,bubbles:!b.current,name:n,value:i,checked:a,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});YUe.displayName=lbe;var XUe="RadioIndicator",QUe=C.forwardRef((t,s)=>{const{__scopeRadio:r,forceMount:n,...a}=t,o=OCt(XUe,r);return e.jsx(ud,{present:n||o.checked,children:e.jsx(Qr.span,{"data-state":eVe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s})})});QUe.displayName=XUe;var RCt="RadioBubbleInput",JUe=C.forwardRef(({__scopeRadio:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=C.useRef(null),i=Ea(l,o),d=DL(r),u=wL(s);return C.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==r&&_){const b=new Event("click",{bubbles:n});_.call(p,r),p.dispatchEvent(b)}},[d,r,n]),e.jsx(Qr.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:i,style:{...a.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});JUe.displayName=RCt;function eVe(t){return t?"checked":"unchecked"}var FCt=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],dle="RadioGroup",[zCt]=Ec(dle,[K_,ZUe]),tVe=K_(),sVe=ZUe(),[BCt,$Ct]=zCt(dle),rVe=C.forwardRef((t,s)=>{const{__scopeRadioGroup:r,name:n,defaultValue:a,value:o,required:l=!1,disabled:i=!1,orientation:d,dir:u,loop:p=!0,onValueChange:f,...y}=t,_=tVe(r),b=G_(u),[w,j]=vu({prop:o,defaultProp:a??null,onChange:f,caller:dle});return e.jsx(BCt,{scope:r,name:n,required:l,disabled:i,value:w,onValueChange:j,children:e.jsx(koe,{asChild:!0,..._,orientation:d,dir:b,loop:p,children:e.jsx(Qr.div,{role:"radiogroup","aria-required":l,"aria-orientation":d,"data-disabled":i?"":void 0,dir:b,...y,ref:s})})})});rVe.displayName=dle;var nVe="RadioGroupItem",aVe=C.forwardRef((t,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=t,o=$Ct(nVe,r),l=o.disabled||n,i=tVe(r),d=sVe(r),u=C.useRef(null),p=Ea(s,u),f=o.value===a.value,y=C.useRef(!1);return C.useEffect(()=>{const _=w=>{FCt.includes(w.key)&&(y.current=!0)},b=()=>y.current=!1;return document.addEventListener("keydown",_),document.addEventListener("keyup",b),()=>{document.removeEventListener("keydown",_),document.removeEventListener("keyup",b)}},[]),e.jsx(Soe,{asChild:!0,...i,focusable:!l,active:f,children:e.jsx(YUe,{disabled:l,required:o.required,checked:f,...d,...a,name:o.name,ref:p,onCheck:()=>o.onValueChange(a.value),onKeyDown:Mr(_=>{_.key==="Enter"&&_.preventDefault()}),onFocus:Mr(a.onFocus,()=>{var _;y.current&&((_=u.current)==null||_.click())})})})});aVe.displayName=nVe;var qCt="RadioGroupIndicator",iVe=C.forwardRef((t,s)=>{const{__scopeRadioGroup:r,...n}=t,a=sVe(r);return e.jsx(QUe,{...a,...n,ref:s})});iVe.displayName=qCt;var oVe=rVe,lVe=aVe,UCt=iVe;const cbe=C.forwardRef(({className:t,...s},r)=>e.jsx(oVe,{className:Pt("grid gap-2",t),...s,ref:r}));cbe.displayName=oVe.displayName;const Gne=C.forwardRef(({className:t,...s},r)=>e.jsx(lVe,{ref:r,className:Pt("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(UCt,{className:"flex items-center justify-center",children:e.jsx(Kc,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Gne.displayName=lVe.displayName;const VCt=({brief:t,open:s,onClose:r,onDismiss:n})=>{const{user:a}=Hs(),[o,l]=C.useState({}),[i,d]=C.useState({}),[u,p]=C.useState([]);C.useEffect(()=>{s&&a&&t.polls.length>0&&f()},[s,a,t.polls]);const f=async()=>{if(!a)return;const j=t.polls.map(S=>S.id),{data:k}=await G.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",a.id).in("poll_id",j);if(k){const S={};k.forEach(T=>{S[T.poll_id]||(S[T.poll_id]=[]),S[T.poll_id].push(T.option_id)}),d(S)}},y=(j,k)=>{l(S=>({...S,[j]:k}))},_=(j,k,S)=>{l(T=>{const I=T[j]||[];return S?{...T,[j]:[...I,k]}:{...T,[j]:I.filter(L=>L!==k)}})},b=async j=>{if(!a)return;const k=o[j];if(!k||Array.isArray(k)&&k.length===0){fe.error("Please select an option");return}p(S=>[...S,j]);try{await G.from("levelup_brief_poll_responses").delete().eq("poll_id",j).eq("user_id",a.id);const S=Array.isArray(k)?k:[k],T=S.map(L=>({poll_id:j,option_id:L,user_id:a.id})),{error:I}=await G.from("levelup_brief_poll_responses").insert(T);if(I)throw I;d(L=>({...L,[j]:S})),fe.success("Response submitted!")}catch(S){console.error("Error submitting poll response:",S),fe.error("Failed to submit response")}finally{p(S=>S.filter(T=>T!==j))}},w=j=>(j.includes("mediadelivery.net")||j.includes("bunny"),j);return e.jsx(_s,{open:s,onOpenChange:j=>!j&&r(),children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] p-0 overflow-hidden [&>button]:hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-primary to-primary/80 p-4 pr-12 text-primary-foreground relative",children:[e.jsx("button",{onClick:r,className:"absolute top-3 right-3 p-1.5 rounded-full bg-white/30 hover:bg-white/50 transition-colors","aria-label":"Close",children:e.jsx(Ur,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-white/20 rounded-lg",children:e.jsx(Rm,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx(rt,{variant:"secondary",className:"mb-1 bg-white/20 text-white border-0",children:"The LevelUp Brief"}),e.jsx(ks,{className:"text-xl font-bold text-white",children:t.brief.title})]})]})]}),e.jsx(Ri,{className:"max-h-[calc(90vh-240px)]",children:e.jsxs("div",{className:"p-6 space-y-6",children:[t.brief.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:t.brief.description}}),t.brief.video_url&&e.jsx("div",{className:"relative w-full aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:w(t.brief.video_url),className:"absolute inset-0 w-full h-full",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})}),t.brief.graphic_url&&!t.brief.video_url&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted",children:t.brief.graphic_link_url?e.jsx("a",{href:t.brief.graphic_link_url,target:"_blank",rel:"noopener noreferrer",className:"block",children:e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain cursor-pointer hover:opacity-90 transition-opacity"})}):e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain"})}),t.links.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:"Quick Links"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.links.map(j=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>window.open(j.url,"_blank"),className:"gap-2",children:[e.jsx(sn,{className:"h-4 w-4"}),j.title]},j.id))})]}),t.polls.map(j=>{var T,I;const k=((T=i[j.id])==null?void 0:T.length)>0,S=u.includes(j.id);return e.jsxs("div",{className:"space-y-3 p-4 bg-muted/50 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:j.question}),k&&e.jsxs(rt,{variant:"secondary",className:"gap-1",children:[e.jsx(ua,{className:"h-3 w-3"}),"Responded"]})]}),j.poll_type==="single"?e.jsx(cbe,{value:o[j.id]||((I=i[j.id])==null?void 0:I[0])||"",onValueChange:L=>y(j.id,L),className:"space-y-2",children:j.options.map(L=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Gne,{value:L.id,id:L.id}),e.jsx(ve,{htmlFor:L.id,className:"cursor-pointer",children:L.option_text})]},L.id))}):e.jsx("div",{className:"space-y-2",children:j.options.map(L=>{const $=(o[j.id]||i[j.id]||[]).includes(L.id);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Bo,{id:L.id,checked:$,onCheckedChange:q=>_(j.id,L.id,q)}),e.jsx(ve,{htmlFor:L.id,className:"cursor-pointer",children:L.option_text})]},L.id)})}),e.jsx(K,{size:"sm",onClick:()=>b(j.id),disabled:S,children:S?"Submitting...":k?"Update Response":"Submit"})]},j.id)})]})}),e.jsxs("div",{className:"p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] border-t bg-muted/30 flex flex-col items-center gap-2 sticky bottom-0 z-10",children:[e.jsx(K,{onClick:r,className:"w-full max-w-xs",children:"Got it!"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:n,children:"Don't show again"})]})]})})},HCt=()=>{const{user:t}=Hs(),[s,r]=C.useState(null),[n,a]=C.useState(!1),[o,l]=C.useState(!0),[i,d]=C.useState(!1),u=C.useCallback(async()=>{if(!t){l(!1);return}try{const{data:b,error:w}=await G.from("levelup_briefs").select("*").eq("is_published",!0).lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(1).single();if(w||!b){l(!1);return}const{data:j}=await G.from("levelup_brief_views").select("*").eq("brief_id",b.id).eq("user_id",t.id).maybeSingle(),[k,S]=await Promise.all([G.from("levelup_brief_links").select("*").eq("brief_id",b.id).order("sort_order"),G.from("levelup_brief_polls").select("*").eq("brief_id",b.id).order("sort_order")]),T=[];if(S.data)for(const q of S.data){const{data:U}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",q.id).order("sort_order");T.push({...q,options:U||[]})}const I={brief:b,links:k.data||[],polls:T};r(I);const L=!!j,R=(j==null?void 0:j.dismissed_at)!=null,$=localStorage.getItem(`brief-dismissed-${b.id}`)==="true";if(R||$)d(!1),a(!1);else if(!L)a(!0),d(!0);else if(b.show_frequency==="every_login")a(!0),d(!0);else if(b.show_frequency==="daily"){const q=new Date(j.viewed_at);(new Date().getTime()-q.getTime())/(1e3*60*60)>=24&&(a(!0),d(!0))}else d(!1)}catch(b){console.error("Error fetching brief:",b)}finally{l(!1)}},[t]);C.useEffect(()=>{u()},[u]);const p=async()=>{if(!(!t||!s))try{const{data:b}=await G.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();b?await G.from("levelup_brief_views").update({viewed_at:new Date().toISOString()}).eq("id",b.id):await G.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id})}catch(b){console.error("Error marking brief as viewed:",b)}};return{currentBrief:s,shouldShowPopup:n,hasUnseenBrief:i,loading:o,openBrief:()=>{a(!0)},closeBrief:()=>{a(!1),p()},dismissBrief:async()=>{if(!(!t||!s)){a(!1),d(!1);try{const{data:b,error:w}=await G.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();if(w&&console.error("Error checking existing brief view:",w),b){const{error:j}=await G.from("levelup_brief_views").update({dismissed_at:new Date().toISOString()}).eq("id",b.id).eq("user_id",t.id);j&&console.error("Error updating brief dismiss:",j)}else{const{error:j}=await G.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id,dismissed_at:new Date().toISOString()});j&&console.error("Error inserting brief dismiss:",j)}localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}catch(b){console.error("Error dismissing brief:",b),s&&localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}}},refetch:u}};function WCt(){const[t,s]=C.useState(!1),[r,n]=C.useState(!1),[a,o]=C.useState(null);C.useEffect(()=>{if(localStorage.getItem("install-banner-dismissed")||window.matchMedia("(display-mode: standalone)").matches||!/iPhone|iPad|iPod|Android/i.test(navigator.userAgent))return;const f=/iPhone|iPad|iPod/i.test(navigator.userAgent);n(f),s(!0);const y=_=>{_.preventDefault(),o(_)};return window.addEventListener("beforeinstallprompt",y),()=>{window.removeEventListener("beforeinstallprompt",y)}},[]);const l=()=>{localStorage.setItem("install-banner-dismissed","true"),s(!1)},i=async()=>{if(a){await a.prompt();const{outcome:d}=await a.userChoice;d==="accepted"&&l(),o(null)}};return t?e.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-50 p-4 bg-primary text-primary-foreground shadow-lg animate-in slide-in-from-bottom duration-300",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"flex-shrink-0 p-2 bg-primary-foreground/10 rounded-full",children:e.jsx(xi,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"Add LevelUp to your home screen"}),r?e.jsxs("p",{className:"text-xs opacity-80 flex items-center gap-1",children:["Tap ",e.jsx(FP,{className:"h-3 w-3 inline"}),' then "Add to Home Screen"']}):e.jsx("p",{className:"text-xs opacity-80",children:"Quick access anytime"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!r&&a&&e.jsx(K,{size:"sm",variant:"secondary",onClick:i,className:"text-xs",children:"Install"}),e.jsx("button",{onClick:l,className:"p-1.5 hover:bg-primary-foreground/10 rounded-full transition-colors","aria-label":"Dismiss",children:e.jsx(Ur,{className:"h-4 w-4"})})]})]})}):null}const GCt=({children:t,onRefresh:s})=>{const[r,n]=C.useState(!1),[a,o]=C.useState(0),[l,i]=C.useState(!1),d=C.useRef(null),u=C.useRef(0),p=rs(),f=80,y=120,_=C.useCallback(S=>{const T=d.current;T&&T.scrollTop<=0&&(u.current=S.touches[0].clientY,n(!0))},[]),b=C.useCallback(S=>{if(!r||l)return;const T=d.current;if(!T||T.scrollTop>0){n(!1),o(0);return}const L=S.touches[0].clientY-u.current;if(L>0){const $=Math.min(L*.5,y);o($),$>10&&S.preventDefault()}},[r,l]),w=C.useCallback(async()=>{if(r)if(n(!1),a>=f&&!l){i(!0),o(f);try{s?await s():await p.invalidateQueries()}catch(S){console.error("Refresh failed:",S)}finally{i(!1),o(0)}}else o(0)},[r,a,l,s,p]),j=Math.min(a/f,1),k=j*180;return e.jsxs("div",{ref:d,className:"h-full overflow-auto",onTouchStart:_,onTouchMove:b,onTouchEnd:w,children:[e.jsx("div",{className:"flex justify-center items-center overflow-hidden transition-all duration-200 ease-out",style:{height:a>0?a:0,opacity:j},children:e.jsx("div",{className:`p-2 rounded-full bg-primary/10 ${l?"animate-spin":""}`,style:{transform:l?void 0:`rotate(${k}deg)`,transition:l?void 0:"transform 0.1s ease-out"},children:e.jsx(Po,{className:"h-5 w-5 text-primary"})})}),e.jsx("div",{style:{transform:a>0?`translateY(${Math.max(0,a-60)}px)`:void 0,transition:r?void 0:"transform 0.2s ease-out"},children:t})]})},cVe=()=>{const{user:t}=Hs(),[s,r]=C.useState(!1),[n,a]=C.useState(!1),[o,l]=C.useState(0),[i,d]=C.useState(!0);C.useEffect(()=>{(async()=>{if(!t){d(!1);return}try{const{data:_}=await G.from("membership_reviews").select("id").eq("user_id",t.id).maybeSingle();if(_){a(!0),r(!1),d(!1);return}const{data:b}=await G.from("profiles").select("login_count").eq("id",t.id).single(),w=(b==null?void 0:b.login_count)||0;l(w);const j=sessionStorage.getItem("review-prompt-dismissed");r(w>=4&&!j)}catch(_){console.error("Error checking review eligibility:",_)}finally{d(!1)}})()},[t]);const u=C.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),p=C.useCallback(async(y,_)=>{if(!t)return{success:!1,error:"Not authenticated"};try{const{error:b}=await G.from("membership_reviews").insert({user_id:t.id,rating:y,review_text:_});if(b)throw b;return a(!0),r(!1),{success:!0,pointsAwarded:25}}catch(b){return console.error("Error submitting review:",b),{success:!1,error:b.message}}},[t]),f=C.useCallback(async()=>{if(t)try{await G.from("membership_reviews").update({posted_to_google:!0}).eq("user_id",t.id)}catch(y){console.error("Error updating Google review status:",y)}},[t]);return{shouldShowPrompt:s,hasSubmittedReview:n,loginCount:o,isLoading:i,dismissPrompt:u,submitReview:p,markPostedToGoogle:f}},KCt="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",ZCt=()=>{const{shouldShowPrompt:t,isLoading:s,dismissPrompt:r,submitReview:n,markPostedToGoogle:a}=cVe(),[o,l]=C.useState(!1),[i,d]=C.useState("review"),[u,p]=C.useState(0),[f,y]=C.useState(0),[_,b]=C.useState(""),[w,j]=C.useState(!1),[k,S]=C.useState(!1);if(s||!t&&!k)return null;const T=async()=>{if(u===0){pn({title:"Please select a rating",variant:"destructive"});return}j(!0);const R=await n(u,_);j(!1),R.success?(S(!0),pn({title:"Thank you for your feedback!",description:"Your review helps us improve."}),d("google")):pn({title:"Error submitting review",description:R.error,variant:"destructive"})},I=async R=>{R&&(await navigator.clipboard.writeText(_||`${u} star rating for LevelUp!`),pn({title:"Review copied!",description:"Paste it on Google Reviews."}),await a(),window.open(KCt,"_blank")),l(!1),r()},L=()=>{l(!1),r()};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>l(!0),className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-40 flex items-center gap-2 rounded-full bg-primary/90 px-3 py-2 text-xs text-primary-foreground shadow-lg backdrop-blur-sm transition-all hover:bg-primary hover:scale-105 md:bottom-6",children:[e.jsx(Gn,{className:"h-3.5 w-3.5 fill-current"}),e.jsx("span",{className:"hidden sm:inline",children:"Leave a Review"})]}),e.jsx(_s,{open:o,onOpenChange:L,children:e.jsx(vs,{className:"sm:max-w-md",children:i==="review"?e.jsxs(e.Fragment,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{className:"text-center",children:"How are you enjoying LevelUp?"}),e.jsx(Kr,{className:"text-center",children:"Your feedback helps us improve the experience for all members."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsx("div",{className:"flex justify-center gap-1",children:[1,2,3,4,5].map(R=>e.jsx("button",{type:"button",onClick:()=>p(R),onMouseEnter:()=>y(R),onMouseLeave:()=>y(0),className:"p-1 transition-transform hover:scale-110",children:e.jsx(Gn,{className:Pt("h-8 w-8 transition-colors",(f||u)>=R?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},R))}),e.jsx(Ar,{placeholder:"Tell us about your experience (optional)",value:_,onChange:R=>b(R.target.value),rows:4,className:"resize-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:L,className:"flex-1",children:"Maybe Later"}),e.jsx(K,{onClick:T,disabled:w||u===0,className:"flex-1",children:w?"Submitting...":"Submit Review"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{className:"text-center",children:"🎉 Thank you!"}),e.jsx(Kr,{className:"text-center",children:"Would you mind sharing your review on Google? It really helps other agents discover LevelUp!"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"We'll copy your review so you can easily paste it."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>I(!1),className:"flex-1",children:"No Thanks"}),e.jsx(K,{onClick:()=>I(!0),className:"flex-1",children:"Yes, Open Google"})]})]})]})})})]})};function YCt(t){const s="=".repeat((4-t.length%4)%4),r=(t+s).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),a=new Uint8Array(n.length);for(let o=0;o{if(!f){l(!1);return}(async()=>{try{const w="vapid_public_key";let j=localStorage.getItem(w);if(!j){const{data:T,error:I}=await G.functions.invoke("get-vapid-public-key",{body:{}});if(I)throw I;if(j=(T==null?void 0:T.vapidPublicKey)??null,!j)throw new Error("Missing VAPID public key");localStorage.setItem(w,j)}p(j);const k=await navigator.serviceWorker.register("/push-sw.js");d(k),r(Notification.permission);const S=await k.pushManager.getSubscription();a(!!S)}catch(w){console.error("Error initializing push notifications:",w)}finally{l(!1)}})()},[f]);const y=C.useCallback(async()=>{if(!f||!i||!t)return console.error("Push notifications not supported or user not logged in"),!1;if(!u)return fe.error("Push notifications are not ready yet. Please try again in a moment."),!1;try{l(!0);const b=await i.pushManager.getSubscription();if(b){try{await b.unsubscribe()}catch(I){console.warn("Failed to unsubscribe existing push subscription:",I)}const{error:T}=await G.from("push_subscriptions").delete().eq("user_id",t.id);T&&console.warn("Failed to cleanup push_subscriptions rows:",T)}if(Notification.permission!=="granted"){const T=await Notification.requestPermission();if(r(T),T!=="granted")return T==="denied"?fe.error("Notifications blocked. Please enable them in your browser settings (click the lock icon in the address bar)."):fe.error("Notification permission was dismissed. Please try again."),!1}const w=YCt(u);let j;try{j=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:w})}catch(T){console.error("PushManager.subscribe() failed:",T);const I=(T==null?void 0:T.message)||String(T);return I.includes("permission")?fe.error("Push permission denied. Check your browser notification settings."):I.includes("key")||I.includes("VAPID")?fe.error("Push configuration error. Please contact support."):I.includes("AbortError")?fe.error("Push subscription was cancelled. Please try again."):fe.error(`Failed to subscribe: ${I}`),!1}const k=j.toJSON(),{error:S}=await G.from("push_subscriptions").upsert({user_id:t.id,endpoint:k.endpoint,p256dh_key:k.keys.p256dh,auth_key:k.keys.auth},{onConflict:"user_id,endpoint"});if(S)throw console.error("Error saving subscription:",S),fe.error("Failed to save notification preferences. Please try again."),S;return a(!0),fe.success("Push notifications enabled!"),!0}catch(b){if(console.error("Error subscribing to push notifications:",b),!(b instanceof Error&&b.message.includes("toast"))){const w=b instanceof Error?b.message:"Unknown error";fe.error("Failed to enable push notifications: "+w)}return!1}finally{l(!1)}},[f,i,t,u]),_=C.useCallback(async()=>{if(!i||!t)return!1;try{l(!0);const b=await i.pushManager.getSubscription();return b&&await b.unsubscribe(),await G.from("push_subscriptions").delete().eq("user_id",t.id),a(!1),fe.success("Push notifications disabled"),!0}catch(b){console.error("Error unsubscribing:",b);const w=b instanceof Error?b.message:"Unknown error";return fe.error("Failed to disable push notifications: "+w),!1}finally{l(!1)}},[i,t]);return{isSupported:f,permission:s,isSubscribed:n,isLoading:o,vapidPublicKey:u,subscribe:y,unsubscribe:_}}const gme="push_notification_prompt_dismissed",XCt=()=>{const{user:t}=Hs(),{isSupported:s,isSubscribed:r,isLoading:n,subscribe:a}=dVe(),[o,l]=C.useState(!1),[i,d]=C.useState(!1);C.useEffect(()=>{if(!t||!s||r||n||localStorage.getItem(`${gme}_${t.id}`))return;const y=setTimeout(()=>{l(!0)},2e3);return()=>clearTimeout(y)},[t,s,r,n]);const u=async()=>{d(!0);const f=await a();d(!1),f&&(t&&localStorage.setItem(`${gme}_${t.id}`,"true"),l(!1))},p=()=>{t&&localStorage.setItem(`${gme}_${t.id}`,"true"),l(!1)};return!s||r?null:e.jsx(_s,{open:o,onOpenChange:f=>!f&&p(),children:e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:e.jsx(gf,{className:"h-6 w-6 text-primary"})}),e.jsx(ks,{className:"text-center",children:"Stay in the Loop!"}),e.jsx(Kr,{className:"text-center",children:"Enable push notifications to get alerted when:"})]}),e.jsxs("ul",{className:"my-4 space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," New events go live"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," Fresh templates are added"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," New toolbox resources drop"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," Social swag updates"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," New newsletters arrive"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," Posts in your community groups"]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(K,{onClick:u,disabled:i,className:"w-full",children:i?"Enabling...":"Enable Notifications"}),e.jsx(K,{variant:"ghost",onClick:p,className:"w-full",children:"Not Now"})]}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:"You can always change this in your Profile settings."})]})})},GMe=t=>{let s;const r=new Set,n=(u,p)=>{const f=typeof u=="function"?u(s):u;if(!Object.is(f,s)){const y=s;s=p??(typeof f!="object"||f===null)?f:Object.assign({},s,f),r.forEach(_=>_(s,y))}},a=()=>s,i={setState:n,getState:a,getInitialState:()=>d,subscribe:u=>(r.add(u),()=>r.delete(u))},d=s=t(n,a,i);return i},QCt=t=>t?GMe(t):GMe,JCt=t=>t;function e4t(t,s=JCt){const r=ht.useSyncExternalStore(t.subscribe,ht.useCallback(()=>s(t.getState()),[t,s]),ht.useCallback(()=>s(t.getInitialState()),[t,s]));return ht.useDebugValue(r),r}const KMe=t=>{const s=QCt(t),r=n=>e4t(s,n);return Object.assign(r,s),r},t4t=t=>t?KMe(t):KMe;function s4t(t,s){let r;try{r=t()}catch{return}return{getItem:a=>{var o;const l=d=>d===null?null:JSON.parse(d,void 0),i=(o=r.getItem(a))!=null?o:null;return i instanceof Promise?i.then(l):l(i)},setItem:(a,o)=>r.setItem(a,JSON.stringify(o,void 0)),removeItem:a=>r.removeItem(a)}}const Cxe=t=>s=>{try{const r=t(s);return r instanceof Promise?r:{then(n){return Cxe(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return Cxe(n)(r)}}}},r4t=(t,s)=>(r,n,a)=>{let o={storage:s4t(()=>localStorage),partialize:w=>w,version:0,merge:(w,j)=>({...j,...w}),...s},l=!1;const i=new Set,d=new Set;let u=o.storage;if(!u)return t((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...w)},n,a);const p=()=>{const w=o.partialize({...n()});return u.setItem(o.name,{state:w,version:o.version})},f=a.setState;a.setState=(w,j)=>(f(w,j),p());const y=t((...w)=>(r(...w),p()),n,a);a.getInitialState=()=>y;let _;const b=()=>{var w,j;if(!u)return;l=!1,i.forEach(S=>{var T;return S((T=n())!=null?T:y)});const k=((j=o.onRehydrateStorage)==null?void 0:j.call(o,(w=n())!=null?w:y))||void 0;return Cxe(u.getItem.bind(u))(o.name).then(S=>{if(S)if(typeof S.version=="number"&&S.version!==o.version){if(o.migrate){const T=o.migrate(S.state,S.version);return T instanceof Promise?T.then(I=>[!0,I]):[!0,T]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,S.state];return[!1,void 0]}).then(S=>{var T;const[I,L]=S;if(_=o.merge(L,(T=n())!=null?T:y),r(_,!0),I)return p()}).then(()=>{k==null||k(_,void 0),_=n(),l=!0,d.forEach(S=>S(_))}).catch(S=>{k==null||k(void 0,S)})};return a.persist={setOptions:w=>{o={...o,...w},w.storage&&(u=w.storage)},clearStorage:()=>{u==null||u.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>b(),hasHydrated:()=>l,onHydrate:w=>(i.add(w),()=>{i.delete(w)}),onFinishHydration:w=>(d.add(w),()=>{d.delete(w)})},o.skipHydration||b(),_||y},n4t=r4t,ule=t4t()(n4t((t,s)=>({cartItems:[],addToCart:(r,n,a=1,o)=>{t(l=>{const i=l.cartItems.findIndex(d=>{var u;return d.product.id===r.id&&((u=d.variant)==null?void 0:u.id)===(n==null?void 0:n.id)});if(i>=0){const d=[...l.cartItems];return d[i].quantity+=a,o&&(d[i].artworkUrl=o),{cartItems:d}}return{cartItems:[...l.cartItems,{product:r,variant:n,quantity:a,artworkUrl:o}]}})},removeFromCart:(r,n)=>{t(a=>({cartItems:a.cartItems.filter(o=>{var l;return!(o.product.id===r&&((l=o.variant)==null?void 0:l.id)===n)})}))},updateQuantity:(r,n,a)=>{t(o=>({cartItems:o.cartItems.map(l=>{var i;return l.product.id===r&&((i=l.variant)==null?void 0:i.id)===n?{...l,quantity:Math.max(1,a)}:l})}))},updateArtwork:(r,n,a)=>{t(o=>({cartItems:o.cartItems.map(l=>{var i;return l.product.id===r&&((i=l.variant)==null?void 0:i.id)===n?{...l,artworkUrl:a}:l})}))},clearCart:()=>t({cartItems:[]}),getItemPrice:r=>{const n=Number(r.product.base_price),a=r.variant?Number(r.variant.price_adjustment):0;return n+a},getSubtotal:()=>{const{cartItems:r,getItemPrice:n}=s();return r.reduce((a,o)=>a+n(o)*o.quantity,0)},getShippingTotal:()=>{const{cartItems:r}=s();return r.reduce((n,a)=>n+Number(a.product.shipping_fee)*a.quantity,0)},getTotal:()=>{const{getSubtotal:r,getShippingTotal:n}=s();return r()+n()}}),{name:"marketplace-cart",partialize:t=>({cartItems:t.cartItems})})),uVe=C.createContext({onlineUsers:[],totalOnline:0}),a4t=async t=>{try{const{data:s}=await G.storage.from("avatars").list(`${t}`);if(s&&s.length>0){const{data:r}=G.storage.from("avatars").getPublicUrl(`${t}/${s[0].name}`);return r.publicUrl}}catch{}},i4t=({children:t})=>{const{user:s,brokerageId:r,isAdmin:n}=Hs(),[a,o]=C.useState([]),[l,i]=C.useState(null);C.useEffect(()=>{if(!s)return;const u=G.channel("app-presence",{config:{presence:{key:s.id}}});return u.on("presence",{event:"sync"},()=>{const p=u.presenceState(),f=[];Object.entries(p).forEach(([y,_])=>{if(_&&_.length>0){const b=_[0];f.push({id:y,name:b.name||"Unknown",avatarUrl:b.avatarUrl,brokerageId:b.brokerageId,onlineSince:b.onlineSince})}}),o(f)}).on("presence",{event:"join"},()=>{}).on("presence",{event:"leave"},()=>{}).subscribe(async p=>{var f;if(p==="SUBSCRIBED"){const{data:y}=await G.from("profiles").select("name, brokerage_id").eq("id",s.id).single(),_=await a4t(s.id);await u.track({name:(y==null?void 0:y.name)||((f=s.email)==null?void 0:f.split("@")[0])||"User",avatarUrl:_,brokerageId:y==null?void 0:y.brokerage_id,onlineSince:new Date().toISOString()})}}),i(u),()=>{u.unsubscribe()}},[s]);const d=a.filter(u=>u.id===(s==null?void 0:s.id)?!1:!!(n||r&&u.brokerageId===r||!r&&!u.brokerageId));return e.jsx(uVe.Provider,{value:{onlineUsers:d,totalOnline:a.length},children:t})},hVe=()=>C.useContext(uVe),ZMe="dashboard-sidebar-collapsed",Ts=({children:t,title:s})=>{var Ue;const{user:r,signOut:n,isAdmin:a,isBrokerageManager:o,brokerageId:l}=Hs(),{isAssistant:i,actingAsAgent:d,hasPermission:u}=$1e(),{isImpersonating:p}=B1e(),y=(i&&!!d?40:0)+(p?40:0),{avatarUrl:_}=dUe(r==null?void 0:r.id),{isTrial:b,isExpired:w,expiresAt:j}=gSt(r==null?void 0:r.id),{isMarketplaceEnabled:k}=hUe(),{currentBrief:S,shouldShowPopup:T,hasUnseenBrief:I,openBrief:L,closeBrief:R,dismissBrief:$}=HCt(),{unreadCount:q}=xSt(),{openCount:U}=ySt(),{data:H}=Lf(),Y=!!H,te=ule(ut=>ut.cartItems).reduce((ut,De)=>ut+De.quantity,0),Q=Pr(),de=bu(),[re,ae]=C.useState(null);C.useEffect(()=>{r!=null&&r.id&&G.from("profiles").select("name").eq("id",r.id).single().then(({data:ut})=>{ut!=null&&ut.name&&ae(ut.name)})},[r==null?void 0:r.id]);const le=re||((Ue=r==null?void 0:r.user_metadata)==null?void 0:Ue.name)||(r==null?void 0:r.email)||"User",[he,be]=C.useState(()=>typeof window<"u"?localStorage.getItem(ZMe)==="true":!1);C.useEffect(()=>{localStorage.setItem(ZMe,String(he))},[he]);const[_e,je]=C.useState({agentos:!0,tools:!0,marketing:!0,learning:!0,community:!0,contacts:!0,help:!1}),Ne=ut=>{je(De=>({...De,[ut]:!De[ut]}))},Ge=ut=>ut.split(" ").map(De=>De[0]).join("").toUpperCase().slice(0,2),we=ut=>de.pathname===ut,Me=ut=>ut.some(De=>de.pathname===De),Te=({path:ut,icon:De,label:Rt,badgeCount:me})=>{const Xe=e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",we(ut)&&"bg-sidebar-accent text-sidebar-accent-foreground",he?"w-10 h-10 p-0 justify-center":"w-full justify-start gap-2"),onClick:()=>Q(ut),children:[e.jsxs("div",{className:"relative",children:[e.jsx(De,{className:"h-4 w-4 shrink-0"}),he&&me!=null&&me>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]}),!he&&Rt,!he&&me!=null&&me>0&&e.jsx("span",{className:"ml-auto flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:me>9?"9+":me})]});return he?e.jsxs(Wc,{delayDuration:0,children:[e.jsx(Gc,{asChild:!0,children:Xe}),e.jsxs(Cc,{side:"right",className:"flex items-center gap-2",children:[Rt,me!=null&&me>0&&e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:me>9?"9+":me})]})]}):Xe},Fe=({id:ut,label:De,icon:Rt,children:me,activePaths:Xe,showBetaBadge:ot,defaultPath:nt,badgeCount:Se})=>{if(he){const it=nt||Xe[0];return e.jsxs(Wc,{delayDuration:0,children:[e.jsx(Gc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:Pt("w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",Me(Xe)&&"text-primary"),onClick:()=>Q(it),children:e.jsxs("div",{className:"relative",children:[e.jsx(Rt,{className:"h-4 w-4"}),Se!=null&&Se>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]})})}),e.jsxs(Cc,{side:"right",className:"flex items-center gap-2",children:[De,ot&&e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600",children:"Beta"}),Se!=null&&Se>0&&e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:Se>9?"9+":Se})]})]})}return e.jsxs(bf,{open:_e[ut],onOpenChange:()=>Ne(ut),children:[e.jsx(wf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me(Xe)&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2 font-semibold text-[15px]",children:[e.jsx(Rt,{className:"h-4 w-4"}),De,ot&&e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("span",{className:"flex items-center gap-1",children:[Se!=null&&Se>0&&e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:Se>9?"9+":Se}),e.jsx(Ho,{className:Pt("h-4 w-4 transition-transform duration-200",_e[ut]&&"rotate-180")})]})]})}),e.jsx(jf,{className:"pl-4 space-y-1 mt-1",children:me})]})},Ae=({isMobile:ut=!1})=>{const De=ut?!1:he;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:Pt("p-3 border-b border-sidebar-border",De?"flex flex-col items-center gap-2":"flex items-center justify-between"),children:[De?e.jsx("img",{src:SSt,alt:"LevelUp",className:"h-8 w-auto"}):e.jsx("img",{src:kSt,alt:"LevelUp",className:"h-8 w-auto"}),!ut&&e.jsxs(Wc,{delayDuration:0,children:[e.jsx(Gc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>be(!De),children:e.jsx(zl,{className:Pt("h-4 w-4 transition-transform duration-300",De&&"rotate-180")})})}),e.jsx(Cc,{side:"right",children:De?"Expand sidebar":"Collapse sidebar"})]})]}),e.jsx(Ri,{className:"flex-1 [&_[data-radix-scroll-area-scrollbar]]:w-1.5",children:e.jsxs("nav",{className:Pt("p-3 space-y-1",De&&"flex flex-col items-center"),children:[e.jsx(Te,{path:"/dashboard",icon:dk,label:"Dashboard"}),e.jsx(Te,{path:"/apps",icon:Yp,label:"Apps & Tools"}),he?e.jsxs(Wc,{delayDuration:0,children:[e.jsx(Gc,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-10 h-10 p-0 justify-center relative text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",we("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/levelup-u"),children:[e.jsx(ah,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 h-2 w-2 rounded-full bg-primary animate-pulse"})]})}),e.jsxs(Cc,{side:"right",className:"flex items-center gap-2",children:["LevelUp U",e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-primary-foreground bg-primary rounded px-1 py-0.5",children:"New"})]})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",we("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/levelup-u"),children:[e.jsx(ah,{className:"h-4 w-4 shrink-0"}),"LevelUp U",e.jsx("span",{className:"ml-auto text-[10px] font-bold uppercase tracking-wider text-primary-foreground bg-primary rounded px-1.5 py-0.5",children:"New"})]}),e.jsx(Te,{path:"/events",icon:id,label:"Events"}),e.jsxs(Fe,{id:"agentos",label:"Agent OS",icon:m5,activePaths:["/mission-control","/mission-control/contacts","/mission-control/plans","/mission-control/popbys","/mission-control/video-library","/mission-control/scorecard","/mission-control/listings","/mission-control/pipeline","/mission-control/tasks","/mission-control/smart-drips","/mission-control/relationship-scorecard","/mission-control/sphere-gaps","/mission-control/connect-page"],showBetaBadge:!0,defaultPath:"/mission-control",children:[u("contacts")&&e.jsx(Te,{path:"/mission-control",icon:Si,label:"Mission Control"}),u("contacts")&&!De&&e.jsxs(bf,{open:_e.contacts,onOpenChange:()=>Ne("contacts"),children:[e.jsx(wf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me(["/mission-control/contacts","/mission-control/relationship-scorecard","/mission-control/sphere-gaps","/mission-control/connect-page"])&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Contacts"]}),e.jsx(Ho,{className:Pt("h-3.5 w-3.5 transition-transform duration-200",_e.contacts&&"rotate-180")})]})}),e.jsxs(jf,{className:"pl-4 pr-1 space-y-0.5 mt-0.5",children:[e.jsx(Te,{path:"/mission-control/contacts",icon:hr,label:"All Contacts"}),e.jsx(Te,{path:"/mission-control/relationship-scorecard",icon:Pm,label:"Relationship Report"}),e.jsx(Te,{path:"/mission-control/sphere-gaps",icon:OP,label:"Sphere Gaps"}),e.jsx(Te,{path:"/mission-control/connect-page",icon:Wo,label:"Connect Page"})]})]}),u("contacts")&&De&&e.jsx(Te,{path:"/mission-control/contacts",icon:hr,label:"Contacts"}),u("contacts")&&e.jsx(Te,{path:"/mission-control/plans",icon:id,label:"TouchPlans"}),u("pipeline")&&e.jsx(Te,{path:"/mission-control/pipeline",icon:Xx,label:"Deal Pipeline"}),u("pipeline")&&e.jsx(Te,{path:"/mission-control/tasks",icon:g0,label:"Tasks"}),u("popbys")&&e.jsx(Te,{path:"/mission-control/popbys",icon:po,label:"Popbys"}),u("videos")&&e.jsx(Te,{path:"/mission-control/video-library",icon:Nn,label:"Video Library"}),u("scorecard")&&e.jsx(Te,{path:"/mission-control/scorecard",icon:ol,label:"Scorecard"}),u("listings")&&e.jsx(Te,{path:"/mission-control/listings",icon:Ta,label:"Listing Exchange"}),!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",we("/mission-control/smart-drips")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/mission-control/smart-drips"),children:[e.jsx(Fm,{className:"h-4 w-4"}),"Smart Drips",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),De&&e.jsx(Te,{path:"/mission-control/smart-drips",icon:Fm,label:"Smart Drips"})]}),e.jsxs(Fe,{id:"marketing",label:"Marketing",icon:Rm,activePaths:["/templates","/social-swag-2","/newsletters"],defaultPath:"/templates",children:[e.jsx(Te,{path:"/templates",icon:Bl,label:"Templates"}),e.jsx(Te,{path:"/social-swag-2",icon:U0,label:"Social Swag"}),e.jsx(Te,{path:"/newsletters",icon:z0,label:"Newsletters"})]}),e.jsxs(Fe,{id:"learning",label:"Learning",icon:Fu,activePaths:["/academy","/toolbox"],defaultPath:"/academy",children:[e.jsx(Te,{path:"/academy",icon:ah,label:"Academy"}),e.jsx(Te,{path:"/toolbox",icon:Wg,label:"Toolbox"})]}),e.jsxs(Fe,{id:"community",label:"Community",icon:io,activePaths:["/community","/wishlist"],defaultPath:"/community",badgeCount:q,children:[e.jsx(Te,{path:"/community",icon:hr,label:"Community",badgeCount:q}),e.jsx(Te,{path:"/wishlist",icon:l_,label:"Wishlist",badgeCount:U}),!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open("https://www.facebook.com/share/g/1CC6thti2V/","_blank"),children:[e.jsx(sn,{className:"h-4 w-4"}),"Facebook Group"]})]}),e.jsxs(Fe,{id:"goods",label:"The Goods",icon:Sm,activePaths:["/marketplace","/reward-store"],defaultPath:"/reward-store",children:[k&&!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",de.pathname.startsWith("/marketplace")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/marketplace"),children:[e.jsx(Sm,{className:"h-4 w-4"}),"Marketplace",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1.5 py-0.5 rounded-full bg-primary text-primary-foreground",children:"New"})]}),k&&De&&e.jsx(Te,{path:"/marketplace",icon:Sm,label:"Marketplace"}),e.jsx(Te,{path:"/reward-store",icon:ao,label:"Reward Store"})]}),e.jsxs(Fe,{id:"help",label:"Help & Services",icon:h0,activePaths:["/support","/additional-services"],defaultPath:"/support",children:[e.jsx(Te,{path:"/support",icon:b5,label:"Support"}),e.jsx(Te,{path:"/additional-services",icon:hn,label:"Additional Services"})]}),a&&e.jsxs(e.Fragment,{children:[!De&&e.jsx("div",{className:"pt-3 pb-1",children:e.jsx("p",{className:"px-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Admin"})}),De?e.jsx("div",{className:"pt-3 border-t border-sidebar-border mt-3 space-y-1",children:e.jsx(Te,{path:"/admin",icon:$u,label:"Admin Dashboard"})}):e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",de.pathname==="/admin"&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/admin"),children:[e.jsx($u,{className:"h-4 w-4"}),"Admin Dashboard"]})]}),(l||o)&&!a&&e.jsxs(e.Fragment,{children:[!De&&e.jsx("div",{className:"pt-3 pb-1",children:e.jsx("p",{className:"px-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"My Brokerage"})}),De?e.jsxs("div",{className:"border-t border-sidebar-border mt-3 pt-3 space-y-1",children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{path:"/my-brokerage",icon:Ta,label:"My Brokerage"}),e.jsx(Te,{path:"/brokerage-content",icon:Fu,label:"Brokerage Content"})]}),Y&&!o&&e.jsx(Te,{path:"/my-team",icon:hr,label:"My Team"}),o&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{path:"/brokerage/dashboard",icon:$l,label:"Manage Brokerages"}),e.jsx(Te,{path:"/brokerage/teams",icon:hr,label:"Teams"}),e.jsx(Te,{path:"/brokerage-resources",icon:rh,label:"Brokerage Resources"})]})]}):e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",we("/my-brokerage")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/my-brokerage"),children:[e.jsx(Ta,{className:"h-4 w-4"}),"My Brokerage"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",we("/brokerage-content")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/brokerage-content"),children:[e.jsx(Fu,{className:"h-4 w-4"}),"Brokerage Content"]})]}),Y&&!o&&e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",we("/my-team")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/my-team"),children:[e.jsx(hr,{className:"h-4 w-4"}),"My Team"]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",we("/brokerage/dashboard")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/brokerage/dashboard"),children:[e.jsx($l,{className:"h-4 w-4"}),"Manage Brokerages"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",we("/brokerage/teams")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/brokerage/teams"),children:[e.jsx(hr,{className:"h-4 w-4"}),"Teams",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"New"})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",we("/brokerage-resources")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/brokerage-resources"),children:[e.jsx(rh,{className:"h-4 w-4"}),"Brokerage Resources"]})]})]})]})]})}),e.jsxs("div",{className:"p-3 border-t border-sidebar-border md:hidden",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",we("/profile")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/profile"),children:[e.jsx(Yi,{className:"h-4 w-4"}),"Profile"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:n,children:[e.jsx(j5,{className:"h-4 w-4"}),"Sign Out"]})]})]})};return e.jsx(i4t,{children:e.jsx(U_,{children:e.jsxs("div",{className:"min-h-screen bg-background flex",children:[b&&w&&e.jsx(MCt,{}),typeof document<"u"&&km.createPortal(e.jsx("aside",{className:Pt("hidden md:flex flex-col bg-card border-r border-border fixed left-0 z-30 !pointer-events-auto transition-[width] duration-300",he?"w-16":"w-56"),style:{top:`${y}px`,height:`calc(100vh - ${y}px)`},children:e.jsx(Ae,{})}),document.body),e.jsxs("div",{className:Pt("flex-1 flex flex-col overflow-hidden transition-all duration-300",he?"md:ml-16":"md:ml-56"),style:{height:`calc(100vh - ${y}px)`,marginTop:`${y}px`},children:[e.jsx("header",{className:"sticky top-0 z-40 bg-card border-b border-border flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between px-6 py-3",children:[e.jsxs(MM,{children:[e.jsx(K_e,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"md:hidden",children:e.jsx(wP,{className:"h-5 w-5"})})}),e.jsx(cS,{side:"left",className:"w-56 p-0 bg-card",children:e.jsx(Ae,{isMobile:!0})})]}),e.jsx("div",{className:"flex-1 md:hidden",children:e.jsx("img",{src:CSt,alt:"LevelUp",className:"h-8 w-auto"})}),e.jsx("div",{className:"hidden md:flex flex-1 justify-center",children:e.jsx(WMe,{})}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[b&&!w&&j&&e.jsx(CCt,{expiresAt:j,className:"hidden lg:flex"}),e.jsx("div",{className:"md:hidden",children:e.jsx(WMe,{})}),S&&e.jsx(TCt,{hasUnseenBrief:I,onClick:L}),k&&e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",onClick:()=>Q("/marketplace/cart"),children:[e.jsx(Sm,{className:"h-5 w-5"}),te>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-5 w-5 rounded-full bg-primary text-primary-foreground text-xs font-medium flex items-center justify-center",children:te>99?"99+":te})]}),e.jsx(JSt,{}),e.jsx(Nxe,{}),e.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",le.split(" ")[0],"!"]}),e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx("button",{className:"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded-full",children:e.jsxs(xn,{className:"h-9 w-9 cursor-pointer hover:opacity-80 transition-opacity",children:[e.jsx(Aa,{src:_||void 0}),e.jsx(yn,{className:"bg-primary text-primary-foreground font-medium text-sm",children:Ge(le)})]})})}),e.jsxs(Md,{align:"end",className:"w-48",children:[e.jsxs(Na,{onClick:()=>Q("/profile"),className:"cursor-pointer",children:[e.jsx(Yi,{className:"h-4 w-4 mr-2"}),"Profile"]}),e.jsxs(Na,{onClick:()=>Q("/mission-control/integrations"),className:"cursor-pointer",children:[e.jsx(MP,{className:"h-4 w-4 mr-2"}),"Integrations"]}),e.jsx(E_,{}),e.jsxs(Na,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[e.jsx(j5,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),e.jsx(GCt,{children:e.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),S&&e.jsx(VCt,{brief:S,open:T,onClose:R,onDismiss:$}),e.jsx(WCt,{}),e.jsx(ZCt,{}),e.jsx(XCt,{})]})]})})})},o4t=()=>{const{user:t}=Hs(),[s,r]=C.useState(!1),[n,a]=C.useState(null),[o,l]=C.useState(""),i=async f=>{var y;if(!(t!=null&&t.email)){fe.error("Please sign in to upgrade");return}r(!0),a(f);try{const{data:_,error:b}=await G.functions.invoke("create-checkout",{body:{tier:f,email:t.email,name:((y=t.user_metadata)==null?void 0:y.full_name)||t.email,couponCode:o.trim()||void 0,skipTrial:!0}});if(b)throw b;if(_!=null&&_.url)window.open(_.url,"_blank","noopener,noreferrer"),fe.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(_){console.error("Checkout error:",_),fe.error(_.message||"Failed to start checkout. Please try again.")}finally{r(!1),a(null)}},d=["Unlimited access to all marketing templates","Complete Academy training library","AI-powered tools and resources","Community forums and support","Exclusive member events and workshops","Deal pipeline & scorecard tracking","Listing exchange access","Social media content library"],u=["Everything in Individual plan","Up to 25 agent seats","Brokerage admin dashboard","Team performance analytics","Custom branding options","Priority support","Agent onboarding tools","Brokerage-wide announcements"],p=["Everything in Brokerage plan","Unlimited agent seats","Dedicated account manager","Advanced analytics & reporting","White-label options","API access","Custom integrations","Enterprise-level support"];return e.jsx(Ts,{children:e.jsxs("div",{className:"container max-w-6xl py-8 px-4",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold mb-2",children:"Upgrade Your Membership"}),e.jsx("p",{className:"text-muted-foreground text-lg",children:"Choose the plan that's right for you and unlock the full power of LevelUp"})]}),e.jsxs("div",{className:"max-w-md mx-auto mb-8",children:[e.jsx(ve,{htmlFor:"coupon",className:"text-sm font-medium",children:"Have a discount code?"}),e.jsx(Re,{id:"coupon",placeholder:"Enter discount code",value:o,onChange:f=>l(f.target.value),className:"mt-1"})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6 mb-8",children:[e.jsxs(Ee,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 bg-primary text-primary-foreground text-xs px-3 py-1 rounded-bl-lg font-medium",children:"Popular"}),e.jsxs(It,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(hr,{className:"h-7 w-7 text-primary"})}),e.jsx(Ot,{className:"text-xl",children:"Individual Agent"}),e.jsx(pr,{children:"Perfect for solo agents ready to level up"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-primary",children:"$39"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:d.map((f,y)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ha,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},y))}),e.jsxs(K,{className:"w-full",size:"lg",onClick:()=>i("individual_agent"),disabled:s,children:[s&&n==="individual_agent"?e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Ee,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors",children:[e.jsxs(It,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(Ta,{className:"h-7 w-7 text-amber-600"})}),e.jsx(Ot,{className:"text-xl",children:"Brokerage"}),e.jsx(pr,{children:"For teams and brokerages up to 25 agents"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-amber-600",children:"$299"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:u.map((f,y)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ha,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},y))}),e.jsxs(K,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",size:"lg",onClick:()=>i("brokerage_under_25"),disabled:s,children:[s&&n==="brokerage_under_25"?e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Ee,{className:"border-2 border-purple-500/20 hover:border-purple-500/50 transition-colors",children:[e.jsxs(It,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-purple-500/10 flex items-center justify-center",children:e.jsx(Ta,{className:"h-7 w-7 text-purple-600"})}),e.jsx(Ot,{className:"text-xl",children:"Brokerage 25+"}),e.jsx(pr,{children:"For larger brokerages with 25+ agents"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-purple-600",children:"$499"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:p.map((f,y)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ha,{className:"h-4 w-4 text-purple-600 mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},y))}),e.jsxs(K,{variant:"outline",className:"w-full border-purple-500 text-purple-600 hover:bg-purple-50",size:"lg",onClick:()=>i("brokerage_over_25"),disabled:s,children:[s&&n==="brokerage_over_25"?e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]})]}),e.jsx(Ee,{className:"bg-muted/50",children:e.jsxs(Oe,{className:"py-6",children:[e.jsx("p",{className:"text-center font-medium mb-4",children:"Questions? We're here to help!"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs("a",{href:"tel:1-866-527-8668",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(Qn,{className:"h-4 w-4"}),e.jsx("span",{children:"1-866-527-8668"})]}),e.jsxs("a",{href:"mailto:support@relevelup.com",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(br,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})})]})})},l4t=()=>{const{user:t,loading:s,isBrokerageManager:r,brokerageId:n}=Hs(),a=Pr(),[o,l]=C.useState(""),[i,d]=C.useState(!1),[u,p]=C.useState(!1);C.useEffect(()=>{!s&&!t&&a("/auth")},[t,s,a]),C.useEffect(()=>{!s&&t&&n&&a("/profile?setup=true")},[t,s,n,a]);const f=async()=>{if(!o.trim()){fe.error("Please enter a brokerage name");return}const{data:y}=await G.auth.getSession(),_=y.session;if(!t||!_){fe.error("Please sign in again to create your brokerage."),a("/auth");return}d(!0);try{console.log("[SetupBrokerage] Creating brokerage…",{hasUser:!!t,hasSession:!!_,userId:t==null?void 0:t.id});const{data:b,error:w}=await G.functions.invoke("create-brokerage",{body:{name:o.trim()}});if(console.log("[SetupBrokerage] create-brokerage response",{data:b,error:w}),w)throw w;if(!(b!=null&&b.ok))throw new Error((b==null?void 0:b.error)||"Failed to create brokerage");d(!1),p(!0),fe.success("Brokerage created! Setting up your account..."),setTimeout(()=>{a("/profile?setup=true")},2e3)}catch(b){console.error("Error creating brokerage:",b),fe.error(b.message||"Failed to create brokerage"),d(!1)}};return s?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):u?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Ee,{className:"max-w-lg w-full",children:[e.jsxs(It,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(Ms,{className:"w-10 h-10 text-primary animate-spin"})}),e.jsx(Ot,{className:"text-2xl",children:"Setting Up Your Brokerage"}),e.jsx(pr,{className:"text-lg",children:"We're assigning you as the brokerage manager and preparing your dashboard..."})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(hi,{className:"w-5 h-5 text-green-500"}),e.jsx("span",{children:"Brokerage created"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(Ms,{className:"w-5 h-5 animate-spin text-primary"}),e.jsx("span",{children:"Assigning you as manager..."})]}),e.jsx("p",{className:"text-center text-sm text-muted-foreground mt-4",children:"You'll be redirected to complete your profile setup in a moment."})]})]})}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Ee,{className:"max-w-lg w-full",children:[e.jsxs(It,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(Ta,{className:"w-10 h-10 text-primary"})}),e.jsx(Ot,{className:"text-2xl",children:"Set Up Your Brokerage"}),e.jsx(pr,{className:"text-lg",children:"Create your brokerage to start managing your team"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(Re,{id:"brokerage-name",placeholder:"Enter your brokerage name",value:o,onChange:y=>l(y.target.value),onKeyDown:y=>y.key==="Enter"&&f()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This is how your brokerage will appear to your agents"})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-muted/50 space-y-3",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(hr,{className:"w-4 h-4 text-primary"}),"What you can do as a Brokerage Manager:"]}),e.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(hi,{className:"w-4 h-4 text-green-500"}),"Invite agents to join your brokerage"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(hi,{className:"w-4 h-4 text-green-500"}),"Access exclusive brokerage resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(hi,{className:"w-4 h-4 text-green-500"}),"Track your team's activity and engagement"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(hi,{className:"w-4 h-4 text-green-500"}),"Share resources with your agents"]})]})]}),e.jsxs(K,{onClick:f,className:"w-full",disabled:i||!o.trim(),children:[i?"Creating...":"Create Brokerage",e.jsx($i,{className:"w-4 h-4 ml-2"})]})]})]})})},YMe=()=>{const t=Pr(),[s,r]=C.useState("verifying"),[n,a]=C.useState("");C.useEffect(()=>{(async()=>{try{const{data:{session:i},error:d}=await G.auth.getSession();if(d)throw d;if(i!=null&&i.user){const{data:u}=await G.from("profiles").select("login_count").eq("id",i.user.id).single();if(((u==null?void 0:u.login_count)||0)>1){console.log("Account already claimed, redirecting to dashboard"),r("already_claimed");return}console.log("User logged in successfully:",i.user.email),r("success");try{await G.functions.invoke("trial-claim-hook",{body:{userId:i.user.id}})}catch(p){console.log("Trial claim hook (non-critical):",p)}setTimeout(()=>{t("/profile?setup=true")},1500)}else setTimeout(()=>{r("already_claimed")},2e3)}catch(i){console.error("Claim error:",i),r("already_claimed")}})()},[t]);const o=()=>{window.location.href="https://dashboard.relevelup.com/auth"};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(It,{className:"space-y-1 text-center",children:[e.jsxs("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-primary/10",children:[s==="verifying"&&e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),s==="success"&&e.jsx("svg",{className:"h-8 w-8 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),s==="already_claimed"&&e.jsx("svg",{className:"h-8 w-8 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),s==="error"&&e.jsx("svg",{className:"h-8 w-8 text-destructive",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]}),e.jsxs(Ot,{className:"text-2xl",children:[s==="verifying"&&"Claiming Your Account...",s==="success"&&"Account Claimed!",s==="already_claimed"&&"Account Already Claimed",s==="error"&&"Claim Failed"]}),e.jsxs(pr,{children:[s==="verifying"&&"Please wait while we verify your account...",s==="success"&&"Redirecting you to complete your profile...",s==="already_claimed"&&"This account has already been set up. Please log in to access your dashboard.",s==="error"&&n]})]}),(s==="already_claimed"||s==="error")&&e.jsx(Oe,{children:e.jsx(K,{onClick:o,className:"w-full",children:"Go to Login"})})]})})},c4t=()=>{const t=Pr(),[s]=Pc(),[r,n]=C.useState(s.get("code")||""),[a,o]=C.useState(""),[l,i]=C.useState(""),[d,u]=C.useState(""),[p,f]=C.useState(!1),[y,_]=C.useState(!1),[b,w]=C.useState(!1),[j,k]=C.useState(!1),[S,T]=C.useState(null),[I,L]=C.useState(null),[R,$]=C.useState(null),[q,U]=C.useState(null);C.useEffect(()=>{const te=s.get("code");te&&(n(te),H(te))},[s]);const H=async te=>{w(!0);const{data:Q,error:de}=await G.from("invite_codes").select("id, code, max_uses, uses_count, expires_at, is_active, brokerage_id, trial_days").eq("code",te.toUpperCase().trim()).single();if(de||!Q){fe.error("Invalid invite code"),w(!1);return}if(!Q.is_active){fe.error("This invite code is no longer active"),w(!1);return}if(Q.max_uses&&Q.uses_count>=Q.max_uses){fe.error("This invite code has reached its maximum uses"),w(!1);return}if(Q.expires_at&&new Date(Q.expires_at){te.preventDefault(),H(r)},se=async te=>{var Q;if(te.preventDefault(),!d.trim()){fe.error("Please enter your name");return}if(l.length<6){fe.error("Password must be at least 6 characters");return}_(!0);try{const de=`${window.location.origin}/`,{data:re,error:ae}=await G.auth.signUp({email:a.trim(),password:l,options:{emailRedirectTo:de,data:{name:d.trim()}}});if(ae){ae.message.includes("already registered")?fe.error("This email is already registered. Please sign in instead."):fe.error(ae.message);return}re.user&&(await G.rpc("add_default_signup_tag",{user_id:re.user.id}),I?await G.functions.invoke("assign-brokerage",{body:{userId:re.user.id,brokerageId:I}}):q?await G.functions.invoke("assign-brokerage",{body:{userId:re.user.id,trialDays:q}}):await G.functions.invoke("assign-brokerage",{body:{userId:re.user.id,grandfathered:!0}}),S&&await G.from("invite_codes").update({uses_count:((Q=(await G.from("invite_codes").select("uses_count").eq("id",S).single()).data)==null?void 0:Q.uses_count)+1}).eq("id",S),fe.success("Account created! You can now access the dashboard."),t("/dashboard"))}catch(de){console.error("Signup error:",de),fe.error("An unexpected error occurred")}finally{_(!1)}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(It,{className:"text-center",children:[e.jsx(Ot,{className:"text-2xl font-bold text-primary",children:R?`Join ${R}`:"Join LevelUp"}),e.jsx(pr,{children:j?R?`Create your account to join ${R}`:"Create your account to get started":"Enter your invite code to continue"})]}),e.jsx(Oe,{children:j?e.jsxs("form",{onSubmit:se,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Full Name"}),e.jsx(Re,{id:"name",type:"text",placeholder:"John Doe",value:d,onChange:te=>u(te.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",placeholder:"you@example.com",value:a,onChange:te=>o(te.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{id:"password",type:p?"text":"password",placeholder:"••••••••",value:l,onChange:te=>i(te.target.value),required:!0,minLength:6}),e.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>f(!p),children:p?e.jsx(Im,{className:"h-4 w-4"}):e.jsx(xa,{className:"h-4 w-4"})})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:y,children:y?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating Account..."]}):"Create Account"})]}):e.jsxs("form",{onSubmit:Y,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"inviteCode",children:"Invite Code"}),e.jsx(Re,{id:"inviteCode",type:"text",placeholder:"Enter your invite code",value:r,onChange:te=>n(te.target.value),required:!0,autoFocus:!0})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify Code"})]})})]})})},d4t="/assets/testimonial-avatar-1-BsCQFauB.jpg",u4t="/assets/testimonial-avatar-2-B6VPVc2t.jpg",h4t="/assets/testimonial-avatar-3-GuEFwYUE.jpg",m4t="/assets/testimonial-avatar-4-98iKMtkB.jpg",p4t="/assets/testimonial-avatar-5-ZsZfyxMX.jpg",f4t=[d4t,u4t,h4t,m4t,p4t],g4t=lS({name:Jl().trim().min(2,"Name must be at least 2 characters").max(100),email:Jl().trim().email("Please enter a valid email address").max(255),phone:Jl().trim().min(10,"Please enter a valid phone number").max(20).optional().or(Ane("")),brokerage:Jl().trim().max(200).optional().or(Ane(""))}),x4t=[{icon:bm,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:Bl,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:on,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:xc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:In,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:po,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],y4t=[{icon:hr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:hn,title:"Smart TouchPlans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Qn,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:zu,title:"Birthday Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Oi,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:ol,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Si,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Fm,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],v4t=[{name:"Sarah M.",role:"Top Producer, RE/MAX",quote:"LevelUp completely transformed how I run my business. The templates alone save me hours every week."},{name:"Mike T.",role:"Brokerage Owner",quote:"Onboarding new agents used to take weeks. Now they're productive from day one with all the training resources."},{name:"Jessica L.",role:"Team Lead",quote:"The community is incredible. I've learned more from other agents here than any conference I've attended."}],_4t=()=>{const t=Pr(),[s,r]=C.useState(!1),[n,a]=C.useState({name:"",email:"",phone:"",brokerage:""}),[o,l]=C.useState({}),i=async d=>{var p,f;d.preventDefault(),l({});const u=g4t.safeParse(n);if(!u.success){const y={};u.error.errors.forEach(_=>{_.path[0]&&(y[_.path[0]]=_.message)}),l(y);return}r(!0);try{const{data:y,error:_}=await G.functions.invoke("create-trial-signup",{body:{name:n.name.trim(),email:n.email.trim().toLowerCase(),phone:((p=n.phone)==null?void 0:p.trim())||void 0,brokerage:((f=n.brokerage)==null?void 0:f.trim())||void 0}});if(_){console.error("Trial signup error:",_),fe.error(_.message||"Something went wrong. Please try again.");return}if(y!=null&&y.error){fe.error(y.error);return}fe.success("🎉 Welcome aboard! Check your email to claim your account."),t("/trial/success")}catch(y){console.error("Trial signup error:",y),fe.error("Something went wrong. Please try again.")}finally{r(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(lh,{children:[e.jsx("title",{children:"Start Your Free 7-Day Trial | LevelUp Dashboard"}),e.jsx("meta",{name:"description",content:"Take LevelUp for a free 7-day test drive. No credit card required. The all-in-one platform for real estate agents and brokerages."}),e.jsx("meta",{property:"og:title",content:"Start Your Free 7-Day Trial | LevelUp"}),e.jsx("meta",{property:"og:description",content:"Take LevelUp for a free 7-day test drive. No credit card required."}),e.jsx("meta",{property:"og:type",content:"website"})]}),e.jsxs("div",{className:"min-h-screen bg-background overflow-hidden",children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 bg-[#4a6b6d] shadow-md",children:e.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("img",{src:qne,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var d;return(d=document.getElementById("features"))==null?void 0:d.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(K,{onClick:()=>t("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})]})}),e.jsxs("section",{className:"relative pt-24 pb-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"grid lg:grid-cols-2 gap-12 items-center",children:[e.jsxs("div",{className:"space-y-8 text-center lg:text-left",children:[e.jsx("div",{className:"flex justify-center lg:justify-start",children:e.jsx("img",{alt:"LevelUp Consulting Group",className:"h-24 md:h-32 drop-shadow-lg",src:"/lovable-uploads/3a0c7ef9-9e79-411f-a9af-6f2a99e8bd7b.webp"})}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium",children:[e.jsx(hn,{className:"h-4 w-4 text-yellow-400"}),e.jsx("span",{children:"7-Day Free Trial • No Credit Card Required"})]}),e.jsxs("h1",{className:"text-3xl md:text-4xl lg:text-5xl font-bold text-white leading-tight font-sans",children:["Take LevelUp for a"," ",e.jsx("span",{className:"italic",children:"Free Test Drive"})]}),e.jsxs("p",{className:"text-lg md:text-xl text-white/80 max-w-xl mx-auto lg:mx-0 font-sans",children:["The tools you need to get it done.",e.jsx("br",{}),e.jsx("em",{children:"The platform you need to keep it going."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center lg:justify-start",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/80",children:[e.jsx(ua,{className:"h-5 w-5 text-green-400"}),e.jsx("span",{children:"No credit card required"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-white/80",children:[e.jsx(ua,{className:"h-5 w-5 text-green-400"}),e.jsx("span",{children:"Full access to all features"})]})]}),e.jsxs("div",{className:"flex items-center gap-4 justify-center lg:justify-start pt-4",children:[e.jsx("div",{className:"flex -space-x-3",children:f4t.map((d,u)=>e.jsx("img",{src:d,alt:`Agent ${u+1}`,className:"w-10 h-10 rounded-full border-2 border-white/20 object-cover"},u))}),e.jsxs("div",{children:[e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(d=>e.jsx(Gn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},d))}),e.jsx("p",{className:"text-sm text-white/60",children:"Trusted by 3,000+ agents"})]})]})]}),e.jsx("div",{className:"lg:pl-8",children:e.jsx(Ee,{className:"bg-white shadow-2xl border-0",children:e.jsxs(Oe,{className:"p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-[#4a6b6d] mb-4",children:e.jsx(Qx,{className:"h-8 w-8 text-white"})}),e.jsx("h2",{className:"text-2xl font-bold text-foreground font-sans",children:"Start Your Free Trial"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Get instant access • No credit card needed"})]}),e.jsxs("form",{onSubmit:i,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Full Name *"}),e.jsx(Re,{id:"name",type:"text",placeholder:"John Smith",value:n.name,onChange:d=>a({...n,name:d.target.value}),required:!0}),o.name&&e.jsx("p",{className:"text-sm text-destructive",children:o.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"email",children:"Email Address *"}),e.jsx(Re,{id:"email",type:"email",placeholder:"john@example.com",value:n.email,onChange:d=>a({...n,email:d.target.value}),required:!0}),o.email&&e.jsx("p",{className:"text-sm text-destructive",children:o.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"phone",children:"Phone Number"}),e.jsx(Re,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:d=>a({...n,phone:d.target.value})}),o.phone&&e.jsx("p",{className:"text-sm text-destructive",children:o.phone})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"brokerage",children:"Brokerage Name"}),e.jsx(Re,{id:"brokerage",type:"text",placeholder:"Your brokerage or team name",value:n.brokerage,onChange:d=>a({...n,brokerage:d.target.value})}),o.brokerage&&e.jsx("p",{className:"text-sm text-destructive",children:o.brokerage})]}),e.jsx(K,{type:"submit",className:"w-full h-12 text-lg font-semibold bg-[#4a6b6d] hover:bg-[#3d5a5c]",disabled:s,children:s?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"mr-2 h-5 w-5 animate-spin"}),"Creating Your Account..."]}):e.jsxs(e.Fragment,{children:["Start My Free Trial",e.jsx($i,{className:"ml-2 h-5 w-5"})]})}),e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["By signing up, you agree to our"," ",e.jsx("a",{href:"/terms-of-service",className:"text-[#4a6b6d] hover:underline",children:"Terms"})," ","and"," ",e.jsx("a",{href:"/privacy-policy",className:"text-[#4a6b6d] hover:underline",children:"Privacy Policy"})]})]})]})})})]})})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl md:text-5xl leading-tight font-sans font-semibold text-secondary",children:"We help brokerages and agents grow with training, tools, and built-in execution."}),e.jsxs("div",{className:"space-y-2 text-lg text-muted-foreground",children:[e.jsx("p",{children:"Agents get weekly coaching + plug-and-play marketing."}),e.jsx("p",{children:"Brokerages get higher adoption, consistency, and real engagement."})]}),e.jsx("p",{className:"text-2xl md:text-4xl text-[#4a6b6d] pt-4 font-sans font-bold",children:"LEVELUP EQUIPS BOTH TO THRIVE."})]})})}),e.jsx("section",{id:"features",className:"py-20 bg-muted/30",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl mb-6 font-sans font-bold",children:"What's inside our members only portal?"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Everything you need to grow your business, all in one place."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 max-w-6xl mx-auto",children:x4t.map((d,u)=>e.jsxs(Ee,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(It,{children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:e.jsx(d.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(Ot,{className:"text-xl font-sans",children:d.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:d.description})})]},u))})]})}),e.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs("div",{className:"container mx-auto px-4 relative",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium mb-6",children:[e.jsx(hn,{className:"w-4 h-4"}),"Included with Your Trial"]}),e.jsxs("h2",{className:"text-3xl mb-6 text-white font-sans font-bold md:text-6xl",children:["Meet ",e.jsx("span",{className:"italic",children:"Agent OS"})]}),e.jsx("p",{className:"text-lg text-white/80",children:"Your relationship-first operating system. Never forget a follow-up, track every touchpoint, and turn your sphere into a referral machine."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 max-w-6xl mx-auto",children:y4t.map((d,u)=>e.jsxs(Ee,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(It,{className:"pb-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-white/20 flex items-center justify-center mb-3",children:e.jsx(d.icon,{className:"w-6 h-6 text-white"})}),e.jsx(Ot,{className:"text-lg font-semibold text-white",children:d.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:d.description})})]},u))})]})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4 font-sans",children:"Loved by Top Producers"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"See what agents are saying about LevelUp"})]}),e.jsx("div",{className:"grid md:grid-cols-3 gap-8 max-w-5xl mx-auto",children:v4t.map((d,u)=>e.jsx(Ee,{className:"border hover:shadow-lg transition-shadow",children:e.jsxs(Oe,{className:"p-6",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(p=>e.jsx(Gn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},p))}),e.jsxs("p",{className:"text-muted-foreground mb-4 italic",children:['"',d.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:d.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.role})]})]})},u))})]})}),e.jsx("section",{className:"py-16 bg-muted/30",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-wrap justify-center gap-8 md:gap-16",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(ih,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Secure & Private"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Bank-level encryption"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(Fm,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Fast Setup"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Start in 2 minutes"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(hr,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Expert Support"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Real estate pros"})]})]})]})})}),e.jsx("section",{id:"free-trial",className:"py-20 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs(Ee,{className:"bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] border-0 shadow-2xl overflow-hidden relative",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs(Oe,{className:"p-12 text-center relative",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-white mb-4 font-sans",children:"Ready to Level Up Your Business?"}),e.jsx("p",{className:"text-xl text-white/80 mb-8 max-w-2xl mx-auto",children:"Join thousands of successful agents. Start your free 7-day trial today."}),e.jsxs(K,{onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),size:"lg",className:"h-14 px-8 text-lg font-semibold bg-white text-[#1e3a4c] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 rounded-full",children:["Start Your Free Trial Now",e.jsx($i,{className:"ml-2 h-5 w-5"})]})]})]})})}),e.jsx("footer",{className:"bg-[#1e3a4c] py-12",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-6",children:[e.jsx("img",{src:t_e,alt:"LevelUp",className:"h-8"}),e.jsxs("div",{className:"flex gap-6 text-sm text-white/60",children:[e.jsx("a",{href:"/privacy-policy",className:"hover:text-white transition-colors",children:"Privacy Policy"}),e.jsx("a",{href:"/terms-of-service",className:"hover:text-white transition-colors",children:"Terms of Service"})]}),e.jsx("p",{className:"text-sm text-white/40",children:"© 2025 LevelUp Consulting Group. All rights reserved."})]})})})]})]})},b4t=()=>{const t=Pr();return e.jsxs(e.Fragment,{children:[e.jsx(lh,{children:e.jsx("title",{children:"Welcome to LevelUp! | Check Your Email"})}),e.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 bg-[#4a6b6d] shadow-md",children:e.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("img",{src:qne,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsx(K,{onClick:()=>t("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})}),e.jsxs("section",{className:"relative pt-24 pb-12 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden flex-1 flex items-center",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsx("div",{className:"flex justify-center",children:e.jsx(Ee,{className:"max-w-lg w-full bg-white shadow-2xl border-0",children:e.jsxs(Oe,{className:"p-8 md:p-12 text-center",children:[e.jsxs("div",{className:"relative inline-block mb-8",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] flex items-center justify-center",children:e.jsx(ua,{className:"h-12 w-12 text-white"})}),e.jsx("div",{className:"absolute -top-2 -right-2 w-10 h-10 rounded-full bg-yellow-500 flex items-center justify-center animate-bounce",children:e.jsx(kd,{className:"h-5 w-5 text-white"})})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-foreground mb-4 font-sans",children:"You're In! 🎉"}),e.jsx("p",{className:"text-xl text-muted-foreground mb-8",children:"Your 7-day LevelUp adventure starts now!"}),e.jsxs("div",{className:"bg-[#4a6b6d]/10 rounded-xl p-6 mb-8",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/20 flex items-center justify-center",children:e.jsx(br,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Check Your Inbox"})]}),e.jsx("p",{className:"text-muted-foreground",children:"We just sent you a magic link to claim your account and set up your password. Click the link in your email to get started!"})]}),e.jsxs("div",{className:"text-left space-y-3 mb-8",children:[e.jsx("p",{className:"text-sm text-muted-foreground font-medium uppercase tracking-wide",children:"What happens next:"}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d] flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-white",children:"1"})}),e.jsx("p",{className:"text-foreground",children:"Check your email for the welcome message"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d] flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-white",children:"2"})}),e.jsx("p",{className:"text-foreground",children:'Click "Claim Your Account" to set your password'})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d] flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-white",children:"3"})}),e.jsx("p",{className:"text-foreground",children:"Start exploring all the features!"})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["Didn't receive the email? Check your spam folder or"," ",e.jsx("button",{onClick:()=>t("/trial"),className:"text-[#4a6b6d] hover:underline font-medium",children:"try again"})]}),e.jsxs(K,{onClick:()=>t("/auth"),className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["Go to Sign In",e.jsx($i,{className:"ml-2 h-4 w-4"})]})]})})})})]}),e.jsx("footer",{className:"bg-[#1e3a4c] py-8",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4",children:[e.jsx("img",{src:t_e,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm text-white/40",children:["© ",new Date().getFullYear()," LevelUp Consulting Group. All rights reserved."]})]})})})]})]})},w4t=lS({viewerName:Jl().min(1,"Name is required").max(100,"Name must be less than 100 characters"),viewerEmail:Jl().email("Please enter a valid email").max(255,"Email must be less than 255 characters"),viewerPhone:Jl().max(20,"Phone must be less than 20 characters").optional(),message:Jl().min(1,"Message is required").max(1e3,"Message must be less than 1000 characters")});function j4t({shareToken:t,agentName:s,hasContact:r}){const[n,a]=C.useState(!1),[o,l]=C.useState(!1),[i,d]=C.useState(null),u=nle({resolver:ale(w4t),defaultValues:{viewerName:"",viewerEmail:"",viewerPhone:"",message:""}}),p=async f=>{a(!0),d(null);try{const{data:y,error:_}=await G.functions.invoke("video-reply-notify",{body:{shareToken:t,viewerName:f.viewerName,viewerEmail:f.viewerEmail,viewerPhone:f.viewerPhone||void 0,message:f.message}});if(_)throw new Error(_.message);if(!(y!=null&&y.success))throw new Error((y==null?void 0:y.error)||"Failed to send reply");l(!0)}catch(y){console.error("Failed to submit reply:",y),d(y.message||"Something went wrong. Please try again.")}finally{a(!1)}};return o?e.jsx(Ee,{className:"border-2 border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10",children:e.jsxs(Oe,{className:"py-8 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/20 mb-4",children:e.jsx(ua,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:"Message Sent!"}),e.jsxs("p",{className:"text-muted-foreground",children:[s?`${s} will`:"They'll"," get back to you soon."]})]})}):e.jsxs(Ee,{children:[e.jsxs(It,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(xc,{className:"h-5 w-5 text-primary"}),e.jsx(Ot,{className:"text-lg",children:"Reply to this video"})]}),e.jsx(pr,{children:r?`Have a question or want to connect? Send ${s||"them"} a message.`:`Interested? Share your info and ${s||"your agent"} will be in touch.`})]}),e.jsx(Oe,{children:e.jsx(ile,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(p),className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(wc,{control:u.control,name:"viewerName",render:({field:f})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Your Name *"}),e.jsx(mc,{children:e.jsx(Re,{placeholder:"John Smith",...f})}),e.jsx(Oh,{})]})}),e.jsx(wc,{control:u.control,name:"viewerEmail",render:({field:f})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Email *"}),e.jsx(mc,{children:e.jsx(Re,{type:"email",placeholder:"john@example.com",...f})}),e.jsx(Oh,{})]})})]}),!r&&e.jsx(wc,{control:u.control,name:"viewerPhone",render:({field:f})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Phone (optional)"}),e.jsx(mc,{children:e.jsx(Re,{type:"tel",placeholder:"(555) 123-4567",...f})}),e.jsx(Oh,{})]})}),e.jsx(wc,{control:u.control,name:"message",render:({field:f})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Message *"}),e.jsx(mc,{children:e.jsx(Ar,{placeholder:r?"Thanks for the video! I had a question about...":"I'm interested in learning more about...",className:"min-h-[100px] resize-none",...f})}),e.jsx(Oh,{})]})}),i&&e.jsx("p",{className:"text-sm text-destructive",children:i}),e.jsx(K,{type:"submit",className:"w-full gap-2",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(aa,{className:"h-4 w-4"}),"Send Message"]})})]})})})]})}const N4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsxs("div",{className:"absolute inset-0 opacity-[0.08]",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[16%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[32%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[48%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[64%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[80%] left-0 right-0 h-[8%] bg-red-600"})]}),e.jsx("div",{className:"absolute top-0 left-0 w-[35%] h-[45%] bg-blue-900/10 rounded-br-3xl"}),e.jsx(Gn,{className:"absolute top-[5%] left-[8%] w-6 h-6 text-blue-600/30 fill-blue-600/20"}),e.jsx(Gn,{className:"absolute top-[15%] left-[20%] w-4 h-4 text-blue-600/25 fill-blue-600/15"}),e.jsx(Gn,{className:"absolute top-[8%] left-[28%] w-5 h-5 text-blue-600/30 fill-blue-600/20"}),e.jsx(Gn,{className:"absolute top-[25%] left-[12%] w-4 h-4 text-blue-600/20 fill-blue-600/10"}),e.jsx(Gn,{className:"absolute top-[20%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse"}),e.jsx(L0,{className:"absolute bottom-[20%] right-[10%] w-12 h-12 text-blue-600/15 rotate-12"})]}),k4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-500/5 via-transparent to-blue-500/5"}),e.jsxs("div",{className:"absolute top-[10%] left-[15%] w-32 h-32",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-red-400/20 animate-ping",style:{animationDuration:"3s"}}),e.jsx(hn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-8 text-red-400/40"})]}),e.jsxs("div",{className:"absolute top-[5%] right-[20%] w-24 h-24",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-blue-400/20 animate-ping",style:{animationDuration:"4s",animationDelay:"1s"}}),e.jsx(Gn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-6 h-6 text-blue-400/40 fill-blue-400/20"})]}),e.jsxs("div",{className:"absolute top-[20%] left-[50%] w-20 h-20",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border border-white/10 animate-ping",style:{animationDuration:"3.5s",animationDelay:"0.5s"}}),e.jsx(hn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-5 h-5 text-amber-400/40"})]}),e.jsx(Gn,{className:"absolute bottom-[25%] left-[10%] w-6 h-6 text-blue-500/25 fill-blue-500/15 animate-pulse"}),e.jsx(Gn,{className:"absolute bottom-[15%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse",style:{animationDelay:"0.5s"}}),e.jsx(L0,{className:"absolute top-[8%] left-[5%] w-10 h-10 text-red-500/20 rotate-12"})]}),S4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-pink-200/20 via-rose-100/10 to-purple-200/15"}),e.jsx("div",{className:"absolute top-[5%] left-[5%] opacity-20",children:e.jsx(Og,{className:"w-20 h-20 text-pink-400 rotate-12"})}),e.jsx("div",{className:"absolute top-[2%] right-[8%] opacity-15",children:e.jsx(Og,{className:"w-16 h-16 text-rose-400 -rotate-12"})}),e.jsx("div",{className:"absolute bottom-[15%] left-[8%] opacity-15",children:e.jsx(Og,{className:"w-14 h-14 text-purple-400 rotate-45"})}),e.jsx("div",{className:"absolute bottom-[20%] right-[5%] opacity-20",children:e.jsx(Og,{className:"w-16 h-16 text-pink-300 -rotate-6"})}),e.jsx(Si,{className:"absolute top-[15%] left-[30%] w-5 h-5 text-rose-300/40 fill-rose-300/20 animate-pulse"}),e.jsx(Si,{className:"absolute top-[25%] right-[25%] w-4 h-4 text-pink-300/40 fill-pink-300/20 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(Si,{className:"absolute top-[10%] left-[60%] w-4 h-4 text-rose-400/30 fill-rose-400/15 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx("div",{className:"absolute top-[8%] left-[45%] w-8 h-8 rounded-full bg-pink-300/10 blur-sm"}),e.jsx("div",{className:"absolute bottom-[25%] right-[30%] w-6 h-6 rounded-full bg-rose-300/10 blur-sm"})]}),C4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/5 via-slate-800/3 to-indigo-900/5"}),e.jsx("div",{className:"absolute top-[5%] right-[10%] opacity-15",children:e.jsxs("div",{className:"w-12 h-24 relative",children:[e.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-10 h-3 bg-blue-600 rounded-full"}),e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 w-0 h-0 border-l-[20px] border-r-[20px] border-t-[60px] border-l-transparent border-r-transparent border-t-blue-500"})]})}),e.jsx(rc,{className:"absolute top-[8%] left-[12%] w-12 h-12 text-blue-600/15"}),e.jsx(Gn,{className:"absolute top-[15%] left-[22%] w-5 h-5 text-amber-500/25 fill-amber-500/15"}),e.jsx(rc,{className:"absolute bottom-[20%] right-[8%] w-14 h-14 text-indigo-500/12"}),e.jsx("div",{className:"absolute top-[3%] left-[40%] opacity-12",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tr-none rotate-6"}),e.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tl-none -rotate-6"})]})}),e.jsx(Gn,{className:"absolute bottom-[25%] left-[15%] w-6 h-6 text-blue-500/20 fill-blue-500/10 animate-pulse"}),e.jsx(Gn,{className:"absolute top-[20%] right-[22%] w-5 h-5 text-indigo-400/20 fill-indigo-400/10 animate-pulse",style:{animationDelay:"0.5s"}})]}),M4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-pink-100/20 via-purple-100/15 to-sky-100/20"}),e.jsx("div",{className:"absolute top-[5%] left-[8%] w-12 h-16 rounded-full bg-gradient-to-b from-pink-300/25 to-pink-400/18 rotate-12"}),e.jsx("div",{className:"absolute top-[8%] right-[12%] w-10 h-14 rounded-full bg-gradient-to-b from-purple-300/25 to-purple-400/18 -rotate-6"}),e.jsx("div",{className:"absolute bottom-[18%] left-[15%] w-11 h-15 rounded-full bg-gradient-to-b from-sky-300/20 to-sky-400/12 rotate-6"}),e.jsx("div",{className:"absolute bottom-[22%] right-[10%] w-12 h-16 rounded-full bg-gradient-to-b from-yellow-300/20 to-yellow-400/12 -rotate-12"}),e.jsx("div",{className:"absolute top-[10%] left-[10%] w-6 h-1 bg-white/30 rounded-full rotate-12"}),e.jsx("div",{className:"absolute top-[12%] right-[15%] w-5 h-1 bg-white/25 rounded-full -rotate-6"}),e.jsx(Og,{className:"absolute top-[20%] left-[32%] w-7 h-7 text-purple-400/30"}),e.jsx(Og,{className:"absolute top-[12%] right-[28%] w-6 h-6 text-pink-400/30"}),e.jsx(f5,{className:"absolute top-[18%] left-[52%] w-5 h-5 text-sky-400/35"})]}),T4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-orange-900/12 via-purple-900/8 to-slate-900/12"}),e.jsx(lk,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-orange-400/25"}),e.jsx(lk,{className:"absolute top-[10%] right-[12%] w-12 h-12 text-purple-400/20 animate-pulse"}),e.jsxs("div",{className:"absolute bottom-[18%] left-[8%]",children:[e.jsx("div",{className:"w-14 h-12 rounded-full bg-orange-500/20"}),e.jsx("div",{className:"absolute -top-2 left-1/2 -translate-x-1/2 w-2 h-4 bg-green-600/25 rounded-t-full"})]}),e.jsxs("div",{className:"absolute bottom-[22%] right-[12%]",children:[e.jsx("div",{className:"w-12 h-10 rounded-full bg-orange-400/15"}),e.jsx("div",{className:"absolute -top-1.5 left-1/2 -translate-x-1/2 w-1.5 h-3 bg-green-600/20 rounded-t-full"})]}),e.jsx("div",{className:"absolute top-[15%] left-[40%] opacity-20",children:e.jsx("svg",{viewBox:"0 0 24 12",className:"w-10 h-5 text-slate-800 fill-current",children:e.jsx("path",{d:"M12 6c-2-4-6-6-12-6 4 2 6 4 6 6s-2 4-6 6c6 0 10-2 12-6zm0 0c2-4 6-6 12-6-4 2-6 4-6 6s2 4 6 6c-6 0-10-2-12-6z"})})}),e.jsx(hn,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-purple-400/35 animate-pulse"}),e.jsx(hn,{className:"absolute bottom-[28%] right-[25%] w-5 h-5 text-orange-400/30 animate-pulse",style:{animationDelay:"0.5s"}})]}),A4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-900/8 via-green-900/5 to-emerald-900/8"}),e.jsx(m_,{className:"absolute bottom-[8%] left-[5%] w-20 h-20 text-green-600/18"}),e.jsx(m_,{className:"absolute bottom-[12%] right-[8%] w-16 h-16 text-emerald-600/15"}),e.jsx(m_,{className:"absolute bottom-[10%] left-[28%] w-12 h-12 text-green-500/12"}),e.jsx($1,{className:"absolute top-[5%] left-[15%] w-10 h-10 text-sky-300/30 animate-pulse"}),e.jsx($1,{className:"absolute top-[10%] right-[20%] w-8 h-8 text-blue-300/25 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx($1,{className:"absolute top-[18%] left-[45%] w-6 h-6 text-sky-200/25 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx($1,{className:"absolute top-[8%] left-[70%] w-8 h-8 text-blue-200/20 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[12%] left-[10%] w-5 h-5 rounded-full bg-red-500/25"}),e.jsx("div",{className:"absolute top-[15%] right-[15%] w-4 h-4 rounded-full bg-amber-400/25"}),e.jsx("div",{className:"absolute top-[20%] left-[55%] w-4 h-4 rounded-full bg-green-500/20"}),e.jsx(Gn,{className:"absolute top-[3%] left-[50%] -translate-x-1/2 w-10 h-10 text-amber-400/35 fill-amber-400/25"})]}),E4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-orange-900/10 via-amber-800/6 to-red-900/10"}),e.jsx("div",{className:"absolute top-[5%] left-[10%] w-10 h-8 rounded-full bg-orange-500/25 rotate-45"}),e.jsx("div",{className:"absolute top-[10%] right-[15%] w-8 h-6 rounded-full bg-red-500/20 -rotate-12"}),e.jsx("div",{className:"absolute top-[15%] left-[35%] w-7 h-5 rounded-full bg-amber-500/22 rotate-30"}),e.jsx("div",{className:"absolute bottom-[18%] left-[12%] w-10 h-7 rounded-full bg-yellow-600/18 -rotate-45"}),e.jsx("div",{className:"absolute bottom-[22%] right-[10%] w-9 h-6 rounded-full bg-orange-600/15 rotate-12"}),e.jsxs("div",{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2",children:[e.jsx("div",{className:"w-16 h-14 rounded-full bg-orange-400/15"}),e.jsx("div",{className:"absolute -top-2 left-1/2 -translate-x-1/2 w-2 h-5 bg-green-600/18 rounded-t-full"})]}),e.jsx(Si,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-red-400/22 fill-red-400/12"}),e.jsx(Si,{className:"absolute top-[20%] right-[25%] w-5 h-5 text-orange-400/22 fill-orange-400/12"})]}),P4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-yellow-900/8 via-amber-900/4 to-purple-900/8"}),e.jsx(Gn,{className:"absolute top-[5%] left-[15%] w-12 h-12 text-yellow-400/35 fill-yellow-400/25 animate-pulse"}),e.jsx(Gn,{className:"absolute top-[8%] right-[12%] w-10 h-10 text-amber-400/30 fill-amber-400/20 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(Gn,{className:"absolute top-[15%] left-[40%] w-7 h-7 text-yellow-300/25 fill-yellow-300/15 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(Gn,{className:"absolute top-[12%] right-[35%] w-8 h-8 text-amber-300/28 fill-amber-300/18 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[20%] left-[25%] w-4 h-4 rounded-full bg-pink-400/30"}),e.jsx("div",{className:"absolute top-[18%] right-[30%] w-3 h-3 rounded-full bg-sky-400/30"}),e.jsx("div",{className:"absolute top-[25%] left-[60%] w-2.5 h-2.5 rounded-full bg-emerald-400/30"}),e.jsx("div",{className:"absolute top-[22%] right-[42%] w-3 h-3 rounded-full bg-purple-400/30"}),e.jsx(hn,{className:"absolute top-[3%] left-[50%] w-10 h-10 text-yellow-400/40"}),e.jsx(kd,{className:"absolute bottom-[18%] left-[10%] w-12 h-12 text-purple-400/18 rotate-12"}),e.jsx(kd,{className:"absolute bottom-[20%] right-[12%] w-10 h-10 text-amber-400/15 -rotate-12"})]}),I4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/10 via-indigo-900/6 to-sky-900/10"}),e.jsxs("div",{className:"absolute bottom-[12%] left-1/2 -translate-x-1/2 flex items-end gap-3",children:[e.jsx("div",{className:"w-2 h-14 bg-blue-400/18 rounded-full"}),e.jsx("div",{className:"w-2 h-12 bg-blue-300/15 rounded-full"}),e.jsx("div",{className:"w-2 h-16 bg-blue-400/20 rounded-full"}),e.jsx("div",{className:"w-2.5 h-20 bg-blue-500/22 rounded-full"})," ",e.jsx("div",{className:"w-2 h-16 bg-blue-400/20 rounded-full"}),e.jsx("div",{className:"w-2 h-12 bg-blue-300/15 rounded-full"}),e.jsx("div",{className:"w-2 h-14 bg-blue-400/18 rounded-full"})]}),e.jsx("div",{className:"absolute bottom-[38%] left-[calc(50%-42px)] w-3 h-4 bg-yellow-400/30 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[35%] left-[calc(50%-28px)] w-2.5 h-3 bg-yellow-300/25 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[40%] left-[calc(50%-14px)] w-3 h-4 bg-amber-400/30 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[45%] left-1/2 -translate-x-1/2 w-4 h-5 bg-yellow-400/35 rounded-full blur-sm"}),e.jsx(Gn,{className:"absolute top-[8%] left-[50%] -translate-x-1/2 w-14 h-14 text-yellow-400/28 fill-yellow-400/18"}),e.jsx(hn,{className:"absolute top-[5%] left-[20%] w-7 h-7 text-blue-400/35"}),e.jsx(hn,{className:"absolute top-[10%] right-[18%] w-6 h-6 text-sky-400/30"})]}),L4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-green-900/12 via-emerald-900/6 to-teal-900/10"}),e.jsx(N0,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-green-500/25"}),e.jsx(N0,{className:"absolute top-[8%] right-[12%] w-12 h-12 text-emerald-500/20"}),e.jsx(N0,{className:"absolute bottom-[18%] left-[12%] w-14 h-14 text-green-400/22"}),e.jsx(N0,{className:"absolute bottom-[22%] right-[10%] w-11 h-11 text-emerald-400/18"}),e.jsx("div",{className:"absolute top-[15%] left-[35%] w-6 h-6 rounded-full bg-yellow-500/30 border-2 border-yellow-600/25"}),e.jsx("div",{className:"absolute top-[20%] right-[28%] w-5 h-5 rounded-full bg-amber-500/25 border-2 border-amber-600/20"}),e.jsx("div",{className:"absolute bottom-[28%] left-[45%] w-5 h-5 rounded-full bg-yellow-400/25 border-2 border-yellow-500/20"}),e.jsx("div",{className:"absolute top-0 right-0 w-48 h-48 opacity-12 rounded-bl-full overflow-hidden",children:e.jsx("div",{className:"absolute inset-0 bg-gradient-to-bl from-red-400/60 via-yellow-400/60 to-green-400/60"})}),e.jsxs("div",{className:"absolute bottom-[10%] right-[5%] opacity-15",children:[e.jsx("div",{className:"w-12 h-8 bg-slate-700 rounded-b-full"}),e.jsx("div",{className:"absolute -top-1 left-1/2 -translate-x-1/2 w-10 h-3 bg-slate-600 rounded-full"}),e.jsxs("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 flex gap-0.5",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-yellow-400"}),e.jsx("div",{className:"w-2 h-2 rounded-full bg-amber-400"}),e.jsx("div",{className:"w-2 h-2 rounded-full bg-yellow-400"})]})]})]}),D4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/10 via-indigo-900/6 to-sky-900/10"}),e.jsx("div",{className:"absolute top-[8%] left-[12%] w-16 h-16 rounded-full border-4 border-blue-500/18"}),e.jsx("div",{className:"absolute top-[10%] right-[10%] w-14 h-14 rounded-full border-4 border-indigo-500/15"}),e.jsx("div",{className:"absolute bottom-[18%] left-[18%] w-12 h-12 rounded-full border-3 border-sky-500/12"}),e.jsx(Gn,{className:"absolute top-[5%] left-[42%] w-10 h-10 text-amber-400/30 fill-amber-400/20"}),e.jsx(Gn,{className:"absolute top-[15%] right-[25%] w-7 h-7 text-yellow-400/25 fill-yellow-400/15"}),e.jsx(rc,{className:"absolute bottom-[20%] right-[12%] w-12 h-12 text-blue-500/18"}),e.jsx(rc,{className:"absolute top-[18%] left-[28%] w-8 h-8 text-indigo-400/15"}),e.jsx(L0,{className:"absolute top-[8%] left-[60%] w-10 h-10 text-indigo-400/18"})]}),O4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/6 via-rose-900/6 to-purple-900/6"}),e.jsx(zu,{className:"absolute bottom-[10%] left-[50%] -translate-x-1/2 w-20 h-20 text-amber-400/18"}),e.jsxs("div",{className:"absolute top-[5%] left-[15%]",children:[e.jsx("div",{className:"w-12 h-14 rounded-full bg-rose-400/25"}),e.jsx("div",{className:"w-0.5 h-10 bg-rose-400/18 mx-auto"})]}),e.jsxs("div",{className:"absolute top-[3%] left-[25%]",children:[e.jsx("div",{className:"w-10 h-12 rounded-full bg-sky-400/25"}),e.jsx("div",{className:"w-0.5 h-12 bg-sky-400/18 mx-auto"})]}),e.jsxs("div",{className:"absolute top-[8%] right-[18%]",children:[e.jsx("div",{className:"w-11 h-13 rounded-full bg-purple-400/25"}),e.jsx("div",{className:"w-0.5 h-9 bg-purple-400/18 mx-auto"})]}),e.jsxs("div",{className:"absolute top-[5%] right-[10%]",children:[e.jsx("div",{className:"w-10 h-12 rounded-full bg-amber-400/25"}),e.jsx("div",{className:"w-0.5 h-11 bg-amber-400/18 mx-auto"})]}),e.jsx("div",{className:"absolute top-[20%] left-[35%] w-3 h-3 bg-pink-400/35 rounded-full"}),e.jsx("div",{className:"absolute top-[18%] right-[40%] w-2.5 h-2.5 bg-emerald-400/35 rounded-full"}),e.jsx("div",{className:"absolute top-[25%] left-[55%] w-2 h-2 bg-amber-400/35 rounded-full"}),e.jsx("div",{className:"absolute top-[22%] right-[30%] w-2.5 h-2.5 bg-sky-400/35 rounded-full"}),e.jsx(kd,{className:"absolute top-[8%] left-[45%] w-10 h-10 text-purple-400/22 rotate-12"}),e.jsx(po,{className:"absolute bottom-[18%] right-[15%] w-12 h-12 text-rose-400/18"})]}),R4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-rose-900/12 via-pink-900/8 to-red-900/12"}),e.jsx(Si,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-rose-400/28 fill-rose-400/18"}),e.jsx(Si,{className:"absolute top-[8%] right-[12%] w-14 h-14 text-pink-400/25 fill-pink-400/15"}),e.jsx(Si,{className:"absolute bottom-[15%] left-[12%] w-12 h-12 text-red-400/22 fill-red-400/12"}),e.jsx(Si,{className:"absolute bottom-[18%] right-[10%] w-13 h-13 text-rose-300/25 fill-rose-300/15"}),e.jsx(Si,{className:"absolute top-[15%] left-[30%] w-6 h-6 text-pink-300/35 fill-pink-300/20 animate-pulse"}),e.jsx(Si,{className:"absolute top-[20%] right-[35%] w-5 h-5 text-rose-300/35 fill-rose-300/20 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(Si,{className:"absolute top-[12%] left-[55%] w-5 h-5 text-red-300/30 fill-red-300/15 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(Si,{className:"absolute top-[25%] right-[25%] w-4 h-4 text-pink-400/30 fill-pink-400/15 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[18%] left-[45%] w-8 h-8 rounded-full bg-rose-300/18 blur-sm"}),e.jsx("div",{className:"absolute bottom-[25%] right-[40%] w-6 h-6 rounded-full bg-pink-300/15 blur-sm"})]}),F4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/10 via-yellow-900/6 to-orange-900/10"}),e.jsxs("div",{className:"absolute top-[5%] right-[12%]",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-yellow-400/25 blur-sm"}),e.jsx(h_,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-14 h-14 text-amber-400/45"})]}),e.jsx("div",{className:"absolute bottom-[12%] left-[20%] w-20 h-10 bg-slate-800/12 rounded-full blur-md"}),e.jsx(h_,{className:"absolute top-[15%] left-[18%] w-10 h-10 text-yellow-400/30"}),e.jsx(hn,{className:"absolute top-[10%] left-[42%] w-7 h-7 text-amber-400/35"}),e.jsx(h_,{className:"absolute bottom-[22%] right-[25%] w-8 h-8 text-orange-400/25"}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-[15%] bg-gradient-to-t from-amber-900/10 to-transparent"})]}),z4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-teal-900/10 via-cyan-900/6 to-emerald-900/10"}),e.jsx(On,{className:"absolute top-[8%] left-[10%] w-14 h-14 text-teal-500/22"}),e.jsx(On,{className:"absolute bottom-[15%] right-[8%] w-16 h-16 text-emerald-500/18"}),e.jsx(Dm,{className:"absolute top-[12%] right-[18%] w-10 h-10 text-amber-400/25"}),e.jsx(Dm,{className:"absolute bottom-[22%] left-[22%] w-8 h-8 text-yellow-400/22"}),e.jsx(Si,{className:"absolute top-[18%] left-[40%] w-6 h-6 text-rose-400/22 fill-rose-400/12"}),e.jsx(Si,{className:"absolute top-[22%] right-[35%] w-5 h-5 text-teal-400/20 fill-teal-400/10"}),e.jsx(hn,{className:"absolute top-[5%] left-[55%] w-8 h-8 text-teal-400/30"}),e.jsx(kd,{className:"absolute bottom-[20%] left-[48%] w-10 h-10 text-cyan-400/18 rotate-12"})]}),B4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-emerald-900/10 via-teal-900/6 to-cyan-900/10"}),e.jsx(kd,{className:"absolute top-[5%] left-[12%] w-14 h-14 text-emerald-400/25 rotate-12"}),e.jsx(kd,{className:"absolute top-[8%] right-[10%] w-12 h-12 text-teal-400/22 -rotate-12"}),e.jsx(Dm,{className:"absolute bottom-[18%] left-[18%] w-12 h-12 text-amber-400/25"}),e.jsx(On,{className:"absolute bottom-[15%] right-[12%] w-14 h-14 text-teal-500/18"}),e.jsx(hn,{className:"absolute top-[15%] left-[42%] w-10 h-10 text-emerald-400/35"}),e.jsx(hn,{className:"absolute top-[20%] right-[32%] w-7 h-7 text-cyan-400/30"}),e.jsx("div",{className:"absolute top-[25%] left-[55%] w-3 h-3 bg-amber-400/30 rounded-full"}),e.jsx("div",{className:"absolute top-[22%] right-[42%] w-2.5 h-2.5 bg-teal-400/30 rounded-full"}),e.jsx("div",{className:"absolute top-[28%] left-[35%] w-2 h-2 bg-emerald-400/30 rounded-full"})]}),$4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/10 via-yellow-900/6 to-orange-900/10"}),e.jsx(Dm,{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2 w-24 h-24 text-amber-400/25 rotate-45"}),e.jsx(Dm,{className:"absolute top-[10%] left-[12%] w-10 h-10 text-yellow-400/30"}),e.jsx(Dm,{className:"absolute top-[12%] right-[15%] w-9 h-9 text-amber-300/25"}),e.jsx(On,{className:"absolute top-[8%] left-[42%] w-12 h-12 text-teal-500/18"}),e.jsx(kd,{className:"absolute bottom-[22%] right-[18%] w-12 h-12 text-orange-400/18 rotate-12"}),e.jsx(hn,{className:"absolute top-[5%] right-[35%] w-8 h-8 text-yellow-400/35"}),e.jsx(Gn,{className:"absolute top-[18%] left-[28%] w-6 h-6 text-amber-400/25 fill-amber-400/15"})]}),q4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-teal-900/10 via-emerald-900/6 to-green-900/10"}),e.jsx(On,{className:"absolute bottom-[10%] left-[50%] -translate-x-1/2 w-20 h-20 text-teal-500/22"}),e.jsx("div",{className:"absolute bottom-[18%] left-[12%] w-12 h-10 bg-amber-400/18 rounded-sm"}),e.jsx("div",{className:"absolute bottom-[20%] left-[20%] w-10 h-8 bg-orange-400/15 rounded-sm"}),e.jsx("div",{className:"absolute bottom-[16%] right-[15%] w-11 h-9 bg-amber-300/18 rounded-sm"}),e.jsx(Dm,{className:"absolute top-[10%] right-[12%] w-10 h-10 text-amber-400/28"}),e.jsx(Si,{className:"absolute top-[8%] left-[18%] w-8 h-8 text-rose-400/25 fill-rose-400/15"}),e.jsx(hn,{className:"absolute top-[12%] left-[45%] w-8 h-8 text-teal-400/30"}),e.jsx(P0,{className:"absolute top-[15%] right-[28%] w-10 h-10 text-emerald-400/20"})]}),XMe=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute top-4 left-[10%] w-3 h-3 bg-amber-400/60 rounded-full animate-pulse"}),e.jsx("div",{className:"absolute top-12 right-[15%] w-2 h-2 bg-rose-400/60 rounded-full animate-pulse delay-100"}),e.jsx("div",{className:"absolute top-8 left-[30%] w-2.5 h-2.5 bg-sky-400/60 rounded-full animate-pulse delay-200"}),e.jsx("div",{className:"absolute top-16 right-[25%] w-2 h-2 bg-emerald-400/60 rounded-full animate-pulse delay-300"})]}),U4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Si,{className:"absolute top-6 left-[12%] w-4 h-4 text-rose-300/50 fill-rose-300/30 animate-pulse"}),e.jsx(Si,{className:"absolute top-10 right-[18%] w-3 h-3 text-pink-300/50 fill-pink-300/30 animate-pulse delay-150"}),e.jsx(Si,{className:"absolute top-4 left-[40%] w-2.5 h-2.5 text-rose-400/40 fill-rose-400/20 animate-pulse delay-300"}),e.jsx(Si,{className:"absolute top-14 right-[35%] w-3.5 h-3.5 text-pink-300/40 fill-pink-300/20 animate-pulse delay-200"})]}),V4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(P0,{className:"absolute top-5 left-[10%] w-4 h-4 text-blue-400/50 animate-pulse"}),e.jsx(hn,{className:"absolute top-10 right-[15%] w-3 h-3 text-amber-400/50 animate-pulse delay-100"}),e.jsx(On,{className:"absolute top-8 left-[38%] w-3 h-3 text-teal-300/40 animate-pulse delay-200"})]}),H4t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(ik,{className:"absolute top-5 left-[12%] w-4 h-4 text-amber-500/50 animate-pulse"}),e.jsx(N5,{className:"absolute top-10 right-[15%] w-3 h-3 text-rose-400/50 animate-pulse delay-100"}),e.jsx(ik,{className:"absolute top-8 left-[40%] w-3 h-3 text-amber-400/40 animate-pulse delay-200"})]}),uE=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(hn,{className:"absolute top-5 left-[10%] w-4 h-4 text-emerald-400/50 animate-pulse"}),e.jsx(kd,{className:"absolute top-10 right-[12%] w-5 h-5 text-amber-400/50 animate-pulse delay-150"}),e.jsx(hn,{className:"absolute top-8 left-[45%] w-3 h-3 text-sky-400/40 animate-pulse delay-300"})]}),QMe=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(On,{className:"absolute top-6 left-[12%] w-4 h-4 text-teal-400/40 animate-pulse"}),e.jsx(hn,{className:"absolute top-10 right-[15%] w-3 h-3 text-emerald-400/50 animate-pulse delay-100"}),e.jsx(On,{className:"absolute top-4 right-[40%] w-3 h-3 text-cyan-400/30 animate-pulse delay-200"})]}),Mxe=[{id:"default",name:"Classic",description:"Clean, professional look for any occasion",icon:e.jsx(hn,{className:"h-5 w-5"}),category:"general",headerText:()=>"Video Message",subText:"A personal video just for you",gradientClasses:"from-background to-muted/30",accentColor:"primary"},{id:"thank_you",name:"Thank You",description:"Express your gratitude",icon:e.jsx(Si,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Thank You, ${t}!`:"Thank You!",subText:"Your support means the world to me",gradientClasses:"from-rose-50/70 via-pink-50/50 to-red-50/40 dark:from-rose-950/30 dark:via-pink-950/20 dark:to-red-950/20",accentColor:"rose",decorativeElement:e.jsx(U4t,{})},{id:"thinking_of_you",name:"Thinking of You",description:"Let them know they're on your mind",icon:e.jsx(lP,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Thinking of You, ${t}`:"Thinking of You",subText:"Just wanted to reach out and say hello",gradientClasses:"from-violet-50/70 via-purple-50/50 to-indigo-50/40 dark:from-violet-950/30 dark:via-purple-950/20 dark:to-indigo-950/20",accentColor:"violet",decorativeElement:e.jsx(uE,{})},{id:"check_in",name:"Check-in",description:"Touch base with your contacts",icon:e.jsx(ik,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Hey ${t}!`:"Hey There!",subText:"Just checking in to see how you're doing",gradientClasses:"from-amber-50/70 via-orange-50/50 to-yellow-50/40 dark:from-amber-950/30 dark:via-orange-950/20 dark:to-yellow-950/20",accentColor:"amber",decorativeElement:e.jsx(H4t,{})},{id:"market_update",name:"Market Update",description:"Share real estate market insights",icon:e.jsx(ol,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Market Update for ${t}`:"Market Update",subText:"The latest insights from your local market",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-sky-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-sky-950/20",accentColor:"blue"},{id:"referral_thank_you",name:"Referral Thank You",description:"Thank someone for a referral",icon:e.jsx(hr,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Thank You for the Referral, ${t}!`:"Thank You for the Referral!",subText:"Your trust in me means everything",gradientClasses:"from-emerald-50/70 via-green-50/50 to-teal-50/40 dark:from-emerald-950/30 dark:via-green-950/20 dark:to-teal-950/20",accentColor:"emerald",decorativeElement:e.jsx(uE,{})},{id:"congratulations",name:"Congratulations",description:"Celebrate their achievements",icon:e.jsx(rc,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"So proud of your accomplishment",gradientClasses:"from-amber-50/70 via-yellow-50/50 to-orange-50/40 dark:from-amber-950/30 dark:via-yellow-950/20 dark:to-orange-950/20",accentColor:"amber",decorativeElement:e.jsx(XMe,{})},{id:"welcome_neighborhood",name:"Welcome to the Neighborhood",description:"Greet new neighbors",icon:e.jsx(Oi,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Welcome to the Neighborhood, ${t}!`:"Welcome to the Neighborhood!",subText:"So excited to have you as our new neighbor",gradientClasses:"from-teal-50/70 via-cyan-50/50 to-sky-50/40 dark:from-teal-950/30 dark:via-cyan-950/20 dark:to-sky-950/20",accentColor:"teal",decorativeElement:e.jsx(QMe,{})},{id:"just_because",name:"Just Because",description:"No reason needed to connect",icon:e.jsx(N5,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Hey ${t}!`:"Hey There!",subText:"No reason needed – just wanted to connect",gradientClasses:"from-sky-50/70 via-blue-50/50 to-indigo-50/40 dark:from-sky-950/30 dark:via-blue-950/20 dark:to-indigo-950/20",accentColor:"sky",decorativeElement:e.jsx(uE,{})},{id:"birthday",name:"Birthday",description:"Celebrate their special day",icon:e.jsx(zu,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Birthday, ${t}!`:"Happy Birthday!",subText:"Wishing you an amazing year ahead",gradientClasses:"from-amber-50/80 via-rose-50/60 to-purple-50/40 dark:from-amber-950/30 dark:via-rose-950/20 dark:to-purple-950/20",accentColor:"amber",decorativeElement:e.jsx(O4t,{})},{id:"valentines_day",name:"Valentine's Day",description:"Show appreciation on this special day",icon:e.jsx(Si,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Valentine's Day, ${t}!`:"Happy Valentine's Day!",subText:"A heartfelt message from your real estate professional",gradientClasses:"from-rose-50/80 via-pink-50/60 to-red-50/40 dark:from-rose-950/30 dark:via-pink-950/20 dark:to-red-950/20",accentColor:"rose",decorativeElement:e.jsx(R4t,{})},{id:"groundhog_day",name:"Groundhog Day",description:"A fun seasonal greeting",icon:e.jsx(h_,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Groundhog Day, ${t}!`:"Happy Groundhog Day!",subText:"Wishing you an early spring!",gradientClasses:"from-amber-50/70 via-yellow-50/50 to-orange-50/40 dark:from-amber-950/30 dark:via-yellow-950/20 dark:to-orange-950/20",accentColor:"amber",decorativeElement:e.jsx(F4t,{})},{id:"new_years",name:"New Year's Day",description:"Ring in the new year",icon:e.jsx(Gn,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy New Year, ${t}!`:"Happy New Year!",subText:"Wishing you a year full of success and happiness",gradientClasses:"from-yellow-50/70 via-amber-50/50 to-orange-50/40 dark:from-yellow-950/30 dark:via-amber-950/20 dark:to-orange-950/20",accentColor:"yellow",decorativeElement:e.jsx(P4t,{})},{id:"easter",name:"Easter",description:"Celebrate the spring season",icon:e.jsx(f5,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Easter, ${t}!`:"Happy Easter!",subText:"Wishing you a joyful celebration",gradientClasses:"from-pink-50/70 via-purple-50/50 to-sky-50/40 dark:from-pink-950/30 dark:via-purple-950/20 dark:to-sky-950/20",accentColor:"pink",decorativeElement:e.jsx(M4t,{})},{id:"mothers_day",name:"Mother's Day",description:"Celebrate the amazing moms",icon:e.jsx(Og,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Mother's Day, ${t}!`:"Happy Mother's Day!",subText:"Celebrating the wonderful mothers in our lives",gradientClasses:"from-pink-50/70 via-rose-50/50 to-purple-50/40 dark:from-pink-950/30 dark:via-rose-950/20 dark:to-purple-950/20",accentColor:"pink",decorativeElement:e.jsx(S4t,{})},{id:"fathers_day",name:"Father's Day",description:"Celebrate the amazing dads",icon:e.jsx(rc,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Father's Day, ${t}!`:"Happy Father's Day!",subText:"Celebrating the wonderful fathers in our lives",gradientClasses:"from-blue-50/70 via-sky-50/50 to-indigo-50/40 dark:from-blue-950/30 dark:via-sky-950/20 dark:to-indigo-950/20",accentColor:"blue",decorativeElement:e.jsx(C4t,{})},{id:"memorial_day",name:"Memorial Day",description:"Honor those who served",icon:e.jsx(L0,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Memorial Day, ${t}`:"Happy Memorial Day",subText:"Honoring those who served our country",gradientClasses:"from-red-50/60 via-white to-blue-50/60 dark:from-red-950/30 dark:via-slate-950/20 dark:to-blue-950/30",accentColor:"blue",decorativeElement:e.jsx(N4t,{})},{id:"independence_day",name:"4th of July",description:"Celebrate Independence Day",icon:e.jsx(nh,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy 4th of July, ${t}!`:"Happy 4th of July!",subText:"Celebrating freedom and independence",gradientClasses:"from-red-50/70 via-white to-blue-50/70 dark:from-red-950/30 dark:via-slate-950/10 dark:to-blue-950/30",accentColor:"red",decorativeElement:e.jsx(k4t,{})},{id:"labor_day",name:"Labor Day",description:"Celebrate the workers",icon:e.jsx(rc,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Labor Day, ${t}!`:"Happy Labor Day!",subText:"Celebrating the hard work that builds our communities",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-sky-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-sky-950/20",accentColor:"blue",decorativeElement:e.jsx(D4t,{})},{id:"halloween",name:"Halloween",description:"Spooky seasonal greetings",icon:e.jsx(lk,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Halloween, ${t}!`:"Happy Halloween!",subText:"Have a spooktacular day!",gradientClasses:"from-orange-50/70 via-amber-50/50 to-purple-50/40 dark:from-orange-950/30 dark:via-amber-950/20 dark:to-purple-950/30",accentColor:"orange",decorativeElement:e.jsx(T4t,{})},{id:"thanksgiving",name:"Thanksgiving",description:"Express gratitude this season",icon:e.jsx(Si,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Thanksgiving, ${t}!`:"Happy Thanksgiving!",subText:"Grateful for you and your friendship",gradientClasses:"from-orange-50/70 via-amber-50/50 to-red-50/40 dark:from-orange-950/30 dark:via-amber-950/20 dark:to-red-950/20",accentColor:"orange",decorativeElement:e.jsx(E4t,{})},{id:"christmas",name:"Christmas",description:"Spread holiday cheer",icon:e.jsx(m_,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Merry Christmas, ${t}!`:"Merry Christmas!",subText:"Wishing you joy and peace this holiday season",gradientClasses:"from-red-50/70 via-green-50/40 to-emerald-50/40 dark:from-red-950/30 dark:via-green-950/20 dark:to-emerald-950/20",accentColor:"red",decorativeElement:e.jsx(A4t,{})},{id:"hanukkah",name:"Hanukkah",description:"Celebrate the Festival of Lights",icon:e.jsx(hn,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Hanukkah, ${t}!`:"Happy Hanukkah!",subText:"Wishing you eight nights of light and joy",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-sky-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-sky-950/20",accentColor:"blue",decorativeElement:e.jsx(I4t,{})},{id:"st_patricks_day",name:"St. Patrick's Day",description:"Celebrate the luck of the Irish",icon:e.jsx(N0,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy St. Patrick's Day, ${t}!`:"Happy St. Patrick's Day!",subText:"Wishing you the luck of the Irish!",gradientClasses:"from-green-50/70 via-emerald-50/50 to-teal-50/40 dark:from-green-950/30 dark:via-emerald-950/20 dark:to-teal-950/20",accentColor:"green",decorativeElement:e.jsx(L4t,{})},{id:"home_anniversary",name:"Home Anniversary",description:"Celebrate their home ownership milestone",icon:e.jsx(On,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Happy Home Anniversary, ${t}!`:"Happy Home Anniversary!",subText:"Celebrating another year in your beautiful home",gradientClasses:"from-teal-50/70 via-cyan-50/50 to-emerald-50/40 dark:from-teal-950/30 dark:via-cyan-950/20 dark:to-emerald-950/20",accentColor:"teal",decorativeElement:e.jsx(z4t,{})},{id:"under_contract",name:"Under Contract",description:"Celebrate this exciting milestone",icon:e.jsx(kd,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"You're under contract – exciting times ahead!",gradientClasses:"from-emerald-50/70 via-teal-50/50 to-cyan-50/40 dark:from-emerald-950/30 dark:via-teal-950/20 dark:to-cyan-950/20",accentColor:"emerald",decorativeElement:e.jsx(B4t,{})},{id:"just_listed",name:"Just Listed",description:"Announce a new listing",icon:e.jsx(on,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Exciting News, ${t}!`:"Just Listed!",subText:"A new property is now on the market",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-violet-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-violet-950/20",accentColor:"blue",decorativeElement:e.jsx(QMe,{})},{id:"just_sold",name:"Just Sold",description:"Celebrate a successful sale",icon:e.jsx(od,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Just Sold!",subText:"Another successful transaction completed",gradientClasses:"from-emerald-50/70 via-green-50/50 to-teal-50/40 dark:from-emerald-950/30 dark:via-green-950/20 dark:to-teal-950/20",accentColor:"emerald",decorativeElement:e.jsx(uE,{})},{id:"price_reduction",name:"Price Reduction",description:"Notify about a price change",icon:e.jsx(fk,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Great News, ${t}!`:"Price Reduced!",subText:"This property just became more affordable",gradientClasses:"from-orange-50/70 via-amber-50/50 to-yellow-50/40 dark:from-orange-950/30 dark:via-amber-950/20 dark:to-yellow-950/20",accentColor:"orange"},{id:"open_house",name:"Open House",description:"Invite to an open house event",icon:e.jsx(P0,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`You're Invited, ${t}!`:"You're Invited!",subText:"Join us for an exclusive open house",gradientClasses:"from-sky-50/70 via-blue-50/50 to-indigo-50/40 dark:from-sky-950/30 dark:via-blue-950/20 dark:to-indigo-950/20",accentColor:"sky",decorativeElement:e.jsx(V4t,{})},{id:"closing_day",name:"Closing Day",description:"Celebrate their closing day",icon:e.jsx(Dm,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"It's official – the keys are yours!",gradientClasses:"from-amber-50/70 via-yellow-50/50 to-orange-50/40 dark:from-amber-950/30 dark:via-yellow-950/20 dark:to-orange-950/20",accentColor:"amber",decorativeElement:e.jsx($4t,{})},{id:"move_in_day",name:"Move-in Day",description:"Welcome them to their new home",icon:e.jsx(On,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Welcome Home, ${t}!`:"Welcome Home!",subText:"Wishing you all the best in your new home",gradientClasses:"from-teal-50/70 via-emerald-50/50 to-green-50/40 dark:from-teal-950/30 dark:via-emerald-950/20 dark:to-green-950/20",accentColor:"teal",decorativeElement:e.jsx(q4t,{})},{id:"offer_accepted",name:"Offer Accepted",description:"Celebrate their accepted offer",icon:e.jsx(gu,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Amazing News, ${t}!`:"Offer Accepted!",subText:"Your offer has been accepted – congratulations!",gradientClasses:"from-green-50/70 via-emerald-50/50 to-teal-50/40 dark:from-green-950/30 dark:via-emerald-950/20 dark:to-teal-950/20",accentColor:"green",decorativeElement:e.jsx(uE,{})},{id:"pre_approval",name:"Pre-Approval Congrats",description:"Congratulate on pre-approval",icon:e.jsx(rc,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"You're pre-approved and ready to find your dream home",gradientClasses:"from-violet-50/70 via-purple-50/50 to-indigo-50/40 dark:from-violet-950/30 dark:via-purple-950/20 dark:to-indigo-950/20",accentColor:"violet",decorativeElement:e.jsx(XMe,{})}],W4t=[{id:"general",name:"General Touch",description:"Everyday connection templates"},{id:"holidays",name:"Holidays",description:"Seasonal and holiday greetings"},{id:"transactional",name:"Transactional",description:"Real estate milestone templates"}];function G4t(t){return Mxe.filter(s=>s.category===t)}function F5(t){return Mxe.find(s=>s.id===t)||Mxe[0]}function JMe(){const{shareToken:t,recipientToken:s}=ko(),[r,n]=C.useState(null),[a,o]=C.useState(null),[l,i]=C.useState(null),[d,u]=C.useState(!0),[p,f]=C.useState(null),[y,_]=C.useState(!0),b=C.useRef(null),w=C.useRef(0),j=C.useRef(0),k=(()=>{const se=new URLSearchParams(window.location.search);return s||se.get("rt")||null})(),S=C.useCallback((se,te=!1)=>{if(!k||se<=0)return;const Q=Math.max(1,Math.round(se));if(Q<=j.current)return;const re=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${encodeURIComponent(k)}&e=watch&ws=${Q}`;te&&navigator.sendBeacon?navigator.sendBeacon(re):fetch(re,{method:"GET",keepalive:te}).catch(()=>{}),j.current=Math.max(j.current,Q)},[k]);C.useEffect(()=>{var le;if(!y||!(r!=null&&r.playback_url)||!k)return;let se=!1;const te=()=>{w.current>0&&S(w.current,!0)},Q=()=>{document.visibilityState==="hidden"&&te()},de=()=>{te()},re=()=>{var be;if(se||!b.current||!((be=window.playerjs)!=null&&be.Player))return;const he=new window.playerjs.Player(b.current);he.on("timeupdate",_e=>{const je=Math.floor(Number((_e==null?void 0:_e.seconds)??0));!Number.isFinite(je)||je<=0||(w.current=Math.max(w.current,je))}),he.on("pause",()=>{w.current>0&&S(w.current)}),he.on("ended",()=>{w.current>0&&S(w.current,!0)})},ae=document.querySelector('script[data-bunny-playerjs="true"]');if((le=window.playerjs)!=null&&le.Player)re();else if(ae)ae.addEventListener("load",re,{once:!0});else{const he=document.createElement("script");he.src="https://assets.mediadelivery.net/playerjs/playerjs-latest.min.js",he.async=!0,he.defer=!0,he.dataset.bunnyPlayerjs="true",he.onload=re,document.body.appendChild(he)}return document.addEventListener("visibilitychange",Q),window.addEventListener("beforeunload",de),()=>{se=!0,document.removeEventListener("visibilitychange",Q),window.removeEventListener("beforeunload",de),te()}},[y,r==null?void 0:r.playback_url,k,S]),C.useEffect(()=>{w.current=0,j.current=0},[k,t]),C.useEffect(()=>{const se=()=>{['[id*="lc_text_widget"]','[class*="lc-text-widget"]','[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="msgsndr"]',"[data-chat-widget]"].forEach(re=>{document.querySelectorAll(re).forEach(ae=>{ae.style.display="none"})})};se();const te=[setTimeout(se,500),setTimeout(se,1500),setTimeout(se,3e3)],Q=new MutationObserver(se);return Q.observe(document.body,{childList:!0,subtree:!0}),()=>{te.forEach(clearTimeout),Q.disconnect()}},[]),C.useEffect(()=>{(async()=>{if(!t){f("Invalid share link"),u(!1);return}const{data:te,error:Q}=await G.from("agent_videos").select("id, title, playback_url, thumbnail_url, preview_url, duration_seconds, share_token, owner_user_id, contact_id, page_template, recipient_name").eq("share_token",t).eq("is_deleted",!1).single();if(Q||!te){f("Video not found or has been removed"),u(!1);return}n(te);try{await G.rpc("log_video_view",{p_video_id:te.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch(de){console.warn("Failed to log video view:",de)}if(te.owner_user_id){const{data:de}=await G.from("profiles").select("id, name, email, phone").eq("id",te.owner_user_id).single();if(de){o(de);try{const{data:re}=await G.storage.from("avatars").list(`${te.owner_user_id}`);if(re&&re.length>0){const{data:ae}=G.storage.from("avatars").getPublicUrl(`${te.owner_user_id}/${re[0].name}`);i(ae.publicUrl)}}catch{}}}u(!1)})()},[t]);const T=se=>{if(!se)return"0:00";const te=Math.floor(se/60),Q=se%60;return`${te}:${Q.toString().padStart(2,"0")}`},I=se=>se.includes("iframe.mediadelivery.net/play/")?se.replace("/play/","/embed/")+"?autoplay=true&responsive=true":se,L=se=>{if(!se)return"?";const te=se.split(" ");return te.length>=2?`${te[0][0]}${te[1][0]}`.toUpperCase():se.substring(0,2).toUpperCase()},R=F5((r==null?void 0:r.page_template)||"default"),$=(r==null?void 0:r.recipient_name)||null,q=R.headerText($),H=`https://dashboard.relevelup.com/share/video/${t}`;if(d)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(Ms,{className:"h-8 w-8 animate-spin text-primary"})});if(p||!r)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx(Ee,{className:"max-w-md w-full",children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Nn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Video Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:p||"This video is no longer available."})]})})});const Y=R.id!=="default";return e.jsxs(e.Fragment,{children:[e.jsxs(lh,{children:[e.jsx("title",{children:q}),e.jsx("meta",{name:"description",content:R.subText}),e.jsx("meta",{property:"og:title",content:q}),e.jsx("meta",{property:"og:description",content:R.subText}),e.jsx("meta",{property:"og:type",content:"video.other"}),e.jsx("meta",{property:"og:url",content:H}),r.preview_url&&e.jsx("meta",{property:"og:image",content:r.preview_url}),!r.preview_url&&r.thumbnail_url&&e.jsx("meta",{property:"og:image",content:r.thumbnail_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{property:"og:video",content:r.playback_url}),e.jsx("meta",{property:"og:video:type",content:"text/html"}),e.jsx("meta",{property:"og:video:width",content:"1280"}),e.jsx("meta",{property:"og:video:height",content:"720"})]}),e.jsx("meta",{name:"twitter:card",content:"player"}),e.jsx("meta",{name:"twitter:title",content:q}),e.jsx("meta",{name:"twitter:description",content:R.subText}),r.preview_url&&e.jsx("meta",{name:"twitter:image",content:r.preview_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{name:"twitter:player",content:r.playback_url}),e.jsx("meta",{name:"twitter:player:width",content:"1280"}),e.jsx("meta",{name:"twitter:player:height",content:"720"})]})]}),e.jsxs("div",{className:Pt("min-h-screen flex items-center justify-center p-4 bg-gradient-to-b relative",R.gradientClasses),children:[Y&&R.decorativeElement,e.jsxs("div",{className:"max-w-2xl w-full space-y-6 relative z-10",children:[Y&&e.jsxs("div",{className:"text-center py-4 animate-fade-in",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:Pt("w-14 h-14 rounded-full flex items-center justify-center shadow-sm",R.accentColor==="primary"&&"bg-primary/10 text-primary",R.accentColor==="amber"&&"bg-amber-100 text-amber-600 dark:bg-amber-900/50 dark:text-amber-400",R.accentColor==="teal"&&"bg-teal-100 text-teal-600 dark:bg-teal-900/50 dark:text-teal-400",R.accentColor==="rose"&&"bg-rose-100 text-rose-600 dark:bg-rose-900/50 dark:text-rose-400",R.accentColor==="emerald"&&"bg-emerald-100 text-emerald-600 dark:bg-emerald-900/50 dark:text-emerald-400",R.accentColor==="yellow"&&"bg-yellow-100 text-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400",R.accentColor==="pink"&&"bg-pink-100 text-pink-600 dark:bg-pink-900/50 dark:text-pink-400",R.accentColor==="blue"&&"bg-blue-100 text-blue-600 dark:bg-blue-900/50 dark:text-blue-400",R.accentColor==="red"&&"bg-red-100 text-red-600 dark:bg-red-900/50 dark:text-red-400",R.accentColor==="orange"&&"bg-orange-100 text-orange-600 dark:bg-orange-900/50 dark:text-orange-400",R.accentColor==="green"&&"bg-green-100 text-green-600 dark:bg-green-900/50 dark:text-green-400",R.accentColor==="violet"&&"bg-violet-100 text-violet-600 dark:bg-violet-900/50 dark:text-violet-400",R.accentColor==="sky"&&"bg-sky-100 text-sky-600 dark:bg-sky-900/50 dark:text-sky-400"),children:e.jsx("div",{className:"scale-150",children:R.icon})})}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold mb-2",children:q}),e.jsx("p",{className:"text-muted-foreground",children:R.subText})]}),a&&e.jsxs("div",{className:"flex items-center gap-4 p-4 bg-card/90 backdrop-blur-sm rounded-lg border shadow-sm",children:[e.jsxs(xn,{className:"h-14 w-14 border-2 border-primary/20",children:[e.jsx(Aa,{src:l||void 0,alt:a.name||"Agent"}),e.jsx(yn,{className:"bg-primary/10 text-primary font-semibold",children:L(a.name)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:Y?"A special video from":"A personal video from"}),e.jsx("h2",{className:"text-lg font-semibold truncate",children:a.name||"Your Agent"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your Real Estate Professional"})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[a.phone&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:e.jsx("a",{href:`tel:${a.phone}`,"aria-label":"Call agent",children:e.jsx(Qn,{className:"h-4 w-4"})})}),a.email&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:e.jsx("a",{href:`mailto:${a.email}`,"aria-label":"Email agent",children:e.jsx(br,{className:"h-4 w-4"})})})]})]}),e.jsx(Ee,{className:"overflow-hidden shadow-lg",children:y&&r.playback_url?e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:e.jsx("iframe",{ref:b,src:I(r.playback_url),title:r.title||"Video message",className:"absolute top-0 left-0 w-full h-full",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})}):e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>_(!0),children:[r.preview_url||r.thumbnail_url?e.jsx("img",{src:r.preview_url||r.thumbnail_url||"",alt:r.title?`${r.title} video preview`:"Video message preview",className:"w-full h-full object-cover",onError:se=>{var Q;se.currentTarget.style.display="none";const te=(Q=se.currentTarget.parentElement)==null?void 0:Q.querySelector(".video-fallback");te&&(te.style.display="flex")}}):null,e.jsx("div",{className:"video-fallback w-full h-full items-center justify-center bg-gradient-to-br from-primary/20 to-primary/5",style:{display:r.preview_url||r.thumbnail_url?"none":"flex"},children:e.jsx(Nn,{className:"h-16 w-16 text-primary/50"})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30 group-hover:bg-black/40 transition-colors",children:e.jsx("div",{className:"w-20 h-20 rounded-full bg-white/90 flex items-center justify-center shadow-lg transform group-hover:scale-105 transition-transform",children:e.jsx(ul,{className:"h-10 w-10 text-primary ml-1"})})}),r.duration_seconds&&e.jsx("div",{className:"absolute bottom-3 right-3 bg-black/70 text-white text-sm px-2 py-1 rounded",children:T(r.duration_seconds)})]})}),!Y&&e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.title||"Video Message"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:y?"Enjoy the video!":"Click to play the video"})]}),!y&&e.jsx("div",{className:"flex justify-center",children:e.jsxs(K,{size:"lg",onClick:()=>_(!0),className:"gap-2",children:[e.jsx(ul,{className:"h-5 w-5"}),"Watch Video"]})}),e.jsx(j4t,{shareToken:t,agentName:(a==null?void 0:a.name)||null,hasContact:!!r.contact_id})]})]})]})}function K4t(){return C.useEffect(()=>(document.body.classList.add("video-landing-page"),()=>{document.body.classList.remove("video-landing-page")}),[]),e.jsx(jht,{})}function Z4t(){const{token:t}=ko();return C.useEffect(()=>{if(!t)return;const s=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/video-og-image?token=${t}`;window.location.replace(s)},[t]),e.jsx("main",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(Ms,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading video preview…"})]})})}const Y4t={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},X4t={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},d4={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function Q4t(){var Q,de,re,ae;const{slugOrId:t}=ko(),[s]=Pc(),{data:r,isLoading:n}=k9e(t||""),a=S9e(),o=p0t(),l=s.get("ref"),[i,d]=C.useState(""),[u,p]=C.useState(""),[f,y]=C.useState(""),[_,b]=C.useState(""),[w,j]=C.useState(!1),[k,S]=C.useState(!1),[T,I]=C.useState(null),[L,R]=C.useState(!1);C.useEffect(()=>{l&&o.mutate(l)},[l]);const $=le=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(le),q=async le=>{if(le.preventDefault(),!(!i.trim()||!f.trim()||!r)){j(!0);try{await a.mutateAsync({listingId:r.id,agentId:r.agent_id,firstName:i.trim(),lastName:u.trim(),email:f.trim(),phone:_.trim(),shareToken:l}),S(!0),fe.success("Thanks! The agent will be in touch soon.")}catch(he){console.error("Lead submission error:",he),fe.error(`Failed to submit: ${he.message||"Please try again"}`)}finally{j(!1)}}},U=(r==null?void 0:r.photos)||[],H=U.find(le=>le.is_primary)||U[0],Y=()=>{T!==null&&I(T===0?U.length-1:T-1)},se=()=>{T!==null&&I(T===U.length-1?0:T+1)};if(n)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(xs,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(xs,{className:"h-10 w-48 mb-6"}),e.jsx(xs,{className:"aspect-video mb-6"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-4",children:[e.jsx(xs,{className:"h-12 w-48"}),e.jsx(xs,{className:"h-6 w-full"}),e.jsx(xs,{className:"h-6 w-3/4"})]}),e.jsx(xs,{className:"h-64"})]})]})]});if(!r)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(vo,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:jne,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(On,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Listing Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing may no longer be available."}),e.jsx(K,{asChild:!0,children:e.jsx(vo,{to:"/public/listings",children:"Browse All Listings"})})]})]});const te=r.property_address?`${r.property_address} - ${r.city}, ${r.state}`:`${r.city}, ${r.state} Home for Sale`;return e.jsxs(e.Fragment,{children:[e.jsxs(lh,{children:[e.jsxs("title",{children:[te," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${$(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${r.square_footage?r.square_footage.toLocaleString()+" sqft":""} ${d4[r.property_type]} in ${r.city}, ${r.state}. ${((Q=r.description)==null?void 0:Q.slice(0,150))||""}`}),e.jsx("link",{rel:"canonical",href:`https://listings.relevelup.com/${r.slug||r.id}`}),e.jsx("meta",{property:"og:title",content:te}),e.jsx("meta",{property:"og:description",content:`${$(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${d4[r.property_type]} in ${r.city}, ${r.state}. View photos, details, and contact the listing agent.`}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:`https://listings.relevelup.com/${r.slug||r.id}`}),H&&e.jsx("meta",{property:"og:image",content:H.photo_url}),H&&e.jsx("meta",{property:"og:image:alt",content:`${r.property_address||r.city} - ${d4[r.property_type]} for sale`}),e.jsx("meta",{property:"og:site_name",content:"LevelUp Listings"}),e.jsx("meta",{property:"og:locale",content:"en_US"}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:te}),e.jsx("meta",{name:"twitter:description",content:`${$(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA in ${r.city}, ${r.state}`}),H&&e.jsx("meta",{name:"twitter:image",content:H.photo_url}),e.jsx("meta",{name:"robots",content:"index, follow"}),e.jsx("meta",{name:"geo.region",content:`US-${r.state}`}),e.jsx("meta",{name:"geo.placename",content:r.city}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"RealEstateListing",name:r.property_address||`${r.city}, ${r.state} Home`,description:r.description||`${d4[r.property_type]} for sale in ${r.city}, ${r.state}`,url:`https://listings.relevelup.com/${r.slug||r.id}`,datePosted:r.created_at,image:U.map(le=>le.photo_url),address:{"@type":"PostalAddress",streetAddress:r.property_address||void 0,addressLocality:r.city,addressRegion:r.state,addressCountry:"US"},geo:r.neighborhood?{"@type":"GeoCoordinates",name:r.neighborhood}:void 0,offers:{"@type":"Offer",price:r.price,priceCurrency:"USD",availability:r.status==="sold"?"https://schema.org/SoldOut":r.status==="under_contract"?"https://schema.org/LimitedAvailability":"https://schema.org/InStock"},numberOfRooms:r.bedrooms||void 0,numberOfBathroomsTotal:r.bathrooms||void 0,floorSize:r.square_footage?{"@type":"QuantitativeValue",value:r.square_footage,unitCode:"FTK"}:void 0,yearBuilt:r.year_built||void 0,broker:r.agent?{"@type":"RealEstateAgent",name:r.agent.name,email:r.agent.email,worksFor:(de=r.agent.brokerage)!=null&&de.name?{"@type":"RealEstateAgent",name:r.agent.brokerage.name}:void 0}:void 0})})]}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card sticky top-0 z-50",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(vo,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:jne,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs(vo,{to:"/public/listings",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(ti,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),U.length>0&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>I(0),children:e.jsx("img",{src:H==null?void 0:H.photo_url,alt:`${r.property_address||r.city+", "+r.state} - ${d4[r.property_type]} main photo`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:U.slice(1,5).map((le,he)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>I(he+1),children:[e.jsx("img",{src:le.photo_url,alt:`${r.property_address||r.city} - Photo ${he+2} of ${U.length}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),he===3&&U.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",U.length-5," more"]})]},le.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx(rt,{className:`${Y4t[r.status]} text-white border-0`,children:X4t[r.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:$(r.price)}),r.property_address&&e.jsx("p",{className:"text-xl font-medium",children:r.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(Oi,{className:"h-4 w-4"}),r.city,", ",r.state,r.neighborhood&&` • ${r.neighborhood}`]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 py-4 border-y",children:[r.bedrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(E0,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.bedrooms}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Beds"})]}),r.bathrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(Zx,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.bathrooms}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Baths"})]}),r.square_footage&&e.jsxs("div",{className:"text-center",children:[e.jsx(ey,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.square_footage.toLocaleString()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sq Ft"})]}),r.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(on,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.year_built}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(rt,{variant:"secondary",children:[e.jsx(Ta,{className:"h-3 w-3 mr-1"}),d4[r.property_type]]}),r.lot_size&&e.jsxs(rt,{variant:"secondary",children:["Lot: ",r.lot_size]}),r.has_hoa&&e.jsx(rt,{variant:"secondary",children:"HOA"})]}),r.description&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"About This Property"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})]}),r.agent_notes&&r.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.agent_notes})]}),r.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:r.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[r.video&&r.video.playback_url&&e.jsx(Ee,{className:"overflow-hidden bg-gradient-to-br from-primary/5 to-primary/10 border-primary/20",children:e.jsxs(Oe,{className:"p-0",children:[e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>R(!0),children:[r.video.thumbnail_url?e.jsx("img",{src:r.video.thumbnail_url,alt:"Video thumbnail",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gradient-to-br from-primary/20 to-primary/30",children:e.jsx(Nn,{className:"h-12 w-12 text-primary"})}),e.jsx("div",{className:"absolute inset-0 bg-black/30 group-hover:bg-black/40 transition-colors flex items-center justify-center",children:e.jsx("div",{className:"h-16 w-16 rounded-full bg-white/90 group-hover:bg-white flex items-center justify-center transition-colors shadow-lg",children:e.jsx(ul,{className:"h-8 w-8 text-primary fill-primary ml-1"})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs(K,{onClick:()=>R(!0),className:"w-full gap-2",size:"lg",children:[e.jsx(ul,{className:"h-4 w-4"}),"Watch Video Tour"]}),r.video.title&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2 text-center truncate",children:r.video.title})]})]})}),r.agent&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(Yi,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-semibold text-lg",children:r.agent.name}),((re=r.agent.brokerage)==null?void 0:re.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:r.agent.brokerage.name})]})]}),e.jsxs(Ee,{className:"border-primary",children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Oe,{children:k?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-3",children:e.jsx(br,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"font-medium",children:"Thanks for your interest!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The listing agent will contact you soon."})]}):e.jsxs("form",{onSubmit:q,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"firstName",children:"First Name *"}),e.jsx(Re,{id:"firstName",type:"text",placeholder:"John",value:i,onChange:le=>d(le.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"lastName",children:"Last Name"}),e.jsx(Re,{id:"lastName",type:"text",placeholder:"Doe",value:u,onChange:le=>p(le.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email *"}),e.jsx(Re,{id:"email",type:"email",placeholder:"you@example.com",value:f,onChange:le=>y(le.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone"}),e.jsx(Re,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:_,onChange:le=>b(le.target.value)})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:w,children:w?"Submitting...":"Get More Info"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"The listing agent will reach out to you directly."})]})})]})]})]})]}),e.jsx(_s,{open:T!==null,onOpenChange:()=>I(null),children:e.jsxs(vs,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(Ss,{className:"sr-only",children:e.jsx(ks,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>I(null),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Ur,{className:"h-5 w-5"})}),T!==null&&U[T]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:U[T].photo_url,alt:`Photo ${T+1}`,className:"w-full max-h-[80vh] object-contain"}),U.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:Y,className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(zl,{className:"h-6 w-6"})}),e.jsx("button",{onClick:se,className:"absolute right-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Ua,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white bg-black/50 px-3 py-1 rounded-full text-sm",children:[T+1," / ",U.length]})]})]})]})}),e.jsx(_s,{open:L,onOpenChange:R,children:e.jsxs(vs,{className:"max-w-4xl p-0 bg-black overflow-hidden",children:[e.jsx(Ss,{className:"sr-only",children:e.jsx(ks,{children:"Video Tour"})}),e.jsx("button",{onClick:()=>R(!1),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Ur,{className:"h-5 w-5"})}),((ae=r==null?void 0:r.video)==null?void 0:ae.playback_url)&&e.jsx("div",{className:"aspect-video w-full",children:e.jsx("iframe",{src:r.video.playback_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]})}),e.jsx("footer",{className:"border-t py-8 mt-16",children:e.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[e.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("p",{className:"mt-2",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function J4t(){var o;const{slug:t}=ko(),{data:s,isLoading:r,error:n}=A9e(t);if(C.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]),C.useEffect(()=>{s!=null&&s.id&&no(s.id,"card_view")},[s==null?void 0:s.id]),r)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md mx-auto p-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(xs,{className:"h-28 w-28 rounded-full"}),e.jsx(xs,{className:"h-6 w-48"}),e.jsx(xs,{className:"h-4 w-36"})]}),e.jsx(xs,{className:"h-12 w-full"}),e.jsx(xs,{className:"h-12 w-full"})]})});if(n||!s)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Card Not Found"}),e.jsx("p",{className:"text-slate-500",children:"This agent card doesn't exist or isn't published yet."})]})});const a=((o=s.profile)==null?void 0:o.name)||"Agent";return e.jsxs(e.Fragment,{children:[e.jsxs(lh,{children:[e.jsxs("title",{children:[a," | Real Estate Agent"]}),e.jsx("meta",{name:"description",content:s.positioning_statement||`Connect with ${a}, your trusted real estate professional.`}),e.jsx("meta",{property:"og:title",content:`${a} | Real Estate Agent`}),e.jsx("meta",{property:"og:description",content:s.positioning_statement||`Connect with ${a}`}),s.avatar_url&&e.jsx("meta",{property:"og:image",content:s.avatar_url})]}),e.jsx(r_e,{card:s})]})}function mVe({slugOverride:t}={}){var Se;const{slug:s}=ko(),r=t||s,[n]=Pc(),a=n.get("t"),[o,l]=C.useState(!0),[i,d]=C.useState(null),[u,p]=C.useState(null),f=C.useRef(null),y=C.useRef(null),[_,b]=C.useState(null),[w,j]=C.useState(null),[k,S]=C.useState(!1),[T,I]=C.useState(!1),[L,R]=C.useState(0),[$,q]=C.useState(!1),[U,H]=C.useState(""),[Y,se]=C.useState(""),[te,Q]=C.useState(""),[de,re]=C.useState(""),[ae,le]=C.useState(""),[he,be]=C.useState(""),[_e,je]=C.useState(""),[Ne,Ge]=C.useState(""),[we,Me]=C.useState(""),[Te,Fe]=C.useState(""),[Ae,Ue]=C.useState(""),[ut,De]=C.useState("");C.useEffect(()=>{Rt()},[r,a]);const Rt=async()=>{if(!r)return;l(!0);const{data:it,error:$e}=await G.from("contact_intake_pages").select("*").eq("slug",r).eq("is_active",!0).maybeSingle();if($e||!it){q(!0),l(!1);return}p(it),y.current=it;const{data:ct}=await G.from("profiles").select("name, avatar_url, title, phone, email, brokerage_id").eq("id",it.user_id).single();if(ct){let qe;if(ct.brokerage_id){const{data:We}=await G.from("brokerages").select("name").eq("id",ct.brokerage_id).single();qe=(We==null?void 0:We.name)||void 0}let Ze=ct.avatar_url||null;if(!Ze){const{data:We}=G.storage.from("avatars").getPublicUrl(`${it.user_id}/avatar.jpg`);We!=null&&We.publicUrl&&(Ze=`${We.publicUrl}?t=${Date.now()}`)}const Qe={...ct,avatar_url:Ze,brokerage_name:qe};d(Qe),f.current=Qe}if(a)try{console.log("[ConnectPage] Resolving token:",a,"for page:",it.id);const{data:qe,error:Ze}=await G.functions.invoke("process-intake-submissions",{body:{action:"resolve_token",token:a,page_id:it.id}});if(console.log("[ConnectPage] Resolve result:",{resolved:qe,resolveErr:Ze}),!Ze&&(qe!=null&&qe.contact_id)){j(qe.contact_id);const Qe=qe.contact;Qe&&(b(Qe),H(Qe.first_name||""),se(Qe.last_name||""),Q(Qe.email||""),re(Qe.phone||""),le(Qe.address||""),be(Qe.city||""),je(Qe.state||""),Ge(Qe.zip||""),Me(Qe.birthday||""),Fe(Qe.home_anniversary||""))}}catch(qe){console.error("Failed to resolve token:",qe)}l(!1)},me=async()=>{var it,$e;if(!U.trim()){fe.error("Please enter your first name");return}if(!r){fe.error("Invalid page. Please refresh.");return}I(!0);try{let ct=(it=y.current)==null?void 0:it.id,qe=($e=y.current)==null?void 0:$e.user_id;if(!ct||!qe){const{data:Qe}=await G.from("contact_intake_pages").select("id, user_id").eq("slug",r).eq("is_active",!0).maybeSingle();if(!Qe){fe.error("This page is no longer active. Please contact the agent directly."),I(!1);return}ct=Qe.id,qe=Qe.user_id}const{error:Ze}=await G.from("contact_intake_submissions").insert({intake_page_id:ct,agent_user_id:qe,existing_contact_id:w,first_name:U.trim(),last_name:Y.trim()||null,email:te.trim()||null,phone:de.trim()||null,address:ae.trim()||null,city:he.trim()||null,state:_e.trim()||null,zip:Ne.trim()||null,birthday:we||null,home_anniversary:Te||null,real_estate_interest:Ae||null,message:ut.trim()||null});if(console.log("[ConnectPage] Insert result:",{error:Ze}),Ze)throw Ze;a&&await G.from("contact_intake_tokens").update({used_at:new Date().toISOString()}).eq("token",a);try{const Qe=[U.trim(),Y.trim()].filter(Boolean).join(" ");await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/connect-page-notify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentUserId:qe,contactName:Qe,contactEmail:te.trim()||null,contactPhone:de.trim()||null,slug:r})})}catch(Qe){console.warn("Connect page notification failed (non-blocking):",Qe)}S(!0)}catch(ct){console.error(ct),fe.error("Something went wrong. Please try again.")}finally{I(!1)}};if(o)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50",children:e.jsx(Ms,{className:"h-8 w-8 animate-spin text-slate-400"})});if($)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("h1",{className:"text-2xl font-semibold text-slate-700",children:"Page Not Found"}),e.jsx("p",{className:"text-slate-500",children:"This connect page doesn't exist or is no longer active."})]})});if(k)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50 p-4",children:[e.jsx(lh,{children:e.jsxs("title",{children:["Thank You | ",i==null?void 0:i.name]})}),e.jsxs(wr.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"max-w-md w-full text-center space-y-6 p-8",children:[e.jsx(wr.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",delay:.2},className:"mx-auto w-20 h-20 rounded-full bg-emerald-100 flex items-center justify-center",children:e.jsx(ua,{className:"h-10 w-10 text-emerald-600"})}),e.jsx("h1",{className:"text-3xl font-bold text-slate-800",children:"Thank You!"}),e.jsxs("p",{className:"text-lg text-slate-600",children:[i==null?void 0:i.name," has received your info and will be in touch soon."]}),e.jsxs("div",{className:"flex items-center justify-center gap-1 text-sm text-slate-400 pt-4",children:[e.jsx(Si,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})]})]});const Xe=!!a&&!!_,ot=3,nt=[{title:Xe?"Confirm Your Info":"Let's Get Connected",fields:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"First Name *"}),e.jsx("input",{type:"text",value:U,onChange:it=>H(it.target.value),placeholder:"Jane",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Last Name"}),e.jsx("input",{type:"text",value:Y,onChange:it=>se(it.target.value),placeholder:"Smith",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Email"}),e.jsx("input",{type:"email",value:te,onChange:it=>Q(it.target.value),placeholder:"jane@email.com",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Phone"}),e.jsx("input",{type:"tel",value:de,onChange:it=>re(it.target.value),placeholder:"(555) 123-4567",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]})},{title:"A Little More About You",fields:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Street Address"}),e.jsx("input",{type:"text",value:ae,onChange:it=>le(it.target.value),placeholder:"123 Main St",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"grid grid-cols-5 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"City"}),e.jsx("input",{type:"text",value:he,onChange:it=>be(it.target.value),placeholder:"Austin",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"col-span-1",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"State"}),e.jsx("input",{type:"text",value:_e,onChange:it=>je(it.target.value),placeholder:"TX",maxLength:2,className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Zip"}),e.jsx("input",{type:"text",value:Ne,onChange:it=>Ge(it.target.value),placeholder:"78701",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Birthday"}),e.jsx("input",{type:"date",value:we,onChange:it=>Me(it.target.value),className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Home Anniversary"}),e.jsx("input",{type:"date",value:Te,onChange:it=>Fe(it.target.value),className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]})]})},{title:"One Last Thing",fields:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-slate-600 mb-3",children:["Are you thinking about making a move anytime soon? ",e.jsx("span",{className:"text-slate-400 font-normal",children:"(totally optional)"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:[{value:"buying",label:"🏠 Buying",desc:"Looking for a home"},{value:"selling",label:"📋 Selling",desc:"Thinking of selling"},{value:"both",label:"🔄 Both",desc:"Buy & sell"},{value:"not_now",label:"😊 Not right now",desc:"Just staying connected"}].map(it=>e.jsxs("button",{type:"button",onClick:()=>Ue(Ae===it.value?"":it.value),className:`p-3.5 rounded-xl border-2 text-left transition-all ${Ae===it.value?"border-blue-500 bg-blue-50 shadow-sm":"border-slate-200 bg-white hover:border-slate-300"}`,children:[e.jsx("span",{className:"block text-sm font-medium text-slate-800",children:it.label}),e.jsx("span",{className:"block text-xs text-slate-500 mt-0.5",children:it.desc})]},it.value))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:["Anything else you'd like to share? ",e.jsx("span",{className:"text-slate-400 font-normal",children:"(optional)"})]}),e.jsx("textarea",{value:ut,onChange:it=>De(it.target.value),placeholder:"Feel free to drop a note...",rows:3,className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all resize-none"})]})]})}];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-blue-50",children:[e.jsxs(lh,{children:[e.jsxs("title",{children:["Connect with ",(i==null?void 0:i.name)||"Agent"]}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-8 sm:py-12",children:[e.jsxs(wr.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"text-center mb-8",children:[i!=null&&i.avatar_url?e.jsx("img",{src:i.avatar_url,alt:i.name,className:"w-24 h-24 rounded-full object-cover mx-auto mb-4 ring-4 ring-white shadow-lg"}):e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-blue-500 to-indigo-600 mx-auto mb-4 flex items-center justify-center ring-4 ring-white shadow-lg",children:e.jsx("span",{className:"text-3xl font-bold text-white",children:((Se=i==null?void 0:i.name)==null?void 0:Se.charAt(0))||"?"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800",children:i==null?void 0:i.name}),(i==null?void 0:i.title)&&e.jsx("p",{className:"text-slate-500 mt-0.5",children:i.title}),(i==null?void 0:i.brokerage_name)&&e.jsx("p",{className:"text-sm text-slate-400",children:i.brokerage_name}),((i==null?void 0:i.phone)||(i==null?void 0:i.email))&&e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-3",children:[(i==null?void 0:i.phone)&&e.jsx("a",{href:`tel:${i.phone}`,className:"flex items-center justify-center w-10 h-10 rounded-full bg-blue-50 hover:bg-blue-100 text-blue-600 transition-colors","aria-label":"Call agent",children:e.jsx(Qn,{className:"h-4.5 w-4.5"})}),(i==null?void 0:i.email)&&e.jsx("a",{href:`mailto:${i.email}`,className:"flex items-center justify-center w-10 h-10 rounded-full bg-blue-50 hover:bg-blue-100 text-blue-600 transition-colors","aria-label":"Email agent",children:e.jsx(br,{className:"h-4.5 w-4.5"})})]})]}),e.jsx(wr.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2},className:"text-center text-slate-600 mb-8 px-4 leading-relaxed",children:(u==null?void 0:u.welcome_message)||"I'd love to stay connected! Fill in your info below."}),e.jsx("div",{className:"flex gap-2 mb-8 px-2",children:Array.from({length:ot}).map((it,$e)=>e.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-all duration-500 ${$e<=L?"bg-blue-500":"bg-slate-200"}`},$e))}),e.jsxs(wr.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.3},className:"bg-white rounded-2xl shadow-lg shadow-slate-200/50 border border-slate-100 p-6 sm:p-8",children:[e.jsx(Zqe,{mode:"wait",children:e.jsxs(wr.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.25},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[e.jsx(hn,{className:"h-5 w-5 text-blue-500"}),e.jsx("h2",{className:"text-lg font-semibold text-slate-800",children:nt[L].title})]}),nt[L].fields]},L)}),e.jsxs("div",{className:"flex justify-between mt-8",children:[L>0?e.jsx("button",{type:"button",onClick:()=>R(it=>it-1),className:"px-5 py-2.5 text-sm font-medium text-slate-600 hover:text-slate-800 transition-colors",children:"Back"}):e.jsx("div",{}),L{if(L===0&&!U.trim()){fe.error("Please enter your first name");return}R(it=>it+1)},className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-xl hover:bg-blue-700 transition-colors shadow-sm",children:"Continue"}):e.jsx("button",{type:"button",onClick:()=>me(),disabled:T,className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-xl hover:bg-blue-700 transition-colors shadow-sm disabled:opacity-50 flex items-center gap-2",children:T?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):"Submit"})]}),L>0&&LR(it=>it+1),className:"text-xs text-slate-400 hover:text-slate-500 transition-colors",children:"Skip this step"})})]}),e.jsx("div",{className:"text-center mt-8",children:e.jsxs("div",{className:"flex items-center justify-center gap-1 text-xs text-slate-400",children:[e.jsx(Si,{className:"h-3 w-3"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})})]})]})}function hE({banners:t,autoPlayInterval:s=5e3,className:r}){const[n,a]=C.useState(0),[o,l]=C.useState(!1),i=C.useCallback(()=>{a(f=>(f+1)%t.length)},[t.length]),d=C.useCallback(()=>{a(f=>(f-1+t.length)%t.length)},[t.length]),u=C.useCallback(f=>{a(f)},[]);if(C.useEffect(()=>{if(t.length<=1||o)return;const f=setInterval(i,s);return()=>clearInterval(f)},[t.length,o,s,i]),!t||t.length===0)return null;const p=t[n];return e.jsxs("div",{className:Pt("relative w-full overflow-hidden rounded-xl",r),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[e.jsxs("div",{className:"relative aspect-[21/9] md:aspect-[3/1] w-full",children:[e.jsx("img",{src:p.image_url,alt:p.title,className:"w-full h-full object-cover rounded-t-xl"}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:Pt("absolute left-2 top-1/2 -translate-y-1/2 bg-black/30 hover:bg-black/50 text-white rounded-full","opacity-0 transition-opacity",o&&"opacity-100"),onClick:d,children:e.jsx(zl,{className:"h-6 w-6"})}),e.jsx(K,{variant:"ghost",size:"icon",className:Pt("absolute right-2 top-1/2 -translate-y-1/2 bg-black/30 hover:bg-black/50 text-white rounded-full","opacity-0 transition-opacity",o&&"opacity-100"),onClick:i,children:e.jsx(Ua,{className:"h-6 w-6"})})]}),t.length>1&&e.jsx("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex gap-2",children:t.map((f,y)=>e.jsx("button",{onClick:()=>u(y),className:Pt("w-2 h-2 rounded-full transition-all duration-300",y===n?"bg-white w-6":"bg-white/50 hover:bg-white/70"),"aria-label":`Go to slide ${y+1}`},y))})]}),e.jsxs("div",{className:"bg-foreground rounded-b-xl px-5 py-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm md:text-base font-semibold text-background truncate",children:p.title}),p.description&&e.jsx("p",{className:"text-xs text-background/70 truncate",children:p.description})]}),p.link_url&&e.jsx("a",{href:p.link_url,target:"_blank",rel:"noopener noreferrer",className:"shrink-0",children:e.jsx(K,{size:"sm",className:"bg-primary text-primary-foreground font-semibold transition-colors hover:bg-background hover:text-foreground",children:p.link_text||"Learn More"})})]})]})}function e5t(t){return"EST"}function h6(t){const r=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"America/New_York"}).format(t),n=e5t();return`${r} ${n}`}function z5(t){const s=new Date,r=new Date(t),n=V4(r,-15),a=V4(r,30);return s>a?"ended":Mg(s,{start:r,end:a})?"live":Mg(s,{start:n,end:r})?"starting_soon":"upcoming"}function dbe(t){const s=z5(t);return s==="starting_soon"||s==="live"}const eTe=dbe,t5t=({events:t,registrations:s,onNavigateToEvents:r})=>{const[n,a]=C.useState(new Date);C.useEffect(()=>{const _=setInterval(()=>{a(new Date)},3e4);return()=>clearInterval(_)},[]);const o=t.filter(_=>dbe(_.event_date));if(o.length===0)return null;const l=o[0],i=z5(l.event_date),d=s.find(_=>_.event_id===l.id),u=(d==null?void 0:d.zoom_join_url)||l.zoom_link,p=!!d,f=i==="live",y=f?{container:"from-red-500/10 via-red-500/5 to-primary/10 border-red-500/30",pulse:"from-red-500/5",indicator:"bg-red-500",text:"text-red-500",button:"bg-red-500 hover:bg-red-600",outlineButton:"border-red-500/50 text-red-500 hover:bg-red-500/10"}:{container:"from-amber-500/10 via-amber-500/5 to-primary/10 border-amber-500/30",pulse:"from-amber-500/5",indicator:"bg-amber-500",text:"text-amber-500",button:"bg-amber-500 hover:bg-amber-600",outlineButton:"border-amber-500/50 text-amber-500 hover:bg-amber-500/10"};return e.jsxs("div",{className:`relative mb-8 overflow-hidden rounded-xl bg-gradient-to-r ${y.container} border`,children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-r ${y.pulse} to-transparent animate-pulse`}),e.jsx("div",{className:"relative p-4 sm:p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex items-center justify-center",children:[e.jsx("span",{className:`absolute inline-flex h-full w-full animate-ping rounded-full ${y.indicator} opacity-75`}),e.jsx("span",{className:`relative flex h-3 w-3 rounded-full ${y.indicator}`})]}),e.jsx("div",{className:`flex items-center gap-2 ${y.text} font-bold text-sm uppercase tracking-wider`,children:f?e.jsxs(e.Fragment,{children:[e.jsx($0,{className:"h-4 w-4"}),"Live Now"]}):e.jsxs(e.Fragment,{children:[e.jsx(Tn,{className:"h-4 w-4"}),"Starting Soon"]})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-lg text-foreground line-clamp-1",children:l.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f?`Started at ${h6(new Date(l.event_date))}`:`Starts at ${h6(new Date(l.event_date))}`})]}),e.jsx("div",{className:"flex items-center gap-2",children:p?e.jsxs(K,{onClick:()=>window.open(u,"_blank"),className:`${y.button} text-white gap-2`,children:[e.jsx(sn,{className:"h-4 w-4"}),f?"Join Now":"Join When Live"]}):e.jsxs(K,{variant:"outline",onClick:r,className:`${y.outlineButton} gap-2`,children:[e.jsx(hr,{className:"h-4 w-4"}),"Register & Join"]})})]})})]})};var ube="Progress",hbe=100,[s5t]=Ec(ube),[r5t,n5t]=s5t(ube),pVe=C.forwardRef((t,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:o=a5t,...l}=t;(a||a===0)&&!tTe(a)&&console.error(i5t(`${a}`,"Progress"));const i=tTe(a)?a:hbe;n!==null&&!sTe(n,i)&&console.error(o5t(`${n}`,"Progress"));const d=sTe(n,i)?n:null,u=Kne(d)?o(d,i):void 0;return e.jsx(r5t,{scope:r,value:d,max:i,children:e.jsx(Qr.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":Kne(d)?d:void 0,"aria-valuetext":u,role:"progressbar","data-state":xVe(d,i),"data-value":d??void 0,"data-max":i,...l,ref:s})})});pVe.displayName=ube;var fVe="ProgressIndicator",gVe=C.forwardRef((t,s)=>{const{__scopeProgress:r,...n}=t,a=n5t(fVe,r);return e.jsx(Qr.div,{"data-state":xVe(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:s})});gVe.displayName=fVe;function a5t(t,s){return`${Math.round(t/s*100)}%`}function xVe(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function Kne(t){return typeof t=="number"}function tTe(t){return Kne(t)&&!isNaN(t)&&t>0}function sTe(t,s){return Kne(t)&&!isNaN(t)&&t<=s&&t>=0}function i5t(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${hbe}\`.`}function o5t(t,s){return`Invalid prop \`value\` of value \`${t}\` supplied to \`${s}\`. The \`value\` prop must be: - a positive number - less than the value passed to \`max\` (or ${hbe} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var yVe=pVe,l5t=gVe;const Ti=C.forwardRef(({className:t,value:s,...r},n)=>e.jsx(yVe,{ref:n,className:Pt("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...r,children:e.jsx(l5t,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));Ti.displayName=yVe.displayName;function c5t(){const{user:t,isBrokerageManager:s}=Hs(),[r,n]=C.useState([]),[a,o]=C.useState([]),[l,i]=C.useState(!1),[d,u]=C.useState(!0),p=s?"brokerage_manager":"agent";C.useEffect(()=>{if(!(t!=null&&t.id)){u(!1);return}f()},[t==null?void 0:t.id,p]);const f=async()=>{if(t!=null&&t.id)try{const{data:I,error:L}=await G.from("onboarding_checklist_items").select("*").eq("target_role",p).eq("is_active",!0).order("sort_order");if(L)throw L;const{data:R,error:$}=await G.from("onboarding_checklist_progress").select("item_id, completed_at").eq("user_id",t.id);if($)throw $;const{data:q,error:U}=await G.from("onboarding_checklist_dismissed").select("id").eq("user_id",t.id).maybeSingle();if(U)throw U;n(I||[]),o(R||[]),i(!!q),I&&I.length>0&&await y(I,R||[])}catch(I){console.error("Error fetching checklist data:",I)}finally{u(!1)}},y=async(I,L)=>{var Fe,Ae;if(!(t!=null&&t.id))return;const R=L.map(Ue=>Ue.item_id),$=I.filter(Ue=>!R.includes(Ue.id));if($.length===0)return;const[q,U,H,Y,se,te,Q,de,re,ae,le,he,be,_e,je]=await Promise.all([G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle(),G.from("resource_shares").select("id",{count:"exact",head:!0}).eq("sender_id",t.id),G.from("community_posts").select("id",{count:"exact",head:!0}).eq("user_id",t.id),G.from("event_registrations").select("id",{count:"exact",head:!0}).eq("user_id",t.id),G.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","template"),G.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","academy_video"),G.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","toolbox"),G.from("activity_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id),G.from("innercircle_contacts").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("agent_videos").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("contact_touch_logs").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("scorecard_transactions").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("listings").select("id",{count:"exact",head:!0}).eq("agent_id",t.id),G.from("innercircle_contacts").select("id").eq("owner_user_id",t.id),G.from("deal_pipeline").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id)]),Ne={},Ge=(Fe=q.data)==null?void 0:Fe.brokerage_id;Ne.share_resource=(U.count||0)>0,Ne.post_community=(H.count||0)>0,Ne.register_event=(Y.count||0)>0,Ne.view_template=(se.count||0)>0,Ne.watch_academy=(te.count||0)>0,Ne.use_toolbox=(Q.count||0)>0,Ne.launch_app=(de.count||0)>0,Ne.add_contact=(re.count||0)>0,Ne.create_video=(ae.count||0)>0,Ne.complete_touch=(le.count||0)>0,Ne.add_transaction=(he.count||0)>0,Ne.add_listing=(be.count||0)>0,Ne.add_deal=(je.count||0)>0;const we=((Ae=_e.data)==null?void 0:Ae.map(Ue=>Ue.id))||[],Me=[];Ge?Me.push(G.from("profiles").select("id").eq("brokerage_id",Ge).neq("id",t.id).then(Ue=>{var ut;Ne.add_agent=(((ut=Ue.data)==null?void 0:ut.length)||0)>0})):Ne.add_agent=!1,we.length>0?(Me.push(G.from("contact_plan_cycles").select("id",{count:"exact",head:!0}).in("contact_id",we).then(Ue=>{Ne.add_plan=(Ue.count||0)>0})),Me.push(G.from("contact_popby_settings").select("id",{count:"exact",head:!0}).in("contact_id",we).then(Ue=>{Ne.schedule_popby=(Ue.count||0)>0}))):(Ne.add_plan=!1,Ne.schedule_popby=!1),await Promise.all(Me);const Te=$.filter(Ue=>Ne[Ue.action_type]);if(Te.length>0){const Ue=Te.map(De=>({user_id:t.id,item_id:De.id})),{error:ut}=await G.from("onboarding_checklist_progress").upsert(Ue,{onConflict:"user_id,item_id",ignoreDuplicates:!0});if(!ut){const De=Te.map(Rt=>({item_id:Rt.id,completed_at:new Date().toISOString()}));o(Rt=>[...Rt,...De])}}},_=async I=>{if(t!=null&&t.id)try{const{error:L}=await G.from("onboarding_checklist_progress").insert({user_id:t.id,item_id:I});if(L)throw L;o(R=>[...R,{item_id:I,completed_at:new Date().toISOString()}])}catch(L){console.error("Error marking item complete:",L)}},b=async()=>{if(t!=null&&t.id)try{const{error:I}=await G.from("onboarding_checklist_dismissed").insert({user_id:t.id});if(I)throw I;i(!0)}catch(I){console.error("Error dismissing checklist:",I)}},w=a.length,j=r.length,k=j>0&&w>=j,S=j>0?w/j*100:0;return{items:r,progress:a,isDismissed:l,loading:d,completedCount:w,totalCount:j,isComplete:k,progressPercentage:S,isItemComplete:I=>a.some(L=>L.item_id===I),markComplete:_,dismiss:b,refetch:f}}const d5t={add_agent:e.jsx(hr,{className:"h-4 w-4"}),share_resource:e.jsx(ld,{className:"h-4 w-4"}),post_community:e.jsx(io,{className:"h-4 w-4"}),register_event:e.jsx(on,{className:"h-4 w-4"}),view_template:e.jsx(p0,{className:"h-4 w-4"}),watch_academy:e.jsx(ah,{className:"h-4 w-4"}),use_toolbox:e.jsx(Wg,{className:"h-4 w-4"}),launch_app:e.jsx(sP,{className:"h-4 w-4"}),add_deal:e.jsx(Xx,{className:"h-4 w-4"}),add_listing:e.jsx(On,{className:"h-4 w-4"})},u5t={add_deal:"/mission-control/pipeline",add_listing:"/mission-control/listings/new",post_community:"/community",add_contact:"/mission-control/contacts"};function h5t(){const{items:t,isDismissed:s,loading:r,completedCount:n,totalCount:a,isComplete:o,progressPercentage:l,isItemComplete:i,markComplete:d,dismiss:u}=c5t(),p=Pr(),[f,y]=C.useState(!0);return r||s||a===0||o?null:e.jsxs(Ee,{className:"mb-6 border-primary/20 bg-gradient-to-r from-primary/5 to-transparent",children:[e.jsxs(It,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Qx,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Get Started with LevelUp"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Complete these steps to make the most of your membership"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>y(!f),className:"h-8 w-8 p-0",children:f?e.jsx(Ug,{className:"h-4 w-4"}):e.jsx(Ho,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",children:e.jsx(Ur,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm mb-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Progress"}),e.jsxs("span",{className:"font-medium",children:[n," of ",a," complete"]})]}),e.jsx(Ti,{value:l,className:"h-2"})]})]}),f&&e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"space-y-3",children:t.map(_=>{const b=i(_.id);return e.jsxs("div",{className:Pt("flex items-start gap-3 p-3 rounded-lg transition-colors",b?"bg-muted/50":"bg-background hover:bg-muted/30 cursor-pointer"),onClick:()=>{if(b)return;const w=u5t[_.action_type];w?p(w):d(_.id)},children:[e.jsx("div",{className:"mt-0.5",children:b?e.jsx(ua,{className:"h-5 w-5 text-primary"}):e.jsx(Kc,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:d5t[_.action_type]||e.jsx(Kc,{className:"h-4 w-4"})}),e.jsx("span",{className:Pt("font-medium",b&&"line-through text-muted-foreground"),children:_.title})]}),_.description&&e.jsx("p",{className:Pt("text-sm text-muted-foreground mt-1",b&&"line-through"),children:_.description})]})]},_.id)})})})]})}const Rf=()=>wt({queryKey:["relationship-types"],queryFn:async()=>{const{data:t,error:s}=await G.from("relationship_types").select("*").order("sort_order");if(s)throw s;return t}}),tm=t=>{const s=Ya(),r=1e3,n=async a=>{const o=[];let l=0;for(;;){const{data:i,error:d}=await a.range(l,l+r-1);if(d)throw d;const u=i??[];if(o.push(...u),u.length{let a=G.from("innercircle_contacts").select(` *, lead_source_ref:lead_sources(id, name), tags:innercircle_contact_tags( id, contact_id, relationship_type_id, relationship_type:relationship_types(*) ) `).eq("owner_user_id",s).order("created_at",{ascending:!1}).order("first_name");return await n(a)},enabled:!!s})},m5t=t=>wt({queryKey:["innercircle-contact",t],queryFn:async()=>{const{data:s,error:r}=await G.from("innercircle_contacts").select(` *, lead_source_ref:lead_sources(id, name), tags:innercircle_contact_tags( id, contact_id, relationship_type_id, relationship_type:relationship_types(*) ) `).eq("id",t).maybeSingle();if(r)throw r;return s},enabled:!!t}),vVe=()=>{const t=Ya();return wt({queryKey:["innercircle-contact-counts",t],queryFn:async()=>{const{data:s,error:r}=await G.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(r)throw r;const n={};return s==null||s.forEach(a=>{var o;(o=a.tags)==null||o.forEach(l=>{n[l.relationship_type_id]=(n[l.relationship_type_id]||0)+1})}),n},enabled:!!t})},hle=()=>{const t=rs(),s=Ya();return Dt({mutationFn:async r=>{const{tagIds:n,...a}=r,o={...a,birthday:a.birthday||null,home_anniversary:a.home_anniversary||null,owner_user_id:s},{data:l,error:i}=await G.from("innercircle_contacts").insert(o).select().single();if(i)throw i;if(n&&n.length>0){const{error:d}=await G.from("innercircle_contact_tags").insert(n.map(u=>({contact_id:l.id,relationship_type_id:u})));if(d)throw d}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),pn({title:"Contact created successfully"})},onError:r=>{pn({title:"Error creating contact",description:r.message,variant:"destructive"})}})},mbe=()=>{const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{tagIds:n,tags:a,...o}=r,l={...o,birthday:o.birthday||null,home_anniversary:o.home_anniversary||null},{data:i,error:d}=await G.from("innercircle_contacts").update(l).eq("id",s).select().single();if(d)throw d;if(n!==void 0&&(await G.from("innercircle_contact_tags").delete().eq("contact_id",s),n.length>0)){const{error:u}=await G.from("innercircle_contact_tags").insert(n.map(p=>({contact_id:s,relationship_type_id:p})));if(u)throw u}return i},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),pn({title:"Contact updated successfully"})},onError:s=>{pn({title:"Error updating contact",description:s.message,variant:"destructive"})}})},_Ve=()=>{const t=rs();return Dt({mutationFn:async({contactId:s,spouseContactId:r})=>{if(r){const{error:n}=await G.from("innercircle_contacts").update({spouse_contact_id:r}).eq("id",s);if(n)throw n;const{error:a}=await G.from("innercircle_contacts").update({spouse_contact_id:s}).eq("id",r);if(a)throw a}else{const{data:n}=await G.from("innercircle_contacts").select("spouse_contact_id").eq("id",s).single(),a=n==null?void 0:n.spouse_contact_id,{error:o}=await G.from("innercircle_contacts").update({spouse_contact_id:null}).eq("id",s);if(o)throw o;if(a){const{error:l}=await G.from("innercircle_contacts").update({spouse_contact_id:null}).eq("id",a);if(l)throw l}}},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-spouse"]}),pn({title:"Spouse link updated"})},onError:s=>{pn({title:"Error linking spouse",description:s.message,variant:"destructive"})}})},pbe=()=>{const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("innercircle_contacts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),pn({title:"Contact deleted successfully"})},onError:s=>{pn({title:"Error deleting contact",description:s.message,variant:"destructive"})}})},UL=()=>wt({queryKey:["action-types"],queryFn:async()=>{const{data:t,error:s}=await G.from("action_types").select("*").order("sort_order");if(s)throw s;return t}}),p5t=t=>wt({queryKey:["action-scripts",t],queryFn:async()=>{let s=G.from("action_scripts").select("*, action_type:action_types(*)");const{data:r,error:n}=await s;if(n)throw n;return r}}),f5t=()=>wt({queryKey:["touchpoint-plans"],queryFn:async()=>{const{data:t,error:s}=await G.from("touchpoint_plans").select(` *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) `).order("name");if(s)throw s;return t}}),g5t=()=>{const t=rs(),s=Ya();return Dt({mutationFn:async({name:r,description:n})=>{const{data:a,error:o}=await G.from("touchpoint_plans").insert({name:r,description:n,owner_user_id:s,active:!0,is_template:!1}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),pn({title:"Plan created successfully"})},onError:r=>{pn({title:"Error creating plan",description:r.message,variant:"destructive"})}})},x5t=()=>{const t=rs(),s=Ya();return Dt({mutationFn:async({sourcePlanId:r,newName:n})=>{const{data:a,error:o}=await G.from("touchpoint_plans").select(` *, items:touchpoint_plan_items(*) `).eq("id",r).single();if(o)throw o;if(!a)throw new Error("Source plan not found");const{data:l,error:i}=await G.from("touchpoint_plans").insert({name:n,description:a.description,owner_user_id:s,active:!0,is_template:!1}).select().single();if(i)throw i;if(a.items&&a.items.length>0){const d=a.items.map(p=>({plan_id:l.id,month_number:p.month_number,action_type_id:p.action_type_id,default_script_id:p.default_script_id,notes:p.notes})),{error:u}=await G.from("touchpoint_plan_items").insert(d);if(u)throw u}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),pn({title:"Plan duplicated successfully",description:"You can now edit your copy of this plan."})},onError:r=>{pn({title:"Error duplicating plan",description:r.message,variant:"destructive"})}})},y5t=()=>{const t=rs();return Dt({mutationFn:async({id:s,name:r,description:n})=>{const{data:a,error:o}=await G.from("touchpoint_plans").update({name:r,description:n}).eq("id",s).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),pn({title:"Plan updated successfully"})}})},v5t=()=>{const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("touchpoint_plans").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),pn({title:"Plan deleted successfully"})}})},_5t=()=>{const t=rs();return Dt({mutationFn:async({planId:s,items:r})=>{if(await G.from("touchpoint_plan_items").delete().eq("plan_id",s),r.length>0){const{error:n}=await G.from("touchpoint_plan_items").insert(r.map(a=>({plan_id:s,month_number:a.month_number,action_type_id:a.action_type_id,default_script_id:a.default_script_id||null,notes:a.notes})));if(n)throw n}},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),pn({title:"Plan schedule updated"})}})},b5t=()=>{const t=rs();return Dt({mutationFn:async({actionTypeId:s,title:r,scriptBody:n,emailSubject:a,tone:o})=>{const{data:{user:l}}=await G.auth.getUser(),{data:i,error:d}=await G.from("action_scripts").insert({action_type_id:s,title:r,script_body:n,email_subject:a||null,tone:o||null,active:!0,user_id:l==null?void 0:l.id}).select().single();if(d)throw d;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["action-scripts"]}),pn({title:"Script created successfully"})},onError:s=>{pn({title:"Error creating script",description:s.message,variant:"destructive"})}})},w5t=()=>{const t=Ya();return wt({queryKey:["user-plan-enrollments",t],queryFn:async()=>{const{data:s,error:r}=await G.from("user_plan_enrollments").select(` *, plan:touchpoint_plans(*), relationship_type:relationship_types(*) `);if(r)throw r;return s},enabled:!!t})},j5t=()=>{const t=rs(),s=Ya();return Dt({mutationFn:async({planId:r,relationshipTypeId:n,active:a})=>{const{data:o}=await G.from("user_plan_enrollments").select("id").eq("plan_id",r).eq("relationship_type_id",n).maybeSingle();if(o){const{error:l}=await G.from("user_plan_enrollments").update({active:a}).eq("id",o.id);if(l)throw l}else if(a){const{error:l}=await G.from("user_plan_enrollments").insert({owner_user_id:s,plan_id:r,relationship_type_id:n,active:!0,start_date:new Date().toISOString().split("T")[0]});if(l)throw l}},onSuccess:()=>{t.invalidateQueries({queryKey:["user-plan-enrollments"]}),pn({title:"Plan enrollment updated"})}})},VL=(t=7)=>{const s=Ya();return wt({queryKey:["contact-touch-logs",s,t],queryFn:async()=>{const r=new Date;r.setDate(r.getDate()-t);const{data:n,error:a}=await G.from("contact_touch_logs").select(` *, contact:innercircle_contacts(*), action_type:action_types(*) `).eq("owner_user_id",s).gte("completed_at",r.toISOString()).order("completed_at",{ascending:!1});if(a)throw a;return n},enabled:!!s})},bVe=()=>{const t=Ya();return wt({queryKey:["contacts-last-touch",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_touch_logs").select("contact_id, completed_at").eq("owner_user_id",t).order("completed_at",{ascending:!1});if(r)throw r;const n={};return s==null||s.forEach(a=>{n[a.contact_id]||(n[a.contact_id]=a.completed_at)}),n},enabled:!!t})},N5t=(t=90)=>{const{data:s}=tm(),{data:r}=bVe();if(!s||!r)return{contacts:[],count:0};const n=new Date;n.setDate(n.getDate()-t);const a=s.filter(o=>{const l=r[o.id];return l?new Date(l){const t=rs(),s=Ya();return Dt({mutationFn:async({contactId:r,actionTypeId:n,scriptUsedId:a,notes:o,completedAt:l})=>{const{data:i,error:d}=await G.from("contact_touch_logs").insert({owner_user_id:s,contact_id:r,action_type_id:n,script_used_id:a,notes:o,completed_at:l||new Date().toISOString()}).select().single();if(d)throw d;return i},onSuccess:async(r,n)=>{var a,o;t.invalidateQueries({queryKey:["contact-touch-logs"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),t.invalidateQueries({queryKey:["today-actions"]}),pn({title:"Action completed!"});try{const[l,i]=await Promise.all([G.from("innercircle_contacts").select("email").eq("id",n.contactId).single(),G.from("action_types").select("name").eq("id",n.actionTypeId).single()]),d=(a=l.data)==null?void 0:a.email,u=((o=i.data)==null?void 0:o.name)||"Touch";d&&G.functions.invoke("boldtrail-sync",{body:{action:"push_touch",contact_email:d,touch_type:u,touch_notes:n.notes||null,touch_date:n.completedAt||r.completed_at}}).catch(()=>{})}catch{}}})},wVe="agentos_weekly_touch_goal",rTe=20,Zne=()=>{if(typeof window>"u")return rTe;const t=localStorage.getItem(wVe);if(t){const s=parseInt(t,10);if(!isNaN(s)&&s>0)return s}return rTe},jVe=t=>{localStorage.setItem(wVe,t.toString())},gbe=()=>{const{data:t}=VL(7),s=new Date;s.setHours(0,0,0,0);const r=new Date(s);r.setDate(s.getDate()-s.getDay());const n=(t==null?void 0:t.filter(l=>new Date(l.completed_at)>=r).length)||0;let a=0;if(t&&t.length>0){const l=new Set(t.map(d=>new Date(d.completed_at).toDateString()));let i=new Date(s);for(;l.has(i.toDateString());)a++,i.setDate(i.getDate()-1)}const o=Zne();return{actionsThisWeek:n,weeklyGoal:o,streak:a,progress:Math.min(n/o*100,100)}},k5t=()=>{const t=Ya();return wt({queryKey:["contact-plan-cycles",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_plan_cycles").select(` *, contact:innercircle_contacts(*), plan:touchpoint_plans( *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) ) `);if(r)throw r;return s},enabled:!!t})},S5t=()=>{const t=rs();return Ya(),Dt({mutationFn:async()=>{const{data:s}=await G.from("user_plan_enrollments").select("*").eq("active",!0);if(!s||s.length===0)return;const{data:r}=await G.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(!r)return;const{data:n}=await G.from("contact_plan_cycles").select("contact_id, plan_id"),a=new Set((n==null?void 0:n.map(l=>`${l.contact_id}-${l.plan_id}`))||[]),o=[];for(const l of r)for(const i of l.tags||[]){const d=s.find(u=>u.relationship_type_id===i.relationship_type_id);d&&!a.has(`${l.id}-${d.plan_id}`)&&o.push({contact_id:l.id,plan_id:d.plan_id,relationship_type_id:i.relationship_type_id})}if(o.length>0){const{error:l}=await G.from("contact_plan_cycles").insert(o);if(l)throw l}return o.length},onSuccess:s=>{t.invalidateQueries({queryKey:["contact-plan-cycles"]}),s&&s>0&&pn({title:`${s} contact(s) enrolled in plans`})}})},NVe=()=>{const t=Ya(),{data:s}=k5t(),{data:r}=VL(30);return wt({queryKey:["today-actions",t,s==null?void 0:s.length,r==null?void 0:r.length],queryFn:async()=>{var b;if(!s||s.length===0)return[];const{data:n}=await G.from("contact_snoozes").select("contact_id").gte("snoozed_until",new Date().toISOString()),a=new Set((n==null?void 0:n.map(w=>w.contact_id))||[]),o=new Date,l=[],i=new Date(o.getFullYear(),o.getMonth(),1),d=new Set((r==null?void 0:r.filter(w=>new Date(w.completed_at)>=i).map(w=>`${w.contact_id}-${w.action_type_id}`))||[]);for(const w of s){if(!((b=w.plan)!=null&&b.items)||w.plan.items.length===0||!w.contact||a.has(w.contact_id))continue;const j=new Date(w.cycle_start_date),S=Math.floor((o.getTime()-j.getTime())/(30.44*24*60*60*1e3))%12+1,T=w.plan.items.find(I=>I.month_number===S);if(T&&T.action_type){const I=`${w.contact_id}-${T.action_type_id}`;if(!d.has(I)){const{data:L}=await G.from("relationship_types").select("name").eq("id",w.relationship_type_id).single();l.push({contact:w.contact,actionType:T.action_type,script:T.default_script||void 0,planName:w.plan.name,relationshipTypeName:(L==null?void 0:L.name)||"",monthNumber:S})}}}const u=5,p=o.getDate(),f=l.sort((w,j)=>w.contact.first_name.localeCompare(j.contact.first_name)),y=(p-1)%Math.max(1,f.length);return[...f.slice(y),...f.slice(0,y)].slice(0,u)},enabled:!!t&&!!s})};function C5t(){const t=Pr(),{data:s,isLoading:r}=NVe(),{data:n}=tm(),a=gbe(),[o,l]=C.useState(Zne()),[i,d]=C.useState(""),[u,p]=C.useState(!1);C.useEffect(()=>{l(Zne())},[]);const f=()=>{const R=parseInt(i,10);if(isNaN(R)||R<1){pn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}l(R),jVe(R),p(!1),pn({title:"Goal updated",description:`Weekly touch goal set to ${R}`})},y=()=>{d(o.toString()),p(!0)},_=Zh(new Date),b=ml(_,7),w=R=>{if(!R)return null;const $=R.split(/[-/T]/);if($.length<3)return null;const q=parseInt($[1],10)-1,U=parseInt($[2],10);return isNaN(q)||isNaN(U)?null:new Date(_.getFullYear(),q,U)},j=(n==null?void 0:n.map(R=>{const $=w(R.birthday),q=w(R.home_anniversary),U=[];return $&&$>=_&&$<=b&&U.push({contact:R,type:"birthday",date:$,isToday:cl($,_)}),q&&q>=_&&q<=b&&U.push({contact:R,type:"anniversary",date:q,isToday:cl(q,_)}),U}).flat().sort((R,$)=>R.date.getTime()-$.date.getTime()).slice(0,3))||[],k=(n==null?void 0:n.filter(R=>{const $=w(R.birthday),q=w(R.home_anniversary);return $&&cl($,_)||q&&cl(q,_)}).length)||0,S=(s==null?void 0:s.length)||0,T=k+S,I=(a==null?void 0:a.actionsThisWeek)||0,L=(a==null?void 0:a.streak)||0;return r?e.jsx(Ee,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-primary/20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-primary/20 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-primary/10 rounded w-1/2"})]})]})})}):e.jsxs(Ee,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:[e.jsxs(It,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5 text-primary"}),"Agent OS"]}),e.jsx("div",{className:"flex items-center gap-2",children:L>0&&e.jsxs(rt,{variant:"secondary",className:"gap-1 bg-orange-500/10 text-orange-600 border-orange-200",children:[e.jsx(nh,{className:"h-3 w-3"}),L," day streak"]})})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[T>0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-primary font-medium",children:[T," tasks"]})," for today"]}):"No tasks for today",I>0&&e.jsxs("span",{className:"ml-2",children:["• ",e.jsx("span",{className:"text-emerald-600 font-medium",children:I})," touches this week"]})]})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:R=>{R.stopPropagation(),t("/mission-control/contacts?new=true")},children:[e.jsx(yc,{className:"h-3.5 w-3.5"}),"Add Contact"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:R=>{R.stopPropagation(),t("/mission-control")},children:[e.jsx(Qn,{className:"h-3.5 w-3.5"}),"Log Touch"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5 border-emerald-200 text-emerald-700 hover:bg-emerald-50 hover:text-emerald-800",onClick:R=>{R.stopPropagation(),t("/mission-control/video/record")},children:[e.jsx(Nn,{className:"h-3.5 w-3.5"}),"Quick Video"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:R=>{R.stopPropagation(),t("/mission-control/popbys")},children:[e.jsx(Oi,{className:"h-3.5 w-3.5"}),"Pop-by Map"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5 border-purple-200 text-purple-700 hover:bg-purple-50 hover:text-purple-800",onClick:R=>{R.stopPropagation(),t("/mission-control/pipeline")},children:[e.jsx(Xx,{className:"h-3.5 w-3.5"}),"Pipeline"]})]}),e.jsxs("div",{className:"pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Gh,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Weekly Goal"}),e.jsxs(_s,{open:u,onOpenChange:p,children:[e.jsx(Ei,{asChild:!0,children:e.jsx("button",{onClick:y,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx($l,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})})}),e.jsxs(vs,{className:"sm:max-w-[360px]",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Set Weekly Goal"}),e.jsx(Kr,{children:"How many touches do you want to complete each week?"})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"weekly-goal",children:"Weekly touch goal"}),e.jsx(Re,{id:"weekly-goal",type:"number",min:"1",value:i,onChange:R=>d(R.target.value),placeholder:"20",onKeyDown:R=>{R.key==="Enter"&&f()}})]}),e.jsx(K,{onClick:f,className:"w-full",children:"Save Goal"})]})]})]})]}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium text-primary",children:I}),e.jsxs("span",{className:"text-muted-foreground",children:[" / ",o," touches"]})]})]}),e.jsx(Ti,{value:Math.min(I/o*100,100),className:"h-2 bg-muted [&>div]:bg-primary"}),I>=o&&e.jsxs("p",{className:"text-xs text-emerald-600 mt-1.5 flex items-center gap-1",children:[e.jsx("span",{children:"🎉"})," Goal achieved! Keep the momentum going."]}),I0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5",children:[o-I," more to hit your weekly goal"]})]}),j.length>0&&e.jsxs("div",{className:"pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(zu,{className:"h-4 w-4 text-pink-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Upcoming Milestones"})]}),e.jsx("div",{className:"space-y-2",children:j.map((R,$)=>e.jsxs("div",{className:`flex items-center justify-between p-2 rounded-lg cursor-pointer transition-colors ${R.isToday?"bg-pink-500/10 hover:bg-pink-500/15":"bg-muted/50 hover:bg-muted"}`,onClick:q=>{q.stopPropagation(),t(`/mission-control/contacts/${R.contact.id}`)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[R.type==="birthday"?e.jsx(zu,{className:"h-3.5 w-3.5 text-pink-500"}):e.jsx(On,{className:"h-3.5 w-3.5 text-blue-500"}),e.jsxs("span",{className:"text-sm",children:[R.contact.first_name," ",R.contact.last_name]}),R.isToday&&e.jsx(rt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-pink-500/20 text-pink-600",children:"Today!"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:R.isToday?R.type==="birthday"?"🎂":"🏠":ys(R.date,"EEE, MMM d")}),e.jsx(Ua,{className:"h-3 w-3"})]})]},`${R.contact.id}-${R.type}-${$}`))})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full gap-1 text-muted-foreground hover:text-primary",onClick:()=>t("/mission-control"),children:["Open Agent OS",e.jsx($i,{className:"h-4 w-4"})]})]})]})}function M5t(t){return wt({queryKey:["brokerage-content-categories",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("brokerage_content_categories").select("*").eq("brokerage_id",t).order("sort_order");if(r)throw r;return s},enabled:!!t})}function T5t(t,s){return wt({queryKey:["brokerage-content",t,s],queryFn:async()=>{if(!t)return[];let r=G.from("brokerage_content").select("*, category:brokerage_content_categories(*)").eq("brokerage_id",t).order("created_at",{ascending:!1});s&&(r=r.eq("category_id",s));const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!t})}function A5t(t,s=4){return wt({queryKey:["brokerage-content-recent",t,s],queryFn:async()=>{if(!t)return[];const{data:r,error:n}=await G.from("brokerage_content").select("*, category:brokerage_content_categories(*)").eq("brokerage_id",t).order("created_at",{ascending:!1}).limit(s);if(n)throw n;return r},enabled:!!t})}function E5t(t){const s=rs();return Dt({mutationFn:async r=>{const{data:n,error:a}=await G.from("brokerage_content").insert(r).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content"]}),s.invalidateQueries({queryKey:["brokerage-content-recent"]})}})}function P5t(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("brokerage_content").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-content"]}),t.invalidateQueries({queryKey:["brokerage-content-recent"]})}})}function I5t(t){const s=rs();return Dt({mutationFn:async r=>{const{data:n,error:a}=await G.from("brokerage_content_categories").insert({...r,brokerage_id:t}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}function L5t(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("brokerage_content_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}function D5t(t){const s=rs();return Dt({mutationFn:async()=>{const r=[{name:"Events",icon:"📅",sort_order:0,is_default:!0,brokerage_id:t},{name:"Videos",icon:"🎥",sort_order:1,is_default:!0,brokerage_id:t},{name:"Documents",icon:"📄",sort_order:2,is_default:!0,brokerage_id:t},{name:"Resources",icon:"🔗",sort_order:3,is_default:!0,brokerage_id:t},{name:"Graphics",icon:"🎨",sort_order:4,is_default:!0,brokerage_id:t}],{error:n}=await G.from("brokerage_content_categories").upsert(r,{onConflict:"brokerage_id,name"});if(n)throw n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}const O5t={video:ul,pdf:In,link:Wo,event:on,graphic:Bl},R5t={video:"bg-red-500/10 text-red-600 dark:text-red-400",pdf:"bg-blue-500/10 text-blue-600 dark:text-blue-400",link:"bg-green-500/10 text-green-600 dark:text-green-400",event:"bg-purple-500/10 text-purple-600 dark:text-purple-400",graphic:"bg-amber-500/10 text-amber-600 dark:text-amber-400"};function F5t(t){if(!t)return null;try{const s=new URL(t),r=s.hostname.replace("www.","");let n=null;if(r==="youtube.com"||r==="m.youtube.com"?n=s.searchParams.get("v"):r==="youtu.be"&&(n=s.pathname.slice(1)),n)return`https://img.youtube.com/vi/${n}/hqdefault.jpg`}catch{}return null}function z5t(t){if(!t)return!1;try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function B5t({item:t}){const s=Pr(),r=O5t[t.content_type]||Wo,n=R5t[t.content_type]||"",[a,o]=C.useState(null),l=t.thumbnail_url||(t.content_type==="graphic"&&t.file_url?t.file_url:null)||(t.content_type==="video"?F5t(t.url):null);C.useEffect(()=>{l||!t.url||t.content_type!=="video"||!z5t(t.url)||fetch(`https://www.youtube.com/oembed?url=${encodeURIComponent(t.url)}&format=json`).then(d=>d.ok?d.json():null).then(d=>{d!=null&&d.thumbnail_url&&o(d.thumbnail_url)}).catch(()=>{})},[t.url,t.content_type,l]);const i=l||a;return e.jsxs(Ee,{className:"group cursor-pointer overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",onClick:()=>s(`/brokerage-content/${t.id}`),children:[i?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:i,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}):e.jsx("div",{className:"aspect-video bg-muted/20 flex items-center justify-center",children:e.jsx(r,{className:"h-8 w-8 text-muted-foreground/30"})}),e.jsxs(Oe,{className:"p-3",children:[e.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:e.jsxs(rt,{variant:"secondary",className:`text-[10px] px-1.5 py-0 ${n}`,children:[e.jsx(r,{className:"h-3 w-3 mr-0.5"}),t.content_type]})}),e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:t.title}),t.content_type==="event"&&t.event_date&&e.jsx("p",{className:"text-xs text-primary mt-1 font-medium",children:ys(new Date(t.event_date),"MMM d · h:mm a")})]})]})}function $5t(){const{brokerageId:t}=Hs(),s=Pr(),{data:r=[],isLoading:n}=A5t(t,4);return!t||n||r.length===0?null:e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Brokerage Content"})]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/brokerage-content"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx($i,{className:"h-4 w-4"})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:r.map(a=>e.jsx(B5t,{item:a},a.id))})]})}const kVe=()=>wt({queryKey:["listing-exchange-enabled"],queryFn:async()=>{const{data:t,error:s}=await G.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").maybeSingle();if(s)throw s;return(t==null?void 0:t.enabled)??!1}}),SVe=t=>{const{user:s,brokerageId:r}=Hs();return wt({queryKey:["listings",t,r],queryFn:async()=>{let n=G.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("is_public",!0);t!=null&&t.status&&(n=n.eq("status",t.status)),t!=null&&t.propertyType&&(n=n.eq("property_type",t.propertyType)),t!=null&&t.city&&(n=n.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(n=n.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(n=n.lte("price",t.maxPrice)),t!=null&&t.openToReferrals&&(n=n.eq("open_to_referrals",!0));const{data:a,error:o}=await n;if(o)throw o;let l=a||[];if(r){const{data:i}=await G.from("profiles").select("id").eq("brokerage_id",r);if(i&&i.length>0){const d=i.map(f=>f.id);let u=G.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("share_with_brokerage",!0).eq("is_public",!1).in("agent_id",d);t!=null&&t.status&&(u=u.eq("status",t.status)),t!=null&&t.propertyType&&(u=u.eq("property_type",t.propertyType)),t!=null&&t.city&&(u=u.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(u=u.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(u=u.lte("price",t.maxPrice)),t!=null&&t.openToReferrals&&(u=u.eq("open_to_referrals",!0));const{data:p}=await u;if(p){const f=new Set(l.map(_=>_.id)),y=p.filter(_=>!f.has(_.id));l=[...l,...y]}}}switch(t==null?void 0:t.sortBy){case"updated":l.sort((i,d)=>new Date(d.updated_at).getTime()-new Date(i.updated_at).getTime());break;case"price_asc":l.sort((i,d)=>i.price-d.price);break;case"price_desc":l.sort((i,d)=>d.price-i.price);break;default:l.sort((i,d)=>new Date(d.created_at).getTime()-new Date(i.created_at).getTime())}return l}})},CVe=()=>{const{user:t}=Hs();return wt({queryKey:["my-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("listings").select(` *, photos:listing_photos(*) `).eq("agent_id",t.id).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})},MVe=t=>{const{user:s}=Hs();return wt({queryKey:["listing",t],queryFn:async()=>{const{data:r,error:n}=await G.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)), video:agent_videos!listings_video_id_fkey(id, playback_url, thumbnail_url, title, duration_seconds) `).eq("id",t).single();if(n)throw n;return s&&await G.from("listing_views").insert({listing_id:t,viewer_id:s.id}),r},enabled:!!t})},q5t=()=>{const t=rs(),{user:s}=Hs();return Dt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("listings").insert({...r,agent_id:s.id}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},U5t=()=>{const t=rs();return Dt({mutationFn:async({agentId:s,...r})=>{const{data:n,error:a}=await G.from("listings").insert({...r,agent_id:s}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]}),t.invalidateQueries({queryKey:["brokerage-listings"]})}})},V5t=()=>{const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("listings").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]}),t.invalidateQueries({queryKey:["listing",s.id]})}})},TVe=()=>{const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("listings").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},H5t=()=>{const t=rs();return Dt({mutationFn:async({listingId:s,photoUrl:r,isPrimary:n=!1})=>{const{data:a,error:o}=await G.from("listing_photos").insert({listing_id:s,photo_url:r,is_primary:n}).select().single();if(o)throw o;return a},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s.listing_id]}),t.invalidateQueries({queryKey:["my-listings"]})}})},W5t=()=>{const t=rs();return Dt({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await G.from("listing_photos").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s]}),t.invalidateQueries({queryKey:["my-listings"]})}})},G5t=()=>{const t=rs();return Dt({mutationFn:async({photos:s})=>{var o;const r=s.map(l=>G.from("listing_photos").update({sort_order:l.sort_order,is_primary:l.is_primary}).eq("id",l.id)),a=(o=(await Promise.all(r)).find(l=>l.error))==null?void 0:o.error;if(a)throw a;return s},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["listing"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},K5t=()=>{const t=rs();return Dt({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await G.from("listing_photos").update({is_primary:!1}).eq("listing_id",r);if(n)throw n;const{error:a}=await G.from("listing_photos").update({is_primary:!0}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s]}),t.invalidateQueries({queryKey:["my-listings"]})}})},Z5t=()=>{const{user:t}=Hs();return wt({queryKey:["saved-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("listing_saves").select(` *, listing:listings( *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id) ) `).eq("agent_id",t.id);if(r)throw r;return s},enabled:!!t})},AVe=()=>{const t=rs(),{user:s}=Hs();return Dt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await G.from("listing_saves").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await G.from("listing_saves").delete().eq("id",n.id),{saved:!1}):(await G.from("listing_saves").insert({listing_id:r,agent_id:s.id}),{saved:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["saved-listings"]}),t.invalidateQueries({queryKey:["listings"]})}})},EVe=t=>{const{user:s}=Hs();return wt({queryKey:["listing-saved",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await G.from("listing_saves").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},Y5t=()=>{const t=rs(),{user:s}=Hs();return Dt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await G.from("listing_follows").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await G.from("listing_follows").delete().eq("id",n.id),{following:!1}):(await G.from("listing_follows").insert({listing_id:r,agent_id:s.id}),{following:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["listing-following"]})}})},X5t=t=>{const{user:s}=Hs();return wt({queryKey:["listing-following",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await G.from("listing_follows").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},Q5t=()=>{const{user:t}=Hs();return Dt({mutationFn:async({listingId:s,shareType:r})=>{if(!t)throw new Error("Not authenticated");const{error:n}=await G.from("listing_shares").insert({listing_id:s,sharing_agent_id:t.id,share_type:r});if(n)throw n}})},J5t=()=>{const{user:t}=Hs();return wt({queryKey:["my-referrals",t==null?void 0:t.id],queryFn:async()=>{if(!t)return{sent:[],received:[]};const[s,r]=await Promise.all([G.from("listing_referrals").select(` *, listing:listings(*,photos:listing_photos(*)) `).eq("sender_agent_id",t.id).order("created_at",{ascending:!1}),G.from("listing_referrals").select(` *, sender:profiles!listing_referrals_sender_agent_id_fkey(id, name, email), listing:listings(*,photos:listing_photos(*)) `).eq("listing_agent_id",t.id).order("created_at",{ascending:!1})]);return{sent:s.data||[],received:r.data||[]}},enabled:!!t})},e3t=()=>{const t=rs(),{user:s}=Hs();return Dt({mutationFn:async({listingId:r,listingAgentId:n,buyerName:a,buyerType:o,notes:l})=>{if(!s)throw new Error("Not authenticated");const{data:i,error:d}=await G.from("listing_referrals").insert({listing_id:r,sender_agent_id:s.id,listing_agent_id:n,buyer_name:a,buyer_type:o,notes:l}).select().single();if(d)throw d;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["my-referrals"]})}})},t3t=()=>wt({queryKey:["listing-leaderboard"],queryFn:async()=>{const{data:t}=await G.from("listing_shares").select("sharing_agent_id, profiles!listing_shares_agent_id_fkey(name)").order("created_at",{ascending:!1}),s=new Map;t==null||t.forEach(l=>{var u;const i=l.sharing_agent_id;if(!i)return;const d=s.get(i);d?d.count++:s.set(i,{name:((u=l.profiles)==null?void 0:u.name)||"Unknown",count:1})});const r=Array.from(s.entries()).map(([l,i])=>({agentId:l,...i})).sort((l,i)=>i.count-l.count).slice(0,10),{data:n}=await G.from("listings").select("agent_id, agent:profiles!listings_agent_id_fkey(name)").eq("is_approved",!0),a=new Map;n==null||n.forEach(l=>{var d;const i=a.get(l.agent_id);i?i.count++:a.set(l.agent_id,{name:((d=l.agent)==null?void 0:d.name)||"Unknown",count:1})});const o=Array.from(a.entries()).map(([l,i])=>({agentId:l,...i})).sort((l,i)=>i.count-l.count).slice(0,10);return{topSharers:r,topListers:o}}}),s3t=()=>{const{user:t,brokerageId:s}=Hs();return wt({queryKey:["brokerage-listings",s],queryFn:async()=>{if(!t||!s)return[];const{data:r}=await G.from("profiles").select("id").eq("brokerage_id",s);if(!r||r.length===0)return[];const n=r.map(l=>l.id),{data:a,error:o}=await G.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).in("agent_id",n).eq("is_approved",!0).order("created_at",{ascending:!1});if(o)throw o;return a},enabled:!!t&&!!s})},PVe=({className:t,variant:s="default"})=>e.jsx(rt,{variant:"outline",className:Pt("text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0 h-4",s==="default"?"border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10":"border-muted-foreground/30 text-muted-foreground",t),children:"Beta"}),r3t={coming_soon:"bg-amber-500/10 text-amber-600 border-amber-200",active:"bg-emerald-500/10 text-emerald-600 border-emerald-200",under_contract:"bg-blue-500/10 text-blue-600 border-blue-200",sold:"bg-purple-500/10 text-purple-600 border-purple-200",withdrawn:"bg-muted text-muted-foreground border-border"},n3t={coming_soon:"Coming Soon",active:"Active",under_contract:"Under Contract",sold:"Sold",withdrawn:"Withdrawn"};function a3t(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function i3t(){const t=Pr(),{data:s,isLoading:r}=kVe(),{data:n,isLoading:a}=SVe({status:void 0,propertyType:void 0,sortBy:"newest"}),o=(n==null?void 0:n.filter(p=>p.is_approved&&p.is_public))||[],l=o.filter(p=>p.is_featured),i=o.filter(p=>!p.is_featured),d=[...l,...i].slice(0,6),u=r||a;return!u&&!s?null:u?e.jsx(Ee,{className:"bg-gradient-to-br from-emerald-500/5 via-emerald-500/10 to-emerald-500/5 border-emerald-500/20",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-emerald-500/20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-emerald-500/20 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-emerald-500/10 rounded w-1/2"})]})]})})}):e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Listing Exchange"}),e.jsx(PVe,{})]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control/listings"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx($i,{className:"h-4 w-4"})]})]}),d.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(On,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No listings available yet"}),e.jsx(K,{variant:"link",size:"sm",onClick:()=>t("/mission-control/listings/new"),className:"mt-2",children:"Add the first listing"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:d.map(p=>{var y,_;const f=((y=p.photos)==null?void 0:y.find(b=>b.is_primary))||((_=p.photos)==null?void 0:_[0]);return e.jsxs("div",{onClick:()=>t(`/mission-control/listings/${p.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"aspect-[4/3] bg-muted/50 overflow-hidden relative",children:[f!=null&&f.photo_url?e.jsx("img",{src:f.photo_url,alt:`${p.city}, ${p.state}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(On,{className:"h-8 w-8 text-muted-foreground/50"})}),p.is_featured&&e.jsx("div",{className:"absolute top-1.5 left-1.5",children:e.jsxs(rt,{className:"gap-1 bg-amber-500 text-white border-0 text-[10px] px-1.5 py-0.5",children:[e.jsx(Gn,{className:"h-2.5 w-2.5 fill-current"}),"Featured"]})}),e.jsx("div",{className:"absolute top-1.5 right-1.5",children:e.jsx(rt,{className:`text-[10px] px-1.5 py-0.5 ${r3t[p.status]}`,children:n3t[p.status]})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"font-bold text-sm text-foreground",children:a3t(p.price)}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[p.city,", ",p.state]}),(p.bedrooms||p.bathrooms)&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:[p.bedrooms&&`${p.bedrooms} bed`,p.bedrooms&&p.bathrooms&&" · ",p.bathrooms&&`${p.bathrooms} bath`]})]})]},p.id)})})]})}function IVe(t=10,s){return wt({queryKey:["event-leaderboard",t,s],queryFn:async()=>{const{data:r}=await G.from("user_roles").select("user_id").eq("role","admin"),n=new Set((r==null?void 0:r.map(y=>y.user_id))||[]);let a=null;if(s){const{data:y}=await G.from("profiles").select("id").eq("brokerage_id",s);a=new Set((y==null?void 0:y.map(_=>_.id))||[])}const{data:o,error:l}=await G.from("agent_attendance_stats").select("user_id, total_points, total_events_attended, current_streak").order("total_points",{ascending:!1}).limit(t+n.size+50);if(l)throw l;if(!o||o.length===0)return[];let i=o.filter(y=>!n.has(y.user_id));a&&(i=i.filter(y=>a.has(y.user_id)));const d=i.slice(0,t),u=d.map(y=>y.user_id),{data:p}=await G.from("profiles").select("id, name").in("id",u),f=new Map((p==null?void 0:p.map(y=>[y.id,{name:y.name}]))||[]);return d.map(y=>({user_id:y.user_id,total_points:y.total_points,total_events_attended:y.total_events_attended,current_streak:y.current_streak,profile:f.get(y.user_id)||null}))}})}function LVe(t){return wt({queryKey:["user-attendance-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("agent_attendance_stats").select("*").eq("user_id",t).single();if(r&&r.code!=="PGRST116")throw r;return s},enabled:!!t})}function DVe(t){return wt({queryKey:["user-badges",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("agent_badges").select("*").eq("user_id",t).order("earned_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function OVe(t,s){return wt({queryKey:["user-rank",t,s],queryFn:async()=>{if(!t)return null;const{data:r}=await G.from("agent_attendance_stats").select("total_points").eq("user_id",t).single();if(!r)return null;const{data:n}=await G.from("user_roles").select("user_id").eq("role","admin"),a=new Set((n==null?void 0:n.map(d=>d.user_id))||[]),{data:o,error:l}=await G.from("agent_attendance_stats").select("user_id, total_points").gt("total_points",r.total_points);if(l)throw l;let i=(o==null?void 0:o.filter(d=>!a.has(d.user_id)))||[];if(s){const{data:d}=await G.from("profiles").select("id").eq("brokerage_id",s),u=new Set((d==null?void 0:d.map(p=>p.id))||[]);i=i.filter(p=>u.has(p.user_id))}return i.length+1},enabled:!!t})}function o3t(){const{user:t,brokerageId:s,isAdmin:r}=Hs();Pr();const n=!!s,[a,o]=C.useState("brokerage"),l=()=>{if(r)return null;if(n)return a==="global"?null:s},{data:i,isLoading:d}=IVe(5,l()),{data:u}=LVe(t==null?void 0:t.id),{data:p}=OVe(t==null?void 0:t.id,l()),{data:f}=DVe(t==null?void 0:t.id),y=r||n,_=()=>r?"Agent Leaderboard":n?a==="global"?"All LevelUp":"My Brokerage":"My Points";if(d)return e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(ao,{className:"h-4 w-4 text-yellow-500"}),_()]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:[...Array(y?5:3)].map((w,j)=>e.jsx(xs,{className:"h-10 w-full"},j))})})]});const b=w=>w===0?e.jsx(ao,{className:"h-4 w-4 text-yellow-500 mx-auto"}):w===1?e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"2"}):w===2?e.jsx("span",{className:"text-sm font-medium text-amber-600",children:"3"}):e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:w+1});if(y){const w=(i==null?void 0:i.slice(0,5))||[];return e.jsxs(Ee,{children:[e.jsxs(It,{className:"pb-2",children:[e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(ao,{className:"h-4 w-4 text-yellow-500"}),_()]}),!r&&n&&e.jsxs("div",{className:"flex gap-1 mt-2",children:[e.jsx(K,{variant:a==="brokerage"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("brokerage"),children:"My Brokerage"}),e.jsx(K,{variant:a==="global"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("global"),children:"All LevelUp"})]})]}),e.jsxs(Oe,{children:[!r&&u&&e.jsx("div",{className:"mb-3 p-2 rounded-lg bg-primary/5 border border-primary/10",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Your Rank:"}),e.jsxs("span",{className:"font-bold text-primary",children:["#",p||"-"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-primary",children:u.total_points})," pts"]}),e.jsxs("span",{children:[e.jsx("strong",{children:u.total_events_attended})," events"]})]})]})}),e.jsxs("div",{className:"space-y-2",children:[w.map((j,k)=>{var S,T,I;return e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg ${j.user_id===(t==null?void 0:t.id)?"bg-primary/10 border border-primary/20":k===0?"bg-yellow-500/10":""}`,children:[e.jsx("div",{className:"w-5 text-center",children:b(k)}),e.jsx(xn,{className:"h-6 w-6",children:e.jsx(yn,{className:"text-xs",children:((T=(S=j.profile)==null?void 0:S.name)==null?void 0:T.charAt(0))||"?"})}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:((I=j.profile)==null?void 0:I.name)||"Unknown"}),e.jsx("span",{className:"text-sm font-bold text-primary",children:j.total_points})]},j.user_id)}),w.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-2 text-sm",children:"No data yet"})]}),e.jsxs(vo,{to:"/reward-store",className:"mt-3 flex items-center justify-center gap-2 p-2 rounded-lg bg-primary/5 hover:bg-primary/10 transition-colors text-sm font-medium text-primary",children:[e.jsx(po,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(Ua,{className:"h-4 w-4"})]})]})]})}return e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(ao,{className:"h-4 w-4 text-yellow-500"}),"My Points"]})}),e.jsx(Oe,{children:u?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-primary/5 border border-primary/10 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-primary",children:u.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Points"})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-muted/50 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:u.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Events Attended"})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nh,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Current Streak"})]}),e.jsxs("span",{className:"font-bold text-orange-500",children:[u.current_streak," 🔥"]})]}),f&&f.length>0&&e.jsxs("div",{className:"pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[e.jsx(rc,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Badges"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[f.slice(0,4).map(w=>e.jsx("span",{className:"text-xs px-2 py-1 rounded-full bg-yellow-500/10 text-yellow-600 border border-yellow-500/20",children:w.badge_name},w.id)),f.length>4&&e.jsxs("span",{className:"text-xs text-muted-foreground px-2 py-1",children:["+",f.length-4," more"]})]})]}),e.jsxs(vo,{to:"/reward-store",className:"mt-3 flex items-center justify-center gap-2 p-2 rounded-lg bg-primary/5 hover:bg-primary/10 transition-colors text-sm font-medium text-primary",children:[e.jsx(po,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(Ua,{className:"h-4 w-4"})]})]}):e.jsxs("div",{className:"text-center text-muted-foreground py-4 text-sm",children:[e.jsx(Gn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/50"}),e.jsx("p",{children:"Attend events to earn points!"}),e.jsxs(vo,{to:"/reward-store",className:"mt-3 inline-flex items-center gap-2 p-2 rounded-lg bg-primary/5 hover:bg-primary/10 transition-colors text-sm font-medium text-primary",children:[e.jsx(po,{className:"h-4 w-4"}),"Visit Reward Store",e.jsx(Ua,{className:"h-4 w-4"})]})]})})]})}const EM=()=>wt({queryKey:["lead-sources"],queryFn:async()=>{const{data:t,error:s}=await G.from("lead_sources").select("*").eq("is_active",!0).order("sort_order");if(s)throw s;return t}}),xbe=()=>{const t=rs(),{user:s}=Hs();return Dt({mutationFn:async r=>{const{data:n}=await G.from("lead_sources").select("id, name").eq("is_active",!0).ilike("name",r.trim()),a=(n||[]).find(i=>i.name.toLowerCase()===r.trim().toLowerCase()&&!0);if(a)throw new Error(`Lead source "${a.name}" already exists`);const{data:o,error:l}=await G.from("lead_sources").insert({name:r,owner_user_id:s==null?void 0:s.id,sort_order:100}).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),fe.success("Lead source added")},onError:r=>{fe.error("Failed to add lead source"),console.error(r)}})},l3t=()=>{const t=rs();return Dt({mutationFn:async({id:s,name:r})=>{const{error:n}=await G.from("lead_sources").update({name:r}).eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),fe.success("Lead source updated")},onError:s=>{fe.error(s.message||"Failed to update lead source")}})},c3t=()=>{const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("lead_sources").update({is_active:!1}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),fe.success("Lead source removed")},onError:s=>{fe.error(s.message||"Failed to remove lead source")}})},ybe=(t,s)=>{const{user:r,isAdmin:n}=Hs(),a=n&&s?s:r==null?void 0:r.id;return wt({queryKey:["scorecard-transactions",t,a],queryFn:async()=>{let o=G.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).eq("owner_user_id",a).order("close_date",{ascending:!1});t&&(o=o.gte("close_date",`${t}-01-01`).lte("close_date",`${t}-12-31`));const{data:l,error:i}=await o;if(i)throw i;return l},enabled:!!a})},vbe=t=>{const{user:s,isAdmin:r}=Hs(),n=r&&t?t:s==null?void 0:s.id;return wt({queryKey:["scorecard-transactions-all",n],queryFn:async()=>{const{data:a,error:o}=await G.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).eq("owner_user_id",n).order("close_date",{ascending:!1});if(o)throw o;return a},enabled:!!n})},mle=()=>{const t=rs(),{user:s}=Hs();return Dt({mutationFn:async r=>{const{data:n,error:a}=await G.from("scorecard_transactions").insert({...r,owner_user_id:s.id}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),fe.success("Transaction added")},onError:r=>{fe.error("Failed to add transaction"),console.error(r)}})},d3t=()=>{const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("scorecard_transactions").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),fe.success("Transaction updated")},onError:s=>{fe.error("Failed to update transaction"),console.error(s)}})},u3t=()=>{const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("scorecard_transactions").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),fe.success("Transaction deleted")},onError:s=>{fe.error("Failed to delete transaction"),console.error(s)}})},RVe=(t,s)=>{const{user:r,isAdmin:n}=Hs(),a=n&&s?s:r==null?void 0:r.id;return wt({queryKey:["scorecard-goals",t,a],queryFn:async()=>{const{data:o,error:l}=await G.from("scorecard_goals").select("*").eq("owner_user_id",a).eq("year",t).maybeSingle();if(l)throw l;return o},enabled:!!a})},h3t=()=>{const t=rs(),{user:s}=Hs();return Dt({mutationFn:async r=>{const{data:n,error:a}=await G.from("scorecard_goals").upsert({...r,owner_user_id:s.id},{onConflict:"owner_user_id,year"}).select().single();if(a)throw a;return n},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["scorecard-goals",n.year]}),fe.success("Goals saved")},onError:r=>{fe.error("Failed to save goals"),console.error(r)}})},ple=()=>{const{user:t}=Hs();return wt({queryKey:["scorecard-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("scorecard_settings").select("*").eq("user_id",t.id).maybeSingle();if(r)throw r;return s},enabled:!!(t!=null&&t.id)})},m3t=()=>{const t=rs(),{user:s}=Hs();return Dt({mutationFn:async r=>{const{data:n,error:a}=await G.from("scorecard_settings").upsert({...r,user_id:s.id},{onConflict:"user_id"}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-settings"]}),fe.success("Settings saved")},onError:r=>{fe.error("Failed to save settings"),console.error(r)}})},FVe=(t,s)=>{const{data:r,isLoading:n}=ybe(t,s),{data:a,isLoading:o}=vbe(s),{data:l}=ple(),i=(l==null?void 0:l.show_commission)??!0,d=u=>{if(!u||u.length===0)return{totalTransactions:0,buyerCount:0,sellerCount:0,totalVolume:0,averagePrice:0,totalCommission:0,totalNetToAgent:0,topLeadSource:null,transactionsByMonth:[],leadSourceBreakdown:[]};const p=u.filter(L=>L.transaction_type==="buyer").length,f=u.filter(L=>L.transaction_type==="seller").length,y=u.reduce((L,R)=>L+Number(R.sale_price),0),_=u.reduce((L,R)=>L+(Number(R.commission_amount)||0),0),b=u.reduce((L,R)=>{const $=Number(R.commission_amount)||0;if(!$)return L;let q=$;return R.brokerage_split_pct&&(q-=$*(R.brokerage_split_pct/100)),R.team_split_pct&&(q-=$*(R.team_split_pct/100)),R.franchise_fee_pct&&(q-=$*(R.franchise_fee_pct/100)),R.referral_fee_pct&&(q-=$*(R.referral_fee_pct/100)),R.transaction_fee&&(q-=R.transaction_fee),L+Math.max(0,q)},0),w={};u.forEach(L=>{var $;const R=(($=L.lead_source)==null?void 0:$.name)||"Unknown";w[R]=(w[R]||0)+1});const j=Object.entries(w).map(([L,R])=>({name:L,count:R})).sort((L,R)=>R.count-L.count),k=j[0]||null,S={};u.forEach(L=>{const R=gl(L.close_date).toLocaleString("default",{month:"short"});S[R]=(S[R]||0)+1});const I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(L=>({month:L,count:S[L]||0}));return{totalTransactions:u.length,buyerCount:p,sellerCount:f,totalVolume:y,averagePrice:u.length>0?y/u.length:0,totalCommission:i?_:0,totalNetToAgent:i?b:0,topLeadSource:k,transactionsByMonth:I,leadSourceBreakdown:j}};return{yearStats:d(r),lifetimeStats:d(a),isLoading:n||o,showCommission:i}},p3t=()=>{const{isAdmin:t}=Hs();return wt({queryKey:["agents-with-transactions"],queryFn:async()=>{const{data:s,error:r}=await G.from("scorecard_transactions").select("owner_user_id").order("owner_user_id");if(r)throw r;const n=[...new Set(s.map(l=>l.owner_user_id))],{data:a,error:o}=await G.from("profiles").select("id, name, email").in("id",n);if(o)throw o;return a},enabled:t})},f1={recency:40,touchpoints:30,transactions:20},nTe={warm:70,cooling:40};function f3t(t){return t===null?0:t<=14?f1.recency:t<=30?f1.recency*.85:t<=60?f1.recency*.65:t<=90?f1.recency*.4:t<=180?f1.recency*.2:f1.recency*.05}function g3t(t){const s=Math.min(t/12,1);return Math.round(f1.touchpoints*s)}function x3t(t){return t?f1.transactions:0}function y3t(){return 0}function v3t(t){return t>=nTe.warm?"warm":t>=nTe.cooling?"cooling":"at-risk"}function fle(){const{data:t,isLoading:s}=tm(),{data:r}=bVe(),{data:n}=VL(365),{data:a}=vbe(),o=C.useMemo(()=>{if(!t)return[];const i=new Date,d=LN(i,12),u={};n==null||n.forEach(f=>{new Date(f.completed_at)>=d&&(u[f.contact_id]=(u[f.contact_id]||0)+1)});const p=new Set((a==null?void 0:a.filter(f=>f.contact_id).map(f=>f.contact_id))||[]);return t.map(f=>{const y=(r==null?void 0:r[f.id])||null,_=y?Qg(i,new Date(y)):null,b=u[f.id]||0,w=p.has(f.id),j=f3t(_),k=g3t(b),S=x3t(w),T=y3t(),I=Math.round(j+k+S+T),L={score:I,status:v3t(I),breakdown:{recency:Math.round(j),touchpoints:Math.round(k),transactions:Math.round(S),referrals:Math.round(T)},lastTouchDate:y,daysSinceTouch:_,touchCountLast12Months:b,hasTransaction:w};return{...f,relationshipScore:L}})},[t,r,n,a]),l=C.useMemo(()=>{const i=o.filter(y=>y.relationshipScore.status==="warm").length,d=o.filter(y=>y.relationshipScore.status==="cooling").length,u=o.filter(y=>y.relationshipScore.status==="at-risk").length,p=o.length,f=p>0?Math.round(o.reduce((y,_)=>y+_.relationshipScore.score,0)/p):0;return{warm:i,cooling:d,atRisk:u,total:p,averageScore:f}},[o]);return{contactsWithScores:o,stats:l,isLoading:s}}function zVe(){const t=Pr(),{stats:s,contactsWithScores:r,isLoading:n}=fle();if(n)return e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(xs,{className:"h-5 w-40"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(xs,{className:"h-20 w-full"}),e.jsx(xs,{className:"h-16 w-full"})]})]});if(s.total===0)return e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Relationship Health"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add contacts to see your relationship health scores."}),e.jsx(K,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>t("/mission-control/contacts?new=true"),children:"Add Your First Contact"})]})]});const a=Math.round(s.warm/s.total*100),o=Math.round(s.cooling/s.total*100),l=Math.round(s.atRisk/s.total*100),i=r.filter(d=>d.relationshipScore.status==="at-risk").sort((d,u)=>d.relationshipScore.score-u.relationshipScore.score).slice(0,3);return e.jsxs(Ee,{children:[e.jsxs(It,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(ac,{className:"h-5 w-5 text-emerald-500"}),"Relationship Health"]}),e.jsx("span",{className:"text-2xl font-bold",children:s.averageScore})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Average score across ",s.total," contacts"]})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-emerald-500"}),e.jsx("span",{children:"Warm"})]}),e.jsxs("span",{className:"font-medium",children:[s.warm," (",a,"%)"]})]}),e.jsx(Ti,{value:a,className:"h-2 bg-muted [&>div]:bg-emerald-500"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-amber-500"}),e.jsx("span",{children:"Cooling Off"})]}),e.jsxs("span",{className:"font-medium",children:[s.cooling," (",o,"%)"]})]}),e.jsx(Ti,{value:o,className:"h-2 bg-muted [&>div]:bg-amber-500"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-red-500"}),e.jsx("span",{children:"At Risk"})]}),e.jsxs("span",{className:"font-medium",children:[s.atRisk," (",l,"%)"]})]}),e.jsx(Ti,{value:l,className:"h-2 bg-muted [&>div]:bg-red-500"})]})]}),i.length>0&&e.jsxs("div",{className:"pt-3 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(fk,{className:"h-4 w-4 text-red-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Needs Attention"})]}),e.jsx("div",{className:"space-y-2",children:i.map(d=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-red-500/5 hover:bg-red-500/10 cursor-pointer transition-colors",onClick:()=>t(`/mission-control/contacts/${d.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500"}),e.jsxs("span",{className:"text-sm",children:[d.first_name," ",d.last_name]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:d.relationshipScore.daysSinceTouch===null?"Never":`${d.relationshipScore.daysSinceTouch}d`}),e.jsx(Ua,{className:"h-3 w-3"})]})]},d.id))})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>t("/mission-control/contacts?filter=at-risk"),children:["View All At-Risk Contacts",e.jsx(Ua,{className:"h-4 w-4 ml-1"})]})]})]})}const _3t=()=>{var re;const{user:t,isAdmin:s}=Hs(),r=Pr(),[n,a]=C.useState([]),[o,l]=C.useState([]),[i,d]=C.useState([]),[u,p]=C.useState([]),[f,y]=C.useState([]),[_,b]=C.useState([]),[w,j]=C.useState(new Set),[k,S]=C.useState([]),[T,I]=C.useState([]),[L,R]=C.useState([]),[$,q]=C.useState(null),[U,H]=C.useState(!0);C.useEffect(()=>{Y()},[t]);const Y=async()=>{var ae,le,he,be,_e;try{const[je,Ne,Ge,we,Me,Te,Fe,Ae,Ue,ut,De]=await Promise.all([G.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),G.from("app_tiles").select("*").order("name"),G.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),G.from("events").select("*").order("event_date",{ascending:!0}),G.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",t==null?void 0:t.id),G.from("canva_templates").select("id, name, preview_image_url, publish_date").order("publish_date",{ascending:!1}).limit(4),G.from("resource_kits").select("id, name, description, featured_image_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),G.from("academy_videos").select("id, title, description, thumbnail_url, duration, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),G.from("additional_services").select("id, name, description, preview_image_url, signup_link_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),G.from("dashboard_banners").select("id, title, description, image_url, link_url, link_text, placement, section_after").eq("is_active",!0).order("sort_order"),G.from("profiles").select("name").eq("id",t==null?void 0:t.id).single()]);(ae=De.data)!=null&&ae.name&&q(De.data.name);const Rt=((le=je.data)==null?void 0:le.map(it=>it.tag))||[],me=new Set(((he=Ge.data)==null?void 0:he.map(it=>it.app_id))||[]);j(me);const ot=(((be=Ne.data)==null?void 0:be.filter(it=>!it.required_tags||it.required_tags.length===0?!0:it.required_tags.some($e=>Rt.includes($e))))||[]).sort((it,$e)=>it.name==="LevelUp Members Portal"?-1:$e.name==="LevelUp Members Portal"?1:0);a(ot.slice(0,6));const nt=((_e=we.data)==null?void 0:_e.filter(it=>z5(it.event_date)!=="ended"))||[];l(nt.slice(0,4)),S(Me.data||[]),d(Te.data||[]),p(Fe.data||[]),y(Ae.data||[]),b(Ue.data||[]);const Se=ut.data||[];I(Se.filter(it=>it.placement==="top")),R(Se.filter(it=>it.placement==="between"))}catch(je){console.error("Error loading dashboard:",je),fe.error("Failed to load dashboard data")}finally{H(!1)}},se=async ae=>{var he;const le=window.open("about:blank","_blank");try{await G.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:ae.app_id,app_name:ae.name,user_agent:navigator.userAgent});const{data:be,error:_e}=await G.functions.invoke("sso-launch",{body:{app_id:ae.app_id}});if(_e)throw _e;be!=null&&be.redirect_url?le&&!le.closed?(le.location.href=be.redirect_url,(he=le.focus)==null||he.call(le)):window.location.assign(be.redirect_url):(le==null||le.close(),fe.error("Launch link unavailable"))}catch(be){le==null||le.close(),console.error("Error launching app:",be),fe.error("Failed to launch app")}},te=ae=>k==null?void 0:k.some(le=>le.event_id===ae),Q=ae=>{const le=k==null?void 0:k.find(he=>he.event_id===ae);return le==null?void 0:le.zoom_join_url};if(U)return e.jsx(Ts,{title:"Dashboard",children:e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading your dashboard..."})]})})});const de=ae=>L.filter(le=>le.section_after===ae);return e.jsxs(Ts,{title:"Dashboard",children:[e.jsx(t5t,{events:o,registrations:k,onNavigateToEvents:()=>r("/events")}),T.length>0&&e.jsx("div",{className:"mb-8",children:e.jsx(hE,{banners:T})}),e.jsx(h5t,{}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold text-foreground",children:["Welcome back, ",($||((re=t==null?void 0:t.user_metadata)==null?void 0:re.name)||"there").split(" ")[0],"!"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Are you ready to LevelUp today?"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4 mb-8",children:[e.jsx(C5t,{}),e.jsx(zVe,{}),e.jsx(o3t,{})]}),e.jsx($5t,{}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Upcoming Events"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/events"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx($i,{className:"h-4 w-4"})]})]}),o.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(on,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No upcoming events"})]})})}):e.jsx("div",{className:"bg-card rounded-xl border border-border overflow-hidden divide-y divide-border max-w-full",children:o.map(ae=>{const le=te(ae.id),he=Q(ae.id)||ae.zoom_link;return e.jsxs("div",{className:`flex items-start gap-3 sm:gap-4 p-3 sm:p-4 hover:bg-muted/50 transition-colors cursor-pointer group ${eTe(ae.event_date)?"bg-red-500/5 border-l-2 border-l-red-500":""}`,onClick:()=>r("/events"),children:[eTe(ae.event_date)?e.jsxs("div",{className:"flex-shrink-0 w-12 h-12 sm:w-14 sm:h-14 rounded-lg bg-red-500/10 flex flex-col items-center justify-center relative",children:[e.jsx("span",{className:"absolute inline-flex h-3 w-3 top-1 right-1 animate-ping rounded-full bg-red-500 opacity-75"}),e.jsx($0,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"text-[10px] font-bold text-red-500 uppercase mt-0.5",children:"Live"})]}):e.jsxs("div",{className:"flex-shrink-0 w-12 h-12 sm:w-14 sm:h-14 rounded-lg bg-primary/10 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-[10px] sm:text-xs font-medium text-primary uppercase",children:new Intl.DateTimeFormat("en-US",{month:"short",timeZone:"America/New_York"}).format(new Date(ae.event_date))}),e.jsx("span",{className:"text-lg sm:text-xl font-bold text-primary",children:new Intl.DateTimeFormat("en-US",{day:"numeric",timeZone:"America/New_York"}).format(new Date(ae.event_date))})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-sm sm:text-base text-foreground group-hover:text-primary transition-colors line-clamp-2 sm:truncate",children:ae.title}),e.jsxs("p",{className:"text-xs sm:text-sm text-muted-foreground mt-0.5",children:[new Intl.DateTimeFormat("en-US",{weekday:"long",timeZone:"America/New_York"}).format(new Date(ae.event_date))," at ",h6(new Date(ae.event_date))]})]}),e.jsx("div",{className:"hidden sm:flex flex-shrink-0",children:le?e.jsxs(K,{size:"sm",variant:"default",className:"gap-1",onClick:be=>{be.stopPropagation(),window.open(he,"_blank")},children:[e.jsx(sn,{className:"h-3.5 w-3.5"}),"Join"]}):e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground group-hover:text-primary transition-colors",children:[e.jsx("span",{className:"text-sm",children:"Register"}),e.jsx(Ua,{className:"h-4 w-4"})]})})]},ae.id)})})]}),de("events").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(hE,{banners:de("events")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Academy Videos"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/academy"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx($i,{className:"h-4 w-4"})]})]}),f.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(bm,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No academy videos available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:f.map(ae=>e.jsxs("div",{onClick:()=>r(`/academy/${ae.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden relative",children:[ae.thumbnail_url?e.jsx("img",{src:ae.thumbnail_url,alt:ae.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(bm,{className:"h-8 w-8 text-muted-foreground/50"})}),ae.duration&&e.jsx("span",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:ae.duration})]}),e.jsx("div",{className:"p-3",children:e.jsx("h4",{className:"font-medium text-sm text-foreground line-clamp-2 group-hover:text-primary transition-colors",children:ae.title})})]},ae.id))})]}),de("academy").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(hE,{banners:de("academy")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Resource Kits"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/toolbox"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx($i,{className:"h-4 w-4"})]})]}),u.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Vh,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No resource kits available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:u.map(ae=>e.jsxs("div",{onClick:()=>r(`/toolbox/${ae.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden",children:ae.featured_image_url?e.jsx("img",{src:ae.featured_image_url,alt:ae.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Vh,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsx("div",{className:"p-3",children:e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:ae.name})})]},ae.id))})]}),de("toolbox").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(hE,{banners:de("toolbox")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"New Templates"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/templates"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx($i,{className:"h-4 w-4"})]})]}),i.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(i_,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No templates available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:i.map(ae=>e.jsxs("div",{onClick:()=>r("/templates"),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden",children:ae.preview_image_url?e.jsx("img",{src:ae.preview_image_url,alt:ae.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(i_,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsx("div",{className:"p-3",children:e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:ae.name})})]},ae.id))})]}),de("templates").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(hE,{banners:de("templates")})}),e.jsx("div",{className:"mb-10",children:e.jsx(i3t,{})}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Your Apps"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/apps"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx($i,{className:"h-4 w-4"})]})]}),n.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx($g,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No apps available"})]})})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:n.map(ae=>{const le=w.has(ae.id);return e.jsxs("div",{onClick:()=>se(ae),className:"group flex items-start gap-4 p-5 bg-card rounded-xl border border-border cursor-pointer transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-primary/10 flex items-center justify-center text-3xl",children:ae.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate",children:ae.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:ae.description})]}),le&&e.jsx($g,{className:"h-5 w-5 text-primary fill-current flex-shrink-0"})]},ae.id)})})]}),e.jsxs("section",{className:"mt-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Additional Services"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/additional-services"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx($i,{className:"h-4 w-4"})]})]}),_.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(hn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional services available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:_.map(ae=>e.jsxs("div",{onClick:()=>window.open(ae.signup_link_url,"_blank"),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"aspect-[4/3] bg-muted/50 overflow-hidden",children:ae.preview_image_url?e.jsx("img",{src:ae.preview_image_url,alt:ae.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(hn,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsxs("div",{className:"p-3",children:[e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:ae.name}),ae.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:ae.description})]})]},ae.id))})]})]})};var BVe="AlertDialog",[b3t]=Ec(BVe,[wBe]),dv=wBe(),$Ve=t=>{const{__scopeAlertDialog:s,...r}=t,n=dv(s);return e.jsx(Ioe,{...n,...r,modal:!0})};$Ve.displayName=BVe;var w3t="AlertDialogTrigger",qVe=C.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=dv(r);return e.jsx(e_e,{...a,...n,ref:s})});qVe.displayName=w3t;var j3t="AlertDialogPortal",UVe=t=>{const{__scopeAlertDialog:s,...r}=t,n=dv(s);return e.jsx(Loe,{...n,...r})};UVe.displayName=j3t;var N3t="AlertDialogOverlay",VVe=C.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=dv(r);return e.jsx(wM,{...a,...n,ref:s})});VVe.displayName=N3t;var B5="AlertDialogContent",[k3t,S3t]=b3t(B5),C3t=aRe("AlertDialogContent"),HVe=C.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...a}=t,o=dv(r),l=C.useRef(null),i=Ea(s,l),d=C.useRef(null);return e.jsx(Syt,{contentName:B5,titleName:WVe,docsSlug:"alert-dialog",children:e.jsx(k3t,{scope:r,cancelRef:d,children:e.jsxs(jM,{role:"alertdialog",...o,...a,ref:i,onOpenAutoFocus:Mr(a.onOpenAutoFocus,u=>{var p;u.preventDefault(),(p=d.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[e.jsx(C3t,{children:n}),e.jsx(T3t,{contentRef:l})]})})})});HVe.displayName=B5;var WVe="AlertDialogTitle",GVe=C.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=dv(r);return e.jsx(PL,{...a,...n,ref:s})});GVe.displayName=WVe;var KVe="AlertDialogDescription",ZVe=C.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=dv(r);return e.jsx(IL,{...a,...n,ref:s})});ZVe.displayName=KVe;var M3t="AlertDialogAction",YVe=C.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=dv(r);return e.jsx(LL,{...a,...n,ref:s})});YVe.displayName=M3t;var XVe="AlertDialogCancel",QVe=C.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:a}=S3t(XVe,r),o=dv(r),l=Ea(s,a);return e.jsx(LL,{...o,...n,ref:l})});QVe.displayName=XVe;var T3t=({contentRef:t})=>{const s=`\`${B5}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${B5}\` by passing a \`${KVe}\` component as a child, which also benefits sighted users by adding visible context to the dialog. Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${B5}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return C.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},A3t=$Ve,E3t=qVe,P3t=UVe,JVe=VVe,eHe=HVe,tHe=YVe,sHe=QVe,rHe=GVe,nHe=ZVe;const nc=A3t,Rh=E3t,I3t=P3t,aHe=C.forwardRef(({className:t,...s},r)=>e.jsx(JVe,{className:Pt("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:r}));aHe.displayName=JVe.displayName;const El=C.forwardRef(({className:t,...s},r)=>e.jsxs(I3t,{children:[e.jsx(aHe,{}),e.jsx(eHe,{ref:r,className:Pt("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s})]}));El.displayName=eHe.displayName;const Pl=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col space-y-2 text-center sm:text-left",t),...s});Pl.displayName="AlertDialogHeader";const Il=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});Il.displayName="AlertDialogFooter";const Ll=C.forwardRef(({className:t,...s},r)=>e.jsx(rHe,{ref:r,className:Pt("text-lg font-semibold",t),...s}));Ll.displayName=rHe.displayName;const Dl=C.forwardRef(({className:t,...s},r)=>e.jsx(nHe,{ref:r,className:Pt("text-sm text-muted-foreground",t),...s}));Dl.displayName=nHe.displayName;const xl=C.forwardRef(({className:t,...s},r)=>e.jsx(tHe,{ref:r,className:Pt(s6(),t),...s}));xl.displayName=tHe.displayName;const Ol=C.forwardRef(({className:t,...s},r)=>e.jsx(sHe,{ref:r,className:Pt(s6({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));Ol.displayName=sHe.displayName;const L3t=[{key:"contacts",label:"Contacts",icon:Qn,description:"View, add, and edit contacts"},{key:"pipeline",label:"Deal Pipeline",icon:dk,description:"View, add, and move deals"},{key:"client_portal",label:"Client Portals",icon:Vh,description:"Manage client portals on deals"},{key:"videos",label:"Videos",icon:Nn,description:"View and upload videos"},{key:"listings",label:"Listings",icon:On,description:"View, create, and edit listings"},{key:"scorecard",label:"Scorecard",icon:a_,description:"View and add transactions"},{key:"popbys",label:"Pop-bys",icon:Oi,description:"View and log pop-bys"},{key:"digital_card",label:"Digital Card",icon:yf,description:"Create and edit digital business card"},{key:"guest_book",label:"Guest Book",icon:Fu,description:"Manage open house guest books"},{key:"presentations",label:"Presentations",icon:Hg,description:"Create and manage smart presentations"}];function D3t(){var $;const{user:t}=Hs(),[s,r]=C.useState([]),[n,a]=C.useState(!0),[o,l]=C.useState(!1),[i,d]=C.useState(!1),[u,p]=C.useState(null),[f,y]=C.useState({email:"",name:"",password:""}),[_,b]=C.useState("create"),[w,j]=C.useState(!1),[k,S]=C.useState(null);C.useEffect(()=>{t&&T()},[t]);const T=async()=>{if(t){a(!0);try{const{data:q,error:U}=await G.from("agent_assistant_assignments").select("id, assistant_id, permissions, created_at").eq("agent_id",t.id);if(U)throw U;if(q&&q.length>0){const H=q.map(te=>te.assistant_id),{data:Y}=await G.from("profiles").select("id, name, email").in("id",H),se=q.map(te=>{const Q=Y==null?void 0:Y.find(de=>de.id===te.assistant_id);return{...te,permissions:te.permissions,assistant_profile:Q?{name:Q.name||"",email:Q.email||""}:void 0}});r(se)}else r([])}catch(q){console.error("Error loading assistants:",q)}finally{a(!1)}}},I=async()=>{if(t){if(_==="link"){if(!f.email.trim()){fe.error("Please enter the assistant's email");return}j(!0);try{const{data:{session:q}}=await G.auth.getSession();if(!q)throw new Error("Not authenticated");const{data:U,error:H}=await G.from("profiles").select("id, name, email").eq("email",f.email.trim().toLowerCase()).single();if(H||!U){fe.error("No account found with that email. Try creating a new assistant instead.");return}const{data:Y}=await G.from("agent_assistant_assignments").select("id").eq("agent_id",t.id).eq("assistant_id",U.id);if(Y&&Y.length>0){fe.error("This assistant is already assigned to you");return}const se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({userId:U.id,role:"assistant",action:"add",agentId:t.id})}),te=await se.json();if(!se.ok)throw new Error(te.error||"Failed to assign assistant role");const{error:Q}=await G.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:U.id,permissions:{contacts:!0,pipeline:!0,videos:!1,listings:!1,scorecard:!1,popbys:!1,digital_card:!1,client_portal:!1,guest_book:!1,presentations:!1}});if(Q)throw Q;fe.success(`${U.name||U.email} linked as your assistant`),l(!1),y({email:"",name:"",password:""}),T()}catch(q){console.error("Error linking assistant:",q),fe.error(q.message||"Failed to link assistant")}finally{j(!1)}return}if(!f.email.trim()||!f.name.trim()||!f.password.trim()){fe.error("Please fill in all fields");return}if(f.password.length<6){fe.error("Password must be at least 6 characters");return}j(!0);try{const{data:{session:q}}=await G.auth.getSession();if(!q)throw new Error("Not authenticated");const U=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({email:f.email.trim(),password:f.password,name:f.name.trim(),purpose:"assistant"})}),H=await U.json();if(!U.ok)throw new Error(H.error||"Failed to create assistant account");const Y=H.userId||H.id;if(!Y)throw new Error("No user ID returned");const se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({userId:Y,role:"assistant",action:"add",agentId:t.id})}),te=await se.json();if(!se.ok)throw new Error(te.error||"Failed to assign assistant role");const{error:Q}=await G.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:Y,permissions:{contacts:!0,pipeline:!0,videos:!1,listings:!1,scorecard:!1,popbys:!1,digital_card:!1,client_portal:!1,guest_book:!1,presentations:!1}});if(Q)throw Q;fe.success(`Assistant account created for ${f.name.trim()}`),l(!1),y({email:"",name:"",password:""}),T()}catch(q){console.error("Error adding assistant:",q),fe.error(q.message||"Failed to add assistant")}finally{j(!1)}}},L=async()=>{if(!(!u||!t))try{const{data:{session:q}}=await G.auth.getSession();if(!q)throw new Error("Not authenticated");const{error:U}=await G.from("agent_assistant_assignments").delete().eq("id",u.id);if(U)throw U;const{data:H}=await G.from("agent_assistant_assignments").select("id").eq("assistant_id",u.assistant_id);(!H||H.length===0)&&await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({userId:u.assistant_id,role:"assistant",action:"remove"})}),fe.success("Assistant removed"),d(!1),p(null),T()}catch(q){console.error("Error removing assistant:",q),fe.error(q.message||"Failed to remove assistant")}},R=async(q,U,H)=>{S(q);try{const Y=s.find(Q=>Q.id===q);if(!Y)return;const se={...Y.permissions,[U]:H},{error:te}=await G.from("agent_assistant_assignments").update({permissions:se}).eq("id",q);if(te)throw te;r(Q=>Q.map(de=>de.id===q?{...de,permissions:se}:de))}catch(Y){console.error("Error updating permissions:",Y),fe.error("Failed to update permissions")}finally{S(null)}};return n?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"My Assistants"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"My Assistants"]}),e.jsx(pr,{children:"Add assistants to help manage your Agent OS"})]}),e.jsxs(K,{size:"sm",onClick:()=>{b("create"),l(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Assistant"]})]})}),e.jsx(Oe,{children:s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No assistant assigned. Add one to help manage your contacts, deals, and more."}):e.jsx("div",{className:"space-y-4",children:s.map(q=>{var U,H,Y,se;return e.jsxs("div",{className:"border rounded-lg p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xn,{className:"h-10 w-10",children:e.jsx(yn,{children:((H=(U=q.assistant_profile)==null?void 0:U.name)==null?void 0:H.split(" ").map(te=>te[0]).join("").toUpperCase())||"A"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Y=q.assistant_profile)==null?void 0:Y.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((se=q.assistant_profile)==null?void 0:se.email)||""})]}),e.jsxs(rt,{variant:"secondary",className:"ml-2",children:[e.jsx(ih,{className:"h-3 w-3 mr-1"}),"Assistant"]})]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{p(q),d(!0)},children:e.jsx(jr,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-3",children:"Permissions"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:L3t.map(te=>{const Q=te.icon;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:te.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:te.description})]})]}),e.jsx(Br,{checked:q.permissions[te.key]||!1,onCheckedChange:de=>R(q.id,te.key,de),disabled:k===q.id})]},te.key)})})]})]},q.id)})})})]}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Add Assistant"}),e.jsx(Kr,{children:_==="create"?"Create a new account for your assistant.":"Link an existing assistant account by their email."})]}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsxs(K,{variant:_==="create"?"default":"outline",size:"sm",onClick:()=>b("create"),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"}),"Create New"]}),e.jsxs(K,{variant:_==="link"?"default":"outline",size:"sm",onClick:()=>b("link"),children:[e.jsx(Do,{className:"h-3 w-3 mr-1"}),"Link Existing"]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[_==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"assistant-name",children:"Name"}),e.jsx(Re,{id:"assistant-name",value:f.name,onChange:q=>y({...f,name:q.target.value}),placeholder:"Assistant's full name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"assistant-email",children:"Email"}),e.jsx(Re,{id:"assistant-email",type:"email",value:f.email,onChange:q=>y({...f,email:q.target.value}),placeholder:"assistant@email.com"})]}),_==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"assistant-password",children:"Temporary Password"}),e.jsx(Re,{id:"assistant-password",type:"password",value:f.password,onChange:q=>y({...f,password:q.target.value}),placeholder:"Min 6 characters"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your assistant can change this after their first login."})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:I,disabled:w,children:[w&&e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),_==="create"?"Create Assistant":"Link Assistant"]})]})]})}),e.jsx(nc,{open:i,onOpenChange:d,children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Remove Assistant?"}),e.jsxs(Dl,{children:["This will remove ",($=u==null?void 0:u.assistant_profile)==null?void 0:$.name,"'s access to your Agent OS. Their account will remain active but they won't be able to manage your data."]})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:L,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function Pu(t){this.content=t}Pu.prototype={constructor:Pu,find:function(t){for(var s=0;s>1}};Pu.from=function(t){if(t instanceof Pu)return t;var s=[];if(t)for(var r in t)s.push(r,t[r]);return new Pu(s)};function iHe(t,s,r){for(let n=0;;n++){if(n==t.childCount||n==s.childCount)return t.childCount==s.childCount?null:r;let a=t.child(n),o=s.child(n);if(a==o){r+=a.nodeSize;continue}if(!a.sameMarkup(o))return r;if(a.isText&&a.text!=o.text){for(let l=0;a.text[l]==o.text[l];l++)r++;return r}if(a.content.size||o.content.size){let l=iHe(a.content,o.content,r+1);if(l!=null)return l}r+=a.nodeSize}}function oHe(t,s,r,n){for(let a=t.childCount,o=s.childCount;;){if(a==0||o==0)return a==o?null:{a:r,b:n};let l=t.child(--a),i=s.child(--o),d=l.nodeSize;if(l==i){r-=d,n-=d;continue}if(!l.sameMarkup(i))return{a:r,b:n};if(l.isText&&l.text!=i.text){let u=0,p=Math.min(l.text.length,i.text.length);for(;us&&n(d,a+i,o||null,l)!==!1&&d.content.size){let p=i+1;d.nodesBetween(Math.max(0,s-p),Math.min(d.content.size,r-p),n,a+p)}i=u}}descendants(s){this.nodesBetween(0,this.size,s)}textBetween(s,r,n,a){let o="",l=!0;return this.nodesBetween(s,r,(i,d)=>{let u=i.isText?i.text.slice(Math.max(s,d)-d,r-d):i.isLeaf?a?typeof a=="function"?a(i):a:i.type.spec.leafText?i.type.spec.leafText(i):"":"";i.isBlock&&(i.isLeaf&&u||i.isTextblock)&&n&&(l?l=!1:o+=n),o+=u},0),o}append(s){if(!s.size)return this;if(!this.size)return s;let r=this.lastChild,n=s.firstChild,a=this.content.slice(),o=0;for(r.isText&&r.sameMarkup(n)&&(a[a.length-1]=r.withText(r.text+n.text),o=1);os)for(let o=0,l=0;ls&&((lr)&&(i.isText?i=i.cut(Math.max(0,s-l),Math.min(i.text.length,r-l)):i=i.cut(Math.max(0,s-l-1),Math.min(i.content.size,r-l-1))),n.push(i),a+=i.nodeSize),l=d}return new Tr(n,a)}cutByIndex(s,r){return s==r?Tr.empty:s==0&&r==this.content.length?this:new Tr(this.content.slice(s,r))}replaceChild(s,r){let n=this.content[s];if(n==r)return this;let a=this.content.slice(),o=this.size+r.nodeSize-n.nodeSize;return a[s]=r,new Tr(a,o)}addToStart(s){return new Tr([s].concat(this.content),this.size+s.nodeSize)}addToEnd(s){return new Tr(this.content.concat(s),this.size+s.nodeSize)}eq(s){if(this.content.length!=s.content.length)return!1;for(let r=0;rthis.size||s<0)throw new RangeError(`Position ${s} outside of fragment (${this})`);for(let r=0,n=0;;r++){let a=this.child(r),o=n+a.nodeSize;if(o>=s)return o==s?eR(r+1,o):eR(r,n);n=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(s=>s.toJSON()):null}static fromJSON(s,r){if(!r)return Tr.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new Tr(r.map(s.nodeFromJSON))}static fromArray(s){if(!s.length)return Tr.empty;let r,n=0;for(let a=0;athis.type.rank&&(r||(r=s.slice(0,a)),r.push(this),n=!0),r&&r.push(o)}}return r||(r=s.slice()),n||r.push(this),r}removeFromSet(s){for(let r=0;rn.type.rank-a.type.rank),r}};pl.none=[];class Xne extends Error{}class fn{constructor(s,r,n){this.content=s,this.openStart=r,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(s,r){let n=cHe(this.content,s+this.openStart,r);return n&&new fn(n,this.openStart,this.openEnd)}removeBetween(s,r){return new fn(lHe(this.content,s+this.openStart,r+this.openStart),this.openStart,this.openEnd)}eq(s){return this.content.eq(s.content)&&this.openStart==s.openStart&&this.openEnd==s.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let s={content:this.content.toJSON()};return this.openStart>0&&(s.openStart=this.openStart),this.openEnd>0&&(s.openEnd=this.openEnd),s}static fromJSON(s,r){if(!r)return fn.empty;let n=r.openStart||0,a=r.openEnd||0;if(typeof n!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new fn(Tr.fromJSON(s,r.content),n,a)}static maxOpen(s,r=!0){let n=0,a=0;for(let o=s.firstChild;o&&!o.isLeaf&&(r||!o.type.spec.isolating);o=o.firstChild)n++;for(let o=s.lastChild;o&&!o.isLeaf&&(r||!o.type.spec.isolating);o=o.lastChild)a++;return new fn(s,n,a)}}fn.empty=new fn(Tr.empty,0,0);function lHe(t,s,r){let{index:n,offset:a}=t.findIndex(s),o=t.maybeChild(n),{index:l,offset:i}=t.findIndex(r);if(a==s||o.isText){if(i!=r&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,s).append(t.cut(r))}if(n!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(n,o.copy(lHe(o.content,s-a-1,r-a-1)))}function cHe(t,s,r,n){let{index:a,offset:o}=t.findIndex(s),l=t.maybeChild(a);if(o==s||l.isText)return n&&!n.canReplace(a,a,r)?null:t.cut(0,s).append(r).append(t.cut(s));let i=cHe(l.content,s-o-1,r,l);return i&&t.replaceChild(a,l.copy(i))}function O3t(t,s,r){if(r.openStart>t.depth)throw new Xne("Inserted content deeper than insertion position");if(t.depth-r.openStart!=s.depth-r.openEnd)throw new Xne("Inconsistent open depths");return dHe(t,s,r,0)}function dHe(t,s,r,n){let a=t.index(n),o=t.node(n);if(a==s.index(n)&&n=0&&t.isText&&t.sameMarkup(s[r])?s[r]=t.withText(s[r].text+t.text):s.push(t)}function lI(t,s,r,n){let a=(s||t).node(r),o=0,l=s?s.index(r):a.childCount;t&&(o=t.index(r),t.depth>r?o++:t.textOffset&&(vk(t.nodeAfter,n),o++));for(let i=o;ia&&Axe(t,s,a+1),l=n.depth>a&&Axe(r,n,a+1),i=[];return lI(null,t,a,i),o&&l&&s.index(a)==r.index(a)?(uHe(o,l),vk(_k(o,hHe(t,s,r,n,a+1)),i)):(o&&vk(_k(o,Qne(t,s,a+1)),i),lI(s,r,a,i),l&&vk(_k(l,Qne(r,n,a+1)),i)),lI(n,null,a,i),new Tr(i)}function Qne(t,s,r){let n=[];if(lI(null,t,r,n),t.depth>r){let a=Axe(t,s,r+1);vk(_k(a,Qne(t,s,r+1)),n)}return lI(s,null,r,n),new Tr(n)}function R3t(t,s){let r=s.depth-t.openStart,a=s.node(r).copy(t.content);for(let o=r-1;o>=0;o--)a=s.node(o).copy(Tr.from(a));return{start:a.resolveNoCache(t.openStart+r),end:a.resolveNoCache(a.content.size-t.openEnd-r)}}class m6{constructor(s,r,n){this.pos=s,this.path=r,this.parentOffset=n,this.depth=r.length/3-1}resolveDepth(s){return s==null?this.depth:s<0?this.depth+s:s}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(s){return this.path[this.resolveDepth(s)*3]}index(s){return this.path[this.resolveDepth(s)*3+1]}indexAfter(s){return s=this.resolveDepth(s),this.index(s)+(s==this.depth&&!this.textOffset?0:1)}start(s){return s=this.resolveDepth(s),s==0?0:this.path[s*3-1]+1}end(s){return s=this.resolveDepth(s),this.start(s)+this.node(s).content.size}before(s){if(s=this.resolveDepth(s),!s)throw new RangeError("There is no position before the top-level node");return s==this.depth+1?this.pos:this.path[s*3-1]}after(s){if(s=this.resolveDepth(s),!s)throw new RangeError("There is no position after the top-level node");return s==this.depth+1?this.pos:this.path[s*3-1]+this.path[s*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let s=this.parent,r=this.index(this.depth);if(r==s.childCount)return null;let n=this.pos-this.path[this.path.length-1],a=s.child(r);return n?s.child(r).cut(n):a}get nodeBefore(){let s=this.index(this.depth),r=this.pos-this.path[this.path.length-1];return r?this.parent.child(s).cut(0,r):s==0?null:this.parent.child(s-1)}posAtIndex(s,r){r=this.resolveDepth(r);let n=this.path[r*3],a=r==0?0:this.path[r*3-1]+1;for(let o=0;o0;r--)if(this.start(r)<=s&&this.end(r)>=s)return r;return 0}blockRange(s=this,r){if(s.pos=0;n--)if(s.pos<=this.end(n)&&(!r||r(this.node(n))))return new Jne(this,s,n);return null}sameParent(s){return this.pos-this.parentOffset==s.pos-s.parentOffset}max(s){return s.pos>this.pos?s:this}min(s){return s.pos=0&&r<=s.content.size))throw new RangeError("Position "+r+" out of range");let n=[],a=0,o=r;for(let l=s;;){let{index:i,offset:d}=l.content.findIndex(o),u=o-d;if(n.push(l,i,a+d),!u||(l=l.child(i),l.isText))break;o=u-1,a+=d+1}return new m6(r,n,o)}static resolveCached(s,r){let n=aTe.get(s);if(n)for(let o=0;os&&this.nodesBetween(s,r,o=>(n.isInSet(o.marks)&&(a=!0),!a)),a}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let s=this.type.name;return this.content.size&&(s+="("+this.content.toStringInner()+")"),mHe(this.marks,s)}contentMatchAt(s){let r=this.type.contentMatch.matchFragment(this.content,0,s);if(!r)throw new Error("Called contentMatchAt on a node with invalid content");return r}canReplace(s,r,n=Tr.empty,a=0,o=n.childCount){let l=this.contentMatchAt(s).matchFragment(n,a,o),i=l&&l.matchFragment(this.content,r);if(!i||!i.validEnd)return!1;for(let d=a;dr.type.name)}`);this.content.forEach(r=>r.check())}toJSON(){let s={type:this.type.name};for(let r in this.attrs){s.attrs=this.attrs;break}return this.content.size&&(s.content=this.content.toJSON()),this.marks.length&&(s.marks=this.marks.map(r=>r.toJSON())),s}static fromJSON(s,r){if(!r)throw new RangeError("Invalid input for Node.fromJSON");let n;if(r.marks){if(!Array.isArray(r.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=r.marks.map(s.markFromJSON)}if(r.type=="text"){if(typeof r.text!="string")throw new RangeError("Invalid text node in JSON");return s.text(r.text,n)}let a=Tr.fromJSON(s,r.content),o=s.nodeType(r.type).create(r.attrs,a,n);return o.type.checkAttrs(o.attrs),o}};__.prototype.text=void 0;class eae extends __{constructor(s,r,n,a){if(super(s,r,null,a),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):mHe(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(s,r){return this.text.slice(s,r)}get nodeSize(){return this.text.length}mark(s){return s==this.marks?this:new eae(this.type,this.attrs,this.text,s)}withText(s){return s==this.text?this:new eae(this.type,this.attrs,s,this.marks)}cut(s=0,r=this.text.length){return s==0&&r==this.text.length?this:this.withText(this.text.slice(s,r))}eq(s){return this.sameMarkup(s)&&this.text==s.text}toJSON(){let s=super.toJSON();return s.text=this.text,s}}function mHe(t,s){for(let r=t.length-1;r>=0;r--)s=t[r].type.name+"("+s+")";return s}class $k{constructor(s){this.validEnd=s,this.next=[],this.wrapCache=[]}static parse(s,r){let n=new $3t(s,r);if(n.next==null)return $k.empty;let a=pHe(n);n.next&&n.err("Unexpected trailing text");let o=K3t(G3t(a));return Z3t(o,n),o}matchType(s){for(let r=0;ru.createAndFill()));for(let u=0;u=this.next.length)throw new RangeError(`There's no ${s}th edge in this content match`);return this.next[s]}toString(){let s=[];function r(n){s.push(n);for(let a=0;a{let o=a+(n.validEnd?"*":" ")+" ";for(let l=0;l"+s.indexOf(n.next[l].next);return o}).join(` `)}}$k.empty=new $k(!0);class $3t{constructor(s,r){this.string=s,this.nodeTypes=r,this.inline=null,this.pos=0,this.tokens=s.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(s){return this.next==s&&(this.pos++||!0)}err(s){throw new SyntaxError(s+" (in content expression '"+this.string+"')")}}function pHe(t){let s=[];do s.push(q3t(t));while(t.eat("|"));return s.length==1?s[0]:{type:"choice",exprs:s}}function q3t(t){let s=[];do s.push(U3t(t));while(t.next&&t.next!=")"&&t.next!="|");return s.length==1?s[0]:{type:"seq",exprs:s}}function U3t(t){let s=W3t(t);for(;;)if(t.eat("+"))s={type:"plus",expr:s};else if(t.eat("*"))s={type:"star",expr:s};else if(t.eat("?"))s={type:"opt",expr:s};else if(t.eat("{"))s=V3t(t,s);else break;return s}function iTe(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let s=Number(t.next);return t.pos++,s}function V3t(t,s){let r=iTe(t),n=r;return t.eat(",")&&(t.next!="}"?n=iTe(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:s}}function H3t(t,s){let r=t.nodeTypes,n=r[s];if(n)return[n];let a=[];for(let o in r){let l=r[o];l.isInGroup(s)&&a.push(l)}return a.length==0&&t.err("No node type or group '"+s+"' found"),a}function W3t(t){if(t.eat("(")){let s=pHe(t);return t.eat(")")||t.err("Missing closing paren"),s}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let s=H3t(t,t.next).map(r=>(t.inline==null?t.inline=r.isInline:t.inline!=r.isInline&&t.err("Mixing inline and block content"),{type:"name",value:r}));return t.pos++,s.length==1?s[0]:{type:"choice",exprs:s}}}function G3t(t){let s=[[]];return a(o(t,0),r()),s;function r(){return s.push([])-1}function n(l,i,d){let u={term:d,to:i};return s[l].push(u),u}function a(l,i){l.forEach(d=>d.to=i)}function o(l,i){if(l.type=="choice")return l.exprs.reduce((d,u)=>d.concat(o(u,i)),[]);if(l.type=="seq")for(let d=0;;d++){let u=o(l.exprs[d],i);if(d==l.exprs.length-1)return u;a(u,i=r())}else if(l.type=="star"){let d=r();return n(i,d),a(o(l.expr,d),d),[n(d)]}else if(l.type=="plus"){let d=r();return a(o(l.expr,i),d),a(o(l.expr,d),d),[n(d)]}else{if(l.type=="opt")return[n(i)].concat(o(l.expr,i));if(l.type=="range"){let d=i;for(let u=0;u{t[l].forEach(({term:i,to:d})=>{if(!i)return;let u;for(let p=0;p{u||a.push([i,u=[]]),u.indexOf(p)==-1&&u.push(p)})})});let o=s[n.join(",")]=new $k(n.indexOf(t.length-1)>-1);for(let l=0;l-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let s in this.attrs)if(this.attrs[s].isRequired)return!0;return!1}compatibleContent(s){return this==s||this.contentMatch.compatible(s.contentMatch)}computeAttrs(s){return!s&&this.defaultAttrs?this.defaultAttrs:xHe(this.attrs,s)}create(s=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new __(this,this.computeAttrs(s),Tr.from(r),pl.setFrom(n))}createChecked(s=null,r,n){return r=Tr.from(r),this.checkContent(r),new __(this,this.computeAttrs(s),r,pl.setFrom(n))}createAndFill(s=null,r,n){if(s=this.computeAttrs(s),r=Tr.from(r),r.size){let l=this.contentMatch.fillBefore(r);if(!l)return null;r=l.append(r)}let a=this.contentMatch.matchFragment(r),o=a&&a.fillBefore(Tr.empty,!0);return o?new __(this,s,r.append(o),pl.setFrom(n)):null}validContent(s){let r=this.contentMatch.matchFragment(s);if(!r||!r.validEnd)return!1;for(let n=0;n-1}allowsMarks(s){if(this.markSet==null)return!0;for(let r=0;rn[o]=new _He(o,r,l));let a=r.spec.topNode||"doc";if(!n[a])throw new RangeError("Schema is missing its top node type ('"+a+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function Y3t(t,s,r){let n=r.split("|");return a=>{let o=a===null?"null":typeof a;if(n.indexOf(o)<0)throw new RangeError(`Expected value of type ${n} for attribute ${s} on type ${t}, got ${o}`)}}class X3t{constructor(s,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Y3t(s,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class gle{constructor(s,r,n,a){this.name=s,this.rank=r,this.schema=n,this.spec=a,this.attrs=vHe(s,a.attrs),this.excluded=null;let o=gHe(this.attrs);this.instance=o?new pl(this,o):null}create(s=null){return!s&&this.instance?this.instance:new pl(this,xHe(this.attrs,s))}static compile(s,r){let n=Object.create(null),a=0;return s.forEach((o,l)=>n[o]=new gle(o,a++,r,l)),n}removeFromSet(s){for(var r=0;r-1}}class bHe{constructor(s){this.linebreakReplacement=null,this.cached=Object.create(null);let r=this.spec={};for(let a in s)r[a]=s[a];r.nodes=Pu.from(s.nodes),r.marks=Pu.from(s.marks||{}),this.nodes=lTe.compile(this.spec.nodes,this),this.marks=gle.compile(this.spec.marks,this);let n=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw new RangeError(a+" can not be both a node and a mark");let o=this.nodes[a],l=o.spec.content||"",i=o.spec.marks;if(o.contentMatch=n[l]||(n[l]=$k.parse(l,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=i=="_"?null:i?cTe(this,i.split(" ")):i==""||!o.inlineContent?[]:null}for(let a in this.marks){let o=this.marks[a],l=o.spec.excludes;o.excluded=l==null?[o]:l==""?[]:cTe(this,l.split(" "))}this.nodeFromJSON=a=>__.fromJSON(this,a),this.markFromJSON=a=>pl.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(s,r=null,n,a){if(typeof s=="string")s=this.nodeType(s);else if(s instanceof lTe){if(s.schema!=this)throw new RangeError("Node type from different schema used ("+s.name+")")}else throw new RangeError("Invalid node type: "+s);return s.createChecked(r,n,a)}text(s,r){let n=this.nodes.text;return new eae(n,n.defaultAttrs,s,pl.setFrom(r))}mark(s,r){return typeof s=="string"&&(s=this.marks[s]),s.create(r)}nodeType(s){let r=this.nodes[s];if(!r)throw new RangeError("Unknown node type: "+s);return r}}function cTe(t,s){let r=[];for(let n=0;n-1)&&r.push(l=d)}if(!l)throw new SyntaxError("Unknown mark type: '"+s[n]+"'")}return r}function Q3t(t){return t.tag!=null}function J3t(t){return t.style!=null}let cI=class Pxe{constructor(s,r){this.schema=s,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(a=>{if(Q3t(a))this.tags.push(a);else if(J3t(a)){let o=/[^=]*/.exec(a.style)[0];n.indexOf(o)<0&&n.push(o),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(a=>{if(!/^(ul|ol)\b/.test(a.tag)||!a.node)return!1;let o=s.nodes[a.node];return o.contentMatch.matchType(o)})}parse(s,r={}){let n=new uTe(this,r,!1);return n.addAll(s,pl.none,r.from,r.to),n.finish()}parseSlice(s,r={}){let n=new uTe(this,r,!0);return n.addAll(s,pl.none,r.from,r.to),fn.maxOpen(n.finish())}matchTag(s,r,n){for(let a=n?this.tags.indexOf(n)+1:0;as.length&&(i.charCodeAt(s.length)!=61||i.slice(s.length+1)!=r))){if(l.getAttrs){let d=l.getAttrs(r);if(d===!1)continue;l.attrs=d||void 0}return l}}}static schemaRules(s){let r=[];function n(a){let o=a.priority==null?50:a.priority,l=0;for(;l{n(l=hTe(l)),l.mark||l.ignore||l.clearMark||(l.mark=a)})}for(let a in s.nodes){let o=s.nodes[a].spec.parseDOM;o&&o.forEach(l=>{n(l=hTe(l)),l.node||l.ignore||l.mark||(l.node=a)})}return r}static fromSchema(s){return s.cached.domParser||(s.cached.domParser=new Pxe(s,Pxe.schemaRules(s)))}};const wHe={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},eMt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},jHe={ol:!0,ul:!0},p6=1,Ixe=2,dI=4;function dTe(t,s,r){return s!=null?(s?p6:0)|(s==="full"?Ixe:0):t&&t.whitespace=="pre"?p6|Ixe:r&~dI}class tR{constructor(s,r,n,a,o,l){this.type=s,this.attrs=r,this.marks=n,this.solid=a,this.options=l,this.content=[],this.activeMarks=pl.none,this.match=o||(l&dI?null:s.contentMatch)}findWrapping(s){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(Tr.from(s));if(r)this.match=this.type.contentMatch.matchFragment(r);else{let n=this.type.contentMatch,a;return(a=n.findWrapping(s.type))?(this.match=n,a):null}}return this.match.findWrapping(s.type)}finish(s){if(!(this.options&p6)){let n=this.content[this.content.length-1],a;if(n&&n.isText&&(a=/[ \t\r\n\u000c]+$/.exec(n.text))){let o=n;n.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-a[0].length))}}let r=Tr.from(this.content);return!s&&this.match&&(r=r.append(this.match.fillBefore(Tr.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r}inlineContext(s){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:s.parentNode&&!wHe.hasOwnProperty(s.parentNode.nodeName.toLowerCase())}}class uTe{constructor(s,r,n){this.parser=s,this.options=r,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let a=r.topNode,o,l=dTe(null,r.preserveWhitespace,0)|(n?dI:0);a?o=new tR(a.type,a.attrs,pl.none,!0,r.topMatch||a.type.contentMatch,l):n?o=new tR(null,null,pl.none,!0,null,l):o=new tR(s.schema.topNodeType,null,pl.none,!0,null,l),this.nodes=[o],this.find=r.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(s,r){s.nodeType==3?this.addTextNode(s,r):s.nodeType==1&&this.addElement(s,r)}addTextNode(s,r){let n=s.nodeValue,a=this.top,o=a.options&Ixe?"full":this.localPreserveWS||(a.options&p6)>0,{schema:l}=this.parser;if(o==="full"||a.inlineContext(s)||/[^ \t\r\n\u000c]/.test(n)){if(o)if(o==="full")n=n.replace(/\r\n?/g,` `);else if(l.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(l.linebreakReplacement.create())){let i=n.split(/\r?\n|\r/);for(let d=0;d!d.clearMark(u)):r=r.concat(this.parser.schema.marks[d.mark].create(d.attrs)),d.consuming===!1)i=d;else break}}return r}addElementByRule(s,r,n,a){let o,l;if(r.node)if(l=this.parser.schema.nodes[r.node],l.isLeaf)this.insertNode(l.create(r.attrs),n,s.nodeName=="BR")||this.leafFallback(s,n);else{let d=this.enter(l,r.attrs||null,n,r.preserveWhitespace);d&&(o=!0,n=d)}else{let d=this.parser.schema.marks[r.mark];n=n.concat(d.create(r.attrs))}let i=this.top;if(l&&l.isLeaf)this.findInside(s);else if(a)this.addElement(s,n,a);else if(r.getContent)this.findInside(s),r.getContent(s,this.parser.schema).forEach(d=>this.insertNode(d,n,!1));else{let d=s;typeof r.contentElement=="string"?d=s.querySelector(r.contentElement):typeof r.contentElement=="function"?d=r.contentElement(s):r.contentElement&&(d=r.contentElement),this.findAround(s,d,!0),this.addAll(d,n),this.findAround(s,d,!1)}o&&this.sync(i)&&this.open--}addAll(s,r,n,a){let o=n||0;for(let l=n?s.childNodes[n]:s.firstChild,i=a==null?null:s.childNodes[a];l!=i;l=l.nextSibling,++o)this.findAtPoint(s,o),this.addDOM(l,r);this.findAtPoint(s,o)}findPlace(s,r,n){let a,o;for(let l=this.open,i=0;l>=0;l--){let d=this.nodes[l],u=d.findWrapping(s);if(u&&(!a||a.length>u.length+i)&&(a=u,o=d,!u.length))break;if(d.solid){if(n)break;i+=2}}if(!a)return null;this.sync(o);for(let l=0;l(l.type?l.type.allowsMarkType(u.type):mTe(u.type,s))?(d=u.addToSet(d),!1):!0),this.nodes.push(new tR(s,r,d,a,null,i)),this.open++,n}closeExtra(s=!1){let r=this.nodes.length-1;if(r>this.open){for(;r>this.open;r--)this.nodes[r-1].content.push(this.nodes[r].finish(s));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(s){for(let r=this.open;r>=0;r--){if(this.nodes[r]==s)return this.open=r,!0;this.localPreserveWS&&(this.nodes[r].options|=p6)}return!1}get currentPos(){this.closeExtra();let s=0;for(let r=this.open;r>=0;r--){let n=this.nodes[r].content;for(let a=n.length-1;a>=0;a--)s+=n[a].nodeSize;r&&s++}return s}findAtPoint(s,r){if(this.find)for(let n=0;n-1)return s.split(/\s*\|\s*/).some(this.matchesContext,this);let r=s.split("/"),n=this.options.context,a=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),o=-(n?n.depth+1:0)+(a?0:1),l=(i,d)=>{for(;i>=0;i--){let u=r[i];if(u==""){if(i==r.length-1||i==0)continue;for(;d>=o;d--)if(l(i-1,d))return!0;return!1}else{let p=d>0||d==0&&a?this.nodes[d].type:n&&d>=o?n.node(d-o).type:null;if(!p||p.name!=u&&!p.isInGroup(u))return!1;d--}}return!0};return l(r.length-1,this.open)}textblockFromContext(){let s=this.options.context;if(s)for(let r=s.depth;r>=0;r--){let n=s.node(r).contentMatchAt(s.indexAfter(r)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let r in this.parser.schema.nodes){let n=this.parser.schema.nodes[r];if(n.isTextblock&&n.defaultAttrs)return n}}}function tMt(t){for(let s=t.firstChild,r=null;s;s=s.nextSibling){let n=s.nodeType==1?s.nodeName.toLowerCase():null;n&&jHe.hasOwnProperty(n)&&r?(r.appendChild(s),s=r):n=="li"?r=s:n&&(r=null)}}function sMt(t,s){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,s)}function hTe(t){let s={};for(let r in t)s[r]=t[r];return s}function mTe(t,s){let r=s.schema.nodes;for(let n in r){let a=r[n];if(!a.allowsMarkType(t))continue;let o=[],l=i=>{o.push(i);for(let d=0;d{if(o.length||l.marks.length){let i=0,d=0;for(;i=0;a--){let o=this.serializeMark(s.marks[a],s.isInline,r);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(s,r,n={}){let a=this.marks[s.type.name];return a&&Sre(yme(n),a(s,r),null,s.attrs)}static renderSpec(s,r,n=null,a){return Sre(s,r,n,a)}static fromSchema(s){return s.cached.domSerializer||(s.cached.domSerializer=new dS(this.nodesFromSchema(s),this.marksFromSchema(s)))}static nodesFromSchema(s){let r=pTe(s.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(s){return pTe(s.marks)}}function pTe(t){let s={};for(let r in t){let n=t[r].spec.toDOM;n&&(s[r]=n)}return s}function yme(t){return t.document||window.document}const fTe=new WeakMap;function rMt(t){let s=fTe.get(t);return s===void 0&&fTe.set(t,s=nMt(t)),s}function nMt(t){let s=null;function r(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")s||(s=[]),s.push(n);else for(let a=0;a-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=a.indexOf(" ");l>0&&(r=a.slice(0,l),a=a.slice(l+1));let i,d=r?t.createElementNS(r,a):t.createElement(a),u=s[1],p=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){p=2;for(let f in u)if(u[f]!=null){let y=f.indexOf(" ");y>0?d.setAttributeNS(f.slice(0,y),f.slice(y+1),u[f]):f=="style"&&d.style?d.style.cssText=u[f]:d.setAttribute(f,u[f])}}for(let f=p;fp)throw new RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}else{let{dom:_,contentDOM:b}=Sre(t,y,r,n);if(d.appendChild(_),b){if(i)throw new RangeError("Multiple content holes");i=b}}}return{dom:d,contentDOM:i}}const NHe=65535,kHe=Math.pow(2,16);function aMt(t,s){return t+s*kHe}function gTe(t){return t&NHe}function iMt(t){return(t-(t&NHe))/kHe}const SHe=1,CHe=2,Cre=4,MHe=8;class Lxe{constructor(s,r,n){this.pos=s,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&MHe)>0}get deletedBefore(){return(this.delInfo&(SHe|Cre))>0}get deletedAfter(){return(this.delInfo&(CHe|Cre))>0}get deletedAcross(){return(this.delInfo&Cre)>0}}class hp{constructor(s,r=!1){if(this.ranges=s,this.inverted=r,!s.length&&hp.empty)return hp.empty}recover(s){let r=0,n=gTe(s);if(!this.inverted)for(let a=0;as)break;let u=this.ranges[i+o],p=this.ranges[i+l],f=d+u;if(s<=f){let y=u?s==d?-1:s==f?1:r:r,_=d+a+(y<0?0:p);if(n)return _;let b=s==(r<0?d:f)?null:aMt(i/3,s-d),w=s==d?CHe:s==f?SHe:Cre;return(r<0?s!=d:s!=f)&&(w|=MHe),new Lxe(_,w,b)}a+=p-u}return n?s+a:new Lxe(s+a,0,null)}touches(s,r){let n=0,a=gTe(r),o=this.inverted?2:1,l=this.inverted?1:2;for(let i=0;is)break;let u=this.ranges[i+o],p=d+u;if(s<=p&&i==a*3)return!0;n+=this.ranges[i+l]-u}return!1}forEach(s){let r=this.inverted?2:1,n=this.inverted?1:2;for(let a=0,o=0;a=0;r--){let a=s.getMirror(r);this.appendMap(s._maps[r].invert(),a!=null&&a>r?n-a-1:void 0)}}invert(){let s=new f6;return s.appendMappingInverted(this),s}map(s,r=1){if(this.mirror)return this._map(s,r,!0);for(let n=this.from;no&&d!l.isAtom||!i.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),a),r.openStart,r.openEnd);return Nd.fromReplace(s,this.from,this.to,o)}invert(){return new Hx(this.from,this.to,this.mark)}map(s){let r=s.mapResult(this.from,1),n=s.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new H1(r.pos,n.pos,this.mark)}merge(s){return s instanceof H1&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new H1(Math.min(this.from,s.from),Math.max(this.to,s.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(s,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new H1(r.from,r.to,s.markFromJSON(r.mark))}}mh.jsonID("addMark",H1);class Hx extends mh{constructor(s,r,n){super(),this.from=s,this.to=r,this.mark=n}apply(s){let r=s.slice(this.from,this.to),n=new fn(_be(r.content,a=>a.mark(this.mark.removeFromSet(a.marks)),s),r.openStart,r.openEnd);return Nd.fromReplace(s,this.from,this.to,n)}invert(){return new H1(this.from,this.to,this.mark)}map(s){let r=s.mapResult(this.from,1),n=s.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new Hx(r.pos,n.pos,this.mark)}merge(s){return s instanceof Hx&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new Hx(Math.min(this.from,s.from),Math.max(this.to,s.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(s,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Hx(r.from,r.to,s.markFromJSON(r.mark))}}mh.jsonID("removeMark",Hx);class W1 extends mh{constructor(s,r){super(),this.pos=s,this.mark=r}apply(s){let r=s.nodeAt(this.pos);if(!r)return Nd.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return Nd.fromReplace(s,this.pos,this.pos+1,new fn(Tr.from(n),0,r.isLeaf?0:1))}invert(s){let r=s.nodeAt(this.pos);if(r){let n=this.mark.addToSet(r.marks);if(n.length==r.marks.length){for(let a=0;an.pos?null:new xu(r.pos,n.pos,a,o,this.slice,this.insert,this.structure)}toJSON(){let s={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(s.slice=this.slice.toJSON()),this.structure&&(s.structure=!0),s}static fromJSON(s,r){if(typeof r.from!="number"||typeof r.to!="number"||typeof r.gapFrom!="number"||typeof r.gapTo!="number"||typeof r.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new xu(r.from,r.to,r.gapFrom,r.gapTo,fn.fromJSON(s,r.slice),r.insert,!!r.structure)}}mh.jsonID("replaceAround",xu);function Dxe(t,s,r){let n=t.resolve(s),a=r-s,o=n.depth;for(;a>0&&o>0&&n.indexAfter(o)==n.node(o).childCount;)o--,a--;if(a>0){let l=n.node(o).maybeChild(n.indexAfter(o));for(;a>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,a--}}return!1}function oMt(t,s,r,n){let a=[],o=[],l,i;t.doc.nodesBetween(s,r,(d,u,p)=>{if(!d.isInline)return;let f=d.marks;if(!n.isInSet(f)&&p.type.allowsMarkType(n.type)){let y=Math.max(u,s),_=Math.min(u+d.nodeSize,r),b=n.addToSet(f);for(let w=0;wt.step(d)),o.forEach(d=>t.step(d))}function lMt(t,s,r,n){let a=[],o=0;t.doc.nodesBetween(s,r,(l,i)=>{if(!l.isInline)return;o++;let d=null;if(n instanceof gle){let u=l.marks,p;for(;p=n.isInSet(u);)(d||(d=[])).push(p),u=p.removeFromSet(u)}else n?n.isInSet(l.marks)&&(d=[n]):d=l.marks;if(d&&d.length){let u=Math.min(i+l.nodeSize,r);for(let p=0;pt.step(new Hx(l.from,l.to,l.style)))}function bbe(t,s,r,n=r.contentMatch,a=!0){let o=t.doc.nodeAt(s),l=[],i=s+1;for(let d=0;d=0;d--)t.step(l[d])}function cMt(t,s,r){return(s==0||t.canReplace(s,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function PM(t){let r=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth,a=0,o=0;;--n){let l=t.$from.node(n),i=t.$from.index(n)+a,d=t.$to.indexAfter(n)-o;if(nr;b--)w||n.index(b)>0?(w=!0,p=Tr.from(n.node(b).copy(p)),f++):d--;let y=Tr.empty,_=0;for(let b=o,w=!1;b>r;b--)w||a.after(b+1)=0;l--){if(n.size){let i=r[l].type.contentMatch.matchFragment(n);if(!i||!i.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=Tr.from(r[l].type.create(r[l].attrs,n))}let a=s.start,o=s.end;t.step(new xu(a,o,a,o,new fn(n,0,0),r.length,!0))}function pMt(t,s,r,n,a){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(s,r,(l,i)=>{let d=typeof a=="function"?a(l):a;if(l.isTextblock&&!l.hasMarkup(n,d)&&fMt(t.doc,t.mapping.slice(o).map(i),n)){let u=null;if(n.schema.linebreakReplacement){let _=n.whitespace=="pre",b=!!n.contentMatch.matchType(n.schema.linebreakReplacement);_&&!b?u=!1:!_&&b&&(u=!0)}u===!1&&AHe(t,l,i,o),bbe(t,t.mapping.slice(o).map(i,1),n,void 0,u===null);let p=t.mapping.slice(o),f=p.map(i,1),y=p.map(i+l.nodeSize,1);return t.step(new xu(f,y,f+1,y-1,new fn(Tr.from(n.create(d,null,l.marks)),0,0),1,!0)),u===!0&&THe(t,l,i,o),!1}})}function THe(t,s,r,n){s.forEach((a,o)=>{if(a.isText){let l,i=/\r?\n|\r/g;for(;l=i.exec(a.text);){let d=t.mapping.slice(n).map(r+1+o+l.index);t.replaceWith(d,d+1,s.type.schema.linebreakReplacement.create())}}})}function AHe(t,s,r,n){s.forEach((a,o)=>{if(a.type==a.type.schema.linebreakReplacement){let l=t.mapping.slice(n).map(r+1+o);t.replaceWith(l,l+1,s.type.schema.text(` `))}})}function fMt(t,s,r){let n=t.resolve(s),a=n.index();return n.parent.canReplaceWith(a,a+1,r)}function gMt(t,s,r,n,a){let o=t.doc.nodeAt(s);if(!o)throw new RangeError("No node at given position");r||(r=o.type);let l=r.create(n,null,a||o.marks);if(o.isLeaf)return t.replaceWith(s,s+o.nodeSize,l);if(!r.validContent(o.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new xu(s,s+o.nodeSize,s+1,s+o.nodeSize-1,new fn(Tr.from(l),0,0),1,!0))}function V0(t,s,r=1,n){let a=t.resolve(s),o=a.depth-r,l=n&&n[n.length-1]||a.parent;if(o<0||a.parent.type.spec.isolating||!a.parent.canReplace(a.index(),a.parent.childCount)||!l.type.validContent(a.parent.content.cutByIndex(a.index(),a.parent.childCount)))return!1;for(let u=a.depth-1,p=r-2;u>o;u--,p--){let f=a.node(u),y=a.index(u);if(f.type.spec.isolating)return!1;let _=f.content.cutByIndex(y,f.childCount),b=n&&n[p+1];b&&(_=_.replaceChild(0,b.type.create(b.attrs)));let w=n&&n[p]||f;if(!f.canReplace(y+1,f.childCount)||!w.type.validContent(_))return!1}let i=a.indexAfter(o),d=n&&n[0];return a.node(o).canReplaceWith(i,i,d?d.type:a.node(o+1).type)}function xMt(t,s,r=1,n){let a=t.doc.resolve(s),o=Tr.empty,l=Tr.empty;for(let i=a.depth,d=a.depth-r,u=r-1;i>d;i--,u--){o=Tr.from(a.node(i).copy(o));let p=n&&n[u];l=Tr.from(p?p.type.create(p.attrs,l):a.node(i).copy(l))}t.step(new uu(s,s,new fn(o.append(l),r,r),!0))}function J_(t,s){let r=t.resolve(s),n=r.index();return EHe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function yMt(t,s){s.content.size||t.type.compatibleContent(s.type);let r=t.contentMatchAt(t.childCount),{linebreakReplacement:n}=t.type.schema;for(let a=0;a0?(o=n.node(a+1),i++,l=n.node(a).maybeChild(i)):(o=n.node(a).maybeChild(i-1),l=n.node(a+1)),o&&!o.isTextblock&&EHe(o,l)&&n.node(a).canReplace(i,i+1))return s;if(a==0)break;s=r<0?n.before(a):n.after(a)}}function vMt(t,s,r){let n=null,{linebreakReplacement:a}=t.doc.type.schema,o=t.doc.resolve(s-r),l=o.node().type;if(a&&l.inlineContent){let p=l.whitespace=="pre",f=!!l.contentMatch.matchType(a);p&&!f?n=!1:!p&&f&&(n=!0)}let i=t.steps.length;if(n===!1){let p=t.doc.resolve(s+r);AHe(t,p.node(),p.before(),i)}l.inlineContent&&bbe(t,s+r-1,l,o.node().contentMatchAt(o.index()),n==null);let d=t.mapping.slice(i),u=d.map(s-r);if(t.step(new uu(u,d.map(s+r,-1),fn.empty,!0)),n===!0){let p=t.doc.resolve(u);THe(t,p.node(),p.before(),t.steps.length)}return t}function _Mt(t,s,r){let n=t.resolve(s);if(n.parent.canReplaceWith(n.index(),n.index(),r))return s;if(n.parentOffset==0)for(let a=n.depth-1;a>=0;a--){let o=n.index(a);if(n.node(a).canReplaceWith(o,o,r))return n.before(a+1);if(o>0)return null}if(n.parentOffset==n.parent.content.size)for(let a=n.depth-1;a>=0;a--){let o=n.indexAfter(a);if(n.node(a).canReplaceWith(o,o,r))return n.after(a+1);if(o=0;l--){let i=l==n.depth?0:n.pos<=(n.start(l+1)+n.end(l+1))/2?-1:1,d=n.index(l)+(i>0?1:0),u=n.node(l),p=!1;if(o==1)p=u.canReplace(d,d,a);else{let f=u.contentMatchAt(d).findWrapping(a.firstChild.type);p=f&&u.canReplaceWith(d,d,f[0])}if(p)return i==0?n.pos:i<0?n.before(l+1):n.after(l+1)}return null}function yle(t,s,r=s,n=fn.empty){if(s==r&&!n.size)return null;let a=t.resolve(s),o=t.resolve(r);return IHe(a,o,n)?new uu(s,r,n):new bMt(a,o,n).fit()}function IHe(t,s,r){return!r.openStart&&!r.openEnd&&t.start()==s.start()&&t.parent.canReplace(t.index(),s.index(),r.content)}class bMt{constructor(s,r,n){this.$from=s,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Tr.empty;for(let a=0;a<=s.depth;a++){let o=s.node(a);this.frontier.push({type:o.type,match:o.contentMatchAt(s.indexAfter(a))})}for(let a=s.depth;a>0;a--)this.placed=Tr.from(s.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let s=this.mustMoveInline(),r=this.placed.size-this.depth-this.$from.depth,n=this.$from,a=this.close(s<0?this.$to:n.doc.resolve(s));if(!a)return null;let o=this.placed,l=n.depth,i=a.depth;for(;l&&i&&o.childCount==1;)o=o.firstChild.content,l--,i--;let d=new fn(o,l,i);return s>-1?new xu(n.pos,s,this.$to.pos,this.$to.end(),d,r):d.size||n.pos!=this.$to.pos?new uu(n.pos,a.pos,d):null}findFittable(){let s=this.unplaced.openStart;for(let r=this.unplaced.content,n=0,a=this.unplaced.openEnd;n1&&(a=0),o.type.spec.isolating&&a<=n){s=n;break}r=o.content}for(let r=1;r<=2;r++)for(let n=r==1?s:this.unplaced.openStart;n>=0;n--){let a,o=null;n?(o=_me(this.unplaced.content,n-1).firstChild,a=o.content):a=this.unplaced.content;let l=a.firstChild;for(let i=this.depth;i>=0;i--){let{type:d,match:u}=this.frontier[i],p,f=null;if(r==1&&(l?u.matchType(l.type)||(f=u.fillBefore(Tr.from(l),!1)):o&&d.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:i,parent:o,inject:f};if(r==2&&l&&(p=u.findWrapping(l.type)))return{sliceDepth:n,frontierDepth:i,parent:o,wrap:p};if(o&&u.matchType(o.type))break}}}openMore(){let{content:s,openStart:r,openEnd:n}=this.unplaced,a=_me(s,r);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new fn(s,r+1,Math.max(n,a.size+r>=s.size-n?r+1:0)),!0)}dropNode(){let{content:s,openStart:r,openEnd:n}=this.unplaced,a=_me(s,r);if(a.childCount<=1&&r>0){let o=s.size-r<=r+a.size;this.unplaced=new fn(zE(s,r-1,1),r-1,o?r-1:n)}else this.unplaced=new fn(zE(s,r,1),r,n)}placeNodes({sliceDepth:s,frontierDepth:r,parent:n,inject:a,wrap:o}){for(;this.depth>r;)this.closeFrontierNode();if(o)for(let w=0;w1||d==0||w.content.size)&&(f=j,p.push(LHe(w.mark(y.allowedMarks(w.marks)),u==1?d:0,u==i.childCount?_:-1)))}let b=u==i.childCount;b||(_=-1),this.placed=BE(this.placed,r,Tr.from(p)),this.frontier[r].match=f,b&&_<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,j=i;w<_;w++){let k=j.lastChild;this.frontier.push({type:k.type,match:k.contentMatchAt(k.childCount)}),j=k.content}this.unplaced=b?s==0?fn.empty:new fn(zE(l.content,s-1,1),s-1,_<0?l.openEnd:s-1):new fn(zE(l.content,s,u),l.openStart,l.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let s=this.frontier[this.depth],r;if(!s.type.isTextblock||!bme(this.$to,this.$to.depth,s.type,s.match,!1)||this.$to.depth==this.depth&&(r=this.findCloseLevel(this.$to))&&r.depth==this.depth)return-1;let{depth:n}=this.$to,a=this.$to.after(n);for(;n>1&&a==this.$to.end(--n);)++a;return a}findCloseLevel(s){e:for(let r=Math.min(this.depth,s.depth);r>=0;r--){let{match:n,type:a}=this.frontier[r],o=r=0;i--){let{match:d,type:u}=this.frontier[i],p=bme(s,i,u,d,!0);if(!p||p.childCount)continue e}return{depth:r,fit:l,move:o?s.doc.resolve(s.after(r+1)):s}}}}close(s){let r=this.findCloseLevel(s);if(!r)return null;for(;this.depth>r.depth;)this.closeFrontierNode();r.fit.childCount&&(this.placed=BE(this.placed,r.depth,r.fit)),s=r.move;for(let n=r.depth+1;n<=s.depth;n++){let a=s.node(n),o=a.type.contentMatch.fillBefore(a.content,!0,s.index(n));this.openFrontierNode(a.type,a.attrs,o)}return s}openFrontierNode(s,r=null,n){let a=this.frontier[this.depth];a.match=a.match.matchType(s),this.placed=BE(this.placed,this.depth,Tr.from(s.create(r,n))),this.frontier.push({type:s,match:s.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Tr.empty,!0);r.childCount&&(this.placed=BE(this.placed,this.frontier.length,r))}}function zE(t,s,r){return s==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(zE(t.firstChild.content,s-1,r)))}function BE(t,s,r){return s==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(BE(t.lastChild.content,s-1,r)))}function _me(t,s){for(let r=0;r1&&(n=n.replaceChild(0,LHe(n.firstChild,s-1,n.childCount==1?r-1:0))),s>0&&(n=t.type.contentMatch.fillBefore(n).append(n),r<=0&&(n=n.append(t.type.contentMatch.matchFragment(n).fillBefore(Tr.empty,!0)))),t.copy(n)}function bme(t,s,r,n,a){let o=t.node(s),l=a?t.indexAfter(s):t.index(s);if(l==o.childCount&&!r.compatibleContent(o.type))return null;let i=n.fillBefore(o.content,!0,l);return i&&!wMt(r,o.content,l)?i:null}function wMt(t,s,r){for(let n=r;n0;y--,_--){let b=a.node(y).type.spec;if(b.defining||b.definingAsContext||b.isolating)break;l.indexOf(y)>-1?i=y:a.before(y)==_&&l.splice(1,0,-y)}let d=l.indexOf(i),u=[],p=n.openStart;for(let y=n.content,_=0;;_++){let b=y.firstChild;if(u.push(b),_==n.openStart)break;y=b.content}for(let y=p-1;y>=0;y--){let _=u[y],b=jMt(_.type);if(b&&!_.sameMarkup(a.node(Math.abs(i)-1)))p=y;else if(b||!_.type.isTextblock)break}for(let y=n.openStart;y>=0;y--){let _=(y+p+1)%(n.openStart+1),b=u[_];if(b)for(let w=0;w=0&&(t.replace(s,r,n),!(t.steps.length>f));y--){let _=l[y];_<0||(s=a.before(_),r=o.after(_))}}function DHe(t,s,r,n,a){if(sn){let o=a.contentMatchAt(0),l=o.fillBefore(t).append(t);t=l.append(o.matchFragment(l).fillBefore(Tr.empty,!0))}return t}function kMt(t,s,r,n){if(!n.isInline&&s==r&&t.doc.resolve(s).parent.content.size){let a=_Mt(t.doc,s,n.type);a!=null&&(s=r=a)}t.replaceRange(s,r,new fn(Tr.from(n),0,0))}function SMt(t,s,r){let n=t.doc.resolve(s),a=t.doc.resolve(r),o=OHe(n,a);for(let l=0;l0&&(d||n.node(i-1).canReplace(n.index(i-1),a.indexAfter(i-1))))return t.delete(n.before(i),a.after(i))}for(let l=1;l<=n.depth&&l<=a.depth;l++)if(s-n.start(l)==n.depth-l&&r>n.end(l)&&a.end(l)-r!=a.depth-l&&n.start(l-1)==a.start(l-1)&&n.node(l-1).canReplace(n.index(l-1),a.index(l-1)))return t.delete(n.before(l),r);t.delete(s,r)}function OHe(t,s){let r=[],n=Math.min(t.depth,s.depth);for(let a=n;a>=0;a--){let o=t.start(a);if(os.pos+(s.depth-a)||t.node(a).type.spec.isolating||s.node(a).type.spec.isolating)break;(o==s.start(a)||a==t.depth&&a==s.depth&&t.parent.inlineContent&&s.parent.inlineContent&&a&&s.start(a-1)==o-1)&&r.push(a)}return r}class $5 extends mh{constructor(s,r,n){super(),this.pos=s,this.attr=r,this.value=n}apply(s){let r=s.nodeAt(this.pos);if(!r)return Nd.fail("No node at attribute step's position");let n=Object.create(null);for(let o in r.attrs)n[o]=r.attrs[o];n[this.attr]=this.value;let a=r.type.create(n,null,r.marks);return Nd.fromReplace(s,this.pos,this.pos+1,new fn(Tr.from(a),0,r.isLeaf?0:1))}getMap(){return hp.empty}invert(s){return new $5(this.pos,this.attr,s.nodeAt(this.pos).attrs[this.attr])}map(s){let r=s.mapResult(this.pos,1);return r.deletedAfter?null:new $5(r.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(s,r){if(typeof r.pos!="number"||typeof r.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new $5(r.pos,r.attr,r.value)}}mh.jsonID("attr",$5);class g6 extends mh{constructor(s,r){super(),this.attr=s,this.value=r}apply(s){let r=Object.create(null);for(let a in s.attrs)r[a]=s.attrs[a];r[this.attr]=this.value;let n=s.type.create(r,s.content,s.marks);return Nd.ok(n)}getMap(){return hp.empty}invert(s){return new g6(this.attr,s.attrs[this.attr])}map(s){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(s,r){if(typeof r.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new g6(r.attr,r.value)}}mh.jsonID("docAttr",g6);let T3=class extends Error{};T3=function t(s){let r=Error.call(this,s);return r.__proto__=t.prototype,r};T3.prototype=Object.create(Error.prototype);T3.prototype.constructor=T3;T3.prototype.name="TransformError";class jbe{constructor(s){this.doc=s,this.steps=[],this.docs=[],this.mapping=new f6}get before(){return this.docs.length?this.docs[0]:this.doc}step(s){let r=this.maybeStep(s);if(r.failed)throw new T3(r.failed);return this}maybeStep(s){let r=s.apply(this.doc);return r.failed||this.addStep(s,r.doc),r}get docChanged(){return this.steps.length>0}addStep(s,r){this.docs.push(this.doc),this.steps.push(s),this.mapping.appendMap(s.getMap()),this.doc=r}replace(s,r=s,n=fn.empty){let a=yle(this.doc,s,r,n);return a&&this.step(a),this}replaceWith(s,r,n){return this.replace(s,r,new fn(Tr.from(n),0,0))}delete(s,r){return this.replace(s,r,fn.empty)}insert(s,r){return this.replaceWith(s,s,r)}replaceRange(s,r,n){return NMt(this,s,r,n),this}replaceRangeWith(s,r,n){return kMt(this,s,r,n),this}deleteRange(s,r){return SMt(this,s,r),this}lift(s,r){return dMt(this,s,r),this}join(s,r=1){return vMt(this,s,r),this}wrap(s,r){return mMt(this,s,r),this}setBlockType(s,r=s,n,a=null){return pMt(this,s,r,n,a),this}setNodeMarkup(s,r,n=null,a){return gMt(this,s,r,n,a),this}setNodeAttribute(s,r,n){return this.step(new $5(s,r,n)),this}setDocAttribute(s,r){return this.step(new g6(s,r)),this}addNodeMark(s,r){return this.step(new W1(s,r)),this}removeNodeMark(s,r){let n=this.doc.nodeAt(s);if(!n)throw new RangeError("No node at position "+s);if(r instanceof pl)r.isInSet(n.marks)&&this.step(new qk(s,r));else{let a=n.marks,o,l=[];for(;o=r.isInSet(a);)l.push(new qk(s,o)),a=o.removeFromSet(a);for(let i=l.length-1;i>=0;i--)this.step(l[i])}return this}split(s,r=1,n){return xMt(this,s,r,n),this}addMark(s,r,n){return oMt(this,s,r,n),this}removeMark(s,r,n){return lMt(this,s,r,n),this}clearIncompatible(s,r,n){return bbe(this,s,r,n),this}}const wme=Object.create(null);class ni{constructor(s,r,n){this.$anchor=s,this.$head=r,this.ranges=n||[new RHe(s.min(r),s.max(r))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let s=this.ranges;for(let r=0;r=0;o--){let l=r<0?M4(s.node(0),s.node(o),s.before(o+1),s.index(o),r,n):M4(s.node(0),s.node(o),s.after(o+1),s.index(o)+1,r,n);if(l)return l}return null}static near(s,r=1){return this.findFrom(s,r)||this.findFrom(s,-r)||new wp(s.node(0))}static atStart(s){return M4(s,s,0,0,1)||new wp(s)}static atEnd(s){return M4(s,s,s.content.size,s.childCount,-1)||new wp(s)}static fromJSON(s,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=wme[r.type];if(!n)throw new RangeError(`No selection type ${r.type} defined`);return n.fromJSON(s,r)}static jsonID(s,r){if(s in wme)throw new RangeError("Duplicate use of selection JSON ID "+s);return wme[s]=r,r.prototype.jsonID=s,r}getBookmark(){return qa.between(this.$anchor,this.$head).getBookmark()}}ni.prototype.visible=!0;class RHe{constructor(s,r){this.$from=s,this.$to=r}}let yTe=!1;function vTe(t){!yTe&&!t.parent.inlineContent&&(yTe=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class qa extends ni{constructor(s,r=s){vTe(s),vTe(r),super(s,r)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(s,r){let n=s.resolve(r.map(this.head));if(!n.parent.inlineContent)return ni.near(n);let a=s.resolve(r.map(this.anchor));return new qa(a.parent.inlineContent?a:n,n)}replace(s,r=fn.empty){if(super.replace(s,r),r==fn.empty){let n=this.$from.marksAcross(this.$to);n&&s.ensureMarks(n)}}eq(s){return s instanceof qa&&s.anchor==this.anchor&&s.head==this.head}getBookmark(){return new vle(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(s,r){if(typeof r.anchor!="number"||typeof r.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new qa(s.resolve(r.anchor),s.resolve(r.head))}static create(s,r,n=r){let a=s.resolve(r);return new this(a,n==r?a:s.resolve(n))}static between(s,r,n){let a=s.pos-r.pos;if((!n||a)&&(n=a>=0?1:-1),!r.parent.inlineContent){let o=ni.findFrom(r,n,!0)||ni.findFrom(r,-n,!0);if(o)r=o.$head;else return ni.near(r,n)}return s.parent.inlineContent||(a==0?s=r:(s=(ni.findFrom(s,-n,!0)||ni.findFrom(s,n,!0)).$anchor,s.pos0?0:1);a>0?l=0;l+=a){let i=s.child(l);if(i.isAtom){if(!o&&La.isSelectable(i))return La.create(t,r-(a<0?i.nodeSize:0))}else{let d=M4(t,i,r+a,a<0?i.childCount:0,a,o);if(d)return d}r+=i.nodeSize*a}return null}function _Te(t,s,r){let n=t.steps.length-1;if(n{l==null&&(l=p)}),t.setSelection(ni.near(t.doc.resolve(l),r))}const bTe=1,sR=2,wTe=4;class MMt extends jbe{constructor(s){super(s.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=s.selection,this.storedMarks=s.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(s){return this.storedMarks=s,this.updated|=sR,this}ensureMarks(s){return pl.sameSet(this.storedMarks||this.selection.$from.marks(),s)||this.setStoredMarks(s),this}addStoredMark(s){return this.ensureMarks(s.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(s){return this.ensureMarks(s.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&sR)>0}addStep(s,r){super.addStep(s,r),this.updated=this.updated&~sR,this.storedMarks=null}setTime(s){return this.time=s,this}replaceSelection(s){return this.selection.replace(this,s),this}replaceSelectionWith(s,r=!0){let n=this.selection;return r&&(s=s.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||pl.none))),n.replaceWith(this,s),this}deleteSelection(){return this.selection.replace(this),this}insertText(s,r,n){let a=this.doc.type.schema;if(r==null)return s?this.replaceSelectionWith(a.text(s),!0):this.deleteSelection();{if(n==null&&(n=r),!s)return this.deleteRange(r,n);let o=this.storedMarks;if(!o){let l=this.doc.resolve(r);o=n==r?l.marks():l.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(r,n,a.text(s,o)),!this.selection.empty&&this.selection.to==r+s.length&&this.setSelection(ni.near(this.selection.$to)),this}}setMeta(s,r){return this.meta[typeof s=="string"?s:s.key]=r,this}getMeta(s){return this.meta[typeof s=="string"?s:s.key]}get isGeneric(){for(let s in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=wTe,this}get scrolledIntoView(){return(this.updated&wTe)>0}}function jTe(t,s){return!s||!t?t:t.bind(s)}class $E{constructor(s,r,n){this.name=s,this.init=jTe(r.init,n),this.apply=jTe(r.apply,n)}}const TMt=[new $E("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new $E("selection",{init(t,s){return t.selection||ni.atStart(s.doc)},apply(t){return t.selection}}),new $E("storedMarks",{init(t){return t.storedMarks||null},apply(t,s,r,n){return n.selection.$cursor?t.storedMarks:null}}),new $E("scrollToSelection",{init(){return 0},apply(t,s){return t.scrolledIntoView?s+1:s}})];class jme{constructor(s,r){this.schema=s,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=TMt.slice(),r&&r.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new $E(n.key,n.spec.state,n))})}}class K4{constructor(s){this.config=s}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(s){return this.applyTransaction(s).state}filterTransaction(s,r=-1){for(let n=0;nn.toJSON())),s&&typeof s=="object")for(let n in s){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let a=s[n],o=a.spec.state;o&&o.toJSON&&(r[n]=o.toJSON.call(a,this[a.key]))}return r}static fromJSON(s,r,n){if(!r)throw new RangeError("Invalid input for EditorState.fromJSON");if(!s.schema)throw new RangeError("Required config field 'schema' missing");let a=new jme(s.schema,s.plugins),o=new K4(a);return a.fields.forEach(l=>{if(l.name=="doc")o.doc=__.fromJSON(s.schema,r.doc);else if(l.name=="selection")o.selection=ni.fromJSON(o.doc,r.selection);else if(l.name=="storedMarks")r.storedMarks&&(o.storedMarks=r.storedMarks.map(s.schema.markFromJSON));else{if(n)for(let i in n){let d=n[i],u=d.spec.state;if(d.key==l.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(r,i)){o[l.name]=u.fromJSON.call(d,s,r[i],o);return}}o[l.name]=l.init(s,o)}}),o}}function FHe(t,s,r){for(let n in t){let a=t[n];a instanceof Function?a=a.bind(s):n=="handleDOMEvents"&&(a=FHe(a,s,{})),r[n]=a}return r}class Yd{constructor(s){this.spec=s,this.props={},s.props&&FHe(s.props,this,this.props),this.key=s.key?s.key.key:zHe("plugin")}getState(s){return s[this.key]}}const Nme=Object.create(null);function zHe(t){return t in Nme?t+"$"+ ++Nme[t]:(Nme[t]=0,t+"$")}class ph{constructor(s="key"){this.key=zHe(s)}get(s){return s.config.pluginsByKey[this.key]}getState(s){return s[this.key]}}const Lu=function(t){for(var s=0;;s++)if(t=t.previousSibling,!t)return s},A3=function(t){let s=t.assignedSlot||t.parentNode;return s&&s.nodeType==11?s.host:s};let Oxe=null;const c0=function(t,s,r){let n=Oxe||(Oxe=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,s||0),n},AMt=function(){Oxe=null},Uk=function(t,s,r,n){return r&&(NTe(t,s,r,n,-1)||NTe(t,s,r,n,1))},EMt=/^(img|br|input|textarea|hr)$/i;function NTe(t,s,r,n,a){for(var o;;){if(t==r&&s==n)return!0;if(s==(a<0?0:cf(t))){let l=t.parentNode;if(!l||l.nodeType!=1||HL(t)||EMt.test(t.nodeName)||t.contentEditable=="false")return!1;s=Lu(t)+(a<0?0:1),t=l}else if(t.nodeType==1){let l=t.childNodes[s+(a<0?-1:0)];if(l.nodeType==1&&l.contentEditable=="false")if(!((o=l.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)s+=a;else return!1;else t=l,s=a<0?cf(t):0}else return!1}}function cf(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function PMt(t,s){for(;;){if(t.nodeType==3&&s)return t;if(t.nodeType==1&&s>0){if(t.contentEditable=="false")return null;t=t.childNodes[s-1],s=cf(t)}else if(t.parentNode&&!HL(t))s=Lu(t),t=t.parentNode;else return null}}function IMt(t,s){for(;;){if(t.nodeType==3&&s2),tf=E3||(dy?/Mac/.test(dy.platform):!1),qHe=dy?/Win/.test(dy.platform):!1,k0=/Android \d/.test(eb),WL=!!kTe&&"webkitFontSmoothing"in kTe.documentElement.style,RMt=WL?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function FMt(t){let s=t.defaultView&&t.defaultView.visualViewport;return s?{left:0,right:s.width,top:0,bottom:s.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Qy(t,s){return typeof t=="number"?t:t[s]}function zMt(t){let s=t.getBoundingClientRect(),r=s.width/t.offsetWidth||1,n=s.height/t.offsetHeight||1;return{left:s.left,right:s.left+t.clientWidth*r,top:s.top,bottom:s.top+t.clientHeight*n}}function STe(t,s,r){let n=t.someProp("scrollThreshold")||0,a=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let l=r||t.dom;l;){if(l.nodeType!=1){l=A3(l);continue}let i=l,d=i==o.body,u=d?FMt(o):zMt(i),p=0,f=0;if(s.topu.bottom-Qy(n,"bottom")&&(f=s.bottom-s.top>u.bottom-u.top?s.top+Qy(a,"top")-u.top:s.bottom-u.bottom+Qy(a,"bottom")),s.leftu.right-Qy(n,"right")&&(p=s.right-u.right+Qy(a,"right")),p||f)if(d)o.defaultView.scrollBy(p,f);else{let _=i.scrollLeft,b=i.scrollTop;f&&(i.scrollTop+=f),p&&(i.scrollLeft+=p);let w=i.scrollLeft-_,j=i.scrollTop-b;s={left:s.left-w,top:s.top-j,right:s.right-w,bottom:s.bottom-j}}let y=d?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(y))break;l=y=="absolute"?l.offsetParent:A3(l)}}function BMt(t){let s=t.dom.getBoundingClientRect(),r=Math.max(0,s.top),n,a;for(let o=(s.left+s.right)/2,l=r+1;l=r-20){n=i,a=d.top;break}}return{refDOM:n,refTop:a,stack:UHe(t.dom)}}function UHe(t){let s=[],r=t.ownerDocument;for(let n=t;n&&(s.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=A3(n));return s}function $Mt({refDOM:t,refTop:s,stack:r}){let n=t?t.getBoundingClientRect().top:0;VHe(r,n==0?0:n-s)}function VHe(t,s){for(let r=0;r=i){l=Math.max(b.bottom,l),i=Math.min(b.top,i);let w=b.left>s.left?b.left-s.left:b.right=(b.left+b.right)/2?1:0));continue}}else b.top>s.top&&!d&&b.left<=s.left&&b.right>=s.left&&(d=p,u={left:Math.max(b.left,Math.min(b.right,s.left)),top:b.top});!r&&(s.left>=b.right&&s.top>=b.top||s.left>=b.left&&s.top>=b.bottom)&&(o=f+1)}}return!r&&d&&(r=d,a=u,n=0),r&&r.nodeType==3?UMt(r,a):!r||n&&r.nodeType==1?{node:t,offset:o}:HHe(r,a)}function UMt(t,s){let r=t.nodeValue.length,n=document.createRange(),a;for(let o=0;o=(l.left+l.right)/2?1:0)};break}}return n.detach(),a||{node:t,offset:0}}function kbe(t,s){return t.left>=s.left-1&&t.left<=s.right+1&&t.top>=s.top-1&&t.top<=s.bottom+1}function VMt(t,s){let r=t.parentNode;return r&&/^li$/i.test(r.nodeName)&&s.left(l.left+l.right)/2?1:-1}return t.docView.posFromDOM(n,a,o)}function WMt(t,s,r,n){let a=-1;for(let o=s,l=!1;o!=t.dom;){let i=t.docView.nearestDesc(o,!0),d;if(!i)return null;if(i.dom.nodeType==1&&(i.node.isBlock&&i.parent||!i.contentDOM)&&((d=i.dom.getBoundingClientRect()).width||d.height)&&(i.node.isBlock&&i.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(i.dom.nodeName)&&(!l&&d.left>n.left||d.top>n.top?a=i.posBefore:(!l&&d.right-1?a:t.docView.posFromDOM(s,r,-1)}function WHe(t,s,r){let n=t.childNodes.length;if(n&&r.tops.top&&a++}let u;WL&&a&&n.nodeType==1&&(u=n.childNodes[a-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=s.top&&a--,n==t.dom&&a==n.childNodes.length-1&&n.lastChild.nodeType==1&&s.top>n.lastChild.getBoundingClientRect().bottom?i=t.state.doc.content.size:(a==0||n.nodeType!=1||n.childNodes[a-1].nodeName!="BR")&&(i=WMt(t,n,a,s))}i==null&&(i=HMt(t,l,s));let d=t.docView.nearestDesc(l,!0);return{pos:i,inside:d?d.posAtStart-d.border:-1}}function CTe(t){return t.top=0&&a==n.nodeValue.length?(d--,p=1):r<0?d--:u++,mE(d1(c0(n,d,u),p),p<0)}if(!t.state.doc.resolve(s-(o||0)).parent.inlineContent){if(o==null&&a&&(r<0||a==cf(n))){let d=n.childNodes[a-1];if(d.nodeType==1)return kme(d.getBoundingClientRect(),!1)}if(o==null&&a=0)}if(o==null&&a&&(r<0||a==cf(n))){let d=n.childNodes[a-1],u=d.nodeType==3?c0(d,cf(d)-(l?0:1)):d.nodeType==1&&(d.nodeName!="BR"||!d.nextSibling)?d:null;if(u)return mE(d1(u,1),!1)}if(o==null&&a=0)}function mE(t,s){if(t.width==0)return t;let r=s?t.left:t.right;return{top:t.top,bottom:t.bottom,left:r,right:r}}function kme(t,s){if(t.height==0)return t;let r=s?t.top:t.bottom;return{top:r,bottom:r,left:t.left,right:t.right}}function KHe(t,s,r){let n=t.state,a=t.root.activeElement;n!=s&&t.updateState(s),a!=t.dom&&t.focus();try{return r()}finally{n!=s&&t.updateState(n),a!=t.dom&&a&&a.focus()}}function ZMt(t,s,r){let n=s.selection,a=r=="up"?n.$from:n.$to;return KHe(t,s,()=>{let{node:o}=t.docView.domFromPos(a.pos,r=="up"?-1:1);for(;;){let i=t.docView.nearestDesc(o,!0);if(!i)break;if(i.node.isBlock){o=i.contentDOM||i.dom;break}o=i.dom.parentNode}let l=GHe(t,a.pos,1);for(let i=o.firstChild;i;i=i.nextSibling){let d;if(i.nodeType==1)d=i.getClientRects();else if(i.nodeType==3)d=c0(i,0,i.nodeValue.length).getClientRects();else continue;for(let u=0;up.top+1&&(r=="up"?l.top-p.top>(p.bottom-l.top)*2:p.bottom-l.bottom>(l.bottom-p.top)*2))return!1}}return!0})}const YMt=/[\u0590-\u08ac]/;function XMt(t,s,r){let{$head:n}=s.selection;if(!n.parent.isTextblock)return!1;let a=n.parentOffset,o=!a,l=a==n.parent.content.size,i=t.domSelection();return i?!YMt.test(n.parent.textContent)||!i.modify?r=="left"||r=="backward"?o:l:KHe(t,s,()=>{let{focusNode:d,focusOffset:u,anchorNode:p,anchorOffset:f}=t.domSelectionRange(),y=i.caretBidiLevel;i.modify("move",r,"character");let _=n.depth?t.docView.domAfterPos(n.before()):t.dom,{focusNode:b,focusOffset:w}=t.domSelectionRange(),j=b&&!_.contains(b.nodeType==1?b:b.parentNode)||d==b&&u==w;try{i.collapse(p,f),d&&(d!=p||u!=f)&&i.extend&&i.extend(d,u)}catch{}return y!=null&&(i.caretBidiLevel=y),j}):n.pos==n.start()||n.pos==n.end()}let MTe=null,TTe=null,ATe=!1;function QMt(t,s,r){return MTe==s&&TTe==r?ATe:(MTe=s,TTe=r,ATe=r=="up"||r=="down"?ZMt(t,s,r):XMt(t,s,r))}const kf=0,ETe=1,FN=2,uy=3;class GL{constructor(s,r,n,a){this.parent=s,this.children=r,this.dom=n,this.contentDOM=a,this.dirty=kf,n.pmViewDesc=this}matchesWidget(s){return!1}matchesMark(s){return!1}matchesNode(s,r,n){return!1}matchesHack(s){return!1}parseRule(){return null}stopEvent(s){return!1}get size(){let s=0;for(let r=0;rLu(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=s.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(r==0)for(let o=s;;o=o.parentNode){if(o==this.dom){a=!1;break}if(o.previousSibling)break}if(a==null&&r==s.childNodes.length)for(let o=s;;o=o.parentNode){if(o==this.dom){a=!0;break}if(o.nextSibling)break}}return a??n>0?this.posAtEnd:this.posAtStart}nearestDesc(s,r=!1){for(let n=!0,a=s;a;a=a.parentNode){let o=this.getDesc(a),l;if(o&&(!r||o.node))if(n&&(l=o.nodeDOM)&&!(l.nodeType==1?l.contains(s.nodeType==1?s:s.parentNode):l==s))n=!1;else return o}}getDesc(s){let r=s.pmViewDesc;for(let n=r;n;n=n.parent)if(n==this)return r}posFromDOM(s,r,n){for(let a=s;a;a=a.parentNode){let o=this.getDesc(a);if(o)return o.localPosFromDOM(s,r,n)}return-1}descAt(s){for(let r=0,n=0;rs||l instanceof YHe){a=s-o;break}o=i}if(a)return this.children[n].domFromPos(a-this.children[n].border,r);for(let o;n&&!(o=this.children[n-1]).size&&o instanceof ZHe&&o.side>=0;n--);if(r<=0){let o,l=!0;for(;o=n?this.children[n-1]:null,!(!o||o.dom.parentNode==this.contentDOM);n--,l=!1);return o&&r&&l&&!o.border&&!o.domAtom?o.domFromPos(o.size,r):{node:this.contentDOM,offset:o?Lu(o.dom)+1:0}}else{let o,l=!0;for(;o=n=p&&r<=u-d.border&&d.node&&d.contentDOM&&this.contentDOM.contains(d.contentDOM))return d.parseRange(s,r,p);s=l;for(let f=i;f>0;f--){let y=this.children[f-1];if(y.size&&y.dom.parentNode==this.contentDOM&&!y.emptyChildAt(1)){a=Lu(y.dom)+1;break}s-=y.size}a==-1&&(a=0)}if(a>-1&&(u>r||i==this.children.length-1)){r=u;for(let p=i+1;pb&&lr){let b=i;i=d,d=b}let _=document.createRange();_.setEnd(d.node,d.offset),_.setStart(i.node,i.offset),u.removeAllRanges(),u.addRange(_)}}ignoreMutation(s){return!this.contentDOM&&s.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(s,r){for(let n=0,a=0;a=n:sn){let i=n+o.border,d=l-o.border;if(s>=i&&r<=d){this.dirty=s==n||r==l?FN:ETe,s==i&&r==d&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=uy:o.markDirty(s-i,r-i);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?FN:uy}n=l}this.dirty=FN}markParentsDirty(){let s=1;for(let r=this.parent;r;r=r.parent,s++){let n=s==1?FN:ETe;r.dirty{if(!o)return a;if(o.parent)return o.parent.posBeforeChild(o)})),!r.type.spec.raw){if(l.nodeType!=1){let i=document.createElement("span");i.appendChild(l),l=i}l.contentEditable="false",l.classList.add("ProseMirror-widget")}super(s,[],l,null),this.widget=r,this.widget=r,o=this}matchesWidget(s){return this.dirty==kf&&s.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(s){let r=this.widget.spec.stopEvent;return r?r(s):!1}ignoreMutation(s){return s.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class JMt extends GL{constructor(s,r,n,a){super(s,[],r,null),this.textDOM=n,this.text=a}get size(){return this.text.length}localPosFromDOM(s,r){return s!=this.textDOM?this.posAtStart+(r?this.size:0):this.posAtStart+r}domFromPos(s){return{node:this.textDOM,offset:s}}ignoreMutation(s){return s.type==="characterData"&&s.target.nodeValue==s.oldValue}}class Vk extends GL{constructor(s,r,n,a,o){super(s,[],n,a),this.mark=r,this.spec=o}static create(s,r,n,a){let o=a.nodeViews[r.type.name],l=o&&o(r,a,n);return(!l||!l.dom)&&(l=dS.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new Vk(s,r,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&uy||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(s){return this.dirty!=uy&&this.mark.eq(s)}markDirty(s,r){if(super.markDirty(s,r),this.dirty!=kf){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(o=$xe(o,0,s,n));for(let i=0;i{if(!d)return l;if(d.parent)return d.parent.posBeforeChild(d)},n,a),p=u&&u.dom,f=u&&u.contentDOM;if(r.isText){if(!p)p=document.createTextNode(r.text);else if(p.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else p||({dom:p,contentDOM:f}=dS.renderSpec(document,r.type.spec.toDOM(r),null,r.attrs));!f&&!r.isText&&p.nodeName!="BR"&&(p.hasAttribute("contenteditable")||(p.contentEditable="false"),r.type.spec.draggable&&(p.draggable=!0));let y=p;return p=JHe(p,n,r),u?d=new eTt(s,r,n,a,p,f||null,y,u,o,l+1):r.isText?new ble(s,r,n,a,p,y,o):new w_(s,r,n,a,p,f||null,y,o,l+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let s={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(s.preserveWhitespace="full"),!this.contentDOM)s.getContent=()=>this.node.content;else if(!this.contentLost)s.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let n=this.children[r];if(this.dom.contains(n.dom.parentNode)){s.contentElement=n.dom.parentNode;break}}s.contentElement||(s.getContent=()=>Tr.empty)}return s}matchesNode(s,r,n){return this.dirty==kf&&s.eq(this.node)&&tae(r,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(s,r){let n=this.node.inlineContent,a=r,o=s.composing?this.localCompositionInfo(s,r):null,l=o&&o.pos>-1?o:null,i=o&&o.pos<0,d=new sTt(this,l&&l.node,s);aTt(this.node,this.innerDeco,(u,p,f)=>{u.spec.marks?d.syncToMarks(u.spec.marks,n,s):u.type.side>=0&&!f&&d.syncToMarks(p==this.node.childCount?pl.none:this.node.child(p).marks,n,s),d.placeWidget(u,s,a)},(u,p,f,y)=>{d.syncToMarks(u.marks,n,s);let _;d.findNodeMatch(u,p,f,y)||i&&s.state.selection.from>a&&s.state.selection.to-1&&d.updateNodeAt(u,p,f,_,s)||d.updateNextNode(u,p,f,s,y,a)||d.addNode(u,p,f,s,a),a+=u.nodeSize}),d.syncToMarks([],n,s),this.node.isTextblock&&d.addTextblockHacks(),d.destroyRest(),(d.changed||this.dirty==FN)&&(l&&this.protectLocalComposition(s,l),XHe(this.contentDOM,this.children,s),E3&&iTt(this.dom))}localCompositionInfo(s,r){let{from:n,to:a}=s.state.selection;if(!(s.state.selection instanceof qa)||nr+this.node.content.size)return null;let o=s.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let l=o.nodeValue,i=oTt(this.node.content,l,n-r,a-r);return i<0?null:{node:o,pos:i,text:l}}else return{node:o,pos:-1,text:""}}protectLocalComposition(s,{node:r,pos:n,text:a}){if(this.getDesc(r))return;let o=r;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let l=new JMt(this,o,r,a);s.input.compositionNodes.push(l),this.children=$xe(this.children,n,n+a.length,s,l)}update(s,r,n,a){return this.dirty==uy||!s.sameMarkup(this.node)?!1:(this.updateInner(s,r,n,a),!0)}updateInner(s,r,n,a){this.updateOuterDeco(r),this.node=s,this.innerDeco=n,this.contentDOM&&this.updateChildren(a,this.posAtStart),this.dirty=kf}updateOuterDeco(s){if(tae(s,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=QHe(this.dom,this.nodeDOM,Bxe(this.outerDeco,this.node,r),Bxe(s,this.node,r)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=s}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function PTe(t,s,r,n,a){JHe(n,s,t);let o=new w_(void 0,t,s,r,n,n,n,a,0);return o.contentDOM&&o.updateChildren(a,0),o}class ble extends w_{constructor(s,r,n,a,o,l,i){super(s,r,n,a,o,null,l,i,0)}parseRule(){let s=this.nodeDOM.parentNode;for(;s&&s!=this.dom&&!s.pmIsDeco;)s=s.parentNode;return{skip:s||!0}}update(s,r,n,a){return this.dirty==uy||this.dirty!=kf&&!this.inParent()||!s.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=kf||s.text!=this.node.text)&&s.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=s.text,a.trackWrites==this.nodeDOM&&(a.trackWrites=null)),this.node=s,this.dirty=kf,!0)}inParent(){let s=this.parent.contentDOM;for(let r=this.nodeDOM;r;r=r.parentNode)if(r==s)return!0;return!1}domFromPos(s){return{node:this.nodeDOM,offset:s}}localPosFromDOM(s,r,n){return s==this.nodeDOM?this.posAtStart+Math.min(r,this.node.text.length):super.localPosFromDOM(s,r,n)}ignoreMutation(s){return s.type!="characterData"&&s.type!="selection"}slice(s,r,n){let a=this.node.cut(s,r),o=document.createTextNode(a.text);return new ble(this.parent,a,this.outerDeco,this.innerDeco,o,o,n)}markDirty(s,r){super.markDirty(s,r),this.dom!=this.nodeDOM&&(s==0||r==this.nodeDOM.nodeValue.length)&&(this.dirty=uy)}get domAtom(){return!1}isText(s){return this.node.text==s}}class YHe extends GL{parseRule(){return{ignore:!0}}matchesHack(s){return this.dirty==kf&&this.dom.nodeName==s}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class eTt extends w_{constructor(s,r,n,a,o,l,i,d,u,p){super(s,r,n,a,o,l,i,u,p),this.spec=d}update(s,r,n,a){if(this.dirty==uy)return!1;if(this.spec.update&&(this.node.type==s.type||this.spec.multiType)){let o=this.spec.update(s,r,n);return o&&this.updateInner(s,r,n,a),o}else return!this.contentDOM&&!s.isLeaf?!1:super.update(s,r,n,a)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(s,r,n,a){this.spec.setSelection?this.spec.setSelection(s,r,n.root):super.setSelection(s,r,n,a)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(s){return this.spec.stopEvent?this.spec.stopEvent(s):!1}ignoreMutation(s){return this.spec.ignoreMutation?this.spec.ignoreMutation(s):super.ignoreMutation(s)}}function XHe(t,s,r){let n=t.firstChild,a=!1;for(let o=0;o>1,l=Math.min(o,s.length);for(;a-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let d=Vk.create(this.top,s[o],r,n);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,o++}}findNodeMatch(s,r,n,a){let o=-1,l;if(a>=this.preMatch.index&&(l=this.preMatch.matches[a-this.preMatch.index]).parent==this.top&&l.matchesNode(s,r,n))o=this.top.children.indexOf(l,this.index);else for(let i=this.index,d=Math.min(this.top.children.length,i+5);i0;){let i;for(;;)if(n){let u=r.children[n-1];if(u instanceof Vk)r=u,n=u.children.length;else{i=u,n--;break}}else{if(r==s)break e;n=r.parent.children.indexOf(r),r=r.parent}let d=i.node;if(d){if(d!=t.child(a-1))break;--a,o.set(i,a),l.push(i)}}return{index:a,matched:o,matches:l.reverse()}}function nTt(t,s){return t.type.side-s.type.side}function aTt(t,s,r,n){let a=s.locals(t),o=0;if(a.length==0){for(let u=0;uo;)i.push(a[l++]);let b=o+y.nodeSize;if(y.isText){let j=b;l!j.inline):i.slice();n(y,w,s.forChild(o,y),_),o=b}}function iTt(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let s=t.style.cssText;t.style.cssText=s+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=s}}function oTt(t,s,r,n){for(let a=0,o=0;a=r){if(o>=n&&d.slice(n-s.length-i,n-i)==s)return n-s.length;let u=i=0&&u+s.length+i>=r)return i+u;if(r==n&&d.length>=n+s.length-i&&d.slice(n-i,n-i+s.length)==s)return n}}return-1}function $xe(t,s,r,n,a){let o=[];for(let l=0,i=0;l=r||p<=s?o.push(d):(ur&&o.push(d.slice(r-u,d.size,n)))}return o}function Sbe(t,s=null){let r=t.domSelectionRange(),n=t.state.doc;if(!r.focusNode)return null;let a=t.docView.nearestDesc(r.focusNode),o=a&&a.size==0,l=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(l<0)return null;let i=n.resolve(l),d,u;if(_le(r)){for(d=l;a&&!a.node;)a=a.parent;let f=a.node;if(a&&f.isAtom&&La.isSelectable(f)&&a.parent&&!(f.isInline&&LMt(r.focusNode,r.focusOffset,a.dom))){let y=a.posBefore;u=new La(l==y?i:n.resolve(y))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let f=l,y=l;for(let _=0;_{(r.anchorNode!=n||r.anchorOffset!=a)&&(s.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!eWe(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function cTt(t){let s=t.domSelection();if(!s)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?s.collapse(r.parentNode,Lu(r)+1):s.collapse(r,0),!n&&!t.state.selection.visible&&zm&&b_<=11&&(r.disabled=!0,r.disabled=!1)}function tWe(t,s){if(s instanceof La){let r=t.docView.descAt(s.from);r!=t.lastSelectedViewDesc&&(RTe(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else RTe(t)}function RTe(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Cbe(t,s,r,n){return t.someProp("createSelectionBetween",a=>a(t,s,r))||qa.between(s,r,n)}function FTe(t){return t.editable&&!t.hasFocus()?!1:sWe(t)}function sWe(t){let s=t.domSelectionRange();if(!s.anchorNode)return!1;try{return t.dom.contains(s.anchorNode.nodeType==3?s.anchorNode.parentNode:s.anchorNode)&&(t.editable||t.dom.contains(s.focusNode.nodeType==3?s.focusNode.parentNode:s.focusNode))}catch{return!1}}function dTt(t){let s=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return Uk(s.node,s.offset,r.anchorNode,r.anchorOffset)}function qxe(t,s){let{$anchor:r,$head:n}=t.selection,a=s>0?r.max(n):r.min(n),o=a.parent.inlineContent?a.depth?t.doc.resolve(s>0?a.after():a.before()):null:a;return o&&ni.findFrom(o,s)}function g1(t,s){return t.dispatch(t.state.tr.setSelection(s).scrollIntoView()),!0}function zTe(t,s,r){let n=t.state.selection;if(n instanceof qa)if(r.indexOf("s")>-1){let{$head:a}=n,o=a.textOffset?null:s<0?a.nodeBefore:a.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let l=t.state.doc.resolve(a.pos+o.nodeSize*(s<0?-1:1));return g1(t,new qa(n.$anchor,l))}else if(n.empty){if(t.endOfTextblock(s>0?"forward":"backward")){let a=qxe(t.state,s);return a&&a instanceof La?g1(t,a):!1}else if(!(tf&&r.indexOf("m")>-1)){let a=n.$head,o=a.textOffset?null:s<0?a.nodeBefore:a.nodeAfter,l;if(!o||o.isText)return!1;let i=s<0?a.pos-o.nodeSize:a.pos;return o.isAtom||(l=t.docView.descAt(i))&&!l.contentDOM?La.isSelectable(o)?g1(t,new La(s<0?t.state.doc.resolve(a.pos-o.nodeSize):a)):WL?g1(t,new qa(t.state.doc.resolve(s<0?i:i+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof La&&n.node.isInline)return g1(t,new qa(s>0?n.$to:n.$from));{let a=qxe(t.state,s);return a?g1(t,a):!1}}}function sae(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function hI(t,s){let r=t.pmViewDesc;return r&&r.size==0&&(s<0||t.nextSibling||t.nodeName!="BR")}function h4(t,s){return s<0?uTt(t):hTt(t)}function uTt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a,o,l=!1;for(Nf&&r.nodeType==1&&n0){if(r.nodeType!=1)break;{let i=r.childNodes[n-1];if(hI(i,-1))a=r,o=--n;else if(i.nodeType==3)r=i,n=r.nodeValue.length;else break}}else{if(rWe(r))break;{let i=r.previousSibling;for(;i&&hI(i,-1);)a=r.parentNode,o=Lu(i),i=i.previousSibling;if(i)r=i,n=sae(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}l?Uxe(t,r,n):a&&Uxe(t,a,o)}function hTt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a=sae(r),o,l;for(;;)if(n{t.state==a&&H0(t)},50)}function BTe(t,s){let r=t.state.doc.resolve(s);if(!(mu||qHe)&&r.parent.inlineContent){let a=t.coordsAtPos(s);if(s>r.start()){let o=t.coordsAtPos(s-1),l=(o.top+o.bottom)/2;if(l>a.top&&l1)return o.lefta.top&&l1)return o.left>a.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function $Te(t,s,r){let n=t.state.selection;if(n instanceof qa&&!n.empty||r.indexOf("s")>-1||tf&&r.indexOf("m")>-1)return!1;let{$from:a,$to:o}=n;if(!a.parent.inlineContent||t.endOfTextblock(s<0?"up":"down")){let l=qxe(t.state,s);if(l&&l instanceof La)return g1(t,l)}if(!a.parent.inlineContent){let l=s<0?a:o,i=n instanceof wp?ni.near(l,s):ni.findFrom(l,s);return i?g1(t,i):!1}return!1}function qTe(t,s){if(!(t.state.selection instanceof qa))return!0;let{$head:r,$anchor:n,empty:a}=t.state.selection;if(!r.sameParent(n))return!0;if(!a)return!1;if(t.endOfTextblock(s>0?"forward":"backward"))return!0;let o=!r.textOffset&&(s<0?r.nodeBefore:r.nodeAfter);if(o&&!o.isText){let l=t.state.tr;return s<0?l.delete(r.pos-o.nodeSize,r.pos):l.delete(r.pos,r.pos+o.nodeSize),t.dispatch(l),!0}return!1}function UTe(t,s,r){t.domObserver.stop(),s.contentEditable=r,t.domObserver.start()}function fTt(t){if(!dh||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:s,focusOffset:r}=t.domSelectionRange();if(s&&s.nodeType==1&&r==0&&s.firstChild&&s.firstChild.contentEditable=="false"){let n=s.firstChild;UTe(t,n,"true"),setTimeout(()=>UTe(t,n,"false"),20)}return!1}function gTt(t){let s="";return t.ctrlKey&&(s+="c"),t.metaKey&&(s+="m"),t.altKey&&(s+="a"),t.shiftKey&&(s+="s"),s}function xTt(t,s){let r=s.keyCode,n=gTt(s);if(r==8||tf&&r==72&&n=="c")return qTe(t,-1)||h4(t,-1);if(r==46&&!s.shiftKey||tf&&r==68&&n=="c")return qTe(t,1)||h4(t,1);if(r==13||r==27)return!0;if(r==37||tf&&r==66&&n=="c"){let a=r==37?BTe(t,t.state.selection.from)=="ltr"?-1:1:-1;return zTe(t,a,n)||h4(t,a)}else if(r==39||tf&&r==70&&n=="c"){let a=r==39?BTe(t,t.state.selection.from)=="ltr"?1:-1:1;return zTe(t,a,n)||h4(t,a)}else{if(r==38||tf&&r==80&&n=="c")return $Te(t,-1,n)||h4(t,-1);if(r==40||tf&&r==78&&n=="c")return fTt(t)||$Te(t,1,n)||h4(t,1);if(n==(tf?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function Mbe(t,s){t.someProp("transformCopied",_=>{s=_(s,t)});let r=[],{content:n,openStart:a,openEnd:o}=s;for(;a>1&&o>1&&n.childCount==1&&n.firstChild.childCount==1;){a--,o--;let _=n.firstChild;r.push(_.type.name,_.attrs!=_.type.defaultAttrs?_.attrs:null),n=_.content}let l=t.someProp("clipboardSerializer")||dS.fromSchema(t.state.schema),i=cWe(),d=i.createElement("div");d.appendChild(l.serializeFragment(n,{document:i}));let u=d.firstChild,p,f=0;for(;u&&u.nodeType==1&&(p=lWe[u.nodeName.toLowerCase()]);){for(let _=p.length-1;_>=0;_--){let b=i.createElement(p[_]);for(;d.firstChild;)b.appendChild(d.firstChild);d.appendChild(b),f++}u=d.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${a} ${o}${f?` -${f}`:""} ${JSON.stringify(r)}`);let y=t.someProp("clipboardTextSerializer",_=>_(s,t))||s.content.textBetween(0,s.content.size,` `);return{dom:d,text:y,slice:s}}function nWe(t,s,r,n,a){let o=a.parent.type.spec.code,l,i;if(!r&&!s)return null;let d=!!s&&(n||o||!r);if(d){if(t.someProp("transformPastedText",y=>{s=y(s,o||n,t)}),o)return i=new fn(Tr.from(t.state.schema.text(s.replace(/\r\n?/g,` `))),0,0),t.someProp("transformPasted",y=>{i=y(i,t,!0)}),i;let f=t.someProp("clipboardTextParser",y=>y(s,a,n,t));if(f)i=f;else{let y=a.marks(),{schema:_}=t.state,b=dS.fromSchema(_);l=document.createElement("div"),s.split(/(?:\r\n?|\n)+/).forEach(w=>{let j=l.appendChild(document.createElement("p"));w&&j.appendChild(b.serializeNode(_.text(w,y)))})}}else t.someProp("transformPastedHTML",f=>{r=f(r,t)}),l=bTt(r),WL&&wTt(l);let u=l&&l.querySelector("[data-pm-slice]"),p=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(p&&p[3])for(let f=+p[3];f>0;f--){let y=l.firstChild;for(;y&&y.nodeType!=1;)y=y.nextSibling;if(!y)break;l=y}if(i||(i=(t.someProp("clipboardParser")||t.someProp("domParser")||cI.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(d||p),context:a,ruleFromNode(y){return y.nodeName=="BR"&&!y.nextSibling&&y.parentNode&&!yTt.test(y.parentNode.nodeName)?{ignore:!0}:null}})),p)i=jTt(VTe(i,+p[1],+p[2]),p[4]);else if(i=fn.maxOpen(vTt(i.content,a),!0),i.openStart||i.openEnd){let f=0,y=0;for(let _=i.content.firstChild;f{i=f(i,t,d)}),i}const yTt=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function vTt(t,s){if(t.childCount<2)return t;for(let r=s.depth;r>=0;r--){let a=s.node(r).contentMatchAt(s.index(r)),o,l=[];if(t.forEach(i=>{if(!l)return;let d=a.findWrapping(i.type),u;if(!d)return l=null;if(u=l.length&&o.length&&iWe(d,o,i,l[l.length-1],0))l[l.length-1]=u;else{l.length&&(l[l.length-1]=oWe(l[l.length-1],o.length));let p=aWe(i,d);l.push(p),a=a.matchType(p.type),o=d}}),l)return Tr.from(l)}return t}function aWe(t,s,r=0){for(let n=s.length-1;n>=r;n--)t=s[n].create(null,Tr.from(t));return t}function iWe(t,s,r,n,a){if(a1&&(o=0),a=r&&(i=s<0?l.contentMatchAt(0).fillBefore(i,o<=a).append(i):i.append(l.contentMatchAt(l.childCount).fillBefore(Tr.empty,!0))),t.replaceChild(s<0?0:t.childCount-1,l.copy(i))}function VTe(t,s,r){return sr})),Cme.createHTML(t)):t}function bTt(t){let s=/^(\s*]*>)*/.exec(t);s&&(t=t.slice(s[0].length));let r=cWe().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t),a;if((a=n&&lWe[n[1].toLowerCase()])&&(t=a.map(o=>"<"+o+">").join("")+t+a.map(o=>"").reverse().join("")),r.innerHTML=_Tt(t),a)for(let o=0;o=0;i-=2){let d=r.nodes[n[i]];if(!d||d.hasRequiredAttrs())break;a=Tr.from(d.create(n[i+1],a)),o++,l++}return new fn(a,o,l)}const Yh={},Xh={},NTt={touchstart:!0,touchmove:!0};class kTt{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function STt(t){for(let s in Yh){let r=Yh[s];t.dom.addEventListener(s,t.input.eventHandlers[s]=n=>{MTt(t,n)&&!Tbe(t,n)&&(t.editable||!(n.type in Xh))&&r(t,n)},NTt[s]?{passive:!0}:void 0)}dh&&t.dom.addEventListener("input",()=>null),Hxe(t)}function G1(t,s){t.input.lastSelectionOrigin=s,t.input.lastSelectionTime=Date.now()}function CTt(t){t.domObserver.stop();for(let s in t.input.eventHandlers)t.dom.removeEventListener(s,t.input.eventHandlers[s]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Hxe(t){t.someProp("handleDOMEvents",s=>{for(let r in s)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>Tbe(t,n))})}function Tbe(t,s){return t.someProp("handleDOMEvents",r=>{let n=r[s.type];return n?n(t,s)||s.defaultPrevented:!1})}function MTt(t,s){if(!s.bubbles)return!0;if(s.defaultPrevented)return!1;for(let r=s.target;r!=t.dom;r=r.parentNode)if(!r||r.nodeType==11||r.pmViewDesc&&r.pmViewDesc.stopEvent(s))return!1;return!0}function TTt(t,s){!Tbe(t,s)&&Yh[s.type]&&(t.editable||!(s.type in Xh))&&Yh[s.type](t,s)}Xh.keydown=(t,s)=>{let r=s;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!uWe(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!(k0&&mu&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),E3&&r.keyCode==13&&!r.ctrlKey&&!r.altKey&&!r.metaKey){let n=Date.now();t.input.lastIOSEnter=n,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==n&&(t.someProp("handleKeyDown",a=>a(t,SN(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||xTt(t,r)?r.preventDefault():G1(t,"key")};Xh.keyup=(t,s)=>{s.keyCode==16&&(t.input.shiftKey=!1)};Xh.keypress=(t,s)=>{let r=s;if(uWe(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||tf&&r.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof qa)||!n.$from.sameParent(n.$to)){let a=String.fromCharCode(r.charCode),o=()=>t.state.tr.insertText(a).scrollIntoView();!/[\r\n]/.test(a)&&!t.someProp("handleTextInput",l=>l(t,n.$from.pos,n.$to.pos,a,o))&&t.dispatch(o()),r.preventDefault()}};function wle(t){return{left:t.clientX,top:t.clientY}}function ATt(t,s){let r=s.x-t.clientX,n=s.y-t.clientY;return r*r+n*n<100}function Abe(t,s,r,n,a){if(n==-1)return!1;let o=t.state.doc.resolve(n);for(let l=o.depth+1;l>0;l--)if(t.someProp(s,i=>l>o.depth?i(t,r,o.nodeAfter,o.before(l),a,!0):i(t,r,o.node(l),o.before(l),a,!1)))return!0;return!1}function q5(t,s,r){if(t.focused||t.focus(),t.state.selection.eq(s))return;let n=t.state.tr.setSelection(s);n.setMeta("pointer",!0),t.dispatch(n)}function ETt(t,s){if(s==-1)return!1;let r=t.state.doc.resolve(s),n=r.nodeAfter;return n&&n.isAtom&&La.isSelectable(n)?(q5(t,new La(r)),!0):!1}function PTt(t,s){if(s==-1)return!1;let r=t.state.selection,n,a;r instanceof La&&(n=r.node);let o=t.state.doc.resolve(s);for(let l=o.depth+1;l>0;l--){let i=l>o.depth?o.nodeAfter:o.node(l);if(La.isSelectable(i)){n&&r.$from.depth>0&&l>=r.$from.depth&&o.before(r.$from.depth+1)==r.$from.pos?a=o.before(r.$from.depth):a=o.before(l);break}}return a!=null?(q5(t,La.create(t.state.doc,a)),!0):!1}function ITt(t,s,r,n,a){return Abe(t,"handleClickOn",s,r,n)||t.someProp("handleClick",o=>o(t,s,n))||(a?PTt(t,r):ETt(t,r))}function LTt(t,s,r,n){return Abe(t,"handleDoubleClickOn",s,r,n)||t.someProp("handleDoubleClick",a=>a(t,s,n))}function DTt(t,s,r,n){return Abe(t,"handleTripleClickOn",s,r,n)||t.someProp("handleTripleClick",a=>a(t,s,n))||OTt(t,r,n)}function OTt(t,s,r){if(r.button!=0)return!1;let n=t.state.doc;if(s==-1)return n.inlineContent?(q5(t,qa.create(n,0,n.content.size)),!0):!1;let a=n.resolve(s);for(let o=a.depth+1;o>0;o--){let l=o>a.depth?a.nodeAfter:a.node(o),i=a.before(o);if(l.inlineContent)q5(t,qa.create(n,i+1,i+1+l.content.size));else if(La.isSelectable(l))q5(t,La.create(n,i));else continue;return!0}}function Ebe(t){return rae(t)}const dWe=tf?"metaKey":"ctrlKey";Yh.mousedown=(t,s)=>{let r=s;t.input.shiftKey=r.shiftKey;let n=Ebe(t),a=Date.now(),o="singleClick";a-t.input.lastClick.time<500&&ATt(r,t.input.lastClick)&&!r[dWe]&&t.input.lastClick.button==r.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:a,x:r.clientX,y:r.clientY,type:o,button:r.button};let l=t.posAtCoords(wle(r));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new RTt(t,l,r,!!n)):(o=="doubleClick"?LTt:DTt)(t,l.pos,l.inside,r)?r.preventDefault():G1(t,"pointer"))};class RTt{constructor(s,r,n,a){this.view=s,this.pos=r,this.event=n,this.flushed=a,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=s.state.doc,this.selectNode=!!n[dWe],this.allowDefault=n.shiftKey;let o,l;if(r.inside>-1)o=s.state.doc.nodeAt(r.inside),l=r.inside;else{let p=s.state.doc.resolve(r.pos);o=p.parent,l=p.depth?p.before():0}const i=a?null:n.target,d=i?s.docView.nearestDesc(i,!0):null;this.target=d&&d.nodeDOM.nodeType==1?d.nodeDOM:null;let{selection:u}=s.state;(n.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||u instanceof La&&u.from<=l&&u.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Nf&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),s.root.addEventListener("mouseup",this.up=this.up.bind(this)),s.root.addEventListener("mousemove",this.move=this.move.bind(this)),G1(s,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>H0(this.view)),this.view.input.mouseDown=null}up(s){if(this.done(),!this.view.dom.contains(s.target))return;let r=this.pos;this.view.state.doc!=this.startDoc&&(r=this.view.posAtCoords(wle(s))),this.updateAllowDefault(s),this.allowDefault||!r?G1(this.view,"pointer"):ITt(this.view,r.pos,r.inside,s,this.selectNode)?s.preventDefault():s.button==0&&(this.flushed||dh&&this.mightDrag&&!this.mightDrag.node.isAtom||mu&&!this.view.state.selection.visible&&Math.min(Math.abs(r.pos-this.view.state.selection.from),Math.abs(r.pos-this.view.state.selection.to))<=2)?(q5(this.view,ni.near(this.view.state.doc.resolve(r.pos))),s.preventDefault()):G1(this.view,"pointer")}move(s){this.updateAllowDefault(s),G1(this.view,"pointer"),s.buttons==0&&this.done()}updateAllowDefault(s){!this.allowDefault&&(Math.abs(this.event.x-s.clientX)>4||Math.abs(this.event.y-s.clientY)>4)&&(this.allowDefault=!0)}}Yh.touchstart=t=>{t.input.lastTouch=Date.now(),Ebe(t),G1(t,"pointer")};Yh.touchmove=t=>{t.input.lastTouch=Date.now(),G1(t,"pointer")};Yh.contextmenu=t=>Ebe(t);function uWe(t,s){return t.composing?!0:dh&&Math.abs(s.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const FTt=k0?5e3:-1;Xh.compositionstart=Xh.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:s}=t,r=s.selection.$to;if(s.selection instanceof qa&&(s.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||mu&&qHe&&zTt(t)))t.markCursor=t.state.storedMarks||r.marks(),rae(t,!0),t.markCursor=null;else if(rae(t,!s.selection.empty),Nf&&s.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let n=t.domSelectionRange();for(let a=n.focusNode,o=n.focusOffset;a&&a.nodeType==1&&o!=0;){let l=o<0?a.lastChild:a.childNodes[o-1];if(!l)break;if(l.nodeType==3){let i=t.domSelection();i&&i.collapse(l,l.nodeValue.length);break}else a=l,o=-1}}t.input.composing=!0}hWe(t,FTt)};function zTt(t){let{focusNode:s,focusOffset:r}=t.domSelectionRange();if(!s||s.nodeType!=1||r>=s.childNodes.length)return!1;let n=s.childNodes[r];return n.nodeType==1&&n.contentEditable=="false"}Xh.compositionend=(t,s)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=s.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,hWe(t,20))};function hWe(t,s){clearTimeout(t.input.composingTimeout),s>-1&&(t.input.composingTimeout=setTimeout(()=>rae(t),s))}function mWe(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=$Tt());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function BTt(t){let s=t.domSelectionRange();if(!s.focusNode)return null;let r=PMt(s.focusNode,s.focusOffset),n=IMt(s.focusNode,s.focusOffset);if(r&&n&&r!=n){let a=n.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(r==o||n==o)return o;if(!a||!a.isText(n.nodeValue))return n;if(t.input.compositionNode==n){let l=r.pmViewDesc;if(!(!l||!l.isText(r.nodeValue)))return n}}return r||n}function $Tt(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function rae(t,s=!1){if(!(k0&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),mWe(t),s||t.docView&&t.docView.dirty){let r=Sbe(t),n=t.state.selection;return r&&!r.eq(n)?t.dispatch(t.state.tr.setSelection(r)):(t.markCursor||s)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function qTt(t,s){if(!t.dom.parentNode)return;let r=t.dom.parentNode.appendChild(document.createElement("div"));r.appendChild(s),r.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),a=document.createRange();a.selectNodeContents(s),t.dom.blur(),n.removeAllRanges(),n.addRange(a),setTimeout(()=>{r.parentNode&&r.parentNode.removeChild(r),t.focus()},50)}const x6=zm&&b_<15||E3&&RMt<604;Yh.copy=Xh.cut=(t,s)=>{let r=s,n=t.state.selection,a=r.type=="cut";if(n.empty)return;let o=x6?null:r.clipboardData,l=n.content(),{dom:i,text:d}=Mbe(t,l);o?(r.preventDefault(),o.clearData(),o.setData("text/html",i.innerHTML),o.setData("text/plain",d)):qTt(t,i),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function UTt(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function VTt(t,s){if(!t.dom.parentNode)return;let r=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,n=t.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));r||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let a=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),n.parentNode&&n.parentNode.removeChild(n),r?y6(t,n.value,null,a,s):y6(t,n.textContent,n.innerHTML,a,s)},50)}function y6(t,s,r,n,a){let o=nWe(t,s,r,n,t.state.selection.$from);if(t.someProp("handlePaste",d=>d(t,a,o||fn.empty)))return!0;if(!o)return!1;let l=UTt(o),i=l?t.state.tr.replaceSelectionWith(l,n):t.state.tr.replaceSelection(o);return t.dispatch(i.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function pWe(t){let s=t.getData("text/plain")||t.getData("Text");if(s)return s;let r=t.getData("text/uri-list");return r?r.replace(/\r?\n/g," "):""}Xh.paste=(t,s)=>{let r=s;if(t.composing&&!k0)return;let n=x6?null:r.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&y6(t,pWe(n),n.getData("text/html"),a,r)?r.preventDefault():VTt(t,r)};class fWe{constructor(s,r,n){this.slice=s,this.move=r,this.node=n}}const HTt=tf?"altKey":"ctrlKey";function gWe(t,s){let r=t.someProp("dragCopies",n=>!n(s));return r??!s[HTt]}Yh.dragstart=(t,s)=>{let r=s,n=t.input.mouseDown;if(n&&n.done(),!r.dataTransfer)return;let a=t.state.selection,o=a.empty?null:t.posAtCoords(wle(r)),l;if(!(o&&o.pos>=a.from&&o.pos<=(a instanceof La?a.to-1:a.to))){if(n&&n.mightDrag)l=La.create(t.state.doc,n.mightDrag.pos);else if(r.target&&r.target.nodeType==1){let f=t.docView.nearestDesc(r.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(l=La.create(t.state.doc,f.posBefore))}}let i=(l||t.state.selection).content(),{dom:d,text:u,slice:p}=Mbe(t,i);(!r.dataTransfer.files.length||!mu||$He>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(x6?"Text":"text/html",d.innerHTML),r.dataTransfer.effectAllowed="copyMove",x6||r.dataTransfer.setData("text/plain",u),t.dragging=new fWe(p,gWe(t,r),l)};Yh.dragend=t=>{let s=t.dragging;window.setTimeout(()=>{t.dragging==s&&(t.dragging=null)},50)};Xh.dragover=Xh.dragenter=(t,s)=>s.preventDefault();Xh.drop=(t,s)=>{try{WTt(t,s,t.dragging)}finally{t.dragging=null}};function WTt(t,s,r){if(!s.dataTransfer)return;let n=t.posAtCoords(wle(s));if(!n)return;let a=t.state.doc.resolve(n.pos),o=r&&r.slice;o?t.someProp("transformPasted",_=>{o=_(o,t,!1)}):o=nWe(t,pWe(s.dataTransfer),x6?null:s.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&gWe(t,s));if(t.someProp("handleDrop",_=>_(t,s,o||fn.empty,l))){s.preventDefault();return}if(!o)return;s.preventDefault();let i=o?PHe(t.state.doc,a.pos,o):a.pos;i==null&&(i=a.pos);let d=t.state.tr;if(l){let{node:_}=r;_?_.replace(d):d.deleteSelection()}let u=d.mapping.map(i),p=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=d.doc;if(p?d.replaceRangeWith(u,u,o.content.firstChild):d.replaceRange(u,u,o),d.doc.eq(f))return;let y=d.doc.resolve(u);if(p&&La.isSelectable(o.content.firstChild)&&y.nodeAfter&&y.nodeAfter.sameMarkup(o.content.firstChild))d.setSelection(new La(y));else{let _=d.mapping.map(i);d.mapping.maps[d.mapping.maps.length-1].forEach((b,w,j,k)=>_=k),d.setSelection(Cbe(t,y,d.doc.resolve(_)))}t.focus(),t.dispatch(d.setMeta("uiEvent","drop"))}Yh.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&H0(t)},20))};Yh.blur=(t,s)=>{let r=s;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),r.relatedTarget&&t.dom.contains(r.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Yh.beforeinput=(t,s)=>{if(mu&&k0&&s.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:n}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=n||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,SN(8,"Backspace")))))return;let{$cursor:a}=t.state.selection;a&&a.pos>0&&t.dispatch(t.state.tr.delete(a.pos-1,a.pos).scrollIntoView())},50)}};for(let t in Xh)Yh[t]=Xh[t];function v6(t,s){if(t==s)return!0;for(let r in t)if(t[r]!==s[r])return!1;for(let r in s)if(!(r in t))return!1;return!0}class nae{constructor(s,r){this.toDOM=s,this.spec=r||bk,this.side=this.spec.side||0}map(s,r,n,a){let{pos:o,deleted:l}=s.mapResult(r.from+a,this.side<0?-1:1);return l?null:new Fh(o-n,o-n,this)}valid(){return!0}eq(s){return this==s||s instanceof nae&&(this.spec.key&&this.spec.key==s.spec.key||this.toDOM==s.toDOM&&v6(this.spec,s.spec))}destroy(s){this.spec.destroy&&this.spec.destroy(s)}}class j_{constructor(s,r){this.attrs=s,this.spec=r||bk}map(s,r,n,a){let o=s.map(r.from+a,this.spec.inclusiveStart?-1:1)-n,l=s.map(r.to+a,this.spec.inclusiveEnd?1:-1)-n;return o>=l?null:new Fh(o,l,this)}valid(s,r){return r.from=s&&(!o||o(i.spec))&&n.push(i.copy(i.from+a,i.to+a))}for(let l=0;ls){let i=this.children[l]+1;this.children[l+2].findInner(s-i,r-i,n,a+i,o)}}map(s,r,n){return this==Yu||s.maps.length==0?this:this.mapInner(s,r,0,0,n||bk)}mapInner(s,r,n,a,o){let l;for(let i=0;i{let u=d+n,p;if(p=yWe(r,i,u)){for(a||(a=this.children.slice());oi&&f.to=s){this.children[i]==s&&(n=this.children[i+2]);break}let o=s+1,l=o+r.content.size;for(let i=0;io&&d.type instanceof j_){let u=Math.max(o,d.from)-o,p=Math.min(l,d.to)-o;ua.map(s,r,bk));return k1.from(n)}forChild(s,r){if(r.isLeaf)return $c.empty;let n=[];for(let a=0;ar instanceof $c)?s:s.reduce((r,n)=>r.concat(n instanceof $c?n:n.members),[]))}}forEachSet(s){for(let r=0;r{let j=w-b-(_-y);for(let k=0;kS+p-f)continue;let T=i[k]+p-f;_>=T?i[k+1]=y<=T?-2:-1:y>=p&&j&&(i[k]+=j,i[k+1]+=j)}f+=j}),p=r.maps[u].map(p,-1)}let d=!1;for(let u=0;u=n.content.size){d=!0;continue}let y=r.map(t[u+1]+o,-1),_=y-a,{index:b,offset:w}=n.content.findIndex(f),j=n.maybeChild(b);if(j&&w==f&&w+j.nodeSize==_){let k=i[u+2].mapInner(r,j,p+1,t[u]+o+1,l);k!=Yu?(i[u]=f,i[u+1]=_,i[u+2]=k):(i[u+1]=-2,d=!0)}else d=!0}if(d){let u=KTt(i,t,s,r,a,o,l),p=aae(u,n,0,l);s=p.local;for(let f=0;fr&&l.to{let u=yWe(t,i,d+r);if(u){o=!0;let p=aae(u,i,r+d+1,n);p!=Yu&&a.push(d,d+i.nodeSize,p)}});let l=xWe(o?vWe(t):t,-r).sort(wk);for(let i=0;i0;)s++;t.splice(s,0,r)}function Mme(t){let s=[];return t.someProp("decorations",r=>{let n=r(t.state);n&&n!=Yu&&s.push(n)}),t.cursorWrapper&&s.push($c.create(t.state.doc,[t.cursorWrapper.deco])),k1.from(s)}const ZTt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},YTt=zm&&b_<=11;class XTt{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(s){this.anchorNode=s.anchorNode,this.anchorOffset=s.anchorOffset,this.focusNode=s.focusNode,this.focusOffset=s.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(s){return s.anchorNode==this.anchorNode&&s.anchorOffset==this.anchorOffset&&s.focusNode==this.focusNode&&s.focusOffset==this.focusOffset}}class QTt{constructor(s,r){this.view=s,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new XTt,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let a=0;aa.type=="childList"&&a.removedNodes.length||a.type=="characterData"&&a.oldValue.length>a.target.nodeValue.length)?this.flushSoon():this.flush()}),YTt&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,ZTt)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let s=this.observer.takeRecords();if(s.length){for(let r=0;rthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(FTe(this.view)){if(this.suppressingSelectionUpdates)return H0(this.view);if(zm&&b_<=11&&!this.view.state.selection.empty){let s=this.view.domSelectionRange();if(s.focusNode&&Uk(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(s){if(!s.focusNode)return!0;let r=new Set,n;for(let o=s.focusNode;o;o=A3(o))r.add(o);for(let o=s.anchorNode;o;o=A3(o))if(r.has(o)){n=o;break}let a=n&&this.view.docView.nearestDesc(n);if(a&&a.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let s of this.observer.takeRecords())this.queue.push(s);return this.queue}flush(){let{view:s}=this;if(!s.docView||this.flushingSoon>-1)return;let r=this.pendingRecords();r.length&&(this.queue=[]);let n=s.domSelectionRange(),a=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&FTe(s)&&!this.ignoreSelectionChange(n),o=-1,l=-1,i=!1,d=[];if(s.editable)for(let p=0;pf.nodeName=="BR");if(p.length==2){let[f,y]=p;f.parentNode&&f.parentNode.parentNode==y.parentNode?y.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let y of p){let _=y.parentNode;_&&_.nodeName=="LI"&&(!f||tAt(s,f)!=_)&&y.remove()}}}else if((mu||dh)&&d.some(p=>p.nodeName=="BR")&&(s.input.lastKeyCode==8||s.input.lastKeyCode==46)){for(let p of d)if(p.nodeName=="BR"&&p.parentNode){let f=p.nextSibling;f&&f.nodeType==1&&f.contentEditable=="false"&&p.parentNode.removeChild(p)}}let u=null;o<0&&a&&s.input.lastFocus>Date.now()-200&&Math.max(s.input.lastTouch,s.input.lastClick.time)-1||a)&&(o>-1&&(s.docView.markDirty(o,l),JTt(s)),this.handleDOMChange(o,l,i,d),s.docView&&s.docView.dirty?s.updateState(s.state):this.currentSelection.eq(n)||H0(s),this.currentSelection.set(n))}registerMutation(s,r){if(r.indexOf(s.target)>-1)return null;let n=this.view.docView.nearestDesc(s.target);if(s.type=="attributes"&&(n==this.view.docView||s.attributeName=="contenteditable"||s.attributeName=="style"&&!s.oldValue&&!s.target.getAttribute("style"))||!n||n.ignoreMutation(s))return null;if(s.type=="childList"){for(let p=0;pa;j--){let k=n.childNodes[j-1],S=k.pmViewDesc;if(k.nodeName=="BR"&&!S){o=j;break}if(!S||S.size)break}let f=t.state.doc,y=t.someProp("domParser")||cI.fromSchema(t.state.schema),_=f.resolve(l),b=null,w=y.parse(n,{topNode:_.parent,topMatch:_.parent.contentMatchAt(_.index()),topOpen:!0,from:a,to:o,preserveWhitespace:_.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:rAt,context:_});if(u&&u[0].pos!=null){let j=u[0].pos,k=u[1]&&u[1].pos;k==null&&(k=j),b={anchor:j+l,head:k+l}}return{doc:w,sel:b,from:l,to:i}}function rAt(t){let s=t.pmViewDesc;if(s)return s.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(dh&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(t.parentNode.lastChild==t||dh&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const nAt=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function aAt(t,s,r,n,a){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,s<0){let $=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,q=Sbe(t,$);if(q&&!t.state.selection.eq(q)){if(mu&&k0&&t.input.lastKeyCode===13&&Date.now()-100H(t,SN(13,"Enter"))))return;let U=t.state.tr.setSelection(q);$=="pointer"?U.setMeta("pointer",!0):$=="key"&&U.scrollIntoView(),o&&U.setMeta("composition",o),t.dispatch(U)}return}let l=t.state.doc.resolve(s),i=l.sharedDepth(r);s=l.before(i+1),r=t.state.doc.resolve(r).after(i+1);let d=t.state.selection,u=sAt(t,s,r),p=t.state.doc,f=p.slice(u.from,u.to),y,_;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||k0)&&a.some($=>$.nodeType==1&&!nAt.test($.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",$=>$(t,SN(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(n&&d instanceof qa&&!d.empty&&d.$head.sameParent(d.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))b={start:d.from,endA:d.to,endB:d.to};else{if(u.sel){let $=YTe(t,t.state.doc,u.sel);if($&&!$.eq(t.state.selection)){let q=t.state.tr.setSelection($);o&&q.setMeta("composition",o),t.dispatch(q)}}return}t.state.selection.fromt.state.selection.from&&b.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?b.start=t.state.selection.from:b.endA=t.state.selection.to-2&&t.state.selection.to<=u.to&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),zm&&b_<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>u.from&&u.doc.textBetween(b.start-u.from-1,b.start-u.from+1)=="  "&&(b.start--,b.endA--,b.endB--);let w=u.doc.resolveNoCache(b.start-u.from),j=u.doc.resolveNoCache(b.endB-u.from),k=p.resolve(b.start),S=w.sameParent(j)&&w.parent.inlineContent&&k.end()>=b.endA;if((E3&&t.input.lastIOSEnter>Date.now()-225&&(!S||a.some($=>$.nodeName=="DIV"||$.nodeName=="P"))||!S&&w.pos$(t,SN(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&oAt(p,b.start,b.endA,w,j)&&t.someProp("handleKeyDown",$=>$(t,SN(8,"Backspace")))){k0&&mu&&t.domObserver.suppressSelectionUpdates();return}mu&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),k0&&!S&&w.start()!=j.start()&&j.parentOffset==0&&w.depth==j.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==b.endA&&(b.endB-=2,j=u.doc.resolveNoCache(b.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function($){return $(t,SN(13,"Enter"))})},20));let T=b.start,I=b.endA,L=$=>{let q=$||t.state.tr.replace(T,I,u.doc.slice(b.start-u.from,b.endB-u.from));if(u.sel){let U=YTe(t,q.doc,u.sel);U&&!(mu&&t.composing&&U.empty&&(b.start!=b.endB||t.input.lastChromeDeleteH0(t),20));let $=L(t.state.tr.delete(T,I)),q=p.resolve(b.start).marksAcross(p.resolve(b.endA));q&&$.ensureMarks(q),t.dispatch($)}else if(b.endA==b.endB&&(R=iAt(w.parent.content.cut(w.parentOffset,j.parentOffset),k.parent.content.cut(k.parentOffset,b.endA-k.start())))){let $=L(t.state.tr);R.type=="add"?$.addMark(T,I,R.mark):$.removeMark(T,I,R.mark),t.dispatch($)}else if(w.parent.child(w.index()).isText&&w.index()==j.index()-(j.textOffset?0:1)){let $=w.parent.textBetween(w.parentOffset,j.parentOffset),q=()=>L(t.state.tr.insertText($,T,I));t.someProp("handleTextInput",U=>U(t,T,I,$,q))||t.dispatch(q())}else t.dispatch(L());else t.dispatch(L())}function YTe(t,s,r){return Math.max(r.anchor,r.head)>s.content.size?null:Cbe(t,s.resolve(r.anchor),s.resolve(r.head))}function iAt(t,s){let r=t.firstChild.marks,n=s.firstChild.marks,a=r,o=n,l,i,d;for(let p=0;pp.mark(i.addToSet(p.marks));else if(a.length==0&&o.length==1)i=o[0],l="remove",d=p=>p.mark(i.removeFromSet(p.marks));else return null;let u=[];for(let p=0;pr||Tme(l,!0,!1)0&&(s||t.indexAfter(n)==t.node(n).childCount);)n--,a++,s=!1;if(r){let o=t.node(n).maybeChild(t.indexAfter(n));for(;o&&!o.isLeaf;)o=o.firstChild,a++}return a}function lAt(t,s,r,n,a){let o=t.findDiffStart(s,r);if(o==null)return null;let{a:l,b:i}=t.findDiffEnd(s,r+t.size,r+s.size);if(a=="end"){let d=Math.max(0,o-Math.min(l,i));n-=l+d-o}if(l=l?o-n:0;o-=d,o&&o=i?o-n:0;o-=d,o&&o=56320&&s<=57343&&r>=55296&&r<=56319}class _We{constructor(s,r){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new kTt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(sAe),this.dispatch=this.dispatch.bind(this),this.dom=s&&s.mount||document.createElement("div"),s&&(s.appendChild?s.appendChild(this.dom):typeof s=="function"?s(this.dom):s.mount&&(this.mounted=!0)),this.editable=eAe(this),JTe(this),this.nodeViews=tAe(this),this.docView=PTe(this.state.doc,QTe(this),Mme(this),this.dom,this),this.domObserver=new QTt(this,(n,a,o,l)=>aAt(this,n,a,o,l)),this.domObserver.start(),STt(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let s=this._props;this._props={};for(let r in s)this._props[r]=s[r];this._props.state=this.state}return this._props}update(s){s.handleDOMEvents!=this._props.handleDOMEvents&&Hxe(this);let r=this._props;this._props=s,s.plugins&&(s.plugins.forEach(sAe),this.directPlugins=s.plugins),this.updateStateInner(s.state,r)}setProps(s){let r={};for(let n in this._props)r[n]=this._props[n];r.state=this.state;for(let n in s)r[n]=s[n];this.update(r)}updateState(s){this.updateStateInner(s,this._props)}updateStateInner(s,r){var n;let a=this.state,o=!1,l=!1;s.storedMarks&&this.composing&&(mWe(this),l=!0),this.state=s;let i=a.plugins!=s.plugins||this._props.plugins!=r.plugins;if(i||this._props.plugins!=r.plugins||this._props.nodeViews!=r.nodeViews){let _=tAe(this);dAt(_,this.nodeViews)&&(this.nodeViews=_,o=!0)}(i||r.handleDOMEvents!=this._props.handleDOMEvents)&&Hxe(this),this.editable=eAe(this),JTe(this);let d=Mme(this),u=QTe(this),p=a.plugins!=s.plugins&&!a.doc.eq(s.doc)?"reset":s.scrollToSelection>a.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(s.doc,u,d);(f||!s.selection.eq(a.selection))&&(l=!0);let y=p=="preserve"&&l&&this.dom.style.overflowAnchor==null&&BMt(this);if(l){this.domObserver.stop();let _=f&&(zm||mu)&&!this.composing&&!a.selection.empty&&!s.selection.empty&&cAt(a.selection,s.selection);if(f){let b=mu?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=BTt(this)),(o||!this.docView.update(s.doc,u,d,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=PTe(s.doc,u,d,this.dom,this)),b&&!this.trackWrites&&(_=!0)}_||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&dTt(this))?H0(this,_):(tWe(this,s.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(a),!((n=this.dragging)===null||n===void 0)&&n.node&&!a.doc.eq(s.doc)&&this.updateDraggedNode(this.dragging,a),p=="reset"?this.dom.scrollTop=0:p=="to selection"?this.scrollToSelection():y&&$Mt(y)}scrollToSelection(){let s=this.domSelectionRange().focusNode;if(!(!s||!this.dom.contains(s.nodeType==1?s:s.parentNode))){if(!this.someProp("handleScrollToSelection",r=>r(this)))if(this.state.selection instanceof La){let r=this.docView.domAfterPos(this.state.selection.from);r.nodeType==1&&STe(this,r.getBoundingClientRect(),s)}else STe(this,this.coordsAtPos(this.state.selection.head,1),s)}}destroyPluginViews(){let s;for(;s=this.pluginViews.pop();)s.destroy&&s.destroy()}updatePluginViews(s){if(!s||s.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let r=0;r0&&this.state.doc.nodeAt(o))==n.node&&(a=o)}this.dragging=new fWe(s.slice,s.move,a<0?void 0:La.create(this.state.doc,a))}someProp(s,r){let n=this._props&&this._props[s],a;if(n!=null&&(a=r?r(n):n))return a;for(let l=0;lr.ownerDocument.getSelection()),this._root=r}return s||document}updateRoot(){this._root=null}posAtCoords(s){return GMt(this,s)}coordsAtPos(s,r=1){return GHe(this,s,r)}domAtPos(s,r=0){return this.docView.domFromPos(s,r)}nodeDOM(s){let r=this.docView.descAt(s);return r?r.nodeDOM:null}posAtDOM(s,r,n=-1){let a=this.docView.posFromDOM(s,r,n);if(a==null)throw new RangeError("DOM position not inside the editor");return a}endOfTextblock(s,r){return QMt(this,r||this.state,s)}pasteHTML(s,r){return y6(this,"",s,!1,r||new ClipboardEvent("paste"))}pasteText(s,r){return y6(this,s,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(s){return Mbe(this,s)}destroy(){this.docView&&(CTt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Mme(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,AMt())}get isDestroyed(){return this.docView==null}dispatchEvent(s){return TTt(this,s)}domSelectionRange(){let s=this.domSelection();return s?dh&&this.root.nodeType===11&&DMt(this.dom.ownerDocument)==this.dom&&eAt(this,s)||s:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}_We.prototype.dispatch=function(t){let s=this._props.dispatchTransaction;s?s.call(this,t):this.updateState(this.state.apply(t))};function QTe(t){let s=Object.create(null);return s.class="ProseMirror",s.contenteditable=String(t.editable),t.someProp("attributes",r=>{if(typeof r=="function"&&(r=r(t.state)),r)for(let n in r)n=="class"?s.class+=" "+r[n]:n=="style"?s.style=(s.style?s.style+";":"")+r[n]:!s[n]&&n!="contenteditable"&&n!="nodeName"&&(s[n]=String(r[n]))}),s.translate||(s.translate="no"),[Fh.node(0,t.state.doc.content.size,s)]}function JTe(t){if(t.markCursor){let s=document.createElement("img");s.className="ProseMirror-separator",s.setAttribute("mark-placeholder","true"),s.setAttribute("alt",""),t.cursorWrapper={dom:s,deco:Fh.widget(t.state.selection.from,s,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function eAe(t){return!t.someProp("editable",s=>s(t.state)===!1)}function cAt(t,s){let r=Math.min(t.$anchor.sharedDepth(t.head),s.$anchor.sharedDepth(s.head));return t.$anchor.start(r)!=s.$anchor.start(r)}function tAe(t){let s=Object.create(null);function r(n){for(let a in n)Object.prototype.hasOwnProperty.call(s,a)||(s[a]=n[a])}return t.someProp("nodeViews",r),t.someProp("markViews",r),s}function dAt(t,s){let r=0,n=0;for(let a in t){if(t[a]!=s[a])return!0;r++}for(let a in s)n++;return r!=n}function sAe(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var F_={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},iae={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},uAt=typeof navigator<"u"&&/Mac/.test(navigator.platform),hAt=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Du=0;Du<10;Du++)F_[48+Du]=F_[96+Du]=String(Du);for(var Du=1;Du<=24;Du++)F_[Du+111]="F"+Du;for(var Du=65;Du<=90;Du++)F_[Du]=String.fromCharCode(Du+32),iae[Du]=String.fromCharCode(Du);for(var Ame in F_)iae.hasOwnProperty(Ame)||(iae[Ame]=F_[Ame]);function mAt(t){var s=uAt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||hAt&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!s&&t.key||(t.shiftKey?iae:F_)[t.keyCode]||t.key||"Unidentified";return r=="Esc"&&(r="Escape"),r=="Del"&&(r="Delete"),r=="Left"&&(r="ArrowLeft"),r=="Up"&&(r="ArrowUp"),r=="Right"&&(r="ArrowRight"),r=="Down"&&(r="ArrowDown"),r}const pAt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),fAt=typeof navigator<"u"&&/Win/.test(navigator.platform);function gAt(t){let s=t.split(/-(?!$)/),r=s[s.length-1];r=="Space"&&(r=" ");let n,a,o,l;for(let i=0;it.selection.empty?!1:(s&&s(t.tr.deleteSelection().scrollIntoView()),!0);function bWe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const wWe=(t,s,r)=>{let n=bWe(t,r);if(!n)return!1;let a=Obe(n);if(!a){let l=n.blockRange(),i=l&&PM(l);return i==null?!1:(s&&s(t.tr.lift(l,i).scrollIntoView()),!0)}let o=a.nodeBefore;if(EWe(t,a,s,-1))return!0;if(n.parent.content.size==0&&(P3(o,"end")||La.isSelectable(o)))for(let l=n.depth;;l--){let i=yle(t.doc,n.before(l),n.after(l),fn.empty);if(i&&i.slice.size1)break}return o.isAtom&&a.depth==n.depth-1?(s&&s(t.tr.delete(a.pos-o.nodeSize,a.pos).scrollIntoView()),!0):!1},vAt=(t,s,r)=>{let n=bWe(t,r);if(!n)return!1;let a=Obe(n);return a?jWe(t,a,s):!1},_At=(t,s,r)=>{let n=kWe(t,r);if(!n)return!1;let a=Rbe(n);return a?jWe(t,a,s):!1};function jWe(t,s,r){let n=s.nodeBefore,a=n,o=s.pos-1;for(;!a.isTextblock;o--){if(a.type.spec.isolating)return!1;let p=a.lastChild;if(!p)return!1;a=p}let l=s.nodeAfter,i=l,d=s.pos+1;for(;!i.isTextblock;d++){if(i.type.spec.isolating)return!1;let p=i.firstChild;if(!p)return!1;i=p}let u=yle(t.doc,o,d,fn.empty);if(!u||u.from!=o||u instanceof uu&&u.slice.size>=d-o)return!1;if(r){let p=t.tr.step(u);p.setSelection(qa.create(p.doc,o)),r(p.scrollIntoView())}return!0}function P3(t,s,r=!1){for(let n=t;n;n=s=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(r&&n.childCount!=1)return!1}return!1}const NWe=(t,s,r)=>{let{$head:n,empty:a}=t.selection,o=n;if(!a)return!1;if(n.parent.isTextblock){if(r?!r.endOfTextblock("backward",t):n.parentOffset>0)return!1;o=Obe(n)}let l=o&&o.nodeBefore;return!l||!La.isSelectable(l)?!1:(s&&s(t.tr.setSelection(La.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function Obe(t){if(!t.parent.type.spec.isolating)for(let s=t.depth-1;s>=0;s--){if(t.index(s)>0)return t.doc.resolve(t.before(s+1));if(t.node(s).type.spec.isolating)break}return null}function kWe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("forward",t):r.parentOffset{let n=kWe(t,r);if(!n)return!1;let a=Rbe(n);if(!a)return!1;let o=a.nodeAfter;if(EWe(t,a,s,1))return!0;if(n.parent.content.size==0&&(P3(o,"start")||La.isSelectable(o))){let l=yle(t.doc,n.before(),n.after(),fn.empty);if(l&&l.slice.size{let{$head:n,empty:a}=t.selection,o=n;if(!a)return!1;if(n.parent.isTextblock){if(r?!r.endOfTextblock("forward",t):n.parentOffset=0;s--){let r=t.node(s);if(t.index(s)+1{let r=t.selection,n=r instanceof La,a;if(n){if(r.node.isTextblock||!J_(t.doc,r.from))return!1;a=r.from}else if(a=xle(t.doc,r.from,-1),a==null)return!1;if(s){let o=t.tr.join(a);n&&o.setSelection(La.create(o.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),s(o.scrollIntoView())}return!0},wAt=(t,s)=>{let r=t.selection,n;if(r instanceof La){if(r.node.isTextblock||!J_(t.doc,r.to))return!1;n=r.to}else if(n=xle(t.doc,r.to,1),n==null)return!1;return s&&s(t.tr.join(n).scrollIntoView()),!0},jAt=(t,s)=>{let{$from:r,$to:n}=t.selection,a=r.blockRange(n),o=a&&PM(a);return o==null?!1:(s&&s(t.tr.lift(a,o).scrollIntoView()),!0)},MWe=(t,s)=>{let{$head:r,$anchor:n}=t.selection;return!r.parent.type.spec.code||!r.sameParent(n)?!1:(s&&s(t.tr.insertText(` `).scrollIntoView()),!0)};function Fbe(t){for(let s=0;s{let{$head:r,$anchor:n}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(n))return!1;let a=r.node(-1),o=r.indexAfter(-1),l=Fbe(a.contentMatchAt(o));if(!l||!a.canReplaceWith(o,o,l))return!1;if(s){let i=r.after(),d=t.tr.replaceWith(i,i,l.createAndFill());d.setSelection(ni.near(d.doc.resolve(i),1)),s(d.scrollIntoView())}return!0},TWe=(t,s)=>{let r=t.selection,{$from:n,$to:a}=r;if(r instanceof wp||n.parent.inlineContent||a.parent.inlineContent)return!1;let o=Fbe(a.parent.contentMatchAt(a.indexAfter()));if(!o||!o.isTextblock)return!1;if(s){let l=(!n.parentOffset&&a.index(){let{$cursor:r}=t.selection;if(!r||r.parent.content.size)return!1;if(r.depth>1&&r.after()!=r.end(-1)){let o=r.before();if(V0(t.doc,o))return s&&s(t.tr.split(o).scrollIntoView()),!0}let n=r.blockRange(),a=n&&PM(n);return a==null?!1:(s&&s(t.tr.lift(n,a).scrollIntoView()),!0)};function kAt(t){return(s,r)=>{let{$from:n,$to:a}=s.selection;if(s.selection instanceof La&&s.selection.node.isBlock)return!n.parentOffset||!V0(s.doc,n.pos)?!1:(r&&r(s.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let o=[],l,i,d=!1,u=!1;for(let _=n.depth;;_--)if(n.node(_).isBlock){d=n.end(_)==n.pos+(n.depth-_),u=n.start(_)==n.pos-(n.depth-_),i=Fbe(n.node(_-1).contentMatchAt(n.indexAfter(_-1))),o.unshift(d&&i?{type:i}:null),l=_;break}else{if(_==1)return!1;o.unshift(null)}let p=s.tr;(s.selection instanceof qa||s.selection instanceof wp)&&p.deleteSelection();let f=p.mapping.map(n.pos),y=V0(p.doc,f,o.length,o);if(y||(o[0]=i?{type:i}:null,y=V0(p.doc,f,o.length,o)),!y)return!1;if(p.split(f,o.length,o),!d&&u&&n.node(l).type!=i){let _=p.mapping.map(n.before(l)),b=p.doc.resolve(_);i&&n.node(l-1).canReplaceWith(b.index(),b.index()+1,i)&&p.setNodeMarkup(p.mapping.map(n.before(l)),i)}return r&&r(p.scrollIntoView()),!0}}const SAt=kAt(),CAt=(t,s)=>{let{$from:r,to:n}=t.selection,a,o=r.sharedDepth(n);return o==0?!1:(a=r.before(o),s&&s(t.tr.setSelection(La.create(t.doc,a))),!0)};function MAt(t,s,r){let n=s.nodeBefore,a=s.nodeAfter,o=s.index();return!n||!a||!n.type.compatibleContent(a.type)?!1:!n.content.size&&s.parent.canReplace(o-1,o)?(r&&r(t.tr.delete(s.pos-n.nodeSize,s.pos).scrollIntoView()),!0):!s.parent.canReplace(o,o+1)||!(a.isTextblock||J_(t.doc,s.pos))?!1:(r&&r(t.tr.join(s.pos).scrollIntoView()),!0)}function EWe(t,s,r,n){let a=s.nodeBefore,o=s.nodeAfter,l,i,d=a.type.spec.isolating||o.type.spec.isolating;if(!d&&MAt(t,s,r))return!0;let u=!d&&s.parent.canReplace(s.index(),s.index()+1);if(u&&(l=(i=a.contentMatchAt(a.childCount)).findWrapping(o.type))&&i.matchType(l[0]||o.type).validEnd){if(r){let _=s.pos+o.nodeSize,b=Tr.empty;for(let k=l.length-1;k>=0;k--)b=Tr.from(l[k].create(null,b));b=Tr.from(a.copy(b));let w=t.tr.step(new xu(s.pos-1,_,s.pos,_,new fn(b,1,0),l.length,!0)),j=w.doc.resolve(_+2*l.length);j.nodeAfter&&j.nodeAfter.type==a.type&&J_(w.doc,j.pos)&&w.join(j.pos),r(w.scrollIntoView())}return!0}let p=o.type.spec.isolating||n>0&&d?null:ni.findFrom(s,1),f=p&&p.$from.blockRange(p.$to),y=f&&PM(f);if(y!=null&&y>=s.depth)return r&&r(t.tr.lift(f,y).scrollIntoView()),!0;if(u&&P3(o,"start",!0)&&P3(a,"end")){let _=a,b=[];for(;b.push(_),!_.isTextblock;)_=_.lastChild;let w=o,j=1;for(;!w.isTextblock;w=w.firstChild)j++;if(_.canReplace(_.childCount,_.childCount,w.content)){if(r){let k=Tr.empty;for(let T=b.length-1;T>=0;T--)k=Tr.from(b[T].copy(k));let S=t.tr.step(new xu(s.pos-b.length,s.pos+o.nodeSize,s.pos+j,s.pos+o.nodeSize-j,new fn(k,b.length,0),0,!0));r(S.scrollIntoView())}return!0}}return!1}function PWe(t){return function(s,r){let n=s.selection,a=t<0?n.$from:n.$to,o=a.depth;for(;a.node(o).isInline;){if(!o)return!1;o--}return a.node(o).isTextblock?(r&&r(s.tr.setSelection(qa.create(s.doc,t<0?a.start(o):a.end(o)))),!0):!1}}const TAt=PWe(-1),AAt=PWe(1);function EAt(t,s=null){return function(r,n){let{$from:a,$to:o}=r.selection,l=a.blockRange(o),i=l&&wbe(l,t,s);return i?(n&&n(r.tr.wrap(l,i).scrollIntoView()),!0):!1}}function rAe(t,s=null){return function(r,n){let a=!1;for(let o=0;o{if(a)return!1;if(!(!d.isTextblock||d.hasMarkup(t,s)))if(d.type==t)a=!0;else{let p=r.doc.resolve(u),f=p.index();a=p.parent.canReplaceWith(f,f+1,t)}})}if(!a)return!1;if(n){let o=r.tr;for(let l=0;l=2&&s.$from.node(s.depth-1).type.compatibleContent(r)&&s.startIndex==0){if(s.$from.index(s.depth-1)==0)return!1;let d=l.resolve(s.start-2);o=new Jne(d,d,s.depth),s.endIndex=0;p--)o=Tr.from(r[p].type.create(r[p].attrs,o));t.step(new xu(s.start-(n?2:0),s.end,s.start,s.end,new fn(o,0,0),r.length,!0));let l=0;for(let p=0;pl.childCount>0&&l.firstChild.type==t);return o?r?n.node(o.depth-1).type==t?OAt(s,r,t,o):RAt(s,r,o):!0:!1}}function OAt(t,s,r,n){let a=t.tr,o=n.end,l=n.$to.end(n.depth);ow;b--)_-=a.child(b).nodeSize,n.delete(_-1,_+1);let o=n.doc.resolve(r.start),l=o.nodeAfter;if(n.mapping.map(r.end)!=r.start+o.nodeAfter.nodeSize)return!1;let i=r.startIndex==0,d=r.endIndex==a.childCount,u=o.node(-1),p=o.index(-1);if(!u.canReplace(p+(i?0:1),p+1,l.content.append(d?Tr.empty:Tr.from(a))))return!1;let f=o.pos,y=f+l.nodeSize;return n.step(new xu(f-(i?1:0),y+(d?1:0),f+1,y-1,new fn((i?Tr.empty:Tr.from(a.copy(Tr.empty))).append(d?Tr.empty:Tr.from(a.copy(Tr.empty))),i?0:1,d?0:1),i?0:1)),s(n.scrollIntoView()),!0}function FAt(t){return function(s,r){let{$from:n,$to:a}=s.selection,o=n.blockRange(a,u=>u.childCount>0&&u.firstChild.type==t);if(!o)return!1;let l=o.startIndex;if(l==0)return!1;let i=o.parent,d=i.child(l-1);if(d.type!=t)return!1;if(r){let u=d.lastChild&&d.lastChild.type==i.type,p=Tr.from(u?t.create():null),f=new fn(Tr.from(t.create(null,Tr.from(i.type.create(null,p)))),u?3:1,0),y=o.start,_=o.end;r(s.tr.step(new xu(y-(u?3:1),_,y,_,f,1,!0)).scrollIntoView())}return!0}}function jle(t){const{state:s,transaction:r}=t;let{selection:n}=r,{doc:a}=r,{storedMarks:o}=r;return{...s,apply:s.apply.bind(s),applyTransaction:s.applyTransaction.bind(s),plugins:s.plugins,schema:s.schema,reconfigure:s.reconfigure.bind(s),toJSON:s.toJSON.bind(s),get storedMarks(){return o},get selection(){return n},get doc(){return a},get tr(){return n=r.selection,a=r.doc,o=r.storedMarks,r}}}class Nle{constructor(s){this.editor=s.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=s.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:s,editor:r,state:n}=this,{view:a}=r,{tr:o}=n,l=this.buildProps(o);return Object.fromEntries(Object.entries(s).map(([i,d])=>[i,(...p)=>{const f=d(...p)(l);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(o),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(s,r=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i=[],d=!!s,u=s||o.tr,p=()=>(!d&&r&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(u),i.every(y=>y===!0)),f={...Object.fromEntries(Object.entries(n).map(([y,_])=>[y,(...w)=>{const j=this.buildProps(u,r),k=_(...w)(j);return i.push(k),f}])),run:p};return f}createCan(s){const{rawCommands:r,state:n}=this,a=!1,o=s||n.tr,l=this.buildProps(o,a);return{...Object.fromEntries(Object.entries(r).map(([d,u])=>[d,(...p)=>u(...p)({...l,dispatch:void 0})])),chain:()=>this.createChain(o,a)}}buildProps(s,r=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i={tr:s,editor:a,view:l,state:jle({state:o,transaction:s}),dispatch:r?()=>{}:void 0,chain:()=>this.createChain(s,r),can:()=>this.createCan(s),get commands(){return Object.fromEntries(Object.entries(n).map(([d,u])=>[d,(...p)=>u(...p)(i)]))}};return i}}let zAt=class{constructor(){this.callbacks={}}on(s,r){return this.callbacks[s]||(this.callbacks[s]=[]),this.callbacks[s].push(r),this}emit(s,...r){const n=this.callbacks[s];return n&&n.forEach(a=>a.apply(this,r)),this}off(s,r){const n=this.callbacks[s];return n&&(r?this.callbacks[s]=n.filter(a=>a!==r):delete this.callbacks[s]),this}once(s,r){const n=(...a)=>{this.off(s,n),r.apply(this,a)};return this.on(s,n)}removeAllListeners(){this.callbacks={}}};function ea(t,s,r){return t.config[s]===void 0&&t.parent?ea(t.parent,s,r):typeof t.config[s]=="function"?t.config[s].bind({...r,parent:t.parent?ea(t.parent,s,r):null}):t.config[s]}function kle(t){const s=t.filter(a=>a.type==="extension"),r=t.filter(a=>a.type==="node"),n=t.filter(a=>a.type==="mark");return{baseExtensions:s,nodeExtensions:r,markExtensions:n}}function IWe(t){const s=[],{nodeExtensions:r,markExtensions:n}=kle(t),a=[...r,...n],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage,extensions:a},d=ea(l,"addGlobalAttributes",i);if(!d)return;d().forEach(p=>{p.types.forEach(f=>{Object.entries(p.attributes).forEach(([y,_])=>{s.push({type:f,name:y,attribute:{...o,..._}})})})})}),a.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage},d=ea(l,"addAttributes",i);if(!d)return;const u=d();Object.entries(u).forEach(([p,f])=>{const y={...o,...f};typeof(y==null?void 0:y.default)=="function"&&(y.default=y.default()),y!=null&&y.isRequired&&(y==null?void 0:y.default)===void 0&&delete y.default,s.push({type:l.name,name:p,attribute:y})})}),s}function _u(t,s){if(typeof t=="string"){if(!s.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return s.nodes[t]}return t}function Ac(...t){return t.filter(s=>!!s).reduce((s,r)=>{const n={...s};return Object.entries(r).forEach(([a,o])=>{if(!n[a]){n[a]=o;return}if(a==="class"){const i=o?String(o).split(" "):[],d=n[a]?n[a].split(" "):[],u=i.filter(p=>!d.includes(p));n[a]=[...d,...u].join(" ")}else if(a==="style"){const i=o?o.split(";").map(p=>p.trim()).filter(Boolean):[],d=n[a]?n[a].split(";").map(p=>p.trim()).filter(Boolean):[],u=new Map;d.forEach(p=>{const[f,y]=p.split(":").map(_=>_.trim());u.set(f,y)}),i.forEach(p=>{const[f,y]=p.split(":").map(_=>_.trim());u.set(f,y)}),n[a]=Array.from(u.entries()).map(([p,f])=>`${p}: ${f}`).join("; ")}else n[a]=o}),n},{})}function Wxe(t,s){return s.filter(r=>r.type===t.type.name).filter(r=>r.attribute.rendered).map(r=>r.attribute.renderHTML?r.attribute.renderHTML(t.attrs)||{}:{[r.name]:t.attrs[r.name]}).reduce((r,n)=>Ac(r,n),{})}function LWe(t){return typeof t=="function"}function Hi(t,s=void 0,...r){return LWe(t)?s?t.bind(s)(...r):t(...r):t}function BAt(t={}){return Object.keys(t).length===0&&t.constructor===Object}function $At(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function nAe(t,s){return"style"in t?t:{...t,getAttrs:r=>{const n=t.getAttrs?t.getAttrs(r):t.attrs;if(n===!1)return!1;const a=s.reduce((o,l)=>{const i=l.attribute.parseHTML?l.attribute.parseHTML(r):$At(r.getAttribute(l.name));return i==null?o:{...o,[l.name]:i}},{});return{...n,...a}}}}function aAe(t){return Object.fromEntries(Object.entries(t).filter(([s,r])=>s==="attrs"&&BAt(r)?!1:r!=null))}function qAt(t,s){var r;const n=IWe(t),{nodeExtensions:a,markExtensions:o}=kle(t),l=(r=a.find(u=>ea(u,"topNode")))===null||r===void 0?void 0:r.name,i=Object.fromEntries(a.map(u=>{const p=n.filter(k=>k.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},y=t.reduce((k,S)=>{const T=ea(S,"extendNodeSchema",f);return{...k,...T?T(u):{}}},{}),_=aAe({...y,content:Hi(ea(u,"content",f)),marks:Hi(ea(u,"marks",f)),group:Hi(ea(u,"group",f)),inline:Hi(ea(u,"inline",f)),atom:Hi(ea(u,"atom",f)),selectable:Hi(ea(u,"selectable",f)),draggable:Hi(ea(u,"draggable",f)),code:Hi(ea(u,"code",f)),whitespace:Hi(ea(u,"whitespace",f)),linebreakReplacement:Hi(ea(u,"linebreakReplacement",f)),defining:Hi(ea(u,"defining",f)),isolating:Hi(ea(u,"isolating",f)),attrs:Object.fromEntries(p.map(k=>{var S;return[k.name,{default:(S=k==null?void 0:k.attribute)===null||S===void 0?void 0:S.default}]}))}),b=Hi(ea(u,"parseHTML",f));b&&(_.parseDOM=b.map(k=>nAe(k,p)));const w=ea(u,"renderHTML",f);w&&(_.toDOM=k=>w({node:k,HTMLAttributes:Wxe(k,p)}));const j=ea(u,"renderText",f);return j&&(_.toText=j),[u.name,_]})),d=Object.fromEntries(o.map(u=>{const p=n.filter(j=>j.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},y=t.reduce((j,k)=>{const S=ea(k,"extendMarkSchema",f);return{...j,...S?S(u):{}}},{}),_=aAe({...y,inclusive:Hi(ea(u,"inclusive",f)),excludes:Hi(ea(u,"excludes",f)),group:Hi(ea(u,"group",f)),spanning:Hi(ea(u,"spanning",f)),code:Hi(ea(u,"code",f)),attrs:Object.fromEntries(p.map(j=>{var k;return[j.name,{default:(k=j==null?void 0:j.attribute)===null||k===void 0?void 0:k.default}]}))}),b=Hi(ea(u,"parseHTML",f));b&&(_.parseDOM=b.map(j=>nAe(j,p)));const w=ea(u,"renderHTML",f);return w&&(_.toDOM=j=>w({mark:j,HTMLAttributes:Wxe(j,p)})),[u.name,_]}));return new bHe({topNode:l,nodes:i,marks:d})}function Pme(t,s){return s.nodes[t]||s.marks[t]||null}function iAe(t,s){return Array.isArray(s)?s.some(r=>(typeof r=="string"?r:r.name)===t.name):s}function Bbe(t,s){const r=dS.fromSchema(s).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(r),a.innerHTML}const UAt=(t,s=500)=>{let r="";const n=t.parentOffset;return t.parent.nodesBetween(Math.max(0,n-s),n,(a,o,l,i)=>{var d,u;const p=((u=(d=a.type.spec).toText)===null||u===void 0?void 0:u.call(d,{node:a,pos:o,parent:l,index:i}))||a.textContent||"%leaf%";r+=a.isAtom&&!a.isText?p:p.slice(0,Math.max(0,n-o))}),r};function $be(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class Sle{constructor(s){this.find=s.find,this.handler=s.handler}}const VAt=(t,s)=>{if($be(s))return s.exec(t);const r=s(t);if(!r)return null;const n=[r.text];return n.index=r.index,n.input=t,n.data=r.data,r.replaceWith&&(r.text.includes(r.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),n.push(r.replaceWith)),n};function rR(t){var s;const{editor:r,from:n,to:a,text:o,rules:l,plugin:i}=t,{view:d}=r;if(d.composing)return!1;const u=d.state.doc.resolve(n);if(u.parent.type.spec.code||!((s=u.nodeBefore||u.nodeAfter)===null||s===void 0)&&s.marks.find(y=>y.type.spec.code))return!1;let p=!1;const f=UAt(u)+o;return l.forEach(y=>{if(p)return;const _=VAt(f,y.find);if(!_)return;const b=d.state.tr,w=jle({state:d.state,transaction:b}),j={from:n-(_[0].length-o.length),to:a},{commands:k,chain:S,can:T}=new Nle({editor:r,state:w});y.handler({state:w,range:j,match:_,commands:k,chain:S,can:T})===null||!b.steps.length||(b.setMeta(i,{transform:b,from:n,to:a,text:o}),d.dispatch(b),p=!0)}),p}function HAt(t){const{editor:s,rules:r}=t,n=new Yd({state:{init(){return null},apply(a,o,l){const i=a.getMeta(n);if(i)return i;const d=a.getMeta("applyInputRules");return!!d&&setTimeout(()=>{let{text:p}=d;typeof p=="string"?p=p:p=Bbe(Tr.from(p),l.schema);const{from:f}=d,y=f+p.length;rR({editor:s,from:f,to:y,text:p,rules:r,plugin:n})}),a.selectionSet||a.docChanged?null:o}},props:{handleTextInput(a,o,l,i){return rR({editor:s,from:o,to:l,text:i,rules:r,plugin:n})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:o}=a.state.selection;o&&rR({editor:s,from:o.pos,to:o.pos,text:"",rules:r,plugin:n})}),!1)},handleKeyDown(a,o){if(o.key!=="Enter")return!1;const{$cursor:l}=a.state.selection;return l?rR({editor:s,from:l.pos,to:l.pos,text:` `,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function WAt(t){return Object.prototype.toString.call(t).slice(8,-1)}function nR(t){return WAt(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Cle(t,s){const r={...t};return nR(t)&&nR(s)&&Object.keys(s).forEach(n=>{nR(s[n])&&nR(t[n])?r[n]=Cle(t[n],s[n]):r[n]=s[n]}),r}class hy{constructor(s={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...s},this.name=this.config.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Hi(ea(this,"addOptions",{name:this.name}))),this.storage=Hi(ea(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new hy(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Cle(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new hy(s);return r.parent=this,this.child=r,r.name=s.name?s.name:r.parent.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=Hi(ea(r,"addOptions",{name:r.name})),r.storage=Hi(ea(r,"addStorage",{name:r.name,options:r.options})),r}static handleExit({editor:s,mark:r}){const{tr:n}=s.state,a=s.state.selection.$from;if(a.pos===a.end()){const l=a.marks();if(!!!l.find(u=>(u==null?void 0:u.type.name)===r.name))return!1;const d=l.find(u=>(u==null?void 0:u.type.name)===r.name);return d&&n.removeStoredMark(d),n.insertText(" ",a.pos),s.view.dispatch(n),!0}return!1}}function GAt(t){return typeof t=="number"}class KAt{constructor(s){this.find=s.find,this.handler=s.handler}}const ZAt=(t,s,r)=>{if($be(s))return[...t.matchAll(s)];const n=s(t,r);return n?n.map(a=>{const o=[a.text];return o.index=a.index,o.input=t,o.data=a.data,a.replaceWith&&(a.text.includes(a.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(a.replaceWith)),o}):[]};function YAt(t){const{editor:s,state:r,from:n,to:a,rule:o,pasteEvent:l,dropEvent:i}=t,{commands:d,chain:u,can:p}=new Nle({editor:s,state:r}),f=[];return r.doc.nodesBetween(n,a,(_,b)=>{if(!_.isTextblock||_.type.spec.code)return;const w=Math.max(n,b),j=Math.min(a,b+_.content.size),k=_.textBetween(w-b,j-b,void 0,"");ZAt(k,o.find,l).forEach(T=>{if(T.index===void 0)return;const I=w+T.index+1,L=I+T[0].length,R={from:r.tr.mapping.map(I),to:r.tr.mapping.map(L)},$=o.handler({state:r,range:R,match:T,commands:d,chain:u,can:p,pasteEvent:l,dropEvent:i});f.push($)})}),f.every(_=>_!==null)}let aR=null;const XAt=t=>{var s;const r=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(s=r.clipboardData)===null||s===void 0||s.setData("text/html",t),r};function QAt(t){const{editor:s,rules:r}=t;let n=null,a=!1,o=!1,l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,i;try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}const d=({state:p,from:f,to:y,rule:_,pasteEvt:b})=>{const w=p.tr,j=jle({state:p,transaction:w});if(!(!YAt({editor:s,state:j,from:Math.max(f-1,0),to:y.b-1,rule:_,pasteEvent:b,dropEvent:i})||!w.steps.length)){try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return r.map(p=>new Yd({view(f){const y=b=>{var w;n=!((w=f.dom.parentElement)===null||w===void 0)&&w.contains(b.target)?f.dom.parentElement:null,n&&(aR=s)},_=()=>{aR&&(aR=null)};return window.addEventListener("dragstart",y),window.addEventListener("dragend",_),{destroy(){window.removeEventListener("dragstart",y),window.removeEventListener("dragend",_)}}},props:{handleDOMEvents:{drop:(f,y)=>{if(o=n===f.dom.parentElement,i=y,!o){const _=aR;_!=null&&_.isEditable&&setTimeout(()=>{const b=_.state.selection;b&&_.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(f,y)=>{var _;const b=(_=y.clipboardData)===null||_===void 0?void 0:_.getData("text/html");return l=y,a=!!(b!=null&&b.includes("data-pm-slice")),!1}}},appendTransaction:(f,y,_)=>{const b=f[0],w=b.getMeta("uiEvent")==="paste"&&!a,j=b.getMeta("uiEvent")==="drop"&&!o,k=b.getMeta("applyPasteRules"),S=!!k;if(!w&&!j&&!S)return;if(S){let{text:L}=k;typeof L=="string"?L=L:L=Bbe(Tr.from(L),_.schema);const{from:R}=k,$=R+L.length,q=XAt(L);return d({rule:p,state:_,from:R,to:{b:$},pasteEvt:q})}const T=y.doc.content.findDiffStart(_.doc.content),I=y.doc.content.findDiffEnd(_.doc.content);if(!(!GAt(T)||!I||T===I.b))return d({rule:p,state:_,from:T,to:I,pasteEvt:l})}}))}function JAt(t){const s=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(s))}class Z4{constructor(s,r){this.splittableMarks=[],this.editor=r,this.extensions=Z4.resolve(s),this.schema=qAt(this.extensions,r),this.setupExtensions()}static resolve(s){const r=Z4.sort(Z4.flatten(s)),n=JAt(r.map(a=>a.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(a=>`'${a}'`).join(", ")}]. This can lead to issues.`),r}static flatten(s){return s.map(r=>{const n={name:r.name,options:r.options,storage:r.storage},a=ea(r,"addExtensions",n);return a?[r,...this.flatten(a())]:r}).flat(10)}static sort(s){return s.sort((n,a)=>{const o=ea(n,"priority")||100,l=ea(a,"priority")||100;return o>l?-1:o{const n={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:Pme(r.name,this.schema)},a=ea(r,"addCommands",n);return a?{...s,...a()}:s},{})}get plugins(){const{editor:s}=this,r=Z4.sort([...this.extensions].reverse()),n=[],a=[],o=r.map(l=>{const i={name:l.name,options:l.options,storage:l.storage,editor:s,type:Pme(l.name,this.schema)},d=[],u=ea(l,"addKeyboardShortcuts",i);let p={};if(l.type==="mark"&&ea(l,"exitable",i)&&(p.ArrowRight=()=>hy.handleExit({editor:s,mark:l})),u){const w=Object.fromEntries(Object.entries(u()).map(([j,k])=>[j,()=>k({editor:s})]));p={...p,...w}}const f=yAt(p);d.push(f);const y=ea(l,"addInputRules",i);iAe(l,s.options.enableInputRules)&&y&&n.push(...y());const _=ea(l,"addPasteRules",i);iAe(l,s.options.enablePasteRules)&&_&&a.push(..._());const b=ea(l,"addProseMirrorPlugins",i);if(b){const w=b();d.push(...w)}return d}).flat();return[HAt({editor:s,rules:n}),...QAt({editor:s,rules:a}),...o]}get attributes(){return IWe(this.extensions)}get nodeViews(){const{editor:s}=this,{nodeExtensions:r}=kle(this.extensions);return Object.fromEntries(r.filter(n=>!!ea(n,"addNodeView")).map(n=>{const a=this.attributes.filter(d=>d.type===n.name),o={name:n.name,options:n.options,storage:n.storage,editor:s,type:_u(n.name,this.schema)},l=ea(n,"addNodeView",o);if(!l)return[];const i=(d,u,p,f,y)=>{const _=Wxe(d,a);return l()({node:d,view:u,getPos:p,decorations:f,innerDecorations:y,editor:s,extension:n,HTMLAttributes:_})};return[n.name,i]}))}setupExtensions(){this.extensions.forEach(s=>{var r;this.editor.extensionStorage[s.name]=s.storage;const n={name:s.name,options:s.options,storage:s.storage,editor:this.editor,type:Pme(s.name,this.schema)};s.type==="mark"&&(!((r=Hi(ea(s,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(s.name);const a=ea(s,"onBeforeCreate",n),o=ea(s,"onCreate",n),l=ea(s,"onUpdate",n),i=ea(s,"onSelectionUpdate",n),d=ea(s,"onTransaction",n),u=ea(s,"onFocus",n),p=ea(s,"onBlur",n),f=ea(s,"onDestroy",n);a&&this.editor.on("beforeCreate",a),o&&this.editor.on("create",o),l&&this.editor.on("update",l),i&&this.editor.on("selectionUpdate",i),d&&this.editor.on("transaction",d),u&&this.editor.on("focus",u),p&&this.editor.on("blur",p),f&&this.editor.on("destroy",f)})}}class Uu{constructor(s={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...s},this.name=this.config.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Hi(ea(this,"addOptions",{name:this.name}))),this.storage=Hi(ea(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new Uu(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Cle(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new Uu({...this.config,...s});return r.parent=this,this.child=r,r.name=s.name?s.name:r.parent.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=Hi(ea(r,"addOptions",{name:r.name})),r.storage=Hi(ea(r,"addStorage",{name:r.name,options:r.options})),r}}function DWe(t,s,r){const{from:n,to:a}=s,{blockSeparator:o=` `,textSerializers:l={}}=r||{};let i="";return t.nodesBetween(n,a,(d,u,p,f)=>{var y;d.isBlock&&u>n&&(i+=o);const _=l==null?void 0:l[d.type.name];if(_)return p&&(i+=_({node:d,pos:u,parent:p,index:f,range:s})),!1;d.isText&&(i+=(y=d==null?void 0:d.text)===null||y===void 0?void 0:y.slice(Math.max(n,u)-u,a-u))}),i}function OWe(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,s])=>s.spec.toText).map(([s,r])=>[s,r.spec.toText]))}const eEt=Uu.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Yd({key:new ph("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:s,schema:r}=t,{doc:n,selection:a}=s,{ranges:o}=a,l=Math.min(...o.map(p=>p.$from.pos)),i=Math.max(...o.map(p=>p.$to.pos)),d=OWe(r);return DWe(n,{from:l,to:i},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:d})}}})]}}),tEt=()=>({editor:t,view:s})=>(requestAnimationFrame(()=>{var r;t.isDestroyed||(s.dom.blur(),(r=window==null?void 0:window.getSelection())===null||r===void 0||r.removeAllRanges())}),!0),sEt=(t=!1)=>({commands:s})=>s.setContent("",t),rEt=()=>({state:t,tr:s,dispatch:r})=>{const{selection:n}=s,{ranges:a}=n;return r&&a.forEach(({$from:o,$to:l})=>{t.doc.nodesBetween(o.pos,l.pos,(i,d)=>{if(i.type.isText)return;const{doc:u,mapping:p}=s,f=u.resolve(p.map(d)),y=u.resolve(p.map(d+i.nodeSize)),_=f.blockRange(y);if(!_)return;const b=PM(_);if(i.type.isTextblock){const{defaultType:w}=f.parent.contentMatchAt(f.index());s.setNodeMarkup(_.start,w)}(b||b===0)&&s.lift(_,b)})}),!0},nEt=t=>s=>t(s),aEt=()=>({state:t,dispatch:s})=>TWe(t,s),iEt=(t,s)=>({editor:r,tr:n})=>{const{state:a}=r,o=a.doc.slice(t.from,t.to);n.deleteRange(t.from,t.to);const l=n.mapping.map(s);return n.insert(l,o.content),n.setSelection(new qa(n.doc.resolve(Math.max(l-1,0)))),!0},oEt=()=>({tr:t,dispatch:s})=>{const{selection:r}=t,n=r.$anchor.node();if(n.content.size>0)return!1;const a=t.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===n.type){if(s){const i=a.before(o),d=a.after(o);t.delete(i,d).scrollIntoView()}return!0}return!1},lEt=t=>({tr:s,state:r,dispatch:n})=>{const a=_u(t,r.schema),o=s.selection.$anchor;for(let l=o.depth;l>0;l-=1)if(o.node(l).type===a){if(n){const d=o.before(l),u=o.after(l);s.delete(d,u).scrollIntoView()}return!0}return!1},cEt=t=>({tr:s,dispatch:r})=>{const{from:n,to:a}=t;return r&&s.delete(n,a),!0},dEt=()=>({state:t,dispatch:s})=>Dbe(t,s),uEt=()=>({commands:t})=>t.keyboardShortcut("Enter"),hEt=()=>({state:t,dispatch:s})=>NAt(t,s);function oae(t,s,r={strict:!0}){const n=Object.keys(s);return n.length?n.every(a=>r.strict?s[a]===t[a]:$be(s[a])?s[a].test(t[a]):s[a]===t[a]):!0}function RWe(t,s,r={}){return t.find(n=>n.type===s&&oae(Object.fromEntries(Object.keys(r).map(a=>[a,n.attrs[a]])),r))}function oAe(t,s,r={}){return!!RWe(t,s,r)}function qbe(t,s,r){var n;if(!t||!s)return;let a=t.parent.childAfter(t.parentOffset);if((!a.node||!a.node.marks.some(p=>p.type===s))&&(a=t.parent.childBefore(t.parentOffset)),!a.node||!a.node.marks.some(p=>p.type===s)||(r=r||((n=a.node.marks[0])===null||n===void 0?void 0:n.attrs),!RWe([...a.node.marks],s,r)))return;let l=a.index,i=t.start()+a.offset,d=l+1,u=i+a.node.nodeSize;for(;l>0&&oAe([...t.parent.child(l-1).marks],s,r);)l-=1,i-=t.parent.child(l).nodeSize;for(;d({tr:r,state:n,dispatch:a})=>{const o=tb(t,n.schema),{doc:l,selection:i}=r,{$from:d,from:u,to:p}=i;if(a){const f=qbe(d,o,s);if(f&&f.from<=u&&f.to>=p){const y=qa.create(l,f.from,f.to);r.setSelection(y)}}return!0},pEt=t=>s=>{const r=typeof t=="function"?t(s):t;for(let n=0;n({editor:r,view:n,tr:a,dispatch:o})=>{s={scrollIntoView:!0,...s};const l=()=>{(Ube()||fEt())&&n.dom.focus(),requestAnimationFrame(()=>{r.isDestroyed||(n.focus(),s!=null&&s.scrollIntoView&&r.commands.scrollIntoView())})};if(n.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!FWe(r.state.selection))return l(),!0;const i=zWe(a.doc,t)||r.state.selection,d=r.state.selection.eq(i);return o&&(d||a.setSelection(i),d&&a.storedMarks&&a.setStoredMarks(a.storedMarks),l()),!0},xEt=(t,s)=>r=>t.every((n,a)=>s(n,{...r,index:a})),yEt=(t,s)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,s),BWe=t=>{const s=t.childNodes;for(let r=s.length-1;r>=0;r-=1){const n=s[r];n.nodeType===3&&n.nodeValue&&/^(\n\s\s|\n)$/.test(n.nodeValue)?t.removeChild(n):n.nodeType===1&&BWe(n)}return t};function iR(t){const s=`${t}`,r=new window.DOMParser().parseFromString(s,"text/html").body;return BWe(r)}function _6(t,s,r){if(t instanceof __||t instanceof Tr)return t;r={slice:!0,parseOptions:{},...r};const n=typeof t=="object"&&t!==null,a=typeof t=="string";if(n)try{if(Array.isArray(t)&&t.length>0)return Tr.fromArray(t.map(i=>s.nodeFromJSON(i)));const l=s.nodeFromJSON(t);return r.errorOnInvalidContent&&l.check(),l}catch(o){if(r.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),_6("",s,r)}if(a){if(r.errorOnInvalidContent){let l=!1,i="";const d=new bHe({topNode:s.spec.topNode,marks:s.spec.marks,nodes:s.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:u=>(l=!0,i=typeof u=="string"?u:u.outerHTML,null)}]}})});if(r.slice?cI.fromSchema(d).parseSlice(iR(t),r.parseOptions):cI.fromSchema(d).parse(iR(t),r.parseOptions),r.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const o=cI.fromSchema(s);return r.slice?o.parseSlice(iR(t),r.parseOptions).content:o.parse(iR(t),r.parseOptions)}return _6("",s,r)}function vEt(t,s,r){const n=t.steps.length-1;if(n{l===0&&(l=p)}),t.setSelection(ni.near(t.doc.resolve(l),r))}const _Et=t=>!("type"in t),bEt=(t,s,r)=>({tr:n,dispatch:a,editor:o})=>{var l;if(a){r={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...r};let i;const d=j=>{o.emit("contentError",{editor:o,error:j,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{_6(s,o.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(j){d(j)}try{i=_6(s,o.schema,{parseOptions:u,errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})}catch(j){return d(j),!1}let{from:p,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},y=!0,_=!0;if((_Et(i)?i:[i]).forEach(j=>{j.check(),y=y?j.isText&&j.marks.length===0:!1,_=_?j.isBlock:!1}),p===f&&_){const{parent:j}=n.doc.resolve(p);j.isTextblock&&!j.type.spec.code&&!j.childCount&&(p-=1,f+=1)}let w;if(y){if(Array.isArray(s))w=s.map(j=>j.text||"").join("");else if(s instanceof Tr){let j="";s.forEach(k=>{k.text&&(j+=k.text)}),w=j}else typeof s=="object"&&s&&s.text?w=s.text:w=s;n.insertText(w,p,f)}else w=i,n.replaceWith(p,f,w);r.updateSelection&&vEt(n,n.steps.length-1,-1),r.applyInputRules&&n.setMeta("applyInputRules",{from:p,text:w}),r.applyPasteRules&&n.setMeta("applyPasteRules",{from:p,text:w})}return!0},wEt=()=>({state:t,dispatch:s})=>bAt(t,s),jEt=()=>({state:t,dispatch:s})=>wAt(t,s),NEt=()=>({state:t,dispatch:s})=>wWe(t,s),kEt=()=>({state:t,dispatch:s})=>SWe(t,s),SEt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=xle(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},CEt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=xle(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},MEt=()=>({state:t,dispatch:s})=>vAt(t,s),TEt=()=>({state:t,dispatch:s})=>_At(t,s);function $We(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function AEt(t){const s=t.split(/-(?!$)/);let r=s[s.length-1];r==="Space"&&(r=" ");let n,a,o,l;for(let i=0;i({editor:s,view:r,tr:n,dispatch:a})=>{const o=AEt(t).split(/-(?!$)/),l=o.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),i=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),d=s.captureTransaction(()=>{r.someProp("handleKeyDown",u=>u(r,i))});return d==null||d.steps.forEach(u=>{const p=u.map(n.mapping);p&&a&&n.maybeStep(p)}),!0};function b6(t,s,r={}){const{from:n,to:a,empty:o}=t.selection,l=s?_u(s,t.schema):null,i=[];t.doc.nodesBetween(n,a,(f,y)=>{if(f.isText)return;const _=Math.max(n,y),b=Math.min(a,y+f.nodeSize);i.push({node:f,from:_,to:b})});const d=a-n,u=i.filter(f=>l?l.name===f.node.type.name:!0).filter(f=>oae(f.node.attrs,r,{strict:!1}));return o?!!u.length:u.reduce((f,y)=>f+y.to-y.from,0)>=d}const PEt=(t,s={})=>({state:r,dispatch:n})=>{const a=_u(t,r.schema);return b6(r,a,s)?jAt(r,n):!1},IEt=()=>({state:t,dispatch:s})=>AWe(t,s),LEt=t=>({state:s,dispatch:r})=>{const n=_u(t,s.schema);return DAt(n)(s,r)},DEt=()=>({state:t,dispatch:s})=>MWe(t,s);function Mle(t,s){return s.nodes[t]?"node":s.marks[t]?"mark":null}function lAe(t,s){const r=typeof s=="string"?[s]:s;return Object.keys(t).reduce((n,a)=>(r.includes(a)||(n[a]=t[a]),n),{})}const OEt=(t,s)=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=Mle(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=_u(t,n.schema)),i==="mark"&&(l=tb(t,n.schema)),a&&r.selection.ranges.forEach(d=>{n.doc.nodesBetween(d.$from.pos,d.$to.pos,(u,p)=>{o&&o===u.type&&r.setNodeMarkup(p,void 0,lAe(u.attrs,s)),l&&u.marks.length&&u.marks.forEach(f=>{l===f.type&&r.addMark(p,p+u.nodeSize,l.create(lAe(f.attrs,s)))})})}),!0):!1},REt=()=>({tr:t,dispatch:s})=>(s&&t.scrollIntoView(),!0),FEt=()=>({tr:t,dispatch:s})=>{if(s){const r=new wp(t.doc);t.setSelection(r)}return!0},zEt=()=>({state:t,dispatch:s})=>NWe(t,s),BEt=()=>({state:t,dispatch:s})=>CWe(t,s),$Et=()=>({state:t,dispatch:s})=>CAt(t,s),qEt=()=>({state:t,dispatch:s})=>AAt(t,s),UEt=()=>({state:t,dispatch:s})=>TAt(t,s);function Gxe(t,s,r={},n={}){return _6(t,s,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}const VEt=(t,s=!1,r={},n={})=>({editor:a,tr:o,dispatch:l,commands:i})=>{var d,u;const{doc:p}=o;if(r.preserveWhitespace!=="full"){const f=Gxe(t,a.schema,r,{errorOnInvalidContent:(d=n.errorOnInvalidContent)!==null&&d!==void 0?d:a.options.enableContentCheck});return l&&o.replaceWith(0,p.content.size,f).setMeta("preventUpdate",!s),!0}return l&&o.setMeta("preventUpdate",!s),i.insertContentAt({from:0,to:p.content.size},t,{parseOptions:r,errorOnInvalidContent:(u=n.errorOnInvalidContent)!==null&&u!==void 0?u:a.options.enableContentCheck})};function qWe(t,s){const r=tb(s,t.schema),{from:n,to:a,empty:o}=t.selection,l=[];o?(t.storedMarks&&l.push(...t.storedMarks),l.push(...t.selection.$head.marks())):t.doc.nodesBetween(n,a,d=>{l.push(...d.marks)});const i=l.find(d=>d.type.name===r.name);return i?{...i.attrs}:{}}function HEt(t,s){const r=new jbe(t);return s.forEach(n=>{n.steps.forEach(a=>{r.step(a)})}),r}function WEt(t){for(let s=0;s{r(a)&&n.push({node:a,pos:o})}),n}function UWe(t,s){for(let r=t.depth;r>0;r-=1){const n=t.node(r);if(s(n))return{pos:r>0?t.before(r):0,start:t.start(r),depth:r,node:n}}}function Vbe(t){return s=>UWe(s.$from,t)}function KEt(t,s){const r={from:0,to:t.content.size};return DWe(t,r,s)}function ZEt(t,s){const r=_u(s,t.schema),{from:n,to:a}=t.selection,o=[];t.doc.nodesBetween(n,a,i=>{o.push(i)});const l=o.reverse().find(i=>i.type.name===r.name);return l?{...l.attrs}:{}}function VWe(t,s){const r=Mle(typeof s=="string"?s:s.name,t.schema);return r==="node"?ZEt(t,s):r==="mark"?qWe(t,s):{}}function YEt(t,s=JSON.stringify){const r={};return t.filter(n=>{const a=s(n);return Object.prototype.hasOwnProperty.call(r,a)?!1:r[a]=!0})}function XEt(t){const s=YEt(t);return s.length===1?s:s.filter((r,n)=>!s.filter((o,l)=>l!==n).some(o=>r.oldRange.from>=o.oldRange.from&&r.oldRange.to<=o.oldRange.to&&r.newRange.from>=o.newRange.from&&r.newRange.to<=o.newRange.to))}function QEt(t){const{mapping:s,steps:r}=t,n=[];return s.maps.forEach((a,o)=>{const l=[];if(a.ranges.length)a.forEach((i,d)=>{l.push({from:i,to:d})});else{const{from:i,to:d}=r[o];if(i===void 0||d===void 0)return;l.push({from:i,to:d})}l.forEach(({from:i,to:d})=>{const u=s.slice(o).map(i,-1),p=s.slice(o).map(d),f=s.invert().map(u,-1),y=s.invert().map(p);n.push({oldRange:{from:f,to:y},newRange:{from:u,to:p}})})}),XEt(n)}function Hbe(t,s,r){const n=[];return t===s?r.resolve(t).marks().forEach(a=>{const o=r.resolve(t),l=qbe(o,a.type);l&&n.push({mark:a,...l})}):r.nodesBetween(t,s,(a,o)=>{!a||(a==null?void 0:a.nodeSize)===void 0||n.push(...a.marks.map(l=>({from:o,to:o+a.nodeSize,mark:l})))}),n}function Mre(t,s,r){return Object.fromEntries(Object.entries(r).filter(([n])=>{const a=t.find(o=>o.type===s&&o.name===n);return a?a.attribute.keepOnSplit:!1}))}function Kxe(t,s,r={}){const{empty:n,ranges:a}=t.selection,o=s?tb(s,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>oae(f.attrs,r,{strict:!1}));let l=0;const i=[];if(a.forEach(({$from:f,$to:y})=>{const _=f.pos,b=y.pos;t.doc.nodesBetween(_,b,(w,j)=>{if(!w.isText&&!w.marks.length)return;const k=Math.max(_,j),S=Math.min(b,j+w.nodeSize),T=S-k;l+=T,i.push(...w.marks.map(I=>({mark:I,from:k,to:S})))})}),l===0)return!1;const d=i.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>oae(f.mark.attrs,r,{strict:!1})).reduce((f,y)=>f+y.to-y.from,0),u=i.filter(f=>o?f.mark.type!==o&&f.mark.type.excludes(o):!0).reduce((f,y)=>f+y.to-y.from,0);return(d>0?d+u:d)>=l}function JEt(t,s,r={}){if(!s)return b6(t,null,r)||Kxe(t,null,r);const n=Mle(s,t.schema);return n==="node"?b6(t,s,r):n==="mark"?Kxe(t,s,r):!1}function cAe(t,s){const{nodeExtensions:r}=kle(s),n=r.find(l=>l.name===t);if(!n)return!1;const a={name:n.name,options:n.options,storage:n.storage},o=Hi(ea(n,"group",a));return typeof o!="string"?!1:o.split(" ").includes("list")}function Wbe(t,{checkChildren:s=!0,ignoreWhitespace:r=!1}={}){var n;if(r){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((n=t.text)!==null&&n!==void 0?n:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(s){let a=!0;return t.content.forEach(o=>{a!==!1&&(Wbe(o,{ignoreWhitespace:r,checkChildren:s})||(a=!1))}),a}return!1}function ePt(t){return t instanceof La}function tPt(t,s,r){var n;const{selection:a}=s;let o=null;if(FWe(a)&&(o=a.$cursor),o){const i=(n=t.storedMarks)!==null&&n!==void 0?n:o.marks();return!!r.isInSet(i)||!i.some(d=>d.type.excludes(r))}const{ranges:l}=a;return l.some(({$from:i,$to:d})=>{let u=i.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(r):!1;return t.doc.nodesBetween(i.pos,d.pos,(p,f,y)=>{if(u)return!1;if(p.isInline){const _=!y||y.type.allowsMarkType(r),b=!!r.isInSet(p.marks)||!p.marks.some(w=>w.type.excludes(r));u=_&&b}return!u}),u})}const sPt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{const{selection:o}=r,{empty:l,ranges:i}=o,d=tb(t,n.schema);if(a)if(l){const u=qWe(n,d);r.addStoredMark(d.create({...u,...s}))}else i.forEach(u=>{const p=u.$from.pos,f=u.$to.pos;n.doc.nodesBetween(p,f,(y,_)=>{const b=Math.max(_,p),w=Math.min(_+y.nodeSize,f);y.marks.find(k=>k.type===d)?y.marks.forEach(k=>{d===k.type&&r.addMark(b,w,d.create({...k.attrs,...s}))}):r.addMark(b,w,d.create(s))})});return tPt(n,r,d)},rPt=(t,s)=>({tr:r})=>(r.setMeta(t,s),!0),nPt=(t,s={})=>({state:r,dispatch:n,chain:a})=>{const o=_u(t,r.schema);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),o.isTextblock?a().command(({commands:i})=>rAe(o,{...l,...s})(r)?!0:i.clearNodes()).command(({state:i})=>rAe(o,{...l,...s})(i,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},aPt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,a=BN(t,0,n.content.size),o=La.create(n,a);s.setSelection(o)}return!0},iPt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,{from:a,to:o}=typeof t=="number"?{from:t,to:t}:t,l=qa.atStart(n).from,i=qa.atEnd(n).to,d=BN(a,l,i),u=BN(o,l,i),p=qa.create(n,d,u);s.setSelection(p)}return!0},oPt=t=>({state:s,dispatch:r})=>{const n=_u(t,s.schema);return FAt(n)(s,r)};function dAe(t,s){const r=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(r){const n=r.filter(a=>s==null?void 0:s.includes(a.type.name));t.tr.ensureMarks(n)}}const lPt=({keepMarks:t=!0}={})=>({tr:s,state:r,dispatch:n,editor:a})=>{const{selection:o,doc:l}=s,{$from:i,$to:d}=o,u=a.extensionManager.attributes,p=Mre(u,i.node().type.name,i.node().attrs);if(o instanceof La&&o.node.isBlock)return!i.parentOffset||!V0(l,i.pos)?!1:(n&&(t&&dAe(r,a.extensionManager.splittableMarks),s.split(i.pos).scrollIntoView()),!0);if(!i.parent.isBlock)return!1;const f=d.parentOffset===d.parent.content.size,y=i.depth===0?void 0:WEt(i.node(-1).contentMatchAt(i.indexAfter(-1)));let _=f&&y?[{type:y,attrs:p}]:void 0,b=V0(s.doc,s.mapping.map(i.pos),1,_);if(!_&&!b&&V0(s.doc,s.mapping.map(i.pos),1,y?[{type:y}]:void 0)&&(b=!0,_=y?[{type:y,attrs:p}]:void 0),n){if(b&&(o instanceof qa&&s.deleteSelection(),s.split(s.mapping.map(i.pos),1,_),y&&!f&&!i.parentOffset&&i.parent.type!==y)){const w=s.mapping.map(i.before()),j=s.doc.resolve(w);i.node(-1).canReplaceWith(j.index(),j.index()+1,y)&&s.setNodeMarkup(s.mapping.map(i.before()),y)}t&&dAe(r,a.extensionManager.splittableMarks),s.scrollIntoView()}return b},cPt=(t,s={})=>({tr:r,state:n,dispatch:a,editor:o})=>{var l;const i=_u(t,n.schema),{$from:d,$to:u}=n.selection,p=n.selection.node;if(p&&p.isBlock||d.depth<2||!d.sameParent(u))return!1;const f=d.node(-1);if(f.type!==i)return!1;const y=o.extensionManager.attributes;if(d.parent.content.size===0&&d.node(-1).childCount===d.indexAfter(-1)){if(d.depth===2||d.node(-3).type!==i||d.index(-2)!==d.node(-2).childCount-1)return!1;if(a){let k=Tr.empty;const S=d.index(-1)?1:d.index(-2)?2:3;for(let q=d.depth-S;q>=d.depth-3;q-=1)k=Tr.from(d.node(q).copy(k));const T=d.indexAfter(-1){if($>-1)return!1;q.isTextblock&&q.content.size===0&&($=U+1)}),$>-1&&r.setSelection(qa.near(r.doc.resolve($))),r.scrollIntoView()}return!0}const _=u.pos===d.end()?f.contentMatchAt(0).defaultType:null,b={...Mre(y,f.type.name,f.attrs),...s},w={...Mre(y,d.node().type.name,d.node().attrs),...s};r.delete(d.pos,u.pos);const j=_?[{type:i,attrs:b},{type:_,attrs:w}]:[{type:i,attrs:b}];if(!V0(r.doc,d.pos,2))return!1;if(a){const{selection:k,storedMarks:S}=n,{splittableMarks:T}=o.extensionManager,I=S||k.$to.parentOffset&&k.$from.marks();if(r.split(d.pos,2,j).scrollIntoView(),!I||!a)return!0;const L=I.filter(R=>T.includes(R.type.name));r.ensureMarks(L)}return!0},Ime=(t,s)=>{const r=Vbe(l=>l.type===s)(t.selection);if(!r)return!0;const n=t.doc.resolve(Math.max(0,r.pos-1)).before(r.depth);if(n===void 0)return!0;const a=t.doc.nodeAt(n);return r.node.type===(a==null?void 0:a.type)&&J_(t.doc,r.pos)&&t.join(r.pos),!0},Lme=(t,s)=>{const r=Vbe(l=>l.type===s)(t.selection);if(!r)return!0;const n=t.doc.resolve(r.start).after(r.depth);if(n===void 0)return!0;const a=t.doc.nodeAt(n);return r.node.type===(a==null?void 0:a.type)&&J_(t.doc,n)&&t.join(n),!0},dPt=(t,s,r,n={})=>({editor:a,tr:o,state:l,dispatch:i,chain:d,commands:u,can:p})=>{const{extensions:f,splittableMarks:y}=a.extensionManager,_=_u(t,l.schema),b=_u(s,l.schema),{selection:w,storedMarks:j}=l,{$from:k,$to:S}=w,T=k.blockRange(S),I=j||w.$to.parentOffset&&w.$from.marks();if(!T)return!1;const L=Vbe(R=>cAe(R.type.name,f))(w);if(T.depth>=1&&L&&T.depth-L.depth<=1){if(L.node.type===_)return u.liftListItem(b);if(cAe(L.node.type.name,f)&&_.validContent(L.node.content)&&i)return d().command(()=>(o.setNodeMarkup(L.pos,_),!0)).command(()=>Ime(o,_)).command(()=>Lme(o,_)).run()}return!r||!I||!i?d().command(()=>p().wrapInList(_,n)?!0:u.clearNodes()).wrapInList(_,n).command(()=>Ime(o,_)).command(()=>Lme(o,_)).run():d().command(()=>{const R=p().wrapInList(_,n),$=I.filter(q=>y.includes(q.type.name));return o.ensureMarks($),R?!0:u.clearNodes()}).wrapInList(_,n).command(()=>Ime(o,_)).command(()=>Lme(o,_)).run()},uPt=(t,s={},r={})=>({state:n,commands:a})=>{const{extendEmptyMarkRange:o=!1}=r,l=tb(t,n.schema);return Kxe(n,l,s)?a.unsetMark(l,{extendEmptyMarkRange:o}):a.setMark(l,s)},hPt=(t,s,r={})=>({state:n,commands:a})=>{const o=_u(t,n.schema),l=_u(s,n.schema),i=b6(n,o,r);let d;return n.selection.$anchor.sameParent(n.selection.$head)&&(d=n.selection.$anchor.parent.attrs),i?a.setNode(l,d):a.setNode(o,{...d,...r})},mPt=(t,s={})=>({state:r,commands:n})=>{const a=_u(t,r.schema);return b6(r,a,s)?n.lift(a):n.wrapIn(a,s)},pPt=()=>({state:t,dispatch:s})=>{const r=t.plugins;for(let n=0;n=0;d-=1)l.step(i.steps[d].invert(i.docs[d]));if(o.text){const d=l.doc.resolve(o.from).marks();l.replaceWith(o.from,o.to,t.schema.text(o.text,d))}else l.delete(o.from,o.to)}return!0}}return!1},fPt=()=>({tr:t,dispatch:s})=>{const{selection:r}=t,{empty:n,ranges:a}=r;return n||s&&a.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},gPt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{var o;const{extendEmptyMarkRange:l=!1}=s,{selection:i}=r,d=tb(t,n.schema),{$from:u,empty:p,ranges:f}=i;if(!a)return!0;if(p&&l){let{from:y,to:_}=i;const b=(o=u.marks().find(j=>j.type===d))===null||o===void 0?void 0:o.attrs,w=qbe(u,d,b);w&&(y=w.from,_=w.to),r.removeMark(y,_,d)}else f.forEach(y=>{r.removeMark(y.$from.pos,y.$to.pos,d)});return r.removeStoredMark(d),!0},xPt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=Mle(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=_u(t,n.schema)),i==="mark"&&(l=tb(t,n.schema)),a&&r.selection.ranges.forEach(d=>{const u=d.$from.pos,p=d.$to.pos;let f,y,_,b;r.selection.empty?n.doc.nodesBetween(u,p,(w,j)=>{o&&o===w.type&&(_=Math.max(j,u),b=Math.min(j+w.nodeSize,p),f=j,y=w)}):n.doc.nodesBetween(u,p,(w,j)=>{j=u&&j<=p&&(o&&o===w.type&&r.setNodeMarkup(j,void 0,{...w.attrs,...s}),l&&w.marks.length&&w.marks.forEach(k=>{if(l===k.type){const S=Math.max(j,u),T=Math.min(j+w.nodeSize,p);r.addMark(S,T,l.create({...k.attrs,...s}))}}))}),y&&(f!==void 0&&r.setNodeMarkup(f,void 0,{...y.attrs,...s}),l&&y.marks.length&&y.marks.forEach(w=>{l===w.type&&r.addMark(_,b,l.create({...w.attrs,...s}))}))}),!0):!1},yPt=(t,s={})=>({state:r,dispatch:n})=>{const a=_u(t,r.schema);return EAt(a,s)(r,n)},vPt=(t,s={})=>({state:r,dispatch:n})=>{const a=_u(t,r.schema);return PAt(a,s)(r,n)};var _Pt=Object.freeze({__proto__:null,blur:tEt,clearContent:sEt,clearNodes:rEt,command:nEt,createParagraphNear:aEt,cut:iEt,deleteCurrentNode:oEt,deleteNode:lEt,deleteRange:cEt,deleteSelection:dEt,enter:uEt,exitCode:hEt,extendMarkRange:mEt,first:pEt,focus:gEt,forEach:xEt,insertContent:yEt,insertContentAt:bEt,joinBackward:NEt,joinDown:jEt,joinForward:kEt,joinItemBackward:SEt,joinItemForward:CEt,joinTextblockBackward:MEt,joinTextblockForward:TEt,joinUp:wEt,keyboardShortcut:EEt,lift:PEt,liftEmptyBlock:IEt,liftListItem:LEt,newlineInCode:DEt,resetAttributes:OEt,scrollIntoView:REt,selectAll:FEt,selectNodeBackward:zEt,selectNodeForward:BEt,selectParentNode:$Et,selectTextblockEnd:qEt,selectTextblockStart:UEt,setContent:VEt,setMark:sPt,setMeta:rPt,setNode:nPt,setNodeSelection:aPt,setTextSelection:iPt,sinkListItem:oPt,splitBlock:lPt,splitListItem:cPt,toggleList:dPt,toggleMark:uPt,toggleNode:hPt,toggleWrap:mPt,undoInputRule:pPt,unsetAllMarks:fPt,unsetMark:gPt,updateAttributes:xPt,wrapIn:yPt,wrapInList:vPt});const bPt=Uu.create({name:"commands",addCommands(){return{..._Pt}}}),wPt=Uu.create({name:"drop",addProseMirrorPlugins(){return[new Yd({key:new ph("tiptapDrop"),props:{handleDrop:(t,s,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:s,slice:r,moved:n})}}})]}}),jPt=Uu.create({name:"editable",addProseMirrorPlugins(){return[new Yd({key:new ph("editable"),props:{editable:()=>this.editor.options.editable}})]}}),NPt=new ph("focusEvents"),kPt=Uu.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Yd({key:NPt,props:{handleDOMEvents:{focus:(s,r)=>{t.isFocused=!0;const n=t.state.tr.setMeta("focus",{event:r}).setMeta("addToHistory",!1);return s.dispatch(n),!1},blur:(s,r)=>{t.isFocused=!1;const n=t.state.tr.setMeta("blur",{event:r}).setMeta("addToHistory",!1);return s.dispatch(n),!1}}}})]}}),SPt=Uu.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:i})=>{const{selection:d,doc:u}=i,{empty:p,$anchor:f}=d,{pos:y,parent:_}=f,b=f.parent.isTextblock&&y>0?i.doc.resolve(y-1):f,w=b.parent.type.spec.isolating,j=f.pos-f.parentOffset,k=w&&b.parent.childCount===1?j===f.pos:ni.atStart(u).from===y;return!p||!_.type.isTextblock||_.textContent.length||!k||k&&f.parent.type.name==="paragraph"?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),s=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:s,"Mod-Delete":s,"Mod-a":()=>this.editor.commands.selectAll()},a={...n},o={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":s,"Ctrl-Alt-Backspace":s,"Alt-Delete":s,"Alt-d":s,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Ube()||$We()?o:a},addProseMirrorPlugins(){return[new Yd({key:new ph("clearDocument"),appendTransaction:(t,s,r)=>{if(t.some(w=>w.getMeta("composition")))return;const n=t.some(w=>w.docChanged)&&!s.doc.eq(r.doc),a=t.some(w=>w.getMeta("preventClearDocument"));if(!n||a)return;const{empty:o,from:l,to:i}=s.selection,d=ni.atStart(s.doc).from,u=ni.atEnd(s.doc).to;if(o||!(l===d&&i===u)||!Wbe(r.doc))return;const y=r.tr,_=jle({state:r,transaction:y}),{commands:b}=new Nle({editor:this.editor,state:_});if(b.clearNodes(),!!y.steps.length)return y}})]}}),CPt=Uu.create({name:"paste",addProseMirrorPlugins(){return[new Yd({key:new ph("tiptapPaste"),props:{handlePaste:(t,s,r)=>{this.editor.emit("paste",{editor:this.editor,event:s,slice:r})}}})]}}),MPt=Uu.create({name:"tabindex",addProseMirrorPlugins(){return[new Yd({key:new ph("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class CN{get name(){return this.node.type.name}constructor(s,r,n=!1,a=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=s,this.editor=r,this.currentNode=a}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var s;return(s=this.actualDepth)!==null&&s!==void 0?s:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(s){let r=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}r=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:r,to:n},s)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const s=this.resolvedPos.start(this.resolvedPos.depth-1),r=this.resolvedPos.doc.resolve(s);return new CN(r,this.editor)}get before(){let s=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return s.depth!==this.depth&&(s=this.resolvedPos.doc.resolve(this.from-3)),new CN(s,this.editor)}get after(){let s=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return s.depth!==this.depth&&(s=this.resolvedPos.doc.resolve(this.to+3)),new CN(s,this.editor)}get children(){const s=[];return this.node.content.forEach((r,n)=>{const a=r.isBlock&&!r.isTextblock,o=r.isAtom&&!r.isText,l=this.pos+n+(o?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const i=this.resolvedPos.doc.resolve(l);if(!a&&i.depth<=this.depth)return;const d=new CN(i,this.editor,a,a?r:null);a&&(d.actualDepth=this.depth+1),s.push(new CN(i,this.editor,a,a?r:null))}),s}get firstChild(){return this.children[0]||null}get lastChild(){const s=this.children;return s[s.length-1]||null}closest(s,r={}){let n=null,a=this.parent;for(;a&&!n;){if(a.node.type.name===s)if(Object.keys(r).length>0){const o=a.node.attrs,l=Object.keys(r);for(let i=0;i{n&&a.length>0||(l.node.type.name===s&&o.every(d=>r[d]===l.node.attrs[d])&&a.push(l),!(n&&a.length>0)&&(a=a.concat(l.querySelectorAll(s,r,n))))}),a}setAttribute(s){const{tr:r}=this.editor.state;r.setNodeMarkup(this.from,void 0,{...this.node.attrs,...s}),this.editor.view.dispatch(r)}}const TPt=`.ProseMirror { position: relative; } .ProseMirror { word-wrap: break-word; white-space: pre-wrap; white-space: break-spaces; -webkit-font-variant-ligatures: none; font-variant-ligatures: none; font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ } .ProseMirror [contenteditable="false"] { white-space: normal; } .ProseMirror [contenteditable="false"] [contenteditable="true"] { white-space: pre-wrap; } .ProseMirror pre { white-space: pre-wrap; } img.ProseMirror-separator { display: inline !important; border: none !important; margin: 0 !important; width: 0 !important; height: 0 !important; } .ProseMirror-gapcursor { display: none; pointer-events: none; position: absolute; margin: 0; } .ProseMirror-gapcursor:after { content: ""; display: block; position: absolute; top: -2px; width: 20px; border-top: 1px solid black; animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; } @keyframes ProseMirror-cursor-blink { to { visibility: hidden; } } .ProseMirror-hideselection *::selection { background: transparent; } .ProseMirror-hideselection *::-moz-selection { background: transparent; } .ProseMirror-hideselection * { caret-color: transparent; } .ProseMirror-focused .ProseMirror-gapcursor { display: block; } .tippy-box[data-animation=fade][data-state=hidden] { opacity: 0 }`;function APt(t,s,r){const n=document.querySelector("style[data-tiptap-style]");if(n!==null)return n;const a=document.createElement("style");return s&&a.setAttribute("nonce",s),a.setAttribute("data-tiptap-style",""),a.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(a),a}class EPt extends zAt{constructor(s={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(s),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:n,moved:a})=>this.options.onDrop(r,n,a)),this.on("paste",({event:r,slice:n})=>this.options.onPaste(r,n)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=APt(TPt,this.options.injectNonce))}setOptions(s={}){this.options={...this.options,...s},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(s,r=!0){this.setOptions({editable:s}),r&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(s,r){const n=LWe(r)?r(s,[...this.state.plugins]):[...this.state.plugins,s],a=this.state.reconfigure({plugins:n});return this.view.updateState(a),a}unregisterPlugin(s){if(this.isDestroyed)return;const r=this.state.plugins;let n=r;if([].concat(s).forEach(o=>{const l=typeof o=="string"?`${o}$`:o.key;n=n.filter(i=>!i.key.startsWith(l))}),r.length===n.length)return;const a=this.state.reconfigure({plugins:n});return this.view.updateState(a),a}createExtensionManager(){var s,r;const a=[...this.options.enableCoreExtensions?[jPt,eEt.configure({blockSeparator:(r=(s=this.options.coreExtensionOptions)===null||s===void 0?void 0:s.clipboardTextSerializer)===null||r===void 0?void 0:r.blockSeparator}),bPt,kPt,SPt,MPt,wPt,CPt].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o==null?void 0:o.type));this.extensionManager=new Z4(a,this)}createCommandManager(){this.commandManager=new Nle({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var s;let r;try{r=Gxe(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(l){if(!(l instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(l.message))throw l;this.emit("contentError",{editor:this,error:l,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(i=>i.name!=="collaboration"),this.createExtensionManager()}}),r=Gxe(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=zWe(r,this.options.autofocus);this.view=new _We(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(s=this.options.editorProps)===null||s===void 0?void 0:s.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:K4.create({doc:r,selection:n||void 0})});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.createNodeViews(),this.prependClass();const o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(s){this.isCapturingTransaction=!0,s(),this.isCapturingTransaction=!1;const r=this.capturedTransaction;return this.capturedTransaction=null,r}dispatchTransaction(s){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=s;return}s.steps.forEach(l=>{var i;return(i=this.capturedTransaction)===null||i===void 0?void 0:i.step(l)});return}const r=this.state.apply(s),n=!this.state.selection.eq(r.selection);this.emit("beforeTransaction",{editor:this,transaction:s,nextState:r}),this.view.updateState(r),this.emit("transaction",{editor:this,transaction:s}),n&&this.emit("selectionUpdate",{editor:this,transaction:s});const a=s.getMeta("focus"),o=s.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:s}),o&&this.emit("blur",{editor:this,event:o.event,transaction:s}),!(!s.docChanged||s.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:s})}getAttributes(s){return VWe(this.state,s)}isActive(s,r){const n=typeof s=="string"?s:null,a=typeof s=="string"?r:s;return JEt(this.state,n,a)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Bbe(this.state.doc.content,this.schema)}getText(s){const{blockSeparator:r=` `,textSerializers:n={}}=s||{};return KEt(this.state.doc,{blockSeparator:r,textSerializers:{...OWe(this.schema),...n}})}get isEmpty(){return Wbe(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const s=this.view.dom;s&&s.editor&&delete s.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var s;return!(!((s=this.view)===null||s===void 0)&&s.docView)}$node(s,r){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(s,r))||null}$nodes(s,r){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(s,r))||null}$pos(s){const r=this.state.doc.resolve(s);return new CN(r,this)}get $doc(){return this.$pos(0)}}function I3(t){return new Sle({find:t.find,handler:({state:s,range:r,match:n})=>{const a=Hi(t.getAttributes,void 0,n);if(a===!1||a===null)return null;const{tr:o}=s,l=n[n.length-1],i=n[0];if(l){const d=i.search(/\S/),u=r.from+i.indexOf(l),p=u+l.length;if(Hbe(r.from,r.to,s.doc).filter(_=>_.mark.type.excluded.find(w=>w===t.type&&w!==_.mark.type)).filter(_=>_.to>u).length)return null;pr.from&&o.delete(r.from+d,u);const y=r.from+d+l.length;o.addMark(r.from+d,y,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}function HWe(t){return new Sle({find:t.find,handler:({state:s,range:r,match:n})=>{const a=Hi(t.getAttributes,void 0,n)||{},{tr:o}=s,l=r.from;let i=r.to;const d=t.type.create(a);if(n[1]){const u=n[0].lastIndexOf(n[1]);let p=l+u;p>i?p=i:i=p+n[1].length;const f=n[0][n[0].length-1];o.insertText(f,l+n[0].length-1),o.replaceWith(p,i,d)}else if(n[0]){const u=t.type.isInline?l:l-1;o.insert(u,t.type.create(a)).delete(o.mapping.map(l),o.mapping.map(i))}o.scrollIntoView()}})}function Zxe(t){return new Sle({find:t.find,handler:({state:s,range:r,match:n})=>{const a=s.doc.resolve(r.from),o=Hi(t.getAttributes,void 0,n)||{};if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),t.type))return null;s.tr.delete(r.from,r.to).setBlockType(r.from,r.from,t.type,o)}})}function w6(t){return new Sle({find:t.find,handler:({state:s,range:r,match:n,chain:a})=>{const o=Hi(t.getAttributes,void 0,n)||{},l=s.tr.delete(r.from,r.to),d=l.doc.resolve(r.from).blockRange(),u=d&&wbe(d,t.type,o);if(!u)return null;if(l.wrap(d,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:y}=s,{splittableMarks:_}=t.editor.extensionManager,b=y||f.$to.parentOffset&&f.$from.marks();if(b){const w=b.filter(j=>_.includes(j.type.name));l.ensureMarks(w)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(f,o).run()}const p=l.doc.resolve(r.from-1).nodeBefore;p&&p.type===t.type&&J_(l.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,p))&&l.join(r.from-1)}})}let fh=class Yxe{constructor(s={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...s},this.name=this.config.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Hi(ea(this,"addOptions",{name:this.name}))),this.storage=Hi(ea(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new Yxe(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Cle(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new Yxe(s);return r.parent=this,this.child=r,r.name=s.name?s.name:r.parent.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=Hi(ea(r,"addOptions",{name:r.name})),r.storage=Hi(ea(r,"addStorage",{name:r.name,options:r.options})),r}};function Hk(t){return new KAt({find:t.find,handler:({state:s,range:r,match:n,pasteEvent:a})=>{const o=Hi(t.getAttributes,void 0,n,a);if(o===!1||o===null)return null;const{tr:l}=s,i=n[n.length-1],d=n[0];let u=r.to;if(i){const p=d.search(/\S/),f=r.from+d.indexOf(i),y=f+i.length;if(Hbe(r.from,r.to,s.doc).filter(b=>b.mark.type.excluded.find(j=>j===t.type&&j!==b.mark.type)).filter(b=>b.to>f).length)return null;yr.from&&l.delete(r.from+p,f),u=r.from+p+i.length,l.addMark(r.from+p,u,t.type.create(o||{})),l.removeStoredMark(t.type)}}})}function PPt(t,s){const{selection:r}=t,{$from:n}=r;if(r instanceof La){const o=n.index();return n.parent.canReplaceWith(o,o+1,s)}let a=n.depth;for(;a>=0;){const o=n.index(a);if(n.node(a).contentMatchAt(o).matchType(s))return!0;a-=1}return!1}function IPt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var WWe={exports:{}},Dme={};/** * @license React * use-sync-external-store-shim.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var uAe;function LPt(){if(uAe)return Dme;uAe=1;var t=ht;function s(f,y){return f===y&&(f!==0||1/f===1/y)||f!==f&&y!==y}var r=typeof Object.is=="function"?Object.is:s,n=t.useState,a=t.useEffect,o=t.useLayoutEffect,l=t.useDebugValue;function i(f,y){var _=y(),b=n({inst:{value:_,getSnapshot:y}}),w=b[0].inst,j=b[1];return o(function(){w.value=_,w.getSnapshot=y,d(w)&&j({inst:w})},[f,_,y]),a(function(){return d(w)&&j({inst:w}),f(function(){d(w)&&j({inst:w})})},[f]),l(_),_}function d(f){var y=f.getSnapshot;f=f.value;try{var _=y();return!r(f,_)}catch{return!0}}function u(f,y){return y()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:i;return Dme.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,Dme}WWe.exports=LPt();var Gbe=WWe.exports;const DPt=(...t)=>s=>{t.forEach(r=>{typeof r=="function"?r(s):r&&(r.current=s)})},OPt=({contentComponent:t})=>{const s=Gbe.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return ht.createElement(ht.Fragment,null,Object.values(s))};function RPt(){const t=new Set;let s={};return{subscribe(r){return t.add(r),()=>{t.delete(r)}},getSnapshot(){return s},getServerSnapshot(){return s},setRenderer(r,n){s={...s,[r]:r1e.createPortal(n.reactElement,n.element,r)},t.forEach(a=>a())},removeRenderer(r){const n={...s};delete n[r],s=n,t.forEach(a=>a())}}}class FPt extends ht.Component{constructor(s){var r;super(s),this.editorContentRef=ht.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(!((r=s.editor)===null||r===void 0)&&r.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const s=this.props.editor;if(s&&!s.isDestroyed&&s.options.element){if(s.contentComponent)return;const r=this.editorContentRef.current;r.append(...s.options.element.childNodes),s.setOptions({element:r}),s.contentComponent=RPt(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=s.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),s.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const s=this.props.editor;if(!s||(this.initialized=!1,s.isDestroyed||s.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),s.contentComponent=null,!s.options.element.firstChild))return;const r=document.createElement("div");r.append(...s.options.element.childNodes),s.setOptions({element:r})}render(){const{editor:s,innerRef:r,...n}=this.props;return ht.createElement(ht.Fragment,null,ht.createElement("div",{ref:DPt(r,this.editorContentRef),...n}),(s==null?void 0:s.contentComponent)&&ht.createElement(OPt,{contentComponent:s.contentComponent}))}}const zPt=C.forwardRef((t,s)=>{const r=ht.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ht.createElement(FPt,{key:r,innerRef:s,...t})}),GWe=ht.memo(zPt);var BPt=function t(s,r){if(s===r)return!0;if(s&&r&&typeof s=="object"&&typeof r=="object"){if(s.constructor!==r.constructor)return!1;var n,a,o;if(Array.isArray(s)){if(n=s.length,n!=r.length)return!1;for(a=n;a--!==0;)if(!t(s[a],r[a]))return!1;return!0}if(s instanceof Map&&r instanceof Map){if(s.size!==r.size)return!1;for(a of s.entries())if(!r.has(a[0]))return!1;for(a of s.entries())if(!t(a[1],r.get(a[0])))return!1;return!0}if(s instanceof Set&&r instanceof Set){if(s.size!==r.size)return!1;for(a of s.entries())if(!r.has(a[0]))return!1;return!0}if(ArrayBuffer.isView(s)&&ArrayBuffer.isView(r)){if(n=s.length,n!=r.length)return!1;for(a=n;a--!==0;)if(s[a]!==r[a])return!1;return!0}if(s.constructor===RegExp)return s.source===r.source&&s.flags===r.flags;if(s.valueOf!==Object.prototype.valueOf)return s.valueOf()===r.valueOf();if(s.toString!==Object.prototype.toString)return s.toString()===r.toString();if(o=Object.keys(s),n=o.length,n!==Object.keys(r).length)return!1;for(a=n;a--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[a]))return!1;for(a=n;a--!==0;){var l=o[a];if(!(l==="_owner"&&s.$$typeof)&&!t(s[l],r[l]))return!1}return!0}return s!==s&&r!==r},$Pt=IPt(BPt),KWe={exports:{}},Ome={};/** * @license React * use-sync-external-store-shim/with-selector.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var hAe;function qPt(){if(hAe)return Ome;hAe=1;var t=ht,s=Gbe;function r(u,p){return u===p&&(u!==0||1/u===1/p)||u!==u&&p!==p}var n=typeof Object.is=="function"?Object.is:r,a=s.useSyncExternalStore,o=t.useRef,l=t.useEffect,i=t.useMemo,d=t.useDebugValue;return Ome.useSyncExternalStoreWithSelector=function(u,p,f,y,_){var b=o(null);if(b.current===null){var w={hasValue:!1,value:null};b.current=w}else w=b.current;b=i(function(){function k(R){if(!S){if(S=!0,T=R,R=y(R),_!==void 0&&w.hasValue){var $=w.value;if(_($,R))return I=$}return I=R}if($=I,n(T,R))return $;var q=y(R);return _!==void 0&&_($,q)?$:(T=R,I=q)}var S=!1,T,I,L=f===void 0?null:f;return[function(){return k(p())},L===null?void 0:function(){return k(L())}]},[p,f,y,_]);var j=a(u,b[0],b[1]);return l(function(){w.hasValue=!0,w.value=j},[j]),d(j),j},Ome}KWe.exports=qPt();var UPt=KWe.exports;const VPt=typeof window<"u"?C.useLayoutEffect:C.useEffect;class HPt{constructor(s){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=s,this.lastSnapshot={editor:s,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(s){return this.subscribers.add(s),()=>{this.subscribers.delete(s)}}watch(s){if(this.editor=s,this.editor){const r=()=>{this.transactionNumber+=1,this.subscribers.forEach(a=>a())},n=this.editor;return n.on("transaction",r),()=>{n.off("transaction",r)}}}}function WPt(t){var s;const[r]=C.useState(()=>new HPt(t.editor)),n=UPt.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(s=t.equalityFn)!==null&&s!==void 0?s:$Pt);return VPt(()=>r.watch(t.editor),[t.editor,r]),C.useDebugValue(n),n}const GPt=!1,Xxe=typeof window>"u",KPt=Xxe||!!(typeof window<"u"&&window.next);class Kbe{constructor(s){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=s,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(s){this.editor=s,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(r=>r())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?Xxe||KPt?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const s={...this.options.current,onBeforeCreate:(...n)=>{var a,o;return(o=(a=this.options.current).onBeforeCreate)===null||o===void 0?void 0:o.call(a,...n)},onBlur:(...n)=>{var a,o;return(o=(a=this.options.current).onBlur)===null||o===void 0?void 0:o.call(a,...n)},onCreate:(...n)=>{var a,o;return(o=(a=this.options.current).onCreate)===null||o===void 0?void 0:o.call(a,...n)},onDestroy:(...n)=>{var a,o;return(o=(a=this.options.current).onDestroy)===null||o===void 0?void 0:o.call(a,...n)},onFocus:(...n)=>{var a,o;return(o=(a=this.options.current).onFocus)===null||o===void 0?void 0:o.call(a,...n)},onSelectionUpdate:(...n)=>{var a,o;return(o=(a=this.options.current).onSelectionUpdate)===null||o===void 0?void 0:o.call(a,...n)},onTransaction:(...n)=>{var a,o;return(o=(a=this.options.current).onTransaction)===null||o===void 0?void 0:o.call(a,...n)},onUpdate:(...n)=>{var a,o;return(o=(a=this.options.current).onUpdate)===null||o===void 0?void 0:o.call(a,...n)},onContentError:(...n)=>{var a,o;return(o=(a=this.options.current).onContentError)===null||o===void 0?void 0:o.call(a,...n)},onDrop:(...n)=>{var a,o;return(o=(a=this.options.current).onDrop)===null||o===void 0?void 0:o.call(a,...n)},onPaste:(...n)=>{var a,o;return(o=(a=this.options.current).onPaste)===null||o===void 0?void 0:o.call(a,...n)}};return new EPt(s)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(s){return this.subscriptions.add(s),()=>{this.subscriptions.delete(s)}}static compareOptions(s,r){return Object.keys(s).every(n=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)?!0:n==="extensions"&&s.extensions&&r.extensions?s.extensions.length!==r.extensions.length?!1:s.extensions.every((a,o)=>{var l;return a===((l=r.extensions)===null||l===void 0?void 0:l[o])}):s[n]===r[n])}onRender(s){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&s.length===0?Kbe.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(s),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(s){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=s;return}if(this.previousDeps.length===s.length&&this.previousDeps.every((n,a)=>n===s[a]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=s}scheduleDestroy(){const s=this.instanceId,r=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===s){r&&r.setOptions(this.options.current);return}r&&!r.isDestroyed&&(r.destroy(),this.instanceId===s&&this.setEditor(null))},1)}}function ZWe(t={},s=[]){const r=C.useRef(t);r.current=t;const[n]=C.useState(()=>new Kbe(r)),a=Gbe.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return C.useDebugValue(a),C.useEffect(n.onRender(s)),WPt({editor:a,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),a}const ZPt=C.createContext({editor:null});ZPt.Consumer;const YPt=C.createContext({onDragStart:void 0}),XPt=()=>C.useContext(YPt);ht.forwardRef((t,s)=>{const{onDragStart:r}=XPt(),n=t.as||"div";return ht.createElement(n,{...t,ref:s,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});const QPt=/^\s*>\s$/,JPt=fh.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",Ac(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[w6({find:QPt,type:this.type})]}}),eIt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,tIt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,sIt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,rIt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,nIt=hy.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",Ac(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[I3({find:eIt,type:this.type}),I3({find:sIt,type:this.type})]},addPasteRules(){return[Hk({find:tIt,type:this.type}),Hk({find:rIt,type:this.type})]}}),aIt="listItem",mAe="textStyle",pAe=/^\s*([-+*])\s$/,iIt=fh.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",Ac(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:s})=>this.options.keepAttributes?s().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(aIt,this.editor.getAttributes(mAe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=w6({find:pAe,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=w6({find:pAe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(mAe),editor:this.editor})),[t]}}),oIt=/(^|[^`])`([^`]+)`(?!`)/,lIt=/(^|[^`])`([^`]+)`(?!`)/g,cIt=hy.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Ac(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[I3({find:oIt,type:this.type})]},addPasteRules(){return[Hk({find:lIt,type:this.type})]}}),dIt=/^```([a-z]+)?[\s\n]$/,uIt=/^~~~([a-z]+)?[\s\n]$/,hIt=fh.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var s;const{languageClassPrefix:r}=this.options,o=[...((s=t.firstElementChild)===null||s===void 0?void 0:s.classList)||[]].filter(l=>l.startsWith(r)).map(l=>l.replace(r,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:s}){return["pre",Ac(this.options.HTMLAttributes,s),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:s})=>s.setNode(this.name,t),toggleCodeBlock:t=>({commands:s})=>s.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:s}=this.editor.state.selection,r=s.pos===1;return!t||s.parent.type.name!==this.name?!1:r||!s.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:s}=t,{selection:r}=s,{$from:n,empty:a}=r;if(!a||n.parent.type!==this.type)return!1;const o=n.parentOffset===n.parent.nodeSize-2,l=n.parent.textContent.endsWith(` `);return!o||!l?!1:t.chain().command(({tr:i})=>(i.delete(n.pos-2,n.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:s}=t,{selection:r,doc:n}=s,{$from:a,empty:o}=r;if(!o||a.parent.type!==this.type||!(a.parentOffset===a.parent.nodeSize-2))return!1;const i=a.after();return i===void 0?!1:n.nodeAt(i)?t.commands.command(({tr:u})=>(u.setSelection(ni.near(n.resolve(i))),!0)):t.commands.exitCode()}}},addInputRules(){return[Zxe({find:dIt,type:this.type,getAttributes:t=>({language:t[1]})}),Zxe({find:uIt,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Yd({key:new ph("codeBlockVSCodeHandler"),props:{handlePaste:(t,s)=>{if(!s.clipboardData||this.editor.isActive(this.type.name))return!1;const r=s.clipboardData.getData("text/plain"),n=s.clipboardData.getData("vscode-editor-data"),a=n?JSON.parse(n):void 0,o=a==null?void 0:a.mode;if(!r||!o)return!1;const{tr:l,schema:i}=t.state,d=i.text(r.replace(/\r\n?/g,` `));return l.replaceSelectionWith(this.type.create({language:o},d)),l.selection.$from.parent.type!==this.type&&l.setSelection(qa.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),mIt=fh.create({name:"doc",topNode:!0,content:"block+"});function pIt(t={}){return new Yd({view(s){return new fIt(s,t)}})}class fIt{constructor(s,r){var n;this.editorView=s,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=r.width)!==null&&n!==void 0?n:1,this.color=r.color===!1?void 0:r.color||"black",this.class=r.class,this.handlers=["dragover","dragend","drop","dragleave"].map(a=>{let o=l=>{this[a](l)};return s.dom.addEventListener(a,o),{name:a,handler:o}})}destroy(){this.handlers.forEach(({name:s,handler:r})=>this.editorView.dom.removeEventListener(s,r))}update(s,r){this.cursorPos!=null&&r.doc!=s.state.doc&&(this.cursorPos>s.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(s){s!=this.cursorPos&&(this.cursorPos=s,s==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let s=this.editorView.state.doc.resolve(this.cursorPos),r=!s.parent.inlineContent,n,a=this.editorView.dom,o=a.getBoundingClientRect(),l=o.width/a.offsetWidth,i=o.height/a.offsetHeight;if(r){let f=s.nodeBefore,y=s.nodeAfter;if(f||y){let _=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(_){let b=_.getBoundingClientRect(),w=f?b.bottom:b.top;f&&y&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let j=this.width/2*i;n={left:b.left,right:b.right,top:w-j,bottom:w+j}}}}if(!n){let f=this.editorView.coordsAtPos(this.cursorPos),y=this.width/2*l;n={left:f.left-y,right:f.left+y,top:f.top,bottom:f.bottom}}let d=this.editorView.dom.offsetParent;this.element||(this.element=d.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",r),this.element.classList.toggle("prosemirror-dropcursor-inline",!r);let u,p;if(!d||d==document.body&&getComputedStyle(d).position=="static")u=-pageXOffset,p=-pageYOffset;else{let f=d.getBoundingClientRect(),y=f.width/d.offsetWidth,_=f.height/d.offsetHeight;u=f.left-d.scrollLeft*y,p=f.top-d.scrollTop*_}this.element.style.left=(n.left-u)/l+"px",this.element.style.top=(n.top-p)/i+"px",this.element.style.width=(n.right-n.left)/l+"px",this.element.style.height=(n.bottom-n.top)/i+"px"}scheduleRemoval(s){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),s)}dragover(s){if(!this.editorView.editable)return;let r=this.editorView.posAtCoords({left:s.clientX,top:s.clientY}),n=r&&r.inside>=0&&this.editorView.state.doc.nodeAt(r.inside),a=n&&n.type.spec.disableDropCursor,o=typeof a=="function"?a(this.editorView,r,s):a;if(r&&!o){let l=r.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let i=PHe(this.editorView.state.doc,l,this.editorView.dragging.slice);i!=null&&(l=i)}this.setCursor(l),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(s){this.editorView.dom.contains(s.relatedTarget)||this.setCursor(null)}}const gIt=Uu.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[pIt(this.options)]}});class qc extends ni{constructor(s){super(s,s)}map(s,r){let n=s.resolve(r.map(this.head));return qc.valid(n)?new qc(n):ni.near(n)}content(){return fn.empty}eq(s){return s instanceof qc&&s.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(s,r){if(typeof r.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new qc(s.resolve(r.pos))}getBookmark(){return new Zbe(this.anchor)}static valid(s){let r=s.parent;if(r.isTextblock||!xIt(s)||!yIt(s))return!1;let n=r.type.spec.allowGapCursor;if(n!=null)return n;let a=r.contentMatchAt(s.index()).defaultType;return a&&a.isTextblock}static findGapCursorFrom(s,r,n=!1){e:for(;;){if(!n&&qc.valid(s))return s;let a=s.pos,o=null;for(let l=s.depth;;l--){let i=s.node(l);if(r>0?s.indexAfter(l)0){o=i.child(r>0?s.indexAfter(l):s.index(l)-1);break}else if(l==0)return null;a+=r;let d=s.doc.resolve(a);if(qc.valid(d))return d}for(;;){let l=r>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!La.isSelectable(o)){s=s.doc.resolve(a+o.nodeSize*r),n=!1;continue e}break}o=l,a+=r;let i=s.doc.resolve(a);if(qc.valid(i))return i}return null}}}qc.prototype.visible=!1;qc.findFrom=qc.findGapCursorFrom;ni.jsonID("gapcursor",qc);class Zbe{constructor(s){this.pos=s}map(s){return new Zbe(s.map(this.pos))}resolve(s){let r=s.resolve(this.pos);return qc.valid(r)?new qc(r):ni.near(r)}}function YWe(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function xIt(t){for(let s=t.depth;s>=0;s--){let r=t.index(s),n=t.node(s);if(r==0){if(n.type.spec.isolating)return!0;continue}for(let a=n.child(r-1);;a=a.lastChild){if(a.childCount==0&&!a.inlineContent||YWe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function yIt(t){for(let s=t.depth;s>=0;s--){let r=t.indexAfter(s),n=t.node(s);if(r==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let a=n.child(r);;a=a.firstChild){if(a.childCount==0&&!a.inlineContent||YWe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function vIt(){return new Yd({props:{decorations:jIt,createSelectionBetween(t,s,r){return s.pos==r.pos&&qc.valid(r)?new qc(r):null},handleClick:bIt,handleKeyDown:_It,handleDOMEvents:{beforeinput:wIt}}})}const _It=Lbe({ArrowLeft:oR("horiz",-1),ArrowRight:oR("horiz",1),ArrowUp:oR("vert",-1),ArrowDown:oR("vert",1)});function oR(t,s){const r=t=="vert"?s>0?"down":"up":s>0?"right":"left";return function(n,a,o){let l=n.selection,i=s>0?l.$to:l.$from,d=l.empty;if(l instanceof qa){if(!o.endOfTextblock(r)||i.depth==0)return!1;d=!1,i=n.doc.resolve(s>0?i.after():i.before())}let u=qc.findGapCursorFrom(i,s,d);return u?(a&&a(n.tr.setSelection(new qc(u))),!0):!1}}function bIt(t,s,r){if(!t||!t.editable)return!1;let n=t.state.doc.resolve(s);if(!qc.valid(n))return!1;let a=t.posAtCoords({left:r.clientX,top:r.clientY});return a&&a.inside>-1&&La.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new qc(n))),!0)}function wIt(t,s){if(s.inputType!="insertCompositionText"||!(t.state.selection instanceof qc))return!1;let{$from:r}=t.state.selection,n=r.parent.contentMatchAt(r.index()).findWrapping(t.state.schema.nodes.text);if(!n)return!1;let a=Tr.empty;for(let l=n.length-1;l>=0;l--)a=Tr.from(n[l].createAndFill(null,a));let o=t.state.tr.replace(r.pos,r.pos,new fn(a,0,0));return o.setSelection(qa.near(o.doc.resolve(r.pos+1))),t.dispatch(o),!1}function jIt(t){if(!(t.selection instanceof qc))return null;let s=document.createElement("div");return s.className="ProseMirror-gapcursor",$c.create(t.doc,[Fh.widget(t.selection.head,s,{key:"gapcursor"})])}const NIt=Uu.create({name:"gapCursor",addProseMirrorPlugins(){return[vIt()]},extendNodeSchema(t){var s;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(s=Hi(ea(t,"allowGapCursor",r)))!==null&&s!==void 0?s:null}}}),kIt=fh.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Ac(this.options.HTMLAttributes,t)]},renderText(){return` `},addCommands(){return{setHardBreak:()=>({commands:t,chain:s,state:r,editor:n})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:a,storedMarks:o}=r;if(a.$from.parent.type.spec.isolating)return!1;const{keepMarks:l}=this.options,{splittableMarks:i}=n.extensionManager,d=o||a.$to.parentOffset&&a.$from.marks();return s().insertContent({type:this.name}).command(({tr:u,dispatch:p})=>{if(p&&d&&l){const f=d.filter(y=>i.includes(y.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),SIt=fh.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:s}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Ac(this.options.HTMLAttributes,s),0]},addCommands(){return{setHeading:t=>({commands:s})=>this.options.levels.includes(t.level)?s.setNode(this.name,t):!1,toggleHeading:t=>({commands:s})=>this.options.levels.includes(t.level)?s.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,s)=>({...t,[`Mod-Alt-${s}`]:()=>this.editor.commands.toggleHeading({level:s})}),{})},addInputRules(){return this.options.levels.map(t=>Zxe({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var lae=200,yu=function(){};yu.prototype.append=function(s){return s.length?(s=yu.from(s),!this.length&&s||s.length=r?yu.empty:this.sliceInner(Math.max(0,s),Math.min(this.length,r))};yu.prototype.get=function(s){if(!(s<0||s>=this.length))return this.getInner(s)};yu.prototype.forEach=function(s,r,n){r===void 0&&(r=0),n===void 0&&(n=this.length),r<=n?this.forEachInner(s,r,n,0):this.forEachInvertedInner(s,r,n,0)};yu.prototype.map=function(s,r,n){r===void 0&&(r=0),n===void 0&&(n=this.length);var a=[];return this.forEach(function(o,l){return a.push(s(o,l))},r,n),a};yu.from=function(s){return s instanceof yu?s:s&&s.length?new XWe(s):yu.empty};var XWe=function(t){function s(n){t.call(this),this.values=n}t&&(s.__proto__=t),s.prototype=Object.create(t&&t.prototype),s.prototype.constructor=s;var r={length:{configurable:!0},depth:{configurable:!0}};return s.prototype.flatten=function(){return this.values},s.prototype.sliceInner=function(a,o){return a==0&&o==this.length?this:new s(this.values.slice(a,o))},s.prototype.getInner=function(a){return this.values[a]},s.prototype.forEachInner=function(a,o,l,i){for(var d=o;d=l;d--)if(a(this.values[d],i+d)===!1)return!1},s.prototype.leafAppend=function(a){if(this.length+a.length<=lae)return new s(this.values.concat(a.flatten()))},s.prototype.leafPrepend=function(a){if(this.length+a.length<=lae)return new s(a.flatten().concat(this.values))},r.length.get=function(){return this.values.length},r.depth.get=function(){return 0},Object.defineProperties(s.prototype,r),s}(yu);yu.empty=new XWe([]);var CIt=function(t){function s(r,n){t.call(this),this.left=r,this.right=n,this.length=r.length+n.length,this.depth=Math.max(r.depth,n.depth)+1}return t&&(s.__proto__=t),s.prototype=Object.create(t&&t.prototype),s.prototype.constructor=s,s.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},s.prototype.getInner=function(n){return ni&&this.right.forEachInner(n,Math.max(a-i,0),Math.min(this.length,o)-i,l+i)===!1)return!1},s.prototype.forEachInvertedInner=function(n,a,o,l){var i=this.left.length;if(a>i&&this.right.forEachInvertedInner(n,a-i,Math.max(o,i)-i,l+i)===!1||o=o?this.right.slice(n-o,a-o):this.left.slice(n,o).append(this.right.slice(0,a-o))},s.prototype.leafAppend=function(n){var a=this.right.leafAppend(n);if(a)return new s(this.left,a)},s.prototype.leafPrepend=function(n){var a=this.left.leafPrepend(n);if(a)return new s(a,this.right)},s.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new s(this.left,new s(this.right,n)):new s(this,n)},s}(yu);const MIt=500;class Lg{constructor(s,r){this.items=s,this.eventCount=r}popEvent(s,r){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let a,o;r&&(a=this.remapping(n,this.items.length),o=a.maps.length);let l=s.tr,i,d,u=[],p=[];return this.items.forEach((f,y)=>{if(!f.step){a||(a=this.remapping(n,y+1),o=a.maps.length),o--,p.push(f);return}if(a){p.push(new Ex(f.map));let _=f.step.map(a.slice(o)),b;_&&l.maybeStep(_).doc&&(b=l.mapping.maps[l.mapping.maps.length-1],u.push(new Ex(b,void 0,void 0,u.length+p.length))),o--,b&&a.appendMap(b,o)}else l.maybeStep(f.step);if(f.selection)return i=a?f.selection.map(a.slice(o)):f.selection,d=new Lg(this.items.slice(0,n).append(p.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:d,transform:l,selection:i}}addTransform(s,r,n,a){let o=[],l=this.eventCount,i=this.items,d=!a&&i.length?i.get(i.length-1):null;for(let p=0;pAIt&&(i=TIt(i,u),l-=u),new Lg(i.append(o),l)}remapping(s,r){let n=new f6;return this.items.forEach((a,o)=>{let l=a.mirrorOffset!=null&&o-a.mirrorOffset>=s?n.maps.length-a.mirrorOffset:void 0;n.appendMap(a.map,l)},s,r),n}addMaps(s){return this.eventCount==0?this:new Lg(this.items.append(s.map(r=>new Ex(r))),this.eventCount)}rebased(s,r){if(!this.eventCount)return this;let n=[],a=Math.max(0,this.items.length-r),o=s.mapping,l=s.steps.length,i=this.eventCount;this.items.forEach(y=>{y.selection&&i--},a);let d=r;this.items.forEach(y=>{let _=o.getMirror(--d);if(_==null)return;l=Math.min(l,_);let b=o.maps[_];if(y.step){let w=s.steps[_].invert(s.docs[_]),j=y.selection&&y.selection.map(o.slice(d+1,_));j&&i++,n.push(new Ex(b,w,j))}else n.push(new Ex(b))},a);let u=[];for(let y=r;yMIt&&(f=f.compress(this.items.length-n.length)),f}emptyItemCount(){let s=0;return this.items.forEach(r=>{r.step||s++}),s}compress(s=this.items.length){let r=this.remapping(0,s),n=r.maps.length,a=[],o=0;return this.items.forEach((l,i)=>{if(i>=s)a.push(l),l.selection&&o++;else if(l.step){let d=l.step.map(r.slice(n)),u=d&&d.getMap();if(n--,u&&r.appendMap(u,n),d){let p=l.selection&&l.selection.map(r.slice(n));p&&o++;let f=new Ex(u.invert(),d,p),y,_=a.length-1;(y=a.length&&a[_].merge(f))?a[_]=y:a.push(f)}}else l.map&&n--},this.items.length,0),new Lg(yu.from(a.reverse()),o)}}Lg.empty=new Lg(yu.empty,0);function TIt(t,s){let r;return t.forEach((n,a)=>{if(n.selection&&s--==0)return r=a,!1}),t.slice(r)}class Ex{constructor(s,r,n,a){this.map=s,this.step=r,this.selection=n,this.mirrorOffset=a}merge(s){if(this.step&&s.step&&!s.selection){let r=s.step.merge(this.step);if(r)return new Ex(r.getMap().invert(),r,this.selection)}}}class x1{constructor(s,r,n,a,o){this.done=s,this.undone=r,this.prevRanges=n,this.prevTime=a,this.prevComposition=o}}const AIt=20;function EIt(t,s,r,n){let a=r.getMeta(jk),o;if(a)return a.historyState;r.getMeta(LIt)&&(t=new x1(t.done,t.undone,null,0,-1));let l=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(l&&l.getMeta(jk))return l.getMeta(jk).redo?new x1(t.done.addTransform(r,void 0,n,Tre(s)),t.undone,fAe(r.mapping.maps),t.prevTime,t.prevComposition):new x1(t.done,t.undone.addTransform(r,void 0,n,Tre(s)),null,t.prevTime,t.prevComposition);if(r.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let i=r.getMeta("composition"),d=t.prevTime==0||!l&&t.prevComposition!=i&&(t.prevTime<(r.time||0)-n.newGroupDelay||!PIt(r,t.prevRanges)),u=l?Rme(t.prevRanges,r.mapping):fAe(r.mapping.maps);return new x1(t.done.addTransform(r,d?s.selection.getBookmark():void 0,n,Tre(s)),Lg.empty,u,r.time,i??t.prevComposition)}else return(o=r.getMeta("rebased"))?new x1(t.done.rebased(r,o),t.undone.rebased(r,o),Rme(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new x1(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),Rme(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function PIt(t,s){if(!s)return!1;if(!t.docChanged)return!0;let r=!1;return t.mapping.maps[0].forEach((n,a)=>{for(let o=0;o=s[o]&&(r=!0)}),r}function fAe(t){let s=[];for(let r=t.length-1;r>=0&&s.length==0;r--)t[r].forEach((n,a,o,l)=>s.push(o,l));return s}function Rme(t,s){if(!t)return null;let r=[];for(let n=0;n{let a=jk.getState(r);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(n){let o=IIt(a,r,t);o&&n(s?o.scrollIntoView():o)}return!0}}const JWe=QWe(!1,!0),eGe=QWe(!0,!0),OIt=Uu.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:s})=>JWe(t,s),redo:()=>({state:t,dispatch:s})=>eGe(t,s)}},addProseMirrorPlugins(){return[DIt(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),RIt=fh.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Ac(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:s})=>{if(!PPt(s,s.schema.nodes[this.name]))return!1;const{selection:r}=s,{$from:n,$to:a}=r,o=t();return n.parentOffset===0?o.insertContentAt({from:Math.max(n.pos-1,0),to:a.pos},{type:this.name}):ePt(r)?o.insertContentAt(a.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:l,dispatch:i})=>{var d;if(i){const{$to:u}=l.selection,p=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?l.setSelection(qa.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(La.create(l.doc,u.pos)):l.setSelection(qa.create(l.doc,u.pos));else{const f=(d=u.parent.type.contentMatch.defaultType)===null||d===void 0?void 0:d.create();f&&(l.insert(p,f),l.setSelection(qa.create(l.doc,p+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[HWe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),FIt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,zIt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,BIt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,$It=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,qIt=hy.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Ac(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[I3({find:FIt,type:this.type}),I3({find:BIt,type:this.type})]},addPasteRules(){return[Hk({find:zIt,type:this.type}),Hk({find:$It,type:this.type})]}}),UIt=fh.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Ac(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),VIt="listItem",xAe="textStyle",yAe=/^(\d+)\.\s$/,HIt=fh.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:s,...r}=t;return s===1?["ol",Ac(this.options.HTMLAttributes,r),0]:["ol",Ac(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:s})=>this.options.keepAttributes?s().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(VIt,this.editor.getAttributes(xAe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=w6({find:yAe,type:this.type,getAttributes:s=>({start:+s[1]}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=w6({find:yAe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:s=>({start:+s[1],...this.editor.getAttributes(xAe)}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1],editor:this.editor})),[t]}}),WIt=fh.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Ac(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),GIt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,KIt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,ZIt=hy.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Ac(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[I3({find:GIt,type:this.type})]},addPasteRules(){return[Hk({find:KIt,type:this.type})]}}),YIt=fh.create({name:"text",group:"inline"}),tGe=Uu.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(nIt.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(JPt.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(iIt.configure(this.options.bulletList)),this.options.code!==!1&&t.push(cIt.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(hIt.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(mIt.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(gIt.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(NIt.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(kIt.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(SIt.configure(this.options.heading)),this.options.history!==!1&&t.push(OIt.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(RIt.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(qIt.configure(this.options.italic)),this.options.listItem!==!1&&t.push(UIt.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(HIt.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(WIt.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(ZIt.configure(this.options.strike)),this.options.text!==!1&&t.push(YIt.configure(this.options.text)),t}}),XIt="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",QIt="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Qxe="numeric",Jxe="ascii",eye="alpha",mI="asciinumeric",qE="alphanumeric",tye="domain",sGe="emoji",JIt="scheme",e6t="slashscheme",zme="whitespace";function t6t(t,s){return t in s||(s[t]=[]),s[t]}function $N(t,s,r){s[Qxe]&&(s[mI]=!0,s[qE]=!0),s[Jxe]&&(s[mI]=!0,s[eye]=!0),s[mI]&&(s[qE]=!0),s[eye]&&(s[qE]=!0),s[qE]&&(s[tye]=!0),s[sGe]&&(s[tye]=!0);for(const n in s){const a=t6t(n,r);a.indexOf(t)<0&&a.push(t)}}function s6t(t,s){const r={};for(const n in s)s[n].indexOf(t)>=0&&(r[n]=!0);return r}function jm(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}jm.groups={};jm.prototype={accepts(){return!!this.t},go(t){const s=this,r=s.j[t];if(r)return r;for(let n=0;nt.ta(s,r,n,a),Lc=(t,s,r,n,a)=>t.tr(s,r,n,a),vAe=(t,s,r,n,a)=>t.ts(s,r,n,a),Wr=(t,s,r,n,a)=>t.tt(s,r,n,a),a0="WORD",sye="UWORD",rGe="ASCIINUMERICAL",nGe="ALPHANUMERICAL",j6="LOCALHOST",rye="TLD",nye="UTLD",Are="SCHEME",A4="SLASH_SCHEME",Ybe="NUM",aye="WS",Xbe="NL",pI="OPENBRACE",fI="CLOSEBRACE",cae="OPENBRACKET",dae="CLOSEBRACKET",uae="OPENPAREN",hae="CLOSEPAREN",mae="OPENANGLEBRACKET",pae="CLOSEANGLEBRACKET",fae="FULLWIDTHLEFTPAREN",gae="FULLWIDTHRIGHTPAREN",xae="LEFTCORNERBRACKET",yae="RIGHTCORNERBRACKET",vae="LEFTWHITECORNERBRACKET",_ae="RIGHTWHITECORNERBRACKET",bae="FULLWIDTHLESSTHAN",wae="FULLWIDTHGREATERTHAN",jae="AMPERSAND",Nae="APOSTROPHE",kae="ASTERISK",y1="AT",Sae="BACKSLASH",Cae="BACKTICK",Mae="CARET",S1="COLON",Qbe="COMMA",Tae="DOLLAR",Px="DOT",Aae="EQUALS",Jbe="EXCLAMATION",Zp="HYPHEN",gI="PERCENT",Eae="PIPE",Pae="PLUS",Iae="POUND",xI="QUERY",ewe="QUOTE",aGe="FULLWIDTHMIDDLEDOT",twe="SEMI",Ix="SLASH",yI="TILDE",Lae="UNDERSCORE",iGe="EMOJI",Dae="SYM";var oGe=Object.freeze({__proto__:null,ALPHANUMERICAL:nGe,AMPERSAND:jae,APOSTROPHE:Nae,ASCIINUMERICAL:rGe,ASTERISK:kae,AT:y1,BACKSLASH:Sae,BACKTICK:Cae,CARET:Mae,CLOSEANGLEBRACKET:pae,CLOSEBRACE:fI,CLOSEBRACKET:dae,CLOSEPAREN:hae,COLON:S1,COMMA:Qbe,DOLLAR:Tae,DOT:Px,EMOJI:iGe,EQUALS:Aae,EXCLAMATION:Jbe,FULLWIDTHGREATERTHAN:wae,FULLWIDTHLEFTPAREN:fae,FULLWIDTHLESSTHAN:bae,FULLWIDTHMIDDLEDOT:aGe,FULLWIDTHRIGHTPAREN:gae,HYPHEN:Zp,LEFTCORNERBRACKET:xae,LEFTWHITECORNERBRACKET:vae,LOCALHOST:j6,NL:Xbe,NUM:Ybe,OPENANGLEBRACKET:mae,OPENBRACE:pI,OPENBRACKET:cae,OPENPAREN:uae,PERCENT:gI,PIPE:Eae,PLUS:Pae,POUND:Iae,QUERY:xI,QUOTE:ewe,RIGHTCORNERBRACKET:yae,RIGHTWHITECORNERBRACKET:_ae,SCHEME:Are,SEMI:twe,SLASH:Ix,SLASH_SCHEME:A4,SYM:Dae,TILDE:yI,TLD:rye,UNDERSCORE:Lae,UTLD:nye,UWORD:sye,WORD:a0,WS:aye});const Jy=/[a-z]/,pE=new RegExp("\\p{L}","u"),Bme=new RegExp("\\p{Emoji}","u"),e0=/\d/,$me=/\s/,_Ae="\r",qme=` `,r6t="️",n6t="‍",Ume="";let lR=null,cR=null;function a6t(t=[]){const s={};jm.groups=s;const r=new jm;lR==null&&(lR=bAe(XIt)),cR==null&&(cR=bAe(QIt)),Wr(r,"'",Nae),Wr(r,"{",pI),Wr(r,"}",fI),Wr(r,"[",cae),Wr(r,"]",dae),Wr(r,"(",uae),Wr(r,")",hae),Wr(r,"<",mae),Wr(r,">",pae),Wr(r,"(",fae),Wr(r,")",gae),Wr(r,"「",xae),Wr(r,"」",yae),Wr(r,"『",vae),Wr(r,"』",_ae),Wr(r,"<",bae),Wr(r,">",wae),Wr(r,"&",jae),Wr(r,"*",kae),Wr(r,"@",y1),Wr(r,"`",Cae),Wr(r,"^",Mae),Wr(r,":",S1),Wr(r,",",Qbe),Wr(r,"$",Tae),Wr(r,".",Px),Wr(r,"=",Aae),Wr(r,"!",Jbe),Wr(r,"-",Zp),Wr(r,"%",gI),Wr(r,"|",Eae),Wr(r,"+",Pae),Wr(r,"#",Iae),Wr(r,"?",xI),Wr(r,'"',ewe),Wr(r,"/",Ix),Wr(r,";",twe),Wr(r,"~",yI),Wr(r,"_",Lae),Wr(r,"\\",Sae),Wr(r,"・",aGe);const n=Lc(r,e0,Ybe,{[Qxe]:!0});Lc(n,e0,n);const a=Lc(n,Jy,rGe,{[mI]:!0}),o=Lc(n,pE,nGe,{[qE]:!0}),l=Lc(r,Jy,a0,{[Jxe]:!0});Lc(l,e0,a),Lc(l,Jy,l),Lc(a,e0,a),Lc(a,Jy,a);const i=Lc(r,pE,sye,{[eye]:!0});Lc(i,Jy),Lc(i,e0,o),Lc(i,pE,i),Lc(o,e0,o),Lc(o,Jy),Lc(o,pE,o);const d=Wr(r,qme,Xbe,{[zme]:!0}),u=Wr(r,_Ae,aye,{[zme]:!0}),p=Lc(r,$me,aye,{[zme]:!0});Wr(r,Ume,p),Wr(u,qme,d),Wr(u,Ume,p),Lc(u,$me,p),Wr(p,_Ae),Wr(p,qme),Lc(p,$me,p),Wr(p,Ume,p);const f=Lc(r,Bme,iGe,{[sGe]:!0});Wr(f,"#"),Lc(f,Bme,f),Wr(f,r6t,f);const y=Wr(f,n6t);Wr(y,"#"),Lc(y,Bme,f);const _=[[Jy,l],[e0,a]],b=[[Jy,null],[pE,i],[e0,o]];for(let w=0;ww[0]>j[0]?1:-1);for(let w=0;w=0?S[tye]=!0:Jy.test(j)?e0.test(j)?S[mI]=!0:S[Jxe]=!0:S[Qxe]=!0,vAe(r,j,j,S)}return vAe(r,"localhost",j6,{ascii:!0}),r.jd=new jm(Dae),{start:r,tokens:Object.assign({groups:s},oGe)}}function lGe(t,s){const r=i6t(s.replace(/[A-Z]/g,i=>i.toLowerCase())),n=r.length,a=[];let o=0,l=0;for(;l=0&&(f+=r[l].length,y++),u+=r[l].length,o+=r[l].length,l++;o-=f,l-=y,u-=f,a.push({t:p.t,v:s.slice(o-u,o),s:o-u,e:o})}return a}function i6t(t){const s=[],r=t.length;let n=0;for(;n56319||n+1===r||(o=t.charCodeAt(n+1))<56320||o>57343?t[n]:t.slice(n,n+2);s.push(l),n+=l.length}return s}function n1(t,s,r,n,a){let o;const l=s.length;for(let i=0;i=0;)o++;if(o>0){s.push(r.join(""));for(let l=parseInt(t.substring(n,n+o),10);l>0;l--)r.pop();n+=o}else r.push(t[n]),n++}return s}const N6={defaultProtocol:"http",events:null,format:wAe,formatHref:wAe,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function swe(t,s=null){let r=Object.assign({},N6);t&&(r=Object.assign(r,t instanceof swe?t.o:t));const n=r.ignoreTags,a=[];for(let o=0;or?n.substring(0,r)+"…":n},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=N6.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const s=this,r=this.toHref(t.get("defaultProtocol")),n=t.get("formatHref",r,this),a=t.get("tagName",r,s),o=this.toFormattedString(t),l={},i=t.get("className",r,s),d=t.get("target",r,s),u=t.get("rel",r,s),p=t.getObj("attributes",r,s),f=t.getObj("events",r,s);return l.href=n,i&&(l.class=i),d&&(l.target=d),u&&(l.rel=u),p&&Object.assign(l,p),{tagName:a,attributes:l,content:o,eventListeners:f}}};function Tle(t,s){class r extends cGe{constructor(a,o){super(a,o),this.t=t}}for(const n in s)r.prototype[n]=s[n];return r.t=t,r}const jAe=Tle("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),NAe=Tle("text"),o6t=Tle("nl"),dR=Tle("url",{isLink:!0,toHref(t=N6.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==j6&&t[1].t===S1}}),Hp=t=>new jm(t);function l6t({groups:t}){const s=t.domain.concat([jae,kae,y1,Sae,Cae,Mae,Tae,Aae,Zp,Ybe,gI,Eae,Pae,Iae,Ix,Dae,yI,Lae]),r=[Nae,S1,Qbe,Px,Jbe,gI,xI,ewe,twe,mae,pae,pI,fI,dae,cae,uae,hae,fae,gae,xae,yae,vae,_ae,bae,wae],n=[jae,Nae,kae,Sae,Cae,Mae,Tae,Aae,Zp,pI,fI,gI,Eae,Pae,Iae,xI,Ix,Dae,yI,Lae],a=Hp(),o=Wr(a,yI);Vi(o,n,o),Vi(o,t.domain,o);const l=Hp(),i=Hp(),d=Hp();Vi(a,t.domain,l),Vi(a,t.scheme,i),Vi(a,t.slashscheme,d),Vi(l,n,o),Vi(l,t.domain,l);const u=Wr(l,y1);Wr(o,y1,u),Wr(i,y1,u),Wr(d,y1,u);const p=Wr(o,Px);Vi(p,n,o),Vi(p,t.domain,o);const f=Hp();Vi(u,t.domain,f),Vi(f,t.domain,f);const y=Wr(f,Px);Vi(y,t.domain,f);const _=Hp(jAe);Vi(y,t.tld,_),Vi(y,t.utld,_),Wr(u,j6,_);const b=Wr(f,Zp);Wr(b,Zp,b),Vi(b,t.domain,f),Vi(_,t.domain,f),Wr(_,Px,y),Wr(_,Zp,b);const w=Wr(_,S1);Vi(w,t.numeric,jAe);const j=Wr(l,Zp),k=Wr(l,Px);Wr(j,Zp,j),Vi(j,t.domain,l),Vi(k,n,o),Vi(k,t.domain,l);const S=Hp(dR);Vi(k,t.tld,S),Vi(k,t.utld,S),Vi(S,t.domain,l),Vi(S,n,o),Wr(S,Px,k),Wr(S,Zp,j),Wr(S,y1,u);const T=Wr(S,S1),I=Hp(dR);Vi(T,t.numeric,I);const L=Hp(dR),R=Hp();Vi(L,s,L),Vi(L,r,R),Vi(R,s,L),Vi(R,r,R),Wr(S,Ix,L),Wr(I,Ix,L);const $=Wr(i,S1),q=Wr(d,S1),U=Wr(q,Ix),H=Wr(U,Ix);Vi(i,t.domain,l),Wr(i,Px,k),Wr(i,Zp,j),Vi(d,t.domain,l),Wr(d,Px,k),Wr(d,Zp,j),Vi($,t.domain,L),Wr($,Ix,L),Wr($,xI,L),Vi(H,t.domain,L),Vi(H,s,L),Wr(H,Ix,L);const Y=[[pI,fI],[cae,dae],[uae,hae],[mae,pae],[fae,gae],[xae,yae],[vae,_ae],[bae,wae]];for(let se=0;se=0&&y++,a++,p++;if(y<0)a-=p,a0&&(o.push(Vme(NAe,s,l)),l=[]),a-=y,p-=y;const _=f.t,b=r.slice(a-p,a);o.push(Vme(_,s,b))}}return l.length>0&&o.push(Vme(NAe,s,l)),o}function Vme(t,s,r){const n=r[0].s,a=r[r.length-1].e,o=s.slice(n,a);return new t(o,r)}const d6t=typeof console<"u"&&console&&console.warn||(()=>{}),u6t="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Ql={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function h6t(){return jm.groups={},Ql.scanner=null,Ql.parser=null,Ql.tokenQueue=[],Ql.pluginQueue=[],Ql.customSchemes=[],Ql.initialized=!1,Ql}function kAe(t,s=!1){if(Ql.initialized&&d6t(`linkifyjs: already initialized - will not register custom scheme "${t}" ${u6t}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format. 1. Must only contain digits, lowercase ASCII letters or "-" 2. Cannot start or end with "-" 3. "-" cannot repeat`);Ql.customSchemes.push([t,s])}function m6t(){Ql.scanner=a6t(Ql.customSchemes);for(let t=0;t{const a=s.some(u=>u.docChanged)&&!r.doc.eq(n.doc),o=s.some(u=>u.getMeta("preventAutolink"));if(!a||o)return;const{tr:l}=n,i=HEt(r.doc,[...s]);if(QEt(i).forEach(({newRange:u})=>{const p=GEt(n.doc,u,_=>_.isTextblock);let f,y;if(p.length>1)f=p[0],y=n.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(p.length){const _=n.doc.textBetween(u.from,u.to," "," ");if(!f6t.test(_))return;f=p[0],y=n.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&y){const _=y.split(p6t).filter(Boolean);if(_.length<=0)return!1;const b=_[_.length-1],w=f.pos+y.lastIndexOf(b);if(!b)return!1;const j=rwe(b).map(k=>k.toObject(t.defaultProtocol));if(!x6t(j))return!1;j.filter(k=>k.isLink).map(k=>({...k,from:w+k.start+1,to:w+k.end+1})).filter(k=>n.schema.marks.code?!n.doc.rangeHasMark(k.from,k.to,n.schema.marks.code):!0).filter(k=>t.validate(k.value)).filter(k=>t.shouldAutoLink(k.value)).forEach(k=>{Hbe(k.from,k.to,n.doc).some(S=>S.mark.type===t.type)||l.addMark(k.from,k.to,t.type.create({href:k.href}))})}}),!!l.steps.length)return l}})}function v6t(t){return new Yd({key:new ph("handleClickLink"),props:{handleClick:(s,r,n)=>{var a,o;if(n.button!==0||!s.editable)return!1;let l=n.target;const i=[];for(;l.nodeName!=="DIV";)i.push(l),l=l.parentNode;if(!i.find(y=>y.nodeName==="A"))return!1;const d=VWe(s.state,t.type.name),u=n.target,p=(a=u==null?void 0:u.href)!==null&&a!==void 0?a:d.href,f=(o=u==null?void 0:u.target)!==null&&o!==void 0?o:d.target;return u&&p?(window.open(p,f),!0):!1}}})}function _6t(t){return new Yd({key:new ph("handlePasteLink"),props:{handlePaste:(s,r,n)=>{const{state:a}=s,{selection:o}=a,{empty:l}=o;if(l)return!1;let i="";n.content.forEach(u=>{i+=u.textContent});const d=dGe(i,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===i);return!i||!d?!1:t.editor.commands.setMark(t.type,{href:d.href})}}})}function sw(t,s){const r=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return s&&s.forEach(n=>{const a=typeof n=="string"?n:n.scheme;a&&r.push(a)}),!t||t.replace(g6t,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const uGe=hy.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){kAe(t);return}kAe(t.scheme,t.optionalSlashes)})},onDestroy(){h6t()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,s)=>!!sw(t,s.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const s=t.getAttribute("href");return!s||!this.options.isAllowedUri(s,{defaultValidate:r=>!!sw(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:s=>!!sw(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Ac(this.options.HTMLAttributes,t),0]:["a",Ac(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!sw(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?s().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!sw(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?s().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Hk({find:t=>{const s=[];if(t){const{protocols:r,defaultProtocol:n}=this.options,a=dGe(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!sw(l,r),protocols:r,defaultProtocol:n}));a.length&&a.forEach(o=>s.push({text:o.value,data:{href:o.href},index:o.start}))}return s},type:this.type,getAttributes:t=>{var s;return{href:(s=t.data)===null||s===void 0?void 0:s.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:s,defaultProtocol:r}=this.options;return this.options.autolink&&t.push(y6t({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:a=>!!sw(a,s),protocols:s,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(v6t({type:this.type})),this.options.linkOnPaste&&t.push(_6t({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),hGe=Uu.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const s=t.style.textAlign;return this.options.alignments.includes(s)?s:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:s})=>this.options.alignments.includes(t)?this.options.types.map(r=>s.updateAttributes(r,{textAlign:t})).every(r=>r):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(s=>t.resetAttributes(s,"textAlign")).every(s=>s),toggleTextAlign:t=>({editor:s,commands:r})=>this.options.alignments.includes(t)?s.isActive({textAlign:t})?r.unsetTextAlign():r.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),b6t=t=>{if(!t.children.length)return;const s=t.querySelectorAll("span");s&&s.forEach(r=>{var n,a;const o=r.getAttribute("style"),l=(a=(n=r.parentElement)===null||n===void 0?void 0:n.closest("span"))===null||a===void 0?void 0:a.getAttribute("style");r.setAttribute("style",`${l};${o}`)})},mGe=hy.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&b6t(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Ac(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:t})=>{const{selection:s}=t;return t.doc.nodesBetween(s.from,s.to,(r,n)=>{if(r.isTextblock)return!0;r.marks.filter(a=>a.type===this.type).some(a=>Object.values(a.attrs).some(o=>!!o))||t.removeMark(n,n+r.nodeSize,this.type)}),!0}}}}),w6t=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,j6t=fh.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Ac(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:s})=>s.insertContent({type:this.name,attrs:t})}},addInputRules(){return[HWe({find:w6t,type:this.type,getAttributes:t=>{const[,,s,r,n]=t;return{src:r,alt:s,title:n}}})]}});let iye,oye;if(typeof WeakMap<"u"){let t=new WeakMap;iye=s=>t.get(s),oye=(s,r)=>(t.set(s,r),r)}else{const t=[];let r=0;iye=n=>{for(let a=0;a(r==10&&(r=0),t[r++]=n,t[r++]=a)}var Uc=class{constructor(t,s,r,n){this.width=t,this.height=s,this.map=r,this.problems=n}findCell(t){for(let s=0;s=r){(o||(o=[])).push({type:"overlong_rowspan",pos:p,n:k-T});break}const I=a+T*s;for(let L=0;Ln&&(o+=u.attrs.colspan)}}for(let l=0;l1&&(r=!0)}s==-1?s=o:s!=o&&(s=Math.max(s,o))}return s}function S6t(t,s,r){t.problems||(t.problems=[]);const n={};for(let a=0;a0;s--)if(t.node(s).type.spec.tableRole=="row")return t.node(0).resolve(t.before(s+1));return null}function M6t(t){for(let s=t.depth;s>0;s--){const r=t.node(s).type.spec.tableRole;if(r==="cell"||r==="header_cell")return t.node(s)}return null}function sx(t){const s=t.selection.$head;for(let r=s.depth;r>0;r--)if(s.node(r).type.spec.tableRole=="row")return!0;return!1}function Ale(t){const s=t.selection;if("$anchorCell"in s&&s.$anchorCell)return s.$anchorCell.pos>s.$headCell.pos?s.$anchorCell:s.$headCell;if("node"in s&&s.node&&s.node.type.spec.tableRole=="cell")return s.$anchor;const r=IM(s.$head)||T6t(s.$head);if(r)return r;throw new RangeError(`No cell found around position ${s.head}`)}function T6t(t){for(let s=t.nodeAfter,r=t.pos;s;s=s.firstChild,r++){const n=s.type.spec.tableRole;if(n=="cell"||n=="header_cell")return t.doc.resolve(r)}for(let s=t.nodeBefore,r=t.pos;s;s=s.lastChild,r--){const n=s.type.spec.tableRole;if(n=="cell"||n=="header_cell")return t.doc.resolve(r-s.nodeSize)}}function lye(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function A6t(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function awe(t,s){return t.depth==s.depth&&t.pos>=s.start(-1)&&t.pos<=s.end(-1)}function pGe(t,s,r){const n=t.node(-1),a=Uc.get(n),o=t.start(-1),l=a.nextCell(t.pos-o,s,r);return l==null?null:t.node(0).resolve(o+l)}function Wk(t,s,r=1){const n={...t,colspan:t.colspan-r};return n.colwidth&&(n.colwidth=n.colwidth.slice(),n.colwidth.splice(s,r),n.colwidth.some(a=>a>0)||(n.colwidth=null)),n}function fGe(t,s,r=1){const n={...t,colspan:t.colspan+r};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let a=0;ap!=r.pos-o);d.unshift(r.pos-o);const u=d.map(p=>{const f=n.nodeAt(p);if(!f)throw new RangeError(`No cell with offset ${p} found`);const y=o+p+1;return new RHe(i.resolve(y),i.resolve(y+f.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=s,this.$headCell=r}map(s,r){const n=s.resolve(r.map(this.$anchorCell.pos)),a=s.resolve(r.map(this.$headCell.pos));if(lye(n)&&lye(a)&&awe(n,a)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?i0.rowSelection(n,a):o&&this.isColSelection()?i0.colSelection(n,a):new i0(n,a)}return qa.between(n,a)}content(){const s=this.$anchorCell.node(-1),r=Uc.get(s),n=this.$anchorCell.start(-1),a=r.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},l=[];for(let d=a.top;d0||j>0){let k=b.attrs;if(w>0&&(k=Wk(k,0,w)),j>0&&(k=Wk(k,k.colspan-j,j)),_.lefta.bottom){const k={...b.attrs,rowspan:Math.min(_.bottom,a.bottom)-Math.max(_.top,a.top)};_.top0)return!1;const n=s+this.$anchorCell.nodeAfter.attrs.rowspan,a=r+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,a)==this.$headCell.node(-1).childCount}static colSelection(s,r=s){const n=s.node(-1),a=Uc.get(n),o=s.start(-1),l=a.findCell(s.pos-o),i=a.findCell(r.pos-o),d=s.node(0);return l.top<=i.top?(l.top>0&&(s=d.resolve(o+a.map[l.left])),i.bottom0&&(r=d.resolve(o+a.map[i.left])),l.bottom0)return!1;const l=a+this.$anchorCell.nodeAfter.attrs.colspan,i=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(l,i)==r.width}eq(s){return s instanceof i0&&s.$anchorCell.pos==this.$anchorCell.pos&&s.$headCell.pos==this.$headCell.pos}static rowSelection(s,r=s){const n=s.node(-1),a=Uc.get(n),o=s.start(-1),l=a.findCell(s.pos-o),i=a.findCell(r.pos-o),d=s.node(0);return l.left<=i.left?(l.left>0&&(s=d.resolve(o+a.map[l.top*a.width])),i.right0&&(r=d.resolve(o+a.map[i.top*a.width])),l.right{s.push(Fh.node(n,n+r.nodeSize,{class:"selectedCell"}))}),$c.create(t.doc,s)}function L6t({$from:t,$to:s}){if(t.pos==s.pos||t.pos=0&&!(t.after(a+1)=0&&!(s.before(o+1)>s.start(o));o--,n--);return r==n&&/row|table/.test(t.node(a).type.spec.tableRole)}function D6t({$from:t,$to:s}){let r,n;for(let a=t.depth;a>0;a--){const o=t.node(a);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}for(let a=s.depth;a>0;a--){const o=s.node(a);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}return r!==n&&s.parentOffset===0}function O6t(t,s,r){const n=(s||t).selection,a=(s||t).doc;let o,l;if(n instanceof La&&(l=n.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=ql.create(a,n.from);else if(l=="row"){const i=a.resolve(n.from+1);o=ql.rowSelection(i,i)}else if(!r){const i=Uc.get(n.node),d=n.from+1,u=d+i.map[i.width*i.height-1];o=ql.create(a,d+1,u)}}else n instanceof qa&&L6t(n)?o=qa.create(a,n.from):n instanceof qa&&D6t(n)&&(o=qa.create(a,n.$from.start(),n.$from.end()));return o&&(s||(s=t.tr)).setSelection(o),s}const R6t=new ph("fix-tables");function xGe(t,s,r,n){const a=t.childCount,o=s.childCount;e:for(let l=0,i=0;l{a.type.spec.tableRole=="table"&&(r=F6t(t,a,o,r))};return s?s.doc!=t.doc&&xGe(s.doc,t.doc,0,n):t.doc.descendants(n),r}function F6t(t,s,r,n){const a=Uc.get(s);if(!a.problems)return n;n||(n=t.tr);const o=[];for(let d=0;d0){let _="cell";p.firstChild&&(_=p.firstChild.type.spec.tableRole);const b=[];for(let j=0;j0?-1:0;E6t(s,n,a+o)&&(o=a==0||a==s.width?null:0);for(let l=0;l0&&a0&&s.map[i-1]==d||a0?-1:0;U6t(s,n,a+i)&&(i=a==0||a==s.height?null:0);for(let u=0,p=s.width*a;u0&&a0&&f==s.map[p-s.width]){const y=r.nodeAt(f).attrs;t.setNodeMarkup(t.mapping.slice(i).map(f+n),null,{...y,rowspan:y.rowspan-1}),u+=y.colspan-1}else if(a0&&r[o]==r[o-1]||n.right0&&r[a]==r[a-t]||n.bottom0){const p=d+1+u.content.size,f=SAe(u)?d+1:p;o.replaceWith(f+n.tableStart,p+n.tableStart,i)}o.setSelection(new ql(o.doc.resolve(d+n.tableStart))),s(o)}return!0}function MAe(t,s){const r=uh(t.schema);return Z6t(({node:n})=>r[n.type.spec.tableRole])(t,s)}function Z6t(t){return(s,r)=>{const n=s.selection;let a,o;if(n instanceof ql){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;a=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var l;if(a=M6t(n.$from),!a)return!1;o=(l=IM(n.$from))===null||l===void 0?void 0:l.pos}if(a==null||o==null||a.attrs.colspan==1&&a.attrs.rowspan==1)return!1;if(r){let i=a.attrs;const d=[],u=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const p=_y(s),f=s.tr;for(let _=0;_{l.attrs[t]!==s&&o.setNodeMarkup(i,null,{...l.attrs,[t]:s})}):o.setNodeMarkup(a.pos,null,{...a.nodeAfter.attrs,[t]:s}),n(o)}return!0}}function X6t(t){return function(s,r){if(!sx(s))return!1;if(r){const n=uh(s.schema),a=_y(s),o=s.tr,l=a.map.cellsInRect(t=="column"?{left:a.left,top:0,right:a.right,bottom:a.map.height}:t=="row"?{left:0,top:a.top,right:a.map.width,bottom:a.bottom}:a),i=l.map(d=>a.table.nodeAt(d));for(let d=0;d{const _=y+o.tableStart,b=l.doc.nodeAt(_);b&&l.setNodeMarkup(_,f,b.attrs)}),n(l)}return!0}}k6("row",{useDeprecatedLogic:!0});k6("column",{useDeprecatedLogic:!0});const Q6t=k6("cell",{useDeprecatedLogic:!0});function J6t(t,s){if(s<0){const r=t.nodeBefore;if(r)return t.pos-r.nodeSize;for(let n=t.index(-1)-1,a=t.before();n>=0;n--){const o=t.node(-1).child(n),l=o.lastChild;if(l)return a-1-l.nodeSize;a-=o.nodeSize}}else{if(t.index()0;n--)if(r.node(n).type.spec.tableRole=="table")return s&&s(t.tr.delete(r.before(n),r.after(n)).scrollIntoView()),!0;return!1}function uR(t,s){const r=t.selection;if(!(r instanceof ql))return!1;if(s){const n=t.tr,a=uh(t.schema).cell.createAndFill().content;r.forEachCell((o,l)=>{o.content.eq(a)||n.replace(n.mapping.map(l+1),n.mapping.map(l+o.nodeSize-1),new fn(a,0,0))}),n.docChanged&&s(n)}return!0}function tLt(t){if(t.size===0)return null;let{content:s,openStart:r,openEnd:n}=t;for(;s.childCount==1&&(r>0&&n>0||s.child(0).type.spec.tableRole=="table");)r--,n--,s=s.child(0).content;const a=s.child(0),o=a.type.spec.tableRole,l=a.type.schema,i=[];if(o=="row")for(let d=0;d=0;l--){const{rowspan:i,colspan:d}=o.child(l).attrs;for(let u=a;u=s.length&&s.push(Tr.empty),r[a]n&&(y=y.type.createChecked(Wk(y.attrs,y.attrs.colspan,p+y.attrs.colspan-n),y.content)),u.push(y),p+=y.attrs.colspan;for(let _=1;_a&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,a-f.attrs.rowspan)},f.content)),d.push(f)}o.push(Tr.from(d))}r=o,s=a}return{width:t,height:s,rows:r}}function nLt(t,s,r,n,a,o,l){const i=t.doc.type.schema,d=uh(i);let u,p;if(a>s.width)for(let f=0,y=0;fs.height){const f=[];for(let b=0,w=(s.height-1)*s.width;b=s.width?!1:r.nodeAt(s.map[w+b]).type==d.header_cell;f.push(j?p||(p=d.header_cell.createAndFill()):u||(u=d.cell.createAndFill()))}const y=d.row.create(null,Tr.from(f)),_=[];for(let b=s.height;b{if(!a)return!1;const o=r.selection;if(o instanceof ql)return Ere(r,n,ni.near(o.$headCell,s));if(t!="horiz"&&!o.empty)return!1;const l=bGe(a,t,s);if(l==null)return!1;if(t=="horiz")return Ere(r,n,ni.near(r.doc.resolve(o.head+s),s));{const i=r.doc.resolve(l),d=pGe(i,t,s);let u;return d?u=ni.near(d,1):s<0?u=ni.near(r.doc.resolve(i.before(-1)),-1):u=ni.near(r.doc.resolve(i.after(-1)),1),Ere(r,n,u)}}}function mR(t,s){return(r,n,a)=>{if(!a)return!1;const o=r.selection;let l;if(o instanceof ql)l=o;else{const d=bGe(a,t,s);if(d==null)return!1;l=new ql(r.doc.resolve(d))}const i=pGe(l.$headCell,t,s);return i?Ere(r,n,new ql(l.$anchorCell,i)):!1}}function iLt(t,s){const r=t.state.doc,n=IM(r.resolve(s));return n?(t.dispatch(t.state.tr.setSelection(new ql(n))),!0):!1}function oLt(t,s,r){if(!sx(t.state))return!1;let n=tLt(r);const a=t.state.selection;if(a instanceof ql){n||(n={width:1,height:1,rows:[Tr.from(cye(uh(t.state.schema).cell,r))]});const o=a.$anchorCell.node(-1),l=a.$anchorCell.start(-1),i=Uc.get(o).rectBetween(a.$anchorCell.pos-l,a.$headCell.pos-l);return n=rLt(n,i.right-i.left,i.bottom-i.top),IAe(t.state,t.dispatch,l,i,n),!0}else if(n){const o=Ale(t.state),l=o.start(-1);return IAe(t.state,t.dispatch,l,Uc.get(o.node(-1)).findCell(o.pos-l),n),!0}else return!1}function lLt(t,s){var r;if(s.ctrlKey||s.metaKey)return;const n=LAe(t,s.target);let a;if(s.shiftKey&&t.state.selection instanceof ql)o(t.state.selection.$anchorCell,s),s.preventDefault();else if(s.shiftKey&&n&&(a=IM(t.state.selection.$anchor))!=null&&((r=Hme(t,s))===null||r===void 0?void 0:r.pos)!=a.pos)o(a,s),s.preventDefault();else if(!n)return;function o(d,u){let p=Hme(t,u);const f=C1.getState(t.state)==null;if(!p||!awe(d,p))if(f)p=d;else return;const y=new ql(d,p);if(f||!t.state.selection.eq(y)){const _=t.state.tr.setSelection(y);f&&_.setMeta(C1,d.pos),t.dispatch(_)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",i),C1.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(C1,-1))}function i(d){const u=d,p=C1.getState(t.state);let f;if(p!=null)f=t.state.doc.resolve(p);else if(LAe(t,u.target)!=n&&(f=Hme(t,s),!f))return l();f&&o(f,u)}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",i)}function bGe(t,s,r){if(!(t.state.selection instanceof qa))return null;const{$head:n}=t.state.selection;for(let a=n.depth-1;a>=0;a--){const o=n.node(a);if((r<0?n.index(a):n.indexAfter(a))!=(r<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const l=n.before(a),i=s=="vert"?r>0?"down":"up":r>0?"right":"left";return t.endOfTextblock(i)?l:null}}return null}function LAe(t,s){for(;s&&s!=t.dom;s=s.parentNode)if(s.nodeName=="TD"||s.nodeName=="TH")return s;return null}function Hme(t,s){const r=t.posAtCoords({left:s.clientX,top:s.clientY});if(!r)return null;const n=r.inside>=0?r.inside:r.pos;return IM(t.state.doc.resolve(n))}var cLt=class{constructor(s,r){this.node=s,this.defaultCellMinWidth=r,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${r}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),dye(s,this.colgroup,this.table,r),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(s){return s.type!=this.node.type?!1:(this.node=s,dye(s,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(s){return s.type=="attributes"&&(s.target==this.table||this.colgroup.contains(s.target))}};function dye(t,s,r,n,a,o){let l=0,i=!0,d=s.firstChild;const u=t.firstChild;if(u){for(let f=0,y=0;fnew n(f,r,y)),new uLt(-1,!1)},apply(l,i){return i.apply(l)}},props:{attributes:l=>{const i=mp.getState(l);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,i)=>{hLt(l,i,t,a)},mouseleave:l=>{mLt(l)},mousedown:(l,i)=>{pLt(l,i,s,r)}},decorations:l=>{const i=mp.getState(l);if(i&&i.activeHandle>-1)return vLt(l,i.activeHandle)},nodeViews:{}}});return o}var uLt=class Pre{constructor(s,r){this.activeHandle=s,this.dragging=r}apply(s){const r=this,n=s.getMeta(mp);if(n&&n.setHandle!=null)return new Pre(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new Pre(r.activeHandle,n.setDragging);if(r.activeHandle>-1&&s.docChanged){let a=s.mapping.map(r.activeHandle,-1);return lye(s.doc.resolve(a))||(a=-1),new Pre(a,r.dragging)}return r}};function hLt(t,s,r,n){if(!t.editable)return;const a=mp.getState(t.state);if(a&&!a.dragging){const o=gLt(s.target);let l=-1;if(o){const{left:i,right:d}=o.getBoundingClientRect();s.clientX-i<=r?l=DAe(t,s,"left",r):d-s.clientX<=r&&(l=DAe(t,s,"right",r))}if(l!=a.activeHandle){if(!n&&l!==-1){const i=t.state.doc.resolve(l),d=i.node(-1),u=Uc.get(d),p=i.start(-1);if(u.colCount(i.pos-p)+i.nodeAfter.attrs.colspan-1==u.width-1)return}wGe(t,l)}}}function mLt(t){if(!t.editable)return;const s=mp.getState(t.state);s&&s.activeHandle>-1&&!s.dragging&&wGe(t,-1)}function pLt(t,s,r,n){var a;if(!t.editable)return!1;const o=(a=t.dom.ownerDocument.defaultView)!==null&&a!==void 0?a:window,l=mp.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const i=t.state.doc.nodeAt(l.activeHandle),d=fLt(t,l.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(mp,{setDragging:{startX:s.clientX,startWidth:d}}));function u(f){o.removeEventListener("mouseup",u),o.removeEventListener("mousemove",p);const y=mp.getState(t.state);y!=null&&y.dragging&&(xLt(t,y.activeHandle,OAe(y.dragging,f,r)),t.dispatch(t.state.tr.setMeta(mp,{setDragging:null})))}function p(f){if(!f.which)return u(f);const y=mp.getState(t.state);if(y&&y.dragging){const _=OAe(y.dragging,f,r);RAe(t,y.activeHandle,_,n)}}return RAe(t,l.activeHandle,d,n),o.addEventListener("mouseup",u),o.addEventListener("mousemove",p),s.preventDefault(),!0}function fLt(t,s,{colspan:r,colwidth:n}){const a=n&&n[n.length-1];if(a)return a;const o=t.domAtPos(s);let l=o.node.childNodes[o.offset].offsetWidth,i=r;if(n)for(let d=0;d{const n=t.nodes[r];n.spec.tableRole&&(s[n.spec.tableRole]=n)}),t.cached.tableNodeTypes=s,s}function NLt(t,s,r,n,a){const o=jLt(t),l=[],i=[];for(let u=0;u{const{selection:s}=t.state;if(!kLt(s))return!1;let r=0;const n=UWe(s.ranges[0].$from,o=>o.type.name==="table");return n==null||n.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(r+=1)}),r===s.ranges.length?(t.commands.deleteTable(),!0):!1},SLt=fh.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:bLt,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:s}){const{colgroup:r,tableWidth:n,tableMinWidth:a}=wLt(t,this.options.cellMinWidth),o=["table",Ac(this.options.HTMLAttributes,s,{style:n?`width: ${n}`:`min-width: ${a}`}),r,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},o]:o},addCommands(){return{insertTable:({rows:t=3,cols:s=3,withHeaderRow:r=!0}={})=>({tr:n,dispatch:a,editor:o})=>{const l=NLt(o.schema,t,s,r);if(a){const i=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection(qa.near(n.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:s})=>z6t(t,s),addColumnAfter:()=>({state:t,dispatch:s})=>B6t(t,s),deleteColumn:()=>({state:t,dispatch:s})=>q6t(t,s),addRowBefore:()=>({state:t,dispatch:s})=>V6t(t,s),addRowAfter:()=>({state:t,dispatch:s})=>H6t(t,s),deleteRow:()=>({state:t,dispatch:s})=>G6t(t,s),deleteTable:()=>({state:t,dispatch:s})=>eLt(t,s),mergeCells:()=>({state:t,dispatch:s})=>CAe(t,s),splitCell:()=>({state:t,dispatch:s})=>MAe(t,s),toggleHeaderColumn:()=>({state:t,dispatch:s})=>k6("column")(t,s),toggleHeaderRow:()=>({state:t,dispatch:s})=>k6("row")(t,s),toggleHeaderCell:()=>({state:t,dispatch:s})=>Q6t(t,s),mergeOrSplit:()=>({state:t,dispatch:s})=>CAe(t,s)?!0:MAe(t,s),setCellAttribute:(t,s)=>({state:r,dispatch:n})=>Y6t(t,s)(r,n),goToNextCell:()=>({state:t,dispatch:s})=>AAe(1)(t,s),goToPreviousCell:()=>({state:t,dispatch:s})=>AAe(-1)(t,s),fixTables:()=>({state:t,dispatch:s})=>(s&&yGe(t),!0),setCellSelection:t=>({tr:s,dispatch:r})=>{if(r){const n=ql.create(s.doc,t.anchorCell,t.headCell);s.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:pR,"Mod-Backspace":pR,Delete:pR,"Mod-Delete":pR}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[dLt({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],_Lt({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const s={name:t.name,options:t.options,storage:t.storage};return{tableRole:Hi(ea(t,"tableRole",s))}}}),CLt=fh.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Ac(this.options.HTMLAttributes,t),0]}}),MLt=fh.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const s=t.getAttribute("colwidth");return s?s.split(",").map(n=>parseInt(n,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",Ac(this.options.HTMLAttributes,t),0]}}),TLt=fh.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const s=t.getAttribute("colwidth");return s?s.split(",").map(n=>parseInt(n,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",Ac(this.options.HTMLAttributes,t),0]}});function rx({content:t,onChange:s,placeholder:r="Enter content...",minHeight:n="150px",compact:a=!1}){const[o,l]=C.useState(!1),[i,d]=C.useState(""),[u,p]=C.useState(!0),f=ZWe({extensions:[tGe,uGe.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),hGe.configure({types:["heading","paragraph"]}),mGe,j6t.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),width:{default:null},height:{default:null},style:{default:null}}}}).configure({inline:!0,allowBase64:!0}),SLt.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},cellpadding:{default:null},cellspacing:{default:null},border:{default:null}}}}).configure({resizable:!1}),CLt.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null}}}}),MLt.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1},valign:{default:null}}}}),TLt.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1}}}})],content:t,onUpdate:({editor:w})=>{s(w.getHTML())},editorProps:{attributes:{class:"outline-none","data-placeholder":r},handlePaste:(w,j)=>{var S;const k=(S=j.clipboardData)==null?void 0:S.items;if(!k)return!1;for(const T of Array.from(k))if(T.type.startsWith("image/")){j.preventDefault();const I=T.getAsFile();if(!I)continue;const L=new FileReader;return L.onload=R=>{var q;const $=(q=R.target)==null?void 0:q.result;w.dispatch(w.state.tr.replaceSelectionWith(w.state.schema.nodes.image.create({src:$})))},L.readAsDataURL(I),!0}return!1}}});C.useEffect(()=>{f&&t!==f.getHTML()&&f.commands.setContent(t)},[t,f]);const y=()=>{if(!f)return;const w=f.getAttributes("link").href||"",j=f.getAttributes("link").target;d(w),p(j==="_blank"),l(!0)},_=()=>{f&&(i===""?f.chain().focus().extendMarkRange("link").unsetLink().run():f.chain().focus().extendMarkRange("link").setLink({href:i,target:u?"_blank":null,rel:u?"noopener noreferrer nofollow":null}).run(),l(!1),d(""))},b=()=>{f&&f.chain().focus().extendMarkRange("link").unsetLink().run()};return f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleHeading({level:1}).run(),className:f.isActive("heading",{level:1})?"bg-muted":"",title:"Heading 1",children:e.jsx(xP,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleHeading({level:2}).run(),className:f.isActive("heading",{level:2})?"bg-muted":"",title:"Heading 2",children:e.jsx(yP,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleBold().run(),className:f.isActive("bold")?"bg-muted":"",title:"Bold",children:e.jsx(h5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleItalic().run(),className:f.isActive("italic")?"bg-muted":"",title:"Italic",children:e.jsx(v5,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleBulletList().run(),className:f.isActive("bulletList")?"bg-muted":"",title:"Bullet List",children:e.jsx(Hh,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleOrderedList().run(),className:f.isActive("orderedList")?"bg-muted":"",title:"Numbered List",children:e.jsx(O0,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("left").run(),className:f.isActive({textAlign:"left"})?"bg-muted":"",title:"Align Left",children:e.jsx(c5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("center").run(),className:f.isActive({textAlign:"center"})?"bg-muted":"",title:"Align Center",children:e.jsx(l5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("right").run(),className:f.isActive({textAlign:"right"})?"bg-muted":"",title:"Align Right",children:e.jsx(d5,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:y,className:f.isActive("link")?"bg-muted":"",title:"Add Link",children:e.jsx(Do,{className:"h-4 w-4"})}),f.isActive("link")&&e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:b,title:"Remove Link",children:e.jsx(Do,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().undo().run(),disabled:!f.can().undo(),title:"Undo",children:e.jsx(A5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().redo().run(),disabled:!f.can().redo(),title:"Redo",children:e.jsx(M5,{className:"h-4 w-4"})})]}),e.jsx(GWe,{editor:f,className:"prose prose-sm max-w-none p-3 focus:outline-none [&_.ProseMirror]:outline-none [&_.ProseMirror_img]:max-w-none [&_.ProseMirror_table]:border-none [&_.ProseMirror_table]:border-collapse [&_.ProseMirror_td]:border-none [&_.ProseMirror_td]:p-0 [&_.ProseMirror_td]:align-top [&_.ProseMirror_th]:border-none [&_.ProseMirror_th]:p-0 [&_.ProseMirror_tr]:border-none",style:{minHeight:n}})]}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Insert Link"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"link-url",children:"URL"}),e.jsx(Re,{id:"link-url",value:i,onChange:w=>d(w.target.value),placeholder:"https://example.com"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Br,{id:"link-new-tab",checked:u,onCheckedChange:p}),e.jsx(ve,{htmlFor:"link-new-tab",children:"Open in new tab"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{type:"button",onClick:_,children:i?"Apply Link":"Remove Link"})]})]})})]}):null}var ALt=Object.defineProperty,ELt=(t,s,r)=>s in t?ALt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,dc=(t,s,r)=>ELt(t,typeof s!="symbol"?s+"":s,r);const Oae={x:0,y:0,width:0,height:0,unit:"px"},m4=(t,s,r)=>Math.min(Math.max(t,s),r),PLt=(...t)=>t.filter(s=>s&&typeof s=="string").join(" "),BAe=(t,s)=>t===s||t.width===s.width&&t.height===s.height&&t.x===s.x&&t.y===s.y&&t.unit===s.unit;function ILt(t,s,r,n){const a=Lx(t,r,n);return t.width&&(a.height=a.width/s),t.height&&(a.width=a.height*s),a.y+a.height>n&&(a.height=n-a.y,a.width=a.height*s),a.x+a.width>r&&(a.width=r-a.x,a.height=a.width/s),t.unit==="%"?v1(a,r,n):a}function LLt(t,s,r){const n=Lx(t,s,r);return n.x=(s-n.width)/2,n.y=(r-n.height)/2,t.unit==="%"?v1(n,s,r):n}function v1(t,s,r){return t.unit==="%"?{...Oae,...t,unit:"%"}:{unit:"%",x:t.x?t.x/s*100:0,y:t.y?t.y/r*100:0,width:t.width?t.width/s*100:0,height:t.height?t.height/r*100:0}}function Lx(t,s,r){return t.unit?t.unit==="px"?{...Oae,...t,unit:"px"}:{unit:"px",x:t.x?t.x*s/100:0,y:t.y?t.y*r/100:0,width:t.width?t.width*s/100:0,height:t.height?t.height*r/100:0}:{...Oae,...t,unit:"px"}}function $Ae(t,s,r,n,a,o=0,l=0,i=n,d=a){const u={...t};let p=Math.min(o,n),f=Math.min(l,a),y=Math.min(i,n),_=Math.min(d,a);s&&(s>1?(p=l?l*s:p,f=p/s,y=i*s):(f=o?o/s:f,p=f*s,_=d/s)),u.y<0&&(u.height=Math.max(u.height+u.y,f),u.y=0),u.x<0&&(u.width=Math.max(u.width+u.x,p),u.x=0);const b=n-(u.x+u.width);b<0&&(u.x=Math.min(u.x,n-p),u.width+=b);const w=a-(u.y+u.height);if(w<0&&(u.y=Math.min(u.y,a-f),u.height+=w),u.widthy&&((r==="sw"||r=="nw")&&(u.x-=y-u.width),u.width=y),u.height>_&&((r==="nw"||r=="ne")&&(u.y-=_-u.height),u.height=_),s){const j=u.width/u.height;if(js){const k=Math.max(u.height*s,p);(r==="sw"||r=="nw")&&(u.x-=k-u.width),u.width=k}}return u}function DLt(t,s,r,n){const a={...t};return s==="ArrowLeft"?n==="nw"?(a.x-=r,a.y-=r,a.width+=r,a.height+=r):n==="w"?(a.x-=r,a.width+=r):n==="sw"?(a.x-=r,a.width+=r,a.height+=r):n==="ne"?(a.y+=r,a.width-=r,a.height-=r):n==="e"?a.width-=r:n==="se"&&(a.width-=r,a.height-=r):s==="ArrowRight"&&(n==="nw"?(a.x+=r,a.y+=r,a.width-=r,a.height-=r):n==="w"?(a.x+=r,a.width-=r):n==="sw"?(a.x+=r,a.width-=r,a.height-=r):n==="ne"?(a.y-=r,a.width+=r,a.height+=r):n==="e"?a.width+=r:n==="se"&&(a.width+=r,a.height+=r)),s==="ArrowUp"?n==="nw"?(a.x-=r,a.y-=r,a.width+=r,a.height+=r):n==="n"?(a.y-=r,a.height+=r):n==="ne"?(a.y-=r,a.width+=r,a.height+=r):n==="sw"?(a.x+=r,a.width-=r,a.height-=r):n==="s"?a.height-=r:n==="se"&&(a.width-=r,a.height-=r):s==="ArrowDown"&&(n==="nw"?(a.x+=r,a.y+=r,a.width-=r,a.height-=r):n==="n"?(a.y+=r,a.height-=r):n==="ne"?(a.y+=r,a.width-=r,a.height-=r):n==="sw"?(a.x-=r,a.width+=r,a.height+=r):n==="s"?a.height+=r:n==="se"&&(a.width+=r,a.height+=r)),a}const p4={capture:!0,passive:!1};let OLt=0;const u1=class vg extends C.PureComponent{constructor(){super(...arguments),dc(this,"docMoveBound",!1),dc(this,"mouseDownOnCrop",!1),dc(this,"dragStarted",!1),dc(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),dc(this,"componentRef",C.createRef()),dc(this,"mediaRef",C.createRef()),dc(this,"resizeObserver"),dc(this,"initChangeCalled",!1),dc(this,"instanceId",`rc-${OLt++}`),dc(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),dc(this,"onCropPointerDown",s=>{const{crop:r,disabled:n}=this.props,a=this.getBox();if(!r)return;const o=Lx(r,a.width,a.height);if(n)return;s.cancelable&&s.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const l=s.target.dataset.ord,i=!!l;let d=s.clientX,u=s.clientY,p=o.x,f=o.y;if(l){const y=s.clientX-a.x,_=s.clientY-a.y;let b=0,w=0;l==="ne"||l=="e"?(b=y-(o.x+o.width),w=_-o.y,p=o.x,f=o.y+o.height):l==="se"||l==="s"?(b=y-(o.x+o.width),w=_-(o.y+o.height),p=o.x,f=o.y):l==="sw"||l=="w"?(b=y-o.x,w=_-(o.y+o.height),p=o.x+o.width,f=o.y):(l==="nw"||l=="n")&&(b=y-o.x,w=_-o.y,p=o.x+o.width,f=o.y+o.height),d=p+a.x+b,u=f+a.y+w}this.evData={startClientX:d,startClientY:u,startCropX:p,startCropY:f,clientX:s.clientX,clientY:s.clientY,isResize:i,ord:l},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),dc(this,"onComponentPointerDown",s=>{const{crop:r,disabled:n,locked:a,keepSelection:o,onChange:l}=this.props,i=this.getBox();if(n||a||o&&r)return;s.cancelable&&s.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const d=s.clientX-i.x,u=s.clientY-i.y,p={unit:"px",x:d,y:u,width:0,height:0};this.evData={startClientX:s.clientX,startClientY:s.clientY,startCropX:d,startCropY:u,clientX:s.clientX,clientY:s.clientY,isResize:!0},this.mouseDownOnCrop=!0,l(Lx(p,i.width,i.height),v1(p,i.width,i.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),dc(this,"onDocPointerMove",s=>{const{crop:r,disabled:n,onChange:a,onDragStart:o}=this.props,l=this.getBox();if(n||!r||!this.mouseDownOnCrop)return;s.cancelable&&s.preventDefault(),this.dragStarted||(this.dragStarted=!0,o&&o(s));const{evData:i}=this;i.clientX=s.clientX,i.clientY=s.clientY;let d;i.isResize?d=this.resizeCrop():d=this.dragCrop(),BAe(r,d)||a(Lx(d,l.width,l.height),v1(d,l.width,l.height))}),dc(this,"onComponentKeyDown",s=>{const{crop:r,disabled:n,onChange:a,onComplete:o}=this.props;if(n)return;const l=s.key;let i=!1;if(!r)return;const d=this.getBox(),u=this.makePixelCrop(d),p=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?vg.nudgeStepLarge:s.shiftKey?vg.nudgeStepMedium:vg.nudgeStep;if(l==="ArrowLeft"?(u.x-=p,i=!0):l==="ArrowRight"?(u.x+=p,i=!0):l==="ArrowUp"?(u.y-=p,i=!0):l==="ArrowDown"&&(u.y+=p,i=!0),i){s.cancelable&&s.preventDefault(),u.x=m4(u.x,0,d.width-u.width),u.y=m4(u.y,0,d.height-u.height);const f=Lx(u,d.width,d.height),y=v1(u,d.width,d.height);a(f,y),o&&o(f,y)}}),dc(this,"onHandlerKeyDown",(s,r)=>{const{aspect:n=0,crop:a,disabled:o,minWidth:l=0,minHeight:i=0,maxWidth:d,maxHeight:u,onChange:p,onComplete:f}=this.props,y=this.getBox();if(o||!a)return;if(s.key==="ArrowUp"||s.key==="ArrowDown"||s.key==="ArrowLeft"||s.key==="ArrowRight")s.stopPropagation(),s.preventDefault();else return;const _=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?vg.nudgeStepLarge:s.shiftKey?vg.nudgeStepMedium:vg.nudgeStep,b=Lx(a,y.width,y.height),w=DLt(b,s.key,_,r),j=$Ae(w,n,r,y.width,y.height,l,i,d,u);if(!BAe(a,j)){const k=v1(j,y.width,y.height);p(j,k),f&&f(j,k)}}),dc(this,"onDocPointerDone",s=>{const{crop:r,disabled:n,onComplete:a,onDragEnd:o}=this.props,l=this.getBox();this.unbindDocMove(),!(n||!r)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,o&&o(s),a&&a(Lx(r,l.width,l.height),v1(r,l.width,l.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),dc(this,"onDragFocus",()=>{var s;(s=this.componentRef.current)==null||s.scrollTo(0,0)})}get document(){return document}getBox(){const s=this.mediaRef.current;if(!s)return{x:0,y:0,width:0,height:0};const{x:r,y:n,width:a,height:o}=s.getBoundingClientRect();return{x:r,y:n,width:a,height:o}}componentDidUpdate(s){const{crop:r,onComplete:n}=this.props;if(n&&!s.crop&&r){const{width:a,height:o}=this.getBox();a&&o&&n(Lx(r,a,o),v1(r,a,o))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,p4),this.document.addEventListener("pointerup",this.onDocPointerDone,p4),this.document.addEventListener("pointercancel",this.onDocPointerDone,p4),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,p4),this.document.removeEventListener("pointerup",this.onDocPointerDone,p4),this.document.removeEventListener("pointercancel",this.onDocPointerDone,p4),this.docMoveBound=!1)}getCropStyle(){const{crop:s}=this.props;if(s)return{top:`${s.y}${s.unit}`,left:`${s.x}${s.unit}`,width:`${s.width}${s.unit}`,height:`${s.height}${s.unit}`}}dragCrop(){const{evData:s}=this,r=this.getBox(),n=this.makePixelCrop(r),a=s.clientX-s.startClientX,o=s.clientY-s.startClientY;return n.x=m4(s.startCropX+a,0,r.width-n.width),n.y=m4(s.startCropY+o,0,r.height-n.height),n}getPointRegion(s,r,n,a){const{evData:o}=this,l=o.clientX-s.x,i=o.clientY-s.y;let d;a&&r?d=r==="nw"||r==="n"||r==="ne":d=i1?o?[o,o/r]:[l*r,l]:l?[l*r,l]:[o,o/r]}resizeCrop(){const{evData:s}=this,{aspect:r=0,maxWidth:n,maxHeight:a}=this.props,o=this.getBox(),[l,i]=this.resolveMinDimensions(o,r,this.props.minWidth,this.props.minHeight);let d=this.makePixelCrop(o);const u=this.getPointRegion(o,s.ord,l,i),p=s.ord||u;let f=s.clientX-s.startClientX,y=s.clientY-s.startClientY;(l&&p==="nw"||p==="w"||p==="sw")&&(f=Math.min(f,-l)),(i&&p==="nw"||p==="n"||p==="ne")&&(y=Math.min(y,-i));const _={unit:"px",x:0,y:0,width:0,height:0};u==="ne"?(_.x=s.startCropX,_.width=f,r?(_.height=_.width/r,_.y=s.startCropY-_.height):(_.height=Math.abs(y),_.y=s.startCropY-_.height)):u==="se"?(_.x=s.startCropX,_.y=s.startCropY,_.width=f,r?_.height=_.width/r:_.height=y):u==="sw"?(_.x=s.startCropX+f,_.y=s.startCropY,_.width=Math.abs(f),r?_.height=_.width/r:_.height=y):u==="nw"&&(_.x=s.startCropX+f,_.width=Math.abs(f),r?(_.height=_.width/r,_.y=s.startCropY-_.height):(_.height=Math.abs(y),_.y=s.startCropY+y));const b=$Ae(_,r,u,o.width,o.height,l,i,n,a);return r||vg.xyOrds.indexOf(p)>-1?d=b:vg.xOrds.indexOf(p)>-1?(d.x=b.x,d.width=b.width):vg.yOrds.indexOf(p)>-1&&(d.y=b.y,d.height=b.height),d.x=m4(d.x,0,o.width-d.width),d.y=m4(d.y,0,o.height-d.height),d}renderCropSelection(){const{ariaLabels:s=vg.defaultProps.ariaLabels,disabled:r,locked:n,renderSelectionAddon:a,ruleOfThirds:o,crop:l}=this.props,i=this.getCropStyle();if(l)return ht.createElement("div",{style:i,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":s.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!r&&!n&&ht.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},ht.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),ht.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),ht.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),ht.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":s.nwDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"nw"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":s.nDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"n"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":s.neDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"ne"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":s.eDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"e"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":s.seDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"se"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":s.sDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"s"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":s.swDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"sw"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":s.wDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"w"),role:"button"})),a&&ht.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:d=>d.stopPropagation()},a(this.state)),o&&ht.createElement(ht.Fragment,null,ht.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),ht.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(s){const r={...Oae,...this.props.crop||{}};return Lx(r,s.width,s.height)}render(){const{aspect:s,children:r,circularCrop:n,className:a,crop:o,disabled:l,locked:i,style:d,ruleOfThirds:u}=this.props,{cropIsActive:p,newCropIsBeingDrawn:f}=this.state,y=o?this.renderCropSelection():null,_=PLt("ReactCrop",a,p&&"ReactCrop--active",l&&"ReactCrop--disabled",i&&"ReactCrop--locked",f&&"ReactCrop--new-crop",o&&s&&"ReactCrop--fixed-aspect",o&&n&&"ReactCrop--circular-crop",o&&u&&"ReactCrop--rule-of-thirds",!this.dragStarted&&o&&!o.width&&!o.height&&"ReactCrop--invisible-crop",n&&"ReactCrop--no-animate");return ht.createElement("div",{ref:this.componentRef,className:_,style:d},ht.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},r),o?ht.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},ht.createElement("defs",null,ht.createElement("mask",{id:`hole-${this.instanceId}`},ht.createElement("rect",{width:"100%",height:"100%",fill:"white"}),n?ht.createElement("ellipse",{cx:`${o.x+o.width/2}${o.unit}`,cy:`${o.y+o.height/2}${o.unit}`,rx:`${o.width/2}${o.unit}`,ry:`${o.height/2}${o.unit}`,fill:"black"}):ht.createElement("rect",{x:`${o.x}${o.unit}`,y:`${o.y}${o.unit}`,width:`${o.width}${o.unit}`,height:`${o.height}${o.unit}`,fill:"black"}))),ht.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,y)}};dc(u1,"xOrds",["e","w"]),dc(u1,"yOrds",["n","s"]),dc(u1,"xyOrds",["nw","ne","se","sw"]),dc(u1,"nudgeStep",1),dc(u1,"nudgeStepMedium",10),dc(u1,"nudgeStepLarge",100),dc(u1,"defaultProps",{ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}});let RLt=u1;var jGe=["PageUp","PageDown"],NGe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],kGe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},LM="Slider",[hye,FLt,zLt]=vL(LM),[SGe]=Ec(LM,[zLt]),[BLt,Ele]=SGe(LM),CGe=C.forwardRef((t,s)=>{const{name:r,min:n=0,max:a=100,step:o=1,orientation:l="horizontal",disabled:i=!1,minStepsBetweenThumbs:d=0,defaultValue:u=[n],value:p,onValueChange:f=()=>{},onValueCommit:y=()=>{},inverted:_=!1,form:b,...w}=t,j=C.useRef(new Set),k=C.useRef(0),T=l==="horizontal"?$Lt:qLt,[I=[],L]=vu({prop:p,defaultProp:u,onChange:Y=>{var te;(te=[...j.current][k.current])==null||te.focus(),f(Y)}}),R=C.useRef(I);function $(Y){const se=GLt(I,Y);H(Y,se)}function q(Y){H(Y,k.current)}function U(){const Y=R.current[k.current];I[k.current]!==Y&&y(I)}function H(Y,se,{commit:te}={commit:!1}){const Q=XLt(o),de=QLt(Math.round((Y-n)/o)*o+n,Q),re=a6(de,[n,a]);L((ae=[])=>{const le=HLt(ae,re,se);if(YLt(le,d*o)){k.current=le.indexOf(re);const he=String(le)!==String(ae);return he&&te&&y(le),he?le:ae}else return ae})}return e.jsx(BLt,{scope:t.__scopeSlider,name:r,disabled:i,min:n,max:a,valueIndexToChangeRef:k,thumbs:j.current,values:I,orientation:l,form:b,children:e.jsx(hye.Provider,{scope:t.__scopeSlider,children:e.jsx(hye.Slot,{scope:t.__scopeSlider,children:e.jsx(T,{"aria-disabled":i,"data-disabled":i?"":void 0,...w,ref:s,onPointerDown:Mr(w.onPointerDown,()=>{i||(R.current=I)}),min:n,max:a,inverted:_,onSlideStart:i?void 0:$,onSlideMove:i?void 0:q,onSlideEnd:i?void 0:U,onHomeKeyDown:()=>!i&&H(n,0,{commit:!0}),onEndKeyDown:()=>!i&&H(a,I.length-1,{commit:!0}),onStepKeyDown:({event:Y,direction:se})=>{if(!i){const de=jGe.includes(Y.key)||Y.shiftKey&&NGe.includes(Y.key)?10:1,re=k.current,ae=I[re],le=o*de*se;H(ae+le,re,{commit:!0})}}})})})})});CGe.displayName=LM;var[MGe,TGe]=SGe(LM,{startEdge:"left",endEdge:"right",size:"width",direction:1}),$Lt=C.forwardRef((t,s)=>{const{min:r,max:n,dir:a,inverted:o,onSlideStart:l,onSlideMove:i,onSlideEnd:d,onStepKeyDown:u,...p}=t,[f,y]=C.useState(null),_=Ea(s,T=>y(T)),b=C.useRef(void 0),w=G_(a),j=w==="ltr",k=j&&!o||!j&&o;function S(T){const I=b.current||f.getBoundingClientRect(),L=[0,I.width],$=iwe(L,k?[r,n]:[n,r]);return b.current=I,$(T-I.left)}return e.jsx(MGe,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:e.jsx(AGe,{dir:w,"data-orientation":"horizontal",...p,ref:_,style:{...p.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:T=>{const I=S(T.clientX);l==null||l(I)},onSlideMove:T=>{const I=S(T.clientX);i==null||i(I)},onSlideEnd:()=>{b.current=void 0,d==null||d()},onStepKeyDown:T=>{const L=kGe[k?"from-left":"from-right"].includes(T.key);u==null||u({event:T,direction:L?-1:1})}})})}),qLt=C.forwardRef((t,s)=>{const{min:r,max:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:i,onStepKeyDown:d,...u}=t,p=C.useRef(null),f=Ea(s,p),y=C.useRef(void 0),_=!a;function b(w){const j=y.current||p.current.getBoundingClientRect(),k=[0,j.height],T=iwe(k,_?[n,r]:[r,n]);return y.current=j,T(w-j.top)}return e.jsx(MGe,{scope:t.__scopeSlider,startEdge:_?"bottom":"top",endEdge:_?"top":"bottom",size:"height",direction:_?1:-1,children:e.jsx(AGe,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const j=b(w.clientY);o==null||o(j)},onSlideMove:w=>{const j=b(w.clientY);l==null||l(j)},onSlideEnd:()=>{y.current=void 0,i==null||i()},onStepKeyDown:w=>{const k=kGe[_?"from-bottom":"from-top"].includes(w.key);d==null||d({event:w,direction:k?-1:1})}})})}),AGe=C.forwardRef((t,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:i,onStepKeyDown:d,...u}=t,p=Ele(LM,r);return e.jsx(Qr.span,{...u,ref:s,onKeyDown:Mr(t.onKeyDown,f=>{f.key==="Home"?(l(f),f.preventDefault()):f.key==="End"?(i(f),f.preventDefault()):jGe.concat(NGe).includes(f.key)&&(d(f),f.preventDefault())}),onPointerDown:Mr(t.onPointerDown,f=>{const y=f.target;y.setPointerCapture(f.pointerId),f.preventDefault(),p.thumbs.has(y)?y.focus():n(f)}),onPointerMove:Mr(t.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:Mr(t.onPointerUp,f=>{const y=f.target;y.hasPointerCapture(f.pointerId)&&(y.releasePointerCapture(f.pointerId),o(f))})})}),EGe="SliderTrack",PGe=C.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=Ele(EGe,r);return e.jsx(Qr.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:s})});PGe.displayName=EGe;var mye="SliderRange",IGe=C.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=Ele(mye,r),o=TGe(mye,r),l=C.useRef(null),i=Ea(s,l),d=a.values.length,u=a.values.map(y=>OGe(y,a.min,a.max)),p=d>1?Math.min(...u):0,f=100-Math.max(...u);return e.jsx(Qr.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...n,ref:i,style:{...t.style,[o.startEdge]:p+"%",[o.endEdge]:f+"%"}})});IGe.displayName=mye;var pye="SliderThumb",LGe=C.forwardRef((t,s)=>{const r=FLt(t.__scopeSlider),[n,a]=C.useState(null),o=Ea(s,i=>a(i)),l=C.useMemo(()=>n?r().findIndex(i=>i.ref.current===n):-1,[r,n]);return e.jsx(ULt,{...t,ref:o,index:l})}),ULt=C.forwardRef((t,s)=>{const{__scopeSlider:r,index:n,name:a,...o}=t,l=Ele(pye,r),i=TGe(pye,r),[d,u]=C.useState(null),p=Ea(s,S=>u(S)),f=d?l.form||!!d.closest("form"):!0,y=wL(d),_=l.values[n],b=_===void 0?0:OGe(_,l.min,l.max),w=WLt(n,l.values.length),j=y==null?void 0:y[i.size],k=j?KLt(j,b,i.direction):0;return C.useEffect(()=>{if(d)return l.thumbs.add(d),()=>{l.thumbs.delete(d)}},[d,l.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[i.startEdge]:`calc(${b}% + ${k}px)`},children:[e.jsx(hye.ItemSlot,{scope:t.__scopeSlider,children:e.jsx(Qr.span,{role:"slider","aria-label":t["aria-label"]||w,"aria-valuemin":l.min,"aria-valuenow":_,"aria-valuemax":l.max,"aria-orientation":l.orientation,"data-orientation":l.orientation,"data-disabled":l.disabled?"":void 0,tabIndex:l.disabled?void 0:0,...o,ref:p,style:_===void 0?{display:"none"}:t.style,onFocus:Mr(t.onFocus,()=>{l.valueIndexToChangeRef.current=n})})}),f&&e.jsx(DGe,{name:a??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:_},n)]})});LGe.displayName=pye;var VLt="RadioBubbleInput",DGe=C.forwardRef(({__scopeSlider:t,value:s,...r},n)=>{const a=C.useRef(null),o=Ea(a,n),l=DL(s);return C.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==s&&p){const f=new Event("input",{bubbles:!0});p.call(i,s),i.dispatchEvent(f)}},[l,s]),e.jsx(Qr.input,{style:{display:"none"},...r,ref:o,defaultValue:s})});DGe.displayName=VLt;function HLt(t=[],s,r){const n=[...t];return n[r]=s,n.sort((a,o)=>a-o)}function OGe(t,s,r){const o=100/(r-s)*(t-s);return a6(o,[0,100])}function WLt(t,s){return s>2?`Value ${t+1} of ${s}`:s===2?["Minimum","Maximum"][t]:void 0}function GLt(t,s){if(t.length===1)return 0;const r=t.map(a=>Math.abs(a-s)),n=Math.min(...r);return r.indexOf(n)}function KLt(t,s,r){const n=t/2,o=iwe([0,50],[0,n]);return(n-o(s)*r)*r}function ZLt(t){return t.slice(0,-1).map((s,r)=>t[r+1]-s)}function YLt(t,s){if(s>0){const r=ZLt(t);return Math.min(...r)>=s}return!0}function iwe(t,s){return r=>{if(t[0]===t[1]||s[0]===s[1])return s[0];const n=(s[1]-s[0])/(t[1]-t[0]);return s[0]+n*(r-t[0])}}function XLt(t){return(String(t).split(".")[1]||"").length}function QLt(t,s){const r=Math.pow(10,s);return Math.round(t*r)/r}var RGe=CGe,JLt=PGe,eDt=IGe,tDt=LGe;const Fg=C.forwardRef(({className:t,...s},r)=>e.jsxs(RGe,{ref:r,className:Pt("relative flex w-full touch-none select-none items-center",t),...s,children:[e.jsx(JLt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(eDt,{className:"absolute h-full bg-primary"})}),e.jsx(tDt,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));Fg.displayName=RGe.displayName;function sDt(t,s,r){return LLt(ILt({unit:"%",width:90},r,t,s),t,s)}const owe=({open:t,onClose:s,imageSrc:r,onCropComplete:n,aspectRatio:a=1})=>{const o=C.useRef(null),[l,i]=C.useState(),[d,u]=C.useState(),[p,f]=C.useState(1),[y,_]=C.useState(0),b=C.useCallback(k=>{const{width:S,height:T}=k.currentTarget;i(sDt(S,T,a))},[a]),w=C.useCallback(async()=>{const k=o.current;if(!k||!d)return;const S=document.createElement("canvas"),T=S.getContext("2d");if(!T)return;const I=k.naturalWidth/k.width,L=k.naturalHeight/k.height,R=400;S.width=R,S.height=R,T.imageSmoothingQuality="high";const $=d.x*I,q=d.y*L,U=d.width*I,H=d.height*L,Y=y*Math.PI/180,se=S.width/2,te=S.height/2;return T.save(),T.translate(se,te),T.rotate(Y),T.scale(p,p),T.translate(-se,-te),T.drawImage(k,$,q,U,H,0,0,R,R),T.restore(),new Promise((Q,de)=>{S.toBlob(re=>{re?Q(re):de(new Error("Canvas is empty"))},"image/jpeg",.95)})},[d,p,y]),j=async()=>{try{const k=await w();k&&(n(k),s())}catch(k){console.error("Error cropping image:",k)}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-lg",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Crop Your Photo"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"relative max-h-[400px] overflow-hidden rounded-lg bg-muted flex items-center justify-center",children:e.jsx(RLt,{crop:l,onChange:(k,S)=>i(S),onComplete:k=>u(k),aspect:a,circularCrop:!0,className:"max-h-[400px]",children:e.jsx("img",{ref:o,src:r,alt:"Crop preview",style:{transform:`scale(${p}) rotate(${y}deg)`,maxHeight:"400px",width:"auto"},onLoad:b})})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(E5,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Fg,{value:[p],min:.5,max:3,step:.1,onValueChange:([k])=>f(k),className:"flex-1"}),e.jsx(f_,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(IP,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Fg,{value:[y],min:-180,max:180,step:1,onValueChange:([k])=>_(k),className:"flex-1"}),e.jsxs("span",{className:"text-sm text-muted-foreground w-12",children:[y,"°"]})]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(K,{onClick:j,children:"Save Photo"})]})]})})},rDt=()=>{const{user:t}=Hs(),{toast:s}=Pa(),[r,n]=C.useState(!1),[a,o]=C.useState(!1),[l,i]=C.useState(null);C.useEffect(()=>{t&&d()},[t]);const d=async()=>{n(!0);try{const{data:f}=await G.from("profiles").select("subscription_status, subscription_product_id, subscription_end_date, is_grandfathered").eq("id",t==null?void 0:t.id).single();f&&i({status:f.subscription_status||"none",productId:f.subscription_product_id,endDate:f.subscription_end_date,isGrandfathered:f.is_grandfathered||!1})}catch(f){console.error("Error loading subscription:",f)}finally{n(!1)}},u=async()=>{o(!0);try{const{data:{session:f}}=await G.auth.getSession();if(!f)throw new Error("Not authenticated");const{data:y,error:_}=await G.functions.invoke("customer-portal",{headers:{Authorization:`Bearer ${f.access_token}`}});if(_)throw _;y!=null&&y.url&&window.open(y.url,"_blank")}catch(f){console.error("Error opening customer portal:",f),s({title:"Error",description:f.message||"Failed to open billing portal",variant:"destructive"})}finally{o(!1)}},p=()=>{if(l!=null&&l.isGrandfathered)return e.jsx(rt,{className:"bg-amber-500",children:"Grandfathered"});switch(l==null?void 0:l.status){case"active":return e.jsx(rt,{className:"bg-green-500",children:"Active"});case"trialing":return e.jsx(rt,{className:"bg-blue-500",children:"Trial"});case"past_due":return e.jsx(rt,{variant:"destructive",children:"Past Due"});case"canceled":return e.jsx(rt,{variant:"secondary",children:"Canceled"});default:return e.jsx(rt,{variant:"outline",children:"No Subscription"})}};return r?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(yf,{className:"h-5 w-5"}),"Subscription"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(yf,{className:"h-5 w-5"}),"Subscription"]}),e.jsx(pr,{children:"Manage your subscription and billing"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Status"}),e.jsx("div",{className:"mt-1",children:p()})]}),(l==null?void 0:l.endDate)&&l.status==="active"&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Next billing date"}),e.jsx("p",{className:"font-medium",children:new Date(l.endDate).toLocaleDateString()})]})]}),l!=null&&l.isGrandfathered?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your account was upgraded from LevelUp 1.0. To update/manage your subscription please reach out to support."}):(l==null?void 0:l.status)==="active"||(l==null?void 0:l.status)==="trialing"?e.jsxs(e.Fragment,{children:[(l==null?void 0:l.status)==="trialing"&&(l==null?void 0:l.endDate)&&e.jsxs("p",{className:"text-sm text-muted-foreground mb-3",children:["Your trial ends on ",new Date(l.endDate).toLocaleDateString(),". After the trial, you'll be charged automatically."]}),e.jsxs(K,{onClick:u,variant:"outline",disabled:a,children:[a?e.jsx(Ms,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(sn,{className:"mr-2 h-4 w-4"}),"Manage Billing"]})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"You don't have an active subscription."})]})]})},nDt=()=>{const{user:t}=Hs(),s=Pr(),{toast:r}=Pa(),[n]=Pc(),a=n.get("setup")==="true",o=n.get("reset")==="true",{isSupported:l,isSubscribed:i,isLoading:d,subscribe:u,unsubscribe:p}=dVe(),[f,y]=C.useState(!1),[_,b]=C.useState(""),[w,j]=C.useState(!1),[k,S]=C.useState(!1),[T,I]=C.useState(""),[L,R]=C.useState({name:"",email:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}),[$,q]=C.useState(!1),[U,H]=C.useState(!1),[Y,se]=C.useState({newPassword:"",confirmPassword:""});C.useEffect(()=>{t&&te()},[t]),C.useEffect(()=>{o&&t&&setTimeout(()=>{var le;(le=document.getElementById("change-password-section"))==null||le.scrollIntoView({behavior:"smooth",block:"center"})},500)},[o,t]);const te=async()=>{var le,he,be;if(!(t!=null&&t.id)){console.log("No user ID available yet");return}try{console.log("Loading profile for user:",t.id);const{data:_e,error:je}=await G.from("profiles").select("name, email, digest_opt_out, title, bio, areas_served, years_experience, instagram_url, facebook_url, linkedin_url, email_signature, use_email_signature").eq("id",t.id).maybeSingle();if(je)throw console.error("Profile query error:",je),je;_e?(console.log("Profile loaded successfully:",_e),R({name:_e.name||"",email:_e.email||"",title:_e.title||"",bio:_e.bio||"",areas_served:_e.areas_served||"",years_experience:((le=_e.years_experience)==null?void 0:le.toString())||"",instagram_url:_e.instagram_url||"",facebook_url:_e.facebook_url||"",linkedin_url:_e.linkedin_url||"",email_signature:_e.email_signature||"",use_email_signature:_e.use_email_signature||!1}),q(_e.digest_opt_out||!1)):(console.warn("No profile found for user"),R({name:((he=t.user_metadata)==null?void 0:he.name)||((be=t.email)==null?void 0:be.split("@")[0])||"",email:t.email||"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}));const{data:Ne}=await G.storage.from("avatars").list(`${t.id}`);if(Ne&&Ne.length>0){const{data:Ge}=G.storage.from("avatars").getPublicUrl(`${t.id}/${Ne[0].name}`);b(Ge.publicUrl)}}catch(_e){console.error("Error loading profile:",_e),r({title:"Error",description:_e.message||"Failed to load profile",variant:"destructive"})}},Q=le=>{var _e;const he=(_e=le.target.files)==null?void 0:_e[0];if(!he)return;const be=new FileReader;be.onloadend=()=>{I(be.result),S(!0)},be.readAsDataURL(he),le.target.value=""},de=async le=>{if(t){j(!0);try{const{data:he}=await G.storage.from("avatars").list(`${t.id}`);he&&he.length>0&&await G.storage.from("avatars").remove(he.map(we=>`${t.id}/${we.name}`));const _e=`${t.id}/avatar.jpg`,{error:je}=await G.storage.from("avatars").upload(_e,le,{upsert:!0,contentType:"image/jpeg"});if(je)throw je;const{data:Ne}=G.storage.from("avatars").getPublicUrl(_e),Ge=Ne.publicUrl;b(`${Ge}?t=${Date.now()}`),await G.from("profiles").update({avatar_url:Ge}).eq("id",t.id),r({title:"Success",description:"Profile photo updated successfully"})}catch(he){console.error("Error uploading avatar:",he),r({title:"Error",description:he.message||"Failed to upload photo",variant:"destructive"})}finally{j(!1)}}},re=async()=>{if(!L.name.trim()||!L.email.trim()){r({title:"Error",description:"Name and email are required",variant:"destructive"});return}y(!0);try{const{error:le}=await G.from("profiles").update({name:L.name.trim(),email:L.email.trim(),title:L.title.trim()||null,bio:L.bio.trim()||null,areas_served:L.areas_served.trim()||null,years_experience:L.years_experience?parseInt(L.years_experience):null,instagram_url:L.instagram_url.trim()||null,facebook_url:L.facebook_url.trim()||null,linkedin_url:L.linkedin_url.trim()||null,email_signature:L.email_signature||"",use_email_signature:L.use_email_signature}).eq("id",t==null?void 0:t.id);if(le)throw le;r({title:"Success",description:"Profile updated successfully"})}catch(le){console.error("Error updating profile:",le),r({title:"Error",description:le.message||"Failed to update profile",variant:"destructive"})}finally{y(!1)}},ae=async()=>{if(!Y.newPassword){r({title:"Error",description:"Please enter a new password",variant:"destructive"});return}if(Y.newPassword.length<6){r({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}if(Y.newPassword!==Y.confirmPassword){r({title:"Error",description:"Passwords do not match",variant:"destructive"});return}y(!0);try{const{error:le}=await G.auth.updateUser({password:Y.newPassword});if(le)throw le;r({title:"Success",description:"Password updated successfully"}),se({newPassword:"",confirmPassword:""}),a&&setTimeout(()=>s("/dashboard"),1e3)}catch(le){console.error("Error updating password:",le),r({title:"Error",description:le.message||"Failed to update password",variant:"destructive"})}finally{y(!1)}};return e.jsx(Ts,{title:a?"Complete Your Profile":o?"Reset Your Password":"Profile Settings",description:a?"Welcome! Please complete your profile setup":o?"Please set a new password for your account":"Manage your account information and password",children:e.jsxs("div",{className:"mx-auto max-w-4xl",children:[!a&&!o&&e.jsx("div",{className:"mb-6",children:e.jsxs(K,{variant:"outline",onClick:()=>{var le;(le=document.getElementById("change-password-section"))==null||le.scrollIntoView({behavior:"smooth",block:"center"})},className:"gap-2",children:[e.jsx(ck,{className:"h-4 w-4"}),"Change Password"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Profile Photo"}),e.jsx(pr,{children:"Upload a professional photo for your profile"})]}),e.jsxs(Oe,{className:"flex items-center gap-6",children:[e.jsxs(xn,{className:"h-24 w-24",children:[e.jsx(Aa,{src:_}),e.jsx(yn,{className:"text-2xl",children:L.name.split(" ").map(le=>le[0]).join("").toUpperCase()||"U"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("input",{type:"file",id:"avatar-upload",accept:"image/*",className:"hidden",onChange:Q,disabled:w}),e.jsxs(K,{variant:"outline",onClick:()=>{var le;return(le=document.getElementById("avatar-upload"))==null?void 0:le.click()},disabled:w,children:[e.jsx(Za,{className:"mr-2 h-4 w-4"}),w?"Uploading...":"Upload Photo"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Upload an image and crop it to your liking."})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Personal Information"}),e.jsx(pr,{children:"Update your profile details"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",value:L.name,onChange:le=>R({...L,name:le.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",value:L.email,onChange:le=>R({...L,email:le.target.value}),maxLength:255})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Job Title"}),e.jsx(Re,{id:"title",value:L.title,onChange:le=>R({...L,title:le.target.value}),placeholder:"e.g., Broker Associate, Team Lead",maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"bio",children:"Bio"}),e.jsx(Ar,{id:"bio",value:L.bio,onChange:le=>R({...L,bio:le.target.value}),placeholder:"A short description about yourself",maxLength:500,className:"min-h-[120px] resize-y"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"areas_served",children:"Areas Served"}),e.jsx(Re,{id:"areas_served",value:L.areas_served,onChange:le=>R({...L,areas_served:le.target.value}),placeholder:"e.g., Downtown, Suburbs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"years_experience",children:"Years Experience"}),e.jsx(Re,{id:"years_experience",type:"number",min:"0",value:L.years_experience,onChange:le=>R({...L,years_experience:le.target.value}),placeholder:"e.g., 5"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Social Links"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsx(Re,{value:L.linkedin_url,onChange:le=>R({...L,linkedin_url:le.target.value}),placeholder:"LinkedIn URL"}),e.jsx(Re,{value:L.instagram_url,onChange:le=>R({...L,instagram_url:le.target.value}),placeholder:"Instagram URL"}),e.jsx(Re,{value:L.facebook_url,onChange:le=>R({...L,facebook_url:le.target.value}),placeholder:"Facebook URL"})]})]}),e.jsxs(K,{onClick:re,disabled:f,children:[e.jsx(fu,{className:"mr-2 h-4 w-4"}),"Save Changes"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(f0,{className:"h-5 w-5"}),"Email Signature"]}),e.jsx(pr,{children:"Add a signature that will be appended to emails sent via Gmail"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Use email signature in all emails"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:L.use_email_signature?"Your signature will be added to every email sent via Gmail":"Signature is currently disabled"})]}),e.jsx(Br,{checked:L.use_email_signature,onCheckedChange:le=>R({...L,use_email_signature:le})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Signature"}),e.jsx(rx,{content:L.email_signature,onChange:le=>R({...L,email_signature:le}),placeholder:"Paste your Gmail signature here or create one...",minHeight:"120px",compact:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tip: Copy your signature from Gmail Settings and paste it here — images and formatting will be preserved."})]}),e.jsxs(K,{onClick:re,disabled:f,children:[e.jsx(fu,{className:"mr-2 h-4 w-4"}),"Save Signature"]})]})]}),e.jsxs(Ee,{id:"change-password-section",children:[e.jsxs(It,{children:[e.jsx(Ot,{children:a?"Set Your Password":"Change Password"}),e.jsx(pr,{children:a?"Create a secure password for your account":"Update your password to keep your account secure"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"newPassword",children:"New Password"}),e.jsx(Re,{id:"newPassword",type:"password",value:Y.newPassword,onChange:le=>se({...Y,newPassword:le.target.value}),placeholder:"Min 6 characters"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"confirmPassword",children:"Confirm Password"}),e.jsx(Re,{id:"confirmPassword",type:"password",value:Y.confirmPassword,onChange:le=>se({...Y,confirmPassword:le.target.value}),placeholder:"Re-enter your new password"})]}),e.jsxs(K,{onClick:ae,disabled:f,children:[e.jsx(fu,{className:"mr-2 h-4 w-4"}),a?"Complete Setup":"Update Password"]}),a&&e.jsx(K,{variant:"outline",onClick:()=>s("/dashboard"),className:"ml-2",children:"Skip for Now"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[i?e.jsx(gf,{className:"h-5 w-5"}):e.jsx(r_,{className:"h-5 w-5"}),"Push Notifications"]}),e.jsx(pr,{children:"Receive browser notifications when new content is added"})]}),e.jsx(Oe,{children:l?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:i?"Notifications enabled":"Notifications disabled"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i?"You'll receive notifications about new templates, videos, and events":"Enable to get notified about new content"})]}),e.jsx(Br,{checked:i,onCheckedChange:le=>{le?u():p()},disabled:d})]}):e.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:"Push notifications are not supported in this browser."}),e.jsxs("p",{className:"text-xs",children:[e.jsx("strong",{children:"Desktop:"})," Use Chrome, Firefox, or Edge.",e.jsx("br",{}),e.jsx("strong",{children:"iPhone/iPad:"}),' Open this site in Safari, tap the Share button, then "Add to Home Screen". Push notifications will work from the installed app.']})]})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[$?e.jsx(_P,{className:"h-5 w-5"}):e.jsx(br,{className:"h-5 w-5"}),"Email Preferences"]}),e.jsx(pr,{children:"Manage your email subscription settings"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:$?"You won't receive weekly digest emails":"Receive a weekly summary of new content, events, and your progress"})]}),e.jsx(Br,{checked:!$,onCheckedChange:async le=>{H(!0);try{const{error:he}=await G.from("profiles").update({digest_opt_out:!le}).eq("id",t==null?void 0:t.id);if(he)throw he;q(!le),r({title:le?"Subscribed":"Unsubscribed",description:le?"You will now receive weekly digest emails":"You will no longer receive weekly digest emails"})}catch(he){r({title:"Error",description:he.message||"Failed to update preference",variant:"destructive"})}finally{H(!1)}},disabled:U})]})})]}),e.jsx(D3t,{}),e.jsx(rDt,{})]}),e.jsx(owe,{open:k,onClose:()=>S(!1),imageSrc:T,onCropComplete:de,aspectRatio:1})]})})};var aDt="AspectRatio",FGe=C.forwardRef((t,s)=>{const{ratio:r=1/1,style:n,...a}=t;return e.jsx("div",{style:{position:"relative",width:"100%",paddingBottom:`${100/r}%`},"data-radix-aspect-ratio-wrapper":"",children:e.jsx(Qr.div,{...a,ref:s,style:{...n,position:"absolute",top:0,right:0,bottom:0,left:0}})})});FGe.displayName=aDt;var iDt=FGe;const oDt=iDt;function lDt(){const{user:t}=Hs(),s=rs(),[r,n]=C.useState(!1),[a,o]=C.useState(!1),{data:l,isLoading:i}=wt({queryKey:["calendar-token",t==null?void 0:t.id],queryFn:async()=>{const{data:b,error:w}=await G.from("profiles").select("calendar_token").eq("id",t==null?void 0:t.id).single();if(w)throw w;return b},enabled:!!t&&a}),d=Dt({mutationFn:async()=>{const b=new Uint8Array(12);crypto.getRandomValues(b);const w=btoa(String.fromCharCode(...b)).replace(/\+/g,"x").replace(/\//g,"y").replace(/=/g,"").substring(0,16),{error:j}=await G.from("profiles").update({calendar_token:w}).eq("id",t==null?void 0:t.id);if(j)throw j;return w},onSuccess:()=>{s.invalidateQueries({queryKey:["calendar-token",t==null?void 0:t.id]}),fe.success("Calendar subscription URL generated!")},onError:b=>{fe.error("Failed to generate calendar URL: "+b.message)}}),u=l!=null&&l.calendar_token?`https://dashboard.relevelup.com/api/calendar/${l.calendar_token}.ics`:null,p=async()=>{u&&(await navigator.clipboard.writeText(u),n(!0),fe.success("Calendar URL copied to clipboard!"),setTimeout(()=>n(!1),2e3))},f=()=>{u&&(window.location.href=u.replace("https://","webcal://"))},y=()=>{if(u){const b=u.replace("https://","webcal://"),w=`https://calendar.google.com/calendar/r?cid=${encodeURIComponent(b)}`;window.open(w,"_blank")}},_=()=>{if(u){const b=`https://outlook.live.com/calendar/0/addfromweb?url=${encodeURIComponent(u)}&name=Level%20Up%20Events`;window.open(b,"_blank")}};return e.jsxs(_s,{open:a,onOpenChange:o,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Subscribe to Calendar"]})}),e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-5 w-5 text-primary"}),"Subscribe to Events Calendar"]}),e.jsx(Kr,{children:"Add all Level Up events to your personal calendar. Events will sync automatically and update when we add or change events."})]}),e.jsx("div",{className:"space-y-4 py-4",children:i?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):u?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Your Calendar URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:u,readOnly:!0,className:"text-xs font-mono"}),e.jsx(K,{variant:"outline",size:"icon",onClick:p,children:r?e.jsx(ha,{className:"h-4 w-4 text-green-500"}):e.jsx(ai,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Quick Add"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:f,children:[e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"})}),"Add to Apple Calendar",e.jsx(sn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:y,children:[e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("path",{d:"M19.5 22h-15A2.5 2.5 0 0 1 2 19.5v-15A2.5 2.5 0 0 1 4.5 2H9v2H4.5a.5.5 0 0 0-.5.5v15a.5.5 0 0 0 .5.5h15a.5.5 0 0 0 .5-.5V15h2v4.5a2.5 2.5 0 0 1-2.5 2.5z"}),e.jsx("path",{d:"M12 2v8.5a1.5 1.5 0 0 0 1.5 1.5H22V2h-10z",fill:"#4285F4"}),e.jsx("path",{d:"M12 12V2H4.5A2.5 2.5 0 0 0 2 4.5V12h10z",fill:"#34A853"}),e.jsx("path",{d:"M2 12v7.5A2.5 2.5 0 0 0 4.5 22H12v-10H2z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 22h7.5a2.5 2.5 0 0 0 2.5-2.5V12h-10v10z",fill:"#EA4335"})]}),"Add to Google Calendar",e.jsx(sn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:_,children:[e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M7.88 12.04q0 .45-.11.87-.1.41-.33.74-.22.33-.58.52-.37.2-.87.2t-.85-.2q-.35-.21-.57-.55-.22-.33-.33-.75-.1-.42-.1-.86t.1-.87q.1-.43.34-.76.22-.34.59-.54.36-.2.87-.2t.86.2q.35.21.57.55.22.34.31.77.1.43.1.88zM24 12v9.38q0 .46-.33.8-.33.32-.8.32H7.13q-.46 0-.8-.33-.32-.33-.32-.8V18H1q-.41 0-.7-.3-.3-.29-.3-.7V7q0-.41.3-.7Q.58 6 1 6h6.5V2.55q0-.44.3-.75.3-.3.75-.3h12.9q.44 0 .75.3.3.3.3.75V12zm-6-8.25v3h3v-3zm0 4.5v3h3v-3zm0 4.5v1.83l3.05-1.83zm-5.25-9v3h3.75v-3zm0 4.5v3h3.75v-3zm0 4.5v2.03l2.41 1.5 1.34-.81v-2.72zM9 3.75V6h2l.13.01.12.04v-2.3zM5.98 15.98q.9 0 1.6-.3.7-.32 1.19-.86.48-.55.73-1.28.25-.74.25-1.61 0-.83-.25-1.55-.24-.71-.71-1.24t-1.15-.83q-.68-.3-1.55-.3-.92 0-1.64.3-.71.3-1.2.85-.5.54-.75 1.3-.25.74-.25 1.63 0 .85.26 1.56.26.72.74 1.23.48.52 1.17.81.69.3 1.56.3zM7.5 21h12.39L12 16.08V17q0 .41-.3.7-.29.3-.7.3H7.5zm15-.13v-7.24l-5.9 3.54Z"})}),"Add to Outlook",e.jsx(sn,{className:"h-3 w-3 ml-auto opacity-50"})]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center pt-2",children:"Events sync automatically. If your membership expires, the calendar will show as empty."})]}):e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generate your personal calendar subscription URL to get started."}),e.jsx(K,{onClick:()=>d.mutate(),disabled:d.isPending,className:"w-full",children:d.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(on,{className:"h-4 w-4 mr-2"}),"Generate Calendar URL"]})})]})})]})]})}var Ple="Tabs",[cDt]=Ec(Ple,[K_]),zGe=K_(),[dDt,lwe]=cDt(Ple),BGe=C.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:o,orientation:l="horizontal",dir:i,activationMode:d="automatic",...u}=t,p=G_(i),[f,y]=vu({prop:n,onChange:a,defaultProp:o??"",caller:Ple});return e.jsx(dDt,{scope:r,baseId:Gd(),value:f,onValueChange:y,orientation:l,dir:p,activationMode:d,children:e.jsx(Qr.div,{dir:p,"data-orientation":l,...u,ref:s})})});BGe.displayName=Ple;var $Ge="TabsList",qGe=C.forwardRef((t,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=t,o=lwe($Ge,r),l=zGe(r);return e.jsx(koe,{asChild:!0,...l,orientation:o.orientation,dir:o.dir,loop:n,children:e.jsx(Qr.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:s})})});qGe.displayName=$Ge;var UGe="TabsTrigger",VGe=C.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...o}=t,l=lwe(UGe,r),i=zGe(r),d=GGe(l.baseId,n),u=KGe(l.baseId,n),p=n===l.value;return e.jsx(Soe,{asChild:!0,...i,focusable:!a,active:p,children:e.jsx(Qr.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":u,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:d,...o,ref:s,onMouseDown:Mr(t.onMouseDown,f=>{!a&&f.button===0&&f.ctrlKey===!1?l.onValueChange(n):f.preventDefault()}),onKeyDown:Mr(t.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&l.onValueChange(n)}),onFocus:Mr(t.onFocus,()=>{const f=l.activationMode!=="manual";!p&&!a&&f&&l.onValueChange(n)})})})});VGe.displayName=UGe;var HGe="TabsContent",WGe=C.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:o,...l}=t,i=lwe(HGe,r),d=GGe(i.baseId,n),u=KGe(i.baseId,n),p=n===i.value,f=C.useRef(p);return C.useEffect(()=>{const y=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(y)},[]),e.jsx(ud,{present:a||p,children:({present:y})=>e.jsx(Qr.div,{"data-state":p?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":d,hidden:!y,id:u,tabIndex:0,...l,ref:s,style:{...t.style,animationDuration:f.current?"0s":void 0},children:y&&o})})});WGe.displayName=HGe;function GGe(t,s){return`${t}-trigger-${s}`}function KGe(t,s){return`${t}-content-${s}`}var uDt=BGe,ZGe=qGe,YGe=VGe,XGe=WGe;const ka=uDt,_a=C.forwardRef(({className:t,...s},r)=>e.jsx(ZGe,{ref:r,className:Pt("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));_a.displayName=ZGe.displayName;const js=C.forwardRef(({className:t,...s},r)=>e.jsx(YGe,{ref:r,className:Pt("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",t),...s}));js.displayName=YGe.displayName;const zs=C.forwardRef(({className:t,...s},r)=>e.jsx(XGe,{ref:r,className:Pt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s}));zs.displayName=XGe.displayName;const hDt={first_timer:Gn,regular:R0,dedicated:rc,veteran:ao,streak_master:nh,century:ao},mDt={first_timer:"bg-green-500/10 text-green-500 border-green-500/20",regular:"bg-blue-500/10 text-blue-500 border-blue-500/20",dedicated:"bg-purple-500/10 text-purple-500 border-purple-500/20",veteran:"bg-amber-500/10 text-amber-500 border-amber-500/20",streak_master:"bg-orange-500/10 text-orange-500 border-orange-500/20",century:"bg-yellow-500/10 text-yellow-500 border-yellow-500/20"};function qAe(t){return t===1?e.jsx(ao,{className:"h-5 w-5 text-yellow-500"}):t===2?e.jsx(R0,{className:"h-5 w-5 text-gray-400"}):t===3?e.jsx(rc,{className:"h-5 w-5 text-amber-600"}):e.jsx("span",{className:"w-5 text-center text-sm font-medium text-muted-foreground",children:t})}function QGe({showUserStats:t=!0,compact:s=!1,brokerageId:r,title:n="Event Leaderboard"}){const{user:a}=Hs(),{data:o,isLoading:l}=IVe(s?5:10,r),{data:i}=LVe(a==null?void 0:a.id),{data:d}=OVe(a==null?void 0:a.id),{data:u}=DVe(a==null?void 0:a.id);return l?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(ao,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((p,f)=>e.jsx(xs,{className:"h-12 w-full"},f))})})]}):e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(ao,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsxs(Oe,{children:[t&&i&&e.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-primary/5 border border-primary/10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Your Stats"}),d&&e.jsxs(rt,{variant:"secondary",className:"text-xs",children:["Rank #",d]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-primary",children:i.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Points"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold",children:i.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Events"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(nh,{className:"h-4 w-4 text-orange-500"}),e.jsx("div",{className:"text-lg font-bold",children:i.current_streak}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Streak"})]})]}),u&&u.length>0&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1",children:[u.slice(0,4).map(p=>{const f=hDt[p.badge_type]||Gn;return e.jsxs(rt,{variant:"outline",className:`text-xs ${mDt[p.badge_type]||""}`,title:p.badge_description||"",children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),p.badge_name]},p.id)}),u.length>4&&e.jsxs(rt,{variant:"outline",className:"text-xs",children:["+",u.length-4," more"]})]})]}),e.jsxs(ka,{defaultValue:"points",className:"w-full",children:[e.jsxs(_a,{className:"w-full mb-3",children:[e.jsx(js,{value:"points",className:"flex-1",children:"By Points"}),e.jsx(js,{value:"events",className:"flex-1",children:"By Events"})]}),e.jsx(zs,{value:"points",className:"mt-0",children:e.jsxs("div",{className:"space-y-2",children:[o==null?void 0:o.map((p,f)=>{var y,_,b;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${p.user_id===(a==null?void 0:a.id)?"bg-primary/5 border border-primary/10":""} ${f===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:qAe(f+1)}),e.jsx(xn,{className:"h-8 w-8",children:e.jsx(yn,{className:"text-xs",children:((_=(y=p.profile)==null?void 0:y.name)==null?void 0:_.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[((b=p.profile)==null?void 0:b.name)||"Unknown",p.user_id===(a==null?void 0:a.id)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(You)"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.total_events_attended," events"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold text-primary",children:p.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"pts"})]})]},p.user_id)}),(!o||o.length===0)&&e.jsx("div",{className:"text-center text-muted-foreground py-4 text-sm",children:"No attendance data yet. Attend an event to get on the leaderboard!"})]})}),e.jsx(zs,{value:"events",className:"mt-0",children:e.jsx("div",{className:"space-y-2",children:[...o||[]].sort((p,f)=>f.total_events_attended-p.total_events_attended).map((p,f)=>{var y,_,b;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${p.user_id===(a==null?void 0:a.id)?"bg-primary/5 border border-primary/10":""} ${f===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:qAe(f+1)}),e.jsx(xn,{className:"h-8 w-8",children:e.jsx(yn,{className:"text-xs",children:((_=(y=p.profile)==null?void 0:y.name)==null?void 0:_.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[((b=p.profile)==null?void 0:b.name)||"Unknown",p.user_id===(a==null?void 0:a.id)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(You)"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.total_points," points"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold",children:p.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"events"})]})]},p.user_id)})})})]})]})]})}function pDt(){const t=Pr(),{user:s,isAdmin:r}=Hs(),n=rs(),{data:a,isLoading:o}=wt({queryKey:["public-events"],queryFn:async()=>{const{data:w,error:j}=await G.from("events").select("*").order("event_date",{ascending:!0});if(j)throw j;return w}}),{data:l}=wt({queryKey:["my-registrations"],queryFn:async()=>{if(!s)return[];const{data:w,error:j}=await G.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",s.id);if(j)throw j;return w},enabled:!!s}),{data:i}=wt({queryKey:["event-registration-counts"],queryFn:async()=>{let w=[],j=0;const k=1e3;for(;;){const{data:T,error:I}=await G.from("event_registrations").select("event_id").range(j,j+k-1);if(I)throw I;if(!T||T.length===0||(w=w.concat(T),T.length{S[T.event_id]=(S[T.event_id]||0)+1}),S}}),d=Dt({mutationFn:async w=>{await G.auth.refreshSession();const{data:j,error:k}=await G.functions.invoke("zoom-register",{body:{event_id:w}});if(k)throw k;if(j!=null&&j.error)throw new Error(j.error);return j},onSuccess:w=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),w!=null&&w.join_url?fe.success("Successfully registered! You'll receive a Zoom confirmation email."):fe.success("Successfully registered for the event!")},onError:w=>{fe.error("Failed to register: "+w.message)}}),u=Dt({mutationFn:async w=>{const{data:j,error:k}=await G.functions.invoke("zoom-unregister",{body:{event_id:w}});if(k)throw k;if(j!=null&&j.error)throw new Error(j.error);return j},onSuccess:()=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),fe.success("Registration cancelled and removed from Zoom")},onError:w=>{fe.error("Failed to cancel: "+w.message)}}),p=w=>l==null?void 0:l.some(j=>j.event_id===w),f=w=>{const j=l==null?void 0:l.find(k=>k.event_id===w);return j==null?void 0:j.zoom_join_url},y=w=>w.capacity?((i==null?void 0:i[w.id])||0)>=w.capacity:!1,_=(a==null?void 0:a.filter(w=>z5(w.event_date)!=="ended"))||[],b=(a==null?void 0:a.filter(w=>z5(w.event_date)==="ended"))||[];return e.jsx(Ts,{title:"Events",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"Events"}),e.jsx("p",{className:"text-muted-foreground",children:"Browse and register for upcoming events"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(lDt,{}),r&&e.jsx(K,{variant:"outline",onClick:()=>t("/admin/events"),children:"Manage Events"})]})]}),e.jsxs("div",{className:`grid grid-cols-1 ${r?"lg:grid-cols-3":""} gap-6`,children:[e.jsxs("div",{className:r?"lg:col-span-2":"",children:[o?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading events..."}):_.length===0?e.jsx(Ee,{className:"text-center py-12",children:e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground",children:"No upcoming events at the moment. Check back soon!"})})}):e.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:_.map(w=>{const j=z5(w.event_date),k=dbe(w.event_date),S=j==="live",T=j==="starting_soon";return e.jsxs(Ee,{className:`flex flex-col overflow-hidden cursor-pointer hover:shadow-lg transition-all ${S?"border-red-500 ring-2 ring-red-500/20":T?"border-amber-500 ring-2 ring-amber-500/20":"hover:border-primary/50"}`,onClick:()=>t(`/events/${w.id}`),children:[k&&e.jsxs("div",{className:`${S?"bg-red-500":"bg-amber-500"} text-white px-3 py-1.5 flex items-center gap-2 text-sm font-medium`,children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-white opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-white"})]}),S?e.jsxs(e.Fragment,{children:[e.jsx($0,{className:"h-3.5 w-3.5"}),"LIVE NOW"]}):e.jsxs(e.Fragment,{children:[e.jsx(Tn,{className:"h-3.5 w-3.5"}),"STARTING SOON"]})]}),w.image_url&&e.jsx(oDt,{ratio:3/2,className:"overflow-hidden",children:e.jsx("img",{src:w.image_url,alt:w.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"})}),e.jsxs(It,{children:[e.jsx(Ot,{className:"line-clamp-2",children:w.title}),w.description&&e.jsx(pr,{className:"line-clamp-2",children:w.description.replace(/<[^>]*>/g,"")})]}),e.jsxs(Oe,{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(on,{className:"h-4 w-4"}),new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(w.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Tn,{className:"h-4 w-4"}),h6(new Date(w.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(hr,{className:"h-4 w-4"}),(i==null?void 0:i[w.id])||0," registered",w.capacity&&` / ${w.capacity} spots`]})]}),e.jsx(QP,{className:"flex gap-2",onClick:I=>I.stopPropagation(),children:p(w.id)?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>u.mutate(w.id),disabled:u.isPending,children:[e.jsx(Ur,{className:"h-4 w-4 mr-2"}),"Cancel"]}),e.jsxs(K,{className:"flex-1",onClick:()=>window.open(f(w.id)||w.zoom_link,"_blank"),children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Join Zoom"]})]}):e.jsx(K,{className:"w-full",onClick:()=>d.mutate(w.id),disabled:d.isPending||y(w),children:y(w)?"Event Full":e.jsxs(e.Fragment,{children:[e.jsx(ha,{className:"h-4 w-4 mr-2"}),"Register"]})})})]},w.id)})}),b.length>0&&e.jsxs("div",{className:"mt-12",children:[e.jsx("h3",{className:"text-xl font-semibold mb-4 text-muted-foreground",children:"Past Events"}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:b.map(w=>e.jsx(Ee,{className:"opacity-60 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>t(`/events/${w.id}`),children:e.jsxs(It,{children:[e.jsx(Ot,{className:"text-base line-clamp-1",children:w.title}),e.jsx(pr,{children:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(w.event_date))})]})},w.id))})]})]}),r&&e.jsx("div",{className:"lg:col-span-1",children:e.jsx(QGe,{showUserStats:!0})})]})]})})}const Wme=[{value:"all",label:"All Roles",icon:hr},{value:"newest",label:"Newest Members",icon:Tn},{value:"brokerage_manager",label:"Brokerage Managers",icon:HP},{value:"admin",label:"Admins",icon:ih}];function fDt({open:t,onOpenChange:s,resourceType:r,resourceId:n,resourceTitle:a}){var Ue,ut;const{user:o,isAdmin:l,isBrokerageManager:i}=Hs(),[d,u]=C.useState([]),[p,f]=C.useState([]),[y,_]=C.useState([]),[b,w]=C.useState([]),[j,k]=C.useState(""),[S,T]=C.useState(""),[I,L]=C.useState(""),[R,$]=C.useState(!1),[q,U]=C.useState(!1),[H,Y]=C.useState("agents"),[se,te]=C.useState("all"),[Q,de]=C.useState({}),re=l||i;C.useEffect(()=>{t&&o&&(l?ae():le())},[t,o,l]),C.useEffect(()=>{t||(_([]),w([]),k(""),T(""),L(""),Y("agents"),te("all"))},[t]);const ae=async()=>{if(o){$(!0);try{const{data:De,error:Rt}=await G.from("brokerages").select("id, name").order("name");if(Rt)throw Rt;const me=1e3,Xe={};let ot=0,nt=!0;for(;nt;){const{data:$e,error:ct}=await G.from("profiles").select("brokerage_id").range(ot*me,(ot+1)*me-1);if(ct)throw ct;$e==null||$e.forEach(qe=>{qe.brokerage_id&&(Xe[qe.brokerage_id]=(Xe[qe.brokerage_id]||0)+1)}),nt=($e==null?void 0:$e.length)===me,ot++}f((De==null?void 0:De.map($e=>({...$e,agent_count:Xe[$e.id]||0})))||[]);const Se=[];for(ot=0,nt=!0;nt;){const{data:$e,error:ct}=await G.from("profiles").select("id, name, email, brokerage_id, created_at, brokerages(name)").neq("id",o.id).order("name").range(ot*me,(ot+1)*me-1);if(ct)throw ct;$e&&Se.push(...$e),nt=($e==null?void 0:$e.length)===me,ot++}const it={};for(ot=0,nt=!0;nt;){const{data:$e,error:ct}=await G.from("user_roles").select("user_id, role").range(ot*me,(ot+1)*me-1);if(ct)throw ct;$e==null||$e.forEach(qe=>{it[qe.user_id]||(it[qe.user_id]=[]),it[qe.user_id].push(qe.role)}),nt=($e==null?void 0:$e.length)===me,ot++}de(it),u(Se.map($e=>{var ct;return{id:$e.id,name:$e.name,email:$e.email,brokerage_name:((ct=$e.brokerages)==null?void 0:ct.name)||"No Brokerage",roles:it[$e.id]||[],created_at:$e.created_at}}))}catch(De){console.error("Error loading data:",De),fe.error("Failed to load agents and brokerages")}finally{$(!1)}}},le=async()=>{if(o){$(!0);try{const{data:De}=await G.from("profiles").select("brokerage_id").eq("id",o.id).single();if(!(De!=null&&De.brokerage_id)){fe.error("You must be part of a brokerage to share resources"),s(!1);return}const{data:Rt,error:me}=await G.from("profiles").select("id, name, email").eq("brokerage_id",De.brokerage_id).neq("id",o.id).order("name");if(me)throw me;u(Rt||[])}catch(De){console.error("Error loading agents:",De),fe.error("Failed to load agents")}finally{$(!1)}}},he=d.filter(De=>{var me;const Rt=De.name.toLowerCase().includes(j.toLowerCase())||De.email.toLowerCase().includes(j.toLowerCase())||((me=De.brokerage_name)==null?void 0:me.toLowerCase().includes(j.toLowerCase()));if(l&&se!=="all"&&se!=="newest"){const Xe=Q[De.id]||[];return Rt&&Xe.includes(se)}return Rt}).sort((De,Rt)=>se==="newest"?(Rt.created_at||"").localeCompare(De.created_at||""):0),be=p.filter(De=>De.name.toLowerCase().includes(S.toLowerCase())),_e=()=>{y.length===he.length?_([]):_(he.map(De=>De.id))},je=()=>{b.length===be.length?w([]):w(be.map(De=>De.id))},Ne=De=>{if(!re){_([De]);return}_(Rt=>Rt.includes(De)?Rt.filter(me=>me!==De):[...Rt,De])},Ge=De=>{w(Rt=>Rt.includes(De)?Rt.filter(me=>me!==De):[...Rt,De])},we=async()=>{if(!(y.length>0||b.length>0)){fe.error("Please select at least one agent or brokerage to share with");return}U(!0);try{const{data:Rt,error:me}=await G.functions.invoke("send-share-notification",{body:{recipientIds:y,brokerageIds:b,resourceType:r,resourceId:n,resourceTitle:a,message:I.trim()||void 0}});if(me)throw me;const Xe=(Rt==null?void 0:Rt.sharesCreated)||y.length;fe.success(`Shared with ${Xe} agent${Xe!==1?"s":""}`),s(!1)}catch(Rt){console.error("Error sharing resource:",Rt),fe.error("Failed to share resource")}finally{U(!1)}},Me=De=>De.split(" ").map(Rt=>Rt[0]).join("").toUpperCase().slice(0,2),Te=De=>{const Rt=Q[De]||[];return Rt.includes("admin")?e.jsx(rt,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Admin"}):Rt.includes("brokerage_manager")?e.jsx(rt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Manager"}):null},Fe=y.length+b.length,Ae=se!=="all"&&se!=="newest"?he.length:null;return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-lg max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs(Ss,{className:"flex-shrink-0",children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(aa,{className:"h-5 w-5 text-primary"}),"Share Resource"]}),e.jsxs(Kr,{className:"line-clamp-2",children:['Share "',a,'" with ',l?"agents or brokerages":"agents in your brokerage"]})]}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[l?e.jsxs(ka,{value:H,onValueChange:Y,className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(_a,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[e.jsxs(js,{value:"agents",className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{children:"Agents"}),y.length>0&&e.jsx(rt,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:y.length})]}),e.jsxs(js,{value:"brokerages",className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-4 w-4"}),e.jsx("span",{children:"Brokerages"}),b.length>0&&e.jsx(rt,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:b.length})]})]}),e.jsxs(zs,{value:"agents",className:"flex-1 flex flex-col space-y-3 mt-3 overflow-hidden",children:[e.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name, email, or brokerage...",value:j,onChange:De=>k(De.target.value),className:"pl-9"})]}),e.jsxs(sr,{value:se,onValueChange:te,children:[e.jsxs(er,{className:"w-[180px]",children:[e.jsx(Yx,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(rr,{placeholder:"Filter by role"})]}),e.jsx(tr,{children:Wme.map(De=>e.jsx(At,{value:De.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De.icon,{className:"h-4 w-4"}),e.jsx("span",{children:De.label})]})},De.value))})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:_e,className:"text-xs h-8",disabled:he.length===0,children:[e.jsx(hr,{className:"h-3.5 w-3.5 mr-1.5"}),y.length===he.length&&he.length>0?"Deselect All":"Select All"]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[Ae!==null&&e.jsxs("span",{className:"text-primary font-medium",children:[Ae," ",(Ue=Wme.find(De=>De.value===se))==null?void 0:Ue.label]}),e.jsxs("span",{className:"font-medium",children:[y.length," selected"]})]})]}),e.jsx(Ri,{className:"h-[300px] border rounded-lg",children:R?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):he.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(hr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:se!=="all"?`No ${(ut=Wme.find(De=>De.value===se))==null?void 0:ut.label.toLowerCase()} found`:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:he.map(De=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${y.includes(De.id)?"bg-accent":""}`,onClick:()=>Ne(De.id),children:[e.jsx(Bo,{checked:y.includes(De.id),onCheckedChange:()=>Ne(De.id),className:"flex-shrink-0"}),e.jsx(xn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(yn,{className:"text-xs bg-primary/10 text-primary",children:Me(De.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:De.name}),Te(De.id)]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[De.email,De.brokerage_name&&e.jsxs("span",{className:"ml-1 opacity-75",children:["• ",De.brokerage_name]})]})]})]},De.id))})})]}),e.jsxs(zs,{value:"brokerages",className:"flex-1 flex flex-col space-y-3 mt-3 overflow-hidden",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search brokerages...",value:S,onChange:De=>T(De.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:je,className:"text-xs h-8",disabled:be.length===0,children:[e.jsx(Ta,{className:"h-3.5 w-3.5 mr-1.5"}),b.length===be.length&&be.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[b.length," selected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground px-1 flex-shrink-0",children:"Selecting a brokerage will send to all agents in that brokerage."}),e.jsx(Ri,{className:"h-[250px] border rounded-lg",children:R?e.jsx("div",{className:"flex items-center justify-center h-[180px]",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):be.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[180px] text-muted-foreground",children:[e.jsx(Ta,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No brokerages found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:be.map(De=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${b.includes(De.id)?"bg-accent":""}`,onClick:()=>Ge(De.id),children:[e.jsx(Bo,{checked:b.includes(De.id),onCheckedChange:()=>Ge(De.id),className:"flex-shrink-0"}),e.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(Ta,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:De.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[De.agent_count," agent",De.agent_count!==1?"s":""]})]})]},De.id))})})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col space-y-3 overflow-hidden",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search agents...",value:j,onChange:De=>k(De.target.value),className:"pl-9"})]}),re&&e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:_e,className:"text-xs h-8",disabled:he.length===0,children:[e.jsx(hr,{className:"h-3.5 w-3.5 mr-1.5"}),y.length===he.length&&he.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[y.length," selected"]})]}),e.jsx(Ri,{className:"h-[300px] border rounded-lg",children:R?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):he.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(hr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:he.map(De=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${y.includes(De.id)?"bg-accent":""}`,onClick:()=>Ne(De.id),children:[e.jsx(Bo,{checked:y.includes(De.id),onCheckedChange:()=>Ne(De.id),className:"flex-shrink-0"}),e.jsx(xn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(yn,{className:"text-xs bg-primary/10 text-primary",children:Me(De.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:De.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:De.email})]})]},De.id))})})]}),e.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[e.jsx(ve,{htmlFor:"message",className:"text-sm font-medium",children:"Add a message (optional)"}),e.jsx(Ar,{id:"message",placeholder:"I thought you might find this useful...",value:I,onChange:De=>L(De.target.value),rows:2,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2 flex-shrink-0",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:we,disabled:Fe===0||q,children:q?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Sharing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(aa,{className:"h-4 w-4 mr-2"}),"Share"]})})]})]})]})})}function DM({resourceType:t,resourceId:s,resourceTitle:r,variant:n="outline",size:a="sm",className:o=""}){const[l,i]=C.useState(!1),{user:d}=Hs();return d?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:n,size:a,onClick:()=>i(!0),className:o,children:[e.jsx(ld,{className:"h-4 w-4 mr-2"}),"Share"]}),e.jsx(fDt,{open:l,onOpenChange:i,resourceType:t,resourceId:s,resourceTitle:r})]}):null}function gDt(){const{eventId:t}=ko(),s=Pr(),{user:r}=Hs(),[n,a]=C.useState(null),[o,l]=C.useState(null),[i,d]=C.useState(0),[u,p]=C.useState(!0),[f,y]=C.useState(!1);C.useEffect(()=>{t&&_()},[t,r]);const _=async()=>{try{const{data:T,error:I}=await G.from("events").select("*").eq("id",t).single();if(I)throw I;a(T);const{count:L}=await G.from("event_registrations").select("*",{count:"exact",head:!0}).eq("event_id",t);if(d(L||0),r){const{data:R}=await G.from("event_registrations").select("id, zoom_join_url").eq("event_id",t).eq("user_id",r.id).maybeSingle();l(R)}}catch(T){console.error("Error loading event:",T),fe.error("Failed to load event"),s("/events")}finally{p(!1)}},b=async()=>{if(!(!r||!n)){y(!0);try{const{error:T}=await G.auth.refreshSession();if(T){console.error("Session refresh failed:",T),fe.error("Your session has expired. Please log in again.");return}if(o){const{error:I}=await G.functions.invoke("zoom-unregister",{body:{event_id:n.id}});if(I)throw I;fe.success("Successfully cancelled registration"),l(null),d(L=>L-1)}else{const{data:I,error:L}=await G.functions.invoke("zoom-register",{body:{event_id:n.id}});if(L)throw L;fe.success("Successfully registered for event!"),l({id:I.registration_id,zoom_join_url:I.zoom_join_url}),d(R=>R+1)}}catch(T){console.error("Registration error:",T),fe.error(o?"Failed to cancel registration":"Failed to register for event")}finally{y(!1)}}},w=T=>{var I,L,R;if(T.includes("iframe.mediadelivery.net")||T.includes("video.bunnycdn.com")){const $=T.match(/embed\/(\d+)\/([a-f0-9-]+)/);if($)return`https://iframe.mediadelivery.net/embed/${$[1]}/${$[2]}?autoplay=false&preload=true`}if(T.includes("youtube.com")||T.includes("youtu.be")){const $=T.includes("youtu.be")?(I=T.split("youtu.be/")[1])==null?void 0:I.split("?")[0]:(L=T.split("v=")[1])==null?void 0:L.split("&")[0];if($)return`https://www.youtube.com/embed/${$}`}if(T.includes("vimeo.com")){const $=(R=T.split("vimeo.com/")[1])==null?void 0:R.split("?")[0];if($)return`https://player.vimeo.com/video/${$}`}return T};if(u)return e.jsx(Ts,{title:"Event",children:e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading event..."})]})})});if(!n)return e.jsx(Ts,{title:"Event Not Found",children:e.jsxs("div",{className:"text-center py-16",children:[e.jsx("p",{className:"text-muted-foreground",children:"Event not found"}),e.jsx(K,{onClick:()=>s("/events"),className:"mt-4",children:"Back to Events"})]})});const j=sy(new Date(n.event_date)),k=n.capacity&&i>=n.capacity,S=(o==null?void 0:o.zoom_join_url)||n.zoom_link;return e.jsx(Ts,{title:n.title,children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs(K,{variant:"ghost",className:"mb-6 gap-2",onClick:()=>s("/events"),children:[e.jsx(ti,{className:"h-4 w-4"}),"Back to Events"]}),n.image_url&&e.jsxs("div",{className:"relative aspect-video rounded-xl overflow-hidden mb-6",children:[e.jsx("img",{src:n.image_url,alt:n.title,className:"w-full h-full object-cover"}),j&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(rt,{variant:"secondary",className:"text-lg px-4 py-2",children:"Event Ended"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground",children:n.title}),e.jsx(DM,{resourceType:"event",resourceId:n.id,resourceTitle:n.title})]}),n.description&&e.jsx("div",{className:"prose prose-sm max-w-none text-muted-foreground dark:prose-invert",dangerouslySetInnerHTML:{__html:n.description}})]}),n.video_url&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(bm,{className:"h-5 w-5"}),"Event Preview"]}),e.jsx("div",{className:"relative w-full aspect-video rounded-xl overflow-hidden border bg-muted",children:e.jsx("iframe",{src:w(n.video_url),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Event Preview Video"})})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(on,{className:"h-5 w-5 text-primary mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(n.event_date))}),e.jsx("p",{className:"text-sm text-muted-foreground",children:h6(new Date(n.event_date))})]})]}),n.capacity&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(hr,{className:"h-5 w-5 text-primary mt-0.5"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[i," / ",n.capacity]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Registered"})]})]}),o&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-500/10 rounded-lg",children:[e.jsx(hi,{className:"h-5 w-5 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-700",children:"You're registered!"})]}),e.jsxs("div",{className:"space-y-2 pt-2",children:[!j&&e.jsx(e.Fragment,{children:o?e.jsxs(e.Fragment,{children:[e.jsxs(K,{className:"w-full gap-2",onClick:()=>window.open(S,"_blank"),children:[e.jsx(sn,{className:"h-4 w-4"}),"Join Event"]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:b,disabled:f,children:[f?e.jsx(Ms,{className:"h-4 w-4 animate-spin mr-2"}):null,"Cancel Registration"]})]}):e.jsx(K,{className:"w-full gap-2",onClick:b,disabled:f||(k??!1),children:f?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):k?"Event Full":"Register Now"})}),j&&o&&e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:()=>window.open(n.zoom_link,"_blank"),children:[e.jsx(sn,{className:"h-4 w-4"}),"View Recording"]})]})]})})})]})]})})}const xDt=[{id:"quickvid",name:"QuickVid",description:"Record, manage, and share personalized video messages",icon:e.jsx(Nn,{className:"h-6 w-6"}),path:"/mission-control/video-library",category:"Marketing"},{id:"smart-card",name:"Smart Card",description:"Your digital business card — share your info with a single link",icon:e.jsx(yf,{className:"h-6 w-6"}),path:"/mission-control/my-card",category:"Marketing"},{id:"smart-presentations",name:"Smart Presentations",description:"Create beautiful listing and buyer presentations",icon:e.jsx(Hg,{className:"h-6 w-6"}),path:"/mission-control/presentations",category:"Marketing"},{id:"landing-pages",name:"Landing Pages",description:"Build custom landing pages to capture leads",icon:e.jsx(In,{className:"h-6 w-6"}),path:"/mission-control/landing-pages",category:"Marketing"},{id:"guest-book",name:"Guest Book",description:"Digital open house sign-in to capture visitor info",icon:e.jsx(Fu,{className:"h-6 w-6"}),path:"/mission-control/guest-book",category:"Open House"},{id:"card-studio",name:"Card Studio",description:"Send beautiful animated digital cards for birthdays, anniversaries & milestones",icon:e.jsx(hn,{className:"h-6 w-6"}),path:"/mission-control/card-studio",category:"Marketing"},{id:"direct-mail",name:"Direct Mail",description:"Send professional postcards to your contacts via direct mail",icon:e.jsx(br,{className:"h-6 w-6"}),path:"/mission-control/direct-mail",category:"Marketing",adminOnly:!0,beta:!0},{id:"mass-emails",name:"Mass Emails",description:"Create and send bulk email campaigns to your contacts",icon:e.jsx(aa,{className:"h-6 w-6"}),path:"/admin/email-campaigns",category:"Marketing",beta:!0}],yDt=()=>{const{user:t,isAdmin:s}=Hs(),r=Pr(),[n,a]=C.useState([]),[o,l]=C.useState(!0),[i,d]=C.useState(""),[u,p]=C.useState("all"),[f,y]=C.useState(new Set);C.useEffect(()=>{_()},[t]);const _=async()=>{try{const{data:R}=await G.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),$=(R==null?void 0:R.map(Q=>Q.tag))||[],{data:q,error:U}=await G.from("app_tiles").select("*").order("name");if(U)throw U;const{data:H}=await G.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),Y=new Set((H==null?void 0:H.map(Q=>Q.app_id))||[]);y(Y);const te=((q==null?void 0:q.filter(Q=>!Q.required_tags||Q.required_tags.length===0?!0:Q.required_tags.some(de=>$.includes(de))))||[]).sort((Q,de)=>Q.name==="LevelUp Members Portal"?-1:de.name==="LevelUp Members Portal"?1:0);a(te)}catch(R){console.error("Error loading apps:",R),fe.error("Failed to load apps")}finally{l(!1)}},b=async R=>{var q;const $=window.open("about:blank","_blank");try{const{data:U,error:H}=await G.auth.getSession();if(H||!U.session){$==null||$.close(),fe.error("Session expired. Please refresh the page and try again.");return}const Y=U.session.access_token;await G.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:R.app_id,app_name:R.name,user_agent:navigator.userAgent});const{data:se,error:te}=await G.functions.invoke("sso-launch",{body:{app_id:R.app_id},headers:{Authorization:`Bearer ${Y}`}});if(te)throw te;se!=null&&se.redirect_url?$&&!$.closed?($.location.href=se.redirect_url,(q=$.focus)==null||q.call($)):window.location.assign(se.redirect_url):($==null||$.close(),fe.error("Launch link unavailable"))}catch(U){$==null||$.close(),console.error("Error launching app:",U),fe.error("Failed to launch app. Please try again.")}},w=async(R,$)=>{R.stopPropagation();const q=f.has($);try{if(q){const{error:U}=await G.from("user_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("app_id",$);if(U)throw U;y(H=>{const Y=new Set(H);return Y.delete($),Y}),fe.success("Removed from favorites")}else{const{error:U}=await G.from("user_favorites").insert({user_id:t==null?void 0:t.id,app_id:$});if(U)throw U;y(H=>new Set(H).add($)),fe.success("Added to favorites")}}catch(U){console.error("Error toggling favorite:",U),fe.error("Failed to update favorites")}},j=n.filter(R=>{var q;const $=R.name.toLowerCase().includes(i.toLowerCase())||((q=R.description)==null?void 0:q.toLowerCase().includes(i.toLowerCase()));return u==="favorites"?$&&f.has(R.id):$}),k=xDt.filter(R=>R.adminOnly&&!s?!1:R.name.toLowerCase().includes(i.toLowerCase())||R.description.toLowerCase().includes(i.toLowerCase())),S=k.reduce((R,$)=>(R[$.category]||(R[$.category]=[]),R[$.category].push($),R),{}),T=[{id:"all",label:"All"},{id:"tools",label:"Built-in Tools"},{id:"apps",label:"Connected Apps"},{id:"favorites",label:"Favorites"}];if(o)return e.jsx(Ts,{title:"Apps & Tools",children:e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading apps & tools..."})]})})});const I=u==="all"||u==="tools",L=u==="all"||u==="apps"||u==="favorites";return e.jsxs(Ts,{title:"Apps & Tools",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"Apps & Tools"}),e.jsxs("div",{className:"relative max-w-sm w-full",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search apps & tools...",className:"pl-10 bg-muted/50 border-0 focus-visible:ring-1",value:i,onChange:R=>d(R.target.value)})]})]}),e.jsx("div",{className:"flex gap-6 border-b border-border mb-8",children:T.map(R=>e.jsxs("button",{onClick:()=>p(R.id),className:Pt("pb-3 text-sm font-medium transition-colors relative",u===R.id?"text-primary":"text-muted-foreground hover:text-foreground"),children:[R.label,u===R.id&&e.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]},R.id))}),I&&Object.keys(S).length>0&&e.jsxs("div",{className:"mb-10",children:[u==="all"&&e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(Wg,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Built-in Tools"})]}),Object.entries(S).map(([R,$])=>e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground bg-muted px-2.5 py-1 rounded-full",children:R})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:$.map(q=>e.jsxs("div",{onClick:()=>r(q.path),className:"group flex items-start gap-4 p-5 bg-card rounded-xl border border-border transition-all duration-200 hover:shadow-lg hover:border-primary/30 cursor-pointer",children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-primary/10 text-primary flex items-center justify-center",children:q.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate flex items-center gap-2",children:[q.name,q.beta&&e.jsx("span",{className:"text-[10px] font-medium bg-primary/10 text-primary px-1.5 py-0.5 rounded-full",children:"Beta"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:q.description})]})]},q.id))})]},R))]}),L&&e.jsxs("div",{children:[u==="all"&&j.length>0&&e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(sn,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Connected Apps"})]}),j.length===0&&u!=="all"?e.jsx("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:u==="favorites"?e.jsxs(e.Fragment,{children:[e.jsx($g,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No favorites yet"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:"Click the bookmark icon on any app to add it to your favorites"})]}):e.jsxs(e.Fragment,{children:[e.jsx($u,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No apps available"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:s?"Get started by adding apps in the admin panel":"Contact your administrator to get access to apps"}),s&&e.jsx(K,{className:"mt-4",onClick:()=>r("/admin/apps"),children:"Add Apps"})]})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:j.map(R=>{const $=f.has(R.id),q=R.name.toLowerCase().includes("agent review")||R.app_id==="agent_review";return e.jsxs("div",{className:"group flex flex-col p-5 bg-card rounded-xl border border-border transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"flex items-start gap-4 cursor-pointer",onClick:()=>b(R),children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-primary/10 flex items-center justify-center text-3xl",children:R.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate",children:R.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:R.description})]}),e.jsx("button",{className:Pt("flex-shrink-0 p-1 transition-colors",$?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:U=>w(U,R.id),children:e.jsx($g,{className:Pt("h-5 w-5",$&&"fill-current")})})]}),q&&e.jsx("a",{href:"https://forms.gle/vXnrzgSnPbw7CKPV6",target:"_blank",rel:"noopener noreferrer",onClick:U=>U.stopPropagation(),className:"mt-3 text-sm text-primary hover:underline flex items-center gap-1",children:"Create your account with this link →"})]},R.id)})})]}),I&&L&&j.length===0&&k.length===0&&i&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:[e.jsx(gn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No results found"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:"Try a different search term"})]})]})},vDt=()=>{const t=Pr(),[s,r]=C.useState(""),[n,a]=C.useState("all"),[o,l]=C.useState("all"),[i,d]=C.useState("grid"),{data:u=[]}=wt({queryKey:["template-categories"],queryFn:async()=>{const{data:k,error:S}=await G.from("template_categories").select("*").order("name");if(S)throw S;return k}}),{data:p=[]}=wt({queryKey:["template-types"],queryFn:async()=>{const{data:k,error:S}=await G.from("template_types").select("*").order("name");if(S)throw S;return k}}),{data:f=[],isLoading:y}=wt({queryKey:["canva-templates"],queryFn:async()=>{const{data:k,error:S}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(S)throw S;const{data:T,error:I}=await G.from("template_links").select("*").order("sort_order");if(I)throw I;const{data:L}=await G.from("template_likes").select("template_id"),{data:R}=await G.from("template_comments").select("template_id"),$=new Map;L==null||L.forEach(H=>{$.set(H.template_id,($.get(H.template_id)||0)+1)});const q=new Map;return R==null||R.forEach(H=>{q.set(H.template_id,(q.get(H.template_id)||0)+1)}),(k||[]).map(H=>({...H,links:(T||[]).filter(Y=>Y.template_id===H.id)||[],likesCount:$.get(H.id)||0,commentsCount:q.get(H.id)||0}))}}),_=f.filter(k=>{var L;const S=k.name.toLowerCase().includes(s.toLowerCase())||((L=k.description)==null?void 0:L.toLowerCase().includes(s.toLowerCase())),T=n==="all"||k.category_id===n,I=o==="all"||k.type_id===o;return S&&T&&I}),b=()=>{r(""),a("all"),l("all")},w=s||n!=="all"||o!=="all",j=k=>{t(`/templates/${k}`)};return e.jsx(Ts,{title:"Canva Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-bold text-foreground text-5xl",children:"Canva Templates"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Browse and use our collection of professionally designed templates"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search templates...",value:s,onChange:k=>r(k.target.value),className:"pl-9"})]}),e.jsxs(sr,{value:n,onValueChange:a,children:[e.jsx(er,{className:"w-full sm:w-48",children:e.jsx(rr,{placeholder:"All Categories"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Categories"}),u.map(k=>e.jsx(At,{value:k.id,children:k.name},k.id))]})]}),e.jsxs(sr,{value:o,onValueChange:l,children:[e.jsx(er,{className:"w-full sm:w-48",children:e.jsx(rr,{placeholder:"All Types"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Types"}),p.map(k=>e.jsx(At,{value:k.id,children:k.name},k.id))]})]}),e.jsxs("div",{className:"flex gap-2",children:[w&&e.jsx(K,{variant:"outline",size:"sm",onClick:b,children:"Clear Filters"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:i==="grid"?"secondary":"outline",size:"icon",onClick:()=>d("grid"),className:"rounded-full",children:e.jsx(yp,{className:"h-4 w-4"})}),e.jsx(K,{variant:i==="list"?"secondary":"outline",size:"icon",onClick:()=>d("list"),className:"rounded-full",children:e.jsx(Hh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[_.length," template",_.length!==1?"s":""," found"]}),y&&e.jsx("div",{className:i==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(8)].map((k,S)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(xs,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(xs,{className:"h-5 w-3/4 mb-2"}),e.jsx(xs,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(xs,{className:"h-5 w-16"}),e.jsx(xs,{className:"h-5 w-20"})]})]})},S))}),!y&&_.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:w?"No templates match your filters":"No templates available yet"}),w&&e.jsx(K,{variant:"outline",onClick:b,children:"Clear Filters"})]}),!y&&_.length>0&&e.jsx("div",{className:i==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:_.map(k=>e.jsxs(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${i==="list"?"flex flex-row":""}`,onClick:()=>j(k.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${i==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[k.preview_image_url?e.jsx("img",{src:k.preview_image_url,alt:k.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"}),k.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(rt,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm !text-secondary",children:[e.jsx(Do,{className:"h-3 w-3"}),k.links.length]})})]}),e.jsxs(Oe,{className:`p-4 flex flex-col ${i==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:k.name}),k.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:poe(k.description)}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[k.category&&e.jsx(rt,{variant:"secondary",className:"text-xs",children:k.category.name}),k.type&&e.jsx(rt,{variant:"outline",className:"text-xs",children:k.type.name})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gu,{className:"h-3.5 w-3.5"}),k.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xc,{className:"h-3.5 w-3.5"}),k.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:S=>{S.stopPropagation(),j(k.id)},children:[e.jsx(sn,{className:"h-4 w-4"}),"View Template"]})]})]},k.id))})]})})};var _Dt="Separator",UAe="horizontal",bDt=["horizontal","vertical"],JGe=C.forwardRef((t,s)=>{const{decorative:r,orientation:n=UAe,...a}=t,o=wDt(n)?n:UAe,i=r?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return e.jsx(Qr.div,{"data-orientation":o,...i,...a,ref:s})});JGe.displayName=_Dt;function wDt(t){return bDt.includes(t)}var eKe=JGe;const Rl=C.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...n},a)=>e.jsx(eKe,{ref:a,decorative:r,orientation:s,className:Pt("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));Rl.displayName=eKe.displayName;const KL=()=>({trackEngagement:C.useCallback(async(s,r,n,a="view")=>{try{const{data:{user:o}}=await G.auth.getUser();if(!o)return;await G.from("content_engagement_logs").insert({user_id:o.id,resource_type:s,resource_id:r,resource_title:n,action_type:a})}catch(o){console.error("Error tracking engagement:",o)}},[])}),jDt=()=>{const{templateId:t}=ko(),s=Pr(),{user:r,isAdmin:n}=Hs(),{toast:a}=Pa(),o=rs(),{trackEngagement:l}=KL(),[i,d]=C.useState(""),{data:u,isLoading:p}=wt({queryKey:["template-detail",t],queryFn:async()=>{const{data:I,error:L}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("id",t).single();if(L)throw L;const{data:R}=await G.from("template_links").select("*").eq("template_id",t).order("sort_order"),{data:$}=await G.from("template_guides").select("*").eq("template_id",t).order("sort_order");return{...I,links:R||[],guides:$||[]}},enabled:!!t}),{data:f=[]}=wt({queryKey:["template-linked-toolkits",t],queryFn:async()=>{const{data:I,error:L}=await G.from("resource_kit_templates").select("kit_id, resource_kits:kit_id(id, name, featured_image_url)").eq("template_id",t);if(L)throw L;return(I||[]).map(R=>R.resource_kits).filter(Boolean)},enabled:!!t});C.useEffect(()=>{u&&l("template",u.id,u.name,"view")},[u==null?void 0:u.id]);const{data:y=[]}=wt({queryKey:["template-likes",t],queryFn:async()=>{const{data:I,error:L}=await G.from("template_likes").select("*").eq("template_id",t);if(L)throw L;return I},enabled:!!t}),{data:_=[]}=wt({queryKey:["template-comments",t],queryFn:async()=>{const{data:I,error:L}=await G.from("template_comments").select("*").eq("template_id",t).order("created_at",{ascending:!1});if(L)throw L;const R=[...new Set(I.map(U=>U.user_id))],{data:$}=await G.from("profiles").select("id, name").in("id",R),q=new Map(($==null?void 0:$.map(U=>[U.id,U.name]))||[]);return I.map(U=>({...U,user_name:q.get(U.user_id)||"Unknown User"}))},enabled:!!t}),b=Dt({mutationFn:async I=>{const{error:L}=await G.from("template_comments").insert({template_id:t,user_id:r.id,content:I});if(L)throw L},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),d(""),a({title:"Comment added!"})},onError:I=>{a({title:"Error adding comment",description:I.message,variant:"destructive"})}}),w=Dt({mutationFn:async I=>{const{error:L}=await G.from("template_comments").delete().eq("id",I);if(L)throw L},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),a({title:"Comment deleted"})}}),j=Dt({mutationFn:async()=>{const I=y.find(L=>L.user_id===(r==null?void 0:r.id));if(I){const{error:L}=await G.from("template_likes").delete().eq("id",I.id);if(L)throw L}else{const{error:L}=await G.from("template_likes").insert({template_id:t,user_id:r.id});if(L)throw L}},onSuccess:()=>{o.invalidateQueries({queryKey:["template-likes",t]})}}),k=y.some(I=>I.user_id===(r==null?void 0:r.id)),S=I=>I.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),T=I=>{I.preventDefault(),!(!i.trim()||!r)&&b.mutate(i.trim())};return p?e.jsx(Ts,{title:"Templates",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):u?e.jsx(Ts,{title:u.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(vo,{to:"/templates",children:[e.jsx(ti,{className:"h-4 w-4"}),"Back to Templates"]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:u.name}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.category&&e.jsx(rt,{variant:"secondary",children:u.category.name}),u.type&&e.jsx(rt,{variant:"outline",children:u.type.name})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(vo,{to:`/admin/templates?edit=${u.id}`,children:[e.jsx(Da,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(DM,{resourceType:"template",resourceId:u.id,resourceTitle:u.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:k?"default":"outline",className:"gap-2 rounded-full",onClick:()=>j.mutate(),disabled:!r||j.isPending,children:[e.jsx(gu,{className:`h-4 w-4 ${k?"fill-current":""}`}),y.length," ",y.length===1?"Like":"Likes"]})]})]}),u.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert [&>p]:mb-4 [&>p:last-child]:mb-0 whitespace-pre-line",dangerouslySetInnerHTML:{__html:u.description}})]}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Do,{className:"h-4 w-4"}),u.links.length===1?"Template Link":"Template Links"]}),e.jsx("div",{className:"grid gap-2",children:u.links.map(I=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_canva"),window.open(I.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:I.title}),e.jsx(sn,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),u.video_url&&e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsx("div",{className:"aspect-video w-full rounded-lg overflow-hidden",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})}),u.guides&&u.guides.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(In,{className:"h-4 w-4"}),"Guide Files"]}),e.jsx("div",{className:"grid gap-2",children:u.guides.map(I=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_pdf"),window.open(I.file_url,"_blank")},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:I.name}),I.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(I.file_size/1024).toFixed(0)," KB)"]})]}),e.jsx(xi,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),f.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(dl,{className:"h-4 w-4"}),"Related Toolkits"]}),e.jsx("div",{className:"grid gap-2",children:f.map(I=>e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-3 h-auto py-3",onClick:()=>s(`/toolbox/${I.id}`),children:[I.featured_image_url?e.jsx("img",{src:I.featured_image_url,alt:"",className:"w-10 h-10 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(dl,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"font-medium",children:I.name})]},I.id))})]})}),e.jsx(Rl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(xc,{className:"h-5 w-5"}),"Comments (",_.length,")"]}),r?e.jsxs("form",{onSubmit:T,className:"flex gap-2",children:[e.jsx(Ar,{placeholder:"Add a comment...",value:i,onChange:I=>d(I.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!i.trim()||b.isPending,children:e.jsx(aa,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:_.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):_.map(I=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(xn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(yn,{className:"text-sm",children:S(I.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:I.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Sd(new Date(I.created_at),{addSuffix:!0})}),I.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>w.mutate(I.id),children:e.jsx(jr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:I.content})]})]})})},I.id))})]})]})}):e.jsx(Ts,{title:"Templates",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Do,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Template not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This template may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(vo,{to:"/templates",children:"Back to Templates"})})]})})},NDt=()=>{const{user:t}=Hs(),[s,r]=C.useState(""),[n,a]=C.useState("all"),{data:o=[]}=wt({queryKey:["academy-categories"],queryFn:async()=>{const{data:y,error:_}=await G.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(_)throw _;return y}}),{data:l=[],isLoading:i}=wt({queryKey:["academy-videos"],queryFn:async()=>{const{data:y,error:_}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("is_published",!0).order("publish_date",{ascending:!1});if(_)throw _;const{data:b,error:w}=await G.from("academy_resources").select("*").order("sort_order");if(w)throw w;return y.map(k=>({...k,resources:(b==null?void 0:b.filter(S=>S.video_id===k.id))||[]}))}}),{data:d=[]}=wt({queryKey:["academy-video-likes"],queryFn:async()=>{const{data:y,error:_}=await G.from("academy_video_likes").select("video_id, user_id");if(_)throw _;return y}}),u=l.filter(y=>{var w;const _=s===""||y.title.toLowerCase().includes(s.toLowerCase())||((w=y.description)==null?void 0:w.toLowerCase().includes(s.toLowerCase())),b=n==="all"||y.category_id===n;return _&&b}),p=y=>d.filter(_=>_.video_id===y).length,f=y=>d.some(_=>_.video_id===y&&_.user_id===(t==null?void 0:t.id));return e.jsx(Ts,{title:"Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Academy"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"On-demand training videos and resources"})]}),e.jsx("div",{className:"flex flex-col sm:flex-row gap-4",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search videos...",value:s,onChange:y=>r(y.target.value),className:"pl-10"})]})}),e.jsx(ka,{value:n,onValueChange:a,children:e.jsxs(_a,{className:"w-full justify-start flex-wrap h-auto gap-2 bg-transparent p-0",children:[e.jsx(js,{value:"all",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:"All Videos"}),o.map(y=>e.jsx(js,{value:y.id,className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:y.name},y.id))]})}),i?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):u.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Nn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No videos found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:s?"Try adjusting your search terms":"Check back soon for new content"})]})}):e.jsx("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-3",children:u.map(y=>e.jsx(vo,{to:`/academy/${y.id}`,children:e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow group h-full",children:[e.jsxs("div",{className:"relative aspect-video bg-muted",children:[y.thumbnail_url?e.jsx("img",{src:y.thumbnail_url,alt:y.title,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Nn,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx("div",{className:"absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/90 flex items-center justify-center",children:e.jsx(ul,{className:"h-8 w-8 text-primary-foreground ml-1"})})}),y.duration&&e.jsxs("div",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-2 py-1 rounded flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),y.duration]})]}),e.jsxs(It,{className:"pb-2",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsx(Ot,{className:"text-lg line-clamp-2",children:y.title})}),y.category&&e.jsx(rt,{variant:"secondary",className:"w-fit",children:y.category.name})]}),e.jsxs(Oe,{className:"pt-0",children:[y.description&&e.jsx(pr,{className:"line-clamp-2",children:y.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 mt-3 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gu,{className:`h-4 w-4 ${f(y.id)?"fill-primary text-primary":""}`}),p(y.id)]}),y.resources&&y.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-4 w-4"}),y.resources.length]})]})]})]})},y.id))})]})})};function tKe({resourceType:t,resourceId:s}){const{data:r=[]}=wt({queryKey:["linked-templates",t,s],queryFn:async()=>{if(t==="academy_video"){const{data:n,error:a}=await G.from("academy_video_templates").select("template_id, canva_templates:template_id(id, name, preview_image_url)").eq("video_id",s);if(a)throw a;return(n||[]).map(o=>o.canva_templates).filter(Boolean)}else{const{data:n,error:a}=await G.from("resource_kit_templates").select("template_id, canva_templates:template_id(id, name, preview_image_url)").eq("kit_id",s);if(a)throw a;return(n||[]).map(o=>o.canva_templates).filter(Boolean)}},enabled:!!s});return r.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-sm",children:[e.jsx(Bl,{className:"h-4 w-4"}),"Related Templates"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(n=>e.jsx(vo,{to:`/templates/${n.id}`,children:e.jsxs(rt,{variant:"secondary",className:"cursor-pointer hover:bg-secondary/80 transition-colors gap-1.5 px-3 py-1.5 text-xs font-medium rounded-full",children:[e.jsx(Bl,{className:"h-3 w-3"}),n.name]})},n.id))})]})}const kDt=(t,s)=>{if(s==="bunny_stream"){let r=t.replace("iframe.mediadelivery.net","player.mediadelivery.net");return r.includes("?")||(r+="?autoplay=false&loop=false&muted=false&preload=true&responsive=true"),r}if(s==="youtube"){const r=/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,n=t.match(r);if(n)return`https://www.youtube.com/embed/${n[1]}`}if(s==="vimeo"){const r=/vimeo\.com\/(?:video\/)?(\d+)/,n=t.match(r);if(n)return`https://player.vimeo.com/video/${n[1]}`}if(s==="loom"){const r=/loom\.com\/share\/([a-zA-Z0-9]+)/,n=t.match(r);if(n)return`https://www.loom.com/embed/${n[1]}`}return t},SDt=()=>{const{videoId:t}=ko();Pr();const{user:s,isAdmin:r}=Hs(),{toast:n}=Pa(),a=rs(),{trackEngagement:o}=KL(),[l,i]=C.useState(""),{data:d,isLoading:u}=wt({queryKey:["academy-video",t],queryFn:async()=>{const{data:T,error:I}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("id",t).eq("is_published",!0).single();if(I)throw I;const{data:L}=await G.from("academy_resources").select("*").eq("video_id",t).order("sort_order");return{...T,resources:L||[]}},enabled:!!t});C.useEffect(()=>{d&&o("academy_video",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:p=[]}=wt({queryKey:["academy-video-likes",t],queryFn:async()=>{const{data:T,error:I}=await G.from("academy_video_likes").select("*").eq("video_id",t);if(I)throw I;return T},enabled:!!t}),{data:f=[]}=wt({queryKey:["academy-video-comments",t],queryFn:async()=>{const{data:T,error:I}=await G.from("academy_video_comments").select("*").eq("video_id",t).order("created_at",{ascending:!1});if(I)throw I;const L=[...new Set(T.map(q=>q.user_id))],{data:R}=await G.from("profiles").select("id, name").in("id",L),$=new Map((R==null?void 0:R.map(q=>[q.id,q.name]))||[]);return T.map(q=>({...q,user_name:$.get(q.user_id)||"Unknown User"}))},enabled:!!t}),y=Dt({mutationFn:async T=>{const{error:I}=await G.from("academy_video_comments").insert({video_id:t,user_id:s.id,content:T});if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),i(""),n({title:"Comment added!"})},onError:T=>{n({title:"Error adding comment",description:T.message,variant:"destructive"})}}),_=Dt({mutationFn:async T=>{const{error:I}=await G.from("academy_video_comments").delete().eq("id",T);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),n({title:"Comment deleted"})}}),b=Dt({mutationFn:async()=>{const T=p.find(I=>I.user_id===(s==null?void 0:s.id));if(T){const{error:I}=await G.from("academy_video_likes").delete().eq("id",T.id);if(I)throw I}else{const{error:I}=await G.from("academy_video_likes").insert({video_id:t,user_id:s.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-likes",t]})}}),w=p.some(T=>T.user_id===(s==null?void 0:s.id)),j=T=>{switch(T==null?void 0:T.toLowerCase()){case"pdf":return"📄";case"pptx":case"ppt":return"📊";case"xlsx":case"xls":return"📈";case"docx":case"doc":return"📝";case"zip":return"📦";default:return"📁"}},k=T=>T.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),S=T=>{T.preventDefault(),!(!l.trim()||!s)&&y.mutate(l.trim())};return u?e.jsx(Ts,{title:"Academy",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):d?e.jsx(Ts,{title:d.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(vo,{to:"/academy",children:[e.jsx(ti,{className:"h-4 w-4"}),"Back to Academy"]})}),e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-black",style:{paddingTop:"56.25%"},children:["youtube","vimeo","loom","bunny_stream"].includes(d.video_type)?e.jsx("iframe",{src:kDt(d.video_url,d.video_type),loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,height:"100%",width:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-white gap-4",children:[e.jsx(Nn,{className:"h-16 w-16 opacity-50"}),e.jsx(K,{variant:"secondary",asChild:!0,children:e.jsxs("a",{href:d.video_url,target:"_blank",rel:"noopener noreferrer",className:"gap-2",children:[e.jsx(sn,{className:"h-4 w-4"}),"Open Video"]})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:d.title}),d.category&&e.jsx(rt,{variant:"secondary",children:d.category.name})]}),e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(vo,{to:`/admin/academy?edit=${d.id}`,children:[e.jsx(Da,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(DM,{resourceType:"academy_video",resourceId:d.id,resourceTitle:d.title}),e.jsxs(K,{variant:w?"default":"outline",className:"gap-2 w-fit",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(gu,{className:`h-4 w-4 ${w?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),d.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:d.description}})]}),d.resources&&d.resources.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(In,{className:"h-4 w-4"}),"Resources"]}),e.jsx("div",{className:"grid gap-2",children:d.resources.map(T=>e.jsxs("a",{href:T.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-3 rounded-lg border hover:bg-muted transition-colors",children:[e.jsx("span",{className:"text-2xl",children:j(T.file_type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:T.title}),e.jsx("p",{className:"text-xs text-muted-foreground uppercase",children:T.file_type})]}),e.jsx(xi,{className:"h-4 w-4 text-muted-foreground"})]},T.id))})]})}),e.jsx(tKe,{resourceType:"academy_video",resourceId:d.id}),e.jsx(Rl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(xc,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[e.jsx(Ar,{placeholder:"Add a comment...",value:l,onChange:T=>i(T.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||y.isPending,children:e.jsx(aa,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:f.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(T=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(xn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(yn,{className:"text-sm",children:k(T.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:T.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Sd(new Date(T.created_at),{addSuffix:!0})}),T.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(T.id),children:e.jsx(jr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:T.content})]})]})})},T.id))})]})]})}):e.jsx(Ts,{title:"Academy",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Nn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Video not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This video may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(vo,{to:"/academy",children:"Back to Academy"})})]})})};function CDt(){const t=Pr(),[s,r]=C.useState(""),{data:n,isLoading:a}=wt({queryKey:["resource-kits-published"],queryFn:async()=>{const{data:_,error:b}=await G.from("resource_kits").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(b)throw b;return _}}),{data:o}=wt({queryKey:["resource-kit-files-all"],queryFn:async()=>{const{data:_,error:b}=await G.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(b)throw b;return _}}),{data:l}=wt({queryKey:["resource-kit-likes-all"],queryFn:async()=>{const{data:_,error:b}=await G.from("resource_kit_likes").select("kit_id");if(b)throw b;return _}}),{data:i}=wt({queryKey:["resource-kit-comments-all"],queryFn:async()=>{const{data:_,error:b}=await G.from("resource_kit_comments").select("kit_id");if(b)throw b;return _}}),d=n==null?void 0:n.filter(_=>{var b;return _.name.toLowerCase().includes(s.toLowerCase())||((b=_.description)==null?void 0:b.toLowerCase().includes(s.toLowerCase()))}),u=_=>(o==null?void 0:o.filter(b=>b.kit_id===_))||[],p=_=>(l==null?void 0:l.filter(b=>b.kit_id===_).length)||0,f=_=>(i==null?void 0:i.filter(b=>b.kit_id===_).length)||0,y=_=>{t(`/toolbox/${_}`)};return e.jsx(Ts,{title:"Toolbox",description:"Download resource kits and tools to help grow your business",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Toolbox"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Download resource kits and tools to help grow your business"})]}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search resource kits...",value:s,onChange:_=>r(_.target.value),className:"pl-10"})]}),!a&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(d==null?void 0:d.length)||0," resource kit",(d==null?void 0:d.length)!==1?"s":""," available"]}),a?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(8)].map((_,b)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(xs,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(xs,{className:"h-5 w-3/4 mb-2"}),e.jsx(xs,{className:"h-4 w-full mb-4"}),e.jsx(xs,{className:"h-4 w-2/3"})]})},b))}):(d==null?void 0:d.length)===0?e.jsxs(Ee,{className:"p-12 text-center",children:[e.jsx(dl,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No resource kits found"}),e.jsx("p",{className:"text-muted-foreground",children:s?"Try adjusting your search terms":"Check back later for new resources"})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:d==null?void 0:d.map(_=>{const b=u(_.id).length,w=p(_.id),j=f(_.id);return e.jsxs(Ee,{className:"group overflow-hidden cursor-pointer hover:shadow-lg transition-all duration-200",onClick:()=>y(_.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:_.featured_image_url?e.jsx("img",{src:_.featured_image_url,alt:_.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(dl,{className:"h-16 w-16 text-muted-foreground"})})}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:_.name}),_.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:poe(_.description)}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-4 w-4"}),b," file",b!==1?"s":""]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gu,{className:"h-3.5 w-3.5"}),w]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xc,{className:"h-3.5 w-3.5"}),j]})]})]})]})]},_.id)})})]})})}const MDt=()=>{const{kitId:t}=ko(),{user:s,isAdmin:r}=Hs(),{toast:n}=Pa(),a=rs(),{trackEngagement:o}=KL(),[l,i]=C.useState(""),{data:d,isLoading:u}=wt({queryKey:["resource-kit-detail",t],queryFn:async()=>{const{data:T,error:I}=await G.from("resource_kits").select("*").eq("id",t).eq("is_published",!0).single();if(I)throw I;const{data:L}=await G.from("resource_kit_files").select("*").eq("kit_id",t).order("sort_order"),{data:R}=await G.from("resource_kit_links").select("*").eq("kit_id",t).order("sort_order");return{...T,files:L||[],links:R||[]}},enabled:!!t});C.useEffect(()=>{d&&o("toolbox",d.id,d.name,"view")},[d==null?void 0:d.id]);const{data:p=[]}=wt({queryKey:["resource-kit-likes",t],queryFn:async()=>{const{data:T,error:I}=await G.from("resource_kit_likes").select("*").eq("kit_id",t);if(I)throw I;return T},enabled:!!t}),{data:f=[]}=wt({queryKey:["resource-kit-comments",t],queryFn:async()=>{const{data:T,error:I}=await G.from("resource_kit_comments").select("*").eq("kit_id",t).order("created_at",{ascending:!1});if(I)throw I;const L=[...new Set(T.map(q=>q.user_id))],{data:R}=await G.from("profiles").select("id, name").in("id",L),$=new Map((R==null?void 0:R.map(q=>[q.id,q.name]))||[]);return T.map(q=>({...q,user_name:$.get(q.user_id)||"Unknown User"}))},enabled:!!t}),y=Dt({mutationFn:async T=>{const{error:I}=await G.from("resource_kit_comments").insert({kit_id:t,user_id:s.id,content:T});if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),i(""),n({title:"Comment added!"})},onError:T=>{n({title:"Error adding comment",description:T.message,variant:"destructive"})}}),_=Dt({mutationFn:async T=>{const{error:I}=await G.from("resource_kit_comments").delete().eq("id",T);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),n({title:"Comment deleted"})}}),b=Dt({mutationFn:async()=>{const T=p.find(I=>I.user_id===(s==null?void 0:s.id));if(T){const{error:I}=await G.from("resource_kit_likes").delete().eq("id",T.id);if(I)throw I}else{const{error:I}=await G.from("resource_kit_likes").insert({kit_id:t,user_id:s.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-likes",t]})}}),w=p.some(T=>T.user_id===(s==null?void 0:s.id)),j=T=>T.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),k=T=>T?T<1024?T+" B":T<1024*1024?(T/1024).toFixed(1)+" KB":(T/(1024*1024)).toFixed(1)+" MB":"",S=T=>{T.preventDefault(),!(!l.trim()||!s)&&y.mutate(l.trim())};return u?e.jsx(Ts,{title:"Toolbox",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):d?e.jsx(Ts,{title:d.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(vo,{to:"/toolbox",children:[e.jsx(ti,{className:"h-4 w-4"}),"Back to Toolbox"]})}),d.featured_image_url&&e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:d.featured_image_url,alt:d.name,className:"w-full max-h-[400px] object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:d.name})}),e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(vo,{to:`/admin/toolbox?edit=${d.id}`,children:[e.jsx(Da,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(DM,{resourceType:"resource_kit",resourceId:d.id,resourceTitle:d.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:w?"default":"outline",className:"gap-2 rounded-full",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(gu,{className:`h-4 w-4 ${w?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),d.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:d.description}})]}),d.files&&d.files.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(In,{className:"h-4 w-4"}),"Included Resources (",d.files.length,")"]}),e.jsx("div",{className:"grid gap-2",children:d.files.map(T=>e.jsxs("a",{href:T.file_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("toolbox",d.id,d.name,"click_pdf"),className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(In,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:T.name}),T.file_size&&e.jsx("div",{className:"text-xs text-muted-foreground",children:k(T.file_size)})]})]}),e.jsx(xi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},T.id))})]})}),d.links&&d.links.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(sn,{className:"h-4 w-4"}),"Canva Templates (",d.links.length,")"]}),e.jsx("div",{className:"grid gap-2",children:d.links.map(T=>e.jsxs("a",{href:T.canva_share_link,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("toolbox",d.id,d.name,"click_canva"),className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-purple-500/10",children:e.jsx(sn,{className:"h-4 w-4 text-purple-600"})}),e.jsx("div",{className:"font-medium text-sm",children:T.title})]}),e.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-primary transition-colors",children:"Open in Canva"})]},T.id))})]})}),e.jsx(tKe,{resourceType:"resource_kit",resourceId:d.id}),e.jsx(Rl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(xc,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[e.jsx(Ar,{placeholder:"Add a comment...",value:l,onChange:T=>i(T.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||y.isPending,children:e.jsx(aa,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:f.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(T=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(xn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(yn,{className:"text-sm",children:j(T.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:T.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Sd(new Date(T.created_at),{addSuffix:!0})}),T.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(T.id),children:e.jsx(jr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:T.content})]})]})})},T.id))})]})]})}):e.jsx(Ts,{title:"Toolbox",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(dl,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Resource kit not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This resource kit may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(vo,{to:"/toolbox",children:"Back to Toolbox"})})]})})},TDt=()=>{const t=Pr(),[s,r]=C.useState(""),[n,a]=C.useState("grid"),{data:o=[],isLoading:l}=wt({queryKey:["social-swag"],queryFn:async()=>{const{data:u,error:p}=await G.from("social_swag").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(p)throw p;const{data:f,error:y}=await G.from("social_swag_links").select("*").order("sort_order");if(y)throw y;const{data:_}=await G.from("social_swag_likes").select("swag_id"),{data:b}=await G.from("social_swag_comments").select("swag_id"),w=new Map;_==null||_.forEach(S=>{w.set(S.swag_id,(w.get(S.swag_id)||0)+1)});const j=new Map;return b==null||b.forEach(S=>{j.set(S.swag_id,(j.get(S.swag_id)||0)+1)}),(u||[]).map(S=>({...S,links:(f||[]).filter(T=>T.swag_id===S.id)||[],likesCount:w.get(S.id)||0,commentsCount:j.get(S.id)||0}))}}),i=o.filter(u=>{var f;return u.title.toLowerCase().includes(s.toLowerCase())||((f=u.description)==null?void 0:f.toLowerCase().includes(s.toLowerCase()))}),d=u=>{t(`/social-swag/${u}`)};return e.jsx(Ts,{title:"Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Social Swag"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Browse our collection of social media content and graphics"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search social swag...",value:s,onChange:u=>r(u.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[s&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(yp,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Hh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.length," item",i.length!==1?"s":""," found"]}),l&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(8)].map((u,p)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(xs,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(xs,{className:"h-5 w-3/4 mb-2"}),e.jsx(xs,{className:"h-4 w-full mb-4"})]})},p))}),!l&&i.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:s?"No items match your search":"No social swag available yet"}),s&&e.jsx(K,{variant:"outline",onClick:()=>r(""),children:"Clear Search"})]}),!l&&i.length>0&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:i.map(u=>e.jsxs(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${n==="list"?"flex flex-row":""}`,onClick:()=>d(u.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${n==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[u.preview_image_url?e.jsx("img",{src:u.preview_image_url,alt:u.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"}),u.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(rt,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm",children:[e.jsx(Do,{className:"h-3 w-3"}),u.links.length]})})]}),e.jsxs(Oe,{className:`p-4 flex flex-col ${n==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:u.title}),u.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:u.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gu,{className:"h-3.5 w-3.5"}),u.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xc,{className:"h-3.5 w-3.5"}),u.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:p=>{p.stopPropagation(),d(u.id)},children:[e.jsx(sn,{className:"h-4 w-4"}),"View Details"]})]})]},u.id))})]})})};var ui=function(){return ui=Object.assign||function(s){for(var r,n=1,a=arguments.length;n1&&(d||!u),f=s>1&&(u||!d),y=function(){n&&o(n)},_=function(){a&&o(a)};return e.jsx(lOt,{displayMonth:t.displayMonth,hideNext:p,hidePrevious:f,nextMonth:a,previousMonth:n,onPreviousClick:y,onNextClick:_})}function cOt(t){var s,r=Ul(),n=r.classNames,a=r.disableNavigation,o=r.styles,l=r.captionLayout,i=r.components,d=(s=i==null?void 0:i.CaptionLabel)!==null&&s!==void 0?s:nKe,u;return a?u=e.jsx(d,{id:t.id,displayMonth:t.displayMonth}):l==="dropdown"?u=e.jsx(VAe,{displayMonth:t.displayMonth,id:t.id}):l==="dropdown-buttons"?u=e.jsxs(e.Fragment,{children:[e.jsx(VAe,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(HAe,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id})]}):u=e.jsxs(e.Fragment,{children:[e.jsx(d,{id:t.id,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(HAe,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:n.caption,style:o.caption,children:u})}function dOt(t){var s=Ul(),r=s.footer,n=s.styles,a=s.classNames.tfoot;return r?e.jsx("tfoot",{className:a,style:n.tfoot,children:e.jsx("tr",{children:e.jsx("td",{colSpan:8,children:r})})}):e.jsx(e.Fragment,{})}function uOt(t,s,r){for(var n=r?nv(new Date):ch(new Date,{locale:t,weekStartsOn:s}),a=[],o=0;o<7;o++){var l=ml(n,o);a.push(l)}return a}function hOt(){var t=Ul(),s=t.classNames,r=t.styles,n=t.showWeekNumber,a=t.locale,o=t.weekStartsOn,l=t.ISOWeek,i=t.formatters.formatWeekdayName,d=t.labels.labelWeekday,u=uOt(a,o,l);return e.jsxs("tr",{style:r.head_row,className:s.head_row,children:[n&&e.jsx("td",{style:r.head_cell,className:s.head_cell}),u.map(function(p,f){return e.jsx("th",{scope:"col",className:s.head_cell,style:r.head_cell,"aria-label":d(p,{locale:a}),children:i(p,{locale:a})},f)})]})}function mOt(){var t,s=Ul(),r=s.classNames,n=s.styles,a=s.components,o=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:hOt;return e.jsx("thead",{style:n.head,className:r.head,children:e.jsx(o,{})})}function pOt(t){var s=Ul(),r=s.locale,n=s.formatters.formatDay;return e.jsx(e.Fragment,{children:n(t.date,{locale:r})})}var cwe=C.createContext(void 0);function fOt(t){if(!ZL(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(cwe.Provider,{value:s,children:t.children})}return e.jsx(gOt,{initialProps:t.initialProps,children:t.children})}function gOt(t){var s=t.initialProps,r=t.children,n=s.selected,a=s.min,o=s.max,l=function(u,p,f){var y,_;(y=s.onDayClick)===null||y===void 0||y.call(s,u,p,f);var b=!!(p.selected&&a&&(n==null?void 0:n.length)===a);if(!b){var w=!!(!p.selected&&o&&(n==null?void 0:n.length)===o);if(!w){var j=n?sKe([],n):[];if(p.selected){var k=j.findIndex(function(S){return cl(u,S)});j.splice(k,1)}else j.push(u);(_=s.onSelect)===null||_===void 0||_.call(s,j,u,p,f)}}},i={disabled:[]};n&&i.disabled.push(function(u){var p=o&&n.length>o-1,f=n.some(function(y){return cl(y,u)});return!!(p&&!f)});var d={selected:n,onDayClick:l,modifiers:i};return e.jsx(cwe.Provider,{value:d,children:r})}function dwe(){var t=C.useContext(cwe);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function xOt(t,s){var r=s||{},n=r.from,a=r.to;return n&&a?cl(a,t)&&cl(n,t)?void 0:cl(a,t)?{from:a,to:void 0}:cl(n,t)?void 0:Rk(n,t)?{from:t,to:a}:{from:n,to:t}:a?Rk(t,a)?{from:a,to:t}:{from:t,to:a}:n?Fk(t,n)?{from:t,to:n}:{from:n,to:t}:{from:t,to:void 0}}var uwe=C.createContext(void 0);function yOt(t){if(!YL(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(uwe.Provider,{value:s,children:t.children})}return e.jsx(vOt,{initialProps:t.initialProps,children:t.children})}function vOt(t){var s=t.initialProps,r=t.children,n=s.selected,a=n||{},o=a.from,l=a.to,i=s.min,d=s.max,u=function(_,b,w){var j,k;(j=s.onDayClick)===null||j===void 0||j.call(s,_,b,w);var S=xOt(_,n);(k=s.onSelect)===null||k===void 0||k.call(s,S,_,b,w)},p={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(p.range_start=[o],l?(p.range_end=[l],cl(o,l)||(p.range_middle=[{after:o,before:l}])):p.range_end=[o]):l&&(p.range_start=[l],p.range_end=[l]),i&&(o&&!l&&p.disabled.push({after:fre(o,i-1),before:ml(o,i-1)}),o&&l&&p.disabled.push({after:o,before:ml(o,i-1)}),!o&&l&&p.disabled.push({after:fre(l,i-1),before:ml(l,i-1)})),d){if(o&&!l&&(p.disabled.push({before:ml(o,-d+1)}),p.disabled.push({after:ml(o,d-1)})),o&&l){var f=gp(l,o)+1,y=d-f;p.disabled.push({before:fre(o,y)}),p.disabled.push({after:ml(l,y)})}!o&&l&&(p.disabled.push({before:ml(l,-d+1)}),p.disabled.push({after:ml(l,d-1)}))}return e.jsx(uwe.Provider,{value:{selected:n,onDayClick:u,modifiers:p},children:r})}function hwe(){var t=C.useContext(uwe);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function Ire(t){return Array.isArray(t)?sKe([],t):t!==void 0?[t]:[]}function _Ot(t){var s={};return Object.entries(t).forEach(function(r){var n=r[0],a=r[1];s[n]=Ire(a)}),s}var Jg;(function(t){t.Outside="outside",t.Disabled="disabled",t.Selected="selected",t.Hidden="hidden",t.Today="today",t.RangeStart="range_start",t.RangeEnd="range_end",t.RangeMiddle="range_middle"})(Jg||(Jg={}));var bOt=Jg.Selected,t0=Jg.Disabled,wOt=Jg.Hidden,jOt=Jg.Today,Gme=Jg.RangeEnd,Kme=Jg.RangeMiddle,Zme=Jg.RangeStart,NOt=Jg.Outside;function kOt(t,s,r){var n,a=(n={},n[bOt]=Ire(t.selected),n[t0]=Ire(t.disabled),n[wOt]=Ire(t.hidden),n[jOt]=[t.today],n[Gme]=[],n[Kme]=[],n[Zme]=[],n[NOt]=[],n);return t.fromDate&&a[t0].push({before:t.fromDate}),t.toDate&&a[t0].push({after:t.toDate}),ZL(t)?a[t0]=a[t0].concat(s.modifiers[t0]):YL(t)&&(a[t0]=a[t0].concat(r.modifiers[t0]),a[Zme]=r.modifiers[Zme],a[Kme]=r.modifiers[Kme],a[Gme]=r.modifiers[Gme]),a}var oKe=C.createContext(void 0);function SOt(t){var s=Ul(),r=dwe(),n=hwe(),a=kOt(s,r,n),o=_Ot(s.modifiers),l=ui(ui({},a),o);return e.jsx(oKe.Provider,{value:l,children:t.children})}function lKe(){var t=C.useContext(oKe);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function COt(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function MOt(t){return!!(t&&typeof t=="object"&&"from"in t)}function TOt(t){return!!(t&&typeof t=="object"&&"after"in t)}function AOt(t){return!!(t&&typeof t=="object"&&"before"in t)}function EOt(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function POt(t,s){var r,n=s.from,a=s.to;if(n&&a){var o=gp(a,n)<0;o&&(r=[a,n],n=r[0],a=r[1]);var l=gp(t,n)>=0&&gp(a,t)>=0;return l}return a?cl(a,t):n?cl(n,t):!1}function IOt(t){return i_e(t)}function LOt(t){return Array.isArray(t)&&t.every(i_e)}function DOt(t,s){return s.some(function(r){if(typeof r=="boolean")return r;if(IOt(r))return cl(t,r);if(LOt(r))return r.includes(t);if(MOt(r))return POt(t,r);if(EOt(r))return r.dayOfWeek.includes(t.getDay());if(COt(r)){var n=gp(r.before,t),a=gp(r.after,t),o=n>0,l=a<0,i=Rk(r.before,r.after);return i?l&&o:o||l}return TOt(r)?gp(t,r.after)>0:AOt(r)?gp(r.before,t)>0:typeof r=="function"?r(t):!1})}function mwe(t,s,r){var n=Object.keys(s).reduce(function(o,l){var i=s[l];return DOt(t,i)&&o.push(l),o},[]),a={};return n.forEach(function(o){return a[o]=!0}),r&&!Woe(t,r)&&(a.outside=!0),a}function OOt(t,s){for(var r=pc(t[0]),n=ef(t[t.length-1]),a,o,l=r;l<=n;){var i=mwe(l,s),d=!i.disabled&&!i.hidden;if(!d){l=ml(l,1);continue}if(i.selected)return l;i.today&&!o&&(o=l),a||(a=l),l=ml(l,1)}return o||a}var ROt=365;function cKe(t,s){var r=s.moveBy,n=s.direction,a=s.context,o=s.modifiers,l=s.retry,i=l===void 0?{count:0,lastFocused:t}:l,d=a.weekStartsOn,u=a.fromDate,p=a.toDate,f=a.locale,y={day:ml,week:IN,month:Kh,year:Nvt,startOfWeek:function(j){return a.ISOWeek?nv(j):ch(j,{locale:f,weekStartsOn:d})},endOfWeek:function(j){return a.ISOWeek?K9e(j):Voe(j,{locale:f,weekStartsOn:d})}},_=y[r](t,n==="after"?1:-1);n==="before"&&u?_=kvt([u,_]):n==="after"&&p&&(_=Svt([p,_]));var b=!0;if(o){var w=mwe(_,o);b=!w.disabled&&!w.hidden}return b?_:i.count>ROt?i.lastFocused:cKe(_,{moveBy:r,direction:n,context:a,modifiers:o,retry:ui(ui({},i),{count:i.count+1})})}var dKe=C.createContext(void 0);function FOt(t){var s=XL(),r=lKe(),n=C.useState(),a=n[0],o=n[1],l=C.useState(),i=l[0],d=l[1],u=OOt(s.displayMonths,r),p=a??(i&&s.isDateDisplayed(i))?i:u,f=function(){d(a),o(void 0)},y=function(j){o(j)},_=Ul(),b=function(j,k){if(a){var S=cKe(a,{moveBy:j,direction:k,context:_,modifiers:r});cl(a,S)||(s.goToDate(S,a),y(S))}},w={focusedDay:a,focusTarget:p,blur:f,focus:y,focusDayAfter:function(){return b("day","after")},focusDayBefore:function(){return b("day","before")},focusWeekAfter:function(){return b("week","after")},focusWeekBefore:function(){return b("week","before")},focusMonthBefore:function(){return b("month","before")},focusMonthAfter:function(){return b("month","after")},focusYearBefore:function(){return b("year","before")},focusYearAfter:function(){return b("year","after")},focusStartOfWeek:function(){return b("startOfWeek","before")},focusEndOfWeek:function(){return b("endOfWeek","after")}};return e.jsx(dKe.Provider,{value:w,children:t.children})}function pwe(){var t=C.useContext(dKe);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function zOt(t,s){var r=lKe(),n=mwe(t,r,s);return n}var fwe=C.createContext(void 0);function BOt(t){if(!Ile(t.initialProps)){var s={selected:void 0};return e.jsx(fwe.Provider,{value:s,children:t.children})}return e.jsx($Ot,{initialProps:t.initialProps,children:t.children})}function $Ot(t){var s=t.initialProps,r=t.children,n=function(o,l,i){var d,u,p;if((d=s.onDayClick)===null||d===void 0||d.call(s,o,l,i),l.selected&&!s.required){(u=s.onSelect)===null||u===void 0||u.call(s,void 0,o,l,i);return}(p=s.onSelect)===null||p===void 0||p.call(s,o,o,l,i)},a={selected:s.selected,onDayClick:n};return e.jsx(fwe.Provider,{value:a,children:r})}function uKe(){var t=C.useContext(fwe);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function qOt(t,s){var r=Ul(),n=uKe(),a=dwe(),o=hwe(),l=pwe(),i=l.focusDayAfter,d=l.focusDayBefore,u=l.focusWeekAfter,p=l.focusWeekBefore,f=l.blur,y=l.focus,_=l.focusMonthBefore,b=l.focusMonthAfter,w=l.focusYearBefore,j=l.focusYearAfter,k=l.focusStartOfWeek,S=l.focusEndOfWeek,T=function(ae){var le,he,be,_e;Ile(r)?(le=n.onDayClick)===null||le===void 0||le.call(n,t,s,ae):ZL(r)?(he=a.onDayClick)===null||he===void 0||he.call(a,t,s,ae):YL(r)?(be=o.onDayClick)===null||be===void 0||be.call(o,t,s,ae):(_e=r.onDayClick)===null||_e===void 0||_e.call(r,t,s,ae)},I=function(ae){var le;y(t),(le=r.onDayFocus)===null||le===void 0||le.call(r,t,s,ae)},L=function(ae){var le;f(),(le=r.onDayBlur)===null||le===void 0||le.call(r,t,s,ae)},R=function(ae){var le;(le=r.onDayMouseEnter)===null||le===void 0||le.call(r,t,s,ae)},$=function(ae){var le;(le=r.onDayMouseLeave)===null||le===void 0||le.call(r,t,s,ae)},q=function(ae){var le;(le=r.onDayPointerEnter)===null||le===void 0||le.call(r,t,s,ae)},U=function(ae){var le;(le=r.onDayPointerLeave)===null||le===void 0||le.call(r,t,s,ae)},H=function(ae){var le;(le=r.onDayTouchCancel)===null||le===void 0||le.call(r,t,s,ae)},Y=function(ae){var le;(le=r.onDayTouchEnd)===null||le===void 0||le.call(r,t,s,ae)},se=function(ae){var le;(le=r.onDayTouchMove)===null||le===void 0||le.call(r,t,s,ae)},te=function(ae){var le;(le=r.onDayTouchStart)===null||le===void 0||le.call(r,t,s,ae)},Q=function(ae){var le;(le=r.onDayKeyUp)===null||le===void 0||le.call(r,t,s,ae)},de=function(ae){var le;switch(ae.key){case"ArrowLeft":ae.preventDefault(),ae.stopPropagation(),r.dir==="rtl"?i():d();break;case"ArrowRight":ae.preventDefault(),ae.stopPropagation(),r.dir==="rtl"?d():i();break;case"ArrowDown":ae.preventDefault(),ae.stopPropagation(),u();break;case"ArrowUp":ae.preventDefault(),ae.stopPropagation(),p();break;case"PageUp":ae.preventDefault(),ae.stopPropagation(),ae.shiftKey?w():_();break;case"PageDown":ae.preventDefault(),ae.stopPropagation(),ae.shiftKey?j():b();break;case"Home":ae.preventDefault(),ae.stopPropagation(),k();break;case"End":ae.preventDefault(),ae.stopPropagation(),S();break}(le=r.onDayKeyDown)===null||le===void 0||le.call(r,t,s,ae)},re={onClick:T,onFocus:I,onBlur:L,onKeyDown:de,onKeyUp:Q,onMouseEnter:R,onMouseLeave:$,onPointerEnter:q,onPointerLeave:U,onTouchCancel:H,onTouchEnd:Y,onTouchMove:se,onTouchStart:te};return re}function UOt(){var t=Ul(),s=uKe(),r=dwe(),n=hwe(),a=Ile(t)?s.selected:ZL(t)?r.selected:YL(t)?n.selected:void 0;return a}function VOt(t){return Object.values(Jg).includes(t)}function HOt(t,s){var r=[t.classNames.day];return Object.keys(s).forEach(function(n){var a=t.modifiersClassNames[n];if(a)r.push(a);else if(VOt(n)){var o=t.classNames["day_".concat(n)];o&&r.push(o)}}),r}function WOt(t,s){var r=ui({},t.styles.day);return Object.keys(s).forEach(function(n){var a;r=ui(ui({},r),(a=t.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function GOt(t,s,r){var n,a,o,l=Ul(),i=pwe(),d=zOt(t,s),u=qOt(t,d),p=UOt(),f=!!(l.onDayClick||l.mode!=="default");C.useEffect(function(){var R;d.outside||i.focusedDay&&f&&cl(i.focusedDay,t)&&((R=r.current)===null||R===void 0||R.focus())},[i.focusedDay,t,r,f,d.outside]);var y=HOt(l,d).join(" "),_=WOt(l,d),b=!!(d.outside&&!l.showOutsideDays||d.hidden),w=(o=(a=l.components)===null||a===void 0?void 0:a.DayContent)!==null&&o!==void 0?o:pOt,j=e.jsx(w,{date:t,displayMonth:s,activeModifiers:d}),k={style:_,className:y,children:j,role:"gridcell"},S=i.focusTarget&&cl(i.focusTarget,t)&&!d.outside,T=i.focusedDay&&cl(i.focusedDay,t),I=ui(ui(ui({},k),(n={disabled:d.disabled,role:"gridcell"},n["aria-selected"]=d.selected,n.tabIndex=T||S?0:-1,n)),u),L={isButton:f,isHidden:b,activeModifiers:d,selectedDays:p,buttonProps:I,divProps:k};return L}function KOt(t){var s=C.useRef(null),r=GOt(t.date,t.displayMonth,s);return r.isHidden?e.jsx("div",{role:"gridcell"}):r.isButton?e.jsx(Rae,ui({name:"day",ref:s},r.buttonProps)):e.jsx("div",ui({},r.divProps))}function ZOt(t){var s=t.number,r=t.dates,n=Ul(),a=n.onWeekNumberClick,o=n.styles,l=n.classNames,i=n.locale,d=n.labels.labelWeekNumber,u=n.formatters.formatWeekNumber,p=u(Number(s),{locale:i});if(!a)return e.jsx("span",{className:l.weeknumber,style:o.weeknumber,children:p});var f=d(Number(s),{locale:i}),y=function(_){a(s,r,_)};return e.jsx(Rae,{name:"week-number","aria-label":f,className:l.weeknumber,style:o.weeknumber,onClick:y,children:p})}function YOt(t){var s,r,n=Ul(),a=n.styles,o=n.classNames,l=n.showWeekNumber,i=n.components,d=(s=i==null?void 0:i.Day)!==null&&s!==void 0?s:KOt,u=(r=i==null?void 0:i.WeekNumber)!==null&&r!==void 0?r:ZOt,p;return l&&(p=e.jsx("td",{className:o.cell,style:a.cell,children:e.jsx(u,{number:t.weekNumber,dates:t.dates})})),e.jsxs("tr",{className:o.row,style:a.row,children:[p,t.dates.map(function(f){return e.jsx("td",{className:o.cell,style:a.cell,role:"presentation",children:e.jsx(d,{displayMonth:t.displayMonth,date:f})},T1t(f))})]})}function WAe(t,s,r){for(var n=r!=null&&r.ISOWeek?K9e(s):Voe(s,r),a=r!=null&&r.ISOWeek?nv(t):ch(t,r),o=gp(n,a),l=[],i=0;i<=o;i++)l.push(ml(a,i));var d=l.reduce(function(u,p){var f=r!=null&&r.ISOWeek?o_e(p):c_e(p,r),y=u.find(function(_){return _.weekNumber===f});return y?(y.dates.push(p),u):(u.push({weekNumber:f,dates:[p]}),u)},[]);return d}function XOt(t,s){var r=WAe(pc(t),ef(t),s);if(s!=null&&s.useFixedWeeks){var n=E1t(t,s);if(n<6){var a=r[r.length-1],o=a.dates[a.dates.length-1],l=IN(o,6-n),i=WAe(IN(o,1),l,s);r.push.apply(r,i)}}return r}function QOt(t){var s,r,n,a=Ul(),o=a.locale,l=a.classNames,i=a.styles,d=a.hideHead,u=a.fixedWeeks,p=a.components,f=a.weekStartsOn,y=a.firstWeekContainsDate,_=a.ISOWeek,b=XOt(t.displayMonth,{useFixedWeeks:!!u,ISOWeek:_,locale:o,weekStartsOn:f,firstWeekContainsDate:y}),w=(s=p==null?void 0:p.Head)!==null&&s!==void 0?s:mOt,j=(r=p==null?void 0:p.Row)!==null&&r!==void 0?r:YOt,k=(n=p==null?void 0:p.Footer)!==null&&n!==void 0?n:dOt;return e.jsxs("table",{id:t.id,className:l.table,style:i.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!d&&e.jsx(w,{}),e.jsx("tbody",{className:l.tbody,style:i.tbody,children:b.map(function(S){return e.jsx(j,{displayMonth:t.displayMonth,dates:S.dates,weekNumber:S.weekNumber},S.weekNumber)})}),e.jsx(k,{displayMonth:t.displayMonth})]})}function JOt(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var e8t=JOt()?C.useLayoutEffect:C.useEffect,Yme=!1,t8t=0;function GAe(){return"react-day-picker-".concat(++t8t)}function s8t(t){var s,r=t??(Yme?GAe():null),n=C.useState(r),a=n[0],o=n[1];return e8t(function(){a===null&&o(GAe())},[]),C.useEffect(function(){Yme===!1&&(Yme=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function r8t(t){var s,r,n=Ul(),a=n.dir,o=n.classNames,l=n.styles,i=n.components,d=XL().displayMonths,u=s8t(n.id?"".concat(n.id,"-").concat(t.displayIndex):void 0),p=n.id?"".concat(n.id,"-grid-").concat(t.displayIndex):void 0,f=[o.month],y=l.month,_=t.displayIndex===0,b=t.displayIndex===d.length-1,w=!_&&!b;a==="rtl"&&(s=[_,b],b=s[0],_=s[1]),_&&(f.push(o.caption_start),y=ui(ui({},y),l.caption_start)),b&&(f.push(o.caption_end),y=ui(ui({},y),l.caption_end)),w&&(f.push(o.caption_between),y=ui(ui({},y),l.caption_between));var j=(r=i==null?void 0:i.Caption)!==null&&r!==void 0?r:cOt;return e.jsxs("div",{className:f.join(" "),style:y,children:[e.jsx(j,{id:u,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(QOt,{id:p,"aria-labelledby":u,displayMonth:t.displayMonth})]},t.displayIndex)}function n8t(t){var s=Ul(),r=s.classNames,n=s.styles;return e.jsx("div",{className:r.months,style:n.months,children:t.children})}function a8t(t){var s,r,n=t.initialProps,a=Ul(),o=pwe(),l=XL(),i=C.useState(!1),d=i[0],u=i[1];C.useEffect(function(){a.initialFocus&&o.focusTarget&&(d||(o.focus(o.focusTarget),u(!0)))},[a.initialFocus,d,o.focus,o.focusTarget,o]);var p=[a.classNames.root,a.className];a.numberOfMonths>1&&p.push(a.classNames.multiple_months),a.showWeekNumber&&p.push(a.classNames.with_weeknumber);var f=ui(ui({},a.styles.root),a.style),y=Object.keys(n).filter(function(b){return b.startsWith("data-")}).reduce(function(b,w){var j;return ui(ui({},b),(j={},j[w]=n[w],j))},{}),_=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:n8t;return e.jsx("div",ui({className:p.join(" "),style:f,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},y,{children:e.jsx(_,{children:l.displayMonths.map(function(b,w){return e.jsx(r8t,{displayIndex:w,displayMonth:b},w)})})}))}function i8t(t){var s=t.children,r=ADt(t,["children"]);return e.jsx(ZDt,{initialProps:r,children:e.jsx(aOt,{children:e.jsx(BOt,{initialProps:r,children:e.jsx(fOt,{initialProps:r,children:e.jsx(yOt,{initialProps:r,children:e.jsx(SOt,{children:e.jsx(FOt,{children:s})})})})})})})}function o8t(t){return e.jsx(i8t,ui({},t,{children:e.jsx(a8t,{initialProps:t})}))}function jp({className:t,classNames:s,showOutsideDays:r=!0,...n}){return e.jsx(o8t,{showOutsideDays:r,className:Pt("p-3",t),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:Pt(s6({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:Pt(s6({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...s},components:{IconLeft:({...a})=>e.jsx(zl,{className:"h-4 w-4"}),IconRight:({...a})=>e.jsx(Ua,{className:"h-4 w-4"})},...n})}jp.displayName="Calendar";var Lle="Popover",[hKe]=Ec(Lle,[xy]),QL=xy(),[l8t,sb]=hKe(Lle),mKe=t=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!1}=t,i=QL(s),d=C.useRef(null),[u,p]=C.useState(!1),[f,y]=vu({prop:n,defaultProp:a??!1,onChange:o,caller:Lle});return e.jsx(jL,{...i,children:e.jsx(l8t,{scope:s,contentId:Gd(),triggerRef:d,open:f,onOpenChange:y,onOpenToggle:C.useCallback(()=>y(_=>!_),[y]),hasCustomAnchor:u,onCustomAnchorAdd:C.useCallback(()=>p(!0),[]),onCustomAnchorRemove:C.useCallback(()=>p(!1),[]),modal:l,children:r})})};mKe.displayName=Lle;var pKe="PopoverAnchor",c8t=C.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=sb(pKe,r),o=QL(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:i}=a;return C.useEffect(()=>(l(),()=>i()),[l,i]),e.jsx(gM,{...o,...n,ref:s})});c8t.displayName=pKe;var fKe="PopoverTrigger",gKe=C.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=sb(fKe,r),o=QL(r),l=Ea(s,a.triggerRef),i=e.jsx(Qr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":bKe(a.open),...n,ref:l,onClick:Mr(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:e.jsx(gM,{asChild:!0,...o,children:i})});gKe.displayName=fKe;var gwe="PopoverPortal",[d8t,u8t]=hKe(gwe,{forceMount:void 0}),xKe=t=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=t,o=sb(gwe,s);return e.jsx(d8t,{scope:s,forceMount:r,children:e.jsx(ud,{present:r||o.open,children:e.jsx(hM,{asChild:!0,container:a,children:n})})})};xKe.displayName=gwe;var L3="PopoverContent",yKe=C.forwardRef((t,s)=>{const r=u8t(L3,t.__scopePopover),{forceMount:n=r.forceMount,...a}=t,o=sb(L3,t.__scopePopover);return e.jsx(ud,{present:n||o.open,children:o.modal?e.jsx(m8t,{...a,ref:s}):e.jsx(p8t,{...a,ref:s})})});yKe.displayName=L3;var h8t=M_("PopoverContent.RemoveScroll"),m8t=C.forwardRef((t,s)=>{const r=sb(L3,t.__scopePopover),n=C.useRef(null),a=Ea(s,n),o=C.useRef(!1);return C.useEffect(()=>{const l=n.current;if(l)return Coe(l)},[]),e.jsx(TL,{as:h8t,allowPinchZoom:!0,children:e.jsx(vKe,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Mr(t.onCloseAutoFocus,l=>{var i;l.preventDefault(),o.current||(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Mr(t.onPointerDownOutside,l=>{const i=l.detail.originalEvent,d=i.button===0&&i.ctrlKey===!0,u=i.button===2||d;o.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Mr(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),p8t=C.forwardRef((t,s)=>{const r=sb(L3,t.__scopePopover),n=C.useRef(!1),a=C.useRef(!1);return e.jsx(vKe,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,i;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(n.current||(i=r.triggerRef.current)==null||i.focus(),o.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:o=>{var d,u;(d=t.onInteractOutside)==null||d.call(t,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((u=r.triggerRef.current)==null?void 0:u.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),vKe=C.forwardRef((t,s)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:p,...f}=t,y=sb(L3,r),_=QL(r);return Noe(),e.jsx(CL,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(q_,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:p,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>y.onOpenChange(!1),children:e.jsx(NL,{"data-state":bKe(y.open),role:"dialog",id:y.contentId,..._,...f,ref:s,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),_Ke="PopoverClose",f8t=C.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=sb(_Ke,r);return e.jsx(Qr.button,{type:"button",...n,ref:s,onClick:Mr(t.onClick,()=>a.onOpenChange(!1))})});f8t.displayName=_Ke;var g8t="PopoverArrow",x8t=C.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=QL(r);return e.jsx(kL,{...a,...n,ref:s})});x8t.displayName=g8t;function bKe(t){return t?"open":"closed"}var y8t=mKe,v8t=gKe,_8t=xKe,wKe=yKe;const Co=y8t,Mo=v8t,No=C.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(_8t,{children:e.jsx(wKe,{ref:a,align:s,sideOffset:r,className:Pt("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));No.displayName=wKe.displayName;const b8t=nS("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),xwe=C.forwardRef(({className:t,variant:s,...r},n)=>e.jsx("div",{ref:n,role:"alert",className:Pt(b8t({variant:s}),t),...r}));xwe.displayName="Alert";const w8t=C.forwardRef(({className:t,...s},r)=>e.jsx("h5",{ref:r,className:Pt("mb-1 font-medium leading-none tracking-tight",t),...s}));w8t.displayName="AlertTitle";const ywe=C.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("text-sm [&_p]:leading-relaxed",t),...s}));ywe.displayName="AlertDescription";function j8t({open:t,onOpenChange:s,imageUrl:r,imageId:n,defaultCaption:a="",swagItemId:o,reelId:l}){const i=rs(),[d,u]=C.useState(a),[p,f]=C.useState([]),[y,_]=C.useState(null),[b,w]=C.useState("now"),[j,k]=C.useState(U5e(Z5e(new Date),1)),[S,T]=C.useState("12"),[I,L]=C.useState("00"),[R,$]=C.useState("PM");C.useEffect(()=>{if(t){u(a),w("now"),f([]);const Ne=U5e(Z5e(new Date),1);k(Ne);const Ge=Ne.getHours();T(String(Ge>12?Ge-12:Ge===0?12:Ge)),L("00"),$(Ge>=12?"PM":"AM")}},[t,a]);const q=()=>{if(!j)return null;let Ne=parseInt(S);const Ge=parseInt(I);return R==="PM"&&Ne!==12&&(Ne+=12),R==="AM"&&Ne===12&&(Ne=0),eI(JP(j,Ne),Ge)},{data:U,isLoading:H}=wt({queryKey:["social-accounts-for-post"],queryFn:async()=>{const{data:{user:Ne}}=await G.auth.getUser();if(!Ne)return[];const{data:Ge,error:we}=await G.from("social_accounts").select("*").eq("user_id",Ne.id).eq("is_active",!0).order("platform",{ascending:!0});if(we)throw we;return console.log("Fetched social accounts for posting:",Ge),Ge},enabled:t,staleTime:0}),Y=Dt({mutationFn:async({accountId:Ne,platform:Ge})=>{_(Ne);const{data:we,error:Me}=await G.functions.invoke("social-post",{body:{platform:Ge,accountId:Ne,imageUrl:r,caption:d}});if(Me)throw Me;if(we!=null&&we.error)throw new Error(we.error);return we},onSuccess:Ne=>{const Ge=Ne.platform==="facebook"?"Facebook":Ne.platform==="instagram"?"Instagram":Ne.platform==="linkedin"?"LinkedIn":"Google Business";fe.success(`Posted to ${Ge}!`)},onError:Ne=>{fe.error(`Failed to post: ${Ne.message}`)},onSettled:()=>{_(null)}}),se=Dt({mutationFn:async({accountId:Ne,platform:Ge,scheduledFor:we})=>{const{data:{user:Me}}=await G.auth.getUser();if(!Me)throw new Error("Not authenticated");const{error:Te}=await G.from("scheduled_posts").insert({user_id:Me.id,social_account_id:Ne,platform:Ge,image_url:r,caption:d,swag_item_id:o||null,reel_id:l||null,scheduled_for:we.toISOString(),status:"scheduled"});if(Te)throw Te;return{platform:Ge}},onSuccess:Ne=>{const Ge=Ne.platform==="facebook"?"Facebook":Ne.platform==="instagram"?"Instagram":"LinkedIn";fe.success(`Post scheduled for ${Ge}!`)},onError:Ne=>{fe.error(`Failed to schedule: ${Ne.message}`)}}),te=async()=>{if(p.length===0){fe.error("Please select at least one account");return}if(b==="schedule"){const Ne=q();if(!Ne||Ne<=new Date){fe.error("Please select a future date and time");return}for(const Ge of p){const we=U==null?void 0:U.find(Me=>Me.id===Ge);we&&await se.mutateAsync({accountId:Ge,platform:we.platform,scheduledFor:Ne})}i.invalidateQueries({queryKey:["scheduled-posts"]}),fe.success(`${p.length} post(s) scheduled for ${ys(Ne,"PPp")}`)}else for(const Ne of p){const Ge=U==null?void 0:U.find(we=>we.id===Ne);Ge&&await Y.mutateAsync({accountId:Ne,platform:Ge.platform})}i.invalidateQueries({queryKey:["scheduled-posts"]}),u(""),f([]),s(!1)},Q=Ne=>{f(Ge=>Ge.includes(Ne)?Ge.filter(we=>we!==Ne):[...Ge,Ne])},de=(U==null?void 0:U.filter(Ne=>Ne.platform==="facebook"))||[],re=(U==null?void 0:U.filter(Ne=>Ne.platform==="instagram"))||[],ae=(U==null?void 0:U.filter(Ne=>Ne.platform==="linkedin"))||[],le=(U==null?void 0:U.filter(Ne=>Ne.platform==="google_business"))||[],he=((U==null?void 0:U.length)||0)>0,be=Y.isPending||se.isPending,_e=Array.from({length:12},(Ne,Ge)=>String(Ge+1)),je=["00","15","30","45"];return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Create Social Post"}),e.jsx(Kr,{children:"Share this image to your connected social accounts"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("div",{className:"aspect-square w-full max-w-[200px] mx-auto overflow-hidden rounded-lg border",children:e.jsx("img",{src:r,alt:"Post preview",className:"h-full w-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"caption",children:"Caption"}),e.jsx(Ar,{id:"caption",placeholder:"Write a caption for your post...",value:d,onChange:Ne=>u(Ne.target.value),rows:3}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[d.length,"/2200 characters"]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{children:"Publish Time"}),e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsx("button",{type:"button",onClick:()=>w("now"),className:Pt("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",b==="now"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Post Now"}),e.jsx("button",{type:"button",onClick:()=>w("schedule"),className:Pt("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",b==="schedule"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Schedule"})]})]}),b==="schedule"&&e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Tn,{className:"h-4 w-4"}),"Schedule for"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(Co,{children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("justify-start text-left font-normal flex-1",!j&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),j?ys(j,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(No,{className:"w-auto p-0",align:"start",children:e.jsx(jp,{mode:"single",selected:j,onSelect:k,disabled:Ne=>Nee.jsx(At,{value:Ne,children:Ne},Ne))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(sr,{value:I,onValueChange:L,children:[e.jsx(er,{className:"w-[70px]",children:e.jsx(rr,{})}),e.jsx(tr,{children:je.map(Ne=>e.jsx(At,{value:Ne,children:Ne},Ne))})]}),e.jsxs(sr,{value:R,onValueChange:Ne=>$(Ne),children:[e.jsx(er,{className:"w-[70px]",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"AM",children:"AM"}),e.jsx(At,{value:"PM",children:"PM"})]})]})]})]}),j&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Post will be published on ",ys(q()||new Date,"PPP 'at' p")]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{children:"Post to"}),H&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin"})}),!H&&!he&&e.jsxs(xwe,{children:[e.jsx(ll,{className:"h-4 w-4"}),e.jsxs(ywe,{className:"flex flex-col gap-2",children:[e.jsx("span",{children:"No social accounts connected yet."}),e.jsxs(vo,{to:"/social-connections",className:"inline-flex items-center gap-1.5 text-primary hover:underline font-medium",children:[e.jsx($l,{className:"h-3.5 w-3.5"}),"Connect your Facebook, Instagram & LinkedIn"]})]})]}),de.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Hd,{className:"h-4 w-4 text-blue-600"})," Facebook"]}),de.map(Ne=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Bo,{checked:p.includes(Ne.id),onCheckedChange:()=>Q(Ne.id),disabled:y===Ne.id}),e.jsxs(xn,{className:"h-8 w-8",children:[e.jsx(Aa,{src:Ne.profile_picture_url||""}),e.jsx(yn,{children:e.jsx(Hd,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:Ne.page_name||Ne.platform_username}),y===Ne.id&&e.jsx(Ms,{className:"h-4 w-4 animate-spin"})]},Ne.id))]}),re.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Wd,{className:"h-4 w-4 text-pink-600"})," Instagram"]}),re.map(Ne=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Bo,{checked:p.includes(Ne.id),onCheckedChange:()=>Q(Ne.id),disabled:y===Ne.id}),e.jsxs(xn,{className:"h-8 w-8",children:[e.jsx(Aa,{src:Ne.profile_picture_url||""}),e.jsx(yn,{children:e.jsx(Wd,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"flex-1 text-sm font-medium",children:["@",Ne.platform_username]}),y===Ne.id&&e.jsx(Ms,{className:"h-4 w-4 animate-spin"})]},Ne.id))]}),ae.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Om,{className:"h-4 w-4 text-blue-700"})," LinkedIn"]}),ae.map(Ne=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Bo,{checked:p.includes(Ne.id),onCheckedChange:()=>Q(Ne.id),disabled:y===Ne.id}),e.jsxs(xn,{className:"h-8 w-8",children:[e.jsx(Aa,{src:Ne.profile_picture_url||""}),e.jsx(yn,{children:e.jsx(Om,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:Ne.platform_username}),y===Ne.id&&e.jsx(Ms,{className:"h-4 w-4 animate-spin"})]},Ne.id))]}),le.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Oi,{className:"h-4 w-4 text-red-600"})," Google Business"]}),le.map(Ne=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Bo,{checked:p.includes(Ne.id),onCheckedChange:()=>Q(Ne.id),disabled:y===Ne.id}),e.jsxs(xn,{className:"h-8 w-8",children:[e.jsx(Aa,{src:Ne.profile_picture_url||""}),e.jsx(yn,{children:e.jsx(Oi,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:Ne.page_name||Ne.platform_username}),y===Ne.id&&e.jsx(Ms,{className:"h-4 w-4 animate-spin"})]},Ne.id))]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:te,disabled:p.length===0||be,className:"gap-2",children:[be?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):b==="schedule"?e.jsx(on,{className:"h-4 w-4"}):e.jsx(aa,{className:"h-4 w-4"}),b==="schedule"?`Schedule ${p.length} post${p.length!==1?"s":""}`:`Post to ${p.length} account${p.length!==1?"s":""}`]})]})]})})}function N8t(){const t=rs(),[s,r]=C.useState(void 0),[n,a]=C.useState("all"),[o,l]=C.useState(null),[i,d]=C.useState(""),[u,p]=C.useState(void 0),[f,y]=C.useState("12"),[_,b]=C.useState("00"),[w,j]=C.useState("PM"),{data:k=[],isLoading:S}=wt({queryKey:["scheduled-posts"],queryFn:async()=>{const{data:le,error:he}=await G.from("scheduled_posts").select(` *, social_accounts ( page_name, platform_username, profile_picture_url ) `).order("scheduled_for",{ascending:!1});if(he)throw he;return le}}),T=k.filter(le=>{if(n!=="all"&&le.status!==n)return!1;if(s&&le.scheduled_for){const he=new Date(le.scheduled_for);if(!cl(he,s))return!1}return!0}),I=k.filter(le=>le.scheduled_for).map(le=>Zh(new Date(le.scheduled_for))),L=Dt({mutationFn:async le=>{const{error:he}=await G.from("scheduled_posts").update({caption:le.caption,scheduled_for:le.scheduled_for}).eq("id",le.id);if(he)throw he},onSuccess:()=>{fe.success("Post updated!"),t.invalidateQueries({queryKey:["scheduled-posts"]}),l(null)},onError:le=>{fe.error(`Failed to update: ${le.message}`)}}),R=Dt({mutationFn:async le=>{const{error:he}=await G.from("scheduled_posts").update({status:"cancelled"}).eq("id",le);if(he)throw he},onSuccess:()=>{fe.success("Post cancelled"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{fe.error(`Failed to cancel: ${le.message}`)}}),$=Dt({mutationFn:async le=>{const{error:he}=await G.from("scheduled_posts").delete().eq("id",le);if(he)throw he},onSuccess:()=>{fe.success("Post deleted"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{fe.error(`Failed to delete: ${le.message}`)}}),q=Dt({mutationFn:async le=>{const{data:he,error:be}=await G.functions.invoke("social-post",{body:{platform:le.platform,accountId:le.social_account_id,imageUrl:le.image_url,caption:le.caption}});if(be)throw be;if(he!=null&&he.error)throw new Error(he.error);return await G.from("scheduled_posts").update({status:"posted",posted_at:new Date().toISOString(),post_id:he.postId}).eq("id",le.id),he},onSuccess:le=>{const he=le.platform==="facebook"?"Facebook":le.platform==="instagram"?"Instagram":"LinkedIn";fe.success(`Posted to ${he}!`),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{fe.error(`Failed to post: ${le.message}`)}}),U=le=>{if(l(le),d(le.caption||""),le.scheduled_for){const he=new Date(le.scheduled_for);p(he);const be=he.getHours();y(String(be>12?be-12:be===0?12:be)),b(String(he.getMinutes()).padStart(2,"0")),j(be>=12?"PM":"AM")}},H=()=>{if(!o||!u)return;let le=parseInt(f);const he=parseInt(_);w==="PM"&&le!==12&&(le+=12),w==="AM"&&le===12&&(le=0);const be=eI(JP(u,le),he);L.mutate({id:o.id,caption:i,scheduled_for:be.toISOString()})},Y=le=>{switch(le){case"facebook":return e.jsx(Hd,{className:"h-4 w-4 text-blue-600"});case"instagram":return e.jsx(Wd,{className:"h-4 w-4 text-pink-600"});case"linkedin":return e.jsx(Om,{className:"h-4 w-4 text-blue-700"});default:return null}},se=le=>{switch(le){case"scheduled":return e.jsxs(rt,{variant:"secondary",className:"gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),"Scheduled"]});case"posted":return e.jsxs(rt,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(hi,{className:"h-3 w-3"}),"Posted"]});case"failed":return e.jsxs(rt,{variant:"destructive",className:"gap-1",children:[e.jsx(kc,{className:"h-3 w-3"}),"Failed"]});case"cancelled":return e.jsxs(rt,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(ll,{className:"h-3 w-3"}),"Cancelled"]});default:return e.jsx(rt,{variant:"outline",children:le})}},te=Array.from({length:12},(le,he)=>String(he+1)),Q=["00","15","30","45"],de=k.filter(le=>le.status==="scheduled").length,re=k.filter(le=>le.status==="posted").length,ae=k.filter(le=>le.status==="scheduled"&&le.scheduled_for&&P1t(new Date(le.scheduled_for))).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:de}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Scheduled"})]}),e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ae}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Upcoming"})]}),e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:re}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Posted"})]}),e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:k.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total"})]})]}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[e.jsxs(Ee,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(id,{className:"h-5 w-5"}),e.jsx("h3",{className:"font-semibold",children:"Calendar"})]}),e.jsx(jp,{mode:"single",selected:s,onSelect:r,className:Pt("pointer-events-auto"),modifiers:{hasPost:I},modifiersStyles:{hasPost:{fontWeight:"bold",backgroundColor:"hsl(var(--primary) / 0.1)",borderRadius:"50%"}}}),s&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>r(void 0),className:"w-full mt-2",children:"Clear date filter"})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yx,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:["all","scheduled","posted","failed","cancelled"].map(le=>e.jsx(K,{variant:n===le?"default":"outline",size:"sm",onClick:()=>a(le),className:"capitalize",children:le},le))})]}),S&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Ms,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),!S&&T.length===0&&e.jsxs(Ee,{className:"p-8 text-center",children:[e.jsx(on,{className:"h-12 w-12 mx-auto text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"font-medium mb-2",children:"No posts found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s?`No posts scheduled for ${ys(s,"PPP")}`:"Schedule a post from Social Swag to get started!"})]}),e.jsx("div",{className:"space-y-4",children:T.map(le=>{var he,be;return e.jsx(Ee,{className:"overflow-hidden",children:e.jsxs("div",{className:"flex flex-col sm:flex-row",children:[e.jsx("div",{className:"sm:w-32 h-32 sm:h-auto bg-muted flex-shrink-0",children:e.jsx("img",{src:le.image_url,alt:"Post preview",className:"w-full h-full object-cover"})}),e.jsxs(Oe,{className:"flex-1 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[Y(le.platform),e.jsx("span",{className:"font-medium",children:((he=le.social_accounts)==null?void 0:he.page_name)||((be=le.social_accounts)==null?void 0:be.platform_username)||"Unknown"}),se(le.status)]}),e.jsxs("div",{className:"flex items-center gap-1",children:[le.status==="scheduled"&&e.jsxs(U_,{children:[e.jsxs(Wc,{children:[e.jsx(Gc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>U(le),children:e.jsx(Da,{className:"h-4 w-4"})})}),e.jsx(Cc,{children:"Edit post"})]}),e.jsxs(Wc,{children:[e.jsx(Gc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>q.mutate(le),disabled:q.isPending,children:q.isPending?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):e.jsx(aa,{className:"h-4 w-4"})})}),e.jsx(Cc,{children:"Post now"})]}),e.jsxs(nc,{children:[e.jsx(Rh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Cancel this scheduled post?"}),e.jsx(Dl,{children:"This will cancel the post. You can delete it entirely or keep it in your history."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Keep"}),e.jsx(xl,{onClick:()=>R.mutate(le.id),className:"bg-amber-600 hover:bg-amber-700",children:"Cancel Post"}),e.jsx(xl,{onClick:()=>$.mutate(le.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]}),(le.status==="posted"||le.status==="cancelled"||le.status==="failed")&&e.jsxs(nc,{children:[e.jsx(Rh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete this post?"}),e.jsx(Dl,{children:"This will permanently remove this post from your history."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>$.mutate(le.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}),le.caption&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-2",children:le.caption}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),le.status==="posted"&&le.posted_at?`Posted ${ys(new Date(le.posted_at),"PPp")}`:le.scheduled_for?`Scheduled for ${ys(new Date(le.scheduled_for),"PPp")}`:"Not scheduled"]}),le.status==="failed"&&le.error_message&&e.jsxs("p",{className:"text-xs text-destructive mt-2",children:["Error: ",le.error_message]})]})]})},le.id)})})]})]}),e.jsx(_s,{open:!!o,onOpenChange:le=>!le&&l(null),children:e.jsxs(vs,{className:"max-w-lg",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Edit Scheduled Post"}),e.jsx(Kr,{children:"Update the caption or reschedule this post"})]}),o&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("div",{className:"aspect-square w-32 mx-auto overflow-hidden rounded-lg border",children:e.jsx("img",{src:o.image_url,alt:"Post preview",className:"h-full w-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Caption"}),e.jsx(Ar,{value:i,onChange:le=>d(le.target.value),rows:3})]}),e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg",children:[e.jsx(ve,{children:"Schedule for"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(Co,{children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("justify-start text-left font-normal flex-1",!u&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),u?ys(u,"PPP"):"Pick a date"]})}),e.jsx(No,{className:"w-auto p-0",align:"start",children:e.jsx(jp,{mode:"single",selected:u,onSelect:p,disabled:le=>lee.jsx(At,{value:le,children:le},le))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(sr,{value:_,onValueChange:b,children:[e.jsx(er,{className:"w-[70px]",children:e.jsx(rr,{})}),e.jsx(tr,{children:Q.map(le=>e.jsx(At,{value:le,children:le},le))})]}),e.jsxs(sr,{value:w,onValueChange:le=>j(le),children:[e.jsx(er,{className:"w-[70px]",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"AM",children:"AM"}),e.jsx(At,{value:"PM",children:"PM"})]})]})]})]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(null),children:"Cancel"}),e.jsxs(K,{onClick:H,disabled:L.isPending,children:[L.isPending?e.jsx(Ms,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Changes"]})]})]})})]})}function fR(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var jKe={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files (c) 2009-2016 Stuart Knightley Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */(function(t,s){(function(r){t.exports=r()})(function(){return function r(n,a,o){function l(u,p){if(!a[u]){if(!n[u]){var f=typeof fR=="function"&&fR;if(!p&&f)return f(u,!0);if(i)return i(u,!0);var y=new Error("Cannot find module '"+u+"'");throw y.code="MODULE_NOT_FOUND",y}var _=a[u]={exports:{}};n[u][0].call(_.exports,function(b){var w=n[u][1][b];return l(w||b)},_,_.exports,r,n,a,o)}return a[u].exports}for(var i=typeof fR=="function"&&fR,d=0;d>2,_=(3&u)<<4|p>>4,b=1>6:64,w=2>4,p=(15&y)<<4|(_=i.indexOf(d.charAt(w++)))>>2,f=(3&_)<<6|(b=i.indexOf(d.charAt(w++))),S[j++]=u,_!==64&&(S[j++]=p),b!==64&&(S[j++]=f);return S}},{"./support":30,"./utils":32}],2:[function(r,n,a){var o=r("./external"),l=r("./stream/DataWorker"),i=r("./stream/Crc32Probe"),d=r("./stream/DataLengthProbe");function u(p,f,y,_,b){this.compressedSize=p,this.uncompressedSize=f,this.crc32=y,this.compression=_,this.compressedContent=b}u.prototype={getContentWorker:function(){var p=new l(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new d("data_length")),f=this;return p.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),p},getCompressedWorker:function(){return new l(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(p,f,y){return p.pipe(new i).pipe(new d("uncompressedSize")).pipe(f.compressWorker(y)).pipe(new d("compressedSize")).withStreamInfo("compression",f)},n.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(r,n,a){var o=r("./stream/GenericWorker");a.STORE={magic:"\0\0",compressWorker:function(){return new o("STORE compression")},uncompressWorker:function(){return new o("STORE decompression")}},a.DEFLATE=r("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(r,n,a){var o=r("./utils"),l=function(){for(var i,d=[],u=0;u<256;u++){i=u;for(var p=0;p<8;p++)i=1&i?3988292384^i>>>1:i>>>1;d[u]=i}return d}();n.exports=function(i,d){return i!==void 0&&i.length?o.getTypeOf(i)!=="string"?function(u,p,f,y){var _=l,b=y+f;u^=-1;for(var w=y;w>>8^_[255&(u^p[w])];return-1^u}(0|d,i,i.length,0):function(u,p,f,y){var _=l,b=y+f;u^=-1;for(var w=y;w>>8^_[255&(u^p.charCodeAt(w))];return-1^u}(0|d,i,i.length,0):0}},{"./utils":32}],5:[function(r,n,a){a.base64=!1,a.binary=!1,a.dir=!1,a.createFolders=!0,a.date=null,a.compression=null,a.compressionOptions=null,a.comment=null,a.unixPermissions=null,a.dosPermissions=null},{}],6:[function(r,n,a){var o=null;o=typeof Promise<"u"?Promise:r("lie"),n.exports={Promise:o}},{lie:37}],7:[function(r,n,a){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",l=r("pako"),i=r("./utils"),d=r("./stream/GenericWorker"),u=o?"uint8array":"array";function p(f,y){d.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=y,this.meta={}}a.magic="\b\0",i.inherits(p,d),p.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(u,f.data),!1)},p.prototype.flush=function(){d.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},p.prototype.cleanUp=function(){d.prototype.cleanUp.call(this),this._pako=null},p.prototype._createPako=function(){this._pako=new l[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(y){f.push({data:y,meta:f.meta})}},a.compressWorker=function(f){return new p("Deflate",f)},a.uncompressWorker=function(){return new p("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,n,a){function o(_,b){var w,j="";for(w=0;w>>=8;return j}function l(_,b,w,j,k,S){var T,I,L=_.file,R=_.compression,$=S!==u.utf8encode,q=i.transformTo("string",S(L.name)),U=i.transformTo("string",u.utf8encode(L.name)),H=L.comment,Y=i.transformTo("string",S(H)),se=i.transformTo("string",u.utf8encode(H)),te=U.length!==L.name.length,Q=se.length!==H.length,de="",re="",ae="",le=L.dir,he=L.date,be={crc32:0,compressedSize:0,uncompressedSize:0};b&&!w||(be.crc32=_.crc32,be.compressedSize=_.compressedSize,be.uncompressedSize=_.uncompressedSize);var _e=0;b&&(_e|=8),$||!te&&!Q||(_e|=2048);var je=0,Ne=0;le&&(je|=16),k==="UNIX"?(Ne=798,je|=function(we,Me){var Te=we;return we||(Te=Me?16893:33204),(65535&Te)<<16}(L.unixPermissions,le)):(Ne=20,je|=function(we){return 63&(we||0)}(L.dosPermissions)),T=he.getUTCHours(),T<<=6,T|=he.getUTCMinutes(),T<<=5,T|=he.getUTCSeconds()/2,I=he.getUTCFullYear()-1980,I<<=4,I|=he.getUTCMonth()+1,I<<=5,I|=he.getUTCDate(),te&&(re=o(1,1)+o(p(q),4)+U,de+="up"+o(re.length,2)+re),Q&&(ae=o(1,1)+o(p(Y),4)+se,de+="uc"+o(ae.length,2)+ae);var Ge="";return Ge+=` \0`,Ge+=o(_e,2),Ge+=R.magic,Ge+=o(T,2),Ge+=o(I,2),Ge+=o(be.crc32,4),Ge+=o(be.compressedSize,4),Ge+=o(be.uncompressedSize,4),Ge+=o(q.length,2),Ge+=o(de.length,2),{fileRecord:f.LOCAL_FILE_HEADER+Ge+q+de,dirRecord:f.CENTRAL_FILE_HEADER+o(Ne,2)+Ge+o(Y.length,2)+"\0\0\0\0"+o(je,4)+o(j,4)+q+de+Y}}var i=r("../utils"),d=r("../stream/GenericWorker"),u=r("../utf8"),p=r("../crc32"),f=r("../signature");function y(_,b,w,j){d.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=w,this.encodeFileName=j,this.streamFiles=_,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(y,d),y.prototype.push=function(_){var b=_.meta.percent||0,w=this.entriesCount,j=this._sources.length;this.accumulate?this.contentBuffer.push(_):(this.bytesWritten+=_.data.length,d.prototype.push.call(this,{data:_.data,meta:{currentFile:this.currentFile,percent:w?(b+100*(w-j-1))/w:100}}))},y.prototype.openedSource=function(_){this.currentSourceOffset=this.bytesWritten,this.currentFile=_.file.name;var b=this.streamFiles&&!_.file.dir;if(b){var w=l(_,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:w.fileRecord,meta:{percent:0}})}else this.accumulate=!0},y.prototype.closedSource=function(_){this.accumulate=!1;var b=this.streamFiles&&!_.file.dir,w=l(_,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(w.dirRecord),b)this.push({data:function(j){return f.DATA_DESCRIPTOR+o(j.crc32,4)+o(j.compressedSize,4)+o(j.uncompressedSize,4)}(_),meta:{percent:100}});else for(this.push({data:w.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},y.prototype.flush=function(){for(var _=this.bytesWritten,b=0;b=this.index;d--)u=(u<<8)+this.byteAt(d);return this.index+=i,u},readString:function(i){return o.transformTo("string",this.readData(i))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var i=this.readInt(4);return new Date(Date.UTC(1980+(i>>25&127),(i>>21&15)-1,i>>16&31,i>>11&31,i>>5&63,(31&i)<<1))}},n.exports=l},{"../utils":32}],19:[function(r,n,a){var o=r("./Uint8ArrayReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.readData=function(i){this.checkOffset(i);var d=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},n.exports=l},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(r,n,a){var o=r("./DataReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.byteAt=function(i){return this.data.charCodeAt(this.zero+i)},l.prototype.lastIndexOfSignature=function(i){return this.data.lastIndexOf(i)-this.zero},l.prototype.readAndCheckSignature=function(i){return i===this.readData(4)},l.prototype.readData=function(i){this.checkOffset(i);var d=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},n.exports=l},{"../utils":32,"./DataReader":18}],21:[function(r,n,a){var o=r("./ArrayReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.readData=function(i){if(this.checkOffset(i),i===0)return new Uint8Array(0);var d=this.data.subarray(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},n.exports=l},{"../utils":32,"./ArrayReader":17}],22:[function(r,n,a){var o=r("../utils"),l=r("../support"),i=r("./ArrayReader"),d=r("./StringReader"),u=r("./NodeBufferReader"),p=r("./Uint8ArrayReader");n.exports=function(f){var y=o.getTypeOf(f);return o.checkSupport(y),y!=="string"||l.uint8array?y==="nodebuffer"?new u(f):l.uint8array?new p(o.transformTo("uint8array",f)):new i(o.transformTo("array",f)):new d(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(r,n,a){a.LOCAL_FILE_HEADER="PK",a.CENTRAL_FILE_HEADER="PK",a.CENTRAL_DIRECTORY_END="PK",a.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",a.ZIP64_CENTRAL_DIRECTORY_END="PK",a.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(r,n,a){var o=r("./GenericWorker"),l=r("../utils");function i(d){o.call(this,"ConvertWorker to "+d),this.destType=d}l.inherits(i,o),i.prototype.processChunk=function(d){this.push({data:l.transformTo(this.destType,d.data),meta:d.meta})},n.exports=i},{"../utils":32,"./GenericWorker":28}],25:[function(r,n,a){var o=r("./GenericWorker"),l=r("../crc32");function i(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}r("../utils").inherits(i,o),i.prototype.processChunk=function(d){this.streamInfo.crc32=l(d.data,this.streamInfo.crc32||0),this.push(d)},n.exports=i},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(r,n,a){var o=r("../utils"),l=r("./GenericWorker");function i(d){l.call(this,"DataLengthProbe for "+d),this.propName=d,this.withStreamInfo(d,0)}o.inherits(i,l),i.prototype.processChunk=function(d){if(d){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+d.data.length}l.prototype.processChunk.call(this,d)},n.exports=i},{"../utils":32,"./GenericWorker":28}],27:[function(r,n,a){var o=r("../utils"),l=r("./GenericWorker");function i(d){l.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,d.then(function(p){u.dataIsReady=!0,u.data=p,u.max=p&&p.length||0,u.type=o.getTypeOf(p),u.isPaused||u._tickAndRepeat()},function(p){u.error(p)})}o.inherits(i,l),i.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this.data=null},i.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},i.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},i.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var d=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":d=this.data.substring(this.index,u);break;case"uint8array":d=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":d=this.data.slice(this.index,u)}return this.index=u,this.push({data:d,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=i},{"../utils":32,"./GenericWorker":28}],28:[function(r,n,a){function o(l){this.name=l||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}o.prototype={push:function(l){this.emit("data",l)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(l){this.emit("error",l)}return!0},error:function(l){return!this.isFinished&&(this.isPaused?this.generatedError=l:(this.isFinished=!0,this.emit("error",l),this.previous&&this.previous.error(l),this.cleanUp()),!0)},on:function(l,i){return this._listeners[l].push(i),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(l,i){if(this._listeners[l])for(var d=0;d "+l:l}},n.exports=o},{}],29:[function(r,n,a){var o=r("../utils"),l=r("./ConvertWorker"),i=r("./GenericWorker"),d=r("../base64"),u=r("../support"),p=r("../external"),f=null;if(u.nodestream)try{f=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function y(b,w){return new p.Promise(function(j,k){var S=[],T=b._internalType,I=b._outputType,L=b._mimeType;b.on("data",function(R,$){S.push(R),w&&w($)}).on("error",function(R){S=[],k(R)}).on("end",function(){try{var R=function($,q,U){switch($){case"blob":return o.newBlob(o.transformTo("arraybuffer",q),U);case"base64":return d.encode(q);default:return o.transformTo($,q)}}(I,function($,q){var U,H=0,Y=null,se=0;for(U=0;U"u")a.blob=!1;else{var o=new ArrayBuffer(0);try{a.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var l=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);l.append(o),a.blob=l.getBlob("application/zip").size===0}catch{a.blob=!1}}}try{a.nodestream=!!r("readable-stream").Readable}catch{a.nodestream=!1}},{"readable-stream":16}],31:[function(r,n,a){for(var o=r("./utils"),l=r("./support"),i=r("./nodejsUtils"),d=r("./stream/GenericWorker"),u=new Array(256),p=0;p<256;p++)u[p]=252<=p?6:248<=p?5:240<=p?4:224<=p?3:192<=p?2:1;u[254]=u[254]=1;function f(){d.call(this,"utf-8 decode"),this.leftOver=null}function y(){d.call(this,"utf-8 encode")}a.utf8encode=function(_){return l.nodebuffer?i.newBufferFrom(_,"utf-8"):function(b){var w,j,k,S,T,I=b.length,L=0;for(S=0;S>>6:(j<65536?w[T++]=224|j>>>12:(w[T++]=240|j>>>18,w[T++]=128|j>>>12&63),w[T++]=128|j>>>6&63),w[T++]=128|63&j);return w}(_)},a.utf8decode=function(_){return l.nodebuffer?o.transformTo("nodebuffer",_).toString("utf-8"):function(b){var w,j,k,S,T=b.length,I=new Array(2*T);for(w=j=0;w>10&1023,I[j++]=56320|1023&k)}return I.length!==j&&(I.subarray?I=I.subarray(0,j):I.length=j),o.applyFromCharCode(I)}(_=o.transformTo(l.uint8array?"uint8array":"array",_))},o.inherits(f,d),f.prototype.processChunk=function(_){var b=o.transformTo(l.uint8array?"uint8array":"array",_.data);if(this.leftOver&&this.leftOver.length){if(l.uint8array){var w=b;(b=new Uint8Array(w.length+this.leftOver.length)).set(this.leftOver,0),b.set(w,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var j=function(S,T){var I;for((T=T||S.length)>S.length&&(T=S.length),I=T-1;0<=I&&(192&S[I])==128;)I--;return I<0||I===0?T:I+u[S[I]]>T?I:T}(b),k=b;j!==b.length&&(l.uint8array?(k=b.subarray(0,j),this.leftOver=b.subarray(j,b.length)):(k=b.slice(0,j),this.leftOver=b.slice(j,b.length))),this.push({data:a.utf8decode(k),meta:_.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:a.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},a.Utf8DecodeWorker=f,o.inherits(y,d),y.prototype.processChunk=function(_){this.push({data:a.utf8encode(_.data),meta:_.meta})},a.Utf8EncodeWorker=y},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(r,n,a){var o=r("./support"),l=r("./base64"),i=r("./nodejsUtils"),d=r("./external");function u(w){return w}function p(w,j){for(var k=0;k>8;this.dir=!!(16&this.externalFileAttributes),_==0&&(this.dosPermissions=63&this.externalFileAttributes),_==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var _=o(this.extraFields[1].value);this.uncompressedSize===l.MAX_VALUE_32BITS&&(this.uncompressedSize=_.readInt(8)),this.compressedSize===l.MAX_VALUE_32BITS&&(this.compressedSize=_.readInt(8)),this.localHeaderOffset===l.MAX_VALUE_32BITS&&(this.localHeaderOffset=_.readInt(8)),this.diskNumberStart===l.MAX_VALUE_32BITS&&(this.diskNumberStart=_.readInt(4))}},readExtraFields:function(_){var b,w,j,k=_.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});_.index+4>>6:(_<65536?y[j++]=224|_>>>12:(y[j++]=240|_>>>18,y[j++]=128|_>>>12&63),y[j++]=128|_>>>6&63),y[j++]=128|63&_);return y},a.buf2binstring=function(f){return p(f,f.length)},a.binstring2buf=function(f){for(var y=new o.Buf8(f.length),_=0,b=y.length;_>10&1023,S[b++]=56320|1023&w)}return p(S,b)},a.utf8border=function(f,y){var _;for((y=y||f.length)>f.length&&(y=f.length),_=y-1;0<=_&&(192&f[_])==128;)_--;return _<0||_===0?y:_+d[f[_]]>y?_:y}},{"./common":41}],43:[function(r,n,a){n.exports=function(o,l,i,d){for(var u=65535&o|0,p=o>>>16&65535|0,f=0;i!==0;){for(i-=f=2e3>>1:l>>>1;i[d]=l}return i}();n.exports=function(l,i,d,u){var p=o,f=u+d;l^=-1;for(var y=u;y>>8^p[255&(l^i[y])];return-1^l}},{}],46:[function(r,n,a){var o,l=r("../utils/common"),i=r("./trees"),d=r("./adler32"),u=r("./crc32"),p=r("./messages"),f=0,y=4,_=0,b=-2,w=-1,j=4,k=2,S=8,T=9,I=286,L=30,R=19,$=2*I+1,q=15,U=3,H=258,Y=H+U+1,se=42,te=113,Q=1,de=2,re=3,ae=4;function le(me,Xe){return me.msg=p[Xe],Xe}function he(me){return(me<<1)-(4me.avail_out&&(ot=me.avail_out),ot!==0&&(l.arraySet(me.output,Xe.pending_buf,Xe.pending_out,ot,me.next_out),me.next_out+=ot,Xe.pending_out+=ot,me.total_out+=ot,me.avail_out-=ot,Xe.pending-=ot,Xe.pending===0&&(Xe.pending_out=0))}function je(me,Xe){i._tr_flush_block(me,0<=me.block_start?me.block_start:-1,me.strstart-me.block_start,Xe),me.block_start=me.strstart,_e(me.strm)}function Ne(me,Xe){me.pending_buf[me.pending++]=Xe}function Ge(me,Xe){me.pending_buf[me.pending++]=Xe>>>8&255,me.pending_buf[me.pending++]=255&Xe}function we(me,Xe){var ot,nt,Se=me.max_chain_length,it=me.strstart,$e=me.prev_length,ct=me.nice_match,qe=me.strstart>me.w_size-Y?me.strstart-(me.w_size-Y):0,Ze=me.window,Qe=me.w_mask,We=me.prev,He=me.strstart+H,et=Ze[it+$e-1],Tt=Ze[it+$e];me.prev_length>=me.good_match&&(Se>>=2),ct>me.lookahead&&(ct=me.lookahead);do if(Ze[(ot=Xe)+$e]===Tt&&Ze[ot+$e-1]===et&&Ze[ot]===Ze[it]&&Ze[++ot]===Ze[it+1]){it+=2,ot++;do;while(Ze[++it]===Ze[++ot]&&Ze[++it]===Ze[++ot]&&Ze[++it]===Ze[++ot]&&Ze[++it]===Ze[++ot]&&Ze[++it]===Ze[++ot]&&Ze[++it]===Ze[++ot]&&Ze[++it]===Ze[++ot]&&Ze[++it]===Ze[++ot]&&itqe&&--Se!=0);return $e<=me.lookahead?$e:me.lookahead}function Me(me){var Xe,ot,nt,Se,it,$e,ct,qe,Ze,Qe,We=me.w_size;do{if(Se=me.window_size-me.lookahead-me.strstart,me.strstart>=We+(We-Y)){for(l.arraySet(me.window,me.window,We,We,0),me.match_start-=We,me.strstart-=We,me.block_start-=We,Xe=ot=me.hash_size;nt=me.head[--Xe],me.head[Xe]=We<=nt?nt-We:0,--ot;);for(Xe=ot=We;nt=me.prev[--Xe],me.prev[Xe]=We<=nt?nt-We:0,--ot;);Se+=We}if(me.strm.avail_in===0)break;if($e=me.strm,ct=me.window,qe=me.strstart+me.lookahead,Ze=Se,Qe=void 0,Qe=$e.avail_in,Ze=U)for(it=me.strstart-me.insert,me.ins_h=me.window[it],me.ins_h=(me.ins_h<=U&&(me.ins_h=(me.ins_h<=U)if(nt=i._tr_tally(me,me.strstart-me.match_start,me.match_length-U),me.lookahead-=me.match_length,me.match_length<=me.max_lazy_match&&me.lookahead>=U){for(me.match_length--;me.strstart++,me.ins_h=(me.ins_h<=U&&(me.ins_h=(me.ins_h<=U&&me.match_length<=me.prev_length){for(Se=me.strstart+me.lookahead-U,nt=i._tr_tally(me,me.strstart-1-me.prev_match,me.prev_length-U),me.lookahead-=me.prev_length-1,me.prev_length-=2;++me.strstart<=Se&&(me.ins_h=(me.ins_h<me.pending_buf_size-5&&(ot=me.pending_buf_size-5);;){if(me.lookahead<=1){if(Me(me),me.lookahead===0&&Xe===f)return Q;if(me.lookahead===0)break}me.strstart+=me.lookahead,me.lookahead=0;var nt=me.block_start+ot;if((me.strstart===0||me.strstart>=nt)&&(me.lookahead=me.strstart-nt,me.strstart=nt,je(me,!1),me.strm.avail_out===0)||me.strstart-me.block_start>=me.w_size-Y&&(je(me,!1),me.strm.avail_out===0))return Q}return me.insert=0,Xe===y?(je(me,!0),me.strm.avail_out===0?re:ae):(me.strstart>me.block_start&&(je(me,!1),me.strm.avail_out),Q)}),new Ae(4,4,8,4,Te),new Ae(4,5,16,8,Te),new Ae(4,6,32,32,Te),new Ae(4,4,16,16,Fe),new Ae(8,16,32,32,Fe),new Ae(8,16,128,128,Fe),new Ae(8,32,128,256,Fe),new Ae(32,128,258,1024,Fe),new Ae(32,258,258,4096,Fe)],a.deflateInit=function(me,Xe){return Rt(me,Xe,S,15,8,0)},a.deflateInit2=Rt,a.deflateReset=De,a.deflateResetKeep=ut,a.deflateSetHeader=function(me,Xe){return me&&me.state?me.state.wrap!==2?b:(me.state.gzhead=Xe,_):b},a.deflate=function(me,Xe){var ot,nt,Se,it;if(!me||!me.state||5>8&255),Ne(nt,nt.gzhead.time>>16&255),Ne(nt,nt.gzhead.time>>24&255),Ne(nt,nt.level===9?2:2<=nt.strategy||nt.level<2?4:0),Ne(nt,255&nt.gzhead.os),nt.gzhead.extra&&nt.gzhead.extra.length&&(Ne(nt,255&nt.gzhead.extra.length),Ne(nt,nt.gzhead.extra.length>>8&255)),nt.gzhead.hcrc&&(me.adler=u(me.adler,nt.pending_buf,nt.pending,0)),nt.gzindex=0,nt.status=69):(Ne(nt,0),Ne(nt,0),Ne(nt,0),Ne(nt,0),Ne(nt,0),Ne(nt,nt.level===9?2:2<=nt.strategy||nt.level<2?4:0),Ne(nt,3),nt.status=te);else{var $e=S+(nt.w_bits-8<<4)<<8;$e|=(2<=nt.strategy||nt.level<2?0:nt.level<6?1:nt.level===6?2:3)<<6,nt.strstart!==0&&($e|=32),$e+=31-$e%31,nt.status=te,Ge(nt,$e),nt.strstart!==0&&(Ge(nt,me.adler>>>16),Ge(nt,65535&me.adler)),me.adler=1}if(nt.status===69)if(nt.gzhead.extra){for(Se=nt.pending;nt.gzindex<(65535&nt.gzhead.extra.length)&&(nt.pending!==nt.pending_buf_size||(nt.gzhead.hcrc&&nt.pending>Se&&(me.adler=u(me.adler,nt.pending_buf,nt.pending-Se,Se)),_e(me),Se=nt.pending,nt.pending!==nt.pending_buf_size));)Ne(nt,255&nt.gzhead.extra[nt.gzindex]),nt.gzindex++;nt.gzhead.hcrc&&nt.pending>Se&&(me.adler=u(me.adler,nt.pending_buf,nt.pending-Se,Se)),nt.gzindex===nt.gzhead.extra.length&&(nt.gzindex=0,nt.status=73)}else nt.status=73;if(nt.status===73)if(nt.gzhead.name){Se=nt.pending;do{if(nt.pending===nt.pending_buf_size&&(nt.gzhead.hcrc&&nt.pending>Se&&(me.adler=u(me.adler,nt.pending_buf,nt.pending-Se,Se)),_e(me),Se=nt.pending,nt.pending===nt.pending_buf_size)){it=1;break}it=nt.gzindexSe&&(me.adler=u(me.adler,nt.pending_buf,nt.pending-Se,Se)),it===0&&(nt.gzindex=0,nt.status=91)}else nt.status=91;if(nt.status===91)if(nt.gzhead.comment){Se=nt.pending;do{if(nt.pending===nt.pending_buf_size&&(nt.gzhead.hcrc&&nt.pending>Se&&(me.adler=u(me.adler,nt.pending_buf,nt.pending-Se,Se)),_e(me),Se=nt.pending,nt.pending===nt.pending_buf_size)){it=1;break}it=nt.gzindexSe&&(me.adler=u(me.adler,nt.pending_buf,nt.pending-Se,Se)),it===0&&(nt.status=103)}else nt.status=103;if(nt.status===103&&(nt.gzhead.hcrc?(nt.pending+2>nt.pending_buf_size&&_e(me),nt.pending+2<=nt.pending_buf_size&&(Ne(nt,255&me.adler),Ne(nt,me.adler>>8&255),me.adler=0,nt.status=te)):nt.status=te),nt.pending!==0){if(_e(me),me.avail_out===0)return nt.last_flush=-1,_}else if(me.avail_in===0&&he(Xe)<=he(ot)&&Xe!==y)return le(me,-5);if(nt.status===666&&me.avail_in!==0)return le(me,-5);if(me.avail_in!==0||nt.lookahead!==0||Xe!==f&&nt.status!==666){var ct=nt.strategy===2?function(qe,Ze){for(var Qe;;){if(qe.lookahead===0&&(Me(qe),qe.lookahead===0)){if(Ze===f)return Q;break}if(qe.match_length=0,Qe=i._tr_tally(qe,0,qe.window[qe.strstart]),qe.lookahead--,qe.strstart++,Qe&&(je(qe,!1),qe.strm.avail_out===0))return Q}return qe.insert=0,Ze===y?(je(qe,!0),qe.strm.avail_out===0?re:ae):qe.last_lit&&(je(qe,!1),qe.strm.avail_out===0)?Q:de}(nt,Xe):nt.strategy===3?function(qe,Ze){for(var Qe,We,He,et,Tt=qe.window;;){if(qe.lookahead<=H){if(Me(qe),qe.lookahead<=H&&Ze===f)return Q;if(qe.lookahead===0)break}if(qe.match_length=0,qe.lookahead>=U&&0qe.lookahead&&(qe.match_length=qe.lookahead)}if(qe.match_length>=U?(Qe=i._tr_tally(qe,1,qe.match_length-U),qe.lookahead-=qe.match_length,qe.strstart+=qe.match_length,qe.match_length=0):(Qe=i._tr_tally(qe,0,qe.window[qe.strstart]),qe.lookahead--,qe.strstart++),Qe&&(je(qe,!1),qe.strm.avail_out===0))return Q}return qe.insert=0,Ze===y?(je(qe,!0),qe.strm.avail_out===0?re:ae):qe.last_lit&&(je(qe,!1),qe.strm.avail_out===0)?Q:de}(nt,Xe):o[nt.level].func(nt,Xe);if(ct!==re&&ct!==ae||(nt.status=666),ct===Q||ct===re)return me.avail_out===0&&(nt.last_flush=-1),_;if(ct===de&&(Xe===1?i._tr_align(nt):Xe!==5&&(i._tr_stored_block(nt,0,0,!1),Xe===3&&(be(nt.head),nt.lookahead===0&&(nt.strstart=0,nt.block_start=0,nt.insert=0))),_e(me),me.avail_out===0))return nt.last_flush=-1,_}return Xe!==y?_:nt.wrap<=0?1:(nt.wrap===2?(Ne(nt,255&me.adler),Ne(nt,me.adler>>8&255),Ne(nt,me.adler>>16&255),Ne(nt,me.adler>>24&255),Ne(nt,255&me.total_in),Ne(nt,me.total_in>>8&255),Ne(nt,me.total_in>>16&255),Ne(nt,me.total_in>>24&255)):(Ge(nt,me.adler>>>16),Ge(nt,65535&me.adler)),_e(me),0=ot.w_size&&(it===0&&(be(ot.head),ot.strstart=0,ot.block_start=0,ot.insert=0),Ze=new l.Buf8(ot.w_size),l.arraySet(Ze,Xe,Qe-ot.w_size,ot.w_size,0),Xe=Ze,Qe=ot.w_size),$e=me.avail_in,ct=me.next_in,qe=me.input,me.avail_in=Qe,me.next_in=0,me.input=Xe,Me(ot);ot.lookahead>=U;){for(nt=ot.strstart,Se=ot.lookahead-(U-1);ot.ins_h=(ot.ins_h<>>=U=q>>>24,T-=U,(U=q>>>16&255)===0)de[p++]=65535&q;else{if(!(16&U)){if(!(64&U)){q=I[(65535&q)+(S&(1<>>=U,T-=U),T<15&&(S+=Q[d++]<>>=U=q>>>24,T-=U,!(16&(U=q>>>16&255))){if(!(64&U)){q=L[(65535&q)+(S&(1<>>=U,T-=U,(U=p-f)>3,S&=(1<<(T-=H<<3))-1,o.next_in=d,o.next_out=p,o.avail_in=d>>24&255)+(se>>>8&65280)+((65280&se)<<8)+((255&se)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function T(se){var te;return se&&se.state?(te=se.state,se.total_in=se.total_out=te.total=0,se.msg="",te.wrap&&(se.adler=1&te.wrap),te.mode=b,te.last=0,te.havedict=0,te.dmax=32768,te.head=null,te.hold=0,te.bits=0,te.lencode=te.lendyn=new o.Buf32(w),te.distcode=te.distdyn=new o.Buf32(j),te.sane=1,te.back=-1,y):_}function I(se){var te;return se&&se.state?((te=se.state).wsize=0,te.whave=0,te.wnext=0,T(se)):_}function L(se,te){var Q,de;return se&&se.state?(de=se.state,te<0?(Q=0,te=-te):(Q=1+(te>>4),te<48&&(te&=15)),te&&(te<8||15=ae.wsize?(o.arraySet(ae.window,te,Q-ae.wsize,ae.wsize,0),ae.wnext=0,ae.whave=ae.wsize):(de<(re=ae.wsize-ae.wnext)&&(re=de),o.arraySet(ae.window,te,Q-de,re,ae.wnext),(de-=re)?(o.arraySet(ae.window,te,Q-de,de,0),ae.wnext=de,ae.whave=ae.wsize):(ae.wnext+=re,ae.wnext===ae.wsize&&(ae.wnext=0),ae.whave>>8&255,Q.check=i(Q.check,it,2,0),je=_e=0,Q.mode=2;break}if(Q.flags=0,Q.head&&(Q.head.done=!1),!(1&Q.wrap)||(((255&_e)<<8)+(_e>>8))%31){se.msg="incorrect header check",Q.mode=30;break}if((15&_e)!=8){se.msg="unknown compression method",Q.mode=30;break}if(je-=4,me=8+(15&(_e>>>=4)),Q.wbits===0)Q.wbits=me;else if(me>Q.wbits){se.msg="invalid window size",Q.mode=30;break}Q.dmax=1<>8&1),512&Q.flags&&(it[0]=255&_e,it[1]=_e>>>8&255,Q.check=i(Q.check,it,2,0)),je=_e=0,Q.mode=3;case 3:for(;je<32;){if(he===0)break e;he--,_e+=de[ae++]<>>8&255,it[2]=_e>>>16&255,it[3]=_e>>>24&255,Q.check=i(Q.check,it,4,0)),je=_e=0,Q.mode=4;case 4:for(;je<16;){if(he===0)break e;he--,_e+=de[ae++]<>8),512&Q.flags&&(it[0]=255&_e,it[1]=_e>>>8&255,Q.check=i(Q.check,it,2,0)),je=_e=0,Q.mode=5;case 5:if(1024&Q.flags){for(;je<16;){if(he===0)break e;he--,_e+=de[ae++]<>>8&255,Q.check=i(Q.check,it,2,0)),je=_e=0}else Q.head&&(Q.head.extra=null);Q.mode=6;case 6:if(1024&Q.flags&&(he<(we=Q.length)&&(we=he),we&&(Q.head&&(me=Q.head.extra_len-Q.length,Q.head.extra||(Q.head.extra=new Array(Q.head.extra_len)),o.arraySet(Q.head.extra,de,ae,we,me)),512&Q.flags&&(Q.check=i(Q.check,de,we,ae)),he-=we,ae+=we,Q.length-=we),Q.length))break e;Q.length=0,Q.mode=7;case 7:if(2048&Q.flags){if(he===0)break e;for(we=0;me=de[ae+we++],Q.head&&me&&Q.length<65536&&(Q.head.name+=String.fromCharCode(me)),me&&we>9&1,Q.head.done=!0),se.adler=Q.check=0,Q.mode=12;break;case 10:for(;je<32;){if(he===0)break e;he--,_e+=de[ae++]<>>=7&je,je-=7&je,Q.mode=27;break}for(;je<3;){if(he===0)break e;he--,_e+=de[ae++]<>>=1)){case 0:Q.mode=14;break;case 1:if(H(Q),Q.mode=20,te!==6)break;_e>>>=2,je-=2;break e;case 2:Q.mode=17;break;case 3:se.msg="invalid block type",Q.mode=30}_e>>>=2,je-=2;break;case 14:for(_e>>>=7&je,je-=7&je;je<32;){if(he===0)break e;he--,_e+=de[ae++]<>>16^65535)){se.msg="invalid stored block lengths",Q.mode=30;break}if(Q.length=65535&_e,je=_e=0,Q.mode=15,te===6)break e;case 15:Q.mode=16;case 16:if(we=Q.length){if(he>>=5,je-=5,Q.ndist=1+(31&_e),_e>>>=5,je-=5,Q.ncode=4+(15&_e),_e>>>=4,je-=4,286>>=3,je-=3}for(;Q.have<19;)Q.lens[$e[Q.have++]]=0;if(Q.lencode=Q.lendyn,Q.lenbits=7,ot={bits:Q.lenbits},Xe=u(0,Q.lens,0,19,Q.lencode,0,Q.work,ot),Q.lenbits=ot.bits,Xe){se.msg="invalid code lengths set",Q.mode=30;break}Q.have=0,Q.mode=19;case 19:for(;Q.have>>16&255,Ue=65535&Se,!((Fe=Se>>>24)<=je);){if(he===0)break e;he--,_e+=de[ae++]<>>=Fe,je-=Fe,Q.lens[Q.have++]=Ue;else{if(Ue===16){for(nt=Fe+2;je>>=Fe,je-=Fe,Q.have===0){se.msg="invalid bit length repeat",Q.mode=30;break}me=Q.lens[Q.have-1],we=3+(3&_e),_e>>>=2,je-=2}else if(Ue===17){for(nt=Fe+3;je>>=Fe)),_e>>>=3,je-=3}else{for(nt=Fe+7;je>>=Fe)),_e>>>=7,je-=7}if(Q.have+we>Q.nlen+Q.ndist){se.msg="invalid bit length repeat",Q.mode=30;break}for(;we--;)Q.lens[Q.have++]=me}}if(Q.mode===30)break;if(Q.lens[256]===0){se.msg="invalid code -- missing end-of-block",Q.mode=30;break}if(Q.lenbits=9,ot={bits:Q.lenbits},Xe=u(p,Q.lens,0,Q.nlen,Q.lencode,0,Q.work,ot),Q.lenbits=ot.bits,Xe){se.msg="invalid literal/lengths set",Q.mode=30;break}if(Q.distbits=6,Q.distcode=Q.distdyn,ot={bits:Q.distbits},Xe=u(f,Q.lens,Q.nlen,Q.ndist,Q.distcode,0,Q.work,ot),Q.distbits=ot.bits,Xe){se.msg="invalid distances set",Q.mode=30;break}if(Q.mode=20,te===6)break e;case 20:Q.mode=21;case 21:if(6<=he&&258<=be){se.next_out=le,se.avail_out=be,se.next_in=ae,se.avail_in=he,Q.hold=_e,Q.bits=je,d(se,Ge),le=se.next_out,re=se.output,be=se.avail_out,ae=se.next_in,de=se.input,he=se.avail_in,_e=Q.hold,je=Q.bits,Q.mode===12&&(Q.back=-1);break}for(Q.back=0;Ae=(Se=Q.lencode[_e&(1<>>16&255,Ue=65535&Se,!((Fe=Se>>>24)<=je);){if(he===0)break e;he--,_e+=de[ae++]<>ut)])>>>16&255,Ue=65535&Se,!(ut+(Fe=Se>>>24)<=je);){if(he===0)break e;he--,_e+=de[ae++]<>>=ut,je-=ut,Q.back+=ut}if(_e>>>=Fe,je-=Fe,Q.back+=Fe,Q.length=Ue,Ae===0){Q.mode=26;break}if(32&Ae){Q.back=-1,Q.mode=12;break}if(64&Ae){se.msg="invalid literal/length code",Q.mode=30;break}Q.extra=15&Ae,Q.mode=22;case 22:if(Q.extra){for(nt=Q.extra;je>>=Q.extra,je-=Q.extra,Q.back+=Q.extra}Q.was=Q.length,Q.mode=23;case 23:for(;Ae=(Se=Q.distcode[_e&(1<>>16&255,Ue=65535&Se,!((Fe=Se>>>24)<=je);){if(he===0)break e;he--,_e+=de[ae++]<>ut)])>>>16&255,Ue=65535&Se,!(ut+(Fe=Se>>>24)<=je);){if(he===0)break e;he--,_e+=de[ae++]<>>=ut,je-=ut,Q.back+=ut}if(_e>>>=Fe,je-=Fe,Q.back+=Fe,64&Ae){se.msg="invalid distance code",Q.mode=30;break}Q.offset=Ue,Q.extra=15&Ae,Q.mode=24;case 24:if(Q.extra){for(nt=Q.extra;je>>=Q.extra,je-=Q.extra,Q.back+=Q.extra}if(Q.offset>Q.dmax){se.msg="invalid distance too far back",Q.mode=30;break}Q.mode=25;case 25:if(be===0)break e;if(we=Ge-be,Q.offset>we){if((we=Q.offset-we)>Q.whave&&Q.sane){se.msg="invalid distance too far back",Q.mode=30;break}Me=we>Q.wnext?(we-=Q.wnext,Q.wsize-we):Q.wnext-we,we>Q.length&&(we=Q.length),Te=Q.window}else Te=re,Me=le-Q.offset,we=Q.length;for(be$?(U=Me[Te+j[te]],je[Ne+j[te]]):(U=96,0),S=1<>le)+(T-=S)]=q<<24|U<<16|H|0,T!==0;);for(S=1<>=1;if(S!==0?(_e&=S-1,_e+=S):_e=0,te++,--Ge[se]==0){if(se===de)break;se=f[y+j[te]]}if(re>>7)]}function Ne(Se,it){Se.pending_buf[Se.pending++]=255&it,Se.pending_buf[Se.pending++]=it>>>8&255}function Ge(Se,it,$e){Se.bi_valid>k-$e?(Se.bi_buf|=it<>k-Se.bi_valid,Se.bi_valid+=$e-k):(Se.bi_buf|=it<>>=1,$e<<=1,0<--it;);return $e>>>1}function Te(Se,it,$e){var ct,qe,Ze=new Array(j+1),Qe=0;for(ct=1;ct<=j;ct++)Ze[ct]=Qe=Qe+$e[ct-1]<<1;for(qe=0;qe<=it;qe++){var We=Se[2*qe+1];We!==0&&(Se[2*qe]=Me(Ze[We]++,We))}}function Fe(Se){var it;for(it=0;it>1;1<=$e;$e--)ut(Se,Ze,$e);for(qe=He;$e=Se.heap[1],Se.heap[1]=Se.heap[Se.heap_len--],ut(Se,Ze,1),ct=Se.heap[1],Se.heap[--Se.heap_max]=$e,Se.heap[--Se.heap_max]=ct,Ze[2*qe]=Ze[2*$e]+Ze[2*ct],Se.depth[qe]=(Se.depth[$e]>=Se.depth[ct]?Se.depth[$e]:Se.depth[ct])+1,Ze[2*$e+1]=Ze[2*ct+1]=qe,Se.heap[1]=qe++,ut(Se,Ze,1),2<=Se.heap_len;);Se.heap[--Se.heap_max]=Se.heap[1],function(Tt,Ft){var as,Xt,ss,is,ar,Ct,Is=Ft.dyn_tree,qs=Ft.max_code,gr=Ft.stat_desc.static_tree,Wn=Ft.stat_desc.has_stree,ii=Ft.stat_desc.extra_bits,bo=Ft.stat_desc.extra_base,si=Ft.stat_desc.max_length,nn=0;for(is=0;is<=j;is++)Tt.bl_count[is]=0;for(Is[2*Tt.heap[Tt.heap_max]+1]=0,as=Tt.heap_max+1;as>=7;qe<_;qe++)for(he[qe]=Ze<<7,it=0;it<1<>>=1)if(1&et&&We.dyn_ltree[2*He]!==0)return l;if(We.dyn_ltree[18]!==0||We.dyn_ltree[20]!==0||We.dyn_ltree[26]!==0)return i;for(He=32;He>>3,(Ze=Se.static_len+3+7>>>3)<=qe&&(qe=Ze)):qe=Ze=$e+5,$e+4<=qe&&it!==-1?nt(Se,it,$e,ct):Se.strategy===4||Ze===qe?(Ge(Se,2+(ct?1:0),3),De(Se,Y,se)):(Ge(Se,4+(ct?1:0),3),function(We,He,et,Tt){var Ft;for(Ge(We,He-257,5),Ge(We,et-1,5),Ge(We,Tt-4,4),Ft=0;Ft>>8&255,Se.pending_buf[Se.d_buf+2*Se.last_lit+1]=255&it,Se.pending_buf[Se.l_buf+Se.last_lit]=255&$e,Se.last_lit++,it===0?Se.dyn_ltree[2*$e]++:(Se.matches++,it--,Se.dyn_ltree[2*(Q[$e]+f+1)]++,Se.dyn_dtree[2*je(it)]++),Se.last_lit===Se.lit_bufsize-1},a._tr_align=function(Se){Ge(Se,2,3),we(Se,T,Y),function(it){it.bi_valid===16?(Ne(it,it.bi_buf),it.bi_buf=0,it.bi_valid=0):8<=it.bi_valid&&(it.pending_buf[it.pending++]=255&it.bi_buf,it.bi_buf>>=8,it.bi_valid-=8)}(Se)}},{"../utils/common":41}],53:[function(r,n,a){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(r,n,a){(function(o){(function(l,i){if(!l.setImmediate){var d,u,p,f,y=1,_={},b=!1,w=l.document,j=Object.getPrototypeOf&&Object.getPrototypeOf(l);j=j&&j.setTimeout?j:l,d={}.toString.call(l.process)==="[object process]"?function(I){process.nextTick(function(){S(I)})}:function(){if(l.postMessage&&!l.importScripts){var I=!0,L=l.onmessage;return l.onmessage=function(){I=!1},l.postMessage("","*"),l.onmessage=L,I}}()?(f="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",T,!1):l.attachEvent("onmessage",T),function(I){l.postMessage(f+I,"*")}):l.MessageChannel?((p=new MessageChannel).port1.onmessage=function(I){S(I.data)},function(I){p.port2.postMessage(I)}):w&&"onreadystatechange"in w.createElement("script")?(u=w.documentElement,function(I){var L=w.createElement("script");L.onreadystatechange=function(){S(I),L.onreadystatechange=null,u.removeChild(L),L=null},u.appendChild(L)}):function(I){setTimeout(S,0,I)},j.setImmediate=function(I){typeof I!="function"&&(I=new Function(""+I));for(var L=new Array(arguments.length-1),R=0;R"u"?o===void 0?this:o:self)}).call(this,typeof b0<"u"?b0:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(jKe);var k8t=jKe.exports;const S8t=_o(k8t);function Xme(t,s=400,r=75){return t&&`${t.replace("/storage/v1/object/public/","/storage/v1/render/image/public/")}?width=${s}&quality=${r}&resize=contain`}const C8t=()=>{const{isAdmin:t}=Hs(),[s,r]=C.useState(null),[n,a]=C.useState(null),[o,l]=C.useState("all"),[i,d]=C.useState(new Set),[u,p]=C.useState(!1),[f,y]=C.useState(!1),[_,b]=C.useState("images"),[w,j]=C.useState(null),{data:k=[],isLoading:S}=wt({queryKey:["social-swag-2"],queryFn:async()=>{const{data:he,error:be}=await G.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(be)throw be;return he}}),{data:T=[]}=wt({queryKey:["social-swag-2-months"],queryFn:async()=>{const{data:he,error:be}=await G.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(be)throw be;return he}}),{data:I=[]}=wt({queryKey:["social-swag-2-reels"],queryFn:async()=>{const{data:he,error:be}=await G.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(be)throw be;return he}}),{data:L=[]}=wt({queryKey:["my-social-accounts-count"],queryFn:async()=>{const{data:he,error:be}=await G.from("social_accounts").select("id, platform").eq("is_active",!0);if(be)throw be;return he||[]}}),R=L.length>0,$=C.useMemo(()=>o==="all"?null:I.find(he=>he.month===o)||null,[o,I]),q=C.useMemo(()=>[...new Set(k.map(be=>be.month))].sort((be,_e)=>_e.localeCompare(be)),[k]);C.useEffect(()=>{q.length>0&&o==="all"&&l(q[0])},[q,o]);const U=he=>{try{const be=h_e(he,"yyyy-MM",new Date);return ys(be,"MMMM yyyy")}catch{return he}},H=C.useMemo(()=>o==="all"?k:k.filter(he=>he.month===o),[o,k]),Y=C.useMemo(()=>{var he;return o==="all"?null:((he=T.find(be=>be.month===o))==null?void 0:he.canva_link)||null},[o,T]),se=async he=>{try{await navigator.clipboard.writeText(he),fe.success("Caption copied to clipboard!")}catch{fe.error("Failed to copy caption")}},te=async(he,be)=>{try{const je=await(await fetch(he)).blob(),Ne=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),Ge=navigator.canShare&&navigator.canShare({files:[new File([je],"test.jpg",{type:"image/jpeg"})]});if(Ne&&Ge){const we=new File([je],`social-swag-${be}.jpg`,{type:"image/jpeg"});await navigator.share({files:[we],title:"Social Swag Image"}),fe.success("Image ready to save!")}else{const we=window.URL.createObjectURL(je),Me=document.createElement("a");Me.href=we,Me.download=`social-swag-${be}.jpg`,document.body.appendChild(Me),Me.click(),document.body.removeChild(Me),window.URL.revokeObjectURL(we),fe.success("Image downloaded!")}}catch(_e){_e.name!=="AbortError"&&fe.error("Failed to download image")}},Q=he=>{d(be=>{const _e=new Set(be);return _e.has(he)?_e.delete(he):_e.add(he),_e})},de=()=>{d(new Set(H.map(he=>he.id)))},re=()=>{d(new Set),p(!1)},ae=async()=>{const he=H.filter(be=>i.has(be.id));if(he.length===0){fe.error("No images selected");return}y(!0),fe.info(`Preparing ${he.length} images for download...`);try{const be=new S8t,_e=[...he].sort((Me,Te)=>Me.sort_order-Te.sort_order);for(let Me=0;Me<_e.length;Me++){const Te=_e[Me];try{const Fe=await fetch(Te.image_url),Ae=await Fe.blob(),Ue=Fe.headers.get("content-type")||"image/jpeg",ut=Ue.includes("png")?"png":Ue.includes("webp")?"webp":"jpg",De=`${Me+1}.${ut}`;be.file(De,Ae)}catch{console.error("Failed to fetch image:",Te.id)}}const je=o!=="all"?U(o):"Social Swag",Ne=await be.generateAsync({type:"blob"}),Ge=window.URL.createObjectURL(Ne),we=document.createElement("a");we.href=Ge,we.download=`${je}.zip`,document.body.appendChild(we),we.click(),document.body.removeChild(we),window.URL.revokeObjectURL(Ge),fe.success(`Downloaded ${_e.length} images as "${je}.zip"!`)}catch(be){console.error("Failed to create ZIP:",be),fe.error("Failed to create download package")}y(!1),re()},le=he=>{u?Q(he.id):r(he)};return e.jsx(Ts,{title:"Social Swag 2.0",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary via-primary/80 to-info p-8 text-primary-foreground",children:[e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4xIj48cGF0aCBkPSJNMzYgMzRjMC0yIDItNCAyLTRzMiAyIDIgNC0yIDQtMiA0LTItMi0yLTR6Ii8+PC9nPjwvZz48L3N2Zz4=')] opacity-30"}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[e.jsxs(rt,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(hn,{className:"h-3 w-3 mr-1"}),"New content monthly"]}),e.jsxs(rt,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(Jo,{className:"h-3 w-3 mr-1"}),k.length," images"]})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-3",children:"Social Swag 📸"}),e.jsx("p",{className:"text-lg text-primary-foreground/90 max-w-2xl",children:"Ready-to-post social media images delivered to you monthly. Just download, copy the caption, and share with your audience!"})]})]}),t?e.jsxs(ka,{defaultValue:"gallery",className:"space-y-6",children:[e.jsxs(_a,{className:"grid w-full max-w-md grid-cols-2",children:[e.jsxs(js,{value:"gallery",className:"gap-2",children:[e.jsx(Jo,{className:"h-4 w-4"}),"Gallery"]}),e.jsxs(js,{value:"scheduled",className:"gap-2",children:[e.jsx(id,{className:"h-4 w-4"}),"Scheduled"]})]}),e.jsxs(zs,{value:"gallery",className:"space-y-6",children:[t?R?e.jsx(Ee,{className:"border rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-muted text-2xl",children:"📸"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-foreground mb-1",children:"Ready to post!"}),e.jsx("p",{className:"text-muted-foreground",children:'Click any image and use "Create Post" to share directly to your connected accounts.'})]}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsx(vo,{to:"/social-connections",children:"Manage Accounts"})})]})})}):e.jsx(Ee,{className:"border-2 border-dashed border-primary/30 bg-gradient-to-r from-pink-500/5 via-purple-500/5 to-blue-500/5 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Hd,{className:"h-5 w-5 text-blue-600"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Wd,{className:"h-5 w-5 text-pink-600"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-foreground mb-1",children:"Post directly to social media"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your Facebook & Instagram accounts to post images with one click!"})]}),e.jsx(K,{asChild:!0,className:"gap-2 bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500 hover:from-pink-600 hover:via-purple-600 hover:to-blue-600",children:e.jsxs(vo,{to:"/social-connections",children:[e.jsx(Wo,{className:"h-4 w-4"}),"Connect Accounts"]})})]})})}):e.jsx(Ee,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(Tn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Hd,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Wd,{className:"h-5 w-5 text-pink-400"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Post directly to social media"}),e.jsx(rt,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Soon you'll be able to connect your Facebook & Instagram accounts to post images with one click!"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(he=>e.jsx("button",{onClick:()=>l(he),className:Pt("px-4 py-2 rounded-full text-sm font-medium transition-all",o===he?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:U(he)},he))}),o!=="all"&&(Y?e.jsxs("a",{href:Y,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",U(o)," Images in Canva"]}):e.jsxs("span",{className:"inline-flex items-center gap-2 text-sm text-muted-foreground/50",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",U(o)," Images in Canva"]}))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-full",children:[e.jsxs("button",{onClick:()=>{b("images"),re()},className:Pt("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",_==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(Jo,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{b("reels"),re()},className:Pt("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",_==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(lu,{className:"h-4 w-4"}),"Reels"]})]}),_==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:u?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:de,className:"gap-2",children:["Select All (",H.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:re,className:"gap-2",children:[e.jsx(Ur,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{size:"sm",onClick:ae,disabled:f,className:"gap-2",children:[e.jsx(xi,{className:"h-4 w-4"}),f?"Downloading...":`Download ${i.size} Selected`]}),e.jsx("span",{className:"text-xs text-muted-foreground hidden sm:inline",children:"Please ensure your browser allows downloads from the LevelUp Dashboard."})]})]}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[e.jsx(ha,{className:"h-4 w-4"}),"Select Images"]})})]}),S&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!S&&_==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:H.map(he=>{const be=i.has(he.id);return e.jsx(Ee,{className:Pt("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&be&&"ring-2 ring-primary ring-offset-2"),onClick:()=>le(he),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:Xme(he.image_url,400,75),alt:"Social swag",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110",loading:"lazy",decoding:"async"}),he.post_date&&!u&&e.jsx("div",{className:"absolute top-0 left-0 w-24 h-24 overflow-hidden pointer-events-none",children:e.jsx("div",{className:"absolute flex items-center justify-center text-white font-bold text-[10px] tracking-wider uppercase",style:{top:"20px",left:"-34px",width:"136px",transform:"rotate(-45deg)",backgroundColor:"#2d5052",padding:"5px 0",boxShadow:"0 2px 4px rgba(0,0,0,0.25)"},children:ys(new Date(he.post_date+"T00:00:00"),"MMM d")})}),u&&e.jsx("div",{className:Pt("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",be?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:be&&e.jsx(ha,{className:"h-4 w-4"})}),!u&&e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})},he.id)})}),H.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Jo,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!S&&_==="reels"&&e.jsx(e.Fragment,{children:$?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:e.jsx(Ee,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a($),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:Xme($.image_url,400,75),alt:"Reel preview",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105",loading:"lazy",decoding:"async"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsxs(rt,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(lu,{className:"h-3 w-3 mr-1"}),"Reel"]})}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(lu,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No reel available for this month yet."})]})})]}),e.jsx(_s,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(vs,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:e.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:s&&e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsx("div",{className:"md:w-1/2 bg-muted",children:e.jsx("div",{className:"aspect-[4/5]",children:e.jsx("img",{src:Xme(s.image_url,900,85),alt:"Social swag",className:"w-full h-full object-cover",decoding:"async"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-muted-foreground mb-4",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(on,{className:"h-4 w-4"}),ys(new Date(s.created_at),"MMMM d, yyyy")]}),s.post_date&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium rounded-full px-3 py-1 text-xs text-white",style:{background:"#406E71"},children:[e.jsx(on,{className:"h-3.5 w-3.5"}),"Post on ",ys(new Date(s.post_date+"T00:00:00"),"MMMM d, yyyy")]})]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.caption})})]}),e.jsxs("div",{className:"flex flex-col gap-3 mt-6",children:[t&&e.jsxs(K,{onClick:()=>{j({imageUrl:s.image_url,imageId:s.id,caption:s.caption})},className:"w-full gap-2 bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500 hover:from-pink-600 hover:via-purple-600 hover:to-blue-600 text-white",children:[e.jsx(aa,{className:"h-4 w-4"}),"Create Post"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(K,{variant:"outline",onClick:()=>se(s.caption),className:"flex-1 gap-2",children:[e.jsx(ai,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(K,{variant:"outline",onClick:()=>te(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(xi,{className:"h-4 w-4"}),"Download"]})]})]})]})]})})})}),e.jsx(_s,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(vs,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:e.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:n&&e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsx("div",{className:"md:w-1/2 bg-black flex items-center justify-center",children:e.jsx("div",{className:"aspect-[9/16] max-h-[70vh]",children:e.jsx("img",{src:n.image_url,alt:"Reel preview",className:"w-full h-full object-contain"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[e.jsx(lu,{className:"h-4 w-4"}),"Monthly Reel"]}),n.caption&&e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:n.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[n.caption&&e.jsxs(K,{onClick:()=>se(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(ai,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(K,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(sn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})}),e.jsx(j8t,{open:!!w,onOpenChange:he=>!he&&j(null),imageUrl:(w==null?void 0:w.imageUrl)||"",imageId:(w==null?void 0:w.imageId)||"",defaultCaption:(w==null?void 0:w.caption)||"",swagItemId:w==null?void 0:w.imageId})]}),e.jsx(zs,{value:"scheduled",children:e.jsx(N8t,{})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(Tn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Hd,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Wd,{className:"h-5 w-5 text-pink-400"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Post directly to social media"}),e.jsx(rt,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Soon you'll be able to connect your Facebook & Instagram accounts to post images with one click!"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(he=>e.jsx("button",{onClick:()=>l(he),className:Pt("px-4 py-2 rounded-full text-sm font-medium transition-all",o===he?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:U(he)},he))}),o!=="all"&&(Y?e.jsxs("a",{href:Y,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",U(o)," Images in Canva"]}):e.jsxs("span",{className:"inline-flex items-center gap-2 text-sm text-muted-foreground/50",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",U(o)," Images in Canva"]}))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-full",children:[e.jsxs("button",{onClick:()=>{b("images"),re()},className:Pt("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",_==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(Jo,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{b("reels"),re()},className:Pt("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",_==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(lu,{className:"h-4 w-4"}),"Reels"]})]}),_==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:u?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:de,className:"gap-2",children:["Select All (",H.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:re,className:"gap-2",children:[e.jsx(Ur,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs(K,{size:"sm",onClick:ae,disabled:f,className:"gap-2",children:[e.jsx(xi,{className:"h-4 w-4"}),f?"Downloading...":`Download ${i.size} Selected`]})]}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[e.jsx(ha,{className:"h-4 w-4"}),"Select Images"]})})]}),S&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!S&&_==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:H.map(he=>{const be=i.has(he.id);return e.jsx(Ee,{className:Pt("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&be&&"ring-2 ring-primary ring-offset-2"),onClick:()=>le(he),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:he.image_url,alt:"Social swag",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110"}),u&&e.jsx("div",{className:Pt("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",be?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:be&&e.jsx(ha,{className:"h-4 w-4"})}),!u&&e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})},he.id)})}),H.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Jo,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!S&&_==="reels"&&e.jsx(e.Fragment,{children:$?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:e.jsx(Ee,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a($),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:$.image_url,alt:"Reel preview",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsxs(rt,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(lu,{className:"h-3 w-3 mr-1"}),"Reel"]})}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(lu,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No reel available for this month yet."})]})})]}),e.jsx(_s,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(vs,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:e.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:s&&e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsx("div",{className:"md:w-1/2 bg-muted",children:e.jsx("div",{className:"aspect-[4/5]",children:e.jsx("img",{src:s.image_url,alt:"Social swag",className:"w-full h-full object-cover"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[e.jsx(on,{className:"h-4 w-4"}),ys(new Date(s.created_at),"MMMM d, yyyy")]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[e.jsxs(K,{variant:"outline",onClick:()=>se(s.caption),className:"flex-1 gap-2",children:[e.jsx(ai,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(K,{variant:"outline",onClick:()=>te(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(xi,{className:"h-4 w-4"}),"Download"]})]})]})]})})})}),e.jsx(_s,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(vs,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:e.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:n&&e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsx("div",{className:"md:w-1/2 bg-black flex items-center justify-center",children:e.jsx("div",{className:"aspect-[9/16] max-h-[70vh]",children:e.jsx("img",{src:n.image_url,alt:"Reel preview",className:"w-full h-full object-contain"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[e.jsx(lu,{className:"h-4 w-4"}),"Monthly Reel"]}),n.caption&&e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:n.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[n.caption&&e.jsxs(K,{onClick:()=>se(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(ai,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(K,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(sn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})})]})]})})},M8t=()=>{const{swagId:t}=ko(),{user:s}=Hs(),{toast:r}=Pa(),n=rs(),{trackEngagement:a}=KL(),[o,l]=C.useState(""),{data:i,isLoading:d}=wt({queryKey:["social-swag-detail",t],queryFn:async()=>{const{data:k,error:S}=await G.from("social_swag").select("*").eq("id",t).single();if(S)throw S;const{data:T}=await G.from("social_swag_links").select("*").eq("swag_id",t).order("sort_order");return{...k,links:T||[]}},enabled:!!t});C.useEffect(()=>{i&&a("social_swag",i.id,i.title,"view")},[i==null?void 0:i.id]);const{data:u=[]}=wt({queryKey:["social-swag-likes",t],queryFn:async()=>{const{data:k,error:S}=await G.from("social_swag_likes").select("*").eq("swag_id",t);if(S)throw S;return k},enabled:!!t}),{data:p=[]}=wt({queryKey:["social-swag-comments",t],queryFn:async()=>{const{data:k,error:S}=await G.from("social_swag_comments").select("*").eq("swag_id",t).order("created_at",{ascending:!1});if(S)throw S;const T=[...new Set(k.map(R=>R.user_id))],{data:I}=await G.from("profiles").select("id, name").in("id",T),L=new Map((I==null?void 0:I.map(R=>[R.id,R.name]))||[]);return k.map(R=>({...R,user_name:L.get(R.user_id)||"Unknown User"}))},enabled:!!t}),f=Dt({mutationFn:async k=>{const{error:S}=await G.from("social_swag_comments").insert({swag_id:t,user_id:s.id,content:k});if(S)throw S},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),l(""),r({title:"Comment added!"})},onError:k=>{r({title:"Error adding comment",description:k.message,variant:"destructive"})}}),y=Dt({mutationFn:async k=>{const{error:S}=await G.from("social_swag_comments").delete().eq("id",k);if(S)throw S},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),r({title:"Comment deleted"})}}),_=Dt({mutationFn:async()=>{const k=u.find(S=>S.user_id===(s==null?void 0:s.id));if(k){const{error:S}=await G.from("social_swag_likes").delete().eq("id",k.id);if(S)throw S}else{const{error:S}=await G.from("social_swag_likes").insert({swag_id:t,user_id:s.id});if(S)throw S}},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-likes",t]})}}),b=u.some(k=>k.user_id===(s==null?void 0:s.id)),w=k=>k.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),j=k=>{k.preventDefault(),!(!o.trim()||!s)&&f.mutate(o.trim())};return d?e.jsx(Ts,{title:"Social Swag",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):i?e.jsx(Ts,{title:i.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(vo,{to:"/social-swag",children:[e.jsx(ti,{className:"h-4 w-4"}),"Back to Social Swag"]})}),i.preview_image_url&&e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:i.preview_image_url,alt:i.title,className:"w-full max-h-[500px] object-contain"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:i.title})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(DM,{resourceType:"social_swag",resourceId:i.id,resourceTitle:i.title}),e.jsxs(K,{variant:b?"default":"outline",className:"gap-2 w-fit",onClick:()=>_.mutate(),disabled:!s||_.isPending,children:[e.jsx(gu,{className:`h-4 w-4 ${b?"fill-current":""}`}),u.length," ",u.length===1?"Like":"Likes"]})]})]}),i.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:i.description}})]}),i.links.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Do,{className:"h-4 w-4"}),i.links.length===1?"Canva Link":"Canva Links"]}),e.jsx("div",{className:"grid gap-2",children:i.links.map(k=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{a("social_swag",i.id,i.title,"click_canva"),window.open(k.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:k.title}),e.jsx(sn,{className:"h-4 w-4 text-muted-foreground"})]},k.id))})]})}),e.jsx(Rl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(xc,{className:"h-5 w-5"}),"Comments (",p.length,")"]}),s?e.jsxs("form",{onSubmit:j,className:"flex gap-2",children:[e.jsx(Ar,{placeholder:"Add a comment...",value:o,onChange:k=>l(k.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!o.trim()||f.isPending,children:e.jsx(aa,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:p.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):p.map(k=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(xn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(yn,{className:"text-sm",children:w(k.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:k.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Sd(new Date(k.created_at),{addSuffix:!0})}),k.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>y.mutate(k.id),children:e.jsx(jr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:k.content})]})]})})},k.id))})]})]})}):e.jsx(Ts,{title:"Social Swag",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Do,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Item not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This item may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(vo,{to:"/social-swag",children:"Back to Social Swag"})})]})})},T8t=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=C.useState(!0),[i,d]=C.useState(!0),[u,p]=C.useState(!0),f=y=>y.split(" ").map(_=>_[0]).join("").toUpperCase().slice(0,2);return e.jsx("aside",{className:"w-64 shrink-0 hidden lg:block relative z-0",children:e.jsx("div",{className:"sticky top-4 space-y-4 max-h-[calc(100vh-8rem)] overflow-y-auto overscroll-contain",children:e.jsxs("div",{className:"space-y-2 pr-4",children:[e.jsxs(K,{variant:r==="all"?"secondary":"ghost",className:"w-full justify-start",onClick:()=>n("all"),children:[e.jsx(x5,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsxs(bf,{open:o,onOpenChange:l,children:[e.jsx(wf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",children:"Categories"}),o?e.jsx(Ho,{className:"h-4 w-4"}):e.jsx(Ua,{className:"h-4 w-4"})]})}),e.jsx(jf,{className:"space-y-1 pl-2",children:t.map(y=>e.jsxs(K,{variant:r===y.id?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(y.id),children:[e.jsx("span",{className:"mr-2",children:y.icon||"📂"}),e.jsx("span",{className:"truncate",children:y.name})]},y.id))})]}),s.length>0&&e.jsxs(bf,{open:i,onOpenChange:d,children:[e.jsx(wf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider flex items-center gap-1",children:[e.jsx($u,{className:"h-3 w-3"}),"Your Groups"]}),i?e.jsx(Ho,{className:"h-4 w-4"}):e.jsx(Ua,{className:"h-4 w-4"})]})}),e.jsx(jf,{className:"space-y-1 pl-2",children:s.map(y=>e.jsxs(K,{variant:r===`group:${y.id}`?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(`group:${y.id}`),children:[e.jsx("span",{className:"mr-2",children:y.icon||"🔒"}),e.jsx("span",{className:"truncate",children:y.name})]},y.id))})]}),e.jsxs(bf,{open:u,onOpenChange:p,children:[e.jsx(wf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider flex items-center gap-1",children:[e.jsx(hr,{className:"h-3 w-3"}),"Online Now",a.length>0&&e.jsx("span",{className:"ml-1 bg-green-500 text-white text-xs rounded-full px-1.5 py-0.5 min-w-[20px] text-center",children:a.length})]}),u?e.jsx(Ho,{className:"h-4 w-4"}):e.jsx(Ua,{className:"h-4 w-4"})]})}),e.jsx(jf,{className:"pl-2 space-y-1",children:a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-2 px-2",children:"No one else online right now"}):a.map(y=>e.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-2 rounded-md hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"relative",children:[e.jsxs(xn,{className:"h-7 w-7",children:[e.jsx(Aa,{src:y.avatarUrl}),e.jsx(yn,{className:"text-xs",children:f(y.name)})]}),e.jsx(Kc,{className:"h-2.5 w-2.5 fill-green-500 text-green-500 absolute -bottom-0.5 -right-0.5"})]}),e.jsx("span",{className:"text-sm truncate",children:y.name})]},y.id))})]})]})})})},A8t=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=C.useState(!1),i=u=>u.split(" ").map(p=>p[0]).join("").toUpperCase().slice(0,2),d=()=>{if(r==="all")return"All Posts";if(r.startsWith("group:")){const p=r.replace("group:",""),f=s.find(y=>y.id===p);return f?`🔒 ${f.name}`:"Private Group"}const u=t.find(p=>p.id===r);return u?`${u.icon||"📂"} ${u.name}`:"Category"};return e.jsxs("div",{className:"lg:hidden flex items-center gap-2 mb-4",children:[e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"flex-1 justify-between",children:[e.jsx("span",{className:"truncate",children:d()}),e.jsx(Ho,{className:"h-4 w-4 ml-2 shrink-0"})]})}),e.jsxs(Md,{className:"w-56 bg-background border",children:[e.jsxs(Na,{onClick:()=>n("all"),children:[e.jsx(x5,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsx(E_,{}),e.jsx(Dge,{className:"text-xs text-muted-foreground",children:"Categories"}),t.map(u=>e.jsxs(Na,{onClick:()=>n(u.id),children:[e.jsx("span",{className:"mr-2",children:u.icon||"📂"}),u.name]},u.id)),s.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(E_,{}),e.jsxs(Dge,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx($u,{className:"h-3 w-3"}),"Your Groups"]}),s.map(u=>e.jsxs(Na,{onClick:()=>n(`group:${u.id}`),children:[e.jsx("span",{className:"mr-2",children:u.icon||"🔒"}),u.name]},u.id))]})]})]}),e.jsxs(MM,{open:o,onOpenChange:l,children:[e.jsx(K_e,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(hr,{className:"h-4 w-4"}),a.length>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-green-500 text-white text-xs rounded-full h-4 w-4 flex items-center justify-center",children:a.length})]})}),e.jsxs(cS,{children:[e.jsx(TM,{children:e.jsxs(AM,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Online Now (",a.length,")"]})}),e.jsx(Ri,{className:"h-[calc(100vh-8rem)] mt-4",children:a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No one else online right now"}):e.jsx("div",{className:"space-y-2",children:a.map(u=>e.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"relative",children:[e.jsxs(xn,{className:"h-10 w-10",children:[e.jsx(Aa,{src:u.avatarUrl}),e.jsx(yn,{children:i(u.name)})]}),e.jsx(Kc,{className:"h-3 w-3 fill-green-500 text-green-500 absolute -bottom-0.5 -right-0.5"})]}),e.jsx("span",{className:"font-medium",children:u.name})]},u.id))})})]})]})]})};var Qme,Dle="HoverCard",[NKe]=Ec(Dle,[xy]),Ole=xy(),[E8t,vwe]=NKe(Dle),kKe=t=>{const{__scopeHoverCard:s,children:r,open:n,defaultOpen:a,onOpenChange:o,openDelay:l=700,closeDelay:i=300}=t,d=Ole(s),u=C.useRef(0),p=C.useRef(0),f=C.useRef(!1),y=C.useRef(!1),[_,b]=vu({prop:n,defaultProp:a??!1,onChange:o,caller:Dle}),w=C.useCallback(()=>{clearTimeout(p.current),u.current=window.setTimeout(()=>b(!0),l)},[l,b]),j=C.useCallback(()=>{clearTimeout(u.current),!f.current&&!y.current&&(p.current=window.setTimeout(()=>b(!1),i))},[i,b]),k=C.useCallback(()=>b(!1),[b]);return C.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(p.current)},[]),e.jsx(E8t,{scope:s,open:_,onOpenChange:b,onOpen:w,onClose:j,onDismiss:k,hasSelectionRef:f,isPointerDownOnContentRef:y,children:e.jsx(jL,{...d,children:r})})};kKe.displayName=Dle;var SKe="HoverCardTrigger",CKe=C.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=vwe(SKe,r),o=Ole(r);return e.jsx(gM,{asChild:!0,...o,children:e.jsx(Qr.a,{"data-state":a.open?"open":"closed",...n,ref:s,onPointerEnter:Mr(t.onPointerEnter,zae(a.onOpen)),onPointerLeave:Mr(t.onPointerLeave,zae(a.onClose)),onFocus:Mr(t.onFocus,a.onOpen),onBlur:Mr(t.onBlur,a.onClose),onTouchStart:Mr(t.onTouchStart,l=>l.preventDefault())})})});CKe.displayName=SKe;var P8t="HoverCardPortal",[$_s,I8t]=NKe(P8t,{forceMount:void 0}),Fae="HoverCardContent",MKe=C.forwardRef((t,s)=>{const r=I8t(Fae,t.__scopeHoverCard),{forceMount:n=r.forceMount,...a}=t,o=vwe(Fae,t.__scopeHoverCard);return e.jsx(ud,{present:n||o.open,children:e.jsx(L8t,{"data-state":o.open?"open":"closed",...a,onPointerEnter:Mr(t.onPointerEnter,zae(o.onOpen)),onPointerLeave:Mr(t.onPointerLeave,zae(o.onClose)),ref:s})})});MKe.displayName=Fae;var L8t=C.forwardRef((t,s)=>{const{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,...i}=t,d=vwe(Fae,r),u=Ole(r),p=C.useRef(null),f=Ea(s,p),[y,_]=C.useState(!1);return C.useEffect(()=>{if(y){const b=document.body;return Qme=b.style.userSelect||b.style.webkitUserSelect,b.style.userSelect="none",b.style.webkitUserSelect="none",()=>{b.style.userSelect=Qme,b.style.webkitUserSelect=Qme}}},[y]),C.useEffect(()=>{if(p.current){const b=()=>{_(!1),d.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var j;((j=document.getSelection())==null?void 0:j.toString())!==""&&(d.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",b),()=>{document.removeEventListener("pointerup",b),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!1}}},[d.isPointerDownOnContentRef,d.hasSelectionRef]),C.useEffect(()=>{p.current&&R8t(p.current).forEach(w=>w.setAttribute("tabindex","-1"))}),e.jsx(q_,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:Mr(o,b=>{b.preventDefault()}),onDismiss:d.onDismiss,children:e.jsx(NL,{...u,...i,onPointerDown:Mr(i.onPointerDown,b=>{b.currentTarget.contains(b.target)&&_(!0),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!0}),ref:f,style:{...i.style,userSelect:y?"text":void 0,WebkitUserSelect:y?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),D8t="HoverCardArrow",O8t=C.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=Ole(r);return e.jsx(kL,{...a,...n,ref:s})});O8t.displayName=D8t;function zae(t){return s=>s.pointerType==="touch"?void 0:t()}function R8t(t){const s=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;r.nextNode();)s.push(r.currentNode);return s}var F8t=kKe,z8t=CKe,TKe=MKe;const B8t=F8t,$8t=z8t,AKe=C.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(TKe,{ref:a,align:s,sideOffset:r,className:Pt("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n}));AKe.displayName=TKe.displayName;const q8t=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"},{type:"laugh",emoji:"😂",label:"Haha"},{type:"wow",emoji:"😮",label:"Wow"},{type:"sad",emoji:"😢",label:"Sad"},{type:"angry",emoji:"😠",label:"Angry"}],U8t=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2),EKe=({reactions:t,children:s})=>{if(t.length===0)return e.jsx(e.Fragment,{children:s});const r={};return t.forEach(n=>{r[n.reaction_type]||(r[n.reaction_type]=[]),r[n.reaction_type].push(n)}),e.jsxs(B8t,{openDelay:200,closeDelay:100,children:[e.jsx($8t,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:s})}),e.jsx(AKe,{className:"w-64 p-3 bg-popover border shadow-lg z-50",side:"top",align:"start",children:e.jsx("div",{className:"space-y-3",children:Object.entries(r).map(([n,a])=>{const o=q8t.find(l=>l.type===n);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-lg",children:o==null?void 0:o.emoji}),e.jsxs("span",{className:"text-sm font-medium text-foreground",children:[o==null?void 0:o.label," (",a.length,")"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[a.slice(0,10).map(l=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(xn,{className:"h-6 w-6",children:[e.jsx(Aa,{src:l.user_avatar||void 0}),e.jsx(yn,{className:"text-[10px]",children:U8t(l.user_name||"U")})]}),e.jsx("span",{className:"text-sm text-foreground truncate",children:l.user_name||"Unknown User"})]},l.id)),a.length>10&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",a.length-10," more"]})]})]},n)})})})]})};function V8t({images:t,initialIndex:s=0,open:r,onOpenChange:n}){const[a,o]=C.useState(s),[l,i]=C.useState(!1);C.useEffect(()=>{r&&(o(s),i(!1))},[r,s]);const d=()=>{o(y=>y>0?y-1:t.length-1),i(!1)},u=()=>{o(y=>y{r&&(y.key==="ArrowLeft"&&d(),y.key==="ArrowRight"&&u(),y.key==="Escape"&&n(!1))},[r,t.length]);C.useEffect(()=>(window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)),[p]);const f=t[a];return e.jsx(_s,{open:r,onOpenChange:n,children:e.jsxs(vs,{className:"max-w-[95vw] max-h-[95vh] w-auto h-auto p-0 border-none bg-black/95 overflow-hidden",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute top-2 right-2 z-50 text-white hover:bg-white/20 h-10 w-10",onClick:()=>n(!1),children:e.jsx(Ur,{className:"h-6 w-6"})}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 z-50 text-white hover:bg-white/20 h-12 w-12",onClick:d,children:e.jsx(zl,{className:"h-8 w-8"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 z-50 text-white hover:bg-white/20 h-12 w-12",onClick:u,children:e.jsx(Ua,{className:"h-8 w-8"})})]}),t.length>1&&e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-50 text-white text-sm bg-black/50 px-3 py-1 rounded-full",children:[a+1," / ",t.length]}),(f==null?void 0:f.type)==="image"&&e.jsx(K,{variant:"ghost",size:"icon",className:"absolute top-2 left-2 z-50 text-white hover:bg-white/20 h-10 w-10",onClick:()=>i(!l),children:l?e.jsx(E5,{className:"h-5 w-5"}):e.jsx(f_,{className:"h-5 w-5"})}),e.jsx("div",{className:Pt("flex items-center justify-center w-full h-full min-h-[50vh] p-4",l?"cursor-zoom-out overflow-auto":"cursor-zoom-in"),onClick:()=>(f==null?void 0:f.type)==="image"&&i(!l),children:(f==null?void 0:f.type)==="video"?e.jsx("video",{src:f.url,controls:!0,autoPlay:!0,className:"max-w-full max-h-[85vh] object-contain",onClick:y=>y.stopPropagation()}):e.jsx("img",{src:f==null?void 0:f.url,alt:"",className:Pt("object-contain transition-transform duration-200",l?"max-w-none max-h-none scale-150":"max-w-full max-h-[85vh]")})}),t.length>1&&e.jsx("div",{className:"absolute bottom-12 left-1/2 -translate-x-1/2 z-50 flex gap-2 bg-black/50 p-2 rounded-lg max-w-[90vw] overflow-x-auto",children:t.map((y,_)=>e.jsx("button",{onClick:()=>{o(_),i(!1)},className:Pt("w-12 h-12 rounded overflow-hidden flex-shrink-0 border-2 transition-all",a===_?"border-white":"border-transparent opacity-60 hover:opacity-100"),children:y.type==="video"?e.jsx("video",{src:y.url,className:"w-full h-full object-cover"}):e.jsx("img",{src:y.url,alt:"",className:"w-full h-full object-cover"})},_))})]})})}const gR=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"}],H8t=({commentId:t,reactions:s,currentUserId:r})=>{var u,p;const n=rs(),[a,o]=C.useState(!1),l=s.find(f=>f.user_id===r),i=Dt({mutationFn:async f=>{l?l.reaction_type===f?await G.from("community_comment_reactions").delete().eq("id",l.id):await G.from("community_comment_reactions").update({reaction_type:f}).eq("id",l.id):await G.from("community_comment_reactions").insert({comment_id:t,user_id:r,reaction_type:f})},onSuccess:()=>{n.invalidateQueries({queryKey:["community-posts"]}),o(!1)}}),d={};return s.forEach(f=>{d[f.reaction_type]=(d[f.reaction_type]||0)+1}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.length>0&&e.jsx(EKe,{reactions:s,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("div",{className:"flex -space-x-0.5",children:Object.keys(d).slice(0,2).map(f=>{var y;return e.jsx("span",{className:"text-sm",children:(y=gR.find(_=>_.type===f))==null?void 0:y.emoji},f)})}),e.jsx("span",{children:s.length})]})}),r&&e.jsxs(Co,{open:a,onOpenChange:o,children:[e.jsx(Mo,{asChild:!0,children:e.jsx("button",{className:`text-xs hover:text-primary transition-colors ${l?"text-primary font-medium":"text-muted-foreground"}`,children:l?e.jsxs("span",{children:[(u=gR.find(f=>f.type===l.reaction_type))==null?void 0:u.emoji," ",(p=gR.find(f=>f.type===l.reaction_type))==null?void 0:p.label]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Si,{className:"h-3 w-3"}),"Like"]})})}),e.jsx(No,{className:"w-auto p-1.5 bg-popover border shadow-lg z-50",side:"top",children:e.jsx("div",{className:"flex gap-0.5",children:gR.map(f=>e.jsx("button",{onClick:()=>i.mutate(f.type),className:"text-xl hover:scale-125 transition-transform p-1",title:f.label,children:f.emoji},f.type))})})]})]})};function _we({content:t,className:s}){const r=/([@#])\[([^\]]+)\]\(([^)]+)\)|(https?:\/\/[^\s<>]+)/g,n=[];let a=0,o,l=0;for(;(o=r.exec(t))!==null;){if(o.index>a&&n.push(t.substring(a,o.index)),o[1]){const i=o[1],d=o[2],u=o[3],p=i==="#";n.push(e.jsx(vo,{to:p?`/templates/${u}`:`/profile?user=${u}`,className:Pt("font-medium hover:underline",p?"text-white bg-[#2a4c64] px-1.5 py-0.5 rounded":"text-primary"),onClick:f=>f.stopPropagation(),children:p?d:`@${d}`},`mention-${l++}`))}else if(o[4]){const i=o[4],d=i.replace(/[.,;:!?)]+$/,""),u=i.slice(d.length);let p;try{const f=new URL(d);p=f.hostname+(f.pathname!=="/"?f.pathname.slice(0,20)+(f.pathname.length>20?"...":""):"")}catch{p=d.length>40?d.slice(0,40)+"...":d}n.push(e.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline break-all",onClick:f=>f.stopPropagation(),children:p},`url-${l++}`)),u&&n.push(u)}a=o.index+o[0].length}return ae.jsx(C.Fragment,{children:i},d))})}function Bae({value:t,onChange:s,placeholder:r="What's on your mind? Use @ to mention someone",className:n,minHeight:a="80px",onMentionsChange:o,onTemplatesChange:l,onKeyDown:i,mentionFormat:d="encoded",enableTemplateMentions:u=!1}){const p=C.useRef(null),f=C.useRef(null),[y,_]=C.useState(!1),[b,w]=C.useState("user"),[j,k]=C.useState(""),[S,T]=C.useState(null),[I,L]=C.useState(0),[R,$]=C.useState({top:0,left:0,width:0}),q=C.useRef(new Map),U=C.useRef(new Map),H=je=>{if(d==="plain"){const Me=[];return q.current.forEach((Fe,Ae)=>{je.includes(`@${Ae}`)&&Me.push(Fe)}),[...new Set(Me)]}const Ne=/@\[([^\]]+)\]\(([^)]+)\)/g,Ge=[];let we;for(;(we=Ne.exec(je))!==null;)Ge.push(we[2]);return[...new Set(Ge)]},Y=je=>{if(d==="plain"){const Me=[];return U.current.forEach((Fe,Ae)=>{je.includes(`#${Ae}`)&&Me.push(Fe)}),[...new Set(Me)]}const Ne=/#\[([^\]]+)\]\(([^)]+)\)/g,Ge=[];let we;for(;(we=Ne.exec(je))!==null;)Ge.push(we[2]);return[...new Set(Ge)]};C.useEffect(()=>{if(o){const je=H(t);o(je)}if(l){const je=Y(t);l(je)}},[t,o,l,d]);const{data:se=[],isLoading:te}=wt({queryKey:["mention-users",j],queryFn:async()=>{const je=G.from("profiles").select("id, name").limit(8),Ne=j.length>=1?je.ilike("name",`%${j}%`):je.order("name"),{data:Ge,error:we}=await Ne;if(we)throw we;const Me=Ge.map(Fe=>Fe.id),Te=await uUe(Me);return Ge.map(Fe=>({id:Fe.id,name:Fe.name||"Unknown",avatar_url:Te.get(Fe.id)}))},enabled:y&&b==="user",staleTime:3e4}),{data:Q=[],isLoading:de}=wt({queryKey:["mention-templates",j],queryFn:async()=>{let je=G.from("canva_templates").select("id, name, preview_image_url").lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(8);j.length>=1&&(je=je.ilike("name",`%${j}%`));const{data:Ne,error:Ge}=await je;if(Ge)throw Ge;return Ne||[]},enabled:y&&b==="template"&&u,staleTime:3e4}),re=b==="user"?te:de,ae=b==="user"?se:Q,le=je=>je.split(" ").map(Ne=>Ne[0]).join("").toUpperCase().slice(0,2),he=je=>{const Ne=je.target.value,Ge=je.target.selectionStart;s(Ne);const we=Ne.substring(0,Ge),Me=we.lastIndexOf("@"),Te=u?we.lastIndexOf("#"):-1;let Fe=-1,Ae="user";if(Me>Te?(Fe=Me,Ae="user"):Te>Me&&u&&(Fe=Te,Ae="template"),Fe!==-1){const Ue=we.substring(Fe+1),ut=Ue.includes(" "),De=Ue.includes(` `);if(!ut&&!De&&Ue.length<=30){T(Fe),k(Ue),w(Ae),_(!0),L(0);return}}_(!1),T(null)},be=je=>{if(S===null)return;const Ne=t.substring(0,S),Ge=t.substring(S+j.length+1),we=b==="user"?"@":"#",Me=d==="plain"?`${we}${je.name} `:`${we}[${je.name}](${je.id}) `;d==="plain"&&(b==="user"?q.current.set(je.name,je.id):U.current.set(je.name,je.id));const Te=Ne+Me+Ge;s(Te),_(!1),T(null),k(""),setTimeout(()=>{if(p.current){const Fe=Ne.length+Me.length;p.current.focus(),p.current.setSelectionRange(Fe,Fe)}},0)},_e=je=>{if(!(!y||ae.length===0))switch(je.key){case"ArrowDown":je.preventDefault(),L(Ne=>(Ne+1)%ae.length);break;case"ArrowUp":je.preventDefault(),L(Ne=>(Ne-1+ae.length)%ae.length);break;case"Enter":ae[I]&&(je.preventDefault(),be(ae[I]));break;case"Escape":je.preventDefault(),_(!1);break;case"Tab":ae[I]&&(je.preventDefault(),be(ae[I]));break}};return C.useEffect(()=>{const je=Ne=>{f.current&&!f.current.contains(Ne.target)&&p.current&&!p.current.contains(Ne.target)&&_(!1)};return document.addEventListener("mousedown",je),()=>document.removeEventListener("mousedown",je)},[]),C.useEffect(()=>{if(!y)return;const je=()=>{const Ne=p.current;if(!Ne)return;const Ge=Ne.getBoundingClientRect();$({top:Ge.bottom+4,left:Ge.left,width:Ge.width})};return je(),window.addEventListener("resize",je),window.addEventListener("scroll",je,!0),()=>{window.removeEventListener("resize",je),window.removeEventListener("scroll",je,!0)}},[y,t]),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ar,{ref:p,value:t,onChange:he,onKeyDown:je=>{_e(je),je.defaultPrevented||i==null||i(je)},placeholder:r,className:Pt("resize-none",n),style:{minHeight:a}}),y&&km.createPortal(e.jsxs("div",{ref:f,className:"fixed z-[1000] max-h-[220px] overflow-hidden rounded-lg border bg-popover shadow-lg",style:{top:R.top,left:R.left,width:R.width,maxWidth:"320px"},children:[e.jsx("div",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground border-b bg-muted/30",children:b==="user"?"👤 Mention a person":"📋 Link a template"}),re?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Searching..."}):ae.length===0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:j.length<1?`Type to search ${b==="user"?"people":"templates"}...`:`No ${b==="user"?"users":"templates"} found`}):e.jsx("ul",{className:"py-1 max-h-[180px] overflow-y-auto",children:ae.map((je,Ne)=>e.jsx("li",{className:Pt("flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors",Ne===I?"bg-accent":"hover:bg-accent/50"),onClick:()=>be(je),onMouseEnter:()=>L(Ne),children:b==="user"?e.jsxs(e.Fragment,{children:[e.jsxs(xn,{className:"h-6 w-6",children:[e.jsx(Aa,{src:je.avatar_url}),e.jsx(yn,{className:"text-xs",children:le(je.name)})]}),e.jsx("span",{className:"text-sm font-medium truncate",children:je.name})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-8 w-8 rounded bg-muted flex items-center justify-center overflow-hidden flex-shrink-0",children:je.preview_image_url?e.jsx("img",{src:je.preview_image_url,alt:"",className:"w-full h-full object-cover"}):e.jsx(Bl,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate",children:je.name})]})},je.id))})]}),document.body)]})}function W8t(t){const s=/#\[([^\]]+)\]\(([^)]+)\)/g,r=[];let n;for(;(n=s.exec(t))!==null;)r.push(n[2]);return[...new Set(r)]}const KAe=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2);function PKe({comment:t,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l=0}){const i=rs(),[d,u]=C.useState(!1),[p,f]=C.useState(""),[y,_]=C.useState([]),b=Dt({mutationFn:async({content:S,parentCommentId:T})=>{const{data:I,error:L}=await G.from("community_comments").insert({post_id:s,user_id:r,content:S,parent_comment_id:T}).select("id").single();if(L)throw L;const R=y;if(R.length>0&&I){const $=R.filter(q=>q!==r).map(q=>({comment_id:I.id,mentioned_user_id:q,mentioned_by_user_id:r}));$.length>0&&await G.from("community_comment_mentions").insert($)}},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),f(""),_([]),u(!1)}}),w=Dt({mutationFn:async S=>{const{error:T}=await G.from("community_comments").delete().eq("id",S);if(T)throw T},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),j=()=>{p.trim()&&b.mutate({content:p,parentCommentId:t.id})};return e.jsxs("div",{className:l>0?"ml-8 border-l-2 border-muted pl-3":"",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(xn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Aa,{src:t.user_avatar||void 0}),e.jsx(yn,{className:"text-xs",children:KAe(t.user_name||"U")})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"bg-muted rounded-lg px-3 py-2",children:[e.jsx("div",{className:"font-medium text-sm",children:t.user_name}),e.jsx(_we,{content:t.content,className:"text-sm break-words"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground flex-wrap",children:[e.jsx("span",{children:Sd(new Date(t.created_at),{addSuffix:!0})}),e.jsx(H8t,{commentId:t.id,reactions:t.reactions,currentUserId:r}),r&&l<2&&e.jsxs("button",{onClick:()=>u(!d),className:"hover:text-primary flex items-center gap-1",children:[e.jsx(PP,{className:"h-3 w-3"}),"Reply"]}),(t.user_id===r||o)&&e.jsx("button",{onClick:()=>w.mutate(t.id),className:"hover:text-destructive",children:t.user_id!==r?"Remove":"Delete"})]}),d&&r&&e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(xn,{className:"h-6 w-6 shrink-0 mt-1",children:[e.jsx(Aa,{src:n||void 0}),e.jsx(yn,{className:"text-xs",children:KAe((a==null?void 0:a.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2 items-start",children:[e.jsx(Bae,{placeholder:`Reply to ${t.user_name}...`,value:p,onChange:f,onMentionsChange:_,mentionFormat:"plain",className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:j,disabled:!p.trim()||b.isPending,className:"h-8 px-2 mt-0.5",children:e.jsx(aa,{className:"h-3 w-3"})})]})]})]})]}),t.replies&&t.replies.length>0&&e.jsx("div",{className:"mt-2 space-y-2",children:t.replies.map(S=>e.jsx(PKe,{comment:S,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l+1},S.id))})]})}const xR=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"},{type:"laugh",emoji:"😂",label:"Haha"},{type:"wow",emoji:"😮",label:"Wow"},{type:"sad",emoji:"😢",label:"Sad"},{type:"angry",emoji:"😠",label:"Angry"}],G8t=()=>{const{user:t,isBrokerageManager:s,managedBrokerages:r,isAdmin:n}=Hs(),{avatarUrl:a}=dUe(t==null?void 0:t.id),{onlineUsers:o}=hVe(),{toast:l}=Pa(),i=rs(),d=C.useRef(null),[u,p]=C.useState("all"),[f,y]=C.useState(""),[_,b]=C.useState(""),[w,j]=C.useState(""),[k,S]=C.useState([]),[T,I]=C.useState([]),[L,R]=C.useState(""),[$,q]=C.useState(!1),[U,H]=C.useState(null),[Y,se]=C.useState(""),[te,Q]=C.useState(new Set),[de,re]=C.useState({}),[ae,le]=C.useState({}),[he,be]=C.useState([]),[_e,je]=C.useState([]),[Ne,Ge]=C.useState({open:!1,images:[],index:0});C.useEffect(()=>{if(u.startsWith("group:")){const et=u.replace("group:","");j(et),b("")}else u!=="all"?(b(u),j("")):(b(""),j(""))},[u]);const{data:we=[]}=wt({queryKey:["community-categories"],queryFn:async()=>{const{data:et,error:Tt}=await G.from("community_categories").select("*").order("sort_order");if(Tt)throw Tt;return et}}),{data:Me=[]}=wt({queryKey:["community-private-groups"],queryFn:async()=>{const{data:et,error:Tt}=await G.from("community_private_groups").select("id, name, description, icon, brokerage_id, sort_order").order("sort_order");if(Tt)throw Tt;return et}}),Te=20,{data:Fe,isLoading:Ae,hasNextPage:Ue,fetchNextPage:ut,isFetchingNextPage:De}=Eut({queryKey:["community-posts",u],initialPageParam:0,queryFn:async({pageParam:et})=>{var ze;const Tt=et*Te,Ft=Tt+Te;let as=G.from("community_posts").select("*").order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(Tt,Ft);if(u.startsWith("group:")){const Je=u.replace("group:","");as=as.eq("private_group_id",Je)}else u==="all"||(as=as.eq("category_id",u).is("private_group_id",null));const{data:Xt,error:ss}=await as;if(ss)throw ss;const is=((Xt==null?void 0:Xt.length)||0)>Te,ar=(Xt||[]).slice(0,Te);if(ar.length===0)return{posts:[],hasMore:!1,nextPage:et+1};const Ct=ar.map(Je=>Je.id),Is=[...new Set(ar.filter(Je=>Je.category_id).map(Je=>Je.category_id))].filter(Boolean),[qs,gr,Wn,ii,bo]=await Promise.all([Is.length?G.from("community_categories").select("*").in("id",Is):Promise.resolve({data:[]}),G.from("community_post_media").select("*").in("post_id",Ct).order("sort_order"),G.from("community_reactions").select("*").in("post_id",Ct),G.from("community_comments").select("*").in("post_id",Ct).order("created_at",{ascending:!0}),G.from("community_post_resources").select("*").in("post_id",Ct)]),si=qs==null?void 0:qs.data,nn=gr==null?void 0:gr.data,ia=Wn==null?void 0:Wn.data,kn=ii==null?void 0:ii.data,sa=bo==null?void 0:bo.data,Zt=(kn||[]).map(Je=>Je.id),[$r,es]=await Promise.all([Zt.length?G.from("community_comment_reactions").select("*").in("comment_id",Zt):Promise.resolve({data:[]}),(()=>{const Je=(sa||[]).filter(St=>St.resource_type==="template").map(St=>St.resource_id);return Je.length===0?Promise.resolve({data:[]}):G.from("canva_templates").select("id, name, preview_image_url").in("id",Je)})()]),an=($r==null?void 0:$r.data)||[],Ra=(es==null?void 0:es.data)||[],Zn=new Map(Ra.map(Je=>[Je.id,{name:Je.name,preview_image_url:Je.preview_image_url}])),Ir=Array.from(new Set([...ar.map(Je=>Je.user_id),...(ia||[]).map(Je=>Je.user_id),...(kn||[]).map(Je=>Je.user_id),...an.map(Je=>Je.user_id)])),[mi,Go]=await Promise.all([Ir.length?G.from("profiles").select("id, name").in("id",Ir):Promise.resolve({data:[]}),uUe(Ir)]),yi=new Map(((ze=mi==null?void 0:mi.data)==null?void 0:ze.map(Je=>[Je.id,Je.name]))||[]),Vl=new Map((si||[]).map(Je=>[Je.id,Je])),Vt=Je=>{const St=new Map,Nt=[];return Je.forEach(Bt=>{St.set(Bt.id,{...Bt,user_name:yi.get(Bt.user_id)||"Unknown User",user_avatar:Go.get(Bt.user_id),reactions:an.filter(Kt=>Kt.comment_id===Bt.id).map(Kt=>({...Kt,user_name:yi.get(Kt.user_id)||"Unknown User",user_avatar:Go.get(Kt.user_id)})),replies:[]})}),Je.forEach(Bt=>{const Kt=St.get(Bt.id);if(Bt.parent_comment_id&&St.has(Bt.parent_comment_id)){const qt=St.get(Bt.parent_comment_id);qt.replies=qt.replies||[],qt.replies.push(Kt)}else Nt.push(Kt)}),Nt};return{posts:ar.map(Je=>{const St=(sa||[]).filter(Nt=>Nt.post_id===Je.id).map(Nt=>{let Bt="",Kt=null;if(Nt.resource_type==="template"){const qt=Zn.get(Nt.resource_id);Bt=(qt==null?void 0:qt.name)||"Unknown Template",Kt=(qt==null?void 0:qt.preview_image_url)||null}return{id:Nt.id,resource_type:Nt.resource_type,resource_id:Nt.resource_id,resource_name:Bt,resource_preview_url:Kt}});return{...Je,user_name:yi.get(Je.user_id)||"Unknown User",user_avatar:Go.get(Je.user_id),category:Je.category_id?Vl.get(Je.category_id):null,media:(nn||[]).filter(Nt=>Nt.post_id===Je.id),reactions:((ia||[]).filter(Nt=>Nt.post_id===Je.id)||[]).map(Nt=>({...Nt,user_name:yi.get(Nt.user_id)||"Unknown User",user_avatar:Go.get(Nt.user_id)})),comments:Vt((kn||[]).filter(Nt=>Nt.post_id===Je.id)),resources:St}}),hasMore:is,nextPage:et+1}},getNextPageParam:et=>et.hasMore?et.nextPage:void 0}),Rt=C.useMemo(()=>(Fe==null?void 0:Fe.pages.flatMap(et=>et.posts))??[],[Fe]),me=Dt({mutationFn:async()=>{q(!0);const{data:et,error:Tt}=await G.from("community_posts").insert({user_id:t.id,category_id:w?null:_||null,private_group_id:w||null,content:f,link_url:L||null}).select().single();if(Tt)throw Tt;for(let as=0;as0){const as=he.filter(Xt=>Xt!==t.id).map(Xt=>({post_id:et.id,mentioned_user_id:Xt,mentioned_by_user_id:t.id}));as.length>0&&await G.from("community_post_mentions").insert(as)}const Ft=W8t(f);if(Ft.length>0){const as=Ft.map(Xt=>({post_id:et.id,resource_type:"template",resource_id:Xt}));await G.from("community_post_resources").insert(as)}return et},onSuccess:async et=>{var Tt;i.invalidateQueries({queryKey:["community-posts"]}),y(""),be([]),je([]),b(""),j(""),S([]),I([]),R(""),l({title:"Post created!"});try{const Ft=((Tt=t==null?void 0:t.user_metadata)==null?void 0:Tt.name)||"Someone",as=f.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),Xt=as.length>50?as.substring(0,50)+"...":as;await G.functions.invoke("send-push-notification",{body:{title:"New Community Post",body:`${Ft}: ${Xt}`,url:"/community"}})}catch(Ft){console.error("Failed to send push notification:",Ft)}},onError:et=>{l({title:"Error creating post",description:et.message,variant:"destructive"})},onSettled:()=>q(!1)}),Xe=Dt({mutationFn:async({postId:et,content:Tt})=>{const{error:Ft}=await G.from("community_posts").update({content:Tt}).eq("id",et);if(Ft)throw Ft},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),H(null),se(""),l({title:"Post updated!"})}}),ot=Dt({mutationFn:async et=>{const{error:Tt}=await G.from("community_posts").delete().eq("id",et);if(Tt)throw Tt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:"Post deleted"})}}),nt=Dt({mutationFn:async({postId:et,isPinned:Tt})=>{const{error:Ft}=await G.from("community_posts").update({is_pinned:!Tt,pinned_at:Tt?null:new Date().toISOString(),pinned_by:Tt?null:t==null?void 0:t.id}).eq("id",et);if(Ft)throw Ft},onSuccess:(et,{isPinned:Tt})=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:Tt?"Post unpinned":"Post pinned to top"})}}),Se=Dt({mutationFn:async({postId:et,reactionType:Tt})=>{var as;const Ft=(as=Rt.find(Xt=>Xt.id===et))==null?void 0:as.reactions.find(Xt=>Xt.user_id===(t==null?void 0:t.id));Ft?Ft.reaction_type===Tt?await G.from("community_reactions").delete().eq("id",Ft.id):await G.from("community_reactions").update({reaction_type:Tt}).eq("id",Ft.id):await G.from("community_reactions").insert({post_id:et,user_id:t.id,reaction_type:Tt})},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),it=Dt({mutationFn:async({postId:et,content:Tt})=>{const{data:Ft,error:as}=await G.from("community_comments").insert({post_id:et,user_id:t.id,content:Tt}).select("id").single();if(as)throw as;const Xt=ae[et]||[];if(Xt.length>0&&Ft){const ss=Xt.filter(is=>is!==t.id).map(is=>({comment_id:Ft.id,mentioned_user_id:is,mentioned_by_user_id:t.id}));ss.length>0&&await G.from("community_comment_mentions").insert(ss)}},onSuccess:(et,{postId:Tt})=>{i.invalidateQueries({queryKey:["community-posts"]}),re(Ft=>({...Ft,[Tt]:""})),le(Ft=>({...Ft,[Tt]:[]}))}});Dt({mutationFn:async et=>{const{error:Tt}=await G.from("community_comments").delete().eq("id",et);if(Tt)throw Tt},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})});const $e=et=>{const Tt=Array.from(et.target.files||[]);if(Tt.length+k.length>10){l({title:"Maximum 10 files allowed",variant:"destructive"});return}S(Ft=>[...Ft,...Tt]),Tt.forEach(Ft=>{const as=new FileReader;as.onloadend=()=>{I(Xt=>[...Xt,as.result])},as.readAsDataURL(Ft)})},ct=et=>{S(Tt=>Tt.filter((Ft,as)=>as!==et)),I(Tt=>Tt.filter((Ft,as)=>as!==et))},qe=et=>et.split(" ").map(Tt=>Tt[0]).join("").toUpperCase().slice(0,2),Ze=et=>{const Tt={};return et.forEach(Ft=>{Tt[Ft.reaction_type]=(Tt[Ft.reaction_type]||0)+1}),Tt},Qe=et=>{var Tt;return(Tt=et.find(Ft=>Ft.user_id===(t==null?void 0:t.id)))==null?void 0:Tt.reaction_type},We=et=>et.reduce((Tt,Ft)=>Tt+1+(Ft.replies?We(Ft.replies):0),0),He=et=>{if(n)return!0;if(!s||!et.private_group_id)return!1;const Tt=Me.find(Ft=>Ft.id===et.private_group_id);return Tt!=null&&Tt.brokerage_id?r.some(Ft=>Ft.id===Tt.brokerage_id):!1};return e.jsx(Ts,{title:"Community",children:e.jsxs("div",{className:"flex gap-6 w-full isolate z-0",children:[e.jsx(T8t,{categories:we,privateGroups:Me,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsxs("div",{className:"flex-1 min-w-0 max-w-2xl mx-auto lg:mx-0 space-y-6",children:[e.jsxs("div",{className:"px-1",children:[e.jsx("h1",{className:"text-4xl lg:text-5xl font-bold text-foreground",children:"Community"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Connect and share with fellow agents"})]}),e.jsx(A8t,{categories:we,privateGroups:Me,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(xn,{className:"h-10 w-10",children:[e.jsx(Aa,{src:a||void 0}),e.jsx(yn,{children:t!=null&&t.email?qe(t.email.split("@")[0]):"U"})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(Bae,{placeholder:n?"What's on your mind? Use @ to mention someone, # to link a template":"What's on your mind? Use @ to mention someone",value:f,onChange:y,onMentionsChange:be,onTemplatesChange:je,mentionFormat:"encoded",minHeight:"80px",enableTemplateMentions:n}),T.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:T.map((et,Tt)=>{var Ft;return e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[(Ft=k[Tt])!=null&&Ft.type.startsWith("video/")?e.jsx("video",{src:et,className:"w-full h-full object-cover"}):e.jsx("img",{src:et,alt:"",className:"w-full h-full object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>ct(Tt),children:e.jsx(Ur,{className:"h-3 w-3"})})]},Tt)})}),L&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Do,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Re,{value:L,onChange:et=>R(et.target.value),placeholder:"https://...",className:"flex-1"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>R(""),children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx("input",{type:"file",ref:d,onChange:$e,accept:"image/*,video/*",multiple:!0,className:"hidden"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var et;return(et=d.current)==null?void 0:et.click()},children:[e.jsx(Jo,{className:"h-4 w-4 mr-1"}),"Photo"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var et;return(et=d.current)==null?void 0:et.click()},children:[e.jsx(Nn,{className:"h-4 w-4 mr-1"}),"Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>R("https://"),children:[e.jsx(Do,{className:"h-4 w-4 mr-1"}),"Link"]})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end",children:[Me.length>0?e.jsxs(sr,{value:w||_||"none",onValueChange:et=>{et==="none"?(b(""),j("")):et.startsWith("group:")?(j(et.replace("group:","")),b("")):(b(et),j(""))},children:[e.jsx(er,{className:"w-[130px] sm:w-[160px] h-8 text-xs sm:text-sm",children:e.jsx(rr,{placeholder:"Select..."})}),e.jsxs(tr,{children:[e.jsx(At,{value:"none",children:"No category"}),we.map(et=>e.jsxs(At,{value:et.id,children:[et.icon," ",et.name]},et.id)),Me.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-2 py-1 text-xs font-semibold text-muted-foreground border-t mt-1 pt-1",children:"🔒 Private Groups"}),Me.map(et=>e.jsxs(At,{value:`group:${et.id}`,children:[et.icon||"🔒"," ",et.name]},et.id))]})]})]}):e.jsxs(sr,{value:_,onValueChange:b,children:[e.jsx(er,{className:"w-[110px] sm:w-[140px] h-8 text-xs sm:text-sm",children:e.jsx(rr,{placeholder:"Category"})}),e.jsx(tr,{children:we.map(et=>e.jsxs(At,{value:et.id,children:[et.icon," ",et.name]},et.id))})]}),e.jsxs(K,{size:"sm",onClick:()=>me.mutate(),disabled:!f.trim()||$,children:[e.jsx(aa,{className:"h-4 w-4 mr-1"}),"Post"]})]})]})]})]})})}),Ae?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((et,Tt)=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(xs,{className:"h-10 w-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(xs,{className:"h-4 w-32"}),e.jsx(xs,{className:"h-4 w-full"}),e.jsx(xs,{className:"h-4 w-3/4"})]})]})})},Tt))}):Rt.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(xc,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No posts yet"}),e.jsx("p",{className:"text-muted-foreground",children:"Be the first to start a conversation!"})]})}):e.jsxs("div",{className:"space-y-4",children:[Rt.map(et=>{var Tt,Ft,as,Xt;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex gap-3 min-w-0",children:[e.jsxs(xn,{className:"h-10 w-10",children:[e.jsx(Aa,{src:et.user_avatar||void 0}),e.jsx(yn,{children:qe(et.user_name||"U")})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold break-words",children:et.user_name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{children:Sd(new Date(et.created_at),{addSuffix:!0})}),et.category&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs(rt,{variant:"secondary",className:"text-xs",children:[et.category.icon," ",et.category.name]})]})]})]})]}),(et.user_id===(t==null?void 0:t.id)||He(et))&&e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(of,{className:"h-4 w-4"})})}),e.jsxs(Md,{align:"end",children:[He(et)&&et.private_group_id&&e.jsx(Na,{onClick:()=>nt.mutate({postId:et.id,isPinned:et.is_pinned}),children:et.is_pinned?e.jsxs(e.Fragment,{children:[e.jsx(CP,{className:"h-4 w-4 mr-2"}),"Unpin Post"]}):e.jsxs(e.Fragment,{children:[e.jsx(u_,{className:"h-4 w-4 mr-2"}),"Pin to Top"]})}),et.user_id===(t==null?void 0:t.id)&&e.jsxs(Na,{onClick:()=>{H(et),se(et.content)},children:[e.jsx(Da,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Na,{className:"text-destructive",onClick:()=>ot.mutate(et.id),children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),et.user_id!==(t==null?void 0:t.id)?"Remove (Moderate)":"Delete"]})]})]})]}),et.is_pinned&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-primary",children:[e.jsx(u_,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Pinned"})]}),e.jsx("div",{className:"mb-3",children:e.jsx(_we,{content:et.content})}),et.media.length>0&&e.jsx("div",{className:`grid gap-2 mb-3 ${et.media.length===1?"grid-cols-1":et.media.length===2?"grid-cols-2":et.media.length===3?"grid-cols-3":"grid-cols-2"}`,children:et.media.slice(0,4).map((ss,is)=>{const ar=is===3&&et.media.length>4,Ct=et.media.length-4;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden bg-muted cursor-pointer group ${et.media.length===1?"max-h-[500px]":et.media.length===2?"aspect-[4/3]":"aspect-square"}`,onClick:()=>Ge({open:!0,images:et.media.map(Is=>({url:Is.media_url,type:Is.media_type==="video"?"video":"image"})),index:is}),children:[ss.media_type==="video"?e.jsx("video",{src:ss.media_url,className:"w-full h-full object-cover transition-transform group-hover:scale-105"}):e.jsx("img",{src:ss.media_url,alt:"",className:"w-full h-full object-cover transition-transform group-hover:scale-105"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors flex items-center justify-center",children:e.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity text-white",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})})})}),ar&&e.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center",children:e.jsxs("span",{className:"text-white text-2xl font-bold",children:["+",Ct]})})]},ss.id)})}),et.link_url&&e.jsxs("a",{href:et.link_url,target:"_blank",rel:"noopener noreferrer",className:"block rounded-lg border hover:bg-muted transition-colors mb-3 overflow-hidden",children:[et.link_image&&e.jsx("div",{className:"aspect-video bg-muted",children:e.jsx("img",{src:et.link_image,alt:et.link_title||"Link preview",className:"w-full h-full object-cover",onError:ss=>{ss.currentTarget.style.display="none"}})}),e.jsx("div",{className:"p-3",children:et.link_title?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium text-foreground line-clamp-2",children:et.link_title}),et.link_description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mt-1",children:et.link_description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 truncate",children:new URL(et.link_url).hostname})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-primary",children:[e.jsx(Do,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:et.link_url})]})})]}),et.reactions.length>0&&e.jsx(EKe,{reactions:et.reactions,children:e.jsxs("div",{className:"flex items-center gap-2 mb-3 text-sm text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:[e.jsx("div",{className:"flex -space-x-1",children:Object.entries(Ze(et.reactions)).slice(0,3).map(([ss])=>{var is;return e.jsx("span",{className:"text-base",children:(is=xR.find(ar=>ar.type===ss))==null?void 0:is.emoji},ss)})}),e.jsx("span",{children:et.reactions.length})]})}),e.jsxs("div",{className:"flex items-center gap-1 border-t border-b py-1 my-2",children:[e.jsxs(Co,{children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",children:[Qe(et.reactions)?e.jsx("span",{className:"mr-1",children:(Tt=xR.find(ss=>ss.type===Qe(et.reactions)))==null?void 0:Tt.emoji}):e.jsx(gu,{className:"h-4 w-4 mr-1"}),Qe(et.reactions)?(Ft=xR.find(ss=>ss.type===Qe(et.reactions)))==null?void 0:Ft.label:"Like"]})}),e.jsx(No,{className:"w-auto p-2",side:"top",children:e.jsx("div",{className:"flex gap-1",children:xR.map(ss=>e.jsx("button",{onClick:()=>Se.mutate({postId:et.id,reactionType:ss.type}),className:"text-2xl hover:scale-125 transition-transform p-1",title:ss.label,children:ss.emoji},ss.type))})})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",onClick:()=>Q(ss=>{const is=new Set(ss);return is.has(et.id)?is.delete(et.id):is.add(et.id),is}),children:[e.jsx(xc,{className:"h-4 w-4 mr-1"}),(()=>{const ss=We(et.comments);return ss>0?`Comment (${ss})`:"Comment"})()]})]}),te.has(et.id)&&e.jsxs("div",{className:"space-y-3 mt-3",children:[et.comments.map(ss=>e.jsx(PKe,{comment:ss,postId:et.id,currentUserId:t==null?void 0:t.id,currentUserAvatar:a,currentUserEmail:t==null?void 0:t.email,canModerate:He(et)},ss.id)),t&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(xn,{className:"h-8 w-8",children:[e.jsx(Aa,{src:a||void 0}),e.jsx(yn,{className:"text-xs",children:qe(((as=t.email)==null?void 0:as.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(Bae,{placeholder:"Write a comment... (use @ to mention)",value:de[et.id]||"",onChange:ss=>re(is=>({...is,[et.id]:ss})),onMentionsChange:ss=>le(is=>({...is,[et.id]:ss})),mentionFormat:"plain",onKeyDown:ss=>{var is;ss.defaultPrevented||ss.key==="Enter"&&!ss.shiftKey&&((is=de[et.id])!=null&&is.trim())&&(ss.preventDefault(),it.mutate({postId:et.id,content:de[et.id]}))},className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{var ss;(ss=de[et.id])!=null&&ss.trim()&&it.mutate({postId:et.id,content:de[et.id]})},disabled:!((Xt=de[et.id])!=null&&Xt.trim()),className:"h-8 px-2 mt-0.5",children:e.jsx(aa,{className:"h-4 w-4"})})]})]})]})]})},et.id)}),Ue&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(K,{variant:"outline",onClick:()=>ut(),disabled:De,children:De?"Loading…":"Load more posts"})})]}),e.jsx(_s,{open:!!U,onOpenChange:()=>H(null),children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Edit Post"})}),e.jsx(Ar,{value:Y,onChange:et=>se(et.target.value),className:"min-h-[120px]"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>H(null),children:"Cancel"}),e.jsx(K,{onClick:()=>{U&&Xe.mutate({postId:U.id,content:Y})},disabled:!Y.trim(),children:"Save Changes"})]})]})}),e.jsx(V8t,{images:Ne.images,initialIndex:Ne.index,open:Ne.open,onOpenChange:et=>Ge(Tt=>({...Tt,open:et}))})]})]})})},f4={open:{label:"Open",icon:Tn,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:xc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:hi,color:"bg-green-500"},closed:{label:"Closed",icon:kc,color:"bg-muted-foreground"}},ZAe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function K8t(){const{user:t}=Hs(),s=rs(),[r,n]=C.useState(null),[a,o]=C.useState(""),{data:l=[],isLoading:i}=wt({queryKey:["support-tickets"],queryFn:async()=>{const{data:f,error:y}=await G.from("support_tickets").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});if(y)throw y;return f},enabled:!!t}),{data:d=[]}=wt({queryKey:["ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:f,error:y}=await G.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(y)throw y;return f},enabled:!!r}),u=Dt({mutationFn:async f=>{if(!r||!t)throw new Error("Missing data");const{error:y}=await G.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:f,is_admin_reply:!1});if(y)throw y},onSuccess:()=>{s.invalidateQueries({queryKey:["ticket-replies",r==null?void 0:r.id]}),o(""),fe.success("Reply sent!")},onError:()=>{fe.error("Failed to send reply")}}),p=()=>{a.trim()&&u.mutate(a)};if(r){const f=f4[r.status].icon;return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(ti,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(rt,{variant:"secondary",children:ZAe[r.category]}),e.jsxs(rt,{className:f4[r.status].color,children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),f4[r.status].label]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(pr,{children:["Created on ",ys(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Conversation"})}),e.jsxs(Oe,{children:[e.jsx(Ri,{className:"h-[300px] pr-4",children:d.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):e.jsx("div",{className:"space-y-4",children:d.map(y=>{var _;return e.jsxs("div",{className:`p-4 rounded-lg ${y.is_admin_reply?"bg-primary/10 ml-4":"bg-muted mr-4"}`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("span",{className:"font-medium text-sm",children:y.is_admin_reply?"Support Team":((_=y.profiles)==null?void 0:_.name)||"You"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ys(new Date(y.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:y.content})]},y.id)})})}),r.status!=="closed"&&e.jsxs(e.Fragment,{children:[e.jsx(Rl,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ar,{placeholder:"Type your reply...",value:a,onChange:y=>o(y.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:p,disabled:!a.trim()||u.isPending,className:"self-end",children:e.jsx(aa,{className:"h-4 w-4"})})]})]})]})]})]})})}return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{className:"bg-gradient-to-br from-primary/10 via-primary/5 to-background border-primary/20",children:e.jsx(Oe,{className:"p-6 sm:p-8",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-6",children:[e.jsx("div",{className:"p-4 bg-primary/20 rounded-full",children:e.jsx(h0,{className:"h-8 w-8 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Need Help?"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Submit a support ticket and our team will get back to you as soon as possible."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx(Nxe,{trigger:e.jsxs(K,{size:"lg",className:"gap-2",children:[e.jsx(Zs,{className:"h-5 w-5"}),"Submit a Ticket"]})}),e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-muted rounded-lg",children:[e.jsx(Qn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Or text us: ",e.jsx("span",{className:"font-semibold text-foreground",children:"1-866-527-8668"})]})]})]})]})]})})}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Your Tickets"}),e.jsx(Nxe,{trigger:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"New Ticket"]})})]}),i?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading tickets..."}):l.length===0?e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"text-center py-12",children:[e.jsx(xc,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No tickets yet"}),e.jsx("p",{className:"text-muted-foreground",children:"You haven't submitted any support tickets. Use the button above to get started!"})]})}):e.jsx("div",{className:"space-y-3",children:l.map(f=>{const y=f4[f.status].icon;return e.jsx(Ee,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(f),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:f.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(rt,{variant:"outline",className:"text-xs",children:ZAe[f.category]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ys(new Date(f.created_at),"MMM d, yyyy")})]})]}),e.jsxs(rt,{className:f4[f.status].color,children:[e.jsx(y,{className:"h-3 w-3 mr-1"}),f4[f.status].label]})]})})},f.id)})})]})})}function Z8t({open:t,onOpenChange:s}){return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Ss,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(on,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(ks,{children:"Schedule Agent Onboarding"}),e.jsx(Kr,{children:"Book a one-on-one onboarding session with LevelUp"})]})]})}),t&&e.jsx("iframe",{src:"https://tidycal.com/jeremycollins/new-agent-onboarding",className:"w-full border-0 rounded-lg",style:{height:"600px",minHeight:"500px"},title:"Schedule Agent Onboarding"})]})})}function Y8t({open:t,onOpenChange:s}){const{brokerageId:r}=Hs(),[n,a]=C.useState(""),[o,l]=C.useState([]),[i,d]=C.useState(!1),{data:u,isLoading:p}=wt({queryKey:["brokerage-agents-for-onboarding",r],queryFn:async()=>{if(!r)return[];const{data:w,error:j}=await G.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name",{ascending:!0});if(j)throw j;return w},enabled:t&&!!r}),f=u==null?void 0:u.filter(w=>w.name.toLowerCase().includes(n.toLowerCase())||w.email.toLowerCase().includes(n.toLowerCase())),y=w=>{l(j=>j.includes(w)?j.filter(k=>k!==w):[...j,w])},_=async()=>{if(o.length===0){fe.error("Please select at least one agent");return}d(!0);try{const{data:w,error:j}=await G.functions.invoke("send-onboarding-link",{body:{agentIds:o}});if(j)throw j;fe.success(`Onboarding link sent to ${o.length} agent${o.length>1?"s":""}`),l([]),s(!1)}catch(w){console.error("Error sending onboarding link:",w),fe.error(w.message||"Failed to send onboarding link")}finally{d(!1)}},b=w=>{w||(l([]),a("")),s(w)};return e.jsx(_s,{open:t,onOpenChange:b,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(aa,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(ks,{children:"Send Onboarding Link"}),e.jsx(Kr,{children:"Select agents to receive the onboarding booking link"})]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search agents...",value:n,onChange:w=>a(w.target.value),className:"pl-10"})]}),p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):(f==null?void 0:f.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(hr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No agents found"})]}):e.jsx(Ri,{className:"h-[300px] border rounded-lg",children:e.jsx("div",{className:"p-2 space-y-1",children:f==null?void 0:f.map(w=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted cursor-pointer",onClick:()=>y(w.id),children:[e.jsx(Bo,{checked:o.includes(w.id),onCheckedChange:()=>y(w.id)}),e.jsx(xn,{className:"h-8 w-8",children:e.jsx(yn,{className:"text-xs",children:w.name.split(" ").map(j=>j[0]).join("").toUpperCase()})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:w.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:w.email})]})]},w.id))})}),o.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.length," agent",o.length>1?"s":""," selected"]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(K,{onClick:_,disabled:o.length===0||i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(aa,{className:"h-4 w-4 mr-2"}),"Send Link"]})})]})]})})}function X8t(){const[t,s]=C.useState(!1),[r,n]=C.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"mb-8",children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(hr,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{children:"Agent Onboarding"}),e.jsx(pr,{children:"Schedule onboarding sessions for yourself or your agents"})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Schedule Agent Onboarding"]}),e.jsxs(K,{variant:"outline",onClick:()=>n(!0),className:"flex items-center gap-2",children:[e.jsx(aa,{className:"h-4 w-4"}),"Send New Agent Onboarding Link"]})]})})]}),e.jsx(Z8t,{open:t,onOpenChange:s}),e.jsx(Y8t,{open:r,onOpenChange:n})]})}function Q8t({open:t,onOpenChange:s}){return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Ss,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Qx,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(ks,{children:"Schedule Launch Meeting"}),e.jsx(Kr,{children:"Book a private LevelUp information session for your brokerage"})]})]})}),t&&e.jsx("iframe",{src:"https://tidycal.com/jeremycollins/levelup-launch-call",className:"w-full border-0 rounded-lg",style:{height:"600px",minHeight:"500px"},title:"Schedule Launch Meeting"})]})})}function J8t(){const[t,s]=C.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"mb-8",children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Qx,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{children:"Launch or ReLaunch Meeting"}),e.jsx(pr,{children:"Schedule a private LevelUp information session for your brokerage. Have one of our staff host a meeting to help your team get the most out of all our trainings, tools, and resources."})]})]})}),e.jsx(Oe,{children:e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(Qx,{className:"h-4 w-4"}),"Schedule Launch Meeting"]})})]}),e.jsx(Q8t,{open:t,onOpenChange:s})]})}function eRt(){const t=Pr(),[s,r]=C.useState(""),[n,a]=C.useState(null),{data:o,isLoading:l}=wt({queryKey:["brokerage-resources-published"],queryFn:async()=>{const{data:w,error:j}=await G.from("brokerage_resources").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(j)throw j;return w}}),{data:i}=wt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:w,error:j}=await G.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(j)throw j;return w}}),{data:d}=wt({queryKey:["brokerage-resource-pdfs-all"],queryFn:async()=>{const{data:w,error:j}=await G.from("brokerage_resource_pdfs").select("resource_id");if(j)throw j;return w}}),{data:u}=wt({queryKey:["brokerage-resource-videos-all"],queryFn:async()=>{const{data:w,error:j}=await G.from("brokerage_resource_videos").select("resource_id");if(j)throw j;return w}}),{data:p}=wt({queryKey:["brokerage-resource-links-all"],queryFn:async()=>{const{data:w,error:j}=await G.from("brokerage_resource_links").select("resource_id");if(j)throw j;return w}}),f=o==null?void 0:o.filter(w=>{var S;const j=w.title.toLowerCase().includes(s.toLowerCase())||((S=w.description)==null?void 0:S.toLowerCase().includes(s.toLowerCase())),k=!n||w.category_id===n;return j&&k}),y=i==null?void 0:i.filter(w=>o==null?void 0:o.some(j=>j.category_id===w.id)),_=w=>{const j=(d==null?void 0:d.filter(T=>T.resource_id===w).length)||0,k=(u==null?void 0:u.filter(T=>T.resource_id===w).length)||0,S=(p==null?void 0:p.filter(T=>T.resource_id===w).length)||0;return{pdfCount:j,videoCount:k,linkCount:S}},b=w=>{t(`/brokerage-resources/${w}`)};return e.jsx(Ts,{title:"Brokerage Resources",description:"Access exclusive resources for brokerage managers",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(X8t,{}),e.jsx(J8t,{}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search resources...",value:s,onChange:w=>r(w.target.value),className:"pl-10"})]}),y&&y.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(rt,{variant:n===null?"default":"outline",className:"cursor-pointer",onClick:()=>a(null),children:"All"}),y.map(w=>e.jsx(rt,{variant:n===w.id?"default":"outline",className:"cursor-pointer",onClick:()=>a(w.id),children:w.name},w.id))]}),!l&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(f==null?void 0:f.length)||0," resource",(f==null?void 0:f.length)!==1?"s":""," available"]}),l?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[...Array(6)].map((w,j)=>e.jsxs(Ee,{children:[e.jsx(xs,{className:"h-40 w-full"}),e.jsx(It,{children:e.jsx(xs,{className:"h-5 w-3/4"})}),e.jsxs(Oe,{children:[e.jsx(xs,{className:"h-4 w-full mb-2"}),e.jsx(xs,{className:"h-4 w-2/3"})]})]},j))}):(f==null?void 0:f.length)===0?e.jsxs(Ee,{className:"p-12 text-center",children:[e.jsx(rh,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No resources found"}),e.jsx("p",{className:"text-muted-foreground",children:s||n?"Try adjusting your filters":"Check back later for new resources"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:f==null?void 0:f.map(w=>{const{pdfCount:j,videoCount:k,linkCount:S}=_(w.id),T=i==null?void 0:i.find(I=>I.id===w.category_id);return e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>b(w.id),children:[w.preview_image_url?e.jsx("img",{src:w.preview_image_url,alt:w.title,className:"w-full h-40 object-cover"}):e.jsx("div",{className:"w-full h-40 bg-muted flex items-center justify-center",children:e.jsx(rh,{className:"h-16 w-16 text-muted-foreground"})}),e.jsx(It,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(Ot,{className:"text-lg line-clamp-1",children:w.title}),T&&e.jsx(rt,{variant:"secondary",className:"shrink-0 text-xs",children:T.name})]})}),e.jsxs(Oe,{children:[w.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:w.description}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[j>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-4 w-4"}),j]}),k>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Nn,{className:"h-4 w-4"}),k]}),S>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Do,{className:"h-4 w-4"}),S]})]})]})]},w.id)})})]})})}const tRt=()=>{const{resourceId:t}=ko(),{data:s,isLoading:r}=wt({queryKey:["brokerage-resource-detail",t],queryFn:async()=>{const{data:a,error:o}=await G.from("brokerage_resources").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;const{data:l}=await G.from("brokerage_resource_pdfs").select("*").eq("resource_id",t).order("sort_order"),{data:i}=await G.from("brokerage_resource_videos").select("*").eq("resource_id",t).order("sort_order"),{data:d}=await G.from("brokerage_resource_links").select("*").eq("resource_id",t).order("sort_order");return{...a,pdfs:l||[],videos:i||[],links:d||[]}},enabled:!!t}),n=a=>a?a<1024?a+" B":a<1024*1024?(a/1024).toFixed(1)+" KB":(a/(1024*1024)).toFixed(1)+" MB":"";return r?e.jsx(Ts,{title:"Brokerage Resources",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):s?e.jsx(Ts,{title:s.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(vo,{to:"/brokerage-resources",children:[e.jsx(ti,{className:"h-4 w-4"}),"Back to Resources"]})}),s.preview_image_url&&e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:s.preview_image_url,alt:s.title,className:"w-full max-h-[400px] object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),s.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:s.description}})]}),s.videos&&s.videos.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Nn,{className:"h-4 w-4"}),"Videos (",s.videos.length,")"]}),e.jsx("div",{className:"space-y-4",children:s.videos.map(a=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:a.title}),e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:a.video_url,className:"absolute top-0 left-0 w-full h-full rounded-lg border",allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})]},a.id))})]})}),s.pdfs&&s.pdfs.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(In,{className:"h-4 w-4"}),"Documents (",s.pdfs.length,")"]}),e.jsx("div",{className:"grid gap-2",children:s.pdfs.map(a=>e.jsxs("a",{href:a.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(In,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:a.name}),a.file_size&&e.jsx("div",{className:"text-xs text-muted-foreground",children:n(a.file_size)})]})]}),e.jsx(xi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})}),s.links&&s.links.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(sn,{className:"h-4 w-4"}),"Canva Templates (",s.links.length,")"]}),e.jsx("div",{className:"grid gap-2",children:s.links.map(a=>e.jsxs("a",{href:a.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(sn,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"font-medium text-sm",children:a.title})]}),e.jsx(sn,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})})]})}):e.jsx(Ts,{title:"Brokerage Resources",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(rh,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Resource not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This resource may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(vo,{to:"/brokerage-resources",children:"Back to Resources"})})]})})};function sRt(){const{onlineUsers:t,totalOnline:s}=hVe();return e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Online Now"]}),e.jsxs(rt,{variant:"secondary",className:"bg-green-100 text-green-700",children:[e.jsx(Kc,{className:"h-2 w-2 fill-green-500 text-green-500 mr-1"}),s," online"]})]})}),e.jsx(Oe,{children:t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No other users online right now"}):e.jsx(Ri,{className:"h-[300px] pr-4",children:e.jsx("div",{className:"space-y-3",children:t.map(r=>{var n;return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"relative",children:[e.jsxs(xn,{className:"h-9 w-9",children:[e.jsx(Aa,{src:r.avatarUrl,alt:r.name}),e.jsx(yn,{className:"text-xs",children:(n=r.name)==null?void 0:n.split(" ").map(a=>a[0]).join("").slice(0,2).toUpperCase()})]}),e.jsx("span",{className:"absolute bottom-0 right-0 h-2.5 w-2.5 rounded-full bg-green-500 ring-2 ring-background"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:r.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Online ",Sd(new Date(r.onlineSince),{addSuffix:!1})]})]})]},r.id)})})})})]})}const YAe={users:{label:"Users & Access",sections:[{title:"Members",description:"Manage users, roles, and brokerage assignments",icon:hr,path:"/admin/members",color:"bg-blue-500/10 text-blue-600"},{title:"Invite Codes",description:"Create and manage signup invite codes",icon:UP,path:"/admin/invite-codes",color:"bg-amber-500/10 text-amber-600"},{title:"Subscriptions",description:"Track and manage user subscriptions",icon:yf,path:"/admin/subscriptions",color:"bg-gradient-to-br from-green-500/20 to-green-500/10 text-green-600"},{title:"Credit Management",description:"View and manage ReelFlow, Postcard, Letter & Check credits for all agents",icon:hP,path:"/admin/credits",color:"bg-gradient-to-br from-emerald-500/20 to-teal-500/10 text-emerald-600"},{title:"Subscription Discounts",description:"Create and manage coupon codes",icon:Wh,path:"/admin/discounts",color:"bg-red-500/10 text-red-600"},{title:"Referral Program",description:"Track brokerage referrals and discounts",icon:ld,path:"/admin/referrals",color:"bg-teal-500/10 text-teal-600"},{title:"Teams",description:"Manage agent teams across all brokerages",icon:hr,path:"/admin/members?tab=teams",color:"bg-violet-500/10 text-violet-600"},{title:"Prospector",description:"Send free trial invites and track conversions",icon:Gh,path:"/admin/prospector",color:"bg-gradient-to-br from-orange-500/20 to-amber-500/10 text-orange-600"},{title:"Recruiting",description:"Manage agent recruit pipeline and outreach",icon:yc,path:"/admin/recruiting",color:"bg-gradient-to-br from-emerald-500/20 to-green-500/10 text-emerald-600"}]},content:{label:"Content",sections:[{title:"Manage Templates",description:"Upload and organize Canva templates",icon:Bl,path:"/admin/templates",color:"bg-pink-500/10 text-pink-600"},{title:"Manage Academy",description:"Upload videos and training content",icon:ah,path:"/admin/academy",color:"bg-indigo-500/10 text-indigo-600"},{title:"Manage Toolbox",description:"Create and manage resource kits",icon:Wg,path:"/admin/toolbox",color:"bg-orange-500/10 text-orange-600"},{title:"Social Swag",description:"Manage social media content and links",icon:hn,path:"/admin/social-swag",color:"bg-fuchsia-500/10 text-fuchsia-600"},{title:"Social Swag 2.0",description:"New monthly social media images",icon:hn,path:"/admin/social-swag-2",color:"bg-cyan-500/10 text-cyan-600"},{title:"Newsletters",description:"Manage monthly newsletter templates",icon:z0,path:"/admin/newsletters",color:"bg-violet-500/10 text-violet-600"},{title:"Manage Events",description:"Create and publish events with Zoom integration",icon:id,path:"/admin/events",color:"bg-green-500/10 text-green-600"},{title:"Additional Services",description:"Manage additional service offerings",icon:rh,path:"/admin/additional-services",color:"bg-lime-500/10 text-lime-600"},{title:"Brokerage Resources",description:"Manage resources for brokerage managers",icon:rh,path:"/admin/brokerage-resources",color:"bg-slate-500/10 text-slate-600"},{title:"Agent Email Templates",description:"Manage curated email templates for agents",icon:br,path:"/admin/agent-email-templates",color:"bg-rose-500/10 text-rose-600"}]},platform:{label:"Platform",sections:[{title:"Dashboard Management",description:"Configure banners and dashboard modules",icon:dk,path:"/admin/dashboard-management",color:"bg-teal-500/10 text-teal-600"},{title:"Manage Apps",description:"Configure app tiles and access requirements",icon:Yp,path:"/admin/apps",color:"bg-purple-500/10 text-purple-600"},{title:"Email Templates",description:"Customize system email templates",icon:br,path:"/admin/email-templates",color:"bg-sky-500/10 text-sky-600"},{title:"The LevelUp Brief",description:"Create popup briefs with videos, links, and polls",icon:Rm,path:"/admin/levelup-brief",color:"bg-gradient-to-br from-primary/20 to-primary/10 text-primary"},{title:"Onboarding Checklist",description:"Manage getting started tasks for new users",icon:p5,path:"/admin/onboarding-checklist",color:"bg-emerald-500/10 text-emerald-600"},{title:"Marketplace",description:"Manage store categories, products, and orders",icon:Jx,path:"/admin/marketplace",color:"bg-gradient-to-br from-orange-500/20 to-amber-500/10 text-orange-600"},{title:"Reward Store",description:"Manage reward items agents can redeem with points",icon:po,path:"/admin/reward-store",color:"bg-purple-500/10 text-purple-600"},{title:"Agent Points",description:"View agent points, leaderboard, and award bonus points",icon:ao,path:"/admin/agent-points",color:"bg-amber-500/10 text-amber-600"},{title:"Integrations",description:"Connect Canva, Facebook & Instagram for platform-level features",icon:Wo,path:"/admin/integrations",color:"bg-blue-500/10 text-blue-600"},{title:"Agent Cards",description:"Manage digital business cards for agents",icon:hr,path:"/admin/agent-cards",color:"bg-gradient-to-br from-violet-500/20 to-purple-500/10 text-violet-600"},{title:"Notification Settings",description:"Test and manage push notifications",icon:Rm,path:"/admin/notification-settings",color:"bg-rose-500/10 text-rose-600"}]},community:{label:"Community & Support",sections:[{title:"Community Management",description:"Manage categories and private groups",icon:io,path:"/admin/community",color:"bg-cyan-500/10 text-cyan-600"},{title:"Support Tickets",description:"View and respond to agent support requests",icon:b5,path:"/admin/support-tickets",color:"bg-rose-500/10 text-rose-600"},{title:"Wishlist",description:"Review and manage community feature requests",icon:l_,path:"/admin/wishlist",color:"bg-yellow-500/10 text-yellow-600"},{title:"Membership Reviews",description:"View member feedback and ratings",icon:Gn,path:"/admin/membership-reviews",color:"bg-amber-500/10 text-amber-600"},{title:"Weekly Digest",description:"Configure automated weekly email digests",icon:br,path:"/admin/weekly-digest",color:"bg-indigo-500/10 text-indigo-600"}]},insights:{label:"Insights",sections:[{title:"Analytics",description:"View activity logs and platform statistics",icon:ol,path:"/admin/analytics",color:"bg-emerald-500/10 text-emerald-600"},{title:"Brokerage Content Activity",description:"See which brokerages are creating custom content for agents",icon:Fu,path:"/admin/brokerage-content-activity",color:"bg-sky-500/10 text-sky-600"}]},lms:{label:"LevelUp U",sections:[{title:"Manage Courses",description:"Create and manage LMS training courses, modules, and access",icon:ah,path:"/admin/lms",color:"bg-gradient-to-br from-primary/20 to-primary/10 text-primary"}]},"agent-os":{label:"Agent OS",sections:[{title:"Agent OS Control Center",description:"Manage InnerCircle feature: relationship types, action types, scripts, plans & feature flags",icon:Si,path:"/admin/agent-os",color:"bg-gradient-to-br from-rose-500/20 to-pink-500/10 text-rose-600"},{title:"Listing Exchange",description:"Approve, feature, and moderate community listings",icon:On,path:"/admin/listing-exchange",color:"bg-gradient-to-br from-blue-500/20 to-sky-500/10 text-blue-600"},{title:"Presentation Analytics",description:"Track agent presentation usage, views, and leads",icon:Hg,path:"/admin/presentation-analytics",color:"bg-gradient-to-br from-violet-500/20 to-indigo-500/10 text-violet-600"},{title:"Guest Book Analytics",description:"Track open house sign-in usage, visitors, and lead generation",icon:Fu,path:"/admin/guest-book-analytics",color:"bg-gradient-to-br from-emerald-500/20 to-teal-500/10 text-emerald-600"}]},beta:{label:"🧪 Beta Lab",sections:[{title:"Social Post Generator",description:"Auto-generate branded social media posts from MLS listing data",icon:Jo,path:"/admin/beta/social-post-generator",color:"bg-gradient-to-br from-fuchsia-500/20 to-pink-500/10 text-fuchsia-600"},{title:"Postcard Direct Mail",description:"Upload monthly postcard designs and manage agent direct mail via Postalytics",icon:br,path:"/admin/beta/postcard-manager",color:"bg-gradient-to-br from-orange-500/20 to-amber-500/10 text-orange-600"},{title:"ReelFlow",description:"Turn property photos into cinematic video reels for social media",icon:o_,path:"/admin/beta/homereel",color:"bg-gradient-to-br from-violet-500/20 to-indigo-500/10 text-violet-600"}]}};function rRt(){const t=Pr();return e.jsx(Ts,{title:"Admin Dashboard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Admin Dashboard"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage all aspects of your platform"})]}),e.jsx("div",{className:"w-full lg:w-80",children:e.jsx(sRt,{})})]}),e.jsxs(ka,{defaultValue:"users",className:"w-full",children:[e.jsx(_a,{className:"w-full justify-start flex-wrap h-auto gap-1 bg-muted/50 p-1 overflow-x-auto",children:Object.entries(YAe).map(([s,r])=>e.jsx(js,{value:s,className:"data-[state=active]:bg-background",children:r.label},s))}),Object.entries(YAe).map(([s,r])=>e.jsx(zs,{value:s,className:"mt-6",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:r.sections.map(n=>e.jsxs(Ee,{className:"cursor-pointer hover:shadow-md transition-all hover:border-primary/50 group",onClick:()=>t(n.path),children:[e.jsxs(It,{className:"pb-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${n.color} mb-2 group-hover:scale-110 transition-transform`,children:e.jsx(n.icon,{className:"h-5 w-5"})}),e.jsx(Ot,{className:"text-base",children:n.title})]}),e.jsx(Oe,{className:"pt-0",children:e.jsx(pr,{className:"text-sm",children:n.description})})]},n.path))})},s))]})]})})}const An=C.forwardRef(({className:t,...s},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:Pt("w-full caption-bottom text-sm",t),...s})}));An.displayName="Table";const En=C.forwardRef(({className:t,...s},r)=>e.jsx("thead",{ref:r,className:Pt("[&_tr]:border-b",t),...s}));En.displayName="TableHeader";const Pn=C.forwardRef(({className:t,...s},r)=>e.jsx("tbody",{ref:r,className:Pt("[&_tr:last-child]:border-0",t),...s}));Pn.displayName="TableBody";const nRt=C.forwardRef(({className:t,...s},r)=>e.jsx("tfoot",{ref:r,className:Pt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));nRt.displayName="TableFooter";const Ns=C.forwardRef(({className:t,...s},r)=>e.jsx("tr",{ref:r,className:Pt("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",t),...s}));Ns.displayName="TableRow";const bt=C.forwardRef(({className:t,...s},r)=>e.jsx("th",{ref:r,className:Pt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));bt.displayName="TableHead";const lt=C.forwardRef(({className:t,...s},r)=>e.jsx("td",{ref:r,className:Pt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s}));lt.displayName="TableCell";const aRt=C.forwardRef(({className:t,...s},r)=>e.jsx("caption",{ref:r,className:Pt("mt-4 text-sm text-muted-foreground",t),...s}));aRt.displayName="TableCaption";const iRt=()=>{const{isAdmin:t}=Hs(),s=Pr(),[r,n]=C.useState([]),[a,o]=C.useState(!0),[l,i]=C.useState(!1),[d,u]=C.useState(null);C.useEffect(()=>{if(!t){s("/dashboard");return}p()},[t]);const p=async()=>{try{const{data:w,error:j}=await G.from("app_tiles").select("*").order("name");if(j)throw j;n(w||[])}catch(w){console.error("Error loading apps:",w),fe.error("Failed to load apps")}finally{o(!1)}},f=async w=>{w.preventDefault();const j=new FormData(w.currentTarget),k={name:j.get("name"),description:j.get("description"),icon:j.get("icon"),app_id:j.get("app_id"),target_url:j.get("target_url"),required_tags:j.get("required_tags").split(",").map(S=>S.trim()).filter(Boolean)};try{if(d){const{error:S}=await G.from("app_tiles").update(k).eq("id",d.id);if(S)throw S;fe.success("App updated successfully")}else{const{error:S}=await G.from("app_tiles").insert([k]);if(S)throw S;fe.success("App created successfully")}i(!1),u(null),p()}catch(S){console.error("Error saving app:",S),fe.error("Failed to save app")}},y=async w=>{if(confirm("Are you sure you want to delete this app?"))try{const{error:j}=await G.from("app_tiles").delete().eq("id",w);if(j)throw j;fe.success("App deleted successfully"),p()}catch(j){console.error("Error deleting app:",j),fe.error("Failed to delete app")}},_=w=>{u(w),i(!0)},b=()=>{u(null),i(!0)};return a?e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}):e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/dashboard"),children:[e.jsx(ti,{className:"h-4 w-4 mr-2"}),"Back"]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Manage Apps"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create and configure application tiles"})]})]}),e.jsxs(_s,{open:l,onOpenChange:i,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{onClick:b,children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Add App"]})}),e.jsxs(vs,{className:"max-w-2xl",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:d?"Edit App":"Create New App"}),e.jsx(Kr,{children:"Configure the application tile settings"})]}),e.jsxs("form",{onSubmit:f,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"App Name"}),e.jsx(Re,{id:"name",name:"name",defaultValue:d==null?void 0:d.name,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"app_id",children:"App ID"}),e.jsx(Re,{id:"app_id",name:"app_id",defaultValue:d==null?void 0:d.app_id,placeholder:"agent_connect",required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",name:"description",defaultValue:d==null?void 0:d.description})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"icon",children:"Icon (emoji)"}),e.jsx(Re,{id:"icon",name:"icon",defaultValue:d==null?void 0:d.icon,placeholder:"🚀",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"target_url",children:"Target URL"}),e.jsx(Re,{id:"target_url",name:"target_url",type:"url",defaultValue:d==null?void 0:d.target_url,required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"required_tags",children:"Required Tags (comma-separated)"}),e.jsx(Re,{id:"required_tags",name:"required_tags",defaultValue:d==null?void 0:d.required_tags.join(", "),placeholder:"levelup-member, agent-connect"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{type:"submit",children:d?"Update":"Create"})]})]})]})]})]})})}),e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Application Tiles"}),e.jsx(pr,{children:"Manage the apps that appear on the member dashboard"})]}),e.jsx(Oe,{children:r.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsxs(K,{onClick:b,children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create First App"]})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Icon"}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"App ID"}),e.jsx(bt,{children:"Target URL"}),e.jsx(bt,{children:"Tags"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:r.map(w=>e.jsxs(Ns,{children:[e.jsx(lt,{className:"text-2xl",children:w.icon}),e.jsx(lt,{className:"font-medium",children:w.name}),e.jsx(lt,{className:"font-mono text-sm",children:w.app_id}),e.jsx(lt,{className:"text-sm text-muted-foreground max-w-xs truncate",children:w.target_url}),e.jsx(lt,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:w.required_tags.map(j=>e.jsx("span",{className:"text-xs bg-secondary text-secondary-foreground px-2 py-1 rounded",children:j},j))})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>_(w),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>y(w.id),children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},w.id))})]})})]})})]})};function wu({title:t,description:s,children:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx(vo,{to:"/admin",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",children:[e.jsx(ti,{className:"h-4 w-4"}),"Back to Admin Dashboard"]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:t}),s&&e.jsx("p",{className:"text-muted-foreground",children:s})]}),r]})]})}const XAe=({expiresAt:t,className:s})=>{const r=new Date().getTime(),n=new Date(t).getTime(),a=Math.ceil((n-r)/(1e3*60*60*24));return a<=0?e.jsxs(rt,{variant:"destructive",className:Pt("gap-1",s),children:[e.jsx(Ju,{className:"h-3 w-3"}),"Trial Expired"]}):a<=1?e.jsxs(rt,{variant:"destructive",className:Pt("gap-1",s),children:[e.jsx(Tn,{className:"h-3 w-3"}),"Trial: <1 day left"]}):a<=3?e.jsxs(rt,{className:Pt("gap-1 bg-amber-500 hover:bg-amber-600",s),children:[e.jsx(Tn,{className:"h-3 w-3"}),"Trial: ",a," days left"]}):e.jsxs(rt,{variant:"secondary",className:Pt("gap-1",s),children:[e.jsx(Tn,{className:"h-3 w-3"}),"Trial: ",a," days left"]})},IKe=({open:t,onOpenChange:s,brokerages:r,fixedBrokerageId:n,onSuccess:a})=>{const{toast:o}=Pa(),l=C.useRef(null),[i,d]=C.useState([]),[u,p]=C.useState(""),[f,y]=C.useState(!1),[_,b]=C.useState("upload"),[w,j]=C.useState(null),k=()=>{d([]),p(""),b("upload"),j(null),l.current&&(l.current.value="")},S=()=>{k(),s(!1)},T=q=>{const U=q.split(` `).map(Q=>Q.trim()).filter(Q=>Q);if(U.length===0)return[];const H=U[0].toLowerCase(),se=H.includes("first")||H.includes("last")||H.includes("email")||H.includes("name")||H.includes("phone")||H.includes("sms")||H.includes("consent")?U.slice(1):U,te=[];for(const Q of se){const re=(Q.includes(" ")?Q.split(" "):Q.split(",")).map(ae=>ae.trim().replace(/^["']|["']$/g,""));if(re.length>=2){let ae="",le="",he="",be="",_e;if(re.length===2){const Ge=re[0].split(" ");ae=Ge[0]||"",le=Ge.slice(1).join(" ")||"",he=re[1]}else if(re.length===3)ae=re[0],le=re[1],he=re[2];else if(re.length===4)ae=re[0],le=re[1],he=re[2],be=re[3];else if(re.length>=5){ae=re[0],le=re[1],he=re[2],be=re[3];const Ge=re[4].toLowerCase();_e=Ge==="true"||Ge==="yes"||Ge==="1"||Ge==="y"}const Ne=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(he);te.push({firstName:ae.trim(),lastName:le.trim(),email:he.trim().toLowerCase(),phone:be.trim()||void 0,smsConsent:_e,isValid:Ne&&ae.trim().length>0,error:Ne?ae.trim()?void 0:"Missing name":"Invalid email"})}}return te},I=q=>{var Y;const U=(Y=q.target.files)==null?void 0:Y[0];if(!U)return;const H=new FileReader;H.onload=se=>{var de;const te=(de=se.target)==null?void 0:de.result,Q=T(te);if(Q.length===0){o({title:"No data found",description:"The CSV file appears to be empty or in an unsupported format.",variant:"destructive"});return}d(Q),b("preview")},H.readAsText(U)},L=async()=>{const q=i.filter(H=>H.isValid);if(q.length===0){o({title:"No valid users",description:"There are no valid users to import.",variant:"destructive"});return}const U=n||u||null;y(!0);try{const{data:{session:H}}=await G.auth.getSession(),Y=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/bulk-create-users",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${H==null?void 0:H.access_token}`},body:JSON.stringify({users:q.map(te=>({firstName:te.firstName,lastName:te.lastName,email:te.email,phone:te.phone,smsConsent:te.smsConsent})),brokerageId:U})}),se=await Y.json();if(!Y.ok)throw new Error(se.error||"Failed to import users");j(se),b("result"),se.created>0&&a(),o({title:"Import Complete",description:`${se.created} user(s) created successfully.${se.failed>0?` ${se.failed} failed.`:""}`})}catch(H){console.error("Import error:",H),o({title:"Import Failed",description:H.message||"Failed to import users",variant:"destructive"})}finally{y(!1)}},R=i.filter(q=>q.isValid).length,$=i.filter(q=>!q.isValid).length;return e.jsx(_s,{open:t,onOpenChange:S,children:e.jsxs(vs,{className:"max-w-2xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(I0,{className:"h-5 w-5"}),"Import Agents from CSV"]}),e.jsx(Kr,{children:"Upload a CSV file with agent information. Each row should contain First Name, Last Name, and Email."})]}),_==="upload"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx("input",{type:"file",accept:".csv,.txt",ref:l,onChange:I,className:"hidden"}),e.jsx(Za,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Click to upload or drag and drop a CSV file"}),e.jsx(K,{onClick:()=>{var q;return(q=l.current)==null?void 0:q.click()},children:"Select CSV File"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 text-sm",children:[e.jsx("p",{className:"font-medium mb-2",children:"Expected CSV Format:"}),e.jsxs("code",{className:"text-xs block bg-background p-2 rounded",children:["First Name, Last Name, Email, Phone, SMS Consent",e.jsx("br",{}),"John, Doe, john@example.com, 555-123-4567, yes",e.jsx("br",{}),"Jane, Smith, jane@example.com, 555-987-6543, true"]}),e.jsx("p",{className:"text-muted-foreground mt-2 text-xs",children:"Phone and SMS Consent columns are optional. SMS Consent accepts: yes/no, true/false, 1/0, y/n."})]})]}),_==="preview"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[!n&&r&&r.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Assign to Brokerage (optional)"}),e.jsxs(sr,{value:u||"none",onValueChange:q=>p(q==="none"?"":q),children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select a brokerage..."})}),e.jsxs(tr,{children:[e.jsx(At,{value:"none",children:"No brokerage"}),r.map(q=>e.jsx(At,{value:q.id,children:q.name},q.id))]})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ua,{className:"h-4 w-4 text-green-500"}),e.jsxs("span",{children:[R," valid"]})]}),$>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(ll,{className:"h-4 w-4"}),e.jsxs("span",{children:[$," invalid"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{className:"bg-muted/30",children:[e.jsx(bt,{children:"First Name"}),e.jsx(bt,{children:"Last Name"}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:"Phone"}),e.jsx(bt,{children:"SMS"}),e.jsx(bt,{children:"Status"})]})}),e.jsx(Pn,{children:i.slice(0,100).map((q,U)=>e.jsxs(Ns,{children:[e.jsx(lt,{children:q.firstName}),e.jsx(lt,{children:q.lastName}),e.jsx(lt,{children:q.email}),e.jsx(lt,{className:"text-muted-foreground",children:q.phone||"-"}),e.jsx(lt,{className:"text-muted-foreground",children:q.smsConsent===!0?"✓":q.smsConsent===!1?"✗":"-"}),e.jsx(lt,{children:q.isValid?e.jsx(rt,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):e.jsx(rt,{variant:"destructive",children:q.error||"Invalid"})})]},U))})]}),i.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",i.length," users"]})]})]}),_==="result"&&w&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(ua,{className:"h-12 w-12 mx-auto text-green-500 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:[w.created," agent(s) created and invited"]}),w.failed>0&&e.jsxs("p",{className:"text-destructive mt-1",children:[w.failed," failed to create"]})]}),w.errors.length>0&&e.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 max-h-40 overflow-auto",children:[e.jsx("p",{className:"font-medium text-destructive text-sm mb-2",children:"Errors:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1",children:[w.errors.slice(0,10).map((q,U)=>e.jsxs("li",{children:["• ",q]},U)),w.errors.length>10&&e.jsxs("li",{children:["...and ",w.errors.length-10," more"]})]})]})]}),e.jsxs(Un,{children:[_==="upload"&&e.jsx(K,{variant:"outline",onClick:S,children:"Cancel"}),_==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:k,children:"Back"}),e.jsx(K,{onClick:L,disabled:f||R===0,children:f?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${R} Agent${R!==1?"s":""}`})]}),_==="result"&&e.jsx(K,{onClick:S,children:"Done"})]})]})})};function el({sortKey:t,currentSortKey:s,currentDirection:r,onSort:n,children:a,className:o,...l}){const i=s===t;return e.jsx(bt,{className:Pt("cursor-pointer select-none",o),...l,children:e.jsxs("button",{type:"button",className:"flex items-center gap-1 font-semibold hover:text-foreground transition-colors w-full text-left",onClick:()=>n(t),children:[a,i?r==="asc"?e.jsx(Vd,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(sh,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Hc,{className:"h-3.5 w-3.5 shrink-0 opacity-40"})]})})}function JL(t=null,s=null){const[r,n]=C.useState(t),[a,o]=C.useState(s),l=C.useCallback(d=>{r===d?a==="asc"?o("desc"):a==="desc"?(n(null),o(null)):o("asc"):(n(d),o("asc"))},[r,a]),i=C.useCallback((d,u)=>{if(!r||!a||!u[r])return d;const p=u[r];return[...d].sort((f,y)=>{const _=p(f),b=p(y);if(_==null&&b==null)return 0;if(_==null)return 1;if(b==null)return-1;let w;return typeof _=="string"&&typeof b=="string"?w=_.localeCompare(b,void 0,{sensitivity:"base"}):w=_-b,a==="asc"?w:-w})},[r,a]);return{sortKey:r,sortDirection:a,handleSort:l,sortData:i}}const oRt=[{type:"custom",title:"Great job!",message:"Keep up the amazing work!",icon:Gn},{type:"custom",title:"You're on fire!",message:"Your dedication is inspiring!",icon:ao},{type:"custom",title:"Congratulations!",message:"You earned this celebration!",icon:kd}];function LKe({open:t,onOpenChange:s,userId:r,userName:n}){const[a,o]=C.useState("custom"),[l,i]=C.useState(""),[d,u]=C.useState(""),p=vyt(),f=_=>{o(_.type),i(_.title),u(_.message)},y=async _=>{if(_.preventDefault(),!l.trim()){pn({title:"Title required",description:"Please enter a celebration title",variant:"destructive"});return}try{await p.mutateAsync({user_id:r,celebration_type:a,title:l.trim(),message:d.trim()||void 0}),pn({title:"Celebration sent! 🎉",description:`${n} will see confetti on their next visit!`}),s(!1),i(""),u(""),o("custom")}catch{pn({title:"Error",description:"Failed to send celebration",variant:"destructive"})}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(kd,{className:"h-5 w-5 text-primary"}),"Send Celebration to ",n]}),e.jsx(Kr,{children:"They'll see confetti and this message next time they log in!"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(ve,{className:"text-sm text-muted-foreground mb-2 block",children:"Quick presets:"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:oRt.map((_,b)=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>f(_),className:"text-xs",children:[e.jsx(_.icon,{className:"h-3 w-3 mr-1"}),_.title]},b))})]}),e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"type",children:"Celebration Type"}),e.jsxs(sr,{value:a,onValueChange:_=>o(_),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"custom",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Gn,{className:"h-4 w-4"})," Custom"]})}),e.jsx(At,{value:"points_earned",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ao,{className:"h-4 w-4"})," Points Earned"]})}),e.jsx(At,{value:"listing_created",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(On,{className:"h-4 w-4"})," Listing Created"]})}),e.jsx(At,{value:"deal_closed",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(od,{className:"h-4 w-4"})," Deal Closed"]})})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",value:l,onChange:_=>i(_.target.value),placeholder:"e.g., Congratulations!",maxLength:100})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"message",children:"Message (optional)"}),e.jsx(Ar,{id:"message",value:d,onChange:_=>u(_.target.value),placeholder:"Add a personal message...",rows:3,maxLength:500})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:p.isPending,children:[e.jsx(kd,{className:"h-4 w-4 mr-2"}),p.isPending?"Sending...":"Send Celebration"]})]})]})]})})}const Jme={points_earned:{label:"Points Earned",icon:ao,color:"bg-yellow-500"},listing_created:{label:"Listing Created",icon:On,color:"bg-blue-500"},deal_closed:{label:"Deal Closed",icon:od,color:"bg-green-500"},custom:{label:"Custom",icon:hn,color:"bg-purple-500"}};function lRt(){const[t,s]=C.useState(""),[r,n]=C.useState("all"),[a,o]=C.useState("all"),{data:l=[],isLoading:i}=wt({queryKey:["admin-celebrations"],queryFn:async()=>{const{data:p,error:f}=await G.from("celebration_queue").select("*").order("created_at",{ascending:!1}).limit(500);if(f)throw f;const y=[...new Set([...p.map(w=>w.user_id),...p.map(w=>w.created_by).filter(Boolean)])],{data:_}=await G.from("profiles").select("id, name, email").in("id",y),b=new Map((_==null?void 0:_.map(w=>[w.id,w]))||[]);return p.map(w=>{var j,k,S;return{...w,user_name:((j=b.get(w.user_id))==null?void 0:j.name)||"Unknown",user_email:((k=b.get(w.user_id))==null?void 0:k.email)||"",creator_name:w.created_by?((S=b.get(w.created_by))==null?void 0:S.name)||"System":"Auto-triggered"}})}}),d=l.filter(p=>{var b,w;const f=((b=p.user_name)==null?void 0:b.toLowerCase().includes(t.toLowerCase()))||((w=p.user_email)==null?void 0:w.toLowerCase().includes(t.toLowerCase()))||p.title.toLowerCase().includes(t.toLowerCase()),y=r==="all"||p.celebration_type===r,_=a==="all"||a==="seen"&&p.seen_at||a==="unseen"&&!p.seen_at;return f&&y&&_}),u={total:l.length,seen:l.filter(p=>p.seen_at).length,unseen:l.filter(p=>!p.seen_at).length,byType:Object.keys(Jme).reduce((p,f)=>(p[f]=l.filter(y=>y.celebration_type===f).length,p),{})};return i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Ms,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium",children:"Total Celebrations"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:u.total})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-green-600",children:"Seen"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:u.seen})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-orange-600",children:"Pending"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-orange-600",children:u.unseen})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-purple-600",children:"Custom Sent"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:u.byType.custom||0})})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(kd,{className:"h-5 w-5"}),"Celebration History"]}),e.jsx(pr,{children:"View all celebrations awarded to agents"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by agent name, email, or title...",value:t,onChange:p=>s(p.target.value),className:"pl-9"})]}),e.jsxs(sr,{value:r,onValueChange:n,children:[e.jsx(er,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"Filter by type"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Types"}),Object.entries(Jme).map(([p,f])=>e.jsx(At,{value:p,children:f.label},p))]})]}),e.jsxs(sr,{value:a,onValueChange:o,children:[e.jsx(er,{className:"w-[140px]",children:e.jsx(rr,{placeholder:"Status"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Status"}),e.jsx(At,{value:"seen",children:"Seen"}),e.jsx(At,{value:"unseen",children:"Pending"})]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Type"}),e.jsx(bt,{children:"Agent"}),e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Points"}),e.jsx(bt,{children:"Created By"}),e.jsx(bt,{children:"Created"}),e.jsx(bt,{children:"Status"})]})}),e.jsx(Pn,{children:d.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No celebrations found"})}):d.map(p=>{const f=Jme[p.celebration_type],y=f.icon;return e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsxs(rt,{variant:"outline",className:"gap-1",children:[e.jsx(y,{className:"h-3 w-3"}),f.label]})}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:p.user_name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:p.user_email})]})}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:p.title}),p.message&&e.jsx("div",{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:p.message})]})}),e.jsx(lt,{children:p.points_amount?e.jsxs(rt,{variant:"secondary",children:["+",p.points_amount]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(lt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:p.creator_name})}),e.jsx(lt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ys(new Date(p.created_at),"MMM d, yyyy h:mm a")})}),e.jsx(lt,{children:p.seen_at?e.jsx(rt,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:"Seen"}):e.jsx(rt,{variant:"outline",className:"bg-orange-50 text-orange-700 border-orange-200",children:"Pending"})})]},p.id)})})]})}),d.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-right",children:["Showing ",d.length," of ",l.length," celebrations"]})]})]})]})}const cRt=()=>{const{user:t}=Hs(),{toast:s}=Pa(),[r,n]=C.useState([]),[a,o]=C.useState(!0),[l,i]=C.useState(!1),[d,u]=C.useState("all"),[p,f]=C.useState("all"),[y,_]=C.useState("new"),[b,w]=C.useState(new Set),j=C.useCallback(async()=>{try{o(!0);const{data:te,error:Q}=await G.from("profiles").select("id, name, email, phone, is_trial, trial_started_at, trial_expires_at, subscription_status, subscription_end_date, converted_from_trial_at, created_at").or("is_trial.eq.true,subscription_status.eq.trialing,converted_from_trial_at.not.is.null");if(Q)throw Q;const{data:de,error:re}=await G.from("trial_email_exports").select("user_id");if(re)throw re;const ae=new Set((de||[]).map(he=>he.user_id)),le=(te||[]).map(he=>({...he,converted_from_trial_at:he.converted_from_trial_at??null,already_exported:ae.has(he.id)}));le.sort((he,be)=>new Date(be.created_at).getTime()-new Date(he.created_at).getTime()),n(le)}catch(te){console.error("Error loading trial users:",te),s({title:"Error",description:"Failed to load trial users",variant:"destructive"})}finally{o(!1)}},[s]);C.useEffect(()=>{j()},[j]);const k=te=>te.trial_started_at?"ghl":"stripe",S=te=>te.trial_expires_at?te.trial_expires_at:te.subscription_end_date?te.subscription_end_date:null,T=te=>te.converted_from_trial_at!==null,I=te=>{if(T(te))return!1;const Q=S(te);return Q?new Date(Q).getTime()<=Date.now():!1},L=r.filter(te=>!(d!=="all"&&k(te)!==d||p==="active"&&(I(te)||T(te))||p==="expired"&&!I(te)||p==="converted"&&!T(te)||y==="new"&&te.already_exported||y==="exported"&&!te.already_exported)),R=()=>{b.size===L.length?w(new Set):w(new Set(L.map(te=>te.id)))},$=te=>{const Q=new Set(b);Q.has(te)?Q.delete(te):Q.add(te),w(Q)},q=async()=>{if(b.size===0){s({title:"No users selected",description:"Select users to export",variant:"destructive"});return}i(!0);try{const te=r.filter(_e=>b.has(_e.id)),Q="First Name,Last Name,Email,Phone,Trial Type,Status,Signup Date,Expiry Date",de=te.map(_e=>{const je=(_e.name||"").split(" "),Ne=je[0]||"",Ge=je.slice(1).join(" ")||"",we=k(_e)==="stripe"?"Credit Card Trial":"Free Trial (No CC)",Me=T(_e)?"Converted":I(_e)?"Expired":"Active",Te=_e.created_at?new Date(_e.created_at).toLocaleDateString():"",Fe=S(_e)?new Date(S(_e)).toLocaleDateString():"";return`"${Ne}","${Ge}","${_e.email}","${_e.phone||""}","${we}","${Me}","${Te}","${Fe}"`}),re=[Q,...de].join(` `),ae=new Blob([re],{type:"text/csv"}),le=URL.createObjectURL(ae),he=document.createElement("a");he.href=le,he.download=`trial-users-${new Date().toISOString().split("T")[0]}.csv`,he.click(),URL.revokeObjectURL(le);const be=te.filter(_e=>!_e.already_exported).map(_e=>({user_id:_e.id,exported_by:t.id}));if(be.length>0){const{error:_e}=await G.from("trial_email_exports").upsert(be,{onConflict:"user_id"});_e&&console.error("Error marking exports:",_e)}s({title:"Export complete",description:`Downloaded ${te.length} trial user(s). ${be.length} newly marked as exported.`}),w(new Set),j()}catch(te){console.error("Export error:",te),s({title:"Error",description:"Failed to export",variant:"destructive"})}finally{i(!1)}},U=r.filter(te=>!te.already_exported).length,H=r.filter(te=>te.already_exported).length,Y=r.filter(te=>T(te)).length,se=r.filter(te=>!I(te)&&!T(te)).length;return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(It,{className:"pb-2",children:[e.jsx(pr,{children:"Total"}),e.jsx(Ot,{className:"text-2xl",children:r.length})]})}),e.jsx(Ee,{children:e.jsxs(It,{className:"pb-2",children:[e.jsx(pr,{children:"New (Not Exported)"}),e.jsx(Ot,{className:"text-2xl text-green-600",children:U})]})}),e.jsx(Ee,{children:e.jsxs(It,{className:"pb-2",children:[e.jsx(pr,{children:"Active Trials"}),e.jsx(Ot,{className:"text-2xl",children:se})]})}),e.jsx(Ee,{children:e.jsxs(It,{className:"pb-2",children:[e.jsx(pr,{children:"Converted 🎉"}),e.jsx(Ot,{className:"text-2xl text-primary",children:Y})]})}),e.jsx(Ee,{children:e.jsxs(It,{className:"pb-2",children:[e.jsx(pr,{children:"Already Exported"}),e.jsx(Ot,{className:"text-2xl text-muted-foreground",children:H})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(sr,{value:y,onValueChange:te=>_(te),children:[e.jsx(er,{className:"w-[160px]",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Users"}),e.jsx(At,{value:"new",children:"New Only"}),e.jsx(At,{value:"exported",children:"Already Exported"})]})]}),e.jsxs(sr,{value:d,onValueChange:te=>u(te),children:[e.jsx(er,{className:"w-[180px]",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Trial Types"}),e.jsx(At,{value:"stripe",children:"Credit Card Trial"}),e.jsx(At,{value:"ghl",children:"Free Trial (No CC)"})]})]}),e.jsxs(sr,{value:p,onValueChange:te=>f(te),children:[e.jsx(er,{className:"w-[160px]",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Statuses"}),e.jsx(At,{value:"active",children:"Active Trial"}),e.jsx(At,{value:"expired",children:"Expired"}),e.jsx(At,{value:"converted",children:"Converted ✓"})]})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(K,{onClick:q,disabled:l||b.size===0,children:[l?e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Export Selected (",b.size,")"]})})]}),e.jsx("div",{className:"border rounded-lg",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(bt,{className:"w-[40px]",children:e.jsx(Bo,{checked:L.length>0&&b.size===L.length,onCheckedChange:R})}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:"Trial Type"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{children:"Signup Date"}),e.jsx(bt,{children:"Expires / Renews"}),e.jsx(bt,{children:"Exported"})]})}),e.jsx(Pn,{children:L.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No trial users match the current filters"})}):L.map(te=>{const Q=k(te),de=T(te),re=I(te),ae=S(te);return e.jsxs(Ns,{className:`hover:bg-muted/30 ${de?"bg-primary/5":""}`,children:[e.jsx(lt,{children:e.jsx(Bo,{checked:b.has(te.id),onCheckedChange:()=>$(te.id)})}),e.jsx(lt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[te.name,de&&e.jsx(ac,{className:"h-3.5 w-3.5 text-primary"})]})}),e.jsx(lt,{className:"text-muted-foreground",children:te.email}),e.jsx(lt,{children:Q==="stripe"?e.jsxs(rt,{variant:"outline",className:"gap-1",children:[e.jsx(yf,{className:"h-3 w-3"}),"Credit Card"]}):e.jsxs(rt,{variant:"secondary",className:"gap-1",children:[e.jsx(br,{className:"h-3 w-3"}),"Free (No CC)"]})}),e.jsx(lt,{children:de?e.jsxs(rt,{className:"bg-primary/10 text-primary hover:bg-primary/20 gap-1",children:[e.jsx(ac,{className:"h-3 w-3"}),"Converted"]}):re?e.jsx(rt,{variant:"destructive",children:"Expired"}):e.jsx(rt,{className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active Trial"})}),e.jsx(lt,{className:"text-sm",children:te.created_at?new Date(te.created_at).toLocaleDateString():"—"}),e.jsx(lt,{className:"text-sm",children:de&&ae?e.jsxs("span",{className:"text-muted-foreground",children:["Renews ",new Date(ae).toLocaleDateString()]}):ae?new Date(ae).toLocaleDateString():"—"}),e.jsx(lt,{children:te.already_exported?e.jsx(ua,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(rt,{variant:"outline",className:"text-green-600 border-green-300",children:"New"})})]},te.id)})})]})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",L.length," of ",r.length," trial users · ",Y," converted to paid"]})]})},dRt=()=>{const[t,s]=C.useState([]),[r,n]=C.useState(!0);return C.useEffect(()=>{(async()=>{const{data:o,error:l}=await G.from("user_deletion_log").select("*").order("created_at",{ascending:!1});!l&&o&&s(o),n(!1)})()},[]),r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(jr,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{children:"No deletion records yet"})]})}):e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"User Deletion History"})}),e.jsx(Oe,{children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Date"}),e.jsx(bt,{children:"User"}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:"Brokerage"}),e.jsx(bt,{children:"Type"}),e.jsx(bt,{children:"Deleted By"})]})}),e.jsx(Pn,{children:t.map(a=>e.jsxs(Ns,{children:[e.jsx(lt,{className:"whitespace-nowrap text-sm",children:ys(new Date(a.created_at),"MMM d, yyyy h:mm a")}),e.jsx(lt,{className:"font-medium",children:a.deleted_user_name||"—"}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:a.deleted_user_email||"—"}),e.jsx(lt,{children:a.brokerage_name||"—"}),e.jsx(lt,{children:e.jsx(rt,{variant:a.deletion_type==="deleted"?"destructive":"secondary",children:a.deletion_type==="deleted"?"Account Deleted":"Removed"})}),e.jsx(lt,{className:"text-sm",children:a.deleted_by_name||a.deleted_by_email||"—"})]},a.id))})]})})]})},uS=t=>{const{user:s}=Hs(),r=rs(),n=wt({queryKey:["teams",t],queryFn:async()=>{let f=G.from("teams").select("*").order("created_at",{ascending:!1});t&&(f=f.eq("brokerage_id",t));const{data:y,error:_}=await f;if(_)throw _;return y||[]},enabled:!!s}),a=f=>wt({queryKey:["team-members",f],queryFn:async()=>{const{data:y,error:_}=await G.from("team_members").select("*").eq("team_id",f).order("role",{ascending:!0});if(_)throw _;const b=(y||[]).map(k=>k.user_id),{data:w}=await G.from("profiles").select("id, name, email, avatar_url").in("id",b),j=new Map((w||[]).map(k=>[k.id,k]));return(y||[]).map(k=>({...k,profile:j.get(k.user_id)||null}))},enabled:!!f}),o=Dt({mutationFn:async f=>{const y={name:f.name,created_by:s.id,description:f.description,contact_visibility:f.contact_visibility,lead_pond_enabled:f.lead_pond_enabled,shared_assets_enabled:f.shared_assets_enabled};f.brokerage_id&&(y.brokerage_id=f.brokerage_id);const{data:_,error:b}=await G.from("teams").insert(y).select().single();if(b)throw b;return _},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),fe.success("Team created!")},onError:f=>{fe.error("Failed to create team: "+f.message)}}),l=Dt({mutationFn:async({id:f,...y})=>{const{data:_,error:b}=await G.from("teams").update(y).eq("id",f).select().single();if(b)throw b;return _},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),fe.success("Team updated")},onError:f=>{fe.error("Failed to update team: "+f.message)}}),i=Dt({mutationFn:async f=>{const{error:y}=await G.from("teams").delete().eq("id",f);if(y)throw y},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),fe.success("Team deleted")},onError:f=>{fe.error("Failed to delete team: "+f.message)}}),d=Dt({mutationFn:async f=>{const{data:y,error:_}=await G.from("team_members").insert({team_id:f.team_id,user_id:f.user_id,role:f.role||"team_member"}).select().single();if(_)throw _.message.includes("duplicate")||_.message.includes("unique")?new Error("This agent is already on a team. They must be removed from their current team first."):_;return y},onSuccess:(f,y)=>{r.invalidateQueries({queryKey:["team-members",y.team_id]}),fe.success("Member added to team")},onError:f=>{fe.error(f.message)}}),u=Dt({mutationFn:async f=>{const{error:y}=await G.from("team_members").delete().eq("id",f.member_id);if(y)throw y},onSuccess:(f,y)=>{r.invalidateQueries({queryKey:["team-members",y.team_id]}),fe.success("Member removed from team")},onError:f=>{fe.error("Failed to remove member: "+f.message)}}),p=Dt({mutationFn:async f=>{const{error:y}=await G.from("team_members").update({role:f.role}).eq("id",f.member_id);if(y)throw y},onSuccess:(f,y)=>{r.invalidateQueries({queryKey:["team-members",y.team_id]}),fe.success("Member role updated")},onError:f=>{fe.error("Failed to update role: "+f.message)}});return{teams:n.data||[],isLoading:n.isLoading,createTeam:o,updateTeam:l,deleteTeam:i,addMember:d,removeMember:u,updateMemberRole:p,useTeamMembers:a}},uRt=()=>{const{user:t}=Hs();return wt({queryKey:["team-contacts",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.rpc("get_team_contacts",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},DKe=t=>{const{user:s}=Hs(),r=rs(),n=wt({queryKey:["lead-pond",t],queryFn:async()=>{const{data:i,error:d}=await G.from("team_lead_pond").select("*").eq("team_id",t).order("created_at",{ascending:!1});if(d)throw d;if(!i||i.length===0)return[];const u=i.map(k=>k.contact_id),p=[...new Set(i.map(k=>k.added_by))],f=i.filter(k=>k.claimed_by).map(k=>k.claimed_by),y=[...new Set([...p,...f])],[_,b]=await Promise.all([G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").in("id",u),G.from("profiles").select("id, name, avatar_url").in("id",y)]),w=new Map((_.data||[]).map(k=>[k.id,k])),j=new Map((b.data||[]).map(k=>[k.id,k]));return i.map(k=>({...k,status:k.claimed_by?"claimed":"available",contact:w.get(k.contact_id)||null,contributor:j.get(k.added_by)||null,claimer:k.claimed_by&&j.get(k.claimed_by)||null}))},enabled:!!t&&!!s}),a=Dt({mutationFn:async i=>{const{data:d,error:u}=await G.rpc("add_to_lead_pond",{_contact_id:i.contact_id,_team_id:i.team_id,_notes:i.notes||null});if(u)throw u;return d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),fe.success("Contact added to Lead Pond")},onError:i=>{fe.error(i.message)}}),o=Dt({mutationFn:async i=>{const{error:d}=await G.rpc("claim_lead_pond_contact",{_lead_pond_id:i});if(d)throw d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),fe.success("Lead claimed!")},onError:i=>{fe.error(i.message)}}),l=Dt({mutationFn:async i=>{const{error:d}=await G.rpc("return_lead_pond_contact",{_lead_pond_id:i});if(d)throw d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),fe.success("Lead returned to pond")},onError:i=>{fe.error(i.message)}});return{leadPondItems:n.data||[],isLoading:n.isLoading,addToLeadPond:a,claimLead:o,returnLead:l}},hRt=()=>{const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.rpc("transfer_contact",{_contact_id:s.contactId,_to_user_id:s.toUserId,_notes:s.notes||null});if(n)throw n;const a=r;if(!a.success)throw new Error(a.error);return a},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["team-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),fe.success("Contact transferred successfully")},onError:s=>{fe.error(s.message||"Failed to transfer contact")}})};function OKe({open:t,onOpenChange:s,contactIds:r,contactNames:n=[],onComplete:a}){var L;const{user:o}=Hs(),{data:l}=Lf(),{useTeamMembers:i}=uS(),{data:d=[]}=i((l==null?void 0:l.teamId)||""),u=hRt(),[p,f]=C.useState(null),[y,_]=C.useState(""),[b,w]=C.useState(!1),j=d.filter(R=>R.user_id!==(o==null?void 0:o.id)),k=async()=>{if(p){w(!0);try{for(const R of r)await u.mutateAsync({contactId:R,toUserId:p,notes:y||void 0});s(!1),f(null),_(""),a==null||a()}catch{}finally{w(!1)}}},S=j.find(R=>R.user_id===p),T=r.length>1,I=n.length>0?T?`${n.length} contacts`:n[0]:T?`${r.length} contacts`:"this contact";return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(A0,{className:"h-5 w-5"}),"Transfer ",I]}),e.jsxs(Kr,{children:["Select a team member to transfer ",T?"these contacts":"this contact"," to. The contact will be removed from the current owner's CRM and added to the selected member's."]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium mb-2 block",children:"Transfer to:"}),e.jsx("div",{className:"space-y-1 max-h-[240px] overflow-y-auto",children:j.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No other team members available"}):j.map(R=>{var $,q,U;return e.jsxs("button",{onClick:()=>f(R.user_id),className:`w-full flex items-center gap-3 p-3 rounded-lg text-left transition-colors ${p===R.user_id?"bg-primary/10 border border-primary/30":"hover:bg-accent border border-transparent"}`,children:[e.jsxs(xn,{className:"h-8 w-8",children:[e.jsx(Aa,{src:(($=R.profile)==null?void 0:$.avatar_url)||""}),e.jsx(yn,{className:"text-xs",children:(((q=R.profile)==null?void 0:q.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:((U=R.profile)==null?void 0:U.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:R.role.replace("_"," ")})]})]},R.user_id)})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"transfer-notes",className:"text-sm font-medium",children:"Notes (optional)"}),e.jsx(Ar,{id:"transfer-notes",value:y,onChange:R=>_(R.target.value),placeholder:"Reason for transfer...",className:"mt-1",rows:2})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:k,disabled:!p||b,children:[b?e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(A0,{className:"h-4 w-4 mr-2"}),"Transfer",S?` to ${(L=S.profile)==null?void 0:L.name}`:""]})]})]})})}const bwe=()=>{const t=Pr(),{data:s,isLoading:r}=uRt(),{data:n}=Lf(),[a,o]=C.useState(""),[l,i]=C.useState("all"),[d,u]=C.useState(null),[p,f]=C.useState(""),y=(n==null?void 0:n.role)==="team_leader",_=C.useMemo(()=>{if(!s)return[];const w=new Map;return s.forEach(j=>{w.has(j.owner_user_id)||w.set(j.owner_user_id,{id:j.owner_user_id,name:j.owner_name||"Unknown",avatar:j.owner_avatar_url})}),Array.from(w.values())},[s]),b=C.useMemo(()=>{if(!s)return[];let w=s;if(l!=="all"&&(w=w.filter(j=>j.owner_user_id===l)),a.trim()){const j=a.toLowerCase();w=w.filter(k=>{var S,T,I;return(k.first_name+" "+(k.last_name||"")).toLowerCase().includes(j)||((S=k.email)==null?void 0:S.toLowerCase().includes(j))||((T=k.phone)==null?void 0:T.includes(j))||((I=k.owner_name)==null?void 0:I.toLowerCase().includes(j))})}return w},[s,a,l]);return r?e.jsxs("div",{className:"space-y-4",children:[e.jsx(xs,{className:"h-10 w-full"}),e.jsx(xs,{className:"h-64 w-full"})]}):!s||s.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Team Contacts"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Team contact sharing is not enabled, or you're not on a team. Ask your manager about contact visibility settings."})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name, email, phone, or agent...",value:a,onChange:w=>o(w.target.value),className:"pl-9"})]}),e.jsxs(sr,{value:l,onValueChange:i,children:[e.jsx(er,{className:"w-[200px]",children:e.jsx(rr,{placeholder:"Filter by agent"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Team Members"}),_.map(w=>e.jsx(At,{value:w.id,children:w.name},w.id))]})]})]})})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[b.length," contact",b.length!==1?"s":""," from ",_.length," teammate",_.length!==1?"s":""]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0 overflow-x-auto",children:e.jsxs(An,{className:"min-w-[800px]",children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Agent"}),e.jsx(bt,{children:"Contact Info"}),e.jsx(bt,{children:"Address"}),e.jsx(bt,{children:"Lead Source"}),e.jsx(bt,{children:"Date Added"}),y&&e.jsx(bt,{className:"w-[80px]",children:"Actions"})]})}),e.jsx(Pn,{children:b.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:y?7:6,className:"text-center py-8 text-muted-foreground",children:a||l!=="all"?"No contacts match your filters":"No team contacts available"})}):b.map(w=>e.jsxs(Ns,{className:`hover:bg-accent/50 ${y?"cursor-pointer":""}`,onClick:y?()=>t(`/mission-control/contacts/${w.id}`):void 0,children:[e.jsx(lt,{className:"font-medium",children:e.jsxs("span",{className:y?"hover:text-primary hover:underline transition-colors":"",children:[w.first_name," ",w.last_name||""]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(xn,{className:"h-6 w-6",children:[e.jsx(Aa,{src:w.owner_avatar_url||""}),e.jsx(yn,{className:"text-[10px]",children:(w.owner_name||"?").charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:w.owner_name||"Unknown"})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[w.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(br,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:w.email})]}),w.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Qn,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:w.phone})]}),!w.email&&!w.phone&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No contact info"})]})}),e.jsx(lt,{children:w.address?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(Oi,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:w.address})]}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(lt,{children:w.lead_source?e.jsx(rt,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:w.lead_source}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(lt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ys(new Date(w.created_at),"MMM d, yyyy")})}),y&&e.jsx(lt,{children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:j=>{j.stopPropagation(),u(w.id),f(`${w.first_name} ${w.last_name||""}`.trim())},title:"Transfer to team member",children:e.jsx(A0,{className:"h-4 w-4"})})})]},w.id))})]})})}),e.jsx(OKe,{open:!!d,onOpenChange:w=>{w||u(null)},contactIds:d?[d]:[],contactNames:p?[p]:[],onComplete:()=>u(null)})]})},wwe=({teamId:t})=>{const{user:s}=Hs(),{leadPondItems:r,isLoading:n,claimLead:a,returnLead:o}=DKe(t);if(console.log("[LeadPondView] render — teamId:",t,"itemCount:",r.length,"loading:",n),n)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(d=>e.jsx(xs,{className:"h-20 w-full"},d))});if(r.length===0)return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Vg,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Lead Pond is Empty"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Team members can contribute contacts here for others to claim and follow up with."})]})});const l=r.filter(d=>d.status==="available"),i=r.filter(d=>d.status==="claimed");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:["Available (",l.length,")"]}),l.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No leads available right now."}):e.jsx("div",{className:"space-y-2",children:l.map(d=>{var u,p,f,y,_,b,w;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=d.contact)==null?void 0:u.first_name," ",((p=d.contact)==null?void 0:p.last_name)||""]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 mt-1",children:[((f=d.contact)==null?void 0:f.email)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(br,{className:"h-3 w-3"})," ",d.contact.email]}),((y=d.contact)==null?void 0:y.phone)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Qn,{className:"h-3 w-3"})," ",d.contact.phone]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs(xn,{className:"h-4 w-4",children:[e.jsx(Aa,{src:((_=d.contributor)==null?void 0:_.avatar_url)||""}),e.jsx(yn,{className:"text-[8px]",children:(((b=d.contributor)==null?void 0:b.name)||"?").charAt(0)})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["from ",((w=d.contributor)==null?void 0:w.name)||"Unknown"]})]})]}),e.jsxs(K,{size:"sm",onClick:()=>a.mutate(d.id),disabled:a.isPending,children:[e.jsx(pP,{className:"mr-1 h-3 w-3"}),"Claim"]})]})},d.id)})})]}),i.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:["Claimed (",i.length,")"]}),e.jsx("div",{className:"space-y-2",children:i.map(d=>{var u,p,f;return e.jsx(Ee,{className:"opacity-75",children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=d.contact)==null?void 0:u.first_name," ",((p=d.contact)==null?void 0:p.last_name)||""]}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs(rt,{variant:"secondary",className:"text-xs",children:["Claimed by ",((f=d.claimer)==null?void 0:f.name)||"Unknown"]})})]}),d.claimed_by===(s==null?void 0:s.id)&&e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>o.mutate(d.id),disabled:o.isPending,children:[e.jsx(q0,{className:"mr-1 h-3 w-3"}),"Return"]})]})},d.id)})})]})]})},RKe=({teamId:t})=>{const{useTeamMembers:s}=uS(),{data:r=[]}=s(t),n=r.map(_=>_.user_id),a=new Map(r.map(_=>[_.user_id,_.profile])),{data:o=[],isLoading:l}=wt({queryKey:["team-shared-presentations",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await G.from("smart_presentations").select("id, owner_user_id, title, client_name, status, view_count, cta_clicked_count, share_token, created_at, published_at").in("owner_user_id",n).neq("status","archived").order("created_at",{ascending:!1});if(b)throw b;return _||[]},enabled:n.length>0}),{data:i=[],isLoading:d}=wt({queryKey:["team-shared-open-houses",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await G.from("open_houses").select("id, agent_id, property_address, city, state, event_date, is_active, visitor_count, slug, created_at").in("agent_id",n).order("event_date",{ascending:!1});if(b)throw b;return _||[]},enabled:n.length>0}),{data:u=[],isLoading:p}=wt({queryKey:["team-shared-videos",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await G.from("agent_videos").select("id, owner_user_id, title, recipient_name, status, view_count, touch_type, share_token, created_at").in("owner_user_id",n).eq("is_deleted",!1).order("created_at",{ascending:!1}).limit(50);if(b)throw b;return _||[]},enabled:n.length>0});if(l||d||p)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(_=>e.jsx(xs,{className:"h-20 w-full"},_))});const y=_=>{const b=a.get(_);return{name:(b==null?void 0:b.name)||"Unknown",avatar:(b==null?void 0:b.avatar_url)||"",initials:((b==null?void 0:b.name)||"?").charAt(0).toUpperCase()}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-3",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(Hg,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:o.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Presentations"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(On,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:i.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Guest Books"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(Nn,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:u.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]}),e.jsxs(ka,{defaultValue:"presentations",className:"space-y-4",children:[e.jsxs(_a,{children:[e.jsxs(js,{value:"presentations",children:["Presentations (",o.length,")"]}),e.jsxs(js,{value:"guest-books",children:["Guest Books (",i.length,")"]}),e.jsxs(js,{value:"videos",children:["Videos (",u.length,")"]})]}),e.jsx(zs,{value:"presentations",className:"space-y-2",children:o.length===0?e.jsx(epe,{icon:e.jsx(Hg,{className:"h-10 w-10"}),label:"No presentations yet"}):o.map(_=>{const b=y(_.owner_user_id);return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(xn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Aa,{src:b.avatar}),e.jsx(yn,{className:"text-xs",children:b.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:_.title||"Untitled"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b.name," · ",ys(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(rt,{variant:_.status==="published"?"default":"secondary",className:"text-xs capitalize",children:_.status}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(xa,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})}),e.jsx(zs,{value:"guest-books",className:"space-y-2",children:i.length===0?e.jsx(epe,{icon:e.jsx(On,{className:"h-10 w-10"}),label:"No guest books yet"}):i.map(_=>{const b=y(_.agent_id);return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(xn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Aa,{src:b.avatar}),e.jsx(yn,{className:"text-xs",children:b.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:_.property_address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b.name," · ",ys(new Date(_.event_date),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[_.is_active?e.jsx(rt,{className:"text-xs",children:"Active"}):e.jsx(rt,{variant:"secondary",className:"text-xs",children:"Inactive"}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(hr,{className:"h-3 w-3"}),_.visitor_count||0]})]})]})},_.id)})}),e.jsx(zs,{value:"videos",className:"space-y-2",children:u.length===0?e.jsx(epe,{icon:e.jsx(Nn,{className:"h-10 w-10"}),label:"No videos yet"}):u.map(_=>{const b=y(_.owner_user_id);return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(xn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Aa,{src:b.avatar}),e.jsx(yn,{className:"text-xs",children:b.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:_.title||_.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b.name," · ",ys(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(rt,{variant:"secondary",className:"text-xs capitalize",children:_.touch_type}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(xa,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})})]})]})},epe=({icon:t,label:s})=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-8 text-center text-muted-foreground",children:[t,e.jsx("p",{className:"mt-2 text-sm",children:s})]})}),FKe=({team:t,brokerageAgents:s,onBack:r,onUpdate:n,onAddMember:a,onRemoveMember:o,onUpdateRole:l,onDeleteTeam:i,isUpdating:d,isAddingMember:u})=>{var $,q;const{useTeamMembers:p}=uS(),{data:f=[],isLoading:y}=p(t.id),[_,b]=C.useState(!1),[w,j]=C.useState(""),[k,S]=C.useState("team_member"),{data:T}=wt({queryKey:["agents-on-other-teams",t.id],queryFn:async()=>{const{data:U}=await G.from("team_members").select("user_id, team_id, teams:team_id(name)").neq("team_id",t.id),H=new Map;return(U||[]).forEach(Y=>{var se;H.set(Y.user_id,((se=Y.teams)==null?void 0:se.name)||"another team")}),H}}),I=new Set(f.map(U=>U.user_id)),L=s.filter(U=>!I.has(U.id)),R=async()=>{w&&(await a(w,k),j(""),S("team_member"),b(!1))};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(K,{variant:"ghost",onClick:r,className:"mb-2",children:"← Back to Teams"}),e.jsxs(ka,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(_a,{children:[e.jsx(js,{value:"members",children:"Members"}),e.jsxs(js,{value:"contacts",children:[e.jsx(ok,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),t.lead_pond_enabled&&e.jsxs(js,{value:"lead-pond",children:[e.jsx(Vg,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),t.shared_assets_enabled&&e.jsxs(js,{value:"shared-assets",children:[e.jsx(Vh,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]}),e.jsx(js,{value:"settings",children:"Settings"})]}),e.jsxs(zs,{value:"members",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold",children:[t.name," — Members"]}),e.jsxs(_s,{open:_,onOpenChange:b,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(yc,{className:"mr-2 h-4 w-4"}),"Add Member"]})}),e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Add Team Member"}),e.jsxs(Kr,{children:["Select an agent from your brokerage to add to ",t.name,"."]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Agent"}),e.jsxs(Co,{children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[w&&((($=L.find(U=>U.id===w))==null?void 0:$.name)||((q=L.find(U=>U.id===w))==null?void 0:q.email))||"Select an agent",e.jsx(xf,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(No,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Mf,{children:[e.jsx(Tf,{placeholder:"Search agents..."}),e.jsxs(Af,{children:[e.jsx(Ef,{children:"No agents found."}),e.jsx(Pf,{children:L.map(U=>{const H=T==null?void 0:T.get(U.id);return e.jsxs(Cm,{value:U.name||U.email||U.id,disabled:!!H,onSelect:()=>j(U.id),children:[e.jsx(ha,{className:Pt("mr-2 h-4 w-4",w===U.id?"opacity-100":"opacity-0")}),U.name||U.email,H&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(on ",H,")"]})]},U.id)})})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Role"}),e.jsxs(sr,{value:k,onValueChange:S,children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"team_leader",children:"Team Leader"}),e.jsx(At,{value:"team_member",children:"Team Member"})]})]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(K,{onClick:R,disabled:!w||u,children:u?"Adding...":"Add to Team"})]})]})]})]}),y?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(U=>e.jsx(xs,{className:"h-16 w-full"},U))}):f.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(hr,{className:"h-10 w-10 text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No members yet. Add agents to this team."})]})}):e.jsx("div",{className:"space-y-2",children:f.map(U=>{var H,Y,se,te,Q;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(xn,{className:"h-10 w-10",children:[e.jsx(Aa,{src:((H=U.profile)==null?void 0:H.avatar_url)||""}),e.jsx(yn,{children:(((Y=U.profile)==null?void 0:Y.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((se=U.profile)==null?void 0:se.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(te=U.profile)==null?void 0:te.email})]}),U.role==="team_leader"?e.jsxs(rt,{className:"bg-[hsl(var(--chart-4)/0.1)] text-[hsl(var(--chart-4))] border-[hsl(var(--chart-4))]",children:[e.jsx(Uh,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(rt,{variant:"secondary",children:"Member"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(sr,{value:U.role,onValueChange:de=>l(U.id,de),children:[e.jsx(er,{className:"w-[140px]",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"team_leader",children:"Team Leader"}),e.jsx(At,{value:"team_member",children:"Team Member"})]})]}),e.jsxs(nc,{children:[e.jsx(Rh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",children:e.jsx(WP,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Remove Member?"}),e.jsxs(Dl,{children:["Remove ",((Q=U.profile)==null?void 0:Q.name)||"this member"," from ",t.name,"?"]})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>o(U.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})]})]})]})},U.id)})})]}),e.jsx(zs,{value:"contacts",className:"space-y-4",children:e.jsx(bwe,{})}),t.lead_pond_enabled&&e.jsx(zs,{value:"lead-pond",className:"space-y-4",children:e.jsx(wwe,{teamId:t.id})}),t.shared_assets_enabled&&e.jsx(zs,{value:"shared-assets",className:"space-y-4",children:e.jsx(RKe,{teamId:t.id})}),e.jsxs(zs,{value:"settings",className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{className:"text-lg",children:"Team Settings"}),e.jsx(pr,{children:"Configure how this team operates."})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Team Name"}),e.jsx(Re,{defaultValue:t.name,onBlur:U=>{U.target.value!==t.name&&n({name:U.target.value})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Ar,{defaultValue:t.description||"",onBlur:U=>{U.target.value!==(t.description||"")&&n({description:U.target.value||null})},rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Contact Visibility"}),e.jsxs(sr,{defaultValue:t.contact_visibility,onValueChange:U=>n({contact_visibility:U}),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"private",children:"Private — Members keep their contacts private"}),e.jsx(At,{value:"leader_only",children:"Leader Only — Only team leaders can see member contacts"}),e.jsx(At,{value:"full_team",children:"Full Team — All team members can see shared contacts"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls whether team leaders and members can view each other's contacts."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Lead Pond"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable a shared lead pool where leaders can drop leads for members to claim."})]}),e.jsx(Br,{checked:t.lead_pond_enabled,onCheckedChange:U=>n({lead_pond_enabled:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Shared Assets"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow team members to access shared presentations, guest books, and videos."})]}),e.jsx(Br,{checked:t.shared_assets_enabled,onCheckedChange:U=>n({shared_assets_enabled:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Shared Video Library"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Let team members browse and use each other's videos from the Video Library."})]}),e.jsx(Br,{checked:t.shared_videos_enabled??!1,onCheckedChange:U=>n({shared_videos_enabled:U})})]})]})]}),e.jsxs(nc,{children:[e.jsx(Rh,{asChild:!0,children:e.jsxs(K,{variant:"destructive",size:"sm",children:[e.jsx(jr,{className:"mr-2 h-4 w-4"}),"Delete Team"]})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete Team?"}),e.jsxs(Dl,{children:['This will permanently delete "',t.name,'" and remove all team members. This cannot be undone.']})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>{i(),r()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Team"})]})]})]})]})]})]})},zKe=({open:t,onOpenChange:s,onCreateTeam:r,isCreating:n,brokerageAgents:a,isAdmin:o,allBrokerages:l,activeBrokerageId:i})=>{const[d,u]=C.useState(1),[p,f]=C.useState(""),[y,_]=C.useState(""),[b,w]=C.useState(""),[j,k]=C.useState(""),[S,T]=C.useState([]),I=()=>{u(1),f(""),_(""),w(""),k(""),T([])},L=U=>{U||I(),s(U)},R=async()=>{const U=b&&b!=="none"?b:i||null;await r({name:p.trim(),description:y.trim()||void 0,brokerage_id:U,leaderId:j||void 0,memberIds:S.length>0?S:void 0}),I()},$=U=>{U!==j&&T(H=>H.includes(U)?H.filter(Y=>Y!==U):[...H,U])},q=a.filter(U=>U.id!==j);return e.jsx(_s,{open:t,onOpenChange:L,children:e.jsxs(vs,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:d===1?"Create New Team":"Assign Team Members"}),e.jsx(Kr,{children:d===1?"Name your team and add a description.":"Pick a leader and optionally add initial members."}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx("div",{className:Pt("h-1.5 flex-1 rounded-full transition-colors","bg-primary")}),e.jsx("div",{className:Pt("h-1.5 flex-1 rounded-full transition-colors",d===2?"bg-primary":"bg-muted")})]})]}),e.jsx("div",{className:"overflow-y-auto flex-1 pr-1",children:d===1?e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"team-name",children:"Team Name *"}),e.jsx(Re,{id:"team-name",value:p,onChange:U=>f(U.target.value),placeholder:"e.g., Downtown Squad",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"team-desc",children:"Description"}),e.jsx(Ar,{id:"team-desc",value:y,onChange:U=>_(U.target.value),placeholder:"What is this team focused on?",rows:3})]}),o&&l&&l.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Brokerage"}),e.jsxs(sr,{value:b,onValueChange:w,children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"No brokerage (independent team)"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"none",children:"No brokerage (independent)"}),l.map(U=>e.jsx(At,{value:U.id,children:U.name},U.id))]})]})]})]}):e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(Uh,{className:"h-3.5 w-3.5 text-[hsl(var(--chart-4))]"}),"Team Leader"]}),e.jsxs(sr,{value:j,onValueChange:U=>{k(U),T(H=>H.filter(Y=>Y!==U))},children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select a team leader (optional)"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"none",children:"No leader for now"}),a.map(U=>e.jsx(At,{value:U.id,children:U.name||U.email||"Unknown"},U.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(yc,{className:"h-3.5 w-3.5"}),"Initial Members",S.length>0&&e.jsxs(rt,{variant:"secondary",className:"ml-1 text-xs",children:[S.length," selected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click agents to add them. You can always add more later."}),e.jsx("div",{className:"border rounded-lg max-h-[240px] overflow-y-auto divide-y",children:q.length===0?e.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:[e.jsx(hr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"No agents available"]}):q.map(U=>{const H=S.includes(U.id);return e.jsxs("button",{type:"button",className:Pt("w-full flex items-center gap-3 p-3 text-left transition-colors hover:bg-accent/50",H&&"bg-primary/5"),onClick:()=>$(U.id),children:[e.jsxs(xn,{className:"h-8 w-8",children:[e.jsx(Aa,{src:U.avatar_url||""}),e.jsx(yn,{className:"text-xs",children:(U.name||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:U.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:U.email})]}),e.jsx("div",{className:Pt("h-5 w-5 rounded-full border-2 flex items-center justify-center transition-colors shrink-0",H?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30"),children:H&&e.jsx(ha,{className:"h-3 w-3"})})]},U.id)})})]})]})}),e.jsx(Un,{className:"gap-2 sm:gap-0",children:d===1?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>u(2),disabled:!p.trim(),children:["Next",e.jsx($i,{className:"ml-2 h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>u(1),children:[e.jsx(ti,{className:"mr-2 h-4 w-4"}),"Back"]}),e.jsx(K,{onClick:R,disabled:n,children:n?"Creating…":"Create Team"})]})})]})})},mRt=()=>{const{teams:t,isLoading:s,createTeam:r,updateTeam:n,deleteTeam:a,addMember:o,removeMember:l,updateMemberRole:i}=uS(),[d,u]=C.useState(!1),[p,f]=C.useState(null),[y,_]=C.useState(""),{data:b}=wt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:L,error:R}=await G.from("brokerages").select("id, name").order("name");if(R)throw R;return L||[]}}),{data:w}=wt({queryKey:["admin-team-member-info",t.map(L=>L.id).join(",")],queryFn:async()=>{var U;if(t.length===0)return{};const{data:L}=await G.from("team_members").select("team_id, user_id, role").in("team_id",t.map(H=>H.id));if(!L)return{};const R=L.filter(H=>H.role==="team_leader").map(H=>H.user_id);let $={};if(R.length>0){const{data:H}=await G.from("profiles").select("id, name").in("id",R);H&&($=Object.fromEntries(H.map(Y=>[Y.id,{name:Y.name}])))}const q={};for(const H of t){const Y=L.filter(te=>te.team_id===H.id),se=Y.find(te=>te.role==="team_leader");q[H.id]={count:Y.length,leaderName:se&&((U=$[se.user_id])==null?void 0:U.name)||null}}return q},enabled:t.length>0}),j=(p==null?void 0:p.brokerage_id)||null,{data:k}=wt({queryKey:["brokerage-agents-for-teams",j],queryFn:async()=>{let L=G.from("profiles").select("id, name, email, avatar_url").order("name");j&&(L=L.eq("brokerage_id",j));const{data:R,error:$}=await L;if($)throw $;return R||[]},enabled:!!p}),S=Object.fromEntries((b||[]).map(L=>[L.id,L.name])),T=async L=>{const R=await r.mutateAsync({name:L.name,brokerage_id:L.brokerage_id||null,description:L.description});if(L.leaderId&&L.leaderId!=="none"&&await o.mutateAsync({team_id:R.id,user_id:L.leaderId,role:"team_leader"}),L.memberIds)for(const $ of L.memberIds)await o.mutateAsync({team_id:R.id,user_id:$,role:"team_member"});u(!1)};if(p)return e.jsx(FKe,{team:p,brokerageAgents:k||[],onBack:()=>f(null),onUpdate:L=>n.mutateAsync({id:p.id,...L}).then(R=>f(R)),onAddMember:(L,R)=>o.mutateAsync({team_id:p.id,user_id:L,role:R}),onRemoveMember:L=>l.mutateAsync({team_id:p.id,member_id:L}),onUpdateRole:(L,R)=>i.mutateAsync({team_id:p.id,member_id:L,role:R}),onDeleteTeam:()=>{a.mutate(p.id),f(null)},isUpdating:n.isPending,isAddingMember:o.isPending});const I=t.filter(L=>L.name.toLowerCase().includes(y.toLowerCase())||(L.description||"").toLowerCase().includes(y.toLowerCase()));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search teams...",value:y,onChange:L=>_(L.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[I.length," of ",t.length," teams"]})]}),e.jsxs(K,{size:"sm",onClick:()=>u(!0),children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(zKe,{open:d,onOpenChange:u,onCreateTeam:T,isCreating:r.isPending,brokerageAgents:[],isAdmin:!0,allBrokerages:b,activeBrokerageId:null}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(bt,{className:"font-semibold",children:"Team Name"}),e.jsx(bt,{className:"font-semibold",children:"Brokerage"}),e.jsx(bt,{className:"font-semibold",children:"Leader"}),e.jsx(bt,{className:"font-semibold",children:"Members"}),e.jsx(bt,{className:"font-semibold",children:"Visibility"}),e.jsx(bt,{className:"w-[100px]"})]})}),e.jsx(Pn,{children:s?e.jsx(e.Fragment,{children:[1,2,3].map(L=>e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsx(xs,{className:"h-4 w-32"})}),e.jsx(lt,{children:e.jsx(xs,{className:"h-4 w-24"})}),e.jsx(lt,{children:e.jsx(xs,{className:"h-4 w-28"})}),e.jsx(lt,{children:e.jsx(xs,{className:"h-4 w-12"})}),e.jsx(lt,{children:e.jsx(xs,{className:"h-4 w-20"})}),e.jsx(lt,{children:e.jsx(xs,{className:"h-4 w-16"})})]},L))}):I.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:6,className:"text-center py-12 text-muted-foreground",children:y?"No teams match your search":"No teams found. Create one to get started."})}):I.map(L=>{const R=w==null?void 0:w[L.id];return e.jsxs(Ns,{className:"hover:bg-muted/30",children:[e.jsxs(lt,{children:[e.jsx("button",{onClick:()=>f(L),className:"text-primary hover:underline font-medium",children:L.name}),L.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:L.description})]}),e.jsx(lt,{children:L.brokerage_id?e.jsx("span",{className:"text-sm",children:S[L.brokerage_id]||"—"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Independent"})}),e.jsx(lt,{children:R!=null&&R.leaderName?e.jsxs("span",{className:"text-sm flex items-center gap-1",children:[e.jsx(Uh,{className:"h-3 w-3 text-[hsl(var(--chart-4))]"}),R.leaderName]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No leader"})}),e.jsx(lt,{children:e.jsxs(rt,{variant:"secondary",className:"text-xs",children:[e.jsx(hr,{className:"h-3 w-3 mr-1"}),(R==null?void 0:R.count)??0]})}),e.jsx(lt,{children:e.jsxs("span",{className:"text-xs text-muted-foreground capitalize flex items-center gap-1",children:[e.jsx(ih,{className:"h-3 w-3"}),L.contact_visibility.replace("_"," ")]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>f(L),title:"Edit team",children:e.jsx(Da,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>{confirm(`Delete team "${L.name}"? This cannot be undone.`)&&a.mutate(L.id)},title:"Delete team",children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})})]},L.id)})})]})})]})},pRt=()=>{const t=Pr(),{user:s,isAdmin:r}=Hs(),{startImpersonation:n,isLoading:a}=B1e(),{toast:o}=Pa(),[l,i]=C.useState([]),[d,u]=C.useState([]),[p,f]=C.useState([]),[y,_]=C.useState({}),[b,w]=C.useState(!0),[j,k]=C.useState({}),[S,T]=C.useState(!1),[I,L]=C.useState({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),[R,$]=C.useState(!1),[q,U]=C.useState(""),[H,Y]=C.useState(1),[se,te]=C.useState(50),[Q,de]=C.useState("all"),[re,ae]=C.useState("all"),[le,he]=C.useState("all"),[be,_e]=C.useState("all"),[je,Ne]=C.useState(!1),[Ge,we]=C.useState(!1),[Me,Te]=C.useState(null),[Fe,Ae]=C.useState(null),[Ue,ut]=C.useState(!1),[De,Rt]=C.useState({name:"",email:"",brokerage_id:"",phone:""}),[me,Xe]=C.useState(null),[ot,nt]=C.useState(!1),[Se,it]=C.useState(""),[$e,ct]=C.useState(!1),[qe,Ze]=C.useState(!1),[Qe,We]=C.useState(null),[He,et]=C.useState(""),[Tt,Ft]=C.useState(!1),[as,Xt]=C.useState(!1),[ss,is]=C.useState(null),[ar,Ct]=C.useState(!1),[Is,qs]=C.useState(!1),[gr,Wn]=C.useState(null),[ii,bo]=C.useState(""),[si,nn]=C.useState(!1),[ia,kn]=C.useState({email:"",name:"",password:"",phone:""}),[sa,Zt]=C.useState(!1),[$r,es]=C.useState(!1),[an,Ra]=C.useState(""),[Zn,Ir]=C.useState(!1),[mi,Go]=C.useState(!1),[yi,Vl]=C.useState(""),[Vt,ye]=C.useState(new Set),[ze,Je]=C.useState(!1),[St,Nt]=C.useState(!1),[Bt,Kt]=C.useState(null),[qt,Qt]=C.useState(!1),[As,gs]=C.useState(null),[fr,qr]=C.useState([]),[ur,Cn]=C.useState([]),[Mn,wn]=C.useState(!1),[ma,lo]=C.useState({});C.useEffect(()=>{!s||!r||(Va(),Ko())},[s,r]);const qo=async()=>{try{const{data:xt,error:Cs}=await G.from("brokerage_manager_assignments").select("user_id, brokerage_id");if(Cs)throw Cs;const Ks={};for(const ln of xt??[])Ks[ln.brokerage_id]||(Ks[ln.brokerage_id]=[]),Ks[ln.brokerage_id].push(ln.user_id);_(Ks)}catch(xt){console.error("Error loading brokerage manager assignments:",xt)}},Va=async()=>{try{w(!0);const{data:xt,error:Cs}=await G.functions.invoke("get-user-details");if(Cs)throw Cs;const Ks=xt.users||[];i(Ks),f(xt.brokerages||[]),await qo();const ln=Ks.filter(cn=>cn.roles.includes("assistant"));if(ln.length>0){const cn=ln.map(Fr=>Fr.id),{data:ta}=await G.from("agent_assistant_assignments").select("agent_id, assistant_id").in("assistant_id",cn);if(ta&&ta.length>0){const Fr=[...new Set(ta.map(Hm=>Hm.agent_id))],{data:eo}=await G.from("profiles").select("id, name, email").in("id",Fr),Uf={};for(const Hm of ta){const Hr=eo==null?void 0:eo.find(Ty=>Ty.id===Hm.agent_id);Hr&&(Uf[Hm.assistant_id]={agent_name:Hr.name||"",agent_email:Hr.email||""})}lo(Uf)}}}catch(xt){console.error("Error loading members:",xt),o({title:"Error",description:"Failed to load members",variant:"destructive"})}finally{w(!1)}},Ko=async()=>{try{const{data:xt,error:Cs}=await G.from("app_tiles").select("id, name, icon, app_id, required_tags").order("name");if(Cs)throw Cs;u(xt||[])}catch(xt){console.error("Error loading apps:",xt),o({title:"Error",description:"Failed to load apps",variant:"destructive"})}},Xi=async xt=>{if(!De.name.trim()||!De.email.trim()){o({title:"Error",description:"Name and email are required",variant:"destructive"});return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(De.email)){o({title:"Error",description:"Please enter a valid email address",variant:"destructive"});return}try{const{error:Ks}=await G.from("profiles").update({name:De.name.trim(),email:De.email.trim(),brokerage_id:De.brokerage_id||null,phone:De.phone.trim()||null}).eq("id",xt);if(Ks)throw Ks;o({title:"Success",description:"Member details updated successfully"}),Te(null),Va()}catch(Ks){console.error("Error updating member:",Ks),o({title:"Error",description:Ks.message||"Failed to update member",variant:"destructive"})}},ba=async xt=>{try{const{data:{session:Cs}}=await G.auth.getSession(),Ks=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Cs==null?void 0:Cs.access_token}`},body:JSON.stringify({userId:xt})}),ln=await Ks.json();if(!Ks.ok)throw new Error(ln.error||"Failed to resend welcome email");o({title:"Success",description:"Welcome email sent successfully"})}catch(Cs){console.error("Error resending welcome email:",Cs),o({title:"Error",description:Cs.message||"Failed to resend welcome email",variant:"destructive"})}},Qi=async(xt,Cs)=>{try{const{error:Ks}=await G.functions.invoke("send-password-reset",{body:{email:xt,redirectTo:window.location.origin}});if(Ks)throw Ks;o({title:"Password Reset Sent",description:`Password reset email sent to ${Cs}`})}catch(Ks){console.error("Error sending password reset:",Ks),o({title:"Error",description:Ks.message||"Failed to send password reset email",variant:"destructive"})}},vi=async(xt,Cs)=>{if(confirm(`Are you sure you want to delete ${Cs}? This action cannot be undone.`))try{const{data:{session:Ks}}=await G.auth.getSession(),ln=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ks==null?void 0:Ks.access_token}`},body:JSON.stringify({userId:xt})}),cn=await ln.json();if(!ln.ok)throw new Error(cn.error||"Failed to delete user");o({title:"Success",description:"User deleted successfully"}),Va()}catch(Ks){console.error("Error deleting user:",Ks),o({title:"Error",description:Ks.message||"Failed to delete user",variant:"destructive"})}},ra=async()=>{if(!I.email||!I.name||!I.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}if(I.role==="brokerage_manager"&&!I.brokerage_id){o({title:"Error",description:"Please select a brokerage for this manager",variant:"destructive"});return}T(!0);try{const{data:{session:xt}}=await G.auth.getSession(),Cs=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${xt==null?void 0:xt.access_token}`},body:JSON.stringify(I)}),Ks=await Cs.json();if(!Cs.ok)throw new Error(Ks.error||"Failed to create user");if(I.role&&I.role!=="user"&&Ks.userId){const ln=I.role==="brokerage_manager"?I.brokerage_id:void 0;await Ji(Ks.userId,I.role,"add",ln)}o({title:"Success",description:`User ${I.email} created successfully`}),L({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),$(!1),Va()}catch(xt){console.error("Error creating user:",xt),o({title:"Error",description:xt.message||"Failed to create user",variant:"destructive"})}finally{T(!1)}},Ji=async(xt,Cs,Ks,ln)=>{try{const{data:{session:cn}}=await G.auth.getSession(),ta={userId:xt,role:Cs,action:Ks};if(Cs==="brokerage_manager"){if(!ln){o({title:"Error",description:"Please choose a brokerage for this manager assignment",variant:"destructive"});return}ta.brokerageId=ln}const Fr=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${cn==null?void 0:cn.access_token}`},body:JSON.stringify(ta)}),eo=await Fr.json();if(!Fr.ok)throw new Error(eo.error||"Failed to manage user role");o({title:"Success",description:`Role ${Ks==="add"?"added":"removed"} successfully`}),Va()}catch(cn){console.error("Error managing user role:",cn),o({title:"Error",description:cn.message||"Failed to manage user role",variant:"destructive"})}},ic=(xt,Cs)=>Cs.length===0?!0:Cs.some(Ks=>xt.includes(Ks)),vc=async(xt,Cs,Ks)=>{const ln=`${xt}-${Cs.id}`;Xe(ln);try{if(Ks){const cn=l.find(Fr=>Fr.id===xt),ta=Cs.required_tags.filter(Fr=>cn==null?void 0:cn.tags.includes(Fr));for(const Fr of ta){const{error:eo}=await G.from("user_tags").delete().eq("user_id",xt).eq("tag",Fr);if(eo)throw eo}o({title:"Access Removed",description:`Removed access to ${Cs.name}`})}else if(Cs.required_tags.length>0){const{error:cn}=await G.from("user_tags").insert({user_id:xt,tag:Cs.required_tags[0]});if(cn)throw cn;o({title:"Access Granted",description:`Granted access to ${Cs.name}`})}await Va()}catch(cn){console.error("Error toggling access:",cn),o({title:"Error",description:cn.message||"Failed to update access",variant:"destructive"})}finally{Xe(null)}},Td=async()=>{const xt=Se.trim();if(!xt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(xt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}if(p.find(Ks=>Ks.name.toLowerCase()===xt.toLowerCase())){o({title:"Error",description:"A brokerage with this name already exists",variant:"destructive"});return}ct(!0);try{const{error:Ks}=await G.from("brokerages").insert({name:xt});if(Ks)throw Ks;o({title:"Success",description:`Brokerage "${xt}" created successfully`}),it(""),nt(!1),Va()}catch(Ks){console.error("Error creating brokerage:",Ks),o({title:"Error",description:Ks.message||"Failed to create brokerage",variant:"destructive"})}finally{ct(!1)}},Ap=xt=>{We(xt),et(xt.name),Ze(!0)},vl=()=>{We(null),et(""),Ze(!1)},Nu=async()=>{if(!Qe)return;const xt=He.trim();if(!xt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(xt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}Ft(!0);try{const{error:Cs}=await G.from("brokerages").update({name:xt}).eq("id",Qe.id);if(Cs)throw Cs;o({title:"Success",description:"Brokerage updated successfully"}),vl(),Va()}catch(Cs){console.error("Error updating brokerage:",Cs),o({title:"Error",description:Cs.message||"Failed to update brokerage",variant:"destructive"})}finally{Ft(!1)}},Xc=async(xt,Cs)=>{var Ks;if(!Cs||typeof Cs!="string"){o({title:"Error",description:"Please select a brokerage first",variant:"destructive"});return}try{const ln={userId:xt,role:"brokerage_manager",action:"add",brokerageId:Cs};console.debug("[assignManagerToBrokerage] payload",ln);const{data:{session:cn}}=await G.auth.getSession(),ta=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${cn==null?void 0:cn.access_token}`},body:JSON.stringify(ln)}),Fr=await ta.json();if(!ta.ok&&!((Ks=Fr.error)!=null&&Ks.includes("duplicate")))throw new Error(Fr.error||"Failed to add role");o({title:"Success",description:"Manager assigned to brokerage"}),await Va()}catch(ln){console.error("Error assigning manager:",ln),o({title:"Error",description:ln.message||"Failed to assign manager",variant:"destructive"})}},sm=xt=>{is(xt),Xt(!0)},_l=async()=>{if(ss){Ct(!0);try{const xt=l.filter(ln=>ln.brokerage_id===ss.id),{data:{session:Cs}}=await G.auth.getSession();for(const ln of xt){const cn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Cs==null?void 0:Cs.access_token}`},body:JSON.stringify({userId:ln.id})});if(!cn.ok){const ta=await cn.json();console.error(`Failed to delete user ${ln.email}:`,ta.error)}}const{error:Ks}=await G.from("brokerages").delete().eq("id",ss.id);if(Ks)throw Ks;o({title:"Success",description:`Brokerage "${ss.name}" and ${xt.length} member(s) deleted`}),Xt(!1),is(null),Va()}catch(xt){console.error("Error deleting brokerage:",xt),o({title:"Error",description:xt.message||"Failed to delete brokerage",variant:"destructive"})}finally{Ct(!1)}}},Bf=xt=>{Wn(xt),bo(""),qs(!0)},ax=()=>{Wn(null),bo(""),qs(!1)},pv=async xt=>{try{const{error:Cs}=await G.from("profiles").update({brokerage_id:null}).eq("id",xt);if(Cs)throw Cs;o({title:"Success",description:"User removed from brokerage"}),Va()}catch(Cs){console.error("Error removing user from brokerage:",Cs),o({title:"Error",description:Cs.message||"Failed to remove user",variant:"destructive"})}},fv=async(xt,Cs)=>{try{const{error:Ks}=await G.from("profiles").update({brokerage_id:Cs}).eq("id",xt);if(Ks)throw Ks;o({title:"Success",description:"User added to brokerage"}),Va()}catch(Ks){console.error("Error adding user to brokerage:",Ks),o({title:"Error",description:Ks.message||"Failed to add user",variant:"destructive"})}},gv=async()=>{if(!gr||!ia.email||!ia.name||!ia.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}Zt(!0);try{const{data:{session:xt}}=await G.auth.getSession(),Cs=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${xt==null?void 0:xt.access_token}`},body:JSON.stringify({...ia,brokerage_id:gr.id,role:"user"})}),Ks=await Cs.json();if(!Cs.ok)throw new Error(Ks.error||"Failed to create agent");o({title:"Success",description:`Agent ${ia.email} created successfully`}),kn({email:"",name:"",password:"",phone:""}),nn(!1),Va()}catch(xt){console.error("Error creating agent:",xt),o({title:"Error",description:xt.message||"Failed to create agent",variant:"destructive"})}finally{Zt(!1)}},Vm=xt=>l.filter(Cs=>Cs.brokerage_id===xt),gh=xt=>{const Cs=Vm(xt);if(!ii)return Cs;const Ks=ii.toLowerCase();return Cs.filter(ln=>ln.name.toLowerCase().includes(Ks)||ln.email.toLowerCase().includes(Ks))},Ad=xt=>l.filter(Cs=>Cs.brokerage_id!==xt),xh=l.filter(xt=>{var Ks;if(q){const ln=q.toLowerCase();if(!(xt.name.toLowerCase().includes(ln)||xt.email.toLowerCase().includes(ln)||((Ks=xt.brokerage_name)==null?void 0:Ks.toLowerCase().includes(ln))))return!1}if(Q==="claimed"&&!xt.claimed||Q==="unclaimed"&&xt.claimed||re!=="all"&&!xt.roles.includes(re))return!1;const Cs=xt.is_trial||xt.subscription_status==="trialing";return!(le==="trial"&&!Cs||le==="non-trial"&&Cs||be==="none"&&xt.brokerage_id||be!=="all"&&be!=="none"&&xt.brokerage_id!==be)}),{sortKey:hd,sortDirection:Qc,handleSort:Ed,sortData:Ep}=JL("created_at","desc"),Pp=Ep(xh,{name:xt=>{var Cs;return((Cs=xt.name)==null?void 0:Cs.toLowerCase())||""},brokerage:xt=>{var Cs;return((Cs=xt.brokerage_name)==null?void 0:Cs.toLowerCase())||""},status:xt=>xt.claimed?"active":"pending",role:xt=>xt.roles[0]||"",last_login:xt=>xt.last_sign_in_at?new Date(xt.last_sign_in_at).getTime():null,created_at:xt=>xt.created_at?new Date(xt.created_at).getTime():null}),rm=Pp.length,nm=se===0,Jc=nm?1:Math.ceil(rm/se),ky=nm?0:(H-1)*se,$f=nm?rm:ky+se,hl=Pp.slice(ky,$f),xv=xt=>{U(xt),Y(1)},qf=xt=>{te(xt),Y(1)},Vu=(xt,Cs)=>{xt(Cs),Y(1)},lb=async(xt,Cs)=>{Ne(!0);try{const Ks=l.find(Fr=>Fr.id===xt);if(!Ks)return;const ln=Ks.trial_expires_at?new Date(Ks.trial_expires_at):new Date,cn=new Date(ln.getTime()+Cs*24*60*60*1e3),{error:ta}=await G.from("profiles").update({trial_expires_at:cn.toISOString()}).eq("id",xt);if(ta)throw ta;o({title:"Trial Extended",description:`Trial extended by ${Cs} days`}),Va()}catch(Ks){console.error("Error extending trial:",Ks),o({title:"Error",description:Ks.message||"Failed to extend trial",variant:"destructive"})}finally{Ne(!1)}},yS=async xt=>{we(!0);try{const{error:Cs}=await G.from("profiles").update({is_trial:!1,trial_expires_at:null,trial_started_at:null,trial_claimed_at:null}).eq("id",xt);if(Cs)throw Cs;o({title:"Account Converted",description:"User has been converted to a full account"}),Va(),ix()}catch(Cs){console.error("Error converting trial:",Cs),o({title:"Error",description:Cs.message||"Failed to convert account",variant:"destructive"})}finally{we(!1)}},Sy=async xt=>{wn(!0);try{const{data:Cs}=await G.from("agent_assistant_assignments").select("id, assistant_id, permissions").eq("agent_id",xt);if(Cs&&Cs.length>0){const ln=Cs.map(ta=>ta.assistant_id),{data:cn}=await G.from("profiles").select("id, name, email").in("id",ln);qr(Cs.map(ta=>{const Fr=cn==null?void 0:cn.find(eo=>eo.id===ta.assistant_id);return{id:ta.id,assistant_id:ta.assistant_id,assistant_name:(Fr==null?void 0:Fr.name)||"Unknown",assistant_email:(Fr==null?void 0:Fr.email)||"",permissions:ta.permissions||{}}}))}else qr([]);const{data:Ks}=await G.from("agent_assistant_assignments").select("id, agent_id, permissions").eq("assistant_id",xt);if(Ks&&Ks.length>0){const ln=Ks.map(ta=>ta.agent_id),{data:cn}=await G.from("profiles").select("id, name, email").in("id",ln);Cn(Ks.map(ta=>{const Fr=cn==null?void 0:cn.find(eo=>eo.id===ta.agent_id);return{id:ta.id,agent_id:ta.agent_id,agent_name:(Fr==null?void 0:Fr.name)||"Unknown",agent_email:(Fr==null?void 0:Fr.email)||"",permissions:ta.permissions||{}}}))}else Cn([])}catch(Cs){console.error("Error loading assistant data:",Cs)}finally{wn(!1)}},wa=xt=>{Ae(xt),Rt({name:xt.name,email:xt.email,brokerage_id:xt.brokerage_id||"",phone:xt.phone||""}),ut(!0),Sy(xt.id)},ix=()=>{Ae(null),ut(!1),Rt({name:"",email:"",brokerage_id:"",phone:""})},cb=async()=>{Fe&&(await Xi(Fe.id),ix())},vS=xt=>{ye(Cs=>{const Ks=new Set(Cs);return Ks.has(xt)?Ks.delete(xt):Ks.add(xt),Ks})},_S=()=>{if(Vt.size===hl.length&&hl.every(xt=>Vt.has(xt.id))){const xt=new Set(Vt);hl.forEach(Cs=>xt.delete(Cs.id)),ye(xt)}else{const xt=new Set(Vt);hl.forEach(Cs=>xt.add(Cs.id)),ye(xt)}},yh=()=>{ye(new Set)},Cy=async()=>{if(Vt.size===0)return;Je(!0);let xt=0,Cs=0;try{const{data:{session:Ks}}=await G.auth.getSession();for(const ln of Vt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ks==null?void 0:Ks.access_token}`},body:JSON.stringify({userId:ln})})).ok?xt++:Cs++}catch{Cs++}o({title:"Bulk Email Complete",description:`Sent ${xt} emails${Cs>0?`, ${Cs} failed`:""}`}),yh()}catch(Ks){o({title:"Error",description:Ks.message||"Failed to send emails",variant:"destructive"})}finally{Je(!1)}},My=async()=>{if(Vt.size===0)return;Je(!0);let xt=0,Cs=0;try{const{data:{session:Ks}}=await G.auth.getSession();for(const ln of Vt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-password-reset",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ks==null?void 0:Ks.access_token}`},body:JSON.stringify({userId:ln})})).ok?xt++:Cs++}catch{Cs++}o({title:"Bulk Password Reset Complete",description:`Sent ${xt} reset emails${Cs>0?`, ${Cs} failed`:""}`}),yh()}catch(Ks){o({title:"Error",description:Ks.message||"Failed to send password reset emails",variant:"destructive"})}finally{Je(!1)}},db=async()=>{if(Vt.size===0)return;const xt=l.filter(cn=>Vt.has(cn.id)).map(cn=>cn.name).slice(0,5).join(", "),Cs=Vt.size>5?` and ${Vt.size-5} more`:"";if(!confirm(`Are you sure you want to delete ${Vt.size} users (${xt}${Cs})? This action cannot be undone.`))return;Je(!0);let Ks=0,ln=0;try{const{data:{session:cn}}=await G.auth.getSession();for(const ta of Vt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${cn==null?void 0:cn.access_token}`},body:JSON.stringify({userId:ta})})).ok?Ks++:ln++}catch{ln++}o({title:"Bulk Delete Complete",description:`Deleted ${Ks} users${ln>0?`, ${ln} failed`:""}`}),yh(),Va()}catch(cn){o({title:"Error",description:cn.message||"Failed to delete users",variant:"destructive"})}finally{Je(!1)}},yv=async()=>{Nt(!0);try{const{data:{session:xt}}=await G.auth.getSession(),Cs=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-phone-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${xt==null?void 0:xt.access_token}`}});if(!Cs.ok){const ln=await Cs.json();throw new Error(ln.error||"Failed to sync phones")}const Ks=await Cs.json();o({title:"Phone Sync Complete",description:`Pulled ${Ks.summary.pulledFromGHL} from GHL, pushed ${Ks.summary.pushedToGHL} to GHL, ${Ks.summary.alreadySynced} already synced`}),Va()}catch(xt){o({title:"Error",description:xt.message||"Failed to sync phones with GHL",variant:"destructive"})}finally{Nt(!1)}},am=async(xt,Cs)=>{Kt(xt);try{const{data:{session:Ks}}=await G.auth.getSession(),{data:ln}=await G.from("profiles").select("phone").eq("id",xt).single(),cn=(ln==null?void 0:ln.phone)||"",ta=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-tag-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ks==null?void 0:Ks.access_token}`},body:JSON.stringify({email:Cs,action:"update",phone:cn||void 0})});if(!ta.ok){const eo=await ta.json();throw new Error(eo.error||"Failed to sync with GHL")}const Fr=await fetch(`https://services.leadconnectorhq.com/contacts/lookup?locationId=&email=${encodeURIComponent(Cs)}`,{method:"GET",headers:{"Content-Type":"application/json"}});o({title:"Phone Synced",description:cn?`Phone ${cn} synced to GHL`:"Sync attempted - run bulk sync to pull phone from GHL"}),Va()}catch(Ks){o({title:"Error",description:Ks.message||"Failed to sync phone",variant:"destructive"})}finally{Kt(null)}},ox=async xt=>{await n(xt)},ub=()=>{if(Vt.size===0){o({title:"No members selected",description:"Please select members to export",variant:"destructive"});return}const xt=l.filter(eo=>Vt.has(eo.id)),Cs=["Name","Email","Phone","Brokerage","Roles","Status","Created At"],Ks=xt.map(eo=>[eo.name,eo.email,eo.phone||"",eo.brokerage_name||"",eo.roles.join("; "),eo.claimed?"Claimed":"Unclaimed",new Date(eo.created_at).toLocaleDateString()]),ln=[Cs.join(","),...Ks.map(eo=>eo.map(Uf=>`"${(Uf||"").replace(/"/g,'""')}"`).join(","))].join(` `),cn=new Blob([ln],{type:"text/csv"}),ta=URL.createObjectURL(cn),Fr=document.createElement("a");Fr.href=ta,Fr.download=`members-export-${new Date().toISOString().split("T")[0]}.csv`,Fr.click(),URL.revokeObjectURL(ta),o({title:"Export complete",description:`Exported ${xt.length} member(s)`})};return b?e.jsx(Ts,{title:"Members",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(Ts,{title:"Members",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(wu,{title:"Member Management",description:"Manage users, roles, and permissions"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:yv,disabled:St,children:[St?e.jsx(Ms,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Qn,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:St?"Syncing...":"Sync Phones with GHL"}),e.jsx("span",{className:"sm:hidden",children:St?"Syncing...":"Sync GHL"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>es(!0),children:[e.jsx(I0,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Import CSV"}),e.jsx("span",{className:"sm:hidden",children:"Import"})]}),e.jsxs(_s,{open:R,onOpenChange:$,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(yc,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Add Member"}),e.jsx("span",{className:"sm:hidden",children:"Add"})]})}),e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Create New User"}),e.jsx(Kr,{children:"Add a new user to the system. They'll be able to sign in immediately."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",placeholder:"John Doe",value:I.name,onChange:xt=>L({...I,name:xt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",placeholder:"john@example.com",value:I.email,onChange:xt=>L({...I,email:xt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"password",children:"Password"}),e.jsx(Re,{id:"password",type:"password",placeholder:"Min 6 characters",value:I.password,onChange:xt=>L({...I,password:xt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(Re,{id:"phone",type:"tel",placeholder:"555-123-4567",value:I.phone,onChange:xt=>L({...I,phone:xt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"brokerage",children:["Brokerage",I.role==="brokerage_manager"?" (required)":""]}),e.jsxs(sr,{value:I.brokerage_id||"none",onValueChange:xt=>L({...I,brokerage_id:xt==="none"?"":xt}),children:[e.jsx(er,{id:"brokerage",children:e.jsx(rr,{placeholder:I.role==="brokerage_manager"?"Select brokerage":"Select brokerage (optional)"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"none",children:"None"}),p.map(xt=>e.jsx(At,{value:xt.id,children:xt.name},xt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"role",children:"Role"}),e.jsxs(sr,{value:I.role,onValueChange:xt=>L({...I,role:xt}),children:[e.jsx(er,{id:"role",children:e.jsx(rr,{placeholder:"Select role"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"user",children:"User"}),e.jsx(At,{value:"moderator",children:"Moderator"}),e.jsx(At,{value:"brokerage_manager",children:"Brokerage Manager"}),e.jsx(At,{value:"admin",children:"Admin"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"trial_days",children:"Trial Period (optional)"}),e.jsxs(sr,{value:I.trial_days||"none",onValueChange:xt=>L({...I,trial_days:xt==="none"?"":xt}),children:[e.jsx(er,{id:"trial_days",children:e.jsx(rr,{placeholder:"No trial (full access)"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"none",children:"No trial (full access)"}),e.jsx(At,{value:"7",children:"7-day trial"}),e.jsx(At,{value:"30",children:"30-day trial"}),e.jsx(At,{value:"60",children:"60-day trial"}),e.jsx(At,{value:"90",children:"90-day trial"}),e.jsx(At,{value:"365",children:"1-year trial"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Trial accounts don't require a credit card. Access expires after the trial period."})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),e.jsx(K,{onClick:ra,disabled:S,children:S?"Creating...":"Create User"})]})]})]})]})]}),e.jsxs(ka,{defaultValue:new URLSearchParams(window.location.search).get("tab")||"members",className:"space-y-6",children:[e.jsxs(_a,{children:[e.jsx(js,{value:"members",children:"Members"}),e.jsx(js,{value:"brokerages",children:"Brokerages"}),e.jsx(js,{value:"teams",children:"Teams"}),e.jsx(js,{value:"trials",children:"Trial Users"}),e.jsx(js,{value:"access",children:"Access Matrix"}),e.jsx(js,{value:"celebrations",children:"Celebrations"}),e.jsx(js,{value:"deletions",children:"Deletion Log"})]}),e.jsxs(zs,{value:"members",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search members...",value:q,onChange:xt=>xv(xt.target.value),className:"pl-10 h-9"})]}),e.jsxs(sr,{value:Q,onValueChange:xt=>Vu(de,xt),children:[e.jsx(er,{className:"w-[130px] h-9",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Status"}),e.jsx(At,{value:"claimed",children:"Active"}),e.jsx(At,{value:"unclaimed",children:"Pending"})]})]}),e.jsxs(sr,{value:re,onValueChange:xt=>Vu(ae,xt),children:[e.jsx(er,{className:"w-[130px] h-9",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Roles"}),e.jsx(At,{value:"admin",children:"Admin"}),e.jsx(At,{value:"brokerage_manager",children:"Manager"}),e.jsx(At,{value:"assistant",children:"Assistant"}),e.jsx(At,{value:"user",children:"User"})]})]}),e.jsxs(sr,{value:le,onValueChange:xt=>Vu(he,xt),children:[e.jsx(er,{className:"w-[130px] h-9",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Users"}),e.jsx(At,{value:"trial",children:"Trial Only"}),e.jsx(At,{value:"non-trial",children:"Full Only"})]})]}),e.jsxs(sr,{value:be,onValueChange:xt=>Vu(_e,xt),children:[e.jsx(er,{className:"w-[150px] h-9",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Brokerages"}),e.jsx(At,{value:"none",children:"No Brokerage"}),p.map(xt=>e.jsx(At,{value:xt.id,children:xt.name},xt.id))]})]}),(q||Q!=="all"||re!=="all"||le!=="all"||be!=="all")&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-9",onClick:()=>{U(""),de("all"),ae("all"),he("all"),_e("all"),Y(1)},children:[e.jsx(Ur,{className:"h-4 w-4 mr-1"}),"Clear"]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:nm?`Showing all ${rm} members`:`Showing ${ky+1}-${Math.min($f,rm)} of ${rm} members`}),e.jsxs(sr,{value:se.toString(),onValueChange:xt=>qf(Number(xt)),children:[e.jsx(er,{className:"h-9 w-[110px]",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"50",children:"50 / page"}),e.jsx(At,{value:"100",children:"100 / page"}),e.jsx(At,{value:"250",children:"250 / page"}),e.jsx(At,{value:"0",children:"All"})]})]})]})]}),Vt.size>0&&e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/10 border border-primary/20 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g0,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm font-medium",children:[Vt.size," selected"]})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:Cy,disabled:ze,children:[ze?e.jsx(Ms,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(br,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Resend Invite"}),e.jsx("span",{className:"sm:hidden",children:"Invite"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:My,disabled:ze,children:[ze?e.jsx(Ms,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Dm,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Password Reset"}),e.jsx("span",{className:"sm:hidden",children:"Reset"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:ub,children:[e.jsx(xi,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Export"}),e.jsx("span",{className:"sm:hidden",children:"CSV"})]}),e.jsxs(K,{size:"sm",variant:"destructive",onClick:db,disabled:ze,children:[ze?e.jsx(Ms,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(jr,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"}),e.jsx("span",{className:"sm:hidden",children:"Del"})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:yh,disabled:ze,children:e.jsx(Ur,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(bt,{className:"w-[50px]",children:e.jsx(Bo,{checked:hl.length>0&&hl.every(xt=>Vt.has(xt.id)),onCheckedChange:_S,"aria-label":"Select all on page"})}),e.jsx(el,{sortKey:"name",currentSortKey:hd,currentDirection:Qc,onSort:Ed,children:"Name"}),e.jsx(el,{sortKey:"brokerage",currentSortKey:hd,currentDirection:Qc,onSort:Ed,children:"Brokerage"}),e.jsx(el,{sortKey:"status",currentSortKey:hd,currentDirection:Qc,onSort:Ed,children:"Status"}),e.jsx(el,{sortKey:"role",currentSortKey:hd,currentDirection:Qc,onSort:Ed,children:"Role"}),e.jsx(el,{sortKey:"last_login",currentSortKey:hd,currentDirection:Qc,onSort:Ed,children:"Last Login"}),e.jsx(el,{sortKey:"created_at",currentSortKey:hd,currentDirection:Qc,onSort:Ed,children:"Member Since"}),e.jsx(bt,{className:"w-[100px]"})]})}),e.jsx(Pn,{children:hl.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:8,className:"text-center py-12 text-muted-foreground",children:"No members found"})}):hl.map(xt=>e.jsxs(Ns,{className:`hover:bg-muted/30 ${Vt.has(xt.id)?"bg-primary/5":""}`,children:[e.jsx(lt,{children:e.jsx(Bo,{checked:Vt.has(xt.id),onCheckedChange:()=>vS(xt.id),"aria-label":`Select ${xt.name}`})}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("button",{onClick:()=>wa(xt),className:"text-primary hover:underline font-medium text-left",children:xt.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:xt.email})]})}),e.jsx(lt,{className:"text-muted-foreground",children:xt.brokerage_name||"—"}),e.jsx(lt,{children:e.jsx("div",{className:"flex flex-col",children:(()=>{const Cs=xt.is_trial&&xt.trial_expires_at||!xt.is_trial&&xt.subscription_status==="trialing"&&xt.subscription_end_date,Ks=xt.trial_expires_at||xt.subscription_end_date;if(Cs&&Ks){const ln=Math.ceil((new Date(Ks).getTime()-Date.now())/864e5),cn=ln<=0,ta=ln<=3;return e.jsx(rt,{variant:"outline",className:Pt("w-fit",cn?"border-destructive text-destructive":ta?"border-amber-500 text-amber-600":"border-violet-300 text-violet-700 bg-violet-50"),children:cn?"Trial Expired":`Trial · ${ln}d left`})}return e.jsx(rt,{variant:xt.claimed?"default":"secondary",className:xt.claimed?"bg-primary text-primary-foreground w-fit":"w-fit",children:xt.claimed?"Active":"Pending"})})()})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex flex-col",children:[xt.roles.length>0?e.jsx("span",{className:"text-sm capitalize",children:xt.roles[0]}):e.jsx("span",{className:"text-muted-foreground",children:"—"}),xt.roles.includes("assistant")&&ma[xt.id]&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",ma[xt.id].agent_name||ma[xt.id].agent_email]})]})}),e.jsx(lt,{className:"text-muted-foreground",children:xt.last_sign_in_at?new Date(xt.last_sign_in_at).toLocaleDateString():"—"}),e.jsx(lt,{className:"text-muted-foreground",children:xt.created_at?new Date(xt.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—"}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",onClick:()=>{gs(xt),Qt(!0)},title:"Send celebration",children:e.jsx(kd,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>wa(xt),title:"Edit member",children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>am(xt.id,xt.email),disabled:Bt===xt.id,title:"Sync phone with GHL",children:Bt===xt.id?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):e.jsx(Qn,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>ba(xt.id),title:"Resend welcome email",children:e.jsx(br,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Qi(xt.email,xt.name),title:"Send password reset",children:e.jsx(ck,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>ox(xt.id),disabled:a||xt.id===(s==null?void 0:s.id),title:xt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${xt.name}`,children:a?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):e.jsx(w5,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>vi(xt.id,xt.name),title:"Delete user",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},xt.id))})]})}),Jc>1&&e.jsxs("div",{className:"flex items-center justify-between px-2 py-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Page ",H," of ",Jc]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>Y(1),disabled:H===1,children:"First"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Y(xt=>Math.max(1,xt-1)),disabled:H===1,children:e.jsx(zl,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,Jc)},(xt,Cs)=>{let Ks;return Jc<=5||H<=3?Ks=Cs+1:H>=Jc-2?Ks=Jc-4+Cs:Ks=H-2+Cs,e.jsx(K,{variant:H===Ks?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>Y(Ks),children:Ks},Ks)})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Y(xt=>Math.min(Jc,xt+1)),disabled:H===Jc,children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>Y(Jc),disabled:H===Jc,children:"Last"})]})]})]}),e.jsx(_s,{open:Ue,onOpenChange:ut,children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Edit Member"}),e.jsx(Kr,{children:"Update member details, roles, and app access"})]}),Fe&&e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Basic Information"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"edit-name",children:"Name"}),e.jsx(Re,{id:"edit-name",value:De.name,onChange:xt=>Rt({...De,name:xt.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"edit-email",children:"Email"}),e.jsx(Re,{id:"edit-email",type:"email",value:De.email,onChange:xt=>Rt({...De,email:xt.target.value}),maxLength:255})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(Re,{id:"edit-phone",type:"tel",value:De.phone,onChange:xt=>Rt({...De,phone:xt.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"edit-brokerage",children:"Brokerage"}),e.jsxs(sr,{value:De.brokerage_id||"none",onValueChange:xt=>Rt({...De,brokerage_id:xt==="none"?"":xt}),children:[e.jsx(er,{id:"edit-brokerage",children:e.jsx(rr,{placeholder:"Select brokerage"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"none",children:"None"}),p.map(xt=>e.jsx(At,{value:xt.id,children:xt.name},xt.id))]})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Roles"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Fe.roles.map(xt=>e.jsxs(rt,{variant:"default",className:"gap-1",children:[e.jsx(ih,{className:"h-3 w-3"}),xt,xt==="brokerage_manager"?e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(manage in Brokerages tab)"}):e.jsx("button",{onClick:()=>Ji(Fe.id,xt,"remove"),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove role",children:e.jsx(Ur,{className:"h-3 w-3"})})]},xt)),Fe.roles.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"No roles assigned"})]}),e.jsxs(sr,{onValueChange:xt=>Ji(Fe.id,xt,"add"),children:[e.jsx(er,{className:"w-[200px]",children:e.jsx(rr,{placeholder:"Add role..."})}),e.jsxs(tr,{children:[!Fe.roles.includes("admin")&&e.jsx(At,{value:"admin",children:"Admin"}),!Fe.roles.includes("user")&&e.jsx(At,{value:"user",children:"User"})]})]}),!Fe.roles.includes("brokerage_manager")&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"To add as brokerage manager, use Brokerages tab → Manage"})]}),(fr.length>0||ur.length>0||Fe.roles.includes("assistant"))&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Assistant Relationships"]}),Mn?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Ms,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):e.jsxs("div",{className:"space-y-3",children:[fr.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Has assistants:"}),fr.map(xt=>e.jsxs("div",{className:"p-3 rounded-lg border bg-muted/30 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:xt.assistant_name}),e.jsx(rt,{variant:"outline",className:"text-xs",children:"Assistant"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:xt.assistant_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(xt.permissions).filter(([,Cs])=>Cs).map(([Cs])=>e.jsx(rt,{variant:"secondary",className:"text-[10px] capitalize",children:Cs},Cs))})]},xt.id))]}),ur.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Assists agents:"}),ur.map(xt=>e.jsxs("div",{className:"p-3 rounded-lg border bg-muted/30 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:xt.agent_name}),e.jsx(rt,{variant:"outline",className:"text-xs",children:"Agent"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:xt.agent_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(xt.permissions).filter(([,Cs])=>Cs).map(([Cs])=>e.jsx(rt,{variant:"secondary",className:"text-[10px] capitalize",children:Cs},Cs))})]},xt.id))]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"App Access"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Toggle which apps this member can access"}),e.jsx("div",{className:"grid gap-3",children:d.map(xt=>{const Cs=ic(Fe.tags,xt.required_tags),Ks=`${Fe.id}-${xt.id}`,ln=me===Ks,cn=xt.required_tags.length===0;return e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xl",children:xt.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:xt.name}),cn&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Available to all members"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:ln?e.jsx(Ms,{className:"h-4 w-4 animate-spin text-muted-foreground"}):cn?e.jsx(rt,{variant:"secondary",className:"text-xs",children:"Always On"}):e.jsx(Br,{checked:Cs,onCheckedChange:()=>vc(Fe.id,xt,Cs)})})]},xt.id)})})]}),(Fe.is_trial||Fe.subscription_status==="trialing")&&e.jsxs("div",{className:"space-y-3 pt-4 border-t",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(Tn,{className:"h-4 w-4"}),"Trial Status"]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-amber-50 dark:bg-amber-950/20 border-amber-200 dark:border-amber-800",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[Fe.trial_expires_at&&e.jsx(XAe,{expiresAt:Fe.trial_expires_at}),!Fe.trial_expires_at&&Fe.subscription_status==="trialing"&&Fe.subscription_end_date&&e.jsx(XAe,{expiresAt:Fe.subscription_end_date})]}),(Fe.trial_expires_at||Fe.subscription_end_date)&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Expires: ",new Date(Fe.trial_expires_at||Fe.subscription_end_date).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>lb(Fe.id,7),disabled:je,children:[e.jsx(n_,{className:"h-4 w-4 mr-1"}),"+7 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>lb(Fe.id,14),disabled:je,children:[e.jsx(n_,{className:"h-4 w-4 mr-1"}),"+14 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>lb(Fe.id,30),disabled:je,children:[e.jsx(n_,{className:"h-4 w-4 mr-1"}),"+30 Days"]}),e.jsxs(K,{size:"sm",variant:"default",onClick:()=>yS(Fe.id),disabled:Ge,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(p_,{className:"h-4 w-4 mr-1"}),"Convert to Full Account"]})]}),Fe.trial_started_at&&e.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:["Trial started: ",new Date(Fe.trial_started_at).toLocaleDateString(),Fe.trial_claimed_at&&e.jsxs("span",{children:[" • Claimed: ",new Date(Fe.trial_claimed_at).toLocaleDateString()]})]})]})]}),e.jsxs("div",{className:"space-y-2 pt-4 border-t",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Account Information"}),e.jsxs("div",{className:"text-sm space-y-1 text-muted-foreground",children:[Fe.email_confirmed_at&&e.jsxs("div",{children:["Claimed: ",new Date(Fe.email_confirmed_at).toLocaleString()]}),Fe.last_sign_in_at&&e.jsxs("div",{children:["Last login: ",new Date(Fe.last_sign_in_at).toLocaleString()]}),e.jsxs("div",{children:["Created: ",new Date(Fe.created_at).toLocaleString()]})]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:ix,children:"Cancel"}),e.jsx(K,{onClick:cb,children:"Save Changes"})]})]})}),e.jsxs(zs,{value:"access",children:[d.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsx(K,{onClick:()=>t("/admin/apps"),children:"Configure Apps"})]})}):e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Member Access Matrix"}),e.jsx(pr,{children:"Toggle switches to grant or revoke app access for each member"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left p-4 font-semibold sticky left-0 bg-card z-10",children:"Member"}),d.map(xt=>e.jsx("th",{className:"text-center p-4 font-semibold min-w-[120px]",children:e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("span",{className:"text-2xl",children:xt.icon}),e.jsx("span",{className:"text-sm",children:xt.name})]})},xt.id))]})}),e.jsxs("tbody",{children:[hl.map(xt=>e.jsxs("tr",{className:"border-b hover:bg-muted/50",children:[e.jsx("td",{className:"p-4 sticky left-0 bg-card z-10",children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:xt.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:xt.email})]})}),d.map(Cs=>{const Ks=ic(xt.tags,Cs.required_tags),ln=`${xt.id}-${Cs.id}`,cn=me===ln;return e.jsx("td",{className:"p-4 text-center",children:e.jsx("div",{className:"flex items-center justify-center",children:cn?e.jsx(Ms,{className:"h-5 w-5 animate-spin text-muted-foreground"}):e.jsx(Br,{checked:Ks,onCheckedChange:()=>vc(xt.id,Cs,Ks),disabled:Cs.required_tags.length===0})})},Cs.id)})]},xt.id)),hl.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:d.length+1,className:"p-8 text-center text-muted-foreground",children:"No members found"})})]})]})}),Jc>1&&e.jsxs("div",{className:"flex items-center justify-between px-2 py-4 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",ky+1,"-",Math.min($f,rm)," of ",rm," • Page ",H," of ",Jc]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Y(xt=>Math.max(1,xt-1)),disabled:H===1,children:e.jsx(zl,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Y(xt=>Math.min(Jc,xt+1)),disabled:H===Jc,children:e.jsx(Ua,{className:"h-4 w-4"})})]})]})]})]}),e.jsx("div",{className:"mt-6",children:e.jsx(K,{variant:"outline",onClick:()=>t("/admin/apps"),children:"Manage Apps"})})]}),e.jsxs(zs,{value:"brokerages",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search brokerages...",value:an,onChange:xt=>Ra(xt.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[p.filter(xt=>xt.name.toLowerCase().includes(an.toLowerCase())).length," of ",p.length," brokerages"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{const xt=[];for(const Fr of p){const eo=y[Fr.id]??[];for(const Uf of eo){const Hm=l.find(Hr=>Hr.id===Uf);if(Hm){const Hr=(Hm.name||"").trim().split(/\s+/),Ty=Hr[0]||"",Ay=Hr.slice(1).join(" ")||"";xt.push({firstName:Ty,lastName:Ay,email:Hm.email,brokerageName:Fr.name})}}}if(xt.length===0){o({title:"No managers found to export"});return}const Ks=[["First Name","Last Name","Email","Brokerage Name"].join(","),...xt.map(Fr=>[Fr.firstName,Fr.lastName,Fr.email,Fr.brokerageName].map(eo=>`"${(eo||"").replace(/"/g,'""')}"`).join(","))].join(` `),ln=new Blob([Ks],{type:"text/csv"}),cn=URL.createObjectURL(ln),ta=document.createElement("a");ta.href=cn,ta.download=`brokerage-managers-${new Date().toISOString().slice(0,10)}.csv`,ta.click(),URL.revokeObjectURL(cn),o({title:`Exported ${xt.length} managers`})},children:[e.jsx(xi,{className:"mr-2 h-4 w-4"}),"Export Managers"]}),e.jsxs(_s,{open:ot,onOpenChange:nt,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Ta,{className:"mr-2 h-4 w-4"}),"Add Brokerage"]})}),e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Create New Brokerage"}),e.jsx(Kr,{children:"Add a new brokerage to the system."})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(Re,{id:"brokerage-name",placeholder:"Enter brokerage name",value:Se,onChange:xt=>it(xt.target.value),maxLength:100})]})}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>nt(!1),children:"Cancel"}),e.jsx(K,{onClick:Td,disabled:$e,children:$e?"Creating...":"Create Brokerage"})]})]})]})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(bt,{className:"font-semibold",children:"Brokerage Name"}),e.jsx(bt,{className:"font-semibold",children:"Manager(s)"}),e.jsx(bt,{className:"font-semibold",children:"Agents"}),e.jsx(bt,{className:"w-[150px]"})]})}),e.jsx(Pn,{children:(()=>{const xt=p.filter(Cs=>Cs.name.toLowerCase().includes(an.toLowerCase()));return xt.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:4,className:"text-center py-12 text-muted-foreground",children:an?"No brokerages match your search":"No brokerages found"})}):xt.map(Cs=>{const Ks=l.filter(Fr=>Fr.brokerage_id===Cs.id),cn=(y[Cs.id]??[]).map(Fr=>l.find(eo=>eo.id===Fr)).filter(Boolean),ta=Ks.length;return e.jsxs(Ns,{className:"hover:bg-muted/30",children:[e.jsx(lt,{children:e.jsx("button",{onClick:()=>Ap(Cs),className:"text-primary hover:underline font-medium",children:Cs.name})}),e.jsx(lt,{children:cn.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:cn.map(Fr=>e.jsx(rt,{variant:"secondary",className:"text-xs",children:Fr.name},Fr.id))}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"No manager"})}),e.jsxs(lt,{children:[ta," member",ta!==1?"s":""]}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"h-8",onClick:()=>Bf(Cs),children:[e.jsx(hr,{className:"h-4 w-4 mr-1"}),"Manage"]}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Ap(Cs),title:"Edit brokerage",children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>sm(Cs),title:"Delete brokerage",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},Cs.id)})})()})]})}),e.jsx(_s,{open:qe,onOpenChange:Ze,children:e.jsxs(vs,{className:"max-w-lg",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Edit Brokerage"}),e.jsx(Kr,{children:"Update brokerage details and manage managers"})]}),Qe&&e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"edit-brokerage-name",children:"Brokerage Name"}),e.jsx(Re,{id:"edit-brokerage-name",value:He,onChange:xt=>et(xt.target.value),maxLength:100})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{children:"Managers"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click × to remove manager access for this brokerage (keeps them as a member)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:(()=>{const Cs=(y[Qe.id]??[]).map(Ks=>l.find(ln=>ln.id===Ks)).filter(Boolean);return Cs.length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No managers assigned"}):Cs.map(Ks=>e.jsxs(rt,{variant:"default",className:"gap-1",children:[e.jsx(ih,{className:"h-3 w-3"}),Ks.name,e.jsx("button",{onClick:()=>Ji(Ks.id,"brokerage_manager","remove",Qe.id),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove manager from this brokerage",children:e.jsx(Ur,{className:"h-3 w-3"})})]},Ks.id))})()}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{className:"text-sm text-muted-foreground",children:"Assign manager from existing members:"}),e.jsxs(Co,{open:Zn,onOpenChange:Ir,children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":Zn,className:"w-full justify-between",children:["Search for a member...",e.jsx(gn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(No,{className:"w-full p-0",align:"start",children:e.jsxs(Mf,{children:[e.jsx(Tf,{placeholder:"Search by name or email..."}),e.jsxs(Af,{className:"max-h-[200px]",children:[e.jsx(Ef,{children:"No members found."}),e.jsx(Pf,{children:(()=>{const xt=new Set(y[Qe.id]??[]);return l.filter(Cs=>!xt.has(Cs.id)&&(r||Cs.brokerage_id===Qe.id)).map(Cs=>e.jsxs(Cm,{value:`${Cs.name} ${Cs.email}`,onSelect:()=>{Xc(Cs.id,Qe.id),Ir(!1)},children:[Cs.name," (",Cs.email,")"]},Cs.id))})()})]})]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Members in this Brokerage"}),e.jsx("div",{className:"max-h-32 overflow-y-auto border rounded p-2",children:l.filter(xt=>xt.brokerage_id===Qe.id).length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No members"}):l.filter(xt=>xt.brokerage_id===Qe.id).map(xt=>e.jsxs("div",{className:"text-sm py-1 flex items-center justify-between",children:[e.jsx("span",{children:xt.name}),xt.roles.includes("brokerage_manager")&&e.jsx(rt,{variant:"outline",className:"text-xs",children:"Manager"})]},xt.id))})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:vl,children:"Cancel"}),e.jsx(K,{onClick:Nu,disabled:Tt,children:Tt?"Saving...":"Save Changes"})]})]})}),e.jsx(_s,{open:as,onOpenChange:Xt,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{className:"text-destructive",children:"Delete Brokerage"}),e.jsxs(Kr,{children:['Are you sure you want to delete "',ss==null?void 0:ss.name,'"?']})]}),e.jsx("div",{className:"py-4",children:e.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-destructive",children:"Warning: This action cannot be undone!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This will permanently delete:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground list-disc list-inside",children:[e.jsxs("li",{children:['The brokerage "',ss==null?void 0:ss.name,'"']}),e.jsxs("li",{children:["All ",l.filter(xt=>xt.brokerage_id===(ss==null?void 0:ss.id)).length," member(s) assigned to this brokerage"]}),e.jsx("li",{children:"All their data, roles, and access"})]})]})}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>Xt(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:_l,disabled:ar,children:ar?"Deleting...":"Yes, Delete Brokerage"})]})]})}),e.jsx(_s,{open:Is,onOpenChange:qs,children:e.jsxs(vs,{className:"max-w-4xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-5 w-5"}),"Manage ",gr==null?void 0:gr.name]}),e.jsx(Kr,{children:"Add, remove, or manage users in this brokerage"})]}),gr&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search members...",value:ii,onChange:xt=>bo(xt.target.value),className:"pl-10 h-9"})]}),e.jsxs(_s,{open:si,onOpenChange:nn,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(yc,{className:"h-4 w-4 mr-1"}),"Add New Agent"]})}),e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Add New Agent"}),e.jsxs(Kr,{children:["Create a new agent for ",gr.name]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"agent-name",children:"Name"}),e.jsx(Re,{id:"agent-name",placeholder:"John Doe",value:ia.name,onChange:xt=>kn({...ia,name:xt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"agent-email",children:"Email"}),e.jsx(Re,{id:"agent-email",type:"email",placeholder:"john@example.com",value:ia.email,onChange:xt=>kn({...ia,email:xt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"agent-password",children:"Password"}),e.jsx(Re,{id:"agent-password",type:"password",placeholder:"Min 6 characters",value:ia.password,onChange:xt=>kn({...ia,password:xt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"agent-phone",children:"Phone (optional)"}),e.jsx(Re,{id:"agent-phone",type:"tel",placeholder:"555-123-4567",value:ia.phone,onChange:xt=>kn({...ia,phone:xt.target.value})})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>nn(!1),children:"Cancel"}),e.jsx(K,{onClick:gv,disabled:sa,children:sa?"Creating...":"Create Agent"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Add existing user:"}),e.jsxs(Co,{open:mi,onOpenChange:Go,children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":mi,className:"w-[300px] justify-between",children:["Select a user to add...",e.jsx(gn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(No,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Mf,{children:[e.jsx(Tf,{placeholder:"Search users...",value:yi,onValueChange:Vl}),e.jsxs(Af,{children:[e.jsx(Ef,{children:"No users found."}),e.jsx(Pf,{children:Ad(gr.id).filter(xt=>yi===""||xt.name.toLowerCase().includes(yi.toLowerCase())||xt.email.toLowerCase().includes(yi.toLowerCase())).map(xt=>e.jsxs(Cm,{value:`${xt.name} ${xt.email}`,onSelect:()=>{fv(xt.id,gr.id),Go(!1),Vl("")},children:[xt.name," (",xt.email,")"]},xt.id))})]})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto border rounded-lg",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(bt,{className:"font-semibold",children:"Name"}),e.jsx(bt,{className:"font-semibold",children:"Email"}),e.jsx(bt,{className:"font-semibold",children:"Status"}),e.jsx(bt,{className:"font-semibold",children:"Role"}),e.jsx(bt,{className:"w-[120px]"})]})}),e.jsx(Pn,{children:gh(gr.id).length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:ii?"No matching members found":"No members in this brokerage"})}):gh(gr.id).map(xt=>e.jsxs(Ns,{className:"hover:bg-muted/30",children:[e.jsx(lt,{className:"font-medium",children:xt.name}),e.jsx(lt,{className:"text-muted-foreground",children:xt.email}),e.jsx(lt,{children:xt.claimed?e.jsx(rt,{variant:"default",className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active"}):e.jsx(rt,{variant:"secondary",children:"Pending"})}),e.jsx(lt,{children:xt.roles.includes("brokerage_manager")?e.jsxs(rt,{variant:"outline",className:"gap-1",children:[e.jsx(ih,{className:"h-3 w-3"}),"Manager"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Agent"})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[!xt.claimed&&e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>ba(xt.id),title:"Resend welcome email",children:e.jsx(br,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>pv(xt.id),title:"Remove from brokerage",children:e.jsx(Ur,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>ox(xt.id),disabled:a||xt.id===(s==null?void 0:s.id),title:xt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${xt.name}`,children:a?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):e.jsx(w5,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>vi(xt.id,xt.name),title:"Delete user",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},xt.id))})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Vm(gr.id).length," total member",Vm(gr.id).length!==1?"s":""," •",Vm(gr.id).filter(xt=>xt.roles.includes("brokerage_manager")).length," manager",Vm(gr.id).filter(xt=>xt.roles.includes("brokerage_manager")).length!==1?"s":""]})]}),e.jsx(Un,{children:e.jsx(K,{variant:"outline",onClick:ax,children:"Close"})})]})})]}),e.jsx(zs,{value:"teams",children:e.jsx(mRt,{})}),e.jsx(zs,{value:"trials",children:e.jsx(cRt,{})}),e.jsx(zs,{value:"celebrations",children:e.jsx(lRt,{})}),e.jsx(zs,{value:"deletions",children:e.jsx(dRt,{})})]})]}),e.jsx(IKe,{open:$r,onOpenChange:es,brokerages:p,onSuccess:Va}),As&&e.jsx(LKe,{open:qt,onOpenChange:xt=>{Qt(xt),xt||gs(null)},userId:As.id,userName:As.name})]})},fRt=()=>{const[t,s]=C.useState([]),[r,n]=C.useState(!0),[a,o]=C.useState(!1),[l,i]=C.useState(""),[d,u]=C.useState(""),[p,f]=C.useState(""),[y,_]=C.useState("");C.useEffect(()=>{b()},[]);const b=async()=>{const{data:L,error:R}=await G.from("invite_codes").select("*").order("created_at",{ascending:!1});R?(fe.error("Failed to load invite codes"),console.error(R)):s(L||[]),n(!1)},w=async L=>{if(L.preventDefault(),!l.trim()){fe.error("Please enter a code");return}o(!0);const{error:R}=await G.from("invite_codes").insert({code:l.trim().toUpperCase(),description:d.trim()||null,max_uses:p?parseInt(p):null,trial_days:y?parseInt(y):null});R?R.code==="23505"?fe.error("This code already exists"):(fe.error("Failed to create invite code"),console.error(R)):(fe.success("Invite code created"),i(""),u(""),f(""),_(""),b()),o(!1)},j=async(L,R)=>{const{error:$}=await G.from("invite_codes").update({is_active:!R}).eq("id",L);$?fe.error("Failed to update code"):s(t.map(q=>q.id===L?{...q,is_active:!R}:q))},k=async L=>{const{error:R}=await G.from("invite_codes").delete().eq("id",L);R?fe.error("Failed to delete code"):(fe.success("Code deleted"),s(t.filter($=>$.id!==L)))},S="https://dashboard.relevelup.com",T=L=>{const R=`${S}/join?code=${L}`;navigator.clipboard.writeText(R),fe.success("Link copied to clipboard")},I=`${S}/join`;return e.jsx(Ts,{title:"Invite Codes",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(wu,{title:"Invite Codes",description:"Manage signup invite codes"}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Create New Code"}),e.jsxs(pr,{children:["Share link: ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded text-sm",children:I})]})]}),e.jsx(Oe,{children:e.jsxs("form",{onSubmit:w,className:"flex flex-wrap gap-4 items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"code",children:"Code"}),e.jsx(Re,{id:"code",placeholder:"WELCOME2024",value:l,onChange:L=>i(L.target.value),className:"w-40"})]}),e.jsxs("div",{className:"space-y-2 flex-1 min-w-[200px]",children:[e.jsx(ve,{htmlFor:"description",children:"Description (optional)"}),e.jsx(Re,{id:"description",placeholder:"For marketing campaign",value:d,onChange:L=>u(L.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"maxUses",children:"Max Uses"}),e.jsx(Re,{id:"maxUses",type:"number",placeholder:"Unlimited",value:p,onChange:L=>f(L.target.value),className:"w-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"trialDays",children:"Trial Days"}),e.jsx(Re,{id:"trialDays",type:"number",placeholder:"None",value:y,onChange:L=>_(L.target.value),className:"w-28"})]}),e.jsxs(K,{type:"submit",disabled:a,children:[a?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create"]})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Active Codes"})}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx("p",{className:"text-center py-8 text-muted-foreground",children:"No invite codes yet"}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Code"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{children:"Uses"}),e.jsx(bt,{children:"Trial"}),e.jsx(bt,{children:"Created"}),e.jsx(bt,{children:"Active"}),e.jsx(bt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(L=>e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-mono font-medium",children:L.code}),e.jsx(lt,{className:"text-muted-foreground",children:L.description||"—"}),e.jsxs(lt,{children:[L.uses_count,L.max_uses&&` / ${L.max_uses}`]}),e.jsx(lt,{children:L.trial_days?e.jsxs("span",{className:"text-amber-600 dark:text-amber-400 font-medium",children:[L.trial_days," days"]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(lt,{className:"text-muted-foreground",children:ys(new Date(L.created_at),"MMM d, yyyy")}),e.jsx(lt,{children:e.jsx(Br,{checked:L.is_active,onCheckedChange:()=>j(L.id,L.is_active)})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>T(L.code),title:"Copy invite link",children:e.jsx(ai,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>k(L.id),className:"text-destructive hover:text-destructive",title:"Delete code",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},L.id))})]})})]})]})})},eD=async t=>{try{const{data:s,error:r}=await G.from("push_notification_settings").select("is_enabled").eq("setting_key",t).maybeSingle();return r?(console.error("Error checking notification setting:",r),!0):(s==null?void 0:s.is_enabled)??!0}catch(s){return console.error("Error checking notification setting:",s),!0}},OM=async t=>{try{const{data:s,error:r}=await G.functions.invoke("send-push-notification",{body:t});return r?(console.error("Error sending notification:",r),{success:!1,error:r}):(console.log("Notification sent:",s),{success:!0,data:s})}catch(s){return console.error("Error sending notification:",s),{success:!1,error:s}}},gRt=async(t,s)=>await eD("new_templates")?OM({title:"New Template Available",body:`Check out the new template: ${t}`,url:`/templates/${s}`}):(console.log("New template notifications are disabled"),{success:!1,skipped:!0}),xRt=async(t,s)=>OM({title:"New Academy Video",body:`New video added: ${t}`,url:`/academy/${s}`}),yRt=async(t,s)=>await eD("new_events")?OM({title:"New Event",body:`New event: ${t}`,url:`/events/${s}`}):(console.log("New event notifications are disabled"),{success:!1,skipped:!0}),vRt=async(t,s)=>await eD("new_toolbox")?OM({title:"New Resource Kit",body:`New resource kit available: ${t}`,url:`/toolbox/${s}`}):(console.log("New toolbox notifications are disabled"),{success:!1,skipped:!0}),fye=async(t,s)=>await eD("new_social_swag")?OM({title:"New Social Swag",body:`New social swag available: ${t}`,url:`/social-swag/${s}`}):(console.log("New social swag notifications are disabled"),{success:!1,skipped:!0}),_Rt=async(t,s)=>await eD("new_newsletters")?OM({title:"New Newsletter",body:`New newsletter available: ${t}`,url:`/newsletters/${s}`}):(console.log("New newsletter notifications are disabled"),{success:!1,skipped:!0}),yR={title:"",description:"",image_url:"",video_url:"",event_date:void 0,event_time:"12:00",zoom_link:"",zoom_meeting_id:"",capacity:"",is_published:!1,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0};function bRt(){const t=Pr(),s=rs(),[r,n]=C.useState(!1),[a,o]=C.useState(null),[l,i]=C.useState(yR),[d,u]=C.useState(null),[p,f]=C.useState(null),[y,_]=C.useState(!1),b=C.useRef(null),[w,j]=C.useState(!1),[k,S]=C.useState(null),[T,I]=C.useState(!1),[L,R]=C.useState(null),[$,q]=C.useState(null),[U,H]=C.useState(!0),[Y,se]=C.useState(""),{data:te,isLoading:Q}=wt({queryKey:["admin-events"],queryFn:async()=>{const{data:Se,error:it}=await G.from("events").select("*").order("event_date",{ascending:!0});if(it)throw it;return Se}}),{data:de}=wt({queryKey:["event-registrations-count"],queryFn:async()=>{let Se=[],it=0;const $e=1e3;for(;;){const{data:qe,error:Ze}=await G.from("event_registrations").select("event_id").range(it,it+$e-1);if(Ze)throw Ze;if(!qe||qe.length===0||(Se=Se.concat(qe),qe.length<$e))break;it+=$e}const ct={};return Se.forEach(qe=>{ct[qe.event_id]=(ct[qe.event_id]||0)+1}),ct}}),{data:re,isLoading:ae}=wt({queryKey:["event-registrations-details",k==null?void 0:k.id],queryFn:async()=>{if(!k)return[];const{data:Se,error:it}=await G.from("event_registrations").select("id, user_id, registered_at, zoom_join_url, zoom_name, zoom_email").eq("event_id",k.id).order("registered_at",{ascending:!1});if(it)throw it;if(!Se||Se.length===0)return[];const $e=Se.map(Ze=>Ze.user_id).filter(Boolean);let ct=[];if($e.length>0){const{data:Ze,error:Qe}=await G.from("profiles").select("id, name, email").in("id",$e);if(Qe)throw Qe;ct=Ze||[]}const qe=new Map((ct==null?void 0:ct.map(Ze=>[Ze.id,Ze]))||[]);return Se.map(Ze=>({...Ze,profiles:Ze.user_id&&qe.get(Ze.user_id)||null}))},enabled:!!k}),{data:le,isLoading:he}=wt({queryKey:["event-attendees-details",k==null?void 0:k.id],queryFn:async()=>{if(!k)return[];const{data:Se,error:it}=await G.from("event_attendees").select("id, user_id, zoom_email, zoom_name, join_time, leave_time, duration_minutes, manually_added, created_at").eq("event_id",k.id).order("created_at",{ascending:!1});if(it)throw it;if(!Se||Se.length===0)return[];const $e=Se.map(We=>We.user_id).filter(Boolean);let ct=[];if($e.length>0){const{data:We,error:He}=await G.from("profiles").select("id, name, email").in("id",$e);if(He)throw He;ct=We||[]}const{data:qe}=await G.from("agent_points").select("user_id").eq("event_id",k.id),Ze=new Set((qe==null?void 0:qe.map(We=>We.user_id))||[]),Qe=new Map((ct==null?void 0:ct.map(We=>[We.id,We]))||[]);return Se.map(We=>({...We,profiles:We.user_id&&Qe.get(We.user_id)||null,points_awarded:We.user_id?Ze.has(We.user_id):!1}))},enabled:!!k}),be=Se=>{S(Se),j(!0)},_e=Dt({mutationFn:async Se=>{const{data:{session:it}}=await G.auth.getSession();if(!it)throw new Error("Not authenticated");const $e=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-registrations",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${it.access_token}`},body:JSON.stringify({event_id:Se})}),ct=await $e.json();if(!$e.ok)throw new Error(ct.error||"Failed to sync");return ct},onSuccess:Se=>{s.invalidateQueries({queryKey:["event-registrations-details",k==null?void 0:k.id]}),s.invalidateQueries({queryKey:["event-registrations-count"]}),fe.success(Se.message)},onError:Se=>{fe.error("Failed to sync: "+Se.message)}}),je=Dt({mutationFn:async Se=>{const{data:{session:it}}=await G.auth.getSession();if(!it)throw new Error("Not authenticated");const $e=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-attendees",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${it.access_token}`},body:JSON.stringify({event_id:Se})}),ct=await $e.json();if(!$e.ok)throw new Error(ct.error||"Failed to sync attendees");return ct},onSuccess:Se=>{s.invalidateQueries({queryKey:["event-attendees-details",k==null?void 0:k.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]}),Se!=null&&Se.message?fe.success(Se.message):fe.success(`Synced ${Se.synced||0} attendees. ${Se.points_awarded||0} points awarded!`)},onError:Se=>{fe.error("Failed to sync attendees: "+Se.message)}}),Ne=Dt({mutationFn:async({eventId:Se,testMode:it})=>{const{data:{session:$e}}=await G.auth.getSession();if(!$e)throw new Error("Not authenticated");const ct=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-event-reminder",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${$e.access_token}`},body:JSON.stringify({event_id:Se,test_mode:it})}),qe=await ct.json();if(!ct.ok)throw new Error(qe.error||"Failed to send reminders");return qe},onSuccess:Se=>{Se.test?fe.success(Se.message||"Test email sent!"):fe.success(Se.message||`Reminder emails sent to ${Se.sent} registrants!`)},onError:Se=>{fe.error("Failed to send reminders: "+Se.message)}}),{data:Ge}=wt({queryKey:["all-profiles-for-linking"],queryFn:async()=>{let Se=[],it=0;const $e=1e3;for(;;){const{data:ct,error:qe}=await G.from("profiles").select("id, name, email").order("name",{ascending:!0}).range(it,it+$e-1);if(qe)throw qe;if(!ct||ct.length===0||(Se=[...Se,...ct],ct.length<$e))break;it+=$e}return Se},enabled:T}),we=Dt({mutationFn:async({attendeeId:Se,userId:it,zoomEmail:$e,shouldSaveAlias:ct})=>{const{error:qe}=await G.from("event_attendees").update({user_id:it}).eq("id",Se);if(qe)throw qe;if(ct&&$e){const{error:Qe}=await G.from("zoom_email_aliases").upsert({user_id:it,zoom_email:$e.toLowerCase()},{onConflict:"zoom_email"});Qe&&console.error("Failed to save alias:",Qe)}const Ze=k==null?void 0:k.id;if(Ze){const{data:Qe}=await G.from("user_roles").select("id").eq("user_id",it).eq("role","admin").single();if(!Qe){const{data:We}=await G.from("agent_points").select("id").eq("user_id",it).eq("event_id",Ze).single();We||(await G.rpc("award_attendance_points",{p_user_id:it,p_event_id:Ze,p_points:10,p_reason:"Event Attendance (Manual Link)"}),await G.rpc("check_and_award_badges",{p_user_id:it}))}}return{userId:it,zoomEmail:$e,shouldSaveAlias:ct}},onSuccess:Se=>{s.invalidateQueries({queryKey:["event-attendees-details",k==null?void 0:k.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]});let it="Attendee linked and points awarded!";Se.shouldSaveAlias&&Se.zoomEmail&&(it+=` Email "${Se.zoomEmail}" will be auto-matched in the future.`),fe.success(it),I(!1),R(null),q(null),se("")},onError:Se=>{fe.error("Failed to link attendee: "+Se.message)}}),Me=Se=>{R(Se),q(null),H(!0),se(""),I(!0)},Te=()=>{!L||!$||we.mutate({attendeeId:L.id,userId:$,zoomEmail:L.zoom_email,shouldSaveAlias:U})},Fe=(Ge==null?void 0:Ge.filter(Se=>{var $e,ct;if(!Y)return!0;const it=Y.toLowerCase();return(($e=Se.name)==null?void 0:$e.toLowerCase().includes(it))||((ct=Se.email)==null?void 0:ct.toLowerCase().includes(it))}))||[],Ae=async Se=>{const it=Se.name.split(".").pop(),ct=`${`${crypto.randomUUID()}.${it}`}`,{error:qe}=await G.storage.from("event-images").upload(ct,Se);if(qe)throw qe;const{data:{publicUrl:Ze}}=G.storage.from("event-images").getPublicUrl(ct);return Ze},Ue=Se=>{var $e;const it=($e=Se.target.files)==null?void 0:$e[0];if(it){if(it.size>5*1024*1024){fe.error("Image must be less than 5MB");return}u(it),f(URL.createObjectURL(it))}},ut=()=>{u(null),f(null),i({...l,image_url:""}),b.current&&(b.current.value="")},De=Dt({mutationFn:async Se=>{_(!0);let it=Se.image_url;d&&(it=await Ae(d)||"");const $e=new Date(Se.event_date),[ct,qe]=Se.event_time.split(":");$e.setHours(parseInt(ct),parseInt(qe));const Ze=[new Date($e)];if(Se.is_recurring&&Se.recurrence_end_date){let et=new Date($e);for(;Se.recurrence_pattern==="weekly"?et=IN(et,1):Se.recurrence_pattern==="biweekly"?et=IN(et,2):et=Kh(et,1),!(et>Se.recurrence_end_date);)Ze.push(new Date(et))}const Qe=Ze.map(et=>({title:Se.title,description:Se.description||null,image_url:it||null,video_url:Se.video_url||null,event_date:et.toISOString(),zoom_link:Se.zoom_link,zoom_meeting_id:Se.zoom_meeting_id||null,capacity:Se.capacity?parseInt(Se.capacity):null,is_published:Se.is_published})),{data:We,error:He}=await G.from("events").insert(Qe).select();if(He)throw He;return We&&We.length>0&&yRt(Se.title,We[0].id),Ze.length},onSuccess:Se=>{s.invalidateQueries({queryKey:["admin-events"]}),fe.success(Se>1?`${Se} recurring events created successfully`:"Event created successfully"),n(!1),i(yR),u(null),f(null),_(!1)},onError:Se=>{fe.error("Failed to create event: "+Se.message),_(!1)}}),Rt=Dt({mutationFn:async({id:Se,data:it})=>{_(!0);let $e=it.image_url;d&&($e=await Ae(d)||"");const ct=new Date(it.event_date),[qe,Ze]=it.event_time.split(":");ct.setHours(parseInt(qe),parseInt(Ze));const{error:Qe}=await G.from("events").update({title:it.title,description:it.description||null,image_url:$e||null,video_url:it.video_url||null,event_date:ct.toISOString(),zoom_link:it.zoom_link,zoom_meeting_id:it.zoom_meeting_id||null,capacity:it.capacity?parseInt(it.capacity):null,is_published:it.is_published}).eq("id",Se);if(Qe)throw Qe},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),fe.success("Event updated successfully"),n(!1),o(null),i(yR),u(null),f(null),_(!1)},onError:Se=>{fe.error("Failed to update event: "+Se.message),_(!1)}}),me=Dt({mutationFn:async Se=>{const{error:it}=await G.from("events").delete().eq("id",Se);if(it)throw it},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),fe.success("Event deleted successfully")},onError:Se=>{fe.error("Failed to delete event: "+Se.message)}}),Xe=Se=>{var $e;const it=new Date(Se.event_date);o(Se),i({title:Se.title,description:Se.description||"",image_url:Se.image_url||"",video_url:Se.video_url||"",event_date:it,event_time:ys(it,"HH:mm"),zoom_link:Se.zoom_link,zoom_meeting_id:Se.zoom_meeting_id||"",capacity:(($e=Se.capacity)==null?void 0:$e.toString())||"",is_published:Se.is_published,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0}),f(Se.image_url||null),u(null),n(!0)},ot=Se=>{if(Se.preventDefault(),!l.event_date){fe.error("Please select a date");return}if(l.is_recurring&&!l.recurrence_end_date){fe.error("Please select an end date for recurring events");return}a?Rt.mutate({id:a.id,data:l}):De.mutate(l)},nt=()=>{n(!1),o(null),i(yR),u(null),f(null)};return e.jsx("div",{className:"min-h-screen bg-background p-6",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t("/dashboard"),children:e.jsx(ti,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Event Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Create and manage upcoming events"})]})]}),e.jsxs(Ee,{className:"mb-6",children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{children:"All Events"}),e.jsxs(_s,{open:r,onOpenChange:Se=>!Se&&nt(),children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Event"]})}),e.jsxs(vs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:a?"Edit Event":"Create New Event"})}),e.jsxs("form",{onSubmit:ot,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",value:l.title,onChange:Se=>i({...l,title:Se.target.value}),placeholder:"Event title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(rx,{content:l.description,onChange:Se=>i({...l,description:Se}),placeholder:"Event description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Event Image"}),e.jsx("input",{type:"file",ref:b,accept:"image/*",onChange:Ue,className:"hidden"}),p?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:p,alt:"Event preview",className:"w-full h-32 object-cover rounded-lg border"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:ut,children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs(K,{type:"button",variant:"outline",className:"w-full h-32 border-dashed flex flex-col gap-2",onClick:()=>{var Se;return(Se=b.current)==null?void 0:Se.click()},children:[e.jsx(Za,{className:"h-6 w-6"}),e.jsx("span",{className:"text-sm",children:"Click to upload image"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Date *"}),e.jsxs(Co,{children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!l.event_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),l.event_date?ys(l.event_date,"PPP"):"Pick a date"]})}),e.jsx(No,{className:"w-auto p-0",align:"start",children:e.jsx(jp,{mode:"single",selected:l.event_date,onSelect:Se=>i({...l,event_date:Se}),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"time",children:"Time *"}),e.jsx(Re,{id:"time",type:"time",value:l.event_time,onChange:Se=>i({...l,event_time:Se.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"zoom_link",children:"Zoom Link *"}),e.jsx(Re,{id:"zoom_link",value:l.zoom_link,onChange:Se=>i({...l,zoom_link:Se.target.value}),placeholder:"https://zoom.us/j/...",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"zoom_meeting_id",children:"Zoom Meeting ID (for API registration)"}),e.jsx(Re,{id:"zoom_meeting_id",value:l.zoom_meeting_id,onChange:Se=>i({...l,zoom_meeting_id:Se.target.value}),placeholder:"e.g., 1234567890 (find in Zoom dashboard)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional: Enter the numeric meeting ID for automatic Zoom registration"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"video_url",children:"Promo Video URL (optional)"}),e.jsx(Re,{id:"video_url",value:l.video_url,onChange:Se=>i({...l,video_url:Se.target.value}),placeholder:"YouTube, Vimeo, or Bunny.net embed URL"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a preview/promo video for this event"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"capacity",children:"Capacity (optional)"}),e.jsx(Re,{id:"capacity",type:"number",value:l.capacity,onChange:Se=>i({...l,capacity:Se.target.value}),placeholder:"Leave empty for unlimited",min:"1"})]}),!a&&e.jsxs("div",{className:"space-y-3 rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(EP,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{htmlFor:"is_recurring",children:"Recurring Event"})]}),e.jsx(Br,{id:"is_recurring",checked:l.is_recurring,onCheckedChange:Se=>i({...l,is_recurring:Se})})]}),l.is_recurring&&e.jsxs("div",{className:"space-y-3 pt-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Frequency"}),e.jsxs(sr,{value:l.recurrence_pattern,onValueChange:Se=>i({...l,recurrence_pattern:Se}),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"weekly",children:"Weekly"}),e.jsx(At,{value:"biweekly",children:"Every 2 Weeks"}),e.jsx(At,{value:"monthly",children:"Monthly"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Repeat Until"}),e.jsxs(Co,{children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!l.recurrence_end_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),l.recurrence_end_date?ys(l.recurrence_end_date,"PPP"):"Pick end date"]})}),e.jsx(No,{className:"w-auto p-0",align:"start",children:e.jsx(jp,{mode:"single",selected:l.recurrence_end_date,onSelect:Se=>i({...l,recurrence_end_date:Se}),disabled:Se=>Se<(l.event_date||new Date),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),l.event_date&&l.recurrence_end_date&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This will create ",(()=>{let Se=1,it=new Date(l.event_date);for(;it=l.recurrence_pattern==="weekly"?IN(it,1):l.recurrence_pattern==="biweekly"?IN(it,2):Kh(it,1),!(it>l.recurrence_end_date);)Se++;return Se})()," events with the same Zoom link"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{htmlFor:"is_published",children:"Published"}),e.jsx(Br,{id:"is_published",checked:l.is_published,onCheckedChange:Se=>i({...l,is_published:Se})})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:nt,className:"flex-1",children:"Cancel"}),e.jsx(K,{type:"submit",className:"flex-1",disabled:De.isPending||Rt.isPending||y,children:y?"Uploading...":a?"Update Event":l.is_recurring&&l.event_date&&l.recurrence_end_date?"Create Recurring Events":"Create Event"})]})]})]})]})]}),e.jsx(Oe,{children:Q?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading events..."}):(te==null?void 0:te.length)===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No events yet. Create your first event!"}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Date & Time"}),e.jsx(bt,{children:"Registrations"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:te==null?void 0:te.map(Se=>e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium",children:Se.title}),e.jsx(lt,{children:ys(new Date(Se.event_date),"PPP p")}),e.jsx(lt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>be(Se),children:[e.jsx(hr,{className:"h-4 w-4"}),(de==null?void 0:de[Se.id])||0,Se.capacity&&` / ${Se.capacity}`]})}),e.jsx(lt,{children:e.jsx("span",{className:Pt("px-2 py-1 rounded-full text-xs font-medium",Se.is_published?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200"),children:Se.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(Se.zoom_link,"_blank"),title:"Open Zoom Link",children:e.jsx(sn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Xe(Se),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this event?")&&me.mutate(Se.id)},children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},Se.id))})]})})]}),e.jsx(_s,{open:w,onOpenChange:j,children:e.jsxs(vs,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),k==null?void 0:k.title]}),e.jsx(Kr,{children:"View registrations and attendees for this event"})]}),e.jsxs("div",{className:"flex items-center justify-end mb-4 gap-2 flex-wrap",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Ne.mutate({eventId:k.id,testMode:!0}),disabled:Ne.isPending,children:[e.jsx(br,{className:Pt("h-4 w-4 mr-2",Ne.isPending&&"animate-spin")}),"Send Test to Me"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Ne.mutate({eventId:k.id}),disabled:Ne.isPending||!(re!=null&&re.length),children:[e.jsx(br,{className:Pt("h-4 w-4 mr-2",Ne.isPending&&"animate-spin")}),Ne.isPending?"Sending...":"Send Reminder to All"]}),(k==null?void 0:k.zoom_meeting_id)&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>_e.mutate(k.id),disabled:_e.isPending,children:[e.jsx(Po,{className:Pt("h-4 w-4 mr-2",_e.isPending&&"animate-spin")}),_e.isPending?"Syncing...":"Sync Registrations"]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>je.mutate(k.id),disabled:je.isPending,children:[e.jsx(ao,{className:Pt("h-4 w-4 mr-2",je.isPending&&"animate-spin")}),je.isPending?"Syncing...":"Sync Attendees & Award Points"]})]})]}),e.jsxs(ka,{defaultValue:"registrations",className:"w-full",children:[e.jsxs(_a,{className:"grid w-full grid-cols-2",children:[e.jsxs(js,{value:"registrations",className:"gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Registrations (",(re==null?void 0:re.length)||0,")"]}),e.jsxs(js,{value:"attendees",className:"gap-2",children:[e.jsx(ua,{className:"h-4 w-4"}),"Attendees (",(le==null?void 0:le.length)||0,")"]})]}),e.jsx(zs,{value:"registrations",className:"mt-4",children:ae?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading registrations..."}):(re==null?void 0:re.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No registrations yet for this event."}),(k==null?void 0:k.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Registrations" to import from Zoom.'})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:"Registered"}),e.jsx(bt,{children:"Status"})]})}),e.jsx(Pn,{children:re==null?void 0:re.map(Se=>{var qe,Ze;const it=((qe=Se.profiles)==null?void 0:qe.name)||Se.zoom_name||"Unknown",$e=((Ze=Se.profiles)==null?void 0:Ze.email)||Se.zoom_email||null,ct=!Se.user_id;return e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[it,ct&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"External"})]})}),e.jsx(lt,{children:$e?e.jsxs("a",{href:`mailto:${$e}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(br,{className:"h-3 w-3"}),$e]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(lt,{className:"text-muted-foreground text-sm",children:ys(new Date(Se.registered_at),"MMM d, yyyy h:mm a")}),e.jsx(lt,{children:Se.zoom_join_url?e.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",children:"Registered"}):e.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-muted text-muted-foreground",children:"Pending"})})]},Se.id)})})]})}),e.jsx(zs,{value:"attendees",className:"mt-4",children:he?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading attendees..."}):(le==null?void 0:le.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No attendees recorded yet."}),(k==null?void 0:k.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Attendees & Award Points" after the event ends to import actual participants from Zoom.'})]}):e.jsxs(e.Fragment,{children:[(le==null?void 0:le.filter(Se=>!Se.user_id).length)>0&&e.jsxs("div",{className:"mb-6 p-4 border border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ll,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}),e.jsxs("h4",{className:"font-medium text-amber-800 dark:text-amber-200",children:["Unmatched Attendees (",le==null?void 0:le.filter(Se=>!Se.user_id).length,")"]})]}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300 mb-3",children:"These attendees couldn't be matched to a profile. Link them to award points."}),e.jsx("div",{className:"space-y-2",children:le==null?void 0:le.filter(Se=>!Se.user_id).map(Se=>e.jsxs("div",{className:"flex items-center justify-between p-2 bg-background rounded border",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium text-sm",children:Se.zoom_name||"Unknown"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Se.zoom_email||"No email"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Me(Se),className:"gap-1",children:[e.jsx(Wo,{className:"h-3 w-3"}),"Link to Profile"]})]},Se.id))})]}),e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:"Duration"}),e.jsx(bt,{children:"Points"})]})}),e.jsx(Pn,{children:le==null?void 0:le.filter(Se=>Se.user_id).map(Se=>{var ct,qe;const it=((ct=Se.profiles)==null?void 0:ct.name)||Se.zoom_name||"Unknown",$e=((qe=Se.profiles)==null?void 0:qe.email)||Se.zoom_email||null;return e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[it,Se.manually_added&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",children:"Manual"})]})}),e.jsx(lt,{children:$e?e.jsxs("a",{href:`mailto:${$e}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(br,{className:"h-3 w-3"}),$e]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(lt,{children:Se.duration_minutes?e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-sm",children:[e.jsx(Tn,{className:"h-3 w-3"}),Se.duration_minutes," min"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(lt,{children:Se.points_awarded?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",children:[e.jsx(ao,{className:"h-3 w-3"}),"+10 pts"]}):e.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-muted text-muted-foreground",children:"Pending"})})]},Se.id)})})]})]})})]})]})}),e.jsx(_s,{open:T,onOpenChange:I,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(Wo,{className:"h-5 w-5"}),"Link Attendee to Profile"]}),e.jsx(Kr,{children:"Link this Zoom attendee to an existing member profile to award them points."})]}),L&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[e.jsx("p",{className:"text-sm font-medium",children:L.zoom_name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:L.zoom_email||"No email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Search for a profile"}),e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name or email...",value:Y,onChange:Se=>se(Se.target.value),className:"pl-9"})]})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-md",children:Fe.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No profiles found"}):e.jsx("div",{className:"divide-y",children:Fe.slice(0,20).map(Se=>e.jsxs("button",{type:"button",onClick:()=>q(Se.id),className:Pt("w-full p-3 text-left hover:bg-muted/50 transition-colors",$===Se.id&&"bg-primary/10 border-l-2 border-primary"),children:[e.jsx("p",{className:"text-sm font-medium",children:Se.name||"Unnamed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Se.email})]},Se.id))})}),L.zoom_email&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Bo,{id:"save-alias",checked:U,onCheckedChange:Se=>H(Se)}),e.jsx("label",{htmlFor:"save-alias",className:"text-sm text-muted-foreground cursor-pointer",children:"Remember this email for future auto-matching"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),e.jsx(K,{onClick:Te,disabled:!$||we.isPending,children:we.isPending?"Linking...":"Link & Award Points"})]})]})]})})]})})}function wRt({selectedKitIds:t,onChange:s}){const[r,n]=C.useState(""),[a,o]=C.useState(!1),{data:l=[]}=wt({queryKey:["all-resource-kits-picker"],queryFn:async()=>{const{data:f,error:y}=await G.from("resource_kits").select("id, name, featured_image_url").eq("is_published",!0).order("name");if(y)throw y;return f}}),i=l.filter(f=>t.includes(f.id)),d=l.filter(f=>!t.includes(f.id)&&f.name.toLowerCase().includes(r.toLowerCase())),u=f=>{s([...t,f])},p=f=>{s(t.filter(y=>y!==f))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(dl,{className:"h-4 w-4"}),"Linked Toolkits"]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(f=>e.jsxs(rt,{variant:"secondary",className:"gap-1 pr-1",children:[f.name,e.jsx("button",{type:"button",onClick:()=>p(f.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Ur,{className:"h-3 w-3"})})]},f.id))}),e.jsxs(Co,{open:a,onOpenChange:o,children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(dl,{className:"h-3.5 w-3.5"}),"Add Toolkit"]})}),e.jsxs(No,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(gn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search toolkits...",value:r,onChange:f=>n(f.target.value),className:"pl-7 h-8 text-sm"})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5",children:d.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:r?"No toolkits found":"All toolkits selected"}):d.map(f=>e.jsxs("button",{type:"button",onClick:()=>{u(f.id),n("")},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[f.featured_image_url?e.jsx("img",{src:f.featured_image_url,alt:"",className:"w-8 h-8 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(dl,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("span",{className:"truncate",children:f.name})]},f.id))})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link toolkits that agents can download alongside this template."})]})}const jRt=()=>{const{user:t}=Hs(),{toast:s}=Pa(),r=rs(),[n,a]=Pc(),[o,l]=C.useState(!1),[i,d]=C.useState(null),[u,p]=C.useState({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),[f,y]=C.useState(null),[_,b]=C.useState(0),[w,j]=C.useState(!1),[k,S]=C.useState(null),[T,I]=C.useState(""),[L,R]=C.useState([]),[$,q]=C.useState(""),[U,H]=C.useState(""),[Y,se]=C.useState(!1),[te,Q]=C.useState(!1),{data:de=[]}=wt({queryKey:["template-categories"],queryFn:async()=>{const{data:Xe,error:ot}=await G.from("template_categories").select("*").order("name");if(ot)throw ot;return Xe}}),{data:re=[]}=wt({queryKey:["template-types"],queryFn:async()=>{const{data:Xe,error:ot}=await G.from("template_types").select("*").order("name");if(ot)throw ot;return Xe}}),{data:ae=[],isLoading:le}=wt({queryKey:["canva-templates-admin"],queryFn:async()=>{const{data:Xe,error:ot}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(ot)throw ot;const{data:nt,error:Se}=await G.from("template_links").select("*").order("sort_order");if(Se)throw Se;const{data:it,error:$e}=await G.from("template_guides").select("*").order("sort_order");if($e)throw $e;return Xe.map(qe=>({...qe,links:(nt==null?void 0:nt.filter(Ze=>Ze.template_id===qe.id))||[],guides:(it==null?void 0:it.filter(Ze=>Ze.template_id===qe.id))||[]}))}});C.useEffect(()=>{const Xe=n.get("edit");if(Xe&&ae.length>0){const ot=ae.find(nt=>nt.id===Xe);ot&&(Ge(ot),a({},{replace:!0}))}},[ae,n]);const he=Dt({mutationFn:async Xe=>{const{data:ot,error:nt}=await G.from("template_categories").insert({name:Xe}).select().single();if(nt)throw nt;return ot},onSuccess:Xe=>{r.invalidateQueries({queryKey:["template-categories"]}),p({...u,category_id:Xe.id}),q(""),se(!1),s({title:"Category added"})},onError:Xe=>{s({title:"Error adding category",description:Xe.message,variant:"destructive"})}}),be=Dt({mutationFn:async Xe=>{const{data:ot,error:nt}=await G.from("template_types").insert({name:Xe}).select().single();if(nt)throw nt;return ot},onSuccess:Xe=>{r.invalidateQueries({queryKey:["template-types"]}),p({...u,type_id:Xe.id}),H(""),Q(!1),s({title:"Type added"})},onError:Xe=>{s({title:"Error adding type",description:Xe.message,variant:"destructive"})}}),_e=Dt({mutationFn:async Xe=>{var $e;let ot=Xe.existingImageUrl;if(Xe.image){const ct=Xe.image.name.split(".").pop(),qe=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ct}`,{error:Ze}=await G.storage.from("template-previews").upload(qe,Xe.image);if(Ze)throw Ze;const{data:Qe}=G.storage.from("template-previews").getPublicUrl(qe);ot=Qe.publicUrl}const nt={name:Xe.template.name,description:Xe.template.description||null,category_id:Xe.template.category_id||null,type_id:Xe.template.type_id||null,preview_image_url:ot,video_url:Xe.videoUrl||null,publish_date:Xe.template.publish_date?new Date(Xe.template.publish_date).toISOString():new Date().toISOString(),created_by:t==null?void 0:t.id};let Se=Xe.templateId;if(Se){const{error:ct}=await G.from("canva_templates").update(nt).eq("id",Se);if(ct)throw ct;const{error:qe}=await G.from("template_links").delete().eq("template_id",Se);if(qe)throw qe;const Ze=(($e=Xe.existingGuides)==null?void 0:$e.map(He=>He.id).filter(Boolean))||[],Qe=Xe.template.guides.map(He=>He.id).filter(Boolean),We=Ze.filter(He=>!Qe.includes(He));We.length>0&&await G.from("template_guides").delete().in("id",We)}else{const{data:ct,error:qe}=await G.from("canva_templates").insert(nt).select().single();if(qe)throw qe;Se=ct.id,gRt(Xe.template.name,ct.id)}const it=Xe.template.links.filter(ct=>ct.title.trim()&&ct.canva_share_link.trim());if(it.length>0){const ct=it.map((Ze,Qe)=>({template_id:Se,title:Ze.title.trim(),canva_share_link:Ze.canva_share_link.trim(),sort_order:Qe})),{error:qe}=await G.from("template_links").insert(ct);if(qe)throw qe}for(let ct=0;ct0)){const{error:ct}=await G.from("resource_kit_templates").insert(Xe.linkedKitIds.map(qe=>({template_id:Se,kit_id:qe})));if(ct)throw ct}},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),Ne(),l(!1),s({title:i?"Template updated":"Template created"})},onError:Xe=>{s({title:"Error saving template",description:Xe.message,variant:"destructive"})}}),je=Dt({mutationFn:async Xe=>{const{error:ot}=await G.from("canva_templates").delete().eq("id",Xe);if(ot)throw ot},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),s({title:"Template deleted"})},onError:Xe=>{s({title:"Error deleting template",description:Xe.message,variant:"destructive"})}}),Ne=()=>{p({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),S(null),I(""),d(null),se(!1),Q(!1),q(""),H(""),y(null),b(0),j(!1),R([])},Ge=async Xe=>{var nt;d(Xe),p({name:Xe.name,description:Xe.description||"",category_id:Xe.category_id||"",type_id:Xe.type_id||"",publish_date:Xe.publish_date?new Date(Xe.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],links:Xe.links&&Xe.links.length>0?Xe.links.map(Se=>({id:Se.id,title:Se.title,canva_share_link:Se.canva_share_link,sort_order:Se.sort_order})):[{title:"",canva_share_link:"",sort_order:0}],guides:((nt=Xe.guides)==null?void 0:nt.map(Se=>({id:Se.id,name:Se.name,file_url:Se.file_url,file_type:Se.file_type,file_size:Se.file_size,sort_order:Se.sort_order})))||[],video_url:Xe.video_url||""}),I(Xe.preview_image_url||""),y(null);const{data:ot}=await G.from("resource_kit_templates").select("kit_id").eq("template_id",Xe.id);R((ot||[]).map(Se=>Se.kit_id)),l(!0)},we=Xe=>{var nt;const ot=(nt=Xe.target.files)==null?void 0:nt[0];ot&&(S(ot),I(URL.createObjectURL(ot)))},Me=()=>{p({...u,links:[...u.links,{title:"",canva_share_link:"",sort_order:u.links.length}]})},Te=Xe=>{if(u.links.length<=1)return;const ot=u.links.filter((nt,Se)=>Se!==Xe);p({...u,links:ot})},Fe=(Xe,ot,nt)=>{const Se=[...u.links];Se[Xe]={...Se[Xe],[ot]:nt},p({...u,links:Se})},Ae=Xe=>{const ot=Xe.target.files;if(!ot)return;const nt=Array.from(ot).map((Se,it)=>({name:Se.name.replace(/\.[^/.]+$/,""),file_url:"",file_type:Se.type,file_size:Se.size,sort_order:u.guides.length+it,file:Se}));p({...u,guides:[...u.guides,...nt]}),Xe.target.value=""},Ue=Xe=>{const ot=u.guides.filter((nt,Se)=>Se!==Xe);p({...u,guides:ot})},ut=(Xe,ot)=>{const nt=[...u.guides];nt[Xe]={...nt[Xe],name:ot},p({...u,guides:nt})},De=async()=>{if(!f)return null;j(!0),b(0);try{const{data:Xe,error:ot}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:u.name||f.name}});if(ot)throw new Error(ot.message);const{videoId:nt,libraryId:Se}=Xe,{data:it,error:$e}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:nt}});if($e)throw new Error($e.message);const ct=new XMLHttpRequest;return await new Promise((Ze,Qe)=>{ct.upload.addEventListener("progress",We=>{if(We.lengthComputable){const He=Math.round(We.loaded/We.total*100);b(He)}}),ct.addEventListener("load",()=>{ct.status>=200&&ct.status<300?Ze():Qe(new Error(`Upload failed with status ${ct.status}`))}),ct.addEventListener("error",()=>Qe(new Error("Upload failed"))),ct.open("PUT",it.uploadUrl),ct.setRequestHeader("AccessKey",it.apiKey),ct.send(f)}),`https://player.mediadelivery.net/embed/${Se}/${nt}`}catch(Xe){return console.error("Bunny upload error:",Xe),s({title:"Video upload failed",description:Xe instanceof Error?Xe.message:"Unknown error",variant:"destructive"}),null}finally{j(!1)}},Rt=Xe=>{var nt;const ot=(nt=Xe.target.files)==null?void 0:nt[0];ot&&y(ot),Xe.target.value=""},me=async Xe=>{if(Xe.preventDefault(),!u.name.trim()){s({title:"Please enter a template name",variant:"destructive"});return}if(u.links.filter(Se=>Se.title.trim()&&Se.canva_share_link.trim()).length===0){s({title:"Please add at least one Canva link",variant:"destructive"});return}let nt=u.video_url;if(f){const Se=await De();if(!Se)return;nt=Se}_e.mutate({template:u,image:k,existingImageUrl:(i==null?void 0:i.preview_image_url)||null,templateId:i==null?void 0:i.id,existingGuides:i==null?void 0:i.guides,videoUrl:nt,linkedKitIds:L})};return e.jsx(Ts,{title:"Manage Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(wu,{title:"Manage Templates",description:"Create and manage Canva templates"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Templates"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ae.length})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Categories"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:de.length})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Template Types"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:re.length})})]})]}),e.jsxs(_s,{open:o,onOpenChange:Xe=>{l(Xe),Xe||Ne()},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Template"]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:i?"Edit Template":"Add New Template"})}),e.jsxs("form",{onSubmit:me,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Name *"}),e.jsx(Re,{id:"name",value:u.name,onChange:Xe=>p({...u,name:Xe.target.value}),placeholder:"Template name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(rx,{content:u.description,onChange:Xe=>p({...u,description:Xe}),placeholder:"Brief description of the template",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Canva Links *"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Me,className:"gap-1",children:[e.jsx(Zs,{className:"h-3 w-3"}),"Add Link"]})]}),e.jsx("div",{className:"space-y-3",children:u.links.map((Xe,ot)=>e.jsxs("div",{className:"flex gap-2 items-start p-3 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Re,{value:Xe.title,onChange:nt=>Fe(ot,"title",nt.target.value),placeholder:"Link title (e.g., Instagram Post, Story)"}),e.jsx(Re,{value:Xe.canva_share_link,onChange:nt=>Fe(ot,"canva_share_link",nt.target.value),placeholder:"https://www.canva.com/design/..."})]}),u.links.length>1&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>Te(ot),children:e.jsx(Ur,{className:"h-4 w-4"})})]},ot))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Category"}),Y?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:$,onChange:Xe=>q(Xe.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>$.trim()&&he.mutate($.trim()),disabled:he.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{se(!1),q("")},children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(sr,{value:u.category_id,onValueChange:Xe=>p({...u,category_id:Xe}),children:[e.jsx(er,{className:"flex-1",children:e.jsx(rr,{placeholder:"Select category"})}),e.jsx(tr,{children:de.map(Xe=>e.jsx(At,{value:Xe.id,children:Xe.name},Xe.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>se(!0),children:e.jsx(Zs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Template Type"}),te?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:U,onChange:Xe=>H(Xe.target.value),placeholder:"New type name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>U.trim()&&be.mutate(U.trim()),disabled:be.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Q(!1),H("")},children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(sr,{value:u.type_id,onValueChange:Xe=>p({...u,type_id:Xe}),children:[e.jsx(er,{className:"flex-1",children:e.jsx(rr,{placeholder:"Select type"})}),e.jsx(tr,{children:re.map(Xe=>e.jsx(At,{value:Xe.id,children:Xe.name},Xe.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>Q(!0),children:e.jsx(Zs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Re,{id:"publish_date",type:"date",value:u.publish_date,onChange:Xe=>p({...u,publish_date:Xe.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Templates are sorted by publish date (newest first) on the member page"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[T?e.jsxs("div",{className:"relative w-32 h-24 rounded-lg overflow-hidden border bg-muted",children:[e.jsx("img",{src:T,alt:"Preview",className:"w-full h-full object-cover"}),e.jsx(K,{type:"button",size:"icon",variant:"destructive",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>{S(null),I("")},children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsx("div",{className:"w-32 h-24 rounded-lg border-2 border-dashed border-muted-foreground/25 flex items-center justify-center",children:e.jsx(Jo,{className:"h-8 w-8 text-muted-foreground/50"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(Re,{type:"file",accept:"image/*",onChange:we,className:"cursor-pointer"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Upload a preview image for this template"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{children:"Video (Optional)"}),u.video_url&&!f?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/30",children:[e.jsx(Nn,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:"Video uploaded"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>p({...u,video_url:""}),className:"text-destructive hover:text-destructive",children:"Remove"})]}),e.jsx("div",{className:"aspect-video max-w-md rounded-lg overflow-hidden border",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]}):w?e.jsxs("div",{className:"space-y-2 p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ms,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm",children:["Uploading video... ",_,"%"]})]}),e.jsx(Ti,{value:_,className:"h-2"})]}):f?e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/30",children:[e.jsx(Nn,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:f.name}),e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(f.size/1024/1024).toFixed(1)," MB"]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>y(null),children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(Re,{type:"file",accept:"video/*",onChange:Rt,className:"hidden"}),e.jsxs("div",{className:"flex items-center justify-center gap-2 p-6 border-2 border-dashed rounded-lg hover:border-primary/50 transition-colors",children:[e.jsx(Nn,{className:"h-8 w-8 text-muted-foreground/50"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Click to upload a video"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Upload a video to embed on the template page (Bunny.net)"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Guide Files (PDFs)"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(Re,{type:"file",accept:".pdf,.doc,.docx",multiple:!0,onChange:Ae,className:"hidden"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",asChild:!0,children:e.jsxs("span",{children:[e.jsx(Za,{className:"h-3 w-3"}),"Add Files"]})})]})]}),u.guides.length>0?e.jsx("div",{className:"space-y-2",children:u.guides.map((Xe,ot)=>e.jsxs("div",{className:"flex gap-2 items-center p-3 border rounded-lg bg-muted/30",children:[e.jsx(In,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx(Re,{value:Xe.name,onChange:nt=>ut(ot,nt.target.value),placeholder:"Guide name",className:"flex-1"}),Xe.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(Xe.file_size/1024).toFixed(0)," KB"]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>Ue(ot),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Xe.id||ot))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No guide files added. Upload PDFs to help agents understand how to use this template."})]}),e.jsx(wRt,{selectedKitIds:L,onChange:R}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{l(!1),Ne()},children:"Cancel"}),e.jsx(K,{type:"submit",disabled:_e.isPending,children:_e.isPending?"Saving...":i?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:le?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):ae.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No templates yet. Add your first template!"}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Preview"}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Links"}),e.jsx(bt,{children:"Category"}),e.jsx(bt,{children:"Type"}),e.jsx(bt,{children:"Publish Date"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:ae.map(Xe=>{var ot,nt,Se,it,$e;return e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsx("div",{className:"w-16 h-12 rounded overflow-hidden bg-muted",children:Xe.preview_image_url?e.jsx("img",{src:Xe.preview_image_url,alt:Xe.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Jo,{className:"h-4 w-4 text-muted-foreground"})})})}),e.jsx(lt,{className:"font-medium",children:Xe.name}),e.jsx(lt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs(rt,{variant:"secondary",children:[((ot=Xe.links)==null?void 0:ot.length)||0," link",(((nt=Xe.links)==null?void 0:nt.length)||0)!==1?"s":""]}),(((Se=Xe.guides)==null?void 0:Se.length)||0)>0&&e.jsxs(rt,{variant:"outline",className:"gap-1",children:[e.jsx(In,{className:"h-3 w-3"}),(it=Xe.guides)==null?void 0:it.length," guide",((($e=Xe.guides)==null?void 0:$e.length)||0)!==1?"s":""]})]})}),e.jsx(lt,{children:Xe.category?e.jsx(rt,{variant:"secondary",children:Xe.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(lt,{children:Xe.type?e.jsx(rt,{variant:"outline",children:Xe.type.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(lt,{className:"text-muted-foreground",children:new Date(Xe.publish_date).toLocaleDateString()}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"icon",variant:"ghost",onClick:()=>Ge(Xe),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&je.mutate(Xe.id)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},Xe.id)})})]})})})]})})};function BKe({selectedTemplateIds:t,onChange:s}){const[r,n]=C.useState(""),[a,o]=C.useState(!1),{data:l=[]}=wt({queryKey:["all-canva-templates-picker"],queryFn:async()=>{const{data:f,error:y}=await G.from("canva_templates").select("id, name, preview_image_url").order("name");if(y)throw y;return f}}),i=l.filter(f=>t.includes(f.id)),d=l.filter(f=>!t.includes(f.id)&&f.name.toLowerCase().includes(r.toLowerCase())),u=f=>{s([...t,f])},p=f=>{s(t.filter(y=>y!==f))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(uk,{className:"h-4 w-4"}),"Linked Templates"]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(f=>e.jsxs(rt,{variant:"secondary",className:"gap-1 pr-1",children:[f.name,e.jsx("button",{type:"button",onClick:()=>p(f.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Ur,{className:"h-3 w-3"})})]},f.id))}),e.jsxs(Co,{open:a,onOpenChange:o,children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(uk,{className:"h-3.5 w-3.5"}),"Add Template"]})}),e.jsxs(No,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(gn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search templates...",value:r,onChange:f=>n(f.target.value),className:"pl-7 h-8 text-sm"})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5",children:d.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:r?"No templates found":"All templates selected"}):d.map(f=>e.jsxs("button",{type:"button",onClick:()=>{u(f.id),n("")},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[f.preview_image_url?e.jsx("img",{src:f.preview_image_url,alt:"",className:"w-8 h-8 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(uk,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("span",{className:"truncate",children:f.name})]},f.id))})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link templates that agents can use alongside this content."})]})}const NRt=[{value:"bunny_stream",label:"Bunny.net Stream (Upload)"},{value:"youtube",label:"YouTube"},{value:"vimeo",label:"Vimeo"},{value:"google_drive",label:"Google Drive"},{value:"amazon_s3",label:"Amazon S3"},{value:"loom",label:"Loom"},{value:"other",label:"Other"}],kRt=()=>{const{user:t}=Hs(),[s,r]=Pc(),{toast:n}=Pa(),a=rs(),[o,l]=C.useState(!1),[i,d]=C.useState(null),[u,p]=C.useState({title:"",description:"",video_url:"",video_type:"youtube",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[f,y]=C.useState(null),[_,b]=C.useState(""),[w,j]=C.useState([]),[k,S]=C.useState([]),[T,I]=C.useState([]),[L,R]=C.useState([]),[$,q]=C.useState(""),[U,H]=C.useState(!1),[Y,se]=C.useState(null),[te,Q]=C.useState(0),[de,re]=C.useState(!1),[ae,le]=C.useState(null),{data:he=[]}=wt({queryKey:["academy-categories"],queryFn:async()=>{const{data:me,error:Xe}=await G.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(Xe)throw Xe;return me}}),{data:be=[],isLoading:_e}=wt({queryKey:["academy-videos-admin"],queryFn:async()=>{const{data:me,error:Xe}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).order("publish_date",{ascending:!1});if(Xe)throw Xe;const{data:ot,error:nt}=await G.from("academy_resources").select("*").order("sort_order");if(nt)throw nt;return me.map(it=>({...it,resources:(ot==null?void 0:ot.filter($e=>$e.video_id===it.id))||[]}))}});C.useEffect(()=>{const me=s.get("edit");if(me&&be.length>0){const Xe=be.find(ot=>ot.id===me);Xe&&(Te(Xe),r({},{replace:!0}))}},[be,s]);const je=Dt({mutationFn:async me=>{const{data:Xe,error:ot}=await G.from("academy_categories").insert({name:me,sort_order:he.length}).select().single();if(ot)throw ot;return Xe},onSuccess:me=>{a.invalidateQueries({queryKey:["academy-categories"]}),p({...u,category_id:me.id}),q(""),H(!1),n({title:"Category added"})},onError:me=>{n({title:"Error adding category",description:me.message,variant:"destructive"})}}),Ne=Dt({mutationFn:async me=>{let Xe=me.existingThumbnailUrl;if(me.thumbnail){const Se=me.thumbnail.name.split(".").pop(),it=`thumbnails/${Date.now()}-${Math.random().toString(36).substring(7)}.${Se}`,{error:$e}=await G.storage.from("academy-resources").upload(it,me.thumbnail);if($e)throw $e;const{data:ct}=G.storage.from("academy-resources").getPublicUrl(it);Xe=ct.publicUrl}const ot={title:me.video.title,description:me.video.description||null,video_url:me.video.video_url,video_type:me.video.video_type,duration:me.video.duration||null,thumbnail_url:Xe,category_id:me.video.category_id||null,publish_date:me.video.publish_date?new Date(me.video.publish_date).toISOString():new Date().toISOString(),is_published:me.video.is_published,created_by:t==null?void 0:t.id};let nt=me.videoId;if(nt){const{error:Se}=await G.from("academy_videos").update(ot).eq("id",nt);if(Se)throw Se}else{const{data:Se,error:it}=await G.from("academy_videos").insert(ot).select().single();if(it)throw it;nt=Se.id,xRt(me.video.title,Se.id)}if(me.resourcesToDelete.length>0){const{error:Se}=await G.from("academy_resources").delete().in("id",me.resourcesToDelete);if(Se)throw Se}for(let Se=0;Se0){const{error:Se}=await G.from("academy_video_templates").insert(L.map(it=>({video_id:nt,template_id:it})));if(Se)throw Se}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),Me(),l(!1),n({title:i?"Video updated":"Video created"})},onError:me=>{n({title:"Error saving video",description:me.message,variant:"destructive"})}}),Ge=Dt({mutationFn:async me=>{const{error:Xe}=await G.from("academy_videos").delete().eq("id",me);if(Xe)throw Xe},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),n({title:"Video deleted"})},onError:me=>{n({title:"Error deleting video",description:me.message,variant:"destructive"})}}),we=Dt({mutationFn:async({id:me,is_published:Xe})=>{const{error:ot}=await G.from("academy_videos").update({is_published:Xe}).eq("id",me);if(ot)throw ot},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]})},onError:me=>{n({title:"Error updating video",description:me.message,variant:"destructive"})}}),Me=()=>{p({title:"",description:"",video_url:"",video_type:"bunny_stream",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),y(null),b(""),j([]),S([]),I([]),d(null),R([]),q(""),se(null),Q(0),re(!1),le(null)},Te=async me=>{d(me),p({title:me.title,description:me.description||"",video_url:me.video_url,video_type:me.video_type,duration:me.duration||"",category_id:me.category_id||"",publish_date:me.publish_date?new Date(me.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:me.is_published}),b(me.thumbnail_url||""),S(me.resources||[]),j([]),I([]);const{data:Xe}=await G.from("academy_video_templates").select("template_id").eq("video_id",me.id);R((Xe||[]).map(ot=>ot.template_id)),l(!0)},Fe=me=>{var ot;const Xe=(ot=me.target.files)==null?void 0:ot[0];Xe&&(y(Xe),b(URL.createObjectURL(Xe)))},Ae=me=>{const Xe=me.target.files;if(Xe){const ot=Array.from(Xe).map(nt=>({file:nt,title:nt.name.replace(/\.[^/.]+$/,"")}));j([...w,...ot])}me.target.value=""},Ue=me=>{j(w.filter((Xe,ot)=>ot!==me))},ut=me=>{I([...T,me]),S(k.filter(Xe=>Xe.id!==me))},De=async()=>{if(!Y)return null;re(!0),Q(0);try{const{data:me,error:Xe}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:u.title||Y.name}});if(Xe)throw new Error(Xe.message);const{videoId:ot,libraryId:nt}=me;le(ot);const{data:Se,error:it}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:ot}});if(it)throw new Error(it.message);const $e=new XMLHttpRequest;return await new Promise((qe,Ze)=>{$e.upload.addEventListener("progress",Qe=>{if(Qe.lengthComputable){const We=Math.round(Qe.loaded/Qe.total*100);Q(We)}}),$e.addEventListener("load",()=>{$e.status>=200&&$e.status<300?qe():Ze(new Error(`Upload failed with status ${$e.status}`))}),$e.addEventListener("error",()=>Ze(new Error("Upload failed"))),$e.open("PUT",Se.uploadUrl),$e.setRequestHeader("AccessKey",Se.apiKey),$e.send(Y)}),`https://player.mediadelivery.net/embed/${nt}/${ot}`}catch(me){return console.error("Bunny upload error:",me),n({title:"Video upload failed",description:me instanceof Error?me.message:"Unknown error",variant:"destructive"}),null}finally{re(!1)}},Rt=async me=>{if(me.preventDefault(),!u.title.trim()){n({title:"Please enter a video title",variant:"destructive"});return}let Xe=u.video_url;if(u.video_type==="bunny_stream"&&Y&&!i){const ot=await De();if(!ot)return;Xe=ot}else if(!u.video_url.trim()&&u.video_type!=="bunny_stream"){n({title:"Please enter a video URL",variant:"destructive"});return}else if(u.video_type==="bunny_stream"&&!Y&&!u.video_url&&!i){n({title:"Please select a video file to upload",variant:"destructive"});return}Ne.mutate({video:{...u,video_url:Xe},thumbnail:f,existingThumbnailUrl:(i==null?void 0:i.thumbnail_url)||null,videoId:i==null?void 0:i.id,newResources:w,resourcesToDelete:T})};return e.jsx(Ts,{title:"Manage Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(wu,{title:"Manage Academy",description:"Create and manage training videos and resources"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Videos"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:be.length})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:be.filter(me=>me.is_published).length})})]})]}),e.jsxs(_s,{open:o,onOpenChange:me=>{l(me),me||Me()},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Video"]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:i?"Edit Video":"Add New Video"})}),e.jsxs("form",{onSubmit:Rt,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",value:u.title,onChange:me=>p({...u,title:me.target.value}),placeholder:"Video title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(rx,{content:u.description,onChange:me=>p({...u,description:me}),placeholder:"Brief description of the video",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Video Type"}),e.jsxs(sr,{value:u.video_type,onValueChange:me=>{p({...u,video_type:me,video_url:""}),se(null)},disabled:de,children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:NRt.map(me=>e.jsx(At,{value:me.value,children:me.label},me.value))})]})]}),u.video_type==="bunny_stream"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs(ve,{children:["Upload Video File ",!i&&"*"]}),i&&u.video_url&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Current video: ",e.jsx("a",{href:u.video_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"View"})]}),!i&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{type:"file",accept:"video/*",onChange:me=>{var ot;const Xe=(ot=me.target.files)==null?void 0:ot[0];Xe&&se(Xe)},disabled:de}),Y&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Nn,{className:"h-4 w-4"}),Y.name," (",(Y.size/(1024*1024)).toFixed(1)," MB)"]}),de&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ms,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Uploading to Bunny.net..."})]}),e.jsx(Ti,{value:te,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[te,"%"]})]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"video_url",children:"Video URL *"}),e.jsx(Re,{id:"video_url",value:u.video_url,onChange:me=>p({...u,video_url:me.target.value}),placeholder:"https://...",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"duration",children:"Duration"}),e.jsx(Re,{id:"duration",value:u.duration,onChange:me=>p({...u,duration:me.target.value}),placeholder:"e.g., 45:30"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Re,{id:"publish_date",type:"date",value:u.publish_date,onChange:me=>p({...u,publish_date:me.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Category"}),U?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:$,onChange:me=>q(me.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>$.trim()&&je.mutate($.trim()),disabled:je.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{H(!1),q("")},children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(sr,{value:u.category_id,onValueChange:me=>p({...u,category_id:me}),children:[e.jsx(er,{className:"flex-1",children:e.jsx(rr,{placeholder:"Select category"})}),e.jsx(tr,{children:he.map(me=>e.jsx(At,{value:me.id,children:me.name},me.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>H(!0),children:e.jsx(Zs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Thumbnail Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[_&&e.jsx("img",{src:_,alt:"Thumbnail preview",className:"w-32 h-20 object-cover rounded-md border"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(Re,{type:"file",accept:"image/*",onChange:Fe,className:"cursor-pointer"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Recommended: 16:9 aspect ratio"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Resource Files"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{className:"cursor-pointer gap-1",children:[e.jsx(Za,{className:"h-3 w-3"}),"Add Files",e.jsx("input",{type:"file",multiple:!0,accept:".pdf,.pptx,.ppt,.xlsx,.xls,.docx,.doc,.zip",onChange:Ae,className:"hidden"})]})})]}),(k.length>0||w.length>0)&&e.jsxs("div",{className:"space-y-2 mt-2",children:[k.map(me=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm truncate",children:me.title}),e.jsx(rt,{variant:"outline",className:"text-xs",children:me.file_type}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>ut(me.id),className:"text-destructive hover:text-destructive",children:e.jsx(Ur,{className:"h-4 w-4"})})]},me.id)),w.map((me,Xe)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Re,{value:me.title,onChange:ot=>{const nt=[...w];nt[Xe].title=ot.target.value,j(nt)},className:"flex-1 h-8",placeholder:"Resource title"}),e.jsx(rt,{variant:"secondary",className:"text-xs",children:"New"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>Ue(Xe),className:"text-destructive hover:text-destructive",children:e.jsx(Ur,{className:"h-4 w-4"})})]},Xe))]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Supported: PDF, PowerPoint, Excel, Word, ZIP"})]}),e.jsx(BKe,{selectedTemplateIds:L,onChange:R}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"is_published",checked:u.is_published,onCheckedChange:me=>p({...u,is_published:me})}),e.jsx(ve,{htmlFor:"is_published",children:"Published"})]}),e.jsxs(Un,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),disabled:de,children:"Cancel"}),e.jsx(K,{type:"submit",disabled:Ne.isPending||de,children:de?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):Ne.isPending?"Saving...":i?"Update Video":"Add Video"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:_e?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):be.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Nn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No videos yet"}),e.jsx("p",{className:"text-sm",children:"Add your first academy video"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Category"}),e.jsx(bt,{children:"Duration"}),e.jsx(bt,{children:"Resources"}),e.jsx(bt,{children:"Publish Date"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"w-[120px]",children:"Actions"})]})}),e.jsx(Pn,{children:be.map(me=>e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[me.thumbnail_url?e.jsx("img",{src:me.thumbnail_url,alt:"",className:"w-16 h-10 object-cover rounded"}):e.jsx("div",{className:"w-16 h-10 bg-muted rounded flex items-center justify-center",children:e.jsx(Nn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:me.title}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:me.video_type.replace("_"," ")})]})]})}),e.jsx(lt,{children:me.category?e.jsx(rt,{variant:"outline",children:me.category.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(lt,{children:me.duration||"-"}),e.jsx(lt,{children:me.resources&&me.resources.length>0?e.jsxs(rt,{variant:"secondary",children:[me.resources.length," file(s)"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(lt,{children:new Date(me.publish_date).toLocaleDateString()}),e.jsx(lt,{children:e.jsx(Br,{checked:me.is_published,onCheckedChange:Xe=>we.mutate({id:me.id,is_published:Xe})})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Te(me),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Ge.mutate(me.id),className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},me.id))})]})})})]})})};function SRt(){var Ne,Ge,we;const t=rs(),[s,r]=Pc(),[n,a]=C.useState(!1),[o,l]=C.useState(null),[i,d]=C.useState({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=C.useState(null),[f,y]=C.useState(""),[_,b]=C.useState([]),[w,j]=C.useState([]),[k,S]=C.useState([]),[T,I]=C.useState(null),{data:L,isLoading:R}=wt({queryKey:["resource-kits"],queryFn:async()=>{const{data:Me,error:Te}=await G.from("resource_kits").select("*").order("publish_date",{ascending:!1});if(Te)throw Te;return Me}}),{data:$}=wt({queryKey:["resource-kit-files"],queryFn:async()=>{const{data:Me,error:Te}=await G.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(Te)throw Te;return Me}}),{data:q}=wt({queryKey:["resource-kit-links"],queryFn:async()=>{const{data:Me,error:Te}=await G.from("resource_kit_links").select("*").order("sort_order",{ascending:!0});if(Te)throw Te;return Me}});C.useEffect(()=>{const Me=s.get("edit");if(Me&&L&&L.length>0&&$&&q){const Te=L.find(Fe=>Fe.id===Me);Te&&(H(Te),r({},{replace:!0}))}},[L,$,q,s]);const U=()=>{d({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),y(""),b([]),j([]),S([]),l(null)},H=async Me=>{l(Me),d({name:Me.name,description:Me.description||"",publish_date:Me.publish_date.split("T")[0],is_published:Me.is_published}),y(Me.featured_image_url||"");const Te=($==null?void 0:$.filter(Ue=>Ue.kit_id===Me.id))||[];b(Te.map(Ue=>({id:Ue.id,name:Ue.name,file_url:Ue.file_url,file_type:Ue.file_type,file_size:Ue.file_size,sort_order:Ue.sort_order})));const Fe=(q==null?void 0:q.filter(Ue=>Ue.kit_id===Me.id))||[];j(Fe.map(Ue=>({id:Ue.id,title:Ue.title,canva_share_link:Ue.canva_share_link,sort_order:Ue.sort_order})));const{data:Ae}=await G.from("resource_kit_templates").select("template_id").eq("kit_id",Me.id);S((Ae||[]).map(Ue=>Ue.template_id)),a(!0)},Y=Me=>{var Fe;const Te=(Fe=Me.target.files)==null?void 0:Fe[0];Te&&(p(Te),y(URL.createObjectURL(Te)))},se=()=>{b([..._,{name:"",file_url:"",sort_order:_.length}])},te=Me=>{b(_.filter((Te,Fe)=>Fe!==Me))},Q=(Me,Te,Fe)=>{const Ae=[..._];Ae[Me]={...Ae[Me],[Te]:Fe},b(Ae)},de=()=>{j([...w,{title:"",canva_share_link:"",sort_order:w.length}])},re=Me=>{j(w.filter((Te,Fe)=>Fe!==Me))},ae=(Me,Te,Fe)=>{const Ae=[...w];Ae[Me]={...Ae[Me],[Te]:Fe},j(Ae)},le=(Me,Te)=>{var Ae;const Fe=(Ae=Te.target.files)==null?void 0:Ae[0];if(Fe){const Ue=[..._],ut=Fe.name.replace(/\.[^/.]+$/,"");Ue[Me]={...Ue[Me],file:Fe,file_type:Fe.type,file_size:Fe.size,name:Ue[Me].name||ut},b(Ue)}},he=Dt({mutationFn:async()=>{let Me=(o==null?void 0:o.featured_image_url)||null;if(u){const ut=u.name.split(".").pop(),De=`${Date.now()}.${ut}`,{error:Rt}=await G.storage.from("resource-kits").upload(`featured/${De}`,u);if(Rt)throw Rt;const{data:me}=G.storage.from("resource-kits").getPublicUrl(`featured/${De}`);Me=me.publicUrl}const Te={name:i.name,description:i.description||null,featured_image_url:Me,publish_date:i.publish_date,is_published:i.is_published};let Fe;const Ae=!o,Ue=(o==null?void 0:o.is_published)||!1;if(o){const{error:ut}=await G.from("resource_kits").update(Te).eq("id",o.id);if(ut)throw ut;Fe=o.id;const De=($==null?void 0:$.filter(Se=>Se.kit_id===o.id).map(Se=>Se.id))||[],Rt=_.filter(Se=>Se.id).map(Se=>Se.id),me=De.filter(Se=>!Rt.includes(Se));me.length>0&&await G.from("resource_kit_files").delete().in("id",me);const Xe=(q==null?void 0:q.filter(Se=>Se.kit_id===o.id).map(Se=>Se.id))||[],ot=w.filter(Se=>Se.id).map(Se=>Se.id),nt=Xe.filter(Se=>!ot.includes(Se));nt.length>0&&await G.from("resource_kit_links").delete().in("id",nt)}else{const{data:ut,error:De}=await G.from("resource_kits").insert(Te).select().single();if(De)throw De;Fe=ut.id}for(let ut=0;ut<_.length;ut++){const De=_[ut];let Rt=De.file_url;if(De.file){const me=De.file.name.split(".").pop(),Xe=`${Date.now()}-${ut}.${me}`,{error:ot}=await G.storage.from("resource-kits").upload(`files/${Xe}`,De.file);if(ot)throw ot;const{data:nt}=G.storage.from("resource-kits").getPublicUrl(`files/${Xe}`);Rt=nt.publicUrl}De.id?await G.from("resource_kit_files").update({name:De.name,file_url:Rt,file_type:De.file_type,file_size:De.file_size,sort_order:ut}).eq("id",De.id):Rt&&De.name&&await G.from("resource_kit_files").insert({kit_id:Fe,name:De.name,file_url:Rt,file_type:De.file_type,file_size:De.file_size,sort_order:ut})}for(let ut=0;ut0){const{error:ut}=await G.from("resource_kit_templates").insert(k.map(De=>({kit_id:Fe,template_id:De})));if(ut)throw ut}return{kitId:Fe,kitName:i.name,isNewKit:Ae,wasPublished:Ue,isPublished:i.is_published}},onSuccess:Me=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),t.invalidateQueries({queryKey:["resource-kit-links"]}),fe.success(o?"Resource kit updated":"Resource kit created"),Me.isPublished&&(Me.isNewKit||!Me.wasPublished)&&vRt(Me.kitName,Me.kitId),a(!1),U()},onError:Me=>{fe.error("Failed to save resource kit: "+Me.message)}}),be=Dt({mutationFn:async Me=>{const{error:Te}=await G.from("resource_kits").delete().eq("id",Me);if(Te)throw Te},onSuccess:()=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),fe.success("Resource kit deleted")},onError:Me=>{fe.error("Failed to delete: "+Me.message)}}),_e=Me=>{if(Me.preventDefault(),!i.name){fe.error("Please enter a name");return}he.mutate()},je=Me=>($==null?void 0:$.filter(Te=>Te.kit_id===Me).length)||0;return e.jsx(Ts,{title:"Toolbox Management",description:"Create and manage resource kits for agents",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Kits"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(L==null?void 0:L.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(L==null?void 0:L.filter(Me=>Me.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{U(),a(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Resource Kit"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Files"}),e.jsx(bt,{children:"Publish Date"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:R?e.jsx(Ns,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):(L==null?void 0:L.length)===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No resource kits yet. Create your first one!"})}):L==null?void 0:L.map(Me=>e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Me.featured_image_url?e.jsx("img",{src:Me.featured_image_url,alt:Me.name,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(dl,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Me.name}),Me.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Me.description})]})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),je(Me.id)]})}),e.jsx(lt,{children:ys(new Date(Me.publish_date),"MMM d, yyyy")}),e.jsx(lt,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Me.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Me.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{const Te=($==null?void 0:$.filter(Ae=>Ae.kit_id===Me.id))||[],Fe=(q==null?void 0:q.filter(Ae=>Ae.kit_id===Me.id))||[];I({...Me,files:Te,links:Fe})},children:e.jsx(xa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>H(Me),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource kit?")&&be.mutate(Me.id)},children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},Me.id))})]})})}),e.jsx(_s,{open:n,onOpenChange:a,children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:o?"Edit Resource Kit":"Add Resource Kit"})}),e.jsxs("form",{onSubmit:_e,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Featured Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[f?e.jsx("img",{src:f,alt:"Preview",className:"w-24 h-24 rounded object-cover"}):e.jsx("div",{className:"w-24 h-24 rounded bg-muted flex items-center justify-center",children:e.jsx(dl,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(Re,{type:"file",accept:"image/*",onChange:Y})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Name *"}),e.jsx(Re,{id:"name",value:i.name,onChange:Me=>d({...i,name:Me.target.value}),placeholder:"Resource Kit Name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(rx,{content:i.description,onChange:Me=>d({...i,description:Me}),placeholder:"Brief description of this resource kit",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Re,{id:"publish_date",type:"date",value:i.publish_date,onChange:Me=>d({...i,publish_date:Me.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(Br,{checked:i.is_published,onCheckedChange:Me=>d({...i,is_published:Me})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:i.is_published?"Visible to agents":"Hidden from agents"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ve,{children:"Resource Files"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:se,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add File"]})]}),_.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center border rounded-md border-dashed",children:'No files added yet. Click "Add File" to include resources.'}):e.jsx("div",{className:"space-y-3",children:_.map((Me,Te)=>e.jsxs("div",{className:"border rounded-md p-3 space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("span",{className:"text-sm font-medium",children:["File ",Te+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>te(Te),children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsx(Re,{placeholder:"File name (e.g., Getting Started Guide)",value:Me.name,onChange:Fe=>Q(Te,"name",Fe.target.value)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{type:"file",onChange:Fe=>le(Te,Fe),className:"flex-1"}),Me.file_url&&!Me.file&&e.jsx("a",{href:Me.file_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline whitespace-nowrap",children:"Current file"}),Me.file&&e.jsx("span",{className:"text-sm text-green-600 whitespace-nowrap",children:"New file selected"})]})]},Te))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ve,{children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:de,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Canva Link"]})]}),w.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center border rounded-md border-dashed",children:'No Canva links added yet. Click "Add Canva Link" to include templates.'}):e.jsx("div",{className:"space-y-3",children:w.map((Me,Te)=>e.jsxs("div",{className:"border rounded-md p-3 space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("span",{className:"text-sm font-medium",children:["Canva Link ",Te+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>re(Te),children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsx(Re,{placeholder:"Link title (e.g., Social Media Post Template)",value:Me.title,onChange:Fe=>ae(Te,"title",Fe.target.value)}),e.jsx(Re,{placeholder:"Canva share link (e.g., https://www.canva.com/design/...)",value:Me.canva_share_link,onChange:Fe=>ae(Te,"canva_share_link",Fe.target.value)})]},Te))})]}),e.jsx(BKe,{selectedTemplateIds:k,onChange:S}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:he.isPending,children:he.isPending?"Saving...":o?"Update":"Create"})]})]})]})}),e.jsx(_s,{open:!!T,onOpenChange:()=>I(null),children:e.jsxs(vs,{className:"max-w-lg",children:[e.jsx(Ss,{children:e.jsx(ks,{children:T==null?void 0:T.name})}),e.jsxs("div",{className:"space-y-4",children:[(T==null?void 0:T.featured_image_url)&&e.jsx("img",{src:T.featured_image_url,alt:T.name,className:"w-full h-48 object-cover rounded-lg"}),(T==null?void 0:T.description)&&e.jsx("p",{className:"text-muted-foreground",children:T.description}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Resource Files (",((Ne=T==null?void 0:T.files)==null?void 0:Ne.length)||0,")"]}),((Ge=T==null?void 0:T.files)==null?void 0:Ge.length)===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No files in this kit"}):e.jsx("div",{className:"space-y-2",children:(we=T==null?void 0:T.files)==null?void 0:we.map(Me=>e.jsxs("a",{href:Me.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[e.jsx(In,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Me.name})]},Me.id))})]}),(T==null?void 0:T.links)&&T.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Canva Links (",T.links.length,")"]}),e.jsx("div",{className:"space-y-2",children:T.links.map(Me=>e.jsxs("a",{href:Me.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[e.jsx(Do,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Me.title})]},Me.id))})]})]})]})})]})})}const CRt=()=>{const{user:t}=Hs(),{toast:s}=Pa(),r=rs(),[n,a]=C.useState(!1),[o,l]=C.useState(null),[i,d]=C.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),[u,p]=C.useState(null),[f,y]=C.useState(""),{data:_=[],isLoading:b}=wt({queryKey:["social-swag-admin"],queryFn:async()=>{const{data:q,error:U}=await G.from("social_swag").select("*").order("publish_date",{ascending:!1});if(U)throw U;const{data:H,error:Y}=await G.from("social_swag_links").select("*").order("sort_order");if(Y)throw Y;return q.map(te=>({...te,links:(H==null?void 0:H.filter(Q=>Q.swag_id===te.id))||[]}))}}),w=Dt({mutationFn:async q=>{let U=q.existingImageUrl;if(q.image){const de=q.image.name.split(".").pop(),re=`${Date.now()}-${Math.random().toString(36).substring(7)}.${de}`,{error:ae}=await G.storage.from("template-previews").upload(re,q.image);if(ae)throw ae;const{data:le}=G.storage.from("template-previews").getPublicUrl(re);U=le.publicUrl}const H={title:q.item.title,description:q.item.description||null,preview_image_url:U,publish_date:q.item.publish_date?new Date(q.item.publish_date).toISOString():new Date().toISOString(),is_published:q.item.is_published,created_by:t==null?void 0:t.id};let Y=q.itemId;const se=!Y,te=(o==null?void 0:o.is_published)||!1;if(Y){const{error:de}=await G.from("social_swag").update(H).eq("id",Y);if(de)throw de;await G.from("social_swag_links").delete().eq("swag_id",Y)}else{const{data:de,error:re}=await G.from("social_swag").insert(H).select().single();if(re)throw re;Y=de.id}const Q=q.item.links.filter(de=>de.title.trim()&&de.canva_share_link.trim());if(Q.length>0){const de=Q.map((ae,le)=>({swag_id:Y,title:ae.title.trim(),canva_share_link:ae.canva_share_link.trim(),sort_order:le})),{error:re}=await G.from("social_swag_links").insert(de);if(re)throw re}return{itemId:Y,itemTitle:q.item.title,isNewItem:se,wasPublished:te,isPublished:q.item.is_published}},onSuccess:q=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:o?"Item updated":"Item created"}),q.isPublished&&(q.isNewItem||!q.wasPublished)&&fye(q.itemTitle,q.itemId),a(!1),k()},onError:q=>{s({title:"Error saving item",description:q.message,variant:"destructive"})}}),j=Dt({mutationFn:async q=>{const{error:U}=await G.from("social_swag").delete().eq("id",q);if(U)throw U},onSuccess:()=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:"Item deleted"})},onError:q=>{s({title:"Error deleting item",description:q.message,variant:"destructive"})}}),k=()=>{d({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),p(null),y(""),l(null)},S=q=>{l(q),d({title:q.title,description:q.description||"",publish_date:q.publish_date?new Date(q.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:q.is_published,links:q.links&&q.links.length>0?q.links.map(U=>({id:U.id,title:U.title,canva_share_link:U.canva_share_link,sort_order:U.sort_order})):[{title:"",canva_share_link:"",sort_order:0}]}),y(q.preview_image_url||""),a(!0)},T=q=>{var H;const U=(H=q.target.files)==null?void 0:H[0];U&&(p(U),y(URL.createObjectURL(U)))},I=()=>{d({...i,links:[...i.links,{title:"",canva_share_link:"",sort_order:i.links.length}]})},L=q=>{if(i.links.length<=1)return;const U=i.links.filter((H,Y)=>Y!==q);d({...i,links:U})},R=(q,U,H)=>{const Y=[...i.links];Y[q]={...Y[q],[U]:H},d({...i,links:Y})},$=q=>{if(q.preventDefault(),!i.title.trim()){s({title:"Title is required",variant:"destructive"});return}w.mutate({item:i,image:u,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(Ts,{title:"Manage Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(wu,{title:"Manage Social Swag",description:"Create and manage social media content"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Items"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.filter(q=>q.is_published).length})})]})]}),e.jsxs(_s,{open:n,onOpenChange:q=>{a(q),q||k()},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Item"]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:o?"Edit Item":"Add New Item"})}),e.jsxs("form",{onSubmit:$,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",value:i.title,onChange:q=>d({...i,title:q.target.value}),placeholder:"Enter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(rx,{content:i.description,onChange:q=>d({...i,description:q}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Re,{id:"publish_date",type:"date",value:i.publish_date,onChange:q=>d({...i,publish_date:q.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Br,{id:"is_published",checked:i.is_published,onCheckedChange:q=>d({...i,is_published:q})}),e.jsx(ve,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Preview Image"}),f?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:f,alt:"Preview",className:"w-full max-h-48 object-contain rounded-lg border"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{p(null),y("")},children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(Jo,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(Re,{type:"file",accept:"image/*",onChange:T,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:I,children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"}),"Add Link"]})]}),i.links.map((q,U)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["Link ",U+1]}),i.links.length>1&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>L(U),children:e.jsx(Ur,{className:"h-3 w-3"})})]}),e.jsx(Re,{placeholder:"Link title (e.g., Instagram Post)",value:q.title,onChange:H=>R(U,"title",H.target.value)}),e.jsx(Re,{placeholder:"Canva share link",value:q.canva_share_link,onChange:H=>R(U,"canva_share_link",H.target.value)})]})},U))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:w.isPending,children:w.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:b?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):_.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'No items yet. Click "Add Item" to create your first one.'}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{className:"w-16",children:"Preview"}),e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Links"}),e.jsx(bt,{children:"Publish Date"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:_.map(q=>{var U;return e.jsxs(Ns,{children:[e.jsx(lt,{children:q.preview_image_url?e.jsx("img",{src:q.preview_image_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(Jo,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(lt,{className:"font-medium",children:q.title}),e.jsxs(lt,{children:[((U=q.links)==null?void 0:U.length)||0," links"]}),e.jsx(lt,{children:new Date(q.publish_date).toLocaleDateString()}),e.jsx(lt,{children:e.jsx(rt,{variant:q.is_published?"default":"secondary",children:q.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(`/social-swag/${q.id}`,"_blank"),children:e.jsx(xa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>S(q),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this item?")&&j.mutate(q.id)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},q.id)})})]})})})]})})};function MRt(){for(var t=arguments.length,s=new Array(t),r=0;rn=>{s.forEach(a=>a(n))},s)}const Rle=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function RM(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function jwe(t){return"nodeType"in t}function qm(t){var s,r;return t?RM(t)?t:jwe(t)&&(s=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Nwe(t){const{Document:s}=qm(t);return t instanceof s}function tD(t){return RM(t)?!1:t instanceof qm(t).HTMLElement}function $Ke(t){return t instanceof qm(t).SVGElement}function FM(t){return t?RM(t)?t.document:jwe(t)?Nwe(t)?t:tD(t)||$Ke(t)?t.ownerDocument:document:document:document}const my=Rle?C.useLayoutEffect:C.useEffect;function kwe(t){const s=C.useRef(t);return my(()=>{s.current=t}),C.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a{t.current=setInterval(n,a)},[]),r=C.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,r]}function S6(t,s){s===void 0&&(s=[t]);const r=C.useRef(t);return my(()=>{r.current!==t&&(r.current=t)},s),r}function sD(t,s){const r=C.useRef();return C.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...s])}function $ae(t){const s=kwe(t),r=C.useRef(null),n=C.useCallback(a=>{a!==r.current&&(s==null||s(a,r.current)),r.current=a},[]);return[r,n]}function gye(t){const s=C.useRef();return C.useEffect(()=>{s.current=t},[t]),s.current}let tpe={};function rD(t,s){return C.useMemo(()=>{if(s)return s;const r=tpe[t]==null?0:tpe[t]+1;return tpe[t]=r,t+"-"+r},[t,s])}function qKe(t){return function(s){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a{const i=Object.entries(l);for(const[d,u]of i){const p=o[d];p!=null&&(o[d]=p+t*u)}return o},{...s})}}const U5=qKe(1),C6=qKe(-1);function ARt(t){return"clientX"in t&&"clientY"in t}function Swe(t){if(!t)return!1;const{KeyboardEvent:s}=qm(t.target);return s&&t instanceof s}function ERt(t){if(!t)return!1;const{TouchEvent:s}=qm(t.target);return s&&t instanceof s}function xye(t){if(ERt(t)){if(t.touches&&t.touches.length){const{clientX:s,clientY:r}=t.touches[0];return{x:s,y:r}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:s,clientY:r}=t.changedTouches[0];return{x:s,y:r}}}return ARt(t)?{x:t.clientX,y:t.clientY}:null}const D3=Object.freeze({Translate:{toString(t){if(!t)return;const{x:s,y:r}=t;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:s,scaleY:r}=t;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(t){if(t)return[D3.Translate.toString(t),D3.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:r,easing:n}=t;return s+" "+r+"ms "+n}}}),QAe="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function PRt(t){return t.matches(QAe)?t:t.querySelector(QAe)}const IRt={display:"none"};function LRt(t){let{id:s,value:r}=t;return ht.createElement("div",{id:s,style:IRt},r)}function DRt(t){let{id:s,announcement:r,ariaLiveType:n="assertive"}=t;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ht.createElement("div",{id:s,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function ORt(){const[t,s]=C.useState("");return{announce:C.useCallback(n=>{n!=null&&s(n)},[]),announcement:t}}const UKe=C.createContext(null);function RRt(t){const s=C.useContext(UKe);C.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of ");return s(t)},[t,s])}function FRt(){const[t]=C.useState(()=>new Set),s=C.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[C.useCallback(n=>{let{type:a,event:o}=n;t.forEach(l=>{var i;return(i=l[a])==null?void 0:i.call(l,o)})},[t]),s]}const zRt={draggable:` To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel. `},BRt={onDragStart(t){let{active:s}=t;return"Picked up draggable item "+s.id+"."},onDragOver(t){let{active:s,over:r}=t;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(t){let{active:s,over:r}=t;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(t){let{active:s}=t;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function $Rt(t){let{announcements:s=BRt,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=zRt}=t;const{announce:o,announcement:l}=ORt(),i=rD("DndLiveRegion"),[d,u]=C.useState(!1);if(C.useEffect(()=>{u(!0)},[]),RRt(C.useMemo(()=>({onDragStart(f){let{active:y}=f;o(s.onDragStart({active:y}))},onDragMove(f){let{active:y,over:_}=f;s.onDragMove&&o(s.onDragMove({active:y,over:_}))},onDragOver(f){let{active:y,over:_}=f;o(s.onDragOver({active:y,over:_}))},onDragEnd(f){let{active:y,over:_}=f;o(s.onDragEnd({active:y,over:_}))},onDragCancel(f){let{active:y,over:_}=f;o(s.onDragCancel({active:y,over:_}))}}),[o,s])),!d)return null;const p=ht.createElement(ht.Fragment,null,ht.createElement(LRt,{id:n,value:a.draggable}),ht.createElement(DRt,{id:i,announcement:l}));return r?km.createPortal(p,r):p}var Fd;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Fd||(Fd={}));function qae(){}function yye(t,s){return C.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function VKe(){for(var t=arguments.length,s=new Array(t),r=0;r[...s].filter(n=>n!=null),[...s])}const ex=Object.freeze({x:0,y:0});function HKe(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function WKe(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return r-n}function qRt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return n-r}function JAe(t){let{left:s,top:r,height:n,width:a}=t;return[{x:s,y:r},{x:s+a,y:r},{x:s,y:r+n},{x:s+a,y:r+n}]}function GKe(t,s){if(!t||t.length===0)return null;const[r]=t;return r[s]}function eEe(t,s,r){return s===void 0&&(s=t.left),r===void 0&&(r=t.top),{x:s+t.width*.5,y:r+t.height*.5}}const KKe=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=eEe(s,s.left,s.top),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const u=HKe(eEe(d),a);o.push({id:i,data:{droppableContainer:l,value:u}})}}return o.sort(WKe)},URt=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=JAe(s),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const u=JAe(d),p=a.reduce((y,_,b)=>y+HKe(u[b],_),0),f=Number((p/4).toFixed(4));o.push({id:i,data:{droppableContainer:l,value:f}})}}return o.sort(WKe)};function VRt(t,s){const r=Math.max(s.top,t.top),n=Math.max(s.left,t.left),a=Math.min(s.left+s.width,t.left+t.width),o=Math.min(s.top+s.height,t.top+t.height),l=a-n,i=o-r;if(n{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=[];for(const o of n){const{id:l}=o,i=r.get(l);if(i){const d=VRt(i,s);d>0&&a.push({id:l,data:{droppableContainer:o,value:d}})}}return a.sort(qRt)};function WRt(t,s,r){return{...t,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function ZKe(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:ex}function GRt(t){return function(r){for(var n=arguments.length,a=new Array(n>1?n-1:0),o=1;o({...l,top:l.top+t*i.y,bottom:l.bottom+t*i.y,left:l.left+t*i.x,right:l.right+t*i.x}),{...r})}}const KRt=GRt(1);function ZRt(t){if(t.startsWith("matrix3d(")){const s=t.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(t.startsWith("matrix(")){const s=t.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function YRt(t,s,r){const n=ZRt(s);if(!n)return t;const{scaleX:a,scaleY:o,x:l,y:i}=n,d=t.left-l-(1-a)*parseFloat(r),u=t.top-i-(1-o)*parseFloat(r.slice(r.indexOf(" ")+1)),p=a?t.width/a:t.width,f=o?t.height/o:t.height;return{width:p,height:f,top:u,right:d+p,bottom:u+f,left:d}}const XRt={ignoreTransform:!1};function zM(t,s){s===void 0&&(s=XRt);let r=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:p}=qm(t).getComputedStyle(t);u&&(r=YRt(r,u,p))}const{top:n,left:a,width:o,height:l,bottom:i,right:d}=r;return{top:n,left:a,width:o,height:l,bottom:i,right:d}}function tEe(t){return zM(t,{ignoreTransform:!0})}function QRt(t){const s=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function JRt(t,s){return s===void 0&&(s=qm(t).getComputedStyle(t)),s.position==="fixed"}function eFt(t,s){s===void 0&&(s=qm(t).getComputedStyle(t));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const o=s[a];return typeof o=="string"?r.test(o):!1})}function Fle(t,s){const r=[];function n(a){if(s!=null&&r.length>=s||!a)return r;if(Nwe(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!tD(a)||$Ke(a)||r.includes(a))return r;const o=qm(t).getComputedStyle(a);return a!==t&&eFt(a,o)&&r.push(a),JRt(a,o)?r:n(a.parentNode)}return t?n(t):r}function YKe(t){const[s]=Fle(t,1);return s??null}function spe(t){return!Rle||!t?null:RM(t)?t:jwe(t)?Nwe(t)||t===FM(t).scrollingElement?window:tD(t)?t:null:null}function XKe(t){return RM(t)?t.scrollX:t.scrollLeft}function QKe(t){return RM(t)?t.scrollY:t.scrollTop}function vye(t){return{x:XKe(t),y:QKe(t)}}var cu;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(cu||(cu={}));function JKe(t){return!Rle||!t?!1:t===document.scrollingElement}function eZe(t){const s={x:0,y:0},r=JKe(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},n={x:t.scrollWidth-r.width,y:t.scrollHeight-r.height},a=t.scrollTop<=s.y,o=t.scrollLeft<=s.x,l=t.scrollTop>=n.y,i=t.scrollLeft>=n.x;return{isTop:a,isLeft:o,isBottom:l,isRight:i,maxScroll:n,minScroll:s}}const tFt={x:.2,y:.2};function sFt(t,s,r,n,a){let{top:o,left:l,right:i,bottom:d}=r;n===void 0&&(n=10),a===void 0&&(a=tFt);const{isTop:u,isBottom:p,isLeft:f,isRight:y}=eZe(t),_={x:0,y:0},b={x:0,y:0},w={height:s.height*a.y,width:s.width*a.x};return!u&&o<=s.top+w.height?(_.y=cu.Backward,b.y=n*Math.abs((s.top+w.height-o)/w.height)):!p&&d>=s.bottom-w.height&&(_.y=cu.Forward,b.y=n*Math.abs((s.bottom-w.height-d)/w.height)),!y&&i>=s.right-w.width?(_.x=cu.Forward,b.x=n*Math.abs((s.right-w.width-i)/w.width)):!f&&l<=s.left+w.width&&(_.x=cu.Backward,b.x=n*Math.abs((s.left+w.width-l)/w.width)),{direction:_,speed:b}}function rFt(t){if(t===document.scrollingElement){const{innerWidth:o,innerHeight:l}=window;return{top:0,left:0,right:o,bottom:l,width:o,height:l}}const{top:s,left:r,right:n,bottom:a}=t.getBoundingClientRect();return{top:s,left:r,right:n,bottom:a,width:t.clientWidth,height:t.clientHeight}}function tZe(t){return t.reduce((s,r)=>U5(s,vye(r)),ex)}function nFt(t){return t.reduce((s,r)=>s+XKe(r),0)}function aFt(t){return t.reduce((s,r)=>s+QKe(r),0)}function iFt(t,s){if(s===void 0&&(s=zM),!t)return;const{top:r,left:n,bottom:a,right:o}=s(t);YKe(t)&&(a<=0||o<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const oFt=[["x",["left","right"],nFt],["y",["top","bottom"],aFt]];class Cwe{constructor(s,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=Fle(r),a=tZe(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,l,i]of oFt)for(const d of l)Object.defineProperty(this,d,{get:()=>{const u=i(n),p=a[o]-u;return this.rect[d]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class vI{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=s}add(s,r,n){var a;(a=this.target)==null||a.addEventListener(s,r,n),this.listeners.push([s,r,n])}}function lFt(t){const{EventTarget:s}=qm(t);return t instanceof s?t:FM(t)}function rpe(t,s){const r=Math.abs(t.x),n=Math.abs(t.y);return typeof s=="number"?Math.sqrt(r**2+n**2)>s:"x"in s&&"y"in s?r>s.x&&n>s.y:"x"in s?r>s.x:"y"in s?n>s.y:!1}var sf;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(sf||(sf={}));function sEe(t){t.preventDefault()}function cFt(t){t.stopPropagation()}var yo;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(yo||(yo={}));const sZe={start:[yo.Space,yo.Enter],cancel:[yo.Esc],end:[yo.Space,yo.Enter,yo.Tab]},dFt=(t,s)=>{let{currentCoordinates:r}=s;switch(t.code){case yo.Right:return{...r,x:r.x+25};case yo.Left:return{...r,x:r.x-25};case yo.Down:return{...r,y:r.y+25};case yo.Up:return{...r,y:r.y-25}}};class Mwe{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new vI(FM(r)),this.windowListeners=new vI(qm(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(sf.Resize,this.handleCancel),this.windowListeners.add(sf.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(sf.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&iFt(n),r(ex)}handleKeyDown(s){if(Swe(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:o=sZe,coordinateGetter:l=dFt,scrollBehavior:i="smooth"}=a,{code:d}=s;if(o.end.includes(d)){this.handleEnd(s);return}if(o.cancel.includes(d)){this.handleCancel(s);return}const{collisionRect:u}=n.current,p=u?{x:u.left,y:u.top}:ex;this.referenceCoordinates||(this.referenceCoordinates=p);const f=l(s,{active:r,context:n.current,currentCoordinates:p});if(f){const y=C6(f,p),_={x:0,y:0},{scrollableAncestors:b}=n.current;for(const w of b){const j=s.code,{isTop:k,isRight:S,isLeft:T,isBottom:I,maxScroll:L,minScroll:R}=eZe(w),$=rFt(w),q={x:Math.min(j===yo.Right?$.right-$.width/2:$.right,Math.max(j===yo.Right?$.left:$.left+$.width/2,f.x)),y:Math.min(j===yo.Down?$.bottom-$.height/2:$.bottom,Math.max(j===yo.Down?$.top:$.top+$.height/2,f.y))},U=j===yo.Right&&!S||j===yo.Left&&!T,H=j===yo.Down&&!I||j===yo.Up&&!k;if(U&&q.x!==f.x){const Y=w.scrollLeft+y.x,se=j===yo.Right&&Y<=L.x||j===yo.Left&&Y>=R.x;if(se&&!y.y){w.scrollTo({left:Y,behavior:i});return}se?_.x=w.scrollLeft-Y:_.x=j===yo.Right?w.scrollLeft-L.x:w.scrollLeft-R.x,_.x&&w.scrollBy({left:-_.x,behavior:i});break}else if(H&&q.y!==f.y){const Y=w.scrollTop+y.y,se=j===yo.Down&&Y<=L.y||j===yo.Up&&Y>=R.y;if(se&&!y.x){w.scrollTo({top:Y,behavior:i});return}se?_.y=w.scrollTop-Y:_.y=j===yo.Down?w.scrollTop-L.y:w.scrollTop-R.y,_.y&&w.scrollBy({top:-_.y,behavior:i});break}}this.handleMove(s,U5(C6(f,this.referenceCoordinates),_))}}}handleMove(s,r){const{onMove:n}=this.props;s.preventDefault(),n(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Mwe.activators=[{eventName:"onKeyDown",handler:(t,s,r)=>{let{keyboardCodes:n=sZe,onActivation:a}=s,{active:o}=r;const{code:l}=t.nativeEvent;if(n.start.includes(l)){const i=o.activatorNode.current;return i&&t.target!==i?!1:(t.preventDefault(),a==null||a({event:t.nativeEvent}),!0)}return!1}}];function rEe(t){return!!(t&&"distance"in t)}function nEe(t){return!!(t&&"delay"in t)}class Twe{constructor(s,r,n){var a;n===void 0&&(n=lFt(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=r;const{event:o}=s,{target:l}=o;this.props=s,this.events=r,this.document=FM(l),this.documentListeners=new vI(this.document),this.listeners=new vI(n),this.windowListeners=new vI(qm(l)),this.initialCoordinates=(a=xye(o))!=null?a:ex,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(sf.Resize,this.handleCancel),this.windowListeners.add(sf.DragStart,sEe),this.windowListeners.add(sf.VisibilityChange,this.handleCancel),this.windowListeners.add(sf.ContextMenu,sEe),this.documentListeners.add(sf.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(nEe(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(rEe(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,r){const{active:n,onPending:a}=this.props;a(n,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(sf.Click,cFt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(sf.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:n,initialCoordinates:a,props:o}=this,{onMove:l,options:{activationConstraint:i}}=o;if(!a)return;const d=(r=xye(s))!=null?r:ex,u=C6(a,d);if(!n&&i){if(rEe(i)){if(i.tolerance!=null&&rpe(u,i.tolerance))return this.handleCancel();if(rpe(u,i.distance))return this.handleStart()}if(nEe(i)&&rpe(u,i.tolerance))return this.handleCancel();this.handlePending(i,u);return}s.cancelable&&s.preventDefault(),l(d)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===yo.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const uFt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class zle extends Twe{constructor(s){const{event:r}=s,n=FM(r.target);super(s,uFt,n)}}zle.activators=[{eventName:"onPointerDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return!r.isPrimary||r.button!==0?!1:(n==null||n({event:r}),!0)}}];const hFt={move:{name:"mousemove"},end:{name:"mouseup"}};var _ye;(function(t){t[t.RightClick=2]="RightClick"})(_ye||(_ye={}));class mFt extends Twe{constructor(s){super(s,hFt,FM(s.event.target))}}mFt.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return r.button===_ye.RightClick?!1:(n==null||n({event:r}),!0)}}];const npe={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class pFt extends Twe{constructor(s){super(s,npe)}static setup(){return window.addEventListener(npe.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(npe.move.name,s)};function s(){}}}pFt.activators=[{eventName:"onTouchStart",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;const{touches:a}=r;return a.length>1?!1:(n==null||n({event:r}),!0)}}];var _I;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(_I||(_I={}));var Uae;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Uae||(Uae={}));function fFt(t){let{acceleration:s,activator:r=_I.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:i=Uae.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:p,delta:f,threshold:y}=t;const _=xFt({delta:f,disabled:!o}),[b,w]=TRt(),j=C.useRef({x:0,y:0}),k=C.useRef({x:0,y:0}),S=C.useMemo(()=>{switch(r){case _I.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case _I.DraggableRect:return a}},[r,a,d]),T=C.useRef(null),I=C.useCallback(()=>{const R=T.current;if(!R)return;const $=j.current.x*k.current.x,q=j.current.y*k.current.y;R.scrollBy($,q)},[]),L=C.useMemo(()=>i===Uae.TreeOrder?[...u].reverse():u,[i,u]);C.useEffect(()=>{if(!o||!u.length||!S){w();return}for(const R of L){if((n==null?void 0:n(R))===!1)continue;const $=u.indexOf(R),q=p[$];if(!q)continue;const{direction:U,speed:H}=sFt(R,q,S,s,y);for(const Y of["x","y"])_[Y][U[Y]]||(H[Y]=0,U[Y]=0);if(H.x>0||H.y>0){w(),T.current=R,b(I,l),j.current=H,k.current=U;return}}j.current={x:0,y:0},k.current={x:0,y:0},w()},[s,I,n,w,o,l,JSON.stringify(S),JSON.stringify(_),b,u,L,p,JSON.stringify(y)])}const gFt={x:{[cu.Backward]:!1,[cu.Forward]:!1},y:{[cu.Backward]:!1,[cu.Forward]:!1}};function xFt(t){let{delta:s,disabled:r}=t;const n=gye(s);return sD(a=>{if(r||!n||!a)return gFt;const o={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[cu.Backward]:a.x[cu.Backward]||o.x===-1,[cu.Forward]:a.x[cu.Forward]||o.x===1},y:{[cu.Backward]:a.y[cu.Backward]||o.y===-1,[cu.Forward]:a.y[cu.Forward]||o.y===1}}},[r,s,n])}function yFt(t,s){const r=s!=null?t.get(s):void 0,n=r?r.node.current:null;return sD(a=>{var o;return s==null?null:(o=n??a)!=null?o:null},[n,s])}function vFt(t,s){return C.useMemo(()=>t.reduce((r,n)=>{const{sensor:a}=n,o=a.activators.map(l=>({eventName:l.eventName,handler:s(l.handler,n)}));return[...r,...o]},[]),[t,s])}var M6;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(M6||(M6={}));var bye;(function(t){t.Optimized="optimized"})(bye||(bye={}));const aEe=new Map;function _Ft(t,s){let{dragging:r,dependencies:n,config:a}=s;const[o,l]=C.useState(null),{frequency:i,measure:d,strategy:u}=a,p=C.useRef(t),f=j(),y=S6(f),_=C.useCallback(function(k){k===void 0&&(k=[]),!y.current&&l(S=>S===null?k:S.concat(k.filter(T=>!S.includes(T))))},[y]),b=C.useRef(null),w=sD(k=>{if(f&&!r)return aEe;if(!k||k===aEe||p.current!==t||o!=null){const S=new Map;for(let T of t){if(!T)continue;if(o&&o.length>0&&!o.includes(T.id)&&T.rect.current){S.set(T.id,T.rect.current);continue}const I=T.node.current,L=I?new Cwe(d(I),I):null;T.rect.current=L,L&&S.set(T.id,L)}return S}return k},[t,o,r,f,d]);return C.useEffect(()=>{p.current=t},[t]),C.useEffect(()=>{f||_()},[r,f]),C.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),C.useEffect(()=>{f||typeof i!="number"||b.current!==null||(b.current=setTimeout(()=>{_(),b.current=null},i))},[i,f,_,...n]),{droppableRects:w,measureDroppableContainers:_,measuringScheduled:o!=null};function j(){switch(u){case M6.Always:return!1;case M6.BeforeDragging:return r;default:return!r}}}function rZe(t,s){return sD(r=>t?r||(typeof s=="function"?s(t):t):null,[s,t])}function bFt(t,s){return rZe(t,s)}function wFt(t){let{callback:s,disabled:r}=t;const n=kwe(s),a=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,r]);return C.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function Ble(t){let{callback:s,disabled:r}=t;const n=kwe(s),a=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[r]);return C.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function jFt(t){return new Cwe(zM(t),t)}function iEe(t,s,r){s===void 0&&(s=jFt);const[n,a]=C.useState(null);function o(){a(d=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=d??r)!=null?u:null}const p=s(t);return JSON.stringify(d)===JSON.stringify(p)?d:p})}const l=wFt({callback(d){if(t)for(const u of d){const{type:p,target:f}=u;if(p==="childList"&&f instanceof HTMLElement&&f.contains(t)){o();break}}}}),i=Ble({callback:o});return my(()=>{o(),t?(i==null||i.observe(t),l==null||l.observe(document.body,{childList:!0,subtree:!0})):(i==null||i.disconnect(),l==null||l.disconnect())},[t]),n}function NFt(t){const s=rZe(t);return ZKe(t,s)}const oEe=[];function kFt(t){const s=C.useRef(t),r=sD(n=>t?n&&n!==oEe&&t&&s.current&&t.parentNode===s.current.parentNode?n:Fle(t):oEe,[t]);return C.useEffect(()=>{s.current=t},[t]),r}function SFt(t){const[s,r]=C.useState(null),n=C.useRef(t),a=C.useCallback(o=>{const l=spe(o.target);l&&r(i=>i?(i.set(l,vye(l)),new Map(i)):null)},[]);return C.useEffect(()=>{const o=n.current;if(t!==o){l(o);const i=t.map(d=>{const u=spe(d);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,vye(u)]):null}).filter(d=>d!=null);r(i.length?new Map(i):null),n.current=t}return()=>{l(t),l(o)};function l(i){i.forEach(d=>{const u=spe(d);u==null||u.removeEventListener("scroll",a)})}},[a,t]),C.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,l)=>U5(o,l),ex):tZe(t):ex,[t,s])}function lEe(t,s){s===void 0&&(s=[]);const r=C.useRef(null);return C.useEffect(()=>{r.current=null},s),C.useEffect(()=>{const n=t!==ex;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?C6(t,r.current):ex}function CFt(t){C.useEffect(()=>{if(!Rle)return;const s=t.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of s)r==null||r()}},t.map(s=>{let{sensor:r}=s;return r}))}function MFt(t,s){return C.useMemo(()=>t.reduce((r,n)=>{let{eventName:a,handler:o}=n;return r[a]=l=>{o(l,s)},r},{}),[t,s])}function nZe(t){return C.useMemo(()=>t?QRt(t):null,[t])}const cEe=[];function TFt(t,s){s===void 0&&(s=zM);const[r]=t,n=nZe(r?qm(r):null),[a,o]=C.useState(cEe);function l(){o(()=>t.length?t.map(d=>JKe(d)?n:new Cwe(s(d),d)):cEe)}const i=Ble({callback:l});return my(()=>{i==null||i.disconnect(),l(),t.forEach(d=>i==null?void 0:i.observe(d))},[t]),a}function AFt(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return tD(s)?s:t}function EFt(t){let{measure:s}=t;const[r,n]=C.useState(null),a=C.useCallback(u=>{for(const{target:p}of u)if(tD(p)){n(f=>{const y=s(p);return f?{...f,width:y.width,height:y.height}:y});break}},[s]),o=Ble({callback:a}),l=C.useCallback(u=>{const p=AFt(u);o==null||o.disconnect(),p&&(o==null||o.observe(p)),n(p?s(p):null)},[s,o]),[i,d]=$ae(l);return C.useMemo(()=>({nodeRef:i,rect:r,setRef:d}),[r,i,d])}const PFt=[{sensor:zle,options:{}},{sensor:Mwe,options:{}}],IFt={current:{}},Lre={draggable:{measure:tEe},droppable:{measure:tEe,strategy:M6.WhileDragging,frequency:bye.Optimized},dragOverlay:{measure:zM}};class bI extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,n;return(r=(n=this.get(s))==null?void 0:n.node.current)!=null?r:void 0}}const LFt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new bI,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:qae},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Lre,measureDroppableContainers:qae,windowRect:null,measuringScheduled:!1},DFt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:qae,draggableNodes:new Map,over:null,measureDroppableContainers:qae},$le=C.createContext(DFt),aZe=C.createContext(LFt);function OFt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new bI}}}function RFt(t,s){switch(s.type){case Fd.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case Fd.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:s.coordinates.x-t.draggable.initialCoordinates.x,y:s.coordinates.y-t.draggable.initialCoordinates.y}}};case Fd.DragEnd:case Fd.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Fd.RegisterDroppable:{const{element:r}=s,{id:n}=r,a=new bI(t.droppable.containers);return a.set(n,r),{...t,droppable:{...t.droppable,containers:a}}}case Fd.SetDroppableDisabled:{const{id:r,key:n,disabled:a}=s,o=t.droppable.containers.get(r);if(!o||n!==o.key)return t;const l=new bI(t.droppable.containers);return l.set(r,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:l}}}case Fd.UnregisterDroppable:{const{id:r,key:n}=s,a=t.droppable.containers.get(r);if(!a||n!==a.key)return t;const o=new bI(t.droppable.containers);return o.delete(r),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function FFt(t){let{disabled:s}=t;const{active:r,activatorEvent:n,draggableNodes:a}=C.useContext($le),o=gye(n),l=gye(r==null?void 0:r.id);return C.useEffect(()=>{if(!s&&!n&&o&&l!=null){if(!Swe(o)||document.activeElement===o.target)return;const i=a.get(l);if(!i)return;const{activatorNode:d,node:u}=i;if(!d.current&&!u.current)return;requestAnimationFrame(()=>{for(const p of[d.current,u.current]){if(!p)continue;const f=PRt(p);if(f){f.focus();break}}})}},[n,s,a,l,o]),null}function zFt(t,s){let{transform:r,...n}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...n}),r):r}function BFt(t){return C.useMemo(()=>({draggable:{...Lre.draggable,...t==null?void 0:t.draggable},droppable:{...Lre.droppable,...t==null?void 0:t.droppable},dragOverlay:{...Lre.dragOverlay,...t==null?void 0:t.dragOverlay}}),[t==null?void 0:t.draggable,t==null?void 0:t.droppable,t==null?void 0:t.dragOverlay])}function $Ft(t){let{activeNode:s,measure:r,initialRect:n,config:a=!0}=t;const o=C.useRef(!1),{x:l,y:i}=typeof a=="boolean"?{x:a,y:a}:a;my(()=>{if(!l&&!i||!s){o.current=!1;return}if(o.current||!n)return;const u=s==null?void 0:s.node.current;if(!u||u.isConnected===!1)return;const p=r(u),f=ZKe(p,n);if(l||(f.x=0),i||(f.y=0),o.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const y=YKe(u);y&&y.scrollBy({top:f.y,left:f.x})}},[s,l,i,n,r])}const iZe=C.createContext({...ex,scaleX:1,scaleY:1});var _1;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(_1||(_1={}));const oZe=C.memo(function(s){var r,n,a,o;let{id:l,accessibility:i,autoScroll:d=!0,children:u,sensors:p=PFt,collisionDetection:f=HRt,measuring:y,modifiers:_,...b}=s;const w=C.useReducer(RFt,void 0,OFt),[j,k]=w,[S,T]=FRt(),[I,L]=C.useState(_1.Uninitialized),R=I===_1.Initialized,{draggable:{active:$,nodes:q,translate:U},droppable:{containers:H}}=j,Y=$!=null?q.get($):null,se=C.useRef({initial:null,translated:null}),te=C.useMemo(()=>{var si;return $!=null?{id:$,data:(si=Y==null?void 0:Y.data)!=null?si:IFt,rect:se}:null},[$,Y]),Q=C.useRef(null),[de,re]=C.useState(null),[ae,le]=C.useState(null),he=S6(b,Object.values(b)),be=rD("DndDescribedBy",l),_e=C.useMemo(()=>H.getEnabled(),[H]),je=BFt(y),{droppableRects:Ne,measureDroppableContainers:Ge,measuringScheduled:we}=_Ft(_e,{dragging:R,dependencies:[U.x,U.y],config:je.droppable}),Me=yFt(q,$),Te=C.useMemo(()=>ae?xye(ae):null,[ae]),Fe=bo(),Ae=bFt(Me,je.draggable.measure);$Ft({activeNode:$!=null?q.get($):null,config:Fe.layoutShiftCompensation,initialRect:Ae,measure:je.draggable.measure});const Ue=iEe(Me,je.draggable.measure,Ae),ut=iEe(Me?Me.parentElement:null),De=C.useRef({activatorEvent:null,active:null,activeNode:Me,collisionRect:null,collisions:null,droppableRects:Ne,draggableNodes:q,draggingNode:null,draggingNodeRect:null,droppableContainers:H,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Rt=H.getNodeFor((r=De.current.over)==null?void 0:r.id),me=EFt({measure:je.dragOverlay.measure}),Xe=(n=me.nodeRef.current)!=null?n:Me,ot=R?(a=me.rect)!=null?a:Ue:null,nt=!!(me.nodeRef.current&&me.rect),Se=NFt(nt?null:Ue),it=nZe(Xe?qm(Xe):null),$e=kFt(R?Rt??Me:null),ct=TFt($e),qe=zFt(_,{transform:{x:U.x-Se.x,y:U.y-Se.y,scaleX:1,scaleY:1},activatorEvent:ae,active:te,activeNodeRect:Ue,containerNodeRect:ut,draggingNodeRect:ot,over:De.current.over,overlayNodeRect:me.rect,scrollableAncestors:$e,scrollableAncestorRects:ct,windowRect:it}),Ze=Te?U5(Te,U):null,Qe=SFt($e),We=lEe(Qe),He=lEe(Qe,[Ue]),et=U5(qe,We),Tt=ot?KRt(ot,qe):null,Ft=te&&Tt?f({active:te,collisionRect:Tt,droppableRects:Ne,droppableContainers:_e,pointerCoordinates:Ze}):null,as=GKe(Ft,"id"),[Xt,ss]=C.useState(null),is=nt?qe:U5(qe,He),ar=WRt(is,(o=Xt==null?void 0:Xt.rect)!=null?o:null,Ue),Ct=C.useRef(null),Is=C.useCallback((si,nn)=>{let{sensor:ia,options:kn}=nn;if(Q.current==null)return;const sa=q.get(Q.current);if(!sa)return;const Zt=si.nativeEvent,$r=new ia({active:Q.current,activeNode:sa,event:Zt,options:kn,context:De,onAbort(an){if(!q.get(an))return;const{onDragAbort:Zn}=he.current,Ir={id:an};Zn==null||Zn(Ir),S({type:"onDragAbort",event:Ir})},onPending(an,Ra,Zn,Ir){if(!q.get(an))return;const{onDragPending:Go}=he.current,yi={id:an,constraint:Ra,initialCoordinates:Zn,offset:Ir};Go==null||Go(yi),S({type:"onDragPending",event:yi})},onStart(an){const Ra=Q.current;if(Ra==null)return;const Zn=q.get(Ra);if(!Zn)return;const{onDragStart:Ir}=he.current,mi={activatorEvent:Zt,active:{id:Ra,data:Zn.data,rect:se}};km.unstable_batchedUpdates(()=>{Ir==null||Ir(mi),L(_1.Initializing),k({type:Fd.DragStart,initialCoordinates:an,active:Ra}),S({type:"onDragStart",event:mi}),re(Ct.current),le(Zt)})},onMove(an){k({type:Fd.DragMove,coordinates:an})},onEnd:es(Fd.DragEnd),onCancel:es(Fd.DragCancel)});Ct.current=$r;function es(an){return async function(){const{active:Zn,collisions:Ir,over:mi,scrollAdjustedTranslate:Go}=De.current;let yi=null;if(Zn&&Go){const{cancelDrop:Vl}=he.current;yi={activatorEvent:Zt,active:Zn,collisions:Ir,delta:Go,over:mi},an===Fd.DragEnd&&typeof Vl=="function"&&await Promise.resolve(Vl(yi))&&(an=Fd.DragCancel)}Q.current=null,km.unstable_batchedUpdates(()=>{k({type:an}),L(_1.Uninitialized),ss(null),re(null),le(null),Ct.current=null;const Vl=an===Fd.DragEnd?"onDragEnd":"onDragCancel";if(yi){const Vt=he.current[Vl];Vt==null||Vt(yi),S({type:Vl,event:yi})}})}}},[q]),qs=C.useCallback((si,nn)=>(ia,kn)=>{const sa=ia.nativeEvent,Zt=q.get(kn);if(Q.current!==null||!Zt||sa.dndKit||sa.defaultPrevented)return;const $r={active:Zt};si(ia,nn.options,$r)===!0&&(sa.dndKit={capturedBy:nn.sensor},Q.current=kn,Is(ia,nn))},[q,Is]),gr=vFt(p,qs);CFt(p),my(()=>{Ue&&I===_1.Initializing&&L(_1.Initialized)},[Ue,I]),C.useEffect(()=>{const{onDragMove:si}=he.current,{active:nn,activatorEvent:ia,collisions:kn,over:sa}=De.current;if(!nn||!ia)return;const Zt={active:nn,activatorEvent:ia,collisions:kn,delta:{x:et.x,y:et.y},over:sa};km.unstable_batchedUpdates(()=>{si==null||si(Zt),S({type:"onDragMove",event:Zt})})},[et.x,et.y]),C.useEffect(()=>{const{active:si,activatorEvent:nn,collisions:ia,droppableContainers:kn,scrollAdjustedTranslate:sa}=De.current;if(!si||Q.current==null||!nn||!sa)return;const{onDragOver:Zt}=he.current,$r=kn.get(as),es=$r&&$r.rect.current?{id:$r.id,rect:$r.rect.current,data:$r.data,disabled:$r.disabled}:null,an={active:si,activatorEvent:nn,collisions:ia,delta:{x:sa.x,y:sa.y},over:es};km.unstable_batchedUpdates(()=>{ss(es),Zt==null||Zt(an),S({type:"onDragOver",event:an})})},[as]),my(()=>{De.current={activatorEvent:ae,active:te,activeNode:Me,collisionRect:Tt,collisions:Ft,droppableRects:Ne,draggableNodes:q,draggingNode:Xe,draggingNodeRect:ot,droppableContainers:H,over:Xt,scrollableAncestors:$e,scrollAdjustedTranslate:et},se.current={initial:ot,translated:Tt}},[te,Me,Ft,Tt,q,Xe,ot,Ne,H,Xt,$e,et]),fFt({...Fe,delta:U,draggingRect:Tt,pointerCoordinates:Ze,scrollableAncestors:$e,scrollableAncestorRects:ct});const Wn=C.useMemo(()=>({active:te,activeNode:Me,activeNodeRect:Ue,activatorEvent:ae,collisions:Ft,containerNodeRect:ut,dragOverlay:me,draggableNodes:q,droppableContainers:H,droppableRects:Ne,over:Xt,measureDroppableContainers:Ge,scrollableAncestors:$e,scrollableAncestorRects:ct,measuringConfiguration:je,measuringScheduled:we,windowRect:it}),[te,Me,Ue,ae,Ft,ut,me,q,H,Ne,Xt,Ge,$e,ct,je,we,it]),ii=C.useMemo(()=>({activatorEvent:ae,activators:gr,active:te,activeNodeRect:Ue,ariaDescribedById:{draggable:be},dispatch:k,draggableNodes:q,over:Xt,measureDroppableContainers:Ge}),[ae,gr,te,Ue,k,be,q,Xt,Ge]);return ht.createElement(UKe.Provider,{value:T},ht.createElement($le.Provider,{value:ii},ht.createElement(aZe.Provider,{value:Wn},ht.createElement(iZe.Provider,{value:ar},u)),ht.createElement(FFt,{disabled:(i==null?void 0:i.restoreFocus)===!1})),ht.createElement($Rt,{...i,hiddenTextDescribedById:be}));function bo(){const si=(de==null?void 0:de.autoScrollEnabled)===!1,nn=typeof d=="object"?d.enabled===!1:d===!1,ia=R&&!si&&!nn;return typeof d=="object"?{...d,enabled:ia}:{enabled:ia}}}),qFt=C.createContext(null),dEe="button",UFt="Draggable";function VFt(t){let{id:s,data:r,disabled:n=!1,attributes:a}=t;const o=rD(UFt),{activators:l,activatorEvent:i,active:d,activeNodeRect:u,ariaDescribedById:p,draggableNodes:f,over:y}=C.useContext($le),{role:_=dEe,roleDescription:b="draggable",tabIndex:w=0}=a??{},j=(d==null?void 0:d.id)===s,k=C.useContext(j?iZe:qFt),[S,T]=$ae(),[I,L]=$ae(),R=MFt(l,s),$=S6(r);my(()=>(f.set(s,{id:s,key:o,node:S,activatorNode:I,data:$}),()=>{const U=f.get(s);U&&U.key===o&&f.delete(s)}),[f,s]);const q=C.useMemo(()=>({role:_,tabIndex:w,"aria-disabled":n,"aria-pressed":j&&_===dEe?!0:void 0,"aria-roledescription":b,"aria-describedby":p.draggable}),[n,_,w,j,b,p.draggable]);return{active:d,activatorEvent:i,activeNodeRect:u,attributes:q,isDragging:j,listeners:n?void 0:R,node:S,over:y,setNodeRef:T,setActivatorNodeRef:L,transform:k}}function HFt(){return C.useContext(aZe)}const WFt="Droppable",GFt={timeout:25};function KFt(t){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=t;const o=rD(WFt),{active:l,dispatch:i,over:d,measureDroppableContainers:u}=C.useContext($le),p=C.useRef({disabled:r}),f=C.useRef(!1),y=C.useRef(null),_=C.useRef(null),{disabled:b,updateMeasurementsFor:w,timeout:j}={...GFt,...a},k=S6(w??n),S=C.useCallback(()=>{if(!f.current){f.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{u(Array.isArray(k.current)?k.current:[k.current]),_.current=null},j)},[j]),T=Ble({callback:S,disabled:b||!l}),I=C.useCallback((q,U)=>{T&&(U&&(T.unobserve(U),f.current=!1),q&&T.observe(q))},[T]),[L,R]=$ae(I),$=S6(s);return C.useEffect(()=>{!T||!L.current||(T.disconnect(),f.current=!1,T.observe(L.current))},[L,T]),C.useEffect(()=>(i({type:Fd.RegisterDroppable,element:{id:n,key:o,disabled:r,node:L,rect:y,data:$}}),()=>i({type:Fd.UnregisterDroppable,key:o,id:n})),[n]),C.useEffect(()=>{r!==p.current.disabled&&(i({type:Fd.SetDroppableDisabled,id:n,key:o,disabled:r}),p.current.disabled=r)},[n,o,r,i]),{active:l,rect:y,isOver:(d==null?void 0:d.id)===n,node:L,over:d,setNodeRef:R}}function Awe(t,s,r){const n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(s,1)[0]),n}function ZFt(t,s){return t.reduce((r,n,a)=>{const o=s.get(n);return o&&(r[a]=o),r},Array(t.length))}function vR(t){return t!==null&&t>=0}function YFt(t,s){if(t===s)return!0;if(t.length!==s.length)return!1;for(let r=0;r{var s;let{rects:r,activeNodeRect:n,activeIndex:a,overIndex:o,index:l}=t;const i=(s=r[a])!=null?s:n;if(!i)return null;const d=QFt(r,l,a);if(l===a){const u=r[o];return u?{x:aa&&l<=o?{x:-i.width-d,y:0,..._R}:l=o?{x:i.width+d,y:0,..._R}:{x:0,y:0,..._R}};function QFt(t,s,r){const n=t[s],a=t[s-1],o=t[s+1];return!n||!a&&!o?0:r{let{rects:s,activeIndex:r,overIndex:n,index:a}=t;const o=Awe(s,n,r),l=s[a],i=o[a];return!i||!l?null:{x:i.left-l.left,y:i.top-l.top,scaleX:i.width/l.width,scaleY:i.height/l.height}},lZe="Sortable",cZe=ht.createContext({activeIndex:-1,containerId:lZe,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:qle,disabled:{draggable:!1,droppable:!1}});function dZe(t){let{children:s,id:r,items:n,strategy:a=qle,disabled:o=!1}=t;const{active:l,dragOverlay:i,droppableRects:d,over:u,measureDroppableContainers:p}=HFt(),f=rD(lZe,r),y=i.rect!==null,_=C.useMemo(()=>n.map(R=>typeof R=="object"&&"id"in R?R.id:R),[n]),b=l!=null,w=l?_.indexOf(l.id):-1,j=u?_.indexOf(u.id):-1,k=C.useRef(_),S=!YFt(_,k.current),T=j!==-1&&w===-1||S,I=XFt(o);my(()=>{S&&b&&p(_)},[S,_,b,p]),C.useEffect(()=>{k.current=_},[_]);const L=C.useMemo(()=>({activeIndex:w,containerId:f,disabled:I,disableTransforms:T,items:_,overIndex:j,useDragOverlay:y,sortedRects:ZFt(_,d),strategy:a}),[w,f,I.draggable,I.droppable,T,_,j,d,y,a]);return ht.createElement(cZe.Provider,{value:L},s)}const JFt=t=>{let{id:s,items:r,activeIndex:n,overIndex:a}=t;return Awe(r,n,a).indexOf(s)},ezt=t=>{let{containerId:s,isSorting:r,wasDragging:n,index:a,items:o,newIndex:l,previousItems:i,previousContainerId:d,transition:u}=t;return!u||!n||i!==o&&a===l?!1:r?!0:l!==a&&s===d},tzt={duration:200,easing:"ease"},uZe="transform",szt=D3.Transition.toString({property:uZe,duration:0,easing:"linear"}),rzt={roleDescription:"sortable"};function nzt(t){let{disabled:s,index:r,node:n,rect:a}=t;const[o,l]=C.useState(null),i=C.useRef(r);return my(()=>{if(!s&&r!==i.current&&n.current){const d=a.current;if(d){const u=zM(n.current,{ignoreTransform:!0}),p={x:d.left-u.left,y:d.top-u.top,scaleX:d.width/u.width,scaleY:d.height/u.height};(p.x||p.y)&&l(p)}}r!==i.current&&(i.current=r)},[s,r,n,a]),C.useEffect(()=>{o&&l(null)},[o]),o}function hZe(t){let{animateLayoutChanges:s=ezt,attributes:r,disabled:n,data:a,getNewIndex:o=JFt,id:l,strategy:i,resizeObserverConfig:d,transition:u=tzt}=t;const{items:p,containerId:f,activeIndex:y,disabled:_,disableTransforms:b,sortedRects:w,overIndex:j,useDragOverlay:k,strategy:S}=C.useContext(cZe),T=azt(n,_),I=p.indexOf(l),L=C.useMemo(()=>({sortable:{containerId:f,index:I,items:p},...a}),[f,a,I,p]),R=C.useMemo(()=>p.slice(p.indexOf(l)),[p,l]),{rect:$,node:q,isOver:U,setNodeRef:H}=KFt({id:l,data:L,disabled:T.droppable,resizeObserverConfig:{updateMeasurementsFor:R,...d}}),{active:Y,activatorEvent:se,activeNodeRect:te,attributes:Q,setNodeRef:de,listeners:re,isDragging:ae,over:le,setActivatorNodeRef:he,transform:be}=VFt({id:l,data:L,attributes:{...rzt,...r},disabled:T.draggable}),_e=MRt(H,de),je=!!Y,Ne=je&&!b&&vR(y)&&vR(j),Ge=!k&&ae,we=Ge&&Ne?be:null,Te=Ne?we??(i??S)({rects:w,activeNodeRect:te,activeIndex:y,overIndex:j,index:I}):null,Fe=vR(y)&&vR(j)?o({id:l,items:p,activeIndex:y,overIndex:j}):I,Ae=Y==null?void 0:Y.id,Ue=C.useRef({activeId:Ae,items:p,newIndex:Fe,containerId:f}),ut=p!==Ue.current.items,De=s({active:Y,containerId:f,isDragging:ae,isSorting:je,id:l,index:I,items:p,newIndex:Ue.current.newIndex,previousItems:Ue.current.items,previousContainerId:Ue.current.containerId,transition:u,wasDragging:Ue.current.activeId!=null}),Rt=nzt({disabled:!De,index:I,node:q,rect:$});return C.useEffect(()=>{je&&Ue.current.newIndex!==Fe&&(Ue.current.newIndex=Fe),f!==Ue.current.containerId&&(Ue.current.containerId=f),p!==Ue.current.items&&(Ue.current.items=p)},[je,Fe,f,p]),C.useEffect(()=>{if(Ae===Ue.current.activeId)return;if(Ae!=null&&Ue.current.activeId==null){Ue.current.activeId=Ae;return}const Xe=setTimeout(()=>{Ue.current.activeId=Ae},50);return()=>clearTimeout(Xe)},[Ae]),{active:Y,activeIndex:y,attributes:Q,data:L,rect:$,index:I,newIndex:Fe,items:p,isOver:U,isSorting:je,isDragging:ae,listeners:re,node:q,overIndex:j,over:le,setNodeRef:_e,setActivatorNodeRef:he,setDroppableNodeRef:H,setDraggableNodeRef:de,transform:Rt??Te,transition:me()};function me(){if(Rt||ut&&Ue.current.newIndex===I)return szt;if(!(Ge&&!Swe(se)||!u)&&(je||De))return D3.Transition.toString({...u,property:uZe})}}function azt(t,s){var r,n;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(r=t==null?void 0:t.draggable)!=null?r:s.draggable,droppable:(n=t==null?void 0:t.droppable)!=null?n:s.droppable}}function Vae(t){if(!t)return!1;const s=t.data.current;return!!(s&&"sortable"in s&&typeof s.sortable=="object"&&"containerId"in s.sortable&&"items"in s.sortable&&"index"in s.sortable)}const izt=[yo.Down,yo.Right,yo.Up,yo.Left],ozt=(t,s)=>{let{context:{active:r,collisionRect:n,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=s;if(izt.includes(t.code)){if(t.preventDefault(),!r||!n)return;const d=[];o.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const y=a.get(f.id);if(y)switch(t.code){case yo.Down:n.topy.top&&d.push(f);break;case yo.Left:n.left>y.left&&d.push(f);break;case yo.Right:n.left1&&(p=u[1].id),p!=null){const f=o.get(r.id),y=o.get(p),_=y?a.get(y.id):null,b=y==null?void 0:y.node.current;if(b&&_&&f&&y){const j=Fle(b).some((R,$)=>i[$]!==R),k=mZe(f,y),S=lzt(f,y),T=j||!k?{x:0,y:0}:{x:S?n.width-_.width:0,y:S?n.height-_.height:0},I={x:_.left,y:_.top};return T.x&&T.y?I:C6(I,T)}}}};function mZe(t,s){return!Vae(t)||!Vae(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function lzt(t,s){return!Vae(t)||!Vae(s)||!mZe(t,s)?!1:t.data.current.sortable.indexs(t),children:e.jsx(Da,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"destructive",size:"icon",className:"h-7 w-7",onClick:()=>r(t),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]}),t.post_date&&e.jsx("div",{className:"absolute bottom-2 left-2",children:e.jsxs(rt,{className:"bg-primary/90 text-primary-foreground text-[10px] gap-1 backdrop-blur-sm px-1.5 py-0.5",children:[e.jsx(on,{className:"h-2.5 w-2.5"}),ys(new Date(t.post_date+"T00:00:00"),"MMM d")]})})]}),e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3",children:t.caption}),e.jsxs(Co,{children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:Pt("w-full h-7 text-[11px] gap-1 justify-start font-normal",!t.post_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"h-3 w-3"}),t.post_date?ys(new Date(t.post_date+"T00:00:00"),"MMM d, yyyy"):"Set post date"]})}),e.jsxs(No,{className:"w-auto p-0",align:"start",children:[e.jsx(jp,{mode:"single",selected:t.post_date?new Date(t.post_date+"T00:00:00"):void 0,onSelect:f=>n(t.id,f?ys(f,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"}),t.post_date&&e.jsx("div",{className:"p-2 border-t",children:e.jsx(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>n(t.id,null),children:"Clear date"})})]})]})]})]})})}const dzt=()=>{const t=rs(),[s,r]=C.useState("all"),[n,a]=C.useState(!1),[o,l]=C.useState(ys(new Date,"yyyy-MM")),[i,d]=C.useState([]),[u,p]=C.useState(!1),[f,y]=C.useState(null),[_,b]=C.useState(null),[w,j]=C.useState(""),[k,S]=C.useState(null),[T,I]=C.useState(!1),[L,R]=C.useState(!1),[$,q]=C.useState(ys(new Date,"yyyy-MM")),[U,H]=C.useState(null),[Y,se]=C.useState(""),[te,Q]=C.useState(""),[de,re]=C.useState(""),[ae,le]=C.useState(!1),he=VKe(yye(zle,{activationConstraint:{distance:5}}),yye(Mwe,{coordinateGetter:ozt})),{data:be=[],isLoading:_e}=wt({queryKey:["admin-social-swag-2"],queryFn:async()=>{const{data:Ze,error:Qe}=await G.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(Qe)throw Qe;return Ze}}),{data:je=[]}=wt({queryKey:["admin-social-swag-2-months"],queryFn:async()=>{const{data:Ze,error:Qe}=await G.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(Qe)throw Qe;return Ze}}),{data:Ne=[]}=wt({queryKey:["admin-social-swag-2-reels"],queryFn:async()=>{const{data:Ze,error:Qe}=await G.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(Qe)throw Qe;return Ze}}),Ge=[...new Set(be.map(Ze=>Ze.month))].sort((Ze,Qe)=>Qe.localeCompare(Ze)),we=s==="all"?be:be.filter(Ze=>Ze.month===s),Me=Ze=>{const Qe=h_e(Ze,"yyyy-MM",new Date);return ys(Qe,"MMMM yyyy")},Te=Ze=>{b(Ze),j(Ze.caption),S(Ze.post_date)},Fe=async()=>{if(_){I(!0);try{const{error:Ze}=await G.from("social_swag_2").update({caption:w,post_date:k}).eq("id",_.id);if(Ze)throw Ze;fe.success("Image updated"),b(null),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})}catch{fe.error("Failed to update image")}finally{I(!1)}}},Ae=async Ze=>{const{active:Qe,over:We}=Ze;if(!We||Qe.id===We.id)return;const He=we,et=He.findIndex(as=>as.id===Qe.id),Tt=He.findIndex(as=>as.id===We.id);if(et===-1||Tt===-1)return;const Ft=Awe(He,et,Tt);t.setQueryData(["admin-social-swag-2"],as=>{if(!as)return as;const Xt={};return Ft.forEach((ss,is)=>{Xt[ss.id]=is}),as.map(ss=>Xt[ss.id]!==void 0?{...ss,sort_order:Xt[ss.id]}:ss).sort((ss,is)=>ss.month!==is.month?is.month.localeCompare(ss.month):ss.sort_order-is.sort_order)});try{await Promise.all(Ft.map((as,Xt)=>G.from("social_swag_2").update({sort_order:Xt}).eq("id",as.id)))}catch{fe.error("Failed to save order"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})}},Ue=Ze=>{const We=Array.from(Ze.target.files||[]).sort((He,et)=>He.name.localeCompare(et.name,void 0,{numeric:!0,sensitivity:"base"})).slice(0,16-i.length).map(He=>({file:He,preview:URL.createObjectURL(He),caption:""}));d(He=>[...He,...We].slice(0,16))},ut=Ze=>{d(Qe=>{const We=[...Qe];return URL.revokeObjectURL(We[Ze].preview),We.splice(Ze,1),We})},De=(Ze,Qe)=>{d(We=>{const He=[...We];return He[Ze]={...He[Ze],caption:Qe},He})},Rt=async()=>{var Qe;if(i.length===0){fe.error("Please add at least one image");return}if(i.filter(We=>!We.caption.trim()).length>0){fe.error("Please add captions to all images");return}p(!0);try{const{data:We}=await G.from("social_swag_2").select("sort_order").eq("month",o).order("sort_order",{ascending:!1}).limit(1),He=(((Qe=We==null?void 0:We[0])==null?void 0:Qe.sort_order)??-1)+1;for(let et=0;et{const Qe=Ze.image_url.split("/social-swag-2/");Qe[1]&&await G.storage.from("social-swag-2").remove([Qe[1]]);const{error:We}=await G.from("social_swag_2").delete().eq("id",Ze.id);if(We)throw We},onSuccess:()=>{fe.success("Image deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})},onError:()=>fe.error("Failed to delete image")}),Xe=Dt({mutationFn:async({id:Ze,postDate:Qe})=>{const{error:We}=await G.from("social_swag_2").update({post_date:Qe}).eq("id",Ze);if(We)throw We},onSuccess:()=>{fe.success("Post date updated"),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})},onError:()=>fe.error("Failed to update post date")}),ot=Dt({mutationFn:async({month:Ze,link:Qe})=>{const{error:We}=await G.from("social_swag_2_months").upsert({month:Ze,canva_link:Qe||null},{onConflict:"month"});if(We)throw We},onSuccess:()=>{fe.success("Canva link updated"),y(null),t.invalidateQueries({queryKey:["admin-social-swag-2-months"]})},onError:()=>fe.error("Failed to update Canva link")}),nt=Ze=>{var Qe;return((Qe=je.find(We=>We.month===Ze))==null?void 0:Qe.canva_link)||""},Se=Ze=>Ne.find(Qe=>Qe.month===Ze)||null,it=Ze=>{var We;const Qe=(We=Ze.target.files)==null?void 0:We[0];Qe&&(H(Qe),se(URL.createObjectURL(Qe)))},$e=()=>{Y&&URL.revokeObjectURL(Y),H(null),se(""),Q(""),re("")},ct=async()=>{if(!U){fe.error("Please select an image");return}le(!0);try{const Ze=U.name.split(".").pop(),Qe=`reels/${$}-${Date.now()}.${Ze}`,{error:We}=await G.storage.from("social-swag-2").upload(Qe,U);if(We)throw We;const{data:{publicUrl:He}}=G.storage.from("social-swag-2").getPublicUrl(Qe),{error:et}=await G.from("social_swag_2_reels").upsert({month:$,image_url:He,canva_link:de||null,caption:te||null},{onConflict:"month"});if(et)throw et;fe.success("Reel uploaded successfully!"),fye(`${Me($)} Reel`,"social-swag-2"),$e(),R(!1),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})}catch(Ze){console.error("Reel upload error:",Ze),fe.error("Failed to upload reel")}finally{le(!1)}},qe=Dt({mutationFn:async Ze=>{const Qe=Ze.image_url.split("/social-swag-2/");Qe[1]&&await G.storage.from("social-swag-2").remove([Qe[1]]);const{error:We}=await G.from("social_swag_2_reels").delete().eq("id",Ze.id);if(We)throw We},onSuccess:()=>{fe.success("Reel deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})},onError:()=>fe.error("Failed to delete reel")});return e.jsxs(Ts,{title:"Admin - Social Swag 2.0",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Social Swag 2.0"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage monthly social media images and captions"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(_s,{open:n,onOpenChange:a,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Upload Images"]})}),e.jsxs(vs,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Upload Social Swag Images"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Month"}),e.jsx(Re,{type:"month",value:o,onChange:Ze=>l(Ze.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{children:["Images (",i.length,"/16)"]}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",multiple:!0,onChange:Ue,className:"hidden",id:"swag-upload",disabled:i.length>=16}),e.jsxs("label",{htmlFor:"swag-upload",className:"cursor-pointer",children:[e.jsx(Za,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select images (max 16)"})]})]})]}),i.length>0&&e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:i.map((Ze,Qe)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative aspect-[4/5] rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:Ze.preview,alt:`Upload ${Qe+1}`,className:"w-full h-full object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>ut(Qe),children:e.jsx(Ur,{className:"h-3 w-3"})})]}),e.jsx(Ar,{placeholder:"Caption...",value:Ze.caption,onChange:We=>De(Qe,We.target.value),className:"text-xs h-20"})]},Qe))}),e.jsx(K,{onClick:Rt,disabled:u||i.length===0,className:"w-full gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Za,{className:"h-4 w-4"}),"Upload ",i.length," Images"]})})]})]})]}),e.jsxs(_s,{open:L,onOpenChange:Ze=>{R(Ze),Ze||$e()},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(lu,{className:"h-4 w-4"}),"Upload Reel"]})}),e.jsxs(vs,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Upload Monthly Reel"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Month"}),e.jsx(Re,{type:"month",value:$,onChange:Ze=>q(Ze.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Reel Preview Image"}),Y?e.jsxs("div",{className:"relative aspect-[9/16] max-w-[120px] mx-auto rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:Y,alt:"Reel preview",className:"w-full h-full object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{URL.revokeObjectURL(Y),H(null),se("")},children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:it,className:"hidden",id:"reel-upload"}),e.jsxs("label",{htmlFor:"reel-upload",className:"cursor-pointer",children:[e.jsx(lu,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select reel preview image"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Canva Download Link"}),e.jsx(Re,{value:de,onChange:Ze=>re(Ze.target.value),placeholder:"https://www.canva.com/..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Caption"}),e.jsx(Ar,{value:te,onChange:Ze=>Q(Ze.target.value),placeholder:"Enter caption for this reel...",className:"h-24"})]}),e.jsx(K,{onClick:ct,disabled:ae||!U,className:"w-full gap-2",children:ae?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Za,{className:"h-4 w-4"}),"Upload Reel"]})})]})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:be.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Images"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:Ge.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Months"})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ka,{value:s,onValueChange:r,children:e.jsxs(_a,{children:[e.jsx(js,{value:"all",children:"All"}),Ge.map(Ze=>e.jsx(js,{value:Ze,children:Me(Ze)},Ze))]})}),s!=="all"&&e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Do,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(ve,{className:"text-sm text-muted-foreground",children:["Canva Edit Link for ",Me(s)]}),(f==null?void 0:f.month)===s?e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(Re,{value:f.link,onChange:Ze=>y({...f,link:Ze.target.value}),placeholder:"https://www.canva.com/..."}),e.jsx(K,{size:"sm",onClick:()=>ot.mutate(f),children:"Save"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>y(null),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-sm",children:nt(s)||"No link set"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>y({month:s,link:nt(s)}),children:"Edit"})]})]})]})})}),s!=="all"&&e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(lu,{className:"h-4 w-4 text-muted-foreground mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(ve,{className:"text-sm text-muted-foreground",children:["Reel for ",Me(s)]}),(()=>{const Ze=Se(s);return Ze?e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[e.jsx("img",{src:Ze.image_url,alt:"Reel preview",className:"w-16 h-28 object-cover rounded"}),e.jsxs("div",{className:"flex-1 text-sm",children:[e.jsx("p",{className:"line-clamp-2",children:Ze.caption||"No caption"}),Ze.canva_link&&e.jsx("a",{href:Ze.canva_link,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-xs",children:"View Canva Link"})]}),e.jsx(K,{variant:"destructive",size:"sm",onClick:()=>qe.mutate(Ze),children:e.jsx(jr,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"No reel uploaded for this month"})})()]})]})})})]}),_e?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}):we.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Jo,{className:"h-12 w-12 mx-auto text-muted-foreground/50 mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images yet. Upload some!"})]}):e.jsx(oZe,{sensors:he,collisionDetection:KKe,onDragEnd:Ae,children:e.jsx(dZe,{items:we.map(Ze=>Ze.id),strategy:qle,children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:we.map(Ze=>e.jsx(czt,{item:Ze,onEdit:Te,onDelete:Qe=>me.mutate(Qe),onDateChange:(Qe,We)=>Xe.mutate({id:Qe,postDate:We})},Ze.id))})})})]}),e.jsx(_s,{open:!!_,onOpenChange:Ze=>{Ze||b(null)},children:e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Edit Image"})}),_&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"aspect-[4/5] max-h-48 w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:_.image_url,alt:"Preview",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Caption"}),e.jsx(Ar,{value:w,onChange:Ze=>j(Ze.target.value),placeholder:"Enter caption...",className:"h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Post Date"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(Co,{children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("flex-1 justify-start gap-2 font-normal",!k&&"text-muted-foreground"),children:[e.jsx(on,{className:"h-4 w-4"}),k?ys(new Date(k+"T00:00:00"),"MMM d, yyyy"):"Pick a date"]})}),e.jsx(No,{className:"w-auto p-0",align:"start",children:e.jsx(jp,{mode:"single",selected:k?new Date(k+"T00:00:00"):void 0,onSelect:Ze=>S(Ze?ys(Ze,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"})})]}),k&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>S(null),children:e.jsx(Ur,{className:"h-4 w-4"})})]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(null),children:"Cancel"}),e.jsx(K,{onClick:Fe,disabled:T,className:"gap-2",children:T?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})]})},uzt=()=>{const{toast:t}=Pa(),s=rs(),[r,n]=C.useState("categories"),[a,o]=C.useState(!1),[l,i]=C.useState(null),[d,u]=C.useState({name:"",description:"",icon:""}),[p,f]=C.useState(!1),[y,_]=C.useState(null),[b,w]=C.useState({name:"",description:"",icon:""}),[j,k]=C.useState(!1),[S,T]=C.useState(null),[I,L]=C.useState(""),{data:R=[],isLoading:$}=wt({queryKey:["admin-community-categories"],queryFn:async()=>{const{data:Ae,error:Ue}=await G.from("community_categories").select("*").order("sort_order");if(Ue)throw Ue;return Ae}}),{data:q=[],isLoading:U}=wt({queryKey:["admin-private-groups"],queryFn:async()=>{const{data:Ae,error:Ue}=await G.from("community_private_groups").select("*").order("sort_order");if(Ue)throw Ue;return Ae}}),{data:H=[]}=wt({queryKey:["admin-group-members",S==null?void 0:S.id],queryFn:async()=>{if(!S)return[];const{data:Ae,error:Ue}=await G.from("community_private_group_members").select("*").eq("group_id",S.id);if(Ue)throw Ue;return Ae},enabled:!!S}),{data:Y=[]}=wt({queryKey:["admin-all-profiles"],queryFn:async()=>{let Ue=[],ut=0,De=!0;for(;De;){const{data:Rt,error:me}=await G.from("profiles").select("id, name, email, brokerage_id").order("name").range(ut,ut+1e3-1);if(me)throw me;Rt&&Rt.length>0?(Ue=[...Ue,...Rt],ut+=1e3,De=Rt.length===1e3):De=!1}return Ue}}),{data:se=[]}=wt({queryKey:["admin-all-brokerages"],queryFn:async()=>{const{data:Ae,error:Ue}=await G.from("brokerages").select("*").order("name");if(Ue)throw Ue;return Ae}}),te=Dt({mutationFn:async Ae=>{if(Ae.id){const{error:Ue}=await G.from("community_categories").update({name:Ae.name,description:Ae.description||null,icon:Ae.icon||null}).eq("id",Ae.id);if(Ue)throw Ue}else{const Ue=Math.max(...R.map(De=>De.sort_order),0),{error:ut}=await G.from("community_categories").insert({name:Ae.name,description:Ae.description||null,icon:Ae.icon||null,sort_order:Ue+1});if(ut)throw ut}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),o(!1),i(null),u({name:"",description:"",icon:""}),t({title:l?"Category updated!":"Category created!"})},onError:Ae=>{t({title:"Error",description:Ae.message,variant:"destructive"})}}),Q=Dt({mutationFn:async Ae=>{const{error:Ue}=await G.from("community_categories").delete().eq("id",Ae);if(Ue)throw Ue},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),t({title:"Category deleted"})}}),de=Dt({mutationFn:async({id:Ae,direction:Ue})=>{const ut=R.findIndex(De=>De.id===Ae);if(Ue==="up"&&ut>0){const De=R[ut-1],Rt=R[ut];await G.from("community_categories").update({sort_order:Rt.sort_order}).eq("id",De.id),await G.from("community_categories").update({sort_order:De.sort_order}).eq("id",Rt.id)}else if(Ue==="down"&&uts.invalidateQueries({queryKey:["admin-community-categories"]})}),re=Dt({mutationFn:async Ae=>{if(Ae.id){const{error:Ue}=await G.from("community_private_groups").update({name:Ae.name,description:Ae.description||null,icon:Ae.icon||null}).eq("id",Ae.id);if(Ue)throw Ue}else{const Ue=Math.max(...q.map(De=>De.sort_order),0),{error:ut}=await G.from("community_private_groups").insert({name:Ae.name,description:Ae.description||null,icon:Ae.icon||null,sort_order:Ue+1});if(ut)throw ut}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),f(!1),_(null),w({name:"",description:"",icon:""}),t({title:y?"Private group updated!":"Private group created!"})},onError:Ae=>{t({title:"Error",description:Ae.message,variant:"destructive"})}}),ae=Dt({mutationFn:async Ae=>{const{error:Ue}=await G.from("community_private_groups").delete().eq("id",Ae);if(Ue)throw Ue},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),t({title:"Private group deleted"})}}),le=Dt({mutationFn:async({id:Ae,direction:Ue})=>{const ut=q.findIndex(De=>De.id===Ae);if(Ue==="up"&&ut>0){const De=q[ut-1],Rt=q[ut];await G.from("community_private_groups").update({sort_order:Rt.sort_order}).eq("id",De.id),await G.from("community_private_groups").update({sort_order:De.sort_order}).eq("id",Rt.id)}else if(Ue==="down"&&uts.invalidateQueries({queryKey:["admin-private-groups"]})}),he=Dt({mutationFn:async({groupId:Ae,userId:Ue,isMember:ut})=>{if(ut){const{error:De}=await G.from("community_private_group_members").delete().eq("group_id",Ae).eq("user_id",Ue);if(De)throw De}else{const{error:De}=await G.from("community_private_group_members").insert({group_id:Ae,user_id:Ue});if(De)throw De}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",S==null?void 0:S.id]})}}),be=Dt({mutationFn:async({groupId:Ae,brokerageId:Ue,isMember:ut})=>{if(ut){const{error:De}=await G.from("community_private_group_members").delete().eq("group_id",Ae).eq("brokerage_id",Ue);if(De)throw De}else{const{error:De}=await G.from("community_private_group_members").insert({group_id:Ae,brokerage_id:Ue});if(De)throw De}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",S==null?void 0:S.id]})}}),_e=Ae=>{i(Ae),u({name:Ae.name,description:Ae.description||"",icon:Ae.icon||""}),o(!0)},je=()=>{i(null),u({name:"",description:"",icon:""}),o(!0)},Ne=Ae=>{_(Ae),w({name:Ae.name,description:Ae.description||"",icon:Ae.icon||""}),f(!0)},Ge=()=>{_(null),w({name:"",description:"",icon:""}),f(!0)},we=Ae=>{T(Ae),L(""),k(!0)},Me=Ae=>H.some(Ue=>Ue.user_id===Ae),Te=Ae=>H.some(Ue=>Ue.brokerage_id===Ae),Fe=Y.filter(Ae=>Ae.name.toLowerCase().includes(I.toLowerCase())||Ae.email.toLowerCase().includes(I.toLowerCase()));return e.jsx(Ts,{title:"Community Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(wu,{title:"Community Management",description:"Manage categories and private groups for community discussions"}),e.jsxs(ka,{value:r,onValueChange:n,children:[e.jsxs(_a,{children:[e.jsx(js,{value:"categories",children:"Public Categories"}),e.jsxs(js,{value:"private-groups",children:[e.jsx($u,{className:"h-4 w-4 mr-1"}),"Private Groups"]})]}),e.jsxs(zs,{value:"categories",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Categories visible to all community members"}),e.jsxs(K,{onClick:je,children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{className:"w-[50px]",children:"Order"}),e.jsx(bt,{className:"w-[80px]",children:"Icon"}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Pn,{children:$?e.jsx(Ns,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):R.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"})}):R.map((Ae,Ue)=>e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Ue===0,onClick:()=>de.mutate({id:Ae.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Ue===R.length-1,onClick:()=>de.mutate({id:Ae.id,direction:"down"}),children:"↓"})]})}),e.jsx(lt,{className:"text-2xl",children:Ae.icon||"📁"}),e.jsx(lt,{className:"font-medium",children:Ae.name}),e.jsx(lt,{className:"text-muted-foreground",children:Ae.description||"—"}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_e(Ae),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this category? Posts will be uncategorized.")&&Q.mutate(Ae.id)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},Ae.id))})]})})})]}),e.jsxs(zs,{value:"private-groups",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Private groups visible only to assigned members or brokerages"}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Ta,{className:"h-3 w-3"}),"Brokerage groups are created automatically and sync with brokerage names"]})]}),e.jsxs(K,{onClick:Ge,children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Private Group"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{className:"w-[50px]",children:"Order"}),e.jsx(bt,{className:"w-[80px]",children:"Icon"}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{className:"w-[120px]",children:"Members"}),e.jsx(bt,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(Pn,{children:U?e.jsx(Ns,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):q.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No private groups yet. Create your first one!"})}):q.map((Ae,Ue)=>e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Ue===0,onClick:()=>le.mutate({id:Ae.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Ue===q.length-1,onClick:()=>le.mutate({id:Ae.id,direction:"down"}),children:"↓"})]})}),e.jsx(lt,{className:"text-2xl",children:Ae.icon||"🔒"}),e.jsx(lt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Ae.name,Ae.brokerage_id?e.jsxs(rt,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(Ta,{className:"h-3 w-3 mr-1"}),"Auto-managed"]}):e.jsxs(rt,{variant:"secondary",className:"text-xs",children:[e.jsx($u,{className:"h-3 w-3 mr-1"}),"Private"]})]})}),e.jsx(lt,{className:"text-muted-foreground",children:Ae.description||"—"}),e.jsx(lt,{children:e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>we(Ae),children:[e.jsx(hr,{className:"h-4 w-4 mr-1"}),"Manage"]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1",children:[!Ae.brokerage_id&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ne(Ae),children:e.jsx(Da,{className:"h-4 w-4"})}),!Ae.brokerage_id&&e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this private group? All posts in this group will be deleted.")&&ae.mutate(Ae.id)},children:e.jsx(jr,{className:"h-4 w-4"})}),Ae.brokerage_id&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Managed via brokerage"})]})})]},Ae.id))})]})})})]})]}),e.jsx(_s,{open:a,onOpenChange:o,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:l?"Edit Category":"Create Category"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Icon (emoji)"}),e.jsx(Re,{value:d.icon,onChange:Ae=>u(Ue=>({...Ue,icon:Ae.target.value})),placeholder:"💬",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(Re,{value:d.name,onChange:Ae=>u(Ue=>({...Ue,name:Ae.target.value})),placeholder:"Category name",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Ar,{value:d.description,onChange:Ae=>u(Ue=>({...Ue,description:Ae.target.value})),placeholder:"Brief description of this category",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>te.mutate({...d,id:l==null?void 0:l.id}),disabled:!d.name.trim(),children:l?"Save Changes":"Create Category"})]})]})]})}),e.jsx(_s,{open:p,onOpenChange:f,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:y?"Edit Private Group":"Create Private Group"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Icon (emoji)"}),e.jsx(Re,{value:b.icon,onChange:Ae=>w(Ue=>({...Ue,icon:Ae.target.value})),placeholder:"🔒",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(Re,{value:b.name,onChange:Ae=>w(Ue=>({...Ue,name:Ae.target.value})),placeholder:"e.g., Pioneers",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Ar,{value:b.description,onChange:Ae=>w(Ue=>({...Ue,description:Ae.target.value})),placeholder:"Brief description of this private group",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>f(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>re.mutate({...b,id:y==null?void 0:y.id}),disabled:!b.name.trim(),children:y?"Save Changes":"Create Private Group"})]})]})]})}),e.jsx(_s,{open:j,onOpenChange:k,children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsx(Ss,{children:e.jsxs(ks,{children:["Manage Members: ",S==null?void 0:S.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ka,{defaultValue:"brokerages",children:[e.jsxs(_a,{className:"w-full",children:[e.jsx(js,{value:"brokerages",className:"flex-1",children:"By Brokerage"}),e.jsx(js,{value:"users",className:"flex-1",children:"Individual Users"})]}),e.jsxs(zs,{value:"brokerages",className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select brokerages to grant all their agents access to this private group."}),e.jsx(Ri,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[se.map(Ae=>e.jsxs("div",{className:"flex items-center justify-between p-2 hover:bg-muted rounded-md",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Bo,{checked:Te(Ae.id),onCheckedChange:()=>{S&&be.mutate({groupId:S.id,brokerageId:Ae.id,isMember:Te(Ae.id)})}}),e.jsx("span",{className:"font-medium",children:Ae.name})]}),e.jsxs(rt,{variant:"secondary",children:[Y.filter(Ue=>Ue.brokerage_id===Ae.id).length," agents"]})]},Ae.id)),se.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No brokerages found"})]})})]}),e.jsxs(zs,{value:"users",className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search users...",value:I,onChange:Ae=>L(Ae.target.value),className:"pl-9"})]}),e.jsx(Ri,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Fe.map(Ae=>e.jsx("div",{className:"flex items-center justify-between p-2 hover:bg-muted rounded-md",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Bo,{checked:Me(Ae.id),onCheckedChange:()=>{S&&he.mutate({groupId:S.id,userId:Ae.id,isMember:Me(Ae.id)})}}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ae.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:Ae.email})]})]})},Ae.id)),Fe.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No users found"})]})})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{onClick:()=>k(!1),children:"Done"})})]})]})})]})})},uEe=t=>{switch(t){case"academy_video":return e.jsx(ul,{className:"h-3 w-3"});case"template":return e.jsx(In,{className:"h-3 w-3"});case"toolbox":return e.jsx(dl,{className:"h-3 w-3"});case"newsletter":return e.jsx(z0,{className:"h-3 w-3"});case"social_swag":return e.jsx(hn,{className:"h-3 w-3"});default:return e.jsx(sn,{className:"h-3 w-3"})}},hzt=t=>{switch(t){case"academy_video":return"Academy";case"template":return"Template";case"toolbox":return"Toolbox";case"newsletter":return"Newsletter";case"social_swag":return"Social Swag";default:return t}},mzt=t=>{switch(t){case"view":return"Viewed";case"click_canva":return"Clicked Canva";case"click_pdf":return"Downloaded PDF";case"click_video":return"Watched Video";case"click_link":return"Clicked Link";case"click_drive":return"Clicked Drive";default:return t}},pzt=()=>{const{toast:t}=Pa(),[s,r]=C.useState([]),[n,a]=C.useState([]),[o,l]=C.useState([]),[i,d]=C.useState(!0),[u,p]=C.useState(""),[f,y]=C.useState(null),[_,b]=C.useState([]),[w,j]=C.useState([]);C.useEffect(()=>{k()},[]);const k=async()=>{try{d(!0);const{data:H,error:Y}=await G.from("activity_logs").select(` id, user_id, app_name, launched_at, profiles ( name, email, brokerages ( name ) ) `).order("launched_at",{ascending:!1}).limit(5e3);if(Y)throw Y;const{data:se,error:te}=await G.from("content_engagement_logs").select(` id, user_id, resource_type, resource_id, resource_title, action_type, created_at `).order("created_at",{ascending:!1}).limit(5e3);if(te)throw te;const Q=[...new Set((se==null?void 0:se.map(_e=>_e.user_id))||[])],{data:de}=await G.from("profiles").select(` id, name, email, brokerages ( name ) `).in("id",Q),re=new Map((de==null?void 0:de.map(_e=>[_e.id,_e]))||[]),ae=(H==null?void 0:H.map(_e=>{var je,Ne,Ge,we;return{id:_e.id,user_id:_e.user_id,app_name:_e.app_name,launched_at:_e.launched_at,user_name:((je=_e.profiles)==null?void 0:je.name)||"Unknown",user_email:((Ne=_e.profiles)==null?void 0:Ne.email)||"Unknown",brokerage_name:((we=(Ge=_e.profiles)==null?void 0:Ge.brokerages)==null?void 0:we.name)||null}}))||[],le=(se==null?void 0:se.map(_e=>{var Ne;const je=re.get(_e.user_id);return{id:_e.id,user_id:_e.user_id,resource_type:_e.resource_type,resource_id:_e.resource_id,resource_title:_e.resource_title,action_type:_e.action_type,created_at:_e.created_at,user_name:(je==null?void 0:je.name)||"Unknown",user_email:(je==null?void 0:je.email)||"Unknown",brokerage_name:((Ne=je==null?void 0:je.brokerages)==null?void 0:Ne.name)||null}}))||[];r(ae),a(le);const he=new Map;ae.forEach(_e=>{if(!he.has(_e.user_id))he.set(_e.user_id,{user_id:_e.user_id,user_name:_e.user_name,user_email:_e.user_email,brokerage_name:_e.brokerage_name,last_activity_type:"app",last_activity_name:_e.app_name,last_activity_at:_e.launched_at,total_app_launches:1,total_content_views:0});else{const je=he.get(_e.user_id);je.total_app_launches++,new Date(_e.launched_at)>new Date(je.last_activity_at)&&(je.last_activity_type="app",je.last_activity_name=_e.app_name,je.last_activity_at=_e.launched_at)}}),le.forEach(_e=>{if(!he.has(_e.user_id))he.set(_e.user_id,{user_id:_e.user_id,user_name:_e.user_name,user_email:_e.user_email,brokerage_name:_e.brokerage_name,last_activity_type:_e.resource_type,last_activity_name:_e.resource_title,last_activity_at:_e.created_at,total_app_launches:0,total_content_views:1});else{const je=he.get(_e.user_id);je.total_content_views++,new Date(_e.created_at)>new Date(je.last_activity_at)&&(je.last_activity_type=_e.resource_type,je.last_activity_name=_e.resource_title,je.last_activity_at=_e.created_at)}});const be=Array.from(he.values()).sort((_e,je)=>new Date(je.last_activity_at).getTime()-new Date(_e.last_activity_at).getTime());l(be)}catch(H){console.error("Error loading activity:",H),t({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{d(!1)}},S=H=>{y({id:H.user_id,name:H.user_name,email:H.user_email});const Y=s.filter(te=>te.user_id===H.user_id),se=n.filter(te=>te.user_id===H.user_id);b(Y),j(se)},T=()=>{y(null),b([]),j([])},{sortKey:I,sortDirection:L,handleSort:R,sortData:$}=JL("last_activity_at","desc"),q=o.filter(H=>{var se;if(!u)return!0;const Y=u.toLowerCase();return H.user_name.toLowerCase().includes(Y)||H.user_email.toLowerCase().includes(Y)||((se=H.brokerage_name)==null?void 0:se.toLowerCase().includes(Y))}),U=$(q,{user:H=>{var Y;return((Y=H.user_name)==null?void 0:Y.toLowerCase())||""},brokerage:H=>{var Y;return((Y=H.brokerage_name)==null?void 0:Y.toLowerCase())||""},last_activity_at:H=>new Date(H.last_activity_at).getTime(),apps:H=>H.total_app_launches,content:H=>H.total_content_views});return i?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"User Activity"}),e.jsx(pr,{children:"App launches and content engagement - click to see full history"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name, email, or brokerage...",value:u,onChange:H=>p(H.target.value),className:"pl-9"})]})}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(el,{sortKey:"user",currentSortKey:I,currentDirection:L,onSort:R,children:"User"}),e.jsx(el,{sortKey:"brokerage",currentSortKey:I,currentDirection:L,onSort:R,children:"Brokerage"}),e.jsx(bt,{children:"Last Activity"}),e.jsx(el,{sortKey:"last_activity_at",currentSortKey:I,currentDirection:L,onSort:R,children:"Last Active"}),e.jsx(el,{sortKey:"apps",currentSortKey:I,currentDirection:L,onSort:R,className:"text-right",children:"Apps"}),e.jsx(el,{sortKey:"content",currentSortKey:I,currentDirection:L,onSort:R,className:"text-right",children:"Content"})]})}),e.jsx(Pn,{children:U.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:6,className:"text-center text-muted-foreground",children:"No activity found"})}):U.map(H=>e.jsxs(Ns,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>S(H),children:[e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:H.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:H.user_email})]})}),e.jsx(lt,{children:H.brokerage_name?e.jsx(rt,{variant:"outline",children:H.brokerage_name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(lt,{children:e.jsx("div",{className:"flex items-center gap-2",children:H.last_activity_type==="app"?e.jsxs(rt,{variant:"secondary",children:[e.jsx(sn,{className:"h-3 w-3 mr-1"}),H.last_activity_name]}):e.jsxs(rt,{variant:"outline",className:"flex items-center gap-1",children:[uEe(H.last_activity_type),e.jsx("span",{className:"max-w-32 truncate",children:H.last_activity_name})]})})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:Sd(new Date(H.last_activity_at),{addSuffix:!0})}),e.jsx(lt,{className:"text-right",children:e.jsx(rt,{variant:"outline",children:H.total_app_launches})}),e.jsx(lt,{className:"text-right",children:e.jsx(rt,{variant:"outline",children:H.total_content_views})})]},H.user_id))})]})})]})]}),e.jsx(_s,{open:!!f,onOpenChange:H=>!H&&T(),children:e.jsxs(vs,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{children:[f==null?void 0:f.name,"'s Activity"]}),e.jsx(Kr,{children:f==null?void 0:f.email})]}),e.jsxs(ka,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(_a,{className:"grid w-full grid-cols-2",children:[e.jsxs(js,{value:"content",children:["Content (",w.length,")"]}),e.jsxs(js,{value:"apps",children:["App Launches (",_.length,")"]})]}),e.jsx(zs,{value:"content",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Type"}),e.jsx(bt,{children:"Resource"}),e.jsx(bt,{children:"Action"}),e.jsx(bt,{children:"Time"})]})}),e.jsx(Pn,{children:w.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement"})}):w.map(H=>e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsxs(rt,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[uEe(H.resource_type),hzt(H.resource_type)]})}),e.jsx(lt,{className:"max-w-48",children:e.jsx("span",{className:"truncate block",children:H.resource_title})}),e.jsx(lt,{children:e.jsx(rt,{variant:"secondary",children:mzt(H.action_type)})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:Sd(new Date(H.created_at),{addSuffix:!0})})]},H.id))})]})})}),e.jsx(zs,{value:"apps",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"App"}),e.jsx(bt,{children:"Time"})]})}),e.jsx(Pn,{children:_.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches"})}):_.map(H=>e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsx(rt,{variant:"secondary",children:H.app_name})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:Sd(new Date(H.launched_at),{addSuffix:!0})})]},H.id))})]})})})]})]})})]})},fzt=()=>{const{toast:t}=Pa(),[s,r]=C.useState({totalUsers:0,activeUsers:0,pendingUsers:0,totalBrokerages:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0,uniqueActiveThisWeek:0}),[n,a]=C.useState(!0);C.useEffect(()=>{o()},[]);const o=async()=>{try{a(!0);const{count:l}=await G.from("profiles").select("*",{count:"exact",head:!0}),{count:i}=await G.from("profiles").select("*",{count:"exact",head:!0}).not("last_login","is",null),d=(l||0)-(i||0),{count:u}=await G.from("brokerages").select("*",{count:"exact",head:!0}),{count:p}=await G.from("activity_logs").select("*",{count:"exact",head:!0}),f=new Date;f.setDate(f.getDate()-7);const{count:y}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",f.toISOString()),_=new Date;_.setMonth(_.getMonth()-1);const{count:b}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",_.toISOString()),{data:w}=await G.from("activity_logs").select("user_id").gte("launched_at",f.toISOString()),j=new Set(w==null?void 0:w.map(k=>k.user_id)).size;r({totalUsers:l||0,activeUsers:i||0,pendingUsers:d,totalBrokerages:u||0,totalLaunches:p||0,launchesThisWeek:y||0,launchesThisMonth:b||0,uniqueActiveThisWeek:j})}catch(l){console.error("Error loading analytics:",l),t({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{a(!1)}};return n?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Users"}),e.jsx(hr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalUsers}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.activeUsers," active, ",s.pendingUsers," pending"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Active Users"}),e.jsx(hi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.activeUsers}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.totalUsers>0?`${Math.round(s.activeUsers/s.totalUsers*100)}% of total`:"0% of total"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(Tn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.pendingUsers}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting setup"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Brokerages"}),e.jsx(Ta,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalBrokerages}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total brokerages"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(Pm,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalLaunches}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Launches This Week"}),e.jsx(Pm,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Launches This Month"}),e.jsx(Pm,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisMonth}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Active This Week"}),e.jsx(ac,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.uniqueActiveThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique users"})]})]})]})},hEe={event:"Event",template:"Template",academy_video:"Academy Video",resource_kit:"Resource Kit",newsletter:"Newsletter",social_swag:"Social Swag"},mEe={event:"bg-blue-100 text-blue-800",template:"bg-purple-100 text-purple-800",academy_video:"bg-green-100 text-green-800",resource_kit:"bg-orange-100 text-orange-800",newsletter:"bg-pink-100 text-pink-800",social_swag:"bg-yellow-100 text-yellow-800"};function pZe({brokerageOnly:t=!1,brokerageId:s}){const[r,n]=C.useState([]),[a,o]=C.useState(!0),[l,i]=C.useState(""),[d,u]=C.useState("all");C.useEffect(()=>{p()},[s]);const p=async()=>{o(!0);try{let R=[];if(t&&s){const{data:Q}=await G.from("profiles").select("id").eq("brokerage_id",s);if(R=(Q==null?void 0:Q.map(de=>de.id))||[],R.length===0){n([]),o(!1);return}}let $=G.from("resource_shares").select("*").order("created_at",{ascending:!1});t&&R.length>0&&($=$.or(`sender_id.in.(${R.join(",")}),recipient_id.in.(${R.join(",")})`));const{data:q,error:U}=await $;if(U)throw U;const H=new Set;q==null||q.forEach(Q=>{H.add(Q.sender_id),H.add(Q.recipient_id)});const{data:Y}=await G.from("profiles").select("id, name, email").in("id",Array.from(H)),se=new Map((Y==null?void 0:Y.map(Q=>[Q.id,Q]))||[]),te=(q==null?void 0:q.map(Q=>({...Q,sender:se.get(Q.sender_id),recipient:se.get(Q.recipient_id)})))||[];n(te)}catch(R){console.error("Error loading shares:",R)}finally{o(!1)}},{sortKey:f,sortDirection:y,handleSort:_,sortData:b}=JL("created_at","desc"),w=r.filter(R=>{var U,H;const $=l===""||R.resource_title.toLowerCase().includes(l.toLowerCase())||((U=R.sender)==null?void 0:U.name.toLowerCase().includes(l.toLowerCase()))||((H=R.recipient)==null?void 0:H.name.toLowerCase().includes(l.toLowerCase())),q=d==="all"||R.resource_type===d;return $&&q}),j=b(w,{resource:R=>{var $;return(($=R.resource_title)==null?void 0:$.toLowerCase())||""},type:R=>R.resource_type,sender:R=>{var $,q;return((q=($=R.sender)==null?void 0:$.name)==null?void 0:q.toLowerCase())||""},recipient:R=>{var $,q;return((q=($=R.recipient)==null?void 0:$.name)==null?void 0:q.toLowerCase())||""},status:R=>R.is_read?1:0,created_at:R=>new Date(R.created_at).getTime()}),k=r.length,S=new Set(r.map(R=>R.sender_id)).size,T=new Set(r.map(R=>R.recipient_id)).size,I=r.length>0?Math.round(r.filter(R=>R.is_read).length/r.length*100):0,L=r.reduce((R,$)=>(R[$.resource_type]=(R[$.resource_type]||0)+1,R),{});return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[...Array(4)].map((R,$)=>e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(xs,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(xs,{className:"h-8 w-16"})})]},$))}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6",children:e.jsx(xs,{className:"h-[300px]"})})})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Shares"}),e.jsx(ld,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:k})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Active Sharers"}),e.jsx(hr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:S})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Recipients Reached"}),e.jsx(ac,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:T})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Read Rate"}),e.jsx(In,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"text-2xl font-bold",children:[I,"%"]})})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-sm font-medium",children:"Shares by Resource Type"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Object.entries(L).map(([R,$])=>e.jsxs(rt,{variant:"secondary",className:mEe[R],children:[hEe[R],": ",$]},R)),Object.keys(L).length===0&&e.jsx("span",{className:"text-muted-foreground text-sm",children:"No shares yet"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Share History"}),e.jsxs(pr,{children:["All resource shares ",t?"in your brokerage":"across the platform"]})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by resource, sender, or recipient...",value:l,onChange:R=>i(R.target.value),className:"pl-9"})]}),e.jsxs(sr,{value:d,onValueChange:u,children:[e.jsx(er,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"Resource type"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Types"}),e.jsx(At,{value:"event",children:"Events"}),e.jsx(At,{value:"template",children:"Templates"}),e.jsx(At,{value:"academy_video",children:"Academy Videos"}),e.jsx(At,{value:"resource_kit",children:"Resource Kits"}),e.jsx(At,{value:"newsletter",children:"Newsletters"}),e.jsx(At,{value:"social_swag",children:"Social Swag"})]})]})]}),e.jsx(Ri,{className:"h-[400px]",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(el,{sortKey:"resource",currentSortKey:f,currentDirection:y,onSort:_,children:"Resource"}),e.jsx(el,{sortKey:"type",currentSortKey:f,currentDirection:y,onSort:_,children:"Type"}),e.jsx(el,{sortKey:"sender",currentSortKey:f,currentDirection:y,onSort:_,children:"Sender"}),e.jsx(el,{sortKey:"recipient",currentSortKey:f,currentDirection:y,onSort:_,children:"Recipient"}),e.jsx(el,{sortKey:"status",currentSortKey:f,currentDirection:y,onSort:_,children:"Status"}),e.jsx(el,{sortKey:"created_at",currentSortKey:f,currentDirection:y,onSort:_,children:"Date"})]})}),e.jsx(Pn,{children:j.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No shares found"})}):j.map(R=>{var $,q;return e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium max-w-[200px] truncate",children:R.resource_title}),e.jsx(lt,{children:e.jsx(rt,{variant:"secondary",className:mEe[R.resource_type],children:hEe[R.resource_type]})}),e.jsx(lt,{children:(($=R.sender)==null?void 0:$.name)||"Unknown"}),e.jsx(lt,{children:((q=R.recipient)==null?void 0:q.name)||"Unknown"}),e.jsx(lt,{children:e.jsx(rt,{variant:R.is_read?"default":"outline",children:R.is_read?"Read":"Unread"})}),e.jsx(lt,{className:"text-muted-foreground",children:ys(new Date(R.created_at),"MMM d, yyyy")})]},R.id)})})]})})]})]})]})}const ape={academy_video:{label:"Academy Videos",icon:Nn,color:"bg-purple-100 text-purple-800",actionLabel:"Watched",actionIcon:xa},template:{label:"Templates",icon:p0,color:"bg-blue-100 text-blue-800",actionLabel:"Accessed",actionIcon:th},toolbox:{label:"Toolkit",icon:Wg,color:"bg-amber-100 text-amber-800",actionLabel:"Downloaded",actionIcon:xi},newsletter:{label:"Newsletters",icon:br,color:"bg-emerald-100 text-emerald-800",actionLabel:"Clicked",actionIcon:th},social_swag:{label:"Social Swag",icon:Bl,color:"bg-pink-100 text-pink-800",actionLabel:"Accessed",actionIcon:th},event:{label:"Events",icon:on,color:"bg-cyan-100 text-cyan-800",actionLabel:"Registered",actionIcon:th}};function pEe(t){return t.resource_type==="toolbox"?t.total_downloads:t.total_clicks}function gzt(t,s){return t==="toolbox"?s.downloads:s.clicks}function xzt(){var R;const[t,s]=C.useState([]),[r,n]=C.useState(!0),[a,o]=C.useState(null),l=C.useRef(null),{sortKey:i,sortDirection:d,handleSort:u,sortData:p}=JL("total_views","desc");C.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:$,error:q}=await G.rpc("get_admin_content_engagement");if(q)throw q;s($||[])}catch($){console.error("Error loading content engagement:",$)}finally{n(!1)}},y=$=>{o(q=>{const U=q===$?null:$;return requestAnimationFrame(()=>{var H;(H=l.current)==null||H.scrollIntoView({behavior:"smooth",block:"start"})}),U})};if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-4",children:[...Array(4)].map(($,q)=>e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(xs,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(xs,{className:"h-8 w-16"})})]},q))}),e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8",children:e.jsx(xs,{className:"h-64 w-full"})})})]});const _=t.reduce(($,q)=>$+q.total_views,0),b=t.reduce(($,q)=>$+q.total_clicks,0),w=t.reduce(($,q)=>$+q.total_downloads,0),j=t.length,k=t.reduce(($,q)=>($[q.resource_type]||($[q.resource_type]={views:0,clicks:0,downloads:0,assets:0,uniqueUsers:0}),$[q.resource_type].views+=q.total_views,$[q.resource_type].clicks+=q.total_clicks,$[q.resource_type].downloads+=q.total_downloads,$[q.resource_type].assets+=1,$[q.resource_type].uniqueUsers+=q.unique_users,$),{}),S=a?t.filter($=>$.resource_type===a):t,T=p(S,{asset:$=>{var q;return((q=$.resource_title)==null?void 0:q.toLowerCase())||""},type:$=>$.resource_type,views:$=>$.total_views,actions:$=>pEe($),unique_users:$=>$.unique_users,last_activity:$=>$.last_engaged_at?new Date($.last_engaged_at).getTime():0}),I=a?ape[a]||{label:a,icon:xa,actionLabel:"Actions"}:null,L=I==null?void 0:I.icon;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-5",children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Views"}),e.jsx(xa,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:_.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Across all content"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Clicks"}),e.jsx(th,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:b.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link & Canva clicks"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Downloads"}),e.jsx(xi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:w.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PDF downloads"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Assets Tracked"}),e.jsx(ac,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique content items"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(th,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[_>0?Math.round((b+w)/_*100):0,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Of views → actions"})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Engagement by Content Type"}),e.jsx(pr,{children:"Click a category to see individual asset performance"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-3",children:Object.entries(k).map(([$,q])=>{const U=ape[$]||{label:$,icon:xa,color:"bg-muted text-muted-foreground",actionIcon:th},H=U.icon,Y=a===$;return e.jsxs("button",{type:"button",onClick:()=>y($),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors cursor-pointer ${Y?"ring-2 ring-primary border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsx("div",{className:`p-2 rounded-md ${U.color}`,children:e.jsx(H,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:U.label}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xa,{className:"h-3 w-3"})," ",q.views]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(U.actionIcon,{className:"h-3 w-3"})," ",gzt($,q)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hr,{className:"h-3 w-3"})," ",q.uniqueUsers]})]})]}),e.jsxs(rt,{variant:"secondary",className:"text-[10px]",children:[q.assets," items"]})]},$)})})})]}),e.jsx("div",{ref:l,children:e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{className:"text-sm font-medium flex items-center gap-2",children:I&&L?e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"h-4 w-4"}),I.label," — Top Performers"]}):"Top Content by Engagement"}),e.jsx(pr,{children:a?`${S.length} ${((R=I==null?void 0:I.label)==null?void 0:R.toLowerCase())||"items"} ranked by total interactions`:"All tracked assets ranked by total interactions"})]}),a&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>o(null),className:"gap-1",children:[e.jsx(ti,{className:"h-3.5 w-3.5"}),"Show All"]})]})}),e.jsx(Oe,{children:S.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No engagement data yet. As users view and click content, stats will appear here."}):e.jsx(Ri,{className:"h-[400px]",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{className:"w-[40px]",children:"#"}),e.jsx(el,{sortKey:"asset",currentSortKey:i,currentDirection:d,onSort:u,children:"Asset"}),!a&&e.jsx(el,{sortKey:"type",currentSortKey:i,currentDirection:d,onSort:u,children:"Type"}),e.jsx(el,{sortKey:"views",currentSortKey:i,currentDirection:d,onSort:u,className:"text-right",children:"Views"}),e.jsx(el,{sortKey:"actions",currentSortKey:i,currentDirection:d,onSort:u,className:"text-right",children:I?I.actionLabel:"Actions"}),e.jsx(el,{sortKey:"unique_users",currentSortKey:i,currentDirection:d,onSort:u,className:"text-right",children:"Unique Users"}),e.jsx(el,{sortKey:"last_activity",currentSortKey:i,currentDirection:d,onSort:u,children:"Last Activity"})]})}),e.jsx(Pn,{children:T.map(($,q)=>{const U=ape[$.resource_type]||{label:$.resource_type,color:"bg-muted text-muted-foreground"};return e.jsxs(Ns,{children:[e.jsx(lt,{className:"text-muted-foreground text-xs",children:q+1}),e.jsx(lt,{children:e.jsx("p",{className:"font-medium text-sm truncate max-w-[250px]",children:$.resource_title})}),!a&&e.jsx(lt,{children:e.jsx(rt,{className:`text-[10px] ${U.color}`,children:U.label})}),e.jsx(lt,{className:"text-right font-medium",children:$.total_views}),e.jsx(lt,{className:"text-right font-medium",children:pEe($)}),e.jsx(lt,{className:"text-right",children:$.unique_users}),e.jsx(lt,{className:"text-xs text-muted-foreground",children:$.last_engaged_at?Sd(new Date($.last_engaged_at),{addSuffix:!0}):"—"})]},`${$.resource_type}-${$.resource_id}`)})})]})})})]})})]})}var yzt=Array.isArray,Um=yzt,vzt=typeof b0=="object"&&b0&&b0.Object===Object&&b0,fZe=vzt,_zt=fZe,bzt=typeof self=="object"&&self&&self.Object===Object&&self,wzt=_zt||bzt||Function("return this")(),by=wzt,jzt=by,Nzt=jzt.Symbol,nD=Nzt,fEe=nD,gZe=Object.prototype,kzt=gZe.hasOwnProperty,Szt=gZe.toString,fE=fEe?fEe.toStringTag:void 0;function Czt(t){var s=kzt.call(t,fE),r=t[fE];try{t[fE]=void 0;var n=!0}catch{}var a=Szt.call(t);return n&&(s?t[fE]=r:delete t[fE]),a}var Mzt=Czt,Tzt=Object.prototype,Azt=Tzt.toString;function Ezt(t){return Azt.call(t)}var Pzt=Ezt,gEe=nD,Izt=Mzt,Lzt=Pzt,Dzt="[object Null]",Ozt="[object Undefined]",xEe=gEe?gEe.toStringTag:void 0;function Rzt(t){return t==null?t===void 0?Ozt:Dzt:xEe&&xEe in Object(t)?Izt(t):Lzt(t)}var uv=Rzt;function Fzt(t){return t!=null&&typeof t=="object"}var hv=Fzt,zzt=uv,Bzt=hv,$zt="[object Symbol]";function qzt(t){return typeof t=="symbol"||Bzt(t)&&zzt(t)==$zt}var BM=qzt,Uzt=Um,Vzt=BM,Hzt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Wzt=/^\w*$/;function Gzt(t,s){if(Uzt(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||Vzt(t)?!0:Wzt.test(t)||!Hzt.test(t)||s!=null&&t in Object(s)}var Ewe=Gzt;function Kzt(t){var s=typeof t;return t!=null&&(s=="object"||s=="function")}var rb=Kzt;const $M=_o(rb);var Zzt=uv,Yzt=rb,Xzt="[object AsyncFunction]",Qzt="[object Function]",Jzt="[object GeneratorFunction]",e7t="[object Proxy]";function t7t(t){if(!Yzt(t))return!1;var s=Zzt(t);return s==Qzt||s==Jzt||s==Xzt||s==e7t}var Pwe=t7t;const gi=_o(Pwe);var s7t=by,r7t=s7t["__core-js_shared__"],n7t=r7t,ipe=n7t,yEe=function(){var t=/[^.]+$/.exec(ipe&&ipe.keys&&ipe.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function a7t(t){return!!yEe&&yEe in t}var i7t=a7t,o7t=Function.prototype,l7t=o7t.toString;function c7t(t){if(t!=null){try{return l7t.call(t)}catch{}try{return t+""}catch{}}return""}var xZe=c7t,d7t=Pwe,u7t=i7t,h7t=rb,m7t=xZe,p7t=/[\\^$.*+?()[\]{}|]/g,f7t=/^\[object .+?Constructor\]$/,g7t=Function.prototype,x7t=Object.prototype,y7t=g7t.toString,v7t=x7t.hasOwnProperty,_7t=RegExp("^"+y7t.call(v7t).replace(p7t,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function b7t(t){if(!h7t(t)||u7t(t))return!1;var s=d7t(t)?_7t:f7t;return s.test(m7t(t))}var w7t=b7t;function j7t(t,s){return t==null?void 0:t[s]}var N7t=j7t,k7t=w7t,S7t=N7t;function C7t(t,s){var r=S7t(t,s);return k7t(r)?r:void 0}var hS=C7t,M7t=hS,T7t=M7t(Object,"create"),Ule=T7t,vEe=Ule;function A7t(){this.__data__=vEe?vEe(null):{},this.size=0}var E7t=A7t;function P7t(t){var s=this.has(t)&&delete this.__data__[t];return this.size-=s?1:0,s}var I7t=P7t,L7t=Ule,D7t="__lodash_hash_undefined__",O7t=Object.prototype,R7t=O7t.hasOwnProperty;function F7t(t){var s=this.__data__;if(L7t){var r=s[t];return r===D7t?void 0:r}return R7t.call(s,t)?s[t]:void 0}var z7t=F7t,B7t=Ule,$7t=Object.prototype,q7t=$7t.hasOwnProperty;function U7t(t){var s=this.__data__;return B7t?s[t]!==void 0:q7t.call(s,t)}var V7t=U7t,H7t=Ule,W7t="__lodash_hash_undefined__";function G7t(t,s){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=H7t&&s===void 0?W7t:s,this}var K7t=G7t,Z7t=E7t,Y7t=I7t,X7t=z7t,Q7t=V7t,J7t=K7t;function qM(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s-1}var gBt=fBt,xBt=Vle;function yBt(t,s){var r=this.__data__,n=xBt(r,t);return n<0?(++this.size,r.push([t,s])):r[n][1]=s,this}var vBt=yBt,_Bt=sBt,bBt=dBt,wBt=mBt,jBt=gBt,NBt=vBt;function UM(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s0?1:-1},qN=function(s){return Gk(s)&&s.indexOf("%")===s.length-1},tn=function(s){return V9t(s)&&!aD(s)},K9t=function(s){return Ai(s)},Ud=function(s){return tn(s)||Gk(s)},Z9t=0,HM=function(s){var r=++Z9t;return"".concat(s||"").concat(r)},Bh=function(s,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!tn(s)&&!Gk(s))return n;var o;if(qN(s)){var l=s.indexOf("%");o=r*parseFloat(s.slice(0,l))/100}else o=+s;return aD(o)&&(o=n),a&&o>r&&(o=r),o},M1=function(s){if(!s)return null;var r=Object.keys(s);return r&&r.length?s[r[0]]:null},Y9t=function(s){if(!Array.isArray(s))return!1;for(var r=s.length,n={},a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function r$t(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function jye(t){"@babel/helpers - typeof";return jye=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},jye(t)}var SEe={click:"onClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",touchcancel:"onTouchCancel",touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart",contextmenu:"onContextMenu",dblclick:"onDoubleClick"},W0=function(s){return typeof s=="string"?s:s?s.displayName||s.name||"Component":""},CEe=null,lpe=null,qwe=function t(s){if(s===CEe&&Array.isArray(lpe))return lpe;var r=[];return C.Children.forEach(s,function(n){Ai(n)||(z9t.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),lpe=r,CEe=s,r};function kp(t,s){var r=[],n=[];return Array.isArray(s)?n=s.map(function(a){return W0(a)}):n=[W0(s)],qwe(t).forEach(function(a){var o=Np(a,"type.displayName")||Np(a,"type.name");n.indexOf(o)!==-1&&r.push(a)}),r}function ip(t,s){var r=kp(t,s);return r&&r[0]}var MEe=function(s){if(!s||!s.props)return!1;var r=s.props,n=r.width,a=r.height;return!(!tn(n)||n<=0||!tn(a)||a<=0)},n$t=["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColormatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-url","foreignObject","g","glyph","glyphRef","hkern","image","line","lineGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],a$t=function(s){return s&&s.type&&Gk(s.type)&&n$t.indexOf(s.type)>=0},i$t=function(s){return s&&jye(s)==="object"&&"clipDot"in s},o$t=function(s,r,n,a){var o,l=(o=ope==null?void 0:ope[a])!==null&&o!==void 0?o:[];return r.startsWith("data-")||!gi(s)&&(a&&l.includes(r)||J9t.includes(r))||n&&$we.includes(r)},Ga=function(s,r,n){if(!s||typeof s=="function"||typeof s=="boolean")return null;var a=s;if(C.isValidElement(s)&&(a=s.props),!$M(a))return null;var o={};return Object.keys(a).forEach(function(l){var i;o$t((i=a)===null||i===void 0?void 0:i[l],l,r,n)&&(o[l]=a[l])}),o},Nye=function t(s,r){if(s===r)return!0;var n=C.Children.count(s);if(n!==C.Children.count(r))return!1;if(n===0)return!0;if(n===1)return TEe(Array.isArray(s)?s[0]:s,Array.isArray(r)?r[0]:r);for(var a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function h$t(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Sye(t){var s=t.children,r=t.width,n=t.height,a=t.viewBox,o=t.className,l=t.style,i=t.title,d=t.desc,u=u$t(t,d$t),p=a||{width:r,height:n,x:0,y:0},f=Ii("recharts-surface",o);return ht.createElement("svg",kye({},Ga(u,!0,"svg"),{className:f,width:r,height:n,style:l,viewBox:"".concat(p.x," ").concat(p.y," ").concat(p.width," ").concat(p.height)}),ht.createElement("title",null,i),ht.createElement("desc",null,d),s)}var m$t=["children","className"];function Cye(){return Cye=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function f$t(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var Lo=ht.forwardRef(function(t,s){var r=t.children,n=t.className,a=p$t(t,m$t),o=Ii("recharts-layer",n);return ht.createElement("g",Cye({className:o},Ga(a,!0),{ref:s}),r)}),Kg=function(s,r){for(var n=arguments.length,a=new Array(n>2?n-2:0),o=2;oa?0:a+s),r=r>a?a:r,r<0&&(r+=a),a=s>r?0:r-s>>>0,s>>>=0;for(var o=Array(a);++n=n?t:y$t(t,s,r)}var _$t=v$t,b$t="\\ud800-\\udfff",w$t="\\u0300-\\u036f",j$t="\\ufe20-\\ufe2f",N$t="\\u20d0-\\u20ff",k$t=w$t+j$t+N$t,S$t="\\ufe0e\\ufe0f",C$t="\\u200d",M$t=RegExp("["+C$t+b$t+k$t+S$t+"]");function T$t(t){return M$t.test(t)}var CZe=T$t;function A$t(t){return t.split("")}var E$t=A$t,MZe="\\ud800-\\udfff",P$t="\\u0300-\\u036f",I$t="\\ufe20-\\ufe2f",L$t="\\u20d0-\\u20ff",D$t=P$t+I$t+L$t,O$t="\\ufe0e\\ufe0f",R$t="["+MZe+"]",Mye="["+D$t+"]",Tye="\\ud83c[\\udffb-\\udfff]",F$t="(?:"+Mye+"|"+Tye+")",TZe="[^"+MZe+"]",AZe="(?:\\ud83c[\\udde6-\\uddff]){2}",EZe="[\\ud800-\\udbff][\\udc00-\\udfff]",z$t="\\u200d",PZe=F$t+"?",IZe="["+O$t+"]?",B$t="(?:"+z$t+"(?:"+[TZe,AZe,EZe].join("|")+")"+IZe+PZe+")*",$$t=IZe+PZe+B$t,q$t="(?:"+[TZe+Mye+"?",Mye,AZe,EZe,R$t].join("|")+")",U$t=RegExp(Tye+"(?="+Tye+")|"+q$t+$$t,"g");function V$t(t){return t.match(U$t)||[]}var H$t=V$t,W$t=E$t,G$t=CZe,K$t=H$t;function Z$t(t){return G$t(t)?K$t(t):W$t(t)}var Y$t=Z$t,X$t=_$t,Q$t=CZe,J$t=Y$t,eqt=bZe;function tqt(t){return function(s){s=eqt(s);var r=Q$t(s)?J$t(s):void 0,n=r?r[0]:s.charAt(0),a=r?X$t(r,1).join(""):s.slice(1);return n[t]()+a}}var sqt=tqt,rqt=sqt,nqt=rqt("toUpperCase"),aqt=nqt;const nce=_o(aqt);function Ml(t){return function(){return t}}const LZe=Math.cos,Gae=Math.sin,nx=Math.sqrt,Kae=Math.PI,ace=2*Kae,Aye=Math.PI,Eye=2*Aye,bN=1e-6,iqt=Eye-bN;function DZe(t){this._+=t[0];for(let s=1,r=t.length;s=0))throw new Error(`invalid digits: ${t}`);if(s>15)return DZe;const r=10**s;return function(n){this._+=n[0];for(let a=1,o=n.length;abN)if(!(Math.abs(f*d-u*p)>bN)||!o)this._append`L${this._x1=s},${this._y1=r}`;else{let _=n-l,b=a-i,w=d*d+u*u,j=_*_+b*b,k=Math.sqrt(w),S=Math.sqrt(y),T=o*Math.tan((Aye-Math.acos((w+y-j)/(2*k*S)))/2),I=T/S,L=T/k;Math.abs(I-1)>bN&&this._append`L${s+I*p},${r+I*f}`,this._append`A${o},${o},0,0,${+(f*_>p*b)},${this._x1=s+L*d},${this._y1=r+L*u}`}}arc(s,r,n,a,o,l){if(s=+s,r=+r,n=+n,l=!!l,n<0)throw new Error(`negative radius: ${n}`);let i=n*Math.cos(a),d=n*Math.sin(a),u=s+i,p=r+d,f=1^l,y=l?a-o:o-a;this._x1===null?this._append`M${u},${p}`:(Math.abs(this._x1-u)>bN||Math.abs(this._y1-p)>bN)&&this._append`L${u},${p}`,n&&(y<0&&(y=y%Eye+Eye),y>iqt?this._append`A${n},${n},0,1,${f},${s-i},${r-d}A${n},${n},0,1,${f},${this._x1=u},${this._y1=p}`:y>bN&&this._append`A${n},${n},0,${+(y>=Aye)},${f},${this._x1=s+n*Math.cos(o)},${this._y1=r+n*Math.sin(o)}`)}rect(s,r,n,a){this._append`M${this._x0=this._x1=+s},${this._y0=this._y1=+r}h${n=+n}v${+a}h${-n}Z`}toString(){return this._}}function Uwe(t){let s=3;return t.digits=function(r){if(!arguments.length)return s;if(r==null)s=null;else{const n=Math.floor(r);if(!(n>=0))throw new RangeError(`invalid digits: ${r}`);s=n}return t},()=>new lqt(s)}function Vwe(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function OZe(t){this._context=t}OZe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,s){switch(t=+t,s=+s,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,s):this._context.moveTo(t,s);break;case 1:this._point=2;default:this._context.lineTo(t,s);break}}};function ice(t){return new OZe(t)}function RZe(t){return t[0]}function FZe(t){return t[1]}function zZe(t,s){var r=Ml(!0),n=null,a=ice,o=null,l=Uwe(i);t=typeof t=="function"?t:t===void 0?RZe:Ml(t),s=typeof s=="function"?s:s===void 0?FZe:Ml(s);function i(d){var u,p=(d=Vwe(d)).length,f,y=!1,_;for(n==null&&(o=a(_=l())),u=0;u<=p;++u)!(u=_;--b)i.point(T[b],I[b]);i.lineEnd(),i.areaEnd()}k&&(T[y]=+t(j,y,f),I[y]=+s(j,y,f),i.point(n?+n(j,y,f):T[y],r?+r(j,y,f):I[y]))}if(S)return i=null,S+""||null}function p(){return zZe().defined(a).curve(l).context(o)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Ml(+f),n=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Ml(+f),u):t},u.x1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Ml(+f),u):n},u.y=function(f){return arguments.length?(s=typeof f=="function"?f:Ml(+f),r=null,u):s},u.y0=function(f){return arguments.length?(s=typeof f=="function"?f:Ml(+f),u):s},u.y1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Ml(+f),u):r},u.lineX0=u.lineY0=function(){return p().x(t).y(s)},u.lineY1=function(){return p().x(t).y(r)},u.lineX1=function(){return p().x(n).y(s)},u.defined=function(f){return arguments.length?(a=typeof f=="function"?f:Ml(!!f),u):a},u.curve=function(f){return arguments.length?(l=f,o!=null&&(i=l(o)),u):l},u.context=function(f){return arguments.length?(f==null?o=i=null:i=l(o=f),u):o},u}class BZe{constructor(s,r){this._context=s,this._x=r}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(s,r){switch(s=+s,r=+r,this._point){case 0:{this._point=1,this._line?this._context.lineTo(s,r):this._context.moveTo(s,r);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+s)/2,this._y0,this._x0,r,s,r):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+r)/2,s,this._y0,s,r);break}}this._x0=s,this._y0=r}}function cqt(t){return new BZe(t,!0)}function dqt(t){return new BZe(t,!1)}const Hwe={draw(t,s){const r=nx(s/Kae);t.moveTo(r,0),t.arc(0,0,r,0,ace)}},uqt={draw(t,s){const r=nx(s/5)/2;t.moveTo(-3*r,-r),t.lineTo(-r,-r),t.lineTo(-r,-3*r),t.lineTo(r,-3*r),t.lineTo(r,-r),t.lineTo(3*r,-r),t.lineTo(3*r,r),t.lineTo(r,r),t.lineTo(r,3*r),t.lineTo(-r,3*r),t.lineTo(-r,r),t.lineTo(-3*r,r),t.closePath()}},$Ze=nx(1/3),hqt=$Ze*2,mqt={draw(t,s){const r=nx(s/hqt),n=r*$Ze;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},pqt={draw(t,s){const r=nx(s),n=-r/2;t.rect(n,n,r,r)}},fqt=.8908130915292852,qZe=Gae(Kae/10)/Gae(7*Kae/10),gqt=Gae(ace/10)*qZe,xqt=-LZe(ace/10)*qZe,yqt={draw(t,s){const r=nx(s*fqt),n=gqt*r,a=xqt*r;t.moveTo(0,-r),t.lineTo(n,a);for(let o=1;o<5;++o){const l=ace*o/5,i=LZe(l),d=Gae(l);t.lineTo(d*r,-i*r),t.lineTo(i*n-d*a,d*n+i*a)}t.closePath()}},cpe=nx(3),vqt={draw(t,s){const r=-nx(s/(cpe*3));t.moveTo(0,r*2),t.lineTo(-cpe*r,-r),t.lineTo(cpe*r,-r),t.closePath()}},Wp=-.5,Gp=nx(3)/2,Pye=1/nx(12),_qt=(Pye/2+1)*3,bqt={draw(t,s){const r=nx(s/_qt),n=r/2,a=r*Pye,o=n,l=r*Pye+r,i=-o,d=l;t.moveTo(n,a),t.lineTo(o,l),t.lineTo(i,d),t.lineTo(Wp*n-Gp*a,Gp*n+Wp*a),t.lineTo(Wp*o-Gp*l,Gp*o+Wp*l),t.lineTo(Wp*i-Gp*d,Gp*i+Wp*d),t.lineTo(Wp*n+Gp*a,Wp*a-Gp*n),t.lineTo(Wp*o+Gp*l,Wp*l-Gp*o),t.lineTo(Wp*i+Gp*d,Wp*d-Gp*i),t.closePath()}};function wqt(t,s){let r=null,n=Uwe(a);t=typeof t=="function"?t:Ml(t||Hwe),s=typeof s=="function"?s:Ml(s===void 0?64:+s);function a(){let o;if(r||(r=o=n()),t.apply(this,arguments).draw(r,+s.apply(this,arguments)),o)return r=null,o+""||null}return a.type=function(o){return arguments.length?(t=typeof o=="function"?o:Ml(o),a):t},a.size=function(o){return arguments.length?(s=typeof o=="function"?o:Ml(+o),a):s},a.context=function(o){return arguments.length?(r=o??null,a):r},a}function Zae(){}function Yae(t,s,r){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+s)/6,(t._y0+4*t._y1+r)/6)}function UZe(t){this._context=t}UZe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Yae(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,s){switch(t=+t,s=+s,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,s):this._context.moveTo(t,s);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Yae(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function jqt(t){return new UZe(t)}function VZe(t){this._context=t}VZe.prototype={areaStart:Zae,areaEnd:Zae,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(t,s){switch(t=+t,s=+s,this._point){case 0:this._point=1,this._x2=t,this._y2=s;break;case 1:this._point=2,this._x3=t,this._y3=s;break;case 2:this._point=3,this._x4=t,this._y4=s,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+s)/6);break;default:Yae(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function Nqt(t){return new VZe(t)}function HZe(t){this._context=t}HZe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(t,s){switch(t=+t,s=+s,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var r=(this._x0+4*this._x1+t)/6,n=(this._y0+4*this._y1+s)/6;this._line?this._context.lineTo(r,n):this._context.moveTo(r,n);break;case 3:this._point=4;default:Yae(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function kqt(t){return new HZe(t)}function WZe(t){this._context=t}WZe.prototype={areaStart:Zae,areaEnd:Zae,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(t,s){t=+t,s=+s,this._point?this._context.lineTo(t,s):(this._point=1,this._context.moveTo(t,s))}};function Sqt(t){return new WZe(t)}function EEe(t){return t<0?-1:1}function PEe(t,s,r){var n=t._x1-t._x0,a=s-t._x1,o=(t._y1-t._y0)/(n||a<0&&-0),l=(r-t._y1)/(a||n<0&&-0),i=(o*a+l*n)/(n+a);return(EEe(o)+EEe(l))*Math.min(Math.abs(o),Math.abs(l),.5*Math.abs(i))||0}function IEe(t,s){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-s)/2:s}function dpe(t,s,r){var n=t._x0,a=t._y0,o=t._x1,l=t._y1,i=(o-n)/3;t._context.bezierCurveTo(n+i,a+i*s,o-i,l-i*r,o,l)}function Xae(t){this._context=t}Xae.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:dpe(this,this._t0,IEe(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,s){var r=NaN;if(t=+t,s=+s,!(t===this._x1&&s===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,s):this._context.moveTo(t,s);break;case 1:this._point=2;break;case 2:this._point=3,dpe(this,IEe(this,r=PEe(this,t,s)),r);break;default:dpe(this,this._t0,r=PEe(this,t,s));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s,this._t0=r}}};function GZe(t){this._context=new KZe(t)}(GZe.prototype=Object.create(Xae.prototype)).point=function(t,s){Xae.prototype.point.call(this,s,t)};function KZe(t){this._context=t}KZe.prototype={moveTo:function(t,s){this._context.moveTo(s,t)},closePath:function(){this._context.closePath()},lineTo:function(t,s){this._context.lineTo(s,t)},bezierCurveTo:function(t,s,r,n,a,o){this._context.bezierCurveTo(s,t,n,r,o,a)}};function Cqt(t){return new Xae(t)}function Mqt(t){return new GZe(t)}function ZZe(t){this._context=t}ZZe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,s=this._y,r=t.length;if(r)if(this._line?this._context.lineTo(t[0],s[0]):this._context.moveTo(t[0],s[0]),r===2)this._context.lineTo(t[1],s[1]);else for(var n=LEe(t),a=LEe(s),o=0,l=1;l=0;--s)a[s]=(l[s]-a[s+1])/o[s];for(o[r-1]=(t[r]+a[r-1])/2,s=0;s=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,s){switch(t=+t,s=+s,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,s):this._context.moveTo(t,s);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,s),this._context.lineTo(t,s);else{var r=this._x*(1-this._t)+t*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,s)}break}}this._x=t,this._y=s}};function Aqt(t){return new oce(t,.5)}function Eqt(t){return new oce(t,0)}function Pqt(t){return new oce(t,1)}function O3(t,s){if((l=t.length)>1)for(var r=1,n,a,o=t[s[0]],l,i=o.length;r=0;)r[s]=s;return r}function Iqt(t,s){return t[s]}function Lqt(t){const s=[];return s.key=t,s}function Dqt(){var t=Ml([]),s=Iye,r=O3,n=Iqt;function a(o){var l=Array.from(t.apply(this,arguments),Lqt),i,d=l.length,u=-1,p;for(const f of o)for(i=0,++u;i0){for(var r,n,a=0,o=t[0].length,l;a0){for(var r=0,n=t[s[0]],a,o=n.length;r0)||!((o=(a=t[s[0]]).length)>0))){for(var r=0,n=1,a,o,l;n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Vqt(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var YZe={symbolCircle:Hwe,symbolCross:uqt,symbolDiamond:mqt,symbolSquare:pqt,symbolStar:yqt,symbolTriangle:vqt,symbolWye:bqt},Hqt=Math.PI/180,Wqt=function(s){var r="symbol".concat(nce(s));return YZe[r]||Hwe},Gqt=function(s,r,n){if(r==="area")return s;switch(n){case"cross":return 5*s*s/9;case"diamond":return .5*s*s/Math.sqrt(3);case"square":return s*s;case"star":{var a=18*Hqt;return 1.25*s*s*(Math.tan(a)-Math.tan(a*2)*Math.pow(Math.tan(a),2))}case"triangle":return Math.sqrt(3)*s*s/4;case"wye":return(21-10*Math.sqrt(3))*s*s/8;default:return Math.PI*s*s/4}},Kqt=function(s,r){YZe["symbol".concat(nce(s))]=r},Wwe=function(s){var r=s.type,n=r===void 0?"circle":r,a=s.size,o=a===void 0?64:a,l=s.sizeType,i=l===void 0?"area":l,d=Uqt(s,zqt),u=OEe(OEe({},d),{},{type:n,size:o,sizeType:i}),p=function(){var j=Wqt(n),k=wqt().type(j).size(Gqt(o,i,n));return k()},f=u.className,y=u.cx,_=u.cy,b=Ga(u,!0);return y===+y&&_===+_&&o===+o?ht.createElement("path",Lye({},b,{className:Ii("recharts-symbols",f),transform:"translate(".concat(y,", ").concat(_,")"),d:p()})):null};Wwe.registerSymbol=Kqt;function R3(t){"@babel/helpers - typeof";return R3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},R3(t)}function Dye(){return Dye=Object.assign?Object.assign.bind():function(t){for(var s=1;s`);var S=_.inactive?u:_.color;return ht.createElement("li",Dye({className:j,style:f,key:"legend-item-".concat(b)},Kk(n.props,_,b)),ht.createElement(Sye,{width:l,height:l,viewBox:p,style:y},n.renderIcon(_)),ht.createElement("span",{className:"recharts-legend-item-text",style:{color:S}},w?w(k,_,b):k))})}},{key:"render",value:function(){var n=this.props,a=n.payload,o=n.layout,l=n.align;if(!a||!a.length)return null;var i={padding:0,margin:0,textAlign:o==="horizontal"?l:"left"};return ht.createElement("ul",{className:"recharts-default-legend",style:i},this.renderItems())}}])}(C.PureComponent);A6(Gwe,"displayName","Legend");A6(Gwe,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var nUt=Hle;function aUt(){this.__data__=new nUt,this.size=0}var iUt=aUt;function oUt(t){var s=this.__data__,r=s.delete(t);return this.size=s.size,r}var lUt=oUt;function cUt(t){return this.__data__.get(t)}var dUt=cUt;function uUt(t){return this.__data__.has(t)}var hUt=uUt,mUt=Hle,pUt=Lwe,fUt=Dwe,gUt=200;function xUt(t,s){var r=this.__data__;if(r instanceof mUt){var n=r.__data__;if(!pUt||n.lengthi))return!1;var u=o.get(t),p=o.get(s);if(u&&p)return u==s&&p==t;var f=-1,y=!0,_=r&zUt?new DUt:void 0;for(o.set(t,s),o.set(s,t);++f-1&&t%1==0&&t-1&&t%1==0&&t<=UVt}var Xwe=VVt,HVt=uv,WVt=Xwe,GVt=hv,KVt="[object Arguments]",ZVt="[object Array]",YVt="[object Boolean]",XVt="[object Date]",QVt="[object Error]",JVt="[object Function]",eHt="[object Map]",tHt="[object Number]",sHt="[object Object]",rHt="[object RegExp]",nHt="[object Set]",aHt="[object String]",iHt="[object WeakMap]",oHt="[object ArrayBuffer]",lHt="[object DataView]",cHt="[object Float32Array]",dHt="[object Float64Array]",uHt="[object Int8Array]",hHt="[object Int16Array]",mHt="[object Int32Array]",pHt="[object Uint8Array]",fHt="[object Uint8ClampedArray]",gHt="[object Uint16Array]",xHt="[object Uint32Array]",Xl={};Xl[cHt]=Xl[dHt]=Xl[uHt]=Xl[hHt]=Xl[mHt]=Xl[pHt]=Xl[fHt]=Xl[gHt]=Xl[xHt]=!0;Xl[KVt]=Xl[ZVt]=Xl[oHt]=Xl[YVt]=Xl[lHt]=Xl[XVt]=Xl[QVt]=Xl[JVt]=Xl[eHt]=Xl[tHt]=Xl[sHt]=Xl[rHt]=Xl[nHt]=Xl[aHt]=Xl[iHt]=!1;function yHt(t){return GVt(t)&&WVt(t.length)&&!!Xl[HVt(t)]}var vHt=yHt;function _Ht(t){return function(s){return t(s)}}var oYe=_Ht,tie={exports:{}};tie.exports;(function(t,s){var r=fZe,n=s&&!s.nodeType&&s,a=n&&!0&&t&&!t.nodeType&&t,o=a&&a.exports===n,l=o&&r.process,i=function(){try{var d=a&&a.require&&a.require("util").types;return d||l&&l.binding&&l.binding("util")}catch{}}();t.exports=i})(tie,tie.exports);var bHt=tie.exports,wHt=vHt,jHt=oYe,UEe=bHt,VEe=UEe&&UEe.isTypedArray,NHt=VEe?jHt(VEe):wHt,lYe=NHt,kHt=MVt,SHt=Zwe,CHt=Um,MHt=iYe,THt=Ywe,AHt=lYe,EHt=Object.prototype,PHt=EHt.hasOwnProperty;function IHt(t,s){var r=CHt(t),n=!r&&SHt(t),a=!r&&!n&&MHt(t),o=!r&&!n&&!a&&AHt(t),l=r||n||a||o,i=l?kHt(t.length,String):[],d=i.length;for(var u in t)(s||PHt.call(t,u))&&!(l&&(u=="length"||a&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||THt(u,d)))&&i.push(u);return i}var LHt=IHt,DHt=Object.prototype;function OHt(t){var s=t&&t.constructor,r=typeof s=="function"&&s.prototype||DHt;return t===r}var RHt=OHt;function FHt(t,s){return function(r){return t(s(r))}}var cYe=FHt,zHt=cYe,BHt=zHt(Object.keys,Object),$Ht=BHt,qHt=RHt,UHt=$Ht,VHt=Object.prototype,HHt=VHt.hasOwnProperty;function WHt(t){if(!qHt(t))return UHt(t);var s=[];for(var r in Object(t))HHt.call(t,r)&&r!="constructor"&&s.push(r);return s}var GHt=WHt,KHt=Pwe,ZHt=Xwe;function YHt(t){return t!=null&&ZHt(t.length)&&!KHt(t)}var iD=YHt,XHt=LHt,QHt=GHt,JHt=iD;function eWt(t){return JHt(t)?XHt(t):QHt(t)}var lce=eWt,tWt=gVt,sWt=SVt,rWt=lce;function nWt(t){return tWt(t,rWt,sWt)}var aWt=nWt,HEe=aWt,iWt=1,oWt=Object.prototype,lWt=oWt.hasOwnProperty;function cWt(t,s,r,n,a,o){var l=r&iWt,i=HEe(t),d=i.length,u=HEe(s),p=u.length;if(d!=p&&!l)return!1;for(var f=d;f--;){var y=i[f];if(!(l?y in s:lWt.call(s,y)))return!1}var _=o.get(t),b=o.get(s);if(_&&b)return _==s&&b==t;var w=!0;o.set(t,s),o.set(s,t);for(var j=l;++f-1}var oKt=iKt;function lKt(t,s,r){for(var n=-1,a=t==null?0:t.length;++n=jKt){var u=s?null:bKt(t);if(u)return wKt(u);l=!1,a=_Kt,d=new xKt}else d=s?[]:i;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function zKt(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function BKt(t){return t.value}function $Kt(t,s){if(ht.isValidElement(t))return ht.cloneElement(t,s);if(typeof t=="function")return ht.createElement(t,s);s.ref;var r=FKt(s,AKt);return ht.createElement(Gwe,r)}var oPe=1,H5=function(t){function s(){var r;EKt(this,s);for(var n=arguments.length,a=new Array(n),o=0;ooPe||Math.abs(a.height-this.lastBoundingBox.height)>oPe)&&(this.lastBoundingBox.width=a.width,this.lastBoundingBox.height=a.height,n&&n(a)):(this.lastBoundingBox.width!==-1||this.lastBoundingBox.height!==-1)&&(this.lastBoundingBox.width=-1,this.lastBoundingBox.height=-1,n&&n(null))}},{key:"getBBoxSnapshot",value:function(){return this.lastBoundingBox.width>=0&&this.lastBoundingBox.height>=0?s0({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(n){var a=this.props,o=a.layout,l=a.align,i=a.verticalAlign,d=a.margin,u=a.chartWidth,p=a.chartHeight,f,y;if(!n||(n.left===void 0||n.left===null)&&(n.right===void 0||n.right===null))if(l==="center"&&o==="vertical"){var _=this.getBBoxSnapshot();f={left:((u||0)-_.width)/2}}else f=l==="right"?{right:d&&d.right||0}:{left:d&&d.left||0};if(!n||(n.top===void 0||n.top===null)&&(n.bottom===void 0||n.bottom===null))if(i==="middle"){var b=this.getBBoxSnapshot();y={top:((p||0)-b.height)/2}}else y=i==="bottom"?{bottom:d&&d.bottom||0}:{top:d&&d.top||0};return s0(s0({},f),y)}},{key:"render",value:function(){var n=this,a=this.props,o=a.content,l=a.width,i=a.height,d=a.wrapperStyle,u=a.payloadUniqBy,p=a.payload,f=s0(s0({position:"absolute",width:l||"auto",height:i||"auto"},this.getDefaultPosition(d)),d);return ht.createElement("div",{className:"recharts-legend-wrapper",style:f,ref:function(_){n.wrapperNode=_}},$Kt(o,s0(s0({},this.props),{},{payload:gYe(p,u,BKt)})))}}],[{key:"getWithHeight",value:function(n,a){var o=s0(s0({},this.defaultProps),n.props),l=o.layout;return l==="vertical"&&tn(n.props.height)?{height:n.props.height}:l==="horizontal"?{width:n.props.width||a}:null}}])}(C.PureComponent);cce(H5,"displayName","Legend");cce(H5,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var lPe=nD,qKt=Zwe,UKt=Um,cPe=lPe?lPe.isConcatSpreadable:void 0;function VKt(t){return UKt(t)||qKt(t)||!!(cPe&&t&&t[cPe])}var HKt=VKt,WKt=nYe,GKt=HKt;function vYe(t,s,r,n,a){var o=-1,l=t.length;for(r||(r=GKt),a||(a=[]);++o0&&r(i)?s>1?vYe(i,s-1,r,n,a):WKt(a,i):n||(a[a.length]=i)}return a}var _Ye=vYe;function KKt(t){return function(s,r,n){for(var a=-1,o=Object(s),l=n(s),i=l.length;i--;){var d=l[t?i:++a];if(r(o[d],d,o)===!1)break}return s}}var ZKt=KKt,YKt=ZKt,XKt=YKt(),QKt=XKt,JKt=QKt,eZt=lce;function tZt(t,s){return t&&JKt(t,s,eZt)}var bYe=tZt,sZt=iD;function rZt(t,s){return function(r,n){if(r==null)return r;if(!sZt(r))return t(r,n);for(var a=r.length,o=s?a:-1,l=Object(r);(s?o--:++os||o&&l&&d&&!i&&!u||n&&l&&d||!r&&d||!a)return 1;if(!n&&!o&&!u&&t=i)return d;var u=r[n];return d*(u=="desc"?-1:1)}}return t.index-s.index}var xZt=gZt,ppe=Rwe,yZt=Fwe,vZt=wy,_Zt=wYe,bZt=hZt,wZt=oYe,jZt=xZt,NZt=KM,kZt=Um;function SZt(t,s,r){s.length?s=ppe(s,function(o){return kZt(o)?function(l){return yZt(l,o.length===1?o[0]:o)}:o}):s=[NZt];var n=-1;s=ppe(s,wZt(vZt));var a=_Zt(t,function(o,l,i){var d=ppe(s,function(u){return u(o)});return{criteria:d,index:++n,value:o}});return bZt(a,function(o,l){return jZt(o,l,r)})}var CZt=SZt;function MZt(t,s,r){switch(r.length){case 0:return t.call(s);case 1:return t.call(s,r[0]);case 2:return t.call(s,r[0],r[1]);case 3:return t.call(s,r[0],r[1],r[2])}return t.apply(s,r)}var TZt=MZt,AZt=TZt,uPe=Math.max;function EZt(t,s,r){return s=uPe(s===void 0?t.length-1:s,0),function(){for(var n=arguments,a=-1,o=uPe(n.length-s,0),l=Array(o);++a0){if(++s>=$Zt)return arguments[0]}else s=0;return t.apply(void 0,arguments)}}var HZt=VZt,WZt=BZt,GZt=HZt,KZt=GZt(WZt),ZZt=KZt,YZt=KM,XZt=PZt,QZt=ZZt;function JZt(t,s){return QZt(XZt(t,s,YZt),t+"")}var eYt=JZt,tYt=Iwe,sYt=iD,rYt=Ywe,nYt=rb;function aYt(t,s,r){if(!nYt(r))return!1;var n=typeof s;return(n=="number"?sYt(r)&&rYt(s,r.length):n=="string"&&s in r)?tYt(r[s],t):!1}var dce=aYt,iYt=_Ye,oYt=CZt,lYt=eYt,mPe=dce,cYt=lYt(function(t,s){if(t==null)return[];var r=s.length;return r>1&&mPe(t,s[0],s[1])?s=[]:r>2&&mPe(s[0],s[1],s[2])&&(s=[s[0]]),oYt(t,iYt(s,1),[])}),dYt=cYt;const e2e=_o(dYt);function E6(t){"@babel/helpers - typeof";return E6=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},E6(t)}function Uye(){return Uye=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r=s.x),"".concat(gE,"-left"),tn(r)&&s&&tn(s.x)&&r=s.y),"".concat(gE,"-top"),tn(n)&&s&&tn(s.y)&&nw?Math.max(p,d[n]):Math.max(f,d[n])}function kYt(t){var s=t.translateX,r=t.translateY,n=t.useTranslate3d;return{transform:n?"translate3d(".concat(s,"px, ").concat(r,"px, 0)"):"translate(".concat(s,"px, ").concat(r,"px)")}}function SYt(t){var s=t.allowEscapeViewBox,r=t.coordinate,n=t.offsetTopLeft,a=t.position,o=t.reverseDirection,l=t.tooltipBox,i=t.useTranslate3d,d=t.viewBox,u,p,f;return l.height>0&&l.width>0&&r?(p=gPe({allowEscapeViewBox:s,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:d,viewBoxDimension:d.width}),f=gPe({allowEscapeViewBox:s,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:d,viewBoxDimension:d.height}),u=kYt({translateX:p,translateY:f,useTranslate3d:i})):u=jYt,{cssProperties:u,cssClasses:NYt({translateX:p,translateY:f,coordinate:r})}}function z3(t){"@babel/helpers - typeof";return z3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},z3(t)}function xPe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function yPe(t){for(var s=1;svPe||Math.abs(n.height-this.state.lastBoundingBox.height)>vPe)&&this.setState({lastBoundingBox:{width:n.width,height:n.height}})}else(this.state.lastBoundingBox.width!==-1||this.state.lastBoundingBox.height!==-1)&&this.setState({lastBoundingBox:{width:-1,height:-1}})}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyDown),this.updateBBox()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyDown)}},{key:"componentDidUpdate",value:function(){var n,a;this.props.active&&this.updateBBox(),this.state.dismissed&&(((n=this.props.coordinate)===null||n===void 0?void 0:n.x)!==this.state.dismissedAtCoordinate.x||((a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}},{key:"render",value:function(){var n=this,a=this.props,o=a.active,l=a.allowEscapeViewBox,i=a.animationDuration,d=a.animationEasing,u=a.children,p=a.coordinate,f=a.hasPayload,y=a.isAnimationActive,_=a.offset,b=a.position,w=a.reverseDirection,j=a.useTranslate3d,k=a.viewBox,S=a.wrapperStyle,T=SYt({allowEscapeViewBox:l,coordinate:p,offsetTopLeft:_,position:b,reverseDirection:w,tooltipBox:this.state.lastBoundingBox,useTranslate3d:j,viewBox:k}),I=T.cssClasses,L=T.cssProperties,R=yPe(yPe({transition:y&&o?"transform ".concat(i,"ms ").concat(d):void 0},L),{},{pointerEvents:"none",visibility:!this.state.dismissed&&o&&f?"visible":"hidden",position:"absolute",top:0,left:0},S);return ht.createElement("div",{tabIndex:-1,className:I,style:R,ref:function(q){n.wrapperNode=q}},u)}}])}(C.PureComponent),OYt=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},mS={isSsr:OYt()};function B3(t){"@babel/helpers - typeof";return B3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},B3(t)}function _Pe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function bPe(t){for(var s=1;s0;return ht.createElement(DYt,{allowEscapeViewBox:l,animationDuration:i,animationEasing:d,isAnimationActive:y,active:o,coordinate:p,hasPayload:R,offset:_,position:j,reverseDirection:k,useTranslate3d:S,viewBox:T,wrapperStyle:I},WYt(u,bPe(bPe({},this.props),{},{payload:L})))}}])}(C.PureComponent);t2e(vm,"displayName","Tooltip");t2e(vm,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!mS.isSsr,itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,viewBox:{x:0,y:0,height:0,width:0},wrapperStyle:{}});var GYt=by,KYt=function(){return GYt.Date.now()},ZYt=KYt,YYt=/\s/;function XYt(t){for(var s=t.length;s--&&YYt.test(t.charAt(s)););return s}var QYt=XYt,JYt=QYt,eXt=/^\s+/;function tXt(t){return t&&t.slice(0,JYt(t)+1).replace(eXt,"")}var sXt=tXt,rXt=sXt,wPe=rb,nXt=BM,jPe=NaN,aXt=/^[-+]0x[0-9a-f]+$/i,iXt=/^0b[01]+$/i,oXt=/^0o[0-7]+$/i,lXt=parseInt;function cXt(t){if(typeof t=="number")return t;if(nXt(t))return jPe;if(wPe(t)){var s=typeof t.valueOf=="function"?t.valueOf():t;t=wPe(s)?s+"":s}if(typeof t!="string")return t===0?t:+t;t=rXt(t);var r=iXt.test(t);return r||oXt.test(t)?lXt(t.slice(2),r?2:8):aXt.test(t)?jPe:+t}var MYe=cXt,dXt=rb,gpe=ZYt,NPe=MYe,uXt="Expected a function",hXt=Math.max,mXt=Math.min;function pXt(t,s,r){var n,a,o,l,i,d,u=0,p=!1,f=!1,y=!0;if(typeof t!="function")throw new TypeError(uXt);s=NPe(s)||0,dXt(r)&&(p=!!r.leading,f="maxWait"in r,o=f?hXt(NPe(r.maxWait)||0,s):o,y="trailing"in r?!!r.trailing:y);function _(R){var $=n,q=a;return n=a=void 0,u=R,l=t.apply(q,$),l}function b(R){return u=R,i=setTimeout(k,s),p?_(R):l}function w(R){var $=R-d,q=R-u,U=s-$;return f?mXt(U,o-q):U}function j(R){var $=R-d,q=R-u;return d===void 0||$>=s||$<0||f&&q>=o}function k(){var R=gpe();if(j(R))return S(R);i=setTimeout(k,w(R))}function S(R){return i=void 0,y&&n?_(R):(n=a=void 0,l)}function T(){i!==void 0&&clearTimeout(i),u=0,n=d=a=i=void 0}function I(){return i===void 0?l:S(gpe())}function L(){var R=gpe(),$=j(R);if(n=arguments,a=this,d=R,$){if(i===void 0)return b(d);if(f)return clearTimeout(i),i=setTimeout(k,s),_(d)}return i===void 0&&(i=setTimeout(k,s)),l}return L.cancel=T,L.flush=I,L}var fXt=pXt,gXt=fXt,xXt=rb,yXt="Expected a function";function vXt(t,s,r){var n=!0,a=!0;if(typeof t!="function")throw new TypeError(yXt);return xXt(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),gXt(t,s,{leading:n,maxWait:s,trailing:a})}var _Xt=vXt;const TYe=_o(_Xt);function I6(t){"@babel/helpers - typeof";return I6=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},I6(t)}function kPe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function NR(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&(te=TYe(te,w,{trailing:!0,leading:!1}));var Q=new ResizeObserver(te),de=L.current.getBoundingClientRect(),re=de.width,ae=de.height;return Y(re,ae),Q.observe(L.current),function(){Q.disconnect()}},[Y,w]);var se=C.useMemo(function(){var te=U.containerWidth,Q=U.containerHeight;if(te<0||Q<0)return null;Kg(qN(l)||qN(d),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,l,d),Kg(!r||r>0,"The aspect(%s) must be greater than zero.",r);var de=qN(l)?te:l,re=qN(d)?Q:d;r&&r>0&&(de?re=de/r:re&&(de=re*r),y&&re>y&&(re=y)),Kg(de>0||re>0,`The width(%s) and height(%s) of chart should be greater than 0, please check the style of container, or the props width(%s) and height(%s), or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the height and width.`,de,re,l,d,p,f,r);var ae=!Array.isArray(_)&&W0(_.type).endsWith("Chart");return ht.Children.map(_,function(le){return ht.isValidElement(le)?C.cloneElement(le,NR({width:de,height:re},ae?{style:NR({height:"100%",width:"100%",maxHeight:re,maxWidth:de},le.props.style)}:{})):le})},[r,_,d,y,f,p,U,l]);return ht.createElement("div",{id:j?"".concat(j):void 0,className:Ii("recharts-responsive-container",k),style:NR(NR({},I),{},{width:l,height:d,minWidth:p,minHeight:f,maxHeight:y}),ref:L},se)}),oD=function(s){return null};oD.displayName="Cell";function L6(t){"@babel/helpers - typeof";return L6=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},L6(t)}function CPe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Gye(t){for(var s=1;s1&&arguments[1]!==void 0?arguments[1]:{};if(s==null||mS.isSsr)return{width:0,height:0};var n=LXt(r),a=JSON.stringify({text:s,copyStyle:n});if(g4.widthCache[a])return g4.widthCache[a];try{var o=document.getElementById(MPe);o||(o=document.createElement("span"),o.setAttribute("id",MPe),o.setAttribute("aria-hidden","true"),document.body.appendChild(o));var l=Gye(Gye({},IXt),n);Object.assign(o.style,l),o.textContent="".concat(s);var i=o.getBoundingClientRect(),d={width:i.width,height:i.height};return g4.widthCache[a]=d,++g4.cacheCount>PXt&&(g4.cacheCount=0,g4.widthCache={}),d}catch{return{width:0,height:0}}},DXt=function(s){return{top:s.top+window.scrollY-document.documentElement.clientTop,left:s.left+window.scrollX-document.documentElement.clientLeft}};function D6(t){"@babel/helpers - typeof";return D6=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},D6(t)}function aie(t,s){return zXt(t)||FXt(t,s)||RXt(t,s)||OXt()}function OXt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function RXt(t,s){if(t){if(typeof t=="string")return TPe(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return TPe(t,s)}}function TPe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function JXt(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function DPe(t,s){return rQt(t)||sQt(t,s)||tQt(t,s)||eQt()}function eQt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tQt(t,s){if(t){if(typeof t=="string")return OPe(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return OPe(t,s)}}function OPe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&arguments[0]!==void 0?arguments[0]:[];return de.reduce(function(re,ae){var le=ae.word,he=ae.width,be=re[re.length-1];if(be&&(a==null||o||be.width+he+nae.width?re:ae})};if(!p)return _;for(var w="…",j=function(de){var re=f.slice(0,de),ae=IYe({breakAll:u,style:d,children:re+w}).wordsWithComputedWidth,le=y(ae),he=le.length>l||b(le).width>Number(a);return[he,le]},k=0,S=f.length-1,T=0,I;k<=S&&T<=f.length-1;){var L=Math.floor((k+S)/2),R=L-1,$=j(R),q=DPe($,2),U=q[0],H=q[1],Y=j(L),se=DPe(Y,1),te=se[0];if(!U&&!te&&(k=L+1),U&&te&&(S=L-1),!U&&te){I=H;break}T++}return I||_},RPe=function(s){var r=Ai(s)?[]:s.toString().split(PYe);return[{words:r}]},aQt=function(s){var r=s.width,n=s.scaleToFit,a=s.children,o=s.style,l=s.breakAll,i=s.maxLines;if((r||n)&&!mS.isSsr){var d,u,p=IYe({breakAll:l,children:a,style:o});if(p){var f=p.wordsWithComputedWidth,y=p.spaceWidth;d=f,u=y}else return RPe(a);return nQt({breakAll:l,children:a,maxLines:i,style:o},d,u,r,n)}return RPe(a)},FPe="#808080",Zk=function(s){var r=s.x,n=r===void 0?0:r,a=s.y,o=a===void 0?0:a,l=s.lineHeight,i=l===void 0?"1em":l,d=s.capHeight,u=d===void 0?"0.71em":d,p=s.scaleToFit,f=p===void 0?!1:p,y=s.textAnchor,_=y===void 0?"start":y,b=s.verticalAnchor,w=b===void 0?"end":b,j=s.fill,k=j===void 0?FPe:j,S=LPe(s,XXt),T=C.useMemo(function(){return aQt({breakAll:S.breakAll,children:S.children,maxLines:S.maxLines,scaleToFit:f,style:S.style,width:S.width})},[S.breakAll,S.children,S.maxLines,f,S.style,S.width]),I=S.dx,L=S.dy,R=S.angle,$=S.className,q=S.breakAll,U=LPe(S,QXt);if(!Ud(n)||!Ud(o))return null;var H=n+(tn(I)?I:0),Y=o+(tn(L)?L:0),se;switch(w){case"start":se=xpe("calc(".concat(u,")"));break;case"middle":se=xpe("calc(".concat((T.length-1)/2," * -").concat(i," + (").concat(u," / 2))"));break;default:se=xpe("calc(".concat(T.length-1," * -").concat(i,")"));break}var te=[];if(f){var Q=T[0].width,de=S.width;te.push("scale(".concat((tn(de)?de/Q:1)/Q,")"))}return R&&te.push("rotate(".concat(R,", ").concat(H,", ").concat(Y,")")),te.length&&(U.transform=te.join(" ")),ht.createElement("text",Kye({},Ga(U,!0),{x:H,y:Y,className:Ii("recharts-text",$),textAnchor:_,fill:k.includes("url")?FPe:k}),T.map(function(re,ae){var le=re.words.join(q?"":" ");return ht.createElement("tspan",{x:H,dy:ae===0?se:i,key:"".concat(le,"-").concat(ae)},le)}))};function N_(t,s){return t==null||s==null?NaN:ts?1:t>=s?0:NaN}function iQt(t,s){return t==null||s==null?NaN:st?1:s>=t?0:NaN}function s2e(t){let s,r,n;t.length!==2?(s=N_,r=(i,d)=>N_(t(i),d),n=(i,d)=>t(i)-d):(s=t===N_||t===iQt?t:oQt,r=t,n=t);function a(i,d,u=0,p=i.length){if(u>>1;r(i[f],d)<0?u=f+1:p=f}while(u>>1;r(i[f],d)<=0?u=f+1:p=f}while(uu&&n(i[f-1],d)>-n(i[f],d)?f-1:f}return{left:a,center:l,right:o}}function oQt(){return 0}function LYe(t){return t===null?NaN:+t}function*lQt(t,s){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const cQt=s2e(N_),lD=cQt.right;s2e(LYe).center;class zPe extends Map{constructor(s,r=hQt){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:r}}),s!=null)for(const[n,a]of s)this.set(n,a)}get(s){return super.get(BPe(this,s))}has(s){return super.has(BPe(this,s))}set(s,r){return super.set(dQt(this,s),r)}delete(s){return super.delete(uQt(this,s))}}function BPe({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):r}function dQt({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function uQt({_intern:t,_key:s},r){const n=s(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function hQt(t){return t!==null&&typeof t=="object"?t.valueOf():t}function mQt(t=N_){if(t===N_)return DYe;if(typeof t!="function")throw new TypeError("compare is not a function");return(s,r)=>{const n=t(s,r);return n||n===0?n:(t(r,r)===0)-(t(s,s)===0)}}function DYe(t,s){return(t==null||!(t>=t))-(s==null||!(s>=s))||(ts?1:0)}const pQt=Math.sqrt(50),fQt=Math.sqrt(10),gQt=Math.sqrt(2);function iie(t,s,r){const n=(s-t)/Math.max(0,r),a=Math.floor(Math.log10(n)),o=n/Math.pow(10,a),l=o>=pQt?10:o>=fQt?5:o>=gQt?2:1;let i,d,u;return a<0?(u=Math.pow(10,-a)/l,i=Math.round(t*u),d=Math.round(s*u),i/us&&--d,u=-u):(u=Math.pow(10,a)*l,i=Math.round(t/u),d=Math.round(s/u),i*us&&--d),d0))return[];if(t===s)return[t];const n=s=a))return[];const i=o-a+1,d=new Array(i);if(n)if(l<0)for(let u=0;u=n)&&(r=n);return r}function qPe(t,s){let r;for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function OYe(t,s,r=0,n=1/0,a){if(s=Math.floor(s),r=Math.floor(Math.max(0,r)),n=Math.floor(Math.min(t.length-1,n)),!(r<=s&&s<=n))return t;for(a=a===void 0?DYe:mQt(a);n>r;){if(n-r>600){const d=n-r+1,u=s-r+1,p=Math.log(d),f=.5*Math.exp(2*p/3),y=.5*Math.sqrt(p*f*(d-f)/d)*(u-d/2<0?-1:1),_=Math.max(r,Math.floor(s-u*f/d+y)),b=Math.min(n,Math.floor(s+(d-u)*f/d+y));OYe(t,s,_,b,a)}const o=t[s];let l=r,i=n;for(xE(t,r,s),a(t[n],o)>0&&xE(t,r,n);l0;)--i}a(t[r],o)===0?xE(t,r,i):(++i,xE(t,i,n)),i<=s&&(r=i+1),s<=i&&(n=i-1)}return t}function xE(t,s,r){const n=t[s];t[s]=t[r],t[r]=n}function xQt(t,s,r){if(t=Float64Array.from(lQt(t)),!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return qPe(t);if(s>=1)return $Pe(t);var n,a=(n-1)*s,o=Math.floor(a),l=$Pe(OYe(t,o).subarray(0,o+1)),i=qPe(t.subarray(o+1));return l+(i-l)*(a-o)}}function yQt(t,s,r=LYe){if(!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return+r(t[0],0,t);if(s>=1)return+r(t[n-1],n-1,t);var n,a=(n-1)*s,o=Math.floor(a),l=+r(t[o],o,t),i=+r(t[o+1],o+1,t);return l+(i-l)*(a-o)}}function vQt(t,s,r){t=+t,s=+s,r=(a=arguments.length)<2?(s=t,t=0,1):a<3?1:+r;for(var n=-1,a=Math.max(0,Math.ceil((s-t)/r))|0,o=new Array(a);++n>8&15|s>>4&240,s>>4&15|s&240,(s&15)<<4|s&15,1):r===8?SR(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):r===4?SR(s>>12&15|s>>8&240,s>>8&15|s>>4&240,s>>4&15|s&240,((s&15)<<4|s&15)/255):null):(s=bQt.exec(t))?new Mm(s[1],s[2],s[3],1):(s=wQt.exec(t))?new Mm(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=jQt.exec(t))?SR(s[1],s[2],s[3],s[4]):(s=NQt.exec(t))?SR(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=kQt.exec(t))?ZPe(s[1],s[2]/100,s[3]/100,1):(s=SQt.exec(t))?ZPe(s[1],s[2]/100,s[3]/100,s[4]):UPe.hasOwnProperty(t)?WPe(UPe[t]):t==="transparent"?new Mm(NaN,NaN,NaN,0):null}function WPe(t){return new Mm(t>>16&255,t>>8&255,t&255,1)}function SR(t,s,r,n){return n<=0&&(t=s=r=NaN),new Mm(t,s,r,n)}function TQt(t){return t instanceof cD||(t=z6(t)),t?(t=t.rgb(),new Mm(t.r,t.g,t.b,t.opacity)):new Mm}function Jye(t,s,r,n){return arguments.length===1?TQt(t):new Mm(t,s,r,n??1)}function Mm(t,s,r,n){this.r=+t,this.g=+s,this.b=+r,this.opacity=+n}n2e(Mm,Jye,FYe(cD,{brighter(t){return t=t==null?oie:Math.pow(oie,t),new Mm(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?R6:Math.pow(R6,t),new Mm(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Mm(Nk(this.r),Nk(this.g),Nk(this.b),lie(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:GPe,formatHex:GPe,formatHex8:AQt,formatRgb:KPe,toString:KPe}));function GPe(){return`#${UN(this.r)}${UN(this.g)}${UN(this.b)}`}function AQt(){return`#${UN(this.r)}${UN(this.g)}${UN(this.b)}${UN((isNaN(this.opacity)?1:this.opacity)*255)}`}function KPe(){const t=lie(this.opacity);return`${t===1?"rgb(":"rgba("}${Nk(this.r)}, ${Nk(this.g)}, ${Nk(this.b)}${t===1?")":`, ${t})`}`}function lie(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Nk(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function UN(t){return t=Nk(t),(t<16?"0":"")+t.toString(16)}function ZPe(t,s,r,n){return n<=0?t=s=r=NaN:r<=0||r>=1?t=s=NaN:s<=0&&(t=NaN),new Dg(t,s,r,n)}function zYe(t){if(t instanceof Dg)return new Dg(t.h,t.s,t.l,t.opacity);if(t instanceof cD||(t=z6(t)),!t)return new Dg;if(t instanceof Dg)return t;t=t.rgb();var s=t.r/255,r=t.g/255,n=t.b/255,a=Math.min(s,r,n),o=Math.max(s,r,n),l=NaN,i=o-a,d=(o+a)/2;return i?(s===o?l=(r-n)/i+(r0&&d<1?0:l,new Dg(l,i,d,t.opacity)}function EQt(t,s,r,n){return arguments.length===1?zYe(t):new Dg(t,s,r,n??1)}function Dg(t,s,r,n){this.h=+t,this.s=+s,this.l=+r,this.opacity=+n}n2e(Dg,EQt,FYe(cD,{brighter(t){return t=t==null?oie:Math.pow(oie,t),new Dg(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?R6:Math.pow(R6,t),new Dg(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,s=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*s,a=2*r-n;return new Mm(ype(t>=240?t-240:t+120,a,n),ype(t,a,n),ype(t<120?t+240:t-120,a,n),this.opacity)},clamp(){return new Dg(YPe(this.h),CR(this.s),CR(this.l),lie(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=lie(this.opacity);return`${t===1?"hsl(":"hsla("}${YPe(this.h)}, ${CR(this.s)*100}%, ${CR(this.l)*100}%${t===1?")":`, ${t})`}`}}));function YPe(t){return t=(t||0)%360,t<0?t+360:t}function CR(t){return Math.max(0,Math.min(1,t||0))}function ype(t,s,r){return(t<60?s+(r-s)*t/60:t<180?r:t<240?s+(r-s)*(240-t)/60:s)*255}const a2e=t=>()=>t;function PQt(t,s){return function(r){return t+r*s}}function IQt(t,s,r){return t=Math.pow(t,r),s=Math.pow(s,r)-t,r=1/r,function(n){return Math.pow(t+n*s,r)}}function LQt(t){return(t=+t)==1?BYe:function(s,r){return r-s?IQt(s,r,t):a2e(isNaN(s)?r:s)}}function BYe(t,s){var r=s-t;return r?PQt(t,r):a2e(isNaN(t)?s:t)}const XPe=function t(s){var r=LQt(s);function n(a,o){var l=r((a=Jye(a)).r,(o=Jye(o)).r),i=r(a.g,o.g),d=r(a.b,o.b),u=BYe(a.opacity,o.opacity);return function(p){return a.r=l(p),a.g=i(p),a.b=d(p),a.opacity=u(p),a+""}}return n.gamma=t,n}(1);function DQt(t,s){s||(s=[]);var r=t?Math.min(s.length,t.length):0,n=s.slice(),a;return function(o){for(a=0;ar&&(o=s.slice(r,o),i[l]?i[l]+=o:i[++l]=o),(n=n[0])===(a=a[0])?i[l]?i[l]+=a:i[++l]=a:(i[++l]=null,d.push({i:l,x:cie(n,a)})),r=vpe.lastIndex;return rs&&(r=t,t=s,s=r),function(n){return Math.max(t,Math.min(s,n))}}function WQt(t,s,r){var n=t[0],a=t[1],o=s[0],l=s[1];return a2?GQt:WQt,d=u=null,f}function f(y){return y==null||isNaN(y=+y)?o:(d||(d=i(t.map(n),s,r)))(n(l(y)))}return f.invert=function(y){return l(a((u||(u=i(s,t.map(n),cie)))(y)))},f.domain=function(y){return arguments.length?(t=Array.from(y,die),p()):t.slice()},f.range=function(y){return arguments.length?(s=Array.from(y),p()):s.slice()},f.rangeRound=function(y){return s=Array.from(y),r=i2e,p()},f.clamp=function(y){return arguments.length?(l=y?!0:$h,p()):l!==$h},f.interpolate=function(y){return arguments.length?(r=y,p()):r},f.unknown=function(y){return arguments.length?(o=y,f):o},function(y,_){return n=y,a=_,p()}}function o2e(){return uce()($h,$h)}function KQt(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function uie(t,s){if((r=(t=s?t.toExponential(s-1):t.toExponential()).indexOf("e"))<0)return null;var r,n=t.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+t.slice(r+1)]}function $3(t){return t=uie(Math.abs(t)),t?t[1]:NaN}function ZQt(t,s){return function(r,n){for(var a=r.length,o=[],l=0,i=t[0],d=0;a>0&&i>0&&(d+i+1>n&&(i=Math.max(1,n-d)),o.push(r.substring(a-=i,a+i)),!((d+=i+1)>n));)i=t[l=(l+1)%t.length];return o.reverse().join(s)}}function YQt(t){return function(s){return s.replace(/[0-9]/g,function(r){return t[+r]})}}var XQt=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function B6(t){if(!(s=XQt.exec(t)))throw new Error("invalid format: "+t);var s;return new l2e({fill:s[1],align:s[2],sign:s[3],symbol:s[4],zero:s[5],width:s[6],comma:s[7],precision:s[8]&&s[8].slice(1),trim:s[9],type:s[10]})}B6.prototype=l2e.prototype;function l2e(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}l2e.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function QQt(t){e:for(var s=t.length,r=1,n=-1,a;r0&&(n=0);break}return n>0?t.slice(0,n)+t.slice(a+1):t}var $Ye;function JQt(t,s){var r=uie(t,s);if(!r)return t+"";var n=r[0],a=r[1],o=a-($Ye=Math.max(-8,Math.min(8,Math.floor(a/3)))*3)+1,l=n.length;return o===l?n:o>l?n+new Array(o-l+1).join("0"):o>0?n.slice(0,o)+"."+n.slice(o):"0."+new Array(1-o).join("0")+uie(t,Math.max(0,s+o-1))[0]}function JPe(t,s){var r=uie(t,s);if(!r)return t+"";var n=r[0],a=r[1];return a<0?"0."+new Array(-a).join("0")+n:n.length>a+1?n.slice(0,a+1)+"."+n.slice(a+1):n+new Array(a-n.length+2).join("0")}const eIe={"%":(t,s)=>(t*100).toFixed(s),b:t=>Math.round(t).toString(2),c:t=>t+"",d:KQt,e:(t,s)=>t.toExponential(s),f:(t,s)=>t.toFixed(s),g:(t,s)=>t.toPrecision(s),o:t=>Math.round(t).toString(8),p:(t,s)=>JPe(t*100,s),r:JPe,s:JQt,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function tIe(t){return t}var sIe=Array.prototype.map,rIe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function eJt(t){var s=t.grouping===void 0||t.thousands===void 0?tIe:ZQt(sIe.call(t.grouping,Number),t.thousands+""),r=t.currency===void 0?"":t.currency[0]+"",n=t.currency===void 0?"":t.currency[1]+"",a=t.decimal===void 0?".":t.decimal+"",o=t.numerals===void 0?tIe:YQt(sIe.call(t.numerals,String)),l=t.percent===void 0?"%":t.percent+"",i=t.minus===void 0?"−":t.minus+"",d=t.nan===void 0?"NaN":t.nan+"";function u(f){f=B6(f);var y=f.fill,_=f.align,b=f.sign,w=f.symbol,j=f.zero,k=f.width,S=f.comma,T=f.precision,I=f.trim,L=f.type;L==="n"?(S=!0,L="g"):eIe[L]||(T===void 0&&(T=12),I=!0,L="g"),(j||y==="0"&&_==="=")&&(j=!0,y="0",_="=");var R=w==="$"?r:w==="#"&&/[boxX]/.test(L)?"0"+L.toLowerCase():"",$=w==="$"?n:/[%p]/.test(L)?l:"",q=eIe[L],U=/[defgprs%]/.test(L);T=T===void 0?6:/[gprs]/.test(L)?Math.max(1,Math.min(21,T)):Math.max(0,Math.min(20,T));function H(Y){var se=R,te=$,Q,de,re;if(L==="c")te=q(Y)+te,Y="";else{Y=+Y;var ae=Y<0||1/Y<0;if(Y=isNaN(Y)?d:q(Math.abs(Y),T),I&&(Y=QQt(Y)),ae&&+Y==0&&b!=="+"&&(ae=!1),se=(ae?b==="("?b:i:b==="-"||b==="("?"":b)+se,te=(L==="s"?rIe[8+$Ye/3]:"")+te+(ae&&b==="("?")":""),U){for(Q=-1,de=Y.length;++Qre||re>57){te=(re===46?a+Y.slice(Q+1):Y.slice(Q))+te,Y=Y.slice(0,Q);break}}}S&&!j&&(Y=s(Y,1/0));var le=se.length+Y.length+te.length,he=le>1)+se+Y+te+he.slice(le);break;default:Y=he+se+Y+te;break}return o(Y)}return H.toString=function(){return f+""},H}function p(f,y){var _=u((f=B6(f),f.type="f",f)),b=Math.max(-8,Math.min(8,Math.floor($3(y)/3)))*3,w=Math.pow(10,-b),j=rIe[8+b/3];return function(k){return _(w*k)+j}}return{format:u,formatPrefix:p}}var MR,c2e,qYe;tJt({thousands:",",grouping:[3],currency:["$",""]});function tJt(t){return MR=eJt(t),c2e=MR.format,qYe=MR.formatPrefix,MR}function sJt(t){return Math.max(0,-$3(Math.abs(t)))}function rJt(t,s){return Math.max(0,Math.max(-8,Math.min(8,Math.floor($3(s)/3)))*3-$3(Math.abs(t)))}function nJt(t,s){return t=Math.abs(t),s=Math.abs(s)-t,Math.max(0,$3(s)-$3(t))+1}function UYe(t,s,r,n){var a=Xye(t,s,r),o;switch(n=B6(n??",f"),n.type){case"s":{var l=Math.max(Math.abs(t),Math.abs(s));return n.precision==null&&!isNaN(o=rJt(a,l))&&(n.precision=o),qYe(n,l)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=nJt(a,Math.max(Math.abs(t),Math.abs(s))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=sJt(a))&&(n.precision=o-(n.type==="%")*2);break}}return c2e(n)}function nb(t){var s=t.domain;return t.ticks=function(r){var n=s();return Zye(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var a=s();return UYe(a[0],a[a.length-1],r??10,n)},t.nice=function(r){r==null&&(r=10);var n=s(),a=0,o=n.length-1,l=n[a],i=n[o],d,u,p=10;for(i0;){if(u=Yye(l,i,r),u===d)return n[a]=l,n[o]=i,s(n);if(u>0)l=Math.floor(l/u)*u,i=Math.ceil(i/u)*u;else if(u<0)l=Math.ceil(l*u)/u,i=Math.floor(i*u)/u;else break;d=u}return t},t}function hie(){var t=o2e();return t.copy=function(){return dD(t,hie())},zf.apply(t,arguments),nb(t)}function VYe(t){var s;function r(n){return n==null||isNaN(n=+n)?s:n}return r.invert=r,r.domain=r.range=function(n){return arguments.length?(t=Array.from(n,die),r):t.slice()},r.unknown=function(n){return arguments.length?(s=n,r):s},r.copy=function(){return VYe(t).unknown(s)},t=arguments.length?Array.from(t,die):[0,1],nb(r)}function HYe(t,s){t=t.slice();var r=0,n=t.length-1,a=t[r],o=t[n],l;return oMath.pow(t,s)}function cJt(t){return t===Math.E?Math.log:t===10&&Math.log10||t===2&&Math.log2||(t=Math.log(t),s=>Math.log(s)/t)}function iIe(t){return(s,r)=>-t(-s,r)}function d2e(t){const s=t(nIe,aIe),r=s.domain;let n=10,a,o;function l(){return a=cJt(n),o=lJt(n),r()[0]<0?(a=iIe(a),o=iIe(o),t(aJt,iJt)):t(nIe,aIe),s}return s.base=function(i){return arguments.length?(n=+i,l()):n},s.domain=function(i){return arguments.length?(r(i),l()):r()},s.ticks=i=>{const d=r();let u=d[0],p=d[d.length-1];const f=p0){for(;y<=_;++y)for(b=1;bp)break;k.push(w)}}else for(;y<=_;++y)for(b=n-1;b>=1;--b)if(w=y>0?b/o(-y):b*o(y),!(wp)break;k.push(w)}k.length*2{if(i==null&&(i=10),d==null&&(d=n===10?"s":","),typeof d!="function"&&(!(n%1)&&(d=B6(d)).precision==null&&(d.trim=!0),d=c2e(d)),i===1/0)return d;const u=Math.max(1,n*i/s.ticks().length);return p=>{let f=p/o(Math.round(a(p)));return f*nr(HYe(r(),{floor:i=>o(Math.floor(a(i))),ceil:i=>o(Math.ceil(a(i)))})),s}function WYe(){const t=d2e(uce()).domain([1,10]);return t.copy=()=>dD(t,WYe()).base(t.base()),zf.apply(t,arguments),t}function oIe(t){return function(s){return Math.sign(s)*Math.log1p(Math.abs(s/t))}}function lIe(t){return function(s){return Math.sign(s)*Math.expm1(Math.abs(s))*t}}function u2e(t){var s=1,r=t(oIe(s),lIe(s));return r.constant=function(n){return arguments.length?t(oIe(s=+n),lIe(s)):s},nb(r)}function GYe(){var t=u2e(uce());return t.copy=function(){return dD(t,GYe()).constant(t.constant())},zf.apply(t,arguments)}function cIe(t){return function(s){return s<0?-Math.pow(-s,t):Math.pow(s,t)}}function dJt(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function uJt(t){return t<0?-t*t:t*t}function h2e(t){var s=t($h,$h),r=1;function n(){return r===1?t($h,$h):r===.5?t(dJt,uJt):t(cIe(r),cIe(1/r))}return s.exponent=function(a){return arguments.length?(r=+a,n()):r},nb(s)}function m2e(){var t=h2e(uce());return t.copy=function(){return dD(t,m2e()).exponent(t.exponent())},zf.apply(t,arguments),t}function hJt(){return m2e.apply(null,arguments).exponent(.5)}function dIe(t){return Math.sign(t)*t*t}function mJt(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function KYe(){var t=o2e(),s=[0,1],r=!1,n;function a(o){var l=mJt(t(o));return isNaN(l)?n:r?Math.round(l):l}return a.invert=function(o){return t.invert(dIe(o))},a.domain=function(o){return arguments.length?(t.domain(o),a):t.domain()},a.range=function(o){return arguments.length?(t.range((s=Array.from(o,die)).map(dIe)),a):s.slice()},a.rangeRound=function(o){return a.range(o).round(!0)},a.round=function(o){return arguments.length?(r=!!o,a):r},a.clamp=function(o){return arguments.length?(t.clamp(o),a):t.clamp()},a.unknown=function(o){return arguments.length?(n=o,a):n},a.copy=function(){return KYe(t.domain(),s).round(r).clamp(t.clamp()).unknown(n)},zf.apply(a,arguments),nb(a)}function ZYe(){var t=[],s=[],r=[],n;function a(){var l=0,i=Math.max(1,s.length);for(r=new Array(i-1);++l0?r[i-1]:t[0],i=r?[n[r-1],s]:[n[u-1],n[u]]},l.unknown=function(d){return arguments.length&&(o=d),l},l.thresholds=function(){return n.slice()},l.copy=function(){return YYe().domain([t,s]).range(a).unknown(o)},zf.apply(nb(l),arguments)}function XYe(){var t=[.5],s=[0,1],r,n=1;function a(o){return o!=null&&o<=o?s[lD(t,o,0,n)]:r}return a.domain=function(o){return arguments.length?(t=Array.from(o),n=Math.min(t.length,s.length-1),a):t.slice()},a.range=function(o){return arguments.length?(s=Array.from(o),n=Math.min(t.length,s.length-1),a):s.slice()},a.invertExtent=function(o){var l=s.indexOf(o);return[t[l-1],t[l]]},a.unknown=function(o){return arguments.length?(r=o,a):r},a.copy=function(){return XYe().domain(t).range(s).unknown(r)},zf.apply(a,arguments)}const _pe=new Date,bpe=new Date;function Xd(t,s,r,n){function a(o){return t(o=arguments.length===0?new Date:new Date(+o)),o}return a.floor=o=>(t(o=new Date(+o)),o),a.ceil=o=>(t(o=new Date(o-1)),s(o,1),t(o),o),a.round=o=>{const l=a(o),i=a.ceil(o);return o-l(s(o=new Date(+o),l==null?1:Math.floor(l)),o),a.range=(o,l,i)=>{const d=[];if(o=a.ceil(o),i=i==null?1:Math.floor(i),!(o0))return d;let u;do d.push(u=new Date(+o)),s(o,i),t(o);while(uXd(l=>{if(l>=l)for(;t(l),!o(l);)l.setTime(l-1)},(l,i)=>{if(l>=l)if(i<0)for(;++i<=0;)for(;s(l,-1),!o(l););else for(;--i>=0;)for(;s(l,1),!o(l););}),r&&(a.count=(o,l)=>(_pe.setTime(+o),bpe.setTime(+l),t(_pe),t(bpe),Math.floor(r(_pe,bpe))),a.every=o=>(o=Math.floor(o),!isFinite(o)||!(o>0)?null:o>1?a.filter(n?l=>n(l)%o===0:l=>a.count(0,l)%o===0):a)),a}const mie=Xd(()=>{},(t,s)=>{t.setTime(+t+s)},(t,s)=>s-t);mie.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Xd(s=>{s.setTime(Math.floor(s/t)*t)},(s,r)=>{s.setTime(+s+r*t)},(s,r)=>(r-s)/t):mie);mie.range;const S0=1e3,pf=S0*60,C0=pf*60,av=C0*24,p2e=av*7,uIe=av*30,wpe=av*365,VN=Xd(t=>{t.setTime(t-t.getMilliseconds())},(t,s)=>{t.setTime(+t+s*S0)},(t,s)=>(s-t)/S0,t=>t.getUTCSeconds());VN.range;const f2e=Xd(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*S0)},(t,s)=>{t.setTime(+t+s*pf)},(t,s)=>(s-t)/pf,t=>t.getMinutes());f2e.range;const g2e=Xd(t=>{t.setUTCSeconds(0,0)},(t,s)=>{t.setTime(+t+s*pf)},(t,s)=>(s-t)/pf,t=>t.getUTCMinutes());g2e.range;const x2e=Xd(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*S0-t.getMinutes()*pf)},(t,s)=>{t.setTime(+t+s*C0)},(t,s)=>(s-t)/C0,t=>t.getHours());x2e.range;const y2e=Xd(t=>{t.setUTCMinutes(0,0,0)},(t,s)=>{t.setTime(+t+s*C0)},(t,s)=>(s-t)/C0,t=>t.getUTCHours());y2e.range;const uD=Xd(t=>t.setHours(0,0,0,0),(t,s)=>t.setDate(t.getDate()+s),(t,s)=>(s-t-(s.getTimezoneOffset()-t.getTimezoneOffset())*pf)/av,t=>t.getDate()-1);uD.range;const hce=Xd(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/av,t=>t.getUTCDate()-1);hce.range;const QYe=Xd(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/av,t=>Math.floor(t/av));QYe.range;function pS(t){return Xd(s=>{s.setDate(s.getDate()-(s.getDay()+7-t)%7),s.setHours(0,0,0,0)},(s,r)=>{s.setDate(s.getDate()+r*7)},(s,r)=>(r-s-(r.getTimezoneOffset()-s.getTimezoneOffset())*pf)/p2e)}const mce=pS(0),pie=pS(1),pJt=pS(2),fJt=pS(3),q3=pS(4),gJt=pS(5),xJt=pS(6);mce.range;pie.range;pJt.range;fJt.range;q3.range;gJt.range;xJt.range;function fS(t){return Xd(s=>{s.setUTCDate(s.getUTCDate()-(s.getUTCDay()+7-t)%7),s.setUTCHours(0,0,0,0)},(s,r)=>{s.setUTCDate(s.getUTCDate()+r*7)},(s,r)=>(r-s)/p2e)}const pce=fS(0),fie=fS(1),yJt=fS(2),vJt=fS(3),U3=fS(4),_Jt=fS(5),bJt=fS(6);pce.range;fie.range;yJt.range;vJt.range;U3.range;_Jt.range;bJt.range;const v2e=Xd(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,s)=>{t.setMonth(t.getMonth()+s)},(t,s)=>s.getMonth()-t.getMonth()+(s.getFullYear()-t.getFullYear())*12,t=>t.getMonth());v2e.range;const _2e=Xd(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCMonth(t.getUTCMonth()+s)},(t,s)=>s.getUTCMonth()-t.getUTCMonth()+(s.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());_2e.range;const iv=Xd(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,s)=>{t.setFullYear(t.getFullYear()+s)},(t,s)=>s.getFullYear()-t.getFullYear(),t=>t.getFullYear());iv.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Xd(s=>{s.setFullYear(Math.floor(s.getFullYear()/t)*t),s.setMonth(0,1),s.setHours(0,0,0,0)},(s,r)=>{s.setFullYear(s.getFullYear()+r*t)});iv.range;const ov=Xd(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCFullYear(t.getUTCFullYear()+s)},(t,s)=>s.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());ov.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Xd(s=>{s.setUTCFullYear(Math.floor(s.getUTCFullYear()/t)*t),s.setUTCMonth(0,1),s.setUTCHours(0,0,0,0)},(s,r)=>{s.setUTCFullYear(s.getUTCFullYear()+r*t)});ov.range;function JYe(t,s,r,n,a,o){const l=[[VN,1,S0],[VN,5,5*S0],[VN,15,15*S0],[VN,30,30*S0],[o,1,pf],[o,5,5*pf],[o,15,15*pf],[o,30,30*pf],[a,1,C0],[a,3,3*C0],[a,6,6*C0],[a,12,12*C0],[n,1,av],[n,2,2*av],[r,1,p2e],[s,1,uIe],[s,3,3*uIe],[t,1,wpe]];function i(u,p,f){const y=pj).right(l,y);if(_===l.length)return t.every(Xye(u/wpe,p/wpe,f));if(_===0)return mie.every(Math.max(Xye(u,p,f),1));const[b,w]=l[y/l[_-1][2]53)return null;"w"in De||(De.w=1),"Z"in De?(me=Npe(yE(De.y,0,1)),Xe=me.getUTCDay(),me=Xe>4||Xe===0?fie.ceil(me):fie(me),me=hce.offset(me,(De.V-1)*7),De.y=me.getUTCFullYear(),De.m=me.getUTCMonth(),De.d=me.getUTCDate()+(De.w+6)%7):(me=jpe(yE(De.y,0,1)),Xe=me.getDay(),me=Xe>4||Xe===0?pie.ceil(me):pie(me),me=uD.offset(me,(De.V-1)*7),De.y=me.getFullYear(),De.m=me.getMonth(),De.d=me.getDate()+(De.w+6)%7)}else("W"in De||"U"in De)&&("w"in De||(De.w="u"in De?De.u%7:"W"in De?1:0),Xe="Z"in De?Npe(yE(De.y,0,1)).getUTCDay():jpe(yE(De.y,0,1)).getDay(),De.m=0,De.d="W"in De?(De.w+6)%7+De.W*7-(Xe+5)%7:De.w+De.U*7-(Xe+6)%7);return"Z"in De?(De.H+=De.Z/100|0,De.M+=De.Z%100,Npe(De)):jpe(De)}}function q(Ae,Ue,ut,De){for(var Rt=0,me=Ue.length,Xe=ut.length,ot,nt;Rt=Xe)return-1;if(ot=Ue.charCodeAt(Rt++),ot===37){if(ot=Ue.charAt(Rt++),nt=L[ot in hIe?Ue.charAt(Rt++):ot],!nt||(De=nt(Ae,ut,De))<0)return-1}else if(ot!=ut.charCodeAt(De++))return-1}return De}function U(Ae,Ue,ut){var De=u.exec(Ue.slice(ut));return De?(Ae.p=p.get(De[0].toLowerCase()),ut+De[0].length):-1}function H(Ae,Ue,ut){var De=_.exec(Ue.slice(ut));return De?(Ae.w=b.get(De[0].toLowerCase()),ut+De[0].length):-1}function Y(Ae,Ue,ut){var De=f.exec(Ue.slice(ut));return De?(Ae.w=y.get(De[0].toLowerCase()),ut+De[0].length):-1}function se(Ae,Ue,ut){var De=k.exec(Ue.slice(ut));return De?(Ae.m=S.get(De[0].toLowerCase()),ut+De[0].length):-1}function te(Ae,Ue,ut){var De=w.exec(Ue.slice(ut));return De?(Ae.m=j.get(De[0].toLowerCase()),ut+De[0].length):-1}function Q(Ae,Ue,ut){return q(Ae,s,Ue,ut)}function de(Ae,Ue,ut){return q(Ae,r,Ue,ut)}function re(Ae,Ue,ut){return q(Ae,n,Ue,ut)}function ae(Ae){return l[Ae.getDay()]}function le(Ae){return o[Ae.getDay()]}function he(Ae){return d[Ae.getMonth()]}function be(Ae){return i[Ae.getMonth()]}function _e(Ae){return a[+(Ae.getHours()>=12)]}function je(Ae){return 1+~~(Ae.getMonth()/3)}function Ne(Ae){return l[Ae.getUTCDay()]}function Ge(Ae){return o[Ae.getUTCDay()]}function we(Ae){return d[Ae.getUTCMonth()]}function Me(Ae){return i[Ae.getUTCMonth()]}function Te(Ae){return a[+(Ae.getUTCHours()>=12)]}function Fe(Ae){return 1+~~(Ae.getUTCMonth()/3)}return{format:function(Ae){var Ue=R(Ae+="",T);return Ue.toString=function(){return Ae},Ue},parse:function(Ae){var Ue=$(Ae+="",!1);return Ue.toString=function(){return Ae},Ue},utcFormat:function(Ae){var Ue=R(Ae+="",I);return Ue.toString=function(){return Ae},Ue},utcParse:function(Ae){var Ue=$(Ae+="",!0);return Ue.toString=function(){return Ae},Ue}}}var hIe={"-":"",_:" ",0:"0"},ju=/^\s*\d+/,CJt=/^%/,MJt=/[\\^$*+?|[\]().{}]/g;function Oo(t,s,r){var n=t<0?"-":"",a=(n?-t:t)+"",o=a.length;return n+(o[s.toLowerCase(),r]))}function AJt(t,s,r){var n=ju.exec(s.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function EJt(t,s,r){var n=ju.exec(s.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function PJt(t,s,r){var n=ju.exec(s.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function IJt(t,s,r){var n=ju.exec(s.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function LJt(t,s,r){var n=ju.exec(s.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function mIe(t,s,r){var n=ju.exec(s.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function pIe(t,s,r){var n=ju.exec(s.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function DJt(t,s,r){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(s.slice(r,r+6));return n?(t.Z=n[1]?0:-(n[2]+(n[3]||"00")),r+n[0].length):-1}function OJt(t,s,r){var n=ju.exec(s.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function RJt(t,s,r){var n=ju.exec(s.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function fIe(t,s,r){var n=ju.exec(s.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function FJt(t,s,r){var n=ju.exec(s.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function gIe(t,s,r){var n=ju.exec(s.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function zJt(t,s,r){var n=ju.exec(s.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function BJt(t,s,r){var n=ju.exec(s.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function $Jt(t,s,r){var n=ju.exec(s.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function qJt(t,s,r){var n=ju.exec(s.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function UJt(t,s,r){var n=CJt.exec(s.slice(r,r+1));return n?r+n[0].length:-1}function VJt(t,s,r){var n=ju.exec(s.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function HJt(t,s,r){var n=ju.exec(s.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function xIe(t,s){return Oo(t.getDate(),s,2)}function WJt(t,s){return Oo(t.getHours(),s,2)}function GJt(t,s){return Oo(t.getHours()%12||12,s,2)}function KJt(t,s){return Oo(1+uD.count(iv(t),t),s,3)}function eXe(t,s){return Oo(t.getMilliseconds(),s,3)}function ZJt(t,s){return eXe(t,s)+"000"}function YJt(t,s){return Oo(t.getMonth()+1,s,2)}function XJt(t,s){return Oo(t.getMinutes(),s,2)}function QJt(t,s){return Oo(t.getSeconds(),s,2)}function JJt(t){var s=t.getDay();return s===0?7:s}function ees(t,s){return Oo(mce.count(iv(t)-1,t),s,2)}function tXe(t){var s=t.getDay();return s>=4||s===0?q3(t):q3.ceil(t)}function tes(t,s){return t=tXe(t),Oo(q3.count(iv(t),t)+(iv(t).getDay()===4),s,2)}function ses(t){return t.getDay()}function res(t,s){return Oo(pie.count(iv(t)-1,t),s,2)}function nes(t,s){return Oo(t.getFullYear()%100,s,2)}function aes(t,s){return t=tXe(t),Oo(t.getFullYear()%100,s,2)}function ies(t,s){return Oo(t.getFullYear()%1e4,s,4)}function oes(t,s){var r=t.getDay();return t=r>=4||r===0?q3(t):q3.ceil(t),Oo(t.getFullYear()%1e4,s,4)}function les(t){var s=t.getTimezoneOffset();return(s>0?"-":(s*=-1,"+"))+Oo(s/60|0,"0",2)+Oo(s%60,"0",2)}function yIe(t,s){return Oo(t.getUTCDate(),s,2)}function ces(t,s){return Oo(t.getUTCHours(),s,2)}function des(t,s){return Oo(t.getUTCHours()%12||12,s,2)}function ues(t,s){return Oo(1+hce.count(ov(t),t),s,3)}function sXe(t,s){return Oo(t.getUTCMilliseconds(),s,3)}function hes(t,s){return sXe(t,s)+"000"}function mes(t,s){return Oo(t.getUTCMonth()+1,s,2)}function pes(t,s){return Oo(t.getUTCMinutes(),s,2)}function fes(t,s){return Oo(t.getUTCSeconds(),s,2)}function ges(t){var s=t.getUTCDay();return s===0?7:s}function xes(t,s){return Oo(pce.count(ov(t)-1,t),s,2)}function rXe(t){var s=t.getUTCDay();return s>=4||s===0?U3(t):U3.ceil(t)}function yes(t,s){return t=rXe(t),Oo(U3.count(ov(t),t)+(ov(t).getUTCDay()===4),s,2)}function ves(t){return t.getUTCDay()}function _es(t,s){return Oo(fie.count(ov(t)-1,t),s,2)}function bes(t,s){return Oo(t.getUTCFullYear()%100,s,2)}function wes(t,s){return t=rXe(t),Oo(t.getUTCFullYear()%100,s,2)}function jes(t,s){return Oo(t.getUTCFullYear()%1e4,s,4)}function Nes(t,s){var r=t.getUTCDay();return t=r>=4||r===0?U3(t):U3.ceil(t),Oo(t.getUTCFullYear()%1e4,s,4)}function kes(){return"+0000"}function vIe(){return"%"}function _Ie(t){return+t}function bIe(t){return Math.floor(+t/1e3)}var x4,nXe,aXe;Ses({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function Ses(t){return x4=SJt(t),nXe=x4.format,x4.parse,aXe=x4.utcFormat,x4.utcParse,x4}function Ces(t){return new Date(t)}function Mes(t){return t instanceof Date?+t:+new Date(+t)}function b2e(t,s,r,n,a,o,l,i,d,u){var p=o2e(),f=p.invert,y=p.domain,_=u(".%L"),b=u(":%S"),w=u("%I:%M"),j=u("%I %p"),k=u("%a %d"),S=u("%b %d"),T=u("%B"),I=u("%Y");function L(R){return(d(R)s(a/(t.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,o)=>xQt(t,o/n))},r.copy=function(){return cXe(s).domain(t)},mv.apply(r,arguments)}function gce(){var t=0,s=.5,r=1,n=1,a,o,l,i,d,u=$h,p,f=!1,y;function _(w){return isNaN(w=+w)?y:(w=.5+((w=+p(w))-o)*(n*ws}var mXe=Des,Oes=xce,Res=mXe,Fes=KM;function zes(t){return t&&t.length?Oes(t,Fes,Res):void 0}var Bes=zes;const yce=_o(Bes);function $es(t,s){return tt.e^o.s<0?1:-1;for(n=o.d.length,a=t.d.length,s=0,r=nt.d[s]^o.s<0?1:-1;return n===a?0:n>a^o.s<0?1:-1};Xn.decimalPlaces=Xn.dp=function(){var t=this,s=t.d.length-1,r=(s-t.e)*ec;if(s=t.d[s],s)for(;s%10==0;s/=10)r--;return r<0?0:r};Xn.dividedBy=Xn.div=function(t){return G0(this,new this.constructor(t))};Xn.dividedToIntegerBy=Xn.idiv=function(t){var s=this,r=s.constructor;return yl(G0(s,new r(t),0,1),r.precision)};Xn.equals=Xn.eq=function(t){return!this.cmp(t)};Xn.exponent=function(){return Cd(this)};Xn.greaterThan=Xn.gt=function(t){return this.cmp(t)>0};Xn.greaterThanOrEqualTo=Xn.gte=function(t){return this.cmp(t)>=0};Xn.isInteger=Xn.isint=function(){return this.e>this.d.length-2};Xn.isNegative=Xn.isneg=function(){return this.s<0};Xn.isPositive=Xn.ispos=function(){return this.s>0};Xn.isZero=function(){return this.s===0};Xn.lessThan=Xn.lt=function(t){return this.cmp(t)<0};Xn.lessThanOrEqualTo=Xn.lte=function(t){return this.cmp(t)<1};Xn.logarithm=Xn.log=function(t){var s,r=this,n=r.constructor,a=n.precision,o=a+5;if(t===void 0)t=new n(10);else if(t=new n(t),t.s<1||t.eq(pp))throw Error(If+"NaN");if(r.s<1)throw Error(If+(r.s?"NaN":"-Infinity"));return r.eq(pp)?new n(0):(gc=!1,s=G0($6(r,o),$6(t,o),o),gc=!0,yl(s,a))};Xn.minus=Xn.sub=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?yXe(s,t):gXe(s,(t.s=-t.s,t))};Xn.modulo=Xn.mod=function(t){var s,r=this,n=r.constructor,a=n.precision;if(t=new n(t),!t.s)throw Error(If+"NaN");return r.s?(gc=!1,s=G0(r,t,0,1).times(t),gc=!0,r.minus(s)):yl(new n(r),a)};Xn.naturalExponential=Xn.exp=function(){return xXe(this)};Xn.naturalLogarithm=Xn.ln=function(){return $6(this)};Xn.negated=Xn.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Xn.plus=Xn.add=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?gXe(s,t):yXe(s,(t.s=-t.s,t))};Xn.precision=Xn.sd=function(t){var s,r,n,a=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(kk+t);if(s=Cd(a)+1,n=a.d.length-1,r=n*ec+1,n=a.d[n],n){for(;n%10==0;n/=10)r--;for(n=a.d[0];n>=10;n/=10)r++}return t&&s>r?s:r};Xn.squareRoot=Xn.sqrt=function(){var t,s,r,n,a,o,l,i=this,d=i.constructor;if(i.s<1){if(!i.s)return new d(0);throw Error(If+"NaN")}for(t=Cd(i),gc=!1,a=Math.sqrt(+i),a==0||a==1/0?(s=Wx(i.d),(s.length+t)%2==0&&(s+="0"),a=Math.sqrt(s),t=XM((t+1)/2)-(t<0||t%2),a==1/0?s="5e"+t:(s=a.toExponential(),s=s.slice(0,s.indexOf("e")+1)+t),n=new d(s)):n=new d(a.toString()),r=d.precision,a=l=r+3;;)if(o=n,n=o.plus(G0(i,o,l+2)).times(.5),Wx(o.d).slice(0,l)===(s=Wx(n.d)).slice(0,l)){if(s=s.slice(l-3,l+1),a==l&&s=="4999"){if(yl(o,r+1,0),o.times(o).eq(i)){n=o;break}}else if(s!="9999")break;l+=4}return gc=!0,yl(n,r)};Xn.times=Xn.mul=function(t){var s,r,n,a,o,l,i,d,u,p=this,f=p.constructor,y=p.d,_=(t=new f(t)).d;if(!p.s||!t.s)return new f(0);for(t.s*=p.s,r=p.e+t.e,d=y.length,u=_.length,d=0;){for(s=0,a=d+n;a>n;)i=o[a]+_[n]*y[a-n-1]+s,o[a--]=i%iu|0,s=i/iu|0;o[a]=(o[a]+s)%iu|0}for(;!o[--l];)o.pop();return s?++r:o.shift(),t.d=o,t.e=r,gc?yl(t,f.precision):t};Xn.toDecimalPlaces=Xn.todp=function(t,s){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(py(t,0,YM),s===void 0?s=n.rounding:py(s,0,8),yl(r,t+Cd(r)+1,s))};Xn.toExponential=function(t,s){var r,n=this,a=n.constructor;return t===void 0?r=Yk(n,!0):(py(t,0,YM),s===void 0?s=a.rounding:py(s,0,8),n=yl(new a(n),t+1,s),r=Yk(n,!0,t+1)),r};Xn.toFixed=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?Yk(a):(py(t,0,YM),s===void 0?s=o.rounding:py(s,0,8),n=yl(new o(a),t+Cd(a)+1,s),r=Yk(n.abs(),!1,t+Cd(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};Xn.toInteger=Xn.toint=function(){var t=this,s=t.constructor;return yl(new s(t),Cd(t)+1,s.rounding)};Xn.toNumber=function(){return+this};Xn.toPower=Xn.pow=function(t){var s,r,n,a,o,l,i=this,d=i.constructor,u=12,p=+(t=new d(t));if(!t.s)return new d(pp);if(i=new d(i),!i.s){if(t.s<1)throw Error(If+"Infinity");return i}if(i.eq(pp))return i;if(n=d.precision,t.eq(pp))return yl(i,n);if(s=t.e,r=t.d.length-1,l=s>=r,o=i.s,l){if((r=p<0?-p:p)<=fXe){for(a=new d(pp),s=Math.ceil(n/ec+4),gc=!1;r%2&&(a=a.times(i),NIe(a.d,s)),r=XM(r/2),r!==0;)i=i.times(i),NIe(i.d,s);return gc=!0,t.s<0?new d(pp).div(a):yl(a,n)}}else if(o<0)throw Error(If+"NaN");return o=o<0&&t.d[Math.max(s,r)]&1?-1:1,i.s=1,gc=!1,a=t.times($6(i,n+u)),gc=!0,a=xXe(a),a.s=o,a};Xn.toPrecision=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?(r=Cd(a),n=Yk(a,r<=o.toExpNeg||r>=o.toExpPos)):(py(t,1,YM),s===void 0?s=o.rounding:py(s,0,8),a=yl(new o(a),t,s),r=Cd(a),n=Yk(a,t<=r||r<=o.toExpNeg,t)),n};Xn.toSignificantDigits=Xn.tosd=function(t,s){var r=this,n=r.constructor;return t===void 0?(t=n.precision,s=n.rounding):(py(t,1,YM),s===void 0?s=n.rounding:py(s,0,8)),yl(new n(r),t,s)};Xn.toString=Xn.valueOf=Xn.val=Xn.toJSON=Xn[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,s=Cd(t),r=t.constructor;return Yk(t,s<=r.toExpNeg||s>=r.toExpPos)};function gXe(t,s){var r,n,a,o,l,i,d,u,p=t.constructor,f=p.precision;if(!t.s||!s.s)return s.s||(s=new p(t)),gc?yl(s,f):s;if(d=t.d,u=s.d,l=t.e,a=s.e,d=d.slice(),o=l-a,o){for(o<0?(n=d,o=-o,i=u.length):(n=u,a=l,i=d.length),l=Math.ceil(f/ec),i=l>i?l+1:i+1,o>i&&(o=i,n.length=1),n.reverse();o--;)n.push(0);n.reverse()}for(i=d.length,o=u.length,i-o<0&&(o=i,n=u,u=d,d=n),r=0;o;)r=(d[--o]=d[o]+u[o]+r)/iu|0,d[o]%=iu;for(r&&(d.unshift(r),++a),i=d.length;d[--i]==0;)d.pop();return s.d=d,s.e=a,gc?yl(s,f):s}function py(t,s,r){if(t!==~~t||tr)throw Error(kk+t)}function Wx(t){var s,r,n,a=t.length-1,o="",l=t[0];if(a>0){for(o+=l,s=1;sl?1:-1;else for(i=d=0;ia[i]?1:-1;break}return d}function r(n,a,o){for(var l=0;o--;)n[o]-=l,l=n[o]1;)n.shift()}return function(n,a,o,l){var i,d,u,p,f,y,_,b,w,j,k,S,T,I,L,R,$,q,U=n.constructor,H=n.s==a.s?1:-1,Y=n.d,se=a.d;if(!n.s)return new U(n);if(!a.s)throw Error(If+"Division by zero");for(d=n.e-a.e,$=se.length,L=Y.length,_=new U(H),b=_.d=[],u=0;se[u]==(Y[u]||0);)++u;if(se[u]>(Y[u]||0)&&--d,o==null?S=o=U.precision:l?S=o+(Cd(n)-Cd(a))+1:S=o,S<0)return new U(0);if(S=S/ec+2|0,u=0,$==1)for(p=0,se=se[0],S++;(u1&&(se=t(se,p),Y=t(Y,p),$=se.length,L=Y.length),I=$,w=Y.slice(0,$),j=w.length;j<$;)w[j++]=0;q=se.slice(),q.unshift(0),R=se[0],se[1]>=iu/2&&++R;do p=0,i=s(se,w,$,j),i<0?(k=w[0],$!=j&&(k=k*iu+(w[1]||0)),p=k/R|0,p>1?(p>=iu&&(p=iu-1),f=t(se,p),y=f.length,j=w.length,i=s(f,w,y,j),i==1&&(p--,r(f,$16)throw Error(N2e+Cd(t));if(!t.s)return new p(pp);for(gc=!1,i=f,l=new p(.03125);t.abs().gte(.1);)t=t.times(l),u+=5;for(n=Math.log(jN(2,u))/Math.LN10*2+5|0,i+=n,r=a=o=new p(pp),p.precision=i;;){if(a=yl(a.times(t),i),r=r.times(++d),l=o.plus(G0(a,r,i)),Wx(l.d).slice(0,i)===Wx(o.d).slice(0,i)){for(;u--;)o=yl(o.times(o),i);return p.precision=f,s==null?(gc=!0,yl(o,f)):o}o=l}}function Cd(t){for(var s=t.e*ec,r=t.d[0];r>=10;r/=10)s++;return s}function kpe(t,s,r){if(s>t.LN10.sd())throw gc=!0,r&&(t.precision=r),Error(If+"LN10 precision limit exceeded");return yl(new t(t.LN10),s)}function b1(t){for(var s="";t--;)s+="0";return s}function $6(t,s){var r,n,a,o,l,i,d,u,p,f=1,y=10,_=t,b=_.d,w=_.constructor,j=w.precision;if(_.s<1)throw Error(If+(_.s?"NaN":"-Infinity"));if(_.eq(pp))return new w(0);if(s==null?(gc=!1,u=j):u=s,_.eq(10))return s==null&&(gc=!0),kpe(w,u);if(u+=y,w.precision=u,r=Wx(b),n=r.charAt(0),o=Cd(_),Math.abs(o)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)_=_.times(t),r=Wx(_.d),n=r.charAt(0),f++;o=Cd(_),n>1?(_=new w("0."+r),o++):_=new w(n+"."+r.slice(1))}else return d=kpe(w,u+2,j).times(o+""),_=$6(new w(n+"."+r.slice(1)),u-y).plus(d),w.precision=j,s==null?(gc=!0,yl(_,j)):_;for(i=l=_=G0(_.minus(pp),_.plus(pp),u),p=yl(_.times(_),u),a=3;;){if(l=yl(l.times(p),u),d=i.plus(G0(l,new w(a),u)),Wx(d.d).slice(0,u)===Wx(i.d).slice(0,u))return i=i.times(2),o!==0&&(i=i.plus(kpe(w,u+2,j).times(o+""))),i=G0(i,new w(f),u),w.precision=j,s==null?(gc=!0,yl(i,j)):i;i=d,a+=2}}function jIe(t,s){var r,n,a;for((r=s.indexOf("."))>-1&&(s=s.replace(".","")),(n=s.search(/e/i))>0?(r<0&&(r=n),r+=+s.slice(n+1),s=s.substring(0,n)):r<0&&(r=s.length),n=0;s.charCodeAt(n)===48;)++n;for(a=s.length;s.charCodeAt(a-1)===48;)--a;if(s=s.slice(n,a),s){if(a-=n,r=r-n-1,t.e=XM(r/ec),t.d=[],n=(r+1)%ec,r<0&&(n+=ec),ngie||t.e<-gie))throw Error(N2e+r)}else t.s=0,t.e=0,t.d=[0];return t}function yl(t,s,r){var n,a,o,l,i,d,u,p,f=t.d;for(l=1,o=f[0];o>=10;o/=10)l++;if(n=s-l,n<0)n+=ec,a=s,u=f[p=0];else{if(p=Math.ceil((n+1)/ec),o=f.length,p>=o)return t;for(u=o=f[p],l=1;o>=10;o/=10)l++;n%=ec,a=n-ec+l}if(r!==void 0&&(o=jN(10,l-a-1),i=u/o%10|0,d=s<0||f[p+1]!==void 0||u%o,d=r<4?(i||d)&&(r==0||r==(t.s<0?3:2)):i>5||i==5&&(r==4||d||r==6&&(n>0?a>0?u/jN(10,l-a):0:f[p-1])%10&1||r==(t.s<0?8:7))),s<1||!f[0])return d?(o=Cd(t),f.length=1,s=s-o-1,f[0]=jN(10,(ec-s%ec)%ec),t.e=XM(-s/ec)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(n==0?(f.length=p,o=1,p--):(f.length=p+1,o=jN(10,ec-n),f[p]=a>0?(u/jN(10,l-a)%jN(10,a)|0)*o:0),d)for(;;)if(p==0){(f[0]+=o)==iu&&(f[0]=1,++t.e);break}else{if(f[p]+=o,f[p]!=iu)break;f[p--]=0,o=1}for(n=f.length;f[--n]===0;)f.pop();if(gc&&(t.e>gie||t.e<-gie))throw Error(N2e+Cd(t));return t}function yXe(t,s){var r,n,a,o,l,i,d,u,p,f,y=t.constructor,_=y.precision;if(!t.s||!s.s)return s.s?s.s=-s.s:s=new y(t),gc?yl(s,_):s;if(d=t.d,f=s.d,n=s.e,u=t.e,d=d.slice(),l=u-n,l){for(p=l<0,p?(r=d,l=-l,i=f.length):(r=f,n=u,i=d.length),a=Math.max(Math.ceil(_/ec),i)+2,l>a&&(l=a,r.length=1),r.reverse(),a=l;a--;)r.push(0);r.reverse()}else{for(a=d.length,i=f.length,p=a0;--a)d[i++]=0;for(a=f.length;a>l;){if(d[--a]0?o=o.charAt(0)+"."+o.slice(1)+b1(n):l>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(a<0?"e":"e+")+a):a<0?(o="0."+b1(-a-1)+o,r&&(n=r-l)>0&&(o+=b1(n))):a>=l?(o+=b1(a+1-l),r&&(n=r-a-1)>0&&(o=o+"."+b1(n))):((n=a+1)0&&(a+1===l&&(o+="."),o+=b1(n))),t.s<0?"-"+o:o}function NIe(t,s){if(t.length>s)return t.length=s,!0}function vXe(t){var s,r,n;function a(o){var l=this;if(!(l instanceof a))return new a(o);if(l.constructor=a,o instanceof a){l.s=o.s,l.e=o.e,l.d=(o=o.d)?o.slice():o;return}if(typeof o=="number"){if(o*0!==0)throw Error(kk+o);if(o>0)l.s=1;else if(o<0)o=-o,l.s=-1;else{l.s=0,l.e=0,l.d=[0];return}if(o===~~o&&o<1e7){l.e=0,l.d=[o];return}return jIe(l,o.toString())}else if(typeof o!="string")throw Error(kk+o);if(o.charCodeAt(0)===45?(o=o.slice(1),l.s=-1):l.s=1,lts.test(o))jIe(l,o);else throw Error(kk+o)}if(a.prototype=Xn,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.clone=vXe,a.config=a.set=cts,t===void 0&&(t={}),t)for(n=["precision","rounding","toExpNeg","toExpPos","LN10"],s=0;s=a[s+1]&&n<=a[s+2])this[r]=n;else throw Error(kk+r+": "+n);if((n=t[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(kk+r+": "+n);return this}var k2e=vXe(ots);pp=new k2e(1);const il=k2e;function dts(t){return pts(t)||mts(t)||hts(t)||uts()}function uts(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hts(t,s){if(t){if(typeof t=="string")return s0e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s0e(t,s)}}function mts(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function pts(t){if(Array.isArray(t))return s0e(t)}function s0e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=s?r.apply(void 0,a):t(s-l,kIe(function(){for(var i=arguments.length,d=new Array(i),u=0;ut.length)&&(s=t.length);for(var r=0,n=new Array(s);r"u"||!(Symbol.iterator in Object(t)))){var r=[],n=!0,a=!1,o=void 0;try{for(var l=t[Symbol.iterator](),i;!(n=(i=l.next()).done)&&(r.push(i.value),!(s&&r.length===s));n=!0);}catch(d){a=!0,o=d}finally{try{!n&&l.return!=null&&l.return()}finally{if(a)throw o}}return r}}function Tts(t){if(Array.isArray(t))return t}function NXe(t){var s=q6(t,2),r=s[0],n=s[1],a=r,o=n;return r>n&&(a=n,o=r),[a,o]}function kXe(t,s,r){if(t.lte(0))return new il(0);var n=bce.getDigitCount(t.toNumber()),a=new il(10).pow(n),o=t.div(a),l=n!==1?.05:.1,i=new il(Math.ceil(o.div(l).toNumber())).add(r).mul(l),d=i.mul(a);return s?d:new il(Math.ceil(d))}function Ats(t,s,r){var n=1,a=new il(t);if(!a.isint()&&r){var o=Math.abs(t);o<1?(n=new il(10).pow(bce.getDigitCount(t)-1),a=new il(Math.floor(a.div(n).toNumber())).mul(n)):o>1&&(a=new il(Math.floor(t)))}else t===0?a=new il(Math.floor((s-1)/2)):r||(a=new il(Math.floor(t)));var l=Math.floor((s-1)/2),i=yts(xts(function(d){return a.add(new il(d-l).mul(n)).toNumber()}),r0e);return i(0,s)}function SXe(t,s,r,n){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((s-t)/(r-1)))return{step:new il(0),tickMin:new il(0),tickMax:new il(0)};var o=kXe(new il(s).sub(t).div(r-1),n,a),l;t<=0&&s>=0?l=new il(0):(l=new il(t).add(s).div(2),l=l.sub(new il(l).mod(o)));var i=Math.ceil(l.sub(t).div(o).toNumber()),d=Math.ceil(new il(s).sub(l).div(o).toNumber()),u=i+d+1;return u>r?SXe(t,s,r,n,a+1):(u0?d+(r-u):d,i=s>0?i:i+(r-u)),{step:o,tickMin:l.sub(new il(i).mul(o)),tickMax:l.add(new il(d).mul(o))})}function Ets(t){var s=q6(t,2),r=s[0],n=s[1],a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=Math.max(a,2),i=NXe([r,n]),d=q6(i,2),u=d[0],p=d[1];if(u===-1/0||p===1/0){var f=p===1/0?[u].concat(a0e(r0e(0,a-1).map(function(){return 1/0}))):[].concat(a0e(r0e(0,a-1).map(function(){return-1/0})),[p]);return r>n?n0e(f):f}if(u===p)return Ats(u,a,o);var y=SXe(u,p,l,o),_=y.step,b=y.tickMin,w=y.tickMax,j=bce.rangeStep(b,w.add(new il(.1).mul(_)),_);return r>n?n0e(j):j}function Pts(t,s){var r=q6(t,2),n=r[0],a=r[1],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=NXe([n,a]),i=q6(l,2),d=i[0],u=i[1];if(d===-1/0||u===1/0)return[n,a];if(d===u)return[d];var p=Math.max(s,2),f=kXe(new il(u).sub(d).div(p-1),o,0),y=[].concat(a0e(bce.rangeStep(new il(d),new il(u).sub(new il(.99).mul(f)),f)),[u]);return n>a?n0e(y):y}var Its=wXe(Ets),Lts=wXe(Pts),Dts="Invariant failed";function Xk(t,s){throw new Error(Dts)}var Ots=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function V3(t){"@babel/helpers - typeof";return V3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},V3(t)}function xie(){return xie=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Uts(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Vts(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Hts(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0,l=-1,i=(r=n==null?void 0:n.length)!==null&&r!==void 0?r:0;if(i<=1)return 0;if(o&&o.axisType==="angleAxis"&&Math.abs(Math.abs(o.range[1]-o.range[0])-360)<=1e-6)for(var d=o.range,u=0;u0?a[u-1].coordinate:a[i-1].coordinate,f=a[u].coordinate,y=u>=i-1?a[0].coordinate:a[u+1].coordinate,_=void 0;if(zh(f-p)!==zh(y-f)){var b=[];if(zh(y-f)===zh(d[1]-d[0])){_=y;var w=f+d[1]-d[0];b[0]=Math.min(w,(w+p)/2),b[1]=Math.max(w,(w+p)/2)}else{_=p;var j=y+d[1]-d[0];b[0]=Math.min(f,(j+f)/2),b[1]=Math.max(f,(j+f)/2)}var k=[Math.min(f,(_+f)/2),Math.max(f,(_+f)/2)];if(s>k[0]&&s<=k[1]||s>=b[0]&&s<=b[1]){l=a[u].index;break}}else{var S=Math.min(p,y),T=Math.max(p,y);if(s>(S+f)/2&&s<=(T+f)/2){l=a[u].index;break}}}else for(var I=0;I0&&I(n[I].coordinate+n[I-1].coordinate)/2&&s<=(n[I].coordinate+n[I+1].coordinate)/2||I===i-1&&s>(n[I].coordinate+n[I-1].coordinate)/2){l=n[I].index;break}return l},S2e=function(s){var r,n=s,a=n.type.displayName,o=(r=s.type)!==null&&r!==void 0&&r.defaultProps?Bc(Bc({},s.type.defaultProps),s.props):s.props,l=o.stroke,i=o.fill,d;switch(a){case"Line":d=l;break;case"Area":case"Radar":d=l&&l!=="none"?l:i;break;default:d=i;break}return d},lss=function(s){var r=s.barSize,n=s.totalSize,a=s.stackGroups,o=a===void 0?{}:a;if(!o)return{};for(var l={},i=Object.keys(o),d=0,u=i.length;d=0});if(k&&k.length){var S=k[0].type.defaultProps,T=S!==void 0?Bc(Bc({},S),k[0].props):k[0].props,I=T.barSize,L=T[j];l[L]||(l[L]=[]);var R=Ai(I)?r:I;l[L].push({item:k[0],stackList:k.slice(1),barSize:Ai(R)?void 0:Bh(R,n,0)})}}return l},css=function(s){var r=s.barGap,n=s.barCategoryGap,a=s.bandSize,o=s.sizeList,l=o===void 0?[]:o,i=s.maxBarSize,d=l.length;if(d<1)return null;var u=Bh(r,a,0,!0),p,f=[];if(l[0].barSize===+l[0].barSize){var y=!1,_=a/d,b=l.reduce(function(I,L){return I+L.barSize||0},0);b+=(d-1)*u,b>=a&&(b-=(d-1)*u,u=0),b>=a&&_>0&&(y=!0,_*=.9,b=d*_);var w=(a-b)/2>>0,j={offset:w-u,size:0};p=l.reduce(function(I,L){var R={item:L.item,position:{offset:j.offset+j.size+u,size:y?_:L.barSize}},$=[].concat(MIe(I),[R]);return j=$[$.length-1].position,L.stackList&&L.stackList.length&&L.stackList.forEach(function(q){$.push({item:q,position:j})}),$},f)}else{var k=Bh(n,a,0,!0);a-2*k-(d-1)*u<=0&&(u=0);var S=(a-2*k-(d-1)*u)/d;S>1&&(S>>=0);var T=i===+i?Math.min(S,i):S;p=l.reduce(function(I,L,R){var $=[].concat(MIe(I),[{item:L.item,position:{offset:k+(S+u)*R+(S-T)/2,size:T}}]);return L.stackList&&L.stackList.length&&L.stackList.forEach(function(q){$.push({item:q,position:$[$.length-1].position})}),$},f)}return p},dss=function(s,r,n,a){var o=n.children,l=n.width,i=n.margin,d=l-(i.left||0)-(i.right||0),u=AXe({children:o,legendWidth:d});if(u){var p=a||{},f=p.width,y=p.height,_=u.align,b=u.verticalAlign,w=u.layout;if((w==="vertical"||w==="horizontal"&&b==="middle")&&_!=="center"&&tn(s[_]))return Bc(Bc({},s),{},K5({},_,s[_]+(f||0)));if((w==="horizontal"||w==="vertical"&&_==="center")&&b!=="middle"&&tn(s[b]))return Bc(Bc({},s),{},K5({},b,s[b]+(y||0)))}return s},uss=function(s,r,n){return Ai(r)?!0:s==="horizontal"?r==="yAxis":s==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},EXe=function(s,r,n,a,o){var l=r.props.children,i=kp(l,mD).filter(function(u){return uss(a,o,u.props.direction)});if(i&&i.length){var d=i.map(function(u){return u.props.dataKey});return s.reduce(function(u,p){var f=$d(p,n);if(Ai(f))return u;var y=Array.isArray(f)?[vce(f),yce(f)]:[f,f],_=d.reduce(function(b,w){var j=$d(p,w,0),k=y[0]-Math.abs(Array.isArray(j)?j[0]:j),S=y[1]+Math.abs(Array.isArray(j)?j[1]:j);return[Math.min(k,b[0]),Math.max(S,b[1])]},[1/0,-1/0]);return[Math.min(_[0],u[0]),Math.max(_[1],u[1])]},[1/0,-1/0])}return null},hss=function(s,r,n,a,o){var l=r.map(function(i){return EXe(s,i,n,o,a)}).filter(function(i){return!Ai(i)});return l&&l.length?l.reduce(function(i,d){return[Math.min(i[0],d[0]),Math.max(i[1],d[1])]},[1/0,-1/0]):null},PXe=function(s,r,n,a,o){var l=r.map(function(d){var u=d.props.dataKey;return n==="number"&&u&&EXe(s,d,u,a)||NI(s,u,n,o)});if(n==="number")return l.reduce(function(d,u){return[Math.min(d[0],u[0]),Math.max(d[1],u[1])]},[1/0,-1/0]);var i={};return l.reduce(function(d,u){for(var p=0,f=u.length;p=2?zh(i[0]-i[1])*2*u:u,r&&(s.ticks||s.niceTicks)){var p=(s.ticks||s.niceTicks).map(function(f){var y=o?o.indexOf(f):f;return{coordinate:a(y)+u,value:f,offset:u}});return p.filter(function(f){return!aD(f.coordinate)})}return s.isCategorical&&s.categoricalDomain?s.categoricalDomain.map(function(f,y){return{coordinate:a(f)+u,value:f,index:y,offset:u}}):a.ticks&&!n?a.ticks(s.tickCount).map(function(f){return{coordinate:a(f)+u,value:f,offset:u}}):a.domain().map(function(f,y){return{coordinate:a(f)+u,value:o?o[f]:f,index:y,offset:u}})},Spe=new WeakMap,TR=function(s,r){if(typeof r!="function")return s;Spe.has(s)||Spe.set(s,new WeakMap);var n=Spe.get(s);if(n.has(r))return n.get(r);var a=function(){s.apply(void 0,arguments),r.apply(void 0,arguments)};return n.set(r,a),a},DXe=function(s,r,n){var a=s.scale,o=s.type,l=s.layout,i=s.axisType;if(a==="auto")return l==="radial"&&i==="radiusAxis"?{scale:O6(),realScaleType:"band"}:l==="radial"&&i==="angleAxis"?{scale:hie(),realScaleType:"linear"}:o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:jI(),realScaleType:"point"}:o==="category"?{scale:O6(),realScaleType:"band"}:{scale:hie(),realScaleType:"linear"};if(Gk(a)){var d="scale".concat(nce(a));return{scale:(wIe[d]||jI)(),realScaleType:wIe[d]?d:"point"}}return gi(a)?{scale:a}:{scale:jI(),realScaleType:"point"}},AIe=1e-4,OXe=function(s){var r=s.domain();if(!(!r||r.length<=2)){var n=r.length,a=s.range(),o=Math.min(a[0],a[1])-AIe,l=Math.max(a[0],a[1])+AIe,i=s(r[0]),d=s(r[n-1]);(il||dl)&&s.domain([r[0],r[n-1]])}},mss=function(s,r){if(!s)return null;for(var n=0,a=s.length;na)&&(o[1]=a),o[0]>a&&(o[0]=a),o[1]=0?(s[i][n][0]=o,s[i][n][1]=o+d,o=s[i][n][1]):(s[i][n][0]=l,s[i][n][1]=l+d,l=s[i][n][1])}},gss=function(s){var r=s.length;if(!(r<=0))for(var n=0,a=s[0].length;n=0?(s[l][n][0]=o,s[l][n][1]=o+i,o=s[l][n][1]):(s[l][n][0]=0,s[l][n][1]=0)}},xss={sign:fss,expand:Oqt,none:O3,silhouette:Rqt,wiggle:Fqt,positive:gss},yss=function(s,r,n){var a=r.map(function(i){return i.props.dataKey}),o=xss[n],l=Dqt().keys(a).value(function(i,d){return+$d(i,d,0)}).order(Iye).offset(o);return l(s)},vss=function(s,r,n,a,o,l){if(!s)return null;var i=l?r.reverse():r,d={},u=i.reduce(function(f,y){var _,b=(_=y.type)!==null&&_!==void 0&&_.defaultProps?Bc(Bc({},y.type.defaultProps),y.props):y.props,w=b.stackId,j=b.hide;if(j)return f;var k=b[n],S=f[k]||{hasStack:!1,stackGroups:{}};if(Ud(w)){var T=S.stackGroups[w]||{numericAxisId:n,cateAxisId:a,items:[]};T.items.push(y),S.hasStack=!0,S.stackGroups[w]=T}else S.stackGroups[HM("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[y]};return Bc(Bc({},f),{},K5({},k,S))},d),p={};return Object.keys(u).reduce(function(f,y){var _=u[y];if(_.hasStack){var b={};_.stackGroups=Object.keys(_.stackGroups).reduce(function(w,j){var k=_.stackGroups[j];return Bc(Bc({},w),{},K5({},j,{numericAxisId:n,cateAxisId:a,items:k.items,stackedData:yss(s,k.items,o)}))},b)}return Bc(Bc({},f),{},K5({},y,_))},p)},RXe=function(s,r){var n=r.realScaleType,a=r.type,o=r.tickCount,l=r.originalDomain,i=r.allowDecimals,d=n||r.scale;if(d!=="auto"&&d!=="linear")return null;if(o&&a==="number"&&l&&(l[0]==="auto"||l[1]==="auto")){var u=s.domain();if(!u.length)return null;var p=Its(u,o,i);return s.domain([vce(p),yce(p)]),{niceTicks:p}}if(o&&a==="number"){var f=s.domain(),y=Lts(f,o,i);return{niceTicks:y}}return null};function EIe(t){var s=t.axis,r=t.ticks,n=t.bandSize,a=t.entry,o=t.index,l=t.dataKey;if(s.type==="category"){if(!s.allowDuplicatedCategory&&s.dataKey&&!Ai(a[s.dataKey])){var i=Hae(r,"value",a[s.dataKey]);if(i)return i.coordinate+n/2}return r[o]?r[o].coordinate+n/2:null}var d=$d(a,Ai(l)?s.dataKey:l);return Ai(d)?null:s.scale(d)}var PIe=function(s){var r=s.axis,n=s.ticks,a=s.offset,o=s.bandSize,l=s.entry,i=s.index;if(r.type==="category")return n[i]?n[i].coordinate+a:null;var d=$d(l,r.dataKey,r.domain[i]);return Ai(d)?null:r.scale(d)-o/2+a},_ss=function(s){var r=s.numericAxis,n=r.scale.domain();if(r.type==="number"){var a=Math.min(n[0],n[1]),o=Math.max(n[0],n[1]);return a<=0&&o>=0?0:o<0?o:a}return n[0]},bss=function(s,r){var n,a=(n=s.type)!==null&&n!==void 0&&n.defaultProps?Bc(Bc({},s.type.defaultProps),s.props):s.props,o=a.stackId;if(Ud(o)){var l=r[o];if(l){var i=l.items.indexOf(s);return i>=0?l.stackedData[i]:null}}return null},wss=function(s){return s.reduce(function(r,n){return[vce(n.concat([r[0]]).filter(tn)),yce(n.concat([r[1]]).filter(tn))]},[1/0,-1/0])},FXe=function(s,r,n){return Object.keys(s).reduce(function(a,o){var l=s[o],i=l.stackedData,d=i.reduce(function(u,p){var f=wss(p.slice(r,n+1));return[Math.min(u[0],f[0]),Math.max(u[1],f[1])]},[1/0,-1/0]);return[Math.min(d[0],a[0]),Math.max(d[1],a[1])]},[1/0,-1/0]).map(function(a){return a===1/0||a===-1/0?0:a})},IIe=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,LIe=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,c0e=function(s,r,n){if(gi(s))return s(r,n);if(!Array.isArray(s))return r;var a=[];if(tn(s[0]))a[0]=n?s[0]:Math.min(s[0],r[0]);else if(IIe.test(s[0])){var o=+IIe.exec(s[0])[1];a[0]=r[0]-o}else gi(s[0])?a[0]=s[0](r[0]):a[0]=r[0];if(tn(s[1]))a[1]=n?s[1]:Math.max(s[1],r[1]);else if(LIe.test(s[1])){var l=+LIe.exec(s[1])[1];a[1]=r[1]+l}else gi(s[1])?a[1]=s[1](r[1]):a[1]=r[1];return a},vie=function(s,r,n){if(s&&s.scale&&s.scale.bandwidth){var a=s.scale.bandwidth();if(!n||a>0)return a}if(s&&r&&r.length>=2){for(var o=e2e(r,function(f){return f.coordinate}),l=1/0,i=1,d=o.length;it.length)&&(s=t.length);for(var r=0,n=new Array(s);r2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(s-(n.left||0)-(n.right||0)),Math.abs(r-(n.top||0)-(n.bottom||0)))/2},Ess=function(s,r,n,a,o){var l=s.width,i=s.height,d=s.startAngle,u=s.endAngle,p=Bh(s.cx,l,l/2),f=Bh(s.cy,i,i/2),y=$Xe(l,i,n),_=Bh(s.innerRadius,y,0),b=Bh(s.outerRadius,y,y*.8),w=Object.keys(r);return w.reduce(function(j,k){var S=r[k],T=S.domain,I=S.reversed,L;if(Ai(S.range))a==="angleAxis"?L=[d,u]:a==="radiusAxis"&&(L=[_,b]),I&&(L=[L[1],L[0]]);else{L=S.range;var R=L,$=kss(R,2);d=$[0],u=$[1]}var q=DXe(S,o),U=q.realScaleType,H=q.scale;H.domain(T).range(L),OXe(H);var Y=RXe(H,d0(d0({},S),{},{realScaleType:U})),se=d0(d0(d0({},S),Y),{},{range:L,radius:b,realScaleType:U,scale:H,cx:p,cy:f,innerRadius:_,outerRadius:b,startAngle:d,endAngle:u});return d0(d0({},j),{},BXe({},k,se))},{})},Pss=function(s,r){var n=s.x,a=s.y,o=r.x,l=r.y;return Math.sqrt(Math.pow(n-o,2)+Math.pow(a-l,2))},Iss=function(s,r){var n=s.x,a=s.y,o=r.cx,l=r.cy,i=Pss({x:n,y:a},{x:o,y:l});if(i<=0)return{radius:i};var d=(n-o)/i,u=Math.acos(d);return a>l&&(u=2*Math.PI-u),{radius:i,angle:Ass(u),angleInRadian:u}},Lss=function(s){var r=s.startAngle,n=s.endAngle,a=Math.floor(r/360),o=Math.floor(n/360),l=Math.min(a,o);return{startAngle:r-l*360,endAngle:n-l*360}},Dss=function(s,r){var n=r.startAngle,a=r.endAngle,o=Math.floor(n/360),l=Math.floor(a/360),i=Math.min(o,l);return s+i*360},FIe=function(s,r){var n=s.x,a=s.y,o=Iss({x:n,y:a},r),l=o.radius,i=o.angle,d=r.innerRadius,u=r.outerRadius;if(lu)return!1;if(l===0)return!0;var p=Lss(r),f=p.startAngle,y=p.endAngle,_=i,b;if(f<=y){for(;_>y;)_-=360;for(;_=f&&_<=y}else{for(;_>f;)_-=360;for(;_=y&&_<=f}return b?d0(d0({},r),{},{radius:l,angle:Dss(_,r)}):null},qXe=function(s){return!C.isValidElement(s)&&!gi(s)&&typeof s!="boolean"?s.className:""};function W6(t){"@babel/helpers - typeof";return W6=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},W6(t)}var Oss=["offset"];function Rss(t){return $ss(t)||Bss(t)||zss(t)||Fss()}function Fss(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zss(t,s){if(t){if(typeof t=="string")return d0e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d0e(t,s)}}function Bss(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function $ss(t){if(Array.isArray(t))return d0e(t)}function d0e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Uss(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function zIe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Id(t){for(var s=1;s=0?1:-1,T,I;a==="insideStart"?(T=_+S*l,I=w):a==="insideEnd"?(T=b-S*l,I=!w):a==="end"&&(T=b+S*l,I=w),I=k<=0?I:!I;var L=Fl(u,p,j,T),R=Fl(u,p,j,T+(I?1:-1)*359),$="M".concat(L.x,",").concat(L.y,` A`).concat(j,",").concat(j,",0,1,").concat(I?0:1,`, `).concat(R.x,",").concat(R.y),q=Ai(s.id)?HM("recharts-radial-line-"):s.id;return ht.createElement("text",G6({},n,{dominantBaseline:"central",className:Ii("recharts-radial-bar-label",i)}),ht.createElement("defs",null,ht.createElement("path",{id:q,d:$})),ht.createElement("textPath",{xlinkHref:"#".concat(q)},r))},Yss=function(s){var r=s.viewBox,n=s.offset,a=s.position,o=r,l=o.cx,i=o.cy,d=o.innerRadius,u=o.outerRadius,p=o.startAngle,f=o.endAngle,y=(p+f)/2;if(a==="outside"){var _=Fl(l,i,u+n,y),b=_.x,w=_.y;return{x:b,y:w,textAnchor:b>=l?"start":"end",verticalAnchor:"middle"}}if(a==="center")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(a==="centerTop")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"start"};if(a==="centerBottom")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"end"};var j=(d+u)/2,k=Fl(l,i,j,y),S=k.x,T=k.y;return{x:S,y:T,textAnchor:"middle",verticalAnchor:"middle"}},Xss=function(s){var r=s.viewBox,n=s.parentViewBox,a=s.offset,o=s.position,l=r,i=l.x,d=l.y,u=l.width,p=l.height,f=p>=0?1:-1,y=f*a,_=f>0?"end":"start",b=f>0?"start":"end",w=u>=0?1:-1,j=w*a,k=w>0?"end":"start",S=w>0?"start":"end";if(o==="top"){var T={x:i+u/2,y:d-f*a,textAnchor:"middle",verticalAnchor:_};return Id(Id({},T),n?{height:Math.max(d-n.y,0),width:u}:{})}if(o==="bottom"){var I={x:i+u/2,y:d+p+y,textAnchor:"middle",verticalAnchor:b};return Id(Id({},I),n?{height:Math.max(n.y+n.height-(d+p),0),width:u}:{})}if(o==="left"){var L={x:i-j,y:d+p/2,textAnchor:k,verticalAnchor:"middle"};return Id(Id({},L),n?{width:Math.max(L.x-n.x,0),height:p}:{})}if(o==="right"){var R={x:i+u+j,y:d+p/2,textAnchor:S,verticalAnchor:"middle"};return Id(Id({},R),n?{width:Math.max(n.x+n.width-R.x,0),height:p}:{})}var $=n?{width:u,height:p}:{};return o==="insideLeft"?Id({x:i+j,y:d+p/2,textAnchor:S,verticalAnchor:"middle"},$):o==="insideRight"?Id({x:i+u-j,y:d+p/2,textAnchor:k,verticalAnchor:"middle"},$):o==="insideTop"?Id({x:i+u/2,y:d+y,textAnchor:"middle",verticalAnchor:b},$):o==="insideBottom"?Id({x:i+u/2,y:d+p-y,textAnchor:"middle",verticalAnchor:_},$):o==="insideTopLeft"?Id({x:i+j,y:d+y,textAnchor:S,verticalAnchor:b},$):o==="insideTopRight"?Id({x:i+u-j,y:d+y,textAnchor:k,verticalAnchor:b},$):o==="insideBottomLeft"?Id({x:i+j,y:d+p-y,textAnchor:S,verticalAnchor:_},$):o==="insideBottomRight"?Id({x:i+u-j,y:d+p-y,textAnchor:k,verticalAnchor:_},$):$M(o)&&(tn(o.x)||qN(o.x))&&(tn(o.y)||qN(o.y))?Id({x:i+Bh(o.x,u),y:d+Bh(o.y,p),textAnchor:"end",verticalAnchor:"end"},$):Id({x:i+u/2,y:d+p/2,textAnchor:"middle",verticalAnchor:"middle"},$)},Qss=function(s){return"cx"in s&&tn(s.cx)};function hu(t){var s=t.offset,r=s===void 0?5:s,n=qss(t,Oss),a=Id({offset:r},n),o=a.viewBox,l=a.position,i=a.value,d=a.children,u=a.content,p=a.className,f=p===void 0?"":p,y=a.textBreakAll;if(!o||Ai(i)&&Ai(d)&&!C.isValidElement(u)&&!gi(u))return null;if(C.isValidElement(u))return C.cloneElement(u,a);var _;if(gi(u)){if(_=C.createElement(u,a),C.isValidElement(_))return _}else _=Gss(a);var b=Qss(o),w=Ga(a,!0);if(b&&(l==="insideStart"||l==="insideEnd"||l==="end"))return Zss(a,_,w);var j=b?Yss(a):Xss(a);return ht.createElement(Zk,G6({className:Ii("recharts-label",f)},w,j,{breakAll:y}),_)}hu.displayName="Label";var UXe=function(s){var r=s.cx,n=s.cy,a=s.angle,o=s.startAngle,l=s.endAngle,i=s.r,d=s.radius,u=s.innerRadius,p=s.outerRadius,f=s.x,y=s.y,_=s.top,b=s.left,w=s.width,j=s.height,k=s.clockWise,S=s.labelViewBox;if(S)return S;if(tn(w)&&tn(j)){if(tn(f)&&tn(y))return{x:f,y,width:w,height:j};if(tn(_)&&tn(b))return{x:_,y:b,width:w,height:j}}return tn(f)&&tn(y)?{x:f,y,width:0,height:0}:tn(r)&&tn(n)?{cx:r,cy:n,startAngle:o||a||0,endAngle:l||a||0,innerRadius:u||0,outerRadius:p||d||i||0,clockWise:k}:s.viewBox?s.viewBox:{}},Jss=function(s,r){return s?s===!0?ht.createElement(hu,{key:"label-implicit",viewBox:r}):Ud(s)?ht.createElement(hu,{key:"label-implicit",viewBox:r,value:s}):C.isValidElement(s)?s.type===hu?C.cloneElement(s,{key:"label-implicit",viewBox:r}):ht.createElement(hu,{key:"label-implicit",content:s,viewBox:r}):gi(s)?ht.createElement(hu,{key:"label-implicit",content:s,viewBox:r}):$M(s)?ht.createElement(hu,G6({viewBox:r},s,{key:"label-implicit"})):null:null},ers=function(s,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!s||!s.children&&n&&!s.label)return null;var a=s.children,o=UXe(s),l=kp(a,hu).map(function(d,u){return C.cloneElement(d,{viewBox:r||o,key:"label-".concat(u)})});if(!n)return l;var i=Jss(s.label,r||o);return[i].concat(Rss(l))};hu.parseViewBox=UXe;hu.renderCallByParent=ers;function trs(t){var s=t==null?0:t.length;return s?t[s-1]:void 0}var srs=trs;const rrs=_o(srs);function K6(t){"@babel/helpers - typeof";return K6=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},K6(t)}var nrs=["valueAccessor"],ars=["data","dataKey","clockWise","id","textBreakAll"];function irs(t){return drs(t)||crs(t)||lrs(t)||ors()}function ors(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lrs(t,s){if(t){if(typeof t=="string")return u0e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u0e(t,s)}}function crs(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function drs(t){if(Array.isArray(t))return u0e(t)}function u0e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function prs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var frs=function(s){return Array.isArray(s.value)?rrs(s.value):s.value};function K0(t){var s=t.valueAccessor,r=s===void 0?frs:s,n=qIe(t,nrs),a=n.data,o=n.dataKey,l=n.clockWise,i=n.id,d=n.textBreakAll,u=qIe(n,ars);return!a||!a.length?null:ht.createElement(Lo,{className:"recharts-label-list"},a.map(function(p,f){var y=Ai(o)?r(p,f):$d(p&&p.payload,o),_=Ai(i)?{}:{id:"".concat(i,"-").concat(f)};return ht.createElement(hu,bie({},Ga(p,!0),u,_,{parentViewBox:p.parentViewBox,value:y,textBreakAll:d,viewBox:hu.parseViewBox(Ai(l)?p:$Ie($Ie({},p),{},{clockWise:l})),key:"label-".concat(f),index:f}))}))}K0.displayName="LabelList";function grs(t,s){return t?t===!0?ht.createElement(K0,{key:"labelList-implicit",data:s}):ht.isValidElement(t)||gi(t)?ht.createElement(K0,{key:"labelList-implicit",data:s,content:t}):$M(t)?ht.createElement(K0,bie({data:s},t,{key:"labelList-implicit"})):null:null}function xrs(t,s){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!t||!t.children&&r&&!t.label)return null;var n=t.children,a=kp(n,K0).map(function(l,i){return C.cloneElement(l,{data:s,key:"labelList-".concat(i)})});if(!r)return a;var o=grs(t.label,s);return[o].concat(irs(a))}K0.renderCallByParent=xrs;function Z6(t){"@babel/helpers - typeof";return Z6=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Z6(t)}function h0e(){return h0e=Object.assign?Object.assign.bind():function(t){for(var s=1;s180),",").concat(+(l>u),`, `).concat(f.x,",").concat(f.y,` `);if(a>0){var _=Fl(r,n,a,l),b=Fl(r,n,a,u);y+="L ".concat(b.x,",").concat(b.y,` A `).concat(a,",").concat(a,`,0, `).concat(+(Math.abs(d)>180),",").concat(+(l<=u),`, `).concat(_.x,",").concat(_.y," Z")}else y+="L ".concat(r,",").concat(n," Z");return y},wrs=function(s){var r=s.cx,n=s.cy,a=s.innerRadius,o=s.outerRadius,l=s.cornerRadius,i=s.forceCornerRadius,d=s.cornerIsExternal,u=s.startAngle,p=s.endAngle,f=zh(p-u),y=AR({cx:r,cy:n,radius:o,angle:u,sign:f,cornerRadius:l,cornerIsExternal:d}),_=y.circleTangency,b=y.lineTangency,w=y.theta,j=AR({cx:r,cy:n,radius:o,angle:p,sign:-f,cornerRadius:l,cornerIsExternal:d}),k=j.circleTangency,S=j.lineTangency,T=j.theta,I=d?Math.abs(u-p):Math.abs(u-p)-w-T;if(I<0)return i?"M ".concat(b.x,",").concat(b.y,` a`).concat(l,",").concat(l,",0,0,1,").concat(l*2,`,0 a`).concat(l,",").concat(l,",0,0,1,").concat(-l*2,`,0 `):VXe({cx:r,cy:n,innerRadius:a,outerRadius:o,startAngle:u,endAngle:p});var L="M ".concat(b.x,",").concat(b.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(_.x,",").concat(_.y,` A`).concat(o,",").concat(o,",0,").concat(+(I>180),",").concat(+(f<0),",").concat(k.x,",").concat(k.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(S.x,",").concat(S.y,` `);if(a>0){var R=AR({cx:r,cy:n,radius:a,angle:u,sign:f,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),$=R.circleTangency,q=R.lineTangency,U=R.theta,H=AR({cx:r,cy:n,radius:a,angle:p,sign:-f,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),Y=H.circleTangency,se=H.lineTangency,te=H.theta,Q=d?Math.abs(u-p):Math.abs(u-p)-U-te;if(Q<0&&l===0)return"".concat(L,"L").concat(r,",").concat(n,"Z");L+="L".concat(se.x,",").concat(se.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(Y.x,",").concat(Y.y,` A`).concat(a,",").concat(a,",0,").concat(+(Q>180),",").concat(+(f>0),",").concat($.x,",").concat($.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(q.x,",").concat(q.y,"Z")}else L+="L".concat(r,",").concat(n,"Z");return L},jrs={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},HXe=function(s){var r=VIe(VIe({},jrs),s),n=r.cx,a=r.cy,o=r.innerRadius,l=r.outerRadius,i=r.cornerRadius,d=r.forceCornerRadius,u=r.cornerIsExternal,p=r.startAngle,f=r.endAngle,y=r.className;if(l0&&Math.abs(p-f)<360?j=wrs({cx:n,cy:a,innerRadius:o,outerRadius:l,cornerRadius:Math.min(w,b/2),forceCornerRadius:d,cornerIsExternal:u,startAngle:p,endAngle:f}):j=VXe({cx:n,cy:a,innerRadius:o,outerRadius:l,startAngle:p,endAngle:f}),ht.createElement("path",h0e({},Ga(r,!0),{className:_,d:j,role:"img"}))};function Y6(t){"@babel/helpers - typeof";return Y6=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Y6(t)}function m0e(){return m0e=Object.assign?Object.assign.bind():function(t){for(var s=1;s0;)if(!r.equals(t[n],s[n],n,n,t,s,r))return!1;return!0}function qrs(t,s){return gS(t.getTime(),s.getTime())}function Urs(t,s){return t.name===s.name&&t.message===s.message&&t.cause===s.cause&&t.stack===s.stack}function Vrs(t,s){return t===s}function QIe(t,s,r){var n=t.size;if(n!==s.size)return!1;if(!n)return!0;for(var a=new Array(n),o=t.entries(),l,i,d=0;(l=o.next())&&!l.done;){for(var u=s.entries(),p=!1,f=0;(i=u.next())&&!i.done;){if(a[f]){f++;continue}var y=l.value,_=i.value;if(r.equals(y[0],_[0],d,f,t,s,r)&&r.equals(y[1],_[1],y[0],_[0],t,s,r)){p=a[f]=!0;break}f++}if(!p)return!1;d++}return!0}var Hrs=gS;function Wrs(t,s,r){var n=XIe(t),a=n.length;if(XIe(s).length!==a)return!1;for(;a-- >0;)if(!ZXe(t,s,r,n[a]))return!1;return!0}function jE(t,s,r){var n=ZIe(t),a=n.length;if(ZIe(s).length!==a)return!1;for(var o,l,i;a-- >0;)if(o=n[a],!ZXe(t,s,r,o)||(l=YIe(t,o),i=YIe(s,o),(l||i)&&(!l||!i||l.configurable!==i.configurable||l.enumerable!==i.enumerable||l.writable!==i.writable)))return!1;return!0}function Grs(t,s){return gS(t.valueOf(),s.valueOf())}function Krs(t,s){return t.source===s.source&&t.flags===s.flags}function JIe(t,s,r){var n=t.size;if(n!==s.size)return!1;if(!n)return!0;for(var a=new Array(n),o=t.values(),l,i;(l=o.next())&&!l.done;){for(var d=s.values(),u=!1,p=0;(i=d.next())&&!i.done;){if(!a[p]&&r.equals(l.value,i.value,l.value,i.value,t,s,r)){u=a[p]=!0;break}p++}if(!u)return!1}return!0}function Zrs(t,s){var r=t.length;if(s.length!==r)return!1;for(;r-- >0;)if(t[r]!==s[r])return!1;return!0}function Yrs(t,s){return t.hostname===s.hostname&&t.pathname===s.pathname&&t.protocol===s.protocol&&t.port===s.port&&t.hash===s.hash&&t.username===s.username&&t.password===s.password}function ZXe(t,s,r,n){return(n===Brs||n===zrs||n===Frs)&&(t.$$typeof||s.$$typeof)?!0:Rrs(s,n)&&r.equals(t[n],s[n],n,n,t,s,r)}var Xrs="[object Arguments]",Qrs="[object Boolean]",Jrs="[object Date]",ens="[object Error]",tns="[object Map]",sns="[object Number]",rns="[object Object]",nns="[object RegExp]",ans="[object Set]",ins="[object String]",ons="[object URL]",lns=Array.isArray,e6e=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,t6e=Object.assign,cns=Object.prototype.toString.call.bind(Object.prototype.toString);function dns(t){var s=t.areArraysEqual,r=t.areDatesEqual,n=t.areErrorsEqual,a=t.areFunctionsEqual,o=t.areMapsEqual,l=t.areNumbersEqual,i=t.areObjectsEqual,d=t.arePrimitiveWrappersEqual,u=t.areRegExpsEqual,p=t.areSetsEqual,f=t.areTypedArraysEqual,y=t.areUrlsEqual;return function(b,w,j){if(b===w)return!0;if(b==null||w==null)return!1;var k=typeof b;if(k!==typeof w)return!1;if(k!=="object")return k==="number"?l(b,w,j):k==="function"?a(b,w,j):!1;var S=b.constructor;if(S!==w.constructor)return!1;if(S===Object)return i(b,w,j);if(lns(b))return s(b,w,j);if(e6e!=null&&e6e(b))return f(b,w,j);if(S===Date)return r(b,w,j);if(S===RegExp)return u(b,w,j);if(S===Map)return o(b,w,j);if(S===Set)return p(b,w,j);var T=cns(b);return T===Jrs?r(b,w,j):T===nns?u(b,w,j):T===tns?o(b,w,j):T===ans?p(b,w,j):T===rns?typeof b.then!="function"&&typeof w.then!="function"&&i(b,w,j):T===ons?y(b,w,j):T===ens?n(b,w,j):T===Xrs?i(b,w,j):T===Qrs||T===sns||T===ins?d(b,w,j):!1}}function uns(t){var s=t.circular,r=t.createCustomConfig,n=t.strict,a={areArraysEqual:n?jE:$rs,areDatesEqual:qrs,areErrorsEqual:Urs,areFunctionsEqual:Vrs,areMapsEqual:n?KIe(QIe,jE):QIe,areNumbersEqual:Hrs,areObjectsEqual:n?jE:Wrs,arePrimitiveWrappersEqual:Grs,areRegExpsEqual:Krs,areSetsEqual:n?KIe(JIe,jE):JIe,areTypedArraysEqual:n?jE:Zrs,areUrlsEqual:Yrs};if(r&&(a=t6e({},a,r(a))),s){var o=PR(a.areArraysEqual),l=PR(a.areMapsEqual),i=PR(a.areObjectsEqual),d=PR(a.areSetsEqual);a=t6e({},a,{areArraysEqual:o,areMapsEqual:l,areObjectsEqual:i,areSetsEqual:d})}return a}function hns(t){return function(s,r,n,a,o,l,i){return t(s,r,i)}}function mns(t){var s=t.circular,r=t.comparator,n=t.createState,a=t.equals,o=t.strict;if(n)return function(d,u){var p=n(),f=p.cache,y=f===void 0?s?new WeakMap:void 0:f,_=p.meta;return r(d,u,{cache:y,equals:a,meta:_,strict:o})};if(s)return function(d,u){return r(d,u,{cache:new WeakMap,equals:a,meta:void 0,strict:o})};var l={cache:void 0,equals:a,meta:void 0,strict:o};return function(d,u){return r(d,u,l)}}var pns=ib();ib({strict:!0});ib({circular:!0});ib({circular:!0,strict:!0});ib({createInternalComparator:function(){return gS}});ib({strict:!0,createInternalComparator:function(){return gS}});ib({circular:!0,createInternalComparator:function(){return gS}});ib({circular:!0,createInternalComparator:function(){return gS},strict:!0});function ib(t){t===void 0&&(t={});var s=t.circular,r=s===void 0?!1:s,n=t.createInternalComparator,a=t.createState,o=t.strict,l=o===void 0?!1:o,i=uns(t),d=dns(i),u=n?n(d):hns(d);return mns({circular:r,comparator:d,createState:a,equals:u,strict:l})}function fns(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function s6e(t){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=-1,n=function a(o){r<0&&(r=o),o-r>s?(t(o),r=-1):fns(a)};requestAnimationFrame(n)}function p0e(t){"@babel/helpers - typeof";return p0e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},p0e(t)}function gns(t){return _ns(t)||vns(t)||yns(t)||xns()}function xns(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yns(t,s){if(t){if(typeof t=="string")return r6e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return r6e(t,s)}}function r6e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r1?1:k<0?0:k},w=function(k){for(var S=k>1?1:k,T=S,I=0;I<8;++I){var L=f(T)-S,R=_(T);if(Math.abs(L-S)0&&arguments[0]!==void 0?arguments[0]:{},r=s.stiff,n=r===void 0?100:r,a=s.damping,o=a===void 0?8:a,l=s.dt,i=l===void 0?17:l,d=function(p,f,y){var _=-(p-f)*n,b=y*o,w=y+(_-b)*i/1e3,j=y*i/1e3+p;return Math.abs(j-f)t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Xns(t,s){if(t==null)return{};var r={},n=Object.keys(t),a,o;for(o=0;o=0)&&(r[a]=t[a]);return r}function Cpe(t){return tas(t)||eas(t)||Jns(t)||Qns()}function Qns(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Jns(t,s){if(t){if(typeof t=="string")return v0e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return v0e(t,s)}}function eas(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function tas(t){if(Array.isArray(t))return v0e(t)}function v0e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function kie(t){return kie=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},kie(t)}var fy=function(t){ias(r,t);var s=oas(r);function r(n,a){var o;sas(this,r),o=s.call(this,n,a);var l=o.props,i=l.isActive,d=l.attributeName,u=l.from,p=l.to,f=l.steps,y=l.children,_=l.duration;if(o.handleStyleChange=o.handleStyleChange.bind(w0e(o)),o.changeStyle=o.changeStyle.bind(w0e(o)),!i||_<=0)return o.state={style:{}},typeof y=="function"&&(o.state={style:p}),b0e(o);if(f&&f.length)o.state={style:f[0].style};else if(u){if(typeof y=="function")return o.state={style:u},b0e(o);o.state={style:d?UE({},d,u):u}}else o.state={style:{}};return o}return nas(r,[{key:"componentDidMount",value:function(){var a=this.props,o=a.isActive,l=a.canBegin;this.mounted=!0,!(!o||!l)&&this.runAnimation(this.props)}},{key:"componentDidUpdate",value:function(a){var o=this.props,l=o.isActive,i=o.canBegin,d=o.attributeName,u=o.shouldReAnimate,p=o.to,f=o.from,y=this.state.style;if(i){if(!l){var _={style:d?UE({},d,p):p};this.state&&y&&(d&&y[d]!==p||!d&&y!==p)&&this.setState(_);return}if(!(pns(a.to,p)&&a.canBegin&&a.isActive)){var b=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var w=b||u?f:a.to;if(this.state&&y){var j={style:d?UE({},d,w):w};(d&&y[d]!==w||!d&&y!==w)&&this.setState(j)}this.runAnimation(gg(gg({},this.props),{},{from:w,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var a=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),a&&a()}},{key:"handleStyleChange",value:function(a){this.changeStyle(a)}},{key:"changeStyle",value:function(a){this.mounted&&this.setState({style:a})}},{key:"runJSAnimation",value:function(a){var o=this,l=a.from,i=a.to,d=a.duration,u=a.easing,p=a.begin,f=a.onAnimationEnd,y=a.onAnimationStart,_=Kns(l,i,Rns(u),d,this.changeStyle),b=function(){o.stopJSAnimation=_()};this.manager.start([y,p,b,d,f])}},{key:"runStepAnimation",value:function(a){var o=this,l=a.steps,i=a.begin,d=a.onAnimationStart,u=l[0],p=u.style,f=u.duration,y=f===void 0?0:f,_=function(w,j,k){if(k===0)return w;var S=j.duration,T=j.easing,I=T===void 0?"ease":T,L=j.style,R=j.properties,$=j.onAnimationEnd,q=k>0?l[k-1]:j,U=R||Object.keys(L);if(typeof I=="function"||I==="spring")return[].concat(Cpe(w),[o.runJSAnimation.bind(o,{from:q.style,to:L,duration:S,easing:I}),S]);var H=i6e(U,S,I),Y=gg(gg(gg({},q.style),L),{},{transition:H});return[].concat(Cpe(w),[Y,S,$]).filter(kns)};return this.manager.start([d].concat(Cpe(l.reduce(_,[p,Math.max(y,i)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=bns());var o=a.begin,l=a.duration,i=a.attributeName,d=a.to,u=a.easing,p=a.onAnimationStart,f=a.onAnimationEnd,y=a.steps,_=a.children,b=this.manager;if(this.unSubscribe=b.subscribe(this.handleStyleChange),typeof u=="function"||typeof _=="function"||u==="spring"){this.runJSAnimation(a);return}if(y.length>1){this.runStepAnimation(a);return}var w=i?UE({},i,d):d,j=i6e(Object.keys(w),l,u);b.start([p,o,gg(gg({},w),{},{transition:j}),l,f])}},{key:"render",value:function(){var a=this.props,o=a.children;a.begin;var l=a.duration;a.attributeName,a.easing;var i=a.isActive;a.steps,a.from,a.to,a.canBegin,a.onAnimationEnd,a.shouldReAnimate,a.onAnimationReStart;var d=Yns(a,Zns),u=C.Children.count(o),p=this.state.style;if(typeof o=="function")return o(p);if(!i||u===0||l<=0)return o;var f=function(_){var b=_.props,w=b.style,j=w===void 0?{}:w,k=b.className,S=C.cloneElement(_,gg(gg({},d),{},{style:gg(gg({},j),p),className:k}));return S};return u===1?f(C.Children.only(o)):ht.createElement("div",null,C.Children.map(o,function(y){return f(y)}))}}]),r}(C.PureComponent);fy.displayName="Animate";fy.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};fy.propTypes={from:Uo.oneOfType([Uo.object,Uo.string]),to:Uo.oneOfType([Uo.object,Uo.string]),attributeName:Uo.string,duration:Uo.number,begin:Uo.number,easing:Uo.oneOfType([Uo.string,Uo.func]),steps:Uo.arrayOf(Uo.shape({duration:Uo.number.isRequired,style:Uo.object.isRequired,easing:Uo.oneOfType([Uo.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),Uo.func]),properties:Uo.arrayOf("string"),onAnimationEnd:Uo.func})),children:Uo.oneOfType([Uo.node,Uo.func]),isActive:Uo.bool,canBegin:Uo.bool,onAnimationEnd:Uo.func,shouldReAnimate:Uo.bool,onAnimationStart:Uo.func,onAnimationReStart:Uo.func};function J6(t){"@babel/helpers - typeof";return J6=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},J6(t)}function Sie(){return Sie=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0?1:-1,d=n>=0?1:-1,u=a>=0&&n>=0||a<0&&n<0?1:0,p;if(l>0&&o instanceof Array){for(var f=[0,0,0,0],y=0,_=4;y<_;y++)f[y]=o[y]>l?l:o[y];p="M".concat(s,",").concat(r+i*f[0]),f[0]>0&&(p+="A ".concat(f[0],",").concat(f[0],",0,0,").concat(u,",").concat(s+d*f[0],",").concat(r)),p+="L ".concat(s+n-d*f[1],",").concat(r),f[1]>0&&(p+="A ".concat(f[1],",").concat(f[1],",0,0,").concat(u,`, `).concat(s+n,",").concat(r+i*f[1])),p+="L ".concat(s+n,",").concat(r+a-i*f[2]),f[2]>0&&(p+="A ".concat(f[2],",").concat(f[2],",0,0,").concat(u,`, `).concat(s+n-d*f[2],",").concat(r+a)),p+="L ".concat(s+d*f[3],",").concat(r+a),f[3]>0&&(p+="A ".concat(f[3],",").concat(f[3],",0,0,").concat(u,`, `).concat(s,",").concat(r+a-i*f[3])),p+="Z"}else if(l>0&&o===+o&&o>0){var b=Math.min(l,o);p="M ".concat(s,",").concat(r+i*b,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s+d*b,",").concat(r,` L `).concat(s+n-d*b,",").concat(r,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s+n,",").concat(r+i*b,` L `).concat(s+n,",").concat(r+a-i*b,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s+n-d*b,",").concat(r+a,` L `).concat(s+d*b,",").concat(r+a,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s,",").concat(r+a-i*b," Z")}else p="M ".concat(s,",").concat(r," h ").concat(n," v ").concat(a," h ").concat(-n," Z");return p},xas=function(s,r){if(!s||!r)return!1;var n=s.x,a=s.y,o=r.x,l=r.y,i=r.width,d=r.height;if(Math.abs(i)>0&&Math.abs(d)>0){var u=Math.min(o,o+i),p=Math.max(o,o+i),f=Math.min(l,l+d),y=Math.max(l,l+d);return n>=u&&n<=p&&a>=f&&a<=y}return!1},yas={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},C2e=function(s){var r=p6e(p6e({},yas),s),n=C.useRef(),a=C.useState(-1),o=cas(a,2),l=o[0],i=o[1];C.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var I=n.current.getTotalLength();I&&i(I)}catch{}},[]);var d=r.x,u=r.y,p=r.width,f=r.height,y=r.radius,_=r.className,b=r.animationEasing,w=r.animationDuration,j=r.animationBegin,k=r.isAnimationActive,S=r.isUpdateAnimationActive;if(d!==+d||u!==+u||p!==+p||f!==+f||p===0||f===0)return null;var T=Ii("recharts-rectangle",_);return S?ht.createElement(fy,{canBegin:l>0,from:{width:p,height:f,x:d,y:u},to:{width:p,height:f,x:d,y:u},duration:w,animationEasing:b,isActive:S},function(I){var L=I.width,R=I.height,$=I.x,q=I.y;return ht.createElement(fy,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:j,duration:w,isActive:k,easing:b},ht.createElement("path",Sie({},Ga(r,!0),{className:T,d:f6e($,q,L,R,y),ref:n})))}):ht.createElement("path",Sie({},Ga(r,!0),{className:T,d:f6e(d,u,p,f,y)}))},vas=["points","className","baseLinePoints","connectNulls"];function X4(){return X4=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function bas(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function g6e(t){return kas(t)||Nas(t)||jas(t)||was()}function was(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jas(t,s){if(t){if(typeof t=="string")return j0e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return j0e(t,s)}}function Nas(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function kas(t){if(Array.isArray(t))return j0e(t)}function j0e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return s.forEach(function(n){x6e(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),x6e(s[0])&&r[r.length-1].push(s[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},SI=function(s,r){var n=Sas(s);r&&(n=[n.reduce(function(o,l){return[].concat(g6e(o),g6e(l))},[])]);var a=n.map(function(o){return o.reduce(function(l,i,d){return"".concat(l).concat(d===0?"M":"L").concat(i.x,",").concat(i.y)},"")}).join("");return n.length===1?"".concat(a,"Z"):a},Cas=function(s,r,n){var a=SI(s,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(SI(r.reverse(),n).slice(1))},Mas=function(s){var r=s.points,n=s.className,a=s.baseLinePoints,o=s.connectNulls,l=_as(s,vas);if(!r||!r.length)return null;var i=Ii("recharts-polygon",n);if(a&&a.length){var d=l.stroke&&l.stroke!=="none",u=Cas(r,a,o);return ht.createElement("g",{className:i},ht.createElement("path",X4({},Ga(l,!0),{fill:u.slice(-1)==="Z"?l.fill:"none",stroke:"none",d:u})),d?ht.createElement("path",X4({},Ga(l,!0),{fill:"none",d:SI(r,o)})):null,d?ht.createElement("path",X4({},Ga(l,!0),{fill:"none",d:SI(a,o)})):null)}var p=SI(r,o);return ht.createElement("path",X4({},Ga(l,!0),{fill:p.slice(-1)==="Z"?l.fill:"none",className:i,d:p}))};function N0e(){return N0e=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Das(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var Oas=function(s,r,n,a,o,l){return"M".concat(s,",").concat(o,"v").concat(a,"M").concat(l,",").concat(r,"h").concat(n)},Ras=function(s){var r=s.x,n=r===void 0?0:r,a=s.y,o=a===void 0?0:a,l=s.top,i=l===void 0?0:l,d=s.left,u=d===void 0?0:d,p=s.width,f=p===void 0?0:p,y=s.height,_=y===void 0?0:y,b=s.className,w=Las(s,Tas),j=Aas({x:n,y:o,top:i,left:u,width:f,height:_},w);return!tn(n)||!tn(o)||!tn(f)||!tn(_)||!tn(i)||!tn(u)?null:ht.createElement("path",k0e({},Ga(j,!0),{className:Ii("recharts-cross",b),d:Oas(n,o,f,_,i,u)}))},Fas=xce,zas=mXe,Bas=wy;function $as(t,s){return t&&t.length?Fas(t,Bas(s),zas):void 0}var qas=$as;const Uas=_o(qas);var Vas=xce,Has=wy,Was=pXe;function Gas(t,s){return t&&t.length?Vas(t,Has(s),Was):void 0}var Kas=Gas;const Zas=_o(Kas);var Yas=["cx","cy","angle","ticks","axisLine"],Xas=["ticks","tick","angle","tickFormatter","stroke"];function W3(t){"@babel/helpers - typeof";return W3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},W3(t)}function CI(){return CI=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Qas(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Jas(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function b6e(t,s){for(var r=0;rN6e?l=a==="outer"?"start":"end":o<-N6e?l=a==="outer"?"end":"start":l="middle",l}},{key:"renderAxisLine",value:function(){var n=this.props,a=n.cx,o=n.cy,l=n.radius,i=n.axisLine,d=n.axisLineType,u=aw(aw({},Ga(this.props,!1)),{},{fill:"none"},Ga(i,!1));if(d==="circle")return ht.createElement(wce,MN({className:"recharts-polar-angle-axis-line"},u,{cx:a,cy:o,r:l}));var p=this.props.ticks,f=p.map(function(y){return Fl(a,o,l,y.coordinate)});return ht.createElement(Mas,MN({className:"recharts-polar-angle-axis-line"},u,{points:f}))}},{key:"renderTicks",value:function(){var n=this,a=this.props,o=a.ticks,l=a.tick,i=a.tickLine,d=a.tickFormatter,u=a.stroke,p=Ga(this.props,!1),f=Ga(l,!1),y=aw(aw({},p),{},{fill:"none"},Ga(i,!1)),_=o.map(function(b,w){var j=n.getTickLineCoord(b),k=n.getTickTextAnchor(b),S=aw(aw(aw({textAnchor:k},p),{},{stroke:"none",fill:u},f),{},{index:w,payload:b,x:j.x2,y:j.y2});return ht.createElement(Lo,MN({className:Ii("recharts-polar-angle-axis-tick",qXe(l)),key:"tick-".concat(b.coordinate)},Kk(n.props,b,w)),i&&ht.createElement("line",MN({className:"recharts-polar-angle-axis-tick-line"},y,j)),l&&s.renderTickItem(l,S,d?d(b.value,w):b.value))});return ht.createElement(Lo,{className:"recharts-polar-angle-axis-ticks"},_)}},{key:"render",value:function(){var n=this.props,a=n.ticks,o=n.radius,l=n.axisLine;return o<=0||!a||!a.length?null:ht.createElement(Lo,{className:Ii("recharts-polar-angle-axis",this.props.className)},l&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(n,a,o){var l;return ht.isValidElement(n)?l=ht.cloneElement(n,a):gi(n)?l=n(a):l=ht.createElement(Zk,MN({},a,{className:"recharts-polar-angle-axis-tick-value"}),o),l}}])}(C.PureComponent);kce(Sce,"displayName","PolarAngleAxis");kce(Sce,"axisType","angleAxis");kce(Sce,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var pis=cYe,fis=pis(Object.getPrototypeOf,Object),gis=fis,xis=uv,yis=gis,vis=hv,_is="[object Object]",bis=Function.prototype,wis=Object.prototype,iQe=bis.toString,jis=wis.hasOwnProperty,Nis=iQe.call(Object);function kis(t){if(!vis(t)||xis(t)!=_is)return!1;var s=yis(t);if(s===null)return!0;var r=jis.call(s,"constructor")&&s.constructor;return typeof r=="function"&&r instanceof r&&iQe.call(r)==Nis}var Sis=kis;const Cis=_o(Sis);var Mis=uv,Tis=hv,Ais="[object Boolean]";function Eis(t){return t===!0||t===!1||Tis(t)&&Mis(t)==Ais}var Pis=Eis;const Iis=_o(Pis);function tL(t){"@babel/helpers - typeof";return tL=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},tL(t)}function Tie(){return Tie=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0,from:{upperWidth:0,lowerWidth:0,height:y,x:d,y:u},to:{upperWidth:p,lowerWidth:f,height:y,x:d,y:u},duration:w,animationEasing:b,isActive:k},function(T){var I=T.upperWidth,L=T.lowerWidth,R=T.height,$=T.x,q=T.y;return ht.createElement(fy,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:j,duration:w,easing:b},ht.createElement("path",Tie({},Ga(r,!0),{className:S,d:M6e($,q,I,L,R),ref:n})))}):ht.createElement("g",null,ht.createElement("path",Tie({},Ga(r,!0),{className:S,d:M6e(d,u,p,f,y)})))},Vis=["option","shapeType","propTransformer","activeClassName","isActive"];function sL(t){"@babel/helpers - typeof";return sL=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},sL(t)}function His(t,s){if(t==null)return{};var r=Wis(t,s),n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Wis(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function T6e(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Aie(t){for(var s=1;s0?Np(T,"paddingAngle",0):0;if(L){var $=cp(L.endAngle-L.startAngle,T.endAngle-T.startAngle),q=Cl(Cl({},T),{},{startAngle:S+R,endAngle:S+$(w)+R});j.push(q),S=q.endAngle}else{var U=T.endAngle,H=T.startAngle,Y=cp(0,U-H),se=Y(w),te=Cl(Cl({},T),{},{startAngle:S+R,endAngle:S+se+R});j.push(te),S=te.endAngle}}),ht.createElement(Lo,null,n.renderSectorsStatically(j))})}},{key:"attachKeyboardHandlers",value:function(n){var a=this;n.onkeydown=function(o){if(!o.altKey)switch(o.key){case"ArrowLeft":{var l=++a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[l].focus(),a.setState({sectorToFocus:l});break}case"ArrowRight":{var i=--a.state.sectorToFocus<0?a.sectorRefs.length-1:a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[i].focus(),a.setState({sectorToFocus:i});break}case"Escape":{a.sectorRefs[a.state.sectorToFocus].blur(),a.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var n=this.props,a=n.sectors,o=n.isAnimationActive,l=this.state.prevSectors;return o&&a&&a.length&&(!l||!hD(l,a))?this.renderSectorsWithAnimation():this.renderSectorsStatically(a)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var n=this,a=this.props,o=a.hide,l=a.sectors,i=a.className,d=a.label,u=a.cx,p=a.cy,f=a.innerRadius,y=a.outerRadius,_=a.isAnimationActive,b=this.state.isAnimationFinished;if(o||!l||!l.length||!tn(u)||!tn(p)||!tn(f)||!tn(y))return null;var w=Ii("recharts-pie",i);return ht.createElement(Lo,{tabIndex:this.props.rootTabIndex,className:w,ref:function(k){n.pieRef=k}},this.renderSectors(),d&&this.renderLabels(l),hu.renderCallByParent(this.props,null,!1),(!_||b)&&K0.renderCallByParent(this.props,l,!1))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return a.prevIsAnimationActive!==n.isAnimationActive?{prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:[],isAnimationFinished:!0}:n.isAnimationActive&&n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:a.curSectors,isAnimationFinished:!0}:n.sectors!==a.curSectors?{curSectors:n.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(n,a){return n>a?"start":n=360?S:S-1)*d,I=j-S*_-T,L=a.reduce(function(q,U){var H=$d(U,k,0);return q+(tn(H)?H:0)},0),R;if(L>0){var $;R=a.map(function(q,U){var H=$d(q,k,0),Y=$d(q,p,U),se=(tn(H)?H:0)/L,te;U?te=$.endAngle+zh(w)*d*(H!==0?1:0):te=l;var Q=te+zh(w)*((H!==0?_:0)+se*I),de=(te+Q)/2,re=(b.innerRadius+b.outerRadius)/2,ae=[{name:Y,value:H,payload:q,dataKey:k,type:y}],le=Fl(b.cx,b.cy,re,de);return $=Cl(Cl(Cl({percent:se,cornerRadius:o,name:Y,tooltipPayload:ae,midAngle:de,middleRadius:re,tooltipPosition:le},q),b),{},{value:$d(q,k),startAngle:te,endAngle:Q,payload:q,paddingAngle:zh(w)*d}),$})}return Cl(Cl({},b),{},{sectors:R,data:a})});var mos=Math.ceil,pos=Math.max;function fos(t,s,r,n){for(var a=-1,o=pos(mos((s-t)/(r||1)),0),l=Array(o);o--;)l[n?o:++a]=t,t+=r;return l}var gos=fos,xos=MYe,I6e=1/0,yos=17976931348623157e292;function vos(t){if(!t)return t===0?t:0;if(t=xos(t),t===I6e||t===-I6e){var s=t<0?-1:1;return s*yos}return t===t?t:0}var dQe=vos,_os=gos,bos=dce,Mpe=dQe;function wos(t){return function(s,r,n){return n&&typeof n!="number"&&bos(s,r,n)&&(r=n=void 0),s=Mpe(s),r===void 0?(r=s,s=0):r=Mpe(r),n=n===void 0?s0&&n.handleDrag(a.changedTouches[0])}),np(n,"handleDragEnd",function(){n.setState({isTravellerMoving:!1,isSlideMoving:!1},function(){var a=n.props,o=a.endIndex,l=a.onDragEnd,i=a.startIndex;l==null||l({endIndex:o,startIndex:i})}),n.detachDragEndListener()}),np(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),np(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),np(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),np(n,"handleSlideDragStart",function(a){var o=F6e(a)?a.changedTouches[0]:a;n.setState({isTravellerMoving:!1,isSlideMoving:!0,slideMoveStartX:o.pageX}),n.attachDragEndListener()}),n.travellerDragStartHandlers={startX:n.handleTravellerDragStart.bind(n,"startX"),endX:n.handleTravellerDragStart.bind(n,"endX")},n.state={},n}return Oos(s,t),Pos(s,[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(n){var a=n.startX,o=n.endX,l=this.state.scaleValues,i=this.props,d=i.gap,u=i.data,p=u.length-1,f=Math.min(a,o),y=Math.max(a,o),_=s.getIndexInRange(l,f),b=s.getIndexInRange(l,y);return{startIndex:_-_%d,endIndex:b===p?p:b-b%d}}},{key:"getTextOfTick",value:function(n){var a=this.props,o=a.data,l=a.tickFormatter,i=a.dataKey,d=$d(o[n],i,n);return gi(l)?l(d,n):d}},{key:"attachDragEndListener",value:function(){window.addEventListener("mouseup",this.handleDragEnd,!0),window.addEventListener("touchend",this.handleDragEnd,!0),window.addEventListener("mousemove",this.handleDrag,!0)}},{key:"detachDragEndListener",value:function(){window.removeEventListener("mouseup",this.handleDragEnd,!0),window.removeEventListener("touchend",this.handleDragEnd,!0),window.removeEventListener("mousemove",this.handleDrag,!0)}},{key:"handleSlideDrag",value:function(n){var a=this.state,o=a.slideMoveStartX,l=a.startX,i=a.endX,d=this.props,u=d.x,p=d.width,f=d.travellerWidth,y=d.startIndex,_=d.endIndex,b=d.onChange,w=n.pageX-o;w>0?w=Math.min(w,u+p-f-i,u+p-f-l):w<0&&(w=Math.max(w,u-l,u-i));var j=this.getIndex({startX:l+w,endX:i+w});(j.startIndex!==y||j.endIndex!==_)&&b&&b(j),this.setState({startX:l+w,endX:i+w,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var o=F6e(a)?a.changedTouches[0]:a;this.setState({isSlideMoving:!1,isTravellerMoving:!0,movingTravellerId:n,brushMoveStartX:o.pageX}),this.attachDragEndListener()}},{key:"handleTravellerMove",value:function(n){var a=this.state,o=a.brushMoveStartX,l=a.movingTravellerId,i=a.endX,d=a.startX,u=this.state[l],p=this.props,f=p.x,y=p.width,_=p.travellerWidth,b=p.onChange,w=p.gap,j=p.data,k={startX:this.state.startX,endX:this.state.endX},S=n.pageX-o;S>0?S=Math.min(S,f+y-_-u):S<0&&(S=Math.max(S,f-u)),k[l]=u+S;var T=this.getIndex(k),I=T.startIndex,L=T.endIndex,R=function(){var q=j.length-1;return l==="startX"&&(i>d?I%w===0:L%w===0)||id?L%w===0:I%w===0)||i>d&&L===q};this.setState(np(np({},l,u+S),"brushMoveStartX",n.pageX),function(){b&&R()&&b(T)})}},{key:"handleTravellerMoveKeyboard",value:function(n,a){var o=this,l=this.state,i=l.scaleValues,d=l.startX,u=l.endX,p=this.state[a],f=i.indexOf(p);if(f!==-1){var y=f+n;if(!(y===-1||y>=i.length)){var _=i[y];a==="startX"&&_>=u||a==="endX"&&_<=d||this.setState(np({},a,_),function(){o.props.onChange(o.getIndex({startX:o.state.startX,endX:o.state.endX}))})}}}},{key:"renderBackground",value:function(){var n=this.props,a=n.x,o=n.y,l=n.width,i=n.height,d=n.fill,u=n.stroke;return ht.createElement("rect",{stroke:u,fill:d,x:a,y:o,width:l,height:i})}},{key:"renderPanorama",value:function(){var n=this.props,a=n.x,o=n.y,l=n.width,i=n.height,d=n.data,u=n.children,p=n.padding,f=C.Children.only(u);return f?ht.cloneElement(f,{x:a,y:o,width:l,height:i,margin:p,compact:!0,data:d}):null}},{key:"renderTravellerLayer",value:function(n,a){var o,l,i=this,d=this.props,u=d.y,p=d.travellerWidth,f=d.height,y=d.traveller,_=d.ariaLabel,b=d.data,w=d.startIndex,j=d.endIndex,k=Math.max(n,this.props.x),S=Tpe(Tpe({},Ga(this.props,!1)),{},{x:k,y:u,width:p,height:f}),T=_||"Min value: ".concat((o=b[w])===null||o===void 0?void 0:o.name,", Max value: ").concat((l=b[j])===null||l===void 0?void 0:l.name);return ht.createElement(Lo,{tabIndex:0,role:"slider","aria-label":T,"aria-valuenow":n,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[a],onTouchStart:this.travellerDragStartHandlers[a],onKeyDown:function(L){["ArrowLeft","ArrowRight"].includes(L.key)&&(L.preventDefault(),L.stopPropagation(),i.handleTravellerMoveKeyboard(L.key==="ArrowRight"?1:-1,a))},onFocus:function(){i.setState({isTravellerFocused:!0})},onBlur:function(){i.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},s.renderTraveller(y,S))}},{key:"renderSlide",value:function(n,a){var o=this.props,l=o.y,i=o.height,d=o.stroke,u=o.travellerWidth,p=Math.min(n,a)+u,f=Math.max(Math.abs(a-n)-u,0);return ht.createElement("rect",{className:"recharts-brush-slide",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.handleSlideDragStart,onTouchStart:this.handleSlideDragStart,style:{cursor:"move"},stroke:"none",fill:d,fillOpacity:.2,x:p,y:l,width:f,height:i})}},{key:"renderText",value:function(){var n=this.props,a=n.startIndex,o=n.endIndex,l=n.y,i=n.height,d=n.travellerWidth,u=n.stroke,p=this.state,f=p.startX,y=p.endX,_=5,b={pointerEvents:"none",fill:u};return ht.createElement(Lo,{className:"recharts-brush-texts"},ht.createElement(Zk,Iie({textAnchor:"end",verticalAnchor:"middle",x:Math.min(f,y)-_,y:l+i/2},b),this.getTextOfTick(a)),ht.createElement(Zk,Iie({textAnchor:"start",verticalAnchor:"middle",x:Math.max(f,y)+d+_,y:l+i/2},b),this.getTextOfTick(o)))}},{key:"render",value:function(){var n=this.props,a=n.data,o=n.className,l=n.children,i=n.x,d=n.y,u=n.width,p=n.height,f=n.alwaysShowText,y=this.state,_=y.startX,b=y.endX,w=y.isTextActive,j=y.isSlideMoving,k=y.isTravellerMoving,S=y.isTravellerFocused;if(!a||!a.length||!tn(i)||!tn(d)||!tn(u)||!tn(p)||u<=0||p<=0)return null;var T=Ii("recharts-brush",o),I=ht.Children.count(l)===1,L=Aos("userSelect","none");return ht.createElement(Lo,{className:T,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:L},this.renderBackground(),I&&this.renderPanorama(),this.renderSlide(_,b),this.renderTravellerLayer(_,"startX"),this.renderTravellerLayer(b,"endX"),(w||j||k||S||f)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var a=n.x,o=n.y,l=n.width,i=n.height,d=n.stroke,u=Math.floor(o+i/2)-1;return ht.createElement(ht.Fragment,null,ht.createElement("rect",{x:a,y:o,width:l,height:i,fill:d,stroke:"none"}),ht.createElement("line",{x1:a+1,y1:u,x2:a+l-1,y2:u,fill:"none",stroke:"#fff"}),ht.createElement("line",{x1:a+1,y1:u+2,x2:a+l-1,y2:u+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(n,a){var o;return ht.isValidElement(n)?o=ht.cloneElement(n,a):gi(n)?o=n(a):o=s.renderDefaultTraveller(a),o}},{key:"getDerivedStateFromProps",value:function(n,a){var o=n.data,l=n.width,i=n.x,d=n.travellerWidth,u=n.updateId,p=n.startIndex,f=n.endIndex;if(o!==a.prevData||u!==a.prevUpdateId)return Tpe({prevData:o,prevTravellerWidth:d,prevUpdateId:u,prevX:i,prevWidth:l},o&&o.length?Fos({data:o,width:l,x:i,travellerWidth:d,startIndex:p,endIndex:f}):{scale:null,scaleValues:null});if(a.scale&&(l!==a.prevWidth||i!==a.prevX||d!==a.prevTravellerWidth)){a.scale.range([i,i+l-d]);var y=a.scale.domain().map(function(_){return a.scale(_)});return{prevData:o,prevTravellerWidth:d,prevUpdateId:u,prevX:i,prevWidth:l,startX:a.scale(n.startIndex),endX:a.scale(n.endIndex),scaleValues:y}}return null}},{key:"getIndexInRange",value:function(n,a){for(var o=n.length,l=0,i=o-1;i-l>1;){var d=Math.floor((l+i)/2);n[d]>a?i=d:l=d}return a>=n[i]?i:l}}])}(C.PureComponent);np(Y3,"displayName","Brush");np(Y3,"defaultProps",{height:40,travellerWidth:5,gap:1,fill:"#fff",stroke:"#666",padding:{top:1,right:1,bottom:1,left:1},leaveTimeOut:1e3,alwaysShowText:!1});var zos=Jwe;function Bos(t,s){var r;return zos(t,function(n,a,o){return r=s(n,a,o),!r}),!!r}var $os=Bos,qos=tYe,Uos=wy,Vos=$os,Hos=Um,Wos=dce;function Gos(t,s,r){var n=Hos(t)?qos:Vos;return r&&Wos(t,s,r)&&(s=void 0),n(t,Uos(s))}var Kos=Gos;const Zos=_o(Kos);var iy=function(s,r){var n=s.alwaysShow,a=s.ifOverflow;return n&&(a="extendDomain"),a===r},z6e=jYe;function Yos(t,s,r){s=="__proto__"&&z6e?z6e(t,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[s]=r}var Xos=Yos,Qos=Xos,Jos=bYe,els=wy;function tls(t,s){var r={};return s=els(s),Jos(t,function(n,a,o){Qos(r,a,s(n,a,o))}),r}var sls=tls;const rls=_o(sls);function nls(t,s){for(var r=-1,n=t==null?0:t.length;++r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function bls(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function wls(t,s){var r=t.x,n=t.y,a=_ls(t,gls),o="".concat(r),l=parseInt(o,10),i="".concat(n),d=parseInt(i,10),u="".concat(s.height||a.height),p=parseInt(u,10),f="".concat(s.width||a.width),y=parseInt(f,10);return NE(NE(NE(NE(NE({},s),a),l?{x:l}:{}),d?{y:d}:{}),{},{height:p,width:y,name:s.name,radius:s.radius})}function $6e(t){return ht.createElement(oQe,A0e({shapeType:"rectangle",propTransformer:wls,activeClassName:"recharts-active-bar"},t))}var jls=function(s){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return function(n,a){if(typeof s=="number")return s;var o=tn(n)||K9t(n);return o?s(n,a):(o||Xk(),r)}},Nls=["value","background"],fQe;function X3(t){"@babel/helpers - typeof";return X3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},X3(t)}function kls(t,s){if(t==null)return{};var r=Sls(t,s),n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Sls(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Die(){return Die=Object.assign?Object.assign.bind():function(t){for(var s=1;s0&&Math.abs(de)0&&Math.abs(Q)0&&(te=Math.min((Ge||0)-(Q[we-1]||0),te))}),Number.isFinite(te)){var de=te/se,re=w.layout==="vertical"?n.height:n.width;if(w.padding==="gap"&&($=de*re/2),w.padding==="no-gap"){var ae=Bh(s.barCategoryGap,de*re),le=de*re/2;$=le-ae-(le-ae)/re*ae}}}a==="xAxis"?q=[n.left+(T.left||0)+($||0),n.left+n.width-(T.right||0)-($||0)]:a==="yAxis"?q=d==="horizontal"?[n.top+n.height-(T.bottom||0),n.top+(T.top||0)]:[n.top+(T.top||0)+($||0),n.top+n.height-(T.bottom||0)-($||0)]:q=w.range,L&&(q=[q[1],q[0]]);var he=DXe(w,o,y),be=he.scale,_e=he.realScaleType;be.domain(k).range(q),OXe(be);var je=RXe(be,Tg(Tg({},w),{},{realScaleType:_e}));a==="xAxis"?(Y=j==="top"&&!I||j==="bottom"&&I,U=n.left,H=f[R]-Y*w.height):a==="yAxis"&&(Y=j==="left"&&!I||j==="right"&&I,U=f[R]-Y*w.width,H=n.top);var Ne=Tg(Tg(Tg({},w),je),{},{realScaleType:_e,x:U,y:H,scale:be,width:a==="xAxis"?n.width:w.width,height:a==="yAxis"?n.height:w.height});return Ne.bandSize=vie(Ne,je),!w.hide&&a==="xAxis"?f[R]+=(Y?-1:1)*Ne.height:w.hide||(f[R]+=(Y?-1:1)*Ne.width),Tg(Tg({},_),{},Tce({},b,Ne))},{})},_Qe=function(s,r){var n=s.x,a=s.y,o=r.x,l=r.y;return{x:Math.min(n,o),y:Math.min(a,l),width:Math.abs(o-n),height:Math.abs(l-a)}},Rls=function(s){var r=s.x1,n=s.y1,a=s.x2,o=s.y2;return _Qe({x:r,y:n},{x:a,y:o})},bQe=function(){function t(s){Lls(this,t),this.scale=s}return Dls(t,[{key:"domain",get:function(){return this.scale.domain}},{key:"range",get:function(){return this.scale.range}},{key:"rangeMin",get:function(){return this.range()[0]}},{key:"rangeMax",get:function(){return this.range()[1]}},{key:"bandwidth",get:function(){return this.scale.bandwidth}},{key:"apply",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.bandAware,o=n.position;if(r!==void 0){if(o)switch(o){case"start":return this.scale(r);case"middle":{var l=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+l}case"end":{var i=this.bandwidth?this.bandwidth():0;return this.scale(r)+i}default:return this.scale(r)}if(a){var d=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+d}return this.scale(r)}}},{key:"isInRange",value:function(r){var n=this.range(),a=n[0],o=n[n.length-1];return a<=o?r>=a&&r<=o:r>=o&&r<=a}}],[{key:"create",value:function(r){return new t(r)}}])}();Tce(bQe,"EPS",1e-4);var M2e=function(s){var r=Object.keys(s).reduce(function(n,a){return Tg(Tg({},n),{},Tce({},a,bQe.create(s[a])))},{});return Tg(Tg({},r),{},{apply:function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=o.bandAware,i=o.position;return rls(a,function(d,u){return r[u].apply(d,{bandAware:l,position:i})})},isInRange:function(a){return pQe(a,function(o,l){return r[l].isInRange(o)})}})};function Fls(t){return(t%180+180)%180}var zls=function(s){var r=s.width,n=s.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=Fls(a),l=o*Math.PI/180,i=Math.atan(n/r),d=l>i&&l-1?a[o?s[l]:l]:void 0}}var Vls=Uls,Hls=dQe;function Wls(t){var s=Hls(t),r=s%1;return s===s?r?s-r:s:0}var Gls=Wls,Kls=fYe,Zls=wy,Yls=Gls,Xls=Math.max;function Qls(t,s,r){var n=t==null?0:t.length;if(!n)return-1;var a=r==null?0:Yls(r);return a<0&&(a=Xls(n+a,0)),Kls(t,Zls(s),a)}var Jls=Qls,ecs=Vls,tcs=Jls,scs=ecs(tcs),rcs=scs;const ncs=_o(rcs);var acs=e9t(function(t){return{x:t.left,y:t.top,width:t.width,height:t.height}},function(t){return["l",t.left,"t",t.top,"w",t.width,"h",t.height].join("")}),T2e=C.createContext(void 0),A2e=C.createContext(void 0),wQe=C.createContext(void 0),jQe=C.createContext({}),NQe=C.createContext(void 0),kQe=C.createContext(0),SQe=C.createContext(0),W6e=function(s){var r=s.state,n=r.xAxisMap,a=r.yAxisMap,o=r.offset,l=s.clipPathId,i=s.children,d=s.width,u=s.height,p=acs(o);return ht.createElement(T2e.Provider,{value:n},ht.createElement(A2e.Provider,{value:a},ht.createElement(jQe.Provider,{value:o},ht.createElement(wQe.Provider,{value:p},ht.createElement(NQe.Provider,{value:l},ht.createElement(kQe.Provider,{value:u},ht.createElement(SQe.Provider,{value:d},i)))))))},ics=function(){return C.useContext(NQe)},CQe=function(s){var r=C.useContext(T2e);r==null&&Xk();var n=r[s];return n==null&&Xk(),n},ocs=function(){var s=C.useContext(T2e);return M1(s)},lcs=function(){var s=C.useContext(A2e),r=ncs(s,function(n){return pQe(n.domain,Number.isFinite)});return r||M1(s)},MQe=function(s){var r=C.useContext(A2e);r==null&&Xk();var n=r[s];return n==null&&Xk(),n},ccs=function(){var s=C.useContext(wQe);return s},dcs=function(){return C.useContext(jQe)},E2e=function(){return C.useContext(SQe)},P2e=function(){return C.useContext(kQe)};function Q3(t){"@babel/helpers - typeof";return Q3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Q3(t)}function ucs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function hcs(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);rt*a)return!1;var o=r();return t*(s-t*o/2-n)>=0&&t*(s+t*o/2-a)<=0}function Gcs(t,s){return DQe(t,s+1)}function Kcs(t,s,r,n,a){for(var o=(n||[]).slice(),l=s.start,i=s.end,d=0,u=1,p=l,f=function(){var b=n==null?void 0:n[d];if(b===void 0)return{v:DQe(n,u)};var w=d,j,k=function(){return j===void 0&&(j=r(b,w)),j},S=b.coordinate,T=d===0||Bie(t,S,k,p,i);T||(d=0,p=l,u+=1),T&&(p=S+t*(k()/2+a),d+=u)},y;u<=o.length;)if(y=f(),y)return y.v;return[]}function oL(t){"@babel/helpers - typeof";return oL=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},oL(t)}function eLe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Xu(t){for(var s=1;s0?_.coordinate-j*t:_.coordinate})}else o[y]=_=Xu(Xu({},_),{},{tickCoord:_.coordinate});var k=Bie(t,_.tickCoord,w,i,d);k&&(d=_.tickCoord-t*(w()/2+a),o[y]=Xu(Xu({},_),{},{isShow:!0}))},p=l-1;p>=0;p--)u(p);return o}function Jcs(t,s,r,n,a,o){var l=(n||[]).slice(),i=l.length,d=s.start,u=s.end;if(o){var p=n[i-1],f=r(p,i-1),y=t*(p.coordinate+t*f/2-u);l[i-1]=p=Xu(Xu({},p),{},{tickCoord:y>0?p.coordinate-y*t:p.coordinate});var _=Bie(t,p.tickCoord,function(){return f},d,u);_&&(u=p.tickCoord-t*(f/2+a),l[i-1]=Xu(Xu({},p),{},{isShow:!0}))}for(var b=o?i-1:i,w=function(S){var T=l[S],I,L=function(){return I===void 0&&(I=r(T,S)),I};if(S===0){var R=t*(T.coordinate-t*L()/2-d);l[S]=T=Xu(Xu({},T),{},{tickCoord:R<0?T.coordinate-R*t:T.coordinate})}else l[S]=T=Xu(Xu({},T),{},{tickCoord:T.coordinate});var $=Bie(t,T.tickCoord,L,d,u);$&&(d=T.tickCoord+t*(L()/2+a),l[S]=Xu(Xu({},T),{},{isShow:!0}))},j=0;j=2?zh(a[1].coordinate-a[0].coordinate):1,k=Wcs(o,j,_);return d==="equidistantPreserveStart"?Kcs(j,k,w,a,l):(d==="preserveStart"||d==="preserveStartEnd"?y=Jcs(j,k,w,a,l,d==="preserveStartEnd"):y=Qcs(j,k,w,a,l),y.filter(function(S){return S.isShow}))}var eds=["viewBox"],tds=["viewBox"],sds=["ticks"];function tM(t){"@babel/helpers - typeof";return tM=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},tM(t)}function J4(){return J4=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function rds(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function nds(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function sLe(t,s){for(var r=0;r0?d(this.props):d(_)),l<=0||i<=0||!b||!b.length?null:ht.createElement(Lo,{className:Ii("recharts-cartesian-axis",u),ref:function(j){n.layerReference=j}},o&&this.renderAxisLine(),this.renderTicks(b,this.state.fontSize,this.state.letterSpacing),hu.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,o){var l,i=Ii(a.className,"recharts-cartesian-axis-tick-value");return ht.isValidElement(n)?l=ht.cloneElement(n,Pd(Pd({},a),{},{className:i})):gi(n)?l=n(Pd(Pd({},a),{},{className:i})):l=ht.createElement(Zk,J4({},a,{className:"recharts-cartesian-axis-tick-value"}),o),l}}])}(C.Component);O2e(QM,"displayName","CartesianAxis");O2e(QM,"defaultProps",{x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd"});var uds=["x1","y1","x2","y2","key"],hds=["offset"];function Qk(t){"@babel/helpers - typeof";return Qk=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Qk(t)}function rLe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function eh(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function gds(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var xds=function(s){var r=s.fill;if(!r||r==="none")return null;var n=s.fillOpacity,a=s.x,o=s.y,l=s.width,i=s.height,d=s.ry;return ht.createElement("rect",{x:a,y:o,ry:d,width:l,height:i,stroke:"none",fill:r,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function FQe(t,s){var r;if(ht.isValidElement(t))r=ht.cloneElement(t,s);else if(gi(t))r=t(s);else{var n=s.x1,a=s.y1,o=s.x2,l=s.y2,i=s.key,d=nLe(s,uds),u=Ga(d,!1);u.offset;var p=nLe(u,hds);r=ht.createElement("line",HN({},p,{x1:n,y1:a,x2:o,y2:l,fill:"none",key:i}))}return r}function yds(t){var s=t.x,r=t.width,n=t.horizontal,a=n===void 0?!0:n,o=t.horizontalPoints;if(!a||!o||!o.length)return null;var l=o.map(function(i,d){var u=eh(eh({},t),{},{x1:s,y1:i,x2:s+r,y2:i,key:"line-".concat(d),index:d});return FQe(a,u)});return ht.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function vds(t){var s=t.y,r=t.height,n=t.vertical,a=n===void 0?!0:n,o=t.verticalPoints;if(!a||!o||!o.length)return null;var l=o.map(function(i,d){var u=eh(eh({},t),{},{x1:i,y1:s,x2:i,y2:s+r,key:"line-".concat(d),index:d});return FQe(a,u)});return ht.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function _ds(t){var s=t.horizontalFill,r=t.fillOpacity,n=t.x,a=t.y,o=t.width,l=t.height,i=t.horizontalPoints,d=t.horizontal,u=d===void 0?!0:d;if(!u||!s||!s.length)return null;var p=i.map(function(y){return Math.round(y+a-a)}).sort(function(y,_){return y-_});a!==p[0]&&p.unshift(0);var f=p.map(function(y,_){var b=!p[_+1],w=b?a+l-y:p[_+1]-y;if(w<=0)return null;var j=_%s.length;return ht.createElement("rect",{key:"react-".concat(_),y,x:n,height:w,width:o,stroke:"none",fill:s[j],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return ht.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},f)}function bds(t){var s=t.vertical,r=s===void 0?!0:s,n=t.verticalFill,a=t.fillOpacity,o=t.x,l=t.y,i=t.width,d=t.height,u=t.verticalPoints;if(!r||!n||!n.length)return null;var p=u.map(function(y){return Math.round(y+o-o)}).sort(function(y,_){return y-_});o!==p[0]&&p.unshift(0);var f=p.map(function(y,_){var b=!p[_+1],w=b?o+i-y:p[_+1]-y;if(w<=0)return null;var j=_%n.length;return ht.createElement("rect",{key:"react-".concat(_),x:y,y:l,width:w,height:d,stroke:"none",fill:n[j],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return ht.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},f)}var wds=function(s,r){var n=s.xAxis,a=s.width,o=s.height,l=s.offset;return LXe(D2e(eh(eh(eh({},QM.defaultProps),n),{},{ticks:M0(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.left,l.left+l.width,r)},jds=function(s,r){var n=s.yAxis,a=s.width,o=s.height,l=s.offset;return LXe(D2e(eh(eh(eh({},QM.defaultProps),n),{},{ticks:M0(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.top,l.top+l.height,r)},y4={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function zQe(t){var s,r,n,a,o,l,i=E2e(),d=P2e(),u=dcs(),p=eh(eh({},t),{},{stroke:(s=t.stroke)!==null&&s!==void 0?s:y4.stroke,fill:(r=t.fill)!==null&&r!==void 0?r:y4.fill,horizontal:(n=t.horizontal)!==null&&n!==void 0?n:y4.horizontal,horizontalFill:(a=t.horizontalFill)!==null&&a!==void 0?a:y4.horizontalFill,vertical:(o=t.vertical)!==null&&o!==void 0?o:y4.vertical,verticalFill:(l=t.verticalFill)!==null&&l!==void 0?l:y4.verticalFill,x:tn(t.x)?t.x:u.left,y:tn(t.y)?t.y:u.top,width:tn(t.width)?t.width:u.width,height:tn(t.height)?t.height:u.height}),f=p.x,y=p.y,_=p.width,b=p.height,w=p.syncWithTicks,j=p.horizontalValues,k=p.verticalValues,S=ocs(),T=lcs();if(!tn(_)||_<=0||!tn(b)||b<=0||!tn(f)||f!==+f||!tn(y)||y!==+y)return null;var I=p.verticalCoordinatesGenerator||wds,L=p.horizontalCoordinatesGenerator||jds,R=p.horizontalPoints,$=p.verticalPoints;if((!R||!R.length)&&gi(L)){var q=j&&j.length,U=L({yAxis:T?eh(eh({},T),{},{ticks:q?j:T.ticks}):void 0,width:i,height:d,offset:u},q?!0:w);Kg(Array.isArray(U),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(Qk(U),"]")),Array.isArray(U)&&(R=U)}if((!$||!$.length)&&gi(I)){var H=k&&k.length,Y=I({xAxis:S?eh(eh({},S),{},{ticks:H?k:S.ticks}):void 0,width:i,height:d,offset:u},H?!0:w);Kg(Array.isArray(Y),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(Qk(Y),"]")),Array.isArray(Y)&&($=Y)}return ht.createElement("g",{className:"recharts-cartesian-grid"},ht.createElement(xds,{fill:p.fill,fillOpacity:p.fillOpacity,x:p.x,y:p.y,width:p.width,height:p.height,ry:p.ry}),ht.createElement(yds,HN({},p,{offset:u,horizontalPoints:R,xAxis:S,yAxis:T})),ht.createElement(vds,HN({},p,{offset:u,verticalPoints:$,xAxis:S,yAxis:T})),ht.createElement(_ds,HN({},p,{horizontalPoints:R})),ht.createElement(bds,HN({},p,{verticalPoints:$})))}zQe.displayName="CartesianGrid";var Nds=["type","layout","connectNulls","ref"],kds=["key"];function sM(t){"@babel/helpers - typeof";return sM=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},sM(t)}function aLe(t,s){if(t==null)return{};var r=Sds(t,s),n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Sds(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function MI(){return MI=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);rf){_=[].concat(v4(d.slice(0,b)),[f-w]);break}var j=_.length%2===0?[0,y]:[y];return[].concat(v4(s.repeat(d,p)),v4(_),j).map(function(k){return"".concat(k,"px")}).join(", ")}),Ag(r,"id",HM("recharts-line-")),Ag(r,"pathRef",function(l){r.mainCurve=l}),Ag(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),Ag(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return Ods(s,t),Pds(s,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();this.setState({totalLength:n})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();n!==this.state.totalLength&&this.setState({totalLength:n})}}},{key:"getTotalLength",value:function(){var n=this.mainCurve;try{return n&&n.getTotalLength&&n.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(n,a){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,l=o.points,i=o.xAxis,d=o.yAxis,u=o.layout,p=o.children,f=kp(p,mD);if(!f)return null;var y=function(w,j){return{x:w.x,y:w.y,value:w.value,errorVal:$d(w.payload,j)}},_={clipPath:n?"url(#clipPath-".concat(a,")"):null};return ht.createElement(Lo,_,f.map(function(b){return ht.cloneElement(b,{key:"bar-".concat(b.props.dataKey),data:l,xAxis:i,yAxis:d,layout:u,dataPointFormatter:y})}))}},{key:"renderDots",value:function(n,a,o){var l=this.props.isAnimationActive;if(l&&!this.state.isAnimationFinished)return null;var i=this.props,d=i.dot,u=i.points,p=i.dataKey,f=Ga(this.props,!1),y=Ga(d,!0),_=u.map(function(w,j){var k=rp(rp(rp({key:"dot-".concat(j),r:3},f),y),{},{index:j,cx:w.x,cy:w.y,value:w.value,dataKey:p,payload:w.payload,points:u});return s.renderDotItem(d,k)}),b={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(o,")"):null};return ht.createElement(Lo,MI({className:"recharts-line-dots",key:"dots"},b),_)}},{key:"renderCurveStatically",value:function(n,a,o,l){var i=this.props,d=i.type,u=i.layout,p=i.connectNulls;i.ref;var f=aLe(i,Nds),y=rp(rp(rp({},Ga(f,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(o,")"):null,points:n},l),{},{type:d,layout:u,connectNulls:p});return ht.createElement(wie,MI({},y,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(n,a){var o=this,l=this.props,i=l.points,d=l.strokeDasharray,u=l.isAnimationActive,p=l.animationBegin,f=l.animationDuration,y=l.animationEasing,_=l.animationId,b=l.animateNewValues,w=l.width,j=l.height,k=this.state,S=k.prevPoints,T=k.totalLength;return ht.createElement(fy,{begin:p,duration:f,isActive:u,easing:y,from:{t:0},to:{t:1},key:"line-".concat(_),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(I){var L=I.t;if(S){var R=S.length/i.length,$=i.map(function(se,te){var Q=Math.floor(te*R);if(S[Q]){var de=S[Q],re=cp(de.x,se.x),ae=cp(de.y,se.y);return rp(rp({},se),{},{x:re(L),y:ae(L)})}if(b){var le=cp(w*2,se.x),he=cp(j/2,se.y);return rp(rp({},se),{},{x:le(L),y:he(L)})}return rp(rp({},se),{},{x:se.x,y:se.y})});return o.renderCurveStatically($,n,a)}var q=cp(0,T),U=q(L),H;if(d){var Y="".concat(d).split(/[,\s]+/gim).map(function(se){return parseFloat(se)});H=o.getStrokeDasharray(U,T,Y)}else H=o.generateSimpleStrokeDasharray(T,U);return o.renderCurveStatically(i,n,a,{strokeDasharray:H})})}},{key:"renderCurve",value:function(n,a){var o=this.props,l=o.points,i=o.isAnimationActive,d=this.state,u=d.prevPoints,p=d.totalLength;return i&&l&&l.length&&(!u&&p>0||!hD(u,l))?this.renderCurveWithAnimation(n,a):this.renderCurveStatically(l,n,a)}},{key:"render",value:function(){var n,a=this.props,o=a.hide,l=a.dot,i=a.points,d=a.className,u=a.xAxis,p=a.yAxis,f=a.top,y=a.left,_=a.width,b=a.height,w=a.isAnimationActive,j=a.id;if(o||!i||!i.length)return null;var k=this.state.isAnimationFinished,S=i.length===1,T=Ii("recharts-line",d),I=u&&u.allowDataOverflow,L=p&&p.allowDataOverflow,R=I||L,$=Ai(j)?this.id:j,q=(n=Ga(l,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},U=q.r,H=U===void 0?3:U,Y=q.strokeWidth,se=Y===void 0?2:Y,te=i$t(l)?l:{},Q=te.clipDot,de=Q===void 0?!0:Q,re=H*2+se;return ht.createElement(Lo,{className:T},I||L?ht.createElement("defs",null,ht.createElement("clipPath",{id:"clipPath-".concat($)},ht.createElement("rect",{x:I?y:y-_/2,y:L?f:f-b/2,width:I?_:_*2,height:L?b:b*2})),!de&&ht.createElement("clipPath",{id:"clipPath-dots-".concat($)},ht.createElement("rect",{x:y-re/2,y:f-re/2,width:_+re,height:b+re}))):null,!S&&this.renderCurve(R,$),this.renderErrorBar(R,$),(S||l)&&this.renderDots(R,de,$),(!w||k)&&K0.renderCallByParent(this.props,i))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,prevPoints:a.curPoints}:n.points!==a.curPoints?{curPoints:n.points}:null}},{key:"repeat",value:function(n,a){for(var o=n.length%2!==0?[].concat(v4(n),[0]):n,l=[],i=0;it.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function kus(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Sus(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Cus(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r0?l:s&&s.length&&tn(a)&&tn(o)?s.slice(a,o+1):[]};function tJe(t){return t==="number"?[0,"auto"]:void 0}var Z0e=function(s,r,n,a){var o=s.graphicalItems,l=s.tooltipAxis,i=Lce(r,s);return n<0||!o||!o.length||n>=i.length?null:o.reduce(function(d,u){var p,f=(p=u.props.data)!==null&&p!==void 0?p:r;f&&s.dataStartIndex+s.dataEndIndex!==0&&s.dataEndIndex-s.dataStartIndex>=n&&(f=f.slice(s.dataStartIndex,s.dataEndIndex+1));var y;if(l.dataKey&&!l.allowDuplicatedCategory){var _=f===void 0?i:f;y=Hae(_,l.dataKey,a)}else y=f&&f[n]||i[n];return y?[].concat(iM(d),[zXe(u,y)]):d},[])},mLe=function(s,r,n,a){var o=a||{x:s.chartX,y:s.chartY},l=zus(o,n),i=s.orderedTooltipTicks,d=s.tooltipAxis,u=s.tooltipTicks,p=oss(l,i,u,d);if(p>=0&&u){var f=u[p]&&u[p].value,y=Z0e(s,r,p,f),_=Bus(n,i,p,o);return{activeTooltipIndex:p,activeLabel:f,activePayload:y,activeCoordinate:_}}return null},$us=function(s,r){var n=r.axes,a=r.graphicalItems,o=r.axisType,l=r.axisIdKey,i=r.stackGroups,d=r.dataStartIndex,u=r.dataEndIndex,p=s.layout,f=s.children,y=s.stackOffset,_=IXe(p,o);return n.reduce(function(b,w){var j,k=w.type.defaultProps!==void 0?vr(vr({},w.type.defaultProps),w.props):w.props,S=k.type,T=k.dataKey,I=k.allowDataOverflow,L=k.allowDuplicatedCategory,R=k.scale,$=k.ticks,q=k.includeHidden,U=k[l];if(b[U])return b;var H=Lce(s.data,{graphicalItems:a.filter(function(je){var Ne,Ge=l in je.props?je.props[l]:(Ne=je.type.defaultProps)===null||Ne===void 0?void 0:Ne[l];return Ge===U}),dataStartIndex:d,dataEndIndex:u}),Y=H.length,se,te,Q;mus(k.domain,I,S)&&(se=c0e(k.domain,null,I),_&&(S==="number"||R!=="auto")&&(Q=NI(H,T,"category")));var de=tJe(S);if(!se||se.length===0){var re,ae=(re=k.domain)!==null&&re!==void 0?re:de;if(T){if(se=NI(H,T,S),S==="category"&&_){var le=Y9t(se);L&&le?(te=se,se=Pie(0,Y)):L||(se=DIe(ae,se,w).reduce(function(je,Ne){return je.indexOf(Ne)>=0?je:[].concat(iM(je),[Ne])},[]))}else if(S==="category")L?se=se.filter(function(je){return je!==""&&!Ai(je)}):se=DIe(ae,se,w).reduce(function(je,Ne){return je.indexOf(Ne)>=0||Ne===""||Ai(Ne)?je:[].concat(iM(je),[Ne])},[]);else if(S==="number"){var he=hss(H,a.filter(function(je){var Ne,Ge,we=l in je.props?je.props[l]:(Ne=je.type.defaultProps)===null||Ne===void 0?void 0:Ne[l],Me="hide"in je.props?je.props.hide:(Ge=je.type.defaultProps)===null||Ge===void 0?void 0:Ge.hide;return we===U&&(q||!Me)}),T,o,p);he&&(se=he)}_&&(S==="number"||R!=="auto")&&(Q=NI(H,T,"category"))}else _?se=Pie(0,Y):i&&i[U]&&i[U].hasStack&&S==="number"?se=y==="expand"?[0,1]:FXe(i[U].stackGroups,d,u):se=PXe(H,a.filter(function(je){var Ne=l in je.props?je.props[l]:je.type.defaultProps[l],Ge="hide"in je.props?je.props.hide:je.type.defaultProps.hide;return Ne===U&&(q||!Ge)}),S,p,!0);if(S==="number")se=W0e(f,se,U,o,$),ae&&(se=c0e(ae,se,I));else if(S==="category"&&ae){var be=ae,_e=se.every(function(je){return be.indexOf(je)>=0});_e&&(se=be)}}return vr(vr({},b),{},ei({},U,vr(vr({},k),{},{axisType:o,domain:se,categoricalDomain:Q,duplicateDomain:te,originalDomain:(j=k.domain)!==null&&j!==void 0?j:de,isCategorical:_,layout:p})))},{})},qus=function(s,r){var n=r.graphicalItems,a=r.Axis,o=r.axisType,l=r.axisIdKey,i=r.stackGroups,d=r.dataStartIndex,u=r.dataEndIndex,p=s.layout,f=s.children,y=Lce(s.data,{graphicalItems:n,dataStartIndex:d,dataEndIndex:u}),_=y.length,b=IXe(p,o),w=-1;return n.reduce(function(j,k){var S=k.type.defaultProps!==void 0?vr(vr({},k.type.defaultProps),k.props):k.props,T=S[l],I=tJe("number");if(!j[T]){w++;var L;return b?L=Pie(0,_):i&&i[T]&&i[T].hasStack?(L=FXe(i[T].stackGroups,d,u),L=W0e(f,L,T,o)):(L=c0e(I,PXe(y,n.filter(function(R){var $,q,U=l in R.props?R.props[l]:($=R.type.defaultProps)===null||$===void 0?void 0:$[l],H="hide"in R.props?R.props.hide:(q=R.type.defaultProps)===null||q===void 0?void 0:q.hide;return U===T&&!H}),"number",p),a.defaultProps.allowDataOverflow),L=W0e(f,L,T,o)),vr(vr({},j),{},ei({},T,vr(vr({axisType:o},a.defaultProps),{},{hide:!0,orientation:Np(Rus,"".concat(o,".").concat(w%2),null),domain:L,originalDomain:I,isCategorical:b,layout:p})))}return j},{})},Uus=function(s,r){var n=r.axisType,a=n===void 0?"xAxis":n,o=r.AxisComp,l=r.graphicalItems,i=r.stackGroups,d=r.dataStartIndex,u=r.dataEndIndex,p=s.children,f="".concat(a,"Id"),y=kp(p,o),_={};return y&&y.length?_=$us(s,{axes:y,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:d,dataEndIndex:u}):l&&l.length&&(_=qus(s,{Axis:o,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:d,dataEndIndex:u})),_},Vus=function(s){var r=M1(s),n=M0(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:e2e(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:vie(r,n)}},pLe=function(s){var r=s.children,n=s.defaultShowTooltip,a=ip(r,Y3),o=0,l=0;return s.data&&s.data.length!==0&&(l=s.data.length-1),a&&a.props&&(a.props.startIndex>=0&&(o=a.props.startIndex),a.props.endIndex>=0&&(l=a.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:o,dataEndIndex:l,activeTooltipIndex:-1,isTooltipActive:!!n}},Hus=function(s){return!s||!s.length?!1:s.some(function(r){var n=W0(r&&r.type);return n&&n.indexOf("Bar")>=0})},fLe=function(s){return s==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:s==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:s==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},Wus=function(s,r){var n=s.props,a=s.graphicalItems,o=s.xAxisMap,l=o===void 0?{}:o,i=s.yAxisMap,d=i===void 0?{}:i,u=n.width,p=n.height,f=n.children,y=n.margin||{},_=ip(f,Y3),b=ip(f,H5),w=Object.keys(d).reduce(function(L,R){var $=d[R],q=$.orientation;return!$.mirror&&!$.hide?vr(vr({},L),{},ei({},q,L[q]+$.width)):L},{left:y.left||0,right:y.right||0}),j=Object.keys(l).reduce(function(L,R){var $=l[R],q=$.orientation;return!$.mirror&&!$.hide?vr(vr({},L),{},ei({},q,Np(L,"".concat(q))+$.height)):L},{top:y.top||0,bottom:y.bottom||0}),k=vr(vr({},j),w),S=k.bottom;_&&(k.bottom+=_.props.height||Y3.defaultProps.height),b&&r&&(k=dss(k,a,n,r));var T=u-k.left-k.right,I=p-k.top-k.bottom;return vr(vr({brushBottom:S},k),{},{width:Math.max(T,0),height:Math.max(I,0)})},Gus=function(s,r){if(r==="xAxis")return s[r].width;if(r==="yAxis")return s[r].height},R2e=function(s){var r=s.chartName,n=s.GraphicalChild,a=s.defaultTooltipEventType,o=a===void 0?"axis":a,l=s.validateTooltipEventTypes,i=l===void 0?["axis"]:l,d=s.axisComponents,u=s.legendContent,p=s.formatAxisMap,f=s.defaultProps,y=function(k,S){var T=S.graphicalItems,I=S.stackGroups,L=S.offset,R=S.updateId,$=S.dataStartIndex,q=S.dataEndIndex,U=k.barSize,H=k.layout,Y=k.barGap,se=k.barCategoryGap,te=k.maxBarSize,Q=fLe(H),de=Q.numericAxisName,re=Q.cateAxisName,ae=Hus(T),le=[];return T.forEach(function(he,be){var _e=Lce(k.data,{graphicalItems:[he],dataStartIndex:$,dataEndIndex:q}),je=he.type.defaultProps!==void 0?vr(vr({},he.type.defaultProps),he.props):he.props,Ne=je.dataKey,Ge=je.maxBarSize,we=je["".concat(de,"Id")],Me=je["".concat(re,"Id")],Te={},Fe=d.reduce(function(ct,qe){var Ze=S["".concat(qe.axisType,"Map")],Qe=je["".concat(qe.axisType,"Id")];Ze&&Ze[Qe]||qe.axisType==="zAxis"||Xk();var We=Ze[Qe];return vr(vr({},ct),{},ei(ei({},qe.axisType,We),"".concat(qe.axisType,"Ticks"),M0(We)))},Te),Ae=Fe[re],Ue=Fe["".concat(re,"Ticks")],ut=I&&I[we]&&I[we].hasStack&&bss(he,I[we].stackGroups),De=W0(he.type).indexOf("Bar")>=0,Rt=vie(Ae,Ue),me=[],Xe=ae&&lss({barSize:U,stackGroups:I,totalSize:Gus(Fe,re)});if(De){var ot,nt,Se=Ai(Ge)?te:Ge,it=(ot=(nt=vie(Ae,Ue,!0))!==null&&nt!==void 0?nt:Se)!==null&&ot!==void 0?ot:0;me=css({barGap:Y,barCategoryGap:se,bandSize:it!==Rt?it:Rt,sizeList:Xe[Me],maxBarSize:Se}),it!==Rt&&(me=me.map(function(ct){return vr(vr({},ct),{},{position:vr(vr({},ct.position),{},{offset:ct.position.offset-it/2})})}))}var $e=he&&he.type&&he.type.getComposedData;$e&&le.push({props:vr(vr({},$e(vr(vr({},Fe),{},{displayedData:_e,props:k,dataKey:Ne,item:he,bandSize:Rt,barPosition:me,offset:L,stackedData:ut,layout:H,dataStartIndex:$,dataEndIndex:q}))),{},ei(ei(ei({key:he.key||"item-".concat(be)},de,Fe[de]),re,Fe[re]),"animationId",R)),childIndex:c$t(he,k.children),item:he})}),le},_=function(k,S){var T=k.props,I=k.dataStartIndex,L=k.dataEndIndex,R=k.updateId;if(!MEe({props:T}))return null;var $=T.children,q=T.layout,U=T.stackOffset,H=T.data,Y=T.reverseStackOrder,se=fLe(q),te=se.numericAxisName,Q=se.cateAxisName,de=kp($,n),re=vss(H,de,"".concat(te,"Id"),"".concat(Q,"Id"),U,Y),ae=d.reduce(function(je,Ne){var Ge="".concat(Ne.axisType,"Map");return vr(vr({},je),{},ei({},Ge,Uus(T,vr(vr({},Ne),{},{graphicalItems:de,stackGroups:Ne.axisType===te&&re,dataStartIndex:I,dataEndIndex:L}))))},{}),le=Wus(vr(vr({},ae),{},{props:T,graphicalItems:de}),S==null?void 0:S.legendBBox);Object.keys(ae).forEach(function(je){ae[je]=p(T,ae[je],le,je.replace("Map",""),r)});var he=ae["".concat(Q,"Map")],be=Vus(he),_e=y(T,vr(vr({},ae),{},{dataStartIndex:I,dataEndIndex:L,updateId:R,graphicalItems:de,stackGroups:re,offset:le}));return vr(vr({formattedGraphicalItems:_e,graphicalItems:de,offset:le,stackGroups:re},be),ae)},b=function(j){function k(S){var T,I,L;return Sus(this,k),L=Tus(this,k,[S]),ei(L,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),ei(L,"accessibilityManager",new hus),ei(L,"handleLegendBBoxUpdate",function(R){if(R){var $=L.state,q=$.dataStartIndex,U=$.dataEndIndex,H=$.updateId;L.setState(vr({legendBBox:R},_({props:L.props,dataStartIndex:q,dataEndIndex:U,updateId:H},vr(vr({},L.state),{},{legendBBox:R}))))}}),ei(L,"handleReceiveSyncEvent",function(R,$,q){if(L.props.syncId===R){if(q===L.eventEmitterSymbol&&typeof L.props.syncMethod!="function")return;L.applySyncEvent($)}}),ei(L,"handleBrushChange",function(R){var $=R.startIndex,q=R.endIndex;if($!==L.state.dataStartIndex||q!==L.state.dataEndIndex){var U=L.state.updateId;L.setState(function(){return vr({dataStartIndex:$,dataEndIndex:q},_({props:L.props,dataStartIndex:$,dataEndIndex:q,updateId:U},L.state))}),L.triggerSyncEvent({dataStartIndex:$,dataEndIndex:q})}}),ei(L,"handleMouseEnter",function(R){var $=L.getMouseInfo(R);if($){var q=vr(vr({},$),{},{isTooltipActive:!0});L.setState(q),L.triggerSyncEvent(q);var U=L.props.onMouseEnter;gi(U)&&U(q,R)}}),ei(L,"triggeredAfterMouseMove",function(R){var $=L.getMouseInfo(R),q=$?vr(vr({},$),{},{isTooltipActive:!0}):{isTooltipActive:!1};L.setState(q),L.triggerSyncEvent(q);var U=L.props.onMouseMove;gi(U)&&U(q,R)}),ei(L,"handleItemMouseEnter",function(R){L.setState(function(){return{isTooltipActive:!0,activeItem:R,activePayload:R.tooltipPayload,activeCoordinate:R.tooltipPosition||{x:R.cx,y:R.cy}}})}),ei(L,"handleItemMouseLeave",function(){L.setState(function(){return{isTooltipActive:!1}})}),ei(L,"handleMouseMove",function(R){R.persist(),L.throttleTriggeredAfterMouseMove(R)}),ei(L,"handleMouseLeave",function(R){L.throttleTriggeredAfterMouseMove.cancel();var $={isTooltipActive:!1};L.setState($),L.triggerSyncEvent($);var q=L.props.onMouseLeave;gi(q)&&q($,R)}),ei(L,"handleOuterEvent",function(R){var $=l$t(R),q=Np(L.props,"".concat($));if($&&gi(q)){var U,H;/.*touch.*/i.test($)?H=L.getMouseInfo(R.changedTouches[0]):H=L.getMouseInfo(R),q((U=H)!==null&&U!==void 0?U:{},R)}}),ei(L,"handleClick",function(R){var $=L.getMouseInfo(R);if($){var q=vr(vr({},$),{},{isTooltipActive:!0});L.setState(q),L.triggerSyncEvent(q);var U=L.props.onClick;gi(U)&&U(q,R)}}),ei(L,"handleMouseDown",function(R){var $=L.props.onMouseDown;if(gi($)){var q=L.getMouseInfo(R);$(q,R)}}),ei(L,"handleMouseUp",function(R){var $=L.props.onMouseUp;if(gi($)){var q=L.getMouseInfo(R);$(q,R)}}),ei(L,"handleTouchMove",function(R){R.changedTouches!=null&&R.changedTouches.length>0&&L.throttleTriggeredAfterMouseMove(R.changedTouches[0])}),ei(L,"handleTouchStart",function(R){R.changedTouches!=null&&R.changedTouches.length>0&&L.handleMouseDown(R.changedTouches[0])}),ei(L,"handleTouchEnd",function(R){R.changedTouches!=null&&R.changedTouches.length>0&&L.handleMouseUp(R.changedTouches[0])}),ei(L,"handleDoubleClick",function(R){var $=L.props.onDoubleClick;if(gi($)){var q=L.getMouseInfo(R);$(q,R)}}),ei(L,"handleContextMenu",function(R){var $=L.props.onContextMenu;if(gi($)){var q=L.getMouseInfo(R);$(q,R)}}),ei(L,"triggerSyncEvent",function(R){L.props.syncId!==void 0&&Epe.emit(Ppe,L.props.syncId,R,L.eventEmitterSymbol)}),ei(L,"applySyncEvent",function(R){var $=L.props,q=$.layout,U=$.syncMethod,H=L.state.updateId,Y=R.dataStartIndex,se=R.dataEndIndex;if(R.dataStartIndex!==void 0||R.dataEndIndex!==void 0)L.setState(vr({dataStartIndex:Y,dataEndIndex:se},_({props:L.props,dataStartIndex:Y,dataEndIndex:se,updateId:H},L.state)));else if(R.activeTooltipIndex!==void 0){var te=R.chartX,Q=R.chartY,de=R.activeTooltipIndex,re=L.state,ae=re.offset,le=re.tooltipTicks;if(!ae)return;if(typeof U=="function")de=U(le,R);else if(U==="value"){de=-1;for(var he=0;he=0){var ut,De;if(te.dataKey&&!te.allowDuplicatedCategory){var Rt=typeof te.dataKey=="function"?Ue:"payload.".concat(te.dataKey.toString());ut=Hae(he,Rt,de),De=be&&_e&&Hae(_e,Rt,de)}else ut=he==null?void 0:he[Q],De=be&&_e&&_e[Q];if(Me||we){var me=R.props.activeIndex!==void 0?R.props.activeIndex:Q;return[C.cloneElement(R,vr(vr(vr({},U.props),Fe),{},{activeIndex:me})),null,null]}if(!Ai(ut))return[Ae].concat(iM(L.renderActivePoints({item:U,activePoint:ut,basePoint:De,childIndex:Q,isRange:be})))}else{var Xe,ot=(Xe=L.getItemByXY(L.state.activeCoordinate))!==null&&Xe!==void 0?Xe:{graphicalItem:Ae},nt=ot.graphicalItem,Se=nt.item,it=Se===void 0?R:Se,$e=nt.childIndex,ct=vr(vr(vr({},U.props),Fe),{},{activeIndex:$e});return[C.cloneElement(it,ct),null,null]}return be?[Ae,null,null]:[Ae,null]}),ei(L,"renderCustomized",function(R,$,q){return C.cloneElement(R,vr(vr({key:"recharts-customized-".concat(q)},L.props),L.state))}),ei(L,"renderMap",{CartesianGrid:{handler:LR,once:!0},ReferenceArea:{handler:L.renderReferenceElement},ReferenceLine:{handler:LR},ReferenceDot:{handler:L.renderReferenceElement},XAxis:{handler:LR},YAxis:{handler:LR},Brush:{handler:L.renderBrush,once:!0},Bar:{handler:L.renderGraphicChild},Line:{handler:L.renderGraphicChild},Area:{handler:L.renderGraphicChild},Radar:{handler:L.renderGraphicChild},RadialBar:{handler:L.renderGraphicChild},Scatter:{handler:L.renderGraphicChild},Pie:{handler:L.renderGraphicChild},Funnel:{handler:L.renderGraphicChild},Tooltip:{handler:L.renderCursor,once:!0},PolarGrid:{handler:L.renderPolarGrid,once:!0},PolarAngleAxis:{handler:L.renderPolarAxis},PolarRadiusAxis:{handler:L.renderPolarAxis},Customized:{handler:L.renderCustomized}}),L.clipPathId="".concat((T=S.id)!==null&&T!==void 0?T:HM("recharts"),"-clip"),L.throttleTriggeredAfterMouseMove=TYe(L.triggeredAfterMouseMove,(I=S.throttleDelay)!==null&&I!==void 0?I:1e3/60),L.state={},L}return Pus(k,j),Mus(k,[{key:"componentDidMount",value:function(){var T,I;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(T=this.props.margin.left)!==null&&T!==void 0?T:0,top:(I=this.props.margin.top)!==null&&I!==void 0?I:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var T=this.props,I=T.children,L=T.data,R=T.height,$=T.layout,q=ip(I,vm);if(q){var U=q.props.defaultIndex;if(!(typeof U!="number"||U<0||U>this.state.tooltipTicks.length-1)){var H=this.state.tooltipTicks[U]&&this.state.tooltipTicks[U].value,Y=Z0e(this.state,L,U,H),se=this.state.tooltipTicks[U].coordinate,te=(this.state.offset.top+R)/2,Q=$==="horizontal",de=Q?{x:se,y:te}:{y:se,x:te},re=this.state.formattedGraphicalItems.find(function(le){var he=le.item;return he.type.name==="Scatter"});re&&(de=vr(vr({},de),re.props.points[U].tooltipPosition),Y=re.props.points[U].tooltipPayload);var ae={activeTooltipIndex:U,isTooltipActive:!0,activeLabel:H,activePayload:Y,activeCoordinate:de};this.setState(ae),this.renderCursor(q),this.accessibilityManager.setIndex(U)}}}},{key:"getSnapshotBeforeUpdate",value:function(T,I){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==I.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==T.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==T.margin){var L,R;this.accessibilityManager.setDetails({offset:{left:(L=this.props.margin.left)!==null&&L!==void 0?L:0,top:(R=this.props.margin.top)!==null&&R!==void 0?R:0}})}return null}},{key:"componentDidUpdate",value:function(T){Nye([ip(T.children,vm)],[ip(this.props.children,vm)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var T=ip(this.props.children,vm);if(T&&typeof T.props.shared=="boolean"){var I=T.props.shared?"axis":"item";return i.indexOf(I)>=0?I:o}return o}},{key:"getMouseInfo",value:function(T){if(!this.container)return null;var I=this.container,L=I.getBoundingClientRect(),R=DXt(L),$={chartX:Math.round(T.pageX-R.left),chartY:Math.round(T.pageY-R.top)},q=L.width/I.offsetWidth||1,U=this.inRange($.chartX,$.chartY,q);if(!U)return null;var H=this.state,Y=H.xAxisMap,se=H.yAxisMap,te=this.getTooltipEventType(),Q=mLe(this.state,this.props.data,this.props.layout,U);if(te!=="axis"&&Y&&se){var de=M1(Y).scale,re=M1(se).scale,ae=de&&de.invert?de.invert($.chartX):null,le=re&&re.invert?re.invert($.chartY):null;return vr(vr({},$),{},{xValue:ae,yValue:le},Q)}return Q?vr(vr({},$),Q):null}},{key:"inRange",value:function(T,I){var L=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,R=this.props.layout,$=T/L,q=I/L;if(R==="horizontal"||R==="vertical"){var U=this.state.offset,H=$>=U.left&&$<=U.left+U.width&&q>=U.top&&q<=U.top+U.height;return H?{x:$,y:q}:null}var Y=this.state,se=Y.angleAxisMap,te=Y.radiusAxisMap;if(se&&te){var Q=M1(se);return FIe({x:$,y:q},Q)}return null}},{key:"parseEventsOfWrapper",value:function(){var T=this.props.children,I=this.getTooltipEventType(),L=ip(T,vm),R={};L&&I==="axis"&&(L.props.trigger==="click"?R={onClick:this.handleClick}:R={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var $=Wae(this.props,this.handleOuterEvent);return vr(vr({},$),R)}},{key:"addListener",value:function(){Epe.on(Ppe,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Epe.removeListener(Ppe,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(T,I,L){for(var R=this.state.formattedGraphicalItems,$=0,q=R.length;${const{data:S,error:T}=await G.from("email_campaigns").select("*").eq("status","sent").order("sent_at",{ascending:!0});if(T)throw T;return S}}),{data:n}=wt({queryKey:["campaign-agent-profiles"],queryFn:async()=>{const{data:S,error:T}=await G.from("profiles").select("id, name, email");if(T)throw T;return S}});if(r)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading analytics..."});const a=s||[],o=new Map((n||[]).map(S=>[S.id,S])),l=a.reduce((S,T)=>S+(T.sent_count||0),0),i=a.reduce((S,T)=>S+(T.open_count||0),0),d=a.reduce((S,T)=>S+(T.click_count||0),0),u=a.reduce((S,T)=>S+(T.bounce_count||0),0),p=a.reduce((S,T)=>S+(T.complaint_count||0),0),f=l>0?(i/l*100).toFixed(1):"0.0",y=l>0?(d/l*100).toFixed(1):"0.0",_=[{label:"Campaigns Sent",value:a.length,icon:aa,color:"text-foreground"},{label:"Total Emails Sent",value:l,icon:hr,color:"text-green-600"},{label:"Avg Open Rate",value:`${f}%`,icon:xa,color:"text-blue-600"},{label:"Avg Click Rate",value:`${y}%`,icon:th,color:"text-purple-600"},{label:"Total Bounces",value:u,icon:Ju,color:"text-orange-600"},{label:"Complaints",value:p,icon:ac,color:"text-destructive"}],b=new Map;a.forEach(S=>{var L,R;const T=S.user_id,I=b.get(T)||{name:((L=o.get(T))==null?void 0:L.name)||((R=o.get(T))==null?void 0:R.email)||"Unknown",campaigns:0,sent:0,opens:0,clicks:0};I.campaigns++,I.sent+=S.sent_count||0,I.opens+=S.open_count||0,I.clicks+=S.click_count||0,b.set(T,I)});const w=[...b.entries()].map(([S,T])=>({id:S,...T,openRate:T.sent>0?+(T.opens/T.sent*100).toFixed(1):0})).sort((S,T)=>T.sent-S.sent),j=w.slice(0,6).map(S=>({name:S.name,value:S.sent})),k=a.map(S=>{var T;return{name:S.name.length>20?S.name.slice(0,20)+"…":S.name,agent:((T=o.get(S.user_id))==null?void 0:T.name)||"Unknown",openRate:S.sent_count>0?+(S.open_count/S.sent_count*100).toFixed(1):0,clickRate:S.sent_count>0?+(S.click_count/S.sent_count*100).toFixed(1):0,sent:S.sent_count,date:S.sent_at?ys(new Date(S.sent_at),"MMM d"):""}});return e.jsx("div",{className:"space-y-6",children:a.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(aa,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No campaigns sent yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Campaign analytics will appear here after the first send."})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:_.map(S=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx(S.icon,{className:`h-5 w-5 mx-auto mb-1 ${S.color}`}),e.jsx("p",{className:"text-2xl font-bold",children:S.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.label})]})},S.label))}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Open & Click Rates by Campaign"})}),e.jsx(Oe,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(W5,{width:"100%",height:"100%",children:e.jsxs(sJe,{data:k,children:[e.jsx(Jk,{dataKey:"date",fontSize:11}),e.jsx(eS,{fontSize:11,unit:"%"}),e.jsx(vm,{formatter:S=>`${S}%`}),e.jsx(lv,{dataKey:"openRate",fill:"hsl(220, 70%, 50%)",name:"Open Rate",radius:[2,2,0,0]}),e.jsx(lv,{dataKey:"clickRate",fill:"hsl(270, 70%, 50%)",name:"Click Rate",radius:[2,2,0,0]})]})})})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Send Volume by Agent"})}),e.jsx(Oe,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(W5,{width:"100%",height:"100%",children:e.jsxs(rJe,{children:[e.jsx(jy,{data:j,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:100,label:({name:S,percent:T})=>`${S} (${(T*100).toFixed(0)}%)`,fontSize:11,children:j.map((S,T)=>e.jsx(oD,{fill:gLe[T%gLe.length]},T))}),e.jsx(vm,{})]})})})})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Send Volume Trend"})}),e.jsx(Oe,{children:e.jsx("div",{className:"h-[240px]",children:e.jsx(W5,{width:"100%",height:"100%",children:e.jsxs(Kus,{data:k,children:[e.jsx(Jk,{dataKey:"date",fontSize:11}),e.jsx(eS,{fontSize:11}),e.jsx(vm,{}),e.jsx(pD,{type:"monotone",dataKey:"sent",stroke:"hsl(142, 71%, 45%)",strokeWidth:2,name:"Emails Sent",dot:{r:4}})]})})})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Agent Performance"})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"pb-2 font-medium",children:"Agent"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Campaigns"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Sent"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Opens"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Clicks"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Open Rate"})]})}),e.jsx("tbody",{children:w.map(S=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-2.5 font-medium",children:S.name}),e.jsx("td",{className:"py-2.5 text-center",children:S.campaigns}),e.jsx("td",{className:"py-2.5 text-center",children:S.sent}),e.jsx("td",{className:"py-2.5 text-center",children:S.opens}),e.jsx("td",{className:"py-2.5 text-center",children:S.clicks}),e.jsx("td",{className:"py-2.5 text-center",children:e.jsxs(rt,{variant:"outline",children:[S.openRate,"%"]})})]},S.id))})]})})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Campaign Leaderboard"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:[...a].sort((S,T)=>{const I=S.sent_count>0?S.open_count/S.sent_count:0;return(T.sent_count>0?T.open_count/T.sent_count:0)-I}).slice(0,10).map((S,T)=>{const I=S.sent_count>0?(S.open_count/S.sent_count*100).toFixed(1):"0.0",L=S.sent_count>0?(S.click_count/S.sent_count*100).toFixed(1):"0.0",R=o.get(S.user_id);return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted/30 cursor-pointer",onClick:()=>t(`/admin/email-campaigns/${S.id}`),children:[e.jsxs("span",{className:"text-lg font-bold text-muted-foreground w-6",children:["#",T+1]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:S.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(R==null?void 0:R.name)||"Unknown"," · ",S.sent_at?ys(new Date(S.sent_at),"MMM d, yyyy"):""," · ",S.sent_count," sent"]})]}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs(rt,{variant:"outline",className:"gap-1",children:[e.jsx(xa,{className:"h-3 w-3"})," ",I,"%"]}),e.jsxs(rt,{variant:"outline",className:"gap-1",children:[e.jsx(th,{className:"h-3 w-3"})," ",L,"%"]})]})]},S.id)})})})]})]})})}const Yus=()=>e.jsx(Ts,{title:"Analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Analytics & Activity"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Platform-wide usage statistics and user activity"})]}),e.jsxs(ka,{defaultValue:"analytics",className:"space-y-4",children:[e.jsxs(_a,{children:[e.jsx(js,{value:"analytics",children:"Analytics"}),e.jsx(js,{value:"content",children:"Content"}),e.jsx(js,{value:"email-campaigns",children:"Email Campaigns"}),e.jsx(js,{value:"activity",children:"Activity"}),e.jsx(js,{value:"shares",children:"Shares"})]}),e.jsx(zs,{value:"analytics",className:"space-y-4",children:e.jsx(fzt,{})}),e.jsx(zs,{value:"content",className:"space-y-4",children:e.jsx(xzt,{})}),e.jsx(zs,{value:"email-campaigns",className:"space-y-4",children:e.jsx(Zus,{})}),e.jsx(zs,{value:"activity",className:"space-y-4",children:e.jsx(pzt,{})}),e.jsx(zs,{value:"shares",className:"space-y-4",children:e.jsx(pZe,{})})]})]})});function Xus(){const t=rs(),[s,r]=C.useState(!1),[n,a]=C.useState(null),[o,l]=C.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),[i,d]=C.useState(null),[u,p]=C.useState(""),[f,y]=C.useState([]),[_,b]=C.useState([]),[w,j]=C.useState([]),[k,S]=C.useState(!1),[T,I]=C.useState(null),[L,R]=C.useState(""),{data:$,isLoading:q}=wt({queryKey:["brokerage-resources"],queryFn:async()=>{const{data:De,error:Rt}=await G.from("brokerage_resources").select("*").order("publish_date",{ascending:!1});if(Rt)throw Rt;return De}}),{data:U}=wt({queryKey:["brokerage-resource-pdfs"],queryFn:async()=>{const{data:De,error:Rt}=await G.from("brokerage_resource_pdfs").select("*").order("sort_order",{ascending:!0});if(Rt)throw Rt;return De}}),{data:H}=wt({queryKey:["brokerage-resource-videos"],queryFn:async()=>{const{data:De,error:Rt}=await G.from("brokerage_resource_videos").select("*").order("sort_order",{ascending:!0});if(Rt)throw Rt;return De}}),{data:Y}=wt({queryKey:["brokerage-resource-links"],queryFn:async()=>{const{data:De,error:Rt}=await G.from("brokerage_resource_links").select("*").order("sort_order",{ascending:!0});if(Rt)throw Rt;return De}}),{data:se,isLoading:te}=wt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:De,error:Rt}=await G.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(Rt)throw Rt;return De}}),Q=()=>{l({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),d(null),p(""),y([]),b([]),j([]),a(null),R("")},de=De=>{a(De),l({title:De.title,description:De.description||"",publish_date:De.publish_date.split("T")[0],is_published:De.is_published,category_id:De.category_id||""}),p(De.preview_image_url||""),R("");const Rt=(U==null?void 0:U.filter(ot=>ot.resource_id===De.id))||[];y(Rt.map(ot=>({id:ot.id,name:ot.name,file_url:ot.file_url,file_size:ot.file_size,sort_order:ot.sort_order})));const me=(H==null?void 0:H.filter(ot=>ot.resource_id===De.id))||[];b(me.map(ot=>({id:ot.id,title:ot.title,video_url:ot.video_url,sort_order:ot.sort_order})));const Xe=(Y==null?void 0:Y.filter(ot=>ot.resource_id===De.id))||[];j(Xe.map(ot=>({id:ot.id,title:ot.title,canva_share_link:ot.canva_share_link,sort_order:ot.sort_order}))),r(!0)},re=De=>{var me;const Rt=(me=De.target.files)==null?void 0:me[0];Rt&&(d(Rt),p(URL.createObjectURL(Rt)))},ae=()=>{y([...f,{name:"",file_url:"",sort_order:f.length}])},le=De=>{y(f.filter((Rt,me)=>me!==De))},he=(De,Rt,me)=>{const Xe=[...f];if(Rt==="file"&&me instanceof File){const ot=me.name.replace(/\.[^/.]+$/,"");Xe[De]={...Xe[De],file:me,file_size:me.size,name:Xe[De].name||ot}}else Xe[De]={...Xe[De],[Rt]:me};y(Xe)},be=()=>{b([..._,{title:"",video_url:"",sort_order:_.length}])},_e=De=>{b(_.filter((Rt,me)=>me!==De))},je=(De,Rt,me)=>{const Xe=[..._];Rt==="file"&&me instanceof File?Xe[De]={...Xe[De],file:me}:Xe[De]={...Xe[De],[Rt]:me},b(Xe)},Ne=()=>{j([...w,{title:"",canva_share_link:"",sort_order:w.length}])},Ge=De=>{j(w.filter((Rt,me)=>me!==De))},we=(De,Rt,me)=>{const Xe=[...w];Xe[De]={...Xe[De],[Rt]:me},j(Xe)},Me=async(De,Rt)=>{try{const me=await G.functions.invoke("bunny-upload",{body:{action:"create",title:De.name}});if(me.error)throw me.error;const{videoId:Xe,uploadUrl:ot,libraryId:nt}=me.data,Se=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Xe,libraryId:nt}});if(Se.error)throw Se.error;const{uploadUrl:it,apiKey:$e}=Se.data,ct=new XMLHttpRequest;return ct.open("PUT",it,!0),ct.setRequestHeader("AccessKey",$e),ct.upload.onprogress=qe=>{if(qe.lengthComputable){const Ze=Math.round(qe.loaded/qe.total*100),Qe=[..._];Qe[Rt]={...Qe[Rt],uploadProgress:Ze},b(Qe)}},await new Promise((qe,Ze)=>{ct.onload=()=>ct.status>=200&&ct.status<300?qe():Ze(new Error("Upload failed")),ct.onerror=()=>Ze(new Error("Upload failed")),ct.send(De)}),`https://iframe.mediadelivery.net/embed/${nt}/${Xe}`}catch(me){throw console.error("Bunny upload error:",me),me}},Te=Dt({mutationFn:async De=>{const{data:Rt,error:me}=await G.from("brokerage_resource_categories").insert({name:De,sort_order:(se==null?void 0:se.length)||0}).select().single();if(me)throw me;return Rt},onSuccess:De=>{t.invalidateQueries({queryKey:["brokerage-resource-categories"]}),l({...o,category_id:De.id}),R(""),fe.success("Category created")},onError:De=>{fe.error("Failed to create category: "+De.message)}}),Fe=Dt({mutationFn:async()=>{S(!0);let De=(n==null?void 0:n.preview_image_url)||null;if(i){const Xe=i.name.split(".").pop(),ot=`${Date.now()}.${Xe}`,{error:nt}=await G.storage.from("brokerage-resources").upload(`previews/${ot}`,i);if(nt)throw nt;const{data:Se}=G.storage.from("brokerage-resources").getPublicUrl(`previews/${ot}`);De=Se.publicUrl}const Rt={title:o.title,description:o.description||null,preview_image_url:De,publish_date:o.publish_date,is_published:o.is_published,category_id:o.category_id||null};let me;if(n){const{error:Xe}=await G.from("brokerage_resources").update(Rt).eq("id",n.id);if(Xe)throw Xe;me=n.id;const ot=(U==null?void 0:U.filter(We=>We.resource_id===n.id).map(We=>We.id))||[],nt=f.filter(We=>We.id).map(We=>We.id),Se=ot.filter(We=>!nt.includes(We));Se.length>0&&await G.from("brokerage_resource_pdfs").delete().in("id",Se);const it=(H==null?void 0:H.filter(We=>We.resource_id===n.id).map(We=>We.id))||[],$e=_.filter(We=>We.id).map(We=>We.id),ct=it.filter(We=>!$e.includes(We));ct.length>0&&await G.from("brokerage_resource_videos").delete().in("id",ct);const qe=(Y==null?void 0:Y.filter(We=>We.resource_id===n.id).map(We=>We.id))||[],Ze=w.filter(We=>We.id).map(We=>We.id),Qe=qe.filter(We=>!Ze.includes(We));Qe.length>0&&await G.from("brokerage_resource_links").delete().in("id",Qe)}else{const{data:Xe,error:ot}=await G.from("brokerage_resources").insert(Rt).select().single();if(ot)throw ot;me=Xe.id}for(let Xe=0;Xe{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),fe.success(n?"Resource updated":"Resource created"),r(!1),Q(),S(!1)},onError:De=>{fe.error("Failed to save resource: "+De.message),S(!1)}}),Ae=Dt({mutationFn:async De=>{const{error:Rt}=await G.from("brokerage_resources").delete().eq("id",De);if(Rt)throw Rt},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),fe.success("Resource deleted")},onError:De=>{fe.error("Failed to delete: "+De.message)}}),Ue=De=>{if(De.preventDefault(),!o.title){fe.error("Please enter a title");return}Fe.mutate()},ut=De=>{const Rt=(U==null?void 0:U.filter(ot=>ot.resource_id===De).length)||0,me=(H==null?void 0:H.filter(ot=>ot.resource_id===De).length)||0,Xe=(Y==null?void 0:Y.filter(ot=>ot.resource_id===De).length)||0;return{pdfCount:Rt,videoCount:me,linkCount:Xe}};return e.jsx(Ts,{title:"Brokerage Resources Management",description:"Create and manage resources for brokerage managers",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Resources"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:($==null?void 0:$.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:($==null?void 0:$.filter(De=>De.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{Q(),r(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Resource"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Category"}),e.jsx(bt,{children:"Content"}),e.jsx(bt,{children:"Publish Date"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:q?e.jsx(Ns,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):($==null?void 0:$.length)===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No brokerage resources yet. Create your first one!"})}):$==null?void 0:$.map(De=>{const{pdfCount:Rt,videoCount:me,linkCount:Xe}=ut(De.id),ot=se==null?void 0:se.find(nt=>nt.id===De.category_id);return e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[De.preview_image_url?e.jsx("img",{src:De.preview_image_url,alt:De.title,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(rh,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:De.title}),De.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:De.description})]})]})}),e.jsx(lt,{children:ot?e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-muted",children:ot.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-3.5 w-3.5"}),Rt]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Nn,{className:"h-3.5 w-3.5"}),me]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Do,{className:"h-3.5 w-3.5"}),Xe]})]})}),e.jsx(lt,{children:ys(new Date(De.publish_date),"MMM d, yyyy")}),e.jsx(lt,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${De.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:De.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{const nt=(U==null?void 0:U.filter($e=>$e.resource_id===De.id))||[],Se=(H==null?void 0:H.filter($e=>$e.resource_id===De.id))||[],it=(Y==null?void 0:Y.filter($e=>$e.resource_id===De.id))||[];I({...De,pdfs:nt,videos:Se,links:it})},children:e.jsx(xa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>de(De),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource?")&&Ae.mutate(De.id)},children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},De.id)})})]})})}),e.jsx(_s,{open:s,onOpenChange:r,children:e.jsxs(vs,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:n?"Edit Brokerage Resource":"Add Brokerage Resource"})}),e.jsxs("form",{onSubmit:Ue,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[u?e.jsx("img",{src:u,alt:"Preview",className:"w-24 h-24 rounded object-cover"}):e.jsx("div",{className:"w-24 h-24 rounded bg-muted flex items-center justify-center",children:e.jsx(rh,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(Re,{type:"file",accept:"image/*",onChange:re})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",value:o.title,onChange:De=>l({...o,title:De.target.value}),placeholder:"Resource Title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(Wh,{className:"h-4 w-4"}),"Category"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(sr,{value:o.category_id,onValueChange:De=>l({...o,category_id:De}),children:[e.jsx(er,{className:"flex-1",children:e.jsx(rr,{placeholder:"Select a category"})}),e.jsx(tr,{children:se==null?void 0:se.map(De=>e.jsx(At,{value:De.id,children:De.name},De.id))})]}),o.category_id&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>l({...o,category_id:""}),children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"Or create new category...",value:L,onChange:De=>R(De.target.value),className:"flex-1"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",disabled:!L.trim()||Te.isPending,onClick:()=>Te.mutate(L.trim()),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(rx,{content:o.description,onChange:De=>l({...o,description:De}),placeholder:"Brief description of this resource",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Re,{id:"publish_date",type:"date",value:o.publish_date,onChange:De=>l({...o,publish_date:De.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(Br,{checked:o.is_published,onCheckedChange:De=>l({...o,is_published:De})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:o.is_published?"Visible to brokerage managers":"Hidden from brokerage managers"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(In,{className:"h-4 w-4"}),"PDF Documents (",f.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ae,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add PDF"]})]}),f.map((De,Rt)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(Re,{placeholder:"PDF Name",value:De.name,onChange:me=>he(Rt,"name",me.target.value),className:"flex-1"}),e.jsx(Re,{type:"file",accept:".pdf",onChange:me=>{var ot;const Xe=(ot=me.target.files)==null?void 0:ot[0];Xe&&he(Rt,"file",Xe)},className:"flex-1"}),De.file_url&&!De.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Uploaded"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>le(Rt),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Rt))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(Nn,{className:"h-4 w-4"}),"Videos (",_.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:be,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Video"]})]}),_.map((De,Rt)=>e.jsxs("div",{className:"space-y-2 p-3 border rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{placeholder:"Video Title",value:De.title,onChange:me=>je(Rt,"title",me.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>_e(Rt),children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsx(Re,{type:"file",accept:"video/*",onChange:me=>{var ot;const Xe=(ot=me.target.files)==null?void 0:ot[0];Xe&&je(Rt,"file",Xe)}}),De.uploadProgress!==void 0&&De.uploadProgress>0&&e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${De.uploadProgress}%`}})}),De.video_url&&!De.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Video uploaded"})]},Rt))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(Do,{className:"h-4 w-4"}),"Canva Links (",w.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Ne,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),w.map((De,Rt)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(Re,{placeholder:"Link Title",value:De.title,onChange:me=>we(Rt,"title",me.target.value),className:"flex-1"}),e.jsx(Re,{placeholder:"Canva Share Link",value:De.canva_share_link,onChange:me=>we(Rt,"canva_share_link",me.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>Ge(Rt),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Rt))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:Fe.isPending||k,children:Fe.isPending||k?"Saving...":n?"Update":"Create"})]})]})]})}),e.jsx(_s,{open:!!T,onOpenChange:()=>I(null),children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:T==null?void 0:T.title})}),T&&e.jsxs("div",{className:"space-y-4",children:[T.preview_image_url&&e.jsx("img",{src:T.preview_image_url,alt:T.title,className:"w-full h-48 object-cover rounded-lg"}),T.description&&e.jsx("p",{className:"text-muted-foreground",children:T.description}),T.pdfs&&T.pdfs.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(In,{className:"h-4 w-4"}),"PDF Documents (",T.pdfs.length,")"]}),e.jsx("div",{className:"space-y-1",children:T.pdfs.map(De=>e.jsx("a",{href:De.file_url,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:De.name},De.id))})]}),T.videos&&T.videos.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Nn,{className:"h-4 w-4"}),"Videos (",T.videos.length,")"]}),e.jsx("div",{className:"space-y-2",children:T.videos.map(De=>e.jsx("div",{className:"p-2 border rounded",children:e.jsx("p",{className:"font-medium text-sm",children:De.title})},De.id))})]}),T.links&&T.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Do,{className:"h-4 w-4"}),"Canva Links (",T.links.length,")"]}),e.jsx("div",{className:"space-y-1",children:T.links.map(De=>e.jsx("a",{href:De.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:De.title},De.id))})]})]})]})})]})})}const nJe=[{value:"events",label:"After Events Section"},{value:"academy",label:"After Academy Section"},{value:"toolbox",label:"After Toolbox Section"},{value:"templates",label:"After Templates Section"},{value:"apps",label:"After Apps Section"}];function Qus(){const[t,s]=C.useState([]),[r,n]=C.useState(!0),[a,o]=C.useState(!1),[l,i]=C.useState(!1),[d,u]=C.useState(null),[p,f]=C.useState(!1),[y,_]=C.useState(!1),[b,w]=C.useState(""),[j,k]=C.useState(""),[S,T]=C.useState(""),[I,L]=C.useState(""),[R,$]=C.useState("Learn More"),[q,U]=C.useState("top"),[H,Y]=C.useState(""),[se,te]=C.useState(!0),[Q,de]=C.useState(""),[re,ae]=C.useState("");C.useEffect(()=>{le()},[]);const le=async()=>{try{const{data:Te,error:Fe}=await G.from("dashboard_banners").select("*").order("placement").order("sort_order");if(Fe)throw Fe;s(Te||[])}catch(Te){fe.error("Failed to load banners: "+Te.message)}finally{n(!1)}},he=()=>{w(""),k(""),T(""),L(""),$("Learn More"),U("top"),Y(""),te(!0),de(""),ae(""),u(null)},be=Te=>{u(Te),w(Te.title),k(Te.description||""),T(Te.image_url),L(Te.link_url||""),$(Te.link_text||"Learn More"),U(Te.placement),Y(Te.section_after||""),te(Te.is_active),de(Te.start_date?ys(new Date(Te.start_date),"yyyy-MM-dd'T'HH:mm"):""),ae(Te.end_date?ys(new Date(Te.end_date),"yyyy-MM-dd'T'HH:mm"):""),o(!0)},_e=async Te=>{var Ae;const Fe=(Ae=Te.target.files)==null?void 0:Ae[0];if(Fe){f(!0);try{const Ue=Fe.name.split(".").pop(),ut=`${Date.now()}.${Ue}`,{error:De}=await G.storage.from("banner-images").upload(ut,Fe);if(De)throw De;const{data:{publicUrl:Rt}}=G.storage.from("banner-images").getPublicUrl(ut);T(Rt),fe.success("Image uploaded successfully")}catch(Ue){fe.error("Failed to upload image: "+Ue.message)}finally{f(!1)}}},je=async()=>{if(!b.trim()||!S){fe.error("Please fill in required fields (title and image)");return}_(!0);try{const Te={title:b.trim(),description:j.trim()||null,image_url:S,link_url:I.trim()||null,link_text:R.trim()||"Learn More",placement:q,section_after:q==="between"?H:null,is_active:se,start_date:Q?new Date(Q).toISOString():null,end_date:re?new Date(re).toISOString():null};if(d){const{error:Fe}=await G.from("dashboard_banners").update(Te).eq("id",d.id);if(Fe)throw Fe;fe.success("Banner updated successfully")}else{const Fe=t.filter(Ue=>Ue.placement===q).length,{error:Ae}=await G.from("dashboard_banners").insert({...Te,sort_order:Fe});if(Ae)throw Ae;fe.success("Banner created successfully")}o(!1),he(),le()}catch(Te){fe.error("Failed to save banner: "+Te.message)}finally{_(!1)}},Ne=async()=>{if(d)try{const{error:Te}=await G.from("dashboard_banners").delete().eq("id",d.id);if(Te)throw Te;fe.success("Banner deleted successfully"),i(!1),u(null),le()}catch(Te){fe.error("Failed to delete banner: "+Te.message)}},Ge=async Te=>{try{const{error:Fe}=await G.from("dashboard_banners").update({is_active:!Te.is_active}).eq("id",Te.id);if(Fe)throw Fe;fe.success(Te.is_active?"Banner deactivated":"Banner activated"),le()}catch(Fe){fe.error("Failed to update banner: "+Fe.message)}},we=t.filter(Te=>Te.placement==="top"),Me=t.filter(Te=>Te.placement==="between");return r?e.jsx(Ts,{title:"Dashboard Management",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):e.jsxs(Ts,{title:"Dashboard Management",description:"Configure dashboard modules and banners",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Jo,{className:"h-5 w-5"}),"Hero Banners (Top of Dashboard)"]}),e.jsx(pr,{children:"These banners appear in a rotating carousel at the top of the dashboard"})]}),e.jsxs(_s,{open:a&&q==="top",onOpenChange:Te=>{Te||he(),o(Te),Te&&U("top")},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{onClick:()=>{he(),U("top")},children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Add Hero Banner"]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{children:[d?"Edit":"Create"," Banner"]}),e.jsx(Kr,{children:"Configure the banner's content and display settings"})]}),e.jsx(xLe,{title:b,setTitle:w,description:j,setDescription:k,imageUrl:S,linkUrl:I,setLinkUrl:L,linkText:R,setLinkText:$,placement:q,setPlacement:U,sectionAfter:H,setSectionAfter:Y,isActive:se,setIsActive:te,startDate:Q,setStartDate:de,endDate:re,setEndDate:ae,handleImageUpload:_e,uploading:p,showPlacementOptions:!1}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),he()},children:"Cancel"}),e.jsx(K,{onClick:je,disabled:y,children:y?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Oe,{children:we.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No hero banners yet. Add your first banner above."}):e.jsx("div",{className:"space-y-3",children:we.map(Te=>e.jsx(yLe,{banner:Te,onEdit:()=>be(Te),onDelete:()=>{u(Te),i(!0)},onToggleActive:()=>Ge(Te)},Te.id))})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Jo,{className:"h-5 w-5"}),"Section Banners"]}),e.jsx(pr,{children:"These banners appear between dashboard content sections"})]}),e.jsxs(_s,{open:a&&q==="between",onOpenChange:Te=>{Te||he(),o(Te),Te&&U("between")},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{onClick:()=>{he(),U("between")},children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Add Section Banner"]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{children:[d?"Edit":"Create"," Section Banner"]}),e.jsx(Kr,{children:"Configure where this banner appears between sections"})]}),e.jsx(xLe,{title:b,setTitle:w,description:j,setDescription:k,imageUrl:S,linkUrl:I,setLinkUrl:L,linkText:R,setLinkText:$,placement:q,setPlacement:U,sectionAfter:H,setSectionAfter:Y,isActive:se,setIsActive:te,startDate:Q,setStartDate:de,endDate:re,setEndDate:ae,handleImageUpload:_e,uploading:p,showPlacementOptions:!0}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),he()},children:"Cancel"}),e.jsx(K,{onClick:je,disabled:y,children:y?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Oe,{children:Me.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No section banners yet. Add your first banner above."}):e.jsx("div",{className:"space-y-3",children:Me.map(Te=>e.jsx(yLe,{banner:Te,onEdit:()=>be(Te),onDelete:()=>{u(Te),i(!0)},onToggleActive:()=>Ge(Te),showSection:!0},Te.id))})})]})]}),e.jsx(_s,{open:l,onOpenChange:i,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Delete Banner"}),e.jsxs(Kr,{children:['Are you sure you want to delete "',d==null?void 0:d.title,'"? This action cannot be undone.']})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Ne,children:"Delete"})]})]})})]})}function xLe({title:t,setTitle:s,description:r,setDescription:n,imageUrl:a,linkUrl:o,setLinkUrl:l,linkText:i,setLinkText:d,placement:u,setPlacement:p,sectionAfter:f,setSectionAfter:y,isActive:_,setIsActive:b,startDate:w,setStartDate:j,endDate:k,setEndDate:S,handleImageUpload:T,uploading:I,showPlacementOptions:L}){return e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",placeholder:"Banner headline...",value:t,onChange:R=>s(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",placeholder:"Optional banner description...",value:r,onChange:R=>n(R.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Banner Image *"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Re,{type:"file",accept:"image/*",onChange:T,disabled:I,className:"flex-1"}),I&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),a&&e.jsx("div",{className:"mt-2 relative rounded-lg overflow-hidden border",children:e.jsx("img",{src:a,alt:"Preview",className:"w-full h-40 object-cover"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"linkUrl",children:"Link URL (optional)"}),e.jsx(Re,{id:"linkUrl",placeholder:"https://...",value:o,onChange:R=>l(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"linkText",children:"Button Text"}),e.jsx(Re,{id:"linkText",placeholder:"Learn More",value:i,onChange:R=>d(R.target.value)})]})]}),L&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Placement"}),e.jsxs(sr,{value:f,onValueChange:y,children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select section placement..."})}),e.jsx(tr,{children:nJe.map(R=>e.jsx(At,{value:R.value,children:R.label},R.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"startDate",className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Start Date (optional)"]}),e.jsx(Re,{id:"startDate",type:"datetime-local",value:w,onChange:R=>j(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"endDate",className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"End Date (optional)"]}),e.jsx(Re,{id:"endDate",type:"datetime-local",value:k,onChange:R=>S(R.target.value)})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"isActive",checked:_,onCheckedChange:b}),e.jsx(ve,{htmlFor:"isActive",children:"Active"})]})})]})}function yLe({banner:t,onEdit:s,onDelete:r,onToggleActive:n,showSection:a=!1}){var l;const o=(l=nJe.find(i=>i.value===t.section_after))==null?void 0:l.label;return e.jsxs("div",{className:"flex items-center gap-4 p-3 border rounded-lg bg-card hover:bg-accent/50 transition-colors",children:[e.jsx(Bu,{className:"h-5 w-5 text-muted-foreground cursor-grab"}),e.jsx("img",{src:t.image_url,alt:t.title,className:"w-24 h-14 object-cover rounded"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-medium truncate",children:t.title}),!t.is_active&&e.jsx(rt,{variant:"secondary",children:"Inactive"}),t.start_date&&new Date(t.start_date)>new Date&&e.jsx(rt,{variant:"outline",children:"Scheduled"})]}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:t.description}),a&&o&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t.link_url&&e.jsx("a",{href:t.link_url,target:"_blank",rel:"noopener noreferrer",children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(sn,{className:"h-4 w-4"})})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:n,children:t.is_active?e.jsx(xa,{className:"h-4 w-4"}):e.jsx(Im,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:s,children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})]})}const DR={open:{label:"Open",icon:Tn,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:xc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:hi,color:"bg-green-500"},closed:{label:"Closed",icon:kc,color:"bg-muted-foreground"}},vLe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function Jus(){var R,$;const{user:t}=Hs(),s=rs(),[r,n]=C.useState(null),[a,o]=C.useState(""),[l,i]=C.useState("all"),[d,u]=C.useState("all"),[p,f]=C.useState(!1),{data:y=[],isLoading:_}=wt({queryKey:["admin-support-tickets",l,d],queryFn:async()=>{let q=G.from("support_tickets").select("*, profiles!support_tickets_user_id_fkey(name, email)").order("created_at",{ascending:!1});l!=="all"&&(q=q.eq("status",l)),d!=="all"&&(q=q.eq("category",d));const{data:U,error:H}=await q;if(H)throw H;return U}}),{data:b=[]}=wt({queryKey:["admin-users-notifications"],queryFn:async()=>{const{data:q,error:U}=await G.from("user_roles").select("user_id").eq("role","admin");if(U)throw U;const H=q.map(re=>re.user_id),{data:Y,error:se}=await G.from("profiles").select("id, name, email").in("id",H);if(se)throw se;const{data:te,error:Q}=await G.from("support_notification_settings").select("user_id, receive_notifications");if(Q)throw Q;const de=new Map((te==null?void 0:te.map(re=>[re.user_id,re.receive_notifications]))||[]);return Y.map(re=>({...re,receives_notifications:de.get(re.id)||!1}))}}),{data:w=[]}=wt({queryKey:["admin-ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:q,error:U}=await G.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(U)throw U;return q},enabled:!!r}),j=Dt({mutationFn:async({userId:q,enabled:U})=>{const{data:H}=await G.from("support_notification_settings").select("id").eq("user_id",q).maybeSingle();if(H){const{error:Y}=await G.from("support_notification_settings").update({receive_notifications:U}).eq("user_id",q);if(Y)throw Y}else{const{error:Y}=await G.from("support_notification_settings").insert({user_id:q,receive_notifications:U});if(Y)throw Y}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-users-notifications"]}),fe.success("Notification settings updated")},onError:()=>{fe.error("Failed to update settings")}}),k=Dt({mutationFn:async({ticketId:q,status:U})=>{const{error:H}=await G.from("support_tickets").update({status:U}).eq("id",q);if(H)throw H},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),r&&n({...r,status:r.status}),fe.success("Status updated")},onError:()=>{fe.error("Failed to update status")}}),S=Dt({mutationFn:async({ticketId:q,assignedTo:U})=>{const{error:H}=await G.from("support_tickets").update({assigned_to:U}).eq("id",q);if(H)throw H},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),fe.success("Ticket assigned")},onError:()=>{fe.error("Failed to assign ticket")}}),T=Dt({mutationFn:async q=>{var H,Y;if(!r||!t)throw new Error("Missing data");const{error:U}=await G.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:q,is_admin_reply:!0});if(U)throw U;try{await G.functions.invoke("support-reply-notify",{body:{ticketId:r.id,ticketSubject:r.subject,replyContent:q,userEmail:(H=r.profiles)==null?void 0:H.email,userName:(Y=r.profiles)==null?void 0:Y.name}})}catch(se){console.error("Failed to send reply notification:",se)}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-ticket-replies",r==null?void 0:r.id]}),o(""),fe.success("Reply sent!")},onError:()=>{fe.error("Failed to send reply")}}),I=()=>{a.trim()&&T.mutate(a)};C.useEffect(()=>{const q=G.channel("admin-tickets").on("postgres_changes",{event:"*",schema:"public",table:"support_tickets"},()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]})}).subscribe();return()=>{G.removeChannel(q)}},[s]);const L=y.filter(q=>q.status==="open").length;return r?(DR[r.status].icon,e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(ti,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(rt,{variant:"secondary",children:vLe[r.category]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["from ",((R=r.profiles)==null?void 0:R.name)||"Unknown"," (",($=r.profiles)==null?void 0:$.email,")"]})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm",children:"Status"})}),e.jsx(Oe,{children:e.jsxs(sr,{value:r.status,onValueChange:q=>{k.mutate({ticketId:r.id,status:q}),n({...r,status:q})},children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"open",children:"Open"}),e.jsx(At,{value:"in_progress",children:"In Progress"}),e.jsx(At,{value:"resolved",children:"Resolved"}),e.jsx(At,{value:"closed",children:"Closed"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm",children:"Assigned To"})}),e.jsx(Oe,{children:e.jsxs(sr,{value:r.assigned_to||"unassigned",onValueChange:q=>{const U=q==="unassigned"?null:q;S.mutate({ticketId:r.id,assignedTo:U}),n({...r,assigned_to:U})},children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Unassigned"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"unassigned",children:"Unassigned"}),b.map(q=>e.jsx(At,{value:q.id,children:q.name},q.id))]})]})})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(pr,{children:["Created on ",ys(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Conversation"})}),e.jsxs(Oe,{children:[e.jsx(Ri,{className:"h-[300px] pr-4",children:w.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):e.jsx("div",{className:"space-y-4",children:w.map(q=>{var U,H;return e.jsxs("div",{className:`p-4 rounded-lg ${q.is_admin_reply?"bg-primary/10 ml-4":"bg-muted mr-4"}`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("span",{className:"font-medium text-sm",children:q.is_admin_reply?`${((U=q.profiles)==null?void 0:U.name)||"Admin"} (Support)`:((H=q.profiles)==null?void 0:H.name)||"User"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ys(new Date(q.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:q.content})]},q.id)})})}),e.jsx(Rl,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ar,{placeholder:"Type your reply...",value:a,onChange:q=>o(q.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:I,disabled:!a.trim()||T.isPending,className:"self-end",children:e.jsx(aa,{className:"h-4 w-4"})})]})]})]})]})})):e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Support Tickets"}),e.jsxs("p",{className:"text-muted-foreground",children:["Manage support requests from agents",L>0&&e.jsxs(rt,{variant:"destructive",className:"ml-2",children:[L," open"]})]})]}),e.jsxs(_s,{open:p,onOpenChange:f,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx($l,{className:"h-4 w-4 mr-2"}),"Notification Settings"]})}),e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Email Notification Settings"}),e.jsx(Kr,{children:"Choose which admins receive email notifications for new support tickets."})]}),e.jsx("div",{className:"space-y-4 mt-4",children:b.map(q=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Yi,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:q.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:q.email})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[q.receives_notifications?e.jsx(gf,{className:"h-4 w-4 text-primary"}):e.jsx(r_,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Br,{checked:q.receives_notifications,onCheckedChange:U=>j.mutate({userId:q.id,enabled:U})})]})]},q.id))})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[e.jsx(ka,{value:l,onValueChange:i,className:"w-auto",children:e.jsxs(_a,{children:[e.jsx(js,{value:"all",children:"All"}),e.jsx(js,{value:"open",children:"Open"}),e.jsx(js,{value:"in_progress",children:"In Progress"}),e.jsx(js,{value:"resolved",children:"Resolved"}),e.jsx(js,{value:"closed",children:"Closed"})]})}),e.jsxs(sr,{value:d,onValueChange:u,children:[e.jsx(er,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"All Categories"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Categories"}),e.jsx(At,{value:"general",children:"General Support"}),e.jsx(At,{value:"technology",children:"Technology Support"}),e.jsx(At,{value:"crm",children:"CRM Support"}),e.jsx(At,{value:"marketing",children:"Marketing Support"})]})]})]}),e.jsx("div",{className:"mt-4",children:_?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading tickets..."}):y.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"text-center py-12",children:[e.jsx(xc,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No tickets found"}),e.jsx("p",{className:"text-muted-foreground",children:"No support tickets match the current filters."})]})}):e.jsx("div",{className:"space-y-3",children:y.map(q=>{var H,Y;const U=DR[q.status].icon;return e.jsx(Ee,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(q),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:q.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[e.jsx(rt,{variant:"outline",className:"text-xs",children:vLe[q.category]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(H=q.profiles)==null?void 0:H.name," • ",ys(new Date(q.created_at),"MMM d, yyyy")]}),q.assigned_to&&e.jsxs(rt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Yi,{className:"h-3 w-3"}),((Y=b.find(se=>se.id===q.assigned_to))==null?void 0:Y.name)||"Assigned"]})]})]}),e.jsxs(rt,{className:DR[q.status].color,children:[e.jsx(U,{className:"h-3 w-3 mr-1"}),DR[q.status].label]})]})})},q.id)})})})]})]})})}const ehs=Uu.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var s;return(s=t.style.color)===null||s===void 0?void 0:s.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:s})=>s().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}});function ths({content:t,onChange:s,variables:r}){const n=ZWe({extensions:[tGe,uGe.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),hGe.configure({types:["heading","paragraph"]}),mGe,ehs],content:t,onUpdate:({editor:l})=>{s(l.getHTML())}});C.useEffect(()=>{n&&t!==n.getHTML()&&n.commands.setContent(t)},[t,n]);const a=l=>{n&&n.chain().focus().insertContent(`{{${l.key}}}`).run()},o=()=>{if(!n)return;const l=n.getAttributes("link").href,i=window.prompt("URL",l);if(i!==null){if(i===""){n.chain().focus().extendMarkRange("link").unsetLink().run();return}n.chain().focus().extendMarkRange("link").setLink({href:i}).run()}};return n?e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1 p-2 border-b bg-muted/30",children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBold().run(),className:n.isActive("bold")?"bg-muted":"",children:e.jsx(h5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleItalic().run(),className:n.isActive("italic")?"bg-muted":"",children:e.jsx(v5,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBulletList().run(),className:n.isActive("bulletList")?"bg-muted":"",children:e.jsx(Hh,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleOrderedList().run(),className:n.isActive("orderedList")?"bg-muted":"",children:e.jsx(O0,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("left").run(),className:n.isActive({textAlign:"left"})?"bg-muted":"",children:e.jsx(c5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("center").run(),className:n.isActive({textAlign:"center"})?"bg-muted":"",children:e.jsx(l5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("right").run(),className:n.isActive({textAlign:"right"})?"bg-muted":"",children:e.jsx(d5,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:o,className:n.isActive("link")?"bg-muted":"",children:e.jsx(Do,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleCodeBlock().run(),className:n.isActive("codeBlock")?"bg-muted":"",children:e.jsx(ak,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().undo().run(),disabled:!n.can().undo(),children:e.jsx(A5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().redo().run(),disabled:!n.can().redo(),children:e.jsx(M5,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),r.length>0&&e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(GP,{className:"h-4 w-4"}),"Insert Variable"]})}),e.jsx(Md,{align:"end",className:"w-64",children:r.map(l=>e.jsxs(Na,{onClick:()=>a(l),className:"flex flex-col items-start",children:[e.jsx("span",{className:"font-medium",children:l.label}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:`{{${l.key}}}`}),l.description&&e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:l.description})]},l.key))})]})]}),e.jsx(GWe,{editor:n,className:"prose prose-sm max-w-none p-4 min-h-[300px] focus:outline-none [&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[280px]"}),r.length>0&&e.jsxs("div",{className:"border-t p-3 bg-muted/20",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Available variables (click to copy):"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(l=>e.jsx(rt,{variant:"secondary",className:"cursor-pointer hover:bg-secondary/80 font-mono text-xs",onClick:()=>{navigator.clipboard.writeText(`{{${l.key}}}`)},children:`{{${l.key}}}`},l.key))})]})]}):null}function shs(){const t=rs(),[s,r]=C.useState(null),[n,a]=C.useState(null),[o,l]=C.useState(""),[i,d]=C.useState(""),[u,p]=C.useState(""),[f,y]=C.useState(!0),[_,b]=C.useState("visual"),{data:w,isLoading:j}=wt({queryKey:["email-templates"],queryFn:async()=>{const{data:L,error:R}=await G.from("email_templates").select("*").order("name");if(R)throw R;return L.map($=>({...$,available_variables:$.available_variables||[]}))}}),k=Dt({mutationFn:async L=>{const{error:R}=await G.from("email_templates").update({subject:L.subject,body_html:L.body_html,description:L.description,is_active:L.is_active}).eq("id",L.id);if(R)throw R},onSuccess:()=>{t.invalidateQueries({queryKey:["email-templates"]}),fe.success("Email template updated successfully"),r(null)},onError:L=>{fe.error("Failed to update template: "+L.message)}}),S=L=>{r(L),l(L.subject),d(L.body_html),p(L.description||""),y(L.is_active),b("visual")},T=()=>{s&&k.mutate({id:s.id,subject:o,body_html:i,description:u,is_active:f})},I=(L,R)=>{let $=L;return R.forEach(q=>{const U=`{{${q.key}}}`,H=`[${q.label}]`;$=$.replace(new RegExp(U.replace(/[{}]/g,"\\$&"),"g"),H)}),$};return s?e.jsxs(Ts,{title:"Edit Email Template",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(K,{variant:"ghost",onClick:()=>r(null),children:[e.jsx(ti,{className:"h-4 w-4 mr-2"}),"Back to Templates"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(K,{variant:"outline",onClick:()=>a(s),children:[e.jsx(xa,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{onClick:T,disabled:k.isPending,children:[e.jsx(fu,{className:"h-4 w-4 mr-2"}),k.isPending?"Saving...":"Save Changes"]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),s.name]}),e.jsxs(pr,{className:"mt-1",children:["Template slug: ",e.jsx("code",{className:"bg-muted px-1 rounded",children:s.slug})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{htmlFor:"active-toggle",children:"Active"}),e.jsx(Br,{id:"active-toggle",checked:f,onCheckedChange:y})]})]})}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",value:u,onChange:L=>p(L.target.value),placeholder:"Brief description of when this email is sent",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"subject",children:"Email Subject"}),e.jsx(Re,{id:"subject",value:o,onChange:L=>l(L.target.value),placeholder:"Email subject line"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["You can use variables like ","{{name}}"," in the subject"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Email Body"}),e.jsx(ka,{value:_,onValueChange:L=>b(L),children:e.jsxs(_a,{className:"h-8",children:[e.jsxs(js,{value:"visual",className:"text-xs px-3 h-6",children:[e.jsx(hk,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(js,{value:"html",className:"text-xs px-3 h-6",children:[e.jsx(ak,{className:"h-3 w-3 mr-1"}),"HTML"]})]})})]}),_==="visual"?e.jsx(ths,{content:i,onChange:d,variables:s.available_variables}):e.jsx(Ar,{value:i,onChange:L=>d(L.target.value),className:"font-mono text-sm min-h-[400px]",placeholder:"HTML email body"})]})]})]})]}),e.jsx(_s,{open:!!n,onOpenChange:()=>a(null),children:e.jsxs(vs,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Email Preview"}),e.jsxs(Kr,{children:["Subject: ",o.replace(/\{\{(\w+)\}\}/g,"[$1]")]})]}),e.jsx("div",{className:"border rounded-lg p-4 bg-white",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:I(i,s.available_variables)}})})]})})]}):e.jsx(Ts,{title:"Email Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Email Templates"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage and customize system email templates"})]}),j?e.jsx("div",{className:"grid gap-4",children:[...Array(4)].map((L,R)=>e.jsx(Ee,{children:e.jsxs(It,{children:[e.jsx(xs,{className:"h-5 w-48"}),e.jsx(xs,{className:"h-4 w-96"})]})},R))}):e.jsx("div",{className:"grid gap-4",children:w==null?void 0:w.map(L=>e.jsxs(Ee,{className:"hover:shadow-md transition-shadow",children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Ot,{className:"flex items-center gap-2 text-lg",children:[e.jsx(br,{className:"h-5 w-5 text-muted-foreground"}),L.name,!L.is_active&&e.jsx(rt,{variant:"secondary",children:"Inactive"})]}),e.jsx(pr,{children:L.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>a(L),children:[e.jsx(xa,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{size:"sm",onClick:()=>S(L),children:[e.jsx(Rc,{className:"h-4 w-4 mr-2"}),"Edit"]})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Subject:"}),e.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-sm",children:L.subject})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Variables:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:L.available_variables.map(R=>e.jsx(rt,{variant:"outline",className:"font-mono text-xs",children:`{{${R.key}}}`},R.key))})]})]})})]},L.id))}),e.jsx(_s,{open:!!n&&!s,onOpenChange:()=>a(null),children:e.jsxs(vs,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{children:["Email Preview: ",n==null?void 0:n.name]}),e.jsxs(Kr,{children:["Subject: ",n==null?void 0:n.subject.replace(/\{\{(\w+)\}\}/g,"[$1]")]})]}),n&&e.jsx("div",{className:"border rounded-lg p-4 bg-white",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:I(n.body_html,n.available_variables)}})})]})})]})})}function rhs(){const t=rs(),[s,r]=C.useState("templates"),[n,a]=C.useState(null),[o,l]=C.useState(null),[i,d]=C.useState(!1),[u,p]=C.useState(!1),[f,y]=C.useState({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),[_,b]=C.useState({name:"",description:"",icon:"📧"}),{data:w=[]}=wt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:H,error:Y}=await G.from("email_template_categories").select("*").order("sort_order");if(Y)throw Y;return H}}),{data:j=[],isLoading:k}=wt({queryKey:["agent-email-templates-admin"],queryFn:async()=>{const{data:H,error:Y}=await G.from("agent_email_templates").select("*, category:email_template_categories(*)").order("sort_order");if(Y)throw Y;return H}}),S=Dt({mutationFn:async H=>{const Y={title:H.title,subject:H.subject,body:H.body,description:H.description||null,tone:H.tone||null,category_id:H.category_id||null,is_active:H.is_active};if(H.id){const{error:se}=await G.from("agent_email_templates").update(Y).eq("id",H.id);if(se)throw se}else{const{error:se}=await G.from("agent_email_templates").insert(Y);if(se)throw se}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),d(!1),fe.success(n?"Template updated":"Template created")},onError:()=>fe.error("Failed to save template")}),T=Dt({mutationFn:async H=>{const{error:Y}=await G.from("agent_email_templates").delete().eq("id",H);if(Y)throw Y},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),fe.success("Template deleted")}}),I=Dt({mutationFn:async H=>{const Y={name:H.name,description:H.description||null,icon:H.icon};if(H.id){const{error:se}=await G.from("email_template_categories").update(Y).eq("id",H.id);if(se)throw se}else{const se=w.length>0?Math.max(...w.map(Q=>Q.sort_order))+1:0,{error:te}=await G.from("email_template_categories").insert({...Y,sort_order:se});if(te)throw te}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),p(!1),fe.success(o?"Category updated":"Category created")},onError:()=>fe.error("Failed to save category")}),L=Dt({mutationFn:async H=>{const{error:Y}=await G.from("email_template_categories").delete().eq("id",H);if(Y)throw Y},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),fe.success("Category deleted")}}),R=()=>{a(null),y({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),d(!0)},$=H=>{a(H),y({title:H.title,subject:H.subject,body:H.body,description:H.description||"",tone:H.tone||"",category_id:H.category_id||"",is_active:H.is_active}),d(!0)},q=()=>{l(null),b({name:"",description:"",icon:"📧"}),p(!0)},U=H=>{l(H),b({name:H.name,description:H.description||"",icon:H.icon}),p(!0)};return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(wu,{title:"Agent Email Templates",description:"Manage email templates that agents use when composing emails from Mission Control."}),e.jsxs(ka,{value:s,onValueChange:r,children:[e.jsxs(_a,{children:[e.jsxs(js,{value:"templates",className:"gap-2",children:[e.jsx(br,{className:"h-4 w-4"})," Templates"]}),e.jsxs(js,{value:"categories",className:"gap-2",children:[e.jsx(Vh,{className:"h-4 w-4"})," Categories"]})]}),e.jsxs(zs,{value:"templates",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:R,className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"})," Add Template"]})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Template"}),e.jsx(bt,{className:"hidden md:table-cell",children:"Category"}),e.jsx(bt,{className:"hidden md:table-cell",children:"Tone"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:k?e.jsx(Ns,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin mx-auto"})})}):j.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No templates yet. Create your first one!"})}):j.map(H=>e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:H.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[300px]",children:H.subject})]})}),e.jsx(lt,{className:"hidden md:table-cell",children:H.category?e.jsxs(rt,{variant:"outline",className:"gap-1",children:[H.category.icon," ",H.category.name]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(lt,{className:"hidden md:table-cell",children:H.tone?e.jsx(rt,{variant:"secondary",children:H.tone}):"—"}),e.jsx(lt,{children:e.jsx(rt,{variant:H.is_active?"default":"secondary",children:H.is_active?"Active":"Inactive"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>$(H),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&T.mutate(H.id)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},H.id))})]})})})]}),e.jsxs(zs,{value:"categories",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:q,className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"})," Add Category"]})}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:w.map(H=>e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:H.icon})," ",H.name]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>U(H),children:e.jsx(Da,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>{confirm("Delete this category?")&&L.mutate(H.id)},children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:H.description||"No description"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[j.filter(Y=>Y.category_id===H.id).length," templates"]})]})]},H.id))})]})]}),e.jsx(_s,{open:i,onOpenChange:d,children:e.jsxs(vs,{className:"sm:max-w-[700px] max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:n?"Edit Template":"New Template"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Title"}),e.jsx(Re,{value:f.title,onChange:H=>y(Y=>({...Y,title:H.target.value})),placeholder:"e.g. Quick Check-in"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Category"}),e.jsxs(sr,{value:f.category_id,onValueChange:H=>y(Y=>({...Y,category_id:H})),children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select category"})}),e.jsx(tr,{children:w.map(H=>e.jsxs(At,{value:H.id,children:[H.icon," ",H.name]},H.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Subject Line"}),e.jsx(Re,{value:f.subject,onChange:H=>y(Y=>({...Y,subject:H.target.value})),placeholder:"e.g. Hey {{first_name}}, just checking in!"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ","{{first_name}}",", ","{{last_name}}",", ","{{full_name}}"," for merge variables"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Email Body"}),e.jsx(Ar,{value:f.body,onChange:H=>y(Y=>({...Y,body:H.target.value})),rows:12,placeholder:"Write your email template...",className:"resize-y"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Description (internal)"}),e.jsx(Re,{value:f.description,onChange:H=>y(Y=>({...Y,description:H.target.value})),placeholder:"Short description for admin reference"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Tone"}),e.jsx(Re,{value:f.tone,onChange:H=>y(Y=>({...Y,tone:H.target.value})),placeholder:"e.g. Warm & Casual"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{checked:f.is_active,onCheckedChange:H=>y(Y=>({...Y,is_active:H}))}),e.jsx(ve,{children:"Active"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>S.mutate({...f,id:n==null?void 0:n.id}),disabled:S.isPending||!f.title||!f.subject||!f.body,children:[S.isPending&&e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),n?"Save Changes":"Create Template"]})]})]})}),e.jsx(_s,{open:u,onOpenChange:p,children:e.jsxs(vs,{className:"sm:max-w-[450px]",children:[e.jsx(Ss,{children:e.jsx(ks,{children:o?"Edit Category":"New Category"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-[60px_1fr] gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Icon"}),e.jsx(Re,{value:_.icon,onChange:H=>b(Y=>({...Y,icon:H.target.value})),className:"text-center text-lg"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Name"}),e.jsx(Re,{value:_.name,onChange:H=>b(Y=>({...Y,name:H.target.value})),placeholder:"e.g. Check-in & Stay in Touch"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Description"}),e.jsx(Re,{value:_.description,onChange:H=>b(Y=>({...Y,description:H.target.value})),placeholder:"Brief description of this category"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>I.mutate({..._,id:o==null?void 0:o.id}),disabled:I.isPending||!_.name,children:[I.isPending&&e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),o?"Save Changes":"Create Category"]})]})]})})]})})}const nhs=({brokerageId:t})=>{var Vl,Vt;const{toast:s}=Pa(),r=Pr(),[n,a]=C.useState([]),[o,l]=C.useState(!0),[i,d]=C.useState(""),[u,p]=C.useState("all"),[f,y]=C.useState(new Set),[_,b]=C.useState(!1),[w,j]=C.useState({}),[k,S]=C.useState(!1),[T,I]=C.useState(!1),[L,R]=C.useState({email:"",name:"",password:"",phone:""}),[$,q]=C.useState(!1),[U,H]=C.useState(null),[Y,se]=C.useState(!1),[te,Q]=C.useState(!1),[de,re]=C.useState(!1),[ae,le]=C.useState(""),[he,be]=C.useState(!1),[_e,je]=C.useState([]),[Ne,Ge]=C.useState(!1),[we,Me]=C.useState(!1),[Te,Fe]=C.useState(null),[Ae,Ue]=C.useState({name:"",phone:"",email:""}),[ut,De]=C.useState(!1),[Rt,me]=C.useState(!1),[Xe,ot]=C.useState(null),[nt,Se]=C.useState("asc"),[it,$e]=C.useState(!1),[ct,qe]=C.useState(null),[Ze,Qe]=C.useState(!1),[We,He]=C.useState(null),[et,Tt]=C.useState(""),[Ft,as]=C.useState(!1),[Xt,ss]=C.useState(null);C.useEffect(()=>{ar(),is()},[t]);const is=async()=>{try{const{data:ye,error:ze}=await G.from("brokerage_manager_assignments").select("user_id").eq("brokerage_id",t);if(ze)throw ze;je((ye==null?void 0:ye.map(Je=>Je.user_id))||[])}catch(ye){console.error("Error loading brokerage managers:",ye)}},ar=async()=>{try{l(!0);const{data:ye,error:ze}=await G.functions.invoke("get-brokerage-agents",{body:{brokerageId:t}});if(ze)throw ze;const Je=ye.agents||[];if(a(Je),Je.length>0){const St=Je.map(Bt=>Bt.id),{data:Nt}=await G.from("agent_assistant_assignments").select("agent_id, assistant_id").in("agent_id",St);if(Nt&&Nt.length>0){const Bt=Nt.map(Qt=>Qt.assistant_id),{data:Kt}=await G.from("profiles").select("id, name, email").in("id",Bt),qt={};for(const Qt of Nt){const As=Kt==null?void 0:Kt.find(gs=>gs.id===Qt.assistant_id);As&&(qt[Qt.agent_id]={name:As.name||"",email:As.email||""})}j(qt)}else j({})}}catch(ye){console.error("Error loading agents:",ye),s({title:"Error",description:"Failed to load agents",variant:"destructive"})}finally{l(!1)}},Ct=async()=>{if(!L.email||!L.name||!L.password){s({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}I(!0);try{const{data:{session:ye}}=await G.auth.getSession(),ze=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ye==null?void 0:ye.access_token}`},body:JSON.stringify({...L,brokerageId:t})}),Je=await ze.json();if(!ze.ok)throw new Error(Je.error||"Failed to create agent");s({title:"Success",description:`Agent ${L.email} created successfully`}),R({email:"",name:"",password:"",phone:""}),S(!1),ar()}catch(ye){console.error("Error creating agent:",ye),s({title:"Error",description:ye.message||"Failed to create agent",variant:"destructive"})}finally{I(!1)}},Is=async ye=>{try{const{data:{session:ze}}=await G.auth.getSession(),Je=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ze==null?void 0:ze.access_token}`},body:JSON.stringify({userId:ye})}),St=await Je.json();if(!Je.ok)throw new Error(St.error||"Failed to resend welcome email");s({title:"Success",description:"Welcome email sent successfully"})}catch(ze){console.error("Error resending welcome email:",ze),s({title:"Error",description:ze.message||"Failed to resend welcome email",variant:"destructive"})}},qs=async(ye,ze)=>{try{const{error:Je}=await G.functions.invoke("send-password-reset",{body:{email:ye,redirectTo:window.location.origin}});if(Je)throw Je;s({title:"Password Reset Sent",description:`Password reset email sent to ${ze}`})}catch(Je){console.error("Error sending password reset:",Je),s({title:"Error",description:Je.message||"Failed to send password reset email",variant:"destructive"})}},gr=ye=>{H(ye),q(!0)},Wn=ye=>{Fe(ye),Ue({name:ye.name,phone:ye.phone||"",email:ye.email}),Me(!0)},ii=async()=>{if(!Te)return;if(!Ae.name.trim()){s({title:"Error",description:"Name is required",variant:"destructive"});return}const ye=Ae.email.trim().toLowerCase()!==Te.email.toLowerCase();De(!0);try{if(ye){if(!Ae.email.trim())throw new Error("Email is required");me(!0);const{data:{session:Je}}=await G.auth.getSession(),St=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Je==null?void 0:Je.access_token}`},body:JSON.stringify({agentId:Te.id,newEmail:Ae.email.trim(),brokerageId:t})}),Nt=await St.json();if(me(!1),!St.ok)throw new Error(Nt.error||"Failed to update email")}const{error:ze}=await G.from("profiles").update({name:Ae.name.trim(),phone:Ae.phone.trim()||null}).eq("id",Te.id);if(ze)throw ze;s({title:"Success",description:"Agent profile updated successfully"}),Me(!1),Fe(null),ar()}catch(ze){console.error("Error updating agent:",ze),s({title:"Error",description:ze.message||"Failed to update agent",variant:"destructive"})}finally{De(!1),me(!1)}},bo=async()=>{if(!ae){s({title:"Error",description:"Please select an agent to promote",variant:"destructive"});return}be(!0);try{const{data:{session:ye}}=await G.auth.getSession(),ze=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ye==null?void 0:ye.access_token}`},body:JSON.stringify({userId:ae,role:"brokerage_manager",action:"add",brokerageId:t})}),Je=await ze.json();if(!ze.ok)throw new Error(Je.error||"Failed to add brokerage manager");s({title:"Success",description:"Brokerage manager added successfully"}),re(!1),le(""),is()}catch(ye){console.error("Error adding brokerage manager:",ye),s({title:"Error",description:ye.message||"Failed to add brokerage manager",variant:"destructive"})}finally{be(!1)}},si=async ye=>{try{const{data:{session:ze}}=await G.auth.getSession(),Je=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ze==null?void 0:ze.access_token}`},body:JSON.stringify({userId:ye,role:"brokerage_manager",action:"remove",brokerageId:t})}),St=await Je.json();if(!Je.ok)throw new Error(St.error||"Failed to remove brokerage manager");s({title:"Success",description:"Brokerage manager role removed"}),is()}catch(ze){console.error("Error removing brokerage manager:",ze),s({title:"Error",description:ze.message||"Failed to remove brokerage manager",variant:"destructive"})}},nn=ye=>_e.includes(ye),ia=ye=>{He(ye),Tt(""),Qe(!0)},kn=async()=>{if(!(!We||!et)){if(et.length<6){s({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}as(!0);try{const{data:{session:ye}}=await G.auth.getSession(),ze=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ye==null?void 0:ye.access_token}`},body:JSON.stringify({agentId:We.id,brokerageId:t,action:"set_password",newPassword:et})}),Je=await ze.json();if(!ze.ok)throw new Error(Je.error||"Failed to set password");s({title:"Success",description:`Password set for ${We.name}`}),Qe(!1),He(null),Tt("")}catch(ye){console.error("Error setting password:",ye),s({title:"Error",description:ye.message||"Failed to set password",variant:"destructive"})}finally{as(!1)}}},sa=async ye=>{ss(ye.id);try{const{data:{session:ze}}=await G.auth.getSession(),Je=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ze==null?void 0:ze.access_token}`},body:JSON.stringify({agentId:ye.id,brokerageId:t,action:"claim_account"})}),St=await Je.json();if(!Je.ok)throw new Error(St.error||"Failed to claim account");s({title:"Success",description:`Account claimed for ${ye.name}`}),ar()}catch(ze){console.error("Error claiming account:",ze),s({title:"Error",description:ze.message||"Failed to claim account",variant:"destructive"})}finally{ss(null)}},Zt=async()=>{if(U){se(!0);try{const{data:{session:ye}}=await G.auth.getSession(),ze=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/remove-agent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ye==null?void 0:ye.access_token}`},body:JSON.stringify({userId:U.id,brokerageId:t})}),Je=await ze.json();if(!ze.ok)throw new Error(Je.error||"Failed to remove agent");s({title:"Success",description:`${U.name} has been removed from your brokerage`}),q(!1),H(null),ar()}catch(ye){console.error("Error removing agent:",ye),s({title:"Error",description:ye.message||"Failed to remove agent",variant:"destructive"})}finally{se(!1)}}},$r=ye=>{const ze=ye.trim().split(" ");return ze.length>1?ze[ze.length-1].toLowerCase():ye.toLowerCase()},es=ye=>{Xe===ye?Se(nt==="asc"?"desc":"asc"):(ot(ye),Se("asc"))},an=ye=>Xe!==ye?e.jsx(Hc,{className:"ml-1 h-4 w-4"}):nt==="asc"?e.jsx(Vd,{className:"ml-1 h-4 w-4"}):e.jsx(sh,{className:"ml-1 h-4 w-4"}),Ra=n.filter(ye=>{if(u==="active"&&!ye.claimed||u==="pending"&&ye.claimed)return!1;if(!i)return!0;const ze=i.toLowerCase();return ye.name.toLowerCase().includes(ze)||ye.email.toLowerCase().includes(ze)}),Zn=[...Ra].sort((ye,ze)=>{if(!Xe)return 0;let Je=0;return Xe==="name"?Je=$r(ye.name).localeCompare($r(ze.name)):Xe==="status"&&(Je=ye.claimed===ze.claimed?0:ye.claimed?-1:1),nt==="asc"?Je:-Je});Ra.filter(ye=>ye.claimed&&!nn(ye.id));const Ir=ye=>{y(ze=>{const Je=new Set(ze);return Je.has(ye)?Je.delete(ye):Je.add(ye),Je})},mi=()=>{f.size===Zn.length?y(new Set):y(new Set(Zn.map(ye=>ye.id)))},Go=()=>{y(new Set)},yi=async()=>{const ye=Array.from(f);if(ye.length===0)return;b(!0);let ze=0,Je=0;try{const{data:{session:St}}=await G.auth.getSession();for(const Nt of ye)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${St==null?void 0:St.access_token}`},body:JSON.stringify({userId:Nt})})).ok?ze++:Je++}catch{Je++}ze>0?s({title:"Success",description:`Welcome emails sent to ${ze} agent${ze>1?"s":""}${Je>0?` (${Je} failed)`:""}`}):s({title:"Error",description:"Failed to send welcome emails",variant:"destructive"}),Go()}catch(St){console.error("Error bulk sending welcome emails:",St),s({title:"Error",description:St.message||"Failed to send welcome emails",variant:"destructive"})}finally{b(!1)}};return o?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Agents"}),e.jsx(pr,{children:"Manage your brokerage's agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>re(!0),children:[e.jsx(ih,{className:"mr-2 h-4 w-4"}),"Add Brokerage Manager"]}),e.jsxs(K,{variant:"outline",onClick:()=>Q(!0),children:[e.jsx(I0,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),e.jsxs(K,{onClick:()=>S(!0),children:[e.jsx(yc,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-4 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(gn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search agents...",value:i,onChange:ye=>d(ye.target.value),className:"pl-9"})]}),e.jsxs(sr,{value:u,onValueChange:ye=>p(ye),children:[e.jsx(er,{className:"w-[160px]",children:e.jsx(rr,{placeholder:"Filter by status"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Agents"}),e.jsx(At,{value:"active",children:"Active"}),e.jsx(At,{value:"pending",children:"Pending"})]})]})]}),f.size>0&&e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border bg-muted/50 p-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[f.size," agent",f.size>1?"s":""," selected"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{const ze=n.filter(Je=>f.has(Je.id)&&Je.email).map(Je=>({email:Je.email,name:Je.name}));sessionStorage.setItem("campaign_direct_recipients",JSON.stringify(ze)),r("/admin/email-campaigns/new?directMode=1",{state:{directRecipients:ze}})},disabled:_,children:[e.jsx(Rm,{className:"mr-2 h-4 w-4"}),"Email Agents (",f.size,")"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:yi,disabled:_,children:[e.jsx(br,{className:"mr-2 h-4 w-4"}),_?"Sending...":"Resend Welcome Email"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:Go,children:"Clear"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{className:"w-[40px]",children:e.jsx(Bo,{checked:Zn.length>0&&f.size===Zn.length,onCheckedChange:mi,"aria-label":"Select all"})}),e.jsx(bt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>es("name"),children:["Name (Last)",an("name")]})}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>es("status"),children:["Status",an("status")]})}),e.jsx(bt,{children:"Actions"})]})}),e.jsx(Pn,{children:Zn.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:5,className:"text-center text-muted-foreground",children:"No agents found"})}):Zn.map(ye=>e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsx(Bo,{checked:f.has(ye.id),onCheckedChange:()=>Ir(ye.id),"aria-label":`Select ${ye.name}`})}),e.jsx(lt,{className:"font-medium",children:ye.name}),e.jsx(lt,{children:ye.email}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[ye.claimed?e.jsx(rt,{variant:"default",children:"Active"}):e.jsx(rt,{variant:"secondary",children:"Pending"}),nn(ye.id)&&e.jsxs(rt,{variant:"outline",className:"border-primary text-primary",children:[e.jsx(zP,{className:"mr-1 h-3 w-3"}),"Manager"]}),w[ye.id]&&e.jsxs(rt,{variant:"outline",className:"text-xs",children:[e.jsx(hr,{className:"mr-1 h-3 w-3"}),"Asst: ",w[ye.id].name||w[ye.id].email]})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{qe(ye),$e(!0)},title:"Send celebration",className:"text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",children:e.jsx(kd,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Wn(ye),title:"Edit agent",children:e.jsx(Da,{className:"h-4 w-4"})}),!ye.claimed&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Is(ye.id),title:"Resend welcome email",children:e.jsx(br,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>sa(ye),title:"Claim account for agent",disabled:Xt===ye.id,className:"text-green-600 hover:text-green-700 hover:bg-green-50",children:e.jsx(p_,{className:"h-4 w-4"})})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>ia(ye),title:"Set password",className:"text-blue-600 hover:text-blue-700 hover:bg-blue-50",children:e.jsx($u,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>qs(ye.email,ye.name),title:"Send password reset email",children:e.jsx(ck,{className:"h-4 w-4"})}),nn(ye.id)&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>si(ye.id),title:"Remove manager role",className:"text-orange-500 hover:text-orange-600",children:e.jsx(ih,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>gr(ye),className:"text-destructive hover:text-destructive",title:"Remove agent",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},ye.id))})]})})]})]}),e.jsx(_s,{open:k,onOpenChange:S,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Add New Agent"}),e.jsx(Kr,{children:"Create a new agent account. They'll receive an email to set up their account."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",value:L.name,onChange:ye=>R({...L,name:ye.target.value}),placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",value:L.email,onChange:ye=>R({...L,email:ye.target.value}),placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(Re,{id:"phone",type:"tel",value:L.phone,onChange:ye=>R({...L,phone:ye.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"password",children:"Temporary Password"}),e.jsx(Re,{id:"password",type:"password",value:L.password,onChange:ye=>R({...L,password:ye.target.value}),placeholder:"Temporary password"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(K,{onClick:Ct,disabled:T,children:T?"Creating...":"Create Agent"})]})]})}),e.jsx(_s,{open:$,onOpenChange:q,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Remove Agent"}),e.jsxs(Kr,{children:["Are you sure you want to remove ",e.jsx("strong",{children:U==null?void 0:U.name})," from your brokerage? This will revoke their access to the dashboard."]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>q(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Zt,disabled:Y,children:Y?"Removing...":"Remove Agent"})]})]})}),e.jsx(IKe,{open:te,onOpenChange:Q,fixedBrokerageId:t,onSuccess:ar}),e.jsx(_s,{open:de,onOpenChange:re,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Add Brokerage Manager"}),e.jsx(Kr,{children:"Promote an existing active agent to brokerage manager. They will be able to manage agents and view analytics."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(ve,{children:"Select Agent"}),e.jsxs(Co,{open:Ne,onOpenChange:Ge,children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":Ne,className:"w-full justify-between",children:[ae?((Vl=n.find(ye=>ye.id===ae))==null?void 0:Vl.name)+" ("+((Vt=n.find(ye=>ye.id===ae))==null?void 0:Vt.email)+")":"Select an agent to promote...",e.jsx(xf,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(No,{className:"w-full p-0",align:"start",children:e.jsxs(Mf,{children:[e.jsx(Tf,{placeholder:"Search by name or email..."}),e.jsxs(Af,{className:"max-h-[200px]",children:[e.jsx(Ef,{children:"No eligible agents found."}),e.jsx(Pf,{children:n.filter(ye=>!nn(ye.id)).map(ye=>e.jsxs(Cm,{value:`${ye.name} ${ye.email}`,onSelect:()=>{le(ye.id),Ge(!1)},children:[e.jsx(ha,{className:`mr-2 h-4 w-4 ${ae===ye.id?"opacity-100":"opacity-0"}`}),ye.name," (",ye.email,")"]},ye.id))})]})]})})]}),n.filter(ye=>!nn(ye.id)).length===0&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"All agents are already brokerage managers."})]})}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>re(!1),children:"Cancel"}),e.jsx(K,{onClick:bo,disabled:he||!ae,children:he?"Adding...":"Add as Manager"})]})]})}),e.jsx(_s,{open:we,onOpenChange:Me,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Edit Agent"}),e.jsxs(Kr,{children:["Update profile information for ",Te==null?void 0:Te.name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"edit-name",children:"Name"}),e.jsx(Re,{id:"edit-name",value:Ae.name,onChange:ye=>Ue({...Ae,name:ye.target.value}),placeholder:"Agent name"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"edit-email",children:"Email"}),e.jsx(Re,{id:"edit-email",type:"email",value:Ae.email,onChange:ye=>Ue({...Ae,email:ye.target.value}),placeholder:"agent@example.com"}),Ae.email.trim().toLowerCase()!==(Te==null?void 0:Te.email.toLowerCase())&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Changing email will update their login credentials"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(Re,{id:"edit-phone",type:"tel",value:Ae.phone,onChange:ye=>Ue({...Ae,phone:ye.target.value}),placeholder:"555-123-4567"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>Me(!1),children:"Cancel"}),e.jsx(K,{onClick:ii,disabled:ut||Rt,children:Rt?"Updating email...":ut?"Saving...":"Save Changes"})]})]})}),ct&&e.jsx(LKe,{open:it,onOpenChange:ye=>{$e(ye),ye||qe(null)},userId:ct.id,userName:ct.name}),e.jsx(_s,{open:Ze,onOpenChange:Qe,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Set Password"}),e.jsxs(Kr,{children:["Set a new password for ",We==null?void 0:We.name,". They will be able to log in with this password immediately."]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"new-password",children:"New Password"}),e.jsx(Re,{id:"new-password",type:"password",value:et,onChange:ye=>Tt(ye.target.value),placeholder:"Enter new password (min 6 characters)"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Make sure to communicate this password to the agent through a secure channel."})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>Qe(!1),children:"Cancel"}),e.jsx(K,{onClick:kn,disabled:Ft||!et||et.length<6,children:Ft?"Setting...":"Set Password"})]})]})})]})},ahs={academy_video:"Academy Video",template:"Template",toolbox:"Toolbox Resource",newsletter:"Newsletter",social_swag:"Social Swag",event:"Event"},ihs={view:"Viewed",click_canva:"Opened Canva",click_pdf:"Downloaded PDF",click_video:"Watched Video",click_link:"Clicked Link",register:"Registered"},ohs=t=>{switch(t){case"academy_video":return e.jsx(Nn,{className:"h-4 w-4"});case"template":return e.jsx(In,{className:"h-4 w-4"});case"toolbox":return e.jsx(In,{className:"h-4 w-4"});case"newsletter":return e.jsx(z0,{className:"h-4 w-4"});case"social_swag":return e.jsx(hn,{className:"h-4 w-4"});case"event":return e.jsx(on,{className:"h-4 w-4"});default:return e.jsx(sn,{className:"h-4 w-4"})}},lhs=({brokerageId:t})=>{const{toast:s}=Pa(),[r,n]=C.useState([]),[a,o]=C.useState([]),[l,i]=C.useState([]),[d,u]=C.useState(!0),[p,f]=C.useState(null);C.useEffect(()=>{y()},[t]);const y=async()=>{try{u(!0);const{data:w,error:j}=await G.from("profiles").select("id, name, email").eq("brokerage_id",t);if(j)throw j;const k=w.map(Y=>Y.id),S=new Map(w.map(Y=>[Y.id,Y]));if(k.length===0){n([]),o([]),i([]);return}const{data:T,error:I}=await G.from("activity_logs").select("*").in("user_id",k).order("launched_at",{ascending:!1});if(I)throw I;const L=T.map(Y=>{var se,te;return{id:Y.id,user_id:Y.user_id,app_name:Y.app_name,launched_at:Y.launched_at,user_name:((se=S.get(Y.user_id))==null?void 0:se.name)||"Unknown",user_email:((te=S.get(Y.user_id))==null?void 0:te.email)||"Unknown"}});n(L);const{data:R,error:$}=await G.from("content_engagement_logs").select("*").in("user_id",k).order("created_at",{ascending:!1});if($)throw $;const q=(R||[]).map(Y=>{var se,te;return{id:Y.id,user_id:Y.user_id,resource_type:Y.resource_type,resource_id:Y.resource_id,resource_title:Y.resource_title,action_type:Y.action_type,created_at:Y.created_at,user_name:((se=S.get(Y.user_id))==null?void 0:se.name)||"Unknown",user_email:((te=S.get(Y.user_id))==null?void 0:te.email)||"Unknown"}});o(q);const U=new Map;w.forEach(Y=>{U.set(Y.id,{user_id:Y.id,user_name:Y.name,user_email:Y.email,app_launches:0,content_views:0,last_activity:""})}),L.forEach(Y=>{const se=U.get(Y.user_id);se&&(se.app_launches++,(!se.last_activity||new Date(Y.launched_at)>new Date(se.last_activity))&&(se.last_activity=Y.launched_at))}),q.forEach(Y=>{const se=U.get(Y.user_id);se&&(se.content_views++,(!se.last_activity||new Date(Y.created_at)>new Date(se.last_activity))&&(se.last_activity=Y.created_at))});const H=Array.from(U.values()).filter(Y=>Y.app_launches>0||Y.content_views>0).sort((Y,se)=>new Date(se.last_activity).getTime()-new Date(Y.last_activity).getTime());i(H)}catch(w){console.error("Error loading activity:",w),s({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{u(!1)}},_=w=>r.filter(j=>j.user_id===w),b=w=>a.filter(j=>j.user_id===w);return d?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Agent Activity"}),e.jsx(pr,{children:"Track app usage and content engagement - click an agent for details"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Agent"}),e.jsx(bt,{className:"text-center",children:"App Launches"}),e.jsx(bt,{className:"text-center",children:"Content Views"}),e.jsx(bt,{children:"Last Active"})]})}),e.jsx(Pn,{children:l.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:4,className:"text-center text-muted-foreground",children:"No activity yet"})}):l.map(w=>e.jsxs(Ns,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>f({id:w.user_id,name:w.user_name,email:w.user_email}),children:[e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:w.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:w.user_email})]})}),e.jsx(lt,{className:"text-center",children:e.jsxs(rt,{variant:"outline",className:"gap-1",children:[e.jsx(ul,{className:"h-3 w-3"}),w.app_launches]})}),e.jsx(lt,{className:"text-center",children:e.jsxs(rt,{variant:"secondary",className:"gap-1",children:[e.jsx(In,{className:"h-3 w-3"}),w.content_views]})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:w.last_activity&&Sd(new Date(w.last_activity),{addSuffix:!0})})]},w.user_id))})]})})})]}),e.jsx(_s,{open:!!p,onOpenChange:w=>!w&&f(null),children:e.jsxs(vs,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{children:[p==null?void 0:p.name,"'s Activity"]}),e.jsx(Kr,{children:p==null?void 0:p.email})]}),e.jsxs(ka,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(_a,{className:"grid w-full grid-cols-2",children:[e.jsx(js,{value:"content",children:"Content Engagement"}),e.jsx(js,{value:"apps",children:"App Launches"})]}),e.jsx(zs,{value:"content",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Resource"}),e.jsx(bt,{children:"Type"}),e.jsx(bt,{children:"Action"}),e.jsx(bt,{children:"Time"})]})}),e.jsx(Pn,{children:p&&b(p.id).length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement yet"})}):p&&b(p.id).map(w=>e.jsxs(Ns,{children:[e.jsx(lt,{className:"max-w-[200px] truncate font-medium",children:w.resource_title}),e.jsx(lt,{children:e.jsxs(rt,{variant:"outline",className:"gap-1",children:[ohs(w.resource_type),ahs[w.resource_type]||w.resource_type]})}),e.jsx(lt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ihs[w.action_type]||w.action_type})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:Sd(new Date(w.created_at),{addSuffix:!0})})]},w.id))})]})})}),e.jsx(zs,{value:"apps",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"App"}),e.jsx(bt,{children:"Time"})]})}),e.jsx(Pn,{children:p&&_(p.id).length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches yet"})}):p&&_(p.id).map(w=>e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsx(rt,{variant:"outline",children:w.app_name})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:Sd(new Date(w.launched_at),{addSuffix:!0})})]},w.id))})]})})})]})]})})]})},chs=({brokerageId:t})=>{const{toast:s}=Pa(),[r,n]=C.useState({totalAgents:0,activeAgents:0,pendingAgents:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0}),[a,o]=C.useState(!0);C.useEffect(()=>{l()},[t]);const l=async()=>{try{o(!0);const{data:i,error:d}=await G.from("profiles").select("id").eq("brokerage_id",t);if(d)throw d;const u=i.map(L=>L.id),p=u.length;if(u.length===0){o(!1);return}const{data:f,error:y}=await G.from("profiles").select("id, email").in("id",u);if(y)throw y;const{count:_}=await G.from("profiles").select("*",{count:"exact",head:!0}).eq("brokerage_id",t).not("last_login","is",null),b=_||0,w=p-b,{count:j}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u),k=new Date;k.setDate(k.getDate()-7);const{count:S}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",k.toISOString()),T=new Date;T.setMonth(T.getMonth()-1);const{count:I}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",T.toISOString());n({totalAgents:p,activeAgents:b,pendingAgents:w,totalLaunches:j||0,launchesThisWeek:S||0,launchesThisMonth:I||0})}catch(i){console.error("Error loading analytics:",i),s({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{o(!1)}};return a?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Agents"}),e.jsx(hr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.totalAgents}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[r.activeAgents," active, ",r.pendingAgents," pending"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Active Agents"}),e.jsx(hi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.activeAgents}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r.totalAgents>0?`${Math.round(r.activeAgents/r.totalAgents*100)}% of total`:"0% of total"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(Tn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.pendingAgents}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting setup"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(Pm,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.totalLaunches}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"This Week"}),e.jsx(Pm,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.launchesThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"This Month"}),e.jsx(Pm,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.launchesThisMonth}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]})]})},dhs=({brokerageId:t})=>{const[s,r]=C.useState([]),[n,a]=C.useState(!0),[o,l]=C.useState(!1),[i,d]=C.useState(!1),[u,p]=C.useState({description:"",maxUses:""});C.useEffect(()=>{f()},[t]);const f=async()=>{try{const{data:k,error:S}=await G.from("invite_codes").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(S)throw S;r(k||[])}catch(k){console.error("Error loading invite codes:",k),fe.error("Failed to load invite links")}finally{a(!1)}},y=()=>Math.random().toString(36).substring(2,8).toUpperCase(),_=async()=>{l(!0);try{const k=y(),{error:S}=await G.from("invite_codes").insert({code:k,description:u.description||null,max_uses:u.maxUses?parseInt(u.maxUses):null,brokerage_id:t,is_active:!0});if(S)throw S;fe.success("Invite link created!"),d(!1),p({description:"",maxUses:""}),f()}catch(k){console.error("Error creating invite code:",k),fe.error("Failed to create invite link")}finally{l(!1)}},b=async k=>{try{const{error:S}=await G.from("invite_codes").delete().eq("id",k);if(S)throw S;fe.success("Invite link deleted"),r(s.filter(T=>T.id!==k))}catch(S){console.error("Error deleting invite code:",S),fe.error("Failed to delete invite link")}},w=async(k,S)=>{try{const{error:T}=await G.from("invite_codes").update({is_active:!S}).eq("id",k);if(T)throw T;r(s.map(I=>I.id===k?{...I,is_active:!S}:I)),fe.success(`Invite link ${S?"deactivated":"activated"}`)}catch(T){console.error("Error toggling invite code:",T),fe.error("Failed to update invite link")}},j=k=>{const S=`${window.location.origin}/join?code=${k}`;navigator.clipboard.writeText(S),fe.success("Link copied to clipboard!")};return n?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Do,{className:"h-5 w-5"}),"Agent Invite Links"]}),e.jsx(pr,{children:"Create shareable links for agents to join your brokerage"})]}),e.jsxs(_s,{open:i,onOpenChange:d,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Link"]})}),e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Create Invite Link"}),e.jsx(Kr,{children:"Create a new invite link for agents to join your brokerage"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description (optional)"}),e.jsx(Re,{id:"description",placeholder:"e.g., New agent recruiting campaign",value:u.description,onChange:k=>p({...u,description:k.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"maxUses",children:"Max Uses (optional)"}),e.jsx(Re,{id:"maxUses",type:"number",placeholder:"Leave empty for unlimited",value:u.maxUses,onChange:k=>p({...u,maxUses:k.target.value})})]}),e.jsx(K,{onClick:_,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Invite Link"})]})]})]})]}),e.jsx(Oe,{children:s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Do,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No invite links yet"}),e.jsx("p",{className:"text-sm",children:"Create one to start inviting agents"})]}):e.jsx("div",{className:"space-y-3",children:s.map(k=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"text-sm font-mono bg-muted px-2 py-0.5 rounded",children:k.code}),e.jsx(rt,{variant:k.is_active?"default":"secondary",children:k.is_active?"Active":"Inactive"})]}),k.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:k.description}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[k.uses_count," uses",k.max_uses&&` / ${k.max_uses} max`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>j(k.code),title:"Copy link",children:e.jsx(ai,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(k.id,k.is_active),title:k.is_active?"Deactivate":"Activate",children:k.is_active?"Disable":"Enable"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(k.id),className:"text-destructive hover:text-destructive",title:"Delete",children:e.jsx(jr,{className:"h-4 w-4"})})]})]},k.id))})})]})},uhs=({open:t,onOpenChange:s,referralCode:r,brokerageId:n,senderName:a,brokerageName:o,onInvitesSent:l})=>{const[i,d]=C.useState(""),[u,p]=C.useState([]),[f,y]=C.useState(""),[_,b]=C.useState(!1),w=I=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I),j=()=>{const I=i.trim().toLowerCase();if(I&&w(I)&&!u.includes(I)){if(u.length>=10){fe.error("Maximum 10 emails per invite");return}p([...u,I]),d("")}else I&&!w(I)?fe.error("Please enter a valid email address"):u.includes(I)&&fe.error("Email already added")},k=I=>{p(u.filter(L=>L!==I))},S=I=>{(I.key==="Enter"||I.key===",")&&(I.preventDefault(),j())},T=async()=>{if(u.length===0){fe.error("Please add at least one email address");return}b(!0);try{const{data:I,error:L}=await G.functions.invoke("send-referral-invite",{body:{emails:u,personalMessage:f.trim()||void 0,referralCode:r,brokerageId:n,senderName:a,brokerageName:o}});if(L)throw L;I.successCount===I.totalCount?fe.success(`${I.successCount} invite${I.successCount>1?"s":""} sent successfully!`):fe.warning(`${I.successCount} of ${I.totalCount} invites sent. Some failed.`),p([]),y(""),s(!1),l==null||l()}catch(I){console.error("Error sending invites:",I),fe.error("Failed to send invites. Please try again.")}finally{b(!1)}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-[550px]",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5 text-primary"}),"Invite Broker Friends"]}),e.jsx(Kr,{children:"Send a personalized email invitation to broker owners you know. They'll receive a beautiful email highlighting LevelUp's features."})]}),e.jsxs("div",{className:"bg-gradient-to-r from-primary/10 to-primary/5 border border-primary/20 rounded-lg p-4 flex items-center gap-3",children:[e.jsx("div",{className:"bg-primary/20 rounded-full p-2",children:e.jsx(po,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:"Earn $25/month for each referral!"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"When they sign up and stay for 30 days, you save on your membership forever."})]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"email",children:"Email Addresses (up to 10)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{id:"email",type:"email",placeholder:"Enter email and press Enter",value:i,onChange:I=>d(I.target.value),onKeyDown:S,onBlur:j}),e.jsx(K,{type:"button",variant:"secondary",onClick:j,children:"Add"})]}),u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:u.map(I=>e.jsxs(rt,{variant:"secondary",className:"flex items-center gap-1 pr-1",children:[I,e.jsx("button",{type:"button",onClick:()=>k(I),className:"ml-1 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Ur,{className:"h-3 w-3"})})]},I))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"message",children:"Personal Message (optional)"}),e.jsx(Ar,{id:"message",placeholder:"Add a personal note that will appear at the top of the email...",value:f,onChange:I=>y(I.target.value),rows:3,maxLength:500}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[f.length,"/500 characters"]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),"What they'll receive:"]}),e.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Beautiful branded email from you"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Your personal message (if added)"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Key LevelUp features for brokerages"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Direct signup link with your referral code"]})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:T,disabled:u.length===0||_,children:_?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent mr-2"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(aa,{className:"h-4 w-4 mr-2"}),"Send ",u.length>0&&`(${u.length})`," Invite",u.length!==1?"s":""]})})]})]})})},hhs=({brokerageId:t,refreshTrigger:s})=>{const[r,n]=C.useState([]),[a,o]=C.useState(!0);C.useEffect(()=>{l()},[t,s]);const l=async()=>{try{const{data:d,error:u}=await G.from("referral_invites").select("*").eq("referrer_brokerage_id",t).order("sent_at",{ascending:!1}).limit(20);if(u)throw u;n(d||[])}catch(d){console.error("Error fetching invites:",d)}finally{o(!1)}},i=d=>{switch(d){case"signed_up":return e.jsxs(rt,{className:"bg-green-100 text-green-800 gap-1",children:[e.jsx(hi,{className:"h-3 w-3"}),"Signed Up"]});case"expired":return e.jsxs(rt,{variant:"outline",className:"text-muted-foreground gap-1",children:[e.jsx(kc,{className:"h-3 w-3"}),"Expired"]});default:return e.jsxs(rt,{variant:"secondary",className:"gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),"Pending"]})}};return a?e.jsx("div",{className:"flex justify-center py-4",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):r.length===0?e.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[e.jsx(br,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No invites sent yet"}),e.jsx("p",{className:"text-xs",children:"Start inviting broker friends to earn rewards!"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium mb-3",children:"Recent Invites"}),r.map(d=>e.jsxs("div",{className:"flex items-center justify-between p-2.5 bg-muted/30 rounded-lg",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:d.recipient_email}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sent ",ys(new Date(d.sent_at),"MMM d, yyyy")]})]}),i(d.status)]},d.id))]})},mhs=()=>{const{brokerageId:t,user:s}=Hs(),[r,n]=C.useState(null),[a,o]=C.useState(""),[l,i]=C.useState(""),[d,u]=C.useState([]),[p,f]=C.useState(!0),[y,_]=C.useState(!1),[b,w]=C.useState(0);C.useEffect(()=>{t&&j()},[t]);const j=async()=>{try{const[R,$]=await Promise.all([G.from("brokerages").select("name").eq("id",t).single(),s?G.from("profiles").select("name").eq("id",s.id).single():Promise.resolve({data:null})]);R.data&&o(R.data.name),$.data&&i($.data.name||"A LevelUp Member");const{data:q}=await G.from("referral_codes").select("code").eq("brokerage_id",t).single();if(q)n(q.code);else{const H=`REF${t==null?void 0:t.slice(0,8).toUpperCase()}`;await G.from("referral_codes").insert({brokerage_id:t,code:H}),n(H)}const{data:U}=await G.from("referrals").select(` *, referred_user:profiles!referred_user_id(name, email), referred_brokerage:brokerages!referred_brokerage_id(name) `).eq("referrer_brokerage_id",t).order("created_at",{ascending:!1});u(U||[])}catch(R){console.error("Error fetching referral data:",R)}finally{f(!1)}},k=()=>{const R=`https://dashboard.relevelup.com/?ref=${r}`;navigator.clipboard.writeText(R),fe.success("Referral link copied to clipboard!")},S=d.filter(R=>R.status==="qualified").length,T=d.filter(R=>R.status==="pending").length,I=S*25,L=Math.max(0,Math.ceil((299-I)/25));return p?null:e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-gradient-to-r from-primary/10 via-primary/5 to-background border-b",children:e.jsxs("div",{className:"px-6 py-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"bg-primary/20 rounded-full p-2",children:e.jsx(po,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold",children:"Referral Rewards Program"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Earn $25/month off your membership for every broker you refer"})]})]}),e.jsx("div",{className:"mt-4 bg-background/80 rounded-lg p-4 border",children:e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-3xl font-bold text-primary",children:["$",I]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Savings"})]}),I>0&&e.jsxs("div",{className:"flex items-center gap-1 text-green-600",children:[e.jsx(hi,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Active"})]})]}),L>0&&I<299&&e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-medium",children:["Refer ",L," more = ",e.jsx("span",{className:"text-primary",children:"FREE membership!"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your membership could cost $0/month"})]}),I>=299&&e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(hn,{className:"h-5 w-5"}),e.jsx("span",{className:"font-bold",children:"FREE Membership Unlocked!"})]})]})})]})}),e.jsxs(Oe,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs(K,{onClick:()=>_(!0),className:"w-full",size:"lg",children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Invite Broker Friends"]}),e.jsxs(K,{onClick:k,variant:"outline",className:"w-full",size:"lg",children:[e.jsx(ai,{className:"h-4 w-4 mr-2"}),"Copy Referral Link"]})]}),e.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Your Referral Link"}),e.jsxs("code",{className:"block px-3 py-2 bg-background rounded border text-sm break-all",children:["https://dashboard.relevelup.com/?ref=",r]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"text-center p-4 bg-green-50 dark:bg-green-950/20 rounded-lg border border-green-200 dark:border-green-900",children:[e.jsx(od,{className:"h-5 w-5 mx-auto text-green-600 mb-1"}),e.jsxs("p",{className:"text-2xl font-bold text-green-700 dark:text-green-400",children:["$",I]}),e.jsx("p",{className:"text-xs text-green-600 dark:text-green-500",children:"Monthly Savings"})]}),e.jsxs("div",{className:"text-center p-4 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsx(hr,{className:"h-5 w-5 mx-auto text-primary mb-1"}),e.jsx("p",{className:"text-2xl font-bold",children:S}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified Referrals"})]}),e.jsxs("div",{className:"text-center p-4 bg-amber-50 dark:bg-amber-950/20 rounded-lg border border-amber-200 dark:border-amber-900",children:[e.jsx(Tn,{className:"h-5 w-5 mx-auto text-amber-600 mb-1"}),e.jsx("p",{className:"text-2xl font-bold text-amber-700 dark:text-amber-400",children:T}),e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-500",children:"Pending (30 days)"})]})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-4",children:[e.jsx("h4",{className:"font-semibold text-sm mb-3",children:"How It Works"}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"1"}),e.jsx("p",{children:"Share your referral link or send an invite email to broker friends"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"2"}),e.jsx("p",{children:"They sign up and subscribe to LevelUp"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"3"}),e.jsx("p",{children:"After 30 days, you get $25/month off your membership - forever!"})]})]})]}),e.jsx(hhs,{brokerageId:t,refreshTrigger:b}),d.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Your Referrals"}),d.slice(0,5).map(R=>{var $,q;return e.jsxs("div",{className:"flex items-center justify-between p-2.5 bg-muted/30 rounded-lg",children:[e.jsx("span",{className:"text-sm truncate",children:(($=R.referred_brokerage)==null?void 0:$.name)||((q=R.referred_user)==null?void 0:q.email)||"Pending setup"}),e.jsxs(rt,{variant:R.status==="qualified"?"default":R.status==="pending"?"secondary":"destructive",className:R.status==="qualified"?"bg-green-600":"",children:[R.status==="qualified"&&e.jsx(hi,{className:"h-3 w-3 mr-1"}),R.status]})]},R.id)})]})]})]}),e.jsx(uhs,{open:y,onOpenChange:_,referralCode:r||"",brokerageId:t||"",senderName:l||"A LevelUp Member",brokerageName:a,onInvitesSent:()=>w(R=>R+1)})]})},phs=({brokerageId:t})=>{const s=Pr(),{teams:r,isLoading:n}=uS(t),{data:a,isLoading:o}=wt({queryKey:["team-aggregate-stats",t,r.map(p=>p.id)],queryFn:async()=>{if(r.length===0)return[];const p=r.map(R=>R.id),{data:f}=await G.from("team_members").select("team_id, user_id, role").in("team_id",p);if(!f||f.length===0)return r.map(R=>({team_id:R.id,team_name:R.name,member_count:0,leader_name:null,leader_avatar:null,total_contacts:0,total_deals:0,total_videos:0}));const y=f.map(R=>R.user_id),_=f.filter(R=>R.role==="team_leader").map(R=>R.user_id),{data:b}=await G.from("profiles").select("id, name, avatar_url").in("id",_),w=new Map((b||[]).map(R=>[R.id,R])),{data:j}=await G.from("innercircle_contacts").select("owner_user_id").in("owner_user_id",y),{data:k}=await G.from("deal_pipeline").select("owner_user_id").in("owner_user_id",y),{data:S}=await G.from("agent_videos").select("owner_user_id").in("owner_user_id",y).eq("is_deleted",!1),T=new Map;(j||[]).forEach(R=>{T.set(R.owner_user_id,(T.get(R.owner_user_id)||0)+1)});const I=new Map;(k||[]).forEach(R=>{I.set(R.owner_user_id,(I.get(R.owner_user_id)||0)+1)});const L=new Map;return(S||[]).forEach(R=>{L.set(R.owner_user_id,(L.get(R.owner_user_id)||0)+1)}),r.map(R=>{const $=f.filter(Q=>Q.team_id===R.id),q=$.find(Q=>Q.role==="team_leader"),U=q?w.get(q.user_id):null,H=$.map(Q=>Q.user_id),Y=H.reduce((Q,de)=>Q+(T.get(de)||0),0),se=H.reduce((Q,de)=>Q+(I.get(de)||0),0),te=H.reduce((Q,de)=>Q+(L.get(de)||0),0);return{team_id:R.id,team_name:R.name,member_count:$.length,leader_name:(U==null?void 0:U.name)||null,leader_avatar:(U==null?void 0:U.avatar_url)||null,total_contacts:Y,total_deals:se,total_videos:te}})},enabled:r.length>0});if(n||o)return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(p=>e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(xs,{className:"h-5 w-32"})}),e.jsx(Oe,{children:e.jsx(xs,{className:"h-24 w-full"})})]},p))});if(r.length===0)return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create teams to organize your agents and track their performance."}),e.jsx(K,{onClick:()=>s("/brokerage/teams"),children:"Manage Teams"})]})});const i=(a||[]).reduce((p,f)=>p+f.member_count,0),d=(a||[]).reduce((p,f)=>p+f.total_contacts,0),u=(a||[]).reduce((p,f)=>p+f.total_deals,0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 grid-cols-2 md:grid-cols-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"})," Teams"]}),e.jsx("p",{className:"text-2xl font-bold",children:r.length})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"})," Total Members"]}),e.jsx("p",{className:"text-2xl font-bold",children:i})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(ok,{className:"h-4 w-4"})," Total Contacts"]}),e.jsx("p",{className:"text-2xl font-bold",children:d.toLocaleString()})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(rh,{className:"h-4 w-4"})," Total Deals"]}),e.jsx("p",{className:"text-2xl font-bold",children:u.toLocaleString()})]})})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:(a||[]).map(p=>e.jsxs(Ee,{className:"hover:shadow-md transition-shadow",children:[e.jsxs(It,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ot,{className:"text-lg",children:p.team_name}),e.jsxs(rt,{variant:"secondary",children:[p.member_count," members"]})]}),p.leader_name&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsxs(xn,{className:"h-6 w-6",children:[e.jsx(Aa,{src:p.leader_avatar||""}),e.jsx(yn,{className:"text-xs",children:p.leader_name.charAt(0).toUpperCase()})]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Uh,{className:"h-3 w-3 text-amber-500"}),p.leader_name]})]})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_contacts.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Contacts"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_deals.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Deals"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_videos.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]},p.team_id))}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{variant:"outline",onClick:()=>s("/brokerage/teams"),children:"Manage Teams →"})})]})},fhs=()=>{const{user:t,isBrokerageManager:s,brokerageId:r,isAdmin:n,managedBrokerages:a,selectedBrokerageId:o,setSelectedBrokerageId:l}=Hs(),i=Pr(),{toast:d}=Pa(),[u,p]=C.useState(""),[f,y]=C.useState(!0),_=o||(a.length>0?a[0].id:r);C.useEffect(()=>{if(!t||!s&&!n){i("/dashboard");return}!o&&a.length>0&&l(a[0].id),_?b():a.length===0&&!r&&y(!1)},[t,s,n,_,i,a,o]);const b=async()=>{if(!_){y(!1);return}try{const{data:w,error:j}=await G.from("brokerages").select("name").eq("id",_).single();if(j)throw j;p(w.name)}catch(w){console.error("Error loading brokerage info:",w),d({title:"Error",description:"Failed to load brokerage information",variant:"destructive"})}finally{y(!1)}};return f?e.jsx(Ts,{title:"Manage Brokerages",description:"Loading brokerage information...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):_?e.jsx(Ts,{title:u||"Manage Brokerages",description:"Brokerage Management Dashboard",children:e.jsxs("div",{className:"space-y-6",children:[a.length>1&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Managing:"}),e.jsxs(sr,{value:o||"",onValueChange:l,children:[e.jsxs(er,{className:"w-[280px]",children:[e.jsx(Ta,{className:"mr-2 h-4 w-4"}),e.jsx(rr,{placeholder:"Select brokerage"})]}),e.jsx(tr,{children:a.map(w=>e.jsx(At,{value:w.id,children:w.name},w.id))})]})]}),e.jsxs(ka,{defaultValue:"agents",className:"space-y-4",children:[e.jsxs(_a,{className:"grid w-full grid-cols-4 md:grid-cols-8",children:[e.jsx(js,{value:"agents",children:"Agents"}),e.jsx(js,{value:"teams",children:"Teams"}),e.jsx(js,{value:"invite",children:"Invite Links"}),e.jsx(js,{value:"referrals",children:"Referrals"}),e.jsx(js,{value:"leaderboard",children:"Leaderboard"}),e.jsx(js,{value:"activity",children:"Activity"}),e.jsx(js,{value:"analytics",children:"Analytics"}),e.jsx(js,{value:"shares",children:"Shares"})]}),e.jsx(zs,{value:"agents",className:"space-y-4",children:e.jsx(nhs,{brokerageId:_})}),e.jsx(zs,{value:"teams",className:"space-y-4",children:e.jsx(phs,{brokerageId:_})}),e.jsx(zs,{value:"invite",className:"space-y-4",children:e.jsx(dhs,{brokerageId:_})}),e.jsx(zs,{value:"referrals",className:"space-y-4",children:e.jsx(mhs,{})}),e.jsx(zs,{value:"leaderboard",className:"space-y-4",children:e.jsx(QGe,{brokerageId:_,title:`${u} Event Leaderboard`,showUserStats:!1})}),e.jsx(zs,{value:"activity",className:"space-y-4",children:e.jsx(lhs,{brokerageId:_})}),e.jsx(zs,{value:"analytics",className:"space-y-4",children:e.jsx(chs,{brokerageId:_})}),e.jsx(zs,{value:"shares",className:"space-y-4",children:e.jsx(pZe,{brokerageOnly:!0,brokerageId:_})})]})]})}):e.jsx(Ts,{title:"Manage Brokerages",description:"Brokerage Management",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ta,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Brokerage Assigned"}),e.jsx("p",{className:"text-muted-foreground",children:"You don't have any brokerages to manage."})]})})};function ghs({brokerageId:t,canManage:s}){const{user:r}=Hs(),[n,a]=C.useState([]),[o,l]=C.useState(!0),[i,d]=C.useState(!1),[u,p]=C.useState(null),[f,y]=C.useState(null),[_,b]=C.useState(!1),[w,j]=C.useState(""),[k,S]=C.useState(""),[T,I]=C.useState(!1),L=async()=>{try{const{data:H,error:Y}=await G.from("brokerage_announcements").select("*").eq("brokerage_id",t).order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1});if(Y)throw Y;const se=H;if(se&&se.length>0){const te=[...new Set(se.map(ae=>ae.created_by))],{data:Q}=await G.from("profiles").select("id, name, avatar_url").in("id",te),de=new Map((Q==null?void 0:Q.map(ae=>[ae.id,ae]))||[]),re=se.map(ae=>({...ae,author:de.get(ae.created_by)||{name:"Unknown",avatar_url:null}}));a(re)}else a([])}catch(H){console.error("Error fetching announcements:",H)}finally{l(!1)}};C.useEffect(()=>{L()},[t]);const R=()=>{j(""),S(""),I(!1),p(null)},$=H=>{H?(p(H),j(H.title),S(H.content),I(H.is_pinned)):R(),d(!0)},q=async()=>{if(!w.trim()||!k.trim()){fe.error("Please fill in all fields");return}b(!0);try{if(u){const{error:H}=await G.from("brokerage_announcements").update({title:w.trim(),content:k.trim(),is_pinned:T,pinned_at:T?new Date().toISOString():null}).eq("id",u.id);if(H)throw H;fe.success("Announcement updated")}else{const{error:H}=await G.from("brokerage_announcements").insert({brokerage_id:t,created_by:r==null?void 0:r.id,title:w.trim(),content:k.trim(),is_pinned:T,pinned_at:T?new Date().toISOString():null});if(H)throw H;fe.success("Announcement created")}d(!1),R(),L()}catch(H){console.error("Error saving announcement:",H),fe.error("Failed to save announcement")}finally{b(!1)}},U=async()=>{if(f)try{const{error:H}=await G.from("brokerage_announcements").delete().eq("id",f);if(H)throw H;fe.success("Announcement deleted"),L()}catch(H){console.error("Error deleting announcement:",H),fe.error("Failed to delete announcement")}finally{y(null)}};return o?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Rm,{className:"h-5 w-5"}),"Announcements"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"animate-pulse space-y-3",children:e.jsx("div",{className:"h-20 bg-muted rounded"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Rm,{className:"h-5 w-5 text-primary"}),"Announcements"]}),s&&e.jsxs(K,{size:"sm",onClick:()=>$(),className:"gap-1",children:[e.jsx(Zs,{className:"h-4 w-4"}),"New"]})]}),e.jsx(Oe,{children:n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No announcements yet"}):e.jsx("div",{className:"space-y-4",children:n.map(H=>{var Y,se,te,Q;return e.jsx("div",{className:`p-4 rounded-lg border ${H.is_pinned?"bg-primary/5 border-primary/20":"bg-muted/30"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[H.is_pinned&&e.jsx(u_,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold truncate",children:H.title})]}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:H.content}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-muted-foreground",children:[e.jsxs(xn,{className:"h-5 w-5",children:[e.jsx(Aa,{src:((Y=H.author)==null?void 0:Y.avatar_url)||void 0}),e.jsx(yn,{className:"text-[10px]",children:((te=(se=H.author)==null?void 0:se.name)==null?void 0:te.charAt(0))||"?"})]}),e.jsx("span",{children:(Q=H.author)==null?void 0:Q.name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:ys(new Date(H.created_at),"MMM d, yyyy")})]})]}),s&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>$(H),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>y(H.id),children:e.jsx(jr,{className:"h-4 w-4"})})]})]})},H.id)})})})]}),e.jsx(_s,{open:i,onOpenChange:d,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:u?"Edit Announcement":"New Announcement"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title"}),e.jsx(Re,{id:"title",value:w,onChange:H=>j(H.target.value),placeholder:"Announcement title..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"content",children:"Content"}),e.jsx(Ar,{id:"content",value:k,onChange:H=>S(H.target.value),placeholder:"Write your announcement...",rows:4})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"pinned",checked:T,onCheckedChange:I}),e.jsxs(ve,{htmlFor:"pinned",className:"flex items-center gap-1 cursor-pointer",children:[e.jsx(u_,{className:"h-4 w-4"}),"Pin to top"]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{onClick:q,disabled:_,children:_?"Saving...":u?"Update":"Create"})]})]})]})}),e.jsx(nc,{open:!!f,onOpenChange:()=>y(null),children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete Announcement"}),e.jsx(Dl,{children:"Are you sure you want to delete this announcement? This action cannot be undone."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:U,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function xhs({brokerageId:t}){const[s,r]=C.useState([]),[n,a]=C.useState(!0),[o,l]=C.useState(""),[i,d]=C.useState(new Set);C.useEffect(()=>{(async()=>{try{const{data:f,error:y}=await G.from("profiles").select("id, name, email, phone, avatar_url, title, bio, areas_served, years_experience, instagram_url, facebook_url, linkedin_url").eq("brokerage_id",t).order("name");if(y)throw y;if(r(f||[]),f&&f.length>0){const _=f.map(w=>w.id),{data:b}=await G.from("agent_assistant_assignments").select("agent_id").in("agent_id",_);b&&d(new Set(b.map(w=>w.agent_id)))}}catch(f){console.error("Error fetching agents:",f)}finally{a(!1)}})()},[t]);const u=s.filter(p=>{var f,y;return p.name.toLowerCase().includes(o.toLowerCase())||p.email.toLowerCase().includes(o.toLowerCase())||((f=p.title)==null?void 0:f.toLowerCase().includes(o.toLowerCase()))||((y=p.areas_served)==null?void 0:y.toLowerCase().includes(o.toLowerCase()))});return n?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Agent Roster"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[1,2,3,4].map(p=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-48 bg-muted rounded-lg"})},p))})})]}):e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5 text-primary"}),"Agent Roster",e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",s.length,")"]})]}),e.jsxs("div",{className:"relative w-full sm:w-64",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search agents...",value:o,onChange:p=>l(p.target.value),className:"pl-9"})]})]}),e.jsx(Oe,{children:u.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:o?"No agents match your search":"No agents in this brokerage yet"}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:u.map(p=>e.jsx(yhs,{agent:p,hasAssistant:i.has(p.id)},p.id))})})]})}function yhs({agent:t,hasAssistant:s}){const r=t.name.split(" ").map(n=>n[0]).join("").toUpperCase().slice(0,2);return e.jsxs("div",{className:"group relative bg-card border rounded-xl p-4 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex flex-col items-center text-center mb-3",children:[e.jsxs(xn,{className:"h-20 w-20 mb-3 ring-2 ring-background shadow-md",children:[e.jsx(Aa,{src:t.avatar_url||void 0,alt:t.name}),e.jsx(yn,{className:"text-lg bg-primary/10 text-primary",children:r})]}),e.jsx("h3",{className:"font-semibold text-sm leading-tight",children:t.name}),t.title&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:t.title}),s&&e.jsx(rt,{variant:"outline",className:"text-[10px] mt-1",children:"Has Assistant"})]}),t.bio&&e.jsx("p",{className:"text-xs text-muted-foreground text-center line-clamp-2 mb-3",children:t.bio}),e.jsxs("div",{className:"space-y-1.5 mb-3",children:[t.areas_served&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Oi,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:t.areas_served})]}),t.years_experience&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center",children:[t.years_experience," ",t.years_experience===1?"year":"years"," experience"]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.phone&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:`tel:${t.phone}`,title:`Call ${t.name}`,children:e.jsx(Qn,{className:"h-4 w-4"})})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:`mailto:${t.email}`,title:`Email ${t.name}`,children:e.jsx(br,{className:"h-4 w-4"})})}),t.linkedin_url&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:t.linkedin_url,target:"_blank",rel:"noopener noreferrer",title:"LinkedIn",children:e.jsx(Om,{className:"h-4 w-4"})})}),t.instagram_url&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:t.instagram_url,target:"_blank",rel:"noopener noreferrer",title:"Instagram",children:e.jsx(Wd,{className:"h-4 w-4"})})})]})]})}function vhs({brokerageId:t}){const[s,r]=C.useState([]),[n,a]=C.useState(!0);if(C.useEffect(()=>{(async()=>{try{const{data:d,error:u}=await G.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!d||d.length===0){r([]),a(!1);return}const p=d.map(w=>w.id),{data:f,error:y}=await G.from("agent_attendance_stats").select("user_id, total_points").in("user_id",p).order("total_points",{ascending:!1});if(y)throw y;const _=new Map(d.map(w=>[w.id,w])),b=(f||[]).filter(w=>w.total_points>0).map(w=>{const j=_.get(w.user_id);return{user_id:w.user_id,total_points:w.total_points,name:(j==null?void 0:j.name)||"Unknown",avatar_url:(j==null?void 0:j.avatar_url)||null}});r(b)}catch(d){console.error("Error fetching leaderboard:",d)}finally{a(!1)}})()},[t]),n)return e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(ao,{className:"h-5 w-5"}),"Team Leaderboard"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"animate-pulse space-y-3",children:[1,2,3].map(i=>e.jsx("div",{className:"h-12 bg-muted rounded"},i))})})]});const o=i=>i===1?"text-yellow-500":i===2?"text-gray-400":i===3?"text-amber-600":"text-muted-foreground",l=i=>i<=3?e.jsx(R0,{className:Pt("h-5 w-5",o(i))}):e.jsx("span",{className:"w-5 text-center text-sm text-muted-foreground",children:i});return e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(ao,{className:"h-5 w-5 text-primary"}),"Team Leaderboard"]})}),e.jsx(Oe,{children:s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No points earned yet. Attend events to earn points!"}):e.jsx("div",{className:"space-y-2",children:s.slice(0,10).map((i,d)=>{const u=i.name.split(" ").map(f=>f[0]).join("").toUpperCase().slice(0,2),p=d+1;return e.jsxs("div",{className:Pt("flex items-center gap-3 p-2 rounded-lg",p<=3&&"bg-muted/50"),children:[e.jsx("div",{className:"w-6 flex justify-center",children:l(p)}),e.jsxs(xn,{className:"h-8 w-8",children:[e.jsx(Aa,{src:i.avatar_url||void 0}),e.jsx(yn,{className:"text-xs",children:u})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:i.name}),e.jsxs("span",{className:"text-sm font-semibold text-primary",children:[i.total_points.toLocaleString()," pts"]})]},i.user_id)})})})]})}function _hs({brokerageId:t}){const s=Pr(),[r,n]=C.useState([]),[a,o]=C.useState(!0);C.useEffect(()=>{(async()=>{try{const{data:d,error:u}=await G.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!d||d.length===0){n([]),o(!1);return}const p=d.map(w=>w.id),f=new Map(d.map(w=>[w.id,w])),{data:y,error:_}=await G.from("listings").select(` id, slug, property_address, city, price, property_type, agent_id, listing_photos(photo_url) `).in("agent_id",p).eq("status","active").order("created_at",{ascending:!1}).limit(6);if(_)throw _;const b=(y||[]).map(w=>({id:w.id,slug:w.slug,property_address:w.property_address,city:w.city,price:w.price,property_type:w.property_type,agent_id:w.agent_id,agent:f.get(w.agent_id)||null,photos:w.listing_photos||[]}));n(b)}catch(d){console.error("Error fetching listings:",d)}finally{o(!1)}})()},[t]);const l=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(i);return a?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(On,{className:"h-5 w-5"}),"Brokerage Listings"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[1,2].map(i=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-32 bg-muted rounded-lg"})},i))})})]}):e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(On,{className:"h-5 w-5 text-primary"}),"Brokerage Listings"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>s("/mission-control/listings"),className:"gap-1",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Listing"]})]}),e.jsxs(Oe,{children:[r.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(On,{className:"h-10 w-10 text-muted-foreground mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No active listings from your brokerage yet"}),e.jsxs(K,{size:"sm",onClick:()=>s("/mission-control/listings/new"),className:"gap-1",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Your First Listing"]})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:r.map(i=>e.jsxs("div",{onClick:()=>window.open(`https://listings.relevelup.com/${i.slug||i.id}`,"_blank"),className:"group cursor-pointer border rounded-lg overflow-hidden hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"relative h-24 bg-muted",children:[i.photos&&i.photos.length>0?e.jsx("img",{src:i.photos[0].photo_url,alt:i.property_address||"Listing",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(On,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("span",{className:"text-[10px] font-medium bg-primary text-primary-foreground px-1.5 py-0.5 rounded uppercase",children:i.property_type.replace("_"," ")})})]}),e.jsxs("div",{className:"p-2.5",children:[e.jsx("p",{className:"font-semibold text-sm text-primary",children:l(i.price)}),e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:i.property_address||"Address not available"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:i.city}),i.agent&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-1.5 truncate",children:["Listed by ",i.agent.name]})]})]},i.id))}),r.length>0&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full mt-3",onClick:()=>s("/mission-control/listings"),children:["View All Listings",e.jsx(sn,{className:"h-3 w-3 ml-1"})]})]})]})}function bhs(){const{user:t,isAdmin:s,isBrokerageManager:r}=Hs(),n=Pr(),[a,o]=C.useState(!0),[l,i]=C.useState(null),[d,u]=C.useState(""),[p,f]=C.useState(0),[y,_]=C.useState(!1),[b,w]=C.useState(!1);return C.useEffect(()=>{(async()=>{if(t)try{const{data:k}=await G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(k!=null&&k.brokerage_id)){o(!1);return}i(k.brokerage_id);const{data:S}=await G.from("brokerages").select("name").eq("id",k.brokerage_id).maybeSingle();S&&u(S.name);const{count:T}=await G.from("profiles").select("id",{count:"exact",head:!0}).eq("brokerage_id",k.brokerage_id);if(f(T||0),s)_(!0),w(!0);else if(r){const{data:I}=await G.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",k.brokerage_id).maybeSingle();_(!!I),w(!!I)}}catch(k){console.error("Error fetching brokerage info:",k)}finally{o(!1)}})()},[t,s,r]),a?e.jsx(Ts,{title:"My Brokerage",description:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):l?e.jsx(Ts,{title:d||"My Brokerage",description:"Team Hub",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 rounded-lg px-4 py-2",children:[e.jsx(hr,{className:"h-5 w-5 text-primary"}),e.jsxs("span",{className:"font-medium",children:[p," ",p===1?"Agent":"Agents"]})]}),b&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>n("/brokerage-content"),children:[e.jsx(Fu,{className:"h-4 w-4 mr-2"}),"Brokerage Content"]}),e.jsxs(K,{onClick:()=>n(`/mission-control/listings/new?brokerage=${l}`),children:[e.jsx(On,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})]}),e.jsx(ghs,{brokerageId:l,canManage:y}),e.jsx(xhs,{brokerageId:l}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsx(vhs,{brokerageId:l}),e.jsx(_hs,{brokerageId:l})]})]})}):e.jsx(Ts,{title:"My Brokerage",description:"Team Hub",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ta,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Brokerage Assigned"}),e.jsx("p",{className:"text-muted-foreground",children:"You're not currently part of a brokerage team."})]})})}function whs(t){if(!t)return null;try{const s=new URL(t),r=s.hostname.replace("www.","");let n=null;if(r==="youtube.com"||r==="m.youtube.com"?n=s.searchParams.get("v"):r==="youtu.be"&&(n=s.pathname.slice(1)),n)return`https://img.youtube.com/vi/${n}/hqdefault.jpg`}catch{}return null}function jhs(t){if(!t)return!1;try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}const _Le={video:{icon:ul,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:In,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:Wo,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:on,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:Bl,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function Nhs({item:t,canManage:s}){const[r,n]=C.useState(!1),[a,o]=C.useState(null),l=P5t(),i=Pr(),d=_Le[t.content_type]||_Le.link,u=d.icon,p=C.useMemo(()=>t.thumbnail_url?t.thumbnail_url:t.content_type==="graphic"&&t.file_url?t.file_url:t.content_type==="video"?whs(t.url):null,[t]);C.useEffect(()=>{p||!t.url||t.content_type!=="video"||!jhs(t.url)||fetch(`https://www.youtube.com/oembed?url=${encodeURIComponent(t.url)}&format=json`).then(b=>b.ok?b.json():null).then(b=>{b!=null&&b.thumbnail_url&&o(b.thumbnail_url)}).catch(()=>{})},[t.url,t.content_type,p]);const f=p||a,y=()=>{i(`/brokerage-content/${t.id}`)},_=async()=>{try{await l.mutateAsync(t.id),fe.success("Content deleted")}catch{fe.error("Failed to delete")}n(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"group overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30 cursor-pointer",onClick:y,children:[f?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:f,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}):e.jsx("div",{className:"aspect-video bg-muted/30 flex items-center justify-center",children:e.jsx(u,{className:"h-12 w-12 text-muted-foreground/30"})}),e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs(rt,{variant:"secondary",className:`text-[10px] px-1.5 py-0 ${d.color}`,children:[e.jsx(u,{className:"h-3 w-3 mr-1"}),d.label]}),t.category&&e.jsxs(rt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:[t.category.icon," ",t.category.name]})]}),e.jsx("h3",{className:"font-semibold text-sm text-foreground group-hover:text-primary transition-colors truncate",children:t.title}),t.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:t.description}),t.content_type==="event"&&t.event_date&&e.jsxs("p",{className:"text-xs text-primary mt-2 font-medium",children:["📅 ",ys(new Date(t.event_date),"MMM d, yyyy · h:mm a")]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-2",children:["Added ",ys(new Date(t.created_at),"MMM d, yyyy")]})]}),s&&e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,onClick:b=>b.stopPropagation(),children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(af,{className:"h-4 w-4"})})}),e.jsx(Md,{align:"end",children:e.jsxs(Na,{onClick:b=>{b.stopPropagation(),n(!0)},className:"text-destructive",children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]})})]}),e.jsx(nc,{open:r,onOpenChange:n,children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete Content"}),e.jsxs(Dl,{children:['Are you sure you want to delete "',t.title,'"? This cannot be undone.']})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:_,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function khs(t){try{const s=new URL(t),r=s.hostname.replace("www.","");let n=null;if(r==="youtube.com"||r==="m.youtube.com"?n=s.searchParams.get("v"):r==="youtu.be"&&(n=s.pathname.slice(1)),n)return`https://img.youtube.com/vi/${n}/hqdefault.jpg`}catch{}return null}const bLe=[{value:"video",label:"🎥 Video",hint:"YouTube, Vimeo, or video URL"},{value:"pdf",label:"📄 Document / PDF",hint:"Upload a PDF or document"},{value:"link",label:"🔗 Link / Resource",hint:"External URL"},{value:"event",label:"📅 Event",hint:"Brokerage event with date"},{value:"graphic",label:"🎨 Graphic / Canva",hint:"Image, Canva share link, or social post"}];function Shs({brokerageId:t,categories:s}){var je;const{user:r}=Hs(),[n,a]=C.useState(!1),[o,l]=C.useState(!1),[i,d]=C.useState(""),[u,p]=C.useState("📁"),[f,y]=C.useState(!1);C.useRef(null);const[_,b]=C.useState("video"),[w,j]=C.useState(""),[k,S]=C.useState(""),[T,I]=C.useState(""),[L,R]=C.useState(""),[$,q]=C.useState(""),[U,H]=C.useState(""),[Y,se]=C.useState(""),te=E5t(),Q=I5t(t),de=L5t(),re=D5t(t),ae=()=>{b("video"),j(""),S(""),I(""),R(""),q(""),H(""),se("")},le=async(Ne,Ge)=>{var Me;const we=(Me=Ne.target.files)==null?void 0:Me[0];if(we){y(!0);try{const Te=we.name.split(".").pop(),Fe=`${t}/${Date.now()}-${Math.random().toString(36).slice(2)}.${Te}`,{error:Ae}=await G.storage.from("brokerage-content").upload(Fe,we);if(Ae)throw Ae;const{data:{publicUrl:Ue}}=G.storage.from("brokerage-content").getPublicUrl(Fe);Ge==="file"?(R(Ue),_==="graphic"&&!$&&q(Ue)):q(Ue),fe.success("File uploaded")}catch(Te){fe.error(Te.message||"Upload failed")}finally{y(!1)}}},he=async()=>{if(!w.trim()){fe.error("Title is required");return}if(r)try{await te.mutateAsync({brokerage_id:t,category_id:Y||null,content_type:_,title:w.trim(),description:k.trim()||null,url:T.trim()||null,file_url:L.trim()||null,thumbnail_url:$.trim()||null,event_date:U?new Date(U).toISOString():null,created_by:r.id}),fe.success("Content added!"),ae(),a(!1)}catch(Ne){fe.error(Ne.message||"Failed to add content")}},be=async()=>{if(i.trim())try{await Q.mutateAsync({name:i.trim(),icon:u,sort_order:s.length}),d(""),p("📁"),fe.success("Category created")}catch(Ne){fe.error(Ne.message||"Failed to create category")}},_e=async()=>{try{await re.mutateAsync(),fe.success("Default categories created")}catch{fe.error("Failed to create defaults")}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(_s,{open:n,onOpenChange:a,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Content"]})}),e.jsxs(vs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Add Brokerage Content"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Content Type"}),e.jsxs(sr,{value:_,onValueChange:b,children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:bLe.map(Ne=>e.jsx(At,{value:Ne.value,children:Ne.label},Ne.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(je=bLe.find(Ne=>Ne.value===_))==null?void 0:je.hint})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Category"}),e.jsxs(sr,{value:Y,onValueChange:se,children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select category (optional)"})}),e.jsx(tr,{children:s.map(Ne=>e.jsxs(At,{value:Ne.id,children:[Ne.icon," ",Ne.name]},Ne.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Title *"}),e.jsx(Re,{value:w,onChange:Ne=>j(Ne.target.value),placeholder:"Content title"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Description"}),e.jsx(Ar,{value:k,onChange:Ne=>S(Ne.target.value),placeholder:"Brief description...",rows:2})]}),["video","link","graphic","event"].includes(_)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:_==="video"?"Video URL":_==="graphic"?"Canva / Image URL":_==="event"?"Event Link (Zoom, etc.)":"URL"}),e.jsx(Re,{value:T,onChange:Ne=>{const Ge=Ne.target.value;if(I(Ge),_==="video"&&!$){const we=khs(Ge);we&&q(we)}},placeholder:"https://..."})]}),["pdf","graphic"].includes(_)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:_==="pdf"?"Upload PDF":"Upload Image"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{type:"file",accept:_==="pdf"?".pdf,.doc,.docx":"image/*",onChange:Ne=>le(Ne,"file"),disabled:f}),f&&e.jsx(Ms,{className:"h-4 w-4 animate-spin"})]}),L&&e.jsx("p",{className:"text-xs text-green-600",children:"✓ File uploaded"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Thumbnail Image (optional)"}),e.jsx(Re,{type:"file",accept:"image/*",onChange:Ne=>le(Ne,"thumbnail"),disabled:f}),$&&e.jsxs("div",{className:"relative w-20 h-20 rounded overflow-hidden",children:[e.jsx("img",{src:$,className:"w-full h-full object-cover",alt:"thumb"}),e.jsx("button",{onClick:()=>q(""),className:"absolute top-0 right-0 bg-background/80 rounded-bl p-0.5",children:e.jsx(Ur,{className:"h-3 w-3"})})]})]}),_==="event"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Event Date & Time"}),e.jsx(Re,{type:"datetime-local",value:U,onChange:Ne=>H(Ne.target.value)})]}),e.jsxs(K,{onClick:he,disabled:te.isPending||!w.trim(),className:"w-full",children:[te.isPending?e.jsx(Ms,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Content"]})]})]})]}),e.jsxs(_s,{open:o,onOpenChange:l,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",children:[e.jsx($l,{className:"h-4 w-4 mr-2"}),"Categories"]})}),e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Manage Categories"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[s.length===0&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No categories yet"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:_e,disabled:re.isPending,children:[re.isPending?e.jsx(Ms,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Default Categories"]})]}),s.map(Ne=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg border",children:[e.jsxs("span",{className:"text-sm",children:[Ne.icon," ",Ne.name]}),!Ne.is_default&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:async()=>{await de.mutateAsync(Ne.id),fe.success("Category deleted")},children:e.jsx(Ur,{className:"h-4 w-4"})})]},Ne.id)),e.jsxs("div",{className:"flex gap-2 pt-2 border-t",children:[e.jsx(Re,{value:u,onChange:Ne=>p(Ne.target.value),className:"w-14 text-center",maxLength:2}),e.jsx(Re,{value:i,onChange:Ne=>d(Ne.target.value),placeholder:"New category name",className:"flex-1",onKeyDown:Ne=>Ne.key==="Enter"&&be()}),e.jsx(K,{size:"sm",onClick:be,disabled:!i.trim(),children:"Add"})]})]})]})]})]})}function Chs(){const{user:t,isAdmin:s,isBrokerageManager:r}=Hs(),[n,a]=C.useState(!0),[o,l]=C.useState(null),[i,d]=C.useState(""),[u,p]=C.useState(!1),[f,y]=C.useState(null),[_,b]=C.useState("");C.useEffect(()=>{(async()=>{if(t)try{const{data:I}=await G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(I!=null&&I.brokerage_id)){a(!1);return}l(I.brokerage_id);const{data:L}=await G.from("brokerages").select("name").eq("id",I.brokerage_id).maybeSingle();if(L&&d(L.name),s)p(!0);else if(r){const{data:R}=await G.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",I.brokerage_id).maybeSingle();p(!!R)}}catch(I){console.error("Error fetching brokerage info:",I)}finally{a(!1)}})()},[t,s,r]);const{data:w=[]}=M5t(o),{data:j=[],isLoading:k}=T5t(o,f),S=C.useMemo(()=>{if(!_.trim())return j;const T=_.toLowerCase();return j.filter(I=>{var L;return I.title.toLowerCase().includes(T)||((L=I.description)==null?void 0:L.toLowerCase().includes(T))||I.content_type.toLowerCase().includes(T)})},[j,_]);return n?e.jsx(Ts,{title:"Brokerage Content",description:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):o?e.jsx(Ts,{title:`${i} Content`,description:"Brokerage Content Hub",children:e.jsxs("div",{className:"space-y-6",children:[u&&o&&e.jsx(Shs,{brokerageId:o,categories:w}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search content...",value:_,onChange:T=>b(T.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(K,{variant:f===null?"default":"outline",size:"sm",onClick:()=>y(null),children:"All"}),w.map(T=>e.jsxs(K,{variant:f===T.id?"default":"outline",size:"sm",onClick:()=>y(T.id),children:[e.jsx("span",{className:"mr-1",children:T.icon}),T.name]},T.id))]})]}),k?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):S.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Vh,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:_.trim()?"No matching content found":"No content yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:_.trim()?"Try a different search term or category.":u?"Add your first piece of content above.":"Your brokerage hasn't added content yet."})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:S.map(T=>e.jsx(Nhs,{item:T,canManage:u},T.id))})]})}):e.jsx(Ts,{title:"Brokerage Content",description:"Content Hub",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ta,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Brokerage Assigned"}),e.jsx("p",{className:"text-muted-foreground",children:"You're not currently part of a brokerage team."})]})})}const wLe={video:{icon:ul,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:In,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:Wo,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:on,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:Bl,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function Mhs(t){try{const s=new URL(t),r=s.hostname.replace("www.","");if(s.pathname==="/playlist"){const n=s.searchParams.get("list");if(n)return`https://www.youtube.com/embed/videoseries?list=${n}`}if(r==="youtube.com"||r==="m.youtube.com"){const n=s.searchParams.get("v");if(n){const a=s.searchParams.get("list");let o=`https://www.youtube.com/embed/${n}`;return a&&(o+=`?list=${a}`),o}}if(r==="youtu.be"){const n=s.pathname.slice(1);if(n){const a=s.searchParams.get("list");let o=`https://www.youtube.com/embed/${n}`;return a&&(o+=`?list=${a}`),o}}if(r==="youtube.com"&&s.pathname.startsWith("/embed/"))return t}catch{}return null}function Ths(t){try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function Ahs(t){try{return new URL(t).hostname.includes("vimeo.com")}catch{return!1}}function Ehs(t){try{const s=t.match(/vimeo\.com\/(\d+)/);if(s)return`https://player.vimeo.com/video/${s[1]}`}catch{}return null}function Phs(){const{contentId:t}=ko(),{data:s,isLoading:r}=wt({queryKey:["brokerage-content-detail",t],queryFn:async()=>{const{data:u,error:p}=await G.from("brokerage_content").select(` *, category:brokerage_content_categories(*) `).eq("id",t).single();if(p)throw p;return u},enabled:!!t});if(r)return e.jsx(Ts,{title:"Brokerage Content",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})});if(!s)return e.jsx(Ts,{title:"Brokerage Content",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ta,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Content not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This content may have been removed."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(vo,{to:"/brokerage-content",children:"Back to Content"})})]})});const n=wLe[s.content_type]||wLe.link,a=n.icon,o=s.url||s.file_url,l=o&&Ths(o)?Mhs(o):null,i=o&&Ahs(o)?Ehs(o):null,d=l||i;return e.jsx(Ts,{title:s.title,children:e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(vo,{to:"/brokerage-content",children:[e.jsx(ti,{className:"h-4 w-4"}),"Back to Content"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(rt,{variant:"secondary",className:`text-xs px-2 py-0.5 ${n.color}`,children:[e.jsx(a,{className:"h-3 w-3 mr-1"}),n.label]}),s.category&&e.jsxs(rt,{variant:"outline",className:"text-xs px-2 py-0.5",children:[s.category.icon," ",s.category.name]}),e.jsxs("span",{className:"text-xs text-muted-foreground ml-auto",children:["Added ",ys(new Date(s.created_at),"MMMM d, yyyy")]})]}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),d&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("div",{className:"relative w-full bg-black",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:d,className:"absolute top-0 left-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:s.title})})}),s.content_type==="graphic"&&s.file_url&&!d&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("img",{src:s.file_url,alt:s.title,className:"w-full max-h-[600px] object-contain bg-muted"})}),!d&&s.content_type!=="graphic"&&s.thumbnail_url&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("img",{src:s.thumbnail_url,alt:s.title,className:"w-full max-h-[400px] object-cover"})}),s.description&&e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})})}),s.content_type==="event"&&s.event_date&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(on,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Event Date"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:ys(new Date(s.event_date),"EEEE, MMMM d, yyyy · h:mm a")})]})]})}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.file_url&&e.jsx(K,{asChild:!0,size:"lg",children:e.jsxs("a",{href:s.file_url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),s.content_type==="pdf"?"Download Document":"Download File"]})}),s.url&&e.jsx(K,{variant:s.file_url?"outline":"default",asChild:!0,size:"lg",children:e.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),d?"Open on YouTube":s.content_type==="event"?"Join Event":s.content_type==="graphic"?"Open in Canva":"Open Link"]})})]})]})})}function Ihs(){const t=Pr(),[s,r]=C.useState(""),[n,a]=C.useState("grid"),{data:o,isLoading:l}=wt({queryKey:["newsletters"],queryFn:async()=>{const{data:T,error:I}=await G.from("newsletter_content").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(I)throw I;return T}}),{data:i}=wt({queryKey:["newsletter-likes-all"],queryFn:async()=>{const{data:T}=await G.from("newsletter_likes").select("newsletter_id");return T||[]}}),{data:d}=wt({queryKey:["newsletter-comments-all"],queryFn:async()=>{const{data:T}=await G.from("newsletter_comments").select("newsletter_id");return T||[]}}),{data:u}=wt({queryKey:["newsletter-resource-counts"],queryFn:async()=>{const[T,I,L,R]=await Promise.all([G.from("newsletter_canva_links").select("newsletter_id"),G.from("newsletter_pdfs").select("newsletter_id"),G.from("newsletter_videos").select("newsletter_id"),G.from("newsletter_drive_links").select("newsletter_id")]);return{canva:T.data||[],pdfs:I.data||[],videos:L.data||[],drives:R.data||[]}}}),p=T=>(i==null?void 0:i.filter(I=>I.newsletter_id===T).length)||0,f=T=>(d==null?void 0:d.filter(I=>I.newsletter_id===T).length)||0,y=T=>{var I;return((I=u==null?void 0:u.canva)==null?void 0:I.filter(L=>L.newsletter_id===T).length)||0},_=T=>{var I;return((I=u==null?void 0:u.pdfs)==null?void 0:I.filter(L=>L.newsletter_id===T).length)||0},b=T=>{var I;return((I=u==null?void 0:u.videos)==null?void 0:I.filter(L=>L.newsletter_id===T).length)||0},w=T=>{var I;return((I=u==null?void 0:u.drives)==null?void 0:I.filter(L=>L.newsletter_id===T).length)||0},j=T=>y(T)+_(T)+b(T)+w(T),k=o==null?void 0:o.filter(T=>{var I;return T.title.toLowerCase().includes(s.toLowerCase())||((I=T.description)==null?void 0:I.toLowerCase().includes(s.toLowerCase()))}),S=T=>{t(`/newsletters/${T}`)};return e.jsx(Ts,{title:"Newsletter Content",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-bold text-foreground text-5xl",children:"Newsletter Content"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Monthly newsletter templates and resources"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search newsletters...",value:s,onChange:T=>r(T.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[s&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(yp,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Hh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[(k==null?void 0:k.length)||0," item",(k==null?void 0:k.length)!==1?"s":""," found"]}),l&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(8)].map((T,I)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-0",children:[e.jsx(xs,{className:"aspect-[3/2] w-full"}),e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsx(xs,{className:"h-5 w-3/4"}),e.jsx(xs,{className:"h-4 w-full"})]})]})},I))}),!l&&(k==null?void 0:k.length)===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(In,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("div",{className:"text-muted-foreground mb-4",children:s?"No newsletters match your search":"No newsletters available yet"}),s&&e.jsx(K,{variant:"outline",onClick:()=>r(""),children:"Clear Search"})]}),!l&&k&&k.length>0&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-3",children:k.map(T=>{const I=j(T.id),L=y(T.id),R=_(T.id),$=b(T.id);return n==="grid"?e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer border-border/50",onClick:()=>S(T.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:T.preview_image_url?e.jsx("img",{src:T.preview_image_url,alt:T.title,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(In,{className:"h-16 w-16"})})}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:T.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-xs text-muted-foreground",children:[e.jsx(on,{className:"h-3 w-3"}),ys(new Date(T.publish_date),"MMM d, yyyy")]})]}),T.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:T.description.replace(/<[^>]*>/g,"")}),I>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[L>0&&e.jsxs(rt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(Bl,{className:"h-3 w-3"})," ",L," Template",L>1?"s":""]}),R>0&&e.jsxs(rt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(xi,{className:"h-3 w-3"})," ",R," PDF",R>1?"s":""]}),$>0&&e.jsxs(rt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(ul,{className:"h-3 w-3"})," ",$," Video",$>1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground pt-1 border-t border-border/50",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gu,{className:"h-3 w-3"})," ",p(T.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xc,{className:"h-3 w-3"})," ",f(T.id)]})]})]})]},T.id):e.jsx(Ee,{className:"group overflow-hidden hover:shadow-md transition-all duration-200 cursor-pointer border-border/50",onClick:()=>S(T.id),children:e.jsxs("div",{className:"flex flex-row",children:[e.jsx("div",{className:"relative overflow-hidden bg-muted w-40 sm:w-48 shrink-0",children:T.preview_image_url?e.jsx("img",{src:T.preview_image_url,alt:T.title,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground min-h-[100px]",children:e.jsx(In,{className:"h-10 w-10"})})}),e.jsxs(Oe,{className:"p-4 flex-1 flex flex-col justify-center gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:T.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground",children:[e.jsx(on,{className:"h-3 w-3"}),ys(new Date(T.publish_date),"MMM d, yyyy")]})]}),T.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:T.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[I>0&&e.jsxs("span",{children:[I," resource",I>1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gu,{className:"h-3 w-3"})," ",p(T.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xc,{className:"h-3 w-3"})," ",f(T.id)]})]})]})]})},T.id)})})]})})}function Lhs({rows:t}){if(!t||t.length===0)return null;const s=t.filter(r=>r.columns.some(n=>n.title||n.description||n.image_url));return s.length===0?null:e.jsx("div",{className:"space-y-6",children:s.map((r,n)=>{const a=r.columns.filter(o=>o.title||o.description||o.image_url);return a.length===0?null:e.jsx("div",{className:"grid gap-4",style:{gridTemplateColumns:`repeat(${a.length}, minmax(0, 1fr))`},children:a.map((o,l)=>e.jsxs(Ee,{className:"overflow-hidden border-border/50",children:[o.image_url&&e.jsx("img",{src:o.image_url,alt:o.title||"",className:"w-full h-40 object-cover"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[o.title&&e.jsx("h4",{className:"font-semibold text-foreground",children:o.title}),o.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:o.description})]})]},l))},n)})})}function Dhs(){const{id:t}=ko(),s=Pr(),{user:r}=Hs(),{toast:n}=Pa(),a=rs(),{trackEngagement:o}=KL(),[l,i]=C.useState(""),{data:d,isLoading:u}=wt({queryKey:["newsletter",t],queryFn:async()=>{const{data:L,error:R}=await G.from("newsletter_content").select("*").eq("id",t).single();if(R)throw R;return L},enabled:!!t});C.useEffect(()=>{d&&o("newsletter",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:p}=wt({queryKey:["newsletter-drives",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_drive_links").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:f}=wt({queryKey:["newsletter-pdfs",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_pdfs").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:y}=wt({queryKey:["newsletter-videos",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_videos").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:_}=wt({queryKey:["newsletter-canva-links",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_canva_links").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:b}=wt({queryKey:["newsletter-likes",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_likes").select("*").eq("newsletter_id",t);return L||[]},enabled:!!t}),{data:w}=wt({queryKey:["newsletter-comments",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_comments").select("*, profiles:user_id(name)").eq("newsletter_id",t).order("created_at",{ascending:!1});return L||[]},enabled:!!t}),j=b==null?void 0:b.some(L=>L.user_id===(r==null?void 0:r.id)),k=Dt({mutationFn:async()=>{j?await G.from("newsletter_likes").delete().eq("newsletter_id",t).eq("user_id",r==null?void 0:r.id):await G.from("newsletter_likes").insert({newsletter_id:t,user_id:r==null?void 0:r.id})},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-likes",t]})}}),S=Dt({mutationFn:async L=>{const{error:R}=await G.from("newsletter_comments").insert({newsletter_id:t,user_id:r==null?void 0:r.id,content:L});if(R)throw R},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),i(""),n({title:"Comment added"})}}),T=Dt({mutationFn:async L=>{const{error:R}=await G.from("newsletter_comments").delete().eq("id",L);if(R)throw R},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),n({title:"Comment deleted"})}}),I=L=>{if(L.includes("player.mediadelivery.net")||L.includes("iframe.mediadelivery.net")){const R=L.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(R)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://iframe.mediadelivery.net/embed/${R[1]}/${R[2]}?autoplay=false`,className:"absolute inset-0 w-full h-full rounded-lg",allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})}if(L.includes("youtube.com")||L.includes("youtu.be")){const R=L.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([^&\s]+)/);if(R)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${R[1]}`,className:"absolute inset-0 w-full h-full rounded-lg",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}return e.jsxs("a",{href:L,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[e.jsx(ul,{className:"h-4 w-4"})," Watch Video"]})};return u?e.jsx(Ts,{title:"",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{className:"h-8 w-32"}),e.jsx(xs,{className:"h-64 w-full"}),e.jsx(xs,{className:"h-32 w-full"})]})}):d?e.jsx(Ts,{title:"",description:"",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/newsletters"),className:"mb-4",children:[e.jsx(ti,{className:"mr-2 h-4 w-4"})," Back to Newsletters"]}),d.preview_image_url&&e.jsx("img",{src:d.preview_image_url,alt:d.title,className:"w-full h-64 md:h-80 object-cover rounded-lg"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:d.title}),e.jsx("p",{className:"text-muted-foreground mt-1",children:ys(new Date(d.publish_date),"MMMM d, yyyy")})]}),d.description&&e.jsx("div",{className:"text-lg text-muted-foreground prose prose-sm max-w-none dark:prose-invert [&_p]:mb-4 [&_p:last-child]:mb-0 whitespace-pre-line",dangerouslySetInnerHTML:{__html:d.description}}),e.jsx(Lhs,{rows:d.content_blocks||[]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(DM,{resourceType:"newsletter",resourceId:d.id,resourceTitle:d.title}),e.jsxs(K,{variant:j?"default":"outline",size:"sm",onClick:()=>k.mutate(),children:[e.jsx(Si,{className:`h-4 w-4 mr-1 ${j?"fill-current":""}`}),(b==null?void 0:b.length)||0," ",(b==null?void 0:b.length)===1?"Like":"Likes"]})]}),_&&_.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Canva Templates"})}),e.jsx(Oe,{className:"space-y-2",children:_.map(L=>e.jsxs("a",{href:L.canva_share_link,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",d.id,d.title,"click_canva"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(Bl,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"font-medium",children:L.title}),e.jsx(sn,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},L.id))})]}),p&&p.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Google Drive Files"})}),e.jsx(Oe,{className:"space-y-2",children:p.map(L=>e.jsxs("a",{href:L.drive_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",d.id,d.title,"click_link"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(sn,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:L.title})]},L.id))})]}),f&&f.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"PDF Downloads"})}),e.jsx(Oe,{className:"space-y-2",children:f.map(L=>e.jsxs("a",{href:L.file_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",d.id,d.title,"click_pdf"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(In,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"font-medium flex-1",children:L.name}),e.jsx(xi,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]}),y&&y.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Videos"})}),e.jsx(Oe,{className:"space-y-6",children:y.map(L=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:L.title}),I(L.video_url)]},L.id))})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"text-lg",children:["Comments (",(w==null?void 0:w.length)||0,")"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Ar,{placeholder:"Write a comment...",value:l,onChange:L=>i(L.target.value),className:"flex-1"}),e.jsx(K,{onClick:()=>l.trim()&&S.mutate(l),disabled:!l.trim()||S.isPending,children:e.jsx(aa,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-4",children:w==null?void 0:w.map(L=>{var R,$,q;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx(xn,{className:"h-8 w-8",children:e.jsx(yn,{children:(($=(R=L.profiles)==null?void 0:R.name)==null?void 0:$[0])||"U"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium text-sm",children:((q=L.profiles)==null?void 0:q.name)||"User"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:ys(new Date(L.created_at),"MMM d, yyyy")}),L.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>T.mutate(L.id),children:e.jsx(jr,{className:"h-3 w-3"})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:L.content})]})]},L.id)})})]})]})]})}):e.jsx(Ts,{title:"Not Found",description:"",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Newsletter not found"}),e.jsx(K,{variant:"link",onClick:()=>s("/newsletters"),children:"Back to Newsletters"})]})})}function Ohs({rows:t,onChange:s}){const[r,n]=C.useState(null),a=()=>{s([...t,{columns:[{title:"",description:""},{title:"",description:""},{title:"",description:""}]}])},o=u=>{s(t.filter((p,f)=>f!==u))},l=(u,p,f,y)=>{const _=[...t];_[u]={..._[u],columns:_[u].columns.map((b,w)=>w===p?{...b,[f]:y}:b)},s(_)},i=async(u,p,f)=>{var b;const y=(b=f.target.files)==null?void 0:b[0];if(!y)return;const _=`${u}-${p}`;n(_);try{const w=`content-blocks/${Date.now()}-${y.name}`,{error:j}=await G.storage.from("newsletter-content").upload(w,y);if(!j){const{data:k}=G.storage.from("newsletter-content").getPublicUrl(w);l(u,p,"image_url",k.publicUrl)}}finally{n(null)}},d=(u,p)=>{l(u,p,"image_url","")};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-base font-medium",children:"Content Blocks (3-Column Rows)"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:a,children:[e.jsx(Zs,{className:"mr-1 h-3 w-3"})," Add Row"]})]}),t.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No content block rows yet. Add a row to create a 3-column layout."}),t.map((u,p)=>e.jsxs(Ee,{className:"relative",children:[e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>o(p),children:e.jsx(Ur,{className:"h-4 w-4"})}),e.jsxs(Oe,{className:"p-4 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Bu,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Row ",p+1]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:u.columns.map((f,y)=>{const _=`${p}-${y}`;return e.jsxs("div",{className:"space-y-2 border border-border/50 rounded-md p-3 bg-muted/20",children:[e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:["Column ",y+1]}),f.image_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:f.image_url,alt:"",className:"w-full h-20 object-cover rounded"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>d(p,y),children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsxs("div",{children:[e.jsx(Re,{type:"file",accept:"image/*",className:"hidden",id:`block-img-${_}`,onChange:b=>i(p,y,b)}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"w-full text-xs h-8",disabled:r===_,asChild:!0,children:e.jsx("label",{htmlFor:`block-img-${_}`,className:"cursor-pointer",children:r===_?"Uploading...":e.jsxs(e.Fragment,{children:[e.jsx(Jo,{className:"h-3 w-3 mr-1"})," Image"]})})})]}),e.jsx(Re,{placeholder:"Title",value:f.title,onChange:b=>l(p,y,"title",b.target.value),className:"h-8 text-sm"}),e.jsx(Ar,{placeholder:"Description",value:f.description,onChange:b=>l(p,y,"description",b.target.value),className:"text-sm min-h-[60px] resize-none"})]},y)})})]})]},p))]})}function Rhs(){const{toast:t}=Pa(),s=rs(),[r,n]=C.useState(!1),[a,o]=C.useState(null),[l,i]=C.useState({title:"",description:"",publish_date:ys(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),[d,u]=C.useState(null),[p,f]=C.useState(null),[y,_]=C.useState([]),[b,w]=C.useState([]),[j,k]=C.useState([]),[S,T]=C.useState([]),[I,L]=C.useState([]),[R,$]=C.useState([]),[q,U]=C.useState(!1),{data:H,isLoading:Y}=wt({queryKey:["admin-newsletters"],queryFn:async()=>{const{data:we,error:Me}=await G.from("newsletter_content").select("*").order("publish_date",{ascending:!1});if(Me)throw Me;return we}}),se=Dt({mutationFn:async we=>{const{data:Me,error:Te}=await G.from("newsletter_content").insert({title:we.title,description:we.description||null,preview_image_url:we.preview_image_url,publish_date:we.publish_date,is_published:we.is_published,content_blocks:we.content_blocks}).select().single();if(Te)throw Te;return Me},onSuccess:async we=>{await de(we.id),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter created successfully"}),we.is_published&&_Rt(we.title,we.id),le()},onError:we=>{t({title:"Error creating newsletter",description:we.message,variant:"destructive"})}}),te=Dt({mutationFn:async we=>{const{error:Me}=await G.from("newsletter_content").update({title:we.title,description:we.description||null,preview_image_url:we.preview_image_url,publish_date:we.publish_date,is_published:we.is_published,content_blocks:we.content_blocks}).eq("id",we.id);if(Me)throw Me;return we.id},onSuccess:async we=>{await de(we),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter updated successfully"}),le()},onError:we=>{t({title:"Error updating newsletter",description:we.message,variant:"destructive"})}}),Q=Dt({mutationFn:async we=>{const{error:Me}=await G.from("newsletter_content").delete().eq("id",we);if(Me)throw Me},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter deleted successfully"})},onError:we=>{t({title:"Error deleting newsletter",description:we.message,variant:"destructive"})}}),de=async we=>{await G.from("newsletter_drive_links").delete().eq("newsletter_id",we),await G.from("newsletter_pdfs").delete().eq("newsletter_id",we),await G.from("newsletter_videos").delete().eq("newsletter_id",we),await G.from("newsletter_canva_links").delete().eq("newsletter_id",we);for(const Me of R){const Te=`${we}/${Date.now()}-${Me.file.name}`,{error:Fe}=await G.storage.from("newsletter-content").upload(Te,Me.file);if(!Fe){const{data:Ae}=G.storage.from("newsletter-content").getPublicUrl(Te);b.push({name:Me.name,file_url:Ae.publicUrl,file_size:Me.file.size,sort_order:b.length})}}y.length>0&&await G.from("newsletter_drive_links").insert(y.map((Me,Te)=>({newsletter_id:we,title:Me.title,drive_url:Me.drive_url,sort_order:Te}))),b.length>0&&await G.from("newsletter_pdfs").insert(b.map((Me,Te)=>({newsletter_id:we,name:Me.name,file_url:Me.file_url,file_size:Me.file_size||null,sort_order:Te}))),j.length>0&&await G.from("newsletter_videos").insert(j.map((Me,Te)=>({newsletter_id:we,title:Me.title,video_url:Me.video_url,sort_order:Te}))),S.length>0&&await G.from("newsletter_canva_links").insert(S.map((Me,Te)=>({newsletter_id:we,title:Me.title,canva_share_link:Me.canva_share_link,sort_order:Te})))},re=async we=>{o(we),i({title:we.title,description:we.description||"",publish_date:ys(new Date(we.publish_date),"yyyy-MM-dd'T'HH:mm"),is_published:we.is_published}),f(we.preview_image_url),L(we.content_blocks||[]);const[Me,Te,Fe,Ae]=await Promise.all([G.from("newsletter_drive_links").select("*").eq("newsletter_id",we.id).order("sort_order"),G.from("newsletter_pdfs").select("*").eq("newsletter_id",we.id).order("sort_order"),G.from("newsletter_videos").select("*").eq("newsletter_id",we.id).order("sort_order"),G.from("newsletter_canva_links").select("*").eq("newsletter_id",we.id).order("sort_order")]);_(Me.data||[]),w(Te.data||[]),k(Fe.data||[]),T(Ae.data||[]),$([]),n(!0)},ae=async we=>{const[Me,Te,Fe,Ae]=await Promise.all([G.from("newsletter_drive_links").select("*").eq("newsletter_id",we.id).order("sort_order"),G.from("newsletter_pdfs").select("*").eq("newsletter_id",we.id).order("sort_order"),G.from("newsletter_videos").select("*").eq("newsletter_id",we.id).order("sort_order"),G.from("newsletter_canva_links").select("*").eq("newsletter_id",we.id).order("sort_order")]);o(null),i({title:`${we.title} (Copy)`,description:we.description||"",publish_date:ys(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),f(we.preview_image_url),L(we.content_blocks||[]),_((Me.data||[]).map(({id:Ue,...ut})=>ut)),w((Te.data||[]).map(({id:Ue,...ut})=>ut)),k((Fe.data||[]).map(({id:Ue,...ut})=>ut)),T((Ae.data||[]).map(({id:Ue,...ut})=>ut)),$([]),n(!0)},le=()=>{n(!1),o(null),i({title:"",description:"",publish_date:ys(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),u(null),f(null),_([]),w([]),k([]),T([]),L([]),$([])},he=async we=>{var Te;const Me=(Te=we.target.files)==null?void 0:Te[0];Me&&(u(Me),f(URL.createObjectURL(Me)))},be=async()=>{if(!l.title){t({title:"Title is required",variant:"destructive"});return}U(!0);let we=p;if(d){const Me=`previews/${Date.now()}-${d.name}`,{error:Te}=await G.storage.from("newsletter-content").upload(Me,d);if(!Te){const{data:Fe}=G.storage.from("newsletter-content").getPublicUrl(Me);we=Fe.publicUrl}}a?te.mutate({id:a.id,...l,preview_image_url:we,content_blocks:I}):se.mutate({...l,preview_image_url:we,content_blocks:I}),U(!1)},_e=()=>_([...y,{title:"",drive_url:"",sort_order:y.length}]),je=()=>k([...j,{title:"",video_url:"",sort_order:j.length}]),Ne=()=>T([...S,{title:"",canva_share_link:"",sort_order:S.length}]),Ge=we=>{const Me=we.target.files;if(!Me)return;const Te=Array.from(Me).map(Fe=>({file:Fe,name:Fe.name.replace(/\.[^/.]+$/,"")}));$([...R,...Te])};return e.jsx(Ts,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(wu,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources"}),e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(H==null?void 0:H.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(H==null?void 0:H.filter(we=>we.is_published).length)||0})})]})]}),e.jsxs(_s,{open:r,onOpenChange:we=>!we&&le(),children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"})," Add Newsletter"]})}),e.jsxs(vs,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:a?"Edit Newsletter":"Add Newsletter"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Title *"}),e.jsx(Re,{value:l.title,onChange:we=>i({...l,title:we.target.value}),placeholder:"Newsletter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Publish Date"}),e.jsx(Re,{type:"datetime-local",value:l.publish_date,onChange:we=>i({...l,publish_date:we.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(rx,{content:l.description,onChange:we=>i({...l,description:we}),placeholder:"Newsletter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[p&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:p,alt:"Preview",className:"h-20 w-32 object-cover rounded-md"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute -top-2 -right-2 h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{u(null),f(null)},children:e.jsx(Ur,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:[e.jsx(Re,{type:"file",accept:"image/*",onChange:he,className:"hidden",id:"preview-upload"}),e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("label",{htmlFor:"preview-upload",className:"cursor-pointer",children:[e.jsx(Za,{className:"mr-2 h-4 w-4"})," Upload Image"]})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{checked:l.is_published,onCheckedChange:we=>i({...l,is_published:we})}),e.jsx(ve,{children:"Published"})]}),e.jsx(Ohs,{rows:I,onChange:L}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-base font-medium",children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Ne,children:[e.jsx(Zs,{className:"mr-1 h-3 w-3"})," Add Canva Link"]})]}),S.map((we,Me)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Re,{placeholder:"Link title",value:we.title,onChange:Te=>{const Fe=[...S];Fe[Me].title=Te.target.value,T(Fe)},className:"w-1/3"}),e.jsx(Re,{placeholder:"Canva share link",value:we.canva_share_link,onChange:Te=>{const Fe=[...S];Fe[Me].canva_share_link=Te.target.value,T(Fe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>T(S.filter((Te,Fe)=>Fe!==Me)),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Me))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-base font-medium",children:"Google Drive Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:_e,children:[e.jsx(Zs,{className:"mr-1 h-3 w-3"})," Add Link"]})]}),y.map((we,Me)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Re,{placeholder:"Link title",value:we.title,onChange:Te=>{const Fe=[...y];Fe[Me].title=Te.target.value,_(Fe)},className:"w-1/3"}),e.jsx(Re,{placeholder:"Google Drive URL",value:we.drive_url,onChange:Te=>{const Fe=[...y];Fe[Me].drive_url=Te.target.value,_(Fe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>_(y.filter((Te,Fe)=>Fe!==Me)),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Me))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-base font-medium",children:"PDF Files"}),e.jsxs("div",{children:[e.jsx(Re,{type:"file",accept:".pdf",multiple:!0,onChange:Ge,className:"hidden",id:"pdf-upload"}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{htmlFor:"pdf-upload",className:"cursor-pointer",children:[e.jsx(Za,{className:"mr-1 h-3 w-3"})," Upload PDF"]})})]})]}),b.map((we,Me)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm",children:we.name}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>w(b.filter((Te,Fe)=>Fe!==Me)),children:e.jsx(Ur,{className:"h-4 w-4"})})]},`existing-${Me}`)),R.map((we,Me)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Re,{value:we.name,onChange:Te=>{const Fe=[...R];Fe[Me].name=Te.target.value,$(Fe)},className:"flex-1 h-8",placeholder:"PDF name"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"(new)"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>$(R.filter((Te,Fe)=>Fe!==Me)),children:e.jsx(Ur,{className:"h-4 w-4"})})]},`pending-${Me}`))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-base font-medium",children:"Video Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:je,children:[e.jsx(Zs,{className:"mr-1 h-3 w-3"})," Add Video"]})]}),j.map((we,Me)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Re,{placeholder:"Video title",value:we.title,onChange:Te=>{const Fe=[...j];Fe[Me].title=Te.target.value,k(Fe)},className:"w-1/3"}),e.jsx(Re,{placeholder:"Video URL",value:we.video_url,onChange:Te=>{const Fe=[...j];Fe[Me].video_url=Te.target.value,k(Fe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>k(j.filter((Te,Fe)=>Fe!==Me)),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Me))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(K,{variant:"outline",onClick:le,children:"Cancel"}),e.jsx(K,{onClick:be,disabled:q||se.isPending||te.isPending,children:q?"Uploading...":a?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Publish Date"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:Y?e.jsx(Ns,{children:e.jsx(lt,{colSpan:4,className:"text-center py-8",children:"Loading..."})}):(H==null?void 0:H.length)===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"No newsletters yet. Create your first one!"})}):H==null?void 0:H.map(we=>e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[we.preview_image_url?e.jsx("img",{src:we.preview_image_url,alt:we.title,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(In,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:we.title}),we.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:we.description.replace(/<[^>]*>/g,"")})]})]})}),e.jsx(lt,{children:ys(new Date(we.publish_date),"MMM d, yyyy")}),e.jsx(lt,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${we.is_published?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400"}`,children:we.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>re(we),title:"Edit",children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ae(we),title:"Duplicate",children:e.jsx(ai,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",title:"Delete",onClick:()=>{confirm("Are you sure you want to delete this newsletter?")&&Q.mutate(we.id)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},we.id))})]})})})]})})}const jLe={open:{label:"Open",color:"bg-blue-100 text-blue-800"},under_review:{label:"Under Review",color:"bg-yellow-100 text-yellow-800"},planned:{label:"Planned",color:"bg-purple-100 text-purple-800"},in_progress:{label:"In Progress",color:"bg-orange-100 text-orange-800"},launched:{label:"Launched",color:"bg-green-100 text-green-800"},declined:{label:"Declined",color:"bg-gray-100 text-gray-800"}};function Fhs(){const{user:t}=Hs(),{toast:s}=Pa(),r=Pr(),n=rs(),[a,o]=C.useState(""),[l,i]=C.useState("popular"),[d,u]=C.useState(!1),[p,f]=C.useState(""),[y,_]=C.useState(""),[b,w]=C.useState(!1),{data:j=[],isLoading:k}=wt({queryKey:["wishlist-items",l,b],queryFn:async()=>{let R=G.from("wishlist_items").select("*");b&&t&&(R=R.eq("user_id",t.id)),l==="latest"?R=R.order("created_at",{ascending:!1}):l==="popular"?R=R.order("vote_count",{ascending:!1}):l==="trending"&&(R=R.order("vote_count",{ascending:!1}));const{data:$,error:q}=await R;if(q)throw q;const U=[...new Set(($==null?void 0:$.map(re=>re.user_id))||[])],{data:H}=await G.from("profiles").select("id, name").in("id",U),Y=new Map((H==null?void 0:H.map(re=>[re.id,re]))||[]);let se=[];if(t){const{data:re}=await G.from("wishlist_votes").select("item_id").eq("user_id",t.id);se=(re==null?void 0:re.map(ae=>ae.item_id))||[]}const te=($==null?void 0:$.map(re=>re.id))||[],{data:Q}=await G.from("wishlist_comments").select("item_id").in("item_id",te),de=new Map;return Q==null||Q.forEach(re=>{de.set(re.item_id,(de.get(re.item_id)||0)+1)}),$==null?void 0:$.map(re=>{const ae=Y.get(re.user_id),le=(ae==null?void 0:ae.name)||"Unknown";return{...re,user_name:le,user_initials:le.split(" ").map(he=>he[0]).join("").toUpperCase().slice(0,2),has_voted:se.includes(re.id),comment_count:de.get(re.id)||0}})}}),S=Dt({mutationFn:async({title:R,description:$})=>{const{error:q}=await G.from("wishlist_items").insert({user_id:t.id,title:R,description:$});if(q)throw q},onSuccess:()=>{n.invalidateQueries({queryKey:["wishlist-items"]}),u(!1),f(""),_(""),s({title:"Idea submitted!",description:"Your idea has been added to the wishlist."})},onError:R=>{s({title:"Error",description:R.message,variant:"destructive"})}}),T=Dt({mutationFn:async({itemId:R,hasVoted:$})=>{if($){const{error:q}=await G.from("wishlist_votes").delete().eq("item_id",R).eq("user_id",t.id);if(q)throw q;return{itemId:R,wasAdded:!1}}else{const{error:q}=await G.from("wishlist_votes").insert({item_id:R,user_id:t.id});if(q)throw q;return{itemId:R,wasAdded:!0}}},onSuccess:async R=>{if(n.invalidateQueries({queryKey:["wishlist-items"]}),R!=null&&R.wasAdded){const $=j.find(U=>U.id===R.itemId),q=(($==null?void 0:$.vote_count)||0)+1;G.functions.invoke("wishlist-notify",{body:{itemId:R.itemId,voteCount:q}}).catch(console.error)}},onError:R=>{s({title:"Error",description:R.message,variant:"destructive"})}}),I=j.filter(R=>R.title.toLowerCase().includes(a.toLowerCase())||R.description.toLowerCase().includes(a.toLowerCase())),L=()=>{if(!p.trim()||!y.trim()){s({title:"Error",description:"Please fill in both title and description.",variant:"destructive"});return}S.mutate({title:p.trim(),description:y.trim()})};return e.jsx(Ts,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(l_,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold",children:"Wishlist"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Share ideas and vote on what we build next"})]})]}),e.jsxs(_s,{open:d,onOpenChange:u,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Idea"]})}),e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Submit a New Idea"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title"}),e.jsx(Re,{id:"title",placeholder:"Give your idea a clear title...",value:p,onChange:R=>f(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",placeholder:"Describe your idea in detail. What problem does it solve? How would it help agents?",value:y,onChange:R=>_(R.target.value),rows:4})]}),e.jsx(K,{onClick:L,className:"w-full",disabled:S.isPending,children:S.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Idea"})]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-6",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search ideas...",value:a,onChange:R=>o(R.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ka,{value:l,onValueChange:R=>i(R),children:e.jsxs(_a,{children:[e.jsx(js,{value:"popular",children:"Most Popular"}),e.jsx(js,{value:"latest",children:"Latest"}),e.jsx(js,{value:"trending",children:"Trending"})]})})})]}),e.jsx("div",{className:"flex items-center gap-2 mb-4",children:e.jsx(K,{variant:b?"default":"outline",size:"sm",onClick:()=>w(!b),children:b?"Show All Ideas":"My Ideas"})}),k?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Ms,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):I.length===0?e.jsxs("div",{className:"text-center py-12 bg-muted/30 rounded-lg",children:[e.jsx(l_,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No ideas yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Be the first to submit an idea!"}),e.jsxs(K,{onClick:()=>u(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Idea"]})]}):e.jsx("div",{className:"space-y-3",children:I.map(R=>e.jsx("div",{className:"bg-card border rounded-lg p-4 hover:shadow-md transition-shadow cursor-pointer",onClick:()=>r(`/wishlist/${R.id}`),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("button",{onClick:$=>{$.stopPropagation(),T.mutate({itemId:R.id,hasVoted:R.has_voted||!1})},className:Pt("flex flex-col items-center justify-center min-w-[50px] py-2 px-3 rounded-lg border transition-colors",R.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(Vd,{className:Pt("h-4 w-4",R.has_voted&&"fill-current")}),e.jsx("span",{className:"text-sm font-semibold",children:R.vote_count})]}),e.jsx(xn,{className:"h-10 w-10 bg-primary/20",children:e.jsx(yn,{className:"bg-primary/20 text-primary text-sm font-medium",children:R.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:R.title}),e.jsx(rt,{className:Pt("text-xs",jLe[R.status].color),children:jLe[R.status].label})]}),e.jsx("p",{className:"text-muted-foreground text-sm line-clamp-2",children:R.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:R.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(R.created_at).toLocaleDateString()})]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(io,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:R.comment_count})]})]})},R.id))})]})})}const NLe={open:{label:"Open",color:"bg-blue-100 text-blue-800"},under_review:{label:"Under Review",color:"bg-yellow-100 text-yellow-800"},planned:{label:"Planned",color:"bg-purple-100 text-purple-800"},in_progress:{label:"In Progress",color:"bg-orange-100 text-orange-800"},launched:{label:"Launched",color:"bg-green-100 text-green-800"},declined:{label:"Declined",color:"bg-gray-100 text-gray-800"}};function zhs(){const{itemId:t}=ko(),s=Pr(),{user:r}=Hs(),{toast:n}=Pa(),a=rs(),[o,l]=C.useState(""),{data:i=!1}=wt({queryKey:["user-is-admin",r==null?void 0:r.id],queryFn:async()=>{if(!r)return!1;const{data:j,error:k}=await G.from("user_roles").select("role").eq("user_id",r.id).eq("role","admin").maybeSingle();return!k&&!!j},enabled:!!r}),{data:d,isLoading:u}=wt({queryKey:["wishlist-item",t],queryFn:async()=>{const{data:j,error:k}=await G.from("wishlist_items").select("*").eq("id",t).single();if(k)throw k;const{data:S}=await G.from("profiles").select("name").eq("id",j.user_id).single();let T=!1;if(r){const{data:I}=await G.from("wishlist_votes").select("id").eq("item_id",t).eq("user_id",r.id).maybeSingle();T=!!I}return{...j,user_name:(S==null?void 0:S.name)||"Unknown",user_initials:((S==null?void 0:S.name)||"U").split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),has_voted:T}}}),{data:p=[],isLoading:f}=wt({queryKey:["wishlist-comments",t],queryFn:async()=>{const{data:j,error:k}=await G.from("wishlist_comments").select("*").eq("item_id",t).order("created_at",{ascending:!0});if(k)throw k;const S=[...new Set((j==null?void 0:j.map(L=>L.user_id))||[])],{data:T}=await G.from("profiles").select("id, name").in("id",S),I=new Map((T==null?void 0:T.map(L=>[L.id,L]))||[]);return j==null?void 0:j.map(L=>{const R=I.get(L.user_id),$=(R==null?void 0:R.name)||"Unknown";return{...L,user_name:$,user_initials:$.split(" ").map(q=>q[0]).join("").toUpperCase().slice(0,2)}})}}),y=Dt({mutationFn:async j=>{if(j){const{error:k}=await G.from("wishlist_votes").delete().eq("item_id",t).eq("user_id",r.id);if(k)throw k;return{wasAdded:!1}}else{const{error:k}=await G.from("wishlist_votes").insert({item_id:t,user_id:r.id});if(k)throw k;return{wasAdded:!0}}},onSuccess:async j=>{if(a.invalidateQueries({queryKey:["wishlist-item",t]}),a.invalidateQueries({queryKey:["wishlist-items"]}),j!=null&&j.wasAdded&&d){const k=(d.vote_count||0)+1;G.functions.invoke("wishlist-notify",{body:{itemId:t,voteCount:k}}).catch(console.error)}},onError:j=>{n({title:"Error",description:j.message,variant:"destructive"})}}),_=Dt({mutationFn:async j=>{const{error:k}=await G.from("wishlist_comments").insert({item_id:t,user_id:r.id,content:j});if(k)throw k},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),l(""),n({title:"Comment added!"})},onError:j=>{n({title:"Error",description:j.message,variant:"destructive"})}}),b=Dt({mutationFn:async j=>{const{error:k}=await G.from("wishlist_comments").delete().eq("id",j);if(k)throw k},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),n({title:"Comment deleted"})},onError:j=>{n({title:"Error",description:j.message,variant:"destructive"})}}),w=()=>{o.trim()&&_.mutate(o.trim())};return u?e.jsx(Ts,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx(xs,{className:"h-8 w-32 mb-6"}),e.jsx(xs,{className:"h-48 w-full mb-6"}),e.jsx(xs,{className:"h-32 w-full"})]})}):d?e.jsx(Ts,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/wishlist"),className:"mb-4",children:[e.jsx(ti,{className:"h-4 w-4 mr-2"}),"Back to Wishlist"]}),e.jsx("div",{className:"bg-card border rounded-lg p-6 mb-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("button",{onClick:()=>y.mutate(d.has_voted),className:Pt("flex flex-col items-center justify-center min-w-[60px] py-3 px-4 rounded-lg border transition-colors",d.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(Vd,{className:Pt("h-5 w-5",d.has_voted&&"fill-current")}),e.jsx("span",{className:"text-lg font-bold",children:d.vote_count}),e.jsx("span",{className:"text-xs",children:"votes"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h1",{className:"text-xl font-bold",children:d.title}),e.jsx(rt,{className:Pt("text-xs",NLe[d.status].color),children:NLe[d.status].label})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap mb-4",children:d.description}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(xn,{className:"h-6 w-6",children:e.jsx(yn,{className:"bg-primary/20 text-primary text-xs",children:d.user_initials})}),e.jsx("span",{children:d.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(d.created_at).toLocaleDateString()})]})]})]})}),e.jsxs("div",{className:"bg-card border rounded-lg p-6",children:[e.jsxs("h2",{className:"text-lg font-semibold mb-4",children:["Comments (",p.length,")"]}),e.jsxs("div",{className:"flex gap-3 mb-6",children:[e.jsx(Bae,{placeholder:i?"Share your thoughts... Use # to link templates":"Share your thoughts on this idea...",value:o,onChange:l,minHeight:"60px",mentionFormat:"encoded",enableTemplateMentions:i}),e.jsx(K,{onClick:w,disabled:!o.trim()||_.isPending,size:"icon",className:"h-auto",children:_.isPending?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):e.jsx(aa,{className:"h-4 w-4"})})]}),f?e.jsx("div",{className:"space-y-4",children:[1,2].map(j=>e.jsx(xs,{className:"h-20 w-full"},j))}):p.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No comments yet. Be the first to share your thoughts!"}):e.jsx("div",{className:"space-y-4",children:p.map(j=>e.jsxs("div",{className:"flex gap-3 p-3 bg-muted/30 rounded-lg",children:[e.jsx(xn,{className:"h-8 w-8",children:e.jsx(yn,{className:"bg-primary/20 text-primary text-xs",children:j.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-sm",children:j.user_name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(j.created_at).toLocaleDateString()})]}),e.jsx(_we,{content:j.content,className:"text-sm text-foreground"})]}),(r==null?void 0:r.id)===j.user_id&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>b.mutate(j.id),children:e.jsx(jr,{className:"h-4 w-4"})})]},j.id))})]})]})}):e.jsx(Ts,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Item not found"}),e.jsx(K,{variant:"link",onClick:()=>s("/wishlist"),children:"Go back to Wishlist"})]})})}const kLe={open:{label:"Open",color:"bg-blue-100 text-blue-800"},under_review:{label:"Under Review",color:"bg-yellow-100 text-yellow-800"},planned:{label:"Planned",color:"bg-purple-100 text-purple-800"},in_progress:{label:"In Progress",color:"bg-orange-100 text-orange-800"},launched:{label:"Launched",color:"bg-green-100 text-green-800"},declined:{label:"Declined",color:"bg-gray-100 text-gray-800"}},SLe=["open","under_review","planned","in_progress","launched","declined"];function Bhs(){const{toast:t}=Pa(),s=Pr(),r=rs(),[n,a]=C.useState(""),[o,l]=C.useState("all"),[i,d]=C.useState(!1),[u,p]=C.useState(null),{data:f=[],isLoading:y}=wt({queryKey:["admin-wishlist-items"],queryFn:async()=>{const{data:k,error:S}=await G.from("wishlist_items").select("*").order("vote_count",{ascending:!1});if(S)throw S;const T=[...new Set((k==null?void 0:k.map(U=>U.user_id))||[])],{data:I}=await G.from("profiles").select("id, name, email").in("id",T),L=new Map((I==null?void 0:I.map(U=>[U.id,U]))||[]),R=(k==null?void 0:k.map(U=>U.id))||[],{data:$}=await G.from("wishlist_comments").select("item_id").in("item_id",R),q=new Map;return $==null||$.forEach(U=>{q.set(U.item_id,(q.get(U.item_id)||0)+1)}),k==null?void 0:k.map(U=>{const H=L.get(U.user_id);return{...U,user_name:(H==null?void 0:H.name)||"Unknown",user_email:(H==null?void 0:H.email)||"",comment_count:q.get(U.id)||0}})}}),_=Dt({mutationFn:async({itemId:k,status:S})=>{const{error:T}=await G.from("wishlist_items").update({status:S}).eq("id",k);if(T)throw T},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),t({title:"Status updated!"})},onError:k=>{t({title:"Error",description:k.message,variant:"destructive"})}}),b=Dt({mutationFn:async k=>{const{error:S}=await G.from("wishlist_items").delete().eq("id",k);if(S)throw S},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),d(!1),p(null),t({title:"Item deleted!"})},onError:k=>{t({title:"Error",description:k.message,variant:"destructive"})}}),w=f.filter(k=>{const S=k.title.toLowerCase().includes(n.toLowerCase())||k.description.toLowerCase().includes(n.toLowerCase())||k.user_name.toLowerCase().includes(n.toLowerCase()),T=o==="all"||k.status===o;return S&&T}),j={total:f.length,open:f.filter(k=>k.status==="open").length,inProgress:f.filter(k=>k.status==="in_progress").length,launched:f.filter(k=>k.status==="launched").length,highVotes:f.filter(k=>k.vote_count>=10).length};return e.jsx(Ts,{title:"Admin - Wishlist",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/admin"),children:e.jsx(ti,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Wishlist Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Review and manage community ideas"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Ideas"}),e.jsx("p",{className:"text-2xl font-bold",children:j.total})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Open"}),e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:j.open})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"In Progress"}),e.jsx("p",{className:"text-2xl font-bold text-orange-600",children:j.inProgress})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Launched"}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:j.launched})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"10+ Votes"}),e.jsx("p",{className:"text-2xl font-bold text-primary",children:j.highVotes})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search ideas, users...",value:n,onChange:k=>a(k.target.value),className:"pl-10"})]}),e.jsxs(sr,{value:o,onValueChange:k=>l(k),children:[e.jsx(er,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"Filter by status"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Statuses"}),SLe.map(k=>e.jsx(At,{value:k,children:kLe[k].label},k))]})]})]}),y?e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(k=>e.jsx(xs,{className:"h-16 w-full"},k))}):e.jsx("div",{className:"bg-card border rounded-lg overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{className:"w-[60px]",children:"Votes"}),e.jsx(bt,{children:"Title"}),e.jsx(bt,{className:"hidden md:table-cell",children:"Submitted By"}),e.jsx(bt,{className:"hidden sm:table-cell",children:"Comments"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Pn,{children:w.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No items found"})}):w.map(k=>e.jsxs(Ns,{className:Pt(k.vote_count>=10&&"bg-primary/5"),children:[e.jsx(lt,{children:e.jsx(rt,{variant:k.vote_count>=10?"default":"secondary",children:k.vote_count})}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium line-clamp-1",children:k.title}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:k.description})]})}),e.jsx(lt,{className:"hidden md:table-cell",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:k.user_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:k.user_email})]})}),e.jsx(lt,{className:"hidden sm:table-cell",children:k.comment_count}),e.jsx(lt,{children:e.jsxs(sr,{value:k.status,onValueChange:S=>_.mutate({itemId:k.id,status:S}),children:[e.jsx(er,{className:"w-[140px] h-8",children:e.jsx(rr,{})}),e.jsx(tr,{children:SLe.map(S=>e.jsx(At,{value:S,children:kLe[S].label},S))})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(`/wishlist/${k.id}`,"_blank"),children:e.jsx(sn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{p(k.id),d(!0)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},k.id))})]})}),e.jsx(_s,{open:i,onOpenChange:d,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Delete Wishlist Item"})}),e.jsx("p",{className:"text-muted-foreground",children:"Are you sure you want to delete this idea? This will also delete all votes and comments."}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:()=>u&&b.mutate(u),disabled:b.isPending,children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})})}function $hs(){const{user:t}=Hs(),[s,r]=C.useState([]),[n,a]=C.useState(!0),[o,l]=C.useState(!1),[i,d]=C.useState(null),[u,p]=C.useState(!1),[f,y]=C.useState(null),[_,b]=C.useState(""),[w,j]=C.useState(""),[k,S]=C.useState(""),[T,I]=C.useState(""),[L,R]=C.useState(""),[$,q]=C.useState(!1),[U,H]=C.useState(""),[Y,se]=C.useState("once"),[te,Q]=C.useState([]),[de,re]=C.useState([]),[ae,le]=C.useState(!1),[he,be]=C.useState(!1),[_e,je]=C.useState([]),[Ne,Ge]=C.useState({total:0,dismissed:0});C.useEffect(()=>{we()},[]);const we=async()=>{const{data:Ze,error:Qe}=await G.from("levelup_briefs").select("*").order("created_at",{ascending:!1});Qe?(fe.error("Failed to fetch briefs"),console.error(Qe)):r(Ze||[]),a(!1)},Me=()=>{b(""),j(""),S(""),I(""),R(""),q(!1),H(new Date().toISOString().slice(0,16)),se("once"),Q([]),re([]),d(null)},Te=()=>{Me(),l(!0)},Fe=async Ze=>{d(Ze),b(Ze.title),j(Ze.description||""),S(Ze.video_url||""),I(Ze.graphic_url||""),R(Ze.graphic_link_url||""),q(Ze.is_published),H(Ze.publish_date.slice(0,16)),se(Ze.show_frequency);const{data:Qe}=await G.from("levelup_brief_links").select("*").eq("brief_id",Ze.id).order("sort_order");Q((Qe==null?void 0:Qe.map(He=>({title:He.title,url:He.url})))||[]);const{data:We}=await G.from("levelup_brief_polls").select("*").eq("brief_id",Ze.id).order("sort_order");if(We){const He=[];for(const et of We){const{data:Tt}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",et.id).order("sort_order");He.push({question:et.question,poll_type:et.poll_type,options:(Tt==null?void 0:Tt.map(Ft=>Ft.option_text))||[]})}re(He)}l(!0)},Ae=async Ze=>{var We;const Qe=(We=Ze.target.files)==null?void 0:We[0];if(Qe){le(!0);try{const He=await G.functions.invoke("bunny-upload",{body:{action:"create",title:Qe.name.replace(/\.[^/.]+$/,"")}});if(He.error)throw He.error;const{videoId:et,libraryId:Tt}=He.data,Ft=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:et}});if(Ft.error)throw Ft.error;const{uploadUrl:as,apiKey:Xt}=Ft.data,ss=new XMLHttpRequest;await new Promise((ar,Ct)=>{ss.upload.addEventListener("progress",Is=>{if(Is.lengthComputable){const qs=Math.round(Is.loaded/Is.total*100);console.log("Upload progress:",qs)}}),ss.addEventListener("load",()=>{ss.status>=200&&ss.status<300?ar():Ct(new Error(`Upload failed with status ${ss.status}`))}),ss.addEventListener("error",()=>Ct(new Error("Upload failed"))),ss.open("PUT",as),ss.setRequestHeader("AccessKey",Xt),ss.send(Qe)});const is=`https://player.mediadelivery.net/embed/${Tt}/${et}`;S(is),fe.success("Video uploaded successfully! It may take a few minutes to process.")}catch(He){console.error("Upload error:",He),fe.error("Failed to upload video")}finally{le(!1)}}},Ue=async()=>{if(!_.trim()){fe.error("Title is required");return}try{let Ze;if(i){const{error:Qe}=await G.from("levelup_briefs").update({title:_,description:w||null,video_url:k||null,graphic_url:T||null,graphic_link_url:L||null,is_published:$,publish_date:U,show_frequency:Y}).eq("id",i.id);if(Qe)throw Qe;Ze=i.id,await G.from("levelup_brief_links").delete().eq("brief_id",Ze);const{data:We}=await G.from("levelup_brief_polls").select("id").eq("brief_id",Ze);if(We)for(const He of We)await G.from("levelup_brief_poll_options").delete().eq("poll_id",He.id);await G.from("levelup_brief_polls").delete().eq("brief_id",Ze)}else{const{data:Qe,error:We}=await G.from("levelup_briefs").insert({title:_,description:w||null,video_url:k||null,graphic_url:T||null,graphic_link_url:L||null,is_published:$,publish_date:U,show_frequency:Y,created_by:t==null?void 0:t.id}).select().single();if(We)throw We;Ze=Qe.id}if(te.length>0){const Qe=te.map((We,He)=>({brief_id:Ze,title:We.title,url:We.url,sort_order:He}));await G.from("levelup_brief_links").insert(Qe)}for(let Qe=0;Qe0){const Tt=We.options.map((Ft,as)=>({poll_id:He.id,option_text:Ft,sort_order:as}));await G.from("levelup_brief_poll_options").insert(Tt)}}fe.success(i?"Brief updated":"Brief created"),l(!1),Me(),we()}catch(Ze){console.error("Error saving brief:",Ze),fe.error("Failed to save brief")}},ut=async Ze=>{if(confirm("Are you sure you want to delete this brief?"))try{const{error:Qe}=await G.from("levelup_briefs").delete().eq("id",Ze);if(Qe)throw Qe;fe.success("Brief deleted"),we()}catch(Qe){console.error("Error deleting brief:",Qe),fe.error("Failed to delete brief")}},De=async Ze=>{y(Ze);const{count:Qe}=await G.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ze.id),{count:We}=await G.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ze.id).not("dismissed_at","is",null);Ge({total:Qe||0,dismissed:We||0});const{data:He}=await G.from("levelup_brief_polls").select("*").eq("brief_id",Ze.id).order("sort_order");if(He){const et=[];for(const Tt of He){const{data:Ft}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",Tt.id).order("sort_order"),{data:as}=await G.from("levelup_brief_poll_responses").select("option_id, user_id").eq("poll_id",Tt.id),Xt=[...new Set((as==null?void 0:as.map(Is=>Is.user_id))||[])];let ss={};if(Xt.length>0){const{data:Is}=await G.from("profiles").select("id, name, email").in("id",Xt);Is&&Is.forEach(qs=>{ss[qs.id]=qs.name||qs.email||"Unknown"})}const is=(as||[]).map(Is=>({optionId:Is.option_id,userName:ss[Is.user_id]||"Unknown",userId:Is.user_id})),ar={};let Ct=0;Ft&&Ft.forEach(Is=>{const qs=(as==null?void 0:as.filter(gr=>gr.option_id===Is.id).length)||0;ar[Is.id]=qs,Ct+=qs}),et.push({...Tt,options:Ft||[],results:ar,respondents:is,totalResponses:Tt.poll_type==="single"?new Set(as==null?void 0:as.map(Is=>Is.user_id)).size:Ct})}je(et)}p(!0)},Rt=()=>{Q([...te,{title:"",url:""}])},me=(Ze,Qe,We)=>{const He=[...te];He[Ze][Qe]=We,Q(He)},Xe=Ze=>{Q(te.filter((Qe,We)=>We!==Ze))},ot=()=>{re([...de,{question:"",poll_type:"single",options:["",""]}])},nt=(Ze,Qe)=>{const We=[...de];We[Ze].question=Qe,re(We)},Se=(Ze,Qe)=>{const We=[...de];We[Ze].poll_type=Qe,re(We)},it=Ze=>{const Qe=[...de];Qe[Ze].options.push(""),re(Qe)},$e=(Ze,Qe,We)=>{const He=[...de];He[Ze].options[Qe]=We,re(He)},ct=(Ze,Qe)=>{const We=[...de];We[Ze].options=We[Ze].options.filter((He,et)=>et!==Qe),re(We)},qe=Ze=>{re(de.filter((Qe,We)=>We!==Ze))};return e.jsxs(Ts,{title:"The LevelUp Brief",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(wu,{title:"The LevelUp Brief",description:"Create engaging popup briefs for your agents",children:e.jsxs(K,{onClick:Te,children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create Brief"]})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{children:"Frequency"}),e.jsx(bt,{children:"Publish Date"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:n?e.jsx(Ns,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):s.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No briefs created yet"})}):s.map(Ze=>e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium",children:Ze.title}),e.jsx(lt,{children:e.jsx(rt,{variant:Ze.is_published?"default":"secondary",children:Ze.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"capitalize",children:Ze.show_frequency.replace("_"," ")}),e.jsx(lt,{children:ys(new Date(Ze.publish_date),"MMM d, yyyy h:mm a")}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>De(Ze),children:e.jsx(ol,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Fe(Ze),children:e.jsx(Rc,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ut(Ze.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},Ze.id))})]})})})]}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:i?"Edit Brief":"Create New Brief"})}),e.jsxs(ka,{defaultValue:"content",className:"w-full",children:[e.jsxs(_a,{className:"grid w-full grid-cols-4",children:[e.jsx(js,{value:"content",children:"Content"}),e.jsx(js,{value:"media",children:"Media"}),e.jsx(js,{value:"links",children:"Links"}),e.jsx(js,{value:"polls",children:"Polls"})]}),e.jsxs(zs,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Title *"}),e.jsx(Re,{value:_,onChange:Ze=>b(Ze.target.value),placeholder:"What's happening at LevelUp..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(rx,{content:w,onChange:Ze=>j(Ze),placeholder:"Brief overview for agents...",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Publish Date"}),e.jsx(Re,{type:"datetime-local",value:U,onChange:Ze=>H(Ze.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Show Frequency"}),e.jsxs(sr,{value:Y,onValueChange:se,children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"once",children:"Once (until dismissed)"}),e.jsx(At,{value:"every_login",children:"Every login"}),e.jsx(At,{value:"daily",children:"Daily"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Br,{checked:$,onCheckedChange:q}),e.jsx(ve,{children:"Publish immediately"})]})]}),e.jsxs(zs,{value:"media",className:"space-y-6 mt-4",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Video (optional)"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Upload Video to Bunny.net"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Re,{type:"file",accept:"video/*",onChange:Ae,disabled:ae})}),ae&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Or paste embed URL"}),e.jsx(Re,{value:k,onChange:Ze=>S(Ze.target.value),placeholder:"https://iframe.mediadelivery.net/embed/..."})]}),k&&e.jsx("div",{className:"aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:k,className:"w-full h-full",allow:"autoplay; fullscreen",allowFullScreen:!0})})]}),e.jsxs("div",{className:"border-t pt-4 space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Graphic / Image (optional)"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Upload Image"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Re,{type:"file",accept:"image/*",onChange:async Ze=>{var We;const Qe=(We=Ze.target.files)==null?void 0:We[0];if(Qe){be(!0);try{const He=Qe.name.split(".").pop(),et=`brief-graphics/${Date.now()}.${He}`,{error:Tt}=await G.storage.from("banner-images").upload(et,Qe,{upsert:!0});if(Tt)throw Tt;const{data:Ft}=G.storage.from("banner-images").getPublicUrl(et);I(Ft.publicUrl),fe.success("Image uploaded!")}catch(He){console.error(He),fe.error("Failed to upload image")}finally{be(!1)}}},disabled:he})}),he&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Or paste Image URL"}),e.jsx(Re,{value:T,onChange:Ze=>I(Ze.target.value),placeholder:"https://example.com/image.png"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Click-through Link (optional)"}),e.jsx(Re,{value:L,onChange:Ze=>R(Ze.target.value),placeholder:"https://example.com/landing-page"})]}),T&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted border",children:e.jsx("img",{src:T,alt:"Brief graphic preview",className:"w-full object-contain max-h-64"})})]})]}),e.jsxs(zs,{value:"links",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ve,{children:"Quick Links"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:Rt,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),te.map((Ze,Qe)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(Re,{value:Ze.title,onChange:We=>me(Qe,"title",We.target.value),placeholder:"Link title",className:"flex-1"}),e.jsx(Re,{value:Ze.url,onChange:We=>me(Qe,"url",We.target.value),placeholder:"https://...",className:"flex-[2]"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Xe(Qe),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]},Qe)),te.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No links added yet"})]}),e.jsxs(zs,{value:"polls",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ve,{children:"Polls"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ot,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Poll"]})]}),de.map((Ze,Qe)=>e.jsx(Ee,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(Re,{value:Ze.question,onChange:We=>nt(Qe,We.target.value),placeholder:"Poll question...",className:"flex-1 mr-2"}),e.jsxs(sr,{value:Ze.poll_type,onValueChange:We=>Se(Qe,We),children:[e.jsx(er,{className:"w-32",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"single",children:"Single"}),e.jsx(At,{value:"multi",children:"Multi-select"})]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>qe(Qe),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"space-y-2 pl-4",children:[Ze.options.map((We,He)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:We,onChange:et=>$e(Qe,He,et.target.value),placeholder:`Option ${He+1}`}),Ze.options.length>2&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ct(Qe,He),children:e.jsx(jr,{className:"h-4 w-4 text-muted-foreground"})})]},He)),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>it(Qe),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Option"]})]})]})},Qe)),de.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls added yet"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:Ue,children:i?"Update Brief":"Create Brief"})]})]})}),e.jsx(_s,{open:u,onOpenChange:p,children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsx(Ss,{children:e.jsxs(ks,{children:["Results: ",f==null?void 0:f.title]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Views"})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-2xl font-bold",children:Ne.total})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Dismissed"})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-2xl font-bold",children:Ne.dismissed})})]})]}),_e.length>0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold",children:"Poll Results"}),_e.map(Ze=>e.jsxs(Ee,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:Ze.question}),e.jsx("div",{className:"space-y-2",children:Ze.options.map(Qe=>{const We=Ze.results[Qe.id]||0,He=Ze.totalResponses>0?Math.round(We/Ze.totalResponses*100):0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:Qe.option_text}),e.jsxs("span",{className:"text-muted-foreground",children:[We," (",He,"%)"]})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${He}%`}})}),We>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:(Ze.respondents||[]).filter(et=>et.optionId===Qe.id).map((et,Tt)=>e.jsx(rt,{variant:"secondary",className:"text-xs font-normal",children:et.userName},Tt))})]},Qe.id)})})]},Ze.id))]}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls in this brief"})]})]})})]})}const qhs=()=>{const{user:t}=Hs(),{toast:s}=Pa(),r=rs(),[n,a]=C.useState(!1),[o,l]=C.useState(null),[i,d]=C.useState({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=C.useState(null),[f,y]=C.useState(""),{data:_=[],isLoading:b}=wt({queryKey:["additional-services-admin"],queryFn:async()=>{const{data:L,error:R}=await G.from("additional_services").select("*").order("publish_date",{ascending:!1});if(R)throw R;return L}}),w=Dt({mutationFn:async L=>{let R=L.existingImageUrl;if(L.image){const q=L.image.name.split(".").pop(),U=`${Date.now()}-${Math.random().toString(36).substring(7)}.${q}`,{error:H}=await G.storage.from("service-images").upload(U,L.image);if(H)throw H;const{data:Y}=G.storage.from("service-images").getPublicUrl(U);R=Y.publicUrl}const $={name:L.item.name,description:L.item.description||null,preview_image_url:R,signup_link_url:L.item.signup_link_url,publish_date:L.item.publish_date?new Date(L.item.publish_date).toISOString():new Date().toISOString(),is_published:L.item.is_published,created_by:t==null?void 0:t.id};if(L.itemId){const{error:q}=await G.from("additional_services").update($).eq("id",L.itemId);if(q)throw q}else{const{error:q}=await G.from("additional_services").insert($);if(q)throw q}},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:o?"Service updated":"Service created"}),a(!1),k()},onError:L=>{s({title:"Error saving service",description:L.message,variant:"destructive"})}}),j=Dt({mutationFn:async L=>{const{error:R}=await G.from("additional_services").delete().eq("id",L);if(R)throw R},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:"Service deleted"})},onError:L=>{s({title:"Error deleting service",description:L.message,variant:"destructive"})}}),k=()=>{d({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),y(""),l(null)},S=L=>{l(L),d({name:L.name,description:L.description||"",signup_link_url:L.signup_link_url,publish_date:L.publish_date?new Date(L.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:L.is_published}),y(L.preview_image_url||""),a(!0)},T=L=>{var $;const R=($=L.target.files)==null?void 0:$[0];R&&(p(R),y(URL.createObjectURL(R)))},I=L=>{if(L.preventDefault(),!i.name.trim()){s({title:"Name is required",variant:"destructive"});return}if(!i.signup_link_url.trim()){s({title:"Signup link URL is required",variant:"destructive"});return}w.mutate({item:i,image:u,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(Ts,{title:"Manage Additional Services",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Services"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.filter(L=>L.is_published).length})})]})]}),e.jsxs(_s,{open:n,onOpenChange:L=>{a(L),L||k()},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Service"]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:o?"Edit Service":"Add New Service"})}),e.jsxs("form",{onSubmit:I,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Name *"}),e.jsx(Re,{id:"name",value:i.name,onChange:L=>d({...i,name:L.target.value}),placeholder:"Enter service name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(rx,{content:i.description,onChange:L=>d({...i,description:L}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"signup_link_url",children:"Signup Link URL *"}),e.jsx(Re,{id:"signup_link_url",type:"url",value:i.signup_link_url,onChange:L=>d({...i,signup_link_url:L.target.value}),placeholder:"https://example.com/signup"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Re,{id:"publish_date",type:"date",value:i.publish_date,onChange:L=>d({...i,publish_date:L.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Br,{id:"is_published",checked:i.is_published,onCheckedChange:L=>d({...i,is_published:L})}),e.jsx(ve,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Preview Image"}),f?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:f,alt:"Preview",className:"w-full max-h-48 object-contain rounded-lg border"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{p(null),y("")},children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(Jo,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(Re,{type:"file",accept:"image/*",onChange:T,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:w.isPending,children:w.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:b?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):_.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'No services yet. Click "Add Service" to create your first one.'}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{className:"w-16",children:"Preview"}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Signup Link"}),e.jsx(bt,{children:"Publish Date"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:_.map(L=>e.jsxs(Ns,{children:[e.jsx(lt,{children:L.preview_image_url?e.jsx("img",{src:L.preview_image_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(Jo,{className:"h-5 w-5 text-muted-foreground"})})}),e.jsx(lt,{className:"font-medium",children:L.name}),e.jsx(lt,{children:e.jsxs("a",{href:L.signup_link_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline flex items-center gap-1",children:[e.jsx(sn,{className:"h-3 w-3"}),"Link"]})}),e.jsx(lt,{children:new Date(L.publish_date).toLocaleDateString()}),e.jsx(lt,{children:e.jsx(rt,{variant:L.is_published?"default":"secondary",children:L.is_published?"Published":"Draft"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>S(L),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this service?")&&j.mutate(L.id)},children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},L.id))})]})})})]})})};function Uhs(){const{toast:t}=Pa(),[s,r]=C.useState([]),[n,a]=C.useState(!0),[o,l]=C.useState(!1),[i,d]=C.useState(!1),[u,p]=C.useState({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""});C.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:j,error:k}=await G.functions.invoke("stripe-manage-coupons",{body:{action:"list"}});if(k)throw k;r(j.coupons||[])}catch(j){console.error("Error fetching coupons:",j),t({title:"Error",description:"Failed to load coupons",variant:"destructive"})}finally{a(!1)}},y=async()=>{if(!u.name){t({title:"Error",description:"Please enter a coupon name",variant:"destructive"});return}if(u.discountType==="percent"&&!u.percentOff){t({title:"Error",description:"Please enter a percent off value",variant:"destructive"});return}if(u.discountType==="amount"&&!u.amountOff){t({title:"Error",description:"Please enter an amount off value",variant:"destructive"});return}if(u.duration==="repeating"&&!u.durationInMonths){t({title:"Error",description:"Please enter duration in months",variant:"destructive"});return}l(!0);try{const j={action:"create",name:u.name,duration:u.duration,promotion_code:u.promotionCode.trim()||void 0};u.discountType==="percent"?j.percent_off=parseFloat(u.percentOff):(j.amount_off=Math.round(parseFloat(u.amountOff)*100),j.currency="usd"),u.duration==="repeating"&&(j.duration_in_months=parseInt(u.durationInMonths));const{data:k,error:S}=await G.functions.invoke("stripe-manage-coupons",{body:j});if(S)throw S;t({title:"Success",description:"Coupon created successfully"}),d(!1),p({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""}),f()}catch(j){console.error("Error creating coupon:",j),t({title:"Error",description:j.message||"Failed to create coupon",variant:"destructive"})}finally{l(!1)}},_=async j=>{if(confirm("Are you sure you want to delete this coupon?"))try{const{error:k}=await G.functions.invoke("stripe-manage-coupons",{body:{action:"delete",couponId:j}});if(k)throw k;t({title:"Success",description:"Coupon deleted successfully"}),f()}catch(k){console.error("Error deleting coupon:",k),t({title:"Error",description:k.message||"Failed to delete coupon",variant:"destructive"})}},b=j=>j.percent_off?`${j.percent_off}% off`:j.amount_off?`$${(j.amount_off/100).toFixed(2)} off`:"N/A",w=j=>{switch(j.duration){case"once":return"Once";case"forever":return"Forever";case"repeating":return`${j.duration_in_months} months`;default:return j.duration}};return e.jsx(Ts,{title:"Subscription Discounts",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(wu,{title:"Subscription Discounts",description:"Create and manage discount coupons for subscriptions",children:e.jsxs(_s,{open:i,onOpenChange:d,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Coupon"]})}),e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Create New Coupon"}),e.jsx(Kr,{children:"Create a discount coupon that can be applied to subscriptions"})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Promotion Code (what users will type)"}),e.jsx(Re,{placeholder:"e.g., BROKERAGE50",value:u.promotionCode,onChange:j=>p({...u,promotionCode:j.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")}),className:"font-mono uppercase"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters and numbers only. This is the code users enter at checkout."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Coupon Name (internal label)"}),e.jsx(Re,{placeholder:"e.g., 50% Off Brokerage Launch",value:u.name,onChange:j=>p({...u,name:j.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Discount Type"}),e.jsxs(sr,{value:u.discountType,onValueChange:j=>{const k=j==="amount"&&u.duration==="forever"?"once":u.duration;p({...u,discountType:j,duration:k})},children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"percent",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(S5,{className:"mr-2 h-4 w-4"}),"Percentage Off"]})}),e.jsx(At,{value:"amount",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(od,{className:"mr-2 h-4 w-4"}),"Fixed Amount Off"]})})]})]})]}),u.discountType==="percent"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Percent Off"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",min:"1",max:"100",placeholder:"20",value:u.percentOff,onChange:j=>p({...u,percentOff:j.target.value})}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Amount Off (USD)"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"$"}),e.jsx(Re,{type:"number",min:"1",placeholder:"10.00",className:"pl-7",value:u.amountOff,onChange:j=>p({...u,amountOff:j.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Duration"}),e.jsxs(sr,{value:u.duration,onValueChange:j=>p({...u,duration:j}),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"once",children:"Once (first payment only)"}),e.jsx(At,{value:"repeating",children:"Multiple months"}),e.jsxs(At,{value:"forever",disabled:u.discountType==="amount",children:["Forever ",u.discountType==="amount"&&"(% discounts only)"]})]})]}),u.discountType==="amount"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:'Note: "Forever" duration is only available for percentage-based discounts.'})]}),u.duration==="repeating"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Number of Months"}),e.jsx(Re,{type:"number",min:"1",placeholder:"3",value:u.durationInMonths,onChange:j=>p({...u,durationInMonths:j.target.value})})]}),e.jsx(K,{onClick:y,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Coupon"})]})]})]})}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Active Coupons"}),e.jsx(pr,{children:"Share coupon codes with users to give them discounts on subscriptions"})]}),e.jsx(Oe,{children:n?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Ms,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):s.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No coupons created yet. Create your first coupon to get started."}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Promo Code"}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Discount"}),e.jsx(bt,{children:"Duration"}),e.jsx(bt,{children:"Redemptions"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:s.map(j=>{var k;return e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-mono font-medium",children:((k=j.promotion_codes)==null?void 0:k.length)>0?j.promotion_codes.join(", "):e.jsx("span",{className:"text-muted-foreground text-xs",children:"No promo code"})}),e.jsx(lt,{children:j.name||"-"}),e.jsx(lt,{children:b(j)}),e.jsx(lt,{children:w(j)}),e.jsx(lt,{children:j.times_redeemed}),e.jsx(lt,{children:e.jsx(rt,{variant:j.valid?"default":"secondary",children:j.valid?"Active":"Inactive"})}),e.jsx(lt,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>_(j.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})})]},j.id)})})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"How to Use Coupons"})}),e.jsxs(Oe,{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:"1. Create a coupon above with your desired discount."}),e.jsx("p",{children:'2. Share the coupon code (shown in the "Code" column) with users.'}),e.jsx("p",{children:"3. Users can enter the code during checkout to receive the discount."}),e.jsx("p",{children:"4. Alternatively, you can create a promotion code in Stripe dashboard for public-facing promotions."})]})]})]})})}const Lpe={prod_Tc07cYplXUGNkm:{name:"Individual Agent",price:"$39/mo",type:"individual"},prod_Tc08MupgoVySDG:{name:"Brokerage (Under 25)",price:"$299/mo",type:"brokerage"},prod_Tc09N1tJ4RrAFn:{name:"Brokerage (Over 25)",price:"$499/mo",type:"brokerage"}};function Vhs(){const[t,s]=C.useState(""),[r,n]=C.useState("all"),[a,o]=C.useState(null),{data:l,isLoading:i,refetch:d}=wt({queryKey:["admin-subscriptions"],queryFn:async()=>{const{data:b,error:w}=await G.from("profiles").select(` *, brokerages:brokerage_id (id, name) `).order("created_at",{ascending:!1});if(w)throw w;return b}}),{data:u}=wt({queryKey:["admin-brokerages-subscriptions"],queryFn:async()=>{const{data:b,error:w}=await G.from("brokerages").select("*").order("name");if(w)throw w;return await Promise.all((b||[]).map(async k=>{const{data:S}=await G.from("profiles").select("id, name, email, subscription_status, subscription_product_id").eq("brokerage_id",k.id),{data:T}=await G.from("user_roles").select("user_id").eq("role","brokerage_manager"),I=(T==null?void 0:T.map($=>$.user_id))||[],L=(S==null?void 0:S.filter($=>I.includes($.id)))||[],R=(S==null?void 0:S.length)||0;return{...k,managers:L,agentCount:R}}))}}),p=b=>{if(b.is_grandfathered)return{status:"Grandfathered",badge:"Legacy",variant:"secondary"};if(b.brokerage_id&&!b.subscription_product_id)return{status:"Brokerage",badge:"Team Member",variant:"outline"};if(b.is_trial&&b.trial_expires_at)return new Date(b.trial_expires_at)>new Date?{status:"Trial",badge:"Active Trial",variant:"default"}:{status:"Trial Expired",badge:"Expired",variant:"destructive"};if(b.subscription_status==="active"||b.subscription_status==="trialing"){const w=Lpe[b.subscription_product_id];return{status:(w==null?void 0:w.name)||"Active",badge:b.subscription_status==="trialing"?"Trial":"Active",variant:"default"}}return b.subscription_status==="canceled"||b.subscription_status==="past_due"?{status:"Canceled",badge:"Inactive",variant:"destructive"}:{status:"None",badge:"No Subscription",variant:"outline"}},f=l==null?void 0:l.filter(b=>{var j,k;if(!(((j=b.name)==null?void 0:j.toLowerCase().includes(t.toLowerCase()))||((k=b.email)==null?void 0:k.toLowerCase().includes(t.toLowerCase()))))return!1;switch(p(b),r){case"active":return b.subscription_status==="active";case"trialing":return b.subscription_status==="trialing"||b.is_trial&&new Date(b.trial_expires_at)>new Date;case"grandfathered":return b.is_grandfathered;case"brokerage":return b.brokerage_id&&!b.subscription_product_id&&!b.is_grandfathered;case"expired":return b.subscription_status==="canceled"||b.subscription_status==="past_due"||b.is_trial&&new Date(b.trial_expires_at)<=new Date;case"none":return!b.subscription_status||b.subscription_status==="none";default:return!0}}),y={totalUsers:(l==null?void 0:l.length)||0,activeSubscriptions:(l==null?void 0:l.filter(b=>b.subscription_status==="active").length)||0,trials:(l==null?void 0:l.filter(b=>b.subscription_status==="trialing"||b.is_trial&&new Date(b.trial_expires_at)>new Date).length)||0,grandfathered:(l==null?void 0:l.filter(b=>b.is_grandfathered).length)||0,brokerageMembers:(l==null?void 0:l.filter(b=>b.brokerage_id&&!b.subscription_product_id&&!b.is_grandfathered).length)||0,individualSubscribers:(l==null?void 0:l.filter(b=>b.subscription_status==="active"&&b.subscription_product_id==="prod_Tc07cYplXUGNkm").length)||0,brokerageSubscribers:(l==null?void 0:l.filter(b=>b.subscription_status==="active"&&(b.subscription_product_id==="prod_Tc08MupgoVySDG"||b.subscription_product_id==="prod_Tc09N1tJ4RrAFn")).length)||0},_=b=>{window.open(`https://dashboard.stripe.com/customers/${b}`,"_blank")};return e.jsx(Ts,{title:"Subscription Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(wu,{title:"Subscription Management",description:"Track and manage all subscriptions",children:e.jsxs(K,{onClick:()=>d(),variant:"outline",size:"sm",children:[e.jsx(Po,{className:"h-4 w-4 mr-2"}),"Refresh"]})}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Users"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:y.totalUsers})]})}),e.jsx(Ee,{className:"border-green-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yf,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Active Paid"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-green-600",children:y.activeSubscriptions})]})}),e.jsx(Ee,{className:"border-blue-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Trials"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-blue-600",children:y.trials})]})}),e.jsx(Ee,{className:"border-purple-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Uh,{className:"h-4 w-4 text-purple-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Grandfathered"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-purple-600",children:y.grandfathered})]})}),e.jsx(Ee,{className:"border-orange-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage Members"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-orange-600",children:y.brokerageMembers})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p_,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Individual"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:y.individualSubscribers})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage Subs"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:y.brokerageSubscribers})]})})]}),e.jsxs(ka,{defaultValue:"users",className:"space-y-4",children:[e.jsxs(_a,{children:[e.jsx(js,{value:"users",children:"All Users"}),e.jsx(js,{value:"brokerages",children:"Brokerages"})]}),e.jsxs(zs,{value:"users",className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name or email...",value:t,onChange:b=>s(b.target.value),className:"pl-9"})]}),e.jsxs(sr,{value:r,onValueChange:b=>n(b),children:[e.jsx(er,{className:"w-[200px]",children:e.jsx(rr,{placeholder:"Filter by status"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Users"}),e.jsx(At,{value:"active",children:"Active Subscriptions"}),e.jsx(At,{value:"trialing",children:"Trials"}),e.jsx(At,{value:"grandfathered",children:"Grandfathered"}),e.jsx(At,{value:"brokerage",children:"Brokerage Members"}),e.jsx(At,{value:"expired",children:"Expired/Canceled"}),e.jsx(At,{value:"none",children:"No Subscription"})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"User"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{children:"Plan"}),e.jsx(bt,{children:"Brokerage"}),e.jsx(bt,{children:"End Date"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:i?e.jsx(Ns,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8",children:"Loading subscriptions..."})}):(f==null?void 0:f.length)===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No users found"})}):f==null?void 0:f.map(b=>{var k,S;const w=p(b),j=Lpe[b.subscription_product_id];return e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:b.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:b.email})]})}),e.jsx(lt,{children:e.jsx(rt,{variant:w.variant,children:w.badge})}),e.jsx(lt,{children:e.jsx("span",{className:"text-sm",children:b.is_grandfathered?"Legacy Access":b.brokerage_id&&!b.subscription_product_id?"Brokerage Subscription":(j==null?void 0:j.name)||w.status})}),e.jsx(lt,{children:(k=b.brokerages)!=null&&k.name?e.jsx("span",{className:"text-sm",children:b.brokerages.name}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(lt,{children:b.subscription_end_date?e.jsx("span",{className:"text-sm",children:ys(new Date(b.subscription_end_date),"MMM d, yyyy")}):b.trial_expires_at?e.jsxs("span",{className:"text-sm text-blue-600",children:["Trial: ",ys(new Date(b.trial_expires_at),"MMM d, yyyy")]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[b.stripe_customer_id&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>_(b.stripe_customer_id),children:e.jsx(sn,{className:"h-4 w-4"})}),e.jsxs(_s,{children:[e.jsx(Ei,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",onClick:()=>o(b),children:"Details"})}),e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Subscription Details"}),e.jsxs(Kr,{children:[b.name," (",b.email,")"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Status"}),e.jsx(rt,{variant:w.variant,className:"mt-1",children:w.badge})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Plan"}),e.jsx("p",{className:"font-medium",children:b.is_grandfathered?"Grandfathered (Legacy)":b.brokerage_id&&!b.subscription_product_id?"Brokerage Subscription":(j==null?void 0:j.name)||"None"})]}),b.brokerage_id&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Brokerage"}),e.jsx("p",{className:"font-medium",children:((S=b.brokerages)==null?void 0:S.name)||"Unknown"})]}),b.subscription_end_date&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Current Period End"}),e.jsx("p",{className:"font-medium",children:ys(new Date(b.subscription_end_date),"MMMM d, yyyy")})]}),b.trial_expires_at&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Trial Expires"}),e.jsx("p",{className:"font-medium",children:ys(new Date(b.trial_expires_at),"MMMM d, yyyy")})]}),b.stripe_customer_id&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Stripe Customer ID"}),e.jsx("p",{className:"font-mono text-sm",children:b.stripe_customer_id})]})]}),b.stripe_customer_id&&e.jsxs(K,{className:"w-full",onClick:()=>_(b.stripe_customer_id),children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"View in Stripe Dashboard"]})]})]})]})]})})]},b.id)})})]})})})]}),e.jsx(zs,{value:"brokerages",className:"space-y-4",children:e.jsx("div",{className:"grid gap-4",children:u==null?void 0:u.map(b=>{var j,k;const w=(j=b.managers)==null?void 0:j.some(S=>S.subscription_status==="active"&&(S.subscription_product_id==="prod_Tc08MupgoVySDG"||S.subscription_product_id==="prod_Tc09N1tJ4RrAFn"));return e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(Ta,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:b.name}),e.jsxs(pr,{children:[b.agentCount," agents"]})]})]}),e.jsx(rt,{variant:w?"default":"outline",children:w?"Active Subscription":"No Active Subscription"})]})}),e.jsx(Oe,{children:((k=b.managers)==null?void 0:k.length)>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Managers:"}),b.managers.map(S=>{const T=Lpe[S.subscription_product_id];return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.email})]}),e.jsx("div",{className:"text-right",children:T?e.jsxs("div",{children:[e.jsx(rt,{variant:"default",children:T.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:T.price})]}):e.jsx(rt,{variant:"outline",children:"No Subscription"})})]},S.id)})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No managers assigned"})})]},b.id)})})})]})]})})}function Hhs(){const[t,s]=C.useState([]),[r,n]=C.useState(!0),[a,o]=C.useState(""),[l,i]=C.useState("all"),[d,u]=C.useState({total:0,qualified:0,pending:0,cancelled:0,totalDiscounts:0});C.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:b,error:w}=await G.from("referrals").select(` *, referrer_brokerage:brokerages!referrer_brokerage_id(name), referred_brokerage:brokerages!referred_brokerage_id(name), referred_user:profiles!referred_user_id(name, email) `).order("created_at",{ascending:!1});if(w)throw w;s(b||[]);const j=(b==null?void 0:b.filter(T=>T.status==="qualified").length)||0,k=(b==null?void 0:b.filter(T=>T.status==="pending").length)||0,S=(b==null?void 0:b.filter(T=>T.status==="cancelled").length)||0;u({total:(b==null?void 0:b.length)||0,qualified:j,pending:k,cancelled:S,totalDiscounts:j*25})}catch(b){console.error("Error fetching referrals:",b),fe.error("Failed to load referrals")}finally{n(!1)}},f=async()=>{try{fe.loading("Processing qualifications...");const{error:b}=await G.functions.invoke("process-referral-qualifications");if(b)throw b;fe.dismiss(),fe.success("Qualifications processed successfully"),p()}catch(b){fe.dismiss(),console.error("Error processing qualifications:",b),fe.error("Failed to process qualifications")}},y=t.filter(b=>{var k,S,T,I,L,R;const w=((S=(k=b.referrer_brokerage)==null?void 0:k.name)==null?void 0:S.toLowerCase().includes(a.toLowerCase()))||((I=(T=b.referred_brokerage)==null?void 0:T.name)==null?void 0:I.toLowerCase().includes(a.toLowerCase()))||((R=(L=b.referred_user)==null?void 0:L.email)==null?void 0:R.toLowerCase().includes(a.toLowerCase())),j=l==="all"||b.status===l;return w&&j}),_=b=>{switch(b){case"qualified":return e.jsxs(rt,{className:"bg-green-100 text-green-800",children:[e.jsx(hi,{className:"h-3 w-3 mr-1"}),"Qualified"]});case"pending":return e.jsxs(rt,{variant:"secondary",children:[e.jsx(Tn,{className:"h-3 w-3 mr-1"}),"Pending"]});case"cancelled":return e.jsxs(rt,{variant:"destructive",children:[e.jsx(kc,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return e.jsx(rt,{children:b})}};return e.jsx(Ts,{title:"Referral Program",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(wu,{title:"Referral Program",description:"Track and manage brokerage referrals",children:e.jsxs(K,{onClick:f,variant:"outline",children:[e.jsx(Po,{className:"h-4 w-4 mr-2"}),"Process Qualifications"]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Referrals"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hi,{className:"h-5 w-5 text-green-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.qualified}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-5 w-5 text-amber-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.pending}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Pending"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(kc,{className:"h-5 w-5 text-red-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.cancelled}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Cancelled"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(od,{className:"h-5 w-5 text-green-600"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:["$",d.totalDiscounts]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Discounts"})]})]})})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"All Referrals"}),e.jsx(pr,{children:"View and manage all referral relationships"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by brokerage or email...",value:a,onChange:b=>o(b.target.value),className:"pl-10"})]}),e.jsxs(sr,{value:l,onValueChange:i,children:[e.jsx(er,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"Filter by status"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Statuses"}),e.jsx(At,{value:"pending",children:"Pending"}),e.jsx(At,{value:"qualified",children:"Qualified"}),e.jsx(At,{value:"cancelled",children:"Cancelled"})]})]})]}),r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Referrer"}),e.jsx(bt,{children:"Referred"}),e.jsx(bt,{children:"Signup Date"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{children:"Qualified Date"}),e.jsx(bt,{children:"Discount"})]})}),e.jsx(Pn,{children:y.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No referrals found"})}):y.map(b=>{var w,j,k,S;return e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium",children:((w=b.referrer_brokerage)==null?void 0:w.name)||"Unknown"}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{children:((j=b.referred_brokerage)==null?void 0:j.name)||((k=b.referred_user)==null?void 0:k.name)||"Pending setup"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(S=b.referred_user)==null?void 0:S.email})]})}),e.jsx(lt,{children:ys(new Date(b.signup_date),"MMM d, yyyy")}),e.jsx(lt,{children:_(b.status)}),e.jsx(lt,{children:b.qualified_date?ys(new Date(b.qualified_date),"MMM d, yyyy"):"-"}),e.jsx(lt,{children:b.discount_applied?e.jsx(rt,{variant:"outline",className:"text-green-600",children:"$25/mo applied"}):e.jsx("span",{className:"text-muted-foreground",children:"-"})})]},b.id)})})]})]})]})]})})}const Dpe=[{value:"add_agent",label:"Add Agent"},{value:"share_resource",label:"Share Resource"},{value:"post_community",label:"Post in Community"},{value:"register_event",label:"Register for Event"},{value:"view_template",label:"View Template"},{value:"watch_academy",label:"Watch Academy Video"},{value:"use_toolbox",label:"Use Toolbox"},{value:"launch_app",label:"Launch App"},{value:"add_contact",label:"Add Contact"},{value:"add_plan",label:"Add Touchpoint Plan"},{value:"create_video",label:"Create Video"},{value:"complete_touch",label:"Complete Touch"},{value:"add_transaction",label:"Add Transaction"},{value:"add_listing",label:"Add Listing"},{value:"schedule_popby",label:"Schedule Pop-by"}],Whs=[{value:"brokerage_manager",label:"Brokerage Manager"},{value:"agent",label:"Agent"}];function Ghs(){const[t,s]=C.useState([]),[r,n]=C.useState(!0),[a,o]=C.useState(!1),[l,i]=C.useState(null),[d,u]=C.useState({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0});C.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:S,error:T}=await G.from("onboarding_checklist_items").select("*").order("target_role").order("sort_order");if(T)throw T;s(S||[])}catch(S){console.error("Error fetching checklist items:",S),fe.error("Failed to load checklist items")}finally{n(!1)}},f=()=>{i(null),u({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0}),o(!0)},y=S=>{i(S),u({title:S.title,description:S.description||"",action_type:S.action_type,target_role:S.target_role,is_active:S.is_active}),o(!0)},_=async()=>{if(!d.title.trim()){fe.error("Title is required");return}try{if(l){const{error:S}=await G.from("onboarding_checklist_items").update({title:d.title,description:d.description||null,action_type:d.action_type,target_role:d.target_role,is_active:d.is_active}).eq("id",l.id);if(S)throw S;fe.success("Checklist item updated")}else{const S=t.filter(I=>I.target_role===d.target_role).reduce((I,L)=>Math.max(I,L.sort_order),-1),{error:T}=await G.from("onboarding_checklist_items").insert({title:d.title,description:d.description||null,action_type:d.action_type,target_role:d.target_role,is_active:d.is_active,sort_order:S+1});if(T)throw T;fe.success("Checklist item created")}o(!1),p()}catch(S){console.error("Error saving checklist item:",S),fe.error("Failed to save checklist item")}},b=async S=>{if(confirm("Are you sure you want to delete this checklist item?"))try{const{error:T}=await G.from("onboarding_checklist_items").delete().eq("id",S);if(T)throw T;fe.success("Checklist item deleted"),p()}catch(T){console.error("Error deleting checklist item:",T),fe.error("Failed to delete checklist item")}},w=async S=>{try{const{error:T}=await G.from("onboarding_checklist_items").update({is_active:!S.is_active}).eq("id",S.id);if(T)throw T;fe.success(S.is_active?"Item deactivated":"Item activated"),p()}catch(T){console.error("Error toggling item:",T),fe.error("Failed to update item")}},j=t.filter(S=>S.target_role==="brokerage_manager"),k=t.filter(S=>S.target_role==="agent");return e.jsxs(Ts,{title:"Onboarding Checklist",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Onboarding Checklist"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage checklist items shown to new users on their dashboard"})]}),e.jsxs(K,{onClick:f,className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Item"]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(rt,{variant:"secondary",children:"Brokerage Manager"}),"Checklist Items"]})}),e.jsx(Oe,{children:j.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for brokerage managers"}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{className:"w-12",children:"#"}),e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Action Type"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:j.map((S,T)=>{var I;return e.jsxs(Ns,{children:[e.jsx(lt,{className:"text-muted-foreground",children:T+1}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.title}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:S.description})]})}),e.jsx(lt,{children:e.jsx(rt,{variant:"outline",children:((I=Dpe.find(L=>L.value===S.action_type))==null?void 0:I.label)||S.action_type})}),e.jsx(lt,{children:e.jsx(Br,{checked:S.is_active,onCheckedChange:()=>w(S)})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>y(S),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(S.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},S.id)})})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(rt,{variant:"secondary",children:"Agent"}),"Checklist Items"]})}),e.jsx(Oe,{children:k.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for agents"}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{className:"w-12",children:"#"}),e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Action Type"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:k.map((S,T)=>{var I;return e.jsxs(Ns,{children:[e.jsx(lt,{className:"text-muted-foreground",children:T+1}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.title}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:S.description})]})}),e.jsx(lt,{children:e.jsx(rt,{variant:"outline",children:((I=Dpe.find(L=>L.value===S.action_type))==null?void 0:I.label)||S.action_type})}),e.jsx(lt,{children:e.jsx(Br,{checked:S.is_active,onCheckedChange:()=>w(S)})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>y(S),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(S.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},S.id)})})]})})]})]}),e.jsx(_s,{open:a,onOpenChange:o,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:l?"Edit Checklist Item":"Add Checklist Item"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title *"}),e.jsx(Re,{id:"title",value:d.title,onChange:S=>u({...d,title:S.target.value}),placeholder:"e.g., Watch your first academy video"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",value:d.description,onChange:S=>u({...d,description:S.target.value}),placeholder:"Optional description for the checklist item",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Target Role"}),e.jsxs(sr,{value:d.target_role,onValueChange:S=>u({...d,target_role:S}),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:Whs.map(S=>e.jsx(At,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Action Type"}),e.jsxs(sr,{value:d.action_type,onValueChange:S=>u({...d,action_type:S}),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:Dpe.map(S=>e.jsx(At,{value:S.value,children:S.label},S.value))})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"is_active",checked:d.is_active,onCheckedChange:S=>u({...d,is_active:S})}),e.jsx(ve,{htmlFor:"is_active",children:"Active"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{onClick:_,children:l?"Save Changes":"Create Item"})]})]})})]})}function Khs(){const[t,s]=C.useState(""),[r,n]=C.useState("all"),[a,o]=C.useState("name"),[l,i]=C.useState("asc"),[d,u]=C.useState(""),[p,f]=C.useState(""),[y,_]=C.useState(""),[b,w]=C.useState(""),{data:j}=wt({queryKey:["admin-brokerages"],queryFn:async()=>{const{data:H,error:Y}=await G.from("brokerages").select("id, name").order("name");if(Y)throw Y;return H}}),k=async H=>{let se=[],te=0,Q=!0;for(;Q;){const{data:de,error:re}=await H(te,te+1e3-1);if(re)throw re;de&&de.length>0?(se=[...se,...de],te+=1e3,Q=de.length===1e3):Q=!1}return se},{data:S,isLoading:T}=wt({queryKey:["admin-agent-os-user-stats"],queryFn:async()=>{const H=await k((Fe,Ae)=>G.from("profiles").select("id, name, email, brokerage_id, created_at").range(Fe,Ae)),{data:Y}=await G.from("brokerages").select("id, name"),se=new Map((Y==null?void 0:Y.map(Fe=>[Fe.id,Fe.name]))||[]),[{data:te},{data:Q},{data:de},{data:re},{data:ae},{data:le},{data:he}]=await Promise.all([G.rpc("get_admin_contact_counts"),G.rpc("get_admin_video_counts"),G.rpc("get_admin_popby_counts"),G.rpc("get_admin_listing_counts"),G.rpc("get_admin_deal_counts"),G.rpc("get_admin_portal_counts"),G.rpc("get_admin_sendable_card_counts")]),be=new Map;te==null||te.forEach(Fe=>be.set(Fe.owner_user_id,Fe.contact_count));const _e=new Map;Q==null||Q.forEach(Fe=>_e.set(Fe.owner_user_id,Fe.video_count));const je=new Map;de==null||de.forEach(Fe=>je.set(Fe.owner_user_id,Fe.popby_count));const Ne=new Map;re==null||re.forEach(Fe=>Ne.set(Fe.agent_id,Fe.listing_count));const Ge=new Map;ae==null||ae.forEach(Fe=>Ge.set(Fe.owner_user_id,Fe.deal_count));const we=new Map;le==null||le.forEach(Fe=>we.set(Fe.owner_user_id,{total:Fe.portal_count,active:Fe.active_portal_count}));const Me=new Map;return he==null||he.forEach(Fe=>Me.set(Fe.owner_user_id,{total:Fe.card_count,sent:Fe.sent_card_count,views:Fe.total_card_views})),H.map(Fe=>{const Ae=we.get(Fe.id),Ue=Me.get(Fe.id);return{id:Fe.id,name:Fe.name||"Unknown",email:Fe.email||"",brokerage_id:Fe.brokerage_id,brokerage_name:Fe.brokerage_id&&se.get(Fe.brokerage_id)||null,contact_count:be.get(Fe.id)||0,video_count:_e.get(Fe.id)||0,popby_count:je.get(Fe.id)||0,listing_count:Ne.get(Fe.id)||0,deal_count:Ge.get(Fe.id)||0,portal_count:(Ae==null?void 0:Ae.total)||0,active_portal_count:(Ae==null?void 0:Ae.active)||0,card_count:(Ue==null?void 0:Ue.total)||0,sent_card_count:(Ue==null?void 0:Ue.sent)||0,total_card_views:(Ue==null?void 0:Ue.views)||0,created_at:Fe.created_at}})}}),I=C.useMemo(()=>{if(!S)return[];let H=S.filter(Y=>{const se=t.toLowerCase(),te=!t||Y.name.toLowerCase().includes(se)||Y.email.toLowerCase().includes(se),Q=r==="all"||r==="none"&&!Y.brokerage_id||Y.brokerage_id===r,de=parseInt(d)||0,re=parseInt(p)||0,ae=parseInt(y)||0,le=parseInt(b)||0,he=Y.contact_count>=de&&Y.video_count>=re&&Y.popby_count>=ae&&Y.listing_count>=le;return te&&Q&&he});return H.sort((Y,se)=>{let te=0;return a==="name"?te=Y.name.localeCompare(se.name):te=Y[a]-se[a],l==="asc"?te:-te}),H},[S,t,r,a,l,d,p,y,b]),L=H=>{a===H?i(l==="asc"?"desc":"asc"):(o(H),i("desc"))},R=()=>{const H=["Name","Email","Brokerage","Contacts","Videos","Popbys","Listings","Deals","Portals (Active)","Cards Created","Cards Sent","Card Views"],Y=I.map(re=>[re.name,re.email,re.brokerage_name||"None",re.contact_count,re.video_count,re.popby_count,re.listing_count,re.deal_count,`${re.portal_count} (${re.active_portal_count})`,re.card_count,re.sent_card_count,re.total_card_views]),se=[H.join(","),...Y.map(re=>re.map(ae=>`"${ae}"`).join(","))].join(` `),te=new Blob([se],{type:"text/csv"}),Q=URL.createObjectURL(te),de=document.createElement("a");de.href=Q,de.download=`agent-os-user-stats-${new Date().toISOString().split("T")[0]}.csv`,de.click(),URL.revokeObjectURL(Q)},$=C.useMemo(()=>I.length?I.reduce((H,Y)=>({contacts:H.contacts+Y.contact_count,videos:H.videos+Y.video_count,popbys:H.popbys+Y.popby_count,listings:H.listings+Y.listing_count,deals:H.deals+Y.deal_count,portals:H.portals+Y.portal_count,activePortals:H.activePortals+Y.active_portal_count,cards:H.cards+Y.card_count,sentCards:H.sentCards+Y.sent_card_count,cardViews:H.cardViews+Y.total_card_views}),{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0}):{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0},[I]),q=C.useMemo(()=>I.length?{portals:I.filter(H=>H.portal_count>0).length,cards:I.filter(H=>H.card_count>0).length}:{portals:0,cards:0},[I]),U=({field:H,children:Y})=>e.jsx(bt,{className:"cursor-pointer hover:bg-muted/50 select-none",onClick:()=>L(H),children:e.jsxs("div",{className:"flex items-center gap-1",children:[Y,e.jsx(Hc,{className:`h-3 w-3 ${a===H?"text-primary":"text-muted-foreground"}`})]})});return e.jsx(U_,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ee,{className:"border-blue-500/20 bg-gradient-to-br from-blue-500/5 to-transparent",children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(P0,{className:"h-4 w-4 text-blue-500"}),"Client Portals"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:q.portals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Agents Using"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:$.portals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Portals"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-600",children:$.activePortals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Active Portals"})]})]})})]}),e.jsxs(Ee,{className:"border-violet-500/20 bg-gradient-to-br from-violet-500/5 to-transparent",children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(br,{className:"h-4 w-4 text-violet-500"}),"Card Studio"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-4 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:q.cards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Agents Using"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:$.cards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Cards Created"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-600",children:$.sentCards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Cards Sent"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-blue-600",children:$.cardViews}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Views"})]})]})})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"User Activity Analytics"]}),e.jsx(pr,{children:"View all users and their Agent OS usage metrics"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:R,children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Export CSV"]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-6",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name or email...",value:t,onChange:H=>s(H.target.value),className:"pl-9"})]})}),e.jsx("div",{children:e.jsxs(sr,{value:r,onValueChange:n,children:[e.jsxs(er,{children:[e.jsx(Ta,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(rr,{placeholder:"Brokerage"})]}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Brokerages"}),e.jsx(At,{value:"none",children:"No Brokerage"}),j==null?void 0:j.map(H=>e.jsx(At,{value:H.id,children:H.name},H.id))]})]})}),e.jsx("div",{children:e.jsx(Re,{type:"number",placeholder:"Min contacts",value:d,onChange:H=>u(H.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(Re,{type:"number",placeholder:"Min videos",value:p,onChange:H=>f(H.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(Re,{type:"number",placeholder:"Min popbys",value:y,onChange:H=>_(H.target.value),min:"0"})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-8 text-sm",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:I.length}),e.jsx("div",{className:"text-muted-foreground",children:"Users"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.contacts.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Contacts"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.videos.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Videos"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.popbys.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Popbys"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.listings.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Listings"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.deals.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Deals"})]}),e.jsxs("div",{className:"bg-blue-500/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.portals.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Portals"})]}),e.jsxs("div",{className:"bg-violet-500/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.cards.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Cards"})]})]}),T?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(Ms,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(U,{field:"name",children:"Name"}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:"Brokerage"}),e.jsx(U,{field:"contact_count",children:"Contacts"}),e.jsx(U,{field:"video_count",children:"Videos"}),e.jsx(U,{field:"popby_count",children:"Popbys"}),e.jsx(U,{field:"listing_count",children:"Listings"}),e.jsx(U,{field:"deal_count",children:"Deals"}),e.jsx(U,{field:"portal_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(P0,{className:"h-3 w-3 text-blue-500"}),"Portals"]})}),e.jsx(U,{field:"card_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(br,{className:"h-3 w-3 text-violet-500"}),"Cards"]})})]})}),e.jsx(Pn,{children:I.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No users found matching your filters"})}):I.map(H=>e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium",children:H.name}),e.jsx(lt,{className:"text-muted-foreground",children:H.email}),e.jsx(lt,{children:H.brokerage_name?e.jsx(rt,{variant:"secondary",children:H.brokerage_name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(lt,{children:e.jsx(rt,{variant:H.contact_count>0?"default":"outline",children:H.contact_count})}),e.jsx(lt,{children:e.jsx(rt,{variant:H.video_count>0?"default":"outline",children:H.video_count})}),e.jsx(lt,{children:e.jsx(rt,{variant:H.popby_count>0?"default":"outline",children:H.popby_count})}),e.jsx(lt,{children:e.jsx(rt,{variant:H.listing_count>0?"default":"outline",children:H.listing_count})}),e.jsx(lt,{children:e.jsx(rt,{variant:H.deal_count>0?"default":"outline",children:H.deal_count})}),e.jsx(lt,{children:H.portal_count>0?e.jsxs(Wc,{children:[e.jsx(Gc,{children:e.jsxs(rt,{variant:"default",className:"bg-blue-600 hover:bg-blue-700",children:[H.portal_count,H.active_portal_count>0&&e.jsxs("span",{className:"ml-1 opacity-75",children:["(",H.active_portal_count," active)"]})]})}),e.jsxs(Cc,{children:[e.jsxs("p",{children:[H.portal_count," total portals"]}),e.jsxs("p",{children:[H.active_portal_count," currently active"]})]})]}):e.jsx(rt,{variant:"outline",children:"0"})}),e.jsx(lt,{children:H.card_count>0?e.jsxs(Wc,{children:[e.jsx(Gc,{children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(rt,{variant:"default",className:"bg-violet-600 hover:bg-violet-700",children:H.card_count}),H.sent_card_count>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-emerald-600",children:[e.jsx(aa,{className:"h-3 w-3"}),H.sent_card_count]}),H.total_card_views>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[e.jsx(xa,{className:"h-3 w-3"}),H.total_card_views]})]})}),e.jsxs(Cc,{children:[e.jsxs("p",{children:[H.card_count," cards created"]}),e.jsxs("p",{children:[H.sent_card_count," sent"]}),e.jsxs("p",{children:[H.total_card_views," total views"]})]})]}):e.jsx(rt,{variant:"outline",children:"0"})})]},H.id))})]})})]})]})]})})}function Zhs(){Pa(),rs();const[t,s]=C.useState("user-analytics"),{data:r}=wt({queryKey:["admin-feature-flags"],queryFn:async()=>{const{data:_,error:b}=await G.from("feature_flags").select("*").order("key");if(b)throw b;return _}}),{data:n,isLoading:a}=wt({queryKey:["admin-relationship-types"],queryFn:async()=>{const{data:_,error:b}=await G.from("relationship_types").select("*").order("sort_order");if(b)throw b;return _}}),{data:o,isLoading:l}=wt({queryKey:["admin-action-types"],queryFn:async()=>{const{data:_,error:b}=await G.from("action_types").select("*").order("sort_order");if(b)throw b;return _}}),{data:i,isLoading:d}=wt({queryKey:["admin-action-scripts"],queryFn:async()=>{const{data:_,error:b}=await G.from("action_scripts").select("*, action_type:action_types(*)");if(b)throw b;return _}}),{data:u,isLoading:p}=wt({queryKey:["admin-touchpoint-plans"],queryFn:async()=>{const{data:_,error:b}=await G.from("touchpoint_plans").select("*").order("name");if(b)throw b;return _}}),{data:f,isLoading:y}=wt({queryKey:["admin-popby-items"],queryFn:async()=>{const{data:_,error:b}=await G.from("popby_items").select("*").is("owner_user_id",null).order("name");if(b)throw b;return _}});return e.jsx(Ts,{title:"Agent OS Control Center",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(wu,{title:"Agent OS Control Center",description:"Manage InnerCircle settings, scripts, and touchpoint plans"}),e.jsxs(ka,{value:t,onValueChange:s,children:[e.jsxs(_a,{className:"grid w-full grid-cols-9",children:[e.jsxs(js,{value:"user-analytics",className:"gap-2",children:[e.jsx(ol,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Users"})]}),e.jsxs(js,{value:"relationship-types",className:"gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Relationships"})]}),e.jsxs(js,{value:"action-types",className:"gap-2",children:[e.jsx(Qn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Actions"})]}),e.jsxs(js,{value:"scripts",className:"gap-2",children:[e.jsx(In,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Scripts"})]}),e.jsxs(js,{value:"video-scripts",className:"gap-2",children:[e.jsx(lu,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Video Scripts"})]}),e.jsxs(js,{value:"plans",className:"gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Plans"})]}),e.jsxs(js,{value:"popbys",className:"gap-2",children:[e.jsx(po,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Popbys"})]}),e.jsxs(js,{value:"settings",className:"gap-2",children:[e.jsx($l,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Settings"})]}),e.jsxs(js,{value:"feature-flags",className:"gap-2",children:[e.jsx(L0,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Flags"})]})]}),e.jsx(zs,{value:"user-analytics",className:"mt-6",children:e.jsx(Khs,{})}),e.jsx(zs,{value:"relationship-types",className:"mt-6",children:e.jsx(Yhs,{types:n||[],isLoading:a})}),e.jsx(zs,{value:"action-types",className:"mt-6",children:e.jsx(Xhs,{types:o||[],isLoading:l})}),e.jsx(zs,{value:"scripts",className:"mt-6",children:e.jsx(Qhs,{scripts:i||[],actionTypes:o||[],isLoading:d})}),e.jsx(zs,{value:"video-scripts",className:"mt-6",children:e.jsx(sms,{})}),e.jsx(zs,{value:"plans",className:"mt-6",children:e.jsx(Jhs,{plans:u||[],actionTypes:o||[],scripts:i||[],isLoading:p})}),e.jsx(zs,{value:"popbys",className:"mt-6",children:e.jsx(tms,{items:f||[],isLoading:y})}),e.jsx(zs,{value:"settings",className:"mt-6",children:e.jsx(rms,{})}),e.jsx(zs,{value:"feature-flags",className:"mt-6",children:e.jsx(ems,{flags:r||[]})})]})]})})}function Yhs({types:t,isLoading:s}){const{toast:r}=Pa(),n=rs(),[a,o]=C.useState(null),[l,i]=C.useState(!1),d=Dt({mutationFn:async p=>{if(p.id){const{error:f}=await G.from("relationship_types").update({name:p.name,description:p.description,icon:p.icon}).eq("id",p.id);if(f)throw f}else{const{error:f}=await G.from("relationship_types").insert([{name:p.name,description:p.description,icon:p.icon,sort_order:t.length}]);if(f)throw f}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-relationship-types"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:p=>{r({title:"Error",description:p.message,variant:"destructive"})}}),u=async p=>{await G.from("relationship_types").update({active:!p.active}).eq("id",p.id),n.invalidateQueries({queryKey:["admin-relationship-types"]})};return e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Relationship Types"}),e.jsx(pr,{children:"Define the relationship categories for InnerCircle contacts"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Type"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ms,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{className:"w-12"}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(p=>e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsx(Bu,{className:"h-4 w-4 text-muted-foreground cursor-grab"})}),e.jsx(lt,{className:"font-medium",children:p.name}),e.jsx(lt,{className:"text-muted-foreground",children:p.description}),e.jsx(lt,{children:e.jsx(Br,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(lt,{children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:e.jsx(Da,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(_s,{open:l,onOpenChange:i,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsxs(ks,{children:[a?"Edit":"Add"," Relationship Type"]})}),e.jsxs("form",{onSubmit:p=>{p.preventDefault();const f=new FormData(p.currentTarget);d.mutate({id:a==null?void 0:a.id,name:f.get("name"),description:f.get("description"),icon:f.get("icon")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"icon",children:"Icon"}),e.jsx(Re,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., star, heart, user"})]})]}),e.jsxs(Un,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Xhs({types:t,isLoading:s}){const{toast:r}=Pa(),n=rs(),[a,o]=C.useState(null),[l,i]=C.useState(!1),d=Dt({mutationFn:async p=>{if(p.id){const{error:f}=await G.from("action_types").update({name:p.name,description:p.description,icon:p.icon,color:p.color}).eq("id",p.id);if(f)throw f}else{const{error:f}=await G.from("action_types").insert([{name:p.name,description:p.description,icon:p.icon,color:p.color,sort_order:t.length}]);if(f)throw f}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-action-types"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:p=>{r({title:"Error",description:p.message,variant:"destructive"})}}),u=async p=>{await G.from("action_types").update({active:!p.active}).eq("id",p.id),n.invalidateQueries({queryKey:["admin-action-types"]})};return e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Action Types"}),e.jsx(pr,{children:"Define the types of touchpoint actions agents can take"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Action"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ms,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{children:"Color"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(p=>e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium",children:p.name}),e.jsx(lt,{className:"text-muted-foreground",children:p.description}),e.jsx(lt,{children:p.color&&e.jsx("div",{className:"w-6 h-6 rounded",style:{backgroundColor:p.color}})}),e.jsx(lt,{children:e.jsx(Br,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(lt,{children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:e.jsx(Da,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(_s,{open:l,onOpenChange:i,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsxs(ks,{children:[a?"Edit":"Add"," Action Type"]})}),e.jsxs("form",{onSubmit:p=>{p.preventDefault();const f=new FormData(p.currentTarget);d.mutate({id:a==null?void 0:a.id,name:f.get("name"),description:f.get("description"),icon:f.get("icon"),color:f.get("color")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"icon",children:"Icon"}),e.jsx(Re,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., phone, message"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"color",children:"Color"}),e.jsx(Re,{id:"color",name:"color",type:"color",defaultValue:(a==null?void 0:a.color)||"#6366f1"})]})]}),e.jsxs(Un,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Qhs({scripts:t,actionTypes:s,isLoading:r}){const{toast:n}=Pa(),a=rs(),[o,l]=C.useState(null),[i,d]=C.useState(!1),u=Dt({mutationFn:async f=>{if(f.id){const{error:y}=await G.from("action_scripts").update({title:f.title,action_type_id:f.action_type_id,tone:f.tone,script_body:f.script_body,active:f.active}).eq("id",f.id);if(y)throw y}else{const{error:y}=await G.from("action_scripts").insert([{title:f.title,action_type_id:f.action_type_id,tone:f.tone,script_body:f.script_body,active:!0}]);if(y)throw y}},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),d(!1),l(null),n({title:"Saved successfully"})},onError:f=>{n({title:"Error",description:f.message,variant:"destructive"})}}),p=Dt({mutationFn:async f=>{const{error:y}=await G.from("action_scripts").delete().eq("id",f);if(y)throw y},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),n({title:"Deleted successfully"})}});return e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Script Library"}),e.jsx(pr,{children:"Create and manage scripts for each action type"})]}),e.jsxs(K,{onClick:()=>{l(null),d(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ms,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Action Type"}),e.jsx(bt,{children:"Tone"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(f=>{var y;return e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium",children:f.title}),e.jsx(lt,{children:e.jsx(rt,{variant:"outline",children:((y=f.action_type)==null?void 0:y.name)||"Unknown"})}),e.jsx(lt,{className:"text-muted-foreground",children:f.tone}),e.jsx(lt,{children:e.jsx(rt,{variant:f.active?"default":"secondary",children:f.active?"Active":"Inactive"})}),e.jsxs(lt,{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{l(f),d(!0)},children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutate(f.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})]},f.id)})})]})}),e.jsx(_s,{open:i,onOpenChange:d,children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsx(Ss,{children:e.jsxs(ks,{children:[o?"Edit":"Add"," Script"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const y=new FormData(f.currentTarget);u.mutate({id:o==null?void 0:o.id,title:y.get("title"),action_type_id:y.get("action_type_id"),tone:y.get("tone"),script_body:y.get("script_body"),active:!0})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"title",children:"Title"}),e.jsx(Re,{id:"title",name:"title",defaultValue:o==null?void 0:o.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"action_type_id",children:"Action Type"}),e.jsxs(sr,{name:"action_type_id",defaultValue:o==null?void 0:o.action_type_id,children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select action type"})}),e.jsx(tr,{children:s.map(f=>e.jsx(At,{value:f.id,children:f.name},f.id))})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"tone",children:"Tone (optional)"}),e.jsx(Re,{id:"tone",name:"tone",defaultValue:(o==null?void 0:o.tone)||"",placeholder:"e.g., Friendly, Professional, Casual"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Ar,{id:"script_body",name:"script_body",defaultValue:o==null?void 0:o.script_body,rows:8,required:!0,placeholder:`Use {{FirstName}}, {{LastName}}, and {{AgentName}} as placeholders. Example: Hey {{FirstName}}, it's {{AgentName}}. I was thinking about you and wanted to check in...`})]})]}),e.jsxs(Un,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:u.isPending,children:[u.isPending&&e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Jhs({plans:t,actionTypes:s,scripts:r,isLoading:n}){const{toast:a}=Pa(),o=rs(),[l,i]=C.useState(null),[d,u]=C.useState(!1),[p,f]=C.useState(null),[y,_]=C.useState(!1),[b,w]=C.useState(null),[j,k]=C.useState(null),{data:S}=wt({queryKey:["plan-items",p],queryFn:async()=>{if(!p)return[];const{data:U,error:H}=await G.from("touchpoint_plan_items").select("*").eq("plan_id",p).order("month_number");if(H)throw H;return U},enabled:!!p}),T=Dt({mutationFn:async U=>{if(U.id){const{error:H}=await G.from("touchpoint_plans").update({name:U.name,description:U.description,active:U.active}).eq("id",U.id);if(H)throw H}else{const{error:H}=await G.from("touchpoint_plans").insert([{name:U.name,description:U.description,active:!0}]);if(H)throw H}},onSuccess:()=>{o.invalidateQueries({queryKey:["admin-touchpoint-plans"]}),u(!1),i(null),a({title:"Saved successfully"})},onError:U=>{a({title:"Error",description:U.message,variant:"destructive"})}}),I=Dt({mutationFn:async U=>{if(U.id){const{error:H}=await G.from("touchpoint_plan_items").update({action_type_id:U.action_type_id,default_script_id:U.default_script_id,notes:U.notes}).eq("id",U.id);if(H)throw H}else{const{error:H}=await G.from("touchpoint_plan_items").insert([{plan_id:U.plan_id,month_number:U.month_number,action_type_id:U.action_type_id,default_script_id:U.default_script_id,notes:U.notes}]);if(H)throw H}},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]}),a({title:"Item saved"})}}),L=Dt({mutationFn:async U=>{const{error:H}=await G.from("touchpoint_plan_items").delete().eq("id",U);if(H)throw H},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]})}}),R=Dt({mutationFn:async U=>{const{data:H,error:Y}=await G.from("action_scripts").insert([{...U,active:!0}]).select().single();if(Y)throw Y;return H},onSuccess:async U=>{o.invalidateQueries({queryKey:["admin-action-scripts"]}),b&&await I.mutateAsync({id:b.itemId,plan_id:p,month_number:b.month,action_type_id:b.actionTypeId,default_script_id:U.id}),_(!1),w(null),a({title:"Script created and assigned"})},onError:U=>{a({title:"Error",description:U.message,variant:"destructive"})}}),$=(U,H,Y)=>{w({month:U,actionTypeId:H,itemId:Y}),_(!0)},q=U=>r.find(H=>H.id===U);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Touchpoint Plans"}),e.jsx(pr,{children:"Create annual touchpoint plans that agents can apply to their contacts"})]}),e.jsxs(K,{onClick:()=>{i(null),u(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Plan"]})]}),e.jsx(Oe,{children:n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ms,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(U=>e.jsxs(Ee,{className:`cursor-pointer transition-colors ${p===U.id?"border-primary":""}`,onClick:()=>f(U.id),children:[e.jsx(It,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ot,{className:"text-base",children:U.name}),e.jsx(K,{variant:"ghost",size:"icon",onClick:H=>{H.stopPropagation(),i(U),u(!0)},children:e.jsx(Da,{className:"h-4 w-4"})})]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:U.description}),e.jsx(rt,{variant:U.active?"default":"secondary",className:"mt-2",children:U.active?"Active":"Inactive"})]})]},U.id))})})]}),p&&e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Plan Schedule"}),e.jsx(pr,{children:"Configure the monthly touchpoint schedule. Select an action type for each month, then assign or create a script."})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:12},(U,H)=>H+1).map(U=>{const H=S==null?void 0:S.find(te=>te.month_number===U),Y=H!=null&&H.default_script_id?q(H.default_script_id):null,se=r.filter(te=>te.action_type_id===(H==null?void 0:H.action_type_id)&&te.active);return e.jsxs("div",{className:"p-4 border rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"w-20 font-medium text-sm",children:["Month ",U]}),e.jsxs(sr,{value:(H==null?void 0:H.action_type_id)||"none",onValueChange:te=>{te==="none"&&H?L.mutate(H.id):te!=="none"&&I.mutate({id:H==null?void 0:H.id,plan_id:p,month_number:U,action_type_id:te,default_script_id:null})},children:[e.jsx(er,{className:"w-40",children:e.jsx(rr,{placeholder:"No action"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"none",children:"No action"}),s.filter(te=>te.active).map(te=>e.jsx(At,{value:te.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[te.color&&e.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:te.color}}),te.name]})},te.id))]})]}),H&&e.jsxs(e.Fragment,{children:[e.jsxs(sr,{value:H.default_script_id||"none",onValueChange:te=>{k(null),I.mutate({id:H.id,default_script_id:te==="none"?null:te})},children:[e.jsx(er,{className:"w-56",children:e.jsx(rr,{placeholder:"Select script"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"none",children:"No default script"}),se.map(te=>e.jsxs(At,{value:te.id,children:[te.title," ",te.tone&&`(${te.tone})`]},te.id))]})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>$(U,H.action_type_id,H.id),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"}),"New Script"]}),Y&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k((j==null?void 0:j.id)===Y.id?null:Y),children:(j==null?void 0:j.id)===Y.id?"Hide":"Preview"})]})]}),j&&(H==null?void 0:H.default_script_id)===j.id&&e.jsxs("div",{className:"ml-24 p-3 bg-muted rounded-lg text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(rt,{variant:"outline",children:j.title}),j.tone&&e.jsx(rt,{variant:"secondary",children:j.tone})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:j.script_body})]})]},U)})})})]}),e.jsx(_s,{open:d,onOpenChange:u,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsxs(ks,{children:[l?"Edit":"Add"," Touchpoint Plan"]})}),e.jsxs("form",{onSubmit:U=>{U.preventDefault();const H=new FormData(U.currentTarget);T.mutate({id:l==null?void 0:l.id,name:H.get("name"),description:H.get("description"),active:!0})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",name:"name",defaultValue:l==null?void 0:l.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",name:"description",defaultValue:(l==null?void 0:l.description)||"",rows:3})]})]}),e.jsxs(Un,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:T.isPending,children:[T.isPending&&e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})}),e.jsx(_s,{open:y,onOpenChange:_,children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Create New Script"}),e.jsxs(Kr,{children:["Create a script for Month ",b==null?void 0:b.month,". Use ","{{FirstName}}",", ","{{LastName}}",", and ","{{AgentName}}"," as placeholders."]})]}),e.jsxs("form",{onSubmit:U=>{U.preventDefault();const H=new FormData(U.currentTarget);R.mutate({title:H.get("title"),action_type_id:b.actionTypeId,tone:H.get("tone"),script_body:H.get("script_body")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script_title",children:"Title"}),e.jsx(Re,{id:"script_title",name:"title",placeholder:"e.g., Warm Check-In",required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script_tone",children:"Tone"}),e.jsx(Re,{id:"script_tone",name:"tone",placeholder:"e.g., Friendly, Professional"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Ar,{id:"script_body",name:"script_body",rows:6,required:!0,placeholder:"Hey {{FirstName}}, it's {{AgentName}}. I was thinking about you and wanted to check in..."})]})]}),e.jsxs(Un,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:R.isPending,children:[R.isPending&&e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Create & Assign"]})]})]})]})})]})}function ems({flags:t}){const{toast:s}=Pa(),r=rs(),n=async(a,o)=>{const{error:l}=await G.from("feature_flags").update({...o,updated_at:new Date().toISOString()}).eq("id",a.id);l?s({title:"Error",description:l.message,variant:"destructive"}):(r.invalidateQueries({queryKey:["admin-feature-flags"]}),s({title:"Flag updated"}))};return e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Feature Flags"}),e.jsx(pr,{children:"Control which features are enabled for members"})]}),e.jsx(Oe,{children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Flag"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{children:"Notes"}),e.jsx(bt,{children:"Last Updated"})]})}),e.jsx(Pn,{children:t.map(a=>e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-mono text-sm",children:a.key}),e.jsx(lt,{children:e.jsx(Br,{checked:a.enabled,onCheckedChange:o=>n(a,{enabled:o})})}),e.jsx(lt,{children:e.jsx(Re,{defaultValue:a.notes||"",placeholder:"Add notes...",className:"max-w-xs",onBlur:o=>{o.target.value!==a.notes&&n(a,{notes:o.target.value})}})}),e.jsx(lt,{className:"text-muted-foreground text-sm",children:new Date(a.updated_at).toLocaleDateString()})]},a.id))})]})})]})}function tms({items:t,isLoading:s}){const{toast:r}=Pa(),n=rs(),[a,o]=C.useState(null),[l,i]=C.useState(!1),d=Dt({mutationFn:async f=>{if(f.id){const{error:y}=await G.from("popby_items").update({name:f.name,description:f.description}).eq("id",f.id);if(y)throw y}else{const{error:y}=await G.from("popby_items").insert([{name:f.name,description:f.description,owner_user_id:null}]);if(y)throw y}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:f=>{r({title:"Error",description:f.message,variant:"destructive"})}}),u=async f=>{await G.from("popby_items").update({is_active:!f.is_active}).eq("id",f.id),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]})},p=async f=>{await G.from("popby_items").delete().eq("id",f),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),r({title:"Deleted successfully"})};return e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Popby Ideas"}),e.jsx(pr,{children:"Manage global popby ideas that all agents can see"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ms,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):t.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(po,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No popby ideas yet. Add your first one!"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(f=>e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium",children:f.name}),e.jsx(lt,{className:"text-muted-foreground",children:f.description}),e.jsx(lt,{children:e.jsx(Br,{checked:f.is_active,onCheckedChange:()=>u(f)})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(f),i(!0)},children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p(f.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},f.id))})]})}),e.jsx(_s,{open:l,onOpenChange:i,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsxs(ks,{children:[a?"Edit":"Add"," Popby Idea"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const y=new FormData(f.currentTarget);d.mutate({id:a==null?void 0:a.id,name:y.get("name"),description:y.get("description")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0,placeholder:"e.g., Homemade Cookies"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||"",placeholder:"Brief description of the popby idea..."})]})]}),e.jsxs(Un,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function sms(){var _;const{toast:t}=Pa(),s=rs(),[r,n]=C.useState(null),[a,o]=C.useState(!1),{data:l,isLoading:i}=wt({queryKey:["admin-video-script-categories"],queryFn:async()=>{const{data:b,error:w}=await G.from("video_script_categories").select("*").order("sort_order");if(w)throw w;return b}}),{data:d,isLoading:u}=wt({queryKey:["admin-video-scripts"],queryFn:async()=>{const{data:b,error:w}=await G.from("video_scripts").select("*, category:video_script_categories(*)").order("title");if(w)throw w;return b}}),p=Dt({mutationFn:async b=>{var w,j;if(b.id){const{error:k}=await G.from("video_scripts").update({title:b.title,script_text:b.script_text,category_id:b.category_id,tags:((w=b.tags)==null?void 0:w.split(",").map(S=>S.trim()).filter(Boolean))||[]}).eq("id",b.id);if(k)throw k}else{const{error:k}=await G.from("video_scripts").insert([{title:b.title,script_text:b.script_text,category_id:b.category_id||null,tags:((j=b.tags)==null?void 0:j.split(",").map(S=>S.trim()).filter(Boolean))||[]}]);if(k)throw k}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-video-scripts"]}),o(!1),n(null),t({title:"Video script saved!"})},onError:b=>t({title:"Error",description:b.message,variant:"destructive"})}),f=async b=>{await G.from("video_scripts").update({is_active:!b.is_active}).eq("id",b.id),s.invalidateQueries({queryKey:["admin-video-scripts"]})},y=async b=>{confirm("Delete this video script?")&&(await G.from("video_scripts").delete().eq("id",b),s.invalidateQueries({queryKey:["admin-video-scripts"]}),t({title:"Script deleted"}))};return e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Video Scripts"}),e.jsx(pr,{children:"Manage teleprompter scripts for Quick Video Touch"})]}),e.jsxs(K,{onClick:()=>{n(null),o(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Oe,{children:u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ms,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Category"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:d==null?void 0:d.map(b=>{var w;return e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium",children:b.title}),e.jsx(lt,{className:"text-muted-foreground",children:((w=b.category)==null?void 0:w.name)||"Uncategorized"}),e.jsx(lt,{children:e.jsx(Br,{checked:b.is_active,onCheckedChange:()=>f(b)})}),e.jsxs(lt,{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{n(b),o(!0)},children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>y(b.id),children:e.jsx(jr,{className:"h-4 w-4"})})]})]},b.id)})})]})}),e.jsx(_s,{open:a,onOpenChange:o,children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsx(Ss,{children:e.jsxs(ks,{children:[r?"Edit":"Add"," Video Script"]})}),e.jsxs("form",{onSubmit:b=>{b.preventDefault();const w=new FormData(b.currentTarget);p.mutate({id:r==null?void 0:r.id,title:w.get("title"),script_text:w.get("script_text"),category_id:w.get("category_id")||null,tags:w.get("tags")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"title",children:"Title"}),e.jsx(Re,{id:"title",name:"title",defaultValue:r==null?void 0:r.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"category_id",children:"Category"}),e.jsxs(sr,{name:"category_id",defaultValue:(r==null?void 0:r.category_id)||"",children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select category"})}),e.jsx(tr,{children:l==null?void 0:l.map(b=>e.jsx(At,{value:b.id,children:b.name},b.id))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script_text",children:"Script Text"}),e.jsx(Ar,{id:"script_text",name:"script_text",defaultValue:r==null?void 0:r.script_text,rows:6,required:!0,placeholder:"Enter the teleprompter script..."})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"tags",children:"Tags (comma-separated)"}),e.jsx(Re,{id:"tags",name:"tags",defaultValue:((_=r==null?void 0:r.tags)==null?void 0:_.join(", "))||"",placeholder:"birthday, follow-up, thank-you"})]})]}),e.jsxs(Un,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:p.isPending,children:[p.isPending&&e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function rms(){const{toast:t}=Pa(),[s,r]=C.useState(""),[n,a]=C.useState(!0),[o,l]=C.useState(!1);C.useEffect(()=>{(async()=>{a(!0);try{const{data:u}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();u!=null&&u.value&&r(u.value)}catch(u){console.error("Error fetching settings:",u)}a(!1)})()},[]);const i=async()=>{l(!0);try{await G.from("settings").upsert({key:"mapbox_public_token",value:s.trim()}),t({title:"Mapbox token saved!"})}catch{t({title:"Error saving token",variant:"destructive"})}l(!1)};return n?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex justify-center py-8",children:e.jsx(Ms,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):e.jsx("div",{className:"space-y-6",children:e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Oi,{className:"h-5 w-5"}),"Popby Map Settings"]}),e.jsx(pr,{children:"Configure the map feature for popbys"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"mapbox-token",children:"Mapbox Public Token"}),e.jsx(Re,{id:"mapbox-token",placeholder:"pk.eyJ1I...",value:s,onChange:d=>r(d.target.value)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token at"," ",e.jsx("a",{href:"https://mapbox.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"mapbox.com"}),". This token will be used by all agents for the popby map feature."]})]}),e.jsxs(K,{onClick:i,disabled:o,children:[o&&e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Token"]}),s&&e.jsx(rt,{variant:"secondary",className:"ml-2",children:"Token configured"})]})]})})}const nms=()=>{const[t,s]=C.useState(""),[r,n]=C.useState("grid"),a=Pr(),{data:o=[],isLoading:l}=wt({queryKey:["additional-services"],queryFn:async()=>{const{data:d,error:u}=await G.from("additional_services").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(u)throw u;return d}}),i=o.filter(d=>{var p;return d.name.toLowerCase().includes(t.toLowerCase())||((p=d.description)==null?void 0:p.toLowerCase().includes(t.toLowerCase()))});return e.jsx(Ts,{title:"Additional Services",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Additional Services"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Explore our additional services and offerings"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search services...",value:t,onChange:d=>s(d.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[t&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>s(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:r==="grid"?"secondary":"outline",size:"icon",onClick:()=>n("grid"),className:"rounded-full",children:e.jsx(yp,{className:"h-4 w-4"})}),e.jsx(K,{variant:r==="list"?"secondary":"outline",size:"icon",onClick:()=>n("list"),className:"rounded-full",children:e.jsx(Hh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.length," service",i.length!==1?"s":""," found"]}),l&&e.jsx("div",{className:r==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(4)].map((d,u)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(xs,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(xs,{className:"h-5 w-3/4 mb-2"}),e.jsx(xs,{className:"h-4 w-full mb-4"})]})},u))}),!l&&i.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:t?"No services match your search":"No additional services available yet"}),t&&e.jsx(K,{variant:"outline",onClick:()=>s(""),children:"Clear Search"})]}),!l&&i.length>0&&e.jsx("div",{className:r==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:i.map(d=>e.jsxs(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${r==="list"?"flex flex-row":""}`,onClick:()=>a(`/additional-services/${d.id}`),children:[e.jsx("div",{className:`relative overflow-hidden bg-muted ${r==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:d.preview_image_url?e.jsx("img",{src:d.preview_image_url,alt:d.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(hn,{className:"h-8 w-8"})})}),e.jsxs(Oe,{className:`p-4 flex flex-col ${r==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:d.name}),d.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 flex-1",children:poe(d.description)})]})]},d.id))})]})})},ams=()=>{const{serviceId:t}=ko(),s=Pr(),{data:r,isLoading:n}=wt({queryKey:["additional-service",t],queryFn:async()=>{const{data:a,error:o}=await G.from("additional_services").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;return a},enabled:!!t});return n?e.jsx(Ts,{title:"Loading...",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsx(xs,{className:"h-8 w-48"}),e.jsx(xs,{className:"h-64 w-full rounded-lg"}),e.jsx(xs,{className:"h-24 w-full"})]})}):r?e.jsx(Ts,{title:r.name,children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/additional-services"),className:"gap-2",children:[e.jsx(ti,{className:"h-4 w-4"}),"Back to Services"]}),e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("div",{className:"relative bg-muted",children:r.preview_image_url?e.jsx("img",{src:r.preview_image_url,alt:r.name,className:"w-full h-auto max-h-[500px] object-contain mx-auto"}):e.jsx("div",{className:"w-full h-64 flex items-center justify-center text-muted-foreground",children:e.jsx(hn,{className:"h-16 w-16"})})})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:r.name}),e.jsxs("div",{className:"flex items-center text-sm text-muted-foreground",children:[e.jsx(on,{className:"h-4 w-4 mr-1"}),"Published ",ys(new Date(r.publish_date),"MMMM d, yyyy")]})]}),r.description&&e.jsx("div",{className:"prose prose-sm max-w-none text-muted-foreground [&_a]:text-primary [&_a]:underline",dangerouslySetInnerHTML:{__html:r.description}}),e.jsx("div",{className:"pt-4 border-t",children:e.jsxs(K,{size:"lg",className:"gap-2",onClick:()=>window.open(r.signup_link_url,"_blank"),children:[e.jsx(sn,{className:"h-5 w-5"}),"Sign Up Now"]})})]})})]})}):e.jsx(Ts,{title:"Not Found",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center py-12",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground mb-4",children:"Service Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"The service you're looking for doesn't exist or has been removed."}),e.jsxs(K,{onClick:()=>s("/additional-services"),children:[e.jsx(ti,{className:"h-4 w-4 mr-2"}),"Back to Services"]})]})})},kE=[{id:"content-calendar",name:"Social Media Content Calendar Generator",iframe:``},{id:"property-promotion",name:"Property Promotion AI Tool",iframe:''},{id:"bio-boost",name:"Realtor Bio-Boost",iframe:''},{id:"market-report",name:"Market Report & Video Script Generator",iframe:''},{id:"property-description",name:"Property Description Writer",iframe:''},{id:"newsletter-generator",name:"Local Real Estate Newsletter Generator",iframe:''}];function ims(){const[t,s]=C.useState(kE[0].id),r=kE.find(n=>n.id===t)||kE[0];return e.jsx(Ts,{title:"AI Toolkit",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(m5,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"AI Toolkit"}),e.jsx("p",{className:"text-muted-foreground",children:"Powerful AI tools to boost your real estate business"})]})]}),e.jsx("div",{className:"md:hidden",children:e.jsxs(sr,{value:t,onValueChange:s,children:[e.jsx(er,{className:"w-full",children:e.jsx(rr,{placeholder:"Select a tool"})}),e.jsx(tr,{children:kE.map(n=>e.jsx(At,{value:n.id,children:n.name},n.id))})]})}),e.jsx("div",{className:"hidden md:block",children:e.jsx(ka,{value:t,onValueChange:s,className:"w-full",children:e.jsx(_a,{className:"w-full flex-wrap h-auto gap-1 bg-muted p-1",children:kE.map(n=>e.jsx(js,{value:n.id,className:"flex-1 min-w-[150px] text-xs lg:text-sm whitespace-normal h-auto py-2",children:n.name},n.id))})})}),e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-full max-w-[700px]",dangerouslySetInnerHTML:{__html:r.iframe}})})]})})}const CLe="agent-os-onboarding-completed",OR=[{icon:Qx,iconColor:"text-white",bgGradient:"from-primary via-primary/80 to-purple-600",title:"Welcome to Agent OS",description:"You've unlocked a powerful new tool designed to help you build stronger relationships and close more deals. Agent OS is currently in beta, and we're excited for you to try it!",highlights:["Manage your most important relationships","Stay in touch with automated reminders","Track your transactions and goals","Maximize referrals from your sphere"]},{icon:Fm,iconColor:"text-white",bgGradient:"from-pink-500 via-rose-500 to-red-500",title:"InnerCircle Home",description:"Your daily command center. See today's action items, track your momentum streak, and get a snapshot of your relationship health—all at a glance.",highlights:["Today's touchpoints and special dates","Momentum stats and streak tracking","Relationship health overview","Quick access to all features"]},{icon:hr,iconColor:"text-white",bgGradient:"from-blue-500 via-indigo-500 to-purple-500",title:"Contacts",description:"Import and organize your sphere of influence. Tag contacts by relationship type (Top 25, Past Clients, Referral Partners, etc.) to prioritize your outreach.",highlights:["Import contacts via CSV","Tag by relationship type","Track birthdays and home anniversaries","See relationship health scores"]},{icon:id,iconColor:"text-white",bgGradient:"from-emerald-500 via-teal-500 to-cyan-500",title:"Touchpoint Plans",description:"Assign automated touchpoint schedules to your contact groups. Each plan tells you exactly who to reach out to and when—with pre-written scripts to make it easy.",highlights:["Pre-built 12-month plans","Create your own custom plans","Scripts for calls, texts, and emails","Automatic daily action items"]},{icon:po,iconColor:"text-white",bgGradient:"from-orange-500 via-amber-500 to-yellow-500",title:"Popbys",description:"Pop-by visits are one of the most powerful ways to stay top-of-mind. Track your gift drop-offs and see who's due for a visit on the map.",highlights:["Track pop-by gift ideas","Set visit frequency by contact type","Log completed pop-bys","Map view for route planning"]},{icon:ol,iconColor:"text-white",bgGradient:"from-purple-500 via-violet-500 to-indigo-500",title:"Scorecard",description:"Track your transactions, set goals, and see your progress over time. Know exactly where your business stands and where your deals are coming from.",highlights:["Log buyer and seller transactions","Set and track annual goals","See your top lead sources","Export data for your records"]}],oms=()=>{const[t,s]=C.useState(!1),[r,n]=C.useState(0),[a,o]=C.useState(!1);C.useEffect(()=>{if(!localStorage.getItem(CLe)){const b=setTimeout(()=>s(!0),500);return()=>clearTimeout(b)}},[]);const l=()=>{r{n(r+1),o(!1)},150)):d()},i=()=>{d()},d=()=>{localStorage.setItem(CLe,"true"),s(!1)},u=OR[r],p=u.icon,f=r===OR.length-1,y=_=>{_||d(),s(_)};return e.jsx(_s,{open:t,onOpenChange:y,children:e.jsxs(vs,{className:"sm:max-w-lg overflow-hidden p-0 gap-0",children:[e.jsxs("div",{className:`relative bg-gradient-to-br ${u.bgGradient} p-8 pb-12 transition-all duration-500`,children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx("div",{className:"absolute -top-4 -right-4 w-32 h-32 bg-white/10 rounded-full blur-2xl animate-pulse"}),e.jsx("div",{className:"absolute -bottom-8 -left-8 w-40 h-40 bg-white/10 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-white/5 rounded-full blur-3xl"})]}),e.jsxs("div",{className:`relative mx-auto flex h-20 w-20 items-center justify-center transition-all duration-300 ${a?"scale-75 opacity-0":"scale-100 opacity-100"}`,children:[e.jsx("div",{className:"absolute inset-0 bg-white/20 rounded-2xl blur-xl"}),e.jsx("div",{className:"relative flex h-20 w-20 items-center justify-center rounded-2xl bg-white/20 backdrop-blur-sm border border-white/30 shadow-2xl",children:e.jsx(p,{className:`h-10 w-10 ${u.iconColor} drop-shadow-lg`})})]}),r===0&&e.jsxs("div",{className:"absolute top-4 right-4 px-3 py-1 rounded-full bg-white/20 backdrop-blur-sm border border-white/30 text-white text-xs font-medium flex items-center gap-1.5",children:[e.jsx(hn,{className:"h-3 w-3"}),"Beta"]})]}),e.jsxs("div",{className:"p-6 pt-4",children:[e.jsxs(Ss,{className:"text-center sm:text-center pb-2",children:[e.jsx(ks,{className:`text-2xl font-bold transition-all duration-300 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.title}),e.jsx(Kr,{className:`text-base pt-2 transition-all duration-300 delay-75 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.description})]}),u.highlights&&e.jsx("div",{className:`space-y-2.5 py-4 transition-all duration-300 delay-100 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.highlights.map((_,b)=>e.jsxs("div",{className:"flex items-center gap-3 group",style:{transitionDelay:`${150+b*50}ms`},children:[e.jsx("div",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-gradient-to-br ${u.bgGradient} shadow-sm`,children:e.jsx(ha,{className:"h-3.5 w-3.5 text-white"})}),e.jsx("span",{className:"text-sm text-muted-foreground group-hover:text-foreground transition-colors",children:_})]},b))}),e.jsx("div",{className:"flex justify-center gap-2 py-4",children:OR.map((_,b)=>e.jsx("button",{onClick:()=>{b!==r&&(o(!0),setTimeout(()=>{n(b),o(!1)},150))},className:`h-2 rounded-full transition-all duration-300 ${b===r?"w-8 bg-gradient-to-r "+u.bgGradient:b{const{user:t}=Hs();return wt({queryKey:["contact-snoozes",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_snoozes").select("*").gte("snoozed_until",new Date().toISOString());if(r)throw r;return s},enabled:!!t})},cms=()=>{const t=rs(),{user:s}=Hs();return Dt({mutationFn:async({contactId:r,days:n})=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const a=ml(new Date,n);await G.from("contact_snoozes").delete().eq("contact_id",r);const{error:o}=await G.from("contact_snoozes").insert({contact_id:r,owner_user_id:s.id,snoozed_until:a.toISOString()});if(o)throw o},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-snoozes"]}),t.invalidateQueries({queryKey:["today-actions"]}),t.invalidateQueries({queryKey:["popby-logs"]}),pn({title:"Touch snoozed!",description:"Contact has been snoozed."})},onError:r=>{pn({title:"Error snoozing contact",description:r.message,variant:"destructive"})}})},dms=()=>{const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("contact_snoozes").delete().eq("contact_id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-snoozes"]}),pn({title:"Snooze cancelled"})},onError:s=>{pn({title:"Error cancelling snooze",description:s.message,variant:"destructive"})}})},ums=[{label:"1 week",days:7},{label:"2 weeks",days:14},{label:"1 month",days:30}];function Dce({open:t,onOpenChange:s,contactId:r,contactName:n}){const[a,o]=C.useState(null),l=cms(),i=async()=>{a&&(await l.mutateAsync({contactId:r,days:a}),o(null),s(!1))},d=u=>ys(ml(new Date,u),"MMM d, yyyy");return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-5 w-5"}),"Snooze Touch"]}),e.jsxs(Kr,{children:["Postpone the next scheduled touch for ",n,". Select how long to snooze."]})]}),e.jsx("div",{className:"space-y-3 py-4",children:ums.map(u=>e.jsxs("button",{type:"button",onClick:()=>o(u.days),className:Pt("w-full flex items-center justify-between p-3 rounded-lg border transition-colors",a===u.days?"border-primary bg-primary/5":"border-border hover:border-primary/50 hover:bg-accent/50"),children:[e.jsx("span",{className:"font-medium",children:u.label}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(on,{className:"h-3.5 w-3.5"}),"Until ",d(u.days)]})]},u.days))}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:i,disabled:!a||l.isPending,children:l.isPending?"Snoozing...":"Snooze Touch"})]})]})})}const hms={Crown:Uh,FileText:In,Users:hr,Globe:Lm,Star:Gn,Phone:Qn,MessageSquare:io,PenTool:d_,Video:Nn,Gift:po};function mms({actions:t,onMarkComplete:s,onViewScript:r,isLoading:n,buildSmsLink:a,buildEmailLink:o,onGmailCompose:l}){const i=Pr(),[d,u]=C.useState("name"),[p,f]=C.useState("asc"),[y,_]=C.useState(null),[b,w]=C.useState(""),j=L=>{d===L?f(R=>R==="asc"?"desc":"asc"):(u(L),f("asc"))},k=C.useMemo(()=>[...t].sort((L,R)=>{var q,U;let $=0;switch(d){case"name":{const H=`${L.contact.first_name} ${L.contact.last_name||""}`.toLowerCase(),Y=`${R.contact.first_name} ${R.contact.last_name||""}`.toLowerCase();$=H.localeCompare(Y);break}case"relationship_type":$=(L.relationshipTypeName||"").localeCompare(R.relationshipTypeName||"");break;case"action_type":$=(((q=L.actionType)==null?void 0:q.name)||"").localeCompare(((U=R.actionType)==null?void 0:U.name)||"");break;case"last_touch":$=(L.monthNumber||0)-(R.monthNumber||0);break}return p==="asc"?$:-$}),[t,d,p]),S=L=>hms[L||"Phone"]||Qn,T=({field:L,children:R})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>j(L),children:[R,d===L?p==="asc"?e.jsx(Vd,{className:"ml-2 h-4 w-4"}):e.jsx(sh,{className:"ml-2 h-4 w-4"}):e.jsx(Hc,{className:"ml-2 h-4 w-4 opacity-50"})]}),I=(L,R,$)=>{_(L),w(`${R} ${$||""}`.trim())};return t.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No actions scheduled for today."}),e.jsx("p",{className:"text-sm mt-1",children:"Add contacts and enable touchpoint plans to get started."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{className:"bg-muted/50",children:[e.jsx(bt,{className:"w-[180px]",children:e.jsx(T,{field:"name",children:"Contact"})}),e.jsx(bt,{className:"w-[130px]",children:e.jsx(T,{field:"relationship_type",children:"Type"})}),e.jsx(bt,{className:"w-[120px]",children:e.jsx(T,{field:"action_type",children:"Action"})}),e.jsx(bt,{className:"w-[130px]",children:"Phone"}),e.jsx(bt,{className:"w-[200px]",children:"Quick Actions"})]})}),e.jsx(Pn,{children:k.map((L,R)=>{var se,te,Q,de,re,ae;const $=L.isSpecialDate,q=L.specialDateType,U=$?q==="birthday"?zu:On:S(((se=L.actionType)==null?void 0:se.icon)||null),H=L.contact.phone,Y=L.contact.email;return e.jsxs(Ns,{className:Pt("hover:bg-muted/50 transition-colors",$&&q==="birthday"&&"bg-pink-50/50 dark:bg-pink-950/20",$&&q==="anniversary"&&"bg-purple-50/50 dark:bg-purple-950/20"),children:[e.jsx(lt,{className:"font-medium",children:e.jsx("div",{children:e.jsxs("button",{onClick:()=>i(`/mission-control/contacts/${L.contact.id}`),className:"truncate max-w-[160px] text-left hover:text-primary hover:underline transition-colors",children:[L.contact.first_name," ",L.contact.last_name]})})}),e.jsx(lt,{children:L.relationshipTypeName?e.jsx(rt,{variant:"secondary",className:"text-xs",children:L.relationshipTypeName}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(lt,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:$?e.jsx(rt,{className:Pt("gap-1",q==="birthday"&&"bg-pink-500 hover:bg-pink-600",q==="anniversary"&&"bg-purple-500 hover:bg-purple-600"),children:q==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(zu,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(On,{className:"h-3 w-3"})," Anniversary"]})}):e.jsxs(rt,{variant:"outline",className:"gap-1",children:[e.jsx(U,{className:"h-3 w-3"}),(te=L.actionType)==null?void 0:te.name]})})}),e.jsx(lt,{children:H?e.jsx("span",{className:"text-sm font-mono",children:L.contact.phone}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[H&&e.jsx("a",{href:`tel:${L.contact.phone}`,className:"p-1.5 rounded bg-primary/10 hover:bg-primary/20 text-primary transition-colors",title:"Call",children:e.jsx(Qn,{className:"h-3.5 w-3.5"})}),H&&e.jsx("a",{href:a(L.contact.phone,(Q=L.script)==null?void 0:Q.script_body,L.contact),className:"p-1.5 rounded bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 transition-colors",title:"Text",children:e.jsx(io,{className:"h-3.5 w-3.5"})}),Y&&(l?e.jsx("button",{onClick:()=>l({id:L.contact.id,first_name:L.contact.first_name,last_name:L.contact.last_name,email:L.contact.email}),className:"p-1.5 rounded bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 transition-colors",title:"Compose Email",children:e.jsx(br,{className:"h-3.5 w-3.5"})}):e.jsx("a",{href:o(L.contact.email,(de=L.script)==null?void 0:de.script_body,(re=L.script)==null?void 0:re.email_subject,(ae=L.actionType)==null?void 0:ae.name,L.contact),className:"p-1.5 rounded bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 transition-colors",title:"Email",children:e.jsx(br,{className:"h-3.5 w-3.5"})})),$&&e.jsxs("button",{onClick:()=>{const le=`${L.contact.first_name}${L.contact.last_name?" "+L.contact.last_name:""}`,he=q==="birthday"?"birthday":"home_anniversary",be=new URLSearchParams({cardType:he,contactId:L.contact.id,name:le,...L.contact.address?{address:L.contact.address}:{},...q==="anniversary"&&L.contact.home_anniversary?{date:L.contact.home_anniversary}:{}});i(`/mission-control/card-studio?${be.toString()}`)},className:Pt("h-7 px-2 rounded text-xs font-semibold flex items-center gap-1 transition-colors",q==="birthday"?"bg-pink-500/15 hover:bg-pink-500/25 text-pink-600 dark:text-pink-400":"bg-purple-500/15 hover:bg-purple-500/25 text-purple-600 dark:text-purple-400"),title:`Send ${q==="birthday"?"Birthday":"Anniversary"} Card`,children:[e.jsx(br,{className:"h-3.5 w-3.5"}),"Send Card"]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:()=>I(L.contact.id,L.contact.first_name,L.contact.last_name),title:"Snooze",children:e.jsx(vp,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{variant:"default",size:"sm",className:"h-7 px-2 text-xs ml-1",onClick:()=>{var le;return s(L.contact.id,L.actionType.id,(le=L.script)==null?void 0:le.id)},disabled:n,children:[e.jsx(ua,{className:"h-3.5 w-3.5 mr-1"}),"Done"]})]})})]},`${L.contact.id}-${R}`)})})]})}),e.jsx(Dce,{open:!!y,onOpenChange:L=>!L&&_(null),contactId:y||"",contactName:b})]})}function Ny(){const{data:t,isLoading:s}=wt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:a,error:o}=await G.from("gmail_integrations").select("*").maybeSingle();if(o)throw o;return a}}),r=!!(t!=null&&t.is_active),n=(t==null?void 0:t.gmail_email)||null;return{isGmailConnected:r,gmailEmail:n,isLoading:s}}function pms({onSelect:t}){const[s,r]=C.useState(null),{data:n=[],isLoading:a}=wt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:d,error:u}=await G.from("email_template_categories").select("*").order("sort_order");if(u)throw u;return d}}),{data:o=[],isLoading:l}=wt({queryKey:["agent-email-templates",s],queryFn:async()=>{let d=G.from("agent_email_templates").select("*").eq("is_active",!0).order("sort_order");s&&(d=d.eq("category_id",s));const{data:u,error:p}=await d;if(p)throw p;return u}}),i=n.find(d=>d.id===s);return a?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(Ms,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):s?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{onClick:()=>r(null),className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(zl,{className:"h-3.5 w-3.5"}),"Back to categories"]}),e.jsxs("p",{className:"text-xs font-medium flex items-center gap-1.5",children:[e.jsx("span",{children:i==null?void 0:i.icon})," ",i==null?void 0:i.name]}),l?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(Ms,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):o.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No templates in this category"}):e.jsx(Ri,{className:"max-h-[280px]",children:e.jsx("div",{className:"space-y-1",children:o.map(d=>e.jsxs("button",{onClick:()=>t(d),className:"w-full p-2.5 rounded-lg border hover:bg-accent transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"font-medium text-sm",children:d.title}),d.tone&&e.jsx(rt,{variant:"secondary",className:"text-[10px] shrink-0",children:d.tone})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:d.subject})]},d.id))})})]}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground px-1 mb-2",children:"Select a category"}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto space-y-1 pr-1",children:n.map(d=>e.jsxs("button",{onClick:()=>r(d.id),className:"w-full flex items-center justify-between p-2.5 rounded-lg border hover:bg-accent transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"text-lg",children:d.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:d.name}),d.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:d.description})]})]}),e.jsx(Ua,{className:"h-4 w-4 text-muted-foreground shrink-0"})]},d.id))})]})}function F2e(){var a;const{user:t}=Hs(),{data:s,isLoading:r}=wt({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,staleTime:60*1e3,queryFn:async()=>{var u,p,f,y;const[{data:o,error:l},{data:i,error:d}]=await Promise.all([G.from("mass_email_settings").select("reply_to_email, display_name").eq("user_id",t.id).maybeSingle(),G.from("profiles").select("email, name").eq("id",t.id).maybeSingle()]);if(l)throw l;if(d)throw d;return{reply_to_email:((u=o==null?void 0:o.reply_to_email)==null?void 0:u.trim())||((p=i==null?void 0:i.email)==null?void 0:p.trim())||null,display_name:((f=o==null?void 0:o.display_name)==null?void 0:f.trim())||((y=i==null?void 0:i.name)==null?void 0:y.trim())||null}}});return{isReady:!!((a=s==null?void 0:s.reply_to_email)!=null&&a.trim()),isLoading:r,settings:s}}const fms=5*1024*1024,r0=50,gms=["application/pdf","image/jpeg","image/png","image/gif","image/webp","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","text/csv"];function xms(t){return t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function yms(t){return new Promise((s,r)=>{const n=new FileReader;n.onload=()=>{const a=n.result;s(a.split(",")[1])},n.onerror=r,n.readAsDataURL(t)})}function a1(t,s){let r=t.replace(/\{\{first_name\}\}/gi,s.first_name).replace(/\{\{last_name\}\}/gi,s.last_name||"").replace(/\{\{full_name\}\}/gi,`${s.first_name} ${s.last_name||""}`.trim());return s.updateLink&&(r=r.replace(/\{\{update_link\}\}/gi,s.updateLink)),r}function JM({open:t,onOpenChange:s,contact:r,bulkContacts:n,defaultSubject:a="",defaultBody:o="",gmailEmail:l,onSendComplete:i}){const{user:d}=Hs(),u=rs(),{isReady:p,settings:f}=F2e(),y=!!n&&n.length>0,_=y&&p,b=y?n:r?[r]:[],w=b[0],j=y?Math.ceil(b.length/r0):1,k=y&&b.length>r0,[S,T]=C.useState((w==null?void 0:w.email)||""),[I,L]=C.useState(a),[R,$]=C.useState(o),[q,U]=C.useState(!1),[H,Y]=C.useState(!1),[se,te]=C.useState([]),[Q,de]=C.useState(a),[re,ae]=C.useState(o),[le,he]=C.useState("composing"),[be,_e]=C.useState(0),[je,Ne]=C.useState(0),[Ge,we]=C.useState(0),[Me,Te]=C.useState(0),Fe=C.useRef(!1),[Ae,Ue]=C.useState(null);C.useEffect(()=>{t&&(T((w==null?void 0:w.email)||""),de(a),ae(o),L(a1(a,w||{first_name:""})),$(a1(o,w||{first_name:""})),Y(!a&&!o),te([]),he("composing"),_e(0),Ne(0),we(0),Te(0),Fe.current=!1,Ue(null))},[t,w,a,o]);const ut=async Qe=>{const We=Qe.target.files;if(!We)return;const He=se.reduce((Tt,Ft)=>Tt+Ft.size,0),et=[];for(const Tt of Array.from(We)){if(!gms.includes(Tt.type)){fe.error(`${Tt.name}: Unsupported file type`);continue}if(He+Tt.size>fms){fe.error("Total attachments exceed 5MB limit");break}try{const Ft=await yms(Tt);et.push({name:Tt.name,type:Tt.type,size:Tt.size,data:Ft})}catch{fe.error(`Failed to read ${Tt.name}`)}}te(Tt=>[...Tt,...et]),Qe.target.value=""},De=Qe=>{te(We=>We.filter((He,et)=>et!==Qe))},Rt=Qe=>{de(Qe.subject),ae(Qe.body),L(a1(Qe.subject,w||{first_name:""})),$(a1(Qe.body,w||{first_name:""})),Y(!1)},me=Qe=>Qe.split(/\n\n+/).map(We=>`

${We.replace(/\n/g,"
")}

`).join(""),Xe=async Qe=>{const We=a1(I,Qe),He=a1(R,Qe),et=me(He);try{if(_){const Tt=(f==null?void 0:f.display_name)||"ReLevelUp",Ft=`${Tt.toLowerCase().replace(/[^a-z]/g,".")}@send.relevelup.com`,as=`${Tt} <${Ft}>`,{data:Xt,error:ss}=await G.functions.invoke("ses-send-campaign",{body:{action:"test_send",to:Qe.email,from_email:as,subject:We,body_html:et,reply_to:(f==null?void 0:f.reply_to_email)||void 0}});if(ss)throw ss;if(!(Xt!=null&&Xt.success))throw new Error((Xt==null?void 0:Xt.error)||"Failed to send")}else{const{data:Tt,error:Ft}=await G.functions.invoke("gmail-send",{body:{to:Qe.email,subject:We,body:et,contactId:Qe.id,attachments:se.map(({name:as,type:Xt,data:ss})=>({name:as,type:Xt,data:ss}))}});if(Ft)throw Ft;if(!(Tt!=null&&Tt.success))throw new Error((Tt==null?void 0:Tt.error)||"Failed to send")}return d&&await G.from("bulk_email_sends").insert({user_id:d.id,contact_id:Qe.id,contact_email:Qe.email,subject:We,source:_?"ses_bulk":"sphere_gaps"}),!0}catch(Tt){return console.error("Send error:",Tt),fe.error("Failed to send to "+Qe.first_name+": "+(Tt instanceof Error?Tt.message:"Unknown error")),!1}},ot=()=>{const Qe=be*r0;return b.slice(Qe,Qe+r0)},nt=async()=>{if(!I||!R){fe.error("Please fill in subject and message");return}const Qe=ot();U(!0),he("sending");let We=0,He=0;for(let Tt=0;TtsetTimeout(as,150));Ne(Tt=>Tt+We),we(Tt=>Tt+He),U(!1),u.invalidateQueries({queryKey:["bulk-email-sends"]}),be>=j-1||Fe.current?he("all_done"):he("batch_complete")},Se=async()=>{if(!I||!R){fe.error("Please fill in subject and message");return}if(!y){U(!0);const Qe=await Xe(w);U(!1),Qe&&(u.invalidateQueries({queryKey:["bulk-email-sends"]}),fe.success("Email sent successfully!"),s(!1),i==null||i());return}await nt()},it=async()=>{_e(Qe=>Qe+1),Te(0),await new Promise(Qe=>setTimeout(Qe,50)),await nt()};C.useEffect(()=>{},[be]);const $e=()=>{if(q){Fe.current=!0;return}s(!1),i==null||i()},ct=be*r0,qe=Math.min(ct+r0,b.length),Ze=y&&b.length>0?Math.round((je+Ge)/b.length*100):0;return e.jsx(_s,{open:t,onOpenChange:$e,children:e.jsxs(vs,{className:"sm:max-w-[600px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(br,{className:`h-5 w-5 ${_?"text-orange-500":"text-red-500"}`}),y?`Send to ${b.length} Contacts`:"Compose Email"]}),_?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sending via ",e.jsx("span",{className:"font-medium",children:"Mass Email"})," (reply-to: ",f==null?void 0:f.reply_to_email,")"]}):l?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sending from ",e.jsx("span",{className:"font-medium",children:l})]}):null,y&&le==="composing"&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Composing email for ",e.jsxs("span",{className:"font-medium",children:[b.length," contacts"]}),". You'll review each personalized email before sending."]})]}),le==="sending"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(Ms,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsxs("p",{className:"font-medium",children:["Sending batch ",be+1," of ",j,"..."]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Me," of ",ot().length," in this batch"]})]}),e.jsx(Ti,{value:Me/ot().length*100,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Overall: ",je+Ge," / ",b.length]}),e.jsxs("span",{children:[je," sent • ",Ge," failed"]})]}),e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{Fe.current=!0},children:"Stop Sending"})]}),le==="batch_complete"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(ua,{className:"h-8 w-8 text-emerald-500 mx-auto"}),e.jsxs("p",{className:"font-medium",children:["Batch ",be+1," Complete!"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[je," sent, ",Ge," failed so far"]})]}),e.jsx(Ti,{value:Ze,className:"h-2"}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[b.length-je-Ge," contacts remaining (",j-be-1," batches left)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:$e,children:"Done for Now"}),e.jsxs(K,{className:"flex-1 gap-2",onClick:it,children:[e.jsx(aa,{className:"h-4 w-4"}),"Send Next ",Math.min(r0,b.length-qe)," Contacts"]})]})]}),le==="all_done"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(ua,{className:"h-10 w-10 text-emerald-500 mx-auto"}),e.jsx("p",{className:"font-semibold text-lg",children:"All Done!"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[je," emails sent successfully",Ge>0&&e.jsxs("span",{className:"text-destructive",children:[" • ",Ge," failed"]})]})]}),e.jsx(K,{className:"w-full",onClick:$e,children:"Close"})]}),le==="composing"&&e.jsxs("div",{className:"space-y-4",children:[H?e.jsxs("div",{className:"border rounded-lg p-3 bg-muted/30 max-h-[50vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(In,{className:"h-4 w-4"})," Choose a Template"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Y(!1),className:"h-7 px-2 text-xs",children:[e.jsx(Ur,{className:"h-3 w-3 mr-1"})," Write from scratch"]})]}),e.jsx(pms,{onSelect:Rt})]}):e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>Y(!0),children:[e.jsx(In,{className:"h-4 w-4"}),"Browse Templates"]}),e.jsx(Rl,{}),!y&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"gmail-to",children:"To"}),e.jsx(Re,{id:"gmail-to",value:S,onChange:Qe=>T(Qe.target.value),placeholder:"recipient@example.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"gmail-subject",children:"Subject"}),e.jsx(Re,{id:"gmail-subject",value:I,onChange:Qe=>{L(Qe.target.value),de(Qe.target.value)},placeholder:"Enter subject..."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{htmlFor:"gmail-body",children:"Message"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(rt,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{$(Qe=>Qe+"{{first_name}}"),ae(Qe=>Qe+"{{first_name}}")},children:"{{first_name}}"}),e.jsx(rt,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{$(Qe=>Qe+"{{last_name}}"),ae(Qe=>Qe+"{{last_name}}")},children:"{{last_name}}"})]})]}),e.jsx(Ar,{id:"gmail-body",value:R,onChange:Qe=>{$(Qe.target.value),ae(Qe.target.value)},placeholder:"Write your message...",rows:10,className:"resize-y"}),y&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ","{{first_name}}",", ","{{last_name}}"," to personalize. You'll preview each recipient's email in the next step."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-2",onClick:()=>{var Qe;return(Qe=document.getElementById("gmail-attachments"))==null?void 0:Qe.click()},disabled:q,children:[e.jsx(mk,{className:"h-4 w-4"}),"Attach Files"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"PDF, images, Word, Excel (max 5MB total)"}),e.jsx("input",{id:"gmail-attachments",type:"file",multiple:!0,accept:".pdf,.jpg,.jpeg,.png,.gif,.webp,.doc,.docx,.xls,.xlsx,.csv",className:"hidden",onChange:ut})]}),se.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:se.map((Qe,We)=>e.jsxs(rt,{variant:"secondary",className:"gap-1.5 pl-2 pr-1 py-1",children:[e.jsx(mk,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-[140px] truncate text-xs",children:Qe.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["(",xms(Qe.size),")"]}),e.jsx("button",{type:"button",onClick:()=>De(We),className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Ur,{className:"h-3 w-3"})})]},We))})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),y?e.jsxs(K,{onClick:()=>{Ue(b[0]||null),he("reviewing")},disabled:!I||!R,className:"gap-2",children:["Review Emails",e.jsx($i,{className:"h-4 w-4"})]}):e.jsxs(K,{onClick:Se,disabled:q||!I||!R,className:"gap-2",children:[q?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):e.jsx(aa,{className:"h-4 w-4"}),q?"Sending...":"Send Email"]})]})]}),le==="reviewing"&&y&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-xs text-primary bg-primary/10 rounded-md px-2.5 py-1.5",children:["✉️ Click any recipient below to preview the ",e.jsx("span",{className:"font-semibold",children:"exact personalized email"})," they will receive."]}),k&&e.jsxs("p",{className:"text-xs text-amber-600 bg-amber-500/10 rounded-md px-2.5 py-1.5",children:["📦 ",b.length," contacts will be sent in ",j," batches of up to ",r0,". You'll confirm before each batch."]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(ve,{children:["Recipients (",b.length,")"]}),e.jsx("div",{className:"bg-muted p-1.5 rounded-md space-y-0.5 max-h-32 overflow-y-auto",children:b.map(Qe=>e.jsxs("div",{className:`text-sm px-2 py-1 rounded cursor-pointer transition-colors ${(Ae==null?void 0:Ae.id)===Qe.id?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>Ue(Qe),children:[Qe.first_name," ",Qe.last_name," — ",Qe.email]},Qe.id))})]}),Ae&&e.jsxs("div",{className:"border rounded-lg p-3 bg-muted/30 space-y-2 animate-in fade-in slide-in-from-top-1",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"text-xs font-semibold text-primary flex items-center gap-1.5",children:[e.jsx(br,{className:"h-3.5 w-3.5"}),"Preview for ",Ae.first_name," ",Ae.last_name]})}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"To:"})," ",Ae.email]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Subject:"})," ",a1(Q,Ae)]})]}),e.jsx(Rl,{}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-background rounded p-2.5 max-h-40 overflow-y-auto border",children:a1(re,Ae)})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>{he("composing"),Ue(null)},children:[e.jsx(ti,{className:"h-4 w-4 mr-1"}),"Back to Edit"]}),e.jsxs(K,{onClick:Se,disabled:q,className:"gap-2",children:[q?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):e.jsx(aa,{className:"h-4 w-4"}),k?`Send First ${r0}`:`Send to ${b.length}`]})]})]})]})})}function vms(){const t=Pr(),{data:s}=tm(),{data:r}=UL(),n=fbe(),{isGmailConnected:a,gmailEmail:o}=Ny(),[l,i]=C.useState(null),[d,u]=C.useState(!1),[p,f]=C.useState(new Set),y=Zh(new Date),_=ml(y,30),b=I=>{if(!I)return null;const L=I.split(/[-/T]/);if(L.length<3)return null;const R=parseInt(L[1],10)-1,$=parseInt(L[2],10);return isNaN(R)||isNaN($)?null:new Date(y.getFullYear(),R,$)},w=C.useMemo(()=>{if(!s)return[];const I=[];for(const L of s){if(L.birthday){const R=b(L.birthday);R&&(cl(R,y)||Rk(R,y)&&Fk(R,_))&&I.push({contact:L,type:"birthday",date:R,daysUntil:gp(R,y),dateStr:L.birthday})}if(L.home_anniversary){const R=b(L.home_anniversary);R&&(cl(R,y)||Rk(R,y)&&Fk(R,_))&&I.push({contact:L,type:"anniversary",date:R,daysUntil:gp(R,y),dateStr:L.home_anniversary})}}return I.sort((L,R)=>L.daysUntil-R.daysUntil),I},[s]),j=async I=>{const L=(r==null?void 0:r.find(R=>R.name==="Call"))||(r==null?void 0:r[0]);if(L)try{await n.mutateAsync({contactId:I.contact.id,actionTypeId:L.id,notes:`${I.type==="birthday"?"Birthday":"Home Anniversary"} outreach`}),f(R=>new Set(R).add(`${I.contact.id}-${I.type}`)),pn({title:"Touch logged!",description:`Logged outreach for ${I.contact.first_name}`})}catch{pn({title:"Error",description:"Failed to log touch",variant:"destructive"})}},k=I=>{const L=`${I.contact.first_name}${I.contact.last_name?" "+I.contact.last_name:""}`,R=I.type==="birthday"?"birthday":"home_anniversary",$=new URLSearchParams({cardType:R,contactId:I.contact.id,name:L,...I.contact.address?{address:I.contact.address}:{},...I.type==="anniversary"&&I.dateStr?{date:I.dateStr}:{}});t(`/mission-control/card-studio?${$.toString()}`)},S=I=>I===0?"Today!":I===1?"Tomorrow":`${I} days`,T=I=>I===0?"bg-red-500/15 text-red-600 dark:text-red-400 border-red-500/30":I<=3?"bg-amber-500/15 text-amber-600 dark:text-amber-400 border-amber-500/30":I<=7?"bg-blue-500/15 text-blue-600 dark:text-blue-400 border-blue-500/30":"bg-muted text-muted-foreground border-border";return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(id,{className:"h-5 w-5 text-primary"}),"Upcoming Milestones",e.jsx(rt,{variant:"secondary",className:"text-xs font-normal",children:"Next 30 days"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[w.length," event",w.length!==1?"s":""]})]})}),e.jsxs(Oe,{className:"space-y-2",children:[w.length===0&&e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(zu,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No birthdays or anniversaries in the next 30 days."}),e.jsx("p",{className:"text-xs mt-1",children:"Add dates to your contacts to see upcoming milestones here."})]}),w.map((I,L)=>{var U,H;const R=`${I.contact.id}-${I.type}`,$=p.has(R),q=`${((U=I.contact.first_name)==null?void 0:U[0])||""}${((H=I.contact.last_name)==null?void 0:H[0])||""}`.toUpperCase();return e.jsxs("div",{className:Pt("p-3 rounded-lg border transition-colors",I.daysUntil===0&&I.type==="birthday"?"bg-pink-500/10 border-pink-500/30 dark:bg-pink-900/20 dark:border-pink-800/40":I.daysUntil===0&&I.type==="anniversary"?"bg-blue-500/10 border-blue-500/30 dark:bg-blue-900/20 dark:border-blue-800/40":I.type==="birthday"?"bg-pink-50/60 border-pink-200/60 hover:bg-pink-100/60 dark:bg-pink-950/20 dark:border-pink-900/30 dark:hover:bg-pink-950/30":"bg-blue-50/60 border-blue-200/60 hover:bg-blue-100/60 dark:bg-blue-950/20 dark:border-blue-900/30 dark:hover:bg-blue-950/30"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(xn,{className:Pt("h-10 w-10",I.type==="birthday"?"ring-2 ring-pink-300/50 dark:ring-pink-700/50":"ring-2 ring-blue-300/50 dark:ring-blue-700/50"),children:e.jsx(yn,{className:Pt("text-xs font-medium",I.type==="birthday"?"bg-pink-100 text-pink-700 dark:bg-pink-900/40 dark:text-pink-300":"bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300"),children:q})}),e.jsx("span",{className:"absolute -bottom-1.5 -right-1.5 text-base leading-none drop-shadow-sm",children:I.type==="birthday"?"🎂":"🏠"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:[I.contact.first_name," ",I.contact.last_name||""]}),e.jsx(rt,{variant:"outline",className:Pt("text-[10px] shrink-0 whitespace-nowrap",T(I.daysUntil)),children:S(I.daysUntil)})]}),e.jsxs("div",{className:Pt("text-xs flex items-center gap-1.5 mt-0.5",I.type==="birthday"?"text-pink-600/80 dark:text-pink-400/80":"text-blue-600/80 dark:text-blue-400/80"),children:[I.type==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(zu,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(On,{className:"h-3 w-3"})," Home Anniversary"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:ys(I.date,"MMM d")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 pl-[52px]",children:[I.contact.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Call",asChild:!0,children:e.jsx("a",{href:`tel:${I.contact.phone}`,children:e.jsx(Qn,{className:"h-3.5 w-3.5"})})}),I.contact.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Text",asChild:!0,children:e.jsx("a",{href:`sms:${I.contact.phone}`,children:e.jsx(io,{className:"h-3.5 w-3.5"})})}),I.contact.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Email",onClick:()=>{a?(i({id:I.contact.id,first_name:I.contact.first_name,last_name:I.contact.last_name,email:I.contact.email}),u(!0)):window.location.href=`mailto:${I.contact.email}`},children:e.jsx(br,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Record video",onClick:()=>t(`/mission-control/video/record?contactId=${I.contact.id}`),children:e.jsx(Nn,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("h-7 px-2 gap-1 text-xs",I.type==="birthday"?"text-pink-600 hover:text-pink-700 dark:text-pink-400":"text-blue-600 hover:text-blue-700 dark:text-blue-400"),title:`Send ${I.type==="birthday"?"birthday":"anniversary"} card`,onClick:()=>k(I),children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Card"})]}),e.jsx(K,{variant:"ghost",size:"icon",className:Pt("h-7 w-7",$&&"text-green-600"),title:"Log a touch",disabled:$||n.isPending,onClick:()=>j(I),children:e.jsx(ua,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"View contact",onClick:()=>t(`/mission-control/contacts/${I.contact.id}`),children:e.jsx(xa,{className:"h-3.5 w-3.5"})})]})]},`${R}-${L}`)})]})]}),a&&l&&e.jsx(JM,{open:d,onOpenChange:u,contact:l,gmailEmail:o})]})}const MLe={Crown:Uh,FileText:In,Users:hr,Globe:Lm,Star:Gn,Phone:Qn,MessageSquare:io,PenTool:d_,Video:Nn,Gift:po},_ms={"Top 25":"bg-primary text-primary-foreground","Past Client":"bg-sky-500 text-white","Referral Partner":"bg-orange-500 text-white",Sphere:"bg-emerald-500 text-white",VIP:"bg-amber-500 text-white"};function bms(){var $e,ct,qe,Ze,Qe,We;const t=Pr(),{user:s}=Hs(),{data:r}=Rf(),{data:n}=vVe(),{data:a}=tm(),{data:o}=UL(),{data:l}=NVe(),i=S5t(),d=gbe(),u=N5t(90),p=fbe(),[f,y]=C.useState(null),[_,b]=C.useState(null),[w,j]=C.useState(!1),[k,S]=C.useState(""),[T,I]=C.useState(!1),[L,R]=C.useState(""),[$,q]=C.useState(Zne()),[U,H]=C.useState("cards"),[Y,se]=C.useState(!1),[te,Q]=C.useState(null),[de,re]=C.useState(null),[ae,le]=C.useState(""),{isGmailConnected:he,gmailEmail:be}=Ny(),_e=()=>{const He=parseInt(L,10);if(isNaN(He)||He<1){pn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}q(He),jVe(He),I(!1),pn({title:"Goal updated",description:`Weekly touch goal set to ${He}`})},je=()=>{R($.toString()),I(!0)};C.useEffect(()=>{(async()=>{if(!(s!=null&&s.id))return;const{data:et}=await G.from("profiles").select("name").eq("id",s.id).single();et!=null&&et.name&&S(et.name.split(" ")[0])})()},[s==null?void 0:s.id]),C.useEffect(()=>{i.mutate()},[]);const Ne=Zh(new Date),Ge=ml(Ne,7),we=He=>{if(!He)return null;const et=He.split(/[-/T]/);if(et.length<3)return null;const Tt=parseInt(et[1],10)-1,Ft=parseInt(et[2],10);return isNaN(Tt)||isNaN(Ft)?null:new Date(Ne.getFullYear(),Tt,Ft)},Me=(a==null?void 0:a.filter(He=>{const et=we(He.birthday),Tt=we(He.home_anniversary);return et&&cl(et,Ne)||Tt&&cl(Tt,Ne)}))||[];a!=null&&a.filter(He=>{if(!He.birthday&&!He.home_anniversary)return!1;const et=Tt=>{if(!Tt)return!1;const Ft=we(Tt);return Ft?Rk(Ft,Ne)&&Fk(Ft,Ge):!1};return et(He.birthday)||et(He.home_anniversary)}).slice(0,5);const Te=[],Fe=(o==null?void 0:o.find(He=>He.name==="Call"))||(o==null?void 0:o[0]);for(const He of Me){const et=we(He.birthday),Tt=we(He.home_anniversary),Ft=et&&cl(et,Ne),as=Tt&&cl(Tt,Ne);Ft&&Te.push({contact:He,actionType:Fe||{id:"special-date-birthday",name:"Birthday Call",icon:"Cake",color:"#EC4899",description:"Wish them happy birthday!",active:!0,sort_order:0,created_at:"",updated_at:""},planName:"🎂 Birthday Today!",relationshipTypeName:((qe=(ct=($e=He.tags)==null?void 0:$e[0])==null?void 0:ct.relationship_type)==null?void 0:qe.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"birthday"}),as&&Te.push({contact:He,actionType:Fe||{id:"special-date-anniversary",name:"Anniversary Call",icon:"Home",color:"#8B5CF6",description:"Celebrate their home anniversary!",active:!0,sort_order:0,created_at:"",updated_at:""},planName:"🏠 Home Anniversary!",relationshipTypeName:((We=(Qe=(Ze=He.tags)==null?void 0:Ze[0])==null?void 0:Qe.relationship_type)==null?void 0:We.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"anniversary"})}const Ue=l!==void 0?l||[]:(a==null?void 0:a.slice(0,5).map((He,et)=>{var Ft,as,Xt;const Tt=o==null?void 0:o[et%((o==null?void 0:o.length)||1)];return Tt?{contact:He,actionType:Tt,planName:"Quick Touch",relationshipTypeName:((Xt=(as=(Ft=He.tags)==null?void 0:Ft[0])==null?void 0:as.relationship_type)==null?void 0:Xt.name)||"",monthNumber:0}:null}).filter(Boolean))||[],ut=[...Te,...Ue],De=async(He,et,Tt)=>{await p.mutateAsync({contactId:He,actionTypeId:et,scriptUsedId:Tt}),j(!1),b(null)},Rt=He=>{He.script?(b(He),j(!0)):De(He.contact.id,He.actionType.id)},me=He=>MLe[He||"Phone"]||Qn,Xe=He=>MLe[He||"Users"]||hr,ot=(He,et)=>He.replace(/\{\{FirstName\}\}/g,et.first_name).replace(/\{\{LastName\}\}/g,et.last_name||"").replace(/\{\{AgentName\}\}/g,k||"there"),nt=(He,et)=>({Call:`Thinking of you, ${et}!`,Text:`Quick hello, ${et}`,Email:`Checking in, ${et}`,"Handwritten Note":`A note for ${et}`,Video:`Video message for ${et}`,Gift:`Something special for you, ${et}`})[He]||`Hello ${et}!`,Se=(He,et,Tt)=>{const Ft=`sms:${He}`;if(et&&Tt){const as=ot(et,Tt);return`${Ft}?body=${encodeURIComponent(as)}`}return Ft},it=(He,et,Tt,Ft,as)=>{const Xt=`mailto:${He}`,ss=[];if(as){const is=Tt||nt(Ft||"Email",as.first_name);if(ss.push(`subject=${encodeURIComponent(is)}`),et){const ar=ot(et,as);ss.push(`body=${encodeURIComponent(ar)}`)}}return ss.length>0?`${Xt}?${ss.join("&")}`:Xt};return e.jsxs(e.Fragment,{children:[e.jsxs(Ts,{title:"Mission Control",description:"Your relationship-first contact system",children:[e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Mission Control"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Your Sphere"}),e.jsx("div",{className:"flex flex-wrap gap-3",children:r==null?void 0:r.filter(He=>He.active).map(He=>{const et=Xe(He.icon),Tt=(n==null?void 0:n[He.id])||0,Ft=f===He.id,as=_ms[He.name]||"bg-secondary text-secondary-foreground";return e.jsxs("button",{onClick:()=>{Ft?(y(null),t("/mission-control/contacts")):(y(He.id),t(`/mission-control/contacts?type=${He.id}`))},className:` flex items-center gap-2 px-4 py-3 rounded-lg border transition-all ${Ft?as:"bg-card hover:bg-accent"} `,children:[e.jsx(et,{className:"h-5 w-5"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:He.name}),e.jsxs("div",{className:`text-sm ${Ft?"opacity-90":"text-muted-foreground"}`,children:[Tt," Contacts"]})]})]},He.id)})})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),className:"w-full bg-gradient-to-r from-primary to-primary/80",children:[e.jsx(lu,{className:"h-4 w-4 mr-1"}),"Quick Video"]}),e.jsxs(K,{onClick:()=>t("/mission-control/contacts"),className:"w-full",variant:"outline",children:["View Contacts",e.jsx(Ua,{className:"h-4 w-4 ml-1"})]}),e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/video-library"),className:"w-full",children:"Video Library"}),e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/plans"),className:"w-full",children:"Manage Plans"})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Today in Your InnerCircle"}),l!==void 0&&e.jsxs(rt,{variant:"outline",className:"gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),"Plan-based"]}),e.jsxs("div",{className:"ml-auto flex items-center gap-1 border rounded-lg p-0.5",children:[e.jsx(K,{variant:U==="cards"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>H("cards"),title:"Card view",children:e.jsx(yp,{className:"h-4 w-4"})}),e.jsx(K,{variant:U==="table"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>H("table"),title:"Table view",children:e.jsx(Hh,{className:"h-4 w-4"})})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:ut.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No actions scheduled for today."}),e.jsx("p",{className:"text-sm mt-1",children:"Add contacts and enable touchpoint plans to get started."}),e.jsx(K,{variant:"outline",className:"mt-4",onClick:()=>t("/mission-control/plans"),children:"Manage Plans"})]}):U==="table"?e.jsx(mms,{actions:ut,onMarkComplete:De,onViewScript:Rt,isLoading:p.isPending,buildSmsLink:Se,buildEmailLink:it,onGmailCompose:he?He=>{Q(He),se(!0)}:void 0}):e.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[ut.map((He,et)=>{var Ct,Is,qs,gr,Wn,ii,bo;const Tt=He.isSpecialDate,Ft=He.specialDateType,as=Tt?Ft==="birthday"?zu:On:me(((Ct=He.actionType)==null?void 0:Ct.icon)||null),Xt=He.contact.phone,ss=He.contact.email,is=Tt?Ft==="birthday"?"#EC4899":"#8B5CF6":((Is=He.actionType)==null?void 0:Is.color)||"#3B82F6",ar=Tt?Ft==="birthday"?"🎂 Birthday Today!":"🏠 Home Anniversary!":(qs=He.actionType)==null?void 0:qs.name;return e.jsxs("div",{className:`flex-shrink-0 w-[260px] border rounded-lg overflow-hidden ${Tt?"ring-2 ring-offset-2":""}`,style:Tt?{"--tw-ring-color":is}:void 0,children:[e.jsxs("div",{className:"p-3 text-white flex items-center gap-2",style:{backgroundColor:is},children:[e.jsx(as,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:ar})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("button",{onClick:()=>t(`/mission-control/contacts/${He.contact.id}`),className:"font-medium text-sm hover:text-primary hover:underline transition-colors text-left",children:[He.contact.first_name," ",He.contact.last_name]}),e.jsxs("div",{className:"flex gap-1.5",children:[Xt&&e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:`tel:${He.contact.phone}`,className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-primary/10 hover:bg-primary/20 text-primary rounded text-xs font-medium transition-colors",title:"Call",children:[e.jsx(Qn,{className:"h-3 w-3"}),"Call"]}),e.jsxs("a",{href:Se(He.contact.phone,(gr=He.script)==null?void 0:gr.script_body,He.contact),className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 rounded text-xs font-medium transition-colors",title:"Text",children:[e.jsx(io,{className:"h-3 w-3"}),"Text"]})]}),ss&&(he?e.jsxs("button",{onClick:()=>{Q({id:He.contact.id,first_name:He.contact.first_name,last_name:He.contact.last_name,email:He.contact.email}),se(!0)},className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 rounded text-xs font-medium transition-colors",title:"Compose Email",children:[e.jsx(br,{className:"h-3 w-3"}),"Email"]}):e.jsxs("a",{href:it(He.contact.email,(Wn=He.script)==null?void 0:Wn.script_body,(ii=He.script)==null?void 0:ii.email_subject,(bo=He.actionType)==null?void 0:bo.name,He.contact),className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 rounded text-xs font-medium transition-colors",title:"Email",children:[e.jsx(br,{className:"h-3 w-3"}),"Email"]}))]}),Tt&&e.jsxs("button",{onClick:()=>{const si=`${He.contact.first_name}${He.contact.last_name?" "+He.contact.last_name:""}`,nn=Ft==="birthday"?"birthday":"home_anniversary",ia=new URLSearchParams({cardType:nn,contactId:He.contact.id,name:si,...He.contact.address?{address:He.contact.address}:{},...Ft==="anniversary"&&He.contact.home_anniversary?{date:He.contact.home_anniversary}:{}});t(`/mission-control/card-studio?${ia.toString()}`)},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 rounded text-xs font-semibold bg-gradient-to-r from-pink-500/15 to-violet-500/15 hover:from-pink-500/25 hover:to-violet-500/25 text-pink-600 dark:text-pink-400 transition-colors",children:[e.jsx(br,{className:"h-3 w-3"}),"Send ",Ft==="birthday"?"Birthday":"Anniversary"," Card"]}),!Xt&&!ss&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No contact info"}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[He.relationshipTypeName&&e.jsx(rt,{variant:"secondary",className:"text-xs",children:He.relationshipTypeName}),He.monthNumber>0&&e.jsxs(rt,{variant:"outline",className:"text-xs",children:["Month ",He.monthNumber]})]}),He.script&&e.jsx(K,{size:"sm",variant:"outline",className:"w-full",onClick:()=>Rt(He),children:"View Script"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1 gap-1",onClick:()=>{re(He.contact.id),le(`${He.contact.first_name} ${He.contact.last_name||""}`.trim())},children:[e.jsx(vp,{className:"h-3.5 w-3.5"}),"Snooze"]}),e.jsx(K,{size:"sm",className:"flex-1",onClick:()=>{var si;return De(He.contact.id,He.actionType.id,(si=He.script)==null?void 0:si.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]},He.contact.id+et)}),e.jsx("div",{className:"flex-shrink-0 w-[100px] border rounded-lg flex items-center justify-center",children:e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"h-full w-full",children:[e.jsx(of,{className:"h-5 w-5 mr-2"}),"More"]})}),e.jsx(Md,{children:e.jsx(Na,{onClick:()=>t("/mission-control/contacts"),children:"View all contacts"})})]})})]})})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ot,{className:"text-lg",children:"Momentum"}),e.jsxs(_s,{open:T,onOpenChange:I,children:[e.jsx(Ei,{asChild:!0,children:e.jsx("button",{onClick:je,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx($l,{className:"h-4 w-4 text-muted-foreground hover:text-primary"})})}),e.jsxs(vs,{className:"sm:max-w-[360px]",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Set Weekly Goal"}),e.jsx(Kr,{children:"How many touches do you want to complete each week?"})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"weekly-goal-ic",children:"Weekly touch goal"}),e.jsx(Re,{id:"weekly-goal-ic",type:"number",min:"1",value:L,onChange:He=>R(He.target.value),placeholder:"20",onKeyDown:He=>{He.key==="Enter"&&_e()}})]}),e.jsx(K,{onClick:_e,className:"w-full",children:"Save Goal"})]})]})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Ti,{value:Math.min(d.actionsThisWeek/$*100,100),className:"h-3 w-full max-w-full"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(nh,{className:"h-5 w-5 text-orange-500"}),e.jsxs("span",{className:"font-medium",children:[d.actionsThisWeek," / ",$]}),e.jsx("span",{className:"text-muted-foreground",children:"Actions Completed This Week"})]}),d.streak>0&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-lg",children:"🔥"}),e.jsx("span",{className:"font-medium",children:"Great Job!"}),e.jsxs("span",{className:"text-muted-foreground",children:["Keep Your Streak Going! (",d.streak," days)"]})]}),u.count>0&&e.jsxs("button",{onClick:()=>t("/mission-control/contacts?filter=not-touched-90"),className:"flex items-start gap-2 text-sm pt-2 border-t w-full text-left hover:bg-accent/50 -mx-4 px-4 py-2 rounded-md transition-colors",children:[e.jsx(Tn,{className:"h-4 w-4 text-orange-500 mt-0.5"}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-orange-600 dark:text-orange-400",children:[u.count," Contact",u.count!==1?"s":""]}),e.jsx("span",{className:"text-muted-foreground",children:" Not Reached in 90+ Days"})]}),e.jsx(Ua,{className:"h-4 w-4 text-muted-foreground ml-auto mt-0.5"})]})]})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsx(zVe,{}),e.jsx(vms,{})]})]}),e.jsx(_s,{open:w,onOpenChange:j,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsx(ks,{className:"flex items-center gap-2",children:_&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:_.actionType.color||"#3B82F6"}}),_.actionType.name," Script"]})})}),_&&_.script&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["For: ",e.jsxs("span",{className:"font-medium text-foreground",children:[_.contact.first_name," ",_.contact.last_name]})]}),e.jsx("div",{className:"bg-muted p-4 rounded-lg",children:e.jsx("p",{className:"whitespace-pre-wrap",children:ot(_.script.script_body,_.contact)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>j(!1),children:"Close"}),e.jsx(K,{className:"flex-1",onClick:()=>{var He;return De(_.contact.id,_.actionType.id,(He=_.script)==null?void 0:He.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]})}),e.jsx(oms,{})]}),he&&te&&e.jsx(JM,{open:Y,onOpenChange:se,contact:te,gmailEmail:be}),e.jsx(Dce,{open:!!de,onOpenChange:He=>!He&&re(null),contactId:de||"",contactName:ae})]})}var aJe="Toggle",z2e=C.forwardRef((t,s)=>{const{pressed:r,defaultPressed:n,onPressedChange:a,...o}=t,[l,i]=vu({prop:r,onChange:a,defaultProp:n??!1,caller:aJe});return e.jsx(Qr.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":t.disabled?"":void 0,...o,ref:s,onClick:Mr(t.onClick,()=>{t.disabled||i(!l)})})});z2e.displayName=aJe;var iJe=z2e,ob="ToggleGroup",[oJe]=Ec(ob,[K_]),lJe=K_(),B2e=ht.forwardRef((t,s)=>{const{type:r,...n}=t;if(r==="single"){const a=n;return e.jsx(wms,{...a,ref:s})}if(r==="multiple"){const a=n;return e.jsx(jms,{...a,ref:s})}throw new Error(`Missing prop \`type\` expected on \`${ob}\``)});B2e.displayName=ob;var[cJe,dJe]=oJe(ob),wms=ht.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=vu({prop:r,defaultProp:n??"",onChange:a,caller:ob});return e.jsx(cJe,{scope:t.__scopeToggleGroup,type:"single",value:ht.useMemo(()=>l?[l]:[],[l]),onItemActivate:i,onItemDeactivate:ht.useCallback(()=>i(""),[i]),children:e.jsx(uJe,{...o,ref:s})})}),jms=ht.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=vu({prop:r,defaultProp:n??[],onChange:a,caller:ob}),d=ht.useCallback(p=>i((f=[])=>[...f,p]),[i]),u=ht.useCallback(p=>i((f=[])=>f.filter(y=>y!==p)),[i]);return e.jsx(cJe,{scope:t.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:d,onItemDeactivate:u,children:e.jsx(uJe,{...o,ref:s})})});B2e.displayName=ob;var[Nms,kms]=oJe(ob),uJe=ht.forwardRef((t,s)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:o,dir:l,loop:i=!0,...d}=t,u=lJe(r),p=G_(l),f={role:"group",dir:p,...d};return e.jsx(Nms,{scope:r,rovingFocus:a,disabled:n,children:a?e.jsx(koe,{asChild:!0,...u,orientation:o,dir:p,loop:i,children:e.jsx(Qr.div,{...f,ref:s})}):e.jsx(Qr.div,{...f,ref:s})})}),Wie="ToggleGroupItem",hJe=ht.forwardRef((t,s)=>{const r=dJe(Wie,t.__scopeToggleGroup),n=kms(Wie,t.__scopeToggleGroup),a=lJe(t.__scopeToggleGroup),o=r.value.includes(t.value),l=n.disabled||t.disabled,i={...t,pressed:o,disabled:l},d=ht.useRef(null);return n.rovingFocus?e.jsx(Soe,{asChild:!0,...a,focusable:!l,active:o,ref:d,children:e.jsx(TLe,{...i,ref:s})}):e.jsx(TLe,{...i,ref:s})});hJe.displayName=Wie;var TLe=ht.forwardRef((t,s)=>{const{__scopeToggleGroup:r,value:n,...a}=t,o=dJe(Wie,r),l={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},i=o.type==="single"?l:void 0;return e.jsx(z2e,{...i,...a,ref:s,onPressedChange:d=>{d?o.onItemActivate(n):o.onItemDeactivate(n)}})}),mJe=B2e,pJe=hJe;const fJe=nS("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),Sms=C.forwardRef(({className:t,variant:s,size:r,...n},a)=>e.jsx(iJe,{ref:a,className:Pt(fJe({variant:s,size:r,className:t})),...n}));Sms.displayName=iJe.displayName;const gJe=C.createContext({size:"default",variant:"default"}),xJe=C.forwardRef(({className:t,variant:s,size:r,children:n,...a},o)=>e.jsx(mJe,{ref:o,className:Pt("flex items-center justify-center gap-1",t),...a,children:e.jsx(gJe.Provider,{value:{variant:s,size:r},children:n})}));xJe.displayName=mJe.displayName;const yJe=C.forwardRef(({className:t,children:s,variant:r,size:n,...a},o)=>{const l=C.useContext(gJe);return e.jsx(pJe,{ref:o,className:Pt(fJe({variant:l.variant||r,size:l.size||n}),t),...a,children:s})});yJe.displayName=pJe.displayName;const Cms=[{value:"bidirectional",label:"Two-Way",icon:Hc,tooltip:"Sync contacts in both directions"},{value:"push_only",label:"Push Only",icon:Vd,tooltip:"Only push Agent OS → BoldTrail"},{value:"pull_only",label:"Pull Only",icon:sh,tooltip:"Only pull BoldTrail → Agent OS"}];function Y0e({value:t,onChange:s,size:r="default"}){const n=r==="sm"?"text-xs":"text-sm";return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:`font-medium ${n} text-muted-foreground`,children:"Sync Direction"}),e.jsx(xJe,{type:"single",value:t,onValueChange:a=>{a&&s(a)},className:"justify-start",children:Cms.map(a=>e.jsxs(Wc,{children:[e.jsx(Gc,{asChild:!0,children:e.jsxs(yJe,{value:a.value,"aria-label":a.tooltip,className:`gap-1.5 ${n} border border-transparent data-[state=on]:!bg-primary data-[state=on]:!text-primary-foreground data-[state=on]:!border-primary data-[state=on]:shadow-sm`,children:[e.jsx(a.icon,{className:r==="sm"?"h-3 w-3":"h-4 w-4"}),a.label]})}),e.jsx(Cc,{children:a.tooltip})]},a.value))})]})}function Mms(){const t=rs(),[s,r]=C.useState(!1),[n,a]=C.useState(null),[o,l]=C.useState(!1),[i,d]=C.useState(!1),[u,p]=C.useState(null),[f,y]=C.useState(null),[_,b]=C.useState(0),w=C.useRef(!1),{data:j}=wt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:$,error:q}=await G.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(q)throw q;return $}}),k=(j==null?void 0:j.sync_direction)||"bidirectional",S=u??k,T=Dt({mutationFn:async()=>{const{data:$,error:q}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(q)throw q;if($!=null&&$.error)throw new Error($.error);return $},onSuccess:$=>{p(null),a($),r(!0)},onError:$=>{fe.error($.message||"Failed to generate sync preview")}}),I=Dt({mutationFn:async()=>{w.current=!1,y("Initializing sync..."),b(5);const{data:$,error:q}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:S}});if(q)throw q;if($!=null&&$.error)throw new Error($.error);const U=$;let H=U.sync_log_id,Y=U.next_phase,se=U.next_offset;const te=U.push_total||0,Q=U.pull_total||0,de=te+Q;let re=0,ae=0;for(;Y!=="finalize"&&!w.current;){Y==="push"?(y(`Pushing contacts to BoldTrail... (${re}/${te})`),b(de>0?re/de*100:0)):Y==="pull"&&(y(`Pulling contacts from BoldTrail... (${ae}/${Q})`),b(de>0?(te+ae)/de*100:0));const{data:be,error:_e}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:Y,offset:se,sync_log_id:H,sync_direction:S}});if(_e)throw _e;if(be!=null&&be.error)throw new Error(be.error);const je=be;re+=je.chunk_pushed||0,ae+=je.chunk_pulled||0,je.progress&&y(je.progress),Y==="pull"&&Q>0?b(Math.min(95,ae/Q*100)):Y==="push"&&te>0&&b(Math.min(95,re/te*100)),Y=je.next_phase,se=je.next_offset}y("Finalizing sync..."),b(95);const{data:le,error:he}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:H,sync_direction:S}});if(he)throw he;return b(100),le},onSuccess:$=>{y(null),b(0),r(!1),t.invalidateQueries({queryKey:["boldtrail-status"]}),t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),fe.success(`Sync complete! Pushed ${$.contacts_pushed||0}, pulled ${$.contacts_pulled||0}, skipped ${$.contacts_skipped||0} duplicates.`)},onError:$=>{y(null),b(0),fe.error($.message||"Sync failed")}});if(!(j!=null&&j.connected))return null;const L=S==="pull_only"?0:(n==null?void 0:n.to_push)??0,R=S==="push_only"?0:(n==null?void 0:n.to_pull)??0;return e.jsxs(e.Fragment,{children:[e.jsxs(Wc,{children:[e.jsx(Gc,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"icon",onClick:()=>T.mutate(),disabled:T.isPending,className:"shrink-0",children:T.isPending?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Hc,{className:"h-4 w-4 text-emerald-600"})})}),e.jsx(Cc,{children:"Sync with BoldTrail"})]}),e.jsx(_s,{open:s,onOpenChange:$=>{I.isPending||r($)},children:e.jsxs(vs,{className:"sm:max-w-lg",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(Hc,{className:"h-5 w-5 text-emerald-600"}),"Sync Preview"]}),e.jsx(Kr,{children:"Review what will happen when you sync your contacts."})]}),n&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(Y0e,{value:S,onChange:p,size:"sm"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-center ${S==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:L}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Vd,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${S==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:R}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(sh,{className:"h-3 w-3"})," Pull to Agent OS"]})]}),e.jsxs("div",{className:"rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-muted-foreground",children:n.already_synced}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(hr,{className:"h-3 w-3"})," Already synced"]})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["Agent OS: ",n.agent_os_total," contacts · BoldTrail: ",n.boldtrail_total," contacts"]}),L>0&&e.jsxs(bf,{open:o,onOpenChange:l,children:[e.jsx(wf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Vd,{className:"h-3 w-3 text-emerald-600"}),L," contacts to push to BoldTrail"]}),e.jsx(Ho,{className:`h-3 w-3 transition-transform ${o?"rotate-180":""}`})]})}),e.jsx(jf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.push_preview.map(($,q)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:$.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:$.email})]},q)),n.to_push>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",n.to_push-20," more"]})]})})]}),R>0&&e.jsxs(bf,{open:i,onOpenChange:d,children:[e.jsx(wf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(sh,{className:"h-3 w-3 text-blue-600"}),R," contacts to pull from BoldTrail"]}),e.jsx(Ho,{className:`h-3 w-3 transition-transform ${i?"rotate-180":""}`})]})}),e.jsx(jf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.pull_preview.map(($,q)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:$.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:$.email})]},q)),n.to_pull>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",n.to_pull-20," more"]})]})})]}),L===0&&R===0&&!I.isPending&&e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"✅ Everything is already in sync! No contacts to transfer."}),I.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(Ti,{value:_||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:f||"Sync in progress..."})]}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>r(!1),disabled:I.isPending,children:"Cancel"}),e.jsxs(K,{onClick:()=>I.mutate(),disabled:I.isPending||L===0&&R===0,className:"gap-2",children:[I.isPending?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Hc,{className:"h-4 w-4"}),I.isPending?"Syncing...":"Sync Now"]})]})]})]})})]})}const Tms=()=>{const{user:t}=Hs();return wt({queryKey:["popby-items",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("popby_items").select("*").or(`owner_user_id.is.null,owner_user_id.eq.${t==null?void 0:t.id}`).eq("is_active",!0).order("name");if(r)throw r;return s},enabled:!!t})},Oce=t=>{const{user:s}=Hs();return wt({queryKey:["popby-logs",s==null?void 0:s.id,t],queryFn:async()=>{let r=G.from("popby_logs").select("*").order("completed_at",{ascending:!1});if(t){const o=new Date;o.setDate(o.getDate()-t),r=r.gte("completed_at",o.toISOString())}const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!s})},$2e=()=>{const{user:t}=Hs();return wt({queryKey:["relationship-type-popby-defaults",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("relationship_type_popby_defaults").select("*");if(r)throw r;return s},enabled:!!t})},vJe=()=>{const{user:t}=Hs();return wt({queryKey:["contact-popby-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_popby_settings").select("*");if(r)throw r;return s},enabled:!!t})},Ams=()=>{const{data:t}=tm(),{data:s}=Rf(),{data:r}=Oce(),{data:n}=vJe(),{data:a}=$2e(),o=new Map;r==null||r.forEach(p=>{const f=o.get(p.contact_id);(!f||new Date(p.completed_at)>new Date(f))&&o.set(p.contact_id,p.completed_at)});const l=new Map;a==null||a.forEach(p=>l.set(p.relationship_type_id,p.frequency_days));const i=new Map;n==null||n.filter(p=>p.is_active).forEach(p=>{i.set(p.contact_id,p.frequency_days)});const d=Zh(new Date);return(t||[]).map(p=>{let f=90;if(i.has(p.id))f=i.get(p.id);else if(p.tags&&p.tags.length>0){const j=p.tags.map(k=>l.get(k.relationship_type_id)).filter(k=>k!==void 0);j.length>0&&(f=Math.min(...j))}const y=o.get(p.id)||null,_=y?Qg(d,Zh(new Date(y))):null,b=_===null||_>=f,w=b&&_!==null?_-f:0;return{...p,lastPopby:y,daysSinceLastPopby:_,frequencyDays:f,isDue:b,daysOverdue:w}}).sort((p,f)=>f.daysOverdue-p.daysOverdue)},_Je=()=>Ams().filter(s=>s.isDue),Ems=()=>{const t=rs(),{user:s}=Hs();return Dt({mutationFn:async r=>{const{error:n}=await G.from("popby_items").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-items"]}),pn({title:"Popby item created!"})},onError:r=>{pn({title:"Error creating popby item",description:r.message,variant:"destructive"})}})},Pms=()=>{const t=rs(),{user:s}=Hs();return Dt({mutationFn:async r=>{const{error:n}=await G.from("popby_logs").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-logs"]}),pn({title:"Popby logged!"})},onError:r=>{pn({title:"Error logging popby",description:r.message,variant:"destructive"})}})},Ims=()=>{const t=rs(),{user:s}=Hs();return Dt({mutationFn:async r=>{const{error:n}=await G.from("relationship_type_popby_defaults").upsert({...r,owner_user_id:s==null?void 0:s.id},{onConflict:"relationship_type_id,owner_user_id"});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["relationship-type-popby-defaults"]}),pn({title:"Frequency updated!"})},onError:r=>{pn({title:"Error updating frequency",description:r.message,variant:"destructive"})}})},Lms=()=>{const{data:t}=Oce(30),s=_Je(),r=new Date;r.setDate(r.getDate()-7);const n=(t==null?void 0:t.filter(o=>new Date(o.completed_at)>=r).length)||0,a=(t==null?void 0:t.length)||0;return{thisWeekCount:n,thisMonthCount:a,dueCount:s.length}};function Dms(){const{user:t}=Hs();return wt({queryKey:["contact-touch-logs",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_touch_logs").select("*").order("completed_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function bJe(t){const{data:s}=Dms(),{data:r}=vJe(),{data:n}=$2e(),{data:a}=lms();return C.useMemo(()=>{const o=a==null?void 0:a.find(j=>j.contact_id===t.id),l=o?new Date(o.snoozed_until):null,i=Zh(new Date);if(l&&!Fk(l,i))return{nextTouchDate:l,daysUntil:Qg(l,i),status:"snoozed",frequencyDays:90,lastTouchDate:null,snoozedUntil:l};const u=((s==null?void 0:s.filter(j=>j.contact_id===t.id))||[]).sort((j,k)=>new Date(k.completed_at).getTime()-new Date(j.completed_at).getTime())[0],p=u?new Date(u.completed_at):null;let f=90;const y=r==null?void 0:r.find(j=>j.contact_id===t.id&&j.is_active);if(y)f=y.frequency_days;else if(t.tags&&t.tags.length>0){const j=t.tags.map(k=>{const S=n==null?void 0:n.find(T=>T.relationship_type_id===k.relationship_type_id);return S==null?void 0:S.frequency_days}).filter(k=>k!==void 0);j.length>0&&(f=Math.min(...j))}if(!p)return{nextTouchDate:null,daysUntil:null,status:"never-touched",frequencyDays:f,lastTouchDate:null,snoozedUntil:null};const _=ml(Zh(p),f),b=Qg(_,i);let w;return b<0?w="overdue":b<=7?w="due-soon":w="on-track",{nextTouchDate:_,daysUntil:b,status:w,frequencyDays:f,lastTouchDate:p,snoozedUntil:null}},[t,s,r,n,a])}function X0e({contact:t}){const s=bJe(t),n=(()=>{switch(s.status){case"overdue":return{variant:"destructive",icon:ll,text:`${Math.abs(s.daysUntil)} days overdue`,className:""};case"due-soon":return{variant:"secondary",icon:Tn,text:s.daysUntil===0?"Due today":`Due in ${s.daysUntil} days`,className:"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400"};case"on-track":return{variant:"secondary",icon:ua,text:`Next touch in ${s.daysUntil} days`,className:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-400"};case"snoozed":return{variant:"secondary",icon:vp,text:`Snoozed until ${ys(s.snoozedUntil,"MMM d")}`,className:"bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300"};case"never-touched":return{variant:"outline",icon:on,text:"Never touched",className:"border-dashed"}}})(),a=n.icon;return e.jsxs(rt,{variant:n.variant,className:Pt("gap-1",n.className),children:[e.jsx(a,{className:"h-3 w-3"}),n.text]})}function Oms({contact:t,onLogTouch:s,onSnooze:r}){const n=bJe(t),a=dms(),[o,l]=C.useState(!1),i=()=>{switch(n.status){case"overdue":return"text-destructive";case"due-soon":return"text-amber-600 dark:text-amber-400";case"on-track":return"text-emerald-600 dark:text-emerald-400";case"snoozed":return"text-slate-600 dark:text-slate-400";case"never-touched":return"text-muted-foreground"}},d=()=>{switch(n.status){case"overdue":return e.jsx(ll,{className:"h-5 w-5 text-destructive"});case"due-soon":return e.jsx(Tn,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"});case"on-track":return e.jsx(ua,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"});case"snoozed":return e.jsx(vp,{className:"h-5 w-5 text-slate-600 dark:text-slate-400"});case"never-touched":return e.jsx(on,{className:"h-5 w-5 text-muted-foreground"})}},u=()=>{switch(n.status){case"overdue":return`${Math.abs(n.daysUntil)} days overdue`;case"due-soon":return n.daysUntil===0?"Due today!":`Due in ${n.daysUntil} days`;case"on-track":return`On track - ${n.daysUntil} days remaining`;case"snoozed":return`Snoozed for ${n.daysUntil} more days`;case"never-touched":return"No touches logged yet"}},p=async()=>{await a.mutateAsync(t.id)};return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Next Touch"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d(),e.jsx("span",{className:Pt("font-medium",i()),children:u()})]}),n.status==="snoozed"&&n.snoozedUntil&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Snoozed until:"})," ",ys(n.snoozedUntil,"MMMM d, yyyy")]}),n.status!=="snoozed"&&n.nextTouchDate&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Scheduled:"})," ",ys(n.nextTouchDate,"MMMM d, yyyy")]}),n.lastTouchDate&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Last touch:"})," ",ys(n.lastTouchDate,"MMM d, yyyy")]}),n.status!=="snoozed"&&e.jsxs("div",{className:"text-xs text-muted-foreground border-t pt-2",children:["Touch frequency: Every ",n.frequencyDays," days"]}),n.status==="snoozed"&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1",onClick:p,disabled:a.isPending,children:[e.jsx(Ur,{className:"h-4 w-4 mr-1"}),"Cancel Snooze"]}),s&&e.jsx(K,{size:"sm",className:"flex-1",onClick:s,children:"Log Touch"})]}),n.status!=="snoozed"&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>l(!0),children:[e.jsx(vp,{className:"h-4 w-4 mr-1"}),"Snooze"]}),(n.status==="overdue"||n.status==="due-soon"||n.status==="never-touched")&&s&&e.jsx(K,{size:"sm",className:"flex-1",variant:n.status==="overdue"?"default":"outline",onClick:s,children:"Log Touch"})]})]})]}),e.jsx(Dce,{open:o,onOpenChange:l,contactId:t.id,contactName:`${t.first_name} ${t.last_name||""}`.trim()})]})}const Ope=768;function eT(){const[t,s]=C.useState(void 0);return C.useEffect(()=>{const r=window.matchMedia(`(max-width: ${Ope-1}px)`),n=()=>{s(window.innerWidthr.removeEventListener("change",n)},[]),!!t}const Rms={warm:{label:"Warm",emoji:"🟢",bgClass:"bg-emerald-500",textClass:"text-emerald-600 dark:text-emerald-400",borderClass:"border-emerald-500",bgLightClass:"bg-emerald-500/10"},cooling:{label:"Cooling Off",emoji:"🟡",bgClass:"bg-amber-500",textClass:"text-amber-600 dark:text-amber-400",borderClass:"border-amber-500",bgLightClass:"bg-amber-500/10"},"at-risk":{label:"At Risk",emoji:"🔴",bgClass:"bg-red-500",textClass:"text-red-600 dark:text-red-400",borderClass:"border-red-500",bgLightClass:"bg-red-500/10"}},Fms={sm:{dot:"h-2 w-2",text:"text-xs",badge:"px-1.5 py-0.5 gap-1"},md:{dot:"h-2.5 w-2.5",text:"text-sm",badge:"px-2 py-1 gap-1.5"},lg:{dot:"h-3 w-3",text:"text-base",badge:"px-3 py-1.5 gap-2"}};function TI({score:t,showScore:s=!1,showTooltip:r=!0,size:n="sm",className:a}){const o=Rms[t.status],l=Fms[n],i=e.jsxs("div",{className:Pt("inline-flex items-center rounded-full font-medium",o.bgLightClass,o.textClass,l.badge,l.text,a),children:[e.jsx("span",{className:Pt("rounded-full",o.bgClass,l.dot)}),s?e.jsx("span",{children:t.score}):e.jsx("span",{children:o.label})]});return r?e.jsx(U_,{children:e.jsxs(Wc,{children:[e.jsx(Gc,{asChild:!0,children:i}),e.jsx(Cc,{side:"top",className:"w-64 p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-semibold",children:"Relationship Score"}),e.jsxs("span",{className:Pt("font-bold",o.textClass),children:[t.score,"/100"]})]}),e.jsx(Ti,{value:t.score,className:"h-2"}),e.jsxs("div",{className:"space-y-1.5 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Recency"}),e.jsxs("span",{children:[t.breakdown.recency,"/40"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Touchpoints (12mo)"}),e.jsxs("span",{children:[t.breakdown.touchpoints,"/30"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Transactions"}),e.jsxs("span",{children:[t.breakdown.transactions,"/20"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Referrals"}),e.jsxs("span",{children:[t.breakdown.referrals,"/10"]})]})]}),t.daysSinceTouch!==null&&e.jsxs("p",{className:"text-xs text-muted-foreground pt-1 border-t",children:["Last contact: ",t.daysSinceTouch===0?"Today":`${t.daysSinceTouch} days ago`]}),t.daysSinceTouch===null&&e.jsx("p",{className:"text-xs text-muted-foreground pt-1 border-t italic",children:"Never contacted"})]})})]})}):i}const zms=[{key:"first_name",label:"First Name",required:!0},{key:"last_name",label:"Last Name",required:!1},{key:"email",label:"Email",required:!1},{key:"phone",label:"Phone",required:!1},{key:"address",label:"Street Address",required:!1},{key:"city",label:"City",required:!1},{key:"state",label:"State",required:!1},{key:"zip",label:"Zip Code",required:!1},{key:"spouse_name",label:"Spouse Name",required:!1},{key:"spouse_email",label:"Spouse Email",required:!1},{key:"company_name",label:"Company",required:!1},{key:"job_title",label:"Job Title",required:!1},{key:"birthday",label:"Birthday",required:!1},{key:"home_anniversary",label:"Home Anniversary",required:!1},{key:"notes",label:"Notes",required:!1}],RR=t=>{if(!t||!t.trim())return null;const s=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(s))return s;const r=s.match(/^(\d{1,2})[\/\-](\d{1,2})(?:[\/\-](\d{2,4}))?$/);if(r){const a=r[1].padStart(2,"0"),o=r[2].padStart(2,"0");let l="2000";r[3]&&(l=r[3].length===2?(parseInt(r[3])>50?"19":"20")+r[3]:r[3]);const i=parseInt(a),d=parseInt(o);if(i>=1&&i<=12&&d>=1&&d<=31)return`${l}-${a}-${o}`}const n=new Date(s);return isNaN(n.getTime())?null:n.toISOString().split("T")[0]},Bms=({open:t,onOpenChange:s,relationshipTypes:r,onSuccess:n})=>{const{user:a}=Hs(),{toast:o}=Pa(),l=C.useRef(null),[i,d]=C.useState("upload"),[u,p]=C.useState([]),[f,y]=C.useState([]),[_,b]=C.useState({}),[w,j]=C.useState([]),[k,S]=C.useState([]),[T,I]=C.useState(!1),[L,R]=C.useState(null),$=()=>{d("upload"),p([]),y([]),b({}),j([]),S([]),R(null),l.current&&(l.current.value="")},q=()=>{$(),s(!1)},U=be=>{const _e=be.split(` `).map(we=>we.trim()).filter(we=>we);if(_e.length===0)return{headers:[],data:[]};const je=we=>{const Me=[];let Te="",Fe=!1;for(let Ae=0;Ae{var Ne;const _e=(Ne=be.target.files)==null?void 0:Ne[0];if(!_e)return;const je=new FileReader;je.onload=Ge=>{var Ae;const we=(Ae=Ge.target)==null?void 0:Ae.result,{headers:Me,data:Te}=U(we);if(Me.length===0){o({title:"No data found",description:"The CSV file appears to be empty.",variant:"destructive"});return}p(Me),y(Te);const Fe={};Me.forEach(Ue=>{const ut=Ue.toLowerCase().replace(/[_\s-]/g,"");ut.includes("firstname")||ut==="first"?Fe.first_name=Ue:ut.includes("lastname")||ut==="last"?Fe.last_name=Ue:ut.includes("spouse")&&ut.includes("email")?Fe.spouse_email=Ue:ut.includes("spouse")||ut.includes("partner")?Fe.spouse_name=Ue:ut.includes("email")?Fe.email=Ue:ut.includes("phone")||ut.includes("mobile")||ut.includes("cell")?Fe.phone=Ue:ut.includes("address")||ut.includes("street")?Fe.address=Ue:ut==="city"?Fe.city=Ue:ut==="state"||ut==="province"?Fe.state=Ue:ut==="zip"||ut==="zipcode"||ut==="postalcode"?Fe.zip=Ue:ut.includes("company")||ut.includes("organization")||ut.includes("business")?Fe.company_name=Ue:ut.includes("jobtitle")||ut.includes("title")&&!ut.includes("spouse")?Fe.job_title=Ue:ut.includes("birthday")||ut.includes("dob")||ut.includes("birthdate")?Fe.birthday=Ue:ut.includes("anniversary")||ut.includes("homeanniversary")?Fe.home_anniversary=Ue:(ut.includes("notes")||ut.includes("comment"))&&(Fe.notes=Ue)}),b(Fe),d("mapping")},je.readAsText(_e)},Y=(be,_e)=>{b(je=>{if(_e==="none"){const{[be]:Ne,...Ge}=je;return Ge}return{...je,[be]:_e}})},se=be=>{j(_e=>_e.includes(be)?_e.filter(je=>je!==be):[..._e,be])},te=async()=>{if(!(a!=null&&a.id))return;const{data:be}=await G.from("innercircle_contacts").select("id, email, phone").eq("owner_user_id",a.id),_e=new Set((be||[]).filter(Ge=>Ge.email).map(Ge=>Ge.email.toLowerCase())),je=new Set((be||[]).filter(Ge=>Ge.phone).map(Ge=>Ge.phone.replace(/[^0-9]/g,""))),Ne=f.map(Ge=>{const we=ut=>{const De=_[ut];if(!De)return"";const Rt=u.indexOf(De);return Rt>=0?(Ge[Rt]||"").trim():""},Me=we("first_name"),Te=we("email"),Fe=we("phone"),Ae=Me.length>0,Ue=!!(Te&&_e.has(Te.toLowerCase())||Fe&&je.has(Fe.replace(/[^0-9]/g,"")));return{first_name:Me,last_name:we("last_name"),email:Te,phone:Fe,address:we("address"),city:we("city"),state:we("state"),zip:we("zip"),spouse_name:we("spouse_name"),spouse_email:we("spouse_email"),company_name:we("company_name"),job_title:we("job_title"),birthday:we("birthday"),home_anniversary:we("home_anniversary"),notes:we("notes"),isValid:Ae,isDuplicate:Ue,error:Ae?void 0:"First name is required"}});S(Ne),d("preview")},Q=be=>{const _e=be.trim().split(/\s+/);return{first_name:_e[0],last_name:_e.length>1?_e.slice(1).join(" "):null}},de=async()=>{if(!(a!=null&&a.id))return;const be=k.filter(Ge=>Ge.isValid);if(be.length===0){o({title:"No valid contacts",description:"There are no valid contacts to import.",variant:"destructive"});return}I(!0);let _e=0,je=0,Ne=0;try{for(const Ge of be)try{let we=null;if(Ge.email){const{data:Fe}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Ge.email).maybeSingle();we=Fe}if(!we&&Ge.phone){const Fe=Ge.phone.replace(/[^0-9]/g,""),{data:Ae}=await G.from("innercircle_contacts").select("id, phone").eq("owner_user_id",a.id).not("phone","is",null);if(Ae){const Ue=Ae.find(ut=>ut.phone&&ut.phone.replace(/[^0-9]/g,"")===Fe);Ue&&(we={id:Ue.id})}}const Me={owner_user_id:a.id,first_name:Ge.first_name,last_name:Ge.last_name||null,email:Ge.email||null,phone:Ge.phone||null,address:Ge.address||null,city:Ge.city||null,state:Ge.state||null,zip:Ge.zip||null,spouse_name:Ge.spouse_name||null,spouse_email:Ge.spouse_email||null,company_name:Ge.company_name||null,job_title:Ge.job_title||null,birthday:RR(Ge.birthday),home_anniversary:RR(Ge.home_anniversary),notes:Ge.notes||null};let Te=null;if(we){const{data:Fe}=await G.from("innercircle_contacts").select("*").eq("id",we.id).single();if(Fe){const Ae={},Ue=["last_name","email","phone","address","city","state","zip","spouse_name","spouse_email","company_name","job_title","birthday","home_anniversary","notes"];for(const ut of Ue){const De=Fe[ut],Rt=Me[ut];(!De||De==="")&&Rt&&(Ae[ut]=Rt)}Object.keys(Ae).length>0&&await G.from("innercircle_contacts").update(Ae).eq("id",we.id)}Te=we.id,je++}else{const{data:Fe,error:Ae}=await G.from("innercircle_contacts").insert(Me).select("id").single();Ae?(console.error("Insert error for contact:",Ge.first_name,Ae),Ne++):Fe?(Te=Fe.id,w.length>0&&await G.from("innercircle_contact_tags").insert(w.map(Ue=>({contact_id:Fe.id,relationship_type_id:Ue}))),_e++):Ne++}if(Te&&Ge.spouse_name){const Fe=Q(Ge.spouse_name);let Ae=null;if(Ge.spouse_email){const{data:ut}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Ge.spouse_email).maybeSingle();Ae=ut}if(!Ae){const{data:ut}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("first_name",Fe.first_name).eq("last_name",Fe.last_name||Ge.last_name||"").maybeSingle();Ae=ut}let Ue=null;if(Ae){Ue=Ae.id;const ut=RR(Ge.home_anniversary);ut&&await G.from("innercircle_contacts").update({home_anniversary:ut}).eq("id",Ae.id).is("home_anniversary",null)}else{const{data:ut}=await G.from("innercircle_contacts").insert({owner_user_id:a.id,first_name:Fe.first_name,last_name:Fe.last_name||Ge.last_name||null,email:Ge.spouse_email||null,address:Ge.address||null,city:Ge.city||null,state:Ge.state||null,zip:Ge.zip||null,home_anniversary:RR(Ge.home_anniversary),spouse_name:`${Ge.first_name}${Ge.last_name?" "+Ge.last_name:""}`,spouse_email:Ge.email||null,notes:`Spouse of ${Ge.first_name} ${Ge.last_name||""} (imported via CSV)`.trim()}).select("id").single();ut&&(Ue=ut.id,_e++)}Ue&&(await G.from("innercircle_contacts").update({spouse_contact_id:Ue}).eq("id",Te),await G.from("innercircle_contacts").update({spouse_contact_id:Te}).eq("id",Ue))}}catch(we){console.error("Error importing contact:",we),Ne++}R({created:_e,updated:je,failed:Ne}),d("result"),(_e>0||je>0)&&n(),o({title:"Import Complete",description:`${_e} created, ${je} updated${Ne>0?`, ${Ne} failed`:""}.`})}catch(Ge){console.error("Import error:",Ge),o({title:"Import Failed",description:Ge.message||"Failed to import contacts",variant:"destructive"})}finally{I(!1)}},re=k.filter(be=>be.isValid).length,ae=k.filter(be=>!be.isValid).length,le=k.filter(be=>be.isValid&&be.isDuplicate).length,he=re-le;return e.jsx(_s,{open:t,onOpenChange:q,children:e.jsxs(vs,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(I0,{className:"h-5 w-5"}),"Import Contacts from CSV"]}),e.jsx(Kr,{children:"Upload a CSV file with your contacts. You can map columns and select relationship types."})]}),i==="upload"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx("input",{type:"file",accept:".csv,.txt",ref:l,onChange:H,className:"hidden"}),e.jsx(Za,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Click to upload or drag and drop a CSV file"}),e.jsx(K,{onClick:()=>{var be;return(be=l.current)==null?void 0:be.click()},children:"Select CSV File"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 text-sm",children:[e.jsx("p",{className:"font-medium mb-2",children:"Supported Fields:"}),e.jsx("p",{className:"text-muted-foreground text-xs mb-3",children:"First Name, Last Name, Email, Phone, Street Address, City, State, Zip, Spouse Name, Spouse Email, Company, Job Title, Birthday, Home Anniversary, Notes"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{const be=`First Name,Last Name,Email,Phone,Street Address,City,State,Zip,Spouse Name,Spouse Email,Company,Job Title,Birthday,Home Anniversary,Notes John,Doe,john@example.com,555-123-4567,123 Main St,Austin,TX,78701,Jane Doe,jane@example.com,ABC Realty,Real Estate Agent,1985-06-15,2020-03-22,Met at open house`,_e=new Blob([be],{type:"text/csv"}),je=URL.createObjectURL(_e),Ne=document.createElement("a");Ne.href=je,Ne.download="contact_import_template.csv",Ne.click(),URL.revokeObjectURL(je)},children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Download Template"]})]})]}),i==="mapping"&&e.jsxs("div",{className:"flex-1 overflow-auto space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{className:"text-base font-medium",children:"Map CSV Columns to Contact Fields"}),e.jsx("div",{className:"grid gap-3",children:zms.map(be=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(ve,{className:"w-40 text-sm",children:[be.label,be.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(sr,{value:_[be.key]||"none",onValueChange:_e=>Y(be.key,_e),children:[e.jsx(er,{className:"w-48",children:e.jsx(rr,{placeholder:"Select column..."})}),e.jsxs(tr,{children:[e.jsx(At,{value:"none",children:"-- Not mapped --"}),u.map(_e=>e.jsx(At,{value:_e,children:_e},_e))]})]})]},be.key))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{className:"text-base font-medium",children:"Apply Relationship Types (optional)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(be=>e.jsx(rt,{variant:w.includes(be.id)?"default":"outline",className:"cursor-pointer",onClick:()=>se(be.id),children:be.name},be.id))})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-3 text-sm",children:e.jsxs("p",{className:"text-muted-foreground",children:["Preview: ",f.length," row(s) found in CSV"]})})]}),i==="preview"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ua,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{children:[he," new"]})]}),le>0&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ll,{className:"h-4 w-4"}),e.jsxs("span",{children:[le," existing (will merge gaps)"]})]}),ae>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(ll,{className:"h-4 w-4"}),e.jsxs("span",{children:[ae," invalid"]})]})]}),le>0&&e.jsx("div",{className:"bg-muted/50 rounded-lg p-3 text-xs text-muted-foreground",children:"Duplicates matched by email or phone will only fill in missing fields — your existing data won't be overwritten."}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{className:"bg-muted/30",children:[e.jsx(bt,{children:"First Name"}),e.jsx(bt,{children:"Last Name"}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:"Phone"}),e.jsx(bt,{children:"Status"})]})}),e.jsx(Pn,{children:k.slice(0,100).map((be,_e)=>e.jsxs(Ns,{children:[e.jsx(lt,{children:be.first_name}),e.jsx(lt,{children:be.last_name}),e.jsx(lt,{children:be.email}),e.jsx(lt,{children:be.phone}),e.jsx(lt,{children:be.isValid?be.isDuplicate?e.jsx(rt,{variant:"outline",className:"bg-accent text-accent-foreground",children:"Merge"}):e.jsx(rt,{variant:"secondary",className:"bg-primary/10 text-primary",children:"New"}):e.jsx(rt,{variant:"destructive",children:be.error||"Invalid"})})]},_e))})]}),k.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",k.length," contacts"]})]})]}),i==="result"&&L&&e.jsxs("div",{className:"space-y-4 py-4 text-center",children:[e.jsx(ua,{className:"h-12 w-12 mx-auto text-primary"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),e.jsxs("p",{className:"text-muted-foreground",children:[L.created," created, ",L.updated," merged"]}),L.failed>0&&e.jsxs("p",{className:"text-destructive",children:[L.failed," failed to import"]})]}),e.jsxs(Un,{children:[i==="upload"&&e.jsx(K,{variant:"outline",onClick:q,children:"Cancel"}),i==="mapping"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:$,children:"Back"}),e.jsx(K,{onClick:te,disabled:!_.first_name,children:"Continue"})]}),i==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>d("mapping"),children:"Back"}),e.jsx(K,{onClick:de,disabled:T||re===0,children:T?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${re} Contact${re!==1?"s":""}`})]}),i==="result"&&e.jsx(K,{onClick:q,children:"Done"})]})]})})};function $ms(){return"contacts"in navigator&&"ContactsManager"in window}function qms(t){const s=[],r=t.split("BEGIN:VCARD").filter(n=>n.trim());for(const n of r){const a=n.split(/\r?\n/);let o="",l="",i="",d="",u="";for(const p of a){const f=p.replace(/^\s+/,"");if(f.startsWith("N:")||f.startsWith("N;")){const _=f.substring(f.indexOf(":")+1).split(";");l=(_[0]||"").trim(),o=(_[1]||"").trim()}if((f.startsWith("FN:")||f.startsWith("FN;"))&&!o){const _=f.substring(f.indexOf(":")+1).trim().split(" ");o=_[0]||"",l=_.slice(1).join(" ")}(f.startsWith("EMAIL")||f.match(/^item\d+\.EMAIL/i))&&!i&&(i=f.substring(f.indexOf(":")+1).trim()),(f.startsWith("TEL")||f.match(/^item\d+\.TEL/i))&&!d&&(d=f.substring(f.indexOf(":")+1).trim()),(f.startsWith("ADR")||f.match(/^item\d+\.ADR/i))&&!u&&(u=f.substring(f.indexOf(":")+1).split(";").map(b=>b.trim()).filter(Boolean).join(", "))}(o||l)&&s.push({first_name:o,last_name:l,email:i,phone:d,address:u})}return s}function Ums({open:t,onOpenChange:s,onComplete:r}){const{user:n}=Hs(),{data:a}=tm(),o=hle(),l=C.useRef(null),[i,d]=C.useState("choose"),[u,p]=C.useState([]),[f,y]=C.useState(new Set),[_,b]=C.useState(0),[w,j]=C.useState(0),k=$ms(),S=C.useCallback(Y=>{if(!a)return Y;const se=new Set(a.filter(Q=>Q.email).map(Q=>Q.email.toLowerCase())),te=new Set(a.filter(Q=>Q.phone).map(Q=>Q.phone.replace(/\D/g,"")));return Y.map(Q=>{var ae,le;const de=(ae=Q.email)==null?void 0:ae.toLowerCase(),re=(le=Q.phone)==null?void 0:le.replace(/\D/g,"");return de&&se.has(de)?{...Q,isDuplicate:!0,duplicateField:"email"}:re&&re.length>=7&&te.has(re)?{...Q,isDuplicate:!0,duplicateField:"phone"}:Q})},[a]),T=async()=>{try{const Y=["name","email","tel","address"],se=await navigator.contacts.select(Y,{multiple:!0});if(!se||se.length===0)return;const te=se.map(re=>{var he,be,_e,je;const le=(((he=re.name)==null?void 0:he[0])||"").split(" ");return{first_name:le[0]||"",last_name:le.slice(1).join(" "),email:((be=re.email)==null?void 0:be[0])||"",phone:((_e=re.tel)==null?void 0:_e[0])||"",address:(je=re.address)!=null&&je[0]?[re.address[0].streetAddress,re.address[0].city,re.address[0].region,re.address[0].postalCode].filter(Boolean).join(", "):""}}),Q=S(te);p(Q);const de=new Set;Q.forEach((re,ae)=>{re.isDuplicate||de.add(ae)}),y(de),d("preview")}catch(Y){console.error("Contact Picker error:",Y),pn({title:"Could not access contacts",description:"Please try the file upload option instead.",variant:"destructive"})}},I=Y=>{var Q;const se=(Q=Y.target.files)==null?void 0:Q[0];if(!se)return;const te=new FileReader;te.onload=de=>{var be;const re=(be=de.target)==null?void 0:be.result,ae=qms(re);if(ae.length===0){pn({title:"No contacts found",description:"The file didn't contain any valid contacts.",variant:"destructive"});return}const le=S(ae);p(le);const he=new Set;le.forEach((_e,je)=>{_e.isDuplicate||he.add(je)}),y(he),d("preview")},te.readAsText(se),l.current&&(l.current.value="")},L=async()=>{const Y=u.filter((te,Q)=>f.has(Q));if(Y.length===0)return;d("importing");let se=0;for(const te of Y)try{await o.mutateAsync({first_name:te.first_name,last_name:te.last_name||void 0,email:te.email||void 0,phone:te.phone||void 0,address:te.address||void 0}),se++,j(Math.round(se/Y.length*100))}catch(Q){console.error(`Failed to import ${te.first_name} ${te.last_name}:`,Q)}b(se),d("done")},R=Y=>{y(se=>{const te=new Set(se);return te.has(Y)?te.delete(Y):te.add(Y),te})},$=()=>{f.size===u.length?y(new Set):y(new Set(u.map((Y,se)=>se)))},q=Y=>{Y||(d("choose"),p([]),y(new Set),b(0),j(0),i==="done"&&r()),s(Y)},U=u.filter(Y=>Y.isDuplicate).length,H=f.size;return e.jsx(_s,{open:t,onOpenChange:q,children:e.jsxs(vs,{className:"sm:max-w-lg max-h-[90vh]",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(U0,{className:"h-5 w-5 text-primary"}),i==="choose"&&"Import Phone Contacts",i==="preview"&&"Select Contacts to Import",i==="importing"&&"Importing Contacts...",i==="done"&&"Import Complete"]}),i==="choose"&&e.jsx(Kr,{children:"Add contacts from your phone directly into Agent OS."})]}),i==="choose"&&e.jsxs("div",{className:"space-y-4 pt-2",children:[k&&e.jsxs(K,{onClick:T,className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(U0,{className:"h-6 w-6"}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"font-semibold",children:"Select from Phone"}),e.jsx("div",{className:"text-xs opacity-80",children:"Pick contacts directly from your device"})]})]}),e.jsxs("div",{className:"relative",children:[k&&e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),k&&e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"or"})})]}),e.jsxs(K,{variant:k?"outline":"default",onClick:()=>{var Y;return(Y=l.current)==null?void 0:Y.click()},className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(Za,{className:"h-6 w-6"}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"font-semibold",children:"Upload Contact File"}),e.jsx("div",{className:"text-xs opacity-80",children:k?"Import a .vcf file exported from your Contacts app":"Export contacts from your phone as a .vcf file, then upload here"})]})]}),e.jsx("input",{ref:l,type:"file",accept:".vcf,.vcard",onChange:I,className:"hidden"}),!k&&e.jsxs("div",{className:"rounded-lg bg-muted p-3 text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{className:"font-medium",children:"How to export contacts:"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-xs",children:"iPhone:"}),e.jsx("p",{className:"text-xs",children:'Open Contacts → select contacts → Share → choose "Export vCard"'})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-xs",children:"Android:"}),e.jsx("p",{className:"text-xs",children:"Open Contacts → Menu → Export → save as .vcf file"})]})]})]}),i==="preview"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{children:[u.length," contact",u.length!==1?"s":""," found",U>0&&e.jsxs("span",{className:"text-amber-600 ml-1",children:["(",U," already exist)"]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:$,children:f.size===u.length?"Deselect All":"Select All"})]}),e.jsx(Ri,{className:"h-[350px] rounded-md border",children:e.jsx("div",{className:"divide-y",children:u.map((Y,se)=>e.jsxs("div",{className:`flex items-start gap-3 p-3 cursor-pointer hover:bg-accent/50 transition-colors ${Y.isDuplicate?"opacity-60":""}`,onClick:()=>R(se),children:[e.jsx(Bo,{checked:f.has(se),onCheckedChange:()=>R(se),className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:[Y.first_name," ",Y.last_name]}),Y.isDuplicate&&e.jsxs(rt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600 border-amber-200",children:["Exists (",Y.duplicateField,")"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5 mt-0.5",children:[Y.phone&&e.jsx("div",{children:Y.phone}),Y.email&&e.jsx("div",{className:"truncate",children:Y.email})]})]})]},se))})}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d("choose"),children:"Back"}),e.jsxs(K,{onClick:L,disabled:H===0,children:["Import ",H," Contact",H!==1?"s":""]})]})]}),i==="importing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(Ms,{className:"h-8 w-8 animate-spin text-primary"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:"Importing contacts..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[w,"% complete"]})]}),e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${w}%`}})})]}),i==="done"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx(ha,{className:"h-6 w-6 text-emerald-600"})}),e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"font-semibold text-lg",children:[_," contact",_!==1?"s":""," imported!"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Your contacts are now in Agent OS and ready for touchpoint plans."})]}),e.jsx(K,{onClick:()=>q(!1),className:"mt-2",children:"Done"})]})]})})}function Rce(){const t=Ya();return wt({queryKey:["custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_custom_tags").select("*").eq("owner_user_id",t).order("name");if(r)throw r;return s},enabled:!!t})}function Vms(t){return wt({queryKey:["contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_custom_tag_assignments").select("*, tag:contact_custom_tags(*)").eq("contact_id",t);if(r)throw r;return s},enabled:!!t})}function q2e(){const t=rs(),s=Ya();return Dt({mutationFn:async({name:r,color:n})=>{const{data:a,error:o}=await G.from("contact_custom_tags").insert({owner_user_id:s,name:r.trim(),color:n||"#6366F1"}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]})}})}function Hms(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("contact_custom_tags").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]}),t.invalidateQueries({queryKey:["contact-custom-tags"]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function Wms(){const t=rs();return Dt({mutationFn:async({id:s,name:r,color:n})=>{const a={};r!==void 0&&(a.name=r.trim()),n!==void 0&&(a.color=n);const{error:o}=await G.from("contact_custom_tags").update(a).eq("id",s);if(o)throw o},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]}),t.invalidateQueries({queryKey:["contact-custom-tags"]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function wJe(){const t=rs();return Dt({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await G.from("contact_custom_tag_assignments").insert({contact_id:s,tag_id:r});if(n)throw n},onSuccess:(s,{contactId:r})=>{t.invalidateQueries({queryKey:["contact-custom-tags",r]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function Gms(){const t=rs();return Dt({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await G.from("contact_custom_tag_assignments").delete().eq("contact_id",s).eq("tag_id",r);if(n)throw n},onSuccess:(s,{contactId:r})=>{t.invalidateQueries({queryKey:["contact-custom-tags",r]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function Kms(){const t=Ya();return wt({queryKey:["all-contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_custom_tag_assignments").select("contact_id, tag_id, tag:contact_custom_tags(id, name, color)");if(r)throw r;return s},enabled:!!t})}function Zms({selectedIds:t,contacts:s,onClearSelection:r,onSendToLeadPond:n,showLeadPondAction:a,onTransfer:o,showTransferAction:l}){const i=Pr(),{data:d}=Rf(),u=pbe(),p=rs(),{isGmailConnected:f}=Ny(),{isReady:y}=F2e(),{data:_}=Rce(),b=q2e(),w=wJe(),[j,k]=C.useState(!1),[S,T]=C.useState(!1),[I,L]=C.useState(!1),[R,$]=C.useState(""),q=t.size;if(q===0)return null;const U=async re=>{k(!0);try{const le=Array.from(t).map(be=>({contact_id:be,relationship_type_id:re})),{error:he}=await G.from("innercircle_contact_tags").upsert(le,{onConflict:"contact_id,relationship_type_id",ignoreDuplicates:!0});if(he)throw he;p.invalidateQueries({queryKey:["innercircle-contacts"]}),p.invalidateQueries({queryKey:["innercircle-contact-counts"]}),pn({title:`Assigned type to ${q} contacts`}),r()}catch(ae){pn({title:"Error assigning type",description:ae.message,variant:"destructive"})}finally{k(!1)}},H=async re=>{k(!0);try{const ae=Array.from(t);for(const le of ae)try{await w.mutateAsync({contactId:le,tagId:re})}catch{}p.invalidateQueries({queryKey:["all-contact-custom-tags"]}),pn({title:`Tagged ${q} contacts`}),L(!1),$("")}catch(ae){pn({title:"Error adding tags",description:ae.message,variant:"destructive"})}finally{k(!1)}},Y=async()=>{if(R.trim()){k(!0);try{const re=await b.mutateAsync({name:R.trim()});await H(re.id)}catch(re){pn({title:"Error creating tag",description:re.message,variant:"destructive"}),k(!1)}}},se=(_==null?void 0:_.filter(re=>re.name.toLowerCase().includes(R.toLowerCase())))||[],te=_==null?void 0:_.find(re=>re.name.toLowerCase()===R.trim().toLowerCase()),Q=()=>{const re=s.filter(Ne=>t.has(Ne.id)),ae=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Notes","Relationship Types"],le=re.map(Ne=>{var Ge;return[Ne.first_name,Ne.last_name||"",Ne.email||"",Ne.phone||"",Ne.address||"",Ne.birthday||"",Ne.home_anniversary||"",Ne.notes||"",((Ge=Ne.tags)==null?void 0:Ge.map(we=>{var Me;return(Me=we.relationship_type)==null?void 0:Me.name}).join("; "))||""]}),he=[ae.join(","),...le.map(Ne=>Ne.map(Ge=>`"${(Ge||"").replace(/"/g,'""')}"`).join(","))].join(` `),be=new Blob([he],{type:"text/csv"}),_e=URL.createObjectURL(be),je=document.createElement("a");je.href=_e,je.download=`contacts-export-${new Date().toISOString().slice(0,10)}.csv`,je.click(),URL.revokeObjectURL(_e),pn({title:`Exported ${q} contacts`})},de=async()=>{if(confirm(`Are you sure you want to delete ${q} contacts? This cannot be undone.`)){k(!0);try{const re=Array.from(t);for(const ae of re)await u.mutateAsync(ae);r()}catch(re){pn({title:"Error deleting contacts",description:re.message,variant:"destructive"})}finally{k(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/5 border border-primary/20 rounded-lg",children:[e.jsxs(rt,{variant:"secondary",className:"font-semibold",children:[q," selected"]}),e.jsxs(sr,{onValueChange:U,disabled:j,children:[e.jsx(er,{className:"w-[180px] h-8",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Wh,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm",children:"Assign Type"})]})}),e.jsx(tr,{children:d==null?void 0:d.filter(re=>re.active).map(re=>e.jsx(At,{value:re.id,children:re.name},re.id))})]}),e.jsxs(Co,{open:I,onOpenChange:L,children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",disabled:j,children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"}),"Add Tag"]})}),e.jsxs(No,{className:"w-56 p-2",align:"start",children:[e.jsx(Re,{placeholder:"Search or create tag...",value:R,onChange:re=>$(re.target.value),onKeyDown:re=>{re.key==="Enter"&&R.trim()&&!te?(re.preventDefault(),Y()):re.key==="Enter"&&te&&(re.preventDefault(),H(te.id))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[se.map(re=>e.jsxs("button",{onClick:()=>H(re.id),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors",children:[e.jsx("div",{className:"h-3 w-3 rounded-full shrink-0",style:{backgroundColor:re.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:re.name})]},re.id)),R.trim()&&!te&&e.jsxs("button",{onClick:Y,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors text-primary",children:[e.jsx(Zs,{className:"h-3.5 w-3.5"}),'Create "',R.trim(),'"']}),se.length===0&&!R.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create a tag"})]})]})]}),f&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>T(!0),disabled:j,children:[e.jsx(br,{className:"h-3.5 w-3.5 mr-1"}),"Email"]}),y&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{const re=Array.from(t).join(",");i(`/admin/email-campaigns/new?contactIds=${re}`)},disabled:j,children:[e.jsx(Rm,{className:"h-3.5 w-3.5 mr-1"}),"Mass Email"]}),a&&n&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>n(Array.from(t)),disabled:j,children:[e.jsx(Vg,{className:"h-3.5 w-3.5 mr-1"}),"Send to Lead Pond"]}),l&&o&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>o(Array.from(t)),disabled:j,children:[e.jsx(A0,{className:"h-3.5 w-3.5 mr-1"}),"Transfer"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:Q,disabled:j,children:[e.jsx(xi,{className:"h-3.5 w-3.5 mr-1"}),"Export"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:de,disabled:j,className:"text-destructive hover:text-destructive",children:[e.jsx(jr,{className:"h-3.5 w-3.5 mr-1"}),"Delete"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:r,className:"ml-auto",children:[e.jsx(Ur,{className:"h-3.5 w-3.5 mr-1"}),"Clear"]})]}),e.jsx(JM,{open:S,onOpenChange:T,bulkContacts:Array.from(t).map(re=>{const ae=s.find(le=>le.id===re);return ae?{id:ae.id,first_name:ae.first_name,last_name:ae.last_name,email:ae.email||""}:null}).filter(re=>re!==null&&re.email!==""),onSendComplete:()=>{T(!1),r()}})]})}function ALe({contact:t,onEdit:s,onDelete:r,onSnooze:n,onSendToLeadPond:a,showLeadPondAction:o,onTransfer:l,showTransferAction:i}){const d=Pr(),{isReady:u}=F2e(),p=`${t.first_name} ${t.last_name||""}`.trim();return e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:f=>f.stopPropagation(),children:e.jsx(of,{className:"h-4 w-4"})})}),e.jsxs(Md,{align:"end",onClick:f=>f.stopPropagation(),children:[e.jsxs(Na,{onClick:()=>d(`/mission-control/contacts/${t.id}?tab=activity&action=log`),children:[e.jsx(Qn,{className:"h-4 w-4 mr-2"}),"Log Touch"]}),e.jsxs(Na,{onClick:()=>d(`/mission-control/video?contactId=${t.id}`),children:[e.jsx(Nn,{className:"h-4 w-4 mr-2"}),"Send Video"]}),e.jsxs(Na,{onClick:()=>d(`/mission-control/popbys?contactId=${t.id}`),children:[e.jsx(Oi,{className:"h-4 w-4 mr-2"}),"Schedule Pop-by"]}),u&&t.email&&e.jsxs(Na,{onClick:()=>d(`/admin/email-campaigns/new?contactIds=${t.id}`),children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Mass Email"]}),e.jsxs(Na,{onClick:()=>n(t.id,p),children:[e.jsx(vp,{className:"h-4 w-4 mr-2"}),"Snooze"]}),o&&a&&e.jsxs(Na,{onClick:()=>a(t.id),children:[e.jsx(Vg,{className:"h-4 w-4 mr-2"}),"Send to Lead Pond"]}),i&&l&&e.jsxs(Na,{onClick:()=>l(t.id),children:[e.jsx(A0,{className:"h-4 w-4 mr-2"}),"Transfer to Team Member"]}),e.jsxs(Na,{onClick:()=>s(t),children:[e.jsx(Da,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Na,{onClick:()=>r(t.id),className:"text-destructive focus:text-destructive",children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}function Yms(){const{user:t}=Hs();return wt({queryKey:["contact-smart-lists",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_smart_lists").select("*").order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Xms(){const t=rs(),{user:s}=Hs();return Dt({mutationFn:async({name:r,filters:n,sort_by:a})=>{const{data:o,error:l}=await G.from("contact_smart_lists").insert({owner_user_id:s.id,name:r,filters:n,sort_by:a}).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-smart-lists"]}),pn({title:"Smart filter saved"})},onError:r=>{pn({title:"Error saving smart filter",description:r.message,variant:"destructive"})}})}function Qms(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("contact_smart_lists").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-smart-lists"]}),pn({title:"Smart filter deleted"})}})}function Jms({currentFilters:t,currentSortBy:s,onApplySmartList:r}){const{data:n}=Yms(),a=Xms(),o=Qms(),[l,i]=C.useState(!1),[d,u]=C.useState(""),p=t.search||t.type&&t.type!=="all"||t.status&&t.status!=="all",f=async()=>{d.trim()&&(await a.mutateAsync({name:d.trim(),filters:t,sort_by:s}),u(""),i(!1))};return e.jsxs(e.Fragment,{children:[e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(Yx,{className:"h-3.5 w-3.5"}),"Smart Filters",n&&n.length>0&&e.jsx(rt,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:n.length}),e.jsx(Ho,{className:"h-3.5 w-3.5"})]})}),e.jsxs(Md,{align:"start",className:"w-56",children:[n&&n.length>0?e.jsxs(e.Fragment,{children:[n.map(y=>e.jsxs(Na,{className:"flex items-center justify-between group",children:[e.jsx("span",{className:"flex-1 cursor-pointer",onClick:()=>r(y.filters,y.sort_by),children:y.name}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100",onClick:_=>{_.stopPropagation(),o.mutate(y.id)},children:e.jsx(jr,{className:"h-3 w-3 text-destructive"})})]},y.id)),e.jsx(E_,{})]}):e.jsx(Na,{disabled:!0,className:"text-muted-foreground text-xs",children:"No saved filters yet"}),p&&e.jsxs(Na,{onClick:()=>i(!0),children:[e.jsx(oP,{className:"h-4 w-4 mr-2"}),"Save Current Filter"]})]})]}),e.jsx(_s,{open:l,onOpenChange:i,children:e.jsxs(vs,{className:"max-w-sm",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Save Smart Filter"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Re,{placeholder:"e.g. Buyers in 40205",value:d,onChange:y=>u(y.target.value),onKeyDown:y=>y.key==="Enter"&&f(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{onClick:f,disabled:!d.trim()||a.isPending,children:"Save"})]})]})]})})]})}function VE(t){if(!t)return null;try{const s=t.split(/[-/T]/);if(s.length<3)return null;const r=parseInt(s[1],10)-1,n=parseInt(s[2],10);if(isNaN(r)||isNaN(n))return null;const a=new Date;a.setHours(0,0,0,0);let o=new Date(a.getFullYear(),r,n);return o.setHours(0,0,0,0),or)return null;const a=s==="birthday"?"🎂":"🏡",o=n===0?s==="birthday"?"Birthday today!":"Anniversary today!":n===1?s==="birthday"?"Birthday tomorrow":"Anniversary tomorrow":`${a} in ${n}d`;return{emoji:a,label:o,daysUntil:n}}function PLe({birthday:t,homeAnniversary:s,className:r,contactId:n,contactName:a,contactAddress:o}){const l=Pr(),i=ELe(t,"birthday",7),d=ELe(s,"anniversary",7);if(!i&&!d)return null;const u=(p,f)=>{f.stopPropagation();const y=new URLSearchParams;n&&y.set("contactId",n),a&&y.set("name",a),o&&y.set("address",o),p==="home_anniversary"&&s&&y.set("date",s),y.set("cardType",p),l(`/mission-control/card-studio?${y.toString()}`)};return e.jsxs("div",{className:Pt("flex flex-wrap gap-1",r),children:[i&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(rt,{variant:"secondary",className:Pt("text-[10px] gap-0.5 font-medium",i.daysUntil===0?"bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-400 animate-pulse":"bg-pink-50 text-pink-600 dark:bg-pink-900/20 dark:text-pink-400"),children:i.label}),n&&e.jsxs("button",{onClick:p=>u("birthday",p),className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[9px] font-semibold bg-pink-500/15 text-pink-600 dark:text-pink-400 hover:bg-pink-500/25 transition-colors",title:"Send a birthday card",children:[e.jsx(br,{className:"h-2.5 w-2.5"}),"Send Card"]})]}),d&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(rt,{variant:"secondary",className:Pt("text-[10px] gap-0.5 font-medium",d.daysUntil===0?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400 animate-pulse":"bg-blue-50 text-blue-600 dark:bg-blue-900/20 dark:text-blue-400"),children:d.label}),n&&e.jsxs("button",{onClick:p=>u("home_anniversary",p),className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[9px] font-semibold bg-blue-500/15 text-blue-600 dark:text-blue-400 hover:bg-blue-500/25 transition-colors",title:"Send an anniversary card",children:[e.jsx(br,{className:"h-2.5 w-2.5"}),"Send Card"]})]})]})}function ILe({deal:t}){if(!t||!t.stage)return null;const{stage:s}=t;return e.jsxs(rt,{variant:"outline",className:"text-[10px] gap-1 font-medium whitespace-nowrap",style:{borderColor:s.color,color:s.color,backgroundColor:`${s.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:s.color}}),s.name]})}function eps(){const t=Ya();return wt({queryKey:["contact-deals-map",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_pipeline").select(` id, deal_name, contact_id, stage:deal_pipeline_stages(id, name, color, icon, is_won_stage, is_lost_stage) `).not("contact_id","is",null);if(r)throw r;const n={};return(s||[]).forEach(a=>{a.contact_id&&!n[a.contact_id]&&(n[a.contact_id]=a)}),n},enabled:!!t})}function tps({contactId:t,compact:s=!1}){const{data:r}=Rce(),{data:n}=Vms(t),a=q2e(),o=wJe(),l=Gms(),[i,d]=C.useState(!1),[u,p]=C.useState(""),f=C.useRef(null),y=new Set((n==null?void 0:n.map(k=>k.tag_id))||[]),_=(r==null?void 0:r.filter(k=>k.name.toLowerCase().includes(u.toLowerCase())))||[],b=r==null?void 0:r.find(k=>k.name.toLowerCase()===u.trim().toLowerCase()),w=async k=>{y.has(k.id)?await l.mutateAsync({contactId:t,tagId:k.id}):await o.mutateAsync({contactId:t,tagId:k.id})},j=async()=>{if(!(!u.trim()||b))try{const k=await a.mutateAsync({name:u.trim()});await o.mutateAsync({contactId:t,tagId:k.id}),p("")}catch{}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n==null?void 0:n.map(k=>{var S,T,I;return e.jsxs(rt,{variant:"outline",className:"text-xs gap-1 pr-1",style:{borderColor:((S=k.tag)==null?void 0:S.color)||"#6366F1",color:((T=k.tag)==null?void 0:T.color)||"#6366F1"},children:[e.jsx(Wh,{className:"h-2.5 w-2.5"}),(I=k.tag)==null?void 0:I.name,e.jsx("button",{onClick:L=>{L.stopPropagation(),l.mutate({contactId:t,tagId:k.tag_id})},className:"ml-0.5 rounded-full hover:bg-accent p-0.5",children:e.jsx(Ur,{className:"h-2.5 w-2.5"})})]},k.id)}),e.jsxs(Co,{open:i,onOpenChange:d,children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:s?"h-6 w-6 p-0":"h-6 px-2 text-xs",onClick:k=>k.stopPropagation(),children:[e.jsx(Zs,{className:"h-3 w-3"}),!s&&e.jsx("span",{className:"ml-1",children:"Tag"})]})}),e.jsxs(No,{className:"w-56 p-2",align:"start",onClick:k=>k.stopPropagation(),children:[e.jsx(Re,{ref:f,placeholder:"Search or create tag...",value:u,onChange:k=>p(k.target.value),onKeyDown:k=>{k.key==="Enter"&&u.trim()&&!b?(k.preventDefault(),j()):k.key==="Enter"&&b&&!y.has(b.id)&&(k.preventDefault(),w(b))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[_.map(k=>e.jsxs("button",{onClick:()=>w(k),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors",children:[e.jsx("div",{className:"h-3 w-3 rounded-full shrink-0",style:{backgroundColor:k.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:k.name}),y.has(k.id)&&e.jsx(ha,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},k.id)),u.trim()&&!b&&e.jsxs("button",{onClick:j,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors text-primary",children:[e.jsx(Zs,{className:"h-3.5 w-3.5"}),'Create "',u.trim(),'"']}),_.length===0&&!u.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create your first tag"})]})]})]})]})}function LLe({contactId:t,tags:s}){return!s||s.length===0?null:e.jsx(e.Fragment,{children:s.map(r=>{var n,a,o;return e.jsx(rt,{variant:"outline",className:"text-[10px] gap-0.5",style:{borderColor:((n=r.tag)==null?void 0:n.color)||"#6366F1",color:((a=r.tag)==null?void 0:a.color)||"#6366F1"},children:(o=r.tag)==null?void 0:o.name},r.tag_id)})})}const FR=["#6366F1","#8B5CF6","#EC4899","#EF4444","#F97316","#F59E0B","#10B981","#14B8A6","#06B6D4","#3B82F6","#6B7280","#1F2937"];function sps({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Rce(),a=q2e(),o=Wms(),l=Hms(),[i,d]=C.useState(""),[u,p]=C.useState(FR[0]),[f,y]=C.useState(null),[_,b]=C.useState(""),[w,j]=C.useState(""),k=async()=>{if(i.trim())try{await a.mutateAsync({name:i.trim(),color:u}),d(""),p(FR[0]),pn({title:"Tag created"})}catch(L){pn({title:"Error",description:L.message,variant:"destructive"})}},S=async L=>{if(_.trim())try{await o.mutateAsync({id:L,name:_.trim(),color:w}),y(null),pn({title:"Tag updated"})}catch(R){pn({title:"Error",description:R.message,variant:"destructive"})}},T=async(L,R)=>{if(confirm(`Delete tag "${R}"? It will be removed from all contacts.`))try{await l.mutateAsync(L),pn({title:"Tag deleted"})}catch($){pn({title:"Error",description:$.message,variant:"destructive"})}},I=L=>{y(L.id),b(L.name),j(L.color)};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Manage Tags"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"New tag name...",value:i,onChange:L=>d(L.target.value),onKeyDown:L=>L.key==="Enter"&&k(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:k,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:FR.map(L=>e.jsx("button",{onClick:()=>p(L),className:`h-6 w-6 rounded-full border-2 transition-transform ${u===L?"border-foreground scale-110":"border-transparent hover:scale-105"}`,style:{backgroundColor:L}},L))})]}),e.jsxs("div",{className:"mt-2 space-y-1 max-h-[320px] overflow-y-auto",children:[n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Loading..."}),(r==null?void 0:r.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No tags yet. Create one above!"}),r==null?void 0:r.map(L=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:f===L.id?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:FR.map(R=>e.jsx("button",{onClick:()=>j(R),className:`h-5 w-5 rounded-full border-2 ${w===R?"border-foreground":"border-transparent"}`,style:{backgroundColor:R}},R))}),e.jsx(Re,{value:_,onChange:R=>b(R.target.value),onKeyDown:R=>R.key==="Enter"&&S(L.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>S(L.id),children:e.jsx(ha,{className:"h-4 w-4 text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>y(null),children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3.5 w-3.5 rounded-full shrink-0",style:{backgroundColor:L.color}}),e.jsx("span",{className:"flex-1 text-sm",children:L.name}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>I(L),children:e.jsx(Da,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-destructive hover:text-destructive",onClick:()=>T(L.id,L.name),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})},L.id))]})]})})}function rps({open:t,onOpenChange:s}){const{data:r,isLoading:n}=EM(),a=xbe(),o=l3t(),l=c3t(),[i,d]=C.useState(""),[u,p]=C.useState(null),[f,y]=C.useState(""),_=async()=>{if(i.trim())try{await a.mutateAsync(i.trim()),d("")}catch(k){fe.error(k.message||"Failed to add lead source")}},b=async k=>{if(f.trim())try{await o.mutateAsync({id:k,name:f.trim()}),p(null)}catch(S){fe.error(S.message||"Failed to update")}},w=async(k,S)=>{if(confirm(`Remove lead source "${S}"? Contacts using it will keep the label but it won't appear in new dropdowns.`))try{await l.mutateAsync(k)}catch(T){fe.error(T.message||"Failed to remove")}},j=k=>{p(k.id),y(k.name)};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Manage Lead Sources"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"New lead source name...",value:i,onChange:k=>d(k.target.value),onKeyDown:k=>k.key==="Enter"&&_(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:_,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsxs("div",{className:"mt-2 space-y-1 max-h-[360px] overflow-y-auto",children:[n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Loading..."}),(r==null?void 0:r.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No lead sources yet. Create one above!"}),r==null?void 0:r.map(k=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:u===k.id?e.jsxs(e.Fragment,{children:[e.jsx(Re,{value:f,onChange:S=>y(S.target.value),onKeyDown:S=>S.key==="Enter"&&b(k.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>b(k.id),children:e.jsx(ha,{className:"h-4 w-4 text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>p(null),children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-sm",children:k.name}),k.owner_user_id&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>j(k),children:e.jsx(Da,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-destructive hover:text-destructive",onClick:()=>w(k.id,k.name),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]}),!k.owner_user_id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default"})]})},k.id))]})]})})}function jJe({value:t,onChange:s,label:r="Lead Source"}){const{data:n}=EM(),a=xbe(),[o,l]=C.useState(!1),[i,d]=C.useState(""),u=async()=>{if(i.trim())try{const p=await a.mutateAsync(i.trim());p&&(s(p.id),d(""),l(!1))}catch{}};return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:r}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(sr,{value:t||"_none",onValueChange:p=>s(p==="_none"?"":p),children:[e.jsx(er,{className:"flex-1",children:e.jsx(rr,{placeholder:"Select lead source"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"_none",children:"No source"}),n==null?void 0:n.map(p=>e.jsx(At,{value:p.id,children:p.name},p.id))]})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",className:"shrink-0",onClick:()=>l(!o),children:o?e.jsx(Ur,{className:"h-4 w-4"}):e.jsx(Zs,{className:"h-4 w-4"})})]}),o&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"New lead source name...",value:i,onChange:p=>d(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),u())},className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:u,disabled:!i.trim()||a.isPending,children:"Add"})]})]})}function Q0e({contactId:t,currentSpouseContactId:s,currentSpouseName:r,currentSpouseEmail:n,onLink:a,onUnlink:o,isEditing:l}){const i=Pr(),[d,u]=C.useState(!1),[p,f]=C.useState(""),{data:y}=wt({queryKey:["innercircle-contact-spouse",s],queryFn:async()=>{const{data:b,error:w}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone, birthday").eq("id",s).maybeSingle();if(w)throw w;return b},enabled:!!s}),{data:_}=wt({queryKey:["spouse-search",p],queryFn:async()=>{let b=G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").neq("id",t).order("first_name").limit(20);p.trim()&&(b=b.or(`first_name.ilike.%${p}%,last_name.ilike.%${p}%,email.ilike.%${p}%,phone.ilike.%${p}%`));const{data:w,error:j}=await b;if(j)throw j;return w},enabled:d});if(s&&y){const b=`${y.first_name} ${y.last_name||""}`.trim();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/30 px-3 py-2",children:[e.jsx(Yi,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("button",{onClick:()=>i(`/mission-control/contacts/${y.id}`),className:"text-sm font-medium text-primary hover:underline truncate block",children:b}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:[y.phone,y.email].filter(Boolean).join(" · ")||"No contact info"})]}),l&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:o,className:"shrink-0 h-7 px-2",children:[e.jsx(gk,{className:"h-3.5 w-3.5 mr-1"}),"Unlink"]}),!l&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>i(`/mission-control/contacts/${y.id}`),className:"shrink-0 h-7 px-2",children:e.jsx($i,{className:"h-3.5 w-3.5"})})]})]})}return!s&&(r||n)?e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/30 px-3 py-2",children:[e.jsx(Yi,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-sm",children:r}),n&&e.jsx("span",{className:"text-xs text-muted-foreground block truncate",children:n})]}),l&&e.jsxs(Co,{open:d,onOpenChange:u,children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"shrink-0 h-7 px-2",children:[e.jsx(Wo,{className:"h-3.5 w-3.5 mr-1"}),"Link Contact"]})}),e.jsx(No,{className:"w-72 p-2",align:"end",children:e.jsx(DLe,{search:p,setSearch:f,results:_,onSelect:b=>{a(b),u(!1),f("")}})})]})]})]}):l?e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs(Co,{open:d,onOpenChange:u,children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full justify-start text-muted-foreground font-normal h-10",children:[e.jsx(Wo,{className:"h-4 w-4 mr-2"}),"Link an existing contact as spouse..."]})}),e.jsx(No,{className:"w-72 p-2",align:"start",children:e.jsx(DLe,{search:p,setSearch:f,results:_,onSelect:b=>{a(b),u(!1),f("")}})})]})]}):null}function DLe({search:t,setSearch:s,results:r,onSelect:n}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Re,{value:t,onChange:a=>s(a.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(Ri,{className:"max-h-48",children:r&&r.length>0?e.jsx("div",{className:"space-y-0.5",children:r.map(a=>e.jsxs("button",{onClick:()=>n(a.id),className:"w-full text-left px-2 py-1.5 rounded hover:bg-accent transition-colors",children:[e.jsxs("div",{className:"text-sm font-medium truncate",children:[a.first_name," ",a.last_name]}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:[a.phone,a.email].filter(Boolean).join(" · ")||"No contact info"})]},a.id))}):e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:t?"No contacts found":"Type to search contacts"})})]})}function nps(){var sa;const t=Pr(),[s]=Pc(),{user:r}=Hs(),n=eT(),a=rs(),o=s.get("type"),l=s.get("filter")??s.get("status"),i=s.get("new")==="true",{contactsWithScores:d,isLoading:u}=fle(),{data:p}=Rf(),{data:f}=eps(),{data:y}=Rce(),{data:_}=Kms(),[b,w]=C.useState(new Set),[j,k]=C.useState("any"),S=hle(),T=mbe(),I=pbe(),L=_Ve(),[R,$]=C.useState(""),[q,U]=C.useState(o||"all"),[H,Y]=C.useState(l||"all"),[se,te]=C.useState("date-added"),[Q,de]=C.useState(i),[re,ae]=C.useState(null),[le,he]=C.useState(!1),[be,_e]=C.useState(!1),[je,Ne]=C.useState(null),[Ge,we]=C.useState(""),[Me,Te]=C.useState(new Set),[Fe,Ae]=C.useState(!1),[Ue,ut]=C.useState(1),[De,Rt]=C.useState(50),[me,Xe]=C.useState("my"),[ot,nt]=C.useState(!1),[Se,it]=C.useState(!1),{data:$e}=Lf(),{addToLeadPond:ct}=DKe($e==null?void 0:$e.teamId),qe=!!((sa=$e==null?void 0:$e.team)!=null&&sa.lead_pond_enabled&&($e!=null&&$e.teamId)),Ze=!!($e!=null&&$e.teamId),[Qe,We]=C.useState([]),[He,et]=C.useState(!1),Tt=Zt=>{We([Zt]),et(!0)},Ft=Zt=>{We(Zt),et(!0)},as=Zt=>{$e!=null&&$e.teamId&&ct.mutate({contact_id:Zt,team_id:$e.teamId})},Xt=Zt=>{$e!=null&&$e.teamId&&Zt.forEach($r=>{ct.mutate({contact_id:$r,team_id:$e.teamId})})},ss=C.useCallback(Zt=>{Ae(!1),Te($r=>{const es=new Set($r);return es.has(Zt)?es.delete(Zt):es.add(Zt),es})},[]);C.useEffect(()=>{if(!(r!=null&&r.id))return;const Zt=G.channel(`innercircle_contacts_inserts_${r.id}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"innercircle_contacts",filter:`owner_user_id=eq.${r.id}`},()=>{a.invalidateQueries({queryKey:["innercircle-contacts"]}),a.invalidateQueries({queryKey:["innercircle-contact-counts"]})}).subscribe();return()=>{G.removeChannel(Zt)}},[a,r==null?void 0:r.id]),C.useEffect(()=>{l&&Y(l)},[l]);const[is,ar]=C.useState({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]});C.useEffect(()=>{i&&de(!0)},[i]),C.useEffect(()=>{var Zt;re&&ar({first_name:re.first_name||"",last_name:re.last_name||"",email:re.email||"",phone:re.phone||"",address:re.address||"",city:re.city||"",state:re.state||"",zip_code:re.zip_code||"",birthday:re.birthday||"",home_anniversary:re.home_anniversary||"",spouse_name:re.spouse_name||"",spouse_email:re.spouse_email||"",lead_source_id:re.lead_source_id||"",notes:re.notes||"",tagIds:((Zt=re.tags)==null?void 0:Zt.map($r=>$r.relationship_type_id))||[]})},[re]);const Ct=C.useMemo(()=>{if(!d)return[];let Zt=d.filter($r=>{var Zn,Ir,mi;const es=R===""||`${$r.first_name} ${$r.last_name}`.toLowerCase().includes(R.toLowerCase())||((Zn=$r.email)==null?void 0:Zn.toLowerCase().includes(R.toLowerCase()))||((Ir=$r.phone)==null?void 0:Ir.includes(R)),an=q==="all"||((mi=$r.tags)==null?void 0:mi.some(Go=>Go.relationship_type_id===q)),Ra=b.size===0||(()=>{const Go=(_==null?void 0:_.filter(yi=>yi.contact_id===$r.id).map(yi=>yi.tag_id))||[];return j==="any"?Go.some(yi=>b.has(yi)):Array.from(b).every(yi=>Go.includes(yi))})();return es&&an&&Ra});return H==="not-touched-90"?Zt=Zt.filter($r=>{const es=$r.relationshipScore.daysSinceTouch;return es===null||es>90}):H==="at-risk"?Zt=Zt.filter($r=>$r.relationshipScore.status==="at-risk"):H==="cooling"?Zt=Zt.filter($r=>$r.relationshipScore.status==="cooling"):H==="warm"?Zt=Zt.filter($r=>$r.relationshipScore.status==="warm"):H==="has-deal"?Zt=Zt.filter($r=>f&&f[$r.id]):H==="no-deal"?Zt=Zt.filter($r=>!f||!f[$r.id]):H==="open-house"&&(Zt=Zt.filter($r=>{var an;return(((an=$r.lead_source_ref)==null?void 0:an.name)||$r.lead_source)==="Open House"})),Zt=[...Zt].sort(($r,es)=>{switch(se){case"important-dates":{const an=VE($r.birthday),Ra=VE(es.birthday),Zn=VE($r.home_anniversary),Ir=VE(es.home_anniversary),mi=[an,Zn].filter(yi=>yi!==null).sort((yi,Vl)=>(yi??1/0)-(Vl??1/0))[0]??1/0,Go=[Ra,Ir].filter(yi=>yi!==null).sort((yi,Vl)=>(yi??1/0)-(Vl??1/0))[0]??1/0;return mi-Go}case"last-touched":{const an=$r.relationshipScore.lastTouchDate,Ra=es.relationshipScore.lastTouchDate;return!an&&!Ra?0:an?Ra?new Date(an).getTime()-new Date(Ra).getTime():1:-1}case"next-touch":{const an=$r.relationshipScore.daysSinceTouch,Ra=es.relationshipScore.daysSinceTouch;return an===null&&Ra===null?0:an===null?-1:Ra===null?1:Ra-an}case"score":return $r.relationshipScore.score-es.relationshipScore.score;case"date-added":{const an=$r.created_at,Ra=es.created_at;return!an&&!Ra?0:an?Ra?new Date(Ra).getTime()-new Date(an).getTime():-1:1}case"name":default:{const an=`${$r.first_name||""} ${$r.last_name||""}`.toLowerCase(),Ra=`${es.first_name||""} ${es.last_name||""}`.toLowerCase();return an.localeCompare(Ra)}}}),Zt},[d,R,q,b,j,H,se,f,_]),Is=Ct.length,qs=Math.max(1,Math.ceil(Is/De)),gr=Math.min(Ue,qs),Wn=C.useMemo(()=>{const Zt=(gr-1)*De;return Ct.slice(Zt,Zt+De)},[Ct,gr,De]);C.useEffect(()=>{ut(1)},[R,q,b,j,H,se]);const ii=C.useCallback(()=>{Ae(!1),Te(Zt=>Zt.size>0?new Set:new Set(Wn.map($r=>$r.id)))},[Wn]),bo=C.useCallback(()=>{Ae(!0),Te(new Set(Ct.map(Zt=>Zt.id)))},[Ct]),si=C.useCallback((Zt,$r)=>{$(Zt.search||""),U(Zt.type||"all"),Y(Zt.status||"all"),te($r||"name")},[]),nn=()=>{ar({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]})},ia=async Zt=>{Zt.preventDefault();const $r={...is,lead_source_id:is.lead_source_id||null};re?(await T.mutateAsync({id:re.id,...$r}),ae(null)):(await S.mutateAsync($r),de(!1)),nn()},kn=async Zt=>{confirm("Are you sure you want to delete this contact?")&&await I.mutateAsync(Zt)};return e.jsx(Ts,{title:"Contacts",description:"Manage your InnerCircle contacts",children:e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Contacts"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),$e&&e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsx("button",{onClick:()=>Xe("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${me==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Contacts"}),($e.team.contact_visibility==="full_team"||$e.team.contact_visibility==="leader_only"&&$e.role==="team_leader")&&e.jsxs("button",{onClick:()=>Xe("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${me==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(hr,{className:"h-3.5 w-3.5"}),"Team"]}),$e.team.lead_pond_enabled&&e.jsxs("button",{onClick:()=>Xe("lead-pond"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${me==="lead-pond"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Vg,{className:"h-3.5 w-3.5"}),"Lead Pond"]})]})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(zl,{className:"h-4 w-4 mr-1"}),"Back"]})}),me==="team"?e.jsx(bwe,{}):me==="lead-pond"&&$e?e.jsx(wwe,{teamId:$e.teamId}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name, email, or phone...",value:R,onChange:Zt=>$(Zt.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto pb-1",children:[e.jsxs(K,{onClick:()=>de(!0),className:"shrink-0",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Contact"]}),e.jsxs(K,{variant:"outline",onClick:()=>he(!0),className:"shrink-0",children:[e.jsx(Za,{className:"h-4 w-4 mr-1"}),"Import CSV"]}),e.jsxs(K,{variant:"outline",onClick:()=>_e(!0),className:"shrink-0",children:[e.jsx(U0,{className:"h-4 w-4 mr-1"}),"Import from Phone"]}),e.jsx(Mms,{})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(sr,{value:q,onValueChange:U,children:[e.jsx(er,{className:"w-[145px] h-9 text-sm",children:e.jsx(rr,{placeholder:"Filter by type"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Types"}),p==null?void 0:p.filter(Zt=>Zt.active).map(Zt=>e.jsx(At,{value:Zt.id,children:Zt.name},Zt.id))]})]}),y&&y.length>0&&e.jsxs(Co,{children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"h-9 justify-start text-sm",children:[e.jsx(Wh,{className:"h-3.5 w-3.5 mr-1.5 shrink-0 text-muted-foreground"}),b.size===0?"Filter by Tags":`${b.size} tag${b.size>1?"s":""}`]})}),e.jsx(No,{className:"w-60 p-3",align:"start",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Tags"}),e.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-md p-0.5",children:[e.jsx("button",{onClick:()=>k("any"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${j==="any"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"Any"}),e.jsx("button",{onClick:()=>k("all"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${j==="all"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"All"})]})]}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:y.map(Zt=>{const $r=b.has(Zt.id);return e.jsxs("button",{onClick:()=>{w(es=>{const an=new Set(es);return an.has(Zt.id)?an.delete(Zt.id):an.add(Zt.id),an})},className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors",children:[e.jsx(Bo,{checked:$r,className:"pointer-events-none"}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:Zt.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:Zt.name})]},Zt.id)})}),b.size>0&&e.jsx(K,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>w(new Set),children:"Clear tags"})]})})]}),e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",title:"Settings",children:e.jsx($l,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs(Md,{align:"end",children:[e.jsxs(Na,{onClick:()=>nt(!0),children:[e.jsx(Wh,{className:"h-4 w-4 mr-2"}),"Manage Tags"]}),e.jsxs(Na,{onClick:()=>it(!0),children:[e.jsx(Vg,{className:"h-4 w-4 mr-2"}),"Manage Lead Sources"]})]})]}),e.jsxs(sr,{value:H,onValueChange:Y,children:[e.jsx(er,{className:"w-[145px] h-9 text-sm",children:e.jsx(rr,{placeholder:"Filter by status"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Status"}),e.jsx(At,{value:"warm",children:"🟢 Warm"}),e.jsx(At,{value:"cooling",children:"🟡 Cooling Off"}),e.jsx(At,{value:"at-risk",children:"🔴 At Risk"}),e.jsx(At,{value:"has-deal",children:"📋 Has Deal"}),e.jsx(At,{value:"no-deal",children:"📭 No Deal"}),e.jsx(At,{value:"open-house",children:"🏠 Open House"})]})]}),e.jsxs(sr,{value:se,onValueChange:te,children:[e.jsx(er,{className:"w-[165px] h-9 text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hc,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(rr,{placeholder:"Sort by"})]})}),e.jsxs(tr,{children:[e.jsx(At,{value:"name",children:"Name (A-Z)"}),e.jsx(At,{value:"important-dates",children:"Important Dates"}),e.jsx(At,{value:"last-touched",children:"Last Touched"}),e.jsx(At,{value:"next-touch",children:"Next Touch Due"}),e.jsx(At,{value:"score",children:"Relationship Score"}),e.jsx(At,{value:"date-added",children:"Date Added"})]})]}),e.jsx(Jms,{currentFilters:{search:R,type:q,status:H},currentSortBy:se,onApplySmartList:si})]})]})})}),e.jsx(Zms,{selectedIds:Me,contacts:Ct,onClearSelection:()=>{Te(new Set),Ae(!1)},showLeadPondAction:qe,onSendToLeadPond:Xt,showTransferAction:Ze,onTransfer:Ft}),Me.size>0&&Me.size===Wn.length&&!Fe&&Is>De&&e.jsxs("div",{className:"flex items-center justify-center gap-2 p-2 bg-primary/5 border border-primary/20 rounded-lg text-sm",children:[e.jsxs("span",{children:["All ",Wn.length," contacts on this page are selected."]}),e.jsxs(K,{variant:"link",size:"sm",className:"h-auto p-0 font-semibold",onClick:bo,children:["Select all ",Is.toLocaleString()," matching contacts"]})]}),Fe&&e.jsxs("div",{className:"flex items-center justify-center gap-2 p-2 bg-primary/10 border border-primary/30 rounded-lg text-sm font-medium",children:["All ",Is.toLocaleString()," matching contacts are selected.",e.jsx(K,{variant:"link",size:"sm",className:"h-auto p-0",onClick:()=>{Te(new Set),Ae(!1)},children:"Clear selection"})]}),n?e.jsx("div",{className:"space-y-3",children:u?e.jsx(Ee,{className:"p-6 text-center text-muted-foreground",children:"Loading contacts..."}):Ct.length===0?e.jsx(Ee,{className:"p-6 text-center text-muted-foreground",children:R||q!=="all"||H!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"}):Wn.map(Zt=>{var es,an,Ra;const{relationshipScore:$r}=Zt;return e.jsx(Ee,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{const Zn=new URLSearchParams;R&&Zn.set("search",R),q!=="all"&&Zn.set("type",q),H!=="all"&&Zn.set("filter",H);const Ir=Zn.toString();t(`/mission-control/contacts/${Zt.id}${Ir?`?${Ir}`:""}`)},children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("h3",{className:"font-semibold text-base truncate",children:[Zt.first_name," ",Zt.last_name]}),e.jsx(Ua,{className:"h-4 w-4 text-muted-foreground shrink-0"})]}),e.jsxs("div",{className:"space-y-1 text-sm mb-3",children:[Zt.email&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(br,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:Zt.email})]}),Zt.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Qn,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:Zt.phone})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 mb-2",children:[e.jsx(TI,{score:$r,size:"sm"}),e.jsx(X0e,{contact:Zt}),(((es=Zt.lead_source_ref)==null?void 0:es.name)||Zt.lead_source)&&e.jsx(rt,{variant:"outline",className:"text-xs gap-1 border-primary/30 text-primary",children:((an=Zt.lead_source_ref)==null?void 0:an.name)||Zt.lead_source}),(Ra=Zt.tags)==null?void 0:Ra.map(Zn=>{var Ir;return e.jsx(rt,{variant:"secondary",className:"text-xs",children:(Ir=Zn.relationship_type)==null?void 0:Ir.name},Zn.id)}),e.jsx(LLe,{contactId:Zt.id,tags:_==null?void 0:_.filter(Zn=>Zn.contact_id===Zt.id)}),e.jsx(ILe,{deal:f==null?void 0:f[Zt.id]})]}),e.jsx(PLe,{birthday:Zt.birthday,homeAnniversary:Zt.home_anniversary,className:"mb-2",contactId:Zt.id,contactName:`${Zt.first_name}${Zt.last_name?" "+Zt.last_name:""}`,contactAddress:[Zt.address,Zt.city,Zt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[$r.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),ys(new Date($r.lastTouchDate),"MMM d")]}):e.jsx("span",{className:"italic",children:"Never contacted"}),Zt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ys(gl(Zt.birthday),"MMM d")]}),Zt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(On,{className:"h-3 w-3"}),ys(gl(Zt.home_anniversary),"MMM d")]}),Zt.created_at&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Zs,{className:"h-3 w-3"}),"Added ",ys(new Date(Zt.created_at),"MMM d, yyyy")]})]})]}),e.jsx("div",{className:"ml-2",onClick:Zn=>Zn.stopPropagation(),children:e.jsx(ALe,{contact:Zt,onEdit:ae,onDelete:kn,onSnooze:(Zn,Ir)=>{Ne(Zn),we(Ir)},showLeadPondAction:qe,onSendToLeadPond:as,showTransferAction:Ze,onTransfer:Tt})})]})})},Zt.id)})}):e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0 overflow-x-auto",children:e.jsxs(An,{className:"min-w-[800px]",children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{className:"w-[40px]",children:e.jsx(Bo,{checked:Wn.length>0&&Wn.every(Zt=>Me.has(Zt.id)),onCheckedChange:()=>ii()})}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{children:"Score"}),e.jsx(bt,{children:"Contact Info"}),e.jsx(bt,{children:"Types / Pipeline"}),e.jsx(bt,{children:"Last Contact"}),e.jsx(bt,{className:"cursor-pointer select-none",onClick:()=>te(se==="date-added"?"name":"date-added"),children:e.jsxs("div",{className:"flex items-center gap-1",children:["Date Added",se==="date-added"&&e.jsx(Hc,{className:"h-3 w-3"})]})}),e.jsx(bt,{children:"Important Dates"}),e.jsx(bt,{className:"w-[50px]",children:"Actions"})]})}),e.jsx(Pn,{children:u?e.jsx(Ns,{children:e.jsx(lt,{colSpan:10,className:"text-center py-8",children:"Loading contacts..."})}):Ct.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:R||q!=="all"||H!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"})}):Wn.map(Zt=>{var an,Ra,Zn;const{relationshipScore:$r}=Zt,es=f==null?void 0:f[Zt.id];return e.jsxs(Ns,{className:`cursor-pointer hover:bg-accent/50 ${Me.has(Zt.id)?"bg-accent/30":""}`,onClick:()=>{const Ir=new URLSearchParams;R&&Ir.set("search",R),q!=="all"&&Ir.set("type",q),H!=="all"&&Ir.set("status",H);const mi=Ir.toString();t(`/mission-control/contacts/${Zt.id}${mi?`?${mi}`:""}`)},children:[e.jsx(lt,{onClick:Ir=>Ir.stopPropagation(),children:e.jsx(Bo,{checked:Me.has(Zt.id),onCheckedChange:()=>ss(Zt.id)})}),e.jsxs(lt,{className:"font-medium",children:[Zt.first_name," ",Zt.last_name]}),e.jsx(lt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(TI,{score:$r,size:"sm"}),e.jsx(X0e,{contact:Zt})]})}),e.jsx(lt,{children:e.jsx(TI,{score:$r,size:"sm",showScore:!0})}),e.jsx(lt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[Zt.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(br,{className:"h-3 w-3"}),Zt.email]}),Zt.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Qn,{className:"h-3 w-3"}),Zt.phone]})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(((an=Zt.lead_source_ref)==null?void 0:an.name)||Zt.lead_source)&&e.jsx(rt,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((Ra=Zt.lead_source_ref)==null?void 0:Ra.name)||Zt.lead_source}),(Zn=Zt.tags)==null?void 0:Zn.map(Ir=>{var mi;return e.jsx(rt,{variant:"secondary",className:"text-xs",children:(mi=Ir.relationship_type)==null?void 0:mi.name},Ir.id)}),e.jsx(LLe,{contactId:Zt.id,tags:_==null?void 0:_.filter(Ir=>Ir.contact_id===Zt.id)}),e.jsx(ILe,{deal:es})]})}),e.jsx(lt,{children:e.jsx("div",{className:"text-sm",children:$r.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Tn,{className:"h-3 w-3"}),ys(new Date($r.lastTouchDate),"MMM d, yyyy")]}):e.jsx("span",{className:"text-muted-foreground text-xs italic",children:"Never contacted"})})}),e.jsx(lt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:Zt.created_at?ys(new Date(Zt.created_at),"MMM d, yyyy"):"—"})}),e.jsx(lt,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(PLe,{birthday:Zt.birthday,homeAnniversary:Zt.home_anniversary,contactId:Zt.id,contactName:`${Zt.first_name}${Zt.last_name?" "+Zt.last_name:""}`,contactAddress:[Zt.address,Zt.city,Zt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Zt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ys(gl(Zt.birthday),"MMM d")]}),Zt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(On,{className:"h-3 w-3"}),ys(gl(Zt.home_anniversary),"MMM d")]})]})]})}),e.jsx(lt,{children:e.jsx(ALe,{contact:Zt,onEdit:ae,onDelete:kn,onSnooze:(Ir,mi)=>{Ne(Ir),we(mi)},showLeadPondAction:qe,onSendToLeadPond:as,showTransferAction:Ze,onTransfer:Tt})})]},Zt.id)})})]})})}),Is>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsxs("span",{children:["Showing ",(gr-1)*De+1,"–",Math.min(gr*De,Is)," of ",Is.toLocaleString()," contacts"]}),e.jsxs(sr,{value:String(De),onValueChange:Zt=>{Rt(Number(Zt)),ut(1)},children:[e.jsx(er,{className:"w-[80px] h-8",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"50",children:"50"}),e.jsx(At,{value:"100",children:"100"}),e.jsx(At,{value:"250",children:"250"})]})]}),e.jsx("span",{className:"text-xs",children:"per page"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",disabled:gr<=1,onClick:()=>ut(1),children:"First"}),e.jsx(K,{variant:"outline",size:"sm",disabled:gr<=1,onClick:()=>ut(Zt=>Zt-1),children:e.jsx(zl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",gr," of ",qs]}),e.jsx(K,{variant:"outline",size:"sm",disabled:gr>=qs,onClick:()=>ut(Zt=>Zt+1),children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",disabled:gr>=qs,onClick:()=>ut(qs),children:"Last"})]})]}),e.jsx(_s,{open:Q||!!re,onOpenChange:Zt=>{Zt||(de(!1),ae(null),nn())},children:e.jsxs(vs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:re?"Edit Contact":"Add Contact"})}),e.jsxs("form",{onSubmit:ia,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"first_name",children:"First Name *"}),e.jsx(Re,{id:"first_name",value:is.first_name,onChange:Zt=>ar({...is,first_name:Zt.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"last_name",children:"Last Name"}),e.jsx(Re,{id:"last_name",value:is.last_name,onChange:Zt=>ar({...is,last_name:Zt.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",value:is.email,onChange:Zt=>ar({...is,email:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone"}),e.jsx(Re,{id:"phone",value:is.phone,onChange:Zt=>ar({...is,phone:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"address",children:"Address"}),e.jsx(Re,{id:"address",value:is.address,onChange:Zt=>ar({...is,address:Zt.target.value}),placeholder:"Street address"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"city",children:"City"}),e.jsx(Re,{id:"city",value:is.city,onChange:Zt=>ar({...is,city:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"state",children:"State"}),e.jsx(Re,{id:"state",value:is.state,onChange:Zt=>ar({...is,state:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"zip_code",children:"Zip"}),e.jsx(Re,{id:"zip_code",value:is.zip_code,onChange:Zt=>ar({...is,zip_code:Zt.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"birthday",children:"Birthday"}),e.jsx(Re,{id:"birthday",type:"date",value:is.birthday,onChange:Zt=>ar({...is,birthday:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(Re,{id:"home_anniversary",type:"date",value:is.home_anniversary,onChange:Zt=>ar({...is,home_anniversary:Zt.target.value})})]})]}),re&&e.jsx(Q0e,{contactId:re.id,currentSpouseContactId:(re==null?void 0:re.spouse_contact_id)||null,currentSpouseName:(re==null?void 0:re.spouse_name)||null,currentSpouseEmail:(re==null?void 0:re.spouse_email)||null,onLink:Zt=>L.mutate({contactId:re.id,spouseContactId:Zt}),onUnlink:()=>L.mutate({contactId:re.id,spouseContactId:null}),isEditing:!0}),e.jsx(jJe,{value:is.lead_source_id,onChange:Zt=>ar({...is,lead_source_id:Zt})}),e.jsxs("div",{children:[e.jsx(ve,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:p==null?void 0:p.filter(Zt=>Zt.active).map(Zt=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Bo,{checked:is.tagIds.includes(Zt.id),onCheckedChange:$r=>{ar($r?{...is,tagIds:[...is.tagIds,Zt.id]}:{...is,tagIds:is.tagIds.filter(es=>es!==Zt.id)})}}),e.jsx("span",{className:"text-sm",children:Zt.name})]},Zt.id))})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"notes",children:"Notes"}),e.jsx(Ar,{id:"notes",value:is.notes,onChange:Zt=>ar({...is,notes:Zt.target.value}),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{de(!1),ae(null),nn()},children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:S.isPending||T.isPending,children:[re?"Update":"Create"," Contact"]})]})]})]})}),e.jsx(Bms,{open:le,onOpenChange:he,relationshipTypes:(p==null?void 0:p.filter(Zt=>Zt.active))||[],onSuccess:()=>{he(!1)}}),e.jsx(Ums,{open:be,onOpenChange:_e,onComplete:()=>_e(!1)}),e.jsx(Dce,{open:!!je,onOpenChange:Zt=>{Zt||Ne(null)},contactId:je||"",contactName:Ge}),e.jsx(sps,{open:ot,onOpenChange:nt}),e.jsx(rps,{open:Se,onOpenChange:it}),e.jsx(OKe,{open:He,onOpenChange:et,contactIds:Qe,contactNames:Qe.map(Zt=>{const $r=Ct.find(es=>es.id===Zt);return $r?`${$r.first_name} ${$r.last_name||""}`.trim():""}),onComplete:()=>{We([]),Te(new Set),Ae(!1)}})]})]})})}function aps(){return wt({queryKey:["video-script-categories"],queryFn:async()=>{const{data:t,error:s}=await G.from("video_script_categories").select("*").order("sort_order");if(s)throw s;return t}})}function ips(t){return wt({queryKey:["video-scripts",t],queryFn:async()=>{let s=G.from("video_scripts").select("*, category:video_script_categories(*)").eq("is_active",!0).order("title");const{data:r,error:n}=await s;if(n)throw n;return r}})}function ops(){const{user:t}=Hs();return wt({queryKey:["user-video-scripts",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await G.from("user_video_scripts").select("*, category:video_script_categories(*)").eq("owner_user_id",t.id).order("title");if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function lps(){const{user:t}=Hs(),s=rs();return Dt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await G.from("user_video_scripts").insert([{owner_user_id:t.id,source_script_id:r.id,category_id:r.category_id,title:r.title,script_text:r.script_text,tags:r.tags,is_custom:!1}]).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["user-video-scripts"]})}})}function cps(t){const{user:s}=Hs();return wt({queryKey:["agent-videos",s==null?void 0:s.id,t],queryFn:async()=>{if(!(s!=null&&s.id))return[];let r=G.from("agent_videos").select("*, contact:innercircle_contacts(id, first_name, last_name)").eq("owner_user_id",s.id).order("created_at",{ascending:!1});r=r.eq("is_deleted",!1);const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!(s!=null&&s.id)})}function dps(t){return wt({queryKey:["agent-video",t],queryFn:async()=>{const{data:s,error:r}=await G.from("agent_videos").select("*, contact:innercircle_contacts(id, first_name, last_name)").eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function xS(){const{user:t}=Hs(),s=rs();return Dt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await G.from("agent_videos").insert([{owner_user_id:t.id,contact_id:r.contact_id,bunny_video_id:r.bunny_video_id,playback_url:r.playback_url,thumbnail_url:r.thumbnail_url,preview_url:r.preview_url,duration_seconds:r.duration_seconds,file_size_mb:r.file_size_mb||0,title:r.title,notes:r.notes,task_id:r.task_id,status:r.status||"processing",touch_type:r.touch_type||"video",page_template:"default"}]).select("*, share_token").single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["agent-videos"]}),s.invalidateQueries({queryKey:["storage-usage"]})}})}function ups(){const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("agent_videos").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["agent-videos"]}),t.invalidateQueries({queryKey:["agent-video",s.id]})}})}function hps(){const t=rs();return Dt({mutationFn:async({id:s,bunnyVideoId:r,hardDelete:n=!1})=>{if(console.log("Deleting video:",{id:s,bunnyVideoId:r,hardDelete:n}),r){console.log("Calling bunny-upload delete for videoId:",r);const{data:a,error:o}=await G.functions.invoke("bunny-upload",{body:{action:"delete",videoId:r,isAgentVideo:!0}});o?console.error("Failed to delete from Bunny:",o):console.log("Bunny delete response:",a)}else console.warn("No bunnyVideoId provided, skipping Bunny.net deletion");if(n){console.log("Hard deleting from database:",s);const{error:a}=await G.from("agent_videos").delete().eq("id",s);if(a)throw a}else{console.log("Soft deleting from database:",s);const{error:a}=await G.from("agent_videos").update({is_deleted:!0}).eq("id",s);if(a)throw a}console.log("Video deletion complete")},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-videos"]}),t.invalidateQueries({queryKey:["storage-usage"]})}})}function Fce(){const{user:t}=Hs();return wt({queryKey:["storage-usage",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:s,error:r}=await G.from("agent_storage_usage").select("*").eq("user_id",t.id).maybeSingle();if(r)throw r;return s||{user_id:t.id,total_storage_mb:0,storage_tier:"basic",max_storage_mb:1024}},enabled:!!(t!=null&&t.id)})}function NJe(){const{data:t,isLoading:s}=Fce(),r=t?t.total_storage_mb0?t.total_storage_mb/t.max_storage_mb*100:0,o=a>=80;return{canRecord:r,remainingMb:n,usagePercent:a,isNearLimit:o,storage:t,isLoading:s}}async function fD(t){const{data:s,error:r}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:t,isAgentVideo:!0}});if(r)throw r;return s}async function gD(t){const{data:s,error:r}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}async function oM(t){const{data:s,error:r}=await G.functions.invoke("bunny-upload",{body:{action:"status",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}function mps(){const{user:t}=Hs(),s=rs();return Dt({mutationFn:async({contactId:r,videoId:n,notes:a})=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:o}=await G.from("action_types").select("id").eq("name","Video").single();if(!o)throw new Error("Video action type not found");const{data:l,error:i}=await G.from("contact_touch_logs").insert([{owner_user_id:t.id,contact_id:r,action_type_id:o.id,notes:a||`Quick Video Touch - Video ID: ${n}`}]).select().single();if(i)throw i;return l},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-touch-logs"]}),s.invalidateQueries({queryKey:["contacts"]})}})}function pps(t){return wt({queryKey:["contact-video-replies",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("video_replies").select(` *, video:agent_videos(id, title, thumbnail_url, playback_url) `).eq("contact_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function fps(t){return wt({queryKey:["client-portal",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("client_portals").select("*").eq("deal_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function U2e(){const t=Ya(),s=rs();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("client_portals").insert({deal_id:r.deal_id,owner_user_id:t,slug:"",is_enabled:r.is_enabled??!0,visibility:r.visibility||"private",require_onboarding:r.require_onboarding??!0,allow_spouse:r.allow_spouse??!1,client_name:r.client_name||null,client_email:r.client_email||null,client_phone:r.client_phone||null,invite_method:r.invite_method||"email"}).select().single();if(a)throw a;return n},onSuccess:(r,n)=>{s.invalidateQueries({queryKey:["client-portal",n.deal_id]})}})}function xD(){const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("client_portals").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function gps(){const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("client_portals").update({archived_at:new Date().toISOString(),is_enabled:!1}).eq("id",s).select().single();if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function xps(){const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("client_portals").update({archived_at:null}).eq("id",s).select().single();if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function yps(){const t=rs();return Dt({mutationFn:async({id:s,dealId:r})=>{await G.from("portal_updates").delete().eq("portal_id",s);const{error:n}=await G.from("client_portals").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function kJe(){const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("portal_updates").insert({portal_id:s.portal_id,title:s.title,content:s.content||null,video_url:s.video_url||null,is_stage_change:s.is_stage_change||!1}).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["portal-updates",r.portal_id]})}})}function vps(){const t=Ya();return wt({queryKey:["portal-custom-questions",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("portal_custom_questions").select("*").eq("owner_user_id",t).eq("is_active",!0).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function _ps(){const t=Ya(),s=rs();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("portal_custom_questions").insert({owner_user_id:t,question_text:r.question_text,field_type:r.field_type,options:r.options||[],is_required:r.is_required||!1,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function bps(){const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("portal_custom_questions").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function wps(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("portal_custom_questions").update({is_active:!1}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function Z0(t){const s=window.location.hostname;return s==="localhost"||s.includes("lovable.app")?`${window.location.origin}/portal/${t}`:`https://clients.relevelup.com/${t}`}function jps({contactId:t}){const s=Pr(),r=rs(),[n,a]=C.useState(null),[o,l]=C.useState(!1),[i,d]=C.useState(!1),[u,p]=C.useState(""),[f,y]=C.useState(""),[_,b]=C.useState(null),w=xD(),j=kJe(),{data:k,isLoading:S}=wt({queryKey:["contact-portals",t],queryFn:async()=>{const{data:q,error:U}=await G.from("deal_pipeline").select("id, deal_name, deal_type").eq("contact_id",t);if(U)throw U;if(!q||q.length===0)return[];const H=q.map(te=>te.id),{data:Y,error:se}=await G.from("client_portals").select("*").in("deal_id",H).is("archived_at",null);if(se)throw se;return(Y||[]).map(te=>({...te,deal:q.find(Q=>Q.id===te.deal_id)}))},enabled:!!t}),T=(k==null?void 0:k.map(q=>q.id))||[],{data:I}=wt({queryKey:["contact-portal-updates",T],queryFn:async()=>{if(T.length===0)return{};const{data:q,error:U}=await G.from("portal_updates").select("*").in("portal_id",T).order("created_at",{ascending:!1});if(U)throw U;const H={};return(q||[]).forEach(Y=>{H[Y.portal_id]||(H[Y.portal_id]=Y)}),H},enabled:T.length>0}),L=q=>{navigator.clipboard.writeText(Z0(q)),a(q),fe.success("Portal link copied!"),setTimeout(()=>a(null),2e3)},R=async q=>{u.trim()&&(await j.mutateAsync({portal_id:q,title:u,content:f||void 0}),d(!1),p(""),y(""),r.invalidateQueries({queryKey:["contact-portal-updates"]}),fe.success("Portal update posted!"))},$=async()=>{_&&(await w.mutateAsync({id:_.id,welcome_message:_.welcome_message,next_step_text:_.next_step_text,is_enabled:_.is_enabled,show_post_close_tips:_.show_post_close_tips,review_url:_.review_url}),l(!1),b(null),r.invalidateQueries({queryKey:["contact-portals",t]}),fe.success("Portal settings updated!"))};return S||!k||k.length===0?null:e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Lm,{className:"h-4 w-4"}),"Client Portal"]})}),e.jsx(Oe,{className:"space-y-3",children:k.map(q=>{var se,te,Q;const U=((se=q.stage_mapping)==null?void 0:se.length)>0?q.stage_mapping:G_e(((te=q.deal)==null?void 0:te.deal_type)||"buyer"),H=U==null?void 0:U[q.current_stage_index??0],Y=I==null?void 0:I[q.id];return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:((Q=q.deal)==null?void 0:Q.deal_name)||"Portal"}),H&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Stage: ",H.label||H.name]})]}),e.jsx(rt,{variant:q.is_enabled?"default":"secondary",className:"text-[10px] flex-shrink-0",children:q.is_enabled?"Active":"Disabled"})]}),Y&&e.jsxs("div",{className:"bg-muted/50 rounded-md p-2",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:Y.title}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:ys(new Date(Y.created_at),"MMM d, yyyy")})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>L(q.slug),children:[n===q.slug?e.jsx(ha,{className:"h-3 w-3 mr-1"}):e.jsx(ai,{className:"h-3 w-3 mr-1"}),"Copy Link"]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>window.open(Z0(q.slug),"_blank"),children:[e.jsx(sn,{className:"h-3 w-3 mr-1"}),"View"]}),e.jsxs(_s,{open:i,onOpenChange:d,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>d(!0),children:[e.jsx(io,{className:"h-3 w-3 mr-1"}),"Post Update"]})}),e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Title"}),e.jsx(Re,{value:u,onChange:de=>p(de.target.value),placeholder:"e.g. Inspection completed!"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Details (optional)"}),e.jsx(Ar,{value:f,onChange:de=>y(de.target.value),placeholder:"Add more details...",rows:3})]}),e.jsxs(K,{onClick:()=>R(q.id),disabled:!u.trim()||j.isPending,className:"w-full",children:[e.jsx(aa,{className:"h-4 w-4 mr-1"}),"Post Update"]})]})]})]}),e.jsxs(_s,{open:o,onOpenChange:l,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{b({...q}),l(!0)},children:[e.jsx($l,{className:"h-3 w-3 mr-1"}),"Settings"]})}),e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Portal Settings"})}),_&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Portal Enabled"}),e.jsx(Br,{checked:_.is_enabled,onCheckedChange:de=>b({..._,is_enabled:de})})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Welcome Message"}),e.jsx(Ar,{value:_.welcome_message||"",onChange:de=>b({..._,welcome_message:de.target.value}),placeholder:"Welcome to your home journey!",rows:2})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Next Step"}),e.jsx(Re,{value:_.next_step_text||"",onChange:de=>b({..._,next_step_text:de.target.value}),placeholder:"What your client should do next..."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Review URL"}),e.jsx(Re,{value:_.review_url||"",onChange:de=>b({..._,review_url:de.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Show Post-Close Tips"}),e.jsx(Br,{checked:_.show_post_close_tips,onCheckedChange:de=>b({..._,show_post_close_tips:de})})]}),e.jsx(Rl,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:$,disabled:w.isPending,className:"flex-1",children:"Save Settings"}),e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/pipeline?deal=${q.deal_id}`),children:[e.jsx($i,{className:"h-4 w-4 mr-1"}),"Full Settings"]})]})]})]})]})]}),k.length>1&&e.jsx(Rl,{})]},q.id)})})]})}function Nps({videoId:t}){var l;const{data:s,isLoading:r,error:n}=dps(t);if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(xs,{className:"w-full aspect-video rounded-lg"}),e.jsx(xs,{className:"h-4 w-1/3"})]});if(n||!s||s.is_deleted)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Ju,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-medium",children:"Video Unavailable"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"This video has been deleted or is no longer available."})]});const a=i=>{let d=i;return d.includes("iframe.mediadelivery.net/play/")&&(d=d.replace("/play/","/embed/"),d+=(d.includes("?")?"&":"?")+"autoplay=true&responsive=true"),d},o=(l=s.playback_url)==null?void 0:l.includes("iframe.mediadelivery.net");return e.jsxs("div",{className:"space-y-4",children:[s.playback_url?e.jsx("div",{className:"relative w-full aspect-video bg-black rounded-lg overflow-hidden",children:o?e.jsx("iframe",{src:a(s.playback_url),title:s.title||"Video preview",className:"absolute top-0 left-0 w-full h-full",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsx("video",{src:s.playback_url,controls:!0,autoPlay:!0,className:"absolute top-0 left-0 w-full h-full object-contain"})}):e.jsx("div",{className:"w-full aspect-video bg-muted rounded-lg flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Video is still processing..."})}),s.title&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:s.title}),s.notes&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.notes})]})]})}function kps({contactId:t}){const s=Pr(),[r,n]=C.useState(!1),{data:a,isLoading:o}=wt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:f,error:y}=await G.from("deal_tasks").select(` id, title, priority, status, due_date, completed_at, deal:deal_pipeline(id, deal_name) `).eq("contact_id",t).order("status").order("due_date",{ascending:!0,nullsFirst:!1});if(y)throw y;return f},enabled:!!t}),l=async(f,y)=>{const _=y==="done"?"todo":"done";await G.from("deal_tasks").update({status:_,completed_at:_==="done"?new Date().toISOString():null}).eq("id",f),window.dispatchEvent(new CustomEvent("refetch-contact-tasks"))},{refetch:i}=wt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:f,error:y}=await G.from("deal_tasks").select(` id, title, priority, status, due_date, completed_at, deal:deal_pipeline(id, deal_name) `).eq("contact_id",t).order("status").order("due_date",{ascending:!0,nullsFirst:!1});if(y)throw y;return f},enabled:!!t}),d={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"},u=(a==null?void 0:a.filter(f=>f.status!=="done"))||[],p=(a==null?void 0:a.filter(f=>f.status==="done"))||[];return e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(ha,{className:"h-4 w-4"}),"Tasks",u.length>0&&e.jsx(rt,{variant:"secondary",className:"text-xs",children:u.length})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/tasks"),children:"View All"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>n(!0),children:e.jsx(Zs,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx(Oe,{className:"space-y-1",children:o?e.jsx(xs,{className:"h-8 w-full"}):u.length===0&&p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No tasks yet"}):e.jsxs(e.Fragment,{children:[u.map(f=>e.jsxs("button",{onClick:async()=>{await l(f.id,f.status),i()},className:"w-full text-left flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/50 transition-colors group",children:[e.jsx("div",{className:"h-4 w-4 rounded-full border-2 border-muted-foreground/30 shrink-0 group-hover:border-primary"}),e.jsxs("span",{className:"text-sm flex-1 truncate",children:[d[f.priority]," ",f.title]}),f.due_date&&e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ys(new Date(f.due_date),"MMM d")})]},f.id)),p.length>0&&e.jsx("div",{className:"pt-1 border-t mt-1",children:e.jsxs("p",{className:"text-[10px] text-muted-foreground px-2 py-1",children:[p.length," completed"]})})]})}),r&&e.jsx(Sps,{contactId:t,open:r,onOpenChange:f=>{n(f),f||i()}})]})}function Sps({contactId:t,open:s,onOpenChange:r}){const[n,a]=C.useState(""),[o,l]=C.useState("medium"),[i,d]=C.useState(),{data:u}=wt({queryKey:["session"],queryFn:async()=>{const{data:f}=await G.auth.getSession();return f.session}}),p=async()=>{var y;if(!n.trim()||!((y=u==null?void 0:u.user)!=null&&y.id))return;const{error:f}=await G.from("deal_tasks").insert([{owner_user_id:u.user.id,contact_id:t,title:n.trim(),priority:o,status:"todo",due_date:i?ys(i,"yyyy-MM-dd"):null}]);if(f){console.error("Task create error:",f);return}r(!1)};return e.jsx(_s,{open:s,onOpenChange:r,children:e.jsxs(vs,{className:"sm:max-w-[400px]",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Add Task"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Title"}),e.jsx(Re,{value:n,onChange:f=>a(f.target.value),placeholder:"Task title...",onKeyDown:f=>f.key==="Enter"&&p()})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Priority"}),e.jsxs("select",{value:o,onChange:f=>l(f.target.value),className:"w-full h-10 rounded-md border border-input bg-background px-3 text-sm",children:[e.jsx("option",{value:"low",children:"🟢 Low"}),e.jsx("option",{value:"medium",children:"🟡 Medium"}),e.jsx("option",{value:"high",children:"🟠 High"}),e.jsx("option",{value:"urgent",children:"🔴 Urgent"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Due Date"}),e.jsx(Re,{type:"date",value:i?ys(i,"yyyy-MM-dd"):"",onChange:f=>d(f.target.value?new Date(f.target.value+"T00:00:00"):void 0)})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{onClick:p,disabled:!n.trim(),children:"Create Task"})]})]})]})})}function Cps({contactId:t}){const s=Pr(),{data:r,isLoading:n}=wt({queryKey:["contact-linked-deals",t],queryFn:async()=>{const{data:a,error:o}=await G.from("deal_pipeline").select(` id, deal_name, deal_type, expected_price, property_address, stage:deal_pipeline_stages(id, name, color, icon, is_won_stage, is_lost_stage) `).eq("contact_id",t).order("updated_at",{ascending:!1});if(o)throw o;return a},enabled:!!t});return n||!r||r.length===0?null:e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(rh,{className:"h-4 w-4"}),"Linked Deals"]})}),e.jsx(Oe,{className:"space-y-2",children:r.map(a=>{const o=a.stage;return e.jsx("button",{onClick:()=>s(`/mission-control/pipeline?deal=${a.id}`),className:"w-full text-left p-3 rounded-lg border hover:bg-accent transition-colors group",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:a.deal_name}),a.property_address&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:a.property_address}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(rt,{variant:"outline",className:"text-[10px] capitalize",children:a.deal_type}),o&&e.jsxs(rt,{variant:"outline",className:"text-[10px] gap-1",style:{borderColor:o.color,color:o.color,backgroundColor:`${o.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:o.color}}),o.name]})]})]}),e.jsx($i,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors flex-shrink-0"})]})},a.id)})})]})}function Mps(){var $e,ct,qe,Ze,Qe;const{contactId:t}=ko(),s=Pr(),[r]=Pc(),n=r.get("search")||"",a=r.get("type")||"all",o=r.get("status")||"all",{data:l,isLoading:i}=m5t(t||""),{data:d}=Rf(),{data:u}=UL(),{data:p}=VL(3650),{data:f}=Oce(365),{data:y}=pps(t),{contactsWithScores:_}=fle(),b=mbe(),w=pbe(),j=fbe(),k=_Ve(),[S,T]=C.useState(!1),[I,L]=C.useState({}),[R,$]=C.useState(!1),[q,U]=C.useState(null),[H,Y]=C.useState(""),[se,te]=C.useState(void 0),[Q,de]=C.useState(""),[re,ae]=C.useState(null),[le,he]=C.useState(!1),[be,_e]=C.useState(null),{isGmailConnected:je,gmailEmail:Ne}=Ny(),{data:Ge}=wt({queryKey:["gmail-sent-emails",t],queryFn:async()=>{const{data:We,error:He}=await G.from("gmail_sent_emails").select("*").eq("contact_id",t).order("sent_at",{ascending:!1});if(He)throw He;return We},enabled:!!t}),we=We=>{if(!We)return null;const He=We.match(/Video ID:\s*([a-f0-9-]+)/i);return He?He[1]:null},Me=C.useMemo(()=>{if(!_)return[];let We=_.filter(He=>{var Ft,as,Xt;const et=n===""||`${He.first_name} ${He.last_name}`.toLowerCase().includes(n.toLowerCase())||((Ft=He.email)==null?void 0:Ft.toLowerCase().includes(n.toLowerCase()))||((as=He.phone)==null?void 0:as.includes(n)),Tt=a==="all"||((Xt=He.tags)==null?void 0:Xt.some(ss=>ss.relationship_type_id===a));return et&&Tt});return o==="not-touched-90"?We=We.filter(He=>{const et=He.relationshipScore.daysSinceTouch;return et===null||et>90}):o==="at-risk"?We=We.filter(He=>He.relationshipScore.status==="at-risk"):o==="cooling"?We=We.filter(He=>He.relationshipScore.status==="cooling"):o==="warm"&&(We=We.filter(He=>He.relationshipScore.status==="warm")),We.map(He=>He.id)},[_,n,a,o]),Te=Me.indexOf(t||""),Fe=Te>0?Me[Te-1]:null,Ae=Te1&&Te!==-1,ut=We=>{const He=new URLSearchParams;n&&He.set("search",n),a!=="all"&&He.set("type",a),o!=="all"&&He.set("status",o);const et=He.toString();return`/mission-control/contacts/${We}${et?`?${et}`:""}`},De=C.useMemo(()=>{const We=((p==null?void 0:p.filter(et=>et.contact_id===t))||[]).map(et=>{var Xt,ss,is;const Tt=we(et.notes);let Ft=((Xt=et.action_type)==null?void 0:Xt.name)||"Touch",as=et.notes;if(Ft==="Other"&&((ss=et.notes)!=null&&ss.startsWith("["))){const ar=et.notes.indexOf("]");ar>0&&(Ft=et.notes.substring(1,ar),as=et.notes.substring(ar+1).replace(/^\s*—\s*/,"").trim()||null)}return{id:et.id,type:"touch",completed_at:et.completed_at,name:Ft,color:((is=et.action_type)==null?void 0:is.color)||"#3B82F6",notes:as,videoId:Tt}}),He=((f==null?void 0:f.filter(et=>et.contact_id===t))||[]).map(et=>({id:et.id,type:"popby",completed_at:et.completed_at,name:"Pop-by",color:"#F97316",notes:et.notes,videoId:null}));return[...We,...He].sort((et,Tt)=>new Date(Tt.completed_at).getTime()-new Date(et.completed_at).getTime())},[p,f,t]),Rt=()=>{var We;l&&(L({first_name:l.first_name||"",last_name:l.last_name||"",email:l.email||"",phone:l.phone||"",address:l.address||"",city:l.city||"",state:l.state||"",zip_code:l.zip_code||"",birthday:l.birthday||"",home_anniversary:l.home_anniversary||"",spouse_name:l.spouse_name||"",spouse_email:l.spouse_email||"",company_name:l.company_name||"",job_title:l.job_title||"",lead_source_id:l.lead_source_id||"",notes:l.notes||"",tagIds:((We=l.tags)==null?void 0:We.map(He=>He.relationship_type_id))||[]}),T(!0))},me=async()=>{await b.mutateAsync({id:t,...I,lead_source_id:I.lead_source_id||null}),T(!1)},Xe=async()=>{confirm("Are you sure you want to delete this contact?")&&(await w.mutateAsync(t),s("/mission-control/contacts"))},nt=(($e=u==null?void 0:u.find(We=>We.id===q))==null?void 0:$e.name)==="Other",Se=async()=>{if(!q||nt&&!Q.trim())return;const We=se?new Date(se.getFullYear(),se.getMonth(),se.getDate(),12,0,0).toISOString():void 0,He=nt?`[${Q.trim()}]${H?" — "+H:""}`:H;await j.mutateAsync({contactId:t,actionTypeId:q,notes:He,completedAt:We}),$(!1),U(null),Y(""),te(void 0),de("")},it=(We,He)=>{je&&l?(_e({email:We,name:He||`${l.first_name} ${l.last_name||""}`.trim()}),he(!0)):window.location.href=`mailto:${We}`};return i?e.jsx(Ts,{title:"Contact Details",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})})}):l?e.jsxs(e.Fragment,{children:[e.jsx(Ts,{title:`${l.first_name} ${l.last_name||""}`,description:"Contact details and activity",children:e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/contacts"),children:[e.jsx(zl,{className:"h-4 w-4 mr-1"}),"Back to Contacts"]}),Ue&&e.jsxs("div",{className:"flex items-center gap-1 ml-2 border-l pl-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Fe&&s(ut(Fe)),disabled:!Fe,className:"px-2",children:[e.jsx(zl,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only sm:not-sr-only sm:ml-1",children:"Prev"})]}),e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[Te+1," of ",Me.length]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Ae&&s(ut(Ae)),disabled:!Ae,className:"px-2",children:[e.jsx("span",{className:"sr-only sm:not-sr-only sm:mr-1",children:"Next"}),e.jsx(Ua,{className:"h-4 w-4"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end flex-wrap",children:[l.email&&e.jsxs(K,{variant:"outline",onClick:()=>it(l.email,`${l.first_name} ${l.last_name||""}`.trim()),children:[e.jsx(br,{className:"h-4 w-4 mr-1"}),"Email"]}),e.jsxs(K,{variant:"default",onClick:()=>s(`/mission-control/video/record?contact_id=${t}`),className:"bg-gradient-to-r from-primary to-primary/80",children:[e.jsx(Nn,{className:"h-4 w-4 mr-1"}),"Quick Video Touch"]}),e.jsxs(_s,{open:R,onOpenChange:$,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Log Action"]})}),e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Log an Action"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Action Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:u==null?void 0:u.filter(We=>We.active).map(We=>e.jsxs("button",{onClick:()=>U(We.id),className:` p-3 rounded-lg border text-left transition-all ${q===We.id?"border-primary bg-primary/10":"hover:bg-accent"} `,children:[e.jsx("div",{className:"font-medium",children:We.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:We.description})]},We.id))}),nt&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ve,{htmlFor:"custom-action-name",children:"What did you do?"}),e.jsx(Re,{id:"custom-action-name",value:Q,onChange:We=>de(We.target.value),placeholder:"e.g. Met a client for lunch, Dropped off a gift...",className:"mt-1"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Date (optional — backdate if needed)"}),e.jsxs(Co,{children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal mt-2",!se&&"text-muted-foreground"),children:[e.jsx(on,{className:"h-4 w-4 mr-2"}),se?ys(se,"PPP"):"Today (default)"]})}),e.jsx(No,{className:"w-auto p-0",align:"start",children:e.jsx(jp,{mode:"single",selected:se,onSelect:te,disabled:We=>We>new Date,initialFocus:!0,className:Pt("p-3 pointer-events-auto")})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"action-notes",children:"Notes (optional)"}),e.jsx(Ar,{id:"action-notes",value:H,onChange:We=>Y(We.target.value),placeholder:"Add any notes about this interaction...",rows:3})]}),e.jsxs(K,{onClick:Se,disabled:!q||nt&&!Q.trim()||j.isPending,className:"w-full",children:[e.jsx(ha,{className:"h-4 w-4 mr-1"}),"Complete Action"]})]})]})]}),e.jsxs(K,{variant:"outline",onClick:Rt,children:[e.jsx(Rc,{className:"h-4 w-4 mr-1"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:Xe,children:e.jsx(jr,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"bg-card border rounded-lg p-4 sm:p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold",children:[l.first_name," ",l.last_name||""]}),(((ct=l.lead_source_ref)==null?void 0:ct.name)||l.lead_source)&&e.jsx(rt,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((qe=l.lead_source_ref)==null?void 0:qe.name)||l.lead_source})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mt-2 text-muted-foreground",children:[l.email&&e.jsxs("button",{onClick:()=>it(l.email),className:"flex items-center gap-1 hover:text-primary transition-colors",children:[e.jsx(br,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:l.email})]}),l.phone&&e.jsxs("a",{href:`tel:${l.phone}`,className:"flex items-center gap-1 hover:text-primary transition-colors",children:[e.jsx(Qn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:l.phone})]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(X0e,{contact:l}),(Ze=l.tags)==null?void 0:Ze.map(We=>{const He=d==null?void 0:d.find(et=>et.id===We.relationship_type_id);return He?e.jsx(rt,{variant:"secondary",className:"text-xs",children:He.name},We.id):null})]}),e.jsx("div",{className:"mt-2",children:e.jsx(tps,{contactId:t})})]})}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs(Ee,{className:"md:col-span-2",children:[e.jsx(It,{children:e.jsx(Ot,{children:"Contact Information"})}),e.jsx(Oe,{children:S?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"first_name",children:"First Name"}),e.jsx(Re,{id:"first_name",value:I.first_name,onChange:We=>L({...I,first_name:We.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"last_name",children:"Last Name"}),e.jsx(Re,{id:"last_name",value:I.last_name,onChange:We=>L({...I,last_name:We.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",value:I.email,onChange:We=>L({...I,email:We.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone"}),e.jsx(Re,{id:"phone",value:I.phone,onChange:We=>L({...I,phone:We.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"address",children:"Street Address"}),e.jsx(Re,{id:"address",value:I.address,onChange:We=>L({...I,address:We.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(ve,{htmlFor:"city",children:"City"}),e.jsx(Re,{id:"city",value:I.city,onChange:We=>L({...I,city:We.target.value}),placeholder:"City"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"state",children:"State"}),e.jsx(Re,{id:"state",value:I.state,onChange:We=>L({...I,state:We.target.value}),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"zip_code",children:"Zip Code"}),e.jsx(Re,{id:"zip_code",value:I.zip_code,onChange:We=>L({...I,zip_code:We.target.value}),placeholder:"12345"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"birthday",children:"Birthday"}),e.jsx(Re,{id:"birthday",type:"date",value:I.birthday,onChange:We=>L({...I,birthday:We.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(Re,{id:"home_anniversary",type:"date",value:I.home_anniversary,onChange:We=>L({...I,home_anniversary:We.target.value})})]})]}),e.jsx(Rl,{}),e.jsx(Q0e,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:(l==null?void 0:l.spouse_name)||null,currentSpouseEmail:(l==null?void 0:l.spouse_email)||null,onLink:We=>k.mutate({contactId:t,spouseContactId:We}),onUnlink:()=>k.mutate({contactId:t,spouseContactId:null}),isEditing:!0}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"company_name",children:"Company"}),e.jsx(Re,{id:"company_name",value:I.company_name,onChange:We=>L({...I,company_name:We.target.value}),placeholder:"Enter company name"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"job_title",children:"Job Title"}),e.jsx(Re,{id:"job_title",value:I.job_title,onChange:We=>L({...I,job_title:We.target.value}),placeholder:"Enter job title"})]})]}),e.jsx(jJe,{value:I.lead_source_id||"",onChange:We=>L({...I,lead_source_id:We})}),e.jsxs("div",{children:[e.jsx(ve,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:d==null?void 0:d.filter(We=>We.active).map(We=>{var He;return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Bo,{checked:(He=I.tagIds)==null?void 0:He.includes(We.id),onCheckedChange:et=>{var Tt;L(et?{...I,tagIds:[...I.tagIds||[],We.id]}:{...I,tagIds:(Tt=I.tagIds)==null?void 0:Tt.filter(Ft=>Ft!==We.id)})}}),e.jsx("span",{className:"text-sm",children:We.name})]},We.id)})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"notes",children:"Notes"}),e.jsx(Ar,{id:"notes",value:I.notes,onChange:We=>L({...I,notes:We.target.value}),rows:4})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:me,disabled:b.isPending,children:"Save Changes"}),e.jsx(K,{variant:"outline",onClick:()=>T(!1),children:"Cancel"})]})]}):e.jsxs("div",{className:"space-y-4",children:[De.length>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Last Contacted:"})," ",ys(new Date(De[0].completed_at),"MMM d, yyyy")," ","(",De[0].name,")"]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:gap-6 gap-2",children:[l.email&&e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(br,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("button",{onClick:()=>it(l.email),className:"text-primary hover:underline truncate text-left",children:l.email})]}),l.phone&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qn,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("a",{href:`tel:${l.phone}`,className:"text-primary hover:underline",children:l.phone})]})]}),(l.address||l.city||l.state||l.zip_code)&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Oi,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{className:"flex flex-col",children:[l.address&&e.jsx("span",{children:l.address}),(l.city||l.state||l.zip_code)&&e.jsxs("span",{className:"text-muted-foreground",children:[[l.city,l.state].filter(Boolean).join(", "),l.zip_code&&` ${l.zip_code}`]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[l.birthday&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Birthday: ",ys(gl(l.birthday),"MMMM d")]})]}),l.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(On,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Home Anniversary: ",ys(gl(l.home_anniversary),"MMMM d")]})]}),l.created_at&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Zs,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Date Added: ",ys(new Date(l.created_at),"MMMM d, yyyy")]})]})]}),e.jsx(Rl,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(Q0e,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:l.spouse_name||null,currentSpouseEmail:l.spouse_email||null,onLink:We=>k.mutate({contactId:t,spouseContactId:We}),onUnlink:()=>k.mutate({contactId:t,spouseContactId:null}),isEditing:!1}),(l.company_name||l.job_title)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:l.job_title&&l.company_name?`${l.job_title} at ${l.company_name}`:l.job_title||l.company_name})]})]}),e.jsx(Rl,{}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:(Qe=l.tags)!=null&&Qe.length?l.tags.map(We=>{var He;return e.jsx(rt,{variant:"secondary",children:(He=We.relationship_type)==null?void 0:He.name},We.id)}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No relationship types assigned"})})]}),l.notes&&e.jsxs(e.Fragment,{children:[e.jsx(Rl,{}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Notes"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:l.notes})]})]})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(Oms,{contact:l,onLogTouch:()=>$(!0)}),e.jsx(Cps,{contactId:t}),e.jsx(jps,{contactId:t}),e.jsx(kps,{contactId:t}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Activity Log"})}),e.jsx(Oe,{children:De.length>0?e.jsx("div",{className:"space-y-4",children:De.map(We=>{var He;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[e.jsx("div",{className:"h-8 w-8 rounded-full flex items-center justify-center text-white text-xs",style:{backgroundColor:We.color},children:We.type==="popby"?e.jsx(po,{className:"h-4 w-4"}):(He=We.name)==null?void 0:He.charAt(0)}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:We.name}),We.videoId&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>ae(We.videoId),children:[e.jsx(ul,{className:"h-3 w-3 mr-1"}),"Preview"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ys(new Date(We.completed_at),"MMM d, yyyy h:mm a")}),We.notes&&!We.videoId&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:We.notes})]})]},We.id)})}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"})})]}),y&&y.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(io,{className:"h-5 w-5 text-primary"}),"Video Replies"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:y.map(We=>{var He,et;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[(He=We.video)!=null&&He.thumbnail_url?e.jsx("img",{src:We.video.thumbnail_url,alt:We.video.title||"Video",className:"h-12 w-16 object-cover rounded cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>ae(We.video_id)}):e.jsx("div",{className:"h-12 w-16 bg-muted rounded flex items-center justify-center cursor-pointer hover:bg-muted/80 transition-colors",onClick:()=>ae(We.video_id),children:e.jsx(Nn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:["Replied to: ",((et=We.video)==null?void 0:et.title)||"Untitled Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs flex-shrink-0",onClick:()=>ae(We.video_id),children:[e.jsx(ul,{className:"h-3 w-3 mr-1"}),"Watch"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ys(new Date(We.created_at),"MMM d, yyyy h:mm a")}),We.message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:['"',We.message,'"']})]})]},We.id)})})})]}),Ge&&Ge.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(aa,{className:"h-5 w-5 text-sky-500"}),"Sent Emails"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:Ge.map(We=>e.jsxs(_s,{children:[e.jsx(Ei,{asChild:!0,children:e.jsxs("button",{className:"w-full text-left flex items-start gap-3 p-3 rounded-lg border hover:bg-muted/50 transition-colors cursor-pointer",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-sky-500/10 flex items-center justify-center text-sky-600 flex-shrink-0",children:e.jsx(br,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:We.subject}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["To: ",We.to_email," · ",ys(new Date(We.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx(Ua,{className:"h-4 w-4 text-muted-foreground mt-1 flex-shrink-0"})]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[85vh] flex flex-col",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5 text-sky-500"}),We.subject]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["To: ",We.to_email," · ",ys(new Date(We.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden rounded-lg border bg-white",children:e.jsx("iframe",{srcDoc:We.body,className:"w-full h-[400px] border-0",sandbox:"",title:`Email: ${We.subject}`})})]})]},We.id))})})]})]}),e.jsx(_s,{open:!!re,onOpenChange:We=>!We&&ae(null),children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Video Preview"})}),re&&e.jsx(Nps,{videoId:re})]})})]})]})}),je&&l&&be&&e.jsx(JM,{open:le,onOpenChange:he,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:be.email},gmailEmail:Ne})]}):e.jsx(Ts,{title:"Contact Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"This contact was not found."}),e.jsx(K,{onClick:()=>s("/mission-control/contacts"),children:"Back to Contacts"})]})})}const OLe={Crown:Uh,FileText:In,Users:hr,Globe:Lm,Star:Gn,Phone:Qn,MessageSquare:io,PenTool:d_,Video:Nn,Gift:po},Rpe=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Tps(){var Qe,We;const t=Pr(),{user:s}=Hs(),{data:r}=Rf(),{data:n}=f5t(),{data:a}=w5t(),{data:o}=vVe(),{data:l}=UL(),{data:i}=p5t(),d=j5t(),u=g5t(),p=y5t(),f=v5t(),y=_5t(),_=b5t(),b=x5t(),[w,j]=C.useState(null),[k,S]=C.useState(!1),[T,I]=C.useState(null),[L,R]=C.useState(""),[$,q]=C.useState(""),[U,H]=C.useState([]),[Y,se]=C.useState(null),[te,Q]=C.useState(null),[de,re]=C.useState(!1),[ae,le]=C.useState(""),[he,be]=C.useState(""),[_e,je]=C.useState(""),[Ne,Ge]=C.useState(""),we=(He,et)=>a==null?void 0:a.some(Tt=>Tt.plan_id===He&&Tt.relationship_type_id===et&&Tt.active),Me=He=>a==null?void 0:a.find(et=>et.relationship_type_id===He&&et.active),Te=async(He,et)=>{const Tt=we(He,et);await d.mutateAsync({planId:He,relationshipTypeId:et,active:!Tt})},Fe=(n==null?void 0:n.filter(He=>He.active&&!He.owner_user_id))||[],Ae=(n==null?void 0:n.filter(He=>He.owner_user_id===(s==null?void 0:s.id)))||[],Ue=r==null?void 0:r.find(He=>He.id===w),ut=w?Me(w):null,De=n==null?void 0:n.find(He=>He.id===(ut==null?void 0:ut.plan_id)),Rt=async()=>{if(!L.trim())return;const He=await u.mutateAsync({name:L,description:$});He&&U.length>0&&await y.mutateAsync({planId:He.id,items:U}),ot()},me=async()=>{!L.trim()||!T||(await p.mutateAsync({id:T,name:L,description:$}),await y.mutateAsync({planId:T,items:U}),ot())},Xe=He=>{var et;I(He.id),R(He.name),q(He.description||""),H(((et=He.items)==null?void 0:et.map(Tt=>({month_number:Tt.month_number,action_type_id:Tt.action_type_id,default_script_id:Tt.default_script_id||void 0,notes:Tt.notes||void 0})))||[]),S(!0)},ot=()=>{S(!1),I(null),R(""),q(""),H([])},nt=(He,et)=>{Q(et)},Se=(He,et,Tt)=>{H(Ft=>[...Ft.filter(Xt=>Xt.month_number!==He),{month_number:He,action_type_id:et,default_script_id:Tt}]),se(null),Q(null)},it=He=>{H(et=>et.filter(Tt=>Tt.month_number!==He))},$e=async()=>{if(!ae.trim()||!he.trim()||!te)return;const He=await _.mutateAsync({actionTypeId:te,title:ae,scriptBody:he,emailSubject:_e||void 0,tone:Ne||void 0});He&&Y!==null&&Se(Y,te,He.id),re(!1),le(""),be(""),je(""),Ge("")},ct=te?i==null?void 0:i.filter(He=>He.action_type_id===te&&He.active):[],qe=He=>OLe[He||"Phone"]||Qn,Ze=He=>OLe[He||"Users"]||hr;return e.jsxs(Ts,{title:"Touchpoint Plans",description:"Assign plans to your contact groups",children:[e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Touchpoint Plans"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(zl,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs(K,{onClick:()=>S(!0),className:"w-full sm:w-auto",children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create Custom Plan"]})]}),e.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Your Contact Groups"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a group to assign a touchpoint plan"}),r==null?void 0:r.filter(He=>He.active).map(He=>{const et=Ze(He.icon),Tt=(o==null?void 0:o[He.id])||0,Ft=Me(He.id),as=n==null?void 0:n.find(ss=>ss.id===(Ft==null?void 0:Ft.plan_id)),Xt=w===He.id;return e.jsxs("button",{onClick:()=>j(He.id),className:` w-full flex items-center gap-3 p-4 rounded-lg border text-left transition-all ${Xt?"border-primary bg-primary/5 ring-2 ring-primary":"hover:bg-accent"} `,children:[e.jsx(et,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium",children:He.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Tt," contacts"]})]}),as?e.jsxs(rt,{variant:"secondary",className:"text-xs",children:[e.jsx(hi,{className:"h-3 w-3 mr-1"}),as.name.split(" ")[0]]}):e.jsx(rt,{variant:"outline",className:"text-xs text-muted-foreground",children:"No plan"})]},He.id)})]}),e.jsx("div",{className:"lg:col-span-2",children:w&&Ue?e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[(()=>{const He=Ze(Ue.icon);return e.jsx(He,{className:"h-5 w-5"})})(),Ue.name," Touchpoint Plan"]}),e.jsxs(pr,{children:["Choose a plan for your ",Ue.name," contacts"]})]}),e.jsxs(Oe,{className:"space-y-6",children:[De&&e.jsxs("div",{className:"p-4 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(hi,{className:"h-4 w-4 text-green-500"}),"Currently using: ",De.name]}),De.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:De.description})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>Te(De.id,w),children:"Disable"})]}),De.items&&De.items.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"12-Month Schedule"]}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:Rpe.map((He,et)=>{var Xt,ss;const Tt=((Xt=De.items)==null?void 0:Xt.filter(is=>is.month_number===et+1))||[],Ft=(ss=Tt[0])==null?void 0:ss.action_type,as=Ft?qe(Ft.icon):null;return e.jsxs("div",{className:` p-2 rounded border text-center ${Tt.length>0?"bg-primary/10 border-primary":"bg-muted"} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:He}),as&&e.jsx(as,{className:"h-4 w-4 mx-auto mt-1",style:{color:(Ft==null?void 0:Ft.color)||"#3B82F6"}})]},et)})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:De?"Switch to a Different Plan":"Choose a Plan"}),Fe.length>0&&e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Pre-built Templates"}),Fe.map(He=>{var Tt;const et=(De==null?void 0:De.id)===He.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${et?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:He.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Tt=He.items)==null?void 0:Tt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Duplicate as my own plan",disabled:b.isPending,onClick:()=>{const Ft=`${He.name} (Copy)`;b.mutate({sourcePlanId:He.id,newName:Ft})},children:e.jsx(ai,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:et?"outline":"default",disabled:et||d.isPending,onClick:()=>Te(He.id,w),children:et?"Active":"Use This"})]})]},He.id)})]}),Ae.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"My Custom Plans"}),Ae.map(He=>{var Tt;const et=(De==null?void 0:De.id)===He.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${et?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:He.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Tt=He.items)==null?void 0:Tt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Edit plan",onClick:()=>Xe(He),children:e.jsx(Fx,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",title:"Delete plan",onClick:()=>f.mutate(He.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})}),e.jsx(K,{size:"sm",variant:et?"outline":"default",disabled:et||d.isPending,onClick:()=>Te(He.id,w),children:et?"Active":"Use This"})]})]},He.id)})]}),Fe.length===0&&Ae.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No plans available. Create a custom plan to get started."})]})]})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(on,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"Select a contact group to view and assign plans"})]})})})]}),e.jsx(Ee,{className:"bg-muted/50",children:e.jsx(Oe,{className:"py-4",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{children:"How it works:"})," When you assign a plan to a contact group, those contacts will appear in your daily suggested actions based on the plan's schedule."]})})})]}),e.jsx(_s,{open:k,onOpenChange:He=>{He?S(!0):ot()},children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:T?"Edit Touchpoint Plan":"Create Custom Touchpoint Plan"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"plan-name",children:"Plan Name"}),e.jsx(Re,{id:"plan-name",value:L,onChange:He=>R(He.target.value),placeholder:"e.g., My VIP Plan"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"plan-description",children:"Description (optional)"}),e.jsx(Ar,{id:"plan-description",value:$,onChange:He=>q(He.target.value),placeholder:"Describe your plan...",rows:2})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"12-Month Schedule"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Click on a month to add a touchpoint"}),e.jsx("div",{className:"grid grid-cols-6 gap-2",children:Rpe.map((He,et)=>{const Tt=et+1,Ft=U.find(ss=>ss.month_number===Tt),as=Ft?l==null?void 0:l.find(ss=>ss.id===Ft.action_type_id):null,Xt=as?qe(as.icon):null;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>se(Y===Tt?null:Tt),className:` w-full p-3 rounded-lg border text-center transition-all ${Ft?"bg-primary/10 border-primary":"bg-muted hover:bg-accent"} ${Y===Tt?"ring-2 ring-primary":""} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:He}),Xt?e.jsx(Xt,{className:"h-5 w-5 mx-auto mt-1",style:{color:(as==null?void 0:as.color)||"#3B82F6"}}):e.jsx(Zs,{className:"h-5 w-5 mx-auto mt-1 text-muted-foreground/50"})]}),Ft&&e.jsx("button",{type:"button",onClick:ss=>{ss.stopPropagation(),it(Tt)},className:"absolute -top-1 -right-1 p-1 bg-destructive text-destructive-foreground rounded-full",children:e.jsx(Ur,{className:"h-3 w-3"})})]},et)})}),Y!==null&&!te&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:[e.jsxs("div",{className:"text-sm font-medium mb-2",children:["Step 1: Select action for ",Rpe[Y-1],":"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l==null?void 0:l.filter(He=>He.active).map(He=>{const et=qe(He.icon);return e.jsxs("button",{type:"button",onClick:()=>nt(Y,He.id),className:"flex items-center gap-2 px-3 py-2 rounded-lg border bg-background hover:bg-accent transition-colors",children:[e.jsx(et,{className:"h-4 w-4",style:{color:He.color||"#3B82F6"}}),e.jsx("span",{className:"text-sm",children:He.name})]},He.id)})})]}),Y!==null&&te&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm font-medium",children:"Step 2: Select a script (optional)"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Q(null),children:[e.jsx(zl,{className:"h-4 w-4 mr-1"})," Back"]})]}),e.jsxs("div",{className:"space-y-2 max-h-[300px] overflow-y-auto pr-1",children:[e.jsx("button",{type:"button",onClick:()=>Se(Y,te),className:"w-full flex items-center gap-3 p-3 rounded-lg border bg-background hover:bg-accent transition-colors text-left",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:"No Script"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Use without a predefined script"})]})}),ct==null?void 0:ct.map(He=>e.jsx("button",{type:"button",onClick:()=>Se(Y,te,He.id),className:"w-full flex items-center gap-3 p-3 rounded-lg border bg-background hover:bg-accent transition-colors text-left",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm",children:He.title}),He.tone&&e.jsx(rt,{variant:"secondary",className:"text-xs mt-1",children:He.tone}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:[He.script_body.substring(0,100),"..."]})]})},He.id)),e.jsxs("button",{type:"button",onClick:()=>re(!0),className:"w-full flex items-center gap-3 p-3 rounded-lg border border-dashed bg-background hover:bg-accent transition-colors text-left",children:[e.jsx(Zs,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:"Create Custom Script"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Write your own script for this action"})]})]})]})]})]}),U.length>0&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[U.length," touchpoint",U.length!==1?"s":""," per year"]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:ot,children:"Cancel"}),e.jsxs(K,{onClick:T?me:Rt,disabled:!L.trim()||u.isPending||p.isPending,children:[e.jsx(fu,{className:"h-4 w-4 mr-2"}),T?"Save Changes":"Create Plan"]})]})]})}),e.jsx(_s,{open:de,onOpenChange:re,children:e.jsxs(vs,{className:"max-w-lg",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Create Custom Script"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script-title",children:"Script Title"}),e.jsx(Re,{id:"script-title",value:ae,onChange:He=>le(He.target.value),placeholder:"e.g., Friendly Check-in Call"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script-tone",children:"Tone (optional)"}),e.jsxs(sr,{value:Ne,onValueChange:Ge,children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select tone..."})}),e.jsxs(tr,{children:[e.jsx(At,{value:"friendly",children:"Friendly"}),e.jsx(At,{value:"professional",children:"Professional"}),e.jsx(At,{value:"casual",children:"Casual"}),e.jsx(At,{value:"formal",children:"Formal"})]})]})]}),((We=(Qe=l==null?void 0:l.find(He=>He.id===te))==null?void 0:Qe.name)==null?void 0:We.toLowerCase().includes("email"))&&e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script-email-subject",children:"Email Subject"}),e.jsx(Re,{id:"script-email-subject",value:_e,onChange:He=>je(He.target.value),placeholder:"e.g., Quick Hello!"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script-body",children:"Script Content"}),e.jsx(Ar,{id:"script-body",value:he,onChange:He=>be(He.target.value),placeholder:"Write your script here... You can use {{FirstName}} and {{LastName}} as placeholders.",rows:6}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Tip: Use ","{{FirstName}}"," and ","{{LastName}}"," as placeholders"]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>re(!1),children:"Cancel"}),e.jsxs(K,{onClick:$e,disabled:!ae.trim()||!he.trim()||_.isPending,children:[e.jsx(fu,{className:"h-4 w-4 mr-2"}),"Create & Use Script"]})]})]})})]})}const Aps="0dde5abb-0005-4c8c-a471-30d0cbc9e280",Eps=[{value:"30",label:"Monthly (30 days)"},{value:"60",label:"Bi-Monthly (60 days)"},{value:"90",label:"Quarterly (90 days)"},{value:"180",label:"Twice a Year (180 days)"},{value:"365",label:"Yearly (365 days)"}];function Pps(){const t=Pr(),s=_Je(),{data:r}=Tms(),{data:n}=Rf(),{data:a}=$2e(),{data:o}=Oce(90),{data:l}=tm(),i=Lms(),d=Pms(),u=Ems(),p=Ims(),{data:f=[],isLoading:y}=wt({queryKey:["popby-templates"],queryFn:async()=>{const{data:de,error:re}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("category_id",Aps).order("publish_date",{ascending:!1});if(re)throw re;const{data:ae}=await G.from("template_likes").select("template_id"),{data:le}=await G.from("template_comments").select("template_id"),he=new Map;ae==null||ae.forEach(_e=>{he.set(_e.template_id,(he.get(_e.template_id)||0)+1)});const be=new Map;return le==null||le.forEach(_e=>{be.set(_e.template_id,(be.get(_e.template_id)||0)+1)}),(de||[]).map(_e=>({..._e,likesCount:he.get(_e.id)||0,commentsCount:be.get(_e.id)||0}))}}),_=de=>{const re=l==null?void 0:l.find(ae=>ae.id===de);return re?`${re.first_name} ${re.last_name||""}`.trim():"Unknown"},b=de=>{if(!de)return null;const re=r==null?void 0:r.find(ae=>ae.id===de);return(re==null?void 0:re.name)||null},[w,j]=C.useState(null),[k,S]=C.useState(!1),[T,I]=C.useState(!1),[L,R]=C.useState(!1),[$,q]=C.useState({popby_item_id:"",notes:""}),[U,H]=C.useState({name:"",description:""}),Y=async()=>{w&&(await d.mutateAsync({contact_id:w.id,popby_item_id:$.popby_item_id||void 0,notes:$.notes||void 0}),S(!1),j(null),q({popby_item_id:"",notes:""}))},se=async()=>{U.name.trim()&&(await u.mutateAsync({name:U.name.trim(),description:U.description.trim()||void 0}),R(!1),H({name:"",description:""}))},te=async(de,re)=>{await p.mutateAsync({relationship_type_id:de,frequency_days:parseInt(re)})},Q=de=>{var ae;const re=a==null?void 0:a.find(le=>le.relationship_type_id===de);return((ae=re==null?void 0:re.frequency_days)==null?void 0:ae.toString())||"90"};return e.jsx(Ts,{title:"Popbys",description:"Drop off gifts to stay top of mind",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Popbys"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-primary",children:i.thisWeekCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This Week"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-emerald-500",children:i.thisMonthCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This Month"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-amber-500",children:i.dueCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Due Now"})]})})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(K,{onClick:()=>t("/mission-control/popbys/map"),children:[e.jsx(Oi,{className:"h-4 w-4 mr-2"}),"View Map"]}),e.jsxs(K,{variant:"outline",onClick:()=>I(!0),children:[e.jsx($l,{className:"h-4 w-4 mr-2"}),"Frequency Settings"]}),e.jsxs(K,{variant:"outline",onClick:()=>R(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsxs(ka,{defaultValue:"due",children:[e.jsxs(_a,{children:[e.jsx(js,{value:"due",children:"Due for Popby"}),e.jsx(js,{value:"activity",children:"Recent Activity"}),e.jsx(js,{value:"library",children:"Popby Library"}),e.jsx(js,{value:"templates",children:"Popby Templates"})]}),e.jsx(zs,{value:"due",className:"space-y-4 mt-4",children:!s||s.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(po,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No contacts due for a popby right now!"}),e.jsx("p",{className:"text-sm mt-1",children:"Great job staying connected."})]})}):e.jsx("div",{className:"space-y-3",children:s.map(de=>e.jsx(Ee,{className:"hover:shadow-md transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium",children:[de.first_name," ",de.last_name]}),de.daysOverdue>0&&e.jsxs(rt,{variant:"destructive",className:"text-xs",children:[de.daysOverdue,"+ days overdue"]}),de.daysSinceLastPopby===null&&e.jsx(rt,{variant:"outline",className:"text-xs",children:"Never visited"})]}),e.jsxs("div",{className:"flex items-center gap-4 mt-1 text-sm text-muted-foreground",children:[de.address&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Oi,{className:"h-3 w-3"}),de.city||de.address]}),de.tags&&de.tags.length>0&&e.jsx("span",{children:de.tags.map(re=>{var ae;return(ae=re.relationship_type)==null?void 0:ae.name}).join(", ")})]}),de.lastPopby&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last popby: ",ys(new Date(de.lastPopby),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[de.phone&&e.jsx(K,{size:"sm",variant:"ghost",asChild:!0,children:e.jsx("a",{href:`tel:${de.phone}`,children:e.jsx(Qn,{className:"h-4 w-4"})})}),e.jsxs(K,{size:"sm",onClick:()=>{j(de),S(!0)},children:[e.jsx(hi,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})},de.id))})}),e.jsx(zs,{value:"activity",className:"space-y-4 mt-4",children:!o||o.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(Tn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No popby activity yet!"}),e.jsx("p",{className:"text-sm mt-1",children:"Start logging popbys to see your history here."})]})}):e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Recent Popby Log"})}),e.jsx(Oe,{className:"space-y-3",children:o.map(de=>e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0 last:pb-0",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/10 flex items-center justify-center",children:e.jsx(po,{className:"h-5 w-5 text-orange-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium",children:_(de.contact_id)}),b(de.popby_item_id)&&e.jsx(rt,{variant:"secondary",className:"text-xs",children:b(de.popby_item_id)})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ys(new Date(de.completed_at),"MMM d, yyyy h:mm a")}),de.notes&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:de.notes})]})]},de.id))})]})}),e.jsx(zs,{value:"library",className:"space-y-4 mt-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[r==null?void 0:r.map(de=>e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(po,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-medium",children:de.name}),de.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:de.description}),!de.owner_user_id&&e.jsx(rt,{variant:"secondary",className:"mt-2 text-xs",children:"Shared"})]})]})})},de.id)),e.jsx(Ee,{className:"border-dashed cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>R(!0),children:e.jsx(Oe,{className:"p-4 flex items-center justify-center h-full min-h-[100px]",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(Zs,{className:"h-8 w-8 mx-auto mb-2"}),e.jsx("p",{children:"Add New Popby Idea"})]})})})]})}),e.jsxs(zs,{value:"templates",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[f.length," template",f.length!==1?"s":""," found"]}),y&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(4)].map((de,re)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(xs,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(xs,{className:"h-5 w-3/4 mb-2"}),e.jsx(xs,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(xs,{className:"h-5 w-16"}),e.jsx(xs,{className:"h-5 w-20"})]})]})},re))}),!y&&f.length===0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(dl,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No popby templates available yet!"}),e.jsx("p",{className:"text-sm mt-1",children:"Check back soon for new templates."})]})}),!y&&f.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:f.map(de=>e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer",onClick:()=>t(`/templates/${de.id}`),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:de.preview_image_url?e.jsx("img",{src:de.preview_image_url,alt:de.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"})}),e.jsxs(Oe,{className:"p-4 flex flex-col",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:de.name}),de.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:poe(de.description)}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:e.jsx(rt,{variant:"secondary",className:"text-xs",children:"PopBys"})}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gu,{className:"h-3.5 w-3.5"}),de.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xc,{className:"h-3.5 w-3.5"}),de.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:re=>{re.stopPropagation(),t(`/templates/${de.id}`)},children:[e.jsx(sn,{className:"h-4 w-4"}),"View Template"]})]})]},de.id))})]})]}),e.jsx(_s,{open:k,onOpenChange:S,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsxs(ks,{children:["Log Popby for ",w==null?void 0:w.first_name," ",w==null?void 0:w.last_name]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Popby Item (optional)"}),e.jsxs(sr,{value:$.popby_item_id,onValueChange:de=>q(re=>({...re,popby_item_id:de})),children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select a popby item..."})}),e.jsx(tr,{children:r==null?void 0:r.map(de=>e.jsx(At,{value:de.id,children:de.name},de.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Notes (optional)"}),e.jsx(Ar,{placeholder:"Any notes about this popby...",value:$.notes,onChange:de=>q(re=>({...re,notes:de.target.value}))})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(K,{onClick:Y,disabled:d.isPending,children:"Log Popby"})]})]})}),e.jsx(_s,{open:T,onOpenChange:I,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Popby Frequency Settings"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set default popby frequency for each relationship type. You can override these per-contact."}),n==null?void 0:n.map(de=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx(ve,{className:"font-medium",children:de.name}),e.jsxs(sr,{value:Q(de.id),onValueChange:re=>te(de.id,re),children:[e.jsx(er,{className:"w-[180px]",children:e.jsx(rr,{})}),e.jsx(tr,{children:Eps.map(re=>e.jsx(At,{value:re.value,children:re.label},re.value))})]})]},de.id))]}),e.jsx(Un,{children:e.jsx(K,{onClick:()=>I(!1),children:"Done"})})]})}),e.jsx(_s,{open:L,onOpenChange:R,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Add Popby Idea"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Name *"}),e.jsx(Re,{placeholder:"e.g., Homemade cookies",value:U.name,onChange:de=>H(re=>({...re,name:de.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Ar,{placeholder:"Optional description...",value:U.description,onChange:de=>H(re=>({...re,description:de.target.value}))})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),e.jsx(K,{onClick:se,disabled:!U.name.trim()||u.isPending,children:"Add Item"})]})]})})]})})}const Ips=lS({property_address:Jl().min(1,"Property address is required"),city:Jl().optional(),state:Jl().optional(),zip:Jl().optional(),transaction_type:i$e(["buyer","seller"]),close_date:Jl().min(1,"Close date is required"),sale_price:tI().min(0,"Sale price must be positive"),commission_amount:tI().optional(),lead_source_id:Jl().optional(),client_type_id:Jl().optional(),contact_id:Jl().optional(),notes:Jl().optional(),is_win:xbt()});function SJe({open:t,onOpenChange:s,transaction:r}){const[n,a]=C.useState(!1),[o,l]=C.useState(""),[i,d]=C.useState(!1),[u,p]=C.useState(""),f=mle(),y=d3t(),{data:_}=EM(),{data:b}=Rf(),{data:w}=tm(),j=hle(),k=xbe(),{data:S}=ple(),T=(S==null?void 0:S.show_commission)??!0,I=nle({resolver:ale(Ips),defaultValues:{property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:new Date().toISOString().split("T")[0],sale_price:0,commission_amount:void 0,lead_source_id:void 0,client_type_id:void 0,contact_id:void 0,notes:"",is_win:!1}});C.useEffect(()=>{r?I.reset({property_address:r.property_address,city:r.city||"",state:r.state||"",zip:r.zip||"",transaction_type:r.transaction_type,close_date:r.close_date,sale_price:Number(r.sale_price),commission_amount:r.commission_amount?Number(r.commission_amount):void 0,lead_source_id:r.lead_source_id||void 0,client_type_id:r.client_type_id||void 0,contact_id:r.contact_id||void 0,notes:r.notes||"",is_win:r.is_win}):I.reset({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:new Date().toISOString().split("T")[0],sale_price:0,commission_amount:void 0,lead_source_id:void 0,client_type_id:void 0,contact_id:void 0,notes:"",is_win:!1})},[r,I]);const L=async U=>{const H={property_address:U.property_address,transaction_type:U.transaction_type,close_date:U.close_date,sale_price:U.sale_price,is_win:U.is_win,commission_amount:U.commission_amount||null,lead_source_id:U.lead_source_id||null,client_type_id:U.client_type_id||null,contact_id:U.contact_id||null,city:U.city||null,state:U.state||null,zip:U.zip||null,notes:U.notes||null};r?await y.mutateAsync({id:r.id,...H}):await f.mutateAsync(H),s(!1)},R=async()=>{if(!o.trim())return;const[U,...H]=o.trim().split(" "),Y=H.join(" ")||null,se=await j.mutateAsync({first_name:U,last_name:Y,tagIds:[]});se&&(I.setValue("contact_id",se.id),l(""),d(!1),a(!1))},$=async()=>{if(!u.trim())return;const U=await k.mutateAsync(u.trim());U&&(I.setValue("lead_source_id",U.id),p(""))},q=w==null?void 0:w.find(U=>U.id===I.watch("contact_id"));return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-lg max-h-[90vh]",children:[e.jsx(Ss,{children:e.jsx(ks,{children:r?"Edit Transaction":"Add Transaction"})}),e.jsx(Ri,{className:"max-h-[70vh] pr-4",children:e.jsx(ile,{...I,children:e.jsxs("form",{onSubmit:I.handleSubmit(L),className:"space-y-4",children:[e.jsx(wc,{control:I.control,name:"property_address",render:({field:U})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Property Address *"}),e.jsx(mc,{children:e.jsx(Re,{placeholder:"123 Main St",...U})}),e.jsx(Oh,{})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(wc,{control:I.control,name:"city",render:({field:U})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"City"}),e.jsx(mc,{children:e.jsx(Re,{placeholder:"City",...U})})]})}),e.jsx(wc,{control:I.control,name:"state",render:({field:U})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"State"}),e.jsx(mc,{children:e.jsx(Re,{placeholder:"TX",...U})})]})}),e.jsx(wc,{control:I.control,name:"zip",render:({field:U})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Zip"}),e.jsx(mc,{children:e.jsx(Re,{placeholder:"75001",...U})})]})})]}),e.jsx(wc,{control:I.control,name:"transaction_type",render:({field:U})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Transaction Type *"}),e.jsxs(sr,{onValueChange:U.onChange,value:U.value,children:[e.jsx(mc,{children:e.jsx(er,{children:e.jsx(rr,{placeholder:"Select type"})})}),e.jsxs(tr,{children:[e.jsx(At,{value:"buyer",children:"Buyer"}),e.jsx(At,{value:"seller",children:"Seller"})]})]}),e.jsx(Oh,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(wc,{control:I.control,name:"close_date",render:({field:U})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Close Date *"}),e.jsx(mc,{children:e.jsx(Re,{type:"date",...U})}),e.jsx(Oh,{})]})}),e.jsx(wc,{control:I.control,name:"sale_price",render:({field:U})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Sale Price *"}),e.jsx(mc,{children:e.jsx(Re,{type:"number",placeholder:"0",...U,onChange:H=>U.onChange(Number(H.target.value))})}),e.jsx(Oh,{})]})})]}),T&&e.jsx(wc,{control:I.control,name:"commission_amount",render:({field:U})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Commission"}),e.jsx(mc,{children:e.jsx(Re,{type:"number",placeholder:"0",...U,value:U.value??"",onChange:H=>U.onChange(H.target.value?Number(H.target.value):void 0)})})]})}),e.jsx(wc,{control:I.control,name:"lead_source_id",render:({field:U})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Lead Source"}),e.jsxs(sr,{onValueChange:U.onChange,value:U.value||"",children:[e.jsx(mc,{children:e.jsx(er,{children:e.jsx(rr,{placeholder:"Select source"})})}),e.jsx(tr,{children:_==null?void 0:_.map(H=>e.jsx(At,{value:H.id,children:H.name},H.id))})]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"Add custom source...",value:u,onChange:U=>p(U.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:$,disabled:!u.trim(),children:e.jsx(Zs,{className:"h-4 w-4"})})]}),e.jsx(wc,{control:I.control,name:"client_type_id",render:({field:U})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Client Type"}),e.jsxs(sr,{onValueChange:U.onChange,value:U.value||"",children:[e.jsx(mc,{children:e.jsx(er,{children:e.jsx(rr,{placeholder:"Select client type"})})}),e.jsx(tr,{children:b==null?void 0:b.map(H=>e.jsx(At,{value:H.id,children:H.name},H.id))})]})]})}),e.jsx(wc,{control:I.control,name:"contact_id",render:({field:U})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Client Contact"}),e.jsxs(Co,{open:n,onOpenChange:a,children:[e.jsx(Mo,{asChild:!0,children:e.jsx(mc,{children:e.jsxs(K,{variant:"outline",role:"combobox",className:Pt("w-full justify-between",!U.value&&"text-muted-foreground"),children:[q?`${q.first_name} ${q.last_name||""}`.trim():"Select contact",e.jsx(xf,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),e.jsxs(No,{className:"w-full p-0",align:"start",children:[e.jsxs(Mf,{children:[e.jsx(Tf,{placeholder:"Search contacts..."}),e.jsxs(Af,{children:[e.jsx(Ef,{children:e.jsxs("div",{className:"p-2 space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"No contact found."}),!i&&e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>d(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add New Contact"]})]})}),e.jsx(Pf,{children:w==null?void 0:w.map(H=>e.jsxs(Cm,{value:`${H.first_name} ${H.last_name||""}`,onSelect:()=>{U.onChange(H.id),a(!1)},children:[e.jsx(ha,{className:Pt("mr-2 h-4 w-4",H.id===U.value?"opacity-100":"opacity-0")}),H.first_name," ",H.last_name||""]},H.id))})]})]}),i&&e.jsxs("div",{className:"p-2 border-t space-y-2",children:[e.jsx(Re,{placeholder:"Enter contact name...",value:o,onChange:H=>l(H.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",onClick:R,disabled:!o.trim()||j.isPending,children:"Add Contact"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{d(!1),l("")},children:"Cancel"})]})]})]})]})]})}),e.jsx(wc,{control:I.control,name:"notes",render:({field:U})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Notes"}),e.jsx(mc,{children:e.jsx(Ar,{placeholder:"Any notes about this transaction...",...U})})]})}),e.jsx(wc,{control:I.control,name:"is_win",render:({field:U})=>e.jsxs(uc,{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(hc,{children:"Mark as Win 🏆"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Highlight this as a notable success"})]}),e.jsx(mc,{children:e.jsx(Br,{checked:U.value,onCheckedChange:U.onChange})})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:f.isPending||y.isPending,children:[r?"Update":"Add"," Transaction"]})]})]})})})]})})}function V2e({transactions:t,showCommission:s,isLoading:r,agentNameMap:n,readOnly:a}){const[o,l]=C.useState(null),[i,d]=C.useState(null),[u,p]=C.useState(""),[f,y]=C.useState("all"),[_,b]=C.useState("all"),[w,j]=C.useState("all"),[k,S]=C.useState(!1),T=u3t(),I=mle(),{data:L}=EM(),{data:R}=Rf(),$=eT(),q=Y=>{const{id:se,created_at:te,updated_at:Q,lead_source:de,client_type:re,contact:ae,...le}=Y;I.mutate(le)},U=()=>{i&&(T.mutate(i),d(null))},H=t.filter(Y=>{var ae,le,he,be;const se=u===""||Y.property_address.toLowerCase().includes(u.toLowerCase())||((le=(ae=Y.contact)==null?void 0:ae.first_name)==null?void 0:le.toLowerCase().includes(u.toLowerCase()))||((be=(he=Y.contact)==null?void 0:he.last_name)==null?void 0:be.toLowerCase().includes(u.toLowerCase())),te=f==="all"||Y.transaction_type===f,Q=_==="all"||Y.lead_source_id===_,de=w==="all"||Y.client_type_id===w,re=!k||Y.is_win;return se&&te&&Q&&de&&re});return r?e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6 space-y-4",children:[1,2,3].map(Y=>e.jsx(xs,{className:"h-16 w-full"},Y))})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs(Ot,{children:["Transactions (",H.length,")"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search...",value:u,onChange:Y=>p(Y.target.value),className:"pl-8 w-[150px]"})]}),e.jsxs(sr,{value:f,onValueChange:y,children:[e.jsx(er,{className:"w-[100px]",children:e.jsx(rr,{placeholder:"Type"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Types"}),e.jsx(At,{value:"buyer",children:"Buyer"}),e.jsx(At,{value:"seller",children:"Seller"})]})]}),e.jsxs(sr,{value:_,onValueChange:b,children:[e.jsx(er,{className:"w-[130px]",children:e.jsx(rr,{placeholder:"Lead Source"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Sources"}),L==null?void 0:L.map(Y=>e.jsx(At,{value:Y.id,children:Y.name},Y.id))]})]}),e.jsxs(K,{variant:k?"default":"outline",size:"sm",onClick:()=>S(!k),children:[e.jsx(rc,{className:"h-4 w-4 mr-1"}),"Wins"]})]})]})}),e.jsx(Oe,{children:H.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No transactions found"}):$?e.jsx("div",{className:"space-y-3",children:H.map(Y=>e.jsxs(Ee,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium truncate",children:Y.property_address}),Y.is_win&&e.jsx(rc,{className:"h-4 w-4 text-yellow-500 flex-shrink-0"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Y.city,Y.state?`, ${Y.state}`:""]})]}),e.jsx(rt,{variant:Y.transaction_type==="buyer"?"default":"secondary",children:Y.transaction_type})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Close Date: "}),g4e(Y.close_date)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Price: "}),Tl(Y.sale_price)]}),s&&Y.commission_amount&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Commission: "}),Tl(Y.commission_amount)]}),Y.lead_source&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Source: "}),Y.lead_source.name]}),Y.contact&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Client: "}),Y.contact.first_name," ",Y.contact.last_name]}),n&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Agent: "}),n[Y.owner_user_id]||"Unknown"]})]}),!a&&e.jsxs("div",{className:"flex justify-end gap-2 mt-3 pt-3 border-t",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>l(Y),children:e.jsx(Rc,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>q(Y),children:e.jsx(ai,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(Y.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})]},Y.id))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[n&&e.jsx(bt,{children:"Agent"}),e.jsx(bt,{children:"Property"}),e.jsx(bt,{children:"Type"}),e.jsx(bt,{children:"Close Date"}),e.jsx(bt,{children:"Sale Price"}),s&&e.jsx(bt,{children:"Commission"}),e.jsx(bt,{children:"Lead Source"}),e.jsx(bt,{children:"Client"}),!a&&e.jsx(bt,{className:"w-[50px]"})]})}),e.jsx(Pn,{children:H.map(Y=>{var se;return e.jsxs(Ns,{children:[n&&e.jsx(lt,{className:"font-medium text-sm",children:n[Y.owner_user_id]||"Unknown"}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[Y.is_win&&e.jsx(rc,{className:"h-4 w-4 text-yellow-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Y.property_address}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Y.city,Y.state?`, ${Y.state}`:""]})]})]})}),e.jsx(lt,{children:e.jsx(rt,{variant:Y.transaction_type==="buyer"?"default":"secondary",children:Y.transaction_type})}),e.jsx(lt,{children:g4e(Y.close_date)}),e.jsx(lt,{children:Tl(Y.sale_price)}),s&&e.jsx(lt,{children:Y.commission_amount?Tl(Y.commission_amount):"-"}),e.jsx(lt,{children:((se=Y.lead_source)==null?void 0:se.name)||"-"}),e.jsx(lt,{children:Y.contact?`${Y.contact.first_name} ${Y.contact.last_name||""}`.trim():"-"}),!a&&e.jsx(lt,{children:e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(af,{className:"h-4 w-4"})})}),e.jsxs(Md,{align:"end",children:[e.jsxs(Na,{onClick:()=>l(Y),children:[e.jsx(Rc,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Na,{onClick:()=>q(Y),children:[e.jsx(ai,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),e.jsxs(Na,{onClick:()=>d(Y.id),className:"text-destructive",children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},Y.id)})})]})})})]}),e.jsx(SJe,{open:!!o,onOpenChange:Y=>!Y&&l(null),transaction:o||void 0}),e.jsx(nc,{open:!!i,onOpenChange:Y=>!Y&&d(null),children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete Transaction?"}),e.jsx(Dl,{children:"This action cannot be undone. This will permanently delete this transaction."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:U,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function CJe({goals:t,stats:s,year:r,showCommission:n}){const a=new Date().getMonth()+1,o=new Date().getFullYear()===r?a:12,l=12-o,i=(y,_)=>{if(!_||_===0)return null;const b=Math.min(y/_*100,100),w=Math.max(_-y,0),j=l>0?w/l:0,k=o/12*100,S=b>=k?"ahead":b>=k*.8?"on-track":"behind";return{percent:b,remaining:w,pace:j,status:S}},d=i(s.totalTransactions,t.transactions_goal),u=i(s.totalVolume,t.volume_goal),p=n?i(s.totalCommission,t.gci_goal):null,f=y=>{switch(y){case"ahead":return e.jsxs(rt,{className:"bg-green-500 text-white",children:[e.jsx(ac,{className:"h-3 w-3 mr-1"}),"Ahead"]});case"on-track":return e.jsxs(rt,{variant:"secondary",children:[e.jsx(F0,{className:"h-3 w-3 mr-1"}),"On Track"]});case"behind":return e.jsxs(rt,{variant:"destructive",children:[e.jsx(fk,{className:"h-3 w-3 mr-1"}),"Behind"]});default:return null}};return!t.transactions_goal&&!t.volume_goal&&!t.gci_goal?null:e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Gh,{className:"h-5 w-5 text-primary"}),e.jsxs(Ot,{children:[r," Goals Progress"]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[t.transactions_goal&&d&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Transactions"}),f(d.status)]}),e.jsx(Ti,{value:d.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[s.totalTransactions," of ",t.transactions_goal]}),e.jsxs("span",{children:[Math.round(d.percent),"%"]})]}),d.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Math.ceil(d.pace),"/month to hit goal"]})]}),t.volume_goal&&u&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Volume"}),f(u.status)]}),e.jsx(Ti,{value:u.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Tl(s.totalVolume,!0)," of ",Tl(t.volume_goal,!0)]}),e.jsxs("span",{children:[Math.round(u.percent),"%"]})]}),u.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Tl(u.pace,!0),"/month"]})]}),n&&t.gci_goal&&p&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"GCI"}),f(p.status)]}),e.jsx(Ti,{value:p.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Tl(s.totalCommission,!0)," of ",Tl(t.gci_goal,!0)]}),e.jsxs("span",{children:[Math.round(p.percent),"%"]})]}),p.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Tl(p.pace,!0),"/month"]})]})]})})]})}const Lps={light:"",dark:".dark"},MJe=C.createContext(null);function TJe(){const t=C.useContext(MJe);if(!t)throw new Error("useChart must be used within a ");return t}const AJe=C.forwardRef(({id:t,className:s,children:r,config:n,...a},o)=>{const l=C.useId(),i=`chart-${t||l.replace(/:/g,"")}`;return e.jsx(MJe.Provider,{value:{config:n},children:e.jsxs("div",{"data-chart":i,ref:o,className:Pt("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",s),...a,children:[e.jsx(Dps,{id:i,config:n}),e.jsx(W5,{children:r})]})})});AJe.displayName="Chart";const Dps=({id:t,config:s})=>{const r=Object.entries(s).filter(([n,a])=>a.theme||a.color);return r.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(Lps).map(([n,a])=>` ${a} [data-chart=${t}] { ${r.map(([o,l])=>{var d;const i=((d=l.theme)==null?void 0:d[n])||l.color;return i?` --color-${o}: ${i};`:null}).join(` `)} } `).join(` `)}}):null},EJe=C.forwardRef(({active:t,payload:s,className:r,indicator:n="dot",hideLabel:a=!1,hideIndicator:o=!1,label:l,labelFormatter:i,labelClassName:d,formatter:u,color:p,nameKey:f,labelKey:y},_)=>{const{config:b}=TJe(),w=C.useMemo(()=>{var L;if(a||!(s!=null&&s.length))return null;const[k]=s,S=`${y||k.dataKey||k.name||"value"}`,T=J0e(b,k,S),I=!y&&typeof l=="string"?((L=b[l])==null?void 0:L.label)||l:T==null?void 0:T.label;return i?e.jsx("div",{className:Pt("font-medium",d),children:i(I,s)}):I?e.jsx("div",{className:Pt("font-medium",d),children:I}):null},[l,i,s,a,d,b,y]);if(!t||!(s!=null&&s.length))return null;const j=s.length===1&&n!=="dot";return e.jsxs("div",{ref:_,className:Pt("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",r),children:[j?null:w,e.jsx("div",{className:"grid gap-1.5",children:s.map((k,S)=>{const T=`${f||k.name||k.dataKey||"value"}`,I=J0e(b,k,T),L=p||k.payload.fill||k.color;return e.jsx("div",{className:Pt("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",n==="dot"&&"items-center"),children:u&&(k==null?void 0:k.value)!==void 0&&k.name?u(k.value,k.name,k,S,k.payload):e.jsxs(e.Fragment,{children:[I!=null&&I.icon?e.jsx(I.icon,{}):!o&&e.jsx("div",{className:Pt("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":n==="dot","w-1":n==="line","w-0 border-[1.5px] border-dashed bg-transparent":n==="dashed","my-0.5":j&&n==="dashed"}),style:{"--color-bg":L,"--color-border":L}}),e.jsxs("div",{className:Pt("flex flex-1 justify-between leading-none",j?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[j?w:null,e.jsx("span",{className:"text-muted-foreground",children:(I==null?void 0:I.label)||k.name})]}),k.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:k.value.toLocaleString()})]})]})},k.dataKey)})})]})});EJe.displayName="ChartTooltip";const Ops=C.forwardRef(({className:t,hideIcon:s=!1,payload:r,verticalAlign:n="bottom",nameKey:a},o)=>{const{config:l}=TJe();return r!=null&&r.length?e.jsx("div",{ref:o,className:Pt("flex items-center justify-center gap-4",n==="top"?"pb-3":"pt-3",t),children:r.map(i=>{const d=`${a||i.dataKey||"value"}`,u=J0e(l,i,d);return e.jsxs("div",{className:Pt("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[u!=null&&u.icon&&!s?e.jsx(u.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:i.color}}),u==null?void 0:u.label]},i.value)})}):null});Ops.displayName="ChartLegend";function J0e(t,s,r){if(typeof s!="object"||s===null)return;const n="payload"in s&&typeof s.payload=="object"&&s.payload!==null?s.payload:void 0;let a=r;return r in s&&typeof s[r]=="string"?a=s[r]:n&&r in n&&typeof n[r]=="string"&&(a=n[r]),a in t?t[a]:t[r]}const zR=["hsl(var(--primary))","hsl(var(--secondary))","hsl(210, 70%, 50%)","hsl(170, 60%, 45%)","hsl(280, 60%, 55%)","hsl(30, 70%, 50%)","hsl(340, 65%, 55%)","hsl(200, 65%, 50%)"];function H2e({stats:t,year:s}){const r=t.transactionsByMonth.some(a=>a.count>0),n=t.leadSourceBreakdown.length>0;return!r&&!n?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12 text-center text-muted-foreground",children:"Add transactions to see your performance charts"})}):e.jsxs("div",{className:"grid gap-6",children:[r&&e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Transactions by Month"})}),e.jsx(Oe,{className:"overflow-hidden",children:e.jsx(AJe,{config:{count:{label:"Transactions",color:"hsl(var(--primary))"}},className:"h-[250px]",children:e.jsx(W5,{width:"100%",height:"100%",children:e.jsxs(sJe,{data:t.transactionsByMonth,margin:{top:5,right:10,left:0,bottom:5},children:[e.jsx(zQe,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Jk,{dataKey:"month",tick:{fontSize:11},className:"fill-muted-foreground",interval:0}),e.jsx(eS,{allowDecimals:!1,tick:{fontSize:12},className:"fill-muted-foreground",width:30}),e.jsx(vm,{content:e.jsx(EJe,{})}),e.jsx(lv,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0],name:"Transactions"})]})})})})]}),n&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Oe,{children:[e.jsx("div",{className:"h-[250px]",children:e.jsx(W5,{width:"100%",height:"100%",children:e.jsxs(rJe,{children:[e.jsx(jy,{data:t.leadSourceBreakdown,dataKey:"count",nameKey:"name",cx:"50%",cy:"50%",outerRadius:80,label:({name:a,percent:o})=>o>.05?`${a} (${(o*100).toFixed(0)}%)`:"",labelLine:!1,children:t.leadSourceBreakdown.map((a,o)=>e.jsx(oD,{fill:zR[o%zR.length]},`cell-${o}`))}),e.jsx(vm,{formatter:(a,o)=>[`${a} deals`,o]})]})})}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2 justify-center",children:t.leadSourceBreakdown.slice(0,6).map((a,o)=>e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:zR[o%zR.length]}}),e.jsx("span",{className:"text-muted-foreground",children:a.name})]},a.name))})]})]})]})}function Rps(t){if(!t||!t.trim())return null;const s=t.trim(),r=["yyyy-MM-dd","M/d/yyyy","MM/dd/yyyy","M-d-yyyy","MM-dd-yyyy","MM/dd/yy","M/d/yy"];for(const n of r)try{const a=h_e(s,n,new Date);if(qge(a))return ys(a,"yyyy-MM-dd")}catch{}try{const n=new Date(s);if(qge(n))return ys(n,"yyyy-MM-dd")}catch{}return null}const Fps=["property_address","city","state","zip","transaction_type","close_date","sale_price","commission_amount","lead_source","client_type","is_win","notes"];function zps({open:t,onOpenChange:s}){const[r,n]=C.useState([]),[a,o]=C.useState(!1),[l,i]=C.useState(0),{data:d}=EM(),{data:u}=Rf(),p=mle(),f=()=>{const k=Fps.join(","),S=["123 Main St","Dallas","TX","75001","buyer","2024-06-15","450000","13500","Referral","Past Client","yes","Great transaction!"].join(","),T=`${k} ${S}`,I=new Blob([T],{type:"text/csv"}),L=URL.createObjectURL(I),R=document.createElement("a");R.href=L,R.download="transaction-import-template.csv",R.click(),URL.revokeObjectURL(L)},y=k=>{const S=k.split(` `).filter(I=>I.trim());if(S.length<2)return[];const T=S[0].split(",").map(I=>I.trim().toLowerCase().replace(/['"]/g,""));return S.slice(1).map((I,L)=>{var ae,le,he,be;const R=[];let $="",q=!1;for(const _e of I)_e==='"'?q=!q:_e===","&&!q?(R.push($.trim()),$=""):$+=_e;R.push($.trim());const U=_e=>{var Ne;const je=T.indexOf(_e);return je>=0?(Ne=R[je])==null?void 0:Ne.replace(/^["']|["']$/g,"").trim():""},H=(ae=U("transaction_type"))==null?void 0:ae.toLowerCase(),Y=(le=U("sale_price"))==null?void 0:le.replace(/[$,]/g,""),se=(he=U("commission_amount"))==null?void 0:he.replace(/[$,]/g,""),te=(be=U("is_win"))==null?void 0:be.toLowerCase(),Q=U("close_date"),de=Rps(Q);let re;return U("property_address")?["buyer","seller"].includes(H)?de?(!Y||isNaN(Number(Y)))&&(re="Invalid sale price"):re=`Invalid date format: "${Q}" - use MM/DD/YYYY or YYYY-MM-DD`:re='Transaction type must be "buyer" or "seller"':re="Missing property address",{property_address:U("property_address"),city:U("city"),state:U("state"),zip:U("zip"),transaction_type:H==="seller"?"seller":"buyer",close_date:de||"",sale_price:Number(Y)||0,commission_amount:se?Number(se):null,lead_source_name:U("lead_source"),client_type_name:U("client_type"),is_win:["yes","true","1"].includes(te),notes:U("notes"),error:re}})},_=k=>{var I;const S=(I=k.target.files)==null?void 0:I[0];if(!S)return;const T=new FileReader;T.onload=L=>{var q;const R=(q=L.target)==null?void 0:q.result,$=y(R);n($)},T.readAsText(S)},b=async()=>{const k=r.filter(I=>!I.error);if(k.length===0){fe.error("No valid transactions to import");return}o(!0),i(0);let S=0,T=0;for(let I=0;Iq.name.toLowerCase()===L.lead_source_name.toLowerCase()),$=u==null?void 0:u.find(q=>q.name.toLowerCase()===L.client_type_name.toLowerCase());await p.mutateAsync({property_address:L.property_address,city:L.city||null,state:L.state||null,zip:L.zip||null,transaction_type:L.transaction_type,close_date:L.close_date,sale_price:L.sale_price,commission_amount:L.commission_amount,lead_source_id:(R==null?void 0:R.id)||null,client_type_id:($==null?void 0:$.id)||null,contact_id:null,notes:L.notes||null,is_win:L.is_win}),S++}catch(R){T++,console.error("Failed to import transaction:",R)}i(Math.round((I+1)/k.length*100))}o(!1),S>0&&fe.success(`Imported ${S} transaction${S>1?"s":""}`),T>0&&fe.error(`Failed to import ${T} transaction${T>1?"s":""}`),n([]),s(!1)},w=r.filter(k=>!k.error).length,j=r.filter(k=>k.error).length;return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh]",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Import Transactions"}),e.jsx(Kr,{children:"Upload a CSV file with your past transactions"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Download Template"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Get a CSV template with the correct format"})]}),e.jsxs(K,{variant:"outline",onClick:f,children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Template"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"csv-file",children:"Upload CSV File"}),e.jsx(Re,{id:"csv-file",type:"file",accept:".csv",onChange:_})]}),r.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(rt,{variant:"outline",children:[r.length," rows found"]}),w>0&&e.jsxs(rt,{className:"bg-green-500 text-white",children:[e.jsx(ha,{className:"h-3 w-3 mr-1"}),w," valid"]}),j>0&&e.jsxs(rt,{variant:"destructive",children:[e.jsx(ll,{className:"h-3 w-3 mr-1"}),j," errors"]})]}),e.jsx(Ri,{className:"h-[200px] border rounded-lg",children:e.jsxs("div",{className:"p-2 space-y-2",children:[r.slice(0,10).map((k,S)=>e.jsxs("div",{className:`p-2 rounded text-sm ${k.error?"bg-destructive/10":"bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:k.property_address||"(no address)"}),e.jsx(rt,{variant:k.transaction_type==="buyer"?"default":"secondary",children:k.transaction_type})]}),e.jsxs("div",{className:"text-muted-foreground",children:[k.close_date," • $",k.sale_price.toLocaleString()]}),k.error&&e.jsx(xwe,{variant:"destructive",className:"mt-1 py-1",children:e.jsx(ywe,{className:"text-xs",children:k.error})})]},S)),r.length>10&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["...and ",r.length-10," more"]})]})}),a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${l}%`}})}),e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:["Importing... ",l,"%"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:b,disabled:w===0||a,children:[e.jsx(Za,{className:"h-4 w-4 mr-2"}),"Import ",w," Transaction",w!==1?"s":""]})]})]})]})})}const Bps=lS({transactions_goal:tI().min(0).optional(),volume_goal:tI().min(0).optional(),gci_goal:tI().min(0).optional()});function $ps({open:t,onOpenChange:s,year:r,existingGoals:n}){const a=h3t(),{data:o}=ple(),l=(o==null?void 0:o.show_commission)??!0,i=nle({resolver:ale(Bps),defaultValues:{transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0}});C.useEffect(()=>{n?i.reset({transactions_goal:n.transactions_goal??void 0,volume_goal:n.volume_goal?Number(n.volume_goal):void 0,gci_goal:n.gci_goal?Number(n.gci_goal):void 0}):i.reset({transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0})},[n,i,t]);const d=async u=>{await a.mutateAsync({year:r,transactions_goal:u.transactions_goal??null,volume_goal:u.volume_goal??null,gci_goal:l?u.gci_goal??null:null}),s(!1)};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{children:[r," Goals"]}),e.jsx(Kr,{children:"Set your annual targets to track your progress throughout the year."})]}),e.jsx(ile,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(d),className:"space-y-4",children:[e.jsx(wc,{control:i.control,name:"transactions_goal",render:({field:u})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Transactions Goal"}),e.jsx(mc,{children:e.jsx(Re,{type:"number",placeholder:"e.g., 24",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(kre,{children:"Total number of deals you want to close"}),e.jsx(Oh,{})]})}),e.jsx(wc,{control:i.control,name:"volume_goal",render:({field:u})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"Volume Goal ($)"}),e.jsx(mc,{children:e.jsx(Re,{type:"number",placeholder:"e.g., 5000000",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(kre,{children:"Total sales volume you want to achieve"}),e.jsx(Oh,{})]})}),l&&e.jsx(wc,{control:i.control,name:"gci_goal",render:({field:u})=>e.jsxs(uc,{children:[e.jsx(hc,{children:"GCI Goal ($)"}),e.jsx(mc,{children:e.jsx(Re,{type:"number",placeholder:"e.g., 150000",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(kre,{children:"Gross commission income target"}),e.jsx(Oh,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:a.isPending,children:"Save Goals"})]})]})})]})})}function W2e({transactions:t,isLoading:s}){const r=C.useRef(null),n=C.useRef(null),a=C.useRef([]),o=C.useRef(null),{isAdmin:l}=Hs(),[i,d]=C.useState(""),[u,p]=C.useState(!0),[f,y]=C.useState(0),[_,b]=C.useState(!1),w=t.filter(k=>k.latitude!=null&&k.longitude!=null),j=t.filter(k=>k.latitude==null||k.longitude==null);return C.useEffect(()=>{(async()=>{p(!0);try{const{data:S}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();S!=null&&S.value&&d(S.value)}catch(S){console.error("Error fetching mapbox token:",S)}p(!1)})()},[]),C.useEffect(()=>{if(!i||j.length===0||_)return;(async()=>{var T;b(!0);let S=0;for(const I of j){const L=[I.property_address,I.city,I.state,I.zip].filter(Boolean).join(", ");if(L)try{const $=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(L)}.json?access_token=${i}&limit=1`)).json();if((T=$.features)!=null&&T[0]){const[q,U]=$.features[0].center;await G.from("scorecard_transactions").update({latitude:U,longitude:q}).eq("id",I.id),I.latitude=U,I.longitude=q,S++}}catch(R){console.error("Geocode error:",R)}}y(S),b(!1)})()},[i,t]),C.useEffect(()=>{if(!r.current||!i||n.current)return;du.accessToken=i;const k=t.filter(I=>I.latitude!=null&&I.longitude!=null);let S=[-98.5795,39.8283],T=4;if(k.length>0){const I=k.reduce((R,$)=>R+$.longitude,0)/k.length,L=k.reduce((R,$)=>R+$.latitude,0)/k.length;S=[I,L],T=k.length===1?12:10}return n.current=new du.Map({container:r.current,style:"mapbox://styles/mapbox/light-v11",zoom:T,center:S}),n.current.addControl(new du.NavigationControl,"top-right"),()=>{var I;(I=n.current)==null||I.remove(),n.current=null}},[i]),C.useEffect(()=>{var S;if(!n.current||!i)return;a.current.forEach(T=>T.remove()),a.current=[],(S=o.current)==null||S.remove();const k=t.filter(T=>T.latitude!=null&&T.longitude!=null);if(k.forEach(T=>{var U;const I=T.transaction_type==="buyer",L=I?"#3B82F6":"#10B981",R=document.createElement("div");R.className="cursor-pointer",R.innerHTML=`
${I?'':''}
`;const $=new du.Popup({offset:25,closeButton:!0}).setHTML(`
${T.property_address}
${T.city?`
${T.city}${T.state?", "+T.state:""} ${T.zip||""}
`:""}
${I?"Buyer":"Seller"} $${Number(T.sale_price).toLocaleString()}
Closed: ${gl(T.close_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} ${(U=T.lead_source)!=null&&U.name?" · "+T.lead_source.name:""}
${T.contact?`
Client: ${T.contact.first_name} ${T.contact.last_name||""}
`:""}
`),q=new du.Marker(R).setLngLat([T.longitude,T.latitude]).setPopup($).addTo(n.current);a.current.push(q)}),k.length>1){const T=new du.LngLatBounds;k.forEach(I=>T.extend([I.longitude,I.latitude])),n.current.fitBounds(T,{padding:60,maxZoom:13})}else k.length===1&&n.current.flyTo({center:[k[0].longitude,k[0].latitude],zoom:12})},[t,i,_]),u||s?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center h-[50vh]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):i?t.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(Oi,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"No Transactions Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add transactions to see them plotted on the map."})]})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#3B82F6"}}),e.jsx("span",{children:"Buyer"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#10B981"}}),e.jsx("span",{children:"Seller"})]}),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[w.length," of ",t.length," mapped",_&&" · Geocoding..."]})]}),e.jsx("div",{ref:r,className:"w-full h-[55vh] rounded-lg shadow-lg border"})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(ll,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Map Not Configured"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?"Set up your Mapbox token in the Popby Map to enable maps across the platform.":"The map feature has not been configured yet. Please contact your administrator."})]})]})})}const PJe=()=>{const{data:t}=Lf();return wt({queryKey:["team-scorecard-members",t==null?void 0:t.teamId],queryFn:async()=>{const{data:s,error:r}=await G.from("team_members").select("user_id").eq("team_id",t.teamId);if(r)throw r;const n=s.map(l=>l.user_id),{data:a,error:o}=await G.from("profiles").select("id, name, email, avatar_url").in("id",n);if(o)throw o;return a||[]},enabled:!!(t!=null&&t.teamId)&&(t==null?void 0:t.role)==="team_leader"})},qps=t=>{const{data:s}=Lf(),{data:r}=PJe();return wt({queryKey:["team-scorecard-transactions",s==null?void 0:s.teamId,t],queryFn:async()=>{const n=r.map(l=>l.id),{data:a,error:o}=await G.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).in("owner_user_id",n).gte("close_date",`${t}-01-01`).lte("close_date",`${t}-12-31`).order("close_date",{ascending:!1});if(o)throw o;return a},enabled:!!r&&r.length>0})};function Ups(t,s){const r=s.filter(o=>o.owner_user_id===t.id),n=r.reduce((o,l)=>o+Number(l.sale_price),0),a=r.reduce((o,l)=>o+(Number(l.commission_amount)||0),0);return{member:t,totalTransactions:r.length,buyerCount:r.filter(o=>o.transaction_type==="buyer").length,sellerCount:r.filter(o=>o.transaction_type==="seller").length,totalVolume:n,averagePrice:r.length>0?n/r.length:0,totalGCI:a}}function Vps(t,s){return t?t.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2):s[0].toUpperCase()}function Hps({year:t}){var y;const{data:s,isLoading:r}=PJe(),{data:n,isLoading:a}=qps(t),o=Pr(),l=r||a,{aggregate:i,memberStats:d,topPerformer:u,agentNameMap:p,teamChartStats:f}=C.useMemo(()=>{if(!s||!n)return{aggregate:null,memberStats:[],topPerformer:null,agentNameMap:{},teamChartStats:null};const _=s.map(H=>Ups(H,n));_.sort((H,Y)=>Y.totalVolume-H.totalVolume);const b={};s.forEach(H=>{b[H.id]=H.name||H.email});const w=n.length,j=n.reduce((H,Y)=>H+Number(Y.sale_price),0),k=n.reduce((H,Y)=>H+(Number(Y.commission_amount)||0),0),S=n.filter(H=>H.transaction_type==="buyer").length,T=n.filter(H=>H.transaction_type==="seller").length,I={};n.forEach(H=>{var se;const Y=((se=H.lead_source)==null?void 0:se.name)||"Unknown";I[Y]=(I[Y]||0)+1});const L=Object.entries(I).sort((H,Y)=>Y[1]-H[1])[0],R={};n.forEach(H=>{const Y=gl(H.close_date).toLocaleString("default",{month:"short"});R[Y]=(R[Y]||0)+1});const q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(H=>({month:H,count:R[H]||0})),U=Object.entries(I).map(([H,Y])=>({name:H,count:Y})).sort((H,Y)=>Y.count-H.count);return{aggregate:{totalTxns:w,buyerCount:S,sellerCount:T,totalVolume:j,avgPrice:w>0?j/w:0,totalGCI:k,topSource:L?{name:L[0],count:L[1]}:null,memberCount:s.length},memberStats:_,topPerformer:_[0]||null,agentNameMap:b,teamChartStats:{transactionsByMonth:q,leadSourceBreakdown:U}}},[s,n]);return l?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[1,2,3,4].map(_=>e.jsx(xs,{className:"h-24"},_))}),e.jsx(xs,{className:"h-64"})]}):!i||d.length===0?e.jsx(Ee,{className:"py-12",children:e.jsxs(Oe,{className:"text-center space-y-2",children:[e.jsx(hr,{className:"h-10 w-10 mx-auto text-muted-foreground"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No Team Data"}),e.jsxs("p",{className:"text-muted-foreground",children:["No scorecard transactions found for your team members in ",t,"."]})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Members"})]}),e.jsx("p",{className:"text-2xl font-bold",children:i.memberCount})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(On,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Team Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:i.totalTxns}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.buyerCount,"B / ",i.sellerCount,"S"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(od,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Team Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Tl(i.totalVolume,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ac,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg Price"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Tl(i.avgPrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(od,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Team GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Tl(i.totalGCI,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(rc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((y=i.topSource)==null?void 0:y.name)||"-"}),i.topSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.topSource.count," deals"]})]})})]}),u&&u.totalTransactions>0&&e.jsx(Ee,{className:"border-primary/30 bg-primary/5",children:e.jsxs(Oe,{className:"pt-4 flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center justify-center h-10 w-10 rounded-full bg-primary/10",children:e.jsx(ao,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground",children:["Top Performer — ",t]}),e.jsx("p",{className:"text-lg font-bold",children:u.member.name||u.member.email})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.totalTransactions," deals"]}),e.jsx("p",{className:"font-semibold",children:Tl(u.totalVolume,!0)})]})]})}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Member Performance"})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Agent"}),e.jsx(bt,{className:"text-center",children:"Transactions"}),e.jsx(bt,{className:"text-center",children:"B / S"}),e.jsx(bt,{className:"text-right",children:"Volume"}),e.jsx(bt,{className:"text-right",children:"Avg Price"}),e.jsx(bt,{className:"text-right",children:"GCI"}),e.jsx(bt,{className:"text-right"})]})}),e.jsx(Pn,{children:d.map((_,b)=>e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[b===0&&_.totalTransactions>0&&e.jsx(ao,{className:"absolute -top-2 -right-2 h-3.5 w-3.5 text-amber-500"}),e.jsxs(xn,{className:"h-8 w-8",children:[e.jsx(Aa,{src:_.member.avatar_url||void 0}),e.jsx(yn,{className:"text-xs",children:Vps(_.member.name,_.member.email)})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:_.member.name||_.member.email}),_.member.name&&e.jsx("p",{className:"text-xs text-muted-foreground",children:_.member.email})]})]})}),e.jsx(lt,{className:"text-center font-semibold",children:_.totalTransactions}),e.jsxs(lt,{className:"text-center text-sm",children:[_.buyerCount," / ",_.sellerCount]}),e.jsx(lt,{className:"text-right font-medium",children:Tl(_.totalVolume,!0)}),e.jsx(lt,{className:"text-right text-sm",children:Tl(_.averagePrice,!0)}),e.jsx(lt,{className:"text-right font-medium",children:Tl(_.totalGCI,!0)}),e.jsx(lt,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>o(`/mission-control/scorecard/${_.member.id}`),children:e.jsx(xa,{className:"h-4 w-4"})})})]},_.member.id))})]})})})]}),e.jsxs(ka,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(_a,{children:[e.jsxs(js,{value:"transactions",children:[e.jsx(Hh,{className:"h-4 w-4 mr-1"}),"All Transactions"]}),e.jsxs(js,{value:"charts",children:[e.jsx(ol,{className:"h-4 w-4 mr-1"}),"Charts"]}),e.jsxs(js,{value:"map",children:[e.jsx(Oi,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(zs,{value:"transactions",children:e.jsx(V2e,{transactions:n||[],showCommission:!0,isLoading:a,agentNameMap:p,readOnly:!0})}),e.jsx(zs,{value:"charts",children:f&&e.jsx(H2e,{stats:f,year:t})}),e.jsx(zs,{value:"map",children:e.jsx(W2e,{transactions:n||[],isLoading:a})})]})]})}const IJe=new Date().getFullYear(),RLe=Array.from({length:10},(t,s)=>IJe-s);function Wps(){var U;const[t,s]=C.useState(IJe),[r,n]=C.useState(!1),[a,o]=C.useState(!1),[l,i]=C.useState(!1),[d,u]=C.useState(!1),[p,f]=C.useState("my"),{data:y}=Lf(),_=(y==null?void 0:y.role)==="team_leader",{data:b,isLoading:w}=ybe(t),{yearStats:j,lifetimeStats:k,showCommission:S}=FVe(t),{data:T,isLoading:I}=RVe(t),{data:L}=ple(),R=m3t(),$=()=>{if(!b||b.length===0)return;const H=["Property Address","City","State","Zip","Transaction Type","Close Date","Sale Price",...S?["Commission"]:[],"Lead Source","Client Type","Contact Name","Is Win","Notes"],Y=b.map(re=>{var ae,le;return[re.property_address,re.city||"",re.state||"",re.zip||"",re.transaction_type,re.close_date,re.sale_price,...S?[re.commission_amount||""]:[],((ae=re.lead_source)==null?void 0:ae.name)||"",((le=re.client_type)==null?void 0:le.name)||"",re.contact?`${re.contact.first_name} ${re.contact.last_name||""}`.trim():"",re.is_win?"Yes":"No",re.notes||""]}),se=[H,...Y].map(re=>re.map(ae=>`"${String(ae).replace(/"/g,'""')}"`).join(",")).join(` `),te=new Blob([se],{type:"text/csv"}),Q=URL.createObjectURL(te),de=document.createElement("a");de.href=Q,de.download=`transactions-${t}.csv`,de.click(),URL.revokeObjectURL(Q)},q=!b||b.length===0;return e.jsxs(Ts,{title:"Scorecard",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Scorecard"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500/50 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),_&&e.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 w-fit",children:[e.jsx(K,{variant:p==="my"?"default":"ghost",size:"sm",onClick:()=>f("my"),className:"h-8",children:"My Scorecard"}),e.jsxs(K,{variant:p==="team"?"default":"ghost",size:"sm",onClick:()=>f("team"),className:"h-8",children:[e.jsx(hr,{className:"h-4 w-4 mr-1.5"}),"Team"]})]}),p==="team"&&_?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Team Performance"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Aggregate stats and member comparison"})]}),e.jsxs(sr,{value:String(t),onValueChange:H=>s(Number(H)),children:[e.jsx(er,{className:"w-[120px]",children:e.jsx(rr,{})}),e.jsx(tr,{children:RLe.map(H=>e.jsx(At,{value:String(H),children:H},H))})]})]}),e.jsx(Hps,{year:t})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Business Scorecard"}),e.jsx("p",{className:"text-muted-foreground",children:"Track your transactions, goals, and performance"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(sr,{value:String(t),onValueChange:H=>s(Number(H)),children:[e.jsx(er,{className:"w-[120px]",children:e.jsx(rr,{})}),e.jsx(tr,{children:RLe.map(H=>e.jsx(At,{value:String(H),children:H},H))})]}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(!d),children:e.jsx($l,{className:"h-4 w-4"})})]})]}),d&&e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsx(Ot,{className:"text-lg",children:"Settings"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ve,{children:"Show Commission"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Display commission fields and include in stats"})]}),e.jsx(Br,{checked:(L==null?void 0:L.show_commission)??!0,onCheckedChange:H=>R.mutate({show_commission:H})})]})})]}),q&&!w?e.jsx(Ee,{className:"py-12",children:e.jsxs(Oe,{className:"text-center space-y-4",children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(ol,{className:"h-8 w-8 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Start Tracking Your Success"}),e.jsx("p",{className:"text-muted-foreground max-w-md mx-auto mt-1",children:"Add your past transactions to see your performance metrics, track your goals, and celebrate your wins."})]}),e.jsxs("div",{className:"flex flex-wrap justify-center gap-2 pt-2",children:[e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Your First Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(Za,{className:"h-4 w-4 mr-2"}),"Import CSV"]})]}),e.jsxs("div",{className:"pt-4 border-t mt-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Need help formatting your data?"}),e.jsx(K,{variant:"link",className:"h-auto p-0",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Download CSV Template"]})})]})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>i(!0),children:[e.jsx(Gh,{className:"h-4 w-4 mr-2"}),"Set Goals"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(Za,{className:"h-4 w-4 mr-2"}),"Import"]}),e.jsxs(K,{variant:"outline",onClick:$,disabled:q,children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Export"]}),e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"CSV Template"]})})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(On,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:j.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[k.totalTransactions," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[j.buyerCount,"/",j.sellerCount]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"B/S split"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(od,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Tl(j.totalVolume,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Tl(k.totalVolume,!0)," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ac,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg Price"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Tl(j.averagePrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(rc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((U=j.topLeadSource)==null?void 0:U.name)||"-"}),j.topLeadSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.topLeadSource.count," deals"]})]})}),S&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(od,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Tl(j.totalCommission,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Tl(k.totalCommission,!0)," lifetime"]})]})}),S&&j.totalNetToAgent>0&&j.totalNetToAgent!==j.totalCommission&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-teal-600 dark:text-teal-400 mb-1",children:[e.jsx(od,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Net to Agent"})]}),e.jsx("p",{className:"text-2xl font-bold text-teal-600 dark:text-teal-400",children:Tl(j.totalNetToAgent,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Tl(k.totalNetToAgent,!0)," lifetime"]})]})})]}),T&&e.jsx(CJe,{goals:T,stats:j,year:t,showCommission:S}),e.jsxs(ka,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(_a,{children:[e.jsx(js,{value:"transactions",children:"Transactions"}),e.jsx(js,{value:"charts",children:"Charts"}),e.jsxs(js,{value:"map",children:[e.jsx(Oi,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(zs,{value:"transactions",children:e.jsx(V2e,{transactions:b||[],showCommission:S,isLoading:w})}),e.jsx(zs,{value:"charts",children:e.jsx(H2e,{stats:j,year:t})}),e.jsx(zs,{value:"map",children:e.jsx(W2e,{transactions:b||[],isLoading:w})})]})]})]})]}),e.jsx(SJe,{open:r,onOpenChange:n}),e.jsx(zps,{open:a,onOpenChange:o}),e.jsx($ps,{open:l,onOpenChange:i,year:t,existingGoals:T})]})}function LJe({open:t,onOpenChange:s,listingId:r,listingSlug:n,listingTitle:a}){const{user:o}=Hs(),[l,i]=C.useState(null),[d,u]=C.useState(!1),[p,f]=C.useState(!1);C.useEffect(()=>{(async()=>{if(!(!t||!o)){u(!0);try{const{data:j,error:k}=await G.from("listing_shares").select("id, share_token, click_count, lead_count").eq("listing_id",r).eq("sharing_agent_id",o.id).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(k)throw k;if(j&&j.share_token)i(j);else if(j&&!j.share_token){const{data:S,error:T}=await G.from("listing_shares").update({share_type:"referral_link"}).eq("id",j.id).select("id, share_token, click_count, lead_count").single();if(T)throw T;i(S)}else{const{data:S,error:T}=await G.from("listing_shares").insert({listing_id:r,sharing_agent_id:o.id,share_type:"referral_link"}).select("id, share_token, click_count, lead_count").single();if(T)throw T;i(S)}}catch(j){console.error("Error creating share link:",j),fe.error("Failed to generate share link")}finally{u(!1)}}})()},[t,o,r]);const y=l!=null&&l.share_token?`https://listings.relevelup.com/${n||r}?ref=${l.share_token}`:"",_=async()=>{try{await navigator.clipboard.writeText(y),f(!0),fe.success("Link copied to clipboard!"),setTimeout(()=>f(!1),2e3)}catch{fe.error("Failed to copy link")}},b=w=>{const j=encodeURIComponent(y),k=encodeURIComponent(`Check out this listing: ${a}`);switch(w){case"email":window.open(`mailto:?subject=${k}&body=${j}`);break;case"text":window.open(`sms:?body=${k}%20${j}`);break;case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${j}`,"_blank");break}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5 text-amber-500"}),"Share & Earn Leads"]}),e.jsx(Kr,{children:"Share this listing with your network. When someone submits a lead through your link, they'll become your contact!"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg p-3",children:e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-200",children:[e.jsx("strong",{children:"How it works:"})," The listing still shows the original agent's info, but any leads from your unique link go directly to you!"]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Your Referral Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:d?"Generating...":y,readOnly:!0,className:"font-mono text-sm"}),e.jsx(K,{onClick:_,disabled:d||!y,variant:p?"default":"outline",children:p?e.jsx(ha,{className:"h-4 w-4"}):e.jsx(ai,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Share via"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>b("email"),disabled:d,children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Email"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>b("text"),disabled:d,children:[e.jsx(io,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>b("facebook"),disabled:d,children:[e.jsx(Hd,{className:"h-4 w-4 mr-2"}),"Facebook"]})]})]}),l&&(l.click_count>0||l.lead_count>0)&&e.jsxs("div",{className:"pt-4 border-t",children:[e.jsx(ve,{className:"mb-2 block",children:"Your Share Performance"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-muted rounded-lg p-3 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 text-muted-foreground mb-1",children:[e.jsx(xa,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:"Clicks"})]}),e.jsx("p",{className:"text-2xl font-bold",children:l.click_count})]}),e.jsxs("div",{className:"bg-primary/10 rounded-lg p-3 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 text-primary mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:"Leads"})]}),e.jsx("p",{className:"text-2xl font-bold text-primary",children:l.lead_count})]})]})]})]})]})})}const Gps={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Kps={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},Zps={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function BR({listing:t,onClick:s,onEdit:r,onDelete:n,showActions:a}){var w,j;const{user:o}=Hs(),{data:l}=EVe(t.id),i=AVe(),[d,u]=C.useState(!1),p=k=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(k),f=((w=t.photos)==null?void 0:w.find(k=>k.is_primary))||((j=t.photos)==null?void 0:j[0]),y=(o==null?void 0:o.id)===t.agent_id,_=async k=>{k.stopPropagation();try{const S=await i.mutateAsync(t.id);fe.success(S.saved?"Listing saved!":"Listing removed from saved")}catch{fe.error("Failed to save listing")}},b=k=>{if(k.stopPropagation(),o)u(!0);else{const S=`https://listings.relevelup.com/${t.slug||t.id}`;navigator.clipboard.writeText(S),fe.success("Link copied to clipboard!")}};return e.jsxs(Ee,{className:"overflow-hidden hover:shadow-lg transition-shadow cursor-pointer group",onClick:s,children:[e.jsxs("div",{className:"relative aspect-[4/3] bg-muted",children:[f?e.jsx("img",{src:f.photo_url,alt:t.property_address||t.city,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(ey,{className:"h-12 w-12"})}),e.jsx(rt,{className:`absolute top-2 left-2 ${Gps[t.status]} text-white border-0`,children:Kps[t.status]}),t.is_featured&&e.jsx("div",{className:"absolute top-2 right-2 p-1.5 bg-amber-500 rounded-full",children:e.jsx(Gn,{className:"h-4 w-4 text-white fill-white"})}),e.jsxs("div",{className:"absolute bottom-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(K,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:_,children:e.jsx(Si,{className:`h-4 w-4 ${l?"fill-pink-500 text-pink-500":""}`})}),e.jsx(K,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:b,title:y?"Copy link":"Share & earn leads",children:y?e.jsx(ld,{className:"h-4 w-4"}):e.jsx(hn,{className:"h-4 w-4 text-amber-500"})})]})]}),e.jsx(LJe,{open:d,onOpenChange:u,listingId:t.id,listingSlug:t.slug||null,listingTitle:t.property_address||`${t.city}, ${t.state}`}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xl font-bold text-primary",children:p(t.price)}),t.open_to_referrals&&e.jsxs(rt,{variant:"outline",className:"text-xs",children:[e.jsx(hr,{className:"h-3 w-3 mr-1"}),"Referrals"]})]}),e.jsxs("div",{children:[t.property_address&&e.jsx("p",{className:"font-medium truncate",children:t.property_address}),e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Oi,{className:"h-3 w-3"}),t.city,", ",t.state,t.neighborhood&&` • ${t.neighborhood}`]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[t.bedrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(E0,{className:"h-4 w-4"}),t.bedrooms," bd"]}),t.bathrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Zx,{className:"h-4 w-4"}),t.bathrooms," ba"]}),t.square_footage&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ey,{className:"h-4 w-4"}),t.square_footage.toLocaleString()," sqft"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsx(rt,{variant:"secondary",className:"text-xs",children:Zps[t.property_type]}),t.agent&&e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[120px]",children:t.agent.name})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xa,{className:"h-3 w-3"}),t.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ld,{className:"h-3 w-3"}),t.share_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Si,{className:"h-3 w-3"}),t.save_count]})]}),a&&(r||n)&&e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1",onClick:k=>{k.stopPropagation(),r()},children:[e.jsx(Rc,{className:"h-4 w-4 mr-2"}),"Edit"]}),n&&e.jsx(K,{variant:"destructive",size:"sm",onClick:k=>{k.stopPropagation(),n()},children:e.jsx(jr,{className:"h-4 w-4"})})]})]})]})}const Yps=[{value:"active",label:"Active"},{value:"coming_soon",label:"Coming Soon"},{value:"price_improvement",label:"Price Improvement"},{value:"under_contract",label:"Under Contract"},{value:"sold",label:"Sold"}],Xps=[{value:"single_family",label:"Single Family"},{value:"condo",label:"Condo"},{value:"townhouse",label:"Townhouse"},{value:"land",label:"Land"},{value:"multi_family",label:"Multi-Family"},{value:"luxury",label:"Luxury"},{value:"commercial",label:"Commercial"},{value:"other",label:"Other"}];function Qps({filters:t,onFiltersChange:s,onClose:r}){const n=()=>{s({sortBy:"newest"})};return e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between pb-3",children:[e.jsx(Ot,{className:"text-lg",children:"Filters"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:n,children:"Clear All"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(Ur,{className:"h-4 w-4"})})]})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Status"}),e.jsxs(sr,{value:t.status||"all",onValueChange:a=>s({...t,status:a==="all"?void 0:a}),children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"All statuses"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Statuses"}),Yps.map(a=>e.jsx(At,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Property Type"}),e.jsxs(sr,{value:t.propertyType||"all",onValueChange:a=>s({...t,propertyType:a==="all"?void 0:a}),children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"All types"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Types"}),Xps.map(a=>e.jsx(At,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Min Price"}),e.jsx(Re,{type:"number",placeholder:"No minimum",value:t.minPrice||"",onChange:a=>s({...t,minPrice:a.target.value?Number(a.target.value):void 0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Max Price"}),e.jsx(Re,{type:"number",placeholder:"No maximum",value:t.maxPrice||"",onChange:a=>s({...t,maxPrice:a.target.value?Number(a.target.value):void 0})})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Open to Referrals Only"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show only listings accepting buyer referrals"})]}),e.jsx(Br,{checked:t.openToReferrals||!1,onCheckedChange:a=>s({...t,openToReferrals:a||void 0})})]})]})]})}function Jps({leaderboard:t}){const s=n=>{switch(n){case 0:return e.jsx(ao,{className:"h-5 w-5 text-amber-500"});case 1:return e.jsx(R0,{className:"h-5 w-5 text-gray-400"});case 2:return e.jsx(rc,{className:"h-5 w-5 text-amber-700"});default:return e.jsx("span",{className:"text-sm font-medium text-muted-foreground w-5 text-center",children:n+1})}},r=(n,a)=>!n||n.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:"No data yet. Start sharing to climb the leaderboard!"}):e.jsx("div",{className:"space-y-2",children:n.map((o,l)=>e.jsxs("div",{className:`flex items-center gap-4 p-3 rounded-lg ${l===0?"bg-gradient-to-r from-amber-500/10 to-amber-500/5 border border-amber-500/20":"bg-muted/50"}`,children:[e.jsx("div",{className:"flex items-center justify-center w-8",children:s(l)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-medium truncate",children:o.name})}),e.jsxs(rt,{variant:l===0?"default":"secondary",children:[o.count," ",a]})]},o.agentId))});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(ao,{className:"h-5 w-5 text-amber-500"}),"Community Badges"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-emerald-500/10 to-emerald-500/5 border border-emerald-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-emerald-500/20 flex items-center justify-center",children:e.jsx(ld,{className:"h-6 w-6 text-emerald-500"})}),e.jsx("p",{className:"font-medium text-sm",children:"Listing Amplifier"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Share 10+ listings"})]}),e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-sky-500/10 to-sky-500/5 border border-sky-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-sky-500/20 flex items-center justify-center",children:e.jsx(On,{className:"h-6 w-6 text-sky-500"})}),e.jsx("p",{className:"font-medium text-sm",children:"Top Contributor"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add 5+ listings"})]}),e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-purple-500/10 to-purple-500/5 border border-purple-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-purple-500/20 flex items-center justify-center",children:e.jsx(R0,{className:"h-6 w-6 text-purple-500"})}),e.jsx("p",{className:"font-medium text-sm",children:"Referral Connector"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Send 3+ referrals"})]}),e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-amber-500/10 to-amber-500/5 border border-amber-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-amber-500/20 flex items-center justify-center",children:e.jsx(ao,{className:"h-6 w-6 text-amber-500"})}),e.jsx("p",{className:"font-medium text-sm",children:"Community MVP"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Top performer"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Community Leaderboard"})}),e.jsx(Oe,{children:e.jsxs(ka,{defaultValue:"sharers",children:[e.jsxs(_a,{className:"w-full",children:[e.jsxs(js,{value:"sharers",className:"flex-1",children:[e.jsx(ld,{className:"h-4 w-4 mr-2"}),"Top Sharers"]}),e.jsxs(js,{value:"listers",className:"flex-1",children:[e.jsx(On,{className:"h-4 w-4 mr-2"}),"Top Contributors"]})]}),e.jsx(zs,{value:"sharers",className:"mt-4",children:r(t==null?void 0:t.topSharers,"shares")}),e.jsx(zs,{value:"listers",className:"mt-4",children:r(t==null?void 0:t.topListers,"listings")})]})})]})]})}const FLe={coming_soon:"#F59E0B",active:"#10B981",price_improvement:"#8B5CF6",under_contract:"#3B82F6",sold:"#A855F7"},zLe={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function efs(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function tfs({listings:t,isLoading:s}){const r=Pr(),n=C.useRef(null),a=C.useRef(null),o=C.useRef([]),{isAdmin:l}=Hs(),[i,d]=C.useState(""),[u,p]=C.useState(!0),[f,y]=C.useState(!1),_=t.filter(w=>w.latitude!=null&&w.longitude!=null),b=t.filter(w=>(w.latitude==null||w.longitude==null)&&(w.property_address||w.city));return C.useEffect(()=>{(async()=>{p(!0);try{const{data:j}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();j!=null&&j.value&&d(j.value)}catch(j){console.error("Error fetching mapbox token:",j)}p(!1)})()},[]),C.useEffect(()=>{if(!i||b.length===0||f)return;(async()=>{var j;y(!0);for(const k of b){const S=[k.property_address,k.city,k.state].filter(Boolean).join(", ");if(S)try{const I=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(S)}.json?access_token=${i}&limit=1`)).json();if((j=I.features)!=null&&j[0]){const[L,R]=I.features[0].center;await G.from("listings").update({latitude:R,longitude:L}).eq("id",k.id),k.latitude=R,k.longitude=L}}catch(T){console.error("Geocode error:",T)}}y(!1)})()},[i,t]),C.useEffect(()=>{if(!n.current||!i||a.current)return;du.accessToken=i;const w=t.filter(S=>S.latitude!=null&&S.longitude!=null);let j=[-98.5795,39.8283],k=4;if(w.length>0){const S=w.reduce((I,L)=>I+L.longitude,0)/w.length,T=w.reduce((I,L)=>I+L.latitude,0)/w.length;j=[S,T],k=w.length===1?12:10}return a.current=new du.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:k,center:j}),a.current.addControl(new du.NavigationControl,"top-right"),()=>{var S;(S=a.current)==null||S.remove(),a.current=null}},[i]),C.useEffect(()=>{if(!a.current||!i)return;o.current.forEach(j=>j.remove()),o.current=[];const w=t.filter(j=>j.latitude!=null&&j.longitude!=null);if(w.forEach(j=>{var R,$,q;const k=FLe[j.status]||"#10B981",S=((R=j.photos)==null?void 0:R.find(U=>U.is_primary))||(($=j.photos)==null?void 0:$[0]),T=document.createElement("div");T.className="cursor-pointer",T.innerHTML=`
`;const I=new du.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${S!=null&&S.photo_url?``:""}
${efs(j.price)}
${j.property_address||""}
${j.city}, ${j.state}
${zLe[j.status]||j.status} ${j.bedrooms?`${j.bedrooms} bed`:""} ${j.bathrooms?`${j.bathrooms} bath`:""}
${(q=j.agent)!=null&&q.name?`
Listed by ${j.agent.name}
`:""}
Click to view details →
`),L=new du.Marker(T).setLngLat([j.longitude,j.latitude]).setPopup(I).addTo(a.current);o.current.push(L)}),w.length>1){const j=new du.LngLatBounds;w.forEach(k=>j.extend([k.longitude,k.latitude])),a.current.fitBounds(j,{padding:60,maxZoom:13})}else w.length===1&&a.current.flyTo({center:[w[0].longitude,w[0].latitude],zoom:12})},[t,i,f]),C.useEffect(()=>(window.__navigateToListing__=w=>{r(`/mission-control/listings/${w}`)},()=>{delete window.__navigateToListing__}),[r]),u||s?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center h-[60vh]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):i?t.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(Oi,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"No Listings Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add listings to see them on the map."})]})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:[Object.entries(FLe).map(([w,j])=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-white shadow",style:{background:j}}),e.jsx("span",{className:"text-xs",children:zLe[w]})]},w)),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[_.length," of ",t.length," mapped",f&&" · Geocoding..."]})]}),e.jsx("div",{ref:n,className:"w-full h-[60vh] rounded-lg shadow-lg border"})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(ll,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Map Not Configured"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?"Set up your Mapbox token in Settings to enable maps.":"The map feature has not been configured yet. Please contact your administrator."})]})]})})}function sfs(){var U,H,Y,se,te,Q,de,re;const t=Pr(),{brokerageId:s}=Hs(),{data:r,isLoading:n}=kVe(),[a,o]=C.useState("feed"),[l,i]=C.useState(!1),[d,u]=C.useState(""),[p,f]=C.useState({sortBy:"newest"}),{data:y,isLoading:_}=SVe({...p,city:d||p.city}),{data:b,isLoading:w}=Z5t(),{data:j,isLoading:k}=CVe(),{data:S,isLoading:T}=J5t(),{data:I,isLoading:L}=s3t(),{data:R}=t3t(),$=TVe(),q=async ae=>{if(confirm("Are you sure you want to delete this listing? This action cannot be undone."))try{await $.mutateAsync(ae),fe.success("Listing deleted successfully")}catch{fe.error("Failed to delete listing")}};return n?e.jsx(Ts,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})})}):r?e.jsx(Ts,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Listing Exchange"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(On,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(y==null?void 0:y.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active Listings"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-pink-500/10 rounded-lg",children:e.jsx(Si,{className:"h-5 w-5 text-pink-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(b==null?void 0:b.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-emerald-500/10 rounded-lg",children:e.jsx(nk,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(j==null?void 0:j.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"My Listings"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-sky-500/10 rounded-lg",children:e.jsx(hr,{className:"h-5 w-5 text-sky-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(((U=S==null?void 0:S.sent)==null?void 0:U.length)||0)+(((H=S==null?void 0:S.received)==null?void 0:H.length)||0)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Referrals"})]})]})})]}),e.jsxs(ka,{value:a,onValueChange:o,children:[e.jsxs(_a,{className:"w-full justify-start overflow-x-auto",children:[e.jsx(js,{value:"feed",children:"Community Feed"}),s&&e.jsx(js,{value:"brokerage",children:"Brokerage"}),e.jsx(js,{value:"my-listings",children:"My Listings"}),e.jsx(js,{value:"saved",children:"Saved"}),e.jsx(js,{value:"referrals",children:"Referrals"}),e.jsx(js,{value:"map",children:"Map"}),e.jsx(js,{value:"leaderboard",children:"Leaderboard"})]}),e.jsxs(zs,{value:"feed",className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by city or neighborhood...",value:d,onChange:ae=>u(ae.target.value),className:"pl-9"})]}),e.jsxs(sr,{value:p.sortBy,onValueChange:ae=>f({...p,sortBy:ae}),children:[e.jsx(er,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"Sort by"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"newest",children:"Newest First"}),e.jsx(At,{value:"updated",children:"Recently Updated"}),e.jsx(At,{value:"price_asc",children:"Price: Low to High"}),e.jsx(At,{value:"price_desc",children:"Price: High to Low"})]})]}),e.jsxs(K,{variant:"outline",onClick:()=>i(!l),children:[e.jsx(Yx,{className:"h-4 w-4 mr-2"}),"Filters"]})]}),l&&e.jsx(Qps,{filters:p,onFiltersChange:f,onClose:()=>i(!1)}),_?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(6)].map((ae,le)=>e.jsxs(Ee,{children:[e.jsx(xs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(xs,{className:"h-5 w-3/4"}),e.jsx(xs,{className:"h-4 w-1/2"}),e.jsx(xs,{className:"h-4 w-1/4"})]})]},le))}):(y==null?void 0:y.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(On,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No listings found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Be the first to share a listing with the community!"}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:y==null?void 0:y.map(ae=>e.jsx(BR,{listing:ae,onClick:()=>t(`/mission-control/listings/${ae.id}`)},ae.id))})]}),e.jsx(zs,{value:"my-listings",className:"space-y-4",children:k?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((ae,le)=>e.jsxs(Ee,{children:[e.jsx(xs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(xs,{className:"h-5 w-3/4"}),e.jsx(xs,{className:"h-4 w-1/2"})]})]},le))}):(j==null?void 0:j.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(nk,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No listings yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Share your listings with the LevelUp community!"}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Your First Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:j==null?void 0:j.map(ae=>e.jsx(BR,{listing:ae,showActions:!0,onClick:()=>t(`/mission-control/listings/${ae.id}`),onEdit:()=>t(`/mission-control/listings/${ae.id}/edit`),onDelete:()=>q(ae.id)},ae.id))})}),e.jsx(zs,{value:"saved",className:"space-y-4",children:w?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((ae,le)=>e.jsxs(Ee,{children:[e.jsx(xs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(xs,{className:"h-5 w-3/4"}),e.jsx(xs,{className:"h-4 w-1/2"})]})]},le))}):(b==null?void 0:b.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Si,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No saved listings"}),e.jsx("p",{className:"text-muted-foreground",children:"Save listings to quickly access them later"})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:b==null?void 0:b.map(ae=>e.jsx(BR,{listing:ae.listing,onClick:()=>t(`/mission-control/listings/${ae.listing.id}`)},ae.id))})}),e.jsx(zs,{value:"referrals",className:"space-y-6",children:e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(ld,{className:"h-4 w-4"}),"Referrals Sent (",((Y=S==null?void 0:S.sent)==null?void 0:Y.length)||0,")"]}),((se=S==null?void 0:S.sent)==null?void 0:se.length)===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No referrals sent yet"})}):e.jsx("div",{className:"space-y-3",children:(te=S==null?void 0:S.sent)==null?void 0:te.map(ae=>{var le,he;return e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:ae.buyer_name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((le=ae.listing)==null?void 0:le.property_address)||((he=ae.listing)==null?void 0:he.city)})]}),e.jsx(rt,{variant:ae.status==="closed"?"default":"secondary",children:ae.status.replace("_"," ")})]})})},ae.id)})})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Referrals Received (",((Q=S==null?void 0:S.received)==null?void 0:Q.length)||0,")"]}),((de=S==null?void 0:S.received)==null?void 0:de.length)===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No referrals received yet"})}):e.jsx("div",{className:"space-y-3",children:(re=S==null?void 0:S.received)==null?void 0:re.map(ae=>{var le;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:ae.buyer_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["From: ",(le=ae.sender)==null?void 0:le.name]})]}),e.jsx(rt,{variant:ae.status==="closed"?"default":"secondary",children:ae.status.replace("_"," ")})]}),e.jsx(K,{size:"sm",variant:"outline",className:"w-full mt-2",onClick:()=>t(`/mission-control/listings/${ae.listing_id}`),children:"View Listing"})]})},ae.id)})})]})]})}),s&&e.jsx(zs,{value:"brokerage",className:"space-y-4",children:L?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((ae,le)=>e.jsxs(Ee,{children:[e.jsx(xs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(xs,{className:"h-5 w-3/4"}),e.jsx(xs,{className:"h-4 w-1/2"})]})]},le))}):(I==null?void 0:I.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(nk,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No brokerage listings yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"No agents in your brokerage have added listings yet."}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add a Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:I==null?void 0:I.map(ae=>e.jsx(BR,{listing:ae,onClick:()=>t(`/mission-control/listings/${ae.id}`)},ae.id))})}),e.jsx(zs,{value:"map",children:e.jsx(tfs,{listings:y||[],isLoading:_})}),e.jsx(zs,{value:"leaderboard",children:e.jsx(Jps,{leaderboard:R})})]})]})}):e.jsx(Ts,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(On,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Coming Soon"}),e.jsx("p",{className:"text-muted-foreground",children:"Listing Exchange is currently in development. Check back soon!"})]})})})}function uf(t){const s=t.expected_commission;if(!s)return null;if((t.commission_calc_method||"standard")==="referral_first"){let a=s;t.referral_fee_pct&&(a-=s*(t.referral_fee_pct/100));let o=a;return t.brokerage_split_pct&&(o-=a*(t.brokerage_split_pct/100)),t.team_split_pct&&(o-=s*(t.team_split_pct/100)),t.franchise_fee_pct&&(o-=s*(t.franchise_fee_pct/100)),t.transaction_fee&&(o-=t.transaction_fee),Math.max(0,o)}let n=s;return t.brokerage_split_pct&&(n-=s*(t.brokerage_split_pct/100)),t.team_split_pct&&(n-=s*(t.team_split_pct/100)),t.franchise_fee_pct&&(n-=s*(t.franchise_fee_pct/100)),t.referral_fee_pct&&(n-=s*(t.referral_fee_pct/100)),t.transaction_fee&&(n-=t.transaction_fee),Math.max(0,n)}function zce(){const t=Ya();return wt({queryKey:["deal-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function DJe(){const t=Ya(),s=rs();return Dt({mutationFn:async()=>{if(!t)throw new Error("Not authenticated");const{error:r}=await G.rpc("initialize_deal_pipeline_stages",{p_user_id:t});if(r)throw r},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-pipeline-stages"]})}})}function Bce(){const t=Ya();return wt({queryKey:["deal-pipeline-deals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("deal_pipeline").select(` *, contact:innercircle_contacts(id, first_name, last_name, email, phone), listing:listings(id, property_address, city, state, price, status, created_at) `).eq("owner_user_id",t).order("updated_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function OJe(){const t=Ya(),s=rs();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("deal_pipeline").insert({deal_name:r.deal_name,deal_type:r.deal_type,stage_id:r.stage_id||null,contact_id:r.contact_id||null,listing_id:r.listing_id||null,property_address:r.property_address||null,city:r.city||null,state:r.state||null,zip_code:r.zip_code||null,expected_price:r.expected_price||null,expected_commission:r.expected_commission||null,commission_percentage:r.commission_percentage||3,target_close_date:r.target_close_date||null,contract_date:r.contract_date||null,listing_date:r.listing_date||null,priority:r.priority||"medium",probability:r.probability||50,notes:r.notes||null,owner_user_id:t}).select().single();if(a)throw a;return await G.from("deal_activities").insert([{deal_id:n.id,activity_type:"system",title:"Deal created",description:`Deal "${r.deal_name}" was created`}]),n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-pipeline-deals"]}),s.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function RJe(){const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("deal_pipeline").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function rfs(){const t=rs();return Dt({mutationFn:async({dealId:s,stageId:r,stageName:n})=>{const{data:a,error:o}=await G.from("deal_pipeline").update({stage_id:r}).eq("id",s).select().single();if(o)throw o;return await G.from("deal_activities").insert({deal_id:s,activity_type:"stage_change",title:`Moved to ${n}`,metadata:{new_stage_id:r,new_stage_name:n}}),a},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-activities"]})}})}function nfs(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("deal_pipeline").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function afs(t){return wt({queryKey:["deal-activities",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_activities").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function ifs(){const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("deal_activities").insert([{deal_id:s.deal_id,activity_type:s.activity_type,title:s.title,description:s.description||null}]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-activities",r.deal_id]})}})}function ofs(t){return wt({queryKey:["deal-checklist",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_checklist_items").select("*").eq("deal_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function lfs(){const t=rs();return Dt({mutationFn:async({id:s,is_completed:r,deal_id:n})=>{const{data:a,error:o}=await G.from("deal_checklist_items").update({is_completed:r,completed_at:r?new Date().toISOString():null}).eq("id",s).select().single();if(o)throw o;return a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-checklist",r.deal_id]})}})}function cfs(){const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("deal_checklist_items").insert([{deal_id:s.deal_id,title:s.title,description:s.description||null,due_date:s.due_date||null,sort_order:s.sort_order||0}]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-checklist",r.deal_id]})}})}function dfs(){const t=Ya();return wt({queryKey:["deal-pipeline-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("deal_pipeline").select("*, deal_pipeline_stages(name, is_won_stage, is_lost_stage)").eq("owner_user_id",t);if(r)throw r;const n=(s==null?void 0:s.filter(i=>{var d,u,p;return!((d=i.deal_pipeline_stages)!=null&&d.is_won_stage)&&!((u=i.deal_pipeline_stages)!=null&&u.is_lost_stage)&&((p=i.deal_pipeline_stages)==null?void 0:p.name)!=="Cancelled"}))||[],a=(s==null?void 0:s.filter(i=>{var d;return(d=i.deal_pipeline_stages)==null?void 0:d.is_won_stage}))||[],o=new Date().getFullYear(),l=a.filter(i=>{const d=i.actual_close_date;return d?new Date(d).getFullYear()===o:!0});return{totalDeals:(s==null?void 0:s.length)||0,activeDeals:n.length,wonDeals:a.length,pipelineValue:n.reduce((i,d)=>i+(d.expected_price||0),0),expectedCommission:n.reduce((i,d)=>i+(d.expected_commission||0),0),expectedNetToAgent:n.reduce((i,d)=>i+(uf(d)||0),0),wonValue:a.reduce((i,d)=>i+(d.expected_price||0),0),weightedGCI:n.reduce((i,d)=>{const u=(d.probability??50)/100;return i+(d.expected_commission||0)*u},0),weightedNet:n.reduce((i,d)=>{const u=(d.probability??50)/100;return i+(uf(d)||0)*u},0),ytdWonDeals:l.length,ytdWonGCI:l.reduce((i,d)=>i+(d.expected_commission||0),0),ytdWonNet:l.reduce((i,d)=>i+(uf(d)||0),0),projectedAnnualNet:l.reduce((i,d)=>i+(uf(d)||0),0)+n.reduce((i,d)=>{const u=(d.probability??50)/100;return i+(uf(d)||0)*u},0)}},enabled:!!t})}function ufs(t){const s=Ya();return wt({queryKey:["deal-by-listing",t,s],queryFn:async()=>{if(!s||!t)return null;const{data:r,error:n}=await G.from("deal_pipeline").select(` *, deal_pipeline_stages(id, name, color) `).eq("owner_user_id",s).eq("listing_id",t).maybeSingle();if(n)throw n;return r},enabled:!!s&&!!t})}function hfs(){const t=rs();return Dt({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await G.from("deal_pipeline").update({listing_id:r}).eq("id",s).select().single();if(a)throw a;return await G.from("deal_activities").insert({deal_id:s,activity_type:"system",title:"Linked to Listing Exchange",description:"This deal is now synced with Listing Exchange",metadata:{listing_id:r}}),n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-by-listing",r.listingId]})}})}function mfs(){const t=rs();return Dt({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await G.from("deal_pipeline").update({listing_id:null}).eq("id",s).select().single();if(a)throw a;return{data:n,listingId:r}},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-by-listing",s.listingId]})}})}function pfs({listing:t}){const s=Pr(),[r,n]=C.useState(""),[a,o]=C.useState(!1),{data:l,isLoading:i}=ufs(t.id),{data:d,isLoading:u}=zce(),{data:p,isLoading:f}=Bce(),y=DJe(),_=hfs(),b=mfs(),w=OJe(),j=(p==null?void 0:p.filter(L=>!L.listing_id))||[],k=L=>{if(!(d!=null&&d.length))return null;switch(L){case"coming_soon":case"active":case"price_improvement":return d.find(R=>R.name==="Active");case"under_contract":return d.find(R=>R.name==="Under Contract");case"sold":return d.find(R=>R.is_won_stage);default:return d.find(R=>R.name==="Active")}},S=async()=>{o(!0);try{d!=null&&d.length||await y.mutateAsync();const L=k(t.status);await w.mutateAsync({deal_name:t.property_address?`${t.property_address}, ${t.city}`:`${t.city}, ${t.state}`,deal_type:"seller",stage_id:(L==null?void 0:L.id)||null,listing_id:t.id,property_address:t.property_address,city:t.city,state:t.state,expected_price:t.price,expected_commission:t.price*.03,commission_percentage:3,priority:"medium",probability:50}),fe.success("Deal created and linked to listing!")}catch(L){console.error("Failed to create deal:",L),fe.error("Failed to create deal")}finally{o(!1)}},T=async()=>{if(!r){fe.error("Please select a deal");return}try{await _.mutateAsync({dealId:r,listingId:t.id}),fe.success("Listing linked to deal!"),n("")}catch{fe.error("Failed to link listing")}},I=async()=>{if(l)try{await b.mutateAsync({dealId:l.id,listingId:t.id}),fe.success("Listing unlinked from deal")}catch{fe.error("Failed to unlink listing")}};return i||u?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2 text-base",children:[e.jsx(Xx,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Ms,{className:"h-5 w-5 animate-spin text-muted-foreground"})})})]}):l?e.jsxs(Ee,{className:"border-primary/20 bg-primary/5",children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"flex items-center gap-2 text-base",children:[e.jsx(Wo,{className:"h-4 w-4 text-primary"}),"Linked to Pipeline"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:l.deal_name}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:l.deal_pipeline_stages&&e.jsx(rt,{variant:"secondary",className:"text-xs",style:{backgroundColor:`${l.deal_pipeline_stages.color}20`,color:l.deal_pipeline_stages.color},children:l.deal_pipeline_stages.name})})]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Status changes sync automatically between the listing and pipeline."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>s("/mission-control/pipeline"),children:["View Pipeline",e.jsx($i,{className:"h-3 w-3 ml-1"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:I,disabled:b.isPending,children:b.isPending?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):e.jsx(gk,{className:"h-4 w-4"})})]})]})]}):e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"flex items-center gap-2 text-base",children:[e.jsx(Xx,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Link this listing to your pipeline to track the deal and sync status changes."}),e.jsxs(K,{onClick:S,disabled:a||w.isPending,className:"w-full",size:"sm",children:[a||w.isPending?e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create New Deal"]}),j.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"or"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(sr,{value:r,onValueChange:n,children:[e.jsx(er,{className:"flex-1 text-sm",children:e.jsx(rr,{placeholder:"Link to existing deal..."})}),e.jsx(tr,{children:j.map(L=>e.jsx(At,{value:L.id,children:L.deal_name},L.id))})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:T,disabled:!r||_.isPending,children:_.isPending?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):e.jsx(Wo,{className:"h-4 w-4"})})]})]})]})]})}const ffs={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},gfs={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},BLe={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function xfs(){var te,Q,de,re,ae,le,he,be,_e;const{listingId:t}=ko(),s=Pr(),{user:r}=Hs(),{data:n,isLoading:a}=MVe(t||""),{data:o}=EVe(t||""),{data:l}=X5t(t||""),i=AVe(),d=Y5t(),u=Q5t(),p=TVe(),f=e3t(),[y,_]=C.useState(!1),[b,w]=C.useState(!1),[j,k]=C.useState(!1),[S,T]=C.useState(null),[I,L]=C.useState({buyerName:"",buyerType:"",notes:""}),R=(r==null?void 0:r.id)===(n==null?void 0:n.agent_id),$=je=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(je),q=async je=>{const Ne=`https://listings.relevelup.com/${(n==null?void 0:n.slug)||(n==null?void 0:n.id)}`,Ge=`Check out this listing: ${(n==null?void 0:n.property_address)||(n==null?void 0:n.city)}`;u.mutate({listingId:n.id,shareType:je});try{switch(je){case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(Ne)}`,"_blank");break;case"copy":await navigator.clipboard.writeText(Ne),fe.success("Link copied to clipboard!");break;case"text":window.open(`sms:?body=${encodeURIComponent(`${Ge} ${Ne}`)}`);break;case"email":window.open(`mailto:?subject=${encodeURIComponent(Ge)}&body=${encodeURIComponent(`Check out this listing: ${Ne}`)}`);break}}catch(we){console.error("Share error:",we),fe.error("Failed to share")}},U=async()=>{try{await p.mutateAsync(n.id),fe.success("Listing deleted"),s("/mission-control/listings")}catch{fe.error("Failed to delete listing")}},H=async()=>{if(!I.buyerName.trim()){fe.error("Please enter buyer name");return}try{await f.mutateAsync({listingId:n.id,listingAgentId:n.agent_id,buyerName:I.buyerName,buyerType:I.buyerType||void 0,notes:I.notes||void 0}),fe.success("Referral sent successfully!"),w(!1),L({buyerName:"",buyerType:"",notes:""})}catch{fe.error("Failed to send referral")}},Y=je=>{var Ae,Ue;const Ne=(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`,Ge=$((n==null?void 0:n.price)||0),we=n!=null&&n.bedrooms?`${n.bedrooms}BD`:"",Me=n!=null&&n.bathrooms?`${n.bathrooms}BA`:"",Te=n!=null&&n.square_footage?`${n.square_footage.toLocaleString()}SF`:"",Fe=[we,Me,Te].filter(Boolean).join(" | ");switch(je){case"just_listed":return`🏡 JUST LISTED! ${Ne} ${Ge} ${Fe} ${(n==null?void 0:n.description)||"Schedule your showing today!"} #JustListed #RealEstate #HomeForSale #${(Ae=n==null?void 0:n.city)==null?void 0:Ae.replace(/\s/g,"")}`;case"price_improvement":return`📣 PRICE IMPROVEMENT! ${Ne} Now ${Ge}! ${Fe} Don't miss this opportunity! #PriceReduced #RealEstate #HomeForSale`;case"teaser":return`Looking for a ${BLe[(n==null?void 0:n.property_type)||"single_family"].toLowerCase()} in ${n==null?void 0:n.city}? 👀 I've got just the one for you! ${Fe} DM me for details! 📩 #ComingSoon #RealEstate #${(Ue=n==null?void 0:n.city)==null?void 0:Ue.replace(/\s/g,"")}`;default:return""}};if(a)return e.jsx(Ts,{title:"Listing",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{className:"h-10 w-32"}),e.jsx(xs,{className:"h-[400px] w-full"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsx(xs,{className:"h-48"}),e.jsx(xs,{className:"h-48"}),e.jsx(xs,{className:"h-48"})]})]})});if(!n)return e.jsx(Ts,{title:"Listing Not Found",description:"",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing could not be found."}),e.jsx(K,{onClick:()=>s("/mission-control/listings"),children:"Back to Listings"})]})})});const se=((te=n.photos)==null?void 0:te.find(je=>je.is_primary))||((Q=n.photos)==null?void 0:Q[0]);return e.jsxs(Ts,{title:"",description:"",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/mission-control/listings"),children:[e.jsx(ti,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>se&&T(se.photo_url),children:se?e.jsx("img",{src:se.photo_url,alt:"Primary",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No photos"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:(de=n.photos)==null?void 0:de.slice(1,5).map((je,Ne)=>e.jsx("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>T(je.photo_url),children:e.jsx("img",{src:je.photo_url,alt:`Photo ${Ne+2}`,className:"w-full h-full object-cover"})},je.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(rt,{className:`${ffs[n.status]} text-white border-0`,children:gfs[n.status]}),n.is_featured&&e.jsxs(rt,{variant:"outline",className:"border-amber-500 text-amber-500",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1 fill-amber-500"}),"Featured"]}),n.open_to_referrals&&e.jsxs(rt,{variant:"outline",children:[e.jsx(hr,{className:"h-3 w-3 mr-1"}),"Open to Referrals"]})]}),e.jsx("h1",{className:"text-3xl font-bold text-primary mb-2",children:$(n.price)}),n.property_address&&e.jsx("p",{className:"text-xl font-medium",children:n.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(Oi,{className:"h-4 w-4"}),n.city,", ",n.state,n.neighborhood&&` • ${n.neighborhood}`]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>i.mutate(n.id),children:e.jsx(Si,{className:`h-4 w-4 ${o?"fill-pink-500 text-pink-500":""}`})}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>d.mutate(n.id),children:l?e.jsx(r_,{className:"h-4 w-4"}):e.jsx(gf,{className:"h-4 w-4"})}),!R&&e.jsxs(K,{variant:"outline",className:"border-amber-500 text-amber-600 hover:bg-amber-50",onClick:()=>k(!0),children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Share & Earn Leads"]}),e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(ld,{className:"h-4 w-4 mr-2"}),"Share"]})}),e.jsxs(Md,{children:[e.jsxs(Na,{onClick:()=>q("copy"),children:[e.jsx(ai,{className:"h-4 w-4 mr-2"}),"Copy Link"]}),e.jsxs(Na,{onClick:()=>q("facebook"),children:[e.jsx(Hd,{className:"h-4 w-4 mr-2"}),"Facebook"]}),e.jsxs(Na,{onClick:()=>q("text"),children:[e.jsx(io,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(Na,{onClick:()=>q("email"),children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Email"]})]})]}),R&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/listings/${n.id}/edit`),children:[e.jsx(Rc,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:()=>_(!0),children:e.jsx(jr,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 py-4 border-y",children:[n.bedrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(E0,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.bedrooms}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Beds"})]}),n.bathrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(Zx,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.bathrooms}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Baths"})]}),n.square_footage&&e.jsxs("div",{className:"text-center",children:[e.jsx(ey,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.square_footage.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sq Ft"})]}),n.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(on,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.year_built}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"pt-4 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(rt,{variant:"secondary",children:[e.jsx(Ta,{className:"h-3 w-3 mr-1"}),BLe[n.property_type]]}),n.lot_size&&e.jsxs(rt,{variant:"secondary",children:["Lot: ",n.lot_size]}),n.has_hoa&&e.jsx(rt,{variant:"secondary",children:"HOA"})]}),n.description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium mb-2",children:"Description"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.description})]}),n.agent_notes&&n.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.agent_notes})]}),n.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:n.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]}),e.jsxs("div",{className:"flex items-center gap-4 pt-4 mt-4 border-t text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xa,{className:"h-4 w-4"}),n.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ld,{className:"h-4 w-4"}),n.share_count," shares"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Si,{className:"h-4 w-4"}),n.save_count," saves"]})]})]})}),n.allow_sharing&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Share Content"})}),e.jsx(Oe,{className:"space-y-4",children:["just_listed","price_improvement","teaser"].map(je=>e.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("p",{className:"font-medium text-sm capitalize",children:[je.replace("_"," ")," Caption"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(Y(je)),fe.success("Caption copied!")},children:e.jsx(ai,{className:"h-3 w-3"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:Y(je)})]},je))})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Listing Agent"})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"text-lg font-semibold text-primary",children:((ae=(re=n.agent)==null?void 0:re.name)==null?void 0:ae.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((le=n.agent)==null?void 0:le.name)||"Unknown"}),((be=(he=n.agent)==null?void 0:he.brokerage)==null?void 0:be.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:n.agent.brokerage.name})]})]}),!R&&e.jsx("div",{className:"space-y-2",children:((_e=n.agent)==null?void 0:_e.email)&&e.jsx(K,{variant:"outline",className:"w-full",asChild:!0,children:e.jsxs("a",{href:`mailto:${n.agent.email}`,children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Email Agent"]})})})]})]}),R&&e.jsx(pfs,{listing:n}),!R&&n.open_to_referrals&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Send a Buyer"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Have a buyer interested in this property? Send a referral to the listing agent."}),e.jsx(K,{className:"w-full",onClick:()=>w(!0),children:"Send Referral"})]})]})]})]})]}),e.jsx(_s,{open:!!S,onOpenChange:()=>T(null),children:e.jsx(vs,{className:"max-w-4xl",children:e.jsx("img",{src:S||"",alt:"Full size",className:"w-full h-auto"})})}),e.jsx(_s,{open:y,onOpenChange:_,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Delete Listing"}),e.jsx(Kr,{children:"Are you sure you want to delete this listing? This action cannot be undone."})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:U,disabled:p.isPending,children:p.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(_s,{open:b,onOpenChange:w,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Send Buyer Referral"}),e.jsx(Kr,{children:"Submit buyer information to the listing agent"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Buyer Name *"}),e.jsx(Re,{value:I.buyerName,onChange:je=>L({...I,buyerName:je.target.value}),placeholder:"Enter buyer's name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Buyer Type"}),e.jsxs(sr,{value:I.buyerType,onValueChange:je=>L({...I,buyerType:je}),children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select type"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"first_time",children:"First-Time Buyer"}),e.jsx(At,{value:"investor",children:"Investor"}),e.jsx(At,{value:"relocating",children:"Relocating"}),e.jsx(At,{value:"upgrade",children:"Upgrading"}),e.jsx(At,{value:"downsize",children:"Downsizing"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Notes"}),e.jsx(Ar,{value:I.notes,onChange:je=>L({...I,notes:je.target.value}),placeholder:"Any additional information..."})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(K,{onClick:H,disabled:f.isPending,children:f.isPending?"Sending...":"Send Referral"})]})]})}),e.jsx(LJe,{open:j,onOpenChange:k,listingId:(n==null?void 0:n.id)||"",listingSlug:(n==null?void 0:n.slug)||null,listingTitle:(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`})]})}function yfs({photo:t,onRemove:s,onSetPrimary:r}){const{attributes:n,listeners:a,setNodeRef:o,transform:l,transition:i,isDragging:d}=hZe({id:t.id}),u={transform:D3.Transform.toString(l),transition:i};return e.jsxs("div",{ref:o,style:u,className:Pt("relative aspect-square rounded-lg overflow-hidden bg-muted group",d&&"opacity-50 ring-2 ring-primary z-50"),children:[e.jsx("img",{src:t.photo_url,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",...n,...a,className:"absolute top-1 left-1 p-1 bg-black/60 text-white rounded cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Bu,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>s(t.id),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Ur,{className:"h-3 w-3"})}),t.is_primary?e.jsxs("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded flex items-center gap-0.5",children:[e.jsx(Gn,{className:"h-2.5 w-2.5 fill-current"})," Primary"]}):e.jsx("button",{type:"button",onClick:()=>r(t.id),className:"absolute bottom-1 left-1 text-[10px] bg-black/60 text-white px-1.5 py-0.5 rounded opacity-0 group-hover:opacity-100 transition-opacity hover:bg-black/80",children:"Set as Primary"})]})}function vfs({photos:t,uploading:s,onUpload:r,onRemove:n,onReorder:a,onSetPrimary:o}){const l=VKe(yye(zle,{activationConstraint:{distance:5}})),i=[...t].sort((u,p)=>(u.sort_order??0)-(p.sort_order??0)),d=u=>{const{active:p,over:f}=u;if(!f||p.id===f.id)return;const y=i.findIndex(k=>k.id===p.id),_=i.findIndex(k=>k.id===f.id),b=[...i],[w]=b.splice(y,1);b.splice(_,0,w);const j=b.map((k,S)=>({...k,sort_order:S}));a(j)};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Drag photos to reorder. Hover to set primary."}),e.jsx(oZe,{sensors:l,collisionDetection:KKe,onDragEnd:d,children:e.jsx(dZe,{items:i.map(u=>u.id),strategy:qle,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[i.map(u=>e.jsx(yfs,{photo:u,onRemove:n,onSetPrimary:o},u.id)),e.jsxs("label",{className:"aspect-square rounded-lg border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 cursor-pointer flex flex-col items-center justify-center gap-2 text-muted-foreground",children:[s?e.jsx(Ms,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Za,{className:"h-8 w-8"}),e.jsx("span",{className:"text-xs",children:"Upload"})]}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:u=>r(u.target.files),disabled:s})]})]})})})]})}function _fs({selectedVideoId:t,onVideoSelect:s,listingId:r}){const n=Pr(),{user:a}=Hs(),[o,l]=C.useState(!1),[i,d]=C.useState([]),[u,p]=C.useState(!1),[f,y]=C.useState(null),[_,b]=C.useState({});C.useEffect(()=>{t&&a?w():y(null)},[t,a]);const w=async()=>{if(!t)return;const{data:U,error:H}=await G.from("agent_videos").select("id, bunny_video_id, title, thumbnail_url, preview_url, playback_url, duration_seconds, status, created_at").eq("id",t).eq("is_deleted",!1).single();!H&&U&&(y(U),j(U))},j=async U=>{try{const{data:H,error:Y}=await G.functions.invoke("bunny-upload",{body:{action:"asset-urls",videoId:U.bunny_video_id,isAgentVideo:!0}});!Y&&(H!=null&&H.thumbnailUrl)&&b(se=>({...se,[U.id]:{thumbnailUrl:H.thumbnailUrl}}))}catch(H){console.warn("Failed to get signed URL",H)}},k=async()=>{if(a){p(!0);try{const{data:U,error:H}=await G.from("agent_videos").select("id, bunny_video_id, title, thumbnail_url, preview_url, playback_url, duration_seconds, status, created_at").eq("owner_user_id",a.id).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(H)throw H;d(U||[]),U!=null&&U.length&&S(U)}catch(U){console.error("Error fetching videos:",U),fe.error("Failed to load videos")}finally{p(!1)}}},S=async U=>{var H;try{const Y=U.map(re=>re.bunny_video_id),{data:se,error:te}=await G.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Y,isAgentVideo:!0}});if(te)throw te;const Q=(se==null?void 0:se.assets)||{},de={};for(const re of U)(H=Q[re.bunny_video_id])!=null&&H.thumbnailUrl&&(de[re.id]={thumbnailUrl:Q[re.bunny_video_id].thumbnailUrl});b(re=>({...re,...de}))}catch(Y){console.warn("Failed to bulk-fetch signed URLs",Y)}},T=()=>{l(!0),k()},I=U=>{s(U.id),y(U),l(!1),fe.success("Video selected")},L=()=>{s(null),y(null)},R=()=>{const U=r?`/mission-control/listings/${r}/edit`:"/mission-control/listings/new";n(`/mission-control/video?returnUrl=${encodeURIComponent(U)}`)},$=U=>{if(!U)return"0:00";const H=Math.floor(U/60),Y=U%60;return`${H}:${Y.toString().padStart(2,"0")}`},q=U=>{var H;return((H=_[U.id])==null?void 0:H.thumbnailUrl)||U.thumbnail_url};return e.jsxs("div",{className:"space-y-3",children:[f?e.jsx(Ee,{className:"overflow-hidden",children:e.jsx(Oe,{className:"p-0",children:e.jsxs("div",{className:"flex items-start gap-4 p-4",children:[e.jsxs("div",{className:"relative w-32 h-20 bg-muted rounded-lg overflow-hidden flex-shrink-0",children:[q(f)?e.jsx("img",{src:q(f),alt:f.title||"Video thumbnail",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Nn,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("div",{className:"absolute inset-0 bg-black/30 flex items-center justify-center",children:e.jsx(ul,{className:"h-6 w-6 text-white fill-white"})}),f.duration_seconds&&e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-white text-[10px] px-1.5 py-0.5 rounded",children:$(f.duration_seconds)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:f.title||"Untitled Video"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Property Video Tour"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:T,children:"Change"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:L,className:"text-destructive hover:text-destructive",children:e.jsx(Ur,{className:"h-4 w-4"})})]})]})})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Nn,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Add a video walkthrough to showcase this property"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 justify-center",children:[e.jsxs(K,{type:"button",variant:"outline",onClick:T,className:"gap-2",children:[e.jsx(_5,{className:"h-4 w-4"}),"Select from Library"]}),e.jsxs(K,{type:"button",variant:"outline",onClick:R,className:"gap-2",children:[e.jsx(qg,{className:"h-4 w-4"}),"Record New Video"]})]})]})})}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(Ss,{children:e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(_5,{className:"h-5 w-5"}),"Select a Video"]})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:u?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Ms,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):i.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Nn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"No videos in your library yet"}),e.jsxs(K,{onClick:R,className:"gap-2",children:[e.jsx(qg,{className:"h-4 w-4"}),"Record Your First Video"]})]}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 p-1",children:i.map(U=>e.jsxs("button",{type:"button",onClick:()=>I(U),className:`group relative rounded-lg overflow-hidden border-2 transition-all text-left ${t===U.id?"border-primary ring-2 ring-primary/20":"border-transparent hover:border-muted-foreground/30"}`,children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[q(U)?e.jsx("img",{src:q(U),alt:U.title||"Video",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Nn,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/30 transition-colors flex items-center justify-center",children:e.jsx(ul,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity"})}),U.duration_seconds&&e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-white text-[10px] px-1.5 py-0.5 rounded",children:$(U.duration_seconds)})]}),e.jsx("div",{className:"p-2 bg-card",children:e.jsx("p",{className:"text-xs font-medium truncate",children:U.title||"Untitled Video"})})]},U.id))})}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[e.jsxs(K,{type:"button",variant:"ghost",onClick:R,className:"gap-2",children:[e.jsx(qg,{className:"h-4 w-4"}),"Record New Video"]}),e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})})]})}const bfs=[{value:"active",label:"Active"},{value:"coming_soon",label:"Coming Soon"},{value:"price_improvement",label:"Price Improvement"},{value:"under_contract",label:"Under Contract"},{value:"sold",label:"Sold"}],wfs=[{value:"single_family",label:"Single Family"},{value:"condo",label:"Condo"},{value:"townhouse",label:"Townhouse"},{value:"land",label:"Land"},{value:"multi_family",label:"Multi-Family"},{value:"luxury",label:"Luxury"},{value:"commercial",label:"Commercial"},{value:"other",label:"Other"}];function $Le(){const{listingId:t}=ko(),[s]=Pc(),r=s.get("brokerage"),n=Pr(),{user:a}=Hs(),o=!!t&&t!=="new",l=!!r&&!o,{data:i,isLoading:d}=MVe(o?t:""),u=q5t(),p=U5t(),f=V5t(),y=H5t(),_=W5t(),b=G5t(),w=K5t(),{data:j=[]}=wt({queryKey:["brokerage-agents",r],queryFn:async()=>{if(!r)return[];const{data:ae,error:le}=await G.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name");if(le)throw le;return ae||[]},enabled:l}),[k,S]=C.useState(""),[T,I]=C.useState(!1),[L,R]=C.useState([]),[$,q]=C.useState([]),[U,H]=C.useState({property_address:"",city:"",state:"",neighborhood:"",price:"",property_type:"single_family",status:"active",bedrooms:"",bathrooms:"",square_footage:"",lot_size:"",year_built:"",has_hoa:!1,description:"",agent_notes:"",agent_notes_public:!1,mls_link:"",video_link:"",video_id:null,allow_sharing:!0,open_to_referrals:!0,open_to_social_promotion:!0,share_with_brokerage:!1,is_public:!0});C.useEffect(()=>{var ae,le,he,be,_e;i&&o&&H({property_address:i.property_address||"",city:i.city||"",state:i.state||"",neighborhood:i.neighborhood||"",price:((ae=i.price)==null?void 0:ae.toString())||"",property_type:i.property_type,status:i.status,bedrooms:((le=i.bedrooms)==null?void 0:le.toString())||"",bathrooms:((he=i.bathrooms)==null?void 0:he.toString())||"",square_footage:((be=i.square_footage)==null?void 0:be.toString())||"",lot_size:i.lot_size||"",year_built:((_e=i.year_built)==null?void 0:_e.toString())||"",has_hoa:i.has_hoa,description:i.description||"",agent_notes:i.agent_notes||"",agent_notes_public:i.agent_notes_public,mls_link:i.mls_link||"",video_link:i.video_link||"",video_id:i.video_id||null,allow_sharing:i.allow_sharing,open_to_referrals:i.open_to_referrals,open_to_social_promotion:i.open_to_social_promotion,share_with_brokerage:i.share_with_brokerage??!1,is_public:i.is_public})},[i,o]);const Y=ae=>{if(!ae)return;const le=Array.from(ae);R(be=>[...be,...le]);const he=le.map(be=>URL.createObjectURL(be));q(be=>[...be,...he])},se=ae=>{URL.revokeObjectURL($[ae]),R(le=>le.filter((he,be)=>be!==ae)),q(le=>le.filter((he,be)=>be!==ae))},te=async ae=>{var le;if(!(!ae||!i)){I(!0);try{for(const he of Array.from(ae)){const be=he.name.split(".").pop(),_e=`${a==null?void 0:a.id}/${i.id}/${Date.now()}.${be}`,{error:je}=await G.storage.from("listing-photos").upload(_e,he);if(je)throw je;const{data:{publicUrl:Ne}}=G.storage.from("listing-photos").getPublicUrl(_e);await y.mutateAsync({listingId:i.id,photoUrl:Ne,isPrimary:!((le=i.photos)!=null&&le.length)})}fe.success("Photos uploaded!")}catch(he){console.error("Upload error:",he),fe.error("Failed to upload photos")}finally{I(!1)}}},Q=async ae=>{for(let le=0;le{if(i)try{await _.mutateAsync({photoId:ae,listingId:i.id}),fe.success("Photo removed")}catch{fe.error("Failed to remove photo")}},re=async ae=>{if(ae.preventDefault(),!U.city.trim()||!U.state.trim()||!U.price){fe.error("Please fill in required fields (City, State, Price)");return}if(l&&!k){fe.error("Please select an agent to assign this listing to");return}try{const le={property_address:U.property_address||null,city:U.city,state:U.state,neighborhood:U.neighborhood||null,price:Number(U.price),property_type:U.property_type,status:U.status,bedrooms:U.bedrooms?Number(U.bedrooms):null,bathrooms:U.bathrooms?Number(U.bathrooms):null,square_footage:U.square_footage?Number(U.square_footage):null,lot_size:U.lot_size||null,year_built:U.year_built?Number(U.year_built):null,has_hoa:U.has_hoa,description:U.description||null,agent_notes:U.agent_notes||null,agent_notes_public:U.agent_notes_public,mls_link:U.mls_link||null,video_link:U.video_link||null,video_id:U.video_id||null,allow_sharing:U.allow_sharing,open_to_referrals:U.open_to_referrals,open_to_social_promotion:U.open_to_social_promotion,share_with_brokerage:U.share_with_brokerage,is_public:U.is_public};if(o)await f.mutateAsync({id:t,...le}),fe.success("Listing updated!"),n(`/mission-control/listings/${t}`);else{I(!0);let he;if(l&&k?he=await p.mutateAsync({agentId:k,...le}):he=await u.mutateAsync(le),L.length>0)try{await Q(he.id),$.forEach(be=>URL.revokeObjectURL(be)),R([]),q([])}catch(be){console.error("Photo upload error:",be),fe.error("Listing created but some photos failed to upload")}I(!1),fe.success("Listing created!"),n(l?"/my-brokerage":`/mission-control/listings/${he.id}`)}}catch(le){console.error("Save error:",le),fe.error("Failed to save listing"),I(!1)}};return o&&d?e.jsx(Ts,{title:"Loading...",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{className:"h-10 w-32"}),e.jsx(xs,{className:"h-[600px] w-full"})]})}):e.jsx(Ts,{title:o?"Edit Listing":l?"Add Listing for Agent":"Add Listing",description:"",children:e.jsxs("form",{onSubmit:re,className:"space-y-6",children:[e.jsxs(K,{type:"button",variant:"ghost",onClick:()=>n(l?"/my-brokerage":"/mission-control/listings"),children:[e.jsx(ti,{className:"h-4 w-4 mr-2"}),l?"Back to Brokerage":"Back to Listings"]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[l&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Assign to Agent *"})}),e.jsxs(Oe,{children:[e.jsxs(sr,{value:k,onValueChange:S,children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select an agent..."})}),e.jsx(tr,{children:j.map(ae=>e.jsx(At,{value:ae.id,children:ae.name||ae.email},ae.id))})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"This listing will appear on the selected agent's Listing Exchange."})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Property Details"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"sm:col-span-2 space-y-2",children:[e.jsx(ve,{children:"Property Address"}),e.jsx(Re,{value:U.property_address,onChange:ae=>H({...U,property_address:ae.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"City *"}),e.jsx(Re,{value:U.city,onChange:ae=>H({...U,city:ae.target.value}),placeholder:"City",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"State *"}),e.jsx(Re,{value:U.state,onChange:ae=>H({...U,state:ae.target.value}),placeholder:"State",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Neighborhood"}),e.jsx(Re,{value:U.neighborhood,onChange:ae=>H({...U,neighborhood:ae.target.value}),placeholder:"Neighborhood"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Price *"}),e.jsx(Re,{type:"number",value:U.price,onChange:ae=>H({...U,price:ae.target.value}),placeholder:"500000",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Property Type"}),e.jsxs(sr,{value:U.property_type,onValueChange:ae=>H({...U,property_type:ae}),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:wfs.map(ae=>e.jsx(At,{value:ae.value,children:ae.label},ae.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Status"}),e.jsxs(sr,{value:U.status,onValueChange:ae=>H({...U,status:ae}),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:bfs.map(ae=>e.jsx(At,{value:ae.value,children:ae.label},ae.value))})]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Property Specs (Optional)"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Bedrooms"}),e.jsx(Re,{type:"number",value:U.bedrooms,onChange:ae=>H({...U,bedrooms:ae.target.value}),placeholder:"3"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Bathrooms"}),e.jsx(Re,{type:"number",step:"0.5",value:U.bathrooms,onChange:ae=>H({...U,bathrooms:ae.target.value}),placeholder:"2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Sq Ft"}),e.jsx(Re,{type:"number",value:U.square_footage,onChange:ae=>H({...U,square_footage:ae.target.value}),placeholder:"2000"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Lot Size"}),e.jsx(Re,{value:U.lot_size,onChange:ae=>H({...U,lot_size:ae.target.value}),placeholder:"0.25 acres"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Year Built"}),e.jsx(Re,{type:"number",value:U.year_built,onChange:ae=>H({...U,year_built:ae.target.value}),placeholder:"2005"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx(Br,{checked:U.has_hoa,onCheckedChange:ae=>H({...U,has_hoa:ae})}),e.jsx(ve,{children:"Has HOA"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Description & Links"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Ar,{value:U.description,onChange:ae=>H({...U,description:ae.target.value}),placeholder:"Tell the story of this property...",rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Agent Notes"}),e.jsx(Ar,{value:U.agent_notes,onChange:ae=>H({...U,agent_notes:ae.target.value}),placeholder:"Notes for other agents...",rows:2}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{checked:U.agent_notes_public,onCheckedChange:ae=>H({...U,agent_notes_public:ae})}),e.jsx(ve,{className:"text-sm text-muted-foreground",children:"Make notes visible to other agents"})]})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"MLS Link"}),e.jsx(Re,{value:U.mls_link,onChange:ae=>H({...U,mls_link:ae.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Video Link"}),e.jsx(Re,{value:U.video_link,onChange:ae=>H({...U,video_link:ae.target.value}),placeholder:"YouTube or Vimeo URL"})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Nn,{className:"h-5 w-5"}),"Property Video"]})}),e.jsx(Oe,{children:e.jsx(_fs,{selectedVideoId:U.video_id,onVideoSelect:ae=>H({...U,video_id:ae}),listingId:o?t:void 0})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Photos"})}),e.jsx(Oe,{children:o&&(i!=null&&i.photos)?e.jsx(vfs,{photos:i.photos,uploading:T,onUpload:ae=>te(ae),onRemove:ae=>de(ae),onReorder:ae=>{b.mutate({photos:ae.map(le=>({id:le.id,sort_order:le.sort_order,is_primary:le.is_primary}))})},onSetPrimary:ae=>{i&&w.mutate({photoId:ae,listingId:i.id})}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[$.map((ae,le)=>e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:ae,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:()=>se(le),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90",children:e.jsx(Ur,{className:"h-3 w-3"})}),le===0&&e.jsx("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded",children:"Primary"})]},le)),e.jsxs("label",{className:"aspect-square rounded-lg border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 cursor-pointer flex flex-col items-center justify-center gap-2 text-muted-foreground",children:[T?e.jsx(Ms,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Za,{className:"h-8 w-8"}),e.jsx("span",{className:"text-xs",children:"Upload"})]}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:ae=>Y(ae.target.files),disabled:T})]})]}),L.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-4",children:[L.length," photo",L.length!==1?"s":""," will be uploaded when you save."]})]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Sharing & Collaboration"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Allow Sharing"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Other agents can share this listing"})]}),e.jsx(Br,{checked:U.allow_sharing,onCheckedChange:ae=>H({...U,allow_sharing:ae})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Open to Referrals"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Accept buyer referrals"})]}),e.jsx(Br,{checked:U.open_to_referrals,onCheckedChange:ae=>H({...U,open_to_referrals:ae})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Social Promotion"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Can be promoted on social media"})]}),e.jsx(Br,{checked:U.open_to_social_promotion,onCheckedChange:ae=>H({...U,open_to_social_promotion:ae})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Share with Brokerage"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visible to agents in your brokerage"})]}),e.jsx(Br,{checked:U.share_with_brokerage,onCheckedChange:ae=>H({...U,share_with_brokerage:ae})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Make Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Publish on listings.relevelup.com to get leads"})]}),e.jsx(Br,{checked:U.is_public,onCheckedChange:ae=>H({...U,is_public:ae})})]})]})]}),e.jsx(K,{type:"submit",className:"w-full",size:"lg",disabled:u.isPending||f.isPending,children:u.isPending||f.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):o?"Update Listing":"Create Listing"})]})]})]})})}function $ce({maxDurationSeconds:t=30,onRecordingComplete:s,onError:r,onRecordingStateChange:n,className:a,teleprompterContent:o}){const l=C.useRef(null),i=C.useRef(null),d=C.useRef(null),u=C.useRef([]),p=C.useRef(null),f=C.useRef(null),y=C.useRef(null),_=C.useRef(null),b=eT(),[w,j]=C.useState(!0),[k,S]=C.useState(!0),[T,I]=C.useState(null),[L,R]=C.useState(!1),[$,q]=C.useState(!1),[U,H]=C.useState(null),[Y,se]=C.useState(null),[te,Q]=C.useState(0),[de,re]=C.useState("user"),[ae,le]=C.useState(0),[he,be]=C.useState(!1),[_e,je]=C.useState(!0),[Ne,Ge]=C.useState(null),[we,Me]=C.useState(!1),[Te,Fe]=C.useState(null),Ae=C.useRef(null),Ue=C.useRef(r);Ue.current=r;const ut=C.useCallback(He=>{j(He)},[]),De=C.useRef(w),Rt=C.useCallback(async()=>{var et,Tt;S(!0),Ge(null);const He=b&&w;console.log("[VideoRecorder] initCamera start",{isMobile:b,usePortraitMode:w,shouldBePortrait:He,facingMode:de});try{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Camera not available in this browser or context. Try opening in a new tab.");d.current&&(console.log("[VideoRecorder] stopping existing stream"),d.current.getTracks().forEach(is=>is.stop()));const Ft=b&&He?{facingMode:{ideal:de},width:{ideal:720},height:{ideal:1280}}:{facingMode:{ideal:de},width:{ideal:1280},height:{ideal:720}};console.log("[VideoRecorder] requesting getUserMedia",Ft);const as=await navigator.mediaDevices.getUserMedia({video:Ft,audio:{echoCancellation:!0,noiseSuppression:!0}});if(console.log("[VideoRecorder] getUserMedia success"),as.getVideoTracks().length===0)throw new Error("Camera stream started but no video track was provided.");d.current=as,I(!0);const ss=as.getVideoTracks()[0].getSettings();if(console.log("[VideoRecorder] Camera initialized with dimensions:",ss.width,"x",ss.height),l.current){const is=l.current;is.srcObject=as,is.muted=!0,is.playsInline=!0,is.autoplay=!0,is.setAttribute("muted",""),is.setAttribute("playsinline",""),is.setAttribute("autoplay","");try{(et=is.load)==null||et.call(is)}catch(Ct){console.warn("[VideoRecorder] videoEl.load failed",Ct)}const ar=async()=>{try{return await is.play(),console.log("[VideoRecorder] preview play ok"),Me(!1),setTimeout(()=>{console.debug("[VideoRecorder] preview metrics",{readyState:is.readyState,videoWidth:is.videoWidth,videoHeight:is.videoHeight})},300),!0}catch(Ct){return console.warn("[VideoRecorder] preview play blocked",Ct),Me(!0),!1}};await new Promise(Ct=>{let Is=!1;const qs=()=>{Is||(Is=!0,Ct())},gr=()=>{ar().finally(qs)};is.onloadedmetadata=gr,is.onloadeddata=gr,setTimeout(qs,1500)})}try{f.current=new AudioContext;const is=f.current.createMediaStreamSource(as);y.current=f.current.createAnalyser(),y.current.fftSize=256,is.connect(y.current);const ar=()=>{if(y.current){const Ct=new Uint8Array(y.current.frequencyBinCount);y.current.getByteFrequencyData(Ct);const Is=Ct.reduce((qs,gr)=>qs+gr)/Ct.length;le(Math.min(100,Is/128*100))}_.current=requestAnimationFrame(ar)};ar()}catch(is){console.warn("Audio context not available:",is)}}catch(Ft){console.error("Camera initialization error:",Ft),I(!1);let as="Failed to access camera or microphone.";Ft.name==="NotAllowedError"?as="Camera permission denied. Please allow camera access in your browser settings.":Ft.name==="NotFoundError"?as="No camera found. Please connect a camera and try again.":Ft.name==="NotReadableError"?as="Camera is in use by another application. Please close other apps using the camera.":Ft.message&&(as=Ft.message),Ge(as),(Tt=Ue.current)==null||Tt.call(Ue,as)}finally{S(!1)}},[de,b,w]);C.useEffect(()=>{De.current!==w&&T&&!L&&!Y&&(De.current=w,Rt())},[w,T,L,Y,Rt]),C.useEffect(()=>(Rt(),()=>{d.current&&d.current.getTracks().forEach(He=>He.stop()),p.current&&clearInterval(p.current),_.current&&cancelAnimationFrame(_.current),f.current&&f.current.close(),Ae.current&&clearInterval(Ae.current),Y&&URL.revokeObjectURL(Y)}),[Rt,Y]),C.useEffect(()=>{if(k||T!==!0||Y)return;const He=d.current,et=l.current;!He||!et||(et.srcObject!==He&&(et.srcObject=He,et.muted=!0,et.playsInline=!0,et.autoplay=!0,et.setAttribute("muted",""),et.setAttribute("playsinline",""),et.setAttribute("autoplay","")),et.play().then(()=>Me(!1)).catch(Tt=>{Me(!0),console.warn("Live preview play blocked on mount:",Tt)}))},[T,k,Y]),C.useEffect(()=>{n==null||n(L)},[L,n]);const me=C.useCallback(async()=>{if(Y)return;const He=l.current;if(He)try{await He.play(),Me(!1)}catch(et){Me(!0),console.warn("Live preview still blocked (needs user gesture):",et)}},[Y]),Xe=C.useCallback(()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),p.current&&(clearInterval(p.current),p.current=null),R(!1),q(!1)},[]),ot=C.useCallback(()=>{if(!d.current)return;me(),u.current=[],Q(0);const et=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"].find(Ft=>MediaRecorder.isTypeSupported(Ft)),Tt=new MediaRecorder(d.current,et?{mimeType:et,videoBitsPerSecond:25e5}:{videoBitsPerSecond:25e5});Tt.ondataavailable=Ft=>{Ft.data.size>0&&u.current.push(Ft.data)},Tt.onstop=()=>{var ss;const Ft=Tt.mimeType||et||((ss=u.current[0])==null?void 0:ss.type)||"video/webm",as=new Blob(u.current,{type:Ft});H(as);const Xt=URL.createObjectURL(as);se(Xt)},i.current=Tt,Tt.start(100),R(!0),p.current=setInterval(()=>{Q(Ft=>Ft>=t-1?(Xe(),t):Ft+1)},1e3)},[me,t,Xe]),nt=C.useCallback(()=>{Ae.current&&(clearInterval(Ae.current),Ae.current=null),Fe(3);let He=3;Ae.current=setInterval(()=>{He-=1,He<=0?(Ae.current&&clearInterval(Ae.current),Ae.current=null,Fe(null),ot()):Fe(He)},1e3)},[ot]),Se=C.useCallback(()=>{i.current&&i.current.state==="recording"&&(i.current.pause(),q(!0),p.current&&clearInterval(p.current))},[]),it=C.useCallback(()=>{i.current&&i.current.state==="paused"&&(i.current.resume(),q(!1),p.current=setInterval(()=>{Q(He=>He>=t-1?(Xe(),t):He+1)},1e3))},[t,Xe]),$e=C.useCallback(()=>{Y&&URL.revokeObjectURL(Y),H(null),se(null),Q(0),be(!1),je(!0),l.current&&d.current&&(l.current.srcObject=d.current,l.current.muted=!0,me())},[me,Y]),ct=C.useCallback(()=>{re(He=>He==="user"?"environment":"user")},[]),qe=C.useCallback(()=>{U&&s(U,te)},[U,te,s]),Ze=C.useCallback(()=>{l.current&&Y&&(he?l.current.pause():(je(!1),l.current.muted=!1,l.current.play()),be(!he))},[Y,he]);C.useEffect(()=>{if(!Y)return;const He=l.current;if(!He)return;je(!1),He.pause(),He.removeAttribute("src"),He.srcObject=null,He.load(),He.src=Y,He.currentTime=0,He.playsInline=!0,He.muted=!1,He.onended=()=>be(!1);const et=()=>{var as;const Tt=He.error,Ft=Tt?`Recorded video failed to play (code ${Tt.code}). Likely unsupported format/codec in this browser.`:"Recorded video failed to play.";console.warn("[VideoRecorder] recorded playback error",Tt),(as=Ue.current)==null||as.call(Ue,Ft)};return He.addEventListener("error",et),He.load(),()=>{He.removeEventListener("error",et)}},[Y]);const Qe=He=>{const et=Math.floor(He/60),Tt=He%60;return`${et}:${Tt.toString().padStart(2,"0")}`},We=b&&w?"aspect-[9/16]":"aspect-video";return k?e.jsx("div",{className:Pt("flex items-center justify-center bg-black rounded-lg",We,a),children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(Ms,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),e.jsx("p",{children:"Initializing camera..."})]})}):T===!1?e.jsx("div",{className:Pt("flex items-center justify-center bg-black rounded-lg",We,a),children:e.jsxs("div",{className:"text-center text-white p-8 max-w-md",children:[e.jsx(ll,{className:"h-12 w-12 mx-auto mb-4 text-destructive"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Camera Access Required"}),e.jsx("p",{className:"text-gray-400 mb-4 text-sm",children:Ne||"Please allow camera and microphone access to record videos."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(K,{onClick:()=>Rt(),variant:"secondary",className:"w-full",children:[e.jsx(Po,{className:"h-4 w-4 mr-2"}),"Try Again"]}),e.jsx("p",{className:"text-xs text-gray-500 mt-3",children:"💡 Tip: If you're viewing this in an embedded preview, try opening the app in a new browser tab for full camera access."})]})]})}):e.jsxs("div",{className:Pt("flex flex-col gap-2",a),children:[b&&!L&&!Y&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 bg-muted/50 rounded-lg",children:[e.jsx(hk,{className:Pt("h-4 w-4",w?"text-muted-foreground":"text-primary")}),e.jsx(ve,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Landscape"}),e.jsx(Br,{id:"orientation-toggle",checked:w,onCheckedChange:ut}),e.jsx(ve,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Portrait"}),e.jsx(U0,{className:Pt("h-4 w-4",w?"text-primary":"text-muted-foreground")})]}),e.jsxs("div",{className:Pt("relative bg-black rounded-lg overflow-hidden"),onPointerDown:()=>{me()},children:[e.jsx("video",{ref:l,src:Y??void 0,className:Pt("w-full bg-black",w&&!Y?"object-contain":"object-cover",We,de==="user"&&!Y&&"scale-x-[-1]"),playsInline:!0,controls:!!Y,muted:Y?_e:!0,autoPlay:!Y},Y??"live"),!Y&&we&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:e.jsx(K,{type:"button",variant:"secondary",onClick:()=>void me(),className:"bg-white/20 hover:bg-white/30 text-white",children:"Tap to enable preview"})}),o&&!Y&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:o}),Te!==null&&!Y&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-30 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"text-white font-bold drop-shadow-lg animate-scale-in",style:{fontSize:"96px",lineHeight:1,textShadow:"0 4px 16px rgba(0,0,0,0.8)"},children:Te},Te),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),L&&e.jsxs("div",{className:"absolute top-4 left-4 flex items-center gap-2 bg-black/50 px-3 py-1.5 rounded-full",children:[e.jsx("div",{className:Pt("w-3 h-3 rounded-full",$?"bg-yellow-500":"bg-red-500 animate-pulse")}),e.jsxs("span",{className:"text-white text-sm font-medium",children:[Qe(te)," / ",Qe(t)]})]}),L&&e.jsx("div",{className:"absolute top-0 left-0 right-0",children:e.jsx(Ti,{value:te/t*100,className:"h-1 rounded-none"})}),!Y&&e.jsxs("div",{className:"absolute bottom-20 left-4 flex items-center gap-2 bg-black/50 px-3 py-1.5 rounded-full",children:[e.jsx(SP,{className:"h-4 w-4 text-white"}),e.jsx("div",{className:"w-20 h-2 bg-white/20 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-green-500 transition-all duration-75",style:{width:`${ae}%`}})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center gap-3 px-4",children:Y?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"secondary",size:"lg",className:"bg-white/20 hover:bg-white/30 text-white",onClick:$e,children:[e.jsx(Po,{className:"h-5 w-5 mr-2"}),"Re-record"]}),e.jsx(K,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:Ze,children:he?e.jsx(vp,{className:"h-5 w-5"}):e.jsx(ul,{className:"h-5 w-5"})}),e.jsxs(K,{size:"lg",className:"bg-green-500 hover:bg-green-600 text-white",onClick:qe,children:[e.jsx(ha,{className:"h-5 w-5 mr-2"}),"Use This Video"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:ct,disabled:L||Te!==null,children:e.jsx(q0,{className:"h-5 w-5"})}),!L&&Te===null?e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:nt,children:e.jsx(Nn,{className:"h-6 w-6"})}):e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:$?it:Se,children:$?e.jsx(ul,{className:"h-5 w-5"}):e.jsx(vp,{className:"h-5 w-5"})}),e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:Xe,children:e.jsx(ey,{className:"h-6 w-6 fill-current"})})]}),e.jsx("div",{className:"h-12 w-12"})]})})]})]})}const FJe="teleprompter_settings",Fpe={scrollSpeed:30,fontSize:24,lineHeight:1.6,opacity:.85,position:"top",isMirrored:!1};function jfs(){try{const t=localStorage.getItem(FJe);return t?{...Fpe,...JSON.parse(t)}:Fpe}catch{return Fpe}}function Nfs(t){try{localStorage.setItem(FJe,JSON.stringify(t))}catch{}}function zJe({text:t,isVisible:s,onToggleVisibility:r,isRecording:n=!1,startCountdown:a=!1,onCountdownComplete:o,className:l}){const i=C.useRef(null),d=C.useRef(null),u=C.useRef(0),p=C.useRef(0),[f,y]=C.useState(jfs),{scrollSpeed:_,fontSize:b,lineHeight:w,opacity:j,position:k,isMirrored:S}=f,T=C.useCallback((se,te)=>{y(Q=>{const de={...Q,[se]:te};return Nfs(de),de})},[]),[I,L]=C.useState(!1),[R,$]=C.useState(null),q=C.useCallback(se=>{if(!i.current)return;u.current===0&&(u.current=se);const te=se-u.current;u.current=se,p.current+=_*te/1e3;const Q=Math.floor(p.current);Q>0&&(i.current.scrollTop+=Q,p.current-=Q);const{scrollTop:de,scrollHeight:re,clientHeight:ae}=i.current;if(de+ae>=re){L(!1);return}d.current=requestAnimationFrame(q)},[_]);C.useEffect(()=>(I?(u.current=0,p.current=0,d.current=requestAnimationFrame(q)):d.current&&cancelAnimationFrame(d.current),()=>{d.current&&cancelAnimationFrame(d.current)}),[I,q]),C.useEffect(()=>{if(n&&s)if(i.current&&(i.current.scrollTop=0),a){$(3);let se=3;const te=setInterval(()=>{se-=1,se<=0?(clearInterval(te),$(null),o==null||o(),L(!0)):$(se)},1e3);return()=>clearInterval(te)}else setTimeout(()=>L(!0),100);else n||(L(!1),$(null))},[n,s,a,o]);const U=C.useCallback(()=>{i.current&&(i.current.scrollTop=0),L(!1)},[]),H=C.useCallback(()=>{L(se=>!se)},[]);if(!s)return e.jsx("div",{className:Pt("absolute top-4 right-4 pointer-events-auto z-10",l),children:e.jsxs(K,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(xa,{className:"h-4 w-4 mr-2"}),"Show Script"]})});const Y={top:"top-0 pt-16",center:"top-1/2 -translate-y-1/2",bottom:"bottom-0 pb-24"};return e.jsxs("div",{className:Pt("absolute inset-0 pointer-events-none",l),children:[R!==null&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"text-white font-bold drop-shadow-lg animate-scale-in",style:{fontSize:"96px",lineHeight:1,textShadow:"0 4px 16px rgba(0,0,0,0.8)"},children:R},R),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),e.jsx("div",{className:Pt("absolute left-0 right-0 h-[60%] overflow-hidden pointer-events-auto",Y[k],R!==null&&"opacity-30"),style:{opacity:R!==null?.3:j},children:e.jsxs("div",{ref:i,className:Pt("mx-auto max-w-2xl px-6 overflow-y-auto scrollbar-hide h-full",S&&"scale-x-[-1]"),style:{maskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)",WebkitMaskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)"},children:[e.jsx("div",{className:"h-full",style:{minHeight:"100%"}}),e.jsx("p",{className:"text-white text-center font-medium drop-shadow-lg",style:{fontSize:`${b}px`,lineHeight:w,textShadow:"0 2px 4px rgba(0,0,0,0.8)"},children:t}),e.jsx("div",{className:"h-full"})]})}),e.jsxs("div",{className:"absolute top-4 right-4 flex items-center gap-2 pointer-events-auto",children:[e.jsxs(Co,{children:[e.jsx(Mo,{asChild:!0,children:e.jsx(K,{variant:"secondary",size:"icon",className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx($l,{className:"h-4 w-4"})})}),e.jsx(No,{className:"w-72",side:"left",align:"start",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium",children:"Teleprompter Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-xs",children:"Scroll Speed"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:_})]}),e.jsx(Fg,{value:[_],onValueChange:([se])=>T("scrollSpeed",se),min:1,max:100,step:1})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-xs",children:"Font Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[b,"px"]})]}),e.jsx(Fg,{value:[b],onValueChange:([se])=>T("fontSize",se),min:16,max:48,step:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-xs",children:"Line Spacing"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:w.toFixed(1)})]}),e.jsx(Fg,{value:[w*10],onValueChange:([se])=>T("lineHeight",se/10),min:12,max:24,step:1})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-xs",children:"Opacity"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(j*100),"%"]})]}),e.jsx(Fg,{value:[j*100],onValueChange:([se])=>T("opacity",se/100),min:30,max:100,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{className:"text-xs",children:"Position"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:k==="top"?"default":"outline",size:"sm",onClick:()=>T("position","top"),children:e.jsx(Ug,{className:"h-4 w-4"})}),e.jsx(K,{variant:k==="center"?"default":"outline",size:"sm",onClick:()=>T("position","center"),children:e.jsx(F0,{className:"h-4 w-4"})}),e.jsx(K,{variant:k==="bottom"?"default":"outline",size:"sm",onClick:()=>T("position","bottom"),children:e.jsx(Ho,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-xs",children:"Mirror Mode"}),e.jsx(Br,{checked:S,onCheckedChange:se=>T("isMirrored",se)})]})]})})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:H,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:I?e.jsx(vp,{className:"h-4 w-4"}):e.jsx(ul,{className:"h-4 w-4"})}),e.jsx(K,{variant:"secondary",size:"icon",onClick:U,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(q0,{className:"h-4 w-4"})}),e.jsxs(K,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(Im,{className:"h-4 w-4 mr-2"}),"Hide"]})]})]})}function kfs({onSelectScript:t,onCreateNew:s,selectedScriptId:r,className:n}){const{toast:a}=Pa(),[o,l]=C.useState(""),[i,d]=C.useState(null),[u,p]=C.useState("levelup"),{data:f,isLoading:y}=aps(),{data:_,isLoading:b}=ips(),{data:w,isLoading:j}=ops(),k=lps(),S=C.useMemo(()=>_?_.filter($=>{const q=!o||$.title.toLowerCase().includes(o.toLowerCase())||$.script_text.toLowerCase().includes(o.toLowerCase())||$.tags.some(H=>H.toLowerCase().includes(o.toLowerCase())),U=!i||$.category_id===i;return q&&U}):[],[_,o,i]),T=C.useMemo(()=>w?w.filter($=>!o||$.title.toLowerCase().includes(o.toLowerCase())||$.script_text.toLowerCase().includes(o.toLowerCase())):[],[w,o]),I=$=>{t({title:$.title,text:$.script_text})},L=async $=>{try{await k.mutateAsync($),a({title:"Script saved to My Scripts"})}catch{a({title:"Failed to save script",variant:"destructive"})}},R=y||b||j;return e.jsxs("div",{className:Pt("flex flex-col h-full",n),children:[e.jsx("div",{className:"p-4 border-b",children:e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search scripts...",value:o,onChange:$=>l($.target.value),className:"pl-9"})]})}),e.jsxs(ka,{value:u,onValueChange:$=>p($),className:"flex-1 flex flex-col",children:[e.jsxs(_a,{className:"mx-4 mt-4 grid grid-cols-2",children:[e.jsxs(js,{value:"levelup",children:[e.jsx(In,{className:"h-4 w-4 mr-2"}),"LevelUp Scripts"]}),e.jsxs(js,{value:"my-scripts",children:[e.jsx($g,{className:"h-4 w-4 mr-2"}),"My Scripts"]})]}),e.jsxs(zs,{value:"levelup",className:"flex-1 flex flex-col mt-0 p-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsx(rt,{variant:i?"outline":"default",className:"cursor-pointer",onClick:()=>d(null),children:"All"}),f==null?void 0:f.map($=>e.jsx(rt,{variant:i===$.id?"default":"outline",className:"cursor-pointer",onClick:()=>d($.id),children:$.name},$.id))]}),e.jsx(Ri,{className:"flex-1 max-h-[50vh]",children:R?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):S.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(In,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No scripts found"})]}):e.jsx("div",{className:"space-y-2",children:S.map($=>e.jsxs(Ee,{className:Pt("cursor-pointer hover:bg-accent/50 transition-colors",r===$.id&&"ring-2 ring-primary"),onClick:()=>I($),children:[e.jsx(It,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Ot,{className:"text-sm font-medium truncate",children:$.title}),$.category&&e.jsx(rt,{variant:"secondary",className:"mt-1 text-xs",children:$.category.name})]}),e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:q=>{q.stopPropagation(),L($)},children:e.jsx($g,{className:"h-4 w-4"})}),e.jsx(Ua,{className:"h-4 w-4 text-muted-foreground"})]})]})}),e.jsx(Oe,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:$.script_text})})]},$.id))})})]}),e.jsxs(zs,{value:"my-scripts",className:"flex-1 flex flex-col mt-0 p-4",children:[s&&e.jsxs(K,{variant:"outline",className:"mb-4",onClick:s,children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create New Script"]}),e.jsx(Ri,{className:"flex-1 max-h-[50vh]",children:j?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):T.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx($g,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No saved scripts"}),e.jsx("p",{className:"text-sm mt-1",children:"Save LevelUp scripts or create your own"})]}):e.jsx("div",{className:"space-y-2",children:T.map($=>e.jsxs(Ee,{className:Pt("cursor-pointer hover:bg-accent/50 transition-colors",r===$.id&&"ring-2 ring-primary"),onClick:()=>I($),children:[e.jsx(It,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Ot,{className:"text-sm font-medium truncate",children:$.title}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:$.is_custom?e.jsx(rt,{variant:"outline",className:"text-xs",children:"Custom"}):e.jsx(rt,{variant:"secondary",className:"text-xs",children:"Saved"})})]}),e.jsx(Ua,{className:"h-4 w-4 text-muted-foreground ml-2"})]})}),e.jsx(Oe,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:$.script_text})})]},$.id))})})]})]})]})}function Sfs({selectedTemplate:t,onSelect:s,contactName:r,saving:n=!1}){const[a,o]=C.useState(()=>{const i=F5(t);return new Set([i.category])}),l=i=>{o(d=>{const u=new Set(d);return u.has(i)?u.delete(i):u.add(i),u})};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Share Page Template"}),n&&e.jsx(Ms,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),e.jsx("div",{className:"space-y-3",children:W4t.map(i=>{const d=G4t(i.id),u=a.has(i.id),p=d.some(f=>f.id===t);return e.jsxs(bf,{open:u,onOpenChange:()=>l(i.id),children:[e.jsxs(wf,{className:"flex items-center justify-between w-full p-2.5 rounded-lg bg-muted/50 hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:i.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",d.length,")"]}),p&&!u&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded-full",children:"✓"})]}),e.jsx(Ho,{className:Pt("h-4 w-4 text-muted-foreground transition-transform",u&&"rotate-180")})]}),e.jsx(jf,{className:"pt-2",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:d.map(f=>{const y=t===f.id;return e.jsxs("button",{type:"button",onClick:()=>s(f.id),disabled:n,className:Pt("relative rounded-lg border-2 p-2.5 text-left transition-all hover:shadow-sm disabled:opacity-50 disabled:cursor-not-allowed",y?"border-primary ring-1 ring-primary/20 bg-primary/5":"border-muted hover:border-muted-foreground/30"),children:[y&&e.jsx("div",{className:"absolute top-1 right-1 w-4 h-4 rounded-full bg-primary flex items-center justify-center",children:e.jsx(ha,{className:"h-2.5 w-2.5 text-primary-foreground"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"opacity-70 shrink-0",children:f.icon}),e.jsx("span",{className:"text-sm font-medium truncate",children:f.name})]})]},f.id)})})})]},i.id)})}),r&&t!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Will show: "',F5(t).headerText(r),'"']})]})}function BJe({open:t,onOpenChange:s,video:r,contactName:n,onTemplateUpdated:a}){const[o,l]=C.useState(r.page_template||"default"),[i,d]=C.useState(!1),[u,p]=C.useState(!1),[f,y]=C.useState(r.page_template||"default"),[_,b]=C.useState([]),[w,j]=C.useState(r.contact_id&&n?{id:r.contact_id,name:n,email:null}:null),[k,S]=C.useState(!1),[T,I]=C.useState(!1),L=r.share_token?`https://video.relevelup.com/${r.share_token}`:"";C.useEffect(()=>{t&&_.length===0&&R()},[t]);const R=async()=>{I(!0);try{const{data:de,error:re}=await G.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(re)throw re;const ae=(de||[]).map(le=>({id:le.id,name:[le.first_name,le.last_name].filter(Boolean).join(" ")||"Unnamed",email:le.email||null}));b(ae)}catch(de){console.error("Failed to fetch contacts:",de)}finally{I(!1)}},$=async de=>{j(de),S(!1),d(!0);try{const{error:re}=await G.from("agent_videos").update({contact_id:(de==null?void 0:de.id)||null,recipient_name:(de==null?void 0:de.name)||null}).eq("id",r.id);if(re)throw re;fe.success(de?`Assigned to ${de.name}`:"Contact removed"),a==null||a()}catch(re){console.error("Failed to update contact:",re),fe.error("Failed to update contact")}finally{d(!1)}},q=async de=>{l(de),d(!0);try{const{error:re}=await G.from("agent_videos").update({page_template:de}).eq("id",r.id);if(re)throw re;y(de),fe.success("Template saved!"),a==null||a()}catch(re){console.error("Failed to save template:",re),fe.error("Failed to save template"),l(f)}finally{d(!1)}},U=(w==null?void 0:w.name)||null,H=()=>{const de=r.title||"Video Message",re=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:r.thumbnail_url||"";return``},Y=async()=>{if(!r.thumbnail_url){fe.error("Video thumbnail not available yet");return}const de=H(),re=`Watch: ${r.title||"Video Message"} ${L}`;try{const ae=new Blob([de],{type:"text/html"}),le=new Blob([re],{type:"text/plain"}),he=new ClipboardItem({"text/html":ae,"text/plain":le});await navigator.clipboard.write([he]),fe.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(re+` `+de),fe.success("Copied! Paste into your email.")}},se=async()=>{await navigator.clipboard.writeText(L),p(!0),fe.success("Share link copied!"),setTimeout(()=>p(!1),2e3)},te=()=>{const re=F5(o).headerText(U),ae=o==="default"?`Check out this video: ${L}`:`${re} Check out this special video: ${L}`;window.open(`sms:?body=${encodeURIComponent(ae)}`,"_self")},Q=()=>{const de=F5(o),re=de.headerText(U),ae=o==="default"?r.title||"Video Message":re,le=`${de.subText} Watch the video: ${L}`,he=w!=null&&w.email?encodeURIComponent(w.email):"";window.open(`mailto:${he}?subject=${encodeURIComponent(ae)}&body=${encodeURIComponent(le)}`,"_self")};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(Do,{className:"h-5 w-5"}),"Share Video"]}),e.jsx(Kr,{children:"Choose a themed page template and share your video"})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Personalize for Contact (Optional)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Co,{open:k,onOpenChange:S,children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":k,className:"flex-1 justify-between",disabled:i,children:[w?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Yi,{className:"h-4 w-4 text-muted-foreground"}),w.name]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(xf,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(No,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Mf,{children:[e.jsx(Tf,{placeholder:"Search contacts..."}),e.jsxs(Af,{children:[e.jsx(Ef,{children:T?"Loading...":"No contacts found."}),e.jsx(Pf,{children:_.map(de=>e.jsxs(Cm,{value:de.name,onSelect:()=>$(de),children:[e.jsx(ha,{className:Pt("mr-2 h-4 w-4",(w==null?void 0:w.id)===de.id?"opacity-100":"opacity-0")}),de.name]},de.id))})]})]})})]}),w&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>$(null),disabled:i,className:"shrink-0",children:e.jsx(Ur,{className:"h-4 w-4"})})]}),w&&o!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Page will show: "',F5(o).headerText(w.name),'"']})]}),e.jsx(Sfs,{selectedTemplate:o,onSelect:q,contactName:U,saving:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Share Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:L,readOnly:!0,className:"font-mono text-sm"}),e.jsx(K,{onClick:se,variant:u?"default":"outline",className:"shrink-0 gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(ha,{className:"h-4 w-4"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ai,{className:"h-4 w-4"}),"Copy"]})})]})]}),r.thumbnail_url&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Share for Email"}),e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:Y,children:[e.jsx(Jo,{className:"h-4 w-4"}),"Copy with Thumbnail (for Gmail)"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paste into Gmail to embed a clickable video thumbnail"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Quick Share"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:te,children:[e.jsx(io,{className:"h-4 w-4"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:Q,children:[e.jsx(br,{className:"h-4 w-4"}),"Email"]})]})]})]}),e.jsx(Un,{children:e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})}function Cfs(){var nt;const t=Pr(),[s]=Pc(),{toast:r}=Pa(),n=s.get("contact_id"),a=s.get("task_id"),{canRecord:o,remainingMb:l,usagePercent:i,isNearLimit:d}=NJe(),{data:u}=tm(),p=xS(),f=mps(),[y,_]=C.useState("record"),[b,w]=C.useState(""),[j,k]=C.useState(!1),[S,T]=C.useState(!1),[I,L]=C.useState(!1),[R,$]=C.useState(null),[q,U]=C.useState(0),[H,Y]=C.useState(0),[se,te]=C.useState(null),[Q,de]=C.useState(null),[re,ae]=C.useState(n||""),[le,he]=C.useState(""),[be,_e]=C.useState(""),[je,Ne]=C.useState(null),[Ge,we]=C.useState(null),[Me,Te]=C.useState(null),[Fe,Ae]=C.useState(!1),Ue=C.useCallback(async(Se,it)=>{$(Se),_("uploading");try{const{videoId:$e,uploadUrl:ct}=await fD(le||"Quick Video Touch");te($e);const{apiKey:qe}=await gD($e),Ze=new XMLHttpRequest;Ze.upload.onprogress=et=>{et.lengthComputable&&U(et.loaded/et.total*100)},await new Promise((et,Tt)=>{Ze.onload=()=>{Ze.status>=200&&Ze.status<300?et():Tt(new Error(`Upload failed: ${Ze.status}`))},Ze.onerror=()=>Tt(new Error("Upload failed")),Ze.open("PUT",ct),Ze.setRequestHeader("AccessKey",qe),Ze.send(Se)}),_("processing");let Qe=0;const We=Date.now(),He=90*1e3;for(;Qe<4;){if(await new Promise(Tt=>setTimeout(Tt,3e3)),Date.now()-We>He){const Tt=Se.size/1048576,Ft=`https://iframe.mediadelivery.net/play/${$e}/${$e}`;await p.mutateAsync({bunny_video_id:$e,playback_url:Ft,file_size_mb:Tt,title:le||"Quick Video Touch",notes:be||void 0,contact_id:re&&re!=="none"?re:void 0,status:"processing",touch_type:"video_touch"}),r({title:"Video saved — still processing",description:'Your video has been saved and will appear in your library with a "processing" badge. It will be ready to share once encoding completes (usually within a few minutes).',duration:8e3}),t("/mission-control/video-library");return}const et=await oM($e);if(Qe=et.status,Y(et.encodeProgress||0),Qe===4)de({playbackUrl:et.directPlayUrl,thumbnailUrl:et.thumbnailUrl,previewUrl:et.previewUrl||null,duration:et.length||it,fileSizeMb:(et.storageSize||Se.size)/(1024*1024)});else if(Qe===5||Qe===6)throw new Error("Video processing failed")}_("details")}catch($e){console.error("Upload error:",$e),r({title:"Upload failed",description:"Please try recording again.",variant:"destructive"}),_("record")}},[le,r]),ut=async()=>{if(!(!se||!Q))try{const Se=re&&re!=="none"?re:null,it=await p.mutateAsync({bunny_video_id:se,contact_id:Se,playback_url:Q.playbackUrl,thumbnail_url:Q.thumbnailUrl,preview_url:Q.previewUrl,duration_seconds:Q.duration,file_size_mb:Q.fileSizeMb,title:le||"Quick Video Touch",notes:be,task_id:a||null,status:"ready"});Ne(it.id),we(it.share_token||null),Se&&await f.mutateAsync({contactId:Se,videoId:it.id,notes:be}),r({title:"Video saved successfully!"}),_("share")}catch(Se){console.error("Save video error:",Se),r({title:"Failed to save video",description:(Se==null?void 0:Se.message)||"Please try again.",variant:"destructive"})}},De=(Se,it)=>{navigator.clipboard.writeText(it),Te(Se),setTimeout(()=>Te(null),2e3),r({title:"Copied to clipboard!"})},Rt=()=>Ge?`https://video.relevelup.com/${Ge}`:(Q==null?void 0:Q.playbackUrl)||"",me=()=>{const Se=u==null?void 0:u.find(Ze=>Ze.id===re),it=Se?`${Se.first_name}`:"",$e=(Se==null?void 0:Se.phone)||"",ct=(Se==null?void 0:Se.email)||"",qe=Rt();return{text:`Hey${it?` ${it}`:""}! I recorded a quick video for you: ${qe}`,link:qe,contactPhone:$e,contactEmail:ct}},Xe=()=>{const{text:Se,contactPhone:it}=me(),$e=it?`sms:${it}?body=${encodeURIComponent(Se)}`:`sms:?body=${encodeURIComponent(Se)}`;window.open($e,"_self")},ot=()=>{const{link:Se,contactEmail:it}=me(),$e="Check out this video",ct=`I recorded a quick video for you: ${Se}`,qe=it?`mailto:${it}?subject=${encodeURIComponent($e)}&body=${encodeURIComponent(ct)}`:`mailto:?subject=${encodeURIComponent($e)}&body=${encodeURIComponent(ct)}`;window.open(qe,"_self")};return o?e.jsx(Ts,{title:"Quick Video Touch",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t(-1),children:e.jsx(ti,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Quick Video Touch"}),e.jsx("p",{className:"text-muted-foreground",children:"Record a personal video message"})]})]}),d&&e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm text-warning",children:["Storage: ",i.toFixed(0),"% used"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[l.toFixed(0)," MB remaining"]})]})]}),y==="record"&&e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsx($ce,{maxDurationSeconds:60,onRecordingComplete:Ue,onRecordingStateChange:L,className:"w-full",teleprompterContent:j&&b&&e.jsx(zJe,{text:b,isVisible:j,onToggleVisibility:()=>k(!1),isRecording:I,startCountdown:!0})}),!j&&b&&e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>k(!0),children:[e.jsx(In,{className:"h-4 w-4 mr-2"}),"Show Teleprompter"]})]}),e.jsxs(Ee,{className:"lg:col-span-1",children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-lg",children:"Teleprompter Script"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Ar,{placeholder:"Type or paste your script here...",value:b,onChange:Se=>w(Se.target.value),rows:6}),e.jsxs(MM,{open:S,onOpenChange:T,children:[e.jsx(K_e,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full",children:[e.jsx(In,{className:"h-4 w-4 mr-2"}),"Browse Scripts"]})}),e.jsxs(cS,{side:"right",className:"w-[400px] sm:w-[540px] p-0",children:[e.jsx(TM,{className:"p-4 border-b",children:e.jsx(AM,{children:"Select a Script"})}),e.jsx(kfs,{onSelectScript:Se=>{w(Se.text),T(!1),k(!0)},className:"h-[calc(100vh-80px)]"})]})]}),b&&e.jsx(K,{className:"w-full",onClick:()=>k(!0),children:"Use Script"})]})]})]}),y==="uploading"&&e.jsx(Ee,{className:"max-w-md mx-auto",children:e.jsxs(Oe,{className:"pt-6 text-center",children:[e.jsx(Za,{className:"h-12 w-12 mx-auto mb-4 text-primary animate-pulse"}),e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Uploading Video..."}),e.jsx(Ti,{value:q,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[q.toFixed(0),"%"]})]})}),y==="processing"&&e.jsx(Ee,{className:"max-w-md mx-auto",children:e.jsxs(Oe,{className:"pt-6 text-center space-y-4",children:[e.jsx(Ms,{className:"h-12 w-12 mx-auto mb-4 text-primary animate-spin"}),e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Processing Video..."}),e.jsx(Ti,{value:H,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[H.toFixed(0),"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:`This usually takes 30-60 seconds. If it takes longer, we'll auto-save your video and you can find it in your Video Library — look for the "processing" badge.`})]})}),y==="details"&&e.jsxs(Ee,{className:"max-w-lg mx-auto",children:[e.jsx(It,{children:e.jsx(Ot,{children:"Video Details"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Title"}),e.jsx(Re,{value:le,onChange:Se=>he(Se.target.value),placeholder:"Quick Video Touch"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Attach to Contact (Optional)"}),e.jsxs(sr,{value:re,onValueChange:ae,children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"No contact - use anywhere"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"none",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Do,{className:"h-4 w-4"}),"No contact - use anywhere"]})}),u==null?void 0:u.map(Se=>e.jsx(At,{value:Se.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yi,{className:"h-4 w-4"}),Se.first_name," ",Se.last_name]})},Se.id))]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Notes"}),e.jsx(Ar,{value:be,onChange:Se=>_e(Se.target.value),placeholder:"Add notes about this video...",rows:3})]}),e.jsxs(K,{className:"w-full",onClick:ut,disabled:p.isPending,children:[p.isPending&&e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Video"]})]})]}),y==="share"&&e.jsxs(Ee,{className:"max-w-lg mx-auto",children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(ha,{className:"h-5 w-5 text-green-500"}),"Video Saved!"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Share your video with one click:"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs(K,{variant:"outline",className:"justify-start",onClick:Xe,children:[e.jsx(io,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:ot,children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>De("link",me().link),children:[e.jsx(Do,{className:"h-4 w-4 mr-2"}),"Copy Video Link",Me==="link"&&e.jsx(ha,{className:"h-4 w-4 ml-auto text-green-500"})]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>Ae(!0),children:[e.jsx(Bl,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/video-library"),children:"View Library"}),e.jsx(K,{onClick:()=>{_("record"),$(null),te(null),de(null)},children:"Record Another"})]})]})]}),je&&Ge&&e.jsx(BJe,{open:Fe,onOpenChange:Ae,video:{id:je,share_token:Ge,title:le||null,contact_id:re||null,thumbnail_url:(Q==null?void 0:Q.thumbnailUrl)||null},contactName:((nt=u==null?void 0:u.find(Se=>Se.id===re))==null?void 0:nt.first_name)||null})]})}):e.jsx(Ts,{title:"Quick Video Touch",children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center py-12",children:[e.jsx(Ju,{className:"h-16 w-16 text-destructive mx-auto mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Storage Limit Reached"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"You've reached your video storage limit. Delete videos from your library to record more."}),e.jsx(K,{onClick:()=>t("/mission-control/video-library"),children:"Open Video Library"})]})})}function Mfs({open:t,onOpenChange:s}){const{data:r}=tm(),{data:n}=Fce(),a=xS(),o=C.useRef(null),[l,i]=C.useState(null),[d,u]=C.useState(""),[p,f]=C.useState(""),[y,_]=C.useState(""),[b,w]=C.useState(!1),[j,k]=C.useState(0),[S,T]=C.useState("idle"),I=(n==null?void 0:n.total_storage_mb)||0,R=((n==null?void 0:n.max_storage_mb)||1024)-I,$=Y=>{var Q;const se=(Q=Y.target.files)==null?void 0:Q[0];if(!se)return;if(!se.type.startsWith("video/")){fe.error("Please select a video file");return}const te=se.size/(1024*1024);if(te>500){fe.error("Video file must be less than 500MB");return}if(te>R){fe.error(`Not enough storage. You have ${R.toFixed(1)} MB remaining.`);return}i(se),d||u(se.name.replace(/\.[^/.]+$/,""))},q=async()=>{if(!l){fe.error("Please select a video file");return}w(!0),k(0),T("creating");try{const{data:Y,error:se}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:d||l.name,isAgentVideo:!0}});if(se)throw new Error(se.message);const{videoId:te,libraryId:Q}=Y;T("uploading");const{data:de,error:re}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:te,isAgentVideo:!0}});if(re)throw new Error(re.message);await new Promise((he,be)=>{const _e=new XMLHttpRequest;_e.upload.addEventListener("progress",je=>{if(je.lengthComputable){const Ne=Math.round(je.loaded/je.total*100);k(Ne)}}),_e.addEventListener("load",()=>{_e.status>=200&&_e.status<300?he():be(new Error(`Upload failed with status ${_e.status}`))}),_e.addEventListener("error",()=>be(new Error("Upload failed"))),_e.open("PUT",de.uploadUrl),_e.setRequestHeader("AccessKey",de.apiKey),_e.send(l)}),T("processing");const ae=l.size/(1024*1024),le=`https://iframe.mediadelivery.net/embed/${Q}/${te}`;await a.mutateAsync({bunny_video_id:te,playback_url:le,file_size_mb:ae,title:d||l.name,notes:p||void 0,contact_id:y||void 0,status:"processing",touch_type:"video_upload"}),fe.success("Video uploaded successfully! Processing may take a few minutes."),U()}catch(Y){console.error("Upload error:",Y),fe.error(Y instanceof Error?Y.message:"Failed to upload video")}finally{w(!1),T("idle")}},U=()=>{b||(i(null),u(""),f(""),_(""),k(0),T("idle"),s(!1))},H=()=>{switch(S){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${j}%`;case"processing":return"Saving video...";default:return""}};return e.jsx(_s,{open:t,onOpenChange:U,children:e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Upload Video"}),e.jsx(Kr,{children:"Upload a video file from your device to your video library."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Video File"}),l?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(Nn,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:l.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(l.size/(1024*1024)).toFixed(1)," MB"]})]}),!b&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:Y=>{Y.stopPropagation(),i(null)},children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>{var Y;return(Y=o.current)==null?void 0:Y.click()},children:[e.jsx(Za,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select a video file"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"MP4, MOV, WebM (max 500MB)"})]}),e.jsx("input",{ref:o,type:"file",accept:"video/*",className:"hidden",onChange:$,disabled:b})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"title",children:"Title"}),e.jsx(Re,{id:"title",value:d,onChange:Y=>u(Y.target.value),placeholder:"Enter video title",disabled:b})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Associate with Contact (optional)"}),e.jsxs(sr,{value:y||"__none__",onValueChange:Y=>_(Y==="__none__"?"":Y),disabled:b,children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select a contact"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"__none__",children:"No contact"}),r==null?void 0:r.map(Y=>e.jsxs(At,{value:Y.id,children:[Y.first_name," ",Y.last_name||""]},Y.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"notes",children:"Notes (optional)"}),e.jsx(Ar,{id:"notes",value:p,onChange:Y=>f(Y.target.value),placeholder:"Add any notes about this video",rows:2,disabled:b})]}),b&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Ms,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:H()})]}),e.jsx(Ti,{value:S==="uploading"?j:S==="processing"?100:10})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:U,disabled:b,children:"Cancel"}),e.jsx(K,{onClick:q,disabled:!l||b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Za,{className:"h-4 w-4 mr-2"}),"Upload Video"]})})]})]})})}function Tfs(t){return wt({queryKey:["video-share-recipients",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("video_share_recipients").select("*").eq("video_id",t).order("sent_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Afs(){const{user:t}=Hs();return wt({queryKey:["video-share-stats",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:s,error:r}=await G.from("video_share_recipients").select("*").eq("owner_user_id",t.id);if(r)throw r;const n=s;return{totalSent:n.length,totalOpened:n.filter(a=>a.opened_at).length,totalClicked:n.filter(a=>a.clicked_at).length,totalWatched:n.filter(a=>a.watched_at).length,openRate:n.length>0?Math.round(n.filter(a=>a.opened_at).length/n.length*100):0,clickRate:n.length>0?Math.round(n.filter(a=>a.clicked_at).length/n.length*100):0,watchRate:n.length>0?Math.round(n.filter(a=>a.watched_at).length/n.length*100):0}},enabled:!!(t!=null&&t.id)})}function Efs(){const{user:t}=Hs();return wt({queryKey:["video-share-history",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await G.from("video_share_recipients").select(` *, agent_videos!inner(id, title, thumbnail_url, share_token, duration_seconds) `).eq("owner_user_id",t.id).order("sent_at",{ascending:!1}).limit(200);if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function Pfs(){const{user:t}=Hs(),s=rs();return Dt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await G.from("video_share_recipients").insert([{video_id:r.video_id,owner_user_id:t.id,recipient_email:r.recipient_email,recipient_name:r.recipient_name||null,contact_id:r.contact_id||null,sent_via:r.sent_via||"gmail",share_token:"placeholder"}]).select().single();if(a)throw a;return n},onSuccess:r=>{s.invalidateQueries({queryKey:["video-share-recipients",r.video_id]}),s.invalidateQueries({queryKey:["video-share-stats"]}),s.invalidateQueries({queryKey:["video-share-history"]})}})}function Ifs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=open`}function Lfs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=click`}function Dfs({open:t,onOpenChange:s,video:r,gmailEmail:n,signedThumbnailUrl:a,onSendComplete:o}){const[l,i]=C.useState([]),[d,u]=C.useState(null),[p,f]=C.useState(!1),[y,_]=C.useState(!1),[b,w]=C.useState(""),[j,k]=C.useState(""),[S,T]=C.useState(""),[I,L]=C.useState(!1),R=Pfs(),$=r.share_token?`https://video.relevelup.com/share/video/${r.share_token}`:"",q=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:a||r.thumbnail_url||"",U=r.title||"Video Message";C.useEffect(()=>{t&&l.length===0&&H()},[t]),C.useEffect(()=>{if(t&&(k(`I recorded a video for you — ${U}`),T("Hey! I recorded a quick video just for you. Click below to watch it:"),u(null),w(""),r.contact_id)){const re=l.find(ae=>ae.id===r.contact_id);re&&(u(re),w(re.email||""))}},[t,r.contact_id,l]);const H=async()=>{_(!0);try{const{data:re,error:ae}=await G.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(ae)throw ae;i(re||[])}catch{console.error("Failed to fetch contacts")}finally{_(!1)}},Y=re=>{u(re),f(!1),w(re.email||""),T(`Hey ${re.first_name}! I recorded a quick video just for you. Click below to watch it:`),k(`I recorded a video for you — ${U}`)},se=()=>{u(null),w(""),T("Hey! I recorded a quick video just for you. Click below to watch it:")},te=re=>`${re.first_name} ${re.last_name||""}`.trim(),Q=re=>{const ae=S.split(/\n\n+/).map(be=>`

${be.replace(/\n/g,"
")}

`).join(""),le=re?Lfs(re):$,he=re?``:"";return`
${ae}

▶ Watch Video

${he}
`},de=async()=>{if(!b){fe.error("Please enter a recipient email");return}if(!$){fe.error("Video does not have a share link");return}L(!0);try{let re;try{const be=d?te(d):b.split("@")[0];re=(await R.mutateAsync({video_id:r.id,recipient_email:b,recipient_name:be,contact_id:(d==null?void 0:d.id)||null,sent_via:"gmail"})).share_token}catch(be){console.warn("Failed to create tracking record, sending without tracking:",be)}const ae=Q(re),{data:le,error:he}=await G.functions.invoke("gmail-send",{body:{to:b,subject:j,body:ae,contactId:(d==null?void 0:d.id)||null}});if(he)throw he;if(!(le!=null&&le.success))throw new Error((le==null?void 0:le.error)||"Failed to send");fe.success("Video email sent!"),s(!1),o==null||o()}catch(re){console.error("Gmail send error:",re),fe.error("Failed to send: "+(re instanceof Error?re.message:"Unknown error"))}finally{L(!1)}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-[560px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5 text-red-500"}),"Send Video via Gmail"]}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sending from ",e.jsx("span",{className:"font-medium",children:n})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Send to Contact"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Co,{open:p,onOpenChange:f,children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"flex-1 justify-between",children:[d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Yi,{className:"h-4 w-4 text-muted-foreground"}),te(d),d.email&&e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",d.email,")"]})]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(xf,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(No,{className:"w-[350px] p-0",align:"start",children:e.jsxs(Mf,{children:[e.jsx(Tf,{placeholder:"Search contacts..."}),e.jsxs(Af,{children:[e.jsx(Ef,{children:y?"Loading...":"No contacts found."}),e.jsx(Pf,{children:l.filter(re=>re.email).map(re=>e.jsxs(Cm,{value:`${re.first_name} ${re.last_name||""} ${re.email||""}`,onSelect:()=>Y(re),children:[e.jsx(ha,{className:Pt("mr-2 h-4 w-4",(d==null?void 0:d.id)===re.id?"opacity-100":"opacity-0")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:te(re)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:re.email})]})]},re.id))})]})]})})]}),d&&e.jsx(K,{variant:"ghost",size:"icon",onClick:se,className:"shrink-0",children:e.jsx(Ur,{className:"h-4 w-4"})})]})]}),!d&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"video-to",children:"Or type email address"}),e.jsx(Re,{id:"video-to",value:b,onChange:re=>w(re.target.value),placeholder:"recipient@example.com",type:"email"})]}),e.jsx(Rl,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"video-subject",children:"Subject"}),e.jsx(Re,{id:"video-subject",value:j,onChange:re=>k(re.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"video-message",children:"Personal Message"}),e.jsx(Ar,{id:"video-message",value:S,onChange:re=>T(re.target.value),rows:4,className:"resize-y"})]}),e.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3 space-y-2",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Video Preview (embedded in email)"}),e.jsxs("div",{className:"relative rounded-lg overflow-hidden bg-black",style:{maxWidth:320},children:[q?e.jsx("img",{src:q,alt:U,className:"w-full aspect-video object-cover"}):e.jsx("div",{className:"w-full aspect-video flex items-center justify-center bg-muted",children:e.jsx(ul,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-10 h-10 rounded-full bg-white/80 flex items-center justify-center shadow",children:e.jsx(ul,{className:"h-5 w-5 text-primary ml-0.5"})})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Recipients will see the thumbnail with a play button. Clicking opens the video page."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),disabled:I,children:"Cancel"}),e.jsxs(K,{onClick:de,disabled:I||!b||!j,className:"gap-2",children:[I?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):e.jsx(aa,{className:"h-4 w-4"}),I?"Sending...":"Send Video Email"]})]})]})]})})}const Ofs=()=>{const{user:t}=Hs();return wt({queryKey:["team-videos",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.rpc("get_team_videos",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})};function Rfs({recipient:t}){return t.watched_at?e.jsxs(rt,{className:"bg-emerald-100 text-emerald-800 text-[10px]",children:[e.jsx(ul,{className:"h-2.5 w-2.5 mr-0.5"}),"Watched"]}):t.clicked_at?e.jsxs(rt,{className:"bg-blue-100 text-blue-800 text-[10px]",children:[e.jsx(th,{className:"h-2.5 w-2.5 mr-0.5"}),"Clicked"]}):t.opened_at?e.jsxs(rt,{className:"bg-amber-100 text-amber-800 text-[10px]",children:[e.jsx(xa,{className:"h-2.5 w-2.5 mr-0.5"}),"Opened"]}):e.jsxs(rt,{variant:"outline",className:"text-[10px]",children:[e.jsx(aa,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]})}function Ffs({open:t,onOpenChange:s,videoId:r,videoTitle:n}){const{data:a=[],isLoading:o}=Tfs(r);return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-2xl max-h-[80vh]",children:[e.jsx(Ss,{children:e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(ol,{className:"h-5 w-5"}),"Send Analytics: ",n]})}),o?e.jsx("div",{className:"space-y-2",children:[...Array(3)].map((l,i)=>e.jsx(xs,{className:"h-12 w-full"},i))}):a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No recipients tracked for this video yet."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs("div",{className:"text-center p-2 rounded-lg bg-muted/50",children:[e.jsx("div",{className:"text-lg font-bold",children:a.length}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Sent"})]}),e.jsxs("div",{className:"text-center p-2 rounded-lg bg-amber-50",children:[e.jsx("div",{className:"text-lg font-bold text-amber-700",children:a.filter(l=>l.opened_at).length}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Opened"})]}),e.jsxs("div",{className:"text-center p-2 rounded-lg bg-blue-50",children:[e.jsx("div",{className:"text-lg font-bold text-blue-700",children:a.filter(l=>l.clicked_at).length}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Clicked"})]})]}),e.jsx(Ri,{className:"h-[400px]",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Recipient"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{children:"Sent"}),e.jsx(bt,{children:"Last Activity"})]})}),e.jsx(Pn,{children:a.map(l=>e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:l.recipient_name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.recipient_email})]})}),e.jsx(lt,{children:e.jsx(Rfs,{recipient:l})}),e.jsx(lt,{className:"text-xs text-muted-foreground",children:ys(new Date(l.sent_at),"MMM d, h:mm a")}),e.jsx(lt,{className:"text-xs text-muted-foreground",children:l.last_activity_at?Sd(new Date(l.last_activity_at),{addSuffix:!0}):"—"})]},l.id))})]})})]})]})})}function zfs(){const{data:t,isLoading:s}=Afs(),{data:r=[],isLoading:n}=Efs(),[a,o]=C.useState(null),l=s||n,i=r.reduce((d,u)=>{const p=u.agent_videos,f=(p==null?void 0:p.id)||u.video_id;return d[f]||(d[f]={videoId:f,title:(p==null?void 0:p.title)||"Untitled",thumbnailUrl:p==null?void 0:p.thumbnail_url,recipients:[]}),d[f].recipients.push(u),d},{});return l?e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[...Array(4)].map((d,u)=>e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(xs,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(xs,{className:"h-8 w-16"})})]},u))})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-3",children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Sent"}),e.jsx(aa,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(t==null?void 0:t.totalSent)||0})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Open Rate"}),e.jsx(xa,{className:"h-4 w-4 text-amber-500"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t==null?void 0:t.openRate)||0,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(t==null?void 0:t.totalOpened)||0," opened"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(th,{className:"h-4 w-4 text-blue-500"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t==null?void 0:t.clickRate)||0,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(t==null?void 0:t.totalClicked)||0," clicked"]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Send History by Video"}),e.jsx(pr,{children:"Click a video to see individual recipient tracking"})]}),e.jsx(Oe,{children:Object.keys(i).length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No tracked sends yet. Send a video via Gmail to start tracking."}):e.jsx("div",{className:"space-y-2",children:Object.values(i).map(d=>{const u=d.recipients.filter(f=>f.opened_at).length,p=d.recipients.filter(f=>f.clicked_at).length;return e.jsxs("button",{onClick:()=>o({id:d.videoId,title:d.title}),className:"w-full flex items-center gap-3 p-3 rounded-lg border hover:bg-muted/50 transition-colors text-left",children:[e.jsx("div",{className:"h-10 w-16 rounded bg-muted overflow-hidden flex-shrink-0",children:d.thumbnailUrl?e.jsx("img",{src:d.thumbnailUrl,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer",onError:f=>{const y=f.currentTarget;y.style.display="none",y.parentElement.innerHTML='
'}}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(Nn,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:d.title}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(aa,{className:"h-3 w-3"})," ",d.recipients.length]}),e.jsxs("span",{className:"text-xs text-amber-600 flex items-center gap-1",children:[e.jsx(xa,{className:"h-3 w-3"})," ",u]}),e.jsxs("span",{className:"text-xs text-blue-600 flex items-center gap-1",children:[e.jsx(th,{className:"h-3 w-3"})," ",p]})]})]}),e.jsx(ac,{className:"h-4 w-4 text-muted-foreground"})]},d.videoId)})})})]}),e.jsx(Ffs,{open:!!a,onOpenChange:d=>!d&&o(null),videoId:(a==null?void 0:a.id)||null,videoTitle:(a==null?void 0:a.title)||""})]})}function Bfs({previewSrc:t,thumbnailSrc:s,alt:r,isHovered:n}){const[a,o]=C.useState(!1),[l,i]=C.useState(!1),d=n&&t&&!a,u=s&&!l;return!u&&!d?e.jsx("div",{className:"w-full h-full flex items-center justify-center absolute inset-0 bg-muted",children:e.jsx(Nn,{className:"h-12 w-12 text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[u&&e.jsx("img",{src:s,alt:r,loading:"lazy",className:`w-full h-full object-cover absolute inset-0 transition-opacity duration-200 ${d?"opacity-0":"opacity-100"}`,onError:()=>i(!0)}),d&&e.jsx("img",{src:t,alt:r,className:"w-full h-full object-cover absolute inset-0",onError:()=>o(!0)})]})}function $fs({video:t,previewSrc:s,thumbnailSrc:r,onOpen:n,onDelete:a,onRename:o,onNavigateToContact:l,onGetEmbedCode:i,onCopyEmailHtml:d,onEmbedToCrm:u,onShareWithTemplate:p,onSendViaGmail:f,isGmailConnected:y,getContactName:_,getShareUrl:b,copyToClipboard:w,formatDuration:j}){const[k,S]=C.useState(!1);return e.jsxs(Ee,{className:"overflow-hidden group cursor-pointer",onClick:n,onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),children:[e.jsxs("div",{className:"relative aspect-video bg-muted overflow-hidden",children:[e.jsx(Bfs,{previewSrc:s,thumbnailSrc:r,alt:t.title||"Video preview",isHovered:k}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx("div",{className:"w-12 h-12 rounded-full bg-white/90 flex items-center justify-center",children:e.jsx(ul,{className:"h-6 w-6 text-primary ml-1"})})}),e.jsx("div",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:j(t.duration_seconds)}),t.status!=="ready"&&e.jsx(rt,{variant:t.status==="processing"?"secondary":"destructive",className:"absolute top-2 left-2",children:t.status})]}),e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"font-medium truncate",children:t.title||"Untitled Video"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsx(Yi,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:_(t.contact_id)})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),e.jsx("span",{children:ys(new Date(t.created_at),"MMM d, yyyy")})]}),(t.view_count??0)>0&&e.jsxs("div",{className:"flex items-center gap-1 text-primary",children:[e.jsx(xa,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]}),y&&t.share_token&&e.jsxs(K,{variant:"outline",size:"sm",className:"mt-2 gap-1.5 text-xs h-7",onClick:T=>{T.stopPropagation(),f==null||f()},children:[e.jsx(br,{className:"h-3 w-3"}),"Send via Gmail"]}),e.jsx("h3",{className:"font-medium truncate",children:t.title||"Untitled Video"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsx(Yi,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:_(t.contact_id)})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),e.jsx("span",{children:ys(new Date(t.created_at),"MMM d, yyyy")})]}),(t.view_count??0)>0&&e.jsxs("div",{className:"flex items-center gap-1 text-primary",children:[e.jsx(xa,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]})]}),e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:T=>T.stopPropagation(),children:e.jsx(af,{className:"h-4 w-4"})})}),e.jsxs(Md,{align:"end",className:"bg-popover",children:[e.jsxs(Na,{onClick:T=>{T.stopPropagation(),n()},children:[e.jsx(xa,{className:"h-4 w-4 mr-2"}),"Watch"]}),e.jsx(E_,{}),e.jsxs(Na,{onClick:T=>{T.stopPropagation(),p()},children:[e.jsx(Bl,{className:"h-4 w-4 mr-2"}),"Share with Template"]}),e.jsxs(Na,{onClick:T=>{T.stopPropagation(),w(b(t),"Share link")},children:[e.jsx(Do,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(Na,{onClick:T=>{T.stopPropagation(),i()},children:[e.jsx(ak,{className:"h-4 w-4 mr-2"}),"Get Embed Code"]}),e.jsxs(Na,{onClick:T=>{T.stopPropagation(),d()},children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(Na,{onClick:T=>{T.stopPropagation(),u()},children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),y&&t.share_token&&e.jsxs(Na,{onClick:T=>{T.stopPropagation(),f==null||f()},children:[e.jsx(aa,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]}),e.jsxs(Na,{onClick:T=>{T.stopPropagation(),o()},children:[e.jsx(Da,{className:"h-4 w-4 mr-2"}),"Rename"]}),e.jsx(E_,{}),t.contact_id&&e.jsxs(Na,{onClick:T=>{T.stopPropagation(),l()},children:[e.jsx(Yi,{className:"h-4 w-4 mr-2"}),"View Contact"]}),e.jsxs(Na,{onClick:T=>{T.stopPropagation(),a()},className:"text-destructive",children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]})}function qfs(){var et,Tt;const t=Pr(),{data:s,isLoading:r,refetch:n}=cps(),{data:a}=Fce(),{data:o}=tm(),l=hps(),i=ups(),{isGmailConnected:d,gmailEmail:u}=Ny(),{data:p}=Lf(),{data:f=[],isLoading:y}=Ofs(),[_,b]=C.useState("my"),[w,j]=C.useState(""),[k,S]=C.useState(null),[T,I]=C.useState(!1),[L,R]=C.useState(!1),[$,q]=C.useState(!1),[U,H]=C.useState(!1),[Y,se]=C.useState(!1),[te,Q]=C.useState(""),[de,re]=C.useState(!1),[ae,le]=C.useState(!1),[he,be]=C.useState(!1),[_e,je]=C.useState(!1),[Ne,Ge]=C.useState(""),[we,Me]=C.useState({}),Te=Ft=>{if(!Ft)return"Unassigned";const as=o==null?void 0:o.find(Xt=>Xt.id===Ft);return as?`${as.first_name} ${as.last_name||""}`.trim():"Unknown"},Fe=Ft=>{if(!Ft)return"0:00";const as=Math.floor(Ft/60),Xt=Ft%60;return`${as}:${Xt.toString().padStart(2,"0")}`},Ae=s==null?void 0:s.filter(Ft=>{if(!w)return!0;const as=Te(Ft.contact_id).toLowerCase(),Xt=(Ft.title||"").toLowerCase(),ss=(Ft.notes||"").toLowerCase();return as.includes(w.toLowerCase())||Xt.includes(w.toLowerCase())||ss.includes(w.toLowerCase())}),[Ue,ut]=C.useState(!1);C.useEffect(()=>{if(Ue)return;(async()=>{if(!(s!=null&&s.length))return;const as=s.filter(ss=>ss.status==="processing"&&ss.bunny_video_id);if(!as.length)return;let Xt=!1;for(const ss of as)try{const{data:is,error:ar}=await G.functions.invoke("bunny-upload",{body:{action:"status",videoId:ss.bunny_video_id,isAgentVideo:!0}});if(ar||!is)continue;is.status===4&&(await G.from("agent_videos").update({status:"ready",playback_url:is.directPlayUrl,thumbnail_url:is.thumbnailUrl,preview_url:is.previewUrl,duration_seconds:is.length||ss.duration_seconds,updated_at:new Date().toISOString()}).eq("id",ss.id),Xt=!0)}catch(is){console.warn("Reconcile check failed for video",ss.id,is)}ut(!0),Xt&&n()})()},[s,Ue,n]),C.useEffect(()=>{(async()=>{if(!(s!=null&&s.length))return;const as=s.filter(Ct=>(Ct==null?void 0:Ct.bunny_video_id)&&!we[Ct.id]);if(!as.length)return;const Xt=as.map(Ct=>Ct.bunny_video_id),{data:ss,error:is}=await G.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Xt,isAgentVideo:!0}});if(is)throw is;const ar=(ss==null?void 0:ss.assets)||{};Me(Ct=>{const Is={...Ct};for(const qs of as)ar[qs.bunny_video_id]&&(Is[qs.id]={previewUrl:ar[qs.bunny_video_id].previewUrl,thumbnailUrl:ar[qs.bunny_video_id].thumbnailUrl});return Is})})().catch(as=>console.warn("Failed to load signed Bunny asset URLs",as))},[s,we]);const De=(a==null?void 0:a.total_storage_mb)||0,Rt=(a==null?void 0:a.max_storage_mb)||1024,me=De/Rt*100,Xe=me>=80,ot=me>=100,nt=async(Ft,as)=>{await navigator.clipboard.writeText(Ft),fe.success(`${as} copied to clipboard`)},Se=Ft=>Ft.share_token?`https://video.relevelup.com/${Ft.share_token}`:Ft.playback_url||"",it=Ft=>{const as=Se(Ft),Xt=o==null?void 0:o.find(qs=>qs.id===Ft.contact_id),ss=Te(Ft.contact_id),is=ss!=="Unassigned"?ss.split(" ")[0]:"",ar=(Xt==null?void 0:Xt.phone)||"",Ct=`Hey${is?` ${is}`:""}! I recorded a quick video message for you. Check it out: ${as}`,Is=ar?`sms:${ar}?body=${encodeURIComponent(Ct)}`:`sms:?body=${encodeURIComponent(Ct)}`;window.open(Is,"_self")},$e=Ft=>{const as=o==null?void 0:o.find(Is=>Is.id===Ft.contact_id),Xt=(as==null?void 0:as.email)||"",ss=Se(Ft),is="Check out this video",ar=`I recorded a quick video for you: ${ss}`,Ct=Xt?`mailto:${Xt}?subject=${encodeURIComponent(is)}&body=${encodeURIComponent(ar)}`:`mailto:?subject=${encodeURIComponent(is)}&body=${encodeURIComponent(ar)}`;window.open(Ct,"_self")},ct=Ft=>{var is;const as=Se(Ft),Xt=Ft.title||"Video Message",ss=Ft.share_token?`https://video.relevelup.com/thumb/${Ft.share_token}`:((is=we[Ft.id])==null?void 0:is.thumbnailUrl)||Ft.thumbnail_url||"";return``},qe=async Ft=>{if(!Ft.thumbnail_url&&!Ft.share_token){fe.error("Video thumbnail not available yet");return}const as=ct(Ft),Xt=Se(Ft),ss=`Watch: ${Ft.title||"Video Message"} ${Xt}`;try{const is=new Blob([as],{type:"text/html"}),ar=new Blob([ss],{type:"text/plain"}),Ct=new ClipboardItem({"text/html":is,"text/plain":ar});await navigator.clipboard.write([Ct]),fe.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(ss+` `+as),fe.success("Copied! Paste into your email.")}},Ze=async Ft=>{try{fe.loading("Preparing download...",{id:"download"});const{data:as,error:Xt}=await G.functions.invoke("bunny-upload",{body:{action:"download-url",videoId:Ft.bunny_video_id,isAgentVideo:!0}});if(Xt||!(as!=null&&as.downloadUrl))throw new Error((Xt==null?void 0:Xt.message)||"Failed to get download URL");const is=`${((Ft.title||"video").toString().trim()||"video").replace(/[\\/:*?"<>|]+/g,"-")}.mp4`,ar=await fetch(as.downloadUrl);if(!ar.ok)throw new Error("Failed to fetch video file");const Ct=await ar.blob(),Is=URL.createObjectURL(Ct),qs=document.createElement("a");qs.href=Is,qs.download=is,qs.rel="noreferrer",document.body.appendChild(qs),qs.click(),qs.remove(),URL.revokeObjectURL(Is),fe.success("Download started",{id:"download"})}catch(as){console.error("Download error:",as),fe.error("Could not force download (your browser may block it).",{id:"download"})}},Qe=async Ft=>{S(Ft),re(!0),Q(""),se(!0);try{const{data:as,error:Xt}=await G.functions.invoke("bunny-upload",{body:{action:"crm-embed",videoId:Ft.bunny_video_id,title:Ft.title,isAgentVideo:!0,shareToken:Ft.share_token}});if(Xt||!(as!=null&&as.html))throw new Error("Failed to generate CRM embed code");Q(as.html)}catch(as){console.error("CRM embed error:",as),fe.error("Failed to generate CRM embed code"),se(!1)}finally{re(!1)}},We=Ft=>{S(Ft),I(!0)},He=async()=>{if(k)try{await l.mutateAsync({id:k.id,bunnyVideoId:k.bunny_video_id,hardDelete:!0}),R(!1),S(null),fe.success("Video deleted successfully")}catch{fe.error("Failed to delete video")}};return e.jsx(Ts,{title:"Video Library",description:"Manage your video touches",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Video Library"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage and share your video touches"})]}),e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5 ml-2",children:[e.jsx("button",{onClick:()=>b("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${_==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Videos"}),p&&((et=p.team)==null?void 0:et.shared_videos_enabled)&&e.jsxs("button",{onClick:()=>b("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${_==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(hr,{className:"h-3.5 w-3.5"}),"Team"]}),e.jsxs("button",{onClick:()=>b("analytics"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${_==="analytics"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(ol,{className:"h-3.5 w-3.5"}),"Analytics"]})]})]}),_==="my"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>q(!0),children:[e.jsx(Za,{className:"h-4 w-4 mr-2"}),"Upload Video"]}),e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Record New Video"]})]})]}),_==="team"?e.jsx(Ufs,{videos:f,isLoading:y,searchTerm:w,setSearchTerm:j}):_==="analytics"?e.jsx(zfs,{}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:Xe?"border-amber-500":ot?"border-destructive":"",children:e.jsxs(Oe,{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(gP,{className:`h-5 w-5 ${ot?"text-destructive":Xe?"text-amber-500":"text-muted-foreground"}`}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-sm font-medium",children:"Storage Used"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[De.toFixed(1)," MB / ",Rt>=1024?`${(Rt/1024).toFixed(0)} GB`:`${Rt} MB`]})]}),e.jsx(Ti,{value:Math.min(me,100),className:`h-2 ${ot?"[&>div]:bg-destructive":Xe?"[&>div]:bg-amber-500":""}`})]}),Xe&&!ot&&e.jsxs(rt,{variant:"outline",className:"border-amber-500 text-amber-600",children:[e.jsx(ll,{className:"h-3 w-3 mr-1"}),"Near Limit"]}),ot&&e.jsxs(rt,{variant:"destructive",children:[e.jsx(ll,{className:"h-3 w-3 mr-1"}),"At Limit"]})]}),ot&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:"You've reached your storage limit. Delete videos to record more."})]})}),e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search videos by contact, title, or notes...",value:w,onChange:Ft=>j(Ft.target.value),className:"pl-10"})]}),r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})}):(Ae==null?void 0:Ae.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Nn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No videos yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Record your first video touch to get started"}),e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Record Video"]})]})}):e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:Ae==null?void 0:Ae.map(Ft=>{var as,Xt;return e.jsx($fs,{video:Ft,previewSrc:(as=we[Ft.id])==null?void 0:as.previewUrl,thumbnailSrc:(Xt=we[Ft.id])==null?void 0:Xt.thumbnailUrl,onOpen:()=>We(Ft),onDelete:()=>{S(Ft),R(!0)},onRename:()=>{S(Ft),Ge(Ft.title||""),je(!0)},onNavigateToContact:()=>t(`/mission-control/contacts/${Ft.contact_id}`),onGetEmbedCode:()=>{S(Ft),H(!0)},onCopyEmailHtml:()=>qe(Ft),onEmbedToCrm:()=>Qe(Ft),onShareWithTemplate:()=>{S(Ft),le(!0)},onSendViaGmail:()=>{S(Ft),be(!0)},isGmailConnected:d,getContactName:Te,getShareUrl:Se,copyToClipboard:nt,formatDuration:Fe},Ft.id)})}),e.jsx(_s,{open:T,onOpenChange:I,children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:(k==null?void 0:k.title)||"Video Preview"}),e.jsx(Kr,{children:(k==null?void 0:k.contact_id)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Yi,{className:"h-3 w-3"}),Te(k.contact_id)]})})]}),k&&e.jsxs("div",{className:"space-y-4",children:[k.status==="processing"?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-6 bg-muted/50 rounded-lg border border-dashed border-border text-center space-y-4",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(Ms,{className:"h-8 w-8 text-primary animate-spin"})})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Video is still processing"}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:"Your video is being encoded and will be ready shortly. This usually takes 1–3 minutes. Check back soon!"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{I(!1),n()},children:[e.jsx(Po,{className:"h-4 w-4 mr-2"}),"Refresh Library"]})]}):e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:k.playback_url?(()=>{let Ft=k.playback_url;return Ft.includes("iframe.mediadelivery.net/play/")&&(Ft=Ft.replace("/play/","/embed/"),Ft+=(Ft.includes("?")?"&":"?")+"autoplay=false&responsive=true"),Ft.includes("iframe.mediadelivery.net")?e.jsx("iframe",{src:Ft,title:k.title||"Video preview",className:"absolute top-0 left-0 w-full h-full rounded-lg",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsx("video",{src:k.playback_url,controls:!0,playsInline:!0,preload:"metadata",poster:k.thumbnail_url||void 0,className:"absolute top-0 left-0 w-full h-full rounded-lg object-cover",onError:()=>fe.error("Video preview failed to load")},k.playback_url)})():e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-muted rounded-lg",children:[e.jsx(Nn,{className:"h-12 w-12 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground ml-2",children:"Video not available"})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>it(k),children:[e.jsx(io,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),!d&&e.jsxs(K,{variant:"outline",onClick:()=>$e(k),children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>nt(Se(k),"Share link"),children:[e.jsx(ai,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(K,{variant:"outline",onClick:()=>qe(k),children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(K,{variant:"outline",onClick:()=>Ze(k),children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Download Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),Qe(k)},children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),le(!0)},children:[e.jsx(Bl,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]}),d&&(k==null?void 0:k.share_token)&&e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),be(!0)},children:[e.jsx(aa,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]})]}),e.jsx("div",{className:"flex justify-end pt-2 border-t",children:e.jsxs(K,{variant:"destructive",onClick:()=>{I(!1),R(!0)},children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),"Delete Video"]})})]})]})}),e.jsx(_s,{open:L,onOpenChange:R,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Delete Video"}),e.jsx(Kr,{children:"Are you sure you want to delete this video? This action cannot be undone."})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:He,disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(Mfs,{open:$,onOpenChange:q}),e.jsx(_s,{open:U,onOpenChange:H,children:e.jsxs(vs,{className:"sm:max-w-lg",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Embed Video"}),e.jsx(Kr,{children:"Copy this code to embed the video on your website."})]}),k&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Embed Code"}),e.jsx(Ar,{readOnly:!0,rows:5,value:``,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(K,{className:"flex-1",onClick:()=>{const Ft=``;nt(Ft,"Embed code")},children:[e.jsx(ai,{className:"h-4 w-4 mr-2"}),"Copy Embed Code"]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paste this code into your website's HTML where you want the video to appear. The video will automatically resize to fit its container."})]})]})}),k&&e.jsx(BJe,{open:ae,onOpenChange:le,video:k,contactName:Te(k.contact_id)}),k&&e.jsx(Dfs,{open:he,onOpenChange:be,video:k,gmailEmail:u,signedThumbnailUrl:(Tt=we[k.id])==null?void 0:Tt.thumbnailUrl}),e.jsx(_s,{open:_e,onOpenChange:je,children:e.jsxs(vs,{className:"max-w-sm",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Rename Video"}),e.jsx(Kr,{children:"Enter a new title for this video."})]}),e.jsx(Re,{value:Ne,onChange:Ft=>Ge(Ft.target.value),placeholder:"Video title",autoFocus:!0,onKeyDown:Ft=>{Ft.key==="Enter"&&Ne.trim()&&i.mutate({id:k.id,title:Ne.trim()},{onSuccess:()=>{fe.success("Video renamed"),je(!1)}})}}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>je(!1),children:"Cancel"}),e.jsx(K,{disabled:!Ne.trim()||i.isPending,onClick:()=>{i.mutate({id:k.id,title:Ne.trim()},{onSuccess:()=>{fe.success("Video renamed"),je(!1)}})},children:i.isPending?"Saving...":"Save"})]})]})}),e.jsx(_s,{open:Y,onOpenChange:se,children:e.jsxs(vs,{className:"sm:max-w-lg",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(sn,{className:"h-5 w-5"}),"Embed to CRM"]}),e.jsx(Kr,{children:"Copy this HTML code and paste it into your CRM's email editor. It uses a simple image + link format that works in all CRM email programs."})]}),de?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Ms,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):te?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"CRM Email HTML"}),e.jsx(Ar,{readOnly:!0,rows:12,value:te,className:"font-mono text-xs"})]}),e.jsxs(K,{className:"w-full",onClick:()=>{nt(te,"CRM embed code")},children:[e.jsx(ai,{className:"h-4 w-4 mr-2"}),"Copy CRM Embed Code"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paste this into your CRM's email HTML editor. The recipient will see the video thumbnail and can click to watch. Works with Follow Up Boss, KvCORE, BoomTown, Sierra, and more."})]}):null]})})]})]})})}function Ufs({videos:t,isLoading:s,searchTerm:r,setSearchTerm:n}){const a=C.useMemo(()=>{if(!r)return t;const i=r.toLowerCase();return t.filter(d=>(d.title||"").toLowerCase().includes(i)||(d.owner_name||"").toLowerCase().includes(i)||(d.recipient_name||"").toLowerCase().includes(i))},[t,r]),o=C.useMemo(()=>{const i=new Map;return a.forEach(d=>{const u=i.get(d.owner_user_id);u?u.videos.push(d):i.set(d.owner_user_id,{name:d.owner_name,avatar:d.owner_avatar_url,videos:[d]})}),Array.from(i.entries())},[a]),l=i=>{if(!i)return"0:00";const d=Math.floor(i/60),u=i%60;return`${d}:${u.toString().padStart(2,"0")}`};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search team videos by title, owner, or recipient...",value:r,onChange:i=>n(i.target.value),className:"pl-10"})]}),s?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})}):a.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No team videos"}),e.jsx("p",{className:"text-muted-foreground",children:t.length===0?"Your teammates haven't recorded any videos yet.":"No videos match your search."})]})}):e.jsx("div",{className:"space-y-6",children:o.map(([i,d])=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(xn,{className:"h-7 w-7",children:[e.jsx(Aa,{src:d.avatar||""}),e.jsx(yn,{children:(d.name||"?").charAt(0).toUpperCase()})]}),e.jsx("h3",{className:"font-semibold text-sm",children:d.name}),e.jsx(rt,{variant:"secondary",className:"text-xs",children:d.videos.length})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:d.videos.map(u=>e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsxs("div",{className:"relative aspect-video bg-muted flex items-center justify-center",children:[u.thumbnail_url?e.jsx("img",{src:u.thumbnail_url,alt:u.title||"Video",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:p=>{p.target.style.display="none"}}):e.jsx(Nn,{className:"h-10 w-10 text-muted-foreground"}),u.duration_seconds&&e.jsx("span",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:l(u.duration_seconds)})]}),e.jsxs(Oe,{className:"p-3",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:u.title||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[u.recipient_name&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Yi,{className:"h-3 w-3"}),u.recipient_name]}),u.view_count!=null&&u.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xa,{className:"h-3 w-3"}),u.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),ys(new Date(u.created_at),"MMM d")]})]})]})]},u.id))})]},i))})]})}const Vfs=()=>{const{user:t}=Hs();return wt({queryKey:["team-deals",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.rpc("get_team_deals",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},qLe=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function Hfs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Vfs(),[a,o]=C.useState(""),[l,i]=C.useState("all"),d=C.useMemo(()=>{if(!r)return new Map;const b=new Map;let w=0;return r.forEach(j=>{b.has(j.owner_user_id)||(b.set(j.owner_user_id,{name:j.owner_name||"Unknown",avatar:j.owner_avatar_url,color:qLe[w%qLe.length]}),w++)}),b},[r]),u=C.useMemo(()=>Array.from(d.entries()).map(([b,w])=>({id:b,...w})),[d]),p=C.useMemo(()=>{if(!r)return[];let b=r;if(l!=="all"&&(b=b.filter(w=>w.owner_user_id===l)),a.trim()){const w=a.toLowerCase();b=b.filter(j=>{var k,S,T,I;return j.deal_name.toLowerCase().includes(w)||((k=j.contact_name)==null?void 0:k.toLowerCase().includes(w))||((S=j.property_address)==null?void 0:S.toLowerCase().includes(w))||((T=j.city)==null?void 0:T.toLowerCase().includes(w))||((I=j.owner_name)==null?void 0:I.toLowerCase().includes(w))})}return b},[r,a,l]),f=C.useMemo(()=>{const b=new Map;return p.forEach(w=>{const j=w.stage_name||"Unknown";b.has(j)||b.set(j,{name:j,color:w.stage_color,icon:w.stage_icon,deals:[],totalValue:0});const k=b.get(j);k.deals.push(w),k.totalValue+=w.sale_price||0}),Array.from(b.values())},[p]),y=b=>b>=1e6?`$${(b/1e6).toFixed(1)}M`:b>=1e3?`$${(b/1e3).toFixed(0)}K`:`$${b.toFixed(0)}`,_=b=>b?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(b):null;return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-[95vw] w-full max-h-[90vh] flex flex-col",children:[e.jsx(Ss,{children:e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Team Pipeline"]})}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("div",{className:"relative flex-1 max-w-xs",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search deals...",value:a,onChange:b=>o(b.target.value),className:"pl-9"})]}),e.jsxs(sr,{value:l,onValueChange:i,children:[e.jsx(er,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"All Members"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Members"}),u.map(b=>e.jsx(At,{value:b.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full inline-block",style:{backgroundColor:b.color}}),b.name]})},b.id))]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-3 ml-auto text-xs text-muted-foreground",children:[u.slice(0,6).map(b=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:b.color}}),b.name.split(" ")[0]]},b.id)),u.length>6&&e.jsxs("span",{children:["+",u.length-6," more"]})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden mt-2",children:n?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(b=>e.jsxs("div",{className:"min-w-[260px] flex-1",children:[e.jsx(xs,{className:"h-12 w-full mb-2 rounded-lg"}),e.jsx(xs,{className:"h-24 w-full mb-2 rounded-lg"}),e.jsx(xs,{className:"h-24 w-full rounded-lg"})]},b))}):f.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx(hr,{className:"h-10 w-10 mx-auto mb-3 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No team deals found"}),e.jsx("p",{className:"text-sm",children:"Team members' deals will appear here."})]})}):e.jsx("div",{className:"flex gap-3 h-full overflow-x-auto pb-2",children:f.map(b=>{const w=b.icon&&c1e[b.icon]||Kc;return e.jsxs("div",{className:"flex flex-col h-full min-w-[260px] max-w-[300px] flex-1 bg-muted/30 rounded-xl border border-border/50",children:[e.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:b.color||"hsl(var(--border))",borderTopWidth:3},children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center",style:{backgroundColor:b.color?`${b.color}20`:void 0},children:e.jsx(w,{className:"h-3.5 w-3.5",style:{color:b.color||void 0}})}),e.jsx("h3",{className:"font-semibold text-sm",children:b.name})]}),e.jsx(rt,{variant:"secondary",className:"text-xs px-2",children:b.deals.length})]}),b.totalValue>0&&e.jsx("p",{className:"text-xs text-muted-foreground ml-8",children:y(b.totalValue)})]}),e.jsx(Ri,{className:"flex-1 p-2",children:e.jsx("div",{className:"space-y-2",children:b.deals.map(j=>{const k=d.get(j.owner_user_id);return e.jsx(Wfs,{deal:j,ownerColor:(k==null?void 0:k.color)||"#888",ownerName:(k==null?void 0:k.name)||"Unknown",ownerAvatar:(k==null?void 0:k.avatar)||null,formatPrice:_},j.id)})})})]},b.name)})})}),e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-2 border-t shrink-0",children:[p.length," deal",p.length!==1?"s":""," across ",f.length," stage",f.length!==1?"s":""," from ",u.length," member",u.length!==1?"s":""]})]})})}function Wfs({deal:t,ownerColor:s,ownerName:r,ownerAvatar:n,formatPrice:a}){const o={buyer:{label:"Buyer",className:"bg-blue-500/10 text-blue-600 border-blue-200"},seller:{label:"Seller",className:"bg-emerald-500/10 text-emerald-600 border-emerald-200"},dual:{label:"Dual",className:"bg-purple-500/10 text-purple-600 border-purple-200"},referral:{label:"Referral",className:"bg-orange-500/10 text-orange-600 border-orange-200"},lease:{label:"Lease",className:"bg-cyan-500/10 text-cyan-600 border-cyan-200"}},l=t.deal_type?o[t.deal_type]:null;return e.jsxs("div",{className:"rounded-lg border bg-card p-3 space-y-2 transition-all hover:shadow-sm",style:{borderLeftWidth:4,borderLeftColor:s},children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(xn,{className:"h-4 w-4",children:[e.jsx(Aa,{src:n||""}),e.jsx(yn,{className:"text-[8px] font-semibold text-white",style:{backgroundColor:s},children:r.charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-[10px] font-medium truncate",style:{color:s},children:r})]}),e.jsxs("div",{className:"flex items-start justify-between gap-1",children:[e.jsx("h4",{className:"font-medium text-sm leading-tight line-clamp-2",children:t.deal_name}),l&&e.jsx(rt,{variant:"outline",className:Pt("text-[10px] px-1.5 py-0 shrink-0",l.className),children:l.label})]}),t.contact_name&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:t.contact_name}),(t.property_address||t.city)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(On,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:t.property_address||`${t.city}, ${t.state}`})]}),t.sale_price&&e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx(od,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:a(t.sale_price)})]})]})}function Gfs({members:t,enabledMembers:s,onToggleMember:r,isOpen:n,onToggleOpen:a}){const o=s.size;return e.jsxs("div",{className:Pt("shrink-0 border-r border-border/50 bg-muted/20 transition-all duration-300 flex flex-col",n?"w-[220px]":"w-[48px]"),children:[e.jsx("div",{className:"p-2 border-b border-border/50 shrink-0",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 px-2",onClick:a,children:[e.jsx(hr,{className:"h-4 w-4 shrink-0 text-primary"}),n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs font-semibold flex-1 text-left",children:"Team"}),o>0&&e.jsx("span",{className:"text-[10px] bg-primary text-primary-foreground rounded-full px-1.5 py-0.5",children:o}),e.jsx(zl,{className:"h-3 w-3 text-muted-foreground"})]}),!n&&o>0&&e.jsx("span",{className:"absolute -top-1 -right-1 text-[9px] bg-primary text-primary-foreground rounded-full w-4 h-4 flex items-center justify-center",children:o})]})}),n?e.jsxs(Ri,{className:"flex-1 p-2",children:[e.jsx("div",{className:"space-y-1",children:t.map(l=>{const i=s.has(l.id);return e.jsxs("button",{onClick:()=>r(l.id),className:Pt("w-full flex items-center gap-2 px-2 py-2 rounded-lg text-left transition-colors",i?"bg-primary/10 hover:bg-primary/15":"hover:bg-muted/50"),children:[e.jsxs("div",{className:"relative",children:[e.jsxs(xn,{className:"h-7 w-7",children:[e.jsx(Aa,{src:l.avatar_url||""}),e.jsx(yn,{className:"text-[10px] font-semibold text-white",style:{backgroundColor:l.color},children:l.name.charAt(0).toUpperCase()})]}),i&&e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-background",style:{backgroundColor:l.color}})]}),e.jsx("span",{className:Pt("text-xs truncate flex-1",i?"font-medium text-foreground":"text-muted-foreground"),children:l.name}),e.jsx(Br,{checked:i,onCheckedChange:()=>r(l.id),className:"scale-75",onClick:d=>d.stopPropagation()})]},l.id)})}),t.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No team members"})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center pt-2 gap-2",children:[t.slice(0,5).map(l=>{const i=s.has(l.id);return e.jsx("button",{onClick:()=>r(l.id),className:"relative",title:l.name,children:e.jsxs(xn,{className:Pt("h-7 w-7 transition-all",i?"ring-2 ring-offset-1 ring-offset-background":"opacity-50"),style:i?{"--tw-ring-color":l.color}:{},children:[e.jsx(Aa,{src:l.avatar_url||""}),e.jsx(yn,{className:"text-[10px] font-semibold text-white",style:{backgroundColor:l.color},children:l.name.charAt(0).toUpperCase()})]})},l.id)}),t.length>5&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",t.length-5]})]})]})}const ULe=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function Kfs(){const t=Ya(),{data:s}=Lf(),r=(s==null?void 0:s.role)==="team_leader",n=s==null?void 0:s.teamId,a=wt({queryKey:["team-pipeline-members",n,t],queryFn:async()=>{const{data:o,error:l}=await G.from("team_members").select("user_id, role").eq("team_id",n).neq("user_id",t);if(l)throw l;if(!o||o.length===0)return[];const i=o.map(p=>p.user_id),{data:d,error:u}=await G.from("profiles").select("id, name, avatar_url").in("id",i);if(u)throw u;return(d||[]).map((p,f)=>({id:p.id,name:p.name||"Unknown",avatar_url:p.avatar_url,color:ULe[f%ULe.length]}))},enabled:!!n&&!!t&&r,staleTime:5*60*1e3});return{isTeamLeader:r,teamMembers:a.data||[],isLoadingMembers:a.isLoading}}function Zfs(t){return wt({queryKey:["team-member-deals",t],queryFn:async()=>{if(t.length===0)return[];const{data:s,error:r}=await G.from("deal_pipeline").select(` *, contact:innercircle_contacts(id, first_name, last_name, email, phone), listing:listings(id, property_address, city, state, price, status, created_at), deal_pipeline_stages(name) `).in("owner_user_id",t).order("updated_at",{ascending:!1});if(r)throw r;return(s||[]).map(n=>{var a;return{...n,_stage_name:((a=n.deal_pipeline_stages)==null?void 0:a.name)||null}})},enabled:t.length>0})}function $Je({stages:t,currentStageId:s,onStageSelect:r,disabled:n}){const[a,o]=C.useState(!1),l=t.find(d=>d.id===s),i=d=>{d.id!==s&&r(d.id,d.name),o(!1)};return e.jsxs(Kd,{open:a,onOpenChange:o,children:[e.jsx(Zd,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5",disabled:n,onClick:d=>d.stopPropagation(),children:[l&&e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:l.color}}),e.jsx("span",{className:"max-w-[80px] truncate",children:(l==null?void 0:l.name)||"Move"}),e.jsx(Ua,{className:"h-3 w-3 shrink-0"})]})}),e.jsx(Md,{align:"end",className:"w-48 z-50 bg-popover",onClick:d=>d.stopPropagation(),children:t.map(d=>{const u=d.icon&&c1e[d.icon]||Kc,p=d.id===s;return e.jsxs(Na,{onClick:()=>i(d),className:Pt("flex items-center gap-2 cursor-pointer",p&&"bg-accent"),children:[e.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center shrink-0",style:{backgroundColor:`${d.color}20`},children:e.jsx(u,{className:"h-3 w-3",style:{color:d.color}})}),e.jsx("span",{className:"flex-1",children:d.name}),p&&e.jsx(ha,{className:"h-4 w-4 text-primary"})]},d.id)})})]})}const Yfs={buyer:{label:"Buyer",color:"bg-blue-500/10 text-blue-600 border-blue-200"},seller:{label:"Seller",color:"bg-emerald-500/10 text-emerald-600 border-emerald-200"},dual:{label:"Dual",color:"bg-purple-500/10 text-purple-600 border-purple-200"},referral:{label:"Referral",color:"bg-orange-500/10 text-orange-600 border-orange-200"},lease:{label:"Lease",color:"bg-cyan-500/10 text-cyan-600 border-cyan-200"}},Xfs={low:{color:"bg-slate-100 text-slate-600",dot:"bg-slate-400"},medium:{color:"bg-amber-100 text-amber-700",dot:"bg-amber-500"},high:{color:"bg-orange-100 text-orange-700",dot:"bg-orange-500"},urgent:{color:"bg-red-100 text-red-700",dot:"bg-red-500"}};function qJe({deal:t,onClick:s,isDragging:r,stages:n,onStageChange:a,showStagePicker:o=!1,isWonStage:l=!1,ownerInfo:i=null}){var S,T;const d=eT(),u=Yfs[t.deal_type],p=Xfs[t.priority],f=C.useMemo(()=>t.target_close_date?Qg(gl(t.target_close_date),new Date):null,[t.target_close_date]),y=f!==null&&f<0,_=f!==null&&f<=7&&f>=0,b=C.useMemo(()=>{var R;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const I=((R=t.listing)==null?void 0:R.created_at)||t.listing_date;if(!I)return null;const L=t.contract_date?gl(t.contract_date):new Date;return Qg(L,gl(I))},[t]),w=l&&!t.scorecard_transaction_id,j=!!t.scorecard_transaction_id,k=I=>I?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I):null;return e.jsx(Ee,{className:Pt("cursor-pointer transition-all duration-200 hover:shadow-md hover:border-primary/30 group overflow-hidden",r&&"opacity-50 rotate-2 shadow-xl",y&&"border-red-200 bg-red-50/30",w&&"border-amber-300 bg-amber-50/30 dark:bg-amber-950/20"),onClick:s,style:i?{borderLeftWidth:4,borderLeftColor:i.color}:void 0,children:e.jsxs(Oe,{className:"p-3 space-y-2.5",children:[i&&e.jsxs("div",{className:"flex items-center gap-1.5 -mt-0.5 mb-1",children:[e.jsxs(xn,{className:"h-4 w-4",children:[e.jsx(Aa,{src:i.avatar_url||""}),e.jsx(yn,{className:"text-[8px] font-semibold text-white",style:{backgroundColor:i.color},children:i.name.charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-[10px] font-medium",style:{color:i.color},children:i.name})]}),e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("h4",{className:"font-medium text-sm leading-tight line-clamp-2 group-hover:text-primary transition-colors",children:t.deal_name})}),e.jsx(rt,{variant:"outline",className:Pt("text-[10px] px-1.5 py-0 shrink-0",u.color),children:u.label})]}),t.contact&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(xn,{className:"h-5 w-5",children:e.jsxs(yn,{className:"text-[10px] bg-primary/10 text-primary",children:[(S=t.contact.first_name)==null?void 0:S[0],(T=t.contact.last_name)==null?void 0:T[0]]})}),e.jsxs("span",{className:"truncate",children:[t.contact.first_name," ",t.contact.last_name]})]}),t.listing&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(Wo,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{className:"text-primary truncate",children:"Linked to Listing Exchange"})]}),w&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 px-2 py-1 rounded",children:[e.jsx(ao,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-medium",children:"Add to Scorecard"})]}),j&&l&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx(ua,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:"Synced to Scorecard"})]}),b!==null&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(dP,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsxs("span",{className:Pt("font-medium",b>90?"text-red-600":b>60?"text-amber-600":"text-muted-foreground"),children:[b," DOM"]}),t.contract_date&&e.jsx("span",{className:"text-muted-foreground",children:"(final)"})]}),!t.listing&&(t.property_address||t.city)&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(On,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:t.property_address||`${t.city}, ${t.state}`})]}),t.expected_price&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(od,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:k(t.expected_price)}),t.expected_commission&&e.jsxs("span",{className:"text-muted-foreground",children:["• ",k(t.expected_commission)," GCI"]}),(()=>{const I=uf(t);return I!==null&&I!==t.expected_commission?e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:["• ",k(I)," Net"]}):null})()]}),e.jsxs("div",{className:"flex items-center justify-between pt-1 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:Pt("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",p.color),children:[e.jsx("div",{className:Pt("w-1.5 h-1.5 rounded-full",p.dot)}),e.jsx("span",{className:"capitalize",children:t.priority})]}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[t.probability,"%"]})]}),o&&d&&n&&a?e.jsx($Je,{stages:n,currentStageId:t.stage_id||"",onStageSelect:(I,L)=>a(t.id,I,L)}):t.target_close_date?e.jsxs("div",{className:Pt("flex items-center gap-1 text-[10px]",y&&"text-red-600",_&&!y&&"text-amber-600",!y&&!_&&"text-muted-foreground"),children:[y?e.jsx(ll,{className:"h-3 w-3"}):e.jsx(on,{className:"h-3 w-3"}),e.jsx("span",{children:y?`${Math.abs(f)}d overdue`:_?`${f}d left`:ys(gl(t.target_close_date),"MMM d")})]}):null]})]})})}function Qfs({stage:t,deals:s,onDealClick:r,onAddDeal:n,onDragStart:a,onDragOver:o,onDrop:l,isDragOver:i,isWonStage:d=!1,getOwnerInfo:u}){const p=C.useRef(null),f=s.reduce((j,k)=>j+(k.expected_price||0),0),y=s.reduce((j,k)=>j+(k.expected_commission||0),0),_=s.reduce((j,k)=>j+(uf(k)||0),0),b=j=>j>=1e6?`$${(j/1e6).toFixed(1)}M`:j>=1e3?`$${(j/1e3).toFixed(0)}K`:`$${j.toFixed(0)}`,w=t.icon&&c1e[t.icon]||Kc;return e.jsxs("div",{ref:p,className:Pt("flex flex-col h-full min-w-[280px] max-w-[320px] bg-muted/30 rounded-xl border border-border/50 transition-all duration-200",i&&"border-primary/50 bg-primary/5 ring-2 ring-primary/20"),onDragOver:j=>o(j,t.id),onDrop:j=>l(j,t.id),children:[e.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:t.color,borderTopWidth:3},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color}20`},children:e.jsx(w,{className:"h-4 w-4",style:{color:t.color}})}),e.jsx("div",{children:e.jsx("h3",{className:"font-semibold text-sm",children:t.name})})]}),e.jsx(rt,{variant:"secondary",className:"text-xs font-medium px-2",children:s.length})]}),f>0&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-wrap",children:[e.jsx("span",{className:"font-medium text-foreground",children:b(f)}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[b(y)," GCI"]}),_>0&&_!==y&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:[b(_)," Net"]})]})]})]}),e.jsx(Ri,{className:"flex-1 p-2",children:e.jsxs("div",{className:"space-y-2",children:[s.map(j=>e.jsx("div",{draggable:!0,onDragStart:k=>{k.dataTransfer.effectAllowed="move",a(j.id,t.id)},children:e.jsx(qJe,{deal:j,onClick:()=>r(j),isWonStage:d,ownerInfo:(u==null?void 0:u(j))||null})},j.id)),s.length===0&&e.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground text-sm",children:[e.jsx("p",{className:"mb-2",children:"No deals yet"}),e.jsx("p",{className:"text-xs",children:"Drag deals here or add new"})]})]})}),e.jsx("div",{className:"p-2 border-t border-border/50 shrink-0",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground hover:text-foreground",onClick:()=>n(t.id),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})})]})}function Jfs({stats:t,isLoading:s}){const r=a=>a>=1e6?`$${(a/1e6).toFixed(1)}M`:a>=1e3?`$${(a/1e3).toFixed(0)}K`:`$${a.toLocaleString()}`,n=[{label:"Active Deals",value:(t==null?void 0:t.activeDeals)||0,icon:Gh,color:"text-blue-500",bgColor:"bg-blue-500/10"},{label:"Weighted GCI",value:r((t==null?void 0:t.weightedGCI)||0),icon:DP,color:"text-indigo-500",bgColor:"bg-indigo-500/10",tooltip:"GCI adjusted by each deal's win probability"},{label:"Weighted Net",value:r((t==null?void 0:t.weightedNet)||0),icon:KP,color:"text-teal-500",bgColor:"bg-teal-500/10",tooltip:"Net to Agent adjusted by each deal's win probability"},{label:"YTD Closed Net",value:r((t==null?void 0:t.ytdWonNet)||0),icon:cP,color:"text-green-500",bgColor:"bg-green-500/10",subtitle:`${(t==null?void 0:t.ytdWonDeals)||0} deals`,tooltip:"Net commission from deals closed this year"},{label:"Projected Annual",value:r((t==null?void 0:t.projectedAnnualNet)||0),icon:ac,color:"text-amber-500",bgColor:"bg-amber-500/10",tooltip:"YTD Closed Net + Weighted Active Net"}];return s?e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[1,2,3,4,5].map(a=>e.jsx(Ee,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-10 bg-muted rounded"})})},a))}):e.jsx(U_,{children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:n.map(a=>{const o=e.jsx(Ee,{className:"border-border/50 hover:shadow-sm transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:Pt("p-2 rounded-lg",a.bgColor),children:e.jsx(a.icon,{className:Pt("h-5 w-5",a.color)})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:a.label}),e.jsx("p",{className:"text-xl font-bold",children:a.value}),"subtitle"in a&&a.subtitle&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a.subtitle})]})]})})},a.label);return"tooltip"in a&&a.tooltip?e.jsxs(Wc,{children:[e.jsx(Gc,{asChild:!0,children:o}),e.jsx(Cc,{children:e.jsx("p",{children:a.tooltip})})]},a.label):o})})})}function egs({formData:t,onChange:s,isEditing:r}){const{isAdmin:n}=Hs(),[a,o]=C.useState(t.portal_enabled);if(!n)return e.jsxs("div",{className:"border rounded-lg p-4 opacity-60",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(rt,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Give your clients a premium, real-time view of their transaction — coming soon!"})]});const l=i=>{s({...t,...i})};return e.jsx(bf,{open:a,onOpenChange:o,children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs(wf,{className:"w-full p-4 flex items-center justify-between hover:bg-muted/50 transition-colors rounded-t-lg",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),t.portal_enabled&&e.jsx(rt,{className:"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200",variant:"outline",children:"Enabled"})]}),e.jsx(Ho,{className:Pt("h-4 w-4 text-muted-foreground transition-transform",a&&"rotate-180")})]}),e.jsx(jf,{children:e.jsxs("div",{className:"px-4 pb-4 space-y-5 border-t pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Enable Client Portal"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Create a beautiful portal your client can track their deal from"})]}),e.jsx(Br,{checked:t.portal_enabled,onCheckedChange:i=>l({portal_enabled:i})})]}),t.portal_enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Portal Visibility"}),e.jsxs(cbe,{value:t.visibility,onValueChange:i=>l({visibility:i}),className:"grid grid-cols-2 gap-3",children:[e.jsxs("label",{className:Pt("flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",t.visibility==="private"?"border-primary bg-primary/5":"hover:bg-muted/50"),children:[e.jsx(Gne,{value:"private"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx($u,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:"Private"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Link-only access"})]})]}),e.jsxs("label",{className:Pt("flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",t.visibility==="public"?"border-primary bg-primary/5":"hover:bg-muted/50"),children:[e.jsx(Gne,{value:"public"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Lm,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:"Public"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Shareable link"})]})]})]})]}),e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-muted/30",children:[e.jsx(Bo,{id:"require_onboarding",checked:t.require_onboarding,onCheckedChange:i=>l({require_onboarding:!!i}),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"require_onboarding",className:"text-sm font-medium cursor-pointer",children:"Require client onboarding before portal access"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Client confirms contact details + preferences before viewing portal. Info is saved to your contacts."})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Bo,{id:"allow_spouse",checked:t.allow_spouse,onCheckedChange:i=>l({allow_spouse:!!i})}),e.jsx(ve,{htmlFor:"allow_spouse",className:"text-sm cursor-pointer",children:"Allow client to add spouse/partner during onboarding"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Client Invite Details"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Client Full Name"}),e.jsx(Re,{value:t.client_name,onChange:i=>l({client_name:i.target.value}),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Email"}),e.jsx(Re,{type:"email",value:t.client_email,onChange:i=>l({client_email:i.target.value}),placeholder:"jane@example.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Phone"}),e.jsx(Re,{type:"tel",value:t.client_phone,onChange:i=>l({client_phone:i.target.value}),placeholder:"(555) 123-4567"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Preferred Invite Method"}),e.jsxs(sr,{value:t.invite_method,onValueChange:i=>l({invite_method:i}),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"email",children:"Email"}),e.jsxs(At,{value:"sms",disabled:!t.client_phone,children:["SMS ",!t.client_phone&&"(add phone first)"]})]})]})]})]})]})]})]})})]})})}const tgs=[{value:"buyer",label:"Buyer"},{value:"seller",label:"Seller"},{value:"dual",label:"Dual Agency"},{value:"referral",label:"Referral"},{value:"lease",label:"Lease"}],sgs=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"urgent",label:"Urgent"}];function rgs({open:t,onOpenChange:s,deal:r,defaultStageId:n}){const{data:a}=zce(),{data:o}=tm(),{data:l}=CVe(),i=hle(),d=OJe(),u=RJe(),p=U2e(),[f,y]=C.useState({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"}),[_,b]=C.useState(""),[w,j]=C.useState(!1),[k,S]=C.useState(!1),[T,I]=C.useState({first_name:"",last_name:"",email:"",phone:""}),L=(l==null?void 0:l.filter(te=>((r==null?void 0:r.listing_id)===te.id,!0)))||[],[R,$]=C.useState({deal_name:"",deal_type:"buyer",stage_id:"",contact_id:"",listing_id:"",property_address:"",city:"",state:"",zip_code:"",expected_price:"",commission_percentage:"3",brokerage_split_pct:"",team_split_pct:"",referral_fee_pct:"",franchise_fee_pct:"",transaction_fee:"",commission_calc_method:"standard",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""});C.useEffect(()=>{var te,Q,de,re,ae,le,he,be;t&&(r?($({deal_name:r.deal_name,deal_type:r.deal_type,stage_id:r.stage_id||"",contact_id:r.contact_id||"",listing_id:r.listing_id||"",property_address:r.property_address||"",city:r.city||"",state:r.state||"",zip_code:r.zip_code||"",expected_price:((te=r.expected_price)==null?void 0:te.toString())||"",commission_percentage:((Q=r.commission_percentage)==null?void 0:Q.toString())||"3",brokerage_split_pct:((de=r.brokerage_split_pct)==null?void 0:de.toString())||"",team_split_pct:((re=r.team_split_pct)==null?void 0:re.toString())||"",referral_fee_pct:((ae=r.referral_fee_pct)==null?void 0:ae.toString())||"",franchise_fee_pct:((le=r.franchise_fee_pct)==null?void 0:le.toString())||"",transaction_fee:((he=r.transaction_fee)==null?void 0:he.toString())||"",commission_calc_method:r.commission_calc_method||"standard",target_close_date:r.target_close_date?gl(r.target_close_date):void 0,contract_date:r.contract_date?gl(r.contract_date):void 0,listing_date:r.listing_date?gl(r.listing_date):void 0,priority:r.priority,probability:r.probability.toString(),notes:r.notes||""}),r.contact&&b(`${r.contact.first_name} ${r.contact.last_name}`)):($({deal_name:"",deal_type:"buyer",stage_id:n||((be=a==null?void 0:a[0])==null?void 0:be.id)||"",contact_id:"",listing_id:"",property_address:"",city:"",state:"",zip_code:"",expected_price:"",commission_percentage:"3",brokerage_split_pct:"",team_split_pct:"",referral_fee_pct:"",franchise_fee_pct:"",transaction_fee:"",commission_calc_method:"standard",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""}),b(""),y({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"})))},[t,r,n,a]);const q=o==null?void 0:o.filter(te=>{var de,re,ae;const Q=_.toLowerCase();return((de=te.first_name)==null?void 0:de.toLowerCase().includes(Q))||((re=te.last_name)==null?void 0:re.toLowerCase().includes(Q))||((ae=te.email)==null?void 0:ae.toLowerCase().includes(Q))}).slice(0,5),U=()=>{const te=parseFloat(R.expected_price)||0,Q=parseFloat(R.commission_percentage)||0;return te*(Q/100)},H=()=>{const te=U();if(!te)return null;const Q=parseFloat(R.brokerage_split_pct)||0,de=parseFloat(R.team_split_pct)||0,re=parseFloat(R.referral_fee_pct)||0,ae=parseFloat(R.franchise_fee_pct)||0,le=parseFloat(R.transaction_fee)||0;if(R.commission_calc_method==="referral_first"){let be=te;re&&(be-=te*re/100);let _e=be;return Q&&(_e-=be*Q/100),de&&(_e-=te*de/100),ae&&(_e-=te*ae/100),le&&(_e-=le),Math.max(0,_e)}let he=te;return Q&&(he=he*((100-Q)/100)),de&&(he=he*((100-de)/100)),re&&(he=he-te*re/100),ae&&(he=he-te*ae/100),le&&(he=he-le),Math.max(0,he)},Y=async te=>{var Q,de,re;if(te.preventDefault(),!R.deal_name.trim()){fe.error("Please enter a deal name");return}try{const ae={deal_name:R.deal_name,deal_type:R.deal_type,stage_id:R.stage_id||null,contact_id:R.contact_id||null,listing_id:R.listing_id||null,property_address:R.property_address||null,city:R.city||null,state:R.state||null,zip_code:R.zip_code||null,expected_price:R.expected_price?parseFloat(R.expected_price):null,expected_commission:U()||null,commission_percentage:R.commission_percentage?parseFloat(R.commission_percentage):3,brokerage_split_pct:R.brokerage_split_pct?parseFloat(R.brokerage_split_pct):null,team_split_pct:R.team_split_pct?parseFloat(R.team_split_pct):null,referral_fee_pct:R.referral_fee_pct?parseFloat(R.referral_fee_pct):null,franchise_fee_pct:R.franchise_fee_pct?parseFloat(R.franchise_fee_pct):null,transaction_fee:R.transaction_fee?parseFloat(R.transaction_fee):null,commission_calc_method:R.commission_calc_method,target_close_date:((Q=R.target_close_date)==null?void 0:Q.toISOString().split("T")[0])||null,contract_date:((de=R.contract_date)==null?void 0:de.toISOString().split("T")[0])||null,listing_date:((re=R.listing_date)==null?void 0:re.toISOString().split("T")[0])||null,priority:R.priority,probability:parseInt(R.probability)||50,notes:R.notes||null};if(r)await u.mutateAsync({id:r.id,...ae}),fe.success("Deal updated successfully");else{const le=await d.mutateAsync(ae);if(fe.success("Deal created successfully"),f.portal_enabled&&(le!=null&&le.id))try{await p.mutateAsync({deal_id:le.id,visibility:f.visibility,require_onboarding:f.require_onboarding,allow_spouse:f.allow_spouse,client_name:f.client_name||null,client_email:f.client_email||null,client_phone:f.client_phone||null,invite_method:f.invite_method}),fe.success("Client portal created!")}catch{fe.error("Deal created, but portal setup failed")}}s(!1)}catch{fe.error("Failed to save deal")}},se=d.isPending||u.isPending;return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:r?"Edit Deal":"Add New Deal"}),e.jsx(Kr,{children:r?"Update the deal details below.":"Enter the details for your new deal."})]}),e.jsxs("form",{onSubmit:Y,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"col-span-2 space-y-2",children:[e.jsx(ve,{htmlFor:"deal_name",children:"Deal Name *"}),e.jsx(Re,{id:"deal_name",value:R.deal_name,onChange:te=>$(Q=>({...Q,deal_name:te.target.value})),placeholder:"e.g., Smith Family - 123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Deal Type"}),e.jsxs(sr,{value:R.deal_type,onValueChange:te=>$(Q=>({...Q,deal_type:te})),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:tgs.map(te=>e.jsx(At,{value:te.value,children:te.label},te.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Stage"}),e.jsxs(sr,{value:R.stage_id||"none",onValueChange:te=>$(Q=>({...Q,stage_id:te==="none"?"":te})),children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select stage"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"none",children:"No Stage"}),a==null?void 0:a.map(te=>e.jsx(At,{value:te.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:te.color}}),te.name]})},te.id))]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Link to Contact"}),e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{value:_,onChange:te=>{b(te.target.value),j(!0),S(!1),te.target.value||$(Q=>({...Q,contact_id:""}))},onFocus:()=>j(!0),placeholder:"Search contacts...",className:"pl-9"}),w&&_&&e.jsxs("div",{className:"absolute z-10 w-full mt-1 bg-background border rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[q&&q.length>0?q.map(te=>e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left hover:bg-muted flex items-center gap-2",onClick:()=>{$(Q=>({...Q,contact_id:te.id})),b(`${te.first_name} ${te.last_name}`),j(!1)},children:[e.jsx(Yi,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:[te.first_name," ",te.last_name]}),te.email&&e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:te.email})]},te.id)):e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"No contacts found"}),e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left hover:bg-muted flex items-center gap-2 border-t text-primary font-medium",onClick:()=>{const te=_.trim().split(/\s+/);I({first_name:te[0]||"",last_name:te.slice(1).join(" ")||"",email:"",phone:""}),S(!0),j(!1)},children:[e.jsx(yc,{className:"h-4 w-4"}),e.jsxs("span",{children:['Create new contact "',_.trim(),'"']})]})]})]}),k&&e.jsxs("div",{className:"border rounded-lg p-3 space-y-3 bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(yc,{className:"h-3.5 w-3.5"}),"Quick Add Contact"]}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>S(!1),children:"Cancel"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Re,{placeholder:"First name *",value:T.first_name,onChange:te=>I(Q=>({...Q,first_name:te.target.value})),className:"h-8 text-sm"}),e.jsx(Re,{placeholder:"Last name",value:T.last_name,onChange:te=>I(Q=>({...Q,last_name:te.target.value})),className:"h-8 text-sm"}),e.jsx(Re,{placeholder:"Email",type:"email",value:T.email,onChange:te=>I(Q=>({...Q,email:te.target.value})),className:"h-8 text-sm"}),e.jsx(Re,{placeholder:"Phone",type:"tel",value:T.phone,onChange:te=>I(Q=>({...Q,phone:te.target.value})),className:"h-8 text-sm"})]}),e.jsx(K,{type:"button",size:"sm",className:"w-full h-8",disabled:!T.first_name.trim()||i.isPending,onClick:async()=>{try{const te=await i.mutateAsync({first_name:T.first_name.trim(),last_name:T.last_name.trim()||null,email:T.email.trim()||null,phone:T.phone.trim()||null});te&&($(Q=>({...Q,contact_id:te.id})),b(`${te.first_name} ${te.last_name||""}`.trim()),S(!1))}catch{}},children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-3.5 w-3.5 mr-1 animate-spin"})," Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(yc,{className:"h-3.5 w-3.5 mr-1"})," Add & Link Contact"]})})]})]}),L.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(Wo,{className:"h-4 w-4"}),"Link to Listing Exchange"]}),e.jsxs(sr,{value:R.listing_id||"none",onValueChange:te=>{const Q=te==="none"?"":te,de=L.find(re=>re.id===Q);$(de?re=>{var ae;return{...re,listing_id:Q,deal_type:"seller",property_address:de.property_address||re.property_address,city:de.city||re.city,state:de.state||re.state,expected_price:((ae=de.price)==null?void 0:ae.toString())||re.expected_price}}:re=>({...re,listing_id:Q}))},children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select a listing to sync status..."})}),e.jsxs(tr,{children:[e.jsx(At,{value:"none",children:"None"}),L.map(te=>e.jsx(At,{value:te.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:te.property_address||`${te.city}, ${te.state}`}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["$",(te.price/1e3).toFixed(0),"K"]})]})},te.id))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Status changes will sync automatically between the deal and listing."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Property Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"col-span-2 space-y-2",children:[e.jsx(ve,{htmlFor:"property_address",children:"Address"}),e.jsx(Re,{id:"property_address",value:R.property_address,onChange:te=>$(Q=>({...Q,property_address:te.target.value})),placeholder:"123 Main Street"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"city",children:"City"}),e.jsx(Re,{id:"city",value:R.city,onChange:te=>$(Q=>({...Q,city:te.target.value}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"state",children:"State"}),e.jsx(Re,{id:"state",value:R.state,onChange:te=>$(Q=>({...Q,state:te.target.value})),maxLength:2,placeholder:"TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"zip_code",children:"ZIP"}),e.jsx(Re,{id:"zip_code",value:R.zip_code,onChange:te=>$(Q=>({...Q,zip_code:te.target.value}))})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Financial Details"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"expected_price",children:"Expected Price"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"$"}),e.jsx(Re,{id:"expected_price",type:"number",value:R.expected_price,onChange:te=>$(Q=>({...Q,expected_price:te.target.value})),className:"pl-7",placeholder:"500000"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"commission_percentage",children:"Commission %"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{id:"commission_percentage",type:"number",step:"0.1",value:R.commission_percentage,onChange:te=>$(Q=>({...Q,commission_percentage:te.target.value})),className:"pr-7"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Expected GCI"}),e.jsx(Re,{value:U()?`$${U().toLocaleString()}`:"-",disabled:!0,className:"bg-muted"})]})]}),e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"text-xs font-medium text-muted-foreground cursor-pointer hover:text-foreground flex items-center gap-1 py-1",children:[e.jsx("span",{className:"group-open:rotate-90 transition-transform text-[10px]",children:"▶"}),"Commission Splits (optional)"]}),e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/50",children:[e.jsx(ve,{className:"text-xs whitespace-nowrap",children:"Calculation Method:"}),e.jsxs(sr,{value:R.commission_calc_method,onValueChange:te=>$(Q=>({...Q,commission_calc_method:te})),children:[e.jsx(er,{className:"h-7 text-xs",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"standard",children:"Standard (all splits on GCI)"}),e.jsx(At,{value:"referral_first",children:"Referral First (brokerage split after referral)"})]})]})]}),R.commission_calc_method==="referral_first"&&e.jsx("p",{className:"text-[10px] text-muted-foreground bg-blue-50 dark:bg-blue-950/30 p-2 rounded",children:"💡 Referral fee is deducted from GCI first, then the brokerage split is applied to the remaining amount."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Brokerage Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",step:"1",min:"0",max:"100",value:R.brokerage_split_pct,onChange:te=>$(Q=>({...Q,brokerage_split_pct:te.target.value})),className:"pr-7 h-8 text-sm",placeholder:"30"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"% that goes to brokerage"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Team Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",step:"1",min:"0",max:"100",value:R.team_split_pct,onChange:te=>$(Q=>({...Q,team_split_pct:te.target.value})),className:"pr-7 h-8 text-sm",placeholder:"0"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"% that goes to team lead"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Referral Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",step:"1",min:"0",max:"100",value:R.referral_fee_pct,onChange:te=>$(Q=>({...Q,referral_fee_pct:te.target.value})),className:"pr-7 h-8 text-sm",placeholder:"0"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Franchise Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",step:"1",min:"0",max:"100",value:R.franchise_fee_pct,onChange:te=>$(Q=>({...Q,franchise_fee_pct:te.target.value})),className:"pr-7 h-8 text-sm",placeholder:"0"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Transaction Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"$"}),e.jsx(Re,{type:"number",step:"1",min:"0",value:R.transaction_fee,onChange:te=>$(Q=>({...Q,transaction_fee:te.target.value})),className:"pl-7 h-8 text-sm",placeholder:"500"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Flat fee deducted"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs",children:"Net to Agent"}),e.jsx(Re,{value:H()?`$${Math.round(H()).toLocaleString()}`:"-",disabled:!0,className:"bg-muted h-8 text-sm font-semibold"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Dates & Status"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Target Close Date"}),e.jsxs(Co,{children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!R.target_close_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),R.target_close_date?ys(R.target_close_date,"PPP"):"Pick a date"]})}),e.jsx(No,{className:"w-auto p-0",align:"start",children:e.jsx(jp,{mode:"single",selected:R.target_close_date,onSelect:te=>$(Q=>({...Q,target_close_date:te})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Contract Date"}),e.jsxs(Co,{children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!R.contract_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),R.contract_date?ys(R.contract_date,"PPP"):"Pick a date"]})}),e.jsx(No,{className:"w-auto p-0",align:"start",children:e.jsx(jp,{mode:"single",selected:R.contract_date,onSelect:te=>$(Q=>({...Q,contract_date:te})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),(R.deal_type==="seller"||R.deal_type==="dual")&&!R.listing_id&&e.jsxs("div",{className:"space-y-2 col-span-2",children:[e.jsx(ve,{children:"Listing Date (for Days on Market)"}),e.jsxs(Co,{children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!R.listing_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),R.listing_date?ys(R.listing_date,"PPP"):"Pick a date"]})}),e.jsx(No,{className:"w-auto p-0",align:"start",children:e.jsx(jp,{mode:"single",selected:R.listing_date,onSelect:te=>$(Q=>({...Q,listing_date:te})),initialFocus:!0,className:"pointer-events-auto"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used to calculate Days on Market. Auto-filled for linked listings."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Priority"}),e.jsxs(sr,{value:R.priority,onValueChange:te=>$(Q=>({...Q,priority:te})),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:sgs.map(te=>e.jsx(At,{value:te.value,children:te.label},te.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Win Probability"}),e.jsxs("div",{className:"relative",children:[e.jsx(Re,{type:"number",min:"0",max:"100",value:R.probability,onChange:te=>$(Q=>({...Q,probability:te.target.value})),className:"pr-7"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"notes",children:"Notes"}),e.jsx(Ar,{id:"notes",value:R.notes,onChange:te=>$(Q=>({...Q,notes:te.target.value})),placeholder:"Add any additional notes about this deal...",rows:3})]}),!r&&e.jsx(egs,{formData:f,onChange:y}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:se,children:[se&&e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),r?"Update Deal":"Create Deal"]})]})]})]})})}function ngs({dealId:t}){const s=Ya(),r=rs(),[n,a]=C.useState(""),[o,l]=C.useState(!1),{data:i=[]}=wt({queryKey:["deal-tags",t],queryFn:async()=>{const{data:b,error:w}=await G.from("deal_tags").select("*").eq("deal_id",t).order("created_at");if(w)throw w;return b},enabled:!!t}),{data:d=[]}=wt({queryKey:["all-deal-tags",s],queryFn:async()=>{if(!s)return[];const{data:b,error:w}=await G.from("deal_tags").select("tag").eq("owner_user_id",s);if(w)throw w;return[...new Set(b.map(k=>k.tag))].sort()},enabled:!!s}),u=Dt({mutationFn:async b=>{if(!s)throw new Error("Not authenticated");const{error:w}=await G.from("deal_tags").insert({deal_id:t,owner_user_id:s,tag:b.trim()});if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]}),r.invalidateQueries({queryKey:["all-deal-tags"]}),a("")}}),p=Dt({mutationFn:async b=>{const{error:w}=await G.from("deal_tags").delete().eq("id",b);if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]})}}),f=()=>{const b=n.trim();b&&(i.some(w=>w.tag.toLowerCase()===b.toLowerCase())||u.mutate(b))},y=i.map(b=>b.tag.toLowerCase()),_=d.filter(b=>b.toLowerCase().includes(n.toLowerCase())&&!y.includes(b.toLowerCase())).slice(0,5);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[i.map(b=>e.jsxs(rt,{variant:"secondary",className:"gap-1 text-xs",children:[b.tag,e.jsx("button",{type:"button",onClick:()=>p.mutate(b.id),className:"ml-0.5 hover:text-destructive",children:e.jsx(Ur,{className:"h-3 w-3"})})]},b.id)),!o&&e.jsxs("button",{type:"button",onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground px-2 py-0.5 rounded border border-dashed border-border hover:border-primary transition-colors",children:[e.jsx(Zs,{className:"h-3 w-3"})," Add tag"]})]}),o&&e.jsxs("div",{className:"relative",children:[e.jsx(Re,{value:n,onChange:b=>a(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),f()),b.key==="Escape"&&(l(!1),a(""))},placeholder:"Type tag and press Enter...",className:"h-7 text-xs",autoFocus:!0,onBlur:()=>{n.trim()||l(!1)}}),n&&_.length>0&&e.jsx("div",{className:"absolute z-10 w-full mt-1 bg-background border rounded shadow-lg max-h-32 overflow-y-auto",children:_.map(b=>e.jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-left text-xs hover:bg-muted",onMouseDown:w=>{w.preventDefault(),u.mutate(b)},children:b},b))})]})]})}function ags(t){return wt({queryKey:["deal-files",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_files").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function igs(){const t=Ya(),s=rs();return Dt({mutationFn:async({dealId:r,file:n})=>{if(!t)throw new Error("Not authenticated");const a=n.name.split(".").pop(),o=`${t}/${r}/${crypto.randomUUID()}.${a}`,{error:l}=await G.storage.from("deal-files").upload(o,n);if(l)throw l;const{data:i,error:d}=await G.from("deal_files").insert({deal_id:r,owner_user_id:t,file_name:n.name,file_size:n.size,file_type:n.type||null,storage_path:o}).select().single();if(d)throw d;return i},onSuccess:(r,n)=>{s.invalidateQueries({queryKey:["deal-files",n.dealId]})}})}function ogs(){const t=rs();return Dt({mutationFn:async({fileId:s,storagePath:r,dealId:n})=>{await G.storage.from("deal-files").remove([r]);const{error:a}=await G.from("deal_files").delete().eq("id",s);if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-files",s]})}})}function lgs(){const t=rs();return Dt({mutationFn:async({fileId:s,visible:r,dealId:n})=>{const{error:a}=await G.from("deal_files").update({visible_on_portal:r}).eq("id",s);if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-files",s]})}})}async function cgs(t){const{data:s,error:r}=await G.storage.from("deal-files").createSignedUrl(t,3600);if(r)throw r;return s.signedUrl}const VLe={text:"Short Text",textarea:"Long Text",dropdown:"Dropdown",toggle:"Yes / No"};function dgs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=vps(),a=_ps(),o=bps(),l=wps(),[i,d]=C.useState(!1),[u,p]=C.useState({question_text:"",field_type:"text",options:[],is_required:!1}),[f,y]=C.useState(""),_=async()=>{if(u.question_text.trim())try{await a.mutateAsync({question_text:u.question_text.trim(),field_type:u.field_type,options:u.field_type==="dropdown"?u.options:[],is_required:u.is_required,sort_order:((r==null?void 0:r.length)||0)+1}),p({question_text:"",field_type:"text",options:[],is_required:!1}),y(""),d(!1),fe.success("Question added")}catch{fe.error("Failed to add question")}},b=async S=>{try{await l.mutateAsync(S),fe.success("Question removed")}catch{fe.error("Failed to remove question")}},w=async(S,T)=>{try{await o.mutateAsync({id:S,is_required:T})}catch{fe.error("Failed to update question")}},j=()=>{f.trim()&&(p(S=>({...S,options:[...S.options,f.trim()]})),y(""))},k=S=>{p(T=>({...T,options:T.options.filter((I,L)=>L!==S)}))};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-md max-h-[85vh] flex flex-col",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Custom Intake Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These questions appear on all your portal onboarding forms."})]}),e.jsx(Ri,{className:"flex-1",children:e.jsxs("div",{className:"space-y-3 pr-2",children:[n&&e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ms,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),r==null?void 0:r.map(S=>{var T;return e.jsx("div",{className:"border rounded-lg p-3 space-y-2",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Bu,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:S.question_text}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(rt,{variant:"secondary",className:"text-xs",children:VLe[S.field_type]||S.field_type}),S.is_required&&e.jsx(rt,{variant:"outline",className:"text-xs",children:"Required"})]}),S.field_type==="dropdown"&&((T=S.options)==null?void 0:T.length)>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Options: ",S.options.join(", ")]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(Br,{checked:S.is_required,onCheckedChange:I=>w(S.id,I),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>b(S.id),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]})},S.id)}),!n&&(r==null?void 0:r.length)===0&&!i&&e.jsxs("div",{className:"text-center py-8 border border-dashed rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"No custom questions yet"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add questions that clients will answer during onboarding."})]}),i&&e.jsxs("div",{className:"border-2 border-primary/20 rounded-lg p-4 space-y-3 bg-primary/5",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Question"}),e.jsx(Re,{value:u.question_text,onChange:S=>p(T=>({...T,question_text:S.target.value})),className:"mt-1",placeholder:"e.g., Do you have a home to sell first?",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Answer Type"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(VLe).map(([S,T])=>e.jsx("button",{type:"button",onClick:()=>p(I=>({...I,field_type:S,options:[]})),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${u.field_type===S?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:T},S))})]}),u.field_type==="dropdown"&&e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Options"}),e.jsxs("div",{className:"space-y-1.5 mt-1.5",children:[u.options.map((S,T)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex-1 text-sm bg-muted/50 rounded px-2 py-1",children:S}),e.jsx("button",{onClick:()=>k(T),className:"text-muted-foreground hover:text-destructive",children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]},T)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:f,onChange:S=>y(S.target.value),onKeyDown:S=>S.key==="Enter"&&(S.preventDefault(),j()),placeholder:"Add option...",className:"h-8 text-sm"}),e.jsx(K,{variant:"outline",size:"sm",onClick:j,disabled:!f.trim(),className:"h-8",children:e.jsx(Zs,{className:"h-3 w-3"})})]})]})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{checked:u.is_required,onCheckedChange:S=>p(T=>({...T,is_required:S}))}),e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Required"})]})}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>d(!1),className:"flex-1",children:"Cancel"}),e.jsxs(K,{size:"sm",onClick:_,disabled:!u.question_text.trim()||a.isPending,className:"flex-1",children:[a.isPending?e.jsx(Ms,{className:"h-3 w-3 mr-1 animate-spin"}):null,"Add Question"]})]})]})]})}),e.jsxs("div",{className:"flex justify-between pt-4 border-t shrink-0",children:[i?e.jsx("div",{}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>d(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Question"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s(!1),children:"Done"})]})]})})}function ugs({portalId:t,ownerId:s,clientEmail:r,linkedPortalId:n,onLink:a}){const[o,l]=C.useState(""),[i,d]=C.useState(!1),{data:u,isLoading:p}=wt({queryKey:["all-owner-portals",s],queryFn:async()=>{const{data:b,error:w}=await G.from("client_portals").select(` id, slug, client_name, client_email, deal_id, archived_at, deal_pipeline (id, deal_name, deal_type, property_address) `).eq("owner_user_id",s).neq("id",t).is("archived_at",null).eq("is_enabled",!0);if(w)throw w;return b},enabled:i||!!n}),f=C.useMemo(()=>!n||!u?null:u.find(b=>b.id===n),[n,u]),y=C.useMemo(()=>!u||!r?[]:u.filter(b=>{var w;return((w=b.client_email)==null?void 0:w.toLowerCase())===r.toLowerCase()&&b.id!==t}),[u,r,t]),_=C.useMemo(()=>{if(!u||!o.trim())return[];const b=o.toLowerCase();return u.filter(w=>{var k,S,T,I;const j=w.deal_pipeline;return((k=w.client_name)==null?void 0:k.toLowerCase().includes(b))||((S=w.client_email)==null?void 0:S.toLowerCase().includes(b))||((T=j==null?void 0:j.deal_name)==null?void 0:T.toLowerCase().includes(b))||((I=j==null?void 0:j.property_address)==null?void 0:I.toLowerCase().includes(b))})},[u,o]);if(n){const b=f==null?void 0:f.deal_pipeline;return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Linked Portal"}),e.jsxs("div",{className:"flex items-center gap-2 bg-primary/5 border border-primary/20 rounded-lg p-3",children:[e.jsx(Wo,{className:"h-4 w-4 text-primary shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:(f==null?void 0:f.client_name)||(b==null?void 0:b.deal_name)||"Linked Portal"}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[(b==null?void 0:b.deal_type)==="listing"?"🏠 Listing":"🔑 Purchase"," · ",(b==null?void 0:b.property_address)||"No address"]})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive shrink-0",onClick:()=>a(null),children:[e.jsx(gk,{className:"h-3 w-3 mr-1"}),"Unlink"]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Client will see both transactions in a tabbed view on one portal link."})]})}return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Link Another Transaction"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Combine buy + sell into one portal"})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>d(!i),children:[e.jsx(Wo,{className:"h-3 w-3 mr-1"}),i?"Cancel":"Link"]})]}),!i&&y.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground font-medium",children:"✨ Suggested match (same client email)"}),y.map(b=>{const w=b.deal_pipeline;return e.jsxs("button",{onClick:()=>a(b.id),className:"w-full flex items-center gap-2 bg-amber-50 border border-amber-200 rounded-lg p-2.5 hover:bg-amber-100 transition-colors text-left",children:[e.jsx(rt,{variant:"outline",className:"text-[10px] shrink-0 bg-amber-100 border-amber-300 text-amber-700",children:(w==null?void 0:w.deal_type)==="listing"?"Listing":"Purchase"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:(w==null?void 0:w.deal_name)||b.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:w==null?void 0:w.property_address})]}),e.jsx(Wo,{className:"h-3.5 w-3.5 text-amber-600 shrink-0"})]},b.id)})]}),i&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Re,{value:o,onChange:b=>l(b.target.value),placeholder:"Search by name, email, or address...",className:"pl-8 h-8 text-xs",autoFocus:!0})]}),p&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Ms,{className:"h-4 w-4 animate-spin text-muted-foreground"})}),_.length>0&&e.jsx("div",{className:"space-y-1 max-h-[200px] overflow-y-auto",children:_.map(b=>{const w=b.deal_pipeline;return e.jsxs("button",{onClick:()=>{a(b.id),d(!1),l("")},className:"w-full flex items-center gap-2 border rounded-lg p-2 hover:bg-muted/50 transition-colors text-left",children:[e.jsx(rt,{variant:"outline",className:"text-[10px] shrink-0",children:(w==null?void 0:w.deal_type)==="listing"?"Listing":"Purchase"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:(w==null?void 0:w.deal_name)||b.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:b.client_email})]})]},b.id)})}),o&&_.length===0&&!p&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No portals found"})]})]})}function G2e({userId:t,onSelect:s,triggerLabel:r="Library",triggerSize:n="sm",triggerVariant:a="outline",triggerClassName:o}){const[l,i]=C.useState(!1),[d,u]=C.useState([]),[p,f]=C.useState(!1),[y,_]=C.useState("");C.useEffect(()=>{!l||!t||(f(!0),G.from("agent_videos").select("id, title, recipient_name, playback_url, thumbnail_url, created_at, duration_seconds").eq("owner_user_id",t).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1}).limit(50).then(({data:w})=>{u(w||[]),f(!1)}))},[l,t]);const b=d.filter(w=>!y||(w.title||w.recipient_name||"").toLowerCase().includes(y.toLowerCase()));return e.jsxs(_s,{open:l,onOpenChange:i,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:a,size:n,className:o||"gap-1.5 shrink-0",children:[e.jsx(lu,{className:"h-3.5 w-3.5"}),r]})}),e.jsxs(vs,{className:"max-w-lg max-h-[70vh] flex flex-col",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Select from Video Library"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a video from your library"})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search videos...",value:y,onChange:w=>_(w.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-2 min-h-0",children:p?e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"h-16 w-full"}),e.jsx(xs,{className:"h-16 w-full"})]}):b.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:d.length===0?"No videos in your library yet":"No videos match your search"}):b.map(w=>e.jsxs("button",{onClick:()=>{s(w.playback_url||""),i(!1)},className:"w-full flex items-center gap-3 p-3 rounded-lg border border-border hover:border-primary/50 hover:bg-accent/50 transition-colors text-left",children:[e.jsx("div",{className:"w-16 h-10 rounded bg-muted flex items-center justify-center shrink-0 overflow-hidden",children:w.thumbnail_url?e.jsx("img",{src:w.thumbnail_url,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:j=>{const k=j.currentTarget.parentElement;if(k){j.currentTarget.remove();const S=document.createElement("span");S.innerHTML="🎬",S.className="text-lg",k.appendChild(S)}}}):e.jsx(Nn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:w.title||w.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[w.duration_seconds?`${Math.round(w.duration_seconds)}s`:"",w.created_at?` · ${new Date(w.created_at).toLocaleDateString()}`:""]})]})]},w.id))})]})]})}function K2e({contactId:t,onVideoReady:s}){const[r,n]=C.useState(!1),[a,o]=C.useState("record"),[l,i]=C.useState(0),[d,u]=C.useState(0),p=xS(),f=()=>{o("record"),i(0),u(0)},y=b=>{!b&&(a==="uploading"||a==="processing")||(n(b),b||f())},_=C.useCallback(async(b,w)=>{o("uploading");try{const j="Card Video",{videoId:k,libraryId:S}=await fD(j),{uploadUrl:T,apiKey:I}=await gD(k),L=new XMLHttpRequest;L.upload.onprogress=se=>{se.lengthComputable&&i(se.loaded/se.total*100)},await new Promise((se,te)=>{L.onload=()=>L.status>=200&&L.status<300?se():te(new Error("Upload failed")),L.onerror=()=>te(new Error("Upload failed")),L.open("PUT",T),L.setRequestHeader("AccessKey",I),L.send(b)}),o("processing");let R=0;const $=Date.now(),q=9e4,U=`https://iframe.mediadelivery.net/embed/${S}/${k}`;for(;R<4;){if(await new Promise(te=>setTimeout(te,3e3)),Date.now()-$>q){const te=b.size/1048576;await p.mutateAsync({bunny_video_id:k,playback_url:`https://iframe.mediadelivery.net/play/${S}/${k}`,file_size_mb:te,title:j,contact_id:t||void 0,status:"processing",touch_type:"video"}),s(U),fe.success("Video saved — still encoding. It will be ready shortly."),o("done"),setTimeout(()=>{n(!1),f()},1500);return}const se=await oM(k);if(R=se.status,u(se.encodeProgress||0),R===5||R===6)throw new Error("Video processing failed")}const H=await oM(k),Y=(H.storageSize||b.size)/(1024*1024);await p.mutateAsync({bunny_video_id:k,contact_id:t||void 0,playback_url:H.directPlayUrl||U,thumbnail_url:H.thumbnailUrl,preview_url:H.previewUrl||null,duration_seconds:H.length||w,file_size_mb:Y,title:j,status:"ready",touch_type:"video"}),s(U),fe.success("Video recorded & added to your library!"),o("done"),setTimeout(()=>{n(!1),f()},1500)}catch(j){console.error("Recording upload error:",j),fe.error("Failed to process video. Please try again."),o("record")}},[t,s,p]);return e.jsxs(_s,{open:r,onOpenChange:y,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 w-full",children:[e.jsx(Nn,{className:"h-3.5 w-3.5"}),"Record Video"]})}),e.jsxs(vs,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Record a Video for Your Card"})}),a==="record"&&e.jsx($ce,{maxDurationSeconds:60,onRecordingComplete:_,onError:b=>fe.error(b)}),a==="uploading"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(Ms,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Uploading video..."}),e.jsx(Ti,{value:l,className:"w-64"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(l),"%"]})]}),a==="processing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(Ms,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Processing video..."}),e.jsx(Ti,{value:d,className:"w-64"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(d),"%"]})]}),a==="done"&&e.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[e.jsx(hi,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium",children:"Video attached to your card!"})]})]})]})}function UJe({open:t,onOpenChange:s,portal:r,dealOwnerId:n}){const a=xD(),[o,l]=C.useState(!1),[i,d]=C.useState(r.next_step_text||""),[u,p]=C.useState(r.next_step_video_url||""),[f,y]=C.useState(r.inspection_date||""),[_,b]=C.useState(r.appraisal_date||""),[w,j]=C.useState(r.welcome_message||""),[k,S]=C.useState(r.review_url||""),[T,I]=C.useState(r.show_post_close_tips),[L,R]=C.useState(r.notify_client),[$,q]=C.useState(r.require_onboarding),[U,H]=C.useState(r.allow_spouse),[Y,se]=C.useState(r.visibility),[te,Q]=C.useState(r.stage_mapping||[]),[de,re]=C.useState(null),[ae,le]=C.useState(r.linked_portal_id||null),{data:he}=wt({queryKey:["pipeline-stages-for-portal",n],queryFn:async()=>{const{data:we,error:Me}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",n).order("sort_order",{ascending:!0});if(Me)throw Me;return we},enabled:t});C.useEffect(()=>{d(r.next_step_text||""),p(r.next_step_video_url||""),y(r.inspection_date||""),b(r.appraisal_date||""),j(r.welcome_message||""),S(r.review_url||""),I(r.show_post_close_tips),R(r.notify_client),q(r.require_onboarding),H(r.allow_spouse),se(r.visibility),Q(r.stage_mapping||[]),le(r.linked_portal_id||null)},[r]);const be=async()=>{try{await a.mutateAsync({id:r.id,next_step_text:i||null,next_step_video_url:u||null,inspection_date:f||null,appraisal_date:_||null,welcome_message:w||null,review_url:k||null,show_post_close_tips:T,notify_client:L,require_onboarding:$,allow_spouse:U,visibility:Y,stage_mapping:te.length>0?te:null,linked_portal_id:ae});const we=r.linked_portal_id;ae&&ae!==we&&await G.from("client_portals").update({linked_portal_id:r.id}).eq("id",ae),!ae&&we&&await G.from("client_portals").update({linked_portal_id:null}).eq("id",we),fe.success("Portal settings saved"),s(!1)}catch{fe.error("Failed to save settings")}},_e=()=>{Q([...te,{label:""}])},je=we=>{Q(te.filter((Me,Te)=>Te!==we)),de===we&&re(null)},Ne=(we,Me,Te)=>{const Fe=[...te];Fe[we]={...Fe[we],[Me]:Te},Q(Fe)},Ge=()=>{const Me=G_e(null).map(Te=>({label:Te.label,description:Te.description,stageId:void 0}));Q(Me)};return e.jsxs(e.Fragment,{children:[e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-lg max-h-[85vh] flex flex-col",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Portal Settings"})}),e.jsxs(ka,{defaultValue:"general",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(_a,{className:"grid grid-cols-3 shrink-0",children:[e.jsx(js,{value:"general",children:"General"}),e.jsx(js,{value:"timeline",children:"Timeline"}),e.jsx(js,{value:"content",children:"Content"})]}),e.jsxs(Ri,{className:"flex-1 mt-4",children:[e.jsxs(zs,{value:"general",className:"space-y-4 mt-0 px-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Visibility"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Public portals appear without restrictions"})]}),e.jsx("div",{className:"flex gap-1",children:["private","public"].map(we=>e.jsx("button",{onClick:()=>se(we),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${Y===we?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:we.charAt(0).toUpperCase()+we.slice(1)},we))})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Require Onboarding"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Clients must fill out intake form"})]}),e.jsx(Br,{checked:$,onCheckedChange:q})]}),$&&e.jsxs("div",{className:"flex items-center justify-between pl-4 border-l-2 border-primary/20",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Custom Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage intake form questions"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>l(!0),className:"text-xs",children:"Manage"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Allow Spouse/Partner"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show spouse fields on onboarding"})]}),e.jsx(Br,{checked:U,onCheckedChange:H})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Post-Close Celebration"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show congrats card when deal closes"})]}),e.jsx(Br,{checked:T,onCheckedChange:I})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Notify Client on Updates"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Email client when you post portal updates"})]}),e.jsx(Br,{checked:L,onCheckedChange:R})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx(ugs,{portalId:r.id,ownerId:n,clientEmail:r.client_email,linkedPortalId:ae,onLink:le})}),e.jsx("div",{children:e.jsx(Re,{type:"date",value:f,onChange:we=>y(we.target.value),className:"mt-1"})}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Appraisal Date"}),e.jsx(Re,{type:"date",value:_,onChange:we=>b(we.target.value),className:"mt-1"})]})]}),e.jsx(zs,{value:"timeline",className:"space-y-4 mt-0 px-1",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Client-Facing Stages"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Customize the client-friendly stage labels shown on the portal timeline"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:Ge,className:"text-xs",children:"Auto-map"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground bg-muted/50 rounded-md p-2",children:'💡 These labels are what clients see. Click "More" on any stage to customize its description and add a video link. Internal pipeline stages are automatically translated to friendly names.'}),te.length===0&&e.jsxs("div",{className:"border border-dashed rounded-lg p-4 text-center",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"No custom mapping — using default client-friendly journey stages"}),e.jsx(K,{variant:"outline",size:"sm",onClick:Ge,children:"Customize journey labels"})]}),e.jsx("div",{className:"space-y-2 mt-2",children:te.map((we,Me)=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bu,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"}),e.jsx(Re,{value:we.label,onChange:Te=>Ne(Me,"label",Te.target.value),placeholder:`Stage ${Me+1} label`,className:"flex-1 h-9 text-sm"}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-primary",onClick:()=>re(de===Me?null:Me),children:de===Me?"Less":"More"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 text-muted-foreground hover:text-destructive",onClick:()=>je(Me),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]}),de===Me&&e.jsxs("div",{className:"ml-6 space-y-2 pl-2 border-l-2 border-primary/15 pb-2",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Description"}),e.jsx("textarea",{value:we.description||"",onChange:Te=>Ne(Me,"description",Te.target.value),placeholder:"e.g. Now it's time to start actively looking at homes",className:"mt-0.5 w-full rounded-md border border-input bg-background px-3 py-2 text-xs min-h-[50px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Video"}),we.video_url?e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 text-xs text-muted-foreground truncate bg-muted/50 rounded px-2 py-1.5 border border-input",children:we.video_url.length>40?we.video_url.slice(0,40)+"...":we.video_url}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive hover:text-destructive",onClick:()=>Ne(Me,"video_url",""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(K2e,{onVideoReady:Te=>Ne(Me,"video_url",Te)}),e.jsx(G2e,{userId:n,onSelect:Te=>Ne(Me,"video_url",Te),triggerSize:"sm",triggerClassName:"gap-1.5 shrink-0 flex-1"}),e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const Te=prompt("Paste a YouTube or Loom URL:");Te&&Ne(Me,"video_url",Te)},children:[e.jsx(Do,{className:"h-3 w-3"}),"Paste URL"]})]})]})]})]},Me))}),te.length>0&&e.jsxs(K,{variant:"outline",size:"sm",onClick:_e,className:"mt-2 text-xs w-full",children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add Stage"]})]})}),e.jsxs(zs,{value:"content",className:"space-y-4 mt-0 px-1",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Welcome Message"}),e.jsx("textarea",{value:w,onChange:we=>j(we.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Welcome! Here's everything you need for your transaction."})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"What's Next"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Tell your client what to expect next"}),e.jsx("textarea",{value:i,onChange:we=>d(we.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"We're waiting on the inspection report..."})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Next Step Video (optional)"}),e.jsx(Re,{value:u,onChange:we=>p(we.target.value),className:"mt-1",placeholder:"YouTube or Loom URL"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Review URL"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Shown after deal closes"}),e.jsx(Re,{value:k,onChange:we=>S(we.target.value),className:"mt-1",placeholder:"https://g.page/r/..."})]})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t shrink-0",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:be,disabled:a.isPending,children:[a.isPending?e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(fu,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})}),e.jsx(dgs,{open:o,onOpenChange:l})]})}function VJe({open:t,onOpenChange:s,portalId:r,portalSlug:n,notifyClient:a}){const[o,l]=C.useState(""),[i,d]=C.useState(""),[u,p]=C.useState(""),[f,y]=C.useState(!1),[_,b]=C.useState(a??!1),w=kJe(),j=async()=>{if(o.trim())try{if(await w.mutateAsync({portal_id:r,title:o.trim(),content:i.trim()||void 0,video_url:u.trim()||void 0,is_stage_change:f}),_&&n)try{const k=Z0(n);await G.functions.invoke("send-portal-notification",{body:{portal_id:r,update_title:o.trim(),update_content:i.trim()||null,portal_url:k}}),fe.success("Update posted & client notified")}catch(k){console.error("Notification failed:",k),fe.success("Update posted (notification failed to send)")}else fe.success("Update posted to portal");l(""),d(""),p(""),y(!1),s(!1)}catch{fe.error("Failed to post update")}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Title *"}),e.jsx(Re,{value:o,onChange:k=>l(k.target.value),className:"mt-1",placeholder:"Inspection cleared!"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Message"}),e.jsx("textarea",{value:i,onChange:k=>d(k.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[80px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Everything looked great during the inspection..."})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Video URL (optional)"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(Re,{value:u,onChange:k=>p(k.target.value),className:"pl-9",placeholder:"YouTube or Loom link"}),e.jsx(Nn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>y(!f),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${f?"bg-emerald-500/10 text-emerald-700 border-emerald-200":"bg-background text-muted-foreground border-input"}`,children:"📊 Stage Change"}),e.jsxs("button",{type:"button",onClick:()=>b(!_),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors flex items-center gap-1.5 ${_?"bg-blue-500/10 text-blue-700 border-blue-200":"bg-background text-muted-foreground border-input"}`,children:[_?e.jsx(gf,{className:"h-3 w-3"}):e.jsx(r_,{className:"h-3 w-3"}),_?"Notify Client":"No Notification"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:j,disabled:!o.trim()||w.isPending,children:[w.isPending?e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(aa,{className:"h-4 w-4 mr-2"}),"Post Update"]})]})]})})}function HJe({open:t,onOpenChange:s,portal:r,dealName:n}){const a=xD(),{isGmailConnected:o,gmailEmail:l}=Ny(),[i,d]=C.useState(r.client_name||""),[u,p]=C.useState(r.client_email||""),[f,y]=C.useState(!1),[_,b]=C.useState(!1),w=Z0(r.slug),j=i.split(" ")[0]||"there",k=`Your Transaction Portal – ${n}`,S=`Hi ${j}, I've set up a dedicated portal where you can track the progress of your transaction in real-time. Here's your link: ${w} You can view your timeline, key dates, documents, and any updates I post along the way. Let me know if you have any questions!`,T=()=>{navigator.clipboard.writeText(w),b(!0),setTimeout(()=>b(!1),2e3),fe.success("Portal link copied!")},I=async()=>{if(!u.trim()){fe.error("Please enter the client email");return}y(!0);try{await a.mutateAsync({id:r.id,client_name:i||null,client_email:u||null,invite_sent_at:new Date().toISOString(),invite_method:"email"});const{error:R}=await G.functions.invoke("gmail-send",{body:{to:u,subject:k,body:S.replace(/\n/g,"
")}});if(R)throw R;fe.success(`Invite sent to ${u}`),s(!1)}catch(R){fe.error(R.message||"Failed to send invite")}finally{y(!1)}},L=()=>{const R=encodeURIComponent(k),$=encodeURIComponent(S);window.open(`mailto:${u}?subject=${R}&body=${$}`,"_blank"),a.mutateAsync({id:r.id,client_name:i||null,client_email:u||null,invite_sent_at:new Date().toISOString(),invite_method:"email"}).catch(()=>{})};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Invite Client to Portal"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Client Name"}),e.jsx(Re,{value:i,onChange:R=>d(R.target.value),className:"mt-1",placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Client Email"}),e.jsx(Re,{type:"email",value:u,onChange:R=>p(R.target.value),className:"mt-1",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Portal Link"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 bg-muted/50 rounded-md px-3 py-2",children:e.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:w})}),e.jsx(K,{variant:"outline",size:"icon",onClick:T,className:"shrink-0",children:_?e.jsx(ha,{className:"h-4 w-4 text-emerald-600"}):e.jsx(ai,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[o?e.jsxs(K,{onClick:I,disabled:f||!u.trim(),className:"w-full",children:[f?e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(br,{className:"h-4 w-4 mr-2"}),"Send via Gmail (",l,")"]}):e.jsxs(K,{onClick:L,disabled:!u.trim(),className:"w-full",variant:"outline",children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Open in Email App"]}),e.jsxs(K,{variant:"ghost",onClick:T,className:"w-full text-muted-foreground",children:[e.jsx(ai,{className:"h-4 w-4 mr-2"}),"Just Copy Link"]})]})]})]})})}function hgs({deal:t}){const{isAdmin:s,user:r}=Hs(),{data:n,isLoading:a}=fps(t.id),o=U2e(),l=xD(),[i,d]=C.useState(!1),[u,p]=C.useState(!1),[f,y]=C.useState(!1),[_,b]=C.useState(!1);if(a)return e.jsx("div",{className:"border rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(Ms,{className:"h-3 w-3 animate-spin ml-auto"})]})});const w=async()=>{var L,R;d(!0);try{await o.mutateAsync({deal_id:t.id,visibility:"private",require_onboarding:!0,client_name:t.contact?`${t.contact.first_name} ${t.contact.last_name}`:void 0,client_email:((L=t.contact)==null?void 0:L.email)||void 0,client_phone:((R=t.contact)==null?void 0:R.phone)||void 0}),fe.success("Client portal enabled!")}catch{fe.error("Failed to create portal")}finally{d(!1)}},j=async L=>{if(n)try{await l.mutateAsync({id:n.id,is_enabled:L}),fe.success(L?"Portal enabled":"Portal disabled")}catch{fe.error("Failed to update portal")}},k=()=>{if(!n)return;const L=Z0(n.slug);navigator.clipboard.writeText(L),fe.success("Portal link copied!")},S=()=>{if(!n)return;const L=Z0(n.slug);window.open(L,"_blank")};if(!n)return e.jsxs("div",{className:"border rounded-lg p-4 border-dashed",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Create a beautiful portal so your client can track their deal progress in real-time."}),e.jsxs(K,{onClick:w,disabled:i,size:"sm",className:"w-full",children:[i?e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Enable Client Portal"]})]});const T=Z0(n.slug),I=(r==null?void 0:r.id)||"";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(rt,{variant:"outline",className:n.is_enabled?"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-xs bg-muted text-muted-foreground",children:n.is_enabled?"Active":"Disabled"})]}),e.jsx(Br,{checked:n.is_enabled,onCheckedChange:j})]}),e.jsxs("div",{className:"space-y-1.5 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Visibility:"}),e.jsx(rt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:n.visibility==="private"?"Private":"Public"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Onboarding:"}),e.jsx("span",{className:"text-foreground",children:n.require_onboarding?"Required":"Disabled"})]}),n.client_name&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Client:"}),e.jsx("span",{className:"text-foreground",children:n.client_name})]})]}),e.jsx("div",{className:"bg-muted/50 rounded-md p-2 mb-3",children:e.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:T})}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:k,className:"text-xs flex-1 min-w-0",children:[e.jsx(ai,{className:"h-3 w-3 mr-1 shrink-0"}),"Copy"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:S,className:"text-xs flex-1 min-w-0",children:[e.jsx(sn,{className:"h-3 w-3 mr-1 shrink-0"}),"Preview"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>b(!0),className:"text-xs flex-1 min-w-0",children:[e.jsx(aa,{className:"h-3 w-3 mr-1 shrink-0"}),"Invite"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>y(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(k5,{className:"h-3 w-3 mr-1 shrink-0"}),"Post Update"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>p(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx($l,{className:"h-3 w-3 mr-1 shrink-0"}),"Settings"]})]})]}),e.jsx(UJe,{open:u,onOpenChange:p,portal:n,dealOwnerId:I}),e.jsx(VJe,{open:f,onOpenChange:y,portalId:n.id,portalSlug:n.slug,notifyClient:n.notify_client}),e.jsx(HJe,{open:_,onOpenChange:b,portal:n,dealName:t.deal_name})]})}const mgs=["Client","Co-Buyer","Co-Seller","Spouse","Lender","Title Company","Inspector","Appraiser","Attorney","Contractor","Other"];function pgs(t){return wt({queryKey:["deal-contacts",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_contacts").select(` id, deal_id, contact_id, role, created_at, contact:innercircle_contacts(id, first_name, last_name, email, phone) `).eq("deal_id",t).order("created_at");if(r)throw r;return s||[]},enabled:!!t})}function fgs(){const t=rs();return Dt({mutationFn:async({dealId:s,contactId:r,role:n})=>{const{data:a,error:o}=await G.from("deal_contacts").insert({deal_id:s,contact_id:r,role:n}).select().single();if(o)throw o;return a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-contacts",r.dealId]}),fe.success("Contact linked to deal")},onError:s=>{var r;(r=s.message)!=null&&r.includes("duplicate")?fe.error("This contact is already linked to this deal"):fe.error("Failed to link contact")}})}function ggs(){const t=rs();return Dt({mutationFn:async({id:s,dealId:r})=>{const{error:n}=await G.from("deal_contacts").delete().eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-contacts",r.dealId]}),fe.success("Contact removed from deal")},onError:()=>{fe.error("Failed to remove contact")}})}function xgs({dealId:t,primaryContactId:s}){const r=Pr(),{data:n,isLoading:a}=pgs(t),{data:o}=tm(),l=fgs(),i=ggs(),[d,u]=C.useState(!1),[p,f]=C.useState(""),[y,_]=C.useState("Client"),b=new Set((n==null?void 0:n.map(T=>T.contact_id))||[]);s&&b.add(s);const w=o==null?void 0:o.filter(T=>{var L,R,$;if(b.has(T.id))return!1;if(!p.trim())return!0;const I=p.toLowerCase();return((L=T.first_name)==null?void 0:L.toLowerCase().includes(I))||((R=T.last_name)==null?void 0:R.toLowerCase().includes(I))||(($=T.email)==null?void 0:$.toLowerCase().includes(I))}).slice(0,8),j=T=>{l.mutate({dealId:t,contactId:T,role:y}),u(!1),f("")},k=T=>{i.mutate({id:T,dealId:t})},S={Client:"bg-primary/10 text-primary","Co-Buyer":"bg-blue-500/10 text-blue-600","Co-Seller":"bg-emerald-500/10 text-emerald-600",Spouse:"bg-pink-500/10 text-pink-600",Lender:"bg-amber-500/10 text-amber-600","Title Company":"bg-purple-500/10 text-purple-600",Inspector:"bg-orange-500/10 text-orange-600",Appraiser:"bg-cyan-500/10 text-cyan-600",Attorney:"bg-slate-500/10 text-slate-600",Contractor:"bg-lime-500/10 text-lime-600",Other:"bg-muted text-muted-foreground"};return!(n!=null&&n.length)&&!d?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Additional Contacts"]})}),e.jsxs(Co,{open:d,onOpenChange:u,children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"w-full text-muted-foreground",children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"}),"Link a contact (lender, spouse, vendor...)"]})}),e.jsx(No,{className:"w-80 p-3",align:"start",children:e.jsx(HLe,{search:p,setSearch:f,selectedRole:y,setSelectedRole:_,filteredContacts:w,onAdd:j})})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Linked Contacts",n&&n.length>0&&e.jsx(rt,{variant:"secondary",className:"text-[10px] px-1.5",children:n.length})]}),e.jsxs(Co,{open:d,onOpenChange:u,children:[e.jsx(Mo,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx(Zs,{className:"h-3.5 w-3.5"})})}),e.jsx(No,{className:"w-80 p-3",align:"end",children:e.jsx(HLe,{search:p,setSearch:f,selectedRole:y,setSelectedRole:_,filteredContacts:w,onAdd:j})})]})]}),e.jsx("div",{className:"space-y-1.5",children:n==null?void 0:n.map(T=>{var I,L,R,$,q,U,H,Y;return e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-muted/40 group",children:[e.jsx(xn,{className:"h-7 w-7",children:e.jsxs(yn,{className:"text-[10px] bg-primary/10 text-primary",children:[(L=(I=T.contact)==null?void 0:I.first_name)==null?void 0:L[0],($=(R=T.contact)==null?void 0:R.last_name)==null?void 0:$[0]]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("button",{onClick:()=>r(`/mission-control/contacts/${T.contact_id}`),className:"text-sm font-medium hover:underline text-primary truncate block",children:[(q=T.contact)==null?void 0:q.first_name," ",(U=T.contact)==null?void 0:U.last_name]})}),e.jsx(rt,{variant:"outline",className:`text-[10px] px-1.5 py-0 shrink-0 ${S[T.role]||S.Other}`,children:T.role}),e.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[((H=T.contact)==null?void 0:H.phone)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`tel:${T.contact.phone}`,children:e.jsx(Qn,{className:"h-3 w-3"})})}),((Y=T.contact)==null?void 0:Y.email)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`mailto:${T.contact.email}`,children:e.jsx(br,{className:"h-3 w-3"})})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>k(T.id),children:e.jsx(jr,{className:"h-3 w-3"})})]})]},T.id)})})]})}function HLe({search:t,setSearch:s,selectedRole:r,setSelectedRole:n,filteredContacts:a,onAdd:o}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs(sr,{value:r,onValueChange:n,children:[e.jsx(er,{className:"h-8 text-sm",children:e.jsx(rr,{placeholder:"Role"})}),e.jsx(tr,{children:mgs.map(l=>e.jsx(At,{value:l,children:l},l))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Re,{value:t,onChange:l=>s(l.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(Ri,{className:"max-h-40",children:a&&a.length>0?e.jsx("div",{className:"space-y-0.5",children:a.map(l=>e.jsxs("button",{onClick:()=>o(l.id),className:"w-full text-left px-2 py-1.5 rounded hover:bg-accent transition-colors",children:[e.jsxs("div",{className:"text-sm font-medium truncate",children:[l.first_name," ",l.last_name]}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:[l.phone,l.email].filter(Boolean).join(" · ")||"No contact info"})]},l.id))}):e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:t?"No contacts found":"Type to search"})})]})}const ygs={buyer:{label:"Buyer",color:"bg-blue-500/10 text-blue-600 border-blue-200"},seller:{label:"Seller",color:"bg-emerald-500/10 text-emerald-600 border-emerald-200"},dual:{label:"Dual",color:"bg-purple-500/10 text-purple-600 border-purple-200"},referral:{label:"Referral",color:"bg-orange-500/10 text-orange-600 border-orange-200"},lease:{label:"Lease",color:"bg-cyan-500/10 text-cyan-600 border-cyan-200"}},vgs={note:io,call:Qn,email:br,meeting:on,stage_change:sn,task_completed:ua,document:On,system:Tn};function _gs({deal:t,open:s,onOpenChange:r,onEdit:n,onAddToScorecard:a,isWonStage:o}){var Te,Fe;const{data:l,isLoading:i}=afs((t==null?void 0:t.id)||""),{data:d,isLoading:u}=ofs((t==null?void 0:t.id)||""),p=ifs(),f=cfs(),y=lfs(),_=nfs(),{data:b,isLoading:w}=ags((t==null?void 0:t.id)||""),j=igs(),k=ogs(),S=lgs(),T=C.useRef(null),[I,L]=C.useState(""),[R,$]=C.useState(""),[q,U]=C.useState(!1),[H,Y]=C.useState(!1);if(!t)return null;const se=ygs[t.deal_type],te=(()=>{var ut;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const Ae=((ut=t.listing)==null?void 0:ut.created_at)||t.listing_date;if(!Ae)return null;const Ue=t.contract_date?gl(t.contract_date):new Date;return Qg(Ue,gl(Ae))})(),Q=Ae=>Ae?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Ae):"-",de=async()=>{if(I.trim())try{await p.mutateAsync({deal_id:t.id,activity_type:"note",title:"Note added",description:I}),L(""),fe.success("Note added")}catch{fe.error("Failed to add note")}},re=async()=>{if(R.trim())try{await f.mutateAsync({deal_id:t.id,title:R,sort_order:((d==null?void 0:d.length)||0)+1}),$(""),fe.success("Task added")}catch{fe.error("Failed to add task")}},ae=async(Ae,Ue)=>{try{await y.mutateAsync({id:Ae,is_completed:Ue,deal_id:t.id})}catch{fe.error("Failed to update task")}},le=async()=>{try{await _.mutateAsync(t.id),fe.success("Deal deleted"),r(!1)}catch{fe.error("Failed to delete deal")}},he=(d==null?void 0:d.filter(Ae=>Ae.is_completed).length)||0,be=(d==null?void 0:d.length)||0,_e=(b==null?void 0:b.length)||0,je=Ae=>Ae<1024?`${Ae} B`:Ae<1024*1024?`${(Ae/1024).toFixed(1)} KB`:`${(Ae/(1024*1024)).toFixed(1)} MB`,Ne=Ae=>Ae?Ae.startsWith("image/")?Jo:Ae.includes("pdf")?In:g5:g5,Ge=async Ae=>{const Ue=Ae.target.files;if(!(!Ue||!t)){Y(!0);try{for(const ut of Array.from(Ue)){if(ut.size>20*1024*1024){fe.error(`${ut.name} exceeds 20MB limit`);continue}await j.mutateAsync({dealId:t.id,file:ut})}fe.success("File(s) uploaded")}catch{fe.error("Failed to upload file")}finally{Y(!1),T.current&&(T.current.value="")}}},we=async(Ae,Ue)=>{if(t)try{await k.mutateAsync({fileId:Ae,storagePath:Ue,dealId:t.id}),fe.success("File deleted")}catch{fe.error("Failed to delete file")}},Me=async(Ae,Ue)=>{try{const ut=await cgs(Ae),De=document.createElement("a");De.href=ut,De.download=Ue,De.target="_blank",document.body.appendChild(De),De.click(),document.body.removeChild(De)}catch{fe.error("Failed to download file")}};return e.jsxs(e.Fragment,{children:[e.jsx(MM,{open:s,onOpenChange:r,children:e.jsxs(cS,{className:"w-full sm:max-w-xl p-0 flex flex-col",children:[e.jsx(TM,{className:"p-6 pb-4 border-b shrink-0",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(rt,{variant:"outline",className:Pt("text-xs",se.color),children:se.label}),e.jsxs(rt,{variant:"secondary",className:"text-xs capitalize",children:[t.priority," priority"]})]}),e.jsx(AM,{className:"text-xl",children:t.deal_name}),e.jsx("div",{className:"mt-2",children:e.jsx(ngs,{dealId:t.id})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>n(t),children:e.jsx(Rc,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"text-destructive hover:bg-destructive/10",onClick:()=>U(!0),children:e.jsx(jr,{className:"h-4 w-4"})})]})]})}),e.jsx(Ri,{className:"flex-1",children:e.jsxs("div",{className:"p-6 space-y-6",children:[t.contact&&e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(xn,{className:"h-10 w-10",children:e.jsxs(yn,{className:"bg-primary/10 text-primary",children:[(Te=t.contact.first_name)==null?void 0:Te[0],(Fe=t.contact.last_name)==null?void 0:Fe[0]]})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"font-medium",children:[t.contact.first_name," ",t.contact.last_name]}),t.contact.email&&e.jsx("p",{className:"text-sm text-muted-foreground",children:t.contact.email})]}),e.jsxs("div",{className:"flex gap-2",children:[t.contact.phone&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`tel:${t.contact.phone}`,children:e.jsx(Qn,{className:"h-4 w-4"})})}),t.contact.email&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`mailto:${t.contact.email}`,children:e.jsx(br,{className:"h-4 w-4"})})})]})]}),e.jsx(xgs,{dealId:t.id,primaryContactId:t.contact_id}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[(t.property_address||t.city)&&e.jsxs("div",{className:"col-span-2 flex items-start gap-2 text-sm",children:[e.jsx(On,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t.property_address||"Address TBD"}),e.jsx("p",{className:"text-muted-foreground",children:[t.city,t.state,t.zip_code].filter(Boolean).join(", ")})]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected Price"}),e.jsx("p",{className:"text-lg font-bold",children:Q(t.expected_price)})]}),e.jsxs("div",{className:"bg-emerald-500/10 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected GCI"}),e.jsx("p",{className:"text-lg font-bold text-emerald-600",children:Q(t.expected_commission)})]}),(t.brokerage_split_pct||t.team_split_pct||t.referral_fee_pct||t.franchise_fee_pct||t.transaction_fee)&&e.jsxs("div",{className:"col-span-2 bg-muted/30 rounded-lg p-3 space-y-1.5",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Commission Splits"}),t.brokerage_split_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Brokerage Split"}),e.jsxs("span",{children:[t.brokerage_split_pct,"%",t.expected_commission?` (${Q(t.expected_commission*t.brokerage_split_pct/100)})`:""]})]}),t.team_split_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Team Split"}),e.jsxs("span",{children:[t.team_split_pct,"%"]})]}),t.referral_fee_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Referral Fee"}),e.jsxs("span",{children:[t.referral_fee_pct,"%"]})]}),t.franchise_fee_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Franchise Fee"}),e.jsxs("span",{children:[t.franchise_fee_pct,"%"]})]}),t.transaction_fee!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Transaction Fee"}),e.jsx("span",{children:Q(t.transaction_fee)})]}),t.net_commission!=null&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"border-t pt-1.5 mt-1.5",children:e.jsxs("div",{className:"flex justify-between text-sm font-semibold",children:[e.jsx("span",{children:"Net to Agent"}),e.jsx("span",{className:"text-emerald-600",children:Q(t.net_commission)})]})})})]}),o&&!t.scorecard_transaction_id&&a&&e.jsxs(K,{onClick:()=>a(t),className:"w-full bg-green-600 hover:bg-green-700",children:[e.jsx(ao,{className:"h-4 w-4 mr-2"}),"Add to Scorecard"]}),t.scorecard_transaction_id&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground bg-muted/50 rounded-lg p-3",children:[e.jsx(ua,{className:"h-4 w-4 text-green-600"}),e.jsx("span",{children:"Synced to Scorecard"})]}),te!==null&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 col-span-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Days on Market"}),e.jsxs("p",{className:Pt("text-lg font-bold",te>90?"text-red-600":te>60?"text-amber-600":"text-foreground"),children:[te," ",t.contract_date?"(final)":"days"]})]}),t.target_close_date&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(on,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Close: ",ys(gl(t.target_close_date),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(od,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:[t.probability,"% probability"]})]})]}),t.notes&&e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium mb-1",children:"Notes"}),e.jsx("p",{className:"text-muted-foreground",children:t.notes})]}),e.jsx(hgs,{deal:t}),e.jsxs(ka,{defaultValue:"tasks",className:"w-full",children:[e.jsxs(_a,{className:"w-full grid grid-cols-3",children:[e.jsxs(js,{value:"tasks",className:"gap-1",children:[e.jsx(ua,{className:"h-4 w-4"}),"Tasks ",be>0&&`(${he}/${be})`]}),e.jsxs(js,{value:"files",className:"gap-1",children:[e.jsx(mk,{className:"h-4 w-4"}),"Files ",_e>0&&`(${_e})`]}),e.jsxs(js,{value:"activity",className:"gap-1",children:[e.jsx(Tn,{className:"h-4 w-4"}),"Activity"]})]}),e.jsxs(zs,{value:"tasks",className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"Add a new task...",value:R,onChange:Ae=>$(Ae.target.value),onKeyDown:Ae=>Ae.key==="Enter"&&re()}),e.jsx(K,{onClick:re,disabled:!R.trim(),children:e.jsx(Zs,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[d==null?void 0:d.map(Ae=>e.jsxs("div",{className:Pt("flex items-center gap-3 p-3 rounded-lg border transition-colors",Ae.is_completed?"bg-muted/50 border-border":"bg-background"),children:[e.jsx(Bo,{checked:Ae.is_completed,onCheckedChange:Ue=>ae(Ae.id,!!Ue)}),e.jsx("span",{className:Pt("flex-1 text-sm",Ae.is_completed&&"line-through text-muted-foreground"),children:Ae.title}),Ae.due_date&&e.jsx("span",{className:"text-xs text-muted-foreground",children:ys(new Date(Ae.due_date),"MMM d")})]},Ae.id)),(d==null?void 0:d.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No tasks yet. Add one above!"})]})]}),e.jsxs(zs,{value:"files",className:"mt-4 space-y-3",children:[e.jsx("input",{type:"file",ref:T,className:"hidden",multiple:!0,onChange:Ge,accept:".pdf,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.webp,.gif,.txt,.csv"}),e.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:()=>{var Ae;return(Ae=T.current)==null?void 0:Ae.click()},disabled:H,children:[H?e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Za,{className:"h-4 w-4 mr-2"}),H?"Uploading...":"Upload Files"]}),e.jsxs("div",{className:"space-y-2",children:[b==null?void 0:b.map(Ae=>{const Ue=Ne(Ae.file_type);return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-background",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center shrink-0",children:e.jsx(Ue,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:Ae.file_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[je(Ae.file_size)," · ",ys(new Date(Ae.created_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(U_,{children:e.jsxs(Wc,{children:[e.jsx(Gc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:`h-8 w-8 transition-colors ${Ae.visible_on_portal?"text-primary bg-primary/10 hover:bg-primary/20":"text-muted-foreground/40 hover:text-muted-foreground"}`,onClick:()=>S.mutate({fileId:Ae.id,visible:!Ae.visible_on_portal,dealId:t.id}),children:Ae.visible_on_portal?e.jsx(xa,{className:"h-4 w-4"}):e.jsx(Im,{className:"h-4 w-4"})})}),e.jsx(Cc,{side:"top",children:Ae.visible_on_portal?"Visible on client portal":"Hidden from client portal"})]})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Me(Ae.storage_path,Ae.file_name),children:e.jsx(xi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>we(Ae.id,Ae.storage_path),children:e.jsx(Ur,{className:"h-4 w-4"})})]})]},Ae.id)}),(b==null?void 0:b.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No files yet. Upload contracts, disclosures, or other documents."})]})]}),e.jsxs(zs,{value:"activity",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ar,{placeholder:"Add a note...",value:I,onChange:Ae=>L(Ae.target.value),rows:2}),e.jsxs(K,{onClick:de,disabled:!I.trim(),size:"sm",className:"w-full",children:[e.jsx(aa,{className:"h-4 w-4 mr-2"}),"Add Note"]})]}),e.jsxs("div",{className:"space-y-3",children:[l==null?void 0:l.map(Ae=>{const Ue=vgs[Ae.activity_type]||Tn;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center shrink-0",children:e.jsx(Ue,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:Ae.title}),Ae.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:Ae.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Sd(new Date(Ae.created_at),{addSuffix:!0})})]})]},Ae.id)}),(l==null?void 0:l.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No activity yet"})]})]})]})]})})]})}),e.jsx(nc,{open:q,onOpenChange:U,children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete Deal?"}),e.jsxs(Dl,{children:['This will permanently delete "',t.deal_name,'" and all associated data. This action cannot be undone.']})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:le,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function bgs({open:t,onOpenChange:s,deal:r,onComplete:n}){const a=mle(),o=RJe(),{data:l}=EM(),{data:i}=Rf(),[d,u]=C.useState({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:ys(new Date,"yyyy-MM-dd"),sale_price:0,commission_amount:0,lead_source_id:"",client_type_id:"",notes:""});C.useEffect(()=>{if(r&&t){const y=r.deal_type==="seller"?"seller":"buyer",_=r.expected_price||0,b=r.commission_percentage||3,w=r.expected_commission||_*b/100;u({property_address:r.property_address||r.deal_name||"",city:r.city||"",state:r.state||"",zip:r.zip_code||"",transaction_type:y,close_date:r.actual_close_date||r.target_close_date||ys(new Date,"yyyy-MM-dd"),sale_price:_,commission_amount:w,lead_source_id:"",client_type_id:"",notes:r.notes||""})}},[r,t]);const p=async y=>{if(y.preventDefault(),!!r)try{const _=await a.mutateAsync({property_address:d.property_address,city:d.city||null,state:d.state||null,zip:d.zip||null,transaction_type:d.transaction_type,close_date:d.close_date,sale_price:d.sale_price,commission_amount:d.commission_amount||null,brokerage_split_pct:r.brokerage_split_pct||null,team_split_pct:r.team_split_pct||null,franchise_fee_pct:r.franchise_fee_pct||null,referral_fee_pct:r.referral_fee_pct||null,transaction_fee:r.transaction_fee||null,lead_source_id:d.lead_source_id||null,client_type_id:d.client_type_id||null,contact_id:r.contact_id||null,notes:d.notes||null,is_win:!0});await o.mutateAsync({id:r.id,scorecard_transaction_id:_.id,actual_close_date:d.close_date}),fe.success("Deal added to Scorecard! 🎉"),s(!1),n==null||n()}catch(_){console.error("Error syncing to scorecard:",_),fe.error("Failed to add to scorecard")}},f=y=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(y);return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-[550px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{className:"space-y-3",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-green-100 dark:bg-green-900/20",children:e.jsx(ao,{className:"h-6 w-6 text-green-600 dark:text-green-400"})}),e.jsx(ks,{className:"text-center text-xl",children:"Congratulations on Closing! 🎉"}),e.jsx(Kr,{className:"text-center",children:"Review and confirm the details before adding this deal to your Scorecard."})]}),e.jsxs("form",{onSubmit:p,className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"property_address",className:"flex items-center gap-2",children:[e.jsx(On,{className:"h-4 w-4 text-muted-foreground"}),"Property Address *"]}),e.jsx(Re,{id:"property_address",value:d.property_address,onChange:y=>u(_=>({..._,property_address:y.target.value})),placeholder:"123 Main St",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"city",children:"City"}),e.jsx(Re,{id:"city",value:d.city,onChange:y=>u(_=>({..._,city:y.target.value})),placeholder:"City"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"state",children:"State"}),e.jsx(Re,{id:"state",value:d.state,onChange:y=>u(_=>({..._,state:y.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"zip",children:"Zip"}),e.jsx(Re,{id:"zip",value:d.zip,onChange:y=>u(_=>({..._,zip:y.target.value})),placeholder:"75001"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Transaction Type *"}),e.jsxs(sr,{value:d.transaction_type,onValueChange:y=>u(_=>({..._,transaction_type:y})),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"buyer",children:"Buyer"}),e.jsx(At,{value:"seller",children:"Seller"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"close_date",className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4 text-muted-foreground"}),"Close Date *"]}),e.jsx(Re,{id:"close_date",type:"date",value:d.close_date,onChange:y=>u(_=>({..._,close_date:y.target.value})),required:!0})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"sale_price",className:"flex items-center gap-2",children:[e.jsx(od,{className:"h-4 w-4 text-muted-foreground"}),"Sale Price *"]}),e.jsx(Re,{id:"sale_price",type:"number",value:d.sale_price||"",onChange:y=>u(_=>({..._,sale_price:Number(y.target.value)})),placeholder:"450000",required:!0,min:0}),d.sale_price>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:f(d.sale_price)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"commission_amount",className:"flex items-center gap-2",children:[e.jsx(S5,{className:"h-4 w-4 text-muted-foreground"}),"GCI (Commission)"]}),e.jsx(Re,{id:"commission_amount",type:"number",value:d.commission_amount||"",onChange:y=>u(_=>({..._,commission_amount:Number(y.target.value)})),placeholder:"13500",min:0}),d.commission_amount>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:f(d.commission_amount)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Lead Source"}),e.jsxs(sr,{value:d.lead_source_id,onValueChange:y=>u(_=>({..._,lead_source_id:y})),children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select source"})}),e.jsx(tr,{children:l==null?void 0:l.map(y=>e.jsx(At,{value:y.id,children:y.name},y.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Client Type"}),e.jsxs(sr,{value:d.client_type_id,onValueChange:y=>u(_=>({..._,client_type_id:y})),children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select type"})}),e.jsx(tr,{children:i==null?void 0:i.map(y=>e.jsx(At,{value:y.id,children:y.name},y.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"notes",children:"Notes"}),e.jsx(Ar,{id:"notes",value:d.notes,onChange:y=>u(_=>({..._,notes:y.target.value})),placeholder:"Any additional notes about this transaction...",rows:2})]}),e.jsxs(Un,{className:"gap-2 sm:gap-0 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Skip for now"}),e.jsx(K,{type:"submit",disabled:a.isPending||o.isPending,className:"bg-green-600 hover:bg-green-700",children:a.isPending?"Adding...":e.jsxs(e.Fragment,{children:["Add to Scorecard",e.jsx($i,{className:"ml-2 h-4 w-4"})]})})]})]})]})})}const wgs={buyer:{label:"Buyer",color:"bg-blue-500/10 text-blue-600 border-blue-200"},seller:{label:"Seller",color:"bg-emerald-500/10 text-emerald-600 border-emerald-200"},dual:{label:"Dual",color:"bg-purple-500/10 text-purple-600 border-purple-200"},referral:{label:"Referral",color:"bg-orange-500/10 text-orange-600 border-orange-200"},lease:{label:"Lease",color:"bg-cyan-500/10 text-cyan-600 border-cyan-200"}},WLe={urgent:0,high:1,medium:2,low:3};function jgs({deals:t,stages:s,onDealClick:r,onStageChange:n}){const[a,o]=C.useState("target_close_date"),[l,i]=C.useState("asc"),d=_=>{a===_?i(b=>b==="asc"?"desc":"asc"):(o(_),i("asc"))},u=C.useMemo(()=>[...t].sort((_,b)=>{var j,k;let w=0;switch(a){case"deal_name":w=_.deal_name.localeCompare(b.deal_name);break;case"stage":{const S=((j=s.find(I=>I.id===_.stage_id))==null?void 0:j.sort_order)||0,T=((k=s.find(I=>I.id===b.stage_id))==null?void 0:k.sort_order)||0;w=S-T;break}case"expected_price":w=(_.expected_price||0)-(b.expected_price||0);break;case"expected_commission":w=(_.expected_commission||0)-(b.expected_commission||0);break;case"target_close_date":{const S=_.target_close_date?gl(_.target_close_date).getTime():1/0,T=b.target_close_date?gl(b.target_close_date).getTime():1/0;w=S-T;break}case"priority":w=WLe[_.priority]-WLe[b.priority];break}return l==="asc"?w:-w}),[t,s,a,l]),p=_=>_?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(_):"—",f=_=>_?s.find(b=>b.id===_):null,y=({field:_,children:b})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>d(_),children:[b,a===_?l==="asc"?e.jsx(Vd,{className:"ml-2 h-4 w-4"}):e.jsx(sh,{className:"ml-2 h-4 w-4"}):e.jsx(Hc,{className:"ml-2 h-4 w-4 opacity-50"})]});return t.length===0?e.jsx("div",{className:"text-center py-16",children:e.jsx("p",{className:"text-muted-foreground",children:"No deals to display"})}):e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{className:"bg-muted/50",children:[e.jsx(bt,{className:"w-[250px]",children:e.jsx(y,{field:"deal_name",children:"Deal Name"})}),e.jsx(bt,{className:"w-[150px]",children:e.jsx(y,{field:"stage",children:"Stage"})}),e.jsx(bt,{className:"w-[100px]",children:"Type"}),e.jsx(bt,{className:"w-[120px]",children:e.jsx(y,{field:"expected_price",children:"Price"})}),e.jsx(bt,{className:"w-[120px]",children:e.jsx(y,{field:"expected_commission",children:"GCI"})}),e.jsx(bt,{className:"w-[130px]",children:e.jsx(y,{field:"target_close_date",children:"Close Date"})}),e.jsx(bt,{className:"w-[100px]",children:e.jsx(y,{field:"priority",children:"Priority"})})]})}),e.jsx(Pn,{children:u.map(_=>{f(_.stage_id);const b=wgs[_.deal_type],w=_.target_close_date?Qg(gl(_.target_close_date),new Date):null,j=w!==null&&w<0,k=w!==null&&w<=7&&w>=0;return e.jsxs(Ns,{className:Pt("cursor-pointer hover:bg-muted/50 transition-colors",j&&"bg-red-50/50"),onClick:()=>r(_),children:[e.jsx(lt,{className:"font-medium",children:e.jsxs("div",{children:[e.jsx("p",{className:"truncate max-w-[230px]",children:_.deal_name}),_.contact&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[_.contact.first_name," ",_.contact.last_name]})]})}),e.jsx(lt,{onClick:S=>S.stopPropagation(),children:e.jsx($Je,{stages:s,currentStageId:_.stage_id||"",onStageSelect:(S,T)=>n(_.id,S,T)})}),e.jsx(lt,{children:e.jsx(rt,{variant:"outline",className:Pt("text-xs",b.color),children:b.label})}),e.jsx(lt,{children:e.jsx("span",{className:"font-medium",children:p(_.expected_price)})}),e.jsx(lt,{children:e.jsx("span",{className:"text-emerald-600",children:p(_.expected_commission)})}),e.jsx(lt,{children:_.target_close_date?e.jsxs("div",{className:Pt("flex items-center gap-1 text-sm",j&&"text-red-600",k&&!j&&"text-amber-600"),children:[j&&e.jsx(ll,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:ys(gl(_.target_close_date),"MMM d, yyyy")})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(lt,{children:e.jsx(rt,{variant:"outline",className:Pt("text-xs capitalize",_.priority==="urgent"&&"border-red-200 bg-red-50 text-red-700",_.priority==="high"&&"border-orange-200 bg-orange-50 text-orange-700",_.priority==="medium"&&"border-amber-200 bg-amber-50 text-amber-700",_.priority==="low"&&"border-slate-200 bg-slate-50 text-slate-600"),children:_.priority})})]},_.id)})})]})})}function Ngs(){const t=Ya();return wt({queryKey:["deal-tasks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("deal_tasks").select(` *, deal:deal_pipeline(id, deal_name, stage_id), contact:innercircle_contacts(id, first_name, last_name), stage:deal_pipeline_stages(id, name, color) `).eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function kgs(t){const s=Ya();return wt({queryKey:["deal-tasks","deal",t,s],queryFn:async()=>{if(!s||!t)return[];const{data:r,error:n}=await G.from("deal_tasks").select(` *, stage:deal_pipeline_stages(id, name, color) `).eq("owner_user_id",s).eq("deal_id",t).order("sort_order",{ascending:!0});if(n)throw n;return r},enabled:!!s&&!!t})}function Sgs(){const t=Ya(),s=rs();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("deal_tasks").insert({owner_user_id:t,title:r.title,description:r.description||null,deal_id:r.deal_id||null,contact_id:r.contact_id||null,stage_id:r.stage_id||null,priority:r.priority||"medium",status:r.status||"todo",due_date:r.due_date||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}function Cgs(){const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("deal_tasks").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function Mgs(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("deal_tasks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function Z2e(){const t=rs();return Dt({mutationFn:async({id:s,status:r})=>{const{data:n,error:a}=await G.from("deal_tasks").update({status:r,completed_at:r==="done"?new Date().toISOString():null}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function Tgs(){const t=rs();return Dt({mutationFn:async s=>{if(s.length===0)return;const{error:r}=await G.from("deal_tasks").update({status:"done",completed_at:new Date().toISOString()}).in("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function Ags(t){const s=Ya();return wt({queryKey:["deal-task-templates",s,t],queryFn:async()=>{if(!s)return[];let r=G.from("deal_task_templates").select("*").eq("owner_user_id",s).order("sort_order",{ascending:!0});t&&(r=r.eq("stage_id",t));const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!s})}function Egs(){const t=Ya(),s=rs();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("deal_task_templates").insert({owner_user_id:t,stage_id:r.stage_id,title:r.title,description:r.description||null,priority:r.priority||"medium",default_due_offset_days:r.default_due_offset_days||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-task-templates"]})}})}function Pgs(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("deal_task_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-task-templates"]})}})}function Igs(){const t=Ya(),s=rs();return Dt({mutationFn:async({dealId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await G.from("deal_task_templates").select("*").eq("owner_user_id",t).eq("stage_id",n).order("sort_order");if(o)throw o;if(!a||a.length===0)return[];const{data:l}=await G.from("deal_tasks").select("title, stage_id").eq("deal_id",r).eq("stage_id",n),i=new Set((l||[]).map(f=>f.title)),d=a.filter(f=>!i.has(f.title)).map((f,y)=>({owner_user_id:t,deal_id:r,stage_id:n,title:f.title,description:f.description,priority:f.priority,due_date:f.default_due_offset_days?new Date(Date.now()+f.default_due_offset_days*864e5).toISOString().split("T")[0]:null,sort_order:y,status:"todo"}));if(d.length===0)return[];const{data:u,error:p}=await G.from("deal_tasks").insert(d).select();if(p)throw p;return u},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}const Lgs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Dgs({open:t,onOpenChange:s,dealId:r,dealName:n,fromStageName:a,toStageName:o,toStageId:l,onConfirm:i}){const{data:d,isLoading:u}=kgs(t?r:void 0),p=Tgs(),f=Igs(),[y,_]=C.useState(new Set),[b,w]=C.useState(!1),j=(d||[]).filter(I=>I.status!=="done");C.useEffect(()=>{j.length>0&&_(new Set(j.map(I=>I.id)))},[d]);const k=I=>{_(L=>{const R=new Set(L);return R.has(I)?R.delete(I):R.add(I),R})},S=async()=>{w(!0);try{const I=Array.from(y);I.length>0&&await p.mutateAsync(I),await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(I){console.error("Stage move failed:",I),fe.error((I==null?void 0:I.message)||"Failed to move deal. Please try again.")}finally{w(!1)}},T=async()=>{w(!0);try{await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(I){console.error("Stage move (skip) failed:",I),fe.error((I==null?void 0:I.message)||"Failed to move deal. Please try again.")}finally{w(!1)}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-[480px]",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Move Deal"}),e.jsxs(Kr,{children:["Moving ",e.jsx("span",{className:"font-medium text-foreground",children:n})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2",children:[e.jsx(rt,{variant:"outline",className:"text-sm",children:a}),e.jsx($i,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(rt,{className:"text-sm bg-primary",children:o})]}),u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):j.length>0?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You have ",e.jsx("span",{className:"font-medium text-foreground",children:j.length})," incomplete task",j.length!==1?"s":"",". Select which to mark as done:"]}),e.jsx(Ri,{className:"max-h-[250px]",children:e.jsx("div",{className:"space-y-1",children:j.map(I=>e.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-muted/50 cursor-pointer transition-colors",children:[e.jsx(Bo,{checked:y.has(I.id),onCheckedChange:()=>k(I.id)}),e.jsxs("span",{className:"text-sm flex-1",children:[Lgs[I.priority]," ",I.title]}),I.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full",style:{backgroundColor:I.stage.color+"20",color:I.stage.color},children:I.stage.name})]},I.id))})}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>{y.size===j.length?_(new Set):_(new Set(j.map(I=>I.id)))},children:y.size===j.length?"Deselect All":"Select All"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:T,disabled:b,children:"Skip"}),e.jsxs(K,{size:"sm",onClick:S,disabled:b,children:[b&&e.jsx(Ms,{className:"h-4 w-4 mr-1 animate-spin"}),y.size>0?`Complete ${y.size} & Move`:"Move Deal"]})]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"text-center py-4",children:[e.jsx(ua,{className:"h-8 w-8 text-emerald-500 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"All tasks completed! Ready to move."})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:S,disabled:b,children:[b&&e.jsx(Ms,{className:"h-4 w-4 mr-1 animate-spin"}),"Move to ",o]})]})]})]})})}function Ogs(){const t=Ya();return wt({queryKey:["all-client-portals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("client_portals").select("*").eq("owner_user_id",t);if(r)throw r;return s||[]},enabled:!!t})}function Rgs({dealId:t,dealName:s,contactName:r,portal:n,onSettingsOpen:a,onComposerOpen:o,onInviteOpen:l,onDeleteConfirm:i}){const d=U2e(),u=xD(),p=gps(),f=xps(),[y,_]=C.useState(!1),b=!!(n!=null&&n.archived_at),w=async()=>{_(!0);try{await d.mutateAsync({deal_id:t,visibility:"private",require_onboarding:!0}),fe.success("Portal enabled!")}catch{fe.error("Failed to create portal")}finally{_(!1)}},j=async L=>{if(n)try{await u.mutateAsync({id:n.id,is_enabled:L}),fe.success(L?"Portal enabled":"Portal disabled")}catch{fe.error("Failed to update portal")}},k=()=>{n&&(navigator.clipboard.writeText(Z0(n.slug)),fe.success("Link copied!"))},S=()=>{n&&window.open(Z0(n.slug),"_blank")},T=async()=>{if(n)try{await p.mutateAsync(n.id),fe.success("Portal archived")}catch{fe.error("Failed to archive portal")}},I=async()=>{if(n)try{await f.mutateAsync(n.id),fe.success("Portal restored")}catch{fe.error("Failed to restore portal")}};return n?b?e.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg opacity-60 bg-muted/30",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx(rt,{variant:"outline",className:"text-[10px] bg-muted text-muted-foreground",children:"Archived"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.client_name||r||"No client name"})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:I,className:"text-xs gap-1",children:[e.jsx(rP,{className:"h-3.5 w-3.5"}),"Restore"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>i(n),className:"text-xs gap-1 text-destructive hover:text-destructive",children:[e.jsx(jr,{className:"h-3.5 w-3.5"}),"Delete"]})]})]}):e.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx(rt,{variant:"outline",className:n.is_enabled?"text-[10px] bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-[10px] bg-muted text-muted-foreground",children:n.is_enabled?"Active":"Disabled"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.client_name||r||"No client name"})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:k,title:"Copy link",children:e.jsx(ai,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:S,title:"Preview",children:e.jsx(sn,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(n,s),title:"Invite client",children:e.jsx(aa,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o(n),title:"Post update",children:e.jsx(k5,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>a(n),title:"Settings",children:e.jsx($l,{className:"h-3.5 w-3.5"})}),e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(of,{className:"h-3.5 w-3.5"})})}),e.jsx(Md,{align:"end",children:e.jsxs(Na,{onClick:T,children:[e.jsx(u5,{className:"h-4 w-4 mr-2"}),"Archive Portal"]})})]}),e.jsx(Br,{checked:n.is_enabled,onCheckedChange:j,className:"ml-1"})]})]}):e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg border-dashed bg-muted/20",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r||"No contact"})]}),e.jsxs(K,{size:"sm",onClick:w,disabled:y,className:"shrink-0 ml-4",children:[y?e.jsx(Ms,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx(hn,{className:"h-3 w-3 mr-1"}),"Enable Portal"]})]})}function Fgs(){const{data:t,isLoading:s}=Bce(),{data:r,isLoading:n}=Ogs(),[a,o]=C.useState(""),[l,i]=C.useState("all"),d=yps(),[u,p]=C.useState(null),[f,y]=C.useState(null),[_,b]=C.useState(null),[w,j]=C.useState(null),k=Ya(),S=s||n,T=new Map;r==null||r.forEach(H=>T.set(H.deal_id,H));const L=[...(t||[]).filter(H=>{var de,re,ae,le,he;const Y=T.get(H.id),se=a.toLowerCase(),te=!se||H.deal_name.toLowerCase().includes(se)||((re=(de=H.contact)==null?void 0:de.first_name)==null?void 0:re.toLowerCase().includes(se))||((le=(ae=H.contact)==null?void 0:ae.last_name)==null?void 0:le.toLowerCase().includes(se))||((he=Y==null?void 0:Y.client_name)==null?void 0:he.toLowerCase().includes(se));let Q=!0;return l==="active"?Q=!!(Y!=null&&Y.is_enabled)&&!(Y!=null&&Y.archived_at):l==="disabled"?Q=!!Y&&!Y.is_enabled&&!Y.archived_at:l==="archived"?Q=!!(Y!=null&&Y.archived_at):l==="none"?Q=!Y:l==="all"&&(Q=!(Y!=null&&Y.archived_at)||!Y),te&&Q})].sort((H,Y)=>{const se=T.get(H.id),te=T.get(Y.id);if(se!=null&&se.archived_at&&!(te!=null&&te.archived_at))return 1;if(!(se!=null&&se.archived_at)&&(te!=null&&te.archived_at)||se&&!te)return-1;if(!se&&te)return 1;if(se&&te){if(se.is_enabled&&!te.is_enabled)return-1;if(!se.is_enabled&&te.is_enabled)return 1}return 0}),R=(r==null?void 0:r.filter(H=>!H.archived_at).length)||0,$=(r==null?void 0:r.filter(H=>H.is_enabled&&!H.archived_at).length)||0,q=(r==null?void 0:r.filter(H=>H.archived_at).length)||0,U=async()=>{if(w)try{await d.mutateAsync({id:w.id,dealId:w.deal_id}),fe.success("Portal permanently deleted"),j(null)}catch{fe.error("Failed to delete portal")}};return S?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(Ms,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"font-medium",children:[R," Portals"]})]}),e.jsxs("span",{className:"text-muted-foreground",children:[$," active · ",R-$," disabled",q>0&&` · ${q} archived`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search deals or clients...",value:a,onChange:H=>o(H.target.value),className:"pl-9 pr-8"}),a&&e.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:["all","active","disabled","archived","none"].map(H=>e.jsx(K,{variant:l===H?"secondary":"ghost",size:"sm",onClick:()=>i(H),className:"text-xs px-3 capitalize",children:H==="none"?"No Portal":H},H))})]}),e.jsx(Ri,{className:"h-[calc(100vh-22rem)]",children:e.jsxs("div",{className:"space-y-2 pb-4",children:[L.map(H=>{const Y=T.get(H.id)||null,se=H.contact?`${H.contact.first_name||""} ${H.contact.last_name||""}`.trim():"";return e.jsx(Rgs,{dealId:H.id,dealName:H.deal_name,contactName:se,portal:Y,onSettingsOpen:p,onComposerOpen:te=>y(te),onInviteOpen:(te,Q)=>b({portal:te,dealName:Q}),onDeleteConfirm:j},H.id)}),L.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 bg-muted rounded-full flex items-center justify-center",children:e.jsx(hn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("p",{className:"text-sm font-medium",children:"No matching deals"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Try adjusting your search or filters"})]})]})})]}),u&&e.jsx(UJe,{open:!!u,onOpenChange:H=>!H&&p(null),portal:u,dealOwnerId:k||""}),f&&e.jsx(VJe,{open:!!f,onOpenChange:H=>!H&&y(null),portalId:f.id,portalSlug:f.slug,notifyClient:f.notify_client}),_&&e.jsx(HJe,{open:!!_,onOpenChange:H=>!H&&b(null),portal:_.portal,dealName:_.dealName}),e.jsx(nc,{open:!!w,onOpenChange:H=>!H&&j(null),children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Permanently delete this portal?"}),e.jsx(Dl,{children:"This will permanently remove the portal and all its updates. The client will no longer be able to access their portal page. This action cannot be undone."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:U,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Permanently"})]})]})})]})}class zgs extends C.Component{constructor(s){super(s),this.state={hasError:!1,error:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}componentDidCatch(s,r){console.error("DealPipeline error:",s,r)}render(){return this.state.hasError?e.jsx(Ts,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center h-[60vh] gap-4 text-center px-4",children:[e.jsx("div",{className:"w-16 h-16 bg-destructive/10 rounded-full flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"⚠️"})}),e.jsx("h2",{className:"text-xl font-semibold",children:"Something went wrong"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"There was an error in the deal pipeline. Click below to try again."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>this.setState({hasError:!1,error:null}),className:"px-4 py-2 bg-primary text-primary-foreground rounded-md text-sm font-medium hover:bg-primary/90",children:"Try Again"}),e.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 border border-border rounded-md text-sm font-medium hover:bg-muted",children:"Refresh Page"})]})]})}):this.props.children}}function Bgs(){var as;const t=eT(),{data:s,isLoading:r}=zce(),{data:n,isLoading:a,refetch:o}=Bce(),{data:l,isLoading:i}=dfs(),d=DJe(),u=rfs(),[p,f]=C.useState("board"),[y,_]=C.useState(!1),[b,w]=C.useState(!1),[j,k]=C.useState(null),[S,T]=C.useState(null),[I,L]=C.useState(null),[R,$]=C.useState(null),[q,U]=C.useState(!1),[H,Y]=C.useState(null),[se,te]=C.useState(""),[Q,de]=C.useState("all"),[re,ae]=C.useState(!1),[le,he]=C.useState(!1),[be,_e]=C.useState(new Set),[je,Ne]=C.useState(null),{data:Ge}=Lf(),{isTeamLeader:we,teamMembers:Me}=Kfs(),Te=C.useMemo(()=>Array.from(be),[be]),{data:Fe}=Zfs(Te),Ae=C.useMemo(()=>{const Xt=new Map;return Me.forEach(ss=>Xt.set(ss.id,{name:ss.name,avatar_url:ss.avatar_url,color:ss.color})),Xt},[Me]),Ue=C.useCallback(Xt=>Xt.owner_user_id&&Ae.get(Xt.owner_user_id)||null,[Ae]),ut=C.useCallback(Xt=>{_e(ss=>{const is=new Set(ss);return is.has(Xt)?is.delete(Xt):is.add(Xt),is})},[]);C.useEffect(()=>{!r&&s&&s.length===0&&d.mutate()},[r,s]);const[De,Rt]=Pc(),me=C.useRef(!1);C.useEffect(()=>{const Xt=De.get("deal");if(Xt&&n&&n.length>0&&!me.current){const ss=n.find(is=>is.id===Xt);ss&&(me.current=!0,k(ss),w(!0),De.delete("deal"),Rt(De,{replace:!0}))}},[n,De]);const Xe=C.useMemo(()=>{if(!Fe||!s)return[];const Xt=new Map(s.map(ss=>[ss.name,ss.id]));return Fe.map(ss=>{const is=ss._stage_name&&Xt.get(ss._stage_name)||null;return{...ss,stage_id:is||ss.stage_id}})},[Fe,s]),ot=C.useMemo(()=>[...n||[],...Xe],[n,Xe]),nt=ot.filter(Xt=>{var Ct,Is,qs,gr,Wn,ii;const ss=se.toLowerCase(),is=!ss||Xt.deal_name.toLowerCase().includes(ss)||((Is=(Ct=Xt.contact)==null?void 0:Ct.first_name)==null?void 0:Is.toLowerCase().includes(ss))||((gr=(qs=Xt.contact)==null?void 0:qs.last_name)==null?void 0:gr.toLowerCase().includes(ss))||((Wn=Xt.property_address)==null?void 0:Wn.toLowerCase().includes(ss))||((ii=Xt.city)==null?void 0:ii.toLowerCase().includes(ss)),ar=Q==="all"||Xt.deal_type===Q;return is&&ar}),Se=C.useMemo(()=>{if(!s)return l||null;const Xt=new Set(s.filter(qs=>qs.is_won_stage).map(qs=>qs.id)),ss=new Set(s.filter(qs=>qs.is_lost_stage).map(qs=>qs.id)),is=ot.filter(qs=>qs.stage_id&&!Xt.has(qs.stage_id)&&!ss.has(qs.stage_id)),ar=ot.filter(qs=>qs.stage_id&&Xt.has(qs.stage_id)),Ct=new Date().getFullYear(),Is=ar.filter(qs=>qs.actual_close_date?new Date(qs.actual_close_date).getFullYear()===Ct:!0);return{totalDeals:ot.length,activeDeals:is.length,wonDeals:ar.length,pipelineValue:is.reduce((qs,gr)=>qs+(gr.expected_price||0),0),expectedCommission:is.reduce((qs,gr)=>qs+(gr.expected_commission||0),0),expectedNetToAgent:is.reduce((qs,gr)=>qs+(uf(gr)||0),0),wonValue:ar.reduce((qs,gr)=>qs+(gr.expected_price||0),0),weightedGCI:is.reduce((qs,gr)=>qs+(gr.expected_commission||0)*((gr.probability??50)/100),0),weightedNet:is.reduce((qs,gr)=>qs+(uf(gr)||0)*((gr.probability??50)/100),0),ytdWonDeals:Is.length,ytdWonGCI:Is.reduce((qs,gr)=>qs+(gr.expected_commission||0),0),ytdWonNet:Is.reduce((qs,gr)=>qs+(uf(gr)||0),0),projectedAnnualNet:Is.reduce((qs,gr)=>qs+(uf(gr)||0),0)+is.reduce((qs,gr)=>qs+(uf(gr)||0)*((gr.probability??50)/100),0)}},[ot,s,l]),it=Xt=>{k(Xt),w(!0)},$e=Xt=>{T(Xt||null),k(null),_(!0)},ct=Xt=>{k(Xt),w(!1),_(!0)},qe=(Xt,ss)=>{L(Xt)},Ze=(Xt,ss)=>{Xt.preventDefault(),Xt.dataTransfer.dropEffect="move",$(ss)},Qe=async(Xt,ss)=>{if(Xt.preventDefault(),$(null),!I)return;const is=n==null?void 0:n.find(Is=>Is.id===I),ar=s==null?void 0:s.find(Is=>Is.id===ss),Ct=s==null?void 0:s.find(Is=>Is.id===(is==null?void 0:is.stage_id));if(!is||!ar||is.stage_id===ss){L(null);return}Ne({dealId:I,dealName:is.deal_name,fromStageName:(Ct==null?void 0:Ct.name)||"Unknown",toStageName:ar.name,toStageId:ss,isWonStage:ar.is_won_stage,deal:is}),L(null)},We=async()=>{if(!je)return;const{dealId:Xt,toStageId:ss,toStageName:is,isWonStage:ar,deal:Ct}=je;if(await u.mutateAsync({dealId:Xt,stageId:ss,stageName:is}),fe.success(`Moved to ${is}`),ar&&!Ct.scorecard_transaction_id){const Is={...Ct,stage_id:ss};Y(Is),U(!0)}},He=C.useCallback(async(Xt,ss,is)=>{const ar=n==null?void 0:n.find(qs=>qs.id===Xt),Ct=s==null?void 0:s.find(qs=>qs.id===ss),Is=s==null?void 0:s.find(qs=>qs.id===(ar==null?void 0:ar.stage_id));!ar||!Ct||ar.stage_id===ss||Ne({dealId:Xt,dealName:ar.deal_name,fromStageName:(Is==null?void 0:Is.name)||"Unknown",toStageName:is,toStageId:ss,isWonStage:Ct.is_won_stage,deal:ar})},[n,s]),et=Xt=>nt.filter(ss=>ss.stage_id===Xt),Tt=r||a,Ft=t?"list":p;return e.jsxs(Ts,{children:[e.jsxs("div",{className:"flex flex-col h-[calc(100vh-4rem)]",children:[e.jsxs("div",{className:"shrink-0 p-4 md:p-6 pb-0 space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Deal Pipeline"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Track and manage your active deals"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>o(),className:"shrink-0",children:e.jsx(Po,{className:"h-4 w-4"})}),!t&&e.jsx(U_,{children:e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsxs(Wc,{children:[e.jsx(Gc,{asChild:!0,children:e.jsxs(K,{variant:p==="board"?"secondary":"ghost",size:"sm",onClick:()=>f("board"),className:"px-3 gap-1.5",children:[e.jsx(yp,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Board"})]})}),e.jsx(Cc,{children:"Kanban board view"})]}),e.jsxs(Wc,{children:[e.jsx(Gc,{asChild:!0,children:e.jsxs(K,{variant:p==="list"?"secondary":"ghost",size:"sm",onClick:()=>f("list"),className:"px-3 gap-1.5",children:[e.jsx(Hh,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"List"})]})}),e.jsx(Cc,{children:"Grouped list view"})]}),e.jsxs(Wc,{children:[e.jsx(Gc,{asChild:!0,children:e.jsxs(K,{variant:p==="table"?"secondary":"ghost",size:"sm",onClick:()=>f("table"),className:"px-3 gap-1.5",children:[e.jsx(T5,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Table"})]})}),e.jsx(Cc,{children:"Sortable table view"})]}),e.jsxs(Wc,{children:[e.jsx(Gc,{asChild:!0,children:e.jsxs(K,{variant:p==="portals"?"secondary":"ghost",size:"sm",onClick:()=>f("portals"),className:"px-3 gap-1.5",children:[e.jsx(hn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Portals"})]})}),e.jsx(Cc,{children:"Client portal management"})]})]})}),Ge&&!we&&e.jsxs(K,{variant:"outline",onClick:()=>ae(!0),children:[e.jsx(hr,{className:"h-4 w-4 mr-2"}),"Team"]}),e.jsxs(K,{onClick:()=>$e(),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})]})]}),Ft!=="portals"&&e.jsx(Jfs,{stats:Se,isLoading:i}),Ft!=="portals"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search deals, contacts, addresses...",value:se,onChange:Xt=>te(Xt.target.value),className:"pl-9 pr-8"}),se&&e.jsx("button",{onClick:()=>te(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsxs(sr,{value:Q,onValueChange:de,children:[e.jsx(er,{className:"w-[140px]",children:e.jsx(rr,{placeholder:"All Types"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Types"}),e.jsx(At,{value:"buyer",children:"Buyer"}),e.jsx(At,{value:"seller",children:"Seller"}),e.jsx(At,{value:"dual",children:"Dual"}),e.jsx(At,{value:"referral",children:"Referral"}),e.jsx(At,{value:"lease",children:"Lease"})]})]}),(se||Q!=="all")&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[nt.length," of ",(n==null?void 0:n.length)||0," deals"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[we&&!t&&Me.length>0&&e.jsx(Gfs,{members:Me,enabledMembers:be,onToggleMember:ut,isOpen:le,onToggleOpen:()=>he(Xt=>!Xt)}),e.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-4 md:p-6 pt-4",children:Tt?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(Xt=>e.jsx("div",{className:"min-w-[280px] max-w-[320px] flex-shrink-0",children:e.jsx(xs,{className:"h-full rounded-xl"})},Xt))}):Ft==="board"?e.jsxs(Ri,{className:"h-full -mx-4 md:-mx-6 px-4 md:px-6",children:[e.jsx("div",{className:"flex gap-4 h-full pb-4",children:s==null?void 0:s.map(Xt=>e.jsx(Qfs,{stage:Xt,deals:et(Xt.id),onDealClick:it,onAddDeal:$e,onDragStart:qe,onDragOver:Ze,onDrop:Qe,isDragOver:R===Xt.id,isWonStage:Xt.is_won_stage,getOwnerInfo:Ue},Xt.id))}),e.jsx(Zoe,{orientation:"horizontal"})]}):Ft==="table"?e.jsx(Ri,{className:"h-full",children:e.jsx(jgs,{deals:nt,stages:s||[],onDealClick:it,onStageChange:He})}):Ft==="portals"?e.jsx(Fgs,{}):e.jsx(Ri,{className:"h-full",children:e.jsxs("div",{className:"space-y-6",children:[s==null?void 0:s.map(Xt=>{const ss=et(Xt.id);return ss.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Xt.color}}),e.jsx("h3",{className:"font-semibold",children:Xt.name}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",ss.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:ss.map(is=>e.jsx(qJe,{deal:is,onClick:()=>it(is),stages:s,onStageChange:He,showStagePicker:!0,isWonStage:Xt.is_won_stage,ownerInfo:Ue(is)},is.id))})]},Xt.id)}),(n==null?void 0:n.length)===0&&e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-muted rounded-full flex items-center justify-center",children:e.jsx(yp,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No deals yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Start tracking your opportunities by adding your first deal"}),e.jsxs(K,{onClick:()=>$e(),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Your First Deal"]})]}),((n==null?void 0:n.length)||0)>0&&nt.length===0&&e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-muted rounded-full flex items-center justify-center",children:e.jsx(gn,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No matching deals"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Try adjusting your search or filters"}),e.jsx(K,{variant:"outline",onClick:()=>{te(""),de("all")},children:"Clear Filters"})]})]})})})]})]}),e.jsx(rgs,{open:y,onOpenChange:_,deal:j,defaultStageId:S}),e.jsx(_gs,{deal:j,open:b,onOpenChange:w,onEdit:ct,isWonStage:j?(as=s==null?void 0:s.find(Xt=>Xt.id===j.stage_id))==null?void 0:as.is_won_stage:!1,onAddToScorecard:Xt=>{Y(Xt),U(!0),w(!1)}}),e.jsx(bgs,{open:q,onOpenChange:U,deal:H,onComplete:()=>{o(),Y(null)}}),je&&e.jsx(Dgs,{open:!!je,onOpenChange:Xt=>{Xt||Ne(null)},dealId:je.dealId,dealName:je.dealName,fromStageName:je.fromStageName,toStageName:je.toStageName,toStageId:je.toStageId,onConfirm:We}),e.jsx(Hfs,{open:re,onOpenChange:ae})]})}function $gs(){return e.jsx(zgs,{children:e.jsx(Bgs,{})})}function WJe({open:t,onOpenChange:s,editTask:r,defaultDealId:n,defaultStageId:a}){var te;const o=Sgs(),l=Cgs(),{data:i}=Bce(),d=Ya(),{data:u}=wt({queryKey:["contacts-for-tasks",d],queryFn:async()=>{if(!d)return[];const{data:Q,error:de}=await G.from("innercircle_contacts").select("id, first_name, last_name").eq("owner_user_id",d).order("first_name").limit(500);if(de)throw de;return Q},enabled:!!d&&t}),[p,f]=C.useState(""),[y,_]=C.useState(""),[b,w]=C.useState("none"),[j,k]=C.useState("none"),[S,T]=C.useState("medium"),[I,L]=C.useState("todo"),[R,$]=C.useState(),[q,U]=C.useState(!1),[H,Y]=C.useState(!1);C.useEffect(()=>{r?(f(r.title),_(r.description||""),w(r.deal_id||"none"),k(r.contact_id||"none"),T(r.priority),L(r.status),$(r.due_date?Ih(r.due_date):void 0)):(f(""),_(""),w(n||"none"),k("none"),T("medium"),L("todo"),$(void 0))},[r,t,n]);const se=async()=>{if(!p.trim()){fe.error("Task title is required");return}try{const Q={title:p.trim(),description:y.trim()||null,deal_id:b==="none"?null:b,contact_id:j==="none"?null:j,stage_id:a||null,priority:S,status:I,due_date:R?ys(R,"yyyy-MM-dd"):null};r?(await l.mutateAsync({id:r.id,...Q}),fe.success("Task updated")):(await o.mutateAsync(Q),fe.success("Task created")),s(!1)}catch{fe.error("Failed to save task")}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-[480px]",children:[e.jsx(Ss,{children:e.jsx(ks,{children:r?"Edit Task":"New Task"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Title *"}),e.jsx(Re,{value:p,onChange:Q=>f(Q.target.value),placeholder:"e.g., Send inspection report"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Ar,{value:y,onChange:Q=>_(Q.target.value),placeholder:"Optional details...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Priority"}),e.jsxs(sr,{value:S,onValueChange:Q=>T(Q),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"low",children:"🟢 Low"}),e.jsx(At,{value:"medium",children:"🟡 Medium"}),e.jsx(At,{value:"high",children:"🟠 High"}),e.jsx(At,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Status"}),e.jsxs(sr,{value:I,onValueChange:Q=>L(Q),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"todo",children:"To Do"}),e.jsx(At,{value:"in_progress",children:"In Progress"}),e.jsx(At,{value:"done",children:"Done"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Due Date"}),e.jsxs(Co,{children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!R&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),R?ys(R,"PPP"):"Pick a date"]})}),e.jsx(No,{className:"w-auto p-0",align:"start",children:e.jsx(jp,{mode:"single",selected:R,onSelect:$,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Link to Deal"}),e.jsxs(Co,{open:q,onOpenChange:U,children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(Ta,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),b!=="none"?((te=i==null?void 0:i.find(Q=>Q.id===b))==null?void 0:te.deal_name)||"Select deal":"No Deal"]}),e.jsx(xf,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(No,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Mf,{children:[e.jsx(Tf,{placeholder:"Search deals..."}),e.jsxs(Af,{children:[e.jsx(Ef,{children:"No deals found."}),e.jsxs(Pf,{children:[e.jsxs(Cm,{value:"no-deal",onSelect:()=>{w("none"),U(!1)},children:[e.jsx(ha,{className:Pt("mr-2 h-4 w-4",b==="none"?"opacity-100":"opacity-0")}),"No Deal"]}),i==null?void 0:i.map(Q=>e.jsxs(Cm,{value:Q.deal_name,onSelect:()=>{w(Q.id),U(!1)},children:[e.jsx(ha,{className:Pt("mr-2 h-4 w-4",b===Q.id?"opacity-100":"opacity-0")}),Q.deal_name]},Q.id))]})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Link to Contact"}),e.jsxs(Co,{open:H,onOpenChange:Y,children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(Yi,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),j!=="none"?(()=>{const Q=u==null?void 0:u.find(de=>de.id===j);return Q?`${Q.first_name} ${Q.last_name}`:"Select contact"})():"No Contact"]}),e.jsx(xf,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(No,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Mf,{children:[e.jsx(Tf,{placeholder:"Search contacts..."}),e.jsxs(Af,{children:[e.jsx(Ef,{children:"No contacts found."}),e.jsxs(Pf,{children:[e.jsxs(Cm,{value:"no-contact",onSelect:()=>{k("none"),Y(!1)},children:[e.jsx(ha,{className:Pt("mr-2 h-4 w-4",j==="none"?"opacity-100":"opacity-0")}),"No Contact"]}),u==null?void 0:u.map(Q=>e.jsxs(Cm,{value:`${Q.first_name} ${Q.last_name}`,onSelect:()=>{k(Q.id),Y(!1)},children:[e.jsx(ha,{className:Pt("mr-2 h-4 w-4",j===Q.id?"opacity-100":"opacity-0")}),Q.first_name," ",Q.last_name]},Q.id))]})]})]})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:se,disabled:o.isPending||l.isPending,children:r?"Save Changes":"Create Task"})]})]})]})})}const qgs={urgent:{label:"Urgent",color:"bg-red-500/10 text-red-600 border-red-200",dot:"🔴"},high:{label:"High",color:"bg-orange-500/10 text-orange-600 border-orange-200",dot:"🟠"},medium:{label:"Medium",color:"bg-amber-500/10 text-amber-600 border-amber-200",dot:"🟡"},low:{label:"Low",color:"bg-emerald-500/10 text-emerald-600 border-emerald-200",dot:"🟢"}};function Ugs({tasks:t}){const s=Z2e(),r=Mgs(),n=Pr(),[a,o]=C.useState(null),l=async p=>{const f=p.status==="done"?"todo":"done";try{await s.mutateAsync({id:p.id,status:f})}catch{fe.error("Failed to update task")}},i=async p=>{try{await r.mutateAsync(p),fe.success("Task deleted")}catch{fe.error("Failed to delete task")}};if(t.length===0)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx(ua,{className:"h-12 w-12 text-muted-foreground/30 mb-3"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:"No tasks found"}),e.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"Create a new task to get started"})]});const d=new Map,u=[];return t.forEach(p=>{if(p.deal){const f=d.get(p.deal.id)||{dealName:p.deal.deal_name,tasks:[]};f.tasks.push(p),d.set(p.deal.id,f)}else u.push(p)}),e.jsxs("div",{className:"space-y-4",children:[u.length>0&&e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 px-4 py-2 border-b",children:e.jsx("h3",{className:"font-medium text-sm text-muted-foreground",children:"General Tasks"})}),u.map(p=>e.jsx(GLe,{task:p,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:f=>n(`/mission-control/pipeline?deal=${f}`)},p.id))]}),Array.from(d.entries()).map(([p,f])=>e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(`/mission-control/pipeline?deal=${p}`),className:"w-full bg-muted/30 px-4 py-2 border-b flex items-center gap-2 hover:bg-muted/50 transition-colors text-left",children:[e.jsx(Ta,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("h3",{className:"font-medium text-sm",children:f.dealName}),e.jsxs(rt,{variant:"secondary",className:"ml-auto text-xs",children:[f.tasks.filter(y=>y.status==="done").length,"/",f.tasks.length]}),e.jsx(Ua,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),f.tasks.map(y=>e.jsx(GLe,{task:y,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:_=>n(`/mission-control/pipeline?deal=${_}`)},y.id))]},p)),a&&e.jsx(WJe,{open:!!a,onOpenChange:()=>o(null),editTask:a})]})}function GLe({task:t,onToggle:s,onDelete:r,onEdit:n,onNavigateDeal:a}){const o=t.status==="done",l=!o&&t.due_date&&sy(Ih(t.due_date))&&!Bd(Ih(t.due_date)),i=!o&&t.due_date&&Bd(Ih(t.due_date)),d=qgs[t.priority];return e.jsxs("div",{className:Pt("flex items-center gap-3 px-4 py-3 border-b last:border-b-0 group hover:bg-muted/30 transition-colors",o&&"opacity-60"),children:[e.jsx("button",{onClick:()=>s(t),className:"shrink-0",children:o?e.jsx(ua,{className:"h-5 w-5 text-emerald-500"}):e.jsx(Kc,{className:"h-5 w-5 text-muted-foreground hover:text-primary transition-colors"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:Pt("text-sm font-medium truncate",o&&"line-through text-muted-foreground"),children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[t.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{backgroundColor:t.stage.color+"20",color:t.stage.color},children:t.stage.name}),t.contact&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(Yi,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]})]}),e.jsxs(rt,{variant:"outline",className:Pt("text-[10px] shrink-0",d.color),children:[d.dot," ",d.label]}),t.due_date&&e.jsxs("span",{className:Pt("text-xs shrink-0 flex items-center gap-1",l&&"text-destructive font-medium",i&&"text-amber-600 font-medium",!l&&!i&&"text-muted-foreground"),children:[e.jsx(Tn,{className:"h-3 w-3"}),ys(Ih(t.due_date),"MMM d")]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>n(t),className:"p-1 hover:bg-muted rounded",children:e.jsx(Rc,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("button",{onClick:()=>r(t.id),className:"p-1 hover:bg-destructive/10 rounded",children:e.jsx(jr,{className:"h-3.5 w-3.5 text-destructive"})})]})]})}const Vgs=[{status:"todo",label:"To Do",icon:Kc,color:"border-t-slate-400"},{status:"in_progress",label:"In Progress",icon:bm,color:"border-t-blue-500"},{status:"done",label:"Done",icon:ua,color:"border-t-emerald-500"}],Hgs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Wgs({tasks:t}){const s=Z2e(),r=C.useMemo(()=>{const o={todo:[],in_progress:[],done:[]};return t.forEach(l=>o[l.status].push(l)),o},[t]),n=(o,l)=>{o.dataTransfer.setData("taskId",l)},a=async(o,l)=>{o.preventDefault();const i=o.dataTransfer.getData("taskId");if(!i)return;const d=t.find(u=>u.id===i);if(!(!d||d.status===l))try{await s.mutateAsync({id:i,status:l})}catch{fe.error("Failed to move task")}};return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:Vgs.map(o=>e.jsxs("div",{className:Pt("border rounded-lg border-t-4 bg-muted/20",o.color),onDragOver:l=>l.preventDefault(),onDrop:l=>a(l,o.status),children:[e.jsxs("div",{className:"px-4 py-3 flex items-center gap-2",children:[e.jsx(o.icon,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold text-sm",children:o.label}),e.jsx(rt,{variant:"secondary",className:"ml-auto text-xs",children:r[o.status].length})]}),e.jsxs("div",{className:"p-2 space-y-2 min-h-[200px]",children:[r[o.status].map(l=>e.jsx(Ggs,{task:l,onDragStart:n},l.id)),r[o.status].length===0&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:"Drag tasks here"})]})]},o.status))})}function Ggs({task:t,onDragStart:s}){const r=t.status==="done",n=!r&&t.due_date&&sy(Ih(t.due_date))&&!Bd(Ih(t.due_date)),a=!r&&t.due_date&&Bd(Ih(t.due_date));return e.jsx("div",{draggable:!0,onDragStart:o=>s(o,t.id),className:Pt("bg-background border rounded-lg p-3 cursor-grab active:cursor-grabbing shadow-sm hover:shadow-md transition-shadow",n&&"border-destructive/50"),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-xs mt-0.5",children:Hgs[t.priority]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:Pt("text-sm font-medium",r&&"line-through text-muted-foreground"),children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5 flex-wrap",children:[t.deal&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(Ta,{className:"h-2.5 w-2.5"}),t.deal.deal_name]}),t.contact&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(Yi,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]}),t.due_date&&e.jsxs("div",{className:Pt("text-[10px] mt-1.5 flex items-center gap-1",n&&"text-destructive font-medium",a&&"text-amber-600 font-medium",!n&&!a&&"text-muted-foreground"),children:[e.jsx(Tn,{className:"h-2.5 w-2.5"}),n?"Overdue — ":a?"Due today — ":"",ys(Ih(t.due_date),"MMM d")]}),t.stage&&e.jsx("span",{className:"inline-block text-[10px] px-1.5 py-0.5 rounded-full font-medium mt-1.5",style:{backgroundColor:t.stage.color+"20",color:t.stage.color},children:t.stage.name})]})]})})}const KLe={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Kgs({tasks:t}){const[s,r]=C.useState(new Date),n=Z2e(),a=pc(s),o=ef(s),l=ch(a),i=Voe(o),d=Ivt({start:l,end:i}),u=C.useMemo(()=>{const y=new Map;return t.forEach(_=>{if(!_.due_date)return;const b=_.due_date,w=y.get(b)||[];w.push(_),y.set(b,w)}),y},[t]),p=C.useMemo(()=>t.filter(y=>!y.due_date),[t]),f=async y=>{const _=y.status==="done"?"todo":"done";try{await n.mutateAsync({id:y.id,status:_})}catch{fe.error("Failed to update task")}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>r(LN(s,1)),children:e.jsx(zl,{className:"h-4 w-4"})}),e.jsx("h3",{className:"font-semibold",children:ys(s,"MMMM yyyy")}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>r(Kh(s,1)),children:e.jsx(Ua,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"grid grid-cols-7 text-center",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(y=>e.jsx("div",{className:"text-xs font-medium text-muted-foreground py-2",children:y},y))}),e.jsx("div",{className:"grid grid-cols-7 border-l border-t",children:d.map(y=>{const _=ys(y,"yyyy-MM-dd"),b=u.get(_)||[],w=Woe(y,s),j=Bd(y);return e.jsxs("div",{className:Pt("border-r border-b min-h-[100px] p-1",!w&&"bg-muted/30",j&&"bg-primary/5"),children:[e.jsx("div",{className:Pt("text-xs font-medium mb-1 text-right px-1",!w&&"text-muted-foreground/40",j&&"text-primary font-bold"),children:ys(y,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[b.slice(0,3).map(k=>e.jsxs("button",{onClick:()=>f(k),className:Pt("w-full text-left text-[10px] px-1 py-0.5 rounded truncate flex items-center gap-0.5 hover:bg-muted transition-colors",k.status==="done"?"text-muted-foreground line-through":"text-foreground"),children:[k.status==="done"?e.jsx(ua,{className:"h-2.5 w-2.5 text-emerald-500 shrink-0"}):e.jsx(Kc,{className:"h-2.5 w-2.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[KLe[k.priority]," ",k.title]})]},k.id)),b.length>3&&e.jsxs("p",{className:"text-[9px] text-muted-foreground text-center",children:["+",b.length-3," more"]})]})]},_)})}),p.length>0&&e.jsxs("div",{className:"border rounded-lg p-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:["No Due Date (",p.length,")"]}),e.jsx("div",{className:"space-y-1",children:p.map(y=>e.jsxs("button",{onClick:()=>f(y),className:Pt("w-full text-left text-xs px-2 py-1.5 rounded flex items-center gap-2 hover:bg-muted transition-colors",y.status==="done"&&"opacity-50 line-through"),children:[y.status==="done"?e.jsx(ua,{className:"h-3.5 w-3.5 text-emerald-500 shrink-0"}):e.jsx(Kc,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[KLe[y.priority]," ",y.title]}),y.deal&&e.jsxs("span",{className:"text-muted-foreground ml-auto shrink-0",children:["• ",y.deal.deal_name]})]},y.id))})]})]})}const Zgs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Ygs({open:t,onOpenChange:s,stages:r}){var k;const[n,a]=C.useState(((k=r[0])==null?void 0:k.id)||""),{data:o,isLoading:l}=Ags(n||void 0),i=Egs(),d=Pgs(),[u,p]=C.useState(""),[f,y]=C.useState("medium"),[_,b]=C.useState(""),w=async()=>{if(!(!u.trim()||!n))try{await i.mutateAsync({stage_id:n,title:u.trim(),priority:f,default_due_offset_days:_?parseInt(_):null,sort_order:((o==null?void 0:o.length)||0)+1}),p(""),b(""),fe.success("Template added")}catch{fe.error("Failed to add template")}},j=async S=>{try{await d.mutateAsync(S),fe.success("Template deleted")}catch{fe.error("Failed to delete template")}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-[560px]",children:[e.jsx(Ss,{children:e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(mP,{className:"h-5 w-5"}),"Task Templates by Stage"]})}),e.jsx("p",{className:"text-sm text-muted-foreground -mt-2",children:"Create default tasks that auto-populate when a deal enters a stage."}),e.jsxs("div",{children:[e.jsx(ve,{children:"Pipeline Stage"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:r.filter(S=>!S.is_won_stage&&!S.is_lost_stage).map(S=>e.jsx("button",{onClick:()=>a(S.id),className:Pt("px-3 py-1.5 rounded-full text-xs font-medium border transition-colors",n===S.id?"border-primary bg-primary/10 text-primary":"border-border hover:bg-muted"),children:S.name},S.id))})]}),e.jsx(Ri,{className:"max-h-[250px]",children:e.jsxs("div",{className:"space-y-1.5",children:[o==null?void 0:o.map((S,T)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border rounded-lg group",children:[e.jsx("span",{className:"text-xs",children:Zgs[S.priority]}),e.jsx("span",{className:"text-sm flex-1 truncate",children:S.title}),S.default_due_offset_days&&e.jsxs(rt,{variant:"outline",className:"text-[10px]",children:["+",S.default_due_offset_days,"d"]}),e.jsx("button",{onClick:()=>j(S.id),className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",children:e.jsx(jr,{className:"h-3.5 w-3.5 text-destructive"})})]},S.id)),(o==null?void 0:o.length)===0&&n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No templates for this stage yet"})]})}),n&&e.jsxs("div",{className:"space-y-3 border-t pt-3",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Add Template Task"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"Task title...",value:u,onChange:S=>p(S.target.value),className:"flex-1",onKeyDown:S=>S.key==="Enter"&&w()}),e.jsxs(sr,{value:f,onValueChange:S=>y(S),children:[e.jsx(er,{className:"w-[100px]",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"low",children:"🟢 Low"}),e.jsx(At,{value:"medium",children:"🟡 Med"}),e.jsx(At,{value:"high",children:"🟠 High"}),e.jsx(At,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(ve,{className:"text-xs",children:"Due offset (days from entering stage)"}),e.jsx(Re,{type:"number",placeholder:"e.g., 7",value:_,onChange:S=>b(S.target.value)})]}),e.jsxs(K,{onClick:w,disabled:!u.trim()||i.isPending,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})})}function Xgs(){const{data:t,isLoading:s}=Ngs(),{data:r}=zce(),[n,a]=C.useState("list"),[o,l]=C.useState(""),[i,d]=C.useState("active"),[u,p]=C.useState("all"),[f,y]=C.useState("all"),[_,b]=C.useState(!1),[w,j]=C.useState(!1),k=C.useMemo(()=>{if(!t)return[];const I=new Map;return t.forEach(L=>{L.deal&&I.set(L.deal.id,L.deal.deal_name)}),Array.from(I,([L,R])=>({id:L,name:R}))},[t]),S=C.useMemo(()=>t?t.filter(I=>{var H,Y,se,te;const L=o.toLowerCase(),R=!L||I.title.toLowerCase().includes(L)||((Y=(H=I.deal)==null?void 0:H.deal_name)==null?void 0:Y.toLowerCase().includes(L))||`${((se=I.contact)==null?void 0:se.first_name)||""} ${((te=I.contact)==null?void 0:te.last_name)||""}`.toLowerCase().includes(L),$=i==="all"||i==="active"&&I.status!=="done"||i==="todo"&&I.status==="todo"||i==="in_progress"&&I.status==="in_progress"||i==="done"&&I.status==="done"||i==="overdue"&&I.status!=="done"&&I.due_date&&sy(Ih(I.due_date))&&!Bd(Ih(I.due_date)),q=u==="all"||I.priority===u,U=f==="all"||f==="no_deal"&&!I.deal_id||I.deal_id===f;return R&&$&&q&&U}):[],[t,o,i,u,f]),T=C.useMemo(()=>{if(!t)return{total:0,overdue:0,dueToday:0,dueThisWeek:0,completed:0};const I=t.filter(L=>L.status!=="done");return{total:I.length,overdue:I.filter(L=>L.due_date&&sy(Ih(L.due_date))&&!Bd(Ih(L.due_date))).length,dueToday:I.filter(L=>L.due_date&&Bd(Ih(L.due_date))).length,dueThisWeek:I.filter(L=>L.due_date&&T_t(Ih(L.due_date))).length,completed:t.filter(L=>L.status==="done").length}},[t]);return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-6 max-w-[1600px] mx-auto",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Manage tasks across deals and contacts"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>j(!0),children:[e.jsx(Yx,{className:"h-4 w-4 mr-1"}),"Templates"]}),e.jsxs(K,{size:"sm",onClick:()=>b(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"New Task"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsxs("button",{onClick:()=>d("active"),className:`p-3 rounded-lg border text-left transition-colors ${i==="active"?"border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs font-medium",children:[e.jsx(Hh,{className:"h-3.5 w-3.5"}),"Active"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:T.total})]}),e.jsxs("button",{onClick:()=>d("overdue"),className:`p-3 rounded-lg border text-left transition-colors ${i==="overdue"?"border-destructive bg-destructive/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-destructive text-xs font-medium",children:[e.jsx(Ju,{className:"h-3.5 w-3.5"}),"Overdue"]}),e.jsx("p",{className:"text-xl font-bold mt-1 text-destructive",children:T.overdue})]}),e.jsxs("button",{onClick:()=>{d("active")},className:"p-3 rounded-lg border text-left hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-xs font-medium",children:[e.jsx(Tn,{className:"h-3.5 w-3.5"}),"Due Today"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:T.dueToday})]}),e.jsxs("button",{onClick:()=>{d("active")},className:"p-3 rounded-lg border text-left hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 text-blue-600 text-xs font-medium",children:[e.jsx(id,{className:"h-3.5 w-3.5"}),"This Week"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:T.dueThisWeek})]}),e.jsxs("button",{onClick:()=>d("done"),className:`p-3 rounded-lg border text-left transition-colors ${i==="done"?"border-emerald-500 bg-emerald-500/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-emerald-600 text-xs font-medium",children:[e.jsx(ua,{className:"h-3.5 w-3.5"}),"Completed"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:T.completed})]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-3 items-start md:items-center",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search tasks...",value:o,onChange:I=>l(I.target.value),className:"pl-9"})]}),e.jsxs(sr,{value:u,onValueChange:p,children:[e.jsx(er,{className:"w-[130px]",children:e.jsx(rr,{placeholder:"Priority"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Priorities"}),e.jsx(At,{value:"urgent",children:"🔴 Urgent"}),e.jsx(At,{value:"high",children:"🟠 High"}),e.jsx(At,{value:"medium",children:"🟡 Medium"}),e.jsx(At,{value:"low",children:"🟢 Low"})]})]}),e.jsxs(sr,{value:f,onValueChange:y,children:[e.jsx(er,{className:"w-[160px]",children:e.jsx(rr,{placeholder:"Deal"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Deals"}),e.jsx(At,{value:"no_deal",children:"No Deal"}),k.map(I=>e.jsx(At,{value:I.id,children:I.name},I.id))]})]}),e.jsxs("div",{className:"flex items-center border rounded-lg p-0.5 ml-auto",children:[e.jsx("button",{onClick:()=>a("list"),className:`p-1.5 rounded-md transition-colors ${n==="list"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(Hh,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>a("kanban"),className:`p-1.5 rounded-md transition-colors ${n==="kanban"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(Xx,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>a("calendar"),className:`p-1.5 rounded-md transition-colors ${n==="calendar"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(id,{className:"h-4 w-4"})})]})]}),s?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-primary border-t-transparent rounded-full"})}):e.jsxs(e.Fragment,{children:[n==="list"&&e.jsx(Ugs,{tasks:S}),n==="kanban"&&e.jsx(Wgs,{tasks:S}),n==="calendar"&&e.jsx(Kgs,{tasks:S})]}),e.jsx(WJe,{open:_,onOpenChange:b}),e.jsx(Ygs,{open:w,onOpenChange:j,stages:r||[]})]})})}const eve=[{value:"video_intro",label:"Video Intro",icon:Nn,description:"Add an intro video"},{value:"testimonials",label:"Testimonials",icon:kP,description:"Client testimonials carousel"},{value:"specialties",label:"Specialties",icon:Wh,description:"Tags for your specialties"},{value:"custom_links",label:"Custom Links",icon:Wo,description:"Custom CTA buttons"},{value:"social_media",label:"Social Media",icon:ld,description:"Links to your social profiles"}],Qgs=["First-Time Buyers","Luxury Homes","Investment Properties","Relocation","New Construction","Condos & Townhomes","Waterfront","Commercial","Land & Lots","Senior Living","Military/VA","Short Sales & Foreclosures"],Jgs={video_intro:{video_url:""},testimonials:{testimonials:[{name:"",quote:"",role:""}]},specialties:{tags:[]},custom_links:{links:[{label:"",url:""}]},social_media:{platforms:[]}};function GJe({cardId:t}){const{data:s,isLoading:r}=M0t(t),n=T0t(),a=A0t(),o=E0t(),[l,i]=C.useState(!1),[d,u]=C.useState(""),[p,f]=C.useState(null);if(r)return e.jsxs("div",{className:"space-y-3",children:[e.jsx(xs,{className:"h-16 w-full"}),e.jsx(xs,{className:"h-16 w-full"})]});const y=()=>{d&&n.mutate({card_id:t,block_type:d,sort_order:(s==null?void 0:s.length)||0,config:Jgs[d]||{}},{onSuccess:()=>{i(!1),u("")}})},_=S=>{a.mutate({id:S.id,is_visible:!S.is_visible})},b=(S,T)=>{if(!s)return;const I=s.findIndex($=>$.id===S.id),L=T==="up"?I-1:I+1;if(L<0||L>=s.length)return;const R=s[L];a.mutate({id:S.id,sort_order:R.sort_order}),a.mutate({id:R.id,sort_order:S.sort_order})},w=S=>{confirm("Remove this block from this card?")&&o.mutate(S.id)},j=(S,T)=>{a.mutate({id:S.id,config:T},{onSuccess:()=>f(null)})},k=S=>eve.find(T=>T.value===S);return e.jsxs("div",{className:"space-y-3",children:[!s||s.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted-foreground mb-4 text-sm",children:"No blocks yet. Add a block to customize this card."}),e.jsxs(K,{size:"sm",onClick:()=>i(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Block"]})]}):e.jsxs(e.Fragment,{children:[s.map((S,T)=>{const I=k(S.block_type),L=(I==null?void 0:I.icon)||Wh;return e.jsx(Ee,{className:S.is_visible?"":"opacity-50",children:e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bu,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx(L,{className:"h-4 w-4 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-xs",children:(I==null?void 0:I.label)||S.block_type}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:exs(S)})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(S,"up"),disabled:T===0,children:e.jsx(Vd,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(S,"down"),disabled:T===s.length-1,children:e.jsx(sh,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(S),children:S.is_visible?e.jsx(xa,{className:"h-3 w-3"}):e.jsx(Im,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>f(S),children:"Edit"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>w(S),children:e.jsx(jr,{className:"h-3 w-3"})})]})]})})},S.id)}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>i(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Block"]})]}),e.jsx(_s,{open:l,onOpenChange:i,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Add Block"})}),e.jsx("div",{className:"grid gap-3",children:eve.map(S=>{const T=S.icon;return e.jsxs("button",{onClick:()=>u(S.value),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors ${d===S.value?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[e.jsx(T,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:S.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.description})]})]},S.value)})}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{onClick:y,disabled:!d||n.isPending,children:"Add Block"})]})]})}),p&&e.jsx(txs,{block:p,onSave:S=>j(p,S),onClose:()=>f(null)})]})}function exs(t){var r;const s=t.config;switch(t.block_type){case"video_intro":return s.video_url?"Video configured":"No video set";case"testimonials":{const n=((r=s.testimonials)==null?void 0:r.length)||0;return`${n} testimonial${n!==1?"s":""}`}case"specialties":{const n=s.tags||[];return n.length?n.slice(0,3).join(", ")+(n.length>3?"...":""):"No tags"}case"custom_links":{const n=s.links||[];return`${n.length} link${n.length!==1?"s":""}`}case"social_media":{const n=s.platforms||[];return n.length?n.map(a=>a.platform).join(", "):"No platforms"}default:return""}}function txs({block:t,onSave:s,onClose:r}){const[n,a]=C.useState(t.config),o=eve.find(l=>l.value===t.block_type);return e.jsx(_s,{open:!0,onOpenChange:r,children:e.jsxs(vs,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsxs(ks,{children:["Edit ",o==null?void 0:o.label]})}),t.block_type==="video_intro"&&e.jsx(sxs,{config:n,onChange:a,cardId:t.card_id}),t.block_type==="testimonials"&&e.jsx(rxs,{config:n,onChange:a}),t.block_type==="specialties"&&e.jsx(nxs,{config:n,onChange:a}),t.block_type==="custom_links"&&e.jsx(axs,{config:n,onChange:a}),t.block_type==="social_media"&&e.jsx(ixs,{config:n,onChange:a}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(K,{onClick:()=>s(n),children:"Save"})]})]})})}function sxs({config:t,onChange:s,cardId:r}){var _,b;const[n,a]=C.useState(""),[o,l]=C.useState((_=t.video_url)!=null&&_.includes("youtube")||(b=t.video_url)!=null&&b.includes("youtu.be")?"youtube":"library"),{data:i}=wt({queryKey:["card-owner",r],queryFn:async()=>{const{data:w}=await G.from("agent_cards").select("user_id").eq("id",r).single();return w==null?void 0:w.user_id},enabled:!!r}),{data:d,isLoading:u}=wt({queryKey:["agent-videos-library",i],queryFn:async()=>{const{data:w,error:j}=await G.from("agent_videos").select("id, title, bunny_video_id, thumbnail_url, playback_url, created_at").eq("owner_user_id",i).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(j)throw j;return w||[]},enabled:!!i}),p=(d==null?void 0:d.filter(w=>!n||(w.title||"").toLowerCase().includes(n.toLowerCase())))||[],f=t.bunny_video_id,y=w=>{var T;const j=(T=w.playback_url)==null?void 0:T.match(/\/(?:play|embed)\/(\d+)\//),S=`https://iframe.mediadelivery.net/embed/${j?j[1]:"570924"}/${w.bunny_video_id}?autoplay=false&responsive=true`;s({...t,video_url:S,bunny_video_id:w.bunny_video_id,video_source:"library"})};return e.jsx("div",{className:"space-y-4",children:e.jsxs(ka,{value:o,onValueChange:l,children:[e.jsxs(_a,{className:"w-full",children:[e.jsx(js,{value:"library",className:"flex-1",children:"Video Library"}),e.jsx(js,{value:"youtube",className:"flex-1",children:"YouTube URL"})]}),e.jsxs(zs,{value:"library",className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search videos...",value:n,onChange:w=>a(w.target.value),className:"pl-9"})]}),e.jsx(Ri,{className:"h-[240px]",children:u?e.jsxs("div",{className:"space-y-2",children:[e.jsx(xs,{className:"h-14 w-full"}),e.jsx(xs,{className:"h-14 w-full"})]}):p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:(d==null?void 0:d.length)===0?"No videos in library yet":"No matching videos"}):e.jsx("div",{className:"space-y-1.5 pr-3",children:p.map(w=>e.jsxs("button",{onClick:()=>y(w),className:`w-full flex items-center gap-3 p-2 rounded-lg border text-left transition-colors ${f===w.bunny_video_id?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[w.thumbnail_url?e.jsx("img",{src:w.thumbnail_url,alt:"",className:"h-10 w-16 rounded object-cover flex-shrink-0 bg-muted",onError:j=>{var k;j.currentTarget.style.display="none",(k=j.currentTarget.nextElementSibling)==null||k.classList.remove("hidden")}}):null,e.jsx("div",{className:`h-10 w-16 rounded bg-muted flex items-center justify-center flex-shrink-0 ${w.thumbnail_url?"hidden":""}`,children:e.jsx(Nn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:w.title||"Untitled Video"}),f===w.bunny_video_id&&e.jsx(ha,{className:"h-4 w-4 text-primary flex-shrink-0"})]},w.id))})})]}),e.jsx(zs,{value:"youtube",className:"space-y-3 mt-3",children:e.jsxs("div",{children:[e.jsx(ve,{children:"YouTube URL"}),e.jsx(Re,{placeholder:"https://www.youtube.com/watch?v=...",value:t.video_source==="youtube"&&t.video_url||"",onChange:w=>s({...t,video_url:w.target.value,bunny_video_id:null,video_source:"youtube"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Paste a YouTube video link"})]})})]})})}function rxs({config:t,onChange:s}){const r=t.testimonials||[],n=(l,i,d)=>{const u=[...r];u[l]={...u[l],[i]:d},s({...t,testimonials:u})},a=()=>s({...t,testimonials:[...r,{name:"",quote:"",role:""}]}),o=l=>s({...t,testimonials:r.filter((i,d)=>d!==l)});return e.jsxs("div",{className:"space-y-4",children:[r.map((l,i)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ve,{className:"text-xs font-medium",children:["Testimonial ",i+1]}),r.length>1&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>o(i),children:e.jsx(jr,{className:"h-3 w-3"})})]}),e.jsx(Re,{placeholder:"Client name",value:l.name,onChange:d=>n(i,"name",d.target.value)}),e.jsx(Re,{placeholder:"Role/title (optional)",value:l.role||"",onChange:d=>n(i,"role",d.target.value)}),e.jsx("textarea",{className:"w-full min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm",placeholder:"Their testimonial quote...",value:l.quote,onChange:d=>n(i,"quote",d.target.value)})]})},i)),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Testimonial"]})]})}function nxs({config:t,onChange:s}){const r=t.tags||[],[n,a]=C.useState(""),o=i=>{s({...t,tags:r.includes(i)?r.filter(d=>d!==i):[...r,i]})},l=()=>{n.trim()&&!r.includes(n.trim())&&(s({...t,tags:[...r,n.trim()]}),a(""))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm mb-2 block",children:"Preset Specialties"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Qgs.map(i=>e.jsx("button",{onClick:()=>o(i),className:`px-3 py-1.5 text-xs rounded-full border transition-colors ${r.includes(i)?"bg-primary text-primary-foreground border-primary":"bg-muted border-border hover:bg-muted/80"}`,children:i},i))})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm mb-2 block",children:"Custom Tag"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{placeholder:"Add your own...",value:n,onChange:i=>a(i.target.value),onKeyDown:i=>i.key==="Enter"&&(i.preventDefault(),l())}),e.jsx(K,{variant:"outline",size:"sm",onClick:l,children:"Add"})]})]}),r.length>0&&e.jsxs("div",{children:[e.jsxs(ve,{className:"text-xs text-muted-foreground mb-1 block",children:["Selected (",r.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.map(i=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs bg-primary/10 text-primary rounded-full",children:[i,e.jsx("button",{onClick:()=>o(i),className:"hover:text-destructive",children:"×"})]},i))})]})]})}function axs({config:t,onChange:s}){const r=t.links||[],n=(l,i,d)=>{const u=[...r];u[l]={...u[l],[i]:d},s({...t,links:u})},a=()=>s({...t,links:[...r,{label:"",url:""}]}),o=l=>s({...t,links:r.filter((i,d)=>d!==l)});return e.jsxs("div",{className:"space-y-3",children:[r.map((l,i)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Re,{placeholder:"Button label",value:l.label,onChange:d=>n(i,"label",d.target.value)}),e.jsx(Re,{placeholder:"https://...",value:l.url,onChange:d=>n(i,"url",d.target.value)})]}),r.length>1&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 mt-1 text-destructive",onClick:()=>o(i),children:e.jsx(jr,{className:"h-3 w-3"})})]},i)),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Link"]})]})}const ZLe=[{value:"instagram",label:"Instagram"},{value:"facebook",label:"Facebook"},{value:"linkedin",label:"LinkedIn"},{value:"twitter",label:"X (Twitter)"},{value:"youtube",label:"YouTube"},{value:"tiktok",label:"TikTok"},{value:"zillow",label:"Zillow"},{value:"realtor",label:"Realtor.com"},{value:"spotify",label:"Spotify"},{value:"apple_music",label:"Apple Music"}];function ixs({config:t,onChange:s}){const r=t.platforms||[],n=d=>{r.find(u=>u.platform===d)||s({...t,platforms:[...r,{platform:d,url:""}]})},a=(d,u)=>{const p=[...r];p[d]={...p[d],url:u},s({...t,platforms:p})},o=d=>{s({...t,platforms:r.filter((u,p)=>p!==d)})},l=ZLe.filter(d=>!r.find(u=>u.platform===d.value)),i=d=>{const u=$ge[d],p=ZLe.find(f=>f.value===d);return{label:(p==null?void 0:p.label)||d,color:(u==null?void 0:u.color)||"#666",iconPath:u==null?void 0:u.icon}};return e.jsxs("div",{className:"space-y-4",children:[r.length>0&&e.jsx("div",{className:"space-y-3",children:r.map((d,u)=>{const p=i(d.platform);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg flex items-center justify-center flex-shrink-0 border",style:{borderColor:p.color+"30",backgroundColor:p.color+"10"},children:p.iconPath&&e.jsx("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:p.color,children:e.jsx("path",{d:p.iconPath})})}),e.jsx("div",{className:"flex-1",children:e.jsx(Re,{placeholder:`Your ${p.label} profile URL`,value:d.url,onChange:f=>a(u,f.target.value)})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive flex-shrink-0",onClick:()=>o(u),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]},u)})}),l.length>0&&e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-muted-foreground mb-2 block",children:"Add a platform"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(d=>{const u=$ge[d.value];return e.jsxs("button",{onClick:()=>n(d.value),className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-full border border-border bg-muted hover:bg-muted/80 transition-colors",children:[(u==null?void 0:u.icon)&&e.jsx("svg",{viewBox:"0 0 24 24",width:12,height:12,fill:u.color,children:e.jsx("path",{d:u.icon})}),d.label]},d.value)})})]}),r.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Tap a platform above to add your social media profile."})]})}var oxs=Object.defineProperty,Gie=Object.getOwnPropertySymbols,KJe=Object.prototype.hasOwnProperty,ZJe=Object.prototype.propertyIsEnumerable,YLe=(t,s,r)=>s in t?oxs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,tve=(t,s)=>{for(var r in s||(s={}))KJe.call(s,r)&&YLe(t,r,s[r]);if(Gie)for(var r of Gie(s))ZJe.call(s,r)&&YLe(t,r,s[r]);return t},sve=(t,s)=>{var r={};for(var n in t)KJe.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&Gie)for(var n of Gie(t))s.indexOf(n)<0&&ZJe.call(t,n)&&(r[n]=t[n]);return r};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var tS;(t=>{const s=class ro{constructor(d,u,p,f){if(this.version=d,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],dro.MAX_VERSION)throw new RangeError("Version value out of range");if(f<-1||f>7)throw new RangeError("Mask value out of range");this.size=d*4+17;let y=[];for(let b=0;b7)throw new RangeError("Invalid value");let b,w;for(b=p;;b++){const T=ro.getNumDataCodewords(b,u)*8,I=l.getTotalBits(d,b);if(I<=T){w=I;break}if(b>=f)throw new RangeError("Data too long")}for(const T of[ro.Ecc.MEDIUM,ro.Ecc.QUARTILE,ro.Ecc.HIGH])_&&w<=ro.getNumDataCodewords(b,T)*8&&(u=T);let j=[];for(const T of d){r(T.mode.modeBits,4,j),r(T.numChars,T.mode.numCharCountBits(b),j);for(const I of T.getData())j.push(I)}a(j.length==w);const k=ro.getNumDataCodewords(b,u)*8;a(j.length<=k),r(0,Math.min(4,k-j.length),j),r(0,(8-j.length%8)%8,j),a(j.length%8==0);for(let T=236;j.lengthS[I>>>3]|=T<<7-(I&7)),new ro(b,u,S,y)}getModule(d,u){return 0<=d&&d>>9)*1335;const f=(u<<10|p)^21522;a(f>>>15==0);for(let y=0;y<=5;y++)this.setFunctionModule(8,y,n(f,y));this.setFunctionModule(8,7,n(f,6)),this.setFunctionModule(8,8,n(f,7)),this.setFunctionModule(7,8,n(f,8));for(let y=9;y<15;y++)this.setFunctionModule(14-y,8,n(f,y));for(let y=0;y<8;y++)this.setFunctionModule(this.size-1-y,8,n(f,y));for(let y=8;y<15;y++)this.setFunctionModule(8,this.size-15+y,n(f,y));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let d=this.version;for(let p=0;p<12;p++)d=d<<1^(d>>>11)*7973;const u=this.version<<12|d;a(u>>>18==0);for(let p=0;p<18;p++){const f=n(u,p),y=this.size-11+p%3,_=Math.floor(p/3);this.setFunctionModule(y,_,f),this.setFunctionModule(_,y,f)}}drawFinderPattern(d,u){for(let p=-4;p<=4;p++)for(let f=-4;f<=4;f++){const y=Math.max(Math.abs(f),Math.abs(p)),_=d+f,b=u+p;0<=_&&_{(T!=w-y||L>=b)&&S.push(I[T])});return a(S.length==_),S}drawCodewords(d){if(d.length!=Math.floor(ro.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let p=this.size-1;p>=1;p-=2){p==6&&(p=5);for(let f=0;f>>3],7-(u&7)),u++)}}a(u==d.length*8)}applyMask(d){if(d<0||d>7)throw new RangeError("Mask value out of range");for(let u=0;u5&&d++):(this.finderPenaltyAddHistory(b,w),_||(d+=this.finderPenaltyCountPatterns(w)*ro.PENALTY_N3),_=this.modules[y][j],b=1);d+=this.finderPenaltyTerminateAndCount(_,b,w)*ro.PENALTY_N3}for(let y=0;y5&&d++):(this.finderPenaltyAddHistory(b,w),_||(d+=this.finderPenaltyCountPatterns(w)*ro.PENALTY_N3),_=this.modules[j][y],b=1);d+=this.finderPenaltyTerminateAndCount(_,b,w)*ro.PENALTY_N3}for(let y=0;y_+(b?1:0),u);const p=this.size*this.size,f=Math.ceil(Math.abs(u*20-p*10)/p)-1;return a(0<=f&&f<=9),d+=f*ro.PENALTY_N4,a(0<=d&&d<=2568888),d}getAlignmentPatternPositions(){if(this.version==1)return[];{const d=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(d*2-2))*2;let p=[6];for(let f=this.size-7;p.lengthro.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*d+128)*d+64;if(d>=2){const p=Math.floor(d/7)+2;u-=(25*p-10)*p-55,d>=7&&(u-=36)}return a(208<=u&&u<=29648),u}static getNumDataCodewords(d,u){return Math.floor(ro.getNumRawDataModules(d)/8)-ro.ECC_CODEWORDS_PER_BLOCK[u.ordinal][d]*ro.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][d]}static reedSolomonComputeDivisor(d){if(d<1||d>255)throw new RangeError("Degree out of range");let u=[];for(let f=0;f0);for(const f of d){const y=f^p.shift();p.push(0),u.forEach((_,b)=>p[b]^=ro.reedSolomonMultiply(_,y))}return p}static reedSolomonMultiply(d,u){if(d>>>8||u>>>8)throw new RangeError("Byte out of range");let p=0;for(let f=7;f>=0;f--)p=p<<1^(p>>>7)*285,p^=(u>>>f&1)*d;return a(p>>>8==0),p}finderPenaltyCountPatterns(d){const u=d[1];a(u<=this.size*3);const p=u>0&&d[2]==u&&d[3]==u*3&&d[4]==u&&d[5]==u;return(p&&d[0]>=u*4&&d[6]>=u?1:0)+(p&&d[6]>=u*4&&d[0]>=u?1:0)}finderPenaltyTerminateAndCount(d,u,p){return d&&(this.finderPenaltyAddHistory(u,p),u=0),u+=this.size,this.finderPenaltyAddHistory(u,p),this.finderPenaltyCountPatterns(p)}finderPenaltyAddHistory(d,u){u[0]==0&&(d+=this.size),u.pop(),u.unshift(d)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=s;function r(i,d,u){if(d<0||d>31||i>>>d)throw new RangeError("Value out of range");for(let p=d-1;p>=0;p--)u.push(i>>>p&1)}function n(i,d){return(i>>>d&1)!=0}function a(i){if(!i)throw new Error("Assertion error")}const o=class Dc{constructor(d,u,p){if(this.mode=d,this.numChars=u,this.bitData=p,u<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(d){let u=[];for(const p of d)r(p,8,u);return new Dc(Dc.Mode.BYTE,d.length,u)}static makeNumeric(d){if(!Dc.isNumeric(d))throw new RangeError("String contains non-numeric characters");let u=[];for(let p=0;p=1<{(s=>{const r=class{constructor(a,o){this.ordinal=a,this.formatBits=o}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(t.QrCode||(t.QrCode={}))})(tS||(tS={}));(t=>{(s=>{const r=class{constructor(a,o){this.modeBits=a,this.numBitsCharCount=o}numCharCountBits(a){return this.numBitsCharCount[Math.floor((a+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(t.QrSegment||(t.QrSegment={}))})(tS||(tS={}));var t5=tS;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var lxs={L:t5.QrCode.Ecc.LOW,M:t5.QrCode.Ecc.MEDIUM,Q:t5.QrCode.Ecc.QUARTILE,H:t5.QrCode.Ecc.HIGH},YJe=128,XJe="L",QJe="#FFFFFF",JJe="#000000",eet=!1,tet=1,cxs=4,dxs=0,uxs=.1;function set(t,s=0){const r=[];return t.forEach(function(n,a){let o=null;n.forEach(function(l,i){if(!l&&o!==null){r.push(`M${o+s} ${a+s}h${i-o}v1H${o+s}z`),o=null;return}if(i===n.length-1){if(!l)return;o===null?r.push(`M${i+s},${a+s} h1v1H${i+s}z`):r.push(`M${o+s},${a+s} h${i+1-o}v1H${o+s}z`);return}l&&o===null&&(o=i)})}),r.join("")}function ret(t,s){return t.slice().map((r,n)=>n=s.y+s.h?r:r.map((a,o)=>o=s.x+s.w?a:!1))}function hxs(t,s,r,n){if(n==null)return null;const a=t.length+r*2,o=Math.floor(s*uxs),l=a/s,i=(n.width||o)*l,d=(n.height||o)*l,u=n.x==null?t.length/2-i/2:n.x*l,p=n.y==null?t.length/2-d/2:n.y*l,f=n.opacity==null?1:n.opacity;let y=null;if(n.excavate){let b=Math.floor(u),w=Math.floor(p),j=Math.ceil(i+u-b),k=Math.ceil(d+p-w);y={x:b,y:w,w:j,h:k}}const _=n.crossOrigin;return{x:u,y:p,h:d,w:i,excavation:y,opacity:f,crossOrigin:_}}function mxs(t,s){return s!=null?Math.max(Math.floor(s),0):t?cxs:dxs}function net({value:t,level:s,minVersion:r,includeMargin:n,marginSize:a,imageSettings:o,size:l,boostLevel:i}){let d=ht.useMemo(()=>{const b=(Array.isArray(t)?t:[t]).reduce((w,j)=>(w.push(...t5.QrSegment.makeSegments(j)),w),[]);return t5.QrCode.encodeSegments(b,lxs[s],r,void 0,void 0,i)},[t,s,r,i]);const{cells:u,margin:p,numCells:f,calculatedImageSettings:y}=ht.useMemo(()=>{let _=d.getModules();const b=mxs(n,a),w=_.length+b*2,j=hxs(_,l,b,o);return{cells:_,margin:b,numCells:w,calculatedImageSettings:j}},[d,l,o,n,a]);return{qrcode:d,margin:p,cells:u,numCells:f,calculatedImageSettings:y}}var pxs=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),fxs=ht.forwardRef(function(s,r){const n=s,{value:a,size:o=YJe,level:l=XJe,bgColor:i=QJe,fgColor:d=JJe,includeMargin:u=eet,minVersion:p=tet,boostLevel:f,marginSize:y,imageSettings:_}=n,w=sve(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:j}=w,k=sve(w,["style"]),S=_==null?void 0:_.src,T=ht.useRef(null),I=ht.useRef(null),L=ht.useCallback(Q=>{T.current=Q,typeof r=="function"?r(Q):r&&(r.current=Q)},[r]),[R,$]=ht.useState(!1),{margin:q,cells:U,numCells:H,calculatedImageSettings:Y}=net({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:y,imageSettings:_,size:o});ht.useEffect(()=>{if(T.current!=null){const Q=T.current,de=Q.getContext("2d");if(!de)return;let re=U;const ae=I.current,le=Y!=null&&ae!==null&&ae.complete&&ae.naturalHeight!==0&&ae.naturalWidth!==0;le&&Y.excavation!=null&&(re=ret(U,Y.excavation));const he=window.devicePixelRatio||1;Q.height=Q.width=o*he;const be=o/H*he;de.scale(be,be),de.fillStyle=i,de.fillRect(0,0,H,H),de.fillStyle=d,pxs?de.fill(new Path2D(set(re,q))):U.forEach(function(_e,je){_e.forEach(function(Ne,Ge){Ne&&de.fillRect(Ge+q,je+q,1,1)})}),Y&&(de.globalAlpha=Y.opacity),le&&de.drawImage(ae,Y.x+q,Y.y+q,Y.w,Y.h)}}),ht.useEffect(()=>{$(!1)},[S]);const se=tve({height:o,width:o},j);let te=null;return S!=null&&(te=ht.createElement("img",{src:S,key:S,style:{display:"none"},onLoad:()=>{$(!0)},ref:I,crossOrigin:Y==null?void 0:Y.crossOrigin})),ht.createElement(ht.Fragment,null,ht.createElement("canvas",tve({style:se,height:o,width:o,ref:L,role:"img"},k)),te)});fxs.displayName="QRCodeCanvas";var yD=ht.forwardRef(function(s,r){const n=s,{value:a,size:o=YJe,level:l=XJe,bgColor:i=QJe,fgColor:d=JJe,includeMargin:u=eet,minVersion:p=tet,boostLevel:f,title:y,marginSize:_,imageSettings:b}=n,w=sve(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:j,cells:k,numCells:S,calculatedImageSettings:T}=net({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:_,imageSettings:b,size:o});let I=k,L=null;b!=null&&T!=null&&(T.excavation!=null&&(I=ret(k,T.excavation)),L=ht.createElement("image",{href:b.src,height:T.h,width:T.w,x:T.x+j,y:T.y+j,preserveAspectRatio:"none",opacity:T.opacity,crossOrigin:T.crossOrigin}));const R=set(I,j);return ht.createElement("svg",tve({height:o,width:o,viewBox:`0 0 ${S} ${S}`,ref:r,role:"img"},w),!!y&&ht.createElement("title",null,y),ht.createElement("path",{fill:i,d:`M0,0 h${S}v${S}H0z`,shapeRendering:"crispEdges"}),ht.createElement("path",{fill:d,d:R,shapeRendering:"crispEdges"}),L)});yD.displayName="QRCodeSVG";function gxs({slug:t,agentName:s}){const r=C.useRef(null),n=`https://cards.relevelup.com/${t}`,a=C.useCallback(()=>{var f;const o=(f=r.current)==null?void 0:f.querySelector("svg");if(!o)return;const l=document.createElement("canvas"),i=1024;l.width=i,l.height=i;const d=l.getContext("2d");if(!d)return;const u=new XMLSerializer().serializeToString(o),p=new Image;p.onload=()=>{d.fillStyle="#ffffff",d.fillRect(0,0,i,i),d.drawImage(p,0,0,i,i);const y=document.createElement("a");y.download=`${t}-qr-code.png`,y.href=l.toDataURL("image/png"),y.click(),fe.success("QR code downloaded!")},p.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(u)))},[t]);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{className:"text-sm font-medium",children:"QR Code"}),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{ref:r,className:"bg-white p-3 rounded-lg border shadow-sm shrink-0",children:e.jsx(yD,{value:n,size:120,level:"H",bgColor:"#ffffff",fgColor:"#000000"})}),e.jsxs("div",{className:"space-y-2 min-w-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Download this QR code to use on business cards, flyers, signs, or any print materials. Scanning it opens your digital card instantly."}),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"gap-1.5",children:[e.jsx(xi,{className:"h-3.5 w-3.5"}),"Download PNG"]})]})]})]})}function zpe(t){return{is_published:t.is_published,theme:t.theme,title:t.title||"",positioning_statement:t.positioning_statement||"",bio:t.bio||"",review_snippet:t.review_snippet||"",review_source_url:t.review_source_url||"",booking_url:t.booking_url||"",custom_cta_label:t.custom_cta_label||"",show_photo:t.show_photo,show_bio:t.show_bio,show_credentials:t.show_credentials,show_social_links:t.show_social_links,show_save_contact:t.show_save_contact,show_leave_review:t.show_leave_review,show_refer_friend:t.show_refer_friend,brokerage_display_name:t.brokerage_display_name||"",brokerage_logo_url:t.brokerage_logo_url||"",brokerage_logo_size:t.brokerage_logo_size||56,team_name:t.team_name||"",team_logo_url:t.team_logo_url||"",team_logo_size:t.team_logo_size||56,bold_theme_colors:t.bold_theme_colors||null,display_email:t.display_email||""}}function xxs(){const{user:t}=Hs(),{data:s,isLoading:r}=k0t(t==null?void 0:t.id),n=eT(),[a,o]=C.useState(null),l=C.useMemo(()=>a||(s?zpe(s):null),[a,s]);if(r)return e.jsx(Ts,{children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 space-y-4",children:[e.jsx(xs,{className:"h-8 w-48"}),e.jsx(xs,{className:"h-32 w-full"}),e.jsx(xs,{className:"h-32 w-full"})]})});if(!s)return e.jsx(Ts,{children:e.jsx(vxs,{userId:t==null?void 0:t.id})});const i=l||zpe(s),d=u=>{o(p=>{const f=p||zpe(s);return typeof u=="function"?u(f):u})};return e.jsx(Ts,{children:e.jsxs("div",{className:"flex gap-6 items-start",children:[e.jsxs("div",{className:`${n?"w-full":"flex-1 min-w-0"} max-w-2xl p-4 space-y-6 animate-fade-in`,children:[e.jsx(_xs,{card:s}),e.jsx(Nxs,{card:s,form:i,setForm:d})]}),!n&&e.jsx("div",{className:"w-[400px] shrink-0","aria-hidden":"true"}),!n&&e.jsx("div",{className:"fixed right-8 top-[5.5rem] w-[400px] z-30",style:{height:"calc(100vh - 6.5rem)"},children:e.jsxs("div",{className:"rounded-xl border bg-muted/30 overflow-hidden h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b bg-card shrink-0",children:[e.jsx(hk,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:"Live Preview"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(yxs,{card:s,form:i})})]})})]})})}function yxs({card:t,form:s}){const{data:r}=wt({queryKey:["card-preview-profile",t.user_id],queryFn:async()=>{const{data:a}=await G.from("profiles").select("name, email, phone, avatar_url, brokerage_id").eq("id",t.user_id).single();let o=(a==null?void 0:a.avatar_url)||null;if(!o){const{data:l}=await G.storage.from("avatars").list(`${t.user_id}`);if(l&&l.length>0){const{data:i}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${l[0].name}`);o=`${i.publicUrl}?t=${Date.now()}`}}return{...a,avatar_url:o}}}),n=C.useMemo(()=>({...t,is_published:s.is_published,theme:s.theme,title:s.title||null,positioning_statement:s.positioning_statement||null,bio:s.bio||null,review_snippet:s.review_snippet||null,review_source_url:s.review_source_url||null,booking_url:s.booking_url||null,custom_cta_label:s.custom_cta_label||null,custom_cta_url:t.custom_cta_url,show_photo:s.show_photo,show_bio:s.show_bio,show_video:t.show_video,show_credentials:s.show_credentials,show_social_links:s.show_social_links,show_save_contact:s.show_save_contact,show_leave_review:s.show_leave_review,show_refer_friend:s.show_refer_friend,brokerage_display_name:s.brokerage_display_name||null,brokerage_logo_url:s.brokerage_logo_url||null,brokerage_logo_size:s.brokerage_logo_size,team_name:s.team_name||null,team_logo_url:s.team_logo_url||null,team_logo_size:s.team_logo_size,display_email:s.display_email||null,social_links:t.social_links||[],profile:{name:(r==null?void 0:r.name)||null,email:s.display_email||(r==null?void 0:r.email)||null,phone:(r==null?void 0:r.phone)||null,brokerage_id:(r==null?void 0:r.brokerage_id)||null},brokerage_name:s.brokerage_display_name||null,avatar_url:(r==null?void 0:r.avatar_url)||null}),[t,s,r]);return e.jsx("div",{className:"transform scale-[0.85] origin-top",children:e.jsx(r_e,{card:n})})}function vxs({userId:t}){var d;const[s,r]=C.useState(""),n=E9e(),{data:a}=wt({queryKey:["my-profile-for-card",t],queryFn:async()=>{if(!t)return null;const{data:u}=await G.from("profiles").select("name").eq("id",t).single();return u},enabled:!!t}),o=((d=a==null?void 0:a.name)==null?void 0:d.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||"",l=()=>{if(!t)return;const u=(s.trim()||o).toLowerCase().replace(/[^a-z0-9-]/g,"-");if(!u){fe.error("Please enter a URL slug for your card");return}n.mutate({user_id:t,slug:u,is_published:!0},{onSuccess:()=>fe.success("Your digital card has been created!")})},i=[{icon:Lm,title:"Shareable Link",desc:"One link that works everywhere"},{icon:Fm,title:"Lead Capture",desc:"Collect leads automatically"},{icon:ih,title:"Always Up-to-Date",desc:"Edit anytime, changes are instant"},{icon:Bl,title:"Fully Customizable",desc:"Themes, colors, and content blocks"}];return e.jsxs("div",{className:"max-w-2xl mx-auto p-4 animate-fade-in",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary/90 via-primary to-primary/80 p-8 md:p-12 mb-8 text-primary-foreground",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_30%_20%,rgba(255,255,255,0.15),transparent_50%)]"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_80%_80%,rgba(0,0,0,0.1),transparent_50%)]"}),e.jsxs("div",{className:"relative z-10",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full bg-white/20 backdrop-blur-sm text-sm font-medium mb-4",children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),"New Feature"]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-3 tracking-tight",children:"Your Digital Business Card"}),e.jsx("p",{className:"text-primary-foreground/80 text-lg max-w-md leading-relaxed",children:"Ditch the paper. Share a beautiful, interactive card that captures leads and makes a lasting impression."})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 mb-8",children:i.map(u=>e.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl border bg-card hover:shadow-md transition-shadow",children:[e.jsx("div",{className:"mt-0.5 p-2 rounded-lg bg-primary/10 shrink-0",children:e.jsx(u.icon,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:u.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u.desc})]})]},u.title))}),e.jsxs(Ee,{className:"shadow-lg border-2",children:[e.jsxs(It,{className:"text-center pb-2",children:[e.jsx(Ot,{className:"text-xl",children:"Set Up Your Card"}),e.jsx(pr,{children:"Choose a URL slug — this is the link you'll share with clients"})]}),e.jsxs(Oe,{className:"p-6 pt-2 space-y-5",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-medium",children:"Your Card URL"}),e.jsxs("div",{className:"flex items-center gap-0 mt-1.5",children:[e.jsx("span",{className:"inline-flex items-center px-3 h-10 rounded-l-md border border-r-0 bg-muted text-sm text-muted-foreground whitespace-nowrap",children:"cards.relevelup.com/"}),e.jsx(Re,{value:s||o,onChange:u=>r(u.target.value),placeholder:"your-name",className:"rounded-l-none"})]})]}),e.jsxs(K,{onClick:l,disabled:n.isPending,className:"w-full h-11 text-base font-semibold",size:"lg",children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),n.isPending?"Creating...":"Create My Card"]})]})]})]})}function _xs({card:t}){const r=`https://cards.relevelup.com/${t.slug}`,n=()=>{navigator.clipboard.writeText(r),fe.success("Card link copied!")};return e.jsx("div",{className:"rounded-xl border bg-card p-5",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-xl font-bold",children:"My Digital Card"}),e.jsx(rt,{variant:t.is_published?"default":"secondary",className:"text-[10px] uppercase tracking-wider",children:t.is_published?"Live":"Draft"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Lm,{className:"h-3.5 w-3.5"}),"cards.relevelup.com/",t.slug]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[e.jsx(ai,{className:"h-3.5 w-3.5"})," Copy Link"]}),e.jsx(K,{size:"sm",asChild:!0,className:"gap-1.5",children:e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(sn,{className:"h-3.5 w-3.5"})," Preview"]})})]})]})})}function bxs({userId:t}){const s=rs(),r=C.useRef(null),[n,a]=C.useState(!1),[o,l]=C.useState(""),{data:i,isLoading:d}=wt({queryKey:["card-editor-profile",t],queryFn:async()=>{const{data:Y}=await G.from("profiles").select("name, email, phone, avatar_url").eq("id",t).single();let se=(Y==null?void 0:Y.avatar_url)||null;if(!se){const{data:te}=await G.storage.from("avatars").list(`${t}`);if(te&&te.length>0){const{data:Q}=G.storage.from("avatars").getPublicUrl(`${t}/${te[0].name}`);se=`${Q.publicUrl}?t=${Date.now()}`,await G.from("profiles").update({avatar_url:se}).eq("id",t)}}return{...Y,avatar_url:se}}}),[u,p]=C.useState(null),[f,y]=C.useState(null),[_,b]=C.useState(null),[w,j]=C.useState(!1),k=u??(i==null?void 0:i.name)??"",S=f??(i==null?void 0:i.phone)??"",T=_??(i==null?void 0:i.email)??"",I=i==null?void 0:i.avatar_url,L=((i==null?void 0:i.name)||"A").split(" ").map(Y=>Y[0]).join("").toUpperCase().slice(0,2),R=!(i!=null&&i.avatar_url)||!(i!=null&&i.phone),$=Dt({mutationFn:async Y=>{const{error:se}=await G.from("profiles").update(Y).eq("id",t);if(se)throw se},onSuccess:()=>{s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),fe.success("Profile updated!")},onError:()=>fe.error("Failed to update profile")}),q=()=>{const Y={};if(u!==null&&u!==(i==null?void 0:i.name)&&(Y.name=u),f!==null&&f!==(i==null?void 0:i.phone)&&(Y.phone=f||null),_!==null&&_!==(i==null?void 0:i.email)&&(Y.email=_),Object.keys(Y).length===0){fe.info("No changes to save");return}$.mutate(Y)},U=Y=>{var Q;const se=(Q=Y.target.files)==null?void 0:Q[0];if(!se)return;if(!se.type.startsWith("image/")){fe.error("Please select an image file");return}const te=new FileReader;te.onloadend=()=>{l(te.result),a(!0)},te.readAsDataURL(se),Y.target.value=""},H=async Y=>{j(!0);try{const{data:se}=await G.storage.from("avatars").list(`${t}`);se&&se.length>0&&await G.storage.from("avatars").remove(se.map(ae=>`${t}/${ae.name}`));const te=`${t}/avatar.jpg`,{error:Q}=await G.storage.from("avatars").upload(te,Y,{upsert:!0,contentType:"image/jpeg"});if(Q)throw Q;const{data:de}=G.storage.from("avatars").getPublicUrl(te),re=de.publicUrl+"?t="+Date.now();await G.from("profiles").update({avatar_url:re}).eq("id",t),s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),fe.success("Photo updated!")}catch{fe.error("Failed to upload photo")}finally{j(!1)}};return d?e.jsx(xs,{className:"h-32 w-full rounded-xl"}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:R?"border-amber-300 dark:border-amber-700":"",children:e.jsxs(Oe,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ve,{className:"text-sm font-semibold",children:"Profile Info"}),R&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400 font-medium",children:[e.jsx(ll,{className:"h-3 w-3"}),"Missing info — complete below so your card looks great"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-3",children:"This info shows on your digital card and updates your profile everywhere."}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative group cursor-pointer",onClick:()=>{var Y;return(Y=r.current)==null?void 0:Y.click()},children:[e.jsxs(xn,{className:"h-16 w-16 ring-2 ring-muted",children:[e.jsx(Aa,{src:I||void 0,alt:k}),e.jsx(yn,{className:"text-lg font-semibold bg-primary/10 text-primary",children:L})]}),e.jsx("div",{className:"absolute inset-0 bg-black/40 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(qg,{className:"h-5 w-5 text-white"})}),e.jsx("input",{ref:r,type:"file",accept:"image/*",className:"hidden",onChange:U})]}),e.jsxs("div",{className:"flex-1 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:w?"Uploading...":I?"Tap to change photo":"Add a profile photo"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This photo appears on your card, profile, and community posts"})]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Full Name"}),e.jsx(Re,{value:k,onChange:Y=>p(Y.target.value),placeholder:"Your full name",className:"h-10"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Phone Number"}),e.jsx(Re,{value:S,onChange:Y=>y(Y.target.value),placeholder:"(555) 123-4567",className:"h-10",type:"tel"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Email"}),e.jsx(Re,{value:T,onChange:Y=>b(Y.target.value),placeholder:"you@example.com",className:"h-10",type:"email"})]})]})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:q,disabled:$.isPending,className:"w-full",children:$.isPending?"Saving...":"Update Profile Info"})]})}),e.jsx(owe,{open:n,onClose:()=>a(!1),imageSrc:o,onCropComplete:H,aspectRatio:1})]})}function wxs({form:t,setForm:s,userId:r}){const[n,a]=C.useState(null),[o,l]=C.useState(t.brokerage_logo_url?"logo":"name"),[i,d]=C.useState(t.team_logo_url?"logo":"name"),u=_=>{l(_),s(_==="name"?b=>({...b,brokerage_logo_url:""}):b=>({...b,brokerage_display_name:""}))},p=_=>{d(_),s(_==="name"?b=>({...b,team_logo_url:""}):b=>({...b,team_name:""}))},f=async(_,b)=>{var j;const w=(j=_.target.files)==null?void 0:j[0];if(w){if(!w.type.startsWith("image/")){fe.error("Please select an image file");return}a(b);try{const k=w.name.split(".").pop()||"png",T=`${r}/${b==="brokerage_logo_url"?"brokerage-logo":"team-logo"}.${k}`,{error:I}=await G.storage.from("card-logos").upload(T,w,{upsert:!0});if(I)throw I;const{data:L}=G.storage.from("card-logos").getPublicUrl(T),R=L.publicUrl+"?t="+Date.now();s(b==="brokerage_logo_url"?$=>({...$,[b]:R,brokerage_display_name:""}):$=>({...$,[b]:R,team_name:""})),fe.success("Logo uploaded!")}catch{fe.error("Failed to upload logo")}finally{a(null),_.target.value=""}}},y=_=>{s(b=>({...b,[_]:""}))};return e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-semibold",children:"Brokerage & Team Branding"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Choose either a name or a logo for each — not both."})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(ve,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"button",variant:o==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>u("name"),children:"Use Name"}),e.jsx(K,{type:"button",variant:o==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>u("logo"),children:"Use Logo"})]}),o==="name"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Name"}),e.jsx(Re,{value:t.brokerage_display_name,onChange:_=>s(b=>({...b,brokerage_display_name:_.target.value})),placeholder:"e.g. Keller Williams Realty",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Logo"}),e.jsxs("div",{className:"flex items-center gap-3",children:[t.brokerage_logo_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:t.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${t.brokerage_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>y("brokerage_logo_url"),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}):null,e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(qg,{className:"h-3.5 w-3.5"}),n==="brokerage_logo_url"?"Uploading...":t.brokerage_logo_url?"Change":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:_=>f(_,"brokerage_logo_url"),disabled:n!==null})]})]}),t.brokerage_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.brokerage_logo_size||56,"px"]})]}),e.jsx(Fg,{value:[t.brokerage_logo_size||56],onValueChange:([_])=>s(b=>({...b,brokerage_logo_size:_})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(ve,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"button",variant:i==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>p("name"),children:"Use Name"}),e.jsx(K,{type:"button",variant:i==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>p("logo"),children:"Use Logo"})]}),i==="name"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Team Name"}),e.jsx(Re,{value:t.team_name,onChange:_=>s(b=>({...b,team_name:_.target.value})),placeholder:"e.g. The Smith Group",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Team Logo"}),e.jsxs("div",{className:"flex items-center gap-3",children:[t.team_logo_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:t.team_logo_url,alt:"Team logo",style:{height:`${t.team_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>y("team_logo_url"),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}):null,e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(qg,{className:"h-3.5 w-3.5"}),n==="team_logo_url"?"Uploading...":t.team_logo_url?"Change":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:_=>f(_,"team_logo_url"),disabled:n!==null})]})]}),t.team_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.team_logo_size||56,"px"]})]}),e.jsx(Fg,{value:[t.team_logo_size||56],onValueChange:([_])=>s(b=>({...b,team_logo_size:_})),min:24,max:120,step:4})]})]})]})]})})}function jxs({form:t,setForm:s}){const r={accent:"#ff5722",dark:"#1a1a2e",button:"#ff5722"},n=t.bold_theme_colors||r,a=(i,d)=>{s(u=>({...u,bold_theme_colors:{...r,...u.bold_theme_colors,[i]:d}}))},o=()=>{s(i=>({...i,bold_theme_colors:null}))},l=[{key:"accent",label:"Accent Color",desc:"Page background, icons, highlights"},{key:"dark",label:"Dark Color",desc:"Header background, action buttons, social icons"},{key:"button",label:"CTA Button Color",desc:"Main call-to-action button"}];return e.jsxs("div",{className:"space-y-3 p-4 rounded-xl border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(ve,{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(Bl,{className:"h-4 w-4"})," Brand Colors"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Customize colors to match your brand"})]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-xs h-7",onClick:o,children:"Reset to Default"})]}),e.jsx("div",{className:"grid gap-3",children:l.map(({key:i,label:d,desc:u})=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"relative shrink-0",children:[e.jsx("input",{type:"color",value:n[i],onChange:p=>a(i,p.target.value),className:"sr-only"}),e.jsx("div",{className:"h-10 w-10 rounded-lg border-2 border-border cursor-pointer shadow-sm hover:scale-105 transition-transform",style:{backgroundColor:n[i]}})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:d}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u})]}),e.jsx(Re,{value:n[i],onChange:p=>{const f=p.target.value;/^#[0-9a-fA-F]{0,6}$/.test(f)&&a(i,f)},className:"w-24 h-8 text-xs font-mono",placeholder:"#ff5722"})]},i))}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Preview:"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.accent}}),e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.dark}}),e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.button}})]})]})]})}function Nxs({card:t,form:s,setForm:r}){var w;const n=P9e(),a=rs(),{data:o}=I9e(t.id),[l,i]=C.useState(t.slug),[d,u]=C.useState(!1),[p,f]=C.useState("idle"),y=C.useRef(JSON.stringify(s)),_=C.useRef(null);C.useEffect(()=>{const j=JSON.stringify(s);if(j!==y.current)return _.current&&clearTimeout(_.current),_.current=setTimeout(()=>{f("saving"),n.mutate({id:t.id,...s,is_published:!0,title:s.title||null,positioning_statement:s.positioning_statement||null,bio:s.bio||null,review_snippet:s.review_snippet||null,review_source_url:s.review_source_url||null,booking_url:s.booking_url||null,custom_cta_label:s.custom_cta_label||null,brokerage_display_name:s.brokerage_display_name||null,brokerage_logo_url:s.brokerage_logo_url||null,brokerage_logo_size:s.brokerage_logo_size,team_name:s.team_name||null,team_logo_url:s.team_logo_url||null,team_logo_size:s.team_logo_size,bold_theme_colors:s.bold_theme_colors||null,display_email:s.display_email||null},{onSuccess:()=>{y.current=j,f("saved"),setTimeout(()=>f("idle"),2e3)},onError:()=>f("idle")})},1500),()=>{_.current&&clearTimeout(_.current)}},[s]);const b=async()=>{const j=l.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!j){fe.error("Please enter a valid URL");return}if(j===t.slug){fe.info("No changes to save");return}u(!0);try{const{data:k}=await G.from("agent_cards").select("id").eq("slug",j).neq("id",t.id).maybeSingle();if(k){fe.error("This URL is already taken. Try another one.");return}const{error:S}=await G.from("agent_cards").update({slug:j}).eq("id",t.id);if(S)throw S;i(j),a.invalidateQueries({queryKey:["agent-card"]}),fe.success("Card address updated!")}catch{fe.error("Failed to update card address")}finally{u(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ka,{defaultValue:"content",children:[e.jsxs(_a,{className:"w-full h-11 p-1",children:[e.jsxs(js,{value:"content",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(yf,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Content"]}),e.jsxs(js,{value:"sections",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(xa,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Sections"]}),e.jsxs(js,{value:"blocks",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Fm,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Blocks"]}),e.jsxs(js,{value:"qrcode",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(B0,{className:"h-3.5 w-3.5 hidden sm:inline"}),"QR Code"]}),e.jsxs(js,{value:"analytics",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(c_,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Analytics"]})]}),e.jsxs(zs,{value:"content",className:"mt-4 space-y-4",children:[e.jsx(bxs,{userId:t.user_id}),e.jsx(wxs,{form:s,setForm:r,userId:t.user_id}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-5 space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-sm font-semibold",children:"Card Status"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Toggle your card on or off"})]}),e.jsx(Br,{checked:s.is_published,onCheckedChange:j=>r(k=>({...k,is_published:j}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Card Address"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex flex-1",children:[e.jsx("span",{className:"inline-flex items-center px-3 rounded-l-md border border-r-0 bg-muted text-muted-foreground text-xs whitespace-nowrap",children:"cards.relevelup.com/"}),e.jsx(Re,{value:l,onChange:j=>i(j.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"your-name",className:"rounded-l-none h-10"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:b,disabled:d||l===t.slug,className:"shrink-0",children:d?"Saving...":"Update"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This is your unique card URL. Only letters, numbers, and dashes allowed."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Card Email (Override)"}),e.jsx(Re,{value:s.display_email,onChange:j=>r(k=>({...k,display_email:j.target.value})),placeholder:"you@yourbusiness.com",className:"h-11",type:"email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional — use a different email on your card instead of your sign-in email."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Theme"}),e.jsxs(sr,{value:s.theme,onValueChange:j=>r(k=>({...k,theme:j})),children:[e.jsx(er,{className:"h-11",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"standard",children:"✨ Standard — Modern & Clean"}),e.jsx(At,{value:"luxury",children:"🌙 Luxury — Dark & Gold"}),e.jsx(At,{value:"bold",children:"🔥 Bold — Vibrant & Punchy"}),e.jsx(At,{value:"classic",children:"📋 Classic — Professional"})]})]})]}),s.theme==="bold"&&e.jsx(jxs,{form:s,setForm:r}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Title / Tagline"}),e.jsx(Re,{value:s.title,onChange:j=>r(k=>({...k,title:j.target.value})),placeholder:"e.g. Luxury Real Estate Specialist",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown below your name on the card"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Positioning Statement"}),e.jsx(Re,{value:s.positioning_statement,onChange:j=>r(k=>({...k,positioning_statement:j.target.value})),placeholder:"Your home journey, handled with care.",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Bio"}),e.jsx(Ar,{value:s.bio,onChange:j=>r(k=>({...k,bio:j.target.value})),placeholder:"A short intro about you and what makes you different...",rows:3})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Review Snippet"}),e.jsx(Re,{value:s.review_snippet,onChange:j=>r(k=>({...k,review_snippet:j.target.value})),placeholder:"Best agent we've ever worked with...",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Review Source URL"}),e.jsx(Re,{value:s.review_source_url,onChange:j=>r(k=>({...k,review_source_url:j.target.value})),placeholder:"https://g.page/your-business/review",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Booking URL"}),e.jsx(Re,{value:s.booking_url,onChange:j=>r(k=>({...k,booking_url:j.target.value})),placeholder:"https://calendly.com/your-link",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave empty to show a built-in lead form instead"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Custom CTA Label"}),e.jsx(Re,{value:s.custom_cta_label,onChange:j=>r(k=>({...k,custom_cta_label:j.target.value})),placeholder:"Book a Call",className:"h-11"})]})]})})]}),e.jsx(zs,{value:"sections",className:"mt-4",children:e.jsx(Ee,{children:e.jsx(Oe,{className:"p-5 divide-y",children:[{key:"show_photo",label:"Photo",desc:"Uses the photo from your Profile Info above"},{key:"show_bio",label:"Bio Section",desc:"Display your bio on the card"},{key:"show_credentials",label:"Credentials",desc:"Show star rating and reviews"},{key:"show_social_links",label:"Social Links",desc:"Display your social media links"},{key:"show_save_contact",label:"Save Contact",desc:"Let visitors save you as a contact"},{key:"show_leave_review",label:"Leave Review",desc:"Link to your review page"},{key:"show_refer_friend",label:"Refer a Friend",desc:"Enable referral submissions"}].map(({key:j,label:k,desc:S})=>e.jsxs("div",{className:"flex items-center justify-between py-4 first:pt-0 last:pb-0",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:k}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S})]}),e.jsx(Br,{checked:s[j],onCheckedChange:T=>r(I=>({...I,[j]:T}))})]},j))})})}),e.jsx(zs,{value:"blocks",className:"mt-4",children:e.jsx(GJe,{cardId:t.id})}),e.jsx(zs,{value:"analytics",className:"mt-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-3",children:[{label:"Views",value:(o==null?void 0:o.views)??0,icon:xa,color:"text-blue-600 bg-blue-100 dark:text-blue-400 dark:bg-blue-900/30"},{label:"Clicks",value:(o==null?void 0:o.clicks)??0,icon:c_,color:"text-amber-600 bg-amber-100 dark:text-amber-400 dark:bg-amber-900/30"},{label:"Leads",value:((w=o==null?void 0:o.leads)==null?void 0:w.length)??0,icon:yc,color:"text-emerald-600 bg-emerald-100 dark:text-emerald-400 dark:bg-emerald-900/30"}].map(j=>e.jsx(Ee,{className:"overflow-hidden",children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:`p-1.5 rounded-md ${j.color}`,children:e.jsx(j.icon,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:j.label})]}),e.jsx("div",{className:"text-2xl font-bold",children:j.value})]})},j.label))}),o&&o.leads.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsx(Ot,{className:"text-base",children:"Recent Leads"})}),e.jsx(Oe,{className:"pt-0 space-y-2",children:o.leads.slice(0,5).map(j=>e.jsxs("div",{className:"flex items-center justify-between text-sm p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:j.name}),j.phone&&e.jsx("span",{className:"text-muted-foreground ml-2",children:j.phone})]}),j.intent&&e.jsx(rt,{variant:"secondary",className:"text-xs",children:j.intent})]},j.id))})]}),(!o||o.leads.length===0)&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center",children:[e.jsx(c_,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"font-medium text-muted-foreground",children:"No analytics data yet"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Share your card link to start tracking"})]})})]})}),e.jsx(zs,{value:"qrcode",className:"mt-4 space-y-4",children:e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6",children:e.jsx(gxs,{slug:t.slug})})})})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[p==="saving"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-400 animate-pulse"})," Saving..."]}),p==="saved"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500"})," All changes saved"]}),p==="idle"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-muted-foreground/30"})," Changes auto-save"]})]})]})}function kxs(){const t=rs(),[s,r]=C.useState(""),[n,a]=C.useState(!1),[o,l]=C.useState(!1),[i,d]=C.useState(null),[u,p]=C.useState(!1),[f,y]=C.useState(!1),[_,b]=C.useState(null),[w,j]=C.useState(null),[k,S]=C.useState(0),{data:T,isLoading:I}=wt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:te,error:Q}=await G.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(Q)throw Q;return te}}),L=Dt({mutationFn:async te=>{const{data:Q,error:de}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_token",api_token:te}});if(de)throw de;if(Q!=null&&Q.error)throw new Error(Q.error);return Q},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),r(""),fe.success("BoldTrail connected successfully!")},onError:te=>{fe.error(te.message||"Failed to connect BoldTrail")}}),R=Dt({mutationFn:async()=>{const{data:te,error:Q}=await G.functions.invoke("boldtrail-sync",{body:{action:"disconnect"}});if(Q)throw Q;return te},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),fe.success("BoldTrail disconnected")},onError:()=>fe.error("Failed to disconnect")}),$=Dt({mutationFn:async te=>{const{data:Q,error:de}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_direction",sync_direction:te}});if(de)throw de;if(Q!=null&&Q.error)throw new Error(Q.error);return Q},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),fe.success("Sync direction saved")},onError:te=>{fe.error(te.message||"Failed to save sync direction")}}),q=Dt({mutationFn:async()=>{const{data:te,error:Q}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(Q)throw Q;if(te!=null&&te.error)throw new Error(te.error);return te},onSuccess:te=>{b(null),d(te),a(!0)},onError:te=>{fe.error(te.message||"Failed to generate sync preview")}}),U=Dt({mutationFn:async()=>{j("Initializing sync..."),S(5);const{data:te,error:Q}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:se}});if(Q)throw Q;if(te!=null&&te.error)throw new Error(te.error);const de=te;let re=de.sync_log_id,ae=de.next_phase,le=de.next_offset;const he=de.push_total||0,be=de.pull_total||0,_e=he+be;let je=0,Ne=0;for(;ae!=="finalize";){ae==="push"?(j(`Pushing contacts to BoldTrail... (${je}/${he})`),S(_e>0?je/_e*100:0)):ae==="pull"&&(j(`Pulling contacts from BoldTrail... (${Ne}/${be})`),S(_e>0?(he+Ne)/_e*100:0));const{data:Me,error:Te}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:ae,offset:le,sync_log_id:re,sync_direction:se}});if(Te)throw Te;if(Me!=null&&Me.error)throw new Error(Me.error);const Fe=Me;je+=Fe.chunk_pushed||0,Ne+=Fe.chunk_pulled||0,Fe.progress&&j(Fe.progress),ae==="pull"&&be>0?S(Math.min(95,Ne/be*100)):ae==="push"&&he>0&&S(Math.min(95,je/he*100)),ae=Fe.next_phase,le=Fe.next_offset}j("Finalizing sync..."),S(95);const{data:Ge,error:we}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:re,sync_direction:se}});if(we)throw we;return S(100),Ge},onSuccess:te=>{j(null),S(0),a(!1),t.invalidateQueries({queryKey:["boldtrail-status"]}),t.invalidateQueries({queryKey:["contacts"]}),t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),fe.success(`Sync complete! Pushed ${te.contacts_pushed||0}, pulled ${te.contacts_pulled||0}, skipped ${te.contacts_skipped||0} duplicates.`)},onError:te=>{j(null),S(0),fe.error(te.message||"Sync failed")}}),H=T==null?void 0:T.connected,Y=(T==null?void 0:T.sync_direction)||"bidirectional",se=_??Y;return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-emerald-500/10 flex items-center justify-center",children:e.jsx(Hc,{className:"h-5 w-5 text-emerald-600"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["BoldTrail",H&&e.jsx(rt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}),e.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(bm,{className:"h-3.5 w-3.5"}),"Learn More"]})]}),e.jsx(pr,{children:"Sync contacts bidirectionally between Agent OS and your BoldTrail (kvCORE) CRM."})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(hi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Two-way contact sync with duplicate prevention"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(hi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Preview what will sync before executing"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(hi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Syncs name, email, phone, address, notes, and lead source"})]}),H?e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsx("div",{className:"rounded-lg border p-3 space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"BoldTrail Connected"}),(T==null?void 0:T.last_sync_at)&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sync: ",new Date(T.last_sync_at).toLocaleString(),T.last_sync_status&&e.jsx(rt,{variant:T.last_sync_status==="success"?"default":"secondary",className:"ml-2 text-[10px]",children:T.last_sync_status})]}),(T==null?void 0:T.boldtrail_contact_count)!=null&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[T.boldtrail_contact_count," contacts in BoldTrail"]}),(T==null?void 0:T.last_sync_message)&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:T.last_sync_message})]}),e.jsxs(nc,{children:[e.jsx(Rh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect BoldTrail?"}),e.jsx(Dl,{children:"This will remove your API token. Previously synced contacts will remain in both systems."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>R.mutate(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]})}),e.jsx("div",{className:"rounded-lg border p-3",children:e.jsx(Y0e,{value:Y,onChange:te=>$.mutate(te)})}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(K,{onClick:()=>q.mutate(),disabled:q.isPending||U.isPending,variant:"outline",className:"gap-2",children:[q.isPending?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(xa,{className:"h-4 w-4"}),"Preview Sync"]})})]}):e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{type:"password",placeholder:"Paste your BoldTrail API token",value:s,onChange:te=>r(te.target.value),className:"flex-1"}),e.jsxs(K,{onClick:()=>L.mutate(s),disabled:!s||s.length<10||L.isPending,children:[L.isPending?e.jsx(Po,{className:"h-4 w-4 animate-spin mr-2"}):null,"Connect"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Find your API token in BoldTrail → Lead Engine → Lead Dropbox → My API Tokens. Generate a ",e.jsx("strong",{children:"Contacts"})," scope token."]})]})]})})]}),e.jsx(_s,{open:n,onOpenChange:te=>{U.isPending||a(te)},children:e.jsxs(vs,{className:"sm:max-w-lg",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(Hc,{className:"h-5 w-5 text-emerald-600"}),"Sync Preview"]}),e.jsx(Kr,{children:"Review what will happen when you sync your contacts."})]}),i&&(()=>{const te=se==="pull_only"?0:i.to_push,Q=se==="push_only"?0:i.to_pull;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Y0e,{value:se,onChange:b,size:"sm"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-center ${se==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:te}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Vd,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${se==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:Q}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(sh,{className:"h-3 w-3"})," Pull to Agent OS"]})]}),e.jsxs("div",{className:"rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-muted-foreground",children:i.already_synced}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(hr,{className:"h-3 w-3"})," Already synced"]})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["Agent OS: ",i.agent_os_total," contacts · BoldTrail: ",i.boldtrail_total," contacts"]}),U.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(Ti,{value:k||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:w||"Sync in progress..."})]}),te>0&&e.jsxs(bf,{open:u,onOpenChange:p,children:[e.jsx(wf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Vd,{className:"h-3 w-3 text-emerald-600"}),te," contacts to push to BoldTrail"]}),e.jsx(Ho,{className:`h-3 w-3 transition-transform ${u?"rotate-180":""}`})]})}),e.jsx(jf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.push_preview.map((de,re)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:de.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:de.email})]},re)),i.to_push>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",i.to_push-20," more"]})]})})]}),Q>0&&e.jsxs(bf,{open:f,onOpenChange:y,children:[e.jsx(wf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(sh,{className:"h-3 w-3 text-blue-600"}),Q," contacts to pull from BoldTrail"]}),e.jsx(Ho,{className:`h-3 w-3 transition-transform ${f?"rotate-180":""}`})]})}),e.jsx(jf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.pull_preview.map((de,re)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:de.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:de.email})]},re)),i.to_pull>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",i.to_pull-20," more"]})]})})]}),te===0&&Q===0&&e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"✅ Everything is already in sync! No contacts to transfer."}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),disabled:U.isPending,children:"Cancel"}),e.jsxs(K,{onClick:()=>U.mutate(),disabled:U.isPending||te===0&&Q===0,className:"gap-2",children:[U.isPending?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Hc,{className:"h-4 w-4"}),U.isPending?"Syncing...":"Sync Now"]})]})]})})()]})}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{className:"sm:max-w-2xl p-0 overflow-hidden",children:[e.jsx(Ss,{className:"p-6 pb-0",children:e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(Hc,{className:"h-5 w-5 text-emerald-600"}),"How BoldTrail Sync Works"]})}),e.jsx("div",{className:"px-6 pb-6",children:e.jsx("video",{src:"/videos/BoldTrailIntegration.mp4",controls:!0,autoPlay:!0,className:"w-full rounded-lg",controlsList:"nodownload"})})]})})]})}function aet(){const t=Pr(),[s,r]=C.useState(""),[n,a]=C.useState(""),[o,l]=C.useState("Test from ReLevelUp"),[i,d]=C.useState(!1),{data:u,isLoading:p}=wt({queryKey:["ses-config"],queryFn:async()=>{const{data:{session:_}}=await G.auth.getSession();if(!_)throw new Error("Not authenticated");return(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ses-send-campaign",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${_.access_token}`},body:JSON.stringify({action:"check_config"})})).json()}}),f=async()=>{if(!s||!n){fe.error("Please fill in From and To email addresses");return}d(!0);try{const{data:{session:_}}=await G.auth.getSession();if(!_)throw new Error("Not authenticated");const w=await(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ses-send-campaign",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${_.access_token}`},body:JSON.stringify({action:"test_send",to:s,from_email:n,subject:o,body_html:"

Test Email

This is a test email sent via Amazon SES from the ReLevelUp platform.

If you received this, SES is configured correctly! 🎉

"})})).json();w.success?fe.success(`Test email sent! Message ID: ${w.messageId}`):fe.error(w.error||"Failed to send test email")}catch(_){fe.error(_.message||"Failed to send test email")}finally{d(!1)}},y=(u==null?void 0:u.configured)===!0;return e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-orange-500/10 flex items-center justify-center",children:e.jsx(br,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Amazon SES — Mass Email"}),e.jsx(pr,{children:"Send bulk email campaigns via Amazon SES"})]})]}),e.jsx(rt,{variant:y?"default":"secondary",children:p?"Checking...":y?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hi,{className:"h-3 w-3"})," Connected"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ll,{className:"h-3 w-3"})," Not Configured"]})})]})}),y&&e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Send Test Email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'Verify your SES setup by sending a test email. The "From" address must be verified in SES or belong to a verified domain.'}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs",children:"From Email"}),e.jsx(Re,{placeholder:"notifications@mail.relevelup.com",value:n,onChange:_=>a(_.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs",children:"To Email"}),e.jsx(Re,{placeholder:"your@email.com",value:s,onChange:_=>r(_.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs",children:"Subject"}),e.jsx(Re,{value:o,onChange:_=>l(_.target.value),className:"text-sm"})]})]}),e.jsxs(K,{onClick:f,disabled:i,size:"sm",children:[i?e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(aa,{className:"h-4 w-4 mr-2"}),"Send Test"]})]}),e.jsxs(K,{onClick:()=>t("/admin/email-campaigns"),className:"w-full",children:[e.jsx(Rm,{className:"h-4 w-4 mr-2"})," Launch Campaign Composer"]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Region:"})," ",u==null?void 0:u.region]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Domain:"})," send.relevelup.com (verified)"]})]})]}),!y&&!p&&e.jsx(Oe,{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["AWS SES credentials are not configured. Add ",e.jsx("code",{children:"AWS_SES_ACCESS_KEY_ID"}),", ",e.jsx("code",{children:"AWS_SES_SECRET_ACCESS_KEY"}),", and ",e.jsx("code",{children:"AWS_SES_REGION"})," as secrets to enable."]})})]})}function Sxs(){var b,w,j,k;const{user:t}=Hs(),s=rs(),[r,n]=C.useState(!1),[a,o]=C.useState(""),[l,i]=C.useState(""),{data:d}=wt({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:S,error:T}=await G.from("mass_email_settings").select("*").eq("user_id",t.id).maybeSingle();if(T)throw T;return S}}),{data:u}=wt({queryKey:["agent-profile-email",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:S,error:T}=await G.from("profiles").select("email, name").eq("id",t.id).single();if(T)throw T;return S}}),p=((b=d==null?void 0:d.reply_to_email)==null?void 0:b.trim())||((w=u==null?void 0:u.email)==null?void 0:w.trim())||"",f=((j=d==null?void 0:d.display_name)==null?void 0:j.trim())||((k=u==null?void 0:u.name)==null?void 0:k.trim())||"";C.useEffect(()=>{r||(o(p),i(f))},[r,p,f]);const y=Dt({mutationFn:async()=>{if(!t||!a.trim())throw new Error("Please enter a reply-to email");const S={reply_to_email:a.trim(),display_name:l.trim()||null,updated_at:new Date().toISOString()};if(d){const{error:T}=await G.from("mass_email_settings").update(S).eq("user_id",t.id);if(T)throw T}else{const{error:T}=await G.from("mass_email_settings").insert({user_id:t.id,...S});if(T)throw T}},onSuccess:()=>{s.invalidateQueries({queryKey:["mass-email-settings",t==null?void 0:t.id]}),s.invalidateQueries({queryKey:["mass-email-ready",t==null?void 0:t.id]}),s.invalidateQueries({queryKey:["mass-email-settings-check",t==null?void 0:t.id]}),fe.success("Reply-to email saved!"),n(!1)},onError:S=>fe.error(S.message)}),_=!!p;return e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-orange-500/10 flex items-center justify-center",children:e.jsx(aa,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["Mass Email",_?e.jsxs(rt,{variant:"default",className:"text-xs bg-green-600",children:[e.jsx(hi,{className:"h-3 w-3 mr-1"})," Set Up"]}):e.jsx(rt,{variant:"secondary",className:"text-xs",children:"Setup Required"})]}),e.jsx(pr,{children:"Set the email address where replies from your campaigns will be sent. If you haven't customized it yet, we'll use your profile email."})]})]})}),e.jsx(Oe,{className:"space-y-3",children:_&&!r?e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:f||"No display name"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p})]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>n(!0),children:[e.jsx(Da,{className:"h-3 w-3 mr-1"})," Edit"]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs",children:"Display Name"}),e.jsx(Re,{placeholder:"e.g. 🏡 Karen Hall",value:l,onChange:S=>i(S.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"How your name appears in the recipient's inbox"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs",children:"Reply-To Email *"}),e.jsx(Re,{type:"email",placeholder:"your@email.com",value:a,onChange:S=>o(S.target.value)})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{size:"sm",onClick:()=>y.mutate(),disabled:y.isPending||!a.trim(),children:[e.jsx(fu,{className:"h-4 w-4 mr-1"})," Save"]}),r&&e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{n(!1),o(p),i(f)},children:[e.jsx(Ur,{className:"h-4 w-4 mr-1"})," Cancel"]})]})]})})]})}function Cxs(){const{isAdmin:t}=Hs(),s=rs(),[r,n]=C.useState(!1),[a,o]=C.useState(!1),[l,i]=C.useState(!1),{data:d,isLoading:u}=wt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:I,error:L}=await G.from("gmail_integrations").select("*").maybeSingle();if(L)throw L;return I}}),{data:p}=wt({queryKey:["social-accounts"],queryFn:async()=>{const{data:{user:I}}=await G.auth.getUser();if(!I)return[];const{data:L,error:R}=await G.from("social_accounts").select("*").eq("user_id",I.id).order("created_at",{ascending:!1});if(R)throw R;return L}}),f=async()=>{n(!0);try{const{data:I,error:L}=await G.functions.invoke("gmail-oauth",{body:{action:"get_auth_url"}});if(L)throw L;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get authorization URL")}catch(I){console.error("Gmail OAuth error:",I),fe.error("Failed to start Gmail connection"),n(!1)}},y=async()=>{o(!0);try{const{data:I,error:L}=await G.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(L)throw L;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get authorization URL")}catch(I){console.error("Meta OAuth error:",I),fe.error("Failed to start connection. Make sure Meta App credentials are configured."),o(!1)}},_=async()=>{i(!0);try{const{data:I,error:L}=await G.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(L)throw L;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(I){console.error("LinkedIn OAuth error:",I),fe.error("Failed to start LinkedIn connection. Please try again."),i(!1)}},b=Dt({mutationFn:async I=>{const{error:L}=await G.from("gmail_integrations").delete().eq("id",I);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["gmail-integration"]}),fe.success("Gmail disconnected")},onError:()=>{fe.error("Failed to disconnect Gmail")}}),w=Dt({mutationFn:async I=>{const{error:L}=await G.from("social_accounts").delete().eq("id",I);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["social-accounts"]}),fe.success("Account disconnected")},onError:()=>{fe.error("Failed to disconnect account")}}),j=!!(d!=null&&d.is_active),k=(p==null?void 0:p.filter(I=>I.platform==="facebook"))||[],S=(p==null?void 0:p.filter(I=>I.platform==="instagram"))||[],T=(p==null?void 0:p.filter(I=>I.platform==="linkedin"))||[];return e.jsx(Ts,{children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6 animate-fade-in",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Integrations"}),e.jsx("p",{className:"text-muted-foreground",children:"Connect third-party services to supercharge your Agent OS workflow."})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-destructive/10 flex items-center justify-center",children:e.jsx(br,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["Gmail",j&&e.jsx(rt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"})]}),e.jsx(pr,{children:"Send emails directly from your contact pages and auto-log them as touchpoints."})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(hi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Send personalized emails from your Gmail account"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(hi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Automatically log emails as activity touchpoints"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(hi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Quick compose from any contact detail page"})]}),j?e.jsxs("div",{className:"flex items-center justify-between mt-4 p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:d.gmail_email}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Gmail account"})]}),e.jsxs(nc,{children:[e.jsx(Rh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect Gmail?"}),e.jsx(Dl,{children:"This will remove your Gmail connection. You'll need to reconnect to send emails."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>b.mutate(d.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}):e.jsxs(K,{className:"mt-4",onClick:f,disabled:r||u,children:[r?e.jsx(Po,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(br,{className:"h-4 w-4 mr-2"}),"Connect Gmail",e.jsx($i,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(Hd,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["Facebook",t?k.length>0?e.jsx(rt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(rt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx($u,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(pr,{children:"Connect Facebook Pages to post content and reach your audience."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[k.length>0&&e.jsx("div",{className:"space-y-2",children:k.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(xn,{className:"h-8 w-8",children:[e.jsx(Aa,{src:I.profile_picture_url||""}),e.jsx(yn,{children:e.jsx(Hd,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.page_name||I.platform_username||"Facebook Page"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Facebook Page"})]})]}),e.jsxs(nc,{children:[e.jsx(Rh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect Facebook?"}),e.jsx(Dl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>w.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(K,{onClick:y,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),"Connect Facebook Page"]})]})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-pink-500/10 flex items-center justify-center",children:e.jsx(Wd,{className:"h-5 w-5 text-pink-600"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["Instagram",t?S.length>0?e.jsx(rt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(rt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx($u,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(pr,{children:"Connect Instagram Business accounts to schedule and publish posts."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[S.length>0&&e.jsx("div",{className:"space-y-2",children:S.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(xn,{className:"h-8 w-8",children:[e.jsx(Aa,{src:I.profile_picture_url||""}),e.jsx(yn,{children:e.jsx(Wd,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:["@",I.platform_username||"Instagram Account"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Instagram account"})]})]}),e.jsxs(nc,{children:[e.jsx(Rh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect Instagram?"}),e.jsx(Dl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>w.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(K,{onClick:y,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),"Connect Instagram Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Instagram Business accounts must be connected to a Facebook Page."})]})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-700/10 flex items-center justify-center",children:e.jsx(Om,{className:"h-5 w-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["LinkedIn",t?T.length>0?e.jsx(rt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(rt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx($u,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(pr,{children:"Connect your LinkedIn profile to share content and grow your professional network."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[T.length>0&&e.jsx("div",{className:"space-y-2",children:T.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(xn,{className:"h-8 w-8",children:[e.jsx(Aa,{src:I.profile_picture_url||""}),e.jsx(yn,{children:e.jsx(Om,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.platform_username||"LinkedIn Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected LinkedIn profile"})]})]}),e.jsxs(nc,{children:[e.jsx(Rh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect LinkedIn?"}),e.jsx(Dl,{children:"This will remove your LinkedIn connection. You'll need to reconnect to post content."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>w.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(K,{onClick:_,disabled:l,variant:"outline",className:"gap-2",children:[l?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),"Connect LinkedIn"]})]})]}),e.jsx(kxs,{}),e.jsx(Sxs,{}),t&&e.jsx(aet,{})]})})}function Mxs(){const[t]=Pc(),s=Pr(),[r,n]=C.useState("loading"),[a,o]=C.useState("Connecting your Gmail account...");return C.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),fe.error("Connection failed: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),fe.error("No authorization code received");return}try{const{data:f,error:y}=await G.functions.invoke("gmail-oauth",{body:{action:"exchange_code",code:i,state:p}});if(y)throw y;if(f!=null&&f.success)n("success"),o(f.message||"Gmail connected successfully!"),fe.success("Gmail connected!");else throw new Error((f==null?void 0:f.error)||"Unknown error")}catch(f){console.error("Gmail OAuth callback error:",f),n("error"),o(f instanceof Error?f.message:"Failed to connect Gmail"),fe.error("Failed to connect: "+(f instanceof Error?f.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(It,{className:"text-center",children:[r==="loading"&&e.jsx(Ms,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(hi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(kc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ot,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(pr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"Back to Integrations":"Try Again"})})]})})}function Txs(){const t=Pr();return C.useEffect(()=>{const s=setTimeout(()=>{t("/mission-control/integrations",{replace:!0})},1500);return()=>clearTimeout(s)},[t]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Finishing Canva connection…"})]})})}function Axs(){const[t]=Pc(),s=Pr(),[r,n]=C.useState("loading"),[a,o]=C.useState("Processing your connection...");return C.useEffect(()=>{(async()=>{var f;const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),fe.error("Connection failed: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),fe.error("No authorization code received");return}try{const{data:y,error:_}=await G.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/mission-control/integrations/meta/callback"}});if(_)throw _;if(y!=null&&y.success)n("success"),o(`Successfully connected ${((f=y.accounts)==null?void 0:f.length)||0} account(s)!`),fe.success("Social accounts connected successfully!");else throw new Error((y==null?void 0:y.error)||"Unknown error")}catch(y){console.error("OAuth callback error:",y),n("error"),o(y instanceof Error?y.message:"Failed to connect accounts"),fe.error("Failed to connect: "+(y instanceof Error?y.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(It,{className:"text-center",children:[r==="loading"&&e.jsx(Ms,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(hi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(kc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ot,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(pr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Integrations":"Try Again"})})]})})}const iet=new Date().getFullYear(),Exs=Array.from({length:5},(t,s)=>iet-s);function Pxs(){const[t,s]=C.useState(iet),r=Pr(),{data:n,isLoading:a}=p3t();return a?e.jsx(Ts,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(o=>e.jsx(xs,{className:"h-24"},o))}),e.jsx(xs,{className:"h-96"})]})}):e.jsx(Ts,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Scorecard Admin"}),e.jsx("p",{className:"text-muted-foreground",children:"View agent performance and scorecards"})]}),e.jsxs(sr,{value:String(t),onValueChange:o=>s(Number(o)),children:[e.jsx(er,{className:"w-[120px]",children:e.jsx(rr,{})}),e.jsx(tr,{children:Exs.map(o=>e.jsx(At,{value:String(o),children:o},o))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Agents Tracking"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(n==null?void 0:n.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ol,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Agents"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(n==null?void 0:n.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with transactions"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Agents with Scorecards"}),e.jsx(pr,{children:"Click to view individual agent scorecards"})]}),e.jsx(Oe,{children:!n||n.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ol,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents have added transactions yet"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Agent"}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:n.map(o=>e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium",children:o.name}),e.jsx(lt,{className:"text-muted-foreground",children:o.email}),e.jsx(lt,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r(`/admin/scorecard/${o.id}`),children:[e.jsx(xa,{className:"h-4 w-4 mr-2"}),"View Scorecard"]})})]},o.id))})]})})]})]})})}const oet=new Date().getFullYear(),Ixs=Array.from({length:10},(t,s)=>oet-s);function XLe(){var b;const{userId:t}=ko(),s=Pr(),n=bu().pathname.startsWith("/mission-control"),[a,o]=C.useState(oet),{data:l,isLoading:i}=wt({queryKey:["agent-profile",t],queryFn:async()=>{const{data:w,error:j}=await G.from("profiles").select("id, name, email").eq("id",t).single();if(j)throw j;return w},enabled:!!t}),{data:d,isLoading:u}=ybe(a,t),{yearStats:p,lifetimeStats:f,showCommission:y}=FVe(a,t),{data:_}=RVe(a,t);return i?e.jsx(Ts,{title:"Agent Scorecard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(w=>e.jsx(xs,{className:"h-24"},w))})]})}):e.jsx(Ts,{title:`${l==null?void 0:l.name}'s Scorecard`,children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s(n?"/mission-control/scorecard":"/admin/scorecard"),children:e.jsx(ti,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:l==null?void 0:l.name}),e.jsx("p",{className:"text-muted-foreground",children:l==null?void 0:l.email})]})]}),e.jsxs(sr,{value:String(a),onValueChange:w=>o(Number(w)),children:[e.jsx(er,{className:"w-[120px]",children:e.jsx(rr,{})}),e.jsx(tr,{children:Ixs.map(w=>e.jsx(At,{value:String(w),children:w},w))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(On,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:p.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[f.totalTransactions," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[p.buyerCount,"/",p.sellerCount]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(od,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Tl(p.totalVolume,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ac,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg Price"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Tl(p.averagePrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(rc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((b=p.topLeadSource)==null?void 0:b.name)||"-"})]})})]}),_&&e.jsx(CJe,{goals:_,stats:p,year:a,showCommission:y}),e.jsxs(ka,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(_a,{children:[e.jsx(js,{value:"transactions",children:"Transactions"}),e.jsx(js,{value:"charts",children:"Charts"}),e.jsxs(js,{value:"map",children:[e.jsx(Oi,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(zs,{value:"transactions",children:e.jsx(V2e,{transactions:d||[],showCommission:y,isLoading:u})}),e.jsx(zs,{value:"charts",children:e.jsx(H2e,{stats:p,year:a})}),e.jsx(zs,{value:"map",children:e.jsx(W2e,{transactions:d||[],isLoading:u})})]})]})})}function Lxs(){const t=rs(),[s,r]=C.useState(""),[n,a]=C.useState("all");hUe();const{data:o,refetch:l}=wt({queryKey:["listing-exchange-flag"],queryFn:async()=>{const{data:I}=await G.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").single();return(I==null?void 0:I.enabled)??!1}}),{data:i,isLoading:d}=wt({queryKey:["admin-listings"],queryFn:async()=>{const{data:I,error:L}=await G.from("listings").select(` *, agent:profiles!listings_agent_id_fkey(id, name, email), photos:listing_photos(id, photo_url, is_primary) `).order("created_at",{ascending:!1});if(L)throw L;return I}}),{data:u}=wt({queryKey:["admin-listing-stats"],queryFn:async()=>{const{data:I}=await G.from("listings").select("id, is_approved, status"),{data:L}=await G.from("listing_shares").select("id"),{data:R}=await G.from("listing_views").select("id");return{total:(I==null?void 0:I.length)||0,pending:(I==null?void 0:I.filter($=>!$.is_approved).length)||0,active:(I==null?void 0:I.filter($=>$.status==="active").length)||0,totalShares:(L==null?void 0:L.length)||0,totalViews:(R==null?void 0:R.length)||0}}}),p=async(I,L,R="submit_url")=>{try{const{data:{session:$}}=await G.auth.getSession();if(!$)return;const{data:q,error:U}=await G.functions.invoke("google-indexing",{body:{action:R,listing_id:I,listing_slug:L}});if(U)throw U;if((q==null?void 0:q.configured)===!1)return;q!=null&&q.success&&fe.success("Submitted to Google for indexing")}catch($){console.error("Google indexing submission failed:",$)}},f=Dt({mutationFn:async()=>{const{data:{session:I}}=await G.auth.getSession();if(!I)throw new Error("Not authenticated");const{data:L,error:R}=await G.functions.invoke("google-indexing",{body:{action:"submit_all"}});if(R)throw R;return L},onSuccess:I=>{if((I==null?void 0:I.configured)===!1){fe.error("Google Indexing API not configured. Add the GOOGLE_INDEXING_SERVICE_ACCOUNT secret.");return}fe.success(`Submitted ${(I==null?void 0:I.succeeded)||0} URLs to Google (${(I==null?void 0:I.failed)||0} failed)`)},onError:I=>{fe.error("Failed to submit to Google"),console.error(I)}}),y=Dt({mutationFn:async({id:I,approved:L,slug:R})=>{const{error:$}=await G.from("listings").update({is_approved:L}).eq("id",I);if($)throw $;return{id:I,approved:L,slug:R}},onSuccess:I=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),fe.success(I.approved?"Listing approved":"Listing unapproved"),I.approved?p(I.id,I.slug||null,"submit_url"):p(I.id,I.slug||null,"remove_url")}}),_=Dt({mutationFn:async({id:I,featured:L})=>{const{error:R}=await G.from("listings").update({is_featured:L}).eq("id",I);if(R)throw R},onSuccess:(I,{featured:L})=>{t.invalidateQueries({queryKey:["admin-listings"]}),fe.success(L?"Listing featured":"Listing unfeatured")}}),b=Dt({mutationFn:async I=>{const{error:L}=await G.from("listings").delete().eq("id",I);if(L)throw L},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),fe.success("Listing deleted")}}),w=Dt({mutationFn:async I=>{const{error:L}=await G.from("feature_flags").update({enabled:I}).eq("key","listing_exchange_enabled");if(L)throw L},onSuccess:()=>{l(),fe.success("Feature flag updated")}}),j=o??!1,k=i==null?void 0:i.filter(I=>{var $,q,U,H;const L=(($=I.city)==null?void 0:$.toLowerCase().includes(s.toLowerCase()))||((U=(q=I.agent)==null?void 0:q.name)==null?void 0:U.toLowerCase().includes(s.toLowerCase()))||((H=I.property_address)==null?void 0:H.toLowerCase().includes(s.toLowerCase())),R=n==="all"||n==="pending"&&!I.is_approved||n==="approved"&&I.is_approved;return L&&R}),S=I=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I),T=I=>{const L={active:"bg-green-500/10 text-green-600 border-green-200",coming_soon:"bg-blue-500/10 text-blue-600 border-blue-200",price_improvement:"bg-amber-500/10 text-amber-600 border-amber-200",under_contract:"bg-purple-500/10 text-purple-600 border-purple-200",sold:"bg-gray-500/10 text-gray-600 border-gray-200"};return L[I]||L.active};return e.jsx(Ts,{title:"Listing Exchange Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Listing Exchange"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage community listings"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>f.mutate(),disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):e.jsx(Lm,{className:"h-4 w-4"}),"Submit All to Google"]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Feature visible to agents"}),e.jsx(Br,{checked:j,onCheckedChange:I=>w.mutate(I)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Listings"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.total)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ac,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Active"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.active)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Pending Review"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.pending)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xa,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Views"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.totalViews)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ld,{className:"h-4 w-4 text-purple-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Shares"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.totalShares)||0})]})})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by city, address, or agent...",value:s,onChange:I=>r(I.target.value),className:"pl-9"})]}),e.jsx(ka,{value:n,onValueChange:I=>a(I),children:e.jsxs(_a,{children:[e.jsx(js,{value:"all",children:"All"}),e.jsx(js,{value:"pending",children:"Pending"}),e.jsx(js,{value:"approved",children:"Approved"})]})})]})})}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{children:["Listings (",(k==null?void 0:k.length)||0,")"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Property"}),e.jsx(bt,{children:"Agent"}),e.jsx(bt,{children:"Price"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-center",children:"Approved"}),e.jsx(bt,{className:"text-center",children:"Featured"}),e.jsx(bt,{children:"Views"}),e.jsx(bt,{children:"Shares"}),e.jsx(bt,{children:"Date"}),e.jsx(bt,{})]})}),e.jsx(Pn,{children:d?e.jsx(Ns,{children:e.jsx(lt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):(k==null?void 0:k.length)===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No listings found"})}):k==null?void 0:k.map(I=>{var L,R,$,q,U;return e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[(R=(L=I.photos)==null?void 0:L[0])!=null&&R.photo_url?e.jsx("img",{src:I.photos[0].photo_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(Ta,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.property_address||`${I.city}, ${I.state}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:($=I.property_type)==null?void 0:$.replace("_"," ")})]})]})}),e.jsx(lt,{children:e.jsx("p",{className:"text-sm",children:((q=I.agent)==null?void 0:q.name)||"Unknown"})}),e.jsx(lt,{className:"font-medium",children:S(I.price)}),e.jsx(lt,{children:e.jsx(rt,{variant:"outline",className:T(I.status),children:(U=I.status)==null?void 0:U.replace("_"," ")})}),e.jsx(lt,{className:"text-center",children:e.jsx(Br,{checked:I.is_approved??!1,onCheckedChange:H=>y.mutate({id:I.id,approved:H,slug:I.slug})})}),e.jsx(lt,{className:"text-center",children:e.jsx(Br,{checked:I.is_featured??!1,onCheckedChange:H=>_.mutate({id:I.id,featured:H})})}),e.jsx(lt,{children:I.view_count||0}),e.jsx(lt,{children:I.share_count||0}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:ys(new Date(I.created_at),"MMM d, yyyy")}),e.jsx(lt,{children:e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(of,{className:"h-4 w-4"})})}),e.jsxs(Md,{align:"end",children:[e.jsxs(Na,{onClick:()=>window.open(`/mission-control/listings/${I.id}`,"_blank"),children:[e.jsx(xa,{className:"h-4 w-4 mr-2"}),"View Listing"]}),e.jsxs(Na,{onClick:()=>_.mutate({id:I.id,featured:!I.is_featured}),children:[e.jsx(Gn,{className:"h-4 w-4 mr-2"}),I.is_featured?"Unfeature":"Feature"]}),e.jsxs(Na,{className:"text-destructive",onClick:()=>{confirm("Are you sure you want to delete this listing?")&&b.mutate(I.id)},children:[e.jsx(Ur,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},I.id)})})]})})})]})]})})}const Dxs=()=>{var f,y;const[t,s]=C.useState(""),[r,n]=C.useState(null),{data:a,isLoading:o}=wt({queryKey:["membership-reviews"],queryFn:async()=>{const{data:_,error:b}=await G.from("membership_reviews").select("*").order("created_at",{ascending:!1});if(b)throw b;const w=(_==null?void 0:_.map(S=>S.user_id))||[],{data:j}=await G.from("profiles").select("id, name, email").in("id",w);return _==null?void 0:_.map(S=>({...S,profiles:(j==null?void 0:j.find(T=>T.id===S.user_id))||null}))}}),l=a==null?void 0:a.filter(_=>{var w,j,k,S,T;const b=t.toLowerCase();return((j=(w=_.profiles)==null?void 0:w.name)==null?void 0:j.toLowerCase().includes(b))||((S=(k=_.profiles)==null?void 0:k.email)==null?void 0:S.toLowerCase().includes(b))||((T=_.review_text)==null?void 0:T.toLowerCase().includes(b))}),i=a!=null&&a.length?(a.reduce((_,b)=>_+b.rating,0)/a.length).toFixed(1):"0.0",d=a==null?void 0:a.reduce((_,b)=>(_[b.rating]=(_[b.rating]||0)+1,_),{}),u=(a==null?void 0:a.filter(_=>_.posted_to_google).length)||0,p=_=>e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(b=>e.jsx(Gn,{className:Pt("h-4 w-4",_>=b?"fill-yellow-400 text-yellow-400":"text-muted-foreground")},b))});return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(wu,{title:"Membership Reviews",description:"View and manage feedback from LevelUp members"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(Ee,{children:e.jsxs(It,{className:"pb-2",children:[e.jsx(pr,{children:"Total Reviews"}),e.jsx(Ot,{className:"text-3xl",children:(a==null?void 0:a.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(It,{className:"pb-2",children:[e.jsx(pr,{children:"Average Rating"}),e.jsxs(Ot,{className:"flex items-center gap-2 text-3xl",children:[i,e.jsx(Gn,{className:"h-6 w-6 fill-yellow-400 text-yellow-400"})]})]})}),e.jsx(Ee,{children:e.jsxs(It,{className:"pb-2",children:[e.jsx(pr,{children:"5-Star Reviews"}),e.jsx(Ot,{className:"text-3xl",children:(d==null?void 0:d[5])||0})]})}),e.jsx(Ee,{children:e.jsxs(It,{className:"pb-2",children:[e.jsx(pr,{children:"Posted to Google"}),e.jsxs(Ot,{className:"flex items-center gap-2 text-3xl",children:[u,e.jsx(sn,{className:"h-5 w-5 text-muted-foreground"})]})]})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name, email, or review...",value:t,onChange:_=>s(_.target.value),className:"pl-9"})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Member"}),e.jsx(bt,{children:"Rating"}),e.jsx(bt,{className:"hidden md:table-cell",children:"Review"}),e.jsx(bt,{children:"Google"}),e.jsx(bt,{children:"Date"})]})}),e.jsx(Pn,{children:o?e.jsx(Ns,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8",children:"Loading reviews..."})}):(l==null?void 0:l.length)===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No reviews found"})}):l==null?void 0:l.map(_=>{var b,w;return e.jsxs(Ns,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>n(_),children:[e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:((b=_.profiles)==null?void 0:b.name)||"Unknown"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:(w=_.profiles)==null?void 0:w.email})]})}),e.jsx(lt,{children:p(_.rating)}),e.jsx(lt,{className:"hidden md:table-cell max-w-xs",children:e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:_.review_text||"-"})}),e.jsx(lt,{children:_.posted_to_google?e.jsx(rt,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Posted"}):e.jsx(rt,{variant:"outline",children:"No"})}),e.jsx(lt,{className:"text-sm text-muted-foreground",children:ys(new Date(_.created_at),"MMM d, yyyy")})]},_.id)})})]})})}),e.jsx(_s,{open:!!r,onOpenChange:()=>n(null),children:e.jsxs(vs,{className:"max-w-lg",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Review Details"})}),r&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-4 p-4 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:((f=r.profiles)==null?void 0:f.name)||"Unknown Member"}),((y=r.profiles)==null?void 0:y.email)&&e.jsxs("a",{href:`mailto:${r.profiles.email}`,className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-primary",children:[e.jsx(br,{className:"h-3 w-3"}),r.profiles.email]})]}),e.jsxs("div",{className:"text-right",children:[p(r.rating),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[r.rating," out of 5 stars"]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Review"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:r.review_text||"No written review provided."})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(on,{className:"h-4 w-4"}),ys(new Date(r.created_at),"MMMM d, yyyy 'at' h:mm a")]}),r.posted_to_google?e.jsxs(rt,{variant:"secondary",className:"bg-green-100 text-green-800",children:[e.jsx(sn,{className:"h-3 w-3 mr-1"}),"Posted to Google"]}):e.jsx(rt,{variant:"outline",children:"Not posted to Google"})]})]})]})})]})})},Oxs=[{value:"0",label:"Sunday"},{value:"1",label:"Monday"},{value:"2",label:"Tuesday"},{value:"3",label:"Wednesday"},{value:"4",label:"Thursday"},{value:"5",label:"Friday"},{value:"6",label:"Saturday"}],Rxs=Array.from({length:24},(t,s)=>({value:String(s),label:s===0?"12:00 AM":s<12?`${s}:00 AM`:s===12?"12:00 PM":`${s-12}:00 PM`}));function Fxs(){const t=rs(),{user:s}=Hs(),[r,n]=C.useState(!1),[a,o]=C.useState(!1),[l,i]=C.useState(!1),{data:d,isLoading:u}=wt({queryKey:["weekly-digest-settings"],queryFn:async()=>{const{data:q,error:U}=await G.from("weekly_digest_settings").select("*").single();if(U)throw U;return q}}),{data:p,isLoading:f}=wt({queryKey:["weekly-digest-logs"],queryFn:async()=>{const{data:q,error:U}=await G.from("weekly_digest_logs").select("*").order("sent_at",{ascending:!1}).limit(100);if(U)throw U;return q}}),{data:y}=wt({queryKey:["digest-subscriber-count"],queryFn:async()=>{const{count:q,error:U}=await G.from("profiles").select("id",{count:"exact",head:!0}).eq("digest_opt_out",!1).not("email","is",null);if(U)throw U;return q||0}}),{data:_,refetch:b}=wt({queryKey:["digest-queue-status"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const[U,H,Y,se]=await Promise.all([G.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","pending").gte("created_at",q.toISOString()),G.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","processing").gte("created_at",q.toISOString()),G.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","sent").gte("created_at",q.toISOString()),G.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","failed").gte("created_at",q.toISOString())]);return{pending:U.count||0,processing:H.count||0,sent:Y.count||0,failed:se.count||0,total:(U.count||0)+(H.count||0)+(Y.count||0)+(se.count||0)}},refetchInterval:5e3});C.useEffect(()=>{if(_&&(_.pending>0||_.processing>0)){const q=setInterval(()=>{b(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})},5e3);return()=>clearInterval(q)}},[_,b,t]);const{data:w=0}=wt({queryKey:["digest-today-failed-count"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const{count:U,error:H}=await G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",q.toISOString());if(H)throw H;return U||0}}),j=Dt({mutationFn:async q=>{const{error:U}=await G.from("weekly_digest_settings").update(q).eq("id",d==null?void 0:d.id);if(U)throw U},onSuccess:()=>{t.invalidateQueries({queryKey:["weekly-digest-settings"]}),fe.success("Settings updated")},onError:q=>{fe.error("Failed to update settings: "+q.message)}}),k=async()=>{n(!0);try{const{data:q,error:U}=await G.functions.invoke("send-weekly-digest",{body:{manual:!0}});if(U)throw U;q.queued?fe.success(`${q.queued.toLocaleString()} emails queued! They'll be sent automatically (~80/minute).`):q.sent!==void 0&&fe.success(`Digest sent! ${q.sent} emails delivered, ${q.failed} failed`),b(),t.invalidateQueries({queryKey:["weekly-digest-logs"]})}catch(q){fe.error("Failed to send digest: "+q.message)}finally{n(!1)}},S=async()=>{var q,U,H,Y,se,te;if(!(s!=null&&s.email)){fe.error("No email found for your account");return}o(!0);try{const{data:Q,error:de}=await G.functions.invoke("send-weekly-digest",{body:{preview:!0,previewEmail:s.email}});if(de)throw de;const re=Q==null?void 0:Q.resendId,ae=Q==null?void 0:Q.resendDetails,le=ae==null?void 0:ae.status,he=((q=ae==null?void 0:ae.body)==null?void 0:q.status)||((H=(U=ae==null?void 0:ae.body)==null?void 0:U.data)==null?void 0:H.status),be=((se=(Y=ae==null?void 0:ae.body)==null?void 0:Y.error)==null?void 0:se.message)||((te=ae==null?void 0:ae.body)==null?void 0:te.message);fe.success(re?`Preview accepted by email provider (id: ${re})${le?`, status check: ${le}`:""}${he?`, provider: ${he}`:""}${be?` (${be})`:""}. Check spam/promotions—delivery can take a few minutes.`:"Preview accepted by email provider. Check spam/promotions—delivery can take a few minutes.")}catch(Q){fe.error("Failed to send preview: "+Q.message)}finally{o(!1)}},T=async()=>{i(!0);try{const{data:q,error:U}=await G.functions.invoke("send-weekly-digest",{body:{retryFailed:!0}});if(U)throw U;q.queued===0||q.sent===0&&q.failed===0&&!q.queued?fe.info("No failed emails to retry"):q.queued?fe.success(`${q.queued} emails queued for retry!`):fe.success(`Retry complete! ${q.sent} emails delivered, ${q.failed} failed`),b(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})}catch(q){fe.error("Failed to retry: "+q.message)}finally{i(!1)}},I=_!=null&&_.total?Math.round((_.sent+_.failed)/_.total*100):0,L=((_==null?void 0:_.pending)||0)>0||((_==null?void 0:_.processing)||0)>0,{data:R}=wt({queryKey:["digest-delivery-stats"],queryFn:async()=>{var te,Q;const q=new Date;q.setUTCHours(0,0,0,0);const[U,H,Y,se]=await Promise.all([G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","sent").gte("sent_at",q.toISOString()),G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",q.toISOString()),G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("has_agent_os_activity",!0).gte("sent_at",q.toISOString()),G.from("weekly_digest_logs").select("sent_at").order("sent_at",{ascending:!1}).limit(1)]);return{totalSent:U.count||0,totalFailed:H.count||0,agentOsEngaged:Y.count||0,lastSent:((Q=(te=se.data)==null?void 0:te[0])==null?void 0:Q.sent_at)||null}},refetchInterval:L?5e3:!1}),$={totalSent:(R==null?void 0:R.totalSent)||0,totalFailed:(R==null?void 0:R.totalFailed)||0,lastSent:R==null?void 0:R.lastSent,agentOsEngaged:(R==null?void 0:R.agentOsEngaged)||0};return u?e.jsx(Ts,{title:"Weekly Digest",description:"Manage automated weekly email digests",children:e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-32 bg-muted rounded-lg"}),e.jsx("div",{className:"h-64 bg-muted rounded-lg"})]})}):e.jsx(Ts,{title:"Weekly Digest",description:"Configure and manage automated weekly email digests for members",children:e.jsxs(ka,{defaultValue:"settings",className:"space-y-6",children:[e.jsxs(_a,{children:[e.jsxs(js,{value:"settings",className:"flex items-center gap-2",children:[e.jsx($l,{className:"h-4 w-4"}),"Settings"]}),e.jsxs(js,{value:"stats",className:"flex items-center gap-2",children:[e.jsx(ol,{className:"h-4 w-4"}),"Delivery Stats"]})]}),e.jsxs(zs,{value:"settings",className:"space-y-6",children:[L&&_&&e.jsx(Ee,{className:"border-primary/50 bg-primary/5",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx(Ms,{className:"h-5 w-5 animate-spin text-primary"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:"Sending emails..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[_.sent.toLocaleString()," sent, ",_.pending.toLocaleString()," pending",_.failed>0&&`, ${_.failed} failed`]})]}),e.jsxs("span",{className:"text-sm font-medium",children:[I,"%"]})]}),e.jsx(Ti,{value:I,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Processing ~80 emails per minute. Estimated time remaining: ~",Math.ceil(_.pending/80)," min"]})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:e.jsx(hr,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:y}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscribers"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-emerald-500/10",children:e.jsx(ua,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.totalSent}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Delivered"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-destructive/10",children:e.jsx(kc,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.totalFailed}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:e.jsx(Tn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.lastSent?ys(new Date($.lastSent),"MMM d"):"Never"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last Sent"})]})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-5 w-5"}),"Schedule"]}),e.jsx(pr,{children:"Configure when the digest is sent"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Enable Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Send automated weekly emails to members"})]}),e.jsx(Br,{checked:d==null?void 0:d.is_enabled,onCheckedChange:q=>j.mutate({is_enabled:q})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Cron Frequency"}),e.jsxs(sr,{value:(d==null?void 0:d.cron_frequency)||"daily",onValueChange:q=>j.mutate({cron_frequency:q}),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"daily",children:"Daily (runs once at selected time)"}),e.jsx(At,{value:"hourly",children:"Hourly (checks every hour)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(d==null?void 0:d.cron_frequency)==="hourly"?"Cron runs every hour; digest sends when day & hour match.":"Cron runs once daily at the selected hour (UTC)."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Day of Week"}),e.jsxs(sr,{value:String(d==null?void 0:d.send_day),onValueChange:q=>j.mutate({send_day:parseInt(q)}),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:Oxs.map(q=>e.jsx(At,{value:q.value,children:q.label},q.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Time (UTC)"}),e.jsxs(sr,{value:String(d==null?void 0:d.send_hour),onValueChange:q=>j.mutate({send_hour:parseInt(q)}),disabled:(d==null?void 0:d.cron_frequency)==="daily",children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:Rxs.map(q=>e.jsx(At,{value:q.value,children:q.label},q.value))})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{onClick:S,disabled:a,variant:"outline",className:"flex-1",children:[e.jsx(xa,{className:"h-4 w-4 mr-2"}),a?"Sending...":"Send Preview to Me"]}),e.jsxs(K,{onClick:k,disabled:r,className:"flex-1",children:[e.jsx(aa,{className:"h-4 w-4 mr-2"}),r?"Sending...":"Send to All"]})]}),w>0&&e.jsxs(K,{onClick:T,disabled:l,variant:"outline",className:"w-full",children:[e.jsx(Po,{className:`h-4 w-4 mr-2 ${l?"animate-spin":""}`}),l?"Retrying...":`Retry ${w} Failed`]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(In,{className:"h-5 w-5"}),"Content Sections"]}),e.jsx(pr,{children:"Choose what to include in the digest"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{children:"New Resources"})]}),e.jsx(Br,{checked:d==null?void 0:d.include_new_resources,onCheckedChange:q=>j.mutate({include_new_resources:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{children:"Community Highlights"})]}),e.jsx(Br,{checked:d==null?void 0:d.include_community_posts,onCheckedChange:q=>j.mutate({include_community_posts:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ol,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{children:"Agent OS Stats"})]}),e.jsx(Br,{checked:d==null?void 0:d.include_agent_os_stats,onCheckedChange:q=>j.mutate({include_agent_os_stats:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{children:"Upcoming Events"})]}),e.jsx(Br,{checked:d==null?void 0:d.include_upcoming_events,onCheckedChange:q=>j.mutate({include_upcoming_events:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Gh,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ve,{children:"Goals Progress"})]}),e.jsx(Br,{checked:d==null?void 0:d.include_goals_progress,onCheckedChange:q=>j.mutate({include_goals_progress:q})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Custom Introduction"}),e.jsx(pr,{children:"Personalize the intro message (optional)"})]}),e.jsx(Oe,{children:e.jsx(Ar,{placeholder:"Here's what's new this week to help you grow your business...",value:(d==null?void 0:d.custom_intro_text)||"",onChange:q=>j.mutate({custom_intro_text:q.target.value||null}),rows:3})})]})]}),e.jsx(zs,{value:"stats",children:e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),"Delivery History"]}),e.jsx(pr,{children:"Recent digest emails sent to members"})]}),e.jsx(Oe,{children:f?e.jsx("div",{className:"animate-pulse space-y-2",children:[1,2,3,4,5].map(q=>e.jsx("div",{className:"h-12 bg-muted rounded"},q))}):p&&p.length>0?e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:"Sent At"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{children:"Resources"}),e.jsx(bt,{children:"Agent OS"})]})}),e.jsx(Pn,{children:p.map(q=>e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium",children:q.email_sent_to}),e.jsx(lt,{children:ys(new Date(q.sent_at),"MMM d, yyyy h:mm a")}),e.jsx(lt,{children:e.jsx(rt,{variant:q.delivery_status==="sent"?"default":"destructive",children:q.delivery_status})}),e.jsx(lt,{children:q.resources_count}),e.jsx(lt,{children:q.has_agent_os_activity?e.jsx(rt,{variant:"secondary",children:"Active"}):e.jsx(rt,{variant:"outline",children:"Not Started"})})]},q.id))})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(br,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No digests sent yet"}),e.jsx("p",{className:"text-sm",children:"Send your first digest to see delivery stats"})]})})]})})]})})}const zxs={first_event:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900 dark:text-emerald-200",streak_3:"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200",streak_5:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",events_5:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",events_10:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",events_25:"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200"};function Bxs(){var je,Ne,Ge;const t=rs(),[s,r]=C.useState(""),[n,a]=C.useState(null),[o,l]=C.useState(!1),[i,d]=C.useState(!1),[u,p]=C.useState(""),[f,y]=C.useState(""),[_,b]=C.useState(!0),[w,j]=C.useState(!1),[k,S]=C.useState(""),[T,I]=C.useState(null),{data:L,isLoading:R}=wt({queryKey:["admin-agent-points"],queryFn:async()=>{const{data:we,error:Me}=await G.from("agent_attendance_stats").select("*").order("total_points",{ascending:!1});if(Me)throw Me;const Te=(we==null?void 0:we.map(Ue=>Ue.user_id))||[],{data:Fe}=await G.from("profiles").select("id, name, email").in("id",Te),Ae=new Map((Fe==null?void 0:Fe.map(Ue=>[Ue.id,{name:Ue.name,email:Ue.email}]))||[]);return we==null?void 0:we.map(Ue=>({...Ue,profile:Ae.get(Ue.user_id)||null}))}}),{data:$}=wt({queryKey:["all-profiles-for-points",L],queryFn:async()=>{const Me=[];let Te=0;for(;;){const{data:Fe,error:Ae}=await G.from("profiles").select("id, name, email").order("name").range(Te,Te+1e3-1);if(Ae)throw Ae;if(Me.push(...Fe),!Fe||Fe.length<1e3)break;Te+=1e3}return Me}}),U=(($==null?void 0:$.filter(we=>!(L!=null&&L.some(Me=>Me.user_id===we.id))))||[]).filter(we=>{var Te,Fe;if(!k)return!0;const Me=k.toLowerCase();return((Te=we.name)==null?void 0:Te.toLowerCase().includes(Me))||((Fe=we.email)==null?void 0:Fe.toLowerCase().includes(Me))}),{data:H,isLoading:Y}=wt({queryKey:["agent-point-history",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:we,error:Me}=await G.from("agent_points").select("*").eq("user_id",n.user_id).order("created_at",{ascending:!1});if(Me)throw Me;return we},enabled:!!(n!=null&&n.user_id)&&i}),{data:se}=wt({queryKey:["agent-badges",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:we,error:Me}=await G.from("agent_badges").select("*").eq("user_id",n.user_id).order("earned_at",{ascending:!1});if(Me)throw Me;return we},enabled:!!(n!=null&&n.user_id)}),te=Dt({mutationFn:async({userId:we,points:Me,reason:Te})=>{const{error:Fe}=await G.from("agent_points").insert({user_id:we,points:Me,reason:Te});if(Fe)throw Fe;const{data:Ae}=await G.from("agent_attendance_stats").select("total_points, spendable_points").eq("user_id",we).maybeSingle(),Ue=((Ae==null?void 0:Ae.total_points)||0)+Me,ut=((Ae==null?void 0:Ae.spendable_points)||0)+Me,{error:De}=await G.from("agent_attendance_stats").upsert({user_id:we,total_points:Math.max(0,Ue),spendable_points:Math.max(0,ut),updated_at:new Date().toISOString()},{onConflict:"user_id"});if(De)throw De},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-agent-points"]}),t.invalidateQueries({queryKey:["agent-point-history"]}),l(!1),p(""),y(""),fe.success(_?"Points awarded successfully!":"Points deducted successfully!")},onError:we=>{console.error("Error modifying points:",we),fe.error("Failed to modify points")}}),Q=()=>{if(!n||!u||!f){fe.error("Please fill in all fields");return}const we=parseInt(u);if(isNaN(we)||we<=0){fe.error("Please enter a valid positive number");return}te.mutate({userId:n.user_id,points:_?we:-we,reason:f})},de=()=>{if(!T||!u||!f){fe.error("Please fill in all fields");return}const we=parseInt(u);if(isNaN(we)||we<=0){fe.error("Please enter a valid positive number");return}te.mutate({userId:T.id,points:we,reason:f},{onSuccess:()=>{j(!1),I(null),S("")}})},re=(we,Me)=>{a(we),b(Me),l(!0)},ae=we=>{a(we),d(!0)},le=L==null?void 0:L.filter(we=>{var Ae,Ue,ut,De;const Me=((Ue=(Ae=we.profile)==null?void 0:Ae.name)==null?void 0:Ue.toLowerCase())||"",Te=((De=(ut=we.profile)==null?void 0:ut.email)==null?void 0:De.toLowerCase())||"",Fe=s.toLowerCase();return Me.includes(Fe)||Te.includes(Fe)}),he=(L==null?void 0:L.reduce((we,Me)=>we+Me.total_points,0))||0,be=(L==null?void 0:L.length)||0,_e=be>0?Math.round(he/be):0;return R?e.jsx(Ts,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(we=>e.jsx(xs,{className:"h-24"},we))}),e.jsx(xs,{className:"h-96"})]})}):e.jsx(Ts,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Agent Points Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Track, view, and manage agent gamification points"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Agents"})]}),e.jsx("p",{className:"text-2xl font-bold",children:be}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with points tracked"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ao,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Points"})]}),e.jsx("p",{className:"text-2xl font-bold",children:he.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"awarded across all agents"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ac,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Average Points"})]}),e.jsx("p",{className:"text-2xl font-bold",children:_e}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"per agent"})]})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[e.jsxs("div",{className:"relative max-w-sm w-full",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search agents...",value:s,onChange:we=>r(we.target.value),className:"pl-10"})]}),e.jsxs(K,{onClick:()=>j(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Award Points to New Agent"]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Agent Leaderboard"}),e.jsx(pr,{children:"All agents with their points, events, and streaks"})]}),e.jsx(Oe,{children:!le||le.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ao,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents with points yet"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{className:"w-12",children:"#"}),e.jsx(bt,{children:"Agent"}),e.jsx(bt,{className:"text-center",children:"Total Points"}),e.jsx(bt,{className:"text-center",children:"Spendable"}),e.jsx(bt,{className:"text-center",children:"Events"}),e.jsx(bt,{className:"text-center",children:"Streak"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:le.map((we,Me)=>{var Te,Fe,Ae,Ue;return e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium",children:Me<3?e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center ${Me===0?"bg-yellow-100 text-yellow-700":Me===1?"bg-gray-100 text-gray-600":"bg-amber-100 text-amber-700"}`,children:Me+1}):e.jsx("span",{className:"text-muted-foreground",children:Me+1})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xn,{className:"h-8 w-8",children:e.jsx(yn,{children:((Fe=(Te=we.profile)==null?void 0:Te.name)==null?void 0:Fe.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Ae=we.profile)==null?void 0:Ae.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(Ue=we.profile)==null?void 0:Ue.email})]})]})}),e.jsx(lt,{className:"text-center",children:e.jsxs(rt,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),we.total_points]})}),e.jsx(lt,{className:"text-center",children:e.jsxs(rt,{variant:"outline",className:"font-bold text-primary",children:[e.jsx(po,{className:"h-3 w-3 mr-1"}),we.spendable_points||0]})}),e.jsx(lt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(on,{className:"h-3 w-3 text-muted-foreground"}),we.total_events_attended]})}),e.jsx(lt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(nh,{className:"h-3 w-3 text-orange-500"}),we.current_streak]})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>re(we,!0),title:"Award points",children:e.jsx(Zs,{className:"h-4 w-4 text-green-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>re(we,!1),title:"Deduct points",children:e.jsx(F0,{className:"h-4 w-4 text-red-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ae(we),title:"View history",children:e.jsx(y5,{className:"h-4 w-4"})})]})})]},we.user_id)})})]})})]}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:_?"Award Points":"Deduct Points"}),e.jsxs(Kr,{children:[_?"Award":"Deduct"," points ",_?"to":"from"," ",((je=n==null?void 0:n.profile)==null?void 0:je.name)||"this agent"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"points",children:"Points Amount"}),e.jsx(Re,{id:"points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:we=>p(we.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"reason",children:"Reason"}),e.jsx(Ar,{id:"reason",placeholder:"Enter reason for this adjustment...",value:f,onChange:we=>y(we.target.value)})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:Q,disabled:te.isPending,className:_?"bg-green-600 hover:bg-green-700":"bg-red-600 hover:bg-red-700",children:te.isPending?"Saving...":_?"Award Points":"Deduct Points"})]})]})}),e.jsx(_s,{open:i,onOpenChange:d,children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{children:["Point History: ",(Ne=n==null?void 0:n.profile)==null?void 0:Ne.name]}),e.jsx(Kr,{children:"View all point transactions and badges for this agent"})]}),e.jsxs(ka,{defaultValue:"history",className:"w-full",children:[e.jsxs(_a,{className:"grid w-full grid-cols-2",children:[e.jsx(js,{value:"history",children:"Point History"}),e.jsx(js,{value:"badges",children:"Badges"})]}),e.jsx(zs,{value:"history",className:"mt-4",children:Y?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(we=>e.jsx(xs,{className:"h-12"},we))}):!H||H.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(y5,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No point history yet"})]}):e.jsx("div",{className:"max-h-80 overflow-y-auto space-y-2",children:H.map(we=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:we.reason}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ys(new Date(we.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(rt,{variant:we.points>=0?"default":"destructive",className:we.points>=0?"bg-green-100 text-green-800":"",children:[we.points>=0?"+":"",we.points]})]},we.id))})}),e.jsx(zs,{value:"badges",className:"mt-4",children:!se||se.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(rc,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No badges earned yet"})]}):e.jsx("div",{className:"grid grid-cols-2 gap-3",children:se.map(we=>e.jsxs("div",{className:`p-3 rounded-lg ${zxs[we.badge_type]||"bg-gray-100"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rc,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:we.badge_name})]}),we.badge_description&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:we.badge_description}),e.jsxs("p",{className:"text-xs mt-1 opacity-60",children:["Earned ",ys(new Date(we.earned_at),"MMM d, yyyy")]})]},we.id))})})]})]})}),e.jsx(_s,{open:w,onOpenChange:we=>{j(we),we||(I(null),S(""),p(""),y(""))},children:e.jsxs(vs,{className:"max-w-md",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Award Points to New Agent"}),e.jsx(Kr,{children:"Select an agent who doesn't have points yet and award them points"})]}),e.jsx("div",{className:"space-y-4 py-4",children:T?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(xn,{className:"h-10 w-10",children:e.jsx(yn,{children:((Ge=T.name)==null?void 0:Ge.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:T.name||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:T.email})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>I(null),children:"Change"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"new-points",children:"Points Amount"}),e.jsx(Re,{id:"new-points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:we=>p(we.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"new-reason",children:"Reason"}),e.jsx(Ar,{id:"new-reason",placeholder:"Enter reason for awarding points...",value:f,onChange:we=>y(we.target.value)})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Search Agent"}),e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name or email...",value:k,onChange:we=>S(we.target.value),className:"pl-10"})]})]}),e.jsx("div",{className:"max-h-60 overflow-y-auto border rounded-lg",children:U.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[e.jsx(hr,{className:"h-6 w-6 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:k?"No matching agents found":"All agents already have points"})]}):U.slice(0,20).map(we=>{var Me;return e.jsxs("button",{onClick:()=>I(we),className:"w-full flex items-center gap-3 p-3 hover:bg-muted/50 transition-colors border-b last:border-b-0 text-left",children:[e.jsx(xn,{className:"h-8 w-8",children:e.jsx(yn,{children:((Me=we.name)==null?void 0:Me.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:we.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:we.email})]})]},we.id)})})]})}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),T&&e.jsxs(K,{onClick:de,disabled:te.isPending,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Award Points"]})]})]})})]})})}function $xs(){const{data:t,isLoading:s}=N0t(),[r,n]=C.useState(null),[a,o]=C.useState(!1),[l,i]=C.useState(""),[d,u]=C.useState("all"),[p,f]=C.useState("newest"),[y,_]=C.useState("table"),b=C.useMemo(()=>(t==null?void 0:t.map(T=>T.user_id))||[],[t]),w=C.useMemo(()=>(t==null?void 0:t.map(T=>T.id))||[],[t]),{data:j}=wt({queryKey:["card-profiles-lookup",b],queryFn:async()=>{if(b.length===0)return{};const{data:T}=await G.from("profiles").select("id, name, email").in("id",b),I={};return T==null||T.forEach(L=>{I[L.id]={name:L.name||"",email:L.email||""}}),I},enabled:b.length>0}),{data:k}=wt({queryKey:["card-stats-all",w],queryFn:async()=>{if(w.length===0)return{};const T={};w.forEach(R=>{T[R]={views:0,leads:0}});const{data:I}=await G.from("agent_card_interactions").select("card_id").in("card_id",w).eq("interaction_type","card_view");I==null||I.forEach(R=>{T[R.card_id]&&T[R.card_id].views++});const{data:L}=await G.from("agent_card_leads").select("card_id").in("card_id",w);return L==null||L.forEach(R=>{T[R.card_id]&&T[R.card_id].leads++}),T},enabled:w.length>0}),S=C.useMemo(()=>{if(!t)return[];let T=[...t];if(d==="live"?T=T.filter(I=>I.is_published):d==="draft"&&(T=T.filter(I=>!I.is_published)),l.trim()){const I=l.toLowerCase();T=T.filter(L=>{var $,q;const R=j==null?void 0:j[L.user_id];return L.slug.toLowerCase().includes(I)||(($=R==null?void 0:R.name)==null?void 0:$.toLowerCase().includes(I))||((q=R==null?void 0:R.email)==null?void 0:q.toLowerCase().includes(I))})}return p==="newest"?T.sort((I,L)=>new Date(L.created_at).getTime()-new Date(I.created_at).getTime()):p==="oldest"?T.sort((I,L)=>new Date(I.created_at).getTime()-new Date(L.created_at).getTime()):p==="name"?T.sort((I,L)=>{var R,$;return(((R=j==null?void 0:j[I.user_id])==null?void 0:R.name)||"").localeCompare((($=j==null?void 0:j[L.user_id])==null?void 0:$.name)||"")}):p==="slug"?T.sort((I,L)=>I.slug.localeCompare(L.slug)):p==="views_desc"?T.sort((I,L)=>{var R,$;return(((R=k==null?void 0:k[L.id])==null?void 0:R.views)||0)-((($=k==null?void 0:k[I.id])==null?void 0:$.views)||0)}):p==="views_asc"?T.sort((I,L)=>{var R,$;return(((R=k==null?void 0:k[I.id])==null?void 0:R.views)||0)-((($=k==null?void 0:k[L.id])==null?void 0:$.views)||0)}):p==="leads_desc"?T.sort((I,L)=>{var R,$;return(((R=k==null?void 0:k[L.id])==null?void 0:R.leads)||0)-((($=k==null?void 0:k[I.id])==null?void 0:$.leads)||0)}):p==="leads_asc"&&T.sort((I,L)=>{var R,$;return(((R=k==null?void 0:k[I.id])==null?void 0:R.leads)||0)-((($=k==null?void 0:k[L.id])==null?void 0:$.leads)||0)}),T},[t,d,l,p,j]);return e.jsxs(Ts,{title:"Digital Agent Cards",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Digital Agent Cards"}),e.jsx("p",{className:"text-muted-foreground",children:"Create and manage agent digital business cards"})]}),e.jsxs(K,{onClick:()=>o(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create Card"]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name, email, or slug...",value:l,onChange:T=>i(T.target.value),className:"pl-9"})]}),e.jsxs(sr,{value:d,onValueChange:u,children:[e.jsx(er,{className:"w-full sm:w-36",children:e.jsx(rr,{placeholder:"Status"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Status"}),e.jsx(At,{value:"live",children:"Live"}),e.jsx(At,{value:"draft",children:"Draft"})]})]}),e.jsxs(sr,{value:p,onValueChange:f,children:[e.jsx(er,{className:"w-full sm:w-44",children:e.jsx(rr,{placeholder:"Sort by"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"newest",children:"Newest First"}),e.jsx(At,{value:"oldest",children:"Oldest First"}),e.jsx(At,{value:"name",children:"Name A–Z"}),e.jsx(At,{value:"slug",children:"Slug A–Z"}),e.jsx(At,{value:"views_desc",children:"Most Views"}),e.jsx(At,{value:"views_asc",children:"Fewest Views"}),e.jsx(At,{value:"leads_desc",children:"Most Leads"}),e.jsx(At,{value:"leads_asc",children:"Fewest Leads"})]})]}),e.jsxs("div",{className:"flex border rounded-md",children:[e.jsx(K,{variant:y==="table"?"default":"ghost",size:"sm",onClick:()=>_("table"),className:"rounded-r-none",children:e.jsx(T5,{className:"h-4 w-4"})}),e.jsx(K,{variant:y==="grid"?"default":"ghost",size:"sm",onClick:()=>_("grid"),className:"rounded-l-none",children:e.jsx(yp,{className:"h-4 w-4"})})]})]}),!s&&t&&t.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",S.length," of ",t.length," cards"]}),s?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(T=>e.jsx(xs,{className:"h-48"},T))}):S.length>0?y==="table"?e.jsx(qxs,{cards:S,cardProfiles:j,cardStats:k,onEdit:n,sortBy:p,setSortBy:f}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:S.map(T=>e.jsx(Uxs,{card:T,onEdit:()=>n(T),stats:k==null?void 0:k[T.id]},T.id))}):t&&t.length>0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(gn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No matching cards"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Try adjusting your search or filters"})]})}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No cards yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mb-4",children:"Create your first digital agent card"}),e.jsxs(K,{onClick:()=>o(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create Card"]})]})})]}),e.jsx(Vxs,{open:a,onOpenChange:o}),r&&e.jsx(Hxs,{card:r,open:!!r,onOpenChange:T=>!T&&n(null)})]})}function qxs({cards:t,cardProfiles:s,cardStats:r,onEdit:n,sortBy:a,setSortBy:o}){const l=d=>{a===`${d}_desc`?o(`${d}_asc`):o(`${d}_desc`)},i=({field:d})=>a===`${d}_desc`?e.jsx(sh,{className:"h-3 w-3"}):a===`${d}_asc`?e.jsx(Vd,{className:"h-3 w-3"}):e.jsx(Hc,{className:"h-3 w-3 opacity-40"});return e.jsx(Ee,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"text-left p-3 font-medium",children:e.jsxs("button",{onClick:()=>{o(a==="name"?"newest":"name")},className:"flex items-center gap-1 hover:text-foreground text-muted-foreground",children:["Agent ",a==="name"&&e.jsx(Vd,{className:"h-3 w-3"})]})}),e.jsx("th",{className:"text-left p-3 font-medium text-muted-foreground hidden md:table-cell",children:"Slug"}),e.jsx("th",{className:"text-center p-3 font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-right p-3 font-medium",children:e.jsxs("button",{onClick:()=>l("views"),className:"flex items-center gap-1 ml-auto hover:text-foreground text-muted-foreground",children:["Views ",e.jsx(i,{field:"views"})]})}),e.jsx("th",{className:"text-right p-3 font-medium",children:e.jsxs("button",{onClick:()=>l("leads"),className:"flex items-center gap-1 ml-auto hover:text-foreground text-muted-foreground",children:["Leads ",e.jsx(i,{field:"leads"})]})}),e.jsx("th",{className:"text-right p-3 font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:t.map(d=>{const u=s==null?void 0:s[d.user_id],p=r==null?void 0:r[d.id],f=`https://cards.relevelup.com/${d.slug}`;return e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30 transition-colors",children:[e.jsx("td",{className:"p-3",children:e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:(u==null?void 0:u.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(u==null?void 0:u.email)||""})]})}),e.jsx("td",{className:"p-3 hidden md:table-cell",children:e.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["/",d.slug]})}),e.jsx("td",{className:"p-3 text-center",children:e.jsx(rt,{variant:d.is_published?"default":"secondary",className:"text-xs",children:d.is_published?"Live":"Draft"})}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(p==null?void 0:p.views)??0}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(p==null?void 0:p.leads)??0}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>n(d),className:"h-8 w-8 p-0",children:e.jsx(Da,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{navigator.clipboard.writeText(f),fe.success("Link copied!")},children:e.jsx(ai,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",asChild:!0,children:e.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",children:e.jsx(sn,{className:"h-3.5 w-3.5"})})})]})})]},d.id)})})]})})})}function Uxs({card:t,onEdit:s,stats:r}){const[n,a]=C.useState(null);C.useEffect(()=>{(async()=>{const{data:d}=await G.from("profiles").select("name").eq("id",t.user_id).single();let u=null;try{const{data:p}=await G.storage.from("avatars").list(`${t.user_id}`);if(p&&p.length>0){const{data:f}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${p[0].name}`);u=f.publicUrl}}catch{}a({name:(d==null?void 0:d.name)||"Unknown",avatar_url:u})})()},[t.user_id]);const o=`https://cards.relevelup.com/${t.slug}`,l=()=>{navigator.clipboard.writeText(o),fe.success("Link copied!")};return e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsxs(xn,{className:"h-10 w-10",children:[e.jsx(Aa,{src:(n==null?void 0:n.avatar_url)||void 0}),e.jsx(yn,{children:((n==null?void 0:n.name)||"U")[0]})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold truncate",children:(n==null?void 0:n.name)||"Loading..."}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["/card/",t.slug]})]}),e.jsx(rt,{variant:t.is_published?"default":"secondary",children:t.is_published?"Live":"Draft"})]}),e.jsxs("div",{className:"flex items-center gap-3 mb-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xa,{className:"h-3.5 w-3.5"}),(r==null?void 0:r.views)??0," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hr,{className:"h-3.5 w-3.5"}),(r==null?void 0:r.leads)??0," leads"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:s,className:"flex-1",children:[e.jsx(Da,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:l,children:e.jsx(ai,{className:"h-3 w-3"})}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:e.jsx(sn,{className:"h-3 w-3"})})})]})]})})}function Vxs({open:t,onOpenChange:s}){const[r,n]=C.useState(""),[a,o]=C.useState(""),[l,i]=C.useState(""),[d,u]=C.useState(!1),p=E9e(),f=l.trim(),{data:y}=wt({queryKey:["profiles-search-for-cards",f],queryFn:async()=>{let S=G.from("profiles").select("id, name, email").order("name").limit(50);f.length>=2&&(S=S.or(`name.ilike.%${f}%,email.ilike.%${f}%`));const{data:T}=await S;return T||[]},enabled:t}),[_,b]=C.useState(null),w=(y==null?void 0:y.find(S=>S.id===r))||_,j=()=>{if(!r||!a.trim()){fe.error("Select an agent and enter a slug");return}p.mutate({user_id:r,slug:a.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-"),is_published:!0},{onSuccess:()=>{s(!1),n(""),o(""),i("")}})},k=S=>{var I;n(S),u(!1);const T=y==null?void 0:y.find(L=>L.id===S);T&&(b(T),o(((I=T.name)==null?void 0:I.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||""))};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Create Agent Card"}),e.jsx(Kr,{children:"Select an agent and set their card URL slug."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Agent"}),e.jsxs(Co,{open:d,onOpenChange:u,children:[e.jsx(Mo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":d,className:"w-full justify-between font-normal",children:[w?`${w.name} (${w.email})`:"Search for an agent...",e.jsx(xf,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(No,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Mf,{shouldFilter:!1,children:[e.jsx(Tf,{placeholder:"Search by name or email...",value:l,onValueChange:i}),e.jsxs(Af,{children:[e.jsx(Ef,{children:"No agents found."}),e.jsx(Pf,{children:(y||[]).map(S=>e.jsxs(Cm,{value:S.id,onSelect:k,children:[e.jsx(ha,{className:Pt("mr-2 h-4 w-4",r===S.id?"opacity-100":"opacity-0")}),S.name," (",S.email,")"]},S.id))})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"URL Slug"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"/card/"}),e.jsx(Re,{value:a,onChange:S=>o(S.target.value),placeholder:"john-doe"})]})]}),e.jsx(K,{onClick:j,disabled:p.isPending,className:"w-full",children:p.isPending?"Creating...":"Create Card"})]})]})})}function Hxs({card:t,open:s,onOpenChange:r}){const n=P9e(),{data:a}=I9e(t.id),o=rs(),[l,i]=C.useState(null),[d,u]=C.useState(!1),[p,f]=C.useState(!1),[y,_]=C.useState(""),[b,w]=C.useState(t.slug),[j,k]=C.useState(!1),[S,T]=C.useState({is_published:t.is_published,theme:t.theme,title:t.title||"",positioning_statement:t.positioning_statement||"",bio:t.bio||"",review_snippet:t.review_snippet||"",review_source_url:t.review_source_url||"",booking_url:t.booking_url||"",custom_cta_label:t.custom_cta_label||"",custom_cta_url:t.custom_cta_url||"",show_photo:t.show_photo,show_bio:t.show_bio,show_credentials:t.show_credentials,show_social_links:t.show_social_links,show_save_contact:t.show_save_contact,show_leave_review:t.show_leave_review,show_refer_friend:t.show_refer_friend,brokerage_display_name:t.brokerage_display_name||"",brokerage_logo_url:t.brokerage_logo_url||"",brokerage_logo_size:t.brokerage_logo_size||56,team_name:t.team_name||"",team_logo_url:t.team_logo_url||"",team_logo_size:t.team_logo_size||56});C.useEffect(()=>{s&&(async()=>{try{const{data:H}=await G.storage.from("avatars").list(`${t.user_id}`);if(H&&H.length>0){const{data:Y}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${H[0].name}`);i(`${Y.publicUrl}?t=${Date.now()}`)}}catch{}})()},[t.user_id,s]);const I=U=>{var se;const H=(se=U.target.files)==null?void 0:se[0];if(!H)return;if(!H.type.startsWith("image/")){fe.error("Please select an image file");return}if(H.size>5*1024*1024){fe.error("Image must be under 5MB");return}const Y=new FileReader;Y.onloadend=()=>{_(Y.result),f(!0)},Y.readAsDataURL(H),U.target.value=""},L=async U=>{u(!0);try{const{data:H}=await G.storage.from("avatars").list(`${t.user_id}`);H&&H.length>0&&await G.storage.from("avatars").remove(H.map(de=>`${t.user_id}/${de.name}`));const Y=`${t.user_id}/avatar.jpg`,{error:se}=await G.storage.from("avatars").upload(Y,U,{upsert:!0,contentType:"image/jpeg"});if(se)throw se;const{data:te}=G.storage.from("avatars").getPublicUrl(Y),Q=`${te.publicUrl}?t=${Date.now()}`;i(Q),await G.from("profiles").update({avatar_url:Q}).eq("id",t.user_id),o.invalidateQueries({queryKey:["agent-card-public"]}),fe.success("Photo updated!")}catch(H){fe.error(H.message||"Upload failed")}finally{u(!1)}},R=async()=>{const U=b.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!U){fe.error("Please enter a valid URL");return}if(U===t.slug){fe.info("No changes to save");return}k(!0);try{const{data:H}=await G.from("agent_cards").select("id").eq("slug",U).neq("id",t.id).maybeSingle();if(H){fe.error("This URL is already taken. Try another one.");return}const{error:Y}=await G.from("agent_cards").update({slug:U}).eq("id",t.id);if(Y)throw Y;w(U),o.invalidateQueries({queryKey:["agent-cards-admin"]}),fe.success("Card address updated!")}catch{fe.error("Failed to update card address")}finally{k(!1)}},$=async(U,H)=>{var se;const Y=(se=U.target.files)==null?void 0:se[0];if(Y){if(!Y.type.startsWith("image/")){fe.error("Please select an image file");return}try{const te=Y.name.split(".").pop()||"png",Q=H==="brokerage_logo_url"?"brokerage-logo":"team-logo",de=`${t.user_id}/${Q}.${te}`,{error:re}=await G.storage.from("card-logos").upload(de,Y,{upsert:!0});if(re)throw re;const{data:ae}=G.storage.from("card-logos").getPublicUrl(de),le=ae.publicUrl+"?t="+Date.now();T(H==="brokerage_logo_url"?he=>({...he,[H]:le,brokerage_display_name:""}):he=>({...he,[H]:le,team_name:""})),fe.success("Logo uploaded!")}catch{fe.error("Failed to upload logo")}finally{U.target.value=""}}},q=()=>{n.mutate({id:t.id,...S,title:S.title||null,positioning_statement:S.positioning_statement||null,bio:S.bio||null,review_snippet:S.review_snippet||null,review_source_url:S.review_source_url||null,booking_url:S.booking_url||null,custom_cta_label:S.custom_cta_label||null,custom_cta_url:S.custom_cta_url||null,brokerage_display_name:S.brokerage_display_name||null,brokerage_logo_url:S.brokerage_logo_url||null,brokerage_logo_size:S.brokerage_logo_size,team_name:S.team_name||null,team_logo_url:S.team_logo_url||null,team_logo_size:S.team_logo_size},{onSuccess:()=>r(!1)})};return e.jsxs(e.Fragment,{children:[e.jsx(_s,{open:s,onOpenChange:r,children:e.jsxs(vs,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Edit Agent Card"}),e.jsxs(Kr,{children:["/card/",t.slug]})]}),e.jsxs(ka,{defaultValue:"content",children:[e.jsxs(_a,{className:"w-full",children:[e.jsx(js,{value:"content",className:"flex-1",children:"Content"}),e.jsx(js,{value:"sections",className:"flex-1",children:"Sections"}),e.jsx(js,{value:"blocks",className:"flex-1",children:"Blocks"}),e.jsx(js,{value:"analytics",className:"flex-1",children:"Analytics"})]}),e.jsxs(zs,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Published"}),e.jsx(Br,{checked:S.is_published,onCheckedChange:U=>T(H=>({...H,is_published:U}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[e.jsxs(xn,{className:"h-16 w-16",children:[e.jsx(Aa,{src:l||void 0}),e.jsx(yn,{children:"?"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:I,disabled:d}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:d,children:e.jsx("span",{children:d?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-3 w-3 mr-1 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Za,{className:"h-3 w-3 mr-1"}),"Change Photo"]})})})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Card Address"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs("div",{className:"flex flex-1",children:[e.jsx("span",{className:"inline-flex items-center px-3 rounded-l-md border border-r-0 bg-muted text-muted-foreground text-xs whitespace-nowrap",children:"cards.relevelup.com/"}),e.jsx(Re,{value:b,onChange:U=>w(U.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"agent-name",className:"rounded-l-none"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:R,disabled:j||b===t.slug,className:"shrink-0",children:j?"Saving...":"Update"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Theme"}),e.jsxs(sr,{value:S.theme,onValueChange:U=>T(H=>({...H,theme:U})),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"standard",children:"✨ Standard (Modern Clean)"}),e.jsx(At,{value:"luxury",children:"🌙 Luxury (Dark & Gold)"}),e.jsx(At,{value:"bold",children:"🔥 Bold (Vibrant & Punchy)"}),e.jsx(At,{value:"classic",children:"📋 Classic (Professional)"})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Title / Tagline"}),e.jsx(Re,{value:S.title,onChange:U=>T(H=>({...H,title:U.target.value})),placeholder:"e.g. Luxury Real Estate Specialist"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Shown below the agent's name on the card"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Positioning Statement"}),e.jsx(Re,{value:S.positioning_statement,onChange:U=>T(H=>({...H,positioning_statement:U.target.value})),placeholder:"Your home journey, handled with care."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Bio"}),e.jsx(Ar,{value:S.bio,onChange:U=>T(H=>({...H,bio:U.target.value})),placeholder:"Short about me...",rows:3})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Review Snippet"}),e.jsx(Re,{value:S.review_snippet,onChange:U=>T(H=>({...H,review_snippet:U.target.value})),placeholder:"Best agent we've ever worked with..."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Review Source URL"}),e.jsx(Re,{value:S.review_source_url,onChange:U=>T(H=>({...H,review_source_url:U.target.value})),placeholder:"https://g.page/your-business/review"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Booking URL (optional — if empty, shows lead form)"}),e.jsx(Re,{value:S.booking_url,onChange:U=>T(H=>({...H,booking_url:U.target.value})),placeholder:"https://calendly.com/your-link"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Custom CTA Label (optional)"}),e.jsx(Re,{value:S.custom_cta_label,onChange:U=>T(H=>({...H,custom_cta_label:U.target.value})),placeholder:"Book a Call"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Custom CTA URL (optional)"}),e.jsx(Re,{value:S.custom_cta_url,onChange:U=>T(H=>({...H,custom_cta_url:U.target.value})),placeholder:"https://example.com/landing"})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(ve,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{value:S.brokerage_display_name,onChange:U=>T(H=>({...H,brokerage_display_name:U.target.value,brokerage_logo_url:""})),placeholder:"Brokerage name (or upload logo below)",disabled:!!S.brokerage_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[S.brokerage_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:S.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${S.brokerage_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>T(U=>({...U,brokerage_logo_url:""})),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(Za,{className:"h-3.5 w-3.5"}),S.brokerage_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:U=>$(U,"brokerage_logo_url")})]})]}),S.brokerage_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.brokerage_logo_size||56,"px"]})]}),e.jsx(Fg,{value:[S.brokerage_logo_size||56],onValueChange:([U])=>T(H=>({...H,brokerage_logo_size:U})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(ve,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{value:S.team_name,onChange:U=>T(H=>({...H,team_name:U.target.value,team_logo_url:""})),placeholder:"Team name (or upload logo below)",disabled:!!S.team_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[S.team_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:S.team_logo_url,alt:"Team logo",style:{height:`${S.team_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>T(U=>({...U,team_logo_url:""})),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(Za,{className:"h-3.5 w-3.5"}),S.team_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:U=>$(U,"team_logo_url")})]})]}),S.team_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.team_logo_size||56,"px"]})]}),e.jsx(Fg,{value:[S.team_logo_size||56],onValueChange:([U])=>T(H=>({...H,team_logo_size:U})),min:24,max:120,step:4})]})]})]})]}),e.jsx(zs,{value:"sections",className:"space-y-4 mt-4",children:[{key:"show_photo",label:"Show Photo",hint:"Photo is pulled from the agent's profile."},{key:"show_bio",label:"Show Bio"},{key:"show_credentials",label:"Show Credentials"},{key:"show_social_links",label:"Show Social Links"},{key:"show_save_contact",label:"Save Contact Button"},{key:"show_leave_review",label:"Leave Review Button"},{key:"show_refer_friend",label:"Refer a Friend Button"}].map(({key:U,label:H,hint:Y})=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx(ve,{children:H}),Y&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[Y," ",U==="show_photo"&&e.jsx("a",{href:"/profile",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:no-underline",children:"Update Profile"})]})]}),e.jsx(Br,{checked:S[U],onCheckedChange:se=>T(te=>({...te,[U]:se}))})]},U))}),e.jsx(zs,{value:"blocks",className:"mt-4",children:e.jsx(GJe,{cardId:t.id})}),e.jsx(zs,{value:"analytics",className:"mt-4",children:a?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.views}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Views"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.clicks}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Clicks"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.leads.length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Leads"})]})})]}),a.leads.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold mb-2",children:"Recent Leads"}),e.jsx("div",{className:"space-y-2",children:a.leads.slice(0,5).map(U=>e.jsxs("div",{className:"text-sm p-2 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"font-medium",children:U.name}),U.phone&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",U.phone]}),U.intent&&e.jsx(rt,{variant:"secondary",className:"ml-2 text-xs",children:U.intent})]},U.id))})]})]}):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No analytics data yet"})})]}),e.jsx(K,{onClick:q,disabled:n.isPending,className:"w-full mt-4",children:n.isPending?"Saving...":"Save Changes"})]})}),e.jsx(owe,{open:p,onClose:()=>f(!1),imageSrc:y,onCropComplete:L,aspectRatio:1})]})}const Z5={pending_payment:"Pending Payment",order_submitted:"Order Submitted",awaiting_proof_approval:"Awaiting Proof Approval",proof_approved:"Proof Approved",processing:"Processing",in_production:"In Production",shipped:"Shipped",completed:"Completed",cancelled:"Cancelled",refunded:"Refunded"},Y2e={pending_payment:"bg-yellow-100 text-yellow-800",order_submitted:"bg-blue-100 text-blue-800",awaiting_proof_approval:"bg-orange-100 text-orange-800",proof_approved:"bg-green-100 text-green-800",processing:"bg-purple-100 text-purple-800",in_production:"bg-indigo-100 text-indigo-800",shipped:"bg-cyan-100 text-cyan-800",completed:"bg-green-200 text-green-900",cancelled:"bg-red-100 text-red-800",refunded:"bg-gray-100 text-gray-800"};function X2e(t=!0){return wt({queryKey:["marketplace-categories",t],queryFn:async()=>{let s=G.from("marketplace_categories").select("*").order("sort_order",{ascending:!0});t&&(s=s.eq("is_active",!0));const{data:r,error:n}=await s;if(n)throw n;return r}})}function Wxs(){const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("marketplace_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),fe.success("Category created successfully")},onError:s=>{fe.error("Failed to create category: "+s.message)}})}function Gxs(){const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("marketplace_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),fe.success("Category updated successfully")},onError:s=>{fe.error("Failed to update category: "+s.message)}})}function Kxs(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("marketplace_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),fe.success("Category deleted successfully")},onError:s=>{fe.error("Failed to delete category: "+s.message)}})}function cet(t,s=!0){return wt({queryKey:["marketplace-products",t,s],queryFn:async()=>{let r=G.from("marketplace_products").select(` *, category:marketplace_categories(*), images:marketplace_product_images(*), video:marketplace_product_videos(*), variants:marketplace_product_variants(*) `).order("sort_order",{ascending:!0});t&&(r=r.eq("category_id",t)),s&&(r=r.eq("is_active",!0));const{data:n,error:a}=await r;if(a)throw a;return n}})}function Zxs(t){return wt({queryKey:["marketplace-product",t],queryFn:async()=>{const{data:s,error:r}=await G.from("marketplace_products").select(` *, category:marketplace_categories(*), images:marketplace_product_images(*), video:marketplace_product_videos(*), variants:marketplace_product_variants(*) `).eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function Yxs(){const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("marketplace_products").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),fe.success("Product created successfully")},onError:s=>{fe.error("Failed to create product: "+s.message)}})}function Xxs(){const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("marketplace_products").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.id]}),fe.success("Product updated successfully")},onError:s=>{fe.error("Failed to update product: "+s.message)}})}function Qxs(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("marketplace_products").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),fe.success("Product deleted successfully")},onError:s=>{fe.error("Failed to delete product: "+s.message)}})}function Jxs(){const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("marketplace_product_images").insert([s]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.product_id]})}})}function eys(){const t=rs();return Dt({mutationFn:async({id:s,productId:r})=>{const{error:n}=await G.from("marketplace_product_images").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),fe.success("Image deleted successfully")},onError:s=>{fe.error("Failed to delete image: "+s.message)}})}function tys(){const t=rs();return Dt({mutationFn:async({imageId:s,productId:r})=>{const{error:n}=await G.from("marketplace_product_images").update({is_primary:!1}).eq("product_id",r);if(n)throw n;const{error:a}=await G.from("marketplace_product_images").update({is_primary:!0}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),fe.success("Primary image updated")},onError:s=>{fe.error("Failed to set primary image: "+s.message)}})}function sys(){const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("marketplace_product_variants").insert([s]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.product_id]}),fe.success("Variant added successfully")}})}function rys(){const t=rs();return Dt({mutationFn:async({id:s,productId:r})=>{const{error:n}=await G.from("marketplace_product_variants").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),fe.success("Variant deleted successfully")}})}function nys(){const t=rs();return Dt({mutationFn:async({productId:s,videoUrl:r})=>{await G.from("marketplace_product_videos").delete().eq("product_id",s);const{data:n,error:a}=await G.from("marketplace_product_videos").insert({product_id:s,video_url:r}).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.productId]}),fe.success("Video updated successfully")}})}function ays(t){const{isAdmin:s}=Hs();return wt({queryKey:["marketplace-orders",t,s],queryFn:async()=>{let r=G.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).order("created_at",{ascending:!1});const{data:n,error:a}=await r;if(a)throw a;if(s&&n){const o=[...new Set(n.map(d=>d.user_id))],{data:l}=await G.from("profiles").select("id, name, email").in("id",o),i=new Map((l==null?void 0:l.map(d=>[d.id,d]))||[]);return n.map(d=>({...d,user:i.get(d.user_id)}))}return n}})}function iys(){const{user:t}=Hs();return wt({queryKey:["my-marketplace-orders",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).eq("user_id",t.id).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function oys(t){return wt({queryKey:["marketplace-order",t],queryFn:async()=>{const{data:s,error:r}=await G.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function lys(){const t=rs(),{user:s}=Hs();return Dt({mutationFn:async({orderId:r,status:n,notes:a,trackingNumber:o,trackingUrl:l,previousStatus:i})=>{const d={status:n};o!==void 0&&(d.tracking_number=o),l!==void 0&&(d.tracking_url=l);const{error:u}=await G.from("marketplace_orders").update(d).eq("id",r);if(u)throw u;const{error:p}=await G.from("marketplace_order_status_history").insert({order_id:r,status:n,notes:a,created_by:s==null?void 0:s.id});if(p)throw p;if(["shipped","in_production","processing","completed"].includes(n)&&n!==i)try{await G.functions.invoke("marketplace-order-notify",{body:{orderId:r,notificationType:n==="shipped"?"shipped":"status_update",newStatus:n,trackingNumber:o,trackingUrl:l}})}catch(y){console.error("Failed to send notification email:",y)}},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",n.orderId]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),fe.success("Order status updated")},onError:r=>{fe.error("Failed to update order: "+r.message)}})}function cys(){const t=rs();return Dt({mutationFn:async({itemId:s,proofUrl:r,proofNotes:n,orderId:a})=>{const{error:o}=await G.from("marketplace_order_items").update({proof_url:r,proof_notes:n,proof_status:"pending"}).eq("id",s);if(o)throw o;await G.from("marketplace_orders").update({status:"awaiting_proof_approval"}).eq("id",a);try{await G.functions.invoke("marketplace-order-notify",{body:{orderId:a,notificationType:"proof_ready"}})}catch(l){console.error("Failed to send proof notification:",l)}return a},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),fe.success("Proof uploaded & customer notified")}})}function dys(){const t=rs();return Dt({mutationFn:async({itemId:s,orderId:r})=>{const{error:n}=await G.from("marketplace_order_items").update({proof_status:"approved"}).eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),fe.success("Proof approved")}})}function uys(){const t=rs();return Dt({mutationFn:async({itemId:s,orderId:r,reason:n})=>{const{error:a}=await G.from("marketplace_order_items").update({proof_status:"rejected",proof_notes:n}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),fe.success("Proof rejected - please upload a new proof")}})}function hys(){const{data:t,isLoading:s}=X2e(!1),r=Wxs(),n=Gxs(),a=Kxs(),[o,l]=C.useState(!1),[i,d]=C.useState(null),[u,p]=C.useState({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),f=()=>{p({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),d(null)},y=w=>{d(w),p({name:w.name,description:w.description||"",image_url:w.image_url||"",sort_order:w.sort_order,is_active:w.is_active}),l(!0)},_=async w=>{w.preventDefault(),i?await n.mutateAsync({id:i.id,...u}):await r.mutateAsync(u),l(!1),f()},b=async w=>{confirm("Are you sure you want to delete this category?")&&await a.mutateAsync(w)};return s?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(xs,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(w=>e.jsx(xs,{className:"h-12 w-full"},w))})})]}):e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{children:"Categories"}),e.jsxs(_s,{open:o,onOpenChange:w=>{l(w),w||f()},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Category"]})}),e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:i?"Edit Category":"Add Category"})}),e.jsxs("form",{onSubmit:_,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Name"}),e.jsx(Re,{id:"name",value:u.name,onChange:w=>p({...u,name:w.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",value:u.description,onChange:w=>p({...u,description:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"image_url",children:"Image URL"}),e.jsx(Re,{id:"image_url",value:u.image_url,onChange:w=>p({...u,image_url:w.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(Re,{id:"sort_order",type:"number",value:u.sort_order,onChange:w=>p({...u,sort_order:parseInt(w.target.value)||0})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"is_active",checked:u.is_active,onCheckedChange:w=>p({...u,is_active:w})}),e.jsx(ve,{htmlFor:"is_active",children:"Active"})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:r.isPending||n.isPending,children:i?"Update Category":"Create Category"})]})]})]})]}),e.jsx(Oe,{children:t&&t.length>0?e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{children:"Sort Order"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(w=>e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium",children:w.name}),e.jsx(lt,{className:"max-w-xs truncate",children:w.description}),e.jsx(lt,{children:w.sort_order}),e.jsx(lt,{children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${w.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:w.is_active?"Active":"Inactive"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>y(w),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(w.id),disabled:a.isPending,children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},w.id))})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first category to get started."})})]})}function mys(){var _e,je;const{data:t,isLoading:s}=cet(void 0,!1),{data:r}=X2e(!1),n=Yxs(),a=Xxs(),o=Qxs(),l=Jxs(),i=eys(),d=tys(),u=sys(),p=rys(),f=nys(),[y,_]=C.useState(!1),[b,w]=C.useState(!1),[j,k]=C.useState(!1),[S,T]=C.useState(null),[I,L]=C.useState(null),[R,$]=C.useState(!1),[q,U]=C.useState({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),[H,Y]=C.useState({name:"",price_adjustment:0}),[se,te]=C.useState(""),Q=()=>{U({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),T(null)},de=Ne=>{T(Ne),U({name:Ne.name,description:Ne.description||"",base_price:Number(Ne.base_price),shipping_fee:Number(Ne.shipping_fee),category_id:Ne.category_id||"",allow_artwork_upload:Ne.allow_artwork_upload,requires_proof_approval:Ne.requires_proof_approval,is_active:Ne.is_active,sort_order:Ne.sort_order}),_(!0)},re=async Ne=>{Ne.preventDefault();const Ge={...q,category_id:q.category_id||null};S?await a.mutateAsync({id:S.id,...Ge}):await n.mutateAsync(Ge),_(!1),Q()},ae=async Ne=>{confirm("Are you sure you want to delete this product?")&&await o.mutateAsync(Ne)},le=async Ne=>{if(!I||!Ne.target.files||Ne.target.files.length===0)return;$(!0);const Ge=Ne.target.files[0],we=Ge.name.split(".").pop(),Me=`products/${I.id}/${Date.now()}.${we}`;try{const{error:Te}=await G.storage.from("marketplace").upload(Me,Ge);if(Te)throw Te;const{data:{publicUrl:Fe}}=G.storage.from("marketplace").getPublicUrl(Me);await l.mutateAsync({product_id:I.id,image_url:Fe,is_primary:!I.images||I.images.length===0}),fe.success("Image uploaded successfully")}catch(Te){fe.error("Failed to upload image: "+Te.message)}finally{$(!1)}},he=async Ne=>{Ne.preventDefault(),I&&(await u.mutateAsync({product_id:I.id,name:H.name,price_adjustment:H.price_adjustment}),Y({name:"",price_adjustment:0}))},be=async()=>{!I||!se||(await f.mutateAsync({productId:I.id,videoUrl:se}),te(""))};return s?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(xs,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(Ne=>e.jsx(xs,{className:"h-64 w-full"},Ne))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{children:"Products"}),e.jsxs(_s,{open:y,onOpenChange:Ne=>{_(Ne),Ne||Q()},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Product"]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:S?"Edit Product":"Add Product"})}),e.jsxs("form",{onSubmit:re,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"name",children:"Product Name"}),e.jsx(Re,{id:"name",value:q.name,onChange:Ne=>U({...q,name:Ne.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"category",children:"Category"}),e.jsxs(sr,{value:q.category_id,onValueChange:Ne=>U({...q,category_id:Ne}),children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select category"})}),e.jsx(tr,{children:r==null?void 0:r.map(Ne=>e.jsx(At,{value:Ne.id,children:Ne.name},Ne.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",value:q.description,onChange:Ne=>U({...q,description:Ne.target.value}),rows:4})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"base_price",children:"Base Price ($)"}),e.jsx(Re,{id:"base_price",type:"number",step:"0.01",min:"0",value:q.base_price,onChange:Ne=>U({...q,base_price:parseFloat(Ne.target.value)||0}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"shipping_fee",children:"Shipping Fee ($)"}),e.jsx(Re,{id:"shipping_fee",type:"number",step:"0.01",min:"0",value:q.shipping_fee,onChange:Ne=>U({...q,shipping_fee:parseFloat(Ne.target.value)||0})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(Re,{id:"sort_order",type:"number",value:q.sort_order,onChange:Ne=>U({...q,sort_order:parseInt(Ne.target.value)||0})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"allow_artwork_upload",checked:q.allow_artwork_upload,onCheckedChange:Ne=>U({...q,allow_artwork_upload:Ne})}),e.jsx(ve,{htmlFor:"allow_artwork_upload",children:"Allow customer to upload artwork"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"requires_proof_approval",checked:q.requires_proof_approval,onCheckedChange:Ne=>U({...q,requires_proof_approval:Ne})}),e.jsx(ve,{htmlFor:"requires_proof_approval",children:"Requires proof approval"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"is_active",checked:q.is_active,onCheckedChange:Ne=>U({...q,is_active:Ne})}),e.jsx(ve,{htmlFor:"is_active",children:"Active"})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:n.isPending||a.isPending,children:S?"Update Product":"Create Product"})]})]})]})]}),e.jsx(Oe,{children:t&&t.length>0?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(Ne=>{var Ge,we;return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[Ne.images&&Ne.images.length>0?e.jsx("img",{src:((Ge=Ne.images.find(Me=>Me.is_primary))==null?void 0:Ge.image_url)||Ne.images[0].image_url,alt:Ne.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:"No image"}),!Ne.is_active&&e.jsx(rt,{variant:"secondary",className:"absolute top-2 right-2",children:"Inactive"})]}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1",children:Ne.name}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:((we=Ne.category)==null?void 0:we.name)||"No category"}),e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("span",{className:"font-bold",children:["$",Number(Ne.base_price).toFixed(2)]}),Number(Ne.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["+$",Number(Ne.shipping_fee).toFixed(2)," shipping"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[Ne.allow_artwork_upload&&e.jsx(rt,{variant:"outline",className:"text-xs",children:"Artwork Upload"}),Ne.requires_proof_approval&&e.jsx(rt,{variant:"outline",className:"text-xs",children:"Proof Required"}),Ne.variants&&Ne.variants.length>0&&e.jsxs(rt,{variant:"outline",className:"text-xs",children:[Ne.variants.length," Variants"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>de(Ne),children:[e.jsx(Da,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(Ne),w(!0)},children:[e.jsx(D0,{className:"h-3 w-3 mr-1"}),"Images"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(Ne),k(!0)},children:[e.jsx(Wh,{className:"h-3 w-3 mr-1"}),"Variants"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ae(Ne.id),children:e.jsx(jr,{className:"h-3 w-3 text-destructive"})})]})]})]},Ne.id)})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No products yet. Create your first product to get started."})})]}),e.jsx(_s,{open:b,onOpenChange:w,children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsx(Ss,{children:e.jsxs(ks,{children:["Manage Images - ",I==null?void 0:I.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-4",children:(_e=I==null?void 0:I.images)==null?void 0:_e.map(Ne=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:Ne.image_url,alt:"",className:"w-full aspect-square object-cover rounded-lg"}),Ne.is_primary&&e.jsx(rt,{className:"absolute top-2 left-2",variant:"default",children:"Primary"}),e.jsxs("div",{className:"absolute top-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[!Ne.is_primary&&e.jsx(K,{variant:"secondary",size:"icon",onClick:async()=>{var Ge;await d.mutateAsync({imageId:Ne.id,productId:I.id}),L({...I,images:(Ge=I.images)==null?void 0:Ge.map(we=>({...we,is_primary:we.id===Ne.id}))})},disabled:d.isPending,title:"Set as primary",children:e.jsx(Gn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"destructive",size:"icon",onClick:async()=>{var we;await i.mutateAsync({id:Ne.id,productId:I.id});const Ge=t==null?void 0:t.find(Me=>Me.id===I.id);Ge&&L({...Ge,images:(we=Ge.images)==null?void 0:we.filter(Me=>Me.id!==Ne.id)})},disabled:i.isPending,children:e.jsx(jr,{className:"h-4 w-4"})})]})]},Ne.id))}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:le,className:"hidden",id:"image-upload",disabled:R}),e.jsxs("label",{htmlFor:"image-upload",className:"cursor-pointer",children:[e.jsx(D0,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:R?"Uploading...":"Click to upload an image"})]})]}),e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx(ve,{children:"Product Video (optional)"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(Re,{placeholder:"Enter video URL (YouTube, Vimeo, etc.)",value:se,onChange:Ne=>te(Ne.target.value)}),e.jsxs(K,{onClick:be,disabled:!se,children:[e.jsx(Nn,{className:"h-4 w-4 mr-2"}),"Set Video"]})]}),(I==null?void 0:I.video)&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Current video: ",I.video.video_url]})]})]})]})}),e.jsx(_s,{open:j,onOpenChange:k,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsxs(ks,{children:["Manage Variants - ",I==null?void 0:I.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:he,className:"flex gap-2",children:[e.jsx(Re,{placeholder:"Variant name (e.g., 500 count)",value:H.name,onChange:Ne=>Y({...H,name:Ne.target.value}),required:!0}),e.jsx(Re,{type:"number",step:"0.01",placeholder:"Price adj.",value:H.price_adjustment,onChange:Ne=>Y({...H,price_adjustment:parseFloat(Ne.target.value)||0}),className:"w-32"}),e.jsx(K,{type:"submit",children:"Add"})]}),e.jsxs("div",{className:"space-y-2",children:[(je=I==null?void 0:I.variants)==null?void 0:je.map(Ne=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted rounded-lg",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:Ne.name}),e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:[Number(Ne.price_adjustment)>=0?"+":"","$",Number(Ne.price_adjustment).toFixed(2)]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutateAsync({id:Ne.id,productId:I.id}),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]},Ne.id)),(!(I!=null&&I.variants)||I.variants.length===0)&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:'No variants yet. Add variants like "250 count", "500 count", etc.'})]})]})]})})]})}const pys=["pending_payment","order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed","cancelled","refunded"];function fys(){var w,j,k;const{data:t,isLoading:s}=ays(),r=lys(),n=cys(),[a,o]=C.useState(null),[l,i]=C.useState(!1),[d,u]=C.useState({status:"",notes:"",trackingNumber:"",trackingUrl:""}),[p,f]=C.useState(!1),y=S=>{o(S),u({status:S.status,notes:"",trackingNumber:S.tracking_number||"",trackingUrl:S.tracking_url||""}),i(!0)},_=async()=>{a&&(await r.mutateAsync({orderId:a.id,status:d.status,notes:d.notes,trackingNumber:d.trackingNumber,trackingUrl:d.trackingUrl,previousStatus:a.status}),i(!1))},b=async(S,T)=>{if(!a||!S.target.files||S.target.files.length===0)return;f(!0);const I=S.target.files[0],L=I.name.split(".").pop(),R=`proofs/${a.id}/${T}/${Date.now()}.${L}`;try{const{error:$}=await G.storage.from("marketplace").upload(R,I);if($)throw $;const{data:{publicUrl:q}}=G.storage.from("marketplace").getPublicUrl(R);await n.mutateAsync({itemId:T,proofUrl:q,orderId:a.id}),fe.success("Proof uploaded successfully")}catch($){fe.error("Failed to upload proof: "+$.message)}finally{f(!1)}};return s?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(xs,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(S=>e.jsx(xs,{className:"h-16 w-full"},S))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Orders"})}),e.jsx(Oe,{children:t&&t.length>0?e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Order #"}),e.jsx(bt,{children:"Customer"}),e.jsx(bt,{children:"Date"}),e.jsx(bt,{children:"Total"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(S=>{var T,I;return e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-mono",children:S.order_number}),e.jsx(lt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((T=S.user)==null?void 0:T.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(I=S.user)==null?void 0:I.email})]})}),e.jsx(lt,{children:ys(new Date(S.created_at),"MMM d, yyyy")}),e.jsxs(lt,{className:"font-bold",children:["$",Number(S.total).toFixed(2)]}),e.jsx(lt,{children:e.jsx(rt,{className:Y2e[S.status],children:Z5[S.status]})}),e.jsx(lt,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>y(S),children:[e.jsx(xa,{className:"h-4 w-4 mr-1"}),"View"]})})]},S.id)})})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No orders yet."})})]}),e.jsx(_s,{open:l,onOpenChange:i,children:e.jsxs(vs,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsxs(ks,{children:["Order ",a==null?void 0:a.order_number]})}),a&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Customer"}),e.jsx("p",{children:(w=a.user)==null?void 0:w.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(j=a.user)==null?void 0:j.email})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Shipping Address"}),e.jsx("p",{children:a.shipping_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.shipping_address,e.jsx("br",{}),a.shipping_city,", ",a.shipping_state," ",a.shipping_zip]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Order Items"}),e.jsx("div",{className:"space-y-3",children:(k=a.items)==null?void 0:k.map(S=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.product_name}),S.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.variant_name})]}),e.jsxs("p",{className:"font-bold",children:["$",Number(S.unit_price).toFixed(2)," x ",S.quantity]})]}),S.artwork_url&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Customer Artwork:"}),e.jsx("a",{href:S.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Artwork"})]}),e.jsx("div",{className:"mt-3 pt-3 border-t",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Proof Status: "}),e.jsx(rt,{variant:S.proof_status==="approved"?"default":"secondary",children:S.proof_status||"No proof yet"})]}),S.proof_url?e.jsx("a",{href:S.proof_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Proof"}):e.jsxs("div",{children:[e.jsx("input",{type:"file",accept:"image/*,.pdf",onChange:T=>b(T,S.id),className:"hidden",id:`proof-${S.id}`,disabled:p}),e.jsx("label",{htmlFor:`proof-${S.id}`,children:e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("span",{children:[e.jsx(Za,{className:"h-4 w-4 mr-1"}),p?"Uploading...":"Upload Proof"]})})})]})]})})]},S.id))})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Subtotal"}),e.jsxs("span",{children:["$",Number(a.subtotal).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",Number(a.shipping_total).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between font-bold text-lg mt-2",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["$",Number(a.total).toFixed(2)]})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Update Order Status"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Status"}),e.jsxs(sr,{value:d.status,onValueChange:S=>u({...d,status:S}),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:pys.map(S=>e.jsx(At,{value:S,children:Z5[S]},S))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Tracking Number"}),e.jsx(Re,{value:d.trackingNumber,onChange:S=>u({...d,trackingNumber:S.target.value}),placeholder:"Enter tracking number"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Tracking URL"}),e.jsx(Re,{value:d.trackingUrl,onChange:S=>u({...d,trackingUrl:S.target.value}),placeholder:"https://..."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Notes (optional)"}),e.jsx(Ar,{value:d.notes,onChange:S=>u({...d,notes:S.target.value}),placeholder:"Add a note about this status change..."})]}),e.jsxs(K,{onClick:_,disabled:r.isPending,className:"w-full",children:[e.jsx(dl,{className:"h-4 w-4 mr-2"}),"Update Status"]})]})]}),a.status_history&&a.status_history.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Status History"}),e.jsx("div",{className:"space-y-2",children:a.status_history.map(S=>e.jsxs("div",{className:"flex justify-between text-sm p-2 bg-muted rounded",children:[e.jsxs("div",{children:[e.jsx(rt,{variant:"outline",children:Z5[S.status]}),S.notes&&e.jsx("p",{className:"text-muted-foreground mt-1",children:S.notes})]}),e.jsx("span",{className:"text-muted-foreground",children:ys(new Date(S.created_at),"MMM d, h:mm a")})]},S.id))})]})]})]})})]})}function gys(){const[t,s]=C.useState("products"),r=Pr();return e.jsx(Ts,{title:"Marketplace Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Marketplace Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage products, categories, and orders"})]}),e.jsxs(K,{variant:"outline",onClick:()=>r("/marketplace"),children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"View Store"]})]}),e.jsxs(ka,{value:t,onValueChange:s,children:[e.jsxs(_a,{className:"grid w-full grid-cols-3",children:[e.jsxs(js,{value:"products",className:"flex items-center gap-2",children:[e.jsx(dl,{className:"h-4 w-4"}),"Products"]}),e.jsxs(js,{value:"categories",className:"flex items-center gap-2",children:[e.jsx(Vh,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(js,{value:"orders",className:"flex items-center gap-2",children:[e.jsx(Sm,{className:"h-4 w-4"}),"Orders"]})]}),e.jsx(zs,{value:"products",children:e.jsx(mys,{})}),e.jsx(zs,{value:"categories",children:e.jsx(hys,{})}),e.jsx(zs,{value:"orders",children:e.jsx(fys,{})})]})]})})}function det(){return wt({queryKey:["reward-categories"],queryFn:async()=>{const{data:t,error:s}=await G.from("reward_store_categories").select("*").order("sort_order",{ascending:!0});if(s)throw s;return t}})}function xys(t){return wt({queryKey:["reward-items",t],queryFn:async()=>{let s=G.from("reward_store_items").select(` *, category:reward_store_categories(*) `).order("created_at",{ascending:!1});const{data:r,error:n}=await s;if(n)throw n;return r}})}function yys(t){return wt({queryKey:["active-reward-items",t],queryFn:async()=>{let s=G.from("reward_store_items").select(` *, category:reward_store_categories(*) `).eq("is_active",!0).order("created_at",{ascending:!1});t&&(s=s.eq("category_id",t));const{data:r,error:n}=await s;if(n)throw n;return r}})}function vys(t){return wt({queryKey:["user-purchases",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("reward_store_purchases").select(` *, item:reward_store_items(*) `).eq("user_id",t).order("purchased_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function _ys(){return wt({queryKey:["all-reward-purchases"],queryFn:async()=>{const{data:t,error:s}=await G.from("reward_store_purchases").select(` *, item:reward_store_items(*) `).order("purchased_at",{ascending:!1});if(s)throw s;if(!t||t.length===0)return[];const r=[...new Set(t.map(l=>l.user_id))],{data:n,error:a}=await G.from("profiles").select("id, name, email").in("id",r);if(a)throw a;const o=new Map((n==null?void 0:n.map(l=>[l.id,l]))||[]);return t.map(l=>({...l,user:o.get(l.user_id)||null}))}})}function bys(t){return wt({queryKey:["spendable-points",t],queryFn:async()=>{if(!t)return 0;const{data:s,error:r}=await G.from("agent_attendance_stats").select("spendable_points").eq("user_id",t).single();if(r&&r.code!=="PGRST116")throw r;return(s==null?void 0:s.spendable_points)||0},enabled:!!t})}function wys(){const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.rpc("purchase_reward_item",{p_item_id:s});if(n)throw n;const a=r;if(!a.success)throw new Error(a.error||"Purchase failed");return a},onSuccess:()=>{t.invalidateQueries({queryKey:["user-purchases"]}),t.invalidateQueries({queryKey:["spendable-points"]}),t.invalidateQueries({queryKey:["active-reward-items"]}),t.invalidateQueries({queryKey:["reward-items"]})}})}function jys(){const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("reward_store_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function Nys(){const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("reward_store_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function kys(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("reward_store_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function Sys(){const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("reward_store_items").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function Cys(){const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("reward_store_items").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function Mys(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("reward_store_items").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function Tys(t){const s=t.match(/\/storage\/v1\/object\/public\/([^/]+)\/(.+)$/);return s?{bucket:s[1],path:s[2]}:null}async function Bpe(t,s){const r=Tys(t);if(r)try{const{data:n,error:a}=await G.storage.from(r.bucket).download(r.path);if(a){console.error("Error downloading file:",a),fe.error("Failed to download file");return}const o=URL.createObjectURL(n),l=document.createElement("a");l.href=o,l.download=s||r.path.split("/").pop()||"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(o),100)}catch(n){console.error("Download error:",n),fe.error("Failed to download file")}else try{const a=await(await fetch(t)).blob(),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=s||t.split("/").pop()||"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(o),100)}catch(n){console.error("External download error:",n),fe.error("Failed to download file")}}function uet(){return wt({queryKey:["point-reward-settings"],queryFn:async()=>{const{data:t,error:s}=await G.from("point_reward_settings").select("*").order("action_name");if(s)throw s;return t}})}function Ays(){const t=rs();return Dt({mutationFn:async({id:s,points:r,is_active:n})=>{const a={points:r};n!==void 0&&(a.is_active=n);const{data:o,error:l}=await G.from("point_reward_settings").update(a).eq("id",s).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["point-reward-settings"]})}})}function Eys(){const{user:t}=Hs(),[s,r]=C.useState("items"),[n,a]=C.useState(!1),[o,l]=C.useState(null),[i,d]=C.useState(""),[u,p]=C.useState(""),[f,y]=C.useState(""),[_,b]=C.useState(null),[w,j]=C.useState(!1),[k,S]=C.useState(null),[T,I]=C.useState(""),[L,R]=C.useState(""),[$,q]=C.useState(null),[U,H]=C.useState(""),[Y,se]=C.useState("file"),[te,Q]=C.useState(""),[de,re]=C.useState(""),[ae,le]=C.useState(""),[he,be]=C.useState(!0),[_e,je]=C.useState(null),[Ne,Ge]=C.useState(!1),[we,Me]=C.useState(!1),Te=C.useRef(null),Fe=C.useRef(null),{data:Ae,isLoading:Ue}=det(),{data:ut,isLoading:De}=xys(),{data:Rt,isLoading:me}=_ys(),{data:Xe,isLoading:ot}=uet(),nt=jys(),Se=Nys(),it=kys(),$e=Sys(),ct=Cys(),qe=Mys(),Ze=Ays(),[Qe,We]=C.useState({}),He=Ct=>{Ct?(l(Ct),d(Ct.name),p(Ct.description||""),y(Ct.icon||"")):(l(null),d(""),p(""),y("")),a(!0)},et=async()=>{if(!i.trim()){fe.error("Please enter a category name");return}try{o?(await Se.mutateAsync({id:o.id,name:i,description:u||null,icon:f||null}),fe.success("Category updated successfully")):(await nt.mutateAsync({name:i,description:u||null,icon:f||null,sort_order:((Ae==null?void 0:Ae.length)||0)+1}),fe.success("Category created successfully")),a(!1)}catch(Ct){console.error("Error saving category:",Ct),fe.error("Failed to save category")}},Tt=async()=>{if(_)try{await it.mutateAsync(_),fe.success("Category deleted successfully"),b(null)}catch(Ct){console.error("Error deleting category:",Ct),fe.error("Failed to delete category")}},Ft=Ct=>{var Is;Ct?(S(Ct),I(Ct.name),R(Ct.description||""),q(Ct.category_id),H(Ct.points_cost.toString()),se(Ct.item_type),Q(Ct.file_url||""),re(Ct.preview_image_url||""),le(((Is=Ct.max_quantity)==null?void 0:Is.toString())||""),be(Ct.is_active)):(S(null),I(""),R(""),q(null),H(""),se("file"),Q(""),re(""),le(""),be(!0)),j(!0)},as=async(Ct,Is)=>{Is==="file"?Ge(!0):Me(!0);try{const qs=Ct.name.split(".").pop(),gr=`${Date.now()}-${Math.random().toString(36).substring(7)}.${qs}`,Wn=`${Is==="file"?"items":"previews"}/${gr}`,{error:ii}=await G.storage.from("reward-store").upload(Wn,Ct);if(ii)throw ii;const{data:{publicUrl:bo}}=G.storage.from("reward-store").getPublicUrl(Wn);Is==="file"?Q(bo):re(bo),fe.success("File uploaded successfully")}catch(qs){console.error("Error uploading file:",qs),fe.error("Failed to upload file")}finally{Is==="file"?Ge(!1):Me(!1)}},Xt=async()=>{if(!T.trim()){fe.error("Please enter an item name");return}if(!U||parseInt(U)<0){fe.error("Please enter a valid points cost");return}try{const Ct={name:T,description:L||null,category_id:$,points_cost:parseInt(U),item_type:Y,file_url:te||null,preview_image_url:de||null,max_quantity:ae?parseInt(ae):null,current_quantity:ae?parseInt(ae):null,is_active:he,created_by:t==null?void 0:t.id};k?(await ct.mutateAsync({id:k.id,...Ct,current_quantity:k.max_quantity!==(ae?parseInt(ae):null)?ae?parseInt(ae):null:k.current_quantity}),fe.success("Item updated successfully")):(await $e.mutateAsync(Ct),fe.success("Item created successfully")),j(!1)}catch(Ct){console.error("Error saving item:",Ct),fe.error("Failed to save item")}},ss=async()=>{if(_e)try{await qe.mutateAsync(_e),fe.success("Item deleted successfully"),je(null)}catch(Ct){console.error("Error deleting item:",Ct),fe.error("Failed to delete item")}},is=async(Ct,Is)=>{const qs=Qe[Ct];if(qs===void 0||qs===Is.toString())return;const gr=parseInt(qs);if(isNaN(gr)||gr<0){fe.error("Please enter a valid positive number");return}try{await Ze.mutateAsync({id:Ct,points:gr}),fe.success("Points updated successfully"),We(Wn=>{const ii={...Wn};return delete ii[Ct],ii})}catch(Wn){console.error("Error updating points:",Wn),fe.error("Failed to update points")}};return Ue||De||me||ot?e.jsx(Ts,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{className:"h-8 w-64"}),e.jsx(xs,{className:"h-96"})]})}):e.jsxs(Ts,{title:"Reward Store",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Reward Store Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage store items that agents can purchase with their points"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(dl,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Items"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(ut==null?void 0:ut.length)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(ut==null?void 0:ut.filter(Ct=>Ct.is_active).length)||0," active"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Vh,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Categories"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(Ae==null?void 0:Ae.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Gn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg. Cost"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[ut&&ut.length>0?Math.round(ut.reduce((Ct,Is)=>Ct+Is.points_cost,0)/ut.length):0," pts"]})]})})]}),e.jsxs(ka,{value:s,onValueChange:r,children:[e.jsxs(_a,{children:[e.jsx(js,{value:"items",children:"Items"}),e.jsx(js,{value:"categories",children:"Categories"}),e.jsx(js,{value:"purchases",children:"Purchases"}),e.jsx(js,{value:"point-settings",children:"Point Settings"})]}),e.jsx(zs,{value:"items",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Store Items"}),e.jsx(pr,{children:"Manage rewards that agents can purchase"})]}),e.jsxs(K,{onClick:()=>Ft(),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Item"]})]}),e.jsx(Oe,{children:!ut||ut.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(po,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No items yet. Add your first reward item!"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Item"}),e.jsx(bt,{children:"Category"}),e.jsx(bt,{className:"text-center",children:"Cost"}),e.jsx(bt,{className:"text-center",children:"Type"}),e.jsx(bt,{className:"text-center",children:"Quantity"}),e.jsx(bt,{className:"text-center",children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:ut.map(Ct=>e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Ct.preview_image_url?e.jsx("img",{src:Ct.preview_image_url,alt:Ct.name,className:"h-10 w-10 rounded object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded bg-muted flex items-center justify-center",children:e.jsx(po,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:Ct.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:Ct.description||"No description"})]})]})}),e.jsx(lt,{children:Ct.category?e.jsx(rt,{variant:"outline",children:Ct.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(lt,{className:"text-center",children:e.jsxs(rt,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),Ct.points_cost]})}),e.jsx(lt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[Ct.item_type==="file"?e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Do,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs capitalize",children:Ct.item_type})]})}),e.jsx(lt,{className:"text-center",children:Ct.max_quantity!==null?e.jsxs("span",{className:Ct.current_quantity===0?"text-red-500":"",children:[Ct.current_quantity,"/",Ct.max_quantity]}):e.jsx("span",{className:"text-muted-foreground",children:"Unlimited"})}),e.jsx(lt,{className:"text-center",children:e.jsx(rt,{variant:Ct.is_active?"default":"secondary",children:Ct.is_active?"Active":"Inactive"})}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Ft(Ct),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>je(Ct.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},Ct.id))})]})})]})}),e.jsx(zs,{value:"categories",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Categories"}),e.jsx(pr,{children:"Organize your store items into categories"})]}),e.jsxs(K,{onClick:()=>He(),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Oe,{children:!Ae||Ae.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Vh,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No categories yet. Add your first category!"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{className:"text-center",children:"Items"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:Ae.map(Ct=>e.jsxs(Ns,{children:[e.jsxs(lt,{className:"font-medium",children:[Ct.icon&&e.jsx("span",{className:"mr-2",children:Ct.icon}),Ct.name]}),e.jsx(lt,{className:"text-muted-foreground",children:Ct.description||"—"}),e.jsx(lt,{className:"text-center",children:(ut==null?void 0:ut.filter(Is=>Is.category_id===Ct.id).length)||0}),e.jsx(lt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>He(Ct),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(Ct.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},Ct.id))})]})})]})}),e.jsx(zs,{value:"purchases",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Sm,{className:"h-5 w-5"}),"Purchase History"]}),e.jsx(pr,{children:"View all reward redemptions by agents"})]}),e.jsx(Oe,{children:!Rt||Rt.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Sm,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No purchases yet."})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Date"}),e.jsx(bt,{children:"Agent"}),e.jsx(bt,{children:"Item"}),e.jsx(bt,{className:"text-center",children:"Points Spent"})]})}),e.jsx(Pn,{children:Rt.map(Ct=>{var Is,qs,gr,Wn;return e.jsxs(Ns,{children:[e.jsx(lt,{className:"text-muted-foreground",children:ys(new Date(Ct.purchased_at),"MMM d, yyyy 'at' h:mm a")}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(Yi,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Is=Ct.user)==null?void 0:Is.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:((qs=Ct.user)==null?void 0:qs.email)||"—"})]})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(gr=Ct.item)!=null&&gr.preview_image_url?e.jsx("img",{src:Ct.item.preview_image_url,alt:Ct.item.name,className:"h-8 w-8 rounded object-cover"}):e.jsx("div",{className:"h-8 w-8 rounded bg-muted flex items-center justify-center",children:e.jsx(po,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{children:((Wn=Ct.item)==null?void 0:Wn.name)||"Deleted item"})]})}),e.jsx(lt,{className:"text-center",children:e.jsxs(rt,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),Ct.points_spent]})})]},Ct.id)})})]})})]})})]})]}),e.jsx(_s,{open:n,onOpenChange:a,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:o?"Edit Category":"Add Category"}),e.jsx(Kr,{children:o?"Update the category details":"Create a new category for your store items"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"categoryName",children:"Name"}),e.jsx(Re,{id:"categoryName",value:i,onChange:Ct=>d(Ct.target.value),placeholder:"e.g., Templates, Resources"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"categoryDescription",children:"Description"}),e.jsx(Ar,{id:"categoryDescription",value:u,onChange:Ct=>p(Ct.target.value),placeholder:"Optional description..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"categoryIcon",children:"Icon (emoji)"}),e.jsx(Re,{id:"categoryIcon",value:f,onChange:Ct=>y(Ct.target.value),placeholder:"e.g., 📄, 🎁"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{onClick:et,disabled:nt.isPending||Se.isPending,children:nt.isPending||Se.isPending?"Saving...":"Save"})]})]})}),e.jsx(_s,{open:w,onOpenChange:j,children:e.jsxs(vs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:k?"Edit Item":"Add Item"}),e.jsx(Kr,{children:k?"Update the item details":"Create a new reward item for agents to purchase"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"itemName",children:"Name *"}),e.jsx(Re,{id:"itemName",value:T,onChange:Ct=>I(Ct.target.value),placeholder:"e.g., Premium Template Pack"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"itemDescription",children:"Description"}),e.jsx(Ar,{id:"itemDescription",value:L,onChange:Ct=>R(Ct.target.value),placeholder:"Describe the item..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"itemCategory",children:"Category"}),e.jsxs(sr,{value:$||"none",onValueChange:Ct=>q(Ct==="none"?null:Ct),children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select category"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"none",children:"No category"}),Ae==null?void 0:Ae.map(Ct=>e.jsxs(At,{value:Ct.id,children:[Ct.icon&&`${Ct.icon} `,Ct.name]},Ct.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"itemPointsCost",children:"Points Cost *"}),e.jsx(Re,{id:"itemPointsCost",type:"number",min:"0",value:U,onChange:Ct=>H(Ct.target.value),placeholder:"e.g., 100"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"itemType",children:"Type"}),e.jsxs(sr,{value:Y,onValueChange:se,children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"file",children:"File Download"}),e.jsx(At,{value:"link",children:"External Link"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"itemMaxQuantity",children:"Max Quantity"}),e.jsx(Re,{id:"itemMaxQuantity",type:"number",min:"1",value:ae,onChange:Ct=>le(Ct.target.value),placeholder:"Leave empty for unlimited"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"File / Link URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:te,onChange:Ct=>Q(Ct.target.value),placeholder:Y==="file"?"Upload a file or paste URL":"Paste external link"}),Y==="file"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var Ct;return(Ct=Te.current)==null?void 0:Ct.click()},disabled:Ne,children:e.jsx(Za,{className:"h-4 w-4"})}),e.jsx("input",{ref:Te,type:"file",className:"hidden",onChange:Ct=>{var qs;const Is=(qs=Ct.target.files)==null?void 0:qs[0];Is&&as(Is,"file")}})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Preview Image"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:de,onChange:Ct=>re(Ct.target.value),placeholder:"Upload an image or paste URL"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var Ct;return(Ct=Fe.current)==null?void 0:Ct.click()},disabled:we,children:e.jsx(Jo,{className:"h-4 w-4"})}),e.jsx("input",{ref:Fe,type:"file",accept:"image/*",className:"hidden",onChange:Ct=>{var qs;const Is=(qs=Ct.target.files)==null?void 0:qs[0];Is&&as(Is,"preview")}})]}),de&&e.jsx("img",{src:de,alt:"Preview",className:"mt-2 h-24 rounded object-cover"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"itemIsActive",checked:he,onCheckedChange:be}),e.jsx(ve,{htmlFor:"itemIsActive",children:"Active (visible to agents)"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),e.jsx(K,{onClick:Xt,disabled:$e.isPending||ct.isPending,children:$e.isPending||ct.isPending?"Saving...":"Save"})]})]})}),e.jsx(nc,{open:!!_,onOpenChange:()=>b(null),children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete Category"}),e.jsx(Dl,{children:"Are you sure you want to delete this category? Items in this category will become uncategorized."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:Tt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(nc,{open:!!_e,onOpenChange:()=>je(null),children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete Item"}),e.jsx(Dl,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:ss,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s==="point-settings"&&e.jsxs(Ee,{className:"mt-4",children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($l,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx(Ot,{children:"Point Reward Settings"}),e.jsx(pr,{children:"Configure how many points agents earn for various actions. Adjust these values to run double-points promotions."})]})]})}),e.jsx(Oe,{children:!Xe||Xe.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx($l,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No point settings configured."})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Action"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{className:"text-center w-32",children:"Points"}),e.jsx(bt,{className:"text-right w-24",children:"Save"})]})}),e.jsx(Pn,{children:Xe.map(Ct=>e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsx("p",{className:"font-medium",children:Ct.action_name})}),e.jsx(lt,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:Ct.description})}),e.jsx(lt,{className:"text-center",children:e.jsx(Re,{type:"number",min:"0",className:"w-20 mx-auto text-center",value:Qe[Ct.id]??Ct.points.toString(),onChange:Is=>We(qs=>({...qs,[Ct.id]:Is.target.value}))})}),e.jsx(lt,{className:"text-right",children:e.jsx(K,{size:"sm",variant:"outline",disabled:Qe[Ct.id]===void 0||Qe[Ct.id]===Ct.points.toString()||Ze.isPending,onClick:()=>is(Ct.id,Ct.points),children:e.jsx(fu,{className:"h-4 w-4"})})})]},Ct.id))})]})})]})]})}const QLe=()=>e.jsxs("svg",{viewBox:"0 0 100 100",className:"h-5 w-5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{width:"100",height:"100",rx:"20",fill:"#7D2AE8"}),e.jsx("path",{d:"M50 20C33.43 20 20 33.43 20 50C20 66.57 33.43 80 50 80C66.57 80 80 66.57 80 50C80 33.43 66.57 20 50 20ZM63.5 63.5C58.3 68.7 50 70.6 43.1 67.6C36.2 64.6 32 57.6 32 50C32 42.4 36.2 35.4 43.1 32.4C50 29.4 58.3 31.3 63.5 36.5L59.3 40.7C55.8 37.2 50.7 35.8 46 37.3C41.3 38.8 37.7 42.8 36.6 47.6C35.5 52.4 37 57.4 40.4 60.8C43.8 64.2 48.8 65.7 53.6 64.6C58.4 63.5 62.4 59.9 63.9 55.2L68.7 56.7C66.9 61.3 65.5 61.5 63.5 63.5Z",fill:"white"})]}),JLe=[{value:"template",label:"Templates"},{value:"brand",label:"Brand Assets"},{value:"listing",label:"Listing Assets"},{value:"social",label:"Social Media"},{value:"general",label:"General"}];function Pys(){const t=rs(),[s,r]=C.useState(!1),[n,a]=C.useState(!1),[o,l]=C.useState(!1),[i,d]=C.useState({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""}),{data:u,isLoading:p}=wt({queryKey:["canva-integration"],queryFn:async()=>{const{data:S,error:T}=await G.from("canva_integration").select("*").eq("is_active",!0).maybeSingle();if(T)throw T;return S}}),{data:f}=wt({queryKey:["brokerages-list"],queryFn:async()=>{const{data:S,error:T}=await G.from("brokerages").select("id, name").order("name");if(T)throw T;return S}}),{data:y}=wt({queryKey:["canva-brokerage-folders"],queryFn:async()=>{const{data:S,error:T}=await G.from("canva_brokerage_folders").select("*, brokerages(name)").order("sort_order");if(T)throw T;return S}}),_=async()=>{var S;r(!0);try{const{data:T}=await G.auth.getSession(),I=(S=T==null?void 0:T.session)==null?void 0:S.access_token;if(!I)throw new Error("Not authenticated");const $=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"get_auth_url"})}),q=await $.json();if(!$.ok||q!=null&&q.error)throw new Error((q==null?void 0:q.error)||"Failed to get authorization URL");if(q!=null&&q.authUrl){localStorage.setItem("canva_code_verifier",q.codeVerifier),localStorage.setItem("canva_oauth_state",q.state);const U=window.open(q.authUrl,"canva-oauth","width=600,height=700,scrollbars=yes,resizable=yes");if(!U){fe.error("Popup was blocked. Please allow popups for this site and try again."),r(!1);return}const H=se=>{var te,Q;se.origin===window.location.origin&&(((te=se.data)==null?void 0:te.type)==="canva-oauth-success"?(window.removeEventListener("message",H),fe.success("Canva connected successfully!"),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1)):((Q=se.data)==null?void 0:Q.type)==="canva-oauth-error"&&(window.removeEventListener("message",H),fe.error("Canva connection failed: "+(se.data.error||"Unknown error")),r(!1)))};window.addEventListener("message",H);const Y=setInterval(()=>{U.closed&&(clearInterval(Y),window.removeEventListener("message",H),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1))},500)}else throw new Error("Failed to get authorization URL")}catch(T){console.error("Canva connect error:",T);const I=(T==null?void 0:T.message)||"";I.includes("CANVA_CLIENT_ID")?fe.error("Canva app credentials not configured yet."):fe.error(I||"Failed to start Canva connection"),r(!1)}},b=Dt({mutationFn:async S=>{var U;const{data:T}=await G.auth.getSession(),I=(U=T==null?void 0:T.session)==null?void 0:U.access_token;if(!I)throw new Error("Not authenticated");const $=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"disconnect",integrationId:S})}),q=await $.json();if(!$.ok||q!=null&&q.error)throw new Error((q==null?void 0:q.error)||"Failed to disconnect")},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-integration"]}),fe.success("Canva disconnected")},onError:S=>{fe.error(S.message||"Failed to disconnect Canva")}}),w=Dt({mutationFn:async S=>{const{error:T}=await G.from("canva_brokerage_folders").insert({brokerage_id:S.brokerage_id,folder_id:S.folder_id.trim(),folder_name:S.folder_name.trim(),folder_type:S.folder_type,description:S.description.trim()||null,sort_order:(y==null?void 0:y.length)||0});if(T)throw T},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),fe.success("Folder added"),l(!1),d({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""})},onError:()=>fe.error("Failed to add folder")}),j=Dt({mutationFn:async S=>{const{error:T}=await G.from("canva_brokerage_folders").delete().eq("id",S);if(T)throw T},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),fe.success("Folder removed")},onError:()=>fe.error("Failed to remove folder")}),k=!!u;return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-accent flex items-center justify-center",children:e.jsx(QLe,{})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["Canva Connect",k&&e.jsx(rt,{variant:"default",className:"text-xs",children:"Connected"}),e.jsx(rt,{variant:"outline",className:"text-xs",children:"Admin Only"})]}),e.jsx(pr,{children:"Auto-share brokerage asset folders with agents when they connect their Canva accounts."})]})]})})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(hi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"OAuth 2.0 + PKCE for secure authorization"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(hi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"Map brokerage folders to auto-share with agents on connection"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(hi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"Multiple folders per brokerage (templates, brand assets, listings)"})]}),e.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-muted border border-dashed",children:[e.jsx("p",{className:"text-xs font-medium text-foreground mb-1",children:"Canva App Redirect URL"}),e.jsx("code",{className:"text-xs text-muted-foreground break-all select-all",children:"https://dashboard.relevelup.com/canva-callback.html"})]}),k?e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:u.canva_team_id?`Team: ${u.canva_team_id}`:"Canva Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u.expires_at?`Token expires ${new Date(u.expires_at).toLocaleDateString()}`:"Platform integration active"})]}),e.jsxs(nc,{children:[e.jsx(Rh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect Canva?"}),e.jsx(Dl,{children:"This will remove the Canva platform integration. Agents who have already connected will not be affected, but new folder sharing will stop."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>b.mutate(u.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}),e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-center justify-between p-3 text-sm font-medium hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vh,{className:"h-4 w-4 text-primary"}),"Brokerage Folder Mappings",y&&y.length>0&&e.jsx(rt,{variant:"secondary",className:"text-xs",children:y.length})]}),n?e.jsx(Ug,{className:"h-4 w-4"}):e.jsx(Ho,{className:"h-4 w-4"})]}),n&&e.jsxs("div",{className:"border-t p-3 space-y-2",children:[y&&y.length>0?y.map(S=>{var T,I;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md bg-muted/50 text-sm",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",children:S.folder_name}),e.jsx(rt,{variant:"outline",className:"text-xs shrink-0",children:((T=JLe.find(L=>L.value===S.folder_type))==null?void 0:T.label)||S.folder_type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(I=S.brokerages)==null?void 0:I.name," · ID: ",e.jsx("span",{className:"font-mono",children:S.folder_id})]})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive shrink-0 ml-2",onClick:()=>j.mutate(S.id),children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]},S.id)}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"No folders mapped yet"}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full gap-1.5 mt-1",onClick:()=>l(!0),children:[e.jsx(Zs,{className:"h-3.5 w-3.5"}),"Add Folder Mapping"]})]})]})]}):e.jsxs(K,{className:"mt-4",onClick:_,disabled:s||p,children:[s?e.jsx(Po,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx("div",{className:"mr-2",children:e.jsx(QLe,{})}),"Connect Canva",e.jsx($i,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Add Brokerage Folder Mapping"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Brokerage"}),e.jsxs(sr,{value:i.brokerage_id,onValueChange:S=>d(T=>({...T,brokerage_id:S})),children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select a brokerage…"})}),e.jsx(tr,{children:f==null?void 0:f.map(S=>e.jsx(At,{value:S.id,children:S.name},S.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Canva Folder ID"}),e.jsx(Re,{placeholder:"e.g. FABCdef123456",value:i.folder_id,onChange:S=>d(T=>({...T,folder_id:S.target.value}))}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Found in the Canva folder URL: canva.com/folder/",e.jsx("strong",{children:"FOLDER_ID"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Folder Display Name"}),e.jsx(Re,{placeholder:"e.g. Brand Templates 2024",value:i.folder_name,onChange:S=>d(T=>({...T,folder_name:S.target.value}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Folder Type"}),e.jsxs(sr,{value:i.folder_type,onValueChange:S=>d(T=>({...T,folder_type:S})),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:JLe.map(S=>e.jsx(At,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(ve,{children:["Description ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx(Re,{placeholder:"What's in this folder?",value:i.description,onChange:S=>d(T=>({...T,description:S.target.value}))})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>w.mutate(i),disabled:!i.brokerage_id||!i.folder_id||!i.folder_name||w.isPending,children:[w.isPending?e.jsx(Po,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Add Folder"]})]})]})})]})}function Iys(){return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(wu,{title:"Integrations",description:"Manage platform-level service connections"}),e.jsx(Pys,{}),e.jsx(aet,{})]})})}const Lys={new_events:{label:"New Events",icon:"📅"},new_templates:{label:"New Templates",icon:"📄"},new_toolbox:{label:"New Toolbox Resources",icon:"🧰"},new_social_swag:{label:"New Social Swag",icon:"🎨"},new_newsletters:{label:"New Newsletters",icon:"📰"},new_community_posts:{label:"New Community Posts",icon:"💬"}};function SE(t,s=18,r=10){return t.length<=s+r+3?t:`${t.slice(0,s)}…${t.slice(-r)}`}function Dys(){var Y,se,te,Q,de;const t=rs(),[s,r]=C.useState("Test Push"),[n,a]=C.useState("Testing web push notification"),[o,l]=C.useState("/community"),[i,d]=C.useState(!1),[u,p]=C.useState(!1),[f,y]=C.useState({isSupported:typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window}),[_,b]=C.useState(null),[w,j]=C.useState(null),{data:k,isLoading:S}=wt({queryKey:["push-notification-settings"],queryFn:async()=>{const{data:re,error:ae}=await G.from("push_notification_settings").select("*").order("setting_key");if(ae)throw ae;return re}}),{data:T,isLoading:I}=wt({queryKey:["push-subscription-stats"],queryFn:async()=>{const{count:re,error:ae}=await G.from("push_subscriptions").select("*",{count:"exact",head:!0});if(ae)throw ae;return{totalSubscriptions:re||0}}}),L=Dt({mutationFn:async({settingKey:re,isEnabled:ae})=>{const{error:le}=await G.from("push_notification_settings").update({is_enabled:ae}).eq("setting_key",re);if(le)throw le},onSuccess:()=>{t.invalidateQueries({queryKey:["push-notification-settings"]}),fe.success("Notification setting updated")},onError:re=>{fe.error("Failed to update setting: "+re.message)}}),R=C.useMemo(()=>{var re,ae;return f.isSupported?`perm=${f.permission??"unknown"} · controller=${f.controllerPresent?"yes":"no"} · sw=${((re=f.serviceWorker)==null?void 0:re.activeState)??"unknown"} · sub=${(ae=f.subscription)!=null&&ae.endpoint?"yes":"no"}`:"Push not supported in this browser."},[f]);C.useEffect(()=>{let re=!0;const ae=async()=>{var _e,je,Ne,Ge,we,Me,Te;const he="serviceWorker"in navigator&&"PushManager"in window,be={isSupported:he,permission:typeof Notification<"u"?Notification.permission:void 0,controllerPresent:!!((_e=navigator.serviceWorker)!=null&&_e.controller)};if(!he){re&&y(be);return}try{const{data:Fe,error:Ae}=await G.functions.invoke("get-vapid-public-key",{body:{}});if(Ae)throw Ae;be.vapidPublicKey=Fe==null?void 0:Fe.vapidPublicKey;const ut=(await navigator.serviceWorker.getRegistrations()).find(De=>{var me,Xe,ot;return(((me=De.active)==null?void 0:me.scriptURL)||((Xe=De.waiting)==null?void 0:Xe.scriptURL)||((ot=De.installing)==null?void 0:ot.scriptURL)||"").includes("/sw.js")});if(ut){be.pushWorkerScriptUrl=((je=ut.active)==null?void 0:je.scriptURL)||((Ne=ut.waiting)==null?void 0:Ne.scriptURL)||((Ge=ut.installing)==null?void 0:Ge.scriptURL),be.serviceWorker={scope:ut.scope,activeState:(we=ut.active)==null?void 0:we.state};const De=await ut.pushManager.getSubscription();if(De){const Rt=De.toJSON();be.subscription={endpoint:Rt.endpoint,p256dh:(Me=Rt.keys)==null?void 0:Me.p256dh,auth:(Te=Rt.keys)==null?void 0:Te.auth}}}}catch(Fe){be.error=(Fe==null?void 0:Fe.message)||String(Fe)}re&&y(be)};ae();const le=window.setInterval(ae,4e3);return()=>{re=!1,window.clearInterval(le)}},[]);const $=async()=>{if(typeof Notification>"u"){fe.error("Notifications API not available in this browser.");return}try{if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted"){fe.error("Notification permission not granted.");return}new Notification("Local notification test",{body:"If you see this, OS/browser notifications can display."}),fe.success("Triggered a local notification (not push).")}catch(re){fe.error(`Local notification failed: ${(re==null?void 0:re.message)||String(re)}`)}},q=async()=>{d(!0),b(null);try{const{data:re,error:ae}=await G.functions.invoke("send-push-notification",{body:{title:s,body:n,url:o}});if(ae)throw ae;b({sent:re==null?void 0:re.sent,failed:re==null?void 0:re.failed,expiredCleaned:re==null?void 0:re.expiredCleaned,vapidPublicKey:re==null?void 0:re.vapidPublicKey}),(re==null?void 0:re.sent)>0?fe.success(`Test notification sent to ${re.sent} subscriber(s)`):(re==null?void 0:re.failed)>0?fe.warning(`Notification failed for ${re.failed} subscriber(s). ${re.expired||0} expired subscriptions cleaned up.`):fe.info("No active subscriptions to send to")}catch(re){console.error("Error sending test notification:",re),b({error:(re==null?void 0:re.message)||String(re)}),fe.error("Failed to send test notification: "+(re.message||"Unknown error"))}finally{d(!1)}},U=async()=>{p(!0),j(null);try{const{data:re,error:ae}=await G.functions.invoke("generate-vapid-keys",{body:{}});if(ae)throw ae;const le=re==null?void 0:re.publicKey,he=re==null?void 0:re.privateKey;if(!le||!he)throw new Error("generate-vapid-keys did not return keys");j({publicKey:le,privateKey:he}),fe.success("Generated new VAPID keys. Update backend secrets, then clear + re-subscribe.")}catch(re){console.error("Error generating VAPID keys:",re),fe.error("Failed to generate VAPID keys: "+((re==null?void 0:re.message)||"Unknown error"))}finally{p(!1)}},H=Dt({mutationFn:async()=>{const{error:re}=await G.from("push_subscriptions").delete().neq("id","00000000-0000-0000-0000-000000000000");if(re)throw re},onSuccess:()=>{fe.success("All subscriptions cleared. Users will need to re-enable notifications."),t.invalidateQueries({queryKey:["push-subscription-stats"]})},onError:re=>{fe.error("Failed to clear subscriptions: "+re.message)}});return e.jsx(Ts,{title:"Notification Settings",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(wu,{title:"Notification Settings",description:"Manage push notifications and test the notification system"}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Push Notification Subscribers"]}),e.jsx(pr,{children:"Current active push notification subscriptions"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"text-4xl font-bold",children:I?"...":(T==null?void 0:T.totalSubscriptions)||0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"active subscriptions"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx($l,{className:"h-5 w-5"}),"Notification Types"]}),e.jsx(pr,{children:"Control which types of push notifications are sent to users"})]}),e.jsx(Oe,{children:S?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading settings..."}):e.jsx("div",{className:"space-y-4",children:k==null?void 0:k.map(re=>{const ae=Lys[re.setting_key]||{label:re.setting_key,icon:"🔔"};return e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:ae.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ae.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:re.description})]})]}),e.jsx(Br,{checked:re.is_enabled,onCheckedChange:le=>L.mutate({settingKey:re.setting_key,isEnabled:le}),disabled:L.isPending})]},re.id)})})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(gf,{className:"h-5 w-5"}),"Send Test Notification"]}),e.jsx(pr,{children:"Send a test push notification to all subscribed users"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"Client push debug"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:R}),f.error&&e.jsx("div",{className:"mt-2 text-destructive",children:f.error}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Backend VAPID public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:f.vapidPublicKey?SE(f.vapidPublicKey):"(not loaded)"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Service worker"}),e.jsxs("div",{className:"rounded-md border bg-background p-2 font-mono text-xs",children:[e.jsxs("div",{children:["scope: ",(Y=f.serviceWorker)!=null&&Y.scope?SE(f.serviceWorker.scope,24,8):"none"]}),e.jsxs("div",{children:["active: ",((se=f.serviceWorker)==null?void 0:se.activeState)??"none"]})]})]}),e.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Current browser subscription"}),e.jsxs("div",{className:"rounded-md border bg-background p-2 font-mono text-xs",children:[e.jsxs("div",{children:["endpoint: ",(te=f.subscription)!=null&&te.endpoint?SE(f.subscription.endpoint,40,12):"none"]}),e.jsxs("div",{children:["p256dh: ",(Q=f.subscription)!=null&&Q.p256dh?SE(f.subscription.p256dh,22,10):"none"]}),e.jsxs("div",{children:["auth: ",(de=f.subscription)!=null&&de.auth?SE(f.subscription.auth,22,10):"none"]})]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(K,{variant:"outline",onClick:$,children:"Local notification test"}),e.jsx(K,{variant:"outline",onClick:()=>window.location.reload(),children:"Reload page"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"test-title",children:"Notification Title"}),e.jsx(Re,{id:"test-title",value:s,onChange:re=>r(re.target.value),placeholder:"Enter notification title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"test-body",children:"Notification Body"}),e.jsx(Ar,{id:"test-body",value:n,onChange:re=>a(re.target.value),placeholder:"Enter notification message",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"test-url",children:"Click URL (optional)"}),e.jsx(Re,{id:"test-url",value:o,onChange:re=>l(re.target.value),placeholder:"/community or full URL"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Where users will be taken when they click the notification"})]}),e.jsxs(K,{onClick:q,disabled:i||!s||!n,className:"w-full sm:w-auto",children:[e.jsx(aa,{className:"h-4 w-4 mr-2"}),i?"Sending...":"Send Test Notification"]}),_&&e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"Last send debug"}),_.error?e.jsxs("div",{className:"mt-1 text-destructive",children:["Error: ",_.error]}):e.jsxs("div",{className:"mt-1 space-y-1 text-muted-foreground",children:[e.jsxs("div",{children:["Result: ",_.sent??0," sent, ",_.failed??0," failed, ",_.expiredCleaned??0," expired cleaned"]}),_.vapidPublicKey?e.jsxs("div",{className:"break-all",children:["Backend VAPID public key: ",e.jsx("span",{className:"font-mono",children:_.vapidPublicKey})]}):e.jsx("div",{children:"Backend VAPID public key: (not returned)"})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(jr,{className:"h-5 w-5"}),"Subscription Maintenance"]}),e.jsx(pr,{children:"Clear all push subscriptions if VAPID keys were changed or subscriptions are invalid"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"If you've recently updated the VAPID keys, existing subscriptions will no longer work. Use this to clear all subscriptions so users can re-subscribe with the new keys."}),e.jsxs(K,{variant:"destructive",onClick:()=>H.mutate(),disabled:H.isPending,children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),H.isPending?"Clearing...":"Clear All Subscriptions"]}),e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"VAPID key rotation helper"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:"If you suspect the backend public/private keys don’t match, generate a fresh pair, update backend secrets, then clear subscriptions and have users re-enable push."}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:e.jsx(K,{variant:"outline",onClick:U,disabled:u,children:u?"Generating…":"Generate VAPID keys"})}),w&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"text-muted-foreground",children:["Copy these into backend secrets ",e.jsx("span",{className:"font-mono",children:"VAPID_PUBLIC_KEY"})," and ",e.jsx("span",{className:"font-mono",children:"VAPID_PRIVATE_KEY"}),"."]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:w.publicKey})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Private key (keep secret)"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:w.privateKey})]})]})]})]})]})]})})}function Oys(){const{toast:t}=Pa(),[s,r]=C.useState([]),[n,a]=C.useState({totalPresentations:0,totalViews:0,totalLeads:0,totalCtaClicks:0,agentsUsing:0}),[o,l]=C.useState(!0),{sortKey:i,sortDirection:d,handleSort:u,sortData:p}=JL("presentation_count","desc"),f=p(s,{name:b=>{var w;return((w=b.name)==null?void 0:w.toLowerCase())||""},presentations:b=>b.presentation_count,views:b=>b.total_views,leads:b=>b.total_leads,cta_clicks:b=>b.total_cta_clicks,conversion:b=>b.total_views>0?b.total_leads/b.total_views*100:0});C.useEffect(()=>{y()},[]);const y=async()=>{try{l(!0);const{data:b,error:w}=await G.rpc("get_admin_presentation_stats");if(w)throw w;if(!b||b.length===0){l(!1);return}const j=b.map(L=>L.owner_user_id),{data:k,error:S}=await G.from("profiles").select("id, name, email, avatar_url").in("id",j);if(S)throw S;const T=new Map((k==null?void 0:k.map(L=>[L.id,L]))||[]),I=b.map(L=>{const R=T.get(L.owner_user_id);return{owner_user_id:L.owner_user_id,name:(R==null?void 0:R.name)||"Unknown",email:(R==null?void 0:R.email)||"",avatar_url:(R==null?void 0:R.avatar_url)||null,presentation_count:Number(L.presentation_count),total_views:Number(L.total_views),total_leads:Number(L.total_leads),total_cta_clicks:Number(L.total_cta_clicks)}});r(I),r(I),a({totalPresentations:I.reduce((L,R)=>L+R.presentation_count,0),totalViews:I.reduce((L,R)=>L+R.total_views,0),totalLeads:I.reduce((L,R)=>L+R.total_leads,0),totalCtaClicks:I.reduce((L,R)=>L+R.total_cta_clicks,0),agentsUsing:I.length})}catch(b){console.error("Error loading presentation stats:",b),t({title:"Error",description:"Failed to load presentation analytics",variant:"destructive"})}finally{l(!1)}},_=[{label:"Agents Using",value:n.agentsUsing,icon:hr,color:"text-blue-600"},{label:"Total Presentations",value:n.totalPresentations,icon:Hg,color:"text-violet-600"},{label:"Total Views",value:n.totalViews,icon:xa,color:"text-emerald-600"},{label:"Total Leads",value:n.totalLeads,icon:yc,color:"text-amber-600"},{label:"CTA Clicks",value:n.totalCtaClicks,icon:c_,color:"text-rose-600"}];return e.jsx(Ts,{title:"Presentation Analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Presentation Analytics"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Track Smart Presentations usage and engagement across all agents"})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:_.map(b=>e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:b.label}),e.jsx(b.icon,{className:`h-4 w-4 ${b.color}`})]}),e.jsx(Oe,{children:o?e.jsx(xs,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:b.value.toLocaleString()})})]},b.label))}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(ac,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Oe,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((b,w)=>e.jsx(xs,{className:"h-12 w-full"},w))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No presentations created yet."}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(el,{sortKey:"name",currentSortKey:i,currentDirection:d,onSort:u,children:"Agent"}),e.jsx(el,{sortKey:"presentations",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Presentations"}),e.jsx(el,{sortKey:"views",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Views"}),e.jsx(el,{sortKey:"leads",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Leads"}),e.jsx(el,{sortKey:"cta_clicks",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"CTA Clicks"}),e.jsx(el,{sortKey:"conversion",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Conversion"})]})}),e.jsx(Pn,{children:f.map(b=>{var j,k;const w=b.total_views>0?(b.total_leads/b.total_views*100).toFixed(1):"0.0";return e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center overflow-hidden",children:b.avatar_url?e.jsx("img",{src:b.avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:((k=(j=b.name)==null?void 0:j.charAt(0))==null?void 0:k.toUpperCase())||"?"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:b.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:b.email})]})]})}),e.jsx(lt,{className:"text-center font-medium",children:b.presentation_count}),e.jsx(lt,{className:"text-center",children:b.total_views.toLocaleString()}),e.jsx(lt,{className:"text-center",children:b.total_leads>0?e.jsx(rt,{variant:"secondary",children:b.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(lt,{className:"text-center",children:b.total_cta_clicks}),e.jsx(lt,{className:"text-center",children:e.jsxs("span",{className:Number(w)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[w,"%"]})})]},b.owner_user_id)})})]})})]})]})})}function Rys(){const{toast:t}=Pa(),[s,r]=C.useState([]),[n,a]=C.useState({totalOpenHouses:0,totalVisitors:0,totalLeads:0,activeOpenHouses:0,agentsUsing:0}),[o,l]=C.useState(!0);C.useEffect(()=>{i()},[]);const i=async()=>{try{l(!0);const{data:u,error:p}=await G.rpc("get_admin_guest_book_stats");if(p)throw p;if(!u||u.length===0){l(!1);return}const f=u.map(j=>j.agent_id),{data:y,error:_}=await G.from("profiles").select("id, name, email, avatar_url").in("id",f);if(_)throw _;const b=new Map((y==null?void 0:y.map(j=>[j.id,j]))||[]),w=u.map(j=>{const k=b.get(j.agent_id);return{agent_id:j.agent_id,name:(k==null?void 0:k.name)||"Unknown",email:(k==null?void 0:k.email)||"",avatar_url:(k==null?void 0:k.avatar_url)||null,open_house_count:Number(j.open_house_count),total_visitors:Number(j.total_visitors),total_leads:Number(j.total_leads),active_count:Number(j.active_count)}});w.sort((j,k)=>k.total_visitors-j.total_visitors),r(w),a({totalOpenHouses:w.reduce((j,k)=>j+k.open_house_count,0),totalVisitors:w.reduce((j,k)=>j+k.total_visitors,0),totalLeads:w.reduce((j,k)=>j+k.total_leads,0),activeOpenHouses:w.reduce((j,k)=>j+k.active_count,0),agentsUsing:w.length})}catch(u){console.error("Error loading guest book stats:",u),t({title:"Error",description:"Failed to load guest book analytics",variant:"destructive"})}finally{l(!1)}},d=[{label:"Agents Using",value:n.agentsUsing,icon:hr,color:"text-blue-600"},{label:"Total Open Houses",value:n.totalOpenHouses,icon:On,color:"text-violet-600"},{label:"Active Now",value:n.activeOpenHouses,icon:hi,color:"text-emerald-600"},{label:"Total Visitors",value:n.totalVisitors,icon:xa,color:"text-amber-600"},{label:"Leads Created",value:n.totalLeads,icon:yc,color:"text-rose-600"}];return e.jsx(Ts,{title:"Guest Book Analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Guest Book Analytics"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Track open house sign-in usage and lead generation across all agents"})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:d.map(u=>e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:u.label}),e.jsx(u.icon,{className:`h-4 w-4 ${u.color}`})]}),e.jsx(Oe,{children:o?e.jsx(xs,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:u.value.toLocaleString()})})]},u.label))}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(ac,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Oe,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((u,p)=>e.jsx(xs,{className:"h-12 w-full"},p))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No open houses created yet."}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Agent"}),e.jsx(bt,{className:"text-center",children:"Open Houses"}),e.jsx(bt,{className:"text-center",children:"Active"}),e.jsx(bt,{className:"text-center",children:"Visitors"}),e.jsx(bt,{className:"text-center",children:"Leads"}),e.jsx(bt,{className:"text-center",children:"Conversion"})]})}),e.jsx(Pn,{children:s.map(u=>{var f,y;const p=u.total_visitors>0?(u.total_leads/u.total_visitors*100).toFixed(1):"0.0";return e.jsxs(Ns,{children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center overflow-hidden",children:u.avatar_url?e.jsx("img",{src:u.avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:((y=(f=u.name)==null?void 0:f.charAt(0))==null?void 0:y.toUpperCase())||"?"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:u.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:u.email})]})]})}),e.jsx(lt,{className:"text-center font-medium",children:u.open_house_count}),e.jsx(lt,{className:"text-center",children:u.active_count>0?e.jsx(rt,{variant:"secondary",className:"bg-emerald-100 text-emerald-700",children:u.active_count}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(lt,{className:"text-center",children:u.total_visitors.toLocaleString()}),e.jsx(lt,{className:"text-center",children:u.total_leads>0?e.jsx(rt,{variant:"secondary",children:u.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(lt,{className:"text-center",children:e.jsxs("span",{className:Number(p)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[p,"%"]})})]},u.agent_id)})})]})})]})]})})}function Fys(){const[t]=Pc(),s=Pr(),[r,n]=C.useState("loading"),[a,o]=C.useState("Processing connection...");return C.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),fe.error("Failed to connect: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),fe.error("Failed to connect: No authorization code");return}try{const{data:f,error:y}=await G.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p}});if(y)throw y;if(f!=null&&f.success)n("success"),o(f.message||"Accounts connected successfully!"),fe.success(f.message||"Social accounts connected!");else throw new Error((f==null?void 0:f.error)||"Failed to connect accounts")}catch(f){console.error("Callback error:",f),n("error"),o(f.message||"Failed to complete connection"),fe.error(f.message||"Failed to connect accounts")}})()},[t]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(It,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4",children:[r==="loading"&&e.jsx(Ms,{className:"h-12 w-12 animate-spin text-primary"}),r==="success"&&e.jsx(hi,{className:"h-12 w-12 text-green-500"}),r==="error"&&e.jsx(kc,{className:"h-12 w-12 text-destructive"})]}),e.jsxs(Ot,{children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(pr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/admin/integrations"),children:r==="success"?"View Integrations":"Back to Integrations"})})]})})}function zys(){const t=rs(),[s,r]=C.useState(""),[n,a]=C.useState(""),[o,l]=C.useState([]),i=C.useRef(null),{data:d,isLoading:u}=wt({queryKey:["prospect-emails"],queryFn:async()=>{const{data:j,error:k}=await G.from("prospect_emails").select("*").order("sent_at",{ascending:!1});if(k)throw k;return j}}),p={total:(d==null?void 0:d.length)||0,sent:(d==null?void 0:d.filter(j=>j.status==="sent").length)||0,converted:(d==null?void 0:d.filter(j=>j.status==="converted").length)||0,conversionRate:d!=null&&d.length?Math.round(d.filter(j=>j.status==="converted").length/d.length*100):0},f=Dt({mutationFn:async j=>{const{data:k,error:S}=await G.functions.invoke("send-prospect-email",{body:{emails:j}});if(S)throw S;return k},onSuccess:j=>{t.invalidateQueries({queryKey:["prospect-emails"]}),fe.success(`${j.sent} email${j.sent>1?"s":""} sent successfully!`),r(""),a(""),l([])},onError:j=>{fe.error("Failed to send: "+j.message)}}),y=Dt({mutationFn:async()=>{var T,I;const{data:{user:j}}=await G.auth.getUser();if(!(j!=null&&j.email))throw new Error("Could not get your email");const{data:k,error:S}=await G.functions.invoke("send-prospect-email",{body:{emails:[{email:j.email,first_name:(I=(T=j.user_metadata)==null?void 0:T.name)==null?void 0:I.split(" ")[0]}],test_mode:!0}});if(S)throw S;return k},onSuccess:()=>{fe.success("Test email sent to your inbox!")},onError:j=>{fe.error("Failed to send test: "+j.message)}}),_=()=>{if(!s.trim()){fe.error("Please enter an email address");return}if(d==null?void 0:d.find(k=>k.email.toLowerCase()===s.trim().toLowerCase())){fe.error("This email has already been prospected");return}f.mutate([{email:s.trim(),first_name:n.trim()||void 0}])},b=j=>{var T;const k=(T=j.target.files)==null?void 0:T[0];if(!k)return;const S=new FileReader;S.onload=I=>{var U,H;const R=((U=I.target)==null?void 0:U.result).split(` `).filter(Y=>Y.trim()),$=[],q=(H=R[0])!=null&&H.toLowerCase().includes("email")?1:0;for(let Y=q;Yde.trim().replace(/"/g,"")),te=se[0],Q=se[1];te&&te.includes("@")&&$.push({email:te,first_name:Q||void 0})}l($),fe.success(`${$.length} entries loaded from CSV`)},S.readAsText(k),i.current&&(i.current.value="")},w=()=>{if(o.length===0){fe.error("No entries to send");return}const j=new Set((d==null?void 0:d.map(S=>S.email.toLowerCase()))||[]),k=o.filter(S=>!j.has(S.email.toLowerCase()));if(k.length===0){fe.error("All emails have already been prospected");return}k.lengthy.mutate(),disabled:y.isPending,className:"gap-2 ml-4 shrink-0",children:[y.isPending?e.jsx(Ms,{className:"h-3 w-3 animate-spin"}):e.jsx(br,{className:"h-3 w-3"}),"Send Test to Me"]})]})]}),e.jsx(Oe,{children:e.jsxs(ka,{defaultValue:"single",children:[e.jsxs(_a,{className:"mb-4",children:[e.jsxs(js,{value:"single",children:[e.jsx(aa,{className:"h-4 w-4 mr-2"}),"Single Send"]}),e.jsxs(js,{value:"bulk",children:[e.jsx(Za,{className:"h-4 w-4 mr-2"}),"Bulk CSV"]})]}),e.jsx(zs,{value:"single",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(ve,{htmlFor:"prospect-email",className:"sr-only",children:"Email"}),e.jsx(Re,{id:"prospect-email",type:"email",placeholder:"agent@example.com",value:s,onChange:j=>r(j.target.value),onKeyDown:j=>j.key==="Enter"&&_()})]}),e.jsxs("div",{className:"w-full sm:w-48",children:[e.jsx(ve,{htmlFor:"prospect-name",className:"sr-only",children:"First Name"}),e.jsx(Re,{id:"prospect-name",placeholder:"First name (optional)",value:n,onChange:j=>a(j.target.value),onKeyDown:j=>j.key==="Enter"&&_()})]}),e.jsxs(K,{onClick:_,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):e.jsx(aa,{className:"h-4 w-4"}),"Send Invite"]})]})}),e.jsx(zs,{value:"bulk",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{ref:i,type:"file",accept:".csv",onChange:b,className:"hidden"}),e.jsxs(K,{variant:"outline",onClick:()=>{var j;return(j=i.current)==null?void 0:j.click()},className:"gap-2",children:[e.jsx(In,{className:"h-4 w-4"}),"Upload CSV"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Format: email, first_name (one per line)"})]}),o.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(rt,{variant:"secondary",className:"gap-1",children:[e.jsx(hr,{className:"h-3 w-3"}),o.length," entries ready"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>l([]),children:[e.jsx(Ur,{className:"h-4 w-4"}),"Clear"]})]}),e.jsxs("div",{className:"max-h-40 overflow-y-auto border rounded-lg p-3 bg-muted/30 text-sm font-mono space-y-1",children:[o.slice(0,20).map((j,k)=>e.jsxs("div",{className:"text-muted-foreground",children:[j.email,j.first_name?` — ${j.first_name}`:""]},k)),o.length>20&&e.jsxs("div",{className:"text-muted-foreground/60",children:["...and ",o.length-20," more"]})]}),e.jsxs(K,{onClick:w,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):e.jsx(aa,{className:"h-4 w-4"}),"Send ",o.length," Invites"]})]})]})})]})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),"Prospect Log"]}),e.jsx(pr,{children:"Track all sent invitations and their conversion status"})]}),e.jsx(Oe,{children:u?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((j,k)=>e.jsx(xs,{className:"h-12 w-full"},k))}):d&&d.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Email"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Name"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Sent"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Converted"})]})}),e.jsx("tbody",{children:d.map(j=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-3 px-4 text-sm font-medium text-foreground",children:j.email}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:j.first_name||"—"}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:ys(new Date(j.sent_at),"MMM d, yyyy")}),e.jsx("td",{className:"py-3 px-4",children:j.status==="converted"?e.jsxs(rt,{className:"bg-green-500/10 text-green-700 hover:bg-green-500/20 border-0",children:[e.jsx(ua,{className:"h-3 w-3 mr-1"}),"Converted"]}):e.jsxs(rt,{variant:"secondary",className:"gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),"Sent"]})}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:j.converted_at?ys(new Date(j.converted_at),"MMM d, yyyy"):"—"})]},j.id))})]})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Gh,{className:"h-12 w-12 text-muted-foreground/30 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No prospects yet. Send your first invite above!"})]})})]})]})})}function qce(t){const s=rs(),{toast:r}=Pa(),n=wt({queryKey:["recruit-stages",t],queryFn:async()=>{if(!t)return[];const{data:d,error:u}=await G.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(u)throw u;return d},enabled:!!t}),a=wt({queryKey:["recruit-prospects",t],queryFn:async()=>{if(!t)return[];const{data:d,error:u}=await G.from("recruit_prospects").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(u)throw u;return d},enabled:!!t}),o=Dt({mutationFn:async d=>{const{data:{user:u}}=await G.auth.getUser();if(!u)throw new Error("Not authenticated");const p={first_name:d.first_name||"",last_name:d.last_name||null,email:d.email||null,phone:d.phone||null,current_brokerage:d.current_brokerage||null,license_number:d.license_number||null,experience_years:d.experience_years??null,annual_production:d.annual_production||null,source:d.source||"manual",notes:d.notes||null,stage_id:d.stage_id||null,brokerage_id:t,created_by:u.id,address:d.address||null,city:d.city||null,state:d.state||null,zip_code:d.zip_code||null,last_year_volume:d.last_year_volume||null,last_year_transactions:d.last_year_transactions??null,avg_sale_price:d.avg_sale_price||null,specialties:d.specialties||null,linkedin_url:d.linkedin_url||null,website_url:d.website_url||null,instagram_handle:d.instagram_handle||null,facebook_url:d.facebook_url||null,birthday:d.birthday||null,spouse_name:d.spouse_name||null,interests:d.interests||null,referred_by:d.referred_by||null},{data:f,error:y}=await G.from("recruit_prospects").insert(p).select().single();if(y)throw y;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]}),r({title:"Prospect added"})},onError:d=>r({title:"Error",description:d.message,variant:"destructive"})}),l=Dt({mutationFn:async({id:d,...u})=>{const{data:p,error:f}=await G.from("recruit_prospects").update({...u,updated_at:new Date().toISOString()}).eq("id",d).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]})},onError:d=>r({title:"Error",description:d.message,variant:"destructive"})}),i=Dt({mutationFn:async d=>{const{error:u}=await G.from("recruit_prospects").delete().eq("id",d);if(u)throw u},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]}),r({title:"Prospect removed"})}});return{stages:n.data||[],prospects:a.data||[],isLoading:n.isLoading||a.isLoading,addProspect:o,updateProspect:l,deleteProspect:i}}function Bys(t){const s=rs(),{toast:r}=Pa(),n=wt({queryKey:["recruit-activities",t],queryFn:async()=>{if(!t)return[];const{data:o,error:l}=await G.from("recruit_activities").select("*").eq("prospect_id",t).order("created_at",{ascending:!1});if(l)throw l;return o},enabled:!!t}),a=Dt({mutationFn:async o=>{const{data:{user:l}}=await G.auth.getUser();if(!l)throw new Error("Not authenticated");const{data:i,error:d}=await G.from("recruit_activities").insert({...o,created_by:l.id}).select().single();if(d)throw d;return i},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-activities",t]}),r({title:"Activity logged"})},onError:o=>r({title:"Error",description:o.message,variant:"destructive"})});return{activities:n.data||[],isLoading:n.isLoading,addActivity:a}}const eDe=(t,s)=>{var r;return{first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",license_number:"",experience_years:"",annual_production:"",source:"manual",notes:"",stage_id:t||((r=s==null?void 0:s[0])==null?void 0:r.id)||"",address:"",city:"",state:"",zip_code:"",last_year_volume:"",last_year_transactions:"",avg_sale_price:"",specialties:"",linkedin_url:"",website_url:"",instagram_handle:"",facebook_url:"",birthday:"",spouse_name:"",interests:"",referred_by:""}};function het({open:t,onOpenChange:s,stages:r,defaultStageId:n,onSubmit:a,isSubmitting:o}){const[l,i]=C.useState(eDe(n,r)),d=p=>f=>i(y=>({...y,[p]:f.target.value})),u=p=>{p.preventDefault(),a({...l,experience_years:l.experience_years?parseInt(l.experience_years):null,last_year_transactions:l.last_year_transactions?parseInt(l.last_year_transactions):null,stage_id:l.stage_id||null}),i(eDe(n,r)),s(!1)};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Add Recruit Prospect"})}),e.jsxs("form",{onSubmit:u,className:"space-y-4",children:[e.jsxs(ka,{defaultValue:"basic",className:"w-full",children:[e.jsxs(_a,{className:"grid w-full grid-cols-4",children:[e.jsx(js,{value:"basic",children:"Basic Info"}),e.jsx(js,{value:"production",children:"Production"}),e.jsx(js,{value:"social",children:"Social & Web"}),e.jsx(js,{value:"personal",children:"Personal"})]}),e.jsxs(zs,{value:"basic",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"First Name *"}),e.jsx(Re,{required:!0,value:l.first_name,onChange:d("first_name")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Last Name"}),e.jsx(Re,{value:l.last_name,onChange:d("last_name")})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Email"}),e.jsx(Re,{type:"email",value:l.email,onChange:d("email")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Phone"}),e.jsx(Re,{value:l.phone,onChange:d("phone")})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Current Brokerage"}),e.jsx(Re,{value:l.current_brokerage,onChange:d("current_brokerage")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"License #"}),e.jsx(Re,{value:l.license_number,onChange:d("license_number")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Experience (years)"}),e.jsx(Re,{type:"number",min:"0",value:l.experience_years,onChange:d("experience_years")})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Address"}),e.jsx(Re,{placeholder:"Street address",value:l.address,onChange:d("address")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"City"}),e.jsx(Re,{value:l.city,onChange:d("city")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"State"}),e.jsx(Re,{value:l.state,onChange:d("state")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Zip"}),e.jsx(Re,{value:l.zip_code,onChange:d("zip_code")})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Pipeline Stage"}),e.jsxs(sr,{value:l.stage_id,onValueChange:p=>i(f=>({...f,stage_id:p})),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:r.map(p=>e.jsx(At,{value:p.id,children:p.name},p.id))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Referred By"}),e.jsx(Re,{placeholder:"Who referred this prospect?",value:l.referred_by,onChange:d("referred_by")})]})]}),e.jsxs(zs,{value:"production",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Annual Production Volume"}),e.jsx(Re,{placeholder:"e.g. $5M, 20 transactions",value:l.annual_production,onChange:d("annual_production")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Last Year Volume"}),e.jsx(Re,{placeholder:"e.g. $8.2M",value:l.last_year_volume,onChange:d("last_year_volume")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Last Year Transactions"}),e.jsx(Re,{type:"number",min:"0",placeholder:"e.g. 24",value:l.last_year_transactions,onChange:d("last_year_transactions")})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Avg Sale Price"}),e.jsx(Re,{placeholder:"e.g. $350K",value:l.avg_sale_price,onChange:d("avg_sale_price")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Specialties / Niche"}),e.jsx(Re,{placeholder:"e.g. Luxury, First-time buyers, Investment",value:l.specialties,onChange:d("specialties")})]})]}),e.jsxs(zs,{value:"social",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"LinkedIn URL"}),e.jsx(Re,{type:"url",placeholder:"https://linkedin.com/in/...",value:l.linkedin_url,onChange:d("linkedin_url")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Website URL"}),e.jsx(Re,{type:"url",placeholder:"https://...",value:l.website_url,onChange:d("website_url")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Instagram Handle"}),e.jsx(Re,{placeholder:"@handle",value:l.instagram_handle,onChange:d("instagram_handle")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Facebook URL"}),e.jsx(Re,{type:"url",placeholder:"https://facebook.com/...",value:l.facebook_url,onChange:d("facebook_url")})]})]}),e.jsxs(zs,{value:"personal",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Birthday"}),e.jsx(Re,{type:"date",value:l.birthday,onChange:d("birthday")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Spouse / Partner Name"}),e.jsx(Re,{value:l.spouse_name,onChange:d("spouse_name")})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Interests / Hobbies"}),e.jsx(Re,{placeholder:"Golf, travel, community events...",value:l.interests,onChange:d("interests")})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Notes"}),e.jsx(Ar,{value:l.notes,onChange:d("notes"),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:o,children:"Add Prospect"})]})]})]})})}const rve=[{value:"why_switch",label:"Why Switch Brokerages"},{value:"commission",label:"Commission & Splits"},{value:"culture",label:"Culture & Team"},{value:"follow_up",label:"Follow Up"},{value:"general",label:"General Pitch"}];function $ys(t){return wt({queryKey:["recruit-videos",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("recruit_videos").select(` *, prospect:recruit_prospects(id, first_name, last_name, email, phone, current_brokerage), video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status) `).eq("brokerage_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function qys(t){return wt({queryKey:["recruit-videos-prospect",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("recruit_videos").select(` *, video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status) `).eq("prospect_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Uys(){const t=rs(),{toast:s}=Pa();return Dt({mutationFn:async r=>{const{data:{user:n}}=await G.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await G.from("recruit_videos").insert({prospect_id:r.prospect_id,video_id:r.video_id,brokerage_id:r.brokerage_id,message:r.message||null,created_by:n.id}).select("*, prospect:recruit_prospects(id, first_name, last_name, email, phone, current_brokerage), video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status)").single();if(o)throw o;return a},onSuccess:r=>{t.invalidateQueries({queryKey:["recruit-videos"]}),t.invalidateQueries({queryKey:["recruit-videos-prospect",r.prospect_id]}),s({title:"Video linked to prospect"})},onError:r=>s({title:"Error",description:r.message,variant:"destructive"})})}function met(){const t=rs();return Dt({mutationFn:async({id:s,sent_via:r})=>{const{error:n}=await G.from("recruit_videos").update({sent_at:new Date().toISOString(),sent_via:r,updated_at:new Date().toISOString()}).eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-videos"]})}})}function pet(t){return wt({queryKey:["recruit-video-scripts",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("recruit_video_scripts").select("*").or(`brokerage_id.eq.${t},is_global.eq.true`).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Vys(){const t=rs(),{toast:s}=Pa();return Dt({mutationFn:async r=>{const{data:{user:n}}=await G.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await G.from("recruit_video_scripts").insert({...r,created_by:n.id}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-video-scripts"]}),s({title:"Script saved"})},onError:r=>s({title:"Error",description:r.message,variant:"destructive"})})}function Hys(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("recruit_video_scripts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-video-scripts"]})}})}function Wys({prospectId:t,prospectName:s,brokerageId:r}){var U;const{data:n=[],isLoading:a}=qys(t),{data:o=[]}=pet(r),l=Uys(),i=xS(),d=met(),[u,p]=C.useState("idle"),[f,y]=C.useState(0),[_,b]=C.useState(0),[w,j]=C.useState(""),[k,S]=C.useState(""),[T,I]=C.useState(!1),L=((U=o.find(H=>H.id===w))==null?void 0:U.script_text)||"",R=()=>{p("idle"),y(0),b(0),j(""),S("")},$=C.useCallback(async(H,Y)=>{p("uploading");try{const se=`Recruiting: ${s}`,{videoId:te,libraryId:Q}=await fD(se),{uploadUrl:de,apiKey:re}=await gD(te),ae=new XMLHttpRequest;ae.upload.onprogress=we=>{we.lengthComputable&&y(we.loaded/we.total*100)},await new Promise((we,Me)=>{ae.onload=()=>ae.status>=200&&ae.status<300?we():Me(new Error("Upload failed")),ae.onerror=()=>Me(new Error("Upload failed")),ae.open("PUT",de),ae.setRequestHeader("AccessKey",re),ae.send(H)}),p("processing");let le=0;const he=Date.now(),be=9e4,_e=`https://iframe.mediadelivery.net/embed/${Q}/${te}`;for(;le<4&&(await new Promise(Me=>setTimeout(Me,3e3)),!(Date.now()-he>be));){const we=await oM(te);if(le=we.status,b(we.encodeProgress||0),le===5||le===6)throw new Error("Video processing failed")}const je=await oM(te),Ne=(je.storageSize||H.size)/(1024*1024),Ge=await i.mutateAsync({bunny_video_id:te,playback_url:je.directPlayUrl||_e,thumbnail_url:je.thumbnailUrl,preview_url:je.previewUrl||null,duration_seconds:je.length||Y,file_size_mb:Ne,title:se,status:le>=4?"ready":"processing",touch_type:"recruiting"});await l.mutateAsync({prospect_id:t,video_id:Ge.id,brokerage_id:r,message:k||void 0}),p("done"),fe.success("Video recorded and linked to prospect!"),setTimeout(()=>{I(!1),R()},1500)}catch(se){fe.error(se.message||"Failed to upload video"),p("record")}},[t,s,r,k,i,l]),q=H=>{H&&(navigator.clipboard.writeText(`${window.location.origin}/recruit-video/${H}`),fe.success("Share link copied"))};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-1.5",children:[e.jsx(Nn,{className:"h-4 w-4"})," Video Outreach"]}),e.jsxs(_s,{open:T,onOpenChange:H=>{!H&&(u==="uploading"||u==="processing")||(I(H),H||R())},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>p("script"),children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Record Video"]})}),e.jsxs(vs,{className:"max-w-2xl",children:[e.jsx(Ss,{children:e.jsxs(ks,{children:["Record Video for ",s]})}),u==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Choose a Script (optional)"}),e.jsxs(sr,{value:w,onValueChange:j,children:[e.jsx(er,{className:"mt-1",children:e.jsx(rr,{placeholder:"No script — speak freely"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"none",children:"No script"}),o.map(H=>{var Y;return e.jsx(At,{value:H.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[H.title,e.jsx(rt,{variant:"outline",className:"text-[9px] ml-1",children:(Y=rve.find(se=>se.value===H.category))==null?void 0:Y.label})]})},H.id)})]})]}),L&&e.jsx("div",{className:"mt-2 p-3 bg-muted/50 rounded-md text-sm max-h-32 overflow-y-auto whitespace-pre-wrap",children:L})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Personal Message (shown on landing page)"}),e.jsx(Ar,{value:k,onChange:H=>S(H.target.value),placeholder:`Hi ${s.split(" ")[0]}, I'd love to chat about what we're building here...`,rows:3,className:"mt-1"})]}),e.jsxs(K,{onClick:()=>p("record"),className:"w-full",children:[e.jsx(Nn,{className:"h-4 w-4 mr-2"})," Start Recording"]})]}),u==="record"&&e.jsx($ce,{maxDurationSeconds:60,onRecordingComplete:$,teleprompterContent:L||void 0}),u==="uploading"&&e.jsxs("div",{className:"py-8 space-y-4 text-center",children:[e.jsx("p",{className:"font-medium",children:"Uploading video…"}),e.jsx(Ti,{value:f,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(f),"%"]})]}),u==="processing"&&e.jsxs("div",{className:"py-8 space-y-4 text-center",children:[e.jsx("p",{className:"font-medium",children:"Processing video…"}),e.jsx(Ti,{value:_,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(_),"%"]})]}),u==="done"&&e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-3",children:e.jsx(ul,{className:"h-6 w-6 text-emerald-600"})}),e.jsx("p",{className:"font-medium text-emerald-600",children:"Video ready!"})]})]})]})]}),a?e.jsx("div",{className:"text-center py-4",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent mx-auto"})}):n.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No videos sent yet"}):e.jsx("div",{className:"space-y-2",children:n.map(H=>{var Y,se;return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-md border text-sm",children:[e.jsx("div",{className:"h-10 w-16 rounded bg-muted overflow-hidden flex-shrink-0",children:(Y=H.video)!=null&&Y.thumbnail_url?e.jsx("img",{src:H.video.thumbnail_url,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(Nn,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-xs truncate",children:((se=H.video)==null?void 0:se.title)||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[H.view_count>0?e.jsxs(rt,{variant:"secondary",className:"text-[9px] h-4",children:[e.jsx(xa,{className:"h-2.5 w-2.5 mr-0.5"}),H.view_count]}):H.sent_at?e.jsxs(rt,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(aa,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]}):e.jsxs(rt,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(Tn,{className:"h-2.5 w-2.5 mr-0.5"}),"Draft"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ys(new Date(H.created_at),"MMM d")})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>q(H.share_token),children:e.jsx(ai,{className:"h-3 w-3"})}),!H.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>d.mutate({id:H.id,sent_via:"email"}),children:e.jsx(aa,{className:"h-3 w-3"})})]})]},H.id)})})]})}const tDe=[{value:"call",label:"Phone Call",icon:Qn},{value:"email",label:"Email",icon:br},{value:"text",label:"Text Message",icon:io},{value:"meeting",label:"Meeting",icon:on},{value:"note",label:"Note",icon:In}];function tp({label:t,value:s,icon:r}){return s?e.jsxs("div",{children:[e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[r&&e.jsx(r,{className:"h-3 w-3"})," ",t]}),e.jsx("p",{className:"font-medium text-sm",children:s})]}):null}function $R({label:t,url:s,icon:r}){return s?e.jsxs("a",{href:s.startsWith("http")?s:`https://${s}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-sm text-primary hover:underline",children:[e.jsx(r,{className:"h-3.5 w-3.5"})," ",t," ",e.jsx(sn,{className:"h-3 w-3 opacity-50"})]}):null}function Zl({label:t,value:s,onChange:r,type:n="text",placeholder:a}){return e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:t}),e.jsx(Re,{type:n,value:s,onChange:o=>r(o.target.value),placeholder:a,className:"mt-1 h-8 text-sm"})]})}function fet({prospect:t,stages:s,brokerageId:r,open:n,onOpenChange:a,onUpdate:o,onDelete:l}){const{activities:i,addActivity:d}=Bys((t==null?void 0:t.id)||null),[u,p]=C.useState({type:"note",title:"",description:""}),[f,y]=C.useState(!1),[_,b]=C.useState(!1),[w,j]=C.useState({});if(!t)return null;const k=()=>{var Y,se;j({first_name:t.first_name||"",last_name:t.last_name||"",email:t.email||"",phone:t.phone||"",current_brokerage:t.current_brokerage||"",license_number:t.license_number||"",experience_years:((Y=t.experience_years)==null?void 0:Y.toString())||"",notes:t.notes||"",source:t.source||"",address:t.address||"",city:t.city||"",state:t.state||"",zip_code:t.zip_code||"",last_year_volume:t.last_year_volume||"",last_year_transactions:((se=t.last_year_transactions)==null?void 0:se.toString())||"",avg_sale_price:t.avg_sale_price||"",specialties:t.specialties||"",annual_production:t.annual_production||"",linkedin_url:t.linkedin_url||"",website_url:t.website_url||"",instagram_handle:t.instagram_handle||"",facebook_url:t.facebook_url||"",birthday:t.birthday||"",spouse_name:t.spouse_name||"",interests:t.interests||"",referred_by:t.referred_by||""}),b(!0)},S=()=>{const Y={id:t.id};for(const[se,te]of Object.entries(w))se==="experience_years"||se==="last_year_transactions"?Y[se]=te?parseInt(te):null:Y[se]=te||null;o(Y),b(!1)},T=()=>b(!1),I=Y=>se=>j(te=>({...te,[Y]:se})),L=()=>{u.title.trim()&&(d.mutate({prospect_id:t.id,activity_type:u.type,title:u.title,description:u.description||null}),p({type:"note",title:"",description:""}),y(!1))},R=s.find(Y=>Y.id===t.stage_id),$=t.address||t.city||t.state,q=t.last_year_volume||t.last_year_transactions||t.avg_sale_price||t.specialties||t.annual_production,U=t.linkedin_url||t.website_url||t.instagram_handle||t.facebook_url,H=t.birthday||t.spouse_name||t.interests||t.referred_by;return e.jsx(MM,{open:n,onOpenChange:Y=>{Y||b(!1),a(Y)},children:e.jsx(cS,{className:"w-full sm:max-w-lg p-0",children:e.jsx(Ri,{className:"h-full",children:e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsx(TM,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(AM,{className:"text-xl",children:[t.first_name," ",t.last_name]}),R&&e.jsx(rt,{variant:"outline",style:{borderColor:R.color,color:R.color},className:"mt-1",children:R.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[_?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:T,children:e.jsx(Ur,{className:"h-4 w-4"})}),e.jsx(K,{variant:"default",size:"icon",onClick:S,children:e.jsx(fu,{className:"h-4 w-4"})})]}):e.jsx(K,{variant:"ghost",size:"icon",onClick:k,title:"Edit prospect",children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsxs(nc,{children:[e.jsx(Rh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete prospect?"}),e.jsx(Dl,{children:"This will permanently remove this prospect and all their activity history."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>{l(t.id),a(!1)},children:"Delete"})]})]})]})]})]})}),!_&&e.jsxs("div",{className:"space-y-1.5 text-sm",children:[t.email&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(br,{className:"h-3.5 w-3.5"})," ",t.email]}),t.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Qn,{className:"h-3.5 w-3.5"})," ",t.phone]}),$&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Oi,{className:"h-3.5 w-3.5"}),[t.address,t.city,t.state,t.zip_code].filter(Boolean).join(", ")]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Move to Stage"}),e.jsxs(sr,{value:t.stage_id||"",onValueChange:Y=>o({id:t.id,stage_id:Y}),children:[e.jsx(er,{className:"mt-1",children:e.jsx(rr,{})}),e.jsx(tr,{children:s.map(Y=>e.jsx(At,{value:Y.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:Y.color}}),Y.name]})},Y.id))})]})]}),e.jsxs(ka,{defaultValue:"details",className:"w-full",children:[e.jsxs(_a,{className:"grid w-full grid-cols-4 h-8 text-xs",children:[e.jsx(js,{value:"details",className:"text-xs",children:"Details"}),e.jsx(js,{value:"production",className:"text-xs",children:"Production"}),e.jsx(js,{value:"social",className:"text-xs",children:"Social"}),e.jsx(js,{value:"personal",className:"text-xs",children:"Personal"})]}),_?e.jsxs(e.Fragment,{children:[e.jsxs(zs,{value:"details",className:"mt-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Zl,{label:"First Name",value:w.first_name,onChange:I("first_name")}),e.jsx(Zl,{label:"Last Name",value:w.last_name,onChange:I("last_name")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Zl,{label:"Email",value:w.email,onChange:I("email"),type:"email"}),e.jsx(Zl,{label:"Phone",value:w.phone,onChange:I("phone")})]}),e.jsx(Zl,{label:"Current Brokerage",value:w.current_brokerage,onChange:I("current_brokerage")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Zl,{label:"License #",value:w.license_number,onChange:I("license_number")}),e.jsx(Zl,{label:"Experience (years)",value:w.experience_years,onChange:I("experience_years"),type:"number"})]}),e.jsx(Zl,{label:"Address",value:w.address,onChange:I("address"),placeholder:"Street address"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(Zl,{label:"City",value:w.city,onChange:I("city")}),e.jsx(Zl,{label:"State",value:w.state,onChange:I("state")}),e.jsx(Zl,{label:"Zip",value:w.zip_code,onChange:I("zip_code")})]}),e.jsx(Zl,{label:"Source",value:w.source,onChange:I("source")}),e.jsx(Zl,{label:"Referred By",value:w.referred_by,onChange:I("referred_by")}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Notes"}),e.jsx(Ar,{value:w.notes,onChange:Y=>j(se=>({...se,notes:Y.target.value})),rows:3,className:"mt-1 text-sm"})]})]}),e.jsxs(zs,{value:"production",className:"mt-3 space-y-3",children:[e.jsx(Zl,{label:"Annual Production",value:w.annual_production,onChange:I("annual_production"),placeholder:"e.g. $5M"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Zl,{label:"Last Year Volume",value:w.last_year_volume,onChange:I("last_year_volume"),placeholder:"e.g. $8.2M"}),e.jsx(Zl,{label:"Last Year Transactions",value:w.last_year_transactions,onChange:I("last_year_transactions"),type:"number",placeholder:"e.g. 24"})]}),e.jsx(Zl,{label:"Avg Sale Price",value:w.avg_sale_price,onChange:I("avg_sale_price"),placeholder:"e.g. $350K"}),e.jsx(Zl,{label:"Specialties / Niche",value:w.specialties,onChange:I("specialties"),placeholder:"e.g. Luxury, Investment"})]}),e.jsxs(zs,{value:"social",className:"mt-3 space-y-3",children:[e.jsx(Zl,{label:"LinkedIn URL",value:w.linkedin_url,onChange:I("linkedin_url"),type:"url",placeholder:"https://linkedin.com/in/..."}),e.jsx(Zl,{label:"Website URL",value:w.website_url,onChange:I("website_url"),type:"url",placeholder:"https://..."}),e.jsx(Zl,{label:"Instagram Handle",value:w.instagram_handle,onChange:I("instagram_handle"),placeholder:"@handle"}),e.jsx(Zl,{label:"Facebook URL",value:w.facebook_url,onChange:I("facebook_url"),type:"url",placeholder:"https://facebook.com/..."})]}),e.jsxs(zs,{value:"personal",className:"mt-3 space-y-3",children:[e.jsx(Zl,{label:"Birthday",value:w.birthday,onChange:I("birthday"),type:"date"}),e.jsx(Zl,{label:"Spouse / Partner",value:w.spouse_name,onChange:I("spouse_name")}),e.jsx(Zl,{label:"Interests / Hobbies",value:w.interests,onChange:I("interests"),placeholder:"Golf, travel, community events..."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(zs,{value:"details",className:"mt-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(tp,{label:"Current Brokerage",value:t.current_brokerage}),e.jsx(tp,{label:"License #",value:t.license_number}),e.jsx(tp,{label:"Experience",value:t.experience_years!=null?`${t.experience_years} years`:null}),e.jsx(tp,{label:"Referred By",value:t.referred_by}),e.jsx(tp,{label:"Source",value:t.source})]}),t.notes&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Notes"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.notes})]})]}),e.jsx(zs,{value:"production",className:"mt-3",children:q?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(tp,{label:"Annual Production",value:t.annual_production}),e.jsx(tp,{label:"Last Year Volume",value:t.last_year_volume}),e.jsx(tp,{label:"Last Year Transactions",value:t.last_year_transactions}),e.jsx(tp,{label:"Avg Sale Price",value:t.avg_sale_price}),e.jsx(tp,{label:"Specialties / Niche",value:t.specialties})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No production data added yet"})}),e.jsx(zs,{value:"social",className:"mt-3",children:U?e.jsxs("div",{className:"space-y-2",children:[e.jsx($R,{label:"LinkedIn",url:t.linkedin_url,icon:Om}),e.jsx($R,{label:"Website",url:t.website_url,icon:Lm}),t.instagram_handle&&e.jsx($R,{label:t.instagram_handle,url:`https://instagram.com/${t.instagram_handle.replace("@","")}`,icon:Wd}),e.jsx($R,{label:"Facebook",url:t.facebook_url,icon:Hd})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No social profiles added yet"})}),e.jsx(zs,{value:"personal",className:"mt-3",children:H?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(tp,{label:"Birthday",value:t.birthday?ys(new Date(t.birthday+"T00:00:00"),"MMMM d, yyyy"):null,icon:po}),e.jsx(tp,{label:"Spouse / Partner",value:t.spouse_name,icon:Si}),e.jsx("div",{className:"col-span-2",children:e.jsx(tp,{label:"Interests / Hobbies",value:t.interests})})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No personal details added yet"})})]})]}),e.jsx(Wys,{prospectId:t.id,prospectName:`${t.first_name} ${t.last_name||""}`,brokerageId:r}),e.jsx(Rl,{}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-semibold text-sm",children:"Activity Log"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>y(!f),children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Log Activity"]})]}),f&&e.jsxs("div",{className:"border rounded-lg p-3 mb-4 space-y-3 bg-muted/30",children:[e.jsxs(sr,{value:u.type,onValueChange:Y=>p(se=>({...se,type:Y})),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:tDe.map(Y=>e.jsx(At,{value:Y.value,children:Y.label},Y.value))})]}),e.jsx(Re,{placeholder:"Subject / Title",value:u.title,onChange:Y=>p(se=>({...se,title:Y.target.value}))}),e.jsx(Ar,{placeholder:"Details (optional)",value:u.description,onChange:Y=>p(se=>({...se,description:Y.target.value})),rows:2}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>y(!1),children:"Cancel"}),e.jsx(K,{size:"sm",onClick:L,disabled:!u.title.trim(),children:"Save"})]})]}),e.jsxs("div",{className:"space-y-3",children:[i.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"}),i.map(Y=>{const se=tDe.find(Q=>Q.value===Y.activity_type),te=(se==null?void 0:se.icon)||In;return e.jsxs("div",{className:"flex gap-3 text-sm",children:[e.jsx("div",{className:"mt-0.5",children:e.jsx("div",{className:"h-7 w-7 rounded-full bg-muted flex items-center justify-center",children:e.jsx(te,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium",children:Y.title}),Y.description&&e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:Y.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ys(new Date(Y.created_at),"MMM d, yyyy h:mm a")})]})]},Y.id)})]})]})]})})})})}const sDe=["first_name","last_name","email","phone","current_brokerage","license_number","experience_years","annual_production","notes"];function get({open:t,onOpenChange:s,brokerageId:r,stages:n}){var H;const{toast:a}=Pa(),o=rs(),l=C.useRef(null),[i,d]=C.useState([]),[u,p]=C.useState([]),[f,y]=C.useState({}),[_,b]=C.useState(((H=n[0])==null?void 0:H.id)||""),[w,j]=C.useState(!1),[k,S]=C.useState("upload"),[T,I]=C.useState(0),L=()=>{d([]),p([]),y({}),S("upload"),I(0)},R=Y=>{var Q;const se=(Q=Y.target.files)==null?void 0:Q[0];if(!se)return;const te=new FileReader;te.onload=de=>{var _e;const ae=((_e=de.target)==null?void 0:_e.result).split(/\r?\n/).filter(je=>je.trim());if(ae.length<2){a({title:"Invalid CSV",description:"File must have a header row and at least one data row",variant:"destructive"});return}const le=$(ae[0]);p(le);const he={};le.forEach((je,Ne)=>{const Ge=je.toLowerCase().replace(/[^a-z]/g,"_").replace(/_+/g,"_"),we=sDe.find(Me=>Ge.includes(Me)||Me.includes(Ge)||Me==="first_name"&&(Ge.includes("first")||Ge==="name")||Me==="last_name"&&Ge.includes("last")||Me==="current_brokerage"&&(Ge.includes("brokerage")||Ge.includes("company"))||Me==="license_number"&&Ge.includes("license")||Me==="experience_years"&&(Ge.includes("experience")||Ge.includes("years"))||Me==="annual_production"&&(Ge.includes("production")||Ge.includes("volume")));we&&(he[String(Ne)]=we)}),y(he);const be=ae.slice(1).map(je=>{const Ne=$(je),Ge={};return le.forEach((we,Me)=>{Ge[String(Me)]=Ne[Me]||""}),Ge});d(be),S("map")},te.readAsText(se)},$=Y=>{const se=[];let te="",Q=!1;for(const de of Y)de==='"'?Q=!Q:de===","&&!Q?(se.push(te.trim()),te=""):te+=de;return se.push(te.trim()),se},q=async()=>{j(!0);try{const{data:{user:Y}}=await G.auth.getUser();if(!Y)throw new Error("Not authenticated");const se=i.map(Q=>{const de={brokerage_id:r,created_by:Y.id,stage_id:_,source:"csv_import",first_name:"Unknown"};return Object.entries(f).forEach(([re,ae])=>{var he;const le=(he=Q[re])==null?void 0:he.trim();le&&(ae==="experience_years"?de[ae]=parseInt(le)||null:de[ae]=le)}),de});let te=0;for(let Q=0;Q{const Y=`first_name,last_name,email,phone,current_brokerage,license_number,experience_years,annual_production,notes Jane,Smith,jane@example.com,555-0100,ABC Realty,RE12345,8,$5M,Met at conference`,se=new Blob([Y],{type:"text/csv"}),te=URL.createObjectURL(se),Q=document.createElement("a");Q.href=te,Q.download="recruit-prospects-template.csv",Q.click(),URL.revokeObjectURL(te)};return e.jsx(_s,{open:t,onOpenChange:Y=>{Y||L(),s(Y)},children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Import Prospects from CSV"})}),k==="upload"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx(I0,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Upload a CSV file with prospect data"}),e.jsx("input",{ref:l,type:"file",accept:".csv",className:"hidden",onChange:R}),e.jsxs(K,{onClick:()=>{var Y;return(Y=l.current)==null?void 0:Y.click()},children:[e.jsx(Za,{className:"h-4 w-4 mr-2"})," Choose File"]})]}),e.jsx(K,{variant:"link",className:"text-xs",onClick:U,children:"Download CSV template"})]}),k==="map"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.length," rows found"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:"Import to stage:"}),e.jsxs(sr,{value:_,onValueChange:b,children:[e.jsx(er,{className:"w-[180px]",children:e.jsx(rr,{})}),e.jsx(tr,{children:n.map(Y=>e.jsx(At,{value:Y.id,children:Y.name},Y.id))})]})]})]}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{className:"w-[140px]",children:"CSV Column"}),e.jsx(bt,{className:"w-[160px]",children:"Map To"}),e.jsx(bt,{children:"Preview"})]})}),e.jsx(Pn,{children:u.map((Y,se)=>{var te;return e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium text-xs",children:Y}),e.jsx(lt,{children:e.jsxs(sr,{value:f[String(se)]||"skip",onValueChange:Q=>y(de=>({...de,[String(se)]:Q==="skip"?"":Q})),children:[e.jsx(er,{className:"h-8 text-xs",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"skip",children:"— Skip —"}),sDe.map(Q=>e.jsx(At,{value:Q,children:Q.replace(/_/g," ")},Q))]})]})}),e.jsx(lt,{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:((te=i[0])==null?void 0:te[String(se)])||"—"})]},se)})})]})}),!Object.values(f).includes("first_name")&&e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-sm",children:[e.jsx(ll,{className:"h-4 w-4"}),' Map at least "first name" to proceed']}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>{L()},children:"Back"}),e.jsx(K,{onClick:q,disabled:w||!Object.values(f).includes("first_name"),children:w?"Importing...":`Import ${i.length} Prospects`})]})]}),k==="done"&&e.jsxs("div",{className:"text-center py-6 space-y-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-green-500/10 flex items-center justify-center mx-auto",children:e.jsx(ha,{className:"h-6 w-6 text-green-600"})}),e.jsxs("p",{className:"font-semibold",children:[T," prospects imported successfully!"]}),e.jsx(K,{onClick:()=>{L(),s(!1)},children:"Close"})]})]})})}function Gys({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=qce(t),[i,d]=C.useState(!1),[u,p]=C.useState(),[f,y]=C.useState(null),[_,b]=C.useState(!1),[w,j]=C.useState(!1),[k,S]=C.useState(null);if(n)return e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});const T=U=>r.filter(H=>H.stage_id===U),I=(U,H)=>{S(H),U.dataTransfer.effectAllowed="move"},L=U=>{U.preventDefault(),U.dataTransfer.dropEffect="move"},R=(U,H)=>{U.preventDefault(),k&&(o.mutate({id:k,stage_id:H}),S(null))},$=U=>{p(U),d(!0)},q=U=>{y(U),b(!0)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.length," prospect",r.length!==1?"s":""]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>j(!0),children:[e.jsx(Za,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>{p(void 0),d(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs(Ri,{className:"w-full",children:[e.jsx("div",{className:"flex gap-4 pb-4",style:{minWidth:s.length*300},children:s.map(U=>{const H=T(U.id);return e.jsxs("div",{className:"w-[280px] flex-shrink-0 flex flex-col",onDragOver:L,onDrop:Y=>R(Y,U.id),children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 px-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-3 rounded-full",style:{backgroundColor:U.color}}),e.jsx("h3",{className:"font-semibold text-sm",children:U.name}),e.jsx(rt,{variant:"secondary",className:"text-xs h-5 px-1.5",children:H.length})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>$(U.id),children:e.jsx(Zs,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"space-y-2 min-h-[200px] bg-muted/30 rounded-lg p-2",children:H.map(Y=>e.jsx(Ee,{className:"p-3 cursor-pointer hover:shadow-md transition-shadow border-l-4 group",style:{borderLeftColor:U.color},draggable:!0,onDragStart:se=>I(se,Y.id),onClick:()=>q(Y),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Bu,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Yi,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsxs("span",{className:"font-medium text-sm truncate",children:[Y.first_name," ",Y.last_name]})]}),Y.current_brokerage&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Ta,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:Y.current_brokerage})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Y.email&&e.jsx(br,{className:"h-3 w-3 text-muted-foreground"}),Y.phone&&e.jsx(Qn,{className:"h-3 w-3 text-muted-foreground"}),Y.experience_years!=null&&e.jsxs(rt,{variant:"secondary",className:"text-[10px] h-4 px-1",children:[Y.experience_years,"yr"]})]})]})]})},Y.id))})]},U.id)})}),e.jsx(Zoe,{orientation:"horizontal"})]}),e.jsx(het,{open:i,onOpenChange:d,stages:s,defaultStageId:u,onSubmit:U=>a.mutate(U),isSubmitting:a.isPending}),e.jsx(fet,{prospect:f,stages:s,brokerageId:t,open:_,onOpenChange:b,onUpdate:U=>{o.mutate(U),y(H=>H?{...H,...U}:null)},onDelete:U=>l.mutate(U)}),e.jsx(get,{open:w,onOpenChange:j,brokerageId:t,stages:s})]})}function Kys({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=qce(t),[i,d]=C.useState(!1),[u,p]=C.useState(null),[f,y]=C.useState(!1),[_,b]=C.useState(!1),[w,j]=C.useState(""),[k,S]=C.useState("all"),[T,I]=C.useState(null),[L,R]=C.useState("asc"),$=Y=>{T===Y?R(se=>se==="asc"?"desc":"asc"):(I(Y),R("asc"))},q=({column:Y})=>T!==Y?e.jsx(Hc,{className:"h-3.5 w-3.5 ml-1 text-muted-foreground/50"}):L==="asc"?e.jsx(Vd,{className:"h-3.5 w-3.5 ml-1 text-primary"}):e.jsx(sh,{className:"h-3.5 w-3.5 ml-1 text-primary"}),U=Y=>s.find(se=>se.id===Y),H=C.useMemo(()=>{let Y=r.filter(se=>{var de,re;const te=!w||`${se.first_name} ${se.last_name}`.toLowerCase().includes(w.toLowerCase())||((de=se.email)==null?void 0:de.toLowerCase().includes(w.toLowerCase()))||((re=se.current_brokerage)==null?void 0:re.toLowerCase().includes(w.toLowerCase())),Q=k==="all"||se.stage_id===k;return te&&Q});return T&&(Y=[...Y].sort((se,te)=>{var ae,le;let Q=null,de=null;switch(T){case"name":Q=`${se.first_name} ${se.last_name||""}`.toLowerCase(),de=`${te.first_name} ${te.last_name||""}`.toLowerCase();break;case"stage":Q=((ae=U(se.stage_id))==null?void 0:ae.sort_order)??999,de=((le=U(te.stage_id))==null?void 0:le.sort_order)??999;break;case"brokerage":Q=(se.current_brokerage||"").toLowerCase(),de=(te.current_brokerage||"").toLowerCase();break;case"experience":Q=se.experience_years??-1,de=te.experience_years??-1;break;case"production":Q=(se.annual_production||"").toLowerCase(),de=(te.annual_production||"").toLowerCase();break;case"source":Q=(se.source||"").toLowerCase(),de=(te.source||"").toLowerCase();break;default:return 0}if(Q===de)return 0;if(Q==null)return 1;if(de==null)return-1;const re=Qj(Y.target.value),className:"pl-8"})]}),e.jsxs(sr,{value:k,onValueChange:S,children:[e.jsx(er,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"All stages"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All stages"}),s.map(Y=>e.jsx(At,{value:Y.id,children:Y.name},Y.id))]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>b(!0),children:[e.jsx(Za,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>d(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{className:"cursor-pointer select-none",onClick:()=>$("name"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Name ",e.jsx(q,{column:"name"})]})}),e.jsx(bt,{className:"cursor-pointer select-none",onClick:()=>$("stage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Stage ",e.jsx(q,{column:"stage"})]})}),e.jsx(bt,{className:"hidden md:table-cell cursor-pointer select-none",onClick:()=>$("brokerage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Brokerage ",e.jsx(q,{column:"brokerage"})]})}),e.jsx(bt,{className:"hidden md:table-cell",children:"Contact"}),e.jsx(bt,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>$("experience"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Experience ",e.jsx(q,{column:"experience"})]})}),e.jsx(bt,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>$("production"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Production ",e.jsx(q,{column:"production"})]})}),e.jsx(bt,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>$("source"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Source ",e.jsx(q,{column:"source"})]})}),e.jsx(bt,{className:"w-[50px]"})]})}),e.jsx(Pn,{children:H.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:8,className:"text-center text-muted-foreground py-8",children:"No prospects found"})}):H.map(Y=>{const se=U(Y.stage_id);return e.jsxs(Ns,{className:"cursor-pointer",onClick:()=>{p(Y),y(!0)},children:[e.jsxs(lt,{className:"font-medium",children:[Y.first_name," ",Y.last_name]}),e.jsx(lt,{children:se?e.jsxs(rt,{variant:"outline",className:"text-xs gap-1 whitespace-nowrap",style:{borderColor:se.color,color:se.color,backgroundColor:`${se.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:se.color}}),se.name]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"—"})}),e.jsx(lt,{className:"hidden md:table-cell",children:Y.current_brokerage?e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(Ta,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate max-w-[150px]",children:Y.current_brokerage})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(lt,{className:"hidden md:table-cell",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Y.email&&e.jsx(br,{className:"h-3.5 w-3.5 text-muted-foreground"}),Y.phone&&e.jsx(Qn,{className:"h-3.5 w-3.5 text-muted-foreground"}),!Y.email&&!Y.phone&&e.jsx("span",{className:"text-muted-foreground",children:"—"})]})}),e.jsx(lt,{className:"hidden lg:table-cell",children:Y.experience_years!=null?`${Y.experience_years} yr`:"—"}),e.jsx(lt,{className:"hidden lg:table-cell",children:Y.annual_production||"—"}),e.jsx(lt,{className:"hidden lg:table-cell",children:Y.source?e.jsx(rt,{variant:"secondary",className:"text-xs",children:Y.source}):"—"}),e.jsx(lt,{children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:te=>{te.stopPropagation(),l.mutate(Y.id)},children:e.jsx(jr,{className:"h-3.5 w-3.5"})})})]},Y.id)})})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[H.length," of ",r.length," prospects"]}),e.jsx(het,{open:i,onOpenChange:d,stages:s,onSubmit:Y=>a.mutate(Y),isSubmitting:a.isPending}),e.jsx(fet,{prospect:u,stages:s,brokerageId:t,open:f,onOpenChange:y,onUpdate:Y=>{o.mutate(Y),p(se=>se?{...se,...Y}:null)},onDelete:Y=>l.mutate(Y)}),e.jsx(get,{open:_,onOpenChange:b,brokerageId:t,stages:s})]})}function Zys({brokerageId:t}){const{stages:s,prospects:r,isLoading:n}=qce(t),a=C.useMemo(()=>{if(!s.length||!r.length)return null;const o=r.length,l=s.find(k=>k.name==="Signed"),i=s.find(k=>k.name==="Onboarded"),d=r.filter(k=>k.stage_id===(l==null?void 0:l.id)||k.stage_id===(i==null?void 0:i.id)).length,u=o>0?(d/o*100).toFixed(1):"0",p=new Date,f=o>0?Math.round(r.reduce((k,S)=>k+Qg(p,new Date(S.created_at)),0)/o):0,y=s.map(k=>({...k,count:r.filter(S=>S.stage_id===k.id).length})),_={};r.forEach(k=>{const S=k.source||"unknown";_[S]=(_[S]||0)+1});const b=Object.entries(_).sort((k,S)=>S[1]-k[1]),w=new Date;w.setDate(w.getDate()-30);const j=r.filter(k=>new Date(k.created_at)>=w).length;return{total:o,signed:d,conversionRate:u,avgDays:f,byStage:y,bySrc:b,recentCount:j}},[s,r]);return n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(hr,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:a.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Prospects"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-500/10 flex items-center justify-center",children:e.jsx(ac,{className:"h-5 w-5 text-green-600"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:[a.conversionRate,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Conversion Rate"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-amber-500/10 flex items-center justify-center",children:e.jsx(Tn,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:[a.avgDays,"d"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Avg Days in Pipeline"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-violet-500/10 flex items-center justify-center",children:e.jsx(Gh,{className:"h-5 w-5 text-violet-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:a.recentCount}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Added (30 days)"})]})]})})})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Pipeline Breakdown"})}),e.jsx(Oe,{className:"space-y-3",children:a.byStage.map(o=>{const l=a.total>0?o.count/a.total*100:0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:o.color}}),e.jsx("span",{children:o.name})]}),e.jsx("span",{className:"font-medium",children:o.count})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${l}%`,backgroundColor:o.color}})})]},o.id)})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Oe,{className:"space-y-3",children:[a.bySrc.map(([o,l])=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(rt,{variant:"secondary",className:"capitalize",children:o.replace(/_/g," ")}),e.jsx("span",{className:"text-sm font-medium",children:l})]},o)),a.bySrc.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No source data"})]})]})]})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No prospect data yet. Add prospects to see metrics."})}const rDe=[{id:"value-prop",category:"Outreach",title:"Value Proposition Introduction",subject:"A Better Way to Grow Your Real Estate Business",body:`Hi [First Name], I hope this message finds you well. I've been following your work in [Area/Market] and I'm impressed by what you've accomplished. I'm reaching out because I believe our brokerage offers unique tools and support that could help take your business to the next level: • Industry-leading commission splits • Full marketing suite with customizable templates • Advanced CRM and lead generation tools • Ongoing training and mentorship programs • Collaborative team environment I'd love to share more about how we're helping agents like you grow their business. Would you be open to a brief conversation this week? Best regards, [Your Name]`},{id:"follow-up",category:"Follow-up",title:"Gentle Follow-up",subject:"Following Up – Quick Chat?",body:`Hi [First Name], I wanted to follow up on my previous message. I understand you're busy – that's the sign of a successful agent! I'd love just 15 minutes of your time to show you what makes our brokerage different. Many agents who've made the switch tell us they wish they'd done it sooner. Would [Day/Time] work for a quick call or coffee? Looking forward to connecting, [Your Name]`},{id:"interview-invite",category:"Interview",title:"Interview / Meeting Invitation",subject:"Invitation to Learn More About [Brokerage Name]",body:`Hi [First Name], Thank you for your interest in exploring opportunities with [Brokerage Name]! I'd love to set up a time for us to meet and discuss how we can support your career goals. Here's what we'll cover: • Our commission structure and agent benefits • Technology and marketing tools available to you • Training and professional development opportunities • Culture and team dynamics • Your questions and goals I have availability on: • [Date/Time Option 1] • [Date/Time Option 2] • [Date/Time Option 3] Please let me know which time works best, or suggest an alternative that suits your schedule. Warm regards, [Your Name]`},{id:"offer",category:"Offer",title:"Formal Offer / Welcome",subject:"Welcome to the Team – Your Offer Details",body:`Hi [First Name], I'm thrilled to extend a formal invitation to join [Brokerage Name]! Based on our conversations, I'm confident this will be a great fit for both of us. Here's a summary of your offer: • Commission Split: [Details] • Start Date: [Date] • Desk/Office: [Details] • Technology Package: [Details] • Additional Benefits: [Details] Next steps: 1. Review the attached agreement 2. Complete the onboarding paperwork 3. Schedule your first-week orientation Please feel free to reach out with any questions. We're excited to have you on the team! Welcome aboard, [Your Name]`},{id:"referral-ask",category:"Referral",title:"Agent Referral Request",subject:"Know Any Great Agents Looking for a Change?",body:`Hi [First Name], Hope you're having a great [week/month]! I'm reaching out because our brokerage is growing and we're looking for talented agents to join our team. Since you know the industry well, I was wondering if you know any agents who might be: • Looking for better technology and support • Seeking a more collaborative environment • Ready to take their business to the next level We offer a referral bonus of [Amount/Details] for any successful placement. It's a great way to help a colleague while earning something extra. If anyone comes to mind, I'd appreciate the introduction! Thanks, [Your Name]`},{id:"market-update",category:"Outreach",title:"Market Insights Outreach",subject:"Market Update + Growth Opportunity",body:`Hi [First Name], With the recent changes in [local market conditions], I wanted to share some insights on how top-performing agents are adapting: 📊 [Market Stat 1] 📈 [Market Stat 2] 🏠 [Market Stat 3] At [Brokerage Name], we're equipping our agents with cutting-edge tools to thrive in this market: • AI-powered lead generation • Automated marketing campaigns • Real-time market analytics dashboard I'd love to share how our agents are outperforming the market. Do you have 15 minutes this week? Best, [Your Name]`}];function Yys({brokerageId:t}){const{toast:s}=Pa(),[r,n]=C.useState(null),[a,o]=C.useState(null),l=(d,u)=>{navigator.clipboard.writeText(d),n(u),s({title:"Copied to clipboard!"}),setTimeout(()=>n(null),2e3)},i=[...new Set(rDe.map(d=>d.category))];return e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pre-built email templates for recruiting outreach. Click to expand and copy."}),i.map(d=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(br,{className:"h-4 w-4"})," ",d]}),rDe.filter(u=>u.category===d).map(u=>e.jsxs(Ee,{className:`cursor-pointer transition-all ${a===u.id?"ring-2 ring-primary/20":"hover:shadow-sm"}`,onClick:()=>o(a===u.id?null:u.id),children:[e.jsx(It,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{className:"text-sm",children:u.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Subject: ",u.subject]})]}),e.jsx(rt,{variant:"secondary",className:"text-[10px]",children:u.category})]})}),a===u.id&&e.jsxs(Oe,{className:"pt-0 space-y-3",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Subject Line:"}),e.jsx("p",{className:"text-sm mb-3",children:u.subject}),e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Body:"}),e.jsx("pre",{className:"text-sm whitespace-pre-wrap font-sans",children:u.body})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:p=>{p.stopPropagation(),l(u.subject,u.id+"-subject")},children:[r===u.id+"-subject"?e.jsx(ha,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(ai,{className:"h-3.5 w-3.5 mr-1"}),"Copy Subject"]}),e.jsxs(K,{size:"sm",onClick:p=>{p.stopPropagation(),l(u.body,u.id+"-body")},children:[r===u.id+"-body"?e.jsx(ha,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(ai,{className:"h-3.5 w-3.5 mr-1"}),"Copy Body"]})]})]})]},u.id))]},d))]})}const nDe={call:Qn,email:br,text:io,meeting:on,note:In};function Xys({brokerageId:t}){const{data:s,isLoading:r}=wt({queryKey:["recruit-activity-report",t],queryFn:async()=>{const{data:n,error:a}=await G.from("recruit_prospects").select("id, created_by").eq("brokerage_id",t);if(a)throw a;const o=(n==null?void 0:n.map(_=>_.id))||[];if(o.length===0)return{recruiters:[],recentActivities:[]};const{data:l,error:i}=await G.from("recruit_activities").select("*").in("prospect_id",o).order("created_at",{ascending:!1});if(i)throw i;const d=[...new Set([...n.map(_=>_.created_by),...(l||[]).map(_=>_.created_by)])],{data:u}=await G.from("profiles").select("id, name, email").in("id",d),p=Object.fromEntries((u||[]).map(_=>[_.id,_])),f=fre(new Date,30);return{recruiters:d.map(_=>{var S,T;const b=(l||[]).filter(I=>I.created_by===_),w=b.filter(I=>new Date(I.created_at)>=f),j={};w.forEach(I=>{j[I.activity_type]=(j[I.activity_type]||0)+1});const k=n.filter(I=>I.created_by===_).length;return{id:_,name:((S=p[_])==null?void 0:S.name)||"Unknown",email:((T=p[_])==null?void 0:T.email)||"",totalActivities:b.length,recentActivities:w.length,byType:j,prospectsCreated:k}}).sort((_,b)=>b.recentActivities-_.recentActivities),recentActivities:(l||[]).slice(0,20)}},enabled:!!t});return r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):s!=null&&s.recruiters.length?e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Recruiter Leaderboard (Last 30 Days)"})}),e.jsx(Oe,{className:"space-y-4",children:s.recruiters.map((n,a)=>e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-primary/10 text-primary font-bold text-sm",children:a+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yi,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"font-medium text-sm",children:n.name})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(n.byType).map(([o,l])=>{const i=nDe[o]||In;return e.jsxs(rt,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(i,{className:"h-2.5 w-2.5"})," ",l," ",o,l!==1?"s":""]},o)})})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-lg font-bold",children:n.recentActivities}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"activities"})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-lg font-bold",children:n.prospectsCreated}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"prospects"})]})]},n.id))})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Recent Activity"})}),e.jsx(Oe,{className:"space-y-3",children:s.recentActivities.map(n=>{const a=nDe[n.activity_type]||In;return e.jsxs("div",{className:"flex items-start gap-3 text-sm",children:[e.jsx("div",{className:"h-7 w-7 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(a,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium",children:n.title}),n.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:ys(new Date(n.created_at),"MMM d, h:mm a")})]})]},n.id)})})]})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No recruiter activity yet."})}function Qys({brokerageId:t}){const{toast:s}=Pa(),r=rs(),[n,a]=C.useState(!1),[o,l]=C.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),{data:i=[],isLoading:d}=wt({queryKey:["recruit-referrals",t],queryFn:async()=>{const{data:j,error:k}=await G.from("recruit_referrals").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(k)throw k;return j}}),u=[...new Set(i.map(j=>j.referred_by))],{data:p=[]}=wt({queryKey:["referral-profiles",u],queryFn:async()=>{if(!u.length)return[];const{data:j}=await G.from("profiles").select("id, name, email").in("id",u);return j||[]},enabled:u.length>0}),f=Object.fromEntries(p.map(j=>[j.id,j])),y=Dt({mutationFn:async j=>{const{data:{user:k}}=await G.auth.getUser();if(!k)throw new Error("Not authenticated");const{error:S}=await G.from("recruit_referrals").insert({brokerage_id:t,referred_by:k.id,referee_first_name:j.first_name,referee_last_name:j.last_name||null,referee_email:j.email||null,referee_phone:j.phone||null,referee_current_brokerage:j.current_brokerage||null,notes:j.notes||null});if(S)throw S},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-referrals",t]}),s({title:"Referral submitted!"}),l({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),a(!1)},onError:j=>s({title:"Error",description:j.message,variant:"destructive"})}),_=Dt({mutationFn:async({id:j,status:k,incentive_status:S})=>{const T={updated_at:new Date().toISOString()};k&&(T.status=k),S&&(T.incentive_status=S);const{error:I}=await G.from("recruit_referrals").update(T).eq("id",j);if(I)throw I},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-referrals",t]})}),b=j=>j==="approved"||j==="signed"?e.jsx(ha,{className:"h-3 w-3"}):j==="rejected"?e.jsx(kc,{className:"h-3 w-3"}):e.jsx(Tn,{className:"h-3 w-3"}),w=j=>j==="approved"||j==="signed"||j==="paid"?"bg-green-500/10 text-green-600 border-green-200":j==="rejected"?"bg-red-500/10 text-red-600 border-red-200":"bg-amber-500/10 text-amber-600 border-amber-200";return d?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.length," referral",i.length!==1?"s":""]}),e.jsxs(K,{onClick:()=>a(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," Submit Referral"]})]}),i.length===0?e.jsxs(Ee,{className:"py-12 text-center",children:[e.jsx(yc,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No referrals yet. Agents can refer potential recruits here."})]}):e.jsx("div",{className:"space-y-3",children:i.map(j=>{var k;return e.jsx(Ee,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"font-medium",children:[j.referee_first_name," ",j.referee_last_name]}),e.jsxs(rt,{variant:"outline",className:w(j.status),children:[b(j.status)," ",j.status]}),j.incentive_status&&e.jsxs(rt,{variant:"outline",className:w(j.incentive_status),children:[e.jsx(po,{className:"h-3 w-3 mr-1"})," ",j.incentive_status]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[j.referee_email&&e.jsx("p",{children:j.referee_email}),j.referee_phone&&e.jsx("p",{children:j.referee_phone}),j.referee_current_brokerage&&e.jsxs("p",{children:["Currently at: ",j.referee_current_brokerage]}),e.jsxs("p",{children:["Referred by: ",((k=f[j.referred_by])==null?void 0:k.name)||"Unknown"," • ",ys(new Date(j.created_at),"MMM d, yyyy")]})]}),j.notes&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 italic",children:j.notes})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(sr,{value:j.status,onValueChange:S=>_.mutate({id:j.id,status:S}),children:[e.jsx(er,{className:"h-7 text-xs w-[110px]",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"pending",children:"Pending"}),e.jsx(At,{value:"contacted",children:"Contacted"}),e.jsx(At,{value:"approved",children:"Approved"}),e.jsx(At,{value:"signed",children:"Signed"}),e.jsx(At,{value:"rejected",children:"Rejected"})]})]}),e.jsxs(sr,{value:j.incentive_status||"pending",onValueChange:S=>_.mutate({id:j.id,incentive_status:S}),children:[e.jsx(er,{className:"h-7 text-xs w-[100px]",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"pending",children:"Unpaid"}),e.jsx(At,{value:"paid",children:"Paid"}),e.jsx(At,{value:"n/a",children:"N/A"})]})]})]})]})},j.id)})}),e.jsx(_s,{open:n,onOpenChange:a,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Submit a Recruit Referral"})}),e.jsxs("form",{onSubmit:j=>{j.preventDefault(),y.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"First Name *"}),e.jsx(Re,{required:!0,value:o.first_name,onChange:j=>l(k=>({...k,first_name:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Last Name"}),e.jsx(Re,{value:o.last_name,onChange:j=>l(k=>({...k,last_name:j.target.value}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Email"}),e.jsx(Re,{type:"email",value:o.email,onChange:j=>l(k=>({...k,email:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Phone"}),e.jsx(Re,{value:o.phone,onChange:j=>l(k=>({...k,phone:j.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Current Brokerage"}),e.jsx(Re,{value:o.current_brokerage,onChange:j=>l(k=>({...k,current_brokerage:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Notes"}),e.jsx(Ar,{value:o.notes,onChange:j=>l(k=>({...k,notes:j.target.value})),rows:2})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:y.isPending,children:"Submit"})]})]})]})})]})}function Jys({brokerageId:t}){const{toast:s}=Pa(),r=rs(),[n,a]=C.useState(!1),{data:o}=wt({queryKey:["brokerage-recruit-form",t],queryFn:async()=>{const{data:y,error:_}=await G.from("brokerages").select("id, name, recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(_)throw _;return y}}),{data:l=[]}=wt({queryKey:["recruit-interest-submissions",t],queryFn:async()=>{const{data:y,error:_}=await G.from("recruit_interest_submissions").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(_)throw _;return y}}),i=Dt({mutationFn:async y=>{const{error:_}=await G.from("brokerages").update({recruit_form_enabled:y}).eq("id",t);if(_)throw _},onSuccess:()=>{r.invalidateQueries({queryKey:["brokerage-recruit-form",t]}),s({title:o!=null&&o.recruit_form_enabled?"Form disabled":"Form enabled"})}}),d=Dt({mutationFn:async({id:y,status:_})=>{const{error:b}=await G.from("recruit_interest_submissions").update({status:_}).eq("id",y);if(b)throw b},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-interest-submissions",t]})}),u=`${window.location.origin}/join-brokerage/${(o==null?void 0:o.recruit_form_slug)||""}`,p=()=>{navigator.clipboard.writeText(u),a(!0),s({title:"Link copied!"}),setTimeout(()=>a(!1),2e3)},f=y=>y==="contacted"||y==="converted"?"bg-green-500/10 text-green-600":y==="dismissed"?"bg-red-500/10 text-red-600":"bg-blue-500/10 text-blue-600";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Public Interest Form"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Enable Public Form"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow agents to express interest in joining via a public link"})]}),e.jsx(Br,{checked:(o==null?void 0:o.recruit_form_enabled)||!1,onCheckedChange:y=>i.mutate(y)})]}),(o==null?void 0:o.recruit_form_enabled)&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg",children:[e.jsx("code",{className:"text-xs flex-1 truncate",children:u}),e.jsx(K,{size:"sm",variant:"outline",onClick:p,children:n?e.jsx(ha,{className:"h-3.5 w-3.5"}):e.jsx(ai,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:e.jsx(sn,{className:"h-3.5 w-3.5"})})})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"text-base",children:["Interest Submissions (",l.length,")"]})}),e.jsx(Oe,{children:l.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(yc,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No submissions yet"})]}):e.jsx("div",{className:"space-y-3",children:l.map(y=>e.jsxs("div",{className:"flex items-start justify-between gap-4 p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"font-medium text-sm",children:[y.first_name," ",y.last_name]}),e.jsx(rt,{variant:"outline",className:f(y.status),children:y.status})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs text-muted-foreground",children:[y.email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(br,{className:"h-3 w-3"}),y.email]}),y.phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Qn,{className:"h-3 w-3"}),y.phone]}),y.current_brokerage&&e.jsxs("span",{children:["From: ",y.current_brokerage]}),y.experience_years&&e.jsxs("span",{children:[y.experience_years,"yr exp"]})]}),y.why_interested&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 italic",children:['"',y.why_interested,'"']}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:ys(new Date(y.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(sr,{value:y.status,onValueChange:_=>d.mutate({id:y.id,status:_}),children:[e.jsx(er,{className:"h-7 text-xs w-[110px]",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"new",children:"New"}),e.jsx(At,{value:"contacted",children:"Contacted"}),e.jsx(At,{value:"converted",children:"Converted"}),e.jsx(At,{value:"dismissed",children:"Dismissed"})]})]})]},y.id))})})]})]})}function e0s({brokerageId:t}){const{toast:s}=Pa(),r=rs(),[n,a]=C.useState(!1),[o,l]=C.useState({prospect_id:"",title:"",description:"",due_date:ys(ml(new Date,1),"yyyy-MM-dd'T'HH:mm")}),[i,d]=C.useState("pending"),{data:u=[]}=wt({queryKey:["recruit-prospects-list",t],queryFn:async()=>{const{data:L,error:R}=await G.from("recruit_prospects").select("id, first_name, last_name").eq("brokerage_id",t).order("first_name");if(R)throw R;return L}}),{data:p=[],isLoading:f}=wt({queryKey:["recruit-follow-ups",t],queryFn:async()=>{const L=u.map(q=>q.id);if(!L.length)return[];const{data:R,error:$}=await G.from("recruit_follow_ups").select("*").in("prospect_id",L).order("due_date");if($)throw $;return R},enabled:u.length>0}),y=Object.fromEntries(u.map(L=>[L.id,L])),_=Dt({mutationFn:async L=>{const{data:{user:R}}=await G.auth.getUser();if(!R)throw new Error("Not authenticated");const{error:$}=await G.from("recruit_follow_ups").insert({prospect_id:L.prospect_id,assigned_to:R.id,title:L.title,description:L.description||null,due_date:new Date(L.due_date).toISOString()});if($)throw $},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-follow-ups",t]}),s({title:"Follow-up scheduled"}),l({prospect_id:"",title:"",description:"",due_date:ys(ml(new Date,1),"yyyy-MM-dd'T'HH:mm")}),a(!1)},onError:L=>s({title:"Error",description:L.message,variant:"destructive"})}),b=Dt({mutationFn:async({id:L,completed:R})=>{const{error:$}=await G.from("recruit_follow_ups").update({completed_at:R?new Date().toISOString():null}).eq("id",L);if($)throw $},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-follow-ups",t]})}),w=p.filter(L=>i==="pending"?!L.completed_at:i==="completed"?!!L.completed_at:!0),j=w.filter(L=>!L.completed_at&&sy(new Date(L.due_date))&&!Bd(new Date(L.due_date))),k=w.filter(L=>!L.completed_at&&Bd(new Date(L.due_date))),S=w.filter(L=>!L.completed_at&&!sy(new Date(L.due_date))&&!Bd(new Date(L.due_date))),T=w.filter(L=>!!L.completed_at),I=L=>{const R=y[L.prospect_id],$=!L.completed_at&&sy(new Date(L.due_date))&&!Bd(new Date(L.due_date));return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Bo,{checked:!!L.completed_at,onCheckedChange:q=>b.mutate({id:L.id,completed:q}),className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`text-sm font-medium ${L.completed_at?"line-through text-muted-foreground":""}`,children:L.title}),L.description&&e.jsx("p",{className:"text-xs text-muted-foreground",children:L.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground",children:[R&&e.jsxs(rt,{variant:"secondary",className:"text-[10px]",children:[R.first_name," ",R.last_name]}),e.jsxs("span",{className:`flex items-center gap-1 ${$?"text-destructive font-medium":""}`,children:[$?e.jsx(ll,{className:"h-3 w-3"}):e.jsx(on,{className:"h-3 w-3"}),ys(new Date(L.due_date),"MMM d, h:mm a")]}),L.is_automated&&e.jsx(rt,{variant:"outline",className:"text-[10px]",children:"Auto"})]})]})]},L.id)};return f?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex gap-2",children:["pending","completed","all"].map(L=>e.jsxs(K,{size:"sm",variant:i===L?"default":"outline",onClick:()=>d(L),className:"capitalize text-xs",children:[L," ",L==="pending"&&j.length+k.length+S.length>0&&`(${j.length+k.length+S.length})`]},L))}),e.jsxs(K,{size:"sm",onClick:()=>a(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Follow-up"]})]}),i!=="completed"&&j.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-destructive flex items-center gap-1",children:[e.jsx(ll,{className:"h-3.5 w-3.5"})," Overdue (",j.length,")"]}),j.map(I)]}),i!=="completed"&&k.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-600 flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3.5 w-3.5"})," Today (",k.length,")"]}),k.map(I)]}),i!=="completed"&&S.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(on,{className:"h-3.5 w-3.5"})," Upcoming (",S.length,")"]}),S.map(I)]}),i!=="pending"&&T.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(ha,{className:"h-3.5 w-3.5"})," Completed (",T.length,")"]}),T.map(I)]}),w.length===0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-8",children:["No follow-ups ",i!=="all"?`(${i})`:""]}),e.jsx(_s,{open:n,onOpenChange:a,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Schedule Follow-up"})}),e.jsxs("form",{onSubmit:L=>{L.preventDefault(),_.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Prospect *"}),e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",required:!0,value:o.prospect_id,onChange:L=>l(R=>({...R,prospect_id:L.target.value})),children:[e.jsx("option",{value:"",children:"Select prospect..."}),u.map(L=>e.jsxs("option",{value:L.id,children:[L.first_name," ",L.last_name]},L.id))]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Task *"}),e.jsx(Re,{required:!0,value:o.title,onChange:L=>l(R=>({...R,title:L.target.value})),placeholder:"e.g. Follow-up call"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Details"}),e.jsx(Ar,{value:o.description,onChange:L=>l(R=>({...R,description:L.target.value})),rows:2})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Due Date *"}),e.jsx(Re,{type:"datetime-local",required:!0,value:o.due_date,onChange:L=>l(R=>({...R,due_date:L.target.value}))})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:_.isPending,children:"Schedule"})]})]})]})})]})}const t0s=[{title:"Competitive Splits",description:"Industry-leading commission structure",icon:"💰"},{title:"Tech & Tools",description:"CRM, marketing automation, and more",icon:"🛠️"},{title:"Training & Support",description:"Ongoing mentorship and education",icon:"📚"}];function s0s({brokerageId:t}){const{toast:s}=Pa(),r=rs(),[n,a]=C.useState(null),{data:o,isLoading:l}=wt({queryKey:["recruit-landing-settings",t],queryFn:async()=>{const{data:j,error:k}=await G.from("recruit_landing_page_settings").select("*").eq("brokerage_id",t).maybeSingle();if(k)throw k;return j}}),[i,d]=C.useState({brokerage_id:t,hero_headline:"Join Our Team",hero_subtext:"Take your real estate career to the next level.",hero_image_url:null,logo_url:null,primary_color:"#406E71",accent_color:"#2a4c64",benefits:t0s,testimonials:[],gallery_images:[]});C.useEffect(()=>{o&&d({id:o.id,brokerage_id:o.brokerage_id,hero_headline:o.hero_headline,hero_subtext:o.hero_subtext||"",hero_image_url:o.hero_image_url,logo_url:o.logo_url,primary_color:o.primary_color,accent_color:o.accent_color,benefits:o.benefits||[],testimonials:o.testimonials||[],gallery_images:o.gallery_images||[]})},[o]);const u=Dt({mutationFn:async()=>{const j={brokerage_id:t,hero_headline:i.hero_headline,hero_subtext:i.hero_subtext,hero_image_url:i.hero_image_url,logo_url:i.logo_url,primary_color:i.primary_color,accent_color:i.accent_color,benefits:JSON.parse(JSON.stringify(i.benefits)),testimonials:JSON.parse(JSON.stringify(i.testimonials)),gallery_images:JSON.parse(JSON.stringify(i.gallery_images)),updated_at:new Date().toISOString()};if(i.id){const{error:k}=await G.from("recruit_landing_page_settings").update(j).eq("id",i.id);if(k)throw k}else{const{error:k}=await G.from("recruit_landing_page_settings").insert(j);if(k)throw k}},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-landing-settings",t]}),s({title:"Landing page saved!"})},onError:j=>s({title:"Error",description:j.message,variant:"destructive"})}),p=async(j,k)=>{const S=j.name.split(".").pop(),T=`${t}/${k}-${Date.now()}.${S}`,{error:I}=await G.storage.from("recruit-landing").upload(T,j);if(I)throw I;const{data:{publicUrl:L}}=G.storage.from("recruit-landing").getPublicUrl(T);return L},f=async(j,k)=>{var T;const S=(T=j.target.files)==null?void 0:T[0];if(S){a(k);try{const I=await p(S,k);d(L=>({...L,[k]:I})),s({title:"Image uploaded!"})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},y=async j=>{var S;const k=(S=j.target.files)==null?void 0:S[0];if(k){a("gallery");try{const T=await p(k,"gallery");d(I=>({...I,gallery_images:[...I.gallery_images,T]})),s({title:"Gallery image added!"})}catch(T){s({title:"Upload failed",description:T.message,variant:"destructive"})}finally{a(null)}}},_=async(j,k)=>{var T;const S=(T=j.target.files)==null?void 0:T[0];if(S){a(`testimonial-${k}`);try{const I=await p(S,`testimonial-${k}`);d(L=>{const R=[...L.testimonials];return R[k]={...R[k],photo_url:I},{...L,testimonials:R}})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},{data:b}=wt({queryKey:["brokerage-slug-for-landing",t],queryFn:async()=>{const{data:j,error:k}=await G.from("brokerages").select("recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(k)throw k;return j}}),w=`${window.location.origin}/join-brokerage/${(b==null?void 0:b.recruit_form_slug)||""}`;return l?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[(b==null?void 0:b.recruit_form_enabled)&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Live page:"}),e.jsx("code",{className:"text-xs flex-1 truncate",children:w}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(sn,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Branding"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Logo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.logo_url&&e.jsx("img",{src:i.logo_url,alt:"Logo",className:"h-10 w-auto rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:n==="logo_url",children:e.jsxs("span",{children:[e.jsx(Za,{className:"h-3.5 w-3.5 mr-1"}),n==="logo_url"?"Uploading...":"Upload Logo"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:j=>f(j,"logo_url")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.primary_color,onChange:j=>d(k=>({...k,primary_color:j.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Re,{value:i.primary_color,onChange:j=>d(k=>({...k,primary_color:j.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.accent_color,onChange:j=>d(k=>({...k,accent_color:j.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Re,{value:i.accent_color,onChange:j=>d(k=>({...k,accent_color:j.target.value})),className:"font-mono text-xs"})]})]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Hero Section"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Headline"}),e.jsx(Re,{value:i.hero_headline,onChange:j=>d(k=>({...k,hero_headline:j.target.value})),placeholder:"Join Our Team"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Subtext"}),e.jsx(Ar,{value:i.hero_subtext,onChange:j=>d(k=>({...k,hero_subtext:j.target.value})),rows:2,placeholder:"Take your career to the next level..."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Background Image"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.hero_image_url&&e.jsx("img",{src:i.hero_image_url,alt:"Hero",className:"h-16 w-28 object-cover rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:n==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(Za,{className:"h-3.5 w-3.5 mr-1"}),n==="hero_image_url"?"Uploading...":"Upload Image"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:j=>f(j,"hero_image_url")})]}),i.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(j=>({...j,hero_image_url:null})),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{className:"text-base",children:"Benefits / Why Join Us"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>d(j=>({...j,benefits:[...j.benefits,{title:"",description:"",icon:"✨"}]})),children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Oe,{className:"space-y-3",children:[i.benefits.map((j,k)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Bu,{className:"h-4 w-4 mt-2 text-muted-foreground"}),e.jsx(Re,{value:j.icon,onChange:S=>{const T=[...i.benefits];T[k]={...j,icon:S.target.value},d(I=>({...I,benefits:T}))},className:"w-14 text-center"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Re,{value:j.title,onChange:S=>{const T=[...i.benefits];T[k]={...j,title:S.target.value},d(I=>({...I,benefits:T}))},placeholder:"Benefit title"}),e.jsx(Re,{value:j.description,onChange:S=>{const T=[...i.benefits];T[k]={...j,description:S.target.value},d(I=>({...I,benefits:T}))},placeholder:"Short description"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(S=>({...S,benefits:S.benefits.filter((T,I)=>I!==k)})),children:e.jsx(jr,{className:"h-3.5 w-3.5 text-destructive"})})]},k)),i.benefits.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No benefits added yet"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{className:"text-base",children:"Testimonials"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>d(j=>({...j,testimonials:[...j.testimonials,{name:"",role:"",quote:""}]})),children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Oe,{className:"space-y-3",children:[i.testimonials.map((j,k)=>{var S;return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[j.photo_url?e.jsx("img",{src:j.photo_url,alt:j.name,className:"h-10 w-10 rounded-full object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded-full bg-muted flex items-center justify-center text-xs text-muted-foreground",children:((S=j.name)==null?void 0:S[0])||"?"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("span",{className:"text-[10px] text-primary hover:underline",children:n===`testimonial-${k}`?"...":"Photo"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:T=>_(T,k)})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Re,{value:j.name,onChange:T=>{const I=[...i.testimonials];I[k]={...j,name:T.target.value},d(L=>({...L,testimonials:I}))},placeholder:"Name"}),e.jsx(Re,{value:j.role,onChange:T=>{const I=[...i.testimonials];I[k]={...j,role:T.target.value},d(L=>({...L,testimonials:I}))},placeholder:"Role / Title"})]}),e.jsx(Ar,{value:j.quote,onChange:T=>{const I=[...i.testimonials];I[k]={...j,quote:T.target.value},d(L=>({...L,testimonials:I}))},placeholder:"What they say about working here...",rows:2})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(T=>({...T,testimonials:T.testimonials.filter((I,L)=>L!==k)})),children:e.jsx(jr,{className:"h-3.5 w-3.5 text-destructive"})})]},k)}),i.testimonials.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No testimonials added yet"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{className:"text-base",children:"Team & Culture Gallery"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{size:"sm",variant:"outline",asChild:!0,disabled:n==="gallery",children:e.jsxs("span",{children:[e.jsx(Jo,{className:"h-3.5 w-3.5 mr-1"}),n==="gallery"?"Uploading...":"Add Photo"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:y})]})]}),e.jsx(Oe,{children:i.gallery_images.length>0?e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:i.gallery_images.map((j,k)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:j,alt:`Gallery ${k+1}`,className:"h-24 w-full object-cover rounded-lg"}),e.jsx(K,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>d(S=>({...S,gallery_images:S.gallery_images.filter((T,I)=>I!==k)})),children:e.jsx(jr,{className:"h-3 w-3"})})]},k))}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No gallery images added yet"})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:()=>u.mutate(),disabled:u.isPending,size:"lg",children:[e.jsx(fu,{className:"h-4 w-4 mr-2"}),u.isPending?"Saving...":"Save Landing Page"]})})]})}function r0s(t){if(!t)return"—";const s=Math.floor(t/60),r=t%60;return s>0?`${s}m ${r}s`:`${r}s`}function n0s({video:t}){return t.cta_clicked_at?e.jsx(rt,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-200",children:"CTA Clicked"}):t.view_count>0?e.jsxs(rt,{className:"bg-blue-500/10 text-blue-600 border-blue-200",children:[e.jsx(xa,{className:"h-3 w-3 mr-1"}),t.view_count," views"]}):t.sent_at?e.jsxs(rt,{variant:"secondary",children:[e.jsx(aa,{className:"h-3 w-3 mr-1"}),"Sent"]}):e.jsxs(rt,{variant:"outline",children:[e.jsx(Tn,{className:"h-3 w-3 mr-1"}),"Draft"]})}function a0s({brokerageId:t}){const{data:s=[],isLoading:r}=$ys(t),{data:n=[]}=pet(t),a=Vys(),o=Hys(),l=met(),[i,d]=C.useState(""),[u,p]=C.useState(!1),[f,y]=C.useState({title:"",script_text:"",category:"general"}),_=s.filter(S=>{var I,L,R,$;return i?`${((I=S.prospect)==null?void 0:I.first_name)||""} ${((L=S.prospect)==null?void 0:L.last_name)||""}`.toLowerCase().includes(i.toLowerCase())||(($=(R=S.video)==null?void 0:R.title)==null?void 0:$.toLowerCase().includes(i.toLowerCase())):!0}),b={total:s.length,sent:s.filter(S=>S.sent_at).length,viewed:s.filter(S=>S.view_count>0).length,ctaClicked:s.filter(S=>S.cta_clicked_at).length},w=C.useCallback(S=>{if(!S)return;const T=`${window.location.origin}/recruit-video/${S}`;navigator.clipboard.writeText(T),fe.success("Share link copied")},[]),j=C.useCallback((S,T)=>{l.mutate({id:S,sent_via:T})},[l]),k=()=>{!f.title.trim()||!f.script_text.trim()||a.mutate({brokerage_id:t,...f},{onSuccess:()=>{y({title:"",script_text:"",category:"general"}),p(!1)}})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{label:"Total Videos",value:b.total,icon:Nn,color:"text-primary"},{label:"Sent",value:b.sent,icon:aa,color:"text-blue-500"},{label:"Viewed",value:b.viewed,icon:xa,color:"text-amber-500"},{label:"CTA Clicked",value:b.ctaClicked,icon:ua,color:"text-emerald-500"}].map(S=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:`h-10 w-10 rounded-lg bg-muted flex items-center justify-center ${S.color}`,children:e.jsx(S.icon,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:S.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.label})]})]})},S.label))}),e.jsxs(ka,{defaultValue:"videos",className:"space-y-4",children:[e.jsxs(_a,{children:[e.jsxs(js,{value:"videos",children:[e.jsx(Nn,{className:"h-4 w-4 mr-1.5"}),"All Videos"]}),e.jsxs(js,{value:"scripts",children:[e.jsx(In,{className:"h-4 w-4 mr-1.5"}),"Script Library"]}),e.jsxs(js,{value:"analytics",children:[e.jsx(ol,{className:"h-4 w-4 mr-1.5"}),"Engagement"]})]}),e.jsx(zs,{value:"videos",children:e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ot,{className:"text-lg",children:"Video Outreach"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name or title...",value:i,onChange:S=>d(S.target.value),className:"pl-9"})]})]})}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):_.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Nn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No video outreach yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Record a personalized video from any prospect's profile card"})]}):e.jsx("div",{className:"space-y-3",children:_.map(S=>{var T,I,L,R,$,q;return e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg border bg-card hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"relative h-16 w-28 rounded-md overflow-hidden bg-muted flex-shrink-0",children:[(T=S.video)!=null&&T.thumbnail_url?e.jsx("img",{src:S.video.thumbnail_url,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(Nn,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-white text-[10px] px-1 rounded",children:r0s(((I=S.video)==null?void 0:I.duration_seconds)??null)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"font-medium truncate",children:[(L=S.prospect)==null?void 0:L.first_name," ",(R=S.prospect)==null?void 0:R.last_name]}),e.jsx(n0s,{video:S})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:(($=S.video)==null?void 0:$.title)||"Untitled video"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ys(new Date(S.created_at),"MMM d, yyyy"),((q=S.prospect)==null?void 0:q.current_brokerage)&&` · ${S.prospect.current_brokerage}`]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(S.share_token),title:"Copy share link",children:e.jsx(ai,{className:"h-4 w-4"})}),!S.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>j(S.id,"email"),title:"Mark as sent",children:e.jsx(aa,{className:"h-4 w-4"})}),S.share_token&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>window.open(`/recruit-video/${S.share_token}`,"_blank"),title:"Preview landing page",children:e.jsx(sn,{className:"h-4 w-4"})})]})]},S.id)})})})]})}),e.jsx(zs,{value:"scripts",children:e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ot,{className:"text-lg",children:"Recruiting Scripts"}),e.jsxs(_s,{open:u,onOpenChange:p,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1.5"}),"New Script"]})}),e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Create Recruiting Script"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Title"}),e.jsx(Re,{value:f.title,onChange:S=>y(T=>({...T,title:S.target.value})),placeholder:"e.g., Why Switch to Our Brokerage"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Category"}),e.jsxs(sr,{value:f.category,onValueChange:S=>y(T=>({...T,category:S})),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:rve.map(S=>e.jsx(At,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Script"}),e.jsx(Ar,{value:f.script_text,onChange:S=>y(T=>({...T,script_text:S.target.value})),placeholder:"Hi [Name], I noticed you've been doing great work at [Brokerage]...",rows:8})]}),e.jsx(K,{onClick:k,disabled:!f.title.trim()||!f.script_text.trim(),className:"w-full",children:"Save Script"})]})]})]})]})}),e.jsx(Oe,{children:n.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(In,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No scripts yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Create teleprompter scripts for common recruiting conversations"})]}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:n.map(S=>{var I;const T=((I=rve.find(L=>L.value===S.category))==null?void 0:I.label)||S.category;return e.jsx(Ee,{className:"relative group",children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(rt,{variant:"outline",className:"text-[10px] mb-2",children:T}),e.jsx("h4",{className:"font-medium text-sm",children:S.title})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity text-destructive",onClick:()=>o.mutate(S.id),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 line-clamp-3",children:S.script_text}),S.is_global&&e.jsx(rt,{variant:"secondary",className:"mt-2 text-[10px]",children:"Template"})]})},S.id)})})})]})}),e.jsx(zs,{value:"analytics",children:e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Engagement Funnel"})}),e.jsxs(Oe,{children:[e.jsx("div",{className:"space-y-4",children:[{label:"Videos Created",count:b.total,pct:100,color:"bg-primary"},{label:"Sent to Prospects",count:b.sent,pct:b.total?Math.round(b.sent/b.total*100):0,color:"bg-blue-500"},{label:"Viewed by Prospect",count:b.viewed,pct:b.sent?Math.round(b.viewed/b.sent*100):0,color:"bg-amber-500"},{label:"CTA Clicked",count:b.ctaClicked,pct:b.viewed?Math.round(b.ctaClicked/b.viewed*100):0,color:"bg-emerald-500"}].map(S=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:S.label}),e.jsxs("span",{className:"font-medium",children:[S.count," (",S.pct,"%)"]})]}),e.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${S.color} rounded-full transition-all`,style:{width:`${S.pct}%`}})})]},S.label))}),s.filter(S=>S.view_count>0).length>0&&e.jsxs("div",{className:"mt-8",children:[e.jsx("h4",{className:"font-medium text-sm mb-3",children:"Most Engaged Prospects"}),e.jsx("div",{className:"space-y-2",children:s.filter(S=>S.view_count>0).sort((S,T)=>T.view_count-S.view_count).slice(0,5).map(S=>{var T,I;return e.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded-md bg-muted/30",children:[e.jsxs("span",{className:"font-medium",children:[(T=S.prospect)==null?void 0:T.first_name," ",(I=S.prospect)==null?void 0:I.last_name]}),e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xa,{className:"h-3.5 w-3.5"})," ",S.view_count]}),S.cta_clicked_at&&e.jsx(ua,{className:"h-4 w-4 text-emerald-500"})]})]},S.id)})})]})]})]})})]})]})}function i0s({brokerageId:t}){const{toast:s}=Pa(),r=rs(),{stages:n,prospects:a}=qce(t),[o,l]=C.useState(!1),[i,d]=C.useState({title:"",target_count:"10",target_stage_id:"",period_start:ys(new Date,"yyyy-MM-dd"),period_end:ys(new Date(new Date().getFullYear(),new Date().getMonth()+3,0),"yyyy-MM-dd")}),{data:u=[],isLoading:p}=wt({queryKey:["recruit-goals",t],queryFn:async()=>{const{data:b,error:w}=await G.from("recruit_goals").select("*").eq("brokerage_id",t).order("period_end",{ascending:!1});if(w)throw w;return b}}),f=Dt({mutationFn:async b=>{const{data:{user:w}}=await G.auth.getUser();if(!w)throw new Error("Not authenticated");const{error:j}=await G.from("recruit_goals").insert({brokerage_id:t,title:b.title,target_count:parseInt(b.target_count),target_stage_id:b.target_stage_id||null,period_start:b.period_start,period_end:b.period_end,created_by:w.id});if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal created"}),l(!1)},onError:b=>s({title:"Error",description:b.message,variant:"destructive"})}),y=Dt({mutationFn:async b=>{const{error:w}=await G.from("recruit_goals").delete().eq("id",b);if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal removed"})}}),_=b=>{const w=n.find(k=>k.id===b.target_stage_id);return{count:a.filter(k=>Mg(new Date(k.created_at),{start:new Date(b.period_start),end:new Date(b.period_end)})?b.target_stage_id?k.stage_id===b.target_stage_id:!0:!1).length,stage:w}};return p?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.length," goal",u.length!==1?"s":""]}),e.jsxs(K,{size:"sm",onClick:()=>l(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," New Goal"]})]}),u.length===0?e.jsxs(Ee,{className:"py-12 text-center",children:[e.jsx(Gh,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No goals set. Create a recruiting target to track progress."})]}):e.jsx("div",{className:"grid md:grid-cols-2 gap-4",children:u.map(b=>{const{count:w,stage:j}=_(b),k=Math.min(100,w/b.target_count*100),S=Mg(new Date,{start:new Date(b.period_start),end:new Date(b.period_end)});return e.jsxs(Ee,{className:S?"":"opacity-60",children:[e.jsx(It,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{className:"text-sm",children:b.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ys(new Date(b.period_start),"MMM d")," – ",ys(new Date(b.period_end),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[S?e.jsx(rt,{className:"text-[10px]",children:"Active"}):e.jsx(rt,{variant:"secondary",className:"text-[10px]",children:"Ended"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground",onClick:()=>y.mutate(b.id),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Oe,{className:"space-y-2",children:[j&&e.jsxs(rt,{variant:"outline",className:"text-[10px]",style:{borderColor:j.color,color:j.color},children:["Stage: ",j.name]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"font-bold text-lg",children:w}),e.jsxs("span",{className:"text-muted-foreground",children:["/ ",b.target_count]})]}),e.jsx(Ti,{value:k,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[k.toFixed(0),"% complete"]})]})]},b.id)})}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Create Recruiting Goal"})}),e.jsxs("form",{onSubmit:b=>{b.preventDefault(),f.mutate(i)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Goal Title *"}),e.jsx(Re,{required:!0,value:i.title,onChange:b=>d(w=>({...w,title:b.target.value})),placeholder:"e.g. Q2 Recruiting Target"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Target Count *"}),e.jsx(Re,{type:"number",min:"1",required:!0,value:i.target_count,onChange:b=>d(w=>({...w,target_count:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Target Stage (optional)"}),e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:i.target_stage_id,onChange:b=>d(w=>({...w,target_stage_id:b.target.value})),children:[e.jsx("option",{value:"",children:"All stages (total prospects)"}),n.map(b=>e.jsx("option",{value:b.id,children:b.name},b.id))]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Count prospects that reach this stage"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Start Date"}),e.jsx(Re,{type:"date",required:!0,value:i.period_start,onChange:b=>d(w=>({...w,period_start:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"End Date"}),e.jsx(Re,{type:"date",required:!0,value:i.period_end,onChange:b=>d(w=>({...w,period_end:b.target.value}))})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:f.isPending,children:"Create Goal"})]})]})]})})]})}function o0s(){var i;const[t,s]=C.useState(""),[r,n]=C.useState("board"),{data:a=[],isLoading:o}=wt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:d,error:u}=await G.from("brokerages").select("id, name").order("name");if(u)throw u;return d}}),l=t||((i=a[0])==null?void 0:i.id)||"";return o?e.jsx(Ts,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsx(Ts,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsxs("div",{className:"space-y-6",children:[a.length>1&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage:"}),e.jsxs(sr,{value:l,onValueChange:s,children:[e.jsxs(er,{className:"w-[280px]",children:[e.jsx(Ta,{className:"mr-2 h-4 w-4"}),e.jsx(rr,{placeholder:"Select brokerage"})]}),e.jsx(tr,{children:a.map(d=>e.jsx(At,{value:d.id,children:d.name},d.id))})]})]}),l?e.jsxs(ka,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(_a,{className:"flex-wrap h-auto gap-1",children:[e.jsx(js,{value:"pipeline",children:"Pipeline"}),e.jsxs(js,{value:"video-outreach",children:[e.jsx(Nn,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(js,{value:"follow-ups",children:"Follow-ups"}),e.jsx(js,{value:"referrals",children:"Referrals"}),e.jsx(js,{value:"interest",children:"Interest Form"}),e.jsx(js,{value:"landing-page",children:"Landing Page"}),e.jsx(js,{value:"goals",children:"Goals"}),e.jsx(js,{value:"metrics",children:"Metrics"}),e.jsx(js,{value:"templates",children:"Email Templates"}),e.jsx(js,{value:"activity",children:"Recruiter Activity"})]}),e.jsxs(zs,{value:"pipeline",children:[e.jsx("div",{className:"flex justify-end mb-3",children:e.jsxs("div",{className:"flex items-center rounded-md border bg-muted p-0.5",children:[e.jsxs(K,{variant:r==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("board"),children:[e.jsx(yp,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(K,{variant:r==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("table"),children:[e.jsx($P,{className:"h-3.5 w-3.5"})," Table"]})]})}),r==="board"?e.jsx(Gys,{brokerageId:l}):e.jsx(Kys,{brokerageId:l})]}),e.jsx(zs,{value:"video-outreach",children:e.jsx(a0s,{brokerageId:l})}),e.jsx(zs,{value:"follow-ups",children:e.jsx(e0s,{brokerageId:l})}),e.jsx(zs,{value:"referrals",children:e.jsx(Qys,{brokerageId:l})}),e.jsx(zs,{value:"interest",children:e.jsx(Jys,{brokerageId:l})}),e.jsx(zs,{value:"landing-page",children:e.jsx(s0s,{brokerageId:l})}),e.jsx(zs,{value:"goals",children:e.jsx(i0s,{brokerageId:l})}),e.jsx(zs,{value:"metrics",children:e.jsx(Zys,{brokerageId:l})}),e.jsx(zs,{value:"templates",children:e.jsx(Yys,{brokerageId:l})}),e.jsx(zs,{value:"activity",children:e.jsx(Xys,{brokerageId:l})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Ta,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found. Create a brokerage first."})]})]})})}function l0s(){const[t,s]=C.useState(""),{data:r,isLoading:n}=wt({queryKey:["admin-brokerage-content-activity"],queryFn:async()=>{const{data:i}=await G.from("brokerages").select("id, name");if(!i)return[];const{data:d}=await G.from("brokerage_content").select("id, brokerage_id, content_type, created_at"),{data:u}=await G.from("brokerage_content_categories").select("id, brokerage_id"),p=d||[],f=u||[],y=i.map(_=>{const b=p.filter(k=>k.brokerage_id===_.id),w=f.filter(k=>k.brokerage_id===_.id),j=b.length>0?b.reduce((k,S)=>S.created_at>k?S.created_at:k,b[0].created_at):null;return{brokerage_id:_.id,brokerage_name:_.name,total_items:b.length,videos:b.filter(k=>k.content_type==="video").length,pdfs:b.filter(k=>k.content_type==="pdf").length,links:b.filter(k=>k.content_type==="link"||k.content_type==="canva_link").length,events:b.filter(k=>k.content_type==="event").length,graphics:b.filter(k=>k.content_type==="graphic").length,latest_item_date:j,categories:w.length}});return y.sort((_,b)=>b.total_items-_.total_items),y}}),a=(r||[]).filter(i=>i.brokerage_name.toLowerCase().includes(t.toLowerCase())),o=a.reduce((i,d)=>i+d.total_items,0),l=a.filter(i=>i.total_items>0).length;return e.jsx(Ts,{title:"Brokerage Content Activity",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(wu,{title:"Brokerage Content Activity",description:"See which brokerages are creating custom content for their agents"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Active Brokerages"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:l}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with content uploaded"})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Content Items"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:o}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"across all brokerages"})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Brokerages"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:a.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"registered"})]})]})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search brokerages...",value:t,onChange:i=>s(i.target.value),className:"pl-9"})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Brokerage"}),e.jsx(bt,{className:"text-center",children:"Total"}),e.jsx(bt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Nn,{className:"h-3 w-3"})," Videos"]})}),e.jsx(bt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(In,{className:"h-3 w-3"})," PDFs"]})}),e.jsx(bt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Wo,{className:"h-3 w-3"})," Links"]})}),e.jsx(bt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(id,{className:"h-3 w-3"})," Events"]})}),e.jsx(bt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Jo,{className:"h-3 w-3"})," Graphics"]})}),e.jsx(bt,{className:"text-center",children:"Categories"}),e.jsx(bt,{children:"Last Upload"})]})}),e.jsx(Pn,{children:n?e.jsx(Ns,{children:e.jsx(lt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):a.length===0?e.jsx(Ns,{children:e.jsx(lt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"No brokerages found"})}):a.map(i=>e.jsxs(Ns,{className:i.total_items===0?"opacity-50":"",children:[e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:i.brokerage_name})]})}),e.jsx(lt,{className:"text-center",children:i.total_items>0?e.jsx(rt,{variant:"secondary",className:"font-bold",children:i.total_items}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(lt,{className:"text-center",children:i.videos||"–"}),e.jsx(lt,{className:"text-center",children:i.pdfs||"–"}),e.jsx(lt,{className:"text-center",children:i.links||"–"}),e.jsx(lt,{className:"text-center",children:i.events||"–"}),e.jsx(lt,{className:"text-center",children:i.graphics||"–"}),e.jsx(lt,{className:"text-center",children:i.categories||"–"}),e.jsx(lt,{children:i.latest_item_date?e.jsx("span",{className:"text-sm text-muted-foreground",children:ys(new Date(i.latest_item_date),"MMM d, yyyy")}):e.jsx("span",{className:"text-muted-foreground",children:"–"})})]},i.brokerage_id))})]})})})]})})}function c0s(t,s){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;const r=document.implementation.createHTMLDocument(),n=r.createElement("base"),a=r.createElement("a");return r.head.appendChild(n),r.body.appendChild(a),s&&(n.href=s),a.href=t,a.href}const d0s=(()=>{let t=0;const s=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${s()}${t}`)})();function k_(t){const s=[];for(let r=0,n=t.length;rsp||t.height>sp)&&(t.width>sp&&t.height>sp?t.width>t.height?(t.height*=sp/t.width,t.width=sp):(t.width*=sp/t.height,t.height=sp):t.width>sp?(t.height*=sp/t.width,t.width=sp):(t.width*=sp/t.height,t.height=sp))}function Zie(t){return new Promise((s,r)=>{const n=new Image;n.onload=()=>{n.decode().then(()=>{requestAnimationFrame(()=>s(n))})},n.onerror=r,n.crossOrigin="anonymous",n.decoding="async",n.src=t})}async function f0s(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(s=>`data:image/svg+xml;charset=utf-8,${s}`)}async function g0s(t,s,r){const n="http://www.w3.org/2000/svg",a=document.createElementNS(n,"svg"),o=document.createElementNS(n,"foreignObject");return a.setAttribute("width",`${s}`),a.setAttribute("height",`${r}`),a.setAttribute("viewBox",`0 0 ${s} ${r}`),o.setAttribute("width","100%"),o.setAttribute("height","100%"),o.setAttribute("x","0"),o.setAttribute("y","0"),o.setAttribute("externalResourcesRequired","true"),a.appendChild(o),o.appendChild(t),f0s(a)}const Bm=(t,s)=>{if(t instanceof s)return!0;const r=Object.getPrototypeOf(t);return r===null?!1:r.constructor.name===s.name||Bm(r,s)};function x0s(t){const s=t.getPropertyValue("content");return`${t.cssText} content: '${s.replace(/'|"/g,"")}';`}function y0s(t,s){return xet(s).map(r=>{const n=t.getPropertyValue(r),a=t.getPropertyPriority(r);return`${r}: ${n}${a?" !important":""};`}).join(" ")}function v0s(t,s,r,n){const a=`.${t}:${s}`,o=r.cssText?x0s(r):y0s(r,n);return document.createTextNode(`${a}{${o}}`)}function aDe(t,s,r,n){const a=window.getComputedStyle(t,r),o=a.getPropertyValue("content");if(o===""||o==="none")return;const l=d0s();try{s.className=`${s.className} ${l}`}catch{return}const i=document.createElement("style");i.appendChild(v0s(l,r,a,n)),s.appendChild(i)}function _0s(t,s,r){aDe(t,s,":before",r),aDe(t,s,":after",r)}const iDe="application/font-woff",oDe="image/jpeg",b0s={woff:iDe,woff2:iDe,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:oDe,jpeg:oDe,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function w0s(t){const s=/\.([^./]*?)$/g.exec(t);return s?s[1]:""}function Q2e(t){const s=w0s(t).toLowerCase();return b0s[s]||""}function j0s(t){return t.split(/,/)[1]}function nve(t){return t.search(/^(data:)/)!==-1}function N0s(t,s){return`data:${s};base64,${t}`}async function vet(t,s,r){const n=await fetch(t,s);if(n.status===404)throw new Error(`Resource "${n.url}" not found`);const a=await n.blob();return new Promise((o,l)=>{const i=new FileReader;i.onerror=l,i.onloadend=()=>{try{o(r({res:n,result:i.result}))}catch(d){l(d)}},i.readAsDataURL(a)})}const $pe={};function k0s(t,s,r){let n=t.replace(/\?.*/,"");return r&&(n=t),/ttf|otf|eot|woff2?/i.test(n)&&(n=n.replace(/.*\//,"")),s?`[${s}]${n}`:n}async function J2e(t,s,r){const n=k0s(t,s,r.includeQueryParams);if($pe[n]!=null)return $pe[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let a;try{const o=await vet(t,r.fetchRequestInit,({res:l,result:i})=>(s||(s=l.headers.get("Content-Type")||""),j0s(i)));a=N0s(o,s)}catch(o){a=r.imagePlaceholder||"";let l=`Failed to fetch resource: ${t}`;o&&(l=typeof o=="string"?o:o.message),l&&console.warn(l)}return $pe[n]=a,a}async function S0s(t){const s=t.toDataURL();return s==="data:,"?t.cloneNode(!1):Zie(s)}async function C0s(t,s){if(t.currentSrc){const o=document.createElement("canvas"),l=o.getContext("2d");o.width=t.clientWidth,o.height=t.clientHeight,l==null||l.drawImage(t,0,0,o.width,o.height);const i=o.toDataURL();return Zie(i)}const r=t.poster,n=Q2e(r),a=await J2e(r,n,s);return Zie(a)}async function M0s(t,s){var r;try{if(!((r=t==null?void 0:t.contentDocument)===null||r===void 0)&&r.body)return await Uce(t.contentDocument.body,s,!0)}catch{}return t.cloneNode(!1)}async function T0s(t,s){return Bm(t,HTMLCanvasElement)?S0s(t):Bm(t,HTMLVideoElement)?C0s(t,s):Bm(t,HTMLIFrameElement)?M0s(t,s):t.cloneNode(_et(t))}const A0s=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",_et=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function E0s(t,s,r){var n,a;if(_et(s))return s;let o=[];return A0s(t)&&t.assignedNodes?o=k_(t.assignedNodes()):Bm(t,HTMLIFrameElement)&&(!((n=t.contentDocument)===null||n===void 0)&&n.body)?o=k_(t.contentDocument.body.childNodes):o=k_(((a=t.shadowRoot)!==null&&a!==void 0?a:t).childNodes),o.length===0||Bm(t,HTMLVideoElement)||await o.reduce((l,i)=>l.then(()=>Uce(i,r)).then(d=>{d&&s.appendChild(d)}),Promise.resolve()),s}function P0s(t,s,r){const n=s.style;if(!n)return;const a=window.getComputedStyle(t);a.cssText?(n.cssText=a.cssText,n.transformOrigin=a.transformOrigin):xet(r).forEach(o=>{let l=a.getPropertyValue(o);o==="font-size"&&l.endsWith("px")&&(l=`${Math.floor(parseFloat(l.substring(0,l.length-2)))-.1}px`),Bm(t,HTMLIFrameElement)&&o==="display"&&l==="inline"&&(l="block"),o==="d"&&s.getAttribute("d")&&(l=`path(${s.getAttribute("d")})`),n.setProperty(o,l,a.getPropertyPriority(o))})}function I0s(t,s){Bm(t,HTMLTextAreaElement)&&(s.innerHTML=t.value),Bm(t,HTMLInputElement)&&s.setAttribute("value",t.value)}function L0s(t,s){if(Bm(t,HTMLSelectElement)){const r=s,n=Array.from(r.children).find(a=>t.value===a.getAttribute("value"));n&&n.setAttribute("selected","")}}function D0s(t,s,r){return Bm(s,Element)&&(P0s(t,s,r),_0s(t,s,r),I0s(t,s),L0s(t,s)),s}async function O0s(t,s){const r=t.querySelectorAll?t.querySelectorAll("use"):[];if(r.length===0)return t;const n={};for(let o=0;oT0s(n,s)).then(n=>E0s(t,n,s)).then(n=>D0s(t,n,s)).then(n=>O0s(n,s))}const bet=/url\((['"]?)([^'"]+?)\1\)/g,R0s=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,F0s=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function z0s(t){const s=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${s})(['"]?\\))`,"g")}function B0s(t){const s=[];return t.replace(bet,(r,n,a)=>(s.push(a),r)),s.filter(r=>!nve(r))}async function $0s(t,s,r,n,a){try{const o=r?c0s(s,r):s,l=Q2e(s);let i;return a||(i=await J2e(o,l,n)),t.replace(z0s(s),`$1${i}$3`)}catch{}return t}function q0s(t,{preferredFontFormat:s}){return s?t.replace(F0s,r=>{for(;;){const[n,,a]=R0s.exec(r)||[];if(!a)return"";if(a===s)return`src: ${n};`}}):t}function wet(t){return t.search(bet)!==-1}async function jet(t,s,r){if(!wet(t))return t;const n=q0s(t,r);return B0s(n).reduce((o,l)=>o.then(i=>$0s(i,l,s,r)),Promise.resolve(n))}async function b4(t,s,r){var n;const a=(n=s.style)===null||n===void 0?void 0:n.getPropertyValue(t);if(a){const o=await jet(a,null,r);return s.style.setProperty(t,o,s.style.getPropertyPriority(t)),!0}return!1}async function U0s(t,s){await b4("background",t,s)||await b4("background-image",t,s),await b4("mask",t,s)||await b4("-webkit-mask",t,s)||await b4("mask-image",t,s)||await b4("-webkit-mask-image",t,s)}async function V0s(t,s){const r=Bm(t,HTMLImageElement);if(!(r&&!nve(t.src))&&!(Bm(t,SVGImageElement)&&!nve(t.href.baseVal)))return;const n=r?t.src:t.href.baseVal,a=await J2e(n,Q2e(n),s);await new Promise((o,l)=>{t.onload=o,t.onerror=s.onImageErrorHandler?(...d)=>{try{o(s.onImageErrorHandler(...d))}catch(u){l(u)}}:l;const i=t;i.decode&&(i.decode=o),i.loading==="lazy"&&(i.loading="eager"),r?(t.srcset="",t.src=a):t.href.baseVal=a})}async function H0s(t,s){const n=k_(t.childNodes).map(a=>Net(a,s));await Promise.all(n).then(()=>t)}async function Net(t,s){Bm(t,Element)&&(await U0s(t,s),await V0s(t,s),await H0s(t,s))}function W0s(t,s){const{style:r}=t;s.backgroundColor&&(r.backgroundColor=s.backgroundColor),s.width&&(r.width=`${s.width}px`),s.height&&(r.height=`${s.height}px`);const n=s.style;return n!=null&&Object.keys(n).forEach(a=>{r[a]=n[a]}),t}const lDe={};async function cDe(t){let s=lDe[t];if(s!=null)return s;const n=await(await fetch(t)).text();return s={url:t,cssText:n},lDe[t]=s,s}async function dDe(t,s){let r=t.cssText;const n=/url\(["']?([^"')]+)["']?\)/g,o=(r.match(/url\([^)]+\)/g)||[]).map(async l=>{let i=l.replace(n,"$1");return i.startsWith("https://")||(i=new URL(i,t.url).href),vet(i,s.fetchRequestInit,({result:d})=>(r=r.replace(l,`url(${d})`),[l,d]))});return Promise.all(o).then(()=>r)}function uDe(t){if(t==null)return[];const s=[],r=/(\/\*[\s\S]*?\*\/)/gi;let n=t.replace(r,"");const a=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const d=a.exec(n);if(d===null)break;s.push(d[0])}n=n.replace(a,"");const o=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,l="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",i=new RegExp(l,"gi");for(;;){let d=o.exec(n);if(d===null){if(d=i.exec(n),d===null)break;o.lastIndex=i.lastIndex}else i.lastIndex=o.lastIndex;s.push(d[0])}return s}async function G0s(t,s){const r=[],n=[];return t.forEach(a=>{if("cssRules"in a)try{k_(a.cssRules||[]).forEach((o,l)=>{if(o.type===CSSRule.IMPORT_RULE){let i=l+1;const d=o.href,u=cDe(d).then(p=>dDe(p,s)).then(p=>uDe(p).forEach(f=>{try{a.insertRule(f,f.startsWith("@import")?i+=1:a.cssRules.length)}catch(y){console.error("Error inserting rule from remote css",{rule:f,error:y})}})).catch(p=>{console.error("Error loading remote css",p.toString())});n.push(u)}})}catch(o){const l=t.find(i=>i.href==null)||document.styleSheets[0];a.href!=null&&n.push(cDe(a.href).then(i=>dDe(i,s)).then(i=>uDe(i).forEach(d=>{l.insertRule(d,l.cssRules.length)})).catch(i=>{console.error("Error loading remote stylesheet",i)})),console.error("Error inlining remote css file",o)}}),Promise.all(n).then(()=>(t.forEach(a=>{if("cssRules"in a)try{k_(a.cssRules||[]).forEach(o=>{r.push(o)})}catch(o){console.error(`Error while reading CSS rules from ${a.href}`,o)}}),r))}function K0s(t){return t.filter(s=>s.type===CSSRule.FONT_FACE_RULE).filter(s=>wet(s.style.getPropertyValue("src")))}async function Z0s(t,s){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=k_(t.ownerDocument.styleSheets),n=await G0s(r,s);return K0s(n)}function ket(t){return t.trim().replace(/["']/g,"")}function Y0s(t){const s=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(o=>{s.add(ket(o))}),Array.from(n.children).forEach(o=>{o instanceof HTMLElement&&r(o)})}return r(t),s}async function X0s(t,s){const r=await Z0s(t,s),n=Y0s(t);return(await Promise.all(r.filter(o=>n.has(ket(o.style.fontFamily))).map(o=>{const l=o.parentStyleSheet?o.parentStyleSheet.href:null;return jet(o.cssText,l,s)}))).join(` `)}async function Q0s(t,s){const r=s.fontEmbedCSS!=null?s.fontEmbedCSS:s.skipFonts?null:await X0s(t,s);if(r){const n=document.createElement("style"),a=document.createTextNode(r);n.appendChild(a),t.firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n)}}async function J0s(t,s={}){const{width:r,height:n}=yet(t,s),a=await Uce(t,s,!0);return await Q0s(a,s),await Net(a,s),W0s(a,s),await g0s(a,r,n)}async function evs(t,s={}){const{width:r,height:n}=yet(t,s),a=await J0s(t,s),o=await Zie(a),l=document.createElement("canvas"),i=l.getContext("2d"),d=s.pixelRatio||m0s(),u=s.canvasWidth||r,p=s.canvasHeight||n;return l.width=u*d,l.height=p*d,s.skipAutoScale||p0s(l),l.style.width=`${u}`,l.style.height=`${p}`,s.backgroundColor&&(i.fillStyle=s.backgroundColor,i.fillRect(0,0,l.width,l.height)),i.drawImage(o,0,0,l.width,l.height),l}async function tvs(t,s={}){return(await evs(t,s)).toDataURL()}const lM=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),Vce={"just-listed":"JUST LISTED","just-sold":"JUST SOLD","open-house":"OPEN HOUSE","price-drop":"PRICE DROP"},qR={"instagram-square":{width:1080,height:1080},"instagram-story":{width:1080,height:1920},"facebook-post":{width:1200,height:630}},svs=({branding:t,dim:s})=>!(t!=null&&t.enabled)||!t.agentName?null:e.jsxs("div",{style:{marginTop:s.w*.03,borderTop:"2px solid rgba(201,168,76,0.4)",paddingTop:s.w*.025,display:"flex",alignItems:"center",gap:s.w*.025},children:[t.agentPhotoUrl&&e.jsx("img",{src:t.agentPhotoUrl,alt:"",crossOrigin:"anonymous",style:{width:s.w*.12,height:s.w*.12,borderRadius:"50%",objectFit:"cover",border:"3px solid rgba(201,168,76,0.7)"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:s.w*.038,fontWeight:700,letterSpacing:"0.03em"},children:t.agentName}),t.brokerage&&e.jsx("div",{style:{fontSize:s.w*.026,opacity:.8,marginTop:s.w*.005},children:t.brokerage})]})]}),Cet=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var f;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,d=(f=t.photos)==null?void 0:f[a],u=Vce[s],p=[t.bedrooms?`${t.bedrooms} Bed`:null,t.bathrooms?`${t.bathrooms} Bath`:null,t.sqft?`${t.sqft.toLocaleString()} Sq Ft`:null].filter(Boolean).join(" • ");return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Georgia', 'Times New Roman', serif",color:"#FFFFFF"},children:[d&&e.jsx("img",{src:d,alt:"",crossOrigin:"anonymous",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:0,background:"linear-gradient(180deg, rgba(10,10,30,0.3) 0%, rgba(10,10,30,0.85) 100%)"}}),e.jsxs("div",{style:{position:"relative",height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between",padding:l.w*.06},children:[e.jsx("div",{children:e.jsx("div",{style:{display:"inline-block",background:"linear-gradient(135deg, #C9A84C, #E8D48B)",color:"#1A1A2E",padding:`${l.w*.012}px ${l.w*.035}px`,fontSize:l.w*.032,fontWeight:700,letterSpacing:"0.25em",textTransform:"uppercase"},children:u})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:l.w*.07,fontWeight:700,lineHeight:1.1,marginBottom:l.w*.015,textShadow:"0 2px 12px rgba(0,0,0,0.5)"},children:lM(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.028,color:"#C9A84C",marginBottom:l.w*.01},children:["Sold for ",lM(t.soldPrice)]}),e.jsx("div",{style:{fontSize:l.w*.028,opacity:.9,marginBottom:l.w*.008},children:t.address}),e.jsxs("div",{style:{fontSize:l.w*.022,opacity:.7,marginBottom:l.w*.02},children:[t.city,", ",t.state," ",t.zip]}),e.jsx("div",{style:{display:"flex",gap:l.w*.015,fontSize:l.w*.022,letterSpacing:"0.05em",borderTop:"1px solid rgba(201,168,76,0.4)",paddingTop:l.w*.02},children:e.jsx("span",{children:p})}),s==="open-house"&&e.jsx("div",{style:{marginTop:l.w*.02,background:"rgba(201,168,76,0.15)",border:"1px solid rgba(201,168,76,0.4)",padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.024,letterSpacing:"0.1em",display:"inline-block"},children:"SAT & SUN • 1–4 PM"}),e.jsx(svs,{branding:n,dim:l})]})]})]})});Cet.displayName="LuxuryDarkTemplate";const rvs=({branding:t,dim:s,accentColor:r})=>!(t!=null&&t.enabled)||!t.agentName?null:e.jsxs("div",{style:{borderTop:"2px solid #E5E7EB",paddingTop:s.w*.025,display:"flex",alignItems:"center",justifyContent:"center",gap:s.w*.025},children:[t.agentPhotoUrl&&e.jsx("img",{src:t.agentPhotoUrl,alt:"",crossOrigin:"anonymous",style:{width:s.w*.14,height:s.w*.14,borderRadius:"50%",objectFit:"cover",border:`3px solid ${r}`,flexShrink:0}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:s.w*.042,fontWeight:800,color:"#1A1A1A"},children:t.agentName}),t.brokerage&&e.jsx("div",{style:{fontSize:s.w*.028,color:"#6B7280",marginTop:s.w*.005},children:t.brokerage})]})]}),Met=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var _;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,d=(_=t.photos)==null?void 0:_[a],u=Vce[s],p=r==="instagram-story",f=r==="facebook-post",y=s==="just-sold"?"#7C3AED":s==="open-house"?"#2563EB":s==="price-drop"?"#DC2626":"#059669";return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Helvetica Neue', Arial, sans-serif",color:"#1A1A1A",background:"#FFFFFF",display:"flex",flexDirection:f?"row":"column"},children:[e.jsxs("div",{style:{width:f?"55%":"100%",height:f?"100%":p?"50%":"52%",position:"relative",overflow:"hidden",flexShrink:0},children:[d&&e.jsx("img",{src:d,alt:"",crossOrigin:"anonymous",style:{width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",top:l.w*.04,left:0,background:y,color:"#FFFFFF",padding:`${l.w*.012}px ${l.w*.04}px`,fontSize:l.w*.026,fontWeight:800,letterSpacing:"0.15em"},children:u})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",padding:l.w*.05},children:[e.jsx("div",{style:{fontSize:l.w*(f?.055:.065),fontWeight:800,lineHeight:1.1,color:y,marginBottom:l.w*.012},children:lM(t.price)}),e.jsx("div",{style:{fontSize:l.w*.026,fontWeight:600,marginBottom:l.w*.006},children:t.address}),e.jsxs("div",{style:{fontSize:l.w*.02,color:"#6B7280",marginBottom:l.w*.02},children:[t.city,", ",t.state," ",t.zip]}),e.jsxs("div",{style:{display:"flex",gap:l.w*.03,marginBottom:l.w*.02},children:[t.bedrooms>0&&e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:l.w*.035,fontWeight:700},children:t.bedrooms}),e.jsx("div",{style:{fontSize:l.w*.016,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.1em"},children:"Beds"})]}),t.bathrooms>0&&e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:l.w*.035,fontWeight:700},children:t.bathrooms}),e.jsx("div",{style:{fontSize:l.w*.016,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.1em"},children:"Baths"})]}),t.sqft>0&&e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:l.w*.035,fontWeight:700},children:t.sqft.toLocaleString()}),e.jsx("div",{style:{fontSize:l.w*.016,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.1em"},children:"Sq Ft"})]})]}),s==="open-house"&&e.jsx("div",{style:{background:`${y}10`,border:`2px solid ${y}`,borderRadius:l.w*.01,padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.022,fontWeight:700,color:y,display:"inline-block",marginBottom:l.w*.015},children:"SAT & SUN • 1–4 PM"}),e.jsx(rvs,{branding:n,dim:l,accentColor:y})]})]})});Met.displayName="ModernCleanTemplate";const nvs=({branding:t,dim:s})=>!(t!=null&&t.enabled)||!t.agentName?null:e.jsxs("div",{style:{marginTop:s.w*.025,display:"flex",alignItems:"center",gap:s.w*.02},children:[t.agentPhotoUrl&&e.jsx("img",{src:t.agentPhotoUrl,alt:"",crossOrigin:"anonymous",style:{width:s.w*.12,height:s.w*.12,borderRadius:"50%",objectFit:"cover",border:"3px solid rgba(255,255,255,0.5)"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:s.w*.035,fontWeight:900},children:t.agentName}),t.brokerage&&e.jsx("div",{style:{fontSize:s.w*.024,opacity:.8,marginTop:s.w*.004,fontFamily:"'Helvetica Neue', sans-serif",fontWeight:400},children:t.brokerage})]})]}),Tet=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var y;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,d=(y=t.photos)==null?void 0:y[a],u=Vce[s],p={"just-listed":"linear-gradient(135deg, #059669, #10B981)","just-sold":"linear-gradient(135deg, #7C3AED, #A855F7)","open-house":"linear-gradient(135deg, #2563EB, #3B82F6)","price-drop":"linear-gradient(135deg, #DC2626, #F43F5E)"},f=[t.bedrooms?`${t.bedrooms} BD`:null,t.bathrooms?`${t.bathrooms} BA`:null,t.sqft?`${t.sqft.toLocaleString()} SF`:null].filter(Boolean).join(" | ");return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Arial Black', 'Helvetica Neue', sans-serif",color:"#FFFFFF"},children:[d&&e.jsx("img",{src:d,alt:"",crossOrigin:"anonymous",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.4)"}}),e.jsxs("div",{style:{position:"relative",height:"100%",display:"flex",flexDirection:"column",padding:l.w*.05},children:[e.jsx("div",{style:{background:p[s],padding:`${l.w*.025}px ${l.w*.04}px`,fontSize:l.w*.055,fontWeight:900,letterSpacing:"0.08em",alignSelf:"flex-start",borderRadius:l.w*.01,boxShadow:"0 8px 32px rgba(0,0,0,0.3)",transform:"rotate(-2deg)",marginBottom:l.w*.03},children:u}),e.jsx("div",{style:{flex:1}}),e.jsxs("div",{style:{background:"rgba(0,0,0,0.65)",backdropFilter:"blur(10px)",borderRadius:l.w*.015,padding:l.w*.04},children:[e.jsx("div",{style:{fontSize:l.w*.08,fontWeight:900,lineHeight:1,marginBottom:l.w*.01},children:lM(t.price)}),e.jsx("div",{style:{fontSize:l.w*.028,fontWeight:700,marginBottom:l.w*.005},children:t.address}),e.jsxs("div",{style:{fontSize:l.w*.022,opacity:.8,marginBottom:l.w*.015},children:[t.city,", ",t.state," ",t.zip]}),e.jsx("div",{style:{display:"inline-block",background:"rgba(255,255,255,0.15)",borderRadius:l.w*.008,padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.022,fontWeight:700,letterSpacing:"0.08em"},children:f}),s==="open-house"&&e.jsx("div",{style:{marginTop:l.w*.015,background:p["open-house"],borderRadius:l.w*.008,padding:`${l.w*.012}px ${l.w*.025}px`,fontSize:l.w*.024,fontWeight:800,display:"inline-block",marginLeft:l.w*.01},children:"SAT & SUN 1–4 PM"}),e.jsx(nvs,{branding:n,dim:l})]})]})]})});Tet.displayName="BoldColorfulTemplate";const avs=({branding:t,dim:s})=>!(t!=null&&t.enabled)||!t.agentName?null:e.jsxs("div",{style:{marginTop:"auto",display:"flex",alignItems:"center",gap:s.w*.02},children:[t.agentPhotoUrl&&e.jsx("img",{src:t.agentPhotoUrl,alt:"",crossOrigin:"anonymous",style:{width:s.w*.11,height:s.w*.11,borderRadius:"50%",objectFit:"cover",border:"3px solid #8B7355"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:s.w*.032,fontWeight:700,color:"#1A1A1A"},children:t.agentName}),t.brokerage&&e.jsx("div",{style:{fontSize:s.w*.022,color:"#8B7355",marginTop:s.w*.004},children:t.brokerage})]})]}),Aet=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var f;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,d=(f=t.photos)==null?void 0:f[a],u=Vce[s],p=r==="instagram-story";return e.jsx("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Georgia', 'Times New Roman', serif",color:"#1A1A1A",background:"#F5F0EB"},children:e.jsxs("div",{style:{display:"flex",flexDirection:p?"column":"row",height:"100%"},children:[e.jsxs("div",{style:{width:p?"100%":"42%",height:p?"40%":"100%",display:"flex",flexDirection:"column",justifyContent:"center",padding:l.w*.05,order:p?2:1},children:[e.jsx("div",{style:{fontSize:l.w*.016,letterSpacing:"0.3em",textTransform:"uppercase",color:"#8B7355",borderBottom:"2px solid #8B7355",paddingBottom:l.w*.01,marginBottom:l.w*.025,display:"inline-block",alignSelf:"flex-start"},children:u}),e.jsx("div",{style:{fontSize:l.w*(p?.06:.055),fontWeight:700,lineHeight:1.1,marginBottom:l.w*.015,fontStyle:"italic"},children:lM(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.02,color:"#8B7355",marginBottom:l.w*.01},children:["Sold: ",lM(t.soldPrice)]}),e.jsxs("div",{style:{fontSize:l.w*.022,lineHeight:1.5,marginBottom:l.w*.02},children:[t.address,e.jsx("br",{}),t.city,", ",t.state," ",t.zip]}),e.jsxs("div",{style:{display:"flex",gap:l.w*.02,fontSize:l.w*.016,color:"#6B5D4E",borderTop:"1px solid #D1C7B7",paddingTop:l.w*.015,marginBottom:l.w*.015,flexWrap:"wrap"},children:[t.bedrooms>0&&e.jsxs("span",{children:[t.bedrooms," Bedrooms"]}),t.bedrooms>0&&t.bathrooms>0&&e.jsx("span",{children:"·"}),t.bathrooms>0&&e.jsxs("span",{children:[t.bathrooms," Bathrooms"]}),t.sqft>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[t.sqft.toLocaleString()," Sq Ft"]})]})]}),s==="open-house"&&e.jsx("div",{style:{fontSize:l.w*.018,fontStyle:"italic",color:"#8B7355",marginBottom:l.w*.01},children:"Open House: Saturday & Sunday, 1–4 PM"}),e.jsx(avs,{branding:n,dim:l})]}),e.jsxs("div",{style:{width:p?"100%":"58%",height:p?"60%":"100%",position:"relative",overflow:"hidden",order:p?1:2},children:[d&&e.jsx("img",{src:d,alt:"",crossOrigin:"anonymous",style:{width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:l.w*.02,border:"1px solid rgba(255,255,255,0.4)",pointerEvents:"none"}})]})]})})});Aet.displayName="EditorialTemplate";const ivs=[{value:"just-listed",label:"Just Listed",icon:"🏠"},{value:"just-sold",label:"Just Sold",icon:"🎉"},{value:"open-house",label:"Open House",icon:"🚪"},{value:"price-drop",label:"Price Drop",icon:"📉"}],hDe=[{value:"instagram-square",label:"Instagram Post",dimensions:"1080×1080",icon:e.jsx(Wd,{className:"h-4 w-4"})},{value:"instagram-story",label:"Instagram Story",dimensions:"1080×1920",icon:e.jsx(Wd,{className:"h-4 w-4"})},{value:"facebook-post",label:"Facebook Post",dimensions:"1200×630",icon:e.jsx(Hd,{className:"h-4 w-4"})}],ovs=[{value:"luxury-dark",label:"Luxury Dark",description:"Dark & gold, high-end feel",preview:"🌙"},{value:"modern-clean",label:"Modern Clean",description:"White, bold, contemporary",preview:"✨"},{value:"bold-colorful",label:"Bold & Vibrant",description:"Energetic gradients & punch",preview:"🔥"},{value:"editorial",label:"Editorial",description:"Magazine-style sophistication",preview:"📰"}],mDe=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),pDe={"luxury-dark":Cet,"modern-clean":Met,"bold-colorful":Tet,editorial:Aet};function lvs(){const[t,s]=C.useState(""),[r,n]=C.useState("address"),[a,o]=C.useState(!1),[l,i]=C.useState([]),[d,u]=C.useState(null),[p,f]=C.useState(0),[y,_]=C.useState("just-listed"),[b,w]=C.useState(["instagram-square"]),[j,k]=C.useState("luxury-dark"),[S,T]=C.useState(!1),[I,L]=C.useState(""),[R,$]=C.useState(""),[q,U]=C.useState(""),[H,Y]=C.useState(!1),[se,te]=C.useState(!1),[Q,de]=C.useState([]),[re,ae]=C.useState("search"),le=C.useRef({});C.useEffect(()=>{(async()=>{const{data:{user:Fe}}=await G.auth.getUser();if(!Fe)return;const{data:Ae}=await G.from("profiles").select("name, avatar_url, brokerages(name)").eq("id",Fe.id).single();if(Ae){L(Ae.name||""),U(Ae.avatar_url||"");const Ue=Ae.brokerages;$((Ue==null?void 0:Ue.name)||"")}})()},[]);const he=async()=>{var Te;if(t.trim()){o(!0),i([]);try{const{data:Fe,error:Ae}=await G.functions.invoke("repliers-mls-search",{body:{searchType:r,query:t.trim()}});if(Ae)throw Ae;if(Fe.error)throw new Error(Fe.error);i(Fe.listings||[]),((Te=Fe.listings)==null?void 0:Te.length)===0&&fe.info("No listings found. Try a different search.")}catch(Fe){fe.error(Fe.message||"Search failed")}finally{o(!1)}}},be=Te=>{var Fe;u(Te),f(0),ae("customize"),Te.soldDate||(Fe=Te.status)!=null&&Fe.toLowerCase().includes("sold")?_("just-sold"):_("just-listed")},_e=Te=>{w(Fe=>Fe.includes(Te)?Fe.filter(Ae=>Ae!==Te):[...Fe,Te])},je=C.useCallback(async()=>{if(!(!d||b.length===0)){Y(!0),de([]),ae("generate");try{await new Promise(Fe=>setTimeout(Fe,500));const Te=[];for(const Fe of b){const Ae=`${j}-${Fe}`,Ue=le.current[Ae];if(!Ue)continue;const ut=qR[Fe],De=await tvs(Ue,{width:ut.width,height:ut.height,pixelRatio:1,cacheBust:!0,style:{transform:"none",transformOrigin:"top left"}});Te.push({format:Fe,imageUrl:De})}de(Te),fe.success(`Generated ${Te.length} social post${Te.length>1?"s":""}!`)}catch(Te){fe.error(Te.message||"Generation failed")}finally{Y(!1)}}},[d,b,j,p,S,I,R,q,y]),Ne=async()=>{if(!(!d||b.length===0)){Y(!0),de([]),ae("generate");try{const Te={...d,photos:d.photos.length>0?[d.photos[p]]:[]},Fe=[];for(const Ae of b){const{data:Ue,error:ut}=await G.functions.invoke("generate-listing-social-post",{body:{listing:Te,postType:y,format:Ae,branding:S?{enabled:!0,agentName:I,brokerage:R}:{enabled:!1}}});if(ut)throw ut;if(Ue.error)throw new Error(Ue.error);Fe.push({format:Ae,imageUrl:Ue.imageUrl})}de(Fe),fe.success(`Generated ${Fe.length} AI post${Fe.length>1?"s":""}!`)}catch(Te){fe.error(Te.message||"AI generation failed")}finally{Y(!1)}}},Ge=()=>se?Ne():je(),we=(Te,Fe)=>{var Ue;const Ae=document.createElement("a");Ae.href=Te,Ae.download=`${((Ue=d==null?void 0:d.address)==null?void 0:Ue.replace(/\s+/g,"-"))||"listing"}-${y}-${Fe}.png`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae)},Me=d?{listing:d,postType:y,format:"instagram-square",branding:S?{enabled:!0,agentName:I,brokerage:R,agentPhotoUrl:q||void 0}:{enabled:!1},selectedPhotoIndex:p}:null;return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(wu,{title:"Social Post Generator",description:"Search MLS listings and generate stunning social media posts"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsxs("button",{onClick:()=>ae("search"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${re==="search"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"}`,children:[e.jsx(gn,{className:"h-3.5 w-3.5"})," 1. Find Listing"]}),e.jsx(Ua,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("button",{onClick:()=>d&&ae("customize"),disabled:!d,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${re==="customize"?"bg-primary text-primary-foreground":d?"bg-muted text-muted-foreground hover:text-foreground":"bg-muted text-muted-foreground/50 cursor-not-allowed"}`,children:[e.jsx(hn,{className:"h-3.5 w-3.5"})," 2. Customize"]}),e.jsx(Ua,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full ${re==="generate"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground/50"}`,children:[e.jsx(Jo,{className:"h-3.5 w-3.5"})," 3. Generate"]})]}),re==="search"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(gn,{className:"h-5 w-5 text-primary"})," Search MLS Listings ",e.jsx(PVe,{})]}),e.jsx(pr,{children:"Find a listing by MLS number or property address using Repliers.io"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(ka,{value:r,onValueChange:Te=>n(Te),children:e.jsxs(_a,{children:[e.jsxs(js,{value:"address",children:[e.jsx(Oi,{className:"h-4 w-4 mr-1.5"})," Address"]}),e.jsxs(js,{value:"mls",children:[e.jsx(Wh,{className:"h-4 w-4 mr-1.5"})," MLS #"]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:t,onChange:Te=>s(Te.target.value),placeholder:r==="mls"?"Enter MLS number...":"Enter property address...",className:"flex-1",onKeyDown:Te=>Te.key==="Enter"&&he()}),e.jsxs(K,{onClick:he,disabled:a||!t.trim(),children:[a?e.jsx(Ms,{className:"h-4 w-4 animate-spin"}):e.jsx(gn,{className:"h-4 w-4"})," Search"]})]})]})]}),l.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-sm font-medium text-muted-foreground",children:[l.length," listing",l.length!==1?"s":""," found"]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:l.map((Te,Fe)=>{var Ae;return e.jsx(Ee,{className:"cursor-pointer hover:border-primary/50 hover:shadow-md transition-all group",onClick:()=>be(Te),children:e.jsx(Oe,{className:"p-0",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"w-32 h-28 flex-shrink-0 bg-muted rounded-l-lg overflow-hidden",children:(Ae=Te.photos)!=null&&Ae[0]?e.jsx("img",{src:Te.photos[0],alt:Te.address,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(On,{className:"h-8 w-8 text-muted-foreground/40"})})}),e.jsxs("div",{className:"flex-1 p-3 min-w-0",children:[e.jsx("p",{className:"font-bold text-foreground",children:mDe(Te.price)}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:Te.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Te.city,", ",Te.state," ",Te.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-xs text-muted-foreground",children:[Te.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(iP,{className:"h-3 w-3"})," ",Te.bedrooms]}),Te.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Zx,{className:"h-3 w-3"})," ",Te.bathrooms]}),Te.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(bP,{className:"h-3 w-3"})," ",Te.sqft.toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(rt,{variant:"outline",className:"text-[10px]",children:Te.mlsNumber}),e.jsx(rt,{variant:"outline",className:"text-[10px]",children:Te.status})]})]})]})})},Te.mlsNumber||Fe)})})]})]}),re==="customize"&&d&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(Ee,{className:"lg:col-span-1",children:[e.jsx(It,{className:"pb-3",children:e.jsx(Ot,{className:"text-base",children:"Selected Listing"})}),e.jsxs(Oe,{className:"space-y-3",children:[d.photos.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[4/3] rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:d.photos[p],alt:"Listing photo",className:"w-full h-full object-cover"})}),d.photos.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(Te=>Math.max(0,Te-1)),disabled:p===0,children:e.jsx(zl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p+1," of ",d.photos.length]}),e.jsx(K,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(Te=>Math.min(d.photos.length-1,Te+1)),disabled:p===d.photos.length-1,children:e.jsx(Ua,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-lg",children:mDe(d.price)}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[d.city,", ",d.state," ",d.zip]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[d.bedrooms>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:d.bedrooms}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Beds"})]}),d.bathrooms>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:d.bathrooms}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Baths"})]}),d.sqft>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:d.sqft.toLocaleString()}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Sq Ft"})]})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{ae("search"),u(null)},children:[e.jsx(q0,{className:"h-3.5 w-3.5 mr-1.5"})," Choose Different Listing"]})]})]}),e.jsxs(Ee,{className:"lg:col-span-2",children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5 text-primary"})," Customize Your Post"]}),e.jsx(pr,{children:"Choose template, post type, format, and branding"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bl,{className:"h-4 w-4 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:se?"AI Custom Generation":"Template-Based (Free)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:se?"Uses AI credits for unique designs":"Instant, no credits used"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Use AI"}),e.jsx(Br,{checked:se,onCheckedChange:te}),se&&e.jsx(x0,{className:"h-4 w-4 text-purple-500"})]})]}),!se&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Bl,{className:"h-4 w-4"})," Template Style"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:ovs.map(Te=>e.jsxs("button",{onClick:()=>k(Te.value),className:`flex flex-col items-center gap-1 px-3 py-3 rounded-lg border-2 transition-all text-center ${j===Te.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-2xl",children:Te.preview}),e.jsx("span",{className:"text-sm font-medium",children:Te.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:Te.description})]},Te.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Post Type"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:ivs.map(Te=>e.jsxs("button",{onClick:()=>_(Te.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm font-medium ${y===Te.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-lg",children:Te.icon})," ",Te.label]},Te.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Output Formats"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:hDe.map(Te=>e.jsxs("button",{onClick:()=>_e(Te.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm ${b.includes(Te.value)?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[Te.icon,e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium",children:Te.label}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:Te.dimensions})]})]},Te.value))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ve,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Yi,{className:"h-4 w-4"})," Agent Branding"]}),e.jsx(Br,{checked:S,onCheckedChange:T})]}),S&&e.jsxs("div",{className:"space-y-3 pl-6 border-l-2 border-primary/20",children:[q&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:q,alt:"Agent",className:"w-12 h-12 rounded-full object-cover border-2 border-primary/30"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Profile photo will appear on the post"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Agent Name"}),e.jsx(Re,{value:I,onChange:Te=>L(Te.target.value),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Brokerage (optional)"}),e.jsx(Re,{value:R,onChange:Te=>$(Te.target.value),placeholder:"XYZ Realty"})]})]})]})]}),!se&&Me&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Preview"}),e.jsx("div",{className:"bg-muted/30 rounded-lg p-4 flex justify-center overflow-hidden",children:e.jsx("div",{style:{width:400,height:400*(qR[b[0]||"instagram-square"].height/qR[b[0]||"instagram-square"].width)},children:(()=>{const Te=pDe[j],Fe=b[0]||"instagram-square";return e.jsx(Te,{...Me,format:Fe})})()})})]}),e.jsx(K,{onClick:Ge,disabled:b.length===0||H,size:"lg",className:"w-full gap-2",children:H?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-5 w-5 animate-spin"})," Generating ",b.length," post",b.length>1?"s":"","..."]}):e.jsxs(e.Fragment,{children:[se?e.jsx(x0,{className:"h-5 w-5"}):e.jsx(hn,{className:"h-5 w-5"}),"Generate ",b.length," Social Post",b.length>1?"s":"",se&&e.jsx(rt,{variant:"outline",className:"ml-2 text-[10px]",children:"Uses Credits"})]})})]})]})]}),re==="generate"&&e.jsxs("div",{className:"space-y-4",children:[H&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(Ms,{className:"h-12 w-12 animate-spin text-primary mb-4"}),e.jsx("p",{className:"text-lg font-medium",children:"Generating your social posts..."}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:se?"AI is creating your unique designs":"Rendering templates to high-res images"})]})}),Q.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Generated Posts"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ae("customize"),children:[e.jsx(q0,{className:"h-3.5 w-3.5 mr-1.5"})," Regenerate"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Q.map((Te,Fe)=>{const Ae=hDe.find(Ue=>Ue.value===Te.format);return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 p-1",children:e.jsx("img",{src:Te.imageUrl,alt:`${Te.format} social post`,className:"w-full rounded"})}),e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[Ae==null?void 0:Ae.icon,e.jsx("span",{className:"text-sm font-medium",children:Ae==null?void 0:Ae.label})]}),e.jsx(rt,{variant:"outline",className:"text-[10px]",children:Ae==null?void 0:Ae.dimensions})]}),e.jsxs(K,{size:"sm",className:"w-full gap-1.5",onClick:()=>we(Te.imageUrl,Te.format),children:[e.jsx(xi,{className:"h-3.5 w-3.5"})," Download"]})]})]},Fe)})})]})]}),re==="generate"&&!se&&d&&Me&&e.jsx("div",{style:{position:"absolute",left:"-9999px",top:0},"aria-hidden":!0,children:b.map(Te=>{const Fe=pDe[j],Ae=qR[Te];return e.jsx("div",{style:{width:Ae.width,height:Ae.height},children:e.jsx(Fe,{ref:Ue=>{le.current[`${j}-${Te}`]=Ue},...Me,format:Te})},`${j}-${Te}`)})})]})})}function cvs(){return wt({queryKey:["lms-courses-admin"],queryFn:async()=>{const{data:t,error:s}=await G.from("lms_courses").select("*, modules:lms_modules(count), access:lms_course_access(*)").order("sort_order");if(s)throw s;return t}})}function dvs(t){return wt({queryKey:["lms-course-admin",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("lms_courses").select("*, modules:lms_modules(*, resources:lms_module_resources(*)), access:lms_course_access(*)").eq("id",t).single();if(r)throw r;return s!=null&&s.modules&&(s.modules.sort((n,a)=>n.sort_order-a.sort_order),s.modules.forEach(n=>{n.resources&&n.resources.sort((a,o)=>a.sort_order-o.sort_order)})),s},enabled:!!t})}function uvs(){const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("lms_courses").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>t.invalidateQueries({queryKey:["lms-courses"]})})}function Eet(){const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("lms_courses").update({...r,updated_at:new Date().toISOString()}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-courses"]}),t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-courses-admin"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function hvs(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("lms_courses").delete().eq("id",s);if(r)throw r},onSuccess:()=>t.invalidateQueries({queryKey:["lms-courses"]})})}function mvs(){const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("lms_modules").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function pvs(){const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("lms_modules").update({...r,updated_at:new Date().toISOString()}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function fvs(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("lms_modules").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function gvs(){const t=rs();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("lms_module_resources").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function xvs(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("lms_module_resources").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function yvs(){const t=rs();return Dt({mutationFn:async({courseId:s,accessRules:r})=>{const{error:n}=await G.from("lms_course_access").delete().eq("course_id",s);if(n)throw n;if(r.length>0){const a=r.map(l=>({...l,course_id:s})),{error:o}=await G.from("lms_course_access").insert(a);if(o)throw o}},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-courses"]}),t.invalidateQueries({queryKey:["lms-course"]})}})}function vvs(){return wt({queryKey:["lms-courses-agent"],queryFn:async()=>{const{data:t,error:s}=await G.from("lms_courses").select("*, modules:lms_modules(id)").eq("is_published",!0).order("sort_order");if(s)throw s;return t}})}function _vs(t){return wt({queryKey:["lms-course-agent",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("lms_courses").select("*, modules:lms_modules(*, resources:lms_module_resources(*))").eq("id",t).single();if(r)throw r;return s!=null&&s.modules&&(s.modules.sort((n,a)=>n.sort_order-a.sort_order),s.modules.forEach(n=>{n.resources&&n.resources.sort((a,o)=>a.sort_order-o.sort_order)})),s},enabled:!!t})}function Pet(t){return wt({queryKey:["lms-progress",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("lms_progress").select("*").eq("course_id",t);if(r)throw r;return s},enabled:!!t})}function bvs(){const t=rs();return Dt({mutationFn:async({courseId:s,moduleId:r,userId:n})=>{const{data:a,error:o}=await G.from("lms_progress").upsert({user_id:n,course_id:s,module_id:r,completed:!0,completed_at:new Date().toISOString()},{onConflict:"user_id,module_id"}).select().single();if(o)throw o;return a},onSuccess:()=>t.invalidateQueries({queryKey:["lms-progress"]})})}function wvs(){const{user:t}=Hs(),s=Pr(),{data:r,isLoading:n}=cvs(),a=uvs(),o=Eet(),l=hvs(),[i,d]=C.useState(!1),[u,p]=C.useState(""),[f,y]=C.useState(""),[_,b]=C.useState(!0),w=async()=>{if(!(!u.trim()||!t))try{const S=await a.mutateAsync({title:u.trim(),description:f.trim()||void 0,is_sequential:_,created_by:t.id});fe.success("Course created"),d(!1),p(""),y(""),b(!0),s(`/admin/lms/${S.id}`)}catch{fe.error("Failed to create course")}},j=async S=>{try{await o.mutateAsync({id:S.id,is_published:!S.is_published}),fe.success(S.is_published?"Course unpublished":"Course published")}catch{fe.error("Failed to update course")}},k=async S=>{if(confirm("Delete this course and all its modules? This cannot be undone."))try{await l.mutateAsync(S),fe.success("Course deleted")}catch{fe.error("Failed to delete")}};return e.jsxs(Ts,{title:"LevelUp U - Admin",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(ah,{className:"h-7 w-7 text-primary"}),"LevelUp U — Course Manager"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Create and manage training courses for your agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>s("/admin/lms/stats"),children:[e.jsx(ol,{className:"h-4 w-4 mr-2"}),"Analytics"]}),e.jsxs(K,{onClick:()=>d(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"New Course"]})]})]}),n?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:[1,2,3].map(S=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(It,{children:[e.jsx("div",{className:"h-5 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-2"})]})},S))}):r!=null&&r.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:r.map(S=>{var R,$;const T=(($=(R=S.modules)==null?void 0:R[0])==null?void 0:$.count)??0,I=S.access||[],L=I.length===0?"No access set":I.some(q=>q.access_type==="all")?"All agents":`${I.length} rule(s)`;return e.jsxs(Ee,{className:"group hover:shadow-md transition-all hover:border-primary/50 cursor-pointer",onClick:()=>s(`/admin/lms/${S.id}`),children:[e.jsx(It,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Ot,{className:"text-base truncate",children:S.title}),S.description&&e.jsx(pr,{className:"mt-1 line-clamp-2",children:S.description})]}),e.jsx(rt,{variant:S.is_published?"default":"secondary",className:"ml-2 shrink-0",children:S.is_published?"Published":"Draft"})]})}),e.jsxs(Oe,{className:"pt-0",children:[e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Fu,{className:"h-3.5 w-3.5"}),T," module",T!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[S.is_sequential?e.jsx(O0,{className:"h-3.5 w-3.5"}):e.jsx(pk,{className:"h-3.5 w-3.5"}),S.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hr,{className:"h-3.5 w-3.5"}),L]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsxs(K,{size:"sm",variant:"ghost",onClick:q=>{q.stopPropagation(),j(S)},children:[S.is_published?e.jsx(Im,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(xa,{className:"h-3.5 w-3.5 mr-1"}),S.is_published?"Unpublish":"Publish"]}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:q=>{q.stopPropagation(),k(S.id)},children:e.jsx(jr,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"flex-1"}),e.jsx($i,{className:"h-4 w-4 text-muted-foreground"})]})]})]},S.id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(Fu,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-1",children:"No courses yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mb-4",children:"Create your first training course to get started"}),e.jsxs(K,{onClick:()=>d(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create Course"]})]})})]}),e.jsx(_s,{open:i,onOpenChange:d,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Create New Course"}),e.jsx(Kr,{children:"Set up a new training course for your agents"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Course Title"}),e.jsx(Re,{value:u,onChange:S=>p(S.target.value),placeholder:"e.g. LevelUp Onboarding"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Ar,{value:f,onChange:S=>y(S.target.value),placeholder:"What will agents learn?",rows:3})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Sequential Learning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents must complete modules in order"})]}),e.jsx(Br,{checked:_,onCheckedChange:b})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{onClick:w,disabled:!u.trim()||a.isPending,children:a.isPending?"Creating...":"Create Course"})]})]})})]})}function jvs(){const{courseId:t}=ko(),s=Pr(),{data:r,isLoading:n}=dvs(t),a=Eet(),o=mvs(),l=pvs(),i=fvs(),d=gvs(),u=xvs(),p=yvs(),{data:f}=wt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:qe}=await G.from("brokerages").select("id, name").order("name");return qe||[]}}),[y,_]=C.useState(null),[b,w]=C.useState(!1),[j,k]=C.useState({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),[S,T]=C.useState(null),[I,L]=C.useState({title:"",resource_type:"link",url:""}),[R,$]=C.useState(new Set),[q,U]=C.useState(null),[H,Y]=C.useState(0),[se,te]=C.useState(!1),Q=C.useRef(null),de=C.useRef(null),[re,ae]=C.useState(!1),[le,he]=C.useState(""),[be,_e]=C.useState(""),[je,Ne]=C.useState(""),[Ge,we]=C.useState(!1);if(n)return e.jsx(Ts,{title:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})});if(!r)return e.jsx(Ts,{title:"Course Not Found",children:e.jsxs("div",{className:"text-center py-20",children:[e.jsx("p",{className:"text-muted-foreground",children:"Course not found"}),e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>s("/admin/lms"),children:[e.jsx(ti,{className:"h-4 w-4 mr-2"})," Back to Courses"]})]})});const Me=r.modules||[],Te=r.access||[],Fe=Te.some(qe=>qe.access_type==="all"),Ae=Te.filter(qe=>qe.access_type==="brokerage").map(qe=>qe.brokerage_id),Ue=(f||[]).filter(qe=>qe.name.toLowerCase().includes(le.toLowerCase())),ut=qe=>{const Ze=new Set(R);Ze.has(qe)?Ze.delete(qe):Ze.add(qe),$(Ze)},De=async()=>{if(!q)return null;te(!0),Y(0);try{const{data:qe,error:Ze}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:q.name}});if(Ze)throw new Error(Ze.message);const{videoId:Qe,libraryId:We}=qe,{data:He,error:et}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Qe,libraryId:We}});if(et)throw new Error(et.message);const Tt=new XMLHttpRequest;return await new Promise((Ft,as)=>{Tt.upload.onprogress=Xt=>{Xt.lengthComputable&&Y(Math.round(Xt.loaded/Xt.total*100))},Tt.onload=()=>Tt.status>=200&&Tt.status<300?Ft():as(new Error(`Upload failed: ${Tt.status}`)),Tt.onerror=()=>as(new Error("Upload failed")),Tt.open("PUT",He.uploadUrl),Tt.setRequestHeader("AccessKey",He.apiKey),Tt.send(q)}),`https://iframe.mediadelivery.net/embed/${We}/${Qe}`}catch(qe){return console.error("Bunny upload error:",qe),fe.error("Video upload failed"),null}finally{te(!1),Y(0)}},Rt=async()=>{if(j.title.trim())try{let qe=j.video_url.trim()||void 0;if(q){const Ze=await De();if(!Ze)return;qe=Ze}await o.mutateAsync({course_id:r.id,title:j.title.trim(),description:j.description.trim()||void 0,video_url:qe,text_content:j.text_content.trim()||void 0,duration_minutes:j.duration_minutes?parseInt(j.duration_minutes):void 0,sort_order:Me.length}),fe.success("Module added"),w(!1),k({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),U(null)}catch{fe.error("Failed to add module")}},me=async()=>{if(y)try{let qe=j.video_url.trim()||null;if(q){const Ze=await De();if(!Ze)return;qe=Ze}await l.mutateAsync({id:y.id,title:j.title.trim(),description:j.description.trim()||null,video_url:qe,text_content:j.text_content.trim()||null,duration_minutes:j.duration_minutes?parseInt(j.duration_minutes):null}),fe.success("Module updated"),_(null),U(null)}catch{fe.error("Failed to update")}},Xe=async qe=>{if(confirm("Delete this module?"))try{await i.mutateAsync(qe),fe.success("Module deleted")}catch{fe.error("Failed to delete")}},ot=async qe=>{if(I.title.trim())try{await d.mutateAsync({module_id:qe,title:I.title.trim(),resource_type:I.resource_type,url:I.url.trim()||void 0}),fe.success("Resource added"),T(null),L({title:"",resource_type:"link",url:""})}catch{fe.error("Failed to add resource")}},nt=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[{access_type:"all"}]}),fe.success("Access updated: All brokerages / all agents")}catch{fe.error("Failed to update access")}},Se=async qe=>{const Ze=Te.filter(et=>et.access_type==="brokerage").map(et=>et.brokerage_id),Qe=Ze.includes(qe);let We;Qe?We=Ze.filter(et=>et!==qe):We=[...Ze,qe];const He=We.map(et=>({access_type:"brokerage",brokerage_id:et}));try{await p.mutateAsync({courseId:r.id,accessRules:He}),fe.success(Qe?"Brokerage removed":"Brokerage added")}catch{fe.error("Failed to update access")}},it=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[]}),fe.success("Access cleared")}catch{fe.error("Failed")}},$e=async(qe,Ze)=>{const Qe=Ze==="up"?qe-1:qe+1;if(!(Qe<0||Qe>=Me.length))try{await Promise.all([l.mutateAsync({id:Me[qe].id,sort_order:Qe}),l.mutateAsync({id:Me[Qe].id,sort_order:qe})])}catch{fe.error("Failed to reorder")}},ct=async()=>{try{await a.mutateAsync({id:r.id,title:be,description:je||null}),fe.success("Course updated"),we(!1)}catch{fe.error("Failed to update")}};return e.jsxs(Ts,{title:r.title,children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/admin/lms"),children:e.jsx(ti,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:r.title}),e.jsx(rt,{variant:r.is_published?"default":"secondary",children:r.is_published?"Published":"Draft"})]}),r.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:r.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[r.is_sequential?e.jsx(O0,{className:"h-3.5 w-3.5"}):e.jsx(pk,{className:"h-3.5 w-3.5"}),r.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{children:[Me.length," module",Me.length!==1?"s":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{_e(r.title),Ne(r.description||""),we(!0)},children:[e.jsx(Da,{className:"h-3.5 w-3.5 mr-1"})," Edit"]}),e.jsxs(K,{variant:r.is_published?"secondary":"default",size:"sm",onClick:()=>a.mutateAsync({id:r.id,is_published:!r.is_published}).then(()=>fe.success(r.is_published?"Unpublished":"Published")),children:[r.is_published?e.jsx(Im,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(xa,{className:"h-3.5 w-3.5 mr-1"}),r.is_published?"Unpublish":"Publish"]})]})]}),e.jsxs(ka,{defaultValue:"modules",className:"w-full",children:[e.jsxs(_a,{children:[e.jsx(js,{value:"modules",children:"Modules"}),e.jsx(js,{value:"access",children:"Access & Permissions"}),e.jsx(js,{value:"settings",children:"Settings"})]}),e.jsxs(zs,{value:"modules",className:"mt-6 space-y-4",children:[Me.map((qe,Ze)=>e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>ut(qe.id),children:[e.jsx("span",{className:"flex items-center gap-1 text-muted-foreground",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("button",{onClick:Qe=>{Qe.stopPropagation(),$e(Ze,"up")},disabled:Ze===0,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(Ug,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:Qe=>{Qe.stopPropagation(),$e(Ze,"down")},disabled:Ze===Me.length-1,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(Ho,{className:"h-3.5 w-3.5"})})]})}),e.jsx(rt,{variant:"outline",className:"shrink-0 font-mono text-xs",children:Ze+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:qe.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:[qe.video_url&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Nn,{className:"h-3 w-3"})," Video"]}),qe.text_content&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(In,{className:"h-3 w-3"})," Text"]}),qe.duration_minutes&&e.jsxs("span",{children:[qe.duration_minutes," min"]}),qe.resources&&qe.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Wo,{className:"h-3 w-3"})," ",qe.resources.length," resource(s)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:Qe=>{var We;Qe.stopPropagation(),_(qe),k({title:qe.title,description:qe.description||"",video_url:qe.video_url||"",text_content:qe.text_content||"",duration_minutes:((We=qe.duration_minutes)==null?void 0:We.toString())||""})},children:e.jsx(Da,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:Qe=>{Qe.stopPropagation(),Xe(qe.id)},children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]}),R.has(qe.id)&&e.jsxs("div",{className:"border-t bg-muted/30 p-4 space-y-3",children:[qe.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:qe.description}),qe.video_url&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Video: "}),e.jsx("a",{href:qe.video_url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline break-all",children:qe.video_url})]}),qe.text_content&&e.jsx("div",{className:"text-sm bg-background rounded-md p-3 border max-h-40 overflow-auto whitespace-pre-wrap",children:qe.text_content}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Resources"}),e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>{T(qe.id),L({title:"",resource_type:"link",url:""})},children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add Resource"]})]}),qe.resources&&qe.resources.length>0?e.jsx("div",{className:"space-y-1",children:qe.resources.map(Qe=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-background rounded p-2 border",children:[e.jsx(rt,{variant:"outline",className:"text-[10px]",children:Qe.resource_type}),e.jsx("span",{className:"flex-1 truncate",children:Qe.title}),Qe.url&&e.jsx("a",{href:Qe.url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline text-xs",children:"Open"}),e.jsx(K,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-destructive",onClick:()=>u.mutateAsync(Qe.id),children:e.jsx(Ur,{className:"h-3 w-3"})})]},Qe.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No resources yet"})]})]})]},qe.id)),e.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:()=>{w(!0),k({title:"",description:"",video_url:"",text_content:"",duration_minutes:""})},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," Add Module"]})]}),e.jsx(zs,{value:"access",className:"mt-6 space-y-4",children:e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Who can access this course?"})}),e.jsxs(Oe,{className:"space-y-5",children:[e.jsxs("div",{className:Pt("flex items-center gap-3 p-4 rounded-xl border-2 cursor-pointer transition-all",Fe?"border-primary bg-primary/5":"border-muted hover:border-muted-foreground/30"),onClick:nt,children:[e.jsx("div",{className:Pt("h-10 w-10 rounded-full flex items-center justify-center shrink-0",Fe?"bg-primary/15 text-primary":"bg-muted text-muted-foreground"),children:e.jsx(Lm,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold",children:"All Brokerages / All Agents"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Every agent on the platform can access this course"})]}),e.jsx(Br,{checked:Fe,onCheckedChange:nt})]}),!Fe&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:"Select Brokerages"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Ae.length===0?"No brokerages selected — agents won't see this course":`${Ae.length} brokerage${Ae.length!==1?"s":""} selected`})]}),Ae.length>0&&e.jsx(K,{size:"sm",variant:"ghost",className:"text-xs text-muted-foreground",onClick:it,children:"Clear all"})]}),e.jsx(Re,{placeholder:"Search brokerages...",value:le,onChange:qe=>he(qe.target.value),className:"h-9"}),e.jsx("div",{className:"border rounded-lg divide-y max-h-[360px] overflow-auto",children:Ue.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No brokerages found"}):Ue.map(qe=>{const Ze=Ae.includes(qe.id);return e.jsxs("div",{className:Pt("flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors",Ze?"bg-primary/5":"hover:bg-muted/50"),onClick:()=>Se(qe.id),children:[e.jsx("div",{className:Pt("h-5 w-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors",Ze?"bg-primary border-primary":"border-muted-foreground/30"),children:Ze&&e.jsx("svg",{className:"h-3 w-3 text-primary-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsx(Ta,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:qe.name}),Ze&&e.jsx(rt,{variant:"secondary",className:"text-[10px] shrink-0",children:"Active"})]},qe.id)})})]})]})]})}),e.jsxs(zs,{value:"settings",className:"mt-6 space-y-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Course Thumbnail"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-start gap-6",children:[r.thumbnail_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:r.thumbnail_url,alt:"Course thumbnail",className:"w-48 h-28 object-cover rounded-lg border"}),e.jsx("button",{onClick:()=>a.mutateAsync({id:r.id,thumbnail_url:null}).then(()=>fe.success("Thumbnail removed")),className:"absolute -top-2 -right-2 bg-destructive text-destructive-foreground rounded-full p-1 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"w-48 h-28 rounded-lg border-2 border-dashed border-muted-foreground/25 flex flex-col items-center justify-center text-muted-foreground",children:[e.jsx(D0,{className:"h-8 w-8 mb-1 opacity-50"}),e.jsx("span",{className:"text-xs",children:"No thumbnail"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload a thumbnail image for this course. Recommended: 800×450px (16:9)."}),e.jsx("input",{ref:de,type:"file",accept:"image/*",className:"hidden",onChange:async qe=>{var Qe;const Ze=(Qe=qe.target.files)==null?void 0:Qe[0];if(!(!Ze||!r)){ae(!0);try{const We=Ze.name.split(".").pop(),He=`${r.id}/thumbnail.${We}`,{error:et}=await G.storage.from("lms-thumbnails").upload(He,Ze,{upsert:!0});if(et)throw et;const{data:Tt}=G.storage.from("lms-thumbnails").getPublicUrl(He),Ft=`${Tt.publicUrl}?t=${Date.now()}`;await a.mutateAsync({id:r.id,thumbnail_url:Ft}),fe.success("Thumbnail uploaded")}catch{fe.error("Failed to upload thumbnail")}finally{ae(!1),de.current&&(de.current.value="")}}}}),e.jsxs(K,{variant:"outline",size:"sm",disabled:re,onClick:()=>{var qe;return(qe=de.current)==null?void 0:qe.click()},children:[re?e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Za,{className:"h-4 w-4 mr-2"}),re?"Uploading...":"Upload Thumbnail"]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Course Settings"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Sequential Learning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents must complete modules in order before advancing"})]}),e.jsx(Br,{checked:r.is_sequential,onCheckedChange:qe=>a.mutateAsync({id:r.id,is_sequential:qe}).then(()=>fe.success("Updated"))})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this course visible to agents with access"})]}),e.jsx(Br,{checked:r.is_published,onCheckedChange:qe=>a.mutateAsync({id:r.id,is_published:qe}).then(()=>fe.success("Updated"))})]})]})]})]})]})]}),e.jsx(_s,{open:b||!!y,onOpenChange:qe=>{qe||(w(!1),_(null))},children:e.jsxs(vs,{className:"max-w-lg",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:y?"Edit Module":"Add Module"}),e.jsx(Kr,{children:"Configure the module content"})]}),e.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-auto",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Title"}),e.jsx(Re,{value:j.title,onChange:qe=>k(Ze=>({...Ze,title:qe.target.value})),placeholder:"Module title"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Ar,{value:j.description,onChange:qe=>k(Ze=>({...Ze,description:qe.target.value})),placeholder:"Brief description",rows:2})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Video"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:Pt("border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors hover:border-primary/50",q?"border-primary bg-primary/5":"border-muted-foreground/25"),onClick:()=>{var qe;return(qe=Q.current)==null?void 0:qe.click()},children:[e.jsx("input",{ref:Q,type:"file",accept:"video/*",className:"hidden",onChange:qe=>{var Qe;const Ze=(Qe=qe.target.files)==null?void 0:Qe[0];Ze&&(U(Ze),k(We=>({...We,video_url:""})))}}),q?e.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm",children:[e.jsx(Nn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-primary",children:q.name}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:qe=>{qe.stopPropagation(),U(null)},children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"flex flex-col items-center gap-1 text-muted-foreground",children:[e.jsx(Za,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Click to upload a video file"})]})]}),se&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Ms,{className:"h-3.5 w-3.5 animate-spin"}),e.jsxs("span",{children:["Uploading to Bunny.net... ",H,"%"]})]}),e.jsx(Ti,{value:H,className:"h-1.5"})]}),!q&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("div",{className:"flex-1 h-px bg-border"}),e.jsx("span",{children:"or paste a URL"}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx(Re,{value:j.video_url,onChange:qe=>k(Ze=>({...Ze,video_url:qe.target.value})),placeholder:"YouTube, Vimeo, or Bunny.net URL"})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Text Content"}),e.jsx(Ar,{value:j.text_content,onChange:qe=>k(Ze=>({...Ze,text_content:qe.target.value})),placeholder:"Additional text content, instructions, notes...",rows:4})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Duration (minutes)"}),e.jsx(Re,{type:"number",value:j.duration_minutes,onChange:qe=>k(Ze=>({...Ze,duration_minutes:qe.target.value})),placeholder:"e.g. 15"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>{w(!1),_(null),U(null)},children:"Cancel"}),e.jsxs(K,{onClick:y?me:Rt,disabled:!j.title.trim()||se,children:[se?e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(fu,{className:"h-4 w-4 mr-2"}),se?"Uploading...":y?"Save Changes":"Add Module"]})]})]})}),e.jsx(_s,{open:!!S,onOpenChange:qe=>{qe||T(null)},children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Add Resource"}),e.jsx(Kr,{children:"Add a link, document, or other resource to this module"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Title"}),e.jsx(Re,{value:I.title,onChange:qe=>L(Ze=>({...Ze,title:qe.target.value})),placeholder:"Resource title"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Type"}),e.jsxs(sr,{value:I.resource_type,onValueChange:qe=>L(Ze=>({...Ze,resource_type:qe})),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"link",children:"Link"}),e.jsx(At,{value:"pdf",children:"PDF"}),e.jsx(At,{value:"template",children:"Template"}),e.jsx(At,{value:"worksheet",children:"Worksheet"})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"URL"}),e.jsx(Re,{value:I.url,onChange:qe=>L(Ze=>({...Ze,url:qe.target.value})),placeholder:"https://..."})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>T(null),children:"Cancel"}),e.jsx(K,{onClick:()=>S&&ot(S),disabled:!I.title.trim(),children:"Add Resource"})]})]})}),e.jsx(_s,{open:Ge,onOpenChange:we,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Edit Course"}),e.jsx(Kr,{children:"Update the course title and description"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Title"}),e.jsx(Re,{value:be,onChange:qe=>_e(qe.target.value)})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Ar,{value:je,onChange:qe=>Ne(qe.target.value),rows:3})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>we(!1),children:"Cancel"}),e.jsx(K,{onClick:ct,disabled:!be.trim(),children:"Save"})]})]})})]})}function Nvs(){return wt({queryKey:["lms-stats-overview"],queryFn:async()=>{const{data:t,error:s}=await G.rpc("get_lms_stats");if(s)throw s;return t}})}function kvs(){return wt({queryKey:["lms-stats-courses"],queryFn:async()=>{const{data:t,error:s}=await G.rpc("get_lms_course_stats");if(s)throw s;return t||[]}})}function Svs(t){return wt({queryKey:["lms-stats-agents",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.rpc("get_lms_agent_progress",{p_course_id:t});if(r)throw r;return s||[]},enabled:!!t})}function Cvs(){const t=Pr(),{data:s,isLoading:r}=Nvs(),{data:n,isLoading:a}=kvs(),[o,l]=C.useState(null),{data:i,isLoading:d}=Svs(o),[u,p]=C.useState(""),f=n==null?void 0:n.find(b=>b.course_id===o),y=i==null?void 0:i.filter(b=>{var w,j;return!u||((w=b.agent_name)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))||((j=b.email)==null?void 0:j.toLowerCase().includes(u.toLowerCase()))}),_=[{label:"Total Courses",value:(s==null?void 0:s.total_courses)??0,icon:Fu,color:"text-primary"},{label:"Published",value:(s==null?void 0:s.published_courses)??0,icon:ua,color:"text-emerald-500"},{label:"Enrolled Agents",value:(s==null?void 0:s.total_enrollments)??0,icon:hr,color:"text-blue-500"},{label:"Modules Completed",value:(s==null?void 0:s.total_completions)??0,icon:ao,color:"text-amber-500"},{label:"Active (30d)",value:(s==null?void 0:s.active_learners)??0,icon:ac,color:"text-violet-500"},{label:"Total Modules",value:(s==null?void 0:s.total_modules)??0,icon:ol,color:"text-rose-500"}];return e.jsx(Ts,{title:"LevelUp U - Stats",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t("/admin/lms"),children:e.jsx(ti,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(ah,{className:"h-7 w-7 text-primary"}),"LevelUp U — Analytics"]}),e.jsx("p",{className:"text-muted-foreground text-sm mt-0.5",children:"Track enrollment, progress, and completion across all courses"})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-6 gap-3",children:_.map(b=>e.jsx(Ee,{className:Pt("transition-all",r&&"animate-pulse"),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b.icon,{className:Pt("h-4 w-4",b.color)}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:b.label})]}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:r?"—":b.value})]})},b.label))}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-5 gap-6",children:[e.jsxs("div",{className:"xl:col-span-2 space-y-3",children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(ol,{className:"h-5 w-5 text-primary"}),"Course Breakdown"]}),a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(b=>e.jsx(Ee,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-16 bg-muted rounded"})})},b))}):n!=null&&n.length?e.jsx("div",{className:"space-y-2",children:n.map(b=>{const w=o===b.course_id;return e.jsx(Ee,{className:Pt("cursor-pointer transition-all hover:shadow-md",w?"border-primary ring-1 ring-primary/30 shadow-md":"hover:border-primary/40"),onClick:()=>l(w?null:b.course_id),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-semibold text-sm text-foreground truncate",children:b.course_title}),e.jsx(rt,{variant:b.is_published?"default":"secondary",className:"shrink-0 text-[10px] px-1.5 py-0",children:b.is_published?"Live":"Draft"})]})}),e.jsx(Ua,{className:Pt("h-4 w-4 text-muted-foreground transition-transform shrink-0 ml-2",w&&"rotate-90")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:b.enrolled_agents}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Enrolled"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:b.total_completions}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Completed"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:b.total_modules}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Modules"})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"Avg. Completion"}),e.jsxs("span",{className:"font-semibold text-foreground",children:[b.avg_completion_pct,"%"]})]}),e.jsx(Ti,{value:b.avg_completion_pct,className:"h-2"})]})]})},b.course_id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(Oe,{className:"py-10 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"No courses created yet"})})})]}),e.jsxs("div",{className:"xl:col-span-3 space-y-3",children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(p_,{className:"h-5 w-5 text-primary"}),f?`Agent Progress — ${f.course_title}`:"Agent Progress"]}),o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{value:u,onChange:b=>p(b.target.value),placeholder:"Search agents...",className:"pl-9"})]}),d?e.jsx("div",{className:"space-y-2",children:[1,2,3,4].map(b=>e.jsx(Ee,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-12 bg-muted rounded"})})},b))}):y!=null&&y.length?e.jsx("div",{className:"space-y-2 max-h-[600px] overflow-y-auto pr-1",children:y.map((b,w)=>{const j=b.completion_pct>=100;return e.jsx(Ee,{className:Pt("transition-all",j&&"border-emerald-200 bg-emerald-50/30 dark:border-emerald-900/40 dark:bg-emerald-950/10"),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:Pt("flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold shrink-0",w===0?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":w===1?"bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400":w===2?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-muted text-muted-foreground"),children:w+1}),e.jsxs(xn,{className:"h-9 w-9 shrink-0",children:[e.jsx(Aa,{src:b.avatar_url||void 0}),e.jsx(yn,{className:"text-xs bg-primary/10 text-primary",children:(b.agent_name||b.email||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:b.agent_name||b.email}),j&&e.jsxs(rt,{variant:"default",className:"text-[10px] px-1.5 py-0 bg-emerald-500 hover:bg-emerald-600 shrink-0",children:[e.jsx(ua,{className:"h-3 w-3 mr-0.5"})," Complete"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-muted-foreground mt-0.5",children:[e.jsxs("span",{children:[b.modules_completed,"/",b.total_modules," modules"]}),b.last_activity&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),ys(new Date(b.last_activity),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"text-right shrink-0 w-20",children:[e.jsxs("p",{className:Pt("text-sm font-bold",j?"text-emerald-600 dark:text-emerald-400":"text-foreground"),children:[b.completion_pct,"%"]}),e.jsx(Ti,{value:b.completion_pct,className:"h-1.5 mt-1"})]})]})})},b.user_id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(Oe,{className:"py-10 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:u?"No agents match your search":"No agents have started this course yet"})})})]}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"py-16 text-center",children:[e.jsx(hr,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Select a course to view agent progress"})]})})]})]})]})})}function Mvs(){const{user:t}=Hs(),s=Pr(),{data:r,isLoading:n}=vvs();return e.jsx(Ts,{title:"LevelUp U",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary/10 via-primary/5 to-background border p-8",children:[e.jsx("div",{className:"relative z-10",children:e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"h-12 w-12 rounded-xl bg-primary/15 flex items-center justify-center",children:e.jsx(ah,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"LevelUp U"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Your training & development hub"})]})]})}),e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-primary/5 rounded-full -translate-y-1/2 translate-x-1/2"})]}),n?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(a=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Oe,{className:"p-6",children:[e.jsx("div",{className:"h-5 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-3"})]})},a))}):r!=null&&r.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:r.map(a=>e.jsx(Tvs,{course:a,userId:t==null?void 0:t.id,onClick:()=>s(`/levelup-u/${a.id}`)},a.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(Fu,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No courses available yet"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Check back soon for new training content"})]})})]})})}function Tvs({course:t,userId:s,onClick:r}){var i;const n=((i=t.modules)==null?void 0:i.length)??0,{data:a}=Pet(t.id),o=(a==null?void 0:a.filter(d=>d.completed).length)??0,l=n>0?Math.round(o/n*100):0;return e.jsxs(Ee,{className:"group cursor-pointer hover:shadow-lg transition-all hover:border-primary/50 overflow-hidden",onClick:r,children:[t.thumbnail_url?e.jsx("div",{className:"aspect-video bg-muted overflow-hidden",children:e.jsx("img",{src:t.thumbnail_url,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"})}):e.jsx("div",{className:"aspect-video bg-gradient-to-br from-primary/15 via-primary/5 to-muted flex items-center justify-center",children:e.jsx(ah,{className:"h-10 w-10 text-primary/40"})}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors line-clamp-1",children:t.title}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:t.description})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Fu,{className:"h-3.5 w-3.5"}),n," module",n!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[t.is_sequential?e.jsx(O0,{className:"h-3.5 w-3.5"}):e.jsx(pk,{className:"h-3.5 w-3.5"}),t.is_sequential?"In order":"Any order"]})]}),n>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground",children:[o," of ",n," completed"]}),e.jsxs("span",{className:"font-medium text-foreground",children:[l,"%"]})]}),e.jsx(Ti,{value:l,className:"h-1.5"})]}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsxs("span",{className:"text-xs text-primary font-medium flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[l===100?"Review":l>0?"Continue":"Start"," Course",e.jsx(Ua,{className:"h-3.5 w-3.5"})]})})]})]})}function Avs(){const{courseId:t}=ko(),s=Pr(),{user:r}=Hs(),{data:n,isLoading:a}=_vs(t),{data:o}=Pet(t),l=bvs(),[i,d]=C.useState(null),u=(n==null?void 0:n.modules)||[],p=new Set((o==null?void 0:o.filter(S=>S.completed).map(S=>S.module_id))||[]),f=p.size,y=u.length>0?Math.round(f/u.length*100):0;C.useEffect(()=>{if(u.length>0&&!i){const S=u.find(T=>!p.has(T.id));d((S==null?void 0:S.id)||u[0].id)}},[u,i,p]);const _=u.find(S=>S.id===i),b=u.findIndex(S=>S.id===i),w=(S,T)=>{if(!(n!=null&&n.is_sequential)||T===0)return!1;for(let I=0;I{if(!(!_||!r||!t))try{await l.mutateAsync({courseId:t,moduleId:_.id,userId:r.id}),fe.success("Module completed! 🎉"),b{const T=S.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(T)return`https://www.youtube.com/embed/${T[1]}`;const I=S.match(/vimeo\.com\/(\d+)/);if(I)return`https://player.vimeo.com/video/${I[1]}`;const L=S.match(/(?:iframe\.mediadelivery\.net|video\.bunnycdn\.com)\/(?:play|embed)\/(\d+)\/([a-f0-9-]+)/);return L?`https://iframe.mediadelivery.net/embed/${L[1]}/${L[2]}?responsive=true`:S};return a?e.jsx(Ts,{title:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):n?e.jsx(Ts,{title:n.title,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/levelup-u"),children:e.jsx(ti,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h1",{className:"text-xl font-bold text-foreground truncate",children:n.title}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("span",{children:[f,"/",u.length," completed"]}),e.jsxs("span",{children:[y,"%"]})]})]}),e.jsx("div",{className:"w-32",children:e.jsx(Ti,{value:y,className:"h-2"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[320px_1fr] gap-4 items-start",children:[e.jsx(Ee,{className:"lg:sticky lg:top-4",children:e.jsxs(Oe,{className:"p-0",children:[e.jsx("div",{className:"p-3 border-b",children:e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Modules"})}),e.jsx(Ri,{className:"max-h-[calc(100vh-280px)]",children:e.jsx("div",{className:"p-1",children:u.map((S,T)=>{const I=w(S,T),L=p.has(S.id),R=S.id===i;return e.jsxs("button",{disabled:I,onClick:()=>!I&&d(S.id),className:Pt("w-full flex items-center gap-3 p-3 rounded-lg text-left transition-all text-sm",R?"bg-primary/10 text-primary":"hover:bg-muted/50",I&&"opacity-50 cursor-not-allowed"),children:[e.jsx("div",{className:"shrink-0",children:I?e.jsx($u,{className:"h-4 w-4 text-muted-foreground"}):L?e.jsx(ua,{className:"h-4 w-4 text-green-500"}):e.jsx(Kc,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:Pt("font-medium truncate",R&&"text-primary"),children:[T+1,". ",S.title]}),S.duration_minutes&&e.jsxs("span",{className:"text-[11px] text-muted-foreground flex items-center gap-0.5 mt-0.5",children:[e.jsx(Tn,{className:"h-3 w-3"})," ",S.duration_minutes," min"]})]})]},S.id)})})})]})}),e.jsx("div",{className:"space-y-4",children:_?e.jsxs(e.Fragment,{children:[_.video_url&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-video bg-black",children:e.jsx("iframe",{src:k(_.video_url),className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:_.title}),_.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:_.description})]}),p.has(_.id)?e.jsxs(rt,{className:"bg-green-500/15 text-green-600 border-green-500/30 shrink-0",children:[e.jsx(ua,{className:"h-3.5 w-3.5 mr-1"})," Completed"]}):e.jsxs(K,{size:"sm",onClick:j,disabled:l.isPending,children:[e.jsx(ua,{className:"h-4 w-4 mr-1"}),"Mark Complete"]})]}),_.text_content&&e.jsx("div",{className:"prose prose-sm max-w-none text-foreground border-t pt-4 whitespace-pre-wrap",children:_.text_content}),_.resources&&_.resources.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Resources"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:_.resources.map(S=>e.jsxs("a",{href:S.url||S.file_url||"#",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 p-3 rounded-lg border hover:bg-muted/50 transition-colors text-sm",children:[S.resource_type==="pdf"?e.jsx(In,{className:"h-4 w-4 text-red-500 shrink-0"}):S.resource_type==="template"?e.jsx(ah,{className:"h-4 w-4 text-purple-500 shrink-0"}):e.jsx(Wo,{className:"h-4 w-4 text-blue-500 shrink-0"}),e.jsx("span",{className:"flex-1 truncate",children:S.title}),e.jsx(sn,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]},S.id))})]}),e.jsxs("div",{className:"flex items-center justify-between border-t pt-4",children:[e.jsxs(K,{variant:"outline",size:"sm",disabled:b===0,onClick:()=>b>0&&d(u[b-1].id),children:[e.jsx(ti,{className:"h-3.5 w-3.5 mr-1"})," Previous"]}),bd(u[b+1].id),children:["Next ",e.jsx(Ua,{className:"h-3.5 w-3.5 ml-1"})]}):y===100&&e.jsx(rt,{className:"bg-green-500/15 text-green-600 border-green-500/30 text-sm px-3 py-1.5",children:"🎉 Course Complete!"})]})]})})]}):e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-16 text-muted-foreground",children:"Select a module to begin"})})})]})]})}):e.jsx(Ts,{title:"Not Found",children:e.jsxs("div",{className:"text-center py-20",children:[e.jsx("p",{className:"text-muted-foreground",children:"Course not found"}),e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>s("/levelup-u"),children:[e.jsx(ti,{className:"h-4 w-4 mr-2"})," Back"]})]})})}function Evs(){const{slug:t}=ko(),{toast:s}=Pa(),[r,n]=C.useState(!1),[a,o]=C.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",experience_years:"",annual_production:"",license_number:"",why_interested:""}),{data:l,isLoading:i,error:d}=wt({queryKey:["recruit-form-brokerage",t],queryFn:async()=>{const{data:T,error:I}=await G.from("brokerages").select("id, name, recruit_form_enabled").eq("recruit_form_slug",t).single();if(I)throw I;return T},enabled:!!t}),{data:u}=wt({queryKey:["recruit-landing-public",l==null?void 0:l.id],queryFn:async()=>{const{data:T,error:I}=await G.from("recruit_landing_page_settings").select("*").eq("brokerage_id",l.id).single();if(I&&I.code!=="PGRST116")throw I;return T},enabled:!!(l!=null&&l.id)}),p=Dt({mutationFn:async()=>{const{error:T}=await G.from("recruit_interest_submissions").insert({brokerage_id:l.id,first_name:a.first_name,last_name:a.last_name||null,email:a.email,phone:a.phone||null,current_brokerage:a.current_brokerage||null,experience_years:a.experience_years?parseInt(a.experience_years):null,annual_production:a.annual_production||null,license_number:a.license_number||null,why_interested:a.why_interested||null});if(T)throw T},onSuccess:()=>n(!0),onError:T=>s({title:"Error",description:T.message,variant:"destructive"})});if(i)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});if(d||!l||!l.recruit_form_enabled)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"max-w-md w-full mx-4 text-center",children:[e.jsx(Ta,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"This page is not available."})]})});const f=u,y=(f==null?void 0:f.primary_color)||"#406E71",_=(f==null?void 0:f.accent_color)||"#2a4c64",b=(f==null?void 0:f.benefits)||[],w=(f==null?void 0:f.testimonials)||[],j=(f==null?void 0:f.gallery_images)||[],k=(f==null?void 0:f.hero_headline)||`Join ${l.name}`,S=(f==null?void 0:f.hero_subtext)||"Take your real estate career to the next level.";return r?e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{background:`linear-gradient(135deg, ${y}, ${_})`},children:e.jsxs("div",{className:"max-w-md w-full mx-4 bg-white rounded-2xl shadow-2xl p-8 text-center space-y-4",children:[e.jsx("div",{className:"h-16 w-16 rounded-full flex items-center justify-center mx-auto",style:{backgroundColor:`${y}20`},children:e.jsx(ha,{className:"h-8 w-8",style:{color:y}})}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:"Thank You!"}),e.jsxs("p",{className:"text-gray-600",children:["Your interest in joining ",l.name," has been submitted. A recruiter will be in touch soon."]})]})}):e.jsxs("div",{className:"min-h-screen",style:{"--recruit-primary":y,"--recruit-accent":_},children:[e.jsxs("section",{className:"relative min-h-[70vh] flex items-center justify-center text-white overflow-hidden",style:{background:f!=null&&f.hero_image_url?`linear-gradient(135deg, ${y}dd, ${_}cc)`:`linear-gradient(135deg, ${y}, ${_})`},children:[(f==null?void 0:f.hero_image_url)&&e.jsx("div",{className:"absolute inset-0 bg-cover bg-center mix-blend-overlay opacity-40",style:{backgroundImage:`url(${f.hero_image_url})`}}),e.jsxs("div",{className:"relative z-10 text-center max-w-3xl mx-auto px-6 py-20",children:[(f==null?void 0:f.logo_url)&&e.jsx("img",{src:f.logo_url,alt:l.name,className:"h-16 w-auto mx-auto mb-8 drop-shadow-lg"}),e.jsx("h1",{className:"text-4xl md:text-6xl font-bold mb-6 leading-tight drop-shadow-md",children:k}),e.jsx("p",{className:"text-lg md:text-xl opacity-90 mb-10 max-w-2xl mx-auto leading-relaxed",children:S}),e.jsxs("a",{href:"#apply",className:"inline-flex items-center gap-2 px-8 py-4 rounded-full text-lg font-semibold shadow-lg transition-all hover:scale-105",style:{backgroundColor:"white",color:y},children:["Apply Now ",e.jsx(Ho,{className:"h-5 w-5"})]})]})]}),b.length>0&&e.jsx("section",{className:"py-20 px-6 bg-white",children:e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-center mb-4",style:{color:_},children:"Why Join Us?"}),e.jsx("p",{className:"text-center text-gray-500 mb-12 max-w-2xl mx-auto",children:"Here's what makes our brokerage different."}),e.jsx("div",{className:"grid md:grid-cols-3 gap-8",children:b.map((T,I)=>e.jsxs("div",{className:"text-center p-6 rounded-2xl border border-gray-100 hover:shadow-lg transition-shadow",children:[e.jsx("div",{className:"text-4xl mb-4",children:T.icon}),e.jsx("h3",{className:"text-xl font-bold mb-2",style:{color:_},children:T.title}),e.jsx("p",{className:"text-gray-600",children:T.description})]},I))})]})}),j.length>0&&e.jsx("section",{className:"py-20 px-6",style:{backgroundColor:`${y}08`},children:e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx(hr,{className:"h-6 w-6",style:{color:y}}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold",style:{color:_},children:"Our Team & Culture"})]}),e.jsx("p",{className:"text-center text-gray-500 mb-12",children:"See what it's like to be part of our team."}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:j.map((T,I)=>e.jsx("img",{src:T,alt:`Team ${I+1}`,className:"w-full h-48 md:h-56 object-cover rounded-xl shadow-md hover:shadow-xl transition-shadow"},I))})]})}),w.length>0&&e.jsx("section",{className:"py-20 px-6 bg-white",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx(C5,{className:"h-6 w-6",style:{color:y}}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold",style:{color:_},children:"What Our Agents Say"})]}),e.jsx("p",{className:"text-center text-gray-500 mb-12",children:"Hear from agents who made the move."}),e.jsx("div",{className:"grid md:grid-cols-2 gap-8",children:w.map((T,I)=>{var L;return e.jsxs("div",{className:"p-6 rounded-2xl border border-gray-100 shadow-sm",children:[e.jsxs("p",{className:"text-gray-700 italic mb-4 leading-relaxed",children:['"',T.quote,'"']}),e.jsxs("div",{className:"flex items-center gap-3",children:[T.photo_url?e.jsx("img",{src:T.photo_url,alt:T.name,className:"h-10 w-10 rounded-full object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded-full flex items-center justify-center text-white text-sm font-bold",style:{backgroundColor:y},children:((L=T.name)==null?void 0:L[0])||"?"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",style:{color:_},children:T.name}),T.role&&e.jsx("p",{className:"text-xs text-gray-500",children:T.role})]})]})]},I)})})]})}),e.jsx("section",{id:"apply",className:"py-20 px-6",style:{backgroundColor:`${y}08`},children:e.jsxs("div",{className:"max-w-lg mx-auto",children:[e.jsx("h2",{className:"text-3xl font-bold text-center mb-2",style:{color:_},children:"Ready to Join?"}),e.jsx("p",{className:"text-center text-gray-500 mb-8",children:"Fill out the form below and a recruiter will be in touch."}),e.jsxs("form",{onSubmit:T=>{T.preventDefault(),p.mutate()},className:"bg-white rounded-2xl shadow-xl p-8 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-gray-700",children:"First Name *"}),e.jsx(Re,{required:!0,value:a.first_name,onChange:T=>o(I=>({...I,first_name:T.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-gray-700",children:"Last Name"}),e.jsx(Re,{value:a.last_name,onChange:T=>o(I=>({...I,last_name:T.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-gray-700",children:"Email *"}),e.jsx(Re,{type:"email",required:!0,value:a.email,onChange:T=>o(I=>({...I,email:T.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-gray-700",children:"Phone"}),e.jsx(Re,{value:a.phone,onChange:T=>o(I=>({...I,phone:T.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-gray-700",children:"Current Brokerage"}),e.jsx(Re,{value:a.current_brokerage,onChange:T=>o(I=>({...I,current_brokerage:T.target.value}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-gray-700",children:"License #"}),e.jsx(Re,{value:a.license_number,onChange:T=>o(I=>({...I,license_number:T.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-gray-700",children:"Years of Experience"}),e.jsx(Re,{type:"number",min:"0",value:a.experience_years,onChange:T=>o(I=>({...I,experience_years:T.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-gray-700",children:"Annual Production"}),e.jsx(Re,{placeholder:"e.g. $5M, 20 transactions",value:a.annual_production,onChange:T=>o(I=>({...I,annual_production:T.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-gray-700",children:"Why are you interested?"}),e.jsx(Ar,{value:a.why_interested,onChange:T=>o(I=>({...I,why_interested:T.target.value})),rows:3,placeholder:"Tell us what you're looking for..."})]}),e.jsx(K,{type:"submit",className:"w-full h-12 text-base font-semibold rounded-xl",style:{backgroundColor:y},disabled:p.isPending,children:p.isPending?"Submitting...":"Submit Interest"})]})]})}),e.jsx("footer",{className:"py-8 text-center text-sm text-white",style:{backgroundColor:_},children:e.jsxs("p",{children:["© ",new Date().getFullYear()," ",l.name,". All rights reserved."]})})]})}function Pvs(t){const s=t.match(/(?:iframe\.mediadelivery\.net\/(?:embed|play)\/|video\.bunnycdn\.com\/play\/)(\d+)\/([a-f0-9-]+)/i);return s?`https://iframe.mediadelivery.net/embed/${s[1]}/${s[2]}?autoplay=false&responsive=true`:t}function Ivs(){var y,_,b,w;const{shareToken:t}=ko(),s=C.useRef(!1),{data:r,isLoading:n,error:a}=wt({queryKey:["public-recruit-video",t],queryFn:async()=>{var L;if(!t)throw new Error("No token");const{data:j,error:k}=await G.from("recruit_videos").select(` *, prospect:recruit_prospects(first_name, last_name), video:agent_videos(id, title, playback_url, thumbnail_url, duration_seconds, owner_user_id) `).eq("share_token",t).single();if(k)throw k;const{data:S}=await G.from("profiles").select("name, avatar_url, title").eq("id",(L=j.video)==null?void 0:L.owner_user_id).single(),{data:T}=await G.from("brokerages").select("name").eq("id",j.brokerage_id).single(),{data:I}=await G.from("recruit_landing_page_settings").select("logo_url, primary_color, accent_color, hero_headline").eq("brokerage_id",j.brokerage_id).maybeSingle();return{rv:j,profile:S,brokerage:T,settings:I}},enabled:!!t});if(C.useEffect(()=>{var j;!((j=r==null?void 0:r.rv)!=null&&j.id)||s.current||(s.current=!0,G.rpc("log_recruit_video_view",{p_recruit_video_id:r.rv.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null}).then(()=>{}))},[(y=r==null?void 0:r.rv)==null?void 0:y.id]),n)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});if(a||!r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("p",{className:"text-muted-foreground",children:"This video is no longer available."})});const{rv:o,profile:l,brokerage:i,settings:d}=r,u=(d==null?void 0:d.primary_color)||"#3b82f6",p=((_=o.prospect)==null?void 0:_.first_name)||"there",f=(b=o.video)!=null&&b.playback_url?Pvs(o.video.playback_url):null;return e.jsxs(e.Fragment,{children:[e.jsx(lh,{children:e.jsx("title",{children:i!=null&&i.name?`${i.name} — A Message For You`:"Personal Video Message"})}),e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-slate-100",children:[e.jsx("header",{className:"border-b bg-white/80 backdrop-blur-sm",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-4 flex items-center gap-3",children:[(d==null?void 0:d.logo_url)&&e.jsx("img",{src:d.logo_url,alt:"",className:"h-8 object-contain"}),e.jsx("span",{className:"font-semibold text-sm",style:{color:u},children:(i==null?void 0:i.name)||"Recruiting"})]})}),e.jsxs("main",{className:"max-w-3xl mx-auto px-4 py-8 space-y-6",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground",children:["Hey ",p,", ",l==null?void 0:l.name," has a message for you"]}),o.message&&e.jsx("p",{className:"text-muted-foreground max-w-xl mx-auto",children:o.message})]}),f&&e.jsx("div",{className:"rounded-xl overflow-hidden shadow-xl bg-black",children:e.jsx("div",{style:{position:"relative",paddingTop:"56.25%"},children:e.jsx("iframe",{src:f,loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,width:"100%",height:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border p-6 flex items-center gap-4",children:[l!=null&&l.avatar_url?e.jsx("img",{src:l.avatar_url,alt:"",className:"h-14 w-14 rounded-full object-cover"}):e.jsx("div",{className:"h-14 w-14 rounded-full flex items-center justify-center text-white text-lg font-bold",style:{backgroundColor:u},children:((w=l==null?void 0:l.name)==null?void 0:w.charAt(0))||"?"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold",children:l==null?void 0:l.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(l==null?void 0:l.title)||"Recruiter"," · ",i==null?void 0:i.name]})]})]}),e.jsx("div",{className:"text-center",children:e.jsxs(K,{size:"lg",className:"text-white shadow-lg hover:shadow-xl transition-shadow px-8",style:{backgroundColor:u},onClick:()=>{G.from("recruit_videos").update({cta_clicked_at:new Date().toISOString()}).eq("id",o.id).then(()=>{})},children:[e.jsx(on,{className:"h-5 w-5 mr-2"})," Schedule a Conversation"]})})]}),e.jsx("footer",{className:"text-center py-6 text-xs text-muted-foreground",children:"Powered by LevelUp"})]})]})}function Lvs(){const t=Pr(),s=rs(),{isAdmin:r}=Hs(),[n,a]=C.useState(!1),[o,l]=C.useState(null),[i,d]=C.useState(null),{data:u,isLoading:p}=wt({queryKey:["my-social-accounts"],queryFn:async()=>{const{data:{user:L},error:R}=await G.auth.getUser();if(R)throw R;if(!L)return[];const{data:$,error:q}=await G.from("social_accounts").select("*").eq("user_id",L.id).order("created_at",{ascending:!1});if(q)throw q;return $}}),f=Dt({mutationFn:async L=>{const{data:{user:R},error:$}=await G.auth.getUser();if($)throw $;if(!R)throw new Error("Not authenticated");const{error:q}=await G.from("social_accounts").delete().eq("id",L).eq("user_id",R.id);if(q)throw q},onSuccess:()=>{s.invalidateQueries({queryKey:["my-social-accounts"]}),s.invalidateQueries({queryKey:["social-accounts-for-post"]}),fe.success("Account disconnected successfully")},onError:()=>{fe.error("Failed to disconnect account")}}),y=async()=>{a(!0);try{const{data:L,error:R}=await G.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(R)throw R;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get authorization URL")}catch(L){console.error("Meta OAuth error:",L),fe.error("Failed to start connection. Please try again."),a(!1)}},_=async()=>{a(!0);try{const{data:L,error:R}=await G.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(R)throw R;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(L){console.error("LinkedIn OAuth error:",L),fe.error("Failed to start LinkedIn connection. Please try again."),a(!1)}},b=async()=>{a(!0);try{const{data:L,error:R}=await G.functions.invoke("google-business-oauth",{body:{action:"get_auth_url"}});if(R)throw R;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get Google authorization URL")}catch(L){console.error("Google OAuth error:",L),fe.error("Failed to start Google connection. Please try again."),a(!1)}},w=(u==null?void 0:u.filter(L=>L.platform==="facebook"))||[],j=(u==null?void 0:u.filter(L=>L.platform==="instagram"))||[],k=(u==null?void 0:u.filter(L=>L.platform==="linkedin"))||[],S=(u==null?void 0:u.filter(L=>L.platform==="google_business"))||[],T=((u==null?void 0:u.length)||0)>0,I=async(L,R)=>{l(L),d(null);try{const{data:$,error:q}=await G.functions.invoke("meta-api-test",{body:{testType:"all",accountId:L}});if(q)throw q;d($.results||[]),fe.success($.summary||"API tests completed")}catch($){console.error("Meta API test error:",$),fe.error("Failed to run API tests")}finally{l(null)}};return e.jsx(Ts,{title:"Social Connections",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-pink-500 via-purple-500 to-blue-500 p-6 md:p-8 text-white",children:[e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4xIj48cGF0aCBkPSJNMzYgMzRjMC0yIDItNCAyLTRzMiAyIDIgNC0yIDQtMiA0LTItMi0yLTR6Ii8+PC9nPjwvZz48L3N2Zz4=')] opacity-30"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsxs(rt,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(hn,{className:"h-3 w-3 mr-1"}),"Post directly from Social Swag"]})}),e.jsx("h1",{className:"text-2xl md:text-3xl font-bold mb-2",children:"Connect Your Social Accounts"}),e.jsx("p",{className:"text-white/90 max-w-xl",children:"Link your Facebook Pages and Instagram Business accounts to post content directly from Social Swag with one click."})]})]}),e.jsxs(K,{variant:"ghost",onClick:()=>t("/social-swag-2"),className:"gap-2",children:[e.jsx(ti,{className:"h-4 w-4"}),"Back to Social Swag"]}),!r&&e.jsx(Ee,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-800",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-amber-100 dark:bg-amber-900/30 p-4 mb-4",children:e.jsx(Tn,{className:"h-10 w-10 text-amber-600 dark:text-amber-400"})}),e.jsx(rt,{variant:"secondary",className:"mb-3 bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400",children:"Coming Soon"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Social Connections Coming Soon!"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"We're putting the finishing touches on this feature. Soon you'll be able to connect your social accounts and post directly from Social Swag with one click."})]})}),r&&e.jsxs(e.Fragment,{children:[T&&e.jsx(Ee,{className:"border-green-200 bg-green-50 dark:bg-green-950/20 dark:border-green-900",children:e.jsxs(Oe,{className:"flex items-center gap-4 p-4",children:[e.jsx("div",{className:"rounded-full bg-green-500 p-2",children:e.jsx(hi,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-green-800 dark:text-green-200",children:"You're all set!"}),e.jsx("p",{className:"text-sm text-green-600 dark:text-green-400",children:"You can now post directly to your connected accounts from Social Swag."})]})]})}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-blue-500/10 p-3",children:e.jsx(Hd,{className:"h-6 w-6 text-blue-600"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Facebook"}),e.jsx(pr,{children:"Connect your Facebook Pages"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Po,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):w.length>0?e.jsx("div",{className:"space-y-3",children:w.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(xn,{className:"h-10 w-10",children:[e.jsx(Aa,{src:L.profile_picture_url||""}),e.jsx(yn,{children:e.jsx(Hd,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.page_name||L.platform_username||"Facebook Page"}),e.jsx(rt,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(nc,{children:[e.jsx(Rh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect Facebook?"}),e.jsx(Dl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Facebook pages connected yet"}),e.jsxs(K,{onClick:y,disabled:n,className:"w-full gap-2",variant:w.length>0?"outline":"default",children:[n?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),w.length>0?"Connect Another Page":"Connect Facebook Page"]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-gradient-to-br from-purple-500/10 via-pink-500/10 to-orange-500/10 p-3",children:e.jsx(Wd,{className:"h-6 w-6 text-pink-600"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Instagram"}),e.jsx(pr,{children:"Connect Instagram Business accounts"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Po,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):j.length>0?e.jsx("div",{className:"space-y-3",children:j.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(xn,{className:"h-10 w-10",children:[e.jsx(Aa,{src:L.profile_picture_url||""}),e.jsx(yn,{children:e.jsx(Wd,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["@",L.platform_username||"Instagram Account"]}),e.jsx(rt,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(nc,{children:[e.jsx(Rh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect Instagram?"}),e.jsx(Dl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Instagram accounts connected yet"}),e.jsxs(K,{onClick:y,disabled:n,className:"w-full gap-2",variant:j.length>0?"outline":"default",children:[n?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),j.length>0?"Connect Another Account":"Connect Instagram"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Instagram Business accounts must be connected to a Facebook Page"})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-blue-600/10 p-3",children:e.jsx(Om,{className:"h-6 w-6 text-blue-700"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"LinkedIn"}),e.jsx(pr,{children:"Connect your LinkedIn profile"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Po,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):k.length>0?e.jsx("div",{className:"space-y-3",children:k.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(xn,{className:"h-10 w-10",children:[e.jsx(Aa,{src:L.profile_picture_url||""}),e.jsx(yn,{children:e.jsx(Om,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.platform_username||"LinkedIn Account"}),e.jsx(rt,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(nc,{children:[e.jsx(Rh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect LinkedIn?"}),e.jsx(Dl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No LinkedIn account connected yet"}),e.jsxs(K,{onClick:_,disabled:n,className:"w-full gap-2",variant:k.length>0?"outline":"default",children:[n?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),k.length>0?"Reconnect LinkedIn":"Connect LinkedIn"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Share content directly to your LinkedIn profile"})]})]}),e.jsxs(Ee,{className:`relative overflow-hidden ${r?"":"opacity-75"}`,children:[!r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(rt,{variant:"secondary",className:"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400",children:"Coming Soon"})}),r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(rt,{variant:"secondary",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"Admin Testing"})}),e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-red-500/10 p-3",children:e.jsx(Oi,{className:"h-6 w-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Google Business"}),e.jsx(pr,{children:"Connect your Google Business Profile"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Po,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):S.length>0?e.jsx("div",{className:"space-y-3",children:S.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(xn,{className:"h-10 w-10",children:[e.jsx(Aa,{src:L.profile_picture_url||""}),e.jsx(yn,{children:e.jsx(Oi,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.page_name||L.platform_username||"Google Business"}),e.jsx(rt,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(nc,{children:[e.jsx(Rh,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Disconnect Google Business?"}),e.jsx(Dl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:r?"No Google Business account connected yet":"Google Business Profile integration is coming soon!"}),e.jsxs(K,{onClick:r?b:void 0,disabled:!r||n,className:"w-full gap-2",variant:S.length>0?"outline":"default",children:[n?e.jsx(Po,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),S.length>0?"Reconnect Google Business":"Connect Google Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Post updates directly to your Google Business Profile"})]})]})]}),r&&(w.length>0||j.length>0)&&e.jsxs(Ee,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-900",children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-amber-500/10 p-3",children:e.jsx(o_,{className:"h-6 w-6 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Meta API Testing (Admin Only)"}),e.jsx(pr,{children:"Run API tests to trigger all required permissions for Meta App Review"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Click "Run Tests" on an account to trigger API calls for: ',e.jsx("strong",{children:"public_profile"}),", ",e.jsx("strong",{children:"pages_show_list"}),", ",e.jsx("strong",{children:"pages_read_engagement"}),", ",e.jsx("strong",{children:"instagram_basic"}),", ",e.jsx("strong",{children:"pages_manage_posts"}),", and ",e.jsx("strong",{children:"instagram_content_publish"}),"."]}),e.jsxs("div",{className:"space-y-3",children:[w.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Hd,{className:"h-5 w-5 text-blue-600"}),e.jsx("span",{className:"font-medium",children:L.page_name||"Facebook Page"})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>I(L.id),disabled:o===L.id,children:o===L.id?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(o_,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-fb-${L.id}`)),j.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Wd,{className:"h-5 w-5 text-pink-600"}),e.jsxs("span",{className:"font-medium",children:["@",L.platform_username||"Instagram"]})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>I(L.id),disabled:o===L.id,children:o===L.id?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(o_,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-ig-${L.id}`))]}),i&&i.length>0&&e.jsxs("div",{className:"mt-4 rounded-lg border bg-background p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Test Results"}),e.jsx("div",{className:"space-y-2",children:i.map((L,R)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[L.status==="success"?e.jsx(ua,{className:"h-4 w-4 text-green-600 mt-0.5 shrink-0"}):L.status==="pending"?e.jsx(Ms,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}):e.jsx(kc,{className:"h-4 w-4 text-red-600 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-mono text-xs bg-muted px-1 rounded",children:L.test}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:L.details})]})]},R))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Note: Facebook posts are auto-deleted. Instagram posts will remain and should be manually deleted. Allow up to 24 hours for Meta to register the API calls."})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"How it works"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"1"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Connect your accounts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Link your Facebook, Instagram, or LinkedIn account"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"2"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Browse Social Swag"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Find the perfect image and caption for your post"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"3"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Post with one click"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Click "Create Post" to share directly to your accounts'})]})]})]})})]})]})]})})}function Dvs(){const[t]=Pc(),s=Pr(),[r,n]=C.useState("loading"),[a,o]=C.useState("Processing your connection...");return C.useEffect(()=>{(async()=>{var f;const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),fe.error("Connection failed: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),fe.error("No authorization code received");return}try{const{data:y,error:_}=await G.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/social-connections/callback"}});if(_)throw _;if(y!=null&&y.success)n("success"),o(`Successfully connected ${((f=y.accounts)==null?void 0:f.length)||0} account(s)!`),fe.success("Social accounts connected successfully!");else throw new Error((y==null?void 0:y.error)||"Unknown error")}catch(y){console.error("OAuth callback error:",y),n("error"),o(y instanceof Error?y.message:"Failed to connect accounts"),fe.error("Failed to connect: "+(y instanceof Error?y.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(It,{className:"text-center",children:[r==="loading"&&e.jsx(Ms,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(hi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(kc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ot,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(pr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function Ovs(){const[t]=Pc(),s=Pr(),[r,n]=C.useState("loading"),[a,o]=C.useState("Connecting your Google Business Profile...");return C.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),fe.error("Connection failed: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),fe.error("No authorization code received");return}try{const{data:f,error:y}=await G.functions.invoke("google-business-oauth",{body:{action:"exchange_code",code:i,state:p}});if(y)throw y;if(f!=null&&f.success)n("success"),o(f.message||"Successfully connected Google Business Profile!"),fe.success("Google Business Profile connected!");else throw new Error((f==null?void 0:f.error)||"Unknown error")}catch(f){console.error("Google OAuth callback error:",f),n("error"),o(f instanceof Error?f.message:"Failed to connect Google Business Profile"),fe.error("Failed to connect: "+(f instanceof Error?f.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(It,{className:"text-center",children:[r==="loading"&&e.jsx(Ms,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(hi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(kc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ot,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(pr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/social-connections"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function Rvs(){const[t]=Pc(),s=Pr(),[r,n]=C.useState("loading"),[a,o]=C.useState("Connecting your LinkedIn account...");return C.useEffect(()=>{(async()=>{var f;const i=t.get("code"),d=t.get("state"),u=t.get("error"),p=t.get("error_description");if(u){console.error("LinkedIn OAuth error:",u,p),n("error"),o(p||"Failed to connect LinkedIn account"),fe.error(p||"Failed to connect LinkedIn");return}if(!i){n("error"),o("No authorization code received"),fe.error("No authorization code received");return}try{const{data:y,error:_}=await G.functions.invoke("linkedin-oauth",{body:{action:"exchange_code",code:i,state:d,callbackPath:"/social-connections/linkedin-callback"}});if(_)throw _;if(y!=null&&y.success)n("success"),o(`Successfully connected ${((f=y.accounts)==null?void 0:f.length)||1} LinkedIn account`),fe.success("LinkedIn connected successfully!");else throw new Error((y==null?void 0:y.error)||"Failed to connect LinkedIn account")}catch(y){console.error("LinkedIn callback error:",y),n("error"),o(y instanceof Error?y.message:"Failed to connect LinkedIn account"),fe.error("Failed to connect LinkedIn")}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center p-4 bg-background",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(It,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4 rounded-full bg-blue-600/10 p-4 w-fit",children:[r==="loading"&&e.jsx(Ms,{className:"h-8 w-8 animate-spin text-blue-600"}),r==="success"&&e.jsx(hi,{className:"h-8 w-8 text-green-600"}),r==="error"&&e.jsx(kc,{className:"h-8 w-8 text-red-600"})]}),e.jsxs(Ot,{className:"flex items-center justify-center gap-2",children:[e.jsx(Om,{className:"h-5 w-5 text-blue-600"}),r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(pr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/social-connections"),disabled:r==="loading",children:r==="success"?"Continue":"Back to Connections"})})]})})}function Fvs(){const t=Pr(),[s,r]=C.useState(null),{data:n,isLoading:a}=cet(s||void 0,!0),{data:o,isLoading:l}=X2e(!0),{cartItems:i}=ule(),d=i.reduce((p,f)=>p+f.quantity,0),u=p=>{t(`/marketplace/${p.id}`)};return a||l?e.jsx(Ts,{title:"Marketplace",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[1,2,3].map(p=>e.jsx(xs,{className:"h-10 w-24 flex-shrink-0"},p))}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:[1,2,3,4].map(p=>e.jsx(xs,{className:"h-72 w-full"},p))})]})}):e.jsx(Ts,{title:"Marketplace",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Marketplace"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Shop exclusive products for LevelUp members"})]}),e.jsxs(K,{variant:"outline",onClick:()=>t("/marketplace/cart"),className:"relative",children:[e.jsx(Sm,{className:"h-4 w-4 mr-2"}),"Cart",d>0&&e.jsx(rt,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:d})]})]}),o&&o.length>0&&e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[e.jsx(K,{variant:s===null?"default":"outline",size:"sm",onClick:()=>r(null),children:"All"}),o.map(p=>e.jsx(K,{variant:s===p.id?"default":"outline",size:"sm",onClick:()=>r(p.id),children:p.name},p.id))]}),n&&n.length>0?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:n.map(p=>{var f;return e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>u(p),children:[e.jsxs("div",{className:"aspect-square bg-muted relative",children:[p.images&&p.images.length>0?e.jsx("img",{src:((f=p.images.find(y=>y.is_primary))==null?void 0:f.image_url)||p.images[0].image_url,alt:p.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(dl,{className:"h-12 w-12 text-muted-foreground"})}),p.category&&e.jsx(rt,{className:"absolute top-2 left-2",variant:"secondary",children:p.category.name})]}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1 line-clamp-1",children:p.name}),p.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2 line-clamp-2",children:p.description}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-bold text-lg",children:["$",Number(p.base_price).toFixed(2)]}),p.variants&&p.variants.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.variants.length," options"]})]})]})]},p.id)})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(dl,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No products available yet."})]})]})})}const Iet=C.forwardRef(({...t},s)=>e.jsx("nav",{ref:s,"aria-label":"breadcrumb",...t}));Iet.displayName="Breadcrumb";const Let=C.forwardRef(({className:t,...s},r)=>e.jsx("ol",{ref:r,className:Pt("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...s}));Let.displayName="BreadcrumbList";const Ore=C.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:Pt("inline-flex items-center gap-1.5",t),...s}));Ore.displayName="BreadcrumbItem";const ave=C.forwardRef(({asChild:t,className:s,...r},n)=>{const a=t?n1e:"a";return e.jsx(a,{ref:n,className:Pt("transition-colors hover:text-foreground",s),...r})});ave.displayName="BreadcrumbLink";const Det=C.forwardRef(({className:t,...s},r)=>e.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:Pt("font-normal text-foreground",t),...s}));Det.displayName="BreadcrumbPage";const ive=({children:t,className:s,...r})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Pt("[&>svg]:size-3.5",s),...r,children:t??e.jsx(Ua,{})});ive.displayName="BreadcrumbSeparator";function zvs(){var te,Q;const{productId:t}=ko(),s=Pr(),{data:r,isLoading:n}=Zxs(t||""),{addToCart:a,cartItems:o}=ule(),[l,i]=C.useState(null),[d,u]=C.useState(1),[p,f]=C.useState(0),[y,_]=C.useState(null),[b,w]=C.useState(!1),[j,k]=C.useState(!1),S=(te=r==null?void 0:r.variants)==null?void 0:te.find(de=>de.id===l),T=((Q=r==null?void 0:r.variants)==null?void 0:Q.filter(de=>de.is_active))||[],I=Number((r==null?void 0:r.base_price)||0),L=S?Number(S.price_adjustment):0,R=I+L,$=Number((r==null?void 0:r.shipping_fee)||0),q=o.reduce((de,re)=>de+re.quantity,0),U=async de=>{if(!de.target.files||de.target.files.length===0)return;w(!0);const re=de.target.files[0],ae=re.name.split(".").pop(),le=`artwork/${Date.now()}-${Math.random().toString(36).substring(7)}.${ae}`;try{const{error:he}=await G.storage.from("marketplace").upload(le,re);if(he)throw he;const{data:{publicUrl:be}}=G.storage.from("marketplace").getPublicUrl(le);_(be),fe.success("Artwork uploaded successfully")}catch(he){fe.error("Failed to upload artwork: "+he.message)}finally{w(!1)}},H=()=>{if(r){if(T.length>0&&!l){fe.error("Please select an option");return}a(r,S||void 0,d,y||void 0),k(!0),fe.success("Added to cart!"),setTimeout(()=>k(!1),2e3)}},Y=()=>{r!=null&&r.images&&f(de=>(de+1)%r.images.length)},se=()=>{r!=null&&r.images&&f(de=>(de-1+r.images.length)%r.images.length)};return n?e.jsx(Ts,{title:"Product",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsx(xs,{className:"aspect-square w-full"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(xs,{className:"h-8 w-3/4"}),e.jsx(xs,{className:"h-6 w-1/4"}),e.jsx(xs,{className:"h-24 w-full"}),e.jsx(xs,{className:"h-12 w-full"})]})]})}):r?e.jsxs(Ts,{title:r.name,children:[e.jsx(Iet,{className:"mb-6",children:e.jsxs(Let,{children:[e.jsx(Ore,{children:e.jsx(ave,{asChild:!0,children:e.jsx(vo,{to:"/marketplace",children:"Marketplace"})})}),r.category&&e.jsxs(e.Fragment,{children:[e.jsx(ive,{}),e.jsx(Ore,{children:e.jsx(ave,{asChild:!0,children:e.jsx(vo,{to:`/marketplace?category=${r.category.id}`,children:r.category.name})})})]}),e.jsx(ive,{}),e.jsx(Ore,{children:e.jsx(Det,{children:r.name})})]})}),e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"relative aspect-square bg-muted rounded-lg overflow-hidden flex items-center justify-center",children:r.images&&r.images.length>0?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:r.images[p].image_url,alt:r.name,className:"max-w-full max-h-full object-contain"}),r.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:se,children:e.jsx(zl,{className:"h-6 w-6"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:Y,children:e.jsx(Ua,{className:"h-6 w-6"})})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(dl,{className:"h-24 w-24 text-muted-foreground"})})}),r.images&&r.images.length>1&&e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-2",children:r.images.map((de,re)=>e.jsx("button",{onClick:()=>f(re),className:`w-16 h-16 flex-shrink-0 rounded-md overflow-hidden border-2 ${re===p?"border-primary":"border-transparent"}`,children:e.jsx("img",{src:de.image_url,alt:"",className:"w-full h-full object-cover"})},de.id))}),r.video&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-2",children:"Product Video"}),e.jsx("div",{className:"aspect-video",children:e.jsx("iframe",{src:r.video.video_url,className:"w-full h-full rounded-lg",allowFullScreen:!0})})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[r.category&&e.jsx(rt,{variant:"secondary",className:"mb-2",children:r.category.name}),e.jsx("h1",{className:"text-3xl font-bold mb-2",children:r.name}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("span",{className:"text-3xl font-bold",children:["$",R.toFixed(2)]}),$>0&&e.jsxs("span",{className:"text-muted-foreground",children:["+ $",$.toFixed(2)," shipping"]})]})]}),r.description&&e.jsx("div",{className:"prose prose-sm max-w-none",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})}),T.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{children:"Select Option"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:T.map(de=>e.jsxs(K,{variant:l===de.id?"default":"outline",onClick:()=>i(de.id),children:[de.name,Number(de.price_adjustment)!==0&&e.jsxs("span",{className:"ml-1 opacity-70",children:["(",Number(de.price_adjustment)>0?"+":"","$",Number(de.price_adjustment).toFixed(2),")"]})]},de.id))})]}),r.allow_artwork_upload&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{children:"Upload Your Artwork (Optional)"}),y?e.jsxs("div",{className:"relative inline-block",children:[e.jsx("img",{src:y,alt:"Your artwork",className:"h-24 w-auto rounded-lg border"}),e.jsx(K,{variant:"ghost",size:"sm",className:"absolute -top-2 -right-2",onClick:()=>_(null),children:"×"})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6",children:[e.jsx("input",{type:"file",accept:"image/*,.pdf,.ai,.eps",onChange:U,className:"hidden",id:"artwork-upload",disabled:b}),e.jsxs("label",{htmlFor:"artwork-upload",className:"flex flex-col items-center cursor-pointer",children:[e.jsx(Za,{className:"h-8 w-8 text-muted-foreground mb-2"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:b?"Uploading...":"Click to upload artwork"}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"Supported: JPG, PNG, PDF, AI, EPS"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{children:"Quantity"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(de=>Math.max(1,de-1)),children:"-"}),e.jsx(Re,{type:"number",value:d,onChange:de=>u(Math.max(1,parseInt(de.target.value)||1)),className:"w-20 text-center",min:"1"}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(de=>de+1),children:"+"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(K,{size:"lg",className:"flex-1",onClick:H,disabled:j,children:j?e.jsxs(e.Fragment,{children:[e.jsx(ha,{className:"h-5 w-5 mr-2"}),"Added!"]}):e.jsxs(e.Fragment,{children:[e.jsx(Sm,{className:"h-5 w-5 mr-2"}),"Add to Cart"]})}),e.jsxs(K,{variant:"outline",size:"lg",onClick:()=>s("/marketplace/cart"),className:"relative",children:[e.jsx(Sm,{className:"h-5 w-5"}),q>0&&e.jsx(rt,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:q})]})]}),r.requires_proof_approval&&e.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-3 rounded-lg",children:"📋 This product requires proof approval before production. You'll receive a proof to review after your order is placed."})]})]})]}):e.jsx(Ts,{title:"Product Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(dl,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Product not found"}),e.jsx(K,{onClick:()=>s("/marketplace"),children:"Back to Marketplace"})]})})}function Bvs(){const t=Pr(),{cartItems:s,removeFromCart:r,updateQuantity:n,getItemPrice:a,getSubtotal:o,getShippingTotal:l,getTotal:i,clearCart:d}=ule(),[u,p]=C.useState(!1),[f,y]=C.useState(""),_=async()=>{if(s.length===0){fe.error("Your cart is empty");return}p(!0);try{const{data:b,error:w}=await G.functions.invoke("marketplace-checkout",{body:{items:s.map(j=>{var k;return{product_id:j.product.id,variant_id:((k=j.variant)==null?void 0:k.id)||null,quantity:j.quantity,artwork_url:j.artworkUrl||null}}),notes:f.trim()||null}});if(w)throw w;if(b!=null&&b.url)d(),window.open(b.url,"_blank");else throw new Error("No checkout URL received")}catch(b){fe.error("Checkout failed: "+b.message)}finally{p(!1)}};return s.length===0?e.jsx(Ts,{title:"Shopping Cart",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Jx,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Your cart is empty"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Add some products to get started!"}),e.jsx(K,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Ts,{title:"Shopping Cart",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[s.map(b=>{var w,j;return e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-24 h-24 flex-shrink-0 bg-muted rounded-lg overflow-hidden",children:b.product.images&&b.product.images.length>0?e.jsx("img",{src:((w=b.product.images.find(k=>k.is_primary))==null?void 0:w.image_url)||b.product.images[0].image_url,alt:b.product.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(Jx,{className:"h-8 w-8 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold line-clamp-1",children:b.product.name}),b.variant&&e.jsx("p",{className:"text-sm text-muted-foreground",children:b.variant.name}),e.jsxs("p",{className:"font-medium mt-1",children:["$",a(b).toFixed(2),Number(b.product.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:["+ $",Number(b.product.shipping_fee).toFixed(2)," shipping"]})]}),b.artworkUrl&&e.jsx("div",{className:"mt-2",children:e.jsx("span",{className:"text-xs text-muted-foreground",children:"Artwork uploaded ✓"})})]}),e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{var k;return r(b.product.id,(k=b.variant)==null?void 0:k.id)},children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var k;return n(b.product.id,(k=b.variant)==null?void 0:k.id,b.quantity-1)},disabled:b.quantity<=1,children:e.jsx(F0,{className:"h-3 w-3"})}),e.jsx(Re,{type:"number",value:b.quantity,onChange:k=>{var S;return n(b.product.id,(S=b.variant)==null?void 0:S.id,parseInt(k.target.value)||1)},className:"w-14 h-8 text-center text-sm",min:"1"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var k;return n(b.product.id,(k=b.variant)==null?void 0:k.id,b.quantity+1)},children:e.jsx(Zs,{className:"h-3 w-3"})})]})]})]})})},`${b.product.id}-${((j=b.variant)==null?void 0:j.id)||"base"}`)}),e.jsx(K,{variant:"ghost",className:"text-destructive",onClick:d,children:"Clear Cart"})]}),e.jsx("div",{children:e.jsxs(Ee,{className:"sticky top-4",children:[e.jsx(It,{children:e.jsx(Ot,{children:"Order Summary"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{children:["Subtotal (",s.reduce((b,w)=>b+w.quantity,0)," items)"]}),e.jsxs("span",{children:["$",o().toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",l().toFixed(2)]})]}),e.jsx(Rl,{}),e.jsxs("div",{className:"flex justify-between font-bold text-lg",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["$",i().toFixed(2)]})]}),e.jsx(Rl,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"orderNotes",children:"Order Notes (Optional)"}),e.jsx(Ar,{id:"orderNotes",placeholder:"Add any special instructions, design notes, or comments for your order...",value:f,onChange:b=>y(b.target.value),rows:3,className:"resize-none"})]}),e.jsx(K,{className:"w-full",size:"lg",onClick:_,disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-5 w-5 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:["Checkout",e.jsx($i,{className:"h-5 w-5 ml-2"})]})}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Secure checkout powered by Stripe"})]})]})})]})})}function $vs(){const t=Pr(),{data:s,isLoading:r}=iys();return r?e.jsx(Ts,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(n=>e.jsx(xs,{className:"h-32 w-full"},n))})}):!s||s.length===0?e.jsx(Ts,{title:"My Orders",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(dl,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No orders yet"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Start shopping to see your orders here!"}),e.jsx(K,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Ts,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:s.map(n=>{var a,o,l;return e.jsx(Ee,{className:"cursor-pointer hover:shadow-md transition-shadow",onClick:()=>t(`/marketplace/orders/${n.id}`),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:n.order_number}),e.jsx("span",{className:"text-muted-foreground text-sm ml-2",children:ys(new Date(n.created_at),"MMM d, yyyy")})]}),e.jsx(rt,{className:Y2e[n.status],children:Z5[n.status]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex -space-x-2",children:[(a=n.items)==null?void 0:a.slice(0,3).map((i,d)=>e.jsxs("div",{className:"w-10 h-10 bg-muted rounded border-2 border-background flex items-center justify-center text-xs font-medium",style:{zIndex:3-d},children:[i.quantity,"×"]},i.id)),n.items&&n.items.length>3&&e.jsxs("div",{className:"w-10 h-10 bg-muted rounded border-2 border-background flex items-center justify-center text-xs font-medium",children:["+",n.items.length-3]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:((o=n.items)==null?void 0:o.length)===1?n.items[0].product_name:`${(l=n.items)==null?void 0:l.length} items`}),e.jsxs("p",{className:"font-semibold",children:["$",Number(n.total).toFixed(2)]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n.tracking_url&&e.jsxs(K,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),window.open(n.tracking_url,"_blank")},children:[e.jsx(sn,{className:"h-4 w-4 mr-1"}),"Track"]}),e.jsx(Ua,{className:"h-5 w-5 text-muted-foreground"})]})]})]})},n.id)})})})}const fDe=["order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed"];function qvs({currentStatus:t,statusHistory:s}){const r=fDe.indexOf(t);return e.jsx("div",{className:"space-y-3",children:fDe.map((n,a)=>{const o=s==null?void 0:s.find(u=>u.status===n),l=ar;return e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center ${l?"bg-green-500 text-white":i?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:l?e.jsx(ua,{className:"h-4 w-4"}):i?e.jsx(Tn,{className:"h-4 w-4"}):e.jsx("span",{className:"text-xs",children:a+1})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`font-medium ${d?"text-muted-foreground":""}`,children:Z5[n]}),o&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ys(new Date(o.created_at),"MMM d, yyyy h:mm a"),o.notes&&` — ${o.notes}`]})]})]},n)})})}function Uvs(){var k;const{orderId:t}=ko(),s=Pr(),{data:r,isLoading:n,refetch:a}=oys(t||""),o=dys(),l=uys(),[i,d]=C.useState(!1),[u,p]=C.useState(null),[f,y]=C.useState(""),[_,b]=C.useState(null),w=async S=>{b(S);try{await o.mutateAsync({orderId:t,itemId:S}),fe.success("Proof approved!"),a()}catch{fe.error("Failed to approve proof")}finally{b(null)}},j=async()=>{if(u){b(u);try{await l.mutateAsync({orderId:t,itemId:u,reason:f}),fe.success("Revision requested"),d(!1),y(""),p(null),a()}catch{fe.error("Failed to request revision")}finally{b(null)}}};return n?e.jsx(Ts,{title:"Order Details",children:e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsx(xs,{className:"h-64 w-full"}),e.jsx(xs,{className:"h-48 w-full"})]}),e.jsx(xs,{className:"h-96 w-full"})]})}):r?e.jsxs(Ts,{title:`Order ${r.order_number}`,children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{children:"Order Status"}),e.jsx(rt,{className:Y2e[r.status],children:Z5[r.status]})]}),e.jsx(Oe,{children:e.jsx(qvs,{currentStatus:r.status,statusHistory:r.status_history})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Items"})}),e.jsx(Oe,{className:"space-y-4",children:(k=r.items)==null?void 0:k.map(S=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold",children:S.product_name}),S.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.variant_name}),e.jsxs("p",{className:"text-sm",children:["Qty: ",S.quantity," × $",Number(S.unit_price).toFixed(2)]})]}),e.jsxs("p",{className:"font-semibold",children:["$",(Number(S.unit_price)*S.quantity).toFixed(2)]})]}),S.artwork_url&&e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your Artwork:"}),e.jsxs("a",{href:S.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline",children:[e.jsx(i_,{className:"h-4 w-4"}),"View Artwork",e.jsx(sn,{className:"h-3 w-3"})]})]}),S.proof_url&&e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Proof Ready for Review"}),e.jsxs("a",{href:S.proof_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline mb-3",children:[e.jsx(i_,{className:"h-4 w-4"}),"View Proof",e.jsx(sn,{className:"h-3 w-3"})]}),S.proof_status==="pending"&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(K,{size:"sm",onClick:()=>w(S.id),disabled:_===S.id,children:[_===S.id?e.jsx(Ms,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(gu,{className:"h-4 w-4 mr-1"}),"Approve"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{p(S.id),d(!0)},disabled:_===S.id,children:[e.jsx(qP,{className:"h-4 w-4 mr-1"}),"Request Changes"]})]}),S.proof_status==="approved"&&e.jsxs(rt,{className:"bg-green-100 text-green-800",children:[e.jsx(ua,{className:"h-3 w-3 mr-1"}),"Proof Approved"]}),S.proof_status==="rejected"&&S.proof_notes&&e.jsxs("div",{className:"mt-2",children:[e.jsx(rt,{variant:"destructive",className:"mb-2",children:"Revision Requested"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.proof_notes})]})]})]},S.id))})]}),r.shipping_name&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(VP,{className:"h-5 w-5"}),"Shipping"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-medium",children:r.shipping_name}),e.jsxs("p",{className:"text-muted-foreground",children:[r.shipping_address,e.jsx("br",{}),r.shipping_city,", ",r.shipping_state," ",r.shipping_zip]}),r.tracking_number&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tracking Number:"}),e.jsx("p",{className:"font-mono font-medium",children:r.tracking_number}),r.tracking_url&&e.jsxs(K,{variant:"link",className:"p-0 h-auto mt-1",onClick:()=>window.open(r.tracking_url,"_blank"),children:["Track Package",e.jsx(sn,{className:"h-3 w-3 ml-1"})]})]})]})]})]}),e.jsx("div",{children:e.jsxs(Ee,{className:"sticky top-4",children:[e.jsx(It,{children:e.jsx(Ot,{children:"Order Summary"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Placed on ",ys(new Date(r.created_at),"MMMM d, yyyy")]}),e.jsx(Rl,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Subtotal"}),e.jsxs("span",{children:["$",Number(r.subtotal).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",Number(r.shipping_total).toFixed(2)]})]})]}),e.jsx(Rl,{}),e.jsxs("div",{className:"flex justify-between font-bold text-lg",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["$",Number(r.total).toFixed(2)]})]}),r.notes&&e.jsxs(e.Fragment,{children:[e.jsx(Rl,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-1",children:"Order Notes"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.notes})]})]})]})]})})]}),e.jsx(_s,{open:i,onOpenChange:d,children:e.jsxs(vs,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Request Changes"}),e.jsx(Kr,{children:"Please describe what changes you'd like made to the proof."})]}),e.jsx(Ar,{placeholder:"Describe the changes needed...",value:f,onChange:S=>y(S.target.value),rows:4}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(K,{onClick:j,disabled:!f.trim()||_!==null,children:[_?e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Submit Request"]})]})]})})]}):e.jsx(Ts,{title:"Order Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(dl,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Order not found"}),e.jsx(K,{onClick:()=>s("/marketplace/orders"),children:"View All Orders"})]})})}function Vvs(){const t=Pr(),[s]=Pc();return s.get("session_id"),C.useEffect(()=>{localStorage.removeItem("marketplace-cart")},[]),e.jsx(Ts,{title:"Order Confirmed",children:e.jsx("div",{className:"max-w-lg mx-auto text-center py-8",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-8 pb-6",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx(ua,{className:"h-8 w-8 text-green-600"})}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Thank You for Your Order!"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Your order has been confirmed and is being processed. You'll receive an email confirmation shortly."}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 mb-6 text-left",children:[e.jsxs("h3",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(dl,{className:"h-4 w-4"}),"What happens next?"]}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("li",{children:"• We'll review your order and prepare it for production"}),e.jsx("li",{children:"• If your order requires a proof, you'll receive it for approval"}),e.jsx("li",{children:"• Once approved, we'll begin production and ship when ready"}),e.jsx("li",{children:"• You'll receive tracking info when your order ships"})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(K,{className:"flex-1",onClick:()=>t("/marketplace/orders"),children:["View My Orders",e.jsx($i,{className:"h-4 w-4 ml-2"})]}),e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>t("/marketplace"),children:"Continue Shopping"})]})]})})})})}function Hvs(){const{user:t}=Hs(),[s,r]=C.useState("store"),[n,a]=C.useState(null),[o,l]=C.useState(null),[i,d]=C.useState(!1),[u,p]=C.useState(5),[f,y]=C.useState(""),[_,b]=C.useState(!1),[w,j]=C.useState(!1),[k,S]=C.useState(""),[T,I]=C.useState(null),[L,R]=C.useState(!1),{hasSubmittedReview:$,submitReview:q,markPostedToGoogle:U}=cVe(),{data:H}=uet(),{data:Y,isLoading:se}=det(),{data:te,isLoading:Q}=yys(n),{data:de,isLoading:re}=vys(t==null?void 0:t.id),{data:ae=0}=bys(t==null?void 0:t.id),le=wys(),he=new Set((de==null?void 0:de.map(Me=>Me.item_id))||[]),be=async()=>{if(o)try{await le.mutateAsync(o.id),fe.success(`Successfully purchased "${o.name}"!`),l(null)}catch(Me){fe.error(Me.message||"Failed to purchase item")}},_e=async()=>{if(!f.trim()){fe.error("Please write a review");return}b(!0);const Me=await q(u,f);b(!1),Me.success?(fe.success("Thank you for your review! You earned 25 points!"),S(f),j(!0),y(""),p(5)):fe.error(Me.error||"Failed to submit review")},je=()=>{navigator.clipboard.writeText(k),fe.success("Review copied to clipboard!")},Ne=()=>{U(),window.open("https://g.page/r/CT8bqTBTm7nJEBM/review","_blank")},Ge=()=>{j(!1),d(!1),S("")};return se||Q||re?e.jsx(Ts,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{className:"h-24 w-full"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3,4,5,6].map(Me=>e.jsx(xs,{className:"h-64"},Me))})]})}):e.jsxs(Ts,{title:"Reward Store",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Reward Store"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Redeem your points for exclusive rewards"})]}),e.jsx(Ee,{className:"bg-gradient-to-r from-primary/10 to-primary/5 border-primary/20",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx(Gn,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your Spendable Points"}),e.jsx("p",{className:"text-3xl font-bold text-primary",children:ae.toLocaleString()})]})]}),e.jsxs("div",{className:"flex items-center gap-6 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ao,{className:"h-4 w-4"}),e.jsx("span",{children:"Earn points by attending events"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(nh,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{children:"Streak bonuses add extra points!"})]})]})]})})}),e.jsx(bf,{open:L,onOpenChange:R,children:e.jsxs(Ee,{className:"border-primary/20",children:[e.jsx(wf,{asChild:!0,children:e.jsx(It,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(ao,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-base",children:"How to Earn Points"}),e.jsx(pr,{children:"See all the ways you can earn spendable points"})]})]}),L?e.jsx(Ug,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(Ho,{className:"h-5 w-5 text-muted-foreground"})]})})}),e.jsx(jf,{children:e.jsx(Oe,{className:"pt-0",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[H==null?void 0:H.filter(Me=>Me.is_active).map(Me=>{const Te=Fe=>{switch(Fe){case"event_attendance":return e.jsx(on,{className:"h-5 w-5"});case"leave_review":return e.jsx(Gn,{className:"h-5 w-5"});case"add_listing":return e.jsx(On,{className:"h-5 w-5"});case"first_contact":return e.jsx(hr,{className:"h-5 w-5"});case"first_video":return e.jsx(Nn,{className:"h-5 w-5"});case"first_community_post":return e.jsx(io,{className:"h-5 w-5"});default:return e.jsx(po,{className:"h-5 w-5"})}};return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/50 border",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center text-primary shrink-0",children:Te(Me.action_key)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:Me.action_name}),Me.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Me.description})]}),e.jsxs(rt,{variant:"secondary",className:"font-bold shrink-0",children:["+",Me.points]})]},Me.id)}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/20 flex items-center justify-center text-orange-500 shrink-0",children:e.jsx(nh,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"Streak Bonuses"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Attend consecutive weeks for bonus points!"})]}),e.jsx(rt,{variant:"outline",className:"font-bold shrink-0 border-orange-500/50 text-orange-600",children:"+Bonus"})]})]})})})]})}),!$&&e.jsx(Ee,{className:"bg-gradient-to-r from-yellow-500/10 to-orange-500/10 border-yellow-500/20",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-yellow-500/20 flex items-center justify-center",children:e.jsx(io,{className:"h-6 w-6 text-yellow-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Earn 25 Free Points!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Leave a quick review and earn 25 spendable points"})]})]}),e.jsxs(K,{onClick:()=>d(!0),className:"bg-yellow-600 hover:bg-yellow-700",children:[e.jsx(Gn,{className:"h-4 w-4 mr-2"}),"Leave Review"]})]})})}),e.jsxs(ka,{value:s,onValueChange:r,children:[e.jsxs(_a,{children:[e.jsxs(js,{value:"store",className:"flex items-center gap-2",children:[e.jsx(Jx,{className:"h-4 w-4"}),"Store"]}),e.jsxs(js,{value:"my-rewards",className:"flex items-center gap-2",children:[e.jsx(dl,{className:"h-4 w-4"}),"My Rewards",de&&de.length>0&&e.jsx(rt,{variant:"secondary",className:"ml-1",children:de.length})]})]}),e.jsxs(zs,{value:"store",className:"mt-6",children:[Y&&Y.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[e.jsx(K,{variant:n===null?"default":"outline",size:"sm",onClick:()=>a(null),children:"All"}),Y.map(Me=>e.jsxs(K,{variant:n===Me.id?"default":"outline",size:"sm",onClick:()=>a(Me.id),children:[Me.icon&&`${Me.icon} `,Me.name]},Me.id))]}),!te||te.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(po,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No items available"}),e.jsx("p",{className:"text-sm",children:"Check back later for new rewards!"})]})})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:te.map(Me=>{const Te=he.has(Me.id),Fe=Me.max_quantity!==null&&Me.current_quantity===0,Ae=ae>=Me.points_cost;return e.jsxs(Ee,{className:`overflow-hidden transition-all cursor-pointer hover:shadow-lg ${Te?"ring-2 ring-green-500/50 bg-green-500/5":""}`,onClick:()=>I(Me),children:[Me.preview_image_url?e.jsxs("div",{className:"aspect-video relative overflow-hidden bg-muted",children:[e.jsx("img",{src:Me.preview_image_url,alt:Me.name,className:"w-full h-full object-cover"}),Te&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(rt,{className:"bg-green-500 text-white",children:[e.jsx(ua,{className:"h-3 w-3 mr-1"}),"Owned"]})}),Fe&&!Te&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(rt,{variant:"destructive",children:"Sold Out"})})]}):e.jsxs("div",{className:"aspect-video bg-muted flex items-center justify-center relative",children:[e.jsx(po,{className:"h-12 w-12 text-muted-foreground/50"}),Te&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(rt,{className:"bg-green-500 text-white",children:[e.jsx(ua,{className:"h-3 w-3 mr-1"}),"Owned"]})})]}),e.jsxs(It,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(Ot,{className:"text-lg",children:Me.name}),e.jsxs(rt,{variant:"secondary",className:"font-bold shrink-0",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),Me.points_cost]})]}),Me.category&&e.jsxs(rt,{variant:"outline",className:"w-fit",children:[Me.category.icon&&`${Me.category.icon} `,Me.category.name]})]}),e.jsxs(Oe,{children:[e.jsx(pr,{className:"mb-4 line-clamp-2",children:Me.description||"No description available"}),Me.max_quantity!==null&&!Te&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:[Me.current_quantity," of ",Me.max_quantity," remaining"]}),Te?e.jsx(K,{className:"w-full",onClick:Ue=>{Ue.stopPropagation(),Me.file_url&&Bpe(Me.file_url,Me.name)},disabled:!Me.file_url,children:Me.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Access"]})}):e.jsx(K,{className:"w-full",onClick:Ue=>{Ue.stopPropagation(),l(Me)},disabled:Fe||!Ae,children:Fe?"Sold Out":Ae?e.jsxs(e.Fragment,{children:[e.jsx(Jx,{className:"h-4 w-4 mr-2"}),"Purchase"]}):`Need ${Me.points_cost-ae} more pts`})]})]},Me.id)})})]}),e.jsx(zs,{value:"my-rewards",className:"mt-6",children:!de||de.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(dl,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No rewards yet"}),e.jsx("p",{className:"text-sm",children:"Purchase items from the store to see them here!"})]})})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:de.map(Me=>{var Te,Fe,Ae,Ue,ut;return e.jsxs(Ee,{className:"overflow-hidden",children:[(Te=Me.item)!=null&&Te.preview_image_url?e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted",children:e.jsx("img",{src:Me.item.preview_image_url,alt:((Fe=Me.item)==null?void 0:Fe.name)||"Reward",className:"w-full h-full object-cover"})}):e.jsx("div",{className:"aspect-video bg-muted flex items-center justify-center",children:e.jsx(po,{className:"h-12 w-12 text-muted-foreground/50"})}),e.jsxs(It,{className:"pb-2",children:[e.jsx(Ot,{className:"text-lg",children:((Ae=Me.item)==null?void 0:Ae.name)||"Unknown Item"}),e.jsxs(pr,{className:"text-xs",children:["Purchased for ",Me.points_spent," points • ",new Date(Me.purchased_at).toLocaleDateString()]})]}),e.jsx(Oe,{children:e.jsx(K,{className:"w-full",onClick:()=>{var De,Rt;(De=Me.item)!=null&&De.file_url&&Bpe(Me.item.file_url,(Rt=Me.item)==null?void 0:Rt.name)},disabled:!((Ue=Me.item)!=null&&Ue.file_url),children:((ut=Me.item)==null?void 0:ut.item_type)==="file"?e.jsxs(e.Fragment,{children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Access"]})})})]},Me.id)})})})]})]}),e.jsx(nc,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Confirm Purchase"}),e.jsxs(Dl,{children:['Are you sure you want to purchase "',o==null?void 0:o.name,'" for ',o==null?void 0:o.points_cost," points?",e.jsx("br",{}),e.jsx("br",{}),"You currently have ",e.jsxs("strong",{children:[ae," points"]}),". After this purchase, you'll have"," ",e.jsxs("strong",{children:[ae-((o==null?void 0:o.points_cost)||0)," points"]})," remaining."]})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:be,disabled:le.isPending,children:le.isPending?"Purchasing...":"Confirm Purchase"})]})]})}),e.jsx(_s,{open:i,onOpenChange:Me=>{!Me&&w?Ge():d(Me)},children:e.jsx(vs,{children:w?e.jsxs(e.Fragment,{children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx(ua,{className:"h-5 w-5 text-green-500"}),"Thank You for Your Review!"]}),e.jsx(Kr,{children:"Would you also share your review on Google? It helps other agents discover LevelUp!"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-muted p-4 rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your review:"}),e.jsxs("p",{className:"text-sm italic",children:['"',k,'"']})]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:je,children:[e.jsx(ai,{className:"h-4 w-4 mr-2"}),"Copy Review to Clipboard"]})]}),e.jsxs(Un,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(K,{variant:"outline",onClick:Ge,children:"Maybe Later"}),e.jsxs(K,{onClick:Ne,className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Leave Google Review"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Leave a Review"}),e.jsx(Kr,{children:"Share your experience with LevelUp and earn 25 spendable points!"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Rating"}),e.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(Me=>e.jsx("button",{type:"button",onClick:()=>p(Me),className:"focus:outline-none",children:e.jsx(Gn,{className:`h-8 w-8 transition-colors ${u>=Me?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400"}`})},Me))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Review"}),e.jsx(Ar,{placeholder:"What do you love about LevelUp? How has it helped your business?",value:f,onChange:Me=>y(Me.target.value),rows:4})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{onClick:_e,disabled:_,className:"bg-yellow-600 hover:bg-yellow-700",children:_?"Submitting...":"Submit & Earn 25 Points"})]})]})})}),e.jsx(_s,{open:!!T,onOpenChange:()=>I(null),children:e.jsxs(vs,{className:"max-w-lg",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[T==null?void 0:T.name,e.jsxs(rt,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),T==null?void 0:T.points_cost]})]}),(T==null?void 0:T.category)&&e.jsxs(rt,{variant:"outline",className:"w-fit",children:[T.category.icon&&`${T.category.icon} `,T.category.name]})]}),(T==null?void 0:T.preview_image_url)&&e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted rounded-lg",children:e.jsx("img",{src:T.preview_image_url,alt:T.name,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:(T==null?void 0:T.description)||"No description available"}),(T==null?void 0:T.max_quantity)!==null&&!he.has((T==null?void 0:T.id)||"")&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[T==null?void 0:T.current_quantity," of ",T==null?void 0:T.max_quantity," remaining"]})]}),e.jsx(Un,{children:T&&he.has(T.id)?e.jsx(K,{className:"w-full",onClick:()=>{T.file_url&&Bpe(T.file_url,T.name)},disabled:!T.file_url,children:T.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Access"]})}):T&&e.jsx(K,{className:"w-full",onClick:()=>{I(null),l(T)},disabled:T.max_quantity!==null&&T.current_quantity===0||ae{const{user:t}=Hs(),s=rs(),r=wt({queryKey:["smart-presentations",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:p}=await G.from("smart_presentations").select("*").eq("owner_user_id",t.id).neq("status","archived").order("created_at",{ascending:!1});if(p)throw p;return u||[]},enabled:!!t}),n=wt({queryKey:["smart-presentation-templates",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:p}=await G.from("smart_presentation_templates").select("*").eq("is_active",!0).order("created_at",{ascending:!0});if(p)throw p;return u||[]},enabled:!!t}),a=Dt({mutationFn:async u=>{const{data:p,error:f}=await G.from("smart_presentations").insert({owner_user_id:t.id,...u}).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),o=Dt({mutationFn:async({id:u,...p})=>{const{data:f,error:y}=await G.from("smart_presentations").update(p).eq("id",u).select().single();if(y)throw y;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),l=Dt({mutationFn:async u=>{const{data:p,error:f}=await G.from("smart_presentations").update({status:"published",published_at:new Date().toISOString()}).eq("id",u).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),fe.success("Presentation published!")}}),i=Dt({mutationFn:async u=>{const{error:p}=await G.from("smart_presentations").update({status:"archived"}).eq("id",u);if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),fe.success("Presentation archived")}}),d=Dt({mutationFn:async u=>{const{error:p}=await G.from("smart_presentation_templates").insert({owner_user_id:t.id,name:u.title+" Template",description:"Created from "+u.title,template_type:"custom",icon:"📄",sections:u.sections,cta_config:{type:u.cta_type,label:u.cta_label},is_system:!1});if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentation-templates"]}),fe.success("Saved as template!")}});return{presentations:r.data||[],templates:n.data||[],isLoading:r.isLoading,templatesLoading:n.isLoading,createPresentation:a,updatePresentation:o,publishPresentation:l,archivePresentation:i,saveAsTemplate:d}},Wvs=()=>{const t=Pr(),{presentations:s,isLoading:r,archivePresentation:n,saveAsTemplate:a}=Oet(),o=i=>i.status==="draft"?e.jsx(rt,{variant:"outline",className:"text-xs",children:"Draft"}):i.view_count>1?e.jsx(rt,{className:"text-xs bg-emerald-100 text-emerald-700 border-emerald-200",children:"Revisited"}):i.view_count===1?e.jsx(rt,{className:"text-xs bg-blue-100 text-blue-700 border-blue-200",children:"Opened"}):e.jsx(rt,{variant:"secondary",className:"text-xs",children:"Not Opened"}),l=i=>{const d=`https://presentations.relevelup.com/${i}`;navigator.clipboard.writeText(d),fe.success("Link copied!")};return e.jsx(Ts,{title:"Smart Presentations",children:e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h1",{className:"text-2xl font-serif font-bold text-foreground",children:"Smart Presentations"})}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Create personalized, video-first presentations for your clients"})]}),e.jsxs(K,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Create Presentation"]})]}),r?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(i=>e.jsx(xs,{className:"h-20 w-full rounded-lg"},i))}):s.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(Hg,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No presentations yet"}),e.jsx("p",{className:"text-muted-foreground mb-6 max-w-md",children:"Create your first Smart Presentation to impress clients with personalized, video-first content."}),e.jsxs(K,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Create Your First Presentation"]})]})}):e.jsx("div",{className:"space-y-3",children:s.map(i=>e.jsx(Ee,{className:"hover:shadow-sm transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(In,{className:"h-5 w-5 text-primary"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-semibold truncate",children:i.title}),o(i)]}),e.jsxs("div",{className:"flex items-center gap-x-3 gap-y-0.5 flex-wrap text-sm text-muted-foreground mt-0.5",children:[i.client_name&&e.jsx("span",{children:i.client_name}),e.jsxs("span",{children:["Created ",ys(new Date(i.created_at),"MMM d, yyyy")]}),i.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xa,{className:"h-3 w-3"})," ",i.view_count," view",i.view_count!==1?"s":""]}),i.cta_clicked_count>0&&e.jsx("span",{className:"text-emerald-600 font-medium",children:"CTA clicked"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap sm:flex-nowrap sm:shrink-0",children:[i.status==="published"&&i.share_token&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>l(i.share_token),children:[e.jsx(ai,{className:"h-3.5 w-3.5 mr-1"}),"Copy Link"]}),i.status==="published"&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}?edit=true`),children:"Edit"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}`),children:i.status==="draft"?"Edit":"View"}),e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(af,{className:"h-4 w-4"})})}),e.jsxs(Md,{align:"end",children:[i.status==="published"&&i.share_token&&e.jsxs(Na,{onClick:()=>window.open(`https://presentations.relevelup.com/${i.share_token}`,"_blank"),children:[e.jsx(sn,{className:"h-4 w-4 mr-2"}),"Preview Link"]}),e.jsxs(Na,{onClick:()=>a.mutate(i),children:[e.jsx(In,{className:"h-4 w-4 mr-2"}),"Save as Template"]}),e.jsxs(Na,{onClick:()=>n.mutate(i.id),className:"text-destructive",children:[e.jsx(u5,{className:"h-4 w-4 mr-2"}),"Archive"]})]})]})]})]})})]})})},i.id))})]})})},gDe={Welcome:[{label:"Warm & Personal",text:"Hey there! I'm so glad you're here. I put this presentation together just for you because I truly believe we'd make a great team. Over the next few minutes, I'll walk you through exactly how I can help you achieve your real estate goals. Let's dive in!"},{label:"Professional & Confident",text:"Welcome! Thank you for taking the time to check this out. I've prepared this presentation specifically with your needs in mind. I want to show you what sets me apart, the results I've delivered, and how I plan to make your experience smooth and successful. Let's get started!"}],"About Me":[{label:"Relatable Story",text:"Let me tell you a little about myself. I didn't just fall into real estate — I chose it because I love helping people with one of the biggest decisions of their lives. Every client I work with gets my full attention, my honest advice, and someone who truly has their back from start to finish."},{label:"Results-Focused",text:"Here's what I want you to know about me: I'm not just another agent. I've helped dozens of families find their perfect home and get top dollar for their properties. I stay on top of the market, I communicate constantly, and I don't stop until we hit your goals."}],"Market Update":[{label:"Engaging Overview",text:"Let's talk about what's happening in the market right now. I want you to feel confident and informed, so here's the honest picture. I'll break down the key numbers, what they mean for you, and how we can use current conditions to your advantage. Knowledge is power!"},{label:"Buyer-Focused",text:"The market is always moving, and I want to make sure you're in the best position possible. Here's what the latest data tells us, what opportunities are out there for you, and why timing matters. Let me walk you through it."}],"My Process":[{label:"Step-by-Step",text:"I want you to know exactly what to expect when we work together. My process is simple, clear, and designed to take the stress out of the equation. From our first conversation all the way to closing day, I'll be right there guiding you every step of the way. Here's how it works."},{label:"Client-Centered",text:"One thing my clients always tell me is how easy and stress-free the process was. That's not by accident — I've refined my approach over the years to make sure you always know what's happening, what's next, and that someone's got your back. Let me show you how."}],Testimonials:[{label:"Social Proof",text:"Don't just take my word for it — let me share what some of my past clients have said. These are real people, real experiences, and real results. I'm proud of the relationships I've built and the outcomes we've achieved together."}],Pricing:[{label:"Transparent & Value-Driven",text:"Let's talk about the investment. I believe in being completely transparent about pricing because trust is everything. Here's what you get when you work with me, and why my clients say it's the best decision they made. Let me walk you through it."}],"Call to Action":[{label:"Warm Close",text:"So here's my ask — let's connect! I'd love to hop on a quick call, answer any questions you have, and see how I can help. No pressure, no obligation — just a real conversation about your goals. Click the button below and let's make it happen!"},{label:"Urgency Close",text:"The market waits for no one, and neither should you. Let's get started today! Click the link below to schedule a quick chat. I promise — this could be the best 15 minutes you invest in your real estate journey."}]},Gvs=[{label:"Engaging Introduction",text:"In this section, I want to share something important with you. I've put real thought into this, and I think you'll find it valuable. Let me walk you through what I've prepared — I'm excited for you to see it!"},{label:"Keep It Simple",text:"Let me keep this short and sweet. Here's what you need to know, and why it matters for you. I'm always about giving you the real picture — no fluff, just the facts and my honest take."}];function Kvs(t){const s=gDe[t];if(s)return s;const r=t.toLowerCase();for(const[n,a]of Object.entries(gDe))if(r.includes(n.toLowerCase())||n.toLowerCase().includes(r))return a;return Gvs}function Zvs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=C.useState(!1),[o,l]=C.useState("script"),[i,d]=C.useState(0),[u,p]=C.useState(0),{canRecord:f}=NJe(),y=xS(),[_,b]=C.useState(""),[w,j]=C.useState(!1),[k,S]=C.useState(!0),[T,I]=C.useState(!1),[L,R]=C.useState(null),$=Kvs(t),q=()=>{l("script"),d(0),p(0),b(""),j(!1),S(!0),I(!1),R(null)},U=Q=>{!Q&&(o==="uploading"||o==="processing")||(a(Q),Q||q())},H=Q=>{R(Q),b($[Q].text),j(!1)},Y=()=>{l("record"),S(_.trim().length>0)},se=()=>{b(""),S(!1),l("record")},te=C.useCallback(async(Q,de)=>{l("uploading");try{const re=t||"Presentation Video",{videoId:ae,uploadUrl:le,libraryId:he}=await fD(re),{apiKey:be}=await gD(ae),_e=new XMLHttpRequest;_e.upload.onprogress=Me=>{Me.lengthComputable&&d(Me.loaded/Me.total*100)},await new Promise((Me,Te)=>{_e.onload=()=>_e.status>=200&&_e.status<300?Me():Te(new Error("Upload failed")),_e.onerror=()=>Te(new Error("Upload failed")),_e.open("PUT",le),_e.setRequestHeader("AccessKey",be),_e.send(Q)}),l("processing");let je=0;const Ne=Date.now(),Ge=9e4;let we=null;for(;je<4;){if(await new Promise(Te=>setTimeout(Te,3e3)),Date.now()-Ne>Ge){const Te=Q.size/1048576,Fe=`https://iframe.mediadelivery.net/embed/${he}/${ae}?responsive=true`;await y.mutateAsync({bunny_video_id:ae,playback_url:Fe,file_size_mb:Te,title:re,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(Fe),fe.success("Video saved — still encoding. It will be ready shortly."),l("done"),setTimeout(()=>a(!1),1500);return}const Me=await oM(ae);if(je=Me.status,p(Me.encodeProgress||0),je===4)we={playbackUrl:Me.directPlayUrl,thumbnailUrl:Me.thumbnailUrl,previewUrl:Me.previewUrl||null,duration:Me.length||de,fileSizeMb:(Me.storageSize||Q.size)/(1024*1024)};else if(je===5||je===6)throw new Error("Video processing failed")}if(!we)throw new Error("No video data");await y.mutateAsync({bunny_video_id:ae,contact_id:s||void 0,playback_url:we.playbackUrl,thumbnail_url:we.thumbnailUrl,preview_url:we.previewUrl,duration_seconds:we.duration,file_size_mb:we.fileSizeMb,title:re,status:"ready",touch_type:"presentation"}),r(we.playbackUrl),fe.success("Video recorded, saved to library & attached!"),l("done"),setTimeout(()=>a(!1),1500)}catch(re){console.error("Recording upload error:",re),fe.error("Failed to process video. Please try again."),l("record")}},[t,s,r,y]);return e.jsxs(_s,{open:n,onOpenChange:U,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Record a video",children:[e.jsx(Nn,{className:"h-3.5 w-3.5"}),"Record"]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto !top-[5%] !translate-y-0 sm:!top-[5%] sm:!translate-y-0",children:[e.jsx(Ss,{children:e.jsxs(ks,{children:[o==="script"&&`Prepare your script for "${t}"`,o==="record"&&`Record video for "${t}"`,o==="uploading"&&"Uploading...",o==="processing"&&"Processing...",o==="done"&&"Done!"]})}),o==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a starter script below, edit it to make it yours, or skip and speak freely."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starter Scripts"}),e.jsx("div",{className:"grid gap-2",children:$.map((Q,de)=>e.jsxs("button",{onClick:()=>H(de),className:Pt("text-left p-3 rounded-lg border transition-all hover:bg-accent/50",L===de?"border-primary bg-primary/5 ring-1 ring-primary":"border-border"),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(In,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:Q.label})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 ml-5.5",children:Q.text})]},de))})]}),_&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Your Script"}),!w&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>j(!0),className:"h-7 text-xs gap-1",children:[e.jsx(Da,{className:"h-3 w-3"}),"Edit"]})]}),w?e.jsx(Ar,{value:_,onChange:Q=>b(Q.target.value),rows:5,placeholder:"Type your script here...",className:"text-sm"}):e.jsx("div",{className:"p-3 rounded-lg bg-muted/50 text-sm text-foreground leading-relaxed",children:_})]}),!_&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Or Write Your Own"}),e.jsx(Ar,{value:_,onChange:Q=>{b(Q.target.value),R(null)},rows:4,placeholder:"Type your own script here...",className:"text-sm"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:se,className:"text-muted-foreground",children:"Skip — no teleprompter"}),e.jsx(K,{onClick:Y,disabled:!1,children:_.trim()?"Continue with Script":"Continue Without Script"})]})]}),!f&&o==="record"?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-8 text-center",children:[e.jsx(Ju,{className:"h-10 w-10 text-destructive"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You've reached your video storage limit. Delete some videos to free up space."})]}):o==="record"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Record up to 60 seconds. Saved to your library & auto-attached."}),_.trim()&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>S(!k),className:"h-7 text-xs gap-1",children:[k?e.jsx(Im,{className:"h-3 w-3"}):e.jsx(xa,{className:"h-3 w-3"}),k?"Hide Script":"Show Script"]})]}),e.jsx($ce,{maxDurationSeconds:60,onRecordingComplete:te,onRecordingStateChange:I,onError:Q=>fe.error(Q),teleprompterContent:_.trim()?e.jsx(zJe,{text:_,isVisible:k,onToggleVisibility:()=>S(!k),isRecording:T,startCountdown:!1}):void 0}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>l("script"),className:"text-xs text-muted-foreground",children:"← Back to script"})]}):o==="uploading"?e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(Ms,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(Ti,{value:i,className:"h-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Uploading... ",Math.round(i),"%"]})]})]}):o==="processing"?e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(Ms,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(Ti,{value:u,className:"h-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Processing... ",Math.round(u),"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"This usually takes less than a minute"})]})]}):o==="done"?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[e.jsx(hi,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Video attached!"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved to your video library"})]}):null]})]})}function Yvs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=C.useState(!1),[o,l]=C.useState(null),[i,d]=C.useState("idle"),[u,p]=C.useState(0),f=C.useRef(null),y=xS(),{data:_}=Fce(),b=(_==null?void 0:_.total_storage_mb)||0,j=((_==null?void 0:_.max_storage_mb)||1024)-b,k=()=>{l(null),d("idle"),p(0)},S=$=>{!$&&i!=="idle"&&i!=="done"||(a($),$||k())},T=$=>{var H;const q=(H=$.target.files)==null?void 0:H[0];if(!q)return;if(!q.type.startsWith("video/")){fe.error("Please select a video file");return}const U=q.size/(1024*1024);if(U>500){fe.error("Video file must be less than 500MB");return}if(U>j){fe.error(`Not enough storage. You have ${j.toFixed(1)} MB remaining.`);return}l(q)},I=C.useCallback(async()=>{if(o){d("creating"),p(0);try{const $=t||o.name,{data:q,error:U}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:$,isAgentVideo:!0}});if(U)throw new Error(U.message);const{videoId:H,libraryId:Y}=q;d("uploading");const{data:se,error:te}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:H,isAgentVideo:!0}});if(te)throw new Error(te.message);await new Promise((re,ae)=>{const le=new XMLHttpRequest;le.upload.addEventListener("progress",he=>{he.lengthComputable&&p(Math.round(he.loaded/he.total*100))}),le.addEventListener("load",()=>le.status>=200&&le.status<300?re():ae(new Error(`Upload failed (${le.status})`))),le.addEventListener("error",()=>ae(new Error("Upload failed"))),le.open("PUT",se.uploadUrl),le.setRequestHeader("AccessKey",se.apiKey),le.send(o)}),d("processing");const Q=o.size/(1024*1024),de=`https://iframe.mediadelivery.net/embed/${Y}/${H}`;await y.mutateAsync({bunny_video_id:H,playback_url:de,file_size_mb:Q,title:$,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(de),d("done"),fe.success("Video uploaded & attached to section!"),setTimeout(()=>a(!1),1200)}catch($){console.error("Upload error:",$),fe.error($ instanceof Error?$.message:"Failed to upload video"),d("idle")}}},[o,t,s,r,y]),L=()=>{switch(i){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${u}%`;case"processing":return"Saving video...";case"done":return"Done!";default:return""}},R=i!=="idle"&&i!=="done";return e.jsxs(_s,{open:n,onOpenChange:S,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Upload a video file",children:[e.jsx(Za,{className:"h-3.5 w-3.5"}),"Upload"]})}),e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsx(Ss,{children:e.jsxs(ks,{children:['Upload Video for "',t,'"']})}),e.jsxs("div",{className:"space-y-4 py-2",children:[o?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(Nn,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:o.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(o.size/(1024*1024)).toFixed(1)," MB"]})]}),!R&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(null),children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>{var $;return($=f.current)==null?void 0:$.click()},children:[e.jsx(Za,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select a video file"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"MP4, MOV, WebM (max 500MB)"})]}),e.jsx("input",{ref:f,type:"file",accept:"video/*",className:"hidden",onChange:T,disabled:R}),R&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Ms,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:L()})]}),e.jsx(Ti,{value:i==="uploading"?u:i==="processing"?100:10})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>S(!1),disabled:R,children:"Cancel"}),e.jsx(K,{onClick:I,disabled:!o||R,children:R?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Za,{className:"h-4 w-4 mr-2"}),"Upload & Attach"]})})]})]})]})}const xDe=[{value:"schedule_call",label:"Schedule a Call"},{value:"ready_to_list",label:"Ready to List"},{value:"request_pricing",label:"Request Pricing Update"},{value:"sign_agreement",label:"Sign Buyer Agreement"},{value:"text_questions",label:"Text Me Questions"}],yDe=()=>{const t=Pr(),{id:s}=ko(),{user:r}=Hs(),{templates:n,templatesLoading:a,createPresentation:o,updatePresentation:l,publishPresentation:i}=Oet(),{isGmailConnected:d,gmailEmail:u}=Ny(),[p,f]=C.useState(!1),[y,_]=C.useState("client"),[b,w]=C.useState(!1),[j,k]=C.useState(""),[S,T]=C.useState([]),[I,L]=C.useState(!1),[R,$]=C.useState(null),[q,U]=C.useState(!1),[H,Y]=C.useState(""),[se,te]=C.useState(""),[Q,de]=C.useState(""),[re,ae]=C.useState("buyer"),[le,he]=C.useState(""),[be,_e]=C.useState(null),[je,Ne]=C.useState(""),[Ge,we]=C.useState([]),[Me,Te]=C.useState("schedule_call"),[Fe,Ae]=C.useState("Schedule a Call"),[Ue,ut]=C.useState(""),[De,Rt]=C.useState(""),[me,Xe]=C.useState(null),[ot,nt]=C.useState(s||null),[Se,it]=C.useState(null),[$e,ct]=C.useState(!1),qe=async(Ct,Is)=>{if(!r)return;const qs=5*1024*1024;if(Ct.size>qs){fe.error("Image must be under 5MB");return}if(!Ct.type.startsWith("image/")){fe.error("Please upload an image file");return}Xe(Is);try{const gr=Ct.name.split(".").pop()||"jpg",Wn=`${r.id}/${Date.now()}.${gr}`,{error:ii}=await G.storage.from("listing-photos").upload(Wn,Ct);if(ii)throw ii;const{data:{publicUrl:bo}}=G.storage.from("listing-photos").getPublicUrl(Wn);Tt(Is,{image_url:bo}),fe.success("Image uploaded")}catch{fe.error("Failed to upload image")}finally{Xe(null)}};C.useEffect(()=>{s&&Ze(s)},[s]);const Ze=async Ct=>{const{data:Is,error:qs}=await G.from("smart_presentations").select("*").eq("id",Ct).single();if(qs||!Is)return;const gr=Is;if(w(!0),Ne(gr.title),Y(gr.client_name||""),he(gr.property_address||""),we(gr.sections||[]),Te(gr.cta_type||"schedule_call"),Ae(gr.cta_label||"Schedule a Call"),ut(gr.cta_url||""),Rt(gr.heading||""),it(gr.share_token),ct(gr.status==="published"),nt(gr.id),_("builder"),gr.contact_id){const{data:Wn}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").eq("id",gr.contact_id).maybeSingle();Wn&&($(Wn),te(Wn.email||""),de(Wn.phone||""))}};C.useEffect(()=>{if(!r||j.length<1){T([]);return}const Ct=setTimeout(async()=>{L(!0);const{data:Is}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone, lead_source").eq("owner_user_id",r.id).or(`first_name.ilike.%${j}%,last_name.ilike.%${j}%,email.ilike.%${j}%`).limit(10);T(Is||[]),L(!1)},300);return()=>clearTimeout(Ct)},[j,r]);const Qe=Ct=>{$(Ct),Y(`${Ct.first_name} ${Ct.last_name||""}`.trim()),te(Ct.email||""),de(Ct.phone||""),U(!1)},We=async()=>{if(!H.trim()){fe.error("Client name is required");return}const Ct=H.trim().split(" "),Is=Ct[0],qs=Ct.slice(1).join(" ")||null,{data:gr,error:Wn}=await G.from("innercircle_contacts").insert({owner_user_id:r.id,first_name:Is,last_name:qs,email:se||null,phone:Q||null,lead_source:"Smart Presentation"}).select().single();if(Wn){fe.error("Failed to create client");return}$(gr),fe.success("Client created & saved to Agent OS"),_("template")},He=Ct=>{_e(Ct);const Is=(Ct.sections||[]).map(qs=>({...qs,is_visible:!0,video_url:"",text:""}));if(we(Is),Ne(Ct.name+(H?` for ${H}`:"")),Ct.cta_config){const qs=Ct.cta_config;Te(qs.type||"schedule_call"),Ae(qs.label||"Schedule a Call")}_("builder")},et=()=>{we([{title:"Welcome",description:"A personal welcome",type:"video",icon:"👋",is_visible:!0}]),Ne(H?`Presentation for ${H}`:"New Presentation"),_("builder")},Tt=(Ct,Is)=>{we(qs=>qs.map((gr,Wn)=>Wn===Ct?{...gr,...Is}:gr))},Ft=Ct=>{Tt(Ct,{is_visible:!Ge[Ct].is_visible})},as=()=>{we(Ct=>[...Ct,{title:"New Section",description:"",type:"video",icon:"📝",is_visible:!0}])},Xt=Ct=>{we(Is=>Is.filter((qs,gr)=>gr!==Ct))},ss=async()=>{if(!je.trim()){fe.error("Title is required");return}try{if(ot){const Ct=await l.mutateAsync({id:ot,title:je,sections:Ge,client_name:H,property_address:le||null,cta_type:Me,cta_label:Fe,cta_url:Ue||null,heading:De||null});fe.success("Saved")}else{const Ct=await o.mutateAsync({title:je,contact_id:(R==null?void 0:R.id)||void 0,client_name:H,property_address:le||void 0,template_id:(be==null?void 0:be.id)||void 0,sections:Ge,cta_type:Me,cta_label:Fe,cta_url:Ue||void 0,heading:De||void 0});nt(Ct.id),it(Ct.share_token),fe.success("Presentation created!")}}catch(Ct){console.error("Failed to save presentation:",Ct);const Is=(Ct==null?void 0:Ct.message)||(Ct==null?void 0:Ct.toString())||"Unknown error";fe.error(`Failed to save: ${Is}`)}},is=async()=>{try{await ss();const Ct=ot;if(Ct){const Is=await i.mutateAsync(Ct);it(Is.share_token),ct(!0),_("share")}}catch(Ct){console.error("Failed to publish presentation:",Ct),fe.error(`Failed to publish: ${(Ct==null?void 0:Ct.message)||"Unknown error"}`)}},ar=Se?`https://presentations.relevelup.com/${Se}`:"";return e.jsx(Ts,{title:"Smart Presentations",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t("/mission-control/presentations"),children:e.jsx(ti,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-serif font-bold text-foreground",children:b?"Edit Presentation":"Create Smart Presentation"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[y==="client"&&"Who is this presentation for?",y==="template"&&"Choose a starting template",y==="builder"&&"Customize your presentation",y==="share"&&"Share with your client"]})]})]}),!b&&e.jsx("div",{className:"flex items-center gap-2",children:["client","template","builder","share"].map((Ct,Is)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:Pt("w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors",y===Ct?"bg-primary text-primary-foreground":Is<["client","template","builder","share"].indexOf(y)?"bg-emerald-100 text-emerald-700":"bg-muted text-muted-foreground"),children:Is<["client","template","builder","share"].indexOf(y)?e.jsx(ha,{className:"h-4 w-4"}):Is+1}),e.jsx("span",{className:"text-sm font-medium capitalize hidden sm:inline",children:Ct}),Is<3&&e.jsx("div",{className:"w-8 h-px bg-border"})]},Ct))}),y==="client"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:()=>{$(null),Y(""),te(""),de(""),U(!1),_("template")},className:"w-full group flex items-center justify-between gap-4 rounded-xl border border-dashed border-primary/30 bg-primary/5 hover:bg-primary/10 transition-all p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(aa,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-semibold text-foreground text-sm",children:"Skip — Use as Lead Gen Tool"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No specific client. Share broadly to capture new leads."})]})]}),e.jsx($i,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors shrink-0"})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(gn,{className:"h-4 w-4 text-muted-foreground"}),"Select Existing Client"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search by name or email...",value:j,onChange:Ct=>k(Ct.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:[I&&e.jsx(xs,{className:"h-12 w-full"}),S.map(Ct=>e.jsxs("button",{onClick:()=>Qe(Ct),className:Pt("w-full text-left p-3 rounded-lg border transition-colors",(R==null?void 0:R.id)===Ct.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsxs("p",{className:"font-medium text-sm",children:[Ct.first_name," ",Ct.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Ct.email||Ct.phone||"No contact info"})]},Ct.id)),!j&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"Start typing to search your contacts"}),j&&S.length===0&&!I&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No clients found"})]}),R&&e.jsxs(K,{onClick:()=>_("template"),className:"w-full gap-2",children:["Continue with ",R.first_name,e.jsx($i,{className:"h-4 w-4"})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(yc,{className:"h-4 w-4 text-muted-foreground"}),"Add New Client"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(ve,{className:"text-xs",children:"Name *"}),e.jsx(Re,{value:H,onChange:Ct=>{Y(Ct.target.value),U(!0),$(null)},placeholder:"Sarah & Mike Johnson"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Email"}),e.jsx(Re,{value:se,onChange:Ct=>te(Ct.target.value),placeholder:"Optional",type:"email"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Phone"}),e.jsx(Re,{value:Q,onChange:Ct=>de(Ct.target.value),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Client Type"}),e.jsxs(sr,{value:re,onValueChange:ae,children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"buyer",children:"Buyer"}),e.jsx(At,{value:"seller",children:"Seller"}),e.jsx(At,{value:"recruit",children:"Recruit"}),e.jsx(At,{value:"other",children:"Other"})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Property Address"}),e.jsx(Re,{value:le,onChange:Ct=>he(Ct.target.value),placeholder:"Optional"})]})]}),q&&H&&e.jsxs(K,{onClick:We,className:"w-full gap-2",children:["Create Client & Continue",e.jsx($i,{className:"h-4 w-4"})]})]})]})]})]}),y==="template"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs(ka,{defaultValue:"system",children:[e.jsxs(_a,{children:[e.jsx(js,{value:"mine",children:"My Core Templates"}),e.jsx(js,{value:"system",children:"LevelUp Smart Templates"}),e.jsx(js,{value:"blank",children:"+ Start Blank"})]}),e.jsx(zs,{value:"mine",className:"mt-4",children:a?e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[1,2].map(Ct=>e.jsx(xs,{className:"h-32"},Ct))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(Ct=>!Ct.is_system).length===0?e.jsx("p",{className:"text-muted-foreground col-span-2 text-center py-8",children:"You haven't saved any templates yet. Create a presentation and save it as a template!"}):n.filter(Ct=>!Ct.is_system).map(Ct=>e.jsx(vDe,{template:Ct,onSelect:He},Ct.id))})}),e.jsx(zs,{value:"system",className:"mt-4",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(Ct=>Ct.is_system).map(Ct=>e.jsx(vDe,{template:Ct,onSelect:He},Ct.id))})}),e.jsx(zs,{value:"blank",className:"mt-4",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"Start with a blank canvas and add your own sections."}),e.jsx(K,{onClick:et,children:"Start from Scratch"})]})})})]}),e.jsxs(K,{variant:"outline",onClick:()=>_("client"),className:"gap-2",children:[e.jsx(ti,{className:"h-4 w-4"}),"Back"]})]}),y==="builder"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Presentation Title"}),e.jsx(Re,{value:je,onChange:Ct=>Ne(Ct.target.value)})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Page Heading"}),e.jsx(Re,{value:De,onChange:Ct=>Rt(Ct.target.value),placeholder:H?`Welcome, ${H}!`:"e.g. Welcome! or Your Custom Listing Plan"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:['The main heading visitors see. Leave blank for "Welcome, ',"",'!"']})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Client Name"}),e.jsx(Re,{value:H,onChange:Ct=>Y(Ct.target.value)})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Property Address"}),e.jsx(Re,{value:le,onChange:Ct=>he(Ct.target.value),placeholder:"Optional"})]})]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sections"}),e.jsx(K,{variant:"outline",size:"sm",onClick:as,children:"+ Add Section"})]}),e.jsx("div",{className:"space-y-3",children:Ge.map((Ct,Is)=>e.jsx(Ee,{className:Pt(!Ct.is_visible&&"opacity-50"),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 pt-1",children:[e.jsx(Bu,{className:"h-4 w-4 text-muted-foreground cursor-grab"}),e.jsx("span",{className:"text-lg",children:Ct.icon})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Re,{value:Ct.title,onChange:qs=>Tt(Is,{title:qs.target.value}),className:"font-semibold border-none p-0 h-auto text-base focus-visible:ring-0 bg-transparent"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ft(Is),children:Ct.is_visible?e.jsx(xa,{className:"h-4 w-4"}):e.jsx(Im,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Xt(Is),className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})]})]}),e.jsx(Re,{value:Ct.description||"",onChange:qs=>Tt(Is,{description:qs.target.value}),placeholder:"Section description...",className:"text-sm"}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(ve,{className:"text-xs",children:"Video URL"}),e.jsx(Re,{value:Ct.video_url||"",onChange:qs=>Tt(Is,{video_url:qs.target.value}),placeholder:"Paste a YouTube or video URL...",className:"text-sm"})]}),e.jsx(Zvs,{sectionTitle:Ct.title,contactId:R==null?void 0:R.id,onVideoReady:qs=>Tt(Is,{video_url:qs})}),e.jsx(Yvs,{sectionTitle:Ct.title,contactId:R==null?void 0:R.id,onVideoReady:qs=>Tt(Is,{video_url:qs})}),e.jsx(G2e,{userId:r==null?void 0:r.id,onSelect:qs=>Tt(Is,{video_url:qs})})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Image (optional — shown if no video is set)"}),Ct.image_url?e.jsxs("div",{className:"relative mt-1 rounded-lg overflow-hidden border border-border bg-muted/30 group",children:[e.jsx("img",{src:Ct.image_url,alt:"",className:"w-full max-h-40 object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>Tt(Is,{image_url:""}),children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]}):e.jsxs("label",{className:"mt-1 flex items-center gap-2 cursor-pointer rounded-lg border border-dashed border-border hover:border-primary/50 p-3 transition-colors",children:[me===Is?e.jsx(Ms,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(D0,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:me===Is?"Uploading...":"Click to upload an image"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:me===Is,onChange:qs=>{var Wn;const gr=(Wn=qs.target.files)==null?void 0:Wn[0];gr&&qe(gr,Is),qs.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Text (optional)"}),e.jsx(rx,{content:Ct.text||"",onChange:qs=>Tt(Is,{text:qs}),placeholder:"Add supporting text...",minHeight:"80px",compact:!0})]})]})]})})},Is))})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Call to Action"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"CTA Type"}),e.jsxs(sr,{value:Me,onValueChange:Ct=>{Te(Ct);const Is=xDe.find(qs=>qs.value===Ct);Is&&Ae(Is.label)},children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:xDe.map(Ct=>e.jsx(At,{value:Ct.value,children:Ct.label},Ct.value))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Button Label"}),e.jsx(Re,{value:Fe,onChange:Ct=>Ae(Ct.target.value)})]}),e.jsxs("div",{children:[e.jsxs(ve,{children:["Link URL ",e.jsx("span",{className:"text-muted-foreground",children:"(optional — leave blank to show a lead capture form instead)"})]}),e.jsx(Re,{value:Ue,onChange:Ct=>ut(Ct.target.value),placeholder:"https://calendly.com/..."}),!Ue&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Without a URL, clients will see a contact form — their info gets added to your contacts and you'll receive an email notification."})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[!b&&e.jsxs(K,{variant:"outline",onClick:()=>_("template"),className:"gap-2",children:[e.jsx(ti,{className:"h-4 w-4"}),"Back"]}),e.jsxs("div",{className:"flex gap-3 ml-auto",children:[e.jsx(K,{variant:"outline",onClick:ss,disabled:o.isPending||l.isPending,children:"Save Draft"}),e.jsxs(K,{onClick:is,disabled:i.isPending,className:"gap-2",children:[e.jsx(aa,{className:"h-4 w-4"}),$e?"Update & Reshare":"Publish & Share"]})]})]})]}),y==="share"&&Se&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center py-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mb-4",children:e.jsx(ha,{className:"h-8 w-8 text-emerald-600"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Your Presentation is Live!"}),e.jsxs("p",{className:"text-muted-foreground mb-6 max-w-md",children:["Share this link with ",H||"your client",". You'll be notified when they view it."]}),e.jsxs("div",{className:"flex items-center gap-2 w-full max-w-lg",children:[e.jsx(Re,{value:ar,readOnly:!0,className:"text-center font-mono text-sm"}),e.jsx(K,{onClick:()=>{navigator.clipboard.writeText(ar),fe.success("Link copied!")},children:e.jsx(ai,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-3 mt-6",children:[e.jsxs(K,{variant:"outline",className:"gap-2",onClick:()=>{const Ct=`Hi ${H||""}! I put together something for you — check it out: ${ar}`;navigator.clipboard.writeText(Ct),fe.success("Message copied!")},children:[e.jsx(io,{className:"h-4 w-4"}),"Copy Text Message"]}),e.jsxs(K,{variant:"outline",className:"gap-2",onClick:()=>{d?f(!0):window.open(`mailto:${se||""}?subject=${encodeURIComponent(je)}&body=${encodeURIComponent(`Hi ${(R==null?void 0:R.first_name)||(H==null?void 0:H.split(" ")[0])||""}, I put together a personalized presentation for you: ${ar} Looking forward to connecting!`)}`)},children:[e.jsx(br,{className:"h-4 w-4"}),"Send Email"]})]}),d&&e.jsx(JM,{open:p,onOpenChange:f,contact:R?{id:R.id,first_name:R.first_name,last_name:R.last_name,email:se||R.email||""}:se?{id:"",first_name:(H==null?void 0:H.split(" ")[0])||"",last_name:(H==null?void 0:H.split(" ").slice(1).join(" "))||"",email:se}:void 0,defaultSubject:je,defaultBody:`Hi ${(R==null?void 0:R.first_name)||(H==null?void 0:H.split(" ")[0])||""}, I put together a personalized presentation for you: ${ar} Looking forward to connecting!`,gmailEmail:u})]})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(K,{variant:"outline",onClick:()=>_("builder"),children:[e.jsx(ti,{className:"h-4 w-4 mr-2"}),"Edit Presentation"]}),e.jsx(K,{onClick:()=>t("/mission-control/presentations"),children:"Done"})]})]})]})})},vDe=({template:t,onSelect:s})=>e.jsx(Ee,{className:"hover:shadow-sm transition-shadow",children:e.jsxs(Oe,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-2xl",children:t.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold",children:t.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(rt,{variant:"outline",className:"text-xs capitalize",children:t.template_type}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(t.sections||[]).length," sections"]})]})]})]}),e.jsx(K,{className:"w-full mt-4",size:"sm",onClick:()=>s(t),children:"Use Template"})]})}),Xvs=()=>{var w;const{shareToken:t}=ko(),[s,r]=C.useState(null),[n,a]=C.useState(!0),[o,l]=C.useState(0),[i,d]=C.useState(!1);C.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]),C.useEffect(()=>{t&&u()},[t]);const u=async()=>{const{data:j,error:k}=await G.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(k||!j){d(!0),a(!1);return}const{data:S}=await G.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",j.owner_user_id).single();let T;if(S!=null&&S.brokerage_id){const{data:L}=await G.from("brokerages").select("name").eq("id",S.brokerage_id).single();T=(L==null?void 0:L.name)||void 0}let I=null;if(j.contact_id){const{data:L}=await G.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",j.contact_id).single();I=L}r({...j,owner_name:S==null?void 0:S.name,owner_email:S==null?void 0:S.email,owner_phone:S==null?void 0:S.phone,owner_avatar:S==null?void 0:S.avatar_url,owner_title:(S==null?void 0:S.title)||void 0,brokerage_name:T,contact_name:I?[I.first_name,I.last_name].filter(Boolean).join(" "):void 0,contact_email:(I==null?void 0:I.email)||void 0,contact_phone:(I==null?void 0:I.phone)||void 0}),a(!1);try{await G.rpc("log_presentation_view",{p_presentation_id:j.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(s){try{await G.rpc("log_presentation_view",{p_presentation_id:s.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}s.cta_url&&window.open(s.cta_url,"_blank")}};if(n)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[e.jsx(xs,{className:"h-12 w-3/4 mx-auto"}),e.jsx(xs,{className:"h-64 w-full"}),e.jsx(xs,{className:"h-8 w-1/2 mx-auto"})]})});if(i||!s)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Presentation Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This presentation may have been removed or is no longer available."})]})});const f=s.sections.filter(j=>j.is_visible!==!1),y=f[o],_=j=>{const k=j.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(k)return`https://www.youtube.com/embed/${k[1]}?rel=0`;if(j.includes("iframe.mediadelivery.net/play/")){const I=j.replace("/play/","/embed/"),L=I.includes("?")?"&":"?";return`${I}${L}responsive=true`}if(j.includes("iframe.mediadelivery.net")){if(j.match(/\/embed\/(\d+)\/([a-f0-9-]+)/)){const L=j.includes("?")?"&":"?";return`${j}${L}responsive=true`}return""}const S=j.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(S)return`https://www.loom.com/embed/${S[1]}`;const T=j.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return T?`https://iframe.mediadelivery.net/embed/${T[1]}/${T[2]}?responsive=true`:j},b=!!((w=s.cta_url)!=null&&w.trim());return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[e.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-3",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),e.jsxs("div",{className:"text-right text-sm",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.owner_title}),s.brokerage_name&&!s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.brokerage_name})]})]})]})}),e.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:s.heading||(s.client_name?`Welcome, ${s.client_name}!`:s.title)}),s.property_address&&e.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",e.jsx("strong",{children:s.property_address}),"."]})]}),e.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[e.jsxs("div",{className:"md:col-span-3",children:[y!=null&&y.video_url&&_(y.video_url)?e.jsx("div",{className:"relative w-full rounded-xl overflow-hidden shadow-lg bg-gray-900",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:_(y.video_url),className:"absolute inset-0 w-full h-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,loading:"lazy"})}):y!=null&&y.image_url?e.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:e.jsx("img",{src:y.image_url,alt:y.title,className:"w-full h-auto object-cover",loading:"lazy"})}):e.jsxs("div",{className:"aspect-video bg-gradient-to-br from-blue-50 to-slate-100 rounded-xl flex flex-col items-center justify-center shadow-lg",children:[e.jsx("span",{className:"text-5xl mb-3",children:y==null?void 0:y.icon}),e.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:y==null?void 0:y.title}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:y==null?void 0:y.description})]}),(y==null?void 0:y.text)&&e.jsx("div",{className:"mt-4 p-4 bg-white rounded-lg border text-gray-700 text-sm leading-relaxed prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:y.text}})]}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:f.map((j,k)=>e.jsx("button",{onClick:()=>l(k),className:Pt("w-full text-left p-4 rounded-xl border transition-all",o===k?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(k+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:j.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:j.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:j.description})]})]})},k))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),b?e.jsxs(K,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(sn,{className:"h-5 w-5 ml-2"})]}):e.jsx("div",{className:"max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6",children:e.jsx(L9e,{presentationId:s.id,ctaLabel:s.cta_label,agentName:s.owner_name||void 0,prefillName:s.contact_name,prefillEmail:s.contact_email,prefillPhone:s.contact_phone})})]})]}),e.jsx("footer",{className:"border-t border-gray-100 bg-white mt-12 py-6 text-center text-xs text-gray-400",children:"Powered by LevelUp"})]})};function Qvs({openHouseId:t,enableSurvey:s,onToggleSurvey:r}){const{data:n,isLoading:a}=ivt(t),o=dvt(),l=uvt(),i=hvt(),d=mvt(),[u,p]=C.useState(""),[f,y]=C.useState("rating"),_=async k=>{r(k),k&&(!n||n.length===0)&&await d.mutateAsync(t)},b=async()=>{if(!u.trim())return;const k=(n==null?void 0:n.reduce((S,T)=>Math.max(S,T.sort_order),0))??0;await o.mutateAsync({open_house_id:t,question_type:f,question_text:u.trim(),sort_order:k+1}),p("")},w=async k=>{await l.mutateAsync({id:k.id,open_house_id:t,is_active:!k.is_active})},j=async k=>{await i.mutateAsync({id:k.id,open_house_id:t})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(ve,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(a_,{className:"h-4 w-4"}),"Property Feedback Survey"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show a quick feedback survey after visitors sign in"})]}),e.jsx(Br,{checked:s,onCheckedChange:_})]}),s&&e.jsx("div",{className:"space-y-3 pt-2 border-t border-border",children:a?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Ms,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2",children:n==null?void 0:n.map(k=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-muted/20",children:[e.jsx(Bu,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm truncate",children:k.question_text}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:k.question_type.replace("_"," ")})]}),e.jsx(Br,{checked:k.is_active,onCheckedChange:()=>w(k),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>j(k),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]},k.id))}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(ve,{className:"text-xs text-muted-foreground",children:"Add Question"}),e.jsx(Re,{value:u,onChange:k=>p(k.target.value),placeholder:"e.g. How did you hear about this listing?",className:"mt-1 h-9 text-sm",onKeyDown:k=>k.key==="Enter"&&b()})]}),e.jsxs(sr,{value:f,onValueChange:y,children:[e.jsx(er,{className:"w-28 h-9 text-xs",children:e.jsx(rr,{})}),e.jsxs(tr,{children:[e.jsx(At,{value:"rating",children:"Rating"}),e.jsx(At,{value:"open_text",children:"Text"})]})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:b,disabled:!u.trim()||o.isPending,className:"h-9",children:e.jsx(Zs,{className:"h-3.5 w-3.5"})})]})]})})]})}function Jvs({open:t,onOpenChange:s,openHouse:r}){const n=O9e(),{user:a}=Hs(),o=C.useRef(null),[l,i]=C.useState(r.auto_forward_to_card??!1),[d,u]=C.useState(r.disclosure_pdf_url??""),[p,f]=C.useState(r.enable_survey??!1),[y,_]=C.useState(!1),[b,w]=C.useState(!1),j=async T=>{var q;const I=(q=T.target.files)==null?void 0:q[0];if(!I||!a)return;if(I.size>20*1024*1024){pn({title:"File must be under 20MB",variant:"destructive"});return}if(I.type!=="application/pdf"){pn({title:"Only PDF files are accepted",variant:"destructive"});return}_(!0);const L=`${a.id}/disclosures/${r.id}-${Date.now()}.pdf`,{error:R}=await G.storage.from("open-house-photos").upload(L,I,{upsert:!0});if(R){pn({title:"Upload failed",description:R.message,variant:"destructive"}),_(!1);return}const{data:$}=G.storage.from("open-house-photos").getPublicUrl(L);u($.publicUrl),_(!1),pn({title:"PDF uploaded!"})},k=()=>{u(""),o.current&&(o.current.value="")},S=async()=>{w(!0);try{await n.mutateAsync({id:r.id,auto_forward_to_card:l,disclosure_pdf_url:d||null,enable_survey:p}),pn({title:"Settings saved!"}),s(!1)}catch{pn({title:"Failed to save",variant:"destructive"})}finally{w(!1)}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-md max-h-[85vh] overflow-y-auto",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Guest Book Settings"}),e.jsx(Kr,{className:"truncate",children:r.property_address})]}),e.jsxs("div",{className:"space-y-6 pt-2",children:[e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Auto-forward to Digital Card"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"After check-in, redirect visitors to your digital business card"})]}),e.jsx(Br,{checked:l,onCheckedChange:i})]})}),!l&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Seller's Disclosures (PDF)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visitors can view or download this on the thank you screen after check-in"}),e.jsx("input",{ref:o,type:"file",accept:"application/pdf",onChange:j,className:"hidden"}),d?e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:[e.jsx(In,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm truncate flex-1",children:"Disclosure PDF uploaded"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:k,children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsx("button",{type:"button",onClick:()=>{var T;return(T=o.current)==null?void 0:T.click()},disabled:y,className:"w-full h-24 rounded-xl border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground transition-colors",children:y?e.jsx(Ms,{className:"h-5 w-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Za,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Upload PDF (max 20MB)"})]})})]}),e.jsx(Qvs,{openHouseId:r.id,enableSurvey:p,onToggleSurvey:f}),e.jsx(K,{onClick:S,disabled:b,className:"w-full",children:b?"Saving...":"Save Settings"})]})]})})}const Ret={5:"Excellent",4:"Good",3:"Neutral",2:"Bad",1:"Very Bad"};function e1s({question:t,responses:s}){const r=s.filter(l=>l.question_id===t.id&&l.rating_value!=null),n=r.length;if(n===0)return null;const a=r.reduce((l,i)=>l+(i.rating_value||0),0)/n,o=[5,4,3,2,1].map(l=>({val:l,count:r.filter(i=>i.rating_value===l).length,pct:Math.round(r.filter(i=>i.rating_value===l).length/n*100)}));return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:t.question_text}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[a.toFixed(1)," avg (",n," responses)"]})]}),e.jsx("div",{className:"space-y-1",children:o.map(l=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-16 text-muted-foreground text-right",children:Ret[l.val]}),e.jsx("div",{className:"flex-1 h-4 bg-muted/30 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary/70 rounded-full transition-all",style:{width:`${l.pct}%`}})}),e.jsx("span",{className:"w-8 text-muted-foreground",children:l.count})]},l.val))})]})}function t1s({openHouseId:t}){const{data:s,isLoading:r}=cvt(t),{data:n}=D9e(t),a=C.useMemo(()=>{const f={};return n==null||n.forEach(y=>{f[y.id]=y}),f},[n]);if(r||!s)return null;const{questions:o,responses:l}=s;if(o.length===0)return null;const i=o.filter(f=>f.question_type==="rating"),d=o.filter(f=>f.question_type!=="rating"),u=[...new Set(l.map(f=>f.visitor_id))],p=u.length;return p===0?e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(a_,{className:"h-4 w-4"}),"Survey Results"]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No survey responses yet."})})]}):e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(a_,{className:"h-4 w-4"}),"Survey Results",e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-auto",children:[p," respondent",p!==1?"s":""]})]})}),e.jsx(Oe,{children:e.jsxs(ka,{defaultValue:"summary",children:[e.jsxs(_a,{className:"mb-4",children:[e.jsxs(js,{value:"summary",className:"text-xs gap-1",children:[e.jsx(ol,{className:"h-3.5 w-3.5"})," Summary"]}),e.jsxs(js,{value:"individual",className:"text-xs gap-1",children:[e.jsx(Yi,{className:"h-3.5 w-3.5"})," Per Visitor"]})]}),e.jsxs(zs,{value:"summary",className:"space-y-6",children:[i.map(f=>e.jsx(e1s,{question:f,responses:l},f.id)),d.map(f=>{const y=l.filter(_=>_.question_id===f.id&&_.text_value);return y.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-sm font-medium",children:f.question_text}),e.jsx("div",{className:"space-y-1.5 max-h-40 overflow-y-auto",children:y.map(_=>{const b=a[_.visitor_id];return e.jsxs("div",{className:"text-sm p-2 bg-muted/30 rounded-lg",children:[e.jsxs("span",{className:"text-muted-foreground text-xs",children:[b?`${b.first_name} ${b.last_name||""}`.trim():"Visitor",":"]}),e.jsx("p",{className:"mt-0.5",children:_.text_value})]},_.id)})})]},f.id)})]}),e.jsx(zs,{value:"individual",className:"space-y-4",children:u.map(f=>{const y=a[f],_=l.filter(b=>b.visitor_id===f);return e.jsxs("div",{className:"p-3 rounded-lg border border-border space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium",children:[y?`${y.first_name} ${y.last_name||""}`.trim():"Unknown Visitor",(y==null?void 0:y.email)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:y.email})]}),e.jsx("div",{className:"space-y-1",children:_.map(b=>{const w=o.find(j=>j.id===b.question_id);return w?e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:w.question_text}),e.jsx("span",{className:"font-medium",children:b.rating_value!=null?Ret[b.rating_value]||b.rating_value:b.text_value})]},b.id):null})})]},f)})})]})})]})}const ove="guestbook.relevelup.com";function s1s(){const{data:t,isLoading:s}=svt(),r=rvt(),n=O9e(),a=nvt(),[o,l]=C.useState(!1),[i,d]=C.useState(null),{user:u}=Hs(),p=Ya(),[f,y]=C.useState(null),[_,b]=C.useState(null),[w,j]=C.useState(!1),k=C.useRef(null),[S,T]=C.useState({property_address:"",city:"",state:"",zip:"",event_date:ys(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),I=q=>{var H;const U=(H=q.target.files)==null?void 0:H[0];if(U){if(U.size>5*1024*1024){pn({title:"Photo must be under 5MB",variant:"destructive"});return}y(U),b(URL.createObjectURL(U))}},L=()=>{y(null),b(null),k.current&&(k.current.value="")},R=async()=>{if(!S.property_address){pn({title:S.event_type==="community"?"Event name is required":"Address is required",variant:"destructive"});return}let q;if(f&&u){j(!0);const U=f.name.split(".").pop(),H=`${p}/${Date.now()}.${U}`,{error:Y}=await G.storage.from("open-house-photos").upload(H,f,{upsert:!0});if(Y){pn({title:"Photo upload failed",description:Y.message,variant:"destructive"}),j(!1);return}const{data:se}=G.storage.from("open-house-photos").getPublicUrl(H);q=se.publicUrl,j(!1)}await r.mutateAsync({...S,photo_url:q}),l(!1),T({property_address:"",city:"",state:"",zip:"",event_date:ys(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),L()},$=q=>{navigator.clipboard.writeText(`https://${ove}/${q}`),pn({title:"Link copied!"})};return e.jsxs(Ts,{title:"Guest Book",children:[e.jsx(lh,{children:e.jsx("title",{children:"Guest Book | LevelUp"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold font-serif text-foreground",children:"Guest Book"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"The modern open house sign-in experience"})]}),e.jsxs(_s,{open:o,onOpenChange:l,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"New Open House"]})}),e.jsxs(vs,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"Create Open House"}),e.jsx(Kr,{children:"Set up a new open house sign-in page"})]}),e.jsxs("div",{className:"space-y-4 pt-2 overflow-y-auto flex-1 pr-1",children:[e.jsx("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:e.jsxs("div",{className:"flex gap-1 flex-1",children:[e.jsx("button",{type:"button",onClick:()=>T(q=>({...q,event_type:"property"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${S.event_type==="property"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Single Property"}),e.jsx("button",{type:"button",onClick:()=>T(q=>({...q,event_type:"community"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${S.event_type==="community"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Community Event"})]})}),e.jsxs("div",{children:[e.jsx(ve,{children:S.event_type==="community"?"Event Name *":"Property Address *"}),e.jsx(Re,{value:S.property_address,onChange:q=>T(U=>({...U,property_address:q.target.value})),placeholder:S.event_type==="community"?"Spring Festival at Riverside Estates":"123 Main Street"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"City"}),e.jsx(Re,{value:S.city,onChange:q=>T(U=>({...U,city:q.target.value})),placeholder:"Austin"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"State"}),e.jsx(Re,{value:S.state,onChange:q=>T(U=>({...U,state:q.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"ZIP"}),e.jsx(Re,{value:S.zip,onChange:q=>T(U=>({...U,zip:q.target.value})),placeholder:"78701"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Date"}),e.jsx(Re,{type:"date",value:S.event_date,onChange:q=>T(U=>({...U,event_date:q.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Start Time"}),e.jsx(Re,{type:"time",value:S.start_time,onChange:q=>T(U=>({...U,start_time:q.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"End Time"}),e.jsx(Re,{type:"time",value:S.end_time,onChange:q=>T(U=>({...U,end_time:q.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Welcome Message"}),e.jsx(Ar,{value:S.agent_greeting,onChange:q=>T(U=>({...U,agent_greeting:q.target.value})),placeholder:"Welcome! Please sign in below."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:S.event_type==="community"?"Event Photo":"Property Photo"}),e.jsx("input",{ref:k,type:"file",accept:"image/*",onChange:I,className:"hidden"}),_?e.jsxs("div",{className:"relative mt-1 rounded-xl overflow-hidden border border-border",children:[e.jsx("img",{src:_,alt:"Property preview",className:"w-full h-40 object-cover"}),e.jsx("button",{type:"button",onClick:L,className:"absolute top-2 right-2 bg-black/60 hover:bg-black/80 text-white rounded-full p-1 transition-colors",children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("button",{type:"button",onClick:()=>{var q;return(q=k.current)==null?void 0:q.click()},className:"mt-1 w-full h-32 rounded-xl border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(D0,{className:"h-6 w-6"}),e.jsxs("span",{className:"text-sm",children:["Add a ",S.event_type==="community"?"cover":"property"," photo"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Max 5MB"})]})]}),e.jsx(K,{onClick:R,disabled:r.isPending||w,className:"w-full",children:w?"Uploading photo...":r.isPending?"Creating...":S.event_type==="community"?"Create Community Event":"Create Open House"})]})]})]})]}),s?e.jsx("div",{className:"grid gap-4",children:[1,2].map(q=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(It,{children:[e.jsx("div",{className:"h-5 bg-muted rounded w-48"}),e.jsx("div",{className:"h-4 bg-muted rounded w-32 mt-2"})]})},q))}):t!=null&&t.length?e.jsx("div",{className:"space-y-4",children:t.map(q=>e.jsx(r1s,{openHouse:q,isExpanded:i===q.id,onToggle:()=>d(i===q.id?null:q.id),onCopyLink:()=>$(q.slug||""),onToggleActive:()=>n.mutate({id:q.id,is_active:!q.is_active}),onDelete:()=>a.mutate(q.id)},q.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(B0,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No Open Houses Yet"}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm mb-6",children:"Create your first open house to get a beautiful, mobile-friendly sign-in page with a shareable link and QR code."}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create Your First Open House"]})]})})]})]})}function r1s({openHouse:t,isExpanded:s,onToggle:r,onCopyLink:n,onToggleActive:a,onDelete:o}){const{data:l}=D9e(s?t.id:void 0),[i,d]=C.useState(!1),[u,p]=C.useState(!1),[f,y]=C.useState(!1),_=C.useRef(null),b=`https://${ove}/${t.slug}`,w=I=>{if(!I)return"";const[L,R]=I.split(":"),$=parseInt(L),q=$>=12?"PM":"AM";return`${$>12?$-12:$||12}:${R} ${q}`},j=()=>{if(!(l!=null&&l.length))return;const I=["First Name","Last Name","Email","Phone","Intent","Wants Market Updates","Message","Signed In"],L=l.map(H=>[H.first_name,H.last_name||"",H.email||"",H.phone||"",H.visitor_intent||"",H.wants_market_updates?"Yes":"No",(H.message||"").replace(/"/g,'""'),ys(new Date(H.created_at),"MM/dd/yyyy h:mm a")]),R=[I,...L].map(H=>H.map(Y=>`"${Y}"`).join(",")).join(` `),$=new Blob([R],{type:"text/csv"}),q=URL.createObjectURL($),U=document.createElement("a");U.href=q,U.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-visitors.csv`,U.click(),URL.revokeObjectURL(q)},k=C.useCallback(()=>{if(!_.current)return;const I=_.current.querySelector("svg");if(!I)return;const L=new XMLSerializer().serializeToString(I),R=document.createElement("canvas");R.width=1024,R.height=1024;const $=R.getContext("2d"),q=new Image;q.onload=()=>{$==null||$.drawImage(q,0,0,1024,1024);const U=document.createElement("a");U.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-qr.png`,U.href=R.toDataURL("image/png"),U.click()},q.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(L)))},[t.property_address]),S=C.useCallback(()=>{if(!_.current)return;const I=_.current.querySelector("svg");if(!I)return;const L=new XMLSerializer().serializeToString(I),R="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(L))),$=ys(new Date(t.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy"),q=t.start_time?`${w(t.start_time)}${t.end_time?" – "+w(t.end_time):""}`:"",U=[t.city,t.state].filter(Boolean).join(", "),H=t.agent_greeting||"Welcome! Please sign in below.",Y=window.open("","_blank");Y&&(Y.document.write(` Open House – ${t.property_address}
${t.event_type==="community"?"Community Event":"Open House"}
${t.property_address}
${U?`
${U}${t.zip?" "+t.zip:""}
`:""}
Date
${$}
${q?`
Time
${q}
`:""}
${H}
QR Code
Scan to Sign In
Point your phone camera at the QR code
`),Y.document.close(),setTimeout(()=>{Y.focus(),Y.print()},500))},[t,b]),T=async()=>{y(!0);try{const{error:I}=await G.functions.invoke("guestbook-email-link",{body:{openHouseId:t.id}});if(I)throw I;pn({title:"Email sent!",description:"Check your inbox for the guest book link."})}catch(I){pn({title:"Failed to send",description:I.message,variant:"destructive"})}finally{y(!1)}};return e.jsxs(Ee,{className:`transition-all ${t.is_active?"border-primary/30":"opacity-75"}`,children:[e.jsx(It,{className:"pb-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Ot,{className:"text-base leading-snug break-words",children:t.property_address}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 flex-wrap",children:[e.jsx(rt,{variant:t.is_active?"default":"secondary",className:"shrink-0 text-[11px]",children:t.is_active?"Active":"Inactive"}),t.agent_name&&e.jsxs(rt,{variant:"outline",className:"shrink-0 gap-1 text-[11px] bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300 border-blue-200 dark:border-blue-800",children:[e.jsx(Yi,{className:"h-3 w-3"}),t.agent_name]}),t.event_type==="community"&&e.jsxs(rt,{variant:"outline",className:"shrink-0 gap-1 text-[11px]",children:[e.jsx(Ta,{className:"h-3 w-3"}),"Community"]})]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,className:"shrink-0 -mr-2 -mt-1",children:s?e.jsx(Ug,{className:"h-4 w-4"}):e.jsx(Ho,{className:"h-4 w-4"})})]}),e.jsxs(pr,{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs",children:[t.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Oi,{className:"h-3 w-3"}),t.city,t.state?`, ${t.state}`:""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ys(new Date(t.event_date+"T00:00:00"),"MMM d, yyyy")]}),t.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),w(t.start_time),t.end_time?` – ${w(t.end_time)}`:""]}),e.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[e.jsx(hr,{className:"h-3 w-3"}),t.visitor_count," visitors"]})]}),e.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto pb-1 -mx-1 px-1 scrollbar-hide",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>window.location.href=`/mission-control/guest-book/live/${t.id}`,title:"Go Live",className:"shrink-0 gap-1.5 text-emerald-600 border-emerald-200 hover:bg-emerald-50 dark:text-emerald-400 dark:border-emerald-800 dark:hover:bg-emerald-900/20 h-8 text-xs",children:[e.jsx($0,{className:"h-3.5 w-3.5"}),"Live"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:n,title:"Copy link",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(ai,{className:"h-3.5 w-3.5"}),"Copy"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>d(!0),title:"QR Code",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(B0,{className:"h-3.5 w-3.5"}),"QR"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>p(!0),title:"Settings",className:"shrink-0 h-8 text-xs",children:e.jsx($l,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>window.open(b,"_blank"),title:"Preview",className:"shrink-0 h-8 text-xs",children:e.jsx(sn,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:a,title:t.is_active?"Deactivate":"Activate",className:"shrink-0 h-8 text-xs",children:t.is_active?e.jsx(Im,{className:"h-3.5 w-3.5"}):e.jsx(xa,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:o,title:"Delete",className:"shrink-0 h-8 text-xs text-destructive border-destructive/30 hover:bg-destructive/10",children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]})}),s&&e.jsxs(Oe,{className:"pt-0",children:[e.jsx(Rl,{className:"mb-4"}),e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Share Link"}),e.jsxs("code",{className:"text-xs bg-muted/50 px-2 py-1 rounded block truncate",children:["https://",ove,"/",t.slug]})]}),l!=null&&l.length?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground",children:[l.length," Visitor",l.length!==1?"s":""]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:j,className:"h-7 text-xs gap-1",children:[e.jsx(xi,{className:"h-3 w-3"}),"Export CSV"]})]}),e.jsx("div",{className:"rounded-lg border overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-muted/30 text-xs text-muted-foreground",children:[e.jsx("th",{className:"text-left p-2 font-medium",children:"Name"}),e.jsx("th",{className:"text-left p-2 font-medium hidden sm:table-cell",children:"Contact"}),e.jsx("th",{className:"text-left p-2 font-medium hidden md:table-cell",children:"Intent"}),e.jsx("th",{className:"text-left p-2 font-medium",children:"Time"})]})}),e.jsx("tbody",{children:l.map(I=>e.jsxs("tr",{className:"border-t border-border/50",children:[e.jsxs("td",{className:"p-2 font-medium",children:[I.first_name,I.last_name?` ${I.last_name}`:""]}),e.jsxs("td",{className:"p-2 text-muted-foreground hidden sm:table-cell",children:[I.email&&e.jsx("div",{className:"truncate max-w-[180px]",children:I.email}),I.phone&&e.jsx("div",{className:"text-xs",children:I.phone})]}),e.jsx("td",{className:"p-2 hidden md:table-cell",children:I.visitor_intent&&e.jsx(rt,{variant:"outline",className:"text-xs capitalize",children:I.visitor_intent})}),e.jsx("td",{className:"p-2 text-xs text-muted-foreground",children:ys(new Date(I.created_at),"h:mm a")})]},I.id))})]})})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No visitors yet. Share the link to start collecting sign-ins!"}),t.enable_survey&&e.jsx("div",{className:"mt-4",children:e.jsx(t1s,{openHouseId:t.id})})]}),e.jsx(_s,{open:i,onOpenChange:d,children:e.jsxs(vs,{className:"sm:max-w-sm",children:[e.jsxs(Ss,{children:[e.jsx(ks,{children:"QR Code"}),e.jsx(Kr,{className:"truncate",children:t.property_address})]}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx("div",{ref:_,className:"bg-white p-4 rounded-xl",children:e.jsx(yD,{value:b,size:240,level:"H"})}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:b}),e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:k,children:[e.jsx(xi,{className:"h-4 w-4 mr-2"}),"Download"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:S,children:[e.jsx(AP,{className:"h-4 w-4 mr-2"}),"Print Flyer"]})]}),e.jsxs(K,{variant:"default",className:"w-full",onClick:T,disabled:f,children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),f?"Sending...":"Email Link to Me"]})]})]})}),e.jsx(Jvs,{open:u,onOpenChange:p,openHouse:t})]})}function n1s(){const{slug:t}=ko();return t?e.jsx(cUe,{slug:t}):e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Portal Not Found"}),e.jsx("p",{className:"text-slate-500",children:"No portal slug was provided."})]})})}function Fet({photoUrl:t,videoUrl:s,onPhotoChange:r,onVideoChange:n,contactId:a}){const{user:o}=Hs(),l=xS(),i=C.useRef(null),d=C.useRef(null),[u,p]=C.useState(!1),[f,y]=C.useState(!1),[_,b]=C.useState(0),w=async k=>{if(o){p(!0);try{const S=k.name.split(".").pop()||"jpg",T=`${o.id}/card-${Date.now()}.${S}`,{error:I}=await G.storage.from("listing-photos").upload(T,k);if(I)throw I;const{data:{publicUrl:L}}=G.storage.from("listing-photos").getPublicUrl(T);r(L),fe.success("Photo uploaded")}catch(S){fe.error(S.message||"Failed to upload photo")}finally{p(!1)}}},j=async k=>{if(o){if(k.size>500*1024*1024){fe.error("Video must be under 500MB");return}y(!0),b(0);try{const{videoId:S,libraryId:T}=await fD(`Card Video - ${Date.now()}`),{uploadUrl:I,apiKey:L}=await gD(S);await new Promise((q,U)=>{const H=new XMLHttpRequest;H.upload.addEventListener("progress",Y=>{Y.lengthComputable&&b(Math.round(Y.loaded/Y.total*100))}),H.addEventListener("load",()=>{H.status>=200&&H.status<300?q():U(new Error("Upload failed"))}),H.addEventListener("error",()=>U(new Error("Upload failed"))),H.open("PUT",I),H.setRequestHeader("AccessKey",L),H.send(k)});const R=`https://iframe.mediadelivery.net/embed/${T}/${S}`;n(R);const $=parseFloat((k.size/(1024*1024)).toFixed(2));await l.mutateAsync({bunny_video_id:S,playback_url:`https://iframe.mediadelivery.net/play/${T}/${S}`,file_size_mb:$,title:"Card Video",status:"processing",touch_type:"video",contact_id:a||void 0}),fe.success("Video uploaded & added to your library")}catch(S){fe.error(S.message||"Failed to upload video")}finally{y(!1),b(0)}}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{children:"Media (optional)"}),e.jsxs(ka,{defaultValue:"photo",className:"w-full",children:[e.jsxs(_a,{className:"grid w-full grid-cols-2",children:[e.jsxs(js,{value:"photo",className:"gap-1.5 text-xs",children:[e.jsx(Jo,{className:"h-3.5 w-3.5"}),"Photo"]}),e.jsxs(js,{value:"video",className:"gap-1.5 text-xs",children:[e.jsx(Nn,{className:"h-3.5 w-3.5"}),"Video"]})]}),e.jsxs(zs,{value:"photo",className:"mt-3",children:[t?e.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-border",children:[e.jsx("img",{src:t,alt:"Card photo",className:"w-full h-40 object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>r(null),children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var k;return(k=i.current)==null?void 0:k.click()},disabled:u,className:"w-full h-32 border-2 border-dashed border-border rounded-lg flex flex-col items-center justify-center gap-2 text-muted-foreground hover:border-primary/40 hover:bg-accent/50 transition-colors",children:u?e.jsx(Ms,{className:"h-6 w-6 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(qg,{className:"h-6 w-6"}),e.jsx("span",{className:"text-xs",children:"Upload a photo"})]})}),e.jsx("input",{ref:i,type:"file",accept:"image/*",className:"hidden",onChange:k=>{var T;const S=(T=k.target.files)==null?void 0:T[0];S&&w(S),k.target.value=""}})]}),e.jsxs(zs,{value:"video",className:"mt-3",children:[s?e.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-border",children:[e.jsx("iframe",{src:`${s}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>n(null),children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var k;return(k=d.current)==null?void 0:k.click()},disabled:f,className:"w-full h-32 border-2 border-dashed border-border rounded-lg flex flex-col items-center justify-center gap-2 text-muted-foreground hover:border-primary/40 hover:bg-accent/50 transition-colors",children:f?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(Ms,{className:"h-6 w-6 animate-spin"}),e.jsxs("span",{className:"text-xs",children:["Uploading... ",_,"%"]}),e.jsx("div",{className:"w-32 h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${_}%`}})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Za,{className:"h-6 w-6"}),e.jsx("span",{className:"text-xs",children:"Upload a video (max 500MB)"})]})}),!s&&!f&&e.jsx("div",{className:"mt-2",children:e.jsx(K2e,{contactId:a,onVideoReady:k=>n(k)})}),e.jsx("input",{ref:d,type:"file",accept:"video/*",className:"hidden",onChange:k=>{var T;const S=(T=k.target.files)==null?void 0:T[0];S&&j(S),k.target.value=""}}),e.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-1.5 text-center",children:"Videos are also saved to your Video Library"})]})]})]})}const a1s=[{type:"home_anniversary",label:"Home Anniversary",emoji:"🏡",description:"Celebrate their homeownership milestone",gradient:"from-blue-500/20 to-slate-500/20 border-blue-200 dark:border-blue-800"},{type:"birthday",label:"Birthday",emoji:"🎂",description:"Wish them a happy birthday",gradient:"from-pink-500/20 to-purple-500/20 border-pink-200 dark:border-pink-800"},{type:"just_sold",label:"Just Sold",emoji:"🎉",description:"Announce a successful closing",gradient:"from-emerald-500/20 to-teal-500/20 border-emerald-200 dark:border-emerald-800"},{type:"just_listed",label:"Just Listed",emoji:"🏠",description:"Share a new listing announcement",gradient:"from-amber-500/20 to-orange-500/20 border-amber-200 dark:border-amber-800"},{type:"thank_you",label:"Thank You",emoji:"💐",description:"Show your appreciation",gradient:"from-rose-500/20 to-pink-500/20 border-rose-200 dark:border-rose-800"},{type:"congratulations",label:"Congratulations",emoji:"🏆",description:"Celebrate their achievements",gradient:"from-yellow-500/20 to-amber-500/20 border-yellow-200 dark:border-yellow-800"},{type:"holiday",label:"Holiday",emoji:"🎄",description:"Send seasonal greetings",gradient:"from-red-500/20 to-green-500/20 border-red-200 dark:border-red-800"},{type:"thinking_of_you",label:"Thinking of You",emoji:"💭",description:"Stay top of mind with a personal touch",gradient:"from-violet-500/20 to-indigo-500/20 border-violet-200 dark:border-violet-800"}];function i1s({onSelect:t}){return e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:a1s.map((s,r)=>e.jsxs(wr.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:r*.04,duration:.25},onClick:()=>t(s.type),className:`group relative flex flex-col items-start gap-1 p-3.5 rounded-xl border bg-gradient-to-br ${s.gradient} hover:shadow-md hover:scale-[1.02] active:scale-[0.98] transition-all text-left`,children:[e.jsx("span",{className:"text-2xl",children:s.emoji}),e.jsx("span",{className:"text-sm font-semibold text-foreground",children:s.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground leading-tight",children:s.description})]},s.type))})}const tT={home_anniversary:{title:["Happy Home","Anniversary"],icon:"🏡",emojis:["🏡","✨","🎉","❤️","🎊","🏠"],defaultMessage:"Wishing you many more wonderful years of memories in your beautiful home. Thank you for letting me be part of your journey."},just_listed:{title:["Just","Listed!"],icon:"🏠",emojis:["🏠","📋","🔑","⭐","🎯","✨"],defaultMessage:"Exciting news — this beautiful property just hit the market! Contact me for a private showing."},just_sold:{title:["Just","Sold!"],icon:"🎉",emojis:["🎉","🏡","🔑","🥂","🎊","💰"],defaultMessage:"Another successful closing! Congratulations to the new homeowners. It was a pleasure making this happen."},congratulations:{title:["Congratulations!",""],icon:"🏆",emojis:["🎉","🥳","🏆","⭐","🎊","✨"],defaultMessage:"What an incredible milestone! I'm so happy for you. Wishing you all the best in this exciting new chapter."},birthday:{title:["Happy","Birthday!"],icon:"🎂",emojis:["🎂","🎈","🎁","🥳","🎉","🧁"],defaultMessage:"Wishing you the happiest of birthdays! May this year bring you joy, laughter, and everything you've been dreaming of."},holiday:{title:["Happy","Holidays!"],icon:"🎄",emojis:["🎄","❄️","🎁","⭐","🕯️","🎅"],defaultMessage:"Wishing you and your family a season filled with warmth, joy, and cherished moments. Happy Holidays!"},thank_you:{title:["Thank","You!"],icon:"💐",emojis:["💐","🙏","❤️","⭐","✨","🤝"],defaultMessage:"Thank you so much for your trust and confidence. It truly means the world to me. I'm always here for you!"},thinking_of_you:{title:["Thinking","Of You"],icon:"💭",emojis:["💭","❤️","🌸","☀️","🦋","💫"],defaultMessage:"Just wanted to reach out and let you know I'm thinking of you. I hope you're doing well — don't hesitate to reach out anytime!"}};function _De({initialOpen:t,initialCardType:s,initialContactId:r,initialRecipientName:n,initialAddress:a,initialDate:o,onOpenChange:l}){const{user:i}=Hs(),d=rs(),[u,p]=C.useState(!1),[f,y]=C.useState("type"),[_,b]=C.useState(""),[w,j]=C.useState(null),[k,S]=C.useState(!1),[T,I]=C.useState("home_anniversary"),[L,R]=C.useState(""),[$,q]=C.useState(""),[U,H]=C.useState(""),[Y,se]=C.useState(""),[te,Q]=C.useState("elegant"),[de,re]=C.useState(null),[ae,le]=C.useState(null),he=C.useState(!1);!he[0]&&t&&s&&(he[1](!0),p(!0),I(s),r&&j(r),n&&R(n),a&&q(a),o&&H(o),y(n?"details":"contact"));const{data:be}=wt({queryKey:["contacts-for-card",i==null?void 0:i.id,_],queryFn:async()=>{let Ue=G.from("innercircle_contacts").select("id, first_name, last_name, address, city, state, home_anniversary, email, phone").eq("owner_user_id",i.id).order("first_name").limit(20);_&&(Ue=Ue.or(`first_name.ilike.%${_}%,last_name.ilike.%${_}%`));const{data:ut,error:De}=await Ue;if(De)throw De;return ut},enabled:!!(i!=null&&i.id)&&u}),{data:_e}=wt({queryKey:["agent-profile-card",i==null?void 0:i.id],queryFn:async()=>{const{data:Ue,error:ut}=await G.from("profiles").select("name, email, phone, avatar_url, brokerage:brokerages(name)").eq("id",i.id).single();if(ut)throw ut;return Ue},enabled:!!(i!=null&&i.id)}),je=Ue=>{j(Ue.id),R(`${Ue.first_name}${Ue.last_name?" "+Ue.last_name:""}`),q([Ue.address,Ue.city,Ue.state].filter(Boolean).join(", ")),H(Ue.home_anniversary||""),y("details")},Ne=Ue=>{I(Ue),y("contact")},Ge=async()=>{var Ue;if(!(!i||!_e)){S(!0);try{const ut={owner_user_id:i.id,contact_id:w,card_type:T,template:te,recipient_name:L,property_address:$||null,home_anniversary_date:U||null,custom_message:Y||null,property_photo_url:de||null,video_url:ae||null,agent_name:_e.name||"Agent",agent_photo_url:_e.avatar_url,agent_phone:_e.phone,agent_email:_e.email,agent_brokerage:((Ue=_e.brokerage)==null?void 0:Ue.name)||null},{error:De}=await G.from("sendable_cards").insert(ut);if(De)throw De;fe.success("Card created! Copy the link to share it."),d.invalidateQueries({queryKey:["sendable-cards"]}),we()}catch(ut){fe.error(ut.message||"Failed to create card")}finally{S(!1)}}},we=()=>{p(!1),y("type"),I("home_anniversary"),b(""),j(null),R(""),q(""),H(""),se(""),Q("elegant"),re(null),le(null)},Me={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"},Te=tT[T],Fe=T==="home_anniversary",Ae=["home_anniversary","just_listed","just_sold"].includes(T);return e.jsxs(_s,{open:u,onOpenChange:Ue=>{Ue?p(!0):(we(),l==null||l(!1))},children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Create Card"]})}),e.jsxs(vs,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:f==="type"?"What type of card?":f==="contact"?`${Me[T]} — Choose a Contact`:`${Me[T]} — Customize`})}),f==="type"&&e.jsx(i1s,{onSelect:Ne}),f==="contact"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>y("type"),children:[e.jsx(ti,{className:"h-3.5 w-3.5"})," Back to card types"]}),e.jsxs("div",{className:"relative",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search contacts...",value:_,onChange:Ue=>b(Ue.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[be==null?void 0:be.map(Ue=>e.jsxs("button",{onClick:()=>je(Ue),className:"w-full flex items-center gap-3 p-3 rounded-lg hover:bg-accent text-left transition-colors",children:[e.jsx("div",{className:"h-9 w-9 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Yi,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[Ue.first_name," ",Ue.last_name]}),Ue.address&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate flex items-center gap-1",children:[e.jsx(On,{className:"h-3 w-3"}),Ue.address]})]}),Ue.home_anniversary&&T==="home_anniversary"&&e.jsx("span",{className:"text-[10px] text-emerald-600 bg-emerald-500/10 px-2 py-0.5 rounded-full shrink-0",children:"Anniversary set"})]},Ue.id)),(be==null?void 0:be.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No contacts found"})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{y("details")},children:"Skip — enter details manually"})})]}),f==="details"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>y("contact"),children:[e.jsx(ti,{className:"h-3.5 w-3.5"})," Back"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Recipient Name"}),e.jsx(Re,{value:L,onChange:Ue=>R(Ue.target.value),placeholder:"John & Jane Smith"})]}),Ae&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Property Address"}),e.jsx(Re,{value:$,onChange:Ue=>q(Ue.target.value),placeholder:"123 Main St, Austin, TX"})]}),Fe&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Home Anniversary Date"}),e.jsx(Re,{type:"date",value:U,onChange:Ue=>H(Ue.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Personal Message (optional)"}),e.jsx(Ar,{value:Y,onChange:Ue=>se(Ue.target.value),placeholder:Te.defaultMessage,rows:3})]}),e.jsx(Fet,{photoUrl:de,videoUrl:ae,onPhotoChange:re,onVideoChange:le,contactId:w}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-5 gap-2",children:[{key:"elegant",label:"Elegant",gradient:"bg-gradient-to-br from-slate-100 to-blue-100 dark:from-slate-800 dark:to-slate-700"},{key:"bold",label:"Bold",gradient:"bg-gradient-to-br from-violet-500 to-fuchsia-500"},{key:"warm",label:"Warm",gradient:"bg-gradient-to-br from-amber-200 to-orange-300"},{key:"glass",label:"Glass",gradient:"bg-gradient-to-br from-slate-900 via-blue-900/50 to-slate-900 border border-white/10"},{key:"cinematic",label:"Cinema",gradient:"bg-gradient-to-br from-slate-950 via-blue-950 to-slate-950"}].map(({key:Ue,label:ut,gradient:De})=>e.jsxs("button",{onClick:()=>Q(Ue),className:`p-2 rounded-lg border-2 transition-all text-center ${te===Ue?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-10 rounded-md mb-1.5 ${De}`}),e.jsx("span",{className:"text-[10px] font-medium",children:ut})]},Ue))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>y("contact"),className:"flex-1",children:"Back"}),e.jsx(K,{onClick:Ge,disabled:!L||k,className:"flex-1 gap-2",children:k?"Creating...":"Create Card"})]})]})]})]})}const o1s={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"};function l1s({card:t}){const{user:s}=Hs(),{isGmailConnected:r}=Ny(),n=rs(),[a,o]=C.useState(!1),[l,i]=C.useState("");C.useEffect(()=>{a&&t.contact_id&&!l&&G.from("innercircle_contacts").select("email").eq("id",t.contact_id).maybeSingle().then(({data:w})=>{w!=null&&w.email&&i(w.email)})},[a,t.contact_id]);const d={home_anniversary:`🏡 Happy Home Anniversary, ${t.recipient_name}!`,just_listed:`🏠 Just Listed — Check This Out, ${t.recipient_name}!`,just_sold:`🎉 Just Sold! Congrats, ${t.recipient_name}!`,congratulations:`🏆 Congratulations, ${t.recipient_name}!`,birthday:`🎂 Happy Birthday, ${t.recipient_name}!`,holiday:`🎄 Happy Holidays, ${t.recipient_name}!`,thank_you:`💐 Thank You, ${t.recipient_name}!`,thinking_of_you:`💭 Thinking of You, ${t.recipient_name}!`},[u,p]=C.useState(d[t.card_type]||`A Special Card for ${t.recipient_name}!`),[f,y]=C.useState(""),_=`https://cardstudio.relevelup.com/c/${t.share_token}`,b=Dt({mutationFn:async()=>{var T;if(!l)throw new Error("Recipient email is required");const w=`
${f?`

${f.replace(/\n/g,"
")}


`:""}

I made you a special ${o1s[t.card_type]||t.card_type} card — click below to view it!

${t.property_address?`

${t.property_address}

`:""}
`,{data:j}=await G.auth.getSession(),k=(T=j==null?void 0:j.session)==null?void 0:T.access_token,S=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/gmail-send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${k}`},body:JSON.stringify({to:l,subject:u,body:w,contactId:t.contact_id||void 0})});if(!S.ok){const I=await S.json();throw new Error(I.error||"Failed to send")}return S.json()},onSuccess:async()=>{await G.from("sendable_cards").update({sent_at:new Date().toISOString(),sent_via:"gmail"}).eq("id",t.id),n.invalidateQueries({queryKey:["sendable-cards"]}),fe.success(`Card sent to ${l}!`),o(!1)},onError:w=>{fe.error(w.message||"Failed to send email")}});return r?e.jsxs(_s,{open:a,onOpenChange:o,children:[e.jsx(Ei,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(aa,{className:"h-3 w-3"})})}),e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Send Card via Gmail"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"To"}),e.jsx(Re,{type:"email",value:l,onChange:w=>i(w.target.value),placeholder:"recipient@email.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Subject"}),e.jsx(Re,{value:u,onChange:w=>p(w.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Personal Note (optional)"}),e.jsx(Ar,{value:f,onChange:w=>y(w.target.value),placeholder:"Add a warm personal note before the card link...",rows:3})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3 text-xs text-muted-foreground",children:["The email will include a beautiful button linking to your card at:",e.jsx("br",{}),e.jsx("span",{className:"font-mono text-foreground",children:_})]}),e.jsx(K,{onClick:()=>b.mutate(),disabled:!l||b.isPending,className:"w-full gap-2",children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 animate-spin"})," Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(aa,{className:"h-4 w-4"})," Send Card"]})})]})]})]}):e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs opacity-50 cursor-not-allowed",title:"Connect Gmail in Settings to send cards via email",disabled:!0,children:e.jsx(aa,{className:"h-3 w-3"})})}function c1s({card:t}){const s=rs(),[r,n]=C.useState(!1),[a,o]=C.useState(!1),[l,i]=C.useState(t.recipient_name),[d,u]=C.useState(t.property_address||""),[p,f]=C.useState(t.home_anniversary_date||""),[y,_]=C.useState(t.custom_message||""),[b,w]=C.useState(t.template),[j,k]=C.useState(t.property_photo_url),[S,T]=C.useState(t.video_url||null),I=R=>{R&&(i(t.recipient_name),u(t.property_address||""),f(t.home_anniversary_date||""),_(t.custom_message||""),w(t.template),k(t.property_photo_url),T(t.video_url||null)),n(R)},L=async()=>{if(!l.trim()){fe.error("Recipient name is required");return}o(!0);try{const{error:R}=await G.from("sendable_cards").update({recipient_name:l.trim(),property_address:d.trim()||null,home_anniversary_date:p||null,custom_message:y.trim()||null,template:b,property_photo_url:j||null,video_url:S||null}).eq("id",t.id);if(R)throw R;s.invalidateQueries({queryKey:["sendable-cards"]}),fe.success("Card updated"),n(!1)}catch(R){fe.error(R.message||"Failed to update card")}finally{o(!1)}};return e.jsxs(_s,{open:r,onOpenChange:I,children:[e.jsx(Ei,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Da,{className:"h-3 w-3"})})}),e.jsxs(vs,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Edit Card"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Recipient Name"}),e.jsx(Re,{value:l,onChange:R=>i(R.target.value),placeholder:"John & Jane Smith"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Property Address"}),e.jsx(Re,{value:d,onChange:R=>u(R.target.value),placeholder:"123 Main St, Austin, TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Home Anniversary Date"}),e.jsx(Re,{type:"date",value:p,onChange:R=>f(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Personal Message (optional)"}),e.jsx(Ar,{value:y,onChange:R=>_(R.target.value),placeholder:"Wishing you many more happy years in your beautiful home!",rows:3})]}),e.jsx(Fet,{photoUrl:j,videoUrl:S,onPhotoChange:k,onVideoChange:T,contactId:t.contact_id}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["elegant","bold","warm"].map(R=>e.jsxs("button",{onClick:()=>w(R),className:`p-3 rounded-lg border-2 transition-all text-center ${b===R?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-12 rounded-md mb-2 ${R==="elegant"?"bg-gradient-to-br from-slate-100 to-slate-200 dark:from-slate-800 dark:to-slate-700":R==="bold"?"bg-gradient-to-br from-violet-500 to-fuchsia-500":"bg-gradient-to-br from-amber-200 to-orange-300"}`}),e.jsx("span",{className:"text-xs font-medium capitalize",children:R})]},R))})]}),e.jsx(K,{onClick:L,disabled:!l.trim()||a,className:"w-full gap-2",children:a?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})]})]})]})}function d1s(){const{user:t}=Hs(),s=rs(),[r,n]=C.useState(""),[a,o]=Pc(),l=a.get("cardType"),i=a.get("contactId"),d=a.get("name"),u=a.get("address"),p=a.get("date"),f=!!l,{data:y,isLoading:_}=wt({queryKey:["sendable-cards",t==null?void 0:t.id],queryFn:async()=>{const{data:T,error:I}=await G.from("sendable_cards").select("*").eq("owner_user_id",t.id).order("created_at",{ascending:!1});if(I)throw I;return T},enabled:!!(t!=null&&t.id)}),b=Dt({mutationFn:async T=>{const{error:I}=await G.from("sendable_cards").delete().eq("id",T);if(I)throw I},onSuccess:()=>{s.invalidateQueries({queryKey:["sendable-cards"]}),fe.success("Card deleted")}}),w=T=>{const I=`https://cardstudio.relevelup.com/c/${T}`;navigator.clipboard.writeText(I),fe.success("Share link copied!")},j=y==null?void 0:y.filter(T=>{var I;return!r||T.recipient_name.toLowerCase().includes(r.toLowerCase())||((I=T.property_address)==null?void 0:I.toLowerCase().includes(r.toLowerCase()))}),k={elegant:"Elegant",bold:"Bold",warm:"Warm"},S={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"};return e.jsx(Ts,{title:"Card Studio",children:e.jsxs("div",{className:"max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Card Studio"})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Create & send beautiful branded cards to your clients"})]}),e.jsx(_De,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:d||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search cards...",value:r,onChange:T=>n(T.target.value),className:"pl-9"})]}),_?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(T=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"h-40 bg-muted rounded-lg mb-3"}),e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2"})]})},T))}):j!=null&&j.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:j.map(T=>e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-shadow",children:[e.jsxs("div",{className:`aspect-[16/10] flex items-center justify-center relative overflow-hidden ${T.template==="elegant"?"bg-gradient-to-br from-slate-50 via-slate-100 to-slate-200 dark:from-slate-900 dark:via-slate-800 dark:to-slate-700":T.template==="bold"?"bg-gradient-to-br from-violet-600 via-fuchsia-500 to-pink-500":"bg-gradient-to-br from-amber-100 via-orange-200 to-rose-200 dark:from-amber-900 dark:via-orange-800 dark:to-rose-800"}`,children:[T.template==="elegant"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"absolute top-0 left-0 w-full h-full opacity-10",children:[e.jsx("div",{className:"absolute top-3 left-3 w-16 h-16 border-t-2 border-l-2 border-primary/40 rounded-tl-lg"}),e.jsx("div",{className:"absolute bottom-3 right-3 w-16 h-16 border-b-2 border-r-2 border-primary/40 rounded-br-lg"})]}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-32 h-32 rounded-full border border-primary/10"})]}),T.template==="bold"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute -top-8 -right-8 w-32 h-32 rounded-full bg-white/10 blur-sm"}),e.jsx("div",{className:"absolute -bottom-6 -left-6 w-24 h-24 rounded-full bg-white/10 blur-sm"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,rgba(255,255,255,0.15)_0%,transparent_70%)]"})]}),T.template==="warm"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute -top-4 -left-4 w-28 h-28 rounded-full bg-orange-400/15 blur-md"}),e.jsx("div",{className:"absolute -bottom-6 -right-6 w-32 h-32 rounded-full bg-rose-400/15 blur-md"})]}),e.jsxs("div",{className:"text-center px-4 relative z-10",children:[e.jsx("div",{className:"text-3xl mb-1.5 opacity-80",children:T.card_type==="home_anniversary"?"🏡":T.card_type==="birthday"?"🎂":T.card_type==="just_sold"?"🎉":T.card_type==="just_listed"?"🏠":T.card_type==="thank_you"?"💐":T.card_type==="congratulations"?"🏆":T.card_type==="holiday"?"🎄":T.card_type==="thinking_of_you"?"💭":"✉️"}),e.jsx("p",{className:`text-[10px] uppercase tracking-[0.2em] mb-1 ${T.template==="bold"?"text-white/70":"text-muted-foreground"}`,children:S[T.card_type]||T.card_type}),e.jsx("p",{className:`font-semibold text-base ${T.template==="bold"?"text-white":"text-foreground"}`,children:T.recipient_name}),T.property_address&&e.jsx("p",{className:`text-xs mt-1 ${T.template==="bold"?"text-white/60":"text-muted-foreground"}`,children:T.property_address})]}),e.jsx("div",{className:"absolute top-2 right-2 z-10",children:e.jsx(rt,{variant:T.template==="bold"?"outline":"secondary",className:`text-[10px] ${T.template==="bold"?"border-white/30 text-white/80":""}`,children:k[T.template]||T.template})})]}),e.jsxs(Oe,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(xa,{className:"h-3 w-3"}),T.view_count," views"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Sd(new Date(T.created_at),{addSuffix:!0})})]}),T.sent_at&&e.jsxs("p",{className:"text-[10px] text-emerald-600 mb-2",children:["Sent ",ys(new Date(T.sent_at),"MMM d, yyyy")," via ",T.sent_via]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1 gap-1 text-xs",onClick:()=>w(T.share_token),children:[e.jsx(ai,{className:"h-3 w-3"}),"Copy Link"]}),e.jsx(c1s,{card:T}),e.jsx(l1s,{card:T}),e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>window.open(`https://cardstudio.relevelup.com/c/${T.share_token}`,"_blank"),children:e.jsx(sn,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive gap-1 text-xs",onClick:()=>b.mutate(T.id),children:e.jsx(jr,{className:"h-3 w-3"})})]})]})]},T.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(br,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"No cards yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Create your first digital card to send to a client"}),e.jsx(_De,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:d||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]})})]})})}function CE({delay:t,x:s,y:r,size:n}){return e.jsx(wr.div,{className:"absolute rounded-full bg-slate-300/30 dark:bg-slate-500/20",style:{left:s,top:r,width:n,height:n},animate:{y:[0,-20,0],opacity:[.3,.7,.3],scale:[1,1.2,1]},transition:{duration:4,delay:t,repeat:1/0,ease:"easeInOut"}})}function u1s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:y}=t,_=tT[s];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-blue-50/30 to-white dark:from-slate-950 dark:to-slate-900 flex items-center justify-center p-4 overflow-hidden relative",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx(wr.div,{className:"absolute -top-20 -right-20 w-72 h-72 rounded-full bg-gradient-to-br from-blue-100/40 to-slate-100/20 blur-3xl",animate:{scale:[1,1.1,1],rotate:[0,5,0]},transition:{duration:8,repeat:1/0,ease:"easeInOut"}}),e.jsx(wr.div,{className:"absolute -bottom-20 -left-20 w-64 h-64 rounded-full bg-gradient-to-tr from-slate-200/30 to-blue-100/20 blur-3xl",animate:{scale:[1,1.15,1],rotate:[0,-5,0]},transition:{duration:10,repeat:1/0,ease:"easeInOut"}}),e.jsx(CE,{delay:0,x:"15%",y:"20%",size:8}),e.jsx(CE,{delay:1,x:"80%",y:"30%",size:6}),e.jsx(CE,{delay:2,x:"60%",y:"70%",size:10}),e.jsx(CE,{delay:.5,x:"25%",y:"80%",size:7}),e.jsx(CE,{delay:1.5,x:"70%",y:"15%",size:5})]}),e.jsxs(wr.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,ease:"easeOut"},children:[e.jsxs(wr.div,{className:"bg-white/80 dark:bg-slate-900/80 backdrop-blur-xl rounded-3xl shadow-[0_20px_60px_-15px_rgba(0,0,0,0.1)] overflow-hidden border border-slate-200/60 dark:border-slate-700/50",initial:{scale:.95},animate:{scale:1},transition:{duration:.6,delay:.2},children:[e.jsx("div",{className:"relative h-2 bg-gradient-to-r from-slate-200 via-blue-300 to-slate-200 dark:from-slate-700 dark:via-blue-500 dark:to-slate-700 overflow-hidden",children:e.jsx(wr.div,{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/60 to-transparent",animate:{x:["-100%","200%"]},transition:{duration:3,repeat:1/0,repeatDelay:2,ease:"easeInOut"}})}),e.jsxs("div",{className:"px-8 py-10 text-center",children:[e.jsxs(wr.div,{className:"mx-auto mb-6 h-20 w-20 rounded-2xl bg-gradient-to-br from-slate-100 to-blue-50 dark:from-slate-800 dark:to-slate-700 flex items-center justify-center shadow-lg relative",initial:{scale:0,rotate:-10},animate:{scale:1,rotate:0},transition:{duration:.5,delay:.4,type:"spring",stiffness:200},children:[e.jsx(wr.div,{className:"absolute inset-0 rounded-2xl border-2 border-slate-200/50 dark:border-slate-600/50",animate:{scale:[1,1.15,1],opacity:[.5,0,.5]},transition:{duration:2.5,repeat:1/0,ease:"easeInOut"}}),e.jsx("span",{className:"text-4xl",children:_.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsx(wr.div,{className:"inline-block mb-4",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.4,delay:.6},children:e.jsxs("span",{className:"text-sm font-semibold tracking-[0.25em] uppercase text-blue-400 dark:text-blue-300",children:[a," ",a===1?"Year":"Years"]})}),e.jsx(wr.h1,{className:"text-4xl font-light text-slate-800 dark:text-slate-100 mb-1 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.5,delay:.7},children:_.title[0]}),_.title[1]&&e.jsx(wr.h2,{className:"text-4xl font-bold text-slate-800 dark:text-slate-100 mb-8 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.5,delay:.85},children:_.title[1]}),e.jsxs(wr.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.5,delay:1},children:[e.jsx("p",{className:"text-xl font-medium text-slate-700 dark:text-slate-200 mb-1",children:r}),n&&e.jsx("p",{className:"text-sm text-slate-400 dark:text-slate-500 mb-6",children:n})]}),e.jsx(wr.div,{className:"h-px bg-gradient-to-r from-transparent via-slate-300 dark:via-slate-600 to-transparent mx-auto mb-6",initial:{width:0},animate:{width:"80%"},transition:{duration:.8,delay:1.1},style:{margin:"0 auto 1.5rem"}}),f&&e.jsx(wr.div,{className:"mb-6 rounded-xl overflow-hidden shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.15,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),y&&e.jsx(wr.div,{className:"mb-6 rounded-xl overflow-hidden shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("iframe",{src:`${y}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(wr.p,{className:"text-sm text-slate-500 dark:text-slate-400 leading-relaxed max-w-xs mx-auto mb-8 italic",initial:{opacity:0},animate:{opacity:1},transition:{duration:.6,delay:1.3},children:o||_.defaultMessage}),e.jsxs(wr.div,{className:"border-t border-slate-100 dark:border-slate-800 pt-6",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5,delay:1.5},children:[e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[i?e.jsx(wr.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-slate-200 dark:ring-slate-700 shadow-md",whileHover:{scale:1.1}}):e.jsx("div",{className:"h-12 w-12 rounded-full bg-gradient-to-br from-slate-200 to-blue-100 dark:from-slate-700 dark:to-slate-600 flex items-center justify-center shadow-md",children:e.jsx("span",{className:"text-sm font-semibold text-slate-600 dark:text-slate-300",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 dark:text-slate-200",children:l}),p&&e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-4",children:[d&&e.jsxs(wr.a,{href:`tel:${d}`,className:"flex items-center gap-1.5 px-4 py-2 rounded-full bg-slate-100 dark:bg-slate-800 text-xs font-medium text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors shadow-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Qn,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(wr.a,{href:`mailto:${u}`,className:"flex items-center gap-1.5 px-4 py-2 rounded-full bg-slate-100 dark:bg-slate-800 text-xs font-medium text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors shadow-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(br,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(wr.p,{className:"text-center text-[10px] text-slate-400 dark:text-slate-600 mt-4",initial:{opacity:0},animate:{opacity:1},transition:{delay:2},children:"Powered by LevelUp"})]})]})}function qpe({delay:t,x:s,y:r,color:n,size:a}){return e.jsx(wr.div,{className:`absolute rounded-full blur-2xl ${n}`,style:{left:s,top:r,width:a,height:a},animate:{scale:[1,1.4,1],opacity:[.2,.5,.2]},transition:{duration:5,delay:t,repeat:1/0,ease:"easeInOut"}})}function ME({delay:t,x:s,y:r}){return e.jsx(wr.div,{className:"absolute text-white/30 text-lg",style:{left:s,top:r},animate:{opacity:[0,1,0],scale:[.5,1,.5],rotate:[0,180,360]},transition:{duration:3,delay:t,repeat:1/0,ease:"easeInOut"},children:"✦"})}const bDe={home_anniversary:{bg:"from-violet-950 via-purple-900 to-fuchsia-950",orbs:["bg-violet-500/30","bg-fuchsia-500/25","bg-purple-400/20"]},birthday:{bg:"from-pink-950 via-rose-900 to-fuchsia-950",orbs:["bg-pink-500/30","bg-rose-500/25","bg-fuchsia-400/20"]},just_sold:{bg:"from-emerald-950 via-teal-900 to-cyan-950",orbs:["bg-emerald-500/30","bg-teal-500/25","bg-cyan-400/20"]},just_listed:{bg:"from-amber-950 via-orange-900 to-yellow-950",orbs:["bg-amber-500/30","bg-orange-500/25","bg-yellow-400/20"]},thank_you:{bg:"from-rose-950 via-pink-900 to-red-950",orbs:["bg-rose-500/30","bg-pink-500/25","bg-red-400/20"]},congratulations:{bg:"from-yellow-950 via-amber-900 to-orange-950",orbs:["bg-yellow-500/30","bg-amber-500/25","bg-orange-400/20"]},holiday:{bg:"from-red-950 via-rose-900 to-emerald-950",orbs:["bg-red-500/30","bg-green-500/25","bg-rose-400/20"]},thinking_of_you:{bg:"from-indigo-950 via-violet-900 to-purple-950",orbs:["bg-indigo-500/30","bg-violet-500/25","bg-purple-400/20"]}};function h1s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:y}=t,_=tT[s],b=bDe[s]||bDe.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-br ${b.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[e.jsx(qpe,{delay:0,x:"10%",y:"10%",color:b.orbs[0],size:200}),e.jsx(qpe,{delay:1,x:"70%",y:"60%",color:b.orbs[1],size:180}),e.jsx(qpe,{delay:2,x:"50%",y:"20%",color:b.orbs[2],size:150}),e.jsx(ME,{delay:0,x:"20%",y:"25%"}),e.jsx(ME,{delay:.8,x:"75%",y:"15%"}),e.jsx(ME,{delay:1.6,x:"85%",y:"65%"}),e.jsx(ME,{delay:2.4,x:"10%",y:"75%"}),e.jsx(ME,{delay:.4,x:"45%",y:"85%"}),e.jsxs(wr.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{duration:.7,ease:"easeOut"},children:[e.jsxs(wr.div,{className:"relative rounded-3xl overflow-hidden",initial:{scale:.9},animate:{scale:1},transition:{duration:.5,delay:.2,type:"spring",stiffness:150},children:[e.jsx(wr.div,{className:"absolute -inset-[1px] rounded-3xl bg-gradient-to-r from-violet-500 via-fuchsia-500 to-violet-500 opacity-50",animate:{backgroundPosition:["0% 50%","100% 50%","0% 50%"]},transition:{duration:4,repeat:1/0,ease:"linear"},style:{backgroundSize:"200% 200%"}}),e.jsxs("div",{className:"relative bg-white/5 backdrop-blur-xl border border-white/10 rounded-3xl px-8 py-10 text-center m-[1px]",children:[e.jsxs(wr.div,{className:"mx-auto mb-6 h-20 w-20 rounded-2xl bg-gradient-to-br from-violet-500 to-fuchsia-500 flex items-center justify-center shadow-2xl shadow-violet-500/40 relative",initial:{scale:0,rotate:-20},animate:{scale:1,rotate:0},transition:{duration:.6,delay:.4,type:"spring",stiffness:200},children:[e.jsx(wr.div,{className:"absolute inset-0 rounded-2xl bg-gradient-to-br from-violet-500 to-fuchsia-500",animate:{scale:[1,1.3,1],opacity:[.6,0,.6]},transition:{duration:2,repeat:1/0,ease:"easeInOut"}}),e.jsx("span",{className:"text-4xl relative z-10",children:_.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(wr.div,{className:"inline-flex items-center gap-2 mb-5 px-5 py-2 rounded-full bg-white/10 border border-white/15 backdrop-blur-sm",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.4,delay:.6},children:[e.jsx(wr.span,{className:"text-3xl font-black text-white",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.8},children:a}),e.jsx("span",{className:"text-xs font-semibold text-violet-200 uppercase tracking-widest",children:a===1?"Year":"Years"})]}),e.jsx(wr.h1,{className:"text-5xl font-black text-transparent bg-clip-text bg-gradient-to-r from-violet-200 via-white to-fuchsia-200 mb-2 leading-tight",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.7},children:_.title[0]}),_.title[1]&&e.jsx(wr.h2,{className:"text-5xl font-black text-transparent bg-clip-text bg-gradient-to-r from-fuchsia-300 via-violet-200 to-purple-300 mb-2 leading-tight",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.85},children:_.title[1]}),e.jsx(wr.div,{className:"text-3xl mb-4",initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.4,delay:1,type:"spring",stiffness:300},children:_.emojis.slice(0,3).join("")}),e.jsxs(wr.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.1},children:[e.jsx("p",{className:"text-xl font-semibold text-white/90 mb-1",children:r}),n&&e.jsxs("p",{className:"text-sm text-violet-300/70 mb-6 flex items-center justify-center gap-1.5",children:[e.jsx(On,{className:"h-3.5 w-3.5"}),n]})]}),f&&e.jsx(wr.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10 shadow-lg",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),y&&e.jsx(wr.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10 shadow-lg",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.25,duration:.5},children:e.jsx("iframe",{src:`${y}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(wr.div,{className:"bg-white/5 rounded-2xl p-5 border border-white/10 mb-8 backdrop-blur-sm",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsx("p",{className:"text-sm text-violet-100/80 leading-relaxed",children:o||_.defaultMessage})}),e.jsxs(wr.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.5},children:[e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[i?e.jsx(wr.img,{src:i,alt:l,className:"h-12 w-12 rounded-xl object-cover ring-2 ring-violet-500/40 shadow-lg",whileHover:{scale:1.1}}):e.jsx("div",{className:"h-12 w-12 rounded-xl bg-gradient-to-br from-violet-500 to-fuchsia-500 flex items-center justify-center shadow-lg",children:e.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-bold text-white",children:l}),p&&e.jsx("p",{className:"text-xs text-violet-300/60",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-5",children:[d&&e.jsxs(wr.a,{href:`tel:${d}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r from-violet-500/30 to-fuchsia-500/30 text-xs font-semibold text-white hover:from-violet-500/50 hover:to-fuchsia-500/50 transition-all border border-white/15 shadow-lg",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Qn,{className:"h-3.5 w-3.5"})," Call Me"]}),u&&e.jsxs(wr.a,{href:`mailto:${u}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r from-violet-500/30 to-fuchsia-500/30 text-xs font-semibold text-white hover:from-violet-500/50 hover:to-fuchsia-500/50 transition-all border border-white/15 shadow-lg",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(br,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(wr.p,{className:"text-center text-[10px] text-violet-400/40 mt-4",initial:{opacity:0},animate:{opacity:1},transition:{delay:2},children:"Powered by LevelUp"})]})]})}function m1s({emoji:t,delay:s,x:r,duration:n}){return e.jsx(wr.div,{className:"absolute text-2xl pointer-events-none",style:{left:r,bottom:-20},animate:{y:[0,-600],opacity:[0,1,1,0],x:[0,15,-10,5],rotate:[0,20,-15,10]},transition:{duration:n,delay:s,repeat:1/0,ease:"easeOut"},children:t})}const wDe={home_anniversary:{bg:"from-amber-50 via-orange-50 to-rose-50",header:"from-amber-400 via-orange-400 to-rose-400",accent:"text-amber-900",text:"text-amber-800"},birthday:{bg:"from-pink-50 via-rose-50 to-fuchsia-50",header:"from-pink-400 via-rose-400 to-fuchsia-400",accent:"text-pink-900",text:"text-pink-800"},just_sold:{bg:"from-emerald-50 via-teal-50 to-cyan-50",header:"from-emerald-400 via-teal-400 to-cyan-400",accent:"text-emerald-900",text:"text-emerald-800"},just_listed:{bg:"from-sky-50 via-blue-50 to-indigo-50",header:"from-sky-400 via-blue-400 to-indigo-400",accent:"text-blue-900",text:"text-blue-800"},thank_you:{bg:"from-rose-50 via-pink-50 to-red-50",header:"from-rose-400 via-pink-400 to-red-400",accent:"text-rose-900",text:"text-rose-800"},congratulations:{bg:"from-yellow-50 via-amber-50 to-orange-50",header:"from-yellow-400 via-amber-400 to-orange-400",accent:"text-amber-900",text:"text-amber-800"},holiday:{bg:"from-red-50 via-green-50 to-emerald-50",header:"from-red-500 via-green-500 to-emerald-500",accent:"text-green-900",text:"text-green-800"},thinking_of_you:{bg:"from-violet-50 via-purple-50 to-indigo-50",header:"from-violet-400 via-purple-400 to-indigo-400",accent:"text-violet-900",text:"text-violet-800"}};function p1s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:y}=t,_=tT[s],b=wDe[s]||wDe.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-b ${b.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[_.emojis.map((w,j)=>e.jsx(m1s,{emoji:w,delay:j*1.2,x:`${15+j*14}%`,duration:5+j%3},j)),e.jsx(wr.div,{className:"absolute top-1/4 left-1/2 -translate-x-1/2 w-96 h-96 bg-gradient-to-r from-amber-200/30 to-rose-200/30 rounded-full blur-[100px]",animate:{scale:[1,1.2,1],opacity:[.3,.5,.3]},transition:{duration:6,repeat:1/0,ease:"easeInOut"}}),e.jsxs(wr.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.7},children:[e.jsxs(wr.div,{className:"bg-white rounded-3xl shadow-[0_20px_60px_-15px_rgba(251,146,60,0.2)] overflow-hidden border border-amber-100",initial:{scale:.9},animate:{scale:1},transition:{duration:.5,delay:.2,type:"spring",stiffness:150},children:[e.jsxs(wr.div,{className:`h-28 bg-gradient-to-r ${b.header} relative overflow-hidden`,children:[e.jsx(wr.div,{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent",animate:{x:["-100%","200%"]},transition:{duration:3,repeat:1/0,repeatDelay:2,ease:"easeInOut"}}),e.jsx(wr.div,{className:"absolute top-3 left-10 text-5xl",animate:{rotate:[0,10,-5,0],y:[0,-3,0]},transition:{duration:3,repeat:1/0,ease:"easeInOut"},children:_.emojis[0]}),e.jsx(wr.div,{className:"absolute top-2 right-14 text-3xl",animate:{scale:[1,1.3,1],rotate:[0,15,0]},transition:{duration:2,repeat:1/0,ease:"easeInOut",delay:.5},children:_.emojis[1]}),e.jsx(wr.div,{className:"absolute bottom-2 left-1/2 -translate-x-1/2 text-3xl",animate:{y:[0,-5,0],scale:[1,1.1,1]},transition:{duration:2.5,repeat:1/0,ease:"easeInOut",delay:1},children:_.emojis[2]})]}),e.jsxs("div",{className:"px-8 py-8 text-center -mt-10 relative",children:[e.jsx(wr.div,{className:"mx-auto mb-4 h-20 w-20 rounded-full bg-white shadow-xl flex items-center justify-center border-4 border-white relative",initial:{scale:0},animate:{scale:1},transition:{delay:.4,type:"spring",stiffness:300},children:e.jsx(wr.div,{animate:{scale:[1,1.2,1]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"},children:e.jsx("span",{className:"text-3xl",children:_.icon})})}),s==="home_anniversary"&&a!==null&&a>0&&e.jsx(wr.div,{className:"mb-3",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{delay:.6},children:e.jsxs("span",{className:`inline-flex items-baseline gap-1.5 ${b.accent}`,children:[e.jsx(wr.span,{className:"text-5xl font-black",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.8},children:a}),e.jsx("span",{className:"text-sm font-semibold",children:a===1?"year":"wonderful years"})]})}),e.jsxs(wr.h1,{className:`text-3xl font-bold ${b.accent} mb-1`,initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.9},children:[_.title.join(" ")," ",_.emojis[4]]}),e.jsxs(wr.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.1},children:[e.jsx("p",{className:`text-lg font-semibold ${b.text} mb-1`,children:r}),n&&e.jsxs("p",{className:`text-sm ${b.text} opacity-70 flex items-center justify-center gap-1 mb-5`,children:[e.jsx(Oi,{className:"h-3 w-3"}),n]})]}),f&&e.jsx(wr.div,{className:"mb-5 rounded-2xl overflow-hidden border border-amber-200 shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),y&&e.jsx(wr.div,{className:"mb-5 rounded-2xl overflow-hidden border border-amber-200 shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.25,duration:.5},children:e.jsx("iframe",{src:`${y}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(wr.div,{className:"bg-gradient-to-br from-amber-50 to-orange-50 rounded-2xl p-5 mb-6 border border-amber-100 shadow-inner",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsxs("p",{className:`text-sm ${b.text} leading-relaxed italic`,children:['"',o||_.defaultMessage,'"']})}),e.jsxs(wr.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.5},children:[e.jsxs("div",{className:"flex items-center gap-3 justify-center",children:[i?e.jsx(wr.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-amber-200 shadow-md",whileHover:{scale:1.1}}):e.jsx("div",{className:`h-12 w-12 rounded-full bg-gradient-to-br ${b.header} flex items-center justify-center shadow-md`,children:e.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:`text-sm font-bold ${b.accent}`,children:l}),p&&e.jsx("p",{className:`text-xs ${b.text} opacity-60`,children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[d&&e.jsxs(wr.a,{href:`tel:${d}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${b.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Qn,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(wr.a,{href:`mailto:${u}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${b.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(br,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(wr.p,{className:"text-center text-[10px] text-amber-400 mt-4",initial:{opacity:0},animate:{opacity:1},transition:{delay:2},children:"Powered by LevelUp"})]})]})}function UR({delay:t,x:s,y:r,size:n,color:a}){return e.jsx(wr.div,{className:`absolute rounded-full ${a} blur-3xl`,style:{left:s,top:r,width:n,height:n},animate:{scale:[1,1.3,1],opacity:[.4,.7,.4],x:[0,20,-10,0],y:[0,-15,10,0]},transition:{duration:8,delay:t,repeat:1/0,ease:"easeInOut"}})}function Upe({delay:t,x:s,y:r,size:n}){return e.jsx(wr.div,{className:"absolute rounded-full border border-white/10",style:{left:s,top:r,width:n,height:n},animate:{scale:[1,1.2,1],opacity:[.1,.3,.1],rotate:[0,180,360]},transition:{duration:12,delay:t,repeat:1/0,ease:"linear"}})}const jDe={home_anniversary:{mesh:["bg-sky-400/40","bg-indigo-500/30","bg-violet-400/25"],accent:"text-sky-200",glow:"shadow-sky-500/20"},birthday:{mesh:["bg-pink-400/40","bg-fuchsia-500/30","bg-purple-400/25"],accent:"text-pink-200",glow:"shadow-pink-500/20"},just_sold:{mesh:["bg-emerald-400/40","bg-teal-500/30","bg-cyan-400/25"],accent:"text-emerald-200",glow:"shadow-emerald-500/20"},just_listed:{mesh:["bg-amber-400/40","bg-orange-500/30","bg-yellow-400/25"],accent:"text-amber-200",glow:"shadow-amber-500/20"},thank_you:{mesh:["bg-rose-400/40","bg-pink-500/30","bg-red-400/25"],accent:"text-rose-200",glow:"shadow-rose-500/20"},congratulations:{mesh:["bg-yellow-400/40","bg-amber-500/30","bg-orange-400/25"],accent:"text-yellow-200",glow:"shadow-yellow-500/20"},holiday:{mesh:["bg-red-400/40","bg-emerald-500/30","bg-green-400/25"],accent:"text-red-200",glow:"shadow-red-500/20"},thinking_of_you:{mesh:["bg-violet-400/40","bg-indigo-500/30","bg-blue-400/25"],accent:"text-violet-200",glow:"shadow-violet-500/20"}};function f1s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:y}=t,_=tT[s],b=jDe[s]||jDe.home_anniversary;return e.jsxs("div",{className:"min-h-screen bg-slate-950 flex items-center justify-center p-4 overflow-hidden relative",children:[e.jsx(UR,{delay:0,x:"5%",y:"10%",size:300,color:b.mesh[0]}),e.jsx(UR,{delay:2,x:"60%",y:"50%",size:250,color:b.mesh[1]}),e.jsx(UR,{delay:4,x:"30%",y:"70%",size:200,color:b.mesh[2]}),e.jsx(UR,{delay:1,x:"80%",y:"15%",size:180,color:b.mesh[0]}),e.jsx(Upe,{delay:0,x:"15%",y:"20%",size:100}),e.jsx(Upe,{delay:3,x:"70%",y:"60%",size:140}),e.jsx(Upe,{delay:6,x:"40%",y:"10%",size:80}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03]",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E")`}}),e.jsxs(wr.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{duration:.8,ease:[.16,1,.3,1]},children:[e.jsxs(wr.div,{className:`relative rounded-[28px] overflow-hidden backdrop-blur-2xl bg-white/[0.06] border border-white/[0.12] shadow-2xl ${b.glow}`,initial:{scale:.92},animate:{scale:1},transition:{duration:.6,delay:.2,type:"spring",stiffness:120},children:[e.jsx("div",{className:"relative h-[2px] bg-gradient-to-r from-transparent via-white/20 to-transparent overflow-hidden",children:e.jsx(wr.div,{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/60 to-transparent",animate:{x:["-100%","200%"]},transition:{duration:4,repeat:1/0,repeatDelay:3,ease:"easeInOut"}})}),e.jsxs("div",{className:"px-8 py-10 text-center",children:[e.jsxs(wr.div,{className:"mx-auto mb-6 h-24 w-24 rounded-3xl bg-white/[0.08] backdrop-blur-xl border border-white/[0.15] flex items-center justify-center relative",initial:{scale:0,rotate:-15},animate:{scale:1,rotate:0},transition:{duration:.6,delay:.4,type:"spring",stiffness:180},children:[e.jsx(wr.div,{className:"absolute -inset-1 rounded-3xl border border-white/[0.08]",animate:{scale:[1,1.1,1],opacity:[.3,0,.3]},transition:{duration:3,repeat:1/0,ease:"easeInOut"}}),e.jsx(wr.span,{className:"text-5xl",animate:{scale:[1,1.08,1]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},children:_.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(wr.div,{className:"inline-flex items-center gap-2 mb-5 px-5 py-2 rounded-full bg-white/[0.06] border border-white/[0.1] backdrop-blur-sm",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.4,delay:.6},children:[e.jsx(wr.span,{className:"text-3xl font-black text-white",initial:{opacity:0},animate:{opacity:1},transition:{delay:.8},children:a}),e.jsx("span",{className:`text-[10px] font-bold uppercase tracking-[0.2em] ${b.accent}`,children:a===1?"Year":"Years"})]}),e.jsx(wr.h1,{className:"text-4xl font-extralight text-white/90 mb-1 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.6,delay:.7},children:_.title[0]}),_.title[1]&&e.jsx(wr.h2,{className:"text-4xl font-bold text-white mb-6 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.6,delay:.85},children:_.title[1]}),e.jsxs(wr.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1},children:[e.jsx("p",{className:"text-xl font-medium text-white/80 mb-1",children:r}),n&&e.jsxs("p",{className:"text-sm text-white/30 mb-6 flex items-center justify-center gap-1.5",children:[e.jsx(Oi,{className:"h-3 w-3"})," ",n]})]}),e.jsx(wr.div,{className:"h-px bg-gradient-to-r from-transparent via-white/15 to-transparent mx-auto mb-6",initial:{width:0},animate:{width:"70%"},transition:{duration:1,delay:1.1},style:{margin:"0 auto 1.5rem"}}),f&&e.jsx(wr.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.15,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),y&&e.jsx(wr.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("iframe",{src:`${y}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(wr.div,{className:"bg-white/[0.04] rounded-2xl p-5 border border-white/[0.08] mb-8 backdrop-blur-sm",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsxs("p",{className:"text-sm text-white/60 leading-relaxed italic",children:['"',o||_.defaultMessage,'"']})}),e.jsxs(wr.div,{className:"border-t border-white/[0.06] pt-6",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.5},children:[e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[i?e.jsx(wr.img,{src:i,alt:l,className:"h-12 w-12 rounded-2xl object-cover ring-1 ring-white/10",whileHover:{scale:1.08}}):e.jsx("div",{className:"h-12 w-12 rounded-2xl bg-white/[0.08] border border-white/[0.1] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-semibold text-white/60",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-white/80",children:l}),p&&e.jsx("p",{className:"text-xs text-white/30",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[d&&e.jsxs(wr.a,{href:`tel:${d}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-white/[0.06] border border-white/[0.1] text-xs font-medium text-white/70 hover:bg-white/[0.12] transition-colors backdrop-blur-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Qn,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(wr.a,{href:`mailto:${u}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-white/[0.06] border border-white/[0.1] text-xs font-medium text-white/70 hover:bg-white/[0.12] transition-colors backdrop-blur-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(br,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(wr.p,{className:"text-center text-[10px] text-white/20 mt-4",initial:{opacity:0},animate:{opacity:1},transition:{delay:2},children:"Powered by LevelUp"})]})]})}function Vpe({delay:t,x:s,angle:r,color:n}){return e.jsx(wr.div,{className:`absolute h-[400px] w-[1px] ${n} origin-top`,style:{left:s,top:"-10%",transform:`rotate(${r}deg)`},animate:{opacity:[0,.4,0],scaleY:[.5,1,.5]},transition:{duration:6,delay:t,repeat:1/0,ease:"easeInOut"}})}function VR({delay:t,x:s}){return e.jsx(wr.div,{className:"absolute w-1 h-1 rounded-full bg-amber-400/60",style:{left:s,bottom:"20%"},animate:{y:[0,-200,-400],x:[0,15,-10],opacity:[0,.8,0],scale:[0,1.5,0]},transition:{duration:4,delay:t,repeat:1/0,ease:"easeOut"}})}const NDe={home_anniversary:{gradient:"from-slate-950 via-blue-950 to-slate-950",accent:"from-blue-400 to-cyan-300",stripe:"bg-blue-400/20"},birthday:{gradient:"from-slate-950 via-rose-950 to-slate-950",accent:"from-rose-400 to-pink-300",stripe:"bg-rose-400/20"},just_sold:{gradient:"from-slate-950 via-emerald-950 to-slate-950",accent:"from-emerald-400 to-green-300",stripe:"bg-emerald-400/20"},just_listed:{gradient:"from-slate-950 via-amber-950 to-slate-950",accent:"from-amber-400 to-yellow-300",stripe:"bg-amber-400/20"},thank_you:{gradient:"from-slate-950 via-pink-950 to-slate-950",accent:"from-pink-400 to-rose-300",stripe:"bg-pink-400/20"},congratulations:{gradient:"from-slate-950 via-yellow-950 to-slate-950",accent:"from-yellow-400 to-amber-300",stripe:"bg-yellow-400/20"},holiday:{gradient:"from-slate-950 via-red-950 to-slate-950",accent:"from-red-400 to-green-400",stripe:"bg-red-400/20"},thinking_of_you:{gradient:"from-slate-950 via-purple-950 to-slate-950",accent:"from-purple-400 to-violet-300",stripe:"bg-purple-400/20"}};function g1s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:y}=t,_=tT[s],b=NDe[s]||NDe.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-b ${b.gradient} flex items-center justify-center p-4 overflow-hidden relative`,children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,rgba(255,255,255,0.04)_0%,transparent_60%)]"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_bottom,rgba(0,0,0,0.6)_0%,transparent_60%)]"}),e.jsx(Vpe,{delay:0,x:"20%",angle:15,color:b.stripe}),e.jsx(Vpe,{delay:2,x:"75%",angle:-12,color:b.stripe}),e.jsx(Vpe,{delay:4,x:"50%",angle:5,color:b.stripe}),e.jsx(VR,{delay:0,x:"30%"}),e.jsx(VR,{delay:1.5,x:"60%"}),e.jsx(VR,{delay:3,x:"45%"}),e.jsx(VR,{delay:.7,x:"75%"}),e.jsx("div",{className:"absolute inset-0 opacity-[0.015] mix-blend-overlay",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`}}),e.jsxs(wr.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0},animate:{opacity:1},transition:{duration:1.2},children:[e.jsx(wr.div,{className:"relative overflow-hidden",initial:{y:50},animate:{y:0},transition:{duration:.8,delay:.3,ease:[.16,1,.3,1]},children:e.jsxs("div",{className:"px-8 py-12 text-center",children:[e.jsx(wr.div,{className:"mx-auto mb-8 relative",initial:{scale:0},animate:{scale:1},transition:{duration:.8,delay:.5,type:"spring",stiffness:100},children:e.jsx(wr.div,{className:`h-20 w-20 mx-auto rounded-2xl bg-gradient-to-br ${b.accent} flex items-center justify-center shadow-2xl`,animate:{boxShadow:["0 0 40px rgba(255,255,255,0.05)","0 0 80px rgba(255,255,255,0.1)","0 0 40px rgba(255,255,255,0.05)"]},transition:{duration:3,repeat:1/0,ease:"easeInOut"},children:e.jsx("span",{className:"text-4xl",children:_.icon})})}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(wr.div,{className:"mb-6",initial:{opacity:0},animate:{opacity:1},transition:{delay:.7},children:[e.jsx(wr.span,{className:`text-6xl font-black bg-gradient-to-r ${b.accent} bg-clip-text text-transparent`,initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},transition:{delay:.9,type:"spring"},children:a}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.4em] text-white/30 mt-1",children:a===1?"Year":"Years"})]}),e.jsx("div",{className:"overflow-hidden mb-2",children:e.jsx(wr.h1,{className:"text-5xl font-thin text-white/90 tracking-wide",initial:{y:"100%"},animate:{y:0},transition:{duration:.7,delay:.8,ease:[.16,1,.3,1]},children:_.title[0]})}),_.title[1]&&e.jsx("div",{className:"overflow-hidden mb-8",children:e.jsx(wr.h2,{className:`text-5xl font-black bg-gradient-to-r ${b.accent} bg-clip-text text-transparent`,initial:{y:"100%"},animate:{y:0},transition:{duration:.7,delay:.95,ease:[.16,1,.3,1]},children:_.title[1]})}),e.jsxs(wr.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:1.1,duration:.6},children:[e.jsx("p",{className:"text-lg font-light text-white/70 tracking-wide",children:r}),n&&e.jsxs("p",{className:"text-xs text-white/25 mt-1 flex items-center justify-center gap-1",children:[e.jsx(Oi,{className:"h-3 w-3"})," ",n]})]}),e.jsxs(wr.div,{className:"flex items-center justify-center gap-3 my-8",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2},children:[e.jsx(wr.div,{className:"h-px flex-1 max-w-[60px] bg-gradient-to-r from-transparent to-white/15",initial:{scaleX:0},animate:{scaleX:1},transition:{delay:1.3,duration:.8},style:{transformOrigin:"right"}}),e.jsx(wr.span,{className:"text-white/10 text-xs",animate:{rotate:[0,360]},transition:{duration:20,repeat:1/0,ease:"linear"},children:"✦"}),e.jsx(wr.div,{className:"h-px flex-1 max-w-[60px] bg-gradient-to-l from-transparent to-white/15",initial:{scaleX:0},animate:{scaleX:1},transition:{delay:1.3,duration:.8},style:{transformOrigin:"left"}})]}),f&&e.jsxs(wr.div,{className:"mb-8 rounded-2xl overflow-hidden ring-1 ring-white/5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:1.3,duration:.6},children:[e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-950/30 to-transparent pointer-events-none"})]}),y&&e.jsx(wr.div,{className:"mb-8 rounded-2xl overflow-hidden ring-1 ring-white/5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:1.35,duration:.6},children:e.jsx("iframe",{src:`${y}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(wr.p,{className:"text-sm text-white/40 leading-relaxed max-w-xs mx-auto mb-10 font-light",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.4,duration:.8},children:o||_.defaultMessage}),e.jsxs(wr.div,{className:"pt-6 border-t border-white/[0.04]",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{delay:1.6,duration:.6},children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[i?e.jsx(wr.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-white/10 shadow-xl",whileHover:{scale:1.1}}):e.jsx("div",{className:`h-12 w-12 rounded-full bg-gradient-to-br ${b.accent} flex items-center justify-center shadow-xl`,children:e.jsx("span",{className:"text-sm font-bold text-slate-900",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium text-white/70",children:l}),p&&e.jsx("p",{className:"text-[11px] text-white/25",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[d&&e.jsxs(wr.a,{href:`tel:${d}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${b.accent} text-xs font-semibold text-slate-900 shadow-lg`,whileHover:{scale:1.05,boxShadow:"0 10px 40px rgba(255,255,255,0.15)"},whileTap:{scale:.95},children:[e.jsx(Qn,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(wr.a,{href:`mailto:${u}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-white/[0.06] border border-white/[0.1] text-xs font-medium text-white/60 hover:bg-white/[0.12] transition-colors",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(br,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})}),e.jsx(wr.p,{className:"text-center text-[10px] text-white/10 mt-6",initial:{opacity:0},animate:{opacity:1},transition:{delay:2.2},children:"Powered by LevelUp"})]})]})}function zet(){const{shareToken:t}=ko(),{data:s,isLoading:r,error:n}=wt({queryKey:["public-sendable-card",t],queryFn:async()=>{const{data:l,error:i}=await G.from("sendable_cards").select("*").eq("share_token",t).single();if(i)throw i;return l},enabled:!!t});if(C.useEffect(()=>{t&&G.rpc("log_sendable_card_view",{p_share_token:t}).then(({error:l})=>{l&&console.error("Error tracking view:",l)})},[t]),r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"animate-pulse space-y-4 text-center",children:[e.jsx("div",{className:"h-8 w-48 bg-muted rounded mx-auto"}),e.jsx("div",{className:"h-4 w-32 bg-muted rounded mx-auto"})]})});if(n||!s)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Card not found"}),e.jsx("p",{className:"text-muted-foreground",children:"This card may have been removed or the link is invalid."})]})});const a=s.home_anniversary_date?Math.floor((Date.now()-gl(s.home_anniversary_date).getTime())/(365.25*24*60*60*1e3)):null,o={cardType:s.card_type||"home_anniversary",recipientName:s.recipient_name,propertyAddress:s.property_address,anniversaryYears:a,customMessage:s.custom_message,agentName:s.agent_name,agentPhotoUrl:s.agent_photo_url,agentPhone:s.agent_phone,agentEmail:s.agent_email,agentBrokerage:s.agent_brokerage,propertyPhotoUrl:s.property_photo_url,videoUrl:s.video_url||null};switch(s.template){case"bold":return e.jsx(h1s,{...o});case"warm":return e.jsx(p1s,{...o});case"glass":return e.jsx(f1s,{...o});case"cinematic":return e.jsx(g1s,{...o});case"elegant":default:return e.jsx(u1s,{...o})}}function x1s(){const t=Ya();return wt({queryKey:["drip-settings",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("drip_settings").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function y1s(){const t=Ya(),s=rs();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n}=await G.from("drip_settings").select("id").eq("user_id",t).maybeSingle();if(n){const{data:a,error:o}=await G.from("drip_settings").update(r).eq("user_id",t).select().single();if(o)throw o;return a}else{const{data:a,error:o}=await G.from("drip_settings").insert({user_id:t,is_globally_enabled:r.is_globally_enabled??!1,append_signature:r.append_signature??!0}).select().single();if(o)throw o;return a}},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-settings"]})}})}function v1s(){const t=Pr(),{isGmailConnected:s,gmailEmail:r}=Ny(),{data:n,isLoading:a}=x1s(),o=y1s(),[l,i]=C.useState(!1),[d,u]=C.useState(!0),[p,f]=C.useState(!1);C.useEffect(()=>{n&&(i(n.is_globally_enabled),u(n.append_signature))},[n]);const y=async b=>{if(b&&!s){fe.error("Connect your Gmail account first before enabling Smart Drips");return}i(b);try{await o.mutateAsync({is_globally_enabled:b}),fe.success(b?"Smart Drips enabled globally":"Smart Drips paused globally")}catch{i(!b),fe.error("Failed to update settings")}},_=async b=>{u(b);try{await o.mutateAsync({append_signature:b}),fe.success(b?"Signature will be appended to drip emails":"Signature disabled for drip emails")}catch{u(!b),fe.error("Failed to update settings")}};return e.jsxs(_s,{open:p,onOpenChange:f,children:[e.jsx(Ei,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx($l,{className:"h-3.5 w-3.5"}),"Settings"]})}),e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Ss,{children:[e.jsxs(ks,{className:"flex items-center gap-2",children:[e.jsx($l,{className:"h-5 w-5 text-primary"}),"Smart Drip Settings"]}),e.jsx(Kr,{children:"Configure how your automated drip emails are sent."})]}),e.jsxs("div",{className:"space-y-5 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Email Connection"}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-full ${s?"bg-emerald-500/10":"bg-destructive/10"}`,children:e.jsx(br,{className:`h-4 w-4 ${s?"text-emerald-600":"text-destructive"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s?"Gmail Connected":"Gmail Not Connected"}),r&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r})]})]}),s?e.jsxs(rt,{variant:"outline",className:"gap-1 text-emerald-600 border-emerald-200 bg-emerald-500/10 text-[10px]",children:[e.jsx(ua,{className:"h-3 w-3"}),"Active"]}):e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs gap-1",onClick:()=>{f(!1),t("/mission-control/integrations")},children:[e.jsx(sn,{className:"h-3 w-3"}),"Connect"]})]}),!s&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Smart Drips sends emails from your Gmail account. Connect Gmail to get started."})]}),e.jsx(Rl,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-full ${l?"bg-emerald-500/10":"bg-muted"}`,children:e.jsx(TP,{className:`h-4 w-4 ${l?"text-emerald-600":"text-muted-foreground"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Enable Smart Drips"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l?"Active drips will send when deals move stages":"All drips are paused — nothing will send"})]})]}),e.jsx(Br,{checked:l,onCheckedChange:y,disabled:a||o.isPending})]}),e.jsx(Rl,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-full ${d?"bg-primary/10":"bg-muted"}`,children:e.jsx(Fx,{className:`h-4 w-4 ${d?"text-primary":"text-muted-foreground"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Append Email Signature"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d?"Your signature from Profile settings will be added":"Drip emails will send without a signature"})]})]}),e.jsx(Br,{checked:d,onCheckedChange:_,disabled:a||o.isPending})]}),d&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>{f(!1),t("/profile")},children:[e.jsx(Fx,{className:"h-3 w-3 mr-1"}),"Edit your email signature in Profile settings"]})]})]})]})}function _1s(){const t=Ya();return wt({queryKey:["drip-templates",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("drip_templates").select("*").or(`owner_user_id.eq.${t},is_starter.eq.true`).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function b1s(){const t=Ya();return wt({queryKey:["drip-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function w1s(){const t=Ya(),s=rs();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("drip_templates").insert({owner_user_id:t,stage_id:r.stage_id,title:r.title||"",subject:r.subject||"",body:r.body||"",video_url:r.video_url||null,channel:r.channel||"email",delay_type:r.delay_type||"instant",delay_minutes:r.delay_minutes||0,is_enabled:!1,deal_type:r.deal_type||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-templates"]})}})}function j1s(){const t=rs();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("drip_templates").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["drip-templates"]})}})}function N1s(){const t=rs();return Dt({mutationFn:async s=>{const{error:r}=await G.from("drip_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["drip-templates"]})}})}function k1s(){const t=Ya(),s=rs();return Dt({mutationFn:async({templateId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await G.from("drip_templates").select("*").eq("id",r).single();if(o)throw o;const{data:l,error:i}=await G.from("drip_templates").insert({owner_user_id:t,stage_id:n,title:a.title,subject:a.subject,body:a.body,video_url:a.video_url,channel:a.channel,delay_type:a.delay_type,delay_minutes:a.delay_minutes,is_enabled:!1,is_starter:!1,deal_type:a.deal_type}).select().single();if(i)throw i;return l},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-templates"]})}})}const S1s=[{key:"{{client_first_name}}",label:"Client First Name"},{key:"{{client_last_name}}",label:"Client Last Name"},{key:"{{property_address}}",label:"Property Address"},{key:"{{agent_name}}",label:"Your Name"},{key:"{{agent_phone}}",label:"Your Phone"},{key:"{{close_date}}",label:"Target Close Date"},{key:"{{stage_name}}",label:"Current Stage"},{key:"{{portal_link}}",label:"Portal Link"},{key:"{{review_link}}",label:"Review Link"}];function C1s(){const t=Ya(),{data:s,isLoading:r}=_1s(),{data:n,isLoading:a}=b1s(),o=w1s(),l=j1s(),i=N1s(),d=k1s(),[u,p]=C.useState(null),[f,y]=C.useState(null),_=(s==null?void 0:s.filter(L=>!L.is_starter&&L.owner_user_id===t))||[],b=(s==null?void 0:s.filter(L=>L.is_starter))||[],w=L=>_.filter(R=>R.stage_id===L),j=async L=>{try{await l.mutateAsync({id:L.id,is_enabled:!L.is_enabled}),fe.success(L.is_enabled?"Drip disabled":"Drip enabled")}catch{fe.error("Failed to update")}},k=async L=>{try{const R=n==null?void 0:n.find($=>$.id===L);await o.mutateAsync({stage_id:L,title:`${(R==null?void 0:R.name)||"Stage"} follow-up`,subject:"",body:"",channel:"email",delay_type:"instant",delay_minutes:0}),p(L),fe.success("Drip template created")}catch{fe.error("Failed to create template")}},S=async L=>{try{await i.mutateAsync(L),fe.success("Template deleted")}catch{fe.error("Failed to delete")}},T=async L=>{if(!n||n.length===0){fe.error("No pipeline stages found");return}const R=n[0].id;try{await d.mutateAsync({templateId:L,stageId:R}),fe.success("Template copied to your drips!")}catch{fe.error("Failed to copy template")}},I=r||a;return e.jsx(Ts,{children:e.jsxs("div",{className:"container max-w-4xl mx-auto py-6 px-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fm,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Smart Drips"}),e.jsx(rt,{variant:"outline",className:"text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 border-amber-500 text-amber-600 bg-amber-500/10",children:"Beta"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Automatically send personalized emails when deals move through your pipeline."})]}),e.jsx(v1s,{})]}),e.jsxs("div",{className:"bg-primary/5 border border-primary/15 rounded-xl p-4 mb-6 flex items-start gap-3",children:[e.jsx(vP,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground mb-1",children:"How it works"}),e.jsxs("p",{children:["When a deal moves to a new stage in your pipeline, Smart Drips automatically sends your pre-written email to the client. Nothing sends until you create a template ",e.jsx("strong",{children:"and"})," toggle it on."]})]})]}),e.jsxs(ka,{defaultValue:"my-drips",children:[e.jsxs(_a,{className:"grid grid-cols-2 w-full max-w-xs mb-6",children:[e.jsx(js,{value:"my-drips",children:"My Drips"}),e.jsxs(js,{value:"starters",children:["Starter Templates",b.length>0&&e.jsx(rt,{variant:"secondary",className:"ml-1.5 text-[10px] px-1.5 py-0",children:b.length})]})]}),e.jsx(zs,{value:"my-drips",children:I?e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(L=>e.jsx(xs,{className:"h-16 w-full rounded-xl"},L))}):!n||n.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(Fm,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"No Pipeline Stages"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create pipeline stages first to set up drip automations."})]}):e.jsxs("div",{className:"space-y-2",children:[n.filter(L=>!L.is_won_stage&&!L.is_lost_stage).map(L=>{const R=w(L.id),$=u===L.id,q=R.some(U=>U.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>p($?null:L.id),className:"w-full flex items-center gap-3 p-4 hover:bg-muted/30 transition-colors text-left",children:[e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:L.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:L.name}),R.length>0&&e.jsxs(rt,{variant:"outline",className:`text-[10px] ${q?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[R.length," drip",R.length!==1?"s":"",q&&" · Active"]}),$?e.jsx(Ho,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Ua,{className:"h-4 w-4 text-muted-foreground"})]}),$&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:R.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No drip set for this stage"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>k(L.id),disabled:o.isPending,children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1.5"}),"Create Drip"]})]}):e.jsxs(e.Fragment,{children:[R.map(U=>e.jsx(kDe,{template:U,isEditing:f===U.id,onToggleEdit:()=>y(f===U.id?null:U.id),onToggleEnabled:()=>j(U),onUpdate:H=>l.mutateAsync({id:U.id,...H}),onDelete:()=>S(U.id),userId:t||""},U.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>k(L.id),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},L.id)}),n.filter(L=>L.is_won_stage||L.is_lost_stage).length>0&&e.jsxs("div",{className:"pt-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground font-medium mb-2 px-1",children:"Closing Stages"}),n.filter(L=>L.is_won_stage||L.is_lost_stage).map(L=>{const R=w(L.id),$=u===L.id,q=R.some(U=>U.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden mb-2",children:[e.jsxs("button",{onClick:()=>p($?null:L.id),className:"w-full flex items-center gap-3 p-4 hover:bg-muted/30 transition-colors text-left",children:[e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:L.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:L.name}),R.length>0&&e.jsxs(rt,{variant:"outline",className:`text-[10px] ${q?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[R.length," drip",R.length!==1?"s":"",q&&" · Active"]}),$?e.jsx(Ho,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Ua,{className:"h-4 w-4 text-muted-foreground"})]}),$&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:R.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No drip set for this stage"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>k(L.id),disabled:o.isPending,children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1.5"})," Create Drip"]})]}):e.jsxs(e.Fragment,{children:[R.map(U=>e.jsx(kDe,{template:U,isEditing:f===U.id,onToggleEdit:()=>y(f===U.id?null:U.id),onToggleEnabled:()=>j(U),onUpdate:H=>l.mutateAsync({id:U.id,...H}),onDelete:()=>S(U.id),userId:t||""},U.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>k(L.id),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},L.id)})]})]})}),e.jsx(zs,{value:"starters",children:b.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(hn,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"No Starter Templates Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Admin-created starter templates will appear here. You'll be able to copy them into your own drips."})]}):e.jsx("div",{className:"space-y-3",children:b.map(L=>e.jsx(M1s,{template:L,onCopy:()=>T(L.id),isCopying:d.isPending},L.id))})})]})]})})}function kDe({template:t,isEditing:s,onToggleEdit:r,onToggleEnabled:n,onUpdate:a,onDelete:o,userId:l}){const[i,d]=C.useState(t.title),[u,p]=C.useState(t.subject),[f,y]=C.useState(t.body),[_,b]=C.useState(t.video_url||""),[w,j]=C.useState(t.channel),[k,S]=C.useState(t.delay_type),[T,I]=C.useState(t.delay_minutes),[L,R]=C.useState(!1),$=async()=>{R(!0);try{await a({title:i,subject:u,body:f,video_url:_||null,channel:w,delay_type:k,delay_minutes:T}),fe.success("Drip saved"),r()}catch{fe.error("Failed to save")}finally{R(!1)}},q=U=>{y(H=>H+U)};return e.jsxs("div",{className:"border rounded-lg bg-background overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",role:"button",onClick:r,children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.title||"Untitled drip"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.channel==="sms"?e.jsx(io,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(br,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.delay_type==="instant"?"Sends instantly":`Sends after ${t.delay_minutes>=60?`${Math.round(t.delay_minutes/60)}h`:`${t.delay_minutes}m`}`}),t.video_url&&e.jsx(Nn,{className:"h-3 w-3 text-primary"})]})]}),e.jsx(Br,{checked:t.is_enabled,onCheckedChange:n})]}),s&&e.jsxs("div",{className:"border-t p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs font-medium",children:"Title (internal)"}),e.jsx(Re,{value:i,onChange:U=>d(U.target.value),className:"mt-1 h-8 text-sm",placeholder:"e.g. Buyer intro video"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(ve,{className:"text-xs font-medium",children:"Channel"}),e.jsx("div",{className:"flex gap-1 mt-1",children:["email","sms"].map(U=>e.jsxs("button",{onClick:()=>j(U),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${w===U?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[U==="sms"?e.jsx(io,{className:"h-3 w-3"}):e.jsx(br,{className:"h-3 w-3"}),U==="sms"?"SMS":"Email"]},U))})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ve,{className:"text-xs font-medium",children:"Timing"}),e.jsxs("div",{className:"flex gap-1 mt-1",children:[e.jsx("button",{onClick:()=>S("instant"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${k==="instant"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:"Instant"}),e.jsxs("button",{onClick:()=>S("scheduled"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${k==="scheduled"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[e.jsx(Tn,{className:"h-3 w-3 mr-1 inline"}),"Delay"]})]})]})]}),k==="scheduled"&&e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs font-medium",children:"Delay"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Re,{type:"number",min:1,value:T>=60?Math.round(T/60):T,onChange:U=>{const H=parseInt(U.target.value)||0;I(T>=60?H*60:H)},className:"h-8 w-20 text-sm"}),e.jsx("div",{className:"flex gap-1",children:[{label:"Minutes",mins:T<60?T:30},{label:"Hours",mins:T>=60?T:60},{label:"Days",mins:T>=1440?T:1440}].map(U=>e.jsx("button",{className:`px-2 py-1 rounded text-xs border transition-colors ${U.label==="Minutes"&&T<60||U.label==="Hours"&&T>=60&&T<1440||U.label==="Days"&&T>=1440?"bg-primary/10 text-primary border-primary/30":"text-muted-foreground border-input"}`,onClick:()=>{U.label==="Minutes"?I(30):U.label==="Hours"?I(60):I(1440)},children:U.label},U.label))})]})]}),w==="email"&&e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs font-medium",children:"Subject Line"}),e.jsx(Re,{value:u,onChange:U=>p(U.target.value),className:"mt-1 h-8 text-sm",placeholder:"e.g. Next steps for your home purchase"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx(ve,{className:"text-xs font-medium",children:w==="sms"?"Message":"Email Body"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Insert:"}),e.jsxs("select",{className:"text-[10px] border rounded px-1 py-0.5 bg-background text-muted-foreground",value:"",onChange:U=>{U.target.value&&q(U.target.value),U.target.value=""},children:[e.jsx("option",{value:"",children:"Merge variable..."}),S1s.map(U=>e.jsx("option",{value:U.key,children:U.label},U.key))]})]})]}),e.jsx("textarea",{value:f,onChange:U=>y(U.target.value),placeholder:w==="sms"?"Hey {{client_first_name}}, great talking with you today! Here's a quick video about what's next...":`Hi {{client_first_name}}, It was great meeting with you! Here's a video about what to expect next...`,className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[100px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs font-medium",children:"Attached Video"}),_?e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 text-xs text-muted-foreground truncate bg-muted/50 rounded px-2 py-1.5 border border-input",children:[e.jsx(Nn,{className:"h-3 w-3 inline mr-1 text-primary"}),_.length>50?_.slice(0,50)+"...":_]}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive",onClick:()=>b(""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(K2e,{onVideoReady:U=>b(U)}),e.jsx(G2e,{userId:l,onSelect:U=>b(U),triggerSize:"sm",triggerClassName:"gap-1.5 flex-1"}),e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const U=prompt("Paste a YouTube or Loom URL:");U&&b(U)},children:[e.jsx(Do,{className:"h-3 w-3"})," Paste URL"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive",onClick:o,children:[e.jsx(jr,{className:"h-3 w-3 mr-1"})," Delete"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",className:"text-xs",onClick:r,children:"Cancel"}),e.jsx(K,{size:"sm",className:"text-xs",onClick:$,disabled:L,children:L?"Saving...":"Save Drip"})]})]})]})]})}function M1s({template:t,onCopy:s,isCopying:r}){const[n,a]=C.useState(!1),o=t.body.replace(/<[^>]+>/g,""),l=t.deal_type==="buyer"?"Buyer":t.deal_type==="seller"?"Seller":null,i=t.delay_type==="instant"?"Sends instantly":t.delay_minutes>=1440?`Sends after ${Math.round(t.delay_minutes/1440)} day${Math.round(t.delay_minutes/1440)!==1?"s":""}`:t.delay_minutes>=60?`Sends after ${Math.round(t.delay_minutes/60)} hour${Math.round(t.delay_minutes/60)!==1?"s":""}`:`Sends after ${t.delay_minutes} min`;return e.jsxs("div",{className:"border rounded-xl overflow-hidden transition-all hover:shadow-sm",children:[e.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-start gap-3 p-4 text-left hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-sm",children:t.title}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:t.subject}),!n&&e.jsx("p",{className:"text-xs text-muted-foreground/70 line-clamp-1 mt-1",children:o})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 pt-0.5",children:[l&&e.jsx(rt,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:l}),e.jsxs(rt,{variant:"outline",className:"text-[10px] gap-1",children:[t.channel==="sms"?e.jsx(io,{className:"h-3 w-3"}):e.jsx(br,{className:"h-3 w-3"}),t.channel==="sms"?"SMS":"Email"]}),e.jsxs(rt,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),t.delay_type==="instant"?"Instant":i.replace("Sends ","")]}),n?e.jsx(Ho,{className:"h-4 w-4 text-muted-foreground ml-1"}):e.jsx(Ua,{className:"h-4 w-4 text-muted-foreground ml-1"})]})]}),n&&e.jsxs("div",{className:"border-t bg-muted/10 p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase font-semibold text-muted-foreground tracking-wider mb-1",children:"Subject Line"}),e.jsx("p",{className:"text-sm font-medium",children:t.subject})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase font-semibold text-muted-foreground tracking-wider mb-1",children:"Email Body"}),e.jsx("div",{className:"text-sm text-foreground/80 bg-background rounded-lg border p-4 prose prose-sm max-w-none [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li]:my-0.5 [&_p]:my-2 [&_a]:text-primary [&_a]:underline",dangerouslySetInnerHTML:{__html:t.body}})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Tn,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:i})]}),e.jsxs(K,{onClick:d=>{d.stopPropagation(),s()},size:"sm",className:"w-full gap-1.5",disabled:r,children:[e.jsx(ai,{className:"h-3.5 w-3.5"}),"Use This Template"]})]})]})}const Bet=()=>{const t=bu();return C.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",t.pathname)},[t.pathname]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gray-100",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"mb-4 text-4xl font-bold",children:"404"}),e.jsx("p",{className:"mb-4 text-xl text-gray-600",children:"Oops! Page not found"}),e.jsx("a",{href:"/",className:"text-blue-500 underline hover:text-blue-700",children:"Return to Home"})]})})};function T1s(){return C.useEffect(()=>(document.body.classList.add("cardstudio-page"),()=>{document.body.classList.remove("cardstudio-page")}),[]),e.jsxs(UFe,{children:[e.jsx($s,{path:"/c/:shareToken",element:e.jsx(zet,{})}),e.jsx($s,{path:"*",element:e.jsx(Bet,{})})]})}const Hpe={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function $et({slugOverride:t}){const s=ko(),r=t||s.slug,[n,a]=C.useState("types"),[o,l]=C.useState(null),[i,d]=C.useState(null),[u,p]=C.useState(null),[f,y]=C.useState(new Date),[_,b]=C.useState({name:"",email:"",phone:"",message:""}),[w,j]=C.useState(!1),{data:k,isLoading:S}=wt({queryKey:["public-booking-settings",r],queryFn:async()=>{const{data:Q,error:de}=await G.from("agent_booking_settings").select("*").eq("slug",r).eq("is_active",!0).single();if(de)throw de;return Q},enabled:!!r}),{data:T}=wt({queryKey:["public-booking-profile",k==null?void 0:k.user_id],queryFn:async()=>{const{data:Q,error:de}=await G.from("profiles").select("name, avatar_url, email, phone, title, bio").eq("id",k.user_id).single();if(de)throw de;return Q},enabled:!!(k!=null&&k.user_id)}),{data:I=[]}=wt({queryKey:["public-booking-types",k==null?void 0:k.user_id],queryFn:async()=>{const{data:Q,error:de}=await G.from("agent_booking_types").select("id, name, description, duration_minutes, color, icon, qualification_enabled").eq("user_id",k.user_id).eq("is_active",!0).order("sort_order");if(de)throw de;return Q},enabled:!!(k!=null&&k.user_id)}),{data:L=[]}=wt({queryKey:["public-availability",k==null?void 0:k.user_id],queryFn:async()=>{const{data:Q,error:de}=await G.from("agent_availability_slots").select("day_of_week, start_time, end_time").eq("user_id",k.user_id).eq("is_active",!0);if(de)throw de;return Q},enabled:!!(k!=null&&k.user_id)}),{data:R=[]}=wt({queryKey:["public-blocked-dates",k==null?void 0:k.user_id],queryFn:async()=>{const{data:Q,error:de}=await G.from("agent_blocked_dates").select("blocked_date").eq("user_id",k.user_id);if(de)throw de;return Q.map(re=>re.blocked_date)},enabled:!!(k!=null&&k.user_id)}),{data:$=[]}=wt({queryKey:["public-existing-bookings",k==null?void 0:k.user_id,i],queryFn:async()=>{if(!i)return[];const Q=ys(i,"yyyy-MM-dd"),{data:de,error:re}=await G.from("bookings").select("start_time, end_time").eq("agent_user_id",k.user_id).eq("booking_date",Q).eq("status","confirmed");if(re)throw re;return de},enabled:!!(k!=null&&k.user_id)&&!!i}),q=C.useMemo(()=>[...new Set(L.map(Q=>Q.day_of_week))],[L]),U=Q=>{const de=Zh(new Date),re=ml(de,(k==null?void 0:k.max_advance_days)||30),ae=ml(de,0);return Fk(Q,ae)||Rk(Q,re)||R.includes(ys(Q,"yyyy-MM-dd"))?!1:q.includes(Q.getDay())},H=C.useMemo(()=>{if(!i||!o||!k)return[];const Q=L.filter(be=>be.day_of_week===i.getDay()),de=o.duration_minutes,re=k.buffer_minutes||0,ae=[],le=new Date,he=(k.min_notice_hours||2)*60*60*1e3;for(const be of Q){const[_e,je]=be.start_time.split(":").map(Number),[Ne,Ge]=be.end_time.split(":").map(Number);let we=eI(JP(i,_e),je);const Me=eI(JP(i,Ne),Ge);for(;V4(we,de)<=Me;){const Te=ys(we,"HH:mm"),Fe=ys(V4(we,de),"HH:mm");we.getTime()-le.getTime()>=he&&($.some(Ue=>{const ut=Ue.start_time.slice(0,5),De=Ue.end_time.slice(0,5);return Teut})||ae.push(Te)),we=V4(we,de+re)}}return ae},[i,o,L,k,$]),Y=C.useMemo(()=>{const Q=f.getFullYear(),de=f.getMonth(),re=new Date(Q,de,1),ae=new Date(Q,de+1,0),le=re.getDay(),he=[];for(let be=0;be{if(!(!o||!i||!u||!_.name||!k)){j(!0);try{const Q=ys(V4(eI(JP(new Date,parseInt(u.split(":")[0])),parseInt(u.split(":")[1])),o.duration_minutes),"HH:mm"),{error:de}=await G.from("bookings").insert({agent_user_id:k.user_id,booking_type_id:o.id,booking_date:ys(i,"yyyy-MM-dd"),start_time:u,end_time:Q,guest_name:_.name,guest_email:_.email||null,guest_phone:_.phone||null,guest_message:_.message||null});if(de)throw de;G.functions.invoke("booking-notify",{body:{agentUserId:k.user_id,guestName:_.name,guestEmail:_.email||null,guestPhone:_.phone||null,guestMessage:_.message||null,bookingTypeName:o.name,bookingDate:ys(i,"yyyy-MM-dd"),startTime:u,endTime:Q,durationMinutes:o.duration_minutes,meetingLink:k.meeting_link||null}}).catch(re=>console.error("Booking notify error:",re)),a("confirmed")}catch(Q){fe.error("Failed to book: "+Q.message)}finally{j(!1)}}},te=Q=>{const[de,re]=Q.split(":").map(Number),ae=de>=12?"PM":"AM";return`${de%12||12}:${re.toString().padStart(2,"0")} ${ae}`};return S?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8] flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-[#406E71] border-t-transparent"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading booking page..."})]})}):k?e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8]",children:[e.jsx("div",{className:"h-1.5 bg-gradient-to-r from-[#406E71] via-[#5a9a9d] to-[#2a4c64]"}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-6 sm:py-10",children:[e.jsxs("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden mb-6",children:[e.jsx("div",{className:"relative bg-gradient-to-r from-[#406E71] to-[#2a4c64] px-6 pt-6 pb-12",children:e.jsxs("div",{className:"absolute inset-0 opacity-10",children:[e.jsx("div",{className:"absolute top-2 right-8 w-20 h-20 rounded-full border-2 border-white/30"}),e.jsx("div",{className:"absolute bottom-4 left-12 w-10 h-10 rounded-full border border-white/20"})]})}),e.jsx("div",{className:"relative -mt-10 px-6",children:e.jsxs("div",{className:"flex items-end gap-4",children:[T!=null&&T.avatar_url?e.jsx("img",{src:T.avatar_url,alt:(T==null?void 0:T.name)||"Agent",className:"w-20 h-20 sm:w-24 sm:h-24 rounded-2xl object-cover border-4 border-white shadow-md"}):e.jsx("div",{className:"w-20 h-20 sm:w-24 sm:h-24 rounded-2xl bg-gradient-to-br from-[#406E71] to-[#2a4c64] border-4 border-white shadow-md flex items-center justify-center",children:e.jsx(Yi,{className:"h-10 w-10 text-white"})}),e.jsxs("div",{className:"pb-1.5",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-slate-800 leading-tight",children:(T==null?void 0:T.name)||"Agent"}),(T==null?void 0:T.title)&&e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:T.title})]})]})}),e.jsxs("div",{className:"px-6 py-4 flex flex-wrap gap-2",children:[(T==null?void 0:T.phone)&&e.jsxs("a",{href:`tel:${T.phone}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[#406E71]/8 hover:bg-[#406E71]/15 text-[#406E71] text-xs font-medium transition-colors",children:[e.jsx(Qn,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:T.phone}),e.jsx("span",{className:"sm:hidden",children:"Call"})]}),(T==null?void 0:T.email)&&e.jsxs("a",{href:`mailto:${T.email}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[#2a4c64]/8 hover:bg-[#2a4c64]/15 text-[#2a4c64] text-xs font-medium transition-colors",children:[e.jsx(br,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:T.email}),e.jsx("span",{className:"sm:hidden",children:"Email"})]})]})]}),e.jsx("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden",children:e.jsxs("div",{className:"p-5 sm:p-6",children:[n==="types"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-slate-800",children:"Select a meeting type"}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"Choose the type of meeting you'd like to schedule"})]}),e.jsx("div",{className:"space-y-2.5",children:I.map(Q=>e.jsx("button",{onClick:()=>{l(Q),a("date")},className:"w-full text-left group",children:e.jsx("div",{className:"relative rounded-xl border border-slate-150 p-4 transition-all duration-200 hover:shadow-md hover:border-[#406E71]/30 hover:-translate-y-0.5 active:translate-y-0",style:{borderLeftWidth:"3px",borderLeftColor:Q.color},children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("span",{className:"text-2xl shrink-0 mt-0.5",children:Hpe[Q.icon]||"📅"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold text-sm text-slate-800 group-hover:text-[#406E71] transition-colors",children:Q.name}),Q.description&&e.jsx("p",{className:"text-xs text-slate-500 mt-0.5 line-clamp-2",children:Q.description})]})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-1 px-2.5 py-1 rounded-full bg-slate-100 text-slate-600 text-xs font-medium",children:[e.jsx(Tn,{className:"h-3 w-3"}),Q.duration_minutes,"m"]})]})})},Q.id))})]}),n==="date"&&o&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("button",{onClick:()=>{a("types"),d(null),p(null)},className:"flex items-center gap-1.5 text-xs font-medium text-slate-500 hover:text-slate-800 transition-colors",children:[e.jsx(ti,{className:"h-3.5 w-3.5"})," Back to meeting types"]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl border",style:{borderColor:o.color+"40",backgroundColor:o.color+"08"},children:[e.jsx("span",{className:"text-xl",children:Hpe[o.icon]||"📅"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-semibold text-sm text-slate-800",children:o.name})}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-500 font-medium",children:[e.jsx(Tn,{className:"h-3 w-3"}),o.duration_minutes," min"]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:ys(f,"MMMM yyyy")}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{className:"h-8 w-8 rounded-lg flex items-center justify-center text-slate-500 hover:bg-slate-100 hover:text-slate-800 transition-colors",onClick:()=>y(new Date(f.getFullYear(),f.getMonth()-1)),children:e.jsx(zl,{className:"h-4 w-4"})}),e.jsx("button",{className:"h-8 w-8 rounded-lg flex items-center justify-center text-slate-500 hover:bg-slate-100 hover:text-slate-800 transition-colors",onClick:()=>y(new Date(f.getFullYear(),f.getMonth()+1)),children:e.jsx(Ua,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-0.5 text-center",children:[["Su","Mo","Tu","We","Th","Fr","Sa"].map(Q=>e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-slate-400 font-semibold py-2",children:Q},Q)),Y.map((Q,de)=>{if(!Q)return e.jsx("div",{},`pad-${de}`);const re=U(Q),ae=i&&cl(Q,i),le=cl(Q,new Date);return e.jsx("button",{disabled:!re,onClick:()=>{d(Q),p(null)},className:`h-10 w-10 mx-auto rounded-xl text-sm font-medium transition-all duration-150 ${ae?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-105":re?"hover:bg-[#406E71]/10 text-slate-700 hover:text-[#406E71]":"text-slate-200 cursor-not-allowed"} ${le&&!ae?"ring-1 ring-[#406E71]/40":""}`,children:Q.getDate()},Q.toISOString())})]})]}),i&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(id,{className:"h-4 w-4 text-[#406E71]"}),e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:ys(i,"EEEE, MMMM d")})]}),H.length===0?e.jsxs("div",{className:"text-center py-8 space-y-2",children:[e.jsx(Tn,{className:"h-8 w-8 text-slate-300 mx-auto"}),e.jsx("p",{className:"text-sm text-slate-400",children:"No available times on this day"}),e.jsx("p",{className:"text-xs text-slate-400",children:"Try selecting a different date"})]}):e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-2 max-h-52 overflow-y-auto pr-1 custom-scrollbar",children:H.map(Q=>{const de=u===Q;return e.jsx("button",{onClick:()=>p(Q),className:`px-3 py-2.5 rounded-xl text-sm font-medium transition-all duration-150 ${de?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-[1.02]":"bg-slate-50 text-slate-700 hover:bg-[#406E71]/10 hover:text-[#406E71] border border-slate-150"}`,children:te(Q)},Q)})}),u&&e.jsx(K,{className:"w-full h-12 rounded-xl bg-[#406E71] hover:bg-[#365c5e] text-white font-semibold shadow-md shadow-[#406E71]/20 transition-all hover:shadow-lg",onClick:()=>a("form"),children:"Continue to Details"})]})]}),n==="form"&&o&&i&&u&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("button",{onClick:()=>a("date"),className:"flex items-center gap-1.5 text-xs font-medium text-slate-500 hover:text-slate-800 transition-colors",children:[e.jsx(ti,{className:"h-3.5 w-3.5"})," Back"]}),e.jsxs("div",{className:"rounded-xl bg-gradient-to-r from-[#406E71]/5 to-[#2a4c64]/5 border border-[#406E71]/15 p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:Hpe[o.icon]||"📅"}),e.jsx("p",{className:"font-semibold text-sm text-slate-800",children:o.name})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-slate-600",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(id,{className:"h-3.5 w-3.5 text-[#406E71]"}),ys(i,"EEE, MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3.5 w-3.5 text-[#406E71]"}),te(u)," · ",o.duration_minutes," min"]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-semibold text-slate-700",children:"Full Name *"}),e.jsx(Re,{value:_.name,onChange:Q=>b({..._,name:Q.target.value}),placeholder:"Jane Smith",className:"h-11 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-semibold text-slate-700",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(br,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(Re,{type:"email",value:_.email,onChange:Q=>b({..._,email:Q.target.value}),placeholder:"jane@email.com",className:"h-11 pl-9 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-semibold text-slate-700",children:"Phone"}),e.jsxs("div",{className:"relative",children:[e.jsx(Qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(Re,{type:"tel",value:_.phone,onChange:Q=>b({..._,phone:Q.target.value}),placeholder:"(555) 123-4567",className:"h-11 pl-9 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{className:"text-xs font-semibold text-slate-700",children:"Message (optional)"}),e.jsx(Ar,{value:_.message,onChange:Q=>b({..._,message:Q.target.value}),placeholder:"Anything you'd like the agent to know ahead of time?",rows:3,className:"rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20 resize-none"})]})]}),e.jsx(K,{className:"w-full h-12 rounded-xl bg-[#406E71] hover:bg-[#365c5e] text-white font-semibold shadow-md shadow-[#406E71]/20 transition-all hover:shadow-lg disabled:opacity-60",onClick:se,disabled:!_.name||w,children:w?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"}),"Booking..."]}):"Confirm Booking"})]}),n==="confirmed"&&e.jsxs("div",{className:"text-center space-y-5 py-6",children:[e.jsxs("div",{className:"relative mx-auto w-20 h-20",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-emerald-100 animate-ping opacity-30"}),e.jsx("div",{className:"relative w-20 h-20 rounded-full bg-gradient-to-br from-emerald-400 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-200",children:e.jsx(ua,{className:"h-10 w-10 text-white"})})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-slate-800",children:"You're booked!"}),e.jsxs("p",{className:"text-slate-500 mt-1.5",children:[o==null?void 0:o.name," with ",(T==null?void 0:T.name)||"your agent"]})]}),e.jsx("div",{className:"inline-flex items-center gap-3 px-5 py-3 rounded-xl bg-slate-50 border border-slate-100",children:e.jsxs("div",{className:"text-left text-sm",children:[e.jsx("p",{className:"font-semibold text-slate-800",children:i&&ys(i,"EEEE, MMMM d, yyyy")}),e.jsxs("p",{className:"text-slate-500",children:[u&&te(u)," · ",o==null?void 0:o.duration_minutes," min"]})]})}),e.jsx("p",{className:"text-sm text-slate-400 max-w-xs mx-auto",children:"A confirmation with meeting details will be sent to you shortly."}),((T==null?void 0:T.phone)||(T==null?void 0:T.email))&&e.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wider font-semibold",children:"Contact"}),e.jsxs("div",{className:"flex gap-3",children:[(T==null?void 0:T.phone)&&e.jsxs("a",{href:`tel:${T.phone}`,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-full bg-[#406E71]/10 text-[#406E71] text-xs font-medium hover:bg-[#406E71]/20 transition-colors",children:[e.jsx(Qn,{className:"h-3.5 w-3.5"})," Call"]}),(T==null?void 0:T.email)&&e.jsxs("a",{href:`mailto:${T.email}`,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-full bg-[#2a4c64]/10 text-[#2a4c64] text-xs font-medium hover:bg-[#2a4c64]/20 transition-colors",children:[e.jsx(br,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]})}),e.jsx("p",{className:"text-center text-[10px] text-slate-300 mt-6 font-medium tracking-wide uppercase",children:"Powered by LevelUp"})]})]}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8] flex items-center justify-center p-4",children:e.jsxs("div",{className:"max-w-sm w-full text-center space-y-4",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-2xl bg-slate-100 flex items-center justify-center",children:e.jsx(id,{className:"h-8 w-8 text-slate-400"})}),e.jsx("h2",{className:"text-lg font-semibold text-slate-700",children:"Page Not Available"}),e.jsx("p",{className:"text-sm text-slate-500",children:"This booking page doesn't exist or is currently inactive."})]})})}function A1s(){const s=bu().pathname.slice(1).split("/")[0];return C.useEffect(()=>{document.body.classList.add("booking-page");const r=()=>{['[id*="lc_text_widget"]','[id*="lc_text-widget"]','[class*="lc-text-widget"]','[class*="lc_text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("booking-page"),n.forEach(clearTimeout)}},[]),s?e.jsx($et,{slugOverride:s}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-slate-100 dark:from-slate-950 dark:to-slate-900 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"LevelUp Scheduler"}),e.jsx("p",{className:"text-muted-foreground",children:"Visit a specific agent's booking URL to schedule a meeting."})]})})}function E1s(){const s=bu().pathname.slice(1);return C.useEffect(()=>{document.body.classList.add("connect-page");const r=()=>{['[id*="lc_text_widget"]','[id*="lc_text-widget"]','[class*="lc-text-widget"]','[class*="lc_text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("connect-page"),n.forEach(clearTimeout)}},[]),!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-slate-100 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Connect"}),e.jsx("p",{className:"text-slate-500",children:"Stay connected with your real estate professional."}),e.jsx("p",{className:"text-slate-400 text-sm mt-2",children:"Visit a specific agent link to get started."})]})}):e.jsx(mVe,{slugOverride:s})}function qet({slugOverride:t}){const{slug:s}=ko(),r=t||s,[n,a]=C.useState(!1),[o,l]=C.useState({}),[i,d]=C.useState(0),[u,p]=C.useState(!1),{data:f,isLoading:y}=wt({queryKey:["public-landing-page",r],queryFn:async()=>{const{data:$,error:q}=await G.from("landing_pages").select("*").eq("slug",r).eq("is_published",!0).single();if(q)throw q;return $},enabled:!!r}),{data:_=[]}=wt({queryKey:["public-landing-page-fields",f==null?void 0:f.id],queryFn:async()=>{const{data:$,error:q}=await G.from("landing_page_fields").select("*").eq("page_id",f.id).order("sort_order");if(q)throw q;return $},enabled:!!(f!=null&&f.id)});C.useEffect(()=>{f!=null&&f.id&&G.from("landing_pages").update({view_count:(f.view_count||0)+1}).eq("id",f.id).then(()=>{})},[f==null?void 0:f.id]);const b=Dt({mutationFn:async()=>{const $=_.find(Y=>Y.field_type==="text"&&Y.label.toLowerCase().includes("name")),q=_.find(Y=>Y.field_type==="email"),U=_.find(Y=>Y.field_type==="phone"),{error:H}=await G.from("landing_page_submissions").insert([{page_id:f.id,answers:JSON.parse(JSON.stringify(o)),contact_name:$?String(o[$.label]||""):null,contact_email:q?String(o[q.label]||""):null,contact_phone:U?String(o[U.label]||""):null,referrer:document.referrer||null,user_agent:navigator.userAgent,utm_source:new URLSearchParams(window.location.search).get("utm_source"),utm_medium:new URLSearchParams(window.location.search).get("utm_medium"),utm_campaign:new URLSearchParams(window.location.search).get("utm_campaign")}]);if(H)throw H},onSuccess:()=>a(!0)}),w=$=>{$.preventDefault(),!(_.filter(U=>U.is_required&&!o[U.label]).length>0)&&b.mutate()};if(y)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-gray-400 border-t-transparent"})});if(!f)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-700",children:"Page Not Found"}),e.jsx("p",{className:"text-gray-500 mt-2",children:"This page doesn't exist or is no longer available."})]})});const j=f.primary_color||"#406E71",k=f.accent_color||"#2a4c64",S=f,T=f.page_type==="lead_magnet",I=f.page_type==="just_listed"||f.page_type==="just_sold",L=Array.isArray(S.property_photos)?S.property_photos:[],R=S.lead_magnet_file_url||S.lead_magnet_external_url;if(n)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{background:`linear-gradient(135deg, ${j}, ${k})`},children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl p-8 max-w-md mx-4 text-center",children:[e.jsx(ua,{className:"h-16 w-16 mx-auto mb-4",style:{color:j}}),e.jsx("h2",{className:"text-2xl font-bold mb-2",children:T?"Your download is ready!":"Submitted!"}),e.jsx("p",{className:"text-gray-600",children:f.success_message}),T&&R&&e.jsxs("a",{href:R,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 mt-6 px-6 py-3 rounded-lg text-white font-semibold transition-transform hover:scale-105",style:{backgroundColor:j},children:[e.jsx(xi,{className:"h-5 w-5"}),"Download ",S.lead_magnet_file_name||"Your File"]}),f.agent_name&&e.jsxs("div",{className:"mt-6 pt-4 border-t",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Contact"}),e.jsx("p",{className:"font-semibold",children:f.agent_name}),f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:j},children:[e.jsx(Qn,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:j},children:[e.jsx(br,{className:"h-3 w-3"})," ",f.agent_email]})]})]})});if(I){const $=q=>{const U=parseFloat(q.replace(/[^0-9.]/g,""));return isNaN(U)?q:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(U)};return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[u&&L.length>0&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/95 flex items-center justify-center",onClick:()=>p(!1),children:[e.jsx("button",{onClick:()=>p(!1),className:"absolute top-4 right-4 text-white/80 hover:text-white z-10",children:e.jsx(Ur,{className:"h-8 w-8"})}),e.jsx("button",{onClick:q=>{q.stopPropagation(),d(U=>U===0?L.length-1:U-1)},className:"absolute left-4 top-1/2 -translate-y-1/2 bg-white/10 hover:bg-white/20 text-white rounded-full p-3 transition-colors z-10",children:e.jsx(zl,{className:"h-6 w-6"})}),e.jsx("img",{src:L[i],alt:`Property photo ${i+1}`,className:"max-h-[90vh] max-w-[90vw] object-contain rounded-lg",onClick:q=>q.stopPropagation()}),e.jsx("button",{onClick:q=>{q.stopPropagation(),d(U=>U===L.length-1?0:U+1)},className:"absolute right-4 top-1/2 -translate-y-1/2 bg-white/10 hover:bg-white/20 text-white rounded-full p-3 transition-colors z-10",children:e.jsx(Ua,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 text-white/70 text-sm",children:[i+1," / ",L.length]})]}),L.length>0&&e.jsxs("div",{className:"relative max-w-6xl mx-auto px-4 pt-6",children:[e.jsx("div",{className:"absolute top-10 left-8 z-10 px-4 py-1.5 rounded-full text-white font-bold text-sm uppercase tracking-wider shadow-lg",style:{backgroundColor:S.property_status==="just_sold"?"#e74c3c":j},children:S.property_status==="just_sold"?"🎉 Just Sold":"🏡 Just Listed"}),L.length===1?e.jsxs("div",{className:"rounded-2xl overflow-hidden cursor-pointer group",onClick:()=>{d(0),p(!0)},children:[e.jsx("img",{src:L[0],alt:"Property",className:"w-full h-[50vh] object-cover group-hover:scale-105 transition-transform duration-500"}),e.jsxs("div",{className:"absolute bottom-4 right-4 bg-black/60 text-white px-3 py-1.5 rounded-lg text-sm flex items-center gap-1.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(f_,{className:"h-4 w-4"})," View"]})]}):L.length===2?e.jsx("div",{className:"grid grid-cols-2 gap-2 rounded-2xl overflow-hidden",children:L.slice(0,2).map((q,U)=>e.jsx("div",{className:"cursor-pointer group relative",onClick:()=>{d(U),p(!0)},children:e.jsx("img",{src:q,alt:`Property ${U+1}`,className:"w-full h-[45vh] object-cover group-hover:scale-105 transition-transform duration-500"})},U))}):e.jsxs("div",{className:"grid grid-cols-4 gap-2 rounded-2xl overflow-hidden",style:{height:"55vh"},children:[e.jsx("div",{className:"col-span-2 row-span-2 cursor-pointer group relative",onClick:()=>{d(0),p(!0)},children:e.jsx("img",{src:L[0],alt:"Property main",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),L.slice(1,5).map((q,U)=>e.jsxs("div",{className:"cursor-pointer group relative",onClick:()=>{d(U+1),p(!0)},children:[e.jsx("img",{src:q,alt:`Property ${U+2}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}),U===3&&L.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center text-white font-bold text-lg",children:["+",L.length-5," more"]})]},U))]}),L.length>2&&e.jsxs("button",{onClick:()=>{d(0),p(!0)},className:"absolute bottom-4 right-8 bg-white shadow-lg hover:shadow-xl text-gray-800 px-4 py-2 rounded-lg text-sm font-medium flex items-center gap-2 transition-shadow",children:[e.jsx(f_,{className:"h-4 w-4"})," View all ",L.length," photos"]})]}),L.length===0&&e.jsx("div",{className:"relative py-16 px-4",style:{background:f.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${f.hero_image_url}) center/cover`:`linear-gradient(135deg, ${j}, ${k})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[f.logo_url&&e.jsx("img",{src:f.logo_url,alt:"Logo",className:"h-12 w-auto mx-auto mb-6"}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold",children:f.hero_headline}),f.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:f.hero_subtext})]})}),e.jsx("div",{className:"max-w-4xl mx-auto px-4 py-8",children:e.jsxs("div",{className:"grid md:grid-cols-5 gap-6",children:[e.jsx("div",{className:"md:col-span-3 space-y-6",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 md:p-8",children:[S.property_price&&e.jsx("p",{className:"text-3xl md:text-4xl font-bold mb-2",style:{color:j},children:$(S.property_price)}),S.property_address&&e.jsxs("p",{className:"text-gray-600 flex items-center gap-1.5 mb-5 text-lg",children:[e.jsx(Oi,{className:"h-5 w-5 shrink-0"})," ",S.property_address]}),e.jsxs("div",{className:"flex gap-6 mb-5 py-4 border-y border-gray-100",children:[S.property_beds&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(E0,{className:"h-5 w-5",style:{color:j}})," ",S.property_beds]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bedrooms"})]}),S.property_baths&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(Zx,{className:"h-5 w-5",style:{color:j}})," ",S.property_baths]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bathrooms"})]}),S.property_sqft&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(LP,{className:"h-5 w-5",style:{color:j}})," ",Number(S.property_sqft).toLocaleString()]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Sq Ft"})]})]}),S.property_description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-800 mb-2",children:"About This Property"}),e.jsx("p",{className:"text-gray-600 leading-relaxed whitespace-pre-line",children:S.property_description})]})]})}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 sticky top-6",children:[e.jsx("h2",{className:"text-lg font-bold mb-1",style:{color:j},children:S.property_status==="just_sold"?"Want results like this?":"Interested in this property?"}),e.jsx("p",{className:"text-gray-500 text-sm mb-4",children:"Fill out the form and I'll be in touch!"}),f.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-5 pb-4 border-b",children:[f.agent_photo_url&&e.jsx("img",{src:f.agent_photo_url,alt:f.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:f.agent_name}),e.jsxs("div",{className:"flex flex-col gap-0.5 text-xs text-gray-500",children:[f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Qn,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(br,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:w,className:"space-y-3",children:[_.map(q=>e.jsxs("div",{children:[e.jsxs(ve,{className:"text-xs font-medium",children:[q.label,q.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),SDe(q,o,l)]},q.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:j},disabled:b.isPending,children:b.isPending?"Submitting...":"Submit"}),b.isError&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:"Something went wrong. Please try again."})]})]})})]})}),e.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Powered by LevelUp"})]})}return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"relative py-16 px-4",style:{background:f.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${f.hero_image_url}) center/cover`:`linear-gradient(135deg, ${j}, ${k})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[f.logo_url&&e.jsx("img",{src:f.logo_url,alt:"Logo",className:"h-12 w-auto mx-auto mb-6"}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold",children:f.hero_headline}),f.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:f.hero_subtext}),T&&S.lead_magnet_file_name&&e.jsxs("div",{className:"mt-6 inline-flex items-center gap-2 bg-white/20 backdrop-blur px-4 py-2 rounded-full text-sm",children:[e.jsx(xi,{className:"h-4 w-4"}),"Free Download: ",S.lead_magnet_file_name]})]})}),e.jsx("div",{className:"max-w-2xl mx-auto px-4 -mt-8",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 md:p-8",children:[T&&e.jsx("p",{className:"text-sm text-gray-500 mb-4 text-center",children:"Fill out the form below to get your free download!"}),f.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-6 pb-4 border-b",children:[f.agent_photo_url&&e.jsx("img",{src:f.agent_photo_url,alt:f.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:f.agent_name}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-500",children:[f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Qn,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(br,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:w,className:"space-y-4",children:[_.map($=>e.jsxs("div",{children:[e.jsxs(ve,{className:"text-sm font-medium",children:[$.label,$.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),SDe($,o,l)]},$.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:j},disabled:b.isPending,children:b.isPending?"Submitting...":T?"Get My Free Download":"Submit"}),b.isError&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:"Something went wrong. Please try again."})]})]})}),e.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Powered by LevelUp"})]})}function SDe(t,s,r,n){const a=s[t.label]||"",o=Array.isArray(t.options)?t.options:[];switch(t.field_type){case"text":case"email":case"phone":return e.jsx(Re,{type:t.field_type==="email"?"email":t.field_type==="phone"?"tel":"text",value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),placeholder:t.placeholder||"",className:"mt-1"});case"textarea":return e.jsx(Ar,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),placeholder:t.placeholder||"",rows:3,className:"mt-1"});case"select":return e.jsxs(sr,{value:String(a),onValueChange:l=>r(i=>({...i,[t.label]:l})),children:[e.jsx(er,{className:"mt-1",children:e.jsx(rr,{placeholder:"Select..."})}),e.jsx(tr,{children:o.map(l=>e.jsx(At,{value:l,children:l},l))})]});case"multiselect":return e.jsx("div",{className:"mt-1 space-y-2",children:o.map(l=>{const i=Array.isArray(a)?a:[];return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Bo,{checked:i.includes(l),onCheckedChange:d=>{const u=d?[...i,l]:i.filter(p=>p!==l);r(p=>({...p,[t.label]:u}))}}),e.jsx("span",{className:"text-sm",children:l})]},l)})});case"toggle":return e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsx(Br,{checked:!!a,onCheckedChange:l=>r(i=>({...i,[t.label]:l?"Yes":"No"}))}),e.jsx("span",{className:"text-sm text-gray-600",children:a?"Yes":"No"})]});default:return e.jsx(Re,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),className:"mt-1"})}}function P1s(){const s=bu().pathname.slice(1).split("/")[0];return C.useEffect(()=>{document.body.classList.add("landing-page-public");const r=()=>{['[id*="lc_text_widget"]','[class*="lc-text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("landing-page-public"),n.forEach(clearTimeout)}},[]),s?e.jsx(qet,{slugOverride:s}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-slate-100 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"LevelUp Pages"}),e.jsx("p",{className:"text-gray-500",children:"Visit a specific page URL to view content."})]})})}const I1s=({team:t,onSelect:s})=>{const{data:r}=wt({queryKey:["team-card-info",t.id],queryFn:async()=>{const{data:n}=await G.from("team_members").select("user_id, role").eq("team_id",t.id),a=(n==null?void 0:n.length)||0,o=n==null?void 0:n.find(i=>i.role==="team_leader");let l=null;if(o){const{data:i}=await G.from("profiles").select("name, avatar_url").eq("id",o.user_id).single();l=i}return{count:a,leaderProfile:l}}});return e.jsxs(Ee,{className:"cursor-pointer hover:shadow-md transition-shadow group",onClick:s,children:[e.jsx(It,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Ot,{className:"text-lg truncate",children:t.name}),t.description&&e.jsx(pr,{className:"mt-1 line-clamp-2",children:t.description})]}),e.jsxs(rt,{variant:"secondary",className:"ml-2 shrink-0",children:[e.jsx(hr,{className:"h-3 w-3 mr-1"}),(r==null?void 0:r.count)??"…"]})]})}),e.jsxs(Oe,{className:"space-y-3",children:[(r==null?void 0:r.leaderProfile)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(xn,{className:"h-6 w-6",children:[e.jsx(Aa,{src:r.leaderProfile.avatar_url||""}),e.jsx(yn,{className:"text-xs",children:(r.leaderProfile.name||"?").charAt(0).toUpperCase()})]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Uh,{className:"h-3 w-3 text-[hsl(var(--chart-4))]"}),r.leaderProfile.name||"Team Leader"]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ih,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"capitalize text-xs",children:t.contact_visibility.replace("_"," ")})]}),t.lead_pond_enabled&&e.jsx(rt,{variant:"outline",className:"text-xs py-0",children:"Lead Pond"}),t.shared_assets_enabled&&e.jsx(rt,{variant:"outline",className:"text-xs py-0",children:"Shared Assets"}),t.shared_videos_enabled&&e.jsx(rt,{variant:"outline",className:"text-xs py-0",children:"Shared Videos"})]})]})]})},L1s=()=>{const{user:t,isAdmin:s,isBrokerageManager:r,brokerageId:n,managedBrokerages:a,selectedBrokerageId:o}=Hs(),l=o||(a.length>0?a[0].id:n),i=s?void 0:l||void 0,{teams:d,isLoading:u,createTeam:p,updateTeam:f,deleteTeam:y,addMember:_,removeMember:b,updateMemberRole:w}=uS(i),[j,k]=C.useState(!1),[S,T]=C.useState(null),{data:I}=wt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:$,error:q}=await G.from("brokerages").select("id, name").order("name");if(q)throw q;return $||[]},enabled:s}),{data:L}=wt({queryKey:["brokerage-agents-for-teams",l],queryFn:async()=>{const{data:$,error:q}=await G.from("profiles").select("id, name, email, avatar_url").eq("brokerage_id",l).order("name");if(q)throw q;return $||[]},enabled:!!l}),R=async $=>{const q=$.brokerage_id||l||null,U=await p.mutateAsync({name:$.name,brokerage_id:q,description:$.description});if($.leaderId&&$.leaderId!=="none"&&await _.mutateAsync({team_id:U.id,user_id:$.leaderId,role:"team_leader"}),$.memberIds)for(const H of $.memberIds)await _.mutateAsync({team_id:U.id,user_id:H,role:"team_member"});k(!1)};return!r&&!s?e.jsx(Ts,{title:"Teams",description:"Team Management",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Access Denied"}),e.jsx("p",{className:"text-muted-foreground",children:"You need brokerage manager access to manage teams."})]})}):e.jsx(Ts,{title:"Teams",description:"Create and manage teams within your brokerage",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Teams"}),e.jsx("p",{className:"text-muted-foreground",children:"Organize your agents into teams with leaders and shared resources."})]}),e.jsxs(K,{onClick:()=>k(!0),children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(zKe,{open:j,onOpenChange:k,onCreateTeam:R,isCreating:p.isPending,brokerageAgents:L||[],isAdmin:s,allBrokerages:I,activeBrokerageId:l}),u&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map($=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6",children:[e.jsx(xs,{className:"h-5 w-32 mb-3"}),e.jsx(xs,{className:"h-4 w-48 mb-4"}),e.jsx(xs,{className:"h-8 w-full"})]})},$))}),!u&&d.length===0&&!S&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first team to organize agents and share resources."}),e.jsxs(K,{onClick:()=>k(!0),children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Your First Team"]})]})}),!u&&d.length>0&&!S&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:d.map($=>e.jsx(I1s,{team:$,onSelect:()=>T($)},$.id))}),S&&e.jsx(FKe,{team:S,brokerageAgents:L||[],onBack:()=>T(null),onUpdate:$=>f.mutateAsync({id:S.id,...$}).then(q=>T(q)),onAddMember:($,q)=>_.mutateAsync({team_id:S.id,user_id:$,role:q}),onRemoveMember:$=>b.mutateAsync({team_id:S.id,member_id:$}),onUpdateRole:($,q)=>w.mutateAsync({team_id:S.id,member_id:$,role:q}),onDeleteTeam:()=>y.mutate(S.id),isUpdating:f.isPending,isAddingMember:_.isPending})]})})},D1s=()=>{const{data:t,isLoading:s}=Lf(),{useTeamMembers:r}=uS(),{data:n=[],isLoading:a}=r((t==null?void 0:t.teamId)||"");if(s)return e.jsx(Ts,{title:"My Team",description:"Your team",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(xs,{className:"h-8 w-48"}),e.jsx(xs,{className:"h-40 w-full"})]})});if(!t)return e.jsx(Ts,{title:"My Team",description:"Your team",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Team Yet"}),e.jsx("p",{className:"text-muted-foreground",children:"You haven't been assigned to a team. Ask your brokerage manager to add you."})]})})});const o=t.team;return e.jsx(Ts,{title:"My Team",description:o.name,children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:o.name}),e.jsx(rt,{variant:t.role==="team_leader"?"default":"secondary",className:"capitalize",children:t.role==="team_leader"?e.jsxs(e.Fragment,{children:[e.jsx(Uh,{className:"mr-1 h-3 w-3"})," Leader"]}):"Member"})]}),o.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:o.description})]}),e.jsxs(ka,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(_a,{className:"flex-wrap",children:[e.jsx(js,{value:"members",children:"Members"}),o.contact_visibility!=="private"&&e.jsxs(js,{value:"contacts",children:[e.jsx(ok,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),o.lead_pond_enabled&&e.jsxs(js,{value:"lead-pond",children:[e.jsx(Vg,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),o.shared_assets_enabled&&e.jsxs(js,{value:"shared-assets",children:[e.jsx(Vh,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]})]}),e.jsx(zs,{value:"members",className:"space-y-2",children:a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(l=>e.jsx(xs,{className:"h-16 w-full"},l))}):n.map(l=>{var i,d,u,p;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsxs(xn,{className:"h-10 w-10",children:[e.jsx(Aa,{src:((i=l.profile)==null?void 0:i.avatar_url)||""}),e.jsx(yn,{children:(((d=l.profile)==null?void 0:d.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium",children:((u=l.profile)==null?void 0:u.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(p=l.profile)==null?void 0:p.email})]}),l.role==="team_leader"?e.jsxs(rt,{className:"ml-auto bg-amber-500/10 text-amber-600 border-amber-500",children:[e.jsx(Uh,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(rt,{variant:"secondary",className:"ml-auto",children:"Member"})]})},l.id)})}),o.contact_visibility!=="private"&&e.jsx(zs,{value:"contacts",className:"space-y-4",children:e.jsx(bwe,{})}),o.lead_pond_enabled&&e.jsx(zs,{value:"lead-pond",className:"space-y-4",children:e.jsx(wwe,{teamId:t.teamId})}),o.shared_assets_enabled&&e.jsx(zs,{value:"shared-assets",className:"space-y-4",children:e.jsx(RKe,{teamId:t.teamId})})]})]})})};function O1s(){const{user:t}=Hs(),s=rs(),r=wt({queryKey:["booking-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:k}=await G.from("agent_booking_settings").select("*").eq("user_id",t.id).maybeSingle();if(k)throw k;return j},enabled:!!t}),n=wt({queryKey:["booking-types",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:k}=await G.from("agent_booking_types").select("*").eq("user_id",t.id).order("sort_order");if(k)throw k;return j},enabled:!!t}),a=wt({queryKey:["availability-slots",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:k}=await G.from("agent_availability_slots").select("*").eq("user_id",t.id).order("day_of_week").order("start_time");if(k)throw k;return j},enabled:!!t}),o=wt({queryKey:["blocked-dates",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:k}=await G.from("agent_blocked_dates").select("*").eq("user_id",t.id).order("blocked_date");if(k)throw k;return j},enabled:!!t}),l=wt({queryKey:["bookings",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:k}=await G.from("bookings").select("*, booking_type:agent_booking_types(*)").eq("agent_user_id",t.id).order("booking_date",{ascending:!1});if(k)throw k;return j},enabled:!!t}),i=Dt({mutationFn:async()=>{const{data:j,error:k}=await G.from("agent_booking_settings").insert({user_id:t.id,slug:""}).select().single();if(k)throw k;const S=[{name:"Listing Consultation",description:"Get a comprehensive market analysis and listing strategy for your home",duration_minutes:60,color:"#10B981",icon:"Home",sort_order:0},{name:"Buyer Consultation",description:"Discuss your home search criteria, budget, and buying process",duration_minutes:45,color:"#3B82F6",icon:"Search",sort_order:1},{name:"Home Valuation",description:"Find out what your home is worth in today's market",duration_minutes:30,color:"#F59E0B",icon:"DollarSign",sort_order:2},{name:"General Meeting",description:"Coffee chat, check-in, or quick real estate question",duration_minutes:30,color:"#8B5CF6",icon:"Coffee",sort_order:3}],{error:T}=await G.from("agent_booking_types").insert(S.map(R=>({...R,user_id:t.id})));if(T)throw T;const I=[1,2,3,4,5].map(R=>({user_id:t.id,day_of_week:R,start_time:"09:00",end_time:"17:00"})),{error:L}=await G.from("agent_availability_slots").insert(I);if(L)throw L;return j},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),s.invalidateQueries({queryKey:["booking-types"]}),s.invalidateQueries({queryKey:["availability-slots"]}),fe.success("Scheduler set up successfully!")},onError:j=>fe.error(j.message)}),d=Dt({mutationFn:async j=>{const{error:k}=await G.from("agent_booking_settings").update(j).eq("user_id",t.id);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),fe.success("Settings updated")},onError:j=>fe.error(j.message)}),u=Dt({mutationFn:async j=>{const k={...j,user_id:t.id};if(j.id){const{error:S}=await G.from("agent_booking_types").update(k).eq("id",j.id);if(S)throw S}else{const{error:S}=await G.from("agent_booking_types").insert(k);if(S)throw S}},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),fe.success("Booking type saved")},onError:j=>fe.error(j.message)}),p=Dt({mutationFn:async j=>{const{error:k}=await G.from("agent_booking_types").delete().eq("id",j);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),fe.success("Booking type deleted")},onError:j=>fe.error(j.message)}),f=Dt({mutationFn:async j=>{const k={...j,user_id:t.id};if(j.id){const{error:S}=await G.from("agent_availability_slots").update(k).eq("id",j.id);if(S)throw S}else{const{error:S}=await G.from("agent_availability_slots").insert(k);if(S)throw S}},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:j=>fe.error(j.message)}),y=Dt({mutationFn:async j=>{const{error:k}=await G.from("agent_availability_slots").delete().eq("id",j);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:j=>fe.error(j.message)}),_=Dt({mutationFn:async j=>{const{error:k}=await G.from("agent_blocked_dates").insert({...j,user_id:t.id});if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]}),fe.success("Date blocked")},onError:j=>fe.error(j.message)}),b=Dt({mutationFn:async j=>{const{error:k}=await G.from("agent_blocked_dates").delete().eq("id",j);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]})},onError:j=>fe.error(j.message)}),w=Dt({mutationFn:async({id:j,reason:k})=>{const{error:S}=await G.from("bookings").update({status:"cancelled",cancelled_at:new Date().toISOString(),cancel_reason:k}).eq("id",j);if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["bookings"]}),fe.success("Booking cancelled")},onError:j=>fe.error(j.message)});return{settings:r.data,bookingTypes:n.data??[],availability:a.data??[],blockedDates:o.data??[],bookings:l.data??[],isLoading:r.isLoading,initializeSettings:i,updateSettings:d,upsertBookingType:u,deleteBookingType:p,upsertAvailability:f,deleteAvailability:y,addBlockedDate:_,removeBlockedDate:b,cancelBooking:w}}const CDe={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function R1s({types:t,onSave:s,onDelete:r}){const[n,a]=C.useState(null),[o,l]=C.useState(!1),i=()=>{a({name:"",description:"",duration_minutes:30,color:"#3B82F6",icon:"Calendar",is_active:!0,qualification_enabled:!1}),l(!0)},d=p=>{a({...p}),l(!0)},u=()=>{n!=null&&n.name&&(s(n),l(!1),a(null))};return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Booking Types"}),e.jsx(pr,{children:"The meeting types prospects can book with you"})]}),e.jsxs(K,{onClick:i,size:"sm",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Type"]})]}),e.jsx(Oe,{children:t.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No booking types yet. Add one to get started."}):e.jsx("div",{className:"grid gap-3",children:t.map(p=>e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-lg",style:{backgroundColor:p.color+"20"},children:CDe[p.icon]||"📅"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:p.name}),!p.is_active&&e.jsx(rt,{variant:"secondary",className:"text-xs",children:"Inactive"}),p.qualification_enabled&&e.jsxs(rt,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(NP,{className:"h-3 w-3"})," Qualifying"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Tn,{className:"h-3 w-3"}),p.duration_minutes," min",p.description&&e.jsxs("span",{children:["· ",p.description.slice(0,60),p.description.length>60?"...":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(p),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>r(p.id),className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})]})]},p.id))})})]}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsxs(ks,{children:[n!=null&&n.id?"Edit":"New"," Booking Type"]})}),n&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Name"}),e.jsx(Re,{value:n.name||"",onChange:p=>a({...n,name:p.target.value}),placeholder:"e.g. Listing Consultation"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Ar,{value:n.description||"",onChange:p=>a({...n,description:p.target.value}),placeholder:"Brief description for prospects",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Duration (minutes)"}),e.jsx(Re,{type:"number",min:15,max:180,step:15,value:n.duration_minutes||30,onChange:p=>a({...n,duration_minutes:parseInt(p.target.value)||30})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:n.color||"#3B82F6",onChange:p=>a({...n,color:p.target.value}),className:"h-10 w-10 rounded border cursor-pointer"}),e.jsx(Re,{value:n.color||"#3B82F6",onChange:p=>a({...n,color:p.target.value}),className:"flex-1"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Icon"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(CDe).map(([p,f])=>e.jsx("button",{onClick:()=>a({...n,icon:p}),className:`w-10 h-10 rounded-lg text-lg flex items-center justify-center border transition-colors ${n.icon===p?"border-primary bg-primary/10":"hover:bg-muted"}`,children:f},p))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Meeting Link Override (optional)"}),e.jsx(Re,{value:n.meeting_link_override||"",onChange:p=>a({...n,meeting_link_override:p.target.value||null}),placeholder:"Use a different link for this type"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Pre-Qualification Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask qualifying questions before booking"})]}),e.jsx(Br,{checked:n.qualification_enabled||!1,onCheckedChange:p=>a({...n,qualification_enabled:p})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ve,{children:"Active"}),e.jsx(Br,{checked:n.is_active??!0,onCheckedChange:p=>a({...n,is_active:p})})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:u,children:"Save"})]})]})})]})}const MDe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function F1s({slots:t,onSave:s,onDelete:r}){const[n,a]=C.useState(null),[o,l]=C.useState("09:00"),[i,d]=C.useState("17:00"),u=MDe.map((f,y)=>t.filter(_=>_.day_of_week===y)),p=()=>{n!==null&&(s({day_of_week:n,start_time:o,end_time:i,is_active:!0}),a(null),l("09:00"),d("17:00"))};return e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-5 w-5"}),"Weekly Availability"]}),e.jsx(pr,{children:"Set your available hours for each day"})]}),e.jsx(Oe,{className:"space-y-2",children:MDe.map((f,y)=>{const _=u[y];return e.jsxs("div",{className:"flex items-start gap-3 py-2 border-b last:border-0",children:[e.jsx("div",{className:"w-24 pt-1",children:e.jsx("p",{className:"text-sm font-medium",children:f})}),e.jsxs("div",{className:"flex-1 space-y-1",children:[_.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"Unavailable"}):_.map(b=>{var w,j;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(w=b.start_time)==null?void 0:w.slice(0,5),onBlur:k=>s({id:b.id,start_time:k.target.value})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(Re,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(j=b.end_time)==null?void 0:j.slice(0,5),onBlur:k=>s({id:b.id,end_time:k.target.value})}),e.jsx(Br,{checked:b.is_active,onCheckedChange:k=>s({id:b.id,is_active:k})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>r(b.id),children:e.jsx(jr,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},b.id)}),n===y?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{type:"time",className:"w-28 h-8 text-sm",value:o,onChange:b=>l(b.target.value)}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(Re,{type:"time",className:"w-28 h-8 text-sm",value:i,onChange:b=>d(b.target.value)}),e.jsx(K,{size:"sm",className:"h-8",onClick:p,children:"Add"}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8",onClick:()=>a(null),children:"Cancel"})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground",onClick:()=>a(y),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add hours"]})]})]},f)})})]})}const z1s={confirmed:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",cancelled:"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400",completed:"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400",no_show:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400"};function B1s({bookings:t,onCancel:s}){const r=t.filter(o=>o.status==="confirmed"&&new Date(o.booking_date)>=new Date(new Date().toDateString())),n=t.filter(o=>o.status!=="confirmed"||new Date(o.booking_date){var i,d;return e.jsxs("div",{className:"flex items-start justify-between p-4 rounded-lg border hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yi,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:o.guest_name}),e.jsx(rt,{className:`text-xs ${z1s[o.status]||""}`,children:o.status})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(id,{className:"h-3.5 w-3.5"}),ys(new Date(o.booking_date+"T00:00:00"),"MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3.5 w-3.5"}),(i=o.start_time)==null?void 0:i.slice(0,5)," - ",(d=o.end_time)==null?void 0:d.slice(0,5)]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[o.guest_email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(br,{className:"h-3 w-3"}),o.guest_email]}),o.guest_phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Qn,{className:"h-3 w-3"}),o.guest_phone]})]}),o.booking_type&&e.jsx(rt,{variant:"outline",className:"text-xs mt-1",children:o.booking_type.name}),o.guest_message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 italic",children:['"',o.guest_message,'"']})]}),l&&o.status==="confirmed"&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s(o.id),className:"text-destructive hover:text-destructive",children:[e.jsx(kc,{className:"h-4 w-4 mr-1"})," Cancel"]})]},o.id)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Upcoming Bookings"}),e.jsxs(pr,{children:[r.length," upcoming appointment",r.length!==1?"s":""]})]}),e.jsx(Oe,{children:r.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No upcoming bookings"}):e.jsx("div",{className:"space-y-3",children:r.map(o=>a(o,!0))})})]}),n.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Past & Cancelled"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:n.slice(0,20).map(o=>a(o))})})]})]})}function $1s({blockedDates:t,onAdd:s,onRemove:r}){const[n,a]=C.useState(!1),[o,l]=C.useState(""),[i,d]=C.useState(""),u=()=>{o&&(s({blocked_date:o,reason:i||void 0}),a(!1),l(""),d(""))};return e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(uP,{className:"h-5 w-5"}),"Blocked Dates"]}),e.jsx(pr,{children:"Block specific dates (vacations, holidays, etc.)"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>a(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Block Date"]})]}),e.jsxs(Oe,{children:[n&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 p-3 rounded-lg border bg-muted/30",children:[e.jsx(Re,{type:"date",value:o,onChange:p=>l(p.target.value),className:"w-40"}),e.jsx(Re,{placeholder:"Reason (optional)",value:i,onChange:p=>d(p.target.value),className:"flex-1"}),e.jsx(K,{size:"sm",onClick:u,children:"Add"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>a(!1),children:"Cancel"})]}),t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No blocked dates"}):e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(p=>e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full border bg-muted/50 text-sm",children:[e.jsx("span",{children:ys(new Date(p.blocked_date+"T00:00:00"),"MMM d, yyyy")}),p.reason&&e.jsxs("span",{className:"text-muted-foreground",children:["(",p.reason,")"]}),e.jsx("button",{onClick:()=>r(p.id),className:"ml-1 text-muted-foreground hover:text-destructive",children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]},p.id))})]})]})}function q1s(){const{settings:t,bookingTypes:s,availability:r,blockedDates:n,bookings:a,isLoading:o,initializeSettings:l,updateSettings:i,upsertBookingType:d,deleteBookingType:u,upsertAvailability:p,deleteAvailability:f,addBlockedDate:y,removeBlockedDate:_,cancelBooking:b}=O1s(),[w,j]=C.useState(""),[k,S]=C.useState(15);w||t!=null&&t.meeting_link;const T=t!=null&&t.slug?`https://booking.relevelup.com/${t.slug}`:null;return o?e.jsx(Ts,{children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):t?e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(id,{className:"h-6 w-6 text-primary"}),"LevelUp Scheduler"]}),e.jsx("p",{className:"text-muted-foreground",children:"Manage your booking types, availability, and appointments"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[T&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(T),fe.success("Booking link copied!")},children:[e.jsx(ai,{className:"h-4 w-4 mr-1"})," Copy Link"]}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:T,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(sn,{className:"h-4 w-4 mr-1"})," Preview"]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{htmlFor:"scheduler-active",className:"text-sm",children:"Active"}),e.jsx(Br,{id:"scheduler-active",checked:t.is_active,onCheckedChange:I=>i.mutate({is_active:I})})]})]})]}),e.jsxs(ka,{defaultValue:"types",className:"space-y-4",children:[e.jsxs(_a,{children:[e.jsx(js,{value:"types",children:"Booking Types"}),e.jsx(js,{value:"availability",children:"Availability"}),e.jsx(js,{value:"settings",children:"Settings"}),e.jsxs(js,{value:"bookings",children:["Bookings",a.filter(I=>I.status==="confirmed").length>0&&e.jsx(rt,{variant:"secondary",className:"ml-1.5 text-xs",children:a.filter(I=>I.status==="confirmed").length})]})]}),e.jsx(zs,{value:"types",children:e.jsx(R1s,{types:s,onSave:I=>d.mutate(I),onDelete:I=>u.mutate(I)})}),e.jsx(zs,{value:"availability",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(F1s,{slots:r,onSave:I=>p.mutate(I),onDelete:I=>f.mutate(I)}),e.jsx($1s,{blockedDates:n,onAdd:I=>y.mutate(I),onRemove:I=>_.mutate(I)})]})}),e.jsx(zs,{value:"settings",children:e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(RP,{className:"h-5 w-5"}),"General Settings"]}),e.jsx(pr,{children:"Configure your booking page defaults"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Booking Page URL"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{value:t.slug,readOnly:!0,className:"bg-muted"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>{T&&(navigator.clipboard.writeText(T),fe.success("Copied!"))},children:e.jsx(ai,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:T})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"meeting-link",children:[e.jsx(Wo,{className:"h-4 w-4 inline mr-1"}),"Default Meeting Link"]}),e.jsx(Re,{id:"meeting-link",placeholder:"https://zoom.us/j/your-personal-link",defaultValue:t.meeting_link||"",onBlur:I=>i.mutate({meeting_link:I.target.value||null})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your Zoom personal link, Google Meet, or phone number"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Buffer Between Meetings"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{type:"number",min:0,max:60,defaultValue:t.buffer_minutes,onBlur:I=>i.mutate({buffer_minutes:parseInt(I.target.value)||15})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"min"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Minimum Notice"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{type:"number",min:0,max:72,defaultValue:t.min_notice_hours,onBlur:I=>i.mutate({min_notice_hours:parseInt(I.target.value)||2})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"hours"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Max Advance Booking"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{type:"number",min:1,max:90,defaultValue:t.max_advance_days,onBlur:I=>i.mutate({max_advance_days:parseInt(I.target.value)||30})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"days"})]})]})]})]})]})}),e.jsx(zs,{value:"bookings",children:e.jsx(B1s,{bookings:a,onCancel:I=>b.mutate({id:I})})})]})]})}):e.jsx(Ts,{children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 md:p-8 space-y-8",children:[e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"mx-auto w-16 h-16 bg-primary/10 rounded-2xl flex items-center justify-center",children:e.jsx(id,{className:"h-8 w-8 text-primary"})}),e.jsx("h1",{className:"text-3xl font-bold",children:"LevelUp Scheduler"}),e.jsx("p",{className:"text-muted-foreground text-lg max-w-md mx-auto",children:"Your own booking page — built for real estate. Prospects book with you, get auto-added to your CRM, and you never miss a lead."})]}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6 space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[{icon:"🏠",title:"Listing Consultation",desc:"60 min"},{icon:"🔍",title:"Buyer Consultation",desc:"45 min"},{icon:"💰",title:"Home Valuation",desc:"30 min"},{icon:"☕",title:"General Meeting",desc:"30 min"}].map(I=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-muted/30",children:[e.jsx("span",{className:"text-2xl",children:I.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:I.desc})]})]},I.title))}),e.jsx(Rl,{}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:"✅ Auto-creates CRM contacts from every booking"}),e.jsx("p",{children:"✅ Optional pre-qualification questions per booking type"}),e.jsx("p",{children:"✅ Embeds on your Smart Card — replaces TidyCal"}),e.jsx("p",{children:"✅ Standalone shareable booking page"})]}),e.jsxs(K,{onClick:()=>l.mutate(),disabled:l.isPending,className:"w-full",size:"lg",children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),l.isPending?"Setting up...":"Activate Scheduler"]})]})})]})})}const TDe=[{id:"event_registration",label:"Event Registration",description:"Capture RSVPs for open houses, expos, seminars"},{id:"buyer_consultation",label:"Buyer Consultation",description:"Pre-qualify buyers with targeted questions"},{id:"home_valuation",label:"Home Valuation Request",description:`"What's your home worth?" lead capture`},{id:"lead_capture",label:"General Lead Capture",description:"Flexible form for any lead gen purpose"},{id:"lead_magnet",label:"Lead Magnet / Giveaway",description:"Offer a free download (PDF, guide, checklist) in exchange for contact info"},{id:"just_listed",label:"Just Listed",description:"Showcase a new listing with photos & details + contact CTA"},{id:"just_sold",label:"Just Sold",description:'Celebrate a sale & capture "Want results like this?" leads'}];function U1s(){const{user:t}=Hs(),s=Ya(),{toast:r}=Pa(),n=Pr(),a=rs(),[o,l]=C.useState(!1),[i,d]=C.useState(null),[u,p]=C.useState(null),[f,y]=C.useState({title:"",description:"",page_type:"lead_capture"}),{data:_=[],isLoading:b}=wt({queryKey:["landing-pages",s],queryFn:async()=>{const{data:S,error:T}=await G.from("landing_pages").select("*").eq("user_id",s).order("created_at",{ascending:!1});if(T)throw T;return S},enabled:!!s}),w=Dt({mutationFn:async()=>{const S=f.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"")+"-"+Date.now().toString(36),{data:T}=await G.from("profiles").select("name, phone, avatar_url, email").eq("id",s).single(),I=f.page_type==="just_listed"||f.page_type==="just_sold",{data:L,error:R}=await G.from("landing_pages").insert({user_id:s,title:f.title,description:f.description||null,page_type:f.page_type,slug:S,hero_headline:I?f.page_type==="just_listed"?"🏡 Just Listed":"🎉 Just Sold":f.page_type==="lead_magnet"?"📥 Free Download":f.title,agent_name:(T==null?void 0:T.name)||null,agent_phone:(T==null?void 0:T.phone)||null,agent_email:(T==null?void 0:T.email)||t.email||null,agent_photo_url:(T==null?void 0:T.avatar_url)||null,property_status:I?f.page_type.replace("just_",""):null}).select().single();if(R)throw R;const $=V1s(f.page_type);if($.length>0){const{error:q}=await G.from("landing_page_fields").insert($.map((U,H)=>({...U,page_id:L.id,sort_order:H})));if(q)throw q}return L},onSuccess:S=>{a.invalidateQueries({queryKey:["landing-pages"]}),l(!1),y({title:"",description:"",page_type:"lead_capture"}),r({title:"Landing page created!"}),n(`/mission-control/landing-pages/${S.id}`)},onError:S=>r({title:"Error",description:S.message,variant:"destructive"})}),j=Dt({mutationFn:async S=>{const{error:T}=await G.from("landing_pages").delete().eq("id",S);if(T)throw T},onSuccess:()=>{a.invalidateQueries({queryKey:["landing-pages"]}),d(null),r({title:"Landing page deleted"})}}),k=S=>`https://pages.relevelup.com/${S}`;return e.jsxs(Ts,{title:"Landing Pages",children:[e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Landing Pages"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Create branded lead capture pages for events, consultations, and more"})]}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," New Page"]})]}),b?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):_.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(In,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No landing pages yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1 mb-4",children:"Create your first page to start capturing leads"}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," Create Landing Page"]})]})}):e.jsx("div",{className:"grid gap-4",children:_.map(S=>{var T;return e.jsx(Ee,{className:"hover:shadow-md transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>n(`/mission-control/landing-pages/${S.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold truncate",children:S.title}),e.jsx(rt,{variant:S.is_published?"default":"secondary",className:"text-[10px]",children:S.is_published?"Published":"Draft"}),e.jsx(rt,{variant:"outline",className:"text-[10px]",children:((T=TDe.find(I=>I.id===S.page_type))==null?void 0:T.label)||S.page_type})]}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:S.description}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xa,{className:"h-3 w-3"})," ",S.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-3 w-3"})," ",S.submission_count," submissions"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[S.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>p(k(S.slug)),children:e.jsx(B0,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(k(S.slug)),r({title:"Link copied!"})},children:e.jsx(ai,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:k(S.slug),target:"_blank",rel:"noopener noreferrer",children:e.jsx(sn,{className:"h-3.5 w-3.5"})})})]}),e.jsxs(Kd,{children:[e.jsx(Zd,{asChild:!0,children:e.jsx(K,{size:"sm",variant:"ghost",children:e.jsx(af,{className:"h-4 w-4"})})}),e.jsxs(Md,{align:"end",children:[e.jsxs(Na,{onClick:()=>n(`/mission-control/landing-pages/${S.id}`),children:[e.jsx(Da,{className:"h-3.5 w-3.5 mr-2"})," Edit"]}),e.jsxs(Na,{onClick:()=>d(S.id),className:"text-destructive",children:[e.jsx(jr,{className:"h-3.5 w-3.5 mr-2"})," Delete"]})]})]})]})]})})},S.id)})})]}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{children:[e.jsx(Ss,{children:e.jsx(ks,{children:"Create Landing Page"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Page Title"}),e.jsx(Re,{value:f.title,onChange:S=>y(T=>({...T,title:S.target.value})),placeholder:"e.g. Veterans Home & Land Expo"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description (optional)"}),e.jsx(Ar,{value:f.description,onChange:S=>y(T=>({...T,description:S.target.value})),placeholder:"Brief internal description...",rows:2})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Page Template"}),e.jsxs(sr,{value:f.page_type,onValueChange:S=>y(T=>({...T,page_type:S})),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:TDe.map(S=>e.jsx(At,{value:S.id,children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:S.label}),e.jsx("div",{className:"text-xs text-muted-foreground",children:S.description})]})},S.id))})]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>w.mutate(),disabled:!f.title.trim()||w.isPending,children:w.isPending?"Creating...":"Create Page"})]})]})}),e.jsx(nc,{open:!!i,onOpenChange:()=>d(null),children:e.jsxs(El,{children:[e.jsxs(Pl,{children:[e.jsx(Ll,{children:"Delete Landing Page?"}),e.jsx(Dl,{children:"This will permanently delete this page and all its submissions."})]}),e.jsxs(Il,{children:[e.jsx(Ol,{children:"Cancel"}),e.jsx(xl,{onClick:()=>i&&j.mutate(i),children:"Delete"})]})]})}),e.jsx(_s,{open:!!u,onOpenChange:()=>p(null),children:e.jsxs(vs,{className:"max-w-sm",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[u&&e.jsx(yD,{value:u,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:u}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{u&&(navigator.clipboard.writeText(u),r({title:"URL copied!"}))},children:[e.jsx(ai,{className:"h-3.5 w-3.5 mr-1"})," Copy URL"]})]})]})})]})}function V1s(t){const s=[{field_type:"text",label:"Full Name",placeholder:"Your name",is_required:!0},{field_type:"email",label:"Email",placeholder:"your@email.com",is_required:!0},{field_type:"phone",label:"Phone",placeholder:"(555) 123-4567",is_required:!1}];switch(t){case"event_registration":return[...s,{field_type:"select",label:"How did you hear about this event?",options:JSON.stringify(["Social Media","Friend/Referral","Email","Flyer/Sign","Other"]),is_required:!1},{field_type:"textarea",label:"Any questions or special needs?",placeholder:"Let us know...",is_required:!1}];case"buyer_consultation":return[...s,{field_type:"select",label:"Interested in",options:JSON.stringify(["Buying","Selling","Both"]),is_required:!0},{field_type:"select",label:"Timeline",options:JSON.stringify(["0-3 months","3-6 months","6-12 months","Just exploring"]),is_required:!1},{field_type:"toggle",label:"Already working with a Realtor?",is_required:!1},{field_type:"toggle",label:"Do you have property to sell?",is_required:!1},{field_type:"textarea",label:"Anything else we should know?",placeholder:"Tell us about your situation...",is_required:!1}];case"home_valuation":return[...s,{field_type:"text",label:"Property Address",placeholder:"123 Main St, City, State",is_required:!0},{field_type:"select",label:"Reason for Valuation",options:JSON.stringify(["Thinking of selling","Refinancing","Curiosity","Estate planning","Other"]),is_required:!1},{field_type:"select",label:"Timeline to Sell",options:JSON.stringify(["ASAP","1-3 months","3-6 months","6+ months","Not sure"]),is_required:!1}];case"lead_magnet":return[...s,{field_type:"select",label:"Are you currently working with a Realtor?",options:JSON.stringify(["Yes","No","Not yet"]),is_required:!1}];case"just_listed":return[...s,{field_type:"select",label:"I am interested in",options:JSON.stringify(["Scheduling a showing","Getting more details","Similar properties","Selling my home"]),is_required:!0},{field_type:"textarea",label:"Message",placeholder:"Tell me more about this property...",is_required:!1}];case"just_sold":return[...s,{field_type:"select",label:"I am looking to",options:JSON.stringify(["Sell my home","Buy a home","Both","Just curious"]),is_required:!0},{field_type:"text",label:"My Property Address",placeholder:"123 Main St, City, State",is_required:!1}];default:return[...s,{field_type:"textarea",label:"Message",placeholder:"How can we help you?",is_required:!1}]}}const H1s=[{value:"text",label:"Short Text"},{value:"email",label:"Email"},{value:"phone",label:"Phone"},{value:"textarea",label:"Long Text"},{value:"select",label:"Dropdown"},{value:"multiselect",label:"Multi-Select"},{value:"toggle",label:"Yes / No Toggle"}];function W1s(){const{pageId:t}=ko(),s=Pr(),{user:r}=Hs(),n=Ya(),{toast:a}=Pa(),o=rs(),[l,i]=C.useState(null),[d,u]=C.useState(!1),{data:p,isLoading:f}=wt({queryKey:["landing-page",t],queryFn:async()=>{const{data:re,error:ae}=await G.from("landing_pages").select("*").eq("id",t).single();if(ae)throw ae;return re},enabled:!!t}),{data:y=[],isLoading:_}=wt({queryKey:["landing-page-fields",t],queryFn:async()=>{const{data:re,error:ae}=await G.from("landing_page_fields").select("*").eq("page_id",t).order("sort_order");if(ae)throw ae;return re},enabled:!!t}),{data:b=[]}=wt({queryKey:["landing-page-submissions",t],queryFn:async()=>{const{data:re,error:ae}=await G.from("landing_page_submissions").select("*").eq("page_id",t).order("created_at",{ascending:!1});if(ae)throw ae;return re},enabled:!!t}),{data:w=[]}=wt({queryKey:["my-listings-for-pages",n],queryFn:async()=>{const{data:re,error:ae}=await G.from("listings").select("id, property_address, city, state, price, bedrooms, bathrooms, square_footage, description, status").eq("agent_id",n).order("created_at",{ascending:!1});if(ae)throw ae;return re},enabled:!!r&&((p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold")}),[j,k]=C.useState({title:"",hero_headline:"",hero_subtext:"",hero_image_url:null,logo_url:null,primary_color:"#406E71",accent_color:"#2a4c64",agent_name:"",agent_phone:"",agent_email:"",agent_photo_url:null,success_message:"Thank you! We'll be in touch soon.",is_published:!1,description:"",lead_magnet_file_url:null,lead_magnet_file_name:null,lead_magnet_external_url:null,listing_id:null,property_address:"",property_price:"",property_beds:"",property_baths:"",property_sqft:"",property_description:"",property_photos:[],property_status:"just_listed"}),[S,T]=C.useState([]);C.useEffect(()=>{p&&k({title:p.title,hero_headline:p.hero_headline,hero_subtext:p.hero_subtext||"",hero_image_url:p.hero_image_url,logo_url:p.logo_url,primary_color:p.primary_color,accent_color:p.accent_color,agent_name:p.agent_name||"",agent_phone:p.agent_phone||"",agent_email:p.agent_email||"",agent_photo_url:p.agent_photo_url,success_message:p.success_message||"Thank you! We'll be in touch soon.",is_published:p.is_published,description:p.description||"",lead_magnet_file_url:p.lead_magnet_file_url||null,lead_magnet_file_name:p.lead_magnet_file_name||null,lead_magnet_external_url:p.lead_magnet_external_url||null,listing_id:p.listing_id||null,property_address:p.property_address||"",property_price:p.property_price||"",property_beds:p.property_beds||"",property_baths:p.property_baths||"",property_sqft:p.property_sqft||"",property_description:p.property_description||"",property_photos:Array.isArray(p.property_photos)?p.property_photos:[],property_status:p.property_status||"just_listed"})},[p]),C.useEffect(()=>{y.length>0&&T(y.map(re=>({id:re.id,field_type:re.field_type,label:re.label,placeholder:re.placeholder,is_required:re.is_required,options:typeof re.options=="string"?re.options:re.options?JSON.stringify(re.options):null,sort_order:re.sort_order})))},[y]);const I=Dt({mutationFn:async()=>{const{error:re}=await G.from("landing_pages").update({title:j.title,hero_headline:j.hero_headline,hero_subtext:j.hero_subtext||null,hero_image_url:j.hero_image_url,logo_url:j.logo_url,primary_color:j.primary_color,accent_color:j.accent_color,agent_name:j.agent_name||null,agent_phone:j.agent_phone||null,agent_email:j.agent_email||null,agent_photo_url:j.agent_photo_url,success_message:j.success_message,is_published:j.is_published,description:j.description||null,lead_magnet_file_url:j.lead_magnet_file_url,lead_magnet_file_name:j.lead_magnet_file_name,lead_magnet_external_url:j.lead_magnet_external_url,listing_id:j.listing_id,property_address:j.property_address||null,property_price:j.property_price||null,property_beds:j.property_beds||null,property_baths:j.property_baths||null,property_sqft:j.property_sqft||null,property_description:j.property_description||null,property_photos:j.property_photos,property_status:j.property_status,updated_at:new Date().toISOString()}).eq("id",t);if(re)throw re;if(await G.from("landing_page_fields").delete().eq("page_id",t),S.length>0){const{error:ae}=await G.from("landing_page_fields").insert(S.map((le,he)=>({page_id:t,field_type:le.field_type,label:le.label,placeholder:le.placeholder||null,is_required:le.is_required,options:le.options?JSON.parse(le.options):null,sort_order:he})));if(ae)throw ae}},onSuccess:()=>{o.invalidateQueries({queryKey:["landing-page",t]}),o.invalidateQueries({queryKey:["landing-page-fields",t]}),a({title:"Page saved!"})},onError:re=>a({title:"Error",description:re.message,variant:"destructive"})}),L=async(re,ae)=>{const le=re.name.split(".").pop(),he=`landing-pages/${r.id}/${ae}-${Date.now()}.${le}`,{error:be}=await G.storage.from("recruit-landing").upload(he,re);if(be)throw be;const{data:{publicUrl:_e}}=G.storage.from("recruit-landing").getPublicUrl(he);return _e},R=async(re,ae)=>{var he;const le=(he=re.target.files)==null?void 0:he[0];if(le){i(ae);try{const be=await L(le,ae);k(_e=>({..._e,[ae]:be})),a({title:"Image uploaded!"})}catch(be){a({title:"Upload failed",description:be.message,variant:"destructive"})}finally{i(null)}}},$=async re=>{var le;const ae=(le=re.target.files)==null?void 0:le[0];if(ae){i("lead_magnet");try{const he=await L(ae,"lead-magnet");k(be=>({...be,lead_magnet_file_url:he,lead_magnet_file_name:ae.name})),a({title:"File uploaded!"})}catch(he){a({title:"Upload failed",description:he.message,variant:"destructive"})}finally{i(null)}}},q=async re=>{const ae=re.target.files;if(!(!ae||ae.length===0)){i("property_photos");try{const le=[];for(const he of Array.from(ae)){const be=await L(he,"property-photo");le.push(be)}k(he=>({...he,property_photos:[...he.property_photos,...le]})),a({title:`${le.length} photo(s) uploaded!`})}catch(le){a({title:"Upload failed",description:le.message,variant:"destructive"})}finally{i(null)}}},U=async re=>{const ae=w.find(he=>he.id===re);if(!ae)return;const{data:le}=await G.from("listing_photos").select("photo_url").eq("listing_id",re).order("sort_order");k(he=>({...he,listing_id:re,property_address:ae.property_address||`${ae.city}, ${ae.state}`,property_price:ae.price?`$${ae.price.toLocaleString()}`:"",property_beds:ae.bedrooms?String(ae.bedrooms):"",property_baths:ae.bathrooms?String(ae.bathrooms):"",property_sqft:ae.square_footage?ae.square_footage.toLocaleString():"",property_description:ae.description||"",property_photos:(le==null?void 0:le.map(be=>be.photo_url))||he.property_photos})),a({title:"Listing data imported!"})},H=()=>{T(re=>[...re,{field_type:"text",label:"",placeholder:"",is_required:!1,options:null,sort_order:re.length}])},Y=(re,ae)=>{T(le=>le.map((he,be)=>be===re?{...he,...ae}:he))},se=re=>{T(ae=>ae.filter((le,he)=>he!==re))},te=p?`https://pages.relevelup.com/${p.slug}`:"",Q=(p==null?void 0:p.page_type)==="lead_magnet",de=(p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold";return f||_?e.jsx(Ts,{title:"Loading...",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):p?e.jsxs(Ts,{title:j.title||"Edit Page",children:[e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/landing-pages"),children:e.jsx(ti,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:j.title||"Untitled Page"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx(rt,{variant:j.is_published?"default":"secondary",className:"text-[10px]",children:j.is_published?"Published":"Draft"}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(xa,{className:"h-3 w-3"})," ",p.view_count," views"]}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(hr,{className:"h-3 w-3"})," ",b.length," submissions"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[j.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>u(!0),children:e.jsx(B0,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(te),a({title:"Link copied!"})},children:[e.jsx(ai,{className:"h-3.5 w-3.5 mr-1"})," Copy Link"]}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:te,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(sn,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(K,{onClick:()=>I.mutate(),disabled:I.isPending,children:[e.jsx(fu,{className:"h-4 w-4 mr-2"}),I.isPending?"Saving...":"Save"]})]})]}),e.jsxs(ka,{defaultValue:"design",children:[e.jsxs(_a,{children:[e.jsx(js,{value:"design",children:"Design"}),Q&&e.jsx(js,{value:"lead_magnet",children:"Lead Magnet"}),de&&e.jsx(js,{value:"property",children:"Property Details"}),e.jsxs(js,{value:"fields",children:["Form Fields (",S.length,")"]}),e.jsxs(js,{value:"submissions",children:["Submissions (",b.length,")"]}),e.jsx(js,{value:"settings",children:"Settings"})]}),e.jsxs(zs,{value:"design",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Page Details"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Page Title (internal)"}),e.jsx(Re,{value:j.title,onChange:re=>k(ae=>({...ae,title:re.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description (internal)"}),e.jsx(Re,{value:j.description,onChange:re=>k(ae=>({...ae,description:re.target.value}))})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Hero Section"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Headline"}),e.jsx(Re,{value:j.hero_headline,onChange:re=>k(ae=>({...ae,hero_headline:re.target.value})),placeholder:"Join us for..."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Subtext"}),e.jsx(Ar,{value:j.hero_subtext,onChange:re=>k(ae=>({...ae,hero_subtext:re.target.value})),rows:2,placeholder:"A brief description..."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Background Image"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[j.hero_image_url&&e.jsx("img",{src:j.hero_image_url,alt:"Hero",className:"h-16 w-28 object-cover rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(Za,{className:"h-3.5 w-3.5 mr-1"}),l==="hero_image_url"?"Uploading...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:re=>R(re,"hero_image_url")})]}),j.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k(re=>({...re,hero_image_url:null})),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Branding"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Logo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[j.logo_url&&e.jsx("img",{src:j.logo_url,alt:"Logo",className:"h-10 w-auto rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="logo_url",children:e.jsxs("span",{children:[e.jsx(Za,{className:"h-3.5 w-3.5 mr-1"}),l==="logo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:re=>R(re,"logo_url")})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[j.agent_photo_url&&e.jsx("img",{src:j.agent_photo_url,alt:"Agent",className:"h-10 w-10 rounded-full object-cover"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="agent_photo_url",children:e.jsxs("span",{children:[e.jsx(Za,{className:"h-3.5 w-3.5 mr-1"}),l==="agent_photo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:re=>R(re,"agent_photo_url")})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:j.primary_color,onChange:re=>k(ae=>({...ae,primary_color:re.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Re,{value:j.primary_color,onChange:re=>k(ae=>({...ae,primary_color:re.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:j.accent_color,onChange:re=>k(ae=>({...ae,accent_color:re.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Re,{value:j.accent_color,onChange:re=>k(ae=>({...ae,accent_color:re.target.value})),className:"font-mono text-xs"})]})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Agent Info (shown on page)"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Name"}),e.jsx(Re,{value:j.agent_name,onChange:re=>k(ae=>({...ae,agent_name:re.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Phone"}),e.jsx(Re,{value:j.agent_phone,onChange:re=>k(ae=>({...ae,agent_phone:re.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Email"}),e.jsx(Re,{value:j.agent_email,onChange:re=>k(ae=>({...ae,agent_email:re.target.value}))})]})]})})]})]}),Q&&e.jsx(zs,{value:"lead_magnet",className:"space-y-4 mt-4",children:e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(xi,{className:"h-4 w-4"})," Giveaway File"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload a file or provide an external URL. Visitors will receive the download link after submitting the form."}),e.jsxs("div",{children:[e.jsx(ve,{children:"Upload File (PDF, guide, checklist, etc.)"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[j.lead_magnet_file_name&&e.jsxs(rt,{variant:"outline",className:"gap-1",children:[e.jsx(xi,{className:"h-3 w-3"})," ",j.lead_magnet_file_name]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="lead_magnet",children:e.jsxs("span",{children:[e.jsx(Za,{className:"h-3.5 w-3.5 mr-1"}),l==="lead_magnet"?"Uploading...":"Upload File"]})}),e.jsx("input",{type:"file",className:"hidden",onChange:$})]}),j.lead_magnet_file_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k(re=>({...re,lead_magnet_file_url:null,lead_magnet_file_name:null})),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("div",{className:"flex-1 border-t"}),e.jsx("span",{children:"OR"}),e.jsx("div",{className:"flex-1 border-t"})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1",children:[e.jsx(Wo,{className:"h-3.5 w-3.5"})," External URL"]}),e.jsx(Re,{value:j.lead_magnet_external_url||"",onChange:re=>k(ae=>({...ae,lead_magnet_external_url:re.target.value||null})),placeholder:"https://drive.google.com/... or https://dropbox.com/...",className:"mt-1"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Link to a file on Google Drive, Dropbox, or any URL"})]})]})]})}),de&&e.jsxs(zs,{value:"property",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(On,{className:"h-4 w-4"})," Import from Listing Exchange"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pull property details and photos directly from one of your listings, or enter them manually below."}),e.jsxs(sr,{value:j.listing_id||"",onValueChange:re=>U(re),children:[e.jsx(er,{children:e.jsx(rr,{placeholder:"Select a listing to import..."})}),e.jsx(tr,{children:w.map(re=>{var ae;return e.jsxs(At,{value:re.id,children:[re.property_address||`${re.city}, ${re.state}`," — $",(ae=re.price)==null?void 0:ae.toLocaleString()]},re.id)})})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Property Information"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Property Address"}),e.jsx(Re,{value:j.property_address,onChange:re=>k(ae=>({...ae,property_address:re.target.value})),placeholder:"123 Main St, City, State"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Price"}),e.jsx(Re,{value:j.property_price,onChange:re=>k(ae=>({...ae,property_price:re.target.value})),placeholder:"$450,000"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Beds"}),e.jsx(Re,{value:j.property_beds,onChange:re=>k(ae=>({...ae,property_beds:re.target.value})),placeholder:"4"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Baths"}),e.jsx(Re,{value:j.property_baths,onChange:re=>k(ae=>({...ae,property_baths:re.target.value})),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Sq Ft"}),e.jsx(Re,{value:j.property_sqft,onChange:re=>k(ae=>({...ae,property_sqft:re.target.value})),placeholder:"2,400"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Ar,{value:j.property_description,onChange:re=>k(ae=>({...ae,property_description:re.target.value})),rows:3,placeholder:"Beautiful home in a great neighborhood..."})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Property Photos"})}),e.jsxs(Oe,{className:"space-y-4",children:[j.property_photos.length>0&&e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:j.property_photos.map((re,ae)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:re,alt:`Property ${ae+1}`,className:"h-24 w-full object-cover rounded"}),e.jsx(K,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>k(le=>({...le,property_photos:le.property_photos.filter((he,be)=>be!==ae)})),children:e.jsx(jr,{className:"h-3 w-3"})})]},ae))}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="property_photos",children:e.jsxs("span",{children:[e.jsx(Za,{className:"h-3.5 w-3.5 mr-1"}),l==="property_photos"?"Uploading...":"Add Photos"]})}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:q})]})]})]})]}),e.jsxs(zs,{value:"fields",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure the form fields visitors will fill out"}),e.jsxs(K,{size:"sm",onClick:H,children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Add Field"]})]}),S.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No fields yet. Add fields to build your form."})}):e.jsx("div",{className:"space-y-3",children:S.map((re,ae)=>e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Bu,{className:"h-4 w-4 mt-2 text-muted-foreground cursor-grab"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Field Type"}),e.jsxs(sr,{value:re.field_type,onValueChange:le=>Y(ae,{field_type:le}),children:[e.jsx(er,{children:e.jsx(rr,{})}),e.jsx(tr,{children:H1s.map(le=>e.jsx(At,{value:le.value,children:le.label},le.value))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Label"}),e.jsx(Re,{value:re.label,onChange:le=>Y(ae,{label:le.target.value}),placeholder:"e.g. Full Name"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Placeholder"}),e.jsx(Re,{value:re.placeholder||"",onChange:le=>Y(ae,{placeholder:le.target.value}),placeholder:"Optional hint text"})]})]}),(re.field_type==="select"||re.field_type==="multiselect")&&e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Options (comma-separated)"}),e.jsx(Re,{value:re.options?(typeof re.options=="string"?JSON.parse(re.options):re.options).join(", "):"",onChange:le=>Y(ae,{options:JSON.stringify(le.target.value.split(",").map(he=>he.trim()).filter(Boolean))}),placeholder:"Option 1, Option 2, Option 3"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{checked:re.is_required,onCheckedChange:le=>Y(ae,{is_required:le})}),e.jsx(ve,{className:"text-xs",children:"Required"})]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>se(ae),children:e.jsx(jr,{className:"h-3.5 w-3.5 text-destructive"})})]})})},ae))})]}),e.jsx(zs,{value:"submissions",className:"mt-4",children:b.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12 text-center text-muted-foreground",children:"No submissions yet. Share your page to start collecting leads!"})}):e.jsx("div",{className:"space-y-3",children:b.map(re=>e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:re.contact_name||"Anonymous"}),re.synced_to_crm&&e.jsx(rt,{variant:"outline",className:"text-[10px]",children:"Synced"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground mt-0.5",children:[re.contact_email&&e.jsx("span",{className:"mr-3",children:re.contact_email}),re.contact_phone&&e.jsx("span",{children:re.contact_phone})]}),re.answers&&typeof re.answers=="object"&&e.jsx("div",{className:"mt-2 text-sm space-y-1",children:Object.entries(re.answers).map(([ae,le])=>e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-muted-foreground",children:[ae,":"]})," ",e.jsx("span",{children:String(le)})]},ae))})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(re.created_at).toLocaleDateString()})]})})},re.id))})}),e.jsxs(zs,{value:"settings",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Publishing"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this page publicly accessible"})]}),e.jsx(Br,{checked:j.is_published,onCheckedChange:re=>k(ae=>({...ae,is_published:re}))})]}),j.is_published&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Public URL:"}),e.jsx("code",{className:"text-xs ml-2 break-all",children:te})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Thank You Message"})}),e.jsx(Oe,{children:e.jsx(Ar,{value:j.success_message,onChange:re=>k(ae=>({...ae,success_message:re.target.value})),rows:2,placeholder:"Message shown after form submission"})})]})]})]})]}),e.jsx(_s,{open:d,onOpenChange:u,children:e.jsxs(vs,{className:"max-w-sm",children:[e.jsx(Ss,{children:e.jsx(ks,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx(yD,{value:te,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:te})]})]})})]}):e.jsx(Ts,{title:"Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Page not found"}),e.jsx(K,{variant:"link",onClick:()=>s("/mission-control/landing-pages"),children:"Go back"})]})})}function ADe({value:t}){return t>0?e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-emerald-600 dark:text-emerald-400",children:[e.jsx(aP,{className:"h-3 w-3"}),t,"%"]}):t<0?e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-red-600 dark:text-red-400",children:[e.jsx(nP,{className:"h-3 w-3"}),Math.abs(t),"%"]}):e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[e.jsx(F0,{className:"h-3 w-3"}),"0%"]})}const G1s={Phone:Qn,MessageSquare:io,Mail:br,Gift:po,PenTool:d_,Video:Nn},EDe=["bg-primary","bg-emerald-500","bg-amber-500","bg-sky-500","bg-purple-500","bg-orange-500","bg-pink-500","bg-teal-500"];function K1s(){const t=Pr(),{contactsWithScores:s,stats:r}=fle(),{data:n}=VL(365),{data:a}=vbe(),{data:o}=UL(),l=gbe(),i=C.useMemo(()=>{if(!n)return{touchesThisMonth:0,touchesLastMonth:0,touchTrend:0};const T=new Date,I=pc(T),L=ef(T),R=pc(LN(T,1)),$=ef(LN(T,1)),q=n.filter(Y=>Mg(new Date(Y.completed_at),{start:I,end:L})).length,U=n.filter(Y=>Mg(new Date(Y.completed_at),{start:R,end:$})).length,H=U>0?Math.round((q-U)/U*100):q>0?100:0;return{touchesThisMonth:q,touchesLastMonth:U,touchTrend:H}},[n]),d=C.useMemo(()=>{if(!n)return 0;const T=new Date,I=pc(T),L=ef(T);return new Set(n.filter(R=>Mg(new Date(R.completed_at),{start:I,end:L})).map(R=>R.contact_id)).size},[n]),u=C.useMemo(()=>{if(!a)return{closedThisMonth:0,totalGCI:0};const T=new Date,I=pc(T),L=ef(T),R=a.filter($=>$.close_date&&Mg(gl($.close_date),{start:I,end:L}));return{closedThisMonth:R.length,totalGCI:R.reduce(($,q)=>$+(Number(q.commission_amount)||0),0)}},[a]),p=C.useMemo(()=>{if(!s.length)return{newThisMonth:0,newLastMonth:0,trend:0};const T=new Date,I=pc(T),L=pc(LN(T,1)),R=ef(LN(T,1)),$=s.filter(H=>new Date(H.created_at)>=I).length,q=s.filter(H=>Mg(new Date(H.created_at),{start:L,end:R})).length,U=q>0?Math.round(($-q)/q*100):$>0?100:0;return{newThisMonth:$,newLastMonth:q,trend:U}},[s]),f=C.useMemo(()=>{if(!n||!o)return[];const T=new Date,I=pc(T),L=ef(T),R=n.filter(U=>Mg(new Date(U.completed_at),{start:I,end:L})),$={};R.forEach(U=>{const H=U.action_type_id;$[H]=($[H]||0)+1});const q=R.length||1;return o.filter(U=>$[U.id]).map(U=>({id:U.id,name:U.name,icon:U.icon,count:$[U.id]||0,percent:Math.round(($[U.id]||0)/q*100)})).sort((U,H)=>H.count-U.count)},[n,o]),y=C.useMemo(()=>[...s].filter(T=>T.relationshipScore.status==="at-risk"||T.relationshipScore.status==="cooling").sort((T,I)=>{const L=T.relationshipScore.daysSinceTouch??9999;return(I.relationshipScore.daysSinceTouch??9999)-L}).slice(0,5),[s]),_=C.useMemo(()=>{if(!n)return[];const T=new Date,I=pc(T),L=ef(T),R=new Set(n.filter($=>Mg(new Date($.completed_at),{start:I,end:L})).map($=>$.contact_id));return s.filter($=>$.relationshipScore.status==="warm"&&R.has($.id)&&$.relationshipScore.touchCountLast12Months>=2).sort(($,q)=>q.relationshipScore.score-$.relationshipScore.score).slice(0,5)},[s,n]),b=C.useMemo(()=>{if(!n)return{currentStreak:0,longestStreak:0};const T=new Set(n.map(H=>{const Y=new Date(H.completed_at);return`${Y.getFullYear()}-${Y.getMonth()}-${Y.getDate()}`})),I=new Date;I.setHours(0,0,0,0);let L=0,R=new Date(I);for(;T.has(`${R.getFullYear()}-${R.getMonth()}-${R.getDate()}`);)L++,R.setDate(R.getDate()-1);let $=0,q=0;if(Array.from(T).sort().length>0){const H=n.map(Y=>{const se=new Date(Y.completed_at);return se.setHours(0,0,0,0),se.getTime()}).filter((Y,se,te)=>te.indexOf(Y)===se).sort((Y,se)=>Y-se);q=1;for(let Y=1;Y[...s].sort((T,I)=>T.relationshipScore.score-I.relationshipScore.score),[s]),j=w.filter(T=>T.relationshipScore.status==="warm"),k=w.filter(T=>T.relationshipScore.status==="cooling"),S=w.filter(T=>T.relationshipScore.status==="at-risk");return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Relationship Scorecard"}),e.jsxs("p",{className:"text-muted-foreground",children:[ys(new Date,"MMMM yyyy")," — Your monthly relationship health report"]})]}),b.currentStreak>0&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-full bg-orange-500/10 border border-orange-500/20",children:[e.jsx(nh,{className:"h-5 w-5 text-orange-500"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-orange-600 dark:text-orange-400",children:b.currentStreak}),e.jsx("span",{className:"text-sm text-muted-foreground ml-1",children:"day streak"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Si,{className:"h-4 w-4"}),"Avg Score"]}),e.jsx("div",{className:"text-3xl font-bold",children:r.averageScore}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"out of 100"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Pm,{className:"h-4 w-4"}),"Touches"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-3xl font-bold",children:i.touchesThisMonth}),e.jsx(ADe,{value:i.touchTrend})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["vs ",i.touchesLastMonth," last month"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),"Reached"]}),e.jsx("div",{className:"text-3xl font-bold",children:d}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["of ",r.total," contacts"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(ac,{className:"h-4 w-4"}),"New Contacts"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-3xl font-bold",children:p.newThisMonth}),e.jsx(ADe,{value:p.trend})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"added this month"})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Gh,{className:"h-4 w-4 text-primary"}),"Weekly Goal"]})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[l.actionsThisWeek," of ",l.weeklyGoal," touches"]}),e.jsxs("span",{className:"text-sm font-medium",children:[Math.round(l.progress),"%"]})]}),e.jsx(Ti,{value:l.progress,className:"h-3"}),l.progress>=100&&e.jsxs("p",{className:"text-xs text-emerald-600 dark:text-emerald-400 mt-2 flex items-center gap-1",children:[e.jsx(ao,{className:"h-3 w-3"}),"Goal reached! 🎉"]}),l.progress<100&&l.progress>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[l.weeklyGoal-l.actionsThisWeek," more to hit your goal"]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(nh,{className:"h-4 w-4 text-orange-500"}),"Momentum"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Current Streak"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xl font-bold",children:b.currentStreak}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"}),b.currentStreak>=7&&e.jsx("span",{className:"ml-1",children:"🔥"}),b.currentStreak>=30&&e.jsx("span",{children:"🏆"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Longest Streak"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xl font-bold",children:b.longestStreak}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"})]})]}),b.currentStreak===0&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 italic",children:"Log a touch today to start your streak!"})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Pm,{className:"h-4 w-4"}),"How You're Reaching Out"]})}),e.jsx(Oe,{children:f.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No touches logged this month yet."}):e.jsx("div",{className:"space-y-2.5",children:f.slice(0,5).map((T,I)=>{const L=G1s[T.icon||""]||Pm;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:T.name})]}),e.jsxs("span",{className:"text-muted-foreground",children:[T.count," (",T.percent,"%)"]})]}),e.jsx(Ti,{value:T.percent,className:Pt("h-1.5 bg-muted [&>div]:",EDe[I%EDe.length])})]},T.id)})})})]})]}),y.length>0&&e.jsxs(Ee,{className:"border-l-4 border-l-primary",children:[e.jsxs(It,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(Qn,{className:"h-5 w-5 text-primary"}),"Who to Reach Out to Today"]}),e.jsxs(rt,{variant:"secondary",children:[y.length," contacts"]})]}),e.jsx(pr,{children:"These relationships need attention the most"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:y.map(T=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card hover:bg-accent/50 cursor-pointer transition-colors",onClick:()=>t(`/mission-control/contacts/${T.id}`),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(TI,{score:T.relationshipScore,showScore:!0,size:"sm",showTooltip:!1}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[T.first_name," ",T.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:T.relationshipScore.daysSinceTouch===null?"Never contacted":`Last touch ${T.relationshipScore.daysSinceTouch}d ago`})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[T.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I=>{I.stopPropagation(),window.open(`tel:${T.phone}`)},children:e.jsx(Qn,{className:"h-4 w-4"})}),T.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I=>{I.stopPropagation(),window.open(`mailto:${T.email}`)},children:e.jsx(br,{className:"h-4 w-4"})}),e.jsx(Ua,{className:"h-4 w-4 text-muted-foreground"})]})]},T.id))})})]}),_.length>0&&e.jsxs(Ee,{className:"border-l-4 border-l-emerald-500",children:[e.jsxs(It,{className:"pb-3",children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(rc,{className:"h-5 w-5 text-emerald-500"}),"Biggest Wins This Month"]}),e.jsx(pr,{children:"Relationships you've successfully warmed up"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:_.map(T=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-full bg-emerald-500/10 border border-emerald-500/20 cursor-pointer hover:bg-emerald-500/20 transition-colors",onClick:()=>t(`/mission-control/contacts/${T.id}`),children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),e.jsxs("span",{className:"text-sm font-medium",children:[T.first_name," ",T.last_name]}),e.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400 font-bold",children:T.relationshipScore.score})]},T.id))})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Ee,{className:"border-l-4 border-l-emerald-500",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Warm"}),e.jsx("p",{className:"text-3xl font-bold text-emerald-600 dark:text-emerald-400",children:r.warm})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🟢"})})]}),e.jsx(Ti,{value:r.total?r.warm/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-emerald-500"})]})}),e.jsx(Ee,{className:"border-l-4 border-l-amber-500",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Cooling Off"}),e.jsx("p",{className:"text-3xl font-bold text-amber-600 dark:text-amber-400",children:r.cooling})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🟡"})})]}),e.jsx(Ti,{value:r.total?r.cooling/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-amber-500"})]})}),e.jsx(Ee,{className:"border-l-4 border-l-red-500",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"At Risk"}),e.jsx("p",{className:"text-3xl font-bold text-red-600 dark:text-red-400",children:r.atRisk})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-red-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🔴"})})]}),e.jsx(Ti,{value:r.total?r.atRisk/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-red-500"})]})})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(fP,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Deals Closed This Month"}),e.jsx("p",{className:"text-2xl font-bold",children:u.closedThisMonth})]})]}),u.totalGCI>0&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"GCI This Month"}),e.jsxs("p",{className:"text-2xl font-bold text-emerald-600 dark:text-emerald-400",children:["$",u.totalGCI.toLocaleString()]})]})]})})}),e.jsxs(ka,{defaultValue:"at-risk",children:[e.jsxs(_a,{children:[e.jsxs(js,{value:"at-risk",className:"gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500"}),"At Risk (",r.atRisk,")"]}),e.jsxs(js,{value:"cooling",className:"gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-500"}),"Cooling (",r.cooling,")"]}),e.jsxs(js,{value:"warm",className:"gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),"Warm (",r.warm,")"]})]}),[{key:"at-risk",contacts:S},{key:"cooling",contacts:k},{key:"warm",contacts:j}].map(({key:T,contacts:I})=>e.jsx(zs,{value:T,children:e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:I.length===0?e.jsx("p",{className:"p-6 text-center text-muted-foreground",children:"No contacts in this category"}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Contact"}),e.jsx(bt,{className:"hidden md:table-cell",children:"Last Touch"}),e.jsx(bt,{className:"hidden md:table-cell",children:"Touches (12mo)"}),e.jsx(bt,{children:"Score"}),e.jsx(bt,{className:"w-10"})]})}),e.jsx(Pn,{children:I.slice(0,20).map(L=>e.jsxs(Ns,{className:"cursor-pointer",onClick:()=>t(`/mission-control/contacts/${L.id}`),children:[e.jsxs(lt,{className:"font-medium",children:[L.first_name," ",L.last_name]}),e.jsx(lt,{className:"hidden md:table-cell text-muted-foreground",children:L.relationshipScore.daysSinceTouch===null?"Never":L.relationshipScore.daysSinceTouch===0?"Today":`${L.relationshipScore.daysSinceTouch}d ago`}),e.jsx(lt,{className:"hidden md:table-cell",children:L.relationshipScore.touchCountLast12Months}),e.jsx(lt,{children:e.jsx(TI,{score:L.relationshipScore,showScore:!0})}),e.jsx(lt,{children:e.jsx(Ua,{className:"h-4 w-4 text-muted-foreground"})})]},L.id))})]})})})},T))]})]})})}function Uet(){const{user:t}=Hs(),s=rs(),{data:r,isLoading:n}=wt({queryKey:["contact-intake-page",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:u,error:p}=await G.from("contact_intake_pages").select("*").eq("user_id",t.id).maybeSingle();if(p)throw p;return u},enabled:!!(t!=null&&t.id)}),a=Dt({mutationFn:async u=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:p,error:f}=await G.from("contact_intake_pages").insert({user_id:t.id,slug:u.toLowerCase().replace(/[^a-z0-9-]/g,"-")}).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-intake-page"]}),fe.success("Connect page created!")},onError:u=>{var p;(p=u.message)!=null&&p.includes("duplicate")?fe.error("That slug is already taken. Try another."):fe.error("Failed to create page")}}),o=Dt({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page");const{error:p}=await G.from("contact_intake_pages").update({...u,updated_at:new Date().toISOString()}).eq("id",r.id);if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-intake-page"]}),fe.success("Page updated!")},onError:()=>fe.error("Failed to update page")}),{data:l=[],isLoading:i}=wt({queryKey:["contact-intake-submissions",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:u,error:p}=await G.from("contact_intake_submissions").select("*").eq("agent_user_id",t.id).order("created_at",{ascending:!1}).limit(100);if(p)throw p;return u},enabled:!!(t!=null&&t.id)}),d=Dt({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page. Create your Connect page first.");const{data:p,error:f}=await G.from("contact_intake_tokens").insert({contact_id:u,intake_page_id:r.id}).select("token").single();if(f)throw f;return`${window.location.origin}/connect/${r.slug}?t=${p.token}`}});return{intakePage:r,isLoading:n,createPage:a,updatePage:o,submissions:l,loadingSubmissions:i,generateUpdateLink:d}}function Z1s(){const{user:t}=Hs();return wt({queryKey:["bulk-email-sends",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:s,error:r}=await G.from("bulk_email_sends").select("contact_id, sent_at, subject").eq("user_id",t.id).order("sent_at",{ascending:!1});if(r)throw r;return s}})}function Y1s(t,s){if(!t)return null;const r=t.find(n=>n.contact_id===s);return(r==null?void 0:r.sent_at)||null}const HE=[{key:"email",label:"Missing Email",icon:br,description:"No email — can't send drips or market updates",check:t=>!t.email,color:"text-red-500",fieldKey:"email",fieldType:"email",placeholder:"email@example.com"},{key:"phone",label:"Missing Phone",icon:Qn,description:"No phone number — can't call or text",check:t=>!t.phone,color:"text-orange-500",fieldKey:"phone",fieldType:"tel",placeholder:"(555) 123-4567"},{key:"address",label:"Missing Address",icon:Oi,description:"No address — can't send postcards or popbys",check:t=>!t.address,color:"text-amber-500",fieldKey:"address",fieldType:"text",placeholder:"123 Main St, City, ST 12345"},{key:"birthday",label:"Missing Birthday",icon:zu,description:"No birthday — missing a key personal touch",check:t=>!t.birthday,color:"text-purple-500",fieldKey:"birthday",fieldType:"date"},{key:"home_anniversary",label:"Missing Home Anniversary",icon:On,description:"No home anniversary — missing annual outreach opportunity",check:t=>!t.home_anniversary,color:"text-blue-500",fieldKey:"home_anniversary",fieldType:"date"},{key:"tags",label:"No Tags",icon:Wh,description:"Untagged — won't appear in filtered lists or plans",check:t=>!t.tags||t.tags.length===0,color:"text-slate-500"}];function E4(t){const s=[!!t.email,!!t.phone,!!t.address,!!t.birthday,!!t.home_anniversary,!!(t.tags&&t.tags.length>0)];return Math.round(s.filter(Boolean).length/s.length*100)}function X1s({contact:t,onClose:s}){const r=mbe(),[n,a]=C.useState({email:t.email||"",phone:t.phone||"",address:t.address||"",birthday:t.birthday||"",home_anniversary:t.home_anniversary||""}),o=async()=>{r.mutate({id:t.id,...n},{onSuccess:()=>s()})},l=HE.filter(i=>i.fieldKey&&i.check(t));return e.jsx(MM,{open:!0,onOpenChange:()=>s(),children:e.jsxs(cS,{className:"sm:max-w-md overflow-y-auto",children:[e.jsxs(TM,{children:[e.jsxs(AM,{children:["Quick Edit — ",t.first_name," ",t.last_name]}),e.jsxs(pUe,{children:["Fill in missing fields to improve this contact's completeness (",E4(t),"%)"]})]}),e.jsxs("div",{className:"space-y-5 mt-6",children:[l.length>0&&e.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400 mb-1",children:"Missing Fields"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:l.map(i=>{const d=i.icon;return e.jsxs(rt,{variant:"outline",className:"gap-1",children:[e.jsx(d,{className:"h-3 w-3"}),i.label.replace("Missing ","")]},i.key)})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(br,{className:"h-3.5 w-3.5"})," Email"]}),e.jsx(Re,{type:"email",placeholder:"email@example.com",value:n.email,onChange:i=>a(d=>({...d,email:i.target.value})),className:Pt(!t.email&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(Qn,{className:"h-3.5 w-3.5"})," Phone"]}),e.jsx(Re,{type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:i=>a(d=>({...d,phone:i.target.value})),className:Pt(!t.phone&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(Oi,{className:"h-3.5 w-3.5"})," Address"]}),e.jsx(Re,{placeholder:"123 Main St, City, ST 12345",value:n.address,onChange:i=>a(d=>({...d,address:i.target.value})),className:Pt(!t.address&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(zu,{className:"h-3.5 w-3.5"})," Birthday"]}),e.jsx(Re,{type:"date",value:n.birthday,onChange:i=>a(d=>({...d,birthday:i.target.value})),className:Pt(!t.birthday&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(On,{className:"h-3.5 w-3.5"})," Home Anniversary"]}),e.jsx(Re,{type:"date",value:n.home_anniversary,onChange:i=>a(d=>({...d,home_anniversary:i.target.value})),className:Pt(!t.home_anniversary&&"border-amber-500/50")})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{className:"flex-1",onClick:o,disabled:r.isPending,children:[e.jsx(fu,{className:"h-4 w-4 mr-1.5"}),r.isPending?"Saving...":"Save Changes"]}),e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"})]})]})]})})}const Wpe="Quick favor — can you update your info? 🙏",PDe=`Hi {{first_name}}, Hope you're doing well! I'm making sure I have the most up-to-date info for all my important contacts. Could you take 30 seconds to update your details? Just click the link below: {{update_link}} It's super quick — and it helps me make sure I'm reaching you at the right place with anything useful (market updates, birthday wishes, you name it 😊). Thanks so much!`;function Q1s(){const t=Pr(),{data:s,isLoading:r}=tm(),{data:n}=Rf(),{intakePage:a}=Uet(),{isGmailConnected:o,gmailEmail:l}=Ny(),{data:i}=Z1s(),[d,u]=C.useState("blocked"),[p,f]=C.useState("all"),[y,_]=C.useState(null),[b,w]=C.useState(!1),[j,k]=C.useState(!1),[S,T]=C.useState(null),[I,L]=C.useState([]),[R,$]=C.useState(""),[q,U]=C.useState(""),H=C.useMemo(()=>s?p==="all"?s:s.filter(we=>{var Me;return(Me=we.tags)==null?void 0:Me.some(Te=>Te.relationship_type_id===p)}):[],[s,p]),Y=C.useMemo(()=>H.filter(we=>!we.email&&!we.phone),[H]),se=C.useMemo(()=>{if(!H.length)return{overallCompleteness:0,fullyComplete:0,contactsByGap:{}};const we={};we.blocked=Y,HE.forEach(Ae=>{we[Ae.key]=H.filter(Ae.check)});const Me=H.map(E4),Te=H.length>0?Math.round(Me.reduce((Ae,Ue)=>Ae+Ue,0)/H.length):0,Fe=Me.filter(Ae=>Ae===100).length;return{contactsByGap:we,overallCompleteness:Te,fullyComplete:Fe}},[H,Y]),te=C.useMemo(()=>{if(!s||s.length===0)return null;const we=pc(LN(new Date,1)),Me=s.filter(Ue=>new Date(Ue.created_at)Ue+ut,0)/Me.length),Fe=se.overallCompleteness,Ae=Fe-Te;return{oldCompleteness:Te,currentCompleteness:Fe,diff:Ae,oldCount:Me.length}},[s,se.overallCompleteness]),Q=H.length,de=C.useCallback(()=>{var Rt;const we=se.contactsByGap[d];if(!(we!=null&&we.length))return;const Me=d==="blocked"?"Outreach Blocked":((Rt=HE.find(me=>me.key===d))==null?void 0:Rt.label)||d,Te=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Completeness %"],Fe=we.map(me=>[me.first_name,me.last_name||"",me.email||"",me.phone||"",me.address||"",me.birthday||"",me.home_anniversary||"",E4(me).toString()]),Ae=[Te.join(","),...Fe.map(me=>me.map(Xe=>`"${Xe.replace(/"/g,'""')}"`).join(","))].join(` `),Ue=new Blob([Ae],{type:"text/csv"}),ut=URL.createObjectURL(Ue),De=document.createElement("a");De.href=ut,De.download=`sphere-gaps-${Me.toLowerCase().replace(/\s+/g,"-")}-${ys(new Date,"yyyy-MM-dd")}.csv`,De.click(),URL.revokeObjectURL(ut),pn({title:`Exported ${we.length} contacts to CSV`})},[se.contactsByGap,d]),re=C.useCallback(async we=>{if(!a)return null;try{const{data:Me,error:Te}=await G.from("contact_intake_tokens").insert({contact_id:we,intake_page_id:a.id}).select("token").single();if(Te)throw Te;return Me.token}catch{return null}},[a]),ae=C.useCallback(we=>a?`https://contacts.relevelup.com/${a.slug}?t=${we}`:"",[a]),le=C.useCallback(async we=>{if(!a){fe.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const Me=await re(we);Me?(await navigator.clipboard.writeText(ae(Me)),fe.success("Update link copied!")):fe.error("Failed to generate link")},[a,re,ae,t]),he=C.useCallback(async we=>{if(!a){fe.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}if(!we.email){fe.error("This contact has no email address");return}const Me=await re(we.id);if(!Me){fe.error("Failed to generate link");return}const Te=ae(Me),Fe=PDe.replace("{{update_link}}",Te).replace(/\{\{first_name\}\}/g,we.first_name).replace(/\{\{last_name\}\}/g,we.last_name||""),Ae=Wpe.replace(/\{\{first_name\}\}/g,we.first_name).replace(/\{\{last_name\}\}/g,we.last_name||"");if(o)T({id:we.id,first_name:we.first_name,last_name:we.last_name,email:we.email}),L([]),$(Ae),U(Fe),k(!0);else{const Ue=encodeURIComponent(Wpe.replace("{{first_name}}",we.first_name)),ut=encodeURIComponent(Fe.replace(/\{\{first_name\}\}/g,we.first_name));window.location.href=`mailto:${we.email}?subject=${Ue}&body=${ut}`}},[a,re,ae,o,t]),be=C.useCallback(async we=>{if(!a){fe.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const Me=we.filter(Te=>Te.email);if(!Me.length){fe.error("No contacts with email addresses in this group");return}if(!o){fe.error("Connect Gmail in Settings to send bulk emails");return}w(!0);try{const{data:Te,error:Fe}=await G.functions.invoke("process-intake-submissions",{body:{action:"generate_tokens",contact_ids:Me.map(me=>me.id),intake_page_id:a.id}});if(Fe)throw Fe;const Ae=typeof Te=="string"?JSON.parse(Te):Te,Ue=Array.isArray(Ae)?Ae:Array.isArray(Ae==null?void 0:Ae.tokens)?Ae.tokens:[],ut=new Map(Ue.filter(me=>(me==null?void 0:me.contact_id)&&(me==null?void 0:me.token)).map(me=>[me.contact_id,me.token]));if(ut.size===0&&(await Promise.all(Me.map(async Xe=>({contactId:Xe.id,token:await re(Xe.id)})))).forEach(({contactId:Xe,token:ot})=>{ot&&ut.set(Xe,ot)}),ut.size===0){fe.error("Failed to generate update links. Please try again.");return}const De=Me.filter(me=>ut.has(me.id)).map(me=>({id:me.id,first_name:me.first_name,last_name:me.last_name,email:me.email,updateLink:ae(ut.get(me.id))})),Rt=PDe;T(null),L(De),$(Wpe),U(Rt),k(!0),fe.success(`Ready to email ${De.length} contacts`)}catch{fe.error("Failed to generate links")}finally{w(!1)}},[a,o,ae,re,t]),je=[{key:"blocked",label:"Outreach Blocked",icon:m0,color:"text-destructive",description:"Missing BOTH email AND phone — completely unreachable"},...HE].find(we=>we.key===d),Ne=se.contactsByGap[d]||[],Ge=Ne.filter(we=>we.email).length;return e.jsxs(Ts,{children:[e.jsxs("div",{className:"space-y-6 p-4 md:p-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Sphere Gaps Analyzer"}),e.jsx("p",{className:"text-muted-foreground",children:"Find missing info in your database to maximize your outreach potential"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yx,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(sr,{value:p,onValueChange:f,children:[e.jsx(er,{className:"w-[180px]",children:e.jsx(rr,{placeholder:"Filter by tag"})}),e.jsxs(tr,{children:[e.jsx(At,{value:"all",children:"All Contacts"}),n==null?void 0:n.map(we=>e.jsx(At,{value:we.id,children:we.name},we.id))]})]})]})]}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Database Completeness",p!=="all"&&e.jsx("span",{className:"ml-1 text-primary",children:"(filtered)"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("p",{className:"text-4xl font-bold",children:[se.overallCompleteness,"%"]}),te&&te.diff!==0&&p==="all"&&e.jsxs("div",{className:Pt("flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",te.diff>0?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-red-500/10 text-red-600 dark:text-red-400"),children:[te.diff>0?"↑":"↓"," ",Math.abs(te.diff),"% vs older contacts"]})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Fully Complete"}),e.jsxs("p",{className:"text-2xl font-bold text-emerald-600 dark:text-emerald-400",children:[se.fullyComplete," ",e.jsxs("span",{className:"text-base font-normal text-muted-foreground",children:["/ ",Q]})]})]})]}),e.jsx(Ti,{value:se.overallCompleteness,className:"h-3"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:se.overallCompleteness>=80?"🎉 Great job! Your database is well maintained.":se.overallCompleteness>=50?"⚡ Good start — fill in the gaps below to unlock more outreach channels.":"🔍 Your database needs attention. Start with emails and phone numbers."})]})}),Y.length>0&&e.jsx(Ee,{className:Pt("border-l-4 border-l-destructive cursor-pointer transition-all hover:shadow-md",d==="blocked"&&"ring-2 ring-primary"),onClick:()=>u("blocked"),children:e.jsx(Oe,{className:"pt-5 pb-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(m0,{className:"h-6 w-6 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Outreach Blocked"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Missing both email AND phone — completely unreachable"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-3xl font-bold text-destructive",children:Y.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"contacts"})]})]})})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:HE.map(we=>{var Ue;const Me=((Ue=se.contactsByGap[we.key])==null?void 0:Ue.length)||0,Te=Q>0?Math.round(Me/Q*100):0,Fe=we.icon,Ae=d===we.key;return e.jsx(Ee,{className:Pt("cursor-pointer transition-all hover:shadow-md",Ae&&"ring-2 ring-primary"),onClick:()=>u(we.key),children:e.jsxs(Oe,{className:"pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Fe,{className:Pt("h-5 w-5",we.color)}),e.jsx("span",{className:"text-sm font-medium",children:we.label})]}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:"text-2xl font-bold",children:Me}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Te,"% of contacts"]})]}),e.jsx(Ti,{value:100-Te,className:"mt-2 h-1.5"})]})},we.key)})}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-lg",children:[(je==null?void 0:je.label)||"Contacts"," — Contacts to Fix"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(rt,{variant:"secondary",children:[Ne.length," contacts"]}),Ne.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:de,className:"gap-1.5",children:[e.jsx(xi,{className:"h-3.5 w-3.5"}),"Export"]}),Ge>0&&a&&e.jsxs(K,{size:"sm",onClick:()=>be(Ne),disabled:b,className:"gap-1.5",children:[b?e.jsx(Ms,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(aa,{className:"h-3.5 w-3.5"}),"Email ",Ge," Update Links"]})]})]})]}),e.jsx(pr,{children:je==null?void 0:je.description})]}),e.jsx(Oe,{className:"p-0",children:Ne.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(ua,{className:"h-10 w-10 text-emerald-500 mx-auto mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:d==="blocked"?"All contacts have at least an email or phone!":"All contacts have this field filled in!"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(Ns,{children:[e.jsx(bt,{children:"Contact"}),e.jsx(bt,{className:"hidden md:table-cell",children:"Email"}),e.jsx(bt,{className:"hidden md:table-cell",children:"Phone"}),e.jsx(bt,{children:"Completeness"}),e.jsx(bt,{className:"w-28",children:"Actions"})]})}),e.jsx(Pn,{children:Ne.map(we=>{const Me=Y1s(i,we.id);return e.jsxs(Ns,{children:[e.jsx(lt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"cursor-pointer hover:underline",onClick:()=>t(`/mission-control/contacts/${we.id}`),children:[we.first_name," ",we.last_name]}),!we.email&&!we.phone&&d!=="blocked"&&e.jsx(rt,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"Blocked"}),Me&&e.jsxs(Wc,{children:[e.jsx(Gc,{asChild:!0,children:e.jsxs(rt,{variant:"outline",className:"text-[10px] px-1.5 py-0 gap-1 text-muted-foreground border-muted",children:[e.jsx(br,{className:"h-2.5 w-2.5"}),Sd(new Date(Me),{addSuffix:!0})]})}),e.jsxs(Cc,{children:["Last bulk emailed ",ys(new Date(Me),"MMM d, yyyy h:mm a")]})]})]})}),e.jsx(lt,{className:"hidden md:table-cell text-muted-foreground",children:we.email||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(lt,{className:"hidden md:table-cell text-muted-foreground",children:we.phone||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ti,{value:E4(we),className:"h-2 w-16"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[E4(we),"%"]})]})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs(Wc,{children:[e.jsx(Gc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>_(we),children:e.jsx(f0,{className:"h-3.5 w-3.5"})})}),e.jsx(Cc,{children:"Quick edit"})]}),(we.email||we.phone)&&a&&e.jsxs(Wc,{children:[e.jsx(Gc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>le(we.id),children:e.jsx(ai,{className:"h-3.5 w-3.5"})})}),e.jsx(Cc,{children:"Copy update link"})]}),we.email&&a&&e.jsxs(Wc,{children:[e.jsx(Gc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>he(we),children:e.jsx(br,{className:"h-3.5 w-3.5"})})}),e.jsx(Cc,{children:"Email update link"})]})]})})]},we.id)})})]})})]})]}),y&&e.jsx(X1s,{contact:y,onClose:()=>_(null)}),e.jsx(JM,{open:j,onOpenChange:k,contact:S||void 0,bulkContacts:I.length>0?I:void 0,defaultSubject:R,defaultBody:q,gmailEmail:l})]})}function J1s(){const{user:t}=Hs(),{intakePage:s,isLoading:r,createPage:n,updatePage:a,submissions:o,loadingSubmissions:l}=Uet(),[i,d]=C.useState(""),[u,p]=C.useState(""),[f,y]=C.useState(!1);C.useEffect(()=>{s&&p(s.welcome_message||"")},[s]),C.useEffect(()=>{if(t!=null&&t.email&&!s){const T=t.email.split("@")[0];d(T.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+$/,""))}},[t,s]);const _=s?`https://contacts.relevelup.com/${s.slug}`:"",b=()=>{navigator.clipboard.writeText(_),fe.success("Link copied!")};if(r)return e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6 flex items-center justify-center",children:e.jsx(Ms,{className:"h-5 w-5 animate-spin text-muted-foreground"})})});if(!s)return e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Wo,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{children:"Connect Page"}),e.jsx(pr,{children:"Create a public link to capture contact info from new leads or update existing contacts"})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{children:"Your Connect Page URL"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"contacts.relevelup.com/"}),e.jsx(Re,{value:i,onChange:T=>d(T.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"jane-smith",className:"max-w-[200px]"})]})]}),e.jsxs(K,{onClick:()=>n.mutate(i),disabled:!i.trim()||n.isPending,children:[n.isPending?e.jsx(Ms,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Connect Page"]})]})})]});const w=o.filter(T=>!T.is_processed),j=o.filter(T=>T.is_processed),k=w.length,S=(T,I)=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:[T.first_name," ",T.last_name||""]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5",children:[T.email&&e.jsx("span",{children:T.email}),T.phone&&e.jsx("span",{children:T.phone})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[T.real_estate_interest&&T.real_estate_interest!=="not_now"&&e.jsx(rt,{variant:"outline",className:"text-xs",children:T.real_estate_interest==="buying"?"🏠 Buying":T.real_estate_interest==="selling"?"📋 Selling":T.real_estate_interest==="both"?"🔄 Both":T.real_estate_interest}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Tn,{className:"h-3 w-3"}),ys(new Date(T.created_at),"MMM d")]}),I&&e.jsx(ua,{className:"h-4 w-4 text-emerald-500"})]})]},T.id);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Wo,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{children:"Connect Page"}),e.jsx(pr,{children:"Share this link to capture contact info"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{htmlFor:"active-toggle",className:"text-sm text-muted-foreground",children:"Active"}),e.jsx(Br,{id:"active-toggle",checked:s.is_active,onCheckedChange:T=>a.mutate({is_active:T})})]})]})}),e.jsxs(Oe,{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:_}),e.jsxs(K,{size:"sm",variant:"outline",onClick:b,children:[e.jsx(ai,{className:"h-3.5 w-3.5 mr-1.5"})," Copy"]}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",children:e.jsx(sn,{className:"h-3.5 w-3.5"})})})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Welcome Message"}),f?e.jsxs("div",{className:"mt-1.5 space-y-2",children:[e.jsx("textarea",{value:u,onChange:T=>p(T.target.value),rows:3,className:"w-full px-3 py-2 text-sm border rounded-md bg-background"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",onClick:()=>{a.mutate({welcome_message:u}),y(!1)},children:"Save"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>y(!1),children:"Cancel"})]})]}):e.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground cursor-pointer hover:text-foreground transition-colors",onClick:()=>y(!0),children:s.welcome_message||"Click to set a welcome message..."})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(hr,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-base",children:"New Submissions"}),k>0&&e.jsxs(pr,{children:[k," awaiting sync"]})]})]}),k>0&&e.jsxs(K,{size:"sm",onClick:async()=>{try{const{data:T,error:I}=await G.functions.invoke("process-intake-submissions",{body:{action:"process_all"}});if(I)throw I;fe.success(`Synced ${T.processed} contacts to your CRM!`)}catch{fe.error("Failed to sync")}},className:"gap-1.5",children:["Sync ",k," to CRM"]})]})}),e.jsx(Oe,{children:l?e.jsx(Ms,{className:"h-5 w-5 animate-spin text-muted-foreground"}):w.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"All caught up! No new submissions to sync."}):e.jsx("div",{className:"space-y-3",children:w.map(T=>S(T,!1))})})]}),j.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ua,{className:"h-5 w-5 text-emerald-500"}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-base",children:"Synced to CRM"}),e.jsxs(pr,{children:[j.length," contacts already in your database"]})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[j.slice(0,10).map(T=>S(T,!0)),j.length>10&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-1",children:["+ ",j.length-10," more synced contacts"]})]})})]})]})}function e_s(){return e.jsx(Ts,{children:e.jsxs("div",{className:"max-w-3xl mx-auto py-8 px-4",children:[e.jsx("h1",{className:"text-2xl font-bold mb-6",children:"Connect Page"}),e.jsx(J1s,{})]})})}const t_s=C.lazy(()=>hh(()=>import("./PostcardManager-Cn1JVEbF.js"),__vite__mapDeps([0,1]))),s_s=C.lazy(()=>hh(()=>import("./HomeReelManager-Bn5PLX_I.js"),[])),r_s=C.lazy(()=>hh(()=>import("./AdminCredits-P7gsJ_0W.js"),[])),n_s=C.lazy(()=>hh(()=>import("./DirectMail-qAENArGH.js"),__vite__mapDeps([2,1]))),a_s=C.lazy(()=>hh(()=>import("./InnerCirclePopbyMap-XNcV40Iq.js"),[])),i_s=C.lazy(()=>hh(()=>import("./LiveVisitorFeed-CgW0PSxa.js"),[])),o_s=C.lazy(()=>hh(()=>import("./EmailCampaigns-C7HY-FjV.js"),[])),l_s=C.lazy(()=>hh(()=>import("./EmailCampaignComposer-CF0z2gU8.js"),[])),c_s=C.lazy(()=>hh(()=>import("./EmailCampaignDetail-CRuyypjX.js"),[])),d_s=C.lazy(()=>hh(()=>import("./SharedCampaignTemplates-7DmWEu_O.js"),[])),u_s=new fut,h_s=()=>{const t=window.location.hostname;return t==="listings.relevelup.com"||t.startsWith("listings.")},m_s=()=>{const t=window.location.hostname;return t==="cards.relevelup.com"||t.startsWith("cards.")},p_s=()=>{const t=window.location.hostname;return t==="presentations.relevelup.com"||t.startsWith("presentations.")},f_s=()=>{const t=window.location.hostname;return t==="guestbook.relevelup.com"||t.startsWith("guestbook.")},g_s=()=>{const t=window.location.hostname;return t==="clients.relevelup.com"||t.startsWith("clients.")},x_s=()=>{const t=window.location.hostname;return t==="cardstudio.relevelup.com"||t.startsWith("cardstudio.")},y_s=()=>{const t=window.location.hostname;return t==="booking.relevelup.com"||t.startsWith("booking.")},v_s=()=>{const t=window.location.hostname;return t==="contacts.relevelup.com"||t.startsWith("contacts.")},__s=()=>{const t=window.location.hostname;return t==="pages.relevelup.com"||t.startsWith("pages.")},b_s=()=>e.jsx(_ut,{client:u_s,children:e.jsx(YFe,{children:e.jsxs(U_,{children:[e.jsx(Dlt,{}),e.jsx(mct,{}),e.jsx(Pht,{children:e.jsx(Dft,{children:e.jsx(Oft,{children:e.jsxs(Fft,{children:[e.jsx(Rft,{}),e.jsx(gyt,{}),e.jsx(Pyt,{}),x_s()?e.jsx(T1s,{}):m_s()?e.jsx(X0t,{}):h_s()?e.jsx(v0t,{}):p_s()?e.jsx(evt,{}):f_s()?e.jsx(Rkt,{}):g_s()?e.jsx(eSt,{}):y_s()?e.jsx(A1s,{}):v_s()?e.jsx(E1s,{}):__s()?e.jsx(P1s,{}):e.jsxs(UFe,{children:[e.jsx($s,{path:"/",element:e.jsx(cSt,{})}),e.jsx($s,{path:"/privacy-policy",element:e.jsx(dSt,{})}),e.jsx($s,{path:"/terms-of-service",element:e.jsx(uSt,{})}),e.jsx($s,{path:"/data-deletion",element:e.jsx(hSt,{})}),e.jsx($s,{path:"/public/listings",element:e.jsx(C9e,{})}),e.jsx($s,{path:"/public/listing/:slugOrId",element:e.jsx(Q4t,{})}),e.jsx($s,{path:"/card/:slug",element:e.jsx(J4t,{})}),e.jsx($s,{path:"/join-brokerage/:slug",element:e.jsx(Evs,{})}),e.jsx($s,{path:"/recruit-video/:shareToken",element:e.jsx(Ivs,{})}),e.jsx($s,{path:"/connect/:slug",element:e.jsx(mVe,{})}),e.jsx($s,{path:"/auth",element:e.jsx(pSt,{})}),e.jsx($s,{path:"/subscription-success",element:e.jsx(fSt,{})}),e.jsx($s,{path:"/subscription",element:e.jsx(lr,{children:e.jsx(o4t,{})})}),e.jsxs($s,{path:"/share/video",element:e.jsx(K4t,{}),children:[e.jsx($s,{path:":shareToken",element:e.jsx(JMe,{})}),e.jsx($s,{path:":shareToken/r/:recipientToken",element:e.jsx(JMe,{})})]}),e.jsx($s,{path:"/p/:shareToken",element:e.jsx(Xvs,{})}),e.jsx($s,{path:"/portal/:slug",element:e.jsx(n1s,{})}),e.jsx($s,{path:"/og/video/:token",element:e.jsx(Z4t,{})}),e.jsx($s,{path:"/setup-brokerage",element:e.jsx(lr,{children:e.jsx(l4t,{})})}),e.jsx($s,{path:"/claim-account",element:e.jsx(YMe,{})}),e.jsx($s,{path:"/claim",element:e.jsx(YMe,{})}),e.jsx($s,{path:"/join",element:e.jsx(c4t,{})}),e.jsx($s,{path:"/trial",element:e.jsx(_4t,{})}),e.jsx($s,{path:"/trial/success",element:e.jsx(b4t,{})}),e.jsx($s,{path:"/dashboard",element:e.jsx(lr,{children:e.jsx(_3t,{})})}),e.jsx($s,{path:"/profile",element:e.jsx(lr,{children:e.jsx(nDt,{})})}),e.jsx($s,{path:"/apps",element:e.jsx(lr,{children:e.jsx(yDt,{})})}),e.jsx($s,{path:"/admin",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(rRt,{})})}),e.jsx($s,{path:"/admin/apps",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(iRt,{})})}),e.jsx($s,{path:"/admin/members",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(pRt,{})})}),e.jsx($s,{path:"/admin/invite-codes",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(fRt,{})})}),e.jsx($s,{path:"/admin/events",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(bRt,{})})}),e.jsx($s,{path:"/events",element:e.jsx(lr,{children:e.jsx(pDt,{})})}),e.jsx($s,{path:"/events/:eventId",element:e.jsx(lr,{children:e.jsx(gDt,{})})}),e.jsx($s,{path:"/templates",element:e.jsx(lr,{children:e.jsx(vDt,{})})}),e.jsx($s,{path:"/templates/:templateId",element:e.jsx(lr,{children:e.jsx(jDt,{})})}),e.jsx($s,{path:"/admin/templates",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(jRt,{})})}),e.jsx($s,{path:"/academy",element:e.jsx(lr,{children:e.jsx(NDt,{})})}),e.jsx($s,{path:"/academy/:videoId",element:e.jsx(lr,{children:e.jsx(SDt,{})})}),e.jsx($s,{path:"/admin/academy",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(kRt,{})})}),e.jsx($s,{path:"/toolbox",element:e.jsx(lr,{children:e.jsx(CDt,{})})}),e.jsx($s,{path:"/toolbox/:kitId",element:e.jsx(lr,{children:e.jsx(MDt,{})})}),e.jsx($s,{path:"/admin/toolbox",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(SRt,{})})}),e.jsx($s,{path:"/social-swag",element:e.jsx(lr,{children:e.jsx(TDt,{})})}),e.jsx($s,{path:"/social-swag-2",element:e.jsx(lr,{children:e.jsx(C8t,{})})}),e.jsx($s,{path:"/social-swag/:swagId",element:e.jsx(lr,{children:e.jsx(M8t,{})})}),e.jsx($s,{path:"/social-connections",element:e.jsx(lr,{children:e.jsx(Lvs,{})})}),e.jsx($s,{path:"/social-connections/callback",element:e.jsx(lr,{children:e.jsx(Dvs,{})})}),e.jsx($s,{path:"/social-connections/linkedin-callback",element:e.jsx(lr,{children:e.jsx(Rvs,{})})}),e.jsx($s,{path:"/social-connections/google-callback",element:e.jsx(lr,{children:e.jsx(Ovs,{})})}),e.jsx($s,{path:"/admin/social-swag",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(CRt,{})})}),e.jsx($s,{path:"/admin/social-swag-2",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(dzt,{})})}),e.jsx($s,{path:"/community",element:e.jsx(lr,{children:e.jsx(G8t,{})})}),e.jsx($s,{path:"/support",element:e.jsx(lr,{children:e.jsx(K8t,{})})}),e.jsx($s,{path:"/admin/community",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(uzt,{})})}),e.jsx($s,{path:"/admin/support-tickets",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Jus,{})})}),e.jsx($s,{path:"/admin/email-templates",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(shs,{})})}),e.jsx($s,{path:"/admin/agent-email-templates",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(rhs,{})})}),e.jsx($s,{path:"/admin/analytics",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Yus,{})})}),e.jsx($s,{path:"/admin/brokerage-resources",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Xus,{})})}),e.jsx($s,{path:"/admin/dashboard-management",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Qus,{})})}),e.jsx($s,{path:"/brokerage/dashboard",element:e.jsx(lr,{requireBrokerageManager:!0,children:e.jsx(fhs,{})})}),e.jsx($s,{path:"/brokerage/teams",element:e.jsx(lr,{requireBrokerageManager:!0,children:e.jsx(L1s,{})})}),e.jsx($s,{path:"/my-team",element:e.jsx(lr,{children:e.jsx(D1s,{})})}),e.jsx($s,{path:"/my-brokerage",element:e.jsx(lr,{children:e.jsx(bhs,{})})}),e.jsx($s,{path:"/brokerage-content",element:e.jsx(lr,{children:e.jsx(Chs,{})})}),e.jsx($s,{path:"/brokerage-content/:contentId",element:e.jsx(lr,{children:e.jsx(Phs,{})})}),e.jsx($s,{path:"/brokerage-resources",element:e.jsx(lr,{requireBrokerageManager:!0,children:e.jsx(eRt,{})})}),e.jsx($s,{path:"/brokerage-resources/:resourceId",element:e.jsx(lr,{requireBrokerageManager:!0,children:e.jsx(tRt,{})})}),e.jsx($s,{path:"/newsletters",element:e.jsx(lr,{children:e.jsx(Ihs,{})})}),e.jsx($s,{path:"/newsletters/:id",element:e.jsx(lr,{children:e.jsx(Dhs,{})})}),e.jsx($s,{path:"/wishlist",element:e.jsx(lr,{children:e.jsx(Fhs,{})})}),e.jsx($s,{path:"/wishlist/:itemId",element:e.jsx(lr,{children:e.jsx(zhs,{})})}),e.jsx($s,{path:"/admin/wishlist",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Bhs,{})})}),e.jsx($s,{path:"/admin/levelup-brief",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx($hs,{})})}),e.jsx($s,{path:"/admin/newsletters",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Rhs,{})})}),e.jsx($s,{path:"/admin/additional-services",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(qhs,{})})}),e.jsx($s,{path:"/admin/discounts",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Uhs,{})})}),e.jsx($s,{path:"/admin/subscriptions",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Vhs,{})})}),e.jsx($s,{path:"/admin/referrals",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Hhs,{})})}),e.jsx($s,{path:"/admin/prospector",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(zys,{})})}),e.jsx($s,{path:"/admin/recruiting",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(o0s,{})})}),e.jsx($s,{path:"/admin/beta/social-post-generator",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(lvs,{})})}),e.jsx($s,{path:"/admin/credits",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(C.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(r_s,{})})})}),e.jsx($s,{path:"/admin/beta/postcard-manager",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(C.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(t_s,{})})})}),e.jsx($s,{path:"/admin/beta/homereel",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(C.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(s_s,{})})})}),e.jsx($s,{path:"/admin/lms",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(wvs,{})})}),e.jsx($s,{path:"/admin/lms/stats",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Cvs,{})})}),e.jsx($s,{path:"/admin/lms/:courseId",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(jvs,{})})}),e.jsx($s,{path:"/levelup-u",element:e.jsx(lr,{children:e.jsx(Mvs,{})})}),e.jsx($s,{path:"/levelup-u/:courseId",element:e.jsx(lr,{children:e.jsx(Avs,{})})}),e.jsx($s,{path:"/admin/brokerage-content-activity",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(l0s,{})})}),e.jsx($s,{path:"/admin/onboarding-checklist",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Ghs,{})})}),e.jsx($s,{path:"/admin/marketplace",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(gys,{})})}),e.jsx($s,{path:"/admin/agent-points",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Bxs,{})})}),e.jsx($s,{path:"/admin/reward-store",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Eys,{})})}),e.jsx($s,{path:"/admin/integrations",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Iys,{})})}),e.jsx($s,{path:"/admin/integrations/callback",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Fys,{})})}),e.jsx($s,{path:"/admin/email-campaigns",element:e.jsx(lr,{children:e.jsx(C.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(o_s,{})})})}),e.jsx($s,{path:"/admin/email-campaigns/templates",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(C.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(d_s,{})})})}),e.jsx($s,{path:"/admin/email-campaigns/new",element:e.jsx(lr,{children:e.jsx(C.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(l_s,{})})})}),e.jsx($s,{path:"/admin/email-campaigns/:id",element:e.jsx(lr,{children:e.jsx(C.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(c_s,{})})})}),e.jsx($s,{path:"/reward-store",element:e.jsx(lr,{children:e.jsx(Hvs,{})})}),e.jsx($s,{path:"/additional-services",element:e.jsx(lr,{children:e.jsx(nms,{})})}),e.jsx($s,{path:"/additional-services/:serviceId",element:e.jsx(lr,{children:e.jsx(ams,{})})}),e.jsx($s,{path:"/ai-toolkit",element:e.jsx(lr,{children:e.jsx(ims,{})})}),e.jsx($s,{path:"/mission-control",element:e.jsx(lr,{children:e.jsx(bms,{})})}),e.jsx($s,{path:"/mission-control/contacts",element:e.jsx(lr,{children:e.jsx(nps,{})})}),e.jsx($s,{path:"/mission-control/contacts/:contactId",element:e.jsx(lr,{children:e.jsx(Mps,{})})}),e.jsx($s,{path:"/mission-control/plans",element:e.jsx(lr,{children:e.jsx(Tps,{})})}),e.jsx($s,{path:"/mission-control/popbys",element:e.jsx(lr,{children:e.jsx(Pps,{})})}),e.jsx($s,{path:"/mission-control/popbys/map",element:e.jsx(lr,{children:e.jsx(a_s,{})})}),e.jsx($s,{path:"/admin/notification-settings",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Dys,{})})}),e.jsx($s,{path:"/admin/agent-os",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Zhs,{})})}),e.jsx($s,{path:"/mission-control/listings",element:e.jsx(lr,{children:e.jsx(sfs,{})})}),e.jsx($s,{path:"/mission-control/listings/new",element:e.jsx(lr,{children:e.jsx($Le,{})})}),e.jsx($s,{path:"/mission-control/listings/:listingId",element:e.jsx(lr,{children:e.jsx(xfs,{})})}),e.jsx($s,{path:"/mission-control/listings/:listingId/edit",element:e.jsx(lr,{children:e.jsx($Le,{})})}),e.jsx($s,{path:"/admin/listing-exchange",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Lxs,{})})}),e.jsx($s,{path:"/mission-control/pipeline",element:e.jsx(lr,{children:e.jsx($gs,{})})}),e.jsx($s,{path:"/mission-control/tasks",element:e.jsx(lr,{children:e.jsx(Xgs,{})})}),e.jsx($s,{path:"/mission-control/my-card",element:e.jsx(lr,{children:e.jsx(xxs,{})})}),e.jsx($s,{path:"/mission-control/integrations",element:e.jsx(lr,{children:e.jsx(Cxs,{})})}),e.jsx($s,{path:"/mission-control/integrations/gmail/callback",element:e.jsx(lr,{children:e.jsx(Mxs,{})})}),e.jsx($s,{path:"/mission-control/integrations/canva/callback",element:e.jsx(Txs,{})}),e.jsx($s,{path:"/mission-control/integrations/meta/callback",element:e.jsx(lr,{children:e.jsx(Axs,{})})}),e.jsx($s,{path:"/mission-control/scorecard",element:e.jsx(lr,{children:e.jsx(Wps,{})})}),e.jsx($s,{path:"/admin/scorecard",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Pxs,{})})}),e.jsx($s,{path:"/admin/scorecard/:userId",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(XLe,{})})}),e.jsx($s,{path:"/mission-control/scorecard/:userId",element:e.jsx(lr,{children:e.jsx(XLe,{})})}),e.jsx($s,{path:"/mission-control/relationship-scorecard",element:e.jsx(lr,{children:e.jsx(K1s,{})})}),e.jsx($s,{path:"/mission-control/sphere-gaps",element:e.jsx(lr,{children:e.jsx(Q1s,{})})}),e.jsx($s,{path:"/mission-control/connect-page",element:e.jsx(lr,{children:e.jsx(e_s,{})})}),e.jsx($s,{path:"/admin/membership-reviews",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Dxs,{})})}),e.jsx($s,{path:"/admin/weekly-digest",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Fxs,{})})}),e.jsx($s,{path:"/mission-control/video/record",element:e.jsx(lr,{children:e.jsx(Cfs,{})})}),e.jsx($s,{path:"/mission-control/video-library",element:e.jsx(lr,{children:e.jsx(qfs,{})})}),e.jsx($s,{path:"/marketplace",element:e.jsx(lr,{children:e.jsx(Fvs,{})})}),e.jsx($s,{path:"/marketplace/:productId",element:e.jsx(lr,{children:e.jsx(zvs,{})})}),e.jsx($s,{path:"/marketplace/cart",element:e.jsx(lr,{children:e.jsx(Bvs,{})})}),e.jsx($s,{path:"/marketplace/orders",element:e.jsx(lr,{children:e.jsx($vs,{})})}),e.jsx($s,{path:"/marketplace/orders/:orderId",element:e.jsx(lr,{children:e.jsx(Uvs,{})})}),e.jsx($s,{path:"/marketplace/success",element:e.jsx(lr,{children:e.jsx(Vvs,{})})}),e.jsx($s,{path:"/admin/agent-cards",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx($xs,{})})}),e.jsx($s,{path:"/admin/presentation-analytics",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Oys,{})})}),e.jsx($s,{path:"/admin/guest-book-analytics",element:e.jsx(lr,{requireAdmin:!0,children:e.jsx(Rys,{})})}),e.jsx($s,{path:"/mission-control/smart-drips",element:e.jsx(lr,{children:e.jsx(C1s,{})})}),e.jsx($s,{path:"/mission-control/direct-mail",element:e.jsx(lr,{children:e.jsx(C.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(n_s,{})})})}),e.jsx($s,{path:"/mission-control/presentations",element:e.jsx(lr,{children:e.jsx(Wvs,{})})}),e.jsx($s,{path:"/mission-control/presentations/new",element:e.jsx(lr,{children:e.jsx(yDe,{})})}),e.jsx($s,{path:"/mission-control/presentations/:id",element:e.jsx(lr,{children:e.jsx(yDe,{})})}),e.jsx($s,{path:"/mission-control/guest-book",element:e.jsx(lr,{children:e.jsx(s1s,{})})}),e.jsx($s,{path:"/mission-control/guest-book/live/:id",element:e.jsx(lr,{children:e.jsx(i_s,{})})}),e.jsx($s,{path:"/guestbook/:slug",element:e.jsx(o$e,{})}),e.jsx($s,{path:"/mission-control/card-studio",element:e.jsx(lr,{children:e.jsx(d1s,{})})}),e.jsx($s,{path:"/mission-control/scheduler",element:e.jsx(lr,{children:e.jsx(q1s,{})})}),e.jsx($s,{path:"/c/:shareToken",element:e.jsx(zet,{})}),e.jsx($s,{path:"/book/:slug",element:e.jsx($et,{})}),e.jsx($s,{path:"/page/:slug",element:e.jsx(qet,{})}),e.jsx($s,{path:"/mission-control/landing-pages",element:e.jsx(lr,{children:e.jsx(U1s,{})})}),e.jsx($s,{path:"/mission-control/landing-pages/:pageId",element:e.jsx(lr,{children:e.jsx(W1s,{})})}),e.jsx($s,{path:"*",element:e.jsx(Bet,{})})]}),")"]})})})})]})})}),IDe=window.location.hostname,w_s=IDe.includes("lovable.app")||IDe.includes("lovableproject.com");w_s&&"serviceWorker"in navigator&&(navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(s=>{s.unregister()})}),"caches"in window&&caches.keys().then(t=>{t.forEach(s=>caches.delete(s))}));rRe(document.getElementById("root")).render(e.jsx(b_s,{}));export{ys as $,ti as A,K as B,Ee as C,Ts as D,Ar as E,sr as F,er as G,rr as H,Jo as I,tr as J,At as K,Ms as L,br as M,Un as N,P_s as O,Zs as P,Za as Q,Da as R,fu as S,ka as T,hr as U,An as V,En as W,Ns as X,bt as Y,Pn as Z,lt as _,_a as a,y5 as a$,fe as a0,G as a1,Hs as a2,YZ as a3,ha as a4,Pt as a5,vp as a6,ul as a7,Mse as a8,Fg as a9,D3 as aA,Bu as aB,Wc as aC,Gc as aD,A0 as aE,Cc as aF,VQ as aG,Yi as aH,Br as aI,Qn as aJ,Co as aK,Mo as aL,No as aM,Ri as aN,Pc as aO,hP as aP,hn as aQ,ua as aR,ll as aS,xa as aT,VZ as aU,FZ as aV,oP as aW,wu as aX,U9 as aY,In as aZ,gn as a_,x0 as aa,Ur as ab,Ti as ac,xi as ad,_5 as ae,Po as af,lu as ag,Nn as ah,U0 as ai,hk as aj,F0 as ak,t4t as al,xn as am,Aa as an,yn as ao,VKe as ap,yye as aq,DJ as ar,oZe as as,KKe as at,dZe as au,q_s as av,e$ as aw,Mwe as ax,zle as ay,hZe as az,js as b,yP as b$,KP as b0,yf as b1,Kr as b2,i2 as b3,Bo as b4,pn as b5,Qnt as b6,_o as b7,ht as b8,Ams as b9,MM as bA,cS as bB,TM as bC,AM as bD,vee as bE,F2e as bF,$l as bG,$i as bH,E0 as bI,Zx as bJ,LP as bK,f0 as bL,Lm as bM,Vh as bN,Gee as bO,nk as bP,on as bQ,ZWe as bR,tGe as bS,j6t as bT,ehs as bU,mGe as bV,uGe as bW,hGe as bX,h5 as bY,v5 as bZ,xP as b_,Tms as ba,Pms as bb,du as bc,Oi as bd,aK as be,eY as bf,po as bg,hi as bh,ko as bi,I_s as bj,D9e as bk,L_s as bl,D_s as bm,O_s as bn,ld as bo,$0 as bp,Zqe as bq,Wo as br,ai as bs,nh as bt,On as bu,wr as bv,ac as bw,p_ as bx,Tn as by,io as bz,Jte as c,Hh as c0,O0 as c1,c5 as c2,l5 as c3,d5 as c4,Do as c5,A5 as c6,M5 as c7,GWe as c8,bu as c9,U_ as ca,jp as cb,W5 as cc,rJe as cd,jy as ce,oD as cf,vm as cg,sJe as ch,Jk as ci,eS as cj,lv as ck,Ho as cl,Ua as cm,th as cn,Ju as co,Qz as cp,Ta as d,Oe as e,rt as f,jr as g,ve as h,Re as i,e as j,rs as k,wt as l,Dt as m,It as n,pr as o,Ot as p,uk as q,C as r,aa as s,zs as t,Pr as u,_s as v,Ei as w,vs as x,Ss as y,ks as z};