var ont=Object.defineProperty;var OSe=t=>{throw TypeError(t)};var lnt=(t,s,r)=>s in t?ont(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var _n=(t,s,r)=>lnt(t,typeof s!="symbol"?s+"":s,r),Aue=(t,s,r)=>s.has(t)||OSe("Cannot "+r);var ds=(t,s,r)=>(Aue(t,s,"read from private field"),r?r.call(t):s.get(t)),Ba=(t,s,r)=>s.has(t)?OSe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,r),qn=(t,s,r,n)=>(Aue(t,s,"write to private field"),n?n.call(t,r):s.set(t,r),r),Bi=(t,s,r)=>(Aue(t,s,"access private method"),r);var ZO=(t,s,r,n)=>({set _(a){qn(t,s,a,r)},get _(){return ds(t,s,n)}});function cnt(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 m0=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 NDe(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 SDe={exports:{}},Iie={},CDe={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 sL=Symbol.for("react.element"),dnt=Symbol.for("react.portal"),unt=Symbol.for("react.fragment"),hnt=Symbol.for("react.strict_mode"),mnt=Symbol.for("react.profiler"),pnt=Symbol.for("react.provider"),fnt=Symbol.for("react.context"),gnt=Symbol.for("react.forward_ref"),xnt=Symbol.for("react.suspense"),ynt=Symbol.for("react.memo"),vnt=Symbol.for("react.lazy"),RSe=Symbol.iterator;function _nt(t){return t===null||typeof t!="object"?null:(t=RSe&&t[RSe]||t["@@iterator"],typeof t=="function"?t:null)}var MDe={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},TDe=Object.assign,ADe={};function J3(t,s,r){this.props=t,this.context=s,this.refs=ADe,this.updater=r||MDe}J3.prototype.isReactComponent={};J3.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")};J3.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function EDe(){}EDe.prototype=J3.prototype;function Z0e(t,s,r){this.props=t,this.context=s,this.refs=ADe,this.updater=r||MDe}var Y0e=Z0e.prototype=new EDe;Y0e.constructor=Z0e;TDe(Y0e,J3.prototype);Y0e.isPureReactComponent=!0;var FSe=Array.isArray,PDe=Object.prototype.hasOwnProperty,X0e={current:null},IDe={key:!0,ref:!0,__self:!0,__source:!0};function LDe(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)PDe.call(s,n)&&!IDe.hasOwnProperty(n)&&(a[n]=s[n]);var i=arguments.length-2;if(i===1)a.children=r;else if(1>>1,we=le[ye];if(0>>1;yea(_e,be))Mea(Te,_e)?(le[ye]=Te,le[Me]=be,ye=Me):(le[ye]=_e,le[Ke]=be,ye=Ke);else if(Mea(Te,be))le[ye]=Te,le[Me]=be,ye=Me;else break e}}return pe}function a(le,pe){var be=le.sortIndex-pe.sortIndex;return be!==0?be:le.id-pe.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,g=null,v=3,_=!1,b=!1,j=!1,w=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function A(le){for(var pe=r(u);pe!==null;){if(pe.callback===null)n(u);else if(pe.startTime<=le)n(u),pe.sortIndex=pe.expirationTime,s(d,pe);else break;pe=r(u)}}function I(le){if(j=!1,A(le),!b)if(r(d)!==null)b=!0,ie(L);else{var pe=r(u);pe!==null&&ae(I,pe.startTime-le)}}function L(le,pe){b=!1,j&&(j=!1,N(q),q=-1),_=!0;var be=v;try{for(A(pe),g=r(d);g!==null&&(!(g.expirationTime>pe)||le&&!X());){var ye=g.callback;if(typeof ye=="function"){g.callback=null,v=g.priorityLevel;var we=ye(g.expirationTime<=pe);pe=t.unstable_now(),typeof we=="function"?g.callback=we:g===r(d)&&n(d),A(pe)}else n(d);g=r(d)}if(g!==null)var Ne=!0;else{var Ke=r(u);Ke!==null&&ae(I,Ke.startTime-pe),Ne=!1}return Ne}finally{g=null,v=be,_=!1}}var R=!1,$=null,q=-1,U=5,V=-1;function X(){return!(t.unstable_now()-Vle||125ye?(le.sortIndex=be,s(u,le),r(d)===null&&le===r(u)&&(j?(N(q),q=-1):j=!0,ae(I,be-ye))):(le.sortIndex=we,s(d,le),b||_||(b=!0,ie(L))),le},t.unstable_shouldYield=X,t.unstable_wrapCallback=function(le){var pe=v;return function(){var be=v;v=pe;try{return le.apply(this,arguments)}finally{v=be}}}})(zDe);FDe.exports=zDe;var Ent=FDe.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 Pnt=S,bp=Ent;function Wr(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"),Dpe=Object.prototype.hasOwnProperty,Int=/^[: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]*$/,BSe={},$Se={};function Lnt(t){return Dpe.call($Se,t)?!0:Dpe.call(BSe,t)?!1:Int.test(t)?$Se[t]=!0:(BSe[t]=!0,!1)}function Dnt(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 Ont(t,s,r,n){if(s===null||typeof s>"u"||Dnt(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 Zh(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 Bu={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Bu[t]=new Zh(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];Bu[s]=new Zh(s,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Bu[t]=new Zh(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Bu[t]=new Zh(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){Bu[t]=new Zh(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Bu[t]=new Zh(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Bu[t]=new Zh(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Bu[t]=new Zh(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Bu[t]=new Zh(t,5,!1,t.toLowerCase(),null,!1,!1)});var eve=/[\-:]([a-z])/g;function tve(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(eve,tve);Bu[s]=new Zh(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(eve,tve);Bu[s]=new Zh(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(eve,tve);Bu[s]=new Zh(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Bu[t]=new Zh(t,1,!1,t.toLowerCase(),null,!1,!1)});Bu.xlinkHref=new Zh("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Bu[t]=new Zh(t,1,!1,t.toLowerCase(),null,!0,!0)});function sve(t,s,r,n){var a=Bu.hasOwnProperty(s)?Bu[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{Iue=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?yE(t):""}function Rnt(t){switch(t.tag){case 5:return yE(t.type);case 16:return yE("Lazy");case 13:return yE("Suspense");case 19:return yE("SuspenseList");case 0:case 2:case 15:return t=Lue(t.type,!1),t;case 11:return t=Lue(t.type.render,!1),t;case 1:return t=Lue(t.type,!0),t;default:return""}}function zpe(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 N4:return"Fragment";case k4:return"Portal";case Ope:return"Profiler";case rve:return"StrictMode";case Rpe:return"Suspense";case Fpe:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case qDe:return(t.displayName||"Context")+".Consumer";case $De:return(t._context.displayName||"Context")+".Provider";case nve:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ave:return s=t.displayName||null,s!==null?s:zpe(t.type)||"Memo";case r1:s=t._payload,t=t._init;try{return zpe(t(s))}catch{}}return null}function Fnt(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 zpe(s);case 8:return s===rve?"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 v_(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function VDe(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function znt(t){var s=VDe(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 QO(t){t._valueTracker||(t._valueTracker=znt(t))}function HDe(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var r=s.getValue(),n="";return t&&(n=VDe(t)?t.checked?"true":"false":t.value),t=n,t!==r?(s.setValue(t),!0):!1}function jre(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 Bpe(t,s){var r=s.checked;return Cc({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function USe(t,s){var r=s.defaultValue==null?"":s.defaultValue,n=s.checked!=null?s.checked:s.defaultChecked;r=v_(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 WDe(t,s){s=s.checked,s!=null&&sve(t,"checked",s,!1)}function $pe(t,s){WDe(t,s);var r=v_(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")?qpe(t,s.type,r):s.hasOwnProperty("defaultValue")&&qpe(t,s.type,v_(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function VSe(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 qpe(t,s,r){(s!=="number"||jre(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var vE=Array.isArray;function K4(t,s,r,n){if(t=t.options,s){s={};for(var a=0;a"+s.valueOf().toString()+"",s=JO.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function vI(t,s){if(s){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=s;return}}t.textContent=s}var DE={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},Bnt=["Webkit","ms","Moz","O"];Object.keys(DE).forEach(function(t){Bnt.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),DE[s]=DE[t]})});function YDe(t,s,r){return s==null||typeof s=="boolean"||s===""?"":r||typeof s!="number"||s===0||DE.hasOwnProperty(t)&&DE[t]?(""+s).trim():s+"px"}function XDe(t,s){t=t.style;for(var r in s)if(s.hasOwnProperty(r)){var n=r.indexOf("--")===0,a=YDe(r,s[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,a):t[r]=a}}var $nt=Cc({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 Hpe(t,s){if(s){if($nt[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(Wr(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(Wr(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(Wr(61))}if(s.style!=null&&typeof s.style!="object")throw Error(Wr(62))}}function Wpe(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 Gpe=null;function ive(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Kpe=null,Z4=null,Y4=null;function GSe(t){if(t=aL(t)){if(typeof Kpe!="function")throw Error(Wr(280));var s=t.stateNode;s&&(s=Fie(s),Kpe(t.stateNode,t.type,s))}}function QDe(t){Z4?Y4?Y4.push(t):Y4=[t]:Z4=t}function JDe(){if(Z4){var t=Z4,s=Y4;if(Y4=Z4=null,GSe(t),s)for(t=0;t>>=0,t===0?32:31-(Qnt(t)/Jnt|0)|0}var e8=64,t8=4194304;function _E(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 Cre(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=_E(i):(o&=l,o!==0&&(n=_E(o)))}else l=r&~a,l!==0?n=_E(l):o!==0&&(n=_E(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 rL(t,s,r){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-Ig(s),t[s]=r}function rat(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=RE),sCe=" ",rCe=!1;function vOe(t,s){switch(t){case"keyup":return Eat.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function _Oe(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var S4=!1;function Iat(t,s){switch(t){case"compositionend":return _Oe(s);case"keypress":return s.which!==32?null:(rCe=!0,sCe);case"textInput":return t=s.data,t===sCe&&rCe?null:t;default:return null}}function Lat(t,s){if(S4)return t==="compositionend"||!pve&&vOe(t,s)?(t=xOe(),LR=uve=E1=null,S4=!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=oCe(r)}}function kOe(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?kOe(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function NOe(){for(var t=window,s=jre();s instanceof t.HTMLIFrameElement;){try{var r=typeof s.contentWindow.location.href=="string"}catch{r=!1}if(r)t=s.contentWindow;else break;s=jre(t.document)}return s}function fve(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 Uat(t){var s=NOe(),r=t.focusedElem,n=t.selectionRange;if(s!==r&&r&&r.ownerDocument&&kOe(r.ownerDocument.documentElement,r)){if(n!==null&&fve(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=lCe(r,o);var l=lCe(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,C4=null,efe=null,zE=null,tfe=!1;function cCe(t,s,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;tfe||C4==null||C4!==jre(n)||(n=C4,"selectionStart"in n&&fve(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}),zE&&NI(zE,n)||(zE=n,n=Are(efe,"onSelect"),0A4||(t.current=ofe[A4],ofe[A4]=null,A4--)}function Ml(t,s){A4++,ofe[A4]=t.current,t.current=s}var __={},rh=I_(__),Nm=I_(!1),vN=__;function e3(t,s){var r=t.type.contextTypes;if(!r)return __;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 Sm(t){return t=t.childContextTypes,t!=null}function Pre(){Jl(Nm),Jl(rh)}function gCe(t,s,r){if(rh.current!==__)throw Error(Wr(168));Ml(rh,s),Ml(Nm,r)}function LOe(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(Wr(108,Fnt(t)||"Unknown",a));return Cc({},r,n)}function Ire(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||__,vN=rh.current,Ml(rh,t),Ml(Nm,Nm.current),!0}function xCe(t,s,r){var n=t.stateNode;if(!n)throw Error(Wr(169));r?(t=LOe(t,s,vN),n.__reactInternalMemoizedMergedChildContext=t,Jl(Nm),Jl(rh),Ml(rh,t)):Jl(Nm),Ml(Nm,r)}var r0=null,zie=!1,Kue=!1;function DOe(t){r0===null?r0=[t]:r0.push(t)}function tit(t){zie=!0,DOe(t)}function L_(){if(!Kue&&r0!==null){Kue=!0;var t=0,s=sl;try{var r=r0;for(sl=1;t>=l,a-=l,p0=1<<32-Ig(s)+a|r<q?(U=$,$=null):U=$.sibling;var V=v(N,$,A[q],I);if(V===null){$===null&&($=U);break}t&&$&&V.alternate===null&&s(N,$),C=o(V,C,q),R===null?L=V:R.sibling=V,R=V,$=U}if(q===A.length)return r(N,$),hc&&Qb(N,q),L;if($===null){for(;qq?(U=$,$=null):U=$.sibling;var X=v(N,$,V.value,I);if(X===null){$===null&&($=U);break}t&&$&&X.alternate===null&&s(N,$),C=o(X,C,q),R===null?L=X:R.sibling=X,R=X,$=U}if(V.done)return r(N,$),hc&&Qb(N,q),L;if($===null){for(;!V.done;q++,V=A.next())V=g(N,V.value,I),V!==null&&(C=o(V,C,q),R===null?L=V:R.sibling=V,R=V);return hc&&Qb(N,q),L}for($=n(N,$);!V.done;q++,V=A.next())V=_($,N,q,V.value,I),V!==null&&(t&&V.alternate!==null&&$.delete(V.key===null?q:V.key),C=o(V,C,q),R===null?L=V:R.sibling=V,R=V);return t&&$.forEach(function(se){return s(N,se)}),hc&&Qb(N,q),L}function w(N,C,A,I){if(typeof A=="object"&&A!==null&&A.type===N4&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case XO:e:{for(var L=A.key,R=C;R!==null;){if(R.key===L){if(L=A.type,L===N4){if(R.tag===7){r(N,R.sibling),C=a(R,A.props.children),C.return=N,N=C;break e}}else if(R.elementType===L||typeof L=="object"&&L!==null&&L.$$typeof===r1&&_Ce(L)===R.type){r(N,R.sibling),C=a(R,A.props),C.ref=BA(N,R,A),C.return=N,N=C;break e}r(N,R);break}else s(N,R);R=R.sibling}A.type===N4?(C=Zk(A.props.children,N.mode,I,A.key),C.return=N,N=C):(I=qR(A.type,A.key,A.props,null,N.mode,I),I.ref=BA(N,C,A),I.return=N,N=I)}return l(N);case k4:e:{for(R=A.key;C!==null;){if(C.key===R)if(C.tag===4&&C.stateNode.containerInfo===A.containerInfo&&C.stateNode.implementation===A.implementation){r(N,C.sibling),C=a(C,A.children||[]),C.return=N,N=C;break e}else{r(N,C);break}else s(N,C);C=C.sibling}C=she(A,N.mode,I),C.return=N,N=C}return l(N);case r1:return R=A._init,w(N,C,R(A._payload),I)}if(vE(A))return b(N,C,A,I);if(DA(A))return j(N,C,A,I);l8(N,A)}return typeof A=="string"&&A!==""||typeof A=="number"?(A=""+A,C!==null&&C.tag===6?(r(N,C.sibling),C=a(C,A),C.return=N,N=C):(r(N,C),C=the(A,N.mode,I),C.return=N,N=C),l(N)):r(N,C)}return w}var s3=zOe(!0),BOe=zOe(!1),Ore=I_(null),Rre=null,I4=null,vve=null;function _ve(){vve=I4=Rre=null}function bve(t){var s=Ore.current;Jl(Ore),t._currentValue=s}function dfe(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 Q4(t,s){Rre=t,vve=I4=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&s&&(vm=!0),t.firstContext=null)}function _f(t){var s=t._currentValue;if(vve!==t)if(t={context:t,memoizedValue:s,next:null},I4===null){if(Rre===null)throw Error(Wr(308));I4=t,Rre.dependencies={lanes:0,firstContext:t}}else I4=I4.next=t;return s}var wk=null;function wve(t){wk===null?wk=[t]:wk.push(t)}function $Oe(t,s,r,n){var a=s.interleaved;return a===null?(r.next=r,wve(s)):(r.next=a.next,a.next=r),s.interleaved=r,U0(t,n)}function U0(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 n1=!1;function jve(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function qOe(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 b0(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function H1(t,s,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,ko&2){var a=n.pending;return a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s,U0(t,r)}return a=n.interleaved,a===null?(s.next=s,wve(n)):(s.next=a.next,a.next=s),n.interleaved=s,U0(t,r)}function OR(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,lve(t,r)}}function bCe(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 Fre(t,s,r,n){var a=t.updateQueue;n1=!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 g=a.baseState;l=0,p=u=d=null,i=o;do{var v=i.lane,_=i.eventTime;if((n&v)===v){p!==null&&(p=p.next={eventTime:_,lane:0,tag:i.tag,payload:i.payload,callback:i.callback,next:null});e:{var b=t,j=i;switch(v=s,_=r,j.tag){case 1:if(b=j.payload,typeof b=="function"){g=b.call(_,g,v);break e}g=b;break e;case 3:b.flags=b.flags&-65537|128;case 0:if(b=j.payload,v=typeof b=="function"?b.call(_,g,v):b,v==null)break e;g=Cc({},g,v);break e;case 2:n1=!0}}i.callback!==null&&i.lane!==0&&(t.flags|=64,v=a.effects,v===null?a.effects=[i]:v.push(i))}else _={eventTime:_,lane:v,tag:i.tag,payload:i.payload,callback:i.callback,next:null},p===null?(u=p=_,d=g):p=p.next=_,l|=v;if(i=i.next,i===null){if(i=a.shared.pending,i===null)break;v=i,i=v.next,v.next=null,a.lastBaseUpdate=v,a.shared.pending=null}}while(!0);if(p===null&&(d=g),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);wN|=l,t.lanes=l,t.memoizedState=g}}function wCe(t,s,r){if(t=s.effects,s.effects=null,t!==null)for(s=0;sr?r:4,t(!0);var n=Yue.transition;Yue.transition={};try{t(!1),s()}finally{sl=r,Yue.transition=n}}function a8e(){return bf().memoizedState}function ait(t,s,r){var n=G1(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},i8e(t))o8e(s,r);else if(r=$Oe(t,s,r,n),r!==null){var a=Fh();Lg(r,t,n,a),l8e(r,s,n)}}function iit(t,s,r){var n=G1(t),a={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(i8e(t))o8e(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,$g(i,l)){var d=s.interleaved;d===null?(a.next=a,wve(s)):(a.next=d.next,d.next=a),s.interleaved=a;return}}catch{}finally{}r=$Oe(t,s,a,n),r!==null&&(a=Fh(),Lg(r,t,n,a),l8e(r,s,n))}}function i8e(t){var s=t.alternate;return t===Nc||s!==null&&s===Nc}function o8e(t,s){BE=Bre=!0;var r=t.pending;r===null?s.next=s:(s.next=r.next,r.next=s),t.pending=s}function l8e(t,s,r){if(r&4194240){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,lve(t,r)}}var $re={readContext:_f,useCallback:Hu,useContext:Hu,useEffect:Hu,useImperativeHandle:Hu,useInsertionEffect:Hu,useLayoutEffect:Hu,useMemo:Hu,useReducer:Hu,useRef:Hu,useState:Hu,useDebugValue:Hu,useDeferredValue:Hu,useTransition:Hu,useMutableSource:Hu,useSyncExternalStore:Hu,useId:Hu,unstable_isNewReconciler:!1},oit={readContext:_f,useCallback:function(t,s){return bx().memoizedState=[t,s===void 0?null:s],t},useContext:_f,useEffect:kCe,useImperativeHandle:function(t,s,r){return r=r!=null?r.concat([t]):null,FR(4194308,4,e8e.bind(null,s,t),r)},useLayoutEffect:function(t,s){return FR(4194308,4,t,s)},useInsertionEffect:function(t,s){return FR(4,2,t,s)},useMemo:function(t,s){var r=bx();return s=s===void 0?null:s,t=t(),r.memoizedState=[t,s],t},useReducer:function(t,s,r){var n=bx();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=ait.bind(null,Nc,t),[n.memoizedState,t]},useRef:function(t){var s=bx();return t={current:t},s.memoizedState=t},useState:jCe,useDebugValue:Eve,useDeferredValue:function(t){return bx().memoizedState=t},useTransition:function(){var t=jCe(!1),s=t[0];return t=nit.bind(null,t[1]),bx().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,r){var n=Nc,a=bx();if(hc){if(r===void 0)throw Error(Wr(407));r=r()}else{if(r=s(),uu===null)throw Error(Wr(349));bN&30||WOe(n,s,r)}a.memoizedState=r;var o={value:r,getSnapshot:s};return a.queue=o,kCe(KOe.bind(null,n,o,t),[t]),n.flags|=2048,II(9,GOe.bind(null,n,o,r,s),void 0,null),r},useId:function(){var t=bx(),s=uu.identifierPrefix;if(hc){var r=f0,n=p0;r=(n&~(1<<32-Ig(n)-1)).toString(32)+r,s=":"+s+"R"+r,r=EI++,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[Px]=s,t[MI]=n,y8e(t,s,!1,!1),s.stateNode=t;e:{switch(l=Wpe(r,n),r){case"dialog":Gl("cancel",t),Gl("close",t),a=n;break;case"iframe":case"object":case"embed":Gl("load",t),a=n;break;case"video":case"audio":for(a=0;aa3&&(s.flags|=128,n=!0,$A(o,!1),s.lanes=4194304)}else{if(!n)if(t=zre(l),t!==null){if(s.flags|=128,n=!0,r=t.updateQueue,r!==null&&(s.updateQueue=r,s.flags|=4),$A(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!hc)return Wu(s),null}else 2*rd()-o.renderingStartTime>a3&&r!==1073741824&&(s.flags|=128,n=!0,$A(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=bc.current,Ml(bc,n?r&1|2:r&1),s):(Wu(s),null);case 22:case 23:return Rve(),n=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(s.flags|=8192),n&&s.mode&1?tp&1073741824&&(Wu(s),s.subtreeFlags&6&&(s.flags|=8192)):Wu(s),null;case 24:return null;case 25:return null}throw Error(Wr(156,s.tag))}function fit(t,s){switch(xve(s),s.tag){case 1:return Sm(s.type)&&Pre(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return r3(),Jl(Nm),Jl(rh),Sve(),t=s.flags,t&65536&&!(t&128)?(s.flags=t&-65537|128,s):null;case 5:return Nve(s),null;case 13:if(Jl(bc),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(Wr(340));t3()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return Jl(bc),null;case 4:return r3(),null;case 10:return bve(s.type._context),null;case 22:case 23:return Rve(),null;case 24:return null;default:return null}}var d8=!1,Yu=!1,git=typeof WeakSet=="function"?WeakSet:Set,Yn=null;function L4(t,s){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){Rc(t,s,n)}else r.current=null}function vfe(t,s,r){try{r()}catch(n){Rc(t,s,n)}}var DCe=!1;function xit(t,s){if(sfe=Mre,t=NOe(),fve(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,g=t,v=null;t:for(;;){for(var _;g!==r||a!==0&&g.nodeType!==3||(i=l+a),g!==o||n!==0&&g.nodeType!==3||(d=l+n),g.nodeType===3&&(l+=g.nodeValue.length),(_=g.firstChild)!==null;)v=g,g=_;for(;;){if(g===t)break t;if(v===r&&++u===a&&(i=l),v===o&&++p===n&&(d=l),(_=g.nextSibling)!==null)break;g=v,v=g.parentNode}g=_}r=i===-1||d===-1?null:{start:i,end:d}}else r=null}r=r||{start:0,end:0}}else r=null;for(rfe={focusedElem:t,selectionRange:r},Mre=!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 j=b.memoizedProps,w=b.memoizedState,N=s.stateNode,C=N.getSnapshotBeforeUpdate(s.elementType===s.type?j:gg(s.type,j),w);N.__reactInternalSnapshotBeforeUpdate=C}break;case 3:var A=s.stateNode.containerInfo;A.nodeType===1?A.textContent="":A.nodeType===9&&A.documentElement&&A.removeChild(A.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Wr(163))}}catch(I){Rc(s,s.return,I)}if(t=s.sibling,t!==null){t.return=s.return,Yn=t;break}Yn=s.return}return b=DCe,DCe=!1,b}function $E(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&&vfe(s,r,o)}a=a.next}while(a!==n)}}function qie(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 _fe(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[Px],delete s[MI],delete s[ife],delete s[Jat],delete s[eit])),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 w8e(t){return t.tag===5||t.tag===3||t.tag===4}function OCe(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||w8e(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 bfe(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=Ere));else if(n!==4&&(t=t.child,t!==null))for(bfe(t,s,r),t=t.sibling;t!==null;)bfe(t,s,r),t=t.sibling}function wfe(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(wfe(t,s,r),t=t.sibling;t!==null;)wfe(t,s,r),t=t.sibling}var Tu=null,_g=!1;function Vv(t,s,r){for(r=r.child;r!==null;)j8e(t,s,r),r=r.sibling}function j8e(t,s,r){if(zx&&typeof zx.onCommitFiberUnmount=="function")try{zx.onCommitFiberUnmount(Lie,r)}catch{}switch(r.tag){case 5:Yu||L4(r,s);case 6:var n=Tu,a=_g;Tu=null,Vv(t,s,r),Tu=n,_g=a,Tu!==null&&(_g?(t=Tu,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):Tu.removeChild(r.stateNode));break;case 18:Tu!==null&&(_g?(t=Tu,r=r.stateNode,t.nodeType===8?Gue(t.parentNode,r):t.nodeType===1&&Gue(t,r),jI(t)):Gue(Tu,r.stateNode));break;case 4:n=Tu,a=_g,Tu=r.stateNode.containerInfo,_g=!0,Vv(t,s,r),Tu=n,_g=a;break;case 0:case 11:case 14:case 15:if(!Yu&&(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)&&vfe(r,s,l),a=a.next}while(a!==n)}Vv(t,s,r);break;case 1:if(!Yu&&(L4(r,s),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(i){Rc(r,s,i)}Vv(t,s,r);break;case 21:Vv(t,s,r);break;case 22:r.mode&1?(Yu=(n=Yu)||r.memoizedState!==null,Vv(t,s,r),Yu=n):Vv(t,s,r);break;default:Vv(t,s,r)}}function RCe(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new git),s.forEach(function(n){var a=Sit.bind(null,t,n);r.has(n)||(r.add(n),n.then(a,a))})}}function og(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*vit(n/1960))-n,10t?16:t,P1===null)var n=!1;else{if(t=P1,P1=null,Vre=0,ko&6)throw Error(Wr(331));var a=ko;for(ko|=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()-Dve?Kk(t,0):Lve|=r),Cm(t,s)}function E8e(t,s){s===0&&(t.mode&1?(s=t8,t8<<=1,!(t8&130023424)&&(t8=4194304)):s=1);var r=Fh();t=U0(t,s),t!==null&&(rL(t,s,r),Cm(t,r))}function Nit(t){var s=t.memoizedState,r=0;s!==null&&(r=s.retryLane),E8e(t,r)}function Sit(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(Wr(314))}n!==null&&n.delete(s),E8e(t,r)}var P8e;P8e=function(t,s,r){if(t!==null)if(t.memoizedProps!==s.pendingProps||Nm.current)vm=!0;else{if(!(t.lanes&r)&&!(s.flags&128))return vm=!1,mit(t,s,r);vm=!!(t.flags&131072)}else vm=!1,hc&&s.flags&1048576&&OOe(s,Dre,s.index);switch(s.lanes=0,s.tag){case 2:var n=s.type;zR(t,s),t=s.pendingProps;var a=e3(s,rh.current);Q4(s,r),a=Mve(null,s,n,t,a,r);var o=Tve();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,Sm(n)?(o=!0,Ire(s)):o=!1,s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,jve(s),a.updater=$ie,s.stateNode=a,a._reactInternals=s,hfe(s,n,t,r),s=ffe(null,s,n,!0,o,r)):(s.tag=0,hc&&o&&gve(s),Nh(null,s,a,r),s=s.child),s;case 16:n=s.elementType;e:{switch(zR(t,s),t=s.pendingProps,a=n._init,n=a(n._payload),s.type=n,a=s.tag=Mit(n),t=gg(n,t),a){case 0:s=pfe(null,s,n,t,r);break e;case 1:s=PCe(null,s,n,t,r);break e;case 11:s=ACe(null,s,n,t,r);break e;case 14:s=ECe(null,s,n,gg(n.type,t),r);break e}throw Error(Wr(306,n,""))}return s;case 0:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:gg(n,a),pfe(t,s,n,a,r);case 1:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:gg(n,a),PCe(t,s,n,a,r);case 3:e:{if(f8e(s),t===null)throw Error(Wr(387));n=s.pendingProps,o=s.memoizedState,a=o.element,qOe(t,s),Fre(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=n3(Error(Wr(423)),s),s=ICe(t,s,n,r,a);break e}else if(n!==a){a=n3(Error(Wr(424)),s),s=ICe(t,s,n,r,a);break e}else for(dp=V1(s.stateNode.containerInfo.firstChild),hp=s,hc=!0,Ng=null,r=BOe(s,null,n,r),s.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(t3(),n===a){s=V0(t,s,r);break e}Nh(t,s,n,r)}s=s.child}return s;case 5:return UOe(s),t===null&&cfe(s),n=s.type,a=s.pendingProps,o=t!==null?t.memoizedProps:null,l=a.children,nfe(n,a)?l=null:o!==null&&nfe(n,o)&&(s.flags|=32),p8e(t,s),Nh(t,s,l,r),s.child;case 6:return t===null&&cfe(s),null;case 13:return g8e(t,s,r);case 4:return kve(s,s.stateNode.containerInfo),n=s.pendingProps,t===null?s.child=s3(s,null,n,r):Nh(t,s,n,r),s.child;case 11:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:gg(n,a),ACe(t,s,n,a,r);case 7:return Nh(t,s,s.pendingProps,r),s.child;case 8:return Nh(t,s,s.pendingProps.children,r),s.child;case 12:return Nh(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,Ml(Ore,n._currentValue),n._currentValue=l,o!==null)if($g(o.value,l)){if(o.children===a.children&&!Nm.current){s=V0(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=b0(-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),dfe(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(Wr(341));l.lanes|=r,i=l.alternate,i!==null&&(i.lanes|=r),dfe(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}Nh(t,s,a.children,r),s=s.child}return s;case 9:return a=s.type,n=s.pendingProps.children,Q4(s,r),a=_f(a),n=n(a),s.flags|=1,Nh(t,s,n,r),s.child;case 14:return n=s.type,a=gg(n,s.pendingProps),a=gg(n.type,a),ECe(t,s,n,a,r);case 15:return h8e(t,s,s.type,s.pendingProps,r);case 17:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:gg(n,a),zR(t,s),s.tag=1,Sm(n)?(t=!0,Ire(s)):t=!1,Q4(s,r),c8e(s,n,a),hfe(s,n,a,r),ffe(null,s,n,!0,t,r);case 19:return x8e(t,s,r);case 22:return m8e(t,s,r)}throw Error(Wr(156,s.tag))};function I8e(t,s){return iOe(t,s)}function Cit(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 nf(t,s,r,n){return new Cit(t,s,r,n)}function zve(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Mit(t){if(typeof t=="function")return zve(t)?1:0;if(t!=null){if(t=t.$$typeof,t===nve)return 11;if(t===ave)return 14}return 2}function K1(t,s){var r=t.alternate;return r===null?(r=nf(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 qR(t,s,r,n,a,o){var l=2;if(n=t,typeof t=="function")zve(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case N4:return Zk(r.children,a,o,s);case rve:l=8,a|=8;break;case Ope:return t=nf(12,r,s,a|2),t.elementType=Ope,t.lanes=o,t;case Rpe:return t=nf(13,r,s,a),t.elementType=Rpe,t.lanes=o,t;case Fpe:return t=nf(19,r,s,a),t.elementType=Fpe,t.lanes=o,t;case UDe:return Vie(r,a,o,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case $De:l=10;break e;case qDe:l=9;break e;case nve:l=11;break e;case ave:l=14;break e;case r1:l=16,n=null;break e}throw Error(Wr(130,t==null?t:typeof t,""))}return s=nf(l,r,s,a),s.elementType=t,s.type=n,s.lanes=o,s}function Zk(t,s,r,n){return t=nf(7,t,n,s),t.lanes=r,t}function Vie(t,s,r,n){return t=nf(22,t,n,s),t.elementType=UDe,t.lanes=r,t.stateNode={isHidden:!1},t}function the(t,s,r){return t=nf(6,t,null,s),t.lanes=r,t}function she(t,s,r){return s=nf(4,t.children!==null?t.children:[],t.key,s),s.lanes=r,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function Tit(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=Oue(0),this.expirationTimes=Oue(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Oue(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function Bve(t,s,r,n,a,o,l,i,d){return t=new Tit(t,s,r,i,d),s===1?(s=1,o===!0&&(s|=8)):s=0,o=nf(3,null,null,s),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},jve(o),t}function Ait(t,s,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(R8e)}catch(t){console.error(t)}}R8e(),RDe.exports=jp;var _m=RDe.exports;const Vve=_o(_m);var F8e,HCe=_m;F8e=HCe.createRoot,HCe.hydrateRoot;const Dit="modulepreload",Oit=function(t){return"/"+t},WCe={},ev=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=Oit(d),d in WCe)return;WCe[d]=!0;const u=d.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const g=document.createElement("link");if(g.rel=u?"stylesheet":Dit,u||(g.as="script"),g.crossOrigin="",g.href=d,i&&g.setAttribute("nonce",i),document.head.appendChild(g),u)return new Promise((v,_)=>{g.addEventListener("load",v),g.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)})},Rit=1,Fit=1e6;let rhe=0;function zit(){return rhe=(rhe+1)%Number.MAX_SAFE_INTEGER,rhe.toString()}const nhe=new Map,GCe=t=>{if(nhe.has(t))return;const s=setTimeout(()=>{nhe.delete(t),VE({type:"REMOVE_TOAST",toastId:t})},Fit);nhe.set(t,s)},Bit=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,Rit)};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?GCe(r):t.toasts.forEach(n=>{GCe(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)}}},UR=[];let VR={toasts:[]};function VE(t){VR=Bit(VR,t),UR.forEach(s=>{s(VR)})}function an({...t}){const s=zit(),r=a=>VE({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>VE({type:"DISMISS_TOAST",toastId:s});return VE({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function Ea(){const[t,s]=S.useState(VR);return S.useEffect(()=>(UR.push(s),()=>{const r=UR.indexOf(s);r>-1&&UR.splice(r,1)}),[t]),{...t,toast:an,dismiss:r=>VE({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 KCe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function H0(...t){return s=>{let r=!1;const n=t.map(a=>{const o=KCe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{children:l,...i}=o,d=S.useMemo(()=>i,Object.values(i));return e.jsx(r.Provider,{value:d,children:l})};n.displayName=t+"Provider";function a(o){const l=S.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 Tc(t,s=[]){let r=[];function n(o,l){const i=S.createContext(l),d=r.length;r=[...r,l];const u=g=>{var N;const{scope:v,children:_,...b}=g,j=((N=v==null?void 0:v[t])==null?void 0:N[d])||i,w=S.useMemo(()=>b,Object.values(b));return e.jsx(j.Provider,{value:w,children:_})};u.displayName=o+"Provider";function p(g,v){var j;const _=((j=v==null?void 0:v[t])==null?void 0:j[d])||i,b=S.useContext(_);if(b)return b;if(l!==void 0)return l;throw new Error(`\`${g}\` must be used within \`${o}\``)}return[u,p]}const a=()=>{const o=r.map(l=>S.createContext(l));return function(i){const d=(i==null?void 0:i[t])||o;return S.useMemo(()=>({[`__scope${t}`]:{...i,[t]:d}}),[i,d])}};return a.scopeName=t,[n,qit(a,...s)]}function qit(...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 g=d(o)[`__scope${u}`];return{...i,...g}},{});return S.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return r.scopeName=s.scopeName,r}function b_(t){const s=Uit(t),r=S.forwardRef((n,a)=>{const{children:o,...l}=n,i=S.Children.toArray(o),d=i.find(Vit);if(d){const u=d.props.children,p=i.map(g=>g===d?S.Children.count(u)>1?S.Children.only(null):S.isValidElement(u)?u.props.children:null:g);return e.jsx(s,{...l,ref:a,children:S.isValidElement(u)?S.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}var Hve=b_("Slot");function Uit(t){const s=S.forwardRef((r,n)=>{const{children:a,...o}=r;if(S.isValidElement(a)){const l=Wit(a),i=Hit(o,a.props);return a.type!==S.Fragment&&(i.ref=n?H0(n,l):l),S.cloneElement(a,i)}return S.Children.count(a)>1?S.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var z8e=Symbol("radix.slottable");function B8e(t){const s=({children:r})=>e.jsx(e.Fragment,{children:r});return s.displayName=`${t}.Slottable`,s.__radixId=z8e,s}function Vit(t){return S.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===z8e}function Hit(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 Wit(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 oL(t){const s=t+"CollectionProvider",[r,n]=Tc(s),[a,o]=r(s,{collectionRef:{current:null},itemMap:new Map}),l=j=>{const{scope:w,children:N}=j,C=ht.useRef(null),A=ht.useRef(new Map).current;return e.jsx(a,{scope:w,itemMap:A,collectionRef:C,children:N})};l.displayName=s;const i=t+"CollectionSlot",d=b_(i),u=ht.forwardRef((j,w)=>{const{scope:N,children:C}=j,A=o(i,N),I=Aa(w,A.collectionRef);return e.jsx(d,{ref:I,children:C})});u.displayName=i;const p=t+"CollectionItemSlot",g="data-radix-collection-item",v=b_(p),_=ht.forwardRef((j,w)=>{const{scope:N,children:C,...A}=j,I=ht.useRef(null),L=Aa(w,I),R=o(p,N);return ht.useEffect(()=>(R.itemMap.set(I,{ref:I,...A}),()=>void R.itemMap.delete(I))),e.jsx(v,{[g]:"",ref:L,children:C})});_.displayName=p;function b(j){const w=o(t+"CollectionConsumer",j);return ht.useCallback(()=>{const C=w.collectionRef.current;if(!C)return[];const A=Array.from(C.querySelectorAll(`[${g}]`));return Array.from(w.itemMap.values()).sort((R,$)=>A.indexOf(R.ref.current)-A.indexOf($.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:l,Slot:u,ItemSlot:_},b,n]}var Git=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Qr=Git.reduce((t,s)=>{const r=b_(`Primitive.${s}`),n=S.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 Wve(t,s){t&&_m.flushSync(()=>t.dispatchEvent(s))}function Uc(t){const s=S.useRef(t);return S.useEffect(()=>{s.current=t}),S.useMemo(()=>(...r)=>{var n;return(n=s.current)==null?void 0:n.call(s,...r)},[])}function Kit(t,s=globalThis==null?void 0:globalThis.document){const r=Uc(t);S.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 Zit="DismissableLayer",Cfe="dismissableLayer.update",Yit="dismissableLayer.pointerDownOutside",Xit="dismissableLayer.focusOutside",ZCe,$8e=S.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),D_=S.forwardRef((t,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:i,...d}=t,u=S.useContext($8e),[p,g]=S.useState(null),v=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,_]=S.useState({}),b=Aa(s,$=>g($)),j=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),N=j.indexOf(w),C=p?j.indexOf(p):-1,A=u.layersWithOutsidePointerEventsDisabled.size>0,I=C>=N,L=Jit($=>{const q=$.target,U=[...u.branches].some(V=>V.contains(q));!I||U||(a==null||a($),l==null||l($),$.defaultPrevented||i==null||i())},v),R=eot($=>{const q=$.target;[...u.branches].some(V=>V.contains(q))||(o==null||o($),l==null||l($),$.defaultPrevented||i==null||i())},v);return Kit($=>{C===u.layers.size-1&&(n==null||n($),!$.defaultPrevented&&i&&($.preventDefault(),i()))},v),S.useEffect(()=>{if(p)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(ZCe=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),YCe(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=ZCe)}},[p,v,r,u]),S.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),YCe())},[p,u]),S.useEffect(()=>{const $=()=>_({});return document.addEventListener(Cfe,$),()=>document.removeEventListener(Cfe,$)},[]),e.jsx(Qr.div,{...d,ref:b,style:{pointerEvents:A?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)})});D_.displayName=Zit;var Qit="DismissableLayerBranch",q8e=S.forwardRef((t,s)=>{const r=S.useContext($8e),n=S.useRef(null),a=Aa(s,n);return S.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})});q8e.displayName=Qit;function Jit(t,s=globalThis==null?void 0:globalThis.document){const r=Uc(t),n=S.useRef(!1),a=S.useRef(()=>{});return S.useEffect(()=>{const o=i=>{if(i.target&&!n.current){let d=function(){U8e(Yit,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 eot(t,s=globalThis==null?void 0:globalThis.document){const r=Uc(t),n=S.useRef(!1);return S.useEffect(()=>{const a=o=>{o.target&&!n.current&&U8e(Xit,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 YCe(){const t=new CustomEvent(Cfe);document.dispatchEvent(t)}function U8e(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?Wve(a,o):a.dispatchEvent(o)}var tot=D_,sot=q8e,Kc=globalThis!=null&&globalThis.document?S.useLayoutEffect:()=>{},rot="Portal",sM=S.forwardRef((t,s)=>{var i;const{container:r,...n}=t,[a,o]=S.useState(!1);Kc(()=>o(!0),[]);const l=r||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return l?Vve.createPortal(e.jsx(Qr.div,{...n,ref:s}),l):null});sM.displayName=rot;function not(t,s){return S.useReducer((r,n)=>s[r][n]??r,t)}var ud=t=>{const{present:s,children:r}=t,n=aot(s),a=typeof r=="function"?r({present:n.isPresent}):S.Children.only(r),o=Aa(n.ref,iot(a));return typeof r=="function"||n.isPresent?S.cloneElement(a,{ref:o}):null};ud.displayName="Presence";function aot(t){const[s,r]=S.useState(),n=S.useRef(null),a=S.useRef(t),o=S.useRef("none"),l=t?"mounted":"unmounted",[i,d]=not(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return S.useEffect(()=>{const u=m8(n.current);o.current=i==="mounted"?u:"none"},[i]),Kc(()=>{const u=n.current,p=a.current;if(p!==t){const v=o.current,_=m8(u);t?d("MOUNT"):_==="none"||(u==null?void 0:u.display)==="none"?d("UNMOUNT"):d(p&&v!==_?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,d]),Kc(()=>{if(s){let u;const p=s.ownerDocument.defaultView??window,g=_=>{const j=m8(n.current).includes(_.animationName);if(_.target===s&&j&&(d("ANIMATION_END"),!a.current)){const w=s.style.animationFillMode;s.style.animationFillMode="forwards",u=p.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=w)})}},v=_=>{_.target===s&&(o.current=m8(n.current))};return s.addEventListener("animationstart",v),s.addEventListener("animationcancel",g),s.addEventListener("animationend",g),()=>{p.clearTimeout(u),s.removeEventListener("animationstart",v),s.removeEventListener("animationcancel",g),s.removeEventListener("animationend",g)}}else d("ANIMATION_END")},[s,d]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:S.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function m8(t){return(t==null?void 0:t.animationName)||"none"}function iot(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 oot=J0e[" useInsertionEffect ".trim().toString()]||Kc;function fu({prop:t,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,o,l]=lot({defaultProp:s,onChange:r}),i=t!==void 0,d=i?t:a;{const p=S.useRef(t!==void 0);S.useEffect(()=>{const g=p.current;g!==i&&console.warn(`${n} is changing from ${g?"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=S.useCallback(p=>{var g;if(i){const v=cot(p)?p(t):p;v!==t&&((g=l.current)==null||g.call(l,v))}else o(p)},[i,t,o,l]);return[d,u]}function lot({defaultProp:t,onChange:s}){const[r,n]=S.useState(t),a=S.useRef(r),o=S.useRef(s);return oot(()=>{o.current=s},[s]),S.useEffect(()=>{var l;a.current!==r&&((l=o.current)==null||l.call(o,r),a.current=r)},[r,a]),[r,n,o]}function cot(t){return typeof t=="function"}var V8e=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"}),dot="VisuallyHidden",Zie=S.forwardRef((t,s)=>e.jsx(Qr.span,{...t,ref:s,style:{...V8e,...t.style}}));Zie.displayName=dot;var uot=Zie,Gve="ToastProvider",[Kve,hot,mot]=oL("Toast"),[H8e]=Tc("Toast",[mot]),[pot,Yie]=H8e(Gve),W8e=t=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:o=50,children:l}=t,[i,d]=S.useState(null),[u,p]=S.useState(0),g=S.useRef(!1),v=S.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${Gve}\`. Expected non-empty \`string\`.`),e.jsx(Kve.Provider,{scope:s,children:e.jsx(pot,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:u,viewport:i,onViewportChange:d,onToastAdd:S.useCallback(()=>p(_=>_+1),[]),onToastRemove:S.useCallback(()=>p(_=>_-1),[]),isFocusedToastEscapeKeyDownRef:g,isClosePausedRef:v,children:l})})};W8e.displayName=Gve;var G8e="ToastViewport",fot=["F8"],Mfe="toast.viewportPause",Tfe="toast.viewportResume",K8e=S.forwardRef((t,s)=>{const{__scopeToast:r,hotkey:n=fot,label:a="Notifications ({hotkey})",...o}=t,l=Yie(G8e,r),i=hot(r),d=S.useRef(null),u=S.useRef(null),p=S.useRef(null),g=S.useRef(null),v=Aa(s,g,l.onViewportChange),_=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),b=l.toastCount>0;S.useEffect(()=>{const w=N=>{var A;n.length!==0&&n.every(I=>N[I]||N.code===I)&&((A=g.current)==null||A.focus())};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[n]),S.useEffect(()=>{const w=d.current,N=g.current;if(b&&w&&N){const C=()=>{if(!l.isClosePausedRef.current){const R=new CustomEvent(Mfe);N.dispatchEvent(R),l.isClosePausedRef.current=!0}},A=()=>{if(l.isClosePausedRef.current){const R=new CustomEvent(Tfe);N.dispatchEvent(R),l.isClosePausedRef.current=!1}},I=R=>{!w.contains(R.relatedTarget)&&A()},L=()=>{w.contains(document.activeElement)||A()};return w.addEventListener("focusin",C),w.addEventListener("focusout",I),w.addEventListener("pointermove",C),w.addEventListener("pointerleave",L),window.addEventListener("blur",C),window.addEventListener("focus",A),()=>{w.removeEventListener("focusin",C),w.removeEventListener("focusout",I),w.removeEventListener("pointermove",C),w.removeEventListener("pointerleave",L),window.removeEventListener("blur",C),window.removeEventListener("focus",A)}}},[b,l.isClosePausedRef]);const j=S.useCallback(({tabbingDirection:w})=>{const C=i().map(A=>{const I=A.ref.current,L=[I,...Mot(I)];return w==="forwards"?L:L.reverse()});return(w==="forwards"?C.reverse():C).flat()},[i]);return S.useEffect(()=>{const w=g.current;if(w){const N=C=>{var L,R,$;const A=C.altKey||C.ctrlKey||C.metaKey;if(C.key==="Tab"&&!A){const q=document.activeElement,U=C.shiftKey;if(C.target===w&&U){(L=u.current)==null||L.focus();return}const se=j({tabbingDirection:U?"backwards":"forwards"}),te=se.findIndex(Y=>Y===q);ahe(se.slice(te+1))?C.preventDefault():U?(R=u.current)==null||R.focus():($=p.current)==null||$.focus()}};return w.addEventListener("keydown",N),()=>w.removeEventListener("keydown",N)}},[i,j]),e.jsxs(sot,{ref:d,role:"region","aria-label":a.replace("{hotkey}",_),tabIndex:-1,style:{pointerEvents:b?void 0:"none"},children:[b&&e.jsx(Afe,{ref:u,onFocusFromOutsideViewport:()=>{const w=j({tabbingDirection:"forwards"});ahe(w)}}),e.jsx(Kve.Slot,{scope:r,children:e.jsx(Qr.ol,{tabIndex:-1,...o,ref:v})}),b&&e.jsx(Afe,{ref:p,onFocusFromOutsideViewport:()=>{const w=j({tabbingDirection:"backwards"});ahe(w)}})]})});K8e.displayName=G8e;var Z8e="ToastFocusProxy",Afe=S.forwardRef((t,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=t,o=Yie(Z8e,r);return e.jsx(Zie,{"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()}})});Afe.displayName=Z8e;var lL="Toast",got="toast.swipeStart",xot="toast.swipeMove",yot="toast.swipeCancel",vot="toast.swipeEnd",Y8e=S.forwardRef((t,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:o,...l}=t,[i,d]=fu({prop:n,defaultProp:a??!0,onChange:o,caller:lL});return e.jsx(ud,{present:r||i,children:e.jsx(wot,{open:i,...l,ref:s,onClose:()=>d(!1),onPause:Uc(t.onPause),onResume:Uc(t.onResume),onSwipeStart:Mr(t.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Mr(t.onSwipeMove,u=>{const{x:p,y:g}=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",`${g}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:g}=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",`${g}px`),d(!1)})})})});Y8e.displayName=lL;var[_ot,bot]=H8e(lL,{onClose(){}}),wot=S.forwardRef((t,s)=>{const{__scopeToast:r,type:n="foreground",duration:a,open:o,onClose:l,onEscapeKeyDown:i,onPause:d,onResume:u,onSwipeStart:p,onSwipeMove:g,onSwipeCancel:v,onSwipeEnd:_,...b}=t,j=Yie(lL,r),[w,N]=S.useState(null),C=Aa(s,Y=>N(Y)),A=S.useRef(null),I=S.useRef(null),L=a||j.duration,R=S.useRef(0),$=S.useRef(L),q=S.useRef(0),{onToastAdd:U,onToastRemove:V}=j,X=Uc(()=>{var de;(w==null?void 0:w.contains(document.activeElement))&&((de=j.viewport)==null||de.focus()),l()}),se=S.useCallback(Y=>{!Y||Y===1/0||(window.clearTimeout(q.current),R.current=new Date().getTime(),q.current=window.setTimeout(X,Y))},[X]);S.useEffect(()=>{const Y=j.viewport;if(Y){const de=()=>{se($.current),u==null||u()},ie=()=>{const ae=new Date().getTime()-R.current;$.current=$.current-ae,window.clearTimeout(q.current),d==null||d()};return Y.addEventListener(Mfe,ie),Y.addEventListener(Tfe,de),()=>{Y.removeEventListener(Mfe,ie),Y.removeEventListener(Tfe,de)}}},[j.viewport,L,d,u,se]),S.useEffect(()=>{o&&!j.isClosePausedRef.current&&se(L)},[o,L,j.isClosePausedRef,se]),S.useEffect(()=>(U(),()=>V()),[U,V]);const te=S.useMemo(()=>w?rRe(w):null,[w]);return j.viewport?e.jsxs(e.Fragment,{children:[te&&e.jsx(jot,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:te}),e.jsx(_ot,{scope:r,onClose:X,children:_m.createPortal(e.jsx(Kve.ItemSlot,{scope:r,children:e.jsx(tot,{asChild:!0,onEscapeKeyDown:Mr(i,()=>{j.isFocusedToastEscapeKeyDownRef.current||X(),j.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":j.swipeDirection,...b,ref:C,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Mr(t.onKeyDown,Y=>{Y.key==="Escape"&&(i==null||i(Y.nativeEvent),Y.nativeEvent.defaultPrevented||(j.isFocusedToastEscapeKeyDownRef.current=!0,X()))}),onPointerDown:Mr(t.onPointerDown,Y=>{Y.button===0&&(A.current={x:Y.clientX,y:Y.clientY})}),onPointerMove:Mr(t.onPointerMove,Y=>{if(!A.current)return;const de=Y.clientX-A.current.x,ie=Y.clientY-A.current.y,ae=!!I.current,le=["left","right"].includes(j.swipeDirection),pe=["left","up"].includes(j.swipeDirection)?Math.min:Math.max,be=le?pe(0,de):0,ye=le?0:pe(0,ie),we=Y.pointerType==="touch"?10:2,Ne={x:be,y:ye},Ke={originalEvent:Y,delta:Ne};ae?(I.current=Ne,p8(xot,g,Ke,{discrete:!1})):XCe(Ne,j.swipeDirection,we)?(I.current=Ne,p8(got,p,Ke,{discrete:!1}),Y.target.setPointerCapture(Y.pointerId)):(Math.abs(de)>we||Math.abs(ie)>we)&&(A.current=null)}),onPointerUp:Mr(t.onPointerUp,Y=>{const de=I.current,ie=Y.target;if(ie.hasPointerCapture(Y.pointerId)&&ie.releasePointerCapture(Y.pointerId),I.current=null,A.current=null,de){const ae=Y.currentTarget,le={originalEvent:Y,delta:de};XCe(de,j.swipeDirection,j.swipeThreshold)?p8(vot,_,le,{discrete:!0}):p8(yot,v,le,{discrete:!0}),ae.addEventListener("click",pe=>pe.preventDefault(),{once:!0})}})})})}),j.viewport)})]}):null}),jot=t=>{const{__scopeToast:s,children:r,...n}=t,a=Yie(lL,s),[o,l]=S.useState(!1),[i,d]=S.useState(!1);return Sot(()=>l(!0)),S.useEffect(()=>{const u=window.setTimeout(()=>d(!0),1e3);return()=>window.clearTimeout(u)},[]),i?null:e.jsx(sM,{asChild:!0,children:e.jsx(Zie,{...n,children:o&&e.jsxs(e.Fragment,{children:[a.label," ",r]})})})},kot="ToastTitle",X8e=S.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Qr.div,{...n,ref:s})});X8e.displayName=kot;var Not="ToastDescription",Q8e=S.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Qr.div,{...n,ref:s})});Q8e.displayName=Not;var J8e="ToastAction",eRe=S.forwardRef((t,s)=>{const{altText:r,...n}=t;return r.trim()?e.jsx(sRe,{altText:r,asChild:!0,children:e.jsx(Zve,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${J8e}\`. Expected non-empty \`string\`.`),null)});eRe.displayName=J8e;var tRe="ToastClose",Zve=S.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t,a=bot(tRe,r);return e.jsx(sRe,{asChild:!0,children:e.jsx(Qr.button,{type:"button",...n,ref:s,onClick:Mr(t.onClick,a.onClose)})})});Zve.displayName=tRe;var sRe=S.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 rRe(t){const s=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),Cot(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(...rRe(n))}}),s}function p8(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?Wve(a,o):a.dispatchEvent(o)}var XCe=(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 Sot(t=()=>{}){const s=Uc(t);Kc(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}function Cot(t){return t.nodeType===t.ELEMENT_NODE}function Mot(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 ahe(t){const s=document.activeElement;return t.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var Tot=W8e,nRe=K8e,aRe=Y8e,iRe=X8e,oRe=Q8e,lRe=eRe,cRe=Zve;function dRe(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,JCe=Ri,ZN=(t,s)=>r=>{var n;if((s==null?void 0:s.variants)==null)return JCe(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],g=o==null?void 0:o[u];if(p===null)return null;const v=QCe(p)||QCe(g);return a[u][v]}),i=r&&Object.entries(r).reduce((u,p)=>{let[g,v]=p;return v===void 0||(u[g]=v),u},{}),d=s==null||(n=s.compoundVariants)===null||n===void 0?void 0:n.reduce((u,p)=>{let{class:g,className:v,..._}=p;return Object.entries(_).every(b=>{let[j,w]=b;return Array.isArray(w)?w.includes({...o,...i}[j]):{...o,...i}[j]===w})?[...u,g,v]:u},[]);return JCe(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 Aot=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),uRe=(...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 Eot={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 hRe=S.forwardRef(({color:t="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:l,...i},d)=>S.createElement("svg",{ref:d,...Eot,width:s,height:s,stroke:t,strokeWidth:n?Number(r)*24/Number(s):r,className:uRe("lucide",a),...i},[...l.map(([u,p])=>S.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=S.forwardRef(({className:n,...a},o)=>S.createElement(hRe,{ref:o,iconNode:s,className:uRe(`lucide-${Aot(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 HR=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 WR=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 GR=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 KR=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 Mm=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 ZR=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 YR=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 ew=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 tw=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 XR=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 sw=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 QR=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 JR=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 eF=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 tF=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 sF=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 e5=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 rF=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 nF=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 aF=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 iF=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 oF=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 lF=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 cF=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 dF=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 uF=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 hF=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 mF=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 t5=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 s5=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 pF=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 fF=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 gF=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 xF=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 yF=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 vF=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 _F=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 bF=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 wF=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 jF=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 kF=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 NF=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 SF=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 CF=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 MF=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 TF=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 AF=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 EF=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 PF=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 IF=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 LF=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 HE=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 DF=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 WE=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 OF=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 r5=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 RF=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 FF=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 zF=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 BF=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 $F=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 qF=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 UF=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 VF=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 HF=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 WF=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 GF=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 rw=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 KF=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 ZF=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 YF=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 GE=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 XF=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 QF=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 JF=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 nw=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 aw=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 Ju=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 ez=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 tz=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 sz=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 Ka=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 rz=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 w0=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 nz=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 Ui=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 az=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 iz=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 iw=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 Vc=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 oz=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 lz=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 cz=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 ow=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 KE=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 dz=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 uz=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 lw=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 qd=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 hz=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 mz=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 pz=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 fz=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 gz=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 xz=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 ec=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 yz=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 cw=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 vz=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 _z=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 bz=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 wz=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 dw=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 jz=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 kz=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 Nz=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 Sz=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 Cz=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 Mz=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 Tz=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 Az=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 Ez=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 Pz=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 Iz=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 Lz=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 Dz=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 Oz=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 Rz=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 Fz=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 zz=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 Bz=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 $z=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 qz=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 Uz=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 $x=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 Vz=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 Hz=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 Wz=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 Gz=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 Kz=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 Zz=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 Yz=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 Xz=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 Qz=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 ZE=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 Jz=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 j0=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 e7=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 t7=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 s7=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 r7=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 n7=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 a7=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 Z1=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 i7=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 o7=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 cf=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 uw=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 hw=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 l7=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 c7=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 d7=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 u7=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 h7=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 m7=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 p7=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 f7=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 g7=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 x7=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 y7=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 v7=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 _7=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 b7=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 w7=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 j7=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 n5=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 k7=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 N7=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 S7=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 C7=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 M7=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 T7=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 A7=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 mw=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 E7=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 P7=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 I7=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 L7=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 D7=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 O7=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 R7=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 F7=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 z7=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 B7=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 cu=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 $7=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 q7=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 U7=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 V7=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 H7=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 W7=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 G7=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 K7=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 Z7=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 Y7=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 YE=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 X7=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 Dg=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 Q7=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 J7=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 eB=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 a5=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 tB=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 sB=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 pw=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 rB=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 nB=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 aB=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 XE=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 iB=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 oB=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 lB=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 cB=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 eh=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 dB=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 uB=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 hB=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 mB=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 pB=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 Ca=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 Yk=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 fB=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 gB=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 xB=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 yB=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 vB=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 Ou=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 _B=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 bB=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 wB=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 jB=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 kB=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 NB=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 QE=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 SB=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 kc=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 CB=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 MB=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 TB=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 AB=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 JE=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 EB=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 Y1=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 PB=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 IB=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 LB=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 DB=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 OB=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 RB=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 Og=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 FB=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 zB=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 BB=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 $B=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 qB=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 fw=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 UB=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 VB=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 HB=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 WB=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 GB=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 KB=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 ZB=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 YB=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 XB=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 QB=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 JB=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 e9=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 t9=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 gw=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 xw=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 s9=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 r9=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 n9=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 yw=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 vw=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 _w=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 a9=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 bw=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 i9=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 Xo=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 o9=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 ww=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 l9=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 c9=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 jw=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 kw=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 d9=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 Nw=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 Sw=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 Cw=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 u9=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 h9=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 fa=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 m9=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 p9=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 Vo=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 f9=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 g9=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 Ol=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 qa=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 Rg=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 x9=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 y9=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 v9=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 _9=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 b9=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 w9=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 j9=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 df=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 k9=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 N9=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 S9=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 C9=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 M9=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 Qo=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 Mw=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 Tw=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 Aw=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 Ew=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 Pw=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 Iw=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 Lw=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 Dw=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 fi=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 la=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 Ow=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 Rw=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 Fw=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 zw=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 T9=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 Bw=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 A9=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 E9=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 P9=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 I9=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 L9=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 D9=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 O9=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 $w=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 n0=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 qw=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 R9=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 Uw=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 Vw=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 Hw=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 Ww=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 gm=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 Gw=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 Kw=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 Zw=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 F9=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 Yw=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 Xw=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 Qw=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 wc=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 Wc=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 z9=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 B9=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 $9=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 i5=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 q9=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 X1=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 U9=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 V9=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 Jw=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 e2=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 H9=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 W9=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 G9=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 K9=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 Z9=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 Y9=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 X9=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 Q9=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 J9=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 e$=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 t$=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 s$=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 r$=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 n$=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 a$=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 i$=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 o$=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 l$=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 c$=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 In=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 d$=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 u$=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 t2=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 h$=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 m$=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 p$=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 f$=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 g$=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 x$=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 y$=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 v$=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 _$=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 b$=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 w$=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 j$=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 s2=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 k$=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 N$=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 g0=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 S$=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 r2=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 Xk=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 C$=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 M$=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 Qk=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 T$=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 eP=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 n2=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 a2=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 A$=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 E$=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 P$=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 I$=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 L$=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 D$=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 O$=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 R$=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 F$=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 i2=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 Jk=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 z$=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 B$=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 $$=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 q$=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 U$=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 V$=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 H$=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 W$=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 G$=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 K$=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 Z$=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 Y$=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 X$=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 Q$=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 J$=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 eq=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 tq=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 sq=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 rq=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 nq=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 aq=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 mp=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 iq=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 oq=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 lq=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 cq=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 zh=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 dq=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 uq=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 hq=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 mq=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 pq=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 fq=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 gq=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 xq=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 yq=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 vq=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 _q=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 bq=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 o2=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 wq=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 jq=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 kq=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 Nq=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 Sq=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 Cq=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 Mq=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 Tq=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 Aq=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 Eq=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 Pq=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 Iq=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 Lq=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 Dq=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 Oq=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 Rq=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 Fq=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 zq=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 Bq=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 Gc=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 $q=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 qq=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 k0=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 Uq=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 gi=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 Vq=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 Hq=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 Wq=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 Gq=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 Kq=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 qx=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 Zq=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 Yq=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 Xq=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 Qq=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 Jq=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 eU=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 l2=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 tU=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 sU=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 rU=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 o5=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 Jp=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 ef=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 nU=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 aU=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 iU=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 oU=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 lU=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 cU=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 dU=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 rn=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 uU=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 Tm=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 ya=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 Ud=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 hU=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 mU=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 pU=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 fU=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 gU=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 xU=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 yU=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 vU=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 _U=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 bU=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 c2=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 wU=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 jU=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 kU=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 d2=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 u2=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 h2=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 m2=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 NU=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 SU=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 CU=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 MU=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 TU=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 p2=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 AU=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 EU=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 PU=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 IU=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 Q1=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 LU=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 DU=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 OU=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 RU=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 FU=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 zU=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 BU=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 $U=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 qU=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 UU=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 VU=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 f2=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 g2=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 HU=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 WU=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 GU=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 KU=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 ZU=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 YU=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 XU=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 N0=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 tP=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 QU=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 JU=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 Sn=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 eV=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 tV=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 sV=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 rV=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 nV=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 aV=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 iV=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 oV=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 lV=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 cV=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 dV=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 l5=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 uV=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 au=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 hV=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 Ux=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 mV=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 pV=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 fV=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 gV=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 xV=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 yV=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 vV=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 _V=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 S0=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 bV=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 Bh=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 wV=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 jV=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 kV=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 J1=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 NV=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 SV=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 CV=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 MV=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 TV=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 Ag=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 AV=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 EV=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 PV=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 IV=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 LV=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 DV=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 OV=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 RV=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 FV=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 x2=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 zV=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 BV=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 $V=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 qV=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 UV=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 VV=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 HV=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 WV=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 GV=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 KV=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 ZV=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 $h=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 YV=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 y2=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 XV=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 QV=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 JV=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 eH=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 tH=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 sH=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 rH=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 nH=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 aH=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 iH=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 oH=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 lH=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 cH=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 dH=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 uH=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 hH=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 mH=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 pH=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 fH=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 gH=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 xH=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 yH=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 vH=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 _H=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 bH=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 wH=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 jH=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 kH=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 NH=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 eN=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 ao=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 SH=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 CH=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 v2=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 MH=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 TH=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 AH=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 EH=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 PH=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 IH=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 LH=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 DH=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 OH=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 RH=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 FH=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 zH=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 BH=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 $H=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 qH=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 UH=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 VH=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 Am=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 HH=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 WH=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 th=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 GH=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 KH=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 _2=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 ZH=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 b2=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 ep=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 YH=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 Ru=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 XH=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 QH=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 JH=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 eW=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 tW=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 sW=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 rW=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 w2=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 nW=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 aW=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 sP=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 rP=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 iW=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 oW=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 nP=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 lW=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 c5=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 cW=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 dW=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 aP=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 iP=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 uW=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 hW=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 mW=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 pW=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 fW=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 gW=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 xW=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 yW=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 vW=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 _W=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 bW=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 wW=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 Ni=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 jW=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 kW=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 NW=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 d5=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 SW=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 CW=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 MW=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 TW=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 AW=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 EW=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 PW=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 Vn=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 j2=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 k2=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 IW=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 LW=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 DW=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 OW=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 RW=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 C0=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 FW=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 zW=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 BW=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 $W=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 qW=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 N2=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 S2=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 UW=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 VW=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 oP=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 HW=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 Vd=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 u5=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 WW=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 GW=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 KW=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 ZW=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 Vx=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 tN=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 YW=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 Em=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 XW=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 QW=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 JW=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 eG=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 tG=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 sG=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 rG=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 nG=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 aG=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 iG=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 oG=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 lG=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 cG=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 C2=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 dG=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 uG=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 hG=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 mG=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 pG=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 fG=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 gG=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 sN=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 pp=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 xG=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 yG=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 vG=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 rN=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 _G=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 bG=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 wG=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 jG=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 kG=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 h5=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 m5=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 NG=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 SG=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 e_=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 CG=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 Ho=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 Io=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 Pm=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 MG=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 TG=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 AG=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 EG=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 PG=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 IG=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 LG=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 M0=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 DG=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 OG=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 RG=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 FG=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 zG=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 BG=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 $G=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 qh=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 As=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 qG=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 UG=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 VG=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 HG=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 lP=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 M2=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 WG=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 T2=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 Fu=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 p5=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 f5=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 GG=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 KG=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 ZG=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 YG=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 XG=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 QG=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 JG=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 eK=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 tK=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 sK=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 rK=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 cP=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 nK=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 aK=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 iK=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 oK=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 lK=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 cK=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 dK=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 uK=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 hK=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 mK=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 pK=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 fK=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 Ti=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 gK=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 xK=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 yK=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 vK=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 dP=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 T0=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 _K=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 Fg=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 bK=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 wK=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 uP=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 jK=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 kK=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 NK=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 g5=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 SK=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 CK=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 MK=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 hP=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 TK=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 AK=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 EK=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 pc=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 PK=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 IK=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 LK=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 DK=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 OK=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 RK=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 mP=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 FK=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 x5=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 pP=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 zK=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 BK=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 $K=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 qK=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 UK=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 VK=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 HK=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 A2=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 fP=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 WK=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 GK=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 KK=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 ZK=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 YK=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 XK=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 QK=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 JK=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 A0=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 eZ=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 tZ=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 sZ=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 rZ=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 nZ=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 aZ=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 iZ=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 oZ=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 lZ=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 cZ=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 dZ=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 uZ=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 nN=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 hZ=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 mZ=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 pZ=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 fZ=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 gZ=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 xZ=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 yZ=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 t_=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 bm=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 vZ=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 E2=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 _Z=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 bZ=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 wZ=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 jZ=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 kZ=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 NZ=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 SZ=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 CZ=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 MZ=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 TZ=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 AZ=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 EZ=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 PZ=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 IZ=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 LZ=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 DZ=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 OZ=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 RZ=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 FZ=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 zZ=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 gP=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 BZ=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 E0=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 $Z=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 qZ=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 UZ=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 VZ=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 HZ=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 WZ=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 GZ=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 KZ=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 ZZ=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 a0=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 YZ=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 P2=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 I2=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 XZ=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 QZ=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 JZ=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 eY=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 tY=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 sY=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 rY=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 nY=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 aY=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 iY=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 oY=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 lY=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 cl=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 cY=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 dY=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 L2=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 uY=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 Rl=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 hY=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 D2=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 pY=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 O2=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 R2=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 F2=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 z2=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 fY=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 B2=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 gY=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 xY=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 yY=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 $2=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 vY=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 _Y=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 bY=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 wY=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 i0=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 aN=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 jY=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 kY=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 Nd=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 fp=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 NY=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 SY=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 o0=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 CY=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 s_=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 Ax=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 MY=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 TY=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 AY=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 Ua=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 EY=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 y5=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 PY=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 IY=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 LY=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 DY=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 OY=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 RY=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 FY=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 zY=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 Zn=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 BY=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 $Y=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 qY=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 UY=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 VY=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 HY=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 WY=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 GY=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 KY=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 ZY=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 YY=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 xP=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 r_=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 XY=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 QY=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 JY=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 eX=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 tX=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 dl=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 sX=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 q2=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 yP=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 rX=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 nX=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 aX=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 iX=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 oX=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 lX=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 cX=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 dX=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 uX=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 vP=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 uf=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 hX=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 _P=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 pX=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 fX=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 gX=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 P0=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 v5=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 xX=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 yX=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 vX=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 _X=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 bX=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 wX=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 iN=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 jX=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 kX=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 NX=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 SX=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 CX=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 MX=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 TX=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 AX=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 EX=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 PX=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 IX=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 LX=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 DX=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 OX=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 U2=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 RX=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 FX=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 zX=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 BX=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 $X=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 _5=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 qX=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 UX=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 VX=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 Eo=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 HX=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 WX=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 GX=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 KX=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 ZX=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 bP=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 YX=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 XX=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 QX=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 wP=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 JX=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 eQ=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 Hx=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 tQ=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 sQ=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 V2=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 rQ=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 I0=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 nQ=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 jP=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 aQ=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 iQ=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 oQ=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 H2=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 W2=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 lQ=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 cQ=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 kP=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 dQ=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 uQ=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 hQ=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 pQ=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 fQ=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 gQ=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 xQ=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 zu=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 G2=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 yQ=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 vQ=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 _Q=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 bQ=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 wQ=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 jQ=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 kQ=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 NQ=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 SQ=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 CQ=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 MQ=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 TQ=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 AQ=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 EQ=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 PQ=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 IQ=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 LQ=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 DQ=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 OQ=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 RQ=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 NP=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 xn=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 FQ=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 K2=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 zQ=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 Ta=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 BQ=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 $Q=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 qQ=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 UQ=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 VQ=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 HQ=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 SP=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 Fl=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 WQ=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 CP=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 GQ=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 KQ=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 ZQ=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 YQ=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 MP=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 XQ=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 QQ=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 JQ=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 eJ=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 tJ=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 sJ=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 Z2=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 sh=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 rJ=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 nJ=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 aJ=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 Wx=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 iJ=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 wm=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 oJ=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 lJ=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 cJ=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 dJ=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 oN=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 uJ=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 hJ=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 mJ=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 pJ=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 fJ=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 gJ=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 xJ=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 yJ=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 vJ=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 _J=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 bJ=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 wJ=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 jJ=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 kJ=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 NJ=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 SJ=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 TP=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 Y2=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 CJ=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 MJ=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 L0=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 TJ=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 AJ=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 EJ=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 I1=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 PJ=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 IJ=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 LJ=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 DJ=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 OJ=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 mn=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 RJ=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 FJ=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 zJ=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 BJ=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 $J=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 qJ=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 UJ=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 VJ=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 X2=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 Q2=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 J2=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 ej=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 tj=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 sj=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 rj=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 nj=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 aj=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 ij=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 oj=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 lj=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 cj=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 dj=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 uj=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 _x=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 l0=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 hj=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 mj=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 pj=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 fj=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 gj=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 xj=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 HJ=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 WJ=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 yj=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 vj=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 _j=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 bj=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 wj=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 jj=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 kj=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 Nj=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 Sj=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 Cj=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 Mj=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 Tj=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 Aj=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 Ej=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 Pj=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 Dc=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 Ij=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 Lj=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 Dj=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 Oj=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 Rj=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 Fj=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 GJ=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 zj=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 Bj=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 $j=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 qj=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 Uj=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 KJ=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 ZJ=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 Vj=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 Hj=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 Wj=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 Gj=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 Gx=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 YJ=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 XJ=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 QJ=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 JJ=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 eee=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 tee=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 see=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 ree=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 nee=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 aee=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 iee=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 oee=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 lee=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 cee=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 dee=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 uee=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 hee=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 mee=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 pee=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 n_=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 fee=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 gee=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 xee=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 yee=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 vee=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 _ee=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 bee=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 wee=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 jee=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 b5=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 kee=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 Nee=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 See=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 Cee=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 Mee=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 Tee=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 AP=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 Aee=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 Eee=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 Pee=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 Im=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 Iee=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 Lee=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 Dee=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 Oee=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 Ree=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 Fee=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 zee=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 Uh=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 Bee=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 $ee=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 qee=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 Uee=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 Kj=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 Vee=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 Hee=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 Wee=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 Gee=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 Kee=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 Zee=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 Zj=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 Yee=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 Xee=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 Qee=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 Jee=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 ete=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 EP=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 hu=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 tte=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 ste=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 rte=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 nte=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 ate=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 ite=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 PP=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 ote=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 lte=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 cte=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 dte=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 ute=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 hte=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 mte=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 pte=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 fte=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 gte=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 xte=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 yte=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 vte=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 _te=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 bte=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 wte=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 jte=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 kte=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 Nte=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 Yj=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 Ste=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 Cte=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 Xj=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 a_=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 Mte=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 Tte=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 lN=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 Ate=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 Sc=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 Mh=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 Ete=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 Pte=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 Gi=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 IP=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 Ite=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 Lte=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 Qj=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 Dte=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 Ote=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 Rte=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 Fte=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 zte=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 Bte=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 $te=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 qte=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 Ute=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 Vte=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 w5=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 Hte=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 Wte=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 Gte=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 Jj=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 Kte=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 cN=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 Zte=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 Xa=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 Yte=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 i_=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 LP=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 DP=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 Xte=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 fc=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 ek=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 tk=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 sk=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 Qte=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 rk=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 Jte=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 nk=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 ak=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 ese=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 tse=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 ik=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 ok=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 lk=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 sse=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 OP=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 rse=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 nse=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 ase=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 ise=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 ose=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 lse=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 cse=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 dse=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 use=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 hse=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 mse=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 pse=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 fse=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 gse=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 xse=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 yse=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 vse=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 ck=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 RP=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 _se=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 c0=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 bse=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 wse=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 jse=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 kse=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 Nse=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 Sse=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 Cse=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 Mse=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 Tse=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 Ase=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 Ese=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 Pse=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 Ise=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 Lse=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 Dse=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 Ose=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 Rse=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 Fse=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 zse=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 Bse=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 $se=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 qse=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 Use=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 Vse=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 Hse=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 Kx=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 Wse=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 Gse=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 Lm=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 o_=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 j5=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 Pot=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:HR,AArrowUp:WR,ALargeSmall:GR,Accessibility:KR,Activity:Mm,AirVent:ZR,Airplay:YR,AlarmClock:QR,AlarmClockCheck:ew,AlarmClockMinus:tw,AlarmClockOff:XR,AlarmClockPlus:sw,AlarmSmoke:JR,Album:eF,AlignCenter:e5,AlignCenterHorizontal:tF,AlignCenterVertical:sF,AlignEndHorizontal:rF,AlignEndVertical:nF,AlignHorizontalDistributeCenter:aF,AlignHorizontalDistributeEnd:iF,AlignHorizontalDistributeStart:oF,AlignHorizontalJustifyCenter:lF,AlignHorizontalJustifyEnd:cF,AlignHorizontalJustifyStart:dF,AlignHorizontalSpaceAround:uF,AlignHorizontalSpaceBetween:hF,AlignJustify:mF,AlignLeft:t5,AlignRight:s5,AlignStartHorizontal:pF,AlignStartVertical:fF,AlignVerticalDistributeCenter:gF,AlignVerticalDistributeEnd:xF,AlignVerticalDistributeStart:yF,AlignVerticalJustifyCenter:vF,AlignVerticalJustifyEnd:_F,AlignVerticalJustifyStart:bF,AlignVerticalSpaceAround:wF,AlignVerticalSpaceBetween:jF,Ambulance:kF,Ampersand:NF,Ampersands:SF,Amphora:CF,Anchor:MF,Angry:TF,Annoyed:AF,Antenna:EF,Anvil:PF,Aperture:IF,AppWindow:HE,AppWindowMac:LF,Apple:DF,Archive:r5,ArchiveRestore:WE,ArchiveX:OF,Armchair:RF,ArrowBigDown:zF,ArrowBigDownDash:FF,ArrowBigLeft:$F,ArrowBigLeftDash:BF,ArrowBigRight:UF,ArrowBigRightDash:qF,ArrowBigUp:HF,ArrowBigUpDash:VF,ArrowDown:Ju,ArrowDown01:WF,ArrowDown10:GF,ArrowDownAZ:rw,ArrowDownFromLine:KF,ArrowDownLeft:ZF,ArrowDownNarrowWide:YF,ArrowDownRight:GE,ArrowDownToDot:XF,ArrowDownToLine:QF,ArrowDownUp:JF,ArrowDownWideNarrow:nw,ArrowDownZA:aw,ArrowLeft:Ka,ArrowLeftFromLine:ez,ArrowLeftRight:tz,ArrowLeftToLine:sz,ArrowRight:Ui,ArrowRightFromLine:rz,ArrowRightLeft:w0,ArrowRightToLine:nz,ArrowUp:qd,ArrowUp01:az,ArrowUp10:iz,ArrowUpAZ:iw,ArrowUpDown:Vc,ArrowUpFromDot:oz,ArrowUpFromLine:lz,ArrowUpLeft:cz,ArrowUpNarrowWide:ow,ArrowUpRight:KE,ArrowUpToLine:dz,ArrowUpWideNarrow:uz,ArrowUpZA:lw,ArrowsUpFromLine:hz,Asterisk:mz,AtSign:pz,Atom:fz,AudioLines:gz,AudioWaveform:xz,Award:ec,Axe:yz,Axis3d:cw,Baby:vz,Backpack:_z,Badge:Oz,BadgeAlert:bz,BadgeCent:wz,BadgeCheck:dw,BadgeDollarSign:jz,BadgeEuro:kz,BadgeHelp:Nz,BadgeIndianRupee:Sz,BadgeInfo:Cz,BadgeJapaneseYen:Mz,BadgeMinus:Tz,BadgePercent:Az,BadgePlus:Ez,BadgePoundSterling:Pz,BadgeRussianRuble:Iz,BadgeSwissFranc:Lz,BadgeX:Dz,BaggageClaim:Rz,Ban:Fz,Banana:zz,Bandage:Bz,Banknote:$z,Barcode:qz,Baseline:Uz,Bath:$x,Battery:Zz,BatteryCharging:Vz,BatteryFull:Hz,BatteryLow:Wz,BatteryMedium:Gz,BatteryWarning:Kz,Beaker:Yz,Bean:Qz,BeanOff:Xz,Bed:j0,BedDouble:ZE,BedSingle:Jz,Beef:e7,Beer:s7,BeerOff:t7,Bell:cf,BellDot:r7,BellElectric:n7,BellMinus:a7,BellOff:Z1,BellPlus:i7,BellRing:o7,BetweenHorizontalEnd:uw,BetweenHorizontalStart:hw,BetweenVerticalEnd:l7,BetweenVerticalStart:c7,BicepsFlexed:d7,Bike:u7,Binary:h7,Binoculars:m7,Biohazard:p7,Bird:f7,Bitcoin:g7,Blend:x7,Blinds:y7,Blocks:v7,Bluetooth:j7,BluetoothConnected:_7,BluetoothOff:b7,BluetoothSearching:w7,Bold:n5,Bolt:k7,Bomb:N7,Bone:S7,Book:K7,BookA:C7,BookAudio:M7,BookCheck:T7,BookCopy:A7,BookDashed:mw,BookDown:E7,BookHeadphones:P7,BookHeart:I7,BookImage:L7,BookKey:D7,BookLock:O7,BookMarked:R7,BookMinus:F7,BookOpen:cu,BookOpenCheck:z7,BookOpenText:B7,BookPlus:$7,BookText:q7,BookType:U7,BookUp:H7,BookUp2:V7,BookUser:W7,BookX:G7,Bookmark:Dg,BookmarkCheck:Z7,BookmarkMinus:Y7,BookmarkPlus:YE,BookmarkX:X7,BoomBox:Q7,Bot:a5,BotMessageSquare:J7,BotOff:eB,Box:tB,Boxes:sB,Braces:pw,Brackets:rB,Brain:XE,BrainCircuit:nB,BrainCog:aB,BrickWall:iB,Briefcase:eh,BriefcaseBusiness:oB,BriefcaseConveyorBelt:lB,BriefcaseMedical:cB,BringToFront:dB,Brush:uB,Bug:pB,BugOff:hB,BugPlay:mB,Building:Yk,Building2:Ca,Bus:gB,BusFront:fB,Cable:yB,CableCar:xB,Cake:Ou,CakeSlice:vB,Calculator:_B,Calendar:on,Calendar1:bB,CalendarArrowDown:wB,CalendarArrowUp:jB,CalendarCheck:NB,CalendarCheck2:kB,CalendarClock:QE,CalendarCog:SB,CalendarDays:kc,CalendarFold:CB,CalendarHeart:MB,CalendarMinus:AB,CalendarMinus2:TB,CalendarOff:JE,CalendarPlus:Y1,CalendarPlus2:EB,CalendarRange:PB,CalendarSearch:IB,CalendarSync:LB,CalendarX:OB,CalendarX2:DB,Camera:Og,CameraOff:RB,Candy:BB,CandyCane:FB,CandyOff:zB,Cannabis:$B,Captions:fw,CaptionsOff:qB,Car:HB,CarFront:UB,CarTaxiFront:VB,Caravan:WB,Carrot:GB,CaseLower:KB,CaseSensitive:ZB,CaseUpper:YB,CassetteTape:XB,Cast:QB,Castle:JB,Cat:e9,Cctv:t9,ChartArea:gw,ChartBar:yw,ChartBarBig:xw,ChartBarDecreasing:s9,ChartBarIncreasing:r9,ChartBarStacked:n9,ChartCandlestick:vw,ChartColumn:Xo,ChartColumnBig:_w,ChartColumnDecreasing:a9,ChartColumnIncreasing:bw,ChartColumnStacked:i9,ChartGantt:o9,ChartLine:ww,ChartNetwork:l9,ChartNoAxesColumn:kw,ChartNoAxesColumnDecreasing:c9,ChartNoAxesColumnIncreasing:jw,ChartNoAxesCombined:d9,ChartNoAxesGantt:Nw,ChartPie:Sw,ChartScatter:Cw,ChartSpline:u9,Check:fa,CheckCheck:h9,ChefHat:m9,Cherry:p9,ChevronDown:Vo,ChevronFirst:f9,ChevronLast:g9,ChevronLeft:Ol,ChevronRight:qa,ChevronUp:Rg,ChevronsDown:y9,ChevronsDownUp:x9,ChevronsLeft:b9,ChevronsLeftRight:_9,ChevronsLeftRightEllipsis:v9,ChevronsRight:j9,ChevronsRightLeft:w9,ChevronsUp:k9,ChevronsUpDown:df,Chrome:N9,Church:S9,Cigarette:M9,CigaretteOff:C9,Circle:Wc,CircleAlert:Qo,CircleArrowDown:Mw,CircleArrowLeft:Tw,CircleArrowOutDownLeft:Aw,CircleArrowOutDownRight:Ew,CircleArrowOutUpLeft:Pw,CircleArrowOutUpRight:Iw,CircleArrowRight:Lw,CircleArrowUp:Dw,CircleCheck:la,CircleCheckBig:fi,CircleChevronDown:Ow,CircleChevronLeft:Rw,CircleChevronRight:Fw,CircleChevronUp:zw,CircleDashed:T9,CircleDivide:Bw,CircleDollarSign:A9,CircleDot:P9,CircleDotDashed:E9,CircleEllipsis:I9,CircleEqual:L9,CircleFadingArrowUp:D9,CircleFadingPlus:O9,CircleGauge:$w,CircleHelp:n0,CircleMinus:qw,CircleOff:R9,CircleParking:Vw,CircleParkingOff:Uw,CirclePause:Hw,CirclePercent:Ww,CirclePlay:gm,CirclePlus:Gw,CirclePower:Kw,CircleSlash:F9,CircleSlash2:Zw,CircleStop:Yw,CircleUser:Qw,CircleUserRound:Xw,CircleX:wc,CircuitBoard:z9,Citrus:B9,Clapperboard:$9,Clipboard:K9,ClipboardCheck:i5,ClipboardCopy:q9,ClipboardList:X1,ClipboardMinus:U9,ClipboardPaste:V9,ClipboardPen:e2,ClipboardPenLine:Jw,ClipboardPlus:H9,ClipboardType:W9,ClipboardX:G9,Clock:In,Clock1:Z9,Clock10:Y9,Clock11:X9,Clock12:Q9,Clock2:J9,Clock3:e$,Clock4:t$,Clock5:s$,Clock6:r$,Clock7:n$,Clock8:a$,Clock9:i$,ClockAlert:o$,ClockArrowDown:l$,ClockArrowUp:c$,Cloud:k$,CloudAlert:d$,CloudCog:u$,CloudDownload:t2,CloudDrizzle:h$,CloudFog:m$,CloudHail:p$,CloudLightning:f$,CloudMoon:x$,CloudMoonRain:g$,CloudOff:y$,CloudRain:_$,CloudRainWind:v$,CloudSnow:b$,CloudSun:j$,CloudSunRain:w$,CloudUpload:s2,Cloudy:N$,Clover:g0,Club:S$,Code:Xk,CodeXml:r2,Codepen:C$,Codesandbox:M$,Coffee:Qk,Cog:T$,Coins:eP,Columns2:n2,Columns3:a2,Columns4:A$,Combine:E$,Command:P$,Compass:I$,Component:L$,Computer:D$,ConciergeBell:O$,Cone:R$,Construction:F$,Contact:Jk,ContactRound:i2,Container:z$,Contrast:B$,Cookie:$$,CookingPot:q$,Copy:ai,CopyCheck:U$,CopyMinus:V$,CopyPlus:H$,CopySlash:W$,CopyX:G$,Copyleft:K$,Copyright:Z$,CornerDownLeft:Y$,CornerDownRight:X$,CornerLeftDown:Q$,CornerLeftUp:J$,CornerRightDown:eq,CornerRightUp:tq,CornerUpLeft:sq,CornerUpRight:rq,Cpu:nq,CreativeCommons:aq,CreditCard:mp,Croissant:iq,Crop:oq,Cross:lq,Crosshair:cq,Crown:zh,Cuboid:dq,CupSoda:uq,Currency:hq,Cylinder:mq,Dam:pq,Database:xq,DatabaseBackup:fq,DatabaseZap:gq,Delete:yq,Dessert:vq,Diameter:_q,Diamond:jq,DiamondMinus:bq,DiamondPercent:o2,DiamondPlus:wq,Dice1:kq,Dice2:Nq,Dice3:Sq,Dice4:Cq,Dice5:Mq,Dice6:Tq,Dices:Aq,Diff:Eq,Disc:Dq,Disc2:Pq,Disc3:Iq,DiscAlbum:Lq,Divide:Oq,Dna:Fq,DnaOff:Rq,Dock:zq,Dog:Bq,DollarSign:Gc,Donut:$q,DoorClosed:qq,DoorOpen:k0,Dot:Uq,Download:gi,DraftingCompass:Vq,Drama:Hq,Dribbble:Wq,Drill:Gq,Droplet:Kq,Droplets:qx,Drum:Zq,Drumstick:Yq,Dumbbell:Xq,Ear:Jq,EarOff:Qq,Earth:l2,EarthLock:eU,Eclipse:tU,Egg:o5,EggFried:sU,EggOff:rU,Ellipsis:ef,EllipsisVertical:Jp,Equal:iU,EqualApproximately:nU,EqualNot:aU,Eraser:oU,EthernetPort:lU,Euro:cU,Expand:dU,ExternalLink:rn,Eye:ya,EyeClosed:uU,EyeOff:Tm,Facebook:Ud,Factory:hU,Fan:mU,FastForward:pU,Feather:fU,Fence:gU,FerrisWheel:xU,Figma:yU,File:l5,FileArchive:vU,FileAudio:bU,FileAudio2:_U,FileAxis3d:c2,FileBadge:jU,FileBadge2:wU,FileBox:kU,FileChartColumn:u2,FileChartColumnIncreasing:d2,FileChartLine:h2,FileChartPie:m2,FileCheck:SU,FileCheck2:NU,FileClock:CU,FileCode:TU,FileCode2:MU,FileCog:p2,FileDiff:AU,FileDigit:EU,FileDown:PU,FileHeart:IU,FileImage:Q1,FileInput:LU,FileJson:OU,FileJson2:DU,FileKey:FU,FileKey2:RU,FileLock:BU,FileLock2:zU,FileMinus:qU,FileMinus2:$U,FileMusic:UU,FileOutput:VU,FilePen:g2,FilePenLine:f2,FilePlus:WU,FilePlus2:HU,FileQuestion:GU,FileScan:KU,FileSearch:YU,FileSearch2:ZU,FileSliders:XU,FileSpreadsheet:N0,FileStack:tP,FileSymlink:QU,FileTerminal:JU,FileText:Sn,FileType:tV,FileType2:eV,FileUp:sV,FileUser:rV,FileVideo:aV,FileVideo2:nV,FileVolume:oV,FileVolume2:iV,FileWarning:lV,FileX:dV,FileX2:cV,Files:uV,Film:au,Filter:Ux,FilterX:hV,Fingerprint:mV,FireExtinguisher:pV,Fish:xV,FishOff:fV,FishSymbol:gV,Flag:S0,FlagOff:yV,FlagTriangleLeft:vV,FlagTriangleRight:_V,Flame:Bh,FlameKindling:bV,Flashlight:jV,FlashlightOff:wV,FlaskConical:J1,FlaskConicalOff:kV,FlaskRound:NV,FlipHorizontal:CV,FlipHorizontal2:SV,FlipVertical:TV,FlipVertical2:MV,Flower:AV,Flower2:Ag,Focus:EV,FoldHorizontal:PV,FoldVertical:IV,Folder:iH,FolderArchive:LV,FolderCheck:DV,FolderClock:OV,FolderClosed:RV,FolderCode:FV,FolderCog:x2,FolderDot:zV,FolderDown:BV,FolderGit:qV,FolderGit2:$V,FolderHeart:UV,FolderInput:VV,FolderKanban:HV,FolderKey:WV,FolderLock:GV,FolderMinus:KV,FolderOpen:$h,FolderOpenDot:ZV,FolderOutput:YV,FolderPen:y2,FolderPlus:XV,FolderRoot:QV,FolderSearch:eH,FolderSearch2:JV,FolderSymlink:tH,FolderSync:sH,FolderTree:rH,FolderUp:nH,FolderX:aH,Folders:oH,Footprints:lH,Forklift:cH,Forward:dH,Frame:uH,Framer:hH,Frown:mH,Fuel:pH,Fullscreen:fH,GalleryHorizontal:xH,GalleryHorizontalEnd:gH,GalleryThumbnails:yH,GalleryVertical:_H,GalleryVerticalEnd:vH,Gamepad:wH,Gamepad2:bH,Gauge:jH,Gavel:kH,Gem:NH,Ghost:eN,Gift:ao,GitBranch:CH,GitBranchPlus:SH,GitCommitHorizontal:v2,GitCommitVertical:MH,GitCompare:AH,GitCompareArrows:TH,GitFork:EH,GitGraph:PH,GitMerge:IH,GitPullRequest:zH,GitPullRequestArrow:LH,GitPullRequestClosed:DH,GitPullRequestCreate:RH,GitPullRequestCreateArrow:OH,GitPullRequestDraft:FH,Github:BH,Gitlab:$H,GlassWater:qH,Glasses:UH,Globe:Am,GlobeLock:VH,Goal:HH,Grab:WH,GraduationCap:th,Grape:GH,Grid2x2:b2,Grid2x2Check:KH,Grid2x2Plus:_2,Grid2x2X:ZH,Grid3x3:ep,Grip:XH,GripHorizontal:YH,GripVertical:Ru,Group:QH,Guitar:JH,Ham:eW,Hammer:tW,Hand:sP,HandCoins:sW,HandHeart:rW,HandHelping:w2,HandMetal:nW,HandPlatter:aW,Handshake:rP,HardDrive:nP,HardDriveDownload:iW,HardDriveUpload:oW,HardHat:lW,Hash:c5,Haze:cW,HdmiPort:dW,Heading:fW,Heading1:aP,Heading2:iP,Heading3:uW,Heading4:hW,Heading5:mW,Heading6:pW,HeadphoneOff:gW,Headphones:xW,Headset:yW,Heart:Ni,HeartCrack:vW,HeartHandshake:_W,HeartOff:bW,HeartPulse:wW,Heater:jW,Hexagon:kW,Highlighter:NW,History:d5,Hop:CW,HopOff:SW,Hospital:MW,Hotel:TW,Hourglass:AW,House:Vn,HousePlug:EW,HousePlus:PW,IceCreamBowl:j2,IceCreamCone:k2,IdCard:IW,Image:Jo,ImageDown:LW,ImageMinus:DW,ImageOff:OW,ImagePlay:RW,ImagePlus:C0,ImageUp:FW,ImageUpscale:zW,Images:BW,Import:$W,Inbox:qW,IndentDecrease:N2,IndentIncrease:S2,IndianRupee:UW,Infinity:VW,Info:oP,InspectionPanel:HW,Instagram:Vd,Italic:u5,IterationCcw:WW,IterationCw:GW,JapaneseYen:KW,Joystick:ZW,Kanban:Vx,Key:Em,KeyRound:tN,KeySquare:YW,Keyboard:JW,KeyboardMusic:XW,KeyboardOff:QW,Lamp:aG,LampCeiling:eG,LampDesk:tG,LampFloor:sG,LampWallDown:rG,LampWallUp:nG,LandPlot:iG,Landmark:oG,Languages:lG,Laptop:dG,LaptopMinimal:C2,LaptopMinimalCheck:cG,Lasso:hG,LassoSelect:uG,Laugh:mG,Layers:gG,Layers2:pG,Layers3:fG,LayoutDashboard:sN,LayoutGrid:pp,LayoutList:xG,LayoutPanelLeft:yG,LayoutPanelTop:vG,LayoutTemplate:rN,Leaf:_G,LeafyGreen:bG,Lectern:wG,LetterText:jG,Library:h5,LibraryBig:kG,LifeBuoy:m5,Ligature:NG,Lightbulb:e_,LightbulbOff:SG,Link:Io,Link2:Ho,Link2Off:CG,Linkedin:Pm,List:qh,ListCheck:MG,ListChecks:TG,ListCollapse:AG,ListEnd:EG,ListFilter:PG,ListMinus:IG,ListMusic:LG,ListOrdered:M0,ListPlus:DG,ListRestart:OG,ListStart:RG,ListTodo:FG,ListTree:zG,ListVideo:BG,ListX:$G,Loader:UG,LoaderCircle:As,LoaderPinwheel:qG,Locate:lP,LocateFixed:VG,LocateOff:HG,Lock:Fu,LockKeyhole:WG,LockKeyholeOpen:M2,LockOpen:T2,LogIn:p5,LogOut:f5,Logs:GG,Lollipop:KG,Luggage:ZG,Magnet:YG,Mail:br,MailCheck:XG,MailMinus:QG,MailOpen:JG,MailPlus:eK,MailQuestion:tK,MailSearch:sK,MailWarning:rK,MailX:cP,Mailbox:nK,Mails:aK,Map:xK,MapPin:Ti,MapPinCheck:oK,MapPinCheckInside:iK,MapPinHouse:lK,MapPinMinus:dK,MapPinMinusInside:cK,MapPinOff:uK,MapPinPlus:mK,MapPinPlusInside:hK,MapPinX:fK,MapPinXInside:pK,MapPinned:gK,Martini:yK,Maximize:dP,Maximize2:vK,Medal:T0,Megaphone:Fg,MegaphoneOff:_K,Meh:bK,MemoryStick:wK,Menu:uP,Merge:jK,MessageCircle:pc,MessageCircleCode:kK,MessageCircleDashed:NK,MessageCircleHeart:g5,MessageCircleMore:SK,MessageCircleOff:CK,MessageCirclePlus:MK,MessageCircleQuestion:hP,MessageCircleReply:TK,MessageCircleWarning:AK,MessageCircleX:EK,MessageSquare:io,MessageSquareCode:PK,MessageSquareDashed:IK,MessageSquareDiff:LK,MessageSquareDot:DK,MessageSquareHeart:OK,MessageSquareLock:RK,MessageSquareMore:mP,MessageSquareOff:FK,MessageSquarePlus:x5,MessageSquareQuote:pP,MessageSquareReply:zK,MessageSquareShare:BK,MessageSquareText:$K,MessageSquareWarning:qK,MessageSquareX:UK,MessagesSquare:VK,Mic:fP,MicOff:HK,MicVocal:A2,Microchip:WK,Microscope:GK,Microwave:KK,Milestone:ZK,Milk:XK,MilkOff:YK,Minimize:JK,Minimize2:QK,Minus:A0,Monitor:nN,MonitorCheck:eZ,MonitorCog:tZ,MonitorDot:sZ,MonitorDown:rZ,MonitorOff:nZ,MonitorPause:aZ,MonitorPlay:iZ,MonitorSmartphone:oZ,MonitorSpeaker:lZ,MonitorStop:cZ,MonitorUp:dZ,MonitorX:uZ,Moon:mZ,MoonStar:hZ,Mountain:fZ,MountainSnow:pZ,Mouse:vZ,MouseOff:gZ,MousePointer:bm,MousePointer2:xZ,MousePointerBan:yZ,MousePointerClick:t_,Move:PZ,Move3d:E2,MoveDiagonal:bZ,MoveDiagonal2:_Z,MoveDown:kZ,MoveDownLeft:wZ,MoveDownRight:jZ,MoveHorizontal:NZ,MoveLeft:SZ,MoveRight:CZ,MoveUp:AZ,MoveUpLeft:MZ,MoveUpRight:TZ,MoveVertical:EZ,Music:OZ,Music2:IZ,Music3:LZ,Music4:DZ,Navigation:gP,Navigation2:FZ,Navigation2Off:RZ,NavigationOff:zZ,Network:BZ,Newspaper:E0,Nfc:$Z,Notebook:HZ,NotebookPen:qZ,NotebookTabs:UZ,NotebookText:VZ,NotepadText:GZ,NotepadTextDashed:WZ,Nut:ZZ,NutOff:KZ,Octagon:XZ,OctagonAlert:a0,OctagonMinus:YZ,OctagonPause:P2,OctagonX:I2,Omega:QZ,Option:JZ,Orbit:eY,Origami:tY,Package:cl,Package2:sY,PackageCheck:rY,PackageMinus:nY,PackageOpen:aY,PackagePlus:iY,PackageSearch:oY,PackageX:lY,PaintBucket:cY,PaintRoller:dY,Paintbrush:uY,PaintbrushVertical:L2,Palette:Rl,PanelBottom:pY,PanelBottomClose:hY,PanelBottomDashed:D2,PanelBottomOpen:mY,PanelLeft:z2,PanelLeftClose:O2,PanelLeftDashed:R2,PanelLeftOpen:F2,PanelRight:xY,PanelRightClose:fY,PanelRightDashed:B2,PanelRightOpen:gY,PanelTop:_Y,PanelTopClose:yY,PanelTopDashed:$2,PanelTopOpen:vY,PanelsLeftBottom:bY,PanelsRightBottom:wY,PanelsTopLeft:i0,Paperclip:aN,Parentheses:jY,ParkingMeter:kY,PartyPopper:Nd,Pause:fp,PawPrint:NY,PcCase:SY,Pen:Ax,PenLine:o0,PenOff:CY,PenTool:s_,Pencil:Ua,PencilLine:MY,PencilOff:TY,PencilRuler:AY,Pentagon:EY,Percent:y5,PersonStanding:PY,PhilippinePeso:IY,Phone:Zn,PhoneCall:LY,PhoneForwarded:DY,PhoneIncoming:OY,PhoneMissed:RY,PhoneOff:FY,PhoneOutgoing:zY,Pi:BY,Piano:$Y,Pickaxe:qY,PictureInPicture:VY,PictureInPicture2:UY,PiggyBank:HY,Pilcrow:KY,PilcrowLeft:WY,PilcrowRight:GY,Pill:YY,PillBottle:ZY,Pin:r_,PinOff:xP,Pipette:XY,Pizza:QY,Plane:tX,PlaneLanding:JY,PlaneTakeoff:eX,Play:dl,Plug:yP,Plug2:sX,PlugZap:q2,Plus:Zs,Pocket:nX,PocketKnife:rX,Podcast:aX,Pointer:oX,PointerOff:iX,Popcorn:lX,Popsicle:cX,PoundSterling:dX,Power:vP,PowerOff:uX,Presentation:uf,Printer:_P,PrinterCheck:hX,Projector:mX,Proportions:pX,Puzzle:fX,Pyramid:gX,QrCode:P0,Quote:v5,Rabbit:xX,Radar:yX,Radiation:vX,Radical:_X,Radio:iN,RadioReceiver:bX,RadioTower:wX,Radius:jX,RailSymbol:kX,Rainbow:NX,Rat:SX,Ratio:CX,Receipt:OX,ReceiptCent:MX,ReceiptEuro:TX,ReceiptIndianRupee:AX,ReceiptJapaneseYen:EX,ReceiptPoundSterling:PX,ReceiptRussianRuble:IX,ReceiptSwissFranc:LX,ReceiptText:DX,RectangleEllipsis:U2,RectangleHorizontal:RX,RectangleVertical:FX,Recycle:zX,Redo:_5,Redo2:BX,RedoDot:$X,RefreshCcw:UX,RefreshCcwDot:qX,RefreshCw:Eo,RefreshCwOff:VX,Refrigerator:HX,Regex:WX,RemoveFormatting:GX,Repeat:bP,Repeat1:KX,Repeat2:ZX,Replace:XX,ReplaceAll:YX,Reply:wP,ReplyAll:QX,Rewind:JX,Ribbon:eQ,Rocket:Hx,RockingChair:tQ,RollerCoaster:sQ,Rotate3d:V2,RotateCcw:I0,RotateCcwSquare:rQ,RotateCw:jP,RotateCwSquare:nQ,Route:iQ,RouteOff:aQ,Router:oQ,Rows2:H2,Rows3:W2,Rows4:lQ,Rss:cQ,Ruler:kP,RussianRuble:dQ,Sailboat:uQ,Salad:hQ,Sandwich:mQ,Satellite:fQ,SatelliteDish:pQ,Save:zu,SaveAll:gQ,SaveOff:xQ,Scale:yQ,Scale3d:G2,Scaling:vQ,Scan:CQ,ScanBarcode:_Q,ScanEye:bQ,ScanFace:wQ,ScanLine:jQ,ScanQrCode:kQ,ScanSearch:NQ,ScanText:SQ,School:MQ,Scissors:AQ,ScissorsLineDashed:TQ,ScreenShare:PQ,ScreenShareOff:EQ,Scroll:LQ,ScrollText:IQ,Search:xn,SearchCheck:DQ,SearchCode:OQ,SearchSlash:RQ,SearchX:NP,Section:FQ,Send:Ta,SendHorizontal:K2,SendToBack:zQ,SeparatorHorizontal:BQ,SeparatorVertical:$Q,Server:HQ,ServerCog:qQ,ServerCrash:UQ,ServerOff:VQ,Settings:Fl,Settings2:SP,Shapes:WQ,Share:CP,Share2:ld,Sheet:GQ,Shell:KQ,Shield:sh,ShieldAlert:ZQ,ShieldBan:YQ,ShieldCheck:MP,ShieldEllipsis:XQ,ShieldHalf:QQ,ShieldMinus:JQ,ShieldOff:eJ,ShieldPlus:tJ,ShieldQuestion:sJ,ShieldX:Z2,Ship:nJ,ShipWheel:rJ,Shirt:aJ,ShoppingBag:Wx,ShoppingBasket:iJ,ShoppingCart:wm,Shovel:oJ,ShowerHead:lJ,Shrink:cJ,Shrub:dJ,Shuffle:oN,Sigma:uJ,Signal:gJ,SignalHigh:hJ,SignalLow:mJ,SignalMedium:pJ,SignalZero:fJ,Signature:xJ,Signpost:vJ,SignpostBig:yJ,Siren:_J,SkipBack:bJ,SkipForward:wJ,Skull:jJ,Slack:kJ,Slash:NJ,Slice:SJ,SlidersHorizontal:TP,SlidersVertical:Y2,Smartphone:L0,SmartphoneCharging:CJ,SmartphoneNfc:MJ,Smile:AJ,SmilePlus:TJ,Snail:EJ,Snowflake:I1,Sofa:PJ,Soup:IJ,Space:LJ,Spade:DJ,Sparkle:OJ,Sparkles:mn,Speaker:RJ,Speech:FJ,SpellCheck:BJ,SpellCheck2:zJ,Spline:$J,Split:qJ,SprayCan:UJ,Sprout:VJ,Square:Gx,SquareActivity:X2,SquareArrowDown:ej,SquareArrowDownLeft:Q2,SquareArrowDownRight:J2,SquareArrowLeft:tj,SquareArrowOutDownLeft:sj,SquareArrowOutDownRight:rj,SquareArrowOutUpLeft:nj,SquareArrowOutUpRight:aj,SquareArrowRight:ij,SquareArrowUp:cj,SquareArrowUpLeft:oj,SquareArrowUpRight:lj,SquareAsterisk:dj,SquareBottomDashedScissors:uj,SquareChartGantt:_x,SquareCheck:hj,SquareCheckBig:l0,SquareChevronDown:mj,SquareChevronLeft:pj,SquareChevronRight:fj,SquareChevronUp:gj,SquareCode:xj,SquareDashed:_j,SquareDashedBottom:WJ,SquareDashedBottomCode:HJ,SquareDashedKanban:yj,SquareDashedMousePointer:vj,SquareDivide:bj,SquareDot:wj,SquareEqual:jj,SquareFunction:kj,SquareKanban:Nj,SquareLibrary:Sj,SquareM:Cj,SquareMenu:Mj,SquareMinus:Tj,SquareMousePointer:Aj,SquareParking:Pj,SquareParkingOff:Ej,SquarePen:Dc,SquarePercent:Ij,SquarePi:Lj,SquarePilcrow:Dj,SquarePlay:Oj,SquarePlus:Rj,SquarePower:Fj,SquareRadical:GJ,SquareScissors:zj,SquareSigma:Bj,SquareSlash:$j,SquareSplitHorizontal:qj,SquareSplitVertical:Uj,SquareSquare:KJ,SquareStack:ZJ,SquareTerminal:Vj,SquareUser:Wj,SquareUserRound:Hj,SquareX:Gj,Squircle:YJ,Squirrel:XJ,Stamp:QJ,Star:Gn,StarHalf:JJ,StarOff:eee,StepBack:tee,StepForward:see,Stethoscope:ree,Sticker:nee,StickyNote:aee,Store:iee,StretchHorizontal:oee,StretchVertical:lee,Strikethrough:cee,Subscript:dee,Sun:n_,SunDim:uee,SunMedium:hee,SunMoon:mee,SunSnow:pee,Sunrise:fee,Sunset:gee,Superscript:xee,SwatchBook:yee,SwissFranc:vee,SwitchCamera:_ee,Sword:bee,Swords:wee,Syringe:jee,Table:AP,Table2:b5,TableCellsMerge:kee,TableCellsSplit:Nee,TableColumnsSplit:See,TableOfContents:Cee,TableProperties:Mee,TableRowsSplit:Tee,Tablet:Eee,TabletSmartphone:Aee,Tablets:Pee,Tag:Im,Tags:Iee,Tally1:Lee,Tally2:Dee,Tally3:Oee,Tally4:Ree,Tally5:Fee,Tangent:zee,Target:Uh,Telescope:Bee,Tent:qee,TentTree:$ee,Terminal:Uee,TestTube:Vee,TestTubeDiagonal:Kj,TestTubes:Hee,Text:Yee,TextCursor:Gee,TextCursorInput:Wee,TextQuote:Kee,TextSearch:Zee,TextSelect:Zj,Theater:Xee,Thermometer:ete,ThermometerSnowflake:Qee,ThermometerSun:Jee,ThumbsDown:EP,ThumbsUp:hu,Ticket:PP,TicketCheck:tte,TicketMinus:ste,TicketPercent:rte,TicketPlus:nte,TicketSlash:ate,TicketX:ite,Tickets:lte,TicketsPlane:ote,Timer:ute,TimerOff:cte,TimerReset:dte,ToggleLeft:hte,ToggleRight:mte,Toilet:pte,Tornado:fte,Torus:gte,Touchpad:yte,TouchpadOff:xte,TowerControl:vte,ToyBrick:_te,Tractor:bte,TrafficCone:wte,TrainFront:kte,TrainFrontTunnel:jte,TrainTrack:Nte,TramFront:Yj,Trash:Ste,Trash2:jr,TreeDeciduous:Cte,TreePalm:Xj,TreePine:a_,Trees:Mte,Trello:Tte,TrendingDown:lN,TrendingUp:Sc,TrendingUpDown:Ate,Triangle:Pte,TriangleAlert:Mh,TriangleRight:Ete,Trophy:Gi,Truck:IP,Turtle:Ite,Tv:Dte,TvMinimal:Qj,TvMinimalPlay:Lte,Twitch:Ote,Twitter:Rte,Type:zte,TypeOutline:Fte,Umbrella:$te,UmbrellaOff:Bte,Underline:qte,Undo:w5,Undo2:Ute,UndoDot:Vte,UnfoldHorizontal:Hte,UnfoldVertical:Wte,Ungroup:Gte,University:Jj,Unlink:cN,Unlink2:Kte,Unplug:Zte,Upload:Xa,Usb:Yte,User:Yi,UserCheck:i_,UserCog:LP,UserMinus:DP,UserPen:Xte,UserPlus:fc,UserRound:ak,UserRoundCheck:ek,UserRoundCog:tk,UserRoundMinus:sk,UserRoundPen:Qte,UserRoundPlus:rk,UserRoundSearch:Jte,UserRoundX:nk,UserSearch:ese,UserX:tse,Users:hr,UsersRound:ik,Utensils:lk,UtensilsCrossed:ok,UtilityPole:sse,Variable:OP,Vault:rse,Vegan:nse,VenetianMask:ase,Vibrate:ose,VibrateOff:ise,Video:Nn,VideoOff:lse,Videotape:cse,View:dse,Voicemail:use,Volleyball:hse,Volume:xse,Volume1:mse,Volume2:pse,VolumeOff:fse,VolumeX:gse,Vote:yse,Wallet:RP,WalletCards:vse,WalletMinimal:ck,Wallpaper:_se,Wand:bse,WandSparkles:c0,Warehouse:wse,WashingMachine:jse,Watch:kse,Waves:Nse,Waypoints:Sse,Webcam:Cse,Webhook:Tse,WebhookOff:Mse,Weight:Ase,Wheat:Pse,WheatOff:Ese,WholeWord:Ise,Wifi:Fse,WifiHigh:Lse,WifiLow:Dse,WifiOff:Ose,WifiZero:Rse,Wind:Bse,WindArrowDown:zse,Wine:qse,WineOff:$se,Workflow:Use,Worm:Vse,WrapText:Hse,Wrench:Kx,X:Ur,Youtube:Wse,Zap:Lm,ZapOff:Gse,ZoomIn:o_,ZoomOut:j5},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 Yve=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:HR,AArrowDownIcon:HR,AArrowUp:WR,AArrowUpIcon:WR,ALargeSmall:GR,ALargeSmallIcon:GR,Accessibility:KR,AccessibilityIcon:KR,Activity:Mm,ActivityIcon:Mm,ActivitySquare:X2,ActivitySquareIcon:X2,AirVent:ZR,AirVentIcon:ZR,Airplay:YR,AirplayIcon:YR,AlarmCheck:ew,AlarmCheckIcon:ew,AlarmClock:QR,AlarmClockCheck:ew,AlarmClockCheckIcon:ew,AlarmClockIcon:QR,AlarmClockMinus:tw,AlarmClockMinusIcon:tw,AlarmClockOff:XR,AlarmClockOffIcon:XR,AlarmClockPlus:sw,AlarmClockPlusIcon:sw,AlarmMinus:tw,AlarmMinusIcon:tw,AlarmPlus:sw,AlarmPlusIcon:sw,AlarmSmoke:JR,AlarmSmokeIcon:JR,Album:eF,AlbumIcon:eF,AlertCircle:Qo,AlertCircleIcon:Qo,AlertOctagon:a0,AlertOctagonIcon:a0,AlertTriangle:Mh,AlertTriangleIcon:Mh,AlignCenter:e5,AlignCenterHorizontal:tF,AlignCenterHorizontalIcon:tF,AlignCenterIcon:e5,AlignCenterVertical:sF,AlignCenterVerticalIcon:sF,AlignEndHorizontal:rF,AlignEndHorizontalIcon:rF,AlignEndVertical:nF,AlignEndVerticalIcon:nF,AlignHorizontalDistributeCenter:aF,AlignHorizontalDistributeCenterIcon:aF,AlignHorizontalDistributeEnd:iF,AlignHorizontalDistributeEndIcon:iF,AlignHorizontalDistributeStart:oF,AlignHorizontalDistributeStartIcon:oF,AlignHorizontalJustifyCenter:lF,AlignHorizontalJustifyCenterIcon:lF,AlignHorizontalJustifyEnd:cF,AlignHorizontalJustifyEndIcon:cF,AlignHorizontalJustifyStart:dF,AlignHorizontalJustifyStartIcon:dF,AlignHorizontalSpaceAround:uF,AlignHorizontalSpaceAroundIcon:uF,AlignHorizontalSpaceBetween:hF,AlignHorizontalSpaceBetweenIcon:hF,AlignJustify:mF,AlignJustifyIcon:mF,AlignLeft:t5,AlignLeftIcon:t5,AlignRight:s5,AlignRightIcon:s5,AlignStartHorizontal:pF,AlignStartHorizontalIcon:pF,AlignStartVertical:fF,AlignStartVerticalIcon:fF,AlignVerticalDistributeCenter:gF,AlignVerticalDistributeCenterIcon:gF,AlignVerticalDistributeEnd:xF,AlignVerticalDistributeEndIcon:xF,AlignVerticalDistributeStart:yF,AlignVerticalDistributeStartIcon:yF,AlignVerticalJustifyCenter:vF,AlignVerticalJustifyCenterIcon:vF,AlignVerticalJustifyEnd:_F,AlignVerticalJustifyEndIcon:_F,AlignVerticalJustifyStart:bF,AlignVerticalJustifyStartIcon:bF,AlignVerticalSpaceAround:wF,AlignVerticalSpaceAroundIcon:wF,AlignVerticalSpaceBetween:jF,AlignVerticalSpaceBetweenIcon:jF,Ambulance:kF,AmbulanceIcon:kF,Ampersand:NF,AmpersandIcon:NF,Ampersands:SF,AmpersandsIcon:SF,Amphora:CF,AmphoraIcon:CF,Anchor:MF,AnchorIcon:MF,Angry:TF,AngryIcon:TF,Annoyed:AF,AnnoyedIcon:AF,Antenna:EF,AntennaIcon:EF,Anvil:PF,AnvilIcon:PF,Aperture:IF,ApertureIcon:IF,AppWindow:HE,AppWindowIcon:HE,AppWindowMac:LF,AppWindowMacIcon:LF,Apple:DF,AppleIcon:DF,Archive:r5,ArchiveIcon:r5,ArchiveRestore:WE,ArchiveRestoreIcon:WE,ArchiveX:OF,ArchiveXIcon:OF,AreaChart:gw,AreaChartIcon:gw,Armchair:RF,ArmchairIcon:RF,ArrowBigDown:zF,ArrowBigDownDash:FF,ArrowBigDownDashIcon:FF,ArrowBigDownIcon:zF,ArrowBigLeft:$F,ArrowBigLeftDash:BF,ArrowBigLeftDashIcon:BF,ArrowBigLeftIcon:$F,ArrowBigRight:UF,ArrowBigRightDash:qF,ArrowBigRightDashIcon:qF,ArrowBigRightIcon:UF,ArrowBigUp:HF,ArrowBigUpDash:VF,ArrowBigUpDashIcon:VF,ArrowBigUpIcon:HF,ArrowDown:Ju,ArrowDown01:WF,ArrowDown01Icon:WF,ArrowDown10:GF,ArrowDown10Icon:GF,ArrowDownAZ:rw,ArrowDownAZIcon:rw,ArrowDownAz:rw,ArrowDownAzIcon:rw,ArrowDownCircle:Mw,ArrowDownCircleIcon:Mw,ArrowDownFromLine:KF,ArrowDownFromLineIcon:KF,ArrowDownIcon:Ju,ArrowDownLeft:ZF,ArrowDownLeftFromCircle:Aw,ArrowDownLeftFromCircleIcon:Aw,ArrowDownLeftFromSquare:sj,ArrowDownLeftFromSquareIcon:sj,ArrowDownLeftIcon:ZF,ArrowDownLeftSquare:Q2,ArrowDownLeftSquareIcon:Q2,ArrowDownNarrowWide:YF,ArrowDownNarrowWideIcon:YF,ArrowDownRight:GE,ArrowDownRightFromCircle:Ew,ArrowDownRightFromCircleIcon:Ew,ArrowDownRightFromSquare:rj,ArrowDownRightFromSquareIcon:rj,ArrowDownRightIcon:GE,ArrowDownRightSquare:J2,ArrowDownRightSquareIcon:J2,ArrowDownSquare:ej,ArrowDownSquareIcon:ej,ArrowDownToDot:XF,ArrowDownToDotIcon:XF,ArrowDownToLine:QF,ArrowDownToLineIcon:QF,ArrowDownUp:JF,ArrowDownUpIcon:JF,ArrowDownWideNarrow:nw,ArrowDownWideNarrowIcon:nw,ArrowDownZA:aw,ArrowDownZAIcon:aw,ArrowDownZa:aw,ArrowDownZaIcon:aw,ArrowLeft:Ka,ArrowLeftCircle:Tw,ArrowLeftCircleIcon:Tw,ArrowLeftFromLine:ez,ArrowLeftFromLineIcon:ez,ArrowLeftIcon:Ka,ArrowLeftRight:tz,ArrowLeftRightIcon:tz,ArrowLeftSquare:tj,ArrowLeftSquareIcon:tj,ArrowLeftToLine:sz,ArrowLeftToLineIcon:sz,ArrowRight:Ui,ArrowRightCircle:Lw,ArrowRightCircleIcon:Lw,ArrowRightFromLine:rz,ArrowRightFromLineIcon:rz,ArrowRightIcon:Ui,ArrowRightLeft:w0,ArrowRightLeftIcon:w0,ArrowRightSquare:ij,ArrowRightSquareIcon:ij,ArrowRightToLine:nz,ArrowRightToLineIcon:nz,ArrowUp:qd,ArrowUp01:az,ArrowUp01Icon:az,ArrowUp10:iz,ArrowUp10Icon:iz,ArrowUpAZ:iw,ArrowUpAZIcon:iw,ArrowUpAz:iw,ArrowUpAzIcon:iw,ArrowUpCircle:Dw,ArrowUpCircleIcon:Dw,ArrowUpDown:Vc,ArrowUpDownIcon:Vc,ArrowUpFromDot:oz,ArrowUpFromDotIcon:oz,ArrowUpFromLine:lz,ArrowUpFromLineIcon:lz,ArrowUpIcon:qd,ArrowUpLeft:cz,ArrowUpLeftFromCircle:Pw,ArrowUpLeftFromCircleIcon:Pw,ArrowUpLeftFromSquare:nj,ArrowUpLeftFromSquareIcon:nj,ArrowUpLeftIcon:cz,ArrowUpLeftSquare:oj,ArrowUpLeftSquareIcon:oj,ArrowUpNarrowWide:ow,ArrowUpNarrowWideIcon:ow,ArrowUpRight:KE,ArrowUpRightFromCircle:Iw,ArrowUpRightFromCircleIcon:Iw,ArrowUpRightFromSquare:aj,ArrowUpRightFromSquareIcon:aj,ArrowUpRightIcon:KE,ArrowUpRightSquare:lj,ArrowUpRightSquareIcon:lj,ArrowUpSquare:cj,ArrowUpSquareIcon:cj,ArrowUpToLine:dz,ArrowUpToLineIcon:dz,ArrowUpWideNarrow:uz,ArrowUpWideNarrowIcon:uz,ArrowUpZA:lw,ArrowUpZAIcon:lw,ArrowUpZa:lw,ArrowUpZaIcon:lw,ArrowsUpFromLine:hz,ArrowsUpFromLineIcon:hz,Asterisk:mz,AsteriskIcon:mz,AsteriskSquare:dj,AsteriskSquareIcon:dj,AtSign:pz,AtSignIcon:pz,Atom:fz,AtomIcon:fz,AudioLines:gz,AudioLinesIcon:gz,AudioWaveform:xz,AudioWaveformIcon:xz,Award:ec,AwardIcon:ec,Axe:yz,AxeIcon:yz,Axis3D:cw,Axis3DIcon:cw,Axis3d:cw,Axis3dIcon:cw,Baby:vz,BabyIcon:vz,Backpack:_z,BackpackIcon:_z,Badge:Oz,BadgeAlert:bz,BadgeAlertIcon:bz,BadgeCent:wz,BadgeCentIcon:wz,BadgeCheck:dw,BadgeCheckIcon:dw,BadgeDollarSign:jz,BadgeDollarSignIcon:jz,BadgeEuro:kz,BadgeEuroIcon:kz,BadgeHelp:Nz,BadgeHelpIcon:Nz,BadgeIcon:Oz,BadgeIndianRupee:Sz,BadgeIndianRupeeIcon:Sz,BadgeInfo:Cz,BadgeInfoIcon:Cz,BadgeJapaneseYen:Mz,BadgeJapaneseYenIcon:Mz,BadgeMinus:Tz,BadgeMinusIcon:Tz,BadgePercent:Az,BadgePercentIcon:Az,BadgePlus:Ez,BadgePlusIcon:Ez,BadgePoundSterling:Pz,BadgePoundSterlingIcon:Pz,BadgeRussianRuble:Iz,BadgeRussianRubleIcon:Iz,BadgeSwissFranc:Lz,BadgeSwissFrancIcon:Lz,BadgeX:Dz,BadgeXIcon:Dz,BaggageClaim:Rz,BaggageClaimIcon:Rz,Ban:Fz,BanIcon:Fz,Banana:zz,BananaIcon:zz,Bandage:Bz,BandageIcon:Bz,Banknote:$z,BanknoteIcon:$z,BarChart:jw,BarChart2:kw,BarChart2Icon:kw,BarChart3:Xo,BarChart3Icon:Xo,BarChart4:bw,BarChart4Icon:bw,BarChartBig:_w,BarChartBigIcon:_w,BarChartHorizontal:yw,BarChartHorizontalBig:xw,BarChartHorizontalBigIcon:xw,BarChartHorizontalIcon:yw,BarChartIcon:jw,Barcode:qz,BarcodeIcon:qz,Baseline:Uz,BaselineIcon:Uz,Bath:$x,BathIcon:$x,Battery:Zz,BatteryCharging:Vz,BatteryChargingIcon:Vz,BatteryFull:Hz,BatteryFullIcon:Hz,BatteryIcon:Zz,BatteryLow:Wz,BatteryLowIcon:Wz,BatteryMedium:Gz,BatteryMediumIcon:Gz,BatteryWarning:Kz,BatteryWarningIcon:Kz,Beaker:Yz,BeakerIcon:Yz,Bean:Qz,BeanIcon:Qz,BeanOff:Xz,BeanOffIcon:Xz,Bed:j0,BedDouble:ZE,BedDoubleIcon:ZE,BedIcon:j0,BedSingle:Jz,BedSingleIcon:Jz,Beef:e7,BeefIcon:e7,Beer:s7,BeerIcon:s7,BeerOff:t7,BeerOffIcon:t7,Bell:cf,BellDot:r7,BellDotIcon:r7,BellElectric:n7,BellElectricIcon:n7,BellIcon:cf,BellMinus:a7,BellMinusIcon:a7,BellOff:Z1,BellOffIcon:Z1,BellPlus:i7,BellPlusIcon:i7,BellRing:o7,BellRingIcon:o7,BetweenHorizonalEnd:uw,BetweenHorizonalEndIcon:uw,BetweenHorizonalStart:hw,BetweenHorizonalStartIcon:hw,BetweenHorizontalEnd:uw,BetweenHorizontalEndIcon:uw,BetweenHorizontalStart:hw,BetweenHorizontalStartIcon:hw,BetweenVerticalEnd:l7,BetweenVerticalEndIcon:l7,BetweenVerticalStart:c7,BetweenVerticalStartIcon:c7,BicepsFlexed:d7,BicepsFlexedIcon:d7,Bike:u7,BikeIcon:u7,Binary:h7,BinaryIcon:h7,Binoculars:m7,BinocularsIcon:m7,Biohazard:p7,BiohazardIcon:p7,Bird:f7,BirdIcon:f7,Bitcoin:g7,BitcoinIcon:g7,Blend:x7,BlendIcon:x7,Blinds:y7,BlindsIcon:y7,Blocks:v7,BlocksIcon:v7,Bluetooth:j7,BluetoothConnected:_7,BluetoothConnectedIcon:_7,BluetoothIcon:j7,BluetoothOff:b7,BluetoothOffIcon:b7,BluetoothSearching:w7,BluetoothSearchingIcon:w7,Bold:n5,BoldIcon:n5,Bolt:k7,BoltIcon:k7,Bomb:N7,BombIcon:N7,Bone:S7,BoneIcon:S7,Book:K7,BookA:C7,BookAIcon:C7,BookAudio:M7,BookAudioIcon:M7,BookCheck:T7,BookCheckIcon:T7,BookCopy:A7,BookCopyIcon:A7,BookDashed:mw,BookDashedIcon:mw,BookDown:E7,BookDownIcon:E7,BookHeadphones:P7,BookHeadphonesIcon:P7,BookHeart:I7,BookHeartIcon:I7,BookIcon:K7,BookImage:L7,BookImageIcon:L7,BookKey:D7,BookKeyIcon:D7,BookLock:O7,BookLockIcon:O7,BookMarked:R7,BookMarkedIcon:R7,BookMinus:F7,BookMinusIcon:F7,BookOpen:cu,BookOpenCheck:z7,BookOpenCheckIcon:z7,BookOpenIcon:cu,BookOpenText:B7,BookOpenTextIcon:B7,BookPlus:$7,BookPlusIcon:$7,BookTemplate:mw,BookTemplateIcon:mw,BookText:q7,BookTextIcon:q7,BookType:U7,BookTypeIcon:U7,BookUp:H7,BookUp2:V7,BookUp2Icon:V7,BookUpIcon:H7,BookUser:W7,BookUserIcon:W7,BookX:G7,BookXIcon:G7,Bookmark:Dg,BookmarkCheck:Z7,BookmarkCheckIcon:Z7,BookmarkIcon:Dg,BookmarkMinus:Y7,BookmarkMinusIcon:Y7,BookmarkPlus:YE,BookmarkPlusIcon:YE,BookmarkX:X7,BookmarkXIcon:X7,BoomBox:Q7,BoomBoxIcon:Q7,Bot:a5,BotIcon:a5,BotMessageSquare:J7,BotMessageSquareIcon:J7,BotOff:eB,BotOffIcon:eB,Box:tB,BoxIcon:tB,BoxSelect:_j,BoxSelectIcon:_j,Boxes:sB,BoxesIcon:sB,Braces:pw,BracesIcon:pw,Brackets:rB,BracketsIcon:rB,Brain:XE,BrainCircuit:nB,BrainCircuitIcon:nB,BrainCog:aB,BrainCogIcon:aB,BrainIcon:XE,BrickWall:iB,BrickWallIcon:iB,Briefcase:eh,BriefcaseBusiness:oB,BriefcaseBusinessIcon:oB,BriefcaseConveyorBelt:lB,BriefcaseConveyorBeltIcon:lB,BriefcaseIcon:eh,BriefcaseMedical:cB,BriefcaseMedicalIcon:cB,BringToFront:dB,BringToFrontIcon:dB,Brush:uB,BrushIcon:uB,Bug:pB,BugIcon:pB,BugOff:hB,BugOffIcon:hB,BugPlay:mB,BugPlayIcon:mB,Building:Yk,Building2:Ca,Building2Icon:Ca,BuildingIcon:Yk,Bus:gB,BusFront:fB,BusFrontIcon:fB,BusIcon:gB,Cable:yB,CableCar:xB,CableCarIcon:xB,CableIcon:yB,Cake:Ou,CakeIcon:Ou,CakeSlice:vB,CakeSliceIcon:vB,Calculator:_B,CalculatorIcon:_B,Calendar:on,Calendar1:bB,Calendar1Icon:bB,CalendarArrowDown:wB,CalendarArrowDownIcon:wB,CalendarArrowUp:jB,CalendarArrowUpIcon:jB,CalendarCheck:NB,CalendarCheck2:kB,CalendarCheck2Icon:kB,CalendarCheckIcon:NB,CalendarClock:QE,CalendarClockIcon:QE,CalendarCog:SB,CalendarCogIcon:SB,CalendarDays:kc,CalendarDaysIcon:kc,CalendarFold:CB,CalendarFoldIcon:CB,CalendarHeart:MB,CalendarHeartIcon:MB,CalendarIcon:on,CalendarMinus:AB,CalendarMinus2:TB,CalendarMinus2Icon:TB,CalendarMinusIcon:AB,CalendarOff:JE,CalendarOffIcon:JE,CalendarPlus:Y1,CalendarPlus2:EB,CalendarPlus2Icon:EB,CalendarPlusIcon:Y1,CalendarRange:PB,CalendarRangeIcon:PB,CalendarSearch:IB,CalendarSearchIcon:IB,CalendarSync:LB,CalendarSyncIcon:LB,CalendarX:OB,CalendarX2:DB,CalendarX2Icon:DB,CalendarXIcon:OB,Camera:Og,CameraIcon:Og,CameraOff:RB,CameraOffIcon:RB,CandlestickChart:vw,CandlestickChartIcon:vw,Candy:BB,CandyCane:FB,CandyCaneIcon:FB,CandyIcon:BB,CandyOff:zB,CandyOffIcon:zB,Cannabis:$B,CannabisIcon:$B,Captions:fw,CaptionsIcon:fw,CaptionsOff:qB,CaptionsOffIcon:qB,Car:HB,CarFront:UB,CarFrontIcon:UB,CarIcon:HB,CarTaxiFront:VB,CarTaxiFrontIcon:VB,Caravan:WB,CaravanIcon:WB,Carrot:GB,CarrotIcon:GB,CaseLower:KB,CaseLowerIcon:KB,CaseSensitive:ZB,CaseSensitiveIcon:ZB,CaseUpper:YB,CaseUpperIcon:YB,CassetteTape:XB,CassetteTapeIcon:XB,Cast:QB,CastIcon:QB,Castle:JB,CastleIcon:JB,Cat:e9,CatIcon:e9,Cctv:t9,CctvIcon:t9,ChartArea:gw,ChartAreaIcon:gw,ChartBar:yw,ChartBarBig:xw,ChartBarBigIcon:xw,ChartBarDecreasing:s9,ChartBarDecreasingIcon:s9,ChartBarIcon:yw,ChartBarIncreasing:r9,ChartBarIncreasingIcon:r9,ChartBarStacked:n9,ChartBarStackedIcon:n9,ChartCandlestick:vw,ChartCandlestickIcon:vw,ChartColumn:Xo,ChartColumnBig:_w,ChartColumnBigIcon:_w,ChartColumnDecreasing:a9,ChartColumnDecreasingIcon:a9,ChartColumnIcon:Xo,ChartColumnIncreasing:bw,ChartColumnIncreasingIcon:bw,ChartColumnStacked:i9,ChartColumnStackedIcon:i9,ChartGantt:o9,ChartGanttIcon:o9,ChartLine:ww,ChartLineIcon:ww,ChartNetwork:l9,ChartNetworkIcon:l9,ChartNoAxesColumn:kw,ChartNoAxesColumnDecreasing:c9,ChartNoAxesColumnDecreasingIcon:c9,ChartNoAxesColumnIcon:kw,ChartNoAxesColumnIncreasing:jw,ChartNoAxesColumnIncreasingIcon:jw,ChartNoAxesCombined:d9,ChartNoAxesCombinedIcon:d9,ChartNoAxesGantt:Nw,ChartNoAxesGanttIcon:Nw,ChartPie:Sw,ChartPieIcon:Sw,ChartScatter:Cw,ChartScatterIcon:Cw,ChartSpline:u9,ChartSplineIcon:u9,Check:fa,CheckCheck:h9,CheckCheckIcon:h9,CheckCircle:fi,CheckCircle2:la,CheckCircle2Icon:la,CheckCircleIcon:fi,CheckIcon:fa,CheckSquare:l0,CheckSquare2:hj,CheckSquare2Icon:hj,CheckSquareIcon:l0,ChefHat:m9,ChefHatIcon:m9,Cherry:p9,CherryIcon:p9,ChevronDown:Vo,ChevronDownCircle:Ow,ChevronDownCircleIcon:Ow,ChevronDownIcon:Vo,ChevronDownSquare:mj,ChevronDownSquareIcon:mj,ChevronFirst:f9,ChevronFirstIcon:f9,ChevronLast:g9,ChevronLastIcon:g9,ChevronLeft:Ol,ChevronLeftCircle:Rw,ChevronLeftCircleIcon:Rw,ChevronLeftIcon:Ol,ChevronLeftSquare:pj,ChevronLeftSquareIcon:pj,ChevronRight:qa,ChevronRightCircle:Fw,ChevronRightCircleIcon:Fw,ChevronRightIcon:qa,ChevronRightSquare:fj,ChevronRightSquareIcon:fj,ChevronUp:Rg,ChevronUpCircle:zw,ChevronUpCircleIcon:zw,ChevronUpIcon:Rg,ChevronUpSquare:gj,ChevronUpSquareIcon:gj,ChevronsDown:y9,ChevronsDownIcon:y9,ChevronsDownUp:x9,ChevronsDownUpIcon:x9,ChevronsLeft:b9,ChevronsLeftIcon:b9,ChevronsLeftRight:_9,ChevronsLeftRightEllipsis:v9,ChevronsLeftRightEllipsisIcon:v9,ChevronsLeftRightIcon:_9,ChevronsRight:j9,ChevronsRightIcon:j9,ChevronsRightLeft:w9,ChevronsRightLeftIcon:w9,ChevronsUp:k9,ChevronsUpDown:df,ChevronsUpDownIcon:df,ChevronsUpIcon:k9,Chrome:N9,ChromeIcon:N9,Church:S9,ChurchIcon:S9,Cigarette:M9,CigaretteIcon:M9,CigaretteOff:C9,CigaretteOffIcon:C9,Circle:Wc,CircleAlert:Qo,CircleAlertIcon:Qo,CircleArrowDown:Mw,CircleArrowDownIcon:Mw,CircleArrowLeft:Tw,CircleArrowLeftIcon:Tw,CircleArrowOutDownLeft:Aw,CircleArrowOutDownLeftIcon:Aw,CircleArrowOutDownRight:Ew,CircleArrowOutDownRightIcon:Ew,CircleArrowOutUpLeft:Pw,CircleArrowOutUpLeftIcon:Pw,CircleArrowOutUpRight:Iw,CircleArrowOutUpRightIcon:Iw,CircleArrowRight:Lw,CircleArrowRightIcon:Lw,CircleArrowUp:Dw,CircleArrowUpIcon:Dw,CircleCheck:la,CircleCheckBig:fi,CircleCheckBigIcon:fi,CircleCheckIcon:la,CircleChevronDown:Ow,CircleChevronDownIcon:Ow,CircleChevronLeft:Rw,CircleChevronLeftIcon:Rw,CircleChevronRight:Fw,CircleChevronRightIcon:Fw,CircleChevronUp:zw,CircleChevronUpIcon:zw,CircleDashed:T9,CircleDashedIcon:T9,CircleDivide:Bw,CircleDivideIcon:Bw,CircleDollarSign:A9,CircleDollarSignIcon:A9,CircleDot:P9,CircleDotDashed:E9,CircleDotDashedIcon:E9,CircleDotIcon:P9,CircleEllipsis:I9,CircleEllipsisIcon:I9,CircleEqual:L9,CircleEqualIcon:L9,CircleFadingArrowUp:D9,CircleFadingArrowUpIcon:D9,CircleFadingPlus:O9,CircleFadingPlusIcon:O9,CircleGauge:$w,CircleGaugeIcon:$w,CircleHelp:n0,CircleHelpIcon:n0,CircleIcon:Wc,CircleMinus:qw,CircleMinusIcon:qw,CircleOff:R9,CircleOffIcon:R9,CircleParking:Vw,CircleParkingIcon:Vw,CircleParkingOff:Uw,CircleParkingOffIcon:Uw,CirclePause:Hw,CirclePauseIcon:Hw,CirclePercent:Ww,CirclePercentIcon:Ww,CirclePlay:gm,CirclePlayIcon:gm,CirclePlus:Gw,CirclePlusIcon:Gw,CirclePower:Kw,CirclePowerIcon:Kw,CircleSlash:F9,CircleSlash2:Zw,CircleSlash2Icon:Zw,CircleSlashIcon:F9,CircleSlashed:Zw,CircleSlashedIcon:Zw,CircleStop:Yw,CircleStopIcon:Yw,CircleUser:Qw,CircleUserIcon:Qw,CircleUserRound:Xw,CircleUserRoundIcon:Xw,CircleX:wc,CircleXIcon:wc,CircuitBoard:z9,CircuitBoardIcon:z9,Citrus:B9,CitrusIcon:B9,Clapperboard:$9,ClapperboardIcon:$9,Clipboard:K9,ClipboardCheck:i5,ClipboardCheckIcon:i5,ClipboardCopy:q9,ClipboardCopyIcon:q9,ClipboardEdit:e2,ClipboardEditIcon:e2,ClipboardIcon:K9,ClipboardList:X1,ClipboardListIcon:X1,ClipboardMinus:U9,ClipboardMinusIcon:U9,ClipboardPaste:V9,ClipboardPasteIcon:V9,ClipboardPen:e2,ClipboardPenIcon:e2,ClipboardPenLine:Jw,ClipboardPenLineIcon:Jw,ClipboardPlus:H9,ClipboardPlusIcon:H9,ClipboardSignature:Jw,ClipboardSignatureIcon:Jw,ClipboardType:W9,ClipboardTypeIcon:W9,ClipboardX:G9,ClipboardXIcon:G9,Clock:In,Clock1:Z9,Clock10:Y9,Clock10Icon:Y9,Clock11:X9,Clock11Icon:X9,Clock12:Q9,Clock12Icon:Q9,Clock1Icon:Z9,Clock2:J9,Clock2Icon:J9,Clock3:e$,Clock3Icon:e$,Clock4:t$,Clock4Icon:t$,Clock5:s$,Clock5Icon:s$,Clock6:r$,Clock6Icon:r$,Clock7:n$,Clock7Icon:n$,Clock8:a$,Clock8Icon:a$,Clock9:i$,Clock9Icon:i$,ClockAlert:o$,ClockAlertIcon:o$,ClockArrowDown:l$,ClockArrowDownIcon:l$,ClockArrowUp:c$,ClockArrowUpIcon:c$,ClockIcon:In,Cloud:k$,CloudAlert:d$,CloudAlertIcon:d$,CloudCog:u$,CloudCogIcon:u$,CloudDownload:t2,CloudDownloadIcon:t2,CloudDrizzle:h$,CloudDrizzleIcon:h$,CloudFog:m$,CloudFogIcon:m$,CloudHail:p$,CloudHailIcon:p$,CloudIcon:k$,CloudLightning:f$,CloudLightningIcon:f$,CloudMoon:x$,CloudMoonIcon:x$,CloudMoonRain:g$,CloudMoonRainIcon:g$,CloudOff:y$,CloudOffIcon:y$,CloudRain:_$,CloudRainIcon:_$,CloudRainWind:v$,CloudRainWindIcon:v$,CloudSnow:b$,CloudSnowIcon:b$,CloudSun:j$,CloudSunIcon:j$,CloudSunRain:w$,CloudSunRainIcon:w$,CloudUpload:s2,CloudUploadIcon:s2,Cloudy:N$,CloudyIcon:N$,Clover:g0,CloverIcon:g0,Club:S$,ClubIcon:S$,Code:Xk,Code2:r2,Code2Icon:r2,CodeIcon:Xk,CodeSquare:xj,CodeSquareIcon:xj,CodeXml:r2,CodeXmlIcon:r2,Codepen:C$,CodepenIcon:C$,Codesandbox:M$,CodesandboxIcon:M$,Coffee:Qk,CoffeeIcon:Qk,Cog:T$,CogIcon:T$,Coins:eP,CoinsIcon:eP,Columns:n2,Columns2:n2,Columns2Icon:n2,Columns3:a2,Columns3Icon:a2,Columns4:A$,Columns4Icon:A$,ColumnsIcon:n2,Combine:E$,CombineIcon:E$,Command:P$,CommandIcon:P$,Compass:I$,CompassIcon:I$,Component:L$,ComponentIcon:L$,Computer:D$,ComputerIcon:D$,ConciergeBell:O$,ConciergeBellIcon:O$,Cone:R$,ConeIcon:R$,Construction:F$,ConstructionIcon:F$,Contact:Jk,Contact2:i2,Contact2Icon:i2,ContactIcon:Jk,ContactRound:i2,ContactRoundIcon:i2,Container:z$,ContainerIcon:z$,Contrast:B$,ContrastIcon:B$,Cookie:$$,CookieIcon:$$,CookingPot:q$,CookingPotIcon:q$,Copy:ai,CopyCheck:U$,CopyCheckIcon:U$,CopyIcon:ai,CopyMinus:V$,CopyMinusIcon:V$,CopyPlus:H$,CopyPlusIcon:H$,CopySlash:W$,CopySlashIcon:W$,CopyX:G$,CopyXIcon:G$,Copyleft:K$,CopyleftIcon:K$,Copyright:Z$,CopyrightIcon:Z$,CornerDownLeft:Y$,CornerDownLeftIcon:Y$,CornerDownRight:X$,CornerDownRightIcon:X$,CornerLeftDown:Q$,CornerLeftDownIcon:Q$,CornerLeftUp:J$,CornerLeftUpIcon:J$,CornerRightDown:eq,CornerRightDownIcon:eq,CornerRightUp:tq,CornerRightUpIcon:tq,CornerUpLeft:sq,CornerUpLeftIcon:sq,CornerUpRight:rq,CornerUpRightIcon:rq,Cpu:nq,CpuIcon:nq,CreativeCommons:aq,CreativeCommonsIcon:aq,CreditCard:mp,CreditCardIcon:mp,Croissant:iq,CroissantIcon:iq,Crop:oq,CropIcon:oq,Cross:lq,CrossIcon:lq,Crosshair:cq,CrosshairIcon:cq,Crown:zh,CrownIcon:zh,Cuboid:dq,CuboidIcon:dq,CupSoda:uq,CupSodaIcon:uq,CurlyBraces:pw,CurlyBracesIcon:pw,Currency:hq,CurrencyIcon:hq,Cylinder:mq,CylinderIcon:mq,Dam:pq,DamIcon:pq,Database:xq,DatabaseBackup:fq,DatabaseBackupIcon:fq,DatabaseIcon:xq,DatabaseZap:gq,DatabaseZapIcon:gq,Delete:yq,DeleteIcon:yq,Dessert:vq,DessertIcon:vq,Diameter:_q,DiameterIcon:_q,Diamond:jq,DiamondIcon:jq,DiamondMinus:bq,DiamondMinusIcon:bq,DiamondPercent:o2,DiamondPercentIcon:o2,DiamondPlus:wq,DiamondPlusIcon:wq,Dice1:kq,Dice1Icon:kq,Dice2:Nq,Dice2Icon:Nq,Dice3:Sq,Dice3Icon:Sq,Dice4:Cq,Dice4Icon:Cq,Dice5:Mq,Dice5Icon:Mq,Dice6:Tq,Dice6Icon:Tq,Dices:Aq,DicesIcon:Aq,Diff:Eq,DiffIcon:Eq,Disc:Dq,Disc2:Pq,Disc2Icon:Pq,Disc3:Iq,Disc3Icon:Iq,DiscAlbum:Lq,DiscAlbumIcon:Lq,DiscIcon:Dq,Divide:Oq,DivideCircle:Bw,DivideCircleIcon:Bw,DivideIcon:Oq,DivideSquare:bj,DivideSquareIcon:bj,Dna:Fq,DnaIcon:Fq,DnaOff:Rq,DnaOffIcon:Rq,Dock:zq,DockIcon:zq,Dog:Bq,DogIcon:Bq,DollarSign:Gc,DollarSignIcon:Gc,Donut:$q,DonutIcon:$q,DoorClosed:qq,DoorClosedIcon:qq,DoorOpen:k0,DoorOpenIcon:k0,Dot:Uq,DotIcon:Uq,DotSquare:wj,DotSquareIcon:wj,Download:gi,DownloadCloud:t2,DownloadCloudIcon:t2,DownloadIcon:gi,DraftingCompass:Vq,DraftingCompassIcon:Vq,Drama:Hq,DramaIcon:Hq,Dribbble:Wq,DribbbleIcon:Wq,Drill:Gq,DrillIcon:Gq,Droplet:Kq,DropletIcon:Kq,Droplets:qx,DropletsIcon:qx,Drum:Zq,DrumIcon:Zq,Drumstick:Yq,DrumstickIcon:Yq,Dumbbell:Xq,DumbbellIcon:Xq,Ear:Jq,EarIcon:Jq,EarOff:Qq,EarOffIcon:Qq,Earth:l2,EarthIcon:l2,EarthLock:eU,EarthLockIcon:eU,Eclipse:tU,EclipseIcon:tU,Edit:Dc,Edit2:Ax,Edit2Icon:Ax,Edit3:o0,Edit3Icon:o0,EditIcon:Dc,Egg:o5,EggFried:sU,EggFriedIcon:sU,EggIcon:o5,EggOff:rU,EggOffIcon:rU,Ellipsis:ef,EllipsisIcon:ef,EllipsisVertical:Jp,EllipsisVerticalIcon:Jp,Equal:iU,EqualApproximately:nU,EqualApproximatelyIcon:nU,EqualIcon:iU,EqualNot:aU,EqualNotIcon:aU,EqualSquare:jj,EqualSquareIcon:jj,Eraser:oU,EraserIcon:oU,EthernetPort:lU,EthernetPortIcon:lU,Euro:cU,EuroIcon:cU,Expand:dU,ExpandIcon:dU,ExternalLink:rn,ExternalLinkIcon:rn,Eye:ya,EyeClosed:uU,EyeClosedIcon:uU,EyeIcon:ya,EyeOff:Tm,EyeOffIcon:Tm,Facebook:Ud,FacebookIcon:Ud,Factory:hU,FactoryIcon:hU,Fan:mU,FanIcon:mU,FastForward:pU,FastForwardIcon:pU,Feather:fU,FeatherIcon:fU,Fence:gU,FenceIcon:gU,FerrisWheel:xU,FerrisWheelIcon:xU,Figma:yU,FigmaIcon:yU,File:l5,FileArchive:vU,FileArchiveIcon:vU,FileAudio:bU,FileAudio2:_U,FileAudio2Icon:_U,FileAudioIcon:bU,FileAxis3D:c2,FileAxis3DIcon:c2,FileAxis3d:c2,FileAxis3dIcon:c2,FileBadge:jU,FileBadge2:wU,FileBadge2Icon:wU,FileBadgeIcon:jU,FileBarChart:d2,FileBarChart2:u2,FileBarChart2Icon:u2,FileBarChartIcon:d2,FileBox:kU,FileBoxIcon:kU,FileChartColumn:u2,FileChartColumnIcon:u2,FileChartColumnIncreasing:d2,FileChartColumnIncreasingIcon:d2,FileChartLine:h2,FileChartLineIcon:h2,FileChartPie:m2,FileChartPieIcon:m2,FileCheck:SU,FileCheck2:NU,FileCheck2Icon:NU,FileCheckIcon:SU,FileClock:CU,FileClockIcon:CU,FileCode:TU,FileCode2:MU,FileCode2Icon:MU,FileCodeIcon:TU,FileCog:p2,FileCog2:p2,FileCog2Icon:p2,FileCogIcon:p2,FileDiff:AU,FileDiffIcon:AU,FileDigit:EU,FileDigitIcon:EU,FileDown:PU,FileDownIcon:PU,FileEdit:g2,FileEditIcon:g2,FileHeart:IU,FileHeartIcon:IU,FileIcon:l5,FileImage:Q1,FileImageIcon:Q1,FileInput:LU,FileInputIcon:LU,FileJson:OU,FileJson2:DU,FileJson2Icon:DU,FileJsonIcon:OU,FileKey:FU,FileKey2:RU,FileKey2Icon:RU,FileKeyIcon:FU,FileLineChart:h2,FileLineChartIcon:h2,FileLock:BU,FileLock2:zU,FileLock2Icon:zU,FileLockIcon:BU,FileMinus:qU,FileMinus2:$U,FileMinus2Icon:$U,FileMinusIcon:qU,FileMusic:UU,FileMusicIcon:UU,FileOutput:VU,FileOutputIcon:VU,FilePen:g2,FilePenIcon:g2,FilePenLine:f2,FilePenLineIcon:f2,FilePieChart:m2,FilePieChartIcon:m2,FilePlus:WU,FilePlus2:HU,FilePlus2Icon:HU,FilePlusIcon:WU,FileQuestion:GU,FileQuestionIcon:GU,FileScan:KU,FileScanIcon:KU,FileSearch:YU,FileSearch2:ZU,FileSearch2Icon:ZU,FileSearchIcon:YU,FileSignature:f2,FileSignatureIcon:f2,FileSliders:XU,FileSlidersIcon:XU,FileSpreadsheet:N0,FileSpreadsheetIcon:N0,FileStack:tP,FileStackIcon:tP,FileSymlink:QU,FileSymlinkIcon:QU,FileTerminal:JU,FileTerminalIcon:JU,FileText:Sn,FileTextIcon:Sn,FileType:tV,FileType2:eV,FileType2Icon:eV,FileTypeIcon:tV,FileUp:sV,FileUpIcon:sV,FileUser:rV,FileUserIcon:rV,FileVideo:aV,FileVideo2:nV,FileVideo2Icon:nV,FileVideoIcon:aV,FileVolume:oV,FileVolume2:iV,FileVolume2Icon:iV,FileVolumeIcon:oV,FileWarning:lV,FileWarningIcon:lV,FileX:dV,FileX2:cV,FileX2Icon:cV,FileXIcon:dV,Files:uV,FilesIcon:uV,Film:au,FilmIcon:au,Filter:Ux,FilterIcon:Ux,FilterX:hV,FilterXIcon:hV,Fingerprint:mV,FingerprintIcon:mV,FireExtinguisher:pV,FireExtinguisherIcon:pV,Fish:xV,FishIcon:xV,FishOff:fV,FishOffIcon:fV,FishSymbol:gV,FishSymbolIcon:gV,Flag:S0,FlagIcon:S0,FlagOff:yV,FlagOffIcon:yV,FlagTriangleLeft:vV,FlagTriangleLeftIcon:vV,FlagTriangleRight:_V,FlagTriangleRightIcon:_V,Flame:Bh,FlameIcon:Bh,FlameKindling:bV,FlameKindlingIcon:bV,Flashlight:jV,FlashlightIcon:jV,FlashlightOff:wV,FlashlightOffIcon:wV,FlaskConical:J1,FlaskConicalIcon:J1,FlaskConicalOff:kV,FlaskConicalOffIcon:kV,FlaskRound:NV,FlaskRoundIcon:NV,FlipHorizontal:CV,FlipHorizontal2:SV,FlipHorizontal2Icon:SV,FlipHorizontalIcon:CV,FlipVertical:TV,FlipVertical2:MV,FlipVertical2Icon:MV,FlipVerticalIcon:TV,Flower:AV,Flower2:Ag,Flower2Icon:Ag,FlowerIcon:AV,Focus:EV,FocusIcon:EV,FoldHorizontal:PV,FoldHorizontalIcon:PV,FoldVertical:IV,FoldVerticalIcon:IV,Folder:iH,FolderArchive:LV,FolderArchiveIcon:LV,FolderCheck:DV,FolderCheckIcon:DV,FolderClock:OV,FolderClockIcon:OV,FolderClosed:RV,FolderClosedIcon:RV,FolderCode:FV,FolderCodeIcon:FV,FolderCog:x2,FolderCog2:x2,FolderCog2Icon:x2,FolderCogIcon:x2,FolderDot:zV,FolderDotIcon:zV,FolderDown:BV,FolderDownIcon:BV,FolderEdit:y2,FolderEditIcon:y2,FolderGit:qV,FolderGit2:$V,FolderGit2Icon:$V,FolderGitIcon:qV,FolderHeart:UV,FolderHeartIcon:UV,FolderIcon:iH,FolderInput:VV,FolderInputIcon:VV,FolderKanban:HV,FolderKanbanIcon:HV,FolderKey:WV,FolderKeyIcon:WV,FolderLock:GV,FolderLockIcon:GV,FolderMinus:KV,FolderMinusIcon:KV,FolderOpen:$h,FolderOpenDot:ZV,FolderOpenDotIcon:ZV,FolderOpenIcon:$h,FolderOutput:YV,FolderOutputIcon:YV,FolderPen:y2,FolderPenIcon:y2,FolderPlus:XV,FolderPlusIcon:XV,FolderRoot:QV,FolderRootIcon:QV,FolderSearch:eH,FolderSearch2:JV,FolderSearch2Icon:JV,FolderSearchIcon:eH,FolderSymlink:tH,FolderSymlinkIcon:tH,FolderSync:sH,FolderSyncIcon:sH,FolderTree:rH,FolderTreeIcon:rH,FolderUp:nH,FolderUpIcon:nH,FolderX:aH,FolderXIcon:aH,Folders:oH,FoldersIcon:oH,Footprints:lH,FootprintsIcon:lH,ForkKnife:lk,ForkKnifeCrossed:ok,ForkKnifeCrossedIcon:ok,ForkKnifeIcon:lk,Forklift:cH,ForkliftIcon:cH,FormInput:U2,FormInputIcon:U2,Forward:dH,ForwardIcon:dH,Frame:uH,FrameIcon:uH,Framer:hH,FramerIcon:hH,Frown:mH,FrownIcon:mH,Fuel:pH,FuelIcon:pH,Fullscreen:fH,FullscreenIcon:fH,FunctionSquare:kj,FunctionSquareIcon:kj,GalleryHorizontal:xH,GalleryHorizontalEnd:gH,GalleryHorizontalEndIcon:gH,GalleryHorizontalIcon:xH,GalleryThumbnails:yH,GalleryThumbnailsIcon:yH,GalleryVertical:_H,GalleryVerticalEnd:vH,GalleryVerticalEndIcon:vH,GalleryVerticalIcon:_H,Gamepad:wH,Gamepad2:bH,Gamepad2Icon:bH,GamepadIcon:wH,GanttChart:Nw,GanttChartIcon:Nw,GanttChartSquare:_x,GanttChartSquareIcon:_x,Gauge:jH,GaugeCircle:$w,GaugeCircleIcon:$w,GaugeIcon:jH,Gavel:kH,GavelIcon:kH,Gem:NH,GemIcon:NH,Ghost:eN,GhostIcon:eN,Gift:ao,GiftIcon:ao,GitBranch:CH,GitBranchIcon:CH,GitBranchPlus:SH,GitBranchPlusIcon:SH,GitCommit:v2,GitCommitHorizontal:v2,GitCommitHorizontalIcon:v2,GitCommitIcon:v2,GitCommitVertical:MH,GitCommitVerticalIcon:MH,GitCompare:AH,GitCompareArrows:TH,GitCompareArrowsIcon:TH,GitCompareIcon:AH,GitFork:EH,GitForkIcon:EH,GitGraph:PH,GitGraphIcon:PH,GitMerge:IH,GitMergeIcon:IH,GitPullRequest:zH,GitPullRequestArrow:LH,GitPullRequestArrowIcon:LH,GitPullRequestClosed:DH,GitPullRequestClosedIcon:DH,GitPullRequestCreate:RH,GitPullRequestCreateArrow:OH,GitPullRequestCreateArrowIcon:OH,GitPullRequestCreateIcon:RH,GitPullRequestDraft:FH,GitPullRequestDraftIcon:FH,GitPullRequestIcon:zH,Github:BH,GithubIcon:BH,Gitlab:$H,GitlabIcon:$H,GlassWater:qH,GlassWaterIcon:qH,Glasses:UH,GlassesIcon:UH,Globe:Am,Globe2:l2,Globe2Icon:l2,GlobeIcon:Am,GlobeLock:VH,GlobeLockIcon:VH,Goal:HH,GoalIcon:HH,Grab:WH,GrabIcon:WH,GraduationCap:th,GraduationCapIcon:th,Grape:GH,GrapeIcon:GH,Grid:ep,Grid2X2:b2,Grid2X2Icon:b2,Grid2X2Plus:_2,Grid2X2PlusIcon:_2,Grid2x2:b2,Grid2x2Check:KH,Grid2x2CheckIcon:KH,Grid2x2Icon:b2,Grid2x2Plus:_2,Grid2x2PlusIcon:_2,Grid2x2X:ZH,Grid2x2XIcon:ZH,Grid3X3:ep,Grid3X3Icon:ep,Grid3x3:ep,Grid3x3Icon:ep,GridIcon:ep,Grip:XH,GripHorizontal:YH,GripHorizontalIcon:YH,GripIcon:XH,GripVertical:Ru,GripVerticalIcon:Ru,Group:QH,GroupIcon:QH,Guitar:JH,GuitarIcon:JH,Ham:eW,HamIcon:eW,Hammer:tW,HammerIcon:tW,Hand:sP,HandCoins:sW,HandCoinsIcon:sW,HandHeart:rW,HandHeartIcon:rW,HandHelping:w2,HandHelpingIcon:w2,HandIcon:sP,HandMetal:nW,HandMetalIcon:nW,HandPlatter:aW,HandPlatterIcon:aW,Handshake:rP,HandshakeIcon:rP,HardDrive:nP,HardDriveDownload:iW,HardDriveDownloadIcon:iW,HardDriveIcon:nP,HardDriveUpload:oW,HardDriveUploadIcon:oW,HardHat:lW,HardHatIcon:lW,Hash:c5,HashIcon:c5,Haze:cW,HazeIcon:cW,HdmiPort:dW,HdmiPortIcon:dW,Heading:fW,Heading1:aP,Heading1Icon:aP,Heading2:iP,Heading2Icon:iP,Heading3:uW,Heading3Icon:uW,Heading4:hW,Heading4Icon:hW,Heading5:mW,Heading5Icon:mW,Heading6:pW,Heading6Icon:pW,HeadingIcon:fW,HeadphoneOff:gW,HeadphoneOffIcon:gW,Headphones:xW,HeadphonesIcon:xW,Headset:yW,HeadsetIcon:yW,Heart:Ni,HeartCrack:vW,HeartCrackIcon:vW,HeartHandshake:_W,HeartHandshakeIcon:_W,HeartIcon:Ni,HeartOff:bW,HeartOffIcon:bW,HeartPulse:wW,HeartPulseIcon:wW,Heater:jW,HeaterIcon:jW,HelpCircle:n0,HelpCircleIcon:n0,HelpingHand:w2,HelpingHandIcon:w2,Hexagon:kW,HexagonIcon:kW,Highlighter:NW,HighlighterIcon:NW,History:d5,HistoryIcon:d5,Home:Vn,HomeIcon:Vn,Hop:CW,HopIcon:CW,HopOff:SW,HopOffIcon:SW,Hospital:MW,HospitalIcon:MW,Hotel:TW,HotelIcon:TW,Hourglass:AW,HourglassIcon:AW,House:Vn,HouseIcon:Vn,HousePlug:EW,HousePlugIcon:EW,HousePlus:PW,HousePlusIcon:PW,IceCream:k2,IceCream2:j2,IceCream2Icon:j2,IceCreamBowl:j2,IceCreamBowlIcon:j2,IceCreamCone:k2,IceCreamConeIcon:k2,IceCreamIcon:k2,Icon:hRe,IdCard:IW,IdCardIcon:IW,Image:Jo,ImageDown:LW,ImageDownIcon:LW,ImageIcon:Jo,ImageMinus:DW,ImageMinusIcon:DW,ImageOff:OW,ImageOffIcon:OW,ImagePlay:RW,ImagePlayIcon:RW,ImagePlus:C0,ImagePlusIcon:C0,ImageUp:FW,ImageUpIcon:FW,ImageUpscale:zW,ImageUpscaleIcon:zW,Images:BW,ImagesIcon:BW,Import:$W,ImportIcon:$W,Inbox:qW,InboxIcon:qW,Indent:S2,IndentDecrease:N2,IndentDecreaseIcon:N2,IndentIcon:S2,IndentIncrease:S2,IndentIncreaseIcon:S2,IndianRupee:UW,IndianRupeeIcon:UW,Infinity:VW,InfinityIcon:VW,Info:oP,InfoIcon:oP,Inspect:Aj,InspectIcon:Aj,InspectionPanel:HW,InspectionPanelIcon:HW,Instagram:Vd,InstagramIcon:Vd,Italic:u5,ItalicIcon:u5,IterationCcw:WW,IterationCcwIcon:WW,IterationCw:GW,IterationCwIcon:GW,JapaneseYen:KW,JapaneseYenIcon:KW,Joystick:ZW,JoystickIcon:ZW,Kanban:Vx,KanbanIcon:Vx,KanbanSquare:Nj,KanbanSquareDashed:yj,KanbanSquareDashedIcon:yj,KanbanSquareIcon:Nj,Key:Em,KeyIcon:Em,KeyRound:tN,KeyRoundIcon:tN,KeySquare:YW,KeySquareIcon:YW,Keyboard:JW,KeyboardIcon:JW,KeyboardMusic:XW,KeyboardMusicIcon:XW,KeyboardOff:QW,KeyboardOffIcon:QW,Lamp:aG,LampCeiling:eG,LampCeilingIcon:eG,LampDesk:tG,LampDeskIcon:tG,LampFloor:sG,LampFloorIcon:sG,LampIcon:aG,LampWallDown:rG,LampWallDownIcon:rG,LampWallUp:nG,LampWallUpIcon:nG,LandPlot:iG,LandPlotIcon:iG,Landmark:oG,LandmarkIcon:oG,Languages:lG,LanguagesIcon:lG,Laptop:dG,Laptop2:C2,Laptop2Icon:C2,LaptopIcon:dG,LaptopMinimal:C2,LaptopMinimalCheck:cG,LaptopMinimalCheckIcon:cG,LaptopMinimalIcon:C2,Lasso:hG,LassoIcon:hG,LassoSelect:uG,LassoSelectIcon:uG,Laugh:mG,LaughIcon:mG,Layers:gG,Layers2:pG,Layers2Icon:pG,Layers3:fG,Layers3Icon:fG,LayersIcon:gG,Layout:i0,LayoutDashboard:sN,LayoutDashboardIcon:sN,LayoutGrid:pp,LayoutGridIcon:pp,LayoutIcon:i0,LayoutList:xG,LayoutListIcon:xG,LayoutPanelLeft:yG,LayoutPanelLeftIcon:yG,LayoutPanelTop:vG,LayoutPanelTopIcon:vG,LayoutTemplate:rN,LayoutTemplateIcon:rN,Leaf:_G,LeafIcon:_G,LeafyGreen:bG,LeafyGreenIcon:bG,Lectern:wG,LecternIcon:wG,LetterText:jG,LetterTextIcon:jG,Library:h5,LibraryBig:kG,LibraryBigIcon:kG,LibraryIcon:h5,LibrarySquare:Sj,LibrarySquareIcon:Sj,LifeBuoy:m5,LifeBuoyIcon:m5,Ligature:NG,LigatureIcon:NG,Lightbulb:e_,LightbulbIcon:e_,LightbulbOff:SG,LightbulbOffIcon:SG,LineChart:ww,LineChartIcon:ww,Link:Io,Link2:Ho,Link2Icon:Ho,Link2Off:CG,Link2OffIcon:CG,LinkIcon:Io,Linkedin:Pm,LinkedinIcon:Pm,List:qh,ListCheck:MG,ListCheckIcon:MG,ListChecks:TG,ListChecksIcon:TG,ListCollapse:AG,ListCollapseIcon:AG,ListEnd:EG,ListEndIcon:EG,ListFilter:PG,ListFilterIcon:PG,ListIcon:qh,ListMinus:IG,ListMinusIcon:IG,ListMusic:LG,ListMusicIcon:LG,ListOrdered:M0,ListOrderedIcon:M0,ListPlus:DG,ListPlusIcon:DG,ListRestart:OG,ListRestartIcon:OG,ListStart:RG,ListStartIcon:RG,ListTodo:FG,ListTodoIcon:FG,ListTree:zG,ListTreeIcon:zG,ListVideo:BG,ListVideoIcon:BG,ListX:$G,ListXIcon:$G,Loader:UG,Loader2:As,Loader2Icon:As,LoaderCircle:As,LoaderCircleIcon:As,LoaderIcon:UG,LoaderPinwheel:qG,LoaderPinwheelIcon:qG,Locate:lP,LocateFixed:VG,LocateFixedIcon:VG,LocateIcon:lP,LocateOff:HG,LocateOffIcon:HG,Lock:Fu,LockIcon:Fu,LockKeyhole:WG,LockKeyholeIcon:WG,LockKeyholeOpen:M2,LockKeyholeOpenIcon:M2,LockOpen:T2,LockOpenIcon:T2,LogIn:p5,LogInIcon:p5,LogOut:f5,LogOutIcon:f5,Logs:GG,LogsIcon:GG,Lollipop:KG,LollipopIcon:KG,LucideAArrowDown:HR,LucideAArrowUp:WR,LucideALargeSmall:GR,LucideAccessibility:KR,LucideActivity:Mm,LucideActivitySquare:X2,LucideAirVent:ZR,LucideAirplay:YR,LucideAlarmCheck:ew,LucideAlarmClock:QR,LucideAlarmClockCheck:ew,LucideAlarmClockMinus:tw,LucideAlarmClockOff:XR,LucideAlarmClockPlus:sw,LucideAlarmMinus:tw,LucideAlarmPlus:sw,LucideAlarmSmoke:JR,LucideAlbum:eF,LucideAlertCircle:Qo,LucideAlertOctagon:a0,LucideAlertTriangle:Mh,LucideAlignCenter:e5,LucideAlignCenterHorizontal:tF,LucideAlignCenterVertical:sF,LucideAlignEndHorizontal:rF,LucideAlignEndVertical:nF,LucideAlignHorizontalDistributeCenter:aF,LucideAlignHorizontalDistributeEnd:iF,LucideAlignHorizontalDistributeStart:oF,LucideAlignHorizontalJustifyCenter:lF,LucideAlignHorizontalJustifyEnd:cF,LucideAlignHorizontalJustifyStart:dF,LucideAlignHorizontalSpaceAround:uF,LucideAlignHorizontalSpaceBetween:hF,LucideAlignJustify:mF,LucideAlignLeft:t5,LucideAlignRight:s5,LucideAlignStartHorizontal:pF,LucideAlignStartVertical:fF,LucideAlignVerticalDistributeCenter:gF,LucideAlignVerticalDistributeEnd:xF,LucideAlignVerticalDistributeStart:yF,LucideAlignVerticalJustifyCenter:vF,LucideAlignVerticalJustifyEnd:_F,LucideAlignVerticalJustifyStart:bF,LucideAlignVerticalSpaceAround:wF,LucideAlignVerticalSpaceBetween:jF,LucideAmbulance:kF,LucideAmpersand:NF,LucideAmpersands:SF,LucideAmphora:CF,LucideAnchor:MF,LucideAngry:TF,LucideAnnoyed:AF,LucideAntenna:EF,LucideAnvil:PF,LucideAperture:IF,LucideAppWindow:HE,LucideAppWindowMac:LF,LucideApple:DF,LucideArchive:r5,LucideArchiveRestore:WE,LucideArchiveX:OF,LucideAreaChart:gw,LucideArmchair:RF,LucideArrowBigDown:zF,LucideArrowBigDownDash:FF,LucideArrowBigLeft:$F,LucideArrowBigLeftDash:BF,LucideArrowBigRight:UF,LucideArrowBigRightDash:qF,LucideArrowBigUp:HF,LucideArrowBigUpDash:VF,LucideArrowDown:Ju,LucideArrowDown01:WF,LucideArrowDown10:GF,LucideArrowDownAZ:rw,LucideArrowDownAz:rw,LucideArrowDownCircle:Mw,LucideArrowDownFromLine:KF,LucideArrowDownLeft:ZF,LucideArrowDownLeftFromCircle:Aw,LucideArrowDownLeftFromSquare:sj,LucideArrowDownLeftSquare:Q2,LucideArrowDownNarrowWide:YF,LucideArrowDownRight:GE,LucideArrowDownRightFromCircle:Ew,LucideArrowDownRightFromSquare:rj,LucideArrowDownRightSquare:J2,LucideArrowDownSquare:ej,LucideArrowDownToDot:XF,LucideArrowDownToLine:QF,LucideArrowDownUp:JF,LucideArrowDownWideNarrow:nw,LucideArrowDownZA:aw,LucideArrowDownZa:aw,LucideArrowLeft:Ka,LucideArrowLeftCircle:Tw,LucideArrowLeftFromLine:ez,LucideArrowLeftRight:tz,LucideArrowLeftSquare:tj,LucideArrowLeftToLine:sz,LucideArrowRight:Ui,LucideArrowRightCircle:Lw,LucideArrowRightFromLine:rz,LucideArrowRightLeft:w0,LucideArrowRightSquare:ij,LucideArrowRightToLine:nz,LucideArrowUp:qd,LucideArrowUp01:az,LucideArrowUp10:iz,LucideArrowUpAZ:iw,LucideArrowUpAz:iw,LucideArrowUpCircle:Dw,LucideArrowUpDown:Vc,LucideArrowUpFromDot:oz,LucideArrowUpFromLine:lz,LucideArrowUpLeft:cz,LucideArrowUpLeftFromCircle:Pw,LucideArrowUpLeftFromSquare:nj,LucideArrowUpLeftSquare:oj,LucideArrowUpNarrowWide:ow,LucideArrowUpRight:KE,LucideArrowUpRightFromCircle:Iw,LucideArrowUpRightFromSquare:aj,LucideArrowUpRightSquare:lj,LucideArrowUpSquare:cj,LucideArrowUpToLine:dz,LucideArrowUpWideNarrow:uz,LucideArrowUpZA:lw,LucideArrowUpZa:lw,LucideArrowsUpFromLine:hz,LucideAsterisk:mz,LucideAsteriskSquare:dj,LucideAtSign:pz,LucideAtom:fz,LucideAudioLines:gz,LucideAudioWaveform:xz,LucideAward:ec,LucideAxe:yz,LucideAxis3D:cw,LucideAxis3d:cw,LucideBaby:vz,LucideBackpack:_z,LucideBadge:Oz,LucideBadgeAlert:bz,LucideBadgeCent:wz,LucideBadgeCheck:dw,LucideBadgeDollarSign:jz,LucideBadgeEuro:kz,LucideBadgeHelp:Nz,LucideBadgeIndianRupee:Sz,LucideBadgeInfo:Cz,LucideBadgeJapaneseYen:Mz,LucideBadgeMinus:Tz,LucideBadgePercent:Az,LucideBadgePlus:Ez,LucideBadgePoundSterling:Pz,LucideBadgeRussianRuble:Iz,LucideBadgeSwissFranc:Lz,LucideBadgeX:Dz,LucideBaggageClaim:Rz,LucideBan:Fz,LucideBanana:zz,LucideBandage:Bz,LucideBanknote:$z,LucideBarChart:jw,LucideBarChart2:kw,LucideBarChart3:Xo,LucideBarChart4:bw,LucideBarChartBig:_w,LucideBarChartHorizontal:yw,LucideBarChartHorizontalBig:xw,LucideBarcode:qz,LucideBaseline:Uz,LucideBath:$x,LucideBattery:Zz,LucideBatteryCharging:Vz,LucideBatteryFull:Hz,LucideBatteryLow:Wz,LucideBatteryMedium:Gz,LucideBatteryWarning:Kz,LucideBeaker:Yz,LucideBean:Qz,LucideBeanOff:Xz,LucideBed:j0,LucideBedDouble:ZE,LucideBedSingle:Jz,LucideBeef:e7,LucideBeer:s7,LucideBeerOff:t7,LucideBell:cf,LucideBellDot:r7,LucideBellElectric:n7,LucideBellMinus:a7,LucideBellOff:Z1,LucideBellPlus:i7,LucideBellRing:o7,LucideBetweenHorizonalEnd:uw,LucideBetweenHorizonalStart:hw,LucideBetweenHorizontalEnd:uw,LucideBetweenHorizontalStart:hw,LucideBetweenVerticalEnd:l7,LucideBetweenVerticalStart:c7,LucideBicepsFlexed:d7,LucideBike:u7,LucideBinary:h7,LucideBinoculars:m7,LucideBiohazard:p7,LucideBird:f7,LucideBitcoin:g7,LucideBlend:x7,LucideBlinds:y7,LucideBlocks:v7,LucideBluetooth:j7,LucideBluetoothConnected:_7,LucideBluetoothOff:b7,LucideBluetoothSearching:w7,LucideBold:n5,LucideBolt:k7,LucideBomb:N7,LucideBone:S7,LucideBook:K7,LucideBookA:C7,LucideBookAudio:M7,LucideBookCheck:T7,LucideBookCopy:A7,LucideBookDashed:mw,LucideBookDown:E7,LucideBookHeadphones:P7,LucideBookHeart:I7,LucideBookImage:L7,LucideBookKey:D7,LucideBookLock:O7,LucideBookMarked:R7,LucideBookMinus:F7,LucideBookOpen:cu,LucideBookOpenCheck:z7,LucideBookOpenText:B7,LucideBookPlus:$7,LucideBookTemplate:mw,LucideBookText:q7,LucideBookType:U7,LucideBookUp:H7,LucideBookUp2:V7,LucideBookUser:W7,LucideBookX:G7,LucideBookmark:Dg,LucideBookmarkCheck:Z7,LucideBookmarkMinus:Y7,LucideBookmarkPlus:YE,LucideBookmarkX:X7,LucideBoomBox:Q7,LucideBot:a5,LucideBotMessageSquare:J7,LucideBotOff:eB,LucideBox:tB,LucideBoxSelect:_j,LucideBoxes:sB,LucideBraces:pw,LucideBrackets:rB,LucideBrain:XE,LucideBrainCircuit:nB,LucideBrainCog:aB,LucideBrickWall:iB,LucideBriefcase:eh,LucideBriefcaseBusiness:oB,LucideBriefcaseConveyorBelt:lB,LucideBriefcaseMedical:cB,LucideBringToFront:dB,LucideBrush:uB,LucideBug:pB,LucideBugOff:hB,LucideBugPlay:mB,LucideBuilding:Yk,LucideBuilding2:Ca,LucideBus:gB,LucideBusFront:fB,LucideCable:yB,LucideCableCar:xB,LucideCake:Ou,LucideCakeSlice:vB,LucideCalculator:_B,LucideCalendar:on,LucideCalendar1:bB,LucideCalendarArrowDown:wB,LucideCalendarArrowUp:jB,LucideCalendarCheck:NB,LucideCalendarCheck2:kB,LucideCalendarClock:QE,LucideCalendarCog:SB,LucideCalendarDays:kc,LucideCalendarFold:CB,LucideCalendarHeart:MB,LucideCalendarMinus:AB,LucideCalendarMinus2:TB,LucideCalendarOff:JE,LucideCalendarPlus:Y1,LucideCalendarPlus2:EB,LucideCalendarRange:PB,LucideCalendarSearch:IB,LucideCalendarSync:LB,LucideCalendarX:OB,LucideCalendarX2:DB,LucideCamera:Og,LucideCameraOff:RB,LucideCandlestickChart:vw,LucideCandy:BB,LucideCandyCane:FB,LucideCandyOff:zB,LucideCannabis:$B,LucideCaptions:fw,LucideCaptionsOff:qB,LucideCar:HB,LucideCarFront:UB,LucideCarTaxiFront:VB,LucideCaravan:WB,LucideCarrot:GB,LucideCaseLower:KB,LucideCaseSensitive:ZB,LucideCaseUpper:YB,LucideCassetteTape:XB,LucideCast:QB,LucideCastle:JB,LucideCat:e9,LucideCctv:t9,LucideChartArea:gw,LucideChartBar:yw,LucideChartBarBig:xw,LucideChartBarDecreasing:s9,LucideChartBarIncreasing:r9,LucideChartBarStacked:n9,LucideChartCandlestick:vw,LucideChartColumn:Xo,LucideChartColumnBig:_w,LucideChartColumnDecreasing:a9,LucideChartColumnIncreasing:bw,LucideChartColumnStacked:i9,LucideChartGantt:o9,LucideChartLine:ww,LucideChartNetwork:l9,LucideChartNoAxesColumn:kw,LucideChartNoAxesColumnDecreasing:c9,LucideChartNoAxesColumnIncreasing:jw,LucideChartNoAxesCombined:d9,LucideChartNoAxesGantt:Nw,LucideChartPie:Sw,LucideChartScatter:Cw,LucideChartSpline:u9,LucideCheck:fa,LucideCheckCheck:h9,LucideCheckCircle:fi,LucideCheckCircle2:la,LucideCheckSquare:l0,LucideCheckSquare2:hj,LucideChefHat:m9,LucideCherry:p9,LucideChevronDown:Vo,LucideChevronDownCircle:Ow,LucideChevronDownSquare:mj,LucideChevronFirst:f9,LucideChevronLast:g9,LucideChevronLeft:Ol,LucideChevronLeftCircle:Rw,LucideChevronLeftSquare:pj,LucideChevronRight:qa,LucideChevronRightCircle:Fw,LucideChevronRightSquare:fj,LucideChevronUp:Rg,LucideChevronUpCircle:zw,LucideChevronUpSquare:gj,LucideChevronsDown:y9,LucideChevronsDownUp:x9,LucideChevronsLeft:b9,LucideChevronsLeftRight:_9,LucideChevronsLeftRightEllipsis:v9,LucideChevronsRight:j9,LucideChevronsRightLeft:w9,LucideChevronsUp:k9,LucideChevronsUpDown:df,LucideChrome:N9,LucideChurch:S9,LucideCigarette:M9,LucideCigaretteOff:C9,LucideCircle:Wc,LucideCircleAlert:Qo,LucideCircleArrowDown:Mw,LucideCircleArrowLeft:Tw,LucideCircleArrowOutDownLeft:Aw,LucideCircleArrowOutDownRight:Ew,LucideCircleArrowOutUpLeft:Pw,LucideCircleArrowOutUpRight:Iw,LucideCircleArrowRight:Lw,LucideCircleArrowUp:Dw,LucideCircleCheck:la,LucideCircleCheckBig:fi,LucideCircleChevronDown:Ow,LucideCircleChevronLeft:Rw,LucideCircleChevronRight:Fw,LucideCircleChevronUp:zw,LucideCircleDashed:T9,LucideCircleDivide:Bw,LucideCircleDollarSign:A9,LucideCircleDot:P9,LucideCircleDotDashed:E9,LucideCircleEllipsis:I9,LucideCircleEqual:L9,LucideCircleFadingArrowUp:D9,LucideCircleFadingPlus:O9,LucideCircleGauge:$w,LucideCircleHelp:n0,LucideCircleMinus:qw,LucideCircleOff:R9,LucideCircleParking:Vw,LucideCircleParkingOff:Uw,LucideCirclePause:Hw,LucideCirclePercent:Ww,LucideCirclePlay:gm,LucideCirclePlus:Gw,LucideCirclePower:Kw,LucideCircleSlash:F9,LucideCircleSlash2:Zw,LucideCircleSlashed:Zw,LucideCircleStop:Yw,LucideCircleUser:Qw,LucideCircleUserRound:Xw,LucideCircleX:wc,LucideCircuitBoard:z9,LucideCitrus:B9,LucideClapperboard:$9,LucideClipboard:K9,LucideClipboardCheck:i5,LucideClipboardCopy:q9,LucideClipboardEdit:e2,LucideClipboardList:X1,LucideClipboardMinus:U9,LucideClipboardPaste:V9,LucideClipboardPen:e2,LucideClipboardPenLine:Jw,LucideClipboardPlus:H9,LucideClipboardSignature:Jw,LucideClipboardType:W9,LucideClipboardX:G9,LucideClock:In,LucideClock1:Z9,LucideClock10:Y9,LucideClock11:X9,LucideClock12:Q9,LucideClock2:J9,LucideClock3:e$,LucideClock4:t$,LucideClock5:s$,LucideClock6:r$,LucideClock7:n$,LucideClock8:a$,LucideClock9:i$,LucideClockAlert:o$,LucideClockArrowDown:l$,LucideClockArrowUp:c$,LucideCloud:k$,LucideCloudAlert:d$,LucideCloudCog:u$,LucideCloudDownload:t2,LucideCloudDrizzle:h$,LucideCloudFog:m$,LucideCloudHail:p$,LucideCloudLightning:f$,LucideCloudMoon:x$,LucideCloudMoonRain:g$,LucideCloudOff:y$,LucideCloudRain:_$,LucideCloudRainWind:v$,LucideCloudSnow:b$,LucideCloudSun:j$,LucideCloudSunRain:w$,LucideCloudUpload:s2,LucideCloudy:N$,LucideClover:g0,LucideClub:S$,LucideCode:Xk,LucideCode2:r2,LucideCodeSquare:xj,LucideCodeXml:r2,LucideCodepen:C$,LucideCodesandbox:M$,LucideCoffee:Qk,LucideCog:T$,LucideCoins:eP,LucideColumns:n2,LucideColumns2:n2,LucideColumns3:a2,LucideColumns4:A$,LucideCombine:E$,LucideCommand:P$,LucideCompass:I$,LucideComponent:L$,LucideComputer:D$,LucideConciergeBell:O$,LucideCone:R$,LucideConstruction:F$,LucideContact:Jk,LucideContact2:i2,LucideContactRound:i2,LucideContainer:z$,LucideContrast:B$,LucideCookie:$$,LucideCookingPot:q$,LucideCopy:ai,LucideCopyCheck:U$,LucideCopyMinus:V$,LucideCopyPlus:H$,LucideCopySlash:W$,LucideCopyX:G$,LucideCopyleft:K$,LucideCopyright:Z$,LucideCornerDownLeft:Y$,LucideCornerDownRight:X$,LucideCornerLeftDown:Q$,LucideCornerLeftUp:J$,LucideCornerRightDown:eq,LucideCornerRightUp:tq,LucideCornerUpLeft:sq,LucideCornerUpRight:rq,LucideCpu:nq,LucideCreativeCommons:aq,LucideCreditCard:mp,LucideCroissant:iq,LucideCrop:oq,LucideCross:lq,LucideCrosshair:cq,LucideCrown:zh,LucideCuboid:dq,LucideCupSoda:uq,LucideCurlyBraces:pw,LucideCurrency:hq,LucideCylinder:mq,LucideDam:pq,LucideDatabase:xq,LucideDatabaseBackup:fq,LucideDatabaseZap:gq,LucideDelete:yq,LucideDessert:vq,LucideDiameter:_q,LucideDiamond:jq,LucideDiamondMinus:bq,LucideDiamondPercent:o2,LucideDiamondPlus:wq,LucideDice1:kq,LucideDice2:Nq,LucideDice3:Sq,LucideDice4:Cq,LucideDice5:Mq,LucideDice6:Tq,LucideDices:Aq,LucideDiff:Eq,LucideDisc:Dq,LucideDisc2:Pq,LucideDisc3:Iq,LucideDiscAlbum:Lq,LucideDivide:Oq,LucideDivideCircle:Bw,LucideDivideSquare:bj,LucideDna:Fq,LucideDnaOff:Rq,LucideDock:zq,LucideDog:Bq,LucideDollarSign:Gc,LucideDonut:$q,LucideDoorClosed:qq,LucideDoorOpen:k0,LucideDot:Uq,LucideDotSquare:wj,LucideDownload:gi,LucideDownloadCloud:t2,LucideDraftingCompass:Vq,LucideDrama:Hq,LucideDribbble:Wq,LucideDrill:Gq,LucideDroplet:Kq,LucideDroplets:qx,LucideDrum:Zq,LucideDrumstick:Yq,LucideDumbbell:Xq,LucideEar:Jq,LucideEarOff:Qq,LucideEarth:l2,LucideEarthLock:eU,LucideEclipse:tU,LucideEdit:Dc,LucideEdit2:Ax,LucideEdit3:o0,LucideEgg:o5,LucideEggFried:sU,LucideEggOff:rU,LucideEllipsis:ef,LucideEllipsisVertical:Jp,LucideEqual:iU,LucideEqualApproximately:nU,LucideEqualNot:aU,LucideEqualSquare:jj,LucideEraser:oU,LucideEthernetPort:lU,LucideEuro:cU,LucideExpand:dU,LucideExternalLink:rn,LucideEye:ya,LucideEyeClosed:uU,LucideEyeOff:Tm,LucideFacebook:Ud,LucideFactory:hU,LucideFan:mU,LucideFastForward:pU,LucideFeather:fU,LucideFence:gU,LucideFerrisWheel:xU,LucideFigma:yU,LucideFile:l5,LucideFileArchive:vU,LucideFileAudio:bU,LucideFileAudio2:_U,LucideFileAxis3D:c2,LucideFileAxis3d:c2,LucideFileBadge:jU,LucideFileBadge2:wU,LucideFileBarChart:d2,LucideFileBarChart2:u2,LucideFileBox:kU,LucideFileChartColumn:u2,LucideFileChartColumnIncreasing:d2,LucideFileChartLine:h2,LucideFileChartPie:m2,LucideFileCheck:SU,LucideFileCheck2:NU,LucideFileClock:CU,LucideFileCode:TU,LucideFileCode2:MU,LucideFileCog:p2,LucideFileCog2:p2,LucideFileDiff:AU,LucideFileDigit:EU,LucideFileDown:PU,LucideFileEdit:g2,LucideFileHeart:IU,LucideFileImage:Q1,LucideFileInput:LU,LucideFileJson:OU,LucideFileJson2:DU,LucideFileKey:FU,LucideFileKey2:RU,LucideFileLineChart:h2,LucideFileLock:BU,LucideFileLock2:zU,LucideFileMinus:qU,LucideFileMinus2:$U,LucideFileMusic:UU,LucideFileOutput:VU,LucideFilePen:g2,LucideFilePenLine:f2,LucideFilePieChart:m2,LucideFilePlus:WU,LucideFilePlus2:HU,LucideFileQuestion:GU,LucideFileScan:KU,LucideFileSearch:YU,LucideFileSearch2:ZU,LucideFileSignature:f2,LucideFileSliders:XU,LucideFileSpreadsheet:N0,LucideFileStack:tP,LucideFileSymlink:QU,LucideFileTerminal:JU,LucideFileText:Sn,LucideFileType:tV,LucideFileType2:eV,LucideFileUp:sV,LucideFileUser:rV,LucideFileVideo:aV,LucideFileVideo2:nV,LucideFileVolume:oV,LucideFileVolume2:iV,LucideFileWarning:lV,LucideFileX:dV,LucideFileX2:cV,LucideFiles:uV,LucideFilm:au,LucideFilter:Ux,LucideFilterX:hV,LucideFingerprint:mV,LucideFireExtinguisher:pV,LucideFish:xV,LucideFishOff:fV,LucideFishSymbol:gV,LucideFlag:S0,LucideFlagOff:yV,LucideFlagTriangleLeft:vV,LucideFlagTriangleRight:_V,LucideFlame:Bh,LucideFlameKindling:bV,LucideFlashlight:jV,LucideFlashlightOff:wV,LucideFlaskConical:J1,LucideFlaskConicalOff:kV,LucideFlaskRound:NV,LucideFlipHorizontal:CV,LucideFlipHorizontal2:SV,LucideFlipVertical:TV,LucideFlipVertical2:MV,LucideFlower:AV,LucideFlower2:Ag,LucideFocus:EV,LucideFoldHorizontal:PV,LucideFoldVertical:IV,LucideFolder:iH,LucideFolderArchive:LV,LucideFolderCheck:DV,LucideFolderClock:OV,LucideFolderClosed:RV,LucideFolderCode:FV,LucideFolderCog:x2,LucideFolderCog2:x2,LucideFolderDot:zV,LucideFolderDown:BV,LucideFolderEdit:y2,LucideFolderGit:qV,LucideFolderGit2:$V,LucideFolderHeart:UV,LucideFolderInput:VV,LucideFolderKanban:HV,LucideFolderKey:WV,LucideFolderLock:GV,LucideFolderMinus:KV,LucideFolderOpen:$h,LucideFolderOpenDot:ZV,LucideFolderOutput:YV,LucideFolderPen:y2,LucideFolderPlus:XV,LucideFolderRoot:QV,LucideFolderSearch:eH,LucideFolderSearch2:JV,LucideFolderSymlink:tH,LucideFolderSync:sH,LucideFolderTree:rH,LucideFolderUp:nH,LucideFolderX:aH,LucideFolders:oH,LucideFootprints:lH,LucideForkKnife:lk,LucideForkKnifeCrossed:ok,LucideForklift:cH,LucideFormInput:U2,LucideForward:dH,LucideFrame:uH,LucideFramer:hH,LucideFrown:mH,LucideFuel:pH,LucideFullscreen:fH,LucideFunctionSquare:kj,LucideGalleryHorizontal:xH,LucideGalleryHorizontalEnd:gH,LucideGalleryThumbnails:yH,LucideGalleryVertical:_H,LucideGalleryVerticalEnd:vH,LucideGamepad:wH,LucideGamepad2:bH,LucideGanttChart:Nw,LucideGanttChartSquare:_x,LucideGauge:jH,LucideGaugeCircle:$w,LucideGavel:kH,LucideGem:NH,LucideGhost:eN,LucideGift:ao,LucideGitBranch:CH,LucideGitBranchPlus:SH,LucideGitCommit:v2,LucideGitCommitHorizontal:v2,LucideGitCommitVertical:MH,LucideGitCompare:AH,LucideGitCompareArrows:TH,LucideGitFork:EH,LucideGitGraph:PH,LucideGitMerge:IH,LucideGitPullRequest:zH,LucideGitPullRequestArrow:LH,LucideGitPullRequestClosed:DH,LucideGitPullRequestCreate:RH,LucideGitPullRequestCreateArrow:OH,LucideGitPullRequestDraft:FH,LucideGithub:BH,LucideGitlab:$H,LucideGlassWater:qH,LucideGlasses:UH,LucideGlobe:Am,LucideGlobe2:l2,LucideGlobeLock:VH,LucideGoal:HH,LucideGrab:WH,LucideGraduationCap:th,LucideGrape:GH,LucideGrid:ep,LucideGrid2X2:b2,LucideGrid2X2Plus:_2,LucideGrid2x2:b2,LucideGrid2x2Check:KH,LucideGrid2x2Plus:_2,LucideGrid2x2X:ZH,LucideGrid3X3:ep,LucideGrid3x3:ep,LucideGrip:XH,LucideGripHorizontal:YH,LucideGripVertical:Ru,LucideGroup:QH,LucideGuitar:JH,LucideHam:eW,LucideHammer:tW,LucideHand:sP,LucideHandCoins:sW,LucideHandHeart:rW,LucideHandHelping:w2,LucideHandMetal:nW,LucideHandPlatter:aW,LucideHandshake:rP,LucideHardDrive:nP,LucideHardDriveDownload:iW,LucideHardDriveUpload:oW,LucideHardHat:lW,LucideHash:c5,LucideHaze:cW,LucideHdmiPort:dW,LucideHeading:fW,LucideHeading1:aP,LucideHeading2:iP,LucideHeading3:uW,LucideHeading4:hW,LucideHeading5:mW,LucideHeading6:pW,LucideHeadphoneOff:gW,LucideHeadphones:xW,LucideHeadset:yW,LucideHeart:Ni,LucideHeartCrack:vW,LucideHeartHandshake:_W,LucideHeartOff:bW,LucideHeartPulse:wW,LucideHeater:jW,LucideHelpCircle:n0,LucideHelpingHand:w2,LucideHexagon:kW,LucideHighlighter:NW,LucideHistory:d5,LucideHome:Vn,LucideHop:CW,LucideHopOff:SW,LucideHospital:MW,LucideHotel:TW,LucideHourglass:AW,LucideHouse:Vn,LucideHousePlug:EW,LucideHousePlus:PW,LucideIceCream:k2,LucideIceCream2:j2,LucideIceCreamBowl:j2,LucideIceCreamCone:k2,LucideIdCard:IW,LucideImage:Jo,LucideImageDown:LW,LucideImageMinus:DW,LucideImageOff:OW,LucideImagePlay:RW,LucideImagePlus:C0,LucideImageUp:FW,LucideImageUpscale:zW,LucideImages:BW,LucideImport:$W,LucideInbox:qW,LucideIndent:S2,LucideIndentDecrease:N2,LucideIndentIncrease:S2,LucideIndianRupee:UW,LucideInfinity:VW,LucideInfo:oP,LucideInspect:Aj,LucideInspectionPanel:HW,LucideInstagram:Vd,LucideItalic:u5,LucideIterationCcw:WW,LucideIterationCw:GW,LucideJapaneseYen:KW,LucideJoystick:ZW,LucideKanban:Vx,LucideKanbanSquare:Nj,LucideKanbanSquareDashed:yj,LucideKey:Em,LucideKeyRound:tN,LucideKeySquare:YW,LucideKeyboard:JW,LucideKeyboardMusic:XW,LucideKeyboardOff:QW,LucideLamp:aG,LucideLampCeiling:eG,LucideLampDesk:tG,LucideLampFloor:sG,LucideLampWallDown:rG,LucideLampWallUp:nG,LucideLandPlot:iG,LucideLandmark:oG,LucideLanguages:lG,LucideLaptop:dG,LucideLaptop2:C2,LucideLaptopMinimal:C2,LucideLaptopMinimalCheck:cG,LucideLasso:hG,LucideLassoSelect:uG,LucideLaugh:mG,LucideLayers:gG,LucideLayers2:pG,LucideLayers3:fG,LucideLayout:i0,LucideLayoutDashboard:sN,LucideLayoutGrid:pp,LucideLayoutList:xG,LucideLayoutPanelLeft:yG,LucideLayoutPanelTop:vG,LucideLayoutTemplate:rN,LucideLeaf:_G,LucideLeafyGreen:bG,LucideLectern:wG,LucideLetterText:jG,LucideLibrary:h5,LucideLibraryBig:kG,LucideLibrarySquare:Sj,LucideLifeBuoy:m5,LucideLigature:NG,LucideLightbulb:e_,LucideLightbulbOff:SG,LucideLineChart:ww,LucideLink:Io,LucideLink2:Ho,LucideLink2Off:CG,LucideLinkedin:Pm,LucideList:qh,LucideListCheck:MG,LucideListChecks:TG,LucideListCollapse:AG,LucideListEnd:EG,LucideListFilter:PG,LucideListMinus:IG,LucideListMusic:LG,LucideListOrdered:M0,LucideListPlus:DG,LucideListRestart:OG,LucideListStart:RG,LucideListTodo:FG,LucideListTree:zG,LucideListVideo:BG,LucideListX:$G,LucideLoader:UG,LucideLoader2:As,LucideLoaderCircle:As,LucideLoaderPinwheel:qG,LucideLocate:lP,LucideLocateFixed:VG,LucideLocateOff:HG,LucideLock:Fu,LucideLockKeyhole:WG,LucideLockKeyholeOpen:M2,LucideLockOpen:T2,LucideLogIn:p5,LucideLogOut:f5,LucideLogs:GG,LucideLollipop:KG,LucideLuggage:ZG,LucideMSquare:Cj,LucideMagnet:YG,LucideMail:br,LucideMailCheck:XG,LucideMailMinus:QG,LucideMailOpen:JG,LucideMailPlus:eK,LucideMailQuestion:tK,LucideMailSearch:sK,LucideMailWarning:rK,LucideMailX:cP,LucideMailbox:nK,LucideMails:aK,LucideMap:xK,LucideMapPin:Ti,LucideMapPinCheck:oK,LucideMapPinCheckInside:iK,LucideMapPinHouse:lK,LucideMapPinMinus:dK,LucideMapPinMinusInside:cK,LucideMapPinOff:uK,LucideMapPinPlus:mK,LucideMapPinPlusInside:hK,LucideMapPinX:fK,LucideMapPinXInside:pK,LucideMapPinned:gK,LucideMartini:yK,LucideMaximize:dP,LucideMaximize2:vK,LucideMedal:T0,LucideMegaphone:Fg,LucideMegaphoneOff:_K,LucideMeh:bK,LucideMemoryStick:wK,LucideMenu:uP,LucideMenuSquare:Mj,LucideMerge:jK,LucideMessageCircle:pc,LucideMessageCircleCode:kK,LucideMessageCircleDashed:NK,LucideMessageCircleHeart:g5,LucideMessageCircleMore:SK,LucideMessageCircleOff:CK,LucideMessageCirclePlus:MK,LucideMessageCircleQuestion:hP,LucideMessageCircleReply:TK,LucideMessageCircleWarning:AK,LucideMessageCircleX:EK,LucideMessageSquare:io,LucideMessageSquareCode:PK,LucideMessageSquareDashed:IK,LucideMessageSquareDiff:LK,LucideMessageSquareDot:DK,LucideMessageSquareHeart:OK,LucideMessageSquareLock:RK,LucideMessageSquareMore:mP,LucideMessageSquareOff:FK,LucideMessageSquarePlus:x5,LucideMessageSquareQuote:pP,LucideMessageSquareReply:zK,LucideMessageSquareShare:BK,LucideMessageSquareText:$K,LucideMessageSquareWarning:qK,LucideMessageSquareX:UK,LucideMessagesSquare:VK,LucideMic:fP,LucideMic2:A2,LucideMicOff:HK,LucideMicVocal:A2,LucideMicrochip:WK,LucideMicroscope:GK,LucideMicrowave:KK,LucideMilestone:ZK,LucideMilk:XK,LucideMilkOff:YK,LucideMinimize:JK,LucideMinimize2:QK,LucideMinus:A0,LucideMinusCircle:qw,LucideMinusSquare:Tj,LucideMonitor:nN,LucideMonitorCheck:eZ,LucideMonitorCog:tZ,LucideMonitorDot:sZ,LucideMonitorDown:rZ,LucideMonitorOff:nZ,LucideMonitorPause:aZ,LucideMonitorPlay:iZ,LucideMonitorSmartphone:oZ,LucideMonitorSpeaker:lZ,LucideMonitorStop:cZ,LucideMonitorUp:dZ,LucideMonitorX:uZ,LucideMoon:mZ,LucideMoonStar:hZ,LucideMoreHorizontal:ef,LucideMoreVertical:Jp,LucideMountain:fZ,LucideMountainSnow:pZ,LucideMouse:vZ,LucideMouseOff:gZ,LucideMousePointer:bm,LucideMousePointer2:xZ,LucideMousePointerBan:yZ,LucideMousePointerClick:t_,LucideMousePointerSquareDashed:vj,LucideMove:PZ,LucideMove3D:E2,LucideMove3d:E2,LucideMoveDiagonal:bZ,LucideMoveDiagonal2:_Z,LucideMoveDown:kZ,LucideMoveDownLeft:wZ,LucideMoveDownRight:jZ,LucideMoveHorizontal:NZ,LucideMoveLeft:SZ,LucideMoveRight:CZ,LucideMoveUp:AZ,LucideMoveUpLeft:MZ,LucideMoveUpRight:TZ,LucideMoveVertical:EZ,LucideMusic:OZ,LucideMusic2:IZ,LucideMusic3:LZ,LucideMusic4:DZ,LucideNavigation:gP,LucideNavigation2:FZ,LucideNavigation2Off:RZ,LucideNavigationOff:zZ,LucideNetwork:BZ,LucideNewspaper:E0,LucideNfc:$Z,LucideNotebook:HZ,LucideNotebookPen:qZ,LucideNotebookTabs:UZ,LucideNotebookText:VZ,LucideNotepadText:GZ,LucideNotepadTextDashed:WZ,LucideNut:ZZ,LucideNutOff:KZ,LucideOctagon:XZ,LucideOctagonAlert:a0,LucideOctagonMinus:YZ,LucideOctagonPause:P2,LucideOctagonX:I2,LucideOmega:QZ,LucideOption:JZ,LucideOrbit:eY,LucideOrigami:tY,LucideOutdent:N2,LucidePackage:cl,LucidePackage2:sY,LucidePackageCheck:rY,LucidePackageMinus:nY,LucidePackageOpen:aY,LucidePackagePlus:iY,LucidePackageSearch:oY,LucidePackageX:lY,LucidePaintBucket:cY,LucidePaintRoller:dY,LucidePaintbrush:uY,LucidePaintbrush2:L2,LucidePaintbrushVertical:L2,LucidePalette:Rl,LucidePalmtree:Xj,LucidePanelBottom:pY,LucidePanelBottomClose:hY,LucidePanelBottomDashed:D2,LucidePanelBottomInactive:D2,LucidePanelBottomOpen:mY,LucidePanelLeft:z2,LucidePanelLeftClose:O2,LucidePanelLeftDashed:R2,LucidePanelLeftInactive:R2,LucidePanelLeftOpen:F2,LucidePanelRight:xY,LucidePanelRightClose:fY,LucidePanelRightDashed:B2,LucidePanelRightInactive:B2,LucidePanelRightOpen:gY,LucidePanelTop:_Y,LucidePanelTopClose:yY,LucidePanelTopDashed:$2,LucidePanelTopInactive:$2,LucidePanelTopOpen:vY,LucidePanelsLeftBottom:bY,LucidePanelsLeftRight:a2,LucidePanelsRightBottom:wY,LucidePanelsTopBottom:W2,LucidePanelsTopLeft:i0,LucidePaperclip:aN,LucideParentheses:jY,LucideParkingCircle:Vw,LucideParkingCircleOff:Uw,LucideParkingMeter:kY,LucideParkingSquare:Pj,LucideParkingSquareOff:Ej,LucidePartyPopper:Nd,LucidePause:fp,LucidePauseCircle:Hw,LucidePauseOctagon:P2,LucidePawPrint:NY,LucidePcCase:SY,LucidePen:Ax,LucidePenBox:Dc,LucidePenLine:o0,LucidePenOff:CY,LucidePenSquare:Dc,LucidePenTool:s_,LucidePencil:Ua,LucidePencilLine:MY,LucidePencilOff:TY,LucidePencilRuler:AY,LucidePentagon:EY,LucidePercent:y5,LucidePercentCircle:Ww,LucidePercentDiamond:o2,LucidePercentSquare:Ij,LucidePersonStanding:PY,LucidePhilippinePeso:IY,LucidePhone:Zn,LucidePhoneCall:LY,LucidePhoneForwarded:DY,LucidePhoneIncoming:OY,LucidePhoneMissed:RY,LucidePhoneOff:FY,LucidePhoneOutgoing:zY,LucidePi:BY,LucidePiSquare:Lj,LucidePiano:$Y,LucidePickaxe:qY,LucidePictureInPicture:VY,LucidePictureInPicture2:UY,LucidePieChart:Sw,LucidePiggyBank:HY,LucidePilcrow:KY,LucidePilcrowLeft:WY,LucidePilcrowRight:GY,LucidePilcrowSquare:Dj,LucidePill:YY,LucidePillBottle:ZY,LucidePin:r_,LucidePinOff:xP,LucidePipette:XY,LucidePizza:QY,LucidePlane:tX,LucidePlaneLanding:JY,LucidePlaneTakeoff:eX,LucidePlay:dl,LucidePlayCircle:gm,LucidePlaySquare:Oj,LucidePlug:yP,LucidePlug2:sX,LucidePlugZap:q2,LucidePlugZap2:q2,LucidePlus:Zs,LucidePlusCircle:Gw,LucidePlusSquare:Rj,LucidePocket:nX,LucidePocketKnife:rX,LucidePodcast:aX,LucidePointer:oX,LucidePointerOff:iX,LucidePopcorn:lX,LucidePopsicle:cX,LucidePoundSterling:dX,LucidePower:vP,LucidePowerCircle:Kw,LucidePowerOff:uX,LucidePowerSquare:Fj,LucidePresentation:uf,LucidePrinter:_P,LucidePrinterCheck:hX,LucideProjector:mX,LucideProportions:pX,LucidePuzzle:fX,LucidePyramid:gX,LucideQrCode:P0,LucideQuote:v5,LucideRabbit:xX,LucideRadar:yX,LucideRadiation:vX,LucideRadical:_X,LucideRadio:iN,LucideRadioReceiver:bX,LucideRadioTower:wX,LucideRadius:jX,LucideRailSymbol:kX,LucideRainbow:NX,LucideRat:SX,LucideRatio:CX,LucideReceipt:OX,LucideReceiptCent:MX,LucideReceiptEuro:TX,LucideReceiptIndianRupee:AX,LucideReceiptJapaneseYen:EX,LucideReceiptPoundSterling:PX,LucideReceiptRussianRuble:IX,LucideReceiptSwissFranc:LX,LucideReceiptText:DX,LucideRectangleEllipsis:U2,LucideRectangleHorizontal:RX,LucideRectangleVertical:FX,LucideRecycle:zX,LucideRedo:_5,LucideRedo2:BX,LucideRedoDot:$X,LucideRefreshCcw:UX,LucideRefreshCcwDot:qX,LucideRefreshCw:Eo,LucideRefreshCwOff:VX,LucideRefrigerator:HX,LucideRegex:WX,LucideRemoveFormatting:GX,LucideRepeat:bP,LucideRepeat1:KX,LucideRepeat2:ZX,LucideReplace:XX,LucideReplaceAll:YX,LucideReply:wP,LucideReplyAll:QX,LucideRewind:JX,LucideRibbon:eQ,LucideRocket:Hx,LucideRockingChair:tQ,LucideRollerCoaster:sQ,LucideRotate3D:V2,LucideRotate3d:V2,LucideRotateCcw:I0,LucideRotateCcwSquare:rQ,LucideRotateCw:jP,LucideRotateCwSquare:nQ,LucideRoute:iQ,LucideRouteOff:aQ,LucideRouter:oQ,LucideRows:H2,LucideRows2:H2,LucideRows3:W2,LucideRows4:lQ,LucideRss:cQ,LucideRuler:kP,LucideRussianRuble:dQ,LucideSailboat:uQ,LucideSalad:hQ,LucideSandwich:mQ,LucideSatellite:fQ,LucideSatelliteDish:pQ,LucideSave:zu,LucideSaveAll:gQ,LucideSaveOff:xQ,LucideScale:yQ,LucideScale3D:G2,LucideScale3d:G2,LucideScaling:vQ,LucideScan:CQ,LucideScanBarcode:_Q,LucideScanEye:bQ,LucideScanFace:wQ,LucideScanLine:jQ,LucideScanQrCode:kQ,LucideScanSearch:NQ,LucideScanText:SQ,LucideScatterChart:Cw,LucideSchool:MQ,LucideSchool2:Jj,LucideScissors:AQ,LucideScissorsLineDashed:TQ,LucideScissorsSquare:zj,LucideScissorsSquareDashedBottom:uj,LucideScreenShare:PQ,LucideScreenShareOff:EQ,LucideScroll:LQ,LucideScrollText:IQ,LucideSearch:xn,LucideSearchCheck:DQ,LucideSearchCode:OQ,LucideSearchSlash:RQ,LucideSearchX:NP,LucideSection:FQ,LucideSend:Ta,LucideSendHorizonal:K2,LucideSendHorizontal:K2,LucideSendToBack:zQ,LucideSeparatorHorizontal:BQ,LucideSeparatorVertical:$Q,LucideServer:HQ,LucideServerCog:qQ,LucideServerCrash:UQ,LucideServerOff:VQ,LucideSettings:Fl,LucideSettings2:SP,LucideShapes:WQ,LucideShare:CP,LucideShare2:ld,LucideSheet:GQ,LucideShell:KQ,LucideShield:sh,LucideShieldAlert:ZQ,LucideShieldBan:YQ,LucideShieldCheck:MP,LucideShieldClose:Z2,LucideShieldEllipsis:XQ,LucideShieldHalf:QQ,LucideShieldMinus:JQ,LucideShieldOff:eJ,LucideShieldPlus:tJ,LucideShieldQuestion:sJ,LucideShieldX:Z2,LucideShip:nJ,LucideShipWheel:rJ,LucideShirt:aJ,LucideShoppingBag:Wx,LucideShoppingBasket:iJ,LucideShoppingCart:wm,LucideShovel:oJ,LucideShowerHead:lJ,LucideShrink:cJ,LucideShrub:dJ,LucideShuffle:oN,LucideSidebar:z2,LucideSidebarClose:O2,LucideSidebarOpen:F2,LucideSigma:uJ,LucideSigmaSquare:Bj,LucideSignal:gJ,LucideSignalHigh:hJ,LucideSignalLow:mJ,LucideSignalMedium:pJ,LucideSignalZero:fJ,LucideSignature:xJ,LucideSignpost:vJ,LucideSignpostBig:yJ,LucideSiren:_J,LucideSkipBack:bJ,LucideSkipForward:wJ,LucideSkull:jJ,LucideSlack:kJ,LucideSlash:NJ,LucideSlashSquare:$j,LucideSlice:SJ,LucideSliders:Y2,LucideSlidersHorizontal:TP,LucideSlidersVertical:Y2,LucideSmartphone:L0,LucideSmartphoneCharging:CJ,LucideSmartphoneNfc:MJ,LucideSmile:AJ,LucideSmilePlus:TJ,LucideSnail:EJ,LucideSnowflake:I1,LucideSofa:PJ,LucideSortAsc:ow,LucideSortDesc:nw,LucideSoup:IJ,LucideSpace:LJ,LucideSpade:DJ,LucideSparkle:OJ,LucideSparkles:mn,LucideSpeaker:RJ,LucideSpeech:FJ,LucideSpellCheck:BJ,LucideSpellCheck2:zJ,LucideSpline:$J,LucideSplit:qJ,LucideSplitSquareHorizontal:qj,LucideSplitSquareVertical:Uj,LucideSprayCan:UJ,LucideSprout:VJ,LucideSquare:Gx,LucideSquareActivity:X2,LucideSquareArrowDown:ej,LucideSquareArrowDownLeft:Q2,LucideSquareArrowDownRight:J2,LucideSquareArrowLeft:tj,LucideSquareArrowOutDownLeft:sj,LucideSquareArrowOutDownRight:rj,LucideSquareArrowOutUpLeft:nj,LucideSquareArrowOutUpRight:aj,LucideSquareArrowRight:ij,LucideSquareArrowUp:cj,LucideSquareArrowUpLeft:oj,LucideSquareArrowUpRight:lj,LucideSquareAsterisk:dj,LucideSquareBottomDashedScissors:uj,LucideSquareChartGantt:_x,LucideSquareCheck:hj,LucideSquareCheckBig:l0,LucideSquareChevronDown:mj,LucideSquareChevronLeft:pj,LucideSquareChevronRight:fj,LucideSquareChevronUp:gj,LucideSquareCode:xj,LucideSquareDashed:_j,LucideSquareDashedBottom:WJ,LucideSquareDashedBottomCode:HJ,LucideSquareDashedKanban:yj,LucideSquareDashedMousePointer:vj,LucideSquareDivide:bj,LucideSquareDot:wj,LucideSquareEqual:jj,LucideSquareFunction:kj,LucideSquareGanttChart:_x,LucideSquareKanban:Nj,LucideSquareLibrary:Sj,LucideSquareM:Cj,LucideSquareMenu:Mj,LucideSquareMinus:Tj,LucideSquareMousePointer:Aj,LucideSquareParking:Pj,LucideSquareParkingOff:Ej,LucideSquarePen:Dc,LucideSquarePercent:Ij,LucideSquarePi:Lj,LucideSquarePilcrow:Dj,LucideSquarePlay:Oj,LucideSquarePlus:Rj,LucideSquarePower:Fj,LucideSquareRadical:GJ,LucideSquareScissors:zj,LucideSquareSigma:Bj,LucideSquareSlash:$j,LucideSquareSplitHorizontal:qj,LucideSquareSplitVertical:Uj,LucideSquareSquare:KJ,LucideSquareStack:ZJ,LucideSquareTerminal:Vj,LucideSquareUser:Wj,LucideSquareUserRound:Hj,LucideSquareX:Gj,LucideSquircle:YJ,LucideSquirrel:XJ,LucideStamp:QJ,LucideStar:Gn,LucideStarHalf:JJ,LucideStarOff:eee,LucideStars:mn,LucideStepBack:tee,LucideStepForward:see,LucideStethoscope:ree,LucideSticker:nee,LucideStickyNote:aee,LucideStopCircle:Yw,LucideStore:iee,LucideStretchHorizontal:oee,LucideStretchVertical:lee,LucideStrikethrough:cee,LucideSubscript:dee,LucideSubtitles:fw,LucideSun:n_,LucideSunDim:uee,LucideSunMedium:hee,LucideSunMoon:mee,LucideSunSnow:pee,LucideSunrise:fee,LucideSunset:gee,LucideSuperscript:xee,LucideSwatchBook:yee,LucideSwissFranc:vee,LucideSwitchCamera:_ee,LucideSword:bee,LucideSwords:wee,LucideSyringe:jee,LucideTable:AP,LucideTable2:b5,LucideTableCellsMerge:kee,LucideTableCellsSplit:Nee,LucideTableColumnsSplit:See,LucideTableOfContents:Cee,LucideTableProperties:Mee,LucideTableRowsSplit:Tee,LucideTablet:Eee,LucideTabletSmartphone:Aee,LucideTablets:Pee,LucideTag:Im,LucideTags:Iee,LucideTally1:Lee,LucideTally2:Dee,LucideTally3:Oee,LucideTally4:Ree,LucideTally5:Fee,LucideTangent:zee,LucideTarget:Uh,LucideTelescope:Bee,LucideTent:qee,LucideTentTree:$ee,LucideTerminal:Uee,LucideTerminalSquare:Vj,LucideTestTube:Vee,LucideTestTube2:Kj,LucideTestTubeDiagonal:Kj,LucideTestTubes:Hee,LucideText:Yee,LucideTextCursor:Gee,LucideTextCursorInput:Wee,LucideTextQuote:Kee,LucideTextSearch:Zee,LucideTextSelect:Zj,LucideTextSelection:Zj,LucideTheater:Xee,LucideThermometer:ete,LucideThermometerSnowflake:Qee,LucideThermometerSun:Jee,LucideThumbsDown:EP,LucideThumbsUp:hu,LucideTicket:PP,LucideTicketCheck:tte,LucideTicketMinus:ste,LucideTicketPercent:rte,LucideTicketPlus:nte,LucideTicketSlash:ate,LucideTicketX:ite,LucideTickets:lte,LucideTicketsPlane:ote,LucideTimer:ute,LucideTimerOff:cte,LucideTimerReset:dte,LucideToggleLeft:hte,LucideToggleRight:mte,LucideToilet:pte,LucideTornado:fte,LucideTorus:gte,LucideTouchpad:yte,LucideTouchpadOff:xte,LucideTowerControl:vte,LucideToyBrick:_te,LucideTractor:bte,LucideTrafficCone:wte,LucideTrain:Yj,LucideTrainFront:kte,LucideTrainFrontTunnel:jte,LucideTrainTrack:Nte,LucideTramFront:Yj,LucideTrash:Ste,LucideTrash2:jr,LucideTreeDeciduous:Cte,LucideTreePalm:Xj,LucideTreePine:a_,LucideTrees:Mte,LucideTrello:Tte,LucideTrendingDown:lN,LucideTrendingUp:Sc,LucideTrendingUpDown:Ate,LucideTriangle:Pte,LucideTriangleAlert:Mh,LucideTriangleRight:Ete,LucideTrophy:Gi,LucideTruck:IP,LucideTurtle:Ite,LucideTv:Dte,LucideTv2:Qj,LucideTvMinimal:Qj,LucideTvMinimalPlay:Lte,LucideTwitch:Ote,LucideTwitter:Rte,LucideType:zte,LucideTypeOutline:Fte,LucideUmbrella:$te,LucideUmbrellaOff:Bte,LucideUnderline:qte,LucideUndo:w5,LucideUndo2:Ute,LucideUndoDot:Vte,LucideUnfoldHorizontal:Hte,LucideUnfoldVertical:Wte,LucideUngroup:Gte,LucideUniversity:Jj,LucideUnlink:cN,LucideUnlink2:Kte,LucideUnlock:T2,LucideUnlockKeyhole:M2,LucideUnplug:Zte,LucideUpload:Xa,LucideUploadCloud:s2,LucideUsb:Yte,LucideUser:Yi,LucideUser2:ak,LucideUserCheck:i_,LucideUserCheck2:ek,LucideUserCircle:Qw,LucideUserCircle2:Xw,LucideUserCog:LP,LucideUserCog2:tk,LucideUserMinus:DP,LucideUserMinus2:sk,LucideUserPen:Xte,LucideUserPlus:fc,LucideUserPlus2:rk,LucideUserRound:ak,LucideUserRoundCheck:ek,LucideUserRoundCog:tk,LucideUserRoundMinus:sk,LucideUserRoundPen:Qte,LucideUserRoundPlus:rk,LucideUserRoundSearch:Jte,LucideUserRoundX:nk,LucideUserSearch:ese,LucideUserSquare:Wj,LucideUserSquare2:Hj,LucideUserX:tse,LucideUserX2:nk,LucideUsers:hr,LucideUsers2:ik,LucideUsersRound:ik,LucideUtensils:lk,LucideUtensilsCrossed:ok,LucideUtilityPole:sse,LucideVariable:OP,LucideVault:rse,LucideVegan:nse,LucideVenetianMask:ase,LucideVerified:dw,LucideVibrate:ose,LucideVibrateOff:ise,LucideVideo:Nn,LucideVideoOff:lse,LucideVideotape:cse,LucideView:dse,LucideVoicemail:use,LucideVolleyball:hse,LucideVolume:xse,LucideVolume1:mse,LucideVolume2:pse,LucideVolumeOff:fse,LucideVolumeX:gse,LucideVote:yse,LucideWallet:RP,LucideWallet2:ck,LucideWalletCards:vse,LucideWalletMinimal:ck,LucideWallpaper:_se,LucideWand:bse,LucideWand2:c0,LucideWandSparkles:c0,LucideWarehouse:wse,LucideWashingMachine:jse,LucideWatch:kse,LucideWaves:Nse,LucideWaypoints:Sse,LucideWebcam:Cse,LucideWebhook:Tse,LucideWebhookOff:Mse,LucideWeight:Ase,LucideWheat:Pse,LucideWheatOff:Ese,LucideWholeWord:Ise,LucideWifi:Fse,LucideWifiHigh:Lse,LucideWifiLow:Dse,LucideWifiOff:Ose,LucideWifiZero:Rse,LucideWind:Bse,LucideWindArrowDown:zse,LucideWine:qse,LucideWineOff:$se,LucideWorkflow:Use,LucideWorm:Vse,LucideWrapText:Hse,LucideWrench:Kx,LucideX:Ur,LucideXCircle:wc,LucideXOctagon:I2,LucideXSquare:Gj,LucideYoutube:Wse,LucideZap:Lm,LucideZapOff:Gse,LucideZoomIn:o_,LucideZoomOut:j5,Luggage:ZG,LuggageIcon:ZG,MSquare:Cj,MSquareIcon:Cj,Magnet:YG,MagnetIcon:YG,Mail:br,MailCheck:XG,MailCheckIcon:XG,MailIcon:br,MailMinus:QG,MailMinusIcon:QG,MailOpen:JG,MailOpenIcon:JG,MailPlus:eK,MailPlusIcon:eK,MailQuestion:tK,MailQuestionIcon:tK,MailSearch:sK,MailSearchIcon:sK,MailWarning:rK,MailWarningIcon:rK,MailX:cP,MailXIcon:cP,Mailbox:nK,MailboxIcon:nK,Mails:aK,MailsIcon:aK,Map:xK,MapIcon:xK,MapPin:Ti,MapPinCheck:oK,MapPinCheckIcon:oK,MapPinCheckInside:iK,MapPinCheckInsideIcon:iK,MapPinHouse:lK,MapPinHouseIcon:lK,MapPinIcon:Ti,MapPinMinus:dK,MapPinMinusIcon:dK,MapPinMinusInside:cK,MapPinMinusInsideIcon:cK,MapPinOff:uK,MapPinOffIcon:uK,MapPinPlus:mK,MapPinPlusIcon:mK,MapPinPlusInside:hK,MapPinPlusInsideIcon:hK,MapPinX:fK,MapPinXIcon:fK,MapPinXInside:pK,MapPinXInsideIcon:pK,MapPinned:gK,MapPinnedIcon:gK,Martini:yK,MartiniIcon:yK,Maximize:dP,Maximize2:vK,Maximize2Icon:vK,MaximizeIcon:dP,Medal:T0,MedalIcon:T0,Megaphone:Fg,MegaphoneIcon:Fg,MegaphoneOff:_K,MegaphoneOffIcon:_K,Meh:bK,MehIcon:bK,MemoryStick:wK,MemoryStickIcon:wK,Menu:uP,MenuIcon:uP,MenuSquare:Mj,MenuSquareIcon:Mj,Merge:jK,MergeIcon:jK,MessageCircle:pc,MessageCircleCode:kK,MessageCircleCodeIcon:kK,MessageCircleDashed:NK,MessageCircleDashedIcon:NK,MessageCircleHeart:g5,MessageCircleHeartIcon:g5,MessageCircleIcon:pc,MessageCircleMore:SK,MessageCircleMoreIcon:SK,MessageCircleOff:CK,MessageCircleOffIcon:CK,MessageCirclePlus:MK,MessageCirclePlusIcon:MK,MessageCircleQuestion:hP,MessageCircleQuestionIcon:hP,MessageCircleReply:TK,MessageCircleReplyIcon:TK,MessageCircleWarning:AK,MessageCircleWarningIcon:AK,MessageCircleX:EK,MessageCircleXIcon:EK,MessageSquare:io,MessageSquareCode:PK,MessageSquareCodeIcon:PK,MessageSquareDashed:IK,MessageSquareDashedIcon:IK,MessageSquareDiff:LK,MessageSquareDiffIcon:LK,MessageSquareDot:DK,MessageSquareDotIcon:DK,MessageSquareHeart:OK,MessageSquareHeartIcon:OK,MessageSquareIcon:io,MessageSquareLock:RK,MessageSquareLockIcon:RK,MessageSquareMore:mP,MessageSquareMoreIcon:mP,MessageSquareOff:FK,MessageSquareOffIcon:FK,MessageSquarePlus:x5,MessageSquarePlusIcon:x5,MessageSquareQuote:pP,MessageSquareQuoteIcon:pP,MessageSquareReply:zK,MessageSquareReplyIcon:zK,MessageSquareShare:BK,MessageSquareShareIcon:BK,MessageSquareText:$K,MessageSquareTextIcon:$K,MessageSquareWarning:qK,MessageSquareWarningIcon:qK,MessageSquareX:UK,MessageSquareXIcon:UK,MessagesSquare:VK,MessagesSquareIcon:VK,Mic:fP,Mic2:A2,Mic2Icon:A2,MicIcon:fP,MicOff:HK,MicOffIcon:HK,MicVocal:A2,MicVocalIcon:A2,Microchip:WK,MicrochipIcon:WK,Microscope:GK,MicroscopeIcon:GK,Microwave:KK,MicrowaveIcon:KK,Milestone:ZK,MilestoneIcon:ZK,Milk:XK,MilkIcon:XK,MilkOff:YK,MilkOffIcon:YK,Minimize:JK,Minimize2:QK,Minimize2Icon:QK,MinimizeIcon:JK,Minus:A0,MinusCircle:qw,MinusCircleIcon:qw,MinusIcon:A0,MinusSquare:Tj,MinusSquareIcon:Tj,Monitor:nN,MonitorCheck:eZ,MonitorCheckIcon:eZ,MonitorCog:tZ,MonitorCogIcon:tZ,MonitorDot:sZ,MonitorDotIcon:sZ,MonitorDown:rZ,MonitorDownIcon:rZ,MonitorIcon:nN,MonitorOff:nZ,MonitorOffIcon:nZ,MonitorPause:aZ,MonitorPauseIcon:aZ,MonitorPlay:iZ,MonitorPlayIcon:iZ,MonitorSmartphone:oZ,MonitorSmartphoneIcon:oZ,MonitorSpeaker:lZ,MonitorSpeakerIcon:lZ,MonitorStop:cZ,MonitorStopIcon:cZ,MonitorUp:dZ,MonitorUpIcon:dZ,MonitorX:uZ,MonitorXIcon:uZ,Moon:mZ,MoonIcon:mZ,MoonStar:hZ,MoonStarIcon:hZ,MoreHorizontal:ef,MoreHorizontalIcon:ef,MoreVertical:Jp,MoreVerticalIcon:Jp,Mountain:fZ,MountainIcon:fZ,MountainSnow:pZ,MountainSnowIcon:pZ,Mouse:vZ,MouseIcon:vZ,MouseOff:gZ,MouseOffIcon:gZ,MousePointer:bm,MousePointer2:xZ,MousePointer2Icon:xZ,MousePointerBan:yZ,MousePointerBanIcon:yZ,MousePointerClick:t_,MousePointerClickIcon:t_,MousePointerIcon:bm,MousePointerSquareDashed:vj,MousePointerSquareDashedIcon:vj,Move:PZ,Move3D:E2,Move3DIcon:E2,Move3d:E2,Move3dIcon:E2,MoveDiagonal:bZ,MoveDiagonal2:_Z,MoveDiagonal2Icon:_Z,MoveDiagonalIcon:bZ,MoveDown:kZ,MoveDownIcon:kZ,MoveDownLeft:wZ,MoveDownLeftIcon:wZ,MoveDownRight:jZ,MoveDownRightIcon:jZ,MoveHorizontal:NZ,MoveHorizontalIcon:NZ,MoveIcon:PZ,MoveLeft:SZ,MoveLeftIcon:SZ,MoveRight:CZ,MoveRightIcon:CZ,MoveUp:AZ,MoveUpIcon:AZ,MoveUpLeft:MZ,MoveUpLeftIcon:MZ,MoveUpRight:TZ,MoveUpRightIcon:TZ,MoveVertical:EZ,MoveVerticalIcon:EZ,Music:OZ,Music2:IZ,Music2Icon:IZ,Music3:LZ,Music3Icon:LZ,Music4:DZ,Music4Icon:DZ,MusicIcon:OZ,Navigation:gP,Navigation2:FZ,Navigation2Icon:FZ,Navigation2Off:RZ,Navigation2OffIcon:RZ,NavigationIcon:gP,NavigationOff:zZ,NavigationOffIcon:zZ,Network:BZ,NetworkIcon:BZ,Newspaper:E0,NewspaperIcon:E0,Nfc:$Z,NfcIcon:$Z,Notebook:HZ,NotebookIcon:HZ,NotebookPen:qZ,NotebookPenIcon:qZ,NotebookTabs:UZ,NotebookTabsIcon:UZ,NotebookText:VZ,NotebookTextIcon:VZ,NotepadText:GZ,NotepadTextDashed:WZ,NotepadTextDashedIcon:WZ,NotepadTextIcon:GZ,Nut:ZZ,NutIcon:ZZ,NutOff:KZ,NutOffIcon:KZ,Octagon:XZ,OctagonAlert:a0,OctagonAlertIcon:a0,OctagonIcon:XZ,OctagonMinus:YZ,OctagonMinusIcon:YZ,OctagonPause:P2,OctagonPauseIcon:P2,OctagonX:I2,OctagonXIcon:I2,Omega:QZ,OmegaIcon:QZ,Option:JZ,OptionIcon:JZ,Orbit:eY,OrbitIcon:eY,Origami:tY,OrigamiIcon:tY,Outdent:N2,OutdentIcon:N2,Package:cl,Package2:sY,Package2Icon:sY,PackageCheck:rY,PackageCheckIcon:rY,PackageIcon:cl,PackageMinus:nY,PackageMinusIcon:nY,PackageOpen:aY,PackageOpenIcon:aY,PackagePlus:iY,PackagePlusIcon:iY,PackageSearch:oY,PackageSearchIcon:oY,PackageX:lY,PackageXIcon:lY,PaintBucket:cY,PaintBucketIcon:cY,PaintRoller:dY,PaintRollerIcon:dY,Paintbrush:uY,Paintbrush2:L2,Paintbrush2Icon:L2,PaintbrushIcon:uY,PaintbrushVertical:L2,PaintbrushVerticalIcon:L2,Palette:Rl,PaletteIcon:Rl,Palmtree:Xj,PalmtreeIcon:Xj,PanelBottom:pY,PanelBottomClose:hY,PanelBottomCloseIcon:hY,PanelBottomDashed:D2,PanelBottomDashedIcon:D2,PanelBottomIcon:pY,PanelBottomInactive:D2,PanelBottomInactiveIcon:D2,PanelBottomOpen:mY,PanelBottomOpenIcon:mY,PanelLeft:z2,PanelLeftClose:O2,PanelLeftCloseIcon:O2,PanelLeftDashed:R2,PanelLeftDashedIcon:R2,PanelLeftIcon:z2,PanelLeftInactive:R2,PanelLeftInactiveIcon:R2,PanelLeftOpen:F2,PanelLeftOpenIcon:F2,PanelRight:xY,PanelRightClose:fY,PanelRightCloseIcon:fY,PanelRightDashed:B2,PanelRightDashedIcon:B2,PanelRightIcon:xY,PanelRightInactive:B2,PanelRightInactiveIcon:B2,PanelRightOpen:gY,PanelRightOpenIcon:gY,PanelTop:_Y,PanelTopClose:yY,PanelTopCloseIcon:yY,PanelTopDashed:$2,PanelTopDashedIcon:$2,PanelTopIcon:_Y,PanelTopInactive:$2,PanelTopInactiveIcon:$2,PanelTopOpen:vY,PanelTopOpenIcon:vY,PanelsLeftBottom:bY,PanelsLeftBottomIcon:bY,PanelsLeftRight:a2,PanelsLeftRightIcon:a2,PanelsRightBottom:wY,PanelsRightBottomIcon:wY,PanelsTopBottom:W2,PanelsTopBottomIcon:W2,PanelsTopLeft:i0,PanelsTopLeftIcon:i0,Paperclip:aN,PaperclipIcon:aN,Parentheses:jY,ParenthesesIcon:jY,ParkingCircle:Vw,ParkingCircleIcon:Vw,ParkingCircleOff:Uw,ParkingCircleOffIcon:Uw,ParkingMeter:kY,ParkingMeterIcon:kY,ParkingSquare:Pj,ParkingSquareIcon:Pj,ParkingSquareOff:Ej,ParkingSquareOffIcon:Ej,PartyPopper:Nd,PartyPopperIcon:Nd,Pause:fp,PauseCircle:Hw,PauseCircleIcon:Hw,PauseIcon:fp,PauseOctagon:P2,PauseOctagonIcon:P2,PawPrint:NY,PawPrintIcon:NY,PcCase:SY,PcCaseIcon:SY,Pen:Ax,PenBox:Dc,PenBoxIcon:Dc,PenIcon:Ax,PenLine:o0,PenLineIcon:o0,PenOff:CY,PenOffIcon:CY,PenSquare:Dc,PenSquareIcon:Dc,PenTool:s_,PenToolIcon:s_,Pencil:Ua,PencilIcon:Ua,PencilLine:MY,PencilLineIcon:MY,PencilOff:TY,PencilOffIcon:TY,PencilRuler:AY,PencilRulerIcon:AY,Pentagon:EY,PentagonIcon:EY,Percent:y5,PercentCircle:Ww,PercentCircleIcon:Ww,PercentDiamond:o2,PercentDiamondIcon:o2,PercentIcon:y5,PercentSquare:Ij,PercentSquareIcon:Ij,PersonStanding:PY,PersonStandingIcon:PY,PhilippinePeso:IY,PhilippinePesoIcon:IY,Phone:Zn,PhoneCall:LY,PhoneCallIcon:LY,PhoneForwarded:DY,PhoneForwardedIcon:DY,PhoneIcon:Zn,PhoneIncoming:OY,PhoneIncomingIcon:OY,PhoneMissed:RY,PhoneMissedIcon:RY,PhoneOff:FY,PhoneOffIcon:FY,PhoneOutgoing:zY,PhoneOutgoingIcon:zY,Pi:BY,PiIcon:BY,PiSquare:Lj,PiSquareIcon:Lj,Piano:$Y,PianoIcon:$Y,Pickaxe:qY,PickaxeIcon:qY,PictureInPicture:VY,PictureInPicture2:UY,PictureInPicture2Icon:UY,PictureInPictureIcon:VY,PieChart:Sw,PieChartIcon:Sw,PiggyBank:HY,PiggyBankIcon:HY,Pilcrow:KY,PilcrowIcon:KY,PilcrowLeft:WY,PilcrowLeftIcon:WY,PilcrowRight:GY,PilcrowRightIcon:GY,PilcrowSquare:Dj,PilcrowSquareIcon:Dj,Pill:YY,PillBottle:ZY,PillBottleIcon:ZY,PillIcon:YY,Pin:r_,PinIcon:r_,PinOff:xP,PinOffIcon:xP,Pipette:XY,PipetteIcon:XY,Pizza:QY,PizzaIcon:QY,Plane:tX,PlaneIcon:tX,PlaneLanding:JY,PlaneLandingIcon:JY,PlaneTakeoff:eX,PlaneTakeoffIcon:eX,Play:dl,PlayCircle:gm,PlayCircleIcon:gm,PlayIcon:dl,PlaySquare:Oj,PlaySquareIcon:Oj,Plug:yP,Plug2:sX,Plug2Icon:sX,PlugIcon:yP,PlugZap:q2,PlugZap2:q2,PlugZap2Icon:q2,PlugZapIcon:q2,Plus:Zs,PlusCircle:Gw,PlusCircleIcon:Gw,PlusIcon:Zs,PlusSquare:Rj,PlusSquareIcon:Rj,Pocket:nX,PocketIcon:nX,PocketKnife:rX,PocketKnifeIcon:rX,Podcast:aX,PodcastIcon:aX,Pointer:oX,PointerIcon:oX,PointerOff:iX,PointerOffIcon:iX,Popcorn:lX,PopcornIcon:lX,Popsicle:cX,PopsicleIcon:cX,PoundSterling:dX,PoundSterlingIcon:dX,Power:vP,PowerCircle:Kw,PowerCircleIcon:Kw,PowerIcon:vP,PowerOff:uX,PowerOffIcon:uX,PowerSquare:Fj,PowerSquareIcon:Fj,Presentation:uf,PresentationIcon:uf,Printer:_P,PrinterCheck:hX,PrinterCheckIcon:hX,PrinterIcon:_P,Projector:mX,ProjectorIcon:mX,Proportions:pX,ProportionsIcon:pX,Puzzle:fX,PuzzleIcon:fX,Pyramid:gX,PyramidIcon:gX,QrCode:P0,QrCodeIcon:P0,Quote:v5,QuoteIcon:v5,Rabbit:xX,RabbitIcon:xX,Radar:yX,RadarIcon:yX,Radiation:vX,RadiationIcon:vX,Radical:_X,RadicalIcon:_X,Radio:iN,RadioIcon:iN,RadioReceiver:bX,RadioReceiverIcon:bX,RadioTower:wX,RadioTowerIcon:wX,Radius:jX,RadiusIcon:jX,RailSymbol:kX,RailSymbolIcon:kX,Rainbow:NX,RainbowIcon:NX,Rat:SX,RatIcon:SX,Ratio:CX,RatioIcon:CX,Receipt:OX,ReceiptCent:MX,ReceiptCentIcon:MX,ReceiptEuro:TX,ReceiptEuroIcon:TX,ReceiptIcon:OX,ReceiptIndianRupee:AX,ReceiptIndianRupeeIcon:AX,ReceiptJapaneseYen:EX,ReceiptJapaneseYenIcon:EX,ReceiptPoundSterling:PX,ReceiptPoundSterlingIcon:PX,ReceiptRussianRuble:IX,ReceiptRussianRubleIcon:IX,ReceiptSwissFranc:LX,ReceiptSwissFrancIcon:LX,ReceiptText:DX,ReceiptTextIcon:DX,RectangleEllipsis:U2,RectangleEllipsisIcon:U2,RectangleHorizontal:RX,RectangleHorizontalIcon:RX,RectangleVertical:FX,RectangleVerticalIcon:FX,Recycle:zX,RecycleIcon:zX,Redo:_5,Redo2:BX,Redo2Icon:BX,RedoDot:$X,RedoDotIcon:$X,RedoIcon:_5,RefreshCcw:UX,RefreshCcwDot:qX,RefreshCcwDotIcon:qX,RefreshCcwIcon:UX,RefreshCw:Eo,RefreshCwIcon:Eo,RefreshCwOff:VX,RefreshCwOffIcon:VX,Refrigerator:HX,RefrigeratorIcon:HX,Regex:WX,RegexIcon:WX,RemoveFormatting:GX,RemoveFormattingIcon:GX,Repeat:bP,Repeat1:KX,Repeat1Icon:KX,Repeat2:ZX,Repeat2Icon:ZX,RepeatIcon:bP,Replace:XX,ReplaceAll:YX,ReplaceAllIcon:YX,ReplaceIcon:XX,Reply:wP,ReplyAll:QX,ReplyAllIcon:QX,ReplyIcon:wP,Rewind:JX,RewindIcon:JX,Ribbon:eQ,RibbonIcon:eQ,Rocket:Hx,RocketIcon:Hx,RockingChair:tQ,RockingChairIcon:tQ,RollerCoaster:sQ,RollerCoasterIcon:sQ,Rotate3D:V2,Rotate3DIcon:V2,Rotate3d:V2,Rotate3dIcon:V2,RotateCcw:I0,RotateCcwIcon:I0,RotateCcwSquare:rQ,RotateCcwSquareIcon:rQ,RotateCw:jP,RotateCwIcon:jP,RotateCwSquare:nQ,RotateCwSquareIcon:nQ,Route:iQ,RouteIcon:iQ,RouteOff:aQ,RouteOffIcon:aQ,Router:oQ,RouterIcon:oQ,Rows:H2,Rows2:H2,Rows2Icon:H2,Rows3:W2,Rows3Icon:W2,Rows4:lQ,Rows4Icon:lQ,RowsIcon:H2,Rss:cQ,RssIcon:cQ,Ruler:kP,RulerIcon:kP,RussianRuble:dQ,RussianRubleIcon:dQ,Sailboat:uQ,SailboatIcon:uQ,Salad:hQ,SaladIcon:hQ,Sandwich:mQ,SandwichIcon:mQ,Satellite:fQ,SatelliteDish:pQ,SatelliteDishIcon:pQ,SatelliteIcon:fQ,Save:zu,SaveAll:gQ,SaveAllIcon:gQ,SaveIcon:zu,SaveOff:xQ,SaveOffIcon:xQ,Scale:yQ,Scale3D:G2,Scale3DIcon:G2,Scale3d:G2,Scale3dIcon:G2,ScaleIcon:yQ,Scaling:vQ,ScalingIcon:vQ,Scan:CQ,ScanBarcode:_Q,ScanBarcodeIcon:_Q,ScanEye:bQ,ScanEyeIcon:bQ,ScanFace:wQ,ScanFaceIcon:wQ,ScanIcon:CQ,ScanLine:jQ,ScanLineIcon:jQ,ScanQrCode:kQ,ScanQrCodeIcon:kQ,ScanSearch:NQ,ScanSearchIcon:NQ,ScanText:SQ,ScanTextIcon:SQ,ScatterChart:Cw,ScatterChartIcon:Cw,School:MQ,School2:Jj,School2Icon:Jj,SchoolIcon:MQ,Scissors:AQ,ScissorsIcon:AQ,ScissorsLineDashed:TQ,ScissorsLineDashedIcon:TQ,ScissorsSquare:zj,ScissorsSquareDashedBottom:uj,ScissorsSquareDashedBottomIcon:uj,ScissorsSquareIcon:zj,ScreenShare:PQ,ScreenShareIcon:PQ,ScreenShareOff:EQ,ScreenShareOffIcon:EQ,Scroll:LQ,ScrollIcon:LQ,ScrollText:IQ,ScrollTextIcon:IQ,Search:xn,SearchCheck:DQ,SearchCheckIcon:DQ,SearchCode:OQ,SearchCodeIcon:OQ,SearchIcon:xn,SearchSlash:RQ,SearchSlashIcon:RQ,SearchX:NP,SearchXIcon:NP,Section:FQ,SectionIcon:FQ,Send:Ta,SendHorizonal:K2,SendHorizonalIcon:K2,SendHorizontal:K2,SendHorizontalIcon:K2,SendIcon:Ta,SendToBack:zQ,SendToBackIcon:zQ,SeparatorHorizontal:BQ,SeparatorHorizontalIcon:BQ,SeparatorVertical:$Q,SeparatorVerticalIcon:$Q,Server:HQ,ServerCog:qQ,ServerCogIcon:qQ,ServerCrash:UQ,ServerCrashIcon:UQ,ServerIcon:HQ,ServerOff:VQ,ServerOffIcon:VQ,Settings:Fl,Settings2:SP,Settings2Icon:SP,SettingsIcon:Fl,Shapes:WQ,ShapesIcon:WQ,Share:CP,Share2:ld,Share2Icon:ld,ShareIcon:CP,Sheet:GQ,SheetIcon:GQ,Shell:KQ,ShellIcon:KQ,Shield:sh,ShieldAlert:ZQ,ShieldAlertIcon:ZQ,ShieldBan:YQ,ShieldBanIcon:YQ,ShieldCheck:MP,ShieldCheckIcon:MP,ShieldClose:Z2,ShieldCloseIcon:Z2,ShieldEllipsis:XQ,ShieldEllipsisIcon:XQ,ShieldHalf:QQ,ShieldHalfIcon:QQ,ShieldIcon:sh,ShieldMinus:JQ,ShieldMinusIcon:JQ,ShieldOff:eJ,ShieldOffIcon:eJ,ShieldPlus:tJ,ShieldPlusIcon:tJ,ShieldQuestion:sJ,ShieldQuestionIcon:sJ,ShieldX:Z2,ShieldXIcon:Z2,Ship:nJ,ShipIcon:nJ,ShipWheel:rJ,ShipWheelIcon:rJ,Shirt:aJ,ShirtIcon:aJ,ShoppingBag:Wx,ShoppingBagIcon:Wx,ShoppingBasket:iJ,ShoppingBasketIcon:iJ,ShoppingCart:wm,ShoppingCartIcon:wm,Shovel:oJ,ShovelIcon:oJ,ShowerHead:lJ,ShowerHeadIcon:lJ,Shrink:cJ,ShrinkIcon:cJ,Shrub:dJ,ShrubIcon:dJ,Shuffle:oN,ShuffleIcon:oN,Sidebar:z2,SidebarClose:O2,SidebarCloseIcon:O2,SidebarIcon:z2,SidebarOpen:F2,SidebarOpenIcon:F2,Sigma:uJ,SigmaIcon:uJ,SigmaSquare:Bj,SigmaSquareIcon:Bj,Signal:gJ,SignalHigh:hJ,SignalHighIcon:hJ,SignalIcon:gJ,SignalLow:mJ,SignalLowIcon:mJ,SignalMedium:pJ,SignalMediumIcon:pJ,SignalZero:fJ,SignalZeroIcon:fJ,Signature:xJ,SignatureIcon:xJ,Signpost:vJ,SignpostBig:yJ,SignpostBigIcon:yJ,SignpostIcon:vJ,Siren:_J,SirenIcon:_J,SkipBack:bJ,SkipBackIcon:bJ,SkipForward:wJ,SkipForwardIcon:wJ,Skull:jJ,SkullIcon:jJ,Slack:kJ,SlackIcon:kJ,Slash:NJ,SlashIcon:NJ,SlashSquare:$j,SlashSquareIcon:$j,Slice:SJ,SliceIcon:SJ,Sliders:Y2,SlidersHorizontal:TP,SlidersHorizontalIcon:TP,SlidersIcon:Y2,SlidersVertical:Y2,SlidersVerticalIcon:Y2,Smartphone:L0,SmartphoneCharging:CJ,SmartphoneChargingIcon:CJ,SmartphoneIcon:L0,SmartphoneNfc:MJ,SmartphoneNfcIcon:MJ,Smile:AJ,SmileIcon:AJ,SmilePlus:TJ,SmilePlusIcon:TJ,Snail:EJ,SnailIcon:EJ,Snowflake:I1,SnowflakeIcon:I1,Sofa:PJ,SofaIcon:PJ,SortAsc:ow,SortAscIcon:ow,SortDesc:nw,SortDescIcon:nw,Soup:IJ,SoupIcon:IJ,Space:LJ,SpaceIcon:LJ,Spade:DJ,SpadeIcon:DJ,Sparkle:OJ,SparkleIcon:OJ,Sparkles:mn,SparklesIcon:mn,Speaker:RJ,SpeakerIcon:RJ,Speech:FJ,SpeechIcon:FJ,SpellCheck:BJ,SpellCheck2:zJ,SpellCheck2Icon:zJ,SpellCheckIcon:BJ,Spline:$J,SplineIcon:$J,Split:qJ,SplitIcon:qJ,SplitSquareHorizontal:qj,SplitSquareHorizontalIcon:qj,SplitSquareVertical:Uj,SplitSquareVerticalIcon:Uj,SprayCan:UJ,SprayCanIcon:UJ,Sprout:VJ,SproutIcon:VJ,Square:Gx,SquareActivity:X2,SquareActivityIcon:X2,SquareArrowDown:ej,SquareArrowDownIcon:ej,SquareArrowDownLeft:Q2,SquareArrowDownLeftIcon:Q2,SquareArrowDownRight:J2,SquareArrowDownRightIcon:J2,SquareArrowLeft:tj,SquareArrowLeftIcon:tj,SquareArrowOutDownLeft:sj,SquareArrowOutDownLeftIcon:sj,SquareArrowOutDownRight:rj,SquareArrowOutDownRightIcon:rj,SquareArrowOutUpLeft:nj,SquareArrowOutUpLeftIcon:nj,SquareArrowOutUpRight:aj,SquareArrowOutUpRightIcon:aj,SquareArrowRight:ij,SquareArrowRightIcon:ij,SquareArrowUp:cj,SquareArrowUpIcon:cj,SquareArrowUpLeft:oj,SquareArrowUpLeftIcon:oj,SquareArrowUpRight:lj,SquareArrowUpRightIcon:lj,SquareAsterisk:dj,SquareAsteriskIcon:dj,SquareBottomDashedScissors:uj,SquareBottomDashedScissorsIcon:uj,SquareChartGantt:_x,SquareChartGanttIcon:_x,SquareCheck:hj,SquareCheckBig:l0,SquareCheckBigIcon:l0,SquareCheckIcon:hj,SquareChevronDown:mj,SquareChevronDownIcon:mj,SquareChevronLeft:pj,SquareChevronLeftIcon:pj,SquareChevronRight:fj,SquareChevronRightIcon:fj,SquareChevronUp:gj,SquareChevronUpIcon:gj,SquareCode:xj,SquareCodeIcon:xj,SquareDashed:_j,SquareDashedBottom:WJ,SquareDashedBottomCode:HJ,SquareDashedBottomCodeIcon:HJ,SquareDashedBottomIcon:WJ,SquareDashedIcon:_j,SquareDashedKanban:yj,SquareDashedKanbanIcon:yj,SquareDashedMousePointer:vj,SquareDashedMousePointerIcon:vj,SquareDivide:bj,SquareDivideIcon:bj,SquareDot:wj,SquareDotIcon:wj,SquareEqual:jj,SquareEqualIcon:jj,SquareFunction:kj,SquareFunctionIcon:kj,SquareGanttChart:_x,SquareGanttChartIcon:_x,SquareIcon:Gx,SquareKanban:Nj,SquareKanbanIcon:Nj,SquareLibrary:Sj,SquareLibraryIcon:Sj,SquareM:Cj,SquareMIcon:Cj,SquareMenu:Mj,SquareMenuIcon:Mj,SquareMinus:Tj,SquareMinusIcon:Tj,SquareMousePointer:Aj,SquareMousePointerIcon:Aj,SquareParking:Pj,SquareParkingIcon:Pj,SquareParkingOff:Ej,SquareParkingOffIcon:Ej,SquarePen:Dc,SquarePenIcon:Dc,SquarePercent:Ij,SquarePercentIcon:Ij,SquarePi:Lj,SquarePiIcon:Lj,SquarePilcrow:Dj,SquarePilcrowIcon:Dj,SquarePlay:Oj,SquarePlayIcon:Oj,SquarePlus:Rj,SquarePlusIcon:Rj,SquarePower:Fj,SquarePowerIcon:Fj,SquareRadical:GJ,SquareRadicalIcon:GJ,SquareScissors:zj,SquareScissorsIcon:zj,SquareSigma:Bj,SquareSigmaIcon:Bj,SquareSlash:$j,SquareSlashIcon:$j,SquareSplitHorizontal:qj,SquareSplitHorizontalIcon:qj,SquareSplitVertical:Uj,SquareSplitVerticalIcon:Uj,SquareSquare:KJ,SquareSquareIcon:KJ,SquareStack:ZJ,SquareStackIcon:ZJ,SquareTerminal:Vj,SquareTerminalIcon:Vj,SquareUser:Wj,SquareUserIcon:Wj,SquareUserRound:Hj,SquareUserRoundIcon:Hj,SquareX:Gj,SquareXIcon:Gj,Squircle:YJ,SquircleIcon:YJ,Squirrel:XJ,SquirrelIcon:XJ,Stamp:QJ,StampIcon:QJ,Star:Gn,StarHalf:JJ,StarHalfIcon:JJ,StarIcon:Gn,StarOff:eee,StarOffIcon:eee,Stars:mn,StarsIcon:mn,StepBack:tee,StepBackIcon:tee,StepForward:see,StepForwardIcon:see,Stethoscope:ree,StethoscopeIcon:ree,Sticker:nee,StickerIcon:nee,StickyNote:aee,StickyNoteIcon:aee,StopCircle:Yw,StopCircleIcon:Yw,Store:iee,StoreIcon:iee,StretchHorizontal:oee,StretchHorizontalIcon:oee,StretchVertical:lee,StretchVerticalIcon:lee,Strikethrough:cee,StrikethroughIcon:cee,Subscript:dee,SubscriptIcon:dee,Subtitles:fw,SubtitlesIcon:fw,Sun:n_,SunDim:uee,SunDimIcon:uee,SunIcon:n_,SunMedium:hee,SunMediumIcon:hee,SunMoon:mee,SunMoonIcon:mee,SunSnow:pee,SunSnowIcon:pee,Sunrise:fee,SunriseIcon:fee,Sunset:gee,SunsetIcon:gee,Superscript:xee,SuperscriptIcon:xee,SwatchBook:yee,SwatchBookIcon:yee,SwissFranc:vee,SwissFrancIcon:vee,SwitchCamera:_ee,SwitchCameraIcon:_ee,Sword:bee,SwordIcon:bee,Swords:wee,SwordsIcon:wee,Syringe:jee,SyringeIcon:jee,Table:AP,Table2:b5,Table2Icon:b5,TableCellsMerge:kee,TableCellsMergeIcon:kee,TableCellsSplit:Nee,TableCellsSplitIcon:Nee,TableColumnsSplit:See,TableColumnsSplitIcon:See,TableIcon:AP,TableOfContents:Cee,TableOfContentsIcon:Cee,TableProperties:Mee,TablePropertiesIcon:Mee,TableRowsSplit:Tee,TableRowsSplitIcon:Tee,Tablet:Eee,TabletIcon:Eee,TabletSmartphone:Aee,TabletSmartphoneIcon:Aee,Tablets:Pee,TabletsIcon:Pee,Tag:Im,TagIcon:Im,Tags:Iee,TagsIcon:Iee,Tally1:Lee,Tally1Icon:Lee,Tally2:Dee,Tally2Icon:Dee,Tally3:Oee,Tally3Icon:Oee,Tally4:Ree,Tally4Icon:Ree,Tally5:Fee,Tally5Icon:Fee,Tangent:zee,TangentIcon:zee,Target:Uh,TargetIcon:Uh,Telescope:Bee,TelescopeIcon:Bee,Tent:qee,TentIcon:qee,TentTree:$ee,TentTreeIcon:$ee,Terminal:Uee,TerminalIcon:Uee,TerminalSquare:Vj,TerminalSquareIcon:Vj,TestTube:Vee,TestTube2:Kj,TestTube2Icon:Kj,TestTubeDiagonal:Kj,TestTubeDiagonalIcon:Kj,TestTubeIcon:Vee,TestTubes:Hee,TestTubesIcon:Hee,Text:Yee,TextCursor:Gee,TextCursorIcon:Gee,TextCursorInput:Wee,TextCursorInputIcon:Wee,TextIcon:Yee,TextQuote:Kee,TextQuoteIcon:Kee,TextSearch:Zee,TextSearchIcon:Zee,TextSelect:Zj,TextSelectIcon:Zj,TextSelection:Zj,TextSelectionIcon:Zj,Theater:Xee,TheaterIcon:Xee,Thermometer:ete,ThermometerIcon:ete,ThermometerSnowflake:Qee,ThermometerSnowflakeIcon:Qee,ThermometerSun:Jee,ThermometerSunIcon:Jee,ThumbsDown:EP,ThumbsDownIcon:EP,ThumbsUp:hu,ThumbsUpIcon:hu,Ticket:PP,TicketCheck:tte,TicketCheckIcon:tte,TicketIcon:PP,TicketMinus:ste,TicketMinusIcon:ste,TicketPercent:rte,TicketPercentIcon:rte,TicketPlus:nte,TicketPlusIcon:nte,TicketSlash:ate,TicketSlashIcon:ate,TicketX:ite,TicketXIcon:ite,Tickets:lte,TicketsIcon:lte,TicketsPlane:ote,TicketsPlaneIcon:ote,Timer:ute,TimerIcon:ute,TimerOff:cte,TimerOffIcon:cte,TimerReset:dte,TimerResetIcon:dte,ToggleLeft:hte,ToggleLeftIcon:hte,ToggleRight:mte,ToggleRightIcon:mte,Toilet:pte,ToiletIcon:pte,Tornado:fte,TornadoIcon:fte,Torus:gte,TorusIcon:gte,Touchpad:yte,TouchpadIcon:yte,TouchpadOff:xte,TouchpadOffIcon:xte,TowerControl:vte,TowerControlIcon:vte,ToyBrick:_te,ToyBrickIcon:_te,Tractor:bte,TractorIcon:bte,TrafficCone:wte,TrafficConeIcon:wte,Train:Yj,TrainFront:kte,TrainFrontIcon:kte,TrainFrontTunnel:jte,TrainFrontTunnelIcon:jte,TrainIcon:Yj,TrainTrack:Nte,TrainTrackIcon:Nte,TramFront:Yj,TramFrontIcon:Yj,Trash:Ste,Trash2:jr,Trash2Icon:jr,TrashIcon:Ste,TreeDeciduous:Cte,TreeDeciduousIcon:Cte,TreePalm:Xj,TreePalmIcon:Xj,TreePine:a_,TreePineIcon:a_,Trees:Mte,TreesIcon:Mte,Trello:Tte,TrelloIcon:Tte,TrendingDown:lN,TrendingDownIcon:lN,TrendingUp:Sc,TrendingUpDown:Ate,TrendingUpDownIcon:Ate,TrendingUpIcon:Sc,Triangle:Pte,TriangleAlert:Mh,TriangleAlertIcon:Mh,TriangleIcon:Pte,TriangleRight:Ete,TriangleRightIcon:Ete,Trophy:Gi,TrophyIcon:Gi,Truck:IP,TruckIcon:IP,Turtle:Ite,TurtleIcon:Ite,Tv:Dte,Tv2:Qj,Tv2Icon:Qj,TvIcon:Dte,TvMinimal:Qj,TvMinimalIcon:Qj,TvMinimalPlay:Lte,TvMinimalPlayIcon:Lte,Twitch:Ote,TwitchIcon:Ote,Twitter:Rte,TwitterIcon:Rte,Type:zte,TypeIcon:zte,TypeOutline:Fte,TypeOutlineIcon:Fte,Umbrella:$te,UmbrellaIcon:$te,UmbrellaOff:Bte,UmbrellaOffIcon:Bte,Underline:qte,UnderlineIcon:qte,Undo:w5,Undo2:Ute,Undo2Icon:Ute,UndoDot:Vte,UndoDotIcon:Vte,UndoIcon:w5,UnfoldHorizontal:Hte,UnfoldHorizontalIcon:Hte,UnfoldVertical:Wte,UnfoldVerticalIcon:Wte,Ungroup:Gte,UngroupIcon:Gte,University:Jj,UniversityIcon:Jj,Unlink:cN,Unlink2:Kte,Unlink2Icon:Kte,UnlinkIcon:cN,Unlock:T2,UnlockIcon:T2,UnlockKeyhole:M2,UnlockKeyholeIcon:M2,Unplug:Zte,UnplugIcon:Zte,Upload:Xa,UploadCloud:s2,UploadCloudIcon:s2,UploadIcon:Xa,Usb:Yte,UsbIcon:Yte,User:Yi,User2:ak,User2Icon:ak,UserCheck:i_,UserCheck2:ek,UserCheck2Icon:ek,UserCheckIcon:i_,UserCircle:Qw,UserCircle2:Xw,UserCircle2Icon:Xw,UserCircleIcon:Qw,UserCog:LP,UserCog2:tk,UserCog2Icon:tk,UserCogIcon:LP,UserIcon:Yi,UserMinus:DP,UserMinus2:sk,UserMinus2Icon:sk,UserMinusIcon:DP,UserPen:Xte,UserPenIcon:Xte,UserPlus:fc,UserPlus2:rk,UserPlus2Icon:rk,UserPlusIcon:fc,UserRound:ak,UserRoundCheck:ek,UserRoundCheckIcon:ek,UserRoundCog:tk,UserRoundCogIcon:tk,UserRoundIcon:ak,UserRoundMinus:sk,UserRoundMinusIcon:sk,UserRoundPen:Qte,UserRoundPenIcon:Qte,UserRoundPlus:rk,UserRoundPlusIcon:rk,UserRoundSearch:Jte,UserRoundSearchIcon:Jte,UserRoundX:nk,UserRoundXIcon:nk,UserSearch:ese,UserSearchIcon:ese,UserSquare:Wj,UserSquare2:Hj,UserSquare2Icon:Hj,UserSquareIcon:Wj,UserX:tse,UserX2:nk,UserX2Icon:nk,UserXIcon:tse,Users:hr,Users2:ik,Users2Icon:ik,UsersIcon:hr,UsersRound:ik,UsersRoundIcon:ik,Utensils:lk,UtensilsCrossed:ok,UtensilsCrossedIcon:ok,UtensilsIcon:lk,UtilityPole:sse,UtilityPoleIcon:sse,Variable:OP,VariableIcon:OP,Vault:rse,VaultIcon:rse,Vegan:nse,VeganIcon:nse,VenetianMask:ase,VenetianMaskIcon:ase,Verified:dw,VerifiedIcon:dw,Vibrate:ose,VibrateIcon:ose,VibrateOff:ise,VibrateOffIcon:ise,Video:Nn,VideoIcon:Nn,VideoOff:lse,VideoOffIcon:lse,Videotape:cse,VideotapeIcon:cse,View:dse,ViewIcon:dse,Voicemail:use,VoicemailIcon:use,Volleyball:hse,VolleyballIcon:hse,Volume:xse,Volume1:mse,Volume1Icon:mse,Volume2:pse,Volume2Icon:pse,VolumeIcon:xse,VolumeOff:fse,VolumeOffIcon:fse,VolumeX:gse,VolumeXIcon:gse,Vote:yse,VoteIcon:yse,Wallet:RP,Wallet2:ck,Wallet2Icon:ck,WalletCards:vse,WalletCardsIcon:vse,WalletIcon:RP,WalletMinimal:ck,WalletMinimalIcon:ck,Wallpaper:_se,WallpaperIcon:_se,Wand:bse,Wand2:c0,Wand2Icon:c0,WandIcon:bse,WandSparkles:c0,WandSparklesIcon:c0,Warehouse:wse,WarehouseIcon:wse,WashingMachine:jse,WashingMachineIcon:jse,Watch:kse,WatchIcon:kse,Waves:Nse,WavesIcon:Nse,Waypoints:Sse,WaypointsIcon:Sse,Webcam:Cse,WebcamIcon:Cse,Webhook:Tse,WebhookIcon:Tse,WebhookOff:Mse,WebhookOffIcon:Mse,Weight:Ase,WeightIcon:Ase,Wheat:Pse,WheatIcon:Pse,WheatOff:Ese,WheatOffIcon:Ese,WholeWord:Ise,WholeWordIcon:Ise,Wifi:Fse,WifiHigh:Lse,WifiHighIcon:Lse,WifiIcon:Fse,WifiLow:Dse,WifiLowIcon:Dse,WifiOff:Ose,WifiOffIcon:Ose,WifiZero:Rse,WifiZeroIcon:Rse,Wind:Bse,WindArrowDown:zse,WindArrowDownIcon:zse,WindIcon:Bse,Wine:qse,WineIcon:qse,WineOff:$se,WineOffIcon:$se,Workflow:Use,WorkflowIcon:Use,Worm:Vse,WormIcon:Vse,WrapText:Hse,WrapTextIcon:Hse,Wrench:Kx,WrenchIcon:Kx,X:Ur,XCircle:wc,XCircleIcon:wc,XIcon:Ur,XOctagon:I2,XOctagonIcon:I2,XSquare:Gj,XSquareIcon:Gj,Youtube:Wse,YoutubeIcon:Wse,Zap:Lm,ZapIcon:Lm,ZapOff:Gse,ZapOffIcon:Gse,ZoomIn:o_,ZoomInIcon:o_,ZoomOut:j5,ZoomOutIcon:j5,createLucideIcon:Z,icons:Pot},Symbol.toStringTag,{value:"Module"})),Xve="-",Iot=t=>{const s=Dot(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:l=>{const i=l.split(Xve);return i[0]===""&&i.length!==1&&i.shift(),mRe(i,s)||Lot(l)},getConflictingClassGroupIds:(l,i)=>{const d=r[l]||[];return i&&n[l]?[...d,...n[l]]:d}}},mRe=(t,s)=>{var l;if(t.length===0)return s.classGroupId;const r=t[0],n=s.nextPart.get(r),a=n?mRe(t.slice(1),n):void 0;if(a)return a;if(s.validators.length===0)return;const o=t.join(Xve);return(l=s.validators.find(({validator:i})=>i(o)))==null?void 0:l.classGroupId},e4e=/^\[(.+)\]$/,Lot=t=>{if(e4e.test(t)){const s=e4e.exec(t)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},Dot=t=>{const{theme:s,prefix:r}=t,n={nextPart:new Map,validators:[]};return Rot(Object.entries(t.classGroups),r).forEach(([o,l])=>{Efe(l,n,o,s)}),n},Efe=(t,s,r,n)=>{t.forEach(a=>{if(typeof a=="string"){const o=a===""?s:t4e(s,a);o.classGroupId=r;return}if(typeof a=="function"){if(Oot(a)){Efe(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([o,l])=>{Efe(l,t4e(s,o),r,n)})})},t4e=(t,s)=>{let r=t;return s.split(Xve).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},Oot=t=>t.isThemeGetter,Rot=(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,Fot=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)}}},pRe="!",zot=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,g;for(let w=0;wp?g-p:void 0;return{modifiers:d,hasImportantModifier:_,baseClassName:b,maybePostfixModifierPosition:j}};return r?i=>r({className:i,parseClassName:l}):l},Bot=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},$ot=t=>({cache:Fot(t.cacheSize),parseClassName:zot(t),...Iot(t)}),qot=/\s+/,Uot=(t,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,o=[],l=t.trim().split(qot);let i="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{modifiers:p,hasImportantModifier:g,baseClassName:v,maybePostfixModifierPosition:_}=r(u);let b=!!_,j=n(b?v.substring(0,_):v);if(!j){if(!b){i=u+(i.length>0?" "+i:i);continue}if(j=n(v),!j){i=u+(i.length>0?" "+i:i);continue}b=!1}const w=Bot(p).join(":"),N=g?w+pRe:w,C=N+j;if(o.includes(C))continue;o.push(C);const A=a(j,b);for(let I=0;I0?" "+i:i)}return i};function Vot(){let t=0,s,r,n="";for(;t{if(typeof t=="string")return t;let s,r="";for(let n=0;ng(p),t());return r=$ot(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=Uot(d,r);return a(d,p),p}return function(){return o(Vot.apply(null,arguments))}}const Hl=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},gRe=/^\[(?:([a-z-]+):)?(.+)\]$/i,Wot=/^\d+\/\d+$/,Got=new Set(["px","full","screen"]),Kot=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Zot=/\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$/,Yot=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Xot=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Qot=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,qy=t=>k5(t)||Got.has(t)||Wot.test(t),Hv=t=>rM(t,"length",ilt),k5=t=>!!t&&!Number.isNaN(Number(t)),ihe=t=>rM(t,"number",k5),UA=t=>!!t&&Number.isInteger(Number(t)),Jot=t=>t.endsWith("%")&&k5(t.slice(0,-1)),Oi=t=>gRe.test(t),Wv=t=>Kot.test(t),elt=new Set(["length","size","percentage"]),tlt=t=>rM(t,elt,xRe),slt=t=>rM(t,"position",xRe),rlt=new Set(["image","url"]),nlt=t=>rM(t,rlt,llt),alt=t=>rM(t,"",olt),VA=()=>!0,rM=(t,s,r)=>{const n=gRe.exec(t);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},ilt=t=>Zot.test(t)&&!Yot.test(t),xRe=()=>!1,olt=t=>Xot.test(t),llt=t=>Qot.test(t),clt=()=>{const t=Hl("colors"),s=Hl("spacing"),r=Hl("blur"),n=Hl("brightness"),a=Hl("borderColor"),o=Hl("borderRadius"),l=Hl("borderSpacing"),i=Hl("borderWidth"),d=Hl("contrast"),u=Hl("grayscale"),p=Hl("hueRotate"),g=Hl("invert"),v=Hl("gap"),_=Hl("gradientColorStops"),b=Hl("gradientColorStopPositions"),j=Hl("inset"),w=Hl("margin"),N=Hl("opacity"),C=Hl("padding"),A=Hl("saturate"),I=Hl("scale"),L=Hl("sepia"),R=Hl("skew"),$=Hl("space"),q=Hl("translate"),U=()=>["auto","contain","none"],V=()=>["auto","hidden","clip","visible","scroll"],X=()=>["auto",Oi,s],se=()=>[Oi,s],te=()=>["",qy,Hv],Y=()=>["auto",k5,Oi],de=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ie=()=>["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"],pe=()=>["","0",Oi],be=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ye=()=>[k5,Oi];return{cacheSize:500,separator:":",theme:{colors:[VA],spacing:[qy,Hv],blur:["none","",Wv,Oi],brightness:ye(),borderColor:[t],borderRadius:["none","","full",Wv,Oi],borderSpacing:se(),borderWidth:te(),contrast:ye(),grayscale:pe(),hueRotate:ye(),invert:pe(),gap:se(),gradientColorStops:[t],gradientColorStopPositions:[Jot,Hv],inset:X(),margin:X(),opacity:ye(),padding:se(),saturate:ye(),scale:ye(),sepia:pe(),skew:ye(),space:se(),translate:se()},classGroups:{aspect:[{aspect:["auto","square","video",Oi]}],container:["container"],columns:[{columns:[Wv]}],"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(),Oi]}],overflow:[{overflow:V()}],"overflow-x":[{"overflow-x":V()}],"overflow-y":[{"overflow-y":V()}],overscroll:[{overscroll:U()}],"overscroll-x":[{"overscroll-x":U()}],"overscroll-y":[{"overscroll-y":U()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[j]}],"inset-x":[{"inset-x":[j]}],"inset-y":[{"inset-y":[j]}],start:[{start:[j]}],end:[{end:[j]}],top:[{top:[j]}],right:[{right:[j]}],bottom:[{bottom:[j]}],left:[{left:[j]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",UA,Oi]}],basis:[{basis:X()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Oi]}],grow:[{grow:pe()}],shrink:[{shrink:pe()}],order:[{order:["first","last","none",UA,Oi]}],"grid-cols":[{"grid-cols":[VA]}],"col-start-end":[{col:["auto",{span:["full",UA,Oi]},Oi]}],"col-start":[{"col-start":Y()}],"col-end":[{"col-end":Y()}],"grid-rows":[{"grid-rows":[VA]}],"row-start-end":[{row:["auto",{span:[UA,Oi]},Oi]}],"row-start":[{"row-start":Y()}],"row-end":[{"row-end":Y()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Oi]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Oi]}],gap:[{gap:[v]}],"gap-x":[{"gap-x":[v]}],"gap-y":[{"gap-y":[v]}],"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:[C]}],px:[{px:[C]}],py:[{py:[C]}],ps:[{ps:[C]}],pe:[{pe:[C]}],pt:[{pt:[C]}],pr:[{pr:[C]}],pb:[{pb:[C]}],pl:[{pl:[C]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"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",Oi,s]}],"min-w":[{"min-w":[Oi,s,"min","max","fit"]}],"max-w":[{"max-w":[Oi,s,"none","full","min","max","fit","prose",{screen:[Wv]},Wv]}],h:[{h:[Oi,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Oi,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Oi,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Oi,s,"auto","min","max","fit"]}],"font-size":[{text:["base",Wv,Hv]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",ihe]}],"font-family":[{font:[VA]}],"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",Oi]}],"line-clamp":[{"line-clamp":["none",k5,ihe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",qy,Oi]}],"list-image":[{"list-image":["none",Oi]}],"list-style-type":[{list:["none","disc","decimal",Oi]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[N]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[N]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ie(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",qy,Hv]}],"underline-offset":[{"underline-offset":["auto",qy,Oi]}],"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",Oi]}],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",Oi]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[N]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...de(),slt]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",tlt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},nlt]}],"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":[N]}],"border-style":[{border:[...ie(),"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":[N]}],"divide-style":[{divide:ie()}],"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:["",...ie()]}],"outline-offset":[{"outline-offset":[qy,Oi]}],"outline-w":[{outline:[qy,Hv]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[N]}],"ring-offset-w":[{"ring-offset":[qy,Hv]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Wv,alt]}],"shadow-color":[{shadow:[VA]}],opacity:[{opacity:[N]}],"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",Wv,Oi]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[g]}],saturate:[{saturate:[A]}],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":[g]}],"backdrop-opacity":[{"backdrop-opacity":[N]}],"backdrop-saturate":[{"backdrop-saturate":[A]}],"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",Oi]}],duration:[{duration:ye()}],ease:[{ease:["linear","in","out","in-out",Oi]}],delay:[{delay:ye()}],animate:[{animate:["none","spin","ping","pulse","bounce",Oi]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[I]}],"scale-x":[{"scale-x":[I]}],"scale-y":[{"scale-y":[I]}],rotate:[{rotate:[UA,Oi]}],"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",Oi]}],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",Oi]}],"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",Oi]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[qy,Hv,ihe]}],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"]}}},dlt=Hot(clt);function Et(...t){return dlt(Ri(t))}function Cl(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 s4e(t){const s=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(s)}function Xie(t){return t?t.replace(/<[^>]*>/g,""):""}const ult=Tot,yRe=S.forwardRef(({className:t,...s},r)=>e.jsx(nRe,{ref:r,className:Et("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}));yRe.displayName=nRe.displayName;const hlt=ZN("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"}}),vRe=S.forwardRef(({className:t,variant:s,...r},n)=>e.jsx(aRe,{ref:n,className:Et(hlt({variant:s}),t),...r}));vRe.displayName=aRe.displayName;const mlt=S.forwardRef(({className:t,...s},r)=>e.jsx(lRe,{ref:r,className:Et("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}));mlt.displayName=lRe.displayName;const _Re=S.forwardRef(({className:t,...s},r)=>e.jsx(cRe,{ref:r,className:Et("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"})}));_Re.displayName=cRe.displayName;const bRe=S.forwardRef(({className:t,...s},r)=>e.jsx(iRe,{ref:r,className:Et("text-sm font-semibold",t),...s}));bRe.displayName=iRe.displayName;const wRe=S.forwardRef(({className:t,...s},r)=>e.jsx(oRe,{ref:r,className:Et("text-sm opacity-90",t),...s}));wRe.displayName=oRe.displayName;function plt(){const{toasts:t}=Ea();return e.jsxs(ult,{children:[t.map(function({id:s,title:r,description:n,action:a,...o}){return e.jsxs(vRe,{...o,children:[e.jsxs("div",{className:"grid gap-1",children:[r&&e.jsx(bRe,{children:r}),n&&e.jsx(wRe,{children:n})]}),a,e.jsx(_Re,{})]},s)}),e.jsx(yRe,{})]})}var r4e=["light","dark"],flt="(prefers-color-scheme: dark)",glt=S.createContext(void 0),xlt={setTheme:t=>{},themes:[]},ylt=()=>{var t;return(t=S.useContext(glt))!=null?t:xlt};S.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';`,g=a?r4e.includes(o)&&o?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${o}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",v=(b,j=!1,w=!0)=>{let N=l?l[b]:b,C=j?b+"|| ''":`'${N}'`,A="";return a&&w&&!j&&r4e.includes(b)&&(A+=`d.style.colorScheme = '${b}';`),r==="class"?j||N?A+=`c.add(${C})`:A+="null":N&&(A+=`d[s](n,${C})`),A},_=t?`!function(){${p}${v(t)}}()`:n?`!function(){try{${p}var e=localStorage.getItem('${s}');if('system'===e||(!e&&${u})){var t='${flt}',m=window.matchMedia(t);if(m.media!==t||m.matches){${v("dark")}}else{${v("light")}}}else if(e){${l?`var x=${JSON.stringify(l)};`:""}${v(l?"x[e]":"e",!0)}}${u?"":"else{"+v(o,!1,!1)+"}"}${g}}catch(e){}}()`:`!function(){try{${p}var e=localStorage.getItem('${s}');if(e){${l?`var x=${JSON.stringify(l)};`:""}${v(l?"x[e]":"e",!0)}}else{${v(o,!1,!1)};}${g}}catch(t){}}();`;return S.createElement("script",{nonce:d,dangerouslySetInnerHTML:{__html:_}})});var vlt=t=>{switch(t){case"success":return wlt;case"info":return klt;case"warning":return jlt;case"error":return Nlt;default:return null}},_lt=Array(12).fill(0),blt=({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}`})))),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:"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"})),jlt=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"})),klt=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"})),Nlt=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"})),Slt=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"})),Clt=()=>{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},Pfe=1,Mlt=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:Pfe++,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(Alt(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)||Pfe++;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}},pm=new Mlt,Tlt=(t,s)=>{let r=(s==null?void 0:s.id)||Pfe++;return pm.addToast({title:t,...s,id:r}),r},Alt=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",Elt=Tlt,Plt=()=>pm.toasts,Ilt=()=>pm.getActiveToasts(),fe=Object.assign(Elt,{success:pm.success,info:pm.info,warning:pm.warning,error:pm.error,custom:pm.custom,message:pm.message,promise:pm.promise,dismiss:pm.dismiss,loading:pm.loading},{getHistory:Plt,getToasts:Ilt});function Llt(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))}Llt(`: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 f8(t){return t.label!==void 0}var Dlt=3,Olt="32px",Rlt="16px",n4e=4e3,Flt=356,zlt=14,Blt=20,$lt=200;function lg(...t){return t.filter(Boolean).join(" ")}function qlt(t){let[s,r]=t.split("-"),n=[];return s&&n.push(s),r&&n.push(r),n}var Ult=t=>{var s,r,n,a,o,l,i,d,u,p,g;let{invert:v,toast:_,unstyled:b,interacting:j,setHeights:w,visibleToasts:N,heights:C,index:A,toasts:I,expanded:L,removeToast:R,defaultRichColors:$,closeButton:q,style:U,cancelButtonStyle:V,actionButtonStyle:X,className:se="",descriptionClassName:te="",duration:Y,position:de,gap:ie,loadingIcon:ae,expandByDefault:le,classNames:pe,icons:be,closeButtonAriaLabel:ye="Close toast",pauseWhenPageIsHidden:we}=t,[Ne,Ke]=ht.useState(null),[_e,Me]=ht.useState(null),[Te,Fe]=ht.useState(!1),[Ae,Ue]=ht.useState(!1),[ut,De]=ht.useState(!1),[Dt,he]=ht.useState(!1),[Ve,nt]=ht.useState(!1),[Qe,ke]=ht.useState(0),[ot,qe]=ht.useState(0),lt=ht.useRef(_.duration||Y||n4e),We=ht.useRef(null),Ye=ht.useRef(null),mt=A===0,Ze=A+1<=N,He=_.type,et=_.dismissible!==!1,Rt=_.className||"",qt=_.descriptionClassName||"",ls=ht.useMemo(()=>C.findIndex(Zt=>Zt.toastId===_.id)||0,[C,_.id]),Kt=ht.useMemo(()=>{var Zt;return(Zt=_.closeButton)!=null?Zt:q},[_.closeButton,q]),Qt=ht.useMemo(()=>_.duration||Y||n4e,[_.duration,Y]),fs=ht.useRef(0),dr=ht.useRef(0),bt=ht.useRef(0),ks=ht.useRef(null),[ir,Rr]=de.split("-"),ca=ht.useMemo(()=>C.reduce((Zt,vr,Gr)=>Gr>=ls?Zt:Zt+vr.height,0),[C,ls]),ii=Clt(),lo=_.invert||v,Oa=He==="loading";dr.current=ht.useMemo(()=>ls*ie+ca,[ls,ca]),ht.useEffect(()=>{lt.current=Qt},[Qt]),ht.useEffect(()=>{Fe(!0)},[]),ht.useEffect(()=>{let Zt=Ye.current;if(Zt){let vr=Zt.getBoundingClientRect().height;return qe(vr),w(Gr=>[{toastId:_.id,height:vr,position:_.position},...Gr]),()=>w(Gr=>Gr.filter(Rn=>Rn.toastId!==_.id))}},[w,_.id]),ht.useLayoutEffect(()=>{if(!Te)return;let Zt=Ye.current,vr=Zt.style.height;Zt.style.height="auto";let Gr=Zt.getBoundingClientRect().height;Zt.style.height=vr,qe(Gr),w(Rn=>Rn.find(rs=>rs.toastId===_.id)?Rn.map(rs=>rs.toastId===_.id?{...rs,height:Gr}:rs):[{toastId:_.id,height:Gr,position:_.position},...Rn])},[Te,_.title,_.description,w,_.id]);let yn=ht.useCallback(()=>{Ue(!0),ke(dr.current),w(Zt=>Zt.filter(vr=>vr.toastId!==_.id)),setTimeout(()=>{R(_)},$lt)},[_,R,w,dr]);ht.useEffect(()=>{if(_.promise&&He==="loading"||_.duration===1/0||_.type==="loading")return;let Zt;return L||j||we&&ii?(()=>{if(bt.current{var vr;(vr=_.onAutoClose)==null||vr.call(_,_),yn()},lt.current)),()=>clearTimeout(Zt)},[L,j,_,He,we,ii,yn]),ht.useEffect(()=>{_.delete&&yn()},[yn,_.delete]);function ta(){var Zt,vr,Gr;return be!=null&&be.loading?ht.createElement("div",{className:lg(pe==null?void 0:pe.loader,(Zt=_==null?void 0:_.classNames)==null?void 0:Zt.loader,"sonner-loader"),"data-visible":He==="loading"},be.loading):ae?ht.createElement("div",{className:lg(pe==null?void 0:pe.loader,(vr=_==null?void 0:_.classNames)==null?void 0:vr.loader,"sonner-loader"),"data-visible":He==="loading"},ae):ht.createElement(blt,{className:lg(pe==null?void 0:pe.loader,(Gr=_==null?void 0:_.classNames)==null?void 0:Gr.loader),visible:He==="loading"})}return ht.createElement("li",{tabIndex:0,ref:Ye,className:lg(se,Rt,pe==null?void 0:pe.toast,(s=_==null?void 0:_.classNames)==null?void 0:s.toast,pe==null?void 0:pe.default,pe==null?void 0:pe[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":Ve,"data-removed":Ae,"data-visible":Ze,"data-y-position":ir,"data-x-position":Rr,"data-index":A,"data-front":mt,"data-swiping":ut,"data-dismissible":et,"data-type":He,"data-invert":lo,"data-swipe-out":Dt,"data-swipe-direction":_e,"data-expanded":!!(L||le&&Te),style:{"--index":A,"--toasts-before":A,"--z-index":I.length-A,"--offset":`${Ae?Qe:dr.current}px`,"--initial-height":le?"auto":`${ot}px`,...U,..._.style},onDragEnd:()=>{De(!1),Ke(null),ks.current=null},onPointerDown:Zt=>{Oa||!et||(We.current=new Date,ke(dr.current),Zt.target.setPointerCapture(Zt.pointerId),Zt.target.tagName!=="BUTTON"&&(De(!0),ks.current={x:Zt.clientX,y:Zt.clientY}))},onPointerUp:()=>{var Zt,vr,Gr,Rn;if(Dt||!et)return;ks.current=null;let rs=Number(((Zt=Ye.current)==null?void 0:Zt.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ln=Number(((vr=Ye.current)==null?void 0:vr.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),da=new Date().getTime()-((Gr=We.current)==null?void 0:Gr.getTime()),Va=Ne==="x"?rs:Ln,Jr=Math.abs(Va)/da;if(Math.abs(Va)>=Blt||Jr>.11){ke(dr.current),(Rn=_.onDismiss)==null||Rn.call(_,_),Me(Ne==="x"?rs>0?"right":"left":Ln>0?"down":"up"),yn(),he(!0),nt(!1);return}De(!1),Ke(null)},onPointerMove:Zt=>{var vr,Gr,Rn,rs;if(!ks.current||!et||((vr=window.getSelection())==null?void 0:vr.toString().length)>0)return;let Ln=Zt.clientY-ks.current.y,da=Zt.clientX-ks.current.x,Va=(Gr=t.swipeDirections)!=null?Gr:qlt(de);!Ne&&(Math.abs(da)>1||Math.abs(Ln)>1)&&Ke(Math.abs(da)>Math.abs(Ln)?"x":"y");let Jr={x:0,y:0};Ne==="y"?(Va.includes("top")||Va.includes("bottom"))&&(Va.includes("top")&&Ln<0||Va.includes("bottom")&&Ln>0)&&(Jr.y=Ln):Ne==="x"&&(Va.includes("left")||Va.includes("right"))&&(Va.includes("left")&&da<0||Va.includes("right")&&da>0)&&(Jr.x=da),(Math.abs(Jr.x)>0||Math.abs(Jr.y)>0)&&nt(!0),(Rn=Ye.current)==null||Rn.style.setProperty("--swipe-amount-x",`${Jr.x}px`),(rs=Ye.current)==null||rs.style.setProperty("--swipe-amount-y",`${Jr.y}px`)}},Kt&&!_.jsx?ht.createElement("button",{"aria-label":ye,"data-disabled":Oa,"data-close-button":!0,onClick:Oa||!et?()=>{}:()=>{var Zt;yn(),(Zt=_.onDismiss)==null||Zt.call(_,_)},className:lg(pe==null?void 0:pe.closeButton,(a=_==null?void 0:_.classNames)==null?void 0:a.closeButton)},(o=be==null?void 0:be.close)!=null?o:Slt):null,_.jsx||S.isValidElement(_.title)?_.jsx?_.jsx:typeof _.title=="function"?_.title():_.title:ht.createElement(ht.Fragment,null,He||_.icon||_.promise?ht.createElement("div",{"data-icon":"",className:lg(pe==null?void 0:pe.icon,(l=_==null?void 0:_.classNames)==null?void 0:l.icon)},_.promise||_.type==="loading"&&!_.icon?_.icon||ta():null,_.type!=="loading"?_.icon||(be==null?void 0:be[He])||vlt(He):null):null,ht.createElement("div",{"data-content":"",className:lg(pe==null?void 0:pe.content,(i=_==null?void 0:_.classNames)==null?void 0:i.content)},ht.createElement("div",{"data-title":"",className:lg(pe==null?void 0:pe.title,(d=_==null?void 0:_.classNames)==null?void 0:d.title)},typeof _.title=="function"?_.title():_.title),_.description?ht.createElement("div",{"data-description":"",className:lg(te,qt,pe==null?void 0:pe.description,(u=_==null?void 0:_.classNames)==null?void 0:u.description)},typeof _.description=="function"?_.description():_.description):null),S.isValidElement(_.cancel)?_.cancel:_.cancel&&f8(_.cancel)?ht.createElement("button",{"data-button":!0,"data-cancel":!0,style:_.cancelButtonStyle||V,onClick:Zt=>{var vr,Gr;f8(_.cancel)&&et&&((Gr=(vr=_.cancel).onClick)==null||Gr.call(vr,Zt),yn())},className:lg(pe==null?void 0:pe.cancelButton,(p=_==null?void 0:_.classNames)==null?void 0:p.cancelButton)},_.cancel.label):null,S.isValidElement(_.action)?_.action:_.action&&f8(_.action)?ht.createElement("button",{"data-button":!0,"data-action":!0,style:_.actionButtonStyle||X,onClick:Zt=>{var vr,Gr;f8(_.action)&&((Gr=(vr=_.action).onClick)==null||Gr.call(vr,Zt),!Zt.defaultPrevented&&yn())},className:lg(pe==null?void 0:pe.actionButton,(g=_==null?void 0:_.classNames)==null?void 0:g.actionButton)},_.action.label):null))};function a4e(){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 Vlt(t,s){let r={};return[t,s].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?Rlt:Olt;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 Hlt=S.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:g,duration:v,style:_,visibleToasts:b=Dlt,toastOptions:j,dir:w=a4e(),gap:N=zlt,loadingIcon:C,icons:A,containerAriaLabel:I="Notifications",pauseWhenPageIsHidden:L}=t,[R,$]=ht.useState([]),q=ht.useMemo(()=>Array.from(new Set([n].concat(R.filter(we=>we.position).map(we=>we.position)))),[R,n]),[U,V]=ht.useState([]),[X,se]=ht.useState(!1),[te,Y]=ht.useState(!1),[de,ie]=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,""),pe=ht.useRef(null),be=ht.useRef(!1),ye=ht.useCallback(we=>{$(Ne=>{var Ke;return(Ke=Ne.find(_e=>_e.id===we.id))!=null&&Ke.delete||pm.dismiss(we.id),Ne.filter(({id:_e})=>_e!==we.id)})},[]);return ht.useEffect(()=>pm.subscribe(we=>{if(we.dismiss){$(Ne=>Ne.map(Ke=>Ke.id===we.id?{...Ke,delete:!0}:Ke));return}setTimeout(()=>{Vve.flushSync(()=>{$(Ne=>{let Ke=Ne.findIndex(_e=>_e.id===we.id);return Ke!==-1?[...Ne.slice(0,Ke),{...Ne[Ke],...we},...Ne.slice(Ke+1)]:[we,...Ne]})})})}),[]),ht.useEffect(()=>{if(p!=="system"){ie(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?ie("dark"):ie("light")),typeof window>"u")return;let we=window.matchMedia("(prefers-color-scheme: dark)");try{we.addEventListener("change",({matches:Ne})=>{ie(Ne?"dark":"light")})}catch{we.addListener(({matches:Ke})=>{try{ie(Ke?"dark":"light")}catch(_e){console.error(_e)}})}},[p]),ht.useEffect(()=>{R.length<=1&&se(!1)},[R]),ht.useEffect(()=>{let we=Ne=>{var Ke,_e;a.every(Me=>Ne[Me]||Ne.code===Me)&&(se(!0),(Ke=ae.current)==null||Ke.focus()),Ne.code==="Escape"&&(document.activeElement===ae.current||(_e=ae.current)!=null&&_e.contains(document.activeElement))&&se(!1)};return document.addEventListener("keydown",we),()=>document.removeEventListener("keydown",we)},[a]),ht.useEffect(()=>{if(ae.current)return()=>{pe.current&&(pe.current.focus({preventScroll:!0}),pe.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((we,Ne)=>{var Ke;let[_e,Me]=we.split("-");return R.length?ht.createElement("ol",{key:we,dir:w==="auto"?a4e():w,tabIndex:-1,ref:ae,className:i,"data-sonner-toaster":!0,"data-theme":de,"data-y-position":_e,"data-lifted":X&&R.length>1&&!o,"data-x-position":Me,style:{"--front-toast-height":`${((Ke=U[0])==null?void 0:Ke.height)||0}px`,"--width":`${Flt}px`,"--gap":`${N}px`,..._,...Vlt(d,u)},onBlur:Te=>{be.current&&!Te.currentTarget.contains(Te.relatedTarget)&&(be.current=!1,pe.current&&(pe.current.focus({preventScroll:!0}),pe.current=null))},onFocus:Te=>{Te.target instanceof HTMLElement&&Te.target.dataset.dismissible==="false"||be.current||(be.current=!0,pe.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"||Y(!0)},onPointerUp:()=>Y(!1)},R.filter(Te=>!Te.position&&Ne===0||Te.position===we).map((Te,Fe)=>{var Ae,Ue;return ht.createElement(Ult,{key:Te.id,icons:A,index:Fe,toast:Te,defaultRichColors:g,duration:(Ae=j==null?void 0:j.duration)!=null?Ae:v,className:j==null?void 0:j.className,descriptionClassName:j==null?void 0:j.descriptionClassName,invert:r,visibleToasts:b,closeButton:(Ue=j==null?void 0:j.closeButton)!=null?Ue:l,interacting:te,position:we,style:j==null?void 0:j.style,unstyled:j==null?void 0:j.unstyled,classNames:j==null?void 0:j.classNames,cancelButtonStyle:j==null?void 0:j.cancelButtonStyle,actionButtonStyle:j==null?void 0:j.actionButtonStyle,removeToast:ye,toasts:R.filter(ut=>ut.position==Te.position),heights:U.filter(ut=>ut.position==Te.position),setHeights:V,expandByDefault:o,gap:N,loadingIcon:C,expanded:X,pauseWhenPageIsHidden:L,swipeDirections:t.swipeDirections})})):null}))});const Wlt=({...t})=>{const{theme:s="system"}=ylt();return e.jsx(Hlt,{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 Glt=J0e[" useId ".trim().toString()]||(()=>{}),Klt=0;function Hd(t){const[s,r]=S.useState(Glt());return Kc(()=>{r(n=>n??String(Klt++))},[t]),s?`radix-${s}`:""}const Zlt=["top","right","bottom","left"],w_=Math.min,np=Math.max,Gre=Math.round,g8=Math.floor,Zx=t=>({x:t,y:t}),Ylt={left:"right",right:"left",bottom:"top",top:"bottom"},Xlt={start:"end",end:"start"};function Ife(t,s,r){return np(t,w_(s,r))}function W0(t,s){return typeof t=="function"?t(s):t}function G0(t){return t.split("-")[0]}function nM(t){return t.split("-")[1]}function Qve(t){return t==="x"?"y":"x"}function Jve(t){return t==="y"?"height":"width"}const Qlt=new Set(["top","bottom"]);function Dx(t){return Qlt.has(G0(t))?"y":"x"}function e1e(t){return Qve(Dx(t))}function Jlt(t,s,r){r===void 0&&(r=!1);const n=nM(t),a=e1e(t),o=Jve(a);let l=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return s.reference[o]>s.floating[o]&&(l=Kre(l)),[l,Kre(l)]}function ect(t){const s=Kre(t);return[Lfe(t),s,Lfe(s)]}function Lfe(t){return t.replace(/start|end/g,s=>Xlt[s])}const i4e=["left","right"],o4e=["right","left"],tct=["top","bottom"],sct=["bottom","top"];function rct(t,s,r){switch(t){case"top":case"bottom":return r?s?o4e:i4e:s?i4e:o4e;case"left":case"right":return s?tct:sct;default:return[]}}function nct(t,s,r,n){const a=nM(t);let o=rct(G0(t),r==="start",n);return a&&(o=o.map(l=>l+"-"+a),s&&(o=o.concat(o.map(Lfe)))),o}function Kre(t){return t.replace(/left|right|bottom|top/g,s=>Ylt[s])}function act(t){return{top:0,right:0,bottom:0,left:0,...t}}function jRe(t){return typeof t!="number"?act(t):{top:t,right:t,bottom:t,left:t}}function Zre(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 l4e(t,s,r){let{reference:n,floating:a}=t;const o=Dx(s),l=e1e(s),i=Jve(l),d=G0(s),u=o==="y",p=n.x+n.width/2-a.width/2,g=n.y+n.height/2-a.height/2,v=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:g};break;case"left":_={x:n.x-a.width,y:g};break;default:_={x:n.x,y:n.y}}switch(nM(s)){case"start":_[l]-=v*(r&&u?-1:1);break;case"end":_[l]+=v*(r&&u?-1:1);break}return _}const ict=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:g}=l4e(u,n,d),v=n,_={},b=0;for(let j=0;j({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}=W0(t,s)||{};if(u==null)return{};const g=jRe(p),v={x:r,y:n},_=e1e(a),b=Jve(_),j=await l.getDimensions(u),w=_==="y",N=w?"top":"left",C=w?"bottom":"right",A=w?"clientHeight":"clientWidth",I=o.reference[b]+o.reference[_]-v[_]-o.floating[b],L=v[_]-o.reference[_],R=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u));let $=R?R[A]:0;(!$||!await(l.isElement==null?void 0:l.isElement(R)))&&($=i.floating[A]||o.floating[b]);const q=I/2-L/2,U=$/2-j[b]/2-1,V=w_(g[N],U),X=w_(g[C],U),se=V,te=$-j[b]-X,Y=$/2-j[b]/2+q,de=Ife(se,Y,te),ie=!d.arrow&&nM(a)!=null&&Y!==de&&o.reference[b]/2-(YY<=0)){var X,se;const Y=(((X=o.flip)==null?void 0:X.index)||0)+1,de=$[Y];if(de&&(!(g==="alignment"?C!==Dx(de):!1)||V.every(le=>le.overflows[0]>0&&Dx(le.placement)===C)))return{data:{index:Y,overflows:V},reset:{placement:de}};let ie=(se=V.filter(ae=>ae.overflows[0]<=0).sort((ae,le)=>ae.overflows[1]-le.overflows[1])[0])==null?void 0:se.placement;if(!ie)switch(_){case"bestFit":{var te;const ae=(te=V.filter(le=>{if(R){const pe=Dx(le.placement);return pe===C||pe==="y"}return!0}).map(le=>[le.placement,le.overflows.filter(pe=>pe>0).reduce((pe,be)=>pe+be,0)]).sort((le,pe)=>le[1]-pe[1])[0])==null?void 0:te[0];ae&&(ie=ae);break}case"initialPlacement":ie=i;break}if(a!==ie)return{reset:{placement:ie}}}return{}}}};function c4e(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function d4e(t){return Zlt.some(s=>t[s]>=0)}const cct=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:r}=s,{strategy:n="referenceHidden",...a}=W0(t,s);switch(n){case"referenceHidden":{const o=await DI(s,{...a,elementContext:"reference"}),l=c4e(o,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:d4e(l)}}}case"escaped":{const o=await DI(s,{...a,altBoundary:!0}),l=c4e(o,r.floating);return{data:{escapedOffsets:l,escaped:d4e(l)}}}default:return{}}}}},kRe=new Set(["left","top"]);async function dct(t,s){const{placement:r,platform:n,elements:a}=t,o=await(n.isRTL==null?void 0:n.isRTL(a.floating)),l=G0(r),i=nM(r),d=Dx(r)==="y",u=kRe.has(l)?-1:1,p=o&&d?-1:1,g=W0(s,t);let{mainAxis:v,crossAxis:_,alignmentAxis:b}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return i&&typeof b=="number"&&(_=i==="end"?b*-1:b),d?{x:_*p,y:v*u}:{x:v*u,y:_*p}}const uct=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 dct(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}}}}},hct=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:w=>{let{x:N,y:C}=w;return{x:N,y:C}}},...d}=W0(t,s),u={x:r,y:n},p=await DI(s,d),g=Dx(G0(a)),v=Qve(g);let _=u[v],b=u[g];if(o){const w=v==="y"?"top":"left",N=v==="y"?"bottom":"right",C=_+p[w],A=_-p[N];_=Ife(C,_,A)}if(l){const w=g==="y"?"top":"left",N=g==="y"?"bottom":"right",C=b+p[w],A=b-p[N];b=Ife(C,b,A)}const j=i.fn({...s,[v]:_,[g]:b});return{...j,data:{x:j.x-r,y:j.y-n,enabled:{[v]:o,[g]:l}}}}}},mct=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}=W0(t,s),p={x:r,y:n},g=Dx(a),v=Qve(g);let _=p[v],b=p[g];const j=W0(i,s),w=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(d){const A=v==="y"?"height":"width",I=o.reference[v]-o.floating[A]+w.mainAxis,L=o.reference[v]+o.reference[A]-w.mainAxis;_L&&(_=L)}if(u){var N,C;const A=v==="y"?"width":"height",I=kRe.has(G0(a)),L=o.reference[g]-o.floating[A]+(I&&((N=l.offset)==null?void 0:N[g])||0)+(I?0:w.crossAxis),R=o.reference[g]+o.reference[A]+(I?0:((C=l.offset)==null?void 0:C[g])||0)-(I?w.crossAxis:0);bR&&(b=R)}return{[v]:_,[g]:b}}}},pct=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}=W0(t,s),p=await DI(s,u),g=G0(a),v=nM(a),_=Dx(a)==="y",{width:b,height:j}=o.floating;let w,N;g==="top"||g==="bottom"?(w=g,N=v===(await(l.isRTL==null?void 0:l.isRTL(i.floating))?"start":"end")?"left":"right"):(N=g,w=v==="end"?"top":"bottom");const C=j-p.top-p.bottom,A=b-p.left-p.right,I=w_(j-p[w],C),L=w_(b-p[N],A),R=!s.middlewareData.shift;let $=I,q=L;if((r=s.middlewareData.shift)!=null&&r.enabled.x&&(q=A),(n=s.middlewareData.shift)!=null&&n.enabled.y&&($=C),R&&!v){const V=np(p.left,0),X=np(p.right,0),se=np(p.top,0),te=np(p.bottom,0);_?q=b-2*(V!==0||X!==0?V+X:np(p.left,p.right)):$=j-2*(se!==0||te!==0?se+te:np(p.top,p.bottom))}await d({...s,availableWidth:q,availableHeight:$});const U=await l.getDimensions(i.floating);return b!==U.width||j!==U.height?{reset:{rects:!0}}:{}}}};function Qie(){return typeof window<"u"}function aM(t){return NRe(t)?(t.nodeName||"").toLowerCase():"#document"}function gp(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function cy(t){var s;return(s=(NRe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function NRe(t){return Qie()?t instanceof Node||t instanceof gp(t).Node:!1}function qg(t){return Qie()?t instanceof Element||t instanceof gp(t).Element:!1}function ty(t){return Qie()?t instanceof HTMLElement||t instanceof gp(t).HTMLElement:!1}function u4e(t){return!Qie()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof gp(t).ShadowRoot}const fct=new Set(["inline","contents"]);function cL(t){const{overflow:s,overflowX:r,overflowY:n,display:a}=Ug(t);return/auto|scroll|overlay|hidden|clip/.test(s+n+r)&&!fct.has(a)}const gct=new Set(["table","td","th"]);function xct(t){return gct.has(aM(t))}const yct=[":popover-open",":modal"];function Jie(t){return yct.some(s=>{try{return t.matches(s)}catch{return!1}})}const vct=["transform","translate","scale","rotate","perspective"],_ct=["transform","translate","scale","rotate","perspective","filter"],bct=["paint","layout","strict","content"];function t1e(t){const s=s1e(),r=qg(t)?Ug(t):t;return vct.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))||bct.some(n=>(r.contain||"").includes(n))}function wct(t){let s=j_(t);for(;ty(s)&&!i3(s);){if(t1e(s))return s;if(Jie(s))return null;s=j_(s)}return null}function s1e(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const jct=new Set(["html","body","#document"]);function i3(t){return jct.has(aM(t))}function Ug(t){return gp(t).getComputedStyle(t)}function eoe(t){return qg(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function j_(t){if(aM(t)==="html")return t;const s=t.assignedSlot||t.parentNode||u4e(t)&&t.host||cy(t);return u4e(s)?s.host:s}function SRe(t){const s=j_(t);return i3(s)?t.ownerDocument?t.ownerDocument.body:t.body:ty(s)&&cL(s)?s:SRe(s)}function OI(t,s,r){var n;s===void 0&&(s=[]),r===void 0&&(r=!0);const a=SRe(t),o=a===((n=t.ownerDocument)==null?void 0:n.body),l=gp(a);if(o){const i=Dfe(l);return s.concat(l,l.visualViewport||[],cL(a)?a:[],i&&r?OI(i):[])}return s.concat(a,OI(a,[],r))}function Dfe(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function CRe(t){const s=Ug(t);let r=parseFloat(s.width)||0,n=parseFloat(s.height)||0;const a=ty(t),o=a?t.offsetWidth:r,l=a?t.offsetHeight:n,i=Gre(r)!==o||Gre(n)!==l;return i&&(r=o,n=l),{width:r,height:n,$:i}}function r1e(t){return qg(t)?t:t.contextElement}function N5(t){const s=r1e(t);if(!ty(s))return Zx(1);const r=s.getBoundingClientRect(),{width:n,height:a,$:o}=CRe(s);let l=(o?Gre(r.width):r.width)/n,i=(o?Gre(r.height):r.height)/a;return(!l||!Number.isFinite(l))&&(l=1),(!i||!Number.isFinite(i))&&(i=1),{x:l,y:i}}const kct=Zx(0);function MRe(t){const s=gp(t);return!s1e()||!s.visualViewport?kct:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function Nct(t,s,r){return s===void 0&&(s=!1),!r||s&&r!==gp(t)?!1:s}function kN(t,s,r,n){s===void 0&&(s=!1),r===void 0&&(r=!1);const a=t.getBoundingClientRect(),o=r1e(t);let l=Zx(1);s&&(n?qg(n)&&(l=N5(n)):l=N5(t));const i=Nct(o,r,n)?MRe(o):Zx(0);let d=(a.left+i.x)/l.x,u=(a.top+i.y)/l.y,p=a.width/l.x,g=a.height/l.y;if(o){const v=gp(o),_=n&&qg(n)?gp(n):n;let b=v,j=Dfe(b);for(;j&&n&&_!==b;){const w=N5(j),N=j.getBoundingClientRect(),C=Ug(j),A=N.left+(j.clientLeft+parseFloat(C.paddingLeft))*w.x,I=N.top+(j.clientTop+parseFloat(C.paddingTop))*w.y;d*=w.x,u*=w.y,p*=w.x,g*=w.y,d+=A,u+=I,b=gp(j),j=Dfe(b)}}return Zre({width:p,height:g,x:d,y:u})}function n1e(t,s){const r=eoe(t).scrollLeft;return s?s.left+r:kN(cy(t)).left+r}function TRe(t,s,r){r===void 0&&(r=!1);const n=t.getBoundingClientRect(),a=n.left+s.scrollLeft-(r?0:n1e(t,n)),o=n.top+s.scrollTop;return{x:a,y:o}}function Sct(t){let{elements:s,rect:r,offsetParent:n,strategy:a}=t;const o=a==="fixed",l=cy(n),i=s?Jie(s.floating):!1;if(n===l||i&&o)return r;let d={scrollLeft:0,scrollTop:0},u=Zx(1);const p=Zx(0),g=ty(n);if((g||!g&&!o)&&((aM(n)!=="body"||cL(l))&&(d=eoe(n)),ty(n))){const _=kN(n);u=N5(n),p.x=_.x+n.clientLeft,p.y=_.y+n.clientTop}const v=l&&!g&&!o?TRe(l,d,!0):Zx(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-d.scrollLeft*u.x+p.x+v.x,y:r.y*u.y-d.scrollTop*u.y+p.y+v.y}}function Cct(t){return Array.from(t.getClientRects())}function Mct(t){const s=cy(t),r=eoe(t),n=t.ownerDocument.body,a=np(s.scrollWidth,s.clientWidth,n.scrollWidth,n.clientWidth),o=np(s.scrollHeight,s.clientHeight,n.scrollHeight,n.clientHeight);let l=-r.scrollLeft+n1e(t);const i=-r.scrollTop;return Ug(n).direction==="rtl"&&(l+=np(s.clientWidth,n.clientWidth)-a),{width:a,height:o,x:l,y:i}}function Tct(t,s){const r=gp(t),n=cy(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=s1e();(!u||u&&s==="fixed")&&(i=a.offsetLeft,d=a.offsetTop)}return{width:o,height:l,x:i,y:d}}const Act=new Set(["absolute","fixed"]);function Ect(t,s){const r=kN(t,!0,s==="fixed"),n=r.top+t.clientTop,a=r.left+t.clientLeft,o=ty(t)?N5(t):Zx(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 h4e(t,s,r){let n;if(s==="viewport")n=Tct(t,r);else if(s==="document")n=Mct(cy(t));else if(qg(s))n=Ect(s,r);else{const a=MRe(t);n={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return Zre(n)}function ARe(t,s){const r=j_(t);return r===s||!qg(r)||i3(r)?!1:Ug(r).position==="fixed"||ARe(r,s)}function Pct(t,s){const r=s.get(t);if(r)return r;let n=OI(t,[],!1).filter(i=>qg(i)&&aM(i)!=="body"),a=null;const o=Ug(t).position==="fixed";let l=o?j_(t):t;for(;qg(l)&&!i3(l);){const i=Ug(l),d=t1e(l);!d&&i.position==="fixed"&&(a=null),(o?!d&&!a:!d&&i.position==="static"&&!!a&&Act.has(a.position)||cL(l)&&!d&&ARe(t,l))?n=n.filter(p=>p!==l):a=i,l=j_(l)}return s.set(t,n),n}function Ict(t){let{element:s,boundary:r,rootBoundary:n,strategy:a}=t;const l=[...r==="clippingAncestors"?Jie(s)?[]:Pct(s,this._c):[].concat(r),n],i=l[0],d=l.reduce((u,p)=>{const g=h4e(s,p,a);return u.top=np(g.top,u.top),u.right=w_(g.right,u.right),u.bottom=w_(g.bottom,u.bottom),u.left=np(g.left,u.left),u},h4e(s,i,a));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function Lct(t){const{width:s,height:r}=CRe(t);return{width:s,height:r}}function Dct(t,s,r){const n=ty(s),a=cy(s),o=r==="fixed",l=kN(t,!0,o,s);let i={scrollLeft:0,scrollTop:0};const d=Zx(0);function u(){d.x=n1e(a)}if(n||!n&&!o)if((aM(s)!=="body"||cL(a))&&(i=eoe(s)),n){const _=kN(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?TRe(a,i):Zx(0),g=l.left+i.scrollLeft-d.x-p.x,v=l.top+i.scrollTop-d.y-p.y;return{x:g,y:v,width:l.width,height:l.height}}function ohe(t){return Ug(t).position==="static"}function m4e(t,s){if(!ty(t)||Ug(t).position==="fixed")return null;if(s)return s(t);let r=t.offsetParent;return cy(t)===r&&(r=r.ownerDocument.body),r}function ERe(t,s){const r=gp(t);if(Jie(t))return r;if(!ty(t)){let a=j_(t);for(;a&&!i3(a);){if(qg(a)&&!ohe(a))return a;a=j_(a)}return r}let n=m4e(t,s);for(;n&&xct(n)&&ohe(n);)n=m4e(n,s);return n&&i3(n)&&ohe(n)&&!t1e(n)?r:n||wct(t)||r}const Oct=async function(t){const s=this.getOffsetParent||ERe,r=this.getDimensions,n=await r(t.floating);return{reference:Dct(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Rct(t){return Ug(t).direction==="rtl"}const Fct={convertOffsetParentRelativeRectToViewportRelativeRect:Sct,getDocumentElement:cy,getClippingRect:Ict,getOffsetParent:ERe,getElementRects:Oct,getClientRects:Cct,getDimensions:Lct,getScale:N5,isElement:qg,isRTL:Rct};function PRe(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function zct(t,s){let r=null,n;const a=cy(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:g,width:v,height:_}=u;if(i||s(),!v||!_)return;const b=g8(g),j=g8(a.clientWidth-(p+v)),w=g8(a.clientHeight-(g+_)),N=g8(p),A={rootMargin:-b+"px "+-j+"px "+-w+"px "+-N+"px",threshold:np(0,w_(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&&!PRe(u,t.getBoundingClientRect())&&l(),I=!1}try{r=new IntersectionObserver(L,{...A,root:a.ownerDocument})}catch{r=new IntersectionObserver(L,A)}r.observe(t)}return l(!0),o}function Bct(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=r1e(t),p=a||o?[...u?OI(u):[],...OI(s)]:[];p.forEach(N=>{a&&N.addEventListener("scroll",r,{passive:!0}),o&&N.addEventListener("resize",r)});const g=u&&i?zct(u,r):null;let v=-1,_=null;l&&(_=new ResizeObserver(N=>{let[C]=N;C&&C.target===u&&_&&(_.unobserve(s),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var A;(A=_)==null||A.observe(s)})),r()}),u&&!d&&_.observe(u),_.observe(s));let b,j=d?kN(t):null;d&&w();function w(){const N=kN(t);j&&!PRe(j,N)&&r(),j=N,b=requestAnimationFrame(w)}return r(),()=>{var N;p.forEach(C=>{a&&C.removeEventListener("scroll",r),o&&C.removeEventListener("resize",r)}),g==null||g(),(N=_)==null||N.disconnect(),_=null,d&&cancelAnimationFrame(b)}}const $ct=uct,qct=hct,Uct=lct,Vct=pct,Hct=cct,p4e=oct,Wct=mct,Gct=(t,s,r)=>{const n=new Map,a={platform:Fct,...r},o={...a.platform,_c:n};return ict(t,s,{...a,platform:o})};var Kct=typeof document<"u",Zct=function(){},Kse=Kct?S.useLayoutEffect:Zct;function Yre(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(!Yre(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)&&!Yre(t[o],s[o]))return!1}return!0}return t!==t&&s!==s}function IRe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function f4e(t,s){const r=IRe(t);return Math.round(s*r)/r}function lhe(t){const s=S.useRef(t);return Kse(()=>{s.current=t}),s}function Yct(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,g]=S.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[v,_]=S.useState(n);Yre(v,n)||_(n);const[b,j]=S.useState(null),[w,N]=S.useState(null),C=S.useCallback(le=>{le!==R.current&&(R.current=le,j(le))},[]),A=S.useCallback(le=>{le!==$.current&&($.current=le,N(le))},[]),I=o||b,L=l||w,R=S.useRef(null),$=S.useRef(null),q=S.useRef(p),U=d!=null,V=lhe(d),X=lhe(a),se=lhe(u),te=S.useCallback(()=>{if(!R.current||!$.current)return;const le={placement:s,strategy:r,middleware:v};X.current&&(le.platform=X.current),Gct(R.current,$.current,le).then(pe=>{const be={...pe,isPositioned:se.current!==!1};Y.current&&!Yre(q.current,be)&&(q.current=be,_m.flushSync(()=>{g(be)}))})},[v,s,r,X,se]);Kse(()=>{u===!1&&q.current.isPositioned&&(q.current.isPositioned=!1,g(le=>({...le,isPositioned:!1})))},[u]);const Y=S.useRef(!1);Kse(()=>(Y.current=!0,()=>{Y.current=!1}),[]),Kse(()=>{if(I&&(R.current=I),L&&($.current=L),I&&L){if(V.current)return V.current(I,L,te);te()}},[I,L,te,V,U]);const de=S.useMemo(()=>({reference:R,floating:$,setReference:C,setFloating:A}),[C,A]),ie=S.useMemo(()=>({reference:I,floating:L}),[I,L]),ae=S.useMemo(()=>{const le={position:r,left:0,top:0};if(!ie.floating)return le;const pe=f4e(ie.floating,p.x),be=f4e(ie.floating,p.y);return i?{...le,transform:"translate("+pe+"px, "+be+"px)",...IRe(ie.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:pe,top:be}},[r,i,ie.floating,p.x,p.y]);return S.useMemo(()=>({...p,update:te,refs:de,elements:ie,floatingStyles:ae}),[p,te,de,ie,ae])}const Xct=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?p4e({element:n.current,padding:a}).fn(r):{}:n?p4e({element:n,padding:a}).fn(r):{}}}},Qct=(t,s)=>({...$ct(t),options:[t,s]}),Jct=(t,s)=>({...qct(t),options:[t,s]}),edt=(t,s)=>({...Wct(t),options:[t,s]}),tdt=(t,s)=>({...Uct(t),options:[t,s]}),sdt=(t,s)=>({...Vct(t),options:[t,s]}),rdt=(t,s)=>({...Hct(t),options:[t,s]}),ndt=(t,s)=>({...Xct(t),options:[t,s]});var adt="Arrow",LRe=S.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"})})});LRe.displayName=adt;var idt=LRe;function dL(t){const[s,r]=S.useState(void 0);return Kc(()=>{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 a1e="Popper",[DRe,dy]=Tc(a1e),[odt,ORe]=DRe(a1e),RRe=t=>{const{__scopePopper:s,children:r}=t,[n,a]=S.useState(null);return e.jsx(odt,{scope:s,anchor:n,onAnchorChange:a,children:r})};RRe.displayName=a1e;var FRe="PopperAnchor",zRe=S.forwardRef((t,s)=>{const{__scopePopper:r,virtualRef:n,...a}=t,o=ORe(FRe,r),l=S.useRef(null),i=Aa(s,l);return S.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||l.current)}),n?null:e.jsx(Qr.div,{...a,ref:i})});zRe.displayName=FRe;var i1e="PopperContent",[ldt,cdt]=DRe(i1e),BRe=S.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:g="partial",hideWhenDetached:v=!1,updatePositionStrategy:_="optimized",onPlaced:b,...j}=t,w=ORe(i1e,r),[N,C]=S.useState(null),A=Aa(s,Dt=>C(Dt)),[I,L]=S.useState(null),R=dL(I),$=(R==null?void 0:R.width)??0,q=(R==null?void 0:R.height)??0,U=n+(o!=="center"?"-"+o:""),V=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},X=Array.isArray(u)?u:[u],se=X.length>0,te={padding:V,boundary:X.filter(udt),altBoundary:se},{refs:Y,floatingStyles:de,placement:ie,isPositioned:ae,middlewareData:le}=Yct({strategy:"fixed",placement:U,whileElementsMounted:(...Dt)=>Bct(...Dt,{animationFrame:_==="always"}),elements:{reference:w.anchor},middleware:[Qct({mainAxis:a+q,alignmentAxis:l}),d&&Jct({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?edt():void 0,...te}),d&&tdt({...te}),sdt({...te,apply:({elements:Dt,rects:he,availableWidth:Ve,availableHeight:nt})=>{const{width:Qe,height:ke}=he.reference,ot=Dt.floating.style;ot.setProperty("--radix-popper-available-width",`${Ve}px`),ot.setProperty("--radix-popper-available-height",`${nt}px`),ot.setProperty("--radix-popper-anchor-width",`${Qe}px`),ot.setProperty("--radix-popper-anchor-height",`${ke}px`)}}),I&&ndt({element:I,padding:i}),hdt({arrowWidth:$,arrowHeight:q}),v&&rdt({strategy:"referenceHidden",...te})]}),[pe,be]=URe(ie),ye=Uc(b);Kc(()=>{ae&&(ye==null||ye())},[ae,ye]);const we=(Te=le.arrow)==null?void 0:Te.x,Ne=(Fe=le.arrow)==null?void 0:Fe.y,Ke=((Ae=le.arrow)==null?void 0:Ae.centerOffset)!==0,[_e,Me]=S.useState();return Kc(()=>{N&&Me(window.getComputedStyle(N).zIndex)},[N]),e.jsx("div",{ref:Y.setFloating,"data-radix-popper-content-wrapper":"",style:{...de,transform:ae?de.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:_e,"--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(ldt,{scope:r,placedSide:pe,onArrowChange:L,arrowX:we,arrowY:Ne,shouldHideArrow:Ke,children:e.jsx(Qr.div,{"data-side":pe,"data-align":be,...j,ref:A,style:{...j.style,animation:ae?void 0:"none"}})})})});BRe.displayName=i1e;var $Re="PopperArrow",ddt={top:"bottom",right:"left",bottom:"top",left:"right"},qRe=S.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,o=cdt($Re,n),l=ddt[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(idt,{...a,ref:r,style:{...a.style,display:"block"}})})});qRe.displayName=$Re;function udt(t){return t!==null}var hdt=t=>({name:"transformOrigin",options:t,fn(s){var w,N,C;const{placement:r,rects:n,middlewareData:a}=s,l=((w=a.arrow)==null?void 0:w.centerOffset)!==0,i=l?0:t.arrowWidth,d=l?0:t.arrowHeight,[u,p]=URe(r),g={start:"0%",center:"50%",end:"100%"}[p],v=(((N=a.arrow)==null?void 0:N.x)??0)+i/2,_=(((C=a.arrow)==null?void 0:C.y)??0)+d/2;let b="",j="";return u==="bottom"?(b=l?g:`${v}px`,j=`${-d}px`):u==="top"?(b=l?g:`${v}px`,j=`${n.floating.height+d}px`):u==="right"?(b=`${-d}px`,j=l?g:`${_}px`):u==="left"&&(b=`${n.floating.width+d}px`,j=l?g:`${_}px`),{data:{x:b,y:j}}}});function URe(t){const[s,r="center"]=t.split("-");return[s,r]}var uL=RRe,iM=zRe,hL=BRe,mL=qRe,[toe]=Tc("Tooltip",[dy]),soe=dy(),VRe="TooltipProvider",mdt=700,Ofe="tooltip.open",[pdt,o1e]=toe(VRe),HRe=t=>{const{__scopeTooltip:s,delayDuration:r=mdt,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=t,l=S.useRef(!0),i=S.useRef(!1),d=S.useRef(0);return S.useEffect(()=>{const u=d.current;return()=>window.clearTimeout(u)},[]),e.jsx(pdt,{scope:s,isOpenDelayedRef:l,delayDuration:r,onOpen:S.useCallback(()=>{window.clearTimeout(d.current),l.current=!1},[]),onClose:S.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,n)},[n]),isPointerInTransitRef:i,onPointerInTransitChange:S.useCallback(u=>{i.current=u},[]),disableHoverableContent:a,children:o})};HRe.displayName=VRe;var RI="Tooltip",[fdt,roe]=toe(RI),WRe=t=>{const{__scopeTooltip:s,children:r,open:n,defaultOpen:a,onOpenChange:o,disableHoverableContent:l,delayDuration:i}=t,d=o1e(RI,t.__scopeTooltip),u=soe(s),[p,g]=S.useState(null),v=Hd(),_=S.useRef(0),b=l??d.disableHoverableContent,j=i??d.delayDuration,w=S.useRef(!1),[N,C]=fu({prop:n,defaultProp:a??!1,onChange:$=>{$?(d.onOpen(),document.dispatchEvent(new CustomEvent(Ofe))):d.onClose(),o==null||o($)},caller:RI}),A=S.useMemo(()=>N?w.current?"delayed-open":"instant-open":"closed",[N]),I=S.useCallback(()=>{window.clearTimeout(_.current),_.current=0,w.current=!1,C(!0)},[C]),L=S.useCallback(()=>{window.clearTimeout(_.current),_.current=0,C(!1)},[C]),R=S.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{w.current=!0,C(!0),_.current=0},j)},[j,C]);return S.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),e.jsx(uL,{...u,children:e.jsx(fdt,{scope:s,contentId:v,open:N,stateAttribute:A,trigger:p,onTriggerChange:g,onTriggerEnter:S.useCallback(()=>{d.isOpenDelayedRef.current?R():I()},[d.isOpenDelayedRef,R,I]),onTriggerLeave:S.useCallback(()=>{b?L():(window.clearTimeout(_.current),_.current=0)},[L,b]),onOpen:I,onClose:L,disableHoverableContent:b,children:r})})};WRe.displayName=RI;var Rfe="TooltipTrigger",GRe=S.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=roe(Rfe,r),o=o1e(Rfe,r),l=soe(r),i=S.useRef(null),d=Aa(s,i,a.onTriggerChange),u=S.useRef(!1),p=S.useRef(!1),g=S.useCallback(()=>u.current=!1,[]);return S.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),e.jsx(iM,{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,v=>{v.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",g,{once:!0})}),onFocus:Mr(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:Mr(t.onBlur,a.onClose),onClick:Mr(t.onClick,a.onClose)})})});GRe.displayName=Rfe;var gdt="TooltipPortal",[S1s,xdt]=toe(gdt,{forceMount:void 0}),o3="TooltipContent",KRe=S.forwardRef((t,s)=>{const r=xdt(o3,t.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=t,l=roe(o3,t.__scopeTooltip);return e.jsx(ud,{present:n||l.open,children:l.disableHoverableContent?e.jsx(ZRe,{side:a,...o,ref:s}):e.jsx(ydt,{side:a,...o,ref:s})})}),ydt=S.forwardRef((t,s)=>{const r=roe(o3,t.__scopeTooltip),n=o1e(o3,t.__scopeTooltip),a=S.useRef(null),o=Aa(s,a),[l,i]=S.useState(null),{trigger:d,onClose:u}=r,p=a.current,{onPointerInTransitChange:g}=n,v=S.useCallback(()=>{i(null),g(!1)},[g]),_=S.useCallback((b,j)=>{const w=b.currentTarget,N={x:b.clientX,y:b.clientY},C=jdt(N,w.getBoundingClientRect()),A=kdt(N,C),I=Ndt(j.getBoundingClientRect()),L=Cdt([...A,...I]);i(L),g(!0)},[g]);return S.useEffect(()=>()=>v(),[v]),S.useEffect(()=>{if(d&&p){const b=w=>_(w,p),j=w=>_(w,d);return d.addEventListener("pointerleave",b),p.addEventListener("pointerleave",j),()=>{d.removeEventListener("pointerleave",b),p.removeEventListener("pointerleave",j)}}},[d,p,_,v]),S.useEffect(()=>{if(l){const b=j=>{const w=j.target,N={x:j.clientX,y:j.clientY},C=(d==null?void 0:d.contains(w))||(p==null?void 0:p.contains(w)),A=!Sdt(N,l);C?v():A&&(v(),u())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[d,p,l,u,v]),e.jsx(ZRe,{...t,ref:o})}),[vdt,_dt]=toe(RI,{isInside:!1}),bdt=B8e("TooltipContent"),ZRe=S.forwardRef((t,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=t,d=roe(o3,r),u=soe(r),{onClose:p}=d;return S.useEffect(()=>(document.addEventListener(Ofe,p),()=>document.removeEventListener(Ofe,p)),[p]),S.useEffect(()=>{if(d.trigger){const g=v=>{const _=v.target;_!=null&&_.contains(d.trigger)&&p()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[d.trigger,p]),e.jsx(D_,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:g=>g.preventDefault(),onDismiss:p,children:e.jsxs(hL,{"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(bdt,{children:n}),e.jsx(vdt,{scope:r,isInside:!0,children:e.jsx(uot,{id:d.contentId,role:"tooltip",children:a||n})})]})})});KRe.displayName=o3;var YRe="TooltipArrow",wdt=S.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=soe(r);return _dt(YRe,r).isInside?null:e.jsx(mL,{...a,...n,ref:s})});wdt.displayName=YRe;function jdt(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 kdt(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 Ndt(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 Sdt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=v>n&&r<(g-u)*(n-p)/(v-p)+u&&(a=!a)}return a}function Cdt(t){const s=t.slice();return s.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),Mdt(s)}function Mdt(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 Tdt=HRe,Adt=WRe,Edt=GRe,XRe=KRe;const YN=Tdt,nd=Adt,ad=Edt,Hc=S.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(XRe,{ref:n,sideOffset:s,className:Et("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}));Hc.displayName=XRe.displayName;var oM=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(){}},NN=typeof window>"u"||"Deno"in globalThis;function Sh(){}function Pdt(t,s){return typeof t=="function"?t(s):t}function Ffe(t){return typeof t=="number"&&t>=0&&t!==1/0}function QRe(t,s){return Math.max(t+(s||0)-Date.now(),0)}function l_(t,s){return typeof t=="function"?t(s):t}function Gp(t,s){return typeof t=="function"?t(s):t}function g4e(t,s){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:l,stale:i}=t;if(l){if(n){if(s.queryHash!==l1e(l,s.options))return!1}else if(!FI(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 x4e(t,s){const{exact:r,status:n,predicate:a,mutationKey:o}=t;if(o){if(!s.options.mutationKey)return!1;if(r){if(SN(s.options.mutationKey)!==SN(o))return!1}else if(!FI(s.options.mutationKey,o))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function l1e(t,s){return((s==null?void 0:s.queryKeyHashFn)||SN)(t)}function SN(t){return JSON.stringify(t,(s,r)=>zfe(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function FI(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"&&typeof s=="object"?Object.keys(s).every(r=>FI(t[r],s[r])):!1}function JRe(t,s){if(t===s)return t;const r=y4e(t)&&y4e(s);if(r||zfe(t)&&zfe(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 Bfe(t,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,s):r.structuralSharing!==!1?JRe(t,s):s}function Ldt(t,s,r=0){const n=[...t,s];return r&&n.length>r?n.slice(1):n}function Ddt(t,s,r=0){const n=[s,...t];return r&&n.length>r?n.slice(0,-1):n}var c1e=Symbol();function eFe(t,s){return!t.queryFn&&(s!=null&&s.initialPromise)?()=>s.initialPromise:!t.queryFn||t.queryFn===c1e?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function tFe(t,s){return typeof t=="function"?t(...s):!!t}var Fk,b1,$5,fDe,Odt=(fDe=class extends oM{constructor(){super();Ba(this,Fk);Ba(this,b1);Ba(this,$5);qn(this,$5,s=>{if(!NN&&window.addEventListener){const r=()=>s();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){ds(this,b1)||this.setEventListener(ds(this,$5))}onUnsubscribe(){var s;this.hasListeners()||((s=ds(this,b1))==null||s.call(this),qn(this,b1,void 0))}setEventListener(s){var r;qn(this,$5,s),(r=ds(this,b1))==null||r.call(this),qn(this,b1,s(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(s){ds(this,Fk)!==s&&(qn(this,Fk,s),this.onFocus())}onFocus(){const s=this.isFocused();this.listeners.forEach(r=>{r(s)})}isFocused(){var s;return typeof ds(this,Fk)=="boolean"?ds(this,Fk):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},Fk=new WeakMap,b1=new WeakMap,$5=new WeakMap,fDe),d1e=new Odt,q5,w1,U5,gDe,Rdt=(gDe=class extends oM{constructor(){super();Ba(this,q5,!0);Ba(this,w1);Ba(this,U5);qn(this,U5,s=>{if(!NN&&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(){ds(this,w1)||this.setEventListener(ds(this,U5))}onUnsubscribe(){var s;this.hasListeners()||((s=ds(this,w1))==null||s.call(this),qn(this,w1,void 0))}setEventListener(s){var r;qn(this,U5,s),(r=ds(this,w1))==null||r.call(this),qn(this,w1,s(this.setOnline.bind(this)))}setOnline(s){ds(this,q5)!==s&&(qn(this,q5,s),this.listeners.forEach(n=>{n(s)}))}isOnline(){return ds(this,q5)}},q5=new WeakMap,w1=new WeakMap,U5=new WeakMap,gDe),Qre=new Rdt;function $fe(){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 Fdt(t){return Math.min(1e3*2**t,3e4)}function sFe(t){return(t??"online")==="online"?Qre.isOnline():!0}var rFe=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function che(t){return t instanceof rFe}function nFe(t){let s=!1,r=0,n=!1,a;const o=$fe(),l=j=>{var w;n||(v(new rFe(j)),(w=t.abort)==null||w.call(t))},i=()=>{s=!0},d=()=>{s=!1},u=()=>d1e.isFocused()&&(t.networkMode==="always"||Qre.isOnline())&&t.canRun(),p=()=>sFe(t.networkMode)&&t.canRun(),g=j=>{var w;n||(n=!0,(w=t.onSuccess)==null||w.call(t,j),a==null||a(),o.resolve(j))},v=j=>{var w;n||(n=!0,(w=t.onError)==null||w.call(t,j),a==null||a(),o.reject(j))},_=()=>new Promise(j=>{var w;a=N=>{(n||u())&&j(N)},(w=t.onPause)==null||w.call(t)}).then(()=>{var j;a=void 0,n||(j=t.onContinue)==null||j.call(t)}),b=()=>{if(n)return;let j;const w=r===0?t.initialPromise:void 0;try{j=w??t.fn()}catch(N){j=Promise.reject(N)}Promise.resolve(j).then(g).catch(N=>{var R;if(n)return;const C=t.retry??(NN?0:3),A=t.retryDelay??Fdt,I=typeof A=="function"?A(r,N):A,L=C===!0||typeof C=="number"&&ru()?void 0:_()).then(()=>{s?v(N):b()})})};return{promise:o,cancel:l,continue:()=>(a==null||a(),o),cancelRetry:i,continueRetry:d,canStart:p,start:()=>(p()?b():_().then(b),o)}}var zdt=t=>setTimeout(t,0);function Bdt(){let t=[],s=0,r=i=>{i()},n=i=>{i()},a=zdt;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 Fd=Bdt(),zk,xDe,aFe=(xDe=class{constructor(){Ba(this,zk)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ffe(this.gcTime)&&qn(this,zk,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(NN?1/0:5*60*1e3))}clearGcTimeout(){ds(this,zk)&&(clearTimeout(ds(this,zk)),qn(this,zk,void 0))}},zk=new WeakMap,xDe),V5,Bk,Wp,$k,Gu,Q6,qk,yg,Yy,yDe,$dt=(yDe=class extends aFe{constructor(s){super();Ba(this,yg);Ba(this,V5);Ba(this,Bk);Ba(this,Wp);Ba(this,$k);Ba(this,Gu);Ba(this,Q6);Ba(this,qk);qn(this,qk,!1),qn(this,Q6,s.defaultOptions),this.setOptions(s.options),this.observers=[],qn(this,$k,s.client),qn(this,Wp,ds(this,$k).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,qn(this,V5,qdt(this.options)),this.state=s.state??ds(this,V5),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var s;return(s=ds(this,Gu))==null?void 0:s.promise}setOptions(s){this.options={...ds(this,Q6),...s},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&ds(this,Wp).remove(this)}setData(s,r){const n=Bfe(this.state.data,s,this.options);return Bi(this,yg,Yy).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(s,r){Bi(this,yg,Yy).call(this,{type:"setState",state:s,setStateOptions:r})}cancel(s){var n,a;const r=(n=ds(this,Gu))==null?void 0:n.promise;return(a=ds(this,Gu))==null||a.cancel(s),r?r.then(Sh).catch(Sh):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(ds(this,V5))}isActive(){return this.observers.some(s=>Gp(s.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===c1e||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(s=>l_(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:!QRe(this.state.dataUpdatedAt,s)}onFocus(){var r;const s=this.observers.find(n=>n.shouldFetchOnWindowFocus());s==null||s.refetch({cancelRefetch:!1}),(r=ds(this,Gu))==null||r.continue()}onOnline(){var r;const s=this.observers.find(n=>n.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(r=ds(this,Gu))==null||r.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),ds(this,Wp).notify({type:"observerAdded",query:this,observer:s}))}removeObserver(s){this.observers.includes(s)&&(this.observers=this.observers.filter(r=>r!==s),this.observers.length||(ds(this,Gu)&&(ds(this,qk)?ds(this,Gu).cancel({revert:!0}):ds(this,Gu).cancelRetry()),this.scheduleGc()),ds(this,Wp).notify({type:"observerRemoved",query:this,observer:s}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Bi(this,yg,Yy).call(this,{type:"invalidate"})}fetch(s,r){var u,p,g;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(ds(this,Gu))return ds(this,Gu).continueRetry(),ds(this,Gu).promise}if(s&&this.setOptions(s),!this.options.queryFn){const v=this.observers.find(_=>_.options.queryFn);v&&this.setOptions(v.options)}const n=new AbortController,a=v=>{Object.defineProperty(v,"signal",{enumerable:!0,get:()=>(qn(this,qk,!0),n.signal)})},o=()=>{const v=eFe(this.options,r),b=(()=>{const j={client:ds(this,$k),queryKey:this.queryKey,meta:this.meta};return a(j),j})();return qn(this,qk,!1),this.options.persister?this.options.persister(v,b,this):v(b)},i=(()=>{const v={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:ds(this,$k),state:this.state,fetchFn:o};return a(v),v})();(u=this.options.behavior)==null||u.onFetch(i,this),qn(this,Bk,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=i.fetchOptions)==null?void 0:p.meta))&&Bi(this,yg,Yy).call(this,{type:"fetch",meta:(g=i.fetchOptions)==null?void 0:g.meta});const d=v=>{var _,b,j,w;che(v)&&v.silent||Bi(this,yg,Yy).call(this,{type:"error",error:v}),che(v)||((b=(_=ds(this,Wp).config).onError)==null||b.call(_,v,this),(w=(j=ds(this,Wp).config).onSettled)==null||w.call(j,this.state.data,v,this)),this.scheduleGc()};return qn(this,Gu,nFe({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:v=>{var _,b,j,w;if(v===void 0){d(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(v)}catch(N){d(N);return}(b=(_=ds(this,Wp).config).onSuccess)==null||b.call(_,v,this),(w=(j=ds(this,Wp).config).onSettled)==null||w.call(j,v,this.state.error,this),this.scheduleGc()},onError:d,onFail:(v,_)=>{Bi(this,yg,Yy).call(this,{type:"failed",failureCount:v,error:_})},onPause:()=>{Bi(this,yg,Yy).call(this,{type:"pause"})},onContinue:()=>{Bi(this,yg,Yy).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0})),ds(this,Gu).start()}},V5=new WeakMap,Bk=new WeakMap,Wp=new WeakMap,$k=new WeakMap,Gu=new WeakMap,Q6=new WeakMap,qk=new WeakMap,yg=new WeakSet,Yy=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,...iFe(n.data,this.options),fetchMeta:s.meta??null};case"success":return qn(this,Bk,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 che(a)&&a.revert&&ds(this,Bk)?{...ds(this,Bk),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),Fd.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),ds(this,Wp).notify({query:this,type:"updated",action:s})})},yDe);function iFe(t,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:sFe(s.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function qdt(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 Cx,vDe,Udt=(vDe=class extends oM{constructor(s={}){super();Ba(this,Cx);this.config=s,qn(this,Cx,new Map)}build(s,r,n){const a=r.queryKey,o=r.queryHash??l1e(a,r);let l=this.get(o);return l||(l=new $dt({client:s,queryKey:a,queryHash:o,options:s.defaultQueryOptions(r),state:n,defaultOptions:s.getQueryDefaults(a)}),this.add(l)),l}add(s){ds(this,Cx).has(s.queryHash)||(ds(this,Cx).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const r=ds(this,Cx).get(s.queryHash);r&&(s.destroy(),r===s&&ds(this,Cx).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){Fd.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return ds(this,Cx).get(s)}getAll(){return[...ds(this,Cx).values()]}find(s){const r={exact:!0,...s};return this.getAll().find(n=>g4e(r,n))}findAll(s={}){const r=this.getAll();return Object.keys(s).length>0?r.filter(n=>g4e(s,n)):r}notify(s){Fd.batch(()=>{this.listeners.forEach(r=>{r(s)})})}onFocus(){Fd.batch(()=>{this.getAll().forEach(s=>{s.onFocus()})})}onOnline(){Fd.batch(()=>{this.getAll().forEach(s=>{s.onOnline()})})}},Cx=new WeakMap,vDe),Mx,jh,Uk,Tx,Xv,_De,Vdt=(_De=class extends aFe{constructor(s){super();Ba(this,Tx);Ba(this,Mx);Ba(this,jh);Ba(this,Uk);this.mutationId=s.mutationId,qn(this,jh,s.mutationCache),qn(this,Mx,[]),this.state=s.state||oFe(),this.setOptions(s.options),this.scheduleGc()}setOptions(s){this.options=s,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(s){ds(this,Mx).includes(s)||(ds(this,Mx).push(s),this.clearGcTimeout(),ds(this,jh).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){qn(this,Mx,ds(this,Mx).filter(r=>r!==s)),this.scheduleGc(),ds(this,jh).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){ds(this,Mx).length||(this.state.status==="pending"?this.scheduleGc():ds(this,jh).remove(this))}continue(){var s;return((s=ds(this,Uk))==null?void 0:s.continue())??this.execute(this.state.variables)}async execute(s){var o,l,i,d,u,p,g,v,_,b,j,w,N,C,A,I,L,R,$,q;const r=()=>{Bi(this,Tx,Xv).call(this,{type:"continue"})};qn(this,Uk,nFe({fn:()=>this.options.mutationFn?this.options.mutationFn(s):Promise.reject(new Error("No mutationFn found")),onFail:(U,V)=>{Bi(this,Tx,Xv).call(this,{type:"failed",failureCount:U,error:V})},onPause:()=>{Bi(this,Tx,Xv).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>ds(this,jh).canRun(this)}));const n=this.state.status==="pending",a=!ds(this,Uk).canStart();try{if(n)r();else{Bi(this,Tx,Xv).call(this,{type:"pending",variables:s,isPaused:a}),await((l=(o=ds(this,jh).config).onMutate)==null?void 0:l.call(o,s,this));const V=await((d=(i=this.options).onMutate)==null?void 0:d.call(i,s));V!==this.state.context&&Bi(this,Tx,Xv).call(this,{type:"pending",context:V,variables:s,isPaused:a})}const U=await ds(this,Uk).start();return await((p=(u=ds(this,jh).config).onSuccess)==null?void 0:p.call(u,U,s,this.state.context,this)),await((v=(g=this.options).onSuccess)==null?void 0:v.call(g,U,s,this.state.context)),await((b=(_=ds(this,jh).config).onSettled)==null?void 0:b.call(_,U,null,this.state.variables,this.state.context,this)),await((w=(j=this.options).onSettled)==null?void 0:w.call(j,U,null,s,this.state.context)),Bi(this,Tx,Xv).call(this,{type:"success",data:U}),U}catch(U){try{throw await((C=(N=ds(this,jh).config).onError)==null?void 0:C.call(N,U,s,this.state.context,this)),await((I=(A=this.options).onError)==null?void 0:I.call(A,U,s,this.state.context)),await((R=(L=ds(this,jh).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{Bi(this,Tx,Xv).call(this,{type:"error",error:U})}}finally{ds(this,jh).runNext(this)}}},Mx=new WeakMap,jh=new WeakMap,Uk=new WeakMap,Tx=new WeakSet,Xv=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),Fd.batch(()=>{ds(this,Mx).forEach(n=>{n.onMutationUpdate(s)}),ds(this,jh).notify({mutation:this,type:"updated",action:s})})},_De);function oFe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var d0,vg,J6,bDe,Hdt=(bDe=class extends oM{constructor(s={}){super();Ba(this,d0);Ba(this,vg);Ba(this,J6);this.config=s,qn(this,d0,new Set),qn(this,vg,new Map),qn(this,J6,0)}build(s,r,n){const a=new Vdt({mutationCache:this,mutationId:++ZO(this,J6)._,options:s.defaultMutationOptions(r),state:n});return this.add(a),a}add(s){ds(this,d0).add(s);const r=x8(s);if(typeof r=="string"){const n=ds(this,vg).get(r);n?n.push(s):ds(this,vg).set(r,[s])}this.notify({type:"added",mutation:s})}remove(s){if(ds(this,d0).delete(s)){const r=x8(s);if(typeof r=="string"){const n=ds(this,vg).get(r);if(n)if(n.length>1){const a=n.indexOf(s);a!==-1&&n.splice(a,1)}else n[0]===s&&ds(this,vg).delete(r)}}this.notify({type:"removed",mutation:s})}canRun(s){const r=x8(s);if(typeof r=="string"){const n=ds(this,vg).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=x8(s);if(typeof r=="string"){const a=(n=ds(this,vg).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(){Fd.batch(()=>{ds(this,d0).forEach(s=>{this.notify({type:"removed",mutation:s})}),ds(this,d0).clear(),ds(this,vg).clear()})}getAll(){return Array.from(ds(this,d0))}find(s){const r={exact:!0,...s};return this.getAll().find(n=>x4e(r,n))}findAll(s={}){return this.getAll().filter(r=>x4e(s,r))}notify(s){Fd.batch(()=>{this.listeners.forEach(r=>{r(s)})})}resumePausedMutations(){const s=this.getAll().filter(r=>r.state.isPaused);return Fd.batch(()=>Promise.all(s.map(r=>r.continue().catch(Sh))))}},d0=new WeakMap,vg=new WeakMap,J6=new WeakMap,bDe);function x8(t){var s;return(s=t.options.scope)==null?void 0:s.id}function Jre(t){return{onFetch:(s,r)=>{var p,g,v,_,b;const n=s.options,a=(v=(g=(p=s.fetchOptions)==null?void 0:p.meta)==null?void 0:g.fetchMore)==null?void 0:v.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 j=!1;const w=A=>{Object.defineProperty(A,"signal",{enumerable:!0,get:()=>(s.signal.aborted?j=!0:s.signal.addEventListener("abort",()=>{j=!0}),s.signal)})},N=eFe(s.options,s.fetchOptions),C=async(A,I,L)=>{if(j)return Promise.reject();if(I==null&&A.pages.length)return Promise.resolve(A);const $=(()=>{const X={client:s.client,queryKey:s.queryKey,pageParam:I,direction:L?"backward":"forward",meta:s.options.meta};return w(X),X})(),q=await N($),{maxPages:U}=s.options,V=L?Ddt:Ldt;return{pages:V(A.pages,q,U),pageParams:V(A.pageParams,I,U)}};if(a&&o.length){const A=a==="backward",I=A?lFe:qfe,L={pages:o,pageParams:l},R=I(n,L);i=await C(L,R,A)}else{const A=t??o.length;do{const I=d===0?l[0]??n.initialPageParam:qfe(n,i);if(d>0&&I==null)break;i=await C(i,I),d++}while(d{var j,w;return(w=(j=s.options).persister)==null?void 0:w.call(j,u,{client:s.client,queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},r)}:s.fetchFn=u}}}function qfe(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 lFe(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 Wdt(t,s){return s?qfe(t,s)!=null:!1}function Gdt(t,s){return!s||!t.getPreviousPageParam?!1:lFe(t,s)!=null}var Lc,j1,k1,H5,W5,N1,G5,K5,wDe,Kdt=(wDe=class{constructor(t={}){Ba(this,Lc);Ba(this,j1);Ba(this,k1);Ba(this,H5);Ba(this,W5);Ba(this,N1);Ba(this,G5);Ba(this,K5);qn(this,Lc,t.queryCache||new Udt),qn(this,j1,t.mutationCache||new Hdt),qn(this,k1,t.defaultOptions||{}),qn(this,H5,new Map),qn(this,W5,new Map),qn(this,N1,0)}mount(){ZO(this,N1)._++,ds(this,N1)===1&&(qn(this,G5,d1e.subscribe(async t=>{t&&(await this.resumePausedMutations(),ds(this,Lc).onFocus())})),qn(this,K5,Qre.subscribe(async t=>{t&&(await this.resumePausedMutations(),ds(this,Lc).onOnline())})))}unmount(){var t,s;ZO(this,N1)._--,ds(this,N1)===0&&((t=ds(this,G5))==null||t.call(this),qn(this,G5,void 0),(s=ds(this,K5))==null||s.call(this),qn(this,K5,void 0))}isFetching(t){return ds(this,Lc).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return ds(this,j1).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=ds(this,Lc).get(s.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const s=this.defaultQueryOptions(t),r=ds(this,Lc).build(this,s),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(l_(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(n))}getQueriesData(t){return ds(this,Lc).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=ds(this,Lc).get(n.queryHash),o=a==null?void 0:a.state.data,l=Pdt(s,o);if(l!==void 0)return ds(this,Lc).build(this,n).setData(l,{...r,manual:!0})}setQueriesData(t,s,r){return Fd.batch(()=>ds(this,Lc).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,s,r)]))}getQueryState(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=ds(this,Lc).get(s.queryHash))==null?void 0:r.state}removeQueries(t){const s=ds(this,Lc);Fd.batch(()=>{s.findAll(t).forEach(r=>{s.remove(r)})})}resetQueries(t,s){const r=ds(this,Lc);return Fd.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},s)))}cancelQueries(t,s={}){const r={revert:!0,...s},n=Fd.batch(()=>ds(this,Lc).findAll(t).map(a=>a.cancel(r)));return Promise.all(n).then(Sh).catch(Sh)}invalidateQueries(t,s={}){return Fd.batch(()=>(ds(this,Lc).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=Fd.batch(()=>ds(this,Lc).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(Sh)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(Sh)}fetchQuery(t){const s=this.defaultQueryOptions(t);s.retry===void 0&&(s.retry=!1);const r=ds(this,Lc).build(this,s);return r.isStaleByTime(l_(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Sh).catch(Sh)}fetchInfiniteQuery(t){return t.behavior=Jre(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Sh).catch(Sh)}ensureInfiniteQueryData(t){return t.behavior=Jre(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Qre.isOnline()?ds(this,j1).resumePausedMutations():Promise.resolve()}getQueryCache(){return ds(this,Lc)}getMutationCache(){return ds(this,j1)}getDefaultOptions(){return ds(this,k1)}setDefaultOptions(t){qn(this,k1,t)}setQueryDefaults(t,s){ds(this,H5).set(SN(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...ds(this,H5).values()],r={};return s.forEach(n=>{FI(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,s){ds(this,W5).set(SN(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...ds(this,W5).values()],r={};return s.forEach(n=>{FI(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const s={...ds(this,k1).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return s.queryHash||(s.queryHash=l1e(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===c1e&&(s.enabled=!1),s}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...ds(this,k1).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){ds(this,Lc).clear(),ds(this,j1).clear()}},Lc=new WeakMap,j1=new WeakMap,k1=new WeakMap,H5=new WeakMap,W5=new WeakMap,N1=new WeakMap,G5=new WeakMap,K5=new WeakMap,wDe),um,xo,eL,kh,Vk,Z5,S1,C1,tL,Y5,X5,Hk,Wk,M1,Q5,Uo,wE,Ufe,Vfe,Hfe,Wfe,Gfe,Kfe,Zfe,dFe,jDe,cFe=(jDe=class extends oM{constructor(s,r){super();Ba(this,Uo);Ba(this,um);Ba(this,xo);Ba(this,eL);Ba(this,kh);Ba(this,Vk);Ba(this,Z5);Ba(this,S1);Ba(this,C1);Ba(this,tL);Ba(this,Y5);Ba(this,X5);Ba(this,Hk);Ba(this,Wk);Ba(this,M1);Ba(this,Q5,new Set);this.options=r,qn(this,um,s),qn(this,C1,null),qn(this,S1,$fe()),this.options.experimental_prefetchInRender||ds(this,S1).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&&(ds(this,xo).addObserver(this),_4e(ds(this,xo),this.options)?Bi(this,Uo,wE).call(this):this.updateResult(),Bi(this,Uo,Wfe).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Yfe(ds(this,xo),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Yfe(ds(this,xo),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Bi(this,Uo,Gfe).call(this),Bi(this,Uo,Kfe).call(this),ds(this,xo).removeObserver(this)}setOptions(s){const r=this.options,n=ds(this,xo);if(this.options=ds(this,um).defaultQueryOptions(s),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Gp(this.options.enabled,ds(this,xo))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Bi(this,Uo,Zfe).call(this),ds(this,xo).setOptions(this.options),r._defaulted&&!Xre(this.options,r)&&ds(this,um).getQueryCache().notify({type:"observerOptionsUpdated",query:ds(this,xo),observer:this});const a=this.hasListeners();a&&b4e(ds(this,xo),n,this.options,r)&&Bi(this,Uo,wE).call(this),this.updateResult(),a&&(ds(this,xo)!==n||Gp(this.options.enabled,ds(this,xo))!==Gp(r.enabled,ds(this,xo))||l_(this.options.staleTime,ds(this,xo))!==l_(r.staleTime,ds(this,xo)))&&Bi(this,Uo,Ufe).call(this);const o=Bi(this,Uo,Vfe).call(this);a&&(ds(this,xo)!==n||Gp(this.options.enabled,ds(this,xo))!==Gp(r.enabled,ds(this,xo))||o!==ds(this,M1))&&Bi(this,Uo,Hfe).call(this,o)}getOptimisticResult(s){const r=ds(this,um).getQueryCache().build(ds(this,um),s),n=this.createResult(r,s);return Ydt(this,n)&&(qn(this,kh,n),qn(this,Z5,this.options),qn(this,Vk,ds(this,xo).state)),n}getCurrentResult(){return ds(this,kh)}trackResult(s,r){return new Proxy(s,{get:(n,a)=>(this.trackProp(a),r==null||r(a),Reflect.get(n,a))})}trackProp(s){ds(this,Q5).add(s)}getCurrentQuery(){return ds(this,xo)}refetch({...s}={}){return this.fetch({...s})}fetchOptimistic(s){const r=ds(this,um).defaultQueryOptions(s),n=ds(this,um).getQueryCache().build(ds(this,um),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(s){return Bi(this,Uo,wE).call(this,{...s,cancelRefetch:s.cancelRefetch??!0}).then(()=>(this.updateResult(),ds(this,kh)))}createResult(s,r){var U;const n=ds(this,xo),a=this.options,o=ds(this,kh),l=ds(this,Vk),i=ds(this,Z5),u=s!==n?s.state:ds(this,eL),{state:p}=s;let g={...p},v=!1,_;if(r._optimisticResults){const V=this.hasListeners(),X=!V&&_4e(s,r),se=V&&b4e(s,n,r,a);(X||se)&&(g={...g,...iFe(p.data,s.options)}),r._optimisticResults==="isRestoring"&&(g.fetchStatus="idle")}let{error:b,errorUpdatedAt:j,status:w}=g;_=g.data;let N=!1;if(r.placeholderData!==void 0&&_===void 0&&w==="pending"){let V;o!=null&&o.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(V=o.data,N=!0):V=typeof r.placeholderData=="function"?r.placeholderData((U=ds(this,X5))==null?void 0:U.state.data,ds(this,X5)):r.placeholderData,V!==void 0&&(w="success",_=Bfe(o==null?void 0:o.data,V,r),v=!0)}if(r.select&&_!==void 0&&!N)if(o&&_===(l==null?void 0:l.data)&&r.select===ds(this,tL))_=ds(this,Y5);else try{qn(this,tL,r.select),_=r.select(_),_=Bfe(o==null?void 0:o.data,_,r),qn(this,Y5,_),qn(this,C1,null)}catch(V){qn(this,C1,V)}ds(this,C1)&&(b=ds(this,C1),_=ds(this,Y5),j=Date.now(),w="error");const C=g.fetchStatus==="fetching",A=w==="pending",I=w==="error",L=A&&C,R=_!==void 0,q={status:w,fetchStatus:g.fetchStatus,isPending:A,isSuccess:w==="success",isError:I,isInitialLoading:L,isLoading:L,data:_,dataUpdatedAt:g.dataUpdatedAt,error:b,errorUpdatedAt:j,failureCount:g.fetchFailureCount,failureReason:g.fetchFailureReason,errorUpdateCount:g.errorUpdateCount,isFetched:g.dataUpdateCount>0||g.errorUpdateCount>0,isFetchedAfterMount:g.dataUpdateCount>u.dataUpdateCount||g.errorUpdateCount>u.errorUpdateCount,isFetching:C,isRefetching:C&&!A,isLoadingError:I&&!R,isPaused:g.fetchStatus==="paused",isPlaceholderData:v,isRefetchError:I&&R,isStale:u1e(s,r),refetch:this.refetch,promise:ds(this,S1),isEnabled:Gp(r.enabled,s)!==!1};if(this.options.experimental_prefetchInRender){const V=te=>{q.status==="error"?te.reject(q.error):q.data!==void 0&&te.resolve(q.data)},X=()=>{const te=qn(this,S1,q.promise=$fe());V(te)},se=ds(this,S1);switch(se.status){case"pending":s.queryHash===n.queryHash&&V(se);break;case"fulfilled":(q.status==="error"||q.data!==se.value)&&X();break;case"rejected":(q.status!=="error"||q.error!==se.reason)&&X();break}}return q}updateResult(){const s=ds(this,kh),r=this.createResult(ds(this,xo),this.options);if(qn(this,Vk,ds(this,xo).state),qn(this,Z5,this.options),ds(this,Vk).data!==void 0&&qn(this,X5,ds(this,xo)),Xre(r,s))return;qn(this,kh,r);const n=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!ds(this,Q5).size)return!0;const l=new Set(o??ds(this,Q5));return this.options.throwOnError&&l.add("error"),Object.keys(ds(this,kh)).some(i=>{const d=i;return ds(this,kh)[d]!==s[d]&&l.has(d)})};Bi(this,Uo,dFe).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Bi(this,Uo,Wfe).call(this)}},um=new WeakMap,xo=new WeakMap,eL=new WeakMap,kh=new WeakMap,Vk=new WeakMap,Z5=new WeakMap,S1=new WeakMap,C1=new WeakMap,tL=new WeakMap,Y5=new WeakMap,X5=new WeakMap,Hk=new WeakMap,Wk=new WeakMap,M1=new WeakMap,Q5=new WeakMap,Uo=new WeakSet,wE=function(s){Bi(this,Uo,Zfe).call(this);let r=ds(this,xo).fetch(this.options,s);return s!=null&&s.throwOnError||(r=r.catch(Sh)),r},Ufe=function(){Bi(this,Uo,Gfe).call(this);const s=l_(this.options.staleTime,ds(this,xo));if(NN||ds(this,kh).isStale||!Ffe(s))return;const n=QRe(ds(this,kh).dataUpdatedAt,s)+1;qn(this,Hk,setTimeout(()=>{ds(this,kh).isStale||this.updateResult()},n))},Vfe=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(ds(this,xo)):this.options.refetchInterval)??!1},Hfe=function(s){Bi(this,Uo,Kfe).call(this),qn(this,M1,s),!(NN||Gp(this.options.enabled,ds(this,xo))===!1||!Ffe(ds(this,M1))||ds(this,M1)===0)&&qn(this,Wk,setInterval(()=>{(this.options.refetchIntervalInBackground||d1e.isFocused())&&Bi(this,Uo,wE).call(this)},ds(this,M1)))},Wfe=function(){Bi(this,Uo,Ufe).call(this),Bi(this,Uo,Hfe).call(this,Bi(this,Uo,Vfe).call(this))},Gfe=function(){ds(this,Hk)&&(clearTimeout(ds(this,Hk)),qn(this,Hk,void 0))},Kfe=function(){ds(this,Wk)&&(clearInterval(ds(this,Wk)),qn(this,Wk,void 0))},Zfe=function(){const s=ds(this,um).getQueryCache().build(ds(this,um),this.options);if(s===ds(this,xo))return;const r=ds(this,xo);qn(this,xo,s),qn(this,eL,s.state),this.hasListeners()&&(r==null||r.removeObserver(this),s.addObserver(this))},dFe=function(s){Fd.batch(()=>{s.listeners&&this.listeners.forEach(r=>{r(ds(this,kh))}),ds(this,um).getQueryCache().notify({query:ds(this,xo),type:"observerResultsUpdated"})})},jDe);function Zdt(t,s){return Gp(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&s.retryOnMount===!1)}function _4e(t,s){return Zdt(t,s)||t.state.data!==void 0&&Yfe(t,s,s.refetchOnMount)}function Yfe(t,s,r){if(Gp(s.enabled,t)!==!1&&l_(s.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&u1e(t,s)}return!1}function b4e(t,s,r,n){return(t!==s||Gp(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&u1e(t,r)}function u1e(t,s){return Gp(s.enabled,t)!==!1&&t.isStaleByTime(l_(s.staleTime,t))}function Ydt(t,s){return!Xre(t.getCurrentResult(),s)}var Xdt=class extends cFe{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:Jre()})}getOptimisticResult(t){return t.behavior=Jre(),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,j;const{state:r}=t,n=super.createResult(t,s),{isFetching:a,isRefetching:o,isError:l,isRefetchError:i}=n,d=(j=(b=r.fetchMeta)==null?void 0:b.fetchMore)==null?void 0:j.direction,u=l&&d==="forward",p=a&&d==="forward",g=l&&d==="backward",v=a&&d==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Wdt(s,r.data),hasPreviousPage:Gdt(s,r.data),isFetchNextPageError:u,isFetchingNextPage:p,isFetchPreviousPageError:g,isFetchingPreviousPage:v,isRefetchError:i&&!u&&!g,isRefetching:o&&!p&&!v}}},T1,A1,hm,u0,B0,Zse,Xfe,kDe,Qdt=(kDe=class extends oM{constructor(r,n){super();Ba(this,B0);Ba(this,T1);Ba(this,A1);Ba(this,hm);Ba(this,u0);qn(this,T1,r),this.setOptions(n),this.bindMethods(),Bi(this,B0,Zse).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=ds(this,T1).defaultMutationOptions(r),Xre(this.options,n)||ds(this,T1).getMutationCache().notify({type:"observerOptionsUpdated",mutation:ds(this,hm),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&SN(n.mutationKey)!==SN(this.options.mutationKey)?this.reset():((a=ds(this,hm))==null?void 0:a.state.status)==="pending"&&ds(this,hm).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=ds(this,hm))==null||r.removeObserver(this)}onMutationUpdate(r){Bi(this,B0,Zse).call(this),Bi(this,B0,Xfe).call(this,r)}getCurrentResult(){return ds(this,A1)}reset(){var r;(r=ds(this,hm))==null||r.removeObserver(this),qn(this,hm,void 0),Bi(this,B0,Zse).call(this),Bi(this,B0,Xfe).call(this)}mutate(r,n){var a;return qn(this,u0,n),(a=ds(this,hm))==null||a.removeObserver(this),qn(this,hm,ds(this,T1).getMutationCache().build(ds(this,T1),this.options)),ds(this,hm).addObserver(this),ds(this,hm).execute(r)}},T1=new WeakMap,A1=new WeakMap,hm=new WeakMap,u0=new WeakMap,B0=new WeakSet,Zse=function(){var n;const r=((n=ds(this,hm))==null?void 0:n.state)??oFe();qn(this,A1,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},Xfe=function(r){Fd.batch(()=>{var n,a,o,l,i,d,u,p;if(ds(this,u0)&&this.hasListeners()){const g=ds(this,A1).variables,v=ds(this,A1).context;(r==null?void 0:r.type)==="success"?((a=(n=ds(this,u0)).onSuccess)==null||a.call(n,r.data,g,v),(l=(o=ds(this,u0)).onSettled)==null||l.call(o,r.data,null,g,v)):(r==null?void 0:r.type)==="error"&&((d=(i=ds(this,u0)).onError)==null||d.call(i,r.error,g,v),(p=(u=ds(this,u0)).onSettled)==null||p.call(u,void 0,r.error,g,v))}this.listeners.forEach(g=>{g(ds(this,A1))})})},kDe),uFe=S.createContext(void 0),ns=t=>{const s=S.useContext(uFe);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},Jdt=({client:t,children:s})=>(S.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(uFe.Provider,{value:t,children:s})),hFe=S.createContext(!1),eut=()=>S.useContext(hFe);hFe.Provider;function tut(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var sut=S.createContext(tut()),rut=()=>S.useContext(sut),nut=(t,s)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(s.isReset()||(t.retryOnMount=!1))},aut=t=>{S.useEffect(()=>{t.clearReset()},[t])},iut=({result:t,errorResetBoundary:s,throwOnError:r,query:n,suspense:a})=>t.isError&&!s.isReset()&&!t.isFetching&&n&&(a&&t.data===void 0||tFe(r,[t.error,n])),out=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))}},lut=(t,s)=>t.isLoading&&t.isFetching&&!s,cut=(t,s)=>(t==null?void 0:t.suspense)&&s.isPending,w4e=(t,s,r)=>s.fetchOptimistic(t).catch(()=>{r.clearReset()});function mFe(t,s,r){var g,v,_,b,j;const n=eut(),a=rut(),o=ns(),l=o.defaultQueryOptions(t);(v=(g=o.getDefaultOptions().queries)==null?void 0:g._experimental_beforeQuery)==null||v.call(g,l),l._optimisticResults=n?"isRestoring":"optimistic",out(l),nut(l,a),aut(a);const i=!o.getQueryCache().get(l.queryHash),[d]=S.useState(()=>new s(o,l)),u=d.getOptimisticResult(l),p=!n&&t.subscribed!==!1;if(S.useSyncExternalStore(S.useCallback(w=>{const N=p?d.subscribe(Fd.batchCalls(w)):Sh;return d.updateResult(),N},[d,p]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),S.useEffect(()=>{d.setOptions(l)},[l,d]),cut(l,u))throw w4e(l,d,a);if(iut({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&&!NN&&lut(u,n)){const w=i?w4e(l,d,a):(j=o.getQueryCache().get(l.queryHash))==null?void 0:j.promise;w==null||w.catch(Sh).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?u:d.trackResult(u)}function Ct(t,s){return mFe(t,cFe)}function Ot(t,s){const r=ns(),[n]=S.useState(()=>new Qdt(r,t));S.useEffect(()=>{n.setOptions(t)},[n,t]);const a=S.useSyncExternalStore(S.useCallback(l=>n.subscribe(Fd.batchCalls(l)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=S.useCallback((l,i)=>{n.mutate(l,i).catch(Sh)},[n]);if(a.error&&tFe(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function dut(t,s){return mFe(t,Xdt)}/** * @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 zI(){return zI=Object.assign?Object.assign.bind():function(t){for(var s=1;s"u")throw new Error(s)}function pFe(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function hut(){return Math.random().toString(36).substr(2,8)}function k4e(t,s){return{usr:t.state,key:t.key,idx:s}}function Qfe(t,s,r,n){return r===void 0&&(r=null),zI({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?lM(s):s,{state:r,key:s&&s.key||n||hut()})}function ene(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 lM(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 mut(t,s,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:o=!1}=n,l=a.history,i=L1.Pop,d=null,u=p();u==null&&(u=0,l.replaceState(zI({},l.state,{idx:u}),""));function p(){return(l.state||{idx:null}).idx}function g(){i=L1.Pop;let w=p(),N=w==null?null:w-u;u=w,d&&d({action:i,location:j.location,delta:N})}function v(w,N){i=L1.Push;let C=Qfe(j.location,w,N);u=p()+1;let A=k4e(C,u),I=j.createHref(C);try{l.pushState(A,"",I)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;a.location.assign(I)}o&&d&&d({action:i,location:j.location,delta:1})}function _(w,N){i=L1.Replace;let C=Qfe(j.location,w,N);u=p();let A=k4e(C,u),I=j.createHref(C);l.replaceState(A,"",I),o&&d&&d({action:i,location:j.location,delta:0})}function b(w){let N=a.location.origin!=="null"?a.location.origin:a.location.href,C=typeof w=="string"?w:ene(w);return C=C.replace(/ $/,"%20"),cd(N,"No window.location.(origin|href) available to create URL for href: "+C),new URL(C,N)}let j={get action(){return i},get location(){return t(a,l)},listen(w){if(d)throw new Error("A history only accepts one active listener");return a.addEventListener(j4e,g),d=w,()=>{a.removeEventListener(j4e,g),d=null}},createHref(w){return s(a,w)},createURL:b,encodeLocation(w){let N=b(w);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:v,replace:_,go(w){return l.go(w)}};return j}var N4e;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(N4e||(N4e={}));function put(t,s,r){return r===void 0&&(r="/"),fut(t,s,r)}function fut(t,s,r,n){let a=typeof s=="string"?lM(s):s,o=h1e(a.pathname||"/",r);if(o==null)return null;let l=fFe(t);gut(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=c_([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+'".')),fFe(o.children,s,p,u)),!(o.path==null&&!o.index)&&s.push({path:u,score:jut(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 gFe(o.path))a(o,l,d)}),s}function gFe(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=gFe(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 gut(t){t.sort((s,r)=>s.score!==r.score?r.score-s.score:kut(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const xut=/^:[\w-]+$/,yut=3,vut=2,_ut=1,but=10,wut=-2,S4e=t=>t==="*";function jut(t,s){let r=t.split("/"),n=r.length;return r.some(S4e)&&(n+=wut),s&&(n+=vut),r.filter(a=>!S4e(a)).reduce((a,o)=>a+(xut.test(o)?yut:o===""?_ut:but),n)}function kut(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 Nut(t,s,r){let{routesMeta:n}=t,a={},o="/",l=[];for(let i=0;i{let{paramName:v,isOptional:_}=p;if(v==="*"){let j=i[g]||"";l=o.slice(0,o.length-j.length).replace(/(.)\/+$/,"$1")}const b=i[g];return _&&!b?u[v]=void 0:u[v]=(b||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:l,pattern:t}}function Cut(t,s,r){s===void 0&&(s=!1),r===void 0&&(r=!0),pFe(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 Mut(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return pFe(!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 h1e(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 Tut(t,s){s===void 0&&(s="/");let{pathname:r,search:n="",hash:a=""}=typeof t=="string"?lM(t):t;return{pathname:r?r.startsWith("/")?r:Aut(r,s):s,search:Iut(n),hash:Lut(a)}}function Aut(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 dhe(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 Eut(t){return t.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function m1e(t,s){let r=Eut(t);return s?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function p1e(t,s,r,n){n===void 0&&(n=!1);let a;typeof t=="string"?a=lM(t):(a=zI({},t),cd(!a.pathname||!a.pathname.includes("?"),dhe("?","pathname","search",a)),cd(!a.pathname||!a.pathname.includes("#"),dhe("#","pathname","hash",a)),cd(!a.search||!a.search.includes("#"),dhe("#","search","hash",a)));let o=t===""||a.pathname==="",l=o?"/":a.pathname,i;if(l==null)i=r;else{let g=s.length-1;if(!n&&l.startsWith("..")){let v=l.split("/");for(;v[0]==="..";)v.shift(),g-=1;a.pathname=v.join("/")}i=g>=0?s[g]:"/"}let d=Tut(a,i),u=l&&l!=="/"&&l.endsWith("/"),p=(o||l===".")&&r.endsWith("/");return!d.pathname.endsWith("/")&&(u||p)&&(d.pathname+="/"),d}const c_=t=>t.join("/").replace(/\/\/+/g,"/"),Put=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Iut=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Lut=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function Dut(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const xFe=["post","put","patch","delete"];new Set(xFe);const Out=["get",...xFe];new Set(Out);/** * 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 BI(){return BI=Object.assign?Object.assign.bind():function(t){for(var s=1;s{i.current=!0}),S.useCallback(function(u,p){if(p===void 0&&(p={}),!i.current)return;if(typeof u=="number"){n.go(u);return}let g=p1e(u,JSON.parse(l),o,p.relative==="path");t==null&&s!=="/"&&(g.pathname=g.pathname==="/"?s:c_([s,g.pathname])),(p.replace?n.replace:n.push)(g,p.state,p)},[s,n,l,o,t])}const But=S.createContext(null);function $ut(t){let s=S.useContext(uy).outlet;return s&&S.createElement(But.Provider,{value:t},s)}function Co(){let{matches:t}=S.useContext(uy),s=t[t.length-1];return s?s.params:{}}function _Fe(t,s){let{relative:r}=s===void 0?{}:s,{future:n}=S.useContext(O_),{matches:a}=S.useContext(uy),{pathname:o}=xu(),l=JSON.stringify(m1e(a,n.v7_relativeSplatPath));return S.useMemo(()=>p1e(t,JSON.parse(l),o,r==="path"),[t,l,o,r])}function qut(t,s){return Uut(t,s)}function Uut(t,s,r,n){cM()||cd(!1);let{navigator:a}=S.useContext(O_),{matches:o}=S.useContext(uy),l=o[o.length-1],i=l?l.params:{};l&&l.pathname;let d=l?l.pathnameBase:"/";l&&l.route;let u=xu(),p;if(s){var g;let w=typeof s=="string"?lM(s):s;d==="/"||(g=w.pathname)!=null&&g.startsWith(d)||cd(!1),p=w}else p=u;let v=p.pathname||"/",_=v;if(d!=="/"){let w=d.replace(/^\//,"").split("/");_="/"+v.replace(/^\//,"").split("/").slice(w.length).join("/")}let b=put(t,{pathname:_}),j=Kut(b&&b.map(w=>Object.assign({},w,{params:Object.assign({},i,w.params),pathname:c_([d,a.encodeLocation?a.encodeLocation(w.pathname).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?d:c_([d,a.encodeLocation?a.encodeLocation(w.pathnameBase).pathname:w.pathnameBase])})),o,r,n);return s&&j?S.createElement(noe.Provider,{value:{location:BI({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:L1.Pop}},j):j}function Vut(){let t=Qut(),s=Dut(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 S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},s),r?S.createElement("pre",{style:a},r):null,null)}const Hut=S.createElement(Vut,null);class Wut extends S.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?S.createElement(uy.Provider,{value:this.props.routeContext},S.createElement(yFe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Gut(t){let{routeContext:s,match:r,children:n}=t,a=S.useContext(f1e);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),S.createElement(uy.Provider,{value:s},n)}function Kut(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(g=>g.route.id&&(i==null?void 0:i[g.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,g,v)=>{let _,b=!1,j=null,w=null;r&&(_=i&&g.route.id?i[g.route.id]:void 0,j=g.route.errorElement||Hut,d&&(u<0&&v===0?(eht("route-fallback"),b=!0,w=null):u===v&&(b=!0,w=g.route.hydrateFallbackElement||null)));let N=s.concat(l.slice(0,v+1)),C=()=>{let A;return _?A=j:b?A=w:g.route.Component?A=S.createElement(g.route.Component,null):g.route.element?A=g.route.element:A=p,S.createElement(Gut,{match:g,routeContext:{outlet:p,matches:N,isDataRoute:r!=null},children:A})};return r&&(g.route.ErrorBoundary||g.route.errorElement||v===0)?S.createElement(Wut,{location:r.location,revalidation:r.revalidation,component:j,error:_,children:C(),routeContext:{outlet:null,matches:N,isDataRoute:!0}}):C()},null)}var bFe=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(bFe||{}),wFe=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}(wFe||{});function Zut(t){let s=S.useContext(f1e);return s||cd(!1),s}function Yut(t){let s=S.useContext(Rut);return s||cd(!1),s}function Xut(t){let s=S.useContext(uy);return s||cd(!1),s}function jFe(t){let s=Xut(),r=s.matches[s.matches.length-1];return r.route.id||cd(!1),r.route.id}function Qut(){var t;let s=S.useContext(yFe),r=Yut(),n=jFe();return s!==void 0?s:(t=r.errors)==null?void 0:t[n]}function Jut(){let{router:t}=Zut(bFe.UseNavigateStable),s=jFe(wFe.UseNavigateStable),r=S.useRef(!1);return vFe(()=>{r.current=!0}),S.useCallback(function(a,o){o===void 0&&(o={}),r.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,BI({fromRouteId:s},o)))},[t,s])}const C4e={};function eht(t,s,r){C4e[t]||(C4e[t]=!0)}function tht(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function uhe(t){let{to:s,replace:r,state:n,relative:a}=t;cM()||cd(!1);let{future:o,static:l}=S.useContext(O_),{matches:i}=S.useContext(uy),{pathname:d}=xu(),u=Lr(),p=p1e(s,m1e(i,o.v7_relativeSplatPath),d,a==="path"),g=JSON.stringify(p);return S.useEffect(()=>u(JSON.parse(g),{replace:r,state:n,relative:a}),[u,g,a,r,n]),null}function sht(t){return $ut(t.context)}function Hs(t){cd(!1)}function rht(t){let{basename:s="/",children:r=null,location:n,navigationType:a=L1.Pop,navigator:o,static:l=!1,future:i}=t;cM()&&cd(!1);let d=s.replace(/^\/*/,"/"),u=S.useMemo(()=>({basename:d,navigator:o,static:l,future:BI({v7_relativeSplatPath:!1},i)}),[d,i,o,l]);typeof n=="string"&&(n=lM(n));let{pathname:p="/",search:g="",hash:v="",state:_=null,key:b="default"}=n,j=S.useMemo(()=>{let w=h1e(p,d);return w==null?null:{location:{pathname:w,search:g,hash:v,state:_,key:b},navigationType:a}},[d,p,g,v,_,b,a]);return j==null?null:S.createElement(O_.Provider,{value:u},S.createElement(noe.Provider,{children:r,value:j}))}function kFe(t){let{children:s,location:r}=t;return qut(Jfe(s),r)}new Promise(()=>{});function Jfe(t,s){s===void 0&&(s=[]);let r=[];return S.Children.forEach(t,(n,a)=>{if(!S.isValidElement(n))return;let o=[...s,a];if(n.type===S.Fragment){r.push.apply(r,Jfe(n.props.children,o));return}n.type!==Hs&&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=Jfe(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 ege(){return ege=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&(r[a]=t[a]);return r}function aht(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function iht(t,s){return t.button===0&&(!s||s==="_self")&&!aht(t)}function tge(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 oht(t,s){let r=tge(t);return s&&s.forEach((n,a)=>{r.has(a)||s.getAll(a).forEach(o=>{r.append(a,o)})}),r}const lht=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],cht="6";try{window.__reactRouterVersion=cht}catch{}const dht="startTransition",M4e=J0e[dht];function uht(t){let{basename:s,children:r,future:n,window:a}=t,o=S.useRef();o.current==null&&(o.current=uut({window:a,v5Compat:!0}));let l=o.current,[i,d]=S.useState({action:l.action,location:l.location}),{v7_startTransition:u}=n||{},p=S.useCallback(g=>{u&&M4e?M4e(()=>d(g)):d(g)},[d,u]);return S.useLayoutEffect(()=>l.listen(p),[l,p]),S.useEffect(()=>tht(n),[n]),S.createElement(rht,{basename:s,children:r,location:i.location,navigationType:i.action,navigator:l,future:n})}const hht=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",mht=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,vo=S.forwardRef(function(s,r){let{onClick:n,relative:a,reloadDocument:o,replace:l,state:i,target:d,to:u,preventScrollReset:p,viewTransition:g}=s,v=nht(s,lht),{basename:_}=S.useContext(O_),b,j=!1;if(typeof u=="string"&&mht.test(u)&&(b=u,hht))try{let A=new URL(window.location.href),I=u.startsWith("//")?new URL(A.protocol+u):new URL(u),L=h1e(I.pathname,_);I.origin===A.origin&&L!=null?u=L+I.search+I.hash:j=!0}catch{}let w=Fut(u,{relative:a}),N=pht(u,{replace:l,state:i,target:d,preventScrollReset:p,relative:a,viewTransition:g});function C(A){n&&n(A),A.defaultPrevented||N(A)}return S.createElement("a",ege({},v,{href:b||w,onClick:j||o?n:C,ref:r,target:d}))});var T4e;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(T4e||(T4e={}));var A4e;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(A4e||(A4e={}));function pht(t,s){let{target:r,replace:n,state:a,preventScrollReset:o,relative:l,viewTransition:i}=s===void 0?{}:s,d=Lr(),u=xu(),p=_Fe(t,{relative:l});return S.useCallback(g=>{if(iht(g,r)){g.preventDefault();let v=n!==void 0?n:ene(u)===ene(p);d(t,{replace:v,state:a,preventScrollReset:o,relative:l,viewTransition:i})}},[u,d,p,n,a,r,t,o,l,i])}function Ac(t){let s=S.useRef(tge(t)),r=S.useRef(!1),n=xu(),a=S.useMemo(()=>oht(n.search,r.current?null:s.current),[n.search]),o=Lr(),l=S.useCallback((i,d)=>{const u=tge(typeof i=="function"?i(a):i);r.current=!0,o("?"+u,d)},[o,a]);return[a,l]}var fht=typeof Element<"u",ght=typeof Map=="function",xht=typeof Set=="function",yht=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function Yse(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(!Yse(t[n],s[n]))return!1;return!0}var o;if(ght&&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(!Yse(n.value[1],s.get(n.value[0])))return!1;return!0}if(xht&&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(yht&&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(fht&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((a[n]==="_owner"||a[n]==="__v"||a[n]==="__o")&&t.$$typeof)&&!Yse(t[a[n]],s[a[n]]))return!1;return!0}return t!==t&&s!==s}var vht=function(s,r){try{return Yse(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(vht);var bht=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}},wht=bht;const E4e=_o(wht);var jht=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))(NFe||{}),hhe={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"]}},P4e=Object.values(NFe),g1e={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},Nht=Object.entries(g1e).reduce((t,[s,r])=>(t[r]=s,t),{}),Eg="data-rh",S5={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},C5=(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},Sht=t=>{let s=C5(t,"title");const r=C5(t,S5.TITLE_TEMPLATE);if(Array.isArray(s)&&(s=s.join("")),r&&s)return r.replace(/%s/g,()=>s);const n=C5(t,S5.DEFAULT_TITLE);return s||n||void 0},Cht=t=>C5(t,S5.ON_CHANGE_CLIENT_STATE)||(()=>{}),mhe=(t,s)=>s.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),Mht=(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),HA=(t,s,r)=>{const n={};return r.filter(a=>Array.isArray(a[t])?!0:(typeof a[t]<"u"&&Tht(`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 v=0;va.push(d));const i=Object.keys(l);for(let d=0;d{if(Array.isArray(t)&&t.length){for(let r=0;r({baseTag:Mht(["href"],t),bodyAttributes:mhe("bodyAttributes",t),defer:C5(t,S5.DEFER),encode:C5(t,S5.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:mhe("htmlAttributes",t),linkTags:HA("link",["rel","href"],t),metaTags:HA("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:HA("noscript",["innerHTML"],t),onChangeClientState:Cht(t),scriptTags:HA("script",["src","innerHTML"],t),styleTags:HA("style",["cssText"],t),title:Sht(t),titleAttributes:mhe("titleAttributes",t),prioritizeSeoTags:Aht(t,S5.PRIORITIZE_SEO_TAGS)}),SFe=t=>Array.isArray(t)?t.join(""):t,Pht=(t,s)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(Pht(n,s)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},I4e=(t,s)=>({...t,[s]:void 0}),Iht=["noscript","script","style"],sge=(t,s=!0)=>s===!1?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),CFe=t=>Object.keys(t).reduce((s,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return s?`${s} ${n}`:n},""),Lht=(t,s,r,n)=>{const a=CFe(r),o=SFe(s);return a?`<${t} ${Eg}="true" ${a}>${sge(o,n)}`:`<${t} ${Eg}="true">${sge(o,n)}`},Dht=(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 g=typeof o[p]>"u"?p:`${p}="${sge(o[p],r)}"`;return u?`${u} ${g}`:g},""),i=o.innerHTML||o.cssText||"",d=Iht.indexOf(t)===-1;return`${n}<${t} ${Eg}="true" ${l}${d?"/>":`>${i}`}`},""),MFe=(t,s={})=>Object.keys(t).reduce((r,n)=>{const a=g1e[n];return r[a||n]=t[n],r},s),Oht=(t,s,r)=>{const n={key:s,[Eg]:!0},a=MFe(r,n);return[ht.createElement("title",a,s)]},Xse=(t,s)=>s.map((r,n)=>{const a={key:n,[Eg]:!0};return Object.keys(r).forEach(o=>{const i=g1e[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)}),Hp=(t,s,r=!0)=>{switch(t){case"title":return{toComponent:()=>Oht(t,s.title,s.titleAttributes),toString:()=>Lht(t,s.title,s.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>MFe(s),toString:()=>CFe(s)};default:return{toComponent:()=>Xse(t,s),toString:()=>Dht(t,s,r)}}},Rht=({metaTags:t,linkTags:s,scriptTags:r,encode:n})=>{const a=phe(t,hhe.meta),o=phe(s,hhe.link),l=phe(r,hhe.script);return{priorityMethods:{toComponent:()=>[...Xse("meta",a.priority),...Xse("link",o.priority),...Xse("script",l.priority)],toString:()=>`${Hp("meta",a.priority,n)} ${Hp("link",o.priority,n)} ${Hp("script",l.priority,n)}`},metaTags:a.default,linkTags:o.default,scriptTags:l.default}},Fht=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:g,scriptTags:v}=t,_={toComponent:()=>{},toString:()=>""};return u&&({priorityMethods:_,linkTags:p,metaTags:g,scriptTags:v}=Rht(t)),{priority:_,base:Hp("base",s,n),bodyAttributes:Hp("bodyAttributes",r,n),htmlAttributes:Hp("htmlAttributes",a,n),link:Hp("link",p,n),meta:Hp("meta",g,n),noscript:Hp("noscript",o,n),script:Hp("script",v,n),style:Hp("style",l,n),title:Hp("title",{title:i,titleAttributes:d},n)}},rge=Fht,y8=[],TFe=!!(typeof window<"u"&&window.document&&window.document.createElement),nge=class{constructor(t,s){_n(this,"instances",[]);_n(this,"canUseDOM",TFe);_n(this,"context");_n(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?y8:this.instances,add:t=>{(this.canUseDOM?y8:this.instances).push(t)},remove:t=>{const s=(this.canUseDOM?y8:this.instances).indexOf(t);(this.canUseDOM?y8:this.instances).splice(s,1)}}});this.context=t,this.canUseDOM=s||!1,s||(t.helmet=rge({baseTag:[],bodyAttributes:{},htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},zht={},AFe=ht.createContext(zht),Gk,EFe=(Gk=class extends S.Component{constructor(r){super(r);_n(this,"helmetData");this.helmetData=new nge(this.props.context||{},Gk.canUseDOM)}render(){return ht.createElement(AFe.Provider,{value:this.helmetData.value},this.props.children)}},_n(Gk,"canUseDOM",TFe),Gk),VC=(t,s)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${Eg}]`),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,g=typeof i[p]>"u"?"":i[p];d.setAttribute(u,g)}d.setAttribute(Eg,"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}},age=(t,s)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(Eg),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(Eg):r.getAttribute(Eg)!==l.join(",")&&r.setAttribute(Eg,l.join(","))},Bht=(t,s)=>{typeof t<"u"&&document.title!==t&&(document.title=SFe(t)),age("title",s)},L4e=(t,s)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:a,linkTags:o,metaTags:l,noscriptTags:i,onChangeClientState:d,scriptTags:u,styleTags:p,title:g,titleAttributes:v}=t;age("body",n),age("html",a),Bht(g,v);const _={baseTag:VC("base",r),linkTags:VC("link",o),metaTags:VC("meta",l),noscriptTags:VC("noscript",i),scriptTags:VC("script",u),styleTags:VC("style",p)},b={},j={};Object.keys(_).forEach(w=>{const{newTags:N,oldTags:C}=_[w];N.length&&(b[w]=N),C.length&&(j[w]=_[w].oldTags)}),s&&s(),d(t,b,j)},WA=null,$ht=t=>{WA&&cancelAnimationFrame(WA),t.defer?WA=requestAnimationFrame(()=>{L4e(t,()=>{WA=null})}):(L4e(t),WA=null)},qht=$ht,D4e=class extends S.Component{constructor(){super(...arguments);_n(this,"rendered",!1)}shouldComponentUpdate(s){return!kht(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=Eht(s.get().map(o=>{const l={...o.props};return delete l.context,l}));EFe.canUseDOM?qht(a):rge&&(n=rge(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}},Lpe,nh=(Lpe=class extends S.Component{shouldComponentUpdate(t){return!_ht(I4e(this.props,"helmetData"),I4e(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 E4e(P4e.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 ${P4e.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),E4e(!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[Nht[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 nge)){const a=n;n=new nge(a.context,!0),delete r.helmetData}return n?ht.createElement(D4e,{...r,context:n.value}):ht.createElement(AFe.Consumer,null,a=>ht.createElement(D4e,{...r,context:a}))}},_n(Lpe,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),Lpe),ige=function(t,s){return ige=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])},ige(t,s)};function PFe(t,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");ige(t,s);function r(){this.constructor=t}t.prototype=s===null?Object.create(s):(r.prototype=s.prototype,new r)}var tf=function(){return tf=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 LFe(t,s){return function(r,n){s(r,n,t)}}function DFe(t,s,r,n,a,o){function l(N){if(N!==void 0&&typeof N!="function")throw new TypeError("Function expected");return N}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):{}),g,v=!1,_=r.length-1;_>=0;_--){var b={};for(var j in n)b[j]=j==="access"?{}:n[j];for(var j in n.access)b.access[j]=n.access[j];b.addInitializer=function(N){if(v)throw new TypeError("Cannot add initializers after decoration has completed");o.push(l(N||null))};var w=(0,r[_])(i==="accessor"?{get:p.get,set:p.set}:p[d],b);if(i==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(g=l(w.get))&&(p.get=g),(g=l(w.set))&&(p.set=g),(g=l(w.init))&&a.unshift(g)}else(g=l(w))&&(i==="field"?a.unshift(g):p[d]=g)}u&&Object.defineProperty(u,n.name,p),v=!0}function OFe(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 x1e(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 qFe(){for(var t=[],s=0;s1||d(_,j)})},b&&(a[_]=b(a[_])))}function d(_,b){try{u(n[_](b))}catch(j){v(o[0][3],j)}}function u(_){_.value instanceof l3?Promise.resolve(_.value.v).then(p,g):v(o[0][2],_)}function p(_){d("next",_)}function g(_){d("throw",_)}function v(_,b){_(b),o.shift(),o.length&&d(o[0][0],o[0][1])}}function HFe(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:l3(t[a](l)),done:!1}:o?o(l):l}:o}}function WFe(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 tne=="function"?tne(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 GFe(t,s){return Object.defineProperty?Object.defineProperty(t,"raw",{value:s}):t.raw=s,t}var Uht=Object.create?function(t,s){Object.defineProperty(t,"default",{enumerable:!0,value:s})}:function(t,s){t.default=s},oge=function(t){return oge=Object.getOwnPropertyNames||function(s){var r=[];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[r.length]=n);return r},oge(t)};function KFe(t){if(t&&t.__esModule)return t;var s={};if(t!=null)for(var r=oge(t),n=0;n{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>ev(async()=>{const{default:n}=await Promise.resolve().then(()=>XN);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)};class v1e extends Error{constructor(s,r="FunctionsError",n){super(s),this.name=r,this.context=n}}class O4e extends v1e{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class R4e extends v1e{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class F4e extends v1e{constructor(s){super("Edge Function returned a non-2xx status code","FunctionsHttpError",s)}}var lge;(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"})(lge||(lge={}));class Kht{constructor(s,{headers:r={},customFetch:n,region:a=lge.Any}={}){this.url=s,this.headers=r,this.region=a,this.fetch=Ght(n)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s){return oa(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 g=new URL(`${this.url}/${r}`);p&&p!=="any"&&(u["x-region"]=p,g.searchParams.set("forceFunctionRegion",p));let v;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",v=i):typeof i=="string"?(u["Content-Type"]="text/plain",v=i):typeof FormData<"u"&&i instanceof FormData?v=i:(u["Content-Type"]="application/json",v=JSON.stringify(i)):v=i;const _=yield this.fetch(g.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},u),this.headers),o),body:v,signal:d}).catch(N=>{throw N.name==="AbortError"?N:new O4e(N)}),b=_.headers.get("x-relay-error");if(b&&b==="true")throw new R4e(_);if(!_.ok)throw new F4e(_);let j=((a=_.headers.get("Content-Type"))!==null&&a!==void 0?a:"text/plain").split(";")[0].trim(),w;return j==="application/json"?w=yield _.json():j==="application/octet-stream"||j==="application/pdf"?w=yield _.blob():j==="text/event-stream"?w=_:j==="multipart/form-data"?w=yield _.formData():w=yield _.text(),{data:w,error:null,response:_}}catch(o){return o instanceof Error&&o.name==="AbortError"?{data:null,error:new O4e(o)}:{data:null,error:o,response:o instanceof F4e||o instanceof R4e?o.context:void 0}}})}}var xm={};const dM=NDe(Wht);var v8={},_8={},b8={},w8={},j8={},Zht=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")},c3=Zht();const Yht=c3.fetch,sze=c3.fetch.bind(c3),rze=c3.Headers,Xht=c3.Request,Qht=c3.Response,XN=Object.freeze(Object.defineProperty({__proto__:null,Headers:rze,Request:Xht,Response:Qht,default:sze,fetch:Yht},Symbol.toStringTag,{value:"Module"})),Jht=NDe(XN);var k8={},z4e;function nze(){if(z4e)return k8;z4e=1,Object.defineProperty(k8,"__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 k8.default=t,k8}var B4e;function aze(){if(B4e)return j8;B4e=1,Object.defineProperty(j8,"__esModule",{value:!0});const t=dM,s=t.__importDefault(Jht),r=t.__importDefault(nze());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,g,v,_;let b=null,j=null,w=null,N=u.status,C=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"))?j=R:j=JSON.parse(R))}const I=(g=this.headers.get("Prefer"))===null||g===void 0?void 0:g.match(/count=(exact|planned|estimated)/),L=(v=u.headers.get("content-range"))===null||v===void 0?void 0:v.split("/");I&&L&&L.length>1&&(w=parseInt(L[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(j)&&(j.length>1?(b={code:"PGRST116",details:`Results contain ${j.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},j=null,w=null,N=406,C="Not Acceptable"):j.length===1?j=j[0]:j=null)}else{const I=await u.text();try{b=JSON.parse(I),Array.isArray(b)&&u.status===404&&(j=[],b=null,N=200,C="OK")}catch{u.status===404&&I===""?(N=204,C="No Content"):b={message:I}}if(b&&this.isMaybeSingle&&(!((_=b==null?void 0:b.details)===null||_===void 0)&&_.includes("0 rows"))&&(b=null,N=200,C="OK"),b&&this.shouldThrowOnError)throw new r.default(b)}return{error:b,data:j,count:w,status:N,statusText:C}});return this.shouldThrowOnError||(d=d.catch(u=>{var p,g,v;return{error:{message:`${(p=u==null?void 0:u.name)!==null&&p!==void 0?p:"FetchError"}: ${u==null?void 0:u.message}`,details:`${(g=u==null?void 0:u.stack)!==null&&g!==void 0?g:""}`,hint:"",code:`${(v=u==null?void 0:u.code)!==null&&v!==void 0?v:""}`},data:null,count:null,status:0,statusText:""}})),d.then(o,l)}returns(){return this}overrideTypes(){return this}}return j8.default=n,j8}var $4e;function ize(){if($4e)return w8;$4e=1,Object.defineProperty(w8,"__esModule",{value:!0});const s=dM.__importDefault(aze());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 g=[a?"analyze":null,o?"verbose":null,l?"settings":null,i?"buffers":null,d?"wal":null].filter(Boolean).join("|"),v=(p=this.headers.get("Accept"))!==null&&p!==void 0?p:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${u}; for="${v}"; options=${g};`),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 w8.default=r,w8}var q4e;function _1e(){if(q4e)return b8;q4e=1,Object.defineProperty(b8,"__esModule",{value:!0});const s=dM.__importDefault(ize()),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 b8.default=n,b8}var U4e;function oze(){if(U4e)return _8;U4e=1,Object.defineProperty(_8,"__esModule",{value:!0});const s=dM.__importDefault(_1e());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(g=>/\s/.test(g)&&!u?"":(g==='"'&&(u=!u),g)).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,g)=>p.concat(Object.keys(g)),[]);if(u.length>0){const p=[...new Set(u)].map(g=>`"${g}"`);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 g=a.reduce((v,_)=>v.concat(Object.keys(_)),[]);if(g.length>0){const v=[...new Set(g)].map(_=>`"${_}"`);this.url.searchParams.set("columns",v.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 _8.default=r,_8}var V4e;function emt(){if(V4e)return v8;V4e=1,Object.defineProperty(v8,"__esModule",{value:!0});const t=dM,s=t.__importDefault(oze()),r=t.__importDefault(_1e());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 g;const v=new URL(`${this.url}/rpc/${o}`);let _;i||d?(g=i?"HEAD":"GET",Object.entries(l).filter(([j,w])=>w!==void 0).map(([j,w])=>[j,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([j,w])=>{v.searchParams.append(j,w)})):(g="POST",_=l);const b=new Headers(this.headers);return u&&b.set("Prefer",`count=${u}`),new r.default({method:g,url:v,headers:b,schema:this.schemaName,body:_,fetch:(p=this.fetch)!==null&&p!==void 0?p:fetch})}}return v8.default=n,v8}Object.defineProperty(xm,"__esModule",{value:!0});var lze=xm.PostgrestError=yze=xm.PostgrestBuilder=gze=xm.PostgrestTransformBuilder=pze=xm.PostgrestFilterBuilder=hze=xm.PostgrestQueryBuilder=dze=xm.PostgrestClient=void 0;const uM=dM,cze=uM.__importDefault(emt());var dze=xm.PostgrestClient=cze.default;const uze=uM.__importDefault(oze());var hze=xm.PostgrestQueryBuilder=uze.default;const mze=uM.__importDefault(_1e());var pze=xm.PostgrestFilterBuilder=mze.default;const fze=uM.__importDefault(ize());var gze=xm.PostgrestTransformBuilder=fze.default;const xze=uM.__importDefault(aze());var yze=xm.PostgrestBuilder=xze.default;const vze=uM.__importDefault(nze());lze=xm.PostgrestError=vze.default;var _ze=xm.default={PostgrestClient:cze.default,PostgrestQueryBuilder:uze.default,PostgrestFilterBuilder:mze.default,PostgrestTransformBuilder:fze.default,PostgrestBuilder:xze.default,PostgrestError:vze.default};const tmt=Object.freeze(Object.defineProperty({__proto__:null,get PostgrestBuilder(){return yze},get PostgrestClient(){return dze},get PostgrestError(){return lze},get PostgrestFilterBuilder(){return pze},get PostgrestQueryBuilder(){return hze},get PostgrestTransformBuilder(){return gze},default:_ze},Symbol.toStringTag,{value:"Module"})),{PostgrestClient:smt,PostgrestQueryBuilder:M1s,PostgrestFilterBuilder:T1s,PostgrestTransformBuilder:A1s,PostgrestBuilder:E1s,PostgrestError:P1s}=_ze||tmt;class rmt{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 nmt="2.78.0",amt=`realtime-js/${nmt}`,imt="1.0.0",cge=1e4,omt=1e3,lmt=100;var FP;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(FP||(FP={}));var Id;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(Id||(Id={}));var bg;(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"})(bg||(bg={}));var dge;(function(t){t.websocket="websocket"})(dge||(dge={}));var gk;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(gk||(gk={}));class cmt{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 kl;(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"})(kl||(kl={}));const H4e=(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]=dmt(l,t,s,a),o),{}):{}},dmt=(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)?wze(o,l):uge(l)},wze=(t,s)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return pmt(s,r)}switch(t){case kl.bool:return umt(s);case kl.float4:case kl.float8:case kl.int2:case kl.int4:case kl.int8:case kl.numeric:case kl.oid:return hmt(s);case kl.json:case kl.jsonb:return mmt(s);case kl.timestamp:return fmt(s);case kl.abstime:case kl.date:case kl.daterange:case kl.int4range:case kl.int8range:case kl.money:case kl.reltime:case kl.text:case kl.time:case kl.timestamptz:case kl.timetz:case kl.tsrange:case kl.tstzrange:return uge(s);default:return uge(s)}},uge=t=>t,umt=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},hmt=t=>{if(typeof t=="string"){const s=parseFloat(t);if(!Number.isNaN(s))return s}return t},mmt=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(s){return console.log(`JSON parse error: ${s}`),t}return t},pmt=(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=>wze(s,i))}return t},fmt=t=>typeof t=="string"?t.replace(" ","T"):t,jze=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 fhe{constructor(s,r,n={},a=cge){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 W4e;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(W4e||(W4e={}));class zP{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=zP.syncState(this.state,a,o,l),this.pendingDiffs.forEach(d=>{this.state=zP.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=zP.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 g=o[u];if(g){const v=p.map(w=>w.presence_ref),_=g.map(w=>w.presence_ref),b=p.filter(w=>_.indexOf(w.presence_ref)<0),j=g.filter(w=>v.indexOf(w.presence_ref)<0);b.length>0&&(i[u]=b),j.length>0&&(d[u]=j)}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 g=s[i].map(_=>_.presence_ref),v=p.filter(_=>g.indexOf(_.presence_ref)<0);s[i].unshift(...v)}n(i,p,d)}),this.map(l,(i,d)=>{let u=s[i];if(!u)return;const p=d.map(g=>g.presence_ref);u=u.filter(g=>p.indexOf(g.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 G4e;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(G4e||(G4e={}));var BP;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(BP||(BP={}));var e0;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(e0||(e0={}));class b1e{constructor(s,r={config:{}},n){var a,o;if(this.topic=s,this.params=r,this.socket=n,this.bindings={},this.state=Id.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 fhe(this,bg.join,this.params,this.timeout),this.rejoinTimer=new bze(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Id.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=Id.closed,this.socket._remove(this)}),this._onError(l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=Id.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Id.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=Id.errored,this.rejoinTimer.scheduleTimeout())}),this._on(bg.reply,{},(l,i)=>{this._trigger(this._replyEventName(i),l)}),this.presence=new zP(this),this.broadcastEndpointURL=jze(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==Id.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[BP.PRESENCE]&&this.bindings[BP.PRESENCE].length>0||((o=this.params.config.presence)===null||o===void 0?void 0:o.enabled)===!0,g={},v={broadcast:l,presence:Object.assign(Object.assign({},i),{enabled:p}),postgres_changes:u,private:d};this.socket.accessTokenValue&&(g.access_token=this.socket.accessTokenValue),this._onError(_=>s==null?void 0:s(e0.CHANNEL_ERROR,_)),this._onClose(()=>s==null?void 0:s(e0.CLOSED)),this.updateJoinPayload(Object.assign({config:v},g)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:_})=>{var b;if(this.socket.setAuth(),_===void 0){s==null||s(e0.SUBSCRIBED);return}else{const j=this.bindings.postgres_changes,w=(b=j==null?void 0:j.length)!==null&&b!==void 0?b:0,N=[];for(let C=0;C{this.state=Id.errored,s==null||s(e0.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(_).join(", ")||"error")))}).receive("timeout",()=>{s==null||s(e0.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===Id.joined&&s===BP.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=Id.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(bg.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(a=>{n=new fhe(this,bg.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=Id.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 fhe(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>lmt){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}=bg;if(n&&[i,d,u,p].indexOf(l)>=0&&n!==this._joinRef())return;let v=this._onMessage(l,r,n);if(r&&!v)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,j,w;return((b=_.filter)===null||b===void 0?void 0:b.event)==="*"||((w=(j=_.filter)===null||j===void 0?void 0:j.event)===null||w===void 0?void 0:w.toLocaleLowerCase())===l}).map(_=>_.callback(v,n)):(o=this.bindings[l])===null||o===void 0||o.filter(_=>{var b,j,w,N,C,A;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&&((j=r.ids)===null||j===void 0?void 0:j.includes(I))&&(L==="*"||(L==null?void 0:L.toLocaleLowerCase())===((w=r.data)===null||w===void 0?void 0:w.type.toLocaleLowerCase()))}else{const I=(C=(N=_==null?void 0:_.filter)===null||N===void 0?void 0:N.event)===null||C===void 0?void 0:C.toLocaleLowerCase();return I==="*"||I===((A=r==null?void 0:r.event)===null||A===void 0?void 0:A.toLocaleLowerCase())}else return _.type.toLocaleLowerCase()===l}).map(_=>{if(typeof v=="object"&&"ids"in v){const b=v.data,{schema:j,table:w,commit_timestamp:N,type:C,errors:A}=b;v=Object.assign(Object.assign({},{schema:j,table:w,commit_timestamp:N,eventType:C,new:{},old:{},errors:A}),this._getPayloadRecords(b))}_.callback(v,n)})}_isClosed(){return this.state===Id.closed}_isJoined(){return this.state===Id.joined}_isJoining(){return this.state===Id.joining}_isLeaving(){return this.state===Id.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&&b1e.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(bg.close,{},s)}_onError(s){this._on(bg.error,{},r=>s(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(s=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Id.joining,this.joinPush.resend(s))}_getPayloadRecords(s){const r={new:{},old:{}};return(s.type==="INSERT"||s.type==="UPDATE")&&(r.new=H4e(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(r.old=H4e(s.columns,s.old_record)),r}}const ghe=()=>{},N8={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},gmt=[1e3,2e3,5e3,1e4],xmt=1e4,ymt=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class vmt{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=cge,this.transport=null,this.heartbeatIntervalMs=N8.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=ghe,this.ref=0,this.reconnectTimer=null,this.logger=ghe,this.conn=null,this.sendBuffer=[],this.serializer=new cmt,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)=>ev(async()=>{const{default:i}=await Promise.resolve().then(()=>XN);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}/${dge.websocket}`,this.httpEndpoint=jze(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=rmt.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:imt}))}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 FP.connecting:return gk.Connecting;case FP.open:return gk.Open;case FP.closing:return gk.Closing;default:return gk.Closed}}isConnected(){return this.connectionState()===gk.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 b1e(`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(omt,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout()},N8.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(bg.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([ymt],{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:amt};r&&n.updateJoinPayload(a),n.joinedOnce&&n._isJoined()&&n._push(bg.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()},N8.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:cge,this.heartbeatIntervalMs=(a=s==null?void 0:s.heartbeatIntervalMs)!==null&&a!==void 0?a:N8.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:ghe,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:g=>gmt[g-1]||xmt,this.encode=(u=s==null?void 0:s.encode)!==null&&u!==void 0?u:(g,v)=>v(JSON.stringify(g)),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 w1e extends Error{constructor(s){super(s),this.__isStorageError=!0,this.name="StorageError"}}function _c(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class _mt extends w1e{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 hge extends w1e{constructor(s,r){super(s),this.name="StorageUnknownError",this.originalError=r}}const j1e=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>ev(async()=>{const{default:n}=await Promise.resolve().then(()=>XN);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},bmt=()=>oa(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield ev(()=>Promise.resolve().then(()=>XN),void 0)).Response:Response}),mge=t=>{if(Array.isArray(t))return t.map(r=>mge(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]=mge(n)}),s},wmt=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)},xhe=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)},jmt=(t,s,r)=>oa(void 0,void 0,void 0,function*(){const n=yield bmt();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(xhe(a),o,l))}).catch(a=>{s(new hge(xhe(a),a))}):s(new hge(xhe(t),t))}),kmt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"||!n?a:(wmt(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 pL(t,s,r,n,a,o){return oa(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,kmt(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=>jmt(d,i,n))})})}function $I(t,s,r,n){return oa(this,void 0,void 0,function*(){return pL(t,"GET",s,r,n)})}function xg(t,s,r,n,a){return oa(this,void 0,void 0,function*(){return pL(t,"POST",s,n,a,r)})}function pge(t,s,r,n,a){return oa(this,void 0,void 0,function*(){return pL(t,"PUT",s,n,a,r)})}function Nmt(t,s,r,n){return oa(this,void 0,void 0,function*(){return pL(t,"HEAD",s,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function k1e(t,s,r,n,a){return oa(this,void 0,void 0,function*(){return pL(t,"DELETE",s,n,a,r)})}class Smt{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r}then(s,r){return this.execute().then(s,r)}execute(){return oa(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(_c(s))return{data:null,error:s};throw s}})}}var kze;class Cmt{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r,this[kze]="BlobDownloadBuilder",this.promise=null}asStream(){return new Smt(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 oa(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(_c(s))return{data:null,error:s};throw s}})}}kze=Symbol.toStringTag;const Mmt={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},K4e={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class Tmt{constructor(s,r={},n,a){this.shouldThrowOnError=!1,this.url=s,this.headers=r,this.bucketId=n,this.fetch=j1e(a)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(s,r,n,a){return oa(this,void 0,void 0,function*(){try{let o;const l=Object.assign(Object.assign({},K4e),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),g=yield(s=="PUT"?pge:xg)(this.fetch,`${this.url}/object/${p}`,o,Object.assign({headers:i},l!=null&&l.duplex?{duplex:l.duplex}:{}));return{data:{path:u,id:g.Id,fullPath:g.Key},error:null}}catch(o){if(this.shouldThrowOnError)throw o;if(_c(o))return{data:null,error:o};throw o}})}upload(s,r,n){return oa(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",s,r,n)})}uploadToSignedUrl(s,r,n,a){return oa(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:K4e.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 g=yield pge(this.fetch,i.toString(),d,{headers:p});return{data:{path:o,fullPath:g.Key},error:null}}catch(d){if(this.shouldThrowOnError)throw d;if(_c(d))return{data:null,error:d};throw d}})}createSignedUploadUrl(s,r){return oa(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 xg(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 w1e("No token returned by API");return{data:{signedUrl:l.toString(),path:s,token:i},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(_c(n))return{data:null,error:n};throw n}})}update(s,r,n){return oa(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",s,r,n)})}move(s,r,n){return oa(this,void 0,void 0,function*(){try{return{data:yield xg(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(_c(a))return{data:null,error:a};throw a}})}copy(s,r,n){return oa(this,void 0,void 0,function*(){try{return{data:{path:(yield xg(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(_c(a))return{data:null,error:a};throw a}})}createSignedUrl(s,r,n){return oa(this,void 0,void 0,function*(){try{let a=this._getFinalPath(s),o=yield xg(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(_c(a))return{data:null,error:a};throw a}})}createSignedUrls(s,r,n){return oa(this,void 0,void 0,function*(){try{const a=yield xg(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(_c(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=()=>$I(this.fetch,`${this.url}/${a}/${i}${l}`,{headers:this.headers,noResolveJson:!0});return new Cmt(d,this.shouldThrowOnError)}info(s){return oa(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{const n=yield $I(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:mge(n),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(_c(n))return{data:null,error:n};throw n}})}exists(s){return oa(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{return yield Nmt(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(_c(n)&&n instanceof hge){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 oa(this,void 0,void 0,function*(){try{return{data:yield k1e(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(_c(r))return{data:null,error:r};throw r}})}list(s,r,n){return oa(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},Mmt),r),{prefix:s||""});return{data:yield xg(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},n),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(_c(a))return{data:null,error:a};throw a}})}listV2(s,r){return oa(this,void 0,void 0,function*(){try{const n=Object.assign({},s);return{data:yield xg(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(_c(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 Nze="2.78.0",Sze={"X-Client-Info":`storage-js/${Nze}`};class Amt{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({},Sze),r),this.fetch=j1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(s){return oa(this,void 0,void 0,function*(){try{const r=this.listBucketOptionsToQueryString(s);return{data:yield $I(this.fetch,`${this.url}/bucket${r}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(_c(r))return{data:null,error:r};throw r}})}getBucket(s){return oa(this,void 0,void 0,function*(){try{return{data:yield $I(this.fetch,`${this.url}/bucket/${s}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(_c(r))return{data:null,error:r};throw r}})}createBucket(s){return oa(this,arguments,void 0,function*(r,n={public:!1}){try{return{data:yield xg(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(_c(a))return{data:null,error:a};throw a}})}updateBucket(s,r){return oa(this,void 0,void 0,function*(){try{return{data:yield pge(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(_c(n))return{data:null,error:n};throw n}})}emptyBucket(s){return oa(this,void 0,void 0,function*(){try{return{data:yield xg(this.fetch,`${this.url}/bucket/${s}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(_c(r))return{data:null,error:r};throw r}})}deleteBucket(s){return oa(this,void 0,void 0,function*(){try{return{data:yield k1e(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(_c(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 Emt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Sze),r),this.fetch=j1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return oa(this,void 0,void 0,function*(){try{return{data:yield xg(this.fetch,`${this.url}/bucket`,{name:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(_c(r))return{data:null,error:r};throw r}})}listBuckets(s){return oa(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 $I(this.fetch,a,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(_c(r))return{data:null,error:r};throw r}})}deleteBucket(s){return oa(this,void 0,void 0,function*(){try{return{data:yield k1e(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(_c(r))return{data:null,error:r};throw r}})}}const N1e={"X-Client-Info":`storage-js/${Nze}`,"Content-Type":"application/json"};class Cze extends Error{constructor(s){super(s),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}}function ap(t){return typeof t=="object"&&t!==null&&"__isStorageVectorsError"in t}class yhe extends Cze{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 Pmt extends Cze{constructor(s,r){super(s),this.name="StorageVectorsUnknownError",this.originalError=r}}var Z4e;(function(t){t.InternalError="InternalError",t.S3VectorConflictException="S3VectorConflictException",t.S3VectorNotFoundException="S3VectorNotFoundException",t.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",t.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",t.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded"})(Z4e||(Z4e={}));const S1e=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>ev(async()=>{const{default:n}=await Promise.resolve().then(()=>XN);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},Imt=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)},Y4e=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Lmt=(t,s,r)=>oa(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 yhe(Y4e(l),a,i))}).catch(()=>{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new yhe(i,a,l))});else{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new yhe(i,a,l))}}else s(new Pmt(Y4e(t),t))}),Dmt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return n?(Imt(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 Omt(t,s,r,n,a,o){return oa(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,Dmt(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=>Lmt(d,i,n))})})}function ip(t,s,r,n,a){return oa(this,void 0,void 0,function*(){return Omt(t,"POST",s,n,a,r)})}class Rmt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},N1e),r),this.fetch=S1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(s){return oa(this,void 0,void 0,function*(){try{return{data:(yield ip(this.fetch,`${this.url}/CreateIndex`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}getIndex(s,r){return oa(this,void 0,void 0,function*(){try{return{data:yield ip(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(ap(n))return{data:null,error:n};throw n}})}listIndexes(s){return oa(this,void 0,void 0,function*(){try{return{data:yield ip(this.fetch,`${this.url}/ListIndexes`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}deleteIndex(s,r){return oa(this,void 0,void 0,function*(){try{return{data:(yield ip(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(ap(n))return{data:null,error:n};throw n}})}}class Fmt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},N1e),r),this.fetch=S1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(s){return oa(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 ip(this.fetch,`${this.url}/PutVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}getVectors(s){return oa(this,void 0,void 0,function*(){try{return{data:yield ip(this.fetch,`${this.url}/GetVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}listVectors(s){return oa(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 ip(this.fetch,`${this.url}/ListVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}queryVectors(s){return oa(this,void 0,void 0,function*(){try{return{data:yield ip(this.fetch,`${this.url}/QueryVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}deleteVectors(s){return oa(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 ip(this.fetch,`${this.url}/DeleteVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}}class zmt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},N1e),r),this.fetch=S1e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return oa(this,void 0,void 0,function*(){try{return{data:(yield ip(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}getBucket(s){return oa(this,void 0,void 0,function*(){try{return{data:yield ip(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}listBuckets(){return oa(this,arguments,void 0,function*(s={}){try{return{data:yield ip(this.fetch,`${this.url}/ListVectorBuckets`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}deleteBucket(s){return oa(this,void 0,void 0,function*(){try{return{data:(yield ip(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ap(r))return{data:null,error:r};throw r}})}}class Bmt extends zmt{constructor(s,r={}){super(s,r.headers||{},r.fetch)}from(s){return new $mt(this.url,this.headers,s,this.fetch)}}class $mt extends Rmt{constructor(s,r,n,a){super(s,r,a),this.vectorBucketName=n}createIndex(s){const r=Object.create(null,{createIndex:{get:()=>super.createIndex}});return oa(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 oa(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 oa(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 oa(this,void 0,void 0,function*(){return r.deleteIndex.call(this,this.vectorBucketName,s)})}index(s){return new qmt(this.url,this.headers,this.vectorBucketName,s,this.fetch)}}class qmt extends Fmt{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 oa(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 oa(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 oa(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 oa(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 oa(this,void 0,void 0,function*(){return r.deleteVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}}class Umt extends Amt{constructor(s,r={},n,a){super(s,r,n,a)}from(s){return new Tmt(this.url,this.headers,s,this.fetch)}get vectors(){return new Bmt(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new Emt(this.url+"/iceberg",this.headers,this.fetch)}}const Vmt="2.78.0";let jE="";typeof Deno<"u"?jE="deno":typeof document<"u"?jE="web":typeof navigator<"u"&&navigator.product==="ReactNative"?jE="react-native":jE="node";const Hmt={"X-Client-Info":`supabase-js-${jE}/${Vmt}`},Wmt={headers:Hmt},Gmt={schema:"public"},Kmt={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Zmt={},Ymt=t=>{let s;return t?s=t:typeof fetch>"u"?s=sze:s=fetch,(...r)=>s(...r)},Xmt=()=>typeof Headers>"u"?rze:Headers,Qmt=(t,s,r)=>{const n=Ymt(r),a=Xmt();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 Jmt(t){return t.endsWith("/")?t:t+"/"}function ept(t,s){var r,n;const{db:a,auth:o,realtime:l,global:i}=t,{db:d,auth:u,realtime:p,global:g}=s,v={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({},g),i),{headers:Object.assign(Object.assign({},(r=g==null?void 0:g.headers)!==null&&r!==void 0?r:{}),(n=i==null?void 0:i.headers)!==null&&n!==void 0?n:{})}),accessToken:async()=>""};return t.accessToken?v.accessToken=t.accessToken:delete v.accessToken,v}function tpt(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(Jmt(s))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const Mze="2.78.0",p4=30*1e3,fge=3,vhe=fge*p4,spt="http://localhost:9999",rpt="supabase.auth.token",npt={"X-Client-Info":`gotrue-js/${Mze}`},gge="X-Supabase-Api-Version",Tze={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},apt=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,ipt=10*60*1e3;class qI extends Error{constructor(s,r,n){super(s),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function Sa(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class opt extends qI{constructor(s,r,n){super(s,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function lpt(t){return Sa(t)&&t.name==="AuthApiError"}class xk extends qI{constructor(s,r){super(s),this.name="AuthUnknownError",this.originalError=r}}class F_ extends qI{constructor(s,r,n,a){super(s,n,a),this.name=r,this.status=n}}class ug extends F_{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function cpt(t){return Sa(t)&&t.name==="AuthSessionMissingError"}class HC extends F_{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class S8 extends F_{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class C8 extends F_{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 dpt(t){return Sa(t)&&t.name==="AuthImplicitGrantRedirectError"}class X4e extends F_{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 xge extends F_{constructor(s,r){super(s,"AuthRetryableFetchError",r,void 0)}}function _he(t){return Sa(t)&&t.name==="AuthRetryableFetchError"}class Q4e extends F_{constructor(s,r,n){super(s,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class yge extends F_{constructor(s){super(s,"AuthInvalidJwtError",400,"invalid_jwt")}}const sne="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),J4e=` \r=`.split(""),upt=(()=>{const t=new Array(128);for(let s=0;s=6;){const n=s.queue>>s.queuedBits-6&63;r(sne[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(sne[n]),s.queuedBits-=6}}function Aze(t,s,r){const n=upt[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 t5e(t){const s=[],r=l=>{s.push(String.fromCodePoint(l))},n={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},o=l=>{ppt(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 mpt(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}hpt(n,s)}}function ppt(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 M5(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};for(let a=0;as.push(r)),new Uint8Array(s)}function kk(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};return t.forEach(a=>e5e(a,r,n)),e5e(null,r,n),s.join("")}function gpt(t){return Math.round(Date.now()/1e3)+t}function xpt(){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 wh=()=>typeof window<"u"&&typeof document<"u",Vb={tested:!1,writable:!1},Eze=()=>{if(!wh())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Vb.tested)return Vb.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Vb.tested=!0,Vb.writable=!0}catch{Vb.tested=!0,Vb.writable=!1}return Vb.writable};function ypt(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 Pze=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>ev(async()=>{const{default:n}=await Promise.resolve().then(()=>XN);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},vpt=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",f4=async(t,s,r)=>{await t.setItem(s,JSON.stringify(r))},Hb=async(t,s)=>{const r=await t.getItem(s);if(!r)return null;try{return JSON.parse(r)}catch{return r}},Gv=async(t,s)=>{await t.removeItem(s)};class ioe{constructor(){this.promise=new ioe.promiseConstructor((s,r)=>{this.resolve=s,this.reject=r})}}ioe.promiseConstructor=Promise;function bhe(t){const s=t.split(".");if(s.length!==3)throw new yge("Invalid JWT structure");for(let n=0;n{setTimeout(()=>s(null),t)})}function bpt(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 wpt(t){return("0"+t.toString(16)).substr(-2)}function jpt(){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,wpt).join("")}async function kpt(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 Npt(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 kpt(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function WC(t,s,r=!1){const n=jpt();let a=n;r&&(a+="/PASSWORD_RECOVERY"),await f4(t,`${s}-code-verifier`,a);const o=await Npt(n);return[o,n===o?"plain":"s256"]}const Spt=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function Cpt(t){const s=t.headers.get(gge);if(!s||!s.match(Spt))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function Mpt(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 Tpt(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 Apt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function GC(t){if(!Apt.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function whe(){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 Ept(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 s5e(t){return JSON.parse(JSON.stringify(t))}const dk=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Ppt=[502,503,504];async function r5e(t){var s;if(!vpt(t))throw new xge(dk(t),0);if(Ppt.includes(t.status))throw new xge(dk(t),t.status);let r;try{r=await t.json()}catch(o){throw new xk(dk(o),o)}let n;const a=Cpt(t);if(a&&a.getTime()>=Tze["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 Q4e(dk(r),t.status,((s=r.weak_password)===null||s===void 0?void 0:s.reasons)||[]);if(n==="session_not_found")throw new ug}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 Q4e(dk(r),t.status,r.weak_password.reasons);throw new opt(dk(r),t.status||500,n)}const Ipt=(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[gge]||(o[gge]=Tze["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 Lpt(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 Lpt(t,s,r,n,a,o){const l=Ipt(s,n,a,o);let i;try{i=await t(r,Object.assign({},l))}catch(d){throw console.error(d),new xge(dk(d),0)}if(i.ok||await r5e(i),n!=null&&n.noResolveJson)return i;try{return await i.json()}catch(d){await r5e(d)}}function hg(t){var s;let r=null;Rpt(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=gpt(t.expires_in)));const n=(s=t.user)!==null&&s!==void 0?s:t;return{data:{session:r,user:n},error:null}}function n5e(t){const s=hg(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 g1(t){var s;return{data:{user:(s=t.user)!==null&&s!==void 0?s:t},error:null}}function Dpt(t){return{data:t,error:null}}function Opt(t){const{action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o}=t,l=R_(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 a5e(t){return t}function Rpt(t){return t.access_token&&t.refresh_token&&t.expires_in}const jhe=["global","local","others"];class Fpt{constructor({url:s="",headers:r={},fetch:n}){this.url=s,this.headers=r,this.fetch=Pze(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=jhe[0]){if(jhe.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${jhe.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(Sa(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:g1})}catch(n){if(Sa(n))return{data:{user:null},error:n};throw n}}async generateLink(s){try{const{options:r}=s,n=R_(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:Opt,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(Sa(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:g1})}catch(r){if(Sa(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:a5e});if(p.error)throw p.error;const g=await p.json(),v=(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 j=parseInt(b.split(";")[0].split("=")[1].substring(0,1)),w=JSON.parse(b.split(";")[1].split("=")[1]);u[`${w}Page`]=j}),u.total=parseInt(v)),{data:Object.assign(Object.assign({},g),u),error:null}}catch(u){if(Sa(u))return{data:{users:[]},error:u};throw u}}async getUserById(s){GC(s);try{return await di(this.fetch,"GET",`${this.url}/admin/users/${s}`,{headers:this.headers,xform:g1})}catch(r){if(Sa(r))return{data:{user:null},error:r};throw r}}async updateUserById(s,r){GC(s);try{return await di(this.fetch,"PUT",`${this.url}/admin/users/${s}`,{body:r,headers:this.headers,xform:g1})}catch(n){if(Sa(n))return{data:{user:null},error:n};throw n}}async deleteUser(s,r=!1){GC(s);try{return await di(this.fetch,"DELETE",`${this.url}/admin/users/${s}`,{headers:this.headers,body:{should_soft_delete:r},xform:g1})}catch(n){if(Sa(n))return{data:{user:null},error:n};throw n}}async _listFactors(s){GC(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(Sa(r))return{data:null,error:r};throw r}}async _deleteFactor(s){GC(s.userId),GC(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(Sa(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:a5e});if(p.error)throw p.error;const g=await p.json(),v=(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 j=parseInt(b.split(";")[0].split("=")[1].substring(0,1)),w=JSON.parse(b.split(";")[1].split("=")[1]);u[`${w}Page`]=j}),u.total=parseInt(v)),{data:Object.assign(Object.assign({},g),u),error:null}}catch(u){if(Sa(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(Sa(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(Sa(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(Sa(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(Sa(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(Sa(r))return{data:null,error:r};throw r}}}function i5e(t={}){return{getItem:s=>t[s]||null,setItem:(s,r)=>{t[s]=r},removeItem:s=>{delete t[s]}}}const KC={debug:!!(globalThis&&Eze()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class Ize extends Error{constructor(s){super(s),this.isAcquireTimeout=!0}}class zpt extends Ize{}async function Bpt(t,s,r){KC.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,s);const n=new globalThis.AbortController;return s>0&&setTimeout(()=>{n.abort(),KC.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){KC.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,a.name);try{return await r()}finally{KC.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,a.name)}}else{if(s===0)throw KC.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new zpt(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(KC.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 $pt(){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 Lze(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function qpt(t){return parseInt(t,16)}function Upt(t){const s=new TextEncoder().encode(t);return"0x"+Array.from(s,n=>n.toString(16).padStart(2,"0")).join("")}function Vpt(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:g,version:v}=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(!g)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(v!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${v}`);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 _=Lze(t.address),b=p?`${p}://${n}`:n,j=t.statement?`${t.statement} `:"",w=`${b} wants you to sign in with your Ethereum account: ${_} ${j}`;let N=`URI: ${g} Version: ${v} Chain ID: ${r}${l?` Nonce: ${l}`:""} Issued At: ${o.toISOString()}`;if(a&&(N+=` Expiration Time: ${a.toISOString()}`),i&&(N+=` Not Before: ${i.toISOString()}`),d&&(N+=` Request ID: ${d}`),u){let C=` Resources:`;for(const A of u){if(!A||typeof A!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${A}`);C+=` - ${A}`}N+=C}return`${w} ${N}`}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 rne extends _d{constructor(s,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:s}),this.name="WebAuthnUnknownError",this.originalError=r}}function Hpt({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(Dze(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 Wpt({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(Dze(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 Gpt{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 Kpt=new Gpt;function Zpt(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=R_(t,["challenge","user","excludeCredentials"]),o=M5(s).buffer,l=Object.assign(Object.assign({},r),{id:M5(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]=nne(i,l):n[o]=nne(l)}else n[o]=l}return n}function rft(t,s){return nne(tft,t,s||{})}function nft(t,s){return nne(sft,t,s||{})}class aft{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??Kpt.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=rft(l.webauthn.credential_options.publicKey,o==null?void 0:o.create),{data:p,error:g}=await Jpt({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:g}}case"request":{const u=nft(l.webauthn.credential_options.publicKey,o==null?void 0:o.request),{data:p,error:g}=await eft(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:g}}}}catch(l){return Sa(l)?{data:null,error:l}:{data:null,error:new xk("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 qI("rpId is required for WebAuthn authentication")};try{if(!o5e())return{data:null,error:new xk("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 Sa(l)?{data:null,error:l}:{data:null,error:new xk("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 qI("rpId is required for WebAuthn registration")};try{if(!o5e())return{data:null,error:new xk("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 g;return(g=p.data)===null||g===void 0?void 0:g.all.find(v=>v.factor_type==="webauthn"&&v.friendly_name===s&&v.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 Sa(l)?{data:null,error:l}:{data:null,error:new xk("Unexpected error in register",l)}}}}$pt();const ift={url:spt,storageKey:rpt,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:npt,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function l5e(t,s,r){return await r()}const ZC={};class UI{get jwks(){var s,r;return(r=(s=ZC[this.storageKey])===null||s===void 0?void 0:s.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(s){ZC[this.storageKey]=Object.assign(Object.assign({},ZC[this.storageKey]),{jwks:s})}get jwks_cached_at(){var s,r;return(r=(s=ZC[this.storageKey])===null||s===void 0?void 0:s.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(s){ZC[this.storageKey]=Object.assign(Object.assign({},ZC[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=UI.nextInstanceID,UI.nextInstanceID+=1,this.instanceID>0&&wh()&&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({},ift),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 Fpt({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=Pze(a.fetch),this.lock=a.lock||l5e,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:wh()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=Bpt:this.lock=l5e,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 aft(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:Eze()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=i5e(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=i5e(this.memoryStorage)),wh()&&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} (${Mze}) ${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=ypt(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),wh()&&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),dpt(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 Sa(r)?{error:r}:{error:new xk("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:hg}),{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(Sa(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:g,options:v}=s;let _=null,b=null;this.flowType==="pkce"&&([_,b]=await WC(this.storage,this.storageKey)),o=await di(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:v==null?void 0:v.emailRedirectTo,body:{email:p,password:g,data:(r=v==null?void 0:v.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:v==null?void 0:v.captchaToken},code_challenge:_,code_challenge_method:b},xform:hg})}else if("phone"in s){const{phone:p,password:g,options:v}=s;o=await di(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:p,password:g,data:(n=v==null?void 0:v.data)!==null&&n!==void 0?n:{},channel:(a=v==null?void 0:v.channel)!==null&&a!==void 0?a:"sms",gotrue_meta_security:{captcha_token:v==null?void 0:v.captchaToken}},xform:hg})}else throw new S8("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(Sa(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:n5e})}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:n5e})}else throw new S8("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 HC}:(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(Sa(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,g,v;let _,b;if("message"in s)_=s.message,b=s.signature;else{const{chain:j,wallet:w,statement:N,options:C}=s;let A;if(wh())if(typeof w=="object")A=w;else{const U=window;if("ethereum"in U&&typeof U.ethereum=="object"&&"request"in U.ethereum&&typeof U.ethereum.request=="function")A=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 w!="object"||!(C!=null&&C.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");A=w}const I=new URL((r=C==null?void 0:C.url)!==null&&r!==void 0?r:window.location.href),L=await A.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=Lze(L[0]);let $=(n=C==null?void 0:C.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!$){const U=await A.request({method:"eth_chainId"});$=qpt(U)}const q={domain:I.host,address:R,statement:N,uri:I.href,version:"1",chainId:$,nonce:(a=C==null?void 0:C.signInWithEthereum)===null||a===void 0?void 0:a.nonce,issuedAt:(l=(o=C==null?void 0:C.signInWithEthereum)===null||o===void 0?void 0:o.issuedAt)!==null&&l!==void 0?l:new Date,expirationTime:(i=C==null?void 0:C.signInWithEthereum)===null||i===void 0?void 0:i.expirationTime,notBefore:(d=C==null?void 0:C.signInWithEthereum)===null||d===void 0?void 0:d.notBefore,requestId:(u=C==null?void 0:C.signInWithEthereum)===null||u===void 0?void 0:u.requestId,resources:(p=C==null?void 0:C.signInWithEthereum)===null||p===void 0?void 0:p.resources};_=Vpt(q),b=await A.request({method:"personal_sign",params:[Upt(_),R]})}try{const{data:j,error:w}=await di(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:_,signature:b},!((g=s.options)===null||g===void 0)&&g.captchaToken?{gotrue_meta_security:{captcha_token:(v=s.options)===null||v===void 0?void 0:v.captchaToken}}:null),xform:hg});if(w)throw w;return!j||!j.session||!j.user?{data:{user:null,session:null},error:new HC}:(j.session&&(await this._saveSession(j.session),await this._notifyAllSubscribers("SIGNED_IN",j.session)),{data:Object.assign({},j),error:w})}catch(j){if(Sa(j))return{data:{user:null,session:null},error:j};throw j}}async signInWithSolana(s){var r,n,a,o,l,i,d,u,p,g,v,_;let b,j;if("message"in s)b=s.message,j=s.signature;else{const{chain:w,wallet:N,statement:C,options:A}=s;let I;if(wh())if(typeof N=="object")I=N;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 N!="object"||!(A!=null&&A.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");I=N}const L=new URL((r=A==null?void 0:A.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()},A==null?void 0:A.signInWithSolana),{version:"1",domain:L.host,uri:L.href}),C?{statement:C}: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),j=$.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(),...C?["",C,""]:[""],"Version: 1",`URI: ${L.href}`,`Issued At: ${(a=(n=A==null?void 0:A.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&a!==void 0?a:new Date().toISOString()}`,...!((o=A==null?void 0:A.signInWithSolana)===null||o===void 0)&&o.notBefore?[`Not Before: ${A.signInWithSolana.notBefore}`]:[],...!((l=A==null?void 0:A.signInWithSolana)===null||l===void 0)&&l.expirationTime?[`Expiration Time: ${A.signInWithSolana.expirationTime}`]:[],...!((i=A==null?void 0:A.signInWithSolana)===null||i===void 0)&&i.chainId?[`Chain ID: ${A.signInWithSolana.chainId}`]:[],...!((d=A==null?void 0:A.signInWithSolana)===null||d===void 0)&&d.nonce?[`Nonce: ${A.signInWithSolana.nonce}`]:[],...!((u=A==null?void 0:A.signInWithSolana)===null||u===void 0)&&u.requestId?[`Request ID: ${A.signInWithSolana.requestId}`]:[],...!((g=(p=A==null?void 0:A.signInWithSolana)===null||p===void 0?void 0:p.resources)===null||g===void 0)&&g.length?["Resources",...A.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");j=R}}try{const{data:w,error:N}=await di(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:b,signature:kk(j)},!((v=s.options)===null||v===void 0)&&v.captchaToken?{gotrue_meta_security:{captcha_token:(_=s.options)===null||_===void 0?void 0:_.captchaToken}}:null),xform:hg});if(N)throw N;return!w||!w.session||!w.user?{data:{user:null,session:null},error:new HC}:(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session)),{data:Object.assign({},w),error:N})}catch(w){if(Sa(w))return{data:{user:null,session:null},error:w};throw w}}async _exchangeCodeForSession(s){const r=await Hb(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:hg});if(await Gv(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new HC}:(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(Sa(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:hg}),{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 HC}:(d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",d.session)),{data:d,error:u})}catch(r){if(Sa(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 WC(this.storage,this.storageKey));const{error:g}=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:g}}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 S8("You must provide either an email or phone number.")}catch(i){if(Sa(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:hg});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(Sa(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 WC(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:Dpt})}catch(o){if(Sa(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 ug;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(Sa(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 S8("You must provide either an email or phone number and a type")}catch(r){if(Sa(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 Hb(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:g1}):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 ug}: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:g1})})}catch(r){if(Sa(r))return cpt(r)&&(await this._removeSession(),await Gv(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 ug;const l=a.session;let i=null,d=null;this.flowType==="pkce"&&s.email!=null&&([i,d]=await WC(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:g1});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(Sa(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 ug;const r=Date.now()/1e3;let n=r,a=!0,o=null;const{payload:l}=bhe(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(Sa(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 ug;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(Sa(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(s,r){try{if(!wh())throw new C8("No browser detected.");if(s.error||s.error_description||s.error_code)throw new C8(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 X4e("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new C8("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 X4e("No code detected.");const{data:C,error:A}=await this._exchangeCodeForSession(s.code);if(A)throw A;const I=new URL(window.location.href);return I.searchParams.delete("code"),window.history.replaceState(window.history.state,"",I.toString()),{data:{session:C.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 C8("No session defined in URL");const p=Math.round(Date.now()/1e3),g=parseInt(i);let v=p+g;d&&(v=parseInt(d));const _=v-p;_*1e3<=p4&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${_}s, should have been closer to ${g}s`);const b=v-g;p-b>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",b,v,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,v,p);const{data:j,error:w}=await this._getUser(o);if(w)throw w;const N={provider_token:n,provider_refresh_token:a,access_token:o,expires_in:g,expires_at:v,refresh_token:l,token_type:u,user:j.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:N,redirectType:s.type},error:null}}catch(n){if(Sa(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 Hb(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&&!(lpt(i)&&(i.status===404||i.status===401||i.status===403)))return{error:i}}return s!=="others"&&(await this._removeSession(),await Gv(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(s){const r=xpt(),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 WC(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(Sa(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(Sa(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:g,error:v}=o;if(v)throw v;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=g.session)===null||u===void 0?void 0:u.access_token)!==null&&p!==void 0?p:void 0})});if(a)throw a;return wh()&&!(!((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(Sa(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,g=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:hg}),{data:v,error:_}=g;return _?{data:{user:null,session:null},error:_}:!v||!v.session||!v.user?{data:{user:null,session:null},error:new HC}:(v.session&&(await this._saveSession(v.session),await this._notifyAllSubscribers("USER_UPDATED",v.session)),{data:v,error:_})}catch(a){if(Sa(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(Sa(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 bpt(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:hg})),(a,o)=>{const l=200*Math.pow(2,a);return o&&_he(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(),p4);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)/p4);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${p4}ms, refresh threshold is ${fge} ticks`),a<=fge&&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 Ize)this._debug("auto refresh token tick lock not available");else throw s}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!wh()||!(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 WC(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(Sa(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(Sa(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"?Xpt(s.webauthn.credential_response):Qpt(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(Sa(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:Zpt(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:Ypt(i.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(Sa(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}=bhe(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 ug}})}catch(r){if(Sa(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 ug};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&&wh()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(Sa(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 ug};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&&wh()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(Sa(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+ipt>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}}=bhe(n);r!=null&&r.allowExpired||Mpt(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=Tpt(a.alg),g=await crypto.subtle.importKey("jwk",u,p,!0,["verify"]);if(!await crypto.subtle.verify(p,g,l,fpt(`${i}.${d}`)))throw new yge("Invalid JWT signature");return{data:{claims:o,header:a,signature:l},error:null}}catch(n){if(Sa(n))return{data:null,error:n};throw n}}}UI.nextInstanceID=0;const oft=UI;class lft extends oft{constructor(s){super(s)}}class cft{constructor(s,r,n){var a,o,l;this.supabaseUrl=s,this.supabaseKey=r;const i=tpt(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:Gmt,realtime:Zmt,auth:Object.assign(Object.assign({},Kmt),{storageKey:d}),global:Wmt},p=ept(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:(g,v)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(v)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((l=p.auth)!==null&&l!==void 0?l:{},this.headers,p.global.fetch),this.fetch=Qmt(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 smt(new URL("rest/v1",i).href,{headers:this.headers,schema:p.db.schema,fetch:this.fetch}),this.storage=new Umt(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),p.accessToken||this._listenForAuthEvents()}get functions(){return new Kht(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,g){const v={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new lft({url:this.authUrl.href,headers:Object.assign(Object.assign({},v),p),storageKey:l,autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,userStorage:o,flowType:i,lock:d,debug:u,fetch:g,hasCustomAuthorizationHeader:Object.keys(this.headers).some(_=>_.toLowerCase()==="authorization")})}_initRealtimeClient(s){return new vmt(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 dft=(t,s,r)=>new cft(t,s,r);function uft(){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}uft()&&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 hft="https://relzejiswnotikjgvjhz.supabase.co",mft="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",G=dft(hft,mft,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),Oze=S.createContext(void 0),pft=({children:t})=>{const[s,r]=S.useState(null),[n,a]=S.useState(null),[o,l]=S.useState(!0),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[g,v]=S.useState(null),[_,b]=S.useState([]),[j,w]=S.useState(null),N=Lr(),C=()=>{d(!1),p(!1),v(null),b([]),w(null)},A=async $=>{try{console.log("Checking roles via RPC for user:",$);const[{data:q,error:U},{data:V,error:X}]=await Promise.all([G.rpc("has_role",{_user_id:$,_role:"admin"}),G.rpc("has_role",{_user_id:$,_role:"brokerage_manager"})]);if(U||X)console.error("Role RPC errors:",{isAdminError:U,isBrokerError:X}),d(!1),p(!1);else{const Y=!!q,de=!!V;console.log("RPC roles result:",{adminValue:Y,brokerValue:de}),d(Y),p(de)}const{data:se,error:te}=await G.from("profiles").select("brokerage_id").eq("id",$).single();if(v(!te&&se?se.brokerage_id:null),V){console.log("Fetching managed brokerages for user:",$);const{data:Y,error:de}=await G.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",$);if(console.log("Managed brokerage assignments result:",{assignments:Y,assignmentsError:de}),de||!Y){console.error("Error fetching managed brokerage assignments:",de),b([]);return}const ie=Array.from(new Set(Y.map(be=>be.brokerage_id).filter(Boolean)));if(ie.length===0){b([]);return}const{data:ae,error:le}=await G.from("brokerages").select("id, name").in("id",ie);if(console.log("Managed brokerages details result:",{brokeragesData:ae,brokeragesError:le}),le||!ae){console.error("Error fetching managed brokerages details:",le),b([]);return}const pe=ae.map(be=>({id:be.id,name:be.name})).sort((be,ye)=>ie.indexOf(be.id)-ie.indexOf(ye.id));console.log("Parsed managed brokerages:",pe),b(pe),pe.length>0&&w(be=>be??pe[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),C()}};S.useEffect(()=>{let $=!0,q=!1;const U=()=>{!$||q||(q=!0,l(!1))},{data:{subscription:V}}=G.auth.onAuthStateChange((te,Y)=>{console.log("Auth event:",te),$&&(a(Y),r((Y==null?void 0:Y.user)??null),U(),te==="PASSWORD_RECOVERY"&&(console.log("Password recovery detected, redirecting to profile"),setTimeout(()=>{N("/profile?reset=true")},100)),Y!=null&&Y.user?setTimeout(()=>{A(Y.user.id)},0):C())}),X=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 A(te.user.id):C()}catch(te){console.error("Error restoring auth session:",te),$&&(a(null),r(null),C())}finally{U()}})(),()=>{$=!1,window.clearTimeout(X),V.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!"),N("/dashboard")},L=async($,q,U)=>{const V=`${window.location.origin}/dashboard`,{error:X}=await G.auth.signUp({email:$,password:q,options:{emailRedirectTo:V,data:{name:U}}});if(X)throw fe.error(X.message),X;fe.success("Account created! Welcome to LevelUp."),N("/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),v(null),b([]),w(null),N("/auth")}catch($){console.error("Unexpected sign out error:",$),N("/auth")}};return e.jsx(Oze.Provider,{value:{user:s,session:n,loading:o,signIn:I,signUp:L,signOut:R,isAdmin:i,isBrokerageManager:u,brokerageId:g,managedBrokerages:_,selectedBrokerageId:j,setSelectedBrokerageId:w},children:t})},Gs=()=>{const t=S.useContext(Oze);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},Rze=S.createContext(void 0),Wb="levelup_admin_session",Kv="levelup_impersonation",fft=({children:t})=>{const[s,r]=S.useState(!1),[n,a]=S.useState(null),[o,l]=S.useState(!1);S.useEffect(()=>{const u=sessionStorage.getItem(Kv);if(u)try{const p=JSON.parse(u);r(!0),a(p)}catch{sessionStorage.removeItem(Kv)}},[]);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 g={access_token:p.access_token,refresh_token:p.refresh_token};sessionStorage.setItem(Wb,JSON.stringify(g));const v=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 v.json();if(!v.ok)throw new Error(_.error||"Failed to impersonate user");const b={id:_.targetUser.id,name:_.targetUser.name,email:_.targetUser.email};if(sessionStorage.setItem(Kv,JSON.stringify(b)),_.method==="session"){const{error:j}=await G.auth.setSession({access_token:_.access_token,refresh_token:_.refresh_token});if(j)throw console.error("Set session error:",j),sessionStorage.removeItem(Wb),sessionStorage.removeItem(Kv),new Error("Failed to establish impersonation session")}else{const j=_.type||"recovery",{error:w}=await G.auth.verifyOtp({token_hash:_.token_hash,type:j});if(w)throw console.error("Verify OTP error:",w),sessionStorage.removeItem(Wb),sessionStorage.removeItem(Kv),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(Wb),sessionStorage.removeItem(Kv),!1}finally{l(!1)}},d=async()=>{l(!0);try{const u=sessionStorage.getItem(Wb);if(!u){await G.auth.signOut(),window.location.href="/auth";return}const p=JSON.parse(u);await G.auth.signOut();const{error:g}=await G.auth.setSession({access_token:p.access_token,refresh_token:p.refresh_token});if(sessionStorage.removeItem(Wb),sessionStorage.removeItem(Kv),g){console.error("Failed to restore admin session:",g),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(Wb),sessionStorage.removeItem(Kv),window.location.href="/auth"}finally{l(!1)}};return e.jsx(Rze.Provider,{value:{isImpersonating:s,impersonatedUser:n,startImpersonation:i,stopImpersonation:d,isLoading:o},children:t})},C1e=()=>{const t=S.useContext(Rze);if(t===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return t},VI=ZN("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=S.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...a},o)=>{const l=n?Hve:"button";return e.jsx(l,{className:Et(VI({variant:s,size:r,className:t})),ref:o,...a})});K.displayName="Button";const gft=()=>{const{isImpersonating:t,impersonatedUser:s,stopImpersonation:r,isLoading:n}=C1e();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(Mh,{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(As,{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"})]})})]})})},Fze=S.createContext(void 0),YC="levelup_acting_as",M8="levelup_acting_as_self",xft=({children:t})=>{const{user:s}=Gs(),[r,n]=S.useState(!1),[a,o]=S.useState([]),[l,i]=S.useState(null),[d,u]=S.useState({}),[p,g]=S.useState(!0),[v,_]=S.useState(()=>sessionStorage.getItem(M8)==="true");S.useEffect(()=>{if(!(s!=null&&s.id)){n(!1),o([]),i(null),u({}),g(!1);return}(async()=>{g(!0);try{const{data:A}=await G.rpc("has_role",{_user_id:s.id,_role:"assistant"});if(!A){n(!1),o([]),i(null),u({}),g(!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([]),g(!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(M8)==="true")_(!0),i(null),u({});else{const U=sessionStorage.getItem(YC);if(U){const V=q.find(X=>X.id===U);if(V){i(V);const X=I.find(se=>se.agent_id===U);u((X==null?void 0:X.permissions)||{})}else if(q.length>0){i(q[0]);const X=I.find(se=>se.agent_id===q[0].id);u((X==null?void 0:X.permissions)||{}),sessionStorage.setItem(YC,q[0].id)}}else if(q.length>0){i(q[0]);const V=I.find(X=>X.agent_id===q[0].id);u((V==null?void 0:V.permissions)||{}),sessionStorage.setItem(YC,q[0].id)}}}catch(A){console.error("Error loading assistant data:",A)}finally{g(!1)}})()},[s==null?void 0:s.id]);const b=C=>{i(C),_(!1),sessionStorage.removeItem(M8),C?(sessionStorage.setItem(YC,C.id),G.from("agent_assistant_assignments").select("permissions").eq("assistant_id",(s==null?void 0:s.id)||"").eq("agent_id",C.id).single().then(({data:A})=>{u((A==null?void 0:A.permissions)||{})})):(sessionStorage.removeItem(YC),u({}))},j=()=>{_(!0),i(null),u({}),sessionStorage.setItem(M8,"true"),sessionStorage.removeItem(YC)},w=C=>!r||v?!0:d[C]===!0,N=r&&l&&!v?l.id:(s==null?void 0:s.id)||null;return e.jsx(Fze.Provider,{value:{isAssistant:r,assignedAgents:a,actingAsAgent:l,setActingAsAgent:b,effectiveUserId:N,permissions:d,hasPermission:w,isLoading:p,isActingAsSelf:v,setActingAsSelf:j},children:t})},M1e=()=>{const t=S.useContext(Fze);if(t===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return t},si=()=>{const{effectiveUserId:t}=M1e();return t};var zze={exports:{}},Bze={};/** * @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 d3=S;function yft(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var vft=typeof Object.is=="function"?Object.is:yft,_ft=d3.useState,bft=d3.useEffect,wft=d3.useLayoutEffect,jft=d3.useDebugValue;function kft(t,s){var r=s(),n=_ft({inst:{value:r,getSnapshot:s}}),a=n[0].inst,o=n[1];return wft(function(){a.value=r,a.getSnapshot=s,khe(a)&&o({inst:a})},[t,r,s]),bft(function(){return khe(a)&&o({inst:a}),t(function(){khe(a)&&o({inst:a})})},[t]),jft(r),r}function khe(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!vft(t,r)}catch{return!0}}function Nft(t,s){return s()}var Sft=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Nft:kft;Bze.useSyncExternalStore=d3.useSyncExternalStore!==void 0?d3.useSyncExternalStore:Sft;zze.exports=Bze;var Cft=zze.exports;function Mft(){return Cft.useSyncExternalStore(Tft,()=>!0,()=>!1)}function Tft(){return()=>{}}var T1e="Avatar",[Aft]=Tc(T1e),[Eft,$ze]=Aft(T1e),qze=S.forwardRef((t,s)=>{const{__scopeAvatar:r,...n}=t,[a,o]=S.useState("idle");return e.jsx(Eft,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:o,children:e.jsx(Qr.span,{...n,ref:s})})});qze.displayName=T1e;var Uze="AvatarImage",Vze=S.forwardRef((t,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...o}=t,l=$ze(Uze,r),i=Pft(n,o),d=Uc(u=>{a(u),l.onImageLoadingStatusChange(u)});return Kc(()=>{i!=="idle"&&d(i)},[i,d]),i==="loaded"?e.jsx(Qr.img,{...o,ref:s,src:n}):null});Vze.displayName=Uze;var Hze="AvatarFallback",Wze=S.forwardRef((t,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=t,o=$ze(Hze,r),[l,i]=S.useState(n===void 0);return S.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});Wze.displayName=Hze;function c5e(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Pft(t,{referrerPolicy:s,crossOrigin:r}){const n=Mft(),a=S.useRef(null),o=n?(a.current||(a.current=new window.Image),a.current):null,[l,i]=S.useState(()=>c5e(o,t));return Kc(()=>{i(c5e(o,t))},[o,t]),Kc(()=>{const d=g=>()=>{i(g)};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 Gze=qze,Kze=Vze,Zze=Wze;const fn=S.forwardRef(({className:t,...s},r)=>e.jsx(Gze,{ref:r,className:Et("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...s}));fn.displayName=Gze.displayName;const Ma=S.forwardRef(({className:t,...s},r)=>e.jsx(Kze,{ref:r,className:Et("aspect-square h-full w-full",t),...s}));Ma.displayName=Kze.displayName;const gn=S.forwardRef(({className:t,...s},r)=>e.jsx(Zze,{ref:r,className:Et("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...s}));gn.displayName=Zze.displayName;const Ift=ZN("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 at({className:t,variant:s,...r}){return e.jsx("div",{className:Et(Ift({variant:s}),t),...r})}var Lft=S.createContext(void 0);function z_(t){const s=S.useContext(Lft);return t||s||"ltr"}var Nhe=0;function ooe(){S.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??d5e()),document.body.insertAdjacentElement("beforeend",t[1]??d5e()),Nhe++,()=>{Nhe===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),Nhe--}},[])}function d5e(){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 She="focusScope.autoFocusOnMount",Che="focusScope.autoFocusOnUnmount",u5e={bubbles:!1,cancelable:!0},Dft="FocusScope",fL=S.forwardRef((t,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[i,d]=S.useState(null),u=Uc(a),p=Uc(o),g=S.useRef(null),v=Aa(s,j=>d(j)),_=S.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;S.useEffect(()=>{if(n){let j=function(A){if(_.paused||!i)return;const I=A.target;i.contains(I)?g.current=I:Qv(g.current,{select:!0})},w=function(A){if(_.paused||!i)return;const I=A.relatedTarget;I!==null&&(i.contains(I)||Qv(g.current,{select:!0}))},N=function(A){if(document.activeElement===document.body)for(const L of A)L.removedNodes.length>0&&Qv(i)};document.addEventListener("focusin",j),document.addEventListener("focusout",w);const C=new MutationObserver(N);return i&&C.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",w),C.disconnect()}}},[n,i,_.paused]),S.useEffect(()=>{if(i){m5e.add(_);const j=document.activeElement;if(!i.contains(j)){const N=new CustomEvent(She,u5e);i.addEventListener(She,u),i.dispatchEvent(N),N.defaultPrevented||(Oft($ft(Yze(i)),{select:!0}),document.activeElement===j&&Qv(i))}return()=>{i.removeEventListener(She,u),setTimeout(()=>{const N=new CustomEvent(Che,u5e);i.addEventListener(Che,p),i.dispatchEvent(N),N.defaultPrevented||Qv(j??document.body,{select:!0}),i.removeEventListener(Che,p),m5e.remove(_)},0)}}},[i,u,p,_]);const b=S.useCallback(j=>{if(!r&&!n||_.paused)return;const w=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,N=document.activeElement;if(w&&N){const C=j.currentTarget,[A,I]=Rft(C);A&&I?!j.shiftKey&&N===I?(j.preventDefault(),r&&Qv(A,{select:!0})):j.shiftKey&&N===A&&(j.preventDefault(),r&&Qv(I,{select:!0})):N===C&&j.preventDefault()}},[r,n,_.paused]);return e.jsx(Qr.div,{tabIndex:-1,...l,ref:v,onKeyDown:b})});fL.displayName=Dft;function Oft(t,{select:s=!1}={}){const r=document.activeElement;for(const n of t)if(Qv(n,{select:s}),document.activeElement!==r)return}function Rft(t){const s=Yze(t),r=h5e(s,t),n=h5e(s.reverse(),t);return[r,n]}function Yze(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 h5e(t,s){for(const r of t)if(!Fft(r,{upTo:s}))return r}function Fft(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 zft(t){return t instanceof HTMLInputElement&&"select"in t}function Qv(t,{select:s=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&zft(t)&&s&&t.select()}}var m5e=Bft();function Bft(){let t=[];return{add(s){const r=t[0];s!==r&&(r==null||r.pause()),t=p5e(t,s),t.unshift(s)},remove(s){var r;t=p5e(t,s),(r=t[0])==null||r.resume()}}}function p5e(t,s){const r=[...t],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function $ft(t){return t.filter(s=>s.tagName!=="A")}var Mhe="rovingFocusGroup.onEntryFocus",qft={bubbles:!1,cancelable:!0},gL="RovingFocusGroup",[vge,Xze,Uft]=oL(gL),[Vft,B_]=Tc(gL,[Uft]),[Hft,Wft]=Vft(gL),Qze=S.forwardRef((t,s)=>e.jsx(vge.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(vge.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Gft,{...t,ref:s})})}));Qze.displayName=gL;var Gft=S.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:p=!1,...g}=t,v=S.useRef(null),_=Aa(s,v),b=z_(o),[j,w]=fu({prop:l,defaultProp:i??null,onChange:d,caller:gL}),[N,C]=S.useState(!1),A=Uc(u),I=Xze(r),L=S.useRef(!1),[R,$]=S.useState(0);return S.useEffect(()=>{const q=v.current;if(q)return q.addEventListener(Mhe,A),()=>q.removeEventListener(Mhe,A)},[A]),e.jsx(Hft,{scope:r,orientation:n,dir:b,loop:a,currentTabStopId:j,onItemFocus:S.useCallback(q=>w(q),[w]),onItemShiftTab:S.useCallback(()=>C(!0),[]),onFocusableItemAdd:S.useCallback(()=>$(q=>q+1),[]),onFocusableItemRemove:S.useCallback(()=>$(q=>q-1),[]),children:e.jsx(Qr.div,{tabIndex:N||R===0?-1:0,"data-orientation":n,...g,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&&!N){const V=new CustomEvent(Mhe,qft);if(q.currentTarget.dispatchEvent(V),!V.defaultPrevented){const X=I().filter(ie=>ie.focusable),se=X.find(ie=>ie.active),te=X.find(ie=>ie.id===j),de=[se,te,...X].filter(Boolean).map(ie=>ie.ref.current);t7e(de,p)}}L.current=!1}),onBlur:Mr(t.onBlur,()=>C(!1))})})}),Jze="RovingFocusGroupItem",e7e=S.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:o,children:l,...i}=t,d=Hd(),u=o||d,p=Wft(Jze,r),g=p.currentTabStopId===u,v=Xze(r),{onFocusableItemAdd:_,onFocusableItemRemove:b,currentTabStopId:j}=p;return S.useEffect(()=>{if(n)return _(),()=>b()},[n,_,b]),e.jsx(vge.ItemSlot,{scope:r,id:u,focusable:n,active:a,children:e.jsx(Qr.span,{tabIndex:g?0:-1,"data-orientation":p.orientation,...i,ref:s,onMouseDown:Mr(t.onMouseDown,w=>{n?p.onItemFocus(u):w.preventDefault()}),onFocus:Mr(t.onFocus,()=>p.onItemFocus(u)),onKeyDown:Mr(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const N=Yft(w,p.orientation,p.dir);if(N!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let A=v().filter(I=>I.focusable).map(I=>I.ref.current);if(N==="last")A.reverse();else if(N==="prev"||N==="next"){N==="prev"&&A.reverse();const I=A.indexOf(w.currentTarget);A=p.loop?Xft(A,I+1):A.slice(I+1)}setTimeout(()=>t7e(A))}}),children:typeof l=="function"?l({isCurrentTabStop:g,hasTabStop:j!=null}):l})})});e7e.displayName=Jze;var Kft={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Zft(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function Yft(t,s,r){const n=Zft(t.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return Kft[n]}function t7e(t,s=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function Xft(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var loe=Qze,coe=e7e,Qft=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},XC=new WeakMap,T8=new WeakMap,A8={},The=0,s7e=function(t){return t&&(t.host||s7e(t.parentNode))},Jft=function(t,s){return s.map(function(r){if(t.contains(r))return r;var n=s7e(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})},egt=function(t,s,r,n){var a=Jft(s,Array.isArray(t)?t:[t]);A8[r]||(A8[r]=new WeakMap);var o=A8[r],l=[],i=new Set,d=new Set(a),u=function(g){!g||i.has(g)||(i.add(g),u(g.parentNode))};a.forEach(u);var p=function(g){!g||d.has(g)||Array.prototype.forEach.call(g.children,function(v){if(i.has(v))p(v);else try{var _=v.getAttribute(n),b=_!==null&&_!=="false",j=(XC.get(v)||0)+1,w=(o.get(v)||0)+1;XC.set(v,j),o.set(v,w),l.push(v),j===1&&b&&T8.set(v,!0),w===1&&v.setAttribute(r,"true"),b||v.setAttribute(n,"true")}catch(N){console.error("aria-hidden: cannot operate on ",v,N)}})};return p(s),i.clear(),The++,function(){l.forEach(function(g){var v=XC.get(g)-1,_=o.get(g)-1;XC.set(g,v),o.set(g,_),v||(T8.has(g)||g.removeAttribute(n),T8.delete(g)),_||g.removeAttribute(r)}),The--,The||(XC=new WeakMap,XC=new WeakMap,T8=new WeakMap,A8={})}},doe=function(t,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),a=Qft(t);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),egt(n,a,r,"aria-hidden")):function(){return null}},Qse="right-scroll-bar-position",Jse="width-before-scroll-bar",tgt="with-scroll-bars-hidden",sgt="--removed-body-scroll-bar-size";function Ahe(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function rgt(t,s){var r=S.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 ngt=typeof window<"u"?S.useLayoutEffect:S.useEffect,f5e=new WeakMap;function agt(t,s){var r=rgt(null,function(n){return t.forEach(function(a){return Ahe(a,n)})});return ngt(function(){var n=f5e.get(r);if(n){var a=new Set(n),o=new Set(t),l=r.current;a.forEach(function(i){o.has(i)||Ahe(i,null)}),o.forEach(function(i){a.has(i)||Ahe(i,l)})}f5e.set(r,t)},[t]),r}function igt(t){return t}function ogt(t,s){s===void 0&&(s=igt);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 lgt(t){t===void 0&&(t={});var s=ogt(null);return s.options=tf({async:!0,ssr:!1},t),s}var r7e=function(t){var s=t.sideCar,r=R_(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 S.createElement(n,tf({},r))};r7e.isSideCarExport=!0;function cgt(t,s){return t.useMedium(s),r7e}var n7e=lgt(),Ehe=function(){},uoe=S.forwardRef(function(t,s){var r=S.useRef(null),n=S.useState({onScrollCapture:Ehe,onWheelCapture:Ehe,onTouchMoveCapture:Ehe}),a=n[0],o=n[1],l=t.forwardProps,i=t.children,d=t.className,u=t.removeScrollBar,p=t.enabled,g=t.shards,v=t.sideCar,_=t.noRelative,b=t.noIsolation,j=t.inert,w=t.allowPinchZoom,N=t.as,C=N===void 0?"div":N,A=t.gapMode,I=R_(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),L=v,R=agt([r,s]),$=tf(tf({},I),a);return S.createElement(S.Fragment,null,p&&S.createElement(L,{sideCar:n7e,removeScrollBar:u,shards:g,noRelative:_,noIsolation:b,inert:j,setCallbacks:o,allowPinchZoom:!!w,lockRef:r,gapMode:A}),l?S.cloneElement(S.Children.only(i),tf(tf({},$),{ref:R})):S.createElement(C,tf({},$,{className:d,ref:R}),i))});uoe.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};uoe.classNames={fullWidth:Jse,zeroRight:Qse};var dgt=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function ugt(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=dgt();return s&&t.setAttribute("nonce",s),t}function hgt(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function mgt(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var pgt=function(){var t=0,s=null;return{add:function(r){t==0&&(s=ugt())&&(hgt(s,r),mgt(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},fgt=function(){var t=pgt();return function(s,r){S.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&r])}},a7e=function(){var t=fgt(),s=function(r){var n=r.styles,a=r.dynamic;return t(n,a),null};return s},ggt={left:0,top:0,right:0,gap:0},Phe=function(t){return parseInt(t||"",10)||0},xgt=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[Phe(r),Phe(n),Phe(a)]},ygt=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return ggt;var s=xgt(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])}},vgt=a7e(),T5="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(tgt,` { overflow: hidden `).concat(n,`; padding-right: `).concat(i,"px ").concat(n,`; } body[`).concat(T5,`] { 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(Qse,` { right: `).concat(i,"px ").concat(n,`; } .`).concat(Jse,` { margin-right: `).concat(i,"px ").concat(n,`; } .`).concat(Qse," .").concat(Qse,` { right: 0 `).concat(n,`; } .`).concat(Jse," .").concat(Jse,` { margin-right: 0 `).concat(n,`; } body[`).concat(T5,`] { `).concat(sgt,": ").concat(i,`px; } `)},g5e=function(){var t=parseInt(document.body.getAttribute(T5)||"0",10);return isFinite(t)?t:0},bgt=function(){S.useEffect(function(){return document.body.setAttribute(T5,(g5e()+1).toString()),function(){var t=g5e()-1;t<=0?document.body.removeAttribute(T5):document.body.setAttribute(T5,t.toString())}},[])},wgt=function(t){var s=t.noRelative,r=t.noImportant,n=t.gapMode,a=n===void 0?"margin":n;bgt();var o=S.useMemo(function(){return ygt(a)},[a]);return S.createElement(vgt,{styles:_gt(o,!s,a,r?"":"!important")})},_ge=!1;if(typeof window<"u")try{var E8=Object.defineProperty({},"passive",{get:function(){return _ge=!0,!0}});window.addEventListener("test",E8,E8),window.removeEventListener("test",E8,E8)}catch{_ge=!1}var QC=_ge?{passive:!1}:!1,jgt=function(t){return t.tagName==="TEXTAREA"},i7e=function(t,s){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!jgt(t)&&r[s]==="visible")},kgt=function(t){return i7e(t,"overflowY")},Ngt=function(t){return i7e(t,"overflowX")},x5e=function(t,s){var r=s.ownerDocument,n=s;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=o7e(t,n);if(a){var o=l7e(t,n),l=o[1],i=o[2];if(l>i)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},Sgt=function(t){var s=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[s,r,n]},Cgt=function(t){var s=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[s,r,n]},o7e=function(t,s){return t==="v"?kgt(s):Ngt(s)},l7e=function(t,s){return t==="v"?Sgt(s):Cgt(s)},Mgt=function(t,s){return t==="h"&&s==="rtl"?-1:1},Tgt=function(t,s,r,n,a){var o=Mgt(t,window.getComputedStyle(s).direction),l=o*n,i=r.target,d=s.contains(i),u=!1,p=l>0,g=0,v=0;do{if(!i)break;var _=l7e(t,i),b=_[0],j=_[1],w=_[2],N=j-w-o*b;(b||N)&&o7e(t,i)&&(g+=N,v+=b);var C=i.parentNode;i=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!d&&i!==document.body||d&&(s.contains(i)||s===i));return(p&&Math.abs(g)<1||!p&&Math.abs(v)<1)&&(u=!0),u},P8=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},y5e=function(t){return[t.deltaX,t.deltaY]},v5e=function(t){return t&&"current"in t?t.current:t},Agt=function(t,s){return t[0]===s[0]&&t[1]===s[1]},Egt=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},Pgt=0,JC=[];function Igt(t){var s=S.useRef([]),r=S.useRef([0,0]),n=S.useRef(),a=S.useState(Pgt++)[0],o=S.useState(a7e)[0],l=S.useRef(t);S.useEffect(function(){l.current=t},[t]),S.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var j=y1e([t.lockRef.current],(t.shards||[]).map(v5e),!0).filter(Boolean);return j.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),j.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var i=S.useCallback(function(j,w){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!l.current.allowPinchZoom;var N=P8(j),C=r.current,A="deltaX"in j?j.deltaX:C[0]-N[0],I="deltaY"in j?j.deltaY:C[1]-N[1],L,R=j.target,$=Math.abs(A)>Math.abs(I)?"h":"v";if("touches"in j&&$==="h"&&R.type==="range")return!1;var q=x5e($,R);if(!q)return!0;if(q?L=$:(L=$==="v"?"h":"v",q=x5e($,R)),!q)return!1;if(!n.current&&"changedTouches"in j&&(A||I)&&(n.current=L),!L)return!0;var U=n.current||L;return Tgt(U,w,j,U==="h"?A:I)},[]),d=S.useCallback(function(j){var w=j;if(!(!JC.length||JC[JC.length-1]!==o)){var N="deltaY"in w?y5e(w):P8(w),C=s.current.filter(function(L){return L.name===w.type&&(L.target===w.target||w.target===L.shadowParent)&&Agt(L.delta,N)})[0];if(C&&C.should){w.cancelable&&w.preventDefault();return}if(!C){var A=(l.current.shards||[]).map(v5e).filter(Boolean).filter(function(L){return L.contains(w.target)}),I=A.length>0?i(w,A[0]):!l.current.noIsolation;I&&w.cancelable&&w.preventDefault()}}},[]),u=S.useCallback(function(j,w,N,C){var A={name:j,delta:w,target:N,should:C,shadowParent:Lgt(N)};s.current.push(A),setTimeout(function(){s.current=s.current.filter(function(I){return I!==A})},1)},[]),p=S.useCallback(function(j){r.current=P8(j),n.current=void 0},[]),g=S.useCallback(function(j){u(j.type,y5e(j),j.target,i(j,t.lockRef.current))},[]),v=S.useCallback(function(j){u(j.type,P8(j),j.target,i(j,t.lockRef.current))},[]);S.useEffect(function(){return JC.push(o),t.setCallbacks({onScrollCapture:g,onWheelCapture:g,onTouchMoveCapture:v}),document.addEventListener("wheel",d,QC),document.addEventListener("touchmove",d,QC),document.addEventListener("touchstart",p,QC),function(){JC=JC.filter(function(j){return j!==o}),document.removeEventListener("wheel",d,QC),document.removeEventListener("touchmove",d,QC),document.removeEventListener("touchstart",p,QC)}},[]);var _=t.removeScrollBar,b=t.inert;return S.createElement(S.Fragment,null,b?S.createElement(o,{styles:Egt(a)}):null,_?S.createElement(wgt,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function Lgt(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const Dgt=cgt(n7e,Igt);var xL=S.forwardRef(function(t,s){return S.createElement(uoe,tf({},t,{ref:s,sideCar:Dgt}))});xL.classNames=uoe.classNames;var bge=["Enter"," "],Ogt=["ArrowDown","PageUp","Home"],c7e=["ArrowUp","PageDown","End"],Rgt=[...Ogt,...c7e],Fgt={ltr:[...bge,"ArrowRight"],rtl:[...bge,"ArrowLeft"]},zgt={ltr:["ArrowLeft"],rtl:["ArrowRight"]},yL="Menu",[HI,Bgt,$gt]=oL(yL),[QN,d7e]=Tc(yL,[$gt,dy,B_]),hoe=dy(),u7e=B_(),[qgt,JN]=QN(yL),[Ugt,vL]=QN(yL),h7e=t=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:o,modal:l=!0}=t,i=hoe(s),[d,u]=S.useState(null),p=S.useRef(!1),g=Uc(o),v=z_(a);return S.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(uL,{...i,children:e.jsx(qgt,{scope:s,open:r,onOpenChange:g,content:d,onContentChange:u,children:e.jsx(Ugt,{scope:s,onClose:S.useCallback(()=>g(!1),[g]),isUsingKeyboardRef:p,dir:v,modal:l,children:n})})})};h7e.displayName=yL;var Vgt="MenuAnchor",A1e=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=hoe(r);return e.jsx(iM,{...a,...n,ref:s})});A1e.displayName=Vgt;var E1e="MenuPortal",[Hgt,m7e]=QN(E1e,{forceMount:void 0}),p7e=t=>{const{__scopeMenu:s,forceMount:r,children:n,container:a}=t,o=JN(E1e,s);return e.jsx(Hgt,{scope:s,forceMount:r,children:e.jsx(ud,{present:r||o.open,children:e.jsx(sM,{asChild:!0,container:a,children:n})})})};p7e.displayName=E1e;var hf="MenuContent",[Wgt,P1e]=QN(hf),f7e=S.forwardRef((t,s)=>{const r=m7e(hf,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=JN(hf,t.__scopeMenu),l=vL(hf,t.__scopeMenu);return e.jsx(HI.Provider,{scope:t.__scopeMenu,children:e.jsx(ud,{present:n||o.open,children:e.jsx(HI.Slot,{scope:t.__scopeMenu,children:l.modal?e.jsx(Ggt,{...a,ref:s}):e.jsx(Kgt,{...a,ref:s})})})})}),Ggt=S.forwardRef((t,s)=>{const r=JN(hf,t.__scopeMenu),n=S.useRef(null),a=Aa(s,n);return S.useEffect(()=>{const o=n.current;if(o)return doe(o)},[]),e.jsx(I1e,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Mr(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),Kgt=S.forwardRef((t,s)=>{const r=JN(hf,t.__scopeMenu);return e.jsx(I1e,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),Zgt=b_("MenuContent.ScrollLock"),I1e=S.forwardRef((t,s)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:l,disableOutsidePointerEvents:i,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:g,onInteractOutside:v,onDismiss:_,disableOutsideScroll:b,...j}=t,w=JN(hf,r),N=vL(hf,r),C=hoe(r),A=u7e(r),I=Bgt(r),[L,R]=S.useState(null),$=S.useRef(null),q=Aa(s,$,w.onContentChange),U=S.useRef(0),V=S.useRef(""),X=S.useRef(0),se=S.useRef(null),te=S.useRef("right"),Y=S.useRef(0),de=b?xL:S.Fragment,ie=b?{as:Zgt,allowPinchZoom:!0}:void 0,ae=pe=>{var Te,Fe;const be=V.current+pe,ye=I().filter(Ae=>!Ae.disabled),we=document.activeElement,Ne=(Te=ye.find(Ae=>Ae.ref.current===we))==null?void 0:Te.textValue,Ke=ye.map(Ae=>Ae.textValue),_e=oxt(Ke,be,Ne),Me=(Fe=ye.find(Ae=>Ae.textValue===_e))==null?void 0:Fe.ref.current;(function Ae(Ue){V.current=Ue,window.clearTimeout(U.current),Ue!==""&&(U.current=window.setTimeout(()=>Ae(""),1e3))})(be),Me&&setTimeout(()=>Me.focus())};S.useEffect(()=>()=>window.clearTimeout(U.current),[]),ooe();const le=S.useCallback(pe=>{var ye,we;return te.current===((ye=se.current)==null?void 0:ye.side)&&cxt(pe,(we=se.current)==null?void 0:we.area)},[]);return e.jsx(Wgt,{scope:r,searchRef:V,onItemEnter:S.useCallback(pe=>{le(pe)&&pe.preventDefault()},[le]),onItemLeave:S.useCallback(pe=>{var be;le(pe)||((be=$.current)==null||be.focus(),R(null))},[le]),onTriggerLeave:S.useCallback(pe=>{le(pe)&&pe.preventDefault()},[le]),pointerGraceTimerRef:X,onPointerGraceIntentChange:S.useCallback(pe=>{se.current=pe},[]),children:e.jsx(de,{...ie,children:e.jsx(fL,{asChild:!0,trapped:a,onMountAutoFocus:Mr(o,pe=>{var be;pe.preventDefault(),(be=$.current)==null||be.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:e.jsx(D_,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:g,onInteractOutside:v,onDismiss:_,children:e.jsx(loe,{asChild:!0,...A,dir:N.dir,orientation:"vertical",loop:n,currentTabStopId:L,onCurrentTabStopIdChange:R,onEntryFocus:Mr(d,pe=>{N.isUsingKeyboardRef.current||pe.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(hL,{role:"menu","aria-orientation":"vertical","data-state":E7e(w.open),"data-radix-menu-content":"",dir:N.dir,...C,...j,ref:q,style:{outline:"none",...j.style},onKeyDown:Mr(j.onKeyDown,pe=>{const ye=pe.target.closest("[data-radix-menu-content]")===pe.currentTarget,we=pe.ctrlKey||pe.altKey||pe.metaKey,Ne=pe.key.length===1;ye&&(pe.key==="Tab"&&pe.preventDefault(),!we&&Ne&&ae(pe.key));const Ke=$.current;if(pe.target!==Ke||!Rgt.includes(pe.key))return;pe.preventDefault();const Me=I().filter(Te=>!Te.disabled).map(Te=>Te.ref.current);c7e.includes(pe.key)&&Me.reverse(),axt(Me)}),onBlur:Mr(t.onBlur,pe=>{pe.currentTarget.contains(pe.target)||(window.clearTimeout(U.current),V.current="")}),onPointerMove:Mr(t.onPointerMove,WI(pe=>{const be=pe.target,ye=Y.current!==pe.clientX;if(pe.currentTarget.contains(be)&&ye){const we=pe.clientX>Y.current?"right":"left";te.current=we,Y.current=pe.clientX}}))})})})})})})});f7e.displayName=hf;var Ygt="MenuGroup",L1e=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Qr.div,{role:"group",...n,ref:s})});L1e.displayName=Ygt;var Xgt="MenuLabel",g7e=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Qr.div,{...n,ref:s})});g7e.displayName=Xgt;var ane="MenuItem",_5e="menu.itemSelect",moe=S.forwardRef((t,s)=>{const{disabled:r=!1,onSelect:n,...a}=t,o=S.useRef(null),l=vL(ane,t.__scopeMenu),i=P1e(ane,t.__scopeMenu),d=Aa(s,o),u=S.useRef(!1),p=()=>{const g=o.current;if(!r&&g){const v=new CustomEvent(_5e,{bubbles:!0,cancelable:!0});g.addEventListener(_5e,_=>n==null?void 0:n(_),{once:!0}),Wve(g,v),v.defaultPrevented?u.current=!1:l.onClose()}};return e.jsx(x7e,{...a,ref:d,disabled:r,onClick:Mr(t.onClick,p),onPointerDown:g=>{var v;(v=t.onPointerDown)==null||v.call(t,g),u.current=!0},onPointerUp:Mr(t.onPointerUp,g=>{var v;u.current||(v=g.currentTarget)==null||v.click()}),onKeyDown:Mr(t.onKeyDown,g=>{const v=i.searchRef.current!=="";r||v&&g.key===" "||bge.includes(g.key)&&(g.currentTarget.click(),g.preventDefault())})})});moe.displayName=ane;var x7e=S.forwardRef((t,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...o}=t,l=P1e(ane,r),i=u7e(r),d=S.useRef(null),u=Aa(s,d),[p,g]=S.useState(!1),[v,_]=S.useState("");return S.useEffect(()=>{const b=d.current;b&&_((b.textContent??"").trim())},[o.children]),e.jsx(HI.ItemSlot,{scope:r,disabled:n,textValue:a??v,children:e.jsx(coe,{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,WI(b=>{n?l.onItemLeave(b):(l.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Mr(t.onPointerLeave,WI(b=>l.onItemLeave(b))),onFocus:Mr(t.onFocus,()=>g(!0)),onBlur:Mr(t.onBlur,()=>g(!1))})})})}),Qgt="MenuCheckboxItem",y7e=S.forwardRef((t,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return e.jsx(j7e,{scope:t.__scopeMenu,checked:r,children:e.jsx(moe,{role:"menuitemcheckbox","aria-checked":ine(r)?"mixed":r,...a,ref:s,"data-state":O1e(r),onSelect:Mr(a.onSelect,()=>n==null?void 0:n(ine(r)?!0:!r),{checkForDefaultPrevented:!1})})})});y7e.displayName=Qgt;var v7e="MenuRadioGroup",[Jgt,ext]=QN(v7e,{value:void 0,onValueChange:()=>{}}),_7e=S.forwardRef((t,s)=>{const{value:r,onValueChange:n,...a}=t,o=Uc(n);return e.jsx(Jgt,{scope:t.__scopeMenu,value:r,onValueChange:o,children:e.jsx(L1e,{...a,ref:s})})});_7e.displayName=v7e;var b7e="MenuRadioItem",w7e=S.forwardRef((t,s)=>{const{value:r,...n}=t,a=ext(b7e,t.__scopeMenu),o=r===a.value;return e.jsx(j7e,{scope:t.__scopeMenu,checked:o,children:e.jsx(moe,{role:"menuitemradio","aria-checked":o,...n,ref:s,"data-state":O1e(o),onSelect:Mr(n.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,r)},{checkForDefaultPrevented:!1})})})});w7e.displayName=b7e;var D1e="MenuItemIndicator",[j7e,txt]=QN(D1e,{checked:!1}),k7e=S.forwardRef((t,s)=>{const{__scopeMenu:r,forceMount:n,...a}=t,o=txt(D1e,r);return e.jsx(ud,{present:n||ine(o.checked)||o.checked===!0,children:e.jsx(Qr.span,{...a,ref:s,"data-state":O1e(o.checked)})})});k7e.displayName=D1e;var sxt="MenuSeparator",N7e=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Qr.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});N7e.displayName=sxt;var rxt="MenuArrow",S7e=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=hoe(r);return e.jsx(mL,{...a,...n,ref:s})});S7e.displayName=rxt;var nxt="MenuSub",[I1s,C7e]=QN(nxt),kE="MenuSubTrigger",M7e=S.forwardRef((t,s)=>{const r=JN(kE,t.__scopeMenu),n=vL(kE,t.__scopeMenu),a=C7e(kE,t.__scopeMenu),o=P1e(kE,t.__scopeMenu),l=S.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:d}=o,u={__scopeMenu:t.__scopeMenu},p=S.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return S.useEffect(()=>p,[p]),S.useEffect(()=>{const g=i.current;return()=>{window.clearTimeout(g),d(null)}},[i,d]),e.jsx(A1e,{asChild:!0,...u,children:e.jsx(x7e,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":E7e(r.open),...t,ref:H0(s,a.onTriggerChange),onClick:g=>{var v;(v=t.onClick)==null||v.call(t,g),!(t.disabled||g.defaultPrevented)&&(g.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Mr(t.onPointerMove,WI(g=>{o.onItemEnter(g),!g.defaultPrevented&&!t.disabled&&!r.open&&!l.current&&(o.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{r.onOpenChange(!0),p()},100))})),onPointerLeave:Mr(t.onPointerLeave,WI(g=>{var _,b;p();const v=(_=r.content)==null?void 0:_.getBoundingClientRect();if(v){const j=(b=r.content)==null?void 0:b.dataset.side,w=j==="right",N=w?-5:5,C=v[w?"left":"right"],A=v[w?"right":"left"];o.onPointerGraceIntentChange({area:[{x:g.clientX+N,y:g.clientY},{x:C,y:v.top},{x:A,y:v.top},{x:A,y:v.bottom},{x:C,y:v.bottom}],side:j}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(g),g.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Mr(t.onKeyDown,g=>{var _;const v=o.searchRef.current!=="";t.disabled||v&&g.key===" "||Fgt[n.dir].includes(g.key)&&(r.onOpenChange(!0),(_=r.content)==null||_.focus(),g.preventDefault())})})})});M7e.displayName=kE;var T7e="MenuSubContent",A7e=S.forwardRef((t,s)=>{const r=m7e(hf,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=JN(hf,t.__scopeMenu),l=vL(hf,t.__scopeMenu),i=C7e(T7e,t.__scopeMenu),d=S.useRef(null),u=Aa(s,d);return e.jsx(HI.Provider,{scope:t.__scopeMenu,children:e.jsx(ud,{present:n||o.open,children:e.jsx(HI.Slot,{scope:t.__scopeMenu,children:e.jsx(I1e,{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 g;l.isUsingKeyboardRef.current&&((g=d.current)==null||g.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 g=p.currentTarget.contains(p.target),v=zgt[l.dir].includes(p.key);g&&v&&(o.onOpenChange(!1),(_=i.trigger)==null||_.focus(),p.preventDefault())})})})})})});A7e.displayName=T7e;function E7e(t){return t?"open":"closed"}function ine(t){return t==="indeterminate"}function O1e(t){return ine(t)?"indeterminate":t?"checked":"unchecked"}function axt(t){const s=document.activeElement;for(const r of t)if(r===s||(r.focus(),document.activeElement!==s))return}function ixt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}function oxt(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=ixt(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 lxt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=v>n&&r<(g-u)*(n-p)/(v-p)+u&&(a=!a)}return a}function cxt(t,s){if(!s)return!1;const r={x:t.clientX,y:t.clientY};return lxt(r,s)}function WI(t){return s=>s.pointerType==="mouse"?t(s):void 0}var dxt=h7e,uxt=A1e,hxt=p7e,mxt=f7e,pxt=L1e,fxt=g7e,gxt=moe,xxt=y7e,yxt=_7e,vxt=w7e,_xt=k7e,bxt=N7e,wxt=S7e,jxt=M7e,kxt=A7e,poe="DropdownMenu",[Nxt]=Tc(poe,[d7e]),Yh=d7e(),[Sxt,P7e]=Nxt(poe),I7e=t=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:o,onOpenChange:l,modal:i=!0}=t,d=Yh(s),u=S.useRef(null),[p,g]=fu({prop:a,defaultProp:o??!1,onChange:l,caller:poe});return e.jsx(Sxt,{scope:s,triggerId:Hd(),triggerRef:u,contentId:Hd(),open:p,onOpenChange:g,onOpenToggle:S.useCallback(()=>g(v=>!v),[g]),modal:i,children:e.jsx(dxt,{...d,open:p,onOpenChange:g,dir:n,modal:i,children:r})})};I7e.displayName=poe;var L7e="DropdownMenuTrigger",D7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,o=P7e(L7e,r),l=Yh(r);return e.jsx(uxt,{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:H0(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())})})})});D7e.displayName=L7e;var Cxt="DropdownMenuPortal",O7e=t=>{const{__scopeDropdownMenu:s,...r}=t,n=Yh(s);return e.jsx(hxt,{...n,...r})};O7e.displayName=Cxt;var R7e="DropdownMenuContent",F7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=P7e(R7e,r),o=Yh(r),l=S.useRef(!1);return e.jsx(mxt,{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)"}})});F7e.displayName=R7e;var Mxt="DropdownMenuGroup",Txt=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Yh(r);return e.jsx(pxt,{...a,...n,ref:s})});Txt.displayName=Mxt;var Axt="DropdownMenuLabel",z7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Yh(r);return e.jsx(fxt,{...a,...n,ref:s})});z7e.displayName=Axt;var Ext="DropdownMenuItem",B7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Yh(r);return e.jsx(gxt,{...a,...n,ref:s})});B7e.displayName=Ext;var Pxt="DropdownMenuCheckboxItem",$7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Yh(r);return e.jsx(xxt,{...a,...n,ref:s})});$7e.displayName=Pxt;var Ixt="DropdownMenuRadioGroup",Lxt=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Yh(r);return e.jsx(yxt,{...a,...n,ref:s})});Lxt.displayName=Ixt;var Dxt="DropdownMenuRadioItem",q7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Yh(r);return e.jsx(vxt,{...a,...n,ref:s})});q7e.displayName=Dxt;var Oxt="DropdownMenuItemIndicator",U7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Yh(r);return e.jsx(_xt,{...a,...n,ref:s})});U7e.displayName=Oxt;var Rxt="DropdownMenuSeparator",V7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Yh(r);return e.jsx(bxt,{...a,...n,ref:s})});V7e.displayName=Rxt;var Fxt="DropdownMenuArrow",zxt=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Yh(r);return e.jsx(wxt,{...a,...n,ref:s})});zxt.displayName=Fxt;var Bxt="DropdownMenuSubTrigger",H7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Yh(r);return e.jsx(jxt,{...a,...n,ref:s})});H7e.displayName=Bxt;var $xt="DropdownMenuSubContent",W7e=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Yh(r);return e.jsx(kxt,{...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)"}})});W7e.displayName=$xt;var qxt=I7e,Uxt=D7e,Vxt=O7e,G7e=F7e,K7e=z7e,Z7e=B7e,Y7e=$7e,X7e=q7e,Q7e=U7e,J7e=V7e,eBe=H7e,tBe=W7e;const yu=qxt,vu=Uxt,Hxt=S.forwardRef(({className:t,inset:s,children:r,...n},a)=>e.jsxs(eBe,{ref:a,className:Et("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(qa,{className:"ml-auto h-4 w-4"})]}));Hxt.displayName=eBe.displayName;const Wxt=S.forwardRef(({className:t,...s},r)=>e.jsx(tBe,{ref:r,className:Et("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}));Wxt.displayName=tBe.displayName;const Wd=S.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(Vxt,{children:e.jsx(G7e,{ref:n,sideOffset:s,className:Et("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})}));Wd.displayName=G7e.displayName;const Da=S.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(Z7e,{ref:n,className:Et("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}));Da.displayName=Z7e.displayName;const Gxt=S.forwardRef(({className:t,children:s,checked:r,...n},a)=>e.jsxs(Y7e,{ref:a,className:Et("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(Q7e,{children:e.jsx(fa,{className:"h-4 w-4"})})}),s]}));Gxt.displayName=Y7e.displayName;const Kxt=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(X7e,{ref:n,className:Et("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(Q7e,{children:e.jsx(Wc,{className:"h-2 w-2 fill-current"})})}),s]}));Kxt.displayName=X7e.displayName;const wge=S.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(K7e,{ref:n,className:Et("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...r}));wge.displayName=K7e.displayName;const k_=S.forwardRef(({className:t,...s},r)=>e.jsx(J7e,{ref:r,className:Et("-mx-1 my-1 h-px bg-muted",t),...s}));k_.displayName=J7e.displayName;const Zxt=()=>{const{isAssistant:t,actingAsAgent:s,assignedAgents:r,setActingAsAgent:n,isActingAsSelf:a,setActingAsSelf:o}=M1e();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(yu,{children:[e.jsx(vu,{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(fn,{className:"h-5 w-5",children:[e.jsx(Ma,{src:s.avatar_url||void 0}),e.jsx(gn,{className:"text-[10px] bg-primary-foreground/30",children:l(s.name)})]}),e.jsx("strong",{children:s.name})]}):e.jsx("strong",{children:"Select..."}),e.jsx(Vo,{className:"h-3 w-3"})]})}),e.jsxs(Wd,{align:"start",className:"z-[2147483647]",children:[e.jsxs(Da,{onClick:o,className:"gap-2",children:[e.jsx(Yi,{className:"h-4 w-4"}),e.jsx("span",{children:"My Account"}),a&&e.jsx(at,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]}),e.jsx(k_,{}),r.map(i=>e.jsxs(Da,{onClick:()=>n(i),className:"gap-2",children:[e.jsxs(fn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:i.avatar_url||void 0}),e.jsx(gn,{className:"text-[10px]",children:l(i.name)})]}),e.jsx("span",{children:i.name}),!a&&i.id===(s==null?void 0:s.id)&&e.jsx(at,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},i.id))]})]})]}),e.jsx(at,{variant:"secondary",className:"bg-primary-foreground/20 text-primary-foreground border-0 text-xs",children:a?"Personal Mode":"Assistant Mode"})]})})},ur=({children:t,requireAdmin:s=!1,requireBrokerageManager:r=!1})=>{const{user:n,loading:a,isAdmin:o,isBrokerageManager:l}=Gs();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(uhe,{to:"/dashboard",replace:!0}):r&&!l&&!o?e.jsx(uhe,{to:"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t}):e.jsx(uhe,{to:"/auth",replace:!0})};var R1e={};(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),ye=be.getContext("2d");ye.fillRect(0,0,1,1);var we=be.transferToImageBitmap();ye.createPattern(we,"no-repeat")}catch{return!1}return!0}();function d(){}function u(be){var ye=r.exports.Promise,we=ye!==void 0?ye:s.Promise;return typeof we=="function"?new we(be):(be(d,d),null)}var p=function(be,ye){return{transform:function(we){if(be)return we;if(ye.has(we))return ye.get(we);var Ne=new OffscreenCanvas(we.width,we.height),Ke=Ne.getContext("2d");return Ke.drawImage(we,0,0),ye.set(we,Ne),Ne},clear:function(){ye.clear()}}}(i,new Map),g=function(){var be=Math.floor(16.666666666666668),ye,we,Ne={},Ke=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(ye=function(_e){var Me=Math.random();return Ne[Me]=requestAnimationFrame(function Te(Fe){Ke===Fe||Ke+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 Xxt(){const t=ns();return Ot({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 Qxt(){const t=ns(),{user:s}=Gs();return Ot({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 foe="Dialog",[sBe,rBe]=Tc(foe),[Jxt,Gg]=sBe(foe),nBe=t=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!0}=t,i=S.useRef(null),d=S.useRef(null),[u,p]=fu({prop:n,defaultProp:a??!1,onChange:o,caller:foe});return e.jsx(Jxt,{scope:s,triggerRef:i,contentRef:d,contentId:Hd(),titleId:Hd(),descriptionId:Hd(),open:u,onOpenChange:p,onOpenToggle:S.useCallback(()=>p(g=>!g),[p]),modal:l,children:r})};nBe.displayName=foe;var aBe="DialogTrigger",iBe=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Gg(aBe,r),o=Aa(s,a.triggerRef);return e.jsx(Qr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":B1e(a.open),...n,ref:o,onClick:Mr(t.onClick,a.onOpenToggle)})});iBe.displayName=aBe;var F1e="DialogPortal",[eyt,oBe]=sBe(F1e,{forceMount:void 0}),lBe=t=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=t,o=Gg(F1e,s);return e.jsx(eyt,{scope:s,forceMount:r,children:S.Children.map(n,l=>e.jsx(ud,{present:r||o.open,children:e.jsx(sM,{asChild:!0,container:a,children:l})}))})};lBe.displayName=F1e;var one="DialogOverlay",cBe=S.forwardRef((t,s)=>{const r=oBe(one,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=Gg(one,t.__scopeDialog);return o.modal?e.jsx(ud,{present:n||o.open,children:e.jsx(syt,{...a,ref:s})}):null});cBe.displayName=one;var tyt=b_("DialogOverlay.RemoveScroll"),syt=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Gg(one,r);return e.jsx(xL,{as:tyt,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(Qr.div,{"data-state":B1e(a.open),...n,ref:s,style:{pointerEvents:"auto",...n.style}})})}),CN="DialogContent",dBe=S.forwardRef((t,s)=>{const r=oBe(CN,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=Gg(CN,t.__scopeDialog);return e.jsx(ud,{present:n||o.open,children:o.modal?e.jsx(ryt,{...a,ref:s}):e.jsx(nyt,{...a,ref:s})})});dBe.displayName=CN;var ryt=S.forwardRef((t,s)=>{const r=Gg(CN,t.__scopeDialog),n=S.useRef(null),a=Aa(s,r.contentRef,n);return S.useEffect(()=>{const o=n.current;if(o)return doe(o)},[]),e.jsx(uBe,{...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())})}),nyt=S.forwardRef((t,s)=>{const r=Gg(CN,t.__scopeDialog),n=S.useRef(!1),a=S.useRef(!1);return e.jsx(uBe,{...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()}})}),uBe=S.forwardRef((t,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=t,i=Gg(CN,r),d=S.useRef(null),u=Aa(s,d);return ooe(),e.jsxs(e.Fragment,{children:[e.jsx(fL,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(D_,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":B1e(i.open),...l,ref:u,onDismiss:()=>i.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(iyt,{titleId:i.titleId}),e.jsx(lyt,{contentRef:d,descriptionId:i.descriptionId})]})]})}),z1e="DialogTitle",hBe=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Gg(z1e,r);return e.jsx(Qr.h2,{id:a.titleId,...n,ref:s})});hBe.displayName=z1e;var mBe="DialogDescription",pBe=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Gg(mBe,r);return e.jsx(Qr.p,{id:a.descriptionId,...n,ref:s})});pBe.displayName=mBe;var fBe="DialogClose",gBe=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Gg(fBe,r);return e.jsx(Qr.button,{type:"button",...n,ref:s,onClick:Mr(t.onClick,()=>a.onOpenChange(!1))})});gBe.displayName=fBe;function B1e(t){return t?"open":"closed"}var xBe="DialogTitleWarning",[ayt,yBe]=$it(xBe,{contentName:CN,titleName:z1e,docsSlug:"dialog"}),iyt=({titleId:t})=>{const s=yBe(xBe),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 S.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},oyt="DialogDescriptionWarning",lyt=({contentRef:t,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${yBe(oyt).contentName}}.`;return S.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},goe=nBe,$1e=iBe,xoe=lBe,hM=cBe,mM=dBe,_L=hBe,bL=pBe,wL=gBe;const vs=goe,Ai=$1e,cyt=xoe,L1s=wL,vBe=S.forwardRef(({className:t,...s},r)=>e.jsx(hM,{ref:r,className:Et("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}));vBe.displayName=hM.displayName;const ys=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(cyt,{children:[e.jsx(vBe,{}),e.jsxs(mM,{ref:n,className:Et("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),...r,children:[s,e.jsxs(wL,{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"})]})]})]}));ys.displayName=mM.displayName;const Cs=({className:t,...s})=>e.jsx("div",{className:Et("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});Cs.displayName="DialogHeader";const On=({className:t,...s})=>e.jsx("div",{className:Et("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});On.displayName="DialogFooter";const Ss=S.forwardRef(({className:t,...s},r)=>e.jsx(_L,{ref:r,className:Et("text-lg font-semibold leading-none tracking-tight",t),...s}));Ss.displayName=_L.displayName;const Kr=S.forwardRef(({className:t,...s},r)=>e.jsx(bL,{ref:r,className:Et("text-sm text-muted-foreground",t),...s}));Kr.displayName=bL.displayName;const dyt={points_earned:Gi,listing_created:Vn,deal_closed:Gc,custom:Gn},w5e={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"},j5e=()=>{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 uyt(){const{user:t}=Gs(),s=ns(),{data:r}=Yxt(),n=Xxt(),[a,o]=S.useState(null),[l,i]=S.useState(!1),d=S.useCallback(()=>{const _=Date.now()+3e3,b={startVelocity:30,spread:360,ticks:60,zIndex:9999},j=(N,C)=>Math.random()*(C-N)+N,w=setInterval(()=>{const N=_-Date.now();if(N<=0){clearInterval(w);return}const C=50*(N/3e3);b5e({...b,particleCount:C,origin:{x:j(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),b5e({...b,particleCount:C,origin:{x:j(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);S.useEffect(()=>{j5e()||r&&r.length>0&&!a&&(o(r[0]),i(!0),setTimeout(d,100))},[r,a,d]);const u=async()=>{if(a){const v=a.id;i(!1),o(null),s.setQueryData(["celebrations","pending",t==null?void 0:t.id],_=>(_==null?void 0:_.filter(b=>b.id!==v))??[]),await n.mutateAsync(v)}};if(j5e()||!a)return null;const p=dyt[a.celebration_type]||Gn,g=w5e[a.celebration_type]||w5e.custom;return e.jsx(vs,{open:l,onOpenChange:v=>!v&&u(),children:e.jsxs(ys,{className:"sm:max-w-md text-center border-0 overflow-hidden",children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${g} 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 ${g} 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(mn,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),e.jsx(mn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),e.jsx(mn,{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 _Be="/assets/levelup-logo-horizontal-DEFNc0ms.png",q1e="/assets/levelup-logo-white-C2RAgAoG.png",hyt="/assets/listings-hero-BI9Ki9Dq.jpg",Re=S.forwardRef(({className:t,type:s,...r},n)=>e.jsx("input",{type:s,className:Et("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()})(m0,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(f,c){var m=c[0],y=c[1],k=c[2],E=c[3],P=m*E-k*y;return P?(f[0]=E*(P=1/P),f[1]=-y*P,f[2]=-k*P,f[3]=m*P,f):null}function g(){var f=new u(9);return u!=Float32Array&&(f[1]=0,f[2]=0,f[3]=0,f[5]=0,f[6]=0,f[7]=0),f[0]=1,f[4]=1,f[8]=1,f}function v(f,c){var m=c[0],y=c[1],k=c[2],E=c[3],P=c[4],O=c[5],B=c[6],W=c[7],J=c[8];return f[0]=P*J-O*W,f[1]=k*W-y*J,f[2]=y*O-k*P,f[3]=O*B-E*J,f[4]=m*J-k*B,f[5]=k*E-m*O,f[6]=E*W-P*B,f[7]=y*B-m*W,f[8]=m*P-y*E,f}function _(f,c,m){var y=c[0],k=c[1],E=c[2],P=c[3],O=c[4],B=c[5],W=c[6],J=c[7],ee=c[8],ne=m[0],ce=m[1],ue=m[2],je=m[3],Le=m[4],Ie=m[5],Ge=m[6],Xe=m[7],rt=m[8];return f[0]=ne*y+ce*P+ue*W,f[1]=ne*k+ce*O+ue*J,f[2]=ne*E+ce*B+ue*ee,f[3]=je*y+Le*P+Ie*W,f[4]=je*k+Le*O+Ie*J,f[5]=je*E+Le*B+Ie*ee,f[6]=Ge*y+Xe*P+rt*W,f[7]=Ge*k+Xe*O+rt*J,f[8]=Ge*E+Xe*B+rt*ee,f}function b(){var f=new u(16);return u!=Float32Array&&(f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[11]=0,f[12]=0,f[13]=0,f[14]=0),f[0]=1,f[5]=1,f[10]=1,f[15]=1,f}function j(f){var c=new u(16);return c[0]=f[0],c[1]=f[1],c[2]=f[2],c[3]=f[3],c[4]=f[4],c[5]=f[5],c[6]=f[6],c[7]=f[7],c[8]=f[8],c[9]=f[9],c[10]=f[10],c[11]=f[11],c[12]=f[12],c[13]=f[13],c[14]=f[14],c[15]=f[15],c}function w(f){return f[0]=1,f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[5]=1,f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[10]=1,f[11]=0,f[12]=0,f[13]=0,f[14]=0,f[15]=1,f}function N(f,c){var m=c[0],y=c[1],k=c[2],E=c[3],P=c[4],O=c[5],B=c[6],W=c[7],J=c[8],ee=c[9],ne=c[10],ce=c[11],ue=c[12],je=c[13],Le=c[14],Ie=c[15],Ge=m*O-y*P,Xe=m*B-k*P,rt=m*W-E*P,_t=y*B-k*O,ft=y*W-E*O,St=k*W-E*B,It=J*je-ee*ue,$t=J*Le-ne*ue,as=J*Ie-ce*ue,Wt=ee*Le-ne*je,hs=ee*Ie-ce*je,_s=ne*Ie-ce*Le,bs=Ge*_s-Xe*hs+rt*Wt+_t*as-ft*$t+St*It;return bs?(f[0]=(O*_s-B*hs+W*Wt)*(bs=1/bs),f[1]=(k*hs-y*_s-E*Wt)*bs,f[2]=(je*St-Le*ft+Ie*_t)*bs,f[3]=(ne*ft-ee*St-ce*_t)*bs,f[4]=(B*as-P*_s-W*$t)*bs,f[5]=(m*_s-k*as+E*$t)*bs,f[6]=(Le*rt-ue*St-Ie*Xe)*bs,f[7]=(J*St-ne*rt+ce*Xe)*bs,f[8]=(P*hs-O*as+W*It)*bs,f[9]=(y*as-m*hs-E*It)*bs,f[10]=(ue*ft-je*rt+Ie*Ge)*bs,f[11]=(ee*rt-J*ft-ce*Ge)*bs,f[12]=(O*$t-P*Wt-B*It)*bs,f[13]=(m*Wt-y*$t+k*It)*bs,f[14]=(je*Xe-ue*_t-Le*Ge)*bs,f[15]=(J*_t-ee*Xe+ne*Ge)*bs,f):null}function C(f,c,m){var y=c[0],k=c[1],E=c[2],P=c[3],O=c[4],B=c[5],W=c[6],J=c[7],ee=c[8],ne=c[9],ce=c[10],ue=c[11],je=c[12],Le=c[13],Ie=c[14],Ge=c[15],Xe=m[0],rt=m[1],_t=m[2],ft=m[3];return f[0]=Xe*y+rt*O+_t*ee+ft*je,f[1]=Xe*k+rt*B+_t*ne+ft*Le,f[2]=Xe*E+rt*W+_t*ce+ft*Ie,f[3]=Xe*P+rt*J+_t*ue+ft*Ge,f[4]=(Xe=m[4])*y+(rt=m[5])*O+(_t=m[6])*ee+(ft=m[7])*je,f[5]=Xe*k+rt*B+_t*ne+ft*Le,f[6]=Xe*E+rt*W+_t*ce+ft*Ie,f[7]=Xe*P+rt*J+_t*ue+ft*Ge,f[8]=(Xe=m[8])*y+(rt=m[9])*O+(_t=m[10])*ee+(ft=m[11])*je,f[9]=Xe*k+rt*B+_t*ne+ft*Le,f[10]=Xe*E+rt*W+_t*ce+ft*Ie,f[11]=Xe*P+rt*J+_t*ue+ft*Ge,f[12]=(Xe=m[12])*y+(rt=m[13])*O+(_t=m[14])*ee+(ft=m[15])*je,f[13]=Xe*k+rt*B+_t*ne+ft*Le,f[14]=Xe*E+rt*W+_t*ce+ft*Ie,f[15]=Xe*P+rt*J+_t*ue+ft*Ge,f}function A(f,c,m){var y,k,E,P,O,B,W,J,ee,ne,ce,ue,je=m[0],Le=m[1],Ie=m[2];return c===f?(f[12]=c[0]*je+c[4]*Le+c[8]*Ie+c[12],f[13]=c[1]*je+c[5]*Le+c[9]*Ie+c[13],f[14]=c[2]*je+c[6]*Le+c[10]*Ie+c[14],f[15]=c[3]*je+c[7]*Le+c[11]*Ie+c[15]):(k=c[1],E=c[2],P=c[3],O=c[4],B=c[5],W=c[6],J=c[7],ee=c[8],ne=c[9],ce=c[10],ue=c[11],f[0]=y=c[0],f[1]=k,f[2]=E,f[3]=P,f[4]=O,f[5]=B,f[6]=W,f[7]=J,f[8]=ee,f[9]=ne,f[10]=ce,f[11]=ue,f[12]=y*je+O*Le+ee*Ie+c[12],f[13]=k*je+B*Le+ne*Ie+c[13],f[14]=E*je+W*Le+ce*Ie+c[14],f[15]=P*je+J*Le+ue*Ie+c[15]),f}function I(f,c,m){var y=m[0],k=m[1],E=m[2];return f[0]=c[0]*y,f[1]=c[1]*y,f[2]=c[2]*y,f[3]=c[3]*y,f[4]=c[4]*k,f[5]=c[5]*k,f[6]=c[6]*k,f[7]=c[7]*k,f[8]=c[8]*E,f[9]=c[9]*E,f[10]=c[10]*E,f[11]=c[11]*E,f[12]=c[12],f[13]=c[13],f[14]=c[14],f[15]=c[15],f}function L(f,c,m){var y=Math.sin(m),k=Math.cos(m),E=c[4],P=c[5],O=c[6],B=c[7],W=c[8],J=c[9],ee=c[10],ne=c[11];return c!==f&&(f[0]=c[0],f[1]=c[1],f[2]=c[2],f[3]=c[3],f[12]=c[12],f[13]=c[13],f[14]=c[14],f[15]=c[15]),f[4]=E*k+W*y,f[5]=P*k+J*y,f[6]=O*k+ee*y,f[7]=B*k+ne*y,f[8]=W*k-E*y,f[9]=J*k-P*y,f[10]=ee*k-O*y,f[11]=ne*k-B*y,f}function R(f,c,m){var y=Math.sin(m),k=Math.cos(m),E=c[0],P=c[1],O=c[2],B=c[3],W=c[8],J=c[9],ee=c[10],ne=c[11];return c!==f&&(f[4]=c[4],f[5]=c[5],f[6]=c[6],f[7]=c[7],f[12]=c[12],f[13]=c[13],f[14]=c[14],f[15]=c[15]),f[0]=E*k-W*y,f[1]=P*k-J*y,f[2]=O*k-ee*y,f[3]=B*k-ne*y,f[8]=E*y+W*k,f[9]=P*y+J*k,f[10]=O*y+ee*k,f[11]=B*y+ne*k,f}function $(f,c,m){var y=Math.sin(m),k=Math.cos(m),E=c[0],P=c[1],O=c[2],B=c[3],W=c[4],J=c[5],ee=c[6],ne=c[7];return c!==f&&(f[8]=c[8],f[9]=c[9],f[10]=c[10],f[11]=c[11],f[12]=c[12],f[13]=c[13],f[14]=c[14],f[15]=c[15]),f[0]=E*k+W*y,f[1]=P*k+J*y,f[2]=O*k+ee*y,f[3]=B*k+ne*y,f[4]=W*k-E*y,f[5]=J*k-P*y,f[6]=ee*k-O*y,f[7]=ne*k-B*y,f}function q(f,c){return f[0]=c[0],f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[5]=c[1],f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[10]=c[2],f[11]=0,f[12]=0,f[13]=0,f[14]=0,f[15]=1,f}function U(f,c,m){var y,k,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)),f[0]=c[0]*E,f[1]=c[1]*E,f[2]=c[2]*E,f}function Ue(f,c){return f[0]*c[0]+f[1]*c[1]+f[2]*c[2]}function ut(f,c,m){var y=c[0],k=c[1],E=c[2],P=m[0],O=m[1],B=m[2];return f[0]=k*B-E*O,f[1]=E*P-y*B,f[2]=y*O-k*P,f}function De(f,c,m,y){var k=c[0],E=c[1],P=c[2];return f[0]=k+y*(m[0]-k),f[1]=E+y*(m[1]-E),f[2]=P+y*(m[2]-P),f}function Dt(f,c,m){var y=c[0],k=c[1],E=c[2],P=m[3]*y+m[7]*k+m[11]*E+m[15];return f[0]=(m[0]*y+m[4]*k+m[8]*E+m[12])/(P=P||1),f[1]=(m[1]*y+m[5]*k+m[9]*E+m[13])/P,f[2]=(m[2]*y+m[6]*k+m[10]*E+m[14])/P,f}function he(f,c,m){var y=c[0],k=c[1],E=c[2];return f[0]=y*m[0]+k*m[3]+E*m[6],f[1]=y*m[1]+k*m[4]+E*m[7],f[2]=y*m[2]+k*m[5]+E*m[8],f}function Ve(f,c,m){var y=m[0],k=m[1],E=m[2],P=m[3],O=c[0],B=c[1],W=c[2],J=k*W-E*B,ee=E*O-y*W,ne=y*B-k*O;return f[0]=O+P*(J+=J)+k*(ne+=ne)-E*(ee+=ee),f[1]=B+P*ee+E*J-y*ne,f[2]=W+P*ne+y*ee-k*J,f}function nt(f){return f[0]=0,f[1]=0,f[2]=0,f}function Qe(f,c){return f[0]===c[0]&&f[1]===c[1]&&f[2]===c[2]}var ke=pe,ot=be,qe=de;function lt(){var f=new u(4);return u!=Float32Array&&(f[0]=0,f[1]=0,f[2]=0,f[3]=0),f}function We(f,c,m){return f[0]=c[0]*m,f[1]=c[1]*m,f[2]=c[2]*m,f[3]=c[3]*m,f}function Ye(f,c){var m=c[0],y=c[1],k=c[2],E=c[3],P=m*m+y*y+k*k+E*E;return P>0&&(P=1/Math.sqrt(P)),f[0]=m*P,f[1]=y*P,f[2]=k*P,f[3]=E*P,f}function mt(f,c,m){var y=c[0],k=c[1],E=c[2],P=c[3];return f[0]=m[0]*y+m[4]*k+m[8]*E+m[12]*P,f[1]=m[1]*y+m[5]*k+m[9]*E+m[13]*P,f[2]=m[2]*y+m[6]*k+m[10]*E+m[14]*P,f[3]=m[3]*y+m[7]*k+m[11]*E+m[15]*P,f}function Ze(){var f=new u(4);return u!=Float32Array&&(f[0]=0,f[1]=0,f[2]=0),f[3]=1,f}function He(f){return f[0]=0,f[1]=0,f[2]=0,f[3]=1,f}function et(f,c,m){m*=.5;var y=c[0],k=c[1],E=c[2],P=c[3],O=Math.sin(m),B=Math.cos(m);return f[0]=y*B+P*O,f[1]=k*B+E*O,f[2]=E*B-k*O,f[3]=P*B-y*O,f}function Rt(f,c,m){m*=.5;var y=c[0],k=c[1],E=c[2],P=c[3],O=Math.sin(m),B=Math.cos(m);return f[0]=y*B-E*O,f[1]=k*B+P*O,f[2]=E*B+y*O,f[3]=P*B-k*O,f}te(),lt();var qt,ls,Kt,Qt=Ye,fs=(qt=te(),ls=ie(1,0,0),Kt=ie(0,1,0),function(f,c,m){var y=Ue(c,m);return y<-.999999?(ut(qt,ls,c),qe(qt)<1e-6&&ut(qt,Kt,c),Ae(qt,qt),function(k,E,P){P*=.5;var O=Math.sin(P);k[0]=O*E[0],k[1]=O*E[1],k[2]=O*E[2],k[3]=Math.cos(P)}(f,qt,Math.PI),f):y>.999999?(f[0]=0,f[1]=0,f[2]=0,f[3]=1,f):(ut(qt,c,m),f[0]=qt[0],f[1]=qt[1],f[2]=qt[2],f[3]=1+y,Qt(f,f))});function dr(){var f=new u(2);return u!=Float32Array&&(f[0]=0,f[1]=0),f}function bt(f,c){var m=new u(2);return m[0]=f,m[1]=c,m}function ks(f,c,m){return f[0]=c,f[1]=m,f}function ir(f,c,m){return f[0]=c[0]+m[0],f[1]=c[1]+m[1],f}function Rr(f,c,m){return f[0]=c[0]-m[0],f[1]=c[1]-m[1],f}function ca(f,c,m){return f[0]=c[0]*m,f[1]=c[1]*m,f}function ii(f){var c=f[0],m=f[1];return Math.sqrt(c*c+m*m)}function lo(f,c){var m=c[0],y=c[1],k=m*m+y*y;return k>0&&(k=1/Math.sqrt(k)),f[0]=c[0]*k,f[1]=c[1]*k,f}function Oa(f,c){return f[0]*c[0]+f[1]*c[1]}Ze(),Ze(),g();var yn,ta,Zt=Rr;function vr(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}dr();var Gr=function(){if(ta)return yn;function f(c,m,y,k){this.cx=3*c,this.bx=3*(y-c)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*m,this.by=3*(k-m)-this.cy,this.ay=1-this.cy-this.by,this.p1x=c,this.p1y=m,this.p2x=y,this.p2y=k}return ta=1,yn=f,f.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 y=c,k=0;k<8;k++){var E=this.sampleCurveX(y)-c;if(Math.abs(E)E?O=y:B=y,y=.5*(B-O)+O;return y},solve:function(c,m){return this.sampleCurveY(this.solveCurveX(c,m))}},yn}(),Rn=vr(Gr);function rs(f,c){this.x=f,this.y=c}function Ln(f,c){if(Array.isArray(f)){if(!Array.isArray(c)||f.length!==c.length)return!1;for(let m=0;m=1)return 1;const c=f*f,m=c*f;return 4*(f<.5?m:3*(f-c)+m-.75)}function Yc(f,c,m,y){const k=new Rn(f,c,m,y);return function(E){return k.solve(E)}}const ct=Yc(.25,.1,.25,1);function Se(f,c,m){return Math.min(m,Math.max(c,f))}function ze(f,c,m){return(m=Se((m-f)/(c-f),0,1))*m*(3-2*m)}function st(f,c,m){const y=m-c,k=((f-c)%y+y)%y+c;return k===c?m:k}function Tt(f,c,m){if(!f.length)return m(null,[]);let y=f.length;const k=new Array(f.length);let E=null;f.forEach((P,O)=>{c(P,(B,W)=>{B&&(E=B),k[O]=W,--y==0&&m(E,k)})})}let Nt=1;function Bt(){return Nt++}function Yt(f){return f<=1?1:Math.pow(2,Math.ceil(Math.log2(f)))}function Ut(f,c){f.forEach(m=>{c[m]&&(c[m]=c[m].bind(c))})}function Jt(f,c,m){const y={};for(const k in f)y[k]=c.call(this,f[k],k,f);return y}function Is(f,c,m){const y={};for(const k in f)c.call(this,f[k],k,f)&&(y[k]=f[k]);return y}function xs(f){return Array.isArray(f)?f.map(xs):typeof f=="object"&&f?Jt(f,xs):f}function pr(f,c){for(let m=0;m=0)return!0;return!1}const $r={};function cr(f){$r[f]||(typeof console<"u"&&console.warn(f),$r[f]=!0)}function Cn(f,c,m){return(m.y-f.y)*(c.x-f.x)>(c.y-f.y)*(m.x-f.x)}function Mn(f){let c=0;for(let m,y,k=0,E=f.length,P=E-1;k@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(m,y,k,E)=>{const P=k||E;return c[y]=!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 $o=null;function Ha(f,c){return[f[4*c],f[4*c+1],f[4*c+2],f[4*c+3]]}function Wo(f,c,m,y){for(;c>1;f[k]>1;f[k]<=y?c=k+1:m=k}return c}function _a(f){return f>0?1/(1.001-f):1+f}function Qi(f){return f>0?1-1/(1.001-f):-f}function xi(f,c,m){return(f-c.min)*(m.max-m.min)/(c.max-c.min)+m.min}const sa={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(!sa.API_URL)return null;try{const f=new URL(sa.API_URL);return f.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":f.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(f){return sa.API_URL_REGEX.test(f)}function rc(f){return sa.API_SPRITE_REGEX.test(f)}let gc,Md,Np,xl,wu,Xc;function Qh(){return gc==null&&(gc=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),gc}const yl={now:()=>xl!==void 0?xl:performance.now(),setNow(f){xl=f},restoreNow(){xl=void 0},frame(f){const c=requestAnimationFrame(f);return{cancel:()=>cancelAnimationFrame(c)}},getImageData(f,c=0){const{width:m,height:y}=f;wu||(wu=document.createElement("canvas"));const k=wu.getContext("2d",{willReadFrequently:!0});if(!k)throw new Error("failed to create canvas 2d context");return(m>wu.width||y>wu.height)&&(wu.width=m,wu.height=y),k.clearRect(-c,-c,m+2*c,y+2*c),k.drawImage(f,0,0,m,y),k.getImageData(-c,-c,m+2*c,y+2*c)},resolveURL:f=>(Md||(Md=document.createElement("a")),Md.href=f,Md.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(Np==null&&(Np=window.matchMedia("(prefers-reduced-motion: reduce)")),Np.matches)},hasCanvasFingerprintNoise(){if(Xc!==void 0)return Xc;if(!Qh())return Xc=!1,!1;const f=new OffscreenCanvas(85,1),c=f.getContext("2d",{willReadFrequently:!0});let m=0;for(let k=0;k0?`?${E}`:""}`}const iv="mapbox-tiles";let ov=500,lv=50;const Bm=["language","worldview","jobid"];let uh,Td;function hh(){try{return caches}catch{}}function hd(){const f=hh();f&&uh==null&&(uh=f.open(iv))}let Qc=1/0;const Ad={supported:!1,testSupport:function(f){!Jh&&Cp&&(em?xy(f):Sp=f)}};let Sp,Cp,Jh=!1,em=!1;const Jc=typeof self<"u"?self:{};function xy(f){const c=f.createTexture();f.bindTexture(f.TEXTURE_2D,c);try{if(f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,Cp),f.isContextLost())return;Ad.supported=!0}catch{}f.deleteTexture(c),Jh=!0}Jc.document&&(Cp=Jc.document.createElement("img"),Cp.onload=function(){Sp&&xy(Sp),Sp=null,em=!0},Cp.onerror=function(){Jh=!0,Sp=null},Cp.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Df={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(Df);class ul extends Error{constructor(c,m,y){m===401&&Ji(y)&&(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=y}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const cv=ua()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,Of=function(f,c){if(!(/^file:/.test(m=f.url)||/^file:/.test(cv())&&!/^\w+:/.test(m))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(y,k){const E=new AbortController,P=new Request(y.url,{method:y.method||"GET",body:y.body,credentials:y.credentials,headers:y.headers,referrer:cv(),referrerPolicy:y.referrerPolicy,signal:E.signal});let O=!1,B=!1;const W=(J=P.url).indexOf("sku=")>0&&Ji(J);var J;y.type==="json"&&P.headers.set("Accept","application/json");const ee=(ce,ue,je)=>{if(B)return;if(ce&&ce.message!=="SecurityError"&&cr(ce.toString()),ue&&je)return ne(ue);const Le=Date.now();fetch(P).then(Ie=>{if(Ie.ok){const Ge=W?Ie.clone():null;return ne(Ie,Ge,Le)}return k(new ul(Ie.statusText,Ie.status,y.url))}).catch(Ie=>{Ie.name!=="AbortError"&&k(new Error(`${Ie.message} ${y.url}`))})},ne=(ce,ue,je)=>{(y.type==="arrayBuffer"?ce.arrayBuffer():y.type==="json"?ce.json():ce.text()).then(Le=>{B||(ue&&je&&function(Ie,Ge,Xe){if(hd(),uh==null)return;const rt=co(Ge.headers.get("Cache-Control")||"");if(rt["no-store"])return;const _t={status:Ge.status,statusText:Ge.statusText,headers:new Headers};Ge.headers.forEach((It,$t)=>_t.headers.set($t,It)),rt["max-age"]&&_t.headers.set("Expires",new Date(Xe+1e3*rt["max-age"]).toUTCString());const ft=_t.headers.get("Expires");if(!ft||new Date(ft).getTime()-Xe<42e4)return;let St=Xg(Ie.url,{persistentParams:Bm});if(Ge.status===206){const It=Ie.headers.get("Range");if(!It)return;_t.status=200,St=Lf(St,{range:It})}(function(It,$t){if(Td===void 0)try{new Response(new ReadableStream),Td=!0}catch{Td=!1}Td?$t(It.body):It.blob().then($t).catch(as=>cr(as.message))})(Ge,It=>{const $t=new Response((as=Ge.status)!==200&&as!==404&&[101,103,204,205,304].includes(as)?null:It,_t);var as;hd(),uh!=null&&uh.then(Wt=>Wt.put(St,$t)).catch(Wt=>cr(Wt.message))})}(P,ue,je),O=!0,k(null,Le,ce.headers))}).catch(Le=>{B||k(new Error(Le.message))})};return W?function(ce,ue){if(hd(),uh==null)return ue(null);uh.then(je=>{let Le=Xg(ce.url,{persistentParams:Bm});const Ie=ce.headers.get("Range");Ie&&(Le=Lf(Le,{range:Ie})),je.match(Le).then(Ge=>{const Xe=function(rt){if(!rt)return!1;const _t=new Date(rt.headers.get("Expires")||0),ft=co(rt.headers.get("Cache-Control")||"");return Number(_t)>Date.now()&&!ft["no-cache"]}(Ge);je.delete(Le).catch(ue),Xe&&je.put(Le,Ge.clone()).catch(ue),ue(null,Ge,Xe)}).catch(ue)}).catch(ue)}(P,ee):ee(null,null),{cancel:()=>{B=!0,O||E.abort()}}}(f,c);if(ua(self)&&self.worker.actor)return self.worker.actor.send("getResource",f,c,void 0,!0)}var m;return function(y,k){const E=new XMLHttpRequest;E.open(y.method||"GET",y.url,!0),y.type==="arrayBuffer"&&(E.responseType="arraybuffer");for(const P in y.headers)E.setRequestHeader(P,y.headers[P]);return y.type==="json"&&(E.responseType="text",E.setRequestHeader("Accept","application/json")),E.withCredentials=y.credentials==="include",E.onerror=()=>{k(new Error(E.statusText))},E.onload=()=>{if((E.status>=200&&E.status<300||E.status===0)&&E.response!==null){let P=E.response;if(y.type==="json")try{P=JSON.parse(E.response)}catch(B){return k(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)}),k(null,P,O)}else k(new ul(E.statusText,E.status,y.url))},E.send(y.body),{cancel:()=>E.abort()}}(f,c)},qu=function(f,c){return Of(Object.assign(f,{type:"arrayBuffer"}),c)};function eb(f){const c=document.createElement("a");return c.href=f,c.protocol===location.protocol&&c.host===location.host}const dS="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let yy,ba;yy=[],ba=0;const Qg=function(f,c){if(Ad.supported&&(f.headers||(f.headers={}),f.headers.accept="image/webp,*/*"),ba>=sa.MAX_PARALLEL_IMAGE_REQUESTS){const E={requestParameters:f,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return yy.push(E),E}ba++;let m=!1;const y=()=>{if(!m)for(m=!0,ba--;yy.length&&ba{y(),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=dS})},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):dS}(P,(B,W)=>c(B,W,O)))});return{cancel:()=>{k.cancel(),y()}}};var tb,uS,hS,mh={exports:{}},vy={exports:{}},_y={exports:{}},sb=function(){if(hS)return mh.exports;hS=1;var f=(tb||(tb=1,vy.exports=function(m,y){var k,E,P,O,B,W,J,ee;for(E=m.length-(k=3&m.length),P=y,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,k){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}),vy.exports),c=(uS||(uS=1,_y.exports=function(m,y){for(var k,E=m.length,P=y^E,O=0;E>=4;)k=1540483477*(65535&(k=255&m.charCodeAt(O)|(255&m.charCodeAt(++O))<<8|(255&m.charCodeAt(++O))<<16|(255&m.charCodeAt(++O))<<24))+((1540483477*(k>>>16)&65535)<<16),P=1540483477*(65535&P)+((1540483477*(P>>>16)&65535)<<16)^(k=1540483477*(65535&(k^=k>>>24))+((1540483477*(k>>>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}),_y.exports);return mh.exports=f,mh.exports.murmur3=f,mh.exports.murmur2=c,mh.exports}(),dv=vr(sb);class tm{constructor(c,...m){Object.assign(this,m[0]||{}),this.type=c}}class Jg extends tm{constructor(c,m={}){super("error",Object.assign({error:c},m))}}function rb(f,c,m){m[f]&&m[f].indexOf(c)!==-1||(m[f]=m[f]||[],m[f].push(c))}function yt(f,c,m){if(m&&m[f]){const y=m[f].indexOf(c);y!==-1&&m[f].splice(y,1)}}class Ts{on(c,m){return this._listeners=this._listeners||{},rb(c,m,this._listeners),this}off(c,m){return yt(c,m,this._listeners),yt(c,m,this._oneTimeListeners),this}once(c,m){return m?(this._oneTimeListeners=this._oneTimeListeners||{},rb(c,m,this._oneTimeListeners),this):new Promise(y=>{this.once(c,y)})}fire(c,m){const y=typeof c=="string"?new tm(c,m):c,k=y.type;if(this.listens(k)){y.target=this;const E=this._listeners&&this._listeners[k]?this._listeners[k].slice():[];for(const B of E)B.call(this,y);const P=this._oneTimeListeners&&this._oneTimeListeners[k]?this._oneTimeListeners[k].slice():[];for(const B of P)yt(k,B,this._oneTimeListeners),B.call(this,y);const O=this._eventedParent;if(O){const B=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(y,B),O.fire(y)}}else y instanceof Jg&&console.error(y.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 Ws{constructor(c){typeof c=="string"?this.name=c:(this.name=c.name,this.iconsetId=c.iconsetId)}static from(c){return new Ws(c)}static toString(c){return c.iconsetId?`${c.name}${c.iconsetId}`:c.name}static parse(c){const[m,y]=c.split("");return new Ws({name:m,iconsetId:y})}static isEqual(c,m){return c.name===m.name&&c.iconsetId===m.iconsetId}toString(){return Ws.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var ln,cn={},ea=function(){if(ln)return cn;ln=1;var f={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 y(E){return(P=E[E.length-1]==="%"?parseFloat(E)/100:parseFloat(E))<0?0:P>1?1:P;var P}function k(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 f)return f[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(","),ne=1;switch(J){case"rgba":if(ee.length!==4)return null;ne=y(ee.pop());case"rgb":return ee.length!==3?null:[m(ee[0]),m(ee[1]),m(ee[2]),ne];case"hsla":if(ee.length!==4)return null;ne=y(ee.pop());case"hsl":if(ee.length!==3)return null;var ce=(parseFloat(ee[0])%360+360)%360/360,ue=y(ee[1]),je=y(ee[2]),Le=je<=.5?je*(ue+1):je+ue-je*ue,Ie=2*je-Le;return[c(255*k(Ie,Le,ce+1/3)),c(255*k(Ie,Le,ce)),c(255*k(Ie,Le,ce-1/3)),ne];default:return null}}return null}}catch{}return cn}();class Fr{constructor(c,m,y,k=1){this.r=c,this.g=m,this.b=y,this.a=k}static parse(c){if(!c)return;if(c instanceof Fr)return c;if(typeof c!="string")return;const m=ea.parseCSSColor(c);return m?new Fr(m[0]/255,m[1]/255,m[2]/255,m[3]):void 0}toString(){const[c,m,y,k]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*c)},${Math.round(255*m)},${Math.round(255*y)},${k})`}toNonPremultipliedRenderColor(c){const{r:m,g:y,b:k,a:E}=this;return new Rf(c,m,y,k,E)}toPremultipliedRenderColor(c){const{r:m,g:y,b:k,a:E}=this;return new $m(c,m*E,y*E,k*E,E)}clone(){return new Fr(this.r,this.g,this.b,this.a)}}class eo{constructor(c,m,y,k,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),y=E===0?0:y/E*(O-1),k=E===0?0:k/E*(O-1)):(m*=O-1,y*=O-1,k*=O-1);const W=Math.floor(m),J=Math.floor(y),ee=Math.floor(k),ne=Math.ceil(m),ce=Math.ceil(y),ue=Math.ceil(k),je=m-W,Le=y-J,Ie=k-ee,Ge=c.image.data,Xe=4*(W+J*B+ee*O),rt=4*(W+J*B+ue*O),_t=4*(W+ce*B+ee*O),ft=4*(W+ce*B+ue*O),St=4*(ne+J*B+ee*O),It=4*(ne+J*B+ue*O),$t=4*(ne+ce*B+ee*O),as=4*(ne+ce*B+ue*O);if(Xe<0||as>=Ge.length)throw new Error("out of range");this.r=Vr(Vr(Vr(Ge[Xe],Ge[rt],Ie),Vr(Ge[_t],Ge[ft],Ie),Le),Vr(Vr(Ge[St],Ge[It],Ie),Vr(Ge[$t],Ge[as],Ie),Le),je)/255*(this.premultiplied?E:1),this.g=Vr(Vr(Vr(Ge[Xe+1],Ge[rt+1],Ie),Vr(Ge[_t+1],Ge[ft+1],Ie),Le),Vr(Vr(Ge[St+1],Ge[It+1],Ie),Vr(Ge[$t+1],Ge[as+1],Ie),Le),je)/255*(this.premultiplied?E:1),this.b=Vr(Vr(Vr(Ge[Xe+2],Ge[rt+2],Ie),Vr(Ge[_t+2],Ge[ft+2],Ie),Le),Vr(Vr(Ge[St+2],Ge[It+2],Ie),Vr(Ge[$t+2],Ge[as+2],Ie),Le),je)/255*(this.premultiplied?E:1),this.a=E}else this.r=m,this.g=y,this.b=k,this.a=E}toArray(){const{r:c,g:m,b:y,a:k}=this;return[255*c,255*m,255*y,k]}toHslaArray(){let{r:c,g:m,b:y,a:k}=this;if(this.premultiplied){if(k===0)return[0,0,0,0];const ue=1/k;c*=ue,m*=ue,y*=ue}const E=Math.min(Math.max(c,0),1),P=Math.min(Math.max(m,0),1),O=Math.min(Math.max(y,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,k];const ne=ee>.5?J/(2-W-B):J/(W+B);let ce;switch(W){case E:ce=60*((P-O)/J+(PVr(y,c[k],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 wy=Object.freeze({__proto__:null,array:by,color:function(f,c,m){return new Fr(Vr(f.r,c.r,m),Vr(f.g,c.g,m),Vr(f.b,c.b,m),Vr(f.a,c.a,m))},number:Vr});class sm extends Error{constructor(c,m){super(m),this.message=m,this.key=c}}class uv{constructor(c,m=[]){this.parent=c,this.bindings={};for(const[y,k]of m)this.bindings[y]=k}concat(c){return new uv(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 qm={kind:"null"},Or={kind:"number"},wa={kind:"string"},mi={kind:"boolean"},ju={kind:"color"},Mp={kind:"object"},ri={kind:"value"},mS={kind:"collator"},nb={kind:"formatted"},ab={kind:"resolvedImage"};function md(f,c){return{kind:"array",itemType:f,N:c}}function nl(f){if(f.kind==="array"){const c=nl(f.itemType);return typeof f.N=="number"?`array<${c}, ${f.N}>`:f.itemType.kind==="value"?"array":`array<${c}>`}return f.kind}const Pce=[qm,Or,wa,mi,ju,nb,Mp,md(ri),ab];function ex(f,c){if(c.kind==="error")return null;if(f.kind==="array"){if(c.kind==="array"&&(c.N===0&&c.itemType.kind==="value"||!ex(f.itemType,c.itemType))&&(typeof f.N!="number"||f.N===c.N))return null}else{if(f.kind===c.kind)return null;if(f.kind==="value"){for(const m of Pce)if(!ex(m,c))return null}}return`Expected ${nl(f)} but found ${nl(c)} instead.`}function HM(f,c){return c.some(m=>m.kind===f.kind)}function ib(f,c){return c.some(m=>m==="null"?f===null:m==="array"?Array.isArray(f):m==="object"?f&&!Array.isArray(f)&&typeof f=="object":m===typeof f)}function pS(f,c){return f.kind==="array"&&c.kind==="array"?f.N===c.N&&pS(f.itemType,c.itemType):f.kind===c.kind}class WM{constructor(c,m,y){this.sensitivity=c?m?"variant":"case":m?"accent":"base",this.locale=y,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 fS{constructor(c,m,y,k,E){this.text=c.normalize?c.normalize():c,this.image=m,this.scale=y,this.fontStack=k,this.textColor=E}}class Zd{constructor(c){this.sections=c}static fromString(c){return new Zd([new fS(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 Zd?c:Zd.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 k=m.image.getPrimary().id.toString();c.push(["image",k]);continue}c.push(m.text);const y={};m.fontStack&&(y["text-font"]=["literal",m.fontStack.split(",")]),m.scale&&(y["font-scale"]=m.scale),m.textColor&&(y["text-color"]=["rgba"].concat(m.textColor.toNonPremultipliedRenderColor(null).toArray())),c.push(y)}return c}}class Ff{constructor(c,m={}){this.id=Ws.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,y,k,E;try{({id:m,params:y,sx:k,sy:E}=JSON.parse(c)||{})}catch{return null}return m?new Ff(m,{params:y,sx:k,sy:E}):null}scaleSelf(c,m=c){return this.sx*=c,this.sy*=m,this}}class Yd{constructor(c,m,y,k,E=!1){this.primaryId=Ws.from(c),this.primaryOptions=m,y&&(this.secondaryId=Ws.from(y)),this.secondaryOptions=k,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 Ff(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new Ff(this.secondaryId,this.secondaryOptions):null}static from(c){return typeof c=="string"?Yd.build({name:c}):c}static build(c,m,y,k){return!c||typeof c=="object"&&!("name"in c)?null:new Yd(c,y,m,k)}}function jy(f,c,m,y){return typeof f=="number"&&f>=0&&f<=255&&typeof c=="number"&&c>=0&&c<=255&&typeof m=="number"&&m>=0&&m<=255?y===void 0||typeof y=="number"&&y>=0&&y<=1?null:`Invalid rgba value [${[f,c,m,y].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof y=="number"?[f,c,m,y]:[f,c,m]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function hv(f){if(f===null||typeof f=="string"||typeof f=="boolean"||typeof f=="number"||f instanceof Fr||f instanceof WM||f instanceof Zd||f instanceof Yd)return!0;if(Array.isArray(f)){for(const c of f)if(!hv(c))return!1;return!0}if(typeof f=="object"){for(const c in f)if(!hv(f[c]))return!1;return!0}return!1}function nc(f){if(f===null)return qm;if(typeof f=="string")return wa;if(typeof f=="boolean")return mi;if(typeof f=="number")return Or;if(f instanceof Fr)return ju;if(f instanceof WM)return mS;if(f instanceof Zd)return nb;if(f instanceof Yd)return ab;if(Array.isArray(f)){const c=f.length;let m;for(const y of f){const k=nc(y);if(m){if(m===k)continue;m=ri;break}m=k}return md(m||ri,c)}return Mp}function rm(f){const c=typeof f;return f===null?"":c==="string"||c==="number"||c==="boolean"?String(f):f instanceof Zd||f instanceof Yd||f instanceof Fr?f.toString():JSON.stringify(f)}class zf{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(!hv(c[1]))return m.error("invalid value");const y=c[1];let k=nc(y);const E=m.expectedType;return k.kind!=="array"||k.N!==0||!E||E.kind!=="array"||typeof E.N=="number"&&E.N!==0||(k=E),new zf(k,y)}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 Zd?this.value.serialize():this.value}}class ql{constructor(c){this.name="ExpressionEvaluationError",this.message=c}toJSON(){return this.message}}const GM={string:wa,number:Or,boolean:mi,object:Mp};class Um{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 y,k=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 GM)||W==="object")return m.error('The item type argument of "array" must be one of string, number, boolean',1);O=GM[W],k++}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],k++}y=md(O,B)}else y=GM[E];const P=[];for(;kc.outputDefined())}serialize(){const c=this.type,m=[c.kind];if(c.kind==="array"){const y=c.itemType;if(y.kind==="string"||y.kind==="number"||y.kind==="boolean"){m.push(y.kind);const k=c.N;(typeof k=="number"||this.args.length>1)&&m.push(k)}}return m.concat(this.args.map(y=>y.serialize()))}}class Tp{constructor(c){this.type=nb,this.sections=c}static parse(c,m){if(c.length<2)return m.error("Expected at least one argument.");const y=c[1];if(!Array.isArray(y)&&typeof y=="object")return m.error("First argument must be an image or text section.");const k=[];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",Or),!B))return null;let W=null;if(O["text-font"]&&(W=m.parseObjectValue(O["text-font"],P,"text-font",md(wa)),!W))return null;let J=null;if(O["text-color"]&&(J=m.parseObjectValue(O["text-color"],P,"text-color",ju),!J))return null;const ee=k[k.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,k.push({content:B,scale:null,font:null,textColor:null})}}return new Tp(k)}evaluate(c){return new Zd(this.sections.map(m=>{const y=m.content.evaluate(c);return pS(nc(y),ab)?new fS("",y,null,null,null):new fS(rm(y),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 y={};m.scale&&(y["font-scale"]=m.scale.serialize()),m.font&&(y["text-font"]=m.font.serialize()),m.textColor&&(y["text-color"]=m.textColor.serialize()),c.push(y)}return c}}class Dn{constructor(c,m,y,k){this._imageWarnHistory={},this.type=ab,this.namePrimary=c,this.nameSecondary=m,y&&(this.paramsPrimary=y.params,this.iconsetIdPrimary=y.iconset?y.iconset.id:void 0),k&&(this.paramsSecondary=k.params,this.iconsetIdSecondary=k.iconset?k.iconset.id:void 0)}static parse(c,m){if(c.length<2)return m.error("Expected two or more arguments.");let y=1;const k=[];function E(){if(yWs.isEqual(P,E)),k.available){const P=k.getSecondary()?k.getSecondary().id:null;P&&(k.available=c.availableImages.some(O=>Ws.isEqual(O,P)))}}return k}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 y={};if(m&&(y.iconset={id:m}),c){y.params={};for(const k in c)c[k]&&(y.params[k]=c[k].serialize())}return Object.keys(y).length>0?y: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 Pr(f){return dn(f)?"string":mv(f)?"number":xS(f)?"boolean":Array.isArray(f)?"array":f===null?"null":gS(f)?"object":typeof f}function gS(f){return f!=null&&!Array.isArray(f)&&typeof f!="function"&&!(f instanceof String||f instanceof Number||f instanceof Boolean)&&typeof f=="object"}function dn(f){return typeof f=="string"||f instanceof String}function mv(f){return typeof f=="number"||f instanceof Number}function xS(f){return typeof f=="boolean"||f instanceof Boolean}const nn={"to-boolean":mi,"to-color":ju,"to-number":Or,"to-string":wa};class Ap{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 y=c[0],k=[];let E=qm;if(y==="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&&hv(c[1][0])))return null;E=md(nc(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.`:jy(m[0],m[1],m[2],m[3]),!y))return new Fr(m[0]/255,m[1]/255,m[2]/255,m[3])}throw new ql(y||`Could not parse color from value '${typeof m=="string"?m:String(JSON.stringify(m))}'`)}if(this.type.kind==="number"){let m=null;for(const y of this.args){if(m=y.evaluate(c),m===null)return 0;const k=Number(m);if(!isNaN(k))return k}throw new ql(`Could not convert ${JSON.stringify(m)} to number.`)}return this.type.kind==="formatted"?Zd.fromString(rm(this.args[0].evaluate(c))):this.type.kind==="resolvedImage"?Yd.build(rm(this.args[0].evaluate(c))):this.type.kind==="array"?this.args.map(m=>m.evaluate(c)):rm(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 Tp([{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 KM=["Unknown","Point","LineString","Polygon"];class yS{constructor(c,m,y){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=y}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?KM[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:y,y:k}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(y*m-c[0])+this.featureDistanceData.bearing[1]*(k*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 Xd{constructor(c,m,y,k,E){this.name=c,this.type=m,this._evaluate=y,this.args=k,this._overloadIndex=E}evaluate(c){if(!this._evaluate){const m=Xd.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 y=c[0],k=Xd.definitions[y];if(!k)return m.error(`Unknown expression "${y}". If you wanted a literal array, use ["literal", [...]].`,0);const E=Array.isArray(k)?k[0]:k.type,P=Array.isArray(k)?[[k[1],k[2]]]:k.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 AS(m.registry,m.path,null,m.scope,void 0,m._scope,m.options,m.iconImageUseTheme);const ne=[];let ce=!1;for(let ue=1;uene)).map(vS).join(" | "),ee=[];for(let ne=1;nem;){if(y-m>600){const B=y-m+1,W=c-m+1,J=Math.log(B),ee=.5*Math.exp(2*J/3),ne=.5*Math.sqrt(J*ee*(B-ee)/B)*(W-B/2<0?-1:1);_S(f,c,Math.max(m,Math.floor(c-W*ee/B+ne)),Math.min(y,Math.floor(c+(B-W)*ee/B+ne)),k)}const E=f[c];let P=m,O=y;for(Vm(f,m,c),k(f[y],E)>0&&Vm(f,m,y);P0;)O--}k(f[m],E)===0?Vm(f,m,O):(O++,Vm(f,O,y)),O<=c&&(m=O+1),c<=O&&(y=O-1)}}function Vm(f,c,m){const y=f[c];f[c]=f[m],f[m]=y}function ZM(f,c){return fc?1:0}function tx(f){let c=0;for(let m,y,k=0,E=f.length,P=E-1;k=c[2]||f[1]<=c[1]||f[3]>=c[3])}function Ice(f,c,m){const y=f[0]-c[0],k=f[1]-c[1],E=f[0]-m[0],P=f[1]-m[1];return y*P-E*k==0&&y*E<=0&&k*P<=0}function pv(f,c,m=!1){let y=!1;for(let O=0,B=c.length;O(k=f)[1]!=(P=ue)[1]>k[1]&&k[0]<(P[0]-E[0])*(k[1]-E[1])/(P[1]-E[1])+E[0]&&(y=!y)}}var k,E,P;return y}function lb(f,c,m,y){const k=y[0]-m[0],E=y[1]-m[1],P=(f[0]-m[0])*E-k*(f[1]-m[1]),O=(c[0]-m[0])*E-k*(c[1]-m[1]);return P>0&&O<0||P<0&&O>0}function cb(f,c,m,y){return(k=[y[0]-m[0],y[1]-m[1]])[0]*(E=[c[0]-f[0],c[1]-f[1]])[1]-k[1]*E[0]!=0&&!(!lb(f,c,m,y)||!lb(m,y,f,c));var k,E}function Bf(f){const c=new rs(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),m=new rs(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const y of f[0])c.x>y.x&&(c.x=y.x),c.y>y.y&&(c.y=y.y),m.xm[2]){const k=.5*y;let E=f[0]-m[0]>k?-y:m[0]-f[0]>k?y:0;E===0&&(E=f[0]-m[2]>k?-y:m[2]-f[0]>k?y:0),f[0]+=E}nm(c,f)}function lD(f,c,m,y){const k=Math.pow(2,y.z)*sx,E=[y.x*sx,y.y*sx],P=[];if(!f)return P;for(const O of f)for(const B of O){const W=[B.x+E[0],B.y+E[1]];oD(W,c,m,k),P.push(W)}return P}function bS(f,c,m,y){const k=Math.pow(2,y.z)*sx,E=[y.x*sx,y.y*sx],P=[];if(!f)return P;for(const B of f){const W=[];for(const J of B){const ee=[J.x+E[0],J.y+E[1]];nm(c,ee),W.push(ee)}P.push(W)}if(c[2]-c[0]<=k/2){(O=c)[0]=O[1]=1/0,O[2]=O[3]=-1/0;for(const B of P)for(const W of B)oD(W,c,m,k)}var O;return P}class nx{constructor(c,m){this.type=mi,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(hv(c[1])){const y=c[1];if(y.type==="FeatureCollection")for(let k=0;km)return wS(E,P,(m-(y-O))/O)}return c[c.length-1]}pointToSegmentDistance(c,m,y){let[k,E]=m,P=ph(y[0]-k)*this.kx,O=(y[1]-E)*this.ky;if(P!==0||O!==0){const B=(ph(c[0]-k)*this.kx*P+(c[1]-E)*this.ky*O)/(P*P+O*O);B>1?(k=y[0],E=y[1]):B>0&&(k+=P/this.kx*B,E+=O/this.ky*B)}return P=ph(c[0]-k)*this.kx,O=(c[1]-E)*this.ky,Math.sqrt(P*P+O*O)}pointOnLine(c,m){let y=1/0,k=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+=ne/this.ky*ce)),ee=ph(m[0]-W)*this.kx,ne=(m[1]-J)*this.ky;const ue=ee*ee+ne*ne;ueE.index||k.index===E.index&&k.t>E.t){const W=k;k=E,E=W}const P=[k.point],O=k.index+1,B=E.index;!QM(y[O],P[0])&&O<=B&&P.push(y[O]);for(let W=O+1;W<=B;W++)P.push(y[W]);return QM(y[B],E.point)||P.push(E.point),P}lineSliceAlong(c,m,y){let k=0;const E=[];for(let P=0;Pc&&E.length===0&&E.push(wS(O,B,(c-(k-W))/W)),k>=m)return E.push(wS(O,B,(m-(k-W))/W)),E;k>c&&E.push(B)}return E}bufferPoint(c,m){const y=m/this.ky,k=m/this.kx;return[c[0]-k,c[1]-y,c[0]+k,c[1]+y]}bufferBBox(c,m){const y=m/this.ky,k=m/this.kx;return[c[0]-k,c[1]-y,c[2]+k,c[3]+y]}insideBBox(c,m){return ph(c[0]-m[0])>=0&&ph(c[0]-m[2])<=0&&c[1]>=m[1]&&c[1]<=m[3]}}function QM(f,c){return f[0]===c[0]&&f[1]===c[1]}function wS(f,c,m){const y=ph(c[0]-f[0]);return[f[0]+y*m,f[1]+(c[1]-f[1])*m]}function ph(f){for(;f<-180;)f+=360;for(;f>180;)f-=360;return f}class jS{constructor(c=[],m=(y,k)=>yk?1:0){if(this.data=c,this.length=this.data.length,this.compare=m,this.length>0)for(let y=(this.length>>1)-1;y>=0;y--)this._down(y)}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:y}=this,k=m[c];for(;c>0;){const E=c-1>>1,P=m[E];if(y(k,P)>=0)break;m[c]=P,c=E}m[c]=k}_down(c){const{data:m,compare:y}=this,k=this.length>>1,E=m[c];for(;c=0)break;m[c]=m[P],c=P}m[c]=E}}var Ys=8192;function JM(f,c){return c.dist-f.dist}const kS=100,NS=50;function eT(f){const c=[1/0,1/0,-1/0,-1/0];if(c.length!==f.length)return!1;for(let m=0;m=f[0]&&f[1]f[1])return[null,null];const m=ub(f);if(c){if(m===2)return[f,null];const y=Math.floor(m/2);return[[f[0],f[0]+y],[f[0]+y,f[1]]]}{if(m===1)return[f,null];const y=Math.floor(m/2)-1;return[[f[0],f[0]+y],[f[0]+y+1,f[1]]]}}function ky(f,c){const m=[1/0,1/0,-1/0,-1/0];if(!Ep(c,f.length))return m;for(let y=c[0];y<=c[1];++y)nm(m,f[y]);return m}function Ny(f){const c=[1/0,1/0,-1/0,-1/0];for(let m=0;mc[2]&&(y=f[0]-c[2]),f[1]>c[3]&&(k=f[1]-c[3]),f[3]=y)return y;if(ob(k,E)){if(rT(f,c))return 0}else if(rT(c,f))return 0;let P=y;for(const O of f)for(let B=0,W=O.length,J=W-1;B=E)continue;const J=W.range1;if(ub(J)<=O){if(!Ep(J,f.length))return NaN;if(c){const ee=zce(f,J,m,y);if((E=Math.min(E,ee))===0)return E}else for(let ee=J[0];ee<=J[1];++ee){const ne=Fce(f[ee],m,y);if((E=Math.min(E,ne))===0)return E}}else{const ee=tT(J,c);if(ee[0]!==null){const ne=ax(ky(f,ee[0]),B,y);ne=P)continue;const ee=J.range1,ne=J.range2;if(ub(ee)<=B&&ub(ne)<=W){if(!Ep(ee,f.length)||!Ep(ne,m.length))return NaN;if(c&&y?P=Math.min(P,ka(f,ee,m,ne,k)):c||y?c&&!y?P=Math.min(P,sT(m,ne,f,ee,k)):!c&&y&&(P=Math.min(P,sT(f,ee,m,ne,k))):P=Math.min(P,Rce(f,ee,m,ne,k)),P===0)return P}else{const ce=tT(ee,c),ue=tT(ne,y);to(O,P,k,f,m,ce[0],ue[0]),to(O,P,k,f,m,ce[0],ue[1]),to(O,P,k,f,m,ce[1],ue[0]),to(O,P,k,f,m,ce[1],ue[1])}}return P}function nT(f,c,m,y,k=1/0){let E=k;const P=ky(f,[0,f.length-1]);for(const O of m)if(!(E!==1/0&&ax(P,ky(O,[0,O.length-1]),y)>=E)&&(E=Math.min(E,hD(f,c,O,!0,y,E)),E===0))return E;return E}function MS(f,c,m,y,k=1/0){let E=k;const P=ky(f,[0,f.length-1]);for(const O of m){if(E!==1/0&&ax(P,Ny(O),y)>=E)continue;const B=$ce(f,c,O,y,E);if(isNaN(B))return B;if((E=Math.min(E,B))===0)return E}return E}function aT(f){return f==="Point"||f==="MultiPoint"||f==="LineString"||f==="MultiLineString"||f==="Polygon"||f==="MultiPolygon"}class Sy{constructor(c,m){this.type=Or,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(hv(c[1])){const y=c[1];if(y.type==="FeatureCollection"){for(let k=0;k{c&&!xv(m)&&(c=!1)}),c}function hb(f){if(f instanceof Xd&&f.name==="feature-state")return!1;let c=!0;return f.eachChild(m=>{c&&!hb(m)&&(c=!1)}),c}function yv(f,c){if(f instanceof Xd&&c.indexOf(f.name)>=0)return!1;let m=!0;return f.eachChild(y=>{m&&!yv(y,c)&&(m=!1)}),m}function mD(f,c,m){return[f,c,m].filter(Boolean).join("")}function iT(f,c){switch(f){case"string":return rm(c);case"number":return+c;case"boolean":return!!c;case"color":return Fr.parse(c);case"formatted":return Zd.fromString(rm(c));case"resolvedImage":return Yd.build(rm(c))}return c}function pD(f,c,m,y){return y!==void 0&&(f=y*Math.round(f/y)),c!==void 0&&fm&&(f=m),f}class vv{constructor(c,m,y,k=!1){this.type=c,this.key=m,this.scope=y,this.featureConstant=k}static parse(c,m){let y=m.expectedType;if(y==null&&(y=ri),c.length<2||c.length>3)return m.error("Invalid number of arguments for 'config' expression.");const k=m.parse(c[1],1);if(!(k instanceof zf))return m.error("Key name of 'config' expression must be a string literal.");let E,P=!0;const O=rm(k.value);if(c.length>=3){const B=m.parse(c[2],2);if(!(B instanceof zf))return m.error("Scope of 'config' expression must be a string literal.");E=rm(B.value)}if(m.options){const B=mD(O,E,m._scope),W=m.options.get(B);W&&(P=xv(W.value||W.default))}return new vv(y,O,E,P)}evaluate(c){const m=mD(this.key,this.scope,c.scope),y=c.getConfig(m);if(!y)return null;const{type:k,value:E,values:P,minValue:O,maxValue:B,stepValue:W}=y,J=y.default.evaluate(c);let ee=J;if(E){const ne=c.scope;c.scope=(ne||"").split("").slice(1).join(""),ee=E.evaluate(c),c.scope=ne}return k&&(ee=iT(k,ee)),ee===void 0||O===void 0&&B===void 0&&W===void 0||(typeof ee=="number"?ee=pD(ee,O,B,W):Array.isArray(ee)&&(ee=ee.map(ne=>typeof ne=="number"?pD(ne,O,B,W):ne))),E!==void 0&&ee!==void 0&&P&&!P.includes(ee)&&(ee=J,k&&(ee=iT(k,ee))),(k&&k!==this.type||ee!==void 0&&!pS(nc(ee),this.type))&&(ee=iT(this.type.kind,ee)),ee}eachChild(){}outputDefined(){return!1}serialize(){const c=["config",this.key];return this.scope&&c.concat(this.scope),c}}class TS{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 y=c[1];return m.scope.has(y)?new TS(y,m.scope.get(y)):m.error(`Unknown variable "${y}". Make sure "${y}" 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 AS{constructor(c,m=[],y,k=new uv,E=[],P,O,B){this.registry=c,this.path=m,this.key=m.map(W=>typeof W=="string"?`['${W}']`:`[${W}]`).join(""),this.scope=k,this.errors=E,this.expectedType=y,this._scope=P,this.options=O,this.iconImageUseTheme=B}parse(c,m,y,k,E={}){return m||y?this.concat(m,null,y,k)._parse(c,E):this._parse(c,E)}parseObjectValue(c,m,y,k,E,P={}){return this.concat(m,y,k,E)._parse(c,P)}_parse(c,m){function y(k,E,P){return P==="assert"?new Um(E,[k]):P==="coerce"?new Ap(E,[k]):k}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 k=typeof c[0]=="string"?this.registry[c[0]]:void 0;if(k){let E=k.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=y(E,P,m.typeAnnotation||"coerce");else E=y(E,P,m.typeAnnotation||"assert")}if(!(E instanceof zf)&&E.type.kind!=="resolvedImage"&&oT(E)){const P=new yS(this._scope,this.options,this.iconImageUseTheme);try{E=new zf(E.type,E.evaluate(P))}catch(O){return this.error(O.message),null}}return E}return Ap.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,y,k){let E=typeof c=="number"?this.path.concat(c):this.path;E=typeof m=="string"?E.concat(m):E;const P=k?this.scope.concat(k):this.scope;return new AS(this.registry,E,y||null,P,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(c,...m){const y=`${this.key}${m.map(k=>`[${k}]`).join("")}`;this.errors.push(new sm(y,c))}checkSubtype(c,m){const y=ex(c,m);return y&&this.error(y),y}}function oT(f){if(f instanceof TS)return oT(f.boundExpression);if(f instanceof Xd&&f.name==="error"||f instanceof xc||f instanceof nx||f instanceof Sy||f instanceof vv)return!1;const c=f instanceof Ap||f instanceof Um;let m=!0;return f.eachChild(y=>{m=c?m&&oT(y):m&&y instanceof zf}),!!m&&xv(f)&&yv(f,["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 ES(f,c){const m=f.length-1;let y,k,E=0,P=m,O=0;for(;E<=P;)if(O=Math.floor((E+P)/2),y=f[O],k=f[O+1],y<=c){if(O===m||cc))throw new ql("Input is not a number.");P=O-1}return 0}class mb{constructor(c,m,y){this.type=c,this.input=m,this.labels=[],this.outputs=[];for(const[k,E]of y)this.labels.push(k),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 y=m.parse(c[1],1,Or);if(!y)return null;const k=[];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,k.push([O,ee])}return new mb(E,y,k)}evaluate(c){const m=this.labels,y=this.outputs;if(m.length===1)return y[0].evaluate(c);const k=this.input.evaluate(c);if(k<=m[0])return y[0].evaluate(c);const E=m.length;return k>=m[E-1]?y[E-1].evaluate(c):y[ES(m,k)].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 fD=.95047,gD=1.08883,xD=4/29,_v=6/29,yD=3*_v*_v,qce=_v*_v*_v,Uce=Math.PI/180,Vce=180/Math.PI;function lT(f){return f>qce?Math.pow(f,1/3):f/yD+xD}function cT(f){return f>_v?f*f*f:yD*(f-xD)}function dT(f){return 255*(f<=.0031308?12.92*f:1.055*Math.pow(f,1/2.4)-.055)}function uT(f){return(f/=255)<=.04045?f/12.92:Math.pow((f+.055)/1.055,2.4)}function vD(f){const c=uT(f.r),m=uT(f.g),y=uT(f.b),k=lT((.4124564*c+.3575761*m+.1804375*y)/fD),E=lT((.2126729*c+.7151522*m+.072175*y)/1);return{l:116*E-16,a:500*(k-E),b:200*(E-lT((.0193339*c+.119192*m+.9503041*y)/gD)),alpha:f.a}}function PS(f){let c=(f.l+16)/116,m=isNaN(f.a)?c:c+f.a/500,y=isNaN(f.b)?c:c-f.b/200;return c=1*cT(c),m=fD*cT(m),y=gD*cT(y),new Fr(dT(3.2404542*m-1.5371385*c-.4985314*y),dT(-.969266*m+1.8760108*c+.041556*y),dT(.0556434*m-.2040259*c+1.0572252*y),f.alpha)}function IS(f,c,m){const y=c-f;return f+m*(y>180||y<-180?y-360*Math.round(y/360):y)}const bv={forward:vD,reverse:PS,interpolate:function(f,c,m){return{l:Vr(f.l,c.l,m),a:Vr(f.a,c.a,m),b:Vr(f.b,c.b,m),alpha:Vr(f.alpha,c.alpha,m)}}},pb={forward:function(f){const{l:c,a:m,b:y}=vD(f),k=Math.atan2(y,m)*Vce;return{h:k<0?k+360:k,c:Math.sqrt(m*m+y*y),l:c,alpha:f.a}},reverse:function(f){const c=f.h*Uce,m=f.c;return PS({l:f.l,a:Math.cos(c)*m,b:Math.sin(c)*m,alpha:f.alpha})},interpolate:function(f,c,m){return{h:IS(f.h,c.h,m),c:Vr(f.c,c.c,m),l:Vr(f.l,c.l,m),alpha:Vr(f.alpha,c.alpha,m)}}};var _D=Object.freeze({__proto__:null,hcl:pb,lab:bv});class fh{constructor(c,m,y,k,E){this.type=c,this.operator=m,this.interpolation=y,this.input=k,this.labels=[],this.outputs=[];for(const[P,O]of E)this.labels.push(P),this.outputs.push(O)}static interpolationFactor(c,m,y,k){let E=0;if(c.name==="exponential")E=LS(m,c.base,y,k);else if(c.name==="linear")E=LS(m,1,y,k);else if(c.name==="cubic-bezier"){const P=c.controlPoints;E=new Rn(P[0],P[1],P[2],P[3]).solve(LS(m,1,y,k))}return E}static parse(c,m){let[y,k,E,...P]=c;if(!Array.isArray(k)||k.length===0)return m.error("Expected an interpolation type expression.",1);if(k[0]==="linear")k={name:"linear"};else if(k[0]==="exponential"){const W=k[1];if(typeof W!="number")return m.error("Exponential interpolation requires a numeric base.",1,1);k={name:"exponential",base:W}}else{if(k[0]!=="cubic-bezier")return m.error(`Unknown interpolation type ${String(k[0])}`,1,0);{const W=k.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);k={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,Or),!E)return null;const O=[];let B=null;y==="interpolate-hcl"||y==="interpolate-lab"?B=ju: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.',ne);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 fh(B,y,k,E,O):m.error(`Type ${nl(B)} is not interpolatable.`)}evaluate(c){const m=this.labels,y=this.outputs;if(m.length===1)return y[0].evaluate(c);const k=this.input.evaluate(c);if(k<=m[0])return y[0].evaluate(c);const E=m.length;if(k>=m[E-1])return y[E-1].evaluate(c);const P=ES(m,k),O=fh.interpolationFactor(this.interpolation,k,m[P],m[P+1]),B=y[P].evaluate(c),W=y[P+1].evaluate(c);return this.operator==="interpolate"?wy[this.type.kind.toLowerCase()](B,W,O):this.operator==="interpolate-hcl"?pb.reverse(pb.interpolate(pb.forward(B),pb.forward(W),O)):bv.reverse(bv.interpolate(bv.forward(B),bv.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 y=0;yex(k,O.type));return new fb(P?ri:y,E)}evaluate(c){let m,y=null,k=0;for(const E of this.args){if(k++,y=E.evaluate(c),y&&y instanceof Yd&&!y.available&&(m||(m=y),y=null,k===this.args.length))return m;if(y!==null)break}return y}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 $f{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 y=[];for(let E=1;E=y.length)throw new ql("Array index out of bounds: index exceeds array size");if(m!==Math.floor(m))throw new ql("Array index must be an integer. Use at-interpolated for fractional indices");return y[m]}eachChild(c){c(this.index),c(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class OS{constructor(c,m,y){this.type=c,this.index=m,this.input=y}static parse(c,m){if(c.length!==3)return m.error(`Expected 2 arguments, but found ${c.length-1} instead.`);const y=m.parse(c[1],1,Or),k=m.parse(c[2],2,md(m.expectedType||ri));return y&&k?new OS(k.type.itemType,y,k):null}evaluate(c){const m=this.index.evaluate(c),y=this.input.evaluate(c);if(m<0)throw new ql(`Array index out of bounds: ${m} < 0.`);if(m>y.length-1)throw new ql(`Array index out of bounds: ${m} > ${y.length-1}.`);if(m===Math.floor(m))return y[m];const k=Math.floor(m),E=Math.ceil(m),P=y[k],O=y[E];if(typeof P!="number"||typeof O!="number")throw new ql(`Cannot interpolate between non-number values at index ${m}.`);const B=m-k;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 hT{constructor(c,m){this.type=mi,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 y=m.parse(c[1],1,ri),k=m.parse(c[2],2,ri);return y&&k?HM(y.type,[mi,wa,Or,qm,ri])?new hT(y,k):m.error(`Expected first argument to be of type boolean, string, number or null, but found ${nl(y.type)} instead`):null}evaluate(c){const m=this.needle.evaluate(c),y=this.haystack.evaluate(c);if(y==null)return!1;if(!ib(m,["boolean","string","number","null"]))throw new ql(`Expected first argument to be of type boolean, string, number or null, but found ${nl(nc(m))} instead.`);if(!ib(y,["string","array"]))throw new ql(`Expected second argument to be of type array or string, but found ${nl(nc(y))} instead.`);return y.indexOf(m)>=0}eachChild(c){c(this.needle),c(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class wv{constructor(c,m,y){this.type=Or,this.needle=c,this.haystack=m,this.fromIndex=y}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 y=m.parse(c[1],1,ri),k=m.parse(c[2],2,ri);if(!y||!k)return null;if(!HM(y.type,[mi,wa,Or,qm,ri]))return m.error(`Expected first argument to be of type boolean, string, number or null, but found ${nl(y.type)} instead`);if(c.length===4){const E=m.parse(c[3],3,Or);return E?new wv(y,k,E):null}return new wv(y,k)}evaluate(c){const m=this.needle.evaluate(c),y=this.haystack.evaluate(c);if(!ib(m,["boolean","string","number","null"]))throw new ql(`Expected first argument to be of type boolean, string, number or null, but found ${nl(nc(m))} instead.`);if(!ib(y,["string","array"]))throw new ql(`Expected second argument to be of type array or string, but found ${nl(nc(y))} instead.`);if(this.fromIndex){const k=this.fromIndex.evaluate(c);return y.indexOf(m,k)}return y.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 gb{constructor(c,m,y,k,E,P){this.inputType=c,this.type=m,this.input=y,this.cases=k,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 y,k;m.expectedType&&m.expectedType.kind!=="value"&&(k=m.expectedType);const E={},P=[];for(let W=2;WNumber.MAX_SAFE_INTEGER)return ne.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof ue=="number"&&Math.floor(ue)!==ue)return ne.error("Numeric branch labels must be integer values.");if(y){if(ne.checkSubtype(y,nc(ue)))return null}else y=nc(ue);if(E[String(ue)]!==void 0)return ne.error("Branch labels must be unique.");E[String(ue)]=P.length}const ce=m.parse(ee,W,k);if(!ce)return null;k=k||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,k);return B?O.type.kind!=="value"&&m.concat(1).checkSubtype(y,O.type)?null:new gb(y,k,O,E,P,B):null}evaluate(c){const m=this.input.evaluate(c);return(pS(nc(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(),y=[],k={};for(const P of m){const O=k[this.cases[P]];O===void 0?(k[this.cases[P]]=y.length,y.push([this.cases[P],[P]])):y[O][1].push(P)}const E=P=>this.inputType.kind==="number"?Number(P):P;for(const[P,O]of y)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 xb{constructor(c,m,y){this.type=c,this.branches=m,this.otherwise=y}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 y;m.expectedType&&m.expectedType.kind!=="value"&&(y=m.expectedType);const k=[];for(let P=1;Pm.outputDefined())&&this.otherwise.outputDefined()}serialize(){const c=["case"];return this.eachChild(m=>{c.push(m.serialize())}),c}}class RS{constructor(c,m,y,k){this.type=c,this.input=m,this.beginIndex=y,this.endIndex=k}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 y=m.parse(c[1],1,ri),k=m.parse(c[2],2,Or);if(!y||!k)return null;if(!HM(y.type,[md(ri),wa,ri]))return m.error(`Expected first argument to be of type array or string, but found ${nl(y.type)} instead`);if(c.length===4){const E=m.parse(c[3],3,Or);return E?new RS(y.type,y,k,E):null}return new RS(y.type,y,k)}evaluate(c){const m=this.input.evaluate(c),y=this.beginIndex.evaluate(c);if(!ib(m,["string","array"]))throw new ql(`Expected first argument to be of type array or string, but found ${nl(nc(m))} instead.`);if(this.endIndex){const k=this.endIndex.evaluate(c);return m.slice(y,k)}return m.slice(y)}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 mT{constructor(c,m){this.type=md(wa),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 y=m.parse(c[1],1,wa),k=m.parse(c[2],2,wa);return y&&k?new mT(y,k):void 0}evaluate(c){const m=this.str.evaluate(c),y=this.delimiter.evaluate(c);return m.split(y)}eachChild(c){c(this.str),c(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function pT(f,c){return f==="=="||f==="!="?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 fT(f,c,m,y){return y.compare(c,m)===0}function jv(f,c,m){const y=f!=="=="&&f!=="!=";return class wBe{constructor(E,P,O){this.type=mi,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(!pT(O,B.type))return P.concat(1).error(`"${O}" comparisons are not supported for type '${nl(B.type)}'.`);let W=P.parse(E[2],2,ri);if(!W)return null;if(!pT(O,W.type))return P.concat(2).error(`"${O}" comparisons are not supported for type '${nl(W.type)}'.`);if(B.type.kind!==W.type.kind&&B.type.kind!=="value"&&W.type.kind!=="value")return P.error(`Cannot compare types '${nl(B.type)}' and '${nl(W.type)}'.`);y&&(B.type.kind==="value"&&W.type.kind!=="value"?B=new Um(W.type,[B]):B.type.kind!=="value"&&W.type.kind==="value"&&(W=new Um(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,mS),!J)return null}return new wBe(B,W,J)}evaluate(E){const P=this.lhs.evaluate(E),O=this.rhs.evaluate(E);if(y&&this.hasUntypedArgument){const B=nc(P),W=nc(O);if(B.kind!==W.kind||B.kind!=="string"&&B.kind!=="number")throw new ql(`Expected arguments for "${f}" to be (string, string) or (number, number), but found (${B.kind}, ${W.kind}) instead.`)}if(this.collator&&!y&&this.hasUntypedArgument){const B=nc(P),W=nc(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=[f];return this.eachChild(P=>{E.push(P.serialize())}),E}}}const Hce=jv("==",function(f,c,m){return c===m},fT),Wce=jv("!=",function(f,c,m){return c!==m},function(f,c,m,y){return!fT(0,c,m,y)}),bD=jv("<",function(f,c,m){return c",function(f,c,m){return c>m},function(f,c,m,y){return y.compare(c,m)>0}),FS=jv("<=",function(f,c,m){return c<=m},function(f,c,m,y){return y.compare(c,m)<=0}),Gce=jv(">=",function(f,c,m){return c>=m},function(f,c,m,y){return y.compare(c,m)>=0});class zS{constructor(c,m,y,k,E,P){this.type=wa,this.number=c,this.locale=m,this.currency=y,this.unit=k,this.minFractionDigits=E,this.maxFractionDigits=P}static parse(c,m){if(c.length!==3)return m.error("Expected two arguments.");const y=m.parse(c[1],1,Or);if(!y)return null;const k=c[2];if(typeof k!="object"||Array.isArray(k))return m.error("NumberFormat options argument must be an object.");let E=null;if(k.locale&&(E=m.parseObjectValue(k.locale,2,"locale",wa),!E))return null;let P=null;if(k.currency&&(P=m.parseObjectValue(k.currency,2,"currency",wa),!P))return null;let O=null;if(k.unit&&(O=m.parseObjectValue(k.unit,2,"unit",wa),!O))return null;let B=null;if(k["min-fraction-digits"]&&(B=m.parseObjectValue(k["min-fraction-digits"],2,"min-fraction-digits",Or),!B))return null;let W=null;return k["max-fraction-digits"]&&(W=m.parseObjectValue(k["max-fraction-digits"],2,"max-fraction-digits",Or),!W)?null:new zS(y,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 gT{constructor(c){this.type=Or,this.input=c}static parse(c,m){if(c.length!==2)return m.error(`Expected 1 argument, but found ${c.length-1} instead.`);const y=m.parse(c[1],1);return y?y.type.kind!=="array"&&y.type.kind!=="string"&&y.type.kind!=="value"?m.error(`Expected argument of type string or array, but found ${nl(y.type)} instead.`):new gT(y):null}evaluate(c){const m=this.input.evaluate(c);if(typeof m=="string"||Array.isArray(m))return m.length;throw new ql(`Expected value to be of type string or array, but found ${nl(nc(m))} instead.`)}eachChild(c){c(this.input)}outputDefined(){return!1}serialize(){const c=["length"];return this.eachChild(m=>{c.push(m.serialize())}),c}}function jD(f){return function(){f=1831565813+(f|=0)|0;let c=Math.imul(f^f>>>15,1|f);return c=c+Math.imul(c^c>>>7,61|c)^c,((c^c>>>14)>>>0)/4294967296}}const kv={"==":Hce,"!=":Wce,">":wD,"<":bD,">=":Gce,"<=":FS,array:Um,at:DS,"at-interpolated":OS,boolean:Um,case:xb,coalesce:fb,collator:xc,format:Tp,image:Dn,in:hT,"index-of":wv,interpolate:fh,"interpolate-hcl":fh,"interpolate-lab":fh,length:gT,let:$f,literal:zf,match:gb,number:Um,"number-format":zS,object:Um,slice:RS,step:mb,string:Um,"to-boolean":Ap,"to-color":Ap,"to-number":Ap,"to-string":Ap,var:TS,within:nx,distance:Sy,config:vv,split:mT};function xT(f,[c,m,y,k]){c=c.evaluate(f),m=m.evaluate(f),y=y.evaluate(f);const E=k?k.evaluate(f):1,P=jy(c,m,y,E);if(P)throw new ql(P);return new Fr(c/255,m/255,y/255,E)}function yT(f,[c,m,y,k]){c=c.evaluate(f),m=m.evaluate(f),y=y.evaluate(f);const E=k?k.evaluate(f):1,P=function(W,J,ee,ne){return typeof W=="number"&&W>=0&&W<=360?typeof J=="number"&&J>=0&&J<=100&&typeof ee=="number"&&ee>=0&&ee<=100?ne===void 0||typeof ne=="number"&&ne>=0&&ne<=1?null:`Invalid hsla value [${[W,J,ee,ne].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof ne=="number"?[W,J,ee,ne]:[W,J,ee]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof ne=="number"?[W,J,ee,ne]:[W,J,ee]).join(", ")}]: 'h' must be between 0 and 360.`}(c,m,y,E);if(P)throw new ql(P);const O=`hsla(${c}, ${m}%, ${y}%, ${E})`,B=Fr.parse(O);if(!B)throw new ql(`Failed to parse HSLA color: ${O}`);return B}function kD(f,c){return f in c}function vT(f,c){const m=c[f];return m===void 0?null:m}function ox(f){return{type:f}}function Cy(f){if(f instanceof vv)return new Set([f.key]);let c=new Set;return f.eachChild(m=>{c=new Set([...c,...Cy(m)])}),c}function BS(f){if(f instanceof Xd&&f.name==="is-active-floor")return!0;let c=!1;return f.eachChild(m=>{!c&&BS(m)&&(c=!0)}),c}function ND(f){return{result:"success",value:f}}function lx(f){return{result:"error",value:f}}function _T(f,c){return!!f&&!!f.parameters&&f.parameters.indexOf(c)>-1}function yb(f){return f["property-type"]==="data-driven"}function SD(f){return _T(f.expression,"measure-light")}function CD(f){return _T(f.expression,"zoom")}function $S(f){return!!f.expression&&f.expression.interpolated}function qS(f){return typeof f=="object"&&f!==null&&!Array.isArray(f)}function MD(f){return f}function TD(f,c){const m=c.type==="color",y=f.stops&&typeof f.stops[0][0]=="object",k=y||!(y||f.property!==void 0),E=f.type||($S(c)?"exponential":"interval");if(m&&((f=Object.assign({},f)).stops&&(f.stops=f.stops.map(W=>[W[0],Fr.parse(W[1])])),f.default=Fr.parse(f.default?f.default:c.default)),f.colorSpace&&f.colorSpace!=="rgb"&&!_D[f.colorSpace])throw new Error(`Unknown color space: ${f.colorSpace}`);let P,O,B;if(E==="exponential")P=AD;else if(E==="interval")P=Zce;else if(E==="categorical"){P=Kce,O=Object.create(null);for(const W of f.stops)O[W[0]]=W[1];B=typeof f.stops[0][0]}else{if(E!=="identity")throw new Error(`Unknown function type "${E}"`);P=ED}if(y){const W={},J=[];for(let ce=0;cece[0]),evaluate:({zoom:ce},ue)=>AD({stops:ee,base:f.base},c,ce).evaluate(ce,ue)}}if(k){const W=E==="exponential"?{name:"exponential",base:f.base!==void 0?f.base:1}:null;return{kind:"camera",interpolationType:W,interpolationFactor:fh.interpolationFactor.bind(void 0,W),zoomStops:f.stops.map(J=>J[0]),evaluate:({zoom:J})=>P(f,c,J,O,B)}}return{kind:"source",evaluate(W,J){const ee=J&&J.properties?J.properties[f.property]:void 0;return ee===void 0?Pp(f.default,c.default):P(f,c,ee,O,B)}}}function Pp(f,c,m){return f!==void 0?f:c!==void 0?c:m!==void 0?m:void 0}function Kce(f,c,m,y,k){return Pp(typeof m===k?y[m]:void 0,f.default,c.default)}function Zce(f,c,m){if(!mv(m))return Pp(f.default,c.default);const y=f.stops.length;if(y===1||m<=f.stops[0][0])return f.stops[0][1];if(m>=f.stops[y-1][0])return f.stops[y-1][1];const k=ES(f.stops.map(E=>E[0]),m);return f.stops[k][1]}function AD(f,c,m){const y=f.base!==void 0?f.base:1;if(!mv(m))return Pp(f.default,c.default);const k=f.stops.length;if(k===1||m<=f.stops[0][0])return f.stops[0][1];if(m>=f.stops[k-1][0])return f.stops[k-1][1];const E=ES(f.stops.map(J=>J[0]),m),P=function(J,ee,ne,ce){const ue=ce-ne,je=J-ne;return ue===0?0:ee===1?je/ue:(Math.pow(ee,je)-1)/(Math.pow(ee,ue)-1)}(m,y,f.stops[E][0],f.stops[E+1][0]),O=f.stops[E][1],B=f.stops[E+1][1];let W=wy[c.type]||MD;if(f.colorSpace&&f.colorSpace!=="rgb"){const J=_D[f.colorSpace];W=(ee,ne)=>J.reverse(J.interpolate(J.forward(ee),J.forward(ne),P))}return typeof O.evaluate=="function"?{evaluate(...J){const ee=O.evaluate.apply(void 0,J),ne=B.evaluate.apply(void 0,J);if(ee!==void 0&&ne!==void 0)return W(ee,ne,P)}}:W(O,B,P)}function ED(f,c,m){return c.type==="color"?m=Fr.parse(m):c.type==="formatted"?m=Zd.fromString(m.toString()):c.type==="resolvedImage"?m=Yd.build(m.toString()):Pr(m)===c.type||c.type==="enum"&&c.values[m]||(m=void 0),Pp(m,f.default,c.default)}Xd.register(kv,{error:[{kind:"error"},[wa],(f,[c])=>{throw new ql(c.evaluate(f))}],typeof:[wa,[ri],(f,[c])=>nl(nc(c.evaluate(f)))],"to-rgba":[md(Or,4),[ju],(f,[c])=>c.evaluate(f).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[md(Or,4),[ju],(f,[c])=>c.evaluate(f).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[ju,[Or,Or,Or],xT],rgba:[ju,[Or,Or,Or,Or],xT],hsl:[ju,[Or,Or,Or],yT],hsla:[ju,[Or,Or,Or,Or],yT],has:{type:mi,overloads:[[[wa],(f,[c])=>kD(c.evaluate(f),f.properties())],[[wa,Mp],(f,[c,m])=>kD(c.evaluate(f),m.evaluate(f))]]},get:{type:ri,overloads:[[[wa],(f,[c])=>vT(c.evaluate(f),f.properties())],[[wa,Mp],(f,[c,m])=>vT(c.evaluate(f),m.evaluate(f))]]},"feature-state":[ri,[wa],(f,[c])=>vT(c.evaluate(f),f.featureState||{})],properties:[Mp,[],f=>f.properties()],"geometry-type":[wa,[],f=>f.geometryType()],worldview:[wa,[],f=>f.globals.worldview||""],"is-active-floor":[mi,ox(wa),(f,c)=>{if(!(f.globals.activeFloors&&f.globals.activeFloors.size>0))return!1;const m=f.globals.activeFloors;return c.some(y=>{const k=y.evaluate(f);return m.has(k)})}],id:[ri,[],f=>f.id()],zoom:[Or,[],f=>f.globals.zoom],pitch:[Or,[],f=>f.globals.pitch||0],"distance-from-center":[Or,[],f=>f.distanceFromCenter()],"measure-light":[Or,[wa],(f,[c])=>f.measureLight(c.evaluate(f))],"heatmap-density":[Or,[],f=>f.globals.heatmapDensity||0],"line-progress":[Or,[],f=>f.globals.lineProgress||0],"raster-value":[Or,[],f=>f.globals.rasterValue||0],"raster-particle-speed":[Or,[],f=>f.globals.rasterParticleSpeed||0],"sky-radial-progress":[Or,[],f=>f.globals.skyRadialProgress||0],accumulated:[ri,[],f=>f.globals.accumulated===void 0?null:f.globals.accumulated],"+":[Or,ox(Or),(f,c)=>{let m=0;for(const y of c)m+=y.evaluate(f);return m}],"*":[Or,ox(Or),(f,c)=>{let m=1;for(const y of c)m*=y.evaluate(f);return m}],"-":{type:Or,overloads:[[[Or,Or],(f,[c,m])=>c.evaluate(f)-m.evaluate(f)],[[Or],(f,[c])=>-c.evaluate(f)]]},"/":[Or,[Or,Or],(f,[c,m])=>c.evaluate(f)/m.evaluate(f)],"%":[Or,[Or,Or],(f,[c,m])=>c.evaluate(f)%m.evaluate(f)],ln2:[Or,[],()=>Math.LN2],pi:[Or,[],()=>Math.PI],e:[Or,[],()=>Math.E],"^":[Or,[Or,Or],(f,[c,m])=>Math.pow(c.evaluate(f),m.evaluate(f))],sqrt:[Or,[Or],(f,[c])=>Math.sqrt(c.evaluate(f))],log10:[Or,[Or],(f,[c])=>Math.log(c.evaluate(f))/Math.LN10],ln:[Or,[Or],(f,[c])=>Math.log(c.evaluate(f))],log2:[Or,[Or],(f,[c])=>Math.log2(c.evaluate(f))],sin:[Or,[Or],(f,[c])=>Math.sin(c.evaluate(f))],cos:[Or,[Or],(f,[c])=>Math.cos(c.evaluate(f))],tan:[Or,[Or],(f,[c])=>Math.tan(c.evaluate(f))],asin:[Or,[Or],(f,[c])=>Math.asin(c.evaluate(f))],acos:[Or,[Or],(f,[c])=>Math.acos(c.evaluate(f))],atan:[Or,[Or],(f,[c])=>Math.atan(c.evaluate(f))],min:[Or,ox(Or),(f,c)=>Math.min(...c.map(m=>m.evaluate(f)))],max:[Or,ox(Or),(f,c)=>Math.max(...c.map(m=>m.evaluate(f)))],abs:[Or,[Or],(f,[c])=>Math.abs(c.evaluate(f))],round:[Or,[Or],(f,[c])=>{const m=c.evaluate(f);return m<0?-Math.round(-m):Math.round(m)}],floor:[Or,[Or],(f,[c])=>Math.floor(c.evaluate(f))],ceil:[Or,[Or],(f,[c])=>Math.ceil(c.evaluate(f))],"filter-==":[mi,[wa,ri],(f,[c,m])=>f.properties()[c.value]===m.value],"filter-id-==":[mi,[ri],(f,[c])=>f.id()===c.value],"filter-type-==":[mi,[wa],(f,[c])=>f.geometryType()===c.value],"filter-<":[mi,[wa,ri],(f,[c,m])=>{const y=f.properties()[c.value],k=m.value;return typeof y==typeof k&&y{const m=f.id(),y=c.value;return typeof m==typeof y&&m":[mi,[wa,ri],(f,[c,m])=>{const y=f.properties()[c.value],k=m.value;return typeof y==typeof k&&y>k}],"filter-id->":[mi,[ri],(f,[c])=>{const m=f.id(),y=c.value;return typeof m==typeof y&&m>y}],"filter-<=":[mi,[wa,ri],(f,[c,m])=>{const y=f.properties()[c.value],k=m.value;return typeof y==typeof k&&y<=k}],"filter-id-<=":[mi,[ri],(f,[c])=>{const m=f.id(),y=c.value;return typeof m==typeof y&&m<=y}],"filter->=":[mi,[wa,ri],(f,[c,m])=>{const y=f.properties()[c.value],k=m.value;return typeof y==typeof k&&y>=k}],"filter-id->=":[mi,[ri],(f,[c])=>{const m=f.id(),y=c.value;return typeof m==typeof y&&m>=y}],"filter-has":[mi,[ri],(f,[c])=>c.value in f.properties()],"filter-has-id":[mi,[],f=>f.id()!==null&&f.id()!==void 0],"filter-type-in":[mi,[md(wa)],(f,[c])=>c.value.indexOf(f.geometryType())>=0],"filter-id-in":[mi,[md(ri)],(f,[c])=>c.value.indexOf(f.id())>=0],"filter-in-small":[mi,[wa,md(ri)],(f,[c,m])=>m.value.indexOf(f.properties()[c.value])>=0],"filter-in-large":[mi,[wa,md(ri)],(f,[c,m])=>function(y,k,E,P){for(;E<=P;){const O=E+P>>1;if(k[O]===y)return!0;k[O]>y?P=O-1:E=O+1}return!1}(f.properties()[c.value],m.value,0,m.value.length-1)],all:{type:mi,overloads:[[[mi,mi],(f,[c,m])=>c.evaluate(f)&&m.evaluate(f)],[ox(mi),(f,c)=>{for(const m of c)if(!m.evaluate(f))return!1;return!0}]]},any:{type:mi,overloads:[[[mi,mi],(f,[c,m])=>c.evaluate(f)||m.evaluate(f)],[ox(mi),(f,c)=>{for(const m of c)if(m.evaluate(f))return!0;return!1}]]},"!":[mi,[mi],(f,[c])=>!c.evaluate(f)],"is-supported-script":[mi,[wa],(f,[c])=>{const m=f.globals&&f.globals.isSupportedScript;return!m||m(c.evaluate(f))}],upcase:[wa,[wa],(f,[c])=>c.evaluate(f).toUpperCase()],downcase:[wa,[wa],(f,[c])=>c.evaluate(f).toLowerCase()],concat:[wa,ox(ri),(f,c)=>c.map(m=>rm(m.evaluate(f))).join("")],"resolved-locale":[wa,[mS],(f,[c])=>c.evaluate(f).resolvedLocale()],random:[Or,[Or,Or,ri],(f,c)=>{const[m,y,k]=c.map(P=>P.evaluate(f));if(m>y||m===y)return m;let E;if(typeof k=="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 vb(f){return Array.isArray(f)&&f.length>0&&typeof f[0]=="string"&&f[0]in kv}function cx(f,c,m,y,k){const E=new AS(kv,[],c?function(O){const B={color:ju,string:wa,number:Or,enum:wa,boolean:mi,formatted:nb,resolvedImage:ab};return O.type==="array"?md(B[O.value]||ri,O.length):B[O.type]}(c):void 0,void 0,void 0,m,y,k),P=E.parse(f,void 0,void 0,void 0,c&&c.type==="string"?{typeAnnotation:"coerce"}:void 0);return P?ND(new US(P,c,m,y,k)):lx(E.errors)}class Nv{constructor(c,m,y,k){this.kind=c,this._styleExpression=m,this.isLightConstant=y,this.isLineProgressConstant=k,this.isStateDependent=c!=="constant"&&!hb(m.expression),this.configDependencies=Cy(m.expression),this.isIndoorDependent=BS(m.expression)}evaluateWithoutErrorHandling(c,m,y,k,E,P){return this._styleExpression.evaluateWithoutErrorHandling(c,m,y,k,E,P)}evaluate(c,m,y,k,E,P,O){return this._styleExpression.evaluate(c,m,y,k,E,P,void 0,void 0,O)}}class My{constructor(c,m,y,k,E,P){this.kind=c,this.zoomStops=y,this._styleExpression=m,this.isStateDependent=c!=="camera"&&!hb(m.expression),this.isIndoorDependent=BS(m.expression),this.isLightConstant=E,this.isLineProgressConstant=P,this.configDependencies=Cy(m.expression),this.interpolationType=k}evaluateWithoutErrorHandling(c,m,y,k,E,P){return this._styleExpression.evaluateWithoutErrorHandling(c,m,y,k,E,P)}evaluate(c,m,y,k,E,P){return this._styleExpression.evaluate(c,m,y,k,E,P)}interpolationFactor(c,m,y){return this.interpolationType?fh.interpolationFactor(this.interpolationType,c,m,y):0}}function bT(f,c,m,y,k){if((f=cx(f,c,m,y,k)).result==="error")return f;const E=f.value.expression,P=xv(E);if(!P&&!yb(c))return lx([new sm("","data expressions not supported")]);const O=yv(E,["zoom","pitch","distance-from-center"]);if(!O&&!CD(c))return lx([new sm("","zoom expressions not supported")]);const B=yv(E,["measure-light"]);if(!B&&!SD(c))return lx([new sm("","measure-light expression not supported")]);const W=yv(E,["line-progress"]);if(!W&&!function(ne){return _T(ne.expression,"line-progress")}(c))return lx([new sm("","line-progress expression not supported")]);const J=c.expression&&c.expression.relaxZoomRestriction,ee=Hm(E);return ee||O||J?ee instanceof sm?lx([ee]):ee instanceof fh&&!$S(c)?lx([new sm("",'"interpolate" expressions cannot be used with this property')]):ND(ee?new My(P&&W?"camera":"composite",f.value,ee.labels,ee instanceof fh?ee.interpolation:void 0,B,W):new Nv(P&&W?"constant":"source",f.value,B,W)):lx([new sm("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class VS{constructor(c,m){this._parameters=c,this._specification=m,Object.assign(this,TD(this._parameters,this._specification))}static deserialize(c){return new VS(c._parameters,c._specification)}static serialize(c){return{_parameters:c._parameters,_specification:c._specification}}}function Hm(f){let c=null;if(f instanceof $f)c=Hm(f.result);else if(f instanceof fb){for(const m of f.args)if(c=Hm(m),c)break}else(f instanceof mb||f instanceof fh)&&f.input instanceof Xd&&f.input.name==="zoom"&&(c=f);return c instanceof sm||f.eachChild(m=>{const y=Hm(m);y instanceof sm?c=y:c&&y&&c!==y&&(c=new sm("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),c}var wT,PD,ID=function(){if(PD)return wT;PD=1,wT=c;var f=3;function c(m,y,k){var E=this.cells=[];if(m instanceof ArrayBuffer){this.arrayBuffer=m;var P=new Int32Array(this.arrayBuffer);m=P[0],this.d=(y=P[1])+2*(k=P[2]);for(var O=0;O=ne[je+0]&&E>=ne[je+1])?(B[ue]=!0,O.push(ee[ue])):B[ue]=!1}}},c.prototype._forEachCell=function(m,y,k,E,P,O,B,W){for(var J=this._convertToCellCoord(m),ee=this._convertToCellCoord(y),ne=this._convertToCellCoord(k),ce=this._convertToCellCoord(E),ue=J;ue<=ne;ue++)for(var je=ee;je<=ce;je++){var Le=this.d*je+ue;if((!W||W(this._convertFromCellCoord(ue),this._convertFromCellCoord(je),this._convertFromCellCoord(ue+1),this._convertFromCellCoord(je+1)))&&P.call(this,m,y,k,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,y=f+this.cells.length+1+1,k=0,E=0;E=0||(k[E]=qf(f[E],c)));f instanceof Error&&(k.message=f.message)}if(k.$name)throw new Error("$name property is reserved for worker serialization logic.");return y!=="Object"&&(k.$name=y),k}throw new Error("can't serialize object of type "+typeof f)}function dx(f){if(f==null||typeof f=="boolean"||typeof f=="number"||typeof f=="string"||f instanceof Boolean||f instanceof Number||f instanceof String||f instanceof Date||f instanceof RegExp||_b(f)||f instanceof ImageBitmap||ArrayBuffer.isView(f)||f instanceof ImageData)return f;if(Array.isArray(f))return f.map(dx);if(typeof f=="object"){const c=f.$name||"Object";if(c==="Map"){const k=f.entries||[],E=new Map;for(let P=0;Pf>=128&&f<=255,Arabic:f=>f>=1536&&f<=1791,"Arabic Supplement":f=>f>=1872&&f<=1919,"Arabic Extended-A":f=>f>=2208&&f<=2303,"Hangul Jamo":f=>f>=4352&&f<=4607,"Unified Canadian Aboriginal Syllabics":f=>f>=5120&&f<=5759,Khmer:f=>f>=6016&&f<=6143,"Unified Canadian Aboriginal Syllabics Extended":f=>f>=6320&&f<=6399,"General Punctuation":f=>f>=8192&&f<=8303,"Letterlike Symbols":f=>f>=8448&&f<=8527,"Number Forms":f=>f>=8528&&f<=8591,"Miscellaneous Technical":f=>f>=8960&&f<=9215,"Control Pictures":f=>f>=9216&&f<=9279,"Optical Character Recognition":f=>f>=9280&&f<=9311,"Enclosed Alphanumerics":f=>f>=9312&&f<=9471,"Geometric Shapes":f=>f>=9632&&f<=9727,"Miscellaneous Symbols":f=>f>=9728&&f<=9983,"Miscellaneous Symbols and Arrows":f=>f>=11008&&f<=11263,"CJK Radicals Supplement":f=>f>=11904&&f<=12031,"Kangxi Radicals":f=>f>=12032&&f<=12255,"Ideographic Description Characters":f=>f>=12272&&f<=12287,"CJK Symbols and Punctuation":f=>f>=12288&&f<=12351,Hiragana:f=>f>=12352&&f<=12447,Katakana:f=>f>=12448&&f<=12543,Bopomofo:f=>f>=12544&&f<=12591,"Hangul Compatibility Jamo":f=>f>=12592&&f<=12687,Kanbun:f=>f>=12688&&f<=12703,"Bopomofo Extended":f=>f>=12704&&f<=12735,"CJK Strokes":f=>f>=12736&&f<=12783,"Katakana Phonetic Extensions":f=>f>=12784&&f<=12799,"Enclosed CJK Letters and Months":f=>f>=12800&&f<=13055,"CJK Compatibility":f=>f>=13056&&f<=13311,"CJK Unified Ideographs Extension A":f=>f>=13312&&f<=19903,"Yijing Hexagram Symbols":f=>f>=19904&&f<=19967,"CJK Unified Ideographs":f=>f>=19968&&f<=40959,"Yi Syllables":f=>f>=40960&&f<=42127,"Yi Radicals":f=>f>=42128&&f<=42191,"Hangul Jamo Extended-A":f=>f>=43360&&f<=43391,"Hangul Syllables":f=>f>=44032&&f<=55215,"Hangul Jamo Extended-B":f=>f>=55216&&f<=55295,"Private Use Area":f=>f>=57344&&f<=63743,"CJK Compatibility Ideographs":f=>f>=63744&&f<=64255,"Arabic Presentation Forms-A":f=>f>=64336&&f<=65023,"Vertical Forms":f=>f>=65040&&f<=65055,"CJK Compatibility Forms":f=>f>=65072&&f<=65103,"Small Form Variants":f=>f>=65104&&f<=65135,"Arabic Presentation Forms-B":f=>f>=65136&&f<=65279,"Halfwidth and Fullwidth Forms":f=>f>=65280&&f<=65519,Osage:f=>f>=66736&&f<=66815,"CJK Unified Ideographs Extension B":f=>f>=131072&&f<=173791};function bb(f){for(const c of f)if(HS(c.charCodeAt(0)))return!0;return!1}function jT(f){for(const c of f)if(!LD(c.charCodeAt(0)))return!1;return!0}function LD(f){return!(Zr.Arabic(f)||Zr["Arabic Supplement"](f)||Zr["Arabic Extended-A"](f)||Zr["Arabic Presentation Forms-A"](f)||Zr["Arabic Presentation Forms-B"](f))}function HS(f){return!(f!==746&&f!==747&&(f<4352||!(Zr["Bopomofo Extended"](f)||Zr.Bopomofo(f)||Zr["CJK Compatibility Forms"](f)&&!(f>=65097&&f<=65103)||Zr["CJK Compatibility Ideographs"](f)||Zr["CJK Compatibility"](f)||Zr["CJK Radicals Supplement"](f)||Zr["CJK Strokes"](f)||!(!Zr["CJK Symbols and Punctuation"](f)||f>=12296&&f<=12305||f>=12308&&f<=12319||f===12336)||Zr["CJK Unified Ideographs Extension A"](f)||Zr["CJK Unified Ideographs"](f)||Zr["Enclosed CJK Letters and Months"](f)||Zr["Hangul Compatibility Jamo"](f)||Zr["Hangul Jamo Extended-A"](f)||Zr["Hangul Jamo Extended-B"](f)||Zr["Hangul Jamo"](f)||Zr["Hangul Syllables"](f)||Zr.Hiragana(f)||Zr["Ideographic Description Characters"](f)||Zr.Kanbun(f)||Zr["Kangxi Radicals"](f)||Zr["Katakana Phonetic Extensions"](f)||Zr.Katakana(f)&&f!==12540||!(!Zr["Halfwidth and Fullwidth Forms"](f)||f===65288||f===65289||f===65293||f>=65306&&f<=65310||f===65339||f===65341||f===65343||f>=65371&&f<=65503||f===65507||f>=65512&&f<=65519)||!(!Zr["Small Form Variants"](f)||f>=65112&&f<=65118||f>=65123&&f<=65126)||Zr["Unified Canadian Aboriginal Syllabics"](f)||Zr["Unified Canadian Aboriginal Syllabics Extended"](f)||Zr["Vertical Forms"](f)||Zr["Yijing Hexagram Symbols"](f)||Zr["Yi Syllables"](f)||Zr["Yi Radicals"](f))))}function WS(f){return!(HS(f)||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)}(f))}function GS(f){return Zr.Arabic(f)||Zr["Arabic Supplement"](f)||Zr["Arabic Extended-A"](f)||Zr["Arabic Presentation Forms-A"](f)||Zr["Arabic Presentation Forms-B"](f)}function kT(f){return f>=1424&&f<=2303||Zr["Arabic Presentation Forms-A"](f)||Zr["Arabic Presentation Forms-B"](f)}function Uf(f,c){return!(!c&&kT(f)||f>=2304&&f<=3583||f>=3840&&f<=4255||Zr.Khmer(f))}function Yce(f){for(const c of f)if(kT(c.charCodeAt(0)))return!0;return!1}const Uu={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let NT=null,Qd=Uu.unavailable,Vf=null;const wb=function(f){f&&typeof f=="string"&&f.indexOf("NetworkError")>-1&&(Qd=Uu.error),NT&&NT(f)};function KS(){ZS.fire(new tm("pluginStateChange",{pluginStatus:Qd,pluginURL:Vf}))}const ZS=new Ts,jb=function(){return Qd},DD=function(){if(Qd!==Uu.deferred||!Vf)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Qd=Uu.loading,KS(),Vf&&qu({url:Vf},f=>{f?wb(f):(Qd=Uu.loaded,KS())})},Hf={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Qd===Uu.loaded||Hf.applyArabicShaping!=null,isLoading:()=>Qd===Uu.loading,setState(f){Qd=f.pluginStatus,Vf=f.pluginURL},isParsing:()=>Qd===Uu.parsing,isParsed:()=>Qd===Uu.parsed,getPluginURL:()=>Vf};class Li{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,y){for(const k of m)if(!Uf(k.charCodeAt(0),y))return!1;return!0}(c,Hf.isLoaded())}}class YS{constructor(c,m,y,k,E){this.property=c,this.value=m,this.expression=function(P,O,B,W,J){if(qS(P))return new VS(P,O);if(vb(P)||Array.isArray(P)&&P.length>0){const ee=bT(P,O,B,W,J);if(ee.result==="error")throw new Error(ee.value.map(ne=>`${ne.key}: ${ne.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,y,k,E)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(c,m,y,k){return this.property.possiblyEvaluate(this,c,m,y,k)}}class ST{constructor(c,m,y,k){this.property=c,this.value=new YS(c,void 0,m,y,k)}transitioned(c,m){return new RD(this.property,this.value,m,Object.assign({},c.transition,this.transition),c.now)}untransitioned(){return new RD(this.property,this.value,null,{},0)}}class OD{constructor(c,m,y,k){this._properties=c,this._values=Object.create(c.defaultTransitionablePropertyValues),this._scope=m,this._options=y,this._iconImageUseTheme=k,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(c){return xs(this._values[c].value.value)}setValue(c,m){this._values.hasOwnProperty(c)||(this._values[c]=new ST(this._values[c].property,this._scope,this._options,this._iconImageUseTheme)),this._values[c].value=new YS(this._values[c].property,m===null?void 0:xs(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 y=this._properties.properties;if(c)for(const k in c){const E=c[k];if(k.endsWith("-transition")){const P=k.slice(0,-11);y[P]&&this.setTransition(P,E)}else y.hasOwnProperty(k)&&this.setValue(k,E)}}getTransition(c){return xs(this._values[c].transition)}setTransition(c,m){this._values.hasOwnProperty(c)||(this._values[c]=new ST(this._values[c].property)),this._values[c].transition=xs(m)||void 0}serialize(){const c={};for(const m of Object.keys(this._values)){const y=this.getValue(m);y!==void 0&&(c[m]=y);const k=this.getTransition(m);k!==void 0&&(c[`${m}-transition`]=k)}return c}transitioned(c,m){const y=new FD(this._properties);for(const k of Object.keys(this._values))y._values[k]=this._values[k].transitioned(c,m._values[k]);return y}untransitioned(){const c=new FD(this._properties);for(const m of Object.keys(this._values))c._values[m]=this._values[m].untransitioned();return c}isIndoorDependent(){return this._isIndoorDependent}}class RD{constructor(c,m,y,k,E){const P=k.delay||0,O=k.duration||0;E=E||0,this.property=c,this.value=m,this.begin=E+P,this.end=this.begin+O,c.specification.transition&&(k.delay||k.duration)&&(this.prior=y)}possiblyEvaluate(c,m,y){const k=c.now||0,E=this.value.possiblyEvaluate(c,m,y),P=this.prior;if(P){if(k>this.end)return this.prior=null,E;if(this.value.isDataDriven())return this.prior=null,E;if(k":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 BD(f){return f instanceof Number||f instanceof String||f instanceof Boolean?f.valueOf():f}function XS(f){if(Array.isArray(f))return f.map(XS);if(f instanceof Object&&!(f instanceof Number||f instanceof String||f instanceof Boolean)){const c={};for(const m in f)c[m]=XS(f[m]);return c}return BD(f)}function Ip(f){if(f===!0||f===!1)return!0;if(!Array.isArray(f)||f.length===0)return!1;switch(f[0]){case"has":return f.length>=2&&f[1]!=="$id"&&f[1]!=="$type";case"in":return f.length>=3&&(typeof f[1]!="string"||Array.isArray(f[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return f.length!==3||Array.isArray(f[1])||Array.isArray(f[2]);case"any":case"all":for(const c of f.slice(1))if(!Ip(c)&&typeof c!="boolean")return!1;return!0;default:return!0}}function QS(f,c="",m=null,y="fill"){if(f==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Ip(f)||(f=JS(f));const k=f;let E=!0;try{E=function(J){if(!Cv(J))return J;let ee=XS(J);return $D(ee),ee=Iy(ee),ee}(k)}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(k,null,2)} `)}let P=null,O=null;if(y!=="background"&&y!=="sky"&&y!=="slot"){O=Gt[`filter_${y}`];const J=cx(E,O,c,m);if(J.result==="error")throw new Error(J.value.map(ee=>`${ee.key}: ${ee.message}`).join(", "));P=(ee,ne,ce)=>J.value.evaluate(ee,ne,{},ce)}let B=null,W=null;if(E!==k){const J=cx(k,O,c,m);if(J.result==="error")throw new Error(J.value.map(ee=>`${ee.key}: ${ee.message}`).join(", "));B=(ee,ne,ce,ue,je)=>J.value.evaluate(ee,ne,{},ce,void 0,void 0,ue,je),W=!xv(J.value.expression)}return{filter:P,dynamicFilter:B||void 0,needGeometry:qD(E),needFeature:!!W}}function Iy(f){if(!Array.isArray(f))return f;const c=function(m){if(Xce.has(m[0])){for(let y=1;yIy(m))}function $D(f){let c=!1;const m=[];if(f[0]==="case"){for(let y=1;y",">=","<","<=","to-boolean"]);function Qce(f,c){return fc?1:0}function qD(f){if(!Array.isArray(f))return!1;if(f[0]==="within"||f[0]==="distance")return!0;for(let c=1;c"||c==="<="||c===">="?eC(f[1],f[2],c):c==="any"?(m=f.slice(1),["any"].concat(m.map(JS))):c==="all"?["all"].concat(f.slice(1).map(JS)):c==="none"?["all"].concat(f.slice(1).map(JS).map(kb)):c==="in"?tC(f[1],f.slice(2)):c==="!in"?kb(tC(f[1],f.slice(2))):c==="has"?sC(f[1]):c!=="!has"||kb(sC(f[1]));var m}function eC(f,c,m){switch(f){case"$type":return[`filter-type-${m}`,c];case"$id":return[`filter-id-${m}`,c];default:return[`filter-${m}`,f,c]}}function tC(f,c){if(c.length===0)return!1;switch(f){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",f,["literal",c.sort(Qce)]]:["filter-in-small",f,["literal",c]]}}function sC(f){switch(f){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",f]}}function kb(f){return["!",f]}const Ly="";function Wm(f,c){return c?`${f}${Ly}${c}`:f}let UD;const VD=()=>UD||(UD=new bo({"icon-size":new rr(Gt.layout_symbol["icon-size"]),"icon-image":new rr(Gt.layout_symbol["icon-image"]),"icon-rotate":new rr(Gt.layout_symbol["icon-rotate"]),"icon-offset":new rr(Gt.layout_symbol["icon-offset"]),"text-size":new rr(Gt.layout_symbol["text-size"]),"text-rotate":new rr(Gt.layout_symbol["text-rotate"]),"text-offset":new rr(Gt.layout_symbol["text-offset"])}));class HD{constructor(c,m,y,k,E,P){const O=cx(c,Gt.appearance.condition);if(O.result==="success"&&(this.condition=O.value),this.name=m,y){this.properties=new Ey(VD()),this.unevaluatedLayout=new zD(VD(),k,E,P);for(const B in y)this.unevaluatedLayout.setValue(B,y[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,y){this.unevaluatedLayout&&(this.properties=this.unevaluatedLayout.possiblyEvaluate(c,void 0,m,y))}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"),y=this.hasProperty("icon-offset"),k=this.hasProperty("icon-rotate");return c||m||y||k}hasTextProperties(){const c=this.hasProperty("text-size"),m=this.hasProperty("text-offset"),y=this.hasProperty("text-rotate");return c||m||y}hasProperty(c){return this.getUnevaluatedProperty(c).value!==void 0}}const WD="-transition",Lp=new Set(["fill","line","background","hillshade","raster"]);class Jd extends Ts{constructor(c,m,y,k,E,P){if(super(),this.id=c.id,this.fqid=Wm(this.id,y),this.type=c.type,this.scope=y,this.lut=k,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=cx(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 zD(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 OD(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 Ey(m.paint)}}}onAdd(c){}onRemove(c){}isDraped(c){return!this.is3D(!0)&&Lp.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 y=this._unevaluatedLayout;y._properties.properties[c]&&(y.setValue(c,m),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...y.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||y.isIndoorDependent(),c==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(c){this.appearances=[],c.forEach(m=>{this.appearances.push(new HD(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(WD)?this._transitionablePaint.getTransition(c.slice(0,-11)):this._transitionablePaint.getValue(c)}isPaintProperty(c){return!!this._transitionablePaint._properties.properties[c]}setPaintProperty(c,m){const y=this._transitionablePaint,k=y._properties.properties;if(c.endsWith(WD)){const ee=c.slice(0,-11);return k[ee]&&y.setTransition(ee,m||void 0),!1}if(!k[c])return!1;const E=y._values[c],P=E.value.isDataDriven(),O=E.value;y.setValue(c,m),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...y.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||y.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(c);const B=y._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,y){return null}_handleOverridablePaintPropertyUpdate(c,m,y){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())),Is(c,(m,y)=>!(m===void 0||y==="layout"&&!Object.keys(m).length||y==="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 Ay&&yb(m.property.specification)&&(m.value.kind==="source"||m.value.kind==="composite")&&m.value.isStateDependent)return!0}for(const c of this.appearances)if(!hb(c.condition.expression))return!0;return!1}compileFilter(c){this._filterCompiled||(this._featureFilter=QS(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,y){return{}}queryRadius(c){}queryIntersectsFeature(c,m,y,k,E,P,O,B,W){}}const GD={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Nb{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 Jce=new ArrayBuffer(0);class Vi{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=Jce),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 na(f,c=1){let m=0,y=0;return{members:f.map(k=>{const E=GD[k.type].BYTES_PER_ELEMENT,P=m=KD(m,Math.max(c,E)),O=k.components||1;return y=Math.max(y,E),m+=E*O,{name:k.name,type:k.type,components:O,offset:P}}),size:KD(m,Math.max(y,c)),alignment:c}}function KD(f,c){return Math.ceil(f/c)*c}class ux extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m){const y=this.length;return this.resize(y+1),this.emplace(y,c,m)}emplace(c,m,y){const k=2*c;return this.int16[k+0]=m,this.int16[k+1]=y,c}}ux.prototype.bytesPerElement=4,_r(ux,"StructArrayLayout2i4");class Mv extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y){const k=this.length;return this.resize(k+1),this.emplace(k,c,m,y)}emplace(c,m,y,k){const E=3*c;return this.int16[E+0]=m,this.int16[E+1]=y,this.int16[E+2]=k,c}}Mv.prototype.bytesPerElement=6,_r(Mv,"StructArrayLayout3i6");class Tv extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y,k){const E=this.length;return this.resize(E+1),this.emplace(E,c,m,y,k)}emplace(c,m,y,k,E){const P=4*c;return this.int16[P+0]=m,this.int16[P+1]=y,this.int16[P+2]=k,this.int16[P+3]=E,c}}Tv.prototype.bytesPerElement=8,_r(Tv,"StructArrayLayout4i8");class Wf extends Vi{_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}}Wf.prototype.bytesPerElement=4,_r(Wf,"StructArrayLayout1f4");class CT extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y){const k=this.length;return this.resize(k+1),this.emplace(k,c,m,y)}emplace(c,m,y,k){const E=4*c,P=2*c;return this.int16[E+0]=m,this.int16[E+1]=y,this.float32[P+1]=k,c}}CT.prototype.bytesPerElement=8,_r(CT,"StructArrayLayout2i1f8");class MT extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y){const k=this.length;return this.resize(k+1),this.emplace(k,c,m,y)}emplace(c,m,y,k){const E=4*c;return this.int16[E+0]=m,this.int16[E+1]=y,this.int16[E+2]=k,c}}MT.prototype.bytesPerElement=8,_r(MT,"StructArrayLayout3i8");class TT extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E){const P=this.length;return this.resize(P+1),this.emplace(P,c,m,y,k,E)}emplace(c,m,y,k,E,P){const O=5*c;return this.int16[O+0]=m,this.int16[O+1]=y,this.int16[O+2]=k,this.int16[O+3]=E,this.int16[O+4]=P,c}}TT.prototype.bytesPerElement=10,_r(TT,"StructArrayLayout5i10");class rC extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,c,m,y,k,E,P,O)}emplace(c,m,y,k,E,P,O,B){const W=6*c,J=12*c,ee=3*c;return this.int16[W+0]=m,this.int16[W+1]=y,this.uint8[J+4]=k,this.uint8[J+5]=E,this.uint8[J+6]=P,this.uint8[J+7]=O,this.float32[ee+2]=B,c}}rC.prototype.bytesPerElement=12,_r(rC,"StructArrayLayout2i4ub1f12");class gh extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y){const k=this.length;return this.resize(k+1),this.emplace(k,c,m,y)}emplace(c,m,y,k){const E=3*c;return this.float32[E+0]=m,this.float32[E+1]=y,this.float32[E+2]=k,c}}gh.prototype.bytesPerElement=12,_r(gh,"StructArrayLayout3f12");class ku extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E){const P=this.length;return this.resize(P+1),this.emplace(P,c,m,y,k,E)}emplace(c,m,y,k,E,P){const O=6*c,B=3*c;return this.uint16[O+0]=m,this.uint16[O+1]=y,this.uint16[O+2]=k,this.uint16[O+3]=E,this.float32[B+2]=P,c}}ku.prototype.bytesPerElement=12,_r(ku,"StructArrayLayout4ui1f12");class Dy extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,y,k){const E=this.length;return this.resize(E+1),this.emplace(E,c,m,y,k)}emplace(c,m,y,k,E){const P=4*c;return this.uint16[P+0]=m,this.uint16[P+1]=y,this.uint16[P+2]=k,this.uint16[P+3]=E,c}}Dy.prototype.bytesPerElement=8,_r(Dy,"StructArrayLayout4ui8");class nC extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,c,m,y,k,E,P)}emplace(c,m,y,k,E,P,O){const B=6*c;return this.int16[B+0]=m,this.int16[B+1]=y,this.int16[B+2]=k,this.int16[B+3]=E,this.int16[B+4]=P,this.int16[B+5]=O,c}}nC.prototype.bytesPerElement=12,_r(nC,"StructArrayLayout6i12");class AT extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P,O,B,W,J,ee,ne){const ce=this.length;return this.resize(ce+1),this.emplace(ce,c,m,y,k,E,P,O,B,W,J,ee,ne)}emplace(c,m,y,k,E,P,O,B,W,J,ee,ne,ce){const ue=12*c;return this.int16[ue+0]=m,this.int16[ue+1]=y,this.int16[ue+2]=k,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]=ne,this.int16[ue+11]=ce,c}}AT.prototype.bytesPerElement=24,_r(AT,"StructArrayLayout4i4ui4i24");class ET extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,c,m,y,k,E,P)}emplace(c,m,y,k,E,P,O){const B=10*c,W=5*c;return this.int16[B+0]=m,this.int16[B+1]=y,this.int16[B+2]=k,this.float32[W+2]=E,this.float32[W+3]=P,this.float32[W+4]=O,c}}ET.prototype.bytesPerElement=20,_r(ET,"StructArrayLayout3i3f20");class hx extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k){const E=this.length;return this.resize(E+1),this.emplace(E,c,m,y,k)}emplace(c,m,y,k,E){const P=4*c;return this.float32[P+0]=m,this.float32[P+1]=y,this.float32[P+2]=k,this.float32[P+3]=E,c}}hx.prototype.bytesPerElement=16,_r(hx,"StructArrayLayout4f16");class aC extends Vi{_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}}aC.prototype.bytesPerElement=4,_r(aC,"StructArrayLayout1ul4");class xh extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m){const y=this.length;return this.resize(y+1),this.emplace(y,c,m)}emplace(c,m,y){const k=2*c;return this.uint16[k+0]=m,this.uint16[k+1]=y,c}}xh.prototype.bytesPerElement=4,_r(xh,"StructArrayLayout2ui4");class iC extends Vi{_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,y,k,E,P,O,B,W,J,ee,ne,ce){const ue=this.length;return this.resize(ue+1),this.emplace(ue,c,m,y,k,E,P,O,B,W,J,ee,ne,ce)}emplace(c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue){const je=20*c,Le=10*c;return this.int16[je+0]=m,this.int16[je+1]=y,this.int16[je+2]=k,this.int16[je+3]=E,this.int16[je+4]=P,this.float32[Le+3]=O,this.float32[Le+4]=B,this.float32[Le+5]=W,this.float32[Le+6]=J,this.int16[je+14]=ee,this.uint32[Le+8]=ne,this.uint16[je+18]=ce,this.uint16[je+19]=ue,c}}iC.prototype.bytesPerElement=40,_r(iC,"StructArrayLayout5i4f1i1ul2ui40");class oC extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,c,m,y,k,E,P,O)}emplace(c,m,y,k,E,P,O,B){const W=8*c;return this.int16[W+0]=m,this.int16[W+1]=y,this.int16[W+2]=k,this.int16[W+4]=E,this.int16[W+5]=P,this.int16[W+6]=O,this.int16[W+7]=B,c}}oC.prototype.bytesPerElement=16,_r(oC,"StructArrayLayout3i2i2i16");class lC extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E){const P=this.length;return this.resize(P+1),this.emplace(P,c,m,y,k,E)}emplace(c,m,y,k,E,P){const O=4*c,B=8*c;return this.float32[O+0]=m,this.float32[O+1]=y,this.float32[O+2]=k,this.int16[B+6]=E,this.int16[B+7]=P,c}}lC.prototype.bytesPerElement=16,_r(lC,"StructArrayLayout2f1f2i16");class PT extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,c,m,y,k,E,P)}emplace(c,m,y,k,E,P,O){const B=20*c,W=5*c;return this.uint8[B+0]=m,this.uint8[B+1]=y,this.float32[W+1]=k,this.float32[W+2]=E,this.float32[W+3]=P,this.float32[W+4]=O,c}}PT.prototype.bytesPerElement=20,_r(PT,"StructArrayLayout2ub4f20");class vl extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,y){const k=this.length;return this.resize(k+1),this.emplace(k,c,m,y)}emplace(c,m,y,k){const E=3*c;return this.uint16[E+0]=m,this.uint16[E+1]=y,this.uint16[E+2]=k,c}}vl.prototype.bytesPerElement=6,_r(vl,"StructArrayLayout3ui6");class Av extends Vi{_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,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie,Ge,Xe,rt,_t){const ft=this.length;return this.resize(ft+1),this.emplace(ft,c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie,Ge,Xe,rt,_t)}emplace(c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie,Ge,Xe,rt,_t,ft){const St=30*c,It=15*c,$t=60*c;return this.int16[St+0]=m,this.int16[St+1]=y,this.int16[St+2]=k,this.float32[It+2]=E,this.float32[It+3]=P,this.uint16[St+8]=O,this.uint16[St+9]=B,this.uint32[It+5]=W,this.uint32[It+6]=J,this.uint32[It+7]=ee,this.uint16[St+16]=ne,this.uint16[St+17]=ce,this.uint16[St+18]=ue,this.float32[It+10]=je,this.float32[It+11]=Le,this.uint8[$t+48]=Ie,this.uint8[$t+49]=Ge,this.uint8[$t+50]=Xe,this.uint32[It+13]=rt,this.int16[St+28]=_t,this.uint8[$t+58]=ft,c}}Av.prototype.bytesPerElement=60,_r(Av,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class IT extends Vi{_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,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie,Ge,Xe,rt,_t,ft,St,It,$t,as,Wt,hs,_s,bs,Os,Fs,Ps){const Ls=this.length;return this.resize(Ls+1),this.emplace(Ls,c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie,Ge,Xe,rt,_t,ft,St,It,$t,as,Wt,hs,_s,bs,Os,Fs,Ps)}emplace(c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie,Ge,Xe,rt,_t,ft,St,It,$t,as,Wt,hs,_s,bs,Os,Fs,Ps,Ls){const us=20*c,is=40*c,Ds=80*c;return this.float32[us+0]=m,this.float32[us+1]=y,this.int16[is+4]=k,this.int16[is+5]=E,this.int16[is+6]=P,this.int16[is+7]=O,this.int16[is+8]=B,this.int16[is+9]=W,this.int16[is+10]=J,this.int16[is+11]=ee,this.int16[is+12]=ne,this.uint16[is+13]=ce,this.uint16[is+14]=ue,this.uint16[is+15]=je,this.uint16[is+16]=Le,this.uint16[is+17]=Ie,this.uint16[is+18]=Ge,this.uint16[is+19]=Xe,this.uint16[is+20]=rt,this.uint16[is+21]=_t,this.uint16[is+22]=ft,this.uint16[is+23]=St,this.uint16[is+24]=It,this.uint16[is+25]=$t,this.uint16[is+26]=as,this.uint16[is+27]=Wt,this.uint32[us+14]=hs,this.float32[us+15]=_s,this.float32[us+16]=bs,this.float32[us+17]=Os,this.float32[us+18]=Fs,this.uint8[Ds+76]=Ps,this.uint16[is+39]=Ls,c}}IT.prototype.bytesPerElement=80,_r(IT,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class LT extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,c,m,y,k,E,P)}emplace(c,m,y,k,E,P,O){const B=6*c;return this.float32[B+0]=m,this.float32[B+1]=y,this.float32[B+2]=k,this.float32[B+3]=E,this.float32[B+4]=P,this.float32[B+5]=O,c}}LT.prototype.bytesPerElement=24,_r(LT,"StructArrayLayout6f24");class Oy extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E){const P=this.length;return this.resize(P+1),this.emplace(P,c,m,y,k,E)}emplace(c,m,y,k,E,P){const O=5*c;return this.float32[O+0]=m,this.float32[O+1]=y,this.float32[O+2]=k,this.float32[O+3]=E,this.float32[O+4]=P,c}}Oy.prototype.bytesPerElement=20,_r(Oy,"StructArrayLayout5f20");class DT extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,c,m,y,k,E,P,O)}emplace(c,m,y,k,E,P,O,B){const W=7*c;return this.float32[W+0]=m,this.float32[W+1]=y,this.float32[W+2]=k,this.float32[W+3]=E,this.float32[W+4]=P,this.float32[W+5]=O,this.float32[W+6]=B,c}}DT.prototype.bytesPerElement=28,_r(DT,"StructArrayLayout7f28");class OT extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P,O,B,W,J,ee){const ne=this.length;return this.resize(ne+1),this.emplace(ne,c,m,y,k,E,P,O,B,W,J,ee)}emplace(c,m,y,k,E,P,O,B,W,J,ee,ne){const ce=11*c;return this.float32[ce+0]=m,this.float32[ce+1]=y,this.float32[ce+2]=k,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]=ne,c}}OT.prototype.bytesPerElement=44,_r(OT,"StructArrayLayout11f44");class Ev extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P,O,B,W){const J=this.length;return this.resize(J+1),this.emplace(J,c,m,y,k,E,P,O,B,W)}emplace(c,m,y,k,E,P,O,B,W,J){const ee=9*c;return this.float32[ee+0]=m,this.float32[ee+1]=y,this.float32[ee+2]=k,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}}Ev.prototype.bytesPerElement=36,_r(Ev,"StructArrayLayout9f36");class Dp extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m){const y=this.length;return this.resize(y+1),this.emplace(y,c,m)}emplace(c,m,y){const k=2*c;return this.float32[k+0]=m,this.float32[k+1]=y,c}}Dp.prototype.bytesPerElement=8,_r(Dp,"StructArrayLayout2f8");class Nu extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,y,k){const E=this.length;return this.resize(E+1),this.emplace(E,c,m,y,k)}emplace(c,m,y,k,E){const P=6*c;return this.uint32[3*c+0]=m,this.uint16[P+2]=y,this.uint16[P+3]=k,this.uint16[P+4]=E,c}}Nu.prototype.bytesPerElement=12,_r(Nu,"StructArrayLayout1ul3ui12");class mx extends Vi{_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}}mx.prototype.bytesPerElement=2,_r(mx,"StructArrayLayout1ui2");class RT extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le){const Ie=this.length;return this.resize(Ie+1),this.emplace(Ie,c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le)}emplace(c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie){const Ge=16*c;return this.float32[Ge+0]=m,this.float32[Ge+1]=y,this.float32[Ge+2]=k,this.float32[Ge+3]=E,this.float32[Ge+4]=P,this.float32[Ge+5]=O,this.float32[Ge+6]=B,this.float32[Ge+7]=W,this.float32[Ge+8]=J,this.float32[Ge+9]=ee,this.float32[Ge+10]=ne,this.float32[Ge+11]=ce,this.float32[Ge+12]=ue,this.float32[Ge+13]=je,this.float32[Ge+14]=Le,this.float32[Ge+15]=Ie,c}}RT.prototype.bytesPerElement=64,_r(RT,"StructArrayLayout16f64");class cC extends Vi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,k,E,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,c,m,y,k,E,P,O)}emplace(c,m,y,k,E,P,O,B){const W=10*c,J=5*c;return this.uint16[W+0]=m,this.uint16[W+1]=y,this.uint16[W+2]=k,this.uint16[W+3]=E,this.float32[J+2]=P,this.float32[J+3]=O,this.float32[J+4]=B,c}}cC.prototype.bytesPerElement=20,_r(cC,"StructArrayLayout4ui3f20");class FT extends Vi{_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}}FT.prototype.bytesPerElement=2,_r(FT,"StructArrayLayout1i2");class dC extends Vi{_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}}dC.prototype.bytesPerElement=1,_r(dC,"StructArrayLayout1ub1");class uC extends Nb{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]}}uC.prototype.size=40;class ZD extends iC{get(c){return new uC(this,c)}}_r(ZD,"CollisionBoxArray");class hC extends Nb{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}}hC.prototype.size=60;class YD extends Av{get(c){return new hC(this,c)}}_r(YD,"PlacedSymbolArray");class XD extends Nb{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]}}XD.prototype.size=80;class zT extends IT{get(c){return new XD(this,c)}}_r(zT,"SymbolInstanceArray");class mC extends Wf{getoffsetX(c){return this.float32[1*c+0]}}_r(mC,"GlyphOffsetArray");class QD extends ux{getx(c){return this.int16[2*c+0]}gety(c){return this.int16[2*c+1]}}_r(QD,"SymbolLineVertexArray");class BT extends Nb{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]}}BT.prototype.size=12;class $T extends Nu{get(c){return new BT(this,c)}}_r($T,"FeatureIndexArray");class JD extends xh{geta_centroid_pos0(c){return this.uint16[2*c+0]}geta_centroid_pos1(c){return this.uint16[2*c+1]}}_r(JD,"FillExtrusionCentroidArray");class pC extends Nb{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]}}pC.prototype.size=6;class Sb extends Mv{get(c){return new pC(this,c)}}_r(Sb,"FillExtrusionWallArray");const eO=na([{name:"a_pos",components:2,type:"Int16"}],4),ede=na([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),tO=na([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class uo{constructor(c=[]){this.segments=c}_prepareSegment(c,m,y,k){let E=this.segments[this.segments.length-1];return c>uo.MAX_VERTEX_ARRAY_LENGTH&&cr(`Max vertices per segment is ${uo.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${c}`),(!E||E.vertexLength+c>uo.MAX_VERTEX_ARRAY_LENGTH||E.sortKey!==k)&&(E={vertexOffset:m,primitiveOffset:y,vertexLength:0,primitiveLength:0},k!==void 0&&(E.sortKey=k),this.segments.push(E)),E}prepareSegment(c,m,y,k){return this._prepareSegment(c,m.length,y.length,k)}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,y,k){return new uo([{vertexOffset:c,primitiveOffset:m,vertexLength:y,primitiveLength:k,vaos:{},sortKey:0}])}}function fC(f,c){return 256*(f=Se(Math.floor(f),0,255))+Se(Math.floor(c),0,255)}uo.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,_r(uo,"SegmentVector");const tde=na([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),sde=na([{name:"a_pattern_b",components:4,type:"Uint16"}]),rde=na([{name:"a_dash",components:4,type:"Uint16"}]);class Cb{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(c,m,y,k){this.ids.push(qT(c)),this.positions.push(m,y,k)}eachPosition(c,m){const y=qT(c);let k=0,E=this.ids.length-1;for(;k>1;this.ids[P]>=y?E=P:k=P+1}for(;this.ids[k]===y;)m(this.positions[3*k],this.positions[3*k+1],this.positions[3*k+2]),k++}static serialize(c,m){const y=new Float64Array(c.ids),k=new Uint32Array(c.positions);return UT(y,k,0,y.length-1),m&&(m.add(y.buffer),m.add(k.buffer)),{ids:y,positions:k}}static deserialize(c){const m=new Cb;let y;m.ids=c.ids,m.positions=c.positions;for(const k of m.ids)k!==y&&m.uniqueIds.push(k),y=k;return m.indexed=!0,m}}function qT(f){const c=+f;return Number.isSafeInteger(c)?c:dv(String(f))}function UT(f,c,m,y){for(;m>1];let E=m-1,P=y+1;for(;;){do E++;while(f[E]k);if(E>=P)break;gC(f,E,P),gC(c,3*E,3*P),gC(c,3*E+1,3*P+1),gC(c,3*E+2,3*P+2)}P-m`u_${E}`),this.type=y,this.context=k}setUniform(c,m,y,k,E){const P=k.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 Tb(c):new _l(c)}}class Pv{constructor(c,m){this.uniformNames=m.map(y=>`u_${y}`),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,y,k,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 yC(c):new _l(c)}}class Kf{constructor(c,m,y,k){this.expression=c,this.type=y,this.maxValue=0,this.paintVertexAttributes=m.map(E=>({name:`a_${E}`,type:"Float32",components:y==="color"?2:1,offset:0})),this.paintVertexArray=new k}populatePaintArray(c,m,y,k,E,P,O,B){const W=this.paintVertexArray.length,J=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new Li(0,{brightness:P,worldview:B}),m,{},E,k,O):this.expression.kind==="constant"&&this.expression.value,ee=Eb(this.lutExpression,m,{},k,E,P,O,B);this.paintVertexArray.resize(c),this._setPaintValue(W,c,J,ee?null:this.context.lut)}updatePaintArray(c,m,y,k,E,P,O,B){const W=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:O,worldview:B},y,k,void 0,E):this.expression.kind==="constant"&&this.expression.value,J=Eb(this.lutExpression,y,k,E,void 0,O,void 0,B);this._setPaintValue(c,m,W,J?null:this.context.lut)}_setPaintValue(c,m,y,k){if(this.type==="color"){const E=VT(y.toPremultipliedRenderColor(k));for(let P=c;P`u_${O}_t`),this.type=y,this.useIntegerZoom=k,this.context=E,this.maxValue=0,this.paintVertexAttributes=m.map(O=>({name:`a_${O}`,type:"Float32",components:y==="color"?4:2,offset:0})),this.paintVertexArray=new P}populatePaintArray(c,m,y,k,E,P,O,B){const W=this.expression.evaluate(new Li(this.context.zoom,{brightness:P,worldview:B}),m,{},E,k,O),J=this.expression.evaluate(new Li(this.context.zoom+1,{brightness:P,worldview:B}),m,{},E,k,O),ee=Eb(this.lutExpression,m,{},k,E,P,O,B),ne=this.paintVertexArray.length;this.paintVertexArray.resize(c),this._setPaintValue(ne,c,W,J,ee?null:this.context.lut)}updatePaintArray(c,m,y,k,E,P,O,B){const W=this.expression.evaluate({zoom:this.context.zoom,brightness:O,worldview:B},y,k,void 0,E),J=this.expression.evaluate({zoom:this.context.zoom+1,brightness:O,worldview:B},y,k,void 0,E),ee=Eb(this.lutExpression,y,k,E,void 0,O,void 0,B);this._setPaintValue(c,m,W,J,ee?null:this.context.lut)}_setPaintValue(c,m,y,k,E){if(this.type==="color"){const P=VT(y.toPremultipliedRenderColor(E)),O=VT(y.toPremultipliedRenderColor(E));for(let B=c;B!0){this.binders={},this._buffers=[],this.context=m;const k=[];for(const E in c.paint._values){const P=c.paint.get(E);if(E.endsWith("-use-theme")||!y(E)||!(P instanceof Ay&&yb(P.property.specification)))continue;const O=ode(E,c.type),B=P.value,W=P.property.specification.type,J=!!P.property.useIntegerZoom,ee=E==="line-dasharray"||E.endsWith("pattern"),ne=c.paint.get(`${E}-use-theme`),ce=E==="line-dasharray"&&c.layout.get("line-cap").value.kind!=="constant"||ne&&ne.value.kind!=="constant";if(B.kind!=="constant"||ce)if(B.kind==="source"||ce||ee){const ue=HT(E,W,"source");this.binders[E]=ee?new Yf(B,O,W,ue,c.id):new Kf(B,O,W,ue),k.push(`/a_${E}`)}else{const ue=HT(E,W,"composite");this.binders[E]=new Zf(B,O,W,J,m,ue),k.push(`/z_${E}`)}else this.binders[E]=ee?new Pv(B.value,O):new Pb(B.value,O,W,m),k.push(`/u_${E}`);ne&&(this.binders[E].lutExpression=ne.value)}this.cacheKey=k.sort().join("")}getMaxValue(c){const m=this.binders[c];return m instanceof Kf||m instanceof Zf?m.maxValue:0}populatePaintArrays(c,m,y,k,E,P,O,B){for(const W in this.binders){const J=this.binders[W];J.context=this.context,(J instanceof Kf||J instanceof Zf||J instanceof Yf)&&J.populatePaintArray(c,m,y,k,E,P,O,B)}}setConstantPatternPositions(c,m){for(const y in this.binders){const k=this.binders[y];k instanceof Pv&&k.setConstantPatternPositions(c,m)}}getPatternTransitionVertexBuffer(c){const m=this.binders[c];return m instanceof Yf?m.paintTransitionVertexBuffer:null}updatePaintArrays(c,m,y,k,E,P,O,B,W,J){let ee=!1;const ne=Object.keys(c),ce=ne.length!==0&&!B,ue=ce?ne:m.uniqueIds;this.context.lut=E.lut;for(const je in this.binders){const Le=this.binders[je];if(Le.context=this.context,(Le instanceof Kf||Le instanceof Zf||Le instanceof Yf)&&Le.expression&&Le.expression.kind&&Le.expression.kind!=="constant"&&(Le.expression.isStateDependent===!0||Le.expression.isLightConstant===!1)){const Ie=E.paint.get(je);Le.expression=Ie.value;for(const Ge of ue){const Xe=c[Ge.toString()];m.eachPosition(Ge,(rt,_t,ft)=>{const St=k.feature(rt);Le.updatePaintArray(_t,ft,St,Xe,P,O,W,J)})}if(!ce)for(const Ge of y.uniqueIds){const Xe=c[Ge.toString()];y.eachPosition(Ge,(rt,_t,ft)=>{const St=k.feature(rt);Le.updatePaintArray(_t,ft,St,Xe,P,O,W,J)})}ee=!0}}return ee}defines(){const c=[];for(const m in this.binders){const y=this.binders[m];(y instanceof Pb||y instanceof Pv)&&c.push(...y.uniformNames.map(k=>`#define HAS_UNIFORM_${k}`))}return c}getPaintVertexBuffers(){return this._buffers}getUniforms(c){const m=[];for(const y in this.binders){const k=this.binders[y];if(k instanceof Pb||k instanceof Pv||k instanceof Zf)for(const E of k.uniformNames)m.push({name:E,property:y,binding:k.getBinding(c,E)})}return m}setUniforms(c,m,y,k,E){for(const{name:P,property:O,binding:B}of y)this.binders[O].setUniform(c,B,E,k.get(O),P)}updatePaintBuffers(){this._buffers=[];for(const c in this.binders){const m=this.binders[c];(m instanceof Kf||m instanceof Zf||m instanceof Yf)&&m.paintVertexBuffer&&this._buffers.push(m.paintVertexBuffer),m instanceof Yf&&m.paintTransitionVertexBuffer&&this._buffers.push(m.paintTransitionVertexBuffer)}}upload(c){for(const m in this.binders){const y=this.binders[m];(y instanceof Kf||y instanceof Zf||y instanceof Yf)&&y.upload(c)}this.updatePaintBuffers()}destroy(){for(const c in this.binders){const m=this.binders[c];(m instanceof Kf||m instanceof Zf||m instanceof Yf)&&m.destroy()}}}class Gm{constructor(c,m,y=()=>!0){this.programConfigurations={};for(const k of c)this.programConfigurations[k.id]=new px(k,m,y);this.needsUpload=!1,this._featureMap=new Cb,this._featureMapWithoutIds=new Cb,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(c,m,y,k,E,P,O,B,W){for(const J in this.programConfigurations)this.programConfigurations[J].populatePaintArrays(c,m,k,E,P,O,B,W);m.id!==void 0?this._featureMap.add(m.id,y,this._bufferOffset,c):(this._featureMapWithoutIds.add(this._idlessCounter,y,this._bufferOffset,c),this._idlessCounter+=1),this._bufferOffset=c,this.needsUpload=!0}updatePaintArrays(c,m,y,k,E,P,O,B){for(const W of y)this.needsUpload=this.programConfigurations[W.id].updatePaintArrays(c,this._featureMap,this._featureMapWithoutIds,m,W,k,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 ide={"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 ode(f,c){return ide[f]||[f.replace(`${c}-`,"").replace(/-/g,"_")]}const lde={"line-pattern":{source:ku,composite:ku},"fill-pattern":{source:ku,composite:ku},"fill-extrusion-pattern":{source:ku,composite:ku},"line-dasharray":{source:Dy,composite:Dy}},cde={color:{source:Dp,composite:hx},number:{source:Wf,composite:Dp}};function HT(f,c,m){const y=lde[f];return y&&y[m]||cde[c][m]}_r(Pb,"ConstantBinder"),_r(Pv,"PatternConstantBinder"),_r(Kf,"SourceExpressionBinder"),_r(Yf,"PatternCompositeBinder"),_r(Zf,"CompositeExpressionBinder"),_r(px,"ProgramConfiguration",{omit:["_buffers"]}),_r(Gm,"ProgramConfigurationSet");const pd=Ys/Math.PI/2,im=5,bC=6,dde=16383,Iv=64,WT=[Iv,32,16],om=-pd,lm=pd;function Ry(f,c,m,y=pd){return m=Jr(m),[f*Math.sin(m)*y,-c*y,f*Math.cos(m)*y]}function Lv(f,c,m){return Ry(Math.cos(Jr(f)),Math.sin(Jr(f)),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(st(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,y=this.lat*m,k=c.lat*m,E=Math.sin(y)*Math.sin(k)+Math.cos(y)*Math.cos(k)*Math.cos((c.lng-this.lng)*m);return M*Math.acos(Math.min(E,1))}toBounds(c=0){const m=360*c/40075017,y=m/Math.cos(Math.PI/180*this.lat);return new T({lng:this.lng-y,lat:this.lat-m},{lng:this.lng+y,lat:this.lat+m})}toEcef(c){return Lv(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 T{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,y=this._ne;let k,E;if(c instanceof x)k=c,E=c;else{if(!(c instanceof T))return Array.isArray(c)?c.length===4||c.every(Array.isArray)?this.extend(T.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(k=c._sw,E=c._ne,!k||!E)return this}return m||y?(m.lng=Math.min(k.lng,m.lng),m.lat=Math.min(k.lat,m.lat),y.lng=Math.max(E.lng,y.lng),y.lat=Math.max(E.lat,y.lat)):(this._sw=new x(k.lng,k.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:y}=x.convert(c);let k=this._sw.lng<=m&&m<=this._ne.lng;return this._sw.lng>this._ne.lng&&(k=this._sw.lng>=m&&m>=this._ne.lng),this._sw.lat<=y&&y<=this._ne.lat&&k}static convert(c){if(c)return c instanceof T?c:new T(c)}}const D=0,F=25.5;function z(f){return h*Math.cos(f*Math.PI/180)}function H(f){return(180+f)/360}function Q(f){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+f*Math.PI/360)))/360}function re(f,c){return f/z(c)}function oe(f){return 360*f-180}function ge(f){return 360/Math.PI*Math.atan(Math.exp((180-360*f)*Math.PI/180))-90}function me(f,c){return f*z(ge(c))}const xe=85.051129;function Pe(f){return Math.cos(Jr(Se(f,-xe,xe)))}function Ce(f,c){const m=Se(c,D,F),y=Math.pow(2,m);return Pe(f)*h/(512*y)}function $e(f){return 1/Math.cos(f*Math.PI/180)}function Be(f,c=0){const m=Math.exp(Math.PI*(1-(f.y+c/Ys)/(1<=B?(dt(f,c,m,W,J,E,ee,O,B),dt(f,W,J,y,k,ee,P,O,B)):f.push(P)}function tt(f,c,m){let y=f[0],k=y.x,E=y.y;c(y);const P=[y];for(let O=1;Of.x+1||yf.y+1)&&cr("Geometry exceeds allowed extent, reduce your vector tile buffer size"),f}function Pt(f,c,m){const y=f.loadGeometry(),k=f.extent,E=Ys/k;if(c&&m&&m.projection.isReprojectedInTileSpace){const P=1<{const ce=oe((c.x+ne.x/k)/P),ue=ge((c.y+ne.y/k)/P),je=J.project(ce,ue);ne.x=(je.x*O-B)*k,ne.y=(je.y*O-W)*k};for(let ne=0;ne=k||ue.y<0||ue.y>=k||(ee(ue),ce.push(ue));y[ne]=ce}}for(const P of y)for(const O of P)pt(O,E);return y}function Ht(f,c){return{type:f.type,id:f.id,properties:f.properties,geometry:c?Pt(f):[]}}class Vt{constructor(c,m,y,k,E){this.properties={},this.extent=y,this.type=0,this.id=void 0,this._pbf=c,this._geometry=-1,this._keys=k,this._values=E,c.readFields(ts,this,m)}loadGeometry(){const c=this._pbf;c.pos=this._geometry;const m=c.readVarint()+c.pos,y=[];let k,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&&(k&&y.push(k),k=[]),k&&k.push(new rs(O,B));else{if(E!==7)throw new Error(`unknown command ${E}`);k&&k.push(k[0].clone())}}return k&&y.push(k),y}bbox(){const c=this._pbf;c.pos=this._geometry;const m=c.readVarint()+c.pos;let y=1,k=0,E=0,P=0,O=1/0,B=-1/0,W=1/0,J=-1/0;for(;c.pos>3}if(k--,y===1||y===2)E+=c.readSVarint(),P+=c.readSVarint(),EB&&(B=E),PJ&&(J=P);else if(y!==7)throw new Error(`unknown command ${y}`)}return[O,W,B,J]}toGeoJSON(c,m,y){const k=this.extent*Math.pow(2,y),E=this.extent*c,P=this.extent*m,O=this.loadGeometry();function B(ne){return[360*(ne.x+E)/k-180,360/Math.PI*Math.atan(Math.exp((1-2*(ne.y+P)/k)*Math.PI))-90]}function W(ne){return ne.map(B)}let J;if(this.type===1){const ne=[];for(const ue of O)ne.push(ue[0]);const ce=W(ne);J=ne.length===1?{type:"Point",coordinates:ce[0]}:{type:"MultiPoint",coordinates:ce}}else if(this.type===2){const ne=O.map(W);J=ne.length===1?{type:"LineString",coordinates:ne[0]}:{type:"MultiLineString",coordinates:ne}}else{if(this.type!==3)throw new Error("unknown feature type");{const ne=function(ue){const je=ue.length;if(je<=1)return[ue];const Le=[];let Ie,Ge;for(let Xe=0;Xe=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 Vt(this._pbf,m,this.extent,this._keys,this._values)}}function Bs(f,c,m){f===15?c.version=m.readVarint():f===1?c.name=m.readString():f===5?c.extent=m.readVarint():f===2?c._features.push(m.pos):f===3?c._keys.push(m.readString()):f===4&&c._values.push(function(y){let k=null;const E=y.readVarint()+y.pos;for(;y.pos>3;k=P===1?y.readString():P===2?y.readFloat():P===3?y.readDouble():P===4?y.readVarint64():P===5?y.readVarint():P===6?y.readSVarint():P===7?y.readBoolean():null}if(k==null)throw new Error("unknown feature value");return k}(m))}class Xt{constructor(c,m){this.layers=c.readFields(Ft,{},m)}}function Ft(f,c,m){if(f===3){const y=new ps(m,m.readVarint()+m.pos);y.length&&(c[y.name]=y)}}const cs="3d_elevation_id",es="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,y){return this.get(c,!0,m,y)}optional(c,m,y){return this.get(c,!1,m,y)}success(){return this._valid}get(c,m,y,k){const E=this.feature.properties.hasOwnProperty(c)?+this.feature.properties[c]:void 0;return this._valid&&E!==void 0&&!Number.isNaN(E)?y(k?k(E):E):m&&(this._valid=!1),this}}class Qs{constructor(c,m){this.featureFunc=c,this.vertexFunc=m}parseFeature(c,m,y){return this.featureFunc(c,m,y)}parseVertex(c,m,y){return this.vertexFunc(c,m,y)}}const mr=new Qs((f,c,m)=>f.reset(c).require(cs,y=>{m.id=y}).optional("fixed_height_relative",y=>{m.constantHeight=y},$s.decodeRelativeHeight).geometry(y=>{m.bounds=y},Bf).success(),(f,c,m)=>f.reset(c).require(cs,y=>{m.id=y}).require("elevation_idx",y=>{m.idx=y}).require("extent",y=>{m.extent=y}).require("height_relative",y=>{m.height=y},$s.decodeRelativeHeight).geometry(y=>{m.position=y},$s.getPoint).success()),Ks=new Qs((f,c,m)=>f.reset(c).require(cs,y=>{m.id=y}).optional("fixed_height",y=>{m.constantHeight=y},$s.decodeMetricHeight).geometry(y=>{m.bounds=y},Bf).success(),(f,c,m)=>f.reset(c).require(cs,y=>{m.id=y}).require("elevation_idx",y=>{m.idx=y}).require("extent",y=>{m.extent=y}).require("height",y=>{m.height=y},$s.decodeMetricHeight).geometry(y=>{m.position=y},$s.getPoint).success());class $s{static getPoint(c){return bt(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"?Ks:void 0:mr}static parse(c){const m=[],y=[],k=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(f,c){for(const m of f.projections){const y=fr(c,f.points[0],m.axis);if(m.projection[1]y[1])return 0}return 1}function ha(f,c){let m=0;const y=[0,0,0,0];for(let P=0;P=0&&m++;var k,E;return m}class Wa{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=[ke([],this.points[2],this.points[3]),ke([],this.points[0],this.points[3]),ke([],this.points[4],this.points[0]),ke([],this.points[5],this.points[1]),ke([],this.points[6],this.points[2]),ke([],this.points[7],this.points[3])];for(const y of this.frustumEdges){const k=[0,-y[2],y[1]],E=[y[2],0,-y[0]];this.projections.push({axis:k,projection:fr(this.points,this.points[0],k)}),this.projections.push({axis:E,projection:fr(this.points,this.points[0],E)})}}static fromInvProjectionMatrix(c,m,y,k){const E=Math.pow(2,y),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=mt([],W,c),ee=1/J[3]/m*E;return(ne=J)[0]=(ce=J)[0]*(ue=[ee,ee,k?1/J[3]:ee,ee])[0],ne[1]=ce[1]*ue[1],ne[2]=ce[2]*ue[2],ne[3]=ce[3]*ue[3],ne;var ne,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([],ke([],P[W[0]],P[W[1]]),ke([],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 y=m[3];if(Ue([m[0],m[1],m[2]],c)+y<0)return!1}return!0}}class Er{static fromPoints(c){const m=[1/0,1/0,1/0],y=[-1/0,-1/0,-1/0];for(const k of c)ye(m,m,k),we(y,y,k);return new Er(m,y)}static fromTileIdAndHeight(c,m,y){const k=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 Ra{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,y=m[1],k=-m[0],E=(c.extent+1)*this.metersToTile;return[new rs(Math.trunc(c.position[0]+y*E),Math.trunc(c.position[1]+k*E)),new rs(Math.trunc(c.position[0]-y*E),Math.trunc(c.position[1]-k*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,y=Number.POSITIVE_INFINITY,k=0;const[E,P,O,B,W,J,ee]=this._tmpVec2;ks(ee,c.x,c.y);const ne=new Cr(ee,null);for(let ce=0;ce0?Oa(B,O)/rt:0,ft=Se(_t,0,1),St=Math.abs((_t-ft)*this.edgeProps[ce].len);Rr(W,ee,Le),ks(J,je[1],-je[0]);const It=St+Math.abs(Oa(W,J));It=0;--P){const O=this.edges[P].a,B=this.edges[P].b,{position:W,height:J,extent:ee}=this.vertices[O],{position:ne,height:ce,extent:ue}=this.vertices[B],je=this.vertexProps[O].dir,Le=this.vertexProps[B].dir;if(ae(m,W[0]/c,W[1]/c,J),ae(y,ne[0]/c,ne[1]/c,ce),ae(k,je[1],-je[0],0),Ne(k,k,ee),ae(E,Le[1],-Le[0],0),Ne(E,E,ue),this.distSqLines(ie(m[0]+.5*k[0],m[1]+.5*k[1],m[2]+.5*k[2]),ie(y[0]-.5*E[0],y[1]-.5*E[1],y[2]-.5*E[2]),ie(m[0]-.5*k[0],m[1]-.5*k[1],m[2]-.5*k[2]),ie(y[0]+.5*E[0],y[1]+.5*E[1],y[2]+.5*E[2]))<=.0025000000000000005)continue;const Ie=this.vertices.length,Ge=ir(dr(),W,ne);this.vertices.push({position:ca(Ge,Ge,.5),height:.5*(J+ce),extent:.5*(ee+ue)});const Xe=ir(dr(),je,Le);this.vertexProps.push({dir:lo(Xe,Xe)}),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 rt=Rr(dr(),this.vertices[Ie].position,W),_t=ii(rt),ft={vec:rt,dir:ca(dr(),rt,1/_t),len:_t};this.edgeProps.push(ft),this.edgeProps.push(ft)}}distSqLines(c,m,y,k){const E=pe(te(),m,c),P=pe(te(),k,y),O=pe(te(),c,y),B=Ue(E,E),W=Ue(E,P),J=Ue(E,O),ee=Ue(P,P),ne=Ue(P,O),ce=B*ee-W*W;if(ce===0)return Me(De(E,y,k,Ue(O,P)/Ue(P,P)),c);const ue=(B*ne-W*J)/ce;return Me(De(E,c,m,(W*ne-J*ee)/ce),De(P,y,k,ue))}}class Qa{static parseFrom(c,m){const y=$s.parse(c);if(!y)return[];let{vertices:k,features:E}=y;const P=1/Be(m);E.sort((J,ee)=>J.id-ee.id),k.sort((J,ee)=>J.id-ee.id||J.idx-ee.idx),k=k.filter((J,ee,ne)=>ee===ne.findIndex(ce=>ce.id===J.id&&ce.idx===J.idx));const O=new Array;let B=0;const W=k.length;for(const J of E){if(J.constantHeight){O.push(new vn(J.id,J.bounds,J.constantHeight));continue}for(;B!==W&&k[B].idk.id===y)}}class pi{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)*Ys,this.yOffset=(c.y*this.zScale-m.y)*Ys)}constantElevation(c,m){if(c.constantHeight!=null)return this.computeBiasedHeight(c.constantHeight,m)}pointElevation(c,m,y){const k=this.constantElevation(m,y);return k??(c.x=c.x*this.zScale+this.xOffset,c.y=c.y*this.zScale+this.yOffset,this.computeBiasedHeight(m.pointElevation(c),y))}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 ux,this.indexArray=new vl,this.segments=new uo,this.programConfigurations=new Gm(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 Wf),this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,y,k){}populate(c,m,y,k){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:ne}of c){const ce=this.layers[0]._featureFilter.needGeometry,ue=Ht(W,ce);if(!this.layers[0]._featureFilter.filter(new Li(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ue,y))continue;const je=O?O.evaluate(ue,{},y):void 0,Le={id:J,properties:W.properties,type:W.type,sourceLayerIndex:ne,index:ee,geometry:ce?ue.geometry:Pt(W,y,k),patterns:{},sortKey:je};P.push(Le)}O&&P.sort((W,J)=>W.sortKey-J.sortKey);let B=null;k.projection.name==="globe"&&(this.globeExtVertexArray=new nC,B=k.projection);for(const W of P){const{geometry:J,index:ee,sourceLayerIndex:ne}=W,ce=c[ee].feature;this.addFeature(W,J,ee,m.availableImages,y,B,m.brightness,m.elevationFeatures),m.featureIndex.insert(ce,J,ee,ne,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(c,m,y,k,E,P,O){this.programConfigurations.updatePaintArrays(c,m,E,y,k,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,eO.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,tO.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=c.createVertexBuffer(this.elevatedLayoutVertexArray,ede.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,y,k,E,P,O,B){let W;this.elevationMode!=="none"&&(W=Qa.getElevationFeature(c,B));for(const J of m)for(const ee of J){const ne=ee.x,ce=ee.y;if(ne<0||ne>=Ys||ce<0||ce>=Ys)continue;if(P){const Le=P.projectTilePoint(ne,ce,E),Ie=P.upVector(E,ne,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),je=ue.vertexLength;if(this.addCircleVertex(ne,ce,-1,-1),this.addCircleVertex(ne,ce,1,-1),this.addCircleVertex(ne,ce,1,1),this.addCircleVertex(ne,ce,-1,1),this.elevationMode!=="none"){const Le=W?W.pointElevation(new rs(ne,ce)):0;this.hasElevation=this.hasElevation||Le!==0;for(let Ie=0;Ie<4;Ie++)this.elevatedLayoutVertexArray.emplaceBack(Le)}this.indexArray.emplaceBack(je,je+1,je+2),this.indexArray.emplaceBack(je,je+2,je+3),ue.vertexLength+=4,ue.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,y,{},k,E,O,void 0,this.worldview)}addCircleVertex(c,m,y,k){this.layoutVertexArray.emplaceBack(2*c+(y+1)/2,2*m+(k+1)/2)}addGlobeExtVertex(c,m){this.globeExtVertexArray.emplaceBack(c.x,c.y,c.z,m[0]*16384,m[1]*16384,m[2]*16384)}}function La(f,c){for(let m=0;m1){if(Hi(f,c))return!0;for(let y=0;y1?m:m.sub(c)._mult(k)._add(c))}function ho(f,c){let m,y,k,E=!1;for(let P=0;Pc.y!=k.y>c.y&&c.x<(k.x-y.x)*(c.y-y.y)/(k.y-y.y)+y.x&&(E=!E)}return E}function wi(f,c){let m=!1;for(let y=0,k=f.length-1;yc.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 eu(f,c,m,y,k){for(const P of f)if(c<=P.x&&m<=P.y&&y>=P.x&&k>=P.y)return!0;const E=[new rs(c,m),new rs(c,k),new rs(y,k),new rs(y,m)];if(f.length>2){for(const P of E)if(wi(f,P))return!0}for(let P=0;Pk.x&&c.x>k.x||f.yk.y&&c.y>k.y)return!1;const E=Cn(f,c,m[0]);return E!==Cn(f,c,m[1])||E!==Cn(f,c,m[2])||E!==Cn(f,c,m[3])}function bl(f,c,m,y,k,E){let P=c.y-f.y,O=f.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-f.x)*P+(m.y-f.y)*O-E<0||(y.x-f.x)*P+(y.y-f.y)*O-E<0||(k.x-f.x)*P+(k.y-f.y)*O-E<0)}function fd(f,c,m,y,k,E,P){return!(bl(f,c,y,k,E,P)||bl(c,m,y,k,E,P)||bl(m,f,y,k,E,P)||bl(y,k,f,c,m,P)||bl(k,E,f,c,m,P)||bl(E,y,f,c,m,P))}function gd(f,c,m){const y=c.paint.get(f).value;return y.kind==="constant"?y.value:m.programConfigurations.get(c.id).getMaxValue(f)}function Ec(f){return Math.sqrt(f[0]*f[0]+f[1]*f[1])}function yh(f,c,m,y,k){if(!c[0]&&!c[1])return f;const E=rs.convert(c)._mult(k);m==="viewport"&&E._rotate(-y);const P=[];for(let O=0;O>m&&c.y===this.y>>m}url(c,m){const y=function(E,P,O){var B=Oo(256*E,256*(P=Math.pow(2,O)-P-1),O),W=Oo(256*(E+1),256*(P+1),O);return B[0]+","+B[1]+","+W[0]+","+W[1]}(this.x,this.y,this.z),k=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 mo(this.wrap*+m,c,this.canonical.z,this.canonical.x,this.canonical.y);{const y=this.canonical.z-c;return mo(this.wrap*+m,c,c,this.canonical.x>>y,this.canonical.y>>y)}}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,y=2*this.canonical.x,k=2*this.canonical.y;return[new go(m,this.wrap,m,y,k),new go(m,this.wrap,m,y+1,k),new go(m,this.wrap,m,y,k+1),new go(m,this.wrap,m,y+1,k+1)]}isLessThan(c){return this.wrapc.wrap)&&(this.overscaledZc.overscaledZ)&&(this.canonical.xc.canonical.x)&&this.canonical.y{let c=f.canonical.x-1,m=f.wrap;return c<0&&(c=(1<{let c=f.canonical.x+1,m=f.wrap;return c===1<new go(f.overscaledZ,f.wrap,f.canonical.z,f.canonical.x,(f.canonical.y===0?1<new go(f.overscaledZ,f.wrap,f.canonical.z,f.canonical.x,f.canonical.y===(1<1?null:function(y,k,E,P){const O=Math.sin(E);return y*(Math.sin((1-P)*E)/O)+k*(Math.sin(P*E)/O)}(f.a[c],f.b[c],f.angle,Se(m,0,1))+f.center[c]}function Zm(f){if(f.z<=1)return Xf[f.z+2*f.y+f.x];const c=ude(sO(f));return Er.fromPoints(c)}function Jf(f,c,m){return Ne(f,f,1-m),Ke(f,f,c,m)}function B2e(f,c,m){for(const y of f)Dt(y,y,c),Ne(y,y,m)}function $2e(f,c,m,y){const k=c/f.worldSize,E=f.globeMatrix;if(m.z<=1){const $t=Zm(m).getCorners();return B2e($t,E,k),Er.fromPoints($t)}const P=sO(m,y),O=ude(P,pd+Rp(f._tileCoverLift));B2e(O,E,k);const B=Number.MAX_VALUE,W=[-B,-B,-B],J=[B,B,B];if(P.contains(f.center)){for(const Wt of O)ye(J,J,Wt),we(W,W,Wt);W[2]=0;const $t=f.point,as=[$t.x*k,$t.y*k,0];return ye(J,J,as),we(W,W,as),new Er(J,W)}if(f._tileCoverLift>0){for(const $t of O)ye(J,J,$t),we(W,W,$t);return new Er(J,W)}const ee=[E[12]*k,E[13]*k,E[14]*k],ne=P.getCenter(),ce=Se(f.center.lat,-xe,xe),ue=Se(ne.lat,-xe,xe),je=H(f.center.lng),Le=Q(ce);let Ie=je-H(ne.lng);const Ge=Le-Q(ue);Ie>.5?Ie-=1:Ie<-.5&&(Ie+=1);let Xe=0;Math.abs(Ie)>Math.abs(Ge)?Xe=Ie>=0?1:3:(Xe=Ge>=0?0:2,Ke(ee,ee,[E[4]*k,E[5]*k,E[6]*k],-Math.sin(Jr(Ge>=0?P.getSouth():P.getNorth()))*pd));const rt=O[Xe],_t=O[(Xe+1)%4],ft=new fx(rt,_t,ee),St=[Qf(ft,0)||rt[0],Qf(ft,1)||rt[1],Qf(ft,2)||rt[2]],It=Rv(f.zoom);if(It>0){const $t=function({x:Wt,y:hs,z:_s},bs,Os,Fs,Ps){const Ls=1/(1<<_s);let us=Wt*Ls,is=us+Ls,Ds=hs*Ls,Xs=Ds+Ls,qs=0;const Ir=(us+is)/2-Fs;return Ir>.5?qs=-1:Ir<-.5&&(qs=1),us=((us+qs)*bs-(Fs*=bs))*Os+Fs,is=((is+qs)*bs-Fs)*Os+Fs,Ds=(Ds*bs-(Ps*=bs))*Os+Ps,Xs=(Xs*bs-Ps)*Os+Ps,[[us,Xs,0],[is,Xs,0],[is,Ds,0],[us,Ds,0]]}(m,c,f._pixelsPerMercatorPixel,je,Le);for(let Wt=0;WtMath.PI/2*1.01}const W2e=Jr(85),wet=Math.cos(W2e),jet=Math.sin(W2e),ket=b(),G2e=f=>{const c=[];return f.paint.get("circle-pitch-alignment")==="map"&&c.push("PITCH_WITH_MAP"),f.paint.get("circle-pitch-scale")==="map"&&c.push("SCALE_WITH_MAP"),c};function K2e(f,c,m,y,k,E,P,O,B){if(E&&f.queryGeometry.isAboveHorizon)return!1;E&&(B*=f.pixelToTileUnitsFactor);const W=f.tileID.canonical,J=m.projection.upVectorScale(W,m.center.lat,m.worldSize).metersToTile;for(const ee of c)for(const ne of ee){const ce=ne.add(O),ue=k&&m.elevation?m.elevation.exaggeration()*k.getElevationAt(ce.x,ce.y,!0):0,je=m.projection.projectTilePoint(ce.x,ce.y,W);if(ue>0){const Xe=m.projection.upVector(W,ce.x,ce.y);je.x+=Xe[0]*J*ue,je.y+=Xe[1]*J*ue,je.z+=Xe[2]*J*ue}const Le=E?ce:Net(je.x,je.y,je.z,y),Ie=E?f.tilespaceRays.map(Xe=>Met(Xe,ue)):f.queryGeometry.screenGeometry,Ge=mt([],[je.x,je.y,je.z,1],y);if(!P&&E?B*=Ge[3]/m.cameraToCenterDistance:P&&!E&&(B*=m.cameraToCenterDistance/Ge[3]),E){const Xe=ge((ne.y/Ys+W.y)/(1<f.width||k.height>f.height||m.x>f.width-k.width||m.y>f.height-k.height)throw new RangeError("out of range source coordinates for image copy");if(k.width>c.width||k.height>c.height||y.x>c.width-k.width||y.y>c.height-k.height)throw new RangeError("out of range destination coordinates for image copy");const B=f.data,W=c.data,J=E===4&&O;for(let ee=0;ee{c[f.evaluationKey]=B;const W=f.expression.evaluate(c),J=W?W.toNonPremultipliedRenderColor(null):null;J&&(k.data[P+O+0]=Math.floor(255*J.r),k.data[P+O+1]=Math.floor(255*J.g),k.data[P+O+2]=Math.floor(255*J.b),k.data[P+O+3]=Math.floor(255*J.a))};if(f.clips)for(let P=0,O=0;P80*m){O=f[0],B=f[1];let J=O,ee=B;for(let ne=m;neJ&&(J=ce),ue>ee&&(ee=ue)}W=Math.max(J-O,ee-B),W=W!==0?32767/W:0}return ZT(E,P,m,O,B,W,0),P}function nje(f,c,m,y,k){let E;if(k===function(P,O,B,W){let J=0;for(let ee=O,ne=B-W;ee0)for(let P=c;P=c;P-=y)E=lje(P/y|0,f[P],f[P+1],E);return E&&jC(E,E.next)&&(QT(E),E=E.next),E}function Db(f,c){if(!f)return f;c||(c=f);let m,y=f;do if(m=!1,y.steiner||!jC(y,y.next)&&yc(y.prev,y,y.next)!==0)y=y.next;else{if(QT(y),y=c=y.prev,y===y.next)break;m=!0}while(m||y!==c);return c}function ZT(f,c,m,y,k,E,P){if(!f)return;!P&&E&&function(B,W,J,ee){let ne=B;do ne.z===0&&(ne.z=gde(ne.x,ne.y,W,J,ee)),ne.prevZ=ne.prev,ne.nextZ=ne.next,ne=ne.next;while(ne!==B);ne.prevZ.nextZ=null,ne.prevZ=null,function(ce){let ue,je=1;do{let Le,Ie=ce;ce=null;let Ge=null;for(ue=0;Ie;){ue++;let Xe=Ie,rt=0;for(let ft=0;ft0||_t>0&&Xe;)rt!==0&&(_t===0||!Xe||Ie.z<=Xe.z)?(Le=Ie,Ie=Ie.nextZ,rt--):(Le=Xe,Xe=Xe.nextZ,_t--),Ge?Ge.nextZ=Le:ce=Le,Le.prevZ=Ge,Ge=Le;Ie=Xe}Ge.nextZ=null,je*=2}while(ue>1)}(ne)}(f,y,k,E);let O=f;for(;f.prev!==f.next;){const B=f.prev,W=f.next;if(E?Let(f,y,k,E):Iet(f))c.push(B.i,f.i,W.i),QT(f),f=W.next,O=W.next;else if((f=W)===O){P?P===1?ZT(f=Det(Db(f),c),c,m,y,k,E,2):P===2&&Oet(f,c,m,y,k,E):ZT(Db(f),c,m,y,k,E,1);break}}}function Iet(f){const c=f.prev,m=f,y=f.next;if(yc(c,m,y)>=0)return!1;const k=c.x,E=m.x,P=y.x,O=c.y,B=m.y,W=y.y,J=Math.min(k,E,P),ee=Math.min(O,B,W),ne=Math.max(k,E,P),ce=Math.max(O,B,W);let ue=y.next;for(;ue!==c;){if(ue.x>=J&&ue.x<=ne&&ue.y>=ee&&ue.y<=ce&&YT(k,O,E,B,P,W,ue.x,ue.y)&&yc(ue.prev,ue,ue.next)>=0)return!1;ue=ue.next}return!0}function Let(f,c,m,y){const k=f.prev,E=f,P=f.next;if(yc(k,E,P)>=0)return!1;const O=k.x,B=E.x,W=P.x,J=k.y,ee=E.y,ne=P.y,ce=Math.min(O,B,W),ue=Math.min(J,ee,ne),je=Math.max(O,B,W),Le=Math.max(J,ee,ne),Ie=gde(ce,ue,c,m,y),Ge=gde(je,Le,c,m,y);let Xe=f.prevZ,rt=f.nextZ;for(;Xe&&Xe.z>=Ie&&rt&&rt.z<=Ge;){if(Xe.x>=ce&&Xe.x<=je&&Xe.y>=ue&&Xe.y<=Le&&Xe!==k&&Xe!==P&&YT(O,J,B,ee,W,ne,Xe.x,Xe.y)&&yc(Xe.prev,Xe,Xe.next)>=0||(Xe=Xe.prevZ,rt.x>=ce&&rt.x<=je&&rt.y>=ue&&rt.y<=Le&&rt!==k&&rt!==P&&YT(O,J,B,ee,W,ne,rt.x,rt.y)&&yc(rt.prev,rt,rt.next)>=0))return!1;rt=rt.nextZ}for(;Xe&&Xe.z>=Ie;){if(Xe.x>=ce&&Xe.x<=je&&Xe.y>=ue&&Xe.y<=Le&&Xe!==k&&Xe!==P&&YT(O,J,B,ee,W,ne,Xe.x,Xe.y)&&yc(Xe.prev,Xe,Xe.next)>=0)return!1;Xe=Xe.prevZ}for(;rt&&rt.z<=Ge;){if(rt.x>=ce&&rt.x<=je&&rt.y>=ue&&rt.y<=Le&&rt!==k&&rt!==P&&YT(O,J,B,ee,W,ne,rt.x,rt.y)&&yc(rt.prev,rt,rt.next)>=0)return!1;rt=rt.nextZ}return!0}function Det(f,c){let m=f;do{const y=m.prev,k=m.next.next;!jC(y,k)&&ije(y,m,m.next,k)&&XT(y,k)&&XT(k,y)&&(c.push(y.i,m.i,k.i),QT(m),QT(m.next),m=f=k),m=m.next}while(m!==f);return Db(m)}function Oet(f,c,m,y,k,E){let P=f;do{let O=P.next.next;for(;O!==P.prev;){if(P.i!==O.i&&$et(P,O)){let B=oje(P,O);return P=Db(P,P.next),B=Db(B,B.next),ZT(P,c,m,y,k,E,0),void ZT(B,c,m,y,k,E,0)}O=O.next}P=P.next}while(P!==f)}function Ret(f,c){let m=f.x-c.x;return m===0&&(m=f.y-c.y,m===0)&&(m=(f.next.y-f.y)/(f.next.x-f.x)-(c.next.y-c.y)/(c.next.x-c.x)),m}function Fet(f,c){const m=function(k,E){let P=E;const O=k.x,B=k.y;let W,J=-1/0;if(jC(k,P))return P;do{if(jC(k,P.next))return P.next;if(B<=P.y&&B>=P.next.y&&P.next.y!==P.y){const je=P.x+(B-P.y)*(P.next.x-P.x)/(P.next.y-P.y);if(je<=O&&je>J&&(J=je,W=P.x=P.x&&P.x>=ne&&O!==P.x&&aje(BW.x||P.x===W.x&&zet(W,P)))&&(W=P,ue=je)}P=P.next}while(P!==ee);return W}(f,c);if(!m)return c;const y=oje(m,f);return Db(y,y.next),Db(m,m.next)}function zet(f,c){return yc(f.prev,f,c.prev)<0&&yc(c.next,f,f.next)<0}function gde(f,c,m,y,k){return(f=1431655765&((f=858993459&((f=252645135&((f=16711935&((f=(f-m)*k|0)|f<<8))|f<<4))|f<<2))|f<<1))|(c=1431655765&((c=858993459&((c=252645135&((c=16711935&((c=(c-y)*k|0)|c<<8))|c<<4))|c<<2))|c<<1))<<1}function Bet(f){let c=f,m=f;do(c.x=(f-P)*(E-O)&&(f-P)*(y-O)>=(m-P)*(c-O)&&(m-P)*(E-O)>=(k-P)*(y-O)}function YT(f,c,m,y,k,E,P,O){return!(f===P&&c===O)&&aje(f,c,m,y,k,E,P,O)}function $et(f,c){return f.next.i!==c.i&&f.prev.i!==c.i&&!function(m,y){let k=m;do{if(k.i!==m.i&&k.next.i!==m.i&&k.i!==y.i&&k.next.i!==y.i&&ije(k,k.next,m,y))return!0;k=k.next}while(k!==m);return!1}(f,c)&&(XT(f,c)&&XT(c,f)&&function(m,y){let k=m,E=!1;const P=(m.x+y.x)/2,O=(m.y+y.y)/2;do k.y>O!=k.next.y>O&&k.next.y!==k.y&&P<(k.next.x-k.x)*(O-k.y)/(k.next.y-k.y)+k.x&&(E=!E),k=k.next;while(k!==m);return E}(f,c)&&(yc(f.prev,f,c.prev)||yc(f,c.prev,c))||jC(f,c)&&yc(f.prev,f,f.next)>0&&yc(c.prev,c,c.next)>0)}function yc(f,c,m){return(c.y-f.y)*(m.x-c.x)-(c.x-f.x)*(m.y-c.y)}function jC(f,c){return f.x===c.x&&f.y===c.y}function ije(f,c,m,y){const k=iO(yc(f,c,m)),E=iO(yc(f,c,y)),P=iO(yc(m,y,f)),O=iO(yc(m,y,c));return k!==E&&P!==O||!(k!==0||!aO(f,m,c))||!(E!==0||!aO(f,y,c))||!(P!==0||!aO(m,f,y))||!(O!==0||!aO(m,c,y))}function aO(f,c,m){return c.x<=Math.max(f.x,m.x)&&c.x>=Math.min(f.x,m.x)&&c.y<=Math.max(f.y,m.y)&&c.y>=Math.min(f.y,m.y)}function iO(f){return f>0?1:f<0?-1:0}function XT(f,c){return yc(f.prev,f,f.next)<0?yc(f,c,f.next)>=0&&yc(f,f.prev,c)>=0:yc(f,c,f.prev)<0||yc(f,f.next,c)<0}function oje(f,c){const m=xde(f.i,f.x,f.y),y=xde(c.i,c.x,c.y),k=f.next,E=c.prev;return f.next=c,c.prev=f,m.next=k,k.prev=m,y.next=m,m.prev=y,E.next=y,y.prev=E,y}function lje(f,c,m,y){const k=xde(f,c,m);return y?(k.next=y.next,k.prev=y,y.next.prev=k,y.next=k):(k.prev=k,k.next=k),k}function QT(f){f.next.prev=f.prev,f.prev.next=f.next,f.prevZ&&(f.prevZ.nextZ=f.nextZ),f.nextZ&&(f.nextZ.prevZ=f.prevZ)}function xde(f,c,m){return{i:f,x:c,y:m,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function JT(f,c){const m=f.length;if(m<=1)return[f];const y=[];let k,E;for(let P=0;P1)for(let P=0;P=Ys&&m>=Ys}static evaluate(c){if(c.length===0)return new Fy;let m=[];for(const B of c)m.push(...B.portals);if(m.length===0)return new Fy;for(const B of m){const W=B.va,J=B.vb;(Fy.isOnBorder(W.x,J.x)||Fy.isOnBorder(W.y,J.y))&&(B.type="border")}const y=m.filter(B=>B.type!=="unevaluated"),k=m.filter(B=>B.type==="unevaluated");if(k.length===0)return new Fy;k.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 Gm(m,{zoom:y,lut:k},E=>E!=="fill-bridge-guard-rail-color")}addVertices(c,m){const y=this.unevalVertices.length;for(let k=0;k=E.min.x&&ee.x<=E.max.x&&ee.y>=E.min.y&&ee.y<=E.max.y||ne.x>=E.min.x&&ne.x<=E.max.x&&ne.y>=E.min.y&&ne.y<=E.max.y||ed(ee,ne,O))||this.isOnBorder(ee.x,ne.x)||this.isOnBorder(ee.y,ne.y))continue;const ce=vh.computeEdgeHash(this.unevalVertices[W],this.unevalVertices[J]);let ue,je=this.vertexHashLookup.get(vh.computePosHash(ee));je!=null?ue=je.next:(je=this.vertexHashLookup.get(vh.computePosHash(ne)),ue=je!=null?je.prev:ce),this.unevalEdges.push({polygonIdx:c,a:W,b:J,hash:ce,portalHash:ue,isTunnel:k,type:"unevaluated",featureInfo:P})}}addPortalCandidates(c,m,y,k,E){if(m.length===0)return;this.portalPolygons.add(c,{geometry:m,zLevel:E});const P=m[0];this.vertexHashLookup.clear();let O=vh.computeEdgeHash(P[P.length-2],P[P.length-1]);for(let B=0;B({vertexOffset:0,primitiveOffset:this.indexArray.length}),y=ne=>{ne.primitiveLength=this.indexArray.length-ne.primitiveOffset},k=new Uet(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(c.portals,this.unevalEdges);const E=m(),P=m(),O=m(),B=(ne,ce)=>{ne.sort((je,Le)=>je.type===ce&&Le.type!==ce?-1:je.type!==ce&&Le.type===ce?1:0);const ue=ne.findIndex(je=>je.type!==ce);return ue>=0?ue:ne.length};let W=0;this.unevalEdges.length>0&&(W=B(this.unevalEdges,"none"),this.constructBridgeStructures(k,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:W},this.tileToMeters)),y(O);const J=m(),ee=m();if(this.unevalEdges.length>0){const ne=this.unevalEdges.splice(W),ce=B(ne,"tunnel")+W;this.unevalEdges.push(...ne),this.constructTunnelStructures(k,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:W},{min:W,max:ce})}y(J),k.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),y(ee),k.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),y(P),k.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),y(E),this.maskSegments=uo.simpleSegment(0,ee.primitiveOffset,0,ee.primitiveLength),this.depthSegments=uo.simpleSegment(0,P.primitiveOffset,0,P.primitiveLength),this.renderableBridgeSegments=uo.simpleSegment(0,O.primitiveOffset,0,O.primitiveLength),this.renderableTunnelSegments=uo.simpleSegment(0,J.primitiveOffset,0,J.primitiveLength),this.shadowCasterSegments=uo.simpleSegment(0,E.primitiveOffset,0,E.primitiveLength)}update(c,m,y,k,E,P,O,B){this.bridgeProgramConfigurations.updatePaintArrays(c,m,E,y,k,P,O,B),this.tunnelProgramConfigurations.updatePaintArrays(c,m,E,y,k,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,Eet.members),this.vertexBufferNormal=c.createVertexBuffer(this.vertexNormals,Pet.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,y,k,E){const P=(O,B)=>{for(let W=0;Wae(Os,m[Fs].x,m[Fs].y,y[Fs]*B),ee=te(),ne=te(),ce=te(),ue=te(),je=te(),Le=(Os,Fs)=>{const Ps=O.get(vh.computePosHash(m[Fs])),Ls=Ps.from,us=Ps.to;if(!Ls||!us)return;J(ee,Ls),J(ne,Fs),J(ce,us),nt(ue),Qe(ee,ne)||(ke(je,ne,ee),Ae(ue,je)),Qe(ce,ne)||(ke(je,ce,ne),le(ue,ue,Ae(je,je)));const is=qe(ue);return is>0?Ne(Os,ue,1/is):void 0};let Ie=Number.POSITIVE_INFINITY;this.sortSubarray(k,E.min,E.max,(Os,Fs)=>Os.featureInfo.featureIndex-Fs.featureInfo.featureIndex);const Ge=te(),Xe=te(),rt=te(),_t=te(),ft=te(),St=te(),It=te(),$t=te(),as=te(),Wt=[te(),te(),te(),te()],hs=[te(),te(),te(),te()],_s=[{coord:new rs(0,0),height:0},{coord:new rs(0,0),height:0}],bs=(Os,Fs)=>Os>Fs;for(let Os=E.min;OsIe.featureInfo.featureIndex-Ge.featureInfo.featureIndex;this.sortSubarray(k,E.min,E.max,B),this.sortSubarray(k,P.min,P.max,B);const W=Ie=>Ae(Ie,Ie),J=[{coord:new rs(0,0),height:0},{coord:new rs(0,0),height:0}],ee=(Ie,Ge)=>IeO.hash===B.hash?B.polygonIdx-O.polygonIdx:B.hash>O.hash?1:-1);let y=0,k=0,E=0,P=m[y].polygonIdx;do k++,(k===m.length||m[y].hash!==m[k].hash)&&((k-y==1||m[k-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>=Ys&&m>=Ys}addFeatureSection(c,m,y,k){return c!==m&&(m=c,y.push({featureIndex:c,vertexStart:k.getVertexCount()}),k.clearVertexLookup()),m}sortSubarray(c,m,y,k){const E=c.slice(m,y);E.sort(k),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(vh.computePosHash(c))<<32n|BigInt(vh.computePosHash(m))}static computePosHash(c){return((65535&c.x)<<16|65535&c.y)>>>0}}var uje,hje={exports:{}},mje=(uje||(uje=1,function(f){function c(gt,wt){return gt>wt?1:gt0){var Dr=Rs+Math.floor(ar/2),zr={key:wt[Dr],data:ms[Dr],parent:gt};return zr.left=k(zr,wt,ms,Rs,Dr),zr.right=k(zr,wt,ms,Dr+1,nr),zr}return null}function E(gt,wt,ms,Rs,nr){if(!(ms>=Rs)){for(var ar=gt[ms+Rs>>1],Dr=ms-1,zr=Rs+1;;){do Dr++;while(nr(gt[Dr],ar)<0);do zr--;while(nr(gt[zr],ar)>0);if(Dr>=zr)break;var kn=gt[Dr];gt[Dr]=gt[zr],gt[zr]=kn,kn=wt[Dr],wt[Dr]=wt[zr],wt[zr]=kn}E(gt,wt,ms,zr,nr),E(gt,wt,zr+1,Rs,nr)}}m.prototype.rotateLeft=function(gt){var wt=gt.right;wt&&(gt.right=wt.left,wt.left&&(wt.left.parent=gt),wt.parent=gt.parent),gt.parent?gt===gt.parent.left?gt.parent.left=wt:gt.parent.right=wt:this._root=wt,wt&&(wt.left=gt),gt.parent=wt},m.prototype.rotateRight=function(gt){var wt=gt.left;wt&&(gt.left=wt.right,wt.right&&(wt.right.parent=gt),wt.parent=gt.parent),gt.parent?gt===gt.parent.left?gt.parent.left=wt:gt.parent.right=wt:this._root=wt,wt&&(wt.right=gt),gt.parent=wt},m.prototype._splay=function(gt){for(;gt.parent;){var wt=gt.parent;wt.parent?wt.left===gt&&wt.parent.left===wt?(this.rotateRight(wt.parent),this.rotateRight(wt)):wt.right===gt&&wt.parent.right===wt?(this.rotateLeft(wt.parent),this.rotateLeft(wt)):wt.left===gt&&wt.parent.right===wt?(this.rotateRight(wt),this.rotateLeft(wt)):(this.rotateLeft(wt),this.rotateRight(wt)):wt.left===gt?this.rotateRight(wt):this.rotateLeft(wt)}},m.prototype.splay=function(gt){for(var wt,ms,Rs,nr,ar;gt.parent;)(ms=(wt=gt.parent).parent)&&ms.parent?((Rs=ms.parent).left===ms?Rs.left=gt:Rs.right=gt,gt.parent=Rs):(gt.parent=null,this._root=gt),nr=gt.left,ar=gt.right,gt===wt.left?(ms&&(ms.left===wt?(wt.right?(ms.left=wt.right,ms.left.parent=ms):ms.left=null,wt.right=ms,ms.parent=wt):(nr?(ms.right=nr,nr.parent=ms):ms.right=null,gt.left=ms,ms.parent=gt)),ar?(wt.left=ar,ar.parent=wt):wt.left=null,gt.right=wt,wt.parent=gt):(ms&&(ms.right===wt?(wt.left?(ms.right=wt.left,ms.right.parent=ms):ms.right=null,wt.left=ms,ms.parent=wt):(ar?(ms.left=ar,ar.parent=ms):ms.left=null,gt.right=ms,ms.parent=gt)),nr?(wt.right=nr,nr.parent=wt):wt.right=null,gt.left=wt,wt.parent=gt)},m.prototype.replace=function(gt,wt){gt.parent?gt===gt.parent.left?gt.parent.left=wt:gt.parent.right=wt:this._root=wt,wt&&(wt.parent=gt.parent)},m.prototype.minNode=function(gt){if(gt===void 0&&(gt=this._root),gt)for(;gt.left;)gt=gt.left;return gt},m.prototype.maxNode=function(gt){if(gt===void 0&&(gt=this._root),gt)for(;gt.right;)gt=gt.right;return gt},m.prototype.insert=function(gt,wt){var ms=this._root,Rs=null,nr=this._compare;if(this._noDuplicates)for(;ms;){if(Rs=ms,nr(ms.key,gt)===0)return;ms=nr(ms.key,gt)<0?ms.right:ms.left}else for(;ms;)Rs=ms,ms=nr(ms.key,gt)<0?ms.right:ms.left;return ms={key:gt,data:wt,left:null,right:null,parent:Rs},Rs?nr(Rs.key,ms.key)<0?Rs.right=ms:Rs.left=ms:this._root=ms,this.splay(ms),this._size++,ms},m.prototype.find=function(gt){for(var wt=this._root,ms=this._compare;wt;){var Rs=ms(wt.key,gt);if(Rs<0)wt=wt.right;else{if(!(Rs>0))return wt;wt=wt.left}}return null},m.prototype.contains=function(gt){for(var wt=this._root,ms=this._compare;wt;){var Rs=ms(gt,wt.key);if(Rs===0)return!0;wt=Rs<0?wt.left:wt.right}return!1},m.prototype.remove=function(gt){var wt=this.find(gt);if(!wt)return!1;if(this.splay(wt),wt.left)if(wt.right){var ms=this.minNode(wt.right);ms.parent!==wt&&(this.replace(ms,ms.right),ms.right=wt.right,ms.right.parent=ms),this.replace(wt,ms),ms.left=wt.left,ms.left.parent=ms}else this.replace(wt,wt.left);else this.replace(wt,wt.right);return this._size--,!0},m.prototype.removeNode=function(gt){if(!gt)return!1;if(this.splay(gt),gt.left)if(gt.right){var wt=this.minNode(gt.right);wt.parent!==gt&&(this.replace(wt,wt.right),wt.right=gt.right,wt.right.parent=wt),this.replace(gt,wt),wt.left=gt.left,wt.left.parent=wt}else this.replace(gt,gt.left);else this.replace(gt,gt.right);return this._size--,!0},m.prototype.erase=function(gt){var wt=this.find(gt);if(wt){this.splay(wt);var ms=wt.left,Rs=wt.right,nr=null;ms&&(ms.parent=null,nr=this.maxNode(ms),this.splay(nr),this._root=nr),Rs&&(ms?nr.right=Rs:this._root=Rs,Rs.parent=nr),this._size--}},m.prototype.pop=function(){var gt=this._root,wt=null;if(gt){for(;gt.left;)gt=gt.left;wt={key:gt.key,data:gt.data},this.remove(gt.key)}return wt},m.prototype.next=function(gt){var wt=gt;if(wt)if(wt.right)for(wt=wt.right;wt&&wt.left;)wt=wt.left;else for(wt=gt.parent;wt&&wt.right===gt;)gt=wt,wt=wt.parent;return wt},m.prototype.prev=function(gt){var wt=gt;if(wt)if(wt.left)for(wt=wt.left;wt&&wt.right;)wt=wt.right;else for(wt=gt.parent;wt&&wt.left===gt;)gt=wt,wt=wt.parent;return wt},m.prototype.forEach=function(gt){for(var wt=this._root,ms=[],Rs=!1,nr=0;!Rs;)wt?(ms.push(wt),wt=wt.left):ms.length>0?(gt(wt=ms.pop(),nr++),wt=wt.right):Rs=!0;return this},m.prototype.range=function(gt,wt,ms,Rs){for(var nr=[],ar=this._compare,Dr=this._root;nr.length!==0||Dr;)if(Dr)nr.push(Dr),Dr=Dr.left;else{if(ar((Dr=nr.pop()).key,wt)>0)break;if(ar(Dr.key,gt)>=0&&ms.call(Rs,Dr))return this;Dr=Dr.right}return this},m.prototype.keys=function(){for(var gt=this._root,wt=[],ms=[],Rs=!1;!Rs;)gt?(wt.push(gt),gt=gt.left):wt.length>0?(gt=wt.pop(),ms.push(gt.key),gt=gt.right):Rs=!0;return ms},m.prototype.values=function(){for(var gt=this._root,wt=[],ms=[],Rs=!1;!Rs;)gt?(wt.push(gt),gt=gt.left):wt.length>0?(gt=wt.pop(),ms.push(gt.data),gt=gt.right):Rs=!0;return ms},m.prototype.at=function(gt){for(var wt=this._root,ms=[],Rs=!1,nr=0;!Rs;)if(wt)ms.push(wt),wt=wt.left;else if(ms.length>0){if(wt=ms.pop(),nr===gt)return wt;nr++,wt=wt.right}else Rs=!0;return null},m.prototype.load=function(gt,wt,ms){if(gt===void 0&&(gt=[]),wt===void 0&&(wt=[]),ms===void 0&&(ms=!1),this._size!==0)throw new Error("bulk-load: tree is not empty");var Rs=gt.length;return ms&&E(gt,wt,0,Rs-1,this._compare),this._root=k(null,gt,wt,0,Rs),this._size=Rs,this},m.prototype.min=function(){var gt=this.minNode(this._root);return gt?gt.key:null},m.prototype.max=function(){var gt=this.maxNode(this._root);return gt?gt.key:null},m.prototype.isEmpty=function(){return this._root===null},y.size.get=function(){return this._size},m.createTree=function(gt,wt,ms,Rs,nr){return new m(ms,nr).load(gt,wt,Rs)},Object.defineProperties(m.prototype,y);var P=0,O=1,B=2,W=3,J=0,ee=1,ne=2,ce=3;function ue(gt,wt,ms){wt===null?(gt.inOut=!1,gt.otherInOut=!0):(gt.isSubject===wt.isSubject?(gt.inOut=!wt.inOut,gt.otherInOut=wt.otherInOut):(gt.inOut=!wt.otherInOut,gt.otherInOut=wt.isVertical()?!wt.inOut:wt.inOut),wt&&(gt.prevInResult=!je(wt,ms)||wt.isVertical()?wt.prevInResult:wt));var Rs=je(gt,ms);gt.resultTransition=Rs?function(nr,ar){var Dr,zr=!nr.inOut,kn=!nr.otherInOut;switch(ar){case J:Dr=zr&&kn;break;case ee:Dr=zr||kn;break;case ce:Dr=zr^kn;break;case ne:Dr=nr.isSubject?zr&&!kn:kn&&!zr}return Dr?1:-1}(gt,ms):0}function je(gt,wt){switch(gt.type){case P:switch(wt){case J:return!gt.otherInOut;case ee:return gt.otherInOut;case ne:return gt.isSubject&>.otherInOut||!gt.isSubject&&!gt.otherInOut;case ce:return!0}break;case B:return wt===J||wt===ee;case W:return wt===ne;case O:return!1}return!1}var Le=function(gt,wt,ms,Rs,nr){this.left=wt,this.point=gt,this.otherEvent=ms,this.isSubject=Rs,this.type=nr||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 Ge(gt,wt){return gt[0]===wt[0]&>[1]===wt[1]}Le.prototype.isBelow=function(gt){var wt=this.point,ms=this.otherEvent.point;return this.left?(wt[0]-gt[0])*(ms[1]-gt[1])-(ms[0]-gt[0])*(wt[1]-gt[1])>0:(ms[0]-gt[0])*(wt[1]-gt[1])-(wt[0]-gt[0])*(ms[1]-gt[1])>0},Le.prototype.isAbove=function(gt){return!this.isBelow(gt)},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 gt=new Le(this.point,this.left,this.otherEvent,this.isSubject,this.type);return gt.contourId=this.contourId,gt.resultTransition=this.resultTransition,gt.prevInResult=this.prevInResult,gt.isExteriorRing=this.isExteriorRing,gt.inOut=this.inOut,gt.otherInOut=this.otherInOut,gt},Object.defineProperties(Le.prototype,Ie);var Xe=11102230246251565e-32,rt=134217729,_t=(3+8*Xe)*Xe;function ft(gt,wt,ms,Rs,nr){var ar,Dr,zr,kn,Bn=wt[0],Hn=Rs[0],aa=0,en=0;Hn>Bn==Hn>-Bn?(ar=Bn,Bn=wt[++aa]):(ar=Hn,Hn=Rs[++en]);var un=0;if(aaBn==Hn>-Bn?(zr=ar-((Dr=Bn+ar)-Bn),Bn=wt[++aa]):(zr=ar-((Dr=Hn+ar)-Hn),Hn=Rs[++en]),ar=Dr,zr!==0&&(nr[un++]=zr);aaBn==Hn>-Bn?(zr=ar-((Dr=ar+Bn)-(kn=Dr-ar))+(Bn-kn),Bn=wt[++aa]):(zr=ar-((Dr=ar+Hn)-(kn=Dr-ar))+(Hn-kn),Hn=Rs[++en]),ar=Dr,zr!==0&&(nr[un++]=zr);for(;aa0!=aa>0)return en;var un=Math.abs(Hn+aa);return Math.abs(en)>=It*un?en:-function(Pa,Fa,za,li,ki,vi,Ga){var ei,$n,ga,so,Yr,ia,bi,Ei,Di,Ro,Pi,Xr,po,ci,Wi,wl,ic,al,il=Pa-ki,Vl=za-ki,Cu=Fa-vi,Ii=li-vi;Wt[0]=(Wi=(Ei=il-(bi=(ia=rt*il)-(ia-il)))*(Ro=Ii-(Di=(ia=rt*Ii)-(ia-Ii)))-((ci=il*Ii)-bi*Di-Ei*Di-bi*Ro))-((Pi=Wi-(ic=(Ei=Cu-(bi=(ia=rt*Cu)-(ia-Cu)))*(Ro=Vl-(Di=(ia=rt*Vl)-(ia-Vl)))-((wl=Cu*Vl)-bi*Di-Ei*Di-bi*Ro)))+(Yr=Wi-Pi))+(Yr-ic),Wt[1]=(po=ci-((Xr=ci+Pi)-(Yr=Xr-ci))+(Pi-Yr))-((Pi=po-wl)+(Yr=po-Pi))+(Yr-wl),Wt[2]=Xr-((al=Xr+Pi)-(Yr=al-Xr))+(Pi-Yr),Wt[3]=al;var Ao=function(yx,td){for(var tu=td[0],bh=1;bh<4;bh++)tu+=td[bh];return tu}(0,Wt),Fo=$t*Ga;if(Ao>=Fo||-Ao>=Fo||(ei=Pa-(il+(Yr=Pa-il))+(Yr-ki),ga=za-(Vl+(Yr=za-Vl))+(Yr-ki),$n=Fa-(Cu+(Yr=Fa-Cu))+(Yr-vi),so=li-(Ii+(Yr=li-Ii))+(Yr-vi),ei===0&&$n===0&&ga===0&&so===0)||(Fo=as*Ga+_t*Math.abs(Ao),(Ao+=il*so+Ii*ei-(Cu*ga+Vl*$n))>=Fo||-Ao>=Fo))return Ao;Os[0]=(Wi=(Ei=ei-(bi=(ia=rt*ei)-(ia-ei)))*(Ro=Ii-(Di=(ia=rt*Ii)-(ia-Ii)))-((ci=ei*Ii)-bi*Di-Ei*Di-bi*Ro))-((Pi=Wi-(ic=(Ei=$n-(bi=(ia=rt*$n)-(ia-$n)))*(Ro=Vl-(Di=(ia=rt*Vl)-(ia-Vl)))-((wl=$n*Vl)-bi*Di-Ei*Di-bi*Ro)))+(Yr=Wi-Pi))+(Yr-ic),Os[1]=(po=ci-((Xr=ci+Pi)-(Yr=Xr-ci))+(Pi-Yr))-((Pi=po-wl)+(Yr=po-Pi))+(Yr-wl),Os[2]=Xr-((al=Xr+Pi)-(Yr=al-Xr))+(Pi-Yr),Os[3]=al;var Vu=ft(4,Wt,4,Os,hs);Os[0]=(Wi=(Ei=il-(bi=(ia=rt*il)-(ia-il)))*(Ro=so-(Di=(ia=rt*so)-(ia-so)))-((ci=il*so)-bi*Di-Ei*Di-bi*Ro))-((Pi=Wi-(ic=(Ei=Cu-(bi=(ia=rt*Cu)-(ia-Cu)))*(Ro=ga-(Di=(ia=rt*ga)-(ia-ga)))-((wl=Cu*ga)-bi*Di-Ei*Di-bi*Ro)))+(Yr=Wi-Pi))+(Yr-ic),Os[1]=(po=ci-((Xr=ci+Pi)-(Yr=Xr-ci))+(Pi-Yr))-((Pi=po-wl)+(Yr=po-Pi))+(Yr-wl),Os[2]=Xr-((al=Xr+Pi)-(Yr=al-Xr))+(Pi-Yr),Os[3]=al;var jl=ft(Vu,hs,4,Os,_s);Os[0]=(Wi=(Ei=ei-(bi=(ia=rt*ei)-(ia-ei)))*(Ro=so-(Di=(ia=rt*so)-(ia-so)))-((ci=ei*so)-bi*Di-Ei*Di-bi*Ro))-((Pi=Wi-(ic=(Ei=$n-(bi=(ia=rt*$n)-(ia-$n)))*(Ro=ga-(Di=(ia=rt*ga)-(ia-ga)))-((wl=$n*ga)-bi*Di-Ei*Di-bi*Ro)))+(Yr=Wi-Pi))+(Yr-ic),Os[1]=(po=ci-((Xr=ci+Pi)-(Yr=Xr-ci))+(Pi-Yr))-((Pi=po-wl)+(Yr=po-Pi))+(Yr-wl),Os[2]=Xr-((al=Xr+Pi)-(Yr=al-Xr))+(Pi-Yr),Os[3]=al;var zp=ft(jl,_s,4,Os,bs);return bs[zp-1]}(nr,ar,Dr,zr,kn,Bn,un)}(gt[0],gt[1],wt[0],wt[1],ms[0],ms[1]);return Rs>0?-1:Rs<0?1:0}function Ps(gt,wt){var ms=gt.point,Rs=wt.point;return ms[0]>Rs[0]?1:ms[0]Rs[1]?1:-1:function(nr,ar,Dr,zr){return nr.left!==ar.left?nr.left?1:-1:Fs(Dr,nr.otherEvent.point,ar.otherEvent.point)!==0?nr.isBelow(ar.otherEvent.point)?-1:1:!nr.isSubject&&ar.isSubject?1:-1}(gt,wt,ms)}function Ls(gt,wt,ms){var Rs=new Le(wt,!1,gt,gt.isSubject),nr=new Le(wt,!0,gt.otherEvent,gt.isSubject);return Ge(gt.point,gt.otherEvent.point)&&console.warn("what is that, a collapsed segment?",gt),Rs.contourId=nr.contourId=gt.contourId,Ps(nr,gt.otherEvent)>0&&(gt.otherEvent.left=!0,nr.left=!1),gt.otherEvent.otherEvent=nr,gt.otherEvent=Rs,ms.push(nr),ms.push(Rs),ms}function us(gt,wt){return gt[0]*wt[1]-gt[1]*wt[0]}function is(gt,wt){return gt[0]*wt[0]+gt[1]*wt[1]}function Ds(gt,wt,ms){var Rs=function(kn,Bn,Hn,aa,en){var un=[Bn[0]-kn[0],Bn[1]-kn[1]],Pa=[aa[0]-Hn[0],aa[1]-Hn[1]];function Fa(ia,bi,Ei){return[ia[0]+bi*Ei[0],ia[1]+bi*Ei[1]]}var za=[Hn[0]-kn[0],Hn[1]-kn[1]],li=us(un,Pa),ki=li*li,vi=is(un,un);if(ki>0){var Ga=us(za,Pa)/li;if(Ga<0||Ga>1)return null;var ei=us(za,un)/li;return ei<0||ei>1?null:Ga===0||Ga===1?[Fa(kn,Ga,un)]:ei===0||ei===1?[Fa(Hn,ei,Pa)]:[Fa(kn,Ga,un)]}if((ki=(li=us(za,un))*li)>0)return null;var $n=is(un,za)/vi,ga=$n+is(un,Pa)/vi,so=Math.min($n,ga),Yr=Math.max($n,ga);return so<=1&&Yr>=0?so===1?[Fa(kn,so>0?so:0,un)]:Yr===0?[Fa(kn,Yr<1?Yr:1,un)]:[Fa(kn,so>0?so:0,un),Fa(kn,Yr<1?Yr:1,un)]:null}(gt.point,gt.otherEvent.point,wt.point,wt.otherEvent.point),nr=Rs?Rs.length:0;if(nr===0||nr===1&&(Ge(gt.point,wt.point)||Ge(gt.otherEvent.point,wt.otherEvent.point))||nr===2&>.isSubject===wt.isSubject)return 0;if(nr===1)return Ge(gt.point,Rs[0])||Ge(gt.otherEvent.point,Rs[0])||Ls(gt,Rs[0],ms),Ge(wt.point,Rs[0])||Ge(wt.otherEvent.point,Rs[0])||Ls(wt,Rs[0],ms),1;var ar=[],Dr=!1,zr=!1;return Ge(gt.point,wt.point)?Dr=!0:Ps(gt,wt)===1?ar.push(wt,gt):ar.push(gt,wt),Ge(gt.otherEvent.point,wt.otherEvent.point)?zr=!0:Ps(gt.otherEvent,wt.otherEvent)===1?ar.push(wt.otherEvent,gt.otherEvent):ar.push(gt.otherEvent,wt.otherEvent),Dr&&zr||Dr?(wt.type=O,gt.type=wt.inOut===gt.inOut?B:W,Dr&&!zr&&Ls(ar[1].otherEvent,ar[0].point,ms),2):zr?(Ls(ar[0],ar[1].point,ms),3):ar[0]!==ar[3].otherEvent?(Ls(ar[0],ar[1].point,ms),Ls(ar[1],ar[2].point,ms),3):(Ls(ar[0],ar[1].point,ms),Ls(ar[3].otherEvent,ar[2].point,ms),3)}function Xs(gt,wt){if(gt===wt)return 0;if(Fs(gt.point,gt.otherEvent.point,wt.point)!==0||Fs(gt.point,gt.otherEvent.point,wt.otherEvent.point)!==0)return Ge(gt.point,wt.point)?gt.isBelow(wt.otherEvent.point)?-1:1:gt.point[0]===wt.point[0]?gt.point[1]wt.contourId?1:-1:Ps(gt,wt)===1?1:-1}var qs=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function Ir(gt,wt,ms,Rs){var nr,ar=gt+1,Dr=wt[gt].point,zr=wt.length;for(arRs;)ar--;return ar}qs.prototype.isExterior=function(){return this.holeOf==null};var lr=Nr,gr=Nr;function Nr(gt,wt){if(!(this instanceof Nr))return new Nr(gt,wt);if(this.data=gt||[],this.length=this.data.length,this.compare=wt||Wn,this.length>0)for(var ms=(this.length>>1)-1;ms>=0;ms--)this._down(ms)}function Wn(gt,wt){return gtwt?1:0}Nr.prototype={push:function(gt){this.data.push(gt),this.length++,this._up(this.length-1)},pop:function(){if(this.length!==0){var gt=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),gt}},peek:function(){return this.data[0]},_up:function(gt){for(var wt=this.data,ms=this.compare,Rs=wt[gt];gt>0;){var nr=gt-1>>1,ar=wt[nr];if(ms(Rs,ar)>=0)break;wt[gt]=ar,gt=nr}wt[gt]=Rs},_down:function(gt){for(var wt=this.data,ms=this.compare,Rs=this.length>>1,nr=wt[gt];gt=0)break;wt[gt]=zr,gt=ar}wt[gt]=nr}},lr.default=gr;var Us=Math.max,Sr=Math.min,hn=0;function ma(gt,wt,ms,Rs,nr,ar){var Dr,zr,kn,Bn,Hn,aa;for(Dr=0,zr=gt.length-1;Dr0?aa.left=!0:Hn.left=!0;var en=kn[0],un=kn[1];nr[0]=Sr(nr[0],en),nr[1]=Sr(nr[1],un),nr[2]=Us(nr[2],en),nr[3]=Us(nr[3],un),Rs.push(Hn),Rs.push(aa)}}var xa=[];function Pn(gt,wt,ms){typeof gt[0][0][0]=="number"&&(gt=[gt]),typeof wt[0][0][0]=="number"&&(wt=[wt]);var Rs=function(un,Pa,Fa){var za=null;return un.length*Pa.length==0&&(Fa===J?za=xa:Fa===ne?za=un:Fa!==ee&&Fa!==ce||(za=un.length===0?Pa:un)),za}(gt,wt,ms);if(Rs)return Rs===xa?null:Rs;var nr=[1/0,1/0,-1/0,-1/0],ar=[1/0,1/0,-1/0,-1/0],Dr=function(un,Pa,Fa,za,li){var ki,vi,Ga,ei,$n,ga,so=new lr(null,Ps);for(Ga=0,ei=un.length;Gaza[2]||za[0]>Fa[2]||Fa[1]>za[3]||za[1]>Fa[3])&&(li===J?ki=xa:li===ne?ki=un:li!==ee&&li!==ce||(ki=un.concat(Pa))),ki}(gt,wt,nr,ar,ms))return Rs===xa?null:Rs;for(var zr=function(un){var Pa,Fa,za=function(Ga){var ei,$n,ga,so,Yr=[];for($n=0,ga=Ga.length;$n0){var Pi=ia[Ro];if(Pi.holeOf!=null){var Xr=Pi.holeOf;ia[Xr].holeIds.push(bi),Ei.holeOf=Xr,Ei.depth=ia[Ro].depth}else ia[Ro].holeIds.push(bi),Ei.holeOf=Ro,Ei.depth=ia[Ro].depth+1}else Ei.holeOf=null,Ei.depth=ia[Ro].depth}else Ei.holeOf=null,Ei.depth=0;return Ei}(za[Pa],ki,Ga),$n=function(Yr){li[Yr]=!0,Yr=za.length)&&za[ga];);ki.push(ei)}};for(Pa=0,Fa=za.length;Paso||ki===ne&&Yr.point[0]>za[2])break;if(Yr.left){Ga=vi=$n.insert(Yr),vi=vi!==(ei=$n.minNode())?$n.prev(vi):null,Ga=$n.next(Ga);var ia=vi?vi.key:null;if(ue(Yr,ia,ki),Ga&&Ds(Yr,Ga.key,un)===2&&(ue(Yr,ia,ki),ue(Ga.key,Yr,ki)),vi&&Ds(vi.key,Yr,un)===2){var bi=vi;ue(ia,(bi=bi!==ei?$n.prev(bi):null)?bi.key:null,ki),ue(Yr,ia,ki)}}else Ga=vi=$n.find(Yr=Yr.otherEvent),vi&&Ga&&(vi=vi!==ei?$n.prev(vi):null,Ga=$n.next(Ga),$n.remove(Yr),Ga&&vi&&Ds(vi.key,Ga.key,un))}return ga}(Dr,0,0,nr,ar,ms)),kn=[],Bn=0;Bn * @license MIT * @preserve */function oO(f,c,m,y){const k=[],E=y===0?(P,O,B,W,J,ee)=>{P.push(new rs(ee,B+(ee-O)/(W-O)*(J-B)))}:(P,O,B,W,J,ee)=>{P.push(new rs(O+(ee-B)/(J-B)*(W-O),ee))};for(const P of f){const O=[];for(const B of P){if(B.length<=2)continue;const W=[];for(let ne=0;nec&&E(W,ce,ue,je,Le,c):Ie>m?Ge=c&&E(W,ce,ue,je,Le,c),Ge>m&&Ie<=m&&E(W,ce,ue,je,Le,m)}let J=B[B.length-1];const ee=y===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&&k.push(O)}return k}function Vet(f,c){const m=_de(f),y=_de([c]),k=mje.intersection(m,y);return k==null?[]:pje(k)}function Het(f,c){let y=_de(f,65536);const k=[];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,ne=J-B,ce=Math.hypot(ee,ne);if(ce===0)continue;const ue=Math.trunc(ne/ce*3),je=-Math.trunc(ee/ce*3);k.push([[[O,B],[W,J],[W+ue,J+je],[O+ue,B+je],[O,B]]])}return k.length>0&&(y=mje.diff(y,k)),pje(y,1/65536)}function _de(f,c=1){return[f.map(m=>m.map(y=>[y.x*c,y.y*c]))]}function pje(f,c=1){return f.map(m=>m.map((y,k)=>{const E=y.map(P=>new rs(P[0]*c,P[1]*c).round());return k>0&&E.reverse(),E}))}class bde{constructor(c,m){this.layoutVertexArray=new ux,this.indexArray=new vl,this.lineIndexArray=new xh,this.triangleSegments=new uo,this.lineSegments=new uo,this.programConfigurations=new Gm(c.layers,{zoom:c.zoom,lut:c.lut}),this.uploaded=!1,m&&(this.elevatedLayoutVertexArray=new Wf)}update(c,m,y,k,E,P,O,B){this.programConfigurations.updatePaintArrays(c,m,E,y,k,P,O,B)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,Tet.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,Aet.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,y,k,E,P,O){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,m,y,k,E,P,void 0,O)}}class wde{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 bde(c,!1),this.elevationBufferData=new bde(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,y,k){}populate(c,m,y,k){this.hasPattern=yde("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,ne=Ht(O,ee);if(!this.layers[0]._featureFilter.filter(new Li(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ne,y))continue;const ce=E?E.evaluate(ne,{},y,m.availableImages):void 0,ue={id:B,properties:O.properties,type:O.type,sourceLayerIndex:J,index:W,geometry:ee?ne.geometry:Pt(O,y,k),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=vde("fill",this.layers,O,this.zoom,this.pixelRatio,m);this.patternFeatures.push(ee)}else this.addFeature(O,B,W,y,{},m.availableImages,m.brightness,m.elevationFeatures);m.featureIndex.insert(c[W].feature,B,W,J,this.index)}}update(c,m,y,k,E,P,O){this.bufferData.update(c,m,y,k,E,P,O,this.worldview),this.elevationBufferData.update(c,m,y,k,E,P,O,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(c,m,y,k,E,P,O,this.worldview)}addFeatures(c,m,y,k,E,P){for(const O of this.patternFeatures)this.addFeature(O,O.geometry,O.index,m,y,k,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,y,k,E,P=[],O,B){const W=JT(m,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(c,W,k,y,B):this.addGeometry(W,this.bufferData),this.bufferData.populatePaintArrays(c,y,E,P,k,O,this.worldview),this.elevationBufferData.populatePaintArrays(c,y,E,P,k,O,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(c,m,y,k,E){this.elevatedStructures&&(this.elevatedStructures.construct(c),this.elevatedStructures.populatePaintArrays(m,y,k,E,this.worldview))}addElevatedRoadFeature(c,m,y,k,E){const P=new Array,O=Qa.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:y})}const B={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(c,{},y),featureIndex:k};for(const W of P)if(W.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new vh(W.elevationTileID,this.layers,this.zoom,this.lut));const ee=W.elevationFeature.isTunnel();let ne=0;c.properties.hasOwnProperty(es)&&(ne=+c.properties[es]);for(const ce of W.polygons)this.elevatedStructures.addPortalCandidates(W.elevationFeature.id,ce,ee,W.elevationFeature,ne)}W.elevationFeature.constantHeight==null&&(W.polygons=this.prepareElevatedPolygons(W.polygons,W.elevationFeature,W.elevationTileID));const J=new pi(y,W.elevationTileID);this.addElevatedGeometry(W.polygons,J,W.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,k,B)}}addElevatedGeometry(c,m,y,k,E,P){const O={elevation:y,elevationSampler:m,bias:k,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,y){let k=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY,P=null;y&&(P=y.elevationSampler.constantElevation(y.elevation,y.bias),P!=null&&(k=P,E=P));const O=(B,W,J)=>{if(y!=null)if(W.push(B),P!=null)m.elevatedLayoutVertexArray.emplaceBack(P),J.push(P);else{const ee=y.elevationSampler.pointElevation(B,y.elevation,y.bias);m.elevatedLayoutVertexArray.emplaceBack(ee),J.push(ee),k=Math.min(k,ee),E=Math.max(E,ee)}};for(const B of c){let W=0;for(const Xe of B)W+=Xe.length;const J=m.triangleSegments.prepareSegment(W,m.layoutVertexArray,m.indexArray),ee=J.vertexLength,ne=[],ce=[],ue=[],je=[],Le=[],Ie=m.layoutVertexArray.length;for(const Xe of B){if(Xe.length===0)continue;Xe!==B[0]&&ce.push(ne.length/2);const rt=m.lineSegments.prepareSegment(Xe.length,m.layoutVertexArray,m.lineIndexArray),_t=rt.vertexLength;y&&Le.push(m.layoutVertexArray.length-Ie),O(Xe[0],ue,je),m.layoutVertexArray.emplaceBack(Xe[0].x,Xe[0].y),m.lineIndexArray.emplaceBack(_t+Xe.length-1,_t),ne.push(Xe[0].x),ne.push(Xe[0].y);for(let ft=1;ft0&&y&&this.elevationMode==="hd-road-base"){const Xe=y.elevation.isTunnel(),rt=y.elevation.safeArea,_t=this.elevatedStructures.addVertices(ue,je);this.elevatedStructures.addTriangles(Ge,_t,Xe);const ft=Le.length;if(ft>0){for(let St=0;St=y&&ce.max.x<=E&&ce.min.y>=k&&ce.max.y<=P?B:W).push(ne)}if(B.length===c.length)return c;const J=[new rs(y,k),new rs(E,k),new rs(E,P),new rs(y,P),new rs(y,k)],ee=B;for(const ne of W)ee.push(...Vet(ne,J));return ee}}let fje,gje,xje,yje;_r(wde,"FillBucket",{omit:["layers","patternFeatures"]}),_r(bde,"FillBufferData"),_r(vh,"ElevatedStructures");class lO{constructor(c,m,y,k){if(this.triangleCount=m.length/3,this.min=new rs(0,0),this.max=new rs(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-ne.cellIdx||ee.triIdx-ne.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 y=gx(c.x-this.min.x,this.xScale,this.cellsX),k=gx(c.y-this.min.y,this.yScale,this.cellsY),E=this.cells[k*this.cellsX+y];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 k=gx(c.x-this.min.x,this.xScale,this.cellsX),E=gx(m.x-this.min.x,this.xScale,this.cellsX),P=gx(c.y-this.min.y,this.yScale,this.cellsY),O=gx(m.y-this.min.y,this.yScale,this.cellsY);for(let B=P;B<=O;B++)for(let W=k;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 y of this.footprints)m.push({footprint:y,id:c})}updateAppearances(c,m,y,k){}populate(c,m,y,k){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 Li(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ee,y))continue;const ne={id:O,properties:P.properties,type:P.type,sourceLayerIndex:W,index:B,geometry:J?ee.geometry:Pt(P,y,k),patterns:{}};E.push(ne)}for(const P of E){const{geometry:O,index:B,sourceLayerIndex:W}=P;this.addFeature(P,O,B,y,{},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,y,k,E,P,O){}destroy(){}addFeature(c,m,y,k,E,P=[],O){for(const B of JT(m,2)){const W=[],J=[],ee=[],ne=new rs(1/0,1/0),ce=new rs(-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===k)===void 0}(y,f.clipScope)}function cO(f,c){return f.x-c.x||f.y-c.y}function wje(f,c){return cO(f.min,c.min)===0&&cO(f.max,c.max)===0}function jde(f,c){return!(f.min.x>c.max.x||f.max.xc.max.y||f.max.ynew rs((B.x+E.x*Ys)*O-P.x*Ys,(B.y+E.y*Ys)*O-P.y*Ys))}return kde(m,k,f.indices,0,f.indices.length,0,0)}function Nje(f,c,m,y){const k=Math.pow(2,y.z-m.z);return new rs((f+m.x*Ys)*k-y.x*Ys,(c+m.y*Ys)*k-y.y*Ys)}function Sje(f,c){const m=[];c.grid.queryPoint(f,m);const y=c.indices,k=c.vertices;for(let E=0;E0&&(y.length>1&&m.push(y),y=[])}return y.length>1&&m.push(y),m}const Sde=Vt.types,ttt=["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"],stt=["fill-extrusion-flood-light-ground-radius"],rtt=Math.pow(2,13),ntt=Math.pow(2,15)-1,Mje=new rs(0,1),zy=2147483648,Tje=7,Aje=450;function tA(f,c,m,y,k,E,P,O){f.emplaceBack((c<<1)+P,(m<<1)+E,(Math.floor(y*rtt)<<1)+k,Math.round(O))}function sA(f,c,m){f.emplaceBack(c.x*Ys,c.y*Ys,m?1:0)}function uO(f,c,m,y,k,E){f.emplaceBack(c.x,c.y,(m.x<<1)+y,(m.y<<1)+k,E)}function rA(f,c,m){f.emplaceBack(c.x,c.y,c.z,m[0]*16384,m[1]*16384,m[2]*16384)}class Eje{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class Pje{constructor(){this.centroidXY=new rs(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 rs(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new rs(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new rs(this.max.x-this.min.x,this.max.y-this.min.y)}}class Ije{constructor(){this.acc=new rs(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,y){this.accCount++,this.acc._add(m);let k=!!this.borders;m.xc.max.x&&(c.max.x=m.x,k=!0),m.yc.max.y&&(c.max.y=m.y,k=!0),((m.x===0||m.x===Ys)&&m.x===y.x)!=((m.y===0||m.y===Ys)&&m.y===y.y)&&this.processBorderOverlap(m,y),k&&this.checkBorderIntersection(m,y)}checkBorderIntersection(c,m){m.x<0!=c.x<0&&this.addBorderIntersection(0,Vr(m.y,c.y,(0-m.x)/(c.x-m.x))),m.x>Ys!=c.x>Ys&&this.addBorderIntersection(1,Vr(m.y,c.y,(Ys-m.x)/(c.x-m.x))),m.y<0!=c.y<0&&this.addBorderIntersection(2,Vr(m.x,c.x,(0-m.y)/(c.y-m.y))),m.y>Ys!=c.y>Ys&&this.addBorderIntersection(3,Vr(m.x,c.x,(Ys-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 y=this.borders[c];my[1]&&(y[1]=m)}processBorderOverlap(c,m){if(c.x===m.x){if(c.y===m.y)return;const y=c.x===0?0:1;this.addBorderIntersection(y,m.y),this.addBorderIntersection(y,c.y)}else{const y=c.y===0?2:3;this.addBorderIntersection(y,m.x),this.addBorderIntersection(y,c.x)}}centroid(){return this.accCount===0?new rs(0,0):new rs(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 Lje(f,c){const m=f.add(c)._unit(),y=Se(f.x*m.x+f.y*m.y,-1,1);var k,E,P;return k=Math.acos(y),Math.min(4,Math.max(-4,Math.tan(k)))/4*ntt*((E=f).x*(P=c).y-E.y*P.x<0?-1:1)}const att=[f=>f.x<0,f=>f.x>Ys,f=>f.y<0,f=>f.y>Ys];function itt(f,c,m,y){const k=[4];if(y===0)return k;m._mult(y);const E=f.sub(m),P=c.sub(m),O=[f,c,E,P];for(let B=0;B<4;B++)for(const W of O)if(att[B](W)){k.push(B);break}return k}class Cde{constructor(c){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new TT,this.indexArray=new vl,this.programConfigurations=new Gm(c.layers,{zoom:c.zoom,lut:c.lut},m=>stt.includes(m)),this._segments=new uo,this.hiddenByLandmarkVertexArray=new dC,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new uo}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(c,m,y,k=!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=Lje(W.sub(c[E-1])._perp()._unit(),J.sub(W)._perp()._unit())}for(let W=0;Wk.region-E.region);for(let y=0;yB+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 uo);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,Xet.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 hO{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 vl,this.footprintVertices=new ux,this.footprintSegments=[],this.layoutVertexArray=new Tv,this.centroidVertexArray=new JD,this.wallVertexArray=new Sb,this.indexArray=new vl,this.programConfigurations=new Gm(c.layers,{zoom:c.zoom,lut:c.lut},m=>ttt.includes(m)),this.segments=new uo,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.groundEffect=new Cde(c),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,y,k){}populate(c,m,y,k){this.features=[],this.hasPattern=yde("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(y),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 Li(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),J,y))continue;const ee={id:P,sourceLayerIndex:B,index:O,geometry:W?J.geometry:Pt(E,y,k),properties:E.properties,type:E.type,patterns:{}},ne=this.layoutVertexArray.length,ce=Sde[ee.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:E.id,feature:vde("fill-extrusion",this.layers,ee,this.zoom,this.pixelRatio,m)});else if(this.wallMode)for(const ue of ee.geometry)for(const je of Cje(ue,ce))this.addFeature(E.id,ee,[je],O,y,{},m.availableImages,k,m.brightness);else this.addFeature(E.id,ee,ee.geometry,O,y,{},m.availableImages,k,m.brightness);m.featureIndex.insert(E,ee.geometry,O,B,this.index,ne)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(c,m,y,k,E,P){for(const{featureId:O,feature:B}of this.features){const W=Sde[B.type]==="Polygon",{geometry:J}=B;if(this.wallMode)for(const ee of J)for(const ne of Cje(ee,W))this.addFeature(O,B,[ne],B.index,m,y,k,E,P);else this.addFeature(O,B,J,B.index,m,y,k,E,P)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(c,m,y,k,E,P,O){this.programConfigurations.updatePaintArrays(c,m,E,y,k,P,O,this.worldview),this.groundEffect.update(c,m,E,y,k,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,Jet),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.wallVertexBuffer=c.createVertexBuffer(this.wallVertexArray,Yet.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=c.createVertexBuffer(this.layoutVertexExtArray,Qet.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,Zet.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,y,k,E,P,O,B,W){const J=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(m,{})/this.tileToMeter,ee=[new rs(0,0),new rs(Ys,Ys)],ne=B.projection,ce=ne.name==="globe",ue=this.wallMode||Sde[m.type]==="Polygon",je=new Ije;je.centroidDataIndex=this.centroidData.length;const Le=new Pje;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,Ge=this.layers[0].paint.get("fill-extrusion-height").evaluate(m,{},E);let Xe;if(Le.height=Ge,Le.vertexArrayOffset=this.layoutVertexArray.length,Le.groundVertexArrayOffset=this.groundEffect.vertexArray.length,ce&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new nC),this.wallMode){if(ce)return void cr("Non zero fill-extrusion-line-width is not yet supported on globe.");if(y.length!==1)return;Xe=function(Wt){const hs=Wt[0].x===Wt[Wt.length-1].x&&Wt[0].y===Wt[Wt.length-1].y;(function(gr){let Nr=0;const Wn=gr.length;for(let Us=0;Us=0})(Wt)||(Wt=Wt.reverse());const bs={geometry:[],joinNormals:[],indices:[]},Os=[],Fs=[],Ps=[];let Ls=Wt.length;for(;Ls>=2&&Wt[Ls-1].equals(Wt[Ls-2]);)Ls--;if(Ls<(hs?3:2))return bs;let us,is,Ds,Xs,qs,Ir=0;for(;Ir0;let hn="miter";const ma=2;hn==="miter"&&Us>ma&&(hn="bevel"),hn==="bevel"&&(Us>100&&(hn="flipbevel"),Us{const ms=new rs(Pn.x,Pn.y),Rs=new rs(Pn.x,Pn.y);ms.x+=yi.x*wt,ms.y+=yi.y*wt,Rs.x-=yi.x*Math.max(gt,1),Rs.y-=yi.y*Math.max(gt,1),Ps.push(yi),Os.push(ms),Fs.push(Rs)};if(hn==="miter")Nr._mult(Us),xa(us,Nr,0,0);else if(hn==="flipbevel")Nr=qs.mult(-1),xa(us,Nr,0,0),xa(us,Nr.mult(-1),0,0);else{const Pn=-Math.sqrt(Us*Us-1),yi=Sr?Pn:0,gt=Sr?0:Pn;is&&xa(us,Xs,yi,gt),Ds&&xa(us,qs,yi,gt)}}bs.geometry=[...Os,...Fs.reverse(),Os[0]],bs.joinNormals=[...Ps,...Ps.reverse(),Ps[Ps.length-1]];const lr=bs.geometry.length-1;for(let gr=0;grWt<(hs.length-1)/2||Wt===hs.length-1,_t=this.wallMode?[y]:JT(y,500);for(let Wt=_t.length-1;Wt>=0;Wt--){const hs=_t[Wt];(hs.length===0||(ft=hs[0]).every(_s=>_s.x<=0)||ft.every(_s=>_s.x>=Ys)||ft.every(_s=>_s.y<=0)||ft.every(_s=>_s.y>=Ys))&&_t.splice(Wt,1)}var ft;let St;if(ce)St=$je(_t,ee,E);else{St=[];for(const Wt of _t)St.push({polygon:Wt,bounds:ee})}const It=ue?this.edgeRadius:0,$t=It>0&&this.zoom<17,as=(Wt,hs)=>{if(Wt.length===0)return!1;const _s=Wt[Wt.length-1];return hs.x===_s.x&&hs.y===_s.y};for(const{polygon:Wt,bounds:hs}of St){let _s=0,bs=0;for(const Ls of Wt)ue&&!Ls[0].equals(Ls[Ls.length-1])&&Ls.push(Ls[0]),bs+=ue?Ls.length-1:Ls.length;const Os=this.segments.prepareSegment((ue?5:4)*bs,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 Eje;if(Ps.vertexOffset=this.footprintVertices.length,Ps.indexOffset=3*this.footprintIndices.length,Ps.ringIndices=[],ue){const Ls=[],us=[];_s=Os.vertexLength;for(let Ds=0;Ds4&&Fje(us[us.length-2],us[0],us[1]),Ds=It?ott(us[us.length-2],us[0],us[1],It):0;const Xs=[];let qs,Ir,lr;Ir=us[1].sub(us[0])._perp()._unit();let gr=!0;for(let Nr=1,Wn=0;Nr0?1:0,yi=Us.dist(Sr);if(Wn+yi>32768&&(Wn=0),It){lr=hn.sub(Sr)._perp()._unit();let Rs=Oje(Us,Sr,hn,Dje(Ir,lr),It);isNaN(Rs)&&(Rs=0);const nr=Sr.sub(Us)._unit();Us=Us.add(nr.mult(Ds))._round(),Sr=Sr.add(nr.mult(-Rs))._round(),Ds=Rs,Ir=lr,Ie&&this.zoom>=17&&(as(Xs,Us)||Xs.push(Us),as(Xs,Sr)||Xs.push(Sr))}const gt=Os.vertexLength,wt=us.length>4&&Fje(Us,Sr,hn);let ms=zje(Wn,is,gr);if(tA(this.layoutVertexArray,Us.x,Us.y,xa,Pn,0,0,ms),tA(this.layoutVertexArray,Us.x,Us.y,xa,Pn,0,1,ms),this.wallMode){const Rs=rt(Nr-1,us),nr=Xe.joinNormals[Nr-1];sA(this.wallVertexArray,nr,Rs),sA(this.wallVertexArray,nr,Rs)}if(Wn+=yi,ms=zje(Wn,wt,!gr),is=wt,tA(this.layoutVertexArray,Sr.x,Sr.y,xa,Pn,0,0,ms),tA(this.layoutVertexArray,Sr.x,Sr.y,xa,Pn,0,1,ms),this.wallMode){const Rs=rt(Nr,us),nr=Xe.joinNormals[Nr];sA(this.wallVertexArray,nr,Rs),sA(this.wallVertexArray,nr,Rs)}if(Os.vertexLength+=4,this.indexArray.emplaceBack(gt+0,gt+1,gt+2),this.indexArray.emplaceBack(gt+1,gt+3,gt+2),Os.primitiveLength+=2,It){const Rs=_s+(Nr===1?us.length-2:Nr-2),nr=Nr===1?_s:Rs+1;if(this.indexArray.emplaceBack(gt+1,Rs,gt+3),this.indexArray.emplaceBack(Rs,nr,gt+3),Os.primitiveLength+=2,qs===void 0&&(qs=gt),!Mde(hn,us[Nr],hs)){const ar=Nr===us.length-1?qs:Os.vertexLength;this.indexArray.emplaceBack(gt+2,gt+3,ar),this.indexArray.emplaceBack(gt+3,ar+1,ar),this.indexArray.emplaceBack(gt+3,nr,ar+1),Os.primitiveLength+=3}gr=!gr}if(ce){const Rs=this.layoutVertexExtArray,nr=ne.projectTilePoint(Us.x,Us.y,E),ar=ne.projectTilePoint(Sr.x,Sr.y,E),Dr=ne.upVector(E,Us.x,Us.y),zr=ne.upVector(E,Sr.x,Sr.y);rA(Rs,nr,Dr),rA(Rs,nr,Dr),rA(Rs,ar,zr),rA(Rs,ar,zr)}}ue&&(_s+=us.length-1),Ie&&It&&this.zoom>=17&&(Xs.length!==0&&as(Xs,Xs[0])&&Xs.pop(),this.groundEffect.addData(Xs,hs,J,It>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=je.borders?Mje:this.encodeCentroid(je,Le),this.centroidData.push(Le),je.borders){this.featuresOnBorder.push(je);const Wt=this.featuresOnBorder.length-1;for(let hs=0;hsthis.featuresOnBorder[m].borders[c][0]-this.featuresOnBorder[y].borders[c][0])}splitToSubtiles(){const c=[];for(let O=0;OYs),J=2*W+(+(B.min.x+B.max.x>Ys)^W);for(let ee=0;eeO.triangleSegmentIdx===B.triangleSegmentIdx?O.subtile-B.subtile:O.triangleSegmentIdx-B.triangleSegmentIdx);let y=0,k=0,E=0;for(const O of c){if(O.triangleSegmentIdx!==y)break;E++}const P=c.length;for(;k!==c.length;){y=c[k].triangleSegmentIdx;let O=0,B=k,W=k;for(let J=B;J0&&this.triangleSubSegments.push({segment:ce,min:ee,max:ne}),B=W;for(let ue=B;ue[je[0]*(1-Ie[0])+Le[0]*Ie[0],je[1]*(1-Ie[1])+Le[1]*Ie[1]],ce=[],ue=[];for(const je of this.triangleSubSegments){ce[0]=je.min.x/Ys,ce[1]=je.min.y/Ys,ue[0]=je.max.x/Ys,ue[1]=je.max.y/Ys;const Le=ne(J,ee,ce),Ie=ne(J,ee,ue);if(new Er([Le[0],Le[1],E],[Ie[0],Ie[1],P]).intersectsPrecise(y)===0){W&&(k.segments.push(W),W=void 0);continue}const Ge=je.segment;W&&W.vertexOffset!==Ge.vertexOffset&&(k.segments.push(W),W=void 0),W?(W.vertexLength+=Ge.vertexLength,W.primitiveLength+=Ge.primitiveLength):W={vertexOffset:Ge.vertexOffset,primitiveLength:Ge.primitiveLength,vertexLength:Ge.vertexLength,primitiveOffset:Ge.primitiveOffset,sortKey:void 0,vaos:{}}}return W&&k.segments.push(W),k}encodeCentroid(c,m){const y=c.centroid(),k=m.span(),E=Math.min(7,Math.round(k.x*this.tileToMeter/10)),P=Math.min(7,Math.round(k.y*this.tileToMeter/10));return new rs(Se(y.x,1,Ys-1)<<3|E,Se(y.y,1,Ys-1)<<3|P)}encodeBorderCentroid(c){if(!c.borders)return new rs(0,0);const m=c.borders,y=Number.MAX_VALUE;if(m[0][0]!==y||m[1][0]!==y){const k=m[0][0]!==y?0:1;return new rs(6|(m[0][0]!==y?0:65528),(m[k][0]+m[k][1])/2<<3|6)}{const k=m[2][0]!==y?2:3;return new rs((m[k][0]+m[k][1])/2<<3|6,6|(m[2][0]!==y?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,y=c.vertexCount+c.vertexArrayOffset,k=c.flags&zy?Mje:c.centroidXY,E=this.centroidVertexArray.geta_centroid_pos0(m);if(this.centroidVertexArray.geta_centroid_pos1(m)!==k.y||E!==k.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|=zy);else for(const B of this.centroidData)if(!(B.flags&zy||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-ne)/(ce-ne)+ee&&(k=!k)}O=B}}return k}getHeightAtTileCoord(c,m){let y=Number.NEGATIVE_INFINITY,k=!0;const E=4*(c+Ys)*Ys+(m+Ys);if(this.partLookup.hasOwnProperty(E)){const P=this.partLookup[E];return P?{height:P.height,hidden:!!(P.flags&zy)}: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<=y||this.footprintContainsPoint(c,m,P)&&(y=P.height,this.partLookup[E]=P,k=!!(P.flags&zy));if(y!==Number.NEGATIVE_INFINITY)return{height:y,hidden:k};this.partLookup[E]=void 0}}function Dje(f,c){const m=f.add(c)._unit();return f.x*m.x+f.y*m.y}function ott(f,c,m,y){const k=c.sub(f)._perp()._unit(),E=m.sub(c)._perp()._unit();return Oje(f,c,m,Dje(k,E),y)}function Oje(f,c,m,y,k){const E=Math.sqrt(1-y*y);return Math.min(f.dist(c)/3,c.dist(m)/3,k*E/y)}function Mde(f,c,m){return f.xm[1].x&&c.x>m[1].x||f.ym[1].y&&c.y>m[1].y}function Rje(f,c){return f.xc[1].x||f.yc[1].y}function Fje(f,c,m){if(f.x<0||f.x>=Ys||c.x<0||c.x>=Ys||m.x<0||m.x>=Ys)return!1;const y=m.sub(c),k=y.perp(),E=f.sub(c);return(y.x*E.x+y.y*E.y)/Math.sqrt((y.x*y.x+y.y*y.y)*(E.x*E.x+E.y*E.y))>-.866&&k.x*E.x+k.y*E.y<0}function zje(f,c,m){const y=c?2|f:-3&f;return m?1|y:-2&y}function Bje(){const f=Math.PI/32,c=Math.tan(f),m=M;return m*Math.sqrt(1+2*c*c)-m}function $je(f,c,m){const y=1<{for(const It of ft)ue.push({polygon:It,bounds:St})},Le=Math.ceil(Math.log2(J)),Ie=Math.ceil(Math.log2(ee)),Ge=Le-Ie,Xe=[];for(let ft=0;ft0?0:1);for(let ft=0;ftSt+1?_t.push({polygons:bs,bounds:Fs,depth:St+1}):je(bs,Fs)}if(Os.length){const Fs=[new rs(It===0?_s:$t.x,It===1?_s:$t.y),as];Xe.length>St+1?_t.push({polygons:Os,bounds:Fs,depth:St+1}):je(Os,Fs)}}return ue}(f,c,Math.ceil((E-k)/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/Ys)/y);return(Q(.5*(ge((m.y+J/Ys)/y)+ee))*y-m.y)*Ys}})}function ltt(f,c,m,y,k,E){const P=Math.pow(2,y.z-k.z);for(let O=0;O=B[P]&&(O=c,B=f),O[P]k&&Hje(O,B,P,k),O[P]E&&Hje(B,O,P,E)}}function mO(f,c,m,y,k,E){const P=[];for(let O=0;O=y&&ue.x>=y||(ce.x>=y?ce=new rs(y,ce.y+(y-ce.x)/(ue.x-ce.x)*(ue.y-ce.y))._round():ue.x>=y&&(ue=new rs(y,ce.y+(y-ce.x)/(ue.x-ce.x)*(ue.y-ce.y))._round()),ce.y>=k&&ue.y>=k||(ce.y>=k?ce=new rs(ce.x+(k-ce.y)/(ue.y-ce.y)*(ue.x-ce.x),k)._round():ue.y>=k&&(ue=new rs(ce.x+(k-ce.y)/(ue.y-ce.y)*(ue.x-ce.x),k)._round()),W&&ce.equals(W[W.length-1])||(W=[ce],P.push(W),E&&E.push({progress:{min:Le+Gje(Ie,Ge,ce)*je,max:1},parentIndex:O,prevPoint:Ie,nextPoint:Ge})),W.push(ue),E&&(E[E.length-1].progress.max=Le+Gje(Ie,Ge,ue)*je,E[E.length-1].nextPoint=Ge)))))}if(E&&ee>0)for(let ne=J;neW.t-J.t);let P=0,O=0,B=[];for(y.push(B);P!==f.length;){if(O===E.length){for(;P!==f.length;)B.length!==0&&B[B.length-1].equals(f[P])||B.push(f[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(f[P])||B.push(f[P]),P++)}}function Gje(f,c,m){return f.x!==c.x?(m.x-f.x)/(c.x-f.x):f.y!==c.y?(m.y-f.y)/(c.y-f.y):0}function nA(f,c){return f.x*c.x+f.y*c.y}function Kje(f,c){if(f.length===1){let m=0;const y=c[m++];let k;for(;!k||y.equals(k);)if(k=c[m++],!k)return 1/0;for(;m{_s[0]=bs,_s[1]=Os,_s[2]=Fs,_s[3]=1},hs=Bje();ce>0&&(ce+=hs),ue+=hs;for(const _s of ne){const bs=[],Os=[];for(const Fs of _s){const Ps=Fs.x+je.x,Ls=Fs.y+je.y,us=ee.projection.projectTilePoint(Ps,Ls,_t),is=ee.projection.upVector(_t,Fs.x,Fs.y);let Ds=ce,Xs=ue;if(Ie){const qs=Xje(Ps,Ls,ce,ue,Ie,Ge,Xe,rt);Ds+=qs.base,Xs+=qs.top}ce!==0?Wt($t,us.x+is[0]*It*Ds,us.y+is[1]*It*Ds,us.z+is[2]*It*Ds):Wt($t,us.x,us.y,us.z),Wt(as,us.x+is[0]*It*Xs,us.y+is[1]*It*Xs,us.z+is[2]*It*Xs),Dt($t,$t,Le),Dt(as,as,Le),bs.push(new Ob($t[0],$t[1],$t[2])),Os.push(new Ob(as[0],as[1],as[2]))}ft.push(bs),St.push(Os)}return[ft,St]}(f,c,m,y,k,E,P,O,B,W,J):P?function(ee,ne,ce,ue,je,Le,Ie,Ge,Xe){const rt=[],_t=[],ft=[0,0,0,1];for(const St of ee){const It=[],$t=[];for(const as of St){const Wt=as.x+ue.x,hs=as.y+ue.y,_s=Xje(Wt,hs,ne,ce,Le,Ie,Ge,Xe);ft[0]=Wt,ft[1]=hs,ft[2]=_s.base,ft[3]=1,mt(ft,ft,je),ft[3]=Math.max(ft[3],1e-5);const bs=new Ob(ft[0]/ft[3],ft[1]/ft[3],ft[2]/ft[3]);ft[0]=Wt,ft[1]=hs,ft[2]=_s.top,ft[3]=1,mt(ft,ft,je),ft[3]=Math.max(ft[3],1e-5);const Os=new Ob(ft[0]/ft[3],ft[1]/ft[3],ft[2]/ft[3]);It.push(bs),$t.push(Os)}rt.push(It),_t.push($t)}return[rt,_t]}(c,m,y,k,E,P,O,B,W):function(ee,ne,ce,ue,je){const Le=[],Ie=[],Ge=je[8]*ne,Xe=je[9]*ne,rt=je[10]*ne,_t=je[11]*ne,ft=je[8]*ce,St=je[9]*ce,It=je[10]*ce,$t=je[11]*ce;for(const as of ee){const Wt=[],hs=[];for(const _s of as){const bs=_s.x+ue.x,Os=_s.y+ue.y,Fs=je[0]*bs+je[4]*Os+je[12],Ps=je[1]*bs+je[5]*Os+je[13],Ls=je[2]*bs+je[6]*Os+je[14],us=je[3]*bs+je[7]*Os+je[15],is=Fs+Ge,Ds=Ps+Xe,Xs=Ls+rt,qs=Math.max(us+_t,1e-5),Ir=Fs+ft,lr=Ps+St,gr=Ls+It,Nr=Math.max(us+$t,1e-5);Wt.push(new Ob(is/qs,Ds/qs,Xs/qs)),hs.push(new Ob(Ir/Nr,lr/Nr,gr/Nr))}Le.push(Wt),Ie.push(hs)}return[Le,Ie]}(c,m,y,k,E)}function Xje(f,c,m,y,k,E,P,O){const B=P*k.getElevationAt(f,c,!0,!0),W=E[0]!==0,J=W?E[1]===0?P*(E[0]/Tje-Aje):P*function(ee,ne,ce){const ue=Math.floor(ne[0]/8),je=Math.floor(ne[1]/8),Le=10*(ne[0]-8*ue),Ie=10*(ne[1]-8*je),Ge=ee.getElevationAt(ue,je,!0,!0),Xe=ee.getMeterToDEM(ce),rt=Math.floor(.5*(Le*Xe-1)),_t=Math.floor(.5*(Ie*Xe-1)),ft=ee.tileCoordToPixel(ue,je),St=2*rt+1,It=2*_t+1,$t=function(Os,Fs,Ps,Ls,us){return[Os.getElevationAtPixel(Fs,Ps,!0),Os.getElevationAtPixel(Fs+us,Ps,!0),Os.getElevationAtPixel(Fs,Ps+us,!0),Os.getElevationAtPixel(Fs+Ls,Ps+us,!0)]}(ee,ft.x-rt,ft.y-_t,St,It),as=Math.abs($t[0]-$t[1]),Wt=Math.abs($t[2]-$t[3]),hs=Math.abs($t[0]-$t[2])+Math.abs($t[1]-$t[3]),_s=Math.min(.25,.5*Xe*(as+Wt)/St),bs=Math.min(.25,.5*Xe*hs/It);return Ge+Math.max(_s*Le,bs*Ie)}(k,E,O):B;return{base:B+(m===0?-1:m),top:W?Math.max(J+y,B+m+2):B+y}}class dtt{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 utt{constructor(){this.tasks={},this.taskQueue=[],Ut(["process"],this),this.invoker=new dtt(this.process),this.nextId=0}add(c,m){const y=this.nextId++,k=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(k===0){try{c()}finally{}return null}return this.tasks[y]={fn:c,metadata:m,priority:k,id:y},this.taskQueue.push(y),this.invoker.trigger(),{cancel:()=>{delete this.tasks[y]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(y=>!!this.tasks[y]),!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 k=0;k{y&&delete this.callbacks[O],this.target.postMessage({id:O,type:"",targetMapId:k,sourceMapId:this.mapId})}}}receive(c){const m=c.data;if(!m)return;const y=m.id;if(y&&(!m.targetMapId||this.mapId===m.targetMapId))if(m.type===""){const k=this.cancelCallbacks[y];delete this.cancelCallbacks[y],k&&k.cancel()}else if(m.mustQueue||ua(self)){const k=this.callbacks[y],E=this.scheduler.add(()=>this.processTask(y,m),k&&k.metadata||{type:"message"});E&&(this.cancelCallbacks[y]=E)}else this.processTask(y,m)}processTask(c,m){if(delete this.cancelCallbacks[c],m.type===""){const y=this.callbacks[c];delete this.callbacks[c],y&&(m.error?y(dx(m.error)):y(null,dx(m.data)))}else{const y=new Set,k=m.hasCallback?(P,O)=>{this.target.postMessage({id:c,type:"",sourceMapId:this.mapId,error:P?qf(P):null,data:qf(O,y)},y)}:()=>{},E=dx(m.data);if(this.parent[m.type])this.parent[m.type](m.sourceMapId,E,k);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,k)}else k(new Error(`Could not find function ${m.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var aA={workerUrl:"",workerClass:null,workerParams:void 0};const Tde="mapboxgl_preloaded_worker_pool";class Rb{constructor(c){this.active={},this.name=c}acquire(c,m=Rb.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{m.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Tde]}numActive(){return Object.keys(this.active).length}}Rb.workerCount=2;class kC{constructor(c,m,y="Worker",k=Rb.workerCount){this.workerPool=c,this.actors=[],this.currentActor=0,this.id=Bt();const E=this.workerPool.acquire(this.id,k);for(let P=0;P{this.ready=!0})}broadcast(c,m,y){Tt(this.actors,(k,E)=>{k.send(c,m,E)},y=y||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 iA,Ade;function pO(){return iA||(iA=new Rb),iA}kC.Actor=Qje;const Ede=4096;class htt{constructor(c){this.module=c,this.memoryStack=this.module.malloc(Ede),this.memoryStackNextFree=this.memoryStack}createIntArray(c){const m=this.memoryStackNextFree;return this.memoryStackNextFree+=c.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Ede?-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>Ede?-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,y){this.module.setFauxFacadeOptions(c?1:0,m?1:0,y)}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 y=this.module.getMeshCount(),k=new Array(y);for(let O=0;Ok.arrayBuffer()).then(k=>{c.buffers[m]=k})}function ike(f,c){const m=f.json.bufferViews[c];return new Uint8Array(f.buffers[m.buffer],m.byteOffset||0,m.byteLength)}function ytt(f,c,m,y){if(f.uri){const k=ake(f.uri,y);return fetch(k).then(E=>E.blob()).then(E=>createImageBitmap(E)).then(E=>{c.images[m]=E})}if(f.bufferView!==void 0){const k=ike(c,f.bufferView),E=new Blob([k],{type:f.mimeType});return createImageBitmap(E).then(P=>{c.images[m]=P})}}function oke(f,c=0,m){const y={json:null,images:[],buffers:[]};if(new Uint32Array(f,c,1)[0]===rke){const J=new Uint32Array(f,c);let ee=2;const ne=(J[ee++]>>2)-3,ce=J[ee++]>>2;if(ee++,y.json=JSON.parse(nke.decode(J.subarray(ee,ee+ce))),ee+=ce,ee{const J=[],ee=O&&O.includes(Lde),ne=O&&O.includes(xO);if(ee&&J.push(function(){if(!eg)return oA??(oA=function(ce){let ue,je=null;function Le(){ue=new Uint8Array(je.buffer)}function Ie(){throw new Error("Unexpected Draco error.")}const Ge={a:{a:Ie,d:function(Xe,rt,_t){return ue.copyWithin(Xe,rt,rt+_t)},c:function(Xe){const rt=ue.length,_t=Math.max(Xe>>>0,Math.ceil(1.2*rt)),ft=Math.ceil((_t-rt)/65536);try{return je.grow(ft),Le(),!0}catch{return!1}},b:Ie}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(ce,Ge):ce.then(Xe=>Xe.arrayBuffer()).then(Xe=>WebAssembly.instantiate(Xe,Ge))).then(Xe=>{const{Rb:rt,Qb:_t,P:ft,T:St,X:It,Ja:$t,La:as,Qa:Wt,Va:hs,Wa:_s,eb:bs,jb:Os,f:Fs,e:Ps,yb:Ls,zb:us,Ab:is,Bb:Ds,Db:Xs,Gb:qs}=Xe.instance.exports;je=Ps;const Ir=(()=>{let lr=0,gr=0,Nr=0,Wn=0;return Us=>{Nr&&(rt(Wn),rt(lr),gr+=Nr,Nr=lr=0),lr||(gr+=128,lr=_t(gr));const Sr=Us.length+7&-8;let hn=lr;Sr>=gr&&(Nr=Sr,hn=Wn=_t(Sr));for(let ma=0;ma{eg=ce,oA=void 0}))}()),ne&&J.push(function(){if(Ide)return;const ce=function(ue){let je;const Le=WebAssembly.instantiateStreaming(ue,{}).then(Xe=>{je=Xe.instance,je.exports.__wasm_call_ctors()}),Ie={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Ge={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:Le,supported:!0,decodeGltfBuffer(Xe,rt,_t,ft,St,It){(function($t,as,Wt,hs,_s,bs,Os){const Fs=$t.exports.sbrk,Ps=hs+3&-4,Ls=Fs(Ps*_s),us=Fs(bs.length),is=new Uint8Array($t.exports.memory.buffer);is.set(bs,us);const Ds=as(Ls,hs,_s,us,bs.length);if(Ds===0&&Os&&Os(Ls,Ps,_s),Wt.set(is.subarray(Ls,Ls+hs*_s)),Fs(Ls-Fs(0)),Ds!==0)throw new Error(`Malformed buffer data: ${Ds}`)})(je,je.exports[Ge[St]],Xe,rt,_t,ft,je.exports[Ie[It]])}}}(fetch(tke()));return ce.ready.then(()=>{Ide=ce})}()),E)for(let ce=0;ce{if(ee&&P)for(const{primitives:ce}of P)for(const ue of ce)ftt(ue,y);if(ne&&P&&B)for(const ce of B)gtt(ce,y);return y})})}function lke(f){return fetch(f).then(c=>c.arrayBuffer()).then(c=>oke(c,0,f))}function Dde(f){switch(f){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 Ode(f){switch(f){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 Rde{constructor(c,m,y,k){this.context=c,this.format=y,this.useMipmap=k&&k.useMipmap,this.texture=c.gl.createTexture(),this.update(m,{premultiply:k&&k.premultiply})}update(c,m){const y=c&&c instanceof HTMLVideoElement&&c.width===0?c.videoWidth:c.width,k=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+y,J=B+k;!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 ne=this.useMipmap?Math.floor(Math.log2(Math.max(W,J)))+1:1;P.texStorage2D(P.TEXTURE_2D,ne,this.format,W,J),this.size=[W,J]}this.size&&(ee?P.texSubImage2D(P.TEXTURE_2D,0,O,B,Dde(this.format),Ode(this.format),c):"data"in c&&c.data&&P.texSubImage2D(P.TEXTURE_2D,0,O,B,y,k,Dde(this.format),Ode(this.format),c.data)),this.useMipmap&&P.generateMipmap(P.TEXTURE_2D)}bind(c,m,y=!1){const{context:k}=this,{gl:E}=k;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&&!y?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,y,k,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),y!==this.wrapS&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_S,y),this.wrapS=y),k!==this.wrapT&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_T,k),this.wrapT=k),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 cA{constructor(c,m){this.context=c,this.texture=m}bind(c,m){const{context:y}=this,{gl:k}=y;k.bindTexture(k.TEXTURE_2D,this.texture),c!==this.minFilter&&(k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,c),k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,c),this.minFilter=c),m!==this.wrapS&&(k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S,m),k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,m),this.wrapS=m)}}const vtt=na([{name:"a_pos_3f",components:3,type:"Float32"}]),_tt=na([{name:"a_color_3f",components:3,type:"Float32"}]),btt=na([{name:"a_color_4f",components:4,type:"Float32"}]),wtt=na([{name:"a_uv_2f",components:2,type:"Float32"}]),jtt=na([{name:"a_normal_3f",components:3,type:"Float32"}]),ktt=na([{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"}]),Ntt=na([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function cke(f,c){const m=yO(f.projection,f.zoom,f.width,f.height),y=function(E,P,O,B,W){const J=new x(O.lng-180*zv,O.lat),ee=new x(O.lng+180*zv,O.lat),ne=E.project(J.lng,J.lat),ce=E.project(ee.lng,ee.lat),ue=-Math.atan2(ce.y-ne.y,ce.x-ne.x),je=Je.fromLngLat(O);je.y=Se(je.y,-1+zv,1-zv);const Le=je.toLngLat(),Ie=E.project(Le.lng,Le.lat),Ge=Je.fromLngLat(Le);Ge.x+=zv;const Xe=Ge.toLngLat(),rt=E.project(Xe.lng,Xe.lat),_t=uke(rt.x-Ie.x,rt.y-Ie.y,ue),ft=Je.fromLngLat(Le);ft.y+=zv;const St=ft.toLngLat(),It=E.project(St.lng,St.lat),$t=uke(It.x-Ie.x,It.y-Ie.y,ue),as=Math.abs(_t.x)/Math.abs($t.y),Wt=w([]);$(Wt,Wt,-ue*(1-(W?0:B)));const hs=w([]);return I(hs,hs,[1,1-(1-as)*B,1]),hs[4]=-$t.x/$t.y*B,$(hs,hs,ue),C(hs,Wt,hs),hs}(f.projection,0,f.center,m,c),k=dke(f);return I(y,y,[k,k,1]),y}function dke(f){const c=f.projection,m=yO(f.projection,f.zoom,f.width,f.height),y=Fde(c,f.center),k=Fde(c,x.convert(c.center));return Math.pow(2,y*m+(1-m)*k)}function yO(f,c,m,y,k=1/0){const E=f.range;if(!E)return 0;const P=Math.min(k,Math.max(m,y)),O=Math.log2(P/1024);return ze(E[0]+O,E[1]+O,c)}const zv=1/4e4;function Fde(f,c){const m=Se(c.lat,-xe,xe),y=new x(c.lng-180*zv,m),k=new x(c.lng+180*zv,m),E=f.project(y.lng,m),P=f.project(k.lng,m),O=Je.fromLngLat(y),B=Je.fromLngLat(k),W=P.x-E.x,J=P.y-E.y,ee=B.x-O.x,ne=B.y-O.y,ce=Math.sqrt((ee*ee+ne*ne)/(W*W+J*J));return Math.log2(ce)}function uke(f,c,m){const y=Math.cos(m),k=Math.sin(m);return{x:f*y-c*k,y:f*k+c*y}}function hke(f,c,m){w(f),$(f,f,Jr(c[2])),L(f,f,Jr(c[0])),R(f,f,Jr(c[1])),I(f,f,m),C(f,f,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function vO(f,c,m,y,k,E,P,O){const B=[m[0]-c[0],m[1]-c[1],0],W=[y[0]-c[0],y[1]-c[1],0];if(de(B)<1e-12||de(W)<1e-12)return He(f);const J=ut([],B,W);Ae(J,J),pe(W,y,c),B[2]=(E-k)*O,W[2]=(P-k)*O;const ee=B;return ut(ee,B,W),Ae(ee,ee),fs(f,J,ee)}function _O(f,c,m=!1){const y=Rv(c.zoom),k=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),ne=w([]),ce=re(1,J)*B,ue=re(1,0)*B*Ce(J,P.zoom),je=1/mde(B);let Le=ue*je;if(O){const rt=yO(P.projection,P.zoom,P.width,P.height,1024);Le=je*P.projection.pixelSpaceConversion(P.center.lat,B,rt)}const Ie=Lv(J,ee);le(Ie,Ie,Ne([],Ae([],Ie),ce*Le*W[2]));const Ge=function(rt){const _t=[rt[0],rt[1],rt[2]];let ft=[0,1,0];const St=ut([],ft,_t);return ut(ft,_t,St),Te(ft)===0&&(ft=[0,1,0],ut(St,_t,ft)),Ae(St,St),Ae(ft,ft),Ae(_t,_t),[St[0],St[1],St[2],0,ft[0],ft[1],ft[2],0,_t[0],_t[1],_t[2],0,rt[0],rt[1],rt[2],1]}(Ie);I(ne,ne,[Le,Le,Le*ce]),A(ne,ne,[-W[0],-W[1],-W[2]]);const Xe=C([],P.globeMatrix,Ge);return C(Xe,Xe,ne),C(Xe,Xe,E),Xe}(f,c,m);if(y>0){const E=function(P,O){const B=O.worldSize,W=re(1,0)*B*Ce(O.center.lat,O.zoom)/mde(B),J=re(1,O.center.lat)*B,ee=w([]);R(ee,ee,Jr(O.center.lng)),L(ee,ee,Jr(O.center.lat)),A(ee,ee,[0,0,pd]),I(ee,ee,[W,W,W*J]);const ne=O.point;return A(ee,ee,[-ne.x,-ne.y,0]),C(ee,ee,P),C(ee,O.globeMatrix,ee)}(f,c);return function(P,O,B){const W=(ue,je,Le)=>{const Ie=de(ue),Ge=de(je),Xe=Jf(ue,je,Le);return Ne(Xe,Xe,1/de(Xe)*Vr(Ie,Ge,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),ne=W([P[8],P[9],P[10]],[O[8],O[9],O[10]],B),ce=Jf([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,ne[0],ne[1],ne[2],0,ce[0],ce[1],ce[2],1]}(k,E,y)}return k}function zde(f,c,m,y){const k=Er.projectAabbCorners(y,m);let E=Number.MAX_VALUE;for(let O=0;O0||Le===0&&ue[0]*je[0]+ue[1]*je[1]>=0&&ue[0]*ue[0]+ue[1]*ue[1]>je[0]*je[0]+je[1]*je[1])&&(J=ce)}ee=J}while(ee!==W);return B.length>0&&B.push(B[0]),B}(k);if(La(f,P))return E}const Fb=64,MC={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function bO(f,c,m,y,k,E,P,O,B,W=!1){const J=m.zoom,ee=m.project(y),ne=Ce(y.lat,J),ce=1/ne;w(f),A(f,f,[ee.x+P[0]*ce,ee.y+P[1]*ce,P[2]]);let ue=1,je=1;const Le=m.worldSize;if(W){if(m.projection.name==="mercator"){let rt=0;m.elevation&&(rt=m.elevation.getAtPointOrZero(new Je(ee.x/Le,ee.y/Le),0));const _t=mt([],[ee.x,ee.y,rt,1],m.projMatrix)[3]/m.cameraToCenterDistance;ue=_t,je=_t*Ce(m.center.lat,J)}else if(m.projection.name==="globe"){const rt=_O(f,m),_t=[0,0,0,1];mt(_t,_t,C([],m.projMatrix,rt));const ft=_t[3]/m.cameraToCenterDistance,St=Rv(J),It=m.projection.pixelsPerMeter(y.lat,Le)*Ce(y.lat,J),$t=m.projection.pixelsPerMeter(m.center.lat,Le)*Ce(m.center.lat,J);ue=ft/Vr(It,Pe(m.center.lat),St),je=ft*ne/It,ue*=$t,je*=$t}}else ue=ce;I(f,f,[ue,ue,je]);const Ie=[...f],Ge=c.orientation,Xe=[];if(hke(Xe,[Ge[0]+(k?k[0]:0),Ge[1]+(k?k[1]:0),Ge[2]+(k?k[2]:0)],E),C(f,Ie,Xe),O&&m.elevation){let rt=0;const _t=[];if(B&&m.elevation){rt=function(St,It,$t,as,Wt){const hs=It.elevation;if(!hs)return 0;const _s=Er.projectAabbCorners($t,as),bs=re(1,Wt.lat)*It.worldSize,Os=function(gr,Nr){const Wn=[0,0,1],Us=[{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 Us){const hn=gr[Sr.corners[0]],ma=gr[Sr.corners[1]],xa=gr[Sr.corners[2]],Pn=[ma[0]-hn[0],ma[1]-hn[1],Nr*(ma[2]-hn[2])],yi=ut(Pn,Pn,[xa[0]-hn[0],xa[1]-hn[1],Nr*(xa[2]-hn[2])]);Ae(yi,yi),Sr.dotProductWithUp=Ue(yi,Wn)}return Us.sort((Sr,hn)=>Sr.dotProductWithUp-hn.dotProductWithUp),Us[0].corners}(_s,bs),Fs=_s[Os[0]],Ps=_s[Os[1]],Ls=_s[Os[2]],us=_s[Os[3]],is=hs.getAtPointOrZero(new Je(Fs[0]/It.worldSize,Fs[1]/It.worldSize),0),Ds=hs.getAtPointOrZero(new Je(Ps[0]/It.worldSize,Ps[1]/It.worldSize),0),Xs=hs.getAtPointOrZero(new Je(Ls[0]/It.worldSize,Ls[1]/It.worldSize),0),qs=hs.getAtPointOrZero(new Je(us[0]/It.worldSize,us[1]/It.worldSize),0),Ir=(is+qs)/2,lr=(Ds+Xs)/2;return Ir>lr?Ds=c.gl.NEAREST_MIPMAP_NEAREST}),f.uploaded=!0,f.image=null)}function Stt(f,c,m){f.indexBuffer=c.createIndexBuffer(f.indexArray,!1,!0),f.vertexBuffer=c.createVertexBuffer(f.vertexArray,vtt.members,!1,!0),f.normalArray&&(f.normalBuffer=c.createVertexBuffer(f.normalArray,jtt.members,!1,!0)),f.texcoordArray&&(f.texcoordBuffer=c.createVertexBuffer(f.texcoordArray,wtt.members,!1,!0)),f.colorArray&&(f.colorBuffer=c.createVertexBuffer(f.colorArray,(f.colorArray.bytesPerElement===12?_tt:btt).members,!1,!0)),f.featureArray&&(f.pbrBuffer=c.createVertexBuffer(f.featureArray,Ntt.members,!0)),f.segments=uo.simpleSegment(0,0,f.vertexArray.length,f.indexArray.length);const y=f.material;y.pbrMetallicRoughness.baseColorTexture&&dA(y.pbrMetallicRoughness.baseColorTexture,c),y.pbrMetallicRoughness.metallicRoughnessTexture&&dA(y.pbrMetallicRoughness.metallicRoughnessTexture,c),y.normalTexture&&dA(y.normalTexture,c),y.occlusionTexture&&dA(y.occlusionTexture,c,m),y.emissionTexture&&dA(y.emissionTexture,c)}function Bde(f,c,m){if(f.meshes)for(const y of f.meshes)Stt(y,c,m);if(f.children)for(const y of f.children)Bde(y,c,m)}function wO(f){if(f.meshes)for(const c of f.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(f.children)for(const c of f.children)wO(c)}function $de(f){if(f.meshes)for(const m of f.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(f.children)for(const m of f.children)$de(m)}function zb(f,c){const m=f.json.bufferViews[c.bufferView],y=gO[c.componentType];return new y(f.buffers[m.buffer],(c.byteOffset||0)+(m.byteOffset||0),c.count*(m.byteStride&&m.byteStride!==lA[c.type]*y.BYTES_PER_ELEMENT?m.byteStride/y.BYTES_PER_ELEMENT:lA[c.type]))}function qde(f,c,m,y){const k=gO[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}}(k),P=f.json.bufferViews[c.bufferView],O=P.byteStride?P.byteStride/k.BYTES_PER_ELEMENT:lA[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 Dp;const ne=c.json.accessors[k.TEXCOORD_0];E.texcoordArray.resize(ne.count);const ce=zb(c,ne);qde(c,ne,E.texcoordArray,ce)}if(k._FEATURE_ID_RGBA4444!==void 0){const ne=c.json.accessors[k._FEATURE_ID_RGBA4444];c.json.extensionsUsed&&c.json.extensionsUsed.includes("EXT_meshopt_compression")&&(E.featureData=zb(c,ne))}k._FEATURE_RGBA4444!==void 0&&(E.featureData=new Uint32Array(zb(c,c.json.accessors[k._FEATURE_RGBA4444]).buffer));const ee=f.material;return E.material=function(ne,ce){const{emissiveFactor:ue=[0,0,0],alphaMode:je="OPAQUE",alphaCutoff:Le=.5,normalTexture:Ie,occlusionTexture:Ge,emissiveTexture:Xe,doubleSided:rt,name:_t}=ne,{baseColorFactor:ft=[1,1,1,1],metallicFactor:St=1,roughnessFactor:It=1,baseColorTexture:$t,metallicRoughnessTexture:as}=ne.pbrMetallicRoughness||{},Wt=Ge?ce[Ge.index]:void 0;if(Ge&&Ge.extensions&&Ge.extensions.KHR_texture_transform&&Wt){const hs=Ge.extensions.KHR_texture_transform;Wt.offsetScale=[hs.offset[0],hs.offset[1],hs.scale[0],hs.scale[1]]}return{name:_t,pbrMetallicRoughness:{baseColorFactor:new Fr(...ft),metallicFactor:St,roughnessFactor:It,baseColorTexture:$t?ce[$t.index]:void 0,metallicRoughnessTexture:as?ce[as.index]:void 0},doubleSided:rt,emissiveFactor:new Fr(...ue),alphaMode:je,alphaCutoff:Le,normalTexture:Ie?ce[Ie.index]:void 0,occlusionTexture:Wt,emissionTexture:Xe?ce[Xe.index]:void 0,defined:ne.defined===void 0}}(ee!==void 0?c.json.materials[ee]:{defined:!1},m),E}function pke(f,c,m){const{matrix:y,rotation:k,translation:E,scale:P,mesh:O,extras:B,children:W,name:J}=f,ee={};if(ee.name=J,ee.localMatrix=y||function(ne,ce,ue,je){var Le=ce[0],Ie=ce[1],Ge=ce[2],Xe=ce[3],rt=Le+Le,_t=Ie+Ie,ft=Ge+Ge,St=Le*rt,It=Le*_t,$t=Le*ft,as=Ie*_t,Wt=Ie*ft,hs=Ge*ft,_s=Xe*rt,bs=Xe*_t,Os=Xe*ft,Fs=je[0],Ps=je[1],Ls=je[2];return ne[0]=(1-(as+hs))*Fs,ne[1]=(It+Os)*Fs,ne[2]=($t-bs)*Fs,ne[3]=0,ne[4]=(It-Os)*Ps,ne[5]=(1-(St+hs))*Ps,ne[6]=(Wt+_s)*Ps,ne[7]=0,ne[8]=($t+bs)*Ls,ne[9]=(Wt-_s)*Ls,ne[10]=(1-(St+as))*Ls,ne[11]=0,ne[12]=ue[0],ne[13]=ue[1],ne[14]=ue[2],ne[15]=1,ne}([],k||[0,0,0,1],E||[0,0,0],P||[1,1,1]),ee.globalMatrix=j(ee.localMatrix),O!==void 0){ee.meshes=m[O];const ne=ee.anchor=[0,0];for(const ce of ee.meshes){const{min:ue,max:je}=ce.aabb;ne[0]+=ue[0]+je[0],ne[1]+=ue[1]+je[1]}ne[0]=Math.floor(ne[0]/ee.meshes.length/2),ne[1]=Math.floor(ne[1]/ee.meshes.length/2)}if(B&&(B.id&&(ee.id=B.id),B.lights&&(ee.lights=function(ne){if(!ne.length)return[];const ce=function(Ge){const Xe=atob(Ge),rt=new Uint8Array(Xe.length);for(let _t=0;_t1&&y[y.length-1].equals(y[0])&&y.pop();let k=0;for(let P=0;P0&&y.reverse();const E=wC(y.flatMap(P=>[P.x,P.y]),[]);return E.length===0?null:{vertices:y,indices:E}}function Att(f,c){const m=[],y=[];let k=0;const E=[];for(const P of f){k=m.length;const O=P.vertexArray.float32,B=P.indexArray.uint16;for(let W=0;W0&&([y[P+1],y[P+2]]=[y[P+2],y[P+1]])}return{vertices:m,indices:y}}function Ude(f){const c=function(B,W){const J=[],ee=WebGL2RenderingContext;if(B.json.textures)for(const ne of B.json.textures){const ce={magFilter:ee.LINEAR,minFilter:ee.NEAREST,wrapS:ee.REPEAT,wrapT:ee.REPEAT};ne.sampler!==void 0&&Object.assign(ce,B.json.samplers[ne.sampler]),J.push({image:W[ne.source],sampler:ce,uploaded:!1})}return J}(f,f.images),m=function(B,W){const J=[];for(const ee of B.json.meshes){const ne=[];for(const ce of ee.primitives)ne.push(Ctt(ce,B,W));J.push(ne)}return J}(f,c),{scenes:y,scene:k,nodes:E}=f.json,P=y?y[k||0].nodes:[...E.keys()],O=[];for(const B of P)O.push(pke(E[B],f,m));return function(B,W,J){const ee={},ne=new Set;for(let ce=0;ce0){const ce=Array.from(ne.values()).sort((ue,je)=>ue-je);for(let ue=ce.length-1;ue>=0;ue--)B.splice(ce[ue],1)}}(O,P,f.json.nodes),O}function Ett(f){f.heightmap=new Float32Array(4096),f.heightmap.fill(-1);const c=f.vertexArray.float32,m=f.aabb.min[0]-1,y=f.aabb.min[1]-1,k=Fb/(f.aabb.max[0]-m+2),E=Fb/(f.aabb.max[1]-y+2);for(let P=0;Pf.heightmap[W*Fb+B]&&(f.heightmap[W*Fb+B]=O)}}function fke(f,c,m,y,k){m.reserve(m.length+4*f.length),y.reserve(y.length+10*f.length),k.reserve(k.length+10*f.length);let E=y.length;for(const P of f){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=Ke([],P.pos,B,J/2),ne=Ke([],P.pos,B,-J/2),ce=[ee[0],ee[1],ee[2]+P.height],ue=[ne[0],ne[1],ne[2]+P.height],je=Ke([],P.normal,B,W);Ne(je,je,O);const Le=Ke([],P.normal,B,-W);Ne(Le,Le,O),le(je,ee,je),le(Le,ne,Le),ee[2]+=.1,ne[2]+=.1,y.emplaceBack(je[0],je[1],je[2]),y.emplaceBack(Le[0],Le[1],Le[2]),y.emplaceBack(ee[0],ee[1],ee[2]),y.emplaceBack(ne[0],ne[1],ne[2]),y.emplaceBack(ce[0],ce[1],ce[2]),y.emplaceBack(ue[0],ue[1],ue[2]),y.emplaceBack(ee[0],ee[1],ee[2]),y.emplaceBack(ne[0],ne[1],ne[2]),y.emplaceBack(je[0],je[1],je[2]),y.emplaceBack(Le[0],Le[1],Le[2]);const Ie=J/O/2;k.emplaceBack(-Ie-W,-1,Ie,.8),k.emplaceBack(Ie+W,-1,Ie,.8),k.emplaceBack(-Ie,0,Ie,1.3),k.emplaceBack(Ie,0,Ie,1.3),k.emplaceBack(Ie+W,-.8,Ie,.7),k.emplaceBack(Ie+W,-.8,Ie,.7),k.emplaceBack(0,0,Ie,1.3),k.emplaceBack(0,0,Ie,1.3),k.emplaceBack(Ie+W,-1.2,Ie,.8),k.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 Ptt(f,c){const m={};m.indexArray=new vl,m.vertexArray=new gh,m.colorArray=new hx,fke(f,c,m.indexArray,m.vertexArray,m.colorArray);const y={defined:!0};y.emissiveFactor=Fr.black;const k={};return k.baseColorFactor=Fr.white,y.pbrMetallicRoughness=k,m.material=y,m.aabb=new Er([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),m}const gke=na([{name:"a_pos_3f",components:3,type:"Float32"}]),Itt=na([{name:"a_normal_3",components:3,type:"Int16"}]),Ltt=na([{name:"a_centroid_3",components:3,type:"Int16"}]),xke=na([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),Dtt=na([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),Ott=na([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Rtt=na([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),Ftt=na([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),ztt=na([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),yke=Vt.types,jO=32767;function Btt(f,c){const m=Ys+c;for(const y of f)for(const k of y)if(k.x<-c||k.x>m||k.y<-c||k.y>m)return!1;return!0}function $tt(f){switch(f){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: ${f}`)}}class Vde{constructor(){this.layoutVertexArray=new gh,this.layoutAttenuationArray=new hx,this.layoutColorArray=new xh,this.indexArray=new vl,this.indexArrayForConflation=new vl,this.segmentsBucket=new uo}}class Hde{constructor(c){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new uo,this.entranceBloom=new Vde;const m=66560;this.layoutVertexArray=new gh,this.layoutVertexArray.reserve(m),this.layoutNormalArray=new Mv,this.layoutNormalArray.reserve(m),this.layoutCentroidArray=new Mv,this.layoutCentroidArray.reserve(m),this.layoutColorArray=new xh,this.layoutColorArray.reserve(m),this.layoutFloodLightDataArray=new mx,this.layoutFloodLightDataArray.reserve(m),this.layoutAOArray=new dC,this.layoutAOArray.reserve(m),this.indexArray=new vl,this.indexArray.reserve(66560),this.indexArrayForConflation=new vl,this.segmentsBucket=new uo,this.entranceBloom=new Vde,c&&(this.layoutFacadePaintArray=new xh,this.layoutFacadeDataArray=new Dy,this.layoutFacadeVerticalRangeArray=new xh)}reserve(c,m,y){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),y&&(this.layoutFacadePaintArray.reserveForAdditional(c),this.layoutFacadeDataArray.reserveForAdditional(c),this.layoutFacadeVerticalRangeArray.reserveForAdditional(c))}}class vke{constructor(c){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Dp,this.footprintsIndices=new mx,this.footprintsMin=new rs(1/0,1/0),this.footprintsMax=new rs(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Hde(!1),this.buildingWithFacade=new Hde(!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 Gm(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 Cde(c),this.groundEffect.groundRadiusArray=new Wf,this.hasAppearances=null}updateFootprints(c,m){const y=new lO([],[],1),k={vertices:[],indices:new Uint32Array(0),grid:y,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};m.push({footprint:k,id:c})}updateAppearances(c,m,y,k){}prepare(){return function(){if(fO!=null||Jje!=null)return null;if(CC!=null)return CC;const c=fetch(sa.BUILDING_GEN_URL);return CC=function(m){let y,k,E,P,O;function B(){y=new Uint8Array(O.buffer),k=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(ne){const ce=y.length,ue=Math.max(ne>>>0,Math.ceil(1.2*ce)),je=Math.ceil((ue-ce)/65536);try{return O.grow(je),B(),!0}catch{return!1}},g:W,b:J,c:J,d:J,e:J}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(m,ee):m.then(ne=>ne.arrayBuffer()).then(ne=>WebAssembly.instantiate(ne,ee))).then(ne=>{const ce=ne.instance.exports;return(0,ce.g)(),O=ce.f,B(),new htt({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:y,heap16:k,heap32:E,heapF32:P})})}(c).then(m=>(CC=null,fO=m,fO)).catch(m=>{cr("Could not load building-gen"),CC=null,Jje=m}),CC}()}populate(c,m,y,k){const E=mtt();if(!E)return;const P=Be(y);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(yke[Ie.type]!=="LineString"){O.set(Ie.id,Ie.properties.source_id);continue}const Ge=this.layers[0]._featureFilter.needGeometry;if(Ge&&!this.layers[0]._featureFilter.filter(new Li(this.zoom),Ie,y))continue;const Xe=Ht(Ie,Ge);if(!Ge&&!this.layers[0]._featureFilter.filter(new Li(this.zoom),Xe,y))continue;const rt=Ge?Xe.geometry:Pt(Ie,y,k),_t=[];for(const $t of rt)for(const as of $t)_t.push(as.x),_t.push(as.y);const ft={coordinates:_t,crossPerc:Ie.properties.cross_perc,distanceToRoad:Ie.properties.distance_to_road,entrances:Ie.properties.entrances,sourceId:0},St=Ie.properties.source_id;let It=B.get(St);It||(It=[],B.set(St,It)),It.push(ft),++W}this.maxHeight=0;const J=new Array,ee=new Set,ne=Ie=>{Ie!=null&&ee.add(Ie)},ce=(Ie,Ge)=>{Ie!=null&&J.push({buildingId:Ie,footprintIndex:Ge})},ue=64*(c.length-W),je=ue/2;this.buildingWithFacade.reserve(ue,je,!0),this.buildingWithoutFacade.reserve(2*ue,2*je,!1),this.footprintsIndices.reserve(16*(c.length-W)),this.footprintsVertices.reserve(8*(c.length-W));for(const{feature:Ie,id:Ge,index:Xe,sourceLayerIndex:rt}of c){if(yke[Ie.type]==="LineString")continue;const _t=this.layers[0]._featureFilter.needGeometry;if(_t&&!this.layers[0]._featureFilter.filter(new Li(this.zoom),Ie,y))continue;let ft=null;if(Ie.properties&&Ie.properties.hasOwnProperty("building_id")&&(ft=Ie.properties.building_id,ee.has(ft)))continue;const St=Ht(Ie,_t);if(!_t&&!this.layers[0]._featureFilter.filter(new Li(this.zoom),St,y))continue;const It=_t?St.geometry:Pt(Ie,y,k),$t=JT(It,500);let as=!1;for(const Xr of $t)if(Xr.length!==1){as=!0;break}if(as){ne(ft);continue}if(!Btt(It,163)){ne(ft);continue}const Wt=this.layers[0],hs=$tt(Wt.layout.get("building-roof-shape").evaluate(Ie,{},y)),_s=Wt.layout.get("building-base").evaluate(Ie,{},y),bs=Wt.layout.get("building-height").evaluate(Ie,{},y),Os=Wt.layout.get("building-flood-light-ground-radius").evaluate(Ie,{},y),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),us=Wt.paint.get("building-emissive-strength").evaluate(Ie,{},this.canonical);Ie.properties["building-part"]="wall";const is=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 Xs=Wt.paint.get("building-color").evaluate(Ie,{},this.canonical).toPremultipliedRenderColor(this.lut),qs=Wt.paint.get("building-emissive-strength").evaluate(Ie,{},this.canonical);Ie.properties["building-part"]="door";const Ir=Wt.paint.get("building-color").evaluate(Ie,{},this.canonical).toPremultipliedRenderColor(this.lut),lr=Wt.paint.get("building-emissive-strength").evaluate(Ie,{},this.canonical);let gr=Wt.layout.get("building-flood-light-wall-radius").evaluate(Ie,{},y);gr=Se(gr,0,2048);const Nr=gr/2048*jO,Wn=O.get(Ge),Us=B.get(Wn)||[],Sr=Us.length!==0&&Wt.layout.get("building-facade").evaluate(Ie,{},y);E.setFacadeOptions(4,!0),E.setFauxFacadeOptions(Sr,!1,1);let hn=0,ma=0,xa=0,Pn=0,yi=0,gt=0,wt=0,ms=0,Rs=0,nr=0,ar=0;if(Sr){let Xr=Math.round(Wt.layout.get("building-facade-floors").evaluate(Ie,{},y));if(_s===0){Xr=Math.max(1,Xr-(Us.length>0?1:0));let ci=4;if(bs>100){const Wi=[10,13,15];ci=Wi[Ie.id?Ie.id%Wi.length:0]}else bs<=10&&(ci=3);E.setFacadeOptions(ci,!0),yi=(bs<15?1.3:1.61803)*ci/P}else yi=_s/P;gt=bs/P,yi=Math.min(yi,gt),xa=Wt.layout.get("building-facade-unit-width").evaluate(Ie,{},y)/P,Pn=(gt-yi)/Xr,E.setFauxFacadeOptions(!0,!0,xa);const po=Wt.layout.get("building-facade-window").evaluate(Ie,{},y);hn=po[0],ma=po[1],wt=Math.floor(65535*Math.min(1,yi/Ys)),ms=Math.floor(65535*Math.min(1,gt/Ys)),Rs=Math.floor(255*hn)<<8|Math.floor(255*ma),nr=Math.floor(65535*Math.min(1,xa/Ys)),ar=Math.floor(65535*Math.min(1,Pn/Ys))}const Dr=Array($t.length),zr={x:1/0,y:1/0},kn={x:-1/0,y:-1/0},Bn={x:0,y:0};let Hn=0;for(let Xr=0;Xr<$t.length;Xr++){const po=$t[Xr];if(po.length>0){const ci=[],Wi=Array(po.length+1);Wi[0]=0;for(let wl=0;wlYs||zr.y<0||kn.y>Ys)&&this.featuresOnBorder.push({featureId:Ie.id,footprintIndex:this.footprints.length});{const Xr=wC(bi,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+Xr.length),this.footprintsIndices.uint16.set(Xr,Yr),this.buildingIds.add(ft??Ie.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,Ei.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,Ei.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Di.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Di.y);const po={footprintVertexOffset:ia,footprintVertexLength:this.footprintsVertices.length-ia,footprintIndexOffset:Yr,footprintIndexLength:this.footprintsIndices.length-Yr,min:Ei,max:Di,hiddenFlags:0,indicesOffset:ei,indicesLength:so,bloomIndicesOffset:li,bloomIndicesLength:ki,groundEffectVertexOffset:Ro,groundEffectVertexLength:Pi,hasFauxFacade:Sr,height:$n,promoteId:Ge,feature:St,parts:Fa,buildingBloom:za},ci=this.footprints.length;Ie.id!==void 0&&this.featureFootprintLookup.set(Ie.id,ci),ce(ft,ci),this.footprints.push(po)}this.programConfigurations.populatePaintArrays(en.layoutVertexArray.length,Ie,Xe,{},m.availableImages,y,m.brightness),this.groundEffect.addPaintPropertiesData(Ie,Xe,{},m.availableImages,y,m.brightness),m.featureIndex.insert(Ie,It,Xe,rt,this.index,vi)}J.forEach(({buildingId:Ie,footprintIndex:Ge})=>{ee.has(Ie)&&(this.footprints[Ge].hiddenFlags|=4)});const Le=new Set;this.buildingIds.forEach((Ie,Ge,Xe)=>{ee.has(Ie)||Le.add(Ie)}),this.buildingIds=Le,this.groundEffect.prepareBorderSegments()}update(c,m,y,k,E,P,O){this.programConfigurations.updatePaintArrays(c,m,E,y,k,P,O),this.groundEffect.update(c,m,E,y,k,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=y=>{y.layoutVertexBuffer=c.createVertexBuffer(y.layoutVertexArray,gke.members),y.layoutNormalBuffer=c.createVertexBuffer(y.layoutNormalArray,Itt.members),y.layoutCentroidBuffer=c.createVertexBuffer(y.layoutCentroidArray,Ltt.members),y.layoutFloodLightDataBuffer=c.createVertexBuffer(y.layoutFloodLightDataArray,ztt.members),y.layoutFacadeDataArray&&y.layoutFacadeDataArray.length&&(y.layoutFacadeDataBuffer=c.createVertexBuffer(y.layoutFacadeDataArray,Ott.members)),y.layoutFacadeVerticalRangeArray&&y.layoutFacadeVerticalRangeArray.length&&(y.layoutFacadeVerticalRangeBuffer=c.createVertexBuffer(y.layoutFacadeVerticalRangeArray,Rtt.members)),y.entranceBloom.layoutVertexArray.length&&(y.entranceBloom.layoutVertexBuffer=c.createVertexBuffer(y.entranceBloom.layoutVertexArray,gke.members),y.entranceBloom.layoutAttenuationBuffer=c.createVertexBuffer(y.entranceBloom.layoutAttenuationArray,Ftt.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,y=!0){let k=!1;const E=y?m:0,P=0|(y?-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,k=!0,this.groundEffect.updateHiddenByLandmarkRange(B.groundEffectVertexOffset,B.groundEffectVertexLength,B.hiddenFlags!==0))}return k&&(this.indexArrayForConflationUploaded=!1),k}uploadUpdatedIndexBuffer(c){if(this.groundEffect.uploadHiddenByLandmark(c),this.indexArrayForConflationUploaded)return;const m=k=>{k.indexArray.length!==0&&(k.indexArrayForConflation.resize(k.indexArray.length),k.indexArrayForConflation.uint16.set(k.indexArray.uint16),k.entranceBloom.indexArrayForConflation.resize(k.entranceBloom.indexArray.length),k.entranceBloom.indexArrayForConflation.uint16.set(k.entranceBloom.indexArray.uint16))};m(this.buildingWithoutFacade),m(this.buildingWithFacade);for(const k of this.footprints){const E=k.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,P=k.indicesOffset+k.indicesLength;if(k.hiddenFlags!==0){for(let B=k.indicesOffset;B{k.indexArray.length!==0&&(k.indexBuffer?k.indexBuffer.updateData(k.indexArrayForConflation):k.indexBuffer=c.createIndexBuffer(k.indexArrayForConflation,!0),k.entranceBloom.indexBuffer?k.entranceBloom.indexBuffer.updateData(k.entranceBloom.indexArrayForConflation):k.entranceBloom.indexBuffer=c.createIndexBuffer(k.entranceBloom.indexArrayForConflation,!0))};y(this.buildingWithoutFacade),y(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(c){const m=y=>{y.layoutColorBuffer?y.layoutColorBuffer.updateData(y.layoutColorArray):y.layoutColorBuffer=c.createVertexBuffer(y.layoutColorArray,xke.members,!0),y.layoutFacadePaintArray&&(y.layoutFacadePaintBuffer?y.layoutFacadePaintBuffer.updateData(y.layoutFacadePaintArray):y.layoutFacadePaintBuffer=c.createVertexBuffer(y.layoutFacadePaintArray,Dtt.members,!0)),y.entranceBloom.layoutColorBuffer?y.entranceBloom.layoutColorBuffer.updateData(y.entranceBloom.layoutColorArray):y.entranceBloom.layoutColorBuffer=c.createVertexBuffer(y.entranceBloom.layoutColorArray,xke.members,!0)};m(this.buildingWithoutFacade),m(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(c,m){const y=c.paint.get("building-ambient-occlusion-intensity");for(const k of this.footprints){if(4&k.hiddenFlags)continue;const E=m[k.promoteId],P=k.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),ne=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),je=k.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const Ie of k.parts){let Ge,Xe=O;Ie.part===1?(Xe=O,Ge=B):Ie.part===0?(Xe=W,Ge=J):Ie.part===2?(Xe=ee,Ge=ne):Ie.part===3&&(Xe=ce,Ge=ue),Ge=Se(Ge,0,1);for(let rt=0;rtP.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<=y||qtt(P,this.footprintsVertices.float32.subarray(2*O.footprintVertexOffset,2*(O.footprintVertexOffset+O.footprintVertexLength)),this.footprintsIndices.uint16.subarray(O.footprintIndexOffset,O.footprintIndexOffset+O.footprintIndexLength))&&(y=O.height,this.footprintLookup[E]=O,k=O.hiddenFlags!==0);if(y!==Number.NEGATIVE_INFINITY)return{height:y,hidden:k};this.footprintLookup[E]=void 0}}function qtt(f,c,m){for(let y=0;y1&&(B=c[++O]);const J=Math.abs(W-B.left),ee=Math.abs(W-B.right),ne=Math.min(J,ee);let ce;const ue=E/y*(k+1);if(B.isDash){const je=k-Math.abs(ue);ce=Math.sqrt(ne*ne+je*je)}else ce=k-Math.sqrt(ne*ne+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 y=c[0],k=c[c.length-1];y.isDash===k.isDash&&(y.left=k.left-this.width,k.right=y.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 y=this.getKey(c,m);if(this.positions[y])return this.positions[y];const k=m==="round",E=k?7:0,P=2*E+1;if(this.nextRow+P>this.height)return cr("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 rC,this.layoutVertexArray2=new gh,this.patternVertexArray=new gh,this.indexArray=new vl,this.programConfigurations=new Gm(c.layers,{zoom:c.zoom,lut:c.lut}),this.segments=new uo,this.maxLineLength=0,this.zOffsetVertexArray=new gh,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.tessellationStep=c.tessellationStep?c.tessellationStep:Ys/64,this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,y,k){}populate(c,m,y,k){this.hasPattern=yde("line",this.layers,this.pixelRatio,m);const E=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Be(y);const P=this.layers[0].layout.get("line-elevation-reference");if(P==="hd-road-markup")this.elevationType="road";else{const ne=this.layers[0].layout.get("line-z-offset"),ce=ne.isConstant()&&!ne.constantOr(0);this.elevationType=P!=="sea"&&P!=="ground"&&ce?"none":"offset",this.elevationType==="offset"&&P==="none"&&cr(`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:ne,id:ce,index:ue,sourceLayerIndex:je}of c){const Le=this.layers[0]._featureFilter.needGeometry,Ie=Ht(ne,Le);if(!this.layers[0]._featureFilter.filter(new Li(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),Ie,y))continue;const Ge=E?E.evaluate(Ie,{},y):void 0,Xe={id:ce,properties:ne.properties,type:ne.type,sourceLayerIndex:je,index:ue,geometry:Le?Ie.geometry:Pt(ne,y,k),patterns:{},sortKey:Ge};B.push(Xe)}E&&B.sort((ne,ce)=>ne.sortKey-ce.sortKey);const{lineAtlas:W,featureIndex:J}=m,ee=this.addConstantDashes(W);for(const ne of B){const{geometry:ce,index:ue,sourceLayerIndex:je}=ne;if(ee&&this.addFeatureDashes(ne,W),this.hasPattern){const Le=vde("line",this.layers,ne,this.zoom,this.pixelRatio,m);this.patternFeatures.push(Le)}else this.addFeature(ne,ce,ue,y,W.positions,m.availableImages,m.brightness,m.elevationFeatures);J.insert(c[ue].feature,ce,ue,je,this.index)}}addConstantDashes(c){let m=!1;for(const y of this.layers){const k=y.paint.get("line-dasharray").value,E=y.layout.get("line-cap").value;if(k.kind!=="constant"||E.kind!=="constant")m=!0;else{const P=E.value,O=k.value;if(!O)continue;c.addDash(O,P)}}return m}addFeatureDashes(c,m){const y=this.zoom;for(const k of this.layers){const E=k.paint.get("line-dasharray").value,P=k.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:y},c);B=P.kind==="constant"?P.value:P.evaluate({zoom:y},c),m.addDash(O,B),c.patterns[k.id]=[m.getKey(O,B)]}}update(c,m,y,k,E,P,O,B){this.programConfigurations.updatePaintArrays(c,m,E,y,k,P,O,B)}addFeatures(c,m,y,k,E,P){for(const O of this.patternFeatures)this.addFeature(O,O.geometry,O.index,m,y,k,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,Ktt)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=c.createVertexBuffer(this.patternVertexArray,Ytt)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,Htt.members,!0)),this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,Wtt),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 y,k;if(m&&m>0?(y=`mapbox_clip_start_${m}`,k=`mapbox_clip_end_${m}`):(y="mapbox_clip_start",k="mapbox_clip_end"),c.properties&&c.properties.hasOwnProperty(y)&&c.properties.hasOwnProperty(k))return{start:+c.properties[y],end:+c.properties[k]}}addFeature(c,m,y,k,E,P,O,B){const W=this.layers[0].layout,J=W.get("line-join").evaluate(c,{}),ee=W.get("line-cap").evaluate(c,{}),ne=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 je=this.layers[0].paint.get("line-width").value;if(je.kind!=="constant"&&je.isLineProgressConstant===!1&&(this.variableWidthValue=je),this.elevationType==="road"){const Le=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(c,m,k,B,J,ee,ne,ce)){const[Ie,Ge]=this.clipRuntimeLinesToTile(m,1);for(let Xe=0;Xe0?_t.parentIndex:null)}this.fillNonElevatedRoadSegment(Le)}}else for(let Le=0;Le0?Le:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,y,E,P,k,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 mO(c,-m,-m,Ys+m,Ys+m)}clipRuntimeLinesToTile(c,m){const y=[];return[mO(c,-m,-m,Ys+m,Ys+m,y),y]}addElevatedRoadFeature(c,m,y,k,E,P,O,B){const W=[],J=Qa.getElevationFeature(c,k);if(J){const ee=this.clipLinesToTile(m,1),ne=this.prepareElevatedLines(ee,J,y);for(const ce of ne)W.push({geometry:ce,elevation:J,elevationTileID:y,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(W.length===0)return!1;for(const ee of W){const ne=this.layoutVertexArray.length;this.addLine(ee.geometry,c,y,E,P,O,B);const ce=new pi(y,ee.elevationTileID);if(ee.elevation)for(let ue=ne;ue>1,this.layoutVertexArray.int16[6*ue+1]>>1),Le=ce.pointElevation(je,ee.elevation,.05);this.updateHeightRange(Le),this.zOffsetVertexArray.emplaceBack(Le,0,0)}else this.fillNonElevatedRoadSegment(ne)}return!0}prepareElevatedLines(c,m,y){if(m.constantHeight!=null)return c;const k=[],E=1/Be(y);for(const P of c)ctt(P,new Ra(m,E),0,k);return k}fillNonElevatedRoadSegment(c){for(let m=c;m0,ne=B&&B.progress.max<1;if(this.lineClips){let $t={min:this.lineClips.start,max:this.lineClips.end},as=1;if(B){const _s=this.lineClips.end-this.lineClips.start;$t=function(bs,Os,Fs){return{min:xi(bs.min,Os,Fs),max:xi(bs.max,Os,Fs)}}(B.progress,{min:0,max:1},$t),_s>0&&(as=($t.max-$t.min)/_s)}const Wt=+m.properties.mapbox_clip_feature_len,hs=+m.properties.mapbox_clip_seg_len;if(Number.isNaN(Wt)||Number.isNaN(hs)){for(let bs=0;bs=2&&c[ue-1].equals(c[ue-2]);)ue--;let je=0;for(;je0,us=this.overscaling<=16?15*Ys/(512*this.overscaling):0;if(as&&Wt==="round"){if(OsP&&(Wt="bevel"),Wt==="bevel"&&(Os>2&&(Wt="flipbevel"),Os2*us){const Xs=Ie.sub(Ie.sub(Ge)._mult(us/is)._round());this.updateDistance(Ge,Xs),this.addCurrentVertex(Xs,rt,0,0,Le,It),Ge=Xs}this.updateDistance(Ge,Ie),_s._mult(Os),this.addCurrentVertex(Ie,_s,0,0,Le,It);const Ds=Ie.dist(Xe);if(Ds>2*us){const Xs=Ie.add(Xe.sub(Ie)._mult(us/Ds)._round());this.updateDistance(Ie,Xs),this.addCurrentVertex(Xs,_t,0,0,Le,It),Ie=Xs}}else _s._mult(Os),this.addCurrentVertex(Ie,_s,0,0,Le,It);else if(Wt==="flipbevel"){if(Os>100)_s=_t.mult(-1);else{const is=Os*rt.add(_t).mag()/rt.sub(_t).mag();_s._perp()._mult(is*(Ls?-1:1))}this.addCurrentVertex(Ie,_s,0,0,Le,It),this.addCurrentVertex(Ie,_s.mult(-1),0,0,Le,It)}else if(Wt==="bevel"||Wt==="fakeround"){It!=null&&Ge&&this.addCurrentVertex(Ie,St||rt,-1,-1,Le,It);const is=Ie.dist(Ge)<=2*us&&Wt!=="bevel",Ds=_s.mult(Ls?1:-1);Ds._mult(Os);const Xs=_t.mult(Ls?-1:1),qs=rt.mult(Ls?-1:1),Ir=this.evaluateLineProgressFeatures(this.distance);if(It==null&&(this.addHalfVertex(Ie,Ds.x,Ds.y,!1,!Ls,0,Le,Ir),is||this.addHalfVertex(Ie,Ds.x+2*qs.x,Ds.y+2*qs.y,!1,Ls,0,Le,Ir)),Wt==="fakeround"){const lr=Math.round(180*Fs/Math.PI/20);this.addHalfVertex(Ie,qs.x,qs.y,!1,Ls,0,Le,Ir);for(let gr=0;gr1){this.lineSoFar=c.w;const je=(m.x-c.x)/ee,Le=(m.y-c.y)/ee,Ie=(m.z-c.z)/ee,Ge=(m.w-c.w)/ee;for(let Xe=1;Xe=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 Gde(f,c,m){return f.xm||f.ym}let jke,kke;function Nke(f,c,m){return c*(Ys/(f.tileSize*Math.pow(2,m-f.tileID.overscaledZ)))}_r(Wde,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const Ske=(f,c,m)=>(1-m)*f+m*c;function Cke(f,c){return 1/Nke(f,1,c.tileZoom)}function Mke(f,c,m,y){return f.translatePosMatrix(y||c.tileID.projMatrix,c,m.paint.get("line-translate"),m.paint.get("line-translate-anchor"))}const Tke=f=>{const c=[];Ake(f)&&c.push("RENDER_LINE_DASH"),f.paint.get("line-gradient")&&c.push("RENDER_LINE_GRADIENT");const m=f.paint.get("line-trim-offset");m[0]===0&&m[1]===0||c.push("RENDER_LINE_TRIM_OFFSET"),f.paint.get("line-border-width").constantOr(1)!==0&&c.push("RENDER_LINE_BORDER");const y=f.layout.get("line-join").constantOr("miter")==="none",k=!!f.paint.get("line-pattern").constantOr(1);return y&&k&&c.push("LINE_JOIN_NONE"),c};function Ake(f){const c=f.paint.get("line-dasharray").value;return c.kind!=="constant"||c.value}let Kde;const Eke=()=>Kde||(Kde={layout:jke||(jke=new bo({"line-cap":new rr(Gt.layout_line["line-cap"]),"line-join":new rr(Gt.layout_line["line-join"]),"line-miter-limit":new Vs(Gt.layout_line["line-miter-limit"]),"line-round-limit":new Vs(Gt.layout_line["line-round-limit"]),"line-sort-key":new rr(Gt.layout_line["line-sort-key"]),"line-z-offset":new rr(Gt.layout_line["line-z-offset"]),"line-elevation-reference":new Vs(Gt.layout_line["line-elevation-reference"]),"line-cross-slope":new Vs(Gt.layout_line["line-cross-slope"]),visibility:new Vs(Gt.layout_line.visibility),"line-width-unit":new Vs(Gt.layout_line["line-width-unit"])})),paint:kke||(kke=new bo({"line-opacity":new rr(Gt.paint_line["line-opacity"]),"line-color":new rr(Gt.paint_line["line-color"]),"line-translate":new Vs(Gt.paint_line["line-translate"]),"line-translate-anchor":new Vs(Gt.paint_line["line-translate-anchor"]),"line-width":new rr(Gt.paint_line["line-width"]),"line-gap-width":new rr(Gt.paint_line["line-gap-width"]),"line-offset":new rr(Gt.paint_line["line-offset"]),"line-blur":new rr(Gt.paint_line["line-blur"]),"line-dasharray":new rr(Gt.paint_line["line-dasharray"]),"line-pattern":new rr(Gt.paint_line["line-pattern"]),"line-pattern-cross-fade":new Vs(Gt.paint_line["line-pattern-cross-fade"]),"line-gradient":new Py(Gt.paint_line["line-gradient"]),"line-trim-offset":new Vs(Gt.paint_line["line-trim-offset"]),"line-trim-fade-range":new Vs(Gt.paint_line["line-trim-fade-range"]),"line-trim-color":new Vs(Gt.paint_line["line-trim-color"]),"line-emissive-strength":new rr(Gt.paint_line["line-emissive-strength"]),"line-border-width":new rr(Gt.paint_line["line-border-width"]),"line-border-color":new rr(Gt.paint_line["line-border-color"]),"line-occlusion-opacity":new Vs(Gt.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"})}))},Kde);class est extends rr{possiblyEvaluate(c,m){return m=new Li(Math.floor(m.zoom),{now:m.now,fadeDuration:m.fadeDuration,transition:m.transition,worldview:m.worldview}),super.possiblyEvaluate(c,m)}evaluate(c,m,y,k){return m=Object.assign({},m,{zoom:Math.floor(m.zoom)}),super.evaluate(c,m,y,k)}}let uA;function Pke(f,c){return c>0?c+2*f:f}const tst=na([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),sst=na([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),rst=na([{name:"a_projected_pos",components:4,type:"Float32"}],4);na([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const nst=na([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),ast=na([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),ist=na([{name:"a_texb",components:2,type:"Uint16"}]),ost=na([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),lst=na([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);na([{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 Ike=na([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),cst=na([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);na([{name:"triangle",components:3,type:"Uint16"}]),na([{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"}]),na([{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"}]),na([{type:"Float32",name:"offsetX"}]),na([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var ac=24;function dst(f,c,m){return f.sections.forEach(y=>{y.text=function(k,E,P){const O=E.layout.get("text-transform").evaluate(P,{});return O==="uppercase"?k=k.toLocaleUpperCase():O==="lowercase"&&(k=k.toLocaleLowerCase()),Hf.applyArabicShaping&&(k=Hf.applyArabicShaping(k)),k}(y.text,c,m)}),f}const hA={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function ust(f){return f==="︶"||f==="﹈"||f==="︸"||f==="﹄"||f==="﹂"||f==="︾"||f==="︼"||f==="︺"||f==="︘"||f==="﹀"||f==="︐"||f==="︓"||f==="︔"||f==="`"||f===" ̄"||f==="︑"||f==="︒"}function hst(f){return f==="︵"||f==="﹇"||f==="︷"||f==="﹃"||f==="﹁"||f==="︽"||f==="︻"||f==="︹"||f==="︗"||f==="︿"}const Zde=4294967296,Lke=1/Zde,Dke=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let kO=class{constructor(f=new Uint8Array(16)){this.buf=ArrayBuffer.isView(f)?f:new Uint8Array(f),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(f,c,m=this.length){for(;this.pos>3,E=this.pos;this.type=7&y,f(k,c,this),this.pos===E&&this.skip(y)}return c}readMessage(f,c){return this.readFields(f,c,this.readVarint()+this.pos)}readFixed32(){const f=this.dataView.getUint32(this.pos,!0);return this.pos+=4,f}readSFixed32(){const f=this.dataView.getInt32(this.pos,!0);return this.pos+=4,f}readFixed64(){const f=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Zde;return this.pos+=8,f}readSFixed64(){const f=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Zde;return this.pos+=8,f}readFloat(){const f=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,f}readDouble(){const f=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,f}readVarint(f){const c=this.buf;let m,y;return y=c[this.pos++],m=127&y,y<128?m:(y=c[this.pos++],m|=(127&y)<<7,y<128?m:(y=c[this.pos++],m|=(127&y)<<14,y<128?m:(y=c[this.pos++],m|=(127&y)<<21,y<128?m:(y=c[this.pos],m|=(15&y)<<28,function(k,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 TC(k,B,E);throw new Error("Expected varint not more than 10 bytes")}(m,f,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const f=this.readVarint();return f%2==1?(f+1)/-2:f/2}readBoolean(){return!!this.readVarint()}readString(){const f=this.readVarint()+this.pos,c=this.pos;return this.pos=f,f-c>=12&&Dke?Dke.decode(this.buf.subarray(c,f)):function(m,y,k){let E="",P=y;for(;P239?4:O>223?3:O>191?2:1;if(P+ne>k)break;ne===1?O<128&&(ee=O):ne===2?(B=m[P+1],(192&B)==128&&(ee=(31&O)<<6|63&B,ee<=127&&(ee=null))):ne===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))):ne===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,ne=1):ee>65535&&(ee-=65536,E+=String.fromCharCode(ee>>>10&1023|55296),ee=56320|1023&ee),E+=String.fromCharCode(ee),P+=ne}return E}(this.buf,c,f)}readBytes(){const f=this.readVarint()+this.pos,c=this.buf.subarray(this.pos,f);return this.pos=f,c}readPackedVarint(f=[],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(f,c){this.writeVarint(f<<3|c)}realloc(f){let c=this.length||16;for(;c268435455||f<0?function(c,m){let y,k;if(c>=0?(y=c%4294967296|0,k=c/4294967296|0):(y=~(-c%4294967296),k=~(-c/4294967296),4294967295^y?y=y+1|0:(y=0,k=k+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)}(y,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)))))}(k,m)}(f,this):(this.realloc(4),this.buf[this.pos++]=127&f|(f>127?128:0),f<=127||(this.buf[this.pos++]=127&(f>>>=7)|(f>127?128:0),f<=127||(this.buf[this.pos++]=127&(f>>>=7)|(f>127?128:0),f<=127||(this.buf[this.pos++]=f>>>7&127))))}writeSVarint(f){this.writeVarint(f<0?2*-f-1:2*f)}writeBoolean(f){this.writeVarint(+f)}writeString(f){f=String(f),this.realloc(4*f.length),this.pos++;const c=this.pos;this.pos=function(y,k,E){for(let P,O,B=0;B55295&&P<57344){if(!O){P>56319||B+1===k.length?(y[E++]=239,y[E++]=191,y[E++]=189):O=P;continue}if(P<56320){y[E++]=239,y[E++]=191,y[E++]=189,O=P;continue}P=O-55296<<10|P-56320|65536,O=null}else O&&(y[E++]=239,y[E++]=191,y[E++]=189,O=null);P<128?y[E++]=P:(P<2048?y[E++]=P>>6|192:(P<65536?y[E++]=P>>12|224:(y[E++]=P>>18|240,y[E++]=P>>12&63|128),y[E++]=P>>6&63|128),y[E++]=63&P|128)}return E}(this.buf,f,this.pos);const m=this.pos-c;m>=128&&Oke(c,m,this),this.pos=c-1,this.writeVarint(m),this.pos+=m}writeFloat(f){this.realloc(4),this.dataView.setFloat32(this.pos,f,!0),this.pos+=4}writeDouble(f){this.realloc(8),this.dataView.setFloat64(this.pos,f,!0),this.pos+=8}writeBytes(f){const c=f.length;this.writeVarint(c),this.realloc(c);for(let m=0;m=128&&Oke(m,y,this),this.pos=m-1,this.writeVarint(y),this.pos+=y}writeMessage(f,c,m){this.writeTag(f,2),this.writeRawMessage(c,m)}writePackedVarint(f,c){c.length&&this.writeMessage(f,mst,c)}writePackedSVarint(f,c){c.length&&this.writeMessage(f,pst,c)}writePackedBoolean(f,c){c.length&&this.writeMessage(f,xst,c)}writePackedFloat(f,c){c.length&&this.writeMessage(f,fst,c)}writePackedDouble(f,c){c.length&&this.writeMessage(f,gst,c)}writePackedFixed32(f,c){c.length&&this.writeMessage(f,yst,c)}writePackedSFixed32(f,c){c.length&&this.writeMessage(f,vst,c)}writePackedFixed64(f,c){c.length&&this.writeMessage(f,_st,c)}writePackedSFixed64(f,c){c.length&&this.writeMessage(f,bst,c)}writeBytesField(f,c){this.writeTag(f,2),this.writeBytes(c)}writeFixed32Field(f,c){this.writeTag(f,5),this.writeFixed32(c)}writeSFixed32Field(f,c){this.writeTag(f,5),this.writeSFixed32(c)}writeFixed64Field(f,c){this.writeTag(f,1),this.writeFixed64(c)}writeSFixed64Field(f,c){this.writeTag(f,1),this.writeSFixed64(c)}writeVarintField(f,c){this.writeTag(f,0),this.writeVarint(c)}writeSVarintField(f,c){this.writeTag(f,0),this.writeSVarint(c)}writeStringField(f,c){this.writeTag(f,2),this.writeString(c)}writeFloatField(f,c){this.writeTag(f,5),this.writeFloat(c)}writeDoubleField(f,c){this.writeTag(f,1),this.writeDouble(c)}writeBooleanField(f,c){this.writeVarintField(f,+c)}};function TC(f,c,m){return m?4294967296*c+(f>>>0):4294967296*(c>>>0)+(f>>>0)}function Oke(f,c,m){const y=c<=16383?1:c<=2097151?2:c<=268435455?3:Math.floor(Math.log(c)/(7*Math.LN2));m.realloc(y);for(let k=m.pos-1;k>=f;k--)m.buf[k+y]=m.buf[k]}function mst(f,c){for(let m=0;m=0&&y>=c&&NO[this.text.charCodeAt(y)];y--)m--;this.text=this.text.substring(c,m),this.sectionIndex=this.sectionIndex.slice(c,m)}substring(c,m){const y=new AC;return y.text=this.text.substring(c,m),y.sectionIndex=this.sectionIndex.slice(c,m),y.sections=this.sections,y}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(mA.forText(c.scale,c.fontStack||m));const y=this.sections.length-1;for(let k=0;k=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Xde(f,c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je=1){const Le=AC.fromFeature(f,k,je);ee===_h.vertical&&Le.verticalizePunctuation(ne);let Ie=[];const Ge=function(St,It,$t,as,Wt,hs){if(!St)return[];const _s=[],bs=function(Ls,us,is,Ds,Xs,qs){let Ir=0;for(let lr=0;lr=0;let Fs=0;for(let Ls=0;Ls0&&za>Pn&&(Pn=za)}else{const Pa=$t[Rs.fontStack];if(!Pa)continue;Pa[ar]&&(kn=Pa[ar]);const Fa=It[Rs.fontStack];if(!Fa)continue;const za=Fa.glyphs[ar];if(!za)continue;if(zr=za.metrics,Hn=ar!==8203?ac:0,qs){const li=Fa.ascender!==void 0?Math.abs(Fa.ascender):0,ki=Fa.descender!==void 0?Math.abs(Fa.descender):0,vi=(li+ki)*Dr;yi-m/2;){if(P--,P<0)return!1;O-=f[P].dist(E),E=f[P]}O+=f[P].dist(f[P+1]),P++;const B=[];let W=0;for(;Oy;)W-=B.shift().angleDelta;if(W>k)return!1;P++,O+=J.dist(ee)}return!0}function Gke(f){let c=0;for(let m=0;mW){const ue=(W-B)/ce,je=Vr(ee.x,ne.x,ue),Le=Vr(ee.y,ne.y,ue),Ie=new By(je,Le,0,ne.angleTo(ee),J);return!P||Wke(f,Ie,O,P,c)?Ie:void 0}B+=ce}}function Mst(f,c,m,y,k,E,P,O,B){const W=Kke(y,E,P),J=Zke(y,k),ee=J*P,ne=f[0].x===0||f[0].x===B||f[0].y===0||f[0].y===B;return c-ee=0&&rt=0&&_t=0&&ne+W<=J){const ft=new By(rt,_t,0,Ge,ue);y&&!Wke(f,ft,E,y,k)||ce.push(ft)}}ee+=Ie}return O||ce.length||P||(ce=Yke(f,ee/2,m,y,k,E,P,!0,B)),ce}function Xke(f){let c=0,m=0;for(const P of f)c+=P.w*P.h,m=Math.max(m,P.w);f.sort((P,O)=>O.h-P.h);const y=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(c/.95)),m),h:1/0}];let k=0,E=0;for(const P of f)for(let O=y.length-1;O>=0;O--){const B=y[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),k=Math.max(k,P.x+P.w),P.w===B.w&&P.h===B.h){const W=y.pop();W&&O1?ue-1:ue,xd.copy(ee.data,W,{x:0,y:0},{x:je,y:Le},ee.data,y),xd.copy(ee.data,W,{x:0,y:Ge-ue},{x:je,y:Le-ue},{width:Ie,height:ue},y),xd.copy(ee.data,W,{x:0,y:0},{x:je,y:Le+Ge},{width:Ie,height:ue},y),xd.copy(ee.data,W,{x:Ie-ue,y:0},{x:je-ue,y:Le},{width:ue,height:Ge},y),xd.copy(ee.data,W,{x:0,y:0},{x:je+Ie,y:Le},{width:ue,height:Ge},y),xd.copy(ee.data,W,{x:Ie-ue,y:Ge-ue},{x:je-ue,y:Le-ue},{width:ue,height:ue},y),xd.copy(ee.data,W,{x:0,y:Ge-ue},{x:je+Ie,y:Le-ue},{width:ue,height:ue},y),xd.copy(ee.data,W,{x:0,y:0},{x:je+Ie,y:Le+Ge},{width:ue,height:ue},y),xd.copy(ee.data,W,{x:Ie-ue,y:0},{x:je-ue,y:Le+Ge},{width:ue,height:ue},y)}this.lut=y,this.image=W,this.iconPositions=k,this.patternPositions=E}addImages(c,m,y,k){for(const[E,P]of c.entries()){const{bin:O,imagePosition:B,imageVariant:W}=sue(E,P,y);m.set(E,B),k.push(O),P.hasRenderCallback&&this.haveRenderCallbacks.push(W.id)}}patchUpdatedImages(c,m,y){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(k=>c.hasImage(k,y)),c.dispatchRenderCallbacks(this.haveRenderCallbacks,y);for(const k of c.getUpdatedImages(y)){for(const E of this.iconPositions.keys()){const P=Ff.parse(E);if(Ws.isEqual(P.id,k)){const O=c.getImage(k,y);this.patchUpdatedImage(this.iconPositions.get(E),O,m,null)}}for(const E of this.patternPositions.keys()){const P=Ff.parse(E);if(Ws.isEqual(P.id,k)){const O=c.getImage(k,y);this.patchUpdatedImage(this.patternPositions.get(E),O,m,this.lut)}}}}patchUpdatedImage(c,m,y,k=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,k,O),y.update(W,{position:{x:E,y:P}})}else y.update(m.data,{position:{x:E,y:P}})}}_r(pA,"ImagePosition"),_r(Qke,"ImageAtlas");const fA=1e20;function Jke(f,c,m,y,k,E,P,O,B){for(let W=c;W-1);B++,E[B]=O,P[B]=W,P[B+1]=fA}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 cr("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]=[],IC.loadGlyphRange(E,J,k,this.requestManager,(ne,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(ne,ce);delete B.requests[J]})),ee.push((ne,ce)=>{ne?O(ne):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!==rue.none&&(this.localGlyphMode===rue.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,y){const k=this.localFontFamily;if(!k||!this._doesCharSupportLocalGlyph(y))return;let E=c.tinySDF;if(!E){let je="400";/bold/i.test(m)?je="900":/medium/i.test(m)?je="500":/light/i.test(m)&&(je="200"),E=c.tinySDF=new IC.TinySDF({fontFamily:k,fontWeight:je,fontSize:24*sg,buffer:3*sg,radius:8*sg}),E.fontWeight=je}if(this.localGlyphs[E.fontWeight][y])return this.localGlyphs[E.fontWeight][y];const P=String.fromCodePoint(y),{data:O,width:B,height:W,glyphWidth:J,glyphHeight:ee,glyphLeft:ne,glyphTop:ce,glyphAdvance:ue}=E.draw(P);return this.localGlyphs[E.fontWeight][y]={id:y,bitmap:new Fv({width:B,height:W},O),metrics:{width:J/sg,height:ee/sg,left:ne/sg,top:ce/sg-27,advance:ue/sg,localGlyph:!0}}}}IC.loadGlyphRange=function(f,c,m,y,k){const E=256*c,P=E+255,O=y.transformRequest(y.normalizeGlyphsURL(m).replace("{fontstack}",f).replace("{range}",`${E}-${P}`),Df.Glyphs);qu(O,(B,W)=>{if(B)k(B);else if(W){const J={},ee=function(ne){return new kO(ne).readFields(wst,{})}(W);for(const ne of ee.glyphs)J[ne.id]=ne;k(null,{glyphs:J,ascender:ee.ascender,descender:ee.descender})}})},IC.TinySDF=class{constructor({fontSize:f=24,buffer:c=3,radius:m=8,cutoff:y=.25,fontFamily:k="sans-serif",fontWeight:E="normal",fontStyle:P="normal",lang:O=null}={}){this.buffer=c,this.cutoff=y,this.radius=m,this.lang=O;const B=this.size=f+4*c,W=this._createCanvas(B),J=this.ctx=W.getContext("2d",{willReadFrequently:!0});J.font=`${P} ${E} ${f}px ${k}`,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(f){const c=document.createElement("canvas");return c.width=c.height=f,c}draw(f){const{width:c,actualBoundingBoxAscent:m,actualBoundingBoxDescent:y,actualBoundingBoxLeft:k,actualBoundingBoxRight:E}=this.ctx.measureText(f),P=Math.ceil(m),O=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(E-k))),B=Math.min(this.size-this.buffer,P+Math.ceil(y)),W=O+2*this.buffer,J=B+2*this.buffer,ee=Math.max(W*J,0),ne=new Uint8ClampedArray(ee),ce={data:ne,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:je,gridInner:Le,gridOuter:Ie}=this;this.lang&&(ue.lang=this.lang),ue.clearRect(je,je,O,B),ue.fillText(f,je,je+P);const Ge=ue.getImageData(je,je,O,B);Ie.fill(fA,0,ee),Le.fill(0,0,ee);for(let Xe=0;Xe0?St*St:0,Le[ft]=St<0?St*St:0}}Jke(Ie,0,0,W,J,W,this.f,this.v,this.z),Jke(Le,je,je,O,B,W,this.f,this.v,this.z);for(let Xe=0;Xe{const Os=MO(Wt.stretch-Ge,Xe,J,f.left*k),Fs=TO(Wt.fixed-ft,St,Wt.stretch,ue),Ps=MO(hs.stretch-rt,_t,ee,f.top*k),Ls=TO(hs.fixed-It,$t,hs.stretch,je),us=MO(_s.stretch-Ge,Xe,J,f.left*k),is=TO(_s.fixed-ft,St,_s.stretch,ue),Ds=MO(bs.stretch-rt,_t,ee,f.top*k),Xs=TO(bs.fixed-It,$t,bs.stretch,je),qs=new rs(Os,Ps),Ir=new rs(us,Ps),lr=new rs(us,Ds),gr=new rs(Os,Ds),Nr=new rs(Fs/O,Ls/O),Wn=new rs(is/O,Xs/O),Us=c*Math.PI/180;if(Us){const yi=Math.sin(Us),gt=Math.cos(Us),wt=[gt,-yi,yi,gt];qs._matMult(wt),Ir._matMult(wt),gr._matMult(wt),lr._matMult(wt)}const Sr=Wt.stretch+Wt.fixed,hn=_s.stretch+_s.fixed,ma=hs.stretch+hs.fixed,xa=bs.stretch+bs.fixed,Pn=f.imageSecondary;return{tl:qs,tr:Ir,bl:gr,br:lr,texPrimary:{x:P.paddedRect.x+xx+Sr,y:P.paddedRect.y+xx+ma,w:hn-Sr,h:xa-ma},texSecondary:Pn?{x:Pn.paddedRect.x+xx+Sr,y:Pn.paddedRect.y+xx+ma,w:hn-Sr,h:xa-ma}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Nr,pixelOffsetBR:Wn,minFontScaleX:St/O/J,minFontScaleY:$t/O/ee,isSDF:m}};if(y&&(P.stretchX||P.stretchY)){const Wt=sNe(ne,Le,ue),hs=sNe(ce,Ie,je);for(let _s=0;_sE)&&(E=ue.x),(!ce||ue.y>P)&&(P=ue.y)}const B=Math.min(E-y,P-k);let W=B/2;const J=new jS([],Pst);if(B===0)return new rs(y,k);for(let ce=y;ceee.d||!ee.d)&&(ee=ce,m&&console.log("found best %d after %d probes",Math.round(1e4*ce.d)/1e4,ne)),ce.max-ee.d<=c||(W=ce.h/2,J.push(new LC(ce.p.x-W,ce.p.y-W,W,f)),J.push(new LC(ce.p.x+W,ce.p.y-W,W,f)),J.push(new LC(ce.p.x-W,ce.p.y+W,W,f)),J.push(new LC(ce.p.x+W,ce.p.y+W,W,f)),ne+=4)}return m&&(console.log(`num probes: ${ne}`),console.log(`best distance: ${ee.d}`)),ee.p}function Pst(f,c){return c.max-f.max}class LC{constructor(c,m,y,k){this.p=new rs(c,m),this.h=y,this.d=function(E,P){let O=!1,B=1/0;for(let W=0;WE.y!=je.y>E.y&&E.x<(je.x-ue.x)*(E.y-ue.y)/(je.y-ue.y)+ue.x&&(O=!O),B=Math.min(B,To(E,ue,je))}}return(O?1:-1)*Math.sqrt(B)}(this.p,k),this.max=this.d+this.h*Math.SQRT2}}const Ist=Object.keys,aue=Number.POSITIVE_INFINITY,Lst=Math.sqrt(2);function Bv(f,c,m,y,k){const E=Jde(f)&&f.collisionPadding?f.collisionPadding:[0,0,0,0],P={top:f.top-E[1],bottom:f.bottom+E[3],left:f.left-E[0],right:f.right+E[2],scaled:!1};return y!==void 0&&function(O,B){O.top*=B,O.bottom*=B,O.left*=B,O.right*=B,O.scaled=!0}(P,y),m&&function(O,B){if(!B)return;const W=Jr(B),J=new rs(O.left,O.top),ee=new rs(O.right,O.top),ne=new rs(O.left,O.bottom),ce=new rs(O.right,O.bottom),ue=new rs(0,0);J._rotateAround(W,ue),ee._rotateAround(W,ue),ne._rotateAround(W,ue),ce._rotateAround(W,ue),O.left=Math.min(J.x,ee.x,ne.x,ce.x),O.right=Math.max(J.x,ee.x,ne.x,ce.x),O.top=Math.min(J.y,ee.y,ne.y,ce.y),O.bottom=Math.max(J.y,ee.y,ne.y,ce.y)}(P,m),k&&(P.left+=k[0],P.right+=k[0],P.top+=k[1],P.bottom+=k[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 nNe(f,[c,m]){let y=0,k=0;if(m===aue){c<0&&(c=0);const E=c/Lst;switch(f){case"top-right":case"top-left":k=E-7;break;case"bottom-right":case"bottom-left":k=7-E;break;case"bottom":k=7-c;break;case"top":k=c-7}switch(f){case"top-right":case"bottom-right":y=-E;break;case"top-left":case"bottom-left":y=E;break;case"left":y=c;break;case"right":y=-c}}else{switch(c=Math.abs(c),m=Math.abs(m),f){case"top-right":case"top-left":case"top":k=m-7;break;case"bottom-right":case"bottom-left":case"bottom":k=7-m}switch(f){case"top-right":case"bottom-right":case"right":y=-c;break;case"top-left":case"bottom-left":case"left":y=c}}return[y,k]}function Dst(f,c,m,y,k,E,P,O,B,W,J,ee,ne,ce){const ue=f.layers[0],je=ue.appearances;if(je.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const Le={iconBBox:null,iconVerticalBBox:null},Ie={textBBox:null,textVerticalBBox:null},{baseIconRotate:Ge,baseTextRotate:Xe,iconScaleFactor:rt}=function(ft,St,It){const $t=ft.get("icon-rotate").evaluate(St,{},It),as=ft.get("text-rotate").evaluate(St,{},It),[Wt,hs]=ft.get("icon-size-scale-range");return{baseIconRotate:$t,baseTextRotate:as,iconScaleFactor:Se(1,Wt,hs)}}(y,k,E);c&&(Le.iconBBox=Bv(c,Le.iconBBox,Ge,P),m)&&(Le.iconVerticalBBox=Bv(m,Le.iconVerticalBBox,Ge+90,P));const _t=EO(ee.horizontal);_t&&(Ie.textBBox=Bv(_t,Ie.textBBox,Xe,1,ce)),ee.vertical&&(Ie.textVerticalBBox=Bv(ee.vertical,Ie.textVerticalBBox,Xe+90,1,ce));for(const ft of je)ft.hasIconProperties()&&Ost(Le,f,ue,ft,k,E,O,Ge,P,B,c,W,rt,J),ft.hasTextProperties()&&Rst(Ie,ue,ft,k,E,ce,Xe,ne,_t,ee.vertical);return{iconBBox:Le.iconBBox,iconVerticalBBox:Le.iconVerticalBBox,textBBox:Ie.textBBox,textVerticalBBox:Ie.textVerticalBBox}}function Ost(f,c,m,y,k,E,P,O,B,W,J,ee,ne,ce){const{appearanceIconOffset:ue,appearanceIconRotate:je,appearanceIconSize:Le}=function(rt,_t,ft,St,It,$t,as,Wt){const hs=rt.hasProperty("icon-offset")?_t.getAppearanceValueAndResolveTokens(rt,"icon-offset",ft,St,[]):null,_s=hs&&Array.isArray(hs)?hs:It,bs=rt.hasProperty("icon-rotate")?_t.getAppearanceValueAndResolveTokens(rt,"icon-rotate",ft,St,[]):null,Os=typeof bs=="number"?bs:$t,Fs=rt.hasProperty("icon-size")?_t.getAppearanceValueAndResolveTokens(rt,"icon-size",ft,St,[]):null;return{appearanceIconOffset:_s,appearanceIconRotate:Os,appearanceIconSize:typeof Fs=="number"?Fs*Wt.iconScaleFactor:as}}(y,m,k,E,P,O,B,W);let Ie=null,Ge=null,Xe=null;y.hasProperty("icon-image")?Xe=function(rt,_t,ft,St,It,$t,as){let Wt=null;const hs=_t.getAppearanceValueAndResolveTokens(ft,"icon-image",St,It,[]);if(hs){const _s=rt.getResolvedImageFromTokens(hs),bs=ft.getUnevaluatedProperty("icon-size"),Os=gA(_s,EC(rt.zoom,bs,rt.worldview),bs,It,rt.zoom,St,rt.pixelRatio,as,rt.worldview);Wt=$t.get(Os.iconPrimary.toString())}return Wt}(c,m,y,k,E,ee,ne):J&&(Xe=J.imagePrimary),Xe&&(Ie=SO(Xe,null,ue,ce),c.allowVerticalPlacement&&(Ge=SO(Xe,null,ue,ce))),Ie&&(f.iconBBox=Bv(Ie,f.iconBBox,je,Le)),Ge&&(f.iconVerticalBBox=Bv(Ge,f.iconVerticalBBox,je+90,Le))}function Rst(f,c,m,y,k,E,P,O,B,W){const{appearanceTextOffset:J,appearanceTextRotate:ee,appearanceTextSize:ne}=function(ue,je,Le,Ie,Ge,Xe,rt){const _t=ue.hasProperty("text-offset")?je.getAppearanceValueAndResolveTokens(ue,"text-offset",Le,Ie,[]):null,ft=_t&&Array.isArray(_t)?[_t[0]*ac,_t[1]*ac]:Ge,St=ue.hasProperty("text-rotate")?je.getAppearanceValueAndResolveTokens(ue,"text-rotate",Le,Ie,[]):null,It=typeof St=="number"?St:Xe,$t=ue.hasProperty("text-size")?je.getAppearanceValueAndResolveTokens(ue,"text-size",Le,Ie,[]):null;return{appearanceTextOffset:ft,appearanceTextRotate:It,appearanceTextSize:typeof $t=="number"?$t:rt}}(m,c,y,k,E,P,O),ce=ne/O;B&&(f.textBBox=Bv(B,f.textBBox,ee,ce,J)),W&&(f.textVerticalBBox=Bv(W,f.textVerticalBBox,ee+90,ce,J))}function AO(f,c,m,y,k,E,P,O,B){if(!c||!c.usvg)return;const W=Hke(y),J=Hke(k),ee=E!=="both"&&E!=="width"||!Uke(y)?1:J.width/W.width,ne=E!=="both"&&E!=="height"||!Vke(y)?1:J.height/W.height;m.scaleSelf(ee,ne);const ce=m.toString();P.set(ce,m),O.set(ce,c);const{imagePosition:ue}=sue(ce,c,Bb);B.set(ce,ue)}function aNe(f,c,m,y,k,E,P,O,B){if(!f)return;const W=function(J,ee,ne,ce,ue,je){if(J.kind==="camera")return J.maxSize;if(J.kind==="composite"){const Le=ee.possiblyEvaluate(new Li(J.maxZoom,{worldview:je}),ne).evaluate(ue,{},ne),Ie=ee.possiblyEvaluate(new Li(J.minZoom,{worldview:je}),ne).evaluate(ue,{},ne);return Math.max(Le,Ie)}return ee.possiblyEvaluate(new Li(ce,{worldview:je})).evaluate(ue,{},ne)}(c,m,y,k,E,B);return f.scaleSelf(W*O*P)}function gA(f,c,m,y,k,E,P,O,B){return{iconPrimary:aNe(f.getPrimary(),c,m,y,k,E,P,O,B),iconSecondary:aNe(f.getSecondary(),c,m,y,k,E,P,O,B)}}function Fst(f,c,m){if(!c)return;const y=m.get(f.toString()),k=m.get(c.toString());y&&k&&(y.paddedRect.w===k.paddedRect.w&&y.paddedRect.h===k.paddedRect.h||cr(`Mismatch in icon variant sizes: ${f.toString()} and ${c.toString()}`),y.usvg!==k.usvg&&cr(`Mismatch in icon variant image types: ${f.id} and ${c.id}`))}function iNe(f,c,m,y){if(!f)return;const k=c.get(m.toString());if(f.imagePrimary=k,y){const E=c.get(y.toString());f.imageSecondary=E}}function zst(f,c){for(const m in f.horizontal)oNe(f.horizontal[m],c);oNe(f.vertical,c)}function oNe(f,c){if(f){for(const m of f.positionedLines)for(const y of m.positionedGlyphs)if(y.image!==null){const k=y.image.toString();y.rect=c.get(k).paddedRect}}}function iue(f){switch(f){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Bst(f,c,m,y,k,E,P,O,B){const W=EO(E.horizontal)||E.vertical,J=m.get("icon-text-fit-padding").evaluate(y,{},k);let ee,ne=c;return c&&B!=="none"&&(f.allowVerticalPlacement&&E.vertical&&(ee=eue(c,E.vertical,B,J,O,P)),W&&(ne=eue(c,W,B,J,O,P))),{defaultShapedIcon:ne,verticallyShapedIcon:ee}}function $st(f,c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie,Ge,Xe,rt,_t,ft,St){let It=P.textMaxSize.evaluate(c,{},ne);It===void 0?It=O*P.textScaleFactor:It*=P.textScaleFactor;const $t=f.layers[0].layout,as=ac,Wt=O*P.textScaleFactor/as,hs=EO(m.horizontal)||m.vertical;if(Le!=="none"&&f.appearanceFeatureData&&c.index18&&Ds>2&&(Ds>>=1),Math.max(Ys/(512*Ds),1)*$t.get("symbol-spacing")),Fs=$t.get("text-padding")*f.tilePixelRatio,Ps=$t.get("icon-padding")*f.tilePixelRatio,Ls=Jr($t.get("text-max-angle")),us=$t.get("icon-rotation-alignment")==="map"&&Xe!=="point",is=Os/2;var Ds;f.hasAnyIconTextFit===!1&&Le!=="none"&&(f.hasAnyIconTextFit=!0);const Xs=c.properties?+c.properties[cs]:null,qs=Xs&&f.elevationFeatureIdToIndex?f.elevationFeatureIdToIndex.get(Xs):65535,Ir=(lr,gr,Nr)=>{if(gr.x<0||gr.x>=Ys||gr.y<0||gr.y>=Ys)return;let Wn=null;if(_s){const{x:Us,y:Sr,z:hn}=ce.projectTilePoint(gr.x,gr.y,Nr);Wn={anchor:new By(Us,Sr,hn,0,void 0),up:ce.upVector(Nr,gr.x,gr.y)}}(function(Us,Sr,hn,ma,xa,Pn,yi,gt,wt,ms,Rs,nr,ar,Dr,zr,kn,Bn,Hn,aa,en,un,Pa,Fa,za,li,ki,vi,Ga,ei,$n,ga,so,Yr){const ia=Us.addToLineVertexArray(Sr,ma);let bi,Ei,Di,Ro,Pi,Xr,po,ci=0,Wi=0,wl=0,ic=0,al=-1,il=-1;const Vl={};let Cu=dv("");const Ii=hn?hn.anchor:Sr,Ao=Ga!=="none";let Fo=0,Vu=0;if(wt._unevaluatedLayout.getValue("text-radial-offset")===void 0){const td=wt.layout.get("text-offset").evaluate(un,{},li);Fo=td[0]*ac,Vu=td[1]*ac}else Fo=wt.layout.get("text-radial-offset").evaluate(un,{},li)*ac,Vu=aue;if(Us.allowVerticalPlacement&&xa.vertical){const td=xa.vertical;if(zr)Xr=oue(td),gt&&(po=oue(gt));else{const tu=wt.layout.get("text-rotate").evaluate(un,{},li)+90;Di=PO(ms,Ii,Sr,Rs,nr,ar,td,Dr,tu,kn,so),gt&&(Ro=PO(ms,Ii,Sr,Rs,nr,ar,gt,Hn,tu,null,ga))}}if(Pn){const td=Us.iconSizeData,tu=wt.layout.get("icon-rotate").evaluate(un,{},li),bh=nue(Pn,tu,Fa,Ao,Pa.iconScaleFactor),Uv=gt?nue(gt,tu,Fa,Ao,Pa.iconScaleFactor):void 0;Ei=PO(ms,Ii,Sr,Rs,nr,ar,Pn,Hn,tu,null,$n);const $C=function(ig,LA,SSe,Jrt,CSe,MSe,ent,tnt){const TSe=ig.layers[0],ASe=TSe.appearances;let qC=LA.length;if(SSe&&(qC=Math.max(qC,SSe.length)),ASe.length===0)return qC;const[snt,rnt]=Jrt.get("icon-size-scale-range"),nnt=Se(1,snt,rnt);for(const ESe of ASe){const PSe=ESe.getUnevaluatedProperties();if(PSe._values["icon-image"].value!==void 0){const ISe=TSe.getAppearanceValueAndResolveTokens(ESe,"icon-image",CSe,MSe,[]);if(ISe){const LSe=ig.getResolvedImageFromTokens(ISe);if(LSe){const DSe=PSe._values["icon-size"],ant=gA(LSe,EC(ig.zoom,DSe,ig.worldview),DSe,MSe,ig.zoom,CSe,ig.pixelRatio,nnt,ig.worldview),int=ent.get(ant.iconPrimary.toString());qC=Math.max(qC,Tst(int,tnt))}}}}return qC}(Us,bh,Uv,wt.layout,un,li,Us.iconAtlasPositions,Ao);ci=4*$C;let ag=null;td.kind==="source"?(ag=[tg*wt.layout.get("icon-size").evaluate(un,{},li)*Pa.iconScaleFactor],ag[0]>$y&&cr(`${Us.layerIds[0]}: Value for "icon-size" is >= ${xA}. Reduce your "icon-size".`)):td.kind==="composite"&&(ag=[tg*Pa.compositeIconSizes[0].evaluate(un,{},li)*Pa.iconScaleFactor,tg*Pa.compositeIconSizes[1].evaluate(un,{},li)*Pa.iconScaleFactor],(ag[0]>$y||ag[1]>$y)&&cr(`${Us.layerIds[0]}: Value for "icon-size" is >= ${xA}. Reduce your "icon-size".`)),Us.addSymbols(Us.icon,bh,ag,en,aa,un,void 0,hn,Sr,ia.lineStartIndex,ia.lineLength,-1,za,li,ki,vi,Us.symbolInstances.length,$C),al=Us.icon.placedSymbolArray.length-1,Uv&&(Wi=4*$C,Us.addSymbols(Us.icon,Uv,ag,en,aa,un,_h.vertical,hn,Sr,ia.lineStartIndex,ia.lineLength,-1,za,li,ki,vi,Us.symbolInstances.length,$C),il=Us.icon.placedSymbolArray.length-1)}for(const td in xa.horizontal){const tu=td,bh=xa.horizontal[tu];bi||(Cu=dv(bh.text),zr?Pi=oue(bh):bi=PO(ms,Ii,Sr,Rs,nr,ar,bh,Dr,wt.layout.get("text-rotate").evaluate(un,{},li),kn,so));const Uv=bh.positionedLines.length===1;if(wl+=lNe(Us,hn,Sr,bh,yi,wt,zr,un,kn,ia,xa.vertical?_h.horizontal:_h.horizontalOnly,Uv?Ist(xa.horizontal):[tu],Vl,al,Pa,za,li,Us.symbolInstances.length,ki),Uv)break}xa.vertical&&(ic+=lNe(Us,hn,Sr,xa.vertical,yi,wt,zr,un,kn,ia,_h.vertical,["vertical"],Vl,il,Pa,za,li,Us.symbolInstances.length,ki));let jl=-1;const zp=(td,tu)=>td?Math.max(td,tu):tu;jl=zp(Pi,jl),jl=zp(Xr,jl),jl=zp(po,jl);const yx=jl>-1?1:0;Us.glyphOffsetArray.length>=65535&&cr("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),un.sortKey!==void 0&&Us.addToSortKeyRanges(Us.symbolInstances.length,un.sortKey),Us.symbolInstances.emplaceBack(Sr.x,Sr.y,Ii.x,Ii.y,Ii.z,Vl.right>=0?Vl.right:-1,Vl.center>=0?Vl.center:-1,Vl.left>=0?Vl.left:-1,Vl.vertical>=0?Vl.vertical:-1,al,il,Cu,bi!==void 0?bi:Us.collisionBoxArray.length,bi!==void 0?bi+1:Us.collisionBoxArray.length,Di!==void 0?Di:Us.collisionBoxArray.length,Di!==void 0?Di+1:Us.collisionBoxArray.length,Ei!==void 0?Ei:Us.collisionBoxArray.length,Ei!==void 0?Ei+1:Us.collisionBoxArray.length,Ro||Us.collisionBoxArray.length,Ro?Ro+1:Us.collisionBoxArray.length,Rs,wl,ic,ci,Wi,yx,0,Fo,Vu,jl,0,Ao?1:0,ei)})(f,gr,Wn,lr,m,y,E,k,f.layers[0],f.collisionBoxArray,c.index,c.sourceLayerIndex,f.index,Fs,Ge,W,0,Ps,us,Ie,c,P,J,ee,ne,ue,je,Le,qs,rt,_t,ft)};if(Xe==="line")for(const lr of mO(c.geometry,0,0,Ys,Ys)){const gr=Mst(lr,Os,Ls,m.vertical||hs,y,as,bs,f.overscaling,Ys);for(const Nr of gr)hs&&qst(f,hs.text,is,Nr)||Ir(lr,Nr,ne)}else if(Xe==="line-center"){for(const lr of c.geometry)if(lr.length>1){const gr=Cst(lr,Ls,m.vertical||hs,y,as,bs);gr&&Ir(lr,gr,ne)}}else if(c.type==="Polygon")for(const lr of JT(c.geometry,0)){const gr=Est(lr,16);Ir(lr[0],new By(gr.x,gr.y,0,0,void 0),ne)}else if(c.type==="LineString")for(const lr of c.geometry)Ir(lr,new By(lr[0].x,lr[0].y,0,0,void 0),ne);else if(c.type==="Point")for(const lr of c.geometry)for(const gr of lr)Ir([gr],new By(gr.x,gr.y,0,0,void 0),ne)}const xA=255,$y=xA*tg;function lNe(f,c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie,Ge){const Xe=function(ft,St,It,$t,as,Wt,hs,_s){const bs=[];if(St.positionedLines.length===0)return bs;const Os=$t.layout.get("text-rotate").evaluate(Wt,{})*Math.PI/180,Fs=function(Ds){const Xs=Ds[0],qs=Ds[1],Ir=Xs*qs;return Ir>0?[Xs,-qs]:Ir<0?[-Xs,qs]:Xs===0?[qs,Xs]:[qs,-Xs]}(It);let Ps=Math.abs(St.top-St.bottom);for(const Ds of St.positionedLines)Ps-=Ds.lineOffset;const Ls=St.positionedLines.length,us=Ps/Ls;let is=St.top-It[1];for(let Ds=0;Ds$y&&cr(`${f.layerIds[0]}: Value for "text-size" is >= ${xA}. Reduce your "text-size".`)):rt.kind==="composite"&&(_t=[tg*ue.compositeTextSizes[0].evaluate(O,{},Le)*ue.textScaleFactor,tg*ue.compositeTextSizes[1].evaluate(O,{},Le)*ue.textScaleFactor],(_t[0]>$y||_t[1]>$y)&&cr(`${f.layerIds[0]}: Value for "text-size" is >= ${xA}. Reduce your "text-size".`)),f.addSymbols(f.text,Xe,_t,B,P,O,J,c,m,W.lineStartIndex,W.lineLength,ce,je,Le,Ge,!1,Ie,Xe.length);for(const ft of ee)ne[ft]=f.text.placedSymbolArray.length-1;return 4*Xe.length}function EO(f){for(const c in f)return f[c];return null}function PO(f,c,m,y,k,E,P,O,B,W,J){let ee,ne,ce,ue;if(ee=J?J.top:P.top,ne=J?J.bottom:P.bottom,ce=J?J.left:P.left,ue=J?J.right:P.right,Jde(P)&&P.collisionPadding){const je=P.collisionPadding;ce-=je[0],ee-=je[1],ue+=je[2],ne+=je[3]}if(B){const je=new rs(ce,ee),Le=new rs(ue,ee),Ie=new rs(ce,ne),Ge=new rs(ue,ne),Xe=Jr(B);let rt=new rs(0,0);W&&(rt=new rs(W[0],W[1])),je._rotateAround(Xe,rt),Le._rotateAround(Xe,rt),Ie._rotateAround(Xe,rt),Ge._rotateAround(Xe,rt),ce=Math.min(je.x,Le.x,Ie.x,Ge.x),ue=Math.max(je.x,Le.x,Ie.x,Ge.x),ee=Math.min(je.y,Le.y,Ie.y,Ge.y),ne=Math.max(je.y,Le.y,Ie.y,Ge.y)}return f.emplaceBack(c.x,c.y,c.z,m.x,m.y,ce,ee,ue,ne,O,y,k,E),f.length-1}function oue(f){Jde(f)&&f.collisionPadding&&(f.top-=f.collisionPadding[1],f.bottom+=f.collisionPadding[3]);const c=f.bottom-f.top;return c>0?Math.max(10,c):null}function qst(f,c,m,y){const k=f.compareText;if(c in k){const E=k[c];for(let P=E.length-1;P>=0;P--)if(y.dist(E[P])Xe&&(rt(ft,bs,It,$t,hs,_s),rt(bs,St,hs,_s,as,Wt))}rt(ee,ne,y,E,k,E),rt(ne,ce,k,E,k,P),rt(ce,ue,k,P,y,P),rt(ue,ee,y,P,y,E),je-=Xe,Le-=Xe,Ie+=Xe,Ge+=Xe;const _t=1/Math.max(Ie-je,Ge-Le);return{scale:_t,x:je*_t,y:Le*_t,x2:Ie*_t,y2:Ge*_t,projection:c}}function dNe(f,{x:c,y:m},y=0){return new rs(((c-y)*f.scale-f.x)*Ys,(m*f.scale-f.y)*Ys)}const Ust=w(new Float32Array(16));class $v{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,y){return{x:c,y:m,z:0}}locationPoint(c,m,y,k=!0){return c._coordinatePoint(c.locationCoordinate(m,y),k)}pixelsPerMeter(c,m){return re(1,c)*m}pixelSpaceConversion(c,m,y){return 1}farthestPixelDistance(c){return cNe(c,c.pixelsPerMeter)}pointCoordinate(c,m,y,k){const E=c.horizonLineFromTop(!1),P=new rs(m,Math.max(E,y));return c.rayIntersectionCoordinate(c.pointRayIntersection(P,k))}pointCoordinate3D(c,m,y){const k=new rs(m,y);if(c.elevation)return c.elevation.pointCoordinate(k);{const E=this.pointCoordinate(c,k.x,k.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 y=c.horizonLineFromTop();return m.y0?m<-DC+y&&(m=-DC+y):m>DC-y&&(m=DC-y);const P=E/Math.pow(LO(m),k);let O=P*Math.sin(k*c),B=E-P*Math.cos(k*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:y,f:k}=this,E=k-m,P=Math.sign(E),O=Math.sign(y)*Math.sqrt(c*c+E*E);let B=Math.atan2(c,Math.abs(E))*P;E*y<0&&(B-=Math.PI*Math.sign(c)*P);const W=Se(Za(B/y)+this.center[0],-180,180),J=Se(Za(2*Math.atan(Math.pow(k/O,1/y))-DC),-xe,xe);return new x(W,this.southernCenter?-J:J)}}class uNe extends $v{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:H(c),y:Q(m),z:0}}unproject(c,m){const y=oe(c),k=ge(m);return new x(y,k)}}const hNe=Jr(xe);class Kst extends $v{project(c,m){const y=(m=Jr(m))*m,k=y*y;return{x:.5*((c=Jr(c))*(.8707-.131979*y+k*(k*(.003971*y-.001529*k)-.013791))/Math.PI+.5),y:1-.5*(m*(1.007226+y*(.015085+k*(.028874*y-.044475-.005916*k)))/Math.PI+1),z:0}}unproject(c,m){c=(2*c-.5)*Math.PI;let y=m=(2*(1-m)-1)*Math.PI,k=25,E=0,P=y*y;do{P=y*y;const W=P*P;E=(y*(1.007226+P*(.015085+W*(.028874*P-.044475-.005916*W)))-m)/(1.007226+P*(.045255+W*(.259866*P-.311325-.005916*11*W))),y=Se(y-E,-hNe,hNe)}while(Math.abs(E)>1e-6&&--k>0);P=y*y;const O=Se(Za(c/(.8707+P*(P*(P*P*P*(.003971-.001529*P)-.013791)-.131979))),-180,180),B=Za(y);return new x(O,B)}}const mNe=Jr(xe);class Zst extends $v{project(c,m){m=Jr(m),c=Jr(c);const y=Math.cos(m),k=2/Math.PI,E=Math.acos(y*Math.cos(c/2)),P=Math.sin(E)/E,O=.5*(c*k+2*y*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 y=c=(2*c-.5)*Math.PI,k=m=(2*(1-m)-1)*Math.PI,E=25;const P=1e-6;let O=0,B=0;do{const W=Math.cos(k),J=Math.sin(k),ee=2*J*W,ne=J*J,ce=W*W,ue=Math.cos(y/2),je=Math.sin(y/2),Le=2*ue*je,Ie=je*je,Ge=1-ce*ue*ue,Xe=Ge?1/Ge:0,rt=Ge?Math.acos(W*ue)*Math.sqrt(1/Ge):0,_t=.5*(2*rt*W*je+2*y/Math.PI)-c,ft=.5*(rt*J+k)-m,St=.5*Xe*(ce*Ie+rt*W*ue*ne)+1/Math.PI,It=Xe*(Le*ee/4-rt*J*je),$t=.125*Xe*(ee*je-rt*J*ce*Le),as=.5*Xe*(ne*ue+rt*Ie*W)+.5,Wt=It*$t-as*St;O=(ft*It-_t*as)/Wt,B=(_t*$t-ft*St)/Wt,y=Se(y-O,-Math.PI,Math.PI),k=Se(k-B,-mNe,mNe)}while((Math.abs(O)>P||Math.abs(B)>P)&&--E>0);return new x(Za(y),Za(k))}}class pNe extends $v{constructor(c){super(c),this.center=c.center||[0,0],this.parallels=c.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Jr(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:y,cosPhi:k}=this;return{x:Jr(c)*k*y+.5,y:-Math.sin(Jr(m))/k*y+.5,z:0}}unproject(c,m){const{scale:y,cosPhi:k}=this,E=-(m-.5)/y,P=Se(Za((c-.5)/y)/k,-180,180),O=Math.asin(Se(E*k,-1,1)),B=Se(Za(O),-xe,xe);return new x(P,B)}}class Yst extends uNe{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,y){const k=GT(c,m,y);return Dt(k,k,nO(Zm(y))),{x:k[0],y:k[1],z:k[2]}}locationPoint(c,m,y){const k=Lv(m.lat,m.lng),E=Ae([],k),P=y?c._centerAltitude+y:c.elevation?c.elevation.getAtPointOrZero(c.locationCoordinate(m),c._centerAltitude):c._centerAltitude;Ke(k,k,E,re(1,0)*Ys*P);const O=w(new Float64Array(16));return C(O,c.pixelMatrix,c.globeMatrix),Dt(k,k,O),new rs(k[0],k[1])}pixelsPerMeter(c,m){return re(1,0)*m}pixelSpaceConversion(c,m,y){const k=re(1,c)*m,E=Vr(re(1,45)*m,k,y);return this.pixelsPerMeter(c,m)/E}createTileMatrix(c,m,y){const k=hde(Zm(y.canonical));return C(new Float64Array(16),c.globeMatrix,k)}createInversionMatrix(c,m){const{center:y}=c,k=nO(Zm(m));return R(k,k,Jr(y.lng)),L(k,k,Jr(y.lat)),I(k,k,[c._pixelsPerMercatorPixel,c._pixelsPerMercatorPixel,1]),Float32Array.from(k)}pointCoordinate(c,m,y,k){return Ov(c,m,y,!0)||new Je(0,0)}pointCoordinate3D(c,m,y){const k=this.pointCoordinate(c,m,y,0);return[k.x,k.y,k.z]}isPointAboveHorizon(c,m){return!Ov(c,m.x,m.y,!1)}farthestPixelDistance(c){const m=function(k,E){const P=k.cameraToCenterDistance,O=k._centerAltitude*E,B=k._camera,W=k._camera.forward(),J=le([],Ne([],W,-P),[0,0,O]),ee=k.worldSize/(2*Math.PI),ne=[0,0,-ee],ce=k.width/k.height,ue=Math.tan(k.fovAboveCenter),je=Ne([],B.up(),ue),Le=Ne([],B.right(),ue*ce),Ie=Ae([],le([],le([],W,je),Le)),Ge=[];let Xe;if(new kr(J,Ie).closestPointOnSphere(ne,ee,Ge)){const rt=le([],Ge,ne),_t=ke([],rt,J);Xe=Math.cos(k.fovAboveCenter)*de(_t)}else{const rt=ke([],J,ne),_t=ke([],ne,J);Ae(_t,_t);const ft=de(rt)-ee;Xe=Math.sqrt(ft*(ft+2*ee));const St=Math.acos(Xe/(ee+ft))-Math.acos(Ue(W,_t));Xe*=Math.cos(St)}return 1.01*Xe}(c,this.pixelsPerMeter(c.center.lat,c.worldSize)),y=Rv(c.zoom);if(y>0){const k=cNe(c,re(1,c.center.lat)*c.worldSize),E=c.worldSize/(2*Math.PI),P=Math.max(c.width,c.height)/c.worldSize*Math.PI;return Vr(m,k+E*(1-Math.cos(P)),Math.pow(y,10))}return m}upVector(c,m,y){return GT(m,y,c,1)}upVectorScale(c){return{metersToTile:Rp(rO(Zm(c)))}}}function fNe(f){const c=f.parallels,m=!!c&&Math.abs(c[0]+c[1])<.01;switch(f.name){case"mercator":return new uNe(f);case"equirectangular":return new Wst(f);case"naturalEarth":return new Kst(f);case"equalEarth":return new Hst(f);case"winkelTripel":return new Zst(f);case"albers":return m?new pNe(f):new Vst(f);case"lambertConformalConic":return m?new pNe(f):new Gst(f);case"globe":return new Yst(f)}throw new Error(`Invalid projection name: ${f.name}`)}const Xst=Vt.types,Qst=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function jA(f,c,m,y,k,E,P,O,B,W,J,ee,ne){const ce=O?Math.min($y,Math.round(O[0])):0,ue=O?Math.min($y,Math.round(O[1])):0;f.emplaceBack(c,m,Math.round(32*y),Math.round(32*k),E,P,(ce<<1)+(B?1:0),0+(ue<<1),16*W,16*J,256*ee,256*ne)}function kA(f,c,m){f.emplaceBack(c,m)}function NA(f,c,m,y,k,E,P){f.emplaceBack(c,m,y,k,E,P)}const DO=(f,c,m,y)=>{for(let k=0;k0&&(this.iconTransitioningVertexBuffer=c.createVertexBuffer(this.iconTransitioningVertexArray,ist.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,sst.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||E)&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,nst.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=c.createVertexBuffer(this.orientationVertexArray,ast.members,!0)),this.opacityVertexBuffer.itemSize=1),(y||k)&&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(lue,"SymbolBuffers");class cue{constructor(c,m,y){this.layoutVertexArray=new c,this.layoutAttributes=m,this.indexArray=new y,this.segments=new uo,this.collisionVertexArray=new PT,this.collisionVertexArrayExt=new hx}upload(c){this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=c.createVertexBuffer(this.collisionVertexArray,ost.members,!0),this.collisionVertexBufferExt=c.createVertexBuffer(this.collisionVertexArrayExt,lst.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}_r(cue,"CollisionBuffers");class OO{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=w([]),this.placementViewportMatrix=w([]);const m=this.layers[0]._unevaluatedLayout._values;this.worldview=c.worldview,this.localizable=c.localizable,this.textSizeData=EC(this.zoom,m["text-size"],this.worldview),this.iconSizeData=EC(this.zoom,m["icon-size"],this.worldview);const y=this.layers[0].layout,k=y.get("symbol-sort-key"),E=y.get("symbol-z-order");this.lut=c.lut,this.canOverlap=y.get("text-allow-overlap")||y.get("icon-allow-overlap")||y.get("text-ignore-placement")||y.get("icon-ignore-placement"),this.sortFeaturesByKey=E!=="viewport-y"&&k.constantOr(1)!==void 0,this.sortFeaturesByY=(E==="viewport-y"||E==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=y.get("text-writing-mode").map(P=>_h[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(y=>y.getProperty(c)!=null)}createArrays(){this.text=new lue(new Gm(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("text")||c.startsWith("symbol"))),this.icon=new lue(new Gm(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("icon")||c.startsWith("symbol"))),this.glyphOffsetArray=new mC,this.lineVertexArray=new QD,this.symbolInstances=new zT}calculateGlyphDependencies(c,m,y,k,E){for(const P of c){const O=P.codePointAt(0);if(O===void 0)break;if(m[O]=!0,k&&E&&O<=65535){const B=hA[P];B&&(m[B.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(c,m,y,k,E,P){let O=1;const B=c.getUnevaluatedProperties()._values["icon-size"],W=EC(this.zoom,B,this.worldview),J=PC(W,m);if(W.kind!=="constant"&&W.kind!=="camera"||(O=J.uSize),W.kind==="composite"){const{minZoom:ee,maxZoom:ne}=W,ce=B.possiblyEvaluate(new Li(ee,{worldview:this.worldview}),k),ue=B.possiblyEvaluate(new Li(ne,{worldview:this.worldview}),k),je=ce.evaluate(y,{},k,E);O=je+(ue.evaluate(y,{},k,E)-je)*J.uSizeT}return W.kind==="source"&&(O=B.possiblyEvaluate(new Li(this.zoom,{worldview:this.worldview}),k).evaluate(y,{},k,E)),O*P}updateFootprints(c,m){}updateReplacement(c,m){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const y=m.getReplacementRegionsForTile(c.toUnwrapped(),!0);return!dO(this.activeReplacements,y)&&(this.activeReplacements=y,!0)}getResolvedImageFromTokens(c){return typeof c=="string"?Yd.build(c):c}populate(c,m,y,k){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,ne]=P.get("icon-size-scale-range"),ce=Se(m.scaleFactor||1,ee,ne),ue=(W.value.kind!=="constant"||W.value.value instanceof Zd&&!W.value.value.isEmpty()||W.value.value.toString().length>0)&&(B.value.kind!=="constant"||B.value.value.length>0),je=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&&!je&&!Le)return;const Ge=m.iconDependencies,Xe=m.glyphDependencies,rt=m.availableImages,_t=new Li(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ft=St=>{const It=St.id.toString();Ge.has(It)?Ge.get(It).push(St):Ge.set(It,[St])};for(const St of c){const{feature:It,id:$t,index:as,sourceLayerIndex:Wt}=St,hs=E._featureFilter.needGeometry,_s=Ht(It,hs);if(!E._featureFilter.filter(_t,_s,y))continue;if(hs||(_s.geometry=Pt(It,y,k)),O&&It.type!==1&&y.z<=5){const Ds=_s.geometry,Xs=.98078528056,qs=(Ir,lr)=>Ue(GT(Ir.x,Ir.y,y,1),GT(lr.x,lr.y,y,1)){if(!Ds.getProperty("icon-image"))return;const Xs=this.getCombinedIconPrimary(Ds,Fs,_s,y,rt,us,ce);Xs&&ft(Xs)}),bs){const Ds=B.evaluate(_s,{},y).join(","),Xs=P.get("text-rotation-alignment")==="map"&&P.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(_h.vertical)>=0;for(const qs of bs.sections)if(qs.image){const Ir=qs.image.getPrimary().scaleSelf(this.pixelRatio),lr=Ir.id.toString(),gr=Ge.get(lr)||[];gr.push(Ir),Ge.set(lr,gr)}else{const Ir=bb(bs.toString()),lr=qs.fontStack||Ds,gr=Xe[lr]=Xe[lr]||{};this.calculateGlyphDependencies(qs.text,gr,Xs,this.allowVerticalPlacement,Ir)}}}if(P.get("symbol-placement")==="line"&&(this.features=function(St){const It={},$t={},as=[];let Wt=0;function hs(Fs){as.push(St[Fs]),Wt++}function _s(Fs,Ps,Ls){const us=$t[Fs];return delete $t[Fs],$t[Ps]=us,as[us].geometry[0].pop(),as[us].geometry[0]=as[us].geometry[0].concat(Ls[0]),us}function bs(Fs,Ps,Ls){const us=It[Ps];return delete It[Ps],It[Fs]=us,as[us].geometry[0].shift(),as[us].geometry[0]=Ls[0].concat(as[us].geometry[0]),us}function Os(Fs,Ps,Ls){const us=Ls?Ps[0][Ps[0].length-1]:Ps[0][0];return`${Fs}:${us.x}:${us.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 St of m.elevationFeatures)this.elevationFeatureIdToIndex.set(St.id,this.elevationFeatures.length),this.elevationFeatures.push(St)}}else P.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((St,It)=>St.sortKey-It.sortKey)}getCombinedIconPrimary(c,m,y,k,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",y,k,E);B=this.getResolvedImageFromTokens(ee)}else{const ee=m.getValueAndResolveTokens("icon-image",y,k,E);B=this.getResolvedImageFromTokens(ee)}if(B){const ee=J._values["icon-size"]||m._unevaluatedLayout._values["icon-size"];W=gA(B,EC(this.zoom,ee,this.worldview),ee,k,this.zoom,P,this.pixelRatio,O,this.worldview).iconPrimary}return W}updateAppearanceBasedIconTextures(c,m,y,k){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=Se(1,W,J);for(let ne=0;ne=0){const Le=je.id,Ie=m&&Le!==void 0?m[String(Le)]:void 0,Ge={type:"Point",id:je.id,properties:je.properties,geometry:[]},Xe=this.layers[0].appearances&&this.layers[0].appearances.find(rt=>rt.isActive({globals:k,feature:Ge,canonical:c,featureState:Ie}));if(je.activeAppearance===Xe){O+=ce.numIconVertices;continue}if(Xe){je.activeAppearance=Xe;const rt=this.getCombinedIconPrimary(Xe,E,Ge,c,y,{sortKey:void 0,text:void 0,icon:null,index:ce.featureIndex,sourceLayerIndex:ce.featureIndex,geometry:[],properties:je.properties,type:"Point",id:je.id},ee);if(!rt)continue;const _t=rt.toString(),ft=this.iconAtlasPositions&&this.iconAtlasPositions.get(_t);if(ft){const St=E.getAppearanceValueAndResolveTokens(Xe,"icon-offset",Ge,c,y),It=St&&Array.isArray(St)?St:[0,0];let $t=SO(ft,void 0,It,E.layout.get("icon-anchor").evaluate(Ge,{},c));const as=E.getAppearanceValueAndResolveTokens(Xe,"icon-rotate",Ge,c,y),Wt=typeof as=="number"?as:0,hs=ft.sdf,_s=E.layout.get("icon-text-fit").constantOr("none");_s!=="none"&&je.textShaping&&je.iconTextFitPadding&&je.fontScale&&($t=eue($t,je.textShaping,_s,je.iconTextFitPadding,It,je.fontScale));const bs=this.calculateEffectiveAppearanceIconSize(Xe,k.zoom,Ge,c,y,ee),Os=0,Fs=1+(Math.min($y,Math.round(bs*tg))<<1),Ps=nue($t,Wt,hs,_s!=="none",ee);je.isUsingAppearanceVertexData||(je.isUsingAppearanceVertexData=!0,je.layoutBasedVertexData=this.icon.getIconVertexData(O,ce.numIconVertices));for(let us=0;us0&&(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,je.activeAppearance=null;else if(je.isUsingAppearanceVertexData){const _t=je.layoutBasedVertexData.length/12;for(let ft=0;ft<_t;++ft){const St=ft*12;this.icon.updateIconVertexData(O+ft,je.layoutBasedVertexData[St+0],je.layoutBasedVertexData[St+1],je.layoutBasedVertexData[St+2],je.layoutBasedVertexData[St+3],je.layoutBasedVertexData[St+4],je.layoutBasedVertexData[St+5],je.layoutBasedVertexData[St+6],je.layoutBasedVertexData[St+7],je.layoutBasedVertexData[St+8],je.layoutBasedVertexData[St+9],je.layoutBasedVertexData[St+10],je.layoutBasedVertexData[St+11])}O+=_t,je.isUsingAppearanceVertexData=!1,je.activeAppearance=null,P=!0}else O+=ce.numIconVertices,je.activeAppearance=null}}return P}update(c,m,y,k,E,P,O){this.text.programConfigurations.updatePaintArrays(c,m,E,y,k,P,O,this.worldview),this.icon.programConfigurations.updatePaintArrays(c,m,E,y,k,P,O,this.worldview)}updateRoadElevation(c){if(this.elevationType!=="road"||!this.elevationFeatures||this.elevationStateComplete)return;this.elevationStateComplete=!0,this.hasAnyZOffset=!1;let m=!1;const y=Be(c),k=1/y;let E=!1,P=!1;for(let O=0;O0||ne>0,Le=ce>0,Ie=this.elevationFeatures[B.elevationFeatureIndex];if(Ie){const Ge=new rs(B.tileAnchorX,B.tileAnchorY),Xe=.075+Ie.pointElevation(Ge);B.zOffset!==Xe&&(m=!0,B.zOffset=Xe),Xe!==0&&(this.hasAnyZOffset=!0);const rt=Ie.computeSlopeNormal(Ge,k),_t=fs(Ze(),ie(0,0,1),rt);Ve(W,W,_t),Ve(J,J,_t),W[2]*=y,J[2]*=y,W[0]===1&&W[1]===0&&W[2]===0&&J[0]===0&&J[1]===1&&J[2]===0||(E=E||je,P=P||Le)}if(je&&(DO(this.text.orientationVertexArray,ee,W,J),DO(this.text.orientationVertexArray,ne,W,J)),Le){const{placedIconSymbolIndex:Ge,verticalPlacedIconSymbolIndex:Xe}=B;Ge>=0&&DO(this.icon.orientationVertexArray,ce,W,J),Xe>=0&&DO(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)=>{y+=P,y>E.length&&E.resize(y);for(let B=-P;B<0;B++)E.emplace(B+y,O)},m=(E,P,O)=>{k+=P,k>E.length&&E.resize(k);for(let B=-P;B<0;B++)E.emplace(B+k,O)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let y=0,k=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:ne,verticalPlacedIconSymbolIndex:ce}=P;ne>=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,y,k,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,y,k){return!!(c&&m&&y)&&!(!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(c,m,y,k)&&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=fNe(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(c,m){const y=this.lineVertexArray.length;if(c.segment!==void 0)for(const{x:k,y:E}of m)this.lineVertexArray.emplaceBack(k,E);return{lineStartIndex:y,lineLength:this.lineVertexArray.length-y}}addSymbols(c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je,Le,Ie,Ge){const Xe=c.indexArray,rt=c.layoutVertexArray,_t=c.globeExtVertexArray,ft=c.segments.prepareSegment(4*Ge,rt,Xe,this.canOverlap?P.sortKey:void 0),St=this.glyphOffsetArray.length,It=ft.vertexLength,$t=this.allowVerticalPlacement&&O===_h.vertical?Math.PI/2:0,as=P.text&&P.text.sections;for(let _s=0;_s=0?m.rightJustifiedTextSymbolIndex:m.centerJustifiedTextSymbolIndex>=0?m.centerJustifiedTextSymbolIndex:m.leftJustifiedTextSymbolIndex>=0?m.leftJustifiedTextSymbolIndex:m.verticalPlacedTextSymbolIndex>=0?m.verticalPlacedTextSymbolIndex:k),P=tue(this.textSizeData,c,E)/ac;return this.tilePixelRatio*P}getSymbolInstanceIconSize(c,m,y){const k=this.icon.placedSymbolArray.get(y),E=tue(this.iconSizeData,c,k);return this.tilePixelRatio*E}_commitDebugCollisionVertexUpdate(c,m,y,k){c.emplaceBack(m,-y,-y,k),c.emplaceBack(m,y,-y,k),c.emplaceBack(m,y,y,k),c.emplaceBack(m,-y,y,k)}_updateTextDebugCollisionBoxes(c,m,y,k,E,P,O){for(let B=k;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 y=c.placedSymbolArray.get(m),k=y.vertexStartIndex+4*y.numGlyphs;for(let E=y.vertexStartIndex;Ek[O]-k[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 y=this.sortKeyRanges[this.sortKeyRanges.length-1];y&&y.sortKey===m?y.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 y=this.symbolInstances.get(m);this.featureSortOrder.push(y.featureIndex);const{rightJustifiedTextSymbolIndex:k,centerJustifiedTextSymbolIndex:E,leftJustifiedTextSymbolIndex:P,verticalPlacedTextSymbolIndex:O,placedIconSymbolIndex:B,verticalPlacedIconSymbolIndex:W}=y;k>=0&&this.addIndicesForPlacedSymbol(this.text,k),E>=0&&E!==k&&this.addIndicesForPlacedSymbol(this.text,E),P>=0&&P!==E&&P!==k&&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 y;return this.elevationFeatures&&my in f?String(f[y]):"")}let xNe,yNe,due;_r(OO,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),OO.addDynamicAttributes=OC;class vNe{constructor(c){this.type=c.property.overrides?c.property.overrides.runtimeType:qm,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(vNe,"FormatSectionOverride",{omit:["defaultValue"]});const uue=()=>due||(due={layout:xNe||(xNe=new bo({"symbol-placement":new Vs(Gt.layout_symbol["symbol-placement"]),"symbol-spacing":new Vs(Gt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Vs(Gt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new rr(Gt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Vs(Gt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Vs(Gt.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Vs(Gt.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Vs(Gt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Vs(Gt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Vs(Gt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Vs(Gt.layout_symbol["icon-rotation-alignment"]),"icon-size":new rr(Gt.layout_symbol["icon-size"]),"icon-size-scale-range":new Vs(Gt.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new rr(Gt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new rr(Gt.layout_symbol["icon-text-fit-padding"]),"icon-image":new rr(Gt.layout_symbol["icon-image"]),"icon-image-use-theme":new Vs({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new rr(Gt.layout_symbol["icon-rotate"]),"icon-padding":new Vs(Gt.layout_symbol["icon-padding"]),"icon-keep-upright":new Vs(Gt.layout_symbol["icon-keep-upright"]),"icon-offset":new rr(Gt.layout_symbol["icon-offset"]),"icon-anchor":new rr(Gt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Vs(Gt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Vs(Gt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Vs(Gt.layout_symbol["text-rotation-alignment"]),"text-field":new rr(Gt.layout_symbol["text-field"]),"text-font":new rr(Gt.layout_symbol["text-font"]),"text-size":new rr(Gt.layout_symbol["text-size"]),"text-size-scale-range":new Vs(Gt.layout_symbol["text-size-scale-range"]),"text-max-width":new rr(Gt.layout_symbol["text-max-width"]),"text-line-height":new rr(Gt.layout_symbol["text-line-height"]),"text-letter-spacing":new rr(Gt.layout_symbol["text-letter-spacing"]),"text-justify":new rr(Gt.layout_symbol["text-justify"]),"text-radial-offset":new rr(Gt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Vs(Gt.layout_symbol["text-variable-anchor"]),"text-anchor":new rr(Gt.layout_symbol["text-anchor"]),"text-max-angle":new Vs(Gt.layout_symbol["text-max-angle"]),"text-writing-mode":new Vs(Gt.layout_symbol["text-writing-mode"]),"text-rotate":new rr(Gt.layout_symbol["text-rotate"]),"text-padding":new Vs(Gt.layout_symbol["text-padding"]),"text-keep-upright":new Vs(Gt.layout_symbol["text-keep-upright"]),"text-transform":new rr(Gt.layout_symbol["text-transform"]),"text-offset":new rr(Gt.layout_symbol["text-offset"]),"text-allow-overlap":new Vs(Gt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Vs(Gt.layout_symbol["text-ignore-placement"]),"text-optional":new Vs(Gt.layout_symbol["text-optional"]),visibility:new Vs(Gt.layout_symbol.visibility)})),paint:yNe||(yNe=new bo({"icon-opacity":new rr(Gt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new rr(Gt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new rr(Gt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new rr(Gt.paint_symbol["text-emissive-strength"]),"icon-color":new rr(Gt.paint_symbol["icon-color"]),"icon-halo-color":new rr(Gt.paint_symbol["icon-halo-color"]),"icon-halo-width":new rr(Gt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new rr(Gt.paint_symbol["icon-halo-blur"]),"icon-translate":new Vs(Gt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Vs(Gt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Vs(Gt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new rr(Gt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new rr(Gt.paint_symbol["text-occlusion-opacity"]),"text-color":new rr(Gt.paint_symbol["text-color"],{runtimeType:ju,getOverride:f=>f.textColor,hasOverride:f=>!!f.textColor}),"text-halo-color":new rr(Gt.paint_symbol["text-halo-color"]),"text-halo-width":new rr(Gt.paint_symbol["text-halo-width"]),"text-halo-blur":new rr(Gt.paint_symbol["text-halo-blur"]),"text-translate":new Vs(Gt.paint_symbol["text-translate"]),"text-translate-anchor":new Vs(Gt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Vs(Gt.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Vs(Gt.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Vs(Gt.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Vs(Gt.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new rr(Gt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"})}))},due);class RO extends Jd{constructor(c,m,y,k){super(c,uue(),m,y,k,c.layout?c.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=w([]),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(k=>{k.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 y=this.layout.get("text-writing-mode");if(y){const k=[];for(const E of y)k.indexOf(E)<0&&k.push(E);this.layout._values["text-writing-mode"]=k}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(c,m,y,k){return this._saturation===c&&this._contrast===m&&this._brightnessMin===y&&this._brightnessMax===k||(this._colorAdjustmentMatrix=function(E,P,O,B){E=Qi(E),P=_a(P);const W=b(),J=E/3,ee=1-2*J,ne=[ee,J,J,0,J,ee,J,0,J,J,ee,0,0,0,0,1],ce=.5-.5*P,ue=B-O;return C(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]),C(W,W,ne),W}(c,m,y,k),this._saturation=c,this._contrast=m,this._brightnessMin=y,this._brightnessMax=k),this._colorAdjustmentMatrix}getValueAndResolveTokens(c,m,y,k){const E=this.layout.get(c).evaluate(m,{},y,k),P=this._unevaluatedLayout._values[c];return P.isDataDriven()||vb(P.value)||!E?E:gNe(m.properties,E)}getAppearanceValueAndResolveTokens(c,m,y,k,E){const P=c.getProperty(m);if(!P)return;const O=P.evaluate(y,{},k,E),B=c.getUnevaluatedProperties()._values[m];return B.isDataDriven()||vb(B.value)||!O||typeof O!="string"?O:gNe(y.properties,O)}createBucket(c){return new OO(c)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const c of uue().paint.overridableProperties){if(!RO.hasPaintOverride(this.layout,c))continue;const m=this.paint.get(c),y=new vNe(m),k=new US(y,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 Nv("source",k):new My("composite",k,m.value.zoomStops,m.value.interpolationType),this.paint._values[c]=new Ay(m.property,E,m.parameters)}}_handleOverridablePaintPropertyUpdate(c,m,y){return!(!this.layout||m.isDataDriven()||y.isDataDriven())&&RO.hasPaintOverride(this.layout,c)}static hasPaintOverride(c,m){const y=c.get("text-field"),k=uue().paint.properties[m];let E=!1;const P=O=>{for(const B of O)if(k.overrides&&k.overrides.hasOverride(B))return void(E=!0)};if(y.value.kind==="constant"&&y.value.value instanceof Zd)P(y.value.value.sections);else if(y.value.kind==="source"){const O=W=>{E||(W instanceof zf&&nc(W.value)===nb?P(W.value.sections):W instanceof Tp?P(W.sections):W.eachChild(O))},B=y.value;B._styleExpression&&O(B._styleExpression.expression)}return E}getProgramIds(){return["symbol"]}getDefaultProgramParams(c,m,y){return{config:new px(this,{zoom:m,lut:y}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let _Ne,bNe,wNe,jNe;var hue=na([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function FO(f,c,m,y,k,E,P,O){const B=[f,c,1,m,y,1,k,E,1],W=[P,O,1],J=v([],B),[ee,ne,ce]=he(W,W,J);return _(B,B,[ee,0,0,0,ne,0,0,0,ce])}function kNe(f,c,m,y,k,E,P,O){const B=function(W,J,ee,ne,ce,ue,je,Le){const Ie=FO(0,0,1,0,1,1,0,1),Ge=FO(W,J,ee,ne,ce,ue,je,Le);return _(Ge,Ge,v([],Ie))}(f,c,m,y,k,E,P,O);return[B[2]/B[8]/Ys,B[5]/B[8]/Ys]}function zO(f){return[f[0],Math.min(Math.max(f[1],-xe),xe)]}class NNe extends Ts{constructor(c,m,y,k){super(),this.id=c,this.dispatcher=y,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(k),this.options=m,this._dirty=!1}load(c,m){if(this._loaded=m||!1,this.fire(new tm("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return c&&(this.coordinates=c),this._loaded=!0,void this._finishLoading();this._imageRequest=Qg(this.map._requestManager.transformRequest(this.url,Df.Image),(y,k)=>{this._imageRequest=null,this._loaded=!0,y?this.fire(new Jg(y)):k&&(this.image=k instanceof HTMLImageElement?yl.getImageData(k):k,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 cA(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 tm("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 cA||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],y=c[0][1];for(const E of c)E[1]>y&&(y=E[1]),E[1]xe?this.onNorthPole=!0:k<-xe&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const E=c.map(Je.fromLngLat);this.tileID=function(P){let O=1/0,B=1/0,W=-1/0,J=-1/0;for(const je of P)O=Math.min(O,je.x),B=Math.min(B,je.y),W=Math.max(W,je.x),J=Math.max(J,je.y);const ee=Math.max(W-O,J-B),ne=Math.max(0,Math.floor(-Math.log2(ee))),ce=Math.pow(2,ne);let ue=Math.floor((O+W)/2*ce);return ue>1&&(ue-=1),new ji(ne,ue,Math.floor((B+J)/2*ce))}(E),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new tm("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof cA||(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 Ge=this.tiles[Ie];Ge.state!=="loaded"&&(Ge.state="loaded",Ge.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const m=yA(new ji(0,0,0),this.map.transform.projection),y=[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 Ge=Ie[1].x-Ie[0].x,Xe=Ie[1].y-Ie[0].y,rt=Ie[2].x-Ie[1].x,_t=Ie[2].y-Ie[1].y,ft=Ie[3].x-Ie[2].x,St=Ie[3].y-Ie[2].y,It=Ie[0].x-Ie[3].x,$t=Ie[0].y-Ie[3].y,as=Ge*_t-rt*Xe,Wt=rt*St-ft*_t,hs=ft*$t-It*St,_s=It*Xe-Ge*$t;return as>0&&Wt>0&&hs>0&&_s>0||as<0&&Wt<0&&hs<0&&_s<0}(y))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const k=yA(this.tileID,this.map.transform.projection),[E,P,O,B]=this.coordinates.map(Ie=>{const Ge=k.projection.project(Ie[0],Ie[1]);return dNe(k,Ge)._round()});this.perspectiveTransform=kNe(E.x,E.y,P.x,P.y,O.x,O.y,B.x,B.y);const W=this._boundsArray=new Tv;W.emplaceBack(E.x,E.y,0,0),W.emplaceBack(P.x,P.y,Ys,0),W.emplaceBack(B.x,B.y,0,Ys),W.emplaceBack(O.x,O.y,Ys,Ys),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=c.createVertexBuffer(W,hue.members),this.boundsSegments=uo.simpleSegment(0,0,4,2);const J=[],ee=[zO((ne=this.coordinates)[0]),zO(ne[1]),zO(ne[2]),zO(ne[3])];var ne;const[ce,ue,je,Le]=function(Ie){let Ge=Ie[0][0],Xe=Ge,rt=Ie[0][1],_t=rt;for(let ft=1;ftXe&&(Xe=Ie[ft][0]),Ie[ft][1]_t&&(_t=Ie[ft][1]);return[Ge,rt,Xe-Ge,_t-rt]}(ee);{const Ie=new Tv,[Ge,Xe,rt,_t]=function(Ps){let Ls=Ps[0].x,us=Ls,is=Ps[0].y,Ds=is;for(let Xs=1;Xsus&&(us=Ps[Xs].x),Ps[Xs].yDs&&(Ds=Ps[Xs].y);return[Ls,is,us-Ls,Ds-is]}(y),ft=Ps=>[(Ps.x-Ge)/rt,(Ps.y-Xe)/_t],[St,It,$t,as]=y.map(ft),Wt=function(Ps,Ls,us,is,Ds,Xs,qs,Ir){const lr=FO(0,0,1,0,1,1,0,1);return _(lr,lr,v([],FO(Ps,Ls,us,is,Ds,Xs,qs,Ir)))}(St[0],St[1],It[0],It[1],$t[0],$t[1],as[0],as[1]);this.elevatedGlobePerspectiveTransform=kNe(St[0],St[1],It[0],It[1],$t[0],$t[1],as[0],as[1]);const hs=(Ps,Ls)=>{J.push(Ps.lng);const us=Math.round((Ps.lng-ce)/je*Ys),is=Math.round((Ps.lat-ue)/Le*Ys),Ds=ft(Ls),Xs=he([],[Ds[0],Ds[1],1],Wt),qs=Math.round(Xs[0]/Xs[2]*Ys),Ir=Math.round(Xs[1]/Xs[2]*Ys);Ie.emplaceBack(us,is,qs,Ir)},_s=y[3].x-y[0].x,bs=y[3].y-y[0].y,Os=y[2].x-y[1].x,Fs=y[2].y-y[1].y;for(let Ps=0;Ps<65;Ps++){const Ls=Ps/64,us=[y[0].x+Ls*_s,y[0].y+Ls*bs],is=[y[1].x+Ls*Os,y[1].y+Ls*Fs],Ds=is[0]-us[0],Xs=is[1]-us[1];for(let qs=0;qs<65;qs++){const Ir=qs/64,lr={x:us[0]+Ds*Ir,y:us[1]+Xs*Ir};hs(m.projection.unproject(lr.x,lr.y),lr)}}this.elevatedGlobeVertexBuffer=c.createVertexBuffer(Ie,hue.members)}{this.maxLongitudeTriangleSize=0;let Ie=[],Ge=new vl;const Xe=(rt,_t,ft)=>{Ge.emplaceBack(rt,_t,ft);const St=J[rt],It=J[_t],$t=J[ft],as=Math.min(Math.min(St,It),$t),Wt=Math.max(Math.max(St,It),$t)-as;Wt>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Wt),Ie.push(as+Wt/2)};for(let rt=0;rt<64;rt++)for(let _t=0;_t<64;_t++){const ft=65*rt+_t,St=ft+1,It=ft+65,$t=It+1;Xe(ft,It,St),Xe(St,It,$t)}[Ie,Ge]=function(rt,_t){const ft=Array.from({length:rt.length},($t,as)=>as);ft.sort(($t,as)=>rt[$t]-rt[as]);const St=[],It=new vl;for(let $t=0;$t{P.segments.push({vertexOffset:0,primitiveOffset:ee,vertexLength:m.segments[0].vertexLength,primitiveLength:ne,sortKey:void 0,vaos:{}})},B=.51*this.maxLongitudeTriangleSize;if(Math.abs(y[0]-k)<=B){const ee=Xi(y,0,y.length,k+B);return ee===y.length||O(ee,Wo(y,ee+1,y.length,k+360-B)-ee),P}kYs?k-Ys:k,new rs(Math.trunc(k),Math.trunc(y[m+1]))}translationForInstance(c){const m=16*c,y=this.instancedDataArray.float32;return[y[m+4],y[m+5],y[m+6]]}rotationScaleForInstance(c){const m=16*c,y=this.instancedDataArray.float32;return[y[m+7],y[m+8],y[m+9],y[m+10],y[m+11],y[m+12],y[m+13],y[m+14],y[m+15]]}transformForInstance(c){const m=16*c,y=this.instancedDataArray.float32;return[y[m+7],y[m+8],y[m+9],y[m+4],y[m+10],y[m+11],y[m+12],y[m+5],y[m+13],y[m+14],y[m+15],y[m+6],0,0,0,1]}}class fue{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,y,k){}populate(c,m,y,k){this.tileToMeter=Be(y);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 Li(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ee,y))continue;const ne={id:J,sourceLayerIndex:W,index:B,geometry:E?ee.geometry:Pt(P,y,k),properties:P.properties,type:P.type,patterns:{}},ce=this.addFeature(ne,ne.geometry,ee);ce&&m.featureIndex.insert(P,ne.geometry,B,W,this.index,this.instancesPerModel[ce].instancedDataArray.length,Ys/32)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const c=this.layers[0].modelManager,m=this.layers[0].scope;let y=0;for(const k of this.modelUris){const E=c.getModel(k,m);if(!E)continue;const P=this.instancesPerModel[k];if(P){const O=.5*_e(E.aabb.max,E.aabb.min)*P.maxScale+P.maxXYTranslationDistance,B=Math.min(Ys,Math.max(O/this.tileToMeter,Ys/32));y=Math.max(B,y)}}return y}update(c,m,y,k){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 y=this.instancesPerModel[m];for(const k of y.features){const E=this.layers[0],P=k.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);Qe(k.rotation,B)&&Qe(k.scale,W)&&Qe(k.translation,J)||(this.evaluate(k,k.featureStates,y,!0),c=!0)}}return c}updateReplacement(c,m,y,k){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const E=m.getReplacementRegionsForTile(c.toUnwrapped(),!0);if(dO(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,ne=J.instancedDataCount;for(let ce=0;ceYs;je=Le?je-Ys:je;const Ie=Math.floor(je),Ge=Math.floor(W.float32[ue+1]);let Xe=!1;for(const rt of this.activeReplacements)if(!bje(rt,y,INe.Model,k)&&!(rt.min.x>Ie||Ie>rt.max.x||rt.min.y>Ge||Ge>rt.max.y)&&(Xe=Sje(Nje(Ie,Ge,c.canonical,rt.footprintTileId.canonical),rt.footprint),Xe))break;W.float32[ue]=Xe?je+Ys:je,P=P||Xe!==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 y=this.instancesPerModel[m];y.instancedDataArray.length<0||y.instancedDataArray.length===0||(y.instancedDataBuffer?y.instancedDataBuffer.updateData(y.instancedDataArray):y.instancedDataBuffer=c.createVertexBuffer(y.instancedDataArray,ktt.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(c){for(const y in this.instancesPerModel){const k=this.instancesPerModel[y];k.instancedDataArray.length!==0&&k.instancedDataBuffer&&k.instancedDataBuffer.destroy()}const m=this.layers[0].modelManager;if(c&&m&&this.modelUris&&this.modelsRequested)for(const y of this.modelUris)m.removeModel(y,"",!0)}addFeature(c,m,y){const k=this.layers[0],E=k.layout.get("model-id").evaluate(y,{},this.canonical);if(!E)return cr(`modelId is not evaluated for layer ${k.id} and it is not going to get rendered.`),E;(pue(E,!1)||this.styleDefinedModelURLs[E]!==void 0)&&(this.modelUris.includes(E)||this.modelUris.push(E)),this.instancesPerModel[E]||(this.instancesPerModel[E]=new DNe);const P=this.instancesPerModel[E],O=P.instancedDataArray,B=new LNe(y,O.length);for(const W of m)for(const J of W){if(J.x<0||J.x>=Ys||J.y<0||J.y>=Ys)continue;if(this.lookupDim!==0){const ne=(this.lookupDim-1)/Ys,ce=this.lookupDim*(J.y*ne|0)+J.x*ne|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,y,k){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 ne=[];this.maxVerticalOffset0?Math.sqrt(ce):0;y.maxScale=Math.max(Math.max(y.maxScale,W[0]),Math.max(W[1],W[2])),y.maxXYTranslationDistance=Math.max(y.maxXYTranslationDistance,ue),this.maxScale=Math.max(Math.max(this.maxScale,W[0]),Math.max(W[1],W[2])),hke(ne,B,W);const je=Math.round(100*ee.a)+ee.b/1.05;for(let Le=0;Le10?this.tileToMeter:Be(O,_t)),Xe[Ge+4]=J[0],Xe[Ge+5]=J[1],Xe[Ge+6]=J[2]+rt,Xe[Ge+7]=ne[0],Xe[Ge+8]=ne[1],Xe[Ge+9]=ne[2],Xe[Ge+10]=ne[4],Xe[Ge+11]=ne[5],Xe[Ge+12]=ne[6],Xe[Ge+13]=ne[8],Xe[Ge+14]=ne[9],Xe[Ge+15]=ne[10],y.instancesEvaluatedElevation[Ie]=J[2]}}}let ONe,RNe;_r(fue,"ModelBucket",{omit:["layers"]}),_r(DNe,"PerModelAttributes"),_r(LNe,"ModelFeature");class RC{constructor(c,m,y){this._demTile=c,this._dem=this._demTile.dem,this._scale=m,this._offset=y}static create(c,m,y){const k=y||c.findDEMTileFor(m);if(!k||!k.dem)return;const E=k.dem,P=k.tileID,O=1<W.fqid),this.stateDependentLayerIds=this.layers.filter(W=>W.isStateDependent()).map(W=>W.id),this.modelTraits|=MC.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,k&&(this.modelTraits|=MC.HasMapboxMeshFeatures),E&&(this.modelTraits|=MC.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 $Ne(W)),zNe(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 y of this.getNodesInfo()){const k=y.node;k.footprint&&m.push({footprint:k.footprint,id:c})}}updateAppearances(c,m,y,k){}update(c){const m=Object.keys(c).length!==0;if(m&&!this.stateDependentLayers.length)return;const y=m?this.stateDependentLayers:this.layers;if(!Ln(c,this.states))for(const k of y)this.evaluate(k,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 y of m){const k=y.node;this.uploaded?this.updatePbrBuffer(k):Bde(k,c,!0)}for(const y of m)wO(y.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(c){let m=!1;if(!c.meshes)return m;for(const y of c.meshes)y.pbrBuffer&&(y.pbrBuffer.updateData(y.featureArray),m=!0);return m}needsReEvaluation(c,m,y){const k=c.transform.projectionOptions,E=c.style.getBrightness(),P=this.brightness!==E;if(!this.uploaded||this.dirty||k.name!==this.projection.name||SA(y.paint.get("model-color").value,P)||SA(y.paint.get("model-color-mix-intensity").value,P)||SA(y.paint.get("model-roughness").value,P)||SA(y.paint.get("model-emissive-strength").value,P)||SA(y.paint.get("model-height-based-emissive-strength-multiplier").value,P)){this.projection=k,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 y=this.getNodesInfo(),k=this.id.canonical;for(const E of y){const P=E.feature;E.evaluatedTranslation=m.paint.get("model-translation").evaluate(P,{},k),E.evaluatedScale=m.paint.get("model-scale").evaluate(P,{},k)}}evaluate(c,m){const y=this.getNodesInfo();for(const k of y){if(!k.node.meshes)continue;const E=k.feature,P=m&&m[E.id];if(Ln(P,k.state))continue;k.state=structuredClone(P);const O=k.node.meshes&&k.node.meshes[0].featureData,B=k.evaluatedColor[2],W=k.evaluatedRMEA[2],J=this.id.canonical;if(k.hasTranslucentParts=!1,O){for(let ee=0;ee=ft)continue;const Ps=gue[Fs],Ls=Math.abs(Ps);Ls>Wt&&(as=Ps,Wt=Ls,hs=Os,_s=bs)}if(Wt>.1){const bs=1-(ft+.5*Math.abs(hs*_s))/ue;let Os=m._dem.get(It,St)+as*bs;const Fs=m._dem.get(It+hs,St+_s),Ps=m._dem.get(It-hs,St-_s,!0);(Os-Fs)*(Os-Ps)>0&&(Os=(Fs+Ps)/2),gue[$t]=m._dem.set(It,St,Os),$b[$t]=ft}}}}}O&&(m._demTile.needsDEMTextureUpload=!0,m._dem._timestamp=yl.now())}setFilter(c){this.filter=c?QS(c):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(c=>this.filter.filter(new Li(this.id.overscaledZ,{worldview:this.worldview}),c.feature,this.id.canonical)):this.nodesInfo}destroy(){const c=this.getNodesInfo();for(const m of c)wO(m.node),$de(m.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(c,m){if(m.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=m.updateTime;const y=m.getReplacementRegionsForTile(c.toUnwrapped());for(const k of this.getNodesInfo()){const E=k.node.footprint;k.hiddenByReplacement=!!E&&!y.find(P=>P.footprint===E)}}getHeightAtTileCoord(c,m){const y=[],k=[0,0,0],E=w([]);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]};N(E,P.node.globalMatrix),k[0]=c,k[1]=m,Dt(k,k,E);const W=(k[0]-O.aabb.min[0])/(O.aabb.max[0]-O.aabb.min[0])*Fb|0,J=Math.min(63,(k[1]-O.aabb.min[1])/(O.aabb.max[1]-O.aabb.min[1])*Fb|0)*Fb+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 rs(c,m),new rs(c,m),y),y.length>0)return{height:void 0,maxHeight:P.feature.properties.height,hidden:P.hiddenByReplacement,verticalScale:P.evaluatedScale[2]}}}}function SA(f,c){return f instanceof Nv&&!f.isLightConstant&&c}function srt(f,c,m,y,k,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=Vr(B,255*m[0],m[3]),W=Vr(W,255*m[1],m[3]),J=Vr(J,255*m[2],m[3]));const ee=B<<8|W,ne=J<<8|Math.floor(255*y[3]),ce=function(ft){const St=Se(ft,0,2);return Math.min(Math.round(.5*St*255),255)}(y[2])<<8|15*y[0]<<4|15*y[1],ue=Se(k[0],0,1),je=Se(k[1],0,1),Le=Se(k[2],0,1),Ie=Se(k[3],0,1);let Ge,Xe,rt,_t;if(ue!==je&&P!==E&&je!==ue){const ft=P-E;Xe=1/(ft*(je-ue)),rt=-(E+ft*ue)/(ft*(je-ue));const St=Se(k[4],-1,1);_t=Math.pow(10,St),Ge=255*Le<<8|255*Ie}else Ge=65535,Xe=0,rt=1,_t=1;if(f.emplaceBack(ee,ne,ce,Ge,Xe,rt,_t),O){const ft=O.length;O.clear();for(let St=0;St>16&65535,J=E?B>>16&65535:65535&B,ee=(15&J)<8?15&J:0,ne=f.evaluatedRMEA[ee],ce=f.evaluatedColor[ee],ue=f.emissionHeightBasedParams[ee];let je;if(O&&ee===2&&y.lights&&(je=new cC,je.resize(10*y.lights.length)),srt(P.featureArray,W,ce,ne,ue,P.aabb.min[2],P.aabb.max[2],je),je&&O){O=!1;const Le=y.meshes[y.lightMeshIndex];Le.featureArray=je,Le.featureArray._trim()}}P.featureArray._trim(),k++}}_r($O,"Tiled3dModelBucket",{omit:["layers"]}),_r($Ne,"Tiled3dModelFeature");const nrt=["id","tile","layer","source","sourceLayer","state"];class qb{constructor(c,m,y,k,E){this.type="Feature",this._vectorTileFeature=c,this._z=m,this._x=y,this._y=k,this.properties=c?c.properties:{},this.id=E}clone(){const c=new qb(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 nrt)this[m]!==void 0&&(c[m]=this[m]);return c}}class Ub extends Ts{constructor(c,m,y,k){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 y=this._options.models[m],k=this._modelsInfo.get(m);if(k){const E=k.model;E.position=y.position!=null?new x(y.position[0],y.position[1]):new x(0,0),E.orientation=y.orientation!=null?y.orientation:[0,0,0],k.modelSpec=y,Ub.applyModelSpecification(E,y),E.computeBoundsAndApplyParent(),this.models.push(E)}else{const E=lke(this.map._requestManager.transformRequest(y.uri,Df.Model).url).then(P=>{if(!P)return;const O=Ude(P),B=new mke(m,y.uri,y.position,y.orientation,O);Ub.applyModelSpecification(B,y),B.computeBoundsAndApplyParent(),this.models.push(B),this._modelsInfo.set(m,{modelSpec:y,model:B})}).catch(P=>{this.fire(new Jg(new Error(`Could not load model ${m} from ${y.uri}: ${P.message}`)))});c.push(E)}}Promise.allSettled(c).then(()=>{this._loaded=!0,this.fire(new tm("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(m=>{this._loaded=!0,this.fire(new Jg(new Error(`Could not load models: ${m.message}`)))})}static applyModelSpecification(c,m){m.nodeOverrides&&Ub.convertNodeOverrides(c,m.nodeOverrides),m.materialOverrides&&Ub.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(y=>typeof y=="string")){c.nodeOverrideNames=[];for(const y of m)c.nodeOverrideNames.push(y)}else Object.entries(m).forEach(([y,k])=>{const E={orientation:[0,0,0]};if(k.hasOwnProperty("orientation")){const P=k.orientation;P&&(E.orientation=P)}c.nodeOverrides.set(y,E)})}static convertMaterialOverrides(c,m){if(Array.isArray(m)&&m.every(y=>typeof y=="string")){c.materialOverrideNames=[];for(const y of m)c.materialOverrideNames.push(y)}else Object.entries(m).forEach(([y,k])=>{const E={color:new Fr(1,1,1),colorMix:0,emissionStrength:0,opacity:1},P=k["model-color"];P!==void 0&&(E.color.r=P[0],E.color.g=P[1],E.color.b=P[2]);const O=k["model-color-mix-intensity"];O!==void 0&&(E.colorMix=O);const B=k["model-emissive-strength"];B!==void 0&&(E.emissionStrength=B);const W=k["model-opacity"];W!==void 0&&(E.opacity=W),c.materialOverrides.set(y,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=Wm(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 y in c){const k=c[y];if(this._modelsInfo.has(y)){const E=this._modelsInfo.get(y);E&&E.modelSpec.uri===k.uri&&m.set(y,E)}}this._modelsInfo=m,this._options.models=c,this._loaded=!1,this.load()}}function xue(f,c,m,y){const k=1<rt.polygon).flat());const Le=ce?O:null,[Ie,Ge]=Yje(E,y,ee,J,W,P,Le,ne,ue,E.center.lat,f.tileID.canonical),Xe=f.queryGeometry;return Zje(Ie,Ge,Xe.isPointQuery()?Xe.screenBounds:Xe.screenGeometry)}},building:class extends Jd{constructor(f,c,m,y){super(f,{layout:_ke||(_ke=new bo({visibility:new Vs(Gt.layout_building.visibility),"building-facade":new rr(Gt.layout_building["building-facade"]),"building-facade-floors":new rr(Gt.layout_building["building-facade-floors"]),"building-facade-unit-width":new rr(Gt.layout_building["building-facade-unit-width"]),"building-facade-window":new rr(Gt.layout_building["building-facade-window"]),"building-roof-shape":new rr(Gt.layout_building["building-roof-shape"]),"building-height":new rr(Gt.layout_building["building-height"]),"building-base":new rr(Gt.layout_building["building-base"]),"building-flood-light-wall-radius":new rr(Gt.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new rr(Gt.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new rr(Gt.layout_building["building-flip-roof-orientation"])})),paint:bke||(bke=new bo({"building-opacity":new Vs(Gt.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Vs(Gt.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Vs(Gt.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Vs(Gt.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Vs(Gt.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Vs(Gt.paint_building["building-vertical-scale"]),"building-cast-shadows":new Vs(Gt.paint_building["building-cast-shadows"]),"building-color":new rr(Gt.paint_building["building-color"]),"building-emissive-strength":new rr(Gt.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Vs(Gt.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Vs(Gt.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new Vs(Gt.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Vs(Gt.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Vs(Gt.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new rr({type:"string",default:"default","property-type":"data-driven"})}))},c,m,y),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(f){return new vke(f)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(f){return!0}queryRadius(f){return 0}queryIntersectsFeature(f,c,m,y,k,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=f.tile.getBucket(this).getFootprint(c);if(ee){if(ee.hiddenFlags!==0)return!1;W=ee.height}const[ne,ce]=Yje(E,y,J,W,new rs(0,0),P,null,[0,0],1,E.center.lat,f.tileID.canonical),ue=f.queryGeometry;return Zje(ne,ce,ue.isPointQuery()?ue.screenBounds:ue.screenGeometry)}},line:class extends Jd{constructor(f,c,m,y){const k=Eke();super(f,k,c,m,y),k.layout&&(this.layout=new Ey(k.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(f){if(f==="line-gradient"){const c=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=c._styleExpression&&c._styleExpression.expression instanceof mb,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(f,c){super.recalculate(f,c),this.paint._values["line-floorwidth"]=(()=>{if(uA)return uA;const m=Eke();return uA=new est(m.paint.properties["line-width"].specification),uA.useIntegerZoom=!0,uA})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,f)}createBucket(f){return new Wde(f)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(f,c,m){const y=Tke(this);return{config:new px(this,{zoom:c,lut:m}),defines:y,overrideFog:!1}}queryRadius(f){const c=f,m=Pke(gd("line-width",this,c),gd("line-gap-width",this,c)),y=gd("line-offset",this,c);return m/2+Math.abs(y)+Ec(this.paint.get("line-translate"))}queryIntersectsFeature(f,c,m,y,k,E){if(f.queryGeometry.isAboveHorizon)return!1;const P=yh(f.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),E.angle,f.pixelToTileUnitsFactor),O=f.pixelToTileUnitsFactor/2*Pke(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&&(y=function(W,J){const ee=[],ne=new rs(0,0);for(let ce=0;ce=3){for(let ue=0;ue>16&255)/255,(f>>8&255)/255,(255&f)/255,1)}function vrt(f,c,m){f===1?(c.rgb_color=HO(m.readVarint()),c.paint="rgb_color"):f===2?(c.linear_gradient_idx=m.readVarint(),c.paint="linear_gradient_idx"):f===3?(c.radial_gradient_idx=m.readVarint(),c.paint="radial_gradient_idx"):f===5?m.readPackedFloat(c.dasharray):f===6?c.dashoffset=m.readFloat():f===7?c.miterlimit=m.readFloat():f===8?c.opacity=m.readVarint():f===9?c.width=m.readFloat():f===10?c.linecap=m.readVarint():f===11&&(c.linejoin=m.readVarint())}function _rt(f,c,m){f===1?c.transform=VO(m,m.readVarint()+m.pos):f===2?c.spread_method=m.readVarint():f===3?c.stops.push(HNe(m,m.readVarint()+m.pos)):f===4?c.x1=m.readFloat():f===5?c.y1=m.readFloat():f===6?c.x2=m.readFloat():f===7&&(c.y2=m.readFloat())}function HNe(f,c){return f.readFields(brt,{offset:0,opacity:255,rgb_color:yue},c)}function brt(f,c,m){f===1?c.offset=m.readFloat():f===2?c.opacity=m.readVarint():f===3&&(c.rgb_color=HO(m.readVarint()))}function wrt(f,c,m){f===1?c.transform=VO(m,m.readVarint()+m.pos):f===2?c.spread_method=m.readVarint():f===3?c.stops.push(HNe(m,m.readVarint()+m.pos)):f===4?c.cx=m.readFloat():f===5?c.cy=m.readFloat():f===6?c.r=m.readFloat():f===7?c.fx=m.readFloat():f===8?c.fy=m.readFloat():f===9&&(c.fr=m.readFloat())}function jrt(f,c,m){f===1?c.transform=VO(m,m.readVarint()+m.pos):f===2?c.clip_path_idx=m.readVarint():f===3&&c.children.push(UO(m,m.readVarint()+m.pos))}function krt(f,c,m){f===1?c.left=c.top=m.readFloat():f===2?c.width=c.height=m.readFloat():f===3?c.top=m.readFloat():f===4?c.height=m.readFloat():f===5?c.mask_type=m.readVarint():f===6?c.mask_idx=m.readVarint():f===7&&c.children.push(UO(m,m.readVarint()+m.pos))}class Nrt{static calculate(c={},m=[]){const y=new Map,k=new Map;if(Object.keys(c).length===0)return y;m.forEach(E=>{k.set(E.name,E.rgb_color||new Fr(0,0,0))});for(const[E,P]of Object.entries(c))k.has(E)?y.set(k.get(E).toString(),P):console.warn(`Ignoring unknown image variable "${E}"`);return y}}function FC(f,c=255,m){const y=c/255,k=f.toString(),E=m.has(k)?m.get(k).clone():f.clone();return E.a*=y,E.toString()}function MA(f,c){if(!Qh()){const m=document.createElement("canvas");return m.width=f,m.height=c,m}return new OffscreenCanvas(f,c)}let bue,TA=null;function wue(f,c,m,y,k){for(const E of y.children)WNe(f,c,m,E,k)}function WNe(f,c,m,y,k){y.group?(f.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=zC(B.transform).preMultiplySelf(P)),!function(ue,je,Le){return ue.opacity!==255||je||Le}(B,ee!=null,J!=null))return void wue(E,P,O,B,W);const ne=MA(E.canvas.width,E.canvas.height),ce=ne.getContext("2d");wue(ce,P,O,B,W),ee&&JNe(ce,P,O,ee),J&&eSe(ce,P,O,J,W),E.globalAlpha=B.opacity/255,E.drawImage(ne,0,0)}(f,c,m,y.group,k),f.restore()):y.path&&(f.save(),function(E,P,O,B,W){E.setTransform(P),B.paint_order===ort.PAINT_ORDER_FILL_AND_STROKE?(GNe(E,O,B,W),ZNe(E,O,B,W)):(ZNe(E,O,B,W),GNe(E,O,B,W))}(f,c,m,y.path,k),f.restore())}function GNe(f,c,m,y){const k=m.fill;if(!k)return;const E=k.opacity/255;switch(f.save(),f.beginPath(),tSe(m,f),k.paint){case"rgb_color":f.fillStyle=FC(k.rgb_color,k.opacity,y);break;case"linear_gradient_idx":{const P=c.linear_gradients[k.linear_gradient_idx];P.transform&&f.setTransform(zC(P.transform).preMultiplySelf(f.getTransform())),f.fillStyle=YNe(f,P,E,y);break}case"radial_gradient_idx":{const P=c.radial_gradients[k.radial_gradient_idx];P.transform&&f.setTransform(zC(P.transform).preMultiplySelf(f.getTransform())),f.fillStyle=XNe(f,P,E,y)}}f.fill(KNe(m)),f.restore()}function KNe(f){return f.rule===vue.PATH_RULE_NON_ZERO?"nonzero":f.rule===vue.PATH_RULE_EVEN_ODD?"evenodd":void 0}function ZNe(f,c,m,y){const k=m.stroke;if(!k)return;const E=sSe(m);f.lineWidth=k.width,f.miterLimit=k.miterlimit,f.setLineDash(k.dasharray),f.lineDashOffset=k.dashoffset;const P=k.opacity/255;switch(k.paint){case"rgb_color":f.strokeStyle=FC(k.rgb_color,k.opacity,y);break;case"linear_gradient_idx":f.strokeStyle=YNe(f,c.linear_gradients[k.linear_gradient_idx],P,y,!0);break;case"radial_gradient_idx":f.strokeStyle=XNe(f,c.radial_gradients[k.radial_gradient_idx],P,y,!0)}switch(k.linejoin){case qO.LINE_JOIN_MITER_CLIP:case qO.LINE_JOIN_MITER:f.lineJoin="miter";break;case qO.LINE_JOIN_ROUND:f.lineJoin="round";break;case qO.LINE_JOIN_BEVEL:f.lineJoin="bevel"}switch(k.linecap){case _ue.LINE_CAP_BUTT:f.lineCap="butt";break;case _ue.LINE_CAP_ROUND:f.lineCap="round";break;case _ue.LINE_CAP_SQUARE:f.lineCap="square"}f.stroke(E)}function YNe(f,c,m,y,k=!1){if(c.stops.length===1){const ne=c.stops[0];return FC(ne.rgb_color,ne.opacity*m,y)}const{x1:E,y1:P,x2:O,y2:B}=c;let W=new DOMPoint(E,P),J=new DOMPoint(O,B);if(k){const ne=zC(c.transform);W=ne.transformPoint(W),J=ne.transformPoint(J)}const ee=f.createLinearGradient(W.x,W.y,J.x,J.y);for(const ne of c.stops)ee.addColorStop(ne.offset,FC(ne.rgb_color,ne.opacity*m,y));return ee}function XNe(f,c,m,y,k=!1){if(c.stops.length===1){const Ie=c.stops[0];return FC(Ie.rgb_color,Ie.opacity*m,y)}const E=zC(c.transform),{fx:P,fy:O,fr:B,cx:W,cy:J,r:ee}=c;let ne=new DOMPoint(P,O),ce=new DOMPoint(W,J),ue=B,je=ee;if(k){ne=E.transformPoint(ne),ce=E.transformPoint(ce);const Ie=(E.a+E.d)/2;ue=B*Ie,je=c.r*Ie}const Le=f.createRadialGradient(ne.x,ne.y,ue,ce.x,ce.y,je);for(const Ie of c.stops)Le.addColorStop(Ie.offset,FC(Ie.rgb_color,Ie.opacity*m,y));return Le}function QNe(f,c,m,y){const k=y.transform?zC(y.transform).preMultiplySelf(c):c,E=MA(f.canvas.width,f.canvas.height),P=E.getContext("2d");for(const B of y.children)if(B.group)QNe(P,k,m,B.group);else if(B.path){const W=B.path,J=new Path2D;J.addPath(sSe(W),k),P.fill(J,KNe(W))}const O=y.clip_path_idx!=null?m.clip_paths[y.clip_path_idx]:null;O&&JNe(P,k,m,O),f.globalCompositeOperation="source-over",f.drawImage(E,0,0)}function JNe(f,c,m,y){const k=MA(f.canvas.width,f.canvas.height);QNe(k.getContext("2d"),c,m,y),f.globalCompositeOperation="destination-in",f.drawImage(k,0,0)}function eSe(f,c,m,y,k){if(y.children.length===0)return;const E=y.mask_idx!=null?m.masks[y.mask_idx]:null;E&&eSe(f,c,m,E,k);const P=f.canvas.width,O=f.canvas.height,B=MA(P,O),W=B.getContext("2d"),J=y.width,ee=y.height,ne=y.left,ce=y.top,ue=new Path2D,je=new Path2D;je.rect(ne,ce,J,ee),ue.addPath(je,c),W.clip(ue);for(const Ge of y.children)WNe(W,c,m,Ge,k);const Le=W.getImageData(0,0,P,O),Ie=Le.data;if(y.mask_type===qNe.MASK_TYPE_LUMINANCE)for(let Ge=0;Gec[P])return null}else{const O=1/y[P];let B=(f[P]-m[P])*O,W=(c[P]-m[P])*O;if(B>W){const J=B;B=W,W=J}if(B>k&&(k=B),WE)return null}return k}function aSe(f,c,m,y,k,E,P,O,B,W,J){const ee=y-f,ne=k-c,ce=E-m,ue=P-f,je=O-c,Le=B-m,Ie=J[1]*Le-J[2]*je,Ge=J[2]*ue-J[0]*Le,Xe=J[0]*je-J[1]*ue,rt=ee*Ie+ne*Ge+ce*Xe;if(Math.abs(rt)<1e-15)return null;const _t=1/rt,ft=W[0]-f,St=W[1]-c,It=W[2]-m,$t=(ft*Ie+St*Ge+It*Xe)*_t;if($t<0||$t>1)return null;const as=St*ce-It*ne,Wt=It*ee-ft*ce,hs=ft*ne-St*ee,_s=(J[0]*as+J[1]*Wt+J[2]*hs)*_t;return _s<0||$t+_s>1?null:(ue*as+je*Wt+Le*hs)*_t}function iSe(f,c,m){return(f-c)/(m-c)}function oSe(f,c,m,y,k,E,P,O,B){const W=1<{const Ge=Le?1:0,Xe=(ce+1)*je-Ge,rt=ue*je,_t=(ue+1)*je-Ge;Ie[0]=ce*je,Ie[1]=rt,Ie[2]=Xe,Ie[3]=_t};let ee=new rSe(B);const ne=[];for(let ce=0;ce=1;B/=2){const ce=O[O.length-1];ee=new rSe(B);for(let ue=0;ue0;){const{idx:ue,t:je,nodex:Le,nodey:Ie,depth:Ge}=ce.pop();if(this.leaves[ue]){oSe(Le,Ie,Ge,c,m,y,k,ee,ne);const rt=1<=Fs[2])return je}continue}let Xe=0;for(let rt=0;rt=W[J[It]]&&(J.splice(It,0,rt),St=!0);St||(J[Xe]=rt),Xe++}}for(let rt=0;rt=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 y=[0,0,0,0],k=GO.getUnpackVector(m);let E=Math.floor((c+k[3])/k[2]);return y[2]=E%256,E=Math.floor(E/256),y[1]=E%256,E=Math.floor(E/256),y[0]=E,y}getPixels(){return new rje({width:this.stride,height:this.stride},this.pixels)}backfillBorder(c,m,y){if(this.dim!==c.dim)throw new Error("dem dimension mismatch");let k=m*this.dim,E=m*this.dim+this.dim,P=y*this.dim,O=y*this.dim+this.dim;switch(m){case-1:k=E-1;break;case 1:E=k+1}switch(y){case-1:P=O-1;break;case 1:O=P+1}const B=-m*this.dim,W=-y*this.dim;for(let J=P;J=1;y--){const k=y===1?1:0,E=y===2?1:0;for(let P=0;P>>1^-(1&f[c]);return f}function zrt(f,c){switch(c){case"uint32":return f;case"uint16":for(let m=0;m>4|(61440&y)>>8|(240&k)<<4|61440&k,f[m+1]=15&y|(3840&y)>>4|(15&k)<<8|(3840&k)<<4}return f;case"uint8":for(let m=0;m>6|(192&k)>>4|(192&E)>>2|192&P,f[m+1]=(48&y)>>4|(48&k)>>2|48&E|(48&P)<<2,f[m+2]=(12&y)>>2|12&k|(12&E)<<2|(12&P)<<4,f[m+3]=3&y|(3&k)<<2|(3&E)<<4|(3&P)<<6}return f;default:throw new Error(`Invalid pixel format, "${c}"`)}}_r(GO,"DEMData"),_r(lSe,"DemMinMaxQuadTree",{omit:["dem"]});var Ym=Uint8Array,AA=Uint16Array,Brt=Int32Array,dSe=new Ym([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]),uSe=new Ym([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]),$rt=new Ym([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),hSe=function(f,c){for(var m=new AA(31),y=0;y<31;++y)m[y]=c+=1<>1|(21845&Ul)<<1;fSe[Ul]=((65280&(BC=(61680&(BC=(52428&BC)>>2|(13107&BC)<<2))>>4|(3855&BC)<<4))>>8|(255&BC)<<8)>>1}var EA=function(f,c,m){for(var y=f.length,k=0,E=new AA(c);k>B]=W;return P},PA=new Ym(288);for(Ul=0;Ul<144;++Ul)PA[Ul]=8;for(Ul=144;Ul<256;++Ul)PA[Ul]=9;for(Ul=256;Ul<280;++Ul)PA[Ul]=7;for(Ul=280;Ul<288;++Ul)PA[Ul]=8;var gSe=new Ym(32);for(Ul=0;Ul<32;++Ul)gSe[Ul]=5;var Vrt=EA(PA,9),Hrt=EA(gSe,5),kue=function(f){for(var c=f[0],m=1;mc&&(c=f[m]);return c},rg=function(f,c,m){var y=c/8|0;return(f[y]|f[y+1]<<8)>>(7&c)&m},Nue=function(f,c){var m=c/8|0;return(f[m]|f[m+1]<<8|f[m+2]<<16)>>(7&c)},Wrt=["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"],ng=function(f,c,m){var y=new Error(c||Wrt[f]);if(y.code=f,Error.captureStackTrace&&Error.captureStackTrace(y,ng),!m)throw y;return y},Grt=new Ym(0),Krt=typeof TextDecoder<"u"&&new TextDecoder;try{Krt.decode(Grt,{stream:!0})}catch{}const Zrt={gzip_data:"gzip"};class Fp extends Error{constructor(c){super(c),this.name="MRTError"}}const Yrt={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},xSe={uint32:1,uint16:2,uint8:4},Xrt={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let Sue;class KO{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 Fp(`Layer '${c}' not found`);return m}getHeaderLength(c){const m=new Uint8Array(c),y=new DataView(c);if(m[0]!==13)throw new Fp("File is not a valid MRT.");return y.getUint32(1,!0)}parseHeader(c){const m=new Uint8Array(c),y=this.getHeaderLength(c);if(m.length= ${y} but got buffer of length ${m.length}`);const k=new Sue(m.subarray(0,y)).readFields(Trt,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==k.x||this.y!==k.y||this.z!==k.z))throw new Fp(`Invalid attempt to parse header ${k.z}/${k.x}/${k.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=k.x,this.y=k.y,this.z=k.z;for(const E of k.layers)this.layers[E.name]=new ySe(E,{cacheSize:this._cacheSize});return this}createDecodingTask(c){const m=[],y=this.getLayer(c.layerName);for(let k of c.blockIndices){const E=y.dataIndex[k],P=E.firstByte-c.firstByte,O=E.lastByte-c.firstByte;if(y._blocksInProgress.has(k))continue;const B={layerName:y.name,firstByte:P,lastByte:O,pixelFormat:y.pixelFormat,blockIndex:k,blockShape:[E.bands.length].concat(y.bandShape),buffer:y.buffer,codec:E.codec.codec,filters:E.filters.map(W=>W.filter)};y._blocksInProgress.add(k),m.push(B)}return new vSe(m,()=>{m.forEach(k=>y._blocksInProgress.delete(k.blockIndex))},(k,E)=>{if(m.forEach(P=>y._blocksInProgress.delete(P.blockIndex)),k)throw k;E.forEach(P=>{this.getLayer(P.layerName).processDecodedData(P)})})}}class ySe{constructor({version:c,name:m,units:y,tileSize:k,pixelFormat:E,buffer:P,dataIndex:O},B){if(this.version=c,this.version!==1)throw new Fp(`Cannot parse raster layer encoded with MRT version ${c}`);this.name=m,this.units=y,this.tileSize=k,this.buffer=P,this.pixelFormat=Yrt[E],this.dataIndex=O,this.bandShape=[k+2*P,k+2*P,xSe[this.pixelFormat]],this._decodedBlocks=new WO(B?B.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return xSe[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[y,k]of this.dataIndex.entries()){for(const[E,P]of k.bands.entries())if(P===c)return{bandIndex:m+E,blockIndex:y,blockBandIndex:E};m+=k.bands.length}break;case"number":for(const[y,k]of this.dataIndex.entries()){if(c>=m&&cthis.cacheSize)throw new Fp(`Number of blocks to decode (${E.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:m,lastByte:y,blockIndices:k}}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:y}=this.getBlockForBand(c);if(m<0)throw new Fp(`Band not found: ${JSON.stringify(c)}`);const k=this._decodedBlocks.get(m.toString());if(!k)throw new Fp(`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=y*P,B=k.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}}}KO.setPbf=function(f){Sue=f};class vSe{constructor(c,m,y){this.tasks=c,this._onCancel=m,this._onComplete=y,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(c,m){this._finalized||(this._onComplete(c,m),this._finalized=!0)}}KO.performDecoding=function(f,c){const m=new Uint8Array(f);return Promise.all(c.tasks.map(y=>{const{layerName:k,firstByte:E,lastByte:P,pixelFormat:O,blockShape:B,blockIndex:W,filters:J,codec:ee}=y,ne=m.subarray(E,P+1),ce=new Uint32Array(B[0]*B[1]*B[2]);let ue;if(ee!=="gzip_data")throw new Fp(`Unhandled codec: ${ee}`);return ue=function(je,Le){if(!globalThis.DecompressionStream&&Le==="gzip_data")return Promise.resolve(((rt=function(St){St[0]==31&&St[1]==139&&St[2]==8||ng(6,"invalid gzip data");var It=St[3],$t=10;4&It&&($t+=2+(St[10]|St[11]<<8));for(var as=(It>>3&1)+(It>>4&1);as>0;as-=!St[$t++]);return $t+(2&It)}(Xe=je))+8>Xe.length&&ng(6,"invalid gzip data"),function(St,It,$t,as){var Wt=St.length;if(!Wt||It.f&&!It.l)return $t||new Ym(0);var hs=!$t,_s=hs||It.i!=2,bs=It.i;hs&&($t=new Ym(3*Wt));var Os,Fs,Ps=function(vi){var Ga=$t.length;if(vi>Ga){var ei=new Ym(Math.max(2*Ga,vi));ei.set($t),$t=ei}},Ls=It.f||0,us=It.p||0,is=It.b||0,Ds=It.l,Xs=It.d,qs=It.m,Ir=It.n,lr=8*Wt;do{if(!Ds){Ls=rg(St,us,1);var gr=rg(St,us+1,3);if(us+=3,!gr){var Nr=St[(ms=4+((us+7)/8|0))-4]|St[ms-3]<<8,Wn=ms+Nr;if(Wn>Wt){bs&&ng(0);break}_s&&Ps(is+Nr),$t.set(St.subarray(ms,Wn),is),It.b=is+=Nr,It.p=us=8*Wn,It.f=Ls;continue}if(gr==1)Ds=Vrt,Xs=Hrt,qs=9,Ir=5;else if(gr==2){var Us=rg(St,us,31)+257,Sr=rg(St,us+10,15)+4,hn=Us+rg(St,us+5,31)+1;us+=14;for(var ma=new Ym(hn),xa=new Ym(19),Pn=0;Pn>4)<16)ma[Pn++]=ms;else{var nr=0,ar=0;for(ms==16?(ar=3+rg(St,us,3),us+=2,nr=ma[Pn-1]):ms==17?(ar=3+rg(St,us,7),us+=3):ms==18&&(ar=11+rg(St,us,127),us+=7);ar--;)ma[Pn++]=nr}}var Dr=ma.subarray(0,Us),zr=ma.subarray(Us);qs=kue(Dr),Ir=kue(zr),Ds=EA(Dr,qs),Xs=EA(zr,Ir)}else ng(1);if(us>lr){bs&&ng(0);break}}_s&&Ps(is+131072);for(var kn=(1<>4;if((us+=15&nr)>lr){bs&&ng(0);break}if(nr||ng(2),aa<256)$t[is++]=aa;else{if(aa==256){Hn=us,Ds=null;break}var en=aa-254;aa>264&&(en=rg(St,us,(1<<(Fa=dSe[Pn=aa-257]))-1)+pSe[Pn],us+=Fa);var un=Xs[Nue(St,us)&Bn],Pa=un>>4;if(un||ng(3),us+=15&un,zr=Urt[Pa],Pa>3){var Fa=uSe[Pa];zr+=Nue(St,us)&(1<lr){bs&&ng(0);break}_s&&Ps(is+131072);var za=is+en;if(isOs.length)&&(Fs=Os.length),new Ym(Os.subarray(0,Fs))):$t.subarray(0,is)}(Xe.subarray(rt,-8),{i:2},new Ym(((Ie=Xe)[(Ge=Ie.length)-4]|Ie[Ge-3]<<8|Ie[Ge-2]<<16|Ie[Ge-1]<<24)>>>0))));var Ie,Ge,Xe,rt;const _t=Zrt[Le];if(!_t)throw new Error(`Unhandled codec: ${Le}`);const ft=new globalThis.DecompressionStream(_t);return new Response(new Blob([je]).stream().pipeThrough(ft)).arrayBuffer().then(St=>new Uint8Array(St))}(ne,ee).then(je=>(function(Le,Ie){Le.readFields(Drt,Ie)}(new Sue(je),ce),new Xrt[O](ce.buffer))),ue.then(je=>{for(let Le=J.length-1;Le>=0;Le--)switch(J[Le]){case"delta_filter":Rrt(je,B);break;case"zigzag_filter":Frt(je);break;case"bitshuffle_filter":zrt(je,O);break;default:throw new Fp(`Unhandled filter "${J[Le]}"`)}return{layerName:k,blockIndex:W,data:je}}).catch(je=>{throw je})}))},_r(vSe,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),_r(KO,"MapboxRasterTile"),_r(ySe,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class _Se{constructor(c){this._stringToNumber={},this._numberToString=[];for(let m=0;m=0&&ne[3]>=0&&W.insert(B,ne[0],ne[1],ne[2],ne[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Xt(new kO(this.rawTileData)).layers,this.sourceLayerCoder=new _Se(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:y,transform:k,tileTransform:E,pixelPosMatrix:P,availableImages:O,worldview:B}=m;this.loadVTLayers(),this.serializedLayersCache.clear();const W=m.queryRadius?m.queryRadius:0,J=y.bufferedTilespaceBounds,ee=this.grid.query(J.min.x,J.min.y,J.max.x,J.max.y,(je,Le,Ie,Ge)=>eu(y.bufferedTilespaceGeometry,je-W,Le-W,Ie+W,Ge+W));ee.sort(Qrt);let ne=null;k.elevation&&ee.length>0&&(ne=RC.create(k.elevation,this.tileID));const ce={};let ue;for(let je=0;je(Ge||(Ge=Pt(Xe,this.tileID.canonical,E)),rt.queryIntersectsFeature(y,Xe,_t,Ge,this.z,k,P,ne,ft)))}return ce}loadMatchingFeature(c,m,y,k,E,P){const{featureIndex:O,bucketIndex:B,sourceLayerIndex:W,layoutVertexArrayOffset:J}=m,ee=this.bucketLayerIDs[B],ne=y.layers,ce=Object.keys(ne);if(ce.length&&!pr(ce,ee))return;const ue=y.sourceCache,je=this.sourceLayerCoder.decode(W),Le=this.vtLayers[je].feature(O),Ie=this.getId(Le,je);for(let Ge=0;Ge`${O.key}: ${O.message}`).join(", ");return void cr(`Failed to create expression for promoteId: ${P}`)}this.promoteIdExpression=E.value}y=this.promoteIdExpression.evaluate({zoom:0},c)}else y=c.properties[k];typeof y=="boolean"&&(y=Number(y))}return y}}function wSe(f,c,m,y,k){return Jt(f,(E,P)=>{const O=c instanceof Ey?c.get(P):null;return O&&O.evaluate?O.evaluate(m,y,void 0,k):O})}function Qrt(f,c){return c-f}_r(bSe,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const jSe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Cue{static from(c){if(!(c instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[m,y]=new Uint8Array(c,0,2);if(m!==219)throw new Error("Data does not appear to be in a KDBush format.");const k=y>>4;if(k!==1)throw new Error(`Got v${k} data when expected v1.`);const E=jSe[15&y];if(!E)throw new Error("Unrecognized array type.");const[P]=new Uint16Array(c,2,1),[O]=new Uint32Array(c,4,1);return new Cue(O,P,E,c)}constructor(c,m=64,y=Float64Array,k){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=y,this.IndexArrayType=c<65536?Uint16Array:Uint32Array;const E=jSe.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: ${y}.`);k&&k instanceof ArrayBuffer?(this.data=k,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 y=this._pos>>1;return this.ids[y]=y,this.coords[this._pos++]=c,this.coords[this._pos++]=m,y}finish(){const c=this._pos>>1;if(c!==this.numItems)throw new Error(`Added ${c} items when expected ${this.numItems}.`);return Mue(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(c,m,y,k){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,ne=B.pop()||0;if(ee-ne<=O){for(let Le=ne;Le<=ee;Le++){const Ie=P[2*Le],Ge=P[2*Le+1];Ie>=c&&Ie<=y&&Ge>=m&&Ge<=k&&W.push(E[Le])}continue}const ce=ne+ee>>1,ue=P[2*ce],je=P[2*ce+1];ue>=c&&ue<=y&&je>=m&&je<=k&&W.push(E[ce]),(J===0?c<=ue:m<=je)&&(B.push(ne),B.push(ce-1),B.push(1-J)),(J===0?y>=ue:k>=je)&&(B.push(ce+1),B.push(ee),B.push(1-J))}return W}within(c,m,y){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:k,coords:E,nodeSize:P}=this,O=[0,k.length-1,0],B=[],W=y*y;for(;O.length;){const J=O.pop()||0,ee=O.pop()||0,ne=O.pop()||0;if(ee-ne<=P){for(let Le=ne;Le<=ee;Le++)NSe(E[2*Le],E[2*Le+1],c,m)<=W&&B.push(k[Le]);continue}const ce=ne+ee>>1,ue=E[2*ce],je=E[2*ce+1];NSe(ue,je,c,m)<=W&&B.push(k[ce]),(J===0?c-y<=ue:m-y<=je)&&(O.push(ne),O.push(ce-1),O.push(1-J)),(J===0?c+y>=ue:m+y>=je)&&(O.push(ce+1),O.push(ee),O.push(1-J))}return B}}function Mue(f,c,m,y,k,E){if(k-y<=m)return;const P=y+k>>1;kSe(f,c,P,y,k,E),Mue(f,c,m,y,P-1,1-E),Mue(f,c,m,P+1,k,1-E)}function kSe(f,c,m,y,k,E){for(;k>y;){if(k-y>600){const W=k-y+1,J=m-y+1,ee=Math.log(W),ne=.5*Math.exp(2*ee/3),ce=.5*Math.sqrt(ee*ne*(W-ne)/W)*(J-W/2<0?-1:1);kSe(f,c,m,Math.max(y,Math.floor(m-J*ne/W+ce)),Math.min(k,Math.floor(m+(W-J)*ne/W+ce)),E)}const P=c[2*m+E];let O=y,B=k;for(IA(f,c,y,m),c[2*k+E]>P&&IA(f,c,y,k);OP;)B--}c[2*y+E]===P?IA(f,c,y,B):(B++,IA(f,c,B,k)),B<=m&&(y=B+1),m<=B&&(k=B-1)}}function IA(f,c,m,y){Tue(f,m,y),Tue(c,2*m,2*y),Tue(c,2*m+1,2*y+1)}function Tue(f,c,m){const y=f[c];f[c]=f[m],f[m]=y}function NSe(f,c,m,y){const k=f-m,E=c-y;return k*k+E*E}i.$=xS,i.A=Ff,i.B=Wm,i.C=2,i.D=kC,i.E=Ts,i.F=pA,i.G=Xke,i.H=gS,i.I=Ws,i.J=BD,i.K=Pr,i.L=mv,i.M=$S,i.N=yb,i.O=CD,i.P=rs,i.Q=vb,i.R=Df,i.S=XS,i.T=Rde,i.U=cx,i.V=BO,i.W=bT,i.X=yv,i.Y=xv,i.Z=hb,i._=Xd,i.a=function(f){return sa.API_CDN_URL_REGEX.test(f)},i.a$=ge,i.a0=dn,i.a1=ea,i.a2=Ip,i.a3=class extends BO{},i.a4=qS,i.a5=SD,i.a6=Gt,i.a7=function(f){const c=f.value;return c?dn(c)?pue(c,!0)?[]:[new BO(f.key,c,`invalid url "${c}"`)]:[new BO(f.key,c,`string expected, "${Pr(c)}" found`)]:[]},i.a8=OD,i.a9=bo,i.aA=Se,i.aB=C,i.aC=mt,i.aD=pd,i.aE=wi,i.aF=H,i.aG=tt,i.aH=function(f,c){const m={};for(let y=0;y{y(E,P)},c):y(E,P),()=>{}}return k.callbacks.push(y),k.cancel||(k.cancel=m((E,P)=>{k.result=[E,P];for(const O of k.callbacks)this.scheduler?this.scheduler.add(()=>{O(E,P)},c):O(E,P);setTimeout(()=>delete this.entries[f],3e3)})),()=>{k.result||(k.callbacks=k.callbacks.filter(E=>E!==y),k.callbacks.length||(k.cancel(),delete this.entries[f]))}}},i.aL=function(f,c,m){const y=JSON.stringify(f.request);return f.data&&(this.deduped.entries[y]={result:[null,f.data]}),this.deduped.request(y,{type:"parseTile",isSymbolTile:f.isSymbolTile,zoom:f.tileZoom},k=>{const E=qu(f.request,(P,O,B)=>{P?k(P):O&&k(null,{rawData:O,vectorTile:m?void 0:new Xt(new kO(O)),responseHeaders:new Map(B.entries())})});return()=>{E.cancel(),k()}},c)},i.aM=function(f){return f?{cacheControl:f.get("Cache-Control"),expires:f.get("Expires")}:{cacheControl:void 0,expires:void 0}},i.aN=ul,i.aO=function(f){Qc++,Qc>lv&&(f.getActor().send("enforceCacheSizeLimit",ov),Qc=0)},i.aP=function(f){return f<=1?1:Math.pow(2,Math.floor(Math.log2(f)))},i.aQ=go,i.aR=SNe,i.aS=PNe,i.aT=x,i.aU=NNe,i.aV=function(f,c){const m=document.createElement("video");m.muted=!0,m.onloadstart=function(){c(null,m)};for(let y=0;y{}}},i.aW=cA,i.aX=Ub,i.aY=Ut,i.aZ=yA,i.a_=oe,i.aa=Vs,i.ab=class{constructor(f){this.specification=f}possiblyEvaluate(f,c){return wn(f.expression.evaluate(c))}interpolate(f,c,m){return{x:Vr(f.x,c.x,m),y:Vr(f.y,c.y,m),z:Vr(f.z,c.z,m),azimuthal:Vr(f.azimuthal,c.azimuthal,m),polar:Vr(f.polar,c.polar,m)}}},i.ac=Li,i.ad=My,i.ae=Je,i.af=Dt,i.ag=de,i.ah=ze,i.ai=Ey,i.aj=Rv,i.ak=Vr,i.al=Ys,i.am=by,i.an=Jr,i.ao=Fr,i.ap=class{constructor(f){this.specification=f}possiblyEvaluate(f,c){return function([m,y]){const k=wn([1,m,y]);return{x:k.x,y:k.y,z:k.z}}(f.expression.evaluate(c))}interpolate(f,c,m){return{x:Vr(f.x,c.x,m),y:Vr(f.y,c.y,m),z:Vr(f.z,c.z,m)}}},i.aq=function(f,c,m=0,y=!0){const k=new rs(m,m),E=f.sub(k),P=c.add(k),O=[E,new rs(P.x,E.y),P,new rs(E.x,P.y)];return y&&O.push(E.clone()),O},i.ar=function(f,c){const m=[];for(let y=0;y1)return!1;const m=c.getSource().maxzoom,y=1<1)return c;const k=y.getSource().maxzoom,E=1<{const O=this.getAtTileOffset(f,k,E,P),B=y.upVector(f.canonical,k.x,k.y);return Ne(B,B,O*y.upVectorScale(f.canonical,c,m).metersToTile),B}}getForTilePoints(f,c,m,y){if(this.isUsingMockSource())return!1;const k=RC.create(this,f,y);return!!k&&(c.forEach(E=>{E[2]=this.exaggeration()*k.getElevationAt(E[0],E[1],m)}),!0)}getMinMaxForTile(f){if(this.isUsingMockSource())return null;const c=this.findDEMTileFor(f);if(!c||!c.dem)return null;const m=c.dem.tree,y=c.tileID,k=1<0&&(y+=(f[k]-0)*(f[k]-0)),c[k]<0&&(y+=(0-c[k])*(0-c[k]));return y},i.c0=Sje,i.c1=Qde,i.c2=nNe,i.c3=iue,i.c4=Cue,i.c5=Ne,i.c6=qe,i.c7=He,i.c8=function(f,c,m){m*=.5;var y=c[0],k=c[1],E=c[2],P=c[3],O=Math.sin(m),B=Math.cos(m);return f[0]=y*B+k*O,f[1]=k*B-y*O,f[2]=E*B+P*O,f[3]=P*B-E*O,f},i.c9=et,i.cA=te,i.cB=Wa,i.cC=dke,i.cD=ji,i.cE=$2e,i.cF=function(f,c,m,y,k,E,P,O,B){if(B.name==="globe")return $2e(f,c,new ji(m,y,k),!1);const W=yA({z:m,x:y,y:k},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(f,c,m){return f[0]=Math.min(c[0],m[0]),f[1]=Math.min(c[1],m[1]),f[2]=Math.min(c[2],m[2]),f[3]=Math.min(c[3],m[3]),f},i.cH=function(f,c,m){return f[0]=Math.max(c[0],m[0]),f[1]=Math.max(c[1],m[1]),f[2]=Math.max(c[2],m[2]),f[3]=Math.max(c[3],m[3]),f},i.cI=function(f){const c=Math.round((f+45+360)%360/90)%4;return $l[c]},i.cJ=xe,i.cK=We,i.cL=bC,i.cM=function(f){const c=w(new Float64Array(16));C(c,f.pixelMatrix,f.globeMatrix);const m=[0,om,0],y=[0,lm,0];return Dt(m,m,c),Dt(y,y,c),[m[0]>0&&m[0]<=f.width&&m[1]>0&&m[1]<=f.height&&!pde(f,new x(f.center.lat,90)),y[0]>0&&y[0]<=f.width&&y[1]>0&&y[1]<=f.height&&!pde(f,new x(f.center.lat,-90))]},i.cN=function(f,c){const{scale:m}=f.tileTransform,y=m*Ys/(f.tileSize*Math.pow(2,c.zoom-f.tileID.overscaledZ+f.tileID.canonical.z));return function(k,E,P){var O=E[1],B=E[2],W=E[3],J=P[0],ee=P[1];return k[0]=E[0]*J,k[1]=O*J,k[2]=B*ee,k[3]=W*ee,k}(new Float32Array(4),c.inverseAdjustmentMatrix,[y,y])},i.cO=yO,i.cP=se,i.cQ=cke,i.cR=function(f){const c=cke(f,!0);return p([],[c[0],c[1],c[4],c[5]])},i.cS=I,i.cT=or,i.cU=L,i.cV=function(f){const{x:c,y:m}=f.point,{lng:y,lat:k}=f._center;return V2e(c,m,f.worldSize,y,k)},i.cW=be,i.cX=Za,i.cY=mo,i.cZ=ed,i.c_=im,i.ca=Ha,i.cb=function(f,c){return f[0]=-c[0],f[1]=-c[1],f[2]=-c[2],f[3]=c[3],f},i.cc=X,i.cd=function(f,c,m,y,k){var E=1/Math.tan(c/2);if(f[0]=E/m,f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[5]=E,f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[11]=-1,f[12]=0,f[13]=0,f[15]=0,k!=null&&k!==1/0){var P=1/(y-k);f[10]=(k+y)*P,f[14]=2*k*y*P}else f[10]=-1,f[14]=-2*y;return f},i.ce=function(f,c,m,y,k,E,P){var O=1/(c-m),B=1/(y-k),W=1/(E-P);return f[0]=-2*O,f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[5]=-2*B,f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[10]=2*W,f[11]=0,f[12]=(c+m)*O,f[13]=(k+y)*B,f[14]=(P+E)*W,f[15]=1,f},i.cf=re,i.cg=function(f,c,m){f[4*c+0]=m[0],f[4*c+1]=m[1],f[4*c+2]=m[2],f[4*c+3]=m[3]},i.ch=xC,i.ci=Mb,i.cj=_l,i.ck=Op,i.cl=Ab,i.cm=fNe,i.cn=function(){var f=new u(4);return u!=Float32Array&&(f[1]=0,f[2]=0),f[0]=1,f[3]=1,f},i.co=function(f,c,m){var y=c[0],k=c[1],E=c[2],P=c[3],O=Math.sin(m),B=Math.cos(m);return f[0]=y*B+E*O,f[1]=k*B+P*O,f[2]=y*-O+E*B,f[3]=k*-O+P*B,f},i.cp=function(f,c){return f[0]===c[0]&&f[1]===c[1]&&f[2]===c[2]&&f[3]===c[3]},i.cq=Qe,i.cr=function(f){var c=f[0],m=f[1],y=f[2],k=f[3];return Math.sqrt(c*c+m*m+y*y+k*k)},i.cs=Qt,i.ct=Ve,i.cu=Go,i.cv=3,i.cw=2,i.cx=7,i.cy=6,i.cz=De,i.d=function(f){return sa.API_TILEJSON_REGEX.test(f)},i.d$=class{constructor(f,c,m,y){this.context=f,this.format=y,this.size=m,this.texture=f.gl.createTexture();const[k,E,P]=this.size,{gl:O}=f;O.bindTexture(O.TEXTURE_3D,this.texture),f.pixelStoreUnpackFlipY.set(!1),f.pixelStoreUnpack.set(1),f.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in c&&c.data&&O.texImage3D(O.TEXTURE_3D,0,this.format,k,E,P,0,Dde(this.format),Ode(this.format),c.data)}bind(f,c){const{context:m}=this,{gl:y}=m;y.bindTexture(y.TEXTURE_3D,this.texture),f!==this.minFilter&&(y.texParameteri(y.TEXTURE_3D,y.TEXTURE_MAG_FILTER,f),y.texParameteri(y.TEXTURE_3D,y.TEXTURE_MIN_FILTER,f),this.minFilter=f),c!==this.wrapS&&(y.texParameteri(y.TEXTURE_3D,y.TEXTURE_WRAP_S,c),y.texParameteri(y.TEXTURE_3D,y.TEXTURE_WRAP_T,c),this.wrapS=c)}destroy(){const{gl:f}=this.context;f.deleteTexture(this.texture),this.texture=null}},i.d0=function(f){return f*f*f*f*f},i.d1=z,i.d2=45,i.d3=yC,i.d4=function(f,c,m){const y=Math.sqrt(f*f+c*c+m*m),k=y>0?Math.acos(m/y)*Va:0;let E=f!==0||c!==0?Math.atan2(-c,-f)*Va+90:0;return E<0&&(E+=360),[y,E,k]},i.d5=ie,i.d6=wn,i.d7=Be,i.d8=le,i.d9=Er,i.dA=function(f){return f({pluginStatus:Qd,pluginURL:Vf}),ZS.on("pluginStateChange",f),f},i.dB=Tb,i.dC=class extends Gf{constructor(f){super(f),this.current=vC}set(f,c,m){if(this.fetchUniformLocation(f,c)){for(let y=0;y<9;y++)if(m[y]!==this.current[y]){this.current=m,this.gl.uniformMatrix3fv(this.location,!1,m);break}}}},i.dD=Do,i.dE=function(f,c,m){const y=Rv(m.zoom),k=f.style.map._antialias,E=f.terrain&&f.terrain.exaggeration()>0;return y===0&&!k&&!E},i.dF=function(f){const c=f.pixelsPerMeter,m=c/re(1,f.center.lat),y=w(new Float64Array(16));return A(y,y,[f.point.x,f.point.y,0]),I(y,y,[m,m,c]),Float32Array.from(y)},i.dG=sO,i.dH=function(f){const c=xe-5;f=Se(f,-c,c)/c*90;const m=Math.pow(Math.abs(Math.sin(Jr(f))),3);return Math.round(m*(WT.length-1))},i.dI=function(f,c,m,y){const k=c.getNorth(),E=c.getSouth(),P=c.getWest(),O=c.getEast(),B=1<0){const ue=180/y;_(ce,ce,[ue/W+1,0,0,0,ue/J+1,0,-.5*ue/ee,.5*ue/ne,1])}return ce[2]=B,ce[5]=f.x,ce[8]=f.y,ce},i.dJ=Zm,i.dK=function(f,c,m){const y=w(new Float64Array(16)),k=(c/(1<({u_matrix:new Ab(f),u_texsize:new Op(f),u_pixels_to_tile_units:new _C(f),u_device_pixel_ratio:new _l(f),u_width_scale:new _l(f),u_floor_width_scale:new _l(f),u_image:new xC(f),u_units_to_pixels:new Op(f),u_tile_units_to_pixels:new _l(f),u_alpha_discard_threshold:new _l(f),u_trim_offset:new Op(f),u_trim_fade_range:new Op(f),u_trim_color:new yC(f),u_zbias_factor:new _l(f),u_tile_to_meter:new _l(f),u_ground_shadow_factor:new Mb(f),u_pattern_transition:new _l(f)}),i.dX=f=>({u_matrix:new Ab(f),u_pixels_to_tile_units:new _C(f),u_device_pixel_ratio:new _l(f),u_width_scale:new _l(f),u_floor_width_scale:new _l(f),u_units_to_pixels:new Op(f),u_dash_image:new xC(f),u_gradient_image:new xC(f),u_image_height:new _l(f),u_texsize:new Op(f),u_tile_units_to_pixels:new _l(f),u_alpha_discard_threshold:new _l(f),u_trim_offset:new Op(f),u_trim_fade_range:new Op(f),u_trim_color:new yC(f),u_zbias_factor:new _l(f),u_tile_to_meter:new _l(f),u_ground_shadow_factor:new Mb(f)}),i.dY=f=>({u_camera_to_center_distance:new _l(f),u_extrude_scale:new _C(f),u_device_pixel_ratio:new _l(f),u_matrix:new Ab(f),u_inv_rot_matrix:new Ab(f),u_merc_center:new Op(f),u_tile_id:new Mb(f),u_zoom_transition:new _l(f),u_up_dir:new Mb(f),u_emissive_strength:new _l(f)}),i.dZ=lC,i.d_=cst,i.da=pe,i.db=function(f){return[Math.pow(f[0],1/2.2),Math.pow(f[1],1/2.2),Math.pow(f[2],1/2.2)]},i.dc=lke,i.dd=Ude,i.de=mke,i.df=pue,i.dg=function(f,c){return f.readFields(lrt,{icons:[]},c)},i.dh=pO,i.di=IC,i.dj=rue,i.dk=cv,i.dl=wb,i.dm=Xg,i.dn=dv,i.dp=xs,i.dq=function(f){const c=f.indexOf(Ly);return c>=0?f.slice(0,c):f},i.dr=function(f){return f.indexOf(Ly)>=0},i.ds=function(f){const c=f.lastIndexOf(Ly);return c>=0?f.slice(c+1):""},i.dt=function(f){const c=[],m=f.id;return m===void 0&&c.push({message:`layers.${m}: missing required property "id"`}),f.render===void 0&&c.push({message:`layers.${m}: missing required method "render"`}),f.renderingMode&&f.renderingMode!=="2d"&&f.renderingMode!=="3d"&&c.push({message:`layers.${m}: property "renderingMode" must be either "2d" or "3d"`}),c},i.du=function(f,c,m,y){return f.type==="custom"?new trt(f,c):new irt[f.type](f,c,m,y)},i.dv=Is,i.dw=function(f){const c=f.indexOf(Ly);return c>=0?f.slice(c+1):""},i.dx=class extends qb{constructor(f,c){super(f._vectorTileFeature,f._z,f._x,f._y,f.id),f.state&&(this.state=Object.assign({},f.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=f.source,this.sourceLayer=f.sourceLayer,this.layer=f.layer)}toJSON(){const f=super.toJSON();return f.target=this.target,f.namespace=this.namespace,f}},i.dy=ZS,i.dz=Of,i.e=sa,i.e$=ae,i.e0=G2e,i.e1=(f,c,m,y,k,E)=>{const P=f.transform,O=P.projection.name==="globe";let B;if(E.paint.get("circle-pitch-alignment")==="map")if(O){const J=U2e(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:f.transform.getCameraToCenterDistance(P.projection),u_matrix:f.translatePosMatrix(c.projMatrix,m,E.paint.get("circle-translate"),E.paint.get("circle-translate-anchor")),u_device_pixel_ratio:yl.devicePixelRatio,u_extrude_scale:B,u_inv_rot_matrix:ket,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=y,W.u_merc_center=k,W.u_tile_id=[c.canonical.x,c.canonical.y,1<{const J=f.transform,ee=J.pitch<15?Ske(.07,.7,Se((14-J.zoom)/5,0,1)):.07,ne=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:Mke(f,c,m,y),u_texsize:c.imageAtlasTexture?c.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:J.calculatePixelsToTileUnitsMatrix(c),u_device_pixel_ratio:k,u_width_scale:E,u_floor_width_scale:P,u_image:0,u_tile_units_to_pixels:Cke(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(ne?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=(f,c,m,y,k,E,P,O,B,W)=>{const J=f.transform,ee=J.calculatePixelsToTileUnitsMatrix(c),ne=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none",ce=J.pitch<15?Ske(.07,.7,Se((14-J.zoom)/5,0,1)):.07;return{u_matrix:Mke(f,c,m,y),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:k,u_texsize:Ake(m)&&c.lineAtlasTexture?c.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Cke(c,f.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(ne?null:m.lut).toArray01(),u_zbias_factor:ce,u_tile_to_meter:Be(c.tileID.canonical,0),u_ground_shadow_factor:W}},i.e6=Yt,i.e7=KT,i.e8=me,i.e9=dm,i.eA=function(f,c){var m=2*Math.acos(c[3]),y=Math.sin(m/2);return y>d?(f[0]=c[0]/y,f[1]=c[1]/y,f[2]=c[2]/y):(f[0]=1,f[1]=0,f[2]=0),m},i.eB=xue,i.eC=bO,i.eD=_O,i.eE=[1,1,1],i.eF=RC,i.eG=lt,i.eH=function(f,c,m,y){var k=c[0],E=c[1],P=c[2],O=c[3];return f[0]=k+y*(m[0]-k),f[1]=E+y*(m[1]-E),f[2]=P+y*(m[2]-P),f[3]=O+y*(m[3]-O),f},i.eI=MC,i.eJ=xh,i.eK=Dp,i.eL=function(f,c,m,y,k,E,P,O,B,W,J,ee,ne,ce,ue,je){var Le=new u(16);return Le[0]=f,Le[1]=c,Le[2]=m,Le[3]=y,Le[4]=k,Le[5]=E,Le[6]=P,Le[7]=O,Le[8]=B,Le[9]=W,Le[10]=J,Le[11]=ee,Le[12]=ne,Le[13]=ce,Le[14]=ue,Le[15]=je,Le},i.eM=M,i.eN=Ev,i.eO=OT,i.eP=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new rs(1/0,1/0),max:new rs(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(f,c=!1){const m=jje(new rs(0,0),new rs(Ys,Ys),f),y=[];if(c&&!jde(m,this._globalClipBounds))return y;for(const k of this._activeRegions){if(k.hiddenByOverlap||!jde(m,k))continue;const E=ett(k.min,k.max,f);y.push({min:E.min,max:E.max,sourceId:this._sourceIds[k.priority],footprint:k.footprint,footprintTileId:k.tileId,order:k.order,clipMask:k.clipMask,clipScope:k.clipScope})}return y}setSources(f){this._setSources(f.map(c=>({getSourceId:()=>c.cache.id,getFootprints:()=>{const m=[];for(const y of c.cache.getVisibleCoordinates()){const k=c.cache.getTile(y).buckets[c.layer];k&&k.updateFootprints(y.toUnwrapped(),m)}return m},getOrder:()=>c.order,getClipMask:()=>c.clipMask,getClipScope:()=>c.clipScope})))}_addSource(f){const c=f.getFootprints();if(c.length===0)return;const m=f.getOrder(),y=f.getClipMask(),k=f.getClipScope();for(const E of c){if(!E.footprint)continue;const P=jje(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:y,clipScope:k})}this._sourceIds.push(f.getSourceId())}_computeReplacement(){this._activeRegions.sort((c,m)=>c.priority-m.priority||cO(c.min,m.min)||cO(c.max,m.max)||c.order-m.order||c.clipMask-m.clipMask||function(y,k){const E=(P,O)=>P+O;return y.length-k.length||y.reduce(E,"").localeCompare(k.reduce(E,""))}(c.clipScope,m.clipScope));let f=this._activeRegions.length!==this._prevRegions.length;if(!f){let c=0;for(;!f&&c!==this._activeRegions.length;){const m=this._activeRegions[c],y=this._prevRegions[c];f=m.priority!==y.priority||!wje(m,y)||m.order!==y.order||m.clipMask!==y.clipMask||!Ln(m.clipScope,y.clipScope),this._activeRegions[c].hiddenByOverlap=y.hiddenByOverlap,++c}}if(f){++this._updateTime;for(const m of this._activeRegions)m.order!==eA&&(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 y=this._activeRegions;if(m>=y.length)return m;const k=y[m].priority;for(;m1){let m=0,y=c(m);for(;m!==y;){let k=m;const E=m;for(;k!==y;){const P=this._activeRegions[k];P.hiddenByOverlap=!1;for(let O=0;O=0;c--)this._addSource(f[c]);this._computeReplacement()}},i.eQ=eA,i.eR=class{constructor(f){this._createGrid(f),this._createPoles(f)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const f of this._poleSegments)f.destroy();for(const f of this._gridSegments)f.withSkirts.destroy(),f.withoutSkirts.destroy()}_fillGridMeshWithLods(f,c){const m=new ux,y=new vl,k=[],E=f+1+2,P=c[0]+1,O=c[0]+1+(1+c.length),B=(W,J,ee)=>{let ne=W===E-1?W-2:W===0?W:W-1;return ne+=ee?24575:0,[ne,J]};for(let W=0;W0?(Le=2*Math.sqrt(je+1),f[3]=.25*Le,f[0]=(ee-ce)/Le,f[1]=(ne-B)/Le,f[2]=(O-W)/Le):P>J&&P>ue?(Le=2*Math.sqrt(1+P-J-ue),f[3]=(ee-ce)/Le,f[0]=.25*Le,f[1]=(O+W)/Le,f[2]=(ne+B)/Le):J>ue?(Le=2*Math.sqrt(1+J-P-ue),f[3]=(ne-B)/Le,f[0]=(O+W)/Le,f[1]=.25*Le,f[2]=(ee+ce)/Le):(Le=2*Math.sqrt(1+ue-P-J),f[3]=(O-W)/Le,f[0]=(ne+B)/Le,f[1]=(ee+ce)/Le,f[2]=.25*Le),f},i.f=function(f){return btoa(encodeURIComponent(f).replace(/%([0-9A-F]{2})/g,(c,m)=>String.fromCharCode(+("0x"+m))))},i.f0=function([f,c,m]){const y=Math.hypot(f,c,m),k=Math.atan2(f,m),E=.5*Math.PI-Math.acos(-c/y);return new x(Za(k),Za(E))},i.f1=Ye,i.f2=Fde,i.f3=function(f){const c=f.navigator?f.navigator.userAgent:null;return!!function(m){if($o==null){const y=m.navigator?m.navigator.userAgent:null;$o=!!m.safari||!(!y||!(/\b(iPad|iPhone|iPod)\b/.test(y)||y.match("Safari")&&!y.match("Chrome")))}return $o}(f)&&!(!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(f,c){ov=f,lv=c},i.f5=pde,i.f6=H2e,i.f7=function(f){const c=[0,0,0],m=w(new Float64Array(16));return C(m,f.pixelMatrix,f.globeMatrix),Dt(c,c,m),new rs(c[0],c[1])},i.f8=function(){const f=iA;f&&(f.isPreloaded()&&f.numActive()===1?(f.release(Tde),iA=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(){pO().acquire(Tde)},i.fA=GO,i.fB=Vt,i.fC=function(f){let c=0;if(new Uint32Array(f,0,1)[0]!==rke){const m=new Uint32Array(f,0,7),[,,y,k,E,P]=m;c=m.byteLength+k+E+P+E,(y!==f.byteLength||c>=f.byteLength)&&cr("Invalid b3dm header information.")}return oke(f,c)},i.fD=function(f,c){const m=Ude(f);for(const y of m){for(const k of y.meshes)Ett(k);y.lights&&(y.lightMeshIndex=y.meshes.length,y.meshes.push(Ptt(y.lights,c)))}return m},i.fE=$O,i.fF=ua,i.fG=Qje,i.fH=Hf,i.fI=Uu,i.fJ=function(f){hd(),uh!=null&&uh.then(c=>{c.keys().then(m=>{for(let y=0;ycr(k.message))}).catch(m=>cr(m.message))}).catch(c=>cr(c.message))},i.fa=jb,i.fb=function(f,c,m=!1){if(Qd===Uu.deferred||Qd===Uu.loading||Qd===Uu.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Vf=yl.resolveURL(f),Qd=Uu.deferred,NT=c,KS(),m||DD()},i.fc=function(f){NC=yl.resolveURL(f),SC||(SC=new kC(pO(),new Ts)),SC.broadcast("setMeshoptUrl",NC)},i.fd=tke,i.fe=function(f){Pde=yl.resolveURL(f),SC||(SC=new kC(pO(),new Ts)),SC.broadcast("setDracoUrl",Pde)},i.ff=eke,i.fg=aA,i.fh=function(f){const c=hh();if(!c)return;const m=c.delete(iv);f&&m.then(()=>f()).catch(f)},i.fi=Rb,i.fj=_r,i.fk=Fv,i.fl=sg,i.fm=_Se,i.fn=bSe,i.fo=wke,i.fp=cs,i.fq="hd_road_elevation",i.fr=Qa,i.fs=Jt,i.ft=Fy,i.fu=sue,i.fv=Bb,i.fw=function(f,c,m,y,k,E,P,O=1,B,W,J){f.createArrays(),f.tilePixelRatio=Ys/(512*f.overscaling),f.compareText={},f.iconsNeedLinear=!1;const ee=f.layers[0].layout,ne=f.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,je]=ce.textSizeScaleRange,[Le,Ie]=ce.iconSizeScaleRange;ce.textScaleFactor=Se(ce.scaleFactor,ue,je),ce.iconScaleFactor=Se(ce.scaleFactor,Le,Ie);const Ge=ne["text-size"],Xe=ne["icon-size"];if(f.textSizeData.kind==="composite"){const{minZoom:$t,maxZoom:as}=f.textSizeData;ce.compositeTextSizes=[Ge.possiblyEvaluate(new Li($t,{worldview:J}),E),Ge.possiblyEvaluate(new Li(as,{worldview:J}),E)]}if(f.iconSizeData.kind==="composite"){const{minZoom:$t,maxZoom:as}=f.iconSizeData;ce.compositeIconSizes=[Xe.possiblyEvaluate(new Li($t,{worldview:J}),E),Xe.possiblyEvaluate(new Li(as,{worldview:J}),E)]}ce.layoutTextSize=Ge.possiblyEvaluate(new Li(P+1,{worldview:J}),E),ce.layoutIconSize=Xe.possiblyEvaluate(new Li(P+1,{worldview:J}),E),ce.textMaxSize=Ge.possiblyEvaluate(new Li(18,{worldview:J}),E);const rt=ee.get("symbol-placement"),_t=ee.get("text-rotation-alignment")==="map"&&rt!=="point",ft=ee.get("text-size");let St=!1;const It=[];for(const $t of f.features){const as=ee.get("text-font").evaluate($t,{},E).join(","),Wt=ft.evaluate($t,{},E)*ce.textScaleFactor,hs=ce.layoutTextSize.evaluate($t,{},E)*ce.textScaleFactor,_s=ce.layoutIconSize.evaluate($t,{},E)*ce.iconScaleFactor,bs={horizontal:{},vertical:void 0},Os=$t.text;let Fs,Ps=[0,0];if(Os){const Pn=Os.toString(),yi=ee.get("text-letter-spacing").evaluate($t,{},E)*ac,gt=ee.get("text-line-height").evaluate($t,{},E)*ac,wt=jT(Pn)?yi:0,ms=ee.get("text-anchor").evaluate($t,{},E),Rs=ee.get("text-variable-anchor");if(!Rs){const kn=ee.get("text-radial-offset").evaluate($t,{},E);if(kn)Ps=nNe(ms,[kn*ac,aue]);else{const Bn=ee.get("text-offset").evaluate($t,{},E);Ps=[Bn[0]*ac,Bn[1]*ac]}}let nr=_t?"center":ee.get("text-justify").evaluate($t,{},E);const ar=rt==="point",Dr=ar?ee.get("text-max-width").evaluate($t,{},E)*ac:1/0,zr=kn=>{f.allowVerticalPlacement&&bb(Pn)&&(bs.vertical=Xde(Os,c,m,k,as,Dr,gt,ms,kn,wt,Ps,_h.vertical,!0,hs,Wt,B))};if(!_t&&Rs){const kn=nr==="auto"?Rs.map(Hn=>iue(Hn)):[nr];let Bn=!1;for(let Hn=0;Hn=0||!bb(Pn)){const kn=Xde(Os,c,m,k,as,Dr,gt,ms,nr,wt,Ps,_h.horizontal,!1,hs,Wt,B);kn&&(bs.horizontal[nr]=kn)}zr(ar?"left":nr)}}let Ls,us,is,Ds,Xs,qs,Ir=!1;const lr=ee.get("icon-text-fit").evaluate($t,{},E);if($t.icon&&$t.icon.hasPrimary()){const Pn=gA($t.icon,f.iconSizeData,ne["icon-size"],E,f.zoom,$t,B,ce.iconScaleFactor,J);Ls=Pn.iconPrimary,is=Pn.iconSecondary;const yi=Ls.toString();if(us=y.get(yi),us&&(Xs=ee.get("icon-offset").evaluate($t,{},E),qs=ee.get("icon-anchor").evaluate($t,{},E),Fs=SO(k.get(yi),is?k.get(is.toString()):void 0,Xs,qs),Ir=us.sdf,f.sdfIcons===void 0?f.sdfIcons=us.sdf:f.sdfIcons!==us.sdf&&cr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(us.pixelRatio!==f.pixelRatio||ee.get("icon-rotate").constantOr(1)!==0)&&(f.iconsNeedLinear=!0)),is){const gt=is.toString();Ds=y.get(gt)}}St=St||!(!$t.icon||!$t.icon.hasSecondary());const gr=EO(bs.horizontal)||bs.vertical;f.iconsInText||(f.iconsInText=!!gr&&gr.iconsInText);const Nr=hs*ce.textScaleFactor/ac,{defaultShapedIcon:Wn,verticallyShapedIcon:Us}=Bst(f,Fs,ee,$t,E,bs,Nr,Xs,lr);lr!=="none"&&Fs&&(Uke(Fs)||Vke(Fs))&&(AO(0,us,Ls,Fs,Wn,lr,W,y,k),AO(0,Ds,is,Fs,Wn,lr,W,y,k),Us&&(AO(0,us,Ls,Fs,Us,lr,W,y,k),AO(0,Ds,is,Fs,Us,lr,W,y,k))),Fs=Wn;const{iconBBox:Sr,iconVerticalBBox:hn,textBBox:ma,textVerticalBBox:xa}=Dst(f,Fs,Us,ee,$t,E,_s,Xs,ce,k,qs,bs,hs,Ps);It.push({feature:$t,shapedTextOrientations:bs,shapedText:gr,shapedIcon:Fs,iconPrimary:Ls,iconSecondary:is,iconOffset:Xs,iconAnchor:qs,verticallyShapedIcon:Us,layoutTextSize:hs,layoutIconSize:_s,textOffset:Ps,isSDFIcon:Ir,iconTextFit:lr,iconCollisionBounds:Sr,iconVerticalCollisionBounds:hn,textCollisionBounds:ma,textVerticalCollisionBounds:xa})}return{featureData:It,sizes:ce,hasAnySecondaryIcon:St,textAlongLine:_t,symbolPlacement:rt}},i.fx=Qke,i.fy=function(f,c,m,y,k,E,P,O,B,W){f.iconAtlasPositions=W.iconPositions;const{featureData:J,hasAnySecondaryIcon:ee,sizes:ne,textAlongLine:ce,symbolPlacement:ue}=c;for(const je of J){const{shapedIcon:Le,verticallyShapedIcon:Ie,feature:Ge,shapedTextOrientations:Xe,shapedText:rt,layoutTextSize:_t,textOffset:ft,isSDFIcon:St,iconPrimary:It,iconSecondary:$t,iconTextFit:as,iconOffset:Wt,iconCollisionBounds:hs,iconVerticalCollisionBounds:_s,textCollisionBounds:bs}=je;iNe(Le,W.iconPositions,It,$t),iNe(Ie,W.iconPositions,It,$t),zst(Xe,W.iconPositions),Fst(It,$t,W.iconPositions),(rt||Le)&&$st(f,Ge,Xe,Le,Ie,B,ne,_t,0,ft,St,y,k,P,O,ee,as,Wt,ce,ue,hs,_s,bs)}m&&f.generateCollisionDebugBuffers(E,f.collisionBoxArray,ne.textScaleFactor)},i.fz=Xt,i.g=function(f,c){return Of(Object.assign(f,{method:"GET"}),c)},i.h=function(f){return f.indexOf("mapbox:")===0},i.i=function(f){return sa.API_STYLE_REGEX.test(f)&&!rc(f)},i.j=Ji,i.k=Ad,i.l=function(f){return decodeURIComponent(atob(f).split("").map(c=>"%"+("00"+c.charCodeAt(0).toString(16)).slice(-2)).join(""))},i.m=function(f,c){return Of(Object.assign(f,{type:"json"}),c)},i.n=Qg,i.o=yl,i.p=function(f,c){return Of(Object.assign(f,{method:"POST"}),c)},i.q=xd,i.r=Qh,i.s=function(f){try{const c=self[f];return c.setItem("_mapbox_test_",1),c.removeItem("_mapbox_test_"),!0}catch{return!1}},i.t=function(){return Ade||(Ade=new Rb("ImageRasterizer")),Ade},i.u=function(){return function f(c){return c?(c^Math.random()*(16>>c/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,f)}()},i.v=function(f){return!!f&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(f)},i.w=cr,i.x=jue,i.y=Jg,i.z=tm}),o(["./shared"],function(i){function d(ct){const Se=ct?ct.url.toString():void 0;return Se?performance.getEntriesByName(Se):[]}function u(ct){if(typeof ct=="number"||typeof ct=="boolean"||typeof ct=="string"||ct==null)return JSON.stringify(ct);if(Array.isArray(ct)){let ze="[";for(const st of ct)ze+=`${u(st)},`;return`${ze}]`}let Se="{";for(const ze of Object.keys(ct).sort())Se+=`${ze}:${u(ct[ze])},`;return`${Se}}`}function p(ct){let Se="";for(const ze of i.bx)Se+=`/${u(ct[ze])}`;return Se}class g{constructor(Se){this.keyCache={},this._layers={},this._layerConfigs={},Se&&this.replace(Se)}replace(Se,ze){this._layerConfigs={},this._layers={},this.update(Se,[],ze)}update(Se,ze,st){this._options=st;for(const Nt of Se)this._layerConfigs[Nt.id]=Nt,(this._layers[Nt.id]=i.du(Nt,this.scope,null,this._options)).compileFilter(st),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 Tt=function(Nt,Bt){const Yt={};for(let Jt=0;Jtthis._layers[pr.id]),Yt=Bt[0];if(Yt.visibility==="none")continue;const Ut=Yt.source||"";let Jt=this.familiesBySource[Ut];Jt||(Jt=this.familiesBySource[Ut]={});const Is=Yt.sourceLayer||"_geojsonTileLayer";let xs=Jt[Is];xs||(xs=Jt[Is]=[]),xs.push(Bt)}}}const v=1*i.fl;class _{constructor(Se){const ze={},st=[];for(const Yt in Se){const Ut=Se[Yt],Jt=ze[Yt]={};for(const Is in Ut.glyphs){const xs=Ut.glyphs[+Is];if(!xs||xs.bitmap.width===0||xs.bitmap.height===0)continue;const pr=xs.metrics.localGlyph?v:1,$r={x:0,y:0,w:xs.bitmap.width+2*pr,h:xs.bitmap.height+2*pr};st.push($r),Jt[Is]=$r}}const{w:Tt,h:Nt}=i.G(st),Bt=new i.fk({width:Tt||1,height:Nt||1});for(const Yt in Se){const Ut=Se[Yt];for(const Jt in Ut.glyphs){const Is=Ut.glyphs[+Jt];if(!Is||Is.bitmap.width===0||Is.bitmap.height===0)continue;const xs=ze[Yt][Jt],pr=Is.metrics.localGlyph?v:1;i.fk.copy(Is.bitmap,Bt,{x:0,y:0},{x:xs.x+pr,y:xs.y+pr},Is.bitmap)}}this.image=Bt,this.positions=ze}}function b(ct,Se,ze){ct[Se]?ze&&(ct[Se].center=ze):ct[Se]={floorIds:new Set,center:ze||[0,0],floors:{}}}function j(ct,Se,ze,st){for(const Tt of Se)b(ct,Tt),ct[Tt].floors[ze]=st,ct[Tt].floorIds.add(ze)}function w(ct){return{id:ct.properties.id.toString(),center:ct.properties.center.toString().split(";").map(Number)}}function N(ct){return{id:ct.properties.id.toString(),isDefault:!!ct.properties.is_default&&ct.properties.is_default,connections:ct.properties.connected_floor_ids?new Set(ct.properties.connected_floor_ids.toString().split(";")):new Set,conflicts:ct.properties.conflicted_floor_ids?new Set(ct.properties.conflicted_floor_ids.toString().split(";")):new Set,buildings:ct.properties.building_ids?new Set(ct.properties.building_ids.toString().split(";")):new Set,name:ct.properties.name.toString(),zIndex:ct.properties.z_index}}function C(ct,Se){return Se.every(ze=>ct.properties&&ct.properties[ze]!=null)}function A(ct){return C(ct,["type","id","name"])&&ct.properties.type==="building"}function I(ct){return C(ct,["type","id","name","z_index"])&&ct.properties.type==="floor"}i.fj(_,"GlyphAtlas");class L{constructor(Se){this.tileID=new i.aQ(Se.tileID.overscaledZ,Se.tileID.wrap,Se.tileID.canonical.z,Se.tileID.canonical.x,Se.tileID.canonical.y),this.tileZoom=Se.tileZoom,this.uid=Se.uid,this.zoom=Se.zoom,this.lut=Se.lut,this.canonical=Se.tileID.canonical,this.pixelRatio=Se.pixelRatio,this.tileSize=Se.tileSize,this.source=Se.source,this.scope=Se.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=Se.showCollisionBoxes,this.collectResourceTiming=!!Se.request&&Se.request.collectResourceTiming,this.promoteId=Se.promoteId,this.isSymbolTile=Se.isSymbolTile,this.tileTransform=i.aZ(Se.tileID.canonical,Se.projection),this.projection=Se.projection,this.worldview=Se.worldview,this.localizableLayerIds=Se.localizableLayerIds,this.brightness=Se.brightness,this.extraShadowCaster=!!Se.extraShadowCaster,this.tessellationStep=Se.tessellationStep,this.scaleFactor=Se.scaleFactor,this.worldview=Se.worldview,this.indoor=Se.indoor}parse(Se,ze,st,Tt,Nt,Bt){this.status="parsing",this.data=Se,this.collisionBoxArray=new i.b3;const Yt=new i.fm(Object.keys(Se.layers).sort()),Ut=new i.fn(this.tileID,this.promoteId);Ut.bucketLayerIDs=[];const Jt={},Is=new i.fo(256,256),xs={featureIndex:Ut,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Is,availableImages:st,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const Cn=this.indoor.indoorState.activeFloorsVisible,Mn=function(wn,ua,co){const $o=function(Xi,_a){if(!Xi)return i.w("No source layers defined in indoor specification"),_a;if(Xi.size===0)return _a;const Qi=Xi.difference(_a);for(const xi of Qi)i.w(`Missing source layer required in indoor specification: ${xi}`);return _a.intersection(_a)}(ua.sourceLayers,new Set(Object.keys(wn.layers))),Ha=ua.indoorState,Wo=function(Xi,_a,Qi,xi){const sa=new Set,Ji=new Set,rc=new Set,gc=new Map,Md={},Np=xl=>{const wu=gc.get(xl)||new Set;for(const Xc of sa)if((gc.get(Xc)||new Set).has(xl)||wu.has(Xc))return!0;return!1};for(const xl of _a){const wu=Xi.layers[xl];if(wu)for(let Xc=0;Xc=Qi.maxzoom||Qi.visibility==="none")continue;R(_a,this.zoom,xs.brightness,st,this.worldview);const xi=Jt[Qi.id]=Qi.createBucket({index:Ut.bucketLayerIDs.length,layers:_a,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:$o,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:Tt,worldview:this.worldview,localizable:Wo});Ut.bucketLayerIDs.push(_a.map(Ji=>i.B(Ji.id,Ji.scope)));let sa=xi.prepare?xi.prepare():null;sa!=null?(sa=sa.then(()=>xi.populate(Ha,xs,this.tileID.canonical,this.tileTransform)),pr.push(sa)):xi.populate(Ha,xs,this.tileID.canonical,this.tileTransform)}}const cr=()=>{let Cn,Mn,wn,ua,co,$o;Is.trim();const Ha={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},Wo=()=>{if(Cn)return this.status="done",Bt(Cn);if(this.extraShadowCaster)this.status="done",Bt(null,{buckets:Object.values(Jt).filter(_a=>!_a.isEmpty()),featureIndex:Ut,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:xs.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(Mn&&wn&&ua){const _a=new _(Mn),Qi=new Map;for(const[Ji,rc]of wn.entries()){const{imagePosition:gc}=i.fu(Ji,rc,i.fv);Qi.set(Ji,gc)}const xi={};for(const Ji in Jt){const rc=Jt[Ji];rc instanceof i.b4&&(R(rc.layers,this.zoom,xs.brightness,st,this.worldview),xi[Ji]=i.fw(rc,Mn,_a.positions,wn,Qi,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,co,this.worldview))}const sa={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(Nt,wn,co,()=>{sa.iconsPending=!1,Xi(xi,_a,sa)}),this.rasterizeIfNeeded(Nt,ua,$o,()=>{sa.patternsPending=!1,Xi(xi,_a,sa)})}},Xi=(_a,Qi,xi,sa)=>{if(xi.iconsPending||xi.patternsPending)return;const Ji=new i.fx(wn,ua,this.lut);for(const rc in Jt){const gc=Jt[rc];if(rc in _a)i.fy(gc,_a[rc],this.showCollisionBoxes,st,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,wn,Ji);else if(gc.hasPattern&&(gc instanceof i.ba||gc instanceof i.bb||gc instanceof i.ea)){R(gc.layers,this.zoom,xs.brightness,st,this.worldview);const Md=Object.fromEntries(Ji.patternPositions);gc.addFeatures(xs,this.tileID.canonical,Md,st,this.tileTransform,this.brightness)}}this.status="done",Bt(null,{buckets:Object.values(Jt).filter(rc=>!rc.isEmpty()),featureIndex:Ut,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Qi.image,lineAtlas:Is,imageAtlas:Ji,brightness:xs.brightness})};if(!this.extraShadowCaster){const _a=i.fs(xs.glyphDependencies,sa=>Object.keys(sa).map(Number));Object.keys(_a).length?Nt.send("getGlyphs",{uid:this.uid,stacks:_a},(sa,Ji)=>{Cn||(Cn=sa,Mn=Ji,Wo())},void 0,!1,Ha):Mn={};const Qi=Array.from(xs.iconDependencies.keys()).map(sa=>i.I.parse(sa));Qi.length?Nt.send("getImages",{images:Qi,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(sa,Ji)=>{Cn||(Cn=sa,wn=new Map,co=this.updateImageMapAndGetImageTaskQueue(wn,Ji,xs.iconDependencies),Wo())},void 0,!1,Ha):(wn=new Map,co=new Map);const xi=Array.from(xs.patternDependencies.keys()).map(sa=>i.I.parse(sa));xi.length?Nt.send("getImages",{images:xi,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(sa,Ji)=>{Cn||(Cn=sa,ua=new Map,$o=this.updateImageMapAndGetImageTaskQueue(ua,Ji,xs.patternDependencies),Wo())},void 0,!1,Ha):(ua=new Map,$o=new Map)}if(xs.elevationFeatures&&xs.elevationFeatures.length>0){const _a=[];for(const xi of Object.values(Jt))if(xi instanceof i.bb){const sa=xi.getUnevaluatedPortalGraph();sa&&_a.push(sa)}const Qi=i.ft.evaluate(_a);for(const xi of Object.values(Jt))if(xi instanceof i.bb){const sa=Se.layers[Yt.decode(xi.sourceLayerIndex)];xi.setEvaluatedPortalGraph(Qi,sa,this.tileID.canonical,xs.availableImages,xs.brightness)}}Wo()};pr.length>0?Promise.allSettled(pr).then(cr).catch(Bt):cr()}updateParameters(Se){this.scaleFactor=Se.scaleFactor,this.showCollisionBoxes=Se.showCollisionBoxes,this.projection=Se.projection,this.brightness=Se.brightness,this.tileTransform=i.aZ(Se.tileID.canonical,Se.projection),this.extraShadowCaster=Se.extraShadowCaster,this.lut=Se.lut,this.worldview=Se.worldview,this.indoor=Se.indoor}rasterizeIfNeeded(Se,ze,st,Tt){Array.from(ze.values()).some(Nt=>Nt.usvg)?this.rasterize(Se,ze,st,Tt):Tt()}updateImageMapAndGetImageTaskQueue(Se,ze,st){const Tt=new Map;for(const Nt of ze.keys()){const Bt=st.get(Nt)||[];for(const Yt of Bt){const Ut=Yt.toString(),Jt=ze.get(Yt.id.toString());Jt.usvg?Tt.has(Ut)||(Tt.set(Ut,Yt),Se.set(Ut,Object.assign({},Jt))):Se.set(Ut,Jt)}}return Tt}rasterize(Se,ze,st,Tt){this.rasterizeTask=Se.send("rasterizeImages",{scope:this.scope,tasks:st},(Nt,Bt)=>{if(!Nt)for(const[Yt,Ut]of Bt.entries()){const Jt=Object.assign(ze.get(Yt),{data:Ut});ze.set(Yt,Jt)}Tt()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function R(ct,Se,ze,st,Tt){const Nt=new i.ac(Se,{brightness:ze,worldview:Tt});for(const Bt of ct)Bt.recalculate(Nt,st)}class $ extends i.E{constructor(Se,ze,st,Tt,Nt,Bt,Yt){super(),this.actor=Se,this.layerIndex=ze,this.availableImages=st,this.availableModels=Tt,this.loadVectorData=Bt||i.aL,this.loading={},this.loaded={},this.deduped=new i.aK(Se.scheduler),this.isSpriteLoaded=Nt,this.scheduler=Se.scheduler,this.brightness=Yt}loadTile(Se,ze){const st=Se.uid,Tt=Se&&Se.request,Nt=Tt&&Tt.collectResourceTiming,Bt=this.loading[st]=new L(Se);Bt.abort=this.loadVectorData(Se,(Yt,Ut)=>{const Jt=!this.loading[st];if(delete this.loading[st],Bt.cancelRasterize(),Jt||Yt||!Ut)return Bt.status="done",Jt||(this.loaded[st]=Bt),ze(Yt);const Is=Ut.rawData,xs={},pr=i.aM(Ut.responseHeaders);pr&&pr.expires&&(xs.expires=pr.expires),pr&&pr.cacheControl&&(xs.cacheControl=pr.cacheControl),Bt.vectorTile=Ut.vectorTile||new i.fz(new i.bt(Is));const $r=()=>{Bt.parse(Bt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(cr,Cn)=>{if(cr||!Cn)return ze(cr);const Mn={};if(Nt){const wn=d(Tt);wn.length>0&&(Mn.resourceTiming=JSON.parse(JSON.stringify(wn)))}ze(null,Object.assign({rawTileData:Is.slice(0),responseHeaders:Ut.responseHeaders},Cn,xs,Mn))})};this.isSpriteLoaded?$r():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add($r,{type:"parseTile",isSymbolTile:Se.isSymbolTile,zoom:Se.tileZoom}):$r()}),this.loaded=this.loaded||{},this.loaded[st]=Bt})}reloadTile(Se,ze){const st=this.loaded,Tt=Se.uid;if(st&&st[Tt]){const Nt=st[Tt];Nt.updateParameters(Se);const Bt=(Yt,Ut)=>{const Jt=Nt.reloadCallback;Jt&&(delete Nt.reloadCallback,Nt.parse(Nt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Jt)),ze(Yt,Ut)};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(Se,ze){const st=Se.uid,Tt=this.loading[st];Tt&&(Tt.abort&&Tt.abort(),delete this.loading[st]),ze()}removeTile(Se,ze){const st=this.loaded,Tt=Se.uid;st&&st[Tt]&&delete st[Tt],ze()}}class q{loadTile(Se,ze){const{uid:st,encoding:Tt,rawImageData:Nt,padding:Bt}=Se,Yt=ImageBitmap&&Nt instanceof ImageBitmap?this.getImageData(Nt,Bt):Nt;ze(null,new i.fA(st,Yt,Tt,Bt<1))}reloadTile(Se,ze){ze(null,null)}abortTile(Se,ze){ze()}removeTile(Se,ze){ze()}getImageData(Se,ze){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(Se.width,Se.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=Se.width,this.offscreenCanvas.height=Se.height,this.offscreenCanvasContext.drawImage(Se,0,0,Se.width,Se.height);const st=this.offscreenCanvasContext.getImageData(-ze,-ze,Se.width+2*ze,Se.height+2*ze);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),st}}i.bs.setPbf(i.bt);class U{constructor(Se){this._mrt=new i.bs(Se.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=Se.uid,this.tileID=Se.tileID,this.source=Se.source}parse(Se,ze){const st=this._mrt;this.status="parsing",this._entireBuffer=Se;try{st.parseHeader(Se),this._isHeaderLoaded=!0;const Tt=[];for(const Nt in st.layers){const Bt=st.getLayer(Nt),Yt=Bt.getDataRange(Bt.getBandList()),Ut=st.createDecodingTask(Yt),Jt=Se.slice(Yt.firstByte,Yt.lastByte+1),Is=i.bs.performDecoding(Jt,Ut).then(xs=>Ut.complete(null,xs)).catch(xs=>Ut.complete(xs,null));Tt.push(Is)}Promise.allSettled(Tt).then(()=>ze(null,st)).catch(Nt=>ze(Nt))}catch(Tt){ze(Tt)}}}class V{constructor(Se){this.actor=Se,this.loading={},this.loaded={}}loadTile(Se,ze){const st=Se.uid,Tt=Se.request,Nt=this.loading[st]=new U(Se),{cancel:Bt}=i.bu(Tt,(Yt,Ut,Jt)=>{const Is=!this.loading[st];if(delete this.loading[st],Is||Yt||!Ut)return Nt.status="done",Is||(this.loaded[st]=Nt),ze(Yt);Nt.parse(Ut,(xs,pr)=>{if(xs||!pr)return ze(xs);ze(null,pr,Jt)}),this.loaded[st]=Nt});Nt.abort=Bt}reloadTile(Se,ze){ze(null,void 0)}abortTile(Se,ze){const st=Se.uid,Tt=this.loading[st];Tt&&(Tt.abort&&Tt.abort(),delete this.loading[st]),ze()}removeTile(Se,ze){const st=Se.uid;this.loaded[st]&&delete this.loaded[st],ze()}decodeRasterArray(Se,ze){i.bs.performDecoding(Se.buffer,Se.task).then(st=>ze(null,st)).catch(st=>ze(st))}}const X=i.fB.prototype.toGeoJSON;class se{constructor(Se){this._feature=Se,this.extent=i.al,this.type=Se.type,this.properties=Se.tags,"id"in Se&&!isNaN(Se.id)&&(this.id=parseInt(Se.id,10))}loadGeometry(){if(this._feature.type===1){const Se=[];for(const ze of this._feature.geometry)Se.push([new i.P(ze[0],ze[1])]);return Se}{const Se=[];for(const ze of this._feature.geometry){const st=[];for(const Tt of ze)st.push(new i.P(Tt[0],Tt[1]));Se.push(st)}return Se}}toGeoJSON(Se,ze,st){return X.call(this,Se,ze,st)}}class te{constructor(Se,ze){this.name=Se,this.extent=i.al,this.length=ze.length,this._jsonFeatures=ze}feature(Se){return new se(this._jsonFeatures[Se])}}class Y{constructor(Se){this.layers={},this.extent=i.al;for(const ze of Object.keys(Se))this.layers[ze]=new te(ze,Se[ze])}}const de=64/4096,ie=128;class ae{constructor(){this.features=new Map}clear(){this.features.clear()}load(Se=[],ze){for(const st of Se){const Tt=st.id;if(Tt==null)continue;let Nt=this.features.get(Tt);Nt&&this.updateCache(Nt,ze),st.geometry?(Nt=pe(st),this.updateCache(Nt,ze),this.features.set(Tt,Nt)):this.features.delete(Tt),this.updateCache(Nt,ze)}}updateCache(Se,ze){for(const{canonical:st,uid:Tt}of Object.values(ze)){const{z:Nt,x:Bt,y:Yt}=st;le(Se,Math.pow(2,Nt),Bt,Yt)&&delete ze[Tt]}}getTile(Se,ze,st){const Tt=Math.pow(2,Se),Nt=[];for(const Bt of this.features.values())le(Bt,Tt,ze,st)&&Nt.push(Ne(Bt,Tt,ze,st));return{features:Nt}}getFeatures(){return[...this.features.values()]}}function le({minX:ct,minY:Se,maxX:ze,maxY:st},Tt,Nt,Bt){return ct<(Nt+1+de)/Tt&&Se<(Bt+1+de)/Tt&&ze>(Nt-de)/Tt&&st>(Bt-de)/Tt}function pe(ct){const{id:Se,geometry:ze,properties:st}=ct;if(!ze)return;if(ze.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:Tt,coordinates:Nt}=ze,Bt={id:Se,type:1,geometry:[],tags:st,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Yt=Bt.geometry;if(Tt==="Point")be(Nt,Yt,Bt);else if(Tt==="MultiPoint")for(const Ut of Nt)be(Ut,Yt,Bt);else if(Tt==="LineString")Bt.type=2,ye(Nt,Yt,Bt);else if(Tt==="MultiLineString")Bt.type=2,we(Nt,Yt,Bt);else if(Tt==="Polygon")Bt.type=3,we(Nt,Yt,Bt,!0);else{if(Tt!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");Bt.type=3;for(const Ut of Nt)we(Ut,Yt,Bt,!0)}return Bt}function be([ct,Se],ze,st){const Tt=i.aF(ct);let Nt=i.aJ(Se);Nt=Nt<0?0:Nt>1?1:Nt,ze.push(Tt,Nt),st.minX=Math.min(st.minX,Tt),st.minY=Math.min(st.minY,Nt),st.maxX=Math.max(st.maxX,Tt),st.maxY=Math.max(st.maxY,Nt)}function ye(ct,Se,ze,st=!1,Tt=!1){const Nt=[];for(const Bt of ct)be(Bt,Nt,ze);Se.push(Nt),st&&function(Bt,Yt){let Ut=0;for(let Jt=0,Is=Bt.length,xs=Is-2;Jt0===Yt)for(let Jt=0,Is=Bt.length;Jt=Bt&&xs>=Bt||(Jt>=Bt?(Is+=Math.round(cr*((Bt-Jt)/$r)),Jt=Bt):xs>=Bt&&(pr=Is+Math.round(cr*((Bt-Jt)/$r)),xs=Bt),Is>=Bt&&pr>=Bt||(Is>=Bt?(Jt+=Math.round($r*((Bt-Is)/cr)),Is=Bt):pr>=Bt&&(xs=Jt+Math.round($r*((Bt-Is)/cr)),pr=Bt),Yt&&Jt===Yt[Yt.length-1][0]&&Is===Yt[Yt.length-1][1]||(Yt=[[Jt,Is]],Tt.push(Yt)),Yt.push([xs,pr])))))}}function _e(ct,Se,ze,st,Tt){const Nt=(ze-de)/Se,Bt=(st-de)/Se,Yt=(ze+1+de)/Se,Ut=(st+1+de)/Se;function Jt(pr,$r){let cr=0;return prYt&&(cr|=2),$rUt&&(cr|=8),cr}let Is=[];for(let pr=1;pr<=8;pr*=2){let $r=ct[ct.length-2],cr=ct[ct.length-1],Cn=!(Jt($r,cr)&pr);for(let Mn=0;Mn>31}function ut(ct,Se){const{geometry:ze,type:st}=ct;let Tt=0,Nt=0;if(st===1){Se.writeVarint(Ae(1,ze.length));for(const Bt of ze){const Yt=Bt[0]-Tt,Ut=Bt[1]-Nt;Se.writeVarint(Ue(Yt)),Se.writeVarint(Ue(Ut)),Tt+=Yt,Nt+=Ut}}else for(const Bt of ze){Se.writeVarint(Ae(1,1));const Yt=Bt.length-(st===3?1:0);for(let Ut=0;Utct},he=Math.fround||(Ve=new Float32Array(1),ct=>(Ve[0]=+ct,Ve[0]));var Ve;const nt=3,Qe=5,ke=6;class ot{constructor(Se){this.options=Object.assign(Object.create(Dt),Se),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(Se){const{log:ze,minZoom:st,maxZoom:Tt}=this.options;ze&&console.time("total time");const Nt=`prepare ${Se.length} points`;ze&&console.time(Nt),this.points=Se;const Bt=[];for(let Ut=0;Ut=st;Ut--){const Jt=+Date.now();Yt=this.trees[Ut]=this._createTree(this._cluster(Yt,Ut)),ze&&console.log("z%d: %d clusters in %dms",Ut,Yt.numItems,+Date.now()-Jt)}return ze&&console.timeEnd("total time"),this}getClusters(Se,ze){let st=((Se[0]+180)%360+360)%360-180;const Tt=Math.max(-90,Math.min(90,Se[1]));let Nt=Se[2]===180?180:((Se[2]+180)%360+360)%360-180;const Bt=Math.max(-90,Math.min(90,Se[3]));if(Se[2]-Se[0]>=360)st=-180,Nt=180;else if(st>Nt){const xs=this.getClusters([st,Tt,180,Bt],ze),pr=this.getClusters([-180,Tt,Nt,Bt],ze);return xs.concat(pr)}const Yt=this.trees[this._limitZoom(ze)],Ut=Yt.range(We(st),Ye(Bt),We(Nt),Ye(Tt)),Jt=Yt.data,Is=[];for(const xs of Ut){const pr=this.stride*xs;Is.push(Jt[pr+Qe]>1?qe(Jt,pr,this.clusterProps):this.points[Jt[pr+nt]])}return Is}getChildren(Se){const ze=this._getOriginId(Se),st=this._getOriginZoom(Se),Tt="No cluster with the specified id.",Nt=this.trees[st];if(!Nt)throw new Error(Tt);const Bt=Nt.data;if(ze*this.stride>=Bt.length)throw new Error(Tt);const Yt=this.options.radius/(this.options.extent*Math.pow(2,st-1)),Ut=Nt.within(Bt[ze*this.stride],Bt[ze*this.stride+1],Yt),Jt=[];for(const Is of Ut){const xs=Is*this.stride;Bt[xs+4]===Se&&Jt.push(Bt[xs+Qe]>1?qe(Bt,xs,this.clusterProps):this.points[Bt[xs+nt]])}if(Jt.length===0)throw new Error(Tt);return Jt}getLeaves(Se,ze,st){const Tt=[];return this._appendLeaves(Tt,Se,ze=ze||10,st=st||0,0),Tt}getTile(Se,ze,st){const Tt=this.trees[this._limitZoom(Se)],Nt=Math.pow(2,Se),{extent:Bt,radius:Yt}=this.options,Ut=Yt/Bt,Jt=(st-Ut)/Nt,Is=(st+1+Ut)/Nt,xs={features:[]};return this._addTileFeatures(Tt.range((ze-Ut)/Nt,Jt,(ze+1+Ut)/Nt,Is),Tt.data,ze,st,Nt,xs),ze===0&&this._addTileFeatures(Tt.range(1-Ut/Nt,Jt,1,Is),Tt.data,Nt,st,Nt,xs),ze===Nt-1&&this._addTileFeatures(Tt.range(0,Jt,Ut/Nt,Is),Tt.data,-1,st,Nt,xs),xs.features.length?xs:null}getClusterExpansionZoom(Se){let ze=this._getOriginZoom(Se)-1;for(;ze<=this.options.maxZoom;){const st=this.getChildren(Se);if(ze++,st.length!==1)break;Se=st[0].properties.cluster_id}return ze}_appendLeaves(Se,ze,st,Tt,Nt){const Bt=this.getChildren(ze);for(const Yt of Bt){const Ut=Yt.properties;if(Ut&&Ut.cluster?Nt+Ut.point_count<=Tt?Nt+=Ut.point_count:Nt=this._appendLeaves(Se,Ut.cluster_id,st,Tt,Nt):Nt1;let Is,xs,pr;if(Jt)Is=lt(ze,Ut,this.clusterProps),xs=ze[Ut],pr=ze[Ut+1];else{const Cn=this.points[ze[Ut+nt]];Is=Cn.properties;const[Mn,wn]=Cn.geometry.coordinates;xs=We(Mn),pr=Ye(wn)}const $r={type:1,geometry:[[Math.round(this.options.extent*(xs*Nt-st)),Math.round(this.options.extent*(pr*Nt-Tt))]],tags:Is};let cr;cr=Jt||this.options.generateId?ze[Ut+nt]:this.points[ze[Ut+nt]].id,cr!==void 0&&($r.id=cr),Bt.features.push($r)}}_limitZoom(Se){return Math.max(this.options.minZoom,Math.min(Math.floor(+Se),this.options.maxZoom+1))}_cluster(Se,ze){const{radius:st,extent:Tt,reduce:Nt,minPoints:Bt}=this.options,Yt=st/(Tt*Math.pow(2,ze)),Ut=Se.data,Jt=[],Is=this.stride;for(let xs=0;xsze&&(Mn+=Ut[ua+Qe])}if(Mn>Cn&&Mn>=Bt){let wn,ua=pr*Cn,co=$r*Cn,$o=-1;const Ha=(xs/Is<<5)+(ze+1)+this.points.length;for(const Wo of cr){const Xi=Wo*Is;if(Ut[Xi+2]<=ze)continue;Ut[Xi+2]=ze;const _a=Ut[Xi+Qe];ua+=Ut[Xi]*_a,co+=Ut[Xi+1]*_a,Ut[Xi+4]=Ha,Nt&&(wn||(wn=this._map(Ut,xs,!0),$o=this.clusterProps.length,this.clusterProps.push(wn)),Nt(wn,this._map(Ut,Xi)))}Ut[xs+4]=Ha,Jt.push(ua/Mn,co/Mn,1/0,Ha,-1,Mn),Nt&&Jt.push($o)}else{for(let wn=0;wn1)for(const wn of cr){const ua=wn*Is;if(!(Ut[ua+2]<=ze)){Ut[ua+2]=ze;for(let co=0;co>5}_getOriginZoom(Se){return(Se-this.points.length)%32}_map(Se,ze,st){if(Se[ze+Qe]>1){const Bt=this.clusterProps[Se[ze+ke]];return st?Object.assign({},Bt):Bt}const Tt=this.points[Se[ze+nt]].properties,Nt=this.options.map(Tt);return st&&Nt===Tt?Object.assign({},Nt):Nt}}function qe(ct,Se,ze){return{type:"Feature",id:ct[Se+nt],properties:lt(ct,Se,ze),geometry:{type:"Point",coordinates:[(st=ct[Se],360*(st-.5)),mt(ct[Se+1])]}};var st}function lt(ct,Se,ze){const st=ct[Se+Qe],Tt=st>=1e4?`${Math.round(st/1e3)}k`:st>=1e3?Math.round(st/100)/10+"k":st,Nt=ct[Se+ke],Bt=Nt===-1?{}:Object.assign({},ze[Nt]);return Object.assign(Bt,{cluster:!0,cluster_id:ct[Se+nt],point_count:st,point_count_abbreviated:Tt})}function We(ct){return ct/360+.5}function Ye(ct){const Se=Math.sin(ct*Math.PI/180),ze=.5-.25*Math.log((1+Se)/(1-Se))/Math.PI;return ze<0?0:ze>1?1:ze}function mt(ct){const Se=(180-360*ct)*Math.PI/180;return 360*Math.atan(Math.exp(Se))/Math.PI-90}function Ze(ct,Se,ze,st){let Tt=st;const Nt=Se+(ze-Se>>1);let Bt,Yt=ze-Se;const Ut=ct[Se],Jt=ct[Se+1],Is=ct[ze],xs=ct[ze+1];for(let pr=Se+3;prTt)Bt=pr,Tt=$r;else if($r===Tt){const cr=Math.abs(pr-Nt);crst&&(Bt-Se>3&&Ze(ct,Se,Bt,st),ct[Bt+2]=Tt,ze-Bt>3&&Ze(ct,Bt,ze,st))}function He(ct,Se,ze,st,Tt,Nt){let Bt=Tt-ze,Yt=Nt-st;if(Bt!==0||Yt!==0){const Ut=((ct-ze)*Bt+(Se-st)*Yt)/(Bt*Bt+Yt*Yt);Ut>1?(ze=Tt,st=Nt):Ut>0&&(ze+=Bt*Ut,st+=Yt*Ut)}return Bt=ct-ze,Yt=Se-st,Bt*Bt+Yt*Yt}function et(ct,Se,ze,st){const Tt={id:ct??null,type:Se,geometry:ze,tags:st,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(Se==="Point"||Se==="MultiPoint"||Se==="LineString")Rt(Tt,ze);else if(Se==="Polygon")Rt(Tt,ze[0]);else if(Se==="MultiLineString")for(const Nt of ze)Rt(Tt,Nt);else if(Se==="MultiPolygon")for(const Nt of ze)Rt(Tt,Nt[0]);return Tt}function Rt(ct,Se){for(let ze=0;ze0&&(Bt+=st?(Tt*Is-Jt*Nt)/2:Math.sqrt(Math.pow(Jt-Tt,2)+Math.pow(Is-Nt,2))),Tt=Jt,Nt=Is}const Yt=Se.length-3;Se[2]=1,Ze(Se,0,Yt,ze),Se[Yt+2]=1,Se.size=Math.abs(Bt),Se.start=0,Se.end=Se.size}function Qt(ct,Se,ze,st){for(let Tt=0;Tt1?1:ze}function bt(ct,Se,ze,st,Tt,Nt,Bt,Yt){if(st/=Se,Nt>=(ze/=Se)&&Bt=st)return null;const Ut=[];for(const Jt of ct){const Is=Jt.geometry;let xs=Jt.type;const pr=Tt===0?Jt.minX:Jt.minY,$r=Tt===0?Jt.maxX:Jt.maxY;if(pr>=ze&&$r=st)continue;let cr=[];if(xs==="Point"||xs==="MultiPoint")ks(Is,cr,ze,st,Tt);else if(xs==="LineString")ir(Is,cr,ze,st,Tt,!1,Yt.lineMetrics);else if(xs==="MultiLineString")ca(Is,cr,ze,st,Tt,!1);else if(xs==="Polygon")ca(Is,cr,ze,st,Tt,!0);else if(xs==="MultiPolygon")for(const Cn of Is){const Mn=[];ca(Cn,Mn,ze,st,Tt,!0),Mn.length&&cr.push(Mn)}if(cr.length){if(Yt.lineMetrics&&xs==="LineString"){for(const Cn of cr)Ut.push(et(Jt.id,xs,Cn,Jt.tags));continue}xs!=="LineString"&&xs!=="MultiLineString"||(cr.length===1?(xs="LineString",cr=cr[0]):xs="MultiLineString"),xs!=="Point"&&xs!=="MultiPoint"||(xs=cr.length===3?"Point":"MultiPoint"),Ut.push(et(Jt.id,xs,cr,Jt.tags))}}return Ut.length?Ut:null}function ks(ct,Se,ze,st,Tt){for(let Nt=0;Nt=ze&&Bt<=st&&ii(Se,ct[Nt],ct[Nt+1],ct[Nt+2])}}function ir(ct,Se,ze,st,Tt,Nt,Bt){let Yt=Rr(ct);const Ut=Tt===0?lo:Oa;let Jt,Is,xs=ct.start;for(let Mn=0;Mnze&&(Is=Ut(Yt,wn,ua,$o,Ha,ze),Bt&&(Yt.start=xs+Jt*Is)):Wo>st?Xi=ze&&(Is=Ut(Yt,wn,ua,$o,Ha,ze),_a=!0),Xi>st&&Wo<=st&&(Is=Ut(Yt,wn,ua,$o,Ha,st),_a=!0),!Nt&&_a&&(Bt&&(Yt.end=xs+Jt*Is),Se.push(Yt),Yt=Rr(ct)),Bt&&(xs+=Jt)}let pr=ct.length-3;const $r=ct[pr],cr=ct[pr+1],Cn=Tt===0?$r:cr;Cn>=ze&&Cn<=st&&ii(Yt,$r,cr,ct[pr+2]),pr=Yt.length-3,Nt&&pr>=3&&(Yt[pr]!==Yt[0]||Yt[pr+1]!==Yt[1])&&ii(Yt,Yt[0],Yt[1],Yt[2]),Yt.length&&Se.push(Yt)}function Rr(ct){const Se=[];return Se.size=ct.size,Se.start=ct.start,Se.end=ct.end,Se}function ca(ct,Se,ze,st,Tt,Nt){for(const Bt of ct)ir(Bt,Se,ze,st,Tt,Nt,!1)}function ii(ct,Se,ze,st){ct.push(Se,ze,st)}function lo(ct,Se,ze,st,Tt,Nt){const Bt=(Nt-Se)/(st-Se);return ii(ct,Nt,ze+(Tt-ze)*Bt,1),Bt}function Oa(ct,Se,ze,st,Tt,Nt){const Bt=(Nt-ze)/(Tt-ze);return ii(ct,Se+(st-Se)*Bt,Nt,1),Bt}function yn(ct,Se){const ze=[];for(let st=0;st0&&Se.size<(Tt?Bt:st))return void(ze.numPoints+=Se.length/3);const Yt=[];for(let Ut=0;UtBt)&&(ze.numSimplified++,Yt.push(Se[Ut],Se[Ut+1])),ze.numPoints++;Tt&&function(Ut,Jt){let Is=0;for(let xs=0,pr=Ut.length,$r=pr-2;xs0===Jt)for(let xs=0,pr=Ut.length;xs24)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 Tt=function(Nt,Bt){const Yt=[];if(Nt.type==="FeatureCollection")for(let Ut=0;Ut1&&console.time("creation"),$r=this.tiles[pr]=Gr(Se,ze,st,Tt,Jt),this.tileCoords.push({z:ze,x:st,y:Tt}),Is)){Is>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",ze,st,Tt,$r.numFeatures,$r.numPoints,$r.numSimplified),console.timeEnd("creation"));const _a=`z${ze}`;this.stats[_a]=(this.stats[_a]||0)+1,this.total++}if($r.source=Se,Nt==null){if(ze===Jt.indexMaxZoom||$r.numPoints<=Jt.indexMaxPoints)continue}else{if(ze===Jt.maxZoom||ze===Nt)continue;if(Nt!=null){const _a=Nt-ze;if(st!==Bt>>_a||Tt!==Yt>>_a)continue}}if($r.source=null,Se.length===0)continue;Is>1&&console.time("clipping");const cr=.5*Jt.buffer/Jt.extent,Cn=.5-cr,Mn=.5+cr,wn=1+cr;let ua=null,co=null,$o=null,Ha=null,Wo=bt(Se,xs,st-cr,st+Mn,0,$r.minX,$r.maxX,Jt),Xi=bt(Se,xs,st+Cn,st+wn,0,$r.minX,$r.maxX,Jt);Se=null,Wo&&(ua=bt(Wo,xs,Tt-cr,Tt+Mn,1,$r.minY,$r.maxY,Jt),co=bt(Wo,xs,Tt+Cn,Tt+wn,1,$r.minY,$r.maxY,Jt),Wo=null),Xi&&($o=bt(Xi,xs,Tt-cr,Tt+Mn,1,$r.minY,$r.maxY,Jt),Ha=bt(Xi,xs,Tt+Cn,Tt+wn,1,$r.minY,$r.maxY,Jt),Xi=null),Is>1&&console.timeEnd("clipping"),Ut.push(ua||[],ze+1,2*st,2*Tt),Ut.push(co||[],ze+1,2*st,2*Tt+1),Ut.push($o||[],ze+1,2*st+1,2*Tt),Ut.push(Ha||[],ze+1,2*st+1,2*Tt+1)}}getTile(Se,ze,st){Se=+Se,ze=+ze,st=+st;const Tt=this.options,{extent:Nt,debug:Bt}=Tt;if(Se<0||Se>24)return null;const Yt=1<1&&console.log("drilling down to z%d-%d-%d",Se,ze,st);let Jt,Is=Se,xs=ze,pr=st;for(;!Jt&&Is>0;)Is--,xs>>=1,pr>>=1,Jt=this.tiles[Va(Is,xs,pr)];return Jt&&Jt.source?(Bt>1&&(console.log("found parent tile z%d-%d-%d",Is,xs,pr),console.time("drilling down")),this.splitTile(Jt.source,Is,xs,pr,Se,ze,st),Bt>1&&console.timeEnd("drilling down"),this.tiles[Ut]?Zt(this.tiles[Ut],Nt):null):null}}function Va(ct,Se,ze){return 32*((1<Jt.tags&&"3d_elevation_id"in Jt.tags&&"source"in Jt.tags&&Jt.tags.source==="elevation",Nt=st.features.filter(Jt=>Tt(Jt));let Bt={_geojsonTileLayer:st.features};Nt.length>0&&(Bt={_geojsonTileLayer:st.features.filter(Jt=>!Tt(Jt)),hd_road_elevation:Nt});const Yt=new Y(Bt),Ut=function(Jt){const Is=new i.bt;for(const xs of Object.keys(Jt))Is.writeMessage(3,Me,{name:xs,features:Jt[xs]});return Is.finish()}(Bt).buffer;Se(null,{vectorTile:Yt,rawData:Ut})}class Za extends ${constructor(Se,ze,st,Tt,Nt,Bt,Yt){super(Se,ze,st,Tt,Nt,Jr,Yt),Bt&&(this.loadGeoJSON=Bt),this._dynamicIndex=new ae}loadData(Se,ze){const st=Se&&Se.request,Tt=st&&st.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(Se,(Nt,Bt)=>{if(Nt||!Bt)return ze(Nt);if(typeof Bt!="object")return ze(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`));{try{if(Se.filter){const Ut=i.U(Se.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Ut.result==="error")throw new Error(Ut.value.map(Jt=>`${Jt.key}: ${Jt.message}`).join(", "));Bt.features=Bt.features.filter(Jt=>Ut.value.evaluate({zoom:0},Jt))}Se.dynamic?(Bt.type==="Feature"&&(Bt={type:"FeatureCollection",features:[Bt]}),Se.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(Bt.features,this.loaded),Se.cluster&&(Bt.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=Se.cluster?new ot(function({superclusterOptions:Ut,clusterProperties:Jt}){if(!Jt||!Ut)return Ut;const Is={},xs={},pr={accumulated:null,zoom:0},$r={properties:null},cr=Object.keys(Jt);for(const Cn of cr){const[Mn,wn]=Jt[Cn],ua=i.U(wn),co=i.U(typeof Mn=="string"?[Mn,["accumulated"],["get",Cn]]:Mn);Is[Cn]=ua.value,xs[Cn]=co.value}return Ut.map=Cn=>{$r.properties=Cn;const Mn={};for(const wn of cr)Mn[wn]=Is[wn].evaluate(pr,$r);return Mn},Ut.reduce=(Cn,Mn)=>{$r.properties=Mn;for(const wn of cr)pr.accumulated=Cn[wn],Cn[wn]=xs[wn].evaluate(pr,$r)},Ut}(Se)).load(Bt.features):Se.dynamic?this._dynamicIndex:function(Ut,Jt){return new da(Ut,Jt)}(Bt,Se.geojsonVtOptions)}catch(Ut){return ze(Ut)}const Yt={};if(Tt){const Ut=d(st);Ut&&(Yt.resourceTiming={},Yt.resourceTiming[Se.source]=JSON.parse(JSON.stringify(Ut)))}ze(null,Yt)}})}reloadTile(Se,ze){const st=this.loaded;return st&&st[Se.uid]?Se.partial?ze(null,void 0):super.reloadTile(Se,ze):this.loadTile(Se,ze)}loadGeoJSON(Se,ze){if(Se.request)i.m(Se.request,ze);else{if(typeof Se.data!="string")return ze(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return ze(null,JSON.parse(Se.data))}catch{return ze(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(Se,ze){try{ze(null,this._geoJSONIndex.getClusterExpansionZoom(Se.clusterId))}catch(st){ze(st)}}getClusterChildren(Se,ze){try{ze(null,this._geoJSONIndex.getChildren(Se.clusterId))}catch(st){ze(st)}}getClusterLeaves(Se,ze){try{ze(null,this._geoJSONIndex.getLeaves(Se.clusterId,Se.limit,Se.offset))}catch(st){ze(st)}}}class $l{constructor(Se,ze,st){this.tileID=new i.aQ(Se.tileID.overscaledZ,Se.tileID.wrap,Se.tileID.canonical.z,Se.tileID.canonical.x,Se.tileID.canonical.y),this.tileZoom=Se.tileZoom,this.uid=Se.uid,this.zoom=Se.zoom,this.canonical=Se.tileID.canonical,this.pixelRatio=Se.pixelRatio,this.tileSize=Se.tileSize,this.source=Se.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=Se.projection,this.brightness=ze,this.worldview=st}parse(Se,ze,st,Tt){this.status="parsing";const Nt=new i.aQ(st.tileID.overscaledZ,st.tileID.wrap,st.tileID.canonical.z,st.tileID.canonical.x,st.tileID.canonical.y),Bt=[],Yt=ze.familiesBySource[st.source],Ut=new i.fn(Nt,st.promoteId);Ut.bucketLayerIDs=[],Ut.is3DTile=!0,i.fC(Se).then(Jt=>{if(!Jt)return Tt(new Error("Could not parse tile"));const Is=Jt.json.extensionsUsed&&Jt.json.extensionsUsed.includes("MAPBOX_mesh_features")||Jt.json.asset.extras&&Jt.json.asset.extras.MAPBOX_mesh_features,xs=Jt.json.extensionsUsed&&Jt.json.extensionsUsed.includes("EXT_meshopt_compression"),pr=new i.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const $r in Yt)for(const cr of Yt[$r]){const Cn=cr[0];Ut.bucketLayerIDs.push(cr.map(ua=>i.B(ua.id,ua.scope))),Cn.recalculate(pr,[]);const Mn=i.fD(Jt,1/i.d7(st.tileID.canonical)),wn=new i.fE(cr,Mn,Nt,Is,xs,this.brightness,Ut,this.worldview);Is||(wn.needsUpload=!0),Bt.push(wn),wn.evaluate(Cn)}this.status="done",Tt(null,{buckets:Bt,featureIndex:Ut,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Jt=>Tt(new Error(Jt.message)))}}class Do{constructor(Se,ze,st,Tt,Nt,Bt,Yt,Ut){this.actor=Se,this.layerIndex=ze,this.availableImages=st,this.availableModels=Tt,this.brightness=Yt,this.loading={},this.loaded={},this.worldview=Ut}loadTile(Se,ze){const st=Se.uid,Tt=this.loading[st]=new $l(Se,this.brightness,this.worldview);i.bu(Se.request,(Nt,Bt)=>{const Yt=!this.loading[st];return delete this.loading[st],Yt||Nt?(Tt.status="done",Yt||(this.loaded[st]=Tt),ze(Nt)):Bt&&Bt.byteLength!==0?void Tt.parse(Bt,this.layerIndex,Se,(Ut,Jt)=>{Tt.status="done",this.loaded=this.loaded||{},this.loaded[st]=Tt,Ut||!Jt?ze(Ut):ze(null,Jt)}):(Tt.status="done",this.loaded[st]=Tt,ze())})}reloadTile(Se,ze){const st=this.loaded,Tt=Se.uid;if(st&&st[Tt]){const Nt=st[Tt];Nt.projection=Se.projection,Nt.brightness=Se.brightness;const Bt=(Yt,Ut)=>{Nt.reloadCallback&&(delete Nt.reloadCallback,this.loadTile(Se,ze)),ze(Yt,Ut)};Nt.status==="parsing"?Nt.reloadCallback=Bt:Nt.status==="done"&&this.loadTile(Se,ze)}}abortTile(Se,ze){const st=Se.uid;this.loading[st]&&delete this.loading[st],ze()}removeTile(Se,ze){const st=this.loaded,Tt=Se.uid;st&&st[Tt]&&delete st[Tt],ze()}}class Yc{constructor(Se){this.self=Se,this.actor=new i.fG(Se,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:Za,"raster-dem":q,"raster-array":V,"batched-model":Do},this.workerSources={},this.self.registerWorkerSource=(ze,st)=>{if(this.workerSourceTypes[ze])throw new Error(`Worker source with name "${ze}" already registered.`);this.workerSourceTypes[ze]=st},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 st of this.rtlPluginParsingListeners)st(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(Se,ze,st){delete this.layerIndexes[Se],delete this.availableImages[Se],delete this.availableModels[Se],delete this.workerSources[Se],st()}checkIfReady(Se,ze,st){st()}setReferrer(Se,ze){this.referrer=ze}spriteLoaded(Se,ze){this.isSpriteLoaded[Se]||(this.isSpriteLoaded[Se]={});const{scope:st,isLoaded:Tt}=ze;if(this.isSpriteLoaded[Se][st]=Tt,this.workerSources[Se]&&this.workerSources[Se][st])for(const Nt in this.workerSources[Se][st]){const Bt=this.workerSources[Se][st][Nt];for(const Yt in Bt){const Ut=Bt[Yt];Ut instanceof $&&(Ut.isSpriteLoaded=Tt,Ut.fire(new i.z("isSpriteLoaded")))}}}setImages(Se,ze,st){this.availableImages[Se]||(this.availableImages[Se]={});const{scope:Tt,images:Nt}=ze;if(this.availableImages[Se][Tt]=Nt,this.workerSources[Se]&&this.workerSources[Se][Tt]){for(const Bt in this.workerSources[Se][Tt]){const Yt=this.workerSources[Se][Tt][Bt];for(const Ut in Yt)Yt[Ut].availableImages=Nt}st()}else st()}setModels(Se,{scope:ze,models:st},Tt){if(this.availableModels[Se]||(this.availableModels[Se]={}),this.availableModels[Se][ze]=st,this.workerSources[Se]&&this.workerSources[Se][ze]){for(const Nt in this.workerSources[Se][ze]){const Bt=this.workerSources[Se][ze][Nt];for(const Yt in Bt)Bt[Yt].availableModels=st}Tt()}else Tt()}setProjection(Se,ze){this.projections[Se]=i.cm(ze)}setBrightness(Se,ze,st){this.brightness=ze,st()}setWorldview(Se,ze,st){this.worldview=ze,st()}setLayers(Se,ze,st){this.getLayerIndex(Se,ze.scope).replace(ze.layers,ze.options),st()}updateLayers(Se,ze,st){this.getLayerIndex(Se,ze.scope).update(ze.layers,ze.removedIds,ze.options),st()}loadTile(Se,ze,st){ze.projection=this.projections[Se]||this.defaultProjection,this.getWorkerSource(Se,ze.type,ze.source,ze.scope).loadTile(ze,st)}decodeRasterArray(Se,ze,st){this.getWorkerSource(Se,ze.type,ze.source,ze.scope).decodeRasterArray(ze,st)}reloadTile(Se,ze,st){ze.projection=this.projections[Se]||this.defaultProjection,this.getWorkerSource(Se,ze.type,ze.source,ze.scope).reloadTile(ze,st)}abortTile(Se,ze,st){this.getWorkerSource(Se,ze.type,ze.source,ze.scope).abortTile(ze,st)}removeTile(Se,ze,st){this.getWorkerSource(Se,ze.type,ze.source,ze.scope).removeTile(ze,st)}removeSource(Se,ze,st){if(!(this.workerSources[Se]&&this.workerSources[Se][ze.scope]&&this.workerSources[Se][ze.scope][ze.type]&&this.workerSources[Se][ze.scope][ze.type][ze.source]))return;const Tt=this.workerSources[Se][ze.scope][ze.type][ze.source];delete this.workerSources[Se][ze.scope][ze.type][ze.source],Tt.removeSource!==void 0?Tt.removeSource(ze,st):st()}loadWorkerSource(Se,ze,st){try{this.self.importScripts(ze.url),st()}catch(Tt){st(Tt)}}syncRTLPluginState(Se,ze,st){if(i.fH.isParsed())st(null,!0);else if(i.fH.isParsing())this.rtlPluginParsingListeners.push(st);else try{i.fH.setState(ze);const Tt=i.fH.getPluginURL();!i.fH.isLoaded()||i.fH.isParsed()||i.fH.isParsing()||Tt==null||(i.fH.setState({pluginStatus:i.fI.parsing,pluginURL:i.fH.getPluginURL()}),this.self.importScripts(Tt),i.fH.isParsed()?st(null,!0):this.rtlPluginParsingListeners.push(st))}catch(Tt){st(Tt)}}setDracoUrl(Se,ze){this.dracoUrl=ze}getAvailableImages(Se,ze){this.availableImages[Se]||(this.availableImages[Se]={});let st=this.availableImages[Se][ze];return st||(st=[]),st}getAvailableModels(Se,ze){this.availableModels[Se]||(this.availableModels[Se]={});let st=this.availableModels[Se][ze];return st||(st={}),st}getLayerIndex(Se,ze){this.layerIndexes[Se]||(this.layerIndexes[Se]={});let st=this.layerIndexes[Se][ze];return st||(st=this.layerIndexes[Se][ze]=new g,st.scope=ze),st}getWorkerSource(Se,ze,st,Tt){const Nt=this.workerSources;return Nt[Se]||(Nt[Se]={}),Nt[Se][Tt]||(Nt[Se][Tt]={}),Nt[Se][Tt][ze]||(Nt[Se][Tt][ze]={}),this.isSpriteLoaded[Se]||(this.isSpriteLoaded[Se]={}),Nt[Se][Tt][ze][st]||(Nt[Se][Tt][ze][st]=new this.workerSourceTypes[ze]({send:(Bt,Yt,Ut,Jt,Is,xs)=>this.actor.send(Bt,Yt,Ut,Se,Is,xs),scheduler:this.actor.scheduler},this.getLayerIndex(Se,Tt),this.getAvailableImages(Se,Tt),this.getAvailableModels(Se,Tt),this.isSpriteLoaded[Se][Tt],void 0,this.brightness,this.worldview)),Nt[Se][Tt][ze][st]}rasterizeImagesWorker(Se,ze,st){const Tt=new Map;for(const[Nt,{image:Bt,imageVariant:Yt}]of ze.tasks.entries()){const Ut=this.imageRasterizer.rasterize(Yt,Bt,ze.scope,Se);Tt.set(Nt,Ut)}st(void 0,Tt)}removeRasterizedImages(Se,ze,st){this.imageRasterizer.removeImagesFromCacheByIds(ze.imageIds,ze.scope,Se),st()}enforceCacheSizeLimit(Se,ze){i.fJ(ze)}getWorkerPerformanceMetrics(Se,ze,st){st(void 0,void 0)}}return i.fF(self)&&(self.worker=new Yc(self)),Yc}),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 g(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 v,_={},b=function(){if(v)return _;function M(T){return!h(T)}function h(T){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,H=new Blob([""],{type:"text/javascript"}),Q=URL.createObjectURL(H);try{z=new Worker(Q),F=!0}catch{F=!1}return z&&z.terminate(),URL.revokeObjectURL(Q),F}()?function(){var F=document.createElement("canvas");F.width=F.height=1;var z=F.getContext("2d");if(!z)return!1;var H=z.getImageData(0,0,1,1);return H&&H.width===F.width}()?(x[D=T&&T.failIfMajorPerformanceCaveat]===void 0&&(x[D]=function(F){var z,H=function(Q){var re=document.createElement("canvas"),oe=Object.create(M.webGLContextAttributes);return oe.failIfMajorPerformanceCaveat=Q,re.getContext("webgl2",oe)}(F);if(!H)return!1;try{z=H.createShader(H.VERTEX_SHADER)}catch{return!1}return!(!z||H.isContextLost())&&(H.shaderSource(z,"void main() {}"),H.compileShader(z),H.getShaderParameter(z,H.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}v=1,_.supported=M,_.notSupportedReason=h;var x={};return M.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},_}();function j(M,h,x){const T=document.createElement(M);return h!=null&&(T.className=h),x&&x.appendChild(T),T}function w(M,h,x){const T=document.createElementNS("http://www.w3.org/2000/svg",M);for(const D of Object.keys(h))T.setAttributeNS(null,D,String(h[D]));return x&&x.appendChild(T),T}const N=typeof document<"u"?document.documentElement&&document.documentElement.style:null,C=N&&N.userSelect!==void 0?"userSelect":"WebkitUserSelect";let A;function I(){N&&C&&(A=N[C],N[C]="none")}function L(){N&&C&&(N[C]=A)}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 X(M,x,h)}function U(M,h){const x=M.getBoundingClientRect(),T=[];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 T=ie(h);return T.params.push(`sdk=js-${d}`),T.path=`/styles/v1${T.path}`,this._makeAPIURL(T,this._customAccessToken||x)}normalizeGlyphsURL(h,x){if(!i.h(h))return h;const T=ie(h);return T.path=`/fonts/v1${T.path}`,this._makeAPIURL(T,this._customAccessToken||x)}normalizeModelURL(h,x){if(!i.h(h))return h;const T=ie(h);return T.path=`/models/v1${T.path}`,this._makeAPIURL(T,this._customAccessToken||x)}normalizeSourceURL(h,x,T,D){if(!i.h(h))return h;const F=ie(h);return F.path=`/v4/${F.authority}.json`,F.params.push("secure"),T&&F.params.push(`language=${T}`),D&&F.params.push(`worldview=${D}`),this._makeAPIURL(F,this._customAccessToken||x)}normalizeIconsetURL(h,x){const T=ie(h);return i.h(h)?(T.path=`/styles/v1${T.path}/iconset.pbf`,this._makeAPIURL(T,this._customAccessToken||x)):ae(T)}normalizeSpriteURL(h,x,T,D){const F=ie(h);return i.h(h)?(F.path=`/styles/v1${F.path}/sprite${x}${T}`,this._makeAPIURL(F,this._customAccessToken||D)):(F.path+=`${x}${T}`,ae(F))}normalizeTileURL(h,x,T){if(this._isSkuTokenExpired()&&this._createSkuToken(),h&&!i.h(h))return h;const D=ie(h);D.path=D.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${x||T&&D.authority!=="raster"&&T===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 H of z){const Q=H.match(/^access_token=(.*)$/);if(Q)return Q[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 T=ie(h);if(!T.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!T.path.match(/\.[\w]+$/))return h;let D="mapbox://";T.path.match(/^\/raster\/v1\//)?D+=`raster/${T.path.replace(`/${i.e.RASTER_URL_PREFIX}/`,"")}`:T.path.match(/^\/rasterarrays\/v1\//)?D+=`rasterarrays/${T.path.replace(`/${i.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:D+=`tiles/${T.path.replace(`/${i.e.TILE_URL_VERSION}/`,"")}`;let F=T.params;return x&&(F=F.filter(z=>!z.match(/^access_token=/))),F.length&&(D+=`?${F.join("&")}`),D}canonicalizeTileset(h,x){const T=!!x&&i.h(x),D=[];for(const F of h.tiles||[])i.j(F)?D.push(this.canonicalizeTileURL(F,T)):D.push(F);return D}_makeAPIURL(h,x){const T="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",D=ie(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. ${T}`);if(x[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${T}`)}return h.params=h.params.filter(F=>F.indexOf("access_token")===-1),h.params.push(`access_token=${x||""}`),ae(h)}}const de=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ie(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 pe(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=pe(i.e.ACCESS_TOKEN);let T="";return T=x&&x.u?i.f(x.u):i.e.ACCESS_TOKEN||"",h?`${le}.${h}:${T}`:`${le}:${T}`}fetchEventData(){const h=i.s("localStorage"),x=this.getStorageKey(),T=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(T);z&&(this.anonId=z);const H=localStorage.getItem(D);H&&(this.anonIdTimestamp=Number(H));const Q=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,T,D){if(!i.e.EVENTS_URL)return;const F=ie(i.e.EVENTS_URL);F.params.push(`access_token=${D||i.e.ACCESS_TOKEN||""}`);const z={event:this.type,created:new Date(h).toISOString()},H=x?Object.assign(z,x):z,Q={url:ae(F),headers:{"Content-Type":"text/plain"},body:JSON.stringify([H])};this.pendingRequest=i.p(Q,re=>{this.pendingRequest=null,T(re),this.saveEventData(),this.processRequests(D)})}queueRequest(h,x){this.queue.push(h),this.processRequests(x)}}class ye 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:T}=this.queue.shift();this.postEvent(x,T,()=>{},h)}}const we=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=pe(i.e.ACCESS_TOKEN),x=h?h.u:i.e.ACCESS_TOKEN;let T=x!==this.eventData.tokenU;i.v(this.anonId)||(this.refreshUUID(),T=!0);const D=this.queue.shift();if(this.eventData.lastSuccess){const F=new Date(this.eventData.lastSuccess),z=new Date(D),H=(D-this.eventData.lastSuccess)/864e5;T=T||H>=1||H<-1||F.getDate()!==z.getDate()}else T=!0;T?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=we.postTurnstileEvent.bind(we),Ke=new class extends be{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(M,h,x,T){this.skuToken=h,this.errorCb=T,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},T=>{T?this.errorCb(T):h&&(this.success[h]=!0)},M))}remove(){this.errorCb=null}},_e=Ke.postMapLoadEvent.bind(Ke),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:T,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:T};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 ye({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Ae=Fe.postMetricsEvent.bind(Fe),Ue=new ye({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(),T=function(D){const F=performance.getEntriesByType("resource"),z=performance.getEntriesByType("mark"),H=function(xe){const Pe={};if(xe){for(const Ce in xe)if(Ce!=="other")for(const $e of xe[Ce]){const Be=`${Ce}ResolveRangeMin`,Je=`${Ce}ResolveRangeMax`,dt=`${Ce}RequestCount`,tt=`${Ce}RequestCachedCount`;Pe[Be]=Math.min(Pe[Be]||1/0,$e.startTime),Pe[Je]=Math.max(Pe[Je]||-1/0,$e.responseEnd);const Mt=vt=>{Pe[vt]===void 0&&(Pe[vt]=0),++Pe[vt]};$e.transferSize!==void 0&&$e.transferSize===0&&Mt(tt),Mt(dt)}}return Pe}(function(xe,Pe){const Ce={};if(xe)for(const $e of xe){const Be=Pe($e);Ce[Be]===void 0&&(Ce[Be]=[]),Ce[Be].push($e)}return Ce}(F,g)),Q=window.devicePixelRatio,re=navigator.connection||navigator.mozConnection||navigator.webkitConnection,oe=re?re.effectiveType:void 0,ge={counters:[],metadata:[],attributes:[]},me=(xe,Pe,Ce)=>{Ce!=null&&xe.push({name:Pe,value:Ce.toString()})};for(const xe in H)me(ge.counters,xe,H[xe]);if(D.interactionRange[0]!==1/0&&D.interactionRange[1]!==-1/0&&(me(ge.counters,"interactionRangeMin",D.interactionRange[0]),me(ge.counters,"interactionRangeMax",D.interactionRange[1])),z)for(const xe of Object.values(u)){const Pe=z.find(Ce=>Ce.name===xe);Pe&&me(ge.counters,xe,Pe.startTime)}return me(ge.counters,"visibilityHidden",D.visibilityHidden),me(ge.attributes,"style",function(xe){if(xe)for(const Pe of xe){const Ce=Pe.name.split("?")[0];if(i.i(Ce)){const $e=Ce.split("/").slice(-2);if($e.length===2)return`mapbox://styles/${$e[0]}/${$e[1]}`}}}(F)),me(ge.attributes,"terrainEnabled",D.terrainEnabled?"true":"false"),me(ge.attributes,"fogEnabled",D.fogEnabled?"true":"false"),me(ge.attributes,"projection",D.projection),me(ge.attributes,"zoom",D.zoom),me(ge.metadata,"devicePixelRatio",Q),me(ge.metadata,"connectionEffectiveType",oe),me(ge.metadata,"navigatorUserAgent",navigator.userAgent),me(ge.metadata,"screenWidth",window.screen.width),me(ge.metadata,"screenHeight",window.screen.height),me(ge.metadata,"windowWidth",window.innerWidth),me(ge.metadata,"windowHeight",window.innerHeight),me(ge.metadata,"mapWidth",D.width/Q),me(ge.metadata,"mapHeight",D.height/Q),me(ge.metadata,"webglRenderer",D.renderer),me(ge.metadata,"webglVendor",D.vendor),me(ge.metadata,"sdkVersion",d),me(ge.metadata,"sdkIdentifier","mapbox-gl-js"),ge}(x);for(const D of T.metadata);for(const D of T.counters);for(const D of T.attributes);this.postEvent(h,T,()=>{},M)}},Dt=De.postPerformanceEvent.bind(De),he=new class extends be{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(M,h,x,T){if(!i.e.API_URL||!i.e.SESSION_PATH)return;const D=ie(i.e.API_URL+i.e.SESSION_PATH);D.params.push(`sku=${h||""}`),D.params.push(`access_token=${T||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(T)})}getSessionAPI(M,h,x,T){this.skuToken=h,this.errorCb=T,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,T=>{T?this.errorCb(T):h&&(this.success[h]=!0)},M)}remove(){this.errorCb=null}},Ve=he.getSessionAPI.bind(he),nt=new Set;function Qe(M,h){h?nt.add(M):nt.delete(M)}class ke{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 ot(M){const{userImage:h}=M;return!!(h&&h.render&&h.render())&&(M.data.replace(new Uint8Array(h.data.buffer)),!0)}class qe 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 T of x.values())T.hasPendingRequests()&&h.push(T);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:T,callback:D}of this.requestors)this._notify(T,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,T){this._validate(h,T)&&this.images.get(x).set(h.toString(),T)}_validate(h,x){let T=!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`))),T=!1),this._validateStretch(x.stretchY,x.data&&x.data.height)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "stretchY" value`))),T=!1),this._validateContent(x.content,x)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "content" value`))),T=!1),T}_validateStretch(h,x){if(!h)return!0;let T=0;for(const D of h){if(D[0]i.I.from(x))}getImages(h,x,T){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,T);let H=!0;const Q=!!this.loaded.get(x),re=this.images.get(x);if(!Q)for(const oe of D)re.has(oe.toString())||(H=!1);Q||H?this._notify(D,x,T):this.requestors.push({ids:D,scope:x,callback:T})}rasterizeImages(h,x){const T=new Map,{tasks:D,scope:F}=h;for(const[z,H]of D.entries()){const Q=this.getImage(H.id,F);Q&&T.set(z,{image:Q,imageVariant:H})}this._rasterizeImages(F,T,x)}_rasterizeImages(h,x,T){if(i.r())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:x,scope:h},T);else{const D=new Map;for(const[F,{image:z,imageVariant:H}]of x.entries())D.set(F,this.imageRasterizer.rasterize(H,z,h,0));T(void 0,D)}}getUpdatedImages(h){return this.updatedImages.get(h)||new Set}_notify(h,x,T){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 H=D.get(z.toString());if(!H){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 Q={data:H.usvg?null:H.data.clone(),pixelRatio:H.pixelRatio,sdf:H.sdf,usvg:H.usvg,version:H.version,stretchX:H.stretchX,stretchY:H.stretchY,content:H.content,hasRenderCallback:!!(H.userImage&&H.userImage.render)};H.usvg&&Object.assign(Q,{width:H.icon.usvg_tree.width,height:H.icon.usvg_tree.height}),F.set(i.I.toString(z),Q)}T(null,F)}getPixelSize(h){const{width:x,height:T}=this.atlasImage.get(h);return{width:x,height:T}}getPattern(h,x,T){const D=h.toString(),F=this.patterns.get(x),z=F.get(D),H=this.getImage(h,x);if(!H)return null;if(z){if(z.position.version===H.version)return z.position;z.position.version=H.version}else{if(H.usvg&&!H.data){const Q=this.getPatternInFlightId(D,x);if(this.patternsInFlight.has(Q))return null;this.patternsInFlight.add(Q);const re=new i.A(h).scaleSelf(i.o.devicePixelRatio),oe=new Map([[re.toString(),{image:H,imageVariant:re}]]);return this._rasterizeImages(x,oe,(ge,me)=>this.storePatternImage(re,x,H,T,me)),null}this.storePattern(h,x,H)}return this._updatePatternAtlas(x,T),F.get(D).position}getPatternInFlightId(h,x){return i.B(h,x)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(h,x,T,D,F){const z=h.toString(),H=F?F.get(z):void 0;H&&(T.data=H,this.storePattern(h.id,x,T),this._updatePatternAtlas(x,D),this.patternsInFlight.delete(this.getPatternInFlightId(h.id.toString(),x)))}storePattern(h,x,T){const D={w:T.data.width+2*i.C,h:T.data.height+2*i.C,x:0,y:0},F=new i.F(D,T,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 T=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),T.RGBA8),this.atlasTexture.set(x,D)),D.bind(T.LINEAR,T.CLAMP_TO_EDGE)}_updatePatternAtlas(h,x){const T=this.patterns.get(h),D=Array.from(T.values()).map(({bin:re})=>re),{w:F,h:z}=i.G(D),H=this.atlasImage.get(h);H.resize({width:F||1,height:z||1});const Q=this.images.get(h);for(const[re,{bin:oe,position:ge}]of T.entries()){let me=ge.padding;const xe=oe.x+me,Pe=oe.y+me,Ce=Q.get(re).data,$e=Ce.width,Be=Ce.height;me=me>1?me-1:me,i.q.copy(Ce,H,{x:0,y:0},{x:xe,y:Pe},{width:$e,height:Be},x),i.q.copy(Ce,H,{x:0,y:Be-me},{x:xe,y:Pe-me},{width:$e,height:me},x),i.q.copy(Ce,H,{x:0,y:0},{x:xe,y:Pe+Be},{width:$e,height:me},x),i.q.copy(Ce,H,{x:$e-me,y:0},{x:xe-me,y:Pe},{width:me,height:Be},x),i.q.copy(Ce,H,{x:0,y:0},{x:xe+$e,y:Pe},{width:me,height:Be},x),i.q.copy(Ce,H,{x:$e-me,y:Be-me},{x:xe-me,y:Pe-me},{width:me,height:me},x),i.q.copy(Ce,H,{x:0,y:Be-me},{x:xe+$e,y:Pe-me},{width:me,height:me},x),i.q.copy(Ce,H,{x:0,y:0},{x:xe+$e,y:Pe+Be},{width:me,height:me},x),i.q.copy(Ce,H,{x:$e-me,y:0},{x:xe-me,y:Pe+Be},{width:me,height:me},x)}this.dirty=!0}beginFrame(){for(const h of this.images.keys())this.callbackDispatchedThisFrame.set(h,new Set)}dispatchRenderCallbacks(h,x){const T=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=T.get(D.toString());ot(F)&&this.updateImage(D,x,F)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function lt(M){const h=M.value,x=M.valueSpec,T=M.style,D=M.styleSpec,F=M.key,z=M.arrayElementValidator||yn;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 Ye(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 T=M.valueSpec,D=i.J(x.type);let F,z,H,Q={};const re=D!=="categorical"&&x.property===void 0,oe=!re,ge=function(Ce){const $e=Ce.stops;return Array.isArray($e)&&Array.isArray($e[0])&&i.H($e[0][0])}(x),me=ta({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 $e=[];const Be=Ce.value;return $e=$e.concat(lt({key:Ce.key,value:Be,valueSpec:Ce.valueSpec,style:Ce.style,styleSpec:Ce.styleSpec,arrayElementValidator:xe})),Array.isArray(Be)&&Be.length===0&&$e.push(new i.V(Ce.key,Be,"array must have at least one stop")),$e},default:function(Ce){return yn({key:Ce.key,value:Ce.value,valueSpec:T,style:Ce.style,styleSpec:Ce.styleSpec})}}});return D==="identity"&&re&&me.push(new i.V(M.key,M.value,'missing required property "property"')),D==="identity"||x.stops||me.push(new i.V(M.key,M.value,'missing required property "stops"')),D==="exponential"&&T.expression&&!i.M(T)&&me.push(new i.V(M.key,M.value,"exponential functions not supported")),M.styleSpec.$version>=8&&(oe&&!i.N(T)?me.push(new i.V(M.key,M.value,"property functions not supported")):re&&!i.O(T)&&me.push(new i.V(M.key,M.value,"zoom functions not supported"))),D!=="categorical"&&!ge||x.property!==void 0||me.push(new i.V(M.key,M.value,'"property" property is required')),me;function xe(Ce){let $e=[];const Be=Ce.value,Je=Ce.key;if(!Array.isArray(Be))return[new i.V(Je,Be,`array expected, ${i.K(Be)} found`)];if(Be.length!==2)return[new i.V(Je,Be,`array length 2 expected, length ${Be.length} found`)];if(ge){if(!i.H(Be[0]))return[new i.V(Je,Be,`object expected, ${i.K(Be[0])} found`)];const dt=Be[0];if(dt.zoom===void 0)return[new i.V(Je,Be,"object stop key must have zoom")];if(dt.value===void 0)return[new i.V(Je,Be,"object stop key must have value")];const tt=i.J(dt.zoom);if(typeof tt!="number")return[new i.V(Je,dt.zoom,"stop zoom values must be numbers")];if(H&&H>tt)return[new i.V(Je,dt.zoom,"stop zoom values must appear in ascending order")];tt!==H&&(H=tt,z=void 0,Q={}),$e=$e.concat(ta({key:`${Je}[0]`,value:Be[0],valueSpec:{zoom:{}},style:Ce.style,styleSpec:Ce.styleSpec,objectElementValidators:{zoom:We,value:Pe}}))}else $e=$e.concat(Pe({key:`${Je}[0]`,value:Be[0],style:Ce.style,styleSpec:Ce.styleSpec},Be));return i.Q(i.S(Be[1]))?$e.concat([new i.V(`${Je}[1]`,Be[1],"expressions are not allowed in function stops.")]):$e.concat(yn({key:`${Je}[1]`,value:Be[1],valueSpec:T,style:Ce.style,styleSpec:Ce.styleSpec}))}function Pe(Ce,$e){const Be=i.K(Ce.value),Je=i.J(Ce.value),dt=Ce.value!==null?Ce.value:$e;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 Je!="number"&&typeof Je!="string"&&typeof Je!="boolean")return[new i.V(Ce.key,dt,"stop domain value must be a number, string, or boolean")];if(Be!=="number"&&D!=="categorical"){let tt=`number expected, ${Be} found`;return i.N(T)&&D===void 0&&(tt+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new i.V(Ce.key,dt,tt)]}return D!=="categorical"||Be!=="number"||typeof Je=="number"&&isFinite(Je)&&Math.floor(Je)===Je?D!=="categorical"&&Be==="number"&&typeof Je=="number"&&typeof z=="number"&&z!==void 0&&Jenew i.V(`${M.key}${T.key}`,M.value,T.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 Ze(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 Ze(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 T=[];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=>{T.push(...Ze(D,h))}),T)}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 T=[];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=>{T.push(...He(D,h))}),T)}function et(M){const h=M.key,x=M.value,T=M.valueSpec,D=[];return Array.isArray(T.values)?T.values.indexOf(i.J(x))===-1&&D.push(new i.V(h,x,`expected one of [${T.values.join(", ")}], ${JSON.stringify(x)} found`)):Object.keys(T.values).indexOf(i.J(x))===-1&&D.push(new i.V(h,x,`expected one of [${Object.keys(T.values).join(", ")}], ${JSON.stringify(x)} found`)),D}function Rt(M){return i.a2(i.S(M.value))?mt(Object.assign({},M,{expressionContext:"filter",valueSpec:M.styleSpec[`filter_${M.layerType||"fill"}`]})):qt(M)}function qt(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 T=M.styleSpec;let D=et({key:`${x}[0]`,value:h[0],valueSpec:T.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{re in x&&h.push(new i.V(T,x[re],`"${re}" is prohibited for ref layers`))}),D.layers.forEach(re=>{i.J(re.id)===H&&(Q=re)}),Q?Q.ref?h.push(new i.V(T,x.ref,"ref cannot reference another ref layer")):z=i.J(Q.type):typeof H=="string"&&h.push(new i.V(T,x.ref,`ref layer "${H}" not found`))}else if(z!=="background"&&z!=="sky"&&z!=="slot")if(x.source)if(i.a0(x.source)){const Q=D.sources&&D.sources[x.source],re=Q&&i.J(Q.type);Q?re==="vector"&&z==="raster"?h.push(new i.V(T,x.source,`layer "${x.id}" requires a raster source`)):re==="raster"&&z!=="raster"?h.push(new i.V(T,x.source,`layer "${x.id}" requires a vector source`)):re!=="vector"||x["source-layer"]?re==="raster-dem"&&z!=="hillshade"?h.push(new i.V(T,x.source,"raster-dem source can only be used with layer type 'hillshade'.")):re!=="raster-array"||["raster","raster-particle"].includes(z)?z==="line"&&x.paint&&(x.paint["line-gradient"]||x.paint["line-trim-offset"])&&re==="geojson"&&!Q.lineMetrics?h.push(new i.V(T,x,`layer "${x.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):z==="raster-particle"&&re!=="raster-array"&&h.push(new i.V(T,x.source,`layer "${x.id}" requires a 'raster-array' source.`)):h.push(new i.V(T,x.source,"raster-array source can only be used with layer type 'raster'.")):h.push(new i.V(T,x,`layer "${x.id}" must specify a "source-layer"`)):h.push(new i.V(T,x.source,`source "${x.source}" not found`))}else h.push(new i.V(`${T}.source`,x.source,'"source" must be a string'));else h.push(new i.V(T,x,'missing required property "source"'));return h=h.concat(ta({key:T,value:x,valueSpec:F.layer,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{"*":()=>[],type:()=>yn({key:`${T}.type`,value:x.type,valueSpec:F.layer.type,style:M.style,styleSpec:M.styleSpec,object:x,objectKey:"type"}),filter:Q=>Rt(Object.assign({layerType:z},Q)),layout:Q=>ta({layer:x,key:Q.key,value:Q.value,valueSpec:{},style:Q.style,styleSpec:Q.styleSpec,objectElementValidators:{"*":re=>Qt(Object.assign({layerType:z},re))}}),paint:Q=>ta({layer:x,key:Q.key,value:Q.value,valueSpec:{},style:Q.style,styleSpec:Q.styleSpec,objectElementValidators:{"*":re=>Kt(Object.assign({layerType:z,layer:x},re))}}),appearances(Q){const re=lt({key:Q.key,value:Q.value,valueSpec:Q.valueSpec,style:Q.style,styleSpec:Q.styleSpec,arrayElementValidator:me=>function(xe){const{key:Pe,layer:Ce,layerType:$e}=xe,Be=i.J(xe.value),Je=i.J(Be.name),dt=i.J(Be.condition),tt=ta({key:Pe,value:Be,valueSpec:xe.styleSpec.appearance,style:xe.style,styleSpec:xe.styleSpec,objectElementValidators:{condition:Mt=>function(vt){const kt=[];return kt.push(...mt({key:vt.key,value:vt.object.condition,valueSpec:i.a6.appearance.condition,expressionContext:"appearance"})),kt}(Object.assign({layer:Ce,layerType:$e},Mt)),properties:Mt=>function(vt){const kt=[],{styleSpec:xt,layer:pt,layerType:Pt}=vt,Ht=xt[`paint_${Pt}`],Vt=xt[`layout_${Pt}`],ts=vt.object[vt.objectKey];for(const ss in ts){const ps=ss in Ht?"paint":ss in Vt?"layout":void 0;if(!ps){kt.push(new i.V(vt.key,ss,`unknown property "${ss}" for layer type "${Pt}"`));continue}const Bs=Object.assign({},vt,{key:`${vt.key}.${ss}`,object:ts,objectKey:ss,layer:pt,layerType:Pt,value:ts[ss],valueSpec:ps==="paint"?Ht[ss]:Vt[ss]});kt.push(...ls(Bs,ps))}return kt}(Object.assign({layer:Ce,layerType:$e},Mt))}});return Je!=="hidden"&&dt===void 0&&tt.push(new i.V(xe.key,"name",'Appearance with name different than "hidden" must have a condition')),tt}(Object.assign({layerType:z,layer:x},me))}),oe=Array.isArray(Q.value)?Q.value:[],ge=new Set;return oe.forEach((me,xe)=>{const Pe=i.J(me.name);if(Pe)if(ge.has(Pe)){const Ce=i.J(x.id);re.push(new i.V(Q.key,Pe,`Duplicated appearance name "${Pe}" for layer "${Ce}"`))}else ge.add(Pe)}),re}}})),h}function dr({key:M,value:h}){return i.a0(h)?[]:[new i.V(M,h,`string expected, ${i.K(h)} found`)]}const bt={promoteId:function M({key:h,value:x}){if(i.a0(x))return dr({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(H=>{D.push(new i.V(`${h}${H.key}`,null,`${H.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 T=[];for(const D in x)T.push(...M({key:`${h}.${D}`,value:x[D]}));return T}};function ks(M){const h=M.value,x=M.key,T=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(ta({key:x,value:h,valueSpec:T[`source_${F.replace("-","_")}`],style:M.style,styleSpec:T,objectElementValidators:bt})),z;case"geojson":if(z=ta({key:x,value:h,valueSpec:T.source_geojson,style:D,styleSpec:T,objectElementValidators:bt}),"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 H in h.clusterProperties){const Q=h.clusterProperties[H];if(!Array.isArray(Q))return[new i.V(`${x}.clusterProperties.${H}`,Q,"array expected")];const[re,oe]=Q,ge=typeof re=="string"?[re,["accumulated"],["get",H]]:re;z.push(...mt({key:`${x}.${H}.map`,value:oe,expressionContext:"cluster-map"})),z.push(...mt({key:`${x}.${H}.reduce`,value:ge,expressionContext:"cluster-reduce"}))}}return z;case"video":return ta({key:x,value:h,valueSpec:T.source_video,style:D,styleSpec:T});case"image":return ta({key:x,value:h,valueSpec:T.source_image,style:D,styleSpec:T});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:ir(T)}})}}function ir(M){return M.source.reduce((h,x)=>{const T=M[x];return T.type.type==="enum"&&(h=h.concat(Object.keys(T.type.values||{}))),h},[])}function Rr(M){const h=M.value,x=M.styleSpec,T=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 H=z.match(/^(.*)-transition$/),Q=z.match(/^(.*)-use-theme$/);F=F.concat(Q&&T[Q[1]]?yn({key:z,value:h[z],valueSpec:{type:"string"},style:D,styleSpec:x}):H&&T[H[1]]&&T[H[1]].transition?yn({key:z,value:h[z],valueSpec:x.transition,style:D,styleSpec:x}):T[z]?yn({key:z,value:h[z],valueSpec:T[z],style:D,styleSpec:x}):[new i.V(z,h[z],`unknown property "${z}"`)])}return F}function ca(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 T=[];const D=M.styleSpec,F=D["light-3d"],z=M.style,H=M.style.lights;for(const oe of["type","id"])if(!(oe in h))return T=T.concat([new i.V(x,h,`missing property "${oe}"`)]),T;if(!i.a0(h.type))return T=T.concat([new i.V(`${x}.type`,h.type,"string expected")]),T;if(H)for(let oe=0;oe[],array:lt,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:We,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:Rt,function:Ye,layer:fs,object:ta,source:ks,model:i.a7,light:Rr,"light-3d":ca,terrain:ii,fog:lo,string:dr,formatted:function(M){return dr(M).length===0?[]:mt(M)},resolvedImage:function(M){return dr(M).length===0?[]:mt(M)},projection:function(M){const h=M.value,x=M.styleSpec,T=x.projection,D=M.style;if(i.H(h)){let F=[];for(const z in h)F=F.concat(yn({key:z,value:h[z],valueSpec:T[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:T}=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=ta(Object.assign({},M,{value:F,valueSpec:T.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(vr(D,T,{key:`${M.key}.data`}))),z},iconset:function(M){const h=M.value,x=M.key,T=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(ta({key:x,value:h,valueSpec:T[`iconset_${F}`],style:D,styleSpec:T})),function(H,Q){return!(H!=="source"||!Q.source)}(F,h)){const H=D.sources&&D.sources[h.source],Q=H&&i.J(H.type);H?Q!=="raster-array"&&z.push(new i.V(x,h.source,`iconset cannot be used with a source of type ${String(Q)}, 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 yn(M,h=!1){const x=M.value,T=M.valueSpec,D=M.styleSpec;if(T.expression){if(i.a4(i.J(x)))return Ye(M);if(i.Q(i.S(x)))return mt(M)}if(T.type&&Oa[T.type]){const F=Oa[T.type](M);return h===!0&&F.length>0&&Array.isArray(M.value)?mt(M):F}return ta(Object.assign({},M,{valueSpec:T.type?D[T.type]:T}))}function ta(M){const h=M.key,x=M.value,T=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 H=[];for(const Q in x){const re=Q.split(".")[0];let oe;D[re]?oe=D[re]:T[re]?oe=yn:D["*"]?oe=D["*"]:T["*"]&&(oe=yn),oe?H=H.concat(oe({key:(h&&`${h}.`)+Q,value:x[Q],valueSpec:T[re]||T["*"],style:F,styleSpec:z,object:x,objectKey:Q},x)):H.push(new i.a3(h,x[Q],`unknown property "${Q}"`))}for(const Q in T){if(D[Q])continue;const re=T[Q];re.required&&re.default===void 0&&x[Q]===void 0&&H.push(new i.V(h,x,`missing required property "${Q}"`))}return H}function Zt({key:M,value:h}){const x=dr({key:M,value:h});if(x.length)return x;const T=h;return T.indexOf("{fontstack}")===-1&&x.push(new i.V(M,h,'"glyphs" url must include a "{fontstack}" token')),T.indexOf("{range}")===-1&&x.push(new i.V(M,h,'"glyphs" url must include a "{range}" token')),x}function vr(M,h=i.a6,x={}){return ta({key:x.key||"",value:M,valueSpec:Object.assign(h.$root,{"*":{type:"*"}}),styleSpec:h,style:M,objectElementValidators:{glyphs:Zt}})}function Gr(M,h=i.a6){return ze(vr(M,h))}const Rn=M=>ze(ks(M)),rs=M=>ze(Rr(M)),Ln=M=>ze(ca(M)),da=M=>ze(ii(M)),Va=M=>ze(lo(M)),Jr=M=>ze(function(h){const x=h.value,T=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 H in x){const Q=H.match(/^(.*)-transition$/);z=z.concat(Q&&F[Q[1]]&&F[Q[1]].transition?yn({key:H,value:x[H],valueSpec:D.transition,style:T,styleSpec:D}):F[H]?yn({key:H,value:x[H],valueSpec:F[H],style:T,styleSpec:D}):[new i.a3(H,x[H],`unknown property "${H}"`)])}return z}(M)),Za=M=>ze(function(h){const x=h.value,T=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 H in x){const Q=H.match(/^(.*)-transition$/);z=z.concat(Q&&F[Q[1]]&&F[Q[1]].transition?yn({key:H,value:x[H],valueSpec:D.transition,style:T,styleSpec:D}):F[H]?yn({key:H,value:x[H],valueSpec:F[H],style:T,styleSpec:D}):[new i.a3(H,x[H],`unknown property "${H}"`)])}return z}(M)),$l=M=>ze(fs(M)),Do=M=>ze(Rt(M)),Yc=M=>ze(Kt(M)),ct=M=>ze(Qt(M)),Se=M=>ze(i.a7(M));function ze(M){return M.slice().sort((h,x)=>h.line&&x.line?h.line-x.line:0)}function st(M,h){let x=!1;if(h&&h.length)for(const T of h)T instanceof i.a3?i.w(T.message):(M.fire(new i.y(new Error(T.message))),x=!0);return x}const Tt=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(Tt.anchor),position:new i.ab(Tt.position),color:new i.aa(Tt.color),intensity:new i.aa(Tt.intensity)}))),this.setLight(h,x),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(h,x,T={}){this._validate(rs,h,T)||(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,T){return(!T||T.validate!==!1)&&st(this,h.call(Gr,Object.assign({value:x,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}const Yt=i.a6.terrain;let Ut=class extends i.E{constructor(M,h,x,T,D){super(),this.scope=x,this._transitionable=new i.a8(new i.a9({source:new i.aa(Yt.source),exaggeration:new i.aa(Yt.exaggeration)}),x,T),this._transitionable.setTransitionOrValue(M,T),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,T=-1,D=1;for(const F of h.zoomStops)D=h.evaluate(new i.ac(F,{worldview:this.worldview})),D>.01?(x=F,T=-1):T=F;return D<.01&&x>0&&T>x?[x,T]: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 Jt=45,Is=65,xs=.05;function pr(M,h,x,T){const D=i.ah(Jt,Is,x),[F,z]=$r(M,T);let H=1-Math.min(1,Math.exp((h-F)/(z-F)*-6));return H*=H*H,H=Math.min(1,1.00747*H),H*D*M.alpha}function $r(M,h){const x=.5/Math.tan(.5*h);return[M.range[0]+x,M.range[1]+x]}function cr(M,h,x,T,D){const F=i.af([],[h,x,T],D.mercatorFogMatrix);return pr(M,i.ag(F),D.pitch,D._fov)}function Cn(M,h,x,T,D,F,z){const H=[[x,T,0],[D,T,0],[D,F,0],[x,F,0]];let Q=Number.MAX_VALUE,re=-Number.MAX_VALUE;for(const oe of H){const ge=i.af([],oe,h),me=i.ag(ge);Q=Math.min(Q,me),re=Math.max(re,me)}return[pr(M,Q,z.pitch,z._fov),pr(M,re,z.pitch,z._fov)]}const Mn=i.a6.fog;class wn extends i.E{constructor(h,x,T,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,T,new Map(D)),this.set(h,D),this._transitioning=this._transitionable.untransitioned(),this._transform=x,this.properties=new i.ai(F),this.scope=T}get state(){const h=this._transform,x=h.projection.name==="globe",T=i.aj(h.zoom),D=this.properties.get("range"),F=[.5,3];return{range:x?[i.ak(F[0],D[0],T),i.ak(F[1],D[1],T)]:D,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(h,x,T={}){if(this._validate(Va,h,T))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(Jt,Is,h))*x.a}getOpacityAtLatLng(h,x){return this._transform.projection.supportsFog?function(T,D,F){const z=i.ae.fromLngLat(D),H=F.elevation?F.elevation.getAtPointOrZero(z):0;return cr(T,z.x,z.y,H,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,T,D,F){return this._transform.projection.supportsFog?Cn(this.state,h,x,T,D,F,this._transform):[1,1]}getFovAdjustedRange(h){return this._transform.projection.supportsFog?$r(this.state,h):[0,1]}isVisibleOnFrustum(h){if(!this._transform.projection.supportsFog)return!1;const x=[4,5,6,7];for(const T of x){const D=h.points[T];let F;if(D[2]>=0)F=D;else{const z=h.points[T-4];F=i.am(z,D,z[2]/(z[2]-D[2]))}if(cr(this.state,F[0],F[1],0,this._transform)>=xs)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,T){return(!T||T.validate!==!1)&&st(this,h.call(Gr,Object.assign({value:x,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}let ua,co,$o,Ha,Wo=class extends i.E{constructor(M,h,x,T){super();const D=ua||(ua=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(T)),this.set(M,T),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"),T=i.an(x[0]),D=-Math.max(i.an(x[1]),.01),F=[Math.cos(T)*Math.cos(D),Math.sin(T)*Math.cos(D),Math.sin(D)],z=this.properties.get("vignette"),H=this.properties.get("vignette-color");return H.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:H}}get(){return this._transitionable.serialize()}set(M,h,x={}){if(this._validate(Jr,M,x))return;const T=Object.assign({},M),D=i.a6.snow;for(const F of Object.keys(D))T[F]===void 0&&(T[F]=D[F].default);this._options=T,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)&&st(this,M.call(Gr,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}},Xi=class extends i.E{constructor(M,h,x,T){super();const D=co||(co=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(T)),this.set(M,T),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"),T=i.an(x[0]),D=-Math.max(i.an(x[1]),.01),F=[Math.cos(T)*Math.cos(D),Math.sin(T)*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(Za,M,x))return;const T=Object.assign({},M),D=i.a6.rain;for(const F of Object.keys(D))T[F]===void 0&&(T[F]=D[F].default);this._options=T,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)&&st(this,M.call(Gr,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}};class _a extends i.E{constructor(h,x,T,D){super(),this.scope=T,this._options=h,this.properties=new i.ai(x),this._transitionable=new i.a8(x,T,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,T){this.screenBounds=h,this.cameraPoint=T.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=x,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,T)}static createFromScreenPoints(h,x){let T,D;if(h instanceof i.P||typeof h[0]=="number"){const F=i.P.convert(h);T=[F],D=x.isPointAboveHorizon(F)}else{const F=i.P.convert(h[0]),z=i.P.convert(h[1]),H=F.add(z)._div(2);T=[F,z],D=i.aq(F,z).every(Q=>x.isPointAboveHorizon(Q))&&x.isPointAboveHorizon(H)}return new Qi(T,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],T=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.aq(x,T,0,!1);return this.cameraPoint.y>T.y&&(this.cameraPoint.x>x.x&&this.cameraPoint.x=T.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],T=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.aq(x,T,h),F=this.cameraPoint.clone();switch(3*((F.y>x.y)+(F.y>T.y))+((F.x>x.x)+(F.x>T.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,T,D=0){const F=Math.max(h.queryPadding,h.evaluateQueryRenderedFeaturePadding())/x._pixelsPerMercatorPixel+1,z=T?this._bufferedCameraMercator(F,x):this._bufferedScreenMercator(F,x);let H=h.tileID.wrap+(z.unwrapped?D:0);const Q=z.polygon.map($e=>i.as(h.tileTransform,$e,H));if(!i.at(Q,0,0,i.al,i.al))return;H=h.tileID.wrap+(this.screenGeometryMercator.unwrapped?D:0);const re=this.screenGeometryMercator.polygon.map($e=>i.au(h.tileTransform,$e,H)),oe=re.map($e=>new i.P($e[0],$e[1])),ge=x.getFreeCameraOptions().position||new i.ae(0,0,0),me=i.au(h.tileTransform,ge,H),xe=re.map($e=>{const Be=i.av($e,$e,me);return i.aw(Be,Be),new i.ax(me,Be)}),Pe=i.ay(h,1,x.zoom)*x._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:oe,tilespaceRays:xe,bufferedTilespaceGeometry:Q,bufferedTilespaceBounds:(Ce=i.az(Q),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 T=Ji(h);if(this._screenRaycastCache[T])return this._screenRaycastCache[T];{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[T]=D,D}}_bufferedCameraMercator(h,x){const T=Ji(h);if(this._cameraRaycastCache[T])return this._cameraRaycastCache[T];{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[T]=D,D}}_projectAndResample(h,x){const T=function(F,z){const H=i.aB([],z.pixelMatrix,z.globeMatrix),Q=[0,-i.aD,0,1],re=[0,i.aD,0,1],oe=[0,0,0,1];i.aC(Q,Q,H),i.aC(re,re,H),i.aC(oe,oe,H);const ge=new i.P(Q[0]/Q[3],Q[1]/Q[3]),me=new i.P(re[0]/re[3],re[1]/re[3]),xe=i.aE(F,ge)&&Q[3]1?xi(F.slice(0,$e),z):[],dt=$enew i.P(sa(kt.x),kt.y)),dt=dt.map(kt=>new i.P(sa(kt.x),kt.y));const tt=[...Je];tt.length===0&&tt.push(dt[dt.length-1]);const Mt=i.ak(tt[tt.length-1].y,(dt.length===0?Je[0]:dt[0]).y,Be);let vt;return vt=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)],tt.push(...vt),dt.length===0?tt.push(Je[0]):tt.push(...dt),{polygon:tt.map(kt=>new i.ae(kt.x,kt.y)),unwrapped:!1}}(h,x);if(T)return T;const D=function(F,z){let H=!1,Q=-1/0,re=0;for(let ge=0;geQ&&(Q=F[ge].x,re=ge);for(let ge=0;ge.5&&(xe.x{ge.x-=1}),{polygon:F,unwrapped:H}}(xi(h,x).map(F=>new i.P(sa(F.x),F.y)),x);return{polygon:D.polygon.map(F=>new i.ae(F.x,F.y)),unwrapped:D.unwrapped}}}function xi(M,h){return i.aG(M,x=>{const T=h.pointCoordinate3D(x);x.x=T.x,x.y=T.y},1/256)}function sa(M){return M<0?1+M%1:M%1}function Ji(M){return 100*M|0}function rc(M,h,x,T,D){const F=function(H,Q){if(H)return D(H);if(Q){if(M.url&&Q.tiles&&M.tiles&&delete M.tiles,Q.variants){if(!Array.isArray(Q.variants))return D(new Error("variants must be an array"));for(const oe of Q.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"){Q=Object.assign(Q,oe);break}}}const re=i.aH(Object.assign({},Q,M),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);re.tiles=h.canonicalizeTileset(re,M.url),D(null,re)}},z=function(H,Q,re){if(!H)return null;if(!Q&&!re)return H;re=re||H.worldview_default;const oe=Object.values(H.language||{});if(oe.length===0)return null;const ge=Object.values(H.worldview||{});if(ge.length===0)return null;const me=oe.every(Pe=>Pe===Q),xe=ge.every(Pe=>Pe===re);return me&&xe?H:Q in(H.language_options||{})||re in(H.worldview_options||{})?null:H.language_options&&H.worldview_options?H:null}(M.data,x,T);return z?i.o.frame(()=>F(null,z)):M.url?i.m(h.transformRequest(h.normalizeSourceURL(M.url,null,x,T),i.R.Source),F):i.o.frame(()=>{const{data:H,...Q}=M;F(null,Q)})}function gc(M,h){const x=Math.pow(2,h.z),T=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>=T&&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}`),T&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${T}`),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=Md.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 T=h.tileID.canonical.url(this.tiles,this.scheme),D=this.map._requestManager.normalizeTileURL(T),F=this.map._requestManager.transformRequest(D,i.R.Tile),z=this.map.style?this.map.style.getLut(this.scope):null,H=z?{image:z.image.clone()}:null,Q={request:F,data:void 0,uid:h.uid,tileID:h.tileID,tileZoom:h.tileZoom,zoom:h.tileID.overscaledZ,maxZoom:this.maxzoom,lut:H,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(T)&&(Q.localizableLayerIds=this.localizableLayerIds),Q.request.collectResourceTiming=this._collectResourceTiming,h.actor&&h.state!=="expired")h.state==="loading"?h.reloadCallback=x:h.request=h.actor.send("reloadTile",Q,re.bind(this));else if(h.actor=this._tileWorkers[D]=this._tileWorkers[D]||this.dispatcher.getActor(),this.dispatcher.ready)h.request=h.actor.send("loadTile",Q,re.bind(this),void 0,!0);else{const oe=i.aL.call({deduped:this._deduped},Q,(ge,me)=>{if(ge||!me)re.call(this,ge);else{const xe=i.aM(me.responseHeaders);Q.data={rawData:me.rawData.slice(0),expires:xe.expires,cacheControl:xe.cacheControl},h.actor&&h.actor.send("loadTile",Q,re.bind(this),void 0,!0)}},!0);h.request={cancel:oe}}function re(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 xl extends i.E{constructor(h,x,T,D){super(),this.id=h,this.dispatcher=T,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=rc(this._options,this.map._requestManager,null,x,(T,D)=>{this._tileJSONRequest=null,this._loaded=!0,T?this.fire(new i.y(T)):D&&(Object.assign(this,D),D.raster_layers&&(this.rasterLayers=D.raster_layers,this.rasterLayerIds=this.rasterLayers.map(F=>F.id)),this.tileBounds=Md.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(T)})}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 T=i.o.devicePixelRatio>=2,D=this.map._requestManager.normalizeTileURL(h.tileID.canonical.url(this.tiles,this.scheme),T,this.tileSize);h.request=i.n(this.map._requestManager.transformRequest(D,i.R.Tile),(F,z,H)=>{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 Q=i.aM(H);this.map._refreshExpiredTiles&&h.setExpiryData(Q),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 wu([M,h],x,T,{scaled:D=!0}={}){const{tileSize:F,buffer:z}=T,{x:H,y:Q,z:re}=x;if(!isFinite(H)||!isFinite(Q)||!isFinite(re))throw new Error("Invalid MRT header");const oe=2**re,ge=oe*i.aF(M),me=oe*i.aJ(h);return function([xe,Pe],Ce,{scaled:$e=!0}={}){if(!Ce)throw new Error("bandView is undefined");const{data:Be,tileSize:Je,buffer:dt,offset:tt,scale:Mt,dimension:vt}=Ce;if(xe<-dt||xe>Je+dt||Pe<-dt||Pe>Je+dt)throw new Error(`Point (${xe}, ${Pe}) out of bounds for tileSize=${Je}, buffer=${dt}`);const kt=(Pe+dt)*(Je+2*dt)+(xe+dt);if(new Uint32Array(Be.buffer)[kt]===4294967295)return null;let xt=[];xt=$e?[]:new Ce.data.constructor(vt);for(let pt=0;pt{if(delete h.request,h.aborted)return h.state="unloaded",x(null);if(H)return H.name==="AbortError"?void 0:(h.state="errored",x(H));if(this.map._refreshExpiredTiles&&Q){const oe=i.aM(re);h.setExpiryData(oe)}if(this.partial&&h.state!=="expired")h.state="empty";else if(!this.partial){if(!Q)return x(null);h.state="loaded",h._isHeaderLoaded=!0,h._mrt=Q}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 T=h.texturePerLayer;if(h.flushAllQueues(),T.size){h.destroy(!1);for(const D of T.values())this.map.painter.saveTileTexture(D)}else h.destroy()}prepareTile(h,x,T,D){h._isHeaderLoaded&&(h.state!=="empty"&&(h.state="reloading"),h.fetchBandForRender(x,T,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(T,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),T=x&&x.fields,D=T&&T.bands&&T.bands;return D?D[0]:0}getTextureDescriptor(h,x,T){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)&&!T)return;const H=h.textureDescriptorPerLayer.get(x.id);return Object.assign({},H,{texture:h.texturePerLayer.get(x.id)})}getImages(h,x){const T=new Map;for(const D of h)for(const F of x){const[z,H]=F.split("/"),Q=D.getLayer(z);if(!Q||!Q.hasBand(H)||!Q.hasDataForBand(H))continue;const{bytes:re,tileSize:oe,buffer:ge}=Q.getBandView(H),me=oe+2*ge,xe={data:new i.q({width:me,height:me},re),pixelRatio:2,sdf:!1,usvg:!1,version:0};T.set(F,xe)}return T}queryRasterArrayValueByBandId(h,x,T){const D=x._mrt;return new Promise(F=>{const z={},H=new Set;for(const[Q,re]of Object.entries(D.layers)){if(T.layerName&&Q!==T.layerName)continue;const oe={};z[Q]=oe;for(const{bands:ge}of re.dataIndex)for(const me of ge)T.bands&&!T.bands.includes(me)||(H.add(i.B(Q,me)),x.fetchBand(Q,null,me,xe=>{i.o.frame(()=>{oe[me]=xe?null:wu([h.lng,h.lat],D,re.getBandView(me)),H.delete(i.B(Q,me)),H.size===0&&F(z)})},!1))}H.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 T=this.map._requestManager.normalizeTileURL(h.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),D=this.map._requestManager.transformRequest(T,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,H)=>{if(F)return this._loadTilePending[h.uid].forEach(Q=>Q(F,null)),void delete this._loadTilePending[h.uid];if(!z)return this._loadTilePending[h.uid].forEach(Q=>Q(null,null)),void delete this._loadTilePending[h.uid];if(this.map._refreshExpiredTiles&&z){const Q=i.aM(H);h.setExpiryData(Q)}h._mrt=z,h._isHeaderLoaded=!0,h.state="loaded",this._loadTilePending[h.uid].forEach(Q=>Q(null,z)),this._loadTileLoaded[h.uid]=!0,delete this._loadTilePending[h.uid]},void 0,!0)}queryRasterArrayValueByAllBands(h,x,T){return new Promise((D,F)=>{this._loadTileForQuery(x,(z,H)=>{z?F(z):D(H?this.queryRasterArrayValueByBandId(h,x,T):null)})})}queryRasterArrayValue(h,x){const T=i.aT.convert(h),D=this.findLoadedParent(T);return D&&D._mrt?x.bands||!this.partial?this.queryRasterArrayValueByBandId(T,D,x):this.queryRasterArrayValueByAllBands(T,D,x):Promise.resolve(null)}findLoadedParent(h){const x=i.ae.fromLngLat(h,this.map.transform.tileSize),T=this.maxzoom+1,D=1<0&&(H[new i.aQ(M.overscaledZ,D,h.z,T,h.y-1).key]={backfilled:!1},H[new i.aQ(M.overscaledZ,M.wrap,h.z,h.x,h.y-1).key]={backfilled:!1},H[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,T)this.fire(new i.y(T));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 T=this.map.style?this.map.style.getLut(this.scope):null,D=T?{image:T.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,(H,Q)=>F&&!Q?(M.state="loaded",h(null)):(delete M.request,M.destroy(!1),M.aborted?h(null):H?h(H):(M.loadVectorData(Q,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,T){super(M,h,x,T),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,T){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(T)}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=rc(this._options,this.map._requestManager,h,x,(T,D)=>{this._tileJSONRequest=null,this._loaded=!0,T?(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(T))):D&&(Object.assign(this,D),D.bounds&&(this.tileBounds=new Md(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(T)})}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)),T={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",T,D.bind(this))}else M.actor=this.dispatcher.getActor(),M.request=M.actor.send("loadTile",T,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,T){super(M,h,x,T),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,T){super(),this.id=M,this.type="custom",this._dataType="raster",this._dispatcher=x,this._implementation=h,this.setEventedParent(T),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 Md(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:T}=M.canonical;return this._implementation.hasTile({x:h,y:x,z:T})}return!this.tileBounds||this.tileBounds.contains(M.canonical)}loadTile(M,h){const{x,y:T,z:D}=M.tileID.canonical,F=new AbortController;M.request=Promise.resolve(this._implementation.loadTile({x,y:T,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(H){return H instanceof ImageData||H instanceof HTMLCanvasElement||H instanceof ImageBitmap||H 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:T,z:D}=M.tileID.canonical;this._implementation.unloadTile({x,y:T,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"}))}}},yl=function(M,h,x,T){const D=new Qh[h.type](M,h,x,T);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 Lf(M,h,x=""){return`${x}:${h.id||""}:${h.layer.id}:${function(T){if("layerId"in T)return`layer:${T.layerId}`;{const{featuresetId:D,importId:F}=T;return`featureset:${D}${F?`:import:${F}`:""}`}}(M.target)}`}function Xg(M,h,x,T=""){if(M.uniqueFeatureID){const D=Lf(M,h,T);if(x.has(D))return!0;x.add(D)}return!1}function iv(M,h,x,T,D=!1){const F=h.sourceCache.transform,z=h.sourceCache.tilesIn(M,h.has3DLayers,D);z.sort(Bm);const H=[];for(const Q of z){const re=Q.tile.queryRenderedFeatures(h,Q,x,T,F,D);Object.keys(re).length&&H.push({wrappedTileID:Q.tile.tileID.wrapped().key,queryResults:re})}for(const Q in h.layers){const re=h.layers[Q];if(re.styleLayer){const oe=re.styleLayer.queryRenderedFeatures(M,h.sourceCache,T);Object.keys(oe).length&&H.push({wrappedTileID:0,queryResults:oe})}}return H.length===0?{}:function(Q){const re={},oe={};for(const ge of Q){const me=ge.queryResults,xe=ge.wrappedTileID,Pe=oe[xe]=oe[xe]||{};for(const Ce in me){const $e=me[Ce],Be=Pe[Ce]=Pe[Ce]||{},Je=re[Ce]=re[Ce]||[];for(const dt of $e)Be[dt.featureIndex]||(Be[dt.featureIndex]=!0,Je.push(dt))}}return re}(H)}function ov(M,h,x,T,D,F){const z={},H=T.queryRenderedSymbols(M),Q=[];for(const re of Object.keys(H).map(Number))Q.push(D[re]);Q.sort(Bm);for(const re of Q){const oe=re.featureIndex.lookupSymbolFeatures(H[re.bucketInstanceId],re.bucketIndex,re.sourceLayerIndex,h,x,F);for(const ge in oe){const me=z[ge]=z[ge]||[],xe=oe[ge];xe.sort((Pe,Ce)=>{const $e=re.featureSortOrder;if($e){const Be=$e.indexOf(Pe.featureIndex);return $e.indexOf(Ce.featureIndex)-Be}return Ce.featureIndex-Pe.featureIndex});for(const Pe of xe)me.push(Pe)}}return z}function lv(M,h){const x=M.getRenderableIds().map(F=>M.getTileByID(F)),T=[],D={};for(let F=0;Fh.getLayer(F)).filter(Boolean);if(D.length!==0){T.layers=D,T.stateDependentLayerIds&&(T.stateDependentLayers=T.stateDependentLayerIds.map(F=>D.filter(z=>z.id===F)[0]));for(const F of D)x[F.fqid]=T}}return x}const Td=32,hh=33,hd=new Uint16Array(8184);for(let M=0;M<2046;M++){let h=M+2,x=0,T=0,D=0,F=0,z=0,H=0;for(1&h?D=F=z=Td:x=T=H=Td;(h>>=1)>1;){const re=x+D>>1,oe=T+F>>1;1&h?(D=x,F=T,x=z,T=H):(x=D,T=F,D=z,F=H),z=re,H=oe}const Q=4*M;hd[Q+0]=x,hd[Q+1]=T,hd[Q+2]=D,hd[Q+3]=F}const Qc=new Uint16Array(2178),Ad=new Uint8Array(1089),Sp=new Uint16Array(1089);function Cp(M){return M===0?-.03125:M===32?.03125:0}const Jh={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 em{constructor(h,x,T,D,F,z){this.tileID=h,this.uid=i.b2(),this.uses=0,this.tileSize=x,this.tileZoom=T,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;xT)D=!1;else if(x)if(this.expirationTimeT.appearances&&T.appearances.length>0))return!0;return!1}updateBuckets(h,x){if(!this.latestFeatureIndex||!h.style)return;const T=h.style.listImages(),D=h.style.getBrightness();for(const F in this.buckets){if(!h.style.hasLayer(F))continue;const z=this.buckets[F],H=z.layers[0],Q=H.sourceLayer||"_geojsonTileLayer",re=h.style.getLayerSourceCache(H);let oe={};re&&(oe=re._state.getState(Q,void 0));const ge=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},me=Object.keys(oe).length>0&&!x;z.hasAppearances=z.layers.some(Ce=>Ce.appearances&&Ce.appearances.length>0);const xe=me?z.stateDependentLayers:z.layers;if(me&&z.stateDependentLayers.length!==0||x){const Ce=this.latestFeatureIndex.loadVTLayers();z.update(oe,Ce[Q],T,ge,xe,x,D)}if(me&&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,T,Ce)}(z instanceof i.ba||z instanceof i.bb)&&h._terrain&&h._terrain.enabled&&re&&z.uploadPending()&&h._terrain._clearRenderCacheForTile(re.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;$e--){const Be=4*$e,Je=hd[Be+0],dt=hd[Be+1],tt=hd[Be+2],Mt=hd[Be+3],vt=Je+tt>>1,kt=dt+Mt>>1,xt=vt+kt-dt,pt=kt+Je-vt,Pt=dt*hh+Je,Ht=Mt*hh+tt,Vt=kt*hh+vt,ts=Math.hypot((Qc[2*Pt+0]+Qc[2*Ht+0])/2-Qc[2*Vt+0],(Qc[2*Pt+1]+Qc[2*Ht+1])/2-Qc[2*Vt+1])>=16;Ad[Vt]=Ad[Vt]||(ts?1:0),$e<1022&&(Ad[Vt]=Ad[Vt]||Ad[(dt+pt>>1)*hh+(Je+xt>>1)]||Ad[(Mt+pt>>1)*hh+(tt+xt>>1)])}const ge=new i.b1,me=new i.b0;let xe=0;function Pe($e,Be){const Je=Be*hh+$e;return Sp[Je]===0&&(ge.emplaceBack(Qc[2*Je+0],Qc[2*Je+1],$e*i.al/Td,Be*i.al/Td),Sp[Je]=++xe),Sp[Je]-1}function Ce($e,Be,Je,dt,tt,Mt){const vt=$e+Je>>1,kt=Be+dt>>1;if(Math.abs($e-tt)+Math.abs(Be-Mt)>1&&Ad[kt*hh+vt])Ce(tt,Mt,$e,Be,vt,kt),Ce(Je,dt,tt,Mt,vt,kt);else{const xt=Pe($e,Be),pt=Pe(Je,dt),Pt=Pe(tt,Mt);me.emplaceBack(xt,pt,Pt)}}return Ce(0,0,Td,Td,Td,0),Ce(Td,Td,0,0,0,Td),{vertices:ge,indices:me}}(this.tileID.canonical,x);D=z.vertices,F=z.indices}else{D=new i.b1,F=new i.b0;for(const{x:H,y:Q}of T)D.emplaceBack(H,Q,0,0);const z=i.bh(D.int16.subarray(0,4*D.length),void 0,4);for(let H=0;H0&&(Q=i.bl(new Float64Array(16),x.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(h,D,x,z,Q,H),this._makeGlobeTileDebugTextBuffer(h,D,x,z,Q,H)}_globePoint(h,x,T,D,F,z,H){let Q=i.bm(h,x,T);if(z){const re=1<.5?xe=-1:me<-.5&&(xe=1);let Pe=(h/i.al+T.x)/re+xe,Ce=(x/i.al+T.y)/re;Pe=(Pe-oe)*D._pixelsPerMercatorPixel+oe,Ce=(Ce-ge)*D._pixelsPerMercatorPixel+ge;const $e=[Pe*D.worldSize,Ce*D.worldSize,0];i.af($e,$e,z),Q=i.bn(Q,$e,H)}return i.af(Q,Q,F)}_makeGlobeTileDebugBorderBuffer(h,x,T,D,F,z){const H=new i.bd,Q=new i.be,re=new i.bo,oe=(me,xe,Pe,Ce,$e)=>{const Be=(Pe-me)/($e-1),Je=(Ce-xe)/($e-1),dt=H.length;for(let tt=0;tt<$e;tt++){const Mt=me+tt*Be,vt=xe+tt*Je;H.emplaceBack(Mt,vt);const kt=this._globePoint(Mt,vt,x,T,D,F,z);re.emplaceBack(kt[0],kt[1],kt[2]),Q.emplaceBack(dt+tt)}},ge=i.al;oe(0,0,ge,0,16),oe(ge,0,ge,ge,16),oe(ge,ge,0,ge,16),oe(0,ge,0,0,16),this._tileDebugIndexBuffer=h.createIndexBuffer(Q),this._tileDebugBuffer=h.createVertexBuffer(H,i.bf.members),this._globeTileDebugBorderBuffer=h.createVertexBuffer(re,i.bp.members),this._tileDebugSegments=i.bg.simpleSegment(0,0,H.length,Q.length)}_makeGlobeTileDebugTextBuffer(h,x,T,D,F,z){const H=i.al/4,Q=new i.bd,re=new i.b0,oe=new i.bo,ge=25;re.reserve(32),Q.reserve(ge),oe.reserve(ge);const me=(xe,Pe)=>ge*xe+Pe;for(let xe=0;xe{if(F)x(F);else try{const Q=T.getHeaderLength(z);if(Q>h)return void(this.request=this.fetchHeader(Q,x));T.parseHeader(z),this._isHeaderLoaded=!0;let re=0;for(const oe of Object.values(T.layers))re=Math.max(re,oe.dataIndex[oe.dataIndex.length-1].lastByte);z.byteLength>=re&&(this.entireBuffer=z),x(null,this.entireBuffer||z,H)}catch(Q){x(Q)}}),this.request}fetchBandForRender(h,x,T,D){this.fetchBand(h,x,T,F=>{if(F)return void D(F);this.updateTextureDescriptor(h,x,T);const z=this.textureDescriptorPerLayer.get(x);D(null,z?z.img:null)})}fetchBand(h,x,T,D,F=!0){const z=this._mrt;if(!this._isHeaderLoaded||!z)return void D(new Error("Tile header is not ready"));const H=this.actor;if(!H)return void D(new Error("Can't fetch tile band without an actor"));let Q;const re=i.B(String(T),i.B(this.tileID.key,h));let oe=this._taskQueue.get(re);oe?oe.add(D):(oe=new Set,oe.add(D),this._taskQueue.set(re,oe));const ge=(Ce,$e)=>{Q.complete(Ce,$e),Ce?D(Ce):(oe.forEach(Be=>Be(null,$e)),this._taskQueue.delete(re))},me=(Ce,$e)=>{if(Ce)return D(Ce);const Be=H.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:$e,task:Q},ge,void 0,!0);if(x!==null){const Je=this._workQueuePerLayer.get(x)||[];Je.push(()=>{Be&&Be.cancel(),Q.cancel()}),this._workQueuePerLayer.has(x)||this._workQueuePerLayer.set(x,Je)}};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(T))return oe.forEach(Ce=>Ce(null,null)),void this._taskQueue.delete(re);const Pe=xe.getDataRange([T]);if(Q=z.createDecodingTask(Pe),!Q||Q.tasks.length)if(x!==null&&this.flushQueues(x),this.entireBuffer)me(null,this.entireBuffer.slice(Pe.firstByte,Pe.lastByte+1));else{const Ce=Object.assign({},this.requestParams,{headers:{Range:`bytes=${Pe.firstByte}-${Pe.lastByte}`}}),$e=i.bu(Ce,me);if(x!==null){const Be=this._fetchQueuePerLayer.get(x)||[];Be.push(()=>{$e.cancel(),Q.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,T){if(!this._mrt)return;const D=this._mrt.getLayer(h);if(!D||!D.hasBand(T)||!D.hasDataForBand(T))return;const{bytes:F,tileSize:z,buffer:H,offset:Q,scale:re}=D.getBandView(T),oe=z+2*H,ge=new i.q({width:oe,height:oe},F),me=this.texturePerLayer.get(x);me&&me instanceof i.T&&me.update(ge,{premultiply:!1}),this.textureDescriptorPerLayer.set(x,{layer:h,band:T,img:ge,buffer:H,offset:Q,tileSize:z,format:D.pixelFormat,mix:[re,256*re,65536*re,16777216*re]})}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 xy{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,T){const D=h.wrapped().key;this.data[D]===void 0&&(this.data[D]=[]);const F={value:x,timeout:void 0};if(T!==void 0&&(F.timeout=setTimeout(()=>{this.remove(h,F)},T)),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 T=h.wrapped().key,D=x===void 0?0:this.data[T].indexOf(x),F=this.data[T][D];return this.data[T].splice(D,1),F.timeout&&clearTimeout(F.timeout),this.data[T].length===0&&delete this.data[T],this.onRemove(F.value),this.order.splice(this.order.indexOf(T),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 T in this.data)for(const D of this.data[T])h(D.value)||x.push(D);for(const T of x)this.remove(T.value.tileID,T)}}class Df{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(h,x,T){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],T),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])T[F]||(this.deletedStates[h][D][F]=null)}else for(const F in T)this.deletedStates[h]&&this.deletedStates[h][D]&&this.deletedStates[h][D][F]===null&&delete this.deletedStates[h][D][F]}removeFeatureState(h,x,T){if(this.deletedStates[h]===null)return;const D=String(x);if(this.deletedStates[h]=this.deletedStates[h]||{},T&&x!==void 0)this.deletedStates[h][D]!==null&&(this.deletedStates[h][D]=this.deletedStates[h][D]||{},this.deletedStates[h][D][T]=null);else if(x!==void 0)if(this.stateChanges[h]&&this.stateChanges[h][D])for(T in this.deletedStates[h][D]={},this.stateChanges[h][D])this.deletedStates[h][D][T]=null;else this.deletedStates[h][D]=null;else this.deletedStates[h]=null}getState(h,x){const T=this.state[h]||{},D=this.stateChanges[h]||{},F=this.deletedStates[h];if(F===null)return{};if(x!==void 0){const H=String(x),Q=Object.assign({},T[H],D[H]);if(F){const re=F[x];if(re===null)return{};for(const oe in re)delete Q[oe]}return Q}const z=Object.assign({},T,D);if(F)for(const H in F)delete z[H];return z}initializeTileState(h,x){h.refreshFeatureState(x)}coalesceChanges(h,x){const T={};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];T[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 H of Object.keys(this.deletedStates[D][z]))delete this.state[D][z][H];F[z]=this.state[D][z]}T[D]=T[D]||{},Object.assign(T[D],F)}if(this.stateChanges={},this.deletedStates={},Object.keys(T).length!==0)for(const D in h)h[D].refreshFeatureState(x)}}class ul extends i.E{constructor(h,x,T){super(),this.id=h,this._onlySymbols=T,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 xy(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 Df,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 T=this._tiles[x];T.upload(h,this.map?this.map.painter:void 0),T.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(cv).map(h=>h.key)}getRenderableIds(h,x){const T=[];for(const D in this._tiles)this._isIdRenderable(+D,h,x)&&T.push(this._tiles[D]);return h?T.sort((D,F)=>{const z=D.tileID,H=F.tileID,Q=new i.P(z.canonical.x,z.canonical.y)._rotate(this.transform.angle),re=new i.P(H.canonical.x,H.canonical.y)._rotate(this.transform.angle);return z.overscaledZ-H.overscaledZ||re.y-Q.y||re.x-Q.x}).map(D=>D.tileID.key):T.map(D=>D.tileID).sort(cv).map(D=>D.key)}hasRenderableParent(h){const x=this.findLoadedParent(h,0);return!!x&&this._isIdRenderable(x.tileID.key)}_isIdRenderable(h,x,T){return this._tiles[h]&&this._tiles[h].hasData()&&!this._coveredTiles[h]&&(x||!this._tiles[h].holdingForFade())&&(T||!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 T=this._tiles[h];T&&(T.state!=="loading"&&(T.state=x),this._loadTile(T,this._tileLoaded.bind(this,T,h,x)))}_tileLoaded(h,x,T,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 H=this.map.painter.terrain;this.update(this.transform,H.getScaledDemTileSize(),!0),H.resetTileLookupCache(this.id)}else this.update(this.transform)}return}h.timeAdded=i.o.now(),T==="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+Q)===1?z+=Q:Math.abs(z-Q)===1&&(z-=Q)),F.dem&&D.dem&&(D.dem.backfillBorder(F.dem,z,H),D.neighboringTiles&&D.neighboringTiles[re]&&(D.neighboringTiles[re].backfilled=!0)))}}getTile(h){return this.getTileByID(h.key)}getTileByID(h){return this._tiles[h]}_retainLoadedChildren(h,x,T,D){for(const F in this._tiles){let z=this._tiles[F];if(D[F]||!z.hasData()||z.tileID.overscaledZ<=x||z.tileID.overscaledZ>T)continue;let H=z.tileID;for(;z&&z.tileID.overscaledZ>x+1;){const re=z.tileID.scaledTo(z.tileID.overscaledZ-1);z=this._tiles[re.key],z&&z.hasData()&&(H=re)}let Q=H;for(;Q.overscaledZ>x;)if(Q=Q.scaledTo(Q.overscaledZ-1),h[Q.key]){D[H.key]=H;break}}}findLoadedParent(h,x){if(h.key in this._loadedParentTiles){const T=this._loadedParentTiles[h.key];return T&&T.tileID.overscaledZ>=x?T:null}for(let T=h.overscaledZ-1;T>=x;T--){const D=h.scaledTo(T),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 T=Math.ceil(h.width/x)+1,D=Math.ceil(h.height/x)+1,F=Math.floor(T*D*5),z=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,F):F,H=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,z):z;this._cache.setMaxSize(H)}handleWrapJump(h){const x=Math.round((h-(this._prevLng===void 0?h:this._prevLng))/360);if(this._prevLng=h,x){const T={};for(const D in this._tiles){const F=this._tiles[D];F.tileID=F.tileID.unwrapTo(F.tileID.wrap+x),T[F.tileID.key]=F}this._tiles=T;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,T,D,F){if(this.transform=h,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!T)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 H,Q=this._source.maxzoom;const re=this.map&&this.map.painter?this.map.painter._terrain:null;if(re&&re.sourceCache===this&&re.attenuationRange()){const me=re.attenuationRange()[0],xe=Math.floor(me)-Math.log2(re.getDemUpscale());Q>xe&&(Q=xe)}if(this.used||this.usedForTerrain){if(this._source.tileID)H=h.getVisibleUnwrappedCoordinates(this._source.tileID).map(me=>new i.aQ(me.canonical.z,me.wrap,me.canonical.z,me.canonical.x,me.canonical.y));else if(this.tileCoverLift!==0){const me=h.clone();me.tileCoverLift=this.tileCoverLift,H=me.coveringTiles({tileSize:x||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:Q,roundZoom:this._source.roundZoom&&!T,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.minzoom<=1&&h.projection.name==="globe"&&(H.push(new i.aQ(1,0,1,0,0)),H.push(new i.aQ(1,0,1,1,0)),H.push(new i.aQ(1,0,1,0,1)),H.push(new i.aQ(1,0,1,1,1)))}else if(H=h.coveringTiles({tileSize:x||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:Q,roundZoom:this._source.roundZoom&&!T,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.hasTile){const me=this._source.hasTile.bind(this._source);H=H.filter(xe=>me(xe))}}else H=[];if(H.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!Of(this._source.type)){const me=h.coveringZoomLevel({tileSize:x||this._source.tileSize,roundZoom:this._source.roundZoom&&!T}),xe=Math.min(me,this._source.maxzoom);if(z){const Pe=h.extendTileCover(H,xe);for(const Ce of Pe)H.push(Ce)}else if(F){const Pe=h.extendTileCoverToNearPlane(H,this.transform.getFrustum(xe),xe);for(const Ce of Pe)H.push(Ce)}else if(this.castsShadows&&D){const Pe=h.extendTileCover(H,xe,D,16);for(const Ce of Pe)this._shadowCasterTiles[Ce.key]=!0,H.push(Ce)}}const oe=this._updateRetainedTiles(H);if(Of(this._source.type)&&H.length!==0){const me={},xe={},Pe=Object.keys(oe);for(const $e of Pe){const Be=oe[$e],Je=this._tiles[$e];if(!Je||Je.fadeEndTime&&Je.fadeEndTime<=i.o.now())continue;const dt=this.findLoadedParent(Be,Math.max(Be.overscaledZ-ul.maxOverzooming,this._source.minzoom));dt&&(this._addTile(dt.tileID),me[dt.tileID.key]=dt.tileID),xe[$e]=Be}const Ce=H[H.length-1].overscaledZ;for(const $e in this._tiles){const Be=this._tiles[$e];if(oe[$e]||!Be.hasData())continue;let Je=Be.tileID;for(;Je.overscaledZ>Ce;){Je=Je.scaledTo(Je.overscaledZ-1);const dt=this._tiles[Je.key];if(dt&&dt.hasData()&&xe[Je.key]){oe[$e]=Be.tileID;break}}}for(const $e in me)oe[$e]||(this._coveredTiles[$e]=!0,oe[$e]=me[$e])}for(const me in oe)this._tiles[me].clearFadeHold();const ge=i.bv(this._tiles,oe);for(const me of ge){const xe=this._tiles[me];xe.hasSymbolBuckets&&!xe.holdingForFade()?xe.setHoldDuration(this.map._fadeDuration):xe.hasSymbolBuckets&&!xe.symbolFadeFinished()||this._removeTile(+me)}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 T={},D=h.reduce((re,oe)=>Math.min(re,oe.overscaledZ),1/0),F=h[0].overscaledZ,z=Math.max(F-ul.maxOverzooming,this._source.minzoom),H=Math.max(F+ul.maxUnderzooming,this._source.minzoom),Q={};for(const re of h){const oe=this._addTile(re);x[re.key]=re,oe.hasData()||D=this._source.maxzoom){const me=re.children(this._source.maxzoom)[0],xe=this.getTile(me);if(xe&&xe.hasData()){x[me.key]=me;continue}}else{const me=re.children(this._source.maxzoom);if(x[me[0].key]&&x[me[1].key]&&x[me[2].key]&&x[me[3].key])continue}let ge=oe.wasRequested();for(let me=re.overscaledZ-1;me>=z;--me){const xe=re.scaledTo(me);if(T[xe.key]||(T[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 T,D=this._tiles[h].tileID;for(;D.overscaledZ>0;){if(D.key in this._loadedParentTiles){T=this._loadedParentTiles[D.key];break}x.push(D.key);const F=D.scaledTo(D.overscaledZ-1);if(T=this._getLoadedTile(F),T)break;D=F}for(const F of x)this._loadedParentTiles[F]=T}}_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 T=!!x;if(!T){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 em(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,T||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 T=x.getExpiryTimeout();T&&(this._timers[h]=setTimeout(()=>{this._reloadTile(h,"expired"),delete this._timers[h]},T))}_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,T){const D=[],F=this.transform;if(!F)return D;const z=F.projection.name==="globe",H=i.aF(F.center.lng);for(const Q in this._tiles){const re=this._tiles[Q];if(T&&re.clearQueryDebugViz(),re.holdingForFade())continue;let oe;if(z){const ge=re.tileID.canonical;if(ge.z===0){const me=[Math.abs(i.aA(H,...qu(ge,-1))-H),Math.abs(i.aA(H,...qu(ge,1))-H)];oe=[0,2*me.indexOf(Math.min(...me))-1]}else{const me=[Math.abs(i.aA(H,...qu(ge,-1))-H),Math.abs(i.aA(H,...qu(ge,0))-H),Math.abs(i.aA(H,...qu(ge,1))-H)];oe=[me.indexOf(Math.min(...me))-1]}}else oe=[0];for(const ge of oe){const me=h.containsTile(re,F,x,ge);me&&D.push(me)}}return D}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(h){return this._getRenderableCoordinates(h)}_getRenderableCoordinates(h,x){const T=this.getRenderableIds(h,x).map(F=>this._tiles[F].tileID),D=this.transform.projection.name==="globe";for(const F of T)F.projMatrix=this.transform.calculateProjMatrix(F.toUnwrapped()),F.expandedProjMatrix=D?this.transform.calculateProjMatrix(F.toUnwrapped(),!1,!0):F.projMatrix;return T}sortCoordinatesByDistance(h){const x=h.slice(),T=this.transform._camera.position,D=this.transform._camera.forward(),F={};for(const z of x){const H=1/(1<F[z.key]-F[H.key]),x}hasTransition(){if(this._source.hasTransition())return!0;if(Of(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,T){this._state.updateState(h=h||"_geojsonTileLayer",x,T)}removeFeatureState(h,x,T){this._state.removeFeatureState(h=h||"_geojsonTileLayer",x,T)}getFeatureState(h,x){return this._state.getState(h=h||"_geojsonTileLayer",x)}setDependencies(h,x,T){const D=this._tiles[h];D&&D.setDependencies(x,T)}reloadTilesForDependencies(h,x){for(const T in this._tiles)this._tiles[T].hasDependency(h,x)&&this._reloadTile(+T,"reloading");this._cache.filter(T=>!T.hasDependency(h,x))}_preloadTiles(h,x){if(!this._sourceLoaded){const Q=()=>{this._sourceLoaded&&(this._source.off("data",Q),this._preloadTiles(h,x))};return void this._source.on("data",Q)}const T=new Map,D=Array.isArray(h)?h:[h],F=this.map.painter.terrain,z=this.usedForTerrain&&F?F.getScaledDemTileSize():this._source.tileSize;for(const Q of D){const re=Q.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 re)T.set(oe.key,oe);this.usedForTerrain&&Q.updateElevation(!1)}const H=Array.from(T.values());i.bw(H,(Q,re)=>{const oe=new em(Q,this._source.tileSize*Q.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),re(ge,oe)})},x)}}function cv(M,h){const x=Math.abs(2*M.wrap)-+(M.wrap<0),T=Math.abs(2*h.wrap)-+(h.wrap<0);return M.overscaledZ-h.overscaledZ||T-x||h.canonical.y-M.canonical.y||h.canonical.x-M.canonical.x}function Of(M){return M==="raster"||M==="image"||M==="video"||M==="custom"}function qu(M,h){const x=1<0:T.type==="building"?D=!T.isHidden(h)&&T.paint.get("building-opacity")>0:T.type==="model"&&(D=!T.isHidden(h)&&T.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 H=1;F.type==="fill-extrusion"?H=D.visible?F.paint.get("fill-extrusion-vertical-scale"):0:F.type==="building"&&(H=D.visible?F.paint.get("building-vertical-scale"):0);let Q=z?z.getTile(x):null;if(!Q&&z)for(const re in z._tiles){const oe=z._tiles[re];if(x.canonical.isChildOf(oe.tileID.canonical)){Q=oe;break}}this.currentBuildingBuckets.push({bucket:Q?Q.getBucket(F):null,tileID:Q?Q.tileID:x,verticalScale:H})}h.hasAnyZOffset=!1;let T=!1;for(let D=0;D{T in h&&(x[T]=h[T])}),x}function yy(M){M=M.slice();const h=Object.create(null);for(let x=0;x0?(D-z)/H:0;return this.points[F].mult(1-Q).add(this.points[x].mult(Q))}}class rb{constructor(h,x,T){const D=this.boxCells=[],F=this.circleCells=[];this.xCellCount=Math.ceil(h/T),this.yCellCount=Math.ceil(x/T);for(let z=0;zthis.width||D<0||x>this.height)return!F&&[];const H=[];if(h<=0&&x<=0&&this.width<=T&&this.height<=D){if(F)return!0;for(let Q=0;Q0:H}_queryCircle(h,x,T,D,F){const z=h-T,H=h+T,Q=x-T,re=x+T;if(H<0||z>this.width||re<0||Q>this.height)return!D&&[];const oe=[];return this._forEachCell(z,Q,H,re,this._queryCellCircle,oe,{hitTest:D,circle:{x:h,y:x,radius:T},seenUids:{box:{},circle:{}}},F),D?oe.length>0:oe}query(h,x,T,D,F){return this._query(h,x,T,D,!1,F)}hitTest(h,x,T,D,F){return this._query(h,x,T,D,!0,F)}hitTestCircle(h,x,T,D){return this._queryCircle(h,x,T,!0,D)}_queryCell(h,x,T,D,F,z,H,Q){const re=H.seenUids,oe=this.boxCells[F];if(oe!==null){const me=this.bboxes;for(const xe of oe)if(!re.box[xe]){re.box[xe]=!0;const Pe=4*xe;if(h<=me[Pe+2]&&x<=me[Pe+3]&&T>=me[Pe+0]&&D>=me[Pe+1]&&(!Q||Q(this.boxKeys[xe]))){if(H.hitTest)return z.push(!0),!0;z.push({key:this.boxKeys[xe],x1:me[Pe],y1:me[Pe+1],x2:me[Pe+2],y2:me[Pe+3]})}}}const ge=this.circleCells[F];if(ge!==null){const me=this.circles;for(const xe of ge)if(!re.circle[xe]){re.circle[xe]=!0;const Pe=3*xe;if(this._circleAndRectCollide(me[Pe],me[Pe+1],me[Pe+2],h,x,T,D)&&(!Q||Q(this.circleKeys[xe]))){if(H.hitTest)return z.push(!0),!0;{const Ce=me[Pe],$e=me[Pe+1],Be=me[Pe+2];z.push({key:this.circleKeys[xe],x1:Ce-Be,y1:$e-Be,x2:Ce+Be,y2:$e+Be})}}}}}_queryCellCircle(h,x,T,D,F,z,H,Q){const re=H.circle,oe=H.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(re.x,re.y,re.radius,xe[Ce+0],xe[Ce+1],xe[Ce+2],xe[Ce+3])&&(!Q||Q(this.boxKeys[Pe])))return z.push(!0),!0}}const me=this.circleCells[F];if(me!==null){const xe=this.circles;for(const Pe of me)if(!oe.circle[Pe]){oe.circle[Pe]=!0;const Ce=3*Pe;if(this._circlesCollide(xe[Ce],xe[Ce+1],xe[Ce+2],re.x,re.y,re.radius)&&(!Q||Q(this.circleKeys[Pe])))return z.push(!0),!0}}}_forEachCell(h,x,T,D,F,z,H,Q){const re=this._convertToXCellCoord(h),oe=this._convertToYCellCoord(x),ge=this._convertToXCellCoord(T),me=this._convertToYCellCoord(D);for(let xe=re;xe<=ge;xe++)for(let Pe=oe;Pe<=me;Pe++)if(F.call(this,h,x,T,D,this.xCellCount*Pe+xe,z,H,Q))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,T,D,F,z){const H=D-h,Q=F-x,re=T+z;return re*re>H*H+Q*Q}_circleAndRectCollide(h,x,T,D,F,z,H){const Q=(z-D)/2,re=Math.abs(h-(D+Q));if(re>Q+T)return!1;const oe=(H-F)/2,ge=Math.abs(x-(F+oe));if(ge>oe+T)return!1;if(re<=Q||ge<=oe)return!0;const me=re-Q,xe=ge-oe;return me*me+xe*xe<=T*T}}const yt={unknown:0,flipRequired:1,flipNotRequired:2},Ts=Math.tan(85*Math.PI/180);function Ws(M,h,x,T,D,F,z){const H=i.bC();if(x)if(F.name==="globe"){const Q=i.bD(D,h);i.aB(H,H,Q)}else{const Q=i.bE([],z);H[0]=Q[0],H[1]=Q[1],H[4]=Q[2],H[5]=Q[3],T||i.bB(H,H,D.angle)}else i.aB(H,D.labelPlaneMatrix,M);return H}function ln(M,h,x,T,D,F,z){const H=Ws(M,h,x,T,D,F,z);return F.name==="globe"&&x||(H[2]=H[6]=H[10]=H[14]=0),H}function cn(M,h,x,T,D,F,z){if(x){if(F.name==="globe"){const H=Ws(M,h,x,T,D,F,z);return i.bl(H,H),i.aB(H,M,H),H}{const H=i.bz(M),Q=i.bA([]);return Q[0]=z[0],Q[1]=z[1],Q[4]=z[2],Q[5]=z[3],i.aB(H,H,Q),T||i.bB(H,H,-D.angle),H}}return D.glCoordMatrix}function ea(M,h,x,T){const D=[M,h,x,1];x?i.aC(D,D,T):Or(D,D,T);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],T=M[1]/M[3];return x>=-h[0]&&x<=h[0]&&T>=-h[1]&&T<=h[1]}function Rf(M,h,x,T,D,F,z,H,Q,re,oe=1){const ge=x.transform,me=T?M.textSizeData:M.iconSizeData,xe=i.bK(me,x.transform.zoom,oe),Pe=ge.projection.name==="globe",Ce=[256/x.width*2+1,256/x.height*2+1],$e=T?M.text.dynamicLayoutVertexArray:M.icon.dynamicLayoutVertexArray;$e.clear();let Be=null;Pe&&(Be=T?M.text.globeExtVertexArray:M.icon.globeExtVertexArray);const Je=M.lineVertexArray,dt=T?M.text.placedSymbolArray:M.icon.placedSymbolArray,tt=x.transform.width/x.transform.height;let Mt,vt=!1;for(let kt=0;ktMath.abs(x)?{useVertical:!0}:M===i.bL.vertical?T>0?{needsFlipping:!0}:null:h!==yt.unknown&&function(D,F){return D===0||Math.abs(F/D)>Ts}(x,T)?h===yt.flipRequired?{needsFlipping:!0}:null:x<0?{needsFlipping:!0}:null}function by(M,h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Ce,$e,Be,Je,dt){const tt=h/24,Mt=M.lineOffsetX*tt,vt=M.lineOffsetY*tt,{lineStartIndex:kt,glyphStartIndex:xt,numGlyphs:pt,segment:Pt,writingMode:Ht,flipState:Vt}=M,ts=kt+M.lineLength,ss=ps=>{if(oe){const[cs,es,Es]=ps.up,Qs=re.length;i.bN(oe,Qs+0,cs,es,Es),i.bN(oe,Qs+1,cs,es,Es),i.bN(oe,Qs+2,cs,es,Es),i.bN(oe,Qs+3,cs,es,Es)}const[Bs,Xt,Ft]=ps.point;i.bO(re,Bs,Xt,Ft,ps.angle)};if(pt>1){const ps=$m(tt,H,Mt,vt,x,ge,me,M,Q,F,xe,Ce,!1,$e,Be,Je,dt);if(!ps)return{notEnoughRoom:!0};if(T&&!x){let[Bs,Xt,Ft]=ps.first.point,[cs,es,Es]=ps.last.point;[Bs,Xt]=ea(Bs,Xt,Ft,z),[cs,es]=ea(cs,es,Es,z);const Qs=Vr(Ht,Vt,(cs-Bs)*Pe,es-Xt);if(M.flipState=Qs&&Qs.needsFlipping?yt.flipRequired:yt.flipNotRequired,Qs)return Qs}ss(ps.first);for(let Bs=xt+1;Bs0?cs:sm(me,Ft,Bs,1,D,void 0,$e,Be.canonical),Es=Vr(Ht,Vt,(es[0]-Bs[0])*Pe,es[1]-Bs[1]);if(M.flipState=Es&&Es.needsFlipping?yt.flipRequired:yt.flipNotRequired,Es)return Es}const ps=uv(tt*H.getoffsetX(xt),Mt,vt,x,ge,me,Pt,kt,ts,Q,F,xe,Ce,!1,!1,$e,Be,Je,dt);if(!ps)return{notEnoughRoom:!0};ss(ps)}return{}}function wy(M,h,x,T,D){const{x:F,y:z,z:H}=T.projectTilePoint(M.x,M.y,h);if(!D)return ea(F,z,H,x);const[Q,re,oe]=D.getElevation(M,D.elevation,D.elevationFeature);return ea(F+Q,z+re,H+oe,x)}function sm(M,h,x,T,D,F,z,H){const Q=wy(M.sub(h)._unit()._add(M),H,D,z,F);return i.av(Q,x,Q),i.aw(Q,Q),i.bH(Q,x,Q,T)}function uv(M,h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Ce,$e,Be,Je){const dt=T?M-h:M+h;let tt=dt>0?1:-1,Mt=0;T&&(tt*=-1,Mt=Math.PI),tt<0&&(Mt+=Math.PI);let vt=H+z+(tt>0?0:1)|0,kt=D,xt=D,pt=0,Pt=0;const Ht=Math.abs(dt),Vt=[],ts=[];let ss=F,ps=ss,Bs=i.bF([]);const Xt=()=>sm(ps,ss,xt,Ht-pt+1,oe,me,Ce,$e.canonical);for(;pt+Pt<=Ht;){if(vt+=tt,vt=Q)return null;if(xt=kt,ps=ss,Vt.push(xt),xe&&ts.push(ps),ss=new i.P(re.getx(vt),re.gety(vt)),kt=ge[vt],!kt){const kr=wy(ss,$e.canonical,oe,Ce,me);kt=kr[3]>0?ge[vt]=kr:Xt()}pt+=Pt;const $s=i.av([],kt,xt),Cr=i.bG(xt,kt);if(x&&Cr>0&&Pt>0&&i.bJ(Bs,$s)/(Pt*Cr)0,dt),kt=re*vt.perspectiveRatio,xt=(T.x1*x+H.x-T.padding)*kt+vt.point.x,pt=(T.y1*x+H.y-T.padding)*kt+vt.point.y,Pt=(T.x2*x+H.x+T.padding)*kt+vt.point.x,Ht=(T.y2*x+H.y+T.padding)*kt+vt.point.y,Vt=vt.perspectiveRatio<=.55||vt.occluded;return!this.isInsideGrid(xt,pt,Pt,Ht)||!Q&&this.grid.hitTest(xt,pt,Pt,Ht,ge)||Vt?{box:[],offscreen:!1,occluded:vt.occluded}:{box:[xt,pt,Pt,Ht],offscreen:this.isOffscreen(xt,pt,Pt,Ht),occluded:!1}}placeCollisionCircles(h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Ce,$e){const Be=[],Je=this.transform.elevation,dt=h.getProjection(),tt=h.elevationType==="road",Mt=!!Je||tt,vt=i.bV.getAtTileOffsetFunc($e,this.transform.center.lat,this.transform.worldSize,dt),kt=new i.P(T.tileAnchorX,T.tileAnchorY),xt=new i.P(T.tileAnchorX,T.tileAnchorY);let{x:pt,y:Pt,z:Ht}=dt.projectTilePoint(xt.x,xt.y,$e.canonical),Vt=null;if(Mt){const Cr=tt?h.getElevationFeatureForText(D):null;Vt={getElevation:vt,elevation:Je,elevationFeature:Cr};const[kr,or,fr]=vt(kt,Je,Cr);pt+=kr,Pt+=or,Ht+=fr}const ts=dt.name==="globe",ss=this.projectAndGetPerspectiveRatio(Q,pt,Pt,Ht,$e,ts||!!Je||this.transform.pitch>0,dt),{perspectiveRatio:ps}=ss,Bs=(me?H/ps:H*ps)/i.bY,Xt=ea(pt,Pt,Ht,re),Ft=T.lineOffsetX*Bs,cs=T.lineOffsetY*Bs,es=i.an(h.layers[0].layout.get("text-max-angle")),Es=Math.cos(es),Qs=ss.signedDistanceFromCamera>0?$m(Bs,z,Ft,cs,tt&&T.flipState===1,Xt,xt,T,F,re,{},Mt&&!me?Vt:null,me&&Mt,dt,$e,me,Es):null;let mr=!1,Ks=!1,$s=!0;if(Qs&&!ss.occluded){const Cr=.5*Pe*ps+Ce,kr=new i.P(-100,-100),or=new i.P(this.screenRightBoundary,this.screenBottomBoundary),fr=new Jg,{first:qr,last:jn}=Qs,ha=qr.path.length;let Wa=[];for(let vn=ha-1;vn>=1;vn--)Wa.push(qr.path[vn]);for(let vn=1;vn(Mt&&!ts&&(pi=vt(oivn[3]<=0)&&(Wa=[]));let Ra=[];if(Wa.length>0){let vn=1/0,Qa=-1/0,pi=1/0,oi=-1/0;for(const La of Wa)vn=Math.min(vn,La[0]),pi=Math.min(pi,La[1]),Qa=Math.max(Qa,La[0]),oi=Math.max(oi,La[1]);Qa>=kr.x&&vn<=or.x&&oi>=kr.y&&pi<=or.y&&(Ra=[Wa.map(La=>new i.P(La[0],La[1]))],(vnor.x||pior.y)&&(Ra=i.bW(Ra,kr.x,kr.y,or.x,or.y)))}for(const vn of Ra){fr.reset(vn,.25*Cr);let Qa=0;Qa=fr.length<=.5*Cr?1:Math.ceil(fr.paddedLength/Er)+1;for(let pi=0;pi0?(i.aC(Q,Q,h),this.fogState&&F&&H.name!=="globe"&&(re=function(me,xe,Pe,Ce,$e,Be){const Je=Be.calculateFogTileMatrix($e),dt=[xe,Pe,Ce];return i.af(dt,dt,Je),pr(me,i.ag(dt),Be.pitch,Be._fov)}(this.fogState,x,T,D,F.toUnwrapped(),this.transform)>.9)):Or(Q,Q,h);const oe=Q[3];return{point:new i.P((Q[0]/oe+1)/2*this.transform.width+wa,(-Q[1]/oe+1)/2*this.transform.height+wa),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(H)/oe*.5,1.5),signedDistanceFromCamera:oe,occluded:z&&Q[2]>oe||re}}isOffscreen(h,x,T,D){return T=this.screenRightBoundary||Dthis.screenBottomBoundary}isInsideGrid(h,x,T,D){return T>=0&&h=0&&xT.collisionGroupID===x}}return this.collisionGroups[h]}}function md(M,h,x,T,D){const{horizontalAlign:F,verticalAlign:z}=i.c1(M),H=-(F-.5)*h,Q=-(z-.5)*x,re=i.c2(M,T);return new i.P(H+re[0]*D,Q+re[1]*D)}function nl(M,h,x,T,D){const F=new i.P(M,h);return x&&F._rotate(T?D:-D),F}class Pce{constructor(h,x,T,D,F,z){this.transform=h.clone(),this.projection=h.projection.name,this.collisionIndex=new mi(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 ab(T),this.collisionCircleArrays={},this.prevPlacement=D,D&&(D.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(h,x,T,D,F=1){const z=T.getBucket(x),H=T.latestFeatureIndex;if(!z||!H||x.fqid!==z.layerIds[0])return;const Q=z.layers[0].layout,re=z.layers[0].paint,oe=T.collisionBoxArray,ge=Math.pow(2,this.transform.zoom-T.tileID.overscaledZ),me=T.tileSize/i.al,xe=T.tileID.toUnwrapped();this.transform.setProjection(z.projection);const Pe=(Ce=T.tileID,$e=z.getProjection(),Be=this.transform,$e.name===this.projection?Be.calculateProjMatrix(Ce.toUnwrapped()):sb(Be,$e,Ce));var Ce,$e,Be;const Je=Q.get("text-pitch-alignment")==="map",dt=Q.get("text-rotation-alignment")==="map";x.compileFilter(x.options);const tt=x.dynamicFilter(),Mt=x.dynamicFilterNeedsFeature(),vt=this.transform.calculatePixelsToTileUnitsMatrix(T),kt=ln(Pe,T.tileID.canonical,Je,dt,this.transform,z.getProjection(),vt);let xt=null;const pt=z.getProjection().createInversionMatrix(this.transform,T.tileID.canonical);if(Je){const Ft=cn(Pe,T.tileID.canonical,Je,dt,this.transform,z.getProjection(),vt);xt=i.aB([],this.transform.labelPlaneMatrix,Ft)}let Pt=null;tt&&T.latestFeatureIndex&&(Pt={unwrappedTileID:xe,dynamicFilter:tt,dynamicFilterNeedsFeature:Mt}),this.retainedQueryData[z.bucketInstanceId]=new nb(z.bucketInstanceId,H,z.sourceLayerIndex,z.index,T.tileID);const[Ht,Vt]=z.layers[0].layout.get("text-size-scale-range"),ts=i.aA(F,Ht,Vt),[ss,ps]=Q.get("icon-size-scale-range"),Bs=i.aA(F,ss,ps),Xt={bucket:z,layout:Q,paint:re,posMatrix:Pe,invMatrix:pt,mercatorCenter:[i.aF(this.transform.center.lng),i.aJ(this.transform.center.lat)],textLabelPlaneMatrix:kt,labelToScreenMatrix:xt,clippingData:Pt,scale:ge,textPixelRatio:me,holdingForFade:T.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:T.latestFeatureIndex};if(D)for(const Ft of z.sortKeyRanges){const{sortKey:cs,symbolInstanceStart:es,symbolInstanceEnd:Es}=Ft;h.push({sortKey:cs,symbolInstanceStart:es,symbolInstanceEnd:Es,parameters:Xt})}else h.push({symbolInstanceStart:0,symbolInstanceEnd:z.symbolInstances.length,parameters:Xt})}attemptAnchorPlacement(h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Ce,$e,Be,Je,dt,tt,Mt){const{textOffset0:vt,textOffset1:kt,crossTileID:xt}=Ce,pt=[vt,kt],Pt=md(h,z,H,pt,Q),Ht=this.collisionIndex.placeCollisionBox(Be,Q,x,T,D,F,nl(Pt.x,Pt.y,re,oe,this.transform.angle),Pe,ge,me,xe.predicate);if(dt){const Vt=Be.getSymbolInstanceIconSize(Mt,this.transform.zoom,Ce.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(Be,Vt,dt,T,D,F,nl(Pt.x,Pt.y,re,oe,this.transform.angle),Pe,ge,me,xe.predicate).box.length===0)return}if(Ht.box.length>0){let Vt;return this.prevPlacement&&this.prevPlacement.variableOffsets[xt]&&this.prevPlacement.placements[xt]&&this.prevPlacement.placements[xt].text&&(Vt=this.prevPlacement.variableOffsets[xt].anchor),this.variableOffsets[xt]={textOffset:pt,width:z,height:H,anchor:h,textScale:Q,prevAnchor:Vt},this.markUsedJustification(Be,h,Ce,Je),Be.allowVerticalPlacement&&(this.markUsedOrientation(Be,Je,Ce),this.placedOrientations[xt]=Je),{shift:Pt,placedGlyphBoxes:Ht}}}placeLayerBucketPart(h,x,T,D,F=1){const{bucket:z,layout:H,paint:Q,posMatrix:re,textLabelPlaneMatrix:oe,labelToScreenMatrix:ge,clippingData:me,textPixelRatio:xe,mercatorCenter:Pe,invMatrix:Ce,holdingForFade:$e,collisionBoxArray:Be,partiallyEvaluatedTextSize:Je,partiallyEvaluatedIconSize:dt,collisionGroup:tt,latestFeatureIndex:Mt}=h.parameters,vt=H.get("text-optional"),kt=H.get("icon-optional"),xt=H.get("text-allow-overlap"),pt=H.get("icon-allow-overlap"),Pt=H.get("text-rotation-alignment")==="map",Ht=H.get("icon-rotation-alignment")==="map",Vt=H.get("text-pitch-alignment")==="map",ts=Q.get("symbol-z-offset"),ss=H.get("symbol-elevation-reference")==="sea",ps=H.get("symbol-placement"),[Bs,Xt]=H.get("text-size-scale-range"),[Ft,cs]=H.get("icon-size-scale-range"),es=i.aA(F,Bs,Xt),Es=i.aA(F,Ft,cs),Qs=H.get("text-variable-anchor"),mr=Pt&&ps!=="point",Ks=Ht&&ps!=="point",$s=Qs&&z.hasTextData(),Cr=z.hasIconTextFit()&&$s&&z.hasIconData();this.transform.setProjection(z.projection);const kr=$s||mr,or=Ks||Cr;let fr=xt&&(pt||!z.hasIconData()||kt),qr=pt&&(xt||!z.hasTextData()||vt);const jn=!ts.isConstant();!z.collisionArrays&&Be&&z.deserializeCollisionBoxes(Be),T&&D&&z.updateCollisionDebugBuffers(this.transform.zoom,Be,es,Es);const ha=(Er,Ra,vn)=>{const{crossTileID:Qa,numVerticalGlyphVertices:pi}=Er;let oi=null;if(me&&me.dynamicFilterNeedsFeature||jn){const wo=this.retainedQueryData[z.bucketInstanceId];oi=Mt.loadFeature({featureIndex:Er.featureIndex,bucketIndex:wo.bucketIndex,sourceLayerIndex:wo.sourceLayerIndex,layoutVertexArrayOffset:0});const Oo=oi.properties?oi.properties.worldview:null;if(z.localizable&&z.worldview&&typeof Oo=="string")if(Oo==="all")oi.properties.$localized=!0;else{if(!Oo.split(",").includes(z.worldview))return;oi.properties.$localized=!0,oi.properties.worldview=z.worldview}}if(me&&!(0,me.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(me.unwrappedTileID)))return this.placements[Qa]=new ri(!1,!1,!1,!0),void x.add(Qa);const La=ts.evaluate(oi,{});if(x.has(Qa))return;if($e)return void(this.placements[Qa]=new ri(!1,!1,!1));let Fn=!1,Ya=!1,fo=!0,Hi=!1,Ja=!1,Na=null,zn={box:null,offscreen:null,occluded:null},zi={box:null},To=null,ho=null,wi=null,eu=0,ed=0,bl=0;vn.textFeatureIndex?eu=vn.textFeatureIndex:Er.useRuntimeCollisionCircles&&(eu=Er.featureIndex),vn.verticalTextFeatureIndex&&(ed=vn.verticalTextFeatureIndex);const fd=z.elevationFeatures?z.elevationFeatures[Er.elevationFeatureIndex]:void 0,gd=wo=>{wo.tileID=this.retainedQueryData[z.bucketInstanceId].tileID;const Oo=this.transform.elevation;wo.elevation=ss?La:La+i.bV.getAtTileOffset(wo.tileID,new i.P(wo.tileAnchorX,wo.tileAnchorY),Oo,fd),wo.elevation+=Er.zOffset},Ec=vn.textBox;if(Ec){gd(Ec);const wo=ji=>{let Go=i.bL.horizontal;if(z.allowVerticalPlacement&&!ji&&this.prevPlacement){const go=this.prevPlacement.placedOrientations[Qa];go&&(this.placedOrientations[Qa]=go,Go=go,this.markUsedOrientation(z,Go,Er))}return Go},Oo=(ji,Go)=>{if(z.allowVerticalPlacement&&pi>0&&vn.verticalTextBox){for(const go of z.writingModes)if(go===i.bL.vertical?(zn=Go(),zi=zn):zn=ji(),zn&&zn.box&&zn.box.length)break}else zn=ji()};if(Qs){let ji=Qs;if(this.prevPlacement&&this.prevPlacement.variableOffsets[Qa]){const mo=this.prevPlacement.variableOffsets[Qa];ji.indexOf(mo.anchor)>0&&(ji=ji.filter(dm=>dm!==mo.anchor),ji.unshift(mo.anchor))}const Go=(mo,dm,Ib)=>{const Km=z.getSymbolInstanceTextSize(Je,Er,this.transform.zoom,Ra),Lb=(mo.x2-mo.x1)*Km+2*mo.padding,Dv=(mo.y2-mo.y1)*Km+2*mo.padding,Rp=Er.hasIconTextFit&&!pt?dm:null;Rp&&gd(Rp);let Xf={box:[],offscreen:!1,occluded:!1};const Ov=xt?2*ji.length:ji.length;for(let fx=0;fx=ji.length,Er,Ra,z,Ib,Rp,Je,dt);if(Qf&&(Xf=Qf.placedGlyphBoxes,Xf&&Xf.box&&Xf.box.length)){Fn=!0,Na=Qf.shift;break}}return Xf};Oo(()=>Go(Ec,vn.iconBox,i.bL.horizontal),()=>{const mo=vn.verticalTextBox;return mo&&gd(mo),z.allowVerticalPlacement&&!(zn&&zn.box&&zn.box.length)&&pi>0&&mo?Go(mo,vn.verticalIconBox,i.bL.vertical):{box:null,offscreen:null,occluded:null}}),zn&&(Fn=zn.box,fo=zn.offscreen,Hi=zn.occluded);const go=wo(!(!zn||!zn.box));if(!Fn&&this.prevPlacement){const mo=this.prevPlacement.variableOffsets[Qa];mo&&(this.variableOffsets[Qa]=mo,this.markUsedJustification(z,mo.anchor,Er,go))}}else{const ji=(Go,go)=>{const mo=z.getSymbolInstanceTextSize(Je,Er,this.transform.zoom,Ra),dm=this.collisionIndex.placeCollisionBox(z,mo,Go,Pe,Ce,kr,new i.P(0,0),xt,xe,re,tt.predicate);return dm&&dm.box&&dm.box.length&&(this.markUsedOrientation(z,go,Er),this.placedOrientations[Qa]=go),dm};Oo(()=>ji(Ec,i.bL.horizontal),()=>{const Go=vn.verticalTextBox;return z.allowVerticalPlacement&&pi>0&&Go?(gd(Go),ji(Go,i.bL.vertical)):{box:null,offscreen:null,occluded:null}}),wo(!!(zn&&zn.box&&zn.box.length))}}if(To=zn,Fn=To&&To.box&&To.box.length>0,fo=To&&To.offscreen,Hi=To&&To.occluded,Er.useRuntimeCollisionCircles){const wo=Er.centerJustifiedTextSymbolIndex>=0?Er.centerJustifiedTextSymbolIndex:Er.verticalPlacedTextSymbolIndex,Oo=z.text.placedSymbolArray.get(wo),ji=i.bM(z.textSizeData,Je,Oo),Go=H.get("text-padding");ho=this.collisionIndex.placeCollisionCircles(z,xt,Oo,wo,z.lineVertexArray,z.glyphOffsetArray,ji,re,oe,ge,T,Vt,tt.predicate,Er.collisionCircleDiameter*ji/i.bY,Go,this.retainedQueryData[z.bucketInstanceId].tileID),Fn=xt||ho.circles.length>0&&!ho.collisionDetected,fo=fo&&ho.offscreen,Hi=ho.occluded}if(vn.iconFeatureIndex&&(bl=vn.iconFeatureIndex),vn.iconBox){const wo=Oo=>{gd(Oo);const ji=Er.hasIconTextFit&&Na?nl(Na.x,Na.y,Pt,Vt,this.transform.angle):new i.P(0,0),Go=z.getSymbolInstanceIconSize(dt,this.transform.zoom,Er.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(z,Go,Oo,Pe,Ce,or,ji,pt,xe,re,tt.predicate)};zi&&zi.box&&zi.box.length&&vn.verticalIconBox?(wi=wo(vn.verticalIconBox),Ya=wi.box.length>0):(wi=wo(vn.iconBox),Ya=wi.box.length>0),fo=fo&&wi.offscreen,Ja=wi.occluded}const yh=vt||Er.numHorizontalGlyphVertices===0&&pi===0,cm=kt||Er.numIconVertices===0;if(yh||cm?cm?yh||(Ya=Ya&&Fn):Fn=Ya&&Fn:Ya=Fn=Ya&&Fn,Fn&&To&&To.box&&this.collisionIndex.insertCollisionBox(To.box,H.get("text-ignore-placement"),z.bucketInstanceId,zi&&zi.box&&ed?ed:eu,tt.ID),Ya&&wi&&this.collisionIndex.insertCollisionBox(wi.box,H.get("icon-ignore-placement"),z.bucketInstanceId,bl,tt.ID),ho&&(Fn&&this.collisionIndex.insertCollisionCircles(ho.circles,H.get("text-ignore-placement"),z.bucketInstanceId,eu,tt.ID),T)){const wo=z.bucketInstanceId;let Oo=this.collisionCircleArrays[wo];Oo===void 0&&(Oo=this.collisionCircleArrays[wo]=new mS);for(let ji=0;ji=0;--Ra){const vn=Er[Ra];ha(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 Ra=0;Ra=0&&(h.text.placedSymbolArray.get(F).crossTileID=ge>=0&&F!==ge?0:re),z>=0&&(h.text.placedSymbolArray.get(z).crossTileID=ge>=0&&z!==ge?0:re),H>=0&&(h.text.placedSymbolArray.get(H).crossTileID=ge>=0&&H!==ge?0:re),Q>=0&&(h.text.placedSymbolArray.get(Q).crossTileID=ge>=0&&Q!==ge?0:re)}markUsedOrientation(h,x,T){const D=x===i.bL.horizontal||x===i.bL.horizontalOnly?x:0,F=x===i.bL.vertical?x:0,{leftJustifiedTextSymbolIndex:z,centerJustifiedTextSymbolIndex:H,rightJustifiedTextSymbolIndex:Q,verticalPlacedTextSymbolIndex:re}=T,oe=h.text.placedSymbolArray;z>=0&&(oe.get(z).placedOrientation=D),H>=0&&(oe.get(H).placedOrientation=D),Q>=0&&(oe.get(Q).placedOrientation=D),re>=0&&(oe.get(re).placedOrientation=F)}commit(h){this.commitTime=h,this.zoomAtLastRecencyCheck=this.transform.zoom;const x=this.prevPlacement;let T=!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:{},H=x?x.placedOrientations:{};for(const Q in this.placements){const re=this.placements[Q],oe=F[Q];oe?(this.opacities[Q]=new Mp(oe,D,re.text,re.icon,null,re.clipped),T=T||re.text!==oe.text.placed||re.icon!==oe.icon.placed):(this.opacities[Q]=new Mp(null,D,re.text,re.icon,re.skipFade,re.clipped),T=T||re.text||re.icon)}for(const Q in F){const re=F[Q];if(!this.opacities[Q]){const oe=new Mp(re,D,!1,!1);oe.isHidden()||(this.opacities[Q]=oe,T=T||re.text.placed||re.icon.placed)}}for(const Q in z)this.variableOffsets[Q]||!this.opacities[Q]||this.opacities[Q].isHidden()||(this.variableOffsets[Q]=z[Q]);for(const Q in H)this.placedOrientations[Q]||!this.opacities[Q]||this.opacities[Q].isHidden()||(this.placedOrientations[Q]=H[Q]);T?this.lastPlacementChangeTime=h:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=x?x.lastPlacementChangeTime:h)}updateLayerOpacities(h,x,T,D){D&&(this.lastReplacementSourceUpdateTime=D.updateTime);const F=new Set;for(const z of x){const H=z.getBucket(h);H&&z.latestFeatureIndex&&h.fqid===H.layerIds[0]&&(this.updateBucketOpacities(H,F,z,z.collisionBoxArray,T,D,z.tileID,h.scope),H.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(H,z.tileID),H.elevationType==="road"&&H.updateRoadElevation(z.tileID.canonical),H.updateZOffset())}}updateBucketOpacities(h,x,T,D,F,z,H,Q){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 re=h.layers[0].layout,oe=h.layers[0].paint,ge=!!h.layers[0].dynamicFilter(),me=new Mp(null,0,!1,!1,!0),xe=re.get("text-allow-overlap"),Pe=re.get("icon-allow-overlap"),Ce=re.get("text-variable-anchor"),$e=re.get("text-rotation-alignment")==="map",Be=re.get("text-pitch-alignment")==="map",Je=oe.get("symbol-z-offset"),dt=re.get("symbol-elevation-reference")==="sea",tt=!Je.isConstant(),Mt=new Mp(null,0,xe&&(Pe||!h.hasIconData()||re.get("icon-optional")),Pe&&(xe||!h.hasTextData()||re.get("text-optional")),!0);!h.collisionArrays&&D&&(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData())&&h.deserializeCollisionBoxes(D);const vt=(xt,pt,Pt)=>{for(let Ht=0;Ht0||Ht>0,Qs=ts>0,mr=this.placedOrientations[Vt],Ks=mr===i.bL.vertical,$s=mr===i.bL.horizontal||mr===i.bL.horizontalOnly;!Es&&!Qs||es.isHidden()||kt++;let Cr=!1;if((Es||Qs)&&z)for(const kr of h.activeReplacements){if(i.bZ(kr,F,i.b_.Symbol,Q)||kr.min.x>ss||ss>kr.max.x||kr.min.y>ps||ps>kr.max.y)continue;const or=i.b$(ss,ps,H.canonical,kr.footprintTileId.canonical);if(Cr=i.c0(or,kr.footprint),Cr)break}if(Es){const kr=Cr?jy:Yd(es.text);vt(h.text,Pt,Ks?jy:kr),vt(h.text,Ht,$s?jy:kr);const or=es.text.isHidden(),{leftJustifiedTextSymbolIndex:fr,centerJustifiedTextSymbolIndex:qr,rightJustifiedTextSymbolIndex:jn,verticalPlacedTextSymbolIndex:ha}=pt,Wa=h.text.placedSymbolArray,Er=or||Ks?1:0;fr>=0&&(Wa.get(fr).hidden=Er),qr>=0&&(Wa.get(qr).hidden=Er),jn>=0&&(Wa.get(jn).hidden=Er),ha>=0&&(Wa.get(ha).hidden=or||$s?1:0);const Ra=this.variableOffsets[Vt];Ra&&this.markUsedJustification(h,Ra.anchor,pt,mr);const vn=this.placedOrientations[Vt];vn&&(this.markUsedJustification(h,"left",pt,vn),this.markUsedOrientation(h,vn,pt))}if(Qs){const kr=Cr?jy:Yd(es.icon),{placedIconSymbolIndex:or,verticalPlacedIconSymbolIndex:fr}=pt,qr=h.icon.placedSymbolArray,jn=es.icon.isHidden()?1:0;or>=0&&(vt(h.icon,ts,Ks?jy:kr),qr.get(or).hidden=jn),fr>=0&&(vt(h.icon,pt.numVerticalIconVertices,$s?jy:kr),qr.get(fr).hidden=jn)}if(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData()){const kr=h.collisionArrays[xt];if(kr){let or=new i.P(0,0),fr=!0;if(kr.textBox||kr.verticalTextBox){if(Ce){const jn=this.variableOffsets[Vt];jn?(or=md(jn.anchor,jn.width,jn.height,jn.textOffset,jn.textScale),$e&&or._rotate(Be?this.transform.angle:-this.transform.angle)):fr=!1}ge&&(fr=!es.clipped),kr.textBox&&ex(h.textCollisionBox.collisionVertexArray,es.text.placed,!fr||Ks,Ft,dt,or.x,or.y),kr.verticalTextBox&&ex(h.textCollisionBox.collisionVertexArray,es.text.placed,!fr||$s,Ft,dt,or.x,or.y)}const qr=fr&&!!(!$s&&kr.verticalIconBox);kr.iconBox&&ex(h.iconCollisionBox.collisionVertexArray,es.icon.placed,qr,Ft,dt,pt.hasIconTextFit?or.x:0,pt.hasIconTextFit?or.y:0),kr.verticalIconBox&&ex(h.iconCollisionBox.collisionVertexArray,es.icon.placed,!qr,Ft,dt,pt.hasIconTextFit?or.x:0,pt.hasIconTextFit?or.y:0)}}}if(h.fullyClipped=kt===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 xt=this.collisionCircleArrays[h.bucketInstanceId];h.placementInvProjMatrix=xt.invProjMatrix,h.placementViewportMatrix=xt.viewportMatrix,h.collisionCircleArray=xt.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 ex(M,h,x,T,D,F,z){M.emplaceBack(h?1:0,x?1:0,F||0,z||0,T,D?1:0),M.emplaceBack(h?1:0,x?1:0,F||0,z||0,T,D?1:0),M.emplaceBack(h?1:0,x?1:0,F||0,z||0,T,D?1:0),M.emplaceBack(h?1:0,x?1:0,F||0,z||0,T,D?1:0)}const HM=Math.pow(2,25),ib=Math.pow(2,24),pS=Math.pow(2,17),WM=Math.pow(2,16),fS=Math.pow(2,9),Zd=Math.pow(2,8),Ff=Math.pow(2,1);function Yd(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*HM+h*ib+x*pS+h*WM+x*fS+h*Zd+x*Ff+h}const jy=0;class hv{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,T,D,F,z){const H=this._bucketParts;for(;this._currentTileIndexQ.sortKey-re.sortKey));this._currentPartIndex{const Q=i.o.now()-z;return!this._forceFullPlacement&&Q>2};for(;this._currentPlacementIndex>=0;){const Q=x[h[this._currentPlacementIndex]],re=this.placement.collisionIndex.transform.zoom;if(Q.type==="symbol"&&Q.visibility!=="none"&&(!Q.minzoom||Q.minzoom<=re)&&(!Q.maxzoom||Q.maxzoom>re)){const oe=Q,ge=oe.layout.get("symbol-z-elevate"),me=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"&&me),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"),$e=Pe&&Ce,Be=this._inProgressLayer=this._inProgressLayer||new hv(oe),Je=i.B(Q.source,Q.scope);if(Be.continuePlacement(ge||$e?D[Je]:T[Je],this.placement,this._showCollisionBoxes,Q,H,F))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(h){return this.placement.commit(h),this.placement}}const rm=512/i.al/2;class zf{constructor(h,x,T){this.tileID=h,this.bucketInstanceId=T,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;z$e-Be);for(const $e of Ce){const Be=this.crossTileIDs[$e];if(this.keys[$e]===oe&&!T.has(Be)){T.add(Be),re.crossTileID=Be;break}}}}}class ql{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class GM{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(h){const x=Math.round((h-this.lng)/360);if(x!==0)for(const T in this.indexes){const D=this.indexes[T],F={};for(const z in D){const H=D[z];H.tileID=H.tileID.unwrapTo(H.tileID.wrap+x),F[H.tileID.key]=H}this.indexes[T]=F}this.lng=h}addBucket(h,x,T){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 H in z){const Q=z[H];Q.tileID.isChildOf(h)&&Q.findMatches(x.symbolInstances,h,D)}else{const H=z[h.scaledTo(Number(F)).key];H&&H.findMatches(x.symbolInstances,h,D)}}for(let F=0;F{x[T]=!0});for(const T in this.layerIndexes)x[T]||delete this.layerIndexes[T]}}const Tp=771;class Dn{constructor(h,x,T,D){this.blendFunction=h,this.blendColor=x.toNonPremultipliedRenderColor(null),this.mask=T,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,Tp,1,Tp],i.ao.transparent,[!0,!0,!0,!0]),Dn.alphaBlendedNonPremultiplied=new Dn([770,Tp,770,Tp],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 Pr{constructor(h,x,T){this.func=h,this.mask=x,this.range=T}}Pr.ReadOnly=!1,Pr.ReadWrite=!0,Pr.disabled=new Pr(519,Pr.ReadOnly,[0,1]);const gS=7680;class dn{constructor(h,x,T,D,F,z){this.test=h,this.ref=x,this.mask=T,this.fail=D,this.depthFail=F,this.pass=z}}dn.disabled=new dn({func:519,mask:0},0,0,gS,gS,gS);const mv=1029,xS=2305;class nn{constructor(h,x,T){this.enable=h,this.mode=x,this.frontFace=T}}function Ap(M,h){const x=i.ca(M,3);i.cc(M,h),i.cg(M,3,x)}function KM(M,h){const x=i.c7([]);return i.c8(x,x,-h),i.c9(x,x,-M),x}function yS(M,h){const x=[M[0],M[1],0],T=[h[0],h[1],0];if(i.ag(x)>=1e-15){const z=i.aw([],x);i.c5(T,z,i.bJ(T,z)),h[0]=T[0],h[1]=T[1]}const D=i.bI([],h,M);if(i.c6(D)<1e-15)return null;const F=Math.atan2(-D[1],D[0]);return KM(Math.atan2(Math.sqrt(M[0]*M[0]+M[1]*M[1]),-M[2]),F)}nn.disabled=new nn(!1,mv,xS),nn.backCCW=new nn(!0,mv,xS),nn.backCW=new nn(!0,mv,2304),nn.frontCW=new nn(!0,1028,2304),nn.frontCCW=new nn(!0,1028,xS);class Xd{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,T){if(this.orientation=null,!this.position)return;const D=this.position,F=T||(this._elevation?this._elevation.getAtPointOrZero(i.ae.fromLngLat(h)):0),z=i.ae.fromLngLat(h,F),H=[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=yS(H,x)}setPitchBearing(h,x){this.orientation=KM(i.an(h),i.an(-x))}}class vS{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&&Ap(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=KM(h,x),Ap(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 T=new Float64Array(16);return i.bl(T,this.getWorldToCamera(h,x)),T}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(h,x,T){const D=this.position;i.c5(D,D,-h);const F=new Float64Array(16);return i.bq(F,[T,T,T]),i.br(F,F,D),F[10]*=x,F}getWorldToCamera(h,x){const T=new Float64Array(16),D=new Float64Array(4),F=this.position;return i.cb(D,this._orientation),i.c5(F,F,-h),i.cc(T,D),i.br(T,T,F),T[1]*=-1,T[5]*=-1,T[9]*=-1,T[13]*=-1,T[8]*=x,T[9]*=x,T[10]*=x,T[11]*=x,T}getCameraToClipPerspective(h,x,T,D){const F=new Float64Array(16);return i.cd(F,h,x,T,D),F}getCameraToClipOrthographic(h,x,T,D,F,z){const H=new Float64Array(16);return i.ce(H,h,x,T,D,F,z),H}getDistanceToElevation(h,x=!1){const T=h===0?0:i.cf(h,x?i.a$(this.position[1]):this.position[1]),D=this.forward();return(T-this.position[2])/D[2]}clone(){return new vS([...this.position],[...this.orientation])}}const xc={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class _S{constructor(h=0,x=0,T=0,D=0){if(isNaN(h)||h<0||isNaN(x)||x<0||isNaN(T)||T<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=T,this.right=D}interpolate(h,x,T){return x.top!=null&&h.top!=null&&(this.top=i.ak(h.top,x.top,T)),x.bottom!=null&&h.bottom!=null&&(this.bottom=i.ak(h.bottom,x.bottom,T)),x.left!=null&&h.left!=null&&(this.left=i.ak(h.left,x.left,T)),x.right!=null&&h.right!=null&&(this.right=i.ak(h.right,x.right,T)),this}getCenter(h,x){const T=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(T,D)}equals(h){return this.top===h.top&&this.bottom===h.bottom&&this.left===h.left&&this.right===h.right}clone(){return new _S(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Vm=15;class ZM{constructor(h,x,T,D,F,z,H){this.tileSize=512,this._renderWorldCopies=F===void 0||F,this._minZoom=h||0,this._maxZoom=x||22,this._minPitch=T??0,this._maxPitch=D??60,this.setProjection(z),this.setMaxBounds(H),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 _S,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new vS,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 ZM(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 T=this._elevation;x||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&T.exaggeration()&&this._centerAltitudeValidForExaggeration!==T.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*T.exaggeration(),this._centerAltitudeValidForExaggeration=T.exaggeration()):(this._centerAltitude=h||0,this._centerAltitudeValidForExaggeration=T.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]],T=this.horizonLineFromTop();let D=0,F=0;for(let z=0;z{const $e=i.cY(me,ge,xe,Pe,Ce);Q.has($e)||(F.push(new i.aQ(ge,me,xe,Pe,Ce)),Q.add($e))};for(let ge=0;geme.canonical.z)continue;const xe=me.canonical,Pe=me.overscaledZ,Ce=me.wrap,$e=1<0,dt=xe.y+1<$e,tt=xe.y>0,Mt=me.wrap-(Je?0:1),vt=me.wrap+(Be?0:1),kt=Je?xe.x-1:$e-1,xt=Be?xe.x+1:0;if(z)T[0]<0?(re(Pe,vt,xe.z,xt,xe.y),T[1]<0&&dt&&(re(Pe,Ce,xe.z,xe.x,xe.y+1),re(Pe,vt,xe.z,xt,xe.y+1)),T[1]>0&&tt&&(re(Pe,Ce,xe.z,xe.x,xe.y-1),re(Pe,vt,xe.z,xt,xe.y-1))):T[0]>0?(re(Pe,Mt,xe.z,kt,xe.y),T[1]<0&&dt&&(re(Pe,Ce,xe.z,xe.x,xe.y+1),re(Pe,Mt,xe.z,kt,xe.y+1)),T[1]>0&&tt&&(re(Pe,Ce,xe.z,xe.x,xe.y-1),re(Pe,Mt,xe.z,kt,xe.y-1))):T[1]<0&&dt?re(Pe,Ce,xe.z,xe.x,xe.y+1):tt&&re(Pe,Ce,xe.z,xe.x,xe.y-1);else{const pt=me.visibleQuadrants;1&pt&&(re(Pe,Mt,xe.z,kt,xe.y),tt&&(re(Pe,Ce,xe.z,xe.x,xe.y-1),re(Pe,Mt,xe.z,kt,xe.y-1))),2&pt&&(re(Pe,vt,xe.z,xt,xe.y),tt&&(re(Pe,Ce,xe.z,xe.x,xe.y-1),re(Pe,vt,xe.z,xt,xe.y-1))),4&pt&&(re(Pe,Mt,xe.z,kt,xe.y),dt&&(re(Pe,Ce,xe.z,xe.x,xe.y+1),re(Pe,Mt,xe.z,kt,xe.y+1))),8&pt&&(re(Pe,vt,xe.z,xt,xe.y),dt&&(re(Pe,Ce,xe.z,xe.x,xe.y+1),re(Pe,vt,xe.z,xt,xe.y+1)))}}const oe=[];for(const ge of F)F.some(me=>ge.isChildOf(me))||oe.push(ge);if(F=oe.filter(ge=>!h.some(me=>!!(ge.overscaledZ{const Be=$e.canonical.x+.5-xe[0],Je=$e.canonical.y+.5-xe[1];return Be*Be+Je*Je{const kt=i.cY(dt,Je,tt,Mt,vt);F.has(kt)||(D.push(new i.aQ(Je,dt,tt,Mt,vt)),F.add(kt))},H=h.reduce((Je,dt)=>Math.max(Je,dt.overscaledZ),T),Q=1<{const tt=Math.floor(Je[0]),Mt=Math.floor(Je[1]),vt=(Je[0]-tt)*i.al,kt=(Je[1]-Mt)*i.al,xt=Math.floor(dt[0]),pt=Math.floor(dt[1]),Pt=(dt[0]-xt)*i.al,Ht=(dt[1]-pt)*i.al;for(let Vt=-1;Vt<=1;Vt++){const ts=tt+Vt;if(!(ts<0||ts>=Q)){oe.x=vt-Vt*i.al,ge.x=Pt-(ts-xt)*i.al;for(let ss=-1;ss<=1;ss++){const ps=Mt+ss;oe.y=kt-ss*i.al,ge.y=Ht-(ps-pt)*i.al,i.cZ(oe,ge,re)&&z(H,0,T,ts,ps)}}}},xe=x.points,Pe=xe[i.cv],Ce=xe[i.cw],$e=this._projectToGround(Pe,xe[i.cx]),Be=this._projectToGround(Ce,xe[i.cy]);return me(Pe,$e),me(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 T=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 H=this.locationCoordinate(this.center),Q=this.center.lat,re=1<{const es=new i.ae(Ft.x+25e-6,Ft.y,Ft.z),Es=new i.ae(Ft.x,Ft.y+25e-6,Ft.z),Qs=Ft.toLngLat(),mr=es.toLngLat(),Ks=Es.toLngLat(),$s=this.locationCoordinate(Qs),Cr=this.locationCoordinate(mr),kr=this.locationCoordinate(Ks),or=Math.hypot(Cr.x-$s.x,Cr.y-$s.y),fr=Math.hypot(kr.x-$s.x,kr.y-$s.y);return Math.sqrt(or*fr)*kt/25e-6},pt=Ft=>{const cs=Mt,es=vt;return{aabb:i.cF(this,re,0,0,0,Ft,es,cs,this.projection),zoom:0,x:0,y:0,minZ:es,maxZ:cs,wrap:Ft,fullyVisible:!1}},Pt=[];let Ht=[];const Vt=x,ts=h.reparseOverscaled?T:x,ss=($e-this._centerAltitude)*Ce,ps=Ft=>{if(!this._elevation||!Ft.tileID||!z)return;const cs=this._elevation.getMinMaxForTile(Ft.tileID),es=Ft.aabb;cs?(es.min[2]=cs.min,es.max[2]=cs.max,es.center[2]=(es.min[2]+es.max[2])/2):(Ft.shouldSplit=Xt(Ft),Ft.shouldSplit||(es.min[2]=es.max[2]=es.center[2]=this._centerAltitude))},Bs=(Ft,cs)=>{if(.707*cs{if(Ft.zoom=.9)return!0}else if(F&&(Es=Ft.aabb.distanceZ(Be)*Ce),this.projection.isReprojectedInTileSpace&&T<=5){const fr=Math.pow(2,Ft.zoom),qr=xt(new i.ae((Ft.x+.5)/fr,(Ft.y+.5)/fr));Qs=qr>.85?1:qr}if(!z&&!ge){const fr=Math.sqrt(cs*cs+es*es+Es*Es);let qr=(1<0;){const Ft=Pt.pop(),cs=Ft.x,es=Ft.y;let Es=Ft.fullyVisible;const Qs=()=>this.projection.name==="globe"&&(Ft.y===0||Ft.y===(1<>1),Cr={aabb:z?Ft.aabb.quadrant(mr):i.cF(this,re,Ft.zoom+1,Ks,$s,Ft.wrap,Ft.minZ,Ft.maxZ,this.projection),zoom:Ft.zoom+1,x:Ks,y:$s,wrap:Ft.wrap,fullyVisible:Es,tileID:void 0,shouldSplit:void 0,minZ:Ft.minZ,maxZ:Ft.maxZ};F&&!ge&&(Cr.tileID=new i.aQ(Ft.zoom+1===Vt?ts:Ft.zoom+1,Ft.wrap,Ft.zoom+1,Ks,$s),ps(Cr)),Pt.push(Cr)}else{const mr=Ft.zoom===Vt?ts:Ft.zoom;if(h.minzoom&&h.minzoom>mr)continue;let Ks=0;if(!Es){let or=Je?Ft.aabb.intersectsPrecise(xe):Ft.aabb.intersectsPreciseFlat(xe);if(or===0&&Qs()){const fr=new i.cD(Ft.zoom,cs,es);or=i.cE(this,re,fr,!0).intersectsPrecise(xe)}if(or===0)continue;if(h.calculateQuadrantVisibility)if(xe.containsPoint(Ft.aabb.center))Ks=15;else for(let fr=0;fr<4;fr++)Ft.aabb.quadrant(fr).intersects(xe)!==0&&(Ks|=1<{const Es=[0,0,0,1],Qs=[i.al,i.al,0,1],mr=this.calculateFogTileMatrix(es.tileID.toUnwrapped());i.aC(Es,Es,mr),i.aC(Qs,Qs,mr);const Ks=i.cG([],Es,Qs),$s=i.cH([],Es,Qs),Cr=i.c$(Ks,$s);if(Cr===0)return!0;let kr=!1;const or=this._elevation;if(or&&Cr>Ft&&cs!==0){const fr=this.calculateProjMatrix(es.tileID.toUnwrapped());let qr;h.isTerrainDEM||(qr=or.getMinMaxForTile(es.tileID)),qr||(qr={min:vt,max:Mt});const jn=i.cI(this.rotation),ha=[jn[0]*i.al,jn[1]*i.al,qr.max];i.af(ha,ha,fr),kr=(1-ha[1])*this.height*.5Ft.distanceSq-cs.distanceSq).map(Ft=>Ft.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),T=this.projection.project(h.lng,x);return new i.P(T.x*this.worldSize,T.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 T,D;const F=this.centerPoint;if(this.projection.name==="globe"){const H=this.worldSize;T=(x.x-F.x)/H,D=(x.y-F.y)/H}else{const H=this.pointCoordinate(x),Q=this.pointCoordinate(F);T=H.x-Q.x,D=H.y-Q.y}const z=this.locationCoordinate(h);this.setLocation(new i.ae(z.x-T,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 T=x?i.cf(x,h.lat):void 0,D=this.projection.project(h.lng,h.lat);return new i.ae(D.x,D.y,T)}coordinateLocation(h){return this.projection.unproject(h.x,h.y)}pointRayIntersection(h,x){const T=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 H=D[2],Q=F[2];return{p0:D,p1:F,t:H===Q?0:(T-H)/(Q-H)}}screenPointToMercatorRay(h){const x=[h.x,h.y,0,1],T=[h.x,h.y,1,1];return i.aC(x,x,this.pixelMatrixInverse),i.aC(T,T,this.pixelMatrixInverse),i.cK(x,x,1/x[3]),i.cK(T,T,1/T[3]),x[2]=i.cf(x[2],this._center.lat)*this.worldSize,T[2]=i.cf(T[2],this._center.lat)*this.worldSize,i.cK(x,x,1/this.worldSize),i.cK(T,T,1/this.worldSize),new i.ax([x[0],x[1],x[2]],i.aw([],i.av([],T,x)))}rayIntersectionCoordinate(h){const{p0:x,p1:T,t:D}=h,F=i.cf(x[2],this._center.lat),z=i.cf(T[2],this._center.lat);return new i.ae(i.ak(x[0],T[0],D)/this.worldSize,i.ak(x[1],T[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 T=this.projection.pointCoordinate3D(this,h.x,h.y);if(T)return new i.ae(T[0],T[1],T[2]);let D=0,F=this.horizonLineFromTop();if(h.y>F)return this.pointCoordinate(h,x);const z=.02*F,H=h.clone();for(let Q=0;Q<10&&F-D>z;Q++){H.y=i.ak(D,F,.66);const re=this.projection.pointCoordinate3D(this,H.x,H.y);re?(F=H.y,T=re):D=H.y}return T?new i.ae(T[0],T[1],T[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 T=x&&this.elevation?this.elevation.getAtPointOrZero(h,this._centerAltitude):this._centerAltitude,D=[h.x*this.worldSize,h.y*this.worldSize,T+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,T=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)),H=this.pointLocation3D(new i.P(D,T)),Q=this.pointLocation3D(new i.P(x,T));let re=Math.min(F.lng,z.lng,H.lng,Q.lng),oe=Math.max(F.lng,z.lng,H.lng,Q.lng),ge=Math.min(F.lat,z.lat,H.lat,Q.lat),me=Math.max(F.lat,z.lat,H.lat,Q.lat);const xe=Math.pow(2,-this.zoom)/16*270,Pe=this.projection.name==="globe"?1:4,Ce=($e,Be,Je,dt,tt)=>{const Mt=($e+Je)/2,vt=(Be+dt)/2,kt=new i.P(Mt,vt),{lng:xt,lat:pt}=this.pointLocation3D(kt),Pt=Math.max(0,re-xt,ge-pt,xt-oe,pt-me);re=Math.min(re,xt),oe=Math.max(oe,xt),ge=Math.min(ge,pt),me=Math.max(me,pt),(ttxe)&&(Ce($e,Be,Mt,vt,tt+1),Ce(Mt,vt,Je,dt,tt+1))};if(Ce(x,h,D,h,1),Ce(D,h,D,T,1),Ce(D,T,x,T,1),Ce(x,T,x,h,1),this.projection.name==="globe"){const[$e,Be]=i.cM(this);$e?(me=90,oe=180,re=-180):Be&&(ge=-90,oe=180,re=-180)}return new i.aI(new i.aT(re,ge),new i.aT(oe,me))}_getBoundsRectangular(h,x){const{top:T,left:D}=this._edgeInsets,F=this.height-this._edgeInsets.bottom,z=this.width-this._edgeInsets.right,H=new i.P(D,T),Q=new i.P(z,T),re=new i.P(z,F),oe=new i.P(D,F);let ge=this.pointCoordinate(H,h),me=this.pointCoordinate(Q,h);const xe=this.pointCoordinate(re,x),Pe=this.pointCoordinate(oe,x),Ce=($e,Be)=>(Be.y-$e.y)/(Be.x-$e.x);return ge.y>1&&me.y>=0?ge=new i.ae((1-Pe.y)/Ce(Pe,ge)+Pe.x,1):ge.y<0&&me.y<=1&&(ge=new i.ae(-Pe.y/Ce(Pe,ge)+Pe.x,0)),me.y>1&&ge.y>=0?me=new i.ae((1-xe.y)/Ce(xe,me)+xe.x,1):me.y<0&&ge.y<=1&&(me=new i.ae(-xe.y/Ce(xe,me)+xe.x,0)),new i.aI().extend(this.coordinateLocation(ge)).extend(this.coordinateLocation(me)).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((T,D)=>{if(D.dem){const F=D.dem.tree;T.min=Math.min(T.min,F.minimums[0]),T.max=Math.max(T.max,F.maximums[0])}return T},{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,T=this.height/2-x*(1-this._horizonShift);return h?Math.max(0,T):T}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&&(H=ge-re),ge-oexe&&(z=xe-Q),xe-me{for(let Xt=0;Xt<16;Xt++)ts[Xt]=i.ak(ss[Xt],ps[Xt],Bs)})(H,H,Q,i.d0(this.pitch>=Vm?1:this.pitch/Vm))}else H=Q;const re=i.cP([],Q,z);let oe=i.cP([],H,z);if(this.projection.isReprojectedInTileSpace){const pt=this.locationCoordinate(this.center),Pt=i.bA([]);i.br(Pt,Pt,[pt.x*this.worldSize,pt.y*this.worldSize,0]),i.aB(Pt,Pt,i.cQ(this)),i.br(Pt,Pt,[-pt.x*this.worldSize,-pt.y*this.worldSize,0]),i.aB(oe,oe,Pt),i.aB(re,re,Pt),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 pt=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);pt[8]=2*-h.x/this.width,pt[9]=2*h.y/this.height,this.expandedFarZProjMatrix=i.cP([],pt,z)}else this.expandedFarZProjMatrix=this.projMatrix;const ge=i.bl([],H);this.frustumCorners=i.cT.fromInvProjectionMatrix(ge,this.horizonLineFromTop(),this.height),this.cameraFrustum=i.cB.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!x);const me=new Float32Array(16);i.bA(me),i.cS(me,me,[1,-1,1]),i.cU(me,me,this._pitch),i.bB(me,me,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(me,xe,me);const Ce=this.point,$e=Ce.x,Be=Ce.y,Je=this.width%2/2,dt=this.height%2/2,tt=Math.cos(this.angle),Mt=Math.sin(this.angle),vt=$e-Math.round($e)+tt*Je+Mt*dt,kt=Be-Math.round(Be)+tt*dt+Mt*Je,xt=new Float64Array(oe);if(i.br(xt,xt,[vt>.5?vt-1:vt,kt>.5?kt-1:kt,0]),this.alignedProjMatrix=xt,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,re),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 pt=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=i.af(pt,pt,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,T=this._camera.position,D=1/this.height/this._pixelsPerMercatorPixel,F=[h,h,x];i.c5(F,F,D),i.c5(T,T,-1),i.cW(T,T,F);const z=i.bC();i.br(z,z,T),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,T=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-T[0]*F,D.y/this.worldSize-T[1]*F,h/this.worldSize*this._centerAltitude-T[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),T=this._camera.position[2],D=h[2];let F=1;this.projection.wrap&&(this.center=this.center.wrap()),D>0&&(F=Math.min((x-T)/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:T,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)),H=Math.max((h[2]-F)/Math.cos(T),z),Q=this._zoomFromMercatorZ(H);i.bH(h,h,x,H),this._pitch=i.aA(T,i.an(this.minPitch),i.an(this.maxPitch)),this.angle=i.bT(D,-Math.PI,Math.PI),this._setZoom(i.aA(Q,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,T=i.cL,D=0,F=1/0;for(;T-x>1e-6&&T>x;){const z=x+.5*(T-x),H=this.tileSize*Math.pow(2,z),Q=this.getCameraToCenterDistance(this.projection,z,H),re=this.scaleZoom(Q/(Math.max(0,h)*this.tileSize)),oe=Math.abs(z-re);oere||me.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 T=i.ag(i.av([],this._camera.position,h)),D=this._zoomFromMercatorZ(T)+x;return T-this._mercatorZfromZoom(D)}getCameraPoint(){if(this.projection.name==="globe"){const h=function([x,T,D],F){const z=[x,T,D,1];i.aC(z,z,F);const H=z[3]=Math.max(z[3],1e-6);return z[0]/=H,z[1]/=H,z[2]/=H,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,T=this.worldSize){const D=i.cO(h,x,this.width,this.height,1024),F=h.pixelSpaceConversion(this.center.lat,T,D);let z=.5/Math.tan(.5*this._fov)*this.height*F;return this.isOrthographic&&(z=i.ak(1,z,i.d0(this.pitch>=Vm?1:this.pitch/Vm))),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 tx=(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,T=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,H=((1-(Q=D))*x.cameraToCenterDistance+Q*(x._farZ+z))*T;var Q;return{shouldRenderCutoff:D<1,uniformValues:{u_cutoff_params:[x._nearZ,x._farZ,(H-x._nearZ)/F,(H-z-x._nearZ)/F]}}},nm=2048;class ob{constructor(h,x){this.aabb=h,this.lastCascade=x}}class Ice{add(h,x){const T=this.receivers[h.key];T!==void 0?(T.aabb.min[0]=Math.min(T.aabb.min[0],x.min[0]),T.aabb.min[1]=Math.min(T.aabb.min[1],x.min[1]),T.aabb.min[2]=Math.min(T.aabb.min[2],x.min[2]),T.aabb.max[0]=Math.max(T.aabb.max[0],x.max[0]),T.aabb.max[1]=Math.max(T.aabb.max[1],x.max[1]),T.aabb.max[2]=Math.max(T.aabb.max[2],x.max[2])):this.receivers[h.key]=new ob(x,null)}clear(){this.receivers={}}get(h){return this.receivers[h.key]}computeRequiredCascades(h,x,T){const D=i.d9.fromPoints(h.points);let F=0;for(const z in this.receivers){const H=this.receivers[z];if(!H||!D.intersectsAabb(H.aabb))continue;H.aabb.min=D.closestPoint(H.aabb.min),H.aabb.max=D.closestPoint(H.aabb.max);const Q=H.aabb.getCorners();for(let re=0;re1||me[1]<-1||me[1]>1){oe=!1;break}}if(H.lastCascade=re,F=Math.max(F,re),oe)break}}return F+1}}class pv{constructor(h){this.painter=h,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new Ice,this._depthMode=new Pr(h.context.gl.LEQUAL,Pr.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 T=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=T.style.order.reduce((Pe,Ce)=>{const $e=T.style._mergedLayers[Ce];return Pe+($e.hasShadowPass()&&!$e.isHidden(h.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled))return;const F=T.context,z=nm,H=nm;if(this._cascades.length===0||nm!==this._cascades[0].texture.size[0]){this._cascades=[];for(let Pe=0;Pe<2;++Pe){const Ce=T._shadowMapDebug,$e=F.gl,Be=F.createFramebuffer(z,H,Ce?1:0,"texture"),Je=new i.T(F,{width:z,height:H,data:null},$e.DEPTH_COMPONENT16);if(Be.depthAttachment.set(Je.texture),Ce){const dt=new i.T(F,{width:z,height:H,data:null},$e.RGBA8);Be.colorAttachment0.set(dt.texture)}this._cascades.push({framebuffer:Be,texture:Je,matrix:[],far:0,boundingSphereRadius:0,frustum:new i.cB,scale:0})}}this.shadowDirection=cb(x);let Q=0;if(h.elevation){const Pe=h.elevation,Ce=[1e4,-1e4];Pe.visibleDemTiles.filter($e=>$e.dem).forEach($e=>{const Be=$e.dem.tree;Ce[0]=Math.min(Ce[0],Be.minimums[0]),Ce[1]=Math.max(Ce[1],Be.maximums[0])}),Ce[0]!==1e4&&(Q=(Ce[1]-Ce[0])*Pe.exaggeration())}const re=1.5*h.cameraToCenterDistance,oe=3*re,ge=new Float64Array(16);for(let Pe=0;Pe=0)return{};const F=function(Q,re,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 H={};return H.vertices=F,H.planes=[lb(F[1],F[0],F[4]),lb(F[2],F[1],F[5]),lb(F[3],F[2],F[6]),lb(F[0],F[3],F[7])],H}addShadowReceiver(h,x,T){this._receivers.add(h,i.d9.fromTileIdAndHeight(h,x,T))}getMaxCascadeForTile(h){const x=this._receivers.get(h);return x&&x.lastCascade?x.lastCascade:0}}function lb(M,h,x){const T=i.av([],x,h),D=i.av([],M,h),F=i.bI([],T,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 cb(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 T=i.d6([x[0],x[1],x[2]]);return i.d5(T.x,T.y,T.z)}function Bf(M,h,x){const T=h.properties.get("color-use-theme")==="none",D=h.properties.get("color"),F=h.properties.get("intensity"),z=h.properties.get("direction"),H=[z.x,z.y,z.z],Q=x.properties.get("color-use-theme")==="none",re=x.properties.get("color"),oe=x.properties.get("intensity"),ge=Math.max(i.bJ([0,0,1],H),0),me=[0,0,0];i.c5(me,re.toPremultipliedRenderColor(Q?null:M.getLut(h.scope)).toArray01Linear().slice(0,3),oe);const xe=[0,0,0];return i.c5(xe,D.toPremultipliedRenderColor(T?null:M.getLut(x.scope)).toArray01Linear().slice(0,3),ge*F),i.db([me[0]>0?me[0]/(me[0]+xe[0]):0,me[1]>0?me[1]/(me[1]+xe[1]):0,me[2]>0?me[2]/(me[2]+xe[2]):0])}function sx(M,h,x,T,D,F){const z=M.zoom,H=M.scale,Q=M.worldSize,re=1/Q,oe=M.aspect,ge=Math.sqrt(1+oe*oe)*Math.tan(.5*M.fovX),me=ge*ge,xe=T-x,Pe=T+x;let Ce,$e;me>xe/Pe?(Ce=T,$e=T*ge):(Ce=.5*Pe*(1+me),$e=.5*Math.sqrt(xe*xe+2*(T*T+x*x)*me+Pe*Pe*me*me));const Be=M.projection.pixelsPerMeter(M.center.lat,Q),Je=M._camera.getCameraToWorldMercator(),dt=[0,0,-Ce*re];i.af(dt,dt,Je);let tt=$e*re;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),Qs=M._camera.getCameraToClipPerspective(M._fov,M.width/M.height,x,T);Qs[8]=2*-M.centerOffset.x/M.width,Qs[9]=2*M.centerOffset.y/M.height;const mr=new Float64Array(16);i.cP(mr,Qs,Es);const Ks=new Float64Array(16);i.bl(Ks,mr);const $s=i.cB.fromInvProjectionMatrix(Ks,Q,z,!0);for(const Cr of $s.points){const kr=((vt=Cr)[0]/=H,vt[1]/=H,vt[2]=i.cf(vt[2],M._center.lat),vt);tt=Math.max(tt,i.c6(i.da([],dt,kr)))}}var vt;tt*=D/(D-1);const kt=Math.acos(h[2]),xt=Math.atan2(-h[0],-h[1]),pt=new vS;pt.position=dt,pt.setPitchBearing(kt,xt);const Pt=pt.getWorldToCamera(Q,Be),Ht=tt*Q,Vt=Math.min(M._mercatorZfromZoom(17)*Q*-2,-2*Ht),ts=pt.getCameraToClipOrthographic(-Ht,Ht,-Ht,Ht,Vt,(Ht+F*Be)/h[2]),ss=new Float64Array(16);i.aB(ss,ts,Pt);const ps=i.d5(Math.floor(1e6*dt[0])/1e6*Q,Math.floor(1e6*dt[1])/1e6*Q,0),Bs=.5*D,Xt=[0,0,0];i.af(Xt,ps,ss),i.c5(Xt,Xt,Bs);const Ft=[Math.floor(Xt[0]),Math.floor(Xt[1]),Math.floor(Xt[2])],cs=[0,0,0];i.av(cs,Xt,Ft),i.c5(cs,cs,-1/Bs);const es=new Float64Array(16);return i.bA(es),i.br(es,es,cs),i.aB(ss,es,ss),[ss,Ht]}class Lce 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(T=>{if(!T)return;const D=i.dd(T),F=new i.de(h,x,void 0,void 0,D);return F.computeBoundsAndApplyParent(),F}).catch(T=>{if(T&&T.status===404)return null;this.fire(new i.y(new Error(`Could not load model ${h} from ${x}: ${T.message}`)))})}load(h,x,T={forceReload:!1}){this.models[x]||(this.models[x]={});const D=Object.keys(h),F=[],z=[];for(const H of D){const Q=h[H];this.hasURLBeenRequested(Q)&&!T.forceReload||(this.modelByURL[Q]={modelId:H,scope:x},F.push(this.loadModel(H,Q)),z.push(H)),this.models[x][H]||(this.models[x][H]={model:null,numReferences:1})}this.numModelsLoading[x]=(this.numModelsLoading[x]||0)+z.length,Promise.allSettled(F).then(H=>{for(let Q=0;Q{this.fire(new i.y(new Error(`Could not load models: ${H.message}`)))})}isLoaded(){for(const h in this.numModelsLoading)if(this.numModelsLoading[h]>0)return!1;return!0}hasModel(h,x,T={exactIdMatch:!1}){return!!(T.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,T){this.models[T]||(this.models[T]={}),this.modelUris[T]||(this.modelUris[T]={});const D=this.requestManager.normalizeModelURL(x);if((this.hasModel(h,T,{exactIdMatch:!0})||this.hasModelBeenAdded(h,T))&&this.modelUris[T][h]===D)this.models[T][h].numReferences++;else if(this.hasURLBeenRequested(D)){const{scope:F,modelId:z}=this.modelByURL[D];this.models[F][z].numReferences++}else this.modelUris[T][h]=D,this.load({[h]:this.modelUris[T][h]},T)}addModelURLs(h,x){this.models[x]||(this.models[x]={}),this.modelUris[x]||(this.modelUris[x]={});const T=this.modelUris[x];for(const D in h)T[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 T={};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)?T[D]=this.modelUris[x][D]:!this.hasURLBeenRequested(D)&&i.df(D,!1)&&(this.modelUris[x][D]=this.requestManager.normalizeModelURL(D),T[D]=this.modelUris[x][D]);this.load(T,x)}hasURLBeenRequested(h){return this.modelByURL[h]!==void 0}removeModel(h,x,T=!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];T||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 T=this.models[h][x].model;delete this.models[h][x],T&&T.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 T in this.models[x])this.models[x][T].model&&this.models[x][T].model.upload(h.context)}}const YM=i.a6.colorTheme,Dce=new i.a9({data:new i.aa(YM.data)});function aD(M){if(!M.metadata||!M.metadata.content_area)return;const h=i.o.devicePixelRatio,{left:x,top:T,width:D,height:F}=M.metadata.content_area,z=x*h,H=T*h;return[z,H,z+D*h,H+F*h]}function iD(M){if(M)return M.map(([h,x])=>[h*i.o.devicePixelRatio,x*i.o.devicePixelRatio])}class XM{constructor(h,x,T){this.id=h,this.scope=x,this.sourceCache=T,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 T=this.sourceCache.getSource();if(!(T instanceof Xc))return h;const D=x.map(z=>this.sourceCache.getTile(z)),F=T.getImages(D,Array.from(this.pendingRequests));for(const[z,H]of F)h.set(i.I.from({name:z,iconsetId:this.id}),H),this.pendingRequests.delete(z);for(const z of this.pendingRequests)this.missingRequests.add(z);return this.pendingRequests.clear(),h}}const rx=(M,h)=>st(M,h&&h.filter(x=>x.identifier!=="source.canvas")),oD=i.aH(ba,["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"]),lD=i.aH(ba,["setCenter","setZoom","setBearing","setPitch"]),bS=new Set(["background","sky","slot","custom"]),nx={version:8,layers:[],sources:{}},db={duration:300,delay:0};class am 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({},db),this._buildingIndex=new eb(this),this.crossTileSymbolIndex=new Um,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 ke,this._hasDataDrivenEmissive=!1,this.dispatcher=x.dispatcher?x.dispatcher:new i.D(i.dh(),this),x.imageManager?this.imageManager=x.imageManager:(this.imageManager=new qe(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 Lce(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 T=this;this._rtlTextPluginCallback=am.registerForPluginStateChange(D=>{T.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:D.pluginStatus,pluginURL:D.pluginURL},(F,z)=>{if(i.dl(F),z&&z.every(H=>H))for(const H in T._sourceCaches){const Q=T._sourceCaches[H],re=Q.getSource().type;re!=="vector"&&re!=="geojson"||Q.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 H=this._layers[z];H.source===F.id&&this._validateLayer(H)}})}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,T){this.globalId=this._getGlobalId(h);const D=(F,z)=>{try{z(null,this.setState(F,T))}catch(H){z(H,!1)}};if(typeof h=="string"){const F=this.map._requestManager.normalizeStyleURL(h),z=this.map._requestManager.transformRequest(F,i.R.Style);i.m(z,(H,Q)=>{H?this.fire(new i.y(H)):Q&&D(Q,x)})}else typeof h=="object"&&D(h,x)}loadURL(h,x={}){this.fire(new i.z("dataloading",{dataType:"style"}));const T=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,T);const F=this.map._requestManager.transformRequest(h,i.R.Style);this._request=i.m(F,(z,H)=>{if(this._request=null,z)this.fire(new i.y(z));else if(H)return this.importsCache.set(h,H),this._load(H,T)})}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(nx,!1)}_loadImports(h,x,T){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),H=new Promise(oe=>{z.once("style.import.load",oe),z.once("error",oe)}).then(()=>this.mergeAll());if(D.push(H),this.resolvedImports.has(F.url)){z.loadEmpty();continue}const Q=F.data||this.importsCache.get(F.url);Q?(z.loadJSON(Q,{validate:x}),this._isInternalStyle(Q)&&(z.globalId=null)):F.url?z.loadURL(F.url,{validate:x}):z.loadEmpty();const re={style:z,id:F.id,config:F.config};if(T){const oe=this.fragments.findIndex(({id:ge})=>ge===T);this.fragments=this.fragments.slice(0,oe).concat(re).concat(this.fragments.slice(oe))}else this.fragments.push(re)}return Promise.allSettled(D)}getImportGlobalIds(h=this,x=new Set){for(const T of h.fragments)T.style.globalId&&x.add(T.style.globalId),this.getImportGlobalIds(T.style,x);return[...x.values()]}_createFragmentStyle(h){const x=this.scope?i.B(h.id,this.scope):h.id;let T;const D=this._initialConfig&&this._initialConfig[x];(h.config||D)&&(T=Object.assign({},h.config,D));const F=new am(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:T,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({},nx,{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&&rx(this,Gr(h)))return;this._loaded=!0,this.stylesheet=i.dp(h);const T=()=>{for(const Q in h.sources)this.addSource(Q,h.sources[Q],{validate:!1,isInitialLoad:!0});if(h.iconsets)for(const Q in h.iconsets)this.addIconset(Q,h.iconsets[Q]);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=yy(this.stylesheet.layers);if(this._order=F.map(Q=>Q.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 Q=this.stylesheet.lights[0];this.light=new Bt(Q.properties,Q.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Bt(this.stylesheet.light)),this._layers={};for(const Q of F){const re=i.du(Q,this.scope,this._styleColorTheme.lut,this.options);re.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(re.fqid),re.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(re.fqid),this._hasAppearances=this._hasAppearances||re.getAppearances().length!==0,re.setEventedParent(this,{layer:{id:re.id}}),this._layers[re.id]=re;const oe=this.getOwnLayerSourceCache(re),ge=!!this.directionalLight&&this.directionalLight.shadowsEnabled();oe&&re.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 H=this.isRootStyle();h.imports?this._loadImports(h.imports,x).then(()=>{this._reloadImports(),this.fire(new i.z(H?"style.load":"style.import.load"))}).catch(Q=>{this.fire(new i.y(new Error("Failed to load imports",Q))),this.fire(new i.z(H?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new i.z(H?"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(()=>{T()}).catch(z=>{i.w(`Couldn't load color theme from the stylesheet: ${z}`),T()})}else this._styleColorTheme.lut=null,T()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(h=>h.style.hasAppearances())}mergeAll(){let h,x,T,D,F,z,H,Q,re,oe;const ge={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(me=>{if(me.stylesheet){if(me.light!=null&&(h=me.light),me.stylesheet.lights)for(const xe of me.stylesheet.lights)xe.type==="ambient"&&me.ambientLight!=null&&(x=me.ambientLight),xe.type==="directional"&&me.directionalLight!=null&&(T=me.directionalLight);D=this._prioritizeTerrain(D,me.terrain,me.stylesheet.terrain),me.stylesheet.fog&&me.fog!=null&&(F=me.fog),me.stylesheet.snow&&me.snow!=null&&(z=me.snow),me.stylesheet.rain&&me.rain!=null&&(H=me.rain),me.stylesheet.camera!=null&&(oe=me.stylesheet.camera),me.stylesheet.projection!=null&&(Q=me.stylesheet.projection),me.stylesheet.transition!=null&&(re=me.stylesheet.transition),ge[me.scope]=me._styleColorTheme}}),this.light=h,this.ambientLight=x,this.directionalLight=T,this.fog=F,this.snow=z,this.rain=H,this._styleColorThemeForScope=ge,D===null?delete this.terrain:this.terrain=D,this.camera=oe||{"camera-projection":"perspective"},this.projection=Q||{name:"mercator"},this.transition=Object.assign({},db,re),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(h){const x=T=>{for(const D of T.fragments)x(D.style);h(T)};x(this)}_prioritizeTerrain(h,x,T){const D=h&&h.drapeRenderMode===0;return T===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={},T={};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);T[z]=D._symbolSourceCaches[F]}}),this._mergedSourceCaches=h,this._mergedOtherSourceCaches=x,this._mergedSymbolSourceCaches=T}mergeIndoor(){this.forEachFragmentStyle(h=>{if(h.stylesheet&&h.stylesheet.indoor)for(const x of Object.values(h.stylesheet.indoor)){const T=x,D=i.B(T.sourceId,h.scope);this._mergedIndoor[D]=new Set(T.sourceLayers||[])}})}mergeLayers(){const h={},x=[],T={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(z=>{for(const H of z._order){const Q=z._layers[H];if(Q.type==="slot"){const re=i.dq(H);if(h[re])continue;h[re]=[]}Q.slot&&h[Q.slot]?h[Q.slot].push(Q):x.push(Q)}}),this._mergedOrder=[];let D=-1;const F=(z=[])=>{for(const H of z)if(H.type==="slot"){const Q=i.dq(H.id);h[Q]&&F(h[Q]),this._mergedSlots.push(Q)}else{const Q=i.B(H.id,H.scope);this._mergedOrder.push(Q),T[Q]=H,H.is3D(!!this.terrain)&&(this._has3DLayers=!0,D=this._mergedOrder.length-1),H.type==="circle"&&(this._hasCircleLayers=!0),H.type==="symbol"&&(this._hasSymbolLayers=!0),H.type==="clip"&&(this._clipLayerPresent=!0)}};if(F(x),this._has3DLayers){const z={};for(let H=0;Hz[H]-z[Q])}this._mergedLayers=T,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,T,D,F){const z=Object.assign({},T);for(const Q of Object.keys(YM))z[Q]===void 0&&(z[Q]=YM[Q].default);const H=new i.a8(Dce,x,new Map(D));return H.setTransitionOrValue(z,D),H.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((T,D)=>{const F="data:image/png;base64,";if(!h||h.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void T();let z=h;z.startsWith(F)||(z=F+z);const H=i.I.from("mapbox-reserved-lut"),Q=new Image;Q.src=z,Q.onerror=()=>{this._styleColorTheme.lutLoading=!1,D(new Error("Failed to load image data"))},Q.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==x)return void T();this._styleColorTheme.lutLoading=!1;const{width:re,height:oe,data:ge}=i.o.getImageData(Q);if(oe>32)return void D(new Error("The height of the image must be less than or equal to 32 pixels."));if(re!==oe*oe)return void D(new Error("The width of the image must be equal to the height squared."));this.getImage(H)&&this.removeImage(H),this.addImage(H,{data:new i.q({width:re,height:oe},ge),pixelRatio:1,sdf:!1,usvg:!1,version:0});const me=this.imageManager.getImage(H,this.scope);me?(this._styleColorTheme.lut={image:me.data,data:h},T()):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,T,D){let F,z,H;const Q=i.o.devicePixelRatio>1?"@2x":"";let re=i.m(T.transformRequest(T.normalizeSpriteURL(x,Q,".json"),i.R.SpriteJSON),(me,xe)=>{re=null,H||(H=me,F=xe,ge())}),oe=i.n(T.transformRequest(T.normalizeSpriteURL(x,Q,".png"),i.R.SpriteImage),(me,xe)=>{oe=null,H||(H=me,z=xe,ge())});function ge(){if(H)D(H);else if(F&&z){const me=i.o.getImageData(z),xe={};for(const Pe in F){const{width:Ce,height:$e,x:Be,y:Je,sdf:dt,pixelRatio:tt,stretchX:Mt,stretchY:vt,content:kt}=F[Pe],xt=new i.q({width:Ce,height:$e});i.q.copy(me,xt,{x:Be,y:Je},{x:0,y:0},{width:Ce,height:$e},null),xe[Pe]={data:xt,pixelRatio:tt!==void 0?tt:1,sdf:dt!==void 0&&dt,stretchX:Mt,stretchY:vt,content:kt,usvg:!1,version:0}}D(null,xe)}}return{cancel(){re&&(re.cancel(),re=null),oe&&(oe.cancel(),oe=null)}}}(h,this.map._requestManager,(x,T)=>{if(this._spriteRequest=null,x)this.fire(new i.y(x));else if(T){const D=new Map;for(const F in T)D.set(i.I.from(F),T[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 T=this.getOwnSourceCache(x.source);if(!T)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=T.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 XM(h,this.scope,T);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 T,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 H=new Map;for(const Q in z)H.set(i.I.from(Q),z[Q]);this.addImages(H)}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((T=this.map._requestManager).transformRequest(T.normalizeIconsetURL(h),i.R.Iconset),(F,z)=>{if(F)return void D(F);const H={},Q=i.dg(new i.bt(z));for(const re of Q.icons){const oe={version:1,pixelRatio:i.o.devicePixelRatio,content:aD(re),stretchX:re.metadata?iD(re.metadata.stretch_x_areas):void 0,stretchY:re.metadata?iD(re.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:re};H[re.name]=oe}D(null,H)}))}_validateLayer(h){const x=this.getOwnSource(h.source);if(!x)return;const T=h.sourceLayer;T&&(x.type==="geojson"||x.vectorLayerIds&&x.vectorLayerIds.indexOf(T)===-1)&&this.fire(new i.y(new Error(`Source layer "${T}" 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 T=this.fragments[x];return T&&T.style&&(h.data=T.style.serialize()),h})}_serializeSources(){const h={};for(const x in this._sourceCaches){const T=this._sourceCaches[x].getSource();h[T.id]||(h[T.id]=T.serialize())}return h}_serializeLayers(h){const x=[];for(const T of h){const D=this._layers[T];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 T=x._transitionablePaint._values["line-emissive-strength"];if(T&&T.value&&T.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 T=this.map.painter;if(T)for(let D=h.minzoom||0;D<(h.maxzoom||25.5);D++){const F=h.getProgramIds();if(F)for(const z of F){const H=h.getDefaultProgramParams(z,x.zoom,this._styleColorTheme.lut);H&&(T.style=this,this.fog&&(T._fogVisible=!0,H.overrideFog=!0,T.getOrCreateProgram(z,H)),T._fogVisible=!1,H.overrideFog=!1,T.getOrCreateProgram(z,H),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(H.overrideRtt=!0,T.getOrCreateProgram(z,H)))}}}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 T=this._changes.isDirty();let D=!1;if(this._changes.isDirty()){const H=this._changes.getLayerUpdatesByScope();for(const Q in H){const{updatedIds:re,removedIds:oe}=H[Q];(re||oe)&&(this._updateWorkerLayers(Q,re,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 H in this._mergedSourceCaches){const Q=this._mergedSourceCaches[H];F[H]=Q.used,Q.used=!1,Q.tileCoverLift=0}for(const H of this._mergedOrder){const Q=this._mergedLayers[H];if(Q.visibility!=="none"&&Q.recalculate(h,this._availableImages),!Q.isHidden(h.zoom)){const re=this.getLayerSourceCache(Q);re&&(re.used=!0,re.tileCoverLift=Math.max(re.tileCoverLift,Q.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(Q,h)}):this.precompilePrograms(Q,h))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&D&&this.mergeLayers();const z=this.imageManager.getPendingImageProviders();for(const H of z)H.sourceCache.used=!0;for(const H in F){const Q=this._mergedSourceCaches[H];F[H]!==Q.used&&Q.getSource().fire(new i.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:Q.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),T&&this.fire(new i.z("data",{dataType:"style"}))}updateImageProviders(){const h=this.imageManager.getPendingImageProviders();for(const x of h){const T=x.resolvePendingRequests(),D=this.getFragmentStyle(x.scope);D&&D.addImages(T)}}_updateTilesForChangedImages(){const h={};for(const x in this._mergedSourceCaches){const T=this._mergedSourceCaches[x].getSource().scope;h[T]=h[T]||this._changes.getUpdatedImages(T),h[T].length!==0&&this._mergedSourceCaches[x].reloadTilesForDependencies(["icons","patterns"],h[T])}for(const x in h)this._changes.resetUpdatedImages(x)}_updateWorkerLayers(h,x,T){const D=this.getFragmentStyle(h);D&&this.dispatcher.broadcast("updateLayers",{layers:x?D._serializeLayers(x):[],scope:h,removedIds:T||[],options:D.options})}setState(h,x){if(this._checkLoaded(),rx(this,Gr(h)))return!1;(h=i.dp(h)).layers=yy(h.layers);const T=function(z,H){if(!z)return[{command:ba.setStyle,args:[H]}];let Q=[];try{if(!i.by(z.version,H.version))return[{command:ba.setStyle,args:[H]}];if(i.by(z.center,H.center)||Q.push({command:ba.setCenter,args:[H.center]}),i.by(z.zoom,H.zoom)||Q.push({command:ba.setZoom,args:[H.zoom]}),i.by(z.bearing,H.bearing)||Q.push({command:ba.setBearing,args:[H.bearing]}),i.by(z.pitch,H.pitch)||Q.push({command:ba.setPitch,args:[H.pitch]}),i.by(z.sprite,H.sprite)||Q.push({command:ba.setSprite,args:[H.sprite]}),i.by(z.glyphs,H.glyphs)||Q.push({command:ba.setGlyphs,args:[H.glyphs]}),i.by(z.imports,H.imports)||function(xe=[],Pe=[],Ce){Pe=Pe||[];const $e=(xe=xe||[]).map(vy),Be=Pe.map(vy),Je=xe.reduce(_y,{}),dt=Pe.reduce(_y,{}),tt=$e.slice();let Mt,vt,kt,xt;for(Mt=0,vt=0;Mt<$e.length;Mt++)kt=$e[Mt],dt.hasOwnProperty(kt)?vt++:(Ce.push({command:ba.removeImport,args:[kt]}),tt.splice(tt.indexOf(kt,vt),1));for(Mt=0,vt=0;Mt{xe.source&&re[xe.source]?Q.push({command:ba.removeLayer,args:[xe.id]}):ge.push(xe)});let me=z.terrain;me&&re[me.source]&&(Q.push({command:ba.setTerrain,args:[void 0]}),me=void 0),Q=Q.concat(oe),i.by(me,H.terrain)||Q.push({command:ba.setTerrain,args:[H.terrain]}),function(xe,Pe,Ce){Pe=Pe||[];const $e=(xe=xe||[]).map(vy),Be=Pe.map(vy),Je=xe.reduce(_y,{}),dt=Pe.reduce(_y,{}),tt=$e.slice(),Mt=Object.create(null);let vt,kt,xt,pt,Pt,Ht,Vt;for(vt=0,kt=0;vt<$e.length;vt++)xt=$e[vt],dt.hasOwnProperty(xt)?kt++:(Ce.push({command:ba.removeLayer,args:[xt]}),tt.splice(tt.indexOf(xt,kt),1));for(vt=0,kt=0;vt!(z.command in lD));if(T.length===0)return!1;const D=T.filter(z=>!(z.command in oD));if(D.length>0)throw new Error(`Unimplemented: ${D.map(z=>z.command).join(", ")}.`);const F=[];return T.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,T]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,T),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,T=!1){this.imageManager.updateImage(h,this.scope,x),T&&(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,T={}){return this._checkLoaded(),this._validate(Se,`models.${h}`,x,null,T)||(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,T={}){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(Rn,`sources.${h}`,x,null,T))return;this.map&&this.map._collectResourceTiming&&(x.collectResourceTiming=!0);const D=yl(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 H=(z?"symbol:":"other:")+D.id,Q=i.B(H,this.scope),re=this._sourceCaches[H]=new ul(Q,D,z);(z?this._symbolSourceCaches:this._otherSourceCaches)[D.id]=re,re.onAdd(this.map)};F(!1),x.type!=="vector"&&x.type!=="geojson"||F(!0),D.onAdd&&D.onAdd(this.map),T.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 T=this.getOwnSourceCaches(h);for(const D of T){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 T=this.getOwnSourceCache(x);T&&h.push(T.getSource())}return h}areTilesLoaded(){const h=this._mergedSourceCaches;for(const x in h){const T=h[x]._tiles;for(const D in T){const F=T[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(Ln,"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 _a(F,$o||($o=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 _a(F,Ha||(Ha=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 T=Object.assign(x,{worldview:this.map.getWorldview()}),D=new i.ac(this.z||0,T);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 T=me=>.2126*(me[0]<=.03928?me[0]/12.92:Math.pow((me[0]+.055)/1.055,2.4))+.7152*(me[1]<=.03928?me[1]/12.92:Math.pow((me[1]+.055)/1.055,2.4))+.0722*(me[2]<=.03928?me[2]/12.92:Math.pow((me[2]+.055)/1.055,2.4)),D=h.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),F=h.properties.get("intensity"),z=h.properties.get("direction"),H=1-i.d4(z.x,z.y,z.z)[2]/90,Q=T(D)*F*H,re=x.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),oe=x.properties.get("intensity"),ge=T(re)*oe;return Number(((Q+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),T=this.fragments.find(({id:F})=>F===x);if(!T)return;const D=i.dq(h);return T.style.getFragmentStyle(D)}{const x=this.fragments.find(({id:T})=>T===h);return x?x.style:void 0}}setFeaturesetSelectors(h){if(!h)return;const x={},T=(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 Q=this.getOwnLayer(z.layer);if(!Q){i.w(`Layer is undefined for selector: ${z.layer}`);continue}const re=T(Q.source,Q.sourceLayer);if(re in x&&x[re]!==z.featureNamespace){i.w(`"featureNamespace ${z.featureNamespace} of featureset ${D}'s selector is not associated to the same source, skip this selector`);continue}x[re]=z.featureNamespace}let H;if(z.properties)for(const Q in z.properties){const re=i.U(z.properties[Q]);re.result==="success"&&(H=H||{},H[Q]=re.value)}F.push({layerId:z.layer,namespace:z.featureNamespace,properties:H,uniqueFeatureID:z._uniqueFeatureID})}}}getFeaturesetDescriptors(h){const x=this.getFragmentStyle(h);if(!x||!x.stylesheet.featuresets)return[];const T=[];for(const D in x.stylesheet.featuresets)T.push({featuresetId:D,importId:x.scope?x.scope:void 0});return T}getFeaturesetLayers(h,x){const T=this.getFragmentStyle(x),D=T.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 H=T.getOwnLayer(z.layer);H&&F.push(H)}return F}getConfigProperty(h,x){const T=this.getFragmentStyle(h);if(!T)return null;const D=i.B(x,T.scope),F=T.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 T=i.B(h,x);return this._mergedIndoor[T]}setIndoorData(h,x){this.map.indoor.setIndoorData(x)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(h,x,T){const D=this.getFragmentStyle(h);if(!D)return;const F=D.stylesheet.schema;if(!F||!F[x])return;const z=i.U(T);if(z.result!=="success")return void rx(this,z.value);const H=z.value.expression,Q=i.B(x,D.scope),re=D.options.get(Q);if(!re)return;let oe;const{minValue:ge,maxValue:me,stepValue:xe,type:Pe,values:Ce}=F[x],$e=i.U(F[x].default);$e.result==="success"&&(oe=$e.value.expression),oe?(this.options.set(Q,Object.assign({},re,{value:H,default:oe,minValue:ge,maxValue:me,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 T=x.stylesheet.schema;if(!T)return null;const D={};for(const F in T){const z=i.B(F,x.scope),H=x.options.get(z),Q=H?H.value||H.default:null;D[F]=Q?Q.serialize():null}return D}setConfig(h,x){const T=this.getFragmentStyle(h);T&&(T.updateConfig(x,T.stylesheet.schema),this.updateConfigDependencies())}getSchema(h){const x=this.getFragmentStyle(h);return x?x.stylesheet.schema:null}setSchema(h,x){const T=this.getFragmentStyle(h);T&&(T.stylesheet.schema=x,T.updateConfig(T._config,x),this.updateConfigDependencies())}updateConfig(h,x){if(this._config=h,h||x)if(x)for(const T in x){let D,F;const z=i.U(x[T].default);if(z.result==="success"&&(D=z.value.expression),h&&h[T]!==void 0){const me=i.U(h[T]);me.result==="success"&&(F=me.value.expression)}const{minValue:H,maxValue:Q,stepValue:re,type:oe,values:ge}=x[T];if(D){const me=i.B(T,this.scope);this.options.set(me,{default:D,value:F,minValue:H,maxValue:Q,stepValue:re,type:oe,values:ge})}else this.fire(new i.y(new Error(`No schema defined for config option "${T}".`)))}else this.fire(new i.y(new Error("Attempting to set config for a style without schema.")))}_updateLayers(h,x=()=>!0){for(const T of h){const D=this.getLayer(T);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 T=x._styleColorTheme.colorThemeOverride?x._styleColorTheme.colorThemeOverride:x._styleColorTheme.colorTheme;if(T){const D=x._evaluateColorThemeData(T);(!x._styleColorTheme.lut&&D!==""||x._styleColorTheme.lut&&D!==x._styleColorTheme.lut.data)&&x.setColorTheme(T)}}),this._changes.setDirty()}addLayer(h,x,T={}){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(rx(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($l,`layers.${D}`,h,{arrayIndex:-1},T))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 H=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?H=ge:i.w(`Layer with id "${x}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(H,0,D),this._layerOrderChanged=!0,this._layers[D]=F;const Q=this.getOwnLayerSourceCache(F),re=!!this.directionalLight&&this.directionalLight.shadowsEnabled();Q&&F.canCastShadows()&&re&&(Q.castsShadows=!0);const oe=this._changes.getRemovedLayer(F);if(oe&&F.source&&Q&&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"),Q.pause())}this._updateLayer(F),F.onAdd&&F.onAdd(this.map),F.scope=this.scope,this.mergeLayers()}moveLayer(h,x){this._checkLoaded();const T=this._checkLayer(h);if(!T||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.`)));T.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 T=this._order.indexOf(h);this._order.splice(T,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,T){this._checkLoaded();const D=this._checkLayer(h);D&&(D.minzoom===x&&D.maxzoom===T||(x!=null&&(D.minzoom=x),T!=null&&(D.maxzoom=T),this._updateLayer(D)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(h,x){this._checkLoaded();const T=this._checkLayer(h);T&&T.slot!==x&&(T.slot=x,this._updateLayer(T))}setFilter(h,x,T={}){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(Do,`layers.${D.id}.filter`,x,{layerType:D.type},T)||(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,T,D={}){this._checkLoaded();const F=this._checkLayer(h);if(F&&!i.by(F.getLayoutProperty(x),T)){if(T!=null&&(!D||D.validate!==!1)&&rx(F,ct.call(Gr,{key:`layers.${h}.layout.${x}`,layerType:F.type,objectKey:x,value:T,styleSpec:i.a6,style:{glyphs:!0,sprite:!0}})))return;F.setLayoutProperty(x,T),F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(F.fqid),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(F.fqid),this._updateLayer(F)}}setLayerProperty(h,x,T,D={}){this._checkLoaded();const F=this._checkLayer(h);F&&(x==="appearances"?(F.setAppearances(T),this._changes.setDirty()):F.isPaintProperty(x)?this.setPaintProperty(h,x,T,D):this.setLayoutProperty(h,x,T,D))}getLayoutProperty(h,x){const T=this._checkLayer(h);if(T)return T.getLayoutProperty(x)}setPaintProperty(h,x,T,D={}){this._checkLoaded();const F=this._checkLayer(h);if(!F||i.by(F.getPaintProperty(x),T)||T!=null&&(!D||D.validate!==!1)&&rx(F,Yc.call(Gr,{key:`layers.${h}.paint.${x}`,layerType:F.type,objectKey:x,value:T,styleSpec:i.a6})))return;const z=F.setPaintProperty(x,T);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 T=this._checkLayer(h);if(T)return T.getPaintProperty(x)}setFeatureState(h,x){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:Q,importId:re}=h.target,oe=this.getFragmentStyle(re),ge=oe.getFeaturesetLayers(Q);for(const{source:me,sourceLayer:xe}of ge)oe.setFeatureState({id:h.id,source:me,sourceLayer:xe},x)}else if("layerId"in h.target){const{layerId:Q}=h.target,re=this.getLayer(Q);this.setFeatureState({id:h.id,source:re.source,sourceLayer:re.sourceLayer},x)}return}const T=h.source,D=h.sourceLayer,F=this._checkSource(T);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 H=this.getOwnSourceCaches(T);for(const Q of H)Q.setFeatureState(D,h.id,x)}removeFeatureState(h,x){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:Q,importId:re}=h.target,oe=this.getFragmentStyle(re),ge=oe.getFeaturesetLayers(Q);for(const{source:me,sourceLayer:xe}of ge)oe.removeFeatureState({id:h.id,source:me,sourceLayer:xe},x)}else if("layerId"in h.target){const{layerId:Q}=h.target,re=this.getLayer(Q);this.removeFeatureState({id:h.id,source:re.source,sourceLayer:re.sourceLayer},x)}return}const T=h.source,D=this._checkSource(T);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 H=this.getOwnSourceCaches(T);for(const Q of H)Q.removeFeatureState(z,h.id,x)}getFeatureState(h){if(this._checkLoaded(),"target"in h){let F;if("featuresetId"in h.target){const{featuresetId:z,importId:H}=h.target,Q=this.getFragmentStyle(H),re=Q.getFeaturesetLayers(z);for(const{source:oe,sourceLayer:ge}of re){const me=Q.getFeatureState({id:h.id,source:oe,sourceLayer:ge});if(me&&!F)F=me;else if(!i.by(F,me))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,H=this.getLayer(z);F=this.getFeatureState({id:h.id,source:H.source,sourceLayer:H.sourceLayer})}return F}const x=h.source,T=h.sourceLayer,D=this._checkSource(x);if(D){if(D.type!=="vector"||T)return h.id===void 0&&this.fire(new i.y(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(x)[0].getFeatureState(T,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)},T=>T!==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),T=i.B(h.source,h.scope),D=this._changes.getUpdatedSourceCaches();h.source&&!D[T]&&x&&x.getSource().type!=="raster"&&(this._changes.updateSourceCache(T,"reload"),x.pause()),h.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(h){const x=H=>this._mergedLayers[H].is3D(!!this.terrain),T=this.order,D={},F=[];for(let H=T.length-1;H>=0;H--){const Q=T[H];if(x(Q)){D[Q]=H;for(const re of h){const oe=re[Q];if(oe)for(const ge of oe)F.push(ge)}}}F.sort((H,Q)=>Q.intersectionZ-H.intersectionZ);const z=[];for(let H=T.length-1;H>=0;H--){const Q=T[H];if(x(Q))for(let re=F.length-1;re>=0;re--){const oe=F[re].feature;if(oe.layer&&D[oe.layer.id]{if(bS.has(oe.type))return;const ge=this.getOwnLayerSourceCache(oe),me=F[ge.id]=F[ge.id]||{sourceCache:ge,layers:{},has3DLayers:!1};oe.is3D(!!this.terrain)&&(me.has3DLayers=!0),me.layers[oe.fqid]=me.layers[oe.fqid]||{styleLayer:oe,targets:[]},me.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 H=this._queryRenderedFeatures(h,F,T),Q=this._flattenAndSortRenderedFeatures(H),re=[];for(const oe of Q)i.dw(oe.layer.id)===this.scope&&re.push(oe);return re}queryRenderedFeatureset(h,x,T){let D;x&&!Array.isArray(x)&&x.filter&&(this._validate(Do,"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 me=ge.getFeaturesetDescriptors();for(const xe of me)z.push({targetId:F,filter:D,target:xe})}}const H=this.queryRenderedTargets(h,z,T),Q=[],re=new Set;for(const oe of H)for(const ge of oe.variants[F])Xg(ge,oe,re)||Q.push(new i.dx(oe,ge));return Q}queryRenderedTargets(h,x,T){const D={},F=(H,Q,re,oe)=>{const ge=D[Q.id]=D[Q.id]||{sourceCache:Q,layers:{},has3DLayers:!1};if(ge.layers[H.fqid]=ge.layers[H.fqid]||{styleLayer:H,targets:[]},H.is3D(!!this.terrain)&&(ge.has3DLayers=!0),!oe)return re.uniqueFeatureID=!1,void ge.layers[H.fqid].targets.push(re);ge.layers[H.fqid].targets.push(Object.assign({},re,{namespace:oe.namespace,properties:oe.properties,uniqueFeatureID:oe.uniqueFeatureID}))};for(const H of x)if("featuresetId"in H.target){const{featuresetId:Q,importId:re}=H.target,oe=this.getFragmentStyle(re);if(!oe||!oe._featuresetSelectors)continue;const ge=oe._featuresetSelectors[Q];if(!ge){this.fire(new i.y(new Error(`The featureset '${Q}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const me of ge){const xe=oe.getOwnLayer(me.layerId);xe&&!bS.has(xe.type)&&F(xe,oe.getOwnLayerSourceCache(xe),H,me)}}else if("layerId"in H.target){const{layerId:Q}=H.target,re=this.getLayer(Q);if(!re||bS.has(re.type))continue;F(re,this.getLayerSourceCache(re),H)}const z=this._queryRenderedFeatures(h,D,T);return this._flattenAndSortRenderedFeatures(z)}_queryRenderedFeatures(h,x,T){const D=[],F=!!this.map._showQueryGeometry,z=Qi.createFromScreenPoints(h,T);for(const H in x){const Q=iv(z,x[H],this._availableImages,T,F);Object.keys(Q).length&&D.push(Q)}if(this.placement)for(const H in x){if(!x[H].sourceCache._onlySymbols)continue;const Q=ov(z.screenGeometry,x[H],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(Q).length&&D.push(Q)}return D}querySourceFeatures(h,x){const T=x&&x.filter;T&&this._validate(Do,"querySourceFeatures.filter",T,null,x);let D=[];const F=this.getOwnSourceCaches(h);for(const z of F)D=D.concat(lv(z,x));return D}addSourceType(h,x,T){return am.getSourceType(h)?T(new Error(`A source type called "${h}" already exists.`)):(am.setSourceType(h,x),x.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:h,url:x.workerSourceURL},T):T(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(h,x,T={}){this._checkLoaded();const D=this.light.getLight();let F=!1;for(const H in h)if(!i.by(h[H],D[H])){F=!0;break}if(!F)return;const z=this._getTransitionParameters();this.light.setLight(h,x,T),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 T=h;const D=!("source"in h)||h.source==null;if(x===1){if(this.disableElevatedTerrain)return;if("source"in T&&typeof T.source=="object"){const H="terrain-dem-src";this.addSource(H,T.source),T=i.dp(T),T=Object.assign(T,{source:H})}const F=Object.assign({},T),z={};if(this.terrain&&D){F.source=this.terrain.get().source;const H=this.terrain?this.getFragmentStyle(this.terrain.scope):null;H&&(z.style=H.serialize())}if(this._validate(da,"terrain",F,z))return}if(!this.terrain||this.terrain.scope!==this.scope&&!D||this.terrain&&x!==this.terrain.drapeRenderMode){if(!T)return;this._createTerrain(T,x),this.fire(new i.z("data",{dataType:"style"}))}else{const F=this.terrain,z=F.get();for(const H of Object.keys(i.a6.terrain))!T.hasOwnProperty(H)&&i.a6.terrain[H].default&&(T[H]=i.a6.terrain[H].default);for(const H in h)if(!i.by(h[H],z[H])){F.set(h,this.options),this.stylesheet.terrain=h;const Q=this._getTransitionParameters({duration:0});F.updateTransitions(Q),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 T=this._getTransitionParameters({duration:0});x.updateTransitions(T)}_createSnow(h){const x=this.snow=new Wo(h,this.map.transform,this.scope,this.options);this.stylesheet.snow=x.get();const T=this._getTransitionParameters({duration:0});x.updateTransitions(T)}_createRain(h){const x=this.rain=new Xi(h,this.map.transform,this.scope,this.options);this.stylesheet.rain=x.get();const T=this._getTransitionParameters({duration:0});x.updateTransitions(T)}_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 T=this._getTransitionParameters({duration:0});x.updateTransitions(T)}}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 T=this._getTransitionParameters({duration:0});x.updateTransitions(T)}}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 T=this._getTransitionParameters({duration:0});x.updateTransitions(T)}}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 T=this._evaluateColorThemeData(x);this._loadColorTheme(T).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 T=this.getFragmentStyle(h);T&&(T._styleColorTheme.colorThemeOverride=x,T._reloadColorTheme())}_getTransitionParameters(h){return{now:i.o.now(),transition:Object.assign(this.transition,h)}}updateDrapeFirstLayers(){if(!this.terrain)return;const h=[],x=[];for(const T of this._mergedOrder)this.isLayerDraped(this._mergedLayers[T])?h.push(T):x.push(T);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...h),this._drapedFirstOrder.push(...x)}_createTerrain(h,x){const T=this.terrain=new Ut(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});T.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,T,D,F={}){if(F&&F.validate===!1)return!1;const z=Object.assign({},this.serialize());return rx(this,h.call(Gr,Object.assign({key:x,style:z,value:T,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 T of x)T.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 T of x)T.resume(),T.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=cb(this.directionalLight));const T=new Set,D=new Set;for(const F in this._mergedLayers){const z=this._mergedLayers[F];z.type==="building"&&T.add(z.source),z.hasElevation()&&!D.has(z.source)&&D.add(z.source)}for(const F in this._mergedSourceCaches){const z=this._mergedSourceCaches[F],H=D.has(z._source.id);T.has(z._source.id)&&(z._source.reparseOverscaled=!1),z.update(h,void 0,void 0,x,H)}}_generateCollisionBoxes(){for(const h in this._sourceCaches){const x=this._sourceCaches[h];x.resume(),x.reload()}}_updatePlacement(h,x,T,D,F,z,H=!1){let Q=!1,re=!1;const oe={},ge={};for(const Ce of this._mergedOrder){const $e=this._mergedLayers[Ce];if($e.type!=="symbol")continue;const Be=i.B($e.source,$e.scope);let Je=oe[Be];if(!Je){const tt=this.getLayerSourceCache($e);if(!tt)continue;const Mt=tt.getRenderableIds(!0).map(vt=>tt.getTileByID(vt));ge[Be]=Mt.slice(),Je=oe[Be]=Mt.sort((vt,kt)=>kt.tileID.overscaledZ-vt.tileID.overscaledZ||(vt.tileID.isLessThan(kt.tileID)?-1:1))}const dt=this.crossTileSymbolIndex.addLayer($e,Je,x.center.lng,x.projection);Q=Q||dt}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),H=H||this._layerOrderChanged,this._layerOrderChanged&&this.fire(new i.z("neworder"));const me=!!(this.placement&&!x.equals(this.placement.transform)),xe=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!z||this.placement.lastReplacementSourceUpdateTime!==z.updateTime)),Pe=(me||xe||Q||this.placement&&this.placement.isStale())&&D===0;if((H||!this.pauseablePlacement||Pe||D!==0&&this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.o.now(),x.zoom))&&(this.pauseablePlacement=new nc(x,this._mergedOrder,H||D===0,T,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()),re=!0),Q&&this.pauseablePlacement.placement.setStale()),re||Q){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 T.push(h),this._loadImports([h],!0);const D=T.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=T.slice(0,D).concat(h).concat(T.slice(D)),this._loadImports([h],!0,x)}updateImport(h,x){this._checkLoaded();const T=this.stylesheet.imports||[],D=this.getImportIndex(h);return D===-1?this:typeof x=="string"?(this.setImportUrl(h,x),this):(x.url&&x.url!==T[D].url&&this.setImportUrl(h,x.url),i.by(x.config,T[D].config)||this.setImportConfig(h,x.config,x.data.schema),i.by(x.data,T[D].data)||this.setImportData(h,x.data),this)}moveImport(h,x){this._checkLoaded();let T=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=T[D],H=this.fragments[D];return T=T.filter(({id:Q})=>Q!==h),this.fragments=this.fragments.filter(({id:Q})=>Q!==h),this.stylesheet.imports=T.slice(0,F).concat(z).concat(T.slice(F)),this.fragments=this.fragments.slice(0,F).concat(H).concat(this.fragments.slice(F)),this.mergeLayers(),this}setImportUrl(h,x){this._checkLoaded();const T=this.stylesheet.imports||[],D=this.getImportIndex(h);if(D===-1)return this;T[D].url=x;const F=this.fragments[D];return F.style=this._createFragmentStyle(T[D]),F.style.on("style.import.load",()=>this.mergeAll()),F.style.loadURL(x),this}setImportData(h,x){this._checkLoaded();const T=this.getImportIndex(h),D=this.stylesheet.imports||[];return T===-1?this:x?(this.fragments[T].style.setState(x),this._reloadImports(),this):(delete D[T].data,this.setImportUrl(h,D[T].url))}setImportConfig(h,x,T){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];T&&z.style.stylesheet&&(z.style.stylesheet.schema=T);const H=z.style.stylesheet&&z.style.stylesheet.schema;return z.config=x,z.style.updateConfig(x,H),this.updateConfigDependencies(),this}removeImport(h){this._checkLoaded();const x=this.stylesheet.imports||[],T=this.getImportIndex(h);T!==-1&&(x.splice(T,1),this.fragments[T].style._remove(),this.fragments.splice(T,1),this._reloadImports())}getImportIndex(h){const x=(this.stylesheet.imports||[]).findIndex(T=>T.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 T=this._mergedOtherSourceCaches[x];T&&h.push(T.getSource())}return h}getSource(h,x){const T=this.getSourceCache(h,x);return T&&T.getSource()}getLayerSource(h){const x=this.getLayerSourceCache(h);return x&&x.getSource()}getSourceCache(h,x){const T=i.B(h,x);return this._mergedOtherSourceCaches[T]}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 T=h[x];T==="reload"?this.reloadSource(x):T==="clear"&&this.clearSource(x)}}updateLayers(h){const x=this._changes.getUpdatedPaintProperties();for(const T of x){const D=this.getLayer(T);D&&D.updateTransitions(h)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(h){this.stylesheet.glyphs=h,this.glyphManager.setURL(h)}getImages(h,x,T){this.imageManager.getImages(x.images,x.scope,T),this._updateTilesForChangedImages();const D=z=>{if(z){const H=x.images.map(Q=>i.I.toString(Q));z.setDependencies(x.tileID.key,x.type,H)}},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,T){this.imageManager.rasterizeImages(x,T)}getGlyphs(h,x,T){this.glyphManager.getGlyphs(x.stacks,T)}getResource(h,x,T){return i.dz(x,T)}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(T=>T.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 T=h.type==="fill-extrusion"&&(h.sourceLayer==="building"||h.sourceLayer==="procedural_buildings"),D=h.type==="building";if(h.is3D(!!this.terrain)){if(T||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)}}am.getSourceType=function(M){return Qh[M]},am.setSourceType=function(M,h){Qh[M]=h},am.registerForPluginStateChange=i.dA;class cD 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,T]of Object.entries(h.buildings))if(this._buildings[x])for(const D of T.floorIds)this._buildings[x].floors[D]||(this._buildings[x].floors[D]=T.floors[D]);else this._buildings[x]=T;for(const x of h.activeFloors)this._activeFloors.add(x);this._updateIndoorSelector()}getIndoorTileOptions(h,x){const T=this._style.getIndoorSourceLayers(h,x);return T&&this._indoorState?{sourceLayers:T,indoorState:this._indoorState}:null}_updateUI(h,x,T){const D=function(F,z,H,Q){let re=null,oe=Number.MAX_SAFE_INTEGER;if(Q<16)return null;for(const[ge,me]of Object.entries(F)){const xe=me.center;if(xe){const Pe=z.distanceTo(i.aT.convert(xe));Pe({id:z,name:T.floors[z].name,zIndex:T.floors[z].zIndex})).sort((z,H)=>H.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 fv=` #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`,gv=` #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;}`,QM=` #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`,wS="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;}",ph=` #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`,jS=`#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`,Ys=`#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`,JM=`#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`,kS=`#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;}`,NS=`#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`,eT=`#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 ub=/#include\s+"([^"]+)"/g,Ep=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,tT=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,ky=new Set(["ifdef","ifndef","elif","if","defined"]),Ny=new Set;ix(fv,Ny),ix(QM,Ny),ix(gv,Ny);const ax={"_prelude_fog.vertex.glsl":jS,"_prelude_terrain.vertex.glsl":ph,"_prelude_shadow.vertex.glsl":NS,"_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":Ys,"_prelude_shadow.fragment.glsl":eT,"_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":JM,"_prelude_raster_particle.glsl":kS},SS={};ka("",ph),ka(Ys,jS),ka(eT,NS),ka(JM,""),ka(kS,"");const dD=ka(gv,QM),CS=fv,Oce=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",CS,dD.fragmentSource].join(` `),uD=["precision highp float;",CS,dD.vertexSource].join(` `);var sT={background:ka(`#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:ka(`#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:ka(`#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:ka(`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:ka(`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:ka(`#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:ka("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:ka(`#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:ka(`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:ka("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:ka("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:ka("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:ka(`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:ka(`#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:ka(`#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:ka(`#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:ka(`#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:ka(`#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:ka(`#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:ka(`#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:ka(`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:ka(`#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:ka(`#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:ka(`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:ka(`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:ka(`#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:ka(`#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:ka(`#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:ka(`#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:ka(`#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:ka("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:ka("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:ka(`#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:ka(`#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:ka(`#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:ka("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:ka(`#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 }`,wS),skyboxGradient:ka(`#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 }`,wS),skyboxCapture:ka(` 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:ka(`#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:ka(`#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:ka(`#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:ka(`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:ka(`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:ka("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:ka("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:ka("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:ka("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 ix(M,h){const x=M.split(` `);for(let T of x){if(T=T.trimStart(),T[0]!=="#"||!T.includes("if")||T.startsWith("#endif"))continue;const D=T.match(tT);if(D)for(const F of D)ky.has(F)||h.add(F)}}function ka(M,h){const x=new Set,T=[],D=[];M=M.replace(ub,(z,H)=>(D.push(H),"")),h=h.replace(ub,(z,H)=>(T.push(H),""));let F=new Set(Ny);ix(M,F),ix(h,F);for(const z of[...T,...D])SS[z]||(SS[z]=new Set,ix(ax[z],SS[z])),F=new Set([...F,...SS[z]]);return{fragmentSource:M=M.replace(Ep,(z,H,Q,re,oe)=>(x.add(oe),H==="define"?` #ifndef HAS_UNIFORM_u_${oe} in ${Q} ${re} ${oe}; #else uniform ${Q} ${re} u_${oe}; #endif `:H==="initialize"?` #ifdef HAS_UNIFORM_u_${oe} ${Q} ${re} ${oe} = u_${oe}; #endif `:H==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${oe} in ${Q} ${re} ${oe}; #endif `:H==="initialize-attribute"?"":void 0)),vertexSource:h=h.replace(Ep,(z,H,Q,re,oe)=>{const ge=`MATERIAL_ATTRIBUTE_OFFSET_${oe}`,me=re==="float"?"vec2":re,xe=`GET_ATTRIBUTE_${me}(a_${oe}, materialInfo, ${ge})`,Pe=oe.match(/color/)?"color":me;return H==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${oe} in ${Q} ${re} a_${oe}; #endif `:x.has(oe)?H==="define"?` #ifndef HAS_UNIFORM_u_${oe} uniform lowp float u_${oe}_t; #if !defined(${ge}) in ${Q} ${me} a_${oe}; #endif out ${Q} ${re} ${oe}; #else uniform ${Q} ${re} u_${oe}; #endif `:H==="initialize"?Pe==="vec4"?` #ifndef HAS_UNIFORM_u_${oe} ${oe} = a_${oe}; #else ${Q} ${re} ${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 ${Q} ${re} ${oe} = u_${oe}; #endif `:H==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${oe} in ${Q} ${re} a_${oe}; out ${Q} ${re} ${oe}; #endif `:H==="initialize-attribute"?` #ifdef HAS_ATTRIBUTE_a_${oe} ${oe} = a_${oe}; #endif `:void 0:H==="define"?` #ifndef HAS_UNIFORM_u_${oe} uniform lowp float u_${oe}_t; #if !defined(${ge}) in ${Q} ${me} a_${oe}; #endif #else uniform ${Q} ${re} u_${oe}; #endif `:H==="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 ${Q} ${re} u_${oe}; #endif `:` #ifdef INSTANCED_ARRAYS in ${Q} ${me} a_${oe}; #else uniform ${Q} ${re} u_${oe}; #endif `:H==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${oe} ${Q} ${re} ${oe} = a_${oe}; #endif `:Pe==="vec4"?` #ifndef HAS_UNIFORM_u_${oe} #ifdef ${ge} ${Q} ${re} ${oe} = ${xe}; #else ${Q} ${re} ${oe} = a_${oe}; #endif #else ${Q} ${re} ${oe} = u_${oe}; #endif `:` #ifndef HAS_UNIFORM_u_${oe} #ifdef ${ge} ${Q} ${re} ${oe} = unpack_mix_${Pe}(${xe}, u_${oe}_t); #else ${Q} ${re} ${oe} = unpack_mix_${Pe}(a_${oe}, u_${oe}_t); #endif #else ${Q} ${re} ${oe} = u_${oe}; #endif `}),usedDefines:F,vertexIncludes:T,fragmentIncludes:D}}class Rce{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(h,x,T,D,F,z,H,Q){this.context=h;let re=this.boundPaintVertexBuffers.length!==D.length;for(let ge=0;!re&&ge{const Mt=dt.paint.get("hillshade-shadow-color"),vt=dt.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",kt=dt.paint.get("hillshade-highlight-color"),xt=dt.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",pt=dt.paint.get("hillshade-accent-color"),Pt=dt.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Ht=dt.paint.get("hillshade-emissive-strength");let Vt=i.an(dt.paint.get("hillshade-illumination-direction"));if(dt.paint.get("hillshade-illumination-anchor")==="viewport")Vt-=Be.transform.angle;else if(Be.style&&Be.style.enable3dLights()&&Be.style.directionalLight){const ss=Be.style.directionalLight.properties.get("direction"),ps=i.d4(ss.x,ss.y,ss.z);Vt=i.an(ps[1])}const ts=!Be.options.moving;return{u_matrix:tt||Be.transform.calculateProjMatrix(Je.tileID.toUnwrapped(),ts),u_image:0,u_latrange:Fce(0,Je.tileID),u_light:[dt.paint.get("hillshade-exaggeration"),Vt],u_shadow:Mt.toPremultipliedRenderColor(vt?null:dt.lut),u_highlight:kt.toPremultipliedRenderColor(xt?null:dt.lut),u_emissive_strength:Ht,u_accent:pt.toPremultipliedRenderColor(Pt?null:dt.lut)}})(M,x,T,M.terrain?h.projMatrix:null);M.uploadCommonUniforms(H,me,h.toUnwrapped());const{tileBoundsBuffer:Pe,tileBoundsIndexBuffer:Ce,tileBoundsSegments:$e}=M.getTileBoundsBuffers(x);me.draw(M,Q.TRIANGLES,D,F,z,nn.disabled,xe,T.id,Pe,Ce,$e)}function rT(M,h,x){if(!h.needsDEMTextureUpload)return;const T=M.context,D=T.gl;T.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(T,F,D.R32F,{premultiply:!1}),h.needsDEMTextureUpload=!1}function Bce(M,h,x){const T=M.context,D=T.gl;if(!h.dem)return;const F=h.dem;if(T.activeTexture.set(D.TEXTURE1),rT(M,h,F),!h.demTexture)return;h.demTexture.bind(D.NEAREST,D.CLAMP_TO_EDGE);const z=F.dim;T.activeTexture.set(D.TEXTURE0);let H=h.hillshadeFBO;if(!H){const me=new i.T(T,{width:z,height:z,data:null},D.RGBA8);me.bind(D.LINEAR,D.CLAMP_TO_EDGE),H=h.hillshadeFBO=T.createFramebuffer(z,z,1,"renderbuffer"),H.colorAttachment0.set(me.texture)}T.bindFramebuffer.set(H.framebuffer),T.viewport.set([0,0,z,z]);const{tileBoundsBuffer:Q,tileBoundsIndexBuffer:re,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,Pr.disabled,dn.disabled,Dn.unblended,nn.disabled,((me,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:me.overscaledZ}})(h.tileID,F),x.id,Q,re,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 $ce 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 hD extends to{getDefault(){return 1}set(h){(h!==this.current||this.dirty)&&(this.gl.clearDepth(h),this.current=h,this.dirty=!1)}}class nT extends to{getDefault(){return 0}set(h){(h!==this.current||this.dirty)&&(this.gl.clearStencil(h),this.current=h,this.dirty=!1)}}class MS 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 aT extends to{getDefault(){return!0}set(h){(h!==this.current||this.dirty)&&(this.gl.depthMask(h),this.current=h,this.dirty=!1)}}class Sy extends to{getDefault(){return 255}set(h){(h!==this.current||this.dirty)&&(this.gl.stencilMask(h),this.current=h,this.dirty=!1)}}class xv 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 hb 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 yv 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 mD 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 iT 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 pD 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 vv 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 TS 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 AS 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 oT 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 ES 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 mb 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 fD 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 gD=class extends to{getDefault(){return null}set(M){(M!==this.current||this.dirty)&&(this.gl.useProgram(M),this.current=M,this.dirty=!1)}};class xD 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 _v 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 yD 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 qce 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 Uce 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 Vce 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 lT 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 cT 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 dT 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 uT 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 vD 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 PS extends to{constructor(h,x){super(h),this.context=h,this.parent=x}getDefault(){return null}}class IS extends PS{constructor(h,x,T=0){super(h,x),this.attachmentPoint=h.gl.COLOR_ATTACHMENT0+T}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 bv extends PS{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 pb extends PS{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 _D extends bv{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const fh=(M,h,x,T)=>({u_matrix:M,u_image0:0,u_image1:1,u_skirt_height:h,u_ground_shadow_factor:x,u_emissive_texture_available:T}),LS=(M,h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Ce,$e)=>({u_proj_matrix:Float32Array.from(M),u_globe_matrix:h,u_normalize_matrix:Float32Array.from(T),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:H,u_frustum_br:Q,u_frustum_bl:re,u_globe_pos:oe,u_globe_radius:ge,u_viewport:me,u_grid_matrix:$e?Float32Array.from($e):new Float32Array(9),u_skirt_height:xe,u_far_z_cutoff:Pe,u_emissive_texture_available:Ce});function fb(M,h){return M!=null&&h!=null&&!(!M.hasData()||!h.hasData())&&M.demTexture!=null&&h.demTexture!=null&&M.tileID.key!==h.tileID.key}const $f=new class{constructor(){this.operations={}}newMorphing(M,h,x,T,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:T,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()}},DS={0:null,1:"TERRAIN_VERTEX_MORPHING"};function OS(M,h,x){if(h===0)return 0;const T=h<1&&x===514?.25/h:1;return 6*Math.pow(1.5,22-M)*Math.max(h,1)*T}function hT(M,h){const x=1<({u_matrix:M});function xb(M,h,x,T,D){if(D>0){const F=i.o.now(),z=(F-M.timeAdded)/D,H=h?(F-h.timeAdded)/D:-1,Q=x.getSource(),re=T.coveringZoomLevel({tileSize:Q.tileSize,roundZoom:Q.roundZoom}),oe=!h||Math.abs(h.tileID.overscaledZ-re)>Math.abs(M.tileID.overscaledZ-re),ge=oe&&M.refreshedUponExpiration?1:i.aA(oe?z:1-H,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 RS extends ul{constructor(h){const x=yl("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 mT extends ul{constructor(h){const x=yl("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,T){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 H=new em(z,this._source.tileSize*z.overscaleFactor(),h.tileZoom,void 0,void 0,this._source.worldview);H.state="loaded",this._tiles[z.key]=H}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 T=Object.values(x);this.renderCachePool.push(...T),delete this.proxyCachedFBO[h]}}deallocRenderCache(){this.renderCache.forEach(h=>h.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class pT extends i.aQ{constructor(h,x,T){super(h.overscaledZ,h.wrap,h.canonical.z,h.canonical.x,h.canonical.y),this.proxyTileKey=x,this.projMatrix=T}}class fT extends i.bV{constructor(h,x){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=h,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[T,D,F]=function(Q){const re=new i.bd,oe=new i.b0,ge=131;re.reserve(17161),oe.reserve(33800);const me=i.al/128,xe=i.al+me/2,Pe=xe+me;for(let $e=-me;$exe||$e<0||$e>xe?24575:0,dt=i.aA(Math.round(Be),0,i.al),tt=i.aA(Math.round($e),0,i.al);re.emplaceBack(dt+Je,tt)}const Ce=($e,Be)=>{const Je=Be*ge+$e;oe.emplaceBack(Je+1,Je,Je+ge),oe.emplaceBack(Je+ge,Je+ge+1,Je+1)};for(let $e=1;$e<129;$e++)for(let Be=1;Be<129;Be++)Ce(Be,$e);return[0,129].forEach($e=>{for(let Be=0;Be<130;Be++)Ce(Be,$e),Ce($e,Be)}),[re,oe,32768]}(),z=h.context;this.gridBuffer=z.createVertexBuffer(T,i.bf.members),this.gridIndexBuffer=z.createIndexBuffer(D),this.gridSegments=i.bg.simpleSegment(0,0,T.length,D.length),this.gridNoSkirtSegments=i.bg.simpleSegment(0,0,T.length,F),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new mT(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 H=z.gl;this._overlapStencilMode=new dn({func:H.GEQUAL,mask:255},0,255,H.KEEP,H.KEEP,H.REPLACE),this._previousZoom=h.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=x,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new RS(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,T){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 H=h.terrain&&h.terrain.scope,Q=D.get("source"),re=F?this._mockSourceCache:h.getSourceCache(Q,H);if(!re)return void i.w(`Couldn't find terrain source "${Q}".`);if(this.sourceCache=re,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,T),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,T=h.getFreeCameraOptions().position.z/h.pixelsPerMeter*h.worldSize;this._previousCameraAltitude=T;const D=x!=null?T-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 H=F-this._previousZoom;const Q=this._previousUpdateTimestamp;let re=F;this._evaluationZoom!=null&&(re=this._evaluationZoom,Math.abs(F-re)>.5&&(H=.5*(F-re+H)),H*D<0&&(re+=H)),this._evaluationZoom=re;const oe=z.getExaggeration(re),ge=oe===z.getExaggeration(Math.max(0,re-.1));if(ge&&Math.abs(oe-this._exaggeration)<.01)return oe;let me=Math.min(.1,.00375*(this._updateTimestamp-Q));return(ge||oe<.1||Math.abs(H)<1e-4)&&(me=Math.min(.2,4*me)),i.ak(this._exaggeration,oe,me)}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,T=this.painter.transform;this._initializing&&(this._initializing=T._centerAltitude===0&&this.getAtPointOrZero(i.ae.fromLngLat(T.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const D=this.proxyCoords=x.getIds().map(Q=>{const re=x.getTileByID(Q).tileID;return re.projMatrix=T.calculateProjMatrix(re.toUnwrapped()),re});(function(Q,re){const oe=re.transform.pointCoordinate(re.transform.getCameraPoint()),ge=new i.P(oe.x,oe.y);Q.sort((me,xe)=>{if(xe.overscaledZ-me.overscaledZ)return xe.overscaledZ-me.overscaledZ;const Pe=new i.P(me.canonical.x+(1<{this.proxyToSource[Q.key]={}}),this.terrainTileForTile={};const z=this._style._mergedSourceCaches;for(const Q in z){const re=z[Q];if(!re.used||(re!==this.sourceCache&&this.resetTileLookupCache(re.id),this._setupProxiedCoordsForOrtho(re,h[Q],F),re.usedForTerrain))continue;const oe=h[Q];re.getSource().reparseOverscaled&&this._assignTerrainTiles(oe)}this.proxiedCoords[x.id]=D.map(Q=>new pT(Q,Q.key,this.orthoMatrix)),this._assignTerrainTiles(D),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(F),this.renderingToTexture=!1;const H={};this._visibleDemTiles=[];for(const Q of this.proxyCoords){const re=this.terrainTileForTile[Q.key];if(!re)continue;const oe=re.tileID.key;oe in H||(this._visibleDemTiles.push(re),H[oe]=oe)}}_assignTerrainTiles(h){this._initializing||h.forEach(x=>{if(this.terrainTileForTile[x.key])return;const T=this._findTileCoveringTileID(x,this.sourceCache);T&&(this.terrainTileForTile[x.key]=T)})}_prepareDEMTextures(){const h=this.painter.context,x=h.gl;for(const T in this.terrainTileForTile){const D=this.terrainTileForTile[T],F=D.dem;!F||D.demTexture&&!D.needsDEMTextureUpload||(h.activeTexture.set(x.TEXTURE1),rT(this.painter,D,F))}}_prepareDemTileUniforms(h,x,T,D){if(!x||x.demTexture==null)return!1;const F=h.tileID.canonical,z=Math.pow(2,x.tileID.canonical.z-F.z),H=D||"";return T[`u_dem_tl${H}`]=[F.x*z%1,F.y*z%1],T[`u_dem_scale${H}`]=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((T,D)=>{if(!D.dem)return T;const F=D.dem.tree.minimums[0];return F>0&&h++,T+F},0);return h?x/h:0}_updateEmptyDEMTexture(){const h=this.painter.context,x=h.gl;h.activeTexture.set(x.TEXTURE2);const T=this._getLoadedAreaMinimum(),D=new i.dL({width:1,height:1},new Float32Array([T]));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,T){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 H=null,Q=null,re=1;if(T&&T.morphing&&this._useVertexMorphing){const xe=T.morphing.srcDemTile,Pe=T.morphing.dstDemTile;re=T.morphing.phase,xe&&Pe&&(this._prepareDemTileUniforms(h,xe,z,"_prev")&&(Q=xe),this._prepareDemTileUniforms(h,Pe,z)&&(H=Pe))}const oe=xe=>xe&&xe.demTexture&&this.painter.linearFloatFilteringSupported()?F.LINEAR:F.NEAREST;let ge=null;var me;if(this.enabled?Q&&H?(ge=H.demTexture,D.activeTexture.set(F.TEXTURE4),Q.demTexture.bind(oe(Q),F.CLAMP_TO_EDGE),z.u_dem_lerp=re):(H=this.terrainTileForTile[h.tileID.key],ge=this._prepareDemTileUniforms(h,H,z)?H.demTexture:this.emptyDEMTexture):ge=this.emptyDEMTexture,D.activeTexture.set(F.TEXTURE2),ge&&(z.u_dem_size=(me=ge).size[0]===1?1:me.size[0]-2,ge.bind(oe(H),F.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(T&&T.useDepthForOcclusion,x,z),T&&T.useMeterToDem&&H){const xe=(1<{if(Be===ss)return;const ps=[DS[ss],"PROJECTION_GLOBE_VIEW"];dt&&ps.push("CUSTOM_ANTIALIASING");const Bs=re.isTileAffectedByFog(ts);$e=re.getOrCreateProgram("globeRaster",{defines:ps,overrideFog:Bs}),Be=ss},Mt=re.colorModeForRenderPass(),vt=new Pr(Ce.LEQUAL,Pr.ReadWrite,re.depthRangeFor3D);$f.update(xe);const kt=i.dF(Je),xt=[i.aF(Je.center.lng),i.aJ(Je.center.lat)],pt=re.globeSharedBuffers,Pt=[Je.width*i.o.devicePixelRatio,Je.height*i.o.devicePixelRatio],Ht=Float32Array.from(Je.globeMatrix),Vt={useDenormalizedUpVectorScale:!0};{const ts=re.transform,ss=OS(ts.zoom,oe.exaggeration(),oe.sourceCache._source.tileSize);Be=-1;const ps=Ce.TRIANGLES;for(const Bs of me){const Xt=ge.getTile(Bs),Ft=dn.disabled,cs=oe.prevTerrainTileForTile[Bs.key],es=oe.terrainTileForTile[Bs.key];fb(cs,es)&&$f.newMorphing(Bs.key,cs,es,xe,250),wv(re,Xt.emissiveTexture),Pe.activeTexture.set(Ce.TEXTURE0),Xt.texture&&Xt.texture.bind(Ce.LINEAR,Ce.CLAMP_TO_EDGE);const Es=$f.getMorphValuesForProxy(Bs.key),Qs=Es?1:0;Es&&Object.assign(Vt,{morphing:{srcDemTile:Es.from,dstDemTile:Es.to,phase:i.dD(Es.phase)}});const mr=i.dG(Bs.canonical),Ks=i.dH(mr.getCenter().lat),$s=i.dI(Bs.canonical,mr,Ks,ts.worldSize/ts._pixelsPerMercatorPixel),Cr=i.bk(i.dJ(Bs.canonical)),kr=re.emissiveMode==="mrt-fallback"?1:0,or=LS(ts.expandedFarZProjMatrix,Ht,kt,Cr,i.aj(ts.zoom),xt,ts.frustumCorners.TL,ts.frustumCorners.TR,ts.frustumCorners.BR,ts.frustumCorners.BL,ts.globeCenterInViewSpace,ts.globeRadius,Pt,ss,ts._farZ,kr,$s);if(tt(Bs,Qs),$e&&(oe.setupElevationDraw(Xt,$e,Vt),re.uploadCommonUniforms(Pe,$e,Bs.toUnwrapped()),pt)){const[fr,qr,jn]=pt.getGridBuffers(Ks,ss!==0);$e.draw(re,ps,vt,Ft,Mt,nn.backCCW,or,"globe_raster",fr,qr,jn)}}}if(pt&&(re.renderDefaultNorthPole||re.renderDefaultSouthPole)){const ts=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];dt&&ts.push("CUSTOM_ANTIALIASING"),$e=re.getOrCreateProgram("globeRaster",{defines:ts});for(const ss of me){const{x:ps,y:Bs,z:Xt}=ss.canonical,Ft=Bs===0,cs=Bs===(1<fr.draw(re,Ce.TRIANGLES,vt,dn.disabled,Mt,nn.disabled,LS(Je.expandedFarZProjMatrix,$s,$s,Cr,0,xt,Je.frustumCorners.TL,Je.frustumCorners.TR,Je.frustumCorners.BR,Je.frustumCorners.BL,Je.globeCenterInViewSpace,Je.globeRadius,Pt,0,Je._farZ,kr),"globe_pole_raster",qr,Qs,mr);oe.setupElevationDraw(Ks,$e,Vt),re.uploadCommonUniforms(Pe,$e,ss.toUnwrapped()),Ft&&re.renderDefaultNorthPole&&or($e,es),cs&&re.renderDefaultSouthPole&&($s=i.cS(i.bC(),$s,[1,-1,1]),or($e,Es))}}}})(D,F,z,H,Q);else{const re=D.context,oe=re.gl;let ge,me;const xe=D.shadowRenderer,Pe=tx(D,D.longestCutoffRange),Ce=Mt=>{if(me===Mt)return;const vt=[];vt.push(DS[Mt]),Pe.shouldRenderCutoff&&vt.push("RENDER_CUTOFF"),xe&&(vt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),xe.useNormalOffset&&vt.push("NORMAL_OFFSET")),ge=D.getOrCreateProgram("terrainRaster",{defines:vt}),me=Mt},$e=D.colorModeForRenderPass(),Be=new Pr(oe.LEQUAL,Pr.ReadWrite,D.depthRangeFor3D);$f.update(Q);const Je=D.transform,dt=OS(Je.zoom,F.exaggeration(),F.sourceCache._source.tileSize);let tt=[0,0,0];if(xe){const Mt=D.style.directionalLight,vt=D.style.ambientLight;Mt&&vt&&(tt=Bf(D.style,Mt,vt))}{me=-1;const Mt=oe.TRIANGLES,[vt,kt]=[F.gridIndexBuffer,F.gridSegments];for(const xt of H){const pt=z.getTile(xt),Pt=dn.disabled,Ht=F.prevTerrainTileForTile[xt.key],Vt=F.terrainTileForTile[xt.key];fb(Ht,Vt)&&$f.newMorphing(xt.key,Ht,Vt,Q,250),wv(D,pt.emissiveTexture),re.activeTexture.set(oe.TEXTURE0),pt.texture&&pt.texture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE);const ts=$f.getMorphValuesForProxy(xt.key),ss=ts?1:0;let ps;ts&&(ps={morphing:{srcDemTile:ts.from,dstDemTile:ts.to,phase:i.dD(ts.phase)}});const Bs=D.emissiveMode==="mrt-fallback"?1:0,Xt=fh(xt.projMatrix,hT(xt.canonical,Je.renderWorldCopies)?dt/10:dt,tt,Bs);if(Ce(ss),!ge)continue;F.setupElevationDraw(pt,ge,ps);const Ft=xt.toUnwrapped();xe&&xe.setupShadows(Ft,ge),D.uploadCommonUniforms(re,ge,Ft,null,Pe),ge.draw(D,Mt,Be,Pt,$e,nn.backCCW,Xt,"terrain_raster",F.gridBuffer,vt,kt)}}}}(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,T=this.painter.context,D=this.proxySourceCache,F=this.proxiedCoords[D.id],z=this._drapedRenderBatches.shift(),H=x.style.order,Q=[];this._updateFBOs(x.emissiveMode==="mrt-fallback");let re=0;for(const oe of F){const ge=D.getTileByID(oe.proxyTileKey),me=D.proxyCachedFBO[oe.key]?D.proxyCachedFBO[oe.key][h]:void 0,xe=me!==void 0?D.renderCache[me]:this.pool[re++],Pe=me!==void 0;if(ge.texture=xe.tex,ge.emissiveTexture=xe.emissiveTex,Pe&&!xe.dirty){Q.push(ge.tileID);continue}T.bindFramebuffer.set(xe.fb.framebuffer);const Ce=T.gl;let $e;Ce.drawBuffers(x.emissiveMode==="mrt-fallback"?[Ce.COLOR_ATTACHMENT0,Ce.COLOR_ATTACHMENT1]:[Ce.COLOR_ATTACHMENT0]),this.renderedToTile=!1,xe.dirty&&(T.clear({color:i.ao.transparent,stencil:0}),xe.dirty=!1);for(let Be=z.start;Be<=z.end;++Be){const Je=x.style._mergedLayers[H[Be]];if(Je.isHidden(x.transform.zoom))continue;const dt=x.style.getLayerSourceCache(Je),tt=dt?this.proxyToSource[oe.key][dt.id]:[oe];if(!tt)continue;const Mt=tt;T.viewport.set([0,0,xe.fb.width,xe.fb.height]),$e!==(dt?dt.id:null)&&(this._setupStencil(xe,tt,Je,dt),$e=dt?dt.id:null),x.renderLayer(x,dt,Je,Mt)}if(Ce.drawBuffers([Ce.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const Be of this._pendingGroundEffectLayers){const Je=x.style._mergedLayers[H[Be]];if(Je.isHidden(x.transform.zoom))continue;const dt=x.style.getLayerSourceCache(Je),tt=dt?this.proxyToSource[oe.key][dt.id]:[oe];if(!tt)continue;const Mt=tt;T.viewport.set([0,0,xe.fb.width,xe.fb.height]),$e!==(dt?dt.id:null)&&(this._setupStencil(xe,tt,Je,dt),$e=dt?dt.id:null),x.renderLayer(x,dt,Je,Mt)}this.renderedToTile?(xe.dirty=!0,Q.push(ge.tileID)):Pe||--re,re===5&&(re=0,this.renderToBackBuffer(Q))}return this.renderToBackBuffer(Q),this.renderingToTexture=!1,T.bindFramebuffer.set(null),T.viewport.set([0,0,x.width,x.height]),z.end+1}postRender(){}isLayerOrderingCorrect(h){const x=h.order.length;let T=-1,D=x;for(let F=0;FT}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,T){if(!this._visibleDemTiles)return null;const D=this._visibleDemTiles.filter(F=>F.dem).map(F=>{const z=F.tileID,H=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,T);if(z!=null)return z}return null}_createFBO(){const h=this.painter.context,x=h.gl,T=this.drapeBufferSize;h.activeTexture.set(x.TEXTURE0);const D=new i.T(h,{width:T[0],height:T[1],data:null},x.RGBA8);D.bind(x.LINEAR,x.CLAMP_TO_EDGE);const F=h.createFramebuffer(T[0],T[1],1,null);let z;return F.colorAttachment0.set(D.texture),this._emissiveTexture&&(z=new i.T(h,{width:T[0],height:T[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 _D(h,F.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=h.createRenderbuffer(h.gl.DEPTH_STENCIL,T[0],T[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 T=h.fb,D=this.painter.context,F=D.gl,z=this.drapeBufferSize;if(x){const H=new i.T(D,{width:z[0],height:z[1],data:null},F.R8);H.bind(F.LINEAR,F.CLAMP_TO_EDGE),h.emissiveTex=H,T.createColorAttachment(D,1),T.colorAttachment1.set(H.texture)}else h.emissiveTex=void 0,T.removeColorAttachment(D,1);h.dirty=!0}_initFBOPool(){for(;this.pool.length{const x=this._style._mergedLayers[h],T=x.isHidden(this.painter.transform.zoom);return x.type==="hillshade"||x.type==="custom"?!T&&x.shouldRedrape():!T&&x.hasTransition()})}_clearLineLayersFromRenderCache(){let h=!1;for(const T of this._style.getSources())if(T instanceof Np){h=!0;break}if(!h)return;const x={};for(let T=0;TQ>H.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=T}_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 H=0;H=0;z--){const H=T[z];if(x.getTileByID(H.key),x.proxyCachedFBO[H.key]!==void 0){const Q=h[H.key],re=this.proxyToSource[H.key];let oe=0;for(const ge in re){const me=re[ge],xe=Q[ge];if(!xe||xe.length!==me.length||me.some((Pe,Ce)=>Pe!==xe[Ce]||D[ge]&&D[ge].hasOwnProperty(Pe.key))){oe=-1;break}++oe}for(const ge in x.proxyCachedFBO[H.key])x.renderCache[x.proxyCachedFBO[H.key][ge]].dirty=oe<0||oe!==Object.values(Q).length}}const F=[...this._drapedRenderBatches];F.sort((z,H)=>H.end-H.start-(z.end-z.start));for(const z of F)for(const H of T){if(x.proxyCachedFBO[H.key])continue;let Q=x.renderCachePool.pop();Q===void 0&&x.renderCache.length<50&&(Q=x.renderCache.length,x.renderCache.push(this._createFBO())),Q!==void 0&&(x.proxyCachedFBO[H.key]={},x.proxyCachedFBO[H.key][z.start]=Q,x.renderCache[Q].dirty=!0)}this._tilesDirty={}}_setupStencil(h,x,T,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 H;if(T.isTileClipped())H=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);H=1,this._overlapStencilMode.test={func:z.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+H>255&&(F.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=H,this._overlapStencilMode.ref=this._stencilRef,T.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 T=this.painter,D=this.painter.context,F=D.gl;T._tileClippingMaskIDs={},D.setColorMode(Dn.disabled),D.setDepthMode(Pr.disabled);const z=T.getOrCreateProgram("clippingMask");for(const H of h){const Q=T._tileClippingMaskIDs[H.key]=--x;z.draw(T,F.TRIANGLES,Pr.disabled,new dn({func:F.ALWAYS,mask:0},Q,255,F.KEEP,F.KEEP,F.REPLACE),Dn.disabled,nn.disabled,gb(H.projMatrix),"$clipping",T.tileExtentBuffer,T.quadTriangleIndexBuffer,T.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 T=[h.x,h.y,1,1];i.aC(T,T,x.pixelMatrixInverse),i.cK(T,T,1/T[3]),T[0]/=x.worldSize,T[1]/=x.worldSize;const D=x._camera.position,F=i.cf(1,x.center.lat),z=[D[0],D[1],D[2]/F,0],H=i.da([],T.slice(0,3),z);i.aw(H,H);const Q=this.raycast(z,H,this._exaggeration);return Q!==null&&Q?(i.bH(z,z,H,Q),z[3]=z[2],z[2]*=F,z):null}_setupProxiedCoordsForOrtho(h,x,T){if(h.getSource()instanceof i.aU)return this._setupProxiedCoordsForImageSource(h,x,T);this._findCoveringTileCache[h.id]=this._findCoveringTileCache[h.id]||{};const D=this.proxiedCoords[h.id]=[],F=this.proxyCoords;for(let Q=0;Qoe.overscaledZ-re.overscaledZ)}_setupProxiedCoordsForImageSource(h,x,T){if(!h.getSource().loaded())return;const D=this.proxiedCoords[h.id]=[],F=this.proxyCoords,z=h.getSource(),H=z.tileID;if(!H)return;const Q=new i.P(H.x,H.y)._div(1<(ge.min.x=Math.min(ge.min.x,me.x-Q.x),ge.min.y=Math.min(ge.min.y,me.y-Q.y),ge.max.x=Math.max(ge.max.x,me.x-Q.x),ge.max.y=Math.max(ge.max.y,me.y-Q.y),ge),{min:new i.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),oe=(ge,me)=>{const xe=ge.wrap+ge.canonical.x/(1<$e+re.max.x||Pe+CeBe+re.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,H,Q;D=i.bC();const re=x.tileID.wrap-h.wrap<0?(z=i.al>>F,H=z*((x.tileID.canonical.x<=ge){const me=h.canonical.z-ge;x.getSource().reparseOverscaled?(H=Math.max(h.canonical.z+2,x.transform.tileZoom),z=new i.aQ(H,h.wrap,ge,h.canonical.x>>me,h.canonical.y>>me)):me!==0&&(H=ge,z=new i.aQ(H,h.wrap,ge,h.canonical.x>>me,h.canonical.y>>me))}z.key!==h.key&&(re.push(z.key),T=x.getTile(z))}const oe=ge=>{re.forEach(me=>{D[me]=ge}),re.length=0};for(H-=1;H>=Q&&(!T||!T.hasData());H--){T&&oe(T.tileID.key);const ge=z.calculateScaledKey(H);if(T=x.getTileByID(ge),T&&T.hasData())break;const me=D[ge];if(me===null)break;me===void 0?re.push(ge):T=x.getTileByID(me)}return oe(T?T.tileID.key:null),T&&T.hasData()?T:null}findDEMTileFor(h){return this.enabled?this._findTileCoveringTileID(h,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(h,x){let T=this._tilesDirty[h];T||(T=this._tilesDirty[h]={}),T[x.key]=!0}}function jv(M,h,x){const T=function(H,Q,re){const oe=i.bJ(Q,H),ge=i.bJ(re,[.2126,.7152,.0722]),me=(Pe,Ce,$e)=>(1-$e)*Pe+$e*Ce,xe=me(1-.3*Math.min(ge,1),1,Math.min(oe+1,1));return me(.92,1,Math.asin(i.aA(Q[2],-1,1))/Math.PI+.5)*xe}(M,[0,0,1],h),D=[0,0,0];i.c5(D,x.slice(0,3),T);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 Hce=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Wce=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class bD{static cacheKey(h,x,T,D){const F=[x];D&&F.push(D.cacheKey);for(const z of T)h.usedDefines.has(z)&&F.push(z);return F.join("/")}constructor(h,x,T,D,F,z){const H=h.gl;this.program=H.createProgram(),this.configuration=D,this.name=x,this.fixedDefines=[...z];const Q=`#version 300 es ${(D?D.defines():[]).concat(z.map(Ce=>`#define ${Ce}`)).join(` `)}`,re=[Q,Oce];for(const Ce of T.fragmentIncludes)re.push(ax[Ce]);re.push(T.fragmentSource);const oe=re.join(` `),ge=[Q,uD];for(const Ce of T.vertexIncludes)ge.push(ax[Ce]);this.forceManualRenderingForInstanceIDShaders=h.forceManualRenderingForInstanceIDShaders&&T.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&ge.push("uniform int u_instanceID;"),ge.push(T.vertexSource);let me=ge.join(` `);this.forceManualRenderingForInstanceIDShaders&&(me=me.replaceAll("gl_InstanceID","u_instanceID"));const xe=H.createShader(H.FRAGMENT_SHADER);if(H.isContextLost())return void(this.failedToCreate=!0);H.shaderSource(xe,oe),H.compileShader(xe),H.attachShader(this.program,xe);const Pe=H.createShader(H.VERTEX_SHADER);H.isContextLost()?this.failedToCreate=!0:(H.shaderSource(Pe,me),H.compileShader(Pe),H.attachShader(this.program,Pe),this.attributes={},H.linkProgram(this.program),H.deleteShader(Pe),H.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 T=this.attributes[x];return T===void 0&&(T=this.attributes[x]=h.getAttribLocation(this.program,x)),T}setTerrainUniformValues(h,x){if(!this.terrainUniforms)return;const T=this.terrainUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)T[D]&&T[D].set(this.program,D,x[D])}}setGlobeUniformValues(h,x){if(!this.globeUniforms)return;const T=this.globeUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)T[D]&&T[D].set(this.program,D,x[D])}}setFogUniformValues(h,x){if(!this.fogUniforms)return;const T=this.fogUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)T[D].set(this.program,D,x[D])}}setCutoffUniformValues(h,x){if(!this.cutoffUniforms)return;const T=this.cutoffUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)T[D].set(this.program,D,x[D])}}setLightsUniformValues(h,x){if(!this.lightsUniforms)return;const T=this.lightsUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)T[D].set(this.program,D,x[D])}}setShadowUniformValues(h,x){if(this.failedToCreate||!this.shadowUniforms)return;const T=this.shadowUniforms;h.program.set(this.program);for(const D in x)T[D].set(this.program,D,x[D])}_drawDebugWireframe(h,x,T,D,F,z,H,Q,re,oe){const ge=h.options.wireframe;if(ge.terrain===!1&&ge.layers2D===!1&&ge.layers3D===!1)return;const me=h.context;if(!(!(!ge.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!ge.layers2D||h._terrain&&h._terrain.renderingToTexture||!Hce.includes(this.name))||!(!ge.layers3D||!Wce.includes(this.name))))return;const xe=me.gl,Pe=h.wireframeDebugCache.getLinesFromTrianglesBuffer(h.frameCounter,F,me);if(!Pe)return;const Ce=[...this.fixedDefines,"DEBUG_WIREFRAME"],$e=h.getOrCreateProgram(this.name,{config:this.configuration,defines:Ce});me.program.set($e.program);const Be=(tt,Mt,vt)=>{if(Mt[tt]&&vt[tt])for(const kt in Mt[tt])vt[tt][kt]&&vt[tt][kt].set(vt.program,kt,Mt[tt][kt].current)};re&&re.setUniforms($e.program,me,$e.binderUniforms,H,{zoom:Q}),Be("fixedUniforms",this,$e),Be("terrainUniforms",this,$e),Be("globeUniforms",this,$e),Be("fogUniforms",this,$e),Be("lightsUniforms",this,$e),Be("shadowUniforms",this,$e),Pe.bind(),me.setColorMode(new Dn([xe.ONE,xe.ONE_MINUS_SRC_ALPHA,xe.ZERO,xe.ONE],i.ao.transparent,[!0,!0,!0,!1])),me.setDepthMode(new Pr(x.func===xe.LESS?xe.LEQUAL:x.func,Pr.ReadOnly,x.range)),me.setStencilMode(dn.disabled);const Je=3*z.primitiveLength*2,dt=3*z.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const tt=oe||1;for(let Mt=0;Mt1?xe.drawElementsInstanced(xe.LINES,Je,xe.UNSIGNED_SHORT,dt,oe):xe.drawElements(xe.LINES,Je,xe.UNSIGNED_SHORT,dt);F.bind(),me.program.set(this.program),me.setDepthMode(x),me.setStencilMode(T),me.setColorMode(D)}checkUniforms(h,x,T){if(this.fixedDefines.includes(x)){for(const D of Object.keys(T))if(!T[D].initialized)throw new Error(`Program '${this.name}', from draw '${h}': uniform ${D} not set but required by ${x} being defined`)}}draw(h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Ce,$e){const Be=h.context,Je=Be.gl;if(this.failedToCreate)return;Be.program.set(this.program),Be.setDepthMode(T),Be.setStencilMode(D),Be.setColorMode(F),Be.setCullFace(z);for(const[xt,pt]of this.fixedUniformsEntries)pt.set(this.program,xt,H[xt]);Pe&&Pe.setUniforms(this.program,Be,this.binderUniforms,me,{zoom:xe});const dt={[Je.POINTS]:1,[Je.LINES]:2,[Je.TRIANGLES]:3,[Je.LINE_STRIP]:1}[x];this.checkUniforms(Q,"RENDER_SHADOWS",this.shadowUniforms);const tt=Ce||[],Mt=Pe?Pe.getPaintVertexBuffers():[],vt=x===Je.TRIANGLES&&oe,kt=$e&&$e>0?1:void 0;for(const xt of ge.get()){const pt=xt.vaos||(xt.vaos={});if((pt[Q]||(pt[Q]=new Rce)).bind(Be,this,re,Mt,oe,xt.vertexOffset,tt,kt),this.forceManualRenderingForInstanceIDShaders){const Pt=$e||1;for(let Ht=0;Ht1?Je.drawElementsInstanced(x,xt.primitiveLength*dt,Je.UNSIGNED_SHORT,xt.primitiveOffset*dt*2,$e):oe?Je.drawElements(x,xt.primitiveLength*dt,Je.UNSIGNED_SHORT,xt.primitiveOffset*dt*2):Je.drawArrays(x,xt.vertexOffset,xt.vertexLength);vt&&this._drawDebugWireframe(h,T,D,F,oe,xt,me,xe,Pe,$e)}}}function wD(M,h,x=0){const T=Math.pow(2,h.tileID.overscaledZ),D=h.tileSize*Math.pow(2,M.transform.tileZoom)/T,F=D*(h.tileID.canonical.x+h.tileID.wrap*T),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 FS={terrain:0,flat:1},Gce=i.bC(),zS=(M,h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Ce,$e,Be)=>{const Je=h.style.light,dt=Je.properties.get("position"),tt=[dt.x,dt.y,dt.z],Mt=i.dO();Je.properties.get("anchor")==="viewport"&&(i.dP(Mt,-h.transform.angle),i.dQ(tt,tt,Mt));const vt=Je.properties.get("color").toPremultipliedRenderColor(null),kt=h.transform,xt={u_matrix:M,u_lightpos:tt,u_lightintensity:Je.properties.get("intensity"),u_lightcolor:[vt.r,vt.g,vt.b],u_vertical_gradient:+x,u_opacity:T,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Gce,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:FS[re],u_base_type:FS[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:$e,u_ground_shadow_factor:Be};return kt.projection.name==="globe"&&(xt.u_tile_id=[H.canonical.x,H.canonical.y,1<({u_matrix:M,u_edge_radius:h,u_width_scale:x,u_vertical_scale:T,u_height_type:FS[D],u_base_type:FS[F]}),jD=(M,h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Ce,$e,Be)=>{const Je=zS(M,h,x,T,D,F,z,H,re,oe,ge,me,xe,Pe,Ce,$e,1,[0,0,0]),dt={u_height_factor:-Math.pow(2,H.overscaledZ)/Q.tileSize/8};return Object.assign(Je,wD(h,Q,Be),dt)},kv=(M,h,x,T,D,F,z,H,Q,re,oe)=>({u_matrix:h,u_opacity:x,u_ao_pass:T?1:0,u_meter_to_tile:D,u_ao:F,u_flood_light_intensity:z,u_flood_light_color:H,u_attenuation:Q,u_edge_radius:re,u_fb:0,u_fb_size:oe,u_dynamic_offset:1}),xT=(M,h,x)=>({u_matrix:M,u_emissive_strength:h,u_ground_shadow_factor:x}),yT=(M,h,x,T,D,F=0)=>Object.assign(xT(M,h,D),wD(x,T,F)),kD=(M,h,x,T)=>({u_matrix:M,u_world:x,u_emissive_strength:h,u_ground_shadow_factor:T}),vT=(M,h,x,T,D,F,z=0)=>Object.assign(yT(M,h,x,T,F,z),{u_world:D}),ox=(M,h)=>({u_matrix:M,u_ground_shadow_factor:h}),Cy=(M,h,x,T,D)=>({u_matrix:M,u_camera_pos:[h[0],h[1],h[2]],u_depth_bias:x,u_height_scale:T,u_reset_depth:D}),BS=(M,h,x,T,D,F,z,H,Q)=>({u_matrix:M,u_normal_matrix:h,u_opacity:x,u_faux_facade_ao_intensity:T,u_camera_pos:D,u_tile_to_meter:F,u_facade_emissive_chance:z,u_flood_light_color:H,u_flood_light_intensity:Q}),ND=M=>({u_matrix:M}),lx=M=>({u_matrix:M}),_T=(M,h,x,T,D,F,z,H)=>{const Q=i.al/F.tileSize;return{u_matrix:M,u_inv_rot_matrix:h,u_camera_to_center_distance:x.getCameraToCenterDistance(H),u_extrude_scale:[x.pixelsToGLUnits[0]/Q,x.pixelsToGLUnits[1]/Q],u_zoom_transition:T,u_tile_id:z,u_merc_center:D}},yb=(M,h,x=1)=>({u_matrix:M,u_color:h,u_overlay:0,u_overlay_scale:x}),SD=i.bC(),CD=(M,h,x,T,D,F,z)=>{const H=M.transform,Q=H.projection.name==="globe",re=Q?i.dR(H.zoom,h.canonical)*H._pixelsPerMercatorPixel:i.ay(x,1,F),oe={u_matrix:h.projMatrix,u_extrude_scale:re,u_intensity:z,u_inv_rot_matrix:SD,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(Q){oe.u_inv_rot_matrix=T,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:T,u_grid_matrix:D,u_tl_parent:F,u_scale_parent:re,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:TD(ge.paint.get("raster-hue-rotate")),u_perspective_transform:me,u_raster_elevation:xe,u_zoom_transition:z,u_merc_center:H,u_cutoff_params:Q,u_colorization_mix:$S(i.dU,Ce,Be),u_colorization_offset:qS(i.dU,$e,Be),u_color_ramp:Pe,u_texture_offset:[dt/(Je+2*dt),Je/(Je+2*dt)],u_texture_res:[Je+2*dt,Je+2*dt],u_emissive_strength:tt});function TD(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 Pp=.05,Kce=(M,h,x,T,D,F,z,H,Q,re,oe,ge)=>({u_matrix:M,u_normalize_matrix:h,u_globe_matrix:x,u_merc_matrix:T,u_grid_matrix:D,u_tl_parent:F,u_scale_parent:re,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:H,u_cutoff_params:Q}),Zce=(M,h,x,T,D,F,z,H,Q,re)=>({u_particle_texture:M,u_particle_texture_side_len:h,u_tile_offset:x,u_velocity:T,u_color_ramp:F,u_velocity_res:D,u_max_speed:z,u_uv_offset:H,u_data_scale:[255*Q[0],255*Q[1]],u_data_offset:re,u_particle_pos_scale:1.1,u_particle_pos_offset:[Pp,Pp]}),AD=(M,h,x,T,D,F,z,H,Q,re)=>({u_particle_texture:M,u_particle_texture_side_len:h,u_velocity:x,u_velocity_res:T,u_max_speed:D,u_speed_factor:F,u_reset_rate:z,u_rand_seed:Math.random(),u_uv_offset:H,u_data_scale:[255*Q[0],255*Q[1]],u_data_offset:re,u_particle_pos_scale:1.1,u_particle_pos_offset:[Pp,Pp]}),ED=i.bC(),US=(M,h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Ce,$e,Be,Je,dt,tt,Mt,vt,kt)=>{const xt=D.transform,pt={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:xt.getCameraToCenterDistance(Je),u_rotate_symbol:+x,u_aspect_ratio:xt.width/xt.height,u_fade_change:D.options.fadeDuration?D.symbolFadeChange:1,u_matrix:F,u_label_plane_matrix:z,u_coord_matrix:H,u_is_text:+re,u_elevation_from_sea:Q?1:0,u_pitch_with_map:+T,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:ED,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:ED,u_up_vector:[0,-1,0],u_color_adj_mat:Mt,u_icon_transition:vt||0,u_gamma_scale:T?D.transform.getCameraToCenterDistance(Je)*Math.cos(D.terrain?0:D.transform._pitch):1,u_device_pixel_ratio:i.o.devicePixelRatio,u_is_halo:1,u_scale_factor:kt||1,u_ground_shadow_factor:dt,u_inv_matrix:i.bl(i.bC(),z),u_normal_scale:tt,u_lutTexture:xc.LUT};return Je.name==="globe"&&(pt.u_tile_id=[xe.canonical.x,xe.canonical.y,1<({u_matrix:M,u_emissive_strength:h,u_opacity:x,u_color:T}),cx=(M,h,x,T,D,F,z,H,Q)=>Object.assign(function(re,oe,ge,me,xe,Pe){const{width:Ce,height:$e}=me.imageManager.getPixelSize(oe),Be=Math.pow(2,Pe.tileID.overscaledZ),Je=Pe.tileSize*Math.pow(2,me.transform.tileZoom)/Be,dt=Je*(Pe.tileID.canonical.x+Pe.tileID.wrap*Be),tt=Je*Pe.tileID.canonical.y;return{u_image:0,u_pattern_tl:ge.tl,u_pattern_br:ge.br,u_texsize:[Ce,$e],u_pattern_size:ge.displaySize,u_pattern_units_to_pixels:xe?[me.transform.width,-1*me.transform.height]:[1/i.ay(Pe,1,me.transform.tileZoom),1/i.ay(Pe,1,me.transform.tileZoom)],u_pixel_coord_upper:[dt>>16,tt>>16],u_pixel_coord_lower:[65535&dt,65535&tt]}}(0,F,z,T,H,Q),{u_matrix:M,u_emissive_strength:h,u_opacity:x}),Nv=new Float32Array(i.bA([])),My=(M,h,x,T,D,F,z,H,Q,re,oe,ge,me,xe=[0,0,0],Pe,Ce,$e)=>{const Be=D.style.light,Je=Be.properties.get("position"),dt=[-Je.x,-Je.y,Je.z],tt=i.dO();Be.properties.get("anchor")==="viewport"&&(i.dP(tt,-D.transform.angle),i.dQ(dt,dt,tt));const Mt=oe.alphaMode==="MASK",vt=Be.properties.get("color").toNonPremultipliedRenderColor(null),kt=me.paint.get("model-ambient-occlusion-intensity"),xt=me.paint.get("model-color").constantOr(i.ao.white).toNonPremultipliedRenderColor(null);return xt.a=me.paint.get("model-color-mix-intensity").constantOr(0),$e&&(xt.r=$e[0],xt.g=$e[1],xt.b=$e[2],xt.a=$e[3]),Ce&&(xt.r=Ce.color.r,xt.g=Ce.color.g,xt.b=Ce.color.b,xt.a=Ce.colorMix,ge=Ce.emissionStrength,F*=Ce.opacity),{u_matrix:M,u_lighting_matrix:h,u_normal_matrix:x,u_node_matrix:T||Nv,u_lightpos:dt,u_lightintensity:Be.properties.get("intensity"),u_lightcolor:[vt.r,vt.g,vt.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:H.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:Q,u_roughnessFactor:re,u_baseColorTexture:xc.BaseColor,u_metallicRoughnessTexture:xc.MetallicRoughness,u_normalTexture:xc.Normal,u_occlusionTexture:xc.Occlusion,u_emissionTexture:xc.Emission,u_lutTexture:xc.LUT,u_color_mix:xt.toArray01(),u_aoIntensity:kt,u_emissive_strength:ge,u_occlusionTextureTransform:Pe||[0,0,0,0]}},bT=(M,h=Nv,x=Nv)=>({u_matrix:M,u_instance:h,u_node_matrix:x}),VS={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 Hm{constructor(h,x,T,D){this.id=Hm.uniqueIdxCounter,Hm.uniqueIdxCounter++,this.context=h;const F=h.gl;this.buffer=F.createBuffer(),this.dynamicDraw=!!T,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=Hm.uniqueIdxCounter,Hm.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)}}Hm.uniqueIdxCounter=0;const wT={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class PD{constructor(h,x,T,D,F,z){this.length=x.length,this.attributes=T,this.itemSize=x.bytesPerElement,this.dynamicDraw=D,this.instanceCount=z,this.context=h;const H=h.gl;this.buffer=H.createBuffer(),h.bindVertexBuffer.set(this.buffer),H.bufferData(H.ARRAY_BUFFER,x.arrayBuffer,this.dynamicDraw?H.DYNAMIC_DRAW:H.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 T=0;T0&&h.vertexAttribDivisor(F,T)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class ID{constructor(h,x,T,D,F){this.context=h,this.width=x,this.height=T;const z=this.framebuffer=h.gl.createFramebuffer();D>0&&(this.colorAttachment0=new IS(h,z,0)),D>1&&(this.colorAttachment1=new IS(h,z,1)),F&&(this.depthAttachmentType=F,this.depthAttachment=F==="renderbuffer"?new bv(h,z):new pb(h,z))}createColorAttachment(h,x){x===0?this.colorAttachment0=new IS(h,this.framebuffer,0):x===1&&(this.colorAttachment1=new IS(h,this.framebuffer,1))}removeColorAttachment(h,x){const T=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&&T.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 Sv{constructor(h,x){this.gl=h,this.clearColor=new $ce(this),this.clearDepth=new hD(this),this.clearStencil=new nT(this),this.colorMask=new MS(this),this.depthMask=new aT(this),this.stencilMask=new Sy(this),this.stencilFunc=new xv(this),this.stencilOp=new hb(this),this.stencilTest=new yv(this),this.depthRange=new mD(this),this.depthTest=new iT(this),this.depthFunc=new pD(this),this.blend=new vv(this),this.blendFunc=new TS(this),this.blendColor=new AS(this),this.blendEquation=new oT(this),this.cullFace=new ES(this),this.cullFaceSide=new mb(this),this.frontFace=new fD(this),this.program=new gD(this),this.activeTexture=new xD(this),this.viewport=new _v(this),this.bindFramebuffer=new yD(this),this.bindRenderbuffer=new qce(this),this.bindTexture=new Uce(this),this.bindVertexBuffer=new Vce(this),this.bindElementBuffer=new lT(this),this.bindVertexArrayOES=new cT(this),this.pixelStoreUnpack=new dT(this),this.pixelStoreUnpackPremultiplyAlpha=new uT(this),this.pixelStoreUnpackFlipY=new vD(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,T){return new Hm(this,h,x,T)}createVertexBuffer(h,x,T,D,F){return new PD(this,h,x,T,D,F)}createRenderbuffer(h,x,T){const D=this.gl,F=D.createRenderbuffer();return this.bindRenderbuffer.set(F),D.renderbufferStorage(D.RENDERBUFFER,h,x,T),this.bindRenderbuffer.set(null),F}createFramebuffer(h,x,T,D){return new ID(this,h,x,T,D)}clear({color:h,depth:x,stencil:T,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)),T!==void 0&&(z|=F.STENCIL_BUFFER_BIT,this.clearStencil.set(T),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 Ty;function _r(M,h,x,T,D,F,z){const H=M.context,Q=H.gl,re=M.transform,oe=[i.aF(re.center.lng),i.aJ(re.center.lat)],ge=x.layout.get("symbol-placement"),me=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",$e=[];let Be=0,Je=0;for(let pt=0;pt0){const or=i.bC(),fr=Ks;i.cP(or,Vt.placementInvProjMatrix,re.glCoordMatrix),i.cP(or,or,Vt.placementViewportMatrix),$e.push({circleArray:Cr,circleOffset:Je,transform:fr,invTransform:or,projection:Vt.getProjection()}),Be+=Cr.length/4,Je=Be}if(!$s)continue;M.terrain&&M.terrain.setupElevationDraw(Ht,mr);const kr=Es?[Pt.canonical.x,Pt.canonical.y,1<=0&&(xe[dt.associatedIconIndex]={x:Vt,y:ts,z:ss,angle:cs})}else qm(vt,ge)}if(re){me.clear();const Je=M.icon.placedSymbolArray;for(let dt=0;dt{let Na=[0,0,0];if(Ja){const zn=M.style.directionalLight,zi=M.style.ambientLight;zn&&zi&&(Na=Bf(M.style,zn,zi))}return Na},Ra=Ja=>{pt.depthOcclusionForSymbolsAndCircles&&(x.hasOcclusionOpacityProperties||M.terrain)&&(Ja.push("DEPTH_D24"),Ja.push("DEPTH_OCCLUSION"))},vn=Ja=>{x.lut&&!vt&&(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],kt.gl.RGBA8)),kt.activeTexture.set(kt.gl.TEXTURE0+xc.LUT),x.lut.texture&&x.lut.texture.bind(kt.gl.LINEAR,kt.gl.CLAMP_TO_EDGE),Ja.push("APPLY_LUT_ON_GPU"))},Qa=()=>{const Ja=Pt&&x.layout.get("symbol-placement")!=="point",Na=[];Ra(Na),vn(Na);const zn=Ja||jn,zi=$s.elevationType==="road",To=M.shadowRenderer,ho=zi&&Vt&&!!To&&To.enabled,wi=Er(ho),eu=zi&&Vt&&!M.terrain?Xt:Bs,ed=x.paint.get("icon-image-cross-fade");M.terrainRenderModeElevated()&&Vt&&Na.push("PITCH_WITH_MAP_TERRAIN"),Cr&&(Na.push("PROJECTION_GLOBE_VIEW"),zn&&Na.push("PROJECTED_POS_ON_VIEWPORT")),ed>0&&$s.hasAnySecondaryIcon&&Na.push("ICON_TRANSITION"),!$s.icon.zOffsetVertexBuffer||zi&&M.terrain||Na.push("Z_OFFSET"),Be===0&&Je===0&&dt===0&&tt===1||Na.push("COLOR_ADJUSTMENT"),$s.sdfIcons&&Na.push("RENDER_SDF"),ho&&Na.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),zi&&Vt&&!M.terrain&&$s.icon.orientationVertexBuffer&&Na.push("ELEVATED_ROADS");const bl=$s.icon.programConfigurations.get(x.id),fd=M.getOrCreateProgram("symbol",{config:bl,defines:Na}),gd=Ks.imageAtlasTexture?Ks.imageAtlasTexture.size:[0,0],Ec=$s.iconSizeData,yh=i.bK(Ec,pt.zoom),cm=Vt||!pt.isOrthographic,Su=Ws(or,Ks.tileID.canonical,Vt,Pt,pt,$s.getProjection(),fr),wo=cn(or,Ks.tileID.canonical,Vt,Pt,pt,$s.getProjection(),fr),Oo=M.translatePosMatrix(wo,Ks,H,re,!0),ji=M.translatePosMatrix(or,Ks,H,re),Go=zn?_b:Su,go=Pt&&!Vt&&!Ja;let mo=Qs;!es&&!pt.mercatorFromTransition||Pt||(mo=qf(pt));const dm=Cr?mo:Qs,Ib=x.getColorAdjustmentMatrix(Be,Je,dt,tt),Km=US(Ec.kind,yh,go,Vt,M,ji,Go,Oo,Mt,!1,gd,[0,0],0,mr,kr,Ft,ha,dm,$s.getProjection(),wi,Wa,Ib,ed,null),Lb=Ks.imageAtlasTexture?Ks.imageAtlasTexture:null,Dv=x.layout.get("icon-size").constantOr(0)!==1||$s.iconsNeedLinear,Rp=$s.sdfIcons||M.options.rotating||M.options.zooming||Dv||cm?xt.LINEAR:xt.NEAREST,Xf=$s.sdfIcons&&x.paint.get("icon-halo-width").constantOr(1)!==0,Ov=M.terrain&&Vt&&Ja?i.bl(i.bC(),Su):_b;if(Ja&&$s.icon){const fx=i.bV.getAtTileOffsetFunc(mr,pt.center.lat,pt.worldSize,$s.getProjection()),Qf=ln(or,Ks.tileID.canonical,Vt,Pt,pt,$s.getProjection(),fr),Zm=x.layout.get("icon-size-scale-range"),Jf=i.aA(M.scaleFactor,Zm[0],Zm[1]);Rf($s,or,M,!1,Qf,wo,Vt,Ce,fx,mr,Jf)}return{program:fd,buffers:$s.icon,uniformValues:Km,atlasTexture:Lb,atlasTextureIcon:null,atlasInterpolation:Rp,atlasInterpolationIcon:null,isSDF:$s.sdfIcons,hasHalo:Xf,depthMode:eu,tile:Ks,renderWithShadows:ho,labelPlaneMatrixInv:Ov}},pi=()=>{const Ja=Ht&&x.layout.get("symbol-placement")!=="point",Na=[],zn=Ja||cs||jn,zi=$s.elevationType==="road",To=M.shadowRenderer,ho=zi&&ts&&!!To&&To.enabled,wi=Er(ho),eu=zi&&ts&&!M.terrain?Xt:Bs;M.terrainRenderModeElevated()&&ts&&Na.push("PITCH_WITH_MAP_TERRAIN"),Cr&&(Na.push("PROJECTION_GLOBE_VIEW"),zn&&Na.push("PROJECTED_POS_ON_VIEWPORT")),!$s.text.zOffsetVertexBuffer||zi&&M.terrain||Na.push("Z_OFFSET"),$s.iconsInText&&Na.push("RENDER_TEXT_AND_SYMBOL"),Na.push("RENDER_SDF"),ho&&Na.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),zi&&ts&&!M.terrain&&$s.text.orientationVertexBuffer&&Na.push("ELEVATED_ROADS"),Ra(Na);const ed=$s.text.programConfigurations.get(x.id),bl=M.getOrCreateProgram("symbol",{config:ed,defines:Na});let fd,gd=[0,0],Ec=null;const yh=$s.textSizeData;$s.iconsInText&&(gd=Ks.imageAtlasTexture?Ks.imageAtlasTexture.size:[0,0],Ec=Ks.imageAtlasTexture?Ks.imageAtlasTexture:null,fd=ts||!pt.isOrthographic||M.options.rotating||M.options.zooming||yh.kind==="composite"||yh.kind==="camera"?xt.LINEAR:xt.NEAREST);const cm=Ks.glyphAtlasTexture?Ks.glyphAtlasTexture.size:[0,0],Su=x.layout.get("text-size-scale-range"),wo=i.aA(M.scaleFactor,Su[0],Su[1]),Oo=i.bK(yh,pt.zoom,wo),ji=Ws(or,Ks.tileID.canonical,ts,Ht,pt,$s.getProjection(),fr),Go=cn(or,Ks.tileID.canonical,ts,Ht,pt,$s.getProjection(),fr),go=M.translatePosMatrix(Go,Ks,Q,oe,!0),mo=M.translatePosMatrix(or,Ks,Q,oe),dm=zn?_b:ji,Ib=Ht&&!ts&&!Ja;let Km=Qs;!es&&!pt.mercatorFromTransition||Ht||(Km=qf(pt));const Lb=US(yh.kind,Oo,Ib,ts,M,mo,dm,go,Mt,!0,cm,gd,0,mr,kr,Ft,ha,Cr?Km:Qs,$s.getProjection(),wi,Wa,null,null,wo),Dv=Ks.glyphAtlasTexture?Ks.glyphAtlasTexture:null,Rp=xt.LINEAR,Xf=x.paint.get("text-halo-width").constantOr(1)!==0,Ov=M.terrain&&ts&&Ja?i.bl(i.bC(),ji):_b;if(Ja&&$s.text){const fx=i.bV.getAtTileOffsetFunc(mr,pt.center.lat,pt.worldSize,$s.getProjection()),Qf=ln(or,Ks.tileID.canonical,ts,Ht,pt,$s.getProjection(),fr);Rf($s,or,M,!0,Qf,Go,ts,$e,fx,mr,wo)}return{program:bl,buffers:$s.text,uniformValues:Lb,atlasTexture:Dv,atlasTextureIcon:Ec,atlasInterpolation:Rp,atlasInterpolationIcon:fd,isSDF:!0,hasHalo:Xf,depthMode:eu,tile:Ks,renderWithShadows:ho,labelPlaneMatrixInv:Ov}},oi=$s.icon.segments.get().length,La=$s.text.segments.get().length,Fn=oi&&!z.onlyText?Qa():null,Ya=La&&!z.onlyIcons?pi():null,fo=x.paint.get("icon-opacity").constantOr(1),Hi=x.paint.get("text-opacity").constantOr(1);if(ss&&$s.canOverlap){ps=!0;const Ja=fo&&!z.onlyText?$s.icon.segments.get():[],Na=Hi&&!z.onlyIcons?$s.text.segments.get():[];for(const zn of Ja)Es.push({segments:new i.bg([zn]),sortKey:zn.sortKey,state:Fn});for(const zn of Na)Es.push({segments:new i.bg([zn]),sortKey:zn.sortKey,state:Ya})}else z.onlyText||Es.push({segments:fo?$s.icon.segments:new i.bg([]),sortKey:0,state:Fn}),z.onlyIcons||Es.push({segments:Hi?$s.text.segments:new i.bg([]),sortKey:0,state:Ya})}ps&&Es.sort((mr,Ks)=>mr.sortKey-Ks.sortKey);for(const mr of Es){const Ks=mr.state;if(Ks)if(M.terrain?M.terrain.setupElevationDraw(Ks.tile,Ks.program,{useDepthForOcclusion:pt.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Ks.labelPlaneMatrixInv}):M.setupDepthForOcclusion(pt.depthOcclusionForSymbolsAndCircles,Ks.program),kt.activeTexture.set(xt.TEXTURE0),Ks.atlasTexture&&Ks.atlasTexture.bind(Ks.atlasInterpolation,xt.CLAMP_TO_EDGE,!0),Ks.atlasTextureIcon&&(kt.activeTexture.set(xt.TEXTURE1),Ks.atlasTextureIcon&&Ks.atlasTextureIcon.bind(Ks.atlasInterpolationIcon,xt.CLAMP_TO_EDGE,!0)),Ks.renderWithShadows&&M.shadowRenderer.setupShadows(Ks.tile.tileID.toUnwrapped(),Ks.program,"vector-tile"),M.uploadCommonLightUniforms(M.context,Ks.program),Ks.hasHalo){const $s=Ks.uniformValues;$s.u_is_halo=1,jT(Ks.buffers,mr.segments,x,M,Ks.program,Ks.depthMode,D,F,$s,2),$s.u_is_halo=0}else{if(Ks.isSDF){const $s=Ks.uniformValues;Ks.hasHalo&&($s.u_is_halo=1,jT(Ks.buffers,mr.segments,x,M,Ks.program,Ks.depthMode,D,F,$s,1)),$s.u_is_halo=0}jT(Ks.buffers,mr.segments,x,M,Ks.program,Ks.depthMode,D,F,Ks.uniformValues,1)}}}function jT(M,h,x,T,D,F,z,H,Q,re){const oe=[M.dynamicLayoutVertexBuffer,M.opacityVertexBuffer,M.iconTransitioningVertexBuffer,M.globeExtVertexBuffer,M.zOffsetVertexBuffer,M.orientationVertexBuffer];D.draw(T,T.context.gl.TRIANGLES,F,z,H,nn.disabled,Q,x.id,M.layoutVertexBuffer,M.indexBuffer,h,x.paint,T.transform.zoom,M.programConfigurations.get(x.id),oe,re)}function LD(M,h){const x=1<=Vm?1:xe.pitch/Vm))),2*Pe}(M.transform),re=M.transform.getFreeCameraOptions().position,oe="elevatedStructuresDepthReconstruct",ge=M.getOrCreateProgram(oe,{defines:["DEPTH_RECONSTRUCTION"]}),me=M.getOrCreateProgram(oe);for(const xe of T){const Pe=h.getTile(xe),Ce=Pe.getBucket(x);if(!Ce)continue;const $e=Ce.elevatedStructures;if(!$e)continue;const Be=Ce.elevationBufferData.heightRange,Je=LD(xe.toUnwrapped(),re),dt=M.translatePosMatrix(xe.projMatrix,Pe,x.paint.get("fill-translate"),x.paint.get("fill-translate-anchor"));let tt,Mt,vt,kt;if(D==="initialize"){if(!Be||Be.min>=1||$e.depthSegments.segments[0].primitiveLength===0)continue;tt=Cy(dt,Je,Q,1,0),Mt=z,vt=$e.depthSegments,kt=ge}else if(D==="reset"){if(!Be||Be.min>=0||$e.maskSegments.segments[0].primitiveLength===0)continue;tt=Cy(dt,Je,0,0,1),Mt=H,vt=$e.maskSegments,kt=ge}else if(D==="geometry"){if($e.depthSegments.segments[0].primitiveLength===0)continue;tt=Cy(dt,Je,Q,1,0),Mt=z,vt=$e.depthSegments,kt=me}kt.draw(M,F.TRIANGLES,Mt,dn.disabled,Dn.disabled,nn.disabled,tt,x.id,$e.vertexBuffer,$e.indexBuffer,vt,x.paint,M.transform.zoom)}}function WS(M,h,x,T){const{painter:D,sourceCache:F,layer:z,coords:H,colorMode:Q,elevationType:re,terrainEnabled:oe,pass:ge}=M,me=D.context.gl,xe=z.paint.get("fill-pattern"),Pe=z.paint.get("fill-pattern-cross-fade"),Ce=xe.constantOr(null);let $e=re;re!=="road"||h&&!oe||($e="none");const Be=$e==="road",Je=M.painter.shadowRenderer,dt=Be&&!!Je&&Je.enabled,tt=new Pr(D.context.gl.LEQUAL,Pr.ReadOnly,D.depthRangeFor3D);let Mt=[0,0,0];if(dt){const pt=D.style.directionalLight,Pt=D.style.ambientLight;pt&&Pt&&(Mt=Bf(D.style,pt,Pt))}const vt=xe&&xe.constantOr(1),kt=D.terrain&&D.terrain.renderingToTexture,xt=(pt,Pt)=>{let Ht,Vt,ts,ss,ps;Pt?(Ht=vt&&!z.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",ts=me.LINES):(Ht=vt?"fillPattern":"fill",ts=me.TRIANGLES);for(const Bs of H){const Xt=F.getTile(Bs);if(vt&&!Xt.patternsLoaded())continue;const Ft=Xt.getBucket(z);if(!Ft)continue;const cs=h?Ft.elevationBufferData:Ft.bufferData;if(cs.isEmpty())continue;D.prepareDrawTile();const es=cs.programConfigurations.get(z.id),Es=D.isTileAffectedByFog(Bs),Qs=[],mr=[];Be&&(Qs.push("ELEVATED_ROADS"),mr.push(cs.elevatedLayoutVertexBuffer)),dt&&Qs.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),kt&&x&&Qs.push("USE_MRT1"),vt&&(D.context.activeTexture.set(me.TEXTURE0),Xt.imageAtlasTexture&&Xt.imageAtlasTexture.bind(me.LINEAR,me.CLAMP_TO_EDGE),es.updatePaintBuffers());let Ks=!1;if(Ce&&Xt.imageAtlas){const fr=Xt.imageAtlas,qr=i.e3.from(Ce),jn=qr.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),ha=qr.getSecondary(),Wa=fr.patternPositions.get(jn),Er=ha?fr.patternPositions.get(ha.scaleSelf(i.o.devicePixelRatio).toString()):null;Ks=!!Wa&&!!Er,Wa&&es.setConstantPatternPositions(Wa,Er)}Pe>0&&(Ks||es.getPatternTransitionVertexBuffer("fill-pattern"))&&Qs.push("FILL_PATTERN_TRANSITION");const $s=D.getOrCreateProgram(Ht,{config:es,overrideFog:Es,defines:Qs}),Cr=D.translatePosMatrix(Bs.projMatrix,Xt,z.paint.get("fill-translate"),z.paint.get("fill-translate-anchor"));dt&&Je.setupShadows(Xt.tileID.toUnwrapped(),$s,"vector-tile");const kr=z.paint.get("fill-emissive-strength");if(Pt){ss=cs.lineIndexBuffer,ps=cs.lineSegments;const fr=D.terrain&&D.terrain.renderingToTexture?D.terrain.drapeBufferSize:[me.drawingBufferWidth,me.drawingBufferHeight];Vt=Ht==="fillOutlinePattern"&&vt?vT(Cr,kr,D,Xt,fr,Mt,Pe):kD(Cr,kr,fr,Mt)}else ss=cs.indexBuffer,ps=cs.triangleSegments,Vt=vt?yT(Cr,kr,D,Xt,Mt,Pe):xT(Cr,kr,Mt);D.uploadCommonUniforms(D.context,$s,Bs.toUnwrapped());let or=pt;(re==="road"&&!oe||re==="offset")&&(or=tt),$s.draw(D,ts,or,T||D.stencilModeForClipping(Bs),Q,nn.disabled,Vt,z.id,cs.layoutVertexBuffer,ss,ps,z.paint,D.transform.zoom,es,mr)}};D.renderPass===ge&&xt(D.depthModeForSublayer(1,D.renderPass==="opaque"?Pr.ReadWrite:Pr.ReadOnly),!1),$e==="none"&&D.renderPass==="translucent"&&z.paint.get("fill-antialias")&&xt(D.depthModeForSublayer(z.getPaintProperty("fill-outline-color")?2:0,Pr.ReadOnly),!0)}function GS(M,h,x,T,D,F,z,H){x.resetLayerRenderingStats(M);const Q=M.context,re=Q.gl,oe=M.transform,ge=x.paint.get("fill-extrusion-pattern"),me=x.paint.get("fill-extrusion-pattern-cross-fade"),xe=ge.constantOr(null),Pe=ge.constantOr(1),Ce=x.paint.get("fill-extrusion-opacity"),$e=M.style.enable3dLights(),Be=x.paint.get($e&&!Pe?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),Je=[x.paint.get("fill-extrusion-ambient-occlusion-intensity"),Be],dt=x.layout.get("fill-extrusion-edge-radius"),tt=dt>0&&!x.paint.get("fill-extrusion-rounded-roof"),Mt=tt?0:dt,vt=oe.projection.name==="globe"?i.eb():0,kt=oe.projection.name==="globe",xt=kt?i.aj(oe.zoom):0,pt=[i.aF(oe.center.lng),i.aJ(oe.center.lat)],Pt=x.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Ht=x.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Pt?null:x.lut).toArray01().slice(0,3),Vt=x.paint.get("fill-extrusion-flood-light-intensity"),ts=x.paint.get("fill-extrusion-vertical-scale"),ss=x.paint.get("fill-extrusion-line-width").constantOr(1)!==0,ps=x.paint.get("fill-extrusion-height-alignment"),Bs=x.paint.get("fill-extrusion-base-alignment"),Xt=tx(M,x.paint.get("fill-extrusion-cutoff-fade-range")),Ft=[];let cs;kt&&Ft.push("PROJECTION_GLOBE_VIEW"),Je[0]>0&&Ft.push("FAUX_AO"),tt&&Ft.push("ZERO_ROOF_RADIUS"),H&&Ft.push("HAS_CENTROID"),Vt>0&&Ft.push("FLOOD_LIGHT"),Xt.shouldRenderCutoff&&Ft.push("RENDER_CUTOFF"),ss&&Ft.push("RENDER_WALL_MODE");const es=M.renderPass==="shadow",Es=M.shadowRenderer,Qs=es&&!!Es,mr=es?nn.disabled:nn.backCCW;M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!0);let Ks=[0,0,0];if(Es){const kr=M.style.directionalLight,or=M.style.ambientLight;kr&&or&&(Ks=Bf(M.style,kr,or)),es||(Ft.push("RENDER_SHADOWS","DEPTH_TEXTURE"),Es.useNormalOffset&&Ft.push("NORMAL_OFFSET")),cs=Ft.concat(["SHADOWS_SINGLE_CASCADE"])}const $s=Qs?"fillExtrusionDepth":Pe?"fillExtrusionPattern":"fillExtrusion",Cr=x.getLayerRenderingStats();for(const kr of T){const or=h.getTile(kr),fr=or.getBucket(x);if(!fr||fr.projection.name!==oe.projection.name)continue;let qr=!1;Es&&(qr=Es.getMaxCascadeForTile(kr.toUnwrapped())===0);const jn=M.isTileAffectedByFog(kr),ha=fr.programConfigurations.get(x.id);let Wa=!1;if(xe&&or.imageAtlas){const La=or.imageAtlas,Fn=i.e3.from(xe),Ya=Fn.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),fo=Fn.getSecondary(),Hi=La.patternPositions.get(Ya),Ja=fo?La.patternPositions.get(fo.scaleSelf(i.o.devicePixelRatio).toString()):null;Wa=!!Hi&&!!Ja,Hi&&ha.setConstantPatternPositions(Hi,Ja)}me>0&&(Wa||ha.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&Ft.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Er=M.getOrCreateProgram($s,{config:ha,defines:qr?cs:Ft,overrideFog:jn});if(M.terrain&&M.terrain.setupElevationDraw(or,Er,{useMeterToDem:!0}),!fr.centroidVertexBuffer){const La=Er.getAttributeLocation(re,"a_centroid_pos");La!==-1&&re.vertexAttrib2f(La,0,0)}!es&&Es&&Es.setupShadows(or.tileID.toUnwrapped(),Er,"vector-tile"),Pe&&(M.context.activeTexture.set(re.TEXTURE0),or.imageAtlasTexture&&or.imageAtlasTexture.bind(re.LINEAR,re.CLAMP_TO_EDGE),ha.updatePaintBuffers());const Ra=x.paint.get("fill-extrusion-vertical-gradient"),vn=1/fr.tileToMeter;let Qa;if(es&&Es){if(Vf(or.tileID,fr.maxHeight,M))continue;const La=Es.calculateShadowPassMatrixFromTile(or.tileID.toUnwrapped());Qa=gT(La,Mt,vn,ts,ps,Bs)}else{const La=M.translatePosMatrix(kr.expandedProjMatrix,or,x.paint.get("fill-extrusion-translate"),x.paint.get("fill-extrusion-translate-anchor")),Fn=oe.projection.createInversionMatrix(oe,kr.canonical);Qa=Pe?jD(La,M,Ra,Ce,Je,Mt,vn,kr,or,vt,ps,Bs,xt,pt,Fn,Ht,ts,me):zS(La,M,Ra,Ce,Je,Mt,vn,kr,vt,ps,Bs,xt,pt,Fn,Ht,ts,Vt,Ks)}M.uploadCommonUniforms(Q,Er,kr.toUnwrapped(),null,Xt);let pi=fr.segments;if(oe.projection.name==="mercator"&&!es&&(pi=fr.getVisibleSegments(or.tileID,M.terrain,M.transform.getFrustum(0)),!pi.get().length))continue;if(Cr)if(es)for(const La of pi.get())Cr.numRenderedVerticesInShadowPass+=La.primitiveLength;else for(const La of pi.get())Cr.numRenderedVerticesInTransparentPass+=La.primitiveLength;const oi=[];(M.terrain||H)&&oi.push(fr.centroidVertexBuffer),kt&&oi.push(fr.layoutVertexExtBuffer),ss&&oi.push(fr.wallVertexBuffer),Er.draw(M,Q.gl.TRIANGLES,D,F,z,mr,Qa,x.id,fr.layoutVertexBuffer,fr.indexBuffer,pi,x.paint,M.transform.zoom,ha,oi)}M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!1)}class kT{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function Uf(M,h,x,T,D,F,z,H,Q,re,oe,ge,me,xe,Pe,Ce,$e,Be,Je,dt){const tt=h.context,Mt=tt.gl,vt=h.transform,kt=h.transform.zoom,xt=[],pt=M.translate,Pt=M.translateAnchor,Ht=M.edgeRadius,Vt=tx(h,M.cutoffFadeRange);oe==="clear"?(xt.push("CLEAR_SUBPASS"),dt&&(xt.push("CLEAR_FROM_TEXTURE"),tt.activeTexture.set(Mt.TEXTURE0),dt.bind(Mt.LINEAR,Mt.CLAMP_TO_EDGE))):oe==="sdf"?xt.push("SDF_SUBPASS"):oe==="emissive"&&(xt.push("USE_MRT1"),tt.activeTexture.set(Mt.TEXTURE0),dt.bind(Mt.LINEAR,Mt.CLAMP_TO_EDGE)),Be&&xt.push("HAS_CENTROID"),Vt.shouldRenderCutoff&&xt.push("RENDER_CUTOFF");const ts=(ss,ps,Bs,Xt,Ft)=>{let cs=xt;ps.groundRadiusBuffer!=null&&(cs=xt.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const es=ps.programConfigurations.get(T.id),Es=h.isTileAffectedByFog(ss),Qs=h.getOrCreateProgram("fillExtrusionGroundEffect",{config:es,defines:cs,overrideFog:Es}),mr=kv(h,Xt,ge,re,Ft,[me,xe*Ft],Pe,Ce,$e,kt>=17?0:Ht*Ft,dt?dt.size[0]:0),Ks=[];Be&&Ks.push(ps.hiddenByLandmarkVertexBuffer),ps.groundRadiusBuffer!=null&&Ks.push(ps.groundRadiusBuffer),h.uploadCommonUniforms(tt,Qs,ss.toUnwrapped(),null,Vt),Qs.draw(h,tt.gl.TRIANGLES,F,z,H,Q,mr,T.id,ps.vertexBuffer,ps.indexBuffer,Bs,T.paint,kt,es,Ks)};for(const ss of D){const ps=x.getTile(ss),Bs=ps.getBucket(T);if(!Bs||Bs.projection.name!==vt.projection.name||!Bs.groundEffect||Bs.groundEffect&&!Bs.groundEffect.hasData())continue;const Xt=Bs.groundEffect,Ft=1/Bs.tileToMeter;{const cs=h.translatePosMatrix(ss.projMatrix,ps,pt,Pt),es=Xt.getDefaultSegment();ts(ss,Xt,es,cs,Ft)}if(Je)for(let cs=0;cs<4;cs++){const es=i.e9[cs](ss),Es=x.getTile(es);if(!Es)continue;const Qs=Es.getBucket(T);if(!Qs||Qs.projection.name!==vt.projection.name||!Qs.groundEffect||Qs.groundEffect&&!Qs.groundEffect.hasData())continue;const mr=Qs.groundEffect;let Ks,$s;cs===0?(Ks=[-i.al,0,0],$s=1):cs===1?(Ks=[i.al,0,0],$s=0):cs===2?(Ks=[0,-i.al,0],$s=3):(Ks=[0,i.al,0],$s=2);const Cr=mr.regionSegments[$s];if(!Cr)continue;const kr=new Float32Array(16);i.br(kr,ss.projMatrix,Ks),ts(ss,mr,Cr,h.translatePosMatrix(kr,ps,pt,Pt),Ft)}}}function Yce(M,h,x,T,D,F,z){T.centroidVertexArray.length===0&&T.createCentroidsBuffer();const H=F?F.findDEMTileFor(x):null;if(!(H&&H.dem||z))return;F&&H&&H.dem&&T.selfDEMTileTimestamp!==H.dem._timestamp&&(T.borderDoneWithNeighborZ=[-1,-1,-1,-1],T.selfDEMTileTimestamp=H.dem._timestamp);const Q=Be=>new i.P(Math.ceil((Be+i.ed)*i.ee),0),re=Be=>{const Je=h.getSource().minzoom,dt=Mt=>{const vt=h.getTileByID(Mt);if(vt&&vt.hasData())return vt.getBucket(D)},tt=[0,-1,1];for(const Mt of tt){if(Be.overscaledZ+Mt(oe[0]=Math.min(Be.min.y,Je.min.y),oe[1]=Math.max(Be.max.y,Je.max.y),oe[2]=i.al-Je.min.x>Be.max.x?Je.min.x-i.al:Be.max.x,oe),me=(Be,Je)=>(oe[0]=Math.min(Be.min.x,Je.min.x),oe[1]=Math.max(Be.max.x,Je.max.x),oe[2]=i.al-Je.min.y>Be.max.y?Je.min.y-i.al:Be.max.y,oe),xe=[(Be,Je)=>ge(Be,Je),(Be,Je)=>ge(Je,Be),(Be,Je)=>me(Be,Je),(Be,Je)=>me(Je,Be)],Pe=(Be,Je,dt,tt,Mt,vt,kt)=>{if(!F)return 0;const xt=[[vt?dt:Be,vt?Be:dt,0],[vt?dt:Je,vt?Je:dt,0]],pt=kt<0?i.al+kt:kt,Pt=[vt?pt:(Be+Je)/2,vt?(Be+Je)/2:pt,0];return dt===0&&kt<0||dt!==0&&kt>0?F.getForTilePoints(Mt,[Pt],!0,tt):xt.push(Pt),F.getForTilePoints(x,xt,!0,H),Math.max(xt[0][2],xt[1][2],Pt[2])/F.exaggeration()};for(let Be=0;Be<4;Be++){const Je=T.borderFeatureIndices[Be];if(Je.length===0)continue;const dt=i.e9[Be](x),tt=re(dt);if(!(tt&&tt instanceof i.ea))continue;const Mt=F?F.findDEMTileFor(dt):null;if(!(Mt&&Mt.dem||z)||(F&&Mt&&Mt.dem&&T.borderDEMTileTimestamp[Be]!==Mt.dem._timestamp&&(T.borderDoneWithNeighborZ[Be]=-1,T.borderDEMTileTimestamp[Be]=Mt.dem._timestamp),T.borderDoneWithNeighborZ[Be]===tt.canonical.z))continue;tt.centroidVertexArray.length===0&&tt.createCentroidsBuffer();const vt=(Be<2?1:5)-Be,kt=tt.borderDoneWithNeighborZ[vt]!==T.canonical.z,xt=tt.borderFeatureIndices[vt];let pt=0;if(T.canonical.z!==tt.canonical.z){for(const Pt of Je)T.showCentroid(T.featuresOnBorder[Pt]);if(kt)for(const Pt of xt)tt.showCentroid(tt.featuresOnBorder[Pt]);T.borderDoneWithNeighborZ[Be]=tt.canonical.z,tt.borderDoneWithNeighborZ[vt]=T.canonical.z}for(const Pt of Je){const Ht=T.featuresOnBorder[Pt],Vt=T.centroidData[Ht.centroidDataIndex],ts=Ht.borders[Be];let ss;for(;ptts[0]+3||ps[0]>ts[0]-3)break;tt.showCentroid(ss),pt++}if(ss&&ptts[1]-3)&&(Bs++,++pt!==xt.length);)ss=tt.featuresOnBorder[xt[pt]];ss=tt.featuresOnBorder[xt[ps]];let Xt=!1;if(Bs>=1){const es=ss.borders[vt];Math.abs(ts[0]-es[0])<3&&Math.abs(ts[1]-es[1])<3&&(Bs=1,Xt=!0,pt=ps+1)}else if(Bs===0){T.showCentroid(Ht);continue}const Ft=tt.centroidData[ss.centroidDataIndex];z&&Xt&&(((Ce=Vt).flags|($e=Ft).flags)&i.ec?(Ce.flags|=i.ec,$e.flags|=i.ec):(Ce.flags&=~i.ec,$e.flags&=~i.ec));const cs=Ht.intersectsCount()>1||ss.intersectsCount()>1;if(Bs>1)pt=ps,Vt.centroidXY=Ft.centroidXY=new i.P(0,0);else if(Mt&&Mt.dem&&!cs){const es=xe[Be](Vt,Ft),Es=Be%2?i.al-1:0,Qs=Pe(es[0],Math.min(i.al-1,es[1]),Es,Mt,dt,Be<2,es[2]);Vt.centroidXY=Ft.centroidXY=Q(Qs)}else cs?Vt.centroidXY=Ft.centroidXY=new i.P(0,0):(Vt.centroidXY=T.encodeBorderCentroid(Ht),Ft.centroidXY=tt.encodeBorderCentroid(ss));T.writeCentroidToBuffer(Vt),tt.writeCentroidToBuffer(Ft)}else T.showCentroid(Ht)}T.borderDoneWithNeighborZ[Be]=tt.canonical.z,tt.borderDoneWithNeighborZ[vt]=T.canonical.z}var Ce,$e;(T.needsCentroidUpdate||!T.centroidVertexBuffer&&T.centroidVertexArray.length!==0)&&T.uploadCentroid(M)}const Uu=[1,0,0],NT=[0,1,0],Qd=[0,0,1];function Vf(M,h,x){const T=x.transform,D=x.shadowRenderer;if(!D)return!0;const F=M.toUnwrapped(),z=T.tileSize*D._cascades[x.currentShadowCascade].scale;let H=h;if(T.elevation){const Ce=T.elevation.getMinMaxForTile(M);Ce&&(H+=Ce.max)}const Q=[...D.shadowDirection];Q[2]=-Q[2];const re=D.computeSimplifiedTileShadowVolume(F,H,z,Q);if(!re)return!1;const oe=[Uu,NT,Qd,Q,[Q[0],0,Q[2]],[0,Q[1],Q[2]]],ge=T.projection.name==="globe",me=T.scaleZoom(z),xe=i.cB.fromInvProjectionMatrix(T.invProjMatrix,T.worldSize,me,!ge),Pe=D.getCurrentCascadeFrustum();return xe.intersectsPrecise(re.vertices,re.planes,oe)===0||Pe.intersectsPrecise(re.vertices,re.planes,oe)===0}function wb(M){const{painter:h,source:x,layer:T,coords:D}=M;let F=M.defines;const z=h.context,H=h.renderPass==="shadow",Q=h.renderPass==="light-beam",re=h.shadowRenderer,oe=i.ef(h.transform.center.lat,h.transform.zoom),ge=tx(h,T.paint.get("building-cutoff-fade-range"));ge.shouldRenderCutoff&&(F=F.concat("RENDER_CUTOFF")),M.floodLightIntensity>0&&(F=F.concat("FLOOD_LIGHT"));for(const me of D){const xe=x.getTile(me),Pe=xe.getBucket(T);if(!Pe)continue;re&&re.getMaxCascadeForTile(me.toUnwrapped())===0&&(F=F.concat("SHADOWS_SINGLE_CASCADE"));const Ce=Pe.programConfigurations.get(T.id);let $e,Be,Je,dt=h.translatePosMatrix(me.expandedProjMatrix,xe,[0,0],"map");if(dt=i.cS(i.bC(),dt,[1,1,M.verticalScale]),H&&re){if(Vf(xe.tileID,Pe.maxHeight*oe,h))continue;let Mt=re.calculateShadowPassMatrixFromTile(xe.tileID.toUnwrapped());Mt=i.cS(i.bC(),Mt,[1,1,M.verticalScale]),Je=lx(Mt),$e=Be=h.getOrCreateProgram("buildingDepth",{config:Ce,defines:F,overrideFog:!1})}else if(Q)$e=Be=h.getOrCreateProgram("buildingBloom",{config:Ce,defines:F,overrideFog:!1}),Je=ND(dt);else{const Mt=h.transform.calculatePosMatrix(me.toUnwrapped(),h.transform.worldSize);i.cS(Mt,Mt,[1,1,M.verticalScale]);const vt=i.bC();i.cS(vt,Mt,[1,-1,1/oe]),i.bl(vt,vt),i.eg(vt,vt);const kt=h.transform.getFreeCameraOptions().position,xt=1<{if(Q){const kt=Mt.entranceBloom;vt.draw(h,z.gl.TRIANGLES,M.depthMode,dn.disabled,M.blendMode,nn.disabled,Je,T.id,kt.layoutVertexBuffer,kt.indexBuffer,kt.segmentsBucket,T.paint,h.transform.zoom,Ce,[kt.layoutAttenuationBuffer,kt.layoutColorBuffer])}else{const kt=Mt.segmentsBucket;let xt=[Mt.layoutNormalBuffer,Mt.layoutCentroidBuffer,Mt.layoutColorBuffer,Mt.layoutFloodLightDataBuffer];Mt.layoutFacadePaintBuffer&&(xt=xt.concat([Mt.layoutFacadeDataBuffer,Mt.layoutFacadeVerticalRangeBuffer,Mt.layoutFacadePaintBuffer])),vt.draw(h,z.gl.TRIANGLES,M.depthMode,dn.disabled,M.blendMode,H?nn.disabled:nn.backCW,Je,T.id,Mt.layoutVertexBuffer,Mt.indexBuffer,kt,T.paint,h.transform.zoom,Ce,xt)}};h.uploadCommonUniforms(z,Be,me.toUnwrapped(),null,ge),Pe.buildingWithoutFacade&&tt(Pe.buildingWithoutFacade,Be),Pe.buildingWithFacade&&($e!==Be&&h.uploadCommonUniforms(z,$e,me.toUnwrapped(),null,ge),tt(Pe.buildingWithFacade,$e))}}function KS(M,h,x,T,D,F,z,H,Q,re,oe,ge,me){const xe=M.context.gl,Pe=M.depthModeForSublayer(1,Pr.ReadOnly,xe.LEQUAL,!0),Ce=.1*(1-($e=oe))+3*$e;var $e;const Be=M._showOverdrawInspector,Je=ge,dt=new kT;Be||Uf(dt,M,h,x,T,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),nn.disabled,D,"sdf",F,z,H,Q,re,Ce,Je,!1);{const tt=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]);Uf(dt,M,h,x,T,Pe,tt,Mt,nn.disabled,D,"color",F,z,H,Q,re,Ce,Je,!1)}}function ZS(M){return[M[0]*i.eh,M[1]*i.eh,M[2]*i.eh,0]}function jb(M,h,x,T,D,F,z,H,Q){const re=T.getSource(),oe=x.globeSharedBuffers;if(!oe)return;let ge,me,xe;if(h&&(ge=T.getTile(h)),re instanceof i.aU?(me=re.texture,xe=i.dK(0,0,x.transform)):ge&&h&&(me=ge.texture,xe=i.dK(h.canonical.z,h.canonical.x,x.transform)),!me||!xe)return;M||(xe=i.cS(i.bC(),xe,[1,-1,1]));const Pe=x.context,Ce=Pe.gl,$e=D.paint.get("raster-resampling")==="nearest"?Ce.NEAREST:Ce.LINEAR,Be=x.colorModeForDrapableLayerRenderPass(F),Je=z.defines;Je.push("GLOBE_POLES");const dt=new Pr(Ce.LEQUAL,Pr.ReadWrite,x.depthRangeFor3D),tt=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),me.bind($e,Ce.CLAMP_TO_EDGE),Pe.activeTexture.set(Ce.TEXTURE1),me.bind($e,Ce.CLAMP_TO_EDGE),"useMipmap"in me&&Pe.extTextureFilterAnisotropic&&x.transform.pitch>20&&Ce.texParameterf(Ce.TEXTURE_2D,Pe.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,Pe.extTextureFilterAnisotropicMax);const[vt,kt,xt,pt]=h?oe.getPoleBuffers(h.canonical.z,!1):oe.getPoleBuffers(0,!0),Pt=D.paint.get("raster-elevation");let Ht;M?(Ht=vt,x.renderDefaultNorthPole=Pt!==0):(Ht=kt,x.renderDefaultSouthPole=Pt!==0);const Vt=ZS(z.mix),ts=((ps,Bs,Xt,Ft,cs,es,Es,Qs,mr,Ks,$s,Cr,kr)=>MD(ps,Bs,Xt,new Float32Array(16),new Float32Array(9),[0,0],Ft,[0,0],[0,0,0,0],1,{opacity:1,mix:0},es,[0,0],Qs,2,Ks,$s,Cr,1,0,kr))(tt,Mt,xe,i.aj(x.transform.zoom),0,D,0,Pt,0,Vt,z.offset,z.range,F),ss=x.getOrCreateProgram("raster",{defines:Je});x.uploadCommonUniforms(Pe,ss,null),ss.draw(x,Ce.TRIANGLES,dt,Q,Be,H,ts,D.id,Ht,xt,pt)}function DD(M){const h=M._nearZ,x=M.projection.farthestPixelDistance(M),T=x-h,D=.2*M.height,F=h+D;return[h,x,(F-D-h)/T,(F-h)/T]}function Hf(M,h,x,T){if(M)return h instanceof Xc&&M instanceof Jc?h.getTextureDescriptor(M,x,!0):{texture:M.texture,mix:ZS(T.mix),offset:T.offset,buffer:0,tileSize:1}}var Li=i.ei([{name:"a_index",type:"Int16",components:1}]);class YS{constructor(h,x,T,D){const F={width:T[0],height:T[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 T=this.context.gl,D=x.width*x.height;this.particleTexture0=new i.T(this.context,x,T.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new i.T(this.context,x,T.RGBA8,{premultiply:!1,useMipmap:!1});const F=new i.ej;F.reserve(D);for(let z=0;z0){const Vt=i.bj(x.canonical,Q),ts=i.el(Vt);me=i.aB(new Float32Array(16),Q.globeMatrix,ts),i.aB(me,Q.projMatrix,me)}const xe=i.bC();xe[12]+=2*D/(i.o.devicePixelRatio*Q.width),xe[13]+=2*F/(i.o.devicePixelRatio*Q.height),i.aB(me,xe,me);const Pe=M.getOrCreateProgram("debug",{defines:ge}),Ce=h.getTileByID(x.key);M.terrain&&M.terrain.setupElevationDraw(Ce,Pe);const $e=Pr.disabled,Be=dn.disabled,Je=M.colorModeForRenderPass(),dt="$debug";H.activeTexture.set(re.TEXTURE0),M.emptyTexture.bind(re.LINEAR,re.CLAMP_TO_EDGE),oe?Ce._makeGlobeTileDebugBuffers(M.context,Q):Ce._makeDebugTileBoundsBuffers(M.context,Q.projection);const tt=Ce._tileDebugBuffer||M.debugBuffer,Mt=Ce._tileDebugIndexBuffer||M.debugIndexBuffer,vt=Ce._tileDebugSegments||M.debugSegments;if(Pe.draw(M,re.LINE_STRIP,$e,Be,Je,nn.disabled,yb(me,T.toPremultipliedRenderColor(null)),dt,tt,Mt,vt,null,null,null,[Ce._globeTileDebugBorderBuffer]),z){const Vt=Ce.latestRawTileData,ts=Math.floor((Vt&&Vt.byteLength||0)/1024);let ss=x.canonical.toString();x.overscaledZ!==x.canonical.z&&(ss+=` => ${x.overscaledZ}`),ss+=` ${Ce.state}`,ss+=` ${ts}kb`,function(ps,Bs){ps.initDebugOverlayCanvas();const Xt=ps.debugOverlayCanvas,Ft=ps.context.gl,cs=ps.debugOverlayCanvas.getContext("2d");cs.clearRect(0,0,Xt.width,Xt.height),cs.shadowColor="white",cs.shadowBlur=2,cs.lineWidth=1.5,cs.strokeStyle="white",cs.textBaseline="top",cs.font="bold 36px Open Sans, sans-serif",cs.fillText(Bs,5,5),cs.strokeText(Bs,5,5),ps.debugOverlayTexture.update(Xt),ps.debugOverlayTexture.bind(Ft.LINEAR,Ft.CLAMP_TO_EDGE)}(M,ss)}const kt=h.getTile(x).tileSize,xt=512/Math.min(kt,512)*(x.overscaledZ/Q.zoom)*.5,pt=Ce._tileDebugTextBuffer||M.debugBuffer,Pt=Ce._tileDebugTextIndexBuffer||M.quadTriangleIndexBuffer,Ht=Ce._tileDebugTextSegments||M.debugSegments;Pe.draw(M,re.TRIANGLES,$e,Be,Dn.alphaBlended,nn.disabled,yb(me,i.ao.transparent.toPremultipliedRenderColor(null),xt),dt,pt,Pt,Ht,null,null,null,[Ce._globeTileDebugTextBuffer])}function Py(M,h,x,T){Gt(M,0,h+x/2,M.transform.width,x,T)}function bo(M,h,x,T){Gt(M,h-x/2,0,x,M.transform.height,T)}function Gt(M,h,x,T,D,F){const z=M.context,H=z.gl;H.enable(H.SCISSOR_TEST),H.scissor(h*i.o.devicePixelRatio,x*i.o.devicePixelRatio,T*i.o.devicePixelRatio,D*i.o.devicePixelRatio),z.clear({color:F}),H.disable(H.SCISSOR_TEST)}const BD=i.ei([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:XS}=BD;function Ip(M,h,x,T){M.emplaceBack(h,x,T)}class QS{constructor(h){this.vertexArray=new i.em,this.indices=new i.b0,Ip(this.vertexArray,-1,-1,1),Ip(this.vertexArray,1,-1,1),Ip(this.vertexArray,-1,1,1),Ip(this.vertexArray,1,1,1),Ip(this.vertexArray,-1,-1,-1),Ip(this.vertexArray,1,-1,-1),Ip(this.vertexArray,-1,1,-1),Ip(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,XS),this.indexBuffer=h.createIndexBuffer(this.indices),this.segment=i.bg.simpleSegment(0,0,36,12)}}function Iy(M,h,x,T,D,F){const z=M.context.gl,H=h.paint.get("sky-atmosphere-color"),Q=h.paint.get("sky-atmosphere-halo-color"),re=h.paint.get("sky-atmosphere-sun-intensity"),oe=((ge,me,xe,Pe,Ce)=>({u_matrix_3f:ge,u_sun_direction:me,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(),T),D,re,H.toPremultipliedRenderColor(null),Q.toPremultipliedRenderColor(null));z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+F,h.skyboxTexture,0),x.draw(M,z.TRIANGLES,Pr.disabled,dn.disabled,Dn.unblended,nn.frontCW,oe,"skyboxCapture",h.skyboxGeometry.vertexBuffer,h.skyboxGeometry.indexBuffer,h.skyboxGeometry.segment)}const $D=i.ei([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Cv{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 T=new i.b0;T.emplaceBack(0,1,2),T.emplaceBack(2,3,0),this.vertexBuffer=h.createVertexBuffer(x,$D.members),this.indexBuffer=h.createIndexBuffer(T),this.segments=i.bg.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Xce=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 Qce{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class qD{constructor(h){this.colorModeAlphaBlendedWriteRGB=new Dn([1,Tp,1,Tp],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 Qce,this.updateNeeded=!0}update(h){const x=h.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Cv(x);const T=this.params.sizeRange,D=this.params.intensityRange,F=function(oe){const ge=i.eq(30),me=[];for(let xe=0;xe{const xt=F.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];kt&&xt.push("ALPHA_PASS");const pt=h.getOrCreateProgram("globeAtmosphere",{defines:xt}),Pt=((Vt,ts,ss,ps,Bs,Xt,Ft,cs,es,Es,Qs,mr)=>({u_frustum_tl:Vt,u_frustum_tr:ts,u_frustum_br:ss,u_frustum_bl:ps,u_horizon:Bs,u_transition:Xt,u_fadeout_range:Ft,u_atmosphere_fog_color:cs.toArray01(),u_high_color:es.toArray01(),u_space_color:Es.toArray01(),u_temporal_offset:Qs,u_horizon_angle:mr}))(F.frustumCorners.TL,F.frustumCorners.TR,F.frustumCorners.BR,F.frustumCorners.BL,F.frustumCorners.horizon,H,$e,oe,me,Pe,Je,Mt);h.uploadCommonUniforms(T,pt);const Ht=this.atmosphereBuffer;Ht&&pt.draw(h,D.TRIANGLES,z,dn.disabled,kt?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,nn.backCW,Pt,kt?"atmosphere_glow_alpha":"atmosphere_glow",Ht.vertexBuffer,Ht.indexBuffer,Ht.segments)};vt(!1),vt(!0)}drawStars(h,x){const T=i.aA(x.properties.get("star-intensity"),0,1);if(T===0)return;const D=h.context,F=D.gl,z=h.transform,H=h.getOrCreateProgram("stars"),Q=i.c7([]);i.c9(Q,Q,-z._pitch),i.c8(Q,Q,-z.angle),i.c9(Q,Q,i.an(z._center.lat)),i.et(Q,Q,-i.an(z._center.lng));const re=i.cc(new Float32Array(16),Q),oe=i.aB([],z.starsProjMatrix,re),ge=i.eo([],re),me=i.eu([],ge),xe=[0,1,0];i.dQ(xe,xe,me),i.c5(xe,xe,this.params.sizeMultiplier);const Pe=[1,0,0];i.dQ(Pe,Pe,me),i.c5(Pe,Pe,this.params.sizeMultiplier);const Ce=($e=xe,Be=Pe,Je=T,{u_matrix:Float32Array.from(oe),u_up:$e,u_right:Be,u_intensity_multiplier:Je});var $e,Be,Je;h.uploadCommonUniforms(D,H),this.starsVx&&this.starsIdx&&H.draw(h,F.TRIANGLES,Pr.disabled,dn.disabled,this.colorModeAlphaBlendedWriteRGB,nn.disabled,Ce,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class JS{constructor(){this.visibleTiles=[]}updateBorders(h,x){const T=[],D=[],F=h._getRenderableCoordinates(!1,!0);for(const Q of F){const re=h.getTile(Q);if(!re.hasData())continue;const oe=re.getBucket(x);oe&&(oe.isEmpty()||(T.push(Q.key),D.push({bucket:oe,tileID:Q.canonical})))}let z=T.length!==this.visibleTiles.length;if(!z){T.sort();for(let Q=0;QQ.tileID.z-re.tileID.z||Q.tileID.x-re.tileID.x||Q.tileID.y-re.tileID.y);for(const Q of D){const re=new Array,oe=new Array,ge=Q.bucket;for(const me of ge.featuresOnBorder)H.has(me.featureId)?oe.push(me.footprintIndex):(H.add(me.featureId),re.push(me.footprintIndex));ge.updateFootprintHiddenFlags(re,i.ev,!1),ge.updateFootprintHiddenFlags(oe,i.ev,!0)}}}function eC(M,h){const x=[...M],T=h.cameraWorldSizeForFog/h.worldSize,D=i.bA([]);return i.cS(D,D,[T,T,1]),i.aB(x,D,x),i.aB(x,h.worldToFogMatrix,x),x}function tC(M,h,x,T,D){const F=x.material,z=T.context,{baseColorTexture:H,metallicRoughnessTexture:Q}=F.pbrMetallicRoughness,{normalTexture:re,occlusionTexture:oe,emissionTexture:ge}=F;function me(Pe,Ce,$e){if(Pe&&(M.push(Ce),z.activeTexture.set(z.gl.TEXTURE0+$e),Pe.gfxTexture)){const{minFilter:Be,magFilter:Je,wrapS:dt,wrapT:tt}=Pe.sampler;Pe.gfxTexture.bindExtraParam(Be,Je,dt,tt)}}me(H,"HAS_TEXTURE_u_baseColorTexture",xc.BaseColor),me(Q,"HAS_TEXTURE_u_metallicRoughnessTexture",xc.MetallicRoughness),me(re,"HAS_TEXTURE_u_normalTexture",xc.Normal),me(oe,"HAS_TEXTURE_u_occlusionTexture",xc.Occlusion),me(ge,"HAS_TEXTURE_u_emissionTexture",xc.Emission),D&&(D.texture||(D.texture=new i.d$(T.context,D.image,[D.image.height,D.image.height,D.image.height],z.gl.RGBA8)),z.activeTexture.set(z.gl.TEXTURE0+xc.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=T.shadowRenderer;xe&&(M.push("RENDER_SHADOWS","DEPTH_TEXTURE"),xe.useNormalOffset&&M.push("NORMAL_OFFSET"))}function sC(M,h,x,T,D,F){const z=M.modelOpacity,H=h.context,Q=new Pr(h.context.gl.LEQUAL,M.isLightMesh?Pr.ReadOnly:Pr.ReadWrite,h.depthRangeFor3D),re=h.transform,oe=M.mesh,ge=oe.material,me=ge.pbrMetallicRoughness,xe=h.style.fog;let Pe;Pe=h.transform.projection.zAxisUnit==="pixels"?[...M.nodeModelMatrix]:i.aB([],T.zScaleMatrix,M.nodeModelMatrix),i.aB(Pe,T.negCameraPosMatrix,Pe);const Ce=i.bl([],Pe);i.eg(Ce,Ce);const $e=x.paint.get("model-color-use-theme").constantOr("default")==="none",Be=x.paint.get("model-emissive-strength").constantOr(0),Je=My(new Float32Array(M.worldViewProjection),new Float32Array(Pe),new Float32Array(Ce),null,h,z,me.baseColorFactor,ge.emissiveFactor,me.metallicFactor,me.roughnessFactor,ge,Be,x,void 0,void 0,M.materialOverride,M.modelColor),dt={defines:[]},tt=[],Mt=h.shadowRenderer;Mt&&(Mt.useNormalOffset=!1),tC(dt.defines,tt,oe,h,$e?null:x.lut);let vt=null;if(xe){const pt=eC(M.nodeModelMatrix,h.transform);if(vt=new Float32Array(pt),re.projection.name!=="globe"){const Pt=oe.aabb.min,Ht=oe.aabb.max,[Vt,ts]=xe.getOpacityForBounds(pt,Pt[0],Pt[1],Ht[0],Ht[1]);dt.overrideFog=Vt>=xs||ts>=xs}}const kt=tx(h,x.paint.get("model-cutoff-fade-range"));kt.shouldRenderCutoff&&dt.defines.push("RENDER_CUTOFF");const xt=h.getOrCreateProgram("model",dt);h.uploadCommonUniforms(H,xt,null,vt,kt),h.renderPass!=="shadow"&&Mt&&Mt.setupShadowsFromMatrix(M.nodeModelMatrix,xt),xt.draw(h,H.gl.TRIANGLES,Q,D,F,oe.material.doubleSided?nn.disabled:nn.backCCW,Je,x.id,oe.vertexBuffer,oe.indexBuffer,oe.segments,x.paint,h.transform.zoom,void 0,tt)}function kb(M,h){return M.style._importedAsBasemap?"basemap":h.scope}function Ly(M,h,x,T,D,F,z,H,Q,re){const oe=M.transform,ge=!!h.isGeometryBloom&&h.isGeometryBloom;if(ge&&M.renderPass==="shadow")return;const me=oe.projection.name==="globe"?i.eD(x,oe):[...x];i.aB(me,me,h.globalMatrix);const xe=i.aB([],T,me);if(h.meshes)for(const Pe of h.meshes){const Ce=H.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:me,isLightMesh:ge,materialOverride:Ce,modelOpacity:Q,modelColor:re});continue}const $e=i.af([],Pe.centroid,xe);!oe.isOrthographic&&$e[2]<=0||F.push({mesh:Pe,depth:$e[2],modelIndex:D,worldViewProjection:xe,nodeModelMatrix:me,isLightMesh:ge,materialOverride:Ce,modelOpacity:Q,modelColor:re})}if(h.children)for(const Pe of h.children)Ly(M,Pe,x,T,D,F,z,H,Q,re)}function Wm(M,h,x,T){const D=x.shadowRenderer;if(!D)return;const F=D.getShadowPassDepthMode(),z=D.getShadowPassColorMode(),H=D.calculateShadowPassMatrixFromMatrix(h),Q=bT(H);x.getOrCreateProgram("modelDepth",{defines:x._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(x,x.context.gl.TRIANGLES,F,dn.disabled,z,nn.disabled,Q,T.id,M.vertexBuffer,M.indexBuffer,M.segments,T.paint,x.transform.zoom,void 0,void 0)}function UD(M,h,x,T,D,F){for(const z of D){const H=Object.assign({},T);H.part=z;const Q={type:"Unknown",id:h,properties:H},re={orientation:M.paint.get("model-rotation").evaluate(Q,x)};F.set(z,re)}}function VD(M,h,x,T,D,F){for(const z of D){const H=Object.assign({},T);H.part=z;const Q={type:"Unknown",id:h,properties:H},re={color:M.paint.get("model-color").evaluate(Q,x),colorMix:M.paint.get("model-color-mix-intensity").evaluate(Q,x),opacity:M.paint.get("model-opacity").evaluate(Q,x),emissionStrength:M.paint.get("model-emissive-strength").evaluate(Q,x)};F.set(z,re)}}function HD(M,h,x,T,D){let F=!1;for(const H of T)H.modelOpacity!==1&&(sC(H,M,h,D[H.modelIndex],dn.disabled,Dn.disabled),F=!0);for(const H of T)sC(H,M,h,D[H.modelIndex],H.modelOpacity!==1?M.stencilModeFor3D():dn.disabled,M.colorModeForRenderPass());F&&M.resetStencilClippingMasks();const z=Dn.additive;for(const H of x)sC(H,M,h,D[H.modelIndex],dn.disabled,H.isLightMesh?z:M.colorModeForRenderPass())}function WD(M,h,x){const T=h.updateZoomBasedPaintProperties(),D=function(F,z,H){let Q,re,oe,ge=F.terrain?F.terrain.exaggeration():0;if(F.terrain&&ge>0){const me=F.terrain,xe=me.findDEMTileFor(H);xe&&xe.dem?Q=i.eF.create(me,H,xe):ge=0}if(ge===0&&(z.terrainElevationMin=0,z.terrainElevationMax=0),ge===z.validForExaggeration&&(ge===0||Q&&Q._demTile&&Q._demTile.tileID===z.validForDEMTile.id&&Q._dem._timestamp===z.validForDEMTile.timestamp))return!1;for(const me in z.instancesPerModel){const xe=z.instancesPerModel[me];for(let Pe=0;Pere&&(re=xe.max)}const oe=i.aA(T.x,F,z)-T.x,ge=i.aA(T.y,H,Q)-T.y,me=i.cf(re,h.center.lat)-T.z;return h._zoomFromMercatorZ(Math.sqrt(oe*oe+ge*ge+me*me))}function GD(M,h,x,T,D,F,z){const H=M.context,Q=M.renderPass==="shadow",re=M.shadowRenderer,oe=Q&&re?re.getShadowPassDepthMode():new Pr(H.gl.LEQUAL,Pr.ReadWrite,M.depthRangeFor3D),ge=M.isTileAffectedByFog(F),me=M.transform.projection.name==="globe";if(x.meshes)for(const xe of x.meshes){const Pe=me?[]:["MODEL_POSITION_ON_GPU"],Ce=[];let $e,Be,Je;const dt=!me&&T.instancedDataArray.length>20;dt&&Pe.push("INSTANCED_ARRAYS");const tt=tx(M,h.paint.get("model-cutoff-fade-range"));if(tt.shouldRenderCutoff&&Pe.push("RENDER_CUTOFF"),Q&&re)$e=M.getOrCreateProgram("modelDepth",{defines:Pe}),Be=bT(z.shadowTileMatrix,z.shadowTileMatrix,Float32Array.from(x.globalMatrix)),Je=re.getShadowPassColorMode();else{tC(Pe,Ce,xe,M,h.paint.get("model-color-use-theme").constantOr("default")==="none"?null:h.lut),$e=M.getOrCreateProgram("model",{defines:Pe,overrideFog:ge});const vt=xe.material,kt=vt.pbrMetallicRoughness,xt=h.paint.get("model-opacity").constantOr(1),pt=h.paint.get("model-emissive-strength").constantOr(0);Be=My(F.expandedProjMatrix,Float32Array.from(x.globalMatrix),new Float32Array(16),null,M,xt,kt.baseColorFactor,vt.emissiveFactor,kt.metallicFactor,kt.roughnessFactor,vt,pt,h,D),re&&(z.shadowUniformsInitialized?$e.setShadowUniformValues(H,re.getShadowUniformValues()):(re.setupShadows(F.toUnwrapped(),$e,"model-tile"),z.shadowUniformsInitialized=!0)),Je=tt.shouldRenderCutoff||xt<1||vt.alphaMode!=="OPAQUE"?Dn.alphaBlended:Dn.unblended}M.uploadCommonUniforms(H,$e,F.toUnwrapped(),null,tt);const Mt=xe.material.doubleSided?nn.disabled:nn.backCCW;if(dt)Ce.push(T.instancedDataBuffer),$e.draw(M,H.gl.TRIANGLES,oe,dn.disabled,Je,Mt,Be,h.id,xe.vertexBuffer,xe.indexBuffer,xe.segments,h.paint,M.transform.zoom,void 0,Ce,T.instancedDataArray.length);else{const vt=Q?"u_instance":"u_normal_matrix";for(let kt=0;ktQ[1]?z:Q,F[0]=x.max[0],z=i.aC(i.eG(),F,D),H=z[1]Q[1]?z:Q,F[1]=x.min[1],z=i.aC(i.eG(),F,D),H=z[1]Q[1]?z:Q;const re=i.aA(T[0],0,1),oe=100*h.pixelsPerMeter*i.aA(T[1],0,1),ge=i.aA(T[2],0,1),me=i.eH(i.eG(),H,Q,re),xe=Math.tan(.5*h.fovX),Pe=-me[2]*xe;if(oe===0)return me[1]<-Math.abs(Pe)?ge:1;const Ce=(-Math.abs(Pe)-me[1])/oe,$e=(Je,dt,tt)=>(1-tt)*Je+tt*dt,Be=i.aA($e(1,ge,Ce),ge,1);return $e(1,Be,i.aA((h.pitch-20)/20,0,1))}class KD{}class ux{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(h,x,T){{const ge=this._storage.get(x.id);if(ge)return ge.lastUsedFrameIdx=h,ge.buf}const D=T.gl,F=D.getBufferParameter(D.ELEMENT_ARRAY_BUFFER,D.BUFFER_SIZE),z=new ArrayBuffer(F),H=new Int16Array(z);D.getBufferSubData(D.ELEMENT_ARRAY_BUFFER,0,new Int16Array(z));const Q=new i.eJ;for(let ge=0;ge30&&(T.buf.destroy(),this._storage.delete(x))}destroy(){for(const[h,x]of this._storage)x.buf.destroy(),this._storage.delete(h)}}class Mv{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const Tv=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 Wf{constructor(h){this.revealStart=11,this.revealRange=2}}const CT=i.ei([{type:"Float32",name:"a_pos_2f",components:2}]);class MT{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(h,x){const T=h.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const z=new i.eK,H=new i.b0;z.emplaceBack(-1,-1),z.emplaceBack(1,-1),z.emplaceBack(1,1),z.emplaceBack(-1,1),H.emplaceBack(0,1,2),H.emplaceBack(0,2,3),this.vignetteVx=h.context.createVertexBuffer(z,CT.members),this.vignetteIdx=h.context.createIndexBuffer(H)}const D=i.bg.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){h.uploadCommonUniforms(h.context,T);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};T.draw(h,h.context.gl.TRIANGLES,Pr.disabled,dn.disabled,Dn.alphaBlended,nn.disabled,z,"vignette",this.vignetteVx,this.vignetteIdx,D)}var F}}class TT{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(h,x){const T=h.getFreeCameraOptions().position,D=T.toAltitude(),F=T.toLngLat(),z=i.an(F.lng),H=i.an(F.lat),Q=h.pixelsPerMeter/x,re=z*i.eM,oe=i.eM*Math.log(Math.tan(Math.PI/4+H/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,me=-this._elevationPrev+D;this._accumulatedOffsetX+=(-this._offsetXPrev+re)*Q,this._accumulatedOffsetY+=ge*Q,this._accumulatedElevation+=me*Q,this._offsetXPrev=re,this._offsetYPrev=oe,this._elevationPrev=D}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function rC(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 gh(M){const h=i.eq(1323123451230),x=[];for(let T=0;T 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 T=gh(this.particlesCount),D=new i.eN,F=new i.b0;let z=0;const H=i.eq(1323123451230);for(let Q=0;QT)return;const D=ku(0,1,x.revealStart,x.revealStart+x.revealRange,T);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 H=structuredClone(this._vignetteParams);H.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,H.strength=1,H.color=structuredClone(h.style.rain.state.vignetteColor));const Q=this.updateOnRender(h,F.timeFactor),re=h.context,oe=re.gl,ge=h.transform;this.screenTexture&&this.screenTexture.size[0]===h.width&&this.screenTexture.size[1]===h.height||(this.screenTexture=new i.T(re,{width:h.width,height:h.height,data:null},oe.RGBA8)),F.distortionStrength>0&&(re.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 me=h.getOrCreateProgram("rainParticle");h.uploadCommonUniforms(re,me),re.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,$e)=>{const Be=rC(this._movement.getPosition(),Ce),Je=F.dropletSizeX,dt=F.dropletSizeX*F.dropletSizeYScale,tt=h.width/2,Mt=h.height/2,vt=ku(0,F.screenThinning.start,0,1,F.screenThinning.intensity),kt=ku(.001,F.screenThinning.range,0,1,F.screenThinning.intensity),xt=ku(0,F.screenThinning.particleOffset,0,1,F.screenThinning.intensity),pt=(Pt={modelview:Q.modelviewMatrix,projection:Q.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Be,velocityConeAperture:F.velocityConeAperture,velocity:F.velocity,boxSize:Ce,rainDropletSize:[Je,dt],distortionStrength:F.distortionStrength,rainDirection:z,color:xe,screenSize:[ge.width,ge.height],thinningCenterPos:[tt,Mt],thinningShape:[vt,kt,Math.pow(10,F.screenThinning.fadePower)],thinningAffectedRatio:F.screenThinning.affectedRatio,thinningParticleOffset:xt,shapeDirectionalPower:F.shapeDirPower,shapeNormalPower:F.shapeNormalPower,mode:$e?0:1},{u_modelview:Float32Array.from(Pt.modelview),u_projection:Float32Array.from(Pt.projection),u_time:Pt.time,u_cam_pos:Pt.camPos,u_texScreen:0,u_velocityConeAperture:Pt.velocityConeAperture,u_velocity:Pt.velocity,u_boxSize:Pt.boxSize,u_rainDropletSize:Pt.rainDropletSize,u_distortionStrength:Pt.distortionStrength,u_rainDirection:Pt.rainDirection,u_color:Pt.color,u_screenSize:Pt.screenSize,u_thinningCenterPos:Pt.thinningCenterPos,u_thinningShape:Pt.thinningShape,u_thinningAffectedRatio:Pt.thinningAffectedRatio,u_thinningParticleOffset:Pt.thinningParticleOffset,u_shapeDirectionalPower:Pt.shapeDirectionalPower,u_shapeNormalPower:Pt.shapeNormalPower,u_mode:Pt.mode});var Pt;const Ht=Math.round(F.intensity*this.particlesCount),Vt=i.bg.simpleSegment(0,0,4*Ht,2*Ht);me.draw(h,oe.TRIANGLES,Pr.disabled,dn.disabled,Dn.alphaBlended,nn.disabled,pt,"rain_particles",this.particlesVx,this.particlesIdx,Vt)};F.distortionStrength>0&&Pe(F.boxSize,!0),Pe(F.boxSize,!1),this._vignette.draw(h,H)}}const AT=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 ET extends Dy{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 Wf("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 T=gh(this.particlesCount),D=new i.eO,F=new i.b0;let z=0;const H=i.eq(1323123451230);for(let Q=0;Qz)return;const H=ku(0,1,F.revealStart,F.revealStart+F.revealRange,z);D.strength*=H,x.overrideStyleParameters||(x.intensity=h.style.snow.state.density,x.timeFactor=h.style.snow.state.intensity,x.color=structuredClone(h.style.snow.state.color),T=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 Q=this.updateOnRender(h,x.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const re=h.context,oe=re.gl,ge=h.transform,me=h.getOrCreateProgram("snowParticle");h.uploadCommonUniforms(re,me),((xe,Pe,Ce)=>{const $e=rC(this._movement.getPosition(),xe),Be=ge.width/2,Je=ge.height/2,dt=ku(0,Ce.screenThinning.start,0,1,Ce.screenThinning.intensity),tt=ku(.001,Ce.screenThinning.range,0,1,Ce.screenThinning.intensity),Mt=ku(0,Ce.screenThinning.particleOffset,0,1,Ce.screenThinning.intensity),vt=(kt={modelview:Q.modelviewMatrix,projection:Q.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:$e,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,Je],thinningShape:[dt,tt,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:T},{u_modelview:Float32Array.from(kt.modelview),u_projection:Float32Array.from(kt.projection),u_time:kt.time,u_cam_pos:kt.camPos,u_velocityConeAperture:kt.velocityConeAperture,u_velocity:kt.velocity,u_horizontalOscillationRadius:kt.horizontalOscillationRadius,u_horizontalOscillationRate:kt.horizontalOscillationRate,u_boxSize:kt.boxSize,u_billboardSize:kt.billboardSize,u_simpleShapeParameters:kt.simpleShapeParameters,u_screenSize:kt.screenSize,u_thinningCenterPos:kt.thinningCenterPos,u_thinningShape:kt.thinningShape,u_thinningAffectedRatio:kt.thinningAffectedRatio,u_thinningParticleOffset:kt.thinningParticleOffset,u_particleColor:kt.color,u_direction:kt.direction});var kt;const xt=Math.round(Ce.intensity*this.particlesCount),pt=i.bg.simpleSegment(0,0,4*xt,2*xt);this.particlesVx&&this.particlesIdx&&me.draw(h,oe.TRIANGLES,Pr.disabled,dn.disabled,Dn.alphaBlended,nn.disabled,vt,"snow_particles",this.particlesVx,this.particlesIdx,pt)})(x.boxSize,0,x),this._vignette.draw(h,D)}}const hx={symbol:function(M,h,x,T,D){if(M.renderPass!=="translucent")return;const F=dn.disabled,z=M.colorModeForRenderPass(),H=x.layout.get("text-variable-anchor"),Q=x.layout.get("text-size-scale-range"),re=i.aA(M.scaleFactor,Q[0],Q[1]);H&&function(me,xe,Pe,Ce,$e,Be,Je,dt){const tt=xe.transform,Mt=$e==="map",vt=Be==="map";for(const kt of me){const xt=Ce.getTile(kt),pt=xt.getBucket(Pe);if(!pt||!pt.text||!pt.text.segments.get().length)continue;const Pt=i.bK(pt.textSizeData,tt.zoom,dt),Ht=tm(kt,pt.getProjection(),tt),Vt=tt.calculatePixelsToTileUnitsMatrix(xt),ts=Ws(Ht,xt.tileID.canonical,vt,Mt,tt,pt.getProjection(),Vt),ss=pt.hasIconTextFit()&&pt.hasIconData();Pt&&Zr(pt,Mt,vt,Je,tt,ts,kt,Math.pow(2,tt.zoom-xt.tileID.overscaledZ),Pt,ss)}}(T,M,x,h,x.layout.get("text-rotation-alignment"),x.layout.get("text-pitch-alignment"),D,re);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)?bb(M,h,x,T,F,z):(oe&&bb(M,h,x,T,F,z,{onlyIcons:!0}),ge&&bb(M,h,x,T,F,z,{onlyText:!0})),h.map.showCollisionBoxes&&(_r(M,h,x,T,x.paint.get("text-translate"),x.paint.get("text-translate-anchor"),!0),_r(M,h,x,T,x.paint.get("icon-translate"),x.paint.get("icon-translate-anchor"),!1))},circle:function(M,h,x,T){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"),H=x.layout.get("circle-sort-key").constantOr(1)!==void 0,Q=x.paint.get("circle-emissive-strength");if(D.constantOr(1)===0&&(F.constantOr(1)===0||z.constantOr(1)===0))return;const re=M.context,oe=re.gl,ge=M.transform,me=!(!M.terrain||!M.terrain.enabled),xe=x.layout.get("circle-elevation-reference"),Pe=M.depthModeForSublayer(0,Pr.ReadOnly),Ce=new Pr(M.context.gl.LEQUAL,Pr.ReadOnly,M.depthRangeFor3D),$e=xe==="none"||me?Pe:Ce,Be=dn.disabled,Je=M.colorModeForDrapableLayerRenderPass(Q),dt=ge.projection.name==="globe",tt=[i.aF(ge.center.lng),i.aJ(ge.center.lat)],Mt=[];for(let kt=0;ktkt.sortKey-xt.sortKey);const vt={useDepthForOcclusion:ge.depthOcclusionForSymbolsAndCircles};for(const kt of Mt){const{programConfiguration:xt,program:pt,layoutVertexBuffer:Pt,dynamicBuffers:Ht,indexBuffer:Vt,uniformValues:ts,tile:ss}=kt.state,ps=kt.segments;M.terrain&&M.terrain.setupElevationDraw(ss,pt,vt),M.uploadCommonUniforms(re,pt,ss.tileID.toUnwrapped()),pt.draw(M,oe.TRIANGLES,$e,Be,Je,nn.disabled,ts,x.id,Pt,Vt,ps,x.paint,ge.zoom,xt,Ht)}},heatmap:function(M,h,x,T){if(x.paint.get("heatmap-opacity")!==0)if(M.renderPass==="offscreen"){const D=M.context,F=D.gl,z=dn.disabled,H=new Dn([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!0,!0,!0,!0]);(function(xe,Pe,Ce,$e){const Be=xe.gl,Je=Pe.width*$e,dt=Pe.height*$e;xe.activeTexture.set(Be.TEXTURE1),xe.viewport.set([0,0,Je,dt]);let tt=Ce.heatmapFbo;if(!tt||tt&&(tt.width!==Je||tt.height!==dt)){tt&&tt.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),tt=Ce.heatmapFbo=xe.createFramebuffer(Je,dt,1,null),function(vt,kt,xt,pt,Pt,Ht){const Vt=vt.gl;Vt.texImage2D(Vt.TEXTURE_2D,0,vt.extRenderToTextureHalfFloat?Vt.RGBA16F:Vt.RGBA,Pt,Ht,0,Vt.RGBA,vt.extRenderToTextureHalfFloat?Vt.HALF_FLOAT:Vt.UNSIGNED_BYTE,null),pt.colorAttachment0.set(xt)}(xe,0,Mt,tt,Je,dt)}else Be.bindTexture(Be.TEXTURE_2D,tt.colorAttachment0.get()),xe.bindFramebuffer.set(tt.framebuffer)})(D,M,x,M.transform.projection.name==="globe"?.5:.25),D.clear({color:i.ao.transparent});const Q=M.transform,re=Q.projection.name==="globe",oe=re?["PROJECTION_GLOBE_VIEW"]:[],ge=re?nn.frontCCW:nn.disabled,me=[i.aF(Q.center.lng),i.aJ(Q.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,T){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(),H=x.paint.get("line-emissive-strength").constantOr(0),Q=x.paint.get("line-occlusion-opacity"),re=x.layout.get("line-elevation-reference"),oe=x.layout.get("line-width-unit")==="meters",ge=re==="sea",me=!(!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"),$e=Ce!==void 0,Be=Ce<1,Je=M.colorModeForDrapableLayerRenderPass(z?H:null),dt=M.terrain&&M.terrain.renderingToTexture,tt=dt?1:i.o.devicePixelRatio,Mt=x.paint.get("line-dasharray"),vt=Mt.constantOr(1),kt=x.layout.get("line-cap"),xt=Mt.constantOr(null),pt=kt.constantOr(null),Pt=x.paint.get("line-pattern"),Ht=Pt.constantOr(1),Vt=x.paint.get("line-pattern-cross-fade"),ts=Pt.constantOr(null),ss=x.paint.get("line-opacity").constantOr(1);let ps=!Ht&&ss!==1||M.depthOcclusion&&Q>0&&Q<1;const Bs=x.paint.get("line-gradient"),Xt=Ht?"linePattern":"line",Ft=i.e2(x);let cs;if(dt&&M.terrain&&M.terrain.clipOrMaskOverlapStencilType()&&(ps=!1),Q!==0&&M.depthOcclusion){const mr=x.paint._values["line-opacity"];mr&&mr.value&&mr.value.kind==="constant"?cs=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&&Ft.push("VARIABLE_LINE_WIDTH"),dt&&(M.emissiveMode!=="dual-source-blending"||z?M.emissiveMode==="mrt-fallback"&&Ft.push("USE_MRT1"):Ft.push("DUAL_SOURCE_BLENDING"));const es=(mr,Ks,$s,Cr,kr,or)=>{for(const fr of mr){const qr=h.getTile(fr);if(Ht&&!qr.patternsLoaded())continue;const jn=qr.getBucket(x);if(!jn||jn.elevationType!=="none"&&!kr||jn.elevationType==="none"&&kr)continue;M.prepareDrawTile();const ha=[...Ks],Wa=M.shadowRenderer,Er=jn.elevationType==="road"&&!!Wa&&Wa.enabled;let Ra=[0,0,0];if(Er){const zn=M.style.directionalLight,zi=M.style.ambientLight;zn&&zi&&(Ra=Bf(M.style,zn,zi)),ha.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const vn=jn.programConfigurations.get(x.id);let Qa=!1;if(ts&&qr.imageAtlas){const zn=i.e3.from(ts),zi=zn.getPrimary().scaleSelf(tt).toString(),To=qr.imageAtlas.patternPositions.get(zi),ho=zn.getSecondary(),wi=ho?qr.imageAtlas.patternPositions.get(ho.scaleSelf(tt).toString()):null;Qa=!!To&&!!wi,To&&vn.setConstantPatternPositions(To,wi)}Vt>0&&(Qa||vn.getPatternTransitionVertexBuffer("line-pattern"))&&ha.push("LINE_PATTERN_TRANSITION");const pi=M.isTileAffectedByFog(fr),oi=M.getOrCreateProgram(Xt,{config:vn,defines:ha,overrideFog:pi});if(!Ht&&xt&&pt&&qr.lineAtlas){const zn=qr.lineAtlas.getDash(xt,pt);zn&&vn.setConstantPatternPositions(zn)}Er&&Wa.setupShadows(qr.tileID.toUnwrapped(),oi,"vector-tile");let[La,Fn]=x.paint.get("line-trim-offset");(pt==="round"||pt==="square")&&La!==Fn&&(La===0&&(La-=1),Fn===1&&(Fn+=1));const Ya=dt?fr.projMatrix:null,fo=oe?1/jn.tileToMeter/i.ay(qr,1,M.transform.zoom):1,Hi=oe?1/jn.tileToMeter/i.ay(qr,1,Math.floor(M.transform.zoom)):1,Ja=Ht?i.e4(M,qr,x,Ya,tt,fo,Hi,[La,Fn],Ra,Vt):i.e5(M,qr,x,Ya,jn.lineClipsArray.length,tt,fo,Hi,[La,Fn],Ra);if(Bs){const zn=jn.gradients[x.id];let zi=zn.texture;if(x.gradientVersion!==zn.version){let To=256;if(x.stepInterpolant){const ho=h.getSource().maxzoom,wi=fr.canonical.z===ho?Math.ceil(1<{cs!=null&&(cs.value=ss*Q),oi.draw(M,Pe.TRIANGLES,$s,zn,Je,nn.disabled,Ja,x.id,jn.layoutVertexBuffer,jn.indexBuffer,jn.segments,x.paint,M.transform.zoom,vn,[jn.layoutVertexBuffer2,jn.patternVertexBuffer,jn.zOffsetVertexBuffer]),cs!=null&&(cs.value=ss)};if(ps&&!kr){const zn=M.stencilModeForClipping(fr).ref;zn===0&&dt&&xe.clear({stencil:0});const zi={func:Pe.EQUAL,mask:255};Ja.u_alpha_discard_threshold=.8,Na(new dn(zi,zn,255,Pe.KEEP,Pe.KEEP,Pe.INVERT)),Ja.u_alpha_discard_threshold=0,Na(new dn(zi,zn,255,Pe.KEEP,Pe.KEEP,Pe.KEEP))}else Ja.u_alpha_discard_threshold=ps&&kr&&or?.8:0,Na(kr?Cr:M.stencilModeForClipping(fr))}};let Es=M.depthModeForSublayer(0,Pr.ReadOnly);const Qs=new Pr(M.depthOcclusion?Pe.GREATER:Pe.LEQUAL,Pr.ReadOnly,M.depthRangeFor3D);if(x.hasNonElevatedBuckets){const mr=!dt&&M.terrain;Q!==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}.`):es(T,Ft,Es,dn.disabled,!1,!0)}if(x.hasElevatedBuckets){re==="hd-road-markup"?me||(Es=Qs,Ft.push("ELEVATED_ROADS")):(Ft.push("ELEVATED"),Es=Qs,$e&&Ft.push(Be?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),ge&&Ft.push("ELEVATION_REFERENCE_SEA"));const mr=ps?M.stencilModeFor3D():dn.disabled;M.forceTerrainMode=!0,es(T,Ft,Es,mr,!0,!0),ps&&es(T,Ft,Es,mr,!0,!1),M.forceTerrainMode=!1}ps&&(M.resetStencilClippingMasks(),dt&&xe.clear({stencil:0})),Q===0||M.depthOcclusion||dt||M.layersWithOcclusionOpacity.push(M.currentLayer)},fill:function(M,h,x,T){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"),H=M.colorModeForDrapableLayerRenderPass(z),Q=x.paint.get("fill-pattern"),re=M.opaquePassEnabledForLayer()&&!Q.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),me={painter:M,sourceCache:h,layer:x,coords:T,colorMode:H,elevationType:oe,terrainEnabled:ge,pass:re};if(M.renderPass==="shadow")return void(M.shadowRenderer&&oe==="road"&&!ge&&function(Pe){const{painter:Ce,sourceCache:$e,layer:Be,coords:Je}=Pe,dt=Ce.context.gl,tt=Pe.painter.shadowRenderer;for(const Mt of Je){const vt=$e.getTile(Mt),kt=vt.getBucket(Be);if(!kt)continue;const xt=kt.elevatedStructures;if(!xt||!xt.shadowCasterSegments||xt.shadowCasterSegments.segments[0].primitiveLength===0)continue;Ce.prepareDrawTile();const pt=kt.bufferData.programConfigurations.get(Be.id),Pt=Ce.isTileAffectedByFog(Mt),Ht=Ce.getOrCreateProgram("elevatedStructuresDepth",{config:pt,overrideFog:Pt}),Vt=tt.calculateShadowPassMatrixFromTile(vt.tileID.toUnwrapped());Ce.uploadCommonUniforms(Ce.context,Ht,Mt.toUnwrapped());const ts={u_matrix:Vt,u_depth_bias:0};Ht.draw(Ce,dt.TRIANGLES,tt.getShadowPassDepthMode(),dn.disabled,tt.getShadowPassColorMode(),nn.disabled,ts,Be.id,xt.vertexBuffer,xt.indexBuffer,xt.shadowCasterSegments,Be.paint,Ce.transform.zoom,pt)}}(me));const xe=M.emissiveMode==="mrt-fallback";if(oe!=="offset"){if(WS(me,!1,xe),oe==="road"){const Pe=!ge&&M.renderPass==="translucent";Pe&&HS(M,h,x,T,"geometry"),WS(me,!0,xe,dn.disabled),Pe&&function(Ce){const{painter:$e,sourceCache:Be,layer:Je,coords:dt,colorMode:tt}=Ce,Mt=$e.context.gl,vt=Ce.painter.shadowRenderer,kt=!!vt&&vt.enabled,xt=new Pr($e.context.gl.LEQUAL,Pr.ReadOnly,$e.depthRangeFor3D);let pt=[0,0,0];if(kt){const Ht=$e.style.directionalLight,Vt=$e.style.ambientLight;Ht&&Vt&&(pt=Bf($e.style,Ht,Vt))}const Pt=Ht=>{for(const Vt of dt){const ts=Be.getTile(Vt),ss=ts.getBucket(Je);if(!ss)continue;const ps=ss.elevatedStructures;if(!ps)continue;let Bs,Xt;if(Ht?(Bs=ps.renderableBridgeSegments,Xt=ps.bridgeProgramConfigurations.get(Je.id)):(Bs=ps.renderableTunnelSegments,Xt=ps.tunnelProgramConfigurations.get(Je.id)),!Bs||Bs.segments[0].primitiveLength===0)continue;Xt.updatePaintBuffers(),$e.prepareDrawTile();const Ft=$e.isTileAffectedByFog(Vt),cs=[];kt&&cs.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const es=$e.getOrCreateProgram("elevatedStructures",{config:Xt,overrideFog:Ft,defines:cs}),Es=$e.translatePosMatrix(Vt.projMatrix,ts,Je.paint.get("fill-translate"),Je.paint.get("fill-translate-anchor"));kt&&vt.setupShadows(ts.tileID.toUnwrapped(),es,"vector-tile");const Qs=ox(Es,pt);$e.uploadCommonUniforms($e.context,es,Vt.toUnwrapped()),es.draw($e,Mt.TRIANGLES,xt,dn.disabled,tt,nn.backCCW,Qs,Je.id,ps.vertexBuffer,ps.indexBuffer,Bs,Je.paint,$e.transform.zoom,Xt,[ps.vertexBufferNormal])}};Pt(!0),Pt(!1)}(me)}}else WS(me,!1,xe,M.stencilModeFor3D())},"fill-extrusion":function(M,h,x,T){const D=x.paint.get("fill-extrusion-opacity"),F=M.context,z=F.gl,H=M.terrain,Q=H&&H.renderingToTexture;if(D===0)return;const re=M.emissiveMode==="mrt-fallback",oe=M.conflationActive&&M.style.isLayerClipped(x,h.getSource()),ge=M.style.order.indexOf(x.fqid);if(oe&&function(me,xe,Pe,Ce,$e){for(const Be of Ce){const Je=xe.getTile(Be).getBucket(Pe);Je&&(Je.updateReplacement(Be,me.replacementSource,$e),Je.uploadCentroid(me.context))}}(M,h,x,T,ge),H||oe)for(const me of T){const xe=h.getTile(me).getBucket(x);xe&&Yce(M.context,h,me,xe,x,H,oe)}if(M.renderPass==="shadow"&&M.shadowRenderer){const me=M.shadowRenderer;if(H&&D<.65&&x._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof i.ad)return;const xe=me.getShadowPassDepthMode(),Pe=me.getShadowPassColorMode();GS(M,h,x,T,xe,dn.disabled,Pe,oe)}else if(M.renderPass==="translucent"){const me=!x.paint.get("fill-extrusion-pattern").constantOr(1),xe=x.paint.get("fill-extrusion-color").constantOr(i.ao.white);if(!Q&&xe.a!==0){const Pe=new Pr(M.context.gl.LEQUAL,Pr.ReadWrite,M.depthRangeFor3D);D===1&&me?GS(M,h,x,T,Pe,dn.disabled,Dn.unblended,oe):(GS(M,h,x,T,Pe,dn.disabled,Dn.disabled,oe),GS(M,h,x,T,Pe,M.stencilModeFor3D(),M.colorModeForRenderPass(),oe),M.resetStencilClippingMasks())}if(M.style.enable3dLights()&&me&&(!H&&M.transform.projection.name!=="globe"||Q)){const Pe=x.paint.get("fill-extrusion-opacity"),Ce=x.paint.get("fill-extrusion-ambient-occlusion-intensity"),$e=x.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),Be=x.paint.get("fill-extrusion-flood-light-intensity"),Je=x.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",dt=x.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Je?null:x.lut).toArray01().slice(0,3),tt=Ce>0&&$e>0,Mt=Be>0,vt=(pt,Pt,Ht)=>(1-Ht)*pt+Ht*Pt,kt=new kT;kt.translate=x.paint.get("fill-extrusion-translate"),kt.translateAnchor=x.paint.get("fill-extrusion-translate-anchor"),kt.edgeRadius=x.layout.get("fill-extrusion-edge-radius"),kt.cutoffFadeRange=x.paint.get("fill-extrusion-cutoff-fade-range");const xt=pt=>{const Pt=M.depthModeForSublayer(1,Pr.ReadOnly,z.LEQUAL,!0),Ht=x.paint.get(pt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Vt=vt(.1,3,Ht),ts=M._showOverdrawInspector;if(!ts){const ss=new dn({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),ps=new Dn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);Uf(kt,M,h,x,T,Pt,ss,ps,nn.disabled,pt,"sdf",Pe,Ce,$e,Be,dt,Vt,oe,!1)}{const ss=ts?dn.disabled:new dn({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),ps=ts?M.colorModeForRenderPass():new Dn([z.ONE_MINUS_DST_ALPHA,z.DST_ALPHA,z.ONE,z.ONE],i.ao.transparent,[!0,!0,!0,!0]);Uf(kt,M,h,x,T,Pt,ss,ps,nn.disabled,pt,"color",Pe,Ce,$e,Be,dt,Vt,oe,!1)}};if(Q){const pt=()=>{const Ht=H.drapeBufferSize[0],Vt=H.drapeBufferSize[1];let ts=H.framebufferCopyTexture;return ts&&(!ts||ts.size[0]===Ht&&ts.size[1]===Vt)||(ts&&ts.destroy(),ts=H.framebufferCopyTexture=new i.T(F,new i.q({width:Ht,height:Vt}),z.RGBA8)),ts.bind(z.LINEAR,z.CLAMP_TO_EDGE),z.copyTexSubImage2D(z.TEXTURE_2D,0,0,0,0,0,Ht,Vt),ts},Pt=(Ht,Vt,ts)=>{const ss=M.depthModeForSublayer(1,Pr.ReadOnly,z.LEQUAL,!1),ps=x.paint.get(Ht?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Bs=vt(.1,3,ps);{const Xt=new Dn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0]);Uf(kt,M,h,x,T,ss,dn.disabled,Xt,nn.disabled,Ht,"clear",Pe,Ce,$e,Be,dt,Bs,oe,Vt)}{const Xt=new dn({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),Ft=new Dn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);Uf(kt,M,h,x,T,ss,Xt,Ft,nn.disabled,Ht,"sdf",Pe,Ce,$e,Be,dt,Bs,oe,Vt)}re&&!Ht&&(ts=pt());{const Xt=Ht?z.ZERO:z.ONE_MINUS_DST_ALPHA,Ft=new dn({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),cs=new Dn([Xt,z.DST_ALPHA,z.ONE_MINUS_DST_ALPHA,z.ZERO],i.ao.transparent,[!0,!0,!0,!0]);Uf(kt,M,h,x,T,ss,Ft,cs,nn.disabled,Ht,"color",Pe,Ce,$e,Be,dt,Bs,oe,Vt)}if(!re||Ht){const Xt=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);Uf(kt,M,h,x,T,ss,dn.disabled,Xt,nn.disabled,Ht,"clear",Pe,Ce,$e,Be,dt,Bs,oe,Vt,ts)}else{z.drawBuffers([z.NONE,z.COLOR_ATTACHMENT1]);const Xt=new dn({func:z.EQUAL,mask:255},254,255,z.KEEP,z.DECR,z.DECR),Ft=new Dn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!0,!1,!1,!1],z.MAX);Uf(kt,M,h,x,T,ss,Xt,Ft,nn.disabled,Ht,"emissive",Pe,Ce,$e,Be,dt,Bs,oe,Vt,ts),z.drawBuffers([z.COLOR_ATTACHMENT0])}};if(tt||Mt){let Ht;M.prepareDrawTile(),re&&!tt||(Ht=pt()),tt&&Pt(!0,!1,Ht),Mt&&Pt(!1,!0,Ht)}}else tt&&xt(!0),Mt&&xt(!1),(tt||Mt)&&M.resetStencilClippingMasks()}}},building:function(M,h,x,T){M.currentLayer0&&F>0,re=!0;const oe=x.paint.get("building-vertical-scale");if(oe<=0)return;M.shadowRenderer||(re=!1);const ge=M.conflationActive&&M.style.isLayerClipped(x,h.getSource()),me=M.style.order.indexOf(x.fqid);if(function(xe,Pe,Ce,$e,Be,Je){for(const dt of Je){const tt=Pe.getTile(dt).getBucket(Ce);tt&&(Be&&tt.updateReplacement(dt,xe.replacementSource,$e),tt.uploadUpdatedIndexBuffer(xe.context))}}(M,h,x,me,ge,T),function(xe,Pe,Ce,$e){for(const Be of $e){const Je=Pe.getTile(Be).getBucket(Ce);Je&&Je.needsEvaluation()&&Je.uploadUpdatedColorBuffer(xe.context)}}(M,h,x,T),x.resetLayerRenderingStats(M),M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!0),M.renderPass==="shadow"&&M.shadowRenderer){const xe=M.shadowRenderer,Pe=[],Ce=xe.getShadowPassDepthMode();wb({painter:M,source:h,layer:x,coords:T,defines:Pe,blendMode:xe.getShadowPassColorMode(),depthMode:Ce,opacity:H,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"];re&&(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"),$e=x.paint.get("building-flood-light-intensity"),Be=x.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",Je=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"),tt=$e>0,Mt=new Pr(M.context.gl.LEQUAL,Pr.ReadWrite,M.depthRangeFor3D);H<1&&wb({painter:M,source:h,layer:x,coords:T,defines:xe,blendMode:Dn.disabled,depthMode:Mt,opacity:H,verticalScale:oe,facadeEmissiveChance:Pe,facadeAOIntensity:Ce,floodLightIntensity:$e,floodLightColor:Je,depthOnly:!0});const vt=M.colorModeForRenderPass();wb({painter:M,source:h,layer:x,coords:T,defines:xe,blendMode:vt,depthMode:Mt,opacity:H,verticalScale:oe,facadeEmissiveChance:Pe,facadeAOIntensity:Ce,floodLightIntensity:$e,floodLightColor:Je}),Q&&KS(M,h,x,T,!0,H,D,F,$e,Je,z,ge),tt&&KS(M,h,x,T,!1,H,D,F,$e,Je,dt,ge)}else if(M.renderPass==="light-beam"){const xe=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],Pe=new Pr(M.context.gl.LEQUAL,Pr.ReadOnly,M.depthRangeFor3D);wb({painter:M,source:h,layer:x,coords:T,defines:xe,blendMode:Dn.alphaBlended,depthMode:Pe,opacity:H,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,T){if(M.renderPass!=="offscreen"&&M.renderPass!=="translucent"||M.style.disableElevatedTerrain)return;const D=M.context,F=M.terrain&&M.terrain.renderingToTexture,[z,H]=M.renderPass!=="translucent"||F?[{},T]:M.stencilConfigForOverlap(T);for(const Q of H){const re=h.getTile(Q);if(re.needsHillshadePrepare&&M.renderPass==="offscreen")Bce(M,re,x);else if(M.renderPass==="translucent"){const oe=M.depthModeForSublayer(0,Pr.ReadOnly),ge=x.paint.get("hillshade-emissive-strength"),me=M.colorModeForDrapableLayerRenderPass(ge),xe=F&&M.terrain?M.terrain.stencilModeForRTTOverlap(Q):z[Q.overscaledZ];zce(M,Q,re,x,oe,xe,me)}}D.viewport.set([0,0,M.width,M.height]),M.resetStencilClippingMasks()},raster:function(M,h,x,T,D,F){if(M.renderPass!=="translucent"||x.paint.get("raster-opacity")===0)return;const z=M.transform.projection.name==="globe",H=x.paint.get("raster-elevation")!==0,Q=H&&z;if(M.renderElevatedRasterBackface&&!Q)return;const re=M.context,oe=re.gl,ge=h.getSource(),me=function(vt,kt,xt,pt,Pt){const Ht=kt.paint.get("raster-color"),Vt=vt.type==="raster-array",ts=[],ss=kt.paint.get("raster-resampling"),ps=kt.paint.get("raster-color-mix");let Bs=kt.paint.get("raster-color-range");const Xt=[ps[0],ps[1],ps[2],0],Ft=ps[3];let cs=ss==="nearest"?pt.NEAREST:pt.LINEAR;if(Vt&&(ts.push("RASTER_ARRAY"),Ht||ts.push("RASTER_COLOR"),ss==="linear"&&ts.push("RASTER_ARRAY_LINEAR"),cs=pt.NEAREST,!Bs&&vt.rasterLayers)){const es=vt.rasterLayers.find(({id:Es})=>Es===kt.sourceLayer);es&&es.fields&&es.fields.range&&(Bs=es.fields.range)}if(Bs=Bs||[0,1],Ht){ts.push("RASTER_COLOR"),xt.activeTexture.set(pt.TEXTURE2),kt.updateColorRamp(Bs);let es=kt.colorRampTexture;es||(es=kt.colorRampTexture=new i.T(xt,kt.colorRamp,pt.RGBA8)),es.bind(pt.LINEAR,pt.CLAMP_TO_EDGE)}return Pt&&ts.push("USE_MRT1"),{mix:Xt,range:Bs,offset:Ft,defines:ts,resampling:cs}}(ge,x,re,oe,M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback");if(ge instanceof i.aU&&!T.length&&!z)return;const xe=x.paint.get("raster-emissive-strength"),Pe=M.colorModeForDrapableLayerRenderPass(xe),Ce=M.terrain&&M.terrain.renderingToTexture,$e=!M.options.moving,Be=x.paint.get("raster-resampling")==="nearest"?oe.NEAREST:oe.LINEAR;if(ge instanceof i.aU&&!T.length&&(ge.onNorthPole||ge.onSouthPole)){const vt=H?M.stencilModeFor3D():dn.disabled;return void jb(!!ge.onNorthPole,null,M,h,x,xe,me,nn.disabled,vt)}if(!T.length)return;const[Je,dt]=ge instanceof i.aU||Ce?[{},T]:M.stencilConfigForOverlap(T),tt=dt[dt.length-1].overscaledZ;Q&&me.defines.push("PROJECTION_GLOBE_VIEW"),H&&me.defines.push("RENDER_CUTOFF");const Mt=(vt,kt,xt)=>{for(const pt of vt){const Pt=pt.toUnwrapped(),Ht=h.getTile(pt);if(Ce&&(!Ht||!Ht.hasData()))continue;re.activeTexture.set(oe.TEXTURE0);const Vt=Hf(Ht,ge,x,me);if(!Vt||!Vt.texture)continue;const{texture:ts,mix:ss,offset:ps,tileSize:Bs,buffer:Xt}=Vt;let Ft,cs;Ce?(Ft=Pr.disabled,cs=pt.projMatrix):H?(Ft=new Pr(oe.LEQUAL,Pr.ReadWrite,M.depthRangeFor3D),cs=z?Float32Array.from(M.transform.expandedFarZProjMatrix):M.transform.calculateProjMatrix(Pt,$e)):(Ft=M.depthModeForSublayer(pt.overscaledZ-tt,x.paint.get("raster-opacity")===1?Pr.ReadWrite:Pr.ReadOnly,oe.LESS),cs=M.transform.calculateProjMatrix(Pt,$e));const es=M.terrain&&Ce?M.terrain.stencilModeForRTTOverlap(pt):Je[pt.overscaledZ],Es=F?0:x.paint.get("raster-fade-duration");Ht.registerFadeDuration(Es);const Qs=h.findLoadedParent(pt,0),mr=xb(Ht,Qs,h,M.transform,Es);let Ks,$s;!mr.isFading&&Ht.refreshedUponExpiration&&(Ht.refreshedUponExpiration=!1),M.terrain&&M.terrain.prepareDrawTile(),re.activeTexture.set(oe.TEXTURE0),ts.bind(Be,oe.CLAMP_TO_EDGE),re.activeTexture.set(oe.TEXTURE1),Qs?(Qs.texture&&Qs.texture.bind(Be,oe.CLAMP_TO_EDGE),Ks=Math.pow(2,Qs.tileID.overscaledZ-Ht.tileID.overscaledZ),$s=[Ht.tileID.canonical.x*Ks%1,Ht.tileID.canonical.y*Ks%1]):ts.bind(Be,oe.CLAMP_TO_EDGE),"useMipmap"in ts&&re.extTextureFilterAnisotropic&&M.transform.pitch>20&&oe.texParameterf(oe.TEXTURE_2D,re.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,re.extTextureFilterAnisotropicMax);const Cr=M.transform;let kr;const or=H?DD(Cr):[0,0,0,0];let fr,qr,jn,ha,Wa,Er=0;if(Q&&ge instanceof i.aU&&ge.coordinates.length>3)fr=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0)))),qr=Float32Array.from(Cr.globeMatrix),jn=Float32Array.from(i.dF(Cr)),ha=[i.aF(Cr.center.lng),i.aJ(Cr.center.lat)],kr=ge.elevatedGlobePerspectiveTransform,Wa=ge.elevatedGlobeGridMatrix||new Float32Array(9);else if(Q){const pi=i.dG(pt.canonical);Er=i.dH(pi.getCenter().lat),fr=Float32Array.from(i.bk(i.dJ(pt.canonical))),qr=Float32Array.from(Cr.globeMatrix),jn=Float32Array.from(i.dF(Cr)),ha=[i.aF(Cr.center.lng),i.aJ(Cr.center.lat)],kr=[0,0],Wa=Float32Array.from(i.dI(pt.canonical,pi,Er,Cr.worldSize/Cr._pixelsPerMercatorPixel))}else kr=ge instanceof i.aU?ge.perspectiveTransform:[0,0],fr=new Float32Array(16),qr=new Float32Array(9),jn=new Float32Array(16),ha=[0,0],Wa=new Float32Array(9);const Ra=MD(cs,fr,qr,jn,Wa,$s||[0,0],i.aj(M.transform.zoom),ha,or,Ks||1,mr,x,kr,H?x.paint.get("raster-elevation"):0,2,ss,ps,me.range,Bs,Xt,xe),vn=M.isTileAffectedByFog(pt),Qa=M.getOrCreateProgram("raster",{defines:me.defines,overrideFog:vn});if(M.uploadCommonUniforms(re,Qa,Pt),ge instanceof i.aU){const pi=ge.elevatedGlobeVertexBuffer,oi=ge.elevatedGlobeIndexBuffer;if(Ce||!z)ge.boundsBuffer&&ge.boundsSegments&&Qa.draw(M,oe.TRIANGLES,Ft,dn.disabled,Pe,nn.disabled,Ra,x.id,ge.boundsBuffer,M.quadTriangleIndexBuffer,ge.boundsSegments);else if(pi&&oi){const La=Cr.zoom<=i.c_?ge.elevatedGlobeSegments:ge.getSegmentsForLongitude(Cr.center.lng);La&&Qa.draw(M,oe.TRIANGLES,Ft,dn.disabled,Pe,kt,Ra,x.id,pi,oi,La)}}else if(Q){Ft=new Pr(oe.LEQUAL,Pr.ReadOnly,M.depthRangeFor3D);const pi=M.globeSharedBuffers;if(pi){const[oi,La,Fn]=pi.getGridBuffers(Er,!1);Qa.draw(M,oe.TRIANGLES,Ft,xt||es,M.colorModeForRenderPass(),kt,Ra,x.id,oi,La,Fn)}}else{const{tileBoundsBuffer:pi,tileBoundsIndexBuffer:oi,tileBoundsSegments:La}=M.getTileBoundsBuffers(Ht);Qa.draw(M,oe.TRIANGLES,Ft,es,Pe,nn.disabled,Ra,x.id,pi,oi,La)}}if(!(ge instanceof i.aU)&&Q)for(const pt of vt){const Pt=pt.canonical.y===(1<>>16,2654435769),((pt=Math.imul(pt^pt>>>16,2654435769))>>>0)/4294967296},xt=1/1.1;for(let pt=0;pti.e9[es](ts));Xt.push(ts);const Ft=ts.canonical.x,cs=ts.canonical.y;for(const es of Xt){const Es=tt.getTile(Pt?es.wrapped():es);if(!Es)continue;const Qs=Es.rasterParticleState;if(!Qs)continue;const mr=es.canonical.x+(1<kt.tileID)),xe&&(re.activeTexture.set(oe.TEXTURE0),M.imageManager.bind(M.context,x.scope));const vt=[];if(M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback"&&vt.push("USE_MRT1"),Q){const kt=M.getOrCreateProgram(dt,{overrideFog:!1,overrideRtt:!0,defines:vt}),xt=new Float32Array(i.bA([])),pt=new i.aQ(0,0,0,0,0),Pt=xe?cx(xt,H,z,M,0,x.scope,Pe,Q,{tileID:pt,tileSize:me}):vb(xt,H,z,D.toPremultipliedRenderColor(F?null:x.lut));kt.draw(M,oe.TRIANGLES,Be,$e,Je,nn.disabled,Pt,x.id,M.viewportBuffer,M.quadTriangleIndexBuffer,M.viewportSegments)}else for(const kt of Mt){const xt=M.isTileAffectedByFog(kt),pt=M.getOrCreateProgram(dt,{overrideFog:xt,defines:vt}),Pt=kt.toUnwrapped(),Ht=T?kt.projMatrix:M.transform.calculateProjMatrix(Pt);M.prepareDrawTile();const Vt=h?h.getTile(kt):tt?tt[kt.key]:new em(kt,me,ge.zoom,M),ts=xe?cx(Ht,H,z,M,0,x.scope,Pe,Q,{tileID:kt,tileSize:me}):vb(Ht,H,z,D.toPremultipliedRenderColor(F?null:x.lut));M.uploadCommonUniforms(re,pt,Pt);const{tileBoundsBuffer:ss,tileBoundsIndexBuffer:ps,tileBoundsSegments:Bs}=M.getTileBoundsBuffers(Vt);pt.draw(M,oe.TRIANGLES,Be,$e,Je,nn.disabled,ts,x.id,ss,ps,Bs)}},sky:function(M,h,x){const T=M._atmosphere?i.aj(M.transform.zoom):1,D=x.paint.get("sky-opacity")*T;if(D===0)return;const F=M.context,z=x.paint.get("sky-type"),H=new Pr(F.gl.LEQUAL,Pr.ReadOnly,[0,1]),Q=M.frameCounter/1e3%1;z==="atmosphere"?M.renderPass==="offscreen"?x.needsSkyboxCapture(M)&&(function(re,oe,ge,me){const xe=re.context,Pe=xe.gl;let Ce=oe.skyboxFbo;if(!Ce){Ce=oe.skyboxFbo=xe.createFramebuffer(32,32,1,null),oe.skyboxGeometry=new QS(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 $e=oe.getCenter(re,!0),Be=re.getOrCreateProgram("skyboxCapture"),Je=new Float64Array(16);i.bA(Je),i.en(Je,Je,.5*-Math.PI),Iy(re,oe,Be,Je,$e,0),i.bA(Je),i.en(Je,Je,.5*Math.PI),Iy(re,oe,Be,Je,$e,1),i.bA(Je),i.cU(Je,Je,.5*-Math.PI),Iy(re,oe,Be,Je,$e,2),i.bA(Je),i.cU(Je,Je,.5*Math.PI),Iy(re,oe,Be,Je,$e,3),i.bA(Je),Iy(re,oe,Be,Je,$e,4),i.bA(Je),i.en(Je,Je,Math.PI),Iy(re,oe,Be,Je,$e,5),xe.viewport.set([0,0,re.width,re.height])}(M,x),x.markSkyboxValid(M)):M.renderPass==="sky"&&function(re,oe,ge,me,xe){const Pe=re.context,Ce=Pe.gl,$e=re.transform,Be=re.getOrCreateProgram("skybox");Pe.activeTexture.set(Ce.TEXTURE0),Ce.bindTexture(Ce.TEXTURE_CUBE_MAP,oe.skyboxTexture);const Je=((dt,tt,Mt,vt,kt)=>({u_matrix:dt,u_sun_direction:tt,u_cubemap:0,u_opacity:vt,u_temporal_offset:kt}))($e.skyboxMatrix,oe.getCenter(re,!1),0,me,xe);re.uploadCommonUniforms(Pe,Be),Be.draw(re,Ce.TRIANGLES,ge,dn.disabled,re.colorModeForRenderPass(),nn.backCW,Je,"skybox",oe.skyboxGeometry.vertexBuffer,oe.skyboxGeometry.indexBuffer,oe.skyboxGeometry.segment)}(M,x,H,D,Q):z==="gradient"&&M.renderPass==="sky"&&function(re,oe,ge,me,xe){const Pe=re.context,Ce=Pe.gl,$e=re.transform,Be=re.getOrCreateProgram("skyboxGradient");oe.skyboxGeometry||(oe.skyboxGeometry=new QS(Pe)),Pe.activeTexture.set(Ce.TEXTURE0);let Je=oe.colorRampTexture;Je||(Je=oe.colorRampTexture=new i.T(Pe,oe.colorRamp,Ce.RGBA8)),Je.bind(Ce.LINEAR,Ce.CLAMP_TO_EDGE);const dt=((tt,Mt,vt,kt,xt)=>({u_matrix:tt,u_color_ramp:0,u_center_direction:Mt,u_radius:i.an(vt),u_opacity:kt,u_temporal_offset:xt}))($e.skyboxMatrix,oe.getCenter(re,!1),oe.paint.get("sky-gradient-radius"),me,xe);re.uploadCommonUniforms(Pe,Be),Be.draw(re,Ce.TRIANGLES,ge,dn.disabled,re.colorModeForRenderPass(),nn.backCW,dt,"skyboxGradient",oe.skyboxGeometry.vertexBuffer,oe.skyboxGeometry.indexBuffer,oe.skyboxGeometry.segment)}(M,x,H,D,Q)},custom:function(M,h,x,T){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 H=M.transform.pointMerc;z.call(F,D.gl,M.transform.customLayerMatrix(),M.transform.getProjection(),M.transform.globeToMercatorMatrix(),i.aj(M.transform.zoom),[H.x,H.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 H=F.renderToTile;if(H){const Q=T[0].canonical,re={x:Q.x+T[0].wrap*(F.wrapTileId?0:1<{re&&(re.useNormalOffset=!0,oe||(re.enabled=!0))},me=h.getSource();if(M.renderPass==="light-beam"&&me.type!=="batched-model")return;if(me.type==="vector"||me.type==="geojson")return function(tt,Mt,vt,kt,xt){const pt=tt.transform,Pt=pt.projection.name==="globe",Ht=pt.getFreeCameraOptions().position;if(!tt.modelManager)return;const Vt=tt.modelManager;vt.modelManager=Vt;const ts=tt.shadowRenderer;if(!vt._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const ss=vt._unevaluatedLayout._values["model-id"],ps=Object.assign({},vt.layout.get("model-id").parameters),Bs=tt.style.order.indexOf(vt.fqid),Xt=vt.paint.get("model-opacity").constantOr(1);for(const Ft of kt){const cs=Mt.getTile(Ft).getBucket(vt);if(!cs||cs.projection.name!==pt.projection.name)continue;const es=cs.getModelUris();if(es&&!cs.modelsRequested&&(Vt.addModelsFromBucket(es,xt),cs.modelsRequested=!0),Pt)ps.zoom=Ft.overscaledZ;else{const or=Jd(Ft,pt);ps.zoom=or}const Es=ss.possiblyEvaluate(ps);if(WD(tt,cs,Ft),Lp.shadowUniformsInitialized=!1,Lp.useSingleShadowCascade=!!ts&&ts.getMaxCascadeForTile(Ft.toUnwrapped())===0,tt.renderPass==="shadow"&&ts){if(tt.currentShadowCascade===1&&cs.isInsideFirstShadowMapFrustum)continue;const or=pt.calculatePosMatrix(Ft.toUnwrapped(),pt.worldSize);if(Lp.tileMatrix.set(or),Lp.shadowTileMatrix=Float32Array.from(ts.calculateShadowPassMatrixFromMatrix(or)),Lp.aabb.min=[0,0,0],Lp.aabb.max[0]=Lp.aabb.max[1]=i.al,Lp.aabb.max[2]=0,Jce(cs,Lp,tt,vt.scope))continue}const Qs=1<0&&tt.style.isLayerClipped(vt,Mt.getSource())&&cs.updateReplacement(Ft,tt.replacementSource,Bs,vt.scope)&&(cs.uploaded=!1,cs.upload(tt.context));let Ks=0;const $s=new Array,Cr=new Array,kr=new Array;for(let or in cs.instancesPerModel){const fr=cs.instancesPerModel[or];fr.features.length>0&&!Pt&&(or=Es.evaluate(fr.features[0].feature,{}));const qr=Vt.getModel(or,xt);if(qr||Vt.hasURLBeenRequested(or)||cs.modelUris.includes(or)||(cs.modelUris.push(or),cs.modelsRequested=!1),qr&&qr.uploaded)if(Pt){const jn=i.c5([],[Ht.x,Ht.y,Ht.z],tt.transform.worldSize);i.ew(jn,jn);for(let ha=0;ha0&&Ra.elevationUpdate(or.terrain,ha,Er,qr.source),Ra.needsReEvaluation(or,Wa,qr)&&Ra.evaluate(qr))}})(tt,Mt,vt,kt),function(){let or,fr,qr;$s?(or=kt.length-1,fr=-1,qr=-1):(or=0,fr=kt.length,qr=1);const jn=new Float64Array(16),ha=i.cA(),Wa=new i.P(0,0);for(let Er=or;Er!==fr;Er+=qr){const Ra=kt[Er],vn=Mt.getTile(Ra).getBucket(vt);if(!vn||!vn.uploaded)continue;let Qa=!1;Ht&&(Qa=Ht.getMaxCascadeForTile(Ra.toUnwrapped())===0);const pi=pt.calculatePosMatrix(Ra.toUnwrapped(),pt.worldSize),oi=vn.modelTraits;!Qs&&$s&&(i.bl(jn,pi),i.af(ha,ts,jn),Wa.x=ha[0],Wa.y=ha[1]);const La=[];vn.setFilter(vt.filter);for(const Fn of vn.getNodesInfo()){if(Fn.hiddenByReplacement||!Fn.node.meshes)continue;const Ya=Fn.node;let fo=0;tt.terrain&&Ya.elevation&&(fo=Ya.elevation*tt.terrain.exaggeration());const Hi=(()=>{const fd=Fn.aabb;return Es.min=[...fd.min],Es.max=[...fd.max],Es.min[2]+=fo,Es.max[2]+=fo,i.af(Es.min,Es.min,pi),i.af(Es.max,Es.max,pi),Es})(),Ja=Fn.evaluatedScale;if(Ja[0]<=1&&Ja[1]<=1&&Ja[2]<=1&&Hi.intersects(mr)===0)continue;if(!Qs&&$s){const fd=.16666666666666666;Fn.cameraCollisionOpacity=ts[0]>Hi.min[0]&&ts[0]Hi.min[1]&&ts[1]!$s||Fn.opacity===1&&Ya.opacity===1?Fn.depthYa.depth?-1:1);for(const Fn of La){const Ya=Fn.nodeInfo,fo=Ya.node;let Hi=i.aB([],Xt,Fn.tileModelMatrix);i.aB(Hi,ps,Hi);const Ja=i.bl([],Hi);i.eg(Ja,Ja),i.cS(Ja,Ja,Nb),Hi=i.aB(Hi,Hi,fo.globalMatrix);const Na=tt.renderPass==="light-beam",zn=vt.paint.get("model-color-use-theme").constantOr("default")==="none",zi=oi&i.eI.HasMapboxMeshFeatures,To=zi?0:Ya.evaluatedRMEA[0][2];for(let ho=0;ho=xs||mo>=xs}}const Ec=wi.material;let yh;Ec.occlusionTexture&&Ec.occlusionTexture.offsetScale&&(yh=Ec.occlusionTexture.offsetScale,bl.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const cm=tt.getOrCreateProgram("model",bl);!Qs&&Ht&&Ht.setupShadowsFromMatrix(Fn.tileModelMatrix,cm,Ht.useNormalOffset),tt.uploadCommonUniforms(xt,cm,null,gd);const Su=Ec.pbrMetallicRoughness;Su.metallicFactor=.9,Su.roughnessFactor=.5;const wo=My(new Float32Array(ed),new Float32Array(Hi),new Float32Array(Ja),new Float32Array(fo.globalMatrix),tt,Fn.opacity,Su.baseColorFactor,Ec.emissiveFactor,Su.metallicFactor,Su.roughnessFactor,Ec,To,vt,[0,0,0],yh);!eu&&(Ya.hasTranslucentParts||Fn.opacity<1)&&cm.draw(tt,xt.gl.TRIANGLES,cs,dn.disabled,Dn.disabled,nn.backCCW,wo,vt.id,wi.vertexBuffer,wi.indexBuffer,wi.segments,vt.paint,tt.transform.zoom,void 0,fd),cm.draw(tt,xt.gl.TRIANGLES,eu?es:cs,dn.disabled,eu||Fn.opacity<1||Ya.hasTranslucentParts?Dn.alphaBlended:Dn.unblended,nn.backCCW,wo,vt.id,wi.vertexBuffer,wi.indexBuffer,wi.segments,vt.paint,tt.transform.zoom,void 0,fd)}}}}()}(M,h,x,T),void ge();if(me.type!=="model")return;const xe=me.getModels(),Pe=[],Ce=M.transform.getFreeCameraOptions().position,$e=i.c5([],[Ce.x,Ce.y,Ce.z],M.transform.worldSize);i.ew($e,$e);const Be=[],Je=[];let dt=0;for(const tt of xe){const Mt=h.getFeatureState("",tt.id),vt={type:"Unknown",id:tt.id,properties:tt.featureProperties},kt=x.paint.get("model-rotation").evaluate(vt,Mt),xt=x.paint.get("model-scale").evaluate(vt,Mt),pt=x.paint.get("model-translation").evaluate(vt,Mt),Pt=x.paint.get("model-opacity").evaluate(vt,Mt);UD(x,tt.id,Mt,tt.featureProperties,tt.nodeOverrideNames,tt.nodeOverrides),VD(x,tt.id,Mt,tt.featureProperties,tt.materialOverrideNames,tt.materialOverrides),tt.nodeOverrides.size>0&&tt.computeBoundsAndApplyParent(),tt.computeModelMatrix(M,kt,xt,pt,H,z,!1);const Ht=i.bA([]),Vt=i.ef(tt.position.lat,M.transform.zoom),ts=i.bq([],[1,1,1/Vt]);i.br(Ht,Ht,$e),Pe.push({zScaleMatrix:ts,negCameraPosMatrix:Ht});for(const ss of tt.nodes)Ly(M,ss,tt.matrix,M.transform.expandedFarZProjMatrix,dt,Be,Je,tt.materialOverrides,Pt);dt++}if(Be.sort((tt,Mt)=>Mt.depth-tt.depth),M.renderPass!=="shadow")HD(M,x,Be,Je,Pe),ge();else{for(const tt of Je)Wm(tt.mesh,tt.nodeModelMatrix,M,x);for(const tt of Be)Wm(tt.mesh,tt.nodeModelMatrix,M,x);ge()}}},aC={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 T=h.getVisibleCoordinates();for(const D of T){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 T=h.getSource();if(!T.loaded())return;if(T.type==="vector"||T.type==="geojson")return void(x.modelManager&&x.modelManager.upload(x,kb(x,M)));if(T.type==="batched-model"||T.type!=="model")return;const D=T.getModels();for(const F of D)F.upload(x.context)},raster:function(M,h,x){const T=h.getSource();if(!(T instanceof Xc&&T.loaded()))return;const D=M.sourceLayer||T.rasterLayerIds&&T.rasterLayerIds[0];if(!D)return;const F=M.paint.get("raster-array-band")||T.getInitialBand(D);if(F==null)return;const z=h.getIds().map(H=>h.getTileByID(H));for(const H of z)H.updateNeeded(M.id,F)&&T.prepareTile(H,D,M.id,F)},"raster-particle":function(M,h,x){const T=h.getSource();if(!(T instanceof Xc&&T.loaded()))return;const D=M.sourceLayer||T.rasterLayerIds&&T.rasterLayerIds[0];if(!D)return;const F=M.paint.get("raster-particle-array-band")||T.getInitialBand(D);if(F==null)return;const z=h.getIds().map(H=>h.getTileByID(H));for(const H of z)H.updateNeeded(M.id,F)&&T.prepareTile(H,D,M.id,F)}},xh={fill:HS},iC={fill:function(M,h,x,T){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 Pr(D.LEQUAL,Pr.ReadOnly,M.depthRangeFor3D),z=new dn({func:D.ALWAYS,mask:255},255,255,D.KEEP,D.KEEP,D.REPLACE),H=M.transform.getFreeCameraOptions().position,Q=M.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const re of T){const oe=h.getTile(re),ge=oe.getBucket(x);if(!ge)continue;const me=ge.elevatedStructures;if(!me||me.depthSegments.segments[0].primitiveLength===0)continue;const xe=LD(re.toUnwrapped(),H),Pe=M.translatePosMatrix(re.projMatrix,oe,x.paint.get("fill-translate"),x.paint.get("fill-translate-anchor")),Ce=Cy(Pe,xe,0,1,0);Q.draw(M,D.TRIANGLES,F,z,Dn.disabled,nn.disabled,Ce,x.id,me.vertexBuffer,me.indexBuffer,me.depthSegments,x.paint,M.transform.zoom)}}};class oC{constructor(h,x,T,D,F){this.context=new Sv(h,x),this.transform=T,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 Q of z)this._debugParams.enabledLayers[Q]=!0;for(const Q of z);this.occlusionParams=new Mv,this.setup(),this.numSublayers=ul.maxUnderzooming+ul.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 pv(this),this._wireframeDebugCache=new ux,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const H=new i.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new i.T(this.context,H,h.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=D,this.worldview=F,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(h,x){const T=!!h&&!!h.terrain&&this.transform.projection.supportsTerrain;if(!(T||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new fT(this,h));const D=this._terrain;this.transform.elevation=T?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[T,D]=x.getFovAdjustedRange(this.transform._fov);if(T>D)return void(this.transform.fogCullDistSq=null);const F=T+.78*(D-T);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 fT(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 T of this.style.order)this.style._mergedLayers[T].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 T=new i.bd;T.emplaceBack(0,0),T.emplaceBack(i.al,0),T.emplaceBack(0,i.al),T.emplaceBack(i.al,i.al),this.debugBuffer=h.createVertexBuffer(T,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 H=new i.be;for(const re of[0,1,3,2,0])H.emplaceBack(re);this.debugIndexBuffer=h.createIndexBuffer(H),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 Q=this.context.gl;this.stencilClearMode=new dn({func:Q.ALWAYS,mask:0},0,255,Q.ZERO,Q.ZERO,Q.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,Pr.disabled,this.stencilClearMode,Dn.disabled,nn.disabled,gb(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(h,x,T){if(!x||this.currentStencilSource===x.id||!h.isTileClipped()||!T||T.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let H=!1;for(const Q of T)if(this._tileClippingMaskIDs[Q.key]===void 0){H=!0;break}if(!H)return}this.currentStencilSource=x.id;const D=this.context,F=D.gl;this.nextStencilID+T.length>256&&this.clearStencil(),D.setColorMode(Dn.disabled),D.setDepthMode(Pr.disabled);const z=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const H of T){const Q=x.getTile(H),re=this._tileClippingMaskIDs[H.key]=this.nextStencilID++,{tileBoundsBuffer:oe,tileBoundsIndexBuffer:ge,tileBoundsSegments:me}=this.getTileBoundsBuffers(Q);z.draw(this,F.TRIANGLES,Pr.disabled,new dn({func:F.ALWAYS,mask:0},re,255,F.KEEP,F.KEEP,F.REPLACE),Dn.disabled,nn.disabled,gb(H.projMatrix),"$clipping",oe,ge,me)}}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,T=h.sort((z,H)=>H.overscaledZ-z.overscaledZ),D=T[T.length-1].overscaledZ,F=T[0].overscaledZ-D+1;if(F>1){this.currentStencilSource=void 0,this.nextStencilID+F>256&&this.clearStencil();const z={};for(let H=0;Hthis._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 T=i.o.now();this._dt=T-this._timeStamp,this._timeStamp=T,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(Xt=>{const Ft=D[Xt];return!(Ft.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[Ft.type]});let H=z(),Q=!1,re=!1,oe=null,ge=0,me=!1;for(const Xt of H){const Ft=D[Xt];Ft.visibility!=="none"&&(Ft.type==="circle"?Q=!0:Ft.type==="building"?(oe=Ft,++ge):Ft.type==="symbol"&&(Ft.hasOcclusionOpacityProperties?re=!0:Q=!0))}this.updateEmissiveMode();let xe=H.map(Xt=>D[Xt]);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 Xt in Pe){const Ft=Pe[Xt];Ft.used&&(Ft.prepare(this.context),Ft.getSource().usedInConflation&&++ge)}let Ce=!1;for(const Xt of xe)Xt.isHidden(this.transform.zoom)||(Xt.type==="clip"&&(Ce=!0),this.prepareLayer(Xt));const $e={},Be={},Je={},dt={},tt={};for(const Xt in Pe){const Ft=Pe[Xt];$e[Xt]=Ft.getVisibleCoordinates(),Be[Xt]=$e[Xt].slice().reverse(),Je[Xt]=Ft.getVisibleCoordinates(!0).reverse(),dt[Xt]=Ft.getShadowCasterCoordinates(),tt[Xt]=Ft.sortCoordinatesByDistance($e[Xt])}const Mt=Xt=>{const Ft=this.style.getLayerSourceCache(Xt);return Ft&&Ft.used?Ft.getSource():null};if(ge||Ce||this._clippingActiveLastFrame){const Xt=[],Ft=[];let cs=0;for(const es of xe)this.isSourceForClippingOrConflation(es,Mt(es))&&(Xt.push(es),Ft.push(cs)),cs++;if(Xt&&(Ce||Xt.length>1)||this._clippingActiveLastFrame){Ce=!1;const es=[];for(let Es=0;Es0){const es=Mt(Ft);es&&(this.minCutoffZoom=Math.max(es.minzoom,this.minCutoffZoom)),Ft.minzoom&&(this.minCutoffZoom=Math.max(Ft.minzoom,this.minCutoffZoom))}Ft.is3D(F)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=Xt),this._lastOcclusionLayer=Xt)}const vt=this.style&&this.style.fog;vt?(this._fogVisible=vt.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=vt.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(Je),this.opaquePassCutoff=0,H=z(),xe=H.map(Xt=>D[Xt]));const kt=this._shadowRenderer;if(kt){kt.updateShadowParameters(this.transform,this.style.directionalLight);for(const Xt in Pe)for(const Ft of $e[Xt]){let cs={min:0,max:0};this.terrain&&(cs=this.terrain.getMinMaxForTile(Ft)||cs),kt.addShadowReceiver(Ft.toUnwrapped(),cs.min,cs.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 qD(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const xt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),pt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(xt&&!this._snow&&(this._snow=new ET(this)),!xt&&this._snow&&(this._snow.destroy(),delete this._snow),pt&&!this._rain&&(this._rain=new nC(this)),!pt&&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 JS);const Xt=this.style.getLayerSourceCache(oe);this.buildingTileBorderManager.updateBorders(Xt,oe)}if(!nt.has(this.context.gl))return;this.renderPass="offscreen";for(const Xt of xe){const Ft=h.getLayerSourceCache(Xt);if(!Xt.hasOffscreenPass()||Xt.isHidden(this.transform.zoom))continue;const cs=Ft?Be[Ft.id]:void 0;(Xt.type==="custom"||Xt.type==="raster"||Xt.type==="raster-particle"||Xt.isSky()||cs&&cs.length)&&this.renderLayer(this,Ft,Xt,cs)}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 Pt=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),Ht=(()=>{if(x.showOverdrawInspector)return i.ao.black;const Xt=this.style.fog;if(Xt&&this.transform.projection.supportsFog){const Ft=this.style.getLut(Xt.scope);if(!Pt){const cs=Xt.properties.get("color-use-theme")==="none",es=Xt.properties.get("color").toNonPremultipliedRenderColor(cs?null:Ft).toArray01();return new i.ao(...es)}if(Pt){const cs=Xt.properties.get("space-color-use-theme")==="none",es=Xt.properties.get("space-color").toNonPremultipliedRenderColor(cs?null:Ft).toArray01();return new i.ao(...es)}}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&&Pt&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=H.length-1;this.currentLayer>=0;this.currentLayer--){const Xt=xe[this.currentLayer],Ft=h.getLayerSourceCache(Xt);if(Xt.isSky())continue;const cs=Ft?(Xt.is3D(F)?tt:Be)[Ft.id]:void 0;this._renderTileClippingMasks(Xt,Ft,cs),this.renderLayer(this,Ft,Xt,cs)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Pt&&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&&Xt.hasShadowPass()&&--ts==0){{this.clearStencil(),this.resetStencilClippingMasks();const cs=this.currentLayer;for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const cs=this.currentLayer;this.depthOcclusion=!0;for(const es of this.layersWithOcclusionOpacity){this.currentLayer=es;const Es=xe[this.currentLayer],Qs=h.getLayerSourceCache(Es),mr=Qs?Be[Qs.id]:void 0;this.terrain||this._renderTileClippingMasks(Es,Qs,Qs?$e[Qs.id]:void 0),this.renderLayer(this,Qs,Es,mr)}this.depthOcclusion=!1,this.currentLayer=cs,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 Xt=null;xe.forEach(Ft=>{const cs=h.getLayerSourceCache(Ft);cs&&!Ft.isHidden(this.transform.zoom)&&cs.getVisibleCoordinates().length&&(!Xt||Xt.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,T){const D=T===void 0?this.terrain&&this.terrain.renderingToTexture:T,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 T=x&&x.defines||[],D=x&&x.config,F=this.currentGlobalDefines(h,x&&x.overrideFog,x&&x.overrideRtt).concat(T),z=bD.cacheKey(sT[h],h,F,D);return this.cache[z]||(this.cache[z]=new bD(this.context,h,sT[h],D,VS[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 T=this.style.directionalLight,D=this.style.ambientLight;if(T&&D){const F=((z,H,Q)=>{const re=z.properties.get("direction"),oe=z.properties.get("color-use-theme")==="none",ge=z.properties.get("color").toNonPremultipliedRenderColor(oe?null:Q.getLut(z.scope)).toArray01(),me=z.properties.get("intensity"),xe=H.properties.get("color-use-theme")==="none",Pe=H.properties.get("color").toNonPremultipliedRenderColor(xe?null:Q.getLut(H.scope)).toArray01(),Ce=H.properties.get("intensity"),$e=[re.x,re.y,re.z],Be=i.dN(Pe,Ce),Je=i.dN(ge,me);return{u_lighting_ambient_color:Be,u_lighting_directional_dir:$e,u_lighting_directional_color:Je,u_ground_radiance:jv($e,Je,Be)}})(T,D,this.style);x.setLightsUniformValues(h,F)}}}uploadCommonUniforms(h,x,T,D,F){if(this.uploadCommonLightUniforms(h,x),this.terrain&&this.terrain.renderingToTexture)return;const z=this.style.fog;if(z){const H=z.getOpacity(this.transform.pitch),Q=((re,oe,ge,me,xe,Pe,Ce,$e,Be,Je,dt,tt)=>{const Mt=re.transform,vt=oe.properties.get("color-use-theme")==="none",kt=oe.properties.get("color").toNonPremultipliedRenderColor(vt?null:re.style.getLut(oe.scope)).toArray01();kt[3]=me;const xt=re.frameCounter/1e3%1,[pt,Pt]=oe.properties.get("vertical-range");return{u_fog_matrix:ge?Mt.calculateFogTileMatrix(ge):tt||re.identityMat,u_fog_range:oe.getFovAdjustedRange(Mt._fov),u_fog_color:kt,u_fog_horizon_blend:oe.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(pt,Pt),Pt],u_fog_temporal_offset:xt,u_frustum_tl:xe,u_frustum_tr:Pe,u_frustum_br:Ce,u_frustum_bl:$e,u_globe_pos:Be,u_globe_radius:Je,u_viewport:dt,u_globe_transition:i.aj(Mt.zoom),u_is_globe:+(Mt.projection.name==="globe")}})(this,z,T,H,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,Q)}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={},T=this.transform.coveringTiles({tileSize:512});for(const D of T)x[D.key]=h[D.key]||new em(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]>=xs||x[1]>=xs}setupDepthForOcclusion(h,x,T){const D=this.context,F=D.gl,z=!!T;var H;T||(T={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),T.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],T.u_depth_range_unpack=[2/((H=this.depthRangeFor3D)[1]-H[0]),-1-2*H[0]/(H[1]-H[0])],T.u_occluder_half_size=.5*this.occlusionParams.occluderSize,T.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,T)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const h=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=h?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function lC(M,h){let x=!1,T=null;const D=()=>{T=null,x&&(M(),T=setTimeout(D,h),x=!1)};return()=>(x=!0,T||D(),T)}class PT{constructor(h){this._hashName=h&&encodeURIComponent(h),i.aY(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=lC(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=vl(h);if(this._hashName){const T=this._hashName;let D=!1;const F=location.hash.slice(1).split("&").map(z=>{const H=z.split("=")[0];return H===T?(D=!0,`${H}=${x}`):z}).filter(z=>z);return D||F.push(`${T}=${x}`),`#${F.join("&")}`}return`#${x}`}_getCurrentHash(){const h=location.hash.replace("#","");if(this._hashName){let x;return h.split("&").map(T=>T.split("=")).forEach(T=>{T[0]===this._hashName&&(x=T)}),(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(T=>isNaN(Number(T)))){const T=h.dragRotate.isEnabled()&&h.touchZoomRotate.isEnabled()?+(x[3]||0):h.getBearing();return h.jumpTo({center:[+x[2],+x[1]],zoom:+x[0],bearing:T,pitch:+(x[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function vl(M,h){const x=M.getCenter(),T=Math.round(100*M.getZoom())/100,D=Math.ceil((T*Math.LN2+Math.log(512/360/.5))/Math.LN10),F=Math.pow(10,D),z=Math.round(x.lng*F)/F,H=Math.round(x.lat*F)/F,Q=M.getBearing(),re=M.getPitch();let oe=h?`/${z}/${H}/${T}`:`${T}/${H}/${z}`;return(Q||re)&&(oe+="/"+Math.round(10*Q)/10),re&&(oe+=`/${Math.round(re)}`),oe}const Av={linearity:.3,easing:i.eT(0,0,.3,1)},IT=Object.assign({deceleration:2500,maxSpeed:1400},Av),LT=Object.assign({deceleration:20,maxSpeed:1400},Av),Oy=Object.assign({deceleration:1e3,maxSpeed:360},Av),DT=Object.assign({deceleration:1e3,maxSpeed:90},Av);class OT{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 T=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,D={};if(x.pan.mag()){const F=Dp(x.pan.mag(),T,Object.assign({},IT,h||{}));D.offset=x.pan.mult(F.amount/x.pan.mag()),D.center=this._map.transform.center,Ev(D,F)}if(x.zoom){const F=Dp(x.zoom,T,LT);D.zoom=this._map.transform.zoom+F.amount,Ev(D,F)}if(x.bearing){const F=Dp(x.bearing,T,Oy);D.bearing=this._map.transform.bearing+i.aA(F.amount,-179,179),Ev(D,F)}if(x.pitch){const F=Dp(x.pitch,T,DT);D.pitch=this._map.transform.pitch+F.amount,Ev(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 Ev(M,h){(!M.duration||M.durationx.unproject(Q)),H=F.reduce((Q,re,oe,ge)=>Q.add(re.div(ge.length)),new i.P(0,0));super(h,{points:F,point:H,lngLats:z,lngLat:x.unproject(H),originalEvent:T}),this._defaultPrevented=!1}}class RT extends i.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(h,x){super("wheel",{originalEvent:x}),this._defaultPrevented=!1}}class cC{constructor(h,x){this._map=h,this._clickTolerance=x.clickTolerance}reset(){this._mousedownPos=void 0}wheel(h){return this._firePreventable(new RT(this._map,h))}mousedown(h,x){return this._mousedownPos=x,this._firePreventable(new Nu(h.type,this._map,h))}mouseup(h){this._map.fire(new Nu(h.type,this._map,h))}preclick(h){const x=new MouseEvent("preclick",h);this._map.fire(new Nu(x.type,this._map,x))}click(h,x){this._mousedownPos&&this._mousedownPos.dist(x)>=this._clickTolerance||(this.preclick(h),this._map.fire(new Nu(h.type,this._map,h)))}dblclick(h){return this._firePreventable(new Nu(h.type,this._map,h))}mouseover(h){this._map.fire(new Nu(h.type,this._map,h))}mouseout(h){this._map.fire(new Nu(h.type,this._map,h))}touchstart(h){return this._firePreventable(new mx(h.type,this._map,h))}touchmove(h){this._map.fire(new mx(h.type,this._map,h))}touchend(h){this._map.fire(new mx(h.type,this._map,h))}touchcancel(h){this._map.fire(new mx(h.type,this._map,h))}_firePreventable(h){if(this._map.fire(h),h.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class FT{constructor(h){this._map=h}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(h){this._map.fire(new Nu(h.type,this._map,h))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Nu("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(h){this._delayContextMenu?this._contextMenuEvent=h:this._map.fire(new Nu(h.type,this._map,h)),this._map.listens("contextmenu")&&h.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class dC{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 T=x,D=this._startPos,F=this._lastPos;if(!D||!F||F.equals(T)||!this._box&&T.dist(D){this._box&&(this._box.style.transform=`translate(${z}px,${Q}px)`,this._box.style.width=H-z+"px",this._box.style.height=re-Q+"px")})}mouseupWindow(h,x){if(!this._active)return;const T=this._startPos,D=x;if(T&&h.button===0){if(this.reset(),$(),T.x!==D.x||T.y!==D.y)return this._map.fire(new i.z("boxzoomend",{originalEvent:h})),{cameraAnimation:F=>F.fitScreenCoordinates(T,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 uC(M,h){const x={};for(let T=0;Tthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=h.timeStamp),T.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=uC(T,x)))}touchmove(h,x,T){if(this.aborted||!this.centroid)return;const D=uC(T,x);for(const F in this.touches){const z=D[F];(!z||z.dist(this.touches[F])>30)&&(this.aborted=!0)}}touchend(h,x,T){if((!this.centroid||h.timeStamp-this.startTime>500)&&(this.aborted=!0),T.length===0){const D=!this.aborted&&this.centroid;if(this.reset(),D)return D}}}class hC{constructor(h){this.singleTap=new ZD(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,T){this.singleTap.touchstart(h,x,T)}touchmove(h,x,T){this.singleTap.touchmove(h,x,T)}touchend(h,x,T){const D=this.singleTap.touchend(h,x,T);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 YD{constructor(){this._zoomIn=new hC({numTouches:1,numTaps:2}),this._zoomOut=new hC({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(h,x,T){this._zoomIn.touchstart(h,x,T),this._zoomOut.touchstart(h,x,T)}touchmove(h,x,T){this._zoomIn.touchmove(h,x,T),this._zoomOut.touchmove(h,x,T)}touchend(h,x,T){const D=this._zoomIn.touchend(h,x,T),F=this._zoomOut.touchend(h,x,T);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 XD={0:1,2:2},zT={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class mC{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 T=V(h);this._correctButton(h,T)&&(this._lastPoint=x,this._eventButton=T)}mousemoveWindow(h,x){const T=this._lastPoint;if(T){if(h.preventDefault(),this._eventButton!=null&&function(D,F){const z=XD[F];return D.buttons===void 0||(D.buttons&z)!==z}(h,this._eventButton))this.reset();else if(this._moved||!(x.dist(T)0&&(this._active=!0);const D=uC(T,x),F=new i.P(0,0),z=new i.P(0,0);let H=0;for(const re in D){const oe=D[re],ge=this._touches[re];ge&&(F._add(oe),z._add(oe.sub(ge)),H++,D[re]=oe)}if(this._touches=D,H{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class pC{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(h){}_move(h,x,T){return{}}touchstart(h,x,T){this._firstTwoTouches||T.length<2||(this._firstTwoTouches=[T[0].identifier,T[1].identifier],this._start([x[0],x[1]]))}touchmove(h,x,T){const D=this._firstTwoTouches;if(!D)return;h.preventDefault();const[F,z]=D,H=Sb(T,x,F),Q=Sb(T,x,z);if(!H||!Q)return;const re=this._aroundCenter?null:H.add(Q).div(2);return this._move([H,Q],re,h)}touchend(h,x,T){if(!this._firstTwoTouches)return;const[D,F]=this._firstTwoTouches,z=Sb(T,x,D),H=Sb(T,x,F);z&&H||(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 Sb(M,h,x){for(let T=0;TMath.abs(M.x)}class tde extends pC{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,fC(h[0].sub(h[1]))&&(this._valid=!1)}_move(h,x,T){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()&&T.touches.length<3||(this._valid=this.gestureBeginsVertically(F,z,T.timeStamp),!this._valid)?void 0:(this._lastPoints=h,this._active=!0,{pitchDelta:(F.y+z.y)/2*-.5})}gestureBeginsVertically(h,x,T){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=T),T-this._firstMove<100&&void 0;const z=h.y>0==x.y>0;return fC(h)&&fC(x)&&z}}const sde={panStep:100,bearingStep:15,pitchStep:10};class rde{constructor(){const h=sde;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,T=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?T=-1:(h.preventDefault(),F=-1);break;case 39:h.shiftKey?T=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&&(T=0,D=0),{cameraAnimation:H=>{const Q=H.getZoom();H.easeTo({duration:300,easeId:"keyboardHandler",easing:Cb,zoom:x?Math.round(Q)+x*(h.shiftKey?2:1):Q,bearing:H.getBearing()+T*this._bearingStep,pitch:H.getPitch()+D*this._pitchStep,offset:[-F*this._panStep,-z*this._panStep],center:H.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 Cb(M){return M*(2-M)}const qT=4.000244140625,UT=1/450;class gC{constructor(h,x){this._map=h,this._el=h.getCanvasContainer(),this._handler=x,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=UT,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 T=i.o.now(),D=T-(this._lastWheelEventTime||0);this._lastWheelEventTime=T,x!==0&&x%qT==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 re=this._type==="wheel"&&Math.abs(this._delta)>qT?this._wheelZoomRate:this._defaultZoomRate;let oe=2/(1+Math.exp(-Math.abs(this._delta*re)));this._delta<0&&oe!==0&&(oe=1/oe);const ge=x(),me=Math.pow(2,ge),xe=typeof this._targetZoom=="number"?h.zoomScale(this._targetZoom):me;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 T=typeof this._targetZoom=="number"?this._targetZoom:x(),D=this._startZoom,F=this._easing;let z,H=!1;if(this._type==="wheel"&&D&&F){const re=Math.min((i.o.now()-this._lastWheelEventTime)/200,1),oe=F(re);z=i.ak(D,T,oe),re<1?this._frameId||(this._frameId=!0):H=!0}else z=T,H=!0;this._active=!0,H&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let Q=z-x();return Q*this._lastDelta<0&&(Q=0),{noInertia:!0,needsRenderFrame:!H,zoomDelta:Q,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(h){let x=i.eV;if(this._prevEase){const T=this._prevEase,D=(i.o.now()-T.start)/T.duration,F=T.easing(D+.01)-T.easing(D),z=.27/Math.sqrt(F*F+1e-4)*.01,H=Math.sqrt(.0729-z*z);x=i.eT(z,H,.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=j("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 Gf{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 xC{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(h,x){return h.preventDefault(),{cameraAnimation:T=>{T.easeTo({duration:300,zoom:T.getZoom()+(h.shiftKey?-1:1),around:T.unproject(x)},{originalEvent:h})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class _l{constructor(){this._tap=new hC({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,T){this._swipePoint||(this._tapTime&&h.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?T.length>0&&(this._swipePoint=x[0],this._swipeTouch=T[0].identifier):this._tap.touchstart(h,x,T))}touchmove(h,x,T){if(this._tapTime){if(this._swipePoint){if(T[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,T)}touchend(h,x,T){this._tapTime?this._swipePoint&&T.length===0&&this.reset():this._tap.touchend(h,x,T)&&(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 Op{constructor(h,x,T){this._el=h,this._mousePan=x,this._touchPan=T}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 Mb{constructor(h,x,T){this._pitchWithRotate=h.pitchWithRotate,this._mouseRotate=x,this._mousePitch=T}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 yC{constructor(h,x,T,D){this._el=h,this._touchZoom=x,this._touchRotate=T,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 Tb=M=>M.zoom||M.drag||M.pitch||M.rotate;class nde extends i.z{}class Ab{constructor(){this.constants=[1,1,.01],this.radius=0}setup(h,x){const T=i.av([],x,h);this.radius=i.ag(T[2]<0?i.eX([],T,this.constants):[T[0],T[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 T=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,T),x),2));x[0]=F[0],x[1]=F[1]}return x}}function vC(M){return M.panDelta&&M.panDelta.mag()||M.zoomDelta||M.bearingDelta||M.pitchDelta}class ade{constructor(h,x){this._map=h,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new OT(h),this._bearingSnap=x.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Ab,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(x),i.aY(["handleEvent","handleWindowEvent"],this);const T=this._el;this._listeners=[[T,"touchstart",{passive:!0}],[T,"touchmove",{passive:!1}],[T,"touchend",void 0],[T,"touchcancel",void 0],[T,"mousedown",void 0],[T,"mousemove",void 0],[T,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[T,"mouseover",void 0],[T,"mouseout",void 0],[T,"dblclick",void 0],[T,"click",void 0],[T,"keydown",{capture:!1}],[T,"keyup",void 0],[T,"wheel",{passive:!1}],[T,"contextmenu",void 0],[window,"blur",void 0]];for(const[D,F,z]of this._listeners){const H=D===document?this.handleWindowEvent:this.handleEvent;D.addEventListener(F,H,z)}}destroy(){for(const[h,x,T]of this._listeners){const D=h===document?this.handleWindowEvent:this.handleEvent;h.removeEventListener(x,D,T)}}_addDefaultHandlers(h){const x=this._map,T=x.getCanvasContainer();this._add("mapEvent",new cC(x,h));const D=x.boxZoom=new dC(x,h);this._add("boxZoom",D);const F=new YD,z=new xC;x.doubleClickZoom=new Gf(z,F),this._add("tapZoom",F),this._add("clickZoom",z);const H=new _l;this._add("tapDragZoom",H);const Q=x.touchPitch=new tde(x);this._add("touchPitch",Q);const re=new BT(h),oe=new $T(h);x.dragRotate=new Mb(h,re,oe),this._add("mouseRotate",re,["mousePitch"]),this._add("mousePitch",oe,["mouseRotate"]);const ge=new QD(h),me=new JD(x,h);x.dragPan=new Op(T,ge,me),this._add("mousePan",ge),this._add("touchPan",me,["touchZoom","touchRotate"]);const xe=new uo,Pe=new ede;x.touchZoomRotate=new yC(T,Pe,xe,H),this._add("touchRotate",xe,["touchPan","touchZoom"]),this._add("touchZoom",Pe,["touchPan","touchRotate"]),this._add("blockableMapEvent",new FT(x));const Ce=x.scrollZoom=new gC(x,this);this._add("scrollZoom",Ce,["mousePan"]);const $e=x.keyboard=new rde;this._add("keyboard",$e);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,T){this._handlers.push({handlerName:h,handler:x,allowed:T}),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!!Tb(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(h,x,T){for(const D in h)if(D!==T&&(!x||x.indexOf(D)<0))return!0;return!1}handleWindowEvent(h){this.handleEvent(h,`${h.type}Window`)}_getMapTouches(h){const x=[];for(const T of h)this._el.contains(T.target)&&x.push(T);return x}handleEvent(h,x){this._updatingCamera=!0;const T=h.type==="renderFrame",D=T?void 0:h,F={needsRenderFrame:!1},z={},H={},Q=h.touches?this._getMapTouches(h.touches):void 0,re=Q?U(this._el,Q):T?void 0:q(this._el,h);for(const{handlerName:me,handler:xe,allowed:Pe}of this._handlers){if(!xe.isEnabled())continue;let Ce;this._blockedByActive(H,Pe,me)?xe.reset():xe[x||h.type]&&(Ce=xe[x||h.type](h,re,Q),this.mergeHandlerResult(F,z,Ce,me,D),Ce&&Ce.needsRenderFrame&&this._triggerRenderFrame()),(Ce||xe.isActive())&&(H[me]=xe)}const oe={};for(const me in this._previousActiveHandlers)H[me]||(oe[me]=D);this._previousActiveHandlers=H,(Object.keys(oe).length||vC(F))&&(this._changes.push([F,z,oe]),this._triggerRenderFrame()),(Object.keys(H).length||vC(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,T,D,F){if(!T)return;Object.assign(h,T);const z={handlerName:D,originalEvent:T.originalEvent||F};T.zoomDelta!==void 0&&(x.zoom=z),T.panDelta!==void 0&&(x.drag=z),T.pitchDelta!==void 0&&(x.pitch=z),T.bearingDelta!==void 0&&(x.rotate=z)}_applyChanges(){const h={},x={},T={};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(T,z);this._updateMapTransform(h,x,T),this._changes=[]}_updateMapTransform(h,x,T){const D=this._map,F=D.transform,z=Je=>[Je.x,Je.y,Je.z];if((Je=>{const dt=this._eventsInProgress.drag;return dt&&!this._handlersById[dt.handlerName].isActive()})()&&!vC(h)){const Je=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"),Je!==F.zoom&&this._map._update(!0)}if(F._isCameraConstrained&&D._stop(!0),!vC(h))return void this._fireEvents(x,T,!0);let{panDelta:H,zoomDelta:Q,bearingDelta:re,pitchDelta:oe,around:ge,aroundCoord:me,pinchAround:xe}=h;F._isCameraConstrained&&(Q>0&&(Q=0),F._isCameraConstrained=!1),xe!==void 0&&(ge=xe),(Q||(Je=>x[Je]&&!this._eventsInProgress[Je])("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,re&&(F.bearing+=re),oe&&(F.pitch+=oe),F._updateCameraState();const Pe=[0,0,0];if(H)if(F.projection.name==="mercator"){const Je=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(ge).dir),dt=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(ge.sub(H)).dir);Pe[0]=dt[0]-Je[0],Pe[1]=dt[1]-Je[1]}else{const Je=F.pointCoordinate(ge);if(F.projection.name==="globe"){H=H.rotate(-F.angle);const dt=F._pixelsPerMercatorPixel/F.worldSize;Pe[0]=-H.x*i.eW(i.a$(Je.y))*dt,Pe[1]=-H.y*i.eW(F.center.lat)*dt}else{const dt=F.pointCoordinate(ge.sub(H));Je&&dt&&(Pe[0]=dt.x-Je.x,Pe[1]=dt.y-Je.y)}}const Ce=F.zoom,$e=[0,0,0];if(Q){const Je=z(me||F.pointCoordinate3D(ge)),dt={dir:i.aw([],i.av([],Je,F._camera.position))};if(dt.dir[2]<0){const tt=F.zoomDeltaToMovement(Je,Q);i.c5($e,dt.dir,tt)}}const Be=i.d8(Pe,Pe,$e);F._translateCameraConstrained(Be),Q&&Math.abs(F.zoom-Ce)>1e-4&&F.recenterOnTerrain(),F.cameraElevationReference="ground",this._map._update(),h.noInertia||this._inertia.record(h),this._fireEvents(x,T,!0)}_fireEvents(h,x,T){const D=Tb(this._eventsInProgress),F=Tb(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 H={};let Q;for(const oe in this._eventsInProgress){const{handlerName:ge,originalEvent:me}=this._eventsInProgress[oe];this._handlersById[ge].isActive()||(delete this._eventsInProgress[oe],Q=x[ge]||me,H[`${oe}end`]=Q)}for(const oe in H)this._fireEvent(oe,H[oe]);const re=Tb(this._eventsInProgress);if(T&&(D||F)&&!re){this._updatingCamera=!0;const oe=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),ge=me=>me!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new nde("renderFrame",{timeStamp:h})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const _C="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class VT 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,T){return h=i.P.convert(h).mult(-1),this.panTo(this.transform.center,Object.assign({offset:h},x),T)}panTo(h,x,T){return this.easeTo(Object.assign({center:h},x),T)}getZoom(){return this.transform.zoom}setZoom(h,x){return this.jumpTo({zoom:h},x),this}zoomTo(h,x,T){return this.easeTo(Object.assign({zoom:h},x),T)}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,T){return this.easeTo(Object.assign({bearing:h},x),T)}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?T/(2*Math.tan(.5*h.fovX)*h.aspect):D/(2*Math.tan(.5*h.fovY)*h.aspect)}_cameraForBoundsOnGlobe(h,x,T,D,F,z){const H=h.clone(),Q=this._extendCameraOptions(z);H.bearing=D,H.pitch=F;const re=i.aT.convert(x),oe=i.aT.convert(T),ge=.5*(re.lat+oe.lat),me=.5*(re.lng+oe.lng),xe=i.eZ(ge,me),Pe=i.aw([],xe),Ce=i.aw([],i.bI([],Pe,[0,1,0])),$e=i.bI([],Ce,Pe),Be=[Ce[0],Ce[1],Ce[2],0,$e[0],$e[1],$e[2],0,Pe[0],Pe[1],Pe[2],0,0,0,0,1],Je=[xe,i.eZ(re.lat,re.lng),i.eZ(oe.lat,re.lng),i.eZ(oe.lat,oe.lng),i.eZ(re.lat,oe.lng),i.eZ(ge,re.lng),i.eZ(ge,oe.lng),i.eZ(re.lat,me),i.eZ(oe.lat,me)];let dt=i.d9.fromPoints(Je.map(es=>[i.bJ(Ce,es),i.bJ($e,es),i.bJ(Pe,es)]));const tt=i.af([],dt.center,Be);i.e_(tt)===0&&i.e$(tt,0,0,1),i.aw(tt,tt),i.c5(tt,tt,i.aD),H.center=i.f0(tt);const Mt=H.getWorldToCameraMatrix(),vt=i.bl(new Float64Array(16),Mt);dt=i.d9.applyTransform(dt,i.aB([],Mt,Be));const kt=this._extendAABB(dt,H,Q,D);if(!kt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");dt=kt,i.af(tt,tt,Mt);const xt=.5*(dt.max[2]-dt.min[2]),pt=this._minimumAABBFrustumDistance(H,dt),Pt=i.c5([],[0,0,1],xt),Ht=i.d8(Pt,tt,Pt),Vt=pt+(H.pitch===0?0:i.bG(tt,Ht)),ts=H.globeCenterInViewSpace,ss=i.av([],tt,[ts[0],ts[1],ts[2]]);i.aw(ss,ss),i.c5(ss,ss,Vt);const ps=i.d8([],tt,ss);i.af(ps,ps,vt);const Bs=i.eM/i.aD,Xt=i.ag(ps),Ft=i.cf(Math.max(Xt*Bs-i.eM,Number.EPSILON),0),cs=Math.min(H.zoomFromMercatorZAdjusted(Ft),Q.maxZoom);return cs>.5*(i.c_+i.cL)?(H.setProjection({name:"mercator"}),H.zoom=cs,this._cameraForBounds(H,x,T,D,F,z)):{center:H.center,zoom:cs,bearing:D,pitch:F}}_extendAABB(h,x,T,D){const F=.5*((T.padding.left||0)+(T.padding.right||0)),z=.5*((T.padding.top||0)+(T.padding.bottom||0)),H=z,Q=F,re=F,oe=z,ge=x.width-(Q+re),me=x.height-(H+oe),xe=i.av([],h.max,h.min),Pe=Math.min(ge/xe[0],me/xe[1]),Ce=Math.min(x.scaleZoom(x.scale*Pe),T.maxZoom);if(isNaN(Ce))return null;const $e=x.scale/x.zoomScale(Ce),Be=new i.d9([h.min[0]-Q*$e,h.min[1]-oe*$e,h.min[2]],[h.max[0]+re*$e,h.max[1]+H*$e,h.max[2]]),Je=(typeof T.offset.x=="number"&&typeof T.offset.y=="number"?new i.P(T.offset.x,T.offset.y):i.P.convert(T.offset)).rotate(-i.an(D));return Be.center[0]-=Je.x*$e,Be.center[1]+=Je.y*$e,Be}queryTerrainElevation(h,x){const T=this.transform.elevation;return T?(x=Object.assign({},{exaggerated:!0},x),T.getAtPoint(i.ae.fromLngLat(h),null,x.exaggerated)):null}_cameraForBounds(h,x,T,D,F,z){if(h.projection.name==="globe")return this._cameraForBoundsOnGlobe(h,x,T,D,F,z);const H=h.clone(),Q=this._extendCameraOptions(z);H.bearing=D,H.pitch=F;const re=i.aT.convert(x),oe=i.aT.convert(T),ge=new i.aT(re.lng,oe.lat),me=new i.aT(oe.lng,re.lat),xe=H.project(re),Pe=H.project(oe),Ce=this.queryTerrainElevation(re),$e=this.queryTerrainElevation(oe),Be=this.queryTerrainElevation(ge),Je=this.queryTerrainElevation(me),dt=[[xe.x,xe.y,Math.min(Ce||0,$e||0,Be||0,Je||0)],[Pe.x,Pe.y,Math.max(Ce||0,$e||0,Be||0,Je||0)]];let tt=i.d9.fromPoints(dt);const Mt=H.getWorldToCameraMatrix(),vt=i.bl(new Float64Array(16),Mt);tt=i.d9.applyTransform(tt,Mt);const kt=this._extendAABB(tt,H,Q,D);if(!kt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");tt=kt;const xt=.5*i.av([],tt.max,tt.min)[2],pt=this._minimumAABBFrustumDistance(H,tt),Pt=[0,0,1,0];i.aC(Pt,Pt,Mt),i.f1(Pt,Pt);const Ht=i.c5([],Pt,pt+xt),Vt=i.d8([],tt.center,Ht);i.af(tt.center,tt.center,vt),i.af(Vt,Vt,vt);const ts=H.unproject(new i.P(tt.center[0],tt.center[1])),ss=i.f2(H.projection,ts),ps=Math.pow(2,ss),Bs=Math.min(H._zoomFromMercatorZ(Vt[2]*H.pixelsPerMeter*ps/H.worldSize),Q.maxZoom);return H.mercatorFromTransition&&Bs<.5*(i.c_+i.cL)?(H.setProjection({name:"globe"}),H.zoom=Bs,this._cameraForBounds(H,x,T,D,F,z)):{center:ts,zoom:Bs,bearing:D,pitch:F}}fitBounds(h,x,T){const D=this.cameraForBounds(h,x);return this._fitInternal(D,x,T)}fitScreenCoordinates(h,x,T,D,F){const z=i.P.convert(h),H=i.P.convert(x),Q=new i.P(Math.min(z.x,H.x),Math.min(z.y,H.y)),re=new i.P(Math.max(z.x,H.x),Math.max(z.y,H.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(z,H))return this;const oe=this.transform.pointLocation3D(Q),ge=this.transform.pointLocation3D(re),me=this.transform.pointLocation3D(new i.P(Q.x,re.y)),xe=this.transform.pointLocation3D(new i.P(re.x,Q.y)),Pe=[Math.min(oe.lng,ge.lng,me.lng,xe.lng),Math.min(oe.lat,ge.lat,me.lat,xe.lat)],Ce=[Math.max(oe.lng,ge.lng,me.lng,xe.lng),Math.max(oe.lat,ge.lat,me.lat,xe.lat)],$e=D&&D.pitch?D.pitch:this.getPitch(),Be=this._cameraForBounds(this.transform,Pe,Ce,T,$e,D);return this._fitInternal(Be,D,F)}_fitInternal(h,x,T){return h?(x=Object.assign(h,x)).linear?this.easeTo(x,T):this.flyTo(x,T):this}jumpTo(h,x){this.stop();const T=h.preloadOnly?this.transform.clone():this.transform;let D=!1,F=!1,z=!1;"zoom"in h&&T.zoom!==+h.zoom&&(D=!0,T.zoom=+h.zoom),h.center!==void 0&&(T.center=i.aT.convert(h.center)),"bearing"in h&&T.bearing!==+h.bearing&&(F=!0,T.bearing=+h.bearing),"pitch"in h&&T.pitch!==+h.pitch&&(z=!0,T.pitch=+h.pitch);const H=typeof h.padding=="number"?this._extendPadding(h.padding):h.padding;if(h.padding!=null&&!T.isPaddingEqual(H))if(h.retainPadding===!1){const Q=T.clone();Q.padding=H,T.setLocationAtPoint(T.center,Q.centerPoint)}else T.padding=H;return h.preloadOnly?(this._preloadTiles(T),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(_C),this.transform.getFreeCameraOptions()}setFreeCameraOptions(h,x){const T=this.transform;if(!T.projection.supportsFreeCamera)return i.w(_C),this;this.stop();const D=T.zoom,F=T.pitch,z=T.bearing;T.setFreeCameraOptions(h);const H=D!==T.zoom,Q=F!==T.pitch,re=z!==T.bearing;return this.fire(new i.z("movestart",x)).fire(new i.z("move",x)),H&&this.fire(new i.z("zoomstart",x)).fire(new i.z("zoom",x)).fire(new i.z("zoomend",x)),re&&this.fire(new i.z("rotatestart",x)).fire(new i.z("rotate",x)).fire(new i.z("rotateend",x)),Q&&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 T=this.transform,D=this.getZoom(),F=this.getBearing(),z=this.getPitch(),H=this.getPadding(),Q="zoom"in h?+h.zoom:D,re="bearing"in h?this._normalizeBearing(h.bearing,F):F,oe="pitch"in h?+h.pitch:z,ge=this._extendPadding(h.padding),me=i.P.convert(h.offset);let xe,Pe,Ce;if(T.projection.name==="globe"){const Pt=i.ae.fromLngLat(T.center),Ht=me.rotate(-T.angle);Pt.x+=Ht.x/T.worldSize,Pt.y+=Ht.y/T.worldSize;const Vt=Pt.toLngLat(),ts=i.aT.convert(h.center||Vt);this._normalizeCenter(ts),xe=T.centerPoint.add(Ht),Pe=new i.P(Pt.x,Pt.y).mult(T.worldSize),Ce=new i.P(i.aF(ts.lng),i.aJ(ts.lat)).mult(T.worldSize).sub(Pe)}else{xe=T.centerPoint.add(me);const Pt=T.pointLocation(xe),Ht=i.aT.convert(h.center||Pt);this._normalizeCenter(Ht),Pe=T.project(Pt),Ce=T.project(Ht).sub(Pe)}const $e=T.zoomScale(Q-D);let Be,Je;h.around&&(Be=i.aT.convert(h.around),Je=T.locationPoint(Be));const dt=this._zooming||Q!==D,tt=this._rotating||F!==re,Mt=this._pitching||oe!==z,vt=!T.isPaddingEqual(ge),kt=h.retainPadding===!1?T.clone():T,xt=Pt=>Ht=>{if(dt&&(Pt.zoom=i.ak(D,Q,Ht)),tt&&(Pt.bearing=i.ak(F,re,Ht)),Mt&&(Pt.pitch=i.ak(z,oe,Ht)),vt&&(kt.interpolatePadding(H,ge,Ht),xe=kt.centerPoint.add(me)),Be)Pt.setLocationAtPoint(Be,Je);else{const Vt=Pt.zoomScale(Pt.zoom-D),ts=Q>D?Math.min(2,$e):Math.max(.5,$e),ss=Math.pow(ts,1-Ht),ps=Pt.unproject(Pe.add(Ce.mult(Ht*ss)).mult(Vt));Pt.setLocationAtPoint(Pt.renderWorldCopies?ps.wrap():ps,xe)}return h.preloadOnly||this._fireMoveEvents(x),Pt};if(h.preloadOnly){const Pt=this._emulate(xt,h.duration,T);return this._preloadTiles(Pt),this}const pt={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=dt,this._rotating=tt,this._pitching=Mt,this._padding=vt,this._easeId=h.easeId,this._prepareEase(x,h.noMoveStart,pt),this._ease(xt(T),Pt=>{T.cameraElevationReference==="sea"&&T.recenterOnTerrain(),this._afterEase(x,Pt)},h),this}_prepareEase(h,x,T={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),x||T.moving||this.fire(new i.z("movestart",h)),this._zooming&&!T.zooming&&this.fire(new i.z("zoomstart",h)),this._rotating&&!T.rotating&&this.fire(new i.z("rotatestart",h)),this._pitching&&!T.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 T=this._zooming,D=this._rotating,F=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,T&&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 es=i.aH(h,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(es,x)}this.stop(),h=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:i.eV},h);const T=this.transform,D=this.getZoom(),F=this.getBearing(),z=this.getPitch(),H=this.getPadding(),Q="zoom"in h?i.aA(+h.zoom,T.minZoom,T.maxZoom):D,re="bearing"in h?this._normalizeBearing(h.bearing,F):F,oe="pitch"in h?+h.pitch:z,ge=this._extendPadding(h.padding),me=T.zoomScale(Q-D),xe=i.P.convert(h.offset);let Pe=T.centerPoint.add(xe);const Ce=T.pointLocation(Pe),$e=i.aT.convert(h.center||Ce);this._normalizeCenter($e);const Be=T.project(Ce),Je=T.project($e).sub(Be);let dt=h.curve;const tt=Math.max(T.width,T.height),Mt=tt/me,vt=Je.mag();if("minZoom"in h){const es=i.aA(Math.min(h.minZoom,D,Q),T.minZoom,T.maxZoom),Es=tt/T.zoomScale(es-D);dt=Math.sqrt(Es/vt*2)}const kt=dt*dt;function xt(es){const Es=(Mt*Mt-tt*tt+(es?-1:1)*kt*kt*vt*vt)/(2*(es?Mt:tt)*kt*vt);return Math.log(Math.sqrt(Es*Es+1)-Es)}function pt(es){return(Math.exp(es)-Math.exp(-es))/2}function Pt(es){return(Math.exp(es)+Math.exp(-es))/2}const Ht=xt(0);let Vt=function(es){return Pt(Ht)/Pt(Ht+dt*es)},ts=function(es){return tt*((Pt(Ht)*(pt(Es=Ht+dt*es)/Pt(Es))-pt(Ht))/kt)/vt;var Es},ss=(xt(1)-Ht)/dt;if(Math.abs(vt)<1e-6||!isFinite(ss)){if(Math.abs(tt-Mt)<1e-6)return this.easeTo(h,x);const es=Mth.maxDuration&&(h.duration=0);const ps=F!==re,Bs=oe!==z,Xt=!T.isPaddingEqual(ge),Ft=h.retainPadding===!1?T.clone():T,cs=es=>Es=>{const Qs=Es*ss,mr=1/Vt(Qs);es.zoom=Es===1?Q:D+es.scaleZoom(mr),ps&&(es.bearing=i.ak(F,re,Es)),Bs&&(es.pitch=i.ak(z,oe,Es)),Xt&&(Ft.interpolatePadding(H,ge,Es),Pe=Ft.centerPoint.add(xe));const Ks=Es===1?$e:es.unproject(Be.add(Je.mult(ts(Qs))).mult(mr));return es.setLocationAtPoint(es.renderWorldCopies?Ks.wrap():Ks,Pe),es._updateCameraOnTerrain(),h.preloadOnly||this._fireMoveEvents(x),es};if(h.preloadOnly){const es=this._emulate(cs,h.duration,T);return this._preloadTiles(es),this}return this._zooming=!0,this._rotating=ps,this._pitching=Bs,this._padding=Xt,this._prepareEase(x,!1),this._ease(cs(T),()=>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 T=this._onEaseEnd;this._onEaseEnd=void 0,T.call(this,x)}if(!h){const T=this.handlers;T&&T.stop(!1)}return this}_ease(h,x,T){T.animate===!1||T.duration===0?(h(1),x()):(this._easeStart=i.o.now(),this._easeOptions=T,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 T=Math.abs(h-x);return Math.abs(h-360-x)180?-360:T<-180?360:0}_prefersReducedMotion(h){return this._respectPrefersReducedMotion&&i.o.prefersReducedMotion&&!(h&&h.essential)}_emulate(h,x,T){const D=Math.ceil(15*x/1e3),F=[],z=h(T.clone());for(let H=0;H<=D;H++){const Q=z(H/D);F.push(Q.clone())}return F}_preloadTiles(h,x){}}class Eb{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,T=h._getUIString("AttributionControl.ToggleAttribution");this._map=h,this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=j("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",T);const D=j("span","mapboxgl-ctrl-icon",this._compactButton);return D.setAttribute("aria-hidden","true"),D.setAttribute("title",T),this._innerContainer=j("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 T=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 T=h.map(D=>function(F){const z=new DOMParser().parseFromString(F,"text/html");return Array.from(z.body.querySelectorAll("*")).forEach(H=>{const Q=H.textContent||"";if(H.tagName!=="A")return void H.replaceWith(z.createTextNode(Q));const re=H.getAttribute("href");if(!re||!/^(https?:|mailto:)/i.test(re))return void H.replaceWith(z.createTextNode(Q));const oe=z.createElement("a");oe.href=re,oe.textContent=Q,oe.rel="noopener nofollow";const ge=H.getAttribute("class");ge&&(oe.className=ge),H.replaceWith(oe)}),z.body.innerHTML}(D)).join(" | ");T!==this._attribHTML&&(this._attribHTML=T,h.length?(this._innerContainer.innerHTML=T,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 Pb{constructor(){i.aY(["_updateLogo","_updateCompact"],this)}onAdd(h){this._map=h,this._container=j("div","mapboxgl-ctrl");const x=j("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 T=h[x].getSource();if(T.hasOwnProperty("mapbox_logo")&&!T.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 Pv{constructor(){i.aY(["_onIndoorUpdate"],this)}onAdd(h){return this._map=h,this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("selector-update",x=>this._onIndoorUpdate(x)),this._container}_createButton(h,x){const T=j("button",h,this._container);return T.type="button",T.addEventListener("click",x),T}_createSeparator(){return j("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(T=>T.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)});j("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 T=0;T{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),T=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,T){this._start=this.getValue(x),this._end=h,this._startTime=x,this._endTime=x+T}}const Yf={"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 px extends i.z{constructor(h,x,T,D){const{point:F,lngLat:z,originalEvent:H,target:Q}=h;super(h.type,{point:F,lngLat:z,originalEvent:H,target:Q}),this.preventDefault=()=>{h.preventDefault()},this.id=x,this.interaction=T,this.feature=D}}class Gm{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 T=x.filter;let D=x.type;T&&this.filters.set(h,i.b6(T)),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 T=this.interactionsByType.get(x);return T?T.get(h):void 0}remove(h){const x=this.typeById.get(h);if(!x)return;this.typeById.delete(h),this.filters.delete(h);const T=this.interactionsByType.get(x);T&&(T.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))):T.size===0&&this.map.off(x,this.handleType))}queryTargets(h,x){const T=[];for(const[D,F]of x)F.target&&T.push({targetId:D,target:F.target,filter:this.filters.get(D)});return this.map.style.queryRenderedTargets(h,T,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 T=new Map;for(const[D,{feature:F}]of this.prevHoveredFeatures)this.hoveredFeatures.has(D)||T.set(F.id,F);T.size&&(h.type="mouseleave",this.handleType(h,Array.from(T.values())))}handleOut(h){const x=Array.from(this.hoveredFeatures.values()).map(({feature:T})=>T);x.length&&(h.type="mouseleave",this.handleType(h,x)),this.hoveredFeatures.clear()}handleType(h,x){const T=h.type==="mouseenter";if(T&&!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 H=new Set;for(const Q of x){for(const[re,oe]of D){if(!oe.target)continue;const ge=Q.variants?Q.variants[re]:null;if(ge){for(const me of ge){if(Xg(me,Q,H,re))continue;const xe=new i.dx(Q,me),Pe=Lf(me,Q,re);F&&xe.id!==void 0&&(xe.state=this.map.getFeatureState(xe));const Ce=T?this.prevHoveredFeatures.get(Pe):null,$e=new px(h,re,oe,xe),Be=Ce?Ce.stop:oe.handler($e);if(T&&this.hoveredFeatures.set(Pe,{feature:Q,stop:Be}),Be!==!1){z=!0;break}}if(z)break}}if(z)break}if(!z)for(const[Q,re]of D){const{handler:oe,target:ge}=re;if(!ge&&oe(new px(h,Q,re,null))!==!1)break}}}function ide(M,h){if(Array.isArray(M)&&Array.isArray(h)){const x=new Set(M),T=new Set(h);return x.size===T.size&&M.every(D=>T.has(D))}return i.by(M,h)}const ode={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"},lde={showCompass:!0,showZoom:!0,visualizePitch:!1};class cde{constructor(h,x,T=!1){this._clickTolerance=10,this.element=x,this.mouseRotate=new BT({clickTolerance:h.dragRotate._mouseRotate._clickTolerance}),this.map=h,T&&(this.mousePitch=new $T({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 T=this.map,D=this.mouseRotate.mousemoveWindow(h,x),F=D&&D.bearingDelta;if(F&&T.setBearing(T.getBearing()+F),this.mousePitch){const z=this.mousePitch.mousemoveWindow(h,x),H=z&&z.pitchDelta;H&&T.setPitch(T.getPitch()+H)}}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(T).distSqr(h)180;){const T=x.locationPoint3D(M);if(T.x>=0&&T.y>=0&&T.x<=x.width&&T.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%)"},im={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class bC 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:T="center",color:D="#3FB1CE",scale:F=1,draggable:z=!1,clickTolerance:H=0,rotation:Q=im.rotation,rotationAlignment:re=im.rotationAlignment,pitchAlignment:oe=im.pitchAlignment,occludedOpacity:ge=im.occludedOpacity,altitude:me=im.altitude}=h||{};this._anchor=T,this._color=D,this._scale=F,this._draggable=z,this._clickTolerance=H,this._rotation=Q,this._rotationAlignment=re,this._pitchAlignment=oe,this._occludedOpacity=ge,this._altitude=me,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=j("div"),x=w("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},h);if(this._altitude===0){const T=w("radialGradient",{id:"shadowGradient"},w("defs",{},x));w("stop",{offset:"10%","stop-opacity":.4},T),w("stop",{offset:"100%","stop-opacity":.05},T),w("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},x)}return w("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),w("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),w("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||im.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,T=h.charCode||h.keyCode;x!=="Space"&&x!=="Enter"&&T!==32&&T!==13||this.togglePopup()}_onMapClick(h){const x=h.originalEvent.target,T=this._element;this._popup&&(x===T||T.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 T=h.unproject(x,this._altitude),D=h.getFreeCameraOptions();if(!D.position)return!1;const F=D.position.toLngLat();return F.distanceTo(T)<.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 T=h.unproject(x,this._altitude);let D;h._showingGlobe()&&i.f5(h.transform,this._lngLat)?D=0:(D=1-h._queryFogOpacity(T),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,T=this.getPitchAlignment();if(!x||!h||T!=="map")return"";if(!x._showingGlobe()){const Q=x.getPitch();return Q?`rotateX(${Q}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 H=D/z;return`rotateX(${-F.y*H}deg) rotateY(${F.x*H}deg)`}_calculateZTransform(){const h=this._pos,x=this._map;if(!x||!h)return"";let T=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);T=i.cX(Math.atan2(z.y,z.x))-90}else T=-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 H=h.sub(z),Q=i.cX(Math.atan2(H.y,H.x));T=(Q>90?Q-270:Q+90)*(1-F)}return T+=this._rotation,T?`rotateZ(${T}deg)`:""}_update(h){cancelAnimationFrame(this._updateFrameId);const x=this._map;x&&(x.transform.renderWorldCopies&&(this._lngLat=HT(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 T=this._pointerdownPos,D=this._positionDelta;if(T&&D){if(!this._isDragging){const F=this._clickTolerance||x._clickTolerance;if(h.point.dist(T)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 ZM(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 Kf,this._domRenderTaskQueue=new Kf,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.b2(),this._locale=Object.assign({},Yf,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 Zf(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=M.scaleFactor,this._requestManager=new Y(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 ade(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 PT(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 Eb({customAttribution:M.customAttribution})),this._logoControl=new Pb,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 Gm(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 T=this._controlPositions[h];return h.indexOf("bottom")!==-1?T.insertBefore(x,T.firstChild):T.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 T=this.transform.getProjection().name==="mercator"&&x!==this.transform.mercatorFromTransition;return(h||T)&&(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 T=D=>{let F=[];if(Array.isArray(h)){const z=h.filter(H=>this.getLayer(H));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 H=T(z.point);H.length?D||(D=!0,x.call(this,new Nu(M,this,z.originalEvent,{features:H}))):D=!1},mouseout:()=>{D=!1}}}}if(M==="mouseleave"||M==="mouseout"){let D=!1;return{listener:x,targets:h,delegates:{mousemove:H=>{T(H.point).length?D=!0:D&&(D=!1,x.call(this,new Nu(M,this,H.originalEvent)))},mouseout:H=>{D&&(D=!1,x.call(this,new Nu(M,this,H.originalEvent)))}}}}{const D=F=>{const z=T(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 T=this._createDelegatedListener(M,h,x);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[M]=this._delegatedListeners[M]||[],this._delegatedListeners[M].push(T);for(const D in T.delegates)this.on(D,T.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 T=this._createDelegatedListener(M,h,x);for(const D in T.delegates)this.once(D,T.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 T=this._delegatedListeners?this._delegatedListeners[M]:void 0;return T&&(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 T&&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 am(this,x).load(M),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new am(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:T=!1,stretchX:D,stretchY:F,content:z}={}){this._lazyInitEmptyStyle();const H=i.I.from(M);if(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap){const{width:Q,height:re,data:oe}=i.o.getImageData(h);this.style.addImage(H,{data:new i.q({width:Q,height:re},oe),pixelRatio:x,stretchX:D,stretchY:F,content:z,sdf:T,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:Q,height:re}=h,oe=h;this.style.addImage(H,{data:new i.q({width:Q,height:re},new Uint8Array(oe.data)),pixelRatio:x,stretchX:D,stretchY:F,content:z,sdf:T,usvg:!1,version:0,userImage:oe}),oe.onAdd&&oe.onAdd(this,M)}}updateImage(M,h){this._lazyInitEmptyStyle();const x=i.I.from(M),T=this.style.getImage(x);if(!T)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:H}=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!==(T.usvg?T.icon.usvg_tree.width:T.data.width)||z!==(T.usvg?T.icon.usvg_tree.height:T.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 (${T.data.width}, ${T.data.height})`)));const Q=!(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap);let re=!1;T.usvg?(T.data=new i.q({width:F,height:z},new Uint8Array(H)),T.usvg=!1,T.icon=void 0,re=!0):T.data.replace(H,Q),this.style.updateImage(x,T,re)}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,T)=>{h(x,T instanceof HTMLImageElement?i.o.getImageData(T):T)})}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,T={}){return this._isValidId(M)?(this.style.setPaintProperty(M,h,x,T),this._update(!0)):this}getPaintProperty(M,h){return this._isValidId(M)?this.style.getPaintProperty(M,h):null}setLayoutProperty(M,h,x,T={}){return this._isValidId(M)?(this.style.setLayoutProperty(M,h,x,T),this._update(!0)):this}getLayoutProperty(M,h){return this._isValidId(M)?this.style.getLayoutProperty(M,h):null}setLayerProperty(M,h,x,T={}){return this._isValidId(M)?(h==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(M,h,x,T),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 Pv),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,T,D,F=this._container;for(;F&&(!T||!D);){const z=window.getComputedStyle(F).transform;z&&z!=="none"&&(x=z.match(/matrix.*\((.+)\)/)[1].split(", "),x[0]&&x[0]!=="0"&&x[0]!=="1"&&(T=x[0]),x[3]&&x[3]!=="0"&&x[3]!=="1"&&(D=x[3])),F=F.parentElement}this._containerWidth=T?Math.abs(M/T):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 cD(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=j("div","mapboxgl-canary",M)).style.visibility="hidden",this._detectMissingCSS();const h=this._canvasContainer=j("div","mapboxgl-canvas-container",M);this._canvas=j("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=j("div","mapboxgl-control-container",M),T=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(D=>{T[D]=j("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?(Qe(h,!0),this.painter=new oC(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,T=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 re=this.transform.zoom,oe=this.transform.pitch,ge=i.o.now(),me=new i.ac(re,{now:ge,fadeDuration:F,pitch:oe,transition:this.style.transition,worldview:this._worldview});this.style.update(me)}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(T),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):z=this._updateAverageElevation(T);const H=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),H&&(this._placementDirty=H.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 re=i.o.now()-T;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:re,gpuTime:oe}))},50)}if(this.listens("gpu-timing-layer")){const re=this.painter.collectGpuTimers();setTimeout(()=>{const oe=this.painter.queryGpuTimers(re);this.fire(new i.z("gpu-timing-layer",{layerTimes:oe}))},50)}if(this.listens("gpu-timing-deferred-render")){const re=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const oe=this.painter.queryGpuTimeDeferredRender(re);this.fire(new i.z("gpu-timing-deferred-render",{gpuTime:oe}))},50)}const Q=this._sourcesDirty||this._styleDirty||this._placementDirty||z;if(Q||this._repaint)this.triggerRepaint();else{const re=this.idle();if(re&&(z=this._updateAverageElevation(T,!0)),z)this.triggerRepaint();else if(this._triggerFrame(!1),re&&(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||Q||(this._fullyLoaded=!0,p.mark(u.fullLoad),this._performanceMetricsCollection&&Dt(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 T=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(T||(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||T)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(){Ve(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,M=>{if(M&&(M.message===te||M.status===401)){const h=this.painter.context.gl;Qe(h,!1),this._logoControl instanceof Pb&&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/")))}}),_e(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,T=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,T),this._canvasPixelComparison(D(M),h.canvasCopies.map(D),h.timeStamps)}_canvasPixelComparison(M,h,x){let T=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,T)=>x._preloadTiles(M,T),()=>{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({},lde,M),this._container=j("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})}),j("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})}),j("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=j("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(),T=h===M.getMinZoom();this._zoomInButton.disabled=x,this._zoomOutButton.disabled=T,this._zoomInButton.setAttribute("aria-disabled",x.toString()),this._zoomOutButton.setAttribute("aria-disabled",T.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 cde(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=j("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},dde,M),i.aY(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=lC(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(M){return this._map=M,this._container=j("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,T=this._map.getBearing(),D=Object.assign({bearing:T},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=j("button","mapboxgl-ctrl-geolocate",this._container),j("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=j("div","mapboxgl-user-location"),this._dotElement.appendChild(j("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(j("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new bC({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=j("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new bC({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:Eb,ScaleControl:class{constructor(M={}){this.options=Object.assign({},Iv,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,T=h._containerWidth/2-M/2,D=h.unproject([T,x]),F=h.unproject([T+M,x]),z=D.distanceTo(F);if(this.options.unit==="imperial"){const H=3.2808*z;H>5280?this._setScale(M,H/5280,"mile"):this._setScale(M,H,"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 T=function(F){const z=Math.pow(10,`${Math.floor(F)}`.length-1);let H=F/z;return H=H>=10?10:H>=5?5:H>=3?3:H>=2?2:H>=1?1:function(Q){const re=Math.pow(10,Math.ceil(-Math.log(Q)/Math.LN10));return Math.round(Q*re)/re}(H),z*H}(h),D=T/h;this._container.innerHTML=x!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:x}).format(T):`${T} ${WT[x]}`,this._container.style.width=M*D+"px"})}onAdd(M){return this._map=M,this._language=M.getLanguage(),this._container=j("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=j("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=j("button","mapboxgl-ctrl-fullscreen",this._controlContainer);j("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:Pv,Popup:class extends i.E{constructor(M){super(),this.options=Object.assign(Object.create(om),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 T;for(x.innerHTML=M;T=x.firstChild,T;)h.appendChild(T);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=j("div","mapboxgl-popup-content",this._container||void 0);if(h.appendChild(M),this.options.closeButton){const x=this._closeButton=j("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,T=this._pos;if(!h||!x||!T)return"bottom";const D=x.offsetWidth,F=x.offsetHeight,z=T.xh.transform.width-D/2;if(T.y+Mh.transform.height-F){if(z)return"bottom-left";if(H)return"bottom-right"}return z?"left":H?"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 T=this._container;if(T||(T=this._container=j("div","mapboxgl-popup",h.getContainer()),this._tip=j("div","mapboxgl-popup-tip",T),T.appendChild(x)),this.options.maxWidth&&T.style.maxWidth!==this.options.maxWidth&&(T.style.maxWidth=this.options.maxWidth),h.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=HT(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=Ry(this.options.offset),z=this._anchor=this._getAnchor(F.y),H=Ry(this.options.offset,z),Q=D.add(H).round();h._requestDomTask(()=>{this._container&&z&&(this._container.style.transform=`${pd[z]} translate(${Q.x}px,${Q.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(lm);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:bC,Style:am,LngLat:i.aT,LngLatBounds:i.aI,Point:i.P,MercatorCoordinate:i.ae,FreeCameraOptions:Xd,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 myt=bBe.exports;const $c=_o(myt);function gs({className:t,...s}){return e.jsx("div",{className:Et("animate-pulse rounded-md bg-muted",t),...s})}const k5e={coming_soon:"#3B82F6",active:"#10B981",price_improvement:"#F97316",under_contract:"#8B5CF6",sold:"#6B7280"},N5e={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function pyt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function fyt({listings:t,isLoading:s}){const r=Lr(),n=S.useRef(null),a=S.useRef(null),o=S.useRef([]),[l,i]=S.useState(""),[d,u]=S.useState(!0);return S.useEffect(()=>{(async()=>{u(!0);try{const{data:v}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();v!=null&&v.value&&i(v.value)}catch(v){console.error("Error fetching mapbox token:",v)}u(!1)})()},[]),S.useEffect(()=>{if(!n.current||!l||a.current)return;$c.accessToken=l;const g=t.filter(b=>b.latitude!=null&&b.longitude!=null);let v=[-98.5795,39.8283],_=4;if(g.length>0){const b=g.reduce((w,N)=>w+N.longitude,0)/g.length,j=g.reduce((w,N)=>w+N.latitude,0)/g.length;v=[b,j],_=g.length===1?12:10}return a.current=new $c.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:_,center:v}),a.current.addControl(new $c.NavigationControl,"top-right"),()=>{var b;(b=a.current)==null||b.remove(),a.current=null}},[l]),S.useEffect(()=>{if(!a.current||!l)return;o.current.forEach(v=>v.remove()),o.current=[];const g=t.filter(v=>v.latitude!=null&&v.longitude!=null);if(g.forEach(v=>{var I,L,R;const _=k5e[v.status]||"#10B981",b=((I=v.photos)==null?void 0:I.find($=>$.is_primary))||((L=v.photos)==null?void 0:L[0]),w=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${v.slug||v.id}`:`/public/listing/${v.slug||v.id}`,N=document.createElement("div");N.className="cursor-pointer",N.innerHTML=`
`;const C=new $c.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${b!=null&&b.photo_url?``:""}
${pyt(v.price)}
${v.property_address||""}
${v.city}, ${v.state}
${N5e[v.status]||v.status} ${v.bedrooms?`${v.bedrooms} bed`:""} ${v.bathrooms?`${v.bathrooms} bath`:""}
${(R=v.agent)!=null&&R.name?`
Listed by ${v.agent.name}
`:""}
Click to view details →
`),A=new $c.Marker(N).setLngLat([v.longitude,v.latitude]).setPopup(C).addTo(a.current);o.current.push(A)}),g.length>1){const v=new $c.LngLatBounds;g.forEach(_=>v.extend([_.longitude,_.latitude])),a.current.fitBounds(v,{padding:60,maxZoom:13})}else g.length===1&&a.current.flyTo({center:[g[0].longitude,g[0].latitude],zoom:12})},[t,l]),S.useEffect(()=>(window.__navigateToPublicListing__=g=>{r(g)},()=>{delete window.__navigateToPublicListing__}),[r]),d||s?e.jsx(gs,{className:"w-full h-[500px] rounded-lg"}):!l||t.filter(g=>g.latitude!=null&&g.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(k5e).map(([g,v])=>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:v}}),e.jsx("span",{className:"text-xs text-gray-600",children:N5e[g]})]},g))}),e.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}function GI(t,[s,r]){return Math.min(r,Math.max(s,t))}function jL(t){const s=S.useRef({value:t,previous:t});return S.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}var gyt=[" ","Enter","ArrowUp","ArrowDown"],xyt=[" ","Enter"],MN="Select",[yoe,voe,yyt]=oL(MN),[pM]=Tc(MN,[yyt,dy]),_oe=dy(),[vyt,$_]=pM(MN),[_yt,byt]=pM(MN),jBe=t=>{const{__scopeSelect:s,children:r,open:n,defaultOpen:a,onOpenChange:o,value:l,defaultValue:i,onValueChange:d,dir:u,name:p,autoComplete:g,disabled:v,required:_,form:b}=t,j=_oe(s),[w,N]=S.useState(null),[C,A]=S.useState(null),[I,L]=S.useState(!1),R=z_(u),[$,q]=fu({prop:n,defaultProp:a??!1,onChange:o,caller:MN}),[U,V]=fu({prop:l,defaultProp:i,onChange:d,caller:MN}),X=S.useRef(null),se=w?b||!!w.closest("form"):!0,[te,Y]=S.useState(new Set),de=Array.from(te).map(ie=>ie.props.value).join(";");return e.jsx(uL,{...j,children:e.jsxs(vyt,{required:_,scope:s,trigger:w,onTriggerChange:N,valueNode:C,onValueNodeChange:A,valueNodeHasChildren:I,onValueNodeHasChildrenChange:L,contentId:Hd(),value:U,onValueChange:V,open:$,onOpenChange:q,dir:R,triggerPointerDownPosRef:X,disabled:v,children:[e.jsx(yoe.Provider,{scope:s,children:e.jsx(_yt,{scope:t.__scopeSelect,onNativeOptionAdd:S.useCallback(ie=>{Y(ae=>new Set(ae).add(ie))},[]),onNativeOptionRemove:S.useCallback(ie=>{Y(ae=>{const le=new Set(ae);return le.delete(ie),le})},[]),children:r})}),se?e.jsxs(GBe,{"aria-hidden":!0,required:_,tabIndex:-1,name:p,autoComplete:g,value:U,onChange:ie=>V(ie.target.value),disabled:v,form:b,children:[U===void 0?e.jsx("option",{value:""}):null,Array.from(te)]},de):null]})})};jBe.displayName=MN;var kBe="SelectTrigger",NBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=t,o=_oe(r),l=$_(kBe,r),i=l.disabled||n,d=Aa(s,l.onTriggerChange),u=voe(r),p=S.useRef("touch"),[g,v,_]=ZBe(j=>{const w=u().filter(A=>!A.disabled),N=w.find(A=>A.value===l.value),C=YBe(w,j,N);C!==void 0&&l.onValueChange(C.value)}),b=j=>{i||(l.onOpenChange(!0),_()),j&&(l.triggerPointerDownPosRef.current={x:Math.round(j.pageX),y:Math.round(j.pageY)})};return e.jsx(iM,{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":KBe(l.value)?"":void 0,...a,ref:d,onClick:Mr(a.onClick,j=>{j.currentTarget.focus(),p.current!=="mouse"&&b(j)}),onPointerDown:Mr(a.onPointerDown,j=>{p.current=j.pointerType;const w=j.target;w.hasPointerCapture(j.pointerId)&&w.releasePointerCapture(j.pointerId),j.button===0&&j.ctrlKey===!1&&j.pointerType==="mouse"&&(b(j),j.preventDefault())}),onKeyDown:Mr(a.onKeyDown,j=>{const w=g.current!=="";!(j.ctrlKey||j.altKey||j.metaKey)&&j.key.length===1&&v(j.key),!(w&&j.key===" ")&&gyt.includes(j.key)&&(b(),j.preventDefault())})})})});NBe.displayName=kBe;var SBe="SelectValue",CBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,children:o,placeholder:l="",...i}=t,d=$_(SBe,r),{onValueNodeHasChildrenChange:u}=d,p=o!==void 0,g=Aa(s,d.onValueNodeChange);return Kc(()=>{u(p)},[u,p]),e.jsx(Qr.span,{...i,ref:g,style:{pointerEvents:"none"},children:KBe(d.value)?e.jsx(e.Fragment,{children:l}):o})});CBe.displayName=SBe;var wyt="SelectIcon",MBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,children:n,...a}=t;return e.jsx(Qr.span,{"aria-hidden":!0,...a,ref:s,children:n||"▼"})});MBe.displayName=wyt;var jyt="SelectPortal",TBe=t=>e.jsx(sM,{asChild:!0,...t});TBe.displayName=jyt;var TN="SelectContent",ABe=S.forwardRef((t,s)=>{const r=$_(TN,t.__scopeSelect),[n,a]=S.useState();if(Kc(()=>{a(new DocumentFragment)},[]),!r.open){const o=n;return o?_m.createPortal(e.jsx(EBe,{scope:t.__scopeSelect,children:e.jsx(yoe.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),o):null}return e.jsx(PBe,{...t,ref:s})});ABe.displayName=TN;var pg=10,[EBe,q_]=pM(TN),kyt="SelectContentImpl",Nyt=b_("SelectContent.RemoveScroll"),PBe=S.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:g,collisionBoundary:v,collisionPadding:_,sticky:b,hideWhenDetached:j,avoidCollisions:w,...N}=t,C=$_(TN,r),[A,I]=S.useState(null),[L,R]=S.useState(null),$=Aa(s,Te=>I(Te)),[q,U]=S.useState(null),[V,X]=S.useState(null),se=voe(r),[te,Y]=S.useState(!1),de=S.useRef(!1);S.useEffect(()=>{if(A)return doe(A)},[A]),ooe();const ie=S.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=S.useCallback(()=>ie([q,A]),[ie,q,A]);S.useEffect(()=>{te&&ae()},[te,ae]);const{onOpenChange:le,triggerPointerDownPosRef:pe}=C;S.useEffect(()=>{if(A){let Te={x:0,y:0};const Fe=Ue=>{var ut,De;Te={x:Math.abs(Math.round(Ue.pageX)-(((ut=pe.current)==null?void 0:ut.x)??0)),y:Math.abs(Math.round(Ue.pageY)-(((De=pe.current)==null?void 0:De.y)??0))}},Ae=Ue=>{Te.x<=10&&Te.y<=10?Ue.preventDefault():A.contains(Ue.target)||le(!1),document.removeEventListener("pointermove",Fe),pe.current=null};return pe.current!==null&&(document.addEventListener("pointermove",Fe),document.addEventListener("pointerup",Ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Fe),document.removeEventListener("pointerup",Ae,{capture:!0})}}},[A,le,pe]),S.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,ye]=ZBe(Te=>{const Fe=se().filter(ut=>!ut.disabled),Ae=Fe.find(ut=>ut.ref.current===document.activeElement),Ue=YBe(Fe,Te,Ae);Ue&&setTimeout(()=>Ue.ref.current.focus())}),we=S.useCallback((Te,Fe,Ae)=>{const Ue=!de.current&&!Ae;(C.value!==void 0&&C.value===Fe||Ue)&&(U(Te),Ue&&(de.current=!0))},[C.value]),Ne=S.useCallback(()=>A==null?void 0:A.focus(),[A]),Ke=S.useCallback((Te,Fe,Ae)=>{const Ue=!de.current&&!Ae;(C.value!==void 0&&C.value===Fe||Ue)&&X(Te)},[C.value]),_e=n==="popper"?jge:IBe,Me=_e===jge?{side:i,sideOffset:d,align:u,alignOffset:p,arrowPadding:g,collisionBoundary:v,collisionPadding:_,sticky:b,hideWhenDetached:j,avoidCollisions:w}:{};return e.jsx(EBe,{scope:r,content:A,viewport:L,onViewportChange:R,itemRefCallback:we,selectedItem:q,onItemLeave:Ne,itemTextRefCallback:Ke,focusSelectedItem:ae,selectedItemText:V,position:n,isPositioned:te,searchRef:be,children:e.jsx(xL,{as:Nyt,allowPinchZoom:!0,children:e.jsx(fL,{asChild:!0,trapped:C.open,onMountAutoFocus:Te=>{Te.preventDefault()},onUnmountAutoFocus:Mr(a,Te=>{var Fe;(Fe=C.trigger)==null||Fe.focus({preventScroll:!0}),Te.preventDefault()}),children:e.jsx(D_,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Te=>Te.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:e.jsx(_e,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:Te=>Te.preventDefault(),...N,...Me,onPlaced:()=>Y(!0),ref:$,style:{display:"flex",flexDirection:"column",outline:"none",...N.style},onKeyDown:Mr(N.onKeyDown,Te=>{const Fe=Te.ctrlKey||Te.altKey||Te.metaKey;if(Te.key==="Tab"&&Te.preventDefault(),!Fe&&Te.key.length===1&&ye(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(()=>ie(Ue)),Te.preventDefault()}})})})})})})});PBe.displayName=kyt;var Syt="SelectItemAlignedPosition",IBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=t,o=$_(TN,r),l=q_(TN,r),[i,d]=S.useState(null),[u,p]=S.useState(null),g=Aa(s,$=>p($)),v=voe(r),_=S.useRef(!1),b=S.useRef(!0),{viewport:j,selectedItem:w,selectedItemText:N,focusSelectedItem:C}=l,A=S.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&j&&w&&N){const $=o.trigger.getBoundingClientRect(),q=u.getBoundingClientRect(),U=o.valueNode.getBoundingClientRect(),V=N.getBoundingClientRect();if(o.dir!=="rtl"){const ut=V.left-q.left,De=U.left-ut,Dt=$.left-De,he=$.width+Dt,Ve=Math.max(he,q.width),nt=window.innerWidth-pg,Qe=GI(De,[pg,Math.max(pg,nt-Ve)]);i.style.minWidth=he+"px",i.style.left=Qe+"px"}else{const ut=q.right-V.right,De=window.innerWidth-U.right-ut,Dt=window.innerWidth-$.right-De,he=$.width+Dt,Ve=Math.max(he,q.width),nt=window.innerWidth-pg,Qe=GI(De,[pg,Math.max(pg,nt-Ve)]);i.style.minWidth=he+"px",i.style.right=Qe+"px"}const X=v(),se=window.innerHeight-pg*2,te=j.scrollHeight,Y=window.getComputedStyle(u),de=parseInt(Y.borderTopWidth,10),ie=parseInt(Y.paddingTop,10),ae=parseInt(Y.borderBottomWidth,10),le=parseInt(Y.paddingBottom,10),pe=de+ie+te+le+ae,be=Math.min(w.offsetHeight*5,pe),ye=window.getComputedStyle(j),we=parseInt(ye.paddingTop,10),Ne=parseInt(ye.paddingBottom,10),Ke=$.top+$.height/2-pg,_e=se-Ke,Me=w.offsetHeight/2,Te=w.offsetTop+Me,Fe=de+ie+Te,Ae=pe-Fe;if(Fe<=Ke){const ut=X.length>0&&w===X[X.length-1].ref.current;i.style.bottom="0px";const De=u.clientHeight-j.offsetTop-j.offsetHeight,Dt=Math.max(_e,Me+(ut?Ne:0)+De+ae),he=Fe+Dt;i.style.height=he+"px"}else{const ut=X.length>0&&w===X[0].ref.current;i.style.top="0px";const Dt=Math.max(Ke,de+j.offsetTop+(ut?we:0)+Me)+Ae;i.style.height=Dt+"px",j.scrollTop=Fe-Ke+j.offsetTop}i.style.margin=`${pg}px 0`,i.style.minHeight=be+"px",i.style.maxHeight=se+"px",n==null||n(),requestAnimationFrame(()=>_.current=!0)}},[v,o.trigger,o.valueNode,i,u,j,w,N,o.dir,n]);Kc(()=>A(),[A]);const[I,L]=S.useState();Kc(()=>{u&&L(window.getComputedStyle(u).zIndex)},[u]);const R=S.useCallback($=>{$&&b.current===!0&&(A(),C==null||C(),b.current=!1)},[A,C]);return e.jsx(Myt,{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:g,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});IBe.displayName=Syt;var Cyt="SelectPopperPosition",jge=S.forwardRef((t,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=pg,...o}=t,l=_oe(r);return e.jsx(hL,{...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)"}})});jge.displayName=Cyt;var[Myt,U1e]=pM(TN,{}),kge="SelectViewport",LBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,nonce:n,...a}=t,o=q_(kge,r),l=U1e(kge,r),i=Aa(s,o.onViewportChange),d=S.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(yoe.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:g,shouldExpandOnScrollRef:v}=l;if(v!=null&&v.current&&g){const _=Math.abs(d.current-p.scrollTop);if(_>0){const b=window.innerHeight-pg*2,j=parseFloat(g.style.minHeight),w=parseFloat(g.style.height),N=Math.max(j,w);if(N0?I:0,g.style.justifyContent="flex-end")}}}d.current=p.scrollTop})})})]})});LBe.displayName=kge;var DBe="SelectGroup",[Tyt,Ayt]=pM(DBe),Eyt=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Hd();return e.jsx(Tyt,{scope:r,id:a,children:e.jsx(Qr.div,{role:"group","aria-labelledby":a,...n,ref:s})})});Eyt.displayName=DBe;var OBe="SelectLabel",RBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Ayt(OBe,r);return e.jsx(Qr.div,{id:a.id,...n,ref:s})});RBe.displayName=OBe;var lne="SelectItem",[Pyt,FBe]=pM(lne),zBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:o,...l}=t,i=$_(lne,r),d=q_(lne,r),u=i.value===n,[p,g]=S.useState(o??""),[v,_]=S.useState(!1),b=Aa(s,C=>{var A;return(A=d.itemRefCallback)==null?void 0:A.call(d,C,n,a)}),j=Hd(),w=S.useRef("touch"),N=()=>{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(Pyt,{scope:r,value:n,disabled:a,textId:j,isSelected:u,onItemTextChange:S.useCallback(C=>{g(A=>A||((C==null?void 0:C.textContent)??"").trim())},[]),children:e.jsx(yoe.ItemSlot,{scope:r,value:n,disabled:a,textValue:p,children:e.jsx(Qr.div,{role:"option","aria-labelledby":j,"data-highlighted":v?"":void 0,"aria-selected":u&&v,"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,()=>{w.current!=="mouse"&&N()}),onPointerUp:Mr(l.onPointerUp,()=>{w.current==="mouse"&&N()}),onPointerDown:Mr(l.onPointerDown,C=>{w.current=C.pointerType}),onPointerMove:Mr(l.onPointerMove,C=>{var A;w.current=C.pointerType,a?(A=d.onItemLeave)==null||A.call(d):w.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Mr(l.onPointerLeave,C=>{var A;C.currentTarget===document.activeElement&&((A=d.onItemLeave)==null||A.call(d))}),onKeyDown:Mr(l.onKeyDown,C=>{var I;((I=d.searchRef)==null?void 0:I.current)!==""&&C.key===" "||(xyt.includes(C.key)&&N(),C.key===" "&&C.preventDefault())})})})})});zBe.displayName=lne;var NE="SelectItemText",BBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,...o}=t,l=$_(NE,r),i=q_(NE,r),d=FBe(NE,r),u=byt(NE,r),[p,g]=S.useState(null),v=Aa(s,N=>g(N),d.onItemTextChange,N=>{var C;return(C=i.itemTextRefCallback)==null?void 0:C.call(i,N,d.value,d.disabled)}),_=p==null?void 0:p.textContent,b=S.useMemo(()=>e.jsx("option",{value:d.value,disabled:d.disabled,children:_},d.value),[d.disabled,d.value,_]),{onNativeOptionAdd:j,onNativeOptionRemove:w}=u;return Kc(()=>(j(b),()=>w(b)),[j,w,b]),e.jsxs(e.Fragment,{children:[e.jsx(Qr.span,{id:d.textId,...o,ref:v}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren?_m.createPortal(o.children,l.valueNode):null]})});BBe.displayName=NE;var $Be="SelectItemIndicator",qBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return FBe($Be,r).isSelected?e.jsx(Qr.span,{"aria-hidden":!0,...n,ref:s}):null});qBe.displayName=$Be;var Nge="SelectScrollUpButton",UBe=S.forwardRef((t,s)=>{const r=q_(Nge,t.__scopeSelect),n=U1e(Nge,t.__scopeSelect),[a,o]=S.useState(!1),l=Aa(s,n.onScrollButtonChange);return Kc(()=>{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(HBe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=r;i&&d&&(i.scrollTop=i.scrollTop-d.offsetHeight)}}):null});UBe.displayName=Nge;var Sge="SelectScrollDownButton",VBe=S.forwardRef((t,s)=>{const r=q_(Sge,t.__scopeSelect),n=U1e(Sge,t.__scopeSelect),[a,o]=S.useState(!1),l=Aa(s,n.onScrollButtonChange);return Kc(()=>{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(HBe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=r;i&&d&&(i.scrollTop=i.scrollTop+d.offsetHeight)}}):null});VBe.displayName=Sge;var HBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=t,o=q_("SelectScrollButton",r),l=S.useRef(null),i=voe(r),d=S.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return S.useEffect(()=>()=>d(),[d]),Kc(()=>{var p;const u=i().find(g=>g.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()})})}),Iyt="SelectSeparator",WBe=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return e.jsx(Qr.div,{"aria-hidden":!0,...n,ref:s})});WBe.displayName=Iyt;var Cge="SelectArrow",Lyt=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=_oe(r),o=$_(Cge,r),l=q_(Cge,r);return o.open&&l.position==="popper"?e.jsx(mL,{...a,...n,ref:s}):null});Lyt.displayName=Cge;var Dyt="SelectBubbleInput",GBe=S.forwardRef(({__scopeSelect:t,value:s,...r},n)=>{const a=S.useRef(null),o=Aa(n,a),l=jL(s);return S.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==s&&p){const g=new Event("change",{bubbles:!0});p.call(i,s),i.dispatchEvent(g)}},[l,s]),e.jsx(Qr.select,{...r,style:{...V8e,...r.style},ref:o,defaultValue:s})});GBe.displayName=Dyt;function KBe(t){return t===""||t===void 0}function ZBe(t){const s=Uc(t),r=S.useRef(""),n=S.useRef(0),a=S.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=S.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return S.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,o]}function YBe(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=Oyt(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 Oyt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var Ryt=jBe,XBe=NBe,Fyt=CBe,zyt=MBe,Byt=TBe,QBe=ABe,$yt=LBe,JBe=RBe,e9e=zBe,qyt=BBe,Uyt=qBe,t9e=UBe,s9e=VBe,r9e=WBe;const tr=Ryt,sr=Fyt,Js=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(XBe,{ref:n,className:Et("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(zyt,{asChild:!0,children:e.jsx(Vo,{className:"h-4 w-4 opacity-50"})})]}));Js.displayName=XBe.displayName;const n9e=S.forwardRef(({className:t,...s},r)=>e.jsx(t9e,{ref:r,className:Et("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Rg,{className:"h-4 w-4"})}));n9e.displayName=t9e.displayName;const a9e=S.forwardRef(({className:t,...s},r)=>e.jsx(s9e,{ref:r,className:Et("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Vo,{className:"h-4 w-4"})}));a9e.displayName=s9e.displayName;const er=S.forwardRef(({className:t,children:s,position:r="popper",...n},a)=>e.jsx(Byt,{children:e.jsxs(QBe,{ref:a,className:Et("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(n9e,{}),e.jsx($yt,{className:Et("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(a9e,{})]})}));er.displayName=QBe.displayName;const Vyt=S.forwardRef(({className:t,...s},r)=>e.jsx(JBe,{ref:r,className:Et("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));Vyt.displayName=JBe.displayName;const At=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(e9e,{ref:n,className:Et("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(Uyt,{children:e.jsx(fa,{className:"h-4 w-4"})})}),e.jsx(qyt,{children:s})]}));At.displayName=e9e.displayName;const Hyt=S.forwardRef(({className:t,...s},r)=>e.jsx(r9e,{ref:r,className:Et("-mx-1 my-1 h-px bg-muted",t),...s}));Hyt.displayName=r9e.displayName;const Wyt=t=>Ct({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}}),i9e=t=>Ct({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}),o9e=()=>Ot({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:v}=await G.from("listing_shares").select("id, sharing_agent_id").eq("share_token",l).eq("listing_id",t).maybeSingle();v&&(i=v.id,d=v.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:g}=await G.functions.invoke("process-listing-lead",{body:{leadId:u.id}});return g&&console.error("Error processing lead:",g),u}}),Gyt=()=>Ot({mutationFn:async t=>{const{error:s}=await G.rpc("increment_listing_share_click",{p_share_token:t});if(s)throw s}}),Kyt={active:"bg-emerald-500",coming_soon:"bg-blue-600",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},S5e={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},Zyt={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function l9e(){const[t,s]=S.useState(""),[r,n]=S.useState(!1),[a,o]=S.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:l,isLoading:i}=Wyt({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=g=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(g),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(nh,{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:_Be,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(${hyt})`},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(xn,{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:g=>s(g.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(xn,{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(TP,{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(tr,{value:a.status||"all",onValueChange:g=>o({...a,status:g==="all"?"":g}),children:[e.jsx(Js,{className:"bg-white",children:e.jsx(sr,{placeholder:"Any status"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"Any status"}),Object.entries(S5e).map(([g,v])=>e.jsx(At,{value:g,children:v},g))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Property Type"}),e.jsxs(tr,{value:a.propertyType||"all",onValueChange:g=>o({...a,propertyType:g==="all"?"":g}),children:[e.jsx(Js,{className:"bg-white",children:e.jsx(sr,{placeholder:"Any type"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"Any type"}),Object.entries(Zyt).map(([g,v])=>e.jsx(At,{value:g,children:v},g))]})]})]}),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:g=>o({...a,minPrice:g.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:g=>o({...a,maxPrice:g.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(fyt,{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((g,v)=>e.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm",children:[e.jsx(gs,{className:"aspect-[4/3]"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(gs,{className:"h-7 w-28"}),e.jsx(gs,{className:"h-4 w-full"}),e.jsx(gs,{className:"h-4 w-3/4"})]})]},v))}):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(g=>{var j,w,N;const v=((j=g.photos)==null?void 0:j.find(C=>C.is_primary))||((w=g.photos)==null?void 0:w[0]),b=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${g.slug||g.id}`:`/public/listing/${g.slug||g.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:[v?e.jsx("img",{src:v.photo_url,alt:g.property_address||g.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(Vn,{className:"h-12 w-12 text-gray-300"})}),e.jsx(at,{className:`absolute top-2 left-2 ${Kyt[g.status]} text-white border-0 text-xs font-medium px-2 py-0.5`,children:S5e[g.status]}),e.jsx("button",{className:"absolute top-2 right-2 p-2 rounded-full bg-white/80 hover:bg-white transition-colors",onClick:C=>C.preventDefault(),children:e.jsx(Ni,{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(g.price)}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-gray-700 mb-2",children:[g.bedrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:g.bedrooms}),e.jsx("span",{className:"text-gray-500",children:"bds"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),g.bathrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:g.bathrooms}),e.jsx("span",{className:"text-gray-500",children:"ba"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),g.square_footage&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:g.square_footage.toLocaleString()}),e.jsx("span",{className:"text-gray-500",children:"sqft"})]})]}),g.property_address&&e.jsx("p",{className:"text-sm text-gray-700 truncate",children:g.property_address}),e.jsxs("p",{className:"text-sm text-gray-500 truncate",children:[g.city,", ",g.state]}),g.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:g.agent.name}),((N=g.agent.brokerage)==null?void 0:N.name)&&e.jsx("p",{className:"text-xs text-gray-400 truncate",children:g.agent.brokerage.name})]})]})]})},g.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(Vn,{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:q1e,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=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Et("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Ee.displayName="Card";const Lt=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Et("flex flex-col space-y-1.5 p-6",t),...s}));Lt.displayName="CardHeader";const zt=S.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:Et("text-2xl font-semibold leading-none tracking-tight",t),...s}));zt.displayName="CardTitle";const yr=S.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:Et("text-sm text-muted-foreground",t),...s}));yr.displayName="CardDescription";const Oe=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Et("p-6 pt-0",t),...s}));Oe.displayName="CardContent";const $P=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Et("flex items-center p-6 pt-0",t),...s}));$P.displayName="CardFooter";var Yyt="Label",c9e=S.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())}}));c9e.displayName=Yyt;var d9e=c9e;const Xyt=ZN("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ve=S.forwardRef(({className:t,...s},r)=>e.jsx(d9e,{ref:r,className:Et(Xyt(),t),...s}));ve.displayName=d9e.displayName;const cne="/assets/levelup-logo-color-D3mY9gCJ.png";function Qyt(){const t=xu(),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(l9e,{}):n.startsWith("public/")?null:e.jsx(Jyt,{slug:n})}function Jyt({slug:t}){return e.jsx(s0t,{slug:t})}const e0t={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},t0t={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},C5e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function s0t({slug:t}){var U,V;const{data:s,isLoading:r}=i9e(t),n=o9e(),[a,o]=S.useState(""),[l,i]=S.useState(""),[d,u]=S.useState(""),[p,g]=S.useState(""),[v,_]=S.useState(!1),[b,j]=S.useState(!1),[w,N]=S.useState(null),C=X=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(X),A=async X=>{if(X.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()}),j(!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(X=>X.is_primary)||I[0],R=()=>{w!==null&&N(w===0?I.length-1:w-1)},$=()=>{w!==null&&N(w===I.length-1?0:w+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(gs,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(gs,{className:"h-10 w-48 mb-6"}),e.jsx(gs,{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(gs,{className:"h-12 w-48"}),e.jsx(gs,{className:"h-6 w-full"}),e.jsx(gs,{className:"h-6 w-3/4"})]}),e.jsx(gs,{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:cne,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Vn,{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(nh,{children:[e.jsxs("title",{children:[q," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${C(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA ${s.square_footage?s.square_footage.toLocaleString()+" sqft":""} ${C5e[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:`${C(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:cne,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(Ka,{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:()=>N(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((X,se)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>N(se+1),children:[e.jsx("img",{src:X.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"]})]},X.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(at,{className:`${e0t[s.status]} text-white border-0`,children:t0t[s.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:C(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(Ti,{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(j0,{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($x,{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(Gx,{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(at,{variant:"secondary",children:[e.jsx(Ca,{className:"h-3 w-3 mr-1"}),C5e[s.property_type]]}),s.lot_size&&e.jsxs(at,{variant:"secondary",children:["Lot: ",s.lot_size]}),s.has_hoa&&e.jsx(at,{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(rn,{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(Lt,{children:e.jsxs(zt,{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}),((V=s.agent.brokerage)==null?void 0:V.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:s.agent.brokerage.name})]})]}),e.jsxs(Ee,{className:"border-primary",children:[e.jsx(Lt,{children:e.jsx(zt,{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:A,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:X=>o(X.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:X=>i(X.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:X=>u(X.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:X=>g(X.target.value)})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:v,children:v?"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(vs,{open:w!==null,onOpenChange:()=>N(null),children:e.jsxs(ys,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(Cs,{className:"sr-only",children:e.jsx(Ss,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>N(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"})}),w!==null&&I[w]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:I[w].photo_url,alt:`Photo ${w+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(Ol,{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(qa,{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:[w+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 boe({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 u9e=t=>Ct({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}),r0t=()=>Ct({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}}),n0t=t=>Ct({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}),h9e=()=>{const t=ns();return Ot({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)})},m9e=()=>{const t=ns();return Ot({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:{}})},a0t=async(t,s)=>{const{error:r}=await G.from("agent_card_leads").insert({card_id:t,...s});if(r)throw r},p9e=t=>Ct({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 woe({open:t,onOpenChange:s,cardId:r,type:n,agentName:a}){const[o,l]=S.useState(""),[i,d]=S.useState(""),[u,p]=S.useState(""),[g,v]=S.useState(""),[_,b]=S.useState(""),[j,w]=S.useState(!1),N=async C=>{if(C.preventDefault(),!o.trim()){fe.error("Please enter your name");return}w(!0);try{await a0t(r,{lead_type:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:_.trim()||void 0,intent:g||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:g||void 0}}).catch(A=>console.error("Card lead notify failed:",A)),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(""),v(""),b("")}catch{fe.error("Something went wrong. Please try again.")}finally{w(!1)}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-md rounded-2xl",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:N,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:C=>l(C.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:C=>p(C.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:C=>d(C.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(tr,{value:g,onValueChange:v,children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select one"})}),e.jsxs(er,{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:C=>b(C.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:j,children:j?"Sending...":"Submit"})]})]})})}const i0t=t=>Ct({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}),o0t=t=>Ct({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}),l0t=()=>{const t=ns();return Ot({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)})},c0t=()=>{const t=ns();return Ot({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)})},d0t=()=>{const t=ns();return Ot({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 u0t(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 h0t(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 m0t={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 p0t({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=h0t(r.video_url),o=n||!!a,l=n?u0t(r.video_url):a||r.video_url;return e.jsx("div",{className:m0t[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 f0t={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 g0t({block:t,variant:s}){const n=t.config.testimonials||[],[a,o]=S.useState(0);if(n.length===0)return null;const l=f0t[s],i=n[a];return e.jsxs("div",{className:l.container,children:[e.jsxs("div",{className:l.card,children:[e.jsx(v5,{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(Ol,{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(qa,{className:"h-4 w-4"})})]})]})}const x0t={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 y0t({block:t,variant:s}){const n=t.config.tags||[];if(n.length===0)return null;const a=x0t[s];return e.jsx("div",{className:a.container,children:n.map((o,l)=>e.jsx("span",{className:a.tag,children:o},l))})}const v0t={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=v0t[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(rn,{className:`h-4 w-4 ${o.icon}`})]},i))})}const Mge={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 b0t({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 w0t={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 j0t({block:t,cardId:s,variant:r}){const a=t.config.platforms||[],o=w0t[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=Mge[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(b0t,{path:d.icon,color:d.color})},i)})})]})}function joe({cardId:t,variant:s}){const{data:r}=i0t(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(p0t,{block:l,variant:s},l.id);case"testimonials":return e.jsx(g0t,{block:l,variant:s},l.id);case"specialties":return e.jsx(y0t,{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(j0t,{block:o,cardId:t,variant:s})]})}async function k0t(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 N0t(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 koe(t){const{first:s,last:r}=N0t(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 k0t(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 S0t({card:t}){var N;const[s,r]=S.useState(!1),[n,a]=S.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,A)=>{no(t.id,"button_click",C),A()},d=()=>i("call",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`tel:${t.profile.phone}`:fe.error("Phone number not available")}),u=()=>i("text",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`sms:${t.profile.phone}`:fe.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=t.profile)!=null&&C.email?window.location.href=`mailto:${t.profile.email}`:fe.error("Email not available")}),g=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),no(t.id,"button_click","book"))},v=()=>{var C,A;no(t.id,"contact_saved"),koe({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(A=t.profile)==null?void 0:A.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")},j=()=>{a("connect"),r(!0),no(t.id,"button_click","connect")},w={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(fn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(Ma,{src:t.avatar_url||void 0,alt:o}),e.jsx(gn,{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(Zn,{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:g,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(boe,{card:t,variant:"standard"}),e.jsx(joe,{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:v,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(gi,{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:j,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(fc,{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((C,A)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>no(t.id,"button_click",`social_${C.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:w[C.platform.toLowerCase()]||"🔗"},A))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-slate-400",children:"Powered by LevelUp"})})]}),e.jsx(woe,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function C0t({card:t}){var N;const[s,r]=S.useState(!1),[n,a]=S.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,A)=>{no(t.id,"button_click",C),A()},d=()=>i("call",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`tel:${t.profile.phone}`:fe.error("Phone number not available")}),u=()=>i("text",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`sms:${t.profile.phone}`:fe.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=t.profile)!=null&&C.email?window.location.href=`mailto:${t.profile.email}`:fe.error("Email not available")}),g=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),no(t.id,"button_click","book"))},v=()=>{var C,A;no(t.id,"contact_saved"),koe({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(A=t.profile)==null?void 0:A.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")},j=()=>{a("connect"),r(!0),no(t.id,"button_click","connect")},w={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(fn,{className:"h-32 w-32 mx-auto mb-5 ring-2 ring-[#c9a84c]/40 shadow-2xl",children:[e.jsx(Ma,{src:t.avatar_url||void 0,alt:o}),e.jsx(gn,{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:Zn,label:"Call",handler:d},{icon:io,label:"Text",handler:u},{icon:br,label:"Email",handler:p}].map(({icon:C,label:A,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(C,{className:"h-5 w-5 text-[#c9a84c]"}),e.jsx("span",{className:"text-xs font-medium text-[#e2e8f0]",children:A})]},A))}),e.jsxs("button",{onClick:g,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(boe,{card:t,variant:"luxury"}),e.jsx(joe,{cardId:t.id,variant:"luxury"}),e.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&e.jsxs("button",{onClick:v,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(gi,{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:j,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(fc,{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((C,A)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>no(t.id,"button_click",`social_${C.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:w[C.platform.toLowerCase()]||"🔗"},A))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#4a5568]",children:"Powered by LevelUp"})})]}),e.jsx(woe,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function M0t({card:t}){var A,I,L,R;const[s,r]=S.useState(!1),[n,a]=S.useState("booking"),o=((A=t.profile)==null?void 0:A.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),V=Math.max(0,(U>>16)-q),X=Math.max(0,(U>>8&255)-q),se=Math.max(0,(U&255)-q);return`#${(V<<16|X<<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")}),g=()=>u("text",()=>{var $;($=t.profile)!=null&&$.phone?window.location.href=`sms:${t.profile.phone}`:fe.error("Phone number not available")}),v=()=>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"),koe({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})},j=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!")},w=()=>{a("referral"),r(!0),no(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),no(t.id,"button_click","connect")},C={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(fn,{className:"h-28 w-28 mx-auto mb-4 shadow-2xl",style:{boxShadow:`0 0 0 4px ${i.accent}`},children:[e.jsx(Ma,{src:t.avatar_url||void 0,alt:o}),e.jsx(gn,{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:Zn,label:"Call",handler:p},{icon:io,label:"Text",handler:g},{icon:br,label:"Email",handler:v}].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(boe,{card:t,variant:"bold"}),e.jsx(joe,{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(gi,{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: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(hr,{className:"h-4 w-4",style:{color:i.accent}})," Refer a Friend"]}),e.jsxs("button",{onClick:N,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(fc,{className:"h-4 w-4",style:{color:i.accent}})," Connect with Me"]}),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(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:C[$.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(woe,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function T0t({card:t}){var N;const[s,r]=S.useState(!1),[n,a]=S.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,A)=>{no(t.id,"button_click",C),A()},d=()=>i("call",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`tel:${t.profile.phone}`:fe.error("Phone number not available")}),u=()=>i("text",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`sms:${t.profile.phone}`:fe.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=t.profile)!=null&&C.email?window.location.href=`mailto:${t.profile.email}`:fe.error("Email not available")}),g=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),no(t.id,"button_click","book"))},v=()=>{var C,A;no(t.id,"contact_saved"),koe({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(A=t.profile)==null?void 0:A.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")},j=()=>{a("connect"),r(!0),no(t.id,"button_click","connect")},w={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(fn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(Ma,{src:t.avatar_url||void 0,alt:o}),e.jsx(gn,{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:Zn,label:"Call",handler:d},{icon:io,label:"Text",handler:u},{icon:br,label:"Email",handler:p}].map(({icon:C,label:A,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(C,{className:"h-5 w-5 text-[#1b3a4b]"}),e.jsx("span",{className:"text-xs font-semibold text-[#1b3a4b]",children:A})]},A))}),e.jsxs("button",{onClick:g,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(boe,{card:t,variant:"classic"}),e.jsx(joe,{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:v,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(gi,{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:j,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(fc,{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((C,A)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>no(t.id,"button_click",`social_${C.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:w[C.platform.toLowerCase()]||"🔗"},A))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Powered by LevelUp"})})]}),e.jsx(woe,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function V1e({card:t}){switch(t.theme){case"luxury":return e.jsx(C0t,{card:t});case"bold":return e.jsx(M0t,{card:t});case"classic":return e.jsx(T0t,{card:t});case"standard":default:return e.jsx(S0t,{card:t})}}function A0t(){const t=xu();S.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(E0t,{slug:s})}function E0t({slug:t}){return e.jsx(P0t,{slug:t})}function P0t({slug:t}){var o;const{data:s,isLoading:r,error:n}=u9e(t);if(S.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(gs,{className:"h-28 w-28 rounded-full"}),e.jsx(gs,{className:"h-6 w-48"}),e.jsx(gs,{className:"h-4 w-36"})]}),e.jsx(gs,{className:"h-12 w-full"}),e.jsx(gs,{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(nh,{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(V1e,{card:s})]})}function f9e({presentationId:t,ctaLabel:s,agentName:r,prefillName:n,prefillEmail:a,prefillPhone:o}){const[l,i]=S.useState(n||""),[d,u]=S.useState(a||""),[p,g]=S.useState(o||""),[v,_]=S.useState(""),[b,j]=S.useState(""),[w,N]=S.useState(!1),[C,A]=S.useState(!1),I=async L=>{if(L.preventDefault(),!l.trim()){fe.error("Please enter your name");return}N(!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:v||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:v||void 0,message:b.trim()||void 0}}).catch($=>console.error("Presentation lead notify failed:",$)),A(!0)}catch{fe.error("Something went wrong. Please try again.")}finally{N(!1)}};return C?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(fa,{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=>g(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(tr,{value:v,onValueChange:_,children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select one"})}),e.jsxs(er,{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=>j(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:w,children:w?"Sending...":s})]})}function I0t(){const t=xu();S.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(L0t,{shareToken:s})}function L0t({shareToken:t}){var b;const[s,r]=S.useState(null),[n,a]=S.useState(!0),[o,l]=S.useState(0),[i,d]=S.useState(!1);S.useEffect(()=>{u()},[t]);const u=async()=>{const{data:j,error:w}=await G.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(w||!j){d(!0),a(!1);return}const{data:N}=await G.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",j.owner_user_id).single();let C;if(N!=null&&N.brokerage_id){const{data:I}=await G.from("brokerages").select("name").eq("id",N.brokerage_id).single();C=(I==null?void 0:I.name)||void 0}let A=null;if(j.contact_id){const{data:I}=await G.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",j.contact_id).single();A=I}r({...j,owner_name:N==null?void 0:N.name,owner_email:N==null?void 0:N.email,owner_phone:N==null?void 0:N.phone,owner_avatar:N==null?void 0:N.avatar_url,owner_title:(N==null?void 0:N.title)||void 0,brokerage_name:C,contact_name:A?[A.first_name,A.last_name].filter(Boolean).join(" "):void 0,contact_email:(A==null?void 0:A.email)||void 0,contact_phone:(A==null?void 0:A.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")}},g=j=>{const w=j.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(w)return`https://www.youtube.com/embed/${w[1]}?rel=0`;if(j.includes("iframe.mediadelivery.net/play/")){const A=j.replace("/play/","/embed/"),I=A.includes("?")?"&":"?";return`${A}${I}responsive=true`}if(j.includes("iframe.mediadelivery.net")){const A=j.includes("?")?"&":"?";return`${j}${A}responsive=true`}const N=j.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(N)return`https://www.loom.com/embed/${N[1]}`;const C=j.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return C?`https://iframe.mediadelivery.net/embed/${C[1]}/${C[2]}?responsive=true`:j};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(gs,{className:"h-12 w-3/4 mx-auto"}),e.jsx(gs,{className:"h-64 w-full"}),e.jsx(gs,{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 v=s.sections.filter(j=>j.is_visible!==!1),_=v[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:g(_.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:v.map((j,w)=>e.jsx("button",{onClick:()=>l(w),className:Et("w-full text-left p-4 rounded-xl border transition-all",o===w?"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(w+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})]})]})},w))})]}),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(rn,{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(f9e,{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 Mf=()=>{const t=si();return Ct({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 D0t(){const{user:t}=Gs(),s=si(),{data:r}=Mf();return Ct({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(g=>g.agent_id))],u={};if(d.length>0){const{data:g}=await G.from("profiles").select("id, name").in("id",d);g==null||g.forEach(v=>{v.name&&(u[v.id]=v.name)})}const p=l.map(g=>({...g,agent_name:u[g.agent_id]||void 0}));o=[...o,...p]}}return o.sort((l,i)=>i.event_date.localeCompare(l.event_date)),o},enabled:!!t&&!!s})}function g9e(t){const{user:s}=Gs(),r=ns();return S.useEffect(()=>{if(!t)return;const n=G.channel(`visitors-${t}`).on("postgres_changes",{event:"INSERT",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]),Ct({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 O0t(){const t=ns(),s=si();return Ot({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"]}),an({title:"Open house created!"})},onError:r=>{an({title:"Error",description:r.message,variant:"destructive"})}})}function x9e(){const t=ns();return Ot({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 R0t(){const t=ns();return Ot({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"]}),an({title:"Open house deleted"})}})}function F0t(t){return Ct({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 z0t(t){const{user:s}=Gs();return Ct({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 B0t(t){return Ct({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 $0t(){return Ot({mutationFn:async t=>{const{error:s}=await G.from("open_house_survey_responses").insert(t);if(s)throw s}})}function q0t(t){const{user:s}=Gs();return Ct({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 U0t(){const t=ns();return Ot({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 V0t(){const t=ns();return Ot({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 H0t(){const t=ns();return Ot({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 W0t(){const t=ns();return Ot({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 G0t(){return Ot({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 Noe="Switch",[K0t]=Tc(Noe),[Z0t,Y0t]=K0t(Noe),y9e=S.forwardRef((t,s)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d="on",onCheckedChange:u,form:p,...g}=t,[v,_]=S.useState(null),b=Aa(s,A=>_(A)),j=S.useRef(!1),w=v?p||!!v.closest("form"):!0,[N,C]=fu({prop:a,defaultProp:o??!1,onChange:u,caller:Noe});return e.jsxs(Z0t,{scope:r,checked:N,disabled:i,children:[e.jsx(Qr.button,{type:"button",role:"switch","aria-checked":N,"aria-required":l,"data-state":w9e(N),"data-disabled":i?"":void 0,disabled:i,value:d,...g,ref:b,onClick:Mr(t.onClick,A=>{C(I=>!I),w&&(j.current=A.isPropagationStopped(),j.current||A.stopPropagation())})}),w&&e.jsx(b9e,{control:v,bubbles:!j.current,name:n,value:d,checked:N,required:l,disabled:i,form:p,style:{transform:"translateX(-100%)"}})]})});y9e.displayName=Noe;var v9e="SwitchThumb",_9e=S.forwardRef((t,s)=>{const{__scopeSwitch:r,...n}=t,a=Y0t(v9e,r);return e.jsx(Qr.span,{"data-state":w9e(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});_9e.displayName=v9e;var X0t="SwitchBubbleInput",b9e=S.forwardRef(({__scopeSwitch:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=S.useRef(null),i=Aa(l,o),d=jL(r),u=dL(s);return S.useEffect(()=>{const p=l.current;if(!p)return;const g=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(g,"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=X0t;function w9e(t){return t?"checked":"unchecked"}var j9e=y9e,Q0t=_9e;const Br=S.forwardRef(({className:t,...s},r)=>e.jsx(j9e,{className:Et("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(Q0t,{className:Et("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=j9e.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 Yo(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function hl(t,s){const r=Kn(t);return isNaN(s)?Yo(t,NaN):(s&&r.setDate(r.getDate()+s),r)}function Vh(t,s){const r=Kn(t);if(isNaN(s))return Yo(t,NaN);if(!s)return r;const n=r.getDate(),a=Yo(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 k9e(t,s){const r=+Kn(t);return Yo(t,r+s)}const H1e=6048e5,J0t=864e5,Soe=6e4,kL=36e5,evt=1e3,I8=43200,M5e=1440;function T5e(t,s){return k9e(t,s*kL)}let tvt={};function U_(){return tvt}function ah(t,s){var i,d,u,p;const r=U_(),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 Hh(t){const s=Kn(t);return s.setHours(0,0,0,0),s}function N_(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 up(t,s){const r=Hh(t),n=Hh(s),a=+r-N_(r),o=+n-N_(n);return Math.round((a-o)/J0t)}function svt(t){const s=N9e(t),r=Yo(t,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),K0(r)}function O4(t,s){return k9e(t,s*Soe)}function Nk(t,s){const r=s*7;return hl(t,r)}function rvt(t,s){return Vh(t,s*12)}function nvt(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 ere(t,s){const r=Kn(t),n=Kn(s),a=r.getTime()-n.getTime();return a<0?-1:a>0?1:a}function W1e(t){return Yo(t,Date.now())}function ll(t,s){const r=Hh(t),n=Hh(s);return+r==+n}function G1e(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Tge(t){if(!G1e(t)&&typeof t!="number")return!1;const s=Kn(t);return!isNaN(Number(s))}function u3(t,s){const r=Kn(t),n=Kn(s),a=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return a*12+o}function ivt(t,s,r){const n=ah(t,r),a=ah(s,r),o=+n-N_(n),l=+a-N_(a);return Math.round((o-l)/H1e)}function Vg(t,s){const r=Kn(t),n=Kn(s),a=A5e(r,n),o=Math.abs(up(r,n));r.setDate(r.getDate()-a*o);const l=+(A5e(r,n)===-a),i=a*(o-l);return i===0?0:i}function A5e(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 S9e(t){return s=>{const n=(t?Math[t]:Math.trunc)(s);return n===0?0:n}}function C9e(t,s){return+Kn(t)-+Kn(s)}function ovt(t,s,r){const n=C9e(t,s)/kL;return S9e(r==null?void 0:r.roundingMethod)(n)}function lvt(t){const s=Kn(t);return s.setHours(23,59,59,999),s}function Kp(t){const s=Kn(t),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function cvt(t){const s=Kn(t);return+lvt(s)==+Kp(s)}function dvt(t,s){const r=Kn(t),n=Kn(s),a=ere(r,n),o=Math.abs(u3(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=ere(r,n)===-a;cvt(Kn(t))&&o===1&&ere(t,n)===1&&(i=!1),l=a*(o-Number(i))}return l===0?0:l}function uvt(t,s,r){const n=C9e(t,s)/1e3;return S9e(r==null?void 0:r.roundingMethod)(n)}function hvt(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 uc(t){const s=Kn(t);return s.setDate(1),s.setHours(0,0,0,0),s}function M9e(t){const s=Kn(t),r=Yo(t,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}function Coe(t,s){var i,d,u,p;const r=U_(),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=mvt[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 Ihe(t){return(s={})=>{const r=s.width?String(s.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const fvt={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},gvt={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},xvt={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},yvt={date:Ihe({formats:fvt,defaultWidth:"full"}),time:Ihe({formats:gvt,defaultWidth:"full"}),dateTime:Ihe({formats:xvt,defaultWidth:"full"})},vvt={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)=>vvt[t];function GA(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 bvt={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},wvt={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},jvt={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"]},kvt={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"]},Nvt={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"}},Svt={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"}},Cvt=(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"},Mvt={ordinalNumber:Cvt,era:GA({values:bvt,defaultWidth:"wide"}),quarter:GA({values:wvt,defaultWidth:"wide",argumentCallback:t=>t-1}),month:GA({values:jvt,defaultWidth:"wide"}),day:GA({values:kvt,defaultWidth:"wide"}),dayPeriod:GA({values:Nvt,defaultWidth:"wide",formattingValues:Svt,defaultFormattingWidth:"wide"})};function KA(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)?Avt(i,g=>g.test(l)):Tvt(i,g=>g.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 Tvt(t,s){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&s(t[r]))return r}function Avt(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 Pvt=/^(\d+)(th|st|nd|rd)?/i,Ivt=/\d+/i,Lvt={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},Dvt={any:[/^b/i,/^(a|c)/i]},Ovt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Rvt={any:[/1/i,/2/i,/3/i,/4/i]},Fvt={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},zvt={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]},Bvt={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},$vt={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]},qvt={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},Uvt={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}},Vvt={ordinalNumber:Evt({matchPattern:Pvt,parsePattern:Ivt,valueCallback:t=>parseInt(t,10)}),era:KA({matchPatterns:Lvt,defaultMatchWidth:"wide",parsePatterns:Dvt,defaultParseWidth:"any"}),quarter:KA({matchPatterns:Ovt,defaultMatchWidth:"wide",parsePatterns:Rvt,defaultParseWidth:"any",valueCallback:t=>t+1}),month:KA({matchPatterns:Fvt,defaultMatchWidth:"wide",parsePatterns:zvt,defaultParseWidth:"any"}),day:KA({matchPatterns:Bvt,defaultMatchWidth:"wide",parsePatterns:$vt,defaultParseWidth:"any"}),dayPeriod:KA({matchPatterns:qvt,defaultMatchWidth:"any",parsePatterns:Uvt,defaultParseWidth:"any"})},Moe={code:"en-US",formatDistance:pvt,formatLong:yvt,formatRelative:_vt,localize:Mvt,match:Vvt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Hvt(t){const s=Kn(t);return up(s,M9e(s))+1}function K1e(t){const s=Kn(t),r=+K0(s)-+svt(s);return Math.round(r/H1e)+1}function Z1e(t,s){var p,g,v,_;const r=Kn(t),n=r.getFullYear(),a=U_(),o=(s==null?void 0:s.firstWeekContainsDate)??((g=(p=s==null?void 0:s.locale)==null?void 0:p.options)==null?void 0:g.firstWeekContainsDate)??a.firstWeekContainsDate??((_=(v=a.locale)==null?void 0:v.options)==null?void 0:_.firstWeekContainsDate)??1,l=Yo(t,0);l.setFullYear(n+1,0,o),l.setHours(0,0,0,0);const i=ah(l,s),d=Yo(t,0);d.setFullYear(n,0,o),d.setHours(0,0,0,0);const u=ah(d,s);return r.getTime()>=i.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function Wvt(t,s){var i,d,u,p;const r=U_(),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=Z1e(t,s),o=Yo(t,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),ah(o,s)}function Y1e(t,s){const r=Kn(t),n=+ah(r,s)-+Wvt(r,s);return Math.round(n/H1e)+1}function Zo(t,s){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(s,"0");return r+n}const Zv={y(t,s){const r=t.getFullYear(),n=r>0?r:1-r;return Zo(s==="yy"?n%100:n,s.length)},M(t,s){const r=t.getMonth();return s==="M"?String(r+1):Zo(r+1,2)},d(t,s){return Zo(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 Zo(t.getHours()%12||12,s.length)},H(t,s){return Zo(t.getHours(),s.length)},m(t,s){return Zo(t.getMinutes(),s.length)},s(t,s){return Zo(t.getSeconds(),s.length)},S(t,s){const r=s.length,n=t.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return Zo(a,s.length)}},e4={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},E5e={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 Zv.y(t,s)},Y:function(t,s,r,n){const a=Z1e(t,n),o=a>0?a:1-a;if(s==="YY"){const l=o%100;return Zo(l,2)}return s==="Yo"?r.ordinalNumber(o,{unit:"year"}):Zo(o,s.length)},R:function(t,s){const r=N9e(t);return Zo(r,s.length)},u:function(t,s){const r=t.getFullYear();return Zo(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 Zo(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 Zo(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 Zv.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 Zo(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=Y1e(t,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):Zo(a,s.length)},I:function(t,s,r){const n=K1e(t);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):Zo(n,s.length)},d:function(t,s,r){return s==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):Zv.d(t,s)},D:function(t,s,r){const n=Hvt(t);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):Zo(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 Zo(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 Zo(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 Zo(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=e4.noon:n===0?a=e4.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=e4.evening:n>=12?a=e4.afternoon:n>=4?a=e4.morning:a=e4.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 Zv.h(t,s)},H:function(t,s,r){return s==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):Zv.H(t,s)},K:function(t,s,r){const n=t.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):Zo(n,s.length)},k:function(t,s,r){let n=t.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):Zo(n,s.length)},m:function(t,s,r){return s==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):Zv.m(t,s)},s:function(t,s,r){return s==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):Zv.s(t,s)},S:function(t,s){return Zv.S(t,s)},X:function(t,s,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return I5e(n);case"XXXX":case"XX":return uk(n);case"XXXXX":case"XXX":default:return uk(n,":")}},x:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"x":return I5e(n);case"xxxx":case"xx":return uk(n);case"xxxxx":case"xxx":default:return uk(n,":")}},O:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+P5e(n,":");case"OOOO":default:return"GMT"+uk(n,":")}},z:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+P5e(n,":");case"zzzz":default:return"GMT"+uk(n,":")}},t:function(t,s,r){const n=Math.trunc(t.getTime()/1e3);return Zo(n,s.length)},T:function(t,s,r){const n=t.getTime();return Zo(n,s.length)}};function P5e(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+Zo(o,2)}function I5e(t,s){return t%60===0?(t>0?"-":"+")+Zo(Math.abs(t)/60,2):uk(t,s)}function uk(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=Zo(Math.trunc(n/60),2),o=Zo(n%60,2);return r+a+s+o}const L5e=(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"})}},A9e=(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"})}},Gvt=(t,s)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return L5e(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}}",L5e(n,s)).replace("{{time}}",A9e(a,s))},Age={p:A9e,P:Gvt},Kvt=/^D+$/,Zvt=/^Y+$/,Yvt=["D","DD","YY","YYYY"];function E9e(t){return Kvt.test(t)}function P9e(t){return Zvt.test(t)}function Ege(t,s,r){const n=Xvt(t,s,r);if(console.warn(n),Yvt.includes(t))throw new RangeError(n)}function Xvt(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 Qvt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Jvt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,e1t=/^'([^]*?)'?$/,t1t=/''/g,s1t=/[a-zA-Z]/;function ws(t,s,r){var p,g,v,_,b,j,w,N;const n=U_(),a=(r==null?void 0:r.locale)??n.locale??Moe,o=(r==null?void 0:r.firstWeekContainsDate)??((g=(p=r==null?void 0:r.locale)==null?void 0:p.options)==null?void 0:g.firstWeekContainsDate)??n.firstWeekContainsDate??((_=(v=n.locale)==null?void 0:v.options)==null?void 0:_.firstWeekContainsDate)??1,l=(r==null?void 0:r.weekStartsOn)??((j=(b=r==null?void 0:r.locale)==null?void 0:b.options)==null?void 0:j.weekStartsOn)??n.weekStartsOn??((N=(w=n.locale)==null?void 0:w.options)==null?void 0:N.weekStartsOn)??0,i=Kn(t);if(!Tge(i))throw new RangeError("Invalid time value");let d=s.match(Jvt).map(C=>{const A=C[0];if(A==="p"||A==="P"){const I=Age[A];return I(C,a.formatLong)}return C}).join("").match(Qvt).map(C=>{if(C==="''")return{isToken:!1,value:"'"};const A=C[0];if(A==="'")return{isToken:!1,value:r1t(C)};if(E5e[A])return{isToken:!0,value:C};if(A.match(s1t))throw new RangeError("Format string contains an unescaped latin alphabet character `"+A+"`");return{isToken:!1,value:C}});a.localize.preprocessor&&(d=a.localize.preprocessor(i,d));const u={firstWeekContainsDate:o,weekStartsOn:l,locale:a};return d.map(C=>{if(!C.isToken)return C.value;const A=C.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&P9e(A)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&E9e(A))&&Ege(A,s,String(t));const I=E5e[A[0]];return I(i,A,a.localize,u)}).join("")}function r1t(t){const s=t.match(e1t);return s?s[1].replace(t1t,"'"):t}function n1t(t,s,r){const n=U_(),a=(r==null?void 0:r.locale)??n.locale??Moe,o=2520,l=ere(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=uvt(u,d),g=(N_(u)-N_(d))/1e3,v=Math.round((p-g)/60);let _;if(v<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):v===0?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",v,i);if(v<45)return a.formatDistance("xMinutes",v,i);if(v<90)return a.formatDistance("aboutXHours",1,i);if(vn.getTime()}function EN(t,s){const r=Kn(t),n=Kn(s);return+r<+n}function u1t(t){return+Kn(t)>Date.now()}function h1t(t,s){const r=s instanceof Date?Yo(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 m1t=10;class I9e{constructor(){_n(this,"subPriority",0)}validate(s,r){return!0}}class p1t extends I9e{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 f1t extends I9e{constructor(){super(...arguments);_n(this,"priority",m1t);_n(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:Yo(r,h1t(r,Date))}}class Bo{run(s,r,n,a){const o=this.parse(s,r,n,a);return o?{setter:new p1t(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(s,r,n){return!0}}class g1t extends Bo{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 id={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}/},Ix={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 od(t,s){return t&&{value:s(t.value),rest:t.rest}}function jc(t,s){const r=s.match(t);return r?{value:parseInt(r[0],10),rest:s.slice(r[0].length)}:null}function Lx(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*kL+o*Soe+l*evt),rest:s.slice(r[0].length)}}function L9e(t){return jc(id.anyDigitsSigned,t)}function Zc(t,s){switch(t){case 1:return jc(id.singleDigit,s);case 2:return jc(id.twoDigits,s);case 3:return jc(id.threeDigits,s);case 4:return jc(id.fourDigits,s);default:return jc(new RegExp("^\\d{1,"+t+"}"),s)}}function dne(t,s){switch(t){case 1:return jc(id.singleDigitSigned,s);case 2:return jc(id.twoDigitsSigned,s);case 3:return jc(id.threeDigitsSigned,s);case 4:return jc(id.fourDigitsSigned,s);default:return jc(new RegExp("^-?\\d{1,"+t+"}"),s)}}function X1e(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 D9e(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 O9e(t){return t%400===0||t%4===0&&t%100!==0}class x1t extends Bo{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 od(Zc(4,r),o);case"yo":return od(a.ordinalNumber(r,{unit:"year"}),o);default:return od(Zc(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=D9e(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 y1t extends Bo{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 od(Zc(4,r),o);case"Yo":return od(a.ordinalNumber(r,{unit:"year"}),o);default:return od(Zc(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a,o){const l=Z1e(r,o);if(a.isTwoDigitYear){const d=D9e(a.year,l);return r.setFullYear(d,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),ah(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),ah(r,o)}}class v1t extends Bo{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 dne(n==="R"?4:n.length,r)}set(r,n,a){const o=Yo(r,0);return o.setFullYear(a,0,4),o.setHours(0,0,0,0),K0(o)}}class _1t extends Bo{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 dne(n==="u"?4:n.length,r)}set(r,n,a){return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}class b1t extends Bo{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 Zc(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 w1t extends Bo{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 Zc(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 j1t extends Bo{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 od(jc(id.month,r),o);case"MM":return od(Zc(2,r),o);case"Mo":return od(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 k1t extends Bo{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 od(jc(id.month,r),o);case"LL":return od(Zc(2,r),o);case"Lo":return od(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 N1t(t,s,r){const n=Kn(t),a=Y1e(n,r)-s;return n.setDate(n.getDate()-a*7),n}class S1t extends Bo{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 jc(id.week,r);case"wo":return a.ordinalNumber(r,{unit:"week"});default:return Zc(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a,o){return ah(N1t(r,a,o),o)}}function C1t(t,s){const r=Kn(t),n=K1e(r)-s;return r.setDate(r.getDate()-n*7),r}class M1t extends Bo{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 jc(id.week,r);case"Io":return a.ordinalNumber(r,{unit:"week"});default:return Zc(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a){return K0(C1t(r,a))}}const T1t=[31,28,31,30,31,30,31,31,30,31,30,31],A1t=[31,29,31,30,31,30,31,31,30,31,30,31];class E1t extends Bo{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 jc(id.date,r);case"do":return a.ordinalNumber(r,{unit:"date"});default:return Zc(n.length,r)}}validate(r,n){const a=r.getFullYear(),o=O9e(a),l=r.getMonth();return o?n>=1&&n<=A1t[l]:n>=1&&n<=T1t[l]}set(r,n,a){return r.setDate(a),r.setHours(0,0,0,0),r}}class P1t extends Bo{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 jc(id.dayOfYear,r);case"Do":return a.ordinalNumber(r,{unit:"date"});default:return Zc(n.length,r)}}validate(r,n){const a=r.getFullYear();return O9e(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 Q1e(t,s,r){var g,v,_,b;const n=U_(),a=(r==null?void 0:r.weekStartsOn)??((v=(g=r==null?void 0:r.locale)==null?void 0:g.options)==null?void 0:v.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 hl(o,p)}class I1t extends Bo{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=Q1e(r,a,o),r.setHours(0,0,0,0),r}}class L1t extends Bo{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 od(Zc(n.length,r),l);case"eo":return od(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=Q1e(r,a,o),r.setHours(0,0,0,0),r}}class D1t extends Bo{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 od(Zc(n.length,r),l);case"co":return od(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=Q1e(r,a,o),r.setHours(0,0,0,0),r}}function O1t(t,s){const r=Kn(t),n=o1t(r),a=s-n;return hl(r,a)}class R1t extends Bo{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 Zc(n.length,r);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return od(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 od(a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return od(a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return od(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=O1t(r,a),r.setHours(0,0,0,0),r}}class F1t extends Bo{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(X1e(a),0,0,0),r}}class z1t extends Bo{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(X1e(a),0,0,0),r}}class B1t extends Bo{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(X1e(a),0,0,0),r}}class $1t extends Bo{constructor(){super(...arguments);_n(this,"priority",70);_n(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,a){switch(n){case"h":return jc(id.hour12h,r);case"ho":return a.ordinalNumber(r,{unit:"hour"});default:return Zc(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 q1t extends Bo{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 jc(id.hour23h,r);case"Ho":return a.ordinalNumber(r,{unit:"hour"});default:return Zc(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,a){return r.setHours(a,0,0,0),r}}class U1t extends Bo{constructor(){super(...arguments);_n(this,"priority",70);_n(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,a){switch(n){case"K":return jc(id.hour11h,r);case"Ko":return a.ordinalNumber(r,{unit:"hour"});default:return Zc(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 V1t extends Bo{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 jc(id.hour24h,r);case"ko":return a.ordinalNumber(r,{unit:"hour"});default:return Zc(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 H1t extends Bo{constructor(){super(...arguments);_n(this,"priority",60);_n(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"m":return jc(id.minute,r);case"mo":return a.ordinalNumber(r,{unit:"minute"});default:return Zc(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setMinutes(a,0,0),r}}class W1t extends Bo{constructor(){super(...arguments);_n(this,"priority",50);_n(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"s":return jc(id.second,r);case"so":return a.ordinalNumber(r,{unit:"second"});default:return Zc(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setSeconds(a,0),r}}class G1t extends Bo{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 od(Zc(n.length,r),a)}set(r,n,a){return r.setMilliseconds(a),r}}class K1t extends Bo{constructor(){super(...arguments);_n(this,"priority",10);_n(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return Lx(Ix.basicOptionalMinutes,r);case"XX":return Lx(Ix.basic,r);case"XXXX":return Lx(Ix.basicOptionalSeconds,r);case"XXXXX":return Lx(Ix.extendedOptionalSeconds,r);case"XXX":default:return Lx(Ix.extended,r)}}set(r,n,a){return n.timestampIsSet?r:Yo(r,r.getTime()-N_(r)-a)}}class Z1t extends Bo{constructor(){super(...arguments);_n(this,"priority",10);_n(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return Lx(Ix.basicOptionalMinutes,r);case"xx":return Lx(Ix.basic,r);case"xxxx":return Lx(Ix.basicOptionalSeconds,r);case"xxxxx":return Lx(Ix.extendedOptionalSeconds,r);case"xxx":default:return Lx(Ix.extended,r)}}set(r,n,a){return n.timestampIsSet?r:Yo(r,r.getTime()-N_(r)-a)}}class Y1t extends Bo{constructor(){super(...arguments);_n(this,"priority",40);_n(this,"incompatibleTokens","*")}parse(r){return L9e(r)}set(r,n,a){return[Yo(r,a*1e3),{timestampIsSet:!0}]}}class X1t extends Bo{constructor(){super(...arguments);_n(this,"priority",20);_n(this,"incompatibleTokens","*")}parse(r){return L9e(r)}set(r,n,a){return[Yo(r,a),{timestampIsSet:!0}]}}const Q1t={G:new g1t,y:new x1t,Y:new y1t,R:new v1t,u:new _1t,Q:new b1t,q:new w1t,M:new j1t,L:new k1t,w:new S1t,I:new M1t,d:new E1t,D:new P1t,E:new I1t,e:new L1t,c:new D1t,i:new R1t,a:new F1t,b:new z1t,B:new B1t,h:new $1t,H:new q1t,K:new U1t,k:new V1t,m:new H1t,s:new W1t,S:new G1t,X:new K1t,x:new Z1t,t:new Y1t,T:new X1t},J1t=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,e_t=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,t_t=/^'([^]*?)'?$/,s_t=/''/g,r_t=/\S/,n_t=/[a-zA-Z]/;function J1e(t,s,r,n){var j,w,N,C;const a=i1t(),o=a.locale??Moe,l=a.firstWeekContainsDate??((w=(j=a.locale)==null?void 0:j.options)==null?void 0:w.firstWeekContainsDate)??1,i=a.weekStartsOn??((C=(N=a.locale)==null?void 0:N.options)==null?void 0:C.weekStartsOn)??0;if(s==="")return t===""?Kn(r):Yo(r,NaN);const d={firstWeekContainsDate:l,weekStartsOn:i,locale:o},u=[new f1t],p=s.match(e_t).map(A=>{const I=A[0];if(I in Age){const L=Age[I];return L(A,o.formatLong)}return A}).join("").match(J1t),g=[];for(let A of p){P9e(A)&&Ege(A,s,t),E9e(A)&&Ege(A,s,t);const I=A[0],L=Q1t[I];if(L){const{incompatibleTokens:R}=L;if(Array.isArray(R)){const q=g.find(U=>R.includes(U.token)||U.token===I);if(q)throw new RangeError(`The format string mustn't contain \`${q.fullToken}\` and \`${A}\` at the same time`)}else if(L.incompatibleTokens==="*"&&g.length>0)throw new RangeError(`The format string mustn't contain \`${A}\` and any other token at the same time`);g.push({token:I,fullToken:A});const $=L.run(t,A,o.match,d);if(!$)return Yo(r,NaN);u.push($.setter),t=$.rest}else{if(I.match(n_t))throw new RangeError("Format string contains an unescaped latin alphabet character `"+I+"`");if(A==="''"?A="'":I==="'"&&(A=a_t(A)),t.indexOf(A)===0)t=t.slice(A.length);else return Yo(r,NaN)}}if(t.length>0&&r_t.test(t))return Yo(r,NaN);const v=u.map(A=>A.priority).sort((A,I)=>I-A).filter((A,I,L)=>L.indexOf(A)===I).map(A=>u.filter(I=>I.priority===A).sort((I,L)=>L.subPriority-I.subPriority)).map(A=>A[0]);let _=Kn(r);if(isNaN(_.getTime()))return Yo(r,NaN);const b={};for(const A of v){if(!A.validate(_,d))return Yo(r,NaN);const I=A.set(_,b,d);Array.isArray(I)?(_=I[0],Object.assign(b,I[1])):_=I}return Yo(r,_)}function a_t(t){return t.match(t_t)[1].replace(s_t,"'")}function Yx(t){return+Kn(t)o-l);return r>=n&&r<=a}function tre(t,s){return hl(t,-s)}function Th(t,s){const n=h_t(t);let a;if(n.date){const d=m_t(n.date,2);a=p_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=f_t(n.time),isNaN(l)))return new Date(NaN);if(n.timezone){if(i=g_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 L8={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},c_t=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,d_t=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,u_t=/^([+-])(\d{2})(?::?(\d{2}))?$/;function h_t(t){const s={},r=t.split(L8.dateTimeDelimiter);let n;if(r.length>2)return s;if(/:/.test(r[0])?n=r[0]:(s.date=r[0],n=r[1],L8.timeZoneDelimiter.test(s.date)&&(s.date=t.split(L8.timeZoneDelimiter)[0],n=t.substr(s.date.length,t.length))),n){const a=L8.timezone.exec(n);a?(s.time=n.replace(a[1],""),s.timezone=a[1]):s.time=n}return s}function m_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 p_t(t,s){if(s===null)return new Date(NaN);const r=t.match(c_t);if(!r)return new Date(NaN);const n=!!r[4],a=ZA(r[1]),o=ZA(r[2])-1,l=ZA(r[3]),i=ZA(r[4]),d=ZA(r[5])-1;if(n)return b_t(s,i,d)?x_t(s,i,d):new Date(NaN);{const u=new Date(0);return!v_t(s,o,l)||!__t(s,a)?new Date(NaN):(u.setUTCFullYear(s,o,Math.max(a,l)),u)}}function ZA(t){return t?parseInt(t):1}function f_t(t){const s=t.match(d_t);if(!s)return NaN;const r=Lhe(s[1]),n=Lhe(s[2]),a=Lhe(s[3]);return w_t(r,n,a)?r*kL+n*Soe+a*1e3:NaN}function Lhe(t){return t&&parseFloat(t.replace(",","."))||0}function g_t(t){if(t==="Z")return 0;const s=t.match(u_t);if(!s)return 0;const r=s[1]==="+"?-1:1,n=parseInt(s[2]),a=s[3]&&parseInt(s[3])||0;return j_t(n,a)?r*(n*kL+a*Soe):NaN}function x_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 y_t=[31,null,31,30,31,30,31,31,30,31,30,31];function R9e(t){return t%400===0||t%4===0&&t%100!==0}function v_t(t,s,r){return s>=0&&s<=11&&r>=1&&r<=(y_t[s]||(R9e(t)?29:28))}function __t(t,s){return s>=1&&s<=(R9e(t)?366:365)}function b_t(t,s,r){return s>=1&&s<=53&&r>=0&&r<=6}function w_t(t,s,r){return t===24?s===0&&r===0:r>=0&&r<60&&s>=0&&s<60&&t>=0&&t<25}function j_t(t,s){return s>=0&&s<=59}function Dhe(t,s){const r=Kn(t),n=r.getFullYear(),a=r.getDate(),o=Yo(t,0);o.setFullYear(n,s,15),o.setHours(0,0,0,0);const l=a1t(o);return r.setMonth(s,Math.min(a,l)),r}function qP(t,s){const r=Kn(t);return r.setHours(s),r}function UP(t,s){const r=Kn(t);return r.setMinutes(s),r}function O5e(t,s){const r=Kn(t);return isNaN(+r)?Yo(t,NaN):(r.setFullYear(s),r)}function Sk(t,s){return Vh(t,-s)}var Po;(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})(Po||(Po={}));var R5e;(function(t){t.mergeShapes=(s,r)=>({...s,...r})})(R5e||(R5e={}));const ra=Po.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),a1=t=>{switch(typeof t){case"undefined":return ra.undefined;case"string":return ra.string;case"number":return Number.isNaN(t)?ra.nan:ra.number;case"boolean":return ra.boolean;case"function":return ra.function;case"bigint":return ra.bigint;case"symbol":return ra.symbol;case"object":return Array.isArray(t)?ra.array:t===null?ra.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?ra.promise:typeof Map<"u"&&t instanceof Map?ra.map:typeof Set<"u"&&t instanceof Set?ra.set:typeof Date<"u"&&t instanceof Date?ra.date:ra.object;default:return ra.unknown}},tn=Po.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 sy 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()}}sy.create=t=>new sy(t);const Pge=(t,s)=>{let r;switch(t.code){case tn.invalid_type:t.received===ra.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case tn.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Po.jsonStringifyReplacer)}`;break;case tn.unrecognized_keys:r=`Unrecognized key(s) in object: ${Po.joinValues(t.keys,", ")}`;break;case tn.invalid_union:r="Invalid input";break;case tn.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Po.joinValues(t.options)}`;break;case tn.invalid_enum_value:r=`Invalid enum value. Expected ${Po.joinValues(t.options)}, received '${t.received}'`;break;case tn.invalid_arguments:r="Invalid function arguments";break;case tn.invalid_return_type:r="Invalid function return type";break;case tn.invalid_date:r="Invalid date";break;case tn.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}"`:Po.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case tn.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 tn.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 tn.custom:r="Invalid input";break;case tn.invalid_intersection_types:r="Intersection results could not be merged";break;case tn.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case tn.not_finite:r="Number must be finite";break;default:r=s.defaultError,Po.assertNever(t)}return{message:r}};let k_t=Pge;function N_t(){return k_t}const S_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 Un(t,s){const r=N_t(),n=S_t({issueData:s,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Pge?void 0:Pge].filter(a=>!!a)});t.common.issues.push(n)}class wp{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 Si;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 wp.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 Si;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 Si=Object.freeze({status:"aborted"}),SE=t=>({status:"dirty",value:t}),Tf=t=>({status:"valid",value:t}),F5e=t=>t.status==="aborted",z5e=t=>t.status==="dirty",h3=t=>t.status==="valid",une=t=>typeof Promise<"u"&&t instanceof Promise;var pa;(function(t){t.errToObj=s=>typeof s=="string"?{message:s}:s||{},t.toString=s=>typeof s=="string"?s:s==null?void 0:s.message})(pa||(pa={}));class S_{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 B5e=(t,s)=>{if(h3(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 sy(t.common.issues);return this._error=r,this._error}}};function Ki(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 Mo{get description(){return this._def.description}_getType(s){return a1(s.data)}_getOrReturnCtx(s,r){return r||{common:s.parent.common,data:s.data,parsedType:a1(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}_processInputParams(s){return{status:new wp,ctx:{common:s.parent.common,data:s.data,parsedType:a1(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const r=this._parse(s);if(une(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:a1(s)},a=this._parseSync({data:s,path:n.path,parent:n});return B5e(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:a1(s)};if(!this["~standard"].async)try{const o=this._parseSync({data:s,path:[],parent:r});return h3(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=>h3(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:a1(s)},a=this._parse({data:s,path:n.path,parent:n}),o=await(une(a)?a:Promise.resolve(a));return B5e(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:tn.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 f3({schema:this,typeName:Ci.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 d_.create(this,this._def)}nullable(){return g3.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Xx.create(this)}promise(){return fne.create(this,this._def)}or(s){return mne.create([this,s],this._def)}and(s){return pne.create(this,s,this._def)}transform(s){return new f3({...Ki(this._def),schema:this,typeName:Ci.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new Oge({...Ki(this._def),innerType:this,defaultValue:r,typeName:Ci.ZodDefault})}brand(){return new Z_t({typeName:Ci.ZodBranded,type:this,...Ki(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new Rge({...Ki(this._def),innerType:this,catchValue:r,typeName:Ci.ZodCatch})}describe(s){const r=this.constructor;return new r({...this._def,description:s})}pipe(s){return e_e.create(this,s)}readonly(){return Fge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const C_t=/^c[^\s-]{8,}$/i,M_t=/^[0-9a-z]+$/,T_t=/^[0-9A-HJKMNP-TV-Z]{26}$/i,A_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,E_t=/^[a-z0-9_-]{21}$/i,P_t=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,I_t=/^[-+]?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)?)??$/,L_t=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,D_t="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ohe;const O_t=/^(?:(?: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])$/,R_t=/^(?:(?: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])$/,F_t=/^(([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]))$/,z_t=/^(([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])$/,B_t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,$_t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,F9e="((\\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])))",q_t=new RegExp(`^${F9e}$`);function z9e(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 U_t(t){return new RegExp(`^${z9e(t)}$`)}function V_t(t){let s=`${F9e}T${z9e(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 H_t(t,s){return!!((s==="v4"||!s)&&O_t.test(t)||(s==="v6"||!s)&&F_t.test(t))}function W_t(t,s){if(!P_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 G_t(t,s){return!!((s==="v4"||!s)&&R_t.test(t)||(s==="v6"||!s)&&z_t.test(t))}class D1 extends Mo{_parse(s){if(this._def.coerce&&(s.data=String(s.data)),this._getType(s)!==ra.string){const o=this._getOrReturnCtx(s);return Un(o,{code:tn.invalid_type,expected:ra.string,received:o.parsedType}),Si}const n=new wp;let a;for(const o of this._def.checks)if(o.kind==="min")s.data.lengtho.value&&(a=this._getOrReturnCtx(s,a),Un(a,{code:tn.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:tn.invalid_string,...pa.errToObj(n)})}_addCheck(s){return new D1({...this._def,checks:[...this._def.checks,s]})}email(s){return this._addCheck({kind:"email",...pa.errToObj(s)})}url(s){return this._addCheck({kind:"url",...pa.errToObj(s)})}emoji(s){return this._addCheck({kind:"emoji",...pa.errToObj(s)})}uuid(s){return this._addCheck({kind:"uuid",...pa.errToObj(s)})}nanoid(s){return this._addCheck({kind:"nanoid",...pa.errToObj(s)})}cuid(s){return this._addCheck({kind:"cuid",...pa.errToObj(s)})}cuid2(s){return this._addCheck({kind:"cuid2",...pa.errToObj(s)})}ulid(s){return this._addCheck({kind:"ulid",...pa.errToObj(s)})}base64(s){return this._addCheck({kind:"base64",...pa.errToObj(s)})}base64url(s){return this._addCheck({kind:"base64url",...pa.errToObj(s)})}jwt(s){return this._addCheck({kind:"jwt",...pa.errToObj(s)})}ip(s){return this._addCheck({kind:"ip",...pa.errToObj(s)})}cidr(s){return this._addCheck({kind:"cidr",...pa.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,...pa.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,...pa.errToObj(s==null?void 0:s.message)})}duration(s){return this._addCheck({kind:"duration",...pa.errToObj(s)})}regex(s,r){return this._addCheck({kind:"regex",regex:s,...pa.errToObj(r)})}includes(s,r){return this._addCheck({kind:"includes",value:s,position:r==null?void 0:r.position,...pa.errToObj(r==null?void 0:r.message)})}startsWith(s,r){return this._addCheck({kind:"startsWith",value:s,...pa.errToObj(r)})}endsWith(s,r){return this._addCheck({kind:"endsWith",value:s,...pa.errToObj(r)})}min(s,r){return this._addCheck({kind:"min",value:s,...pa.errToObj(r)})}max(s,r){return this._addCheck({kind:"max",value:s,...pa.errToObj(r)})}length(s,r){return this._addCheck({kind:"length",value:s,...pa.errToObj(r)})}nonempty(s){return this.min(1,pa.errToObj(s))}trim(){return new D1({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new D1({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new D1({...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 D1({checks:[],typeName:Ci.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Ki(t)});function K_t(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 m3 extends Mo{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)!==ra.number){const o=this._getOrReturnCtx(s);return Un(o,{code:tn.invalid_type,expected:ra.number,received:o.parsedType}),Si}let n;const a=new wp;for(const o of this._def.checks)o.kind==="int"?Po.isInteger(s.data)||(n=this._getOrReturnCtx(s,n),Un(n,{code:tn.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),Un(n,{code:tn.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?K_t(s.data,o.value)!==0&&(n=this._getOrReturnCtx(s,n),Un(n,{code:tn.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(s.data)||(n=this._getOrReturnCtx(s,n),Un(n,{code:tn.not_finite,message:o.message}),a.dirty()):Po.assertNever(o);return{status:a.value,value:s.data}}gte(s,r){return this.setLimit("min",s,!0,pa.toString(r))}gt(s,r){return this.setLimit("min",s,!1,pa.toString(r))}lte(s,r){return this.setLimit("max",s,!0,pa.toString(r))}lt(s,r){return this.setLimit("max",s,!1,pa.toString(r))}setLimit(s,r,n,a){return new m3({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:pa.toString(a)}]})}_addCheck(s){return new m3({...this._def,checks:[...this._def.checks,s]})}int(s){return this._addCheck({kind:"int",message:pa.toString(s)})}positive(s){return this._addCheck({kind:"min",value:0,inclusive:!1,message:pa.toString(s)})}negative(s){return this._addCheck({kind:"max",value:0,inclusive:!1,message:pa.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:0,inclusive:!0,message:pa.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:0,inclusive:!0,message:pa.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:pa.toString(r)})}finite(s){return this._addCheck({kind:"finite",message:pa.toString(s)})}safe(s){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:pa.toString(s)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:pa.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"&&Po.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 m3({checks:[],typeName:Ci.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Ki(t)});class KI extends Mo{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)!==ra.bigint)return this._getInvalidInput(s);let n;const a=new wp;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),Un(n,{code:tn.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),Un(n,{code:tn.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):Po.assertNever(o);return{status:a.value,value:s.data}}_getInvalidInput(s){const r=this._getOrReturnCtx(s);return Un(r,{code:tn.invalid_type,expected:ra.bigint,received:r.parsedType}),Si}gte(s,r){return this.setLimit("min",s,!0,pa.toString(r))}gt(s,r){return this.setLimit("min",s,!1,pa.toString(r))}lte(s,r){return this.setLimit("max",s,!0,pa.toString(r))}lt(s,r){return this.setLimit("max",s,!1,pa.toString(r))}setLimit(s,r,n,a){return new KI({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:pa.toString(a)}]})}_addCheck(s){return new KI({...this._def,checks:[...this._def.checks,s]})}positive(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:pa.toString(s)})}negative(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:pa.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:pa.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:pa.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:pa.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 KI({checks:[],typeName:Ci.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Ki(t)});class Ige extends Mo{_parse(s){if(this._def.coerce&&(s.data=!!s.data),this._getType(s)!==ra.boolean){const n=this._getOrReturnCtx(s);return Un(n,{code:tn.invalid_type,expected:ra.boolean,received:n.parsedType}),Si}return Tf(s.data)}}Ige.create=t=>new Ige({typeName:Ci.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Ki(t)});class hne extends Mo{_parse(s){if(this._def.coerce&&(s.data=new Date(s.data)),this._getType(s)!==ra.date){const o=this._getOrReturnCtx(s);return Un(o,{code:tn.invalid_type,expected:ra.date,received:o.parsedType}),Si}if(Number.isNaN(s.data.getTime())){const o=this._getOrReturnCtx(s);return Un(o,{code:tn.invalid_date}),Si}const n=new wp;let a;for(const o of this._def.checks)o.kind==="min"?s.data.getTime()o.value&&(a=this._getOrReturnCtx(s,a),Un(a,{code:tn.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Po.assertNever(o);return{status:n.value,value:new Date(s.data.getTime())}}_addCheck(s){return new hne({...this._def,checks:[...this._def.checks,s]})}min(s,r){return this._addCheck({kind:"min",value:s.getTime(),message:pa.toString(r)})}max(s,r){return this._addCheck({kind:"max",value:s.getTime(),message:pa.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 hne({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Ci.ZodDate,...Ki(t)});class $5e extends Mo{_parse(s){if(this._getType(s)!==ra.symbol){const n=this._getOrReturnCtx(s);return Un(n,{code:tn.invalid_type,expected:ra.symbol,received:n.parsedType}),Si}return Tf(s.data)}}$5e.create=t=>new $5e({typeName:Ci.ZodSymbol,...Ki(t)});class q5e extends Mo{_parse(s){if(this._getType(s)!==ra.undefined){const n=this._getOrReturnCtx(s);return Un(n,{code:tn.invalid_type,expected:ra.undefined,received:n.parsedType}),Si}return Tf(s.data)}}q5e.create=t=>new q5e({typeName:Ci.ZodUndefined,...Ki(t)});class U5e extends Mo{_parse(s){if(this._getType(s)!==ra.null){const n=this._getOrReturnCtx(s);return Un(n,{code:tn.invalid_type,expected:ra.null,received:n.parsedType}),Si}return Tf(s.data)}}U5e.create=t=>new U5e({typeName:Ci.ZodNull,...Ki(t)});class V5e extends Mo{constructor(){super(...arguments),this._any=!0}_parse(s){return Tf(s.data)}}V5e.create=t=>new V5e({typeName:Ci.ZodAny,...Ki(t)});class H5e extends Mo{constructor(){super(...arguments),this._unknown=!0}_parse(s){return Tf(s.data)}}H5e.create=t=>new H5e({typeName:Ci.ZodUnknown,...Ki(t)});class C_ extends Mo{_parse(s){const r=this._getOrReturnCtx(s);return Un(r,{code:tn.invalid_type,expected:ra.never,received:r.parsedType}),Si}}C_.create=t=>new C_({typeName:Ci.ZodNever,...Ki(t)});class W5e extends Mo{_parse(s){if(this._getType(s)!==ra.undefined){const n=this._getOrReturnCtx(s);return Un(n,{code:tn.invalid_type,expected:ra.void,received:n.parsedType}),Si}return Tf(s.data)}}W5e.create=t=>new W5e({typeName:Ci.ZodVoid,...Ki(t)});class Xx extends Mo{_parse(s){const{ctx:r,status:n}=this._processInputParams(s),a=this._def;if(r.parsedType!==ra.array)return Un(r,{code:tn.invalid_type,expected:ra.array,received:r.parsedType}),Si;if(a.exactLength!==null){const l=r.data.length>a.exactLength.value,i=r.data.lengtha.maxLength.value&&(Un(r,{code:tn.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 S_(r,l,r.path,i)))).then(l=>wp.mergeArray(n,l));const o=[...r.data].map((l,i)=>a.type._parseSync(new S_(r,l,r.path,i)));return wp.mergeArray(n,o)}get element(){return this._def.type}min(s,r){return new Xx({...this._def,minLength:{value:s,message:pa.toString(r)}})}max(s,r){return new Xx({...this._def,maxLength:{value:s,message:pa.toString(r)}})}length(s,r){return new Xx({...this._def,exactLength:{value:s,message:pa.toString(r)}})}nonempty(s){return this.min(1,s)}}Xx.create=(t,s)=>new Xx({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Ci.ZodArray,...Ki(s)});function g4(t){if(t instanceof bd){const s={};for(const r in t.shape){const n=t.shape[r];s[r]=d_.create(g4(n))}return new bd({...t._def,shape:()=>s})}else return t instanceof Xx?new Xx({...t._def,type:g4(t.element)}):t instanceof d_?d_.create(g4(t.unwrap())):t instanceof g3?g3.create(g4(t.unwrap())):t instanceof PN?PN.create(t.items.map(s=>g4(s))):t}class bd extends Mo{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=Po.objectKeys(s);return this._cached={shape:s,keys:r},this._cached}_parse(s){if(this._getType(s)!==ra.object){const u=this._getOrReturnCtx(s);return Un(u,{code:tn.invalid_type,expected:ra.object,received:u.parsedType}),Si}const{status:n,ctx:a}=this._processInputParams(s),{shape:o,keys:l}=this._getCached(),i=[];if(!(this._def.catchall instanceof C_&&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],g=a.data[u];d.push({key:{status:"valid",value:u},value:p._parse(new S_(a,g,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof C_){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&&(Un(a,{code:tn.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 g=a.data[p];d.push({key:{status:"valid",value:p},value:u._parse(new S_(a,g,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of d){const g=await p.key,v=await p.value;u.push({key:g,value:v,alwaysSet:p.alwaysSet})}return u}).then(u=>wp.mergeObjectSync(n,u)):wp.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(s){return pa.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:pa.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:Ci.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 Po.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 Po.objectKeys(this.shape))s[n]||(r[n]=this.shape[n]);return new bd({...this._def,shape:()=>r})}deepPartial(){return g4(this)}partial(s){const r={};for(const n of Po.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 Po.objectKeys(this.shape))if(s&&!s[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof d_;)o=o._def.innerType;r[n]=o}return new bd({...this._def,shape:()=>r})}keyof(){return B9e(Po.objectKeys(this.shape))}}bd.create=(t,s)=>new bd({shape:()=>t,unknownKeys:"strip",catchall:C_.create(),typeName:Ci.ZodObject,...Ki(s)});bd.strictCreate=(t,s)=>new bd({shape:()=>t,unknownKeys:"strict",catchall:C_.create(),typeName:Ci.ZodObject,...Ki(s)});bd.lazycreate=(t,s)=>new bd({shape:t,unknownKeys:"strip",catchall:C_.create(),typeName:Ci.ZodObject,...Ki(s)});class mne extends Mo{_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 sy(i.ctx.common.issues));return Un(r,{code:tn.invalid_union,unionErrors:l}),Si}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 sy(d));return Un(r,{code:tn.invalid_union,unionErrors:i}),Si}}get options(){return this._def.options}}mne.create=(t,s)=>new mne({options:t,typeName:Ci.ZodUnion,...Ki(s)});function Lge(t,s){const r=a1(t),n=a1(s);if(t===s)return{valid:!0,data:t};if(r===ra.object&&n===ra.object){const a=Po.objectKeys(s),o=Po.objectKeys(t).filter(i=>a.indexOf(i)!==-1),l={...t,...s};for(const i of o){const d=Lge(t[i],s[i]);if(!d.valid)return{valid:!1};l[i]=d.data}return{valid:!0,data:l}}else if(r===ra.array&&n===ra.array){if(t.length!==s.length)return{valid:!1};const a=[];for(let o=0;o{if(F5e(o)||F5e(l))return Si;const i=Lge(o.value,l.value);return i.valid?((z5e(o)||z5e(l))&&r.dirty(),{status:r.value,value:i.data}):(Un(n,{code:tn.invalid_intersection_types}),Si)};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}))}}pne.create=(t,s,r)=>new pne({left:t,right:s,typeName:Ci.ZodIntersection,...Ki(r)});class PN extends Mo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ra.array)return Un(n,{code:tn.invalid_type,expected:ra.array,received:n.parsedType}),Si;if(n.data.lengththis._def.items.length&&(Un(n,{code:tn.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 S_(n,l,n.path,i)):null}).filter(l=>!!l);return n.common.async?Promise.all(o).then(l=>wp.mergeArray(r,l)):wp.mergeArray(r,o)}get items(){return this._def.items}rest(s){return new PN({...this._def,rest:s})}}PN.create=(t,s)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new PN({items:t,typeName:Ci.ZodTuple,rest:null,...Ki(s)})};class G5e extends Mo{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!==ra.map)return Un(n,{code:tn.invalid_type,expected:ra.map,received:n.parsedType}),Si;const a=this._def.keyType,o=this._def.valueType,l=[...n.data.entries()].map(([i,d],u)=>({key:a._parse(new S_(n,i,n.path,[u,"key"])),value:o._parse(new S_(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 Si;(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 Si;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}}}}G5e.create=(t,s,r)=>new G5e({valueType:s,keyType:t,typeName:Ci.ZodMap,...Ki(r)});class ZI extends Mo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ra.set)return Un(n,{code:tn.invalid_type,expected:ra.set,received:n.parsedType}),Si;const a=this._def;a.minSize!==null&&n.data.sizea.maxSize.value&&(Un(n,{code:tn.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 Si;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 S_(n,d,n.path,u)));return n.common.async?Promise.all(i).then(d=>l(d)):l(i)}min(s,r){return new ZI({...this._def,minSize:{value:s,message:pa.toString(r)}})}max(s,r){return new ZI({...this._def,maxSize:{value:s,message:pa.toString(r)}})}size(s,r){return this.min(s,r).max(s,r)}nonempty(s){return this.min(1,s)}}ZI.create=(t,s)=>new ZI({valueType:t,minSize:null,maxSize:null,typeName:Ci.ZodSet,...Ki(s)});class K5e extends Mo{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})}}K5e.create=(t,s)=>new K5e({getter:t,typeName:Ci.ZodLazy,...Ki(s)});class Dge extends Mo{_parse(s){if(s.data!==this._def.value){const r=this._getOrReturnCtx(s);return Un(r,{received:r.data,code:tn.invalid_literal,expected:this._def.value}),Si}return{status:"valid",value:s.data}}get value(){return this._def.value}}Dge.create=(t,s)=>new Dge({value:t,typeName:Ci.ZodLiteral,...Ki(s)});function B9e(t,s){return new p3({values:t,typeName:Ci.ZodEnum,...Ki(s)})}class p3 extends Mo{_parse(s){if(typeof s.data!="string"){const r=this._getOrReturnCtx(s),n=this._def.values;return Un(r,{expected:Po.joinValues(n),received:r.parsedType,code:tn.invalid_type}),Si}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 Un(r,{received:r.data,code:tn.invalid_enum_value,options:n}),Si}return Tf(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 p3.create(s,{...this._def,...r})}exclude(s,r=this._def){return p3.create(this.options.filter(n=>!s.includes(n)),{...this._def,...r})}}p3.create=B9e;class Z5e extends Mo{_parse(s){const r=Po.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(s);if(n.parsedType!==ra.string&&n.parsedType!==ra.number){const a=Po.objectValues(r);return Un(n,{expected:Po.joinValues(a),received:n.parsedType,code:tn.invalid_type}),Si}if(this._cache||(this._cache=new Set(Po.getValidEnumValues(this._def.values))),!this._cache.has(s.data)){const a=Po.objectValues(r);return Un(n,{received:n.data,code:tn.invalid_enum_value,options:a}),Si}return Tf(s.data)}get enum(){return this._def.values}}Z5e.create=(t,s)=>new Z5e({values:t,typeName:Ci.ZodNativeEnum,...Ki(s)});class fne extends Mo{unwrap(){return this._def.type}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==ra.promise&&r.common.async===!1)return Un(r,{code:tn.invalid_type,expected:ra.promise,received:r.parsedType}),Si;const n=r.parsedType===ra.promise?r.data:Promise.resolve(r.data);return Tf(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}fne.create=(t,s)=>new fne({type:t,typeName:Ci.ZodPromise,...Ki(s)});class f3 extends Mo{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ci.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=>{Un(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 Si;const d=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return d.status==="aborted"?Si:d.status==="dirty"||r.value==="dirty"?SE(d.value):d});{if(r.value==="aborted")return Si;const i=this._def.schema._parseSync({data:l,path:n.path,parent:n});return i.status==="aborted"?Si:i.status==="dirty"||r.value==="dirty"?SE(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"?Si:(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"?Si:(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(!h3(l))return Si;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=>h3(l)?Promise.resolve(a.transform(l.value,o)).then(i=>({status:r.value,value:i})):Si);Po.assertNever(a)}}f3.create=(t,s,r)=>new f3({schema:t,typeName:Ci.ZodEffects,effect:s,...Ki(r)});f3.createWithPreprocess=(t,s,r)=>new f3({schema:s,effect:{type:"preprocess",transform:t},typeName:Ci.ZodEffects,...Ki(r)});class d_ extends Mo{_parse(s){return this._getType(s)===ra.undefined?Tf(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}d_.create=(t,s)=>new d_({innerType:t,typeName:Ci.ZodOptional,...Ki(s)});class g3 extends Mo{_parse(s){return this._getType(s)===ra.null?Tf(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}g3.create=(t,s)=>new g3({innerType:t,typeName:Ci.ZodNullable,...Ki(s)});class Oge extends Mo{_parse(s){const{ctx:r}=this._processInputParams(s);let n=r.data;return r.parsedType===ra.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Oge.create=(t,s)=>new Oge({innerType:t,typeName:Ci.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...Ki(s)});class Rge extends Mo{_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 une(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new sy(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new sy(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Rge.create=(t,s)=>new Rge({innerType:t,typeName:Ci.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...Ki(s)});class Y5e extends Mo{_parse(s){if(this._getType(s)!==ra.nan){const n=this._getOrReturnCtx(s);return Un(n,{code:tn.invalid_type,expected:ra.nan,received:n.parsedType}),Si}return{status:"valid",value:s.data}}}Y5e.create=t=>new Y5e({typeName:Ci.ZodNaN,...Ki(t)});class Z_t extends Mo{_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 e_e extends Mo{_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"?Si:o.status==="dirty"?(r.dirty(),SE(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"?Si: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 e_e({in:s,out:r,typeName:Ci.ZodPipeline})}}class Fge extends Mo{_parse(s){const r=this._def.innerType._parse(s),n=a=>(h3(a)&&(a.value=Object.freeze(a.value)),a);return une(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}Fge.create=(t,s)=>new Fge({innerType:t,typeName:Ci.ZodReadonly,...Ki(s)});var Ci;(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"})(Ci||(Ci={}));const Yl=D1.create,VP=m3.create,Y_t=Ige.create;C_.create;Xx.create;const eS=bd.create;mne.create;pne.create;PN.create;const gne=Dge.create,$9e=p3.create;fne.create;d_.create;g3.create;const Tr=S.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{className:Et("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}));Tr.displayName="Textarea";const X_t=["Excellent","Good","Neutral","Bad","Very Bad"],Q_t=[5,4,3,2,1];function J_t({questions:t,visitorId:s,onComplete:r,onSkip:n}){const a=$0t(),[o,l]=S.useState({}),i=t.filter(v=>v.question_type==="rating"),d=t.filter(v=>v.question_type!=="rating"),u=(v,_)=>{l(b=>({...b,[v]:{rating_value:_}}))},p=(v,_)=>{l(b=>({...b,[v]:{text_value:_}}))},g=async()=>{const v=Object.entries(o).filter(([,_])=>_.rating_value!=null||_.text_value&&_.text_value.trim()).map(([_,b])=>{var j;return{visitor_id:s,question_id:_,rating_value:b.rating_value??null,text_value:((j=b.text_value)==null?void 0:j.trim())||null}});if(v.length>0)try{await a.mutateAsync(v)}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"}),X_t.map(v=>e.jsx("div",{className:"w-12 text-center",children:e.jsx("span",{className:"text-[10px] text-slate-400 leading-tight block",children:v})},v))]}),i.map(v=>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:v.question_text}),Q_t.map(_=>{var b;return e.jsx("div",{className:"w-12 flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>u(v.id,_),className:`w-6 h-6 rounded-full border-2 transition-all ${((b=o[v.id])==null?void 0:b.rating_value)===_?"bg-slate-900 border-slate-900":"border-slate-300 hover:border-slate-500"}`})},_)})]},v.id))]}),d.map(v=>{var _;return e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 block mb-1",children:v.question_text}),e.jsx(Tr,{value:((_=o[v.id])==null?void 0:_.text_value)||"",onChange:b=>p(v.id,b.target.value),placeholder:"Your thoughts...",className:"h-16 text-sm resize-none rounded-xl border-slate-200"})]},v.id)}),e.jsx(K,{onClick:g,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(As,{className:"h-5 w-5 animate-spin"}):"Submit Feedback"})]})}const ebt=eS({first_name:Yl().trim().min(1,"First name is required").max(50),last_name:Yl().trim().max(50).optional(),email:Yl().trim().email("Please enter a valid email").max(255).optional().or(gne("")),phone:Yl().trim().max(20).optional().or(gne(""))}),tbt=[{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 q9e({slug:t}={}){var ie;const s=Co(),r=t||s.slug,{data:n,isLoading:a,error:o}=F0t(r),l=G0t(),[i,d]=S.useState("welcome"),[u,p]=S.useState(null),[g,v]=S.useState({first_name:"",last_name:"",email:"",phone:""}),[_,b]=S.useState(""),[j,w]=S.useState(!1),[N,C]=S.useState(!1),[A,I]=S.useState(""),[L,R]=S.useState(""),{data:$,isLoading:q}=B0t(n==null?void 0:n.id),U=!!(n!=null&&n.enable_survey);S.useEffect(()=>{i==="pending_survey"&&(q||d(U&&(($==null?void 0:$.length)??0)>0?"survey":"done"))},[i,q,U,$]);const V=ae=>{if(!ae)return"";const[le,pe]=ae.split(":"),be=parseInt(le),ye=be>=12?"PM":"AM";return`${be>12?be-12:be||12}:${pe} ${ye}`},X=()=>{R("");const ae=ebt.safeParse(g);if(!ae.success){R(ae.error.issues[0].message);return}if(!g.email&&!g.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:g.first_name.trim(),last_name:g.last_name.trim()||void 0,email:g.email.trim()||void 0,phone:g.phone.trim()||void 0,visitor_intent:ae,wants_market_updates:j,has_agent:N,working_with_agent_name:N&&A.trim()?A.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(Vn,{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,Y=((ie=te==null?void 0:te.name)==null?void 0:ie.split(" ").map(ae=>ae[0]).join("").slice(0,2))||"?",de=n.event_type==="community";return e.jsxs(e.Fragment,{children:[e.jsxs(nh,{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(fn,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[e.jsx(Ma,{src:(te==null?void 0:te.avatar_url)||"",alt:(te==null?void 0:te.name)||""}),e.jsx(gn,{className:"bg-white/10 text-white text-lg",children:Y})]}),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(Ti,{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"}),ws(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(In,{className:"h-3 w-3"}),V(n.start_time),n.end_time?` – ${V(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(Ca,{className:"h-5 w-5 text-white"}):e.jsx(Vn,{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(Ti,{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"}),ws(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(In,{className:"h-3 w-3"}),V(n.start_time),n.end_time?` – ${V(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(Ui,{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(Ka,{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:g.first_name,onChange:ae=>v(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:g.last_name,onChange:ae=>v(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:g.email,onChange:ae=>v(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:g.phone,onChange:ae=>v(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:j,onChange:ae=>w(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:N?"Yes":"No"}),e.jsx(Br,{checked:N,onCheckedChange:C})]})]}),N&&e.jsx(Re,{value:A,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:X,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",e.jsx(Ui,{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(Ka,{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:tbt.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(J_t,{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(la,{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, ",g.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 sbt(){const s=xu().pathname.slice(1);return S.useEffect(()=>(document.body.classList.add("guestbook-page"),()=>{document.body.classList.remove("guestbook-page")}),[]),!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(q9e,{slug:s})}function rbt({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(Vn,{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(Ti,{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(Zn,{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(pc,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Text"})]})]})})})]})}function nbt({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(Ui,{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 X5e(t){const s=t.split(/[-/T]/);return new Date(Number(s[0]),Number(s[1])-1,Number(s[2]))}function obt(t,s){const r=ws(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 lbt(t,s){const r=ws(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 cbt({targetCloseDate:t,contractDate:s,inspectionDate:r,appraisalDate:n,actualCloseDate:a}){const o=[{label:"Contract Date",date:s,icon:i5,color:"text-blue-600 bg-blue-50"},{label:"Inspection",date:r,icon:xn,color:"text-amber-600 bg-amber-50"},{label:"Appraisal",date:n,icon:Vn,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=X5e(d);if(u==="google")window.open(obt(i,p),"_blank");else{const g=lbt(i,p),v=document.createElement("a");v.href=g,v.download=`${i.replace(/\s+/g,"-").toLowerCase()}.ics`,v.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 g=X5e(d),v=Yx(g)&&!zd(g),_=zd(g),b=!v&&!_;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":v?"text-slate-400":"text-slate-800"}`,children:[ws(g,"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"})]})]}),v&&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(Y1,{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 dbt({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(Sn,{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(gi,{className:"w-4 h-4 text-slate-300 group-hover:text-blue-500 transition-colors"})]},n.id))})]})}function ubt({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(Vc,{className:"w-3.5 h-3.5 text-emerald-600"}):e.jsx(cf,{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:ws(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 hbt({portal:t,dealData:s,agentProfile:r,customQuestions:n,deviceFingerprint:a,onComplete:o}){var b,j;const[l,i]=S.useState({first_name:((b=t.client_name)==null?void 0:b.split(" ")[0])||"",last_name:((j=t.client_name)==null?void 0:j.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]=S.useState({}),[p,g]=S.useState(!1),v=Ot({mutationFn:async()=>{const{error:w}=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(w)throw w},onSuccess:o,onError:w=>{console.error("[PortalOnboarding] Submit failed:",w),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(Ti,{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:w=>{w.preventDefault(),v.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:w=>i(N=>({...N,first_name:w.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:w=>i(N=>({...N,last_name:w.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:w=>i(N=>({...N,email:w.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:w=>i(N=>({...N,phone:w.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(w=>e.jsx("button",{type:"button",onClick:()=>i(N=>({...N,preferred_contact_method:w.value})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.preferred_contact_method===w.value?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:w.label},w.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(w=>e.jsx("button",{type:"button",onClick:()=>i(N=>({...N,client_role:w})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.client_role===w?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:w.charAt(0).toUpperCase()+w.slice(1)},w))})]}),n.map(w=>e.jsxs("div",{children:[e.jsxs(ve,{className:"text-xs text-slate-600",children:[w.question_text," ",w.is_required&&"*"]}),w.field_type==="text"&&e.jsx(Re,{required:w.is_required,value:d[w.id]||"",onChange:N=>u(C=>({...C,[w.id]:N.target.value})),className:"mt-1 rounded-xl"}),w.field_type==="textarea"&&e.jsx("textarea",{required:w.is_required,value:d[w.id]||"",onChange:N=>u(C=>({...C,[w.id]:N.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"}),w.field_type==="dropdown"&&e.jsxs("select",{required:w.is_required,value:d[w.id]||"",onChange:N=>u(C=>({...C,[w.id]:N.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..."}),(w.options||[]).map(N=>e.jsx("option",{value:N,children:N},N))]}),w.field_type==="toggle"&&e.jsx("div",{className:"mt-1.5 flex gap-2",children:["Yes","No"].map(N=>e.jsx("button",{type:"button",onClick:()=>u(C=>({...C,[w.id]:N})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${d[w.id]===N?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200"}`,children:N},N))})]},w.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:w=>i(N=>({...N,notes:w.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:()=>g(!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:w=>i(N=>({...N,spouse_first_name:w.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:w=>i(N=>({...N,spouse_last_name:w.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:w=>i(N=>({...N,spouse_email:w.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:w=>i(N=>({...N,spouse_phone:w.target.value})),className:"mt-1 rounded-xl"})]})]})]}),e.jsx(K,{type:"submit",disabled:v.isPending||!l.first_name,className:"w-full h-12 rounded-full text-sm font-semibold bg-slate-900 hover:bg-slate-800",children:v.isPending?"Submitting...":"Access My Portal"})]})]})}function mbt(t){return t==="buy-side"?"Home Search in Progress":t==="listing"?"Your Home Is On The Market":"Active Phase"}function pbt(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 fbt={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. 🎉"}},U9e=["Lead","Consultation","Agreement Signed","Active","Under Contract","Closing","Closed Won"];function t_e(t){return U9e.map(s=>{if(s==="Active")return{key:"Active",label:mbt(t),description:pbt(t)};const r=fbt[s];return{key:s,label:r.label,description:r.description}})}function Q5e(t){if(!t)return 0;const s=U9e.indexOf(t);return s>=0?s:0}function gbt(t,s){return Ct({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 xbt(t){return Ct({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 V9e({slug:t}){var te,Y,de,ie,ae,le;const[s,r]=S.useState(!1),[n,a]=S.useState("primary"),[o]=S.useState(()=>{const pe=`portal_fp_${t}`;let be=localStorage.getItem(pe);return be||(be=localStorage.getItem("portal_fp"),be?localStorage.setItem(pe,be):(be=crypto.randomUUID(),localStorage.setItem(pe,be),localStorage.setItem("portal_fp",be))),be});S.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:l,isLoading:i,error:d}=gbt(t,!0),u=l==null?void 0:l.linked_portal_id,{data:p}=xbt(u),g=(te=l==null?void 0:l.deal_pipeline)==null?void 0:te.owner_user_id,{data:v}=Ct({queryKey:["portal-stages",g],queryFn:async()=>{const{data:pe,error:be}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",g).order("sort_order",{ascending:!0});if(be)throw be;return pe},enabled:!!g}),{data:_}=Ct({queryKey:["portal-agent",g],queryFn:async()=>{const{data:pe,error:be}=await G.from("profiles").select("id, name, avatar_url, phone, email").eq("id",g).single();if(be)throw be;return pe},enabled:!!g}),b=n==="linked"&&p?p:l,j=b==null?void 0:b.id,{data:w}=Ct({queryKey:["portal-updates-public",j],queryFn:async()=>{const{data:pe,error:be}=await G.from("portal_updates").select("*").eq("portal_id",j).order("created_at",{ascending:!1});if(be)throw be;return pe},enabled:!!j}),N=(Y=b==null?void 0:b.deal_pipeline)==null?void 0:Y.id,{data:C}=Ct({queryKey:["portal-documents",N],queryFn:async()=>{const{data:pe,error:be}=await G.from("deal_files").select("*").eq("deal_id",N).eq("visible_on_portal",!0).order("created_at",{ascending:!1});if(be)throw be;return pe},enabled:!!N}),A=l==null?void 0:l.id,{data:I,isLoading:L}=Ct({queryKey:["portal-onboarding-check",A,o],queryFn:async()=>{const{data:pe,error:be}=await G.from("portal_onboarding_submissions").select("id").eq("portal_id",A).eq("device_fingerprint",o).maybeSingle();if(be)throw be;return pe},enabled:!!A&&!!(l!=null&&l.require_onboarding)}),{data:R}=Ct({queryKey:["portal-custom-questions-public",g],queryFn:async()=>{const{data:pe,error:be}=await G.from("portal_custom_questions").select("*").eq("owner_user_id",g).eq("is_active",!0).order("sort_order",{ascending:!0});if(be)throw be;return pe},enabled:!!g&&!!(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(gs,{className:"h-48 w-full rounded-2xl"}),e.jsx(gs,{className:"h-10 w-48 mx-auto"}),e.jsx(gs,{className:"h-32 w-full rounded-2xl"}),e.jsx(gs,{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 pe=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(hbt,{portal:l,dealData:pe,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=(ie=p==null?void 0:p.deal_pipeline)==null?void 0:ie.deal_type,V=!!p,X=pe=>pe==="listing"?"Your Sale":pe==="buy-side"?"Your Purchase":"Transaction",se=pe=>pe==="listing"?e.jsx(Vn,{className:"w-3.5 h-3.5"}):e.jsx(Em,{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(rbt,{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:[V&&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),X(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),X(U)]})]}),e.jsx(ybt,{portal:b,updates:w,documents:C}),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(sh,{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 ybt({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=t_e(i);d&&d.length>0&&(u=d.map((_,b)=>{var j,w;return{key:`custom-${b}`,label:_.label||((j=u[b])==null?void 0:j.label)||`Stage ${b+1}`,description:_.description||((w=u[b])==null?void 0:w.description)||"",video_url:_.video_url||void 0}}));const p=d&&d.length>0?Math.min(Q5e(o==null?void 0:o.name),u.length-1):Q5e(o==null?void 0:o.name),g=u[p],v=g==null?void 0:g.video_url;return e.jsxs(e.Fragment,{children:[e.jsx(abt,{targetCloseDate:a==null?void 0:a.target_close_date,actualCloseDate:a==null?void 0:a.actual_close_date,clientName:t.client_name}),e.jsx(nbt,{journeyStages:u,currentIndex:p}),g&&e.jsx(ibt,{currentStage:g,nextStepText:t.next_step_text,nextStepVideoUrl:v||t.next_step_video_url}),e.jsx(cbt,{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(dbt,{documents:r}),s&&s.length>0&&e.jsx(ubt,{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 vbt(){const s=xu().pathname.slice(1);return S.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(V9e,{slug:s})}const zge="levelup_affiliate_ref",_bt=30,bbt=()=>{const[t]=Ac();S.useEffect(()=>{const s=t.get("ref");if(s){const r={code:s.toUpperCase(),timestamp:Date.now()};localStorage.setItem(zge,JSON.stringify(r)),console.log("[Affiliate] Stored referral code:",s)}},[t])},wbt=()=>{try{const t=localStorage.getItem(zge);if(!t)return null;const s=JSON.parse(t),r=_bt*24*60*60*1e3;return Date.now()-s.timestamp>r?(localStorage.removeItem(zge),console.log("[Affiliate] Referral code expired"),null):s.code}catch{return null}},xne="/assets/levelup-logo-header-_ZX7DvlA.png",jbt="/assets/scale-your-team-ku4MPatU.png";function kbt({open:t,onOpenChange:s}){return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Cs,{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(Ca,{className:"h-5 w-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Ss,{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 su={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"]}},Nbt=[{icon:gm,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:Rl,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:pc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:Sn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:ao,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],Sbt=[{icon:hr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:mn,title:"Smart Touchpoint Plans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Zn,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Ou,title:"Birthday & Anniversary Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Ti,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:Xo,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Ni,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Lm,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],Cbt=[{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."}],Mbt=()=>{const{user:t,loading:s}=Gs(),r=Lr(),[n]=Ac();S.useEffect(()=>{const $=window.location.host==="listings.relevelup.com",q=window.location.pathname==="/";if($&&q){r("/public/listings",{replace:!0});return}},[r]);const[a,o]=S.useState(null),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,g]=S.useState(""),[v,_]=S.useState(""),[b,j]=S.useState(""),[w,N]=S.useState(!1),[C,A]=S.useState(!1),I=($,q=!1)=>{i({tier:$,skipTrial:q}),u(!0)};bbt(),S.useEffect(()=>{const $=window.location.host==="listings.relevelup.com",q=location.pathname.startsWith("/public/");!s&&t&&!$&&!q&&r("/dashboard")},[t,s,r,location.pathname]),S.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(!v.trim()){fe.error("Please enter your full name");return}N(!0),o($+(q?"_direct":""));const U=wbt();try{const{data:V,error:X}=await G.functions.invoke("create-checkout",{body:{tier:$,email:p,name:v.trim(),couponCode:b.trim()||void 0,skipTrial:q,referralCode:U}});if(X)throw X;if(V!=null&&V.url)window.open(V.url,"_blank","noopener,noreferrer"),fe.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(V){console.error("Checkout error:",V),fe.error(V.message||"Failed to start checkout. Please try again.")}finally{N(!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:xne,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(Ui,{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(Ca,{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:Nbt.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(Lt,{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(zt,{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(mn,{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:Sbt.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(Lt,{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(zt,{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(Ui,{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(Ca,{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(fa,{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(qa,{className:"ml-2 w-5 h-5"})]}),e.jsxs(K,{size:"lg",variant:"outline",onClick:()=>A(!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:jbt,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:Cbt.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(Ui,{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(Lt,{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(zt,{className:"text-xl font-sans",children:su.individual_agent.name})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:su.individual_agent.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:su.individual_agent.period})]}),e.jsx(yr,{className:"text-base mt-2",children:su.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(In,{className:"w-4 h-4"}),su.individual_agent.trial]})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:su.individual_agent.features.map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(fa,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},q))})}),e.jsxs($P,{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(Lt,{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(Ca,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-xl font-sans",children:su.brokerage_under_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:su.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:su.brokerage_under_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:su.brokerage_under_25.period})]}),e.jsx(yr,{className:"text-base mt-2",children:su.brokerage_under_25.description})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:su.brokerage_under_25.features.map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(fa,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},q))})}),e.jsx($P,{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(Lt,{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(Ca,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-xl font-sans",children:su.brokerage_over_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:su.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:su.brokerage_over_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:su.brokerage_over_25.period})]}),e.jsx(yr,{className:"text-base mt-2",children:su.brokerage_over_25.description})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:su.brokerage_over_25.features.map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(fa,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},q))})}),e.jsx($P,{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(Ui,{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:xne,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(kbt,{open:C,onOpenChange:A}),e.jsx(vs,{open:d,onOpenChange:u,children:e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:v,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:$=>g($.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:$=>j($.target.value),className:"mt-1"})]})]}),e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:R,disabled:w,children:w?"Loading...":"Continue to Checkout"})]})})]})},Tbt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(nh,{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"})]})]})]})]})})]}),Abt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(nh,{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"})]})]})]})]})})]}),Ebt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(nh,{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"})]})]})]})]})})]}),Pbt=eS({email:Yl().email("Invalid email address"),password:Yl().min(6,"Password must be at least 6 characters")}),Ibt=()=>{const{signIn:t,user:s}=Gs(),r=Lr(),[n,a]=S.useState(!1),[o,l]=S.useState({}),[i,d]=S.useState(""),[u,p]=S.useState(!1),[g,v]=S.useState(!1);S.useEffect(()=>{s&&r("/dashboard")},[s,r]);const _=async j=>{j.preventDefault(),l({}),a(!0);const w=new FormData(j.currentTarget),N=w.get("email"),C=w.get("password");try{Pbt.parse({email:N,password:C}),await t(N,C)}catch(A){if(A instanceof sy){const I={};A.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:j}=await G.functions.invoke("send-password-reset",{body:{email:i,redirectTo:"https://dashboard.relevelup.com/profile?reset=true"}});if(j)throw j;fe.success("Password reset email sent! Check your inbox."),v(!1),d("")}catch(j){fe.error(j.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(Ka,{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:_Be,alt:"LevelUp",className:"h-12 w-auto"})})}),e.jsxs(Ee,{className:"border-0 shadow-2xl bg-white/95 backdrop-blur-sm",children:[e.jsxs(Lt,{className:"space-y-1 text-center pb-4",children:[e.jsx(zt,{className:"text-3xl font-bold text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Welcome Back"}),e.jsx(yr,{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(vs,{open:g,onOpenChange:v,children:[e.jsx(Ai,{asChild:!0,children:e.jsx(K,{variant:"link",className:"w-full text-sm text-[#4a6b6d] hover:text-[#3d5a5c]",children:"Forgot password?"})}),e.jsxs(ys,{className:"bg-white",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:j=>d(j.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"})]})]})})]})]})},Lbt=()=>{const[t]=Ac(),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(Lt,{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(fi,{className:"w-10 h-10 text-green-500"})}),e.jsx(zt,{className:"text-2xl",children:"Welcome to LevelUp!"}),e.jsx(yr,{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."})})]})]})})},H9e=t=>{const[s,r]=S.useState(null),[n,a]=S.useState(!0);return S.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)}}}},W9e=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},Dbt=t=>{const[s,r]=S.useState({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!0});return S.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)),g=p<=0;r({isTrial:!0,isExpired:g,expiresAt:a.subscription_end_date,daysLeft:g?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)),g=p<=0;r({isTrial:!0,isExpired:g,expiresAt:a.trial_expires_at,daysLeft:g?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},G9e=()=>{const{data:t,isLoading:s}=Ct({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")}},J5e="community_last_seen_post_at";function Obt(){const{user:t}=Gs(),s=xu(),[r,n]=S.useState(0),[a,o]=S.useState(null);S.useEffect(()=>{if(!t)return;const i=localStorage.getItem(`${J5e}_${t.id}`);o(i)},[t]),S.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:g}=await d;!g&&p!==null&&n(p)})()},[t,a]),S.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(j=>j+1);const{data:g}=await G.from("profiles").select("name").eq("id",u.user_id).single(),v=(g==null?void 0:g.name)||"Someone",_=u.content.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),b=_.length>50?_.substring(0,50)+"...":_;p||fe("New Community Post",{description:`${v}: ${b}`,action:{label:"View",onClick:()=>{window.location.href="/community"}}})}).subscribe();return()=>{G.removeChannel(i)}},[t,s.pathname]);const l=S.useCallback(()=>{if(!t)return;const i=new Date().toISOString();localStorage.setItem(`${J5e}_${t.id}`,i),o(i),n(0)},[t]);return S.useEffect(()=>{s.pathname==="/community"&&r>0&&l()},[s.pathname,r,l]),{unreadCount:r,markAsRead:l}}function Rbt(){const{isAdmin:t}=Gs(),{data:s=0}=Ct({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 fM=goe,s_e=$1e,Fbt=xoe,K9e=S.forwardRef(({className:t,...s},r)=>e.jsx(hM,{className:Et("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}));K9e.displayName=hM.displayName;const zbt=ZN("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"}}),tS=S.forwardRef(({side:t="right",className:s,children:r,...n},a)=>e.jsxs(Fbt,{children:[e.jsx(K9e,{}),e.jsxs(mM,{ref:a,className:Et(zbt({side:t}),s),...n,children:[r,e.jsxs(wL,{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"})]})]})]}));tS.displayName=mM.displayName;const gM=({className:t,...s})=>e.jsx("div",{className:Et("flex flex-col space-y-2 text-center sm:text-left",t),...s});gM.displayName="SheetHeader";const xM=S.forwardRef(({className:t,...s},r)=>e.jsx(_L,{ref:r,className:Et("text-lg font-semibold text-foreground",t),...s}));xM.displayName=_L.displayName;const Z9e=S.forwardRef(({className:t,...s},r)=>e.jsx(bL,{ref:r,className:Et("text-sm text-muted-foreground",t),...s}));Z9e.displayName=bL.displayName;function Bbt(t,s){return S.useReducer((r,n)=>s[r][n]??r,t)}var r_e="ScrollArea",[Y9e]=Tc(r_e),[$bt,Af]=Y9e(r_e),X9e=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=t,[i,d]=S.useState(null),[u,p]=S.useState(null),[g,v]=S.useState(null),[_,b]=S.useState(null),[j,w]=S.useState(null),[N,C]=S.useState(0),[A,I]=S.useState(0),[L,R]=S.useState(!1),[$,q]=S.useState(!1),U=Aa(s,X=>d(X)),V=z_(a);return e.jsx($bt,{scope:r,type:n,dir:V,scrollHideDelay:o,scrollArea:i,viewport:u,onViewportChange:p,content:g,onContentChange:v,scrollbarX:_,onScrollbarXChange:b,scrollbarXEnabled:L,onScrollbarXEnabledChange:R,scrollbarY:j,onScrollbarYChange:w,scrollbarYEnabled:$,onScrollbarYEnabledChange:q,onCornerWidthChange:C,onCornerHeightChange:I,children:e.jsx(Qr.div,{dir:V,...l,ref:U,style:{position:"relative","--radix-scroll-area-corner-width":N+"px","--radix-scroll-area-corner-height":A+"px",...t.style}})})});X9e.displayName=r_e;var Q9e="ScrollAreaViewport",J9e=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,children:n,nonce:a,...o}=t,l=Af(Q9e,r),i=S.useRef(null),d=Aa(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})})]})});J9e.displayName=Q9e;var hy="ScrollAreaScrollbar",n_e=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Af(hy,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=a,i=t.orientation==="horizontal";return S.useEffect(()=>(i?o(!0):l(!0),()=>{i?o(!1):l(!1)}),[i,o,l]),a.type==="hover"?e.jsx(qbt,{...n,ref:s,forceMount:r}):a.type==="scroll"?e.jsx(Ubt,{...n,ref:s,forceMount:r}):a.type==="auto"?e.jsx(e$e,{...n,ref:s,forceMount:r}):a.type==="always"?e.jsx(a_e,{...n,ref:s}):null});n_e.displayName=hy;var qbt=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Af(hy,t.__scopeScrollArea),[o,l]=S.useState(!1);return S.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(e$e,{"data-state":o?"visible":"hidden",...n,ref:s})})}),Ubt=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Af(hy,t.__scopeScrollArea),o=t.orientation==="horizontal",l=Eoe(()=>d("SCROLL_END"),100),[i,d]=Bbt("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 S.useEffect(()=>{if(i==="idle"){const u=window.setTimeout(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,a.scrollHideDelay,d]),S.useEffect(()=>{const u=a.viewport,p=o?"scrollLeft":"scrollTop";if(u){let g=u[p];const v=()=>{const _=u[p];g!==_&&(d("SCROLL"),l()),g=_};return u.addEventListener("scroll",v),()=>u.removeEventListener("scroll",v)}},[a.viewport,o,d,l]),e.jsx(ud,{present:r||i!=="hidden",children:e.jsx(a_e,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:s,onPointerEnter:Mr(t.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Mr(t.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),e$e=S.forwardRef((t,s)=>{const r=Af(hy,t.__scopeScrollArea),{forceMount:n,...a}=t,[o,l]=S.useState(!1),i=t.orientation==="horizontal",d=Eoe(()=>{if(r.viewport){const u=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,a=Af(hy,t.__scopeScrollArea),o=S.useRef(null),l=S.useRef(0),[i,d]=S.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=a$e(i.viewport,i.content),p={...n,sizes:i,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:v=>o.current=v,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:v=>l.current=v};function g(v,_){return Zbt(v,l.current,i,_)}return r==="horizontal"?e.jsx(Vbt,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const v=a.viewport.scrollLeft,_=e3e(v,i,a.dir);o.current.style.transform=`translate3d(${_}px, 0, 0)`}},onWheelScroll:v=>{a.viewport&&(a.viewport.scrollLeft=v)},onDragScroll:v=>{a.viewport&&(a.viewport.scrollLeft=g(v,a.dir))}}):r==="vertical"?e.jsx(Hbt,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const v=a.viewport.scrollTop,_=e3e(v,i);o.current.style.transform=`translate3d(0, ${_}px, 0)`}},onWheelScroll:v=>{a.viewport&&(a.viewport.scrollTop=v)},onDragScroll:v=>{a.viewport&&(a.viewport.scrollTop=g(v))}}):null}),Vbt=S.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Af(hy,t.__scopeScrollArea),[l,i]=S.useState(),d=S.useRef(null),u=Aa(s,d,o.onScrollbarXChange);return S.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),e.jsx(s$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":Aoe(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.x),onDragScroll:p=>t.onDragScroll(p.x),onWheelScroll:(p,g)=>{if(o.viewport){const v=o.viewport.scrollLeft+p.deltaX;t.onWheelScroll(v),o$e(v,g)&&p.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:vne(l.paddingLeft),paddingEnd:vne(l.paddingRight)}})}})}),Hbt=S.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Af(hy,t.__scopeScrollArea),[l,i]=S.useState(),d=S.useRef(null),u=Aa(s,d,o.onScrollbarYChange);return S.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),e.jsx(s$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":Aoe(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.y),onDragScroll:p=>t.onDragScroll(p.y),onWheelScroll:(p,g)=>{if(o.viewport){const v=o.viewport.scrollTop+p.deltaY;t.onWheelScroll(v),o$e(v,g)&&p.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:vne(l.paddingTop),paddingEnd:vne(l.paddingBottom)}})}})}),[Wbt,t$e]=Y9e(hy),s$e=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:i,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:p,onResize:g,...v}=t,_=Af(hy,r),[b,j]=S.useState(null),w=Aa(s,U=>j(U)),N=S.useRef(null),C=S.useRef(""),A=_.viewport,I=n.content-n.viewport,L=Uc(p),R=Uc(d),$=Eoe(g,10);function q(U){if(N.current){const V=U.clientX-N.current.left,X=U.clientY-N.current.top;u({x:V,y:X})}}return S.useEffect(()=>{const U=V=>{const X=V.target;(b==null?void 0:b.contains(X))&&L(V,I)};return document.addEventListener("wheel",U,{passive:!1}),()=>document.removeEventListener("wheel",U,{passive:!1})},[A,b,I,L]),S.useEffect(R,[n,R]),x3(b,$),x3(_.content,$),e.jsx(Wbt,{scope:r,scrollbar:b,hasThumb:a,onThumbChange:Uc(o),onThumbPointerUp:Uc(l),onThumbPositionChange:R,onThumbPointerDown:Uc(i),children:e.jsx(Qr.div,{...v,ref:w,style:{position:"absolute",...v.style},onPointerDown:Mr(t.onPointerDown,U=>{U.button===0&&(U.target.setPointerCapture(U.pointerId),N.current=b.getBoundingClientRect(),C.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 V=U.target;V.hasPointerCapture(U.pointerId)&&V.releasePointerCapture(U.pointerId),document.body.style.webkitUserSelect=C.current,_.viewport&&(_.viewport.style.scrollBehavior=""),N.current=null})})})}),yne="ScrollAreaThumb",r$e=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=t$e(yne,t.__scopeScrollArea);return e.jsx(ud,{present:r||a.hasThumb,children:e.jsx(Gbt,{ref:s,...n})})}),Gbt=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,style:n,...a}=t,o=Af(yne,r),l=t$e(yne,r),{onThumbPositionChange:i}=l,d=Aa(s,g=>l.onThumbChange(g)),u=S.useRef(void 0),p=Eoe(()=>{u.current&&(u.current(),u.current=void 0)},100);return S.useEffect(()=>{const g=o.viewport;if(g){const v=()=>{if(p(),!u.current){const _=Ybt(g,i);u.current=_,i()}};return i(),g.addEventListener("scroll",v),()=>g.removeEventListener("scroll",v)}},[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,g=>{const _=g.target.getBoundingClientRect(),b=g.clientX-_.left,j=g.clientY-_.top;l.onThumbPointerDown({x:b,y:j})}),onPointerUp:Mr(t.onPointerUp,l.onThumbPointerUp)})});r$e.displayName=yne;var i_e="ScrollAreaCorner",n$e=S.forwardRef((t,s)=>{const r=Af(i_e,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?e.jsx(Kbt,{...t,ref:s}):null});n$e.displayName=i_e;var Kbt=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,...n}=t,a=Af(i_e,r),[o,l]=S.useState(0),[i,d]=S.useState(0),u=!!(o&&i);return x3(a.scrollbarX,()=>{var g;const p=((g=a.scrollbarX)==null?void 0:g.offsetHeight)||0;a.onCornerHeightChange(p),d(p)}),x3(a.scrollbarY,()=>{var g;const p=((g=a.scrollbarY)==null?void 0:g.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 vne(t){return t?parseInt(t,10):0}function a$e(t,s){const r=t/s;return isNaN(r)?0:r}function Aoe(t){const s=a$e(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*s;return Math.max(n,18)}function Zbt(t,s,r,n="ltr"){const a=Aoe(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,g=n==="ltr"?[0,p]:[p*-1,0];return i$e([d,u],g)(t)}function e3e(t,s,r="ltr"){const n=Aoe(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=GI(t,d);return i$e([0,l],[0,i])(u)}function i$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 o$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 Eoe(t,s){const r=Uc(t),n=S.useRef(0);return S.useEffect(()=>()=>window.clearTimeout(n.current),[]),S.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,s)},[r,s])}function x3(t,s){const r=Uc(s);Kc(()=>{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 l$e=X9e,Xbt=J9e,Qbt=n$e;const Fi=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(l$e,{ref:n,className:Et("relative overflow-hidden",t),...r,children:[e.jsx(Xbt,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(Poe,{}),e.jsx(Qbt,{})]}));Fi.displayName=l$e.displayName;const Poe=S.forwardRef(({className:t,orientation:s="vertical",...r},n)=>e.jsx(n_e,{ref:n,orientation:s,className:Et("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(r$e,{className:"relative flex-1 rounded-full bg-border"})}));Poe.displayName=n_e.displayName;var Ioe="Collapsible",[Jbt]=Tc(Ioe),[ewt,o_e]=Jbt(Ioe),c$e=S.forwardRef((t,s)=>{const{__scopeCollapsible:r,open:n,defaultOpen:a,disabled:o,onOpenChange:l,...i}=t,[d,u]=fu({prop:n,defaultProp:a??!1,onChange:l,caller:Ioe});return e.jsx(ewt,{scope:r,disabled:o,contentId:Hd(),open:d,onOpenToggle:S.useCallback(()=>u(p=>!p),[u]),children:e.jsx(Qr.div,{"data-state":c_e(d),"data-disabled":o?"":void 0,...i,ref:s})})});c$e.displayName=Ioe;var d$e="CollapsibleTrigger",u$e=S.forwardRef((t,s)=>{const{__scopeCollapsible:r,...n}=t,a=o_e(d$e,r);return e.jsx(Qr.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":c_e(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:s,onClick:Mr(t.onClick,a.onOpenToggle)})});u$e.displayName=d$e;var l_e="CollapsibleContent",h$e=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=o_e(l_e,t.__scopeCollapsible);return e.jsx(ud,{present:r||a.open,children:({present:o})=>e.jsx(twt,{...n,ref:s,present:o})})});h$e.displayName=l_e;var twt=S.forwardRef((t,s)=>{const{__scopeCollapsible:r,present:n,children:a,...o}=t,l=o_e(l_e,r),[i,d]=S.useState(n),u=S.useRef(null),p=Aa(s,u),g=S.useRef(0),v=g.current,_=S.useRef(0),b=_.current,j=l.open||i,w=S.useRef(j),N=S.useRef(void 0);return S.useEffect(()=>{const C=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(C)},[]),Kc(()=>{const C=u.current;if(C){N.current=N.current||{transitionDuration:C.style.transitionDuration,animationName:C.style.animationName},C.style.transitionDuration="0s",C.style.animationName="none";const A=C.getBoundingClientRect();g.current=A.height,_.current=A.width,w.current||(C.style.transitionDuration=N.current.transitionDuration,C.style.animationName=N.current.animationName),d(n)}},[l.open,n]),e.jsx(Qr.div,{"data-state":c_e(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!j,...o,ref:p,style:{"--radix-collapsible-content-height":v?`${v}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...t.style},children:j&&a})});function c_e(t){return t?"open":"closed"}var swt=c$e;const mf=swt,pf=u$e,ff=h$e,rwt="/assets/levelup-logo-Eif24dqY.png",nwt="/assets/levelup-logo-icon-C-7iromj.png",awt="/assets/levelup-logo-mobile-B9skSjUG.png";var NL=t=>t.type==="checkbox",Ck=t=>t instanceof Date,Ch=t=>t==null;const m$e=t=>typeof t=="object";var dd=t=>!Ch(t)&&!Array.isArray(t)&&m$e(t)&&!Ck(t),p$e=t=>dd(t)&&t.target?NL(t.target)?t.target.checked:t.target.value:t,iwt=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,f$e=(t,s)=>t.has(iwt(s)),owt=t=>{const s=t.constructor&&t.constructor.prototype;return dd(s)&&s.hasOwnProperty("isPrototypeOf")},d_e=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Ld(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(!(d_e&&(t instanceof Blob||n))&&(r||dd(t)))if(s=r?[]:{},!r&&!owt(t))s=t;else for(const a in t)t.hasOwnProperty(a)&&(s[a]=Ld(t[a]));else return t;return s}var Loe=t=>/^\w*$/.test(t),sd=t=>t===void 0,u_e=t=>Array.isArray(t)?t.filter(Boolean):[],h_e=t=>u_e(t.replace(/["|']|\]/g,"").split(/\.|\[/)),bn=(t,s,r)=>{if(!s||!dd(t))return r;const n=(Loe(s)?[s]:h_e(s)).reduce((a,o)=>Ch(a)?a:a[o],t);return sd(n)||n===t?sd(t[s])?r:t[s]:n},rp=t=>typeof t=="boolean",Ko=(t,s,r)=>{let n=-1;const a=Loe(s)?[s]:h_e(s),o=a.length,l=o-1;for(;++nht.useContext(m_e),lwt=t=>{const{children:s,...r}=t;return ht.createElement(m_e.Provider,{value:r},s)};var g$e=(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]!==Sg.all&&(s._proxyFormState[l]=!n||Sg.all),r&&(r[l]=!0),t[l]}});return a};const p_e=typeof window<"u"?ht.useLayoutEffect:ht.useEffect;function cwt(t){const s=Doe(),{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 p_e(()=>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(()=>g$e(l,r,d.current,!1),[l,r])}var Ox=t=>typeof t=="string",x$e=(t,s,r,n,a)=>Ox(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),Bge=t=>Ch(t)||!m$e(t);function h0(t,s,r=new WeakSet){if(Bge(t)||Bge(s))return t===s;if(Ck(t)&&Ck(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(Ck(l)&&Ck(i)||dd(l)&&dd(i)||Array.isArray(l)&&Array.isArray(i)?!h0(l,i,r):l!==i)return!1}}return!0}function dwt(t){const s=Doe(),{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 g=ht.useMemo(()=>r._getWatch(n,d.current),[r,n]),[v,_]=ht.useState(u.current?u.current(g):g);return p_e(()=>r._subscribe({name:n,formState:{values:!0},exact:l,callback:b=>{if(!o){const j=x$e(n,r._names,b.values||r._formValues,!1,d.current);if(u.current){const w=u.current(j);h0(w,p.current)||(_(w),p.current=w)}else _(j)}}}),[r,o,n,l]),ht.useEffect(()=>r._removeUnmounted()),v}function uwt(t){const s=Doe(),{name:r,disabled:n,control:a=s.control,shouldUnregister:o,defaultValue:l}=t,i=f$e(a._names.array,r),d=ht.useMemo(()=>bn(a._formValues,r,bn(a._defaultValues,r,l)),[a,r,l]),u=dwt({control:a,name:r,defaultValue:d,exact:!0}),p=cwt({control:a,name:r,exact:!0}),g=ht.useRef(t),v=ht.useRef(a.register(r,{...t.rules,value:u,...rp(t.disabled)?{disabled:t.disabled}:{}}));g.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(C=>v.current.onChange({target:{value:p$e(C),name:r},type:_ne.CHANGE}),[r]),j=ht.useCallback(()=>v.current.onBlur({target:{value:bn(a._formValues,r),name:r},type:_ne.BLUR}),[r,a._formValues]),w=ht.useCallback(C=>{const A=bn(a._fields,r);A&&C&&(A._f.ref={focus:()=>C.focus&&C.focus(),select:()=>C.select&&C.select(),setCustomValidity:I=>C.setCustomValidity(I),reportValidity:()=>C.reportValidity()})},[a._fields,r]),N=ht.useMemo(()=>({name:r,value:u,...rp(n)||p.disabled?{disabled:p.disabled||n}:{},onChange:b,onBlur:j,ref:w}),[r,n,p.disabled,b,j,w,u]);return ht.useEffect(()=>{const C=a._options.shouldUnregister||o;a.register(r,{...g.current.rules,...rp(g.current.disabled)?{disabled:g.current.disabled}:{}});const A=(I,L)=>{const R=bn(a._fields,I);R&&R._f&&(R._f.mount=L)};if(A(r,!0),C){const I=Ld(bn(a._options.defaultValues,r));Ko(a._defaultValues,r,I),sd(bn(a._formValues,r))&&Ko(a._formValues,r,I)}return!i&&a.register(r),()=>{(i?C&&!a._state.action:C)?a.unregister(r):A(r,!1)}},[r,a,i,o]),ht.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),ht.useMemo(()=>({field:N,formState:p,fieldState:_}),[N,p,_])}const hwt=t=>t.render(uwt(t));var y$e=(t,s,r,n,a)=>s?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:a||!0}}:{},HP=t=>Array.isArray(t)?t:[t],t3e=()=>{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=[]}}},mm=t=>dd(t)&&!Object.keys(t).length,f_e=t=>t.type==="file",Cg=t=>typeof t=="function",bne=t=>{if(!d_e)return!1;const s=t?t.ownerDocument:0;return t instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},v$e=t=>t.type==="select-multiple",g_e=t=>t.type==="radio",mwt=t=>g_e(t)||NL(t),Rhe=t=>bne(t)&&t.isConnected;function pwt(t,s){const r=s.slice(0,-1).length;let n=0;for(;n{for(const s in t)if(Cg(t[s]))return!0;return!1};function wne(t,s={}){const r=Array.isArray(t);if(dd(t)||r)for(const n in t)Array.isArray(t[n])||dd(t[n])&&!_$e(t[n])?(s[n]=Array.isArray(t[n])?[]:{},wne(t[n],s[n])):Ch(t[n])||(s[n]=!0);return s}function b$e(t,s,r){const n=Array.isArray(t);if(dd(t)||n)for(const a in t)Array.isArray(t[a])||dd(t[a])&&!_$e(t[a])?sd(s)||Bge(r[a])?r[a]=Array.isArray(t[a])?wne(t[a],[]):{...wne(t[a])}:b$e(t[a],Ch(s)?{}:s[a],r[a]):r[a]=!h0(t[a],s[a]);return r}var YA=(t,s)=>b$e(t,s,wne(s));const s3e={value:!1,isValid:!1},r3e={value:!0,isValid:!0};var w$e=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===""?r3e:{value:t[0].value,isValid:!0}:r3e:s3e}return s3e},j$e=(t,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>sd(t)?t:s?t===""?NaN:t&&+t:r&&Ox(t)?new Date(t):n?n(t):t;const n3e={isValid:!1,value:null};var k$e=t=>Array.isArray(t)?t.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,n3e):n3e;function a3e(t){const s=t.ref;return f_e(s)?s.files:g_e(s)?k$e(t.refs).value:v$e(s)?[...s.selectedOptions].map(({value:r})=>r):NL(s)?w$e(t.refs).value:j$e(sd(s.value)?t.ref.value:s.value,t)}var gwt=(t,s,r,n)=>{const a={};for(const o of t){const l=bn(s,o);l&&Ko(a,o,l._f)}return{criteriaMode:r,names:[...t],fields:a,shouldUseNativeValidation:n}},jne=t=>t instanceof RegExp,XA=t=>sd(t)?t:jne(t)?t.source:dd(t)?jne(t.value)?t.value.source:t.value:t,i3e=t=>({isOnSubmit:!t||t===Sg.onSubmit,isOnBlur:t===Sg.onBlur,isOnChange:t===Sg.onChange,isOnAll:t===Sg.all,isOnTouch:t===Sg.onTouched});const o3e="AsyncFunction";var xwt=t=>!!t&&!!t.validate&&!!(Cg(t.validate)&&t.validate.constructor.name===o3e||dd(t.validate)&&Object.values(t.validate).find(s=>s.constructor.name===o3e)),ywt=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),l3e=(t,s,r)=>!r&&(s.watchAll||s.watch.has(t)||[...s.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const WP=(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(WP(i,s))break}else if(dd(i)&&WP(i,s))break}}};function c3e(t,s,r){const n=bn(t,r);if(n||Loe(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 vwt=(t,s,r,n)=>{r(t);const{name:a,...o}=t;return mm(o)||Object.keys(o).length>=Object.keys(s).length||Object.keys(o).find(l=>s[l]===(!n||Sg.all))},_wt=(t,s,r)=>!t||!s||t===s||HP(t).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n))),bwt=(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,wwt=(t,s)=>!u_e(bn(t,s)).length&&yd(t,s),jwt=(t,s,r)=>{const n=HP(bn(t,r));return Ko(n,"root",s[r]),Ko(t,r,n),t},sre=t=>Ox(t);function d3e(t,s,r="validate"){if(sre(t)||Array.isArray(t)&&t.every(sre)||rp(t)&&!t)return{type:r,message:sre(t)?t:"",ref:s}}var t4=t=>dd(t)&&!jne(t)?t:{value:t,message:""},u3e=async(t,s,r,n,a,o)=>{const{ref:l,refs:i,required:d,maxLength:u,minLength:p,min:g,max:v,pattern:_,validate:b,name:j,valueAsNumber:w,mount:N}=t._f,C=bn(r,j);if(!N||s.has(j))return{};const A=i?i[0]:l,I=se=>{a&&A.reportValidity&&(A.setCustomValidity(rp(se)?"":se||""),A.reportValidity())},L={},R=g_e(l),$=NL(l),q=R||$,U=(w||f_e(l))&&sd(l.value)&&sd(C)||bne(l)&&l.value===""||C===""||Array.isArray(C)&&!C.length,V=y$e.bind(null,j,n,L),X=(se,te,Y,de=Uy.maxLength,ie=Uy.minLength)=>{const ae=se?te:Y;L[j]={type:se?de:ie,message:ae,ref:l,...V(se?de:ie,ae)}};if(o?!Array.isArray(C)||!C.length:d&&(!q&&(U||Ch(C))||rp(C)&&!C||$&&!w$e(i).isValid||R&&!k$e(i).isValid)){const{value:se,message:te}=sre(d)?{value:!!d,message:d}:t4(d);if(se&&(L[j]={type:Uy.required,message:te,ref:A,...V(Uy.required,te)},!n))return I(te),L}if(!U&&(!Ch(g)||!Ch(v))){let se,te;const Y=t4(v),de=t4(g);if(!Ch(C)&&!isNaN(C)){const ie=l.valueAsNumber||C&&+C;Ch(Y.value)||(se=ie>Y.value),Ch(de.value)||(te=ienew Date(new Date().toDateString()+" "+be),le=l.type=="time",pe=l.type=="week";Ox(Y.value)&&C&&(se=le?ae(C)>ae(Y.value):pe?C>Y.value:ie>new Date(Y.value)),Ox(de.value)&&C&&(te=le?ae(C)+se.value,de=!Ch(te.value)&&C.length<+te.value;if((Y||de)&&(X(Y,se.message,te.message),!n))return I(L[j].message),L}if(_&&!U&&Ox(C)){const{value:se,message:te}=t4(_);if(jne(se)&&!C.match(se)&&(L[j]={type:Uy.pattern,message:te,ref:l,...V(Uy.pattern,te)},!n))return I(te),L}if(b){if(Cg(b)){const se=await b(C,r),te=d3e(se,A);if(te&&(L[j]={...te,...V(Uy.validate,te.message)},!n))return I(te.message),L}else if(dd(b)){let se={};for(const te in b){if(!mm(se)&&!n)break;const Y=d3e(await b[te](C,r),A,te);Y&&(se={...Y,...V(te,Y.message)},I(Y.message),n&&(L[j]=se))}if(!mm(se)&&(L[j]={ref:A,...se},!n))return L}}return I(!0),L};const kwt={mode:Sg.onSubmit,reValidateMode:Sg.onChange,shouldFocusError:!0};function Nwt(t={}){let s={...kwt,...t},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:Cg(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)?Ld(s.defaultValues||s.values)||{}:{},o=s.shouldUnregister?{}:Ld(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 g={...p};const v={array:t3e(),state:t3e()},_=s.criteriaMode===Sg.all,b=qe=>lt=>{clearTimeout(u),u=setTimeout(qe,lt)},j=async qe=>{if(!s.disabled&&(p.isValid||g.isValid||qe)){const lt=s.resolver?mm((await $()).errors):await U(n,!0);lt!==r.isValid&&v.state.next({isValid:lt})}},w=(qe,lt)=>{!s.disabled&&(p.isValidating||p.validatingFields||g.isValidating||g.validatingFields)&&((qe||Array.from(i.mount)).forEach(We=>{We&&(lt?Ko(r.validatingFields,We,lt):yd(r.validatingFields,We))}),v.state.next({validatingFields:r.validatingFields,isValidating:!mm(r.validatingFields)}))},N=(qe,lt=[],We,Ye,mt=!0,Ze=!0)=>{if(Ye&&We&&!s.disabled){if(l.action=!0,Ze&&Array.isArray(bn(n,qe))){const He=We(bn(n,qe),Ye.argA,Ye.argB);mt&&Ko(n,qe,He)}if(Ze&&Array.isArray(bn(r.errors,qe))){const He=We(bn(r.errors,qe),Ye.argA,Ye.argB);mt&&Ko(r.errors,qe,He),wwt(r.errors,qe)}if((p.touchedFields||g.touchedFields)&&Ze&&Array.isArray(bn(r.touchedFields,qe))){const He=We(bn(r.touchedFields,qe),Ye.argA,Ye.argB);mt&&Ko(r.touchedFields,qe,He)}(p.dirtyFields||g.dirtyFields)&&(r.dirtyFields=YA(a,o)),v.state.next({name:qe,isDirty:X(qe,lt),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Ko(o,qe,lt)},C=(qe,lt)=>{Ko(r.errors,qe,lt),v.state.next({errors:r.errors})},A=qe=>{r.errors=qe,v.state.next({errors:r.errors,isValid:!1})},I=(qe,lt,We,Ye)=>{const mt=bn(n,qe);if(mt){const Ze=bn(o,qe,sd(We)?bn(a,qe):We);sd(Ze)||Ye&&Ye.defaultChecked||lt?Ko(o,qe,lt?Ze:a3e(mt._f)):Y(qe,Ze),l.mount&&j()}},L=(qe,lt,We,Ye,mt)=>{let Ze=!1,He=!1;const et={name:qe};if(!s.disabled){if(!We||Ye){(p.isDirty||g.isDirty)&&(He=r.isDirty,r.isDirty=et.isDirty=X(),Ze=He!==et.isDirty);const Rt=h0(bn(a,qe),lt);He=!!bn(r.dirtyFields,qe),Rt?yd(r.dirtyFields,qe):Ko(r.dirtyFields,qe,!0),et.dirtyFields=r.dirtyFields,Ze=Ze||(p.dirtyFields||g.dirtyFields)&&He!==!Rt}if(We){const Rt=bn(r.touchedFields,qe);Rt||(Ko(r.touchedFields,qe,We),et.touchedFields=r.touchedFields,Ze=Ze||(p.touchedFields||g.touchedFields)&&Rt!==We)}Ze&&mt&&v.state.next(et)}return Ze?et:{}},R=(qe,lt,We,Ye)=>{const mt=bn(r.errors,qe),Ze=(p.isValid||g.isValid)&&rp(lt)&&r.isValid!==lt;if(s.delayError&&We?(d=b(()=>C(qe,We)),d(s.delayError)):(clearTimeout(u),d=null,We?Ko(r.errors,qe,We):yd(r.errors,qe)),(We?!h0(mt,We):mt)||!mm(Ye)||Ze){const He={...Ye,...Ze&&rp(lt)?{isValid:lt}:{},errors:r.errors,name:qe};r={...r,...He},v.state.next(He)}},$=async qe=>{w(qe,!0);const lt=await s.resolver(o,s.context,gwt(qe||i.mount,n,s.criteriaMode,s.shouldUseNativeValidation));return w(qe),lt},q=async qe=>{const{errors:lt}=await $(qe);if(qe)for(const We of qe){const Ye=bn(lt,We);Ye?Ko(r.errors,We,Ye):yd(r.errors,We)}else r.errors=lt;return lt},U=async(qe,lt,We={valid:!0})=>{for(const Ye in qe){const mt=qe[Ye];if(mt){const{_f:Ze,...He}=mt;if(Ze){const et=i.array.has(Ze.name),Rt=mt._f&&xwt(mt._f);Rt&&p.validatingFields&&w([Ye],!0);const qt=await u3e(mt,i.disabled,o,_,s.shouldUseNativeValidation&&!lt,et);if(Rt&&p.validatingFields&&w([Ye]),qt[Ze.name]&&(We.valid=!1,lt))break;!lt&&(bn(qt,Ze.name)?et?jwt(r.errors,qt,Ze.name):Ko(r.errors,Ze.name,qt[Ze.name]):yd(r.errors,Ze.name))}!mm(He)&&await U(He,lt,We)}}return We.valid},V=()=>{for(const qe of i.unMount){const lt=bn(n,qe);lt&&(lt._f.refs?lt._f.refs.every(We=>!Rhe(We)):!Rhe(lt._f.ref))&&Te(qe)}i.unMount=new Set},X=(qe,lt)=>!s.disabled&&(qe&<&&Ko(o,qe,lt),!h0(be(),a)),se=(qe,lt,We)=>x$e(qe,i,{...l.mount?o:sd(lt)?a:Ox(qe)?{[qe]:lt}:lt},We,lt),te=qe=>u_e(bn(l.mount?o:a,qe,s.shouldUnregister?bn(a,qe,[]):[])),Y=(qe,lt,We={})=>{const Ye=bn(n,qe);let mt=lt;if(Ye){const Ze=Ye._f;Ze&&(!Ze.disabled&&Ko(o,qe,j$e(lt,Ze)),mt=bne(Ze.ref)&&Ch(lt)?"":lt,v$e(Ze.ref)?[...Ze.ref.options].forEach(He=>He.selected=mt.includes(He.value)):Ze.refs?NL(Ze.ref)?Ze.refs.forEach(He=>{(!He.defaultChecked||!He.disabled)&&(Array.isArray(mt)?He.checked=!!mt.find(et=>et===He.value):He.checked=mt===He.value||!!mt)}):Ze.refs.forEach(He=>He.checked=He.value===mt):f_e(Ze.ref)?Ze.ref.value="":(Ze.ref.value=mt,Ze.ref.type||v.state.next({name:qe,values:Ld(o)})))}(We.shouldDirty||We.shouldTouch)&&L(qe,mt,We.shouldTouch,We.shouldDirty,!0),We.shouldValidate&&pe(qe)},de=(qe,lt,We)=>{for(const Ye in lt){if(!lt.hasOwnProperty(Ye))return;const mt=lt[Ye],Ze=qe+"."+Ye,He=bn(n,Ze);(i.array.has(qe)||dd(mt)||He&&!He._f)&&!Ck(mt)?de(Ze,mt,We):Y(Ze,mt,We)}},ie=(qe,lt,We={})=>{const Ye=bn(n,qe),mt=i.array.has(qe),Ze=Ld(lt);Ko(o,qe,Ze),mt?(v.array.next({name:qe,values:Ld(o)}),(p.isDirty||p.dirtyFields||g.isDirty||g.dirtyFields)&&We.shouldDirty&&v.state.next({name:qe,dirtyFields:YA(a,o),isDirty:X(qe,Ze)})):Ye&&!Ye._f&&!Ch(Ze)?de(qe,Ze,We):Y(qe,Ze,We),l3e(qe,i)&&v.state.next({...r,name:qe}),v.state.next({name:l.mount?qe:void 0,values:Ld(o)})},ae=async qe=>{l.mount=!0;const lt=qe.target;let We=lt.name,Ye=!0;const mt=bn(n,We),Ze=Rt=>{Ye=Number.isNaN(Rt)||Ck(Rt)&&isNaN(Rt.getTime())||h0(Rt,bn(o,We,Rt))},He=i3e(s.mode),et=i3e(s.reValidateMode);if(mt){let Rt,qt;const ls=lt.type?a3e(mt._f):p$e(qe),Kt=qe.type===_ne.BLUR||qe.type===_ne.FOCUS_OUT,Qt=!ywt(mt._f)&&!s.resolver&&!bn(r.errors,We)&&!mt._f.deps||bwt(Kt,bn(r.touchedFields,We),r.isSubmitted,et,He),fs=l3e(We,i,Kt);Ko(o,We,ls),Kt?(mt._f.onBlur&&mt._f.onBlur(qe),d&&d(0)):mt._f.onChange&&mt._f.onChange(qe);const dr=L(We,ls,Kt),bt=!mm(dr)||fs;if(!Kt&&v.state.next({name:We,type:qe.type,values:Ld(o)}),Qt)return(p.isValid||g.isValid)&&(s.mode==="onBlur"?Kt&&j():Kt||j()),bt&&v.state.next({name:We,...fs?{}:dr});if(!Kt&&fs&&v.state.next({...r}),s.resolver){const{errors:ks}=await $([We]);if(Ze(ls),Ye){const ir=c3e(r.errors,n,We),Rr=c3e(ks,n,ir.name||We);Rt=Rr.error,We=Rr.name,qt=mm(ks)}}else w([We],!0),Rt=(await u3e(mt,i.disabled,o,_,s.shouldUseNativeValidation))[We],w([We]),Ze(ls),Ye&&(Rt?qt=!1:(p.isValid||g.isValid)&&(qt=await U(n,!0)));Ye&&(mt._f.deps&&pe(mt._f.deps),R(We,qt,Rt,dr))}},le=(qe,lt)=>{if(bn(r.errors,lt)&&qe.focus)return qe.focus(),1},pe=async(qe,lt={})=>{let We,Ye;const mt=HP(qe);if(s.resolver){const Ze=await q(sd(qe)?qe:mt);We=mm(Ze),Ye=qe?!mt.some(He=>bn(Ze,He)):We}else qe?(Ye=(await Promise.all(mt.map(async Ze=>{const He=bn(n,Ze);return await U(He&&He._f?{[Ze]:He}:He)}))).every(Boolean),!(!Ye&&!r.isValid)&&j()):Ye=We=await U(n);return v.state.next({...!Ox(qe)||(p.isValid||g.isValid)&&We!==r.isValid?{}:{name:qe},...s.resolver||!qe?{isValid:We}:{},errors:r.errors}),lt.shouldFocus&&!Ye&&WP(n,le,qe?mt:i.mount),Ye},be=qe=>{const lt={...l.mount?o:a};return sd(qe)?lt:Ox(qe)?bn(lt,qe):qe.map(We=>bn(lt,We))},ye=(qe,lt)=>({invalid:!!bn((lt||r).errors,qe),isDirty:!!bn((lt||r).dirtyFields,qe),error:bn((lt||r).errors,qe),isValidating:!!bn(r.validatingFields,qe),isTouched:!!bn((lt||r).touchedFields,qe)}),we=qe=>{qe&&HP(qe).forEach(lt=>yd(r.errors,lt)),v.state.next({errors:qe?r.errors:{}})},Ne=(qe,lt,We)=>{const Ye=(bn(n,qe,{_f:{}})._f||{}).ref,mt=bn(r.errors,qe)||{},{ref:Ze,message:He,type:et,...Rt}=mt;Ko(r.errors,qe,{...Rt,...lt,ref:Ye}),v.state.next({name:qe,errors:r.errors,isValid:!1}),We&&We.shouldFocus&&Ye&&Ye.focus&&Ye.focus()},Ke=(qe,lt)=>Cg(qe)?v.state.subscribe({next:We=>"values"in We&&qe(se(void 0,lt),We)}):se(qe,lt,!0),_e=qe=>v.state.subscribe({next:lt=>{_wt(qe.name,lt.name,qe.exact)&&vwt(lt,qe.formState||p,Qe,qe.reRenderRoot)&&qe.callback({values:{...o},...r,...lt,defaultValues:a})}}).unsubscribe,Me=qe=>(l.mount=!0,g={...g,...qe.formState},_e({...qe,formState:g})),Te=(qe,lt={})=>{for(const We of qe?HP(qe):i.mount)i.mount.delete(We),i.array.delete(We),lt.keepValue||(yd(n,We),yd(o,We)),!lt.keepError&&yd(r.errors,We),!lt.keepDirty&&yd(r.dirtyFields,We),!lt.keepTouched&&yd(r.touchedFields,We),!lt.keepIsValidating&&yd(r.validatingFields,We),!s.shouldUnregister&&!lt.keepDefaultValue&&yd(a,We);v.state.next({values:Ld(o)}),v.state.next({...r,...lt.keepDirty?{isDirty:X()}:{}}),!lt.keepIsValid&&j()},Fe=({disabled:qe,name:lt})=>{(rp(qe)&&l.mount||qe||i.disabled.has(lt))&&(qe?i.disabled.add(lt):i.disabled.delete(lt))},Ae=(qe,lt={})=>{let We=bn(n,qe);const Ye=rp(lt.disabled)||rp(s.disabled);return Ko(n,qe,{...We||{},_f:{...We&&We._f?We._f:{ref:{name:qe}},name:qe,mount:!0,...lt}}),i.mount.add(qe),We?Fe({disabled:rp(lt.disabled)?lt.disabled:s.disabled,name:qe}):I(qe,!0,lt.value),{...Ye?{disabled:lt.disabled||s.disabled}:{},...s.progressive?{required:!!lt.required,min:XA(lt.min),max:XA(lt.max),minLength:XA(lt.minLength),maxLength:XA(lt.maxLength),pattern:XA(lt.pattern)}:{},name:qe,onChange:ae,onBlur:ae,ref:mt=>{if(mt){Ae(qe,lt),We=bn(n,qe);const Ze=sd(mt.value)&&mt.querySelectorAll&&mt.querySelectorAll("input,select,textarea")[0]||mt,He=mwt(Ze),et=We._f.refs||[];if(He?et.find(Rt=>Rt===Ze):Ze===We._f.ref)return;Ko(n,qe,{_f:{...We._f,...He?{refs:[...et.filter(Rhe),Ze,...Array.isArray(bn(a,qe))?[{}]:[]],ref:{type:Ze.type,name:qe}}:{ref:Ze}}}),I(qe,!1,void 0,Ze)}else We=bn(n,qe,{}),We._f&&(We._f.mount=!1),(s.shouldUnregister||lt.shouldUnregister)&&!(f$e(i.array,qe)&&l.action)&&i.unMount.add(qe)}}},Ue=()=>s.shouldFocusError&&WP(n,le,i.mount),ut=qe=>{rp(qe)&&(v.state.next({disabled:qe}),WP(n,(lt,We)=>{const Ye=bn(n,We);Ye&&(lt.disabled=Ye._f.disabled||qe,Array.isArray(Ye._f.refs)&&Ye._f.refs.forEach(mt=>{mt.disabled=Ye._f.disabled||qe}))},0,!1))},De=(qe,lt)=>async We=>{let Ye;We&&(We.preventDefault&&We.preventDefault(),We.persist&&We.persist());let mt=Ld(o);if(v.state.next({isSubmitting:!0}),s.resolver){const{errors:Ze,values:He}=await $();r.errors=Ze,mt=Ld(He)}else await U(n);if(i.disabled.size)for(const Ze of i.disabled)yd(mt,Ze);if(yd(r.errors,"root"),mm(r.errors)){v.state.next({errors:{}});try{await qe(mt,We)}catch(Ze){Ye=Ze}}else lt&&await lt({...r.errors},We),Ue(),setTimeout(Ue);if(v.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:mm(r.errors)&&!Ye,submitCount:r.submitCount+1,errors:r.errors}),Ye)throw Ye},Dt=(qe,lt={})=>{bn(n,qe)&&(sd(lt.defaultValue)?ie(qe,Ld(bn(a,qe))):(ie(qe,lt.defaultValue),Ko(a,qe,Ld(lt.defaultValue))),lt.keepTouched||yd(r.touchedFields,qe),lt.keepDirty||(yd(r.dirtyFields,qe),r.isDirty=lt.defaultValue?X(qe,Ld(bn(a,qe))):X()),lt.keepError||(yd(r.errors,qe),p.isValid&&j()),v.state.next({...r}))},he=(qe,lt={})=>{const We=qe?Ld(qe):a,Ye=Ld(We),mt=mm(qe),Ze=mt?a:Ye;if(lt.keepDefaultValues||(a=We),!lt.keepValues){if(lt.keepDirtyValues){const He=new Set([...i.mount,...Object.keys(YA(a,o))]);for(const et of Array.from(He))bn(r.dirtyFields,et)?Ko(Ze,et,bn(o,et)):ie(et,bn(Ze,et))}else{if(d_e&&sd(qe))for(const He of i.mount){const et=bn(n,He);if(et&&et._f){const Rt=Array.isArray(et._f.refs)?et._f.refs[0]:et._f.ref;if(bne(Rt)){const qt=Rt.closest("form");if(qt){qt.reset();break}}}}if(lt.keepFieldsRef)for(const He of i.mount)ie(He,bn(Ze,He));else n={}}o=s.shouldUnregister?lt.keepDefaultValues?Ld(a):{}:Ld(Ze),v.array.next({values:{...Ze}}),v.state.next({values:{...Ze}})}i={mount:lt.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!p.isValid||!!lt.keepIsValid||!!lt.keepDirtyValues,l.watch=!!s.shouldUnregister,v.state.next({submitCount:lt.keepSubmitCount?r.submitCount:0,isDirty:mt?!1:lt.keepDirty?r.isDirty:!!(lt.keepDefaultValues&&!h0(qe,a)),isSubmitted:lt.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:mt?{}:lt.keepDirtyValues?lt.keepDefaultValues&&o?YA(a,o):r.dirtyFields:lt.keepDefaultValues&&qe?YA(a,qe):lt.keepDirty?r.dirtyFields:{},touchedFields:lt.keepTouched?r.touchedFields:{},errors:lt.keepErrors?r.errors:{},isSubmitSuccessful:lt.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Ve=(qe,lt)=>he(Cg(qe)?qe(o):qe,lt),nt=(qe,lt={})=>{const We=bn(n,qe),Ye=We&&We._f;if(Ye){const mt=Ye.refs?Ye.refs[0]:Ye.ref;mt.focus&&(mt.focus(),lt.shouldSelect&&Cg(mt.select)&&mt.select())}},Qe=qe=>{r={...r,...qe}},ot={control:{register:Ae,unregister:Te,getFieldState:ye,handleSubmit:De,setError:Ne,_subscribe:_e,_runSchema:$,_focusError:Ue,_getWatch:se,_getDirty:X,_setValid:j,_setFieldArray:N,_setDisabledField:Fe,_setErrors:A,_getFieldArray:te,_reset:he,_resetDefaultValues:()=>Cg(s.defaultValues)&&s.defaultValues().then(qe=>{Ve(qe,s.resetOptions),v.state.next({isLoading:!1})}),_removeUnmounted:V,_disableForm:ut,_subjects:v,_proxyFormState:p,get _fields(){return n},get _formValues(){return o},get _state(){return l},set _state(qe){l=qe},get _defaultValues(){return a},get _names(){return i},set _names(qe){i=qe},get _formState(){return r},get _options(){return s},set _options(qe){s={...s,...qe}}},subscribe:Me,trigger:pe,register:Ae,handleSubmit:De,watch:Ke,setValue:ie,getValues:be,reset:Ve,resetField:Dt,clearErrors:we,unregister:Te,setError:Ne,setFocus:nt,getFieldState:ye};return{...ot,formControl:ot}}function Ooe(t={}){const s=ht.useRef(void 0),r=ht.useRef(void 0),[n,a]=ht.useState({isDirty:!1,isValidating:!1,isLoading:Cg(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:Cg(t.defaultValues)?void 0:t.defaultValues});if(!s.current)if(t.formControl)s.current={...t.formControl,formState:n},t.defaultValues&&!Cg(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...i}=Nwt(t);s.current={...i,formState:n}}const o=s.current.control;return o._options=t,p_e(()=>{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&&!h0(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=g$e(n,o),s.current}const h3e=(t,s,r)=>{if(t&&"reportValidity"in t){const n=bn(r,s);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},N$e=(t,s)=>{for(const r in s.fields){const n=s.fields[r];n&&n.ref&&"reportValidity"in n.ref?h3e(n.ref,r,t):n.refs&&n.refs.forEach(a=>h3e(a,r,t))}},Swt=(t,s)=>{s.shouldUseNativeValidation&&N$e(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(Cwt(s.names||Object.keys(t),n)){const l=Object.assign({},bn(r,n));Ko(l,"root",o),Ko(r,n,l)}else Ko(r,n,o)}return r},Cwt=(t,s)=>t.some(r=>r.startsWith(s+"."));var Mwt=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(g){return t.push(g)})}),s){var d=r[l].types,u=d&&d[n.code];r[l]=y$e(l,s,r,a,u?[].concat(u,n.message):n.message)}t.shift()}return r},Roe=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&&N$e({},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:Swt(Mwt(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const Foe=lwt,S$e=S.createContext({}),vc=({...t})=>e.jsx(S$e.Provider,{value:{name:t.name},children:e.jsx(hwt,{...t})}),zoe=()=>{const t=S.useContext(S$e),s=S.useContext(C$e),{getFieldState:r,formState:n}=Doe(),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}},C$e=S.createContext({}),lc=S.forwardRef(({className:t,...s},r)=>{const n=S.useId();return e.jsx(C$e.Provider,{value:{id:n},children:e.jsx("div",{ref:r,className:Et("space-y-2",t),...s})})});lc.displayName="FormItem";const cc=S.forwardRef(({className:t,...s},r)=>{const{error:n,formItemId:a}=zoe();return e.jsx(ve,{ref:r,className:Et(n&&"text-destructive",t),htmlFor:a,...s})});cc.displayName="FormLabel";const dc=S.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:o}=zoe();return e.jsx(Hve,{ref:s,id:n,"aria-describedby":r?`${a} ${o}`:`${a}`,"aria-invalid":!!r,...t})});dc.displayName="FormControl";const rre=S.forwardRef(({className:t,...s},r)=>{const{formDescriptionId:n}=zoe();return e.jsx("p",{ref:r,id:n,className:Et("text-sm text-muted-foreground",t),...s})});rre.displayName="FormDescription";const Ah=S.forwardRef(({className:t,children:s,...r},n)=>{const{error:a,formMessageId:o}=zoe(),l=a?String(a==null?void 0:a.message):s;return l?e.jsx("p",{ref:n,id:o,className:Et("text-sm font-medium text-destructive",t),...r,children:l}):null});Ah.displayName="FormMessage";const Twt=eS({category:$9e(["general","technology","crm","marketing"]),subject:Yl().min(5,"Subject must be at least 5 characters").max(200),description:Yl().min(20,"Please provide more details (at least 20 characters)").max(2e3)}),Awt={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function $ge({trigger:t}){const[s,r]=S.useState(!1),[n,a]=S.useState(!1),{user:o}=Gs(),l=Ooe({resolver:Roe(Twt),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:Awt[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(vs,{open:s,onOpenChange:r,children:[e.jsx(Ai,{asChild:!0,children:t||e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(hP,{className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:"Support"})]})}),e.jsxs(ys,{className:"sm:max-w-[500px]",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(Zn,{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(Foe,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(i),className:"space-y-4",children:[e.jsx(vc,{control:l.control,name:"category",render:({field:d})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Category"}),e.jsxs(tr,{onValueChange:d.onChange,defaultValue:d.value,children:[e.jsx(dc,{children:e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select a category"})})}),e.jsxs(er,{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(Ah,{})]})}),e.jsx(vc,{control:l.control,name:"subject",render:({field:d})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Subject"}),e.jsx(dc,{children:e.jsx(Re,{placeholder:"Brief description of your issue",...d})}),e.jsx(Ah,{})]})}),e.jsx(vc,{control:l.control,name:"description",render:({field:d})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Description"}),e.jsx(dc,{children:e.jsx(Tr,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...d})}),e.jsx(Ah,{})]})}),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 Ewt=()=>{const{user:t}=Gs(),s=Lr(),[r,n]=S.useState([]),[a,o]=S.useState(0),[l,i]=S.useState(!1),[d,u]=S.useState(null);S.useEffect(()=>{if(!t)return;const b=`notification_last_read_${t.id}`;let j=d;if(!j){const C=localStorage.getItem(b);C&&(j=C,u(C))}(async()=>{const{data:C,error:A}=await G.from("push_notifications").select("*").order("created_at",{ascending:!1}).limit(20);if(!A&&C){n(C);const I=j?new Date(j):null,L=C.filter(R=>I?new Date(R.created_at)>I:!0);o(L.length)}})();const N=G.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},C=>{const A=C.new;n(L=>[A,...L].slice(0,20));const I=j?new Date(j):null;(!I||new Date(A.created_at)>I)&&o(L=>L+1),Notification.permission==="granted"&&new Notification(A.title,{body:A.body,icon:"/favicon.ico"})}).subscribe();return()=>{G.removeChannel(N)}},[t,d]);const p=b=>{const j=b.toLowerCase();return j.includes("community")||j.includes("post")?io:j.includes("academy")||j.includes("video")?Nn:j.includes("template")?Rl:j.includes("event")?on:j.includes("newsletter")?E0:j.includes("brokerage")?eh:j.includes("swag")||j.includes("social")?ao:j.includes("toolbox")||j.includes("tool")?Kx:j.includes("brief")?mn:io},g=b=>{i(!1),b.url&&b.url!=="/"&&s(b.url)},v=()=>{if(!t)return;const b=new Date().toISOString(),j=`notification_last_read_${t.id}`;localStorage.setItem(j,b),u(b),o(0)},_=b=>{i(b),b&&a>0&&v()};return e.jsxs(yu,{open:l,onOpenChange:_,children:[e.jsx(vu,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(cf,{className:"h-5 w-5"}),a>0&&e.jsx(at,{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(Wd,{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:v,children:"Mark all read"})]}),e.jsx(Fi,{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 j=p(b.title);return e.jsxs(Da,{className:"group flex items-start gap-3 p-3 cursor-pointer data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",onClick:()=>g(b),children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx(j,{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 m3e=1,Pwt=.9,Iwt=.8,Lwt=.17,Fhe=.1,zhe=.999,Dwt=.9999,Owt=.99,Rwt=/[\\\/_+.#"@\[\(\{&]/,Fwt=/[\\\/_+.#"@\[\(\{&]/g,zwt=/[\s-]/,M$e=/[\s-]/g;function qge(t,s,r,n,a,o,l){if(o===s.length)return a===t.length?m3e:Owt;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,g,v,_,b;u>=0;)g=qge(t,s,r,n,u+1,o+1,l),g>p&&(u===a?g*=m3e:Rwt.test(t.charAt(u-1))?(g*=Iwt,_=t.slice(a,u-1).match(Fwt),_&&a>0&&(g*=Math.pow(zhe,_.length))):zwt.test(t.charAt(u-1))?(g*=Pwt,b=t.slice(a,u-1).match(M$e),b&&a>0&&(g*=Math.pow(zhe,b.length))):(g*=Lwt,a>0&&(g*=Math.pow(zhe,u-a))),t.charAt(u)!==s.charAt(o)&&(g*=Dwt)),(gg&&(g=v*Fhe)),g>p&&(p=g),u=r.indexOf(d,u+1);return l[i]=p,p}function p3e(t){return t.toLowerCase().replace(M$e," ")}function Bwt(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,qge(t,s,p3e(t),p3e(s),0,0,{})}var QA='[cmdk-group=""]',Bhe='[cmdk-group-items=""]',$wt='[cmdk-group-heading=""]',T$e='[cmdk-item=""]',f3e=`${T$e}:not([aria-disabled="true"])`,Uge="cmdk-item-select",x4="data-value",qwt=(t,s,r)=>Bwt(t,s,r),A$e=S.createContext(void 0),SL=()=>S.useContext(A$e),E$e=S.createContext(void 0),x_e=()=>S.useContext(E$e),P$e=S.createContext(void 0),I$e=S.forwardRef((t,s)=>{let r=y4(()=>{var we,Ne;return{search:"",value:(Ne=(we=t.value)!=null?we:t.defaultValue)!=null?Ne:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=y4(()=>new Set),a=y4(()=>new Map),o=y4(()=>new Map),l=y4(()=>new Set),i=L$e(t),{label:d,children:u,value:p,onValueChange:g,filter:v,shouldFilter:_,loop:b,disablePointerSelection:j=!1,vimBindings:w=!0,...N}=t,C=Hd(),A=Hd(),I=Hd(),L=S.useRef(null),R=Jwt();IN(()=>{if(p!==void 0){let we=p.trim();r.current.value=we,$.emit()}},[p]),IN(()=>{R(6,te)},[]);let $=S.useMemo(()=>({subscribe:we=>(l.current.add(we),()=>l.current.delete(we)),snapshot:()=>r.current,setState:(we,Ne,Ke)=>{var _e,Me,Te,Fe;if(!Object.is(r.current[we],Ne)){if(r.current[we]=Ne,we==="search")se(),V(),R(1,X);else if(we==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Ae=document.getElementById(I);Ae?Ae.focus():(_e=document.getElementById(C))==null||_e.focus()}if(R(7,()=>{var Ae;r.current.selectedItemId=(Ae=Y())==null?void 0:Ae.id,$.emit()}),Ke||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(we=>we())}}),[]),q=S.useMemo(()=>({value:(we,Ne,Ke)=>{var _e;Ne!==((_e=o.current.get(we))==null?void 0:_e.value)&&(o.current.set(we,{value:Ne,keywords:Ke}),r.current.filtered.items.set(we,U(Ne,Ke)),R(2,()=>{V(),$.emit()}))},item:(we,Ne)=>(n.current.add(we),Ne&&(a.current.has(Ne)?a.current.get(Ne).add(we):a.current.set(Ne,new Set([we]))),R(3,()=>{se(),V(),r.current.value||X(),$.emit()}),()=>{o.current.delete(we),n.current.delete(we),r.current.filtered.items.delete(we);let Ke=Y();R(4,()=>{se(),(Ke==null?void 0:Ke.getAttribute("id"))===we&&X(),$.emit()})}),group:we=>(a.current.has(we)||a.current.set(we,new Set),()=>{o.current.delete(we),a.current.delete(we)}),filter:()=>i.current.shouldFilter,label:d||t["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:C,inputId:I,labelId:A,listInnerRef:L}),[]);function U(we,Ne){var Ke,_e;let Me=(_e=(Ke=i.current)==null?void 0:Ke.filter)!=null?_e:qwt;return we?Me(we,r.current.search,Ne):0}function V(){if(!r.current.search||i.current.shouldFilter===!1)return;let we=r.current.filtered.items,Ne=[];r.current.filtered.groups.forEach(_e=>{let Me=a.current.get(_e),Te=0;Me.forEach(Fe=>{let Ae=we.get(Fe);Te=Math.max(Ae,Te)}),Ne.push([_e,Te])});let Ke=L.current;de().sort((_e,Me)=>{var Te,Fe;let Ae=_e.getAttribute("id"),Ue=Me.getAttribute("id");return((Te=we.get(Ue))!=null?Te:0)-((Fe=we.get(Ae))!=null?Fe:0)}).forEach(_e=>{let Me=_e.closest(Bhe);Me?Me.appendChild(_e.parentElement===Me?_e:_e.closest(`${Bhe} > *`)):Ke.appendChild(_e.parentElement===Ke?_e:_e.closest(`${Bhe} > *`))}),Ne.sort((_e,Me)=>Me[1]-_e[1]).forEach(_e=>{var Me;let Te=(Me=L.current)==null?void 0:Me.querySelector(`${QA}[${x4}="${encodeURIComponent(_e[0])}"]`);Te==null||Te.parentElement.appendChild(Te)})}function X(){let we=de().find(Ke=>Ke.getAttribute("aria-disabled")!=="true"),Ne=we==null?void 0:we.getAttribute(x4);$.setState("value",Ne||void 0)}function se(){var we,Ne,Ke,_e;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=(we=o.current.get(Te))==null?void 0:we.value)!=null?Ne:"",Ae=(_e=(Ke=o.current.get(Te))==null?void 0:Ke.keywords)!=null?_e:[],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 we,Ne,Ke;let _e=Y();_e&&(((we=_e.parentElement)==null?void 0:we.firstChild)===_e&&((Ke=(Ne=_e.closest(QA))==null?void 0:Ne.querySelector($wt))==null||Ke.scrollIntoView({block:"nearest"})),_e.scrollIntoView({block:"nearest"}))}function Y(){var we;return(we=L.current)==null?void 0:we.querySelector(`${T$e}[aria-selected="true"]`)}function de(){var we;return Array.from(((we=L.current)==null?void 0:we.querySelectorAll(f3e))||[])}function ie(we){let Ne=de()[we];Ne&&$.setState("value",Ne.getAttribute(x4))}function ae(we){var Ne;let Ke=Y(),_e=de(),Me=_e.findIndex(Fe=>Fe===Ke),Te=_e[Me+we];(Ne=i.current)!=null&&Ne.loop&&(Te=Me+we<0?_e[_e.length-1]:Me+we===_e.length?_e[0]:_e[Me+we]),Te&&$.setState("value",Te.getAttribute(x4))}function le(we){let Ne=Y(),Ke=Ne==null?void 0:Ne.closest(QA),_e;for(;Ke&&!_e;)Ke=we>0?Xwt(Ke,QA):Qwt(Ke,QA),_e=Ke==null?void 0:Ke.querySelector(f3e);_e?$.setState("value",_e.getAttribute(x4)):ae(we)}let pe=()=>ie(de().length-1),be=we=>{we.preventDefault(),we.metaKey?pe():we.altKey?le(1):ae(1)},ye=we=>{we.preventDefault(),we.metaKey?ie(0):we.altKey?le(-1):ae(-1)};return S.createElement(Qr.div,{ref:s,tabIndex:-1,...N,"cmdk-root":"",onKeyDown:we=>{var Ne;(Ne=N.onKeyDown)==null||Ne.call(N,we);let Ke=we.nativeEvent.isComposing||we.keyCode===229;if(!(we.defaultPrevented||Ke))switch(we.key){case"n":case"j":{w&&we.ctrlKey&&be(we);break}case"ArrowDown":{be(we);break}case"p":case"k":{w&&we.ctrlKey&&ye(we);break}case"ArrowUp":{ye(we);break}case"Home":{we.preventDefault(),ie(0);break}case"End":{we.preventDefault(),pe();break}case"Enter":{we.preventDefault();let _e=Y();if(_e){let Me=new Event(Uge);_e.dispatchEvent(Me)}}}}},S.createElement("label",{"cmdk-label":"",htmlFor:q.inputId,id:q.labelId,style:t2t},d),Boe(t,we=>S.createElement(E$e.Provider,{value:$},S.createElement(A$e.Provider,{value:q},we))))}),Uwt=S.forwardRef((t,s)=>{var r,n;let a=Hd(),o=S.useRef(null),l=S.useContext(P$e),i=SL(),d=L$e(t),u=(n=(r=d.current)==null?void 0:r.forceMount)!=null?n:l==null?void 0:l.forceMount;IN(()=>{if(!u)return i.item(a,l==null?void 0:l.id)},[u]);let p=D$e(a,o,[t.value,t.children,o],t.keywords),g=x_e(),v=M_(R=>R.value&&R.value===p.current),_=M_(R=>u||i.filter()===!1?!0:R.search?R.filtered.items.get(a)>0:!0);S.useEffect(()=>{let R=o.current;if(!(!R||t.disabled))return R.addEventListener(Uge,b),()=>R.removeEventListener(Uge,b)},[_,t.onSelect,t.disabled]);function b(){var R,$;j(),($=(R=d.current).onSelect)==null||$.call(R,p.current)}function j(){g.setState("value",p.current,!0)}if(!_)return null;let{disabled:w,value:N,onSelect:C,forceMount:A,keywords:I,...L}=t;return S.createElement(Qr.div,{ref:H0(o,s),...L,id:a,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!v,"data-disabled":!!w,"data-selected":!!v,onPointerMove:w||i.getDisablePointerSelection()?void 0:j,onClick:w?void 0:b},t.children)}),Vwt=S.forwardRef((t,s)=>{let{heading:r,children:n,forceMount:a,...o}=t,l=Hd(),i=S.useRef(null),d=S.useRef(null),u=Hd(),p=SL(),g=M_(_=>a||p.filter()===!1?!0:_.search?_.filtered.groups.has(l):!0);IN(()=>p.group(l),[]),D$e(l,i,[t.value,t.heading,d]);let v=S.useMemo(()=>({id:l,forceMount:a}),[a]);return S.createElement(Qr.div,{ref:H0(i,s),...o,"cmdk-group":"",role:"presentation",hidden:g?void 0:!0},r&&S.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:u},r),Boe(t,_=>S.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},S.createElement(P$e.Provider,{value:v},_))))}),Hwt=S.forwardRef((t,s)=>{let{alwaysRender:r,...n}=t,a=S.useRef(null),o=M_(l=>!l.search);return!r&&!o?null:S.createElement(Qr.div,{ref:H0(a,s),...n,"cmdk-separator":"",role:"separator"})}),Wwt=S.forwardRef((t,s)=>{let{onValueChange:r,...n}=t,a=t.value!=null,o=x_e(),l=M_(u=>u.search),i=M_(u=>u.selectedItemId),d=SL();return S.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),S.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)}})}),Gwt=S.forwardRef((t,s)=>{let{children:r,label:n="Suggestions",...a}=t,o=S.useRef(null),l=S.useRef(null),i=M_(u=>u.selectedItemId),d=SL();return S.useEffect(()=>{if(l.current&&o.current){let u=l.current,p=o.current,g,v=new ResizeObserver(()=>{g=requestAnimationFrame(()=>{let _=u.offsetHeight;p.style.setProperty("--cmdk-list-height",_.toFixed(1)+"px")})});return v.observe(u),()=>{cancelAnimationFrame(g),v.unobserve(u)}}},[]),S.createElement(Qr.div,{ref:H0(o,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":n,id:d.listId},Boe(t,u=>S.createElement("div",{ref:H0(l,d.listInnerRef),"cmdk-list-sizer":""},u)))}),Kwt=S.forwardRef((t,s)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=t;return S.createElement(goe,{open:r,onOpenChange:n},S.createElement(xoe,{container:l},S.createElement(hM,{"cmdk-overlay":"",className:a}),S.createElement(mM,{"aria-label":t.label,"cmdk-dialog":"",className:o},S.createElement(I$e,{ref:s,...i}))))}),Zwt=S.forwardRef((t,s)=>M_(r=>r.filtered.count===0)?S.createElement(Qr.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),Ywt=S.forwardRef((t,s)=>{let{progress:r,children:n,label:a="Loading...",...o}=t;return S.createElement(Qr.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Boe(t,l=>S.createElement("div",{"aria-hidden":!0},l)))}),Rm=Object.assign(I$e,{List:Gwt,Item:Uwt,Input:Wwt,Group:Vwt,Separator:Hwt,Dialog:Kwt,Empty:Zwt,Loading:Ywt});function Xwt(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function Qwt(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function L$e(t){let s=S.useRef(t);return IN(()=>{s.current=t}),s}var IN=typeof window>"u"?S.useEffect:S.useLayoutEffect;function y4(t){let s=S.useRef();return s.current===void 0&&(s.current=t()),s}function M_(t){let s=x_e(),r=()=>t(s.snapshot());return S.useSyncExternalStore(s.subscribe,r,r)}function D$e(t,s,r,n=[]){let a=S.useRef(),o=SL();return IN(()=>{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(x4,i),a.current=i}),a}var Jwt=()=>{let[t,s]=S.useState(),r=y4(()=>new Map);return IN(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,a)=>{r.current.set(n,a),s({})}};function e2t(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function Boe({asChild:t,children:s},r){return t&&S.isValidElement(s)?S.cloneElement(e2t(s),{ref:s.ref},r(s.props.children)):r(s)}var t2t={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const wf=S.forwardRef(({className:t,...s},r)=>e.jsx(Rm,{ref:r,className:Et("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));wf.displayName=Rm.displayName;const s2t=({children:t,...s})=>e.jsx(vs,{...s,children:e.jsx(ys,{className:"overflow-hidden p-0 shadow-lg",children:e.jsx(wf,{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})})}),jf=S.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(xn,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Rm.Input,{ref:r,className:Et("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})]}));jf.displayName=Rm.Input.displayName;const kf=S.forwardRef(({className:t,...s},r)=>e.jsx(Rm.List,{ref:r,className:Et("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));kf.displayName=Rm.List.displayName;const Nf=S.forwardRef((t,s)=>e.jsx(Rm.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));Nf.displayName=Rm.Empty.displayName;const Sf=S.forwardRef(({className:t,...s},r)=>e.jsx(Rm.Group,{ref:r,className:Et("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}));Sf.displayName=Rm.Group.displayName;const r2t=S.forwardRef(({className:t,...s},r)=>e.jsx(Rm.Separator,{ref:r,className:Et("-mx-1 h-px bg-border",t),...s}));r2t.displayName=Rm.Separator.displayName;const jm=S.forwardRef(({className:t,...s},r)=>e.jsx(Rm.Item,{ref:r,className:Et("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}));jm.displayName=Rm.Item.displayName;const n2t={event:{label:"Events",icon:kc,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:Rl,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:th,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:Kx,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:mn,color:"bg-fuchsia-500/10 text-fuchsia-600"}},g3e=()=>{const[t,s]=S.useState(!1),[r,n]=S.useState(""),[a,o]=S.useState([]),[l,i]=S.useState(!1),d=Lr();S.useEffect(()=>{const v=_=>{_.key==="k"&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),s(b=>!b))};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[]);const u=S.useCallback(async v=>{if(!v.trim()){o([]);return}i(!0);const _=`%${v}%`;try{const[b,j,w,N,C]=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)]),A=[];b.data&&b.data.forEach(I=>{A.push({id:I.id,title:I.title,description:I.description,type:"event",date:I.event_date,path:`/event/${I.id}`})}),j.data&&j.data.forEach(I=>{A.push({id:I.id,title:I.name,description:I.description,type:"template",date:I.publish_date,path:`/templates/${I.id}`})}),w.data&&w.data.forEach(I=>{A.push({id:I.id,title:I.title,description:I.description,type:"academy",date:I.publish_date,path:`/academy/${I.id}`})}),N.data&&N.data.forEach(I=>{A.push({id:I.id,title:I.name,description:I.description,type:"toolbox",date:I.publish_date,path:`/toolbox/${I.id}`})}),C.data&&C.data.forEach(I=>{A.push({id:I.id,title:I.title,description:I.description,type:"social-swag",date:I.publish_date,path:`/social-swag/${I.id}`})}),o(A)}catch(b){console.error("Search error:",b)}finally{i(!1)}},[]);S.useEffect(()=>{const v=setTimeout(()=>{u(r)},300);return()=>clearTimeout(v)},[r,u]);const p=v=>{s(!1),n(""),d(v)},g=a.reduce((v,_)=>(v[_.type]||(v[_.type]=[]),v[_.type].push(_),v),{});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(xn,{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(s2t,{open:t,onOpenChange:s,children:[e.jsx(jf,{placeholder:"Search events, templates, academy, toolbox, social swag...",value:r,onValueChange:n}),e.jsxs(kf,{children:[l&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!l&&r&&a.length===0&&e.jsxs(Nf,{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(g).map(([v,_])=>{const b=n2t[v],j=b.icon;return e.jsx(Sf,{heading:b.label,children:_.map(w=>e.jsxs(jm,{value:`${w.type}-${w.id}-${w.title}`,onSelect:()=>p(w.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(j,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:w.title}),w.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate group-data-[selected=true]:text-primary-foreground/80",children:w.description})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(at,{variant:"secondary",className:"text-xs",children:b.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Sd(new Date(w.date),{addSuffix:!0})})]})]},`${w.type}-${w.id}`))},v)})]})]})]})},a2t=({expiresAt:t,className:s,showUpgradeButton:r=!0})=>{const[n,a]=S.useState(null),o=Lr();if(S.useEffect(()=>{const u=()=>{const g=new Date().getTime(),_=new Date(t).getTime()-g;if(_<=0){a({days:0,hours:0,minutes:0});return}const b=Math.floor(_/(1e3*60*60*24)),j=Math.floor(_%(1e3*60*60*24)/(1e3*60*60)),w=Math.floor(_%(1e3*60*60)/(1e3*60));a({days:b,hours:j,minutes:w})};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:Et("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(Mh,{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(mn,{className:"h-3 w-3 mr-1"}),"Upgrade Now"]})]}):e.jsxs("div",{className:Et("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(In,{className:Et("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:Et("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:Et("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.days,"d"]}),e.jsxs("span",{className:Et("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),e.jsxs("span",{className:Et("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),e.jsx("span",{className:Et("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:Et("text-xs h-7 px-3",d&&"bg-amber-500 hover:bg-amber-600 text-white"),children:[e.jsx(mn,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},i2t=()=>{const t=Lr();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(Lt,{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(Mh,{className:"h-8 w-8 text-destructive"})}),e.jsx(zt,{className:"text-2xl",children:"Your Free Trial Has Ended"}),e.jsx(yr,{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(mn,{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(Ca,{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(Ca,{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(Zn,{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"})]})]})]})]})]})})},o2t=({hasUnseenBrief:t,onClick:s,className:r})=>e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",onClick:s,className:Et("relative transition-colors",t&&"text-primary hover:text-primary",r),children:[e.jsx(Fg,{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(Hc,{children:e.jsx("p",{children:"The LevelUp Brief"})})]});var $oe="Checkbox",[l2t]=Tc($oe),[c2t,y_e]=l2t($oe);function d2t(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:g}=t,[v,_]=fu({prop:r,defaultProp:a??!1,onChange:d,caller:$oe}),[b,j]=S.useState(null),[w,N]=S.useState(null),C=S.useRef(!1),A=b?!!l||!!b.closest("form"):!0,I={checked:v,disabled:o,setChecked:_,control:b,setControl:j,name:i,form:l,value:p,hasConsumerStoppedPropagationRef:C,required:u,defaultChecked:u_(a)?!1:a,isFormControl:A,bubbleInput:w,setBubbleInput:N};return e.jsx(c2t,{scope:s,...I,children:u2t(g)?g(I):n})}var O$e="CheckboxTrigger",R$e=S.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:r,...n},a)=>{const{control:o,value:l,disabled:i,checked:d,required:u,setControl:p,setChecked:g,hasConsumerStoppedPropagationRef:v,isFormControl:_,bubbleInput:b}=y_e(O$e,t),j=Aa(a,p),w=S.useRef(d);return S.useEffect(()=>{const N=o==null?void 0:o.form;if(N){const C=()=>g(w.current);return N.addEventListener("reset",C),()=>N.removeEventListener("reset",C)}},[o,g]),e.jsx(Qr.button,{type:"button",role:"checkbox","aria-checked":u_(d)?"mixed":d,"aria-required":u,"data-state":q$e(d),"data-disabled":i?"":void 0,disabled:i,value:l,...n,ref:j,onKeyDown:Mr(s,N=>{N.key==="Enter"&&N.preventDefault()}),onClick:Mr(r,N=>{g(C=>u_(C)?!0:!C),b&&_&&(v.current=N.isPropagationStopped(),v.current||N.stopPropagation())})})});R$e.displayName=O$e;var v_e=S.forwardRef((t,s)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d,onCheckedChange:u,form:p,...g}=t;return e.jsx(d2t,{__scopeCheckbox:r,checked:a,defaultChecked:o,disabled:i,required:l,onCheckedChange:u,name:n,form:p,value:d,internal_do_not_use_render:({isFormControl:v})=>e.jsxs(e.Fragment,{children:[e.jsx(R$e,{...g,ref:s,__scopeCheckbox:r}),v&&e.jsx($$e,{__scopeCheckbox:r})]})})});v_e.displayName=$oe;var F$e="CheckboxIndicator",z$e=S.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=t,o=y_e(F$e,r);return e.jsx(ud,{present:n||u_(o.checked)||o.checked===!0,children:e.jsx(Qr.span,{"data-state":q$e(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});z$e.displayName=F$e;var B$e="CheckboxBubbleInput",$$e=S.forwardRef(({__scopeCheckbox:t,...s},r)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:i,disabled:d,name:u,value:p,form:g,bubbleInput:v,setBubbleInput:_}=y_e(B$e,t),b=Aa(r,_),j=jL(o),w=dL(n);S.useEffect(()=>{const C=v;if(!C)return;const A=window.HTMLInputElement.prototype,L=Object.getOwnPropertyDescriptor(A,"checked").set,R=!a.current;if(j!==o&&L){const $=new Event("click",{bubbles:R});C.indeterminate=u_(o),L.call(C,u_(o)?!1:o),C.dispatchEvent($)}},[v,j,o,a]);const N=S.useRef(u_(o)?!1:o);return e.jsx(Qr.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??N.current,required:i,disabled:d,name:u,value:p,form:g,...s,tabIndex:-1,ref:b,style:{...s.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});$$e.displayName=B$e;function u2t(t){return typeof t=="function"}function u_(t){return t==="indeterminate"}function q$e(t){return u_(t)?"indeterminate":t?"checked":"unchecked"}const zo=S.forwardRef(({className:t,...s},r)=>e.jsx(v_e,{ref:r,className:Et("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(z$e,{className:Et("flex items-center justify-center text-current"),children:e.jsx(fa,{className:"h-4 w-4"})})}));zo.displayName=v_e.displayName;var __e="Radio",[h2t,U$e]=Tc(__e),[m2t,p2t]=h2t(__e),V$e=S.forwardRef((t,s)=>{const{__scopeRadio:r,name:n,checked:a=!1,required:o,disabled:l,value:i="on",onCheck:d,form:u,...p}=t,[g,v]=S.useState(null),_=Aa(s,w=>v(w)),b=S.useRef(!1),j=g?u||!!g.closest("form"):!0;return e.jsxs(m2t,{scope:r,checked:a,disabled:l,children:[e.jsx(Qr.button,{type:"button",role:"radio","aria-checked":a,"data-state":K$e(a),"data-disabled":l?"":void 0,disabled:l,value:i,...p,ref:_,onClick:Mr(t.onClick,w=>{a||d==null||d(),j&&(b.current=w.isPropagationStopped(),b.current||w.stopPropagation())})}),j&&e.jsx(G$e,{control:g,bubbles:!b.current,name:n,value:i,checked:a,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});V$e.displayName=__e;var H$e="RadioIndicator",W$e=S.forwardRef((t,s)=>{const{__scopeRadio:r,forceMount:n,...a}=t,o=p2t(H$e,r);return e.jsx(ud,{present:n||o.checked,children:e.jsx(Qr.span,{"data-state":K$e(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s})})});W$e.displayName=H$e;var f2t="RadioBubbleInput",G$e=S.forwardRef(({__scopeRadio:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=S.useRef(null),i=Aa(l,o),d=jL(r),u=dL(s);return S.useEffect(()=>{const p=l.current;if(!p)return;const g=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(g,"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}})});G$e.displayName=f2t;function K$e(t){return t?"checked":"unchecked"}var g2t=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],qoe="RadioGroup",[x2t]=Tc(qoe,[B_,U$e]),Z$e=B_(),Y$e=U$e(),[y2t,v2t]=x2t(qoe),X$e=S.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:g,...v}=t,_=Z$e(r),b=z_(u),[j,w]=fu({prop:o,defaultProp:a??null,onChange:g,caller:qoe});return e.jsx(y2t,{scope:r,name:n,required:l,disabled:i,value:j,onValueChange:w,children:e.jsx(loe,{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,...v,ref:s})})})});X$e.displayName=qoe;var Q$e="RadioGroupItem",J$e=S.forwardRef((t,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=t,o=v2t(Q$e,r),l=o.disabled||n,i=Z$e(r),d=Y$e(r),u=S.useRef(null),p=Aa(s,u),g=o.value===a.value,v=S.useRef(!1);return S.useEffect(()=>{const _=j=>{g2t.includes(j.key)&&(v.current=!0)},b=()=>v.current=!1;return document.addEventListener("keydown",_),document.addEventListener("keyup",b),()=>{document.removeEventListener("keydown",_),document.removeEventListener("keyup",b)}},[]),e.jsx(coe,{asChild:!0,...i,focusable:!l,active:g,children:e.jsx(V$e,{disabled:l,required:o.required,checked:g,...d,...a,name:o.name,ref:p,onCheck:()=>o.onValueChange(a.value),onKeyDown:Mr(_=>{_.key==="Enter"&&_.preventDefault()}),onFocus:Mr(a.onFocus,()=>{var _;v.current&&((_=u.current)==null||_.click())})})})});J$e.displayName=Q$e;var _2t="RadioGroupIndicator",eqe=S.forwardRef((t,s)=>{const{__scopeRadioGroup:r,...n}=t,a=Y$e(r);return e.jsx(W$e,{...a,...n,ref:s})});eqe.displayName=_2t;var tqe=X$e,sqe=J$e,b2t=eqe;const b_e=S.forwardRef(({className:t,...s},r)=>e.jsx(tqe,{className:Et("grid gap-2",t),...s,ref:r}));b_e.displayName=tqe.displayName;const kne=S.forwardRef(({className:t,...s},r)=>e.jsx(sqe,{ref:r,className:Et("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(b2t,{className:"flex items-center justify-center",children:e.jsx(Wc,{className:"h-2.5 w-2.5 fill-current text-current"})})}));kne.displayName=sqe.displayName;const w2t=({brief:t,open:s,onClose:r,onDismiss:n})=>{const{user:a}=Gs(),[o,l]=S.useState({}),[i,d]=S.useState({}),[u,p]=S.useState([]);S.useEffect(()=>{s&&a&&t.polls.length>0&&g()},[s,a,t.polls]);const g=async()=>{if(!a)return;const w=t.polls.map(C=>C.id),{data:N}=await G.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",a.id).in("poll_id",w);if(N){const C={};N.forEach(A=>{C[A.poll_id]||(C[A.poll_id]=[]),C[A.poll_id].push(A.option_id)}),d(C)}},v=(w,N)=>{l(C=>({...C,[w]:N}))},_=(w,N,C)=>{l(A=>{const I=A[w]||[];return C?{...A,[w]:[...I,N]}:{...A,[w]:I.filter(L=>L!==N)}})},b=async w=>{if(!a)return;const N=o[w];if(!N||Array.isArray(N)&&N.length===0){fe.error("Please select an option");return}p(C=>[...C,w]);try{await G.from("levelup_brief_poll_responses").delete().eq("poll_id",w).eq("user_id",a.id);const C=Array.isArray(N)?N:[N],A=C.map(L=>({poll_id:w,option_id:L,user_id:a.id})),{error:I}=await G.from("levelup_brief_poll_responses").insert(A);if(I)throw I;d(L=>({...L,[w]:C})),fe.success("Response submitted!")}catch(C){console.error("Error submitting poll response:",C),fe.error("Failed to submit response")}finally{p(C=>C.filter(A=>A!==w))}},j=w=>(w.includes("mediadelivery.net")||w.includes("bunny"),w);return e.jsx(vs,{open:s,onOpenChange:w=>!w&&r(),children:e.jsxs(ys,{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(Fg,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx(at,{variant:"secondary",className:"mb-1 bg-white/20 text-white border-0",children:"The LevelUp Brief"}),e.jsx(Ss,{className:"text-xl font-bold text-white",children:t.brief.title})]})]})]}),e.jsx(Fi,{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:j(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(w=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>window.open(w.url,"_blank"),className:"gap-2",children:[e.jsx(rn,{className:"h-4 w-4"}),w.title]},w.id))})]}),t.polls.map(w=>{var A,I;const N=((A=i[w.id])==null?void 0:A.length)>0,C=u.includes(w.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:w.question}),N&&e.jsxs(at,{variant:"secondary",className:"gap-1",children:[e.jsx(la,{className:"h-3 w-3"}),"Responded"]})]}),w.poll_type==="single"?e.jsx(b_e,{value:o[w.id]||((I=i[w.id])==null?void 0:I[0])||"",onValueChange:L=>v(w.id,L),className:"space-y-2",children:w.options.map(L=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(kne,{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:w.options.map(L=>{const $=(o[w.id]||i[w.id]||[]).includes(L.id);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(zo,{id:L.id,checked:$,onCheckedChange:q=>_(w.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(w.id),disabled:C,children:C?"Submitting...":N?"Update Response":"Submit"})]},w.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"})]})]})})},j2t=()=>{const{user:t}=Gs(),[s,r]=S.useState(null),[n,a]=S.useState(!1),[o,l]=S.useState(!0),[i,d]=S.useState(!1),u=S.useCallback(async()=>{if(!t){l(!1);return}try{const{data:b,error:j}=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(j||!b){l(!1);return}const{data:w}=await G.from("levelup_brief_views").select("*").eq("brief_id",b.id).eq("user_id",t.id).maybeSingle(),[N,C]=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")]),A=[];if(C.data)for(const q of C.data){const{data:U}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",q.id).order("sort_order");A.push({...q,options:U||[]})}const I={brief:b,links:N.data||[],polls:A};r(I);const L=!!w,R=(w==null?void 0:w.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(w.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]);S.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:j}=await G.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();if(j&&console.error("Error checking existing brief view:",j),b){const{error:w}=await G.from("levelup_brief_views").update({dismissed_at:new Date().toISOString()}).eq("id",b.id).eq("user_id",t.id);w&&console.error("Error updating brief dismiss:",w)}else{const{error:w}=await G.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id,dismissed_at:new Date().toISOString()});w&&console.error("Error inserting brief dismiss:",w)}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 k2t(){const[t,s]=S.useState(!1),[r,n]=S.useState(!1),[a,o]=S.useState(null);S.useEffect(()=>{if(localStorage.getItem("install-banner-dismissed")||window.matchMedia("(display-mode: standalone)").matches||!/iPhone|iPad|iPod|Android/i.test(navigator.userAgent))return;const g=/iPhone|iPad|iPod/i.test(navigator.userAgent);n(g),s(!0);const v=_=>{_.preventDefault(),o(_)};return window.addEventListener("beforeinstallprompt",v),()=>{window.removeEventListener("beforeinstallprompt",v)}},[]);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(gi,{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(CP,{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 N2t=({children:t,onRefresh:s})=>{const[r,n]=S.useState(!1),[a,o]=S.useState(0),[l,i]=S.useState(!1),d=S.useRef(null),u=S.useRef(0),p=ns(),g=80,v=120,_=S.useCallback(C=>{const A=d.current;A&&A.scrollTop<=0&&(u.current=C.touches[0].clientY,n(!0))},[]),b=S.useCallback(C=>{if(!r||l)return;const A=d.current;if(!A||A.scrollTop>0){n(!1),o(0);return}const L=C.touches[0].clientY-u.current;if(L>0){const $=Math.min(L*.5,v);o($),$>10&&C.preventDefault()}},[r,l]),j=S.useCallback(async()=>{if(r)if(n(!1),a>=g&&!l){i(!0),o(g);try{s?await s():await p.invalidateQueries()}catch(C){console.error("Refresh failed:",C)}finally{i(!1),o(0)}}else o(0)},[r,a,l,s,p]),w=Math.min(a/g,1),N=w*180;return e.jsxs("div",{ref:d,className:"h-full overflow-auto",onTouchStart:_,onTouchMove:b,onTouchEnd:j,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:w},children:e.jsx("div",{className:`p-2 rounded-full bg-primary/10 ${l?"animate-spin":""}`,style:{transform:l?void 0:`rotate(${N}deg)`,transition:l?void 0:"transform 0.1s ease-out"},children:e.jsx(Eo,{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})]})},rqe=()=>{const{user:t}=Gs(),[s,r]=S.useState(!1),[n,a]=S.useState(!1),[o,l]=S.useState(0),[i,d]=S.useState(!0);S.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(),j=(b==null?void 0:b.login_count)||0;l(j);const w=sessionStorage.getItem("review-prompt-dismissed");r(j>=4&&!w)}catch(_){console.error("Error checking review eligibility:",_)}finally{d(!1)}})()},[t]);const u=S.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),p=S.useCallback(async(v,_)=>{if(!t)return{success:!1,error:"Not authenticated"};try{const{error:b}=await G.from("membership_reviews").insert({user_id:t.id,rating:v,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]),g=S.useCallback(async()=>{if(t)try{await G.from("membership_reviews").update({posted_to_google:!0}).eq("user_id",t.id)}catch(v){console.error("Error updating Google review status:",v)}},[t]);return{shouldShowPrompt:s,hasSubmittedReview:n,loginCount:o,isLoading:i,dismissPrompt:u,submitReview:p,markPostedToGoogle:g}},S2t="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",C2t=()=>{const{shouldShowPrompt:t,isLoading:s,dismissPrompt:r,submitReview:n,markPostedToGoogle:a}=rqe(),[o,l]=S.useState(!1),[i,d]=S.useState("review"),[u,p]=S.useState(0),[g,v]=S.useState(0),[_,b]=S.useState(""),[j,w]=S.useState(!1),[N,C]=S.useState(!1);if(s||!t&&!N)return null;const A=async()=>{if(u===0){an({title:"Please select a rating",variant:"destructive"});return}w(!0);const R=await n(u,_);w(!1),R.success?(C(!0),an({title:"Thank you for your feedback!",description:"Your review helps us improve."}),d("google")):an({title:"Error submitting review",description:R.error,variant:"destructive"})},I=async R=>{R&&(await navigator.clipboard.writeText(_||`${u} star rating for LevelUp!`),an({title:"Review copied!",description:"Paste it on Google Reviews."}),await a(),window.open(S2t,"_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(vs,{open:o,onOpenChange:L,children:e.jsx(ys,{className:"sm:max-w-md",children:i==="review"?e.jsxs(e.Fragment,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:()=>v(R),onMouseLeave:()=>v(0),className:"p-1 transition-transform hover:scale-110",children:e.jsx(Gn,{className:Et("h-8 w-8 transition-colors",(g||u)>=R?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},R))}),e.jsx(Tr,{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:A,disabled:j||u===0,className:"flex-1",children:j?"Submitting...":"Submit Review"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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 M2t(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(!g){l(!1);return}(async()=>{try{const j="vapid_public_key";let w=localStorage.getItem(j);if(!w){const{data:A,error:I}=await G.functions.invoke("get-vapid-public-key",{body:{}});if(I)throw I;if(w=(A==null?void 0:A.vapidPublicKey)??null,!w)throw new Error("Missing VAPID public key");localStorage.setItem(j,w)}p(w);const N=await navigator.serviceWorker.register("/push-sw.js");d(N),r(Notification.permission);const C=await N.pushManager.getSubscription();a(!!C)}catch(j){console.error("Error initializing push notifications:",j)}finally{l(!1)}})()},[g]);const v=S.useCallback(async()=>{if(!g||!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:A}=await G.from("push_subscriptions").delete().eq("user_id",t.id);A&&console.warn("Failed to cleanup push_subscriptions rows:",A)}if(Notification.permission!=="granted"){const A=await Notification.requestPermission();if(r(A),A!=="granted")return A==="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 j=M2t(u);let w;try{w=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:j})}catch(A){console.error("PushManager.subscribe() failed:",A);const I=(A==null?void 0:A.message)||String(A);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 N=w.toJSON(),{error:C}=await G.from("push_subscriptions").upsert({user_id:t.id,endpoint:N.endpoint,p256dh_key:N.keys.p256dh,auth_key:N.keys.auth},{onConflict:"user_id,endpoint"});if(C)throw console.error("Error saving subscription:",C),fe.error("Failed to save notification preferences. Please try again."),C;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 j=b instanceof Error?b.message:"Unknown error";fe.error("Failed to enable push notifications: "+j)}return!1}finally{l(!1)}},[g,i,t,u]),_=S.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 j=b instanceof Error?b.message:"Unknown error";return fe.error("Failed to disable push notifications: "+j),!1}finally{l(!1)}},[i,t]);return{isSupported:g,permission:s,isSubscribed:n,isLoading:o,vapidPublicKey:u,subscribe:v,unsubscribe:_}}const $he="push_notification_prompt_dismissed",T2t=()=>{const{user:t}=Gs(),{isSupported:s,isSubscribed:r,isLoading:n,subscribe:a}=nqe(),[o,l]=S.useState(!1),[i,d]=S.useState(!1);S.useEffect(()=>{if(!t||!s||r||n||localStorage.getItem(`${$he}_${t.id}`))return;const v=setTimeout(()=>{l(!0)},2e3);return()=>clearTimeout(v)},[t,s,r,n]);const u=async()=>{d(!0);const g=await a();d(!1),g&&(t&&localStorage.setItem(`${$he}_${t.id}`,"true"),l(!1))},p=()=>{t&&localStorage.setItem(`${$he}_${t.id}`,"true"),l(!1)};return!s||r?null:e.jsx(vs,{open:o,onOpenChange:g=>!g&&p(),children:e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Cs,{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(cf,{className:"h-6 w-6 text-primary"})}),e.jsx(Ss,{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."})]})})},x3e=t=>{let s;const r=new Set,n=(u,p)=>{const g=typeof u=="function"?u(s):u;if(!Object.is(g,s)){const v=s;s=p??(typeof g!="object"||g===null)?g:Object.assign({},s,g),r.forEach(_=>_(s,v))}},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},A2t=t=>t?x3e(t):x3e,E2t=t=>t;function P2t(t,s=E2t){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 y3e=t=>{const s=A2t(t),r=n=>P2t(s,n);return Object.assign(r,s),r},I2t=t=>t?y3e(t):y3e;function L2t(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 Vge=t=>s=>{try{const r=t(s);return r instanceof Promise?r:{then(n){return Vge(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return Vge(n)(r)}}}},D2t=(t,s)=>(r,n,a)=>{let o={storage:L2t(()=>localStorage),partialize:j=>j,version:0,merge:(j,w)=>({...w,...j}),...s},l=!1;const i=new Set,d=new Set;let u=o.storage;if(!u)return t((...j)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...j)},n,a);const p=()=>{const j=o.partialize({...n()});return u.setItem(o.name,{state:j,version:o.version})},g=a.setState;a.setState=(j,w)=>(g(j,w),p());const v=t((...j)=>(r(...j),p()),n,a);a.getInitialState=()=>v;let _;const b=()=>{var j,w;if(!u)return;l=!1,i.forEach(C=>{var A;return C((A=n())!=null?A:v)});const N=((w=o.onRehydrateStorage)==null?void 0:w.call(o,(j=n())!=null?j:v))||void 0;return Vge(u.getItem.bind(u))(o.name).then(C=>{if(C)if(typeof C.version=="number"&&C.version!==o.version){if(o.migrate){const A=o.migrate(C.state,C.version);return A instanceof Promise?A.then(I=>[!0,I]):[!0,A]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,C.state];return[!1,void 0]}).then(C=>{var A;const[I,L]=C;if(_=o.merge(L,(A=n())!=null?A:v),r(_,!0),I)return p()}).then(()=>{N==null||N(_,void 0),_=n(),l=!0,d.forEach(C=>C(_))}).catch(C=>{N==null||N(void 0,C)})};return a.persist={setOptions:j=>{o={...o,...j},j.storage&&(u=j.storage)},clearStorage:()=>{u==null||u.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>b(),hasHydrated:()=>l,onHydrate:j=>(i.add(j),()=>{i.delete(j)}),onFinishHydration:j=>(d.add(j),()=>{d.delete(j)})},o.skipHydration||b(),_||v},O2t=D2t,Uoe=I2t()(O2t((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})})),aqe=S.createContext({onlineUsers:[],totalOnline:0}),R2t=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{}},F2t=({children:t})=>{const{user:s,brokerageId:r,isAdmin:n}=Gs(),[a,o]=S.useState([]),[l,i]=S.useState(null);S.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(),g=[];Object.entries(p).forEach(([v,_])=>{if(_&&_.length>0){const b=_[0];g.push({id:v,name:b.name||"Unknown",avatarUrl:b.avatarUrl,brokerageId:b.brokerageId,onlineSince:b.onlineSince})}}),o(g)}).on("presence",{event:"join"},()=>{}).on("presence",{event:"leave"},()=>{}).subscribe(async p=>{var g;if(p==="SUBSCRIBED"){const{data:v}=await G.from("profiles").select("name, brokerage_id").eq("id",s.id).single(),_=await R2t(s.id);await u.track({name:(v==null?void 0:v.name)||((g=s.email)==null?void 0:g.split("@")[0])||"User",avatarUrl:_,brokerageId:v==null?void 0:v.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(aqe.Provider,{value:{onlineUsers:d,totalOnline:a.length},children:t})},iqe=()=>S.useContext(aqe),v3e="dashboard-sidebar-collapsed",Ms=({children:t,title:s})=>{var Ue;const{user:r,signOut:n,isAdmin:a,isBrokerageManager:o,brokerageId:l}=Gs(),{isAssistant:i,actingAsAgent:d,hasPermission:u}=M1e(),{isImpersonating:p}=C1e(),v=(i&&!!d?40:0)+(p?40:0),{avatarUrl:_}=H9e(r==null?void 0:r.id),{isTrial:b,isExpired:j,expiresAt:w}=Dbt(r==null?void 0:r.id),{isMarketplaceEnabled:N}=G9e(),{currentBrief:C,shouldShowPopup:A,hasUnseenBrief:I,openBrief:L,closeBrief:R,dismissBrief:$}=j2t(),{unreadCount:q}=Obt(),{openCount:U}=Rbt(),{data:V}=Mf(),X=!!V,te=Uoe(ut=>ut.cartItems).reduce((ut,De)=>ut+De.quantity,0),Y=Lr(),de=xu(),[ie,ae]=S.useState(null);S.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=ie||((Ue=r==null?void 0:r.user_metadata)==null?void 0:Ue.name)||(r==null?void 0:r.email)||"User",[pe,be]=S.useState(()=>typeof window<"u"?localStorage.getItem(v3e)==="true":!1);S.useEffect(()=>{localStorage.setItem(v3e,String(pe))},[pe]);const[ye,we]=S.useState({agentos:!0,tools:!0,marketing:!0,learning:!0,community:!0,contacts:!0,help:!1}),Ne=ut=>{we(De=>({...De,[ut]:!De[ut]}))},Ke=ut=>ut.split(" ").map(De=>De[0]).join("").toUpperCase().slice(0,2),_e=ut=>de.pathname===ut,Me=ut=>ut.some(De=>de.pathname===De),Te=({path:ut,icon:De,label:Dt,badgeCount:he})=>{const Ve=e.jsxs(K,{variant:"ghost",size:"sm",className:Et("text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",_e(ut)&&"bg-sidebar-accent text-sidebar-accent-foreground",pe?"w-10 h-10 p-0 justify-center":"w-full justify-start gap-2"),onClick:()=>Y(ut),children:[e.jsxs("div",{className:"relative",children:[e.jsx(De,{className:"h-4 w-4 shrink-0"}),pe&&he!=null&&he>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]}),!pe&&Dt,!pe&&he!=null&&he>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:he>9?"9+":he})]});return pe?e.jsxs(nd,{delayDuration:0,children:[e.jsx(ad,{asChild:!0,children:Ve}),e.jsxs(Hc,{side:"right",className:"flex items-center gap-2",children:[Dt,he!=null&&he>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:he>9?"9+":he})]})]}):Ve},Fe=({id:ut,label:De,icon:Dt,children:he,activePaths:Ve,showBetaBadge:nt,defaultPath:Qe,badgeCount:ke})=>{if(pe){const ot=Qe||Ve[0];return e.jsxs(nd,{delayDuration:0,children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:Et("w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",Me(Ve)&&"text-primary"),onClick:()=>Y(ot),children:e.jsxs("div",{className:"relative",children:[e.jsx(Dt,{className:"h-4 w-4"}),ke!=null&&ke>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(Hc,{side:"right",className:"flex items-center gap-2",children:[De,nt&&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"}),ke!=null&&ke>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:ke>9?"9+":ke})]})]})}return e.jsxs(mf,{open:ye[ut],onOpenChange:()=>Ne(ut),children:[e.jsx(pf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Et("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me(Ve)&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2 font-semibold text-[15px]",children:[e.jsx(Dt,{className:"h-4 w-4"}),De,nt&&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:[ke!=null&&ke>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:ke>9?"9+":ke}),e.jsx(Vo,{className:Et("h-4 w-4 transition-transform duration-200",ye[ut]&&"rotate-180")})]})]})}),e.jsx(ff,{className:"pl-4 space-y-1 mt-1",children:he})]})},Ae=({isMobile:ut=!1})=>{const De=ut?!1:pe;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:Et("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:nwt,alt:"LevelUp",className:"h-8 w-auto"}):e.jsx("img",{src:rwt,alt:"LevelUp",className:"h-8 w-auto"}),!ut&&e.jsxs(nd,{delayDuration:0,children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>be(!De),children:e.jsx(Ol,{className:Et("h-4 w-4 transition-transform duration-300",De&&"rotate-180")})})}),e.jsx(Hc,{side:"right",children:De?"Expand sidebar":"Collapse sidebar"})]})]}),e.jsx(Fi,{className:"flex-1 [&_[data-radix-scroll-area-scrollbar]]:w-1.5",children:e.jsxs("nav",{className:Et("p-3 space-y-1",De&&"flex flex-col items-center"),children:[e.jsx(Te,{path:"/dashboard",icon:sN,label:"Dashboard"}),pe?e.jsxs(nd,{delayDuration:0,children:[e.jsx(ad,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Et("w-10 h-10 p-0 justify-center relative text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/levelup-u"),children:[e.jsx(th,{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(Hc,{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:Et("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/levelup-u"),children:[e.jsx(th,{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:kc,label:"Events"}),e.jsxs(Fe,{id:"agentos",label:"Agent OS",icon:a5,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:Ni,label:"Mission Control"}),u("contacts")&&!De&&e.jsxs(mf,{open:ye.contacts,onOpenChange:()=>Ne("contacts"),children:[e.jsx(pf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Et("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(Vo,{className:Et("h-3.5 w-3.5 transition-transform duration-200",ye.contacts&&"rotate-180")})]})}),e.jsxs(ff,{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:Mm,label:"Relationship Report"}),e.jsx(Te,{path:"/mission-control/sphere-gaps",icon:NP,label:"Sphere Gaps"}),e.jsx(Te,{path:"/mission-control/connect-page",icon:Ho,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:kc,label:"TouchPlans"}),u("pipeline")&&e.jsx(Te,{path:"/mission-control/pipeline",icon:Vx,label:"Deal Pipeline"}),u("pipeline")&&e.jsx(Te,{path:"/mission-control/tasks",icon:l0,label:"Tasks"}),u("popbys")&&e.jsx(Te,{path:"/mission-control/popbys",icon:ao,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:Xo,label:"Scorecard"}),u("listings")&&e.jsx(Te,{path:"/mission-control/listings",icon:Ca,label:"Listing Exchange"}),!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:Et("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/mission-control/smart-drips")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/mission-control/smart-drips"),children:[e.jsx(Lm,{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:Lm,label:"Smart Drips"})]}),e.jsxs(Fe,{id:"tools",label:"Tools",icon:ep,activePaths:["/apps","/ai-toolkit","/mission-control/my-card","/mission-control/presentations","/mission-control/guest-book","/mission-control/scheduler","/mission-control/landing-pages"],defaultPath:"/apps",children:[e.jsx(Te,{path:"/apps",icon:ep,label:"Apps"}),u("digital_card")&&!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:Et("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/mission-control/my-card")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/mission-control/my-card"),children:[e.jsx(mp,{className:"h-4 w-4"}),"Smart Card",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1.5 py-0.5 rounded-full bg-destructive text-destructive-foreground",children:"New"})]}),u("digital_card")&&De&&e.jsx(Te,{path:"/mission-control/my-card",icon:mp,label:"Smart Card"}),u("presentations")&&!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:Et("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground overflow-hidden",de.pathname.startsWith("/mission-control/presentations")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/mission-control/presentations"),children:[e.jsx(uf,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:"Presentations"})]}),u("presentations")&&De&&e.jsx(Te,{path:"/mission-control/presentations",icon:uf,label:"Smart Presentations"}),u("guest_book")&&!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:Et("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/mission-control/guest-book")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/mission-control/guest-book"),children:[e.jsx(cu,{className:"h-4 w-4"}),"Guest Book"]}),u("guest_book")&&De&&e.jsx(Te,{path:"/mission-control/guest-book",icon:cu,label:"Guest Book"}),!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:Et("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/mission-control/card-studio")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/mission-control/card-studio"),children:[e.jsx(br,{className:"h-4 w-4"}),"Card Studio"]}),De&&e.jsx(Te,{path:"/mission-control/card-studio",icon:br,label:"Card Studio"}),a&&!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:Et("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/mission-control/scheduler")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/mission-control/scheduler"),children:[e.jsx(kc,{className:"h-4 w-4"}),"Scheduler",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1.5 py-0.5 rounded-full bg-destructive text-destructive-foreground",children:"New"})]}),a&&De&&e.jsx(Te,{path:"/mission-control/scheduler",icon:kc,label:"Scheduler"}),!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:Et("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",de.pathname.startsWith("/mission-control/landing-pages")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/mission-control/landing-pages"),children:[e.jsx(Sn,{className:"h-4 w-4"}),"Landing Pages",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1.5 py-0.5 rounded-full bg-destructive text-destructive-foreground",children:"New"})]}),De&&e.jsx(Te,{path:"/mission-control/landing-pages",icon:Sn,label:"Landing Pages"})]}),e.jsxs(Fe,{id:"marketing",label:"Marketing",icon:Fg,activePaths:["/templates","/social-swag-2","/newsletters"],defaultPath:"/templates",children:[e.jsx(Te,{path:"/templates",icon:Rl,label:"Templates"}),e.jsx(Te,{path:"/social-swag-2",icon:L0,label:"Social Swag"}),e.jsx(Te,{path:"/newsletters",icon:E0,label:"Newsletters"})]}),e.jsxs(Fe,{id:"learning",label:"Learning",icon:cu,activePaths:["/academy","/toolbox"],defaultPath:"/academy",children:[e.jsx(Te,{path:"/academy",icon:th,label:"Academy"}),e.jsx(Te,{path:"/toolbox",icon:Kx,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:e_,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(rn,{className:"h-4 w-4"}),"Facebook Group"]})]}),e.jsxs(Fe,{id:"goods",label:"The Goods",icon:wm,activePaths:["/marketplace","/reward-store"],defaultPath:"/reward-store",children:[N&&!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:Et("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:()=>Y("/marketplace"),children:[e.jsx(wm,{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"})]}),N&&De&&e.jsx(Te,{path:"/marketplace",icon:wm,label:"Marketplace"}),e.jsx(Te,{path:"/reward-store",icon:Gi,label:"Reward Store"})]}),e.jsxs(Fe,{id:"help",label:"Help & Services",icon:n0,activePaths:["/support","/additional-services"],defaultPath:"/support",children:[e.jsx(Te,{path:"/support",icon:m5,label:"Support"}),e.jsx(Te,{path:"/additional-services",icon:mn,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:Fu,label:"Admin Dashboard"})}):e.jsxs(K,{variant:"ghost",size:"sm",className:Et("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:()=>Y("/admin"),children:[e.jsx(Fu,{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:Ca,label:"My Brokerage"}),e.jsx(Te,{path:"/brokerage-content",icon:cu,label:"Brokerage Content"})]}),X&&!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:Fl,label:"Manage Brokerages"}),e.jsx(Te,{path:"/brokerage/teams",icon:hr,label:"Teams"}),e.jsx(Te,{path:"/brokerage-resources",icon:eh,label:"Brokerage Resources"})]})]}):e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:Et("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/my-brokerage")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/my-brokerage"),children:[e.jsx(Ca,{className:"h-4 w-4"}),"My Brokerage"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:Et("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/brokerage-content")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/brokerage-content"),children:[e.jsx(cu,{className:"h-4 w-4"}),"Brokerage Content"]})]}),X&&!o&&e.jsxs(K,{variant:"ghost",size:"sm",className:Et("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/my-team")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/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:Et("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/brokerage/dashboard")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/brokerage/dashboard"),children:[e.jsx(Fl,{className:"h-4 w-4"}),"Manage Brokerages"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:Et("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/brokerage/teams")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/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:Et("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/brokerage-resources")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/brokerage-resources"),children:[e.jsx(eh,{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:Et("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",_e("/profile")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Y("/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(f5,{className:"h-4 w-4"}),"Sign Out"]})]})]})};return e.jsx(F2t,{children:e.jsx(YN,{children:e.jsxs("div",{className:"min-h-screen bg-background flex",children:[b&&j&&e.jsx(i2t,{}),typeof document<"u"&&_m.createPortal(e.jsx("aside",{className:Et("hidden md:flex flex-col bg-card border-r border-border fixed left-0 z-[2147483647] isolate !pointer-events-auto transition-[width] duration-300",pe?"w-16":"w-56"),style:{top:`${v}px`,height:`calc(100vh - ${v}px)`},children:e.jsx(Ae,{})}),document.body),e.jsxs("div",{className:Et("flex-1 flex flex-col overflow-hidden transition-all duration-300",pe?"md:ml-16":"md:ml-56"),style:{height:`calc(100vh - ${v}px)`,marginTop:`${v}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(fM,{children:[e.jsx(s_e,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"md:hidden",children:e.jsx(uP,{className:"h-5 w-5"})})}),e.jsx(tS,{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:awt,alt:"LevelUp",className:"h-8 w-auto"})}),e.jsx("div",{className:"hidden md:flex flex-1 justify-center",children:e.jsx(g3e,{})}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[b&&!j&&w&&e.jsx(a2t,{expiresAt:w,className:"hidden lg:flex"}),e.jsx("div",{className:"md:hidden",children:e.jsx(g3e,{})}),C&&e.jsx(o2t,{hasUnseenBrief:I,onClick:L}),N&&e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",onClick:()=>Y("/marketplace/cart"),children:[e.jsx(wm,{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(Ewt,{}),e.jsx($ge,{}),e.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",le.split(" ")[0],"!"]}),e.jsxs(yu,{children:[e.jsx(vu,{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(fn,{className:"h-9 w-9 cursor-pointer hover:opacity-80 transition-opacity",children:[e.jsx(Ma,{src:_||void 0}),e.jsx(gn,{className:"bg-primary text-primary-foreground font-medium text-sm",children:Ke(le)})]})})}),e.jsxs(Wd,{align:"end",className:"w-48",children:[e.jsxs(Da,{onClick:()=>Y("/profile"),className:"cursor-pointer",children:[e.jsx(Yi,{className:"h-4 w-4 mr-2"}),"Profile"]}),e.jsxs(Da,{onClick:()=>Y("/mission-control/integrations"),className:"cursor-pointer",children:[e.jsx(yP,{className:"h-4 w-4 mr-2"}),"Integrations"]}),e.jsx(k_,{}),e.jsxs(Da,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[e.jsx(f5,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),e.jsx(N2t,{children:e.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),C&&e.jsx(w2t,{brief:C,open:A,onClose:R,onDismiss:$}),e.jsx(k2t,{}),e.jsx(C2t,{}),e.jsx(T2t,{})]})]})})})},z2t=()=>{const{user:t}=Gs(),[s,r]=S.useState(!1),[n,a]=S.useState(null),[o,l]=S.useState(""),i=async g=>{var v;if(!(t!=null&&t.email)){fe.error("Please sign in to upgrade");return}r(!0),a(g);try{const{data:_,error:b}=await G.functions.invoke("create-checkout",{body:{tier:g,email:t.email,name:((v=t.user_metadata)==null?void 0:v.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(Ms,{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:g=>l(g.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(Lt,{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(zt,{className:"text-xl",children:"Individual Agent"}),e.jsx(yr,{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((g,v)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(fa,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),e.jsx("span",{children:g})]},v))}),e.jsxs(K,{className:"w-full",size:"lg",onClick:()=>i("individual_agent"),disabled:s,children:[s&&n==="individual_agent"?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(mn,{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(Lt,{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(Ca,{className:"h-7 w-7 text-amber-600"})}),e.jsx(zt,{className:"text-xl",children:"Brokerage"}),e.jsx(yr,{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((g,v)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(fa,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}),e.jsx("span",{children:g})]},v))}),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(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ca,{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(Lt,{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(Ca,{className:"h-7 w-7 text-purple-600"})}),e.jsx(zt,{className:"text-xl",children:"Brokerage 25+"}),e.jsx(yr,{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((g,v)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(fa,{className:"h-4 w-4 text-purple-600 mt-0.5 shrink-0"}),e.jsx("span",{children:g})]},v))}),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(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ca,{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(Zn,{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"})]})]})]})})]})})},B2t=()=>{const{user:t,loading:s,isBrokerageManager:r,brokerageId:n}=Gs(),a=Lr(),[o,l]=S.useState(""),[i,d]=S.useState(!1),[u,p]=S.useState(!1);S.useEffect(()=>{!s&&!t&&a("/auth")},[t,s,a]),S.useEffect(()=>{!s&&t&&n&&a("/profile?setup=true")},[t,s,n,a]);const g=async()=>{if(!o.trim()){fe.error("Please enter a brokerage name");return}const{data:v}=await G.auth.getSession(),_=v.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:j}=await G.functions.invoke("create-brokerage",{body:{name:o.trim()}});if(console.log("[SetupBrokerage] create-brokerage response",{data:b,error:j}),j)throw j;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(Lt,{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(As,{className:"w-10 h-10 text-primary animate-spin"})}),e.jsx(zt,{className:"text-2xl",children:"Setting Up Your Brokerage"}),e.jsx(yr,{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(fi,{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(As,{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(Lt,{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(Ca,{className:"w-10 h-10 text-primary"})}),e.jsx(zt,{className:"text-2xl",children:"Set Up Your Brokerage"}),e.jsx(yr,{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:v=>l(v.target.value),onKeyDown:v=>v.key==="Enter"&&g()}),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(fi,{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(fi,{className:"w-4 h-4 text-green-500"}),"Access exclusive brokerage resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(fi,{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(fi,{className:"w-4 h-4 text-green-500"}),"Share resources with your agents"]})]})]}),e.jsxs(K,{onClick:g,className:"w-full",disabled:i||!o.trim(),children:[i?"Creating...":"Create Brokerage",e.jsx(Ui,{className:"w-4 h-4 ml-2"})]})]})]})})},_3e=()=>{const t=Lr(),[s,r]=S.useState("verifying"),[n,a]=S.useState("");S.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(Lt,{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(zt,{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(yr,{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"})})]})})},$2t=()=>{const t=Lr(),[s]=Ac(),[r,n]=S.useState(s.get("code")||""),[a,o]=S.useState(""),[l,i]=S.useState(""),[d,u]=S.useState(""),[p,g]=S.useState(!1),[v,_]=S.useState(!1),[b,j]=S.useState(!1),[w,N]=S.useState(!1),[C,A]=S.useState(null),[I,L]=S.useState(null),[R,$]=S.useState(null),[q,U]=S.useState(null);S.useEffect(()=>{const te=s.get("code");te&&(n(te),V(te))},[s]);const V=async te=>{j(!0);const{data:Y,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||!Y){fe.error("Invalid invite code"),j(!1);return}if(!Y.is_active){fe.error("This invite code is no longer active"),j(!1);return}if(Y.max_uses&&Y.uses_count>=Y.max_uses){fe.error("This invite code has reached its maximum uses"),j(!1);return}if(Y.expires_at&&new Date(Y.expires_at){te.preventDefault(),V(r)},se=async te=>{var Y;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:ie,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}ie.user&&(await G.rpc("add_default_signup_tag",{user_id:ie.user.id}),I?await G.functions.invoke("assign-brokerage",{body:{userId:ie.user.id,brokerageId:I}}):q?await G.functions.invoke("assign-brokerage",{body:{userId:ie.user.id,trialDays:q}}):await G.functions.invoke("assign-brokerage",{body:{userId:ie.user.id,grandfathered:!0}}),C&&await G.from("invite_codes").update({uses_count:((Y=(await G.from("invite_codes").select("uses_count").eq("id",C).single()).data)==null?void 0:Y.uses_count)+1}).eq("id",C),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(Lt,{className:"text-center",children:[e.jsx(zt,{className:"text-2xl font-bold text-primary",children:R?`Join ${R}`:"Join LevelUp"}),e.jsx(yr,{children:w?R?`Create your account to join ${R}`:"Create your account to get started":"Enter your invite code to continue"})]}),e.jsx(Oe,{children:w?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:()=>g(!p),children:p?e.jsx(Tm,{className:"h-4 w-4"}):e.jsx(ya,{className:"h-4 w-4"})})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:v,children:v?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating Account..."]}):"Create Account"})]}):e.jsxs("form",{onSubmit:X,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(As,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify Code"})]})})]})})},q2t="/assets/testimonial-avatar-1-BsCQFauB.jpg",U2t="/assets/testimonial-avatar-2-B6VPVc2t.jpg",V2t="/assets/testimonial-avatar-3-GuEFwYUE.jpg",H2t="/assets/testimonial-avatar-4-98iKMtkB.jpg",W2t="/assets/testimonial-avatar-5-ZsZfyxMX.jpg",G2t=[q2t,U2t,V2t,H2t,W2t],K2t=eS({name:Yl().trim().min(2,"Name must be at least 2 characters").max(100),email:Yl().trim().email("Please enter a valid email address").max(255),phone:Yl().trim().min(10,"Please enter a valid phone number").max(20).optional().or(gne("")),brokerage:Yl().trim().max(200).optional().or(gne(""))}),Z2t=[{icon:gm,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:Rl,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:pc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:Sn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:ao,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],Y2t=[{icon:hr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:mn,title:"Smart TouchPlans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Zn,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Ou,title:"Birthday Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Ti,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:Xo,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Ni,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Lm,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],X2t=[{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."}],Q2t=()=>{const t=Lr(),[s,r]=S.useState(!1),[n,a]=S.useState({name:"",email:"",phone:"",brokerage:""}),[o,l]=S.useState({}),i=async d=>{var p,g;d.preventDefault(),l({});const u=K2t.safeParse(n);if(!u.success){const v={};u.error.errors.forEach(_=>{_.path[0]&&(v[_.path[0]]=_.message)}),l(v);return}r(!0);try{const{data:v,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:((g=n.brokerage)==null?void 0:g.trim())||void 0}});if(_){console.error("Trial signup error:",_),fe.error(_.message||"Something went wrong. Please try again.");return}if(v!=null&&v.error){fe.error(v.error);return}fe.success("🎉 Welcome aboard! Check your email to claim your account."),t("/trial/success")}catch(v){console.error("Trial signup error:",v),fe.error("Something went wrong. Please try again.")}finally{r(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(nh,{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:xne,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(mn,{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(la,{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(la,{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:G2t.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(Hx,{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(As,{className:"mr-2 h-5 w-5 animate-spin"}),"Creating Your Account..."]}):e.jsxs(e.Fragment,{children:["Start My Free Trial",e.jsx(Ui,{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:Z2t.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(Lt,{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(zt,{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(mn,{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:Y2t.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(Lt,{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(zt,{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:X2t.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(sh,{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(Lm,{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(Ui,{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:q1e,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."})]})})})]})]})},J2t=()=>{const t=Lr();return e.jsxs(e.Fragment,{children:[e.jsx(nh,{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:xne,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(la,{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(Nd,{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(Ui,{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:q1e,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm text-white/40",children:["© ",new Date().getFullYear()," LevelUp Consulting Group. All rights reserved."]})]})})})]})]})},ejt=eS({viewerName:Yl().min(1,"Name is required").max(100,"Name must be less than 100 characters"),viewerEmail:Yl().email("Please enter a valid email").max(255,"Email must be less than 255 characters"),viewerPhone:Yl().max(20,"Phone must be less than 20 characters").optional(),message:Yl().min(1,"Message is required").max(1e3,"Message must be less than 1000 characters")});function tjt({shareToken:t,agentName:s,hasContact:r}){const[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState(null),u=Ooe({resolver:Roe(ejt),defaultValues:{viewerName:"",viewerEmail:"",viewerPhone:"",message:""}}),p=async g=>{a(!0),d(null);try{const{data:v,error:_}=await G.functions.invoke("video-reply-notify",{body:{shareToken:t,viewerName:g.viewerName,viewerEmail:g.viewerEmail,viewerPhone:g.viewerPhone||void 0,message:g.message}});if(_)throw new Error(_.message);if(!(v!=null&&v.success))throw new Error((v==null?void 0:v.error)||"Failed to send reply");l(!0)}catch(v){console.error("Failed to submit reply:",v),d(v.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(la,{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(Lt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(pc,{className:"h-5 w-5 text-primary"}),e.jsx(zt,{className:"text-lg",children:"Reply to this video"})]}),e.jsx(yr,{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(Foe,{...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(vc,{control:u.control,name:"viewerName",render:({field:g})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Your Name *"}),e.jsx(dc,{children:e.jsx(Re,{placeholder:"John Smith",...g})}),e.jsx(Ah,{})]})}),e.jsx(vc,{control:u.control,name:"viewerEmail",render:({field:g})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Email *"}),e.jsx(dc,{children:e.jsx(Re,{type:"email",placeholder:"john@example.com",...g})}),e.jsx(Ah,{})]})})]}),!r&&e.jsx(vc,{control:u.control,name:"viewerPhone",render:({field:g})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Phone (optional)"}),e.jsx(dc,{children:e.jsx(Re,{type:"tel",placeholder:"(555) 123-4567",...g})}),e.jsx(Ah,{})]})}),e.jsx(vc,{control:u.control,name:"message",render:({field:g})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Message *"}),e.jsx(dc,{children:e.jsx(Tr,{placeholder:r?"Thanks for the video! I had a question about...":"I'm interested in learning more about...",className:"min-h-[100px] resize-none",...g})}),e.jsx(Ah,{})]})}),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(As,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ta,{className:"h-4 w-4"}),"Send Message"]})})]})})})]})}const sjt=()=>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(S0,{className:"absolute bottom-[20%] right-[10%] w-12 h-12 text-blue-600/15 rotate-12"})]}),rjt=()=>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(mn,{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(mn,{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(S0,{className:"absolute top-[8%] left-[5%] w-10 h-10 text-red-500/20 rotate-12"})]}),njt=()=>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(Ag,{className:"w-20 h-20 text-pink-400 rotate-12"})}),e.jsx("div",{className:"absolute top-[2%] right-[8%] opacity-15",children:e.jsx(Ag,{className:"w-16 h-16 text-rose-400 -rotate-12"})}),e.jsx("div",{className:"absolute bottom-[15%] left-[8%] opacity-15",children:e.jsx(Ag,{className:"w-14 h-14 text-purple-400 rotate-45"})}),e.jsx("div",{className:"absolute bottom-[20%] right-[5%] opacity-20",children:e.jsx(Ag,{className:"w-16 h-16 text-pink-300 -rotate-6"})}),e.jsx(Ni,{className:"absolute top-[15%] left-[30%] w-5 h-5 text-rose-300/40 fill-rose-300/20 animate-pulse"}),e.jsx(Ni,{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(Ni,{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"})]}),ajt=()=>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(ec,{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(ec,{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"}})]}),ijt=()=>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(Ag,{className:"absolute top-[20%] left-[32%] w-7 h-7 text-purple-400/30"}),e.jsx(Ag,{className:"absolute top-[12%] right-[28%] w-6 h-6 text-pink-400/30"}),e.jsx(o5,{className:"absolute top-[18%] left-[52%] w-5 h-5 text-sky-400/35"})]}),ojt=()=>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(eN,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-orange-400/25"}),e.jsx(eN,{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(mn,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-purple-400/35 animate-pulse"}),e.jsx(mn,{className:"absolute bottom-[28%] right-[25%] w-5 h-5 text-orange-400/30 animate-pulse",style:{animationDelay:"0.5s"}})]}),ljt=()=>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(a_,{className:"absolute bottom-[8%] left-[5%] w-20 h-20 text-green-600/18"}),e.jsx(a_,{className:"absolute bottom-[12%] right-[8%] w-16 h-16 text-emerald-600/15"}),e.jsx(a_,{className:"absolute bottom-[10%] left-[28%] w-12 h-12 text-green-500/12"}),e.jsx(I1,{className:"absolute top-[5%] left-[15%] w-10 h-10 text-sky-300/30 animate-pulse"}),e.jsx(I1,{className:"absolute top-[10%] right-[20%] w-8 h-8 text-blue-300/25 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(I1,{className:"absolute top-[18%] left-[45%] w-6 h-6 text-sky-200/25 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(I1,{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"})]}),cjt=()=>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(Ni,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-red-400/22 fill-red-400/12"}),e.jsx(Ni,{className:"absolute top-[20%] right-[25%] w-5 h-5 text-orange-400/22 fill-orange-400/12"})]}),djt=()=>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(mn,{className:"absolute top-[3%] left-[50%] w-10 h-10 text-yellow-400/40"}),e.jsx(Nd,{className:"absolute bottom-[18%] left-[10%] w-12 h-12 text-purple-400/18 rotate-12"}),e.jsx(Nd,{className:"absolute bottom-[20%] right-[12%] w-10 h-10 text-amber-400/15 -rotate-12"})]}),ujt=()=>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(mn,{className:"absolute top-[5%] left-[20%] w-7 h-7 text-blue-400/35"}),e.jsx(mn,{className:"absolute top-[10%] right-[18%] w-6 h-6 text-sky-400/30"})]}),hjt=()=>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(g0,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-green-500/25"}),e.jsx(g0,{className:"absolute top-[8%] right-[12%] w-12 h-12 text-emerald-500/20"}),e.jsx(g0,{className:"absolute bottom-[18%] left-[12%] w-14 h-14 text-green-400/22"}),e.jsx(g0,{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"})]})]})]}),mjt=()=>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(ec,{className:"absolute bottom-[20%] right-[12%] w-12 h-12 text-blue-500/18"}),e.jsx(ec,{className:"absolute top-[18%] left-[28%] w-8 h-8 text-indigo-400/15"}),e.jsx(S0,{className:"absolute top-[8%] left-[60%] w-10 h-10 text-indigo-400/18"})]}),pjt=()=>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(Ou,{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(Nd,{className:"absolute top-[8%] left-[45%] w-10 h-10 text-purple-400/22 rotate-12"}),e.jsx(ao,{className:"absolute bottom-[18%] right-[15%] w-12 h-12 text-rose-400/18"})]}),fjt=()=>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(Ni,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-rose-400/28 fill-rose-400/18"}),e.jsx(Ni,{className:"absolute top-[8%] right-[12%] w-14 h-14 text-pink-400/25 fill-pink-400/15"}),e.jsx(Ni,{className:"absolute bottom-[15%] left-[12%] w-12 h-12 text-red-400/22 fill-red-400/12"}),e.jsx(Ni,{className:"absolute bottom-[18%] right-[10%] w-13 h-13 text-rose-300/25 fill-rose-300/15"}),e.jsx(Ni,{className:"absolute top-[15%] left-[30%] w-6 h-6 text-pink-300/35 fill-pink-300/20 animate-pulse"}),e.jsx(Ni,{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(Ni,{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(Ni,{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"})]}),gjt=()=>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(n_,{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(n_,{className:"absolute top-[15%] left-[18%] w-10 h-10 text-yellow-400/30"}),e.jsx(mn,{className:"absolute top-[10%] left-[42%] w-7 h-7 text-amber-400/35"}),e.jsx(n_,{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"})]}),xjt=()=>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(Vn,{className:"absolute top-[8%] left-[10%] w-14 h-14 text-teal-500/22"}),e.jsx(Vn,{className:"absolute bottom-[15%] right-[8%] w-16 h-16 text-emerald-500/18"}),e.jsx(Em,{className:"absolute top-[12%] right-[18%] w-10 h-10 text-amber-400/25"}),e.jsx(Em,{className:"absolute bottom-[22%] left-[22%] w-8 h-8 text-yellow-400/22"}),e.jsx(Ni,{className:"absolute top-[18%] left-[40%] w-6 h-6 text-rose-400/22 fill-rose-400/12"}),e.jsx(Ni,{className:"absolute top-[22%] right-[35%] w-5 h-5 text-teal-400/20 fill-teal-400/10"}),e.jsx(mn,{className:"absolute top-[5%] left-[55%] w-8 h-8 text-teal-400/30"}),e.jsx(Nd,{className:"absolute bottom-[20%] left-[48%] w-10 h-10 text-cyan-400/18 rotate-12"})]}),yjt=()=>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(Nd,{className:"absolute top-[5%] left-[12%] w-14 h-14 text-emerald-400/25 rotate-12"}),e.jsx(Nd,{className:"absolute top-[8%] right-[10%] w-12 h-12 text-teal-400/22 -rotate-12"}),e.jsx(Em,{className:"absolute bottom-[18%] left-[18%] w-12 h-12 text-amber-400/25"}),e.jsx(Vn,{className:"absolute bottom-[15%] right-[12%] w-14 h-14 text-teal-500/18"}),e.jsx(mn,{className:"absolute top-[15%] left-[42%] w-10 h-10 text-emerald-400/35"}),e.jsx(mn,{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"})]}),vjt=()=>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(Em,{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2 w-24 h-24 text-amber-400/25 rotate-45"}),e.jsx(Em,{className:"absolute top-[10%] left-[12%] w-10 h-10 text-yellow-400/30"}),e.jsx(Em,{className:"absolute top-[12%] right-[15%] w-9 h-9 text-amber-300/25"}),e.jsx(Vn,{className:"absolute top-[8%] left-[42%] w-12 h-12 text-teal-500/18"}),e.jsx(Nd,{className:"absolute bottom-[22%] right-[18%] w-12 h-12 text-orange-400/18 rotate-12"}),e.jsx(mn,{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"})]}),_jt=()=>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(Vn,{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(Em,{className:"absolute top-[10%] right-[12%] w-10 h-10 text-amber-400/28"}),e.jsx(Ni,{className:"absolute top-[8%] left-[18%] w-8 h-8 text-rose-400/25 fill-rose-400/15"}),e.jsx(mn,{className:"absolute top-[12%] left-[45%] w-8 h-8 text-teal-400/30"}),e.jsx(k0,{className:"absolute top-[15%] right-[28%] w-10 h-10 text-emerald-400/20"})]}),b3e=()=>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"})]}),bjt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Ni,{className:"absolute top-6 left-[12%] w-4 h-4 text-rose-300/50 fill-rose-300/30 animate-pulse"}),e.jsx(Ni,{className:"absolute top-10 right-[18%] w-3 h-3 text-pink-300/50 fill-pink-300/30 animate-pulse delay-150"}),e.jsx(Ni,{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(Ni,{className:"absolute top-14 right-[35%] w-3.5 h-3.5 text-pink-300/40 fill-pink-300/20 animate-pulse delay-200"})]}),wjt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(k0,{className:"absolute top-5 left-[10%] w-4 h-4 text-blue-400/50 animate-pulse"}),e.jsx(mn,{className:"absolute top-10 right-[15%] w-3 h-3 text-amber-400/50 animate-pulse delay-100"}),e.jsx(Vn,{className:"absolute top-8 left-[38%] w-3 h-3 text-teal-300/40 animate-pulse delay-200"})]}),jjt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Qk,{className:"absolute top-5 left-[12%] w-4 h-4 text-amber-500/50 animate-pulse"}),e.jsx(g5,{className:"absolute top-10 right-[15%] w-3 h-3 text-rose-400/50 animate-pulse delay-100"}),e.jsx(Qk,{className:"absolute top-8 left-[40%] w-3 h-3 text-amber-400/40 animate-pulse delay-200"})]}),JA=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(mn,{className:"absolute top-5 left-[10%] w-4 h-4 text-emerald-400/50 animate-pulse"}),e.jsx(Nd,{className:"absolute top-10 right-[12%] w-5 h-5 text-amber-400/50 animate-pulse delay-150"}),e.jsx(mn,{className:"absolute top-8 left-[45%] w-3 h-3 text-sky-400/40 animate-pulse delay-300"})]}),w3e=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Vn,{className:"absolute top-6 left-[12%] w-4 h-4 text-teal-400/40 animate-pulse"}),e.jsx(mn,{className:"absolute top-10 right-[15%] w-3 h-3 text-emerald-400/50 animate-pulse delay-100"}),e.jsx(Vn,{className:"absolute top-4 right-[40%] w-3 h-3 text-cyan-400/30 animate-pulse delay-200"})]}),Hge=[{id:"default",name:"Classic",description:"Clean, professional look for any occasion",icon:e.jsx(mn,{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(Ni,{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(bjt,{})},{id:"thinking_of_you",name:"Thinking of You",description:"Let them know they're on your mind",icon:e.jsx(XE,{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(JA,{})},{id:"check_in",name:"Check-in",description:"Touch base with your contacts",icon:e.jsx(Qk,{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(jjt,{})},{id:"market_update",name:"Market Update",description:"Share real estate market insights",icon:e.jsx(Xo,{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(JA,{})},{id:"congratulations",name:"Congratulations",description:"Celebrate their achievements",icon:e.jsx(ec,{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(b3e,{})},{id:"welcome_neighborhood",name:"Welcome to the Neighborhood",description:"Greet new neighbors",icon:e.jsx(Ti,{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(w3e,{})},{id:"just_because",name:"Just Because",description:"No reason needed to connect",icon:e.jsx(g5,{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(JA,{})},{id:"birthday",name:"Birthday",description:"Celebrate their special day",icon:e.jsx(Ou,{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(pjt,{})},{id:"valentines_day",name:"Valentine's Day",description:"Show appreciation on this special day",icon:e.jsx(Ni,{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(fjt,{})},{id:"groundhog_day",name:"Groundhog Day",description:"A fun seasonal greeting",icon:e.jsx(n_,{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(gjt,{})},{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(djt,{})},{id:"easter",name:"Easter",description:"Celebrate the spring season",icon:e.jsx(o5,{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(ijt,{})},{id:"mothers_day",name:"Mother's Day",description:"Celebrate the amazing moms",icon:e.jsx(Ag,{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(njt,{})},{id:"fathers_day",name:"Father's Day",description:"Celebrate the amazing dads",icon:e.jsx(ec,{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(ajt,{})},{id:"memorial_day",name:"Memorial Day",description:"Honor those who served",icon:e.jsx(S0,{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(sjt,{})},{id:"independence_day",name:"4th of July",description:"Celebrate Independence Day",icon:e.jsx(Bh,{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(rjt,{})},{id:"labor_day",name:"Labor Day",description:"Celebrate the workers",icon:e.jsx(ec,{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(mjt,{})},{id:"halloween",name:"Halloween",description:"Spooky seasonal greetings",icon:e.jsx(eN,{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(ojt,{})},{id:"thanksgiving",name:"Thanksgiving",description:"Express gratitude this season",icon:e.jsx(Ni,{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(cjt,{})},{id:"christmas",name:"Christmas",description:"Spread holiday cheer",icon:e.jsx(a_,{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(ljt,{})},{id:"hanukkah",name:"Hanukkah",description:"Celebrate the Festival of Lights",icon:e.jsx(mn,{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(ujt,{})},{id:"st_patricks_day",name:"St. Patrick's Day",description:"Celebrate the luck of the Irish",icon:e.jsx(g0,{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(hjt,{})},{id:"home_anniversary",name:"Home Anniversary",description:"Celebrate their home ownership milestone",icon:e.jsx(Vn,{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(xjt,{})},{id:"under_contract",name:"Under Contract",description:"Celebrate this exciting milestone",icon:e.jsx(Nd,{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(yjt,{})},{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(w3e,{})},{id:"just_sold",name:"Just Sold",description:"Celebrate a successful sale",icon:e.jsx(Gc,{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(JA,{})},{id:"price_reduction",name:"Price Reduction",description:"Notify about a price change",icon:e.jsx(lN,{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(k0,{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(wjt,{})},{id:"closing_day",name:"Closing Day",description:"Celebrate their closing day",icon:e.jsx(Em,{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(vjt,{})},{id:"move_in_day",name:"Move-in Day",description:"Welcome them to their new home",icon:e.jsx(Vn,{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(_jt,{})},{id:"offer_accepted",name:"Offer Accepted",description:"Celebrate their accepted offer",icon:e.jsx(hu,{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(JA,{})},{id:"pre_approval",name:"Pre-Approval Congrats",description:"Congratulate on pre-approval",icon:e.jsx(ec,{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(b3e,{})}],kjt=[{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 Njt(t){return Hge.filter(s=>s.category===t)}function A5(t){return Hge.find(s=>s.id===t)||Hge[0]}function j3e(){const{shareToken:t,recipientToken:s}=Co(),[r,n]=S.useState(null),[a,o]=S.useState(null),[l,i]=S.useState(null),[d,u]=S.useState(!0),[p,g]=S.useState(null),[v,_]=S.useState(!0),b=S.useRef(null),j=S.useRef(0),w=S.useRef(0),N=(()=>{const se=new URLSearchParams(window.location.search);return s||se.get("rt")||null})(),C=S.useCallback((se,te=!1)=>{if(!N||se<=0)return;const Y=Math.max(1,Math.round(se));if(Y<=w.current)return;const ie=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${encodeURIComponent(N)}&e=watch&ws=${Y}`;te&&navigator.sendBeacon?navigator.sendBeacon(ie):fetch(ie,{method:"GET",keepalive:te}).catch(()=>{}),w.current=Math.max(w.current,Y)},[N]);S.useEffect(()=>{var le;if(!v||!(r!=null&&r.playback_url)||!N)return;let se=!1;const te=()=>{j.current>0&&C(j.current,!0)},Y=()=>{document.visibilityState==="hidden"&&te()},de=()=>{te()},ie=()=>{var be;if(se||!b.current||!((be=window.playerjs)!=null&&be.Player))return;const pe=new window.playerjs.Player(b.current);pe.on("timeupdate",ye=>{const we=Math.floor(Number((ye==null?void 0:ye.seconds)??0));!Number.isFinite(we)||we<=0||(j.current=Math.max(j.current,we))}),pe.on("pause",()=>{j.current>0&&C(j.current)}),pe.on("ended",()=>{j.current>0&&C(j.current,!0)})},ae=document.querySelector('script[data-bunny-playerjs="true"]');if((le=window.playerjs)!=null&&le.Player)ie();else if(ae)ae.addEventListener("load",ie,{once:!0});else{const pe=document.createElement("script");pe.src="https://assets.mediadelivery.net/playerjs/playerjs-latest.min.js",pe.async=!0,pe.defer=!0,pe.dataset.bunnyPlayerjs="true",pe.onload=ie,document.body.appendChild(pe)}return document.addEventListener("visibilitychange",Y),window.addEventListener("beforeunload",de),()=>{se=!0,document.removeEventListener("visibilitychange",Y),window.removeEventListener("beforeunload",de),te()}},[v,r==null?void 0:r.playback_url,N,C]),S.useEffect(()=>{j.current=0,w.current=0},[N,t]),S.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(ie=>{document.querySelectorAll(ie).forEach(ae=>{ae.style.display="none"})})};se();const te=[setTimeout(se,500),setTimeout(se,1500),setTimeout(se,3e3)],Y=new MutationObserver(se);return Y.observe(document.body,{childList:!0,subtree:!0}),()=>{te.forEach(clearTimeout),Y.disconnect()}},[]),S.useEffect(()=>{(async()=>{if(!t){g("Invalid share link"),u(!1);return}const{data:te,error:Y}=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(Y||!te){g("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:ie}=await G.storage.from("avatars").list(`${te.owner_user_id}`);if(ie&&ie.length>0){const{data:ae}=G.storage.from("avatars").getPublicUrl(`${te.owner_user_id}/${ie[0].name}`);i(ae.publicUrl)}}catch{}}}u(!1)})()},[t]);const A=se=>{if(!se)return"0:00";const te=Math.floor(se/60),Y=se%60;return`${te}:${Y.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=A5((r==null?void 0:r.page_template)||"default"),$=(r==null?void 0:r.recipient_name)||null,q=R.headerText($),V=`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(As,{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 X=R.id!=="default";return e.jsxs(e.Fragment,{children:[e.jsxs(nh,{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:V}),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:Et("min-h-screen flex items-center justify-center p-4 bg-gradient-to-b relative",R.gradientClasses),children:[X&&R.decorativeElement,e.jsxs("div",{className:"max-w-2xl w-full space-y-6 relative z-10",children:[X&&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:Et("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(fn,{className:"h-14 w-14 border-2 border-primary/20",children:[e.jsx(Ma,{src:l||void 0,alt:a.name||"Agent"}),e.jsx(gn,{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:X?"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(Zn,{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:v&&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 Y;se.currentTarget.style.display="none";const te=(Y=se.currentTarget.parentElement)==null?void 0:Y.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(dl,{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:A(r.duration_seconds)})]})}),!X&&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:v?"Enjoy the video!":"Click to play the video"})]}),!v&&e.jsx("div",{className:"flex justify-center",children:e.jsxs(K,{size:"lg",onClick:()=>_(!0),className:"gap-2",children:[e.jsx(dl,{className:"h-5 w-5"}),"Watch Video"]})}),e.jsx(tjt,{shareToken:t,agentName:(a==null?void 0:a.name)||null,hasContact:!!r.contact_id})]})]})]})}function Sjt(){return S.useEffect(()=>(document.body.classList.add("video-landing-page"),()=>{document.body.classList.remove("video-landing-page")}),[]),e.jsx(sht,{})}function Cjt(){const{token:t}=Co();return S.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(As,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading video preview…"})]})})}const Mjt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Tjt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},s4={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function Ajt(){var Y,de,ie,ae;const{slugOrId:t}=Co(),[s]=Ac(),{data:r,isLoading:n}=i9e(t||""),a=o9e(),o=Gyt(),l=s.get("ref"),[i,d]=S.useState(""),[u,p]=S.useState(""),[g,v]=S.useState(""),[_,b]=S.useState(""),[j,w]=S.useState(!1),[N,C]=S.useState(!1),[A,I]=S.useState(null),[L,R]=S.useState(!1);S.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()||!g.trim()||!r)){w(!0);try{await a.mutateAsync({listingId:r.id,agentId:r.agent_id,firstName:i.trim(),lastName:u.trim(),email:g.trim(),phone:_.trim(),shareToken:l}),C(!0),fe.success("Thanks! The agent will be in touch soon.")}catch(pe){console.error("Lead submission error:",pe),fe.error(`Failed to submit: ${pe.message||"Please try again"}`)}finally{w(!1)}}},U=(r==null?void 0:r.photos)||[],V=U.find(le=>le.is_primary)||U[0],X=()=>{A!==null&&I(A===0?U.length-1:A-1)},se=()=>{A!==null&&I(A===U.length-1?0:A+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(gs,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(gs,{className:"h-10 w-48 mb-6"}),e.jsx(gs,{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(gs,{className:"h-12 w-48"}),e.jsx(gs,{className:"h-6 w-full"}),e.jsx(gs,{className:"h-6 w-3/4"})]}),e.jsx(gs,{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:cne,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Vn,{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(nh,{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":""} ${s4[r.property_type]} in ${r.city}, ${r.state}. ${((Y=r.description)==null?void 0:Y.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 ${s4[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}`}),V&&e.jsx("meta",{property:"og:image",content:V.photo_url}),V&&e.jsx("meta",{property:"og:image:alt",content:`${r.property_address||r.city} - ${s4[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}`}),V&&e.jsx("meta",{name:"twitter:image",content:V.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||`${s4[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:cne,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(Ka,{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:V==null?void 0:V.photo_url,alt:`${r.property_address||r.city+", "+r.state} - ${s4[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,pe)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>I(pe+1),children:[e.jsx("img",{src:le.photo_url,alt:`${r.property_address||r.city} - Photo ${pe+2} of ${U.length}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),pe===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(at,{className:`${Mjt[r.status]} text-white border-0`,children:Tjt[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(Ti,{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(j0,{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($x,{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(Gx,{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(at,{variant:"secondary",children:[e.jsx(Ca,{className:"h-3 w-3 mr-1"}),s4[r.property_type]]}),r.lot_size&&e.jsxs(at,{variant:"secondary",children:["Lot: ",r.lot_size]}),r.has_hoa&&e.jsx(at,{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(rn,{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(dl,{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(dl,{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(Lt,{children:e.jsxs(zt,{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}),((ie=r.agent.brokerage)==null?void 0:ie.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:r.agent.brokerage.name})]})]}),e.jsxs(Ee,{className:"border-primary",children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Oe,{children:N?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:g,onChange:le=>v(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:j,children:j?"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(vs,{open:A!==null,onOpenChange:()=>I(null),children:e.jsxs(ys,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(Cs,{className:"sr-only",children:e.jsx(Ss,{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"})}),A!==null&&U[A]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:U[A].photo_url,alt:`Photo ${A+1}`,className:"w-full max-h-[80vh] object-contain"}),U.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:X,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(Ol,{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(qa,{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:[A+1," / ",U.length]})]})]})]})}),e.jsx(vs,{open:L,onOpenChange:R,children:e.jsxs(ys,{className:"max-w-4xl p-0 bg-black overflow-hidden",children:[e.jsx(Cs,{className:"sr-only",children:e.jsx(Ss,{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 Ejt(){var o;const{slug:t}=Co(),{data:s,isLoading:r,error:n}=u9e(t);if(S.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]),S.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(gs,{className:"h-28 w-28 rounded-full"}),e.jsx(gs,{className:"h-6 w-48"}),e.jsx(gs,{className:"h-4 w-36"})]}),e.jsx(gs,{className:"h-12 w-full"}),e.jsx(gs,{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(nh,{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(V1e,{card:s})]})}const w_e=S.createContext({});function j_e(t){const s=S.useRef(null);return s.current===null&&(s.current=t()),s.current}const Pjt=typeof window<"u",oqe=Pjt?S.useLayoutEffect:S.useEffect,Voe=S.createContext(null);function k_e(t,s){t.indexOf(s)===-1&&t.push(s)}function Nne(t,s){const r=t.indexOf(s);r>-1&&t.splice(r,1)}const ry=(t,s,r)=>r>s?s:r{};const T_={},lqe=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function cqe(t){return typeof t=="object"&&t!==null}const dqe=t=>/^0[^.\s]+$/u.test(t);function uqe(t){let s;return()=>(s===void 0&&(s=t()),s)}const gf=t=>t,Ijt=(t,s)=>r=>s(t(r)),CL=(...t)=>t.reduce(Ijt),YI=(t,s,r)=>{const n=s-t;return n===0?1:(r-t)/n};class S_e{constructor(){this.subscriptions=[]}add(s){return k_e(this.subscriptions,s),()=>Nne(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,af=t=>t/1e3;function hqe(t,s){return s?t*(1e3/s):0}const mqe=(t,s,r)=>(((1-3*r+3*s)*t+(3*r-6*s))*t+3*s)*t,Ljt=1e-7,Djt=12;function Ojt(t,s,r,n,a){let o,l,i=0;do l=s+(r-s)/2,o=mqe(l,n,a)-t,o>0?r=l:s=l;while(Math.abs(o)>Ljt&&++iOjt(o,0,1,t,r);return o=>o===0||o===1?o:mqe(a(o),s,n)}const pqe=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,fqe=t=>s=>1-t(1-s),gqe=ML(.33,1.53,.69,.99),C_e=fqe(gqe),xqe=pqe(C_e),yqe=t=>t>=1?1:(t*=2)<1?.5*C_e(t):.5*(2-Math.pow(2,-10*(t-1))),M_e=t=>1-Math.sin(Math.acos(t)),vqe=fqe(M_e),_qe=pqe(M_e),Rjt=ML(.42,0,1,1),Fjt=ML(0,0,.58,1),bqe=ML(.42,0,.58,1),zjt=t=>Array.isArray(t)&&typeof t[0]!="number",wqe=t=>Array.isArray(t)&&typeof t[0]=="number",Bjt={linear:gf,easeIn:Rjt,easeInOut:bqe,easeOut:Fjt,circIn:M_e,circInOut:_qe,circOut:vqe,backIn:C_e,backInOut:xqe,backOut:gqe,anticipate:yqe},$jt=t=>typeof t=="string",k3e=t=>{if(wqe(t)){N_e(t.length===4);const[s,r,n,a]=t;return ML(s,r,n,a)}else if($jt(t))return Bjt[t];return t},D8=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function qjt(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,g=!1,v=!1)=>{const b=v&&a?r:n;return g&&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 g=r;r=n,n=g,r.forEach(d),r.clear(),a=!1,o&&(o=!1,u.process(p))}};return u}const Ujt=40;function jqe(t,s){let r=!1,n=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,l=D8.reduce((A,I)=>(A[I]=qjt(o),A),{}),{setup:i,read:d,resolveKeyframes:u,preUpdate:p,update:g,preRender:v,render:_,postRender:b}=l,j=()=>{const A=T_.useManualTiming,I=A?a.timestamp:performance.now();r=!1,A||(a.delta=n?1e3/60:Math.max(Math.min(I-a.timestamp,Ujt),1)),a.timestamp=I,a.isProcessing=!0,i.process(a),d.process(a),u.process(a),p.process(a),g.process(a),v.process(a),_.process(a),b.process(a),a.isProcessing=!1,r&&s&&(n=!1,t(j))},w=()=>{r=!0,n=!0,a.isProcessing||t(j)};return{schedule:D8.reduce((A,I)=>{const L=l[I];return A[I]=(R,$=!1,q=!1)=>(r||w(),L.schedule(R,$,q)),A},{}),cancel:A=>{for(let I=0;I(nre===void 0&&Eh.set(Eu.isProcessing||T_.useManualTiming?Eu.timestamp:performance.now()),nre),set:t=>{nre=t,queueMicrotask(Vjt)}},kqe=t=>s=>typeof s=="string"&&s.startsWith(t),Nqe=kqe("--"),Hjt=kqe("var(--"),T_e=t=>Hjt(t)?Wjt.test(t.split("/*")[0].trim()):!1,Wjt=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function N3e(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const yM={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},XI={...yM,transform:t=>ry(0,1,t)},O8={...yM,default:1},GP=t=>Math.round(t*1e5)/1e5,A_e=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Gjt(t){return t==null}const Kjt=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,E_e=(t,s)=>r=>!!(typeof r=="string"&&Kjt.test(r)&&r.startsWith(t)||s&&!Gjt(r)&&Object.prototype.hasOwnProperty.call(r,s)),Sqe=(t,s,r)=>n=>{if(typeof n!="string")return n;const[a,o,l,i]=n.match(A_e);return{[t]:parseFloat(a),[s]:parseFloat(o),[r]:parseFloat(l),alpha:i!==void 0?parseFloat(i):1}},Zjt=t=>ry(0,255,t),Uhe={...yM,transform:t=>Math.round(Zjt(t))},Mk={test:E_e("rgb","red"),parse:Sqe("red","green","blue"),transform:({red:t,green:s,blue:r,alpha:n=1})=>"rgba("+Uhe.transform(t)+", "+Uhe.transform(s)+", "+Uhe.transform(r)+", "+GP(XI.transform(n))+")"};function Yjt(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 Wge={test:E_e("#"),parse:Yjt,transform:Mk.transform},TL=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),Jv=TL("deg"),Qx=TL("%"),Qn=TL("px"),Xjt=TL("vh"),Qjt=TL("vw"),S3e={...Qx,parse:t=>Qx.parse(t)/100,transform:t=>Qx.transform(t*100)},R4={test:E_e("hsl","hue"),parse:Sqe("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+Qx.transform(GP(s))+", "+Qx.transform(GP(r))+", "+GP(XI.transform(n))+")"},wd={test:t=>Mk.test(t)||Wge.test(t)||R4.test(t),parse:t=>Mk.test(t)?Mk.parse(t):R4.test(t)?R4.parse(t):Wge.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Mk.transform(t):R4.transform(t),getAnimatableNone:t=>{const s=wd.parse(t);return s.alpha=0,wd.transform(s)}},Jjt=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function ekt(t){var s,r;return isNaN(t)&&typeof t=="string"&&(((s=t.match(A_e))==null?void 0:s.length)||0)+(((r=t.match(Jjt))==null?void 0:r.length)||0)>0}const Cqe="number",Mqe="color",tkt="var",skt="var(",C3e="${}",rkt=/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 y3(t){const s=t.toString(),r=[],n={color:[],number:[],var:[]},a=[];let o=0;const i=s.replace(rkt,d=>(wd.test(d)?(n.color.push(o),a.push(Mqe),r.push(wd.parse(d))):d.startsWith(skt)?(n.var.push(o),a.push(tkt),r.push(d)):(n.number.push(o),a.push(Cqe),r.push(parseFloat(d))),++o,C3e)).split(C3e);return{values:r,split:i,indexes:n,types:a}}function nkt(t){return y3(t).values}function Tqe({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,okt=(t,s)=>typeof t=="number"?s!=null&&s.trim().endsWith("/")?t:0:ikt(t);function lkt(t){const s=y3(t);return Tqe(s)(s.values.map((n,a)=>okt(n,s.split[a])))}const zg={test:ekt,parse:nkt,createTransformer:akt,getAnimatableNone:lkt};function Vhe(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 ckt({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=Vhe(d,i,t+1/3),o=Vhe(d,i,t),l=Vhe(d,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:n}}function Sne(t,s){return r=>r>0?s:t}const Ql=(t,s,r)=>t+(s-t)*r,Hhe=(t,s,r)=>{const n=t*t,a=r*(s*s-n)+n;return a<0?0:Math.sqrt(a)},dkt=[Wge,Mk,R4],ukt=t=>dkt.find(s=>s.test(t));function M3e(t){const s=ukt(t);if(!s)return!1;let r=s.parse(t);return s===R4&&(r=ckt(r)),r}const T3e=(t,s)=>{const r=M3e(t),n=M3e(s);if(!r||!n)return Sne(t,s);const a={...r};return o=>(a.red=Hhe(r.red,n.red,o),a.green=Hhe(r.green,n.green,o),a.blue=Hhe(r.blue,n.blue,o),a.alpha=Ql(r.alpha,n.alpha,o),Mk.transform(a))},Gge=new Set(["none","hidden"]);function hkt(t,s){return Gge.has(t)?r=>r<=0?t:s:r=>r>=1?s:t}function mkt(t,s){return r=>Ql(t,s,r)}function P_e(t){return typeof t=="number"?mkt:typeof t=="string"?T_e(t)?Sne:wd.test(t)?T3e:gkt:Array.isArray(t)?Aqe:typeof t=="object"?wd.test(t)?T3e:pkt:Sne}function Aqe(t,s){const r=[...t],n=r.length,a=t.map((o,l)=>P_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 fkt(t,s){const r=[],n={color:0,var:0,number:0};for(let a=0;a{const r=zg.createTransformer(s),n=y3(t),a=y3(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?Gge.has(t)&&!a.values.length||Gge.has(s)&&!n.values.length?hkt(t,s):CL(Aqe(fkt(n,a),a.values),r):Sne(t,s)};function Eqe(t,s,r){return typeof t=="number"&&typeof s=="number"&&typeof r=="number"?Ql(t,s,r):P_e(t)(t,s)}const xkt=t=>{const s=({timestamp:r})=>t(r);return{start:(r=!0)=>pl.update(s,r),stop:()=>A_(s),now:()=>Eu.isProcessing?Eu.timestamp:Eh.now()}},Pqe=(t,s,r=10)=>{let n="";const a=Math.max(Math.round(s/r),2);for(let o=0;o=Cne?1/0:s}function ykt(t,s=100,r){const n=r({...t,keyframes:[0,s]}),a=Math.min(I_e(n),Cne);return{type:"keyframes",ease:o=>n.next(a*o).value/s,duration:af(a)}}const Oc={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 Kge(t,s){return t*Math.sqrt(1-s*s)}const vkt=12;function _kt(t,s,r){let n=r;for(let a=1;a{const p=u*l,g=p*t,v=p-r,_=Kge(u,l),b=Math.exp(-g);return Whe-v/_*b},o=u=>{const g=u*l*t,v=g*r+r,_=Math.pow(l,2)*Math.pow(u,2)*t,b=Math.exp(-g),j=Kge(Math.pow(u,2),l);return(-a(u)+Whe>0?-1:1)*((v-_)*b)/j}):(a=u=>{const p=Math.exp(-u*t),g=(u-r)*t+1;return-Whe+p*g},o=u=>{const p=Math.exp(-u*t),g=(r-u)*(t*t);return p*g});const i=5/t,d=_kt(a,o,i);if(t=xp(t),isNaN(d))return{stiffness:Oc.stiffness,damping:Oc.damping,duration:t};{const u=Math.pow(d,2)*n;return{stiffness:u,damping:l*2*Math.sqrt(n*u),duration:t}}}const wkt=["duration","bounce"],jkt=["stiffness","damping","mass"];function A3e(t,s){return s.some(r=>t[r]!==void 0)}function kkt(t){let s={velocity:Oc.velocity,stiffness:Oc.stiffness,damping:Oc.damping,mass:Oc.mass,isResolvedFromDuration:!1,...t};if(!A3e(t,jkt)&&A3e(t,wkt))if(s.velocity=0,t.visualDuration){const r=t.visualDuration,n=2*Math.PI/(r*1.2),a=n*n,o=2*ry(.05,1,1-(t.bounce||0))*Math.sqrt(a);s={...s,mass:Oc.mass,stiffness:a,damping:o}}else{const r=bkt({...t,velocity:0});s={...s,...r,mass:Oc.mass},s.isResolvedFromDuration=!0}return s}function Mne(t=Oc.visualDuration,s=Oc.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:g,velocity:v,isResolvedFromDuration:_}=kkt({...r,velocity:-af(r.velocity||0)}),b=v||0,j=u/(2*Math.sqrt(d*p)),w=l-o,N=af(Math.sqrt(d/p)),C=Math.abs(w)<5;n||(n=C?Oc.restSpeed.granular:Oc.restSpeed.default),a||(a=C?Oc.restDelta.granular:Oc.restDelta.default);let A,I,L,R,$,q;if(j<1)L=Kge(N,j),R=(b+j*N*w)/L,A=V=>{const X=Math.exp(-j*N*V);return l-X*(R*Math.sin(L*V)+w*Math.cos(L*V))},$=j*N*R+w*L,q=j*N*w-R*L,I=V=>Math.exp(-j*N*V)*($*Math.sin(L*V)+q*Math.cos(L*V));else if(j===1){A=X=>l-Math.exp(-N*X)*(w+(b+N*w)*X);const V=b+N*w;I=X=>Math.exp(-N*X)*(N*V*X-b)}else{const V=N*Math.sqrt(j*j-1);A=Y=>{const de=Math.exp(-j*N*Y),ie=Math.min(V*Y,300);return l-de*((b+j*N*w)*Math.sinh(ie)+V*w*Math.cosh(ie))/V};const X=(b+j*N*w)/V,se=j*N*X-w*V,te=j*N*w-X*V;I=Y=>{const de=Math.exp(-j*N*Y),ie=Math.min(V*Y,300);return de*(se*Math.sinh(ie)+te*Math.cosh(ie))}}const U={calculatedDuration:_&&g||null,velocity:V=>xp(I(V)),next:V=>{if(!_&&j<1){const se=Math.exp(-j*N*V),te=Math.sin(L*V),Y=Math.cos(L*V),de=l-se*(R*te+w*Y),ie=xp(se*($*te+q*Y));return i.done=Math.abs(ie)<=n&&Math.abs(l-de)<=a,i.value=i.done?l:de,i}const X=A(V);if(_)i.done=V>=g;else{const se=xp(I(V));i.done=Math.abs(se)<=n&&Math.abs(l-X)<=a}return i.value=i.done?l:X,i},toString:()=>{const V=Math.min(I_e(U),Cne),X=Pqe(se=>U.next(V*se).value,V,30);return V+"ms "+X},toTransition:()=>{}};return U}Mne.applyToOptions=t=>{const s=ykt(t,100,Mne);return t.ease=s.ease,t.duration=xp(s.duration),t.type="keyframes",t};const Nkt=5;function Iqe(t,s,r){const n=Math.max(s-Nkt,0);return hqe(r-t(n),s-n)}function Zge({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 g=t[0],v={done:!1,value:g},_=q=>i!==void 0&&qd,b=q=>i===void 0?d:d===void 0||Math.abs(i-q)-j*Math.exp(-q/n),A=q=>N+C(q),I=q=>{const U=C(q),V=A(q);v.done=Math.abs(U)<=u,v.value=v.done?N:V};let L,R;const $=q=>{_(v.value)&&(L=q,R=Mne({keyframes:[v.value,b(v.value)],velocity:Iqe(A,q,v.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),v)}}}function Skt(t,s,r){const n=[],a=r||T_.mix||Eqe,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=Skt(s,n,a),d=i.length,u=p=>{if(l&&p1)for(;gu(ry(t[0],t[o-1],p)):u}function Mkt(t,s){const r=t[t.length-1];for(let n=1;n<=s;n++){const a=YI(0,s,n);t.push(Ql(r,1,a))}}function Tkt(t){const s=[0];return Mkt(s,t.length-1),s}function Akt(t,s){return t.map(r=>r*s)}function Ekt(t,s){return t.map(()=>s||bqe).splice(0,t.length-1)}function KP({duration:t=300,keyframes:s,times:r,ease:n="easeInOut"}){const a=zjt(n)?n.map(k3e):k3e(n),o={done:!1,value:s[0]},l=Akt(r&&r.length===s.length?r:Tkt(s),t),i=Ckt(l,s,{ease:Array.isArray(a)?a:Ekt(s,a)});return{calculatedDuration:t,next:d=>(o.value=i(d),o.done=d>=t,o)}}const Pkt=t=>t!==null;function Hoe(t,{repeat:s,repeatType:r="loop"},n,a=1){const o=t.filter(Pkt),i=a<0||s&&r!=="loop"&&s%2===1?0:o.length-1;return!i||n===void 0?o[i]:n}const Ikt={decay:Zge,inertia:Zge,tween:KP,keyframes:KP,spring:Mne};function Lqe(t){typeof t.type=="string"&&(t.type=Ikt[t.type])}class L_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 Lkt=t=>t/100;class Tne extends L_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!==Eh.now()&&this.tick(Eh.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;Lqe(s);const{type:r=KP,repeat:n=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=s;let{keyframes:i}=s;const d=r||KP;d!==KP&&typeof i[0]!="number"&&(this.mixKeyframes=CL(Lkt,Eqe(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=I_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:g,repeatType:v,repeatDelay:_,type:b,onUpdate:j,finalKeyframe:w}=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 N=this.currentTime-u*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?N<0:N>a;this.currentTime=Math.max(N,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let A=this.currentTime,I=n;if(g){const q=Math.min(this.currentTime,a)/i;let U=Math.floor(q),V=q%1;!V&&q>=1&&(V=1),V===1&&U--,U=Math.min(U,g+1),!!(U%2)&&(v==="reverse"?(V=1-V,_&&(V-=_/i)):v==="mirror"&&(I=l)),A=ry(0,1,V)*i}let L;C?(this.delayState.value=p[0],L=this.delayState):L=I.next(A),o&&!C&&(L.value=o(L.value));let{done:R}=L;!C&&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!==Zge&&(L.value=Hoe(p,this.options,w,this.speed)),j&&j(L.value),$&&this.finish(),L}then(s,r){return this.finished.then(s,r)}get duration(){return af(this.calculatedDuration)}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+af(s)}get time(){return af(this.currentTime)}set time(s){s=xp(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 Iqe(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(Eh.now()),this.playbackSpeed=s,r&&this.driver&&(this.time=af(this.currentTime))}play(){var a,o;if(this.isStopped)return;const{driver:s=xkt,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(Eh.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 Dkt(t){for(let s=1;st*180/Math.PI,Yge=t=>{const s=Tk(Math.atan2(t[1],t[0]));return Xge(s)},Okt={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Yge,rotateZ:Yge,skewX:t=>Tk(Math.atan(t[1])),skewY:t=>Tk(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Xge=t=>(t=t%360,t<0&&(t+=360),t),E3e=Yge,P3e=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),I3e=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Rkt={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:P3e,scaleY:I3e,scale:t=>(P3e(t)+I3e(t))/2,rotateX:t=>Xge(Tk(Math.atan2(t[6],t[5]))),rotateY:t=>Xge(Tk(Math.atan2(-t[2],t[0]))),rotateZ:E3e,rotate:E3e,skewX:t=>Tk(Math.atan(t[4])),skewY:t=>Tk(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Qge(t){return t.includes("scale")?1:0}function Jge(t,s){if(!t||t==="none")return Qge(s);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,a;if(r)n=Rkt,a=r;else{const i=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=Okt,a=i}if(!a)return Qge(s);const o=n[s],l=a[1].split(",").map(zkt);return typeof o=="function"?o(l):l[o]}const Fkt=(t,s)=>{const{transform:r="none"}=getComputedStyle(t);return Jge(r,s)};function zkt(t){return parseFloat(t.trim())}const vM=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],_M=new Set(vM),L3e=t=>t===yM||t===Qn,Bkt=new Set(["x","y","z"]),$kt=vM.filter(t=>!Bkt.has(t));function qkt(t){const s=[];return $kt.forEach(r=>{const n=t.getValue(r);n!==void 0&&(s.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),s}const O1={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})=>Jge(s,"x"),y:(t,{transform:s})=>Jge(s,"y")};O1.translateX=O1.x;O1.translateY=O1.y;const dN=new Set;let exe=!1,txe=!1,sxe=!1;function Dqe(){if(txe){const t=Array.from(dN).filter(n=>n.needsMeasurement),s=new Set(t.map(n=>n.element)),r=new Map;s.forEach(n=>{const a=qkt(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)})}txe=!1,exe=!1,dN.forEach(t=>t.complete(sxe)),dN.clear()}function Oqe(){dN.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(txe=!0)})}function Ukt(){sxe=!0,Oqe(),Dqe(),sxe=!1}class D_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?(dN.add(this),exe||(exe=!0,pl.read(Oqe),pl.resolveKeyframes(Dqe))):(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])}Dkt(s)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(s=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,s),dN.delete(this)}cancel(){this.state==="scheduled"&&(dN.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Vkt=t=>t.startsWith("--");function Rqe(t,s,r){Vkt(s)?t.style.setProperty(s,r):t.style[s]=r}const Hkt={};function Fqe(t,s){const r=uqe(t);return()=>Hkt[s]??r()}const Wkt=Fqe(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),zqe=Fqe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),CE=([t,s,r,n])=>`cubic-bezier(${t}, ${s}, ${r}, ${n})`,D3e={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:CE([0,.65,.55,1]),circOut:CE([.55,0,1,.45]),backIn:CE([.31,.01,.66,-.59]),backOut:CE([.33,1.53,.69,.99])};function Bqe(t,s){if(t)return typeof t=="function"?zqe()?Pqe(t,s):"ease-out":wqe(t)?CE(t):Array.isArray(t)?t.map(r=>Bqe(r,s)||D3e.easeOut):D3e[t]}function Gkt(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 g=Bqe(i,a);Array.isArray(g)&&(p.easing=g);const v={delay:n,duration:a,easing:Array.isArray(g)?"linear":g,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"};return u&&(v.pseudoElement=u),t.animate(p,v)}function $qe(t){return typeof t=="function"&&"applyToOptions"in t}function Kkt({type:t,...s}){return $qe(t)&&zqe()?t.applyToOptions(s):(s.duration??(s.duration=300),s.ease??(s.ease="easeOut"),s)}class qqe extends L_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,N_e(typeof s.type!="string");const u=Kkt(s);this.animation=Gkt(r,n,a,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=Hoe(a,this.options,i,this.speed);this.updateMotionValue&&this.updateMotionValue(p),Rqe(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 af(Number(s))}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+af(s)}get time(){return af(Number(this.animation.currentTime)||0)}set time(s){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=xp(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&&Wkt()?(this.animation.timeline=s,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),gf):a(this)}}const Uqe={anticipate:yqe,backInOut:xqe,circInOut:_qe};function Zkt(t){return t in Uqe}function Ykt(t){typeof t.ease=="string"&&Zkt(t.ease)&&(t.ease=Uqe[t.ease])}const Ghe=10;class Xkt extends qqe{constructor(s){Ykt(s),Lqe(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 Tne({...l,autoplay:!1}),d=Math.max(Ghe,Eh.now()-this.startTime),u=ry(0,Ghe,d-Ghe),p=i.sample(d).value,{name:g}=this.options;o&&g&&Rqe(o,g,p),r.setWithVelocity(i.sample(Math.max(0,d-u)).value,p,u),i.stop()}}const O3e=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(zg.test(t)||t==="0")&&!t.startsWith("url("));function Qkt(t){const s=t[0];if(t.length===1)return!0;for(let r=0;rObject.hasOwnProperty.call(Element.prototype,"animate"));function nNt(t){var g;const{motionValue:s,name:r,repeatDelay:n,repeatType:a,damping:o,type:l,keyframes:i}=t;if(!(((g=s==null?void 0:s.owner)==null?void 0:g.current)instanceof HTMLElement))return!1;const{onUpdate:u,transformTemplate:p}=s.owner.getProps();return rNt()&&r&&(Vqe.has(r)||sNt.has(r)&&tNt(i))&&(r!=="transform"||!p)&&!u&&!n&&a!=="mirror"&&o!==0&&l!=="inertia"}const aNt=40;class iNt extends L_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,...g}){var b;super(),this.stop=()=>{var j,w;this._animation&&(this._animation.stop(),(j=this.stopTimeline)==null||j.call(this)),(w=this.keyframeResolver)==null||w.cancel()},this.createdAt=Eh.now();const v={autoplay:s,delay:r,type:n,repeat:a,repeatDelay:o,repeatType:l,name:d,motionValue:u,element:p,...g},_=(p==null?void 0:p.KeyframeResolver)||D_e;this.keyframeResolver=new _(i,(j,w,N)=>this.onKeyframesResolved(j,w,v,!N),d,u,p),(b=this.keyframeResolver)==null||b.scheduleResolve()}onKeyframesResolved(s,r,n,a){var N,C;this.keyframeResolver=void 0;const{name:o,type:l,velocity:i,delay:d,isHandoff:u,onUpdate:p}=n;this.resolvedAt=Eh.now();let g=!0;Jkt(s,o,l,i)||(g=!1,(T_.instantAnimations||!d)&&(p==null||p(Hoe(s,n,r))),s[0]=s[s.length-1],rxe(n),n.repeat=0);const _={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>aNt?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:s},b=g&&!u&&nNt(_),j=(C=(N=_.motionValue)==null?void 0:N.owner)==null?void 0:C.current;let w;if(b)try{w=new Xkt({..._,element:j})}catch{w=new Tne(_)}else w=new Tne(_);w.finished.then(()=>{this.notifyFinished()}).catch(gf),this.pendingTimeline&&(this.stopTimeline=w.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=w}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(),Ukt()),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 Hqe(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 oNt=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function lNt(t){const s=oNt.exec(t);if(!s)return[,];const[,r,n,a]=s;return[`--${r??n}`,a]}function Wqe(t,s,r=1){const[n,a]=lNt(t);if(!n)return;const o=window.getComputedStyle(s).getPropertyValue(n);if(o){const l=o.trim();return lqe(l)?parseFloat(l):l}return T_e(a)?Wqe(a,s,r+1):a}const cNt={type:"spring",stiffness:500,damping:25,restSpeed:10},dNt=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),uNt={type:"keyframes",duration:.8},hNt={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},mNt=(t,{keyframes:s})=>s.length>2?uNt:_M.has(t)?t.startsWith("scale")?dNt(s[1]):cNt:hNt;function Gqe(t,s){if(t!=null&&t.inherit&&s){const{inherit:r,...n}=t;return{...s,...n}}return t}function O_e(t,s){const r=(t==null?void 0:t[s])??(t==null?void 0:t.default)??t;return r!==t?Gqe(r,t):r}const pNt=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function fNt(t){for(const s in t)if(!pNt.has(s))return!0;return!1}const R_e=(t,s,r,n={},a,o)=>l=>{const i=O_e(n,t)||{},d=i.delay||n.delay||0;let{elapsed:u=0}=n;u=u-xp(d);const p={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:s.getVelocity(),...i,delay:-u,onUpdate:v=>{s.set(v),i.onUpdate&&i.onUpdate(v)},onComplete:()=>{l(),i.onComplete&&i.onComplete()},name:t,motionValue:s,element:o?void 0:a};fNt(i)||Object.assign(p,mNt(t,p)),p.duration&&(p.duration=xp(p.duration)),p.repeatDelay&&(p.repeatDelay=xp(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let g=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(rxe(p),p.delay===0&&(g=!0)),(T_.instantAnimations||T_.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(g=!0,rxe(p),p.delay=0),p.allowFlatten=!i.type&&!i.ease,g&&!o&&s.get()!==void 0){const v=Hoe(p.keyframes,i);if(v!==void 0){pl.update(()=>{p.onUpdate(v),p.onComplete()});return}}return i.isSync?new Tne(p):new iNt(p)};function R3e(t){const s=[{},{}];return t==null||t.values.forEach((r,n)=>{s[0][n]=r.get(),s[1][n]=r.getVelocity()}),s}function F_e(t,s,r,n){if(typeof s=="function"){const[a,o]=R3e(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]=R3e(n);s=s(r!==void 0?r:t.custom,a,o)}return s}function uN(t,s,r){const n=t.getProps();return F_e(n,s,r!==void 0?r:n.custom,t)}const Kqe=new Set(["width","height","top","left","right","bottom",...vM]),F3e=30,gNt=t=>!isNaN(parseFloat(t));class xNt{constructor(s,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const a=Eh.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=Eh.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=gNt(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 S_e);const n=this.events[s].add(r);return s==="change"?()=>{n(),pl.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=Eh.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>F3e)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,F3e);return hqe(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 v3(t,s){return new xNt(t,s)}const nxe=t=>Array.isArray(t);function yNt(t,s,r){t.hasValue(s)?t.getValue(s).set(r):t.addValue(s,v3(r))}function vNt(t){return nxe(t)?t[t.length-1]||0:t}function _Nt(t,s){const r=uN(t,s);let{transitionEnd:n={},transition:a={},...o}=r||{};o={...o,...n};for(const l in o){const i=vNt(o[l]);yNt(t,l,i)}}const Lu=t=>!!(t&&t.getVelocity);function bNt(t){return!!(Lu(t)&&t.add)}function axe(t,s){const r=t.getValue("willChange");if(bNt(r))return r.add(s);if(!r&&T_.WillChange){const n=new T_.WillChange("auto");t.addValue("willChange",n),n.add(s)}}function z_e(t){return t.replace(/([A-Z])/g,s=>`-${s.toLowerCase()}`)}const wNt="framerAppearId",Zqe="data-"+z_e(wNt);function Yqe(t){return t.props[Zqe]}function jNt({protectedKeys:t,needsAnimating:s},r){const n=t.hasOwnProperty(r)&&s[r]!==!0;return s[r]=!1,n}function Xqe(t,s,{delay:r=0,transitionOverride:n,type:a}={}){let{transition:o,transitionEnd:l,...i}=s;const d=t.getDefaultTransition();o=o?Gqe(o,d):d;const u=o==null?void 0:o.reduceMotion;n&&(o=n);const p=[],g=a&&t.animationState&&t.animationState.getState()[a];for(const v in i){const _=t.getValue(v,t.latestValues[v]??null),b=i[v];if(b===void 0||g&&jNt(g,v))continue;const j={delay:r,...O_e(o||{},v)},w=_.get();if(w!==void 0&&!_.isAnimating()&&!Array.isArray(b)&&b===w&&!j.velocity){pl.update(()=>_.set(b));continue}let N=!1;if(window.MotionHandoffAnimation){const I=Yqe(t);if(I){const L=window.MotionHandoffAnimation(I,v,pl);L!==null&&(j.startTime=L,N=!0)}}axe(t,v);const C=u??t.shouldReduceMotion;_.start(R_e(v,_,b,C&&Kqe.has(v)?{type:!1}:j,t,N));const A=_.animation;A&&p.push(A)}if(l){const v=()=>pl.update(()=>{l&&_Nt(t,l)});p.length?Promise.all(p).then(v):v()}return p}function ixe(t,s,r={}){var d;const n=uN(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(Xqe(t,n,r)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:p=0,staggerChildren:g,staggerDirection:v}=a;return kNt(t,s,u,p,g,v,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 kNt(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(ixe(d,s,{...l,delay:r+(typeof n=="function"?0:n)+Hqe(t.variantChildren,d,n,a,o)}).then(()=>d.notify("AnimationComplete",s)));return Promise.all(i)}function NNt(t,s,r={}){t.notify("AnimationStart",s);let n;if(Array.isArray(s)){const a=s.map(o=>ixe(t,o,r));n=Promise.all(a)}else if(typeof s=="string")n=ixe(t,s,r);else{const a=typeof s=="function"?uN(t,s,r.custom):s;n=Promise.all(Xqe(t,a,r))}return n.then(()=>{t.notify("AnimationComplete",s)})}const SNt={test:t=>t==="auto",parse:t=>t},Qqe=t=>s=>s.test(t),Jqe=[yM,Qn,Qx,Jv,Qjt,Xjt,SNt],z3e=t=>Jqe.find(Qqe(t));function CNt(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||dqe(t):!0}const MNt=new Set(["brightness","contrast","saturate","opacity"]);function TNt(t){const[s,r]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[n]=r.match(A_e)||[];if(!n)return t;const a=r.replace(n,"");let o=MNt.has(s)?1:0;return n!==r&&(o*=100),s+"("+o+a+")"}const ANt=/\b([a-z-]*)\(.*?\)/gu,oxe={...zg,getAnimatableNone:t=>{const s=t.match(ANt);return s?s.map(TNt).join(" "):t}},lxe={...zg,getAnimatableNone:t=>{const s=zg.parse(t);return zg.createTransformer(t)(s.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},B3e={...yM,transform:Math.round},ENt={rotate:Jv,rotateX:Jv,rotateY:Jv,rotateZ:Jv,scale:O8,scaleX:O8,scaleY:O8,scaleZ:O8,skew:Jv,skewX:Jv,skewY:Jv,distance:Qn,translateX:Qn,translateY:Qn,translateZ:Qn,x:Qn,y:Qn,z:Qn,perspective:Qn,transformPerspective:Qn,opacity:XI,originX:S3e,originY:S3e,originZ:Qn},B_e={borderWidth:Qn,borderTopWidth:Qn,borderRightWidth:Qn,borderBottomWidth:Qn,borderLeftWidth:Qn,borderRadius:Qn,borderTopLeftRadius:Qn,borderTopRightRadius:Qn,borderBottomRightRadius:Qn,borderBottomLeftRadius:Qn,width:Qn,maxWidth:Qn,height:Qn,maxHeight:Qn,top:Qn,right:Qn,bottom:Qn,left:Qn,inset:Qn,insetBlock:Qn,insetBlockStart:Qn,insetBlockEnd:Qn,insetInline:Qn,insetInlineStart:Qn,insetInlineEnd:Qn,padding:Qn,paddingTop:Qn,paddingRight:Qn,paddingBottom:Qn,paddingLeft:Qn,paddingBlock:Qn,paddingBlockStart:Qn,paddingBlockEnd:Qn,paddingInline:Qn,paddingInlineStart:Qn,paddingInlineEnd:Qn,margin:Qn,marginTop:Qn,marginRight:Qn,marginBottom:Qn,marginLeft:Qn,marginBlock:Qn,marginBlockStart:Qn,marginBlockEnd:Qn,marginInline:Qn,marginInlineStart:Qn,marginInlineEnd:Qn,fontSize:Qn,backgroundPositionX:Qn,backgroundPositionY:Qn,...ENt,zIndex:B3e,fillOpacity:XI,strokeOpacity:XI,numOctaves:B3e},PNt={...B_e,color:wd,backgroundColor:wd,outlineColor:wd,fill:wd,stroke:wd,borderColor:wd,borderTopColor:wd,borderRightColor:wd,borderBottomColor:wd,borderLeftColor:wd,filter:oxe,WebkitFilter:oxe,mask:lxe,WebkitMask:lxe},eUe=t=>PNt[t],INt=new Set([oxe,lxe]);function tUe(t,s){let r=eUe(t);return INt.has(r)||(r=zg),r.getAnimatableNone?r.getAnimatableNone(s):void 0}const LNt=new Set(["auto","none","0"]);function DNt(t,s,r){let n=0,a;for(;n{s.getValue(d).set(u)}),this.resolveNoneKeyframes()}}function sUe(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 rUe=(t,s)=>s&&typeof t=="number"?s.transform(t):t;function are(t){return cqe(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:$_e}=jqe(queueMicrotask,!1),fg={x:!1,y:!1};function nUe(){return fg.x||fg.y}function RNt(t){return t==="x"||t==="y"?fg[t]?null:(fg[t]=!0,()=>{fg[t]=!1}):fg.x||fg.y?null:(fg.x=fg.y=!0,()=>{fg.x=fg.y=!1})}function aUe(t,s){const r=sUe(t),n=new AbortController,a={passive:!0,...s,signal:n.signal};return[r,a,()=>n.abort()]}function FNt(t){return!(t.pointerType==="touch"||nUe())}function zNt(t,s,r={}){const[n,a,o]=aUe(t,r);return n.forEach(l=>{let i=!1,d=!1,u;const p=()=>{l.removeEventListener("pointerleave",b)},g=w=>{u&&(u(w),u=void 0),p()},v=w=>{i=!1,window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v),d&&(d=!1,g(w))},_=()=>{i=!0,window.addEventListener("pointerup",v,a),window.addEventListener("pointercancel",v,a)},b=w=>{if(w.pointerType!=="touch"){if(i){d=!0;return}g(w)}},j=w=>{if(!FNt(w))return;d=!1;const N=s(l,w);typeof N=="function"&&(u=N,l.addEventListener("pointerleave",b,a))};l.addEventListener("pointerenter",j,a),l.addEventListener("pointerdown",_,a)}),o}const iUe=(t,s)=>s?t===s?!0:iUe(t,s.parentElement):!1,q_e=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,BNt=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function $Nt(t){return BNt.has(t.tagName)||t.isContentEditable===!0}const qNt=new Set(["INPUT","SELECT","TEXTAREA"]);function UNt(t){return qNt.has(t.tagName)||t.isContentEditable===!0}const ire=new WeakSet;function $3e(t){return s=>{s.key==="Enter"&&t(s)}}function Khe(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const VNt=(t,s)=>{const r=t.currentTarget;if(!r)return;const n=$3e(()=>{if(ire.has(r))return;Khe(r,"down");const a=$3e(()=>{Khe(r,"up")}),o=()=>Khe(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 q3e(t){return q_e(t)&&!nUe()}const U3e=new WeakSet;function HNt(t,s,r={}){const[n,a,o]=aUe(t,r),l=i=>{const d=i.currentTarget;if(!q3e(i)||U3e.has(i))return;ire.add(d),r.stopPropagation&&U3e.add(i);const u=s(d,i),p=(_,b)=>{window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",v),ire.has(d)&&ire.delete(d),q3e(_)&&typeof u=="function"&&u(_,{success:b})},g=_=>{p(_,d===window||d===document||r.useGlobalTarget||iUe(d,_.target))},v=_=>{p(_,!1)};window.addEventListener("pointerup",g,a),window.addEventListener("pointercancel",v,a)};return n.forEach(i=>{(r.useGlobalTarget?window:i).addEventListener("pointerdown",l,a),are(i)&&(i.addEventListener("focus",u=>VNt(u,a)),!$Nt(i)&&!i.hasAttribute("tabindex")&&(i.tabIndex=0))}),o}function U_e(t){return cqe(t)&&"ownerSVGElement"in t}const ore=new WeakMap;let e1;const oUe=(t,s,r)=>(n,a)=>a&&a[0]?a[0][t+"Size"]:U_e(n)&&"getBBox"in n?n.getBBox()[s]:n[r],WNt=oUe("inline","width","offsetWidth"),GNt=oUe("block","height","offsetHeight");function KNt({target:t,borderBoxSize:s}){var r;(r=ore.get(t))==null||r.forEach(n=>{n(t,{get width(){return WNt(t,s)},get height(){return GNt(t,s)}})})}function ZNt(t){t.forEach(KNt)}function YNt(){typeof ResizeObserver>"u"||(e1=new ResizeObserver(ZNt))}function XNt(t,s){e1||YNt();const r=sUe(t);return r.forEach(n=>{let a=ore.get(n);a||(a=new Set,ore.set(n,a)),a.add(s),e1==null||e1.observe(n)}),()=>{r.forEach(n=>{const a=ore.get(n);a==null||a.delete(s),a!=null&&a.size||e1==null||e1.unobserve(n)})}}const lre=new Set;let F4;function QNt(){F4=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};lre.forEach(s=>s(t))},window.addEventListener("resize",F4)}function JNt(t){return lre.add(t),F4||QNt(),()=>{lre.delete(t),!lre.size&&typeof F4=="function"&&(window.removeEventListener("resize",F4),F4=void 0)}}function V3e(t,s){return typeof t=="function"?JNt(t):XNt(t,s)}function eSt(t){return U_e(t)&&t.tagName==="svg"}const tSt=[...Jqe,wd,zg],sSt=t=>tSt.find(Qqe(t)),H3e=()=>({translate:0,scale:1,origin:0,originPoint:0}),z4=()=>({x:H3e(),y:H3e()}),W3e=()=>({min:0,max:0}),Dd=()=>({x:W3e(),y:W3e()}),rSt=new WeakMap;function Woe(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function QI(t){return typeof t=="string"||Array.isArray(t)}const V_e=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],H_e=["initial",...V_e];function Goe(t){return Woe(t.animate)||H_e.some(s=>QI(t[s]))}function lUe(t){return!!(Goe(t)||t.variants)}function nSt(t,s,r){for(const n in s){const a=s[n],o=r[n];if(Lu(a))t.addValue(n,a);else if(Lu(o))t.addValue(n,v3(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,v3(l!==void 0?l:a,{owner:t}))}}for(const n in r)s[n]===void 0&&t.removeValue(n);return s}const cxe={current:null},cUe={current:!1},aSt=typeof window<"u";function iSt(){if(cUe.current=!0,!!aSt)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>cxe.current=t.matches;t.addEventListener("change",s),s()}else cxe.current=!1}const G3e=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Ane={};function dUe(t){Ane=t}function oSt(){return Ane}class lSt{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=D_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 _=Eh.now();this.renderScheduledAt<_&&(this.renderScheduledAt=_,pl.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=Goe(r),this.isVariantNode=lUe(r),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(s&&s.current);const{willChange:g,...v}=this.scrapeMotionValuesFromProps(r,{},this);for(const _ in v){const b=v[_];u[_]!==void 0&&Lu(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,rSt.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:(cUe.current||iSt(),this.shouldReduceMotion=cxe.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(),A_(this.notifyUpdate),A_(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&&Vqe.has(s)&&this.current instanceof HTMLElement){const{factory:l,keyframes:i,times:d,ease:u,duration:p}=r.accelerate,g=new qqe({element:this.current,name:s,keyframes:i,times:d,ease:u,duration:xp(p)}),v=l(g);this.valueSubscriptions.set(s,()=>{v(),g.cancel()});return}const n=_M.has(s);n&&this.onBindTransform&&this.onBindTransform();const a=r.on("change",l=>{this.latestValues[s]=l,this.props.onUpdate&&pl.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 Ane){const r=Ane[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):Dd()}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=v3(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"&&(lqe(n)||dqe(n))?n=parseFloat(n):!sSt(n)&&zg.test(r)&&(n=tUe(s,r)),this.setBaseTarget(s,Lu(n)?n.get():n)),Lu(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=F_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&&!Lu(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 S_e),this.events[s].add(r)}notify(s,...r){this.events[s]&&this.events[s].notify(...r)}scheduleRenderMicrotask(){$_e.render(this.render)}}class uUe extends lSt{constructor(){super(...arguments),this.KeyframeResolver=ONt}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;Lu(s)&&(this.childSubscription=s.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class V_{constructor(s){this.isMounted=!1,this.node=s}update(){}}function hUe({top:t,left:s,right:r,bottom:n}){return{x:{min:s,max:r},y:{min:t,max:n}}}function cSt({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function dSt(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 Zhe(t){return t===void 0||t===1}function dxe({scale:t,scaleX:s,scaleY:r}){return!Zhe(t)||!Zhe(s)||!Zhe(r)}function hk(t){return dxe(t)||mUe(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function mUe(t){return K3e(t.x)||K3e(t.y)}function K3e(t){return t&&t!=="0%"}function Ene(t,s,r){const n=t-r,a=s*n;return r+a}function Z3e(t,s,r,n,a){return a!==void 0&&(t=Ene(t,a,n)),Ene(t,r,n)+s}function uxe(t,s=0,r=1,n,a){t.min=Z3e(t.min,s,r,n,a),t.max=Z3e(t.max,s,r,n,a)}function pUe(t,{x:s,y:r}){uxe(t.x,s.translate,s.scale,s.originPoint),uxe(t.y,r.translate,r.scale,r.originPoint)}const Y3e=.999999999999,X3e=1.0000000000001;function uSt(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;dY3e&&(s.x=1),s.yY3e&&(s.y=1)}function Ex(t,s){t.min+=s,t.max+=s}function Q3e(t,s,r,n,a=.5){const o=Ql(t.min,t.max,a);uxe(t,s,r,o,n)}function J3e(t,s){return typeof t=="string"?parseFloat(t)/100*(s.max-s.min):t}function cre(t,s,r){const n=r??t;Q3e(t.x,J3e(s.x,n.x),s.scaleX,s.scale,s.originX),Q3e(t.y,J3e(s.y,n.y),s.scaleY,s.scale,s.originY)}function fUe(t,s){return hUe(dSt(t.getBoundingClientRect(),s))}function hSt(t,s,r){const n=fUe(t,r),{scroll:a}=s;return a&&(Ex(n.x,a.offset.x),Ex(n.y,a.offset.y)),n}const mSt={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},pSt=vM.length;function fSt(t,s,r){let n="",a=!0;for(let o=0;o{if(!s.target)return t;if(typeof t=="string")if(Qn.test(t))t=parseFloat(t);else return t;const r=eMe(t,s.target.x),n=eMe(t,s.target.y);return`${r}% ${n}%`}},gSt={correct:(t,{treeScale:s,projectionDelta:r})=>{const n=t,a=zg.parse(t);if(a.length>5)return n;const o=zg.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=Ql(i,d,.5);return typeof a[2+l]=="number"&&(a[2+l]/=u),typeof a[3+l]=="number"&&(a[3+l]/=u),o(a)}},hxe={borderRadius:{...eE,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:eE,borderTopRightRadius:eE,borderBottomLeftRadius:eE,borderBottomRightRadius:eE,boxShadow:gSt};function xUe(t,{layout:s,layoutId:r}){return _M.has(t)||t.startsWith("origin")||(s||r!==void 0)&&(!!hxe[t]||t==="opacity")}function G_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)(Lu(n[i])||a&&Lu(a[i])||xUe(i,t)||((l=r==null?void 0:r.getValue(i))==null?void 0:l.liveStyle)!==void 0)&&(o[i]=n[i]);return o}function xSt(t){return window.getComputedStyle(t)}class ySt extends uUe{constructor(){super(...arguments),this.type="html",this.renderInstance=gUe}readValueFromInstance(s,r){var n;if(_M.has(r))return(n=this.projection)!=null&&n.isProjecting?Qge(r):Fkt(s,r);{const a=xSt(s),o=(Nqe(r)?a.getPropertyValue(r):a[r])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(s,{transformPagePoint:r}){return fUe(s,r)}build(s,r,n){W_e(s,r,n.transformTemplate)}scrapeMotionValuesFromProps(s,r,n){return G_e(s,r,n)}}const vSt={offset:"stroke-dashoffset",array:"stroke-dasharray"},_St={offset:"strokeDashoffset",array:"strokeDasharray"};function bSt(t,s,r=1,n=0,a=!0){t.pathLength=1;const o=a?vSt:_St;t[o.offset]=`${-n}`,t[o.array]=`${s} ${r}`}const wSt=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function yUe(t,{attrX:s,attrY:r,attrScale:n,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...i},d,u,p){if(W_e(t,i,u),d){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:g,style:v}=t;g.transform&&(v.transform=g.transform,delete g.transform),(v.transform||g.transformOrigin)&&(v.transformOrigin=g.transformOrigin??"50% 50%",delete g.transformOrigin),v.transform&&(v.transformBox=(p==null?void 0:p.transformBox)??"fill-box",delete g.transformBox);for(const _ of wSt)g[_]!==void 0&&(v[_]=g[_],delete g[_]);s!==void 0&&(g.x=s),r!==void 0&&(g.y=r),n!==void 0&&(g.scale=n),a!==void 0&&bSt(g,a,o,l,!1)}const vUe=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"]),_Ue=t=>typeof t=="string"&&t.toLowerCase()==="svg";function jSt(t,s,r,n){gUe(t,s,void 0,n);for(const a in s.attrs)t.setAttribute(vUe.has(a)?a:z_e(a),s.attrs[a])}function bUe(t,s,r){const n=G_e(t,s,r);for(const a in t)if(Lu(t[a])||Lu(s[a])){const o=vM.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;n[o]=t[a]}return n}class kSt extends uUe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Dd}getBaseTargetFromProps(s,r){return s[r]}readValueFromInstance(s,r){if(_M.has(r)){const n=eUe(r);return n&&n.default||0}return r=vUe.has(r)?r:z_e(r),s.getAttribute(r)}scrapeMotionValuesFromProps(s,r,n){return bUe(s,r,n)}build(s,r,n){yUe(s,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(s,r,n,a){jSt(s,r,n,a)}mount(s){this.isSVGTag=_Ue(s.tagName),super.mount(s)}}const NSt=H_e.length;function wUe(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?wUe(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})=>NNt(t,r,n)))}function TSt(t){let s=MSt(t),r=tMe(),n=!0,a=!1;const o=u=>(p,g)=>{var _;const v=uN(t,g,u==="exit"?(_=t.presenceContext)==null?void 0:_.custom:void 0);if(v){const{transition:b,transitionEnd:j,...w}=v;p={...p,...w,...j}}return p};function l(u){s=u(t)}function i(u){const{props:p}=t,g=wUe(t.parent)||{},v=[],_=new Set;let b={},j=1/0;for(let N=0;Nj&&L,V=!1;const X=Array.isArray(I)?I:[I];let se=X.reduce(o(C),{});R===!1&&(se={});const{prevResolvedValues:te={}}=A,Y={...te,...se},de=le=>{U=!0,_.has(le)&&(V=!0,_.delete(le)),A.needsAnimating[le]=!0;const pe=t.getValue(le);pe&&(pe.liveStyle=!1)};for(const le in Y){const pe=se[le],be=te[le];if(b.hasOwnProperty(le))continue;let ye=!1;nxe(pe)&&nxe(be)?ye=!jUe(pe,be):ye=pe!==be,ye?pe!=null?de(le):_.add(le):pe!==void 0&&_.has(le)?de(le):A.protectedKeys[le]=!0}A.prevProp=I,A.prevResolvedValues=se,A.isActive&&(b={...b,...se}),(n||a)&&t.blockInitialAnimation&&(U=!1);const ie=$&&q;U&&(!ie||V)&&v.push(...X.map(le=>{const pe={type:C};if(typeof le=="string"&&(n||a)&&!ie&&t.manuallyAnimateOnMount&&t.parent){const{parent:be}=t,ye=uN(be,le);if(be.enteringChildren&&ye){const{delayChildren:we}=ye.transition||{};pe.delay=Hqe(be.enteringChildren,t,we)}}return{animation:le,options:pe}}))}if(_.size){const N={};if(typeof p.initial!="boolean"){const C=uN(t,Array.isArray(p.initial)?p.initial[0]:p.initial);C&&C.transition&&(N.transition=C.transition)}_.forEach(C=>{const A=t.getBaseTarget(C),I=t.getValue(C);I&&(I.liveStyle=!0),N[C]=A??null}),v.push({animation:N})}let w=!!v.length;return n&&(p.initial===!1||p.initial===p.animate)&&!t.manuallyAnimateOnMount&&(w=!1),n=!1,a=!1,w?s(v):Promise.resolve()}function d(u,p){var v;if(r[u].isActive===p)return Promise.resolve();(v=t.variantChildren)==null||v.forEach(_=>{var b;return(b=_.animationState)==null?void 0:b.setActive(u,p)}),r[u].isActive=p;const g=i(u);for(const _ in r)r[_].protectedKeys={};return g}return{animateChanges:i,setActive:d,setAnimateFunction:l,getState:()=>r,reset:()=>{r=tMe(),a=!0}}}function ASt(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!jUe(s,t):!1}function Gb(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function tMe(){return{animate:Gb(!0),whileInView:Gb(),whileHover:Gb(),whileTap:Gb(),whileDrag:Gb(),whileFocus:Gb(),exit:Gb()}}function mxe(t,s){t.min=s.min,t.max=s.max}function cg(t,s){mxe(t.x,s.x),mxe(t.y,s.y)}function sMe(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}const kUe=1e-4,ESt=1-kUe,PSt=1+kUe,NUe=.01,ISt=0-NUe,LSt=0+NUe;function Ph(t){return t.max-t.min}function DSt(t,s,r){return Math.abs(t-s)<=r}function rMe(t,s,r,n=.5){t.origin=n,t.originPoint=Ql(s.min,s.max,t.origin),t.scale=Ph(r)/Ph(s),t.translate=Ql(r.min,r.max,t.origin)-t.originPoint,(t.scale>=ESt&&t.scale<=PSt||isNaN(t.scale))&&(t.scale=1),(t.translate>=ISt&&t.translate<=LSt||isNaN(t.translate))&&(t.translate=0)}function ZP(t,s,r,n){rMe(t.x,s.x,r.x,n?n.originX:void 0),rMe(t.y,s.y,r.y,n?n.originY:void 0)}function nMe(t,s,r,n=0){const a=n?Ql(r.min,r.max,n):r.min;t.min=a+s.min,t.max=t.min+Ph(s)}function OSt(t,s,r,n){nMe(t.x,s.x,r.x,n==null?void 0:n.x),nMe(t.y,s.y,r.y,n==null?void 0:n.y)}function aMe(t,s,r,n=0){const a=n?Ql(r.min,r.max,n):r.min;t.min=s.min-a,t.max=t.min+Ph(s)}function Pne(t,s,r,n){aMe(t.x,s.x,r.x,n==null?void 0:n.x),aMe(t.y,s.y,r.y,n==null?void 0:n.y)}function iMe(t,s,r,n,a){return t-=s,t=Ene(t,1/r,n),a!==void 0&&(t=Ene(t,1/a,n)),t}function RSt(t,s=0,r=1,n=.5,a,o=t,l=t){if(Qx.test(s)&&(s=parseFloat(s),s=Ql(l.min,l.max,s/100)-l.min),typeof s!="number")return;let i=Ql(o.min,o.max,n);t===o&&(i-=s),t.min=iMe(t.min,s,r,i,a),t.max=iMe(t.max,s,r,i,a)}function oMe(t,s,[r,n,a],o,l){RSt(t,s[r],s[n],s[a],s.scale,o,l)}const FSt=["x","scaleX","originX"],zSt=["y","scaleY","originY"];function lMe(t,s,r,n){oMe(t.x,s,FSt,r?r.x:void 0,n?n.x:void 0),oMe(t.y,s,zSt,r?r.y:void 0,n?n.y:void 0)}function cMe(t){return t.translate===0&&t.scale===1}function SUe(t){return cMe(t.x)&&cMe(t.y)}function dMe(t,s){return t.min===s.min&&t.max===s.max}function BSt(t,s){return dMe(t.x,s.x)&&dMe(t.y,s.y)}function uMe(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function CUe(t,s){return uMe(t.x,s.x)&&uMe(t.y,s.y)}function hMe(t){return Ph(t.x)/Ph(t.y)}function mMe(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}function wx(t){return[t("x"),t("y")]}function $St(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:g,rotateY:v,skewX:_,skewY:b}=r;u&&(n=`perspective(${u}px) ${n}`),p&&(n+=`rotate(${p}deg) `),g&&(n+=`rotateX(${g}deg) `),v&&(n+=`rotateY(${v}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 MUe=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],qSt=MUe.length,pMe=t=>typeof t=="string"?parseFloat(t):t,fMe=t=>typeof t=="number"||Qn.test(t);function USt(t,s,r,n,a,o){a?(t.opacity=Ql(0,r.opacity??1,VSt(n)),t.opacityExit=Ql(s.opacity??1,0,HSt(n))):o&&(t.opacity=Ql(s.opacity??1,r.opacity??1,n));for(let l=0;lns?1:r(YI(t,s,n))}function WSt(t,s,r){const n=Lu(t)?t:v3(t);return n.start(R_e("",n,s,r)),n.animation}function JI(t,s,r,n={passive:!0}){return t.addEventListener(s,r,n),()=>t.removeEventListener(s,r)}const GSt=(t,s)=>t.depth-s.depth;class KSt{constructor(){this.children=[],this.isDirty=!1}add(s){k_e(this.children,s),this.isDirty=!0}remove(s){Nne(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(GSt),this.isDirty=!1,this.children.forEach(s)}}function ZSt(t,s){const r=Eh.now(),n=({timestamp:a})=>{const o=a-r;o>=s&&(A_(n),t(o-s))};return pl.setup(n,!0),()=>A_(n)}function dre(t){return Lu(t)?t.get():t}class YSt{constructor(){this.members=[]}add(s){k_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&&(Nne(this.members,n),n.unmount())}s.scheduleRender()}remove(s){if(Nne(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 ure={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Yhe=["","X","Y","Z"],XSt=1e3;let QSt=0;function Xhe(t,s,r,n){const{latestValues:a}=s;a[t]&&(r[t]=a[t],s.setStaticValue(t,0),n&&(n[t]=0))}function AUe(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const r=Yqe(s);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:a,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",pl,!(a||o))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&AUe(n)}function EUe({attachResizeListener:t,defaultParent:s,measureScroll:r,checkIsScrollRoot:n,resetTransform:a}){return class{constructor(l={},i=s==null?void 0:s()){this.id=QSt++,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(tCt),this.nodes.forEach(oCt),this.nodes.forEach(lCt),this.nodes.forEach(sCt)},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;pl.read(()=>{g=window.innerWidth}),t(l,()=>{const _=window.innerWidth;_!==g&&(g=_,this.root.updateBlockedByResize=!0,p&&p(),p=ZSt(v,250),ure.hasAnimatedSinceResize&&(ure.hasAnimatedSinceResize=!1,this.nodes.forEach(vMe)))})}i&&this.root.registerSharedNode(i,this),this.options.animate!==!1&&u&&(i||d)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:g,hasRelativeLayoutChanged:v,layout:_})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const b=this.options.transition||u.getDefaultTransition()||mCt,{onLayoutAnimationStart:j,onLayoutAnimationComplete:w}=u.getProps(),N=!this.targetLayout||!CUe(this.targetLayout,_),C=!g&&v;if(this.options.layoutRoot||this.resumeFrom||C||g&&(N||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const A={...O_e(b,"layout"),onPlay:j,onComplete:w};(u.shouldReduceMotion||this.options.layoutRoot)&&(A.delay=0,A.type=!1),this.startAnimation(A),this.setAnimationOrigin(p,C)}else g||vMe(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(),A_(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(cCt),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&&AUe(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&&!Ph(this.snapshot.measuredBox.x)&&!Ph(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;_Me(g.x,l.x,L),_Me(g.y,l.y,L),this.setTargetDelta(g),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Pne(v,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),uCt(this.relativeTarget,this.relativeTargetOrigin,v,L),A&&BSt(this.relativeTarget,A)&&(this.isProjectionDirty=!1),A||(A=Dd()),cg(A,this.relativeTarget)),j&&(this.animationValues=p,USt(p,u,this.latestValues,L,C,N)),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&&(A_(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=pl.update(()=>{ure.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=v3(0)),this.motionValue.jump(0,!1),this.currentAnimation=WSt(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(XSt),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&&PUe(this.options.animationType,this.layout.layoutBox,u.layoutBox)){d=this.target||Dd();const g=Ph(this.layout.layoutBox.x);d.x.min=l.target.x.min,d.x.max=d.x.min+g;const v=Ph(this.layout.layoutBox.y);d.y.min=l.target.y.min,d.y.max=d.y.min+v}cg(i,d),cre(i,p),ZP(this.projectionDeltaWithTransform,this.layoutCorrected,i,p)}}registerSharedNode(l,i){this.sharedNodes.has(l)||this.sharedNodes.set(l,new YSt),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&&Xhe("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(xMe),this.root.sharedNodes.clear()}}}function JSt(t){t.updateLayout()}function eCt(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")wx(g=>{const v=l?s.measuredBox[g]:s.layoutBox[g],_=Ph(v);v.min=n[g].min,v.max=v.min+_});else if(o==="x"||o==="y"){const g=o==="x"?"y":"x";mxe(l?s.measuredBox[g]:s.layoutBox[g],n[g])}else PUe(o,s.layoutBox,n)&&wx(g=>{const v=l?s.measuredBox[g]:s.layoutBox[g],_=Ph(n[g]);v.max=v.min+_,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[g].max=t.relativeTarget[g].min+_)});const i=z4();ZP(i,n,s.layoutBox);const d=z4();l?ZP(d,t.applyTransform(a,!0),s.measuredBox):ZP(d,n,s.layoutBox);const u=!SUe(i);let p=!1;if(!t.resumeFrom){const g=t.getClosestProjectingParent();if(g&&!g.resumeFrom){const{snapshot:v,layout:_}=g;if(v&&_){const b=t.options.layoutAnchor||void 0,j=Dd();Pne(j,s.layoutBox,v.layoutBox,b);const w=Dd();Pne(w,n,_.layoutBox,b),CUe(j,w)||(p=!0),g.options.layoutRoot&&(t.relativeTarget=w,t.relativeTargetOrigin=j,t.relativeParent=g)}}}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 tCt(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 sCt(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function rCt(t){t.clearSnapshot()}function xMe(t){t.clearMeasurements()}function nCt(t){t.isLayoutDirty=!0,t.updateLayout()}function yMe(t){t.isLayoutDirty=!1}function aCt(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function iCt(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function vMe(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function oCt(t){t.resolveTargetDelta()}function lCt(t){t.calcProjection()}function cCt(t){t.resetSkewAndRotation()}function dCt(t){t.removeLeadSnapshot()}function _Me(t,s,r){t.translate=Ql(s.translate,0,r),t.scale=Ql(s.scale,1,r),t.origin=s.origin,t.originPoint=s.originPoint}function bMe(t,s,r,n){t.min=Ql(s.min,r.min,n),t.max=Ql(s.max,r.max,n)}function uCt(t,s,r,n){bMe(t.x,s.x,r.x,n),bMe(t.y,s.y,r.y,n)}function hCt(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const mCt={duration:.45,ease:[.4,0,.1,1]},wMe=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),jMe=wMe("applewebkit/")&&!wMe("chrome/")?Math.round:gf;function kMe(t){t.min=jMe(t.min),t.max=jMe(t.max)}function pCt(t){kMe(t.x),kMe(t.y)}function PUe(t,s,r){return t==="position"||t==="preserve-aspect"&&!DSt(hMe(s),hMe(r),.2)}function fCt(t){var s;return t!==t.root&&((s=t.scroll)==null?void 0:s.wasRoot)}const gCt=EUe({attachResizeListener:(t,s)=>JI(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}),Qhe={current:void 0},IUe=EUe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Qhe.current){const t=new gCt({});t.mount(window),t.setOptions({layoutScroll:!0}),Qhe.current=t}return Qhe.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),K_e=S.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function NMe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function xCt(...t){return s=>{let r=!1;const n=t.map(a=>{const o=NMe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{width:_,height:b,top:j,left:w,right:N,bottom:C}=d.current;if(s||o===!1||!i.current||!_||!b)return;const A=r==="left"?`left: ${w}`:`right: ${N}`,I=n==="bottom"?`bottom: ${C}`:`top: ${j}`;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; ${A}px !important; ${I}px !important; } `),()=>{var $;($=i.current)==null||$.removeAttribute("data-motion-pop-id"),R.contains(L)&&R.removeChild(L)}},[s]),e.jsx(vCt,{isPresent:s,childRef:i,sizeRef:d,pop:o,children:o===!1?t:S.cloneElement(t,{ref:g})})}const bCt=({children:t,initial:s,isPresent:r,onExitComplete:n,custom:a,presenceAffectsLayout:o,mode:l,anchorX:i,anchorY:d,root:u})=>{const p=j_e(wCt),g=S.useId();let v=!0,_=S.useMemo(()=>(v=!1,{id:g,initial:s,isPresent:r,custom:a,onExitComplete:b=>{p.set(b,!0);for(const j of p.values())if(!j)return;n&&n()},register:b=>(p.set(b,!1),()=>p.delete(b))}),[r,p,n]);return o&&v&&(_={..._}),S.useMemo(()=>{p.forEach((b,j)=>p.set(j,!1))},[r]),S.useEffect(()=>{!r&&!p.size&&n&&n()},[r]),t=e.jsx(_Ct,{pop:l==="popLayout",isPresent:r,anchorX:i,anchorY:d,root:u,children:t}),e.jsx(Voe.Provider,{value:_,children:t})};function wCt(){return new Map}function LUe(t=!0){const s=S.useContext(Voe);if(s===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:a}=s,o=S.useId();S.useEffect(()=>{if(t)return a(o)},[t]);const l=S.useCallback(()=>t&&n&&n(o),[o,n,t]);return!r&&n?[!1,l]:[!0]}const R8=t=>t.key||"";function SMe(t){const s=[];return S.Children.forEach(t,r=>{S.isValidElement(r)&&s.push(r)}),s}const jCt=({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,g]=LUe(l),v=S.useMemo(()=>SMe(t),[t]),_=l&&!p?[]:v.map(R8),b=S.useRef(!0),j=S.useRef(v),w=j_e(()=>new Map),N=S.useRef(new Set),[C,A]=S.useState(v),[I,L]=S.useState(v);oqe(()=>{b.current=!1,j.current=v;for(let q=0;q{const U=R8(q),V=l&&!p?!1:v===I||_.includes(U),X=()=>{if(N.current.has(U))return;if(w.has(U))N.current.add(U),w.set(U,!0);else return;let se=!0;w.forEach(te=>{te||(se=!1)}),se&&($==null||$(),L(j.current),l&&(g==null||g()),n&&n())};return e.jsx(bCt,{isPresent:V,initial:!b.current||r?void 0:!1,custom:s,presenceAffectsLayout:a,mode:o,root:u,onExitComplete:V?void 0:X,anchorX:i,anchorY:d,children:q},U)})})},DUe=S.createContext({strict:!1}),CMe={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 MMe=!1;function kCt(){if(MMe)return;const t={};for(const s in CMe)t[s]={isEnabled:r=>CMe[s].some(n=>!!r[n])};dUe(t),MMe=!0}function OUe(){return kCt(),oSt()}function NCt(t){const s=OUe();for(const r in t)s[r]={...s[r],...t[r]};dUe(s)}const SCt=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 Ine(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||SCt.has(t)}let RUe=t=>!Ine(t);function CCt(t){typeof t=="function"&&(RUe=s=>s.startsWith("on")?!Ine(s):t(s))}try{CCt(require("@emotion/is-prop-valid").default)}catch{}function MCt(t,s,r){const n={};for(const a in t)a==="values"&&typeof t.values=="object"||Lu(t[a])||(RUe(a)||r===!0&&Ine(a)||!s&&!Ine(a)||t.draggable&&a.startsWith("onDrag"))&&(n[a]=t[a]);return n}const Koe=S.createContext({});function TCt(t,s){if(Goe(t)){const{initial:r,animate:n}=t;return{initial:r===!1||QI(r)?r:void 0,animate:QI(n)?n:void 0}}return t.inherit!==!1?s:{}}function ACt(t){const{initial:s,animate:r}=TCt(t,S.useContext(Koe));return S.useMemo(()=>({initial:s,animate:r}),[TMe(s),TMe(r)])}function TMe(t){return Array.isArray(t)?t.join(" "):t}const Z_e=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function FUe(t,s,r){for(const n in s)!Lu(s[n])&&!xUe(n,r)&&(t[n]=s[n])}function ECt({transformTemplate:t},s){return S.useMemo(()=>{const r=Z_e();return W_e(r,s,t),Object.assign({},r.vars,r.style)},[s])}function PCt(t,s){const r=t.style||{},n={};return FUe(n,r,t),Object.assign(n,ECt(t,s)),n}function ICt(t,s){const r={},n=PCt(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 zUe=()=>({...Z_e(),attrs:{}});function LCt(t,s,r,n){const a=S.useMemo(()=>{const o=zUe();return yUe(o,s,_Ue(n),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[s]);if(t.style){const o={};FUe(o,t.style,t),a.style={...o,...a.style}}return a}const DCt=["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 Y_e(t){return typeof t!="string"||t.includes("-")?!1:!!(DCt.indexOf(t)>-1||/[A-Z]/u.test(t))}function OCt(t,s,r,{latestValues:n},a,o=!1,l){const d=(l??Y_e(t)?LCt:ICt)(s,n,a,t),u=MCt(s,typeof t=="string",o),p=t!==S.Fragment?{...u,...d,ref:r}:{},{children:g}=s,v=S.useMemo(()=>Lu(g)?g.get():g,[g]);return S.createElement(t,{...p,children:v})}function RCt({scrapeMotionValuesFromProps:t,createRenderState:s},r,n,a){return{latestValues:FCt(r,n,a,t),renderState:s()}}function FCt(t,s,r,n){const a={},o=n(t,{});for(const v in o)a[v]=dre(o[v]);let{initial:l,animate:i}=t;const d=Goe(t),u=lUe(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 g=p?i:l;if(g&&typeof g!="boolean"&&!Woe(g)){const v=Array.isArray(g)?g:[g];for(let _=0;_(s,r)=>{const n=S.useContext(Koe),a=S.useContext(Voe),o=()=>RCt(t,s,n,a);return r?o():j_e(o)},zCt=BUe({scrapeMotionValuesFromProps:G_e,createRenderState:Z_e}),BCt=BUe({scrapeMotionValuesFromProps:bUe,createRenderState:zUe}),$Ct=Symbol.for("motionComponentSymbol");function qCt(t,s,r){const n=S.useRef(r);S.useInsertionEffect(()=>{n.current=r});const a=S.useRef(null);return S.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 $Ue=S.createContext({});function v4(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function UCt(t,s,r,n,a,o){var A,I;const{visualElement:l}=S.useContext(Koe),i=S.useContext(DUe),d=S.useContext(Voe),u=S.useContext(K_e),p=u.reducedMotion,g=u.skipAnimations,v=S.useRef(null),_=S.useRef(!1);n=n||i.renderer,!v.current&&n&&(v.current=n(t,{visualState:s,parent:l,props:r,presenceContext:d,blockInitialAnimation:d?d.initial===!1:!1,reducedMotionConfig:p,skipAnimations:g,isSVG:o}),_.current&&v.current&&(v.current.manuallyAnimateOnMount=!0));const b=v.current,j=S.useContext($Ue);b&&!b.projection&&a&&(b.type==="html"||b.type==="svg")&&VCt(v.current,r,a,j);const w=S.useRef(!1);S.useInsertionEffect(()=>{b&&w.current&&b.update(r,d)});const N=r[Zqe],C=S.useRef(!!N&&typeof window<"u"&&!((A=window.MotionHandoffIsComplete)!=null&&A.call(window,N))&&((I=window.MotionHasOptimisedAnimation)==null?void 0:I.call(window,N)));return oqe(()=>{_.current=!0,b&&(w.current=!0,window.MotionIsMounted=!0,b.updateFeatures(),b.scheduleRenderMicrotask(),C.current&&b.animationState&&b.animationState.animateChanges())}),S.useEffect(()=>{b&&(!C.current&&b.animationState&&b.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{var L;(L=window.MotionHandoffMarkAsComplete)==null||L.call(window,N)}),C.current=!1),b.enteringChildren=void 0)}),b}function VCt(t,s,r,n){const{layoutId:a,layout:o,drag:l,dragConstraints:i,layoutScroll:d,layoutRoot:u,layoutAnchor:p,layoutCrossfade:g}=s;t.projection=new r(t.latestValues,s["data-framer-portal-id"]?void 0:qUe(t.parent)),t.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||i&&v4(i),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:g,layoutScroll:d,layoutRoot:u,layoutAnchor:p})}function qUe(t){if(t)return t.options.allowProjection!==!1?t.projection:qUe(t.parent)}function Jhe(t,{forwardMotionProps:s=!1,type:r}={},n,a){n&&NCt(n);const o=r?r==="svg":Y_e(t),l=o?BCt:zCt;function i(u,p){let g;const v={...S.useContext(K_e),...u,layoutId:HCt(u)},{isStatic:_}=v,b=ACt(u),j=l(u,_);if(!_&&typeof window<"u"){WCt();const w=GCt(v);g=w.MeasureLayout,b.visualElement=UCt(t,j,v,a,w.ProjectionNode,o)}return e.jsxs(Koe.Provider,{value:b,children:[g&&b.visualElement?e.jsx(g,{visualElement:b.visualElement,...v}):null,OCt(t,u,qCt(j,b.visualElement,p),j,_,s,o)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const d=S.forwardRef(i);return d[$Ct]=t,d}function HCt({layoutId:t}){const s=S.useContext(w_e).id;return s&&t!==void 0?s+"-"+t:t}function WCt(t,s){S.useContext(DUe).strict}function GCt(t){const s=OUe(),{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 KCt(t,s){if(typeof Proxy>"u")return Jhe;const r=new Map,n=(o,l)=>Jhe(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,Jhe(l,void 0,t,s)),r.get(l))})}const ZCt=(t,s)=>s.isSVG??Y_e(t)?new kSt(s):new ySt(s,{allowProjection:t!==S.Fragment});class YCt extends V_{constructor(s){super(s),s.animationState||(s.animationState=TSt(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();Woe(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 XCt=0;class QCt extends V_{constructor(){super(...arguments),this.id=XCt++,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=uN(this.node,l,i);if(d){const{transition:u,transitionEnd:p,...g}=d;for(const v in g)(o=this.node.getValue(v))==null||o.jump(g[v])}}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 JCt={animation:{Feature:YCt},exit:{Feature:QCt}};function AL(t){return{point:{x:t.pageX,y:t.pageY}}}const e4t=t=>s=>q_e(s)&&t(s,AL(s));function YP(t,s,r,n){return JI(t,s,e4t(r),n)}const UUe=({current:t})=>t?t.ownerDocument.defaultView:null,AMe=(t,s)=>Math.abs(t-s);function t4t(t,s){const r=AMe(t.x,s.x),n=AMe(t.y,s.y);return Math.sqrt(r**2+n**2)}const EMe=new Set(["auto","scroll"]);class VUe{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=F8(this.lastRawMoveEventInfo,this.transformPagePoint));const _=eme(this.lastMoveEventInfo,this.history),b=this.startEvent!==null,j=t4t(_.offset,{x:0,y:0})>=this.distanceThreshold;if(!b&&!j)return;const{point:w}=_,{timestamp:N}=Eu;this.history.push({...w,timestamp:N});const{onStart:C,onMove:A}=this.handlers;b||(C&&C(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent),A&&A(this.lastMoveEvent,_)},this.handlePointerMove=(_,b)=>{this.lastMoveEvent=_,this.lastRawMoveEventInfo=b,this.lastMoveEventInfo=F8(b,this.transformPagePoint),pl.update(this.updatePoint,!0)},this.handlePointerUp=(_,b)=>{this.end();const{onEnd:j,onSessionEnd:w,resumeAnimation:N}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&N&&N(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const C=eme(_.type==="pointercancel"?this.lastMoveEventInfo:F8(b,this.transformPagePoint),this.history);this.startEvent&&j&&j(_,C),w&&w(_,C)},!q_e(s))return;this.dragSnapToOrigin=o,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=l,this.contextWindow=a||window;const d=AL(s),u=F8(d,this.transformPagePoint),{point:p}=u,{timestamp:g}=Eu;this.history=[{...p,timestamp:g}];const{onSessionStart:v}=r;v&&v(s,eme(u,this.history)),this.removeListeners=CL(YP(this.contextWindow,"pointermove",this.handlePointerMove),YP(this.contextWindow,"pointerup",this.handlePointerUp),YP(this.contextWindow,"pointercancel",this.handlePointerUp)),i&&this.startScrollTracking(i)}startScrollTracking(s){let r=s.parentElement;for(;r;){const n=getComputedStyle(r);(EMe.has(n.overflowX)||EMe.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),pl.update(this.updatePoint,!0))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),A_(this.updatePoint)}}function F8(t,s){return s?{point:s(t.point)}:t}function PMe(t,s){return{x:t.x-s.x,y:t.y-s.y}}function eme({point:t},s){return{point:t,delta:PMe(t,HUe(s)),offset:PMe(t,s4t(s)),velocity:r4t(s,.1)}}function s4t(t){return t[0]}function HUe(t){return t[t.length-1]}function r4t(t,s){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const a=HUe(t);for(;r>=0&&(n=t[r],!(a.timestamp-n.timestamp>xp(s)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&a.timestamp-n.timestamp>xp(s)*2&&(n=t[1]);const o=af(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 n4t(t,{min:s,max:r},n){return s!==void 0&&tr&&(t=n?Ql(r,t,n.max):Math.min(t,r)),t}function IMe(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 a4t(t,{top:s,left:r,bottom:n,right:a}){return{x:IMe(t.x,r,a),y:IMe(t.y,s,n)}}function LMe(t,s){let r=s.min-t.min,n=s.max-t.max;return s.max-s.minn?r=YI(s.min,s.max-n,t.min):n>a&&(r=YI(t.min,t.max-a,s.min)),ry(0,1,r)}function l4t(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 pxe=.35;function c4t(t=pxe){return t===!1?t=0:t===!0&&(t=pxe),{x:DMe(t,"left","right"),y:DMe(t,"top","bottom")}}function DMe(t,s,r){return{min:OMe(t,s),max:OMe(t,r)}}function OMe(t,s){return typeof t=="number"?t:t[s]||0}const d4t=new WeakMap;class u4t{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=Dd(),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=g=>{r&&this.snapToCursor(AL(g).point),this.stopAnimation()},l=(g,v)=>{const{drag:_,dragPropagation:b,onDragStart:j}=this.getProps();if(_&&!b&&(this.openDragLock&&this.openDragLock(),this.openDragLock=RNt(_),!this.openDragLock))return;this.latestPointerEvent=g,this.latestPanInfo=v,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),wx(N=>{let C=this.getAxisMotionValue(N).get()||0;if(Qx.test(C)){const{projection:A}=this.visualElement;if(A&&A.layout){const I=A.layout.layoutBox[N];I&&(C=Ph(I)*(parseFloat(C)/100))}}this.originPoint[N]=C}),j&&pl.update(()=>j(g,v),!1,!0),axe(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},i=(g,v)=>{this.latestPointerEvent=g,this.latestPanInfo=v;const{dragPropagation:_,dragDirectionLock:b,onDirectionLock:j,onDrag:w}=this.getProps();if(!_&&!this.openDragLock)return;const{offset:N}=v;if(b&&this.currentDirection===null){this.currentDirection=m4t(N),this.currentDirection!==null&&j&&j(this.currentDirection);return}this.updateAxis("x",v.point,N),this.updateAxis("y",v.point,N),this.visualElement.render(),w&&pl.update(()=>w(g,v),!1,!0)},d=(g,v)=>{this.latestPointerEvent=g,this.latestPanInfo=v,this.stop(g,v),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:g}=this.getProps();(g||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:p}=this.getProps();this.panSession=new VUe(s,{onSessionStart:o,onStart:l,onMove:i,onSessionEnd:d,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:n,contextWindow:UUe(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&&pl.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||!z8(s,a,this.currentDirection))return;const o=this.getAxisMotionValue(s);let l=this.originPoint[s]+n[s];this.constraints&&this.constraints[s]&&(l=n4t(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&&v4(s)?this.constraints||(this.constraints=this.resolveRefConstraints()):s&&n?this.constraints=a4t(n.layoutBox,s):this.constraints=!1,this.elastic=c4t(r),a!==this.constraints&&!v4(s)&&n&&this.constraints&&!this.hasMutatedConstraints&&wx(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=l4t(n.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:r}=this.getProps();if(!s||!v4(s))return!1;const n=s.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=hSt(n,a.root,this.visualElement.getTransformPagePoint());let l=i4t(a.layout.layoutBox,o);if(r){const i=r(cSt(l));this.hasMutatedConstraints=!!i,i&&(l=hUe(i))}return l}startAnimation(s){const{drag:r,dragMomentum:n,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:i}=this.getProps(),d=this.constraints||{},u=wx(p=>{if(!z8(p,r,this.currentDirection))return;let g=d&&d[p]||{};(l===!0||l===p)&&(g={min:0,max:0});const v=a?200:1e6,_=a?40:1e7,b={type:"inertia",velocity:n?s[p]:0,bounceStiffness:v,bounceDamping:_,timeConstant:750,restDelta:1,restSpeed:10,...o,...g};return this.startAxisValueAnimation(p,b)});return Promise.all(u).then(i)}startAxisValueAnimation(s,r){const n=this.getAxisMotionValue(s);return axe(this.visualElement,s),n.start(R_e(s,n,0,r,this.visualElement,!1))}stopAnimation(){wx(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){wx(r=>{const{drag:n}=this.getProps();if(!z8(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]-Ql(l,i,.5)+d)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!v4(r)||!n||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};wx(l=>{const i=this.getAxisMotionValue(l);if(i&&this.constraints!==!1){const d=i.get();a[l]=o4t({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(),wx(l=>{if(!z8(l,s,null))return;const i=this.getAxisMotionValue(l),{min:d,max:u}=this.constraints[l];i.set(Ql(d,u,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;d4t.set(this.visualElement,this);const s=this.visualElement.current,r=YP(s,"pointerdown",u=>{const{drag:p,dragListener:g=!0}=this.getProps(),v=u.target,_=v!==s&&UNt(v);p&&g&&!_&&this.start(u)});let n;const a=()=>{const{dragConstraints:u}=this.getProps();v4(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),n||(n=h4t(s,u.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),pl.read(a);const i=JI(window,"resize",()=>this.scalePositionWithinConstraints()),d=o.addEventListener("didUpdate",({delta:u,hasLayoutChanged:p})=>{this.isDragging&&p&&(wx(g=>{const v=this.getAxisMotionValue(g);v&&(this.originPoint[g]+=u[g].translate,v.set(v.get()+u[g].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=pxe,dragMomentum:i=!0}=s;return{...s,drag:r,dragDirectionLock:n,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:i}}}function RMe(t){let s=!0;return()=>{if(s){s=!1;return}t()}}function h4t(t,s,r){const n=V3e(t,RMe(r)),a=V3e(s,RMe(r));return()=>{n(),a()}}function z8(t,s,r){return(s===!0||s===t)&&(r===null||r===t)}function m4t(t,s=10){let r=null;return Math.abs(t.y)>s?r="y":Math.abs(t.x)>s&&(r="x"),r}class p4t extends V_{constructor(s){super(s),this.removeGroupControls=gf,this.removeListeners=gf,this.controls=new u4t(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||gf}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 tme=t=>(s,r)=>{t&&pl.update(()=>t(s,r),!1,!0)};class f4t extends V_{constructor(){super(...arguments),this.removePointerDownListener=gf}onPointerDown(s){this.session=new VUe(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:UUe(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:r,onPan:n,onPanEnd:a}=this.node.getProps();return{onSessionStart:tme(s),onStart:tme(r),onMove:tme(n),onEnd:(o,l)=>{delete this.session,a&&pl.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=YP(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 sme=!1;class g4t extends S.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),sme&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),ure.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}),sme=!0,a||s.layoutDependency!==r||r===void 0||s.isPresent!==o?l.willUpdate():this.safeToRemove(),s.isPresent!==o&&(o?l.promote():l.relegate()||pl.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(),$_e.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:a}=s;sme=!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 WUe(t){const[s,r]=LUe(),n=S.useContext(w_e);return e.jsx(g4t,{...t,layoutGroup:n,switchLayoutGroup:S.useContext($Ue),isPresent:s,safeToRemove:r})}const x4t={pan:{Feature:f4t},drag:{Feature:p4t,ProjectionNode:IUe,MeasureLayout:WUe}};function FMe(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&&pl.postRender(()=>o(s,AL(s)))}class y4t extends V_{mount(){const{current:s}=this.node;s&&(this.unmount=zNt(s,(r,n)=>(FMe(this.node,n,"Start"),a=>FMe(this.node,a,"End"))))}unmount(){}}class v4t extends V_{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=CL(JI(this.node.current,"focus",()=>this.onFocus()),JI(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function zMe(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&&pl.postRender(()=>o(s,AL(s)))}class _4t extends V_{mount(){const{current:s}=this.node;if(!s)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=HNt(s,(a,o)=>(zMe(this.node,o,"Start"),(l,{success:i})=>zMe(this.node,l,i?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const fxe=new WeakMap,rme=new WeakMap,b4t=t=>{const s=fxe.get(t.target);s&&s(t)},w4t=t=>{t.forEach(b4t)};function j4t({root:t,...s}){const r=t||document;rme.has(r)||rme.set(r,{});const n=rme.get(r),a=JSON.stringify(s);return n[a]||(n[a]=new IntersectionObserver(w4t,{root:t,...s})),n[a]}function k4t(t,s,r){const n=j4t(s);return fxe.set(t,r),n.observe(t),()=>{fxe.delete(t),n.unobserve(t)}}const N4t={some:0,all:1};class S4t extends V_{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:N4t[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:g,onViewportLeave:v}=this.node.getProps(),_=p?g:v;_&&_(u)};this.stopObserver=k4t(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(C4t(s,r))&&this.startObserver()}unmount(){var s;(s=this.stopObserver)==null||s.call(this),this.hasEnteredView=!1,this.isInView=!1}}function C4t({viewport:t={}},{viewport:s={}}={}){return r=>t[r]!==s[r]}const M4t={inView:{Feature:S4t},tap:{Feature:_4t},focus:{Feature:v4t},hover:{Feature:y4t}},T4t={layout:{ProjectionNode:IUe,MeasureLayout:WUe}},A4t={...JCt,...M4t,...x4t,...T4t},wr=KCt(A4t,ZCt);function GUe({slugOverride:t}={}){var nt;const{slug:s}=Co(),r=t||s,[n]=Ac(),a=n.get("t"),[o,l]=S.useState(!0),[i,d]=S.useState(null),[u,p]=S.useState(null),[g,v]=S.useState(null),[_,b]=S.useState(null),[j,w]=S.useState(!1),[N,C]=S.useState(!1),[A,I]=S.useState(0),[L,R]=S.useState(!1),[$,q]=S.useState(""),[U,V]=S.useState(""),[X,se]=S.useState(""),[te,Y]=S.useState(""),[de,ie]=S.useState(""),[ae,le]=S.useState(""),[pe,be]=S.useState(""),[ye,we]=S.useState(""),[Ne,Ke]=S.useState(""),[_e,Me]=S.useState(""),[Te,Fe]=S.useState(""),[Ae,Ue]=S.useState("");S.useEffect(()=>{ut()},[r,a]);const ut=async()=>{if(!r)return;l(!0);const{data:Qe,error:ke}=await G.from("contact_intake_pages").select("*").eq("slug",r).eq("is_active",!0).maybeSingle();if(ke||!Qe){R(!0),l(!1);return}p(Qe);const{data:ot}=await G.from("profiles").select("name, avatar_url, title, phone, email, brokerage_id").eq("id",Qe.user_id).single();if(ot){let qe;if(ot.brokerage_id){const{data:lt}=await G.from("brokerages").select("name").eq("id",ot.brokerage_id).single();qe=(lt==null?void 0:lt.name)||void 0}d({...ot,brokerage_name:qe})}if(a)try{console.log("[ConnectPage] Resolving token:",a,"for page:",Qe.id);const{data:qe,error:lt}=await G.functions.invoke("process-intake-submissions",{body:{action:"resolve_token",token:a,page_id:Qe.id}});if(console.log("[ConnectPage] Resolve result:",{resolved:qe,resolveErr:lt}),!lt&&(qe!=null&&qe.contact_id)){b(qe.contact_id);const We=qe.contact;We&&(v(We),q(We.first_name||""),V(We.last_name||""),se(We.email||""),Y(We.phone||""),ie(We.address||""),le(We.city||""),be(We.state||""),we(We.zip||""),Ke(We.birthday||""),Me(We.home_anniversary||""))}}catch(qe){console.error("Failed to resolve token:",qe)}l(!1)},De=async()=>{if(!$.trim()){fe.error("Please enter your first name");return}if(!(!u||!i)){C(!0);try{const{error:Qe}=await G.from("contact_intake_submissions").insert({intake_page_id:u.id,agent_user_id:u.user_id,existing_contact_id:_,first_name:$.trim(),last_name:U.trim()||null,email:X.trim()||null,phone:te.trim()||null,address:de.trim()||null,city:ae.trim()||null,state:pe.trim()||null,zip:ye.trim()||null,birthday:Ne||null,home_anniversary:_e||null,real_estate_interest:Te||null,message:Ae.trim()||null});if(Qe)throw Qe;a&&await G.from("contact_intake_tokens").update({used_at:new Date().toISOString()}).eq("token",a),w(!0)}catch(Qe){console.error(Qe),fe.error("Something went wrong. Please try again.")}finally{C(!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(As,{className:"h-8 w-8 animate-spin text-slate-400"})});if(L)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(j)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(nh,{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(la,{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(Ni,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})]})]});const Dt=!!a&&!!g,he=3,Ve=[{title:Dt?"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:$,onChange:Qe=>q(Qe.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:U,onChange:Qe=>V(Qe.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:X,onChange:Qe=>se(Qe.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:te,onChange:Qe=>Y(Qe.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:de,onChange:Qe=>ie(Qe.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:ae,onChange:Qe=>le(Qe.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:pe,onChange:Qe=>be(Qe.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:ye,onChange:Qe=>we(Qe.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:Ne,onChange:Qe=>Ke(Qe.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:_e,onChange:Qe=>Me(Qe.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(Qe=>e.jsxs("button",{type:"button",onClick:()=>Fe(Te===Qe.value?"":Qe.value),className:`p-3.5 rounded-xl border-2 text-left transition-all ${Te===Qe.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:Qe.label}),e.jsx("span",{className:"block text-xs text-slate-500 mt-0.5",children:Qe.desc})]},Qe.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:Ae,onChange:Qe=>Ue(Qe.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(nh,{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:((nt=i==null?void 0:i.name)==null?void 0:nt.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(Zn,{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:he}).map((Qe,ke)=>e.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-all duration-500 ${ke<=A?"bg-blue-500":"bg-slate-200"}`},ke))}),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(jCt,{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(mn,{className:"h-5 w-5 text-blue-500"}),e.jsx("h2",{className:"text-lg font-semibold text-slate-800",children:Ve[A].title})]}),Ve[A].fields]},A)}),e.jsxs("div",{className:"flex justify-between mt-8",children:[A>0?e.jsx("button",{onClick:()=>I(Qe=>Qe-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",{}),A{if(A===0&&!$.trim()){fe.error("Please enter your first name");return}I(Qe=>Qe+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",{onClick:De,disabled:N,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:N?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):"Submit"})]}),A>0&&AI(Qe=>Qe+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(Ni,{className:"h-3 w-3"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})})]})]})}function tE({banners:t,autoPlayInterval:s=5e3,className:r}){const[n,a]=S.useState(0),[o,l]=S.useState(!1),i=S.useCallback(()=>{a(g=>(g+1)%t.length)},[t.length]),d=S.useCallback(()=>{a(g=>(g-1+t.length)%t.length)},[t.length]),u=S.useCallback(g=>{a(g)},[]);if(S.useEffect(()=>{if(t.length<=1||o)return;const g=setInterval(i,s);return()=>clearInterval(g)},[t.length,o,s,i]),!t||t.length===0)return null;const p=t[n];return e.jsxs("div",{className:Et("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:Et("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(Ol,{className:"h-6 w-6"})}),e.jsx(K,{variant:"ghost",size:"icon",className:Et("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(qa,{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((g,v)=>e.jsx("button",{onClick:()=>u(v),className:Et("w-2 h-2 rounded-full transition-all duration-300",v===n?"bg-white w-6":"bg-white/50 hover:bg-white/70"),"aria-label":`Go to slide ${v+1}`},v))})]}),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 E4t(t){return"EST"}function e6(t){const r=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"America/New_York"}).format(t),n=E4t();return`${r} ${n}`}function E5(t){const s=new Date,r=new Date(t),n=O4(r,-15),a=O4(r,30);return s>a?"ended":wg(s,{start:r,end:a})?"live":wg(s,{start:n,end:r})?"starting_soon":"upcoming"}function X_e(t){const s=E5(t);return s==="starting_soon"||s==="live"}const BMe=X_e,P4t=({events:t,registrations:s,onNavigateToEvents:r})=>{const[n,a]=S.useState(new Date);S.useEffect(()=>{const _=setInterval(()=>{a(new Date)},3e4);return()=>clearInterval(_)},[]);const o=t.filter(_=>X_e(_.event_date));if(o.length===0)return null;const l=o[0],i=E5(l.event_date),d=s.find(_=>_.event_id===l.id),u=(d==null?void 0:d.zoom_join_url)||l.zoom_link,p=!!d,g=i==="live",v=g?{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 ${v.container} border`,children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-r ${v.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 ${v.indicator} opacity-75`}),e.jsx("span",{className:`relative flex h-3 w-3 rounded-full ${v.indicator}`})]}),e.jsx("div",{className:`flex items-center gap-2 ${v.text} font-bold text-sm uppercase tracking-wider`,children:g?e.jsxs(e.Fragment,{children:[e.jsx(iN,{className:"h-4 w-4"}),"Live Now"]}):e.jsxs(e.Fragment,{children:[e.jsx(In,{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:g?`Started at ${e6(new Date(l.event_date))}`:`Starts at ${e6(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:`${v.button} text-white gap-2`,children:[e.jsx(rn,{className:"h-4 w-4"}),g?"Join Now":"Join When Live"]}):e.jsxs(K,{variant:"outline",onClick:r,className:`${v.outlineButton} gap-2`,children:[e.jsx(hr,{className:"h-4 w-4"}),"Register & Join"]})})]})})]})};var Q_e="Progress",J_e=100,[I4t]=Tc(Q_e),[L4t,D4t]=I4t(Q_e),KUe=S.forwardRef((t,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:o=O4t,...l}=t;(a||a===0)&&!$Me(a)&&console.error(R4t(`${a}`,"Progress"));const i=$Me(a)?a:J_e;n!==null&&!qMe(n,i)&&console.error(F4t(`${n}`,"Progress"));const d=qMe(n,i)?n:null,u=Lne(d)?o(d,i):void 0;return e.jsx(L4t,{scope:r,value:d,max:i,children:e.jsx(Qr.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":Lne(d)?d:void 0,"aria-valuetext":u,role:"progressbar","data-state":XUe(d,i),"data-value":d??void 0,"data-max":i,...l,ref:s})})});KUe.displayName=Q_e;var ZUe="ProgressIndicator",YUe=S.forwardRef((t,s)=>{const{__scopeProgress:r,...n}=t,a=D4t(ZUe,r);return e.jsx(Qr.div,{"data-state":XUe(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:s})});YUe.displayName=ZUe;function O4t(t,s){return`${Math.round(t/s*100)}%`}function XUe(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function Lne(t){return typeof t=="number"}function $Me(t){return Lne(t)&&!isNaN(t)&&t>0}function qMe(t,s){return Lne(t)&&!isNaN(t)&&t<=s&&t>=0}function R4t(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${J_e}\`.`}function F4t(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 ${J_e} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var QUe=KUe,z4t=YUe;const Mi=S.forwardRef(({className:t,value:s,...r},n)=>e.jsx(QUe,{ref:n,className:Et("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...r,children:e.jsx(z4t,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));Mi.displayName=QUe.displayName;function B4t(){const{user:t,isBrokerageManager:s}=Gs(),[r,n]=S.useState([]),[a,o]=S.useState([]),[l,i]=S.useState(!1),[d,u]=S.useState(!0),p=s?"brokerage_manager":"agent";S.useEffect(()=>{if(!(t!=null&&t.id)){u(!1);return}g()},[t==null?void 0:t.id,p]);const g=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 v(I,R||[])}catch(I){console.error("Error fetching checklist data:",I)}finally{u(!1)}},v=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,V,X,se,te,Y,de,ie,ae,le,pe,be,ye,we]=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={},Ke=(Fe=q.data)==null?void 0:Fe.brokerage_id;Ne.share_resource=(U.count||0)>0,Ne.post_community=(V.count||0)>0,Ne.register_event=(X.count||0)>0,Ne.view_template=(se.count||0)>0,Ne.watch_academy=(te.count||0)>0,Ne.use_toolbox=(Y.count||0)>0,Ne.launch_app=(de.count||0)>0,Ne.add_contact=(ie.count||0)>0,Ne.create_video=(ae.count||0)>0,Ne.complete_touch=(le.count||0)>0,Ne.add_transaction=(pe.count||0)>0,Ne.add_listing=(be.count||0)>0,Ne.add_deal=(we.count||0)>0;const _e=((Ae=ye.data)==null?void 0:Ae.map(Ue=>Ue.id))||[],Me=[];Ke?Me.push(G.from("profiles").select("id").eq("brokerage_id",Ke).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,_e.length>0?(Me.push(G.from("contact_plan_cycles").select("id",{count:"exact",head:!0}).in("contact_id",_e).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",_e).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(Dt=>({item_id:Dt.id,completed_at:new Date().toISOString()}));o(Dt=>[...Dt,...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)}},j=a.length,w=r.length,N=w>0&&j>=w,C=w>0?j/w*100:0;return{items:r,progress:a,isDismissed:l,loading:d,completedCount:j,totalCount:w,isComplete:N,progressPercentage:C,isItemComplete:I=>a.some(L=>L.item_id===I),markComplete:_,dismiss:b,refetch:g}}const $4t={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(i0,{className:"h-4 w-4"}),watch_academy:e.jsx(th,{className:"h-4 w-4"}),use_toolbox:e.jsx(Kx,{className:"h-4 w-4"}),launch_app:e.jsx(HE,{className:"h-4 w-4"}),add_deal:e.jsx(Vx,{className:"h-4 w-4"}),add_listing:e.jsx(Vn,{className:"h-4 w-4"})},q4t={add_deal:"/mission-control/pipeline",add_listing:"/mission-control/listings/new",post_community:"/community",add_contact:"/mission-control/contacts"};function U4t(){const{items:t,isDismissed:s,loading:r,completedCount:n,totalCount:a,isComplete:o,progressPercentage:l,isItemComplete:i,markComplete:d,dismiss:u}=B4t(),p=Lr(),[g,v]=S.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(Lt,{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(Hx,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{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:()=>v(!g),className:"h-8 w-8 p-0",children:g?e.jsx(Rg,{className:"h-4 w-4"}):e.jsx(Vo,{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(Mi,{value:l,className:"h-2"})]})]}),g&&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:Et("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 j=q4t[_.action_type];j?p(j):d(_.id)},children:[e.jsx("div",{className:"mt-0.5",children:b?e.jsx(la,{className:"h-5 w-5 text-primary"}):e.jsx(Wc,{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:$4t[_.action_type]||e.jsx(Wc,{className:"h-4 w-4"})}),e.jsx("span",{className:Et("font-medium",b&&"line-through text-muted-foreground"),children:_.title})]}),_.description&&e.jsx("p",{className:Et("text-sm text-muted-foreground mt-1",b&&"line-through"),children:_.description})]})]},_.id)})})})]})}const Ef=()=>Ct({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}}),Xh=t=>{const s=si(),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})},V4t=t=>Ct({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}),JUe=()=>{const t=si();return Ct({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})},Zoe=()=>{const t=ns(),s=si();return Ot({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"]}),an({title:"Contact created successfully"})},onError:r=>{an({title:"Error creating contact",description:r.message,variant:"destructive"})}})},ebe=()=>{const t=ns();return Ot({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"]}),an({title:"Contact updated successfully"})},onError:s=>{an({title:"Error updating contact",description:s.message,variant:"destructive"})}})},eVe=()=>{const t=ns();return Ot({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"]}),an({title:"Spouse link updated"})},onError:s=>{an({title:"Error linking spouse",description:s.message,variant:"destructive"})}})},tbe=()=>{const t=ns();return Ot({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"]}),an({title:"Contact deleted successfully"})},onError:s=>{an({title:"Error deleting contact",description:s.message,variant:"destructive"})}})},EL=()=>Ct({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}}),H4t=t=>Ct({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}}),W4t=()=>Ct({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}}),G4t=()=>{const t=ns(),s=si();return Ot({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"]}),an({title:"Plan created successfully"})},onError:r=>{an({title:"Error creating plan",description:r.message,variant:"destructive"})}})},K4t=()=>{const t=ns(),s=si();return Ot({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"]}),an({title:"Plan duplicated successfully",description:"You can now edit your copy of this plan."})},onError:r=>{an({title:"Error duplicating plan",description:r.message,variant:"destructive"})}})},Z4t=()=>{const t=ns();return Ot({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"]}),an({title:"Plan updated successfully"})}})},Y4t=()=>{const t=ns();return Ot({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"]}),an({title:"Plan deleted successfully"})}})},X4t=()=>{const t=ns();return Ot({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"]}),an({title:"Plan schedule updated"})}})},Q4t=()=>{const t=ns();return Ot({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"]}),an({title:"Script created successfully"})},onError:s=>{an({title:"Error creating script",description:s.message,variant:"destructive"})}})},J4t=()=>{const t=si();return Ct({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})},e5t=()=>{const t=ns(),s=si();return Ot({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"]}),an({title:"Plan enrollment updated"})}})},PL=(t=7)=>{const s=si();return Ct({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})},tVe=()=>{const t=si();return Ct({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})},t5t=(t=90)=>{const{data:s}=Xh(),{data:r}=tVe();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=ns(),s=si();return Ot({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"]}),an({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{}}})},sVe="agentos_weekly_touch_goal",UMe=20,Dne=()=>{if(typeof window>"u")return UMe;const t=localStorage.getItem(sVe);if(t){const s=parseInt(t,10);if(!isNaN(s)&&s>0)return s}return UMe},rVe=t=>{localStorage.setItem(sVe,t.toString())},rbe=()=>{const{data:t}=PL(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=Dne();return{actionsThisWeek:n,weeklyGoal:o,streak:a,progress:Math.min(n/o*100,100)}},s5t=()=>{const t=si();return Ct({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})},r5t=()=>{const t=ns();return si(),Ot({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&&an({title:`${s} contact(s) enrolled in plans`})}})},nVe=()=>{const t=si(),{data:s}=s5t(),{data:r}=PL(30);return Ct({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(j=>j.contact_id))||[]),o=new Date,l=[],i=new Date(o.getFullYear(),o.getMonth(),1),d=new Set((r==null?void 0:r.filter(j=>new Date(j.completed_at)>=i).map(j=>`${j.contact_id}-${j.action_type_id}`))||[]);for(const j of s){if(!((b=j.plan)!=null&&b.items)||j.plan.items.length===0||!j.contact||a.has(j.contact_id))continue;const w=new Date(j.cycle_start_date),C=Math.floor((o.getTime()-w.getTime())/(30.44*24*60*60*1e3))%12+1,A=j.plan.items.find(I=>I.month_number===C);if(A&&A.action_type){const I=`${j.contact_id}-${A.action_type_id}`;if(!d.has(I)){const{data:L}=await G.from("relationship_types").select("name").eq("id",j.relationship_type_id).single();l.push({contact:j.contact,actionType:A.action_type,script:A.default_script||void 0,planName:j.plan.name,relationshipTypeName:(L==null?void 0:L.name)||"",monthNumber:C})}}}const u=5,p=o.getDate(),g=l.sort((j,w)=>j.contact.first_name.localeCompare(w.contact.first_name)),v=(p-1)%Math.max(1,g.length);return[...g.slice(v),...g.slice(0,v)].slice(0,u)},enabled:!!t&&!!s})};function n5t(){const t=Lr(),{data:s,isLoading:r}=nVe(),{data:n}=Xh(),a=rbe(),[o,l]=S.useState(Dne()),[i,d]=S.useState(""),[u,p]=S.useState(!1);S.useEffect(()=>{l(Dne())},[]);const g=()=>{const R=parseInt(i,10);if(isNaN(R)||R<1){an({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}l(R),rVe(R),p(!1),an({title:"Goal updated",description:`Weekly touch goal set to ${R}`})},v=()=>{d(o.toString()),p(!0)},_=Hh(new Date),b=hl(_,7),j=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)},w=(n==null?void 0:n.map(R=>{const $=j(R.birthday),q=j(R.home_anniversary),U=[];return $&&$>=_&&$<=b&&U.push({contact:R,type:"birthday",date:$,isToday:ll($,_)}),q&&q>=_&&q<=b&&U.push({contact:R,type:"anniversary",date:q,isToday:ll(q,_)}),U}).flat().sort((R,$)=>R.date.getTime()-$.date.getTime()).slice(0,3))||[],N=(n==null?void 0:n.filter(R=>{const $=j(R.birthday),q=j(R.home_anniversary);return $&&ll($,_)||q&&ll(q,_)}).length)||0,C=(s==null?void 0:s.length)||0,A=N+C,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(Lt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{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(at,{variant:"secondary",className:"gap-1 bg-orange-500/10 text-orange-600 border-orange-200",children:[e.jsx(Bh,{className:"h-3 w-3"}),L," day streak"]})})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[A>0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-primary font-medium",children:[A," 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(fc,{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(Zn,{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(Ti,{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(Vx,{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(Uh,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Weekly Goal"}),e.jsxs(vs,{open:u,onOpenChange:p,children:[e.jsx(Ai,{asChild:!0,children:e.jsx("button",{onClick:v,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(Fl,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})})}),e.jsxs(ys,{className:"sm:max-w-[360px]",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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"&&g()}})]}),e.jsx(K,{onClick:g,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(Mi,{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"]})]}),w.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(Ou,{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:w.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(Ou,{className:"h-3.5 w-3.5 text-pink-500"}):e.jsx(Vn,{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(at,{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"?"🎂":"🏠":ws(R.date,"EEE, MMM d")}),e.jsx(qa,{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(Ui,{className:"h-4 w-4"})]})]})]})}function a5t(t){return Ct({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 i5t(t,s){return Ct({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 o5t(t,s=4){return Ct({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 l5t(t){const s=ns();return Ot({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 c5t(){const t=ns();return Ot({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 d5t(t){const s=ns();return Ot({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 u5t(){const t=ns();return Ot({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 h5t(t){const s=ns();return Ot({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 m5t={video:dl,pdf:Sn,link:Ho,event:on,graphic:Rl},p5t={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 g5t(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 x5t({item:t}){const s=Lr(),r=m5t[t.content_type]||Ho,n=p5t[t.content_type]||"",[a,o]=S.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);S.useEffect(()=>{l||!t.url||t.content_type!=="video"||!g5t(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(at,{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:ws(new Date(t.event_date),"MMM d · h:mm a")})]})]})}function y5t(){const{brokerageId:t}=Gs(),s=Lr(),{data:r=[],isLoading:n}=o5t(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(Ca,{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(Ui,{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(x5t,{item:a},a.id))})]})}const aVe=()=>Ct({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}}),iVe=t=>{const{user:s,brokerageId:r}=Gs();return Ct({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(g=>g.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 g=new Set(l.map(_=>_.id)),v=p.filter(_=>!g.has(_.id));l=[...l,...v]}}}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}})},oVe=()=>{const{user:t}=Gs();return Ct({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})},lVe=t=>{const{user:s}=Gs();return Ct({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})},v5t=()=>{const t=ns(),{user:s}=Gs();return Ot({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"]})}})},_5t=()=>{const t=ns();return Ot({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"]})}})},b5t=()=>{const t=ns();return Ot({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]})}})},cVe=()=>{const t=ns();return Ot({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"]})}})},w5t=()=>{const t=ns();return Ot({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"]})}})},j5t=()=>{const t=ns();return Ot({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"]})}})},k5t=()=>{const t=ns();return Ot({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"]})}})},N5t=()=>{const t=ns();return Ot({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"]})}})},S5t=()=>{const{user:t}=Gs();return Ct({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})},dVe=()=>{const t=ns(),{user:s}=Gs();return Ot({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"]})}})},uVe=t=>{const{user:s}=Gs();return Ct({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})},C5t=()=>{const t=ns(),{user:s}=Gs();return Ot({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"]})}})},M5t=t=>{const{user:s}=Gs();return Ct({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})},T5t=()=>{const{user:t}=Gs();return Ot({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}})},A5t=()=>{const{user:t}=Gs();return Ct({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})},E5t=()=>{const t=ns(),{user:s}=Gs();return Ot({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"]})}})},P5t=()=>Ct({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}}}),I5t=()=>{const{user:t,brokerageId:s}=Gs();return Ct({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})},hVe=({className:t,variant:s="default"})=>e.jsx(at,{variant:"outline",className:Et("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"}),L5t={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"},D5t={coming_soon:"Coming Soon",active:"Active",under_contract:"Under Contract",sold:"Sold",withdrawn:"Withdrawn"};function O5t(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function R5t(){const t=Lr(),{data:s,isLoading:r}=aVe(),{data:n,isLoading:a}=iVe({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(hVe,{})]}),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(Ui,{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(Vn,{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 v,_;const g=((v=p.photos)==null?void 0:v.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:[g!=null&&g.photo_url?e.jsx("img",{src:g.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(Vn,{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(at,{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(at,{className:`text-[10px] px-1.5 py-0.5 ${L5t[p.status]}`,children:D5t[p.status]})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"font-bold text-sm text-foreground",children:O5t(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 mVe(t=10,s){return Ct({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(v=>v.user_id))||[]);let a=null;if(s){const{data:v}=await G.from("profiles").select("id").eq("brokerage_id",s);a=new Set((v==null?void 0:v.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(v=>!n.has(v.user_id));a&&(i=i.filter(v=>a.has(v.user_id)));const d=i.slice(0,t),u=d.map(v=>v.user_id),{data:p}=await G.from("profiles").select("id, name").in("id",u),g=new Map((p==null?void 0:p.map(v=>[v.id,{name:v.name}]))||[]);return d.map(v=>({user_id:v.user_id,total_points:v.total_points,total_events_attended:v.total_events_attended,current_streak:v.current_streak,profile:g.get(v.user_id)||null}))}})}function pVe(t){return Ct({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 fVe(t){return Ct({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 gVe(t,s){return Ct({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 F5t(){const{user:t,brokerageId:s,isAdmin:r}=Gs();Lr();const n=!!s,[a,o]=S.useState("brokerage"),l=()=>{if(r)return null;if(n)return a==="global"?null:s},{data:i,isLoading:d}=mVe(5,l()),{data:u}=pVe(t==null?void 0:t.id),{data:p}=gVe(t==null?void 0:t.id,l()),{data:g}=fVe(t==null?void 0:t.id),v=r||n,_=()=>r?"Agent Leaderboard":n?a==="global"?"All LevelUp":"My Brokerage":"My Points";if(d)return e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Gi,{className:"h-4 w-4 text-yellow-500"}),_()]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:[...Array(v?5:3)].map((j,w)=>e.jsx(gs,{className:"h-10 w-full"},w))})})]});const b=j=>j===0?e.jsx(Gi,{className:"h-4 w-4 text-yellow-500 mx-auto"}):j===1?e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"2"}):j===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:j+1});if(v){const j=(i==null?void 0:i.slice(0,5))||[];return e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"pb-2",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Gi,{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:[j.map((w,N)=>{var C,A,I;return e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg ${w.user_id===(t==null?void 0:t.id)?"bg-primary/10 border border-primary/20":N===0?"bg-yellow-500/10":""}`,children:[e.jsx("div",{className:"w-5 text-center",children:b(N)}),e.jsx(fn,{className:"h-6 w-6",children:e.jsx(gn,{className:"text-xs",children:((A=(C=w.profile)==null?void 0:C.name)==null?void 0:A.charAt(0))||"?"})}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:((I=w.profile)==null?void 0:I.name)||"Unknown"}),e.jsx("span",{className:"text-sm font-bold text-primary",children:w.total_points})]},w.user_id)}),j.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(ao,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(qa,{className:"h-4 w-4"})]})]})]})}return e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Gi,{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(Bh,{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," 🔥"]})]}),g&&g.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(ec,{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:[g.slice(0,4).map(j=>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:j.badge_name},j.id)),g.length>4&&e.jsxs("span",{className:"text-xs text-muted-foreground px-2 py-1",children:["+",g.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(ao,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(qa,{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(ao,{className:"h-4 w-4"}),"Visit Reward Store",e.jsx(qa,{className:"h-4 w-4"})]})]})})]})}const IL=()=>Ct({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}}),xVe=()=>{const t=ns(),{user:s}=Gs();return Ot({mutationFn:async r=>{const{data:n,error:a}=await G.from("lead_sources").insert({name:r,owner_user_id:s==null?void 0:s.id,sort_order:100}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),fe.success("Lead source added")},onError:r=>{fe.error("Failed to add lead source"),console.error(r)}})},nbe=(t,s)=>{const{user:r,isAdmin:n}=Gs(),a=n&&s?s:r==null?void 0:r.id;return Ct({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})},abe=t=>{const{user:s,isAdmin:r}=Gs(),n=r&&t?t:s==null?void 0:s.id;return Ct({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})},Yoe=()=>{const t=ns(),{user:s}=Gs();return Ot({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)}})},z5t=()=>{const t=ns();return Ot({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)}})},B5t=()=>{const t=ns();return Ot({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)}})},yVe=(t,s)=>{const{user:r,isAdmin:n}=Gs(),a=n&&s?s:r==null?void 0:r.id;return Ct({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})},$5t=()=>{const t=ns(),{user:s}=Gs();return Ot({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)}})},Xoe=()=>{const{user:t}=Gs();return Ct({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)})},q5t=()=>{const t=ns(),{user:s}=Gs();return Ot({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)}})},vVe=(t,s)=>{const{data:r,isLoading:n}=nbe(t,s),{data:a,isLoading:o}=abe(s),{data:l}=Xoe(),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,g=u.filter(L=>L.transaction_type==="seller").length,v=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),j={};u.forEach(L=>{var $;const R=(($=L.lead_source)==null?void 0:$.name)||"Unknown";j[R]=(j[R]||0)+1});const w=Object.entries(j).map(([L,R])=>({name:L,count:R})).sort((L,R)=>R.count-L.count),N=w[0]||null,C={};u.forEach(L=>{const R=new Date(L.close_date).toLocaleString("default",{month:"short"});C[R]=(C[R]||0)+1});const I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(L=>({month:L,count:C[L]||0}));return{totalTransactions:u.length,buyerCount:p,sellerCount:g,totalVolume:v,averagePrice:u.length>0?v/u.length:0,totalCommission:i?_:0,totalNetToAgent:i?b:0,topLeadSource:N,transactionsByMonth:I,leadSourceBreakdown:w}};return{yearStats:d(r),lifetimeStats:d(a),isLoading:n||o,showCommission:i}},U5t=()=>{const{isAdmin:t}=Gs();return Ct({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})},i1={recency:40,touchpoints:30,transactions:20},VMe={warm:70,cooling:40};function V5t(t){return t===null?0:t<=14?i1.recency:t<=30?i1.recency*.85:t<=60?i1.recency*.65:t<=90?i1.recency*.4:t<=180?i1.recency*.2:i1.recency*.05}function H5t(t){const s=Math.min(t/12,1);return Math.round(i1.touchpoints*s)}function W5t(t){return t?i1.transactions:0}function G5t(){return 0}function K5t(t){return t>=VMe.warm?"warm":t>=VMe.cooling?"cooling":"at-risk"}function Qoe(){const{data:t,isLoading:s}=Xh(),{data:r}=tVe(),{data:n}=PL(365),{data:a}=abe(),o=S.useMemo(()=>{if(!t)return[];const i=new Date,d=Sk(i,12),u={};n==null||n.forEach(g=>{new Date(g.completed_at)>=d&&(u[g.contact_id]=(u[g.contact_id]||0)+1)});const p=new Set((a==null?void 0:a.filter(g=>g.contact_id).map(g=>g.contact_id))||[]);return t.map(g=>{const v=(r==null?void 0:r[g.id])||null,_=v?Vg(i,new Date(v)):null,b=u[g.id]||0,j=p.has(g.id),w=V5t(_),N=H5t(b),C=W5t(j),A=G5t(),I=Math.round(w+N+C+A),L={score:I,status:K5t(I),breakdown:{recency:Math.round(w),touchpoints:Math.round(N),transactions:Math.round(C),referrals:Math.round(A)},lastTouchDate:v,daysSinceTouch:_,touchCountLast12Months:b,hasTransaction:j};return{...g,relationshipScore:L}})},[t,r,n,a]),l=S.useMemo(()=>{const i=o.filter(v=>v.relationshipScore.status==="warm").length,d=o.filter(v=>v.relationshipScore.status==="cooling").length,u=o.filter(v=>v.relationshipScore.status==="at-risk").length,p=o.length,g=p>0?Math.round(o.reduce((v,_)=>v+_.relationshipScore.score,0)/p):0;return{warm:i,cooling:d,atRisk:u,total:p,averageScore:g}},[o]);return{contactsWithScores:o,stats:l,isLoading:s}}function _Ve(){const t=Lr(),{stats:s,contactsWithScores:r,isLoading:n}=Qoe();if(n)return e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(gs,{className:"h-5 w-40"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(gs,{className:"h-20 w-full"}),e.jsx(gs,{className:"h-16 w-full"})]})]});if(s.total===0)return e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{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(Lt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Sc,{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(Mi,{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(Mi,{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(Mi,{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(lN,{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(qa,{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(qa,{className:"h-4 w-4 ml-1"})]})]})]})}const Z5t=()=>{var ie;const{user:t,isAdmin:s}=Gs(),r=Lr(),[n,a]=S.useState([]),[o,l]=S.useState([]),[i,d]=S.useState([]),[u,p]=S.useState([]),[g,v]=S.useState([]),[_,b]=S.useState([]),[j,w]=S.useState(new Set),[N,C]=S.useState([]),[A,I]=S.useState([]),[L,R]=S.useState([]),[$,q]=S.useState(null),[U,V]=S.useState(!0);S.useEffect(()=>{X()},[t]);const X=async()=>{var ae,le,pe,be,ye;try{const[we,Ne,Ke,_e,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 Dt=((le=we.data)==null?void 0:le.map(ot=>ot.tag))||[],he=new Set(((pe=Ke.data)==null?void 0:pe.map(ot=>ot.app_id))||[]);w(he);const nt=(((be=Ne.data)==null?void 0:be.filter(ot=>!ot.required_tags||ot.required_tags.length===0?!0:ot.required_tags.some(qe=>Dt.includes(qe))))||[]).sort((ot,qe)=>ot.name==="LevelUp Members Portal"?-1:qe.name==="LevelUp Members Portal"?1:0);a(nt.slice(0,6));const Qe=((ye=_e.data)==null?void 0:ye.filter(ot=>E5(ot.event_date)!=="ended"))||[];l(Qe.slice(0,4)),C(Me.data||[]),d(Te.data||[]),p(Fe.data||[]),v(Ae.data||[]),b(Ue.data||[]);const ke=ut.data||[];I(ke.filter(ot=>ot.placement==="top")),R(ke.filter(ot=>ot.placement==="between"))}catch(we){console.error("Error loading dashboard:",we),fe.error("Failed to load dashboard data")}finally{V(!1)}},se=async ae=>{var pe;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:ye}=await G.functions.invoke("sso-launch",{body:{app_id:ae.app_id}});if(ye)throw ye;be!=null&&be.redirect_url?le&&!le.closed?(le.location.href=be.redirect_url,(pe=le.focus)==null||pe.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=>N==null?void 0:N.some(le=>le.event_id===ae),Y=ae=>{const le=N==null?void 0:N.find(pe=>pe.event_id===ae);return le==null?void 0:le.zoom_join_url};if(U)return e.jsx(Ms,{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(Ms,{title:"Dashboard",children:[e.jsx(P4t,{events:o,registrations:N,onNavigateToEvents:()=>r("/events")}),A.length>0&&e.jsx("div",{className:"mb-8",children:e.jsx(tE,{banners:A})}),e.jsx(U4t,{}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold text-foreground",children:["Welcome back, ",($||((ie=t==null?void 0:t.user_metadata)==null?void 0:ie.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(n5t,{}),e.jsx(_Ve,{}),e.jsx(F5t,{})]}),e.jsx(y5t,{}),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(Ui,{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),pe=Y(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 ${BMe(ae.event_date)?"bg-red-500/5 border-l-2 border-l-red-500":""}`,onClick:()=>r("/events"),children:[BMe(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(iN,{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 ",e6(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(pe,"_blank")},children:[e.jsx(rn,{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(qa,{className:"h-4 w-4"})]})})]},ae.id)})})]}),de("events").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(tE,{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(Ui,{className:"h-4 w-4"})]})]}),g.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(gm,{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:g.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(gm,{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(tE,{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(Ui,{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($h,{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($h,{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(tE,{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(Ui,{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(Q1,{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(Q1,{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(tE,{banners:de("templates")})}),e.jsx("div",{className:"mb-10",children:e.jsx(R5t,{})}),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(Ui,{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(Dg,{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=j.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(Dg,{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(Ui,{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(mn,{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(mn,{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",[Y5t]=Tc(bVe,[rBe]),tv=rBe(),wVe=t=>{const{__scopeAlertDialog:s,...r}=t,n=tv(s);return e.jsx(goe,{...n,...r,modal:!0})};wVe.displayName=bVe;var X5t="AlertDialogTrigger",jVe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=tv(r);return e.jsx($1e,{...a,...n,ref:s})});jVe.displayName=X5t;var Q5t="AlertDialogPortal",kVe=t=>{const{__scopeAlertDialog:s,...r}=t,n=tv(s);return e.jsx(xoe,{...n,...r})};kVe.displayName=Q5t;var J5t="AlertDialogOverlay",NVe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=tv(r);return e.jsx(hM,{...a,...n,ref:s})});NVe.displayName=J5t;var P5="AlertDialogContent",[e3t,t3t]=Y5t(P5),s3t=B8e("AlertDialogContent"),SVe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...a}=t,o=tv(r),l=S.useRef(null),i=Aa(s,l),d=S.useRef(null);return e.jsx(ayt,{contentName:P5,titleName:CVe,docsSlug:"alert-dialog",children:e.jsx(e3t,{scope:r,cancelRef:d,children:e.jsxs(mM,{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(s3t,{children:n}),e.jsx(n3t,{contentRef:l})]})})})});SVe.displayName=P5;var CVe="AlertDialogTitle",MVe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=tv(r);return e.jsx(_L,{...a,...n,ref:s})});MVe.displayName=CVe;var TVe="AlertDialogDescription",AVe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=tv(r);return e.jsx(bL,{...a,...n,ref:s})});AVe.displayName=TVe;var r3t="AlertDialogAction",EVe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=tv(r);return e.jsx(wL,{...a,...n,ref:s})});EVe.displayName=r3t;var PVe="AlertDialogCancel",IVe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:a}=t3t(PVe,r),o=tv(r),l=Aa(s,a);return e.jsx(wL,{...o,...n,ref:l})});IVe.displayName=PVe;var n3t=({contentRef:t})=>{const s=`\`${P5}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${P5}\` by passing a \`${TVe}\` 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 \`${P5}\`. 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 S.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},a3t=wVe,i3t=jVe,o3t=kVe,LVe=NVe,DVe=SVe,OVe=EVe,RVe=IVe,FVe=MVe,zVe=AVe;const tc=a3t,Ih=i3t,l3t=o3t,BVe=S.forwardRef(({className:t,...s},r)=>e.jsx(LVe,{className:Et("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}));BVe.displayName=LVe.displayName;const Tl=S.forwardRef(({className:t,...s},r)=>e.jsxs(l3t,{children:[e.jsx(BVe,{}),e.jsx(DVe,{ref:r,className:Et("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})]}));Tl.displayName=DVe.displayName;const Al=({className:t,...s})=>e.jsx("div",{className:Et("flex flex-col space-y-2 text-center sm:text-left",t),...s});Al.displayName="AlertDialogHeader";const El=({className:t,...s})=>e.jsx("div",{className:Et("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});El.displayName="AlertDialogFooter";const Pl=S.forwardRef(({className:t,...s},r)=>e.jsx(FVe,{ref:r,className:Et("text-lg font-semibold",t),...s}));Pl.displayName=FVe.displayName;const Il=S.forwardRef(({className:t,...s},r)=>e.jsx(zVe,{ref:r,className:Et("text-sm text-muted-foreground",t),...s}));Il.displayName=zVe.displayName;const fl=S.forwardRef(({className:t,...s},r)=>e.jsx(OVe,{ref:r,className:Et(VI(),t),...s}));fl.displayName=OVe.displayName;const Ll=S.forwardRef(({className:t,...s},r)=>e.jsx(RVe,{ref:r,className:Et(VI({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));Ll.displayName=RVe.displayName;const c3t=[{key:"contacts",label:"Contacts",icon:Zn,description:"View, add, and edit contacts"},{key:"pipeline",label:"Deal Pipeline",icon:sN,description:"View, add, and move deals"},{key:"client_portal",label:"Client Portals",icon:$h,description:"Manage client portals on deals"},{key:"videos",label:"Videos",icon:Nn,description:"View and upload videos"},{key:"listings",label:"Listings",icon:Vn,description:"View, create, and edit listings"},{key:"scorecard",label:"Scorecard",icon:X1,description:"View and add transactions"},{key:"popbys",label:"Pop-bys",icon:Ti,description:"View and log pop-bys"},{key:"digital_card",label:"Digital Card",icon:mp,description:"Create and edit digital business card"},{key:"guest_book",label:"Guest Book",icon:cu,description:"Manage open house guest books"},{key:"presentations",label:"Presentations",icon:uf,description:"Create and manage smart presentations"}];function d3t(){var $;const{user:t}=Gs(),[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(null),[g,v]=S.useState({email:"",name:"",password:""}),[_,b]=S.useState("create"),[j,w]=S.useState(!1),[N,C]=S.useState(null);S.useEffect(()=>{t&&A()},[t]);const A=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 V=q.map(te=>te.assistant_id),{data:X}=await G.from("profiles").select("id, name, email").in("id",V),se=q.map(te=>{const Y=X==null?void 0:X.find(de=>de.id===te.assistant_id);return{...te,permissions:te.permissions,assistant_profile:Y?{name:Y.name||"",email:Y.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(!g.email.trim()){fe.error("Please enter the assistant's email");return}w(!0);try{const{data:{session:q}}=await G.auth.getSession();if(!q)throw new Error("Not authenticated");const{data:U,error:V}=await G.from("profiles").select("id, name, email").eq("email",g.email.trim().toLowerCase()).single();if(V||!U){fe.error("No account found with that email. Try creating a new assistant instead.");return}const{data:X}=await G.from("agent_assistant_assignments").select("id").eq("agent_id",t.id).eq("assistant_id",U.id);if(X&&X.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:Y}=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(Y)throw Y;fe.success(`${U.name||U.email} linked as your assistant`),l(!1),v({email:"",name:"",password:""}),A()}catch(q){console.error("Error linking assistant:",q),fe.error(q.message||"Failed to link assistant")}finally{w(!1)}return}if(!g.email.trim()||!g.name.trim()||!g.password.trim()){fe.error("Please fill in all fields");return}if(g.password.length<6){fe.error("Password must be at least 6 characters");return}w(!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:g.email.trim(),password:g.password,name:g.name.trim(),purpose:"assistant"})}),V=await U.json();if(!U.ok)throw new Error(V.error||"Failed to create assistant account");const X=V.userId||V.id;if(!X)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:X,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:Y}=await G.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:X,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(Y)throw Y;fe.success(`Assistant account created for ${g.name.trim()}`),l(!1),v({email:"",name:"",password:""}),A()}catch(q){console.error("Error adding assistant:",q),fe.error(q.message||"Failed to add assistant")}finally{w(!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:V}=await G.from("agent_assistant_assignments").select("id").eq("assistant_id",u.assistant_id);(!V||V.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),A()}catch(q){console.error("Error removing assistant:",q),fe.error(q.message||"Failed to remove assistant")}},R=async(q,U,V)=>{C(q);try{const X=s.find(Y=>Y.id===q);if(!X)return;const se={...X.permissions,[U]:V},{error:te}=await G.from("agent_assistant_assignments").update({permissions:se}).eq("id",q);if(te)throw te;r(Y=>Y.map(de=>de.id===q?{...de,permissions:se}:de))}catch(X){console.error("Error updating permissions:",X),fe.error("Failed to update permissions")}finally{C(null)}};return n?e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{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(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"My Assistants"]}),e.jsx(yr,{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,V,X,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(fn,{className:"h-10 w-10",children:e.jsx(gn,{children:((V=(U=q.assistant_profile)==null?void 0:U.name)==null?void 0:V.split(" ").map(te=>te[0]).join("").toUpperCase())||"A"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((X=q.assistant_profile)==null?void 0:X.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((se=q.assistant_profile)==null?void 0:se.email)||""})]}),e.jsxs(at,{variant:"secondary",className:"ml-2",children:[e.jsx(sh,{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:c3t.map(te=>{const Y=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(Y,{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:N===q.id})]},te.key)})})]})]},q.id)})})})]}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(Io,{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:g.name,onChange:q=>v({...g,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:g.email,onChange:q=>v({...g,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:g.password,onChange:q=>v({...g,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(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:I,disabled:j,children:[j&&e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),_==="create"?"Create Assistant":"Link Assistant"]})]})]})}),e.jsx(tc,{open:i,onOpenChange:d,children:e.jsxs(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Remove Assistant?"}),e.jsxs(Il,{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(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:L,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function Au(t){this.content=t}Au.prototype={constructor:Au,find:function(t){for(var s=0;s>1}};Au.from=function(t){if(t instanceof Au)return t;var s=[];if(t)for(var r in t)s.push(r,t[r]);return new Au(s)};function $Ve(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=$Ve(a.content,o.content,r+1);if(l!=null)return l}r+=a.nodeSize}}function qVe(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 Ar(n,a)}cutByIndex(s,r){return s==r?Ar.empty:s==0&&r==this.content.length?this:new Ar(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 Ar(a,o)}addToStart(s){return new Ar([s].concat(this.content),this.size+s.nodeSize)}addToEnd(s){return new Ar(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?B8(r+1,o):B8(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 Ar.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new Ar(r.map(s.nodeFromJSON))}static fromArray(s){if(!s.length)return Ar.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}};ml.none=[];class Rne extends Error{}class pn{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=VVe(this.content,s+this.openStart,r);return n&&new pn(n,this.openStart,this.openEnd)}removeBetween(s,r){return new pn(UVe(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 pn.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 pn(Ar.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 pn(s,n,a)}}pn.empty=new pn(Ar.empty,0,0);function UVe(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(UVe(o.content,s-a-1,r-a-1)))}function VVe(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=VVe(l.content,s-o-1,r,l);return i&&t.replaceChild(a,l.copy(i))}function u3t(t,s,r){if(r.openStart>t.depth)throw new Rne("Inserted content deeper than insertion position");if(t.depth-r.openStart!=s.depth-r.openEnd)throw new Rne("Inconsistent open depths");return HVe(t,s,r,0)}function HVe(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 XP(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&&(hN(t.nodeAfter,n),o++));for(let i=o;ia&&xxe(t,s,a+1),l=n.depth>a&&xxe(r,n,a+1),i=[];return XP(null,t,a,i),o&&l&&s.index(a)==r.index(a)?(WVe(o,l),hN(mN(o,GVe(t,s,r,n,a+1)),i)):(o&&hN(mN(o,Fne(t,s,a+1)),i),XP(s,r,a,i),l&&hN(mN(l,Fne(r,n,a+1)),i)),XP(n,null,a,i),new Ar(i)}function Fne(t,s,r){let n=[];if(XP(null,t,r,n),t.depth>r){let a=xxe(t,s,r+1);hN(mN(a,Fne(t,s,r+1)),n)}return XP(s,null,r,n),new Ar(n)}function h3t(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(Ar.from(a));return{start:a.resolveNoCache(t.openStart+r),end:a.resolveNoCache(a.content.size-t.openEnd-r)}}class t6{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 zne(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 t6(r,n,o)}static resolveCached(s,r){let n=HMe.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()+")"),KVe(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=Ar.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=Ar.fromJSON(s,r.content),o=s.nodeType(r.type).create(r.attrs,a,n);return o.type.checkAttrs(o.attrs),o}};h_.prototype.text=void 0;class Bne extends h_{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):KVe(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 Bne(this.type,this.attrs,this.text,s)}withText(s){return s==this.text?this:new Bne(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 KVe(t,s){for(let r=t.length-1;r>=0;r--)s=t[r].type.name+"("+s+")";return s}class LN{constructor(s){this.validEnd=s,this.next=[],this.wrapCache=[]}static parse(s,r){let n=new g3t(s,r);if(n.next==null)return LN.empty;let a=ZVe(n);n.next&&n.err("Unexpected trailing text");let o=j3t(w3t(a));return k3t(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(` `)}}LN.empty=new LN(!0);class g3t{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 ZVe(t){let s=[];do s.push(x3t(t));while(t.eat("|"));return s.length==1?s[0]:{type:"choice",exprs:s}}function x3t(t){let s=[];do s.push(y3t(t));while(t.next&&t.next!=")"&&t.next!="|");return s.length==1?s[0]:{type:"seq",exprs:s}}function y3t(t){let s=b3t(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 WMe(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=WMe(t),n=r;return t.eat(",")&&(t.next!="}"?n=WMe(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:s}}function _3t(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 b3t(t){if(t.eat("(")){let s=ZVe(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=_3t(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 w3t(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 LN(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:QVe(this.attrs,s)}create(s=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new h_(this,this.computeAttrs(s),Ar.from(r),ml.setFrom(n))}createChecked(s=null,r,n){return r=Ar.from(r),this.checkContent(r),new h_(this,this.computeAttrs(s),r,ml.setFrom(n))}createAndFill(s=null,r,n){if(s=this.computeAttrs(s),r=Ar.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(Ar.empty,!0);return o?new h_(this,s,r.append(o),ml.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 tHe(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 N3t(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 S3t{constructor(s,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?N3t(s,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Joe{constructor(s,r,n,a){this.name=s,this.rank=r,this.schema=n,this.spec=a,this.attrs=eHe(s,a.attrs),this.excluded=null;let o=XVe(this.attrs);this.instance=o?new ml(this,o):null}create(s=null){return!s&&this.instance?this.instance:new ml(this,QVe(this.attrs,s))}static compile(s,r){let n=Object.create(null),a=0;return s.forEach((o,l)=>n[o]=new Joe(o,a++,r,l)),n}removeFromSet(s){for(var r=0;r-1}}class sHe{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=Au.from(s.nodes),r.marks=Au.from(s.marks||{}),this.nodes=KMe.compile(this.spec.nodes,this),this.marks=Joe.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]=LN.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?ZMe(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==""?[]:ZMe(this,l.split(" "))}this.nodeFromJSON=a=>h_.fromJSON(this,a),this.markFromJSON=a=>ml.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 KMe){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 Bne(n,n.defaultAttrs,s,ml.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 ZMe(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 C3t(t){return t.tag!=null}function M3t(t){return t.style!=null}let QP=class vxe{constructor(s,r){this.schema=s,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(a=>{if(C3t(a))this.tags.push(a);else if(M3t(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 XMe(this,r,!1);return n.addAll(s,ml.none,r.from,r.to),n.finish()}parseSlice(s,r={}){let n=new XMe(this,r,!0);return n.addAll(s,ml.none,r.from,r.to),pn.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=QMe(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=QMe(l)),l.node||l.ignore||l.mark||(l.node=a)})}return r}static fromSchema(s){return s.cached.domParser||(s.cached.domParser=new vxe(s,vxe.schemaRules(s)))}};const rHe={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},T3t={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},nHe={ol:!0,ul:!0},s6=1,_xe=2,JP=4;function YMe(t,s,r){return s!=null?(s?s6:0)|(s==="full"?_xe:0):t&&t.whitespace=="pre"?s6|_xe:r&~JP}class $8{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=ml.none,this.match=o||(l&JP?null:s.contentMatch)}findWrapping(s){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(Ar.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&s6)){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=Ar.from(this.content);return!s&&this.match&&(r=r.append(this.match.fillBefore(Ar.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&&!rHe.hasOwnProperty(s.parentNode.nodeName.toLowerCase())}}class XMe{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=YMe(null,r.preserveWhitespace,0)|(n?JP:0);a?o=new $8(a.type,a.attrs,ml.none,!0,r.topMatch||a.type.contentMatch,l):n?o=new $8(null,null,ml.none,!0,null,l):o=new $8(s.schema.topNodeType,null,ml.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&_xe?"full":this.localPreserveWS||(a.options&s6)>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):JMe(u.type,s))?(d=u.addToSet(d),!1):!0),this.nodes.push(new $8(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|=s6)}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 A3t(t){for(let s=t.firstChild,r=null;s;s=s.nextSibling){let n=s.nodeType==1?s.nodeName.toLowerCase():null;n&&nHe.hasOwnProperty(n)&&r?(r.appendChild(s),s=r):n=="li"?r=s:n&&(r=null)}}function E3t(t,s){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,s)}function QMe(t){let s={};for(let r in t)s[r]=t[r];return s}function JMe(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&&hre(ame(n),a(s,r),null,s.attrs)}static renderSpec(s,r,n=null,a){return hre(s,r,n,a)}static fromSchema(s){return s.cached.domSerializer||(s.cached.domSerializer=new sS(this.nodesFromSchema(s),this.marksFromSchema(s)))}static nodesFromSchema(s){let r=eTe(s.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(s){return eTe(s.marks)}}function eTe(t){let s={};for(let r in t){let n=t[r].spec.toDOM;n&&(s[r]=n)}return s}function ame(t){return t.document||window.document}const tTe=new WeakMap;function P3t(t){let s=tTe.get(t);return s===void 0&&tTe.set(t,s=I3t(t)),s}function I3t(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 g in u)if(u[g]!=null){let v=g.indexOf(" ");v>0?d.setAttributeNS(g.slice(0,v),g.slice(v+1),u[g]):g=="style"&&d.style?d.style.cssText=u[g]:d.setAttribute(g,u[g])}}for(let g=p;gp)throw new RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}else{let{dom:_,contentDOM:b}=hre(t,v,r,n);if(d.appendChild(_),b){if(i)throw new RangeError("Multiple content holes");i=b}}}return{dom:d,contentDOM:i}}const aHe=65535,iHe=Math.pow(2,16);function L3t(t,s){return t+s*iHe}function sTe(t){return t&aHe}function D3t(t){return(t-(t&aHe))/iHe}const oHe=1,lHe=2,mre=4,cHe=8;class bxe{constructor(s,r,n){this.pos=s,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&cHe)>0}get deletedBefore(){return(this.delInfo&(oHe|mre))>0}get deletedAfter(){return(this.delInfo&(lHe|mre))>0}get deletedAcross(){return(this.delInfo&mre)>0}}class op{constructor(s,r=!1){if(this.ranges=s,this.inverted=r,!s.length&&op.empty)return op.empty}recover(s){let r=0,n=sTe(s);if(!this.inverted)for(let a=0;as)break;let u=this.ranges[i+o],p=this.ranges[i+l],g=d+u;if(s<=g){let v=u?s==d?-1:s==g?1:r:r,_=d+a+(v<0?0:p);if(n)return _;let b=s==(r<0?d:g)?null:L3t(i/3,s-d),j=s==d?lHe:s==g?oHe:mre;return(r<0?s!=d:s!=g)&&(j|=cHe),new bxe(_,j,b)}a+=p-u}return n?s+a:new bxe(s+a,0,null)}touches(s,r){let n=0,a=sTe(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 r6;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 kd.fromReplace(s,this.from,this.to,o)}invert(){return new Rx(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 R1(r.pos,n.pos,this.mark)}merge(s){return s instanceof R1&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new R1(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 R1(r.from,r.to,s.markFromJSON(r.mark))}}lh.jsonID("addMark",R1);class Rx extends lh{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 pn(ibe(r.content,a=>a.mark(this.mark.removeFromSet(a.marks)),s),r.openStart,r.openEnd);return kd.fromReplace(s,this.from,this.to,n)}invert(){return new R1(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 Rx(r.pos,n.pos,this.mark)}merge(s){return s instanceof Rx&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new Rx(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 Rx(r.from,r.to,s.markFromJSON(r.mark))}}lh.jsonID("removeMark",Rx);class F1 extends lh{constructor(s,r){super(),this.pos=s,this.mark=r}apply(s){let r=s.nodeAt(this.pos);if(!r)return kd.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return kd.fromReplace(s,this.pos,this.pos+1,new pn(Ar.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 mu(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 mu(r.from,r.to,r.gapFrom,r.gapTo,pn.fromJSON(s,r.slice),r.insert,!!r.structure)}}lh.jsonID("replaceAround",mu);function wxe(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 O3t(t,s,r,n){let a=[],o=[],l,i;t.doc.nodesBetween(s,r,(d,u,p)=>{if(!d.isInline)return;let g=d.marks;if(!n.isInSet(g)&&p.type.allowsMarkType(n.type)){let v=Math.max(u,s),_=Math.min(u+d.nodeSize,r),b=n.addToSet(g);for(let j=0;jt.step(d)),o.forEach(d=>t.step(d))}function R3t(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 Joe){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 Rx(l.from,l.to,l.style)))}function obe(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 F3t(t,s,r){return(s==0||t.canReplace(s,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function bM(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--)j||n.index(b)>0?(j=!0,p=Ar.from(n.node(b).copy(p)),g++):d--;let v=Ar.empty,_=0;for(let b=o,j=!1;b>r;b--)j||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=Ar.from(r[l].type.create(r[l].attrs,n))}let a=s.start,o=s.end;t.step(new mu(a,o,a,o,new pn(n,0,0),r.length,!0))}function U3t(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)&&V3t(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&&uHe(t,l,i,o),obe(t,t.mapping.slice(o).map(i,1),n,void 0,u===null);let p=t.mapping.slice(o),g=p.map(i,1),v=p.map(i+l.nodeSize,1);return t.step(new mu(g,v,g+1,v-1,new pn(Ar.from(n.create(d,null,l.marks)),0,0),1,!0)),u===!0&&dHe(t,l,i,o),!1}})}function dHe(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 uHe(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 V3t(t,s,r){let n=t.resolve(s),a=n.index();return n.parent.canReplaceWith(a,a+1,r)}function H3t(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 mu(s,s+o.nodeSize,s+1,s+o.nodeSize-1,new pn(Ar.from(l),0,0),1,!0))}function D0(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 g=a.node(u),v=a.index(u);if(g.type.spec.isolating)return!1;let _=g.content.cutByIndex(v,g.childCount),b=n&&n[p+1];b&&(_=_.replaceChild(0,b.type.create(b.attrs)));let j=n&&n[p]||g;if(!g.canReplace(v+1,g.childCount)||!j.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 W3t(t,s,r=1,n){let a=t.doc.resolve(s),o=Ar.empty,l=Ar.empty;for(let i=a.depth,d=a.depth-r,u=r-1;i>d;i--,u--){o=Ar.from(a.node(i).copy(o));let p=n&&n[u];l=Ar.from(p?p.type.create(p.attrs,l):a.node(i).copy(l))}t.step(new ou(s,s,new pn(o.append(l),r,r),!0))}function H_(t,s){let r=t.resolve(s),n=r.index();return hHe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function G3t(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&&hHe(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 K3t(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",g=!!l.contentMatch.matchType(a);p&&!g?n=!1:!p&&g&&(n=!0)}let i=t.steps.length;if(n===!1){let p=t.doc.resolve(s+r);uHe(t,p.node(),p.before(),i)}l.inlineContent&&obe(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 ou(u,d.map(s+r,-1),pn.empty,!0)),n===!0){let p=t.doc.resolve(u);dHe(t,p.node(),p.before(),t.steps.length)}return t}function Z3t(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 g=u.contentMatchAt(d).findWrapping(a.firstChild.type);p=g&&u.canReplaceWith(d,d,g[0])}if(p)return i==0?n.pos:i<0?n.before(l+1):n.after(l+1)}return null}function tle(t,s,r=s,n=pn.empty){if(s==r&&!n.size)return null;let a=t.resolve(s),o=t.resolve(r);return pHe(a,o,n)?new ou(s,r,n):new Y3t(a,o,n).fit()}function pHe(t,s,r){return!r.openStart&&!r.openEnd&&t.start()==s.start()&&t.parent.canReplace(t.index(),s.index(),r.content)}class Y3t{constructor(s,r,n){this.$from=s,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Ar.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=Ar.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 pn(o,l,i);return s>-1?new mu(n.pos,s,this.$to.pos,this.$to.end(),d,r):d.size||n.pos!=this.$to.pos?new ou(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=ome(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,g=null;if(r==1&&(l?u.matchType(l.type)||(g=u.fillBefore(Ar.from(l),!1)):o&&d.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:i,parent:o,inject:g};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=ome(s,r);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new pn(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=ome(s,r);if(a.childCount<=1&&r>0){let o=s.size-r<=r+a.size;this.unplaced=new pn(ME(s,r-1,1),r-1,o?r-1:n)}else this.unplaced=new pn(ME(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 j=0;j1||d==0||j.content.size)&&(g=w,p.push(fHe(j.mark(v.allowedMarks(j.marks)),u==1?d:0,u==i.childCount?_:-1)))}let b=u==i.childCount;b||(_=-1),this.placed=TE(this.placed,r,Ar.from(p)),this.frontier[r].match=g,b&&_<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let j=0,w=i;j<_;j++){let N=w.lastChild;this.frontier.push({type:N.type,match:N.contentMatchAt(N.childCount)}),w=N.content}this.unplaced=b?s==0?pn.empty:new pn(ME(l.content,s-1,1),s-1,_<0?l.openEnd:s-1):new pn(ME(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||!lme(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=lme(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=TE(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=TE(this.placed,this.depth,Ar.from(s.create(r,n))),this.frontier.push({type:s,match:s.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Ar.empty,!0);r.childCount&&(this.placed=TE(this.placed,this.frontier.length,r))}}function ME(t,s,r){return s==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(ME(t.firstChild.content,s-1,r)))}function TE(t,s,r){return s==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(TE(t.lastChild.content,s-1,r)))}function ome(t,s){for(let r=0;r1&&(n=n.replaceChild(0,fHe(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(Ar.empty,!0)))),t.copy(n)}function lme(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&&!X3t(r,o.content,l)?i:null}function X3t(t,s,r){for(let n=r;n0;v--,_--){let b=a.node(v).type.spec;if(b.defining||b.definingAsContext||b.isolating)break;l.indexOf(v)>-1?i=v:a.before(v)==_&&l.splice(1,0,-v)}let d=l.indexOf(i),u=[],p=n.openStart;for(let v=n.content,_=0;;_++){let b=v.firstChild;if(u.push(b),_==n.openStart)break;v=b.content}for(let v=p-1;v>=0;v--){let _=u[v],b=Q3t(_.type);if(b&&!_.sameMarkup(a.node(Math.abs(i)-1)))p=v;else if(b||!_.type.isTextblock)break}for(let v=n.openStart;v>=0;v--){let _=(v+p+1)%(n.openStart+1),b=u[_];if(b)for(let j=0;j=0&&(t.replace(s,r,n),!(t.steps.length>g));v--){let _=l[v];_<0||(s=a.before(_),r=o.after(_))}}function gHe(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(Ar.empty,!0))}return t}function eMt(t,s,r,n){if(!n.isInline&&s==r&&t.doc.resolve(s).parent.content.size){let a=Z3t(t.doc,s,n.type);a!=null&&(s=r=a)}t.replaceRange(s,r,new pn(Ar.from(n),0,0))}function tMt(t,s,r){let n=t.doc.resolve(s),a=t.doc.resolve(r),o=xHe(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 xHe(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 I5 extends lh{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 kd.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 kd.fromReplace(s,this.pos,this.pos+1,new pn(Ar.from(a),0,r.isLeaf?0:1))}getMap(){return op.empty}invert(s){return new I5(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 I5(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 I5(r.pos,r.attr,r.value)}}lh.jsonID("attr",I5);class n6 extends lh{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 kd.ok(n)}getMap(){return op.empty}invert(s){return new n6(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 n6(r.attr,r.value)}}lh.jsonID("docAttr",n6);let _3=class extends Error{};_3=function t(s){let r=Error.call(this,s);return r.__proto__=t.prototype,r};_3.prototype=Object.create(Error.prototype);_3.prototype.constructor=_3;_3.prototype.name="TransformError";class cbe{constructor(s){this.doc=s,this.steps=[],this.docs=[],this.mapping=new r6}get before(){return this.docs.length?this.docs[0]:this.doc}step(s){let r=this.maybeStep(s);if(r.failed)throw new _3(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=pn.empty){let a=tle(this.doc,s,r,n);return a&&this.step(a),this}replaceWith(s,r,n){return this.replace(s,r,new pn(Ar.from(n),0,0))}delete(s,r){return this.replace(s,r,pn.empty)}insert(s,r){return this.replaceWith(s,s,r)}replaceRange(s,r,n){return J3t(this,s,r,n),this}replaceRangeWith(s,r,n){return eMt(this,s,r,n),this}deleteRange(s,r){return tMt(this,s,r),this}lift(s,r){return z3t(this,s,r),this}join(s,r=1){return K3t(this,s,r),this}wrap(s,r){return q3t(this,s,r),this}setBlockType(s,r=s,n,a=null){return U3t(this,s,r,n,a),this}setNodeMarkup(s,r,n=null,a){return H3t(this,s,r,n,a),this}setNodeAttribute(s,r,n){return this.step(new I5(s,r,n)),this}setDocAttribute(s,r){return this.step(new n6(s,r)),this}addNodeMark(s,r){return this.step(new F1(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 ml)r.isInSet(n.marks)&&this.step(new DN(s,r));else{let a=n.marks,o,l=[];for(;o=r.isInSet(a);)l.push(new DN(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 W3t(this,s,r,n),this}addMark(s,r,n){return O3t(this,s,r,n),this}removeMark(s,r,n){return R3t(this,s,r,n),this}clearIncompatible(s,r,n){return obe(this,s,r,n),this}}const cme=Object.create(null);class ni{constructor(s,r,n){this.$anchor=s,this.$head=r,this.ranges=n||[new yHe(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?_4(s.node(0),s.node(o),s.before(o+1),s.index(o),r,n):_4(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 yp(s.node(0))}static atStart(s){return _4(s,s,0,0,1)||new yp(s)}static atEnd(s){return _4(s,s,s.content.size,s.childCount,-1)||new yp(s)}static fromJSON(s,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=cme[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 cme)throw new RangeError("Duplicate use of selection JSON ID "+s);return cme[s]=r,r.prototype.jsonID=s,r}getBookmark(){return $a.between(this.$anchor,this.$head).getBookmark()}}ni.prototype.visible=!0;class yHe{constructor(s,r){this.$from=s,this.$to=r}}let nTe=!1;function aTe(t){!nTe&&!t.parent.inlineContent&&(nTe=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class $a extends ni{constructor(s,r=s){aTe(s),aTe(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 $a(a.parent.inlineContent?a:n,n)}replace(s,r=pn.empty){if(super.replace(s,r),r==pn.empty){let n=this.$from.marksAcross(this.$to);n&&s.ensureMarks(n)}}eq(s){return s instanceof $a&&s.anchor==this.anchor&&s.head==this.head}getBookmark(){return new sle(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 $a(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&&Ia.isSelectable(i))return Ia.create(t,r-(a<0?i.nodeSize:0))}else{let d=_4(t,i,r+a,a<0?i.childCount:0,a,o);if(d)return d}r+=i.nodeSize*a}return null}function iTe(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 oTe=1,q8=2,lTe=4;class rMt extends cbe{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|=q8,this}ensureMarks(s){return ml.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&q8)>0}addStep(s,r){super.addStep(s,r),this.updated=this.updated&~q8,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)||ml.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|=lTe,this}get scrolledIntoView(){return(this.updated&lTe)>0}}function cTe(t,s){return!s||!t?t:t.bind(s)}class AE{constructor(s,r,n){this.name=s,this.init=cTe(r.init,n),this.apply=cTe(r.apply,n)}}const nMt=[new AE("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new AE("selection",{init(t,s){return t.selection||ni.atStart(s.doc)},apply(t){return t.selection}}),new AE("storedMarks",{init(t){return t.storedMarks||null},apply(t,s,r,n){return n.selection.$cursor?t.storedMarks:null}}),new AE("scrollToSelection",{init(){return 0},apply(t,s){return t.scrolledIntoView?s+1:s}})];class dme{constructor(s,r){this.schema=s,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=nMt.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 AE(n.key,n.spec.state,n))})}}class B4{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 dme(s.schema,s.plugins),o=new B4(a);return a.fields.forEach(l=>{if(l.name=="doc")o.doc=h_.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 vHe(t,s,r){for(let n in t){let a=t[n];a instanceof Function?a=a.bind(s):n=="handleDOMEvents"&&(a=vHe(a,s,{})),r[n]=a}return r}class Gd{constructor(s){this.spec=s,this.props={},s.props&&vHe(s.props,this,this.props),this.key=s.key?s.key.key:_He("plugin")}getState(s){return s[this.key]}}const ume=Object.create(null);function _He(t){return t in ume?t+"$"+ ++ume[t]:(ume[t]=0,t+"$")}class ch{constructor(s="key"){this.key=_He(s)}get(s){return s.config.pluginsByKey[this.key]}getState(s){return s[this.key]}}const Pu=function(t){for(var s=0;;s++)if(t=t.previousSibling,!t)return s},b3=function(t){let s=t.assignedSlot||t.parentNode;return s&&s.nodeType==11?s.host:s};let jxe=null;const t0=function(t,s,r){let n=jxe||(jxe=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,s||0),n},aMt=function(){jxe=null},ON=function(t,s,r,n){return r&&(dTe(t,s,r,n,-1)||dTe(t,s,r,n,1))},iMt=/^(img|br|input|textarea|hr)$/i;function dTe(t,s,r,n,a){for(var o;;){if(t==r&&s==n)return!0;if(s==(a<0?0:sf(t))){let l=t.parentNode;if(!l||l.nodeType!=1||LL(t)||iMt.test(t.nodeName)||t.contentEditable=="false")return!1;s=Pu(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?sf(t):0}else return!1}}function sf(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function oMt(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=sf(t)}else if(t.parentNode&&!LL(t))s=Pu(t),t=t.parentNode;else return null}}function lMt(t,s){for(;;){if(t.nodeType==3&&s2),Zp=w3||(ny?/Mac/.test(ny.platform):!1),jHe=ny?/Win/.test(ny.platform):!1,x0=/Android \d/.test(W_),DL=!!uTe&&"webkitFontSmoothing"in uTe.documentElement.style,hMt=DL?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function mMt(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 Vy(t,s){return typeof t=="number"?t:t[s]}function pMt(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 hTe(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=b3(l);continue}let i=l,d=i==o.body,u=d?mMt(o):pMt(i),p=0,g=0;if(s.topu.bottom-Vy(n,"bottom")&&(g=s.bottom-s.top>u.bottom-u.top?s.top+Vy(a,"top")-u.top:s.bottom-u.bottom+Vy(a,"bottom")),s.leftu.right-Vy(n,"right")&&(p=s.right-u.right+Vy(a,"right")),p||g)if(d)o.defaultView.scrollBy(p,g);else{let _=i.scrollLeft,b=i.scrollTop;g&&(i.scrollTop+=g),p&&(i.scrollLeft+=p);let j=i.scrollLeft-_,w=i.scrollTop-b;s={left:s.left-j,top:s.top-w,right:s.right-j,bottom:s.bottom-w}}let v=d?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(v))break;l=v=="absolute"?l.offsetParent:b3(l)}}function fMt(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:kHe(t.dom)}}function kHe(t){let s=[],r=t.ownerDocument;for(let n=t;n&&(s.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=b3(n));return s}function gMt({refDOM:t,refTop:s,stack:r}){let n=t?t.getBoundingClientRect().top:0;NHe(r,n==0?0:n-s)}function NHe(t,s){for(let r=0;r=i){l=Math.max(b.bottom,l),i=Math.min(b.top,i);let j=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=g+1)}}return!r&&d&&(r=d,a=u,n=0),r&&r.nodeType==3?yMt(r,a):!r||n&&r.nodeType==1?{node:t,offset:o}:SHe(r,a)}function yMt(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 ube(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 bMt(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 CHe(t,s,r){let n=t.childNodes.length;if(n&&r.tops.top&&a++}let u;DL&&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=bMt(t,n,a,s))}i==null&&(i=_Mt(t,l,s));let d=t.docView.nearestDesc(l,!0);return{pos:i,inside:d?d.posAtStart-d.border:-1}}function mTe(t){return t.top=0&&a==n.nodeValue.length?(d--,p=1):r<0?d--:u++,sE(t1(t0(n,d,u),p),p<0)}if(!t.state.doc.resolve(s-(o||0)).parent.inlineContent){if(o==null&&a&&(r<0||a==sf(n))){let d=n.childNodes[a-1];if(d.nodeType==1)return hme(d.getBoundingClientRect(),!1)}if(o==null&&a=0)}if(o==null&&a&&(r<0||a==sf(n))){let d=n.childNodes[a-1],u=d.nodeType==3?t0(d,sf(d)-(l?0:1)):d.nodeType==1&&(d.nodeName!="BR"||!d.nextSibling)?d:null;if(u)return sE(t1(u,1),!1)}if(o==null&&a=0)}function sE(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 hme(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 THe(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 kMt(t,s,r){let n=s.selection,a=r=="up"?n.$from:n.$to;return THe(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=MHe(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=t0(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 NMt=/[\u0590-\u08ac]/;function SMt(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?!NMt.test(n.parent.textContent)||!i.modify?r=="left"||r=="backward"?o:l:THe(t,s,()=>{let{focusNode:d,focusOffset:u,anchorNode:p,anchorOffset:g}=t.domSelectionRange(),v=i.caretBidiLevel;i.modify("move",r,"character");let _=n.depth?t.docView.domAfterPos(n.before()):t.dom,{focusNode:b,focusOffset:j}=t.domSelectionRange(),w=b&&!_.contains(b.nodeType==1?b:b.parentNode)||d==b&&u==j;try{i.collapse(p,g),d&&(d!=p||u!=g)&&i.extend&&i.extend(d,u)}catch{}return v!=null&&(i.caretBidiLevel=v),w}):n.pos==n.start()||n.pos==n.end()}let pTe=null,fTe=null,gTe=!1;function CMt(t,s,r){return pTe==s&&fTe==r?gTe:(pTe=s,fTe=r,gTe=r=="up"||r=="down"?kMt(t,s,r):SMt(t,s,r))}const yf=0,xTe=1,Ak=2,ay=3;class OL{constructor(s,r,n,a){this.parent=s,this.children=r,this.dom=n,this.contentDOM=a,this.dirty=yf,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;rPu(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 EHe){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 AHe&&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?Pu(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 g=i;g>0;g--){let v=this.children[g-1];if(v.size&&v.dom.parentNode==this.contentDOM&&!v.emptyChildAt(1)){a=Pu(v.dom)+1;break}s-=v.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?Ak:xTe,s==i&&r==d&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=ay:o.markDirty(s-i,r-i);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Ak:ay}n=l}this.dirty=Ak}markParentsDirty(){let s=1;for(let r=this.parent;r;r=r.parent,s++){let n=s==1?Ak:xTe;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==yf&&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 MMt extends OL{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 RN extends OL{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=sS.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new RN(s,r,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&ay||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(s){return this.dirty!=ay&&this.mark.eq(s)}markDirty(s,r){if(super.markDirty(s,r),this.dirty!=yf){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(o=Mxe(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,g=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:g}=sS.renderSpec(document,r.type.spec.toDOM(r),null,r.attrs));!g&&!r.isText&&p.nodeName!="BR"&&(p.hasAttribute("contenteditable")||(p.contentEditable="false"),r.type.spec.draggable&&(p.draggable=!0));let v=p;return p=LHe(p,n,r),u?d=new TMt(s,r,n,a,p,g||null,v,u,o,l+1):r.isText?new nle(s,r,n,a,p,v,o):new p_(s,r,n,a,p,g||null,v,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=()=>Ar.empty)}return s}matchesNode(s,r,n){return this.dirty==yf&&s.eq(this.node)&&$ne(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 EMt(this,l&&l.node,s);LMt(this.node,this.innerDeco,(u,p,g)=>{u.spec.marks?d.syncToMarks(u.spec.marks,n,s):u.type.side>=0&&!g&&d.syncToMarks(p==this.node.childCount?ml.none:this.node.child(p).marks,n,s),d.placeWidget(u,s,a)},(u,p,g,v)=>{d.syncToMarks(u.marks,n,s);let _;d.findNodeMatch(u,p,g,v)||i&&s.state.selection.from>a&&s.state.selection.to-1&&d.updateNodeAt(u,p,g,_,s)||d.updateNextNode(u,p,g,s,v,a)||d.addNode(u,p,g,s,a),a+=u.nodeSize}),d.syncToMarks([],n,s),this.node.isTextblock&&d.addTextblockHacks(),d.destroyRest(),(d.changed||this.dirty==Ak)&&(l&&this.protectLocalComposition(s,l),PHe(this.contentDOM,this.children,s),w3&&DMt(this.dom))}localCompositionInfo(s,r){let{from:n,to:a}=s.state.selection;if(!(s.state.selection instanceof $a)||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=OMt(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 MMt(this,o,r,a);s.input.compositionNodes.push(l),this.children=Mxe(this.children,n,n+a.length,s,l)}update(s,r,n,a){return this.dirty==ay||!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=yf}updateOuterDeco(s){if($ne(s,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=IHe(this.dom,this.nodeDOM,Cxe(this.outerDeco,this.node,r),Cxe(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 yTe(t,s,r,n,a){LHe(n,s,t);let o=new p_(void 0,t,s,r,n,n,n,a,0);return o.contentDOM&&o.updateChildren(a,0),o}class nle extends p_{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==ay||this.dirty!=yf&&!this.inParent()||!s.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=yf||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=yf,!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 nle(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=ay)}get domAtom(){return!1}isText(s){return this.node.text==s}}class EHe extends OL{parseRule(){return{ignore:!0}}matchesHack(s){return this.dirty==yf&&this.dom.nodeName==s}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class TMt extends p_{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==ay)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 PHe(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=RN.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 RN)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 IMt(t,s){return t.type.side-s.type.side}function LMt(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+v.nodeSize;if(v.isText){let w=b;l!w.inline):i.slice();n(v,j,s.forChild(o,v),_),o=b}}function DMt(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 OMt(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 Mxe(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 hbe(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(rle(r)){for(d=l;a&&!a.node;)a=a.parent;let g=a.node;if(a&&g.isAtom&&Ia.isSelectable(g)&&a.parent&&!(g.isInline&&cMt(r.focusNode,r.focusOffset,a.dom))){let v=a.posBefore;u=new Ia(l==v?i:n.resolve(v))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let g=l,v=l;for(let _=0;_{(r.anchorNode!=n||r.anchorOffset!=a)&&(s.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!DHe(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function FMt(t){let s=t.domSelection();if(!s)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?s.collapse(r.parentNode,Pu(r)+1):s.collapse(r,0),!n&&!t.state.selection.visible&&Dm&&m_<=11&&(r.disabled=!0,r.disabled=!1)}function OHe(t,s){if(s instanceof Ia){let r=t.docView.descAt(s.from);r!=t.lastSelectedViewDesc&&(jTe(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else jTe(t)}function jTe(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function mbe(t,s,r,n){return t.someProp("createSelectionBetween",a=>a(t,s,r))||$a.between(s,r,n)}function kTe(t){return t.editable&&!t.hasFocus()?!1:RHe(t)}function RHe(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 zMt(t){let s=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return ON(s.node,s.offset,r.anchorNode,r.anchorOffset)}function Txe(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 o1(t,s){return t.dispatch(t.state.tr.setSelection(s).scrollIntoView()),!0}function NTe(t,s,r){let n=t.state.selection;if(n instanceof $a)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 o1(t,new $a(n.$anchor,l))}else if(n.empty){if(t.endOfTextblock(s>0?"forward":"backward")){let a=Txe(t.state,s);return a&&a instanceof Ia?o1(t,a):!1}else if(!(Zp&&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?Ia.isSelectable(o)?o1(t,new Ia(s<0?t.state.doc.resolve(a.pos-o.nodeSize):a)):DL?o1(t,new $a(t.state.doc.resolve(s<0?i:i+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof Ia&&n.node.isInline)return o1(t,new $a(s>0?n.$to:n.$from));{let a=Txe(t.state,s);return a?o1(t,a):!1}}}function qne(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function tI(t,s){let r=t.pmViewDesc;return r&&r.size==0&&(s<0||t.nextSibling||t.nodeName!="BR")}function n4(t,s){return s<0?BMt(t):$Mt(t)}function BMt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a,o,l=!1;for(xf&&r.nodeType==1&&n0){if(r.nodeType!=1)break;{let i=r.childNodes[n-1];if(tI(i,-1))a=r,o=--n;else if(i.nodeType==3)r=i,n=r.nodeValue.length;else break}}else{if(FHe(r))break;{let i=r.previousSibling;for(;i&&tI(i,-1);)a=r.parentNode,o=Pu(i),i=i.previousSibling;if(i)r=i,n=qne(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}l?Axe(t,r,n):a&&Axe(t,a,o)}function $Mt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a=qne(r),o,l;for(;;)if(n{t.state==a&&O0(t)},50)}function STe(t,s){let r=t.state.doc.resolve(s);if(!(du||jHe)&&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 CTe(t,s,r){let n=t.state.selection;if(n instanceof $a&&!n.empty||r.indexOf("s")>-1||Zp&&r.indexOf("m")>-1)return!1;let{$from:a,$to:o}=n;if(!a.parent.inlineContent||t.endOfTextblock(s<0?"up":"down")){let l=Txe(t.state,s);if(l&&l instanceof Ia)return o1(t,l)}if(!a.parent.inlineContent){let l=s<0?a:o,i=n instanceof yp?ni.near(l,s):ni.findFrom(l,s);return i?o1(t,i):!1}return!1}function MTe(t,s){if(!(t.state.selection instanceof $a))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 TTe(t,s,r){t.domObserver.stop(),s.contentEditable=r,t.domObserver.start()}function VMt(t){if(!ih||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;TTe(t,n,"true"),setTimeout(()=>TTe(t,n,"false"),20)}return!1}function HMt(t){let s="";return t.ctrlKey&&(s+="c"),t.metaKey&&(s+="m"),t.altKey&&(s+="a"),t.shiftKey&&(s+="s"),s}function WMt(t,s){let r=s.keyCode,n=HMt(s);if(r==8||Zp&&r==72&&n=="c")return MTe(t,-1)||n4(t,-1);if(r==46&&!s.shiftKey||Zp&&r==68&&n=="c")return MTe(t,1)||n4(t,1);if(r==13||r==27)return!0;if(r==37||Zp&&r==66&&n=="c"){let a=r==37?STe(t,t.state.selection.from)=="ltr"?-1:1:-1;return NTe(t,a,n)||n4(t,a)}else if(r==39||Zp&&r==70&&n=="c"){let a=r==39?STe(t,t.state.selection.from)=="ltr"?1:-1:1;return NTe(t,a,n)||n4(t,a)}else{if(r==38||Zp&&r==80&&n=="c")return CTe(t,-1,n)||n4(t,-1);if(r==40||Zp&&r==78&&n=="c")return VMt(t)||CTe(t,1,n)||n4(t,1);if(n==(Zp?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function pbe(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")||sS.fromSchema(t.state.schema),i=VHe(),d=i.createElement("div");d.appendChild(l.serializeFragment(n,{document:i}));let u=d.firstChild,p,g=0;for(;u&&u.nodeType==1&&(p=UHe[u.nodeName.toLowerCase()]);){for(let _=p.length-1;_>=0;_--){let b=i.createElement(p[_]);for(;d.firstChild;)b.appendChild(d.firstChild);d.appendChild(b),g++}u=d.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${a} ${o}${g?` -${g}`:""} ${JSON.stringify(r)}`);let v=t.someProp("clipboardTextSerializer",_=>_(s,t))||s.content.textBetween(0,s.content.size,` `);return{dom:d,text:v,slice:s}}function zHe(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",v=>{s=v(s,o||n,t)}),o)return i=new pn(Ar.from(t.state.schema.text(s.replace(/\r\n?/g,` `))),0,0),t.someProp("transformPasted",v=>{i=v(i,t,!0)}),i;let g=t.someProp("clipboardTextParser",v=>v(s,a,n,t));if(g)i=g;else{let v=a.marks(),{schema:_}=t.state,b=sS.fromSchema(_);l=document.createElement("div"),s.split(/(?:\r\n?|\n)+/).forEach(j=>{let w=l.appendChild(document.createElement("p"));j&&w.appendChild(b.serializeNode(_.text(j,v)))})}}else t.someProp("transformPastedHTML",g=>{r=g(r,t)}),l=YMt(r),DL&&XMt(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 g=+p[3];g>0;g--){let v=l.firstChild;for(;v&&v.nodeType!=1;)v=v.nextSibling;if(!v)break;l=v}if(i||(i=(t.someProp("clipboardParser")||t.someProp("domParser")||QP.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(d||p),context:a,ruleFromNode(v){return v.nodeName=="BR"&&!v.nextSibling&&v.parentNode&&!GMt.test(v.parentNode.nodeName)?{ignore:!0}:null}})),p)i=QMt(ATe(i,+p[1],+p[2]),p[4]);else if(i=pn.maxOpen(KMt(i.content,a),!0),i.openStart||i.openEnd){let g=0,v=0;for(let _=i.content.firstChild;g{i=g(i,t,d)}),i}const GMt=/^(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 KMt(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&&$He(d,o,i,l[l.length-1],0))l[l.length-1]=u;else{l.length&&(l[l.length-1]=qHe(l[l.length-1],o.length));let p=BHe(i,d);l.push(p),a=a.matchType(p.type),o=d}}),l)return Ar.from(l)}return t}function BHe(t,s,r=0){for(let n=s.length-1;n>=r;n--)t=s[n].create(null,Ar.from(t));return t}function $He(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(Ar.empty,!0))),t.replaceChild(s<0?0:t.childCount-1,l.copy(i))}function ATe(t,s,r){return sr})),pme.createHTML(t)):t}function YMt(t){let s=/^(\s*]*>)*/.exec(t);s&&(t=t.slice(s[0].length));let r=VHe().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t),a;if((a=n&&UHe[n[1].toLowerCase()])&&(t=a.map(o=>"<"+o+">").join("")+t+a.map(o=>"").reverse().join("")),r.innerHTML=ZMt(t),a)for(let o=0;o=0;i-=2){let d=r.nodes[n[i]];if(!d||d.hasRequiredAttrs())break;a=Ar.from(d.create(n[i+1],a)),o++,l++}return new pn(a,o,l)}const Wh={},Gh={},JMt={touchstart:!0,touchmove:!0};class eTt{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 tTt(t){for(let s in Wh){let r=Wh[s];t.dom.addEventListener(s,t.input.eventHandlers[s]=n=>{rTt(t,n)&&!fbe(t,n)&&(t.editable||!(n.type in Gh))&&r(t,n)},JMt[s]?{passive:!0}:void 0)}ih&&t.dom.addEventListener("input",()=>null),Pxe(t)}function z1(t,s){t.input.lastSelectionOrigin=s,t.input.lastSelectionTime=Date.now()}function sTt(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 Pxe(t){t.someProp("handleDOMEvents",s=>{for(let r in s)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>fbe(t,n))})}function fbe(t,s){return t.someProp("handleDOMEvents",r=>{let n=r[s.type];return n?n(t,s)||s.defaultPrevented:!1})}function rTt(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 nTt(t,s){!fbe(t,s)&&Wh[s.type]&&(t.editable||!(s.type in Gh))&&Wh[s.type](t,s)}Gh.keydown=(t,s)=>{let r=s;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!WHe(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!(x0&&du&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),w3&&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,yk(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||WMt(t,r)?r.preventDefault():z1(t,"key")};Gh.keyup=(t,s)=>{s.keyCode==16&&(t.input.shiftKey=!1)};Gh.keypress=(t,s)=>{let r=s;if(WHe(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||Zp&&r.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof $a)||!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 ale(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 gbe(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 L5(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 iTt(t,s){if(s==-1)return!1;let r=t.state.doc.resolve(s),n=r.nodeAfter;return n&&n.isAtom&&Ia.isSelectable(n)?(L5(t,new Ia(r)),!0):!1}function oTt(t,s){if(s==-1)return!1;let r=t.state.selection,n,a;r instanceof Ia&&(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(Ia.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?(L5(t,Ia.create(t.state.doc,a)),!0):!1}function lTt(t,s,r,n,a){return gbe(t,"handleClickOn",s,r,n)||t.someProp("handleClick",o=>o(t,s,n))||(a?oTt(t,r):iTt(t,r))}function cTt(t,s,r,n){return gbe(t,"handleDoubleClickOn",s,r,n)||t.someProp("handleDoubleClick",a=>a(t,s,n))}function dTt(t,s,r,n){return gbe(t,"handleTripleClickOn",s,r,n)||t.someProp("handleTripleClick",a=>a(t,s,n))||uTt(t,r,n)}function uTt(t,s,r){if(r.button!=0)return!1;let n=t.state.doc;if(s==-1)return n.inlineContent?(L5(t,$a.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)L5(t,$a.create(n,i+1,i+1+l.content.size));else if(Ia.isSelectable(l))L5(t,Ia.create(n,i));else continue;return!0}}function xbe(t){return Une(t)}const HHe=Zp?"metaKey":"ctrlKey";Wh.mousedown=(t,s)=>{let r=s;t.input.shiftKey=r.shiftKey;let n=xbe(t),a=Date.now(),o="singleClick";a-t.input.lastClick.time<500&&aTt(r,t.input.lastClick)&&!r[HHe]&&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(ale(r));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new hTt(t,l,r,!!n)):(o=="doubleClick"?cTt:dTt)(t,l.pos,l.inside,r)?r.preventDefault():z1(t,"pointer"))};class hTt{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[HHe],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 Ia&&u.from<=l&&u.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&xf&&!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)),z1(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(()=>O0(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(ale(s))),this.updateAllowDefault(s),this.allowDefault||!r?z1(this.view,"pointer"):lTt(this.view,r.pos,r.inside,s,this.selectNode)?s.preventDefault():s.button==0&&(this.flushed||ih&&this.mightDrag&&!this.mightDrag.node.isAtom||du&&!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)?(L5(this.view,ni.near(this.view.state.doc.resolve(r.pos))),s.preventDefault()):z1(this.view,"pointer")}move(s){this.updateAllowDefault(s),z1(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)}}Wh.touchstart=t=>{t.input.lastTouch=Date.now(),xbe(t),z1(t,"pointer")};Wh.touchmove=t=>{t.input.lastTouch=Date.now(),z1(t,"pointer")};Wh.contextmenu=t=>xbe(t);function WHe(t,s){return t.composing?!0:ih&&Math.abs(s.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const mTt=x0?5e3:-1;Gh.compositionstart=Gh.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:s}=t,r=s.selection.$to;if(s.selection instanceof $a&&(s.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||du&&jHe&&pTt(t)))t.markCursor=t.state.storedMarks||r.marks(),Une(t,!0),t.markCursor=null;else if(Une(t,!s.selection.empty),xf&&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}GHe(t,mTt)};function pTt(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"}Gh.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++,GHe(t,20))};function GHe(t,s){clearTimeout(t.input.composingTimeout),s>-1&&(t.input.composingTimeout=setTimeout(()=>Une(t),s))}function KHe(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=gTt());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function fTt(t){let s=t.domSelectionRange();if(!s.focusNode)return null;let r=oMt(s.focusNode,s.focusOffset),n=lMt(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 gTt(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Une(t,s=!1){if(!(x0&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),KHe(t),s||t.docView&&t.docView.dirty){let r=hbe(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 xTt(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 a6=Dm&&m_<15||w3&&hMt<604;Wh.copy=Gh.cut=(t,s)=>{let r=s,n=t.state.selection,a=r.type=="cut";if(n.empty)return;let o=a6?null:r.clipboardData,l=n.content(),{dom:i,text:d}=pbe(t,l);o?(r.preventDefault(),o.clearData(),o.setData("text/html",i.innerHTML),o.setData("text/plain",d)):xTt(t,i),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function yTt(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?i6(t,n.value,null,a,s):i6(t,n.textContent,n.innerHTML,a,s)},50)}function i6(t,s,r,n,a){let o=zHe(t,s,r,n,t.state.selection.$from);if(t.someProp("handlePaste",d=>d(t,a,o||pn.empty)))return!0;if(!o)return!1;let l=yTt(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 ZHe(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," "):""}Gh.paste=(t,s)=>{let r=s;if(t.composing&&!x0)return;let n=a6?null:r.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&i6(t,ZHe(n),n.getData("text/html"),a,r)?r.preventDefault():vTt(t,r)};class YHe{constructor(s,r,n){this.slice=s,this.move=r,this.node=n}}const _Tt=Zp?"altKey":"ctrlKey";function XHe(t,s){let r=t.someProp("dragCopies",n=>!n(s));return r??!s[_Tt]}Wh.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(ale(r)),l;if(!(o&&o.pos>=a.from&&o.pos<=(a instanceof Ia?a.to-1:a.to))){if(n&&n.mightDrag)l=Ia.create(t.state.doc,n.mightDrag.pos);else if(r.target&&r.target.nodeType==1){let g=t.docView.nearestDesc(r.target,!0);g&&g.node.type.spec.draggable&&g!=t.docView&&(l=Ia.create(t.state.doc,g.posBefore))}}let i=(l||t.state.selection).content(),{dom:d,text:u,slice:p}=pbe(t,i);(!r.dataTransfer.files.length||!du||wHe>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(a6?"Text":"text/html",d.innerHTML),r.dataTransfer.effectAllowed="copyMove",a6||r.dataTransfer.setData("text/plain",u),t.dragging=new YHe(p,XHe(t,r),l)};Wh.dragend=t=>{let s=t.dragging;window.setTimeout(()=>{t.dragging==s&&(t.dragging=null)},50)};Gh.dragover=Gh.dragenter=(t,s)=>s.preventDefault();Gh.drop=(t,s)=>{try{bTt(t,s,t.dragging)}finally{t.dragging=null}};function bTt(t,s,r){if(!s.dataTransfer)return;let n=t.posAtCoords(ale(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=zHe(t,ZHe(s.dataTransfer),a6?null:s.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&XHe(t,s));if(t.someProp("handleDrop",_=>_(t,s,o||pn.empty,l))){s.preventDefault();return}if(!o)return;s.preventDefault();let i=o?mHe(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,g=d.doc;if(p?d.replaceRangeWith(u,u,o.content.firstChild):d.replaceRange(u,u,o),d.doc.eq(g))return;let v=d.doc.resolve(u);if(p&&Ia.isSelectable(o.content.firstChild)&&v.nodeAfter&&v.nodeAfter.sameMarkup(o.content.firstChild))d.setSelection(new Ia(v));else{let _=d.mapping.map(i);d.mapping.maps[d.mapping.maps.length-1].forEach((b,j,w,N)=>_=N),d.setSelection(mbe(t,v,d.doc.resolve(_)))}t.focus(),t.dispatch(d.setMeta("uiEvent","drop"))}Wh.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())&&O0(t)},20))};Wh.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)};Wh.beforeinput=(t,s)=>{if(du&&x0&&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,yk(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 Gh)Wh[t]=Gh[t];function o6(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 Vne{constructor(s,r){this.toDOM=s,this.spec=r||pN,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 Lh(o-n,o-n,this)}valid(){return!0}eq(s){return this==s||s instanceof Vne&&(this.spec.key&&this.spec.key==s.spec.key||this.toDOM==s.toDOM&&o6(this.spec,s.spec))}destroy(s){this.spec.destroy&&this.spec.destroy(s)}}class f_{constructor(s,r){this.attrs=s,this.spec=r||pN}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 Lh(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==Ku||s.maps.length==0?this:this.mapInner(s,r,0,0,n||pN)}mapInner(s,r,n,a,o){let l;for(let i=0;i{let u=d+n,p;if(p=JHe(r,i,u)){for(a||(a=this.children.slice());oi&&g.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 f_){let u=Math.max(o,d.from)-o,p=Math.min(l,d.to)-o;ua.map(s,r,pN));return x1.from(n)}forChild(s,r){if(r.isLeaf)return zc.empty;let n=[];for(let a=0;ar instanceof zc)?s:s.reduce((r,n)=>r.concat(n instanceof zc?n:n.members),[]))}}forEachSet(s){for(let r=0;r{let w=j-b-(_-v);for(let N=0;NC+p-g)continue;let A=i[N]+p-g;_>=A?i[N+1]=v<=A?-2:-1:v>=p&&w&&(i[N]+=w,i[N+1]+=w)}g+=w}),p=r.maps[u].map(p,-1)}let d=!1;for(let u=0;u=n.content.size){d=!0;continue}let v=r.map(t[u+1]+o,-1),_=v-a,{index:b,offset:j}=n.content.findIndex(g),w=n.maybeChild(b);if(w&&j==g&&j+w.nodeSize==_){let N=i[u+2].mapInner(r,w,p+1,t[u]+o+1,l);N!=Ku?(i[u]=g,i[u+1]=_,i[u+2]=N):(i[u+1]=-2,d=!0)}else d=!0}if(d){let u=jTt(i,t,s,r,a,o,l),p=Hne(u,n,0,l);s=p.local;for(let g=0;gr&&l.to{let u=JHe(t,i,d+r);if(u){o=!0;let p=Hne(u,i,r+d+1,n);p!=Ku&&a.push(d,d+i.nodeSize,p)}});let l=QHe(o?eWe(t):t,-r).sort(fN);for(let i=0;i0;)s++;t.splice(s,0,r)}function fme(t){let s=[];return t.someProp("decorations",r=>{let n=r(t.state);n&&n!=Ku&&s.push(n)}),t.cursorWrapper&&s.push(zc.create(t.state.doc,[t.cursorWrapper.deco])),x1.from(s)}const kTt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},NTt=Dm&&m_<=11;class STt{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 CTt{constructor(s,r){this.view=s,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new STt,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()}),NTt&&(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,kTt)),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(kTe(this.view)){if(this.suppressingSelectionUpdates)return O0(this.view);if(Dm&&m_<=11&&!this.view.state.selection.empty){let s=this.view.domSelectionRange();if(s.focusNode&&ON(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=b3(o))r.add(o);for(let o=s.anchorNode;o;o=b3(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)&&kTe(s)&&!this.ignoreSelectionChange(n),o=-1,l=-1,i=!1,d=[];if(s.editable)for(let p=0;pg.nodeName=="BR");if(p.length==2){let[g,v]=p;g.parentNode&&g.parentNode.parentNode==v.parentNode?v.remove():g.remove()}else{let{focusNode:g}=this.currentSelection;for(let v of p){let _=v.parentNode;_&&_.nodeName=="LI"&&(!g||ATt(s,g)!=_)&&v.remove()}}}else if((du||ih)&&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 g=p.nextSibling;g&&g.nodeType==1&&g.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),MTt(s)),this.handleDOMChange(o,l,i,d),s.docView&&s.docView.dirty?s.updateState(s.state):this.currentSelection.eq(n)||O0(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;w--){let N=n.childNodes[w-1],C=N.pmViewDesc;if(N.nodeName=="BR"&&!C){o=w;break}if(!C||C.size)break}let g=t.state.doc,v=t.someProp("domParser")||QP.fromSchema(t.state.schema),_=g.resolve(l),b=null,j=v.parse(n,{topNode:_.parent,topMatch:_.parent.contentMatchAt(_.index()),topOpen:!0,from:a,to:o,preserveWhitespace:_.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:PTt,context:_});if(u&&u[0].pos!=null){let w=u[0].pos,N=u[1]&&u[1].pos;N==null&&(N=w),b={anchor:w+l,head:N+l}}return{doc:j,sel:b,from:l,to:i}}function PTt(t){let s=t.pmViewDesc;if(s)return s.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ih&&/^(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||ih&&/^(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 ITt=/^(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 LTt(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=hbe(t,$);if(q&&!t.state.selection.eq(q)){if(du&&x0&&t.input.lastKeyCode===13&&Date.now()-100V(t,yk(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=ETt(t,s,r),p=t.state.doc,g=p.slice(u.from,u.to),v,_;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||x0)&&a.some($=>$.nodeType==1&&!ITt.test($.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",$=>$(t,yk(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(n&&d instanceof $a&&!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 $=OTe(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)),Dm&&m_<=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 j=u.doc.resolveNoCache(b.start-u.from),w=u.doc.resolveNoCache(b.endB-u.from),N=p.resolve(b.start),C=j.sameParent(w)&&j.parent.inlineContent&&N.end()>=b.endA;if((w3&&t.input.lastIOSEnter>Date.now()-225&&(!C||a.some($=>$.nodeName=="DIV"||$.nodeName=="P"))||!C&&j.pos$(t,yk(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&OTt(p,b.start,b.endA,j,w)&&t.someProp("handleKeyDown",$=>$(t,yk(8,"Backspace")))){x0&&du&&t.domObserver.suppressSelectionUpdates();return}du&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),x0&&!C&&j.start()!=w.start()&&w.parentOffset==0&&j.depth==w.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==b.endA&&(b.endB-=2,w=u.doc.resolveNoCache(b.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function($){return $(t,yk(13,"Enter"))})},20));let A=b.start,I=b.endA,L=$=>{let q=$||t.state.tr.replace(A,I,u.doc.slice(b.start-u.from,b.endB-u.from));if(u.sel){let U=OTe(t,q.doc,u.sel);U&&!(du&&t.composing&&U.empty&&(b.start!=b.endB||t.input.lastChromeDeleteO0(t),20));let $=L(t.state.tr.delete(A,I)),q=p.resolve(b.start).marksAcross(p.resolve(b.endA));q&&$.ensureMarks(q),t.dispatch($)}else if(b.endA==b.endB&&(R=DTt(j.parent.content.cut(j.parentOffset,w.parentOffset),N.parent.content.cut(N.parentOffset,b.endA-N.start())))){let $=L(t.state.tr);R.type=="add"?$.addMark(A,I,R.mark):$.removeMark(A,I,R.mark),t.dispatch($)}else if(j.parent.child(j.index()).isText&&j.index()==w.index()-(w.textOffset?0:1)){let $=j.parent.textBetween(j.parentOffset,w.parentOffset),q=()=>L(t.state.tr.insertText($,A,I));t.someProp("handleTextInput",U=>U(t,A,I,$,q))||t.dispatch(q())}else t.dispatch(L());else t.dispatch(L())}function OTe(t,s,r){return Math.max(r.anchor,r.head)>s.content.size?null:mbe(t,s.resolve(r.anchor),s.resolve(r.head))}function DTt(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||gme(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 RTt(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 tWe{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 eTt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(qTe),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=BTe(this),zTe(this),this.nodeViews=$Te(this),this.docView=yTe(this.state.doc,FTe(this),fme(this),this.dom,this),this.domObserver=new CTt(this,(n,a,o,l)=>LTt(this,n,a,o,l)),this.domObserver.start(),tTt(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&&Pxe(this);let r=this._props;this._props=s,s.plugins&&(s.plugins.forEach(qTe),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&&(KHe(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 _=$Te(this);zTt(_,this.nodeViews)&&(this.nodeViews=_,o=!0)}(i||r.handleDOMEvents!=this._props.handleDOMEvents)&&Pxe(this),this.editable=BTe(this),zTe(this);let d=fme(this),u=FTe(this),p=a.plugins!=s.plugins&&!a.doc.eq(s.doc)?"reset":s.scrollToSelection>a.scrollToSelection?"to selection":"preserve",g=o||!this.docView.matchesNode(s.doc,u,d);(g||!s.selection.eq(a.selection))&&(l=!0);let v=p=="preserve"&&l&&this.dom.style.overflowAnchor==null&&fMt(this);if(l){this.domObserver.stop();let _=g&&(Dm||du)&&!this.composing&&!a.selection.empty&&!s.selection.empty&&FTt(a.selection,s.selection);if(g){let b=du?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=fTt(this)),(o||!this.docView.update(s.doc,u,d,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=yTe(s.doc,u,d,this.dom,this)),b&&!this.trackWrites&&(_=!0)}_||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&zMt(this))?O0(this,_):(OHe(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():v&&gMt(v)}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 Ia){let r=this.docView.domAfterPos(this.state.selection.from);r.nodeType==1&&hTe(this,r.getBoundingClientRect(),s)}else hTe(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 YHe(s.slice,s.move,a<0?void 0:Ia.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 wMt(this,s)}coordsAtPos(s,r=1){return MHe(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 CMt(this,r||this.state,s)}pasteHTML(s,r){return i6(this,"",s,!1,r||new ClipboardEvent("paste"))}pasteText(s,r){return i6(this,s,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(s){return pbe(this,s)}destroy(){this.docView&&(sTt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],fme(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 nTt(this,s)}domSelectionRange(){let s=this.domSelection();return s?ih&&this.root.nodeType===11&&dMt(this.dom.ownerDocument)==this.dom&&TTt(this,s)||s:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}tWe.prototype.dispatch=function(t){let s=this._props.dispatchTransaction;s?s.call(this,t):this.updateState(this.state.apply(t))};function FTe(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"),[Lh.node(0,t.state.doc.content.size,s)]}function zTe(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:Lh.widget(t.state.selection.from,s,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function BTe(t){return!t.someProp("editable",s=>s(t.state)===!1)}function FTt(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 $Te(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 zTt(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 qTe(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 E_={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:"'"},Wne={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},BTt=typeof navigator<"u"&&/Mac/.test(navigator.platform),$Tt=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Iu=0;Iu<10;Iu++)E_[48+Iu]=E_[96+Iu]=String(Iu);for(var Iu=1;Iu<=24;Iu++)E_[Iu+111]="F"+Iu;for(var Iu=65;Iu<=90;Iu++)E_[Iu]=String.fromCharCode(Iu+32),Wne[Iu]=String.fromCharCode(Iu);for(var xme in E_)Wne.hasOwnProperty(xme)||(Wne[xme]=E_[xme]);function qTt(t){var s=BTt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||$Tt&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!s&&t.key||(t.shiftKey?Wne:E_)[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 UTt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),VTt=typeof navigator<"u"&&/Win/.test(navigator.platform);function HTt(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 sWe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const rWe=(t,s,r)=>{let n=sWe(t,r);if(!n)return!1;let a=wbe(n);if(!a){let l=n.blockRange(),i=l&&bM(l);return i==null?!1:(s&&s(t.tr.lift(l,i).scrollIntoView()),!0)}let o=a.nodeBefore;if(hWe(t,a,s,-1))return!0;if(n.parent.content.size==0&&(j3(o,"end")||Ia.isSelectable(o)))for(let l=n.depth;;l--){let i=tle(t.doc,n.before(l),n.after(l),pn.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},KTt=(t,s,r)=>{let n=sWe(t,r);if(!n)return!1;let a=wbe(n);return a?nWe(t,a,s):!1},ZTt=(t,s,r)=>{let n=iWe(t,r);if(!n)return!1;let a=jbe(n);return a?nWe(t,a,s):!1};function nWe(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=tle(t.doc,o,d,pn.empty);if(!u||u.from!=o||u instanceof ou&&u.slice.size>=d-o)return!1;if(r){let p=t.tr.step(u);p.setSelection($a.create(p.doc,o)),r(p.scrollIntoView())}return!0}function j3(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 aWe=(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=wbe(n)}let l=o&&o.nodeBefore;return!l||!Ia.isSelectable(l)?!1:(s&&s(t.tr.setSelection(Ia.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function wbe(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 iWe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("forward",t):r.parentOffset{let n=iWe(t,r);if(!n)return!1;let a=jbe(n);if(!a)return!1;let o=a.nodeAfter;if(hWe(t,a,s,1))return!0;if(n.parent.content.size==0&&(j3(o,"start")||Ia.isSelectable(o))){let l=tle(t.doc,n.before(),n.after(),pn.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 Ia,a;if(n){if(r.node.isTextblock||!H_(t.doc,r.from))return!1;a=r.from}else if(a=ele(t.doc,r.from,-1),a==null)return!1;if(s){let o=t.tr.join(a);n&&o.setSelection(Ia.create(o.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),s(o.scrollIntoView())}return!0},XTt=(t,s)=>{let r=t.selection,n;if(r instanceof Ia){if(r.node.isTextblock||!H_(t.doc,r.to))return!1;n=r.to}else if(n=ele(t.doc,r.to,1),n==null)return!1;return s&&s(t.tr.join(n).scrollIntoView()),!0},QTt=(t,s)=>{let{$from:r,$to:n}=t.selection,a=r.blockRange(n),o=a&&bM(a);return o==null?!1:(s&&s(t.tr.lift(a,o).scrollIntoView()),!0)},cWe=(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 kbe(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=kbe(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},dWe=(t,s)=>{let r=t.selection,{$from:n,$to:a}=r;if(r instanceof yp||n.parent.inlineContent||a.parent.inlineContent)return!1;let o=kbe(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(D0(t.doc,o))return s&&s(t.tr.split(o).scrollIntoView()),!0}let n=r.blockRange(),a=n&&bM(n);return a==null?!1:(s&&s(t.tr.lift(n,a).scrollIntoView()),!0)};function eAt(t){return(s,r)=>{let{$from:n,$to:a}=s.selection;if(s.selection instanceof Ia&&s.selection.node.isBlock)return!n.parentOffset||!D0(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=kbe(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 $a||s.selection instanceof yp)&&p.deleteSelection();let g=p.mapping.map(n.pos),v=D0(p.doc,g,o.length,o);if(v||(o[0]=i?{type:i}:null,v=D0(p.doc,g,o.length,o)),!v)return!1;if(p.split(g,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 tAt=eAt(),sAt=(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(Ia.create(t.doc,a))),!0)};function rAt(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||H_(t.doc,s.pos))?!1:(r&&r(t.tr.join(s.pos).scrollIntoView()),!0)}function hWe(t,s,r,n){let a=s.nodeBefore,o=s.nodeAfter,l,i,d=a.type.spec.isolating||o.type.spec.isolating;if(!d&&rAt(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=Ar.empty;for(let N=l.length-1;N>=0;N--)b=Ar.from(l[N].create(null,b));b=Ar.from(a.copy(b));let j=t.tr.step(new mu(s.pos-1,_,s.pos,_,new pn(b,1,0),l.length,!0)),w=j.doc.resolve(_+2*l.length);w.nodeAfter&&w.nodeAfter.type==a.type&&H_(j.doc,w.pos)&&j.join(w.pos),r(j.scrollIntoView())}return!0}let p=o.type.spec.isolating||n>0&&d?null:ni.findFrom(s,1),g=p&&p.$from.blockRange(p.$to),v=g&&bM(g);if(v!=null&&v>=s.depth)return r&&r(t.tr.lift(g,v).scrollIntoView()),!0;if(u&&j3(o,"start",!0)&&j3(a,"end")){let _=a,b=[];for(;b.push(_),!_.isTextblock;)_=_.lastChild;let j=o,w=1;for(;!j.isTextblock;j=j.firstChild)w++;if(_.canReplace(_.childCount,_.childCount,j.content)){if(r){let N=Ar.empty;for(let A=b.length-1;A>=0;A--)N=Ar.from(b[A].copy(N));let C=t.tr.step(new mu(s.pos-b.length,s.pos+o.nodeSize,s.pos+w,s.pos+o.nodeSize-w,new pn(N,b.length,0),0,!0));r(C.scrollIntoView())}return!0}}return!1}function mWe(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($a.create(s.doc,t<0?a.start(o):a.end(o)))),!0):!1}}const nAt=mWe(-1),aAt=mWe(1);function iAt(t,s=null){return function(r,n){let{$from:a,$to:o}=r.selection,l=a.blockRange(o),i=l&&lbe(l,t,s);return i?(n&&n(r.tr.wrap(l,i).scrollIntoView()),!0):!1}}function UTe(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),g=p.index();a=p.parent.canReplaceWith(g,g+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 zne(d,d,s.depth),s.endIndex=0;p--)o=Ar.from(r[p].type.create(r[p].attrs,o));t.step(new mu(s.start-(n?2:0),s.end,s.start,s.end,new pn(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?uAt(s,r,t,o):hAt(s,r,o):!0:!1}}function uAt(t,s,r,n){let a=t.tr,o=n.end,l=n.$to.end(n.depth);oj;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?Ar.empty:Ar.from(a))))return!1;let g=o.pos,v=g+l.nodeSize;return n.step(new mu(g-(i?1:0),v+(d?1:0),g+1,v-1,new pn((i?Ar.empty:Ar.from(a.copy(Ar.empty))).append(d?Ar.empty:Ar.from(a.copy(Ar.empty))),i?0:1,d?0:1),i?0:1)),s(n.scrollIntoView()),!0}function mAt(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=Ar.from(u?t.create():null),g=new pn(Ar.from(t.create(null,Ar.from(i.type.create(null,p)))),u?3:1,0),v=o.start,_=o.end;r(s.tr.step(new mu(v-(u?3:1),_,v,_,g,1,!0)).scrollIntoView())}return!0}}function ile(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 ole{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 g=d(...p)(l);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(o),g}]))}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(v=>v===!0)),g={...Object.fromEntries(Object.entries(n).map(([v,_])=>[v,(...j)=>{const w=this.buildProps(u,r),N=_(...j)(w);return i.push(N),g}])),run:p};return g}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:ile({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 pAt=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 Jn(t,s,r){return t.config[s]===void 0&&t.parent?Jn(t.parent,s,r):typeof t.config[s]=="function"?t.config[s].bind({...r,parent:t.parent?Jn(t.parent,s,r):null}):t.config[s]}function lle(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 pWe(t){const s=[],{nodeExtensions:r,markExtensions:n}=lle(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=Jn(l,"addGlobalAttributes",i);if(!d)return;d().forEach(p=>{p.types.forEach(g=>{Object.entries(p.attributes).forEach(([v,_])=>{s.push({type:g,name:v,attribute:{...o,..._}})})})})}),a.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage},d=Jn(l,"addAttributes",i);if(!d)return;const u=d();Object.entries(u).forEach(([p,g])=>{const v={...o,...g};typeof(v==null?void 0:v.default)=="function"&&(v.default=v.default()),v!=null&&v.isRequired&&(v==null?void 0:v.default)===void 0&&delete v.default,s.push({type:l.name,name:p,attribute:v})})}),s}function gu(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 Mc(...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[g,v]=p.split(":").map(_=>_.trim());u.set(g,v)}),i.forEach(p=>{const[g,v]=p.split(":").map(_=>_.trim());u.set(g,v)}),n[a]=Array.from(u.entries()).map(([p,g])=>`${p}: ${g}`).join("; ")}else n[a]=o}),n},{})}function Ixe(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)=>Mc(r,n),{})}function fWe(t){return typeof t=="function"}function qi(t,s=void 0,...r){return fWe(t)?s?t.bind(s)(...r):t(...r):t}function fAt(t={}){return Object.keys(t).length===0&&t.constructor===Object}function gAt(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function VTe(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):gAt(r.getAttribute(l.name));return i==null?o:{...o,[l.name]:i}},{});return{...n,...a}}}}function HTe(t){return Object.fromEntries(Object.entries(t).filter(([s,r])=>s==="attrs"&&fAt(r)?!1:r!=null))}function xAt(t,s){var r;const n=pWe(t),{nodeExtensions:a,markExtensions:o}=lle(t),l=(r=a.find(u=>Jn(u,"topNode")))===null||r===void 0?void 0:r.name,i=Object.fromEntries(a.map(u=>{const p=n.filter(N=>N.type===u.name),g={name:u.name,options:u.options,storage:u.storage,editor:s},v=t.reduce((N,C)=>{const A=Jn(C,"extendNodeSchema",g);return{...N,...A?A(u):{}}},{}),_=HTe({...v,content:qi(Jn(u,"content",g)),marks:qi(Jn(u,"marks",g)),group:qi(Jn(u,"group",g)),inline:qi(Jn(u,"inline",g)),atom:qi(Jn(u,"atom",g)),selectable:qi(Jn(u,"selectable",g)),draggable:qi(Jn(u,"draggable",g)),code:qi(Jn(u,"code",g)),whitespace:qi(Jn(u,"whitespace",g)),linebreakReplacement:qi(Jn(u,"linebreakReplacement",g)),defining:qi(Jn(u,"defining",g)),isolating:qi(Jn(u,"isolating",g)),attrs:Object.fromEntries(p.map(N=>{var C;return[N.name,{default:(C=N==null?void 0:N.attribute)===null||C===void 0?void 0:C.default}]}))}),b=qi(Jn(u,"parseHTML",g));b&&(_.parseDOM=b.map(N=>VTe(N,p)));const j=Jn(u,"renderHTML",g);j&&(_.toDOM=N=>j({node:N,HTMLAttributes:Ixe(N,p)}));const w=Jn(u,"renderText",g);return w&&(_.toText=w),[u.name,_]})),d=Object.fromEntries(o.map(u=>{const p=n.filter(w=>w.type===u.name),g={name:u.name,options:u.options,storage:u.storage,editor:s},v=t.reduce((w,N)=>{const C=Jn(N,"extendMarkSchema",g);return{...w,...C?C(u):{}}},{}),_=HTe({...v,inclusive:qi(Jn(u,"inclusive",g)),excludes:qi(Jn(u,"excludes",g)),group:qi(Jn(u,"group",g)),spanning:qi(Jn(u,"spanning",g)),code:qi(Jn(u,"code",g)),attrs:Object.fromEntries(p.map(w=>{var N;return[w.name,{default:(N=w==null?void 0:w.attribute)===null||N===void 0?void 0:N.default}]}))}),b=qi(Jn(u,"parseHTML",g));b&&(_.parseDOM=b.map(w=>VTe(w,p)));const j=Jn(u,"renderHTML",g);return j&&(_.toDOM=w=>j({mark:w,HTMLAttributes:Ixe(w,p)})),[u.name,_]}));return new sHe({topNode:l,nodes:i,marks:d})}function vme(t,s){return s.nodes[t]||s.marks[t]||null}function WTe(t,s){return Array.isArray(s)?s.some(r=>(typeof r=="string"?r:r.name)===t.name):s}function Sbe(t,s){const r=sS.fromSchema(s).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(r),a.innerHTML}const yAt=(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 Cbe(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class cle{constructor(s){this.find=s.find,this.handler=s.handler}}const vAt=(t,s)=>{if(Cbe(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 U8(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(v=>v.type.spec.code))return!1;let p=!1;const g=yAt(u)+o;return l.forEach(v=>{if(p)return;const _=vAt(g,v.find);if(!_)return;const b=d.state.tr,j=ile({state:d.state,transaction:b}),w={from:n-(_[0].length-o.length),to:a},{commands:N,chain:C,can:A}=new ole({editor:r,state:j});v.handler({state:j,range:w,match:_,commands:N,chain:C,can:A})===null||!b.steps.length||(b.setMeta(i,{transform:b,from:n,to:a,text:o}),d.dispatch(b),p=!0)}),p}function _At(t){const{editor:s,rules:r}=t,n=new Gd({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=Sbe(Ar.from(p),l.schema);const{from:g}=d,v=g+p.length;U8({editor:s,from:g,to:v,text:p,rules:r,plugin:n})}),a.selectionSet||a.docChanged?null:o}},props:{handleTextInput(a,o,l,i){return U8({editor:s,from:o,to:l,text:i,rules:r,plugin:n})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:o}=a.state.selection;o&&U8({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?U8({editor:s,from:l.pos,to:l.pos,text:` `,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function bAt(t){return Object.prototype.toString.call(t).slice(8,-1)}function V8(t){return bAt(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function dle(t,s){const r={...t};return V8(t)&&V8(s)&&Object.keys(s).forEach(n=>{V8(s[n])&&V8(t[n])?r[n]=dle(t[n],s[n]):r[n]=s[n]}),r}class iy{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=qi(Jn(this,"addOptions",{name:this.name}))),this.storage=qi(Jn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new iy(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>dle(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new iy(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=qi(Jn(r,"addOptions",{name:r.name})),r.storage=qi(Jn(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 wAt(t){return typeof t=="number"}class jAt{constructor(s){this.find=s.find,this.handler=s.handler}}const kAt=(t,s,r)=>{if(Cbe(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 NAt(t){const{editor:s,state:r,from:n,to:a,rule:o,pasteEvent:l,dropEvent:i}=t,{commands:d,chain:u,can:p}=new ole({editor:s,state:r}),g=[];return r.doc.nodesBetween(n,a,(_,b)=>{if(!_.isTextblock||_.type.spec.code)return;const j=Math.max(n,b),w=Math.min(a,b+_.content.size),N=_.textBetween(j-b,w-b,void 0,"");kAt(N,o.find,l).forEach(A=>{if(A.index===void 0)return;const I=j+A.index+1,L=I+A[0].length,R={from:r.tr.mapping.map(I),to:r.tr.mapping.map(L)},$=o.handler({state:r,range:R,match:A,commands:d,chain:u,can:p,pasteEvent:l,dropEvent:i});g.push($)})}),g.every(_=>_!==null)}let H8=null;const SAt=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 CAt(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:g,to:v,rule:_,pasteEvt:b})=>{const j=p.tr,w=ile({state:p,transaction:j});if(!(!NAt({editor:s,state:w,from:Math.max(g-1,0),to:v.b-1,rule:_,pasteEvent:b,dropEvent:i})||!j.steps.length)){try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,j}};return r.map(p=>new Gd({view(g){const v=b=>{var j;n=!((j=g.dom.parentElement)===null||j===void 0)&&j.contains(b.target)?g.dom.parentElement:null,n&&(H8=s)},_=()=>{H8&&(H8=null)};return window.addEventListener("dragstart",v),window.addEventListener("dragend",_),{destroy(){window.removeEventListener("dragstart",v),window.removeEventListener("dragend",_)}}},props:{handleDOMEvents:{drop:(g,v)=>{if(o=n===g.dom.parentElement,i=v,!o){const _=H8;_!=null&&_.isEditable&&setTimeout(()=>{const b=_.state.selection;b&&_.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(g,v)=>{var _;const b=(_=v.clipboardData)===null||_===void 0?void 0:_.getData("text/html");return l=v,a=!!(b!=null&&b.includes("data-pm-slice")),!1}}},appendTransaction:(g,v,_)=>{const b=g[0],j=b.getMeta("uiEvent")==="paste"&&!a,w=b.getMeta("uiEvent")==="drop"&&!o,N=b.getMeta("applyPasteRules"),C=!!N;if(!j&&!w&&!C)return;if(C){let{text:L}=N;typeof L=="string"?L=L:L=Sbe(Ar.from(L),_.schema);const{from:R}=N,$=R+L.length,q=SAt(L);return d({rule:p,state:_,from:R,to:{b:$},pasteEvt:q})}const A=v.doc.content.findDiffStart(_.doc.content),I=v.doc.content.findDiffEnd(_.doc.content);if(!(!wAt(A)||!I||A===I.b))return d({rule:p,state:_,from:A,to:I,pasteEvt:l})}}))}function MAt(t){const s=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(s))}class $4{constructor(s,r){this.splittableMarks=[],this.editor=r,this.extensions=$4.resolve(s),this.schema=xAt(this.extensions,r),this.setupExtensions()}static resolve(s){const r=$4.sort($4.flatten(s)),n=MAt(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=Jn(r,"addExtensions",n);return a?[r,...this.flatten(a())]:r}).flat(10)}static sort(s){return s.sort((n,a)=>{const o=Jn(n,"priority")||100,l=Jn(a,"priority")||100;return o>l?-1:o{const n={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:vme(r.name,this.schema)},a=Jn(r,"addCommands",n);return a?{...s,...a()}:s},{})}get plugins(){const{editor:s}=this,r=$4.sort([...this.extensions].reverse()),n=[],a=[],o=r.map(l=>{const i={name:l.name,options:l.options,storage:l.storage,editor:s,type:vme(l.name,this.schema)},d=[],u=Jn(l,"addKeyboardShortcuts",i);let p={};if(l.type==="mark"&&Jn(l,"exitable",i)&&(p.ArrowRight=()=>iy.handleExit({editor:s,mark:l})),u){const j=Object.fromEntries(Object.entries(u()).map(([w,N])=>[w,()=>N({editor:s})]));p={...p,...j}}const g=GTt(p);d.push(g);const v=Jn(l,"addInputRules",i);WTe(l,s.options.enableInputRules)&&v&&n.push(...v());const _=Jn(l,"addPasteRules",i);WTe(l,s.options.enablePasteRules)&&_&&a.push(..._());const b=Jn(l,"addProseMirrorPlugins",i);if(b){const j=b();d.push(...j)}return d}).flat();return[_At({editor:s,rules:n}),...CAt({editor:s,rules:a}),...o]}get attributes(){return pWe(this.extensions)}get nodeViews(){const{editor:s}=this,{nodeExtensions:r}=lle(this.extensions);return Object.fromEntries(r.filter(n=>!!Jn(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:gu(n.name,this.schema)},l=Jn(n,"addNodeView",o);if(!l)return[];const i=(d,u,p,g,v)=>{const _=Ixe(d,a);return l()({node:d,view:u,getPos:p,decorations:g,innerDecorations:v,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:vme(s.name,this.schema)};s.type==="mark"&&(!((r=qi(Jn(s,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(s.name);const a=Jn(s,"onBeforeCreate",n),o=Jn(s,"onCreate",n),l=Jn(s,"onUpdate",n),i=Jn(s,"onSelectionUpdate",n),d=Jn(s,"onTransaction",n),u=Jn(s,"onFocus",n),p=Jn(s,"onBlur",n),g=Jn(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),g&&this.editor.on("destroy",g)})}}class $u{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=qi(Jn(this,"addOptions",{name:this.name}))),this.storage=qi(Jn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new $u(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>dle(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new $u({...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=qi(Jn(r,"addOptions",{name:r.name})),r.storage=qi(Jn(r,"addStorage",{name:r.name,options:r.options})),r}}function gWe(t,s,r){const{from:n,to:a}=s,{blockSeparator:o=` `,textSerializers:l={}}=r||{};let i="";return t.nodesBetween(n,a,(d,u,p,g)=>{var v;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:g,range:s})),!1;d.isText&&(i+=(v=d==null?void 0:d.text)===null||v===void 0?void 0:v.slice(Math.max(n,u)-u,a-u))}),i}function xWe(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,s])=>s.spec.toText).map(([s,r])=>[s,r.spec.toText]))}const TAt=$u.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Gd({key:new ch("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=xWe(r);return gWe(n,{from:l,to:i},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:d})}}})]}}),AAt=()=>({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),EAt=(t=!1)=>({commands:s})=>s.setContent("",t),PAt=()=>({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,g=u.resolve(p.map(d)),v=u.resolve(p.map(d+i.nodeSize)),_=g.blockRange(v);if(!_)return;const b=bM(_);if(i.type.isTextblock){const{defaultType:j}=g.parent.contentMatchAt(g.index());s.setNodeMarkup(_.start,j)}(b||b===0)&&s.lift(_,b)})}),!0},IAt=t=>s=>t(s),LAt=()=>({state:t,dispatch:s})=>dWe(t,s),DAt=(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 $a(n.doc.resolve(Math.max(l-1,0)))),!0},OAt=()=>({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},RAt=t=>({tr:s,state:r,dispatch:n})=>{const a=gu(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},FAt=t=>({tr:s,dispatch:r})=>{const{from:n,to:a}=t;return r&&s.delete(n,a),!0},zAt=()=>({state:t,dispatch:s})=>bbe(t,s),BAt=()=>({commands:t})=>t.keyboardShortcut("Enter"),$At=()=>({state:t,dispatch:s})=>JTt(t,s);function Gne(t,s,r={strict:!0}){const n=Object.keys(s);return n.length?n.every(a=>r.strict?s[a]===t[a]:Cbe(s[a])?s[a].test(t[a]):s[a]===t[a]):!0}function yWe(t,s,r={}){return t.find(n=>n.type===s&&Gne(Object.fromEntries(Object.keys(r).map(a=>[a,n.attrs[a]])),r))}function GTe(t,s,r={}){return!!yWe(t,s,r)}function Mbe(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),!yWe([...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&>e([...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=G_(t,n.schema),{doc:l,selection:i}=r,{$from:d,from:u,to:p}=i;if(a){const g=Mbe(d,o,s);if(g&&g.from<=u&&g.to>=p){const v=$a.create(l,g.from,g.to);r.setSelection(v)}}return!0},UAt=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=()=>{(Tbe()||VAt())&&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&&!vWe(r.state.selection))return l(),!0;const i=_We(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},WAt=(t,s)=>r=>t.every((n,a)=>s(n,{...r,index:a})),GAt=(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 W8(t){const s=`${t}`,r=new window.DOMParser().parseFromString(s,"text/html").body;return bWe(r)}function l6(t,s,r){if(t instanceof h_||t instanceof Ar)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 Ar.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),l6("",s,r)}if(a){if(r.errorOnInvalidContent){let l=!1,i="";const d=new sHe({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?QP.fromSchema(d).parseSlice(W8(t),r.parseOptions):QP.fromSchema(d).parse(W8(t),r.parseOptions),r.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const o=QP.fromSchema(s);return r.slice?o.parseSlice(W8(t),r.parseOptions).content:o.parse(W8(t),r.parseOptions)}return l6("",s,r)}function KAt(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 ZAt=t=>!("type"in t),YAt=(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=w=>{o.emit("contentError",{editor:o,error:w,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{l6(s,o.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(w){d(w)}try{i=l6(s,o.schema,{parseOptions:u,errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})}catch(w){return d(w),!1}let{from:p,to:g}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},v=!0,_=!0;if((ZAt(i)?i:[i]).forEach(w=>{w.check(),v=v?w.isText&&w.marks.length===0:!1,_=_?w.isBlock:!1}),p===g&&_){const{parent:w}=n.doc.resolve(p);w.isTextblock&&!w.type.spec.code&&!w.childCount&&(p-=1,g+=1)}let j;if(v){if(Array.isArray(s))j=s.map(w=>w.text||"").join("");else if(s instanceof Ar){let w="";s.forEach(N=>{N.text&&(w+=N.text)}),j=w}else typeof s=="object"&&s&&s.text?j=s.text:j=s;n.insertText(j,p,g)}else j=i,n.replaceWith(p,g,j);r.updateSelection&&KAt(n,n.steps.length-1,-1),r.applyInputRules&&n.setMeta("applyInputRules",{from:p,text:j}),r.applyPasteRules&&n.setMeta("applyPasteRules",{from:p,text:j})}return!0},XAt=()=>({state:t,dispatch:s})=>YTt(t,s),QAt=()=>({state:t,dispatch:s})=>XTt(t,s),JAt=()=>({state:t,dispatch:s})=>rWe(t,s),eEt=()=>({state:t,dispatch:s})=>oWe(t,s),tEt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=ele(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},sEt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=ele(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},rEt=()=>({state:t,dispatch:s})=>KTt(t,s),nEt=()=>({state:t,dispatch:s})=>ZTt(t,s);function wWe(){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 c6(t,s,r={}){const{from:n,to:a,empty:o}=t.selection,l=s?gu(s,t.schema):null,i=[];t.doc.nodesBetween(n,a,(g,v)=>{if(g.isText)return;const _=Math.max(n,v),b=Math.min(a,v+g.nodeSize);i.push({node:g,from:_,to:b})});const d=a-n,u=i.filter(g=>l?l.name===g.node.type.name:!0).filter(g=>Gne(g.node.attrs,r,{strict:!1}));return o?!!u.length:u.reduce((g,v)=>g+v.to-v.from,0)>=d}const oEt=(t,s={})=>({state:r,dispatch:n})=>{const a=gu(t,r.schema);return c6(r,a,s)?QTt(r,n):!1},lEt=()=>({state:t,dispatch:s})=>uWe(t,s),cEt=t=>({state:s,dispatch:r})=>{const n=gu(t,s.schema);return dAt(n)(s,r)},dEt=()=>({state:t,dispatch:s})=>cWe(t,s);function ule(t,s){return s.nodes[t]?"node":s.marks[t]?"mark":null}function KTe(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 uEt=(t,s)=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=ule(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=gu(t,n.schema)),i==="mark"&&(l=G_(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,KTe(u.attrs,s)),l&&u.marks.length&&u.marks.forEach(g=>{l===g.type&&r.addMark(p,p+u.nodeSize,l.create(KTe(g.attrs,s)))})})}),!0):!1},hEt=()=>({tr:t,dispatch:s})=>(s&&t.scrollIntoView(),!0),mEt=()=>({tr:t,dispatch:s})=>{if(s){const r=new yp(t.doc);t.setSelection(r)}return!0},pEt=()=>({state:t,dispatch:s})=>aWe(t,s),fEt=()=>({state:t,dispatch:s})=>lWe(t,s),gEt=()=>({state:t,dispatch:s})=>sAt(t,s),xEt=()=>({state:t,dispatch:s})=>aAt(t,s),yEt=()=>({state:t,dispatch:s})=>nAt(t,s);function Lxe(t,s,r={},n={}){return l6(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 g=Lxe(t,a.schema,r,{errorOnInvalidContent:(d=n.errorOnInvalidContent)!==null&&d!==void 0?d:a.options.enableContentCheck});return l&&o.replaceWith(0,p.content.size,g).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 jWe(t,s){const r=G_(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 _Et(t,s){const r=new cbe(t);return s.forEach(n=>{n.steps.forEach(a=>{r.step(a)})}),r}function bEt(t){for(let s=0;s{r(a)&&n.push({node:a,pos:o})}),n}function kWe(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 Abe(t){return s=>kWe(s.$from,t)}function jEt(t,s){const r={from:0,to:t.content.size};return gWe(t,r,s)}function kEt(t,s){const r=gu(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 NWe(t,s){const r=ule(typeof s=="string"?s:s.name,t.schema);return r==="node"?kEt(t,s):r==="mark"?jWe(t,s):{}}function NEt(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 SEt(t){const s=NEt(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 CEt(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),g=s.invert().map(u,-1),v=s.invert().map(p);n.push({oldRange:{from:g,to:v},newRange:{from:u,to:p}})})}),SEt(n)}function Ebe(t,s,r){const n=[];return t===s?r.resolve(t).marks().forEach(a=>{const o=r.resolve(t),l=Mbe(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 pre(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 Dxe(t,s,r={}){const{empty:n,ranges:a}=t.selection,o=s?G_(s,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(g=>o?o.name===g.type.name:!0).find(g=>Gne(g.attrs,r,{strict:!1}));let l=0;const i=[];if(a.forEach(({$from:g,$to:v})=>{const _=g.pos,b=v.pos;t.doc.nodesBetween(_,b,(j,w)=>{if(!j.isText&&!j.marks.length)return;const N=Math.max(_,w),C=Math.min(b,w+j.nodeSize),A=C-N;l+=A,i.push(...j.marks.map(I=>({mark:I,from:N,to:C})))})}),l===0)return!1;const d=i.filter(g=>o?o.name===g.mark.type.name:!0).filter(g=>Gne(g.mark.attrs,r,{strict:!1})).reduce((g,v)=>g+v.to-v.from,0),u=i.filter(g=>o?g.mark.type!==o&&g.mark.type.excludes(o):!0).reduce((g,v)=>g+v.to-v.from,0);return(d>0?d+u:d)>=l}function MEt(t,s,r={}){if(!s)return c6(t,null,r)||Dxe(t,null,r);const n=ule(s,t.schema);return n==="node"?c6(t,s,r):n==="mark"?Dxe(t,s,r):!1}function ZTe(t,s){const{nodeExtensions:r}=lle(s),n=r.find(l=>l.name===t);if(!n)return!1;const a={name:n.name,options:n.options,storage:n.storage},o=qi(Jn(n,"group",a));return typeof o!="string"?!1:o.split(" ").includes("list")}function Pbe(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&&(Pbe(o,{ignoreWhitespace:r,checkChildren:s})||(a=!1))}),a}return!1}function TEt(t){return t instanceof Ia}function AEt(t,s,r){var n;const{selection:a}=s;let o=null;if(vWe(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,g,v)=>{if(u)return!1;if(p.isInline){const _=!v||v.type.allowsMarkType(r),b=!!r.isInSet(p.marks)||!p.marks.some(j=>j.type.excludes(r));u=_&&b}return!u}),u})}const EEt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{const{selection:o}=r,{empty:l,ranges:i}=o,d=G_(t,n.schema);if(a)if(l){const u=jWe(n,d);r.addStoredMark(d.create({...u,...s}))}else i.forEach(u=>{const p=u.$from.pos,g=u.$to.pos;n.doc.nodesBetween(p,g,(v,_)=>{const b=Math.max(_,p),j=Math.min(_+v.nodeSize,g);v.marks.find(N=>N.type===d)?v.marks.forEach(N=>{d===N.type&&r.addMark(b,j,d.create({...N.attrs,...s}))}):r.addMark(b,j,d.create(s))})});return AEt(n,r,d)},PEt=(t,s)=>({tr:r})=>(r.setMeta(t,s),!0),IEt=(t,s={})=>({state:r,dispatch:n,chain:a})=>{const o=gu(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})=>UTe(o,{...l,...s})(r)?!0:i.clearNodes()).command(({state:i})=>UTe(o,{...l,...s})(i,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},LEt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,a=Pk(t,0,n.content.size),o=Ia.create(n,a);s.setSelection(o)}return!0},DEt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,{from:a,to:o}=typeof t=="number"?{from:t,to:t}:t,l=$a.atStart(n).from,i=$a.atEnd(n).to,d=Pk(a,l,i),u=Pk(o,l,i),p=$a.create(n,d,u);s.setSelection(p)}return!0},OEt=t=>({state:s,dispatch:r})=>{const n=gu(t,s.schema);return mAt(n)(s,r)};function YTe(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 REt=({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=pre(u,i.node().type.name,i.node().attrs);if(o instanceof Ia&&o.node.isBlock)return!i.parentOffset||!D0(l,i.pos)?!1:(n&&(t&&YTe(r,a.extensionManager.splittableMarks),s.split(i.pos).scrollIntoView()),!0);if(!i.parent.isBlock)return!1;const g=d.parentOffset===d.parent.content.size,v=i.depth===0?void 0:bEt(i.node(-1).contentMatchAt(i.indexAfter(-1)));let _=g&&v?[{type:v,attrs:p}]:void 0,b=D0(s.doc,s.mapping.map(i.pos),1,_);if(!_&&!b&&D0(s.doc,s.mapping.map(i.pos),1,v?[{type:v}]:void 0)&&(b=!0,_=v?[{type:v,attrs:p}]:void 0),n){if(b&&(o instanceof $a&&s.deleteSelection(),s.split(s.mapping.map(i.pos),1,_),v&&!g&&!i.parentOffset&&i.parent.type!==v)){const j=s.mapping.map(i.before()),w=s.doc.resolve(j);i.node(-1).canReplaceWith(w.index(),w.index()+1,v)&&s.setNodeMarkup(s.mapping.map(i.before()),v)}t&&YTe(r,a.extensionManager.splittableMarks),s.scrollIntoView()}return b},FEt=(t,s={})=>({tr:r,state:n,dispatch:a,editor:o})=>{var l;const i=gu(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 g=d.node(-1);if(g.type!==i)return!1;const v=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 N=Ar.empty;const C=d.index(-1)?1:d.index(-2)?2:3;for(let q=d.depth-C;q>=d.depth-3;q-=1)N=Ar.from(d.node(q).copy(N));const A=d.indexAfter(-1){if($>-1)return!1;q.isTextblock&&q.content.size===0&&($=U+1)}),$>-1&&r.setSelection($a.near(r.doc.resolve($))),r.scrollIntoView()}return!0}const _=u.pos===d.end()?g.contentMatchAt(0).defaultType:null,b={...pre(v,g.type.name,g.attrs),...s},j={...pre(v,d.node().type.name,d.node().attrs),...s};r.delete(d.pos,u.pos);const w=_?[{type:i,attrs:b},{type:_,attrs:j}]:[{type:i,attrs:b}];if(!D0(r.doc,d.pos,2))return!1;if(a){const{selection:N,storedMarks:C}=n,{splittableMarks:A}=o.extensionManager,I=C||N.$to.parentOffset&&N.$from.marks();if(r.split(d.pos,2,w).scrollIntoView(),!I||!a)return!0;const L=I.filter(R=>A.includes(R.type.name));r.ensureMarks(L)}return!0},_me=(t,s)=>{const r=Abe(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)&&H_(t.doc,r.pos)&&t.join(r.pos),!0},bme=(t,s)=>{const r=Abe(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)&&H_(t.doc,n)&&t.join(n),!0},zEt=(t,s,r,n={})=>({editor:a,tr:o,state:l,dispatch:i,chain:d,commands:u,can:p})=>{const{extensions:g,splittableMarks:v}=a.extensionManager,_=gu(t,l.schema),b=gu(s,l.schema),{selection:j,storedMarks:w}=l,{$from:N,$to:C}=j,A=N.blockRange(C),I=w||j.$to.parentOffset&&j.$from.marks();if(!A)return!1;const L=Abe(R=>ZTe(R.type.name,g))(j);if(A.depth>=1&&L&&A.depth-L.depth<=1){if(L.node.type===_)return u.liftListItem(b);if(ZTe(L.node.type.name,g)&&_.validContent(L.node.content)&&i)return d().command(()=>(o.setNodeMarkup(L.pos,_),!0)).command(()=>_me(o,_)).command(()=>bme(o,_)).run()}return!r||!I||!i?d().command(()=>p().wrapInList(_,n)?!0:u.clearNodes()).wrapInList(_,n).command(()=>_me(o,_)).command(()=>bme(o,_)).run():d().command(()=>{const R=p().wrapInList(_,n),$=I.filter(q=>v.includes(q.type.name));return o.ensureMarks($),R?!0:u.clearNodes()}).wrapInList(_,n).command(()=>_me(o,_)).command(()=>bme(o,_)).run()},BEt=(t,s={},r={})=>({state:n,commands:a})=>{const{extendEmptyMarkRange:o=!1}=r,l=G_(t,n.schema);return Dxe(n,l,s)?a.unsetMark(l,{extendEmptyMarkRange:o}):a.setMark(l,s)},$Et=(t,s,r={})=>({state:n,commands:a})=>{const o=gu(t,n.schema),l=gu(s,n.schema),i=c6(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})},qEt=(t,s={})=>({state:r,commands:n})=>{const a=gu(t,r.schema);return c6(r,a,s)?n.lift(a):n.wrapIn(a,s)},UEt=()=>({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},VEt=()=>({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},HEt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{var o;const{extendEmptyMarkRange:l=!1}=s,{selection:i}=r,d=G_(t,n.schema),{$from:u,empty:p,ranges:g}=i;if(!a)return!0;if(p&&l){let{from:v,to:_}=i;const b=(o=u.marks().find(w=>w.type===d))===null||o===void 0?void 0:o.attrs,j=Mbe(u,d,b);j&&(v=j.from,_=j.to),r.removeMark(v,_,d)}else g.forEach(v=>{r.removeMark(v.$from.pos,v.$to.pos,d)});return r.removeStoredMark(d),!0},WEt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=ule(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=gu(t,n.schema)),i==="mark"&&(l=G_(t,n.schema)),a&&r.selection.ranges.forEach(d=>{const u=d.$from.pos,p=d.$to.pos;let g,v,_,b;r.selection.empty?n.doc.nodesBetween(u,p,(j,w)=>{o&&o===j.type&&(_=Math.max(w,u),b=Math.min(w+j.nodeSize,p),g=w,v=j)}):n.doc.nodesBetween(u,p,(j,w)=>{w=u&&w<=p&&(o&&o===j.type&&r.setNodeMarkup(w,void 0,{...j.attrs,...s}),l&&j.marks.length&&j.marks.forEach(N=>{if(l===N.type){const C=Math.max(w,u),A=Math.min(w+j.nodeSize,p);r.addMark(C,A,l.create({...N.attrs,...s}))}}))}),v&&(g!==void 0&&r.setNodeMarkup(g,void 0,{...v.attrs,...s}),l&&v.marks.length&&v.marks.forEach(j=>{l===j.type&&r.addMark(_,b,l.create({...j.attrs,...s}))}))}),!0):!1},GEt=(t,s={})=>({state:r,dispatch:n})=>{const a=gu(t,r.schema);return iAt(a,s)(r,n)},KEt=(t,s={})=>({state:r,dispatch:n})=>{const a=gu(t,r.schema);return oAt(a,s)(r,n)};var ZEt=Object.freeze({__proto__:null,blur:AAt,clearContent:EAt,clearNodes:PAt,command:IAt,createParagraphNear:LAt,cut:DAt,deleteCurrentNode:OAt,deleteNode:RAt,deleteRange:FAt,deleteSelection:zAt,enter:BAt,exitCode:$At,extendMarkRange:qAt,first:UAt,focus:HAt,forEach:WAt,insertContent:GAt,insertContentAt:YAt,joinBackward:JAt,joinDown:QAt,joinForward:eEt,joinItemBackward:tEt,joinItemForward:sEt,joinTextblockBackward:rEt,joinTextblockForward:nEt,joinUp:XAt,keyboardShortcut:iEt,lift:oEt,liftEmptyBlock:lEt,liftListItem:cEt,newlineInCode:dEt,resetAttributes:uEt,scrollIntoView:hEt,selectAll:mEt,selectNodeBackward:pEt,selectNodeForward:fEt,selectParentNode:gEt,selectTextblockEnd:xEt,selectTextblockStart:yEt,setContent:vEt,setMark:EEt,setMeta:PEt,setNode:IEt,setNodeSelection:LEt,setTextSelection:DEt,sinkListItem:OEt,splitBlock:REt,splitListItem:FEt,toggleList:zEt,toggleMark:BEt,toggleNode:$Et,toggleWrap:qEt,undoInputRule:UEt,unsetAllMarks:VEt,unsetMark:HEt,updateAttributes:WEt,wrapIn:GEt,wrapInList:KEt});const YEt=$u.create({name:"commands",addCommands(){return{...ZEt}}}),XEt=$u.create({name:"drop",addProseMirrorPlugins(){return[new Gd({key:new ch("tiptapDrop"),props:{handleDrop:(t,s,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:s,slice:r,moved:n})}}})]}}),QEt=$u.create({name:"editable",addProseMirrorPlugins(){return[new Gd({key:new ch("editable"),props:{editable:()=>this.editor.options.editable}})]}}),JEt=new ch("focusEvents"),ePt=$u.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Gd({key:JEt,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}}}})]}}),tPt=$u.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:g}=d,{pos:v,parent:_}=g,b=g.parent.isTextblock&&v>0?i.doc.resolve(v-1):g,j=b.parent.type.spec.isolating,w=g.pos-g.parentOffset,N=j&&b.parent.childCount===1?w===g.pos:ni.atStart(u).from===v;return!p||!_.type.isTextblock||_.textContent.length||!N||N&&g.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 Tbe()||wWe()?o:a},addProseMirrorPlugins(){return[new Gd({key:new ch("clearDocument"),appendTransaction:(t,s,r)=>{if(t.some(j=>j.getMeta("composition")))return;const n=t.some(j=>j.docChanged)&&!s.doc.eq(r.doc),a=t.some(j=>j.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)||!Pbe(r.doc))return;const v=r.tr,_=ile({state:r,transaction:v}),{commands:b}=new ole({editor:this.editor,state:_});if(b.clearNodes(),!!v.steps.length)return v}})]}}),sPt=$u.create({name:"paste",addProseMirrorPlugins(){return[new Gd({key:new ch("tiptapPaste"),props:{handlePaste:(t,s,r)=>{this.editor.emit("paste",{editor:this.editor,event:s,slice:r})}}})]}}),rPt=$u.create({name:"tabindex",addProseMirrorPlugins(){return[new Gd({key:new ch("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class vk{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 vk(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 vk(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 vk(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 vk(i,this.editor,a,a?r:null);a&&(d.actualDepth=this.depth+1),s.push(new vk(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 nPt=`.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 iPt extends pAt{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(nPt,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=fWe(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?[QEt,TAt.configure({blockSeparator:(r=(s=this.options.coreExtensionOptions)===null||s===void 0?void 0:s.clipboardTextSerializer)===null||r===void 0?void 0:r.blockSeparator}),YEt,ePt,tPt,rPt,XEt,sPt].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 $4(a,this)}createCommandManager(){this.commandManager=new ole({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var s;let r;try{r=Lxe(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=Lxe(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=_We(r,this.options.autofocus);this.view=new tWe(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:B4.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 NWe(this.state,s)}isActive(s,r){const n=typeof s=="string"?s:null,a=typeof s=="string"?r:s;return MEt(this.state,n,a)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Sbe(this.state.doc.content,this.schema)}getText(s){const{blockSeparator:r=` `,textSerializers:n={}}=s||{};return jEt(this.state.doc,{blockSeparator:r,textSerializers:{...xWe(this.schema),...n}})}get isEmpty(){return Pbe(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 vk(r,this)}get $doc(){return this.$pos(0)}}function k3(t){return new cle({find:t.find,handler:({state:s,range:r,match:n})=>{const a=qi(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(Ebe(r.from,r.to,s.doc).filter(_=>_.mark.type.excluded.find(j=>j===t.type&&j!==_.mark.type)).filter(_=>_.to>u).length)return null;pr.from&&o.delete(r.from+d,u);const v=r.from+d+l.length;o.addMark(r.from+d,v,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}function SWe(t){return new cle({find:t.find,handler:({state:s,range:r,match:n})=>{const a=qi(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 g=n[0][n[0].length-1];o.insertText(g,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 Oxe(t){return new cle({find:t.find,handler:({state:s,range:r,match:n})=>{const a=s.doc.resolve(r.from),o=qi(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 d6(t){return new cle({find:t.find,handler:({state:s,range:r,match:n,chain:a})=>{const o=qi(t.getAttributes,void 0,n)||{},l=s.tr.delete(r.from,r.to),d=l.doc.resolve(r.from).blockRange(),u=d&&lbe(d,t.type,o);if(!u)return null;if(l.wrap(d,u),t.keepMarks&&t.editor){const{selection:g,storedMarks:v}=s,{splittableMarks:_}=t.editor.extensionManager,b=v||g.$to.parentOffset&&g.$from.marks();if(b){const j=b.filter(w=>_.includes(w.type.name));l.ensureMarks(j)}}if(t.keepAttributes){const g=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(g,o).run()}const p=l.doc.resolve(r.from-1).nodeBefore;p&&p.type===t.type&&H_(l.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,p))&&l.join(r.from-1)}})}let dh=class Rxe{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=qi(Jn(this,"addOptions",{name:this.name}))),this.storage=qi(Jn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new Rxe(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>dle(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new Rxe(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=qi(Jn(r,"addOptions",{name:r.name})),r.storage=qi(Jn(r,"addStorage",{name:r.name,options:r.options})),r}};function FN(t){return new jAt({find:t.find,handler:({state:s,range:r,match:n,pasteEvent:a})=>{const o=qi(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/),g=r.from+d.indexOf(i),v=g+i.length;if(Ebe(r.from,r.to,s.doc).filter(b=>b.mark.type.excluded.find(w=>w===t.type&&w!==b.mark.type)).filter(b=>b.to>g).length)return null;vr.from&&l.delete(r.from+p,g),u=r.from+p+i.length,l.addMark(r.from+p,u,t.type.create(o||{})),l.removeStoredMark(t.type)}}})}function oPt(t,s){const{selection:r}=t,{$from:n}=r;if(r instanceof Ia){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 lPt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var CWe={exports:{}},wme={};/** * @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 XTe;function cPt(){if(XTe)return wme;XTe=1;var t=ht;function s(g,v){return g===v&&(g!==0||1/g===1/v)||g!==g&&v!==v}var r=typeof Object.is=="function"?Object.is:s,n=t.useState,a=t.useEffect,o=t.useLayoutEffect,l=t.useDebugValue;function i(g,v){var _=v(),b=n({inst:{value:_,getSnapshot:v}}),j=b[0].inst,w=b[1];return o(function(){j.value=_,j.getSnapshot=v,d(j)&&w({inst:j})},[g,_,v]),a(function(){return d(j)&&w({inst:j}),g(function(){d(j)&&w({inst:j})})},[g]),l(_),_}function d(g){var v=g.getSnapshot;g=g.value;try{var _=v();return!r(g,_)}catch{return!0}}function u(g,v){return v()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:i;return wme.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,wme}CWe.exports=cPt();var Ibe=CWe.exports;const dPt=(...t)=>s=>{t.forEach(r=>{typeof r=="function"?r(s):r&&(r.current=s)})},uPt=({contentComponent:t})=>{const s=Ibe.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return ht.createElement(ht.Fragment,null,Object.values(s))};function hPt(){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]:Vve.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 mPt 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=hPt(),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(uPt,{contentComponent:s.contentComponent}))}}const pPt=S.forwardRef((t,s)=>{const r=ht.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ht.createElement(mPt,{key:r,innerRef:s,...t})}),MWe=ht.memo(pPt);var fPt=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},gPt=lPt(fPt),TWe={exports:{}},jme={};/** * @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 QTe;function xPt(){if(QTe)return jme;QTe=1;var t=ht,s=Ibe;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 jme.useSyncExternalStoreWithSelector=function(u,p,g,v,_){var b=o(null);if(b.current===null){var j={hasValue:!1,value:null};b.current=j}else j=b.current;b=i(function(){function N(R){if(!C){if(C=!0,A=R,R=v(R),_!==void 0&&j.hasValue){var $=j.value;if(_($,R))return I=$}return I=R}if($=I,n(A,R))return $;var q=v(R);return _!==void 0&&_($,q)?$:(A=R,I=q)}var C=!1,A,I,L=g===void 0?null:g;return[function(){return N(p())},L===null?void 0:function(){return N(L())}]},[p,g,v,_]);var w=a(u,b[0],b[1]);return l(function(){j.hasValue=!0,j.value=w},[w]),d(w),w},jme}TWe.exports=xPt();var yPt=TWe.exports;const vPt=typeof window<"u"?S.useLayoutEffect:S.useEffect;class _Pt{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 bPt(t){var s;const[r]=S.useState(()=>new _Pt(t.editor)),n=yPt.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(s=t.equalityFn)!==null&&s!==void 0?s:gPt);return vPt(()=>r.watch(t.editor),[t.editor,r]),S.useDebugValue(n),n}const wPt=!1,Fxe=typeof window>"u",jPt=Fxe||!!(typeof window<"u"&&window.next);class Lbe{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?Fxe||jPt?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 iPt(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?Lbe.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 AWe(t={},s=[]){const r=S.useRef(t);r.current=t;const[n]=S.useState(()=>new Lbe(r)),a=Ibe.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return S.useDebugValue(a),S.useEffect(n.onRender(s)),bPt({editor:a,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),a}const kPt=S.createContext({editor:null});kPt.Consumer;const NPt=S.createContext({onDragStart:void 0}),SPt=()=>S.useContext(NPt);ht.forwardRef((t,s)=>{const{onDragStart:r}=SPt(),n=t.as||"div";return ht.createElement(n,{...t,ref:s,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});const CPt=/^\s*>\s$/,MPt=dh.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",Mc(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[d6({find:CPt,type:this.type})]}}),TPt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,APt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,EPt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,PPt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,IPt=iy.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",Mc(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[k3({find:TPt,type:this.type}),k3({find:EPt,type:this.type})]},addPasteRules(){return[FN({find:APt,type:this.type}),FN({find:PPt,type:this.type})]}}),LPt="listItem",JTe="textStyle",eAe=/^\s*([-+*])\s$/,DPt=dh.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",Mc(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(LPt,this.editor.getAttributes(JTe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=d6({find:eAe,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=d6({find:eAe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(JTe),editor:this.editor})),[t]}}),OPt=/(^|[^`])`([^`]+)`(?!`)/,RPt=/(^|[^`])`([^`]+)`(?!`)/g,FPt=iy.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Mc(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[k3({find:OPt,type:this.type})]},addPasteRules(){return[FN({find:RPt,type:this.type})]}}),zPt=/^```([a-z]+)?[\s\n]$/,BPt=/^~~~([a-z]+)?[\s\n]$/,$Pt=dh.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",Mc(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[Oxe({find:zPt,type:this.type,getAttributes:t=>({language:t[1]})}),Oxe({find:BPt,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Gd({key:new ch("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($a.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),qPt=dh.create({name:"doc",topNode:!0,content:"block+"});function UPt(t={}){return new Gd({view(s){return new VPt(s,t)}})}class VPt{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 g=s.nodeBefore,v=s.nodeAfter;if(g||v){let _=this.editorView.nodeDOM(this.cursorPos-(g?g.nodeSize:0));if(_){let b=_.getBoundingClientRect(),j=g?b.bottom:b.top;g&&v&&(j=(j+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let w=this.width/2*i;n={left:b.left,right:b.right,top:j-w,bottom:j+w}}}}if(!n){let g=this.editorView.coordsAtPos(this.cursorPos),v=this.width/2*l;n={left:g.left-v,right:g.left+v,top:g.top,bottom:g.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 g=d.getBoundingClientRect(),v=g.width/d.offsetWidth,_=g.height/d.offsetHeight;u=g.left-d.scrollLeft*v,p=g.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=mHe(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 HPt=$u.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[UPt(this.options)]}});class Bc extends ni{constructor(s){super(s,s)}map(s,r){let n=s.resolve(r.map(this.head));return Bc.valid(n)?new Bc(n):ni.near(n)}content(){return pn.empty}eq(s){return s instanceof Bc&&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 Bc(s.resolve(r.pos))}getBookmark(){return new Dbe(this.anchor)}static valid(s){let r=s.parent;if(r.isTextblock||!WPt(s)||!GPt(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&&Bc.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(Bc.valid(d))return d}for(;;){let l=r>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!Ia.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(Bc.valid(i))return i}return null}}}Bc.prototype.visible=!1;Bc.findFrom=Bc.findGapCursorFrom;ni.jsonID("gapcursor",Bc);class Dbe{constructor(s){this.pos=s}map(s){return new Dbe(s.map(this.pos))}resolve(s){let r=s.resolve(this.pos);return Bc.valid(r)?new Bc(r):ni.near(r)}}function EWe(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function WPt(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||EWe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function GPt(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||EWe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function KPt(){return new Gd({props:{decorations:QPt,createSelectionBetween(t,s,r){return s.pos==r.pos&&Bc.valid(r)?new Bc(r):null},handleClick:YPt,handleKeyDown:ZPt,handleDOMEvents:{beforeinput:XPt}}})}const ZPt=_be({ArrowLeft:G8("horiz",-1),ArrowRight:G8("horiz",1),ArrowUp:G8("vert",-1),ArrowDown:G8("vert",1)});function G8(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 $a){if(!o.endOfTextblock(r)||i.depth==0)return!1;d=!1,i=n.doc.resolve(s>0?i.after():i.before())}let u=Bc.findGapCursorFrom(i,s,d);return u?(a&&a(n.tr.setSelection(new Bc(u))),!0):!1}}function YPt(t,s,r){if(!t||!t.editable)return!1;let n=t.state.doc.resolve(s);if(!Bc.valid(n))return!1;let a=t.posAtCoords({left:r.clientX,top:r.clientY});return a&&a.inside>-1&&Ia.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Bc(n))),!0)}function XPt(t,s){if(s.inputType!="insertCompositionText"||!(t.state.selection instanceof Bc))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=Ar.empty;for(let l=n.length-1;l>=0;l--)a=Ar.from(n[l].createAndFill(null,a));let o=t.state.tr.replace(r.pos,r.pos,new pn(a,0,0));return o.setSelection($a.near(o.doc.resolve(r.pos+1))),t.dispatch(o),!1}function QPt(t){if(!(t.selection instanceof Bc))return null;let s=document.createElement("div");return s.className="ProseMirror-gapcursor",zc.create(t.doc,[Lh.widget(t.selection.head,s,{key:"gapcursor"})])}const JPt=$u.create({name:"gapCursor",addProseMirrorPlugins(){return[KPt()]},extendNodeSchema(t){var s;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(s=qi(Jn(t,"allowGapCursor",r)))!==null&&s!==void 0?s:null}}}),eIt=dh.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",Mc(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 g=d.filter(v=>i.includes(v.type.name));u.ensureMarks(g)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),tIt=dh.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]}`,Mc(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=>Oxe({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var Kne=200,pu=function(){};pu.prototype.append=function(s){return s.length?(s=pu.from(s),!this.length&&s||s.length=r?pu.empty:this.sliceInner(Math.max(0,s),Math.min(this.length,r))};pu.prototype.get=function(s){if(!(s<0||s>=this.length))return this.getInner(s)};pu.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)};pu.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};pu.from=function(s){return s instanceof pu?s:s&&s.length?new PWe(s):pu.empty};var PWe=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<=Kne)return new s(this.values.concat(a.flatten()))},s.prototype.leafPrepend=function(a){if(this.length+a.length<=Kne)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}(pu);pu.empty=new PWe([]);var sIt=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}(pu);const rIt=500;class Mg{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((g,v)=>{if(!g.step){a||(a=this.remapping(n,v+1),o=a.maps.length),o--,p.push(g);return}if(a){p.push(new jx(g.map));let _=g.step.map(a.slice(o)),b;_&&l.maybeStep(_).doc&&(b=l.mapping.maps[l.mapping.maps.length-1],u.push(new jx(b,void 0,void 0,u.length+p.length))),o--,b&&a.appendMap(b,o)}else l.maybeStep(g.step);if(g.selection)return i=a?g.selection.map(a.slice(o)):g.selection,d=new Mg(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=nIt(i,u),l-=u),new Mg(i.append(o),l)}remapping(s,r){let n=new r6;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 Mg(this.items.append(s.map(r=>new jx(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(v=>{v.selection&&i--},a);let d=r;this.items.forEach(v=>{let _=o.getMirror(--d);if(_==null)return;l=Math.min(l,_);let b=o.maps[_];if(v.step){let j=s.steps[_].invert(s.docs[_]),w=v.selection&&v.selection.map(o.slice(d+1,_));w&&i++,n.push(new jx(b,j,w))}else n.push(new jx(b))},a);let u=[];for(let v=r;vrIt&&(g=g.compress(this.items.length-n.length)),g}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 g=new jx(u.invert(),d,p),v,_=a.length-1;(v=a.length&&a[_].merge(g))?a[_]=v:a.push(g)}}else l.map&&n--},this.items.length,0),new Mg(pu.from(a.reverse()),o)}}Mg.empty=new Mg(pu.empty,0);function nIt(t,s){let r;return t.forEach((n,a)=>{if(n.selection&&s--==0)return r=a,!1}),t.slice(r)}class jx{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 jx(r.getMap().invert(),r,this.selection)}}}class l1{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 iIt(t,s,r,n){let a=r.getMeta(gN),o;if(a)return a.historyState;r.getMeta(cIt)&&(t=new l1(t.done,t.undone,null,0,-1));let l=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(l&&l.getMeta(gN))return l.getMeta(gN).redo?new l1(t.done.addTransform(r,void 0,n,fre(s)),t.undone,tAe(r.mapping.maps),t.prevTime,t.prevComposition):new l1(t.done,t.undone.addTransform(r,void 0,n,fre(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||!oIt(r,t.prevRanges)),u=l?kme(t.prevRanges,r.mapping):tAe(r.mapping.maps);return new l1(t.done.addTransform(r,d?s.selection.getBookmark():void 0,n,fre(s)),Mg.empty,u,r.time,i??t.prevComposition)}else return(o=r.getMeta("rebased"))?new l1(t.done.rebased(r,o),t.undone.rebased(r,o),kme(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new l1(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),kme(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function oIt(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 tAe(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 kme(t,s){if(!t)return null;let r=[];for(let n=0;n{let a=gN.getState(r);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(n){let o=lIt(a,r,t);o&&n(s?o.scrollIntoView():o)}return!0}}const LWe=IWe(!1,!0),DWe=IWe(!0,!0),uIt=$u.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:s})=>LWe(t,s),redo:()=>({state:t,dispatch:s})=>DWe(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()}}}),hIt=dh.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Mc(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:s})=>{if(!oPt(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}):TEt(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($a.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(Ia.create(l.doc,u.pos)):l.setSelection($a.create(l.doc,u.pos));else{const g=(d=u.parent.type.contentMatch.defaultType)===null||d===void 0?void 0:d.create();g&&(l.insert(p,g),l.setSelection($a.create(l.doc,p+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[SWe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),mIt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,pIt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,fIt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,gIt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,xIt=iy.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",Mc(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[k3({find:mIt,type:this.type}),k3({find:fIt,type:this.type})]},addPasteRules(){return[FN({find:pIt,type:this.type}),FN({find:gIt,type:this.type})]}}),yIt=dh.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Mc(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",rAe="textStyle",nAe=/^(\d+)\.\s$/,_It=dh.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",Mc(this.options.HTMLAttributes,r),0]:["ol",Mc(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(rAe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=d6({find:nAe,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=d6({find:nAe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:s=>({start:+s[1],...this.editor.getAttributes(rAe)}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1],editor:this.editor})),[t]}}),bIt=dh.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Mc(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),wIt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,jIt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,kIt=iy.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",Mc(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[k3({find:wIt,type:this.type})]},addPasteRules(){return[FN({find:jIt,type:this.type})]}}),NIt=dh.create({name:"text",group:"inline"}),OWe=$u.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(IPt.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(MPt.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(DPt.configure(this.options.bulletList)),this.options.code!==!1&&t.push(FPt.configure(this.options.code)),this.options.codeBlock!==!1&&t.push($Pt.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(qPt.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(HPt.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(JPt.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(eIt.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(tIt.configure(this.options.heading)),this.options.history!==!1&&t.push(uIt.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(hIt.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(xIt.configure(this.options.italic)),this.options.listItem!==!1&&t.push(yIt.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(_It.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(bIt.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(kIt.configure(this.options.strike)),this.options.text!==!1&&t.push(NIt.configure(this.options.text)),t}}),SIt="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",CIt="ελ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",zxe="numeric",Bxe="ascii",$xe="alpha",sI="asciinumeric",EE="alphanumeric",qxe="domain",RWe="emoji",MIt="scheme",TIt="slashscheme",Sme="whitespace";function AIt(t,s){return t in s||(s[t]=[]),s[t]}function Ik(t,s,r){s[zxe]&&(s[sI]=!0,s[EE]=!0),s[Bxe]&&(s[sI]=!0,s[$xe]=!0),s[sI]&&(s[EE]=!0),s[$xe]&&(s[EE]=!0),s[EE]&&(s[qxe]=!0),s[RWe]&&(s[qxe]=!0);for(const n in s){const a=AIt(n,r);a.indexOf(t)<0&&a.push(t)}}function EIt(t,s){const r={};for(const n in s)s[n].indexOf(t)>=0&&(r[n]=!0);return r}function ym(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}ym.groups={};ym.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),Pc=(t,s,r,n,a)=>t.tr(s,r,n,a),aAe=(t,s,r,n,a)=>t.ts(s,r,n,a),Hr=(t,s,r,n,a)=>t.tt(s,r,n,a),Xy="WORD",Uxe="UWORD",FWe="ASCIINUMERICAL",zWe="ALPHANUMERICAL",u6="LOCALHOST",Vxe="TLD",Hxe="UTLD",gre="SCHEME",w4="SLASH_SCHEME",Obe="NUM",Wxe="WS",Rbe="NL",rI="OPENBRACE",nI="CLOSEBRACE",Zne="OPENBRACKET",Yne="CLOSEBRACKET",Xne="OPENPAREN",Qne="CLOSEPAREN",Jne="OPENANGLEBRACKET",eae="CLOSEANGLEBRACKET",tae="FULLWIDTHLEFTPAREN",sae="FULLWIDTHRIGHTPAREN",rae="LEFTCORNERBRACKET",nae="RIGHTCORNERBRACKET",aae="LEFTWHITECORNERBRACKET",iae="RIGHTWHITECORNERBRACKET",oae="FULLWIDTHLESSTHAN",lae="FULLWIDTHGREATERTHAN",cae="AMPERSAND",dae="APOSTROPHE",uae="ASTERISK",c1="AT",hae="BACKSLASH",mae="BACKTICK",pae="CARET",y1="COLON",Fbe="COMMA",fae="DOLLAR",kx="DOT",gae="EQUALS",zbe="EXCLAMATION",Vp="HYPHEN",aI="PERCENT",xae="PIPE",yae="PLUS",vae="POUND",iI="QUERY",Bbe="QUOTE",BWe="FULLWIDTHMIDDLEDOT",$be="SEMI",Nx="SLASH",oI="TILDE",_ae="UNDERSCORE",$We="EMOJI",bae="SYM";var qWe=Object.freeze({__proto__:null,ALPHANUMERICAL:zWe,AMPERSAND:cae,APOSTROPHE:dae,ASCIINUMERICAL:FWe,ASTERISK:uae,AT:c1,BACKSLASH:hae,BACKTICK:mae,CARET:pae,CLOSEANGLEBRACKET:eae,CLOSEBRACE:nI,CLOSEBRACKET:Yne,CLOSEPAREN:Qne,COLON:y1,COMMA:Fbe,DOLLAR:fae,DOT:kx,EMOJI:$We,EQUALS:gae,EXCLAMATION:zbe,FULLWIDTHGREATERTHAN:lae,FULLWIDTHLEFTPAREN:tae,FULLWIDTHLESSTHAN:oae,FULLWIDTHMIDDLEDOT:BWe,FULLWIDTHRIGHTPAREN:sae,HYPHEN:Vp,LEFTCORNERBRACKET:rae,LEFTWHITECORNERBRACKET:aae,LOCALHOST:u6,NL:Rbe,NUM:Obe,OPENANGLEBRACKET:Jne,OPENBRACE:rI,OPENBRACKET:Zne,OPENPAREN:Xne,PERCENT:aI,PIPE:xae,PLUS:yae,POUND:vae,QUERY:iI,QUOTE:Bbe,RIGHTCORNERBRACKET:nae,RIGHTWHITECORNERBRACKET:iae,SCHEME:gre,SEMI:$be,SLASH:Nx,SLASH_SCHEME:w4,SYM:bae,TILDE:oI,TLD:Vxe,UNDERSCORE:_ae,UTLD:Hxe,UWORD:Uxe,WORD:Xy,WS:Wxe});const Hy=/[a-z]/,rE=new RegExp("\\p{L}","u"),Cme=new RegExp("\\p{Emoji}","u"),Wy=/\d/,Mme=/\s/,iAe="\r",Tme=` `,PIt="️",IIt="‍",Ame="";let K8=null,Z8=null;function LIt(t=[]){const s={};ym.groups=s;const r=new ym;K8==null&&(K8=oAe(SIt)),Z8==null&&(Z8=oAe(CIt)),Hr(r,"'",dae),Hr(r,"{",rI),Hr(r,"}",nI),Hr(r,"[",Zne),Hr(r,"]",Yne),Hr(r,"(",Xne),Hr(r,")",Qne),Hr(r,"<",Jne),Hr(r,">",eae),Hr(r,"(",tae),Hr(r,")",sae),Hr(r,"「",rae),Hr(r,"」",nae),Hr(r,"『",aae),Hr(r,"』",iae),Hr(r,"<",oae),Hr(r,">",lae),Hr(r,"&",cae),Hr(r,"*",uae),Hr(r,"@",c1),Hr(r,"`",mae),Hr(r,"^",pae),Hr(r,":",y1),Hr(r,",",Fbe),Hr(r,"$",fae),Hr(r,".",kx),Hr(r,"=",gae),Hr(r,"!",zbe),Hr(r,"-",Vp),Hr(r,"%",aI),Hr(r,"|",xae),Hr(r,"+",yae),Hr(r,"#",vae),Hr(r,"?",iI),Hr(r,'"',Bbe),Hr(r,"/",Nx),Hr(r,";",$be),Hr(r,"~",oI),Hr(r,"_",_ae),Hr(r,"\\",hae),Hr(r,"・",BWe);const n=Pc(r,Wy,Obe,{[zxe]:!0});Pc(n,Wy,n);const a=Pc(n,Hy,FWe,{[sI]:!0}),o=Pc(n,rE,zWe,{[EE]:!0}),l=Pc(r,Hy,Xy,{[Bxe]:!0});Pc(l,Wy,a),Pc(l,Hy,l),Pc(a,Wy,a),Pc(a,Hy,a);const i=Pc(r,rE,Uxe,{[$xe]:!0});Pc(i,Hy),Pc(i,Wy,o),Pc(i,rE,i),Pc(o,Wy,o),Pc(o,Hy),Pc(o,rE,o);const d=Hr(r,Tme,Rbe,{[Sme]:!0}),u=Hr(r,iAe,Wxe,{[Sme]:!0}),p=Pc(r,Mme,Wxe,{[Sme]:!0});Hr(r,Ame,p),Hr(u,Tme,d),Hr(u,Ame,p),Pc(u,Mme,p),Hr(p,iAe),Hr(p,Tme),Pc(p,Mme,p),Hr(p,Ame,p);const g=Pc(r,Cme,$We,{[RWe]:!0});Hr(g,"#"),Pc(g,Cme,g),Hr(g,PIt,g);const v=Hr(g,IIt);Hr(v,"#"),Pc(v,Cme,g);const _=[[Hy,l],[Wy,a]],b=[[Hy,null],[rE,i],[Wy,o]];for(let j=0;jj[0]>w[0]?1:-1);for(let j=0;j=0?C[qxe]=!0:Hy.test(w)?Wy.test(w)?C[sI]=!0:C[Bxe]=!0:C[zxe]=!0,aAe(r,w,w,C)}return aAe(r,"localhost",u6,{ascii:!0}),r.jd=new ym(bae),{start:r,tokens:Object.assign({groups:s},qWe)}}function UWe(t,s){const r=DIt(s.replace(/[A-Z]/g,i=>i.toLowerCase())),n=r.length,a=[];let o=0,l=0;for(;l=0&&(g+=r[l].length,v++),u+=r[l].length,o+=r[l].length,l++;o-=g,l-=v,u-=g,a.push({t:p.t,v:s.slice(o-u,o),s:o-u,e:o})}return a}function DIt(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 Yv(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 h6={defaultProtocol:"http",events:null,format:lAe,formatHref:lAe,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function qbe(t,s=null){let r=Object.assign({},h6);t&&(r=Object.assign(r,t instanceof qbe?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=h6.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),g=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:g}}};function hle(t,s){class r extends VWe{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 cAe=hle("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),dAe=hle("text"),OIt=hle("nl"),Y8=hle("url",{isLink:!0,toHref(t=h6.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==u6&&t[1].t===y1}}),Bp=t=>new ym(t);function RIt({groups:t}){const s=t.domain.concat([cae,uae,c1,hae,mae,pae,fae,gae,Vp,Obe,aI,xae,yae,vae,Nx,bae,oI,_ae]),r=[dae,y1,Fbe,kx,zbe,aI,iI,Bbe,$be,Jne,eae,rI,nI,Yne,Zne,Xne,Qne,tae,sae,rae,nae,aae,iae,oae,lae],n=[cae,dae,uae,hae,mae,pae,fae,gae,Vp,rI,nI,aI,xae,yae,vae,iI,Nx,bae,oI,_ae],a=Bp(),o=Hr(a,oI);$i(o,n,o),$i(o,t.domain,o);const l=Bp(),i=Bp(),d=Bp();$i(a,t.domain,l),$i(a,t.scheme,i),$i(a,t.slashscheme,d),$i(l,n,o),$i(l,t.domain,l);const u=Hr(l,c1);Hr(o,c1,u),Hr(i,c1,u),Hr(d,c1,u);const p=Hr(o,kx);$i(p,n,o),$i(p,t.domain,o);const g=Bp();$i(u,t.domain,g),$i(g,t.domain,g);const v=Hr(g,kx);$i(v,t.domain,g);const _=Bp(cAe);$i(v,t.tld,_),$i(v,t.utld,_),Hr(u,u6,_);const b=Hr(g,Vp);Hr(b,Vp,b),$i(b,t.domain,g),$i(_,t.domain,g),Hr(_,kx,v),Hr(_,Vp,b);const j=Hr(_,y1);$i(j,t.numeric,cAe);const w=Hr(l,Vp),N=Hr(l,kx);Hr(w,Vp,w),$i(w,t.domain,l),$i(N,n,o),$i(N,t.domain,l);const C=Bp(Y8);$i(N,t.tld,C),$i(N,t.utld,C),$i(C,t.domain,l),$i(C,n,o),Hr(C,kx,N),Hr(C,Vp,w),Hr(C,c1,u);const A=Hr(C,y1),I=Bp(Y8);$i(A,t.numeric,I);const L=Bp(Y8),R=Bp();$i(L,s,L),$i(L,r,R),$i(R,s,L),$i(R,r,R),Hr(C,Nx,L),Hr(I,Nx,L);const $=Hr(i,y1),q=Hr(d,y1),U=Hr(q,Nx),V=Hr(U,Nx);$i(i,t.domain,l),Hr(i,kx,N),Hr(i,Vp,w),$i(d,t.domain,l),Hr(d,kx,N),Hr(d,Vp,w),$i($,t.domain,L),Hr($,Nx,L),Hr($,iI,L),$i(V,t.domain,L),$i(V,s,L),Hr(V,Nx,L);const X=[[rI,nI],[Zne,Yne],[Xne,Qne],[Jne,eae],[tae,sae],[rae,nae],[aae,iae],[oae,lae]];for(let se=0;se=0&&v++,a++,p++;if(v<0)a-=p,a0&&(o.push(Eme(dAe,s,l)),l=[]),a-=v,p-=v;const _=g.t,b=r.slice(a-p,a);o.push(Eme(_,s,b))}}return l.length>0&&o.push(Eme(dAe,s,l)),o}function Eme(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 zIt=typeof console<"u"&&console&&console.warn||(()=>{}),BIt="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Zl={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function $It(){return ym.groups={},Zl.scanner=null,Zl.parser=null,Zl.tokenQueue=[],Zl.pluginQueue=[],Zl.customSchemes=[],Zl.initialized=!1,Zl}function uAe(t,s=!1){if(Zl.initialized&&zIt(`linkifyjs: already initialized - will not register custom scheme "${t}" ${BIt}`),!/^[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`);Zl.customSchemes.push([t,s])}function qIt(){Zl.scanner=LIt(Zl.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=_Et(r.doc,[...s]);if(CEt(i).forEach(({newRange:u})=>{const p=wEt(n.doc,u,_=>_.isTextblock);let g,v;if(p.length>1)g=p[0],v=n.doc.textBetween(g.pos,g.pos+g.node.nodeSize,void 0," ");else if(p.length){const _=n.doc.textBetween(u.from,u.to," "," ");if(!VIt.test(_))return;g=p[0],v=n.doc.textBetween(g.pos,u.to,void 0," ")}if(g&&v){const _=v.split(UIt).filter(Boolean);if(_.length<=0)return!1;const b=_[_.length-1],j=g.pos+v.lastIndexOf(b);if(!b)return!1;const w=Ube(b).map(N=>N.toObject(t.defaultProtocol));if(!WIt(w))return!1;w.filter(N=>N.isLink).map(N=>({...N,from:j+N.start+1,to:j+N.end+1})).filter(N=>n.schema.marks.code?!n.doc.rangeHasMark(N.from,N.to,n.schema.marks.code):!0).filter(N=>t.validate(N.value)).filter(N=>t.shouldAutoLink(N.value)).forEach(N=>{Ebe(N.from,N.to,n.doc).some(C=>C.mark.type===t.type)||l.addMark(N.from,N.to,t.type.create({href:N.href}))})}}),!!l.steps.length)return l}})}function KIt(t){return new Gd({key:new ch("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(v=>v.nodeName==="A"))return!1;const d=NWe(s.state,t.type.name),u=n.target,p=(a=u==null?void 0:u.href)!==null&&a!==void 0?a:d.href,g=(o=u==null?void 0:u.target)!==null&&o!==void 0?o:d.target;return u&&p?(window.open(p,g),!0):!1}}})}function ZIt(t){return new Gd({key:new ch("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=HWe(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 Kb(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(HIt,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const WWe=iy.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"){uAe(t);return}uAe(t.scheme,t.optionalSlashes)})},onDestroy(){$It()},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)=>!!Kb(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=>!!Kb(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=>!!Kb(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Mc(this.options.HTMLAttributes,t),0]:["a",Mc(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!Kb(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=>!!Kb(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[FN({find:t=>{const s=[];if(t){const{protocols:r,defaultProtocol:n}=this.options,a=HWe(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!Kb(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(GIt({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:a=>!!Kb(a,s),protocols:s,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(KIt({type:this.type})),this.options.linkOnPaste&&t.push(ZIt({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),GWe=$u.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")}}}),YIt=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}`)})},KWe=iy.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&YIt(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Mc(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}}}}),XIt=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,QIt=dh.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",Mc(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:s})=>s.insertContent({type:this.name,attrs:t})}},addInputRules(){return[SWe({find:XIt,type:this.type,getAttributes:t=>{const[,,s,r,n]=t;return{src:r,alt:s,title:n}}})]}});let Gxe,Kxe;if(typeof WeakMap<"u"){let t=new WeakMap;Gxe=s=>t.get(s),Kxe=(s,r)=>(t.set(s,r),r)}else{const t=[];let r=0;Gxe=n=>{for(let a=0;a(r==10&&(r=0),t[r++]=n,t[r++]=a)}var qc=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:N-A});break}const I=a+A*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 t6t(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 r6t(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 Kg(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 mle(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=wM(s.$head)||n6t(s.$head);if(r)return r;throw new RangeError(`No cell found around position ${s.head}`)}function n6t(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 Zxe(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function a6t(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Hbe(t,s){return t.depth==s.depth&&t.pos>=s.start(-1)&&t.pos<=s.end(-1)}function ZWe(t,s,r){const n=t.node(-1),a=qc.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 zN(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 YWe(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 g=n.nodeAt(p);if(!g)throw new RangeError(`No cell with offset ${p} found`);const v=o+p+1;return new yHe(i.resolve(v),i.resolve(v+g.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(Zxe(n)&&Zxe(a)&&Hbe(n,a)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?Qy.rowSelection(n,a):o&&this.isColSelection()?Qy.colSelection(n,a):new Qy(n,a)}return $a.between(n,a)}content(){const s=this.$anchorCell.node(-1),r=qc.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||w>0){let N=b.attrs;if(j>0&&(N=zN(N,0,j)),w>0&&(N=zN(N,N.colspan-w,w)),_.lefta.bottom){const N={...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=qc.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 Qy&&s.$anchorCell.pos==this.$anchorCell.pos&&s.$headCell.pos==this.$headCell.pos}static rowSelection(s,r=s){const n=s.node(-1),a=qc.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(Lh.node(n,n+r.nodeSize,{class:"selectedCell"}))}),zc.create(t.doc,s)}function c6t({$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 u6t(t,s,r){const n=(s||t).selection,a=(s||t).doc;let o,l;if(n instanceof Ia&&(l=n.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=zl.create(a,n.from);else if(l=="row"){const i=a.resolve(n.from+1);o=zl.rowSelection(i,i)}else if(!r){const i=qc.get(n.node),d=n.from+1,u=d+i.map[i.width*i.height-1];o=zl.create(a,d+1,u)}}else n instanceof $a&&c6t(n)?o=$a.create(a,n.from):n instanceof $a&&d6t(n)&&(o=$a.create(a,n.$from.start(),n.$from.end()));return o&&(s||(s=t.tr)).setSelection(o),s}const h6t=new ch("fix-tables");function QWe(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=m6t(t,a,o,r))};return s?s.doc!=t.doc&&QWe(s.doc,t.doc,0,n):t.doc.descendants(n),r}function m6t(t,s,r,n){const a=qc.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 w=0;w0?-1:0;i6t(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;y6t(s,n,a+i)&&(i=a==0||a==s.height?null:0);for(let u=0,p=s.width*a;u0&&a0&&g==s.map[p-s.width]){const v=r.nodeAt(g).attrs;t.setNodeMarkup(t.mapping.slice(i).map(g+n),null,{...v,rowspan:v.rowspan-1}),u+=v.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,g=hAe(u)?d+1:p;o.replaceWith(g+n.tableStart,p+n.tableStart,i)}o.setSelection(new zl(o.doc.resolve(d+n.tableStart))),s(o)}return!0}function pAe(t,s){const r=oh(t.schema);return k6t(({node:n})=>r[n.type.spec.tableRole])(t,s)}function k6t(t){return(s,r)=>{const n=s.selection;let a,o;if(n instanceof zl){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;a=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var l;if(a=r6t(n.$from),!a)return!1;o=(l=wM(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=my(s),g=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 S6t(t){return function(s,r){if(!Kg(s))return!1;if(r){const n=oh(s.schema),a=my(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 _=v+o.tableStart,b=l.doc.nodeAt(_);b&&l.setNodeMarkup(_,g,b.attrs)}),n(l)}return!0}}m6("row",{useDeprecatedLogic:!0});m6("column",{useDeprecatedLogic:!0});const C6t=m6("cell",{useDeprecatedLogic:!0});function M6t(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 X8(t,s){const r=t.selection;if(!(r instanceof zl))return!1;if(s){const n=t.tr,a=oh(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 pn(a,0,0))}),n.docChanged&&s(n)}return!0}function A6t(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(Ar.empty),r[a]n&&(v=v.type.createChecked(zN(v.attrs,v.attrs.colspan,p+v.attrs.colspan-n),v.content)),u.push(v),p+=v.attrs.colspan;for(let _=1;_a&&(g=g.type.create({...g.attrs,rowspan:Math.max(1,a-g.attrs.rowspan)},g.content)),d.push(g)}o.push(Ar.from(d))}r=o,s=a}return{width:t,height:s,rows:r}}function I6t(t,s,r,n,a,o,l){const i=t.doc.type.schema,d=oh(i);let u,p;if(a>s.width)for(let g=0,v=0;gs.height){const g=[];for(let b=0,j=(s.height-1)*s.width;b=s.width?!1:r.nodeAt(s.map[j+b]).type==d.header_cell;g.push(w?p||(p=d.header_cell.createAndFill()):u||(u=d.cell.createAndFill()))}const v=d.row.create(null,Ar.from(g)),_=[];for(let b=s.height;b{if(!a)return!1;const o=r.selection;if(o instanceof zl)return xre(r,n,ni.near(o.$headCell,s));if(t!="horiz"&&!o.empty)return!1;const l=sGe(a,t,s);if(l==null)return!1;if(t=="horiz")return xre(r,n,ni.near(r.doc.resolve(o.head+s),s));{const i=r.doc.resolve(l),d=ZWe(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),xre(r,n,u)}}}function J8(t,s){return(r,n,a)=>{if(!a)return!1;const o=r.selection;let l;if(o instanceof zl)l=o;else{const d=sGe(a,t,s);if(d==null)return!1;l=new zl(r.doc.resolve(d))}const i=ZWe(l.$headCell,t,s);return i?xre(r,n,new zl(l.$anchorCell,i)):!1}}function D6t(t,s){const r=t.state.doc,n=wM(r.resolve(s));return n?(t.dispatch(t.state.tr.setSelection(new zl(n))),!0):!1}function O6t(t,s,r){if(!Kg(t.state))return!1;let n=A6t(r);const a=t.state.selection;if(a instanceof zl){n||(n={width:1,height:1,rows:[Ar.from(Yxe(oh(t.state.schema).cell,r))]});const o=a.$anchorCell.node(-1),l=a.$anchorCell.start(-1),i=qc.get(o).rectBetween(a.$anchorCell.pos-l,a.$headCell.pos-l);return n=P6t(n,i.right-i.left,i.bottom-i.top),vAe(t.state,t.dispatch,l,i,n),!0}else if(n){const o=mle(t.state),l=o.start(-1);return vAe(t.state,t.dispatch,l,qc.get(o.node(-1)).findCell(o.pos-l),n),!0}else return!1}function R6t(t,s){var r;if(s.ctrlKey||s.metaKey)return;const n=_Ae(t,s.target);let a;if(s.shiftKey&&t.state.selection instanceof zl)o(t.state.selection.$anchorCell,s),s.preventDefault();else if(s.shiftKey&&n&&(a=wM(t.state.selection.$anchor))!=null&&((r=Pme(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=Pme(t,u);const g=v1.getState(t.state)==null;if(!p||!Hbe(d,p))if(g)p=d;else return;const v=new zl(d,p);if(g||!t.state.selection.eq(v)){const _=t.state.tr.setSelection(v);g&&_.setMeta(v1,d.pos),t.dispatch(_)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",i),v1.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(v1,-1))}function i(d){const u=d,p=v1.getState(t.state);let g;if(p!=null)g=t.state.doc.resolve(p);else if(_Ae(t,u.target)!=n&&(g=Pme(t,s),!g))return l();g&&o(g,u)}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",i)}function sGe(t,s,r){if(!(t.state.selection instanceof $a))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 _Ae(t,s){for(;s&&s!=t.dom;s=s.parentNode)if(s.nodeName=="TD"||s.nodeName=="TH")return s;return null}function Pme(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 wM(t.state.doc.resolve(n))}var F6t=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")),Xxe(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,Xxe(s,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(s){return s.type=="attributes"&&(s.target==this.table||this.colgroup.contains(s.target))}};function Xxe(t,s,r,n,a,o){let l=0,i=!0,d=s.firstChild;const u=t.firstChild;if(u){for(let g=0,v=0;gnew n(g,r,v)),new B6t(-1,!1)},apply(l,i){return i.apply(l)}},props:{attributes:l=>{const i=lp.getState(l);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,i)=>{$6t(l,i,t,a)},mouseleave:l=>{q6t(l)},mousedown:(l,i)=>{U6t(l,i,s,r)}},decorations:l=>{const i=lp.getState(l);if(i&&i.activeHandle>-1)return K6t(l,i.activeHandle)},nodeViews:{}}});return o}var B6t=class yre{constructor(s,r){this.activeHandle=s,this.dragging=r}apply(s){const r=this,n=s.getMeta(lp);if(n&&n.setHandle!=null)return new yre(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new yre(r.activeHandle,n.setDragging);if(r.activeHandle>-1&&s.docChanged){let a=s.mapping.map(r.activeHandle,-1);return Zxe(s.doc.resolve(a))||(a=-1),new yre(a,r.dragging)}return r}};function $6t(t,s,r,n){if(!t.editable)return;const a=lp.getState(t.state);if(a&&!a.dragging){const o=H6t(s.target);let l=-1;if(o){const{left:i,right:d}=o.getBoundingClientRect();s.clientX-i<=r?l=bAe(t,s,"left",r):d-s.clientX<=r&&(l=bAe(t,s,"right",r))}if(l!=a.activeHandle){if(!n&&l!==-1){const i=t.state.doc.resolve(l),d=i.node(-1),u=qc.get(d),p=i.start(-1);if(u.colCount(i.pos-p)+i.nodeAfter.attrs.colspan-1==u.width-1)return}rGe(t,l)}}}function q6t(t){if(!t.editable)return;const s=lp.getState(t.state);s&&s.activeHandle>-1&&!s.dragging&&rGe(t,-1)}function U6t(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=lp.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const i=t.state.doc.nodeAt(l.activeHandle),d=V6t(t,l.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(lp,{setDragging:{startX:s.clientX,startWidth:d}}));function u(g){o.removeEventListener("mouseup",u),o.removeEventListener("mousemove",p);const v=lp.getState(t.state);v!=null&&v.dragging&&(W6t(t,v.activeHandle,wAe(v.dragging,g,r)),t.dispatch(t.state.tr.setMeta(lp,{setDragging:null})))}function p(g){if(!g.which)return u(g);const v=lp.getState(t.state);if(v&&v.dragging){const _=wAe(v.dragging,g,r);jAe(t,v.activeHandle,_,n)}}return jAe(t,l.activeHandle,d,n),o.addEventListener("mouseup",u),o.addEventListener("mousemove",p),s.preventDefault(),!0}function V6t(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 J6t(t,s,r,n,a){const o=Q6t(t),l=[],i=[];for(let u=0;u{const{selection:s}=t.state;if(!eLt(s))return!1;let r=0;const n=kWe(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},tLt=dh.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Y6t,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}=X6t(t,this.options.cellMinWidth),o=["table",Mc(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=J6t(o.schema,t,s,r);if(a){const i=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection($a.near(n.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:s})=>p6t(t,s),addColumnAfter:()=>({state:t,dispatch:s})=>f6t(t,s),deleteColumn:()=>({state:t,dispatch:s})=>x6t(t,s),addRowBefore:()=>({state:t,dispatch:s})=>v6t(t,s),addRowAfter:()=>({state:t,dispatch:s})=>_6t(t,s),deleteRow:()=>({state:t,dispatch:s})=>w6t(t,s),deleteTable:()=>({state:t,dispatch:s})=>T6t(t,s),mergeCells:()=>({state:t,dispatch:s})=>mAe(t,s),splitCell:()=>({state:t,dispatch:s})=>pAe(t,s),toggleHeaderColumn:()=>({state:t,dispatch:s})=>m6("column")(t,s),toggleHeaderRow:()=>({state:t,dispatch:s})=>m6("row")(t,s),toggleHeaderCell:()=>({state:t,dispatch:s})=>C6t(t,s),mergeOrSplit:()=>({state:t,dispatch:s})=>mAe(t,s)?!0:pAe(t,s),setCellAttribute:(t,s)=>({state:r,dispatch:n})=>N6t(t,s)(r,n),goToNextCell:()=>({state:t,dispatch:s})=>gAe(1)(t,s),goToPreviousCell:()=>({state:t,dispatch:s})=>gAe(-1)(t,s),fixTables:()=>({state:t,dispatch:s})=>(s&&JWe(t),!0),setCellSelection:t=>({tr:s,dispatch:r})=>{if(r){const n=zl.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:eR,"Mod-Backspace":eR,Delete:eR,"Mod-Delete":eR}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[z6t({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Z6t({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const s={name:t.name,options:t.options,storage:t.storage};return{tableRole:qi(Jn(t,"tableRole",s))}}}),sLt=dh.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Mc(this.options.HTMLAttributes,t),0]}}),rLt=dh.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",Mc(this.options.HTMLAttributes,t),0]}}),nLt=dh.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",Mc(this.options.HTMLAttributes,t),0]}});function Zg({content:t,onChange:s,placeholder:r="Enter content...",minHeight:n="150px",compact:a=!1}){const[o,l]=S.useState(!1),[i,d]=S.useState(""),[u,p]=S.useState(!0),g=AWe({extensions:[OWe,WWe.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),GWe.configure({types:["heading","paragraph"]}),KWe,QIt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),width:{default:null},height:{default:null},style:{default:null}}}}).configure({inline:!0,allowBase64:!0}),tLt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null},width:{default:null},cellpadding:{default:null},cellspacing:{default:null},border:{default:null}}}}).configure({resizable:!1}),sLt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null}}}}),rLt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1},valign:{default:null}}}}),nLt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1}}}})],content:t,onUpdate:({editor:j})=>{s(j.getHTML())},editorProps:{attributes:{class:"outline-none","data-placeholder":r},handlePaste:(j,w)=>{var C;const N=(C=w.clipboardData)==null?void 0:C.items;if(!N)return!1;for(const A of Array.from(N))if(A.type.startsWith("image/")){w.preventDefault();const I=A.getAsFile();if(!I)continue;const L=new FileReader;return L.onload=R=>{var q;const $=(q=R.target)==null?void 0:q.result;j.dispatch(j.state.tr.replaceSelectionWith(j.state.schema.nodes.image.create({src:$})))},L.readAsDataURL(I),!0}return!1}}});S.useEffect(()=>{g&&t!==g.getHTML()&&g.commands.setContent(t)},[t,g]);const v=()=>{if(!g)return;const j=g.getAttributes("link").href||"",w=g.getAttributes("link").target;d(j),p(w==="_blank"),l(!0)},_=()=>{g&&(i===""?g.chain().focus().extendMarkRange("link").unsetLink().run():g.chain().focus().extendMarkRange("link").setLink({href:i,target:u?"_blank":null,rel:u?"noopener noreferrer nofollow":null}).run(),l(!1),d(""))},b=()=>{g&&g.chain().focus().extendMarkRange("link").unsetLink().run()};return g?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:()=>g.chain().focus().toggleHeading({level:1}).run(),className:g.isActive("heading",{level:1})?"bg-muted":"",title:"Heading 1",children:e.jsx(aP,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleHeading({level:2}).run(),className:g.isActive("heading",{level:2})?"bg-muted":"",title:"Heading 2",children:e.jsx(iP,{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:()=>g.chain().focus().toggleBold().run(),className:g.isActive("bold")?"bg-muted":"",title:"Bold",children:e.jsx(n5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleItalic().run(),className:g.isActive("italic")?"bg-muted":"",title:"Italic",children:e.jsx(u5,{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:()=>g.chain().focus().toggleBulletList().run(),className:g.isActive("bulletList")?"bg-muted":"",title:"Bullet List",children:e.jsx(qh,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleOrderedList().run(),className:g.isActive("orderedList")?"bg-muted":"",title:"Numbered List",children:e.jsx(M0,{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:()=>g.chain().focus().setTextAlign("left").run(),className:g.isActive({textAlign:"left"})?"bg-muted":"",title:"Align Left",children:e.jsx(t5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().setTextAlign("center").run(),className:g.isActive({textAlign:"center"})?"bg-muted":"",title:"Align Center",children:e.jsx(e5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().setTextAlign("right").run(),className:g.isActive({textAlign:"right"})?"bg-muted":"",title:"Align Right",children:e.jsx(s5,{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:v,className:g.isActive("link")?"bg-muted":"",title:"Add Link",children:e.jsx(Io,{className:"h-4 w-4"})}),g.isActive("link")&&e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:b,title:"Remove Link",children:e.jsx(Io,{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:()=>g.chain().focus().undo().run(),disabled:!g.can().undo(),title:"Undo",children:e.jsx(w5,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().redo().run(),disabled:!g.can().redo(),title:"Redo",children:e.jsx(_5,{className:"h-4 w-4"})})]}),e.jsx(MWe,{editor:g,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(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{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:j=>d(j.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(On,{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,iLt=(t,s,r)=>s in t?aLt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,oc=(t,s,r)=>iLt(t,typeof s!="symbol"?s+"":s,r);const wae={x:0,y:0,width:0,height:0,unit:"px"},a4=(t,s,r)=>Math.min(Math.max(t,s),r),oLt=(...t)=>t.filter(s=>s&&typeof s=="string").join(" "),SAe=(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 lLt(t,s,r,n){const a=Sx(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==="%"?d1(a,r,n):a}function cLt(t,s,r){const n=Sx(t,s,r);return n.x=(s-n.width)/2,n.y=(r-n.height)/2,t.unit==="%"?d1(n,s,r):n}function d1(t,s,r){return t.unit==="%"?{...wae,...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 Sx(t,s,r){return t.unit?t.unit==="px"?{...wae,...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}:{...wae,...t,unit:"px"}}function CAe(t,s,r,n,a,o=0,l=0,i=n,d=a){const u={...t};let p=Math.min(o,n),g=Math.min(l,a),v=Math.min(i,n),_=Math.min(d,a);s&&(s>1?(p=l?l*s:p,g=p/s,v=i*s):(g=o?o/s:g,p=g*s,_=d/s)),u.y<0&&(u.height=Math.max(u.height+u.y,g),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 j=a-(u.y+u.height);if(j<0&&(u.y=Math.min(u.y,a-g),u.height+=j),u.widthv&&((r==="sw"||r=="nw")&&(u.x-=v-u.width),u.width=v),u.height>_&&((r==="nw"||r=="ne")&&(u.y-=_-u.height),u.height=_),s){const w=u.width/u.height;if(ws){const N=Math.max(u.height*s,p);(r==="sw"||r=="nw")&&(u.x-=N-u.width),u.width=N}}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 i4={capture:!0,passive:!1};let uLt=0;const s1=class mg extends S.PureComponent{constructor(){super(...arguments),oc(this,"docMoveBound",!1),oc(this,"mouseDownOnCrop",!1),oc(this,"dragStarted",!1),oc(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),oc(this,"componentRef",S.createRef()),oc(this,"mediaRef",S.createRef()),oc(this,"resizeObserver"),oc(this,"initChangeCalled",!1),oc(this,"instanceId",`rc-${uLt++}`),oc(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),oc(this,"onCropPointerDown",s=>{const{crop:r,disabled:n}=this.props,a=this.getBox();if(!r)return;const o=Sx(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,g=o.y;if(l){const v=s.clientX-a.x,_=s.clientY-a.y;let b=0,j=0;l==="ne"||l=="e"?(b=v-(o.x+o.width),j=_-o.y,p=o.x,g=o.y+o.height):l==="se"||l==="s"?(b=v-(o.x+o.width),j=_-(o.y+o.height),p=o.x,g=o.y):l==="sw"||l=="w"?(b=v-o.x,j=_-(o.y+o.height),p=o.x+o.width,g=o.y):(l==="nw"||l=="n")&&(b=v-o.x,j=_-o.y,p=o.x+o.width,g=o.y+o.height),d=p+a.x+b,u=g+a.y+j}this.evData={startClientX:d,startClientY:u,startCropX:p,startCropY:g,clientX:s.clientX,clientY:s.clientY,isResize:i,ord:l},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),oc(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(Sx(p,i.width,i.height),d1(p,i.width,i.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),oc(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(),SAe(r,d)||a(Sx(d,l.width,l.height),d1(d,l.width,l.height))}),oc(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)?mg.nudgeStepLarge:s.shiftKey?mg.nudgeStepMedium:mg.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=a4(u.x,0,d.width-u.width),u.y=a4(u.y,0,d.height-u.height);const g=Sx(u,d.width,d.height),v=d1(u,d.width,d.height);a(g,v),o&&o(g,v)}}),oc(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:g}=this.props,v=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)?mg.nudgeStepLarge:s.shiftKey?mg.nudgeStepMedium:mg.nudgeStep,b=Sx(a,v.width,v.height),j=dLt(b,s.key,_,r),w=CAe(j,n,r,v.width,v.height,l,i,d,u);if(!SAe(a,w)){const N=d1(w,v.width,v.height);p(w,N),g&&g(w,N)}}),oc(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(Sx(r,l.width,l.height),d1(r,l.width,l.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),oc(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(Sx(r,a,o),d1(r,a,o))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,i4),this.document.addEventListener("pointerup",this.onDocPointerDone,i4),this.document.addEventListener("pointercancel",this.onDocPointerDone,i4),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,i4),this.document.removeEventListener("pointerup",this.onDocPointerDone,i4),this.document.removeEventListener("pointercancel",this.onDocPointerDone,i4),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=a4(s.startCropX+a,0,r.width-n.width),n.y=a4(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 g=s.clientX-s.startClientX,v=s.clientY-s.startClientY;(l&&p==="nw"||p==="w"||p==="sw")&&(g=Math.min(g,-l)),(i&&p==="nw"||p==="n"||p==="ne")&&(v=Math.min(v,-i));const _={unit:"px",x:0,y:0,width:0,height:0};u==="ne"?(_.x=s.startCropX,_.width=g,r?(_.height=_.width/r,_.y=s.startCropY-_.height):(_.height=Math.abs(v),_.y=s.startCropY-_.height)):u==="se"?(_.x=s.startCropX,_.y=s.startCropY,_.width=g,r?_.height=_.width/r:_.height=v):u==="sw"?(_.x=s.startCropX+g,_.y=s.startCropY,_.width=Math.abs(g),r?_.height=_.width/r:_.height=v):u==="nw"&&(_.x=s.startCropX+g,_.width=Math.abs(g),r?(_.height=_.width/r,_.y=s.startCropY-_.height):(_.height=Math.abs(v),_.y=s.startCropY+v));const b=CAe(_,r,u,o.width,o.height,l,i,n,a);return r||mg.xyOrds.indexOf(p)>-1?d=b:mg.xOrds.indexOf(p)>-1?(d.x=b.x,d.width=b.width):mg.yOrds.indexOf(p)>-1&&(d.y=b.y,d.height=b.height),d.x=a4(d.x,0,o.width-d.width),d.y=a4(d.y,0,o.height-d.height),d}renderCropSelection(){const{ariaLabels:s=mg.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={...wae,...this.props.crop||{}};return Sx(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:g}=this.state,v=o?this.renderCropSelection():null,_=oLt("ReactCrop",a,p&&"ReactCrop--active",l&&"ReactCrop--disabled",i&&"ReactCrop--locked",g&&"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,v)}};oc(s1,"xOrds",["e","w"]),oc(s1,"yOrds",["n","s"]),oc(s1,"xyOrds",["nw","ne","se","sw"]),oc(s1,"nudgeStep",1),oc(s1,"nudgeStepMedium",10),oc(s1,"nudgeStepLarge",100),oc(s1,"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 hLt=s1;var nGe=["PageUp","PageDown"],aGe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],iGe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},jM="Slider",[Jxe,mLt,pLt]=oL(jM),[oGe]=Tc(jM,[pLt]),[fLt,ple]=oGe(jM),lGe=S.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:g=()=>{},onValueCommit:v=()=>{},inverted:_=!1,form:b,...j}=t,w=S.useRef(new Set),N=S.useRef(0),A=l==="horizontal"?gLt:xLt,[I=[],L]=fu({prop:p,defaultProp:u,onChange:X=>{var te;(te=[...w.current][N.current])==null||te.focus(),g(X)}}),R=S.useRef(I);function $(X){const se=wLt(I,X);V(X,se)}function q(X){V(X,N.current)}function U(){const X=R.current[N.current];I[N.current]!==X&&v(I)}function V(X,se,{commit:te}={commit:!1}){const Y=SLt(o),de=CLt(Math.round((X-n)/o)*o+n,Y),ie=GI(de,[n,a]);L((ae=[])=>{const le=_Lt(ae,ie,se);if(NLt(le,d*o)){N.current=le.indexOf(ie);const pe=String(le)!==String(ae);return pe&&te&&v(le),pe?le:ae}else return ae})}return e.jsx(fLt,{scope:t.__scopeSlider,name:r,disabled:i,min:n,max:a,valueIndexToChangeRef:N,thumbs:w.current,values:I,orientation:l,form:b,children:e.jsx(Jxe.Provider,{scope:t.__scopeSlider,children:e.jsx(Jxe.Slot,{scope:t.__scopeSlider,children:e.jsx(A,{"aria-disabled":i,"data-disabled":i?"":void 0,...j,ref:s,onPointerDown:Mr(j.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&&V(n,0,{commit:!0}),onEndKeyDown:()=>!i&&V(a,I.length-1,{commit:!0}),onStepKeyDown:({event:X,direction:se})=>{if(!i){const de=nGe.includes(X.key)||X.shiftKey&&aGe.includes(X.key)?10:1,ie=N.current,ae=I[ie],le=o*de*se;V(ae+le,ie,{commit:!0})}}})})})})});lGe.displayName=jM;var[cGe,dGe]=oGe(jM,{startEdge:"left",endEdge:"right",size:"width",direction:1}),gLt=S.forwardRef((t,s)=>{const{min:r,max:n,dir:a,inverted:o,onSlideStart:l,onSlideMove:i,onSlideEnd:d,onStepKeyDown:u,...p}=t,[g,v]=S.useState(null),_=Aa(s,A=>v(A)),b=S.useRef(void 0),j=z_(a),w=j==="ltr",N=w&&!o||!w&&o;function C(A){const I=b.current||g.getBoundingClientRect(),L=[0,I.width],$=Wbe(L,N?[r,n]:[n,r]);return b.current=I,$(A-I.left)}return e.jsx(cGe,{scope:t.__scopeSlider,startEdge:N?"left":"right",endEdge:N?"right":"left",direction:N?1:-1,size:"width",children:e.jsx(uGe,{dir:j,"data-orientation":"horizontal",...p,ref:_,style:{...p.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:A=>{const I=C(A.clientX);l==null||l(I)},onSlideMove:A=>{const I=C(A.clientX);i==null||i(I)},onSlideEnd:()=>{b.current=void 0,d==null||d()},onStepKeyDown:A=>{const L=iGe[N?"from-left":"from-right"].includes(A.key);u==null||u({event:A,direction:L?-1:1})}})})}),xLt=S.forwardRef((t,s)=>{const{min:r,max:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:i,onStepKeyDown:d,...u}=t,p=S.useRef(null),g=Aa(s,p),v=S.useRef(void 0),_=!a;function b(j){const w=v.current||p.current.getBoundingClientRect(),N=[0,w.height],A=Wbe(N,_?[n,r]:[r,n]);return v.current=w,A(j-w.top)}return e.jsx(cGe,{scope:t.__scopeSlider,startEdge:_?"bottom":"top",endEdge:_?"top":"bottom",size:"height",direction:_?1:-1,children:e.jsx(uGe,{"data-orientation":"vertical",...u,ref:g,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:j=>{const w=b(j.clientY);o==null||o(w)},onSlideMove:j=>{const w=b(j.clientY);l==null||l(w)},onSlideEnd:()=>{v.current=void 0,i==null||i()},onStepKeyDown:j=>{const N=iGe[_?"from-bottom":"from-top"].includes(j.key);d==null||d({event:j,direction:N?-1:1})}})})}),uGe=S.forwardRef((t,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:i,onStepKeyDown:d,...u}=t,p=ple(jM,r);return e.jsx(Qr.span,{...u,ref:s,onKeyDown:Mr(t.onKeyDown,g=>{g.key==="Home"?(l(g),g.preventDefault()):g.key==="End"?(i(g),g.preventDefault()):nGe.concat(aGe).includes(g.key)&&(d(g),g.preventDefault())}),onPointerDown:Mr(t.onPointerDown,g=>{const v=g.target;v.setPointerCapture(g.pointerId),g.preventDefault(),p.thumbs.has(v)?v.focus():n(g)}),onPointerMove:Mr(t.onPointerMove,g=>{g.target.hasPointerCapture(g.pointerId)&&a(g)}),onPointerUp:Mr(t.onPointerUp,g=>{const v=g.target;v.hasPointerCapture(g.pointerId)&&(v.releasePointerCapture(g.pointerId),o(g))})})}),hGe="SliderTrack",mGe=S.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=ple(hGe,r);return e.jsx(Qr.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:s})});mGe.displayName=hGe;var eye="SliderRange",pGe=S.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=ple(eye,r),o=dGe(eye,r),l=S.useRef(null),i=Aa(s,l),d=a.values.length,u=a.values.map(v=>xGe(v,a.min,a.max)),p=d>1?Math.min(...u):0,g=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]:g+"%"}})});pGe.displayName=eye;var tye="SliderThumb",fGe=S.forwardRef((t,s)=>{const r=mLt(t.__scopeSlider),[n,a]=S.useState(null),o=Aa(s,i=>a(i)),l=S.useMemo(()=>n?r().findIndex(i=>i.ref.current===n):-1,[r,n]);return e.jsx(yLt,{...t,ref:o,index:l})}),yLt=S.forwardRef((t,s)=>{const{__scopeSlider:r,index:n,name:a,...o}=t,l=ple(tye,r),i=dGe(tye,r),[d,u]=S.useState(null),p=Aa(s,C=>u(C)),g=d?l.form||!!d.closest("form"):!0,v=dL(d),_=l.values[n],b=_===void 0?0:xGe(_,l.min,l.max),j=bLt(n,l.values.length),w=v==null?void 0:v[i.size],N=w?jLt(w,b,i.direction):0;return S.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}% + ${N}px)`},children:[e.jsx(Jxe.ItemSlot,{scope:t.__scopeSlider,children:e.jsx(Qr.span,{role:"slider","aria-label":t["aria-label"]||j,"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})})}),g&&e.jsx(gGe,{name:a??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:_},n)]})});fGe.displayName=tye;var vLt="RadioBubbleInput",gGe=S.forwardRef(({__scopeSlider:t,value:s,...r},n)=>{const a=S.useRef(null),o=Aa(a,n),l=jL(s);return S.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==s&&p){const g=new Event("input",{bubbles:!0});p.call(i,s),i.dispatchEvent(g)}},[l,s]),e.jsx(Qr.input,{style:{display:"none"},...r,ref:o,defaultValue:s})});gGe.displayName=vLt;function _Lt(t=[],s,r){const n=[...t];return n[r]=s,n.sort((a,o)=>a-o)}function xGe(t,s,r){const o=100/(r-s)*(t-s);return GI(o,[0,100])}function bLt(t,s){return s>2?`Value ${t+1} of ${s}`:s===2?["Minimum","Maximum"][t]:void 0}function wLt(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 jLt(t,s,r){const n=t/2,o=Wbe([0,50],[0,n]);return(n-o(s)*r)*r}function kLt(t){return t.slice(0,-1).map((s,r)=>t[r+1]-s)}function NLt(t,s){if(s>0){const r=kLt(t);return Math.min(...r)>=s}return!0}function Wbe(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 SLt(t){return(String(t).split(".")[1]||"").length}function CLt(t,s){const r=Math.pow(10,s);return Math.round(t*r)/r}var yGe=lGe,MLt=mGe,TLt=pGe,ALt=fGe;const Pg=S.forwardRef(({className:t,...s},r)=>e.jsxs(yGe,{ref:r,className:Et("relative flex w-full touch-none select-none items-center",t),...s,children:[e.jsx(MLt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(TLt,{className:"absolute h-full bg-primary"})}),e.jsx(ALt,{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"})]}));Pg.displayName=yGe.displayName;function ELt(t,s,r){return cLt(lLt({unit:"%",width:90},r,t,s),t,s)}const Gbe=({open:t,onClose:s,imageSrc:r,onCropComplete:n,aspectRatio:a=1})=>{const o=S.useRef(null),[l,i]=S.useState(),[d,u]=S.useState(),[p,g]=S.useState(1),[v,_]=S.useState(0),b=S.useCallback(N=>{const{width:C,height:A}=N.currentTarget;i(ELt(C,A,a))},[a]),j=S.useCallback(async()=>{const N=o.current;if(!N||!d)return;const C=document.createElement("canvas"),A=C.getContext("2d");if(!A)return;const I=N.naturalWidth/N.width,L=N.naturalHeight/N.height,R=400;C.width=R,C.height=R,A.imageSmoothingQuality="high";const $=d.x*I,q=d.y*L,U=d.width*I,V=d.height*L,X=v*Math.PI/180,se=C.width/2,te=C.height/2;return A.save(),A.translate(se,te),A.rotate(X),A.scale(p,p),A.translate(-se,-te),A.drawImage(N,$,q,U,V,0,0,R,R),A.restore(),new Promise((Y,de)=>{C.toBlob(ie=>{ie?Y(ie):de(new Error("Canvas is empty"))},"image/jpeg",.95)})},[d,p,v]),w=async()=>{try{const N=await j();N&&(n(N),s())}catch(N){console.error("Error cropping image:",N)}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-lg",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(hLt,{crop:l,onChange:(N,C)=>i(C),onComplete:N=>u(N),aspect:a,circularCrop:!0,className:"max-h-[400px]",children:e.jsx("img",{ref:o,src:r,alt:"Crop preview",style:{transform:`scale(${p}) rotate(${v}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(j5,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Pg,{value:[p],min:.5,max:3,step:.1,onValueChange:([N])=>g(N),className:"flex-1"}),e.jsx(o_,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(jP,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Pg,{value:[v],min:-180,max:180,step:1,onValueChange:([N])=>_(N),className:"flex-1"}),e.jsxs("span",{className:"text-sm text-muted-foreground w-12",children:[v,"°"]})]})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(K,{onClick:w,children:"Save Photo"})]})]})})},PLt=()=>{const{user:t}=Gs(),{toast:s}=Ea(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(null);S.useEffect(()=>{t&&d()},[t]);const d=async()=>{n(!0);try{const{data:g}=await G.from("profiles").select("subscription_status, subscription_product_id, subscription_end_date, is_grandfathered").eq("id",t==null?void 0:t.id).single();g&&i({status:g.subscription_status||"none",productId:g.subscription_product_id,endDate:g.subscription_end_date,isGrandfathered:g.is_grandfathered||!1})}catch(g){console.error("Error loading subscription:",g)}finally{n(!1)}},u=async()=>{o(!0);try{const{data:{session:g}}=await G.auth.getSession();if(!g)throw new Error("Not authenticated");const{data:v,error:_}=await G.functions.invoke("customer-portal",{headers:{Authorization:`Bearer ${g.access_token}`}});if(_)throw _;v!=null&&v.url&&window.open(v.url,"_blank")}catch(g){console.error("Error opening customer portal:",g),s({title:"Error",description:g.message||"Failed to open billing portal",variant:"destructive"})}finally{o(!1)}},p=()=>{if(l!=null&&l.isGrandfathered)return e.jsx(at,{className:"bg-amber-500",children:"Grandfathered"});switch(l==null?void 0:l.status){case"active":return e.jsx(at,{className:"bg-green-500",children:"Active"});case"trialing":return e.jsx(at,{className:"bg-blue-500",children:"Trial"});case"past_due":return e.jsx(at,{variant:"destructive",children:"Past Due"});case"canceled":return e.jsx(at,{variant:"secondary",children:"Canceled"});default:return e.jsx(at,{variant:"outline",children:"No Subscription"})}};return r?e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(mp,{className:"h-5 w-5"}),"Subscription"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(mp,{className:"h-5 w-5"}),"Subscription"]}),e.jsx(yr,{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(As,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(rn,{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."})]})]})},ILt=()=>{const{user:t}=Gs(),s=Lr(),{toast:r}=Ea(),[n]=Ac(),a=n.get("setup")==="true",o=n.get("reset")==="true",{isSupported:l,isSubscribed:i,isLoading:d,subscribe:u,unsubscribe:p}=nqe(),[g,v]=S.useState(!1),[_,b]=S.useState(""),[j,w]=S.useState(!1),[N,C]=S.useState(!1),[A,I]=S.useState(""),[L,R]=S.useState({name:"",email:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}),[$,q]=S.useState(!1),[U,V]=S.useState(!1),[X,se]=S.useState({newPassword:"",confirmPassword:""});S.useEffect(()=>{t&&te()},[t]),S.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,pe,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:ye,error:we}=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(we)throw console.error("Profile query error:",we),we;ye?(console.log("Profile loaded successfully:",ye),R({name:ye.name||"",email:ye.email||"",title:ye.title||"",bio:ye.bio||"",areas_served:ye.areas_served||"",years_experience:((le=ye.years_experience)==null?void 0:le.toString())||"",instagram_url:ye.instagram_url||"",facebook_url:ye.facebook_url||"",linkedin_url:ye.linkedin_url||"",email_signature:ye.email_signature||"",use_email_signature:ye.use_email_signature||!1}),q(ye.digest_opt_out||!1)):(console.warn("No profile found for user"),R({name:((pe=t.user_metadata)==null?void 0:pe.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:Ke}=G.storage.from("avatars").getPublicUrl(`${t.id}/${Ne[0].name}`);b(Ke.publicUrl)}}catch(ye){console.error("Error loading profile:",ye),r({title:"Error",description:ye.message||"Failed to load profile",variant:"destructive"})}},Y=le=>{var ye;const pe=(ye=le.target.files)==null?void 0:ye[0];if(!pe)return;const be=new FileReader;be.onloadend=()=>{I(be.result),C(!0)},be.readAsDataURL(pe),le.target.value=""},de=async le=>{if(t){w(!0);try{const{data:pe}=await G.storage.from("avatars").list(`${t.id}`);pe&&pe.length>0&&await G.storage.from("avatars").remove(pe.map(Ke=>`${t.id}/${Ke.name}`));const ye=`${t.id}/avatar.jpg`,{error:we}=await G.storage.from("avatars").upload(ye,le,{upsert:!0,contentType:"image/jpeg"});if(we)throw we;const{data:Ne}=G.storage.from("avatars").getPublicUrl(ye);b(`${Ne.publicUrl}?t=${Date.now()}`),r({title:"Success",description:"Profile photo updated successfully"})}catch(pe){console.error("Error uploading avatar:",pe),r({title:"Error",description:pe.message||"Failed to upload photo",variant:"destructive"})}finally{w(!1)}}},ie=async()=>{if(!L.name.trim()||!L.email.trim()){r({title:"Error",description:"Name and email are required",variant:"destructive"});return}v(!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{v(!1)}},ae=async()=>{if(!X.newPassword){r({title:"Error",description:"Please enter a new password",variant:"destructive"});return}if(X.newPassword.length<6){r({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}if(X.newPassword!==X.confirmPassword){r({title:"Error",description:"Passwords do not match",variant:"destructive"});return}v(!0);try{const{error:le}=await G.auth.updateUser({password:X.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{v(!1)}};return e.jsx(Ms,{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(tN,{className:"h-4 w-4"}),"Change Password"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Profile Photo"}),e.jsx(yr,{children:"Upload a professional photo for your profile"})]}),e.jsxs(Oe,{className:"flex items-center gap-6",children:[e.jsxs(fn,{className:"h-24 w-24",children:[e.jsx(Ma,{src:_}),e.jsx(gn,{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:Y,disabled:j}),e.jsxs(K,{variant:"outline",onClick:()=>{var le;return(le=document.getElementById("avatar-upload"))==null?void 0:le.click()},disabled:j,children:[e.jsx(Xa,{className:"mr-2 h-4 w-4"}),j?"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(Lt,{children:[e.jsx(zt,{children:"Personal Information"}),e.jsx(yr,{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(Tr,{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:ie,disabled:g,children:[e.jsx(zu,{className:"mr-2 h-4 w-4"}),"Save Changes"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(o0,{className:"h-5 w-5"}),"Email Signature"]}),e.jsx(yr,{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(Zg,{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:ie,disabled:g,children:[e.jsx(zu,{className:"mr-2 h-4 w-4"}),"Save Signature"]})]})]}),e.jsxs(Ee,{id:"change-password-section",children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:a?"Set Your Password":"Change Password"}),e.jsx(yr,{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:X.newPassword,onChange:le=>se({...X,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:X.confirmPassword,onChange:le=>se({...X,confirmPassword:le.target.value}),placeholder:"Re-enter your new password"})]}),e.jsxs(K,{onClick:ae,disabled:g,children:[e.jsx(zu,{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(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[i?e.jsx(cf,{className:"h-5 w-5"}):e.jsx(Z1,{className:"h-5 w-5"}),"Push Notifications"]}),e.jsx(yr,{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(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[$?e.jsx(cP,{className:"h-5 w-5"}):e.jsx(br,{className:"h-5 w-5"}),"Email Preferences"]}),e.jsx(yr,{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=>{V(!0);try{const{error:pe}=await G.from("profiles").update({digest_opt_out:!le}).eq("id",t==null?void 0:t.id);if(pe)throw pe;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(pe){r({title:"Error",description:pe.message||"Failed to update preference",variant:"destructive"})}finally{V(!1)}},disabled:U})]})})]}),e.jsx(d3t,{}),e.jsx(PLt,{})]}),e.jsx(Gbe,{open:N,onClose:()=>C(!1),imageSrc:A,onCropComplete:de,aspectRatio:1})]})})};var LLt="AspectRatio",vGe=S.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}})})});vGe.displayName=LLt;var DLt=vGe;const OLt=DLt;function RLt(){const{user:t}=Gs(),s=ns(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),{data:l,isLoading:i}=Ct({queryKey:["calendar-token",t==null?void 0:t.id],queryFn:async()=>{const{data:b,error:j}=await G.from("profiles").select("calendar_token").eq("id",t==null?void 0:t.id).single();if(j)throw j;return b},enabled:!!t&&a}),d=Ot({mutationFn:async()=>{const b=new Uint8Array(12);crypto.getRandomValues(b);const j=btoa(String.fromCharCode(...b)).replace(/\+/g,"x").replace(/\//g,"y").replace(/=/g,"").substring(0,16),{error:w}=await G.from("profiles").update({calendar_token:j}).eq("id",t==null?void 0:t.id);if(w)throw w;return j},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))},g=()=>{u&&(window.location.href=u.replace("https://","webcal://"))},v=()=>{if(u){const b=u.replace("https://","webcal://"),j=`https://calendar.google.com/calendar/r?cid=${encodeURIComponent(b)}`;window.open(j,"_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(vs,{open:a,onOpenChange:o,children:[e.jsx(Ai,{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(ys,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{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(As,{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(fa,{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:g,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(rn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:v,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(rn,{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(rn,{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(As,{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 fle="Tabs",[FLt]=Tc(fle,[B_]),_Ge=B_(),[zLt,Kbe]=FLt(fle),bGe=S.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:o,orientation:l="horizontal",dir:i,activationMode:d="automatic",...u}=t,p=z_(i),[g,v]=fu({prop:n,onChange:a,defaultProp:o??"",caller:fle});return e.jsx(zLt,{scope:r,baseId:Hd(),value:g,onValueChange:v,orientation:l,dir:p,activationMode:d,children:e.jsx(Qr.div,{dir:p,"data-orientation":l,...u,ref:s})})});bGe.displayName=fle;var wGe="TabsList",jGe=S.forwardRef((t,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=t,o=Kbe(wGe,r),l=_Ge(r);return e.jsx(loe,{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})})});jGe.displayName=wGe;var kGe="TabsTrigger",NGe=S.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...o}=t,l=Kbe(kGe,r),i=_Ge(r),d=MGe(l.baseId,n),u=TGe(l.baseId,n),p=n===l.value;return e.jsx(coe,{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,g=>{!a&&g.button===0&&g.ctrlKey===!1?l.onValueChange(n):g.preventDefault()}),onKeyDown:Mr(t.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&l.onValueChange(n)}),onFocus:Mr(t.onFocus,()=>{const g=l.activationMode!=="manual";!p&&!a&&g&&l.onValueChange(n)})})})});NGe.displayName=kGe;var SGe="TabsContent",CGe=S.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:o,...l}=t,i=Kbe(SGe,r),d=MGe(i.baseId,n),u=TGe(i.baseId,n),p=n===i.value,g=S.useRef(p);return S.useEffect(()=>{const v=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(v)},[]),e.jsx(ud,{present:a||p,children:({present:v})=>e.jsx(Qr.div,{"data-state":p?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":d,hidden:!v,id:u,tabIndex:0,...l,ref:s,style:{...t.style,animationDuration:g.current?"0s":void 0},children:v&&o})})});CGe.displayName=SGe;function MGe(t,s){return`${t}-trigger-${s}`}function TGe(t,s){return`${t}-content-${s}`}var BLt=bGe,AGe=jGe,EGe=NGe,PGe=CGe;const ja=BLt,va=S.forwardRef(({className:t,...s},r)=>e.jsx(AGe,{ref:r,className:Et("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));va.displayName=AGe.displayName;const Ns=S.forwardRef(({className:t,...s},r)=>e.jsx(EGe,{ref:r,className:Et("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}));Ns.displayName=EGe.displayName;const zs=S.forwardRef(({className:t,...s},r)=>e.jsx(PGe,{ref:r,className:Et("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=PGe.displayName;const $Lt={first_timer:Gn,regular:T0,dedicated:ec,veteran:Gi,streak_master:Bh,century:Gi},qLt={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 MAe(t){return t===1?e.jsx(Gi,{className:"h-5 w-5 text-yellow-500"}):t===2?e.jsx(T0,{className:"h-5 w-5 text-gray-400"}):t===3?e.jsx(ec,{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 IGe({showUserStats:t=!0,compact:s=!1,brokerageId:r,title:n="Event Leaderboard"}){const{user:a}=Gs(),{data:o,isLoading:l}=mVe(s?5:10,r),{data:i}=pVe(a==null?void 0:a.id),{data:d}=gVe(a==null?void 0:a.id),{data:u}=fVe(a==null?void 0:a.id);return l?e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Gi,{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,g)=>e.jsx(gs,{className:"h-12 w-full"},g))})})]}):e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Gi,{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(at,{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(Bh,{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 g=$Lt[p.badge_type]||Gn;return e.jsxs(at,{variant:"outline",className:`text-xs ${qLt[p.badge_type]||""}`,title:p.badge_description||"",children:[e.jsx(g,{className:"h-3 w-3 mr-1"}),p.badge_name]},p.id)}),u.length>4&&e.jsxs(at,{variant:"outline",className:"text-xs",children:["+",u.length-4," more"]})]})]}),e.jsxs(ja,{defaultValue:"points",className:"w-full",children:[e.jsxs(va,{className:"w-full mb-3",children:[e.jsx(Ns,{value:"points",className:"flex-1",children:"By Points"}),e.jsx(Ns,{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,g)=>{var v,_,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":""} ${g===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:MAe(g+1)}),e.jsx(fn,{className:"h-8 w-8",children:e.jsx(gn,{className:"text-xs",children:((_=(v=p.profile)==null?void 0:v.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,g)=>g.total_events_attended-p.total_events_attended).map((p,g)=>{var v,_,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":""} ${g===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:MAe(g+1)}),e.jsx(fn,{className:"h-8 w-8",children:e.jsx(gn,{className:"text-xs",children:((_=(v=p.profile)==null?void 0:v.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 ULt(){const t=Lr(),{user:s,isAdmin:r}=Gs(),n=ns(),{data:a,isLoading:o}=Ct({queryKey:["public-events"],queryFn:async()=>{const{data:j,error:w}=await G.from("events").select("*").order("event_date",{ascending:!0});if(w)throw w;return j}}),{data:l}=Ct({queryKey:["my-registrations"],queryFn:async()=>{if(!s)return[];const{data:j,error:w}=await G.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",s.id);if(w)throw w;return j},enabled:!!s}),{data:i}=Ct({queryKey:["event-registration-counts"],queryFn:async()=>{const{data:j,error:w}=await G.from("event_registrations").select("event_id");if(w)throw w;const N={};return j.forEach(C=>{N[C.event_id]=(N[C.event_id]||0)+1}),N}}),d=Ot({mutationFn:async j=>{const{data:w,error:N}=await G.functions.invoke("zoom-register",{body:{event_id:j}});if(N)throw N;if(w!=null&&w.error)throw new Error(w.error);return w},onSuccess:j=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),j!=null&&j.join_url?fe.success("Successfully registered! You'll receive a Zoom confirmation email."):fe.success("Successfully registered for the event!")},onError:j=>{fe.error("Failed to register: "+j.message)}}),u=Ot({mutationFn:async j=>{const{data:w,error:N}=await G.functions.invoke("zoom-unregister",{body:{event_id:j}});if(N)throw N;if(w!=null&&w.error)throw new Error(w.error);return w},onSuccess:()=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),fe.success("Registration cancelled and removed from Zoom")},onError:j=>{fe.error("Failed to cancel: "+j.message)}}),p=j=>l==null?void 0:l.some(w=>w.event_id===j),g=j=>{const w=l==null?void 0:l.find(N=>N.event_id===j);return w==null?void 0:w.zoom_join_url},v=j=>j.capacity?((i==null?void 0:i[j.id])||0)>=j.capacity:!1,_=(a==null?void 0:a.filter(j=>E5(j.event_date)!=="ended"))||[],b=(a==null?void 0:a.filter(j=>E5(j.event_date)==="ended"))||[];return e.jsx(Ms,{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(RLt,{}),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(j=>{const w=E5(j.event_date),N=X_e(j.event_date),C=w==="live",A=w==="starting_soon";return e.jsxs(Ee,{className:`flex flex-col overflow-hidden cursor-pointer hover:shadow-lg transition-all ${C?"border-red-500 ring-2 ring-red-500/20":A?"border-amber-500 ring-2 ring-amber-500/20":"hover:border-primary/50"}`,onClick:()=>t(`/events/${j.id}`),children:[N&&e.jsxs("div",{className:`${C?"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"})]}),C?e.jsxs(e.Fragment,{children:[e.jsx(iN,{className:"h-3.5 w-3.5"}),"LIVE NOW"]}):e.jsxs(e.Fragment,{children:[e.jsx(In,{className:"h-3.5 w-3.5"}),"STARTING SOON"]})]}),j.image_url&&e.jsx(OLt,{ratio:3/2,className:"overflow-hidden",children:e.jsx("img",{src:j.image_url,alt:j.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"})}),e.jsxs(Lt,{children:[e.jsx(zt,{className:"line-clamp-2",children:j.title}),j.description&&e.jsx(yr,{className:"line-clamp-2",children:j.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(j.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(In,{className:"h-4 w-4"}),e6(new Date(j.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[j.id])||0," registered",j.capacity&&` / ${j.capacity} spots`]})]}),e.jsx($P,{className:"flex gap-2",onClick:I=>I.stopPropagation(),children:p(j.id)?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>u.mutate(j.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(g(j.id)||j.zoom_link,"_blank"),children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Join Zoom"]})]}):e.jsx(K,{className:"w-full",onClick:()=>d.mutate(j.id),disabled:d.isPending||v(j),children:v(j)?"Event Full":e.jsxs(e.Fragment,{children:[e.jsx(fa,{className:"h-4 w-4 mr-2"}),"Register"]})})})]},j.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(j=>e.jsx(Ee,{className:"opacity-60 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>t(`/events/${j.id}`),children:e.jsxs(Lt,{children:[e.jsx(zt,{className:"text-base line-clamp-1",children:j.title}),e.jsx(yr,{children:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(j.event_date))})]})},j.id))})]})]}),r&&e.jsx("div",{className:"lg:col-span-1",children:e.jsx(IGe,{showUserStats:!0})})]})]})})}const Ime=[{value:"all",label:"All Roles",icon:hr},{value:"brokerage_manager",label:"Brokerage Managers",icon:LP},{value:"admin",label:"Admins",icon:sh}];function VLt({open:t,onOpenChange:s,resourceType:r,resourceId:n,resourceTitle:a}){var Ue,ut;const{user:o,isAdmin:l,isBrokerageManager:i}=Gs(),[d,u]=S.useState([]),[p,g]=S.useState([]),[v,_]=S.useState([]),[b,j]=S.useState([]),[w,N]=S.useState(""),[C,A]=S.useState(""),[I,L]=S.useState(""),[R,$]=S.useState(!1),[q,U]=S.useState(!1),[V,X]=S.useState("agents"),[se,te]=S.useState("all"),[Y,de]=S.useState({}),ie=l||i;S.useEffect(()=>{t&&o&&(l?ae():le())},[t,o,l]),S.useEffect(()=>{t||(_([]),j([]),N(""),A(""),L(""),X("agents"),te("all"))},[t]);const ae=async()=>{if(o){$(!0);try{const{data:De,error:Dt}=await G.from("brokerages").select("id, name").order("name");if(Dt)throw Dt;const he=1e3,Ve={};let nt=0,Qe=!0;for(;Qe;){const{data:qe,error:lt}=await G.from("profiles").select("brokerage_id").range(nt*he,(nt+1)*he-1);if(lt)throw lt;qe==null||qe.forEach(We=>{We.brokerage_id&&(Ve[We.brokerage_id]=(Ve[We.brokerage_id]||0)+1)}),Qe=(qe==null?void 0:qe.length)===he,nt++}g((De==null?void 0:De.map(qe=>({...qe,agent_count:Ve[qe.id]||0})))||[]);const ke=[];for(nt=0,Qe=!0;Qe;){const{data:qe,error:lt}=await G.from("profiles").select("id, name, email, brokerage_id, brokerages(name)").neq("id",o.id).order("name").range(nt*he,(nt+1)*he-1);if(lt)throw lt;qe&&ke.push(...qe),Qe=(qe==null?void 0:qe.length)===he,nt++}const ot={};for(nt=0,Qe=!0;Qe;){const{data:qe,error:lt}=await G.from("user_roles").select("user_id, role").range(nt*he,(nt+1)*he-1);if(lt)throw lt;qe==null||qe.forEach(We=>{ot[We.user_id]||(ot[We.user_id]=[]),ot[We.user_id].push(We.role)}),Qe=(qe==null?void 0:qe.length)===he,nt++}de(ot),u(ke.map(qe=>{var lt;return{id:qe.id,name:qe.name,email:qe.email,brokerage_name:((lt=qe.brokerages)==null?void 0:lt.name)||"No Brokerage",roles:ot[qe.id]||[]}}))}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:Dt,error:he}=await G.from("profiles").select("id, name, email").eq("brokerage_id",De.brokerage_id).neq("id",o.id).order("name");if(he)throw he;u(Dt||[])}catch(De){console.error("Error loading agents:",De),fe.error("Failed to load agents")}finally{$(!1)}}},pe=d.filter(De=>{var he;const Dt=De.name.toLowerCase().includes(w.toLowerCase())||De.email.toLowerCase().includes(w.toLowerCase())||((he=De.brokerage_name)==null?void 0:he.toLowerCase().includes(w.toLowerCase()));if(l&&se!=="all"){const Ve=Y[De.id]||[];return Dt&&Ve.includes(se)}return Dt}),be=p.filter(De=>De.name.toLowerCase().includes(C.toLowerCase())),ye=()=>{v.length===pe.length?_([]):_(pe.map(De=>De.id))},we=()=>{b.length===be.length?j([]):j(be.map(De=>De.id))},Ne=De=>{if(!ie){_([De]);return}_(Dt=>Dt.includes(De)?Dt.filter(he=>he!==De):[...Dt,De])},Ke=De=>{j(Dt=>Dt.includes(De)?Dt.filter(he=>he!==De):[...Dt,De])},_e=async()=>{if(!(v.length>0||b.length>0)){fe.error("Please select at least one agent or brokerage to share with");return}U(!0);try{const{data:Dt,error:he}=await G.functions.invoke("send-share-notification",{body:{recipientIds:v,brokerageIds:b,resourceType:r,resourceId:n,resourceTitle:a,message:I.trim()||void 0}});if(he)throw he;const Ve=(Dt==null?void 0:Dt.sharesCreated)||v.length;fe.success(`Shared with ${Ve} agent${Ve!==1?"s":""}`),s(!1)}catch(Dt){console.error("Error sharing resource:",Dt),fe.error("Failed to share resource")}finally{U(!1)}},Me=De=>De.split(" ").map(Dt=>Dt[0]).join("").toUpperCase().slice(0,2),Te=De=>{const Dt=Y[De]||[];return Dt.includes("admin")?e.jsx(at,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Admin"}):Dt.includes("brokerage_manager")?e.jsx(at,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Manager"}):null},Fe=v.length+b.length,Ae=se!=="all"?pe.length:null;return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-lg max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{className:"flex-shrink-0",children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Ta,{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(ja,{value:V,onValueChange:X,className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(va,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[e.jsxs(Ns,{value:"agents",className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{children:"Agents"}),v.length>0&&e.jsx(at,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:v.length})]}),e.jsxs(Ns,{value:"brokerages",className:"flex items-center gap-2",children:[e.jsx(Ca,{className:"h-4 w-4"}),e.jsx("span",{children:"Brokerages"}),b.length>0&&e.jsx(at,{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(xn,{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:w,onChange:De=>N(De.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:se,onValueChange:te,children:[e.jsxs(Js,{className:"w-[180px]",children:[e.jsx(Ux,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(sr,{placeholder:"Filter by role"})]}),e.jsx(er,{children:Ime.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:ye,className:"text-xs h-8",disabled:pe.length===0,children:[e.jsx(hr,{className:"h-3.5 w-3.5 mr-1.5"}),v.length===pe.length&&pe.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=Ime.find(De=>De.value===se))==null?void 0:Ue.label]}),e.jsxs("span",{className:"font-medium",children:[v.length," selected"]})]})]}),e.jsx(Fi,{className:"h-[300px] border rounded-lg",children:R?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):pe.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=Ime.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:pe.map(De=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${v.includes(De.id)?"bg-accent":""}`,onClick:()=>Ne(De.id),children:[e.jsx(zo,{checked:v.includes(De.id),onCheckedChange:()=>Ne(De.id),className:"flex-shrink-0"}),e.jsx(fn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(gn,{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(xn,{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:C,onChange:De=>A(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:we,className:"text-xs h-8",disabled:be.length===0,children:[e.jsx(Ca,{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(Fi,{className:"h-[250px] border rounded-lg",children:R?e.jsx("div",{className:"flex items-center justify-center h-[180px]",children:e.jsx(As,{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(Ca,{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:()=>Ke(De.id),children:[e.jsx(zo,{checked:b.includes(De.id),onCheckedChange:()=>Ke(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(Ca,{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(xn,{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:w,onChange:De=>N(De.target.value),className:"pl-9"})]}),ie&&e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:ye,className:"text-xs h-8",disabled:pe.length===0,children:[e.jsx(hr,{className:"h-3.5 w-3.5 mr-1.5"}),v.length===pe.length&&pe.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[v.length," selected"]})]}),e.jsx(Fi,{className:"h-[300px] border rounded-lg",children:R?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):pe.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:pe.map(De=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${v.includes(De.id)?"bg-accent":""}`,onClick:()=>Ne(De.id),children:[e.jsx(zo,{checked:v.includes(De.id),onCheckedChange:()=>Ne(De.id),className:"flex-shrink-0"}),e.jsx(fn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(gn,{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(Tr,{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:_e,disabled:Fe===0||q,children:q?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Sharing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Share"]})})]})]})]})})}function kM({resourceType:t,resourceId:s,resourceTitle:r,variant:n="outline",size:a="sm",className:o=""}){const[l,i]=S.useState(!1),{user:d}=Gs();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(VLt,{open:l,onOpenChange:i,resourceType:t,resourceId:s,resourceTitle:r})]}):null}function HLt(){const{eventId:t}=Co(),s=Lr(),{user:r}=Gs(),[n,a]=S.useState(null),[o,l]=S.useState(null),[i,d]=S.useState(0),[u,p]=S.useState(!0),[g,v]=S.useState(!1);S.useEffect(()=>{t&&_()},[t,r]);const _=async()=>{try{const{data:A,error:I}=await G.from("events").select("*").eq("id",t).single();if(I)throw I;a(A);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(A){console.error("Error loading event:",A),fe.error("Failed to load event"),s("/events")}finally{p(!1)}},b=async()=>{if(!(!r||!n)){v(!0);try{if(o){const{error:A}=await G.functions.invoke("zoom-unregister",{body:{event_id:n.id}});if(A)throw A;fe.success("Successfully cancelled registration"),l(null),d(I=>I-1)}else{const{data:A,error:I}=await G.functions.invoke("zoom-register",{body:{event_id:n.id}});if(I)throw I;fe.success("Successfully registered for event!"),l({id:A.registration_id,zoom_join_url:A.zoom_join_url}),d(L=>L+1)}}catch(A){console.error("Registration error:",A),fe.error(o?"Failed to cancel registration":"Failed to register for event")}finally{v(!1)}}},j=A=>{var I,L,R;if(A.includes("iframe.mediadelivery.net")||A.includes("video.bunnycdn.com")){const $=A.match(/embed\/(\d+)\/([a-f0-9-]+)/);if($)return`https://iframe.mediadelivery.net/embed/${$[1]}/${$[2]}?autoplay=false&preload=true`}if(A.includes("youtube.com")||A.includes("youtu.be")){const $=A.includes("youtu.be")?(I=A.split("youtu.be/")[1])==null?void 0:I.split("?")[0]:(L=A.split("v=")[1])==null?void 0:L.split("&")[0];if($)return`https://www.youtube.com/embed/${$}`}if(A.includes("vimeo.com")){const $=(R=A.split("vimeo.com/")[1])==null?void 0:R.split("?")[0];if($)return`https://player.vimeo.com/video/${$}`}return A};if(u)return e.jsx(Ms,{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(Ms,{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 w=Yx(new Date(n.event_date)),N=n.capacity&&i>=n.capacity,C=(o==null?void 0:o.zoom_join_url)||n.zoom_link;return e.jsx(Ms,{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(Ka,{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"}),w&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(at,{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(kM,{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(gm,{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:j(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:e6(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(fi,{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:[!w&&e.jsx(e.Fragment,{children:o?e.jsxs(e.Fragment,{children:[e.jsxs(K,{className:"w-full gap-2",onClick:()=>window.open(C,"_blank"),children:[e.jsx(rn,{className:"h-4 w-4"}),"Join Event"]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:b,disabled:g,children:[g?e.jsx(As,{className:"h-4 w-4 animate-spin mr-2"}):null,"Cancel Registration"]})]}):e.jsx(K,{className:"w-full gap-2",onClick:b,disabled:g||(N??!1),children:g?e.jsx(As,{className:"h-4 w-4 animate-spin"}):N?"Event Full":"Register Now"})}),w&&o&&e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:()=>window.open(n.zoom_link,"_blank"),children:[e.jsx(rn,{className:"h-4 w-4"}),"View Recording"]})]})]})})})]})]})})}const WLt=()=>{const{user:t,isAdmin:s}=Gs(),r=Lr(),[n,a]=S.useState([]),[o,l]=S.useState(!0),[i,d]=S.useState(""),[u,p]=S.useState("all"),[g,v]=S.useState(new Set);S.useEffect(()=>{_()},[t]);const _=async()=>{try{const{data:C}=await G.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),A=(C==null?void 0:C.map(V=>V.tag))||[],{data:I,error:L}=await G.from("app_tiles").select("*").order("name");if(L)throw L;const{data:R}=await G.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),$=new Set((R==null?void 0:R.map(V=>V.app_id))||[]);v($);const U=((I==null?void 0:I.filter(V=>!V.required_tags||V.required_tags.length===0?!0:V.required_tags.some(X=>A.includes(X))))||[]).sort((V,X)=>V.name==="LevelUp Members Portal"?-1:X.name==="LevelUp Members Portal"?1:0);a(U)}catch(C){console.error("Error loading apps:",C),fe.error("Failed to load apps")}finally{l(!1)}},b=async C=>{var I;const A=window.open("about:blank","_blank");try{const{data:L,error:R}=await G.auth.getSession();if(R||!L.session){A==null||A.close(),fe.error("Session expired. Please refresh the page and try again.");return}const $=L.session.access_token;await G.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:C.app_id,app_name:C.name,user_agent:navigator.userAgent});const{data:q,error:U}=await G.functions.invoke("sso-launch",{body:{app_id:C.app_id},headers:{Authorization:`Bearer ${$}`}});if(U)throw U;q!=null&&q.redirect_url?A&&!A.closed?(A.location.href=q.redirect_url,(I=A.focus)==null||I.call(A)):window.location.assign(q.redirect_url):(A==null||A.close(),fe.error("Launch link unavailable"))}catch(L){A==null||A.close(),console.error("Error launching app:",L),fe.error("Failed to launch app. Please try again.")}},j=async(C,A)=>{C.stopPropagation();const I=g.has(A);try{if(I){const{error:L}=await G.from("user_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("app_id",A);if(L)throw L;v(R=>{const $=new Set(R);return $.delete(A),$}),fe.success("Removed from favorites")}else{const{error:L}=await G.from("user_favorites").insert({user_id:t==null?void 0:t.id,app_id:A});if(L)throw L;v(R=>new Set(R).add(A)),fe.success("Added to favorites")}}catch(L){console.error("Error toggling favorite:",L),fe.error("Failed to update favorites")}},w=n.filter(C=>{var I;const A=C.name.toLowerCase().includes(i.toLowerCase())||((I=C.description)==null?void 0:I.toLowerCase().includes(i.toLowerCase()));return u==="favorites"?A&&g.has(C.id):A}),N=[{id:"all",label:"All"},{id:"favorites",label:"Favorites"}];return o?e.jsx(Ms,{title:"Apps",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..."})]})})}):e.jsxs(Ms,{title:"Apps",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"}),e.jsxs("div",{className:"relative max-w-sm w-full",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search apps...",className:"pl-10 bg-muted/50 border-0 focus-visible:ring-1",value:i,onChange:C=>d(C.target.value)})]})]}),e.jsx("div",{className:"flex gap-6 border-b border-border mb-8",children:N.map(C=>e.jsxs("button",{onClick:()=>p(C.id),className:Et("pb-3 text-sm font-medium transition-colors relative",u===C.id?"text-primary":"text-muted-foreground hover:text-foreground"),children:[C.label,u===C.id&&e.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]},C.id))}),w.length===0?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(Dg,{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(Fu,{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:w.map(C=>{const A=g.has(C.id),I=C.name.toLowerCase().includes("agent review")||C.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(C),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:C.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:C.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:C.description})]}),e.jsx("button",{className:Et("flex-shrink-0 p-1 transition-colors",A?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:L=>j(L,C.id),children:e.jsx(Dg,{className:Et("h-5 w-5",A&&"fill-current")})})]}),I&&e.jsx("a",{href:"https://forms.gle/vXnrzgSnPbw7CKPV6",target:"_blank",rel:"noopener noreferrer",onClick:L=>L.stopPropagation(),className:"mt-3 text-sm text-primary hover:underline flex items-center gap-1",children:"Create your account with this link →"})]},C.id)})})]})},GLt=()=>{const t=Lr(),[s,r]=S.useState(""),[n,a]=S.useState("all"),[o,l]=S.useState("all"),[i,d]=S.useState("grid"),{data:u=[]}=Ct({queryKey:["template-categories"],queryFn:async()=>{const{data:N,error:C}=await G.from("template_categories").select("*").order("name");if(C)throw C;return N}}),{data:p=[]}=Ct({queryKey:["template-types"],queryFn:async()=>{const{data:N,error:C}=await G.from("template_types").select("*").order("name");if(C)throw C;return N}}),{data:g=[],isLoading:v}=Ct({queryKey:["canva-templates"],queryFn:async()=>{const{data:N,error:C}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(C)throw C;const{data:A,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(V=>{$.set(V.template_id,($.get(V.template_id)||0)+1)});const q=new Map;return R==null||R.forEach(V=>{q.set(V.template_id,(q.get(V.template_id)||0)+1)}),(N||[]).map(V=>({...V,links:(A||[]).filter(X=>X.template_id===V.id)||[],likesCount:$.get(V.id)||0,commentsCount:q.get(V.id)||0}))}}),_=g.filter(N=>{var L;const C=N.name.toLowerCase().includes(s.toLowerCase())||((L=N.description)==null?void 0:L.toLowerCase().includes(s.toLowerCase())),A=n==="all"||N.category_id===n,I=o==="all"||N.type_id===o;return C&&A&&I}),b=()=>{r(""),a("all"),l("all")},j=s||n!=="all"||o!=="all",w=N=>{t(`/templates/${N}`)};return e.jsx(Ms,{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(xn,{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:N=>r(N.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:n,onValueChange:a,children:[e.jsx(Js,{className:"w-full sm:w-48",children:e.jsx(sr,{placeholder:"All Categories"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Categories"}),u.map(N=>e.jsx(At,{value:N.id,children:N.name},N.id))]})]}),e.jsxs(tr,{value:o,onValueChange:l,children:[e.jsx(Js,{className:"w-full sm:w-48",children:e.jsx(sr,{placeholder:"All Types"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Types"}),p.map(N=>e.jsx(At,{value:N.id,children:N.name},N.id))]})]}),e.jsxs("div",{className:"flex gap-2",children:[j&&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(pp,{className:"h-4 w-4"})}),e.jsx(K,{variant:i==="list"?"secondary":"outline",size:"icon",onClick:()=>d("list"),className:"rounded-full",children:e.jsx(qh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[_.length," template",_.length!==1?"s":""," found"]}),v&&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((N,C)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(gs,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(gs,{className:"h-5 w-3/4 mb-2"}),e.jsx(gs,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(gs,{className:"h-5 w-16"}),e.jsx(gs,{className:"h-5 w-20"})]})]})},C))}),!v&&_.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:j?"No templates match your filters":"No templates available yet"}),j&&e.jsx(K,{variant:"outline",onClick:b,children:"Clear Filters"})]}),!v&&_.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(N=>e.jsxs(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${i==="list"?"flex flex-row":""}`,onClick:()=>w(N.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${i==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[N.preview_image_url?e.jsx("img",{src:N.preview_image_url,alt:N.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"}),N.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(at,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm !text-secondary",children:[e.jsx(Io,{className:"h-3 w-3"}),N.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:N.name}),N.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:Xie(N.description)}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[N.category&&e.jsx(at,{variant:"secondary",className:"text-xs",children:N.category.name}),N.type&&e.jsx(at,{variant:"outline",className:"text-xs",children:N.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(hu,{className:"h-3.5 w-3.5"}),N.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pc,{className:"h-3.5 w-3.5"}),N.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:C=>{C.stopPropagation(),w(N.id)},children:[e.jsx(rn,{className:"h-4 w-4"}),"View Template"]})]})]},N.id))})]})})};var KLt="Separator",TAe="horizontal",ZLt=["horizontal","vertical"],LGe=S.forwardRef((t,s)=>{const{decorative:r,orientation:n=TAe,...a}=t,o=YLt(n)?n:TAe,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})});LGe.displayName=KLt;function YLt(t){return ZLt.includes(t)}var DGe=LGe;const sc=S.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...n},a)=>e.jsx(DGe,{ref:a,decorative:r,orientation:s,className:Et("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));sc.displayName=DGe.displayName;const RL=()=>({trackEngagement:S.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)}},[])}),XLt=()=>{const{templateId:t}=Co(),s=Lr(),{user:r,isAdmin:n}=Gs(),{toast:a}=Ea(),o=ns(),{trackEngagement:l}=RL(),[i,d]=S.useState(""),{data:u,isLoading:p}=Ct({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:g=[]}=Ct({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});S.useEffect(()=>{u&&l("template",u.id,u.name,"view")},[u==null?void 0:u.id]);const{data:v=[]}=Ct({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:_=[]}=Ct({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=Ot({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"})}}),j=Ot({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"})}}),w=Ot({mutationFn:async()=>{const I=v.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]})}}),N=v.some(I=>I.user_id===(r==null?void 0:r.id)),C=I=>I.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),A=I=>{I.preventDefault(),!(!i.trim()||!r)&&b.mutate(i.trim())};return p?e.jsx(Ms,{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(Ms,{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(Ka,{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(at,{variant:"secondary",children:u.category.name}),u.type&&e.jsx(at,{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(Ua,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(kM,{resourceType:"template",resourceId:u.id,resourceTitle:u.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:N?"default":"outline",className:"gap-2 rounded-full",onClick:()=>w.mutate(),disabled:!r||w.isPending,children:[e.jsx(hu,{className:`h-4 w-4 ${N?"fill-current":""}`}),v.length," ",v.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(Io,{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(rn,{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(Sn,{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(Sn,{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(gi,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),g.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(cl,{className:"h-4 w-4"}),"Related Toolkits"]}),e.jsx("div",{className:"grid gap-2",children:g.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(cl,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"font-medium",children:I.name})]},I.id))})]})}),e.jsx(sc,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(pc,{className:"h-5 w-5"}),"Comments (",_.length,")"]}),r?e.jsxs("form",{onSubmit:A,className:"flex gap-2",children:[e.jsx(Tr,{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(Ta,{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(fn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(gn,{className:"text-sm",children:C(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:()=>j.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(Ms,{title:"Templates",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Io,{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"})})]})})},QLt=()=>{const{user:t}=Gs(),[s,r]=S.useState(""),[n,a]=S.useState("all"),{data:o=[]}=Ct({queryKey:["academy-categories"],queryFn:async()=>{const{data:v,error:_}=await G.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(_)throw _;return v}}),{data:l=[],isLoading:i}=Ct({queryKey:["academy-videos"],queryFn:async()=>{const{data:v,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:j}=await G.from("academy_resources").select("*").order("sort_order");if(j)throw j;return v.map(N=>({...N,resources:(b==null?void 0:b.filter(C=>C.video_id===N.id))||[]}))}}),{data:d=[]}=Ct({queryKey:["academy-video-likes"],queryFn:async()=>{const{data:v,error:_}=await G.from("academy_video_likes").select("video_id, user_id");if(_)throw _;return v}}),u=l.filter(v=>{var j;const _=s===""||v.title.toLowerCase().includes(s.toLowerCase())||((j=v.description)==null?void 0:j.toLowerCase().includes(s.toLowerCase())),b=n==="all"||v.category_id===n;return _&&b}),p=v=>d.filter(_=>_.video_id===v).length,g=v=>d.some(_=>_.video_id===v&&_.user_id===(t==null?void 0:t.id));return e.jsx(Ms,{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(xn,{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:v=>r(v.target.value),className:"pl-10"})]})}),e.jsx(ja,{value:n,onValueChange:a,children:e.jsxs(va,{className:"w-full justify-start flex-wrap h-auto gap-2 bg-transparent p-0",children:[e.jsx(Ns,{value:"all",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:"All Videos"}),o.map(v=>e.jsx(Ns,{value:v.id,className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:v.name},v.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(v=>e.jsx(vo,{to:`/academy/${v.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:[v.thumbnail_url?e.jsx("img",{src:v.thumbnail_url,alt:v.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(dl,{className:"h-8 w-8 text-primary-foreground ml-1"})})}),v.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(In,{className:"h-3 w-3"}),v.duration]})]}),e.jsxs(Lt,{className:"pb-2",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsx(zt,{className:"text-lg line-clamp-2",children:v.title})}),v.category&&e.jsx(at,{variant:"secondary",className:"w-fit",children:v.category.name})]}),e.jsxs(Oe,{className:"pt-0",children:[v.description&&e.jsx(yr,{className:"line-clamp-2",children:v.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(hu,{className:`h-4 w-4 ${g(v.id)?"fill-primary text-primary":""}`}),p(v.id)]}),v.resources&&v.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-4 w-4"}),v.resources.length]})]})]})]})},v.id))})]})})};function OGe({resourceType:t,resourceId:s}){const{data:r=[]}=Ct({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(Rl,{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(at,{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(Rl,{className:"h-3 w-3"}),n.name]})},n.id))})]})}const JLt=(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},eDt=()=>{const{videoId:t}=Co();Lr();const{user:s,isAdmin:r}=Gs(),{toast:n}=Ea(),a=ns(),{trackEngagement:o}=RL(),[l,i]=S.useState(""),{data:d,isLoading:u}=Ct({queryKey:["academy-video",t],queryFn:async()=>{const{data:A,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{...A,resources:L||[]}},enabled:!!t});S.useEffect(()=>{d&&o("academy_video",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:p=[]}=Ct({queryKey:["academy-video-likes",t],queryFn:async()=>{const{data:A,error:I}=await G.from("academy_video_likes").select("*").eq("video_id",t);if(I)throw I;return A},enabled:!!t}),{data:g=[]}=Ct({queryKey:["academy-video-comments",t],queryFn:async()=>{const{data:A,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(A.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 A.map(q=>({...q,user_name:$.get(q.user_id)||"Unknown User"}))},enabled:!!t}),v=Ot({mutationFn:async A=>{const{error:I}=await G.from("academy_video_comments").insert({video_id:t,user_id:s.id,content:A});if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),i(""),n({title:"Comment added!"})},onError:A=>{n({title:"Error adding comment",description:A.message,variant:"destructive"})}}),_=Ot({mutationFn:async A=>{const{error:I}=await G.from("academy_video_comments").delete().eq("id",A);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),n({title:"Comment deleted"})}}),b=Ot({mutationFn:async()=>{const A=p.find(I=>I.user_id===(s==null?void 0:s.id));if(A){const{error:I}=await G.from("academy_video_likes").delete().eq("id",A.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]})}}),j=p.some(A=>A.user_id===(s==null?void 0:s.id)),w=A=>{switch(A==null?void 0:A.toLowerCase()){case"pdf":return"📄";case"pptx":case"ppt":return"📊";case"xlsx":case"xls":return"📈";case"docx":case"doc":return"📝";case"zip":return"📦";default:return"📁"}},N=A=>A.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),C=A=>{A.preventDefault(),!(!l.trim()||!s)&&v.mutate(l.trim())};return u?e.jsx(Ms,{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(Ms,{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(Ka,{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:JLt(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(rn,{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(at,{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(Ua,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(kM,{resourceType:"academy_video",resourceId:d.id,resourceTitle:d.title}),e.jsxs(K,{variant:j?"default":"outline",className:"gap-2 w-fit",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(hu,{className:`h-4 w-4 ${j?"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(Sn,{className:"h-4 w-4"}),"Resources"]}),e.jsx("div",{className:"grid gap-2",children:d.resources.map(A=>e.jsxs("a",{href:A.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:w(A.file_type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:A.title}),e.jsx("p",{className:"text-xs text-muted-foreground uppercase",children:A.file_type})]}),e.jsx(gi,{className:"h-4 w-4 text-muted-foreground"})]},A.id))})]})}),e.jsx(OGe,{resourceType:"academy_video",resourceId:d.id}),e.jsx(sc,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(pc,{className:"h-5 w-5"}),"Comments (",g.length,")"]}),s?e.jsxs("form",{onSubmit:C,className:"flex gap-2",children:[e.jsx(Tr,{placeholder:"Add a comment...",value:l,onChange:A=>i(A.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()||v.isPending,children:e.jsx(Ta,{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:g.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!"})})}):g.map(A=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(fn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(gn,{className:"text-sm",children:N(A.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:A.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Sd(new Date(A.created_at),{addSuffix:!0})}),A.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(A.id),children:e.jsx(jr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:A.content})]})]})})},A.id))})]})]})}):e.jsx(Ms,{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 tDt(){const t=Lr(),[s,r]=S.useState(""),{data:n,isLoading:a}=Ct({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}=Ct({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}=Ct({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}=Ct({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,g=_=>(i==null?void 0:i.filter(b=>b.kit_id===_).length)||0,v=_=>{t(`/toolbox/${_}`)};return e.jsx(Ms,{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(xn,{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(gs,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(gs,{className:"h-5 w-3/4 mb-2"}),e.jsx(gs,{className:"h-4 w-full mb-4"}),e.jsx(gs,{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(cl,{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,j=p(_.id),w=g(_.id);return e.jsxs(Ee,{className:"group overflow-hidden cursor-pointer hover:shadow-lg transition-all duration-200",onClick:()=>v(_.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(cl,{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:Xie(_.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(Sn,{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(hu,{className:"h-3.5 w-3.5"}),j]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pc,{className:"h-3.5 w-3.5"}),w]})]})]})]})]},_.id)})})]})})}const sDt=()=>{const{kitId:t}=Co(),{user:s,isAdmin:r}=Gs(),{toast:n}=Ea(),a=ns(),{trackEngagement:o}=RL(),[l,i]=S.useState(""),{data:d,isLoading:u}=Ct({queryKey:["resource-kit-detail",t],queryFn:async()=>{const{data:A,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{...A,files:L||[],links:R||[]}},enabled:!!t});S.useEffect(()=>{d&&o("toolbox",d.id,d.name,"view")},[d==null?void 0:d.id]);const{data:p=[]}=Ct({queryKey:["resource-kit-likes",t],queryFn:async()=>{const{data:A,error:I}=await G.from("resource_kit_likes").select("*").eq("kit_id",t);if(I)throw I;return A},enabled:!!t}),{data:g=[]}=Ct({queryKey:["resource-kit-comments",t],queryFn:async()=>{const{data:A,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(A.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 A.map(q=>({...q,user_name:$.get(q.user_id)||"Unknown User"}))},enabled:!!t}),v=Ot({mutationFn:async A=>{const{error:I}=await G.from("resource_kit_comments").insert({kit_id:t,user_id:s.id,content:A});if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),i(""),n({title:"Comment added!"})},onError:A=>{n({title:"Error adding comment",description:A.message,variant:"destructive"})}}),_=Ot({mutationFn:async A=>{const{error:I}=await G.from("resource_kit_comments").delete().eq("id",A);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),n({title:"Comment deleted"})}}),b=Ot({mutationFn:async()=>{const A=p.find(I=>I.user_id===(s==null?void 0:s.id));if(A){const{error:I}=await G.from("resource_kit_likes").delete().eq("id",A.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]})}}),j=p.some(A=>A.user_id===(s==null?void 0:s.id)),w=A=>A.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),N=A=>A?A<1024?A+" B":A<1024*1024?(A/1024).toFixed(1)+" KB":(A/(1024*1024)).toFixed(1)+" MB":"",C=A=>{A.preventDefault(),!(!l.trim()||!s)&&v.mutate(l.trim())};return u?e.jsx(Ms,{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(Ms,{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(Ka,{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(Ua,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(kM,{resourceType:"resource_kit",resourceId:d.id,resourceTitle:d.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:j?"default":"outline",className:"gap-2 rounded-full",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(hu,{className:`h-4 w-4 ${j?"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(Sn,{className:"h-4 w-4"}),"Included Resources (",d.files.length,")"]}),e.jsx("div",{className:"grid gap-2",children:d.files.map(A=>e.jsxs("a",{href:A.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(Sn,{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(gi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},A.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(rn,{className:"h-4 w-4"}),"Canva Templates (",d.links.length,")"]}),e.jsx("div",{className:"grid gap-2",children:d.links.map(A=>e.jsxs("a",{href:A.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(rn,{className:"h-4 w-4 text-purple-600"})}),e.jsx("div",{className:"font-medium text-sm",children:A.title})]}),e.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-primary transition-colors",children:"Open in Canva"})]},A.id))})]})}),e.jsx(OGe,{resourceType:"resource_kit",resourceId:d.id}),e.jsx(sc,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(pc,{className:"h-5 w-5"}),"Comments (",g.length,")"]}),s?e.jsxs("form",{onSubmit:C,className:"flex gap-2",children:[e.jsx(Tr,{placeholder:"Add a comment...",value:l,onChange:A=>i(A.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()||v.isPending,children:e.jsx(Ta,{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:g.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!"})})}):g.map(A=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(fn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(gn,{className:"text-sm",children:w(A.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:A.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Sd(new Date(A.created_at),{addSuffix:!0})}),A.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(A.id),children:e.jsx(jr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:A.content})]})]})})},A.id))})]})]})}):e.jsx(Ms,{title:"Toolbox",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(cl,{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"})})]})})},rDt=()=>{const t=Lr(),[s,r]=S.useState(""),[n,a]=S.useState("grid"),{data:o=[],isLoading:l}=Ct({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:g,error:v}=await G.from("social_swag_links").select("*").order("sort_order");if(v)throw v;const{data:_}=await G.from("social_swag_likes").select("swag_id"),{data:b}=await G.from("social_swag_comments").select("swag_id"),j=new Map;_==null||_.forEach(C=>{j.set(C.swag_id,(j.get(C.swag_id)||0)+1)});const w=new Map;return b==null||b.forEach(C=>{w.set(C.swag_id,(w.get(C.swag_id)||0)+1)}),(u||[]).map(C=>({...C,links:(g||[]).filter(A=>A.swag_id===C.id)||[],likesCount:j.get(C.id)||0,commentsCount:w.get(C.id)||0}))}}),i=o.filter(u=>{var g;return u.title.toLowerCase().includes(s.toLowerCase())||((g=u.description)==null?void 0:g.toLowerCase().includes(s.toLowerCase()))}),d=u=>{t(`/social-swag/${u}`)};return e.jsx(Ms,{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(xn,{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(pp,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(qh,{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(gs,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(gs,{className:"h-5 w-3/4 mb-2"}),e.jsx(gs,{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(at,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm",children:[e.jsx(Io,{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(hu,{className:"h-3.5 w-3.5"}),u.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pc,{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(rn,{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),g=s>1&&(u||!d),v=function(){n&&o(n)},_=function(){a&&o(a)};return e.jsx(ODt,{displayMonth:t.displayMonth,hideNext:p,hidePrevious:g,nextMonth:a,previousMonth:n,onPreviousClick:v,onNextClick:_})}function RDt(t){var s,r=Bl(),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:zGe,u;return a?u=e.jsx(d,{id:t.id,displayMonth:t.displayMonth}):l==="dropdown"?u=e.jsx(AAe,{displayMonth:t.displayMonth,id:t.id}):l==="dropdown-buttons"?u=e.jsxs(e.Fragment,{children:[e.jsx(AAe,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(EAe,{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(EAe,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:n.caption,style:o.caption,children:u})}function FDt(t){var s=Bl(),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 zDt(t,s,r){for(var n=r?K0(new Date):ah(new Date,{locale:t,weekStartsOn:s}),a=[],o=0;o<7;o++){var l=hl(n,o);a.push(l)}return a}function BDt(){var t=Bl(),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=zDt(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,g){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})},g)})]})}function $Dt(){var t,s=Bl(),r=s.classNames,n=s.styles,a=s.components,o=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:BDt;return e.jsx("thead",{style:n.head,className:r.head,children:e.jsx(o,{})})}function qDt(t){var s=Bl(),r=s.locale,n=s.formatters.formatDay;return e.jsx(e.Fragment,{children:n(t.date,{locale:r})})}var Zbe=S.createContext(void 0);function UDt(t){if(!FL(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(Zbe.Provider,{value:s,children:t.children})}return e.jsx(VDt,{initialProps:t.initialProps,children:t.children})}function VDt(t){var s=t.initialProps,r=t.children,n=s.selected,a=s.min,o=s.max,l=function(u,p,g){var v,_;(v=s.onDayClick)===null||v===void 0||v.call(s,u,p,g);var b=!!(p.selected&&a&&(n==null?void 0:n.length)===a);if(!b){var j=!!(!p.selected&&o&&(n==null?void 0:n.length)===o);if(!j){var w=n?RGe([],n):[];if(p.selected){var N=w.findIndex(function(C){return ll(u,C)});w.splice(N,1)}else w.push(u);(_=s.onSelect)===null||_===void 0||_.call(s,w,u,p,g)}}},i={disabled:[]};n&&i.disabled.push(function(u){var p=o&&n.length>o-1,g=n.some(function(v){return ll(v,u)});return!!(p&&!g)});var d={selected:n,onDayClick:l,modifiers:i};return e.jsx(Zbe.Provider,{value:d,children:r})}function Ybe(){var t=S.useContext(Zbe);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function HDt(t,s){var r=s||{},n=r.from,a=r.to;return n&&a?ll(a,t)&&ll(n,t)?void 0:ll(a,t)?{from:a,to:void 0}:ll(n,t)?void 0:AN(n,t)?{from:t,to:a}:{from:n,to:t}:a?AN(t,a)?{from:a,to:t}:{from:t,to:a}:n?EN(t,n)?{from:t,to:n}:{from:n,to:t}:{from:t,to:void 0}}var Xbe=S.createContext(void 0);function WDt(t){if(!zL(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(Xbe.Provider,{value:s,children:t.children})}return e.jsx(GDt,{initialProps:t.initialProps,children:t.children})}function GDt(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,j){var w,N;(w=s.onDayClick)===null||w===void 0||w.call(s,_,b,j);var C=HDt(_,n);(N=s.onSelect)===null||N===void 0||N.call(s,C,_,b,j)},p={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(p.range_start=[o],l?(p.range_end=[l],ll(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:tre(o,i-1),before:hl(o,i-1)}),o&&l&&p.disabled.push({after:o,before:hl(o,i-1)}),!o&&l&&p.disabled.push({after:tre(l,i-1),before:hl(l,i-1)})),d){if(o&&!l&&(p.disabled.push({before:hl(o,-d+1)}),p.disabled.push({after:hl(o,d-1)})),o&&l){var g=up(l,o)+1,v=d-g;p.disabled.push({before:tre(o,v)}),p.disabled.push({after:hl(l,v)})}!o&&l&&(p.disabled.push({before:hl(l,-d+1)}),p.disabled.push({after:hl(l,d-1)}))}return e.jsx(Xbe.Provider,{value:{selected:n,onDayClick:u,modifiers:p},children:r})}function Qbe(){var t=S.useContext(Xbe);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function vre(t){return Array.isArray(t)?RGe([],t):t!==void 0?[t]:[]}function KDt(t){var s={};return Object.entries(t).forEach(function(r){var n=r[0],a=r[1];s[n]=vre(a)}),s}var Hg;(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"})(Hg||(Hg={}));var ZDt=Hg.Selected,Gy=Hg.Disabled,YDt=Hg.Hidden,XDt=Hg.Today,Lme=Hg.RangeEnd,Dme=Hg.RangeMiddle,Ome=Hg.RangeStart,QDt=Hg.Outside;function JDt(t,s,r){var n,a=(n={},n[ZDt]=vre(t.selected),n[Gy]=vre(t.disabled),n[YDt]=vre(t.hidden),n[XDt]=[t.today],n[Lme]=[],n[Dme]=[],n[Ome]=[],n[QDt]=[],n);return t.fromDate&&a[Gy].push({before:t.fromDate}),t.toDate&&a[Gy].push({after:t.toDate}),FL(t)?a[Gy]=a[Gy].concat(s.modifiers[Gy]):zL(t)&&(a[Gy]=a[Gy].concat(r.modifiers[Gy]),a[Ome]=r.modifiers[Ome],a[Dme]=r.modifiers[Dme],a[Lme]=r.modifiers[Lme]),a}var qGe=S.createContext(void 0);function eOt(t){var s=Bl(),r=Ybe(),n=Qbe(),a=JDt(s,r,n),o=KDt(s.modifiers),l=ui(ui({},a),o);return e.jsx(qGe.Provider,{value:l,children:t.children})}function UGe(){var t=S.useContext(qGe);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function tOt(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function sOt(t){return!!(t&&typeof t=="object"&&"from"in t)}function rOt(t){return!!(t&&typeof t=="object"&&"after"in t)}function nOt(t){return!!(t&&typeof t=="object"&&"before"in t)}function aOt(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function iOt(t,s){var r,n=s.from,a=s.to;if(n&&a){var o=up(a,n)<0;o&&(r=[a,n],n=r[0],a=r[1]);var l=up(t,n)>=0&&up(a,t)>=0;return l}return a?ll(a,t):n?ll(n,t):!1}function oOt(t){return G1e(t)}function lOt(t){return Array.isArray(t)&&t.every(G1e)}function cOt(t,s){return s.some(function(r){if(typeof r=="boolean")return r;if(oOt(r))return ll(t,r);if(lOt(r))return r.includes(t);if(sOt(r))return iOt(t,r);if(aOt(r))return r.dayOfWeek.includes(t.getDay());if(tOt(r)){var n=up(r.before,t),a=up(r.after,t),o=n>0,l=a<0,i=AN(r.before,r.after);return i?l&&o:o||l}return rOt(r)?up(t,r.after)>0:nOt(r)?up(r.before,t)>0:typeof r=="function"?r(t):!1})}function Jbe(t,s,r){var n=Object.keys(s).reduce(function(o,l){var i=s[l];return cOt(t,i)&&o.push(l),o},[]),a={};return n.forEach(function(o){return a[o]=!0}),r&&!Toe(t,r)&&(a.outside=!0),a}function dOt(t,s){for(var r=uc(t[0]),n=Kp(t[t.length-1]),a,o,l=r;l<=n;){var i=Jbe(l,s),d=!i.disabled&&!i.hidden;if(!d){l=hl(l,1);continue}if(i.selected)return l;i.today&&!o&&(o=l),a||(a=l),l=hl(l,1)}return o||a}var uOt=365;function VGe(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,g=a.locale,v={day:hl,week:Nk,month:Vh,year:rvt,startOfWeek:function(w){return a.ISOWeek?K0(w):ah(w,{locale:g,weekStartsOn:d})},endOfWeek:function(w){return a.ISOWeek?T9e(w):Coe(w,{locale:g,weekStartsOn:d})}},_=v[r](t,n==="after"?1:-1);n==="before"&&u?_=nvt([u,_]):n==="after"&&p&&(_=avt([p,_]));var b=!0;if(o){var j=Jbe(_,o);b=!j.disabled&&!j.hidden}return b?_:i.count>uOt?i.lastFocused:VGe(_,{moveBy:r,direction:n,context:a,modifiers:o,retry:ui(ui({},i),{count:i.count+1})})}var HGe=S.createContext(void 0);function hOt(t){var s=BL(),r=UGe(),n=S.useState(),a=n[0],o=n[1],l=S.useState(),i=l[0],d=l[1],u=dOt(s.displayMonths,r),p=a??(i&&s.isDateDisplayed(i))?i:u,g=function(){d(a),o(void 0)},v=function(w){o(w)},_=Bl(),b=function(w,N){if(a){var C=VGe(a,{moveBy:w,direction:N,context:_,modifiers:r});ll(a,C)||(s.goToDate(C,a),v(C))}},j={focusedDay:a,focusTarget:p,blur:g,focus:v,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(HGe.Provider,{value:j,children:t.children})}function ewe(){var t=S.useContext(HGe);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function mOt(t,s){var r=UGe(),n=Jbe(t,r,s);return n}var twe=S.createContext(void 0);function pOt(t){if(!gle(t.initialProps)){var s={selected:void 0};return e.jsx(twe.Provider,{value:s,children:t.children})}return e.jsx(fOt,{initialProps:t.initialProps,children:t.children})}function fOt(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(twe.Provider,{value:a,children:r})}function WGe(){var t=S.useContext(twe);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function gOt(t,s){var r=Bl(),n=WGe(),a=Ybe(),o=Qbe(),l=ewe(),i=l.focusDayAfter,d=l.focusDayBefore,u=l.focusWeekAfter,p=l.focusWeekBefore,g=l.blur,v=l.focus,_=l.focusMonthBefore,b=l.focusMonthAfter,j=l.focusYearBefore,w=l.focusYearAfter,N=l.focusStartOfWeek,C=l.focusEndOfWeek,A=function(ae){var le,pe,be,ye;gle(r)?(le=n.onDayClick)===null||le===void 0||le.call(n,t,s,ae):FL(r)?(pe=a.onDayClick)===null||pe===void 0||pe.call(a,t,s,ae):zL(r)?(be=o.onDayClick)===null||be===void 0||be.call(o,t,s,ae):(ye=r.onDayClick)===null||ye===void 0||ye.call(r,t,s,ae)},I=function(ae){var le;v(t),(le=r.onDayFocus)===null||le===void 0||le.call(r,t,s,ae)},L=function(ae){var le;g(),(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)},V=function(ae){var le;(le=r.onDayTouchCancel)===null||le===void 0||le.call(r,t,s,ae)},X=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)},Y=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?j():_();break;case"PageDown":ae.preventDefault(),ae.stopPropagation(),ae.shiftKey?w():b();break;case"Home":ae.preventDefault(),ae.stopPropagation(),N();break;case"End":ae.preventDefault(),ae.stopPropagation(),C();break}(le=r.onDayKeyDown)===null||le===void 0||le.call(r,t,s,ae)},ie={onClick:A,onFocus:I,onBlur:L,onKeyDown:de,onKeyUp:Y,onMouseEnter:R,onMouseLeave:$,onPointerEnter:q,onPointerLeave:U,onTouchCancel:V,onTouchEnd:X,onTouchMove:se,onTouchStart:te};return ie}function xOt(){var t=Bl(),s=WGe(),r=Ybe(),n=Qbe(),a=gle(t)?s.selected:FL(t)?r.selected:zL(t)?n.selected:void 0;return a}function yOt(t){return Object.values(Hg).includes(t)}function vOt(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(yOt(n)){var o=t.classNames["day_".concat(n)];o&&r.push(o)}}),r}function _Ot(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 bOt(t,s,r){var n,a,o,l=Bl(),i=ewe(),d=mOt(t,s),u=gOt(t,d),p=xOt(),g=!!(l.onDayClick||l.mode!=="default");S.useEffect(function(){var R;d.outside||i.focusedDay&&g&&ll(i.focusedDay,t)&&((R=r.current)===null||R===void 0||R.focus())},[i.focusedDay,t,r,g,d.outside]);var v=vOt(l,d).join(" "),_=_Ot(l,d),b=!!(d.outside&&!l.showOutsideDays||d.hidden),j=(o=(a=l.components)===null||a===void 0?void 0:a.DayContent)!==null&&o!==void 0?o:qDt,w=e.jsx(j,{date:t,displayMonth:s,activeModifiers:d}),N={style:_,className:v,children:w,role:"gridcell"},C=i.focusTarget&&ll(i.focusTarget,t)&&!d.outside,A=i.focusedDay&&ll(i.focusedDay,t),I=ui(ui(ui({},N),(n={disabled:d.disabled,role:"gridcell"},n["aria-selected"]=d.selected,n.tabIndex=A||C?0:-1,n)),u),L={isButton:g,isHidden:b,activeModifiers:d,selectedDays:p,buttonProps:I,divProps:N};return L}function wOt(t){var s=S.useRef(null),r=bOt(t.date,t.displayMonth,s);return r.isHidden?e.jsx("div",{role:"gridcell"}):r.isButton?e.jsx(jae,ui({name:"day",ref:s},r.buttonProps)):e.jsx("div",ui({},r.divProps))}function jOt(t){var s=t.number,r=t.dates,n=Bl(),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 g=d(Number(s),{locale:i}),v=function(_){a(s,r,_)};return e.jsx(jae,{name:"week-number","aria-label":g,className:l.weeknumber,style:o.weeknumber,onClick:v,children:p})}function kOt(t){var s,r,n=Bl(),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:wOt,u=(r=i==null?void 0:i.WeekNumber)!==null&&r!==void 0?r:jOt,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(g){return e.jsx("td",{className:o.cell,style:a.cell,role:"presentation",children:e.jsx(d,{displayMonth:t.displayMonth,date:g})},l1t(g))})]})}function PAe(t,s,r){for(var n=r!=null&&r.ISOWeek?T9e(s):Coe(s,r),a=r!=null&&r.ISOWeek?K0(t):ah(t,r),o=up(n,a),l=[],i=0;i<=o;i++)l.push(hl(a,i));var d=l.reduce(function(u,p){var g=r!=null&&r.ISOWeek?K1e(p):Y1e(p,r),v=u.find(function(_){return _.weekNumber===g});return v?(v.dates.push(p),u):(u.push({weekNumber:g,dates:[p]}),u)},[]);return d}function NOt(t,s){var r=PAe(uc(t),Kp(t),s);if(s!=null&&s.useFixedWeeks){var n=d1t(t,s);if(n<6){var a=r[r.length-1],o=a.dates[a.dates.length-1],l=Nk(o,6-n),i=PAe(Nk(o,1),l,s);r.push.apply(r,i)}}return r}function SOt(t){var s,r,n,a=Bl(),o=a.locale,l=a.classNames,i=a.styles,d=a.hideHead,u=a.fixedWeeks,p=a.components,g=a.weekStartsOn,v=a.firstWeekContainsDate,_=a.ISOWeek,b=NOt(t.displayMonth,{useFixedWeeks:!!u,ISOWeek:_,locale:o,weekStartsOn:g,firstWeekContainsDate:v}),j=(s=p==null?void 0:p.Head)!==null&&s!==void 0?s:$Dt,w=(r=p==null?void 0:p.Row)!==null&&r!==void 0?r:kOt,N=(n=p==null?void 0:p.Footer)!==null&&n!==void 0?n:FDt;return e.jsxs("table",{id:t.id,className:l.table,style:i.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!d&&e.jsx(j,{}),e.jsx("tbody",{className:l.tbody,style:i.tbody,children:b.map(function(C){return e.jsx(w,{displayMonth:t.displayMonth,dates:C.dates,weekNumber:C.weekNumber},C.weekNumber)})}),e.jsx(N,{displayMonth:t.displayMonth})]})}function COt(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var MOt=COt()?S.useLayoutEffect:S.useEffect,Rme=!1,TOt=0;function IAe(){return"react-day-picker-".concat(++TOt)}function AOt(t){var s,r=t??(Rme?IAe():null),n=S.useState(r),a=n[0],o=n[1];return MOt(function(){a===null&&o(IAe())},[]),S.useEffect(function(){Rme===!1&&(Rme=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function EOt(t){var s,r,n=Bl(),a=n.dir,o=n.classNames,l=n.styles,i=n.components,d=BL().displayMonths,u=AOt(n.id?"".concat(n.id,"-").concat(t.displayIndex):void 0),p=n.id?"".concat(n.id,"-grid-").concat(t.displayIndex):void 0,g=[o.month],v=l.month,_=t.displayIndex===0,b=t.displayIndex===d.length-1,j=!_&&!b;a==="rtl"&&(s=[_,b],b=s[0],_=s[1]),_&&(g.push(o.caption_start),v=ui(ui({},v),l.caption_start)),b&&(g.push(o.caption_end),v=ui(ui({},v),l.caption_end)),j&&(g.push(o.caption_between),v=ui(ui({},v),l.caption_between));var w=(r=i==null?void 0:i.Caption)!==null&&r!==void 0?r:RDt;return e.jsxs("div",{className:g.join(" "),style:v,children:[e.jsx(w,{id:u,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(SOt,{id:p,"aria-labelledby":u,displayMonth:t.displayMonth})]},t.displayIndex)}function POt(t){var s=Bl(),r=s.classNames,n=s.styles;return e.jsx("div",{className:r.months,style:n.months,children:t.children})}function IOt(t){var s,r,n=t.initialProps,a=Bl(),o=ewe(),l=BL(),i=S.useState(!1),d=i[0],u=i[1];S.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 g=ui(ui({},a.styles.root),a.style),v=Object.keys(n).filter(function(b){return b.startsWith("data-")}).reduce(function(b,j){var w;return ui(ui({},b),(w={},w[j]=n[j],w))},{}),_=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:POt;return e.jsx("div",ui({className:p.join(" "),style:g,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},v,{children:e.jsx(_,{children:l.displayMonths.map(function(b,j){return e.jsx(EOt,{displayIndex:j,displayMonth:b},j)})})}))}function LOt(t){var s=t.children,r=nDt(t,["children"]);return e.jsx(jDt,{initialProps:r,children:e.jsx(IDt,{children:e.jsx(pOt,{initialProps:r,children:e.jsx(UDt,{initialProps:r,children:e.jsx(WDt,{initialProps:r,children:e.jsx(eOt,{children:e.jsx(hOt,{children:s})})})})})})})}function DOt(t){return e.jsx(LOt,ui({},t,{children:e.jsx(IOt,{initialProps:t})}))}function vp({className:t,classNames:s,showOutsideDays:r=!0,...n}){return e.jsx(DOt,{showOutsideDays:r,className:Et("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:Et(VI({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:Et(VI({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(Ol,{className:"h-4 w-4"}),IconRight:({...a})=>e.jsx(qa,{className:"h-4 w-4"})},...n})}vp.displayName="Calendar";var xle="Popover",[GGe]=Tc(xle,[dy]),$L=dy(),[OOt,K_]=GGe(xle),KGe=t=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!1}=t,i=$L(s),d=S.useRef(null),[u,p]=S.useState(!1),[g,v]=fu({prop:n,defaultProp:a??!1,onChange:o,caller:xle});return e.jsx(uL,{...i,children:e.jsx(OOt,{scope:s,contentId:Hd(),triggerRef:d,open:g,onOpenChange:v,onOpenToggle:S.useCallback(()=>v(_=>!_),[v]),hasCustomAnchor:u,onCustomAnchorAdd:S.useCallback(()=>p(!0),[]),onCustomAnchorRemove:S.useCallback(()=>p(!1),[]),modal:l,children:r})})};KGe.displayName=xle;var ZGe="PopoverAnchor",ROt=S.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=K_(ZGe,r),o=$L(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:i}=a;return S.useEffect(()=>(l(),()=>i()),[l,i]),e.jsx(iM,{...o,...n,ref:s})});ROt.displayName=ZGe;var YGe="PopoverTrigger",XGe=S.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=K_(YGe,r),o=$L(r),l=Aa(s,a.triggerRef),i=e.jsx(Qr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":sKe(a.open),...n,ref:l,onClick:Mr(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:e.jsx(iM,{asChild:!0,...o,children:i})});XGe.displayName=YGe;var swe="PopoverPortal",[FOt,zOt]=GGe(swe,{forceMount:void 0}),QGe=t=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=t,o=K_(swe,s);return e.jsx(FOt,{scope:s,forceMount:r,children:e.jsx(ud,{present:r||o.open,children:e.jsx(sM,{asChild:!0,container:a,children:n})})})};QGe.displayName=swe;var N3="PopoverContent",JGe=S.forwardRef((t,s)=>{const r=zOt(N3,t.__scopePopover),{forceMount:n=r.forceMount,...a}=t,o=K_(N3,t.__scopePopover);return e.jsx(ud,{present:n||o.open,children:o.modal?e.jsx($Ot,{...a,ref:s}):e.jsx(qOt,{...a,ref:s})})});JGe.displayName=N3;var BOt=b_("PopoverContent.RemoveScroll"),$Ot=S.forwardRef((t,s)=>{const r=K_(N3,t.__scopePopover),n=S.useRef(null),a=Aa(s,n),o=S.useRef(!1);return S.useEffect(()=>{const l=n.current;if(l)return doe(l)},[]),e.jsx(xL,{as:BOt,allowPinchZoom:!0,children:e.jsx(eKe,{...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})})})}),qOt=S.forwardRef((t,s)=>{const r=K_(N3,t.__scopePopover),n=S.useRef(!1),a=S.useRef(!1);return e.jsx(eKe,{...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()}})}),eKe=S.forwardRef((t,s)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:p,...g}=t,v=K_(N3,r),_=$L(r);return ooe(),e.jsx(fL,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(D_,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:p,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>v.onOpenChange(!1),children:e.jsx(hL,{"data-state":sKe(v.open),role:"dialog",id:v.contentId,..._,...g,ref:s,style:{...g.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)"}})})})}),tKe="PopoverClose",UOt=S.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=K_(tKe,r);return e.jsx(Qr.button,{type:"button",...n,ref:s,onClick:Mr(t.onClick,()=>a.onOpenChange(!1))})});UOt.displayName=tKe;var VOt="PopoverArrow",HOt=S.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=$L(r);return e.jsx(mL,{...a,...n,ref:s})});HOt.displayName=VOt;function sKe(t){return t?"open":"closed"}var WOt=KGe,GOt=XGe,KOt=QGe,rKe=JGe;const No=WOt,So=GOt,jo=S.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(KOt,{children:e.jsx(rKe,{ref:a,align:s,sideOffset:r,className:Et("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})}));jo.displayName=rKe.displayName;const ZOt=ZN("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"}}),rwe=S.forwardRef(({className:t,variant:s,...r},n)=>e.jsx("div",{ref:n,role:"alert",className:Et(ZOt({variant:s}),t),...r}));rwe.displayName="Alert";const YOt=S.forwardRef(({className:t,...s},r)=>e.jsx("h5",{ref:r,className:Et("mb-1 font-medium leading-none tracking-tight",t),...s}));YOt.displayName="AlertTitle";const nwe=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Et("text-sm [&_p]:leading-relaxed",t),...s}));nwe.displayName="AlertDescription";function XOt({open:t,onOpenChange:s,imageUrl:r,imageId:n,defaultCaption:a="",swagItemId:o,reelId:l}){const i=ns(),[d,u]=S.useState(a),[p,g]=S.useState([]),[v,_]=S.useState(null),[b,j]=S.useState("now"),[w,N]=S.useState(T5e(D5e(new Date),1)),[C,A]=S.useState("12"),[I,L]=S.useState("00"),[R,$]=S.useState("PM");S.useEffect(()=>{if(t){u(a),j("now"),g([]);const Ne=T5e(D5e(new Date),1);N(Ne);const Ke=Ne.getHours();A(String(Ke>12?Ke-12:Ke===0?12:Ke)),L("00"),$(Ke>=12?"PM":"AM")}},[t,a]);const q=()=>{if(!w)return null;let Ne=parseInt(C);const Ke=parseInt(I);return R==="PM"&&Ne!==12&&(Ne+=12),R==="AM"&&Ne===12&&(Ne=0),UP(qP(w,Ne),Ke)},{data:U,isLoading:V}=Ct({queryKey:["social-accounts-for-post"],queryFn:async()=>{const{data:{user:Ne}}=await G.auth.getUser();if(!Ne)return[];const{data:Ke,error:_e}=await G.from("social_accounts").select("*").eq("user_id",Ne.id).eq("is_active",!0).order("platform",{ascending:!0});if(_e)throw _e;return console.log("Fetched social accounts for posting:",Ke),Ke},enabled:t,staleTime:0}),X=Ot({mutationFn:async({accountId:Ne,platform:Ke})=>{_(Ne);const{data:_e,error:Me}=await G.functions.invoke("social-post",{body:{platform:Ke,accountId:Ne,imageUrl:r,caption:d}});if(Me)throw Me;if(_e!=null&&_e.error)throw new Error(_e.error);return _e},onSuccess:Ne=>{const Ke=Ne.platform==="facebook"?"Facebook":Ne.platform==="instagram"?"Instagram":Ne.platform==="linkedin"?"LinkedIn":"Google Business";fe.success(`Posted to ${Ke}!`)},onError:Ne=>{fe.error(`Failed to post: ${Ne.message}`)},onSettled:()=>{_(null)}}),se=Ot({mutationFn:async({accountId:Ne,platform:Ke,scheduledFor:_e})=>{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:Ke,image_url:r,caption:d,swag_item_id:o||null,reel_id:l||null,scheduled_for:_e.toISOString(),status:"scheduled"});if(Te)throw Te;return{platform:Ke}},onSuccess:Ne=>{const Ke=Ne.platform==="facebook"?"Facebook":Ne.platform==="instagram"?"Instagram":"LinkedIn";fe.success(`Post scheduled for ${Ke}!`)},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 Ke of p){const _e=U==null?void 0:U.find(Me=>Me.id===Ke);_e&&await se.mutateAsync({accountId:Ke,platform:_e.platform,scheduledFor:Ne})}i.invalidateQueries({queryKey:["scheduled-posts"]}),fe.success(`${p.length} post(s) scheduled for ${ws(Ne,"PPp")}`)}else for(const Ne of p){const Ke=U==null?void 0:U.find(_e=>_e.id===Ne);Ke&&await X.mutateAsync({accountId:Ne,platform:Ke.platform})}i.invalidateQueries({queryKey:["scheduled-posts"]}),u(""),g([]),s(!1)},Y=Ne=>{g(Ke=>Ke.includes(Ne)?Ke.filter(_e=>_e!==Ne):[...Ke,Ne])},de=(U==null?void 0:U.filter(Ne=>Ne.platform==="facebook"))||[],ie=(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"))||[],pe=((U==null?void 0:U.length)||0)>0,be=X.isPending||se.isPending,ye=Array.from({length:12},(Ne,Ke)=>String(Ke+1)),we=["00","15","30","45"];return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(Tr,{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:()=>j("now"),className:Et("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:()=>j("schedule"),className:Et("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(In,{className:"h-4 w-4"}),"Schedule for"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Et("justify-start text-left font-normal flex-1",!w&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),w?ws(w,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(vp,{mode:"single",selected:w,onSelect:N,disabled:Ne=>Nee.jsx(At,{value:Ne,children:Ne},Ne))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(tr,{value:I,onValueChange:L,children:[e.jsx(Js,{className:"w-[70px]",children:e.jsx(sr,{})}),e.jsx(er,{children:we.map(Ne=>e.jsx(At,{value:Ne,children:Ne},Ne))})]}),e.jsxs(tr,{value:R,onValueChange:Ne=>$(Ne),children:[e.jsx(Js,{className:"w-[70px]",children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"AM",children:"AM"}),e.jsx(At,{value:"PM",children:"PM"})]})]})]})]}),w&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Post will be published on ",ws(q()||new Date,"PPP 'at' p")]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{children:"Post to"}),V&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(As,{className:"h-6 w-6 animate-spin"})}),!V&&!pe&&e.jsxs(rwe,{children:[e.jsx(Qo,{className:"h-4 w-4"}),e.jsxs(nwe,{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(Fl,{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(Ud,{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(zo,{checked:p.includes(Ne.id),onCheckedChange:()=>Y(Ne.id),disabled:v===Ne.id}),e.jsxs(fn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:Ne.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(Ud,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:Ne.page_name||Ne.platform_username}),v===Ne.id&&e.jsx(As,{className:"h-4 w-4 animate-spin"})]},Ne.id))]}),ie.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(Vd,{className:"h-4 w-4 text-pink-600"})," Instagram"]}),ie.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(zo,{checked:p.includes(Ne.id),onCheckedChange:()=>Y(Ne.id),disabled:v===Ne.id}),e.jsxs(fn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:Ne.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(Vd,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"flex-1 text-sm font-medium",children:["@",Ne.platform_username]}),v===Ne.id&&e.jsx(As,{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(Pm,{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(zo,{checked:p.includes(Ne.id),onCheckedChange:()=>Y(Ne.id),disabled:v===Ne.id}),e.jsxs(fn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:Ne.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(Pm,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:Ne.platform_username}),v===Ne.id&&e.jsx(As,{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(Ti,{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(zo,{checked:p.includes(Ne.id),onCheckedChange:()=>Y(Ne.id),disabled:v===Ne.id}),e.jsxs(fn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:Ne.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(Ti,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:Ne.page_name||Ne.platform_username}),v===Ne.id&&e.jsx(As,{className:"h-4 w-4 animate-spin"})]},Ne.id))]})]})]}),e.jsxs(On,{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(As,{className:"h-4 w-4 animate-spin"}):b==="schedule"?e.jsx(on,{className:"h-4 w-4"}):e.jsx(Ta,{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 QOt(){const t=ns(),[s,r]=S.useState(void 0),[n,a]=S.useState("all"),[o,l]=S.useState(null),[i,d]=S.useState(""),[u,p]=S.useState(void 0),[g,v]=S.useState("12"),[_,b]=S.useState("00"),[j,w]=S.useState("PM"),{data:N=[],isLoading:C}=Ct({queryKey:["scheduled-posts"],queryFn:async()=>{const{data:le,error:pe}=await G.from("scheduled_posts").select(` *, social_accounts ( page_name, platform_username, profile_picture_url ) `).order("scheduled_for",{ascending:!1});if(pe)throw pe;return le}}),A=N.filter(le=>{if(n!=="all"&&le.status!==n)return!1;if(s&&le.scheduled_for){const pe=new Date(le.scheduled_for);if(!ll(pe,s))return!1}return!0}),I=N.filter(le=>le.scheduled_for).map(le=>Hh(new Date(le.scheduled_for))),L=Ot({mutationFn:async le=>{const{error:pe}=await G.from("scheduled_posts").update({caption:le.caption,scheduled_for:le.scheduled_for}).eq("id",le.id);if(pe)throw pe},onSuccess:()=>{fe.success("Post updated!"),t.invalidateQueries({queryKey:["scheduled-posts"]}),l(null)},onError:le=>{fe.error(`Failed to update: ${le.message}`)}}),R=Ot({mutationFn:async le=>{const{error:pe}=await G.from("scheduled_posts").update({status:"cancelled"}).eq("id",le);if(pe)throw pe},onSuccess:()=>{fe.success("Post cancelled"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{fe.error(`Failed to cancel: ${le.message}`)}}),$=Ot({mutationFn:async le=>{const{error:pe}=await G.from("scheduled_posts").delete().eq("id",le);if(pe)throw pe},onSuccess:()=>{fe.success("Post deleted"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{fe.error(`Failed to delete: ${le.message}`)}}),q=Ot({mutationFn:async le=>{const{data:pe,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(pe!=null&&pe.error)throw new Error(pe.error);return await G.from("scheduled_posts").update({status:"posted",posted_at:new Date().toISOString(),post_id:pe.postId}).eq("id",le.id),pe},onSuccess:le=>{const pe=le.platform==="facebook"?"Facebook":le.platform==="instagram"?"Instagram":"LinkedIn";fe.success(`Posted to ${pe}!`),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 pe=new Date(le.scheduled_for);p(pe);const be=pe.getHours();v(String(be>12?be-12:be===0?12:be)),b(String(pe.getMinutes()).padStart(2,"0")),w(be>=12?"PM":"AM")}},V=()=>{if(!o||!u)return;let le=parseInt(g);const pe=parseInt(_);j==="PM"&&le!==12&&(le+=12),j==="AM"&&le===12&&(le=0);const be=UP(qP(u,le),pe);L.mutate({id:o.id,caption:i,scheduled_for:be.toISOString()})},X=le=>{switch(le){case"facebook":return e.jsx(Ud,{className:"h-4 w-4 text-blue-600"});case"instagram":return e.jsx(Vd,{className:"h-4 w-4 text-pink-600"});case"linkedin":return e.jsx(Pm,{className:"h-4 w-4 text-blue-700"});default:return null}},se=le=>{switch(le){case"scheduled":return e.jsxs(at,{variant:"secondary",className:"gap-1",children:[e.jsx(In,{className:"h-3 w-3"}),"Scheduled"]});case"posted":return e.jsxs(at,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(fi,{className:"h-3 w-3"}),"Posted"]});case"failed":return e.jsxs(at,{variant:"destructive",className:"gap-1",children:[e.jsx(wc,{className:"h-3 w-3"}),"Failed"]});case"cancelled":return e.jsxs(at,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(Qo,{className:"h-3 w-3"}),"Cancelled"]});default:return e.jsx(at,{variant:"outline",children:le})}},te=Array.from({length:12},(le,pe)=>String(pe+1)),Y=["00","15","30","45"],de=N.filter(le=>le.status==="scheduled").length,ie=N.filter(le=>le.status==="posted").length,ae=N.filter(le=>le.status==="scheduled"&&le.scheduled_for&&u1t(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:ie}),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:N.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(kc,{className:"h-5 w-5"}),e.jsx("h3",{className:"font-semibold",children:"Calendar"})]}),e.jsx(vp,{mode:"single",selected:s,onSelect:r,className:Et("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(Ux,{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))})]}),C&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(As,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),!C&&A.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 ${ws(s,"PPP")}`:"Schedule a post from Social Swag to get started!"})]}),e.jsx("div",{className:"space-y-4",children:A.map(le=>{var pe,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:[X(le.platform),e.jsx("span",{className:"font-medium",children:((pe=le.social_accounts)==null?void 0:pe.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(YN,{children:[e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>U(le),children:e.jsx(Ua,{className:"h-4 w-4"})})}),e.jsx(Hc,{children:"Edit post"})]}),e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>q.mutate(le),disabled:q.isPending,children:q.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(Ta,{className:"h-4 w-4"})})}),e.jsx(Hc,{children:"Post now"})]}),e.jsxs(tc,{children:[e.jsx(Ih,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Cancel this scheduled post?"}),e.jsx(Il,{children:"This will cancel the post. You can delete it entirely or keep it in your history."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Keep"}),e.jsx(fl,{onClick:()=>R.mutate(le.id),className:"bg-amber-600 hover:bg-amber-700",children:"Cancel Post"}),e.jsx(fl,{onClick:()=>$.mutate(le.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]}),(le.status==="posted"||le.status==="cancelled"||le.status==="failed")&&e.jsxs(tc,{children:[e.jsx(Ih,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Delete this post?"}),e.jsx(Il,{children:"This will permanently remove this post from your history."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{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(In,{className:"h-3 w-3"}),le.status==="posted"&&le.posted_at?`Posted ${ws(new Date(le.posted_at),"PPp")}`:le.scheduled_for?`Scheduled for ${ws(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(vs,{open:!!o,onOpenChange:le=>!le&&l(null),children:e.jsxs(ys,{className:"max-w-lg",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(Tr,{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(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Et("justify-start text-left font-normal flex-1",!u&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),u?ws(u,"PPP"):"Pick a date"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(vp,{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(tr,{value:_,onValueChange:b,children:[e.jsx(Js,{className:"w-[70px]",children:e.jsx(sr,{})}),e.jsx(er,{children:Y.map(le=>e.jsx(At,{value:le,children:le},le))})]}),e.jsxs(tr,{value:j,onValueChange:le=>w(le),children:[e.jsx(Js,{className:"w-[70px]",children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"AM",children:"AM"}),e.jsx(At,{value:"PM",children:"PM"})]})]})]})]})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(null),children:"Cancel"}),e.jsxs(K,{onClick:V,disabled:L.isPending,children:[L.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Changes"]})]})]})})]})}function tR(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 nKe={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 g=typeof tR=="function"&&tR;if(!p&&g)return g(u,!0);if(i)return i(u,!0);var v=new Error("Cannot find module '"+u+"'");throw v.code="MODULE_NOT_FOUND",v}var _=a[u]={exports:{}};n[u][0].call(_.exports,function(b){var j=n[u][1][b];return l(j||b)},_,_.exports,r,n,a,o)}return a[u].exports}for(var i=typeof tR=="function"&&tR,d=0;d>2,_=(3&u)<<4|p>>4,b=1>6:64,j=2>4,p=(15&v)<<4|(_=i.indexOf(d.charAt(j++)))>>2,g=(3&_)<<6|(b=i.indexOf(d.charAt(j++))),C[w++]=u,_!==64&&(C[w++]=p),b!==64&&(C[w++]=g);return C}},{"./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,g,v,_,b){this.compressedSize=p,this.uncompressedSize=g,this.crc32=v,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")),g=this;return p.on("end",function(){if(this.streamInfo.data_length!==g.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,g,v){return p.pipe(new i).pipe(new d("uncompressedSize")).pipe(g.compressWorker(v)).pipe(new d("compressedSize")).withStreamInfo("compression",g)},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,g,v){var _=l,b=v+g;u^=-1;for(var j=v;j>>8^_[255&(u^p[j])];return-1^u}(0|d,i,i.length,0):function(u,p,g,v){var _=l,b=v+g;u^=-1;for(var j=v;j>>8^_[255&(u^p.charCodeAt(j))];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(g,v){d.call(this,"FlateWorker/"+g),this._pako=null,this._pakoAction=g,this._pakoOptions=v,this.meta={}}a.magic="\b\0",i.inherits(p,d),p.prototype.processChunk=function(g){this.meta=g.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(u,g.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 g=this;this._pako.onData=function(v){g.push({data:v,meta:g.meta})}},a.compressWorker=function(g){return new p("Deflate",g)},a.uncompressWorker=function(){return new p("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,n,a){function o(_,b){var j,w="";for(j=0;j>>=8;return w}function l(_,b,j,w,N,C){var A,I,L=_.file,R=_.compression,$=C!==u.utf8encode,q=i.transformTo("string",C(L.name)),U=i.transformTo("string",u.utf8encode(L.name)),V=L.comment,X=i.transformTo("string",C(V)),se=i.transformTo("string",u.utf8encode(V)),te=U.length!==L.name.length,Y=se.length!==V.length,de="",ie="",ae="",le=L.dir,pe=L.date,be={crc32:0,compressedSize:0,uncompressedSize:0};b&&!j||(be.crc32=_.crc32,be.compressedSize=_.compressedSize,be.uncompressedSize=_.uncompressedSize);var ye=0;b&&(ye|=8),$||!te&&!Y||(ye|=2048);var we=0,Ne=0;le&&(we|=16),N==="UNIX"?(Ne=798,we|=function(_e,Me){var Te=_e;return _e||(Te=Me?16893:33204),(65535&Te)<<16}(L.unixPermissions,le)):(Ne=20,we|=function(_e){return 63&(_e||0)}(L.dosPermissions)),A=pe.getUTCHours(),A<<=6,A|=pe.getUTCMinutes(),A<<=5,A|=pe.getUTCSeconds()/2,I=pe.getUTCFullYear()-1980,I<<=4,I|=pe.getUTCMonth()+1,I<<=5,I|=pe.getUTCDate(),te&&(ie=o(1,1)+o(p(q),4)+U,de+="up"+o(ie.length,2)+ie),Y&&(ae=o(1,1)+o(p(X),4)+se,de+="uc"+o(ae.length,2)+ae);var Ke="";return Ke+=` \0`,Ke+=o(ye,2),Ke+=R.magic,Ke+=o(A,2),Ke+=o(I,2),Ke+=o(be.crc32,4),Ke+=o(be.compressedSize,4),Ke+=o(be.uncompressedSize,4),Ke+=o(q.length,2),Ke+=o(de.length,2),{fileRecord:g.LOCAL_FILE_HEADER+Ke+q+de,dirRecord:g.CENTRAL_FILE_HEADER+o(Ne,2)+Ke+o(X.length,2)+"\0\0\0\0"+o(we,4)+o(w,4)+q+de+X}}var i=r("../utils"),d=r("../stream/GenericWorker"),u=r("../utf8"),p=r("../crc32"),g=r("../signature");function v(_,b,j,w){d.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=j,this.encodeFileName=w,this.streamFiles=_,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(v,d),v.prototype.push=function(_){var b=_.meta.percent||0,j=this.entriesCount,w=this._sources.length;this.accumulate?this.contentBuffer.push(_):(this.bytesWritten+=_.data.length,d.prototype.push.call(this,{data:_.data,meta:{currentFile:this.currentFile,percent:j?(b+100*(j-w-1))/j:100}}))},v.prototype.openedSource=function(_){this.currentSourceOffset=this.bytesWritten,this.currentFile=_.file.name;var b=this.streamFiles&&!_.file.dir;if(b){var j=l(_,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:j.fileRecord,meta:{percent:0}})}else this.accumulate=!0},v.prototype.closedSource=function(_){this.accumulate=!1;var b=this.streamFiles&&!_.file.dir,j=l(_,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(j.dirRecord),b)this.push({data:function(w){return g.DATA_DESCRIPTOR+o(w.crc32,4)+o(w.compressedSize,4)+o(w.uncompressedSize,4)}(_),meta:{percent:100}});else for(this.push({data:j.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},v.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(g){var v=o.getTypeOf(g);return o.checkSupport(v),v!=="string"||l.uint8array?v==="nodebuffer"?new u(g):l.uint8array?new p(o.transformTo("uint8array",g)):new i(o.transformTo("array",g)):new d(g)}},{"../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"),g=null;if(u.nodestream)try{g=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function v(b,j){return new p.Promise(function(w,N){var C=[],A=b._internalType,I=b._outputType,L=b._mimeType;b.on("data",function(R,$){C.push(R),j&&j($)}).on("error",function(R){C=[],N(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,V=0,X=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 g(){d.call(this,"utf-8 decode"),this.leftOver=null}function v(){d.call(this,"utf-8 encode")}a.utf8encode=function(_){return l.nodebuffer?i.newBufferFrom(_,"utf-8"):function(b){var j,w,N,C,A,I=b.length,L=0;for(C=0;C>>6:(w<65536?j[A++]=224|w>>>12:(j[A++]=240|w>>>18,j[A++]=128|w>>>12&63),j[A++]=128|w>>>6&63),j[A++]=128|63&w);return j}(_)},a.utf8decode=function(_){return l.nodebuffer?o.transformTo("nodebuffer",_).toString("utf-8"):function(b){var j,w,N,C,A=b.length,I=new Array(2*A);for(j=w=0;j>10&1023,I[w++]=56320|1023&N)}return I.length!==w&&(I.subarray?I=I.subarray(0,w):I.length=w),o.applyFromCharCode(I)}(_=o.transformTo(l.uint8array?"uint8array":"array",_))},o.inherits(g,d),g.prototype.processChunk=function(_){var b=o.transformTo(l.uint8array?"uint8array":"array",_.data);if(this.leftOver&&this.leftOver.length){if(l.uint8array){var j=b;(b=new Uint8Array(j.length+this.leftOver.length)).set(this.leftOver,0),b.set(j,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var w=function(C,A){var I;for((A=A||C.length)>C.length&&(A=C.length),I=A-1;0<=I&&(192&C[I])==128;)I--;return I<0||I===0?A:I+u[C[I]]>A?I:A}(b),N=b;w!==b.length&&(l.uint8array?(N=b.subarray(0,w),this.leftOver=b.subarray(w,b.length)):(N=b.slice(0,w),this.leftOver=b.slice(w,b.length))),this.push({data:a.utf8decode(N),meta:_.meta})},g.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:a.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},a.Utf8DecodeWorker=g,o.inherits(v,d),v.prototype.processChunk=function(_){this.push({data:a.utf8encode(_.data),meta:_.meta})},a.Utf8EncodeWorker=v},{"./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(j){return j}function p(j,w){for(var N=0;N>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,j,w,N=_.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});_.index+4>>6:(_<65536?v[w++]=224|_>>>12:(v[w++]=240|_>>>18,v[w++]=128|_>>>12&63),v[w++]=128|_>>>6&63),v[w++]=128|63&_);return v},a.buf2binstring=function(g){return p(g,g.length)},a.binstring2buf=function(g){for(var v=new o.Buf8(g.length),_=0,b=v.length;_>10&1023,C[b++]=56320|1023&j)}return p(C,b)},a.utf8border=function(g,v){var _;for((v=v||g.length)>g.length&&(v=g.length),_=v-1;0<=_&&(192&g[_])==128;)_--;return _<0||_===0?v:_+d[g[_]]>v?_:v}},{"./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,g=0;i!==0;){for(i-=g=2e3>>1:l>>>1;i[d]=l}return i}();n.exports=function(l,i,d,u){var p=o,g=u+d;l^=-1;for(var v=u;v>>8^p[255&(l^i[v])];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"),g=0,v=4,_=0,b=-2,j=-1,w=4,N=2,C=8,A=9,I=286,L=30,R=19,$=2*I+1,q=15,U=3,V=258,X=V+U+1,se=42,te=113,Y=1,de=2,ie=3,ae=4;function le(he,Ve){return he.msg=p[Ve],Ve}function pe(he){return(he<<1)-(4he.avail_out&&(nt=he.avail_out),nt!==0&&(l.arraySet(he.output,Ve.pending_buf,Ve.pending_out,nt,he.next_out),he.next_out+=nt,Ve.pending_out+=nt,he.total_out+=nt,he.avail_out-=nt,Ve.pending-=nt,Ve.pending===0&&(Ve.pending_out=0))}function we(he,Ve){i._tr_flush_block(he,0<=he.block_start?he.block_start:-1,he.strstart-he.block_start,Ve),he.block_start=he.strstart,ye(he.strm)}function Ne(he,Ve){he.pending_buf[he.pending++]=Ve}function Ke(he,Ve){he.pending_buf[he.pending++]=Ve>>>8&255,he.pending_buf[he.pending++]=255&Ve}function _e(he,Ve){var nt,Qe,ke=he.max_chain_length,ot=he.strstart,qe=he.prev_length,lt=he.nice_match,We=he.strstart>he.w_size-X?he.strstart-(he.w_size-X):0,Ye=he.window,mt=he.w_mask,Ze=he.prev,He=he.strstart+V,et=Ye[ot+qe-1],Rt=Ye[ot+qe];he.prev_length>=he.good_match&&(ke>>=2),lt>he.lookahead&&(lt=he.lookahead);do if(Ye[(nt=Ve)+qe]===Rt&&Ye[nt+qe-1]===et&&Ye[nt]===Ye[ot]&&Ye[++nt]===Ye[ot+1]){ot+=2,nt++;do;while(Ye[++ot]===Ye[++nt]&&Ye[++ot]===Ye[++nt]&&Ye[++ot]===Ye[++nt]&&Ye[++ot]===Ye[++nt]&&Ye[++ot]===Ye[++nt]&&Ye[++ot]===Ye[++nt]&&Ye[++ot]===Ye[++nt]&&Ye[++ot]===Ye[++nt]&&otWe&&--ke!=0);return qe<=he.lookahead?qe:he.lookahead}function Me(he){var Ve,nt,Qe,ke,ot,qe,lt,We,Ye,mt,Ze=he.w_size;do{if(ke=he.window_size-he.lookahead-he.strstart,he.strstart>=Ze+(Ze-X)){for(l.arraySet(he.window,he.window,Ze,Ze,0),he.match_start-=Ze,he.strstart-=Ze,he.block_start-=Ze,Ve=nt=he.hash_size;Qe=he.head[--Ve],he.head[Ve]=Ze<=Qe?Qe-Ze:0,--nt;);for(Ve=nt=Ze;Qe=he.prev[--Ve],he.prev[Ve]=Ze<=Qe?Qe-Ze:0,--nt;);ke+=Ze}if(he.strm.avail_in===0)break;if(qe=he.strm,lt=he.window,We=he.strstart+he.lookahead,Ye=ke,mt=void 0,mt=qe.avail_in,Ye=U)for(ot=he.strstart-he.insert,he.ins_h=he.window[ot],he.ins_h=(he.ins_h<=U&&(he.ins_h=(he.ins_h<=U)if(Qe=i._tr_tally(he,he.strstart-he.match_start,he.match_length-U),he.lookahead-=he.match_length,he.match_length<=he.max_lazy_match&&he.lookahead>=U){for(he.match_length--;he.strstart++,he.ins_h=(he.ins_h<=U&&(he.ins_h=(he.ins_h<=U&&he.match_length<=he.prev_length){for(ke=he.strstart+he.lookahead-U,Qe=i._tr_tally(he,he.strstart-1-he.prev_match,he.prev_length-U),he.lookahead-=he.prev_length-1,he.prev_length-=2;++he.strstart<=ke&&(he.ins_h=(he.ins_h<he.pending_buf_size-5&&(nt=he.pending_buf_size-5);;){if(he.lookahead<=1){if(Me(he),he.lookahead===0&&Ve===g)return Y;if(he.lookahead===0)break}he.strstart+=he.lookahead,he.lookahead=0;var Qe=he.block_start+nt;if((he.strstart===0||he.strstart>=Qe)&&(he.lookahead=he.strstart-Qe,he.strstart=Qe,we(he,!1),he.strm.avail_out===0)||he.strstart-he.block_start>=he.w_size-X&&(we(he,!1),he.strm.avail_out===0))return Y}return he.insert=0,Ve===v?(we(he,!0),he.strm.avail_out===0?ie:ae):(he.strstart>he.block_start&&(we(he,!1),he.strm.avail_out),Y)}),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(he,Ve){return Dt(he,Ve,C,15,8,0)},a.deflateInit2=Dt,a.deflateReset=De,a.deflateResetKeep=ut,a.deflateSetHeader=function(he,Ve){return he&&he.state?he.state.wrap!==2?b:(he.state.gzhead=Ve,_):b},a.deflate=function(he,Ve){var nt,Qe,ke,ot;if(!he||!he.state||5>8&255),Ne(Qe,Qe.gzhead.time>>16&255),Ne(Qe,Qe.gzhead.time>>24&255),Ne(Qe,Qe.level===9?2:2<=Qe.strategy||Qe.level<2?4:0),Ne(Qe,255&Qe.gzhead.os),Qe.gzhead.extra&&Qe.gzhead.extra.length&&(Ne(Qe,255&Qe.gzhead.extra.length),Ne(Qe,Qe.gzhead.extra.length>>8&255)),Qe.gzhead.hcrc&&(he.adler=u(he.adler,Qe.pending_buf,Qe.pending,0)),Qe.gzindex=0,Qe.status=69):(Ne(Qe,0),Ne(Qe,0),Ne(Qe,0),Ne(Qe,0),Ne(Qe,0),Ne(Qe,Qe.level===9?2:2<=Qe.strategy||Qe.level<2?4:0),Ne(Qe,3),Qe.status=te);else{var qe=C+(Qe.w_bits-8<<4)<<8;qe|=(2<=Qe.strategy||Qe.level<2?0:Qe.level<6?1:Qe.level===6?2:3)<<6,Qe.strstart!==0&&(qe|=32),qe+=31-qe%31,Qe.status=te,Ke(Qe,qe),Qe.strstart!==0&&(Ke(Qe,he.adler>>>16),Ke(Qe,65535&he.adler)),he.adler=1}if(Qe.status===69)if(Qe.gzhead.extra){for(ke=Qe.pending;Qe.gzindex<(65535&Qe.gzhead.extra.length)&&(Qe.pending!==Qe.pending_buf_size||(Qe.gzhead.hcrc&&Qe.pending>ke&&(he.adler=u(he.adler,Qe.pending_buf,Qe.pending-ke,ke)),ye(he),ke=Qe.pending,Qe.pending!==Qe.pending_buf_size));)Ne(Qe,255&Qe.gzhead.extra[Qe.gzindex]),Qe.gzindex++;Qe.gzhead.hcrc&&Qe.pending>ke&&(he.adler=u(he.adler,Qe.pending_buf,Qe.pending-ke,ke)),Qe.gzindex===Qe.gzhead.extra.length&&(Qe.gzindex=0,Qe.status=73)}else Qe.status=73;if(Qe.status===73)if(Qe.gzhead.name){ke=Qe.pending;do{if(Qe.pending===Qe.pending_buf_size&&(Qe.gzhead.hcrc&&Qe.pending>ke&&(he.adler=u(he.adler,Qe.pending_buf,Qe.pending-ke,ke)),ye(he),ke=Qe.pending,Qe.pending===Qe.pending_buf_size)){ot=1;break}ot=Qe.gzindexke&&(he.adler=u(he.adler,Qe.pending_buf,Qe.pending-ke,ke)),ot===0&&(Qe.gzindex=0,Qe.status=91)}else Qe.status=91;if(Qe.status===91)if(Qe.gzhead.comment){ke=Qe.pending;do{if(Qe.pending===Qe.pending_buf_size&&(Qe.gzhead.hcrc&&Qe.pending>ke&&(he.adler=u(he.adler,Qe.pending_buf,Qe.pending-ke,ke)),ye(he),ke=Qe.pending,Qe.pending===Qe.pending_buf_size)){ot=1;break}ot=Qe.gzindexke&&(he.adler=u(he.adler,Qe.pending_buf,Qe.pending-ke,ke)),ot===0&&(Qe.status=103)}else Qe.status=103;if(Qe.status===103&&(Qe.gzhead.hcrc?(Qe.pending+2>Qe.pending_buf_size&&ye(he),Qe.pending+2<=Qe.pending_buf_size&&(Ne(Qe,255&he.adler),Ne(Qe,he.adler>>8&255),he.adler=0,Qe.status=te)):Qe.status=te),Qe.pending!==0){if(ye(he),he.avail_out===0)return Qe.last_flush=-1,_}else if(he.avail_in===0&&pe(Ve)<=pe(nt)&&Ve!==v)return le(he,-5);if(Qe.status===666&&he.avail_in!==0)return le(he,-5);if(he.avail_in!==0||Qe.lookahead!==0||Ve!==g&&Qe.status!==666){var lt=Qe.strategy===2?function(We,Ye){for(var mt;;){if(We.lookahead===0&&(Me(We),We.lookahead===0)){if(Ye===g)return Y;break}if(We.match_length=0,mt=i._tr_tally(We,0,We.window[We.strstart]),We.lookahead--,We.strstart++,mt&&(we(We,!1),We.strm.avail_out===0))return Y}return We.insert=0,Ye===v?(we(We,!0),We.strm.avail_out===0?ie:ae):We.last_lit&&(we(We,!1),We.strm.avail_out===0)?Y:de}(Qe,Ve):Qe.strategy===3?function(We,Ye){for(var mt,Ze,He,et,Rt=We.window;;){if(We.lookahead<=V){if(Me(We),We.lookahead<=V&&Ye===g)return Y;if(We.lookahead===0)break}if(We.match_length=0,We.lookahead>=U&&0We.lookahead&&(We.match_length=We.lookahead)}if(We.match_length>=U?(mt=i._tr_tally(We,1,We.match_length-U),We.lookahead-=We.match_length,We.strstart+=We.match_length,We.match_length=0):(mt=i._tr_tally(We,0,We.window[We.strstart]),We.lookahead--,We.strstart++),mt&&(we(We,!1),We.strm.avail_out===0))return Y}return We.insert=0,Ye===v?(we(We,!0),We.strm.avail_out===0?ie:ae):We.last_lit&&(we(We,!1),We.strm.avail_out===0)?Y:de}(Qe,Ve):o[Qe.level].func(Qe,Ve);if(lt!==ie&<!==ae||(Qe.status=666),lt===Y||lt===ie)return he.avail_out===0&&(Qe.last_flush=-1),_;if(lt===de&&(Ve===1?i._tr_align(Qe):Ve!==5&&(i._tr_stored_block(Qe,0,0,!1),Ve===3&&(be(Qe.head),Qe.lookahead===0&&(Qe.strstart=0,Qe.block_start=0,Qe.insert=0))),ye(he),he.avail_out===0))return Qe.last_flush=-1,_}return Ve!==v?_:Qe.wrap<=0?1:(Qe.wrap===2?(Ne(Qe,255&he.adler),Ne(Qe,he.adler>>8&255),Ne(Qe,he.adler>>16&255),Ne(Qe,he.adler>>24&255),Ne(Qe,255&he.total_in),Ne(Qe,he.total_in>>8&255),Ne(Qe,he.total_in>>16&255),Ne(Qe,he.total_in>>24&255)):(Ke(Qe,he.adler>>>16),Ke(Qe,65535&he.adler)),ye(he),0=nt.w_size&&(ot===0&&(be(nt.head),nt.strstart=0,nt.block_start=0,nt.insert=0),Ye=new l.Buf8(nt.w_size),l.arraySet(Ye,Ve,mt-nt.w_size,nt.w_size,0),Ve=Ye,mt=nt.w_size),qe=he.avail_in,lt=he.next_in,We=he.input,he.avail_in=mt,he.next_in=0,he.input=Ve,Me(nt);nt.lookahead>=U;){for(Qe=nt.strstart,ke=nt.lookahead-(U-1);nt.ins_h=(nt.ins_h<>>=U=q>>>24,A-=U,(U=q>>>16&255)===0)de[p++]=65535&q;else{if(!(16&U)){if(!(64&U)){q=I[(65535&q)+(C&(1<>>=U,A-=U),A<15&&(C+=Y[d++]<>>=U=q>>>24,A-=U,!(16&(U=q>>>16&255))){if(!(64&U)){q=L[(65535&q)+(C&(1<>>=U,A-=U,(U=p-g)>3,C&=(1<<(A-=V<<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 C(){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 A(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(j),te.distcode=te.distdyn=new o.Buf32(w),te.sane=1,te.back=-1,v):_}function I(se){var te;return se&&se.state?((te=se.state).wsize=0,te.whave=0,te.wnext=0,A(se)):_}function L(se,te){var Y,de;return se&&se.state?(de=se.state,te<0?(Y=0,te=-te):(Y=1+(te>>4),te<48&&(te&=15)),te&&(te<8||15=ae.wsize?(o.arraySet(ae.window,te,Y-ae.wsize,ae.wsize,0),ae.wnext=0,ae.whave=ae.wsize):(de<(ie=ae.wsize-ae.wnext)&&(ie=de),o.arraySet(ae.window,te,Y-de,ie,ae.wnext),(de-=ie)?(o.arraySet(ae.window,te,Y-de,de,0),ae.wnext=de,ae.whave=ae.wsize):(ae.wnext+=ie,ae.wnext===ae.wsize&&(ae.wnext=0),ae.whave>>8&255,Y.check=i(Y.check,ot,2,0),we=ye=0,Y.mode=2;break}if(Y.flags=0,Y.head&&(Y.head.done=!1),!(1&Y.wrap)||(((255&ye)<<8)+(ye>>8))%31){se.msg="incorrect header check",Y.mode=30;break}if((15&ye)!=8){se.msg="unknown compression method",Y.mode=30;break}if(we-=4,he=8+(15&(ye>>>=4)),Y.wbits===0)Y.wbits=he;else if(he>Y.wbits){se.msg="invalid window size",Y.mode=30;break}Y.dmax=1<>8&1),512&Y.flags&&(ot[0]=255&ye,ot[1]=ye>>>8&255,Y.check=i(Y.check,ot,2,0)),we=ye=0,Y.mode=3;case 3:for(;we<32;){if(pe===0)break e;pe--,ye+=de[ae++]<>>8&255,ot[2]=ye>>>16&255,ot[3]=ye>>>24&255,Y.check=i(Y.check,ot,4,0)),we=ye=0,Y.mode=4;case 4:for(;we<16;){if(pe===0)break e;pe--,ye+=de[ae++]<>8),512&Y.flags&&(ot[0]=255&ye,ot[1]=ye>>>8&255,Y.check=i(Y.check,ot,2,0)),we=ye=0,Y.mode=5;case 5:if(1024&Y.flags){for(;we<16;){if(pe===0)break e;pe--,ye+=de[ae++]<>>8&255,Y.check=i(Y.check,ot,2,0)),we=ye=0}else Y.head&&(Y.head.extra=null);Y.mode=6;case 6:if(1024&Y.flags&&(pe<(_e=Y.length)&&(_e=pe),_e&&(Y.head&&(he=Y.head.extra_len-Y.length,Y.head.extra||(Y.head.extra=new Array(Y.head.extra_len)),o.arraySet(Y.head.extra,de,ae,_e,he)),512&Y.flags&&(Y.check=i(Y.check,de,_e,ae)),pe-=_e,ae+=_e,Y.length-=_e),Y.length))break e;Y.length=0,Y.mode=7;case 7:if(2048&Y.flags){if(pe===0)break e;for(_e=0;he=de[ae+_e++],Y.head&&he&&Y.length<65536&&(Y.head.name+=String.fromCharCode(he)),he&&_e>9&1,Y.head.done=!0),se.adler=Y.check=0,Y.mode=12;break;case 10:for(;we<32;){if(pe===0)break e;pe--,ye+=de[ae++]<>>=7&we,we-=7&we,Y.mode=27;break}for(;we<3;){if(pe===0)break e;pe--,ye+=de[ae++]<>>=1)){case 0:Y.mode=14;break;case 1:if(V(Y),Y.mode=20,te!==6)break;ye>>>=2,we-=2;break e;case 2:Y.mode=17;break;case 3:se.msg="invalid block type",Y.mode=30}ye>>>=2,we-=2;break;case 14:for(ye>>>=7&we,we-=7&we;we<32;){if(pe===0)break e;pe--,ye+=de[ae++]<>>16^65535)){se.msg="invalid stored block lengths",Y.mode=30;break}if(Y.length=65535&ye,we=ye=0,Y.mode=15,te===6)break e;case 15:Y.mode=16;case 16:if(_e=Y.length){if(pe<_e&&(_e=pe),be<_e&&(_e=be),_e===0)break e;o.arraySet(ie,de,ae,_e,le),pe-=_e,ae+=_e,be-=_e,le+=_e,Y.length-=_e;break}Y.mode=12;break;case 17:for(;we<14;){if(pe===0)break e;pe--,ye+=de[ae++]<>>=5,we-=5,Y.ndist=1+(31&ye),ye>>>=5,we-=5,Y.ncode=4+(15&ye),ye>>>=4,we-=4,286>>=3,we-=3}for(;Y.have<19;)Y.lens[qe[Y.have++]]=0;if(Y.lencode=Y.lendyn,Y.lenbits=7,nt={bits:Y.lenbits},Ve=u(0,Y.lens,0,19,Y.lencode,0,Y.work,nt),Y.lenbits=nt.bits,Ve){se.msg="invalid code lengths set",Y.mode=30;break}Y.have=0,Y.mode=19;case 19:for(;Y.have>>16&255,Ue=65535&ke,!((Fe=ke>>>24)<=we);){if(pe===0)break e;pe--,ye+=de[ae++]<>>=Fe,we-=Fe,Y.lens[Y.have++]=Ue;else{if(Ue===16){for(Qe=Fe+2;we>>=Fe,we-=Fe,Y.have===0){se.msg="invalid bit length repeat",Y.mode=30;break}he=Y.lens[Y.have-1],_e=3+(3&ye),ye>>>=2,we-=2}else if(Ue===17){for(Qe=Fe+3;we>>=Fe)),ye>>>=3,we-=3}else{for(Qe=Fe+7;we>>=Fe)),ye>>>=7,we-=7}if(Y.have+_e>Y.nlen+Y.ndist){se.msg="invalid bit length repeat",Y.mode=30;break}for(;_e--;)Y.lens[Y.have++]=he}}if(Y.mode===30)break;if(Y.lens[256]===0){se.msg="invalid code -- missing end-of-block",Y.mode=30;break}if(Y.lenbits=9,nt={bits:Y.lenbits},Ve=u(p,Y.lens,0,Y.nlen,Y.lencode,0,Y.work,nt),Y.lenbits=nt.bits,Ve){se.msg="invalid literal/lengths set",Y.mode=30;break}if(Y.distbits=6,Y.distcode=Y.distdyn,nt={bits:Y.distbits},Ve=u(g,Y.lens,Y.nlen,Y.ndist,Y.distcode,0,Y.work,nt),Y.distbits=nt.bits,Ve){se.msg="invalid distances set",Y.mode=30;break}if(Y.mode=20,te===6)break e;case 20:Y.mode=21;case 21:if(6<=pe&&258<=be){se.next_out=le,se.avail_out=be,se.next_in=ae,se.avail_in=pe,Y.hold=ye,Y.bits=we,d(se,Ke),le=se.next_out,ie=se.output,be=se.avail_out,ae=se.next_in,de=se.input,pe=se.avail_in,ye=Y.hold,we=Y.bits,Y.mode===12&&(Y.back=-1);break}for(Y.back=0;Ae=(ke=Y.lencode[ye&(1<>>16&255,Ue=65535&ke,!((Fe=ke>>>24)<=we);){if(pe===0)break e;pe--,ye+=de[ae++]<>ut)])>>>16&255,Ue=65535&ke,!(ut+(Fe=ke>>>24)<=we);){if(pe===0)break e;pe--,ye+=de[ae++]<>>=ut,we-=ut,Y.back+=ut}if(ye>>>=Fe,we-=Fe,Y.back+=Fe,Y.length=Ue,Ae===0){Y.mode=26;break}if(32&Ae){Y.back=-1,Y.mode=12;break}if(64&Ae){se.msg="invalid literal/length code",Y.mode=30;break}Y.extra=15&Ae,Y.mode=22;case 22:if(Y.extra){for(Qe=Y.extra;we>>=Y.extra,we-=Y.extra,Y.back+=Y.extra}Y.was=Y.length,Y.mode=23;case 23:for(;Ae=(ke=Y.distcode[ye&(1<>>16&255,Ue=65535&ke,!((Fe=ke>>>24)<=we);){if(pe===0)break e;pe--,ye+=de[ae++]<>ut)])>>>16&255,Ue=65535&ke,!(ut+(Fe=ke>>>24)<=we);){if(pe===0)break e;pe--,ye+=de[ae++]<>>=ut,we-=ut,Y.back+=ut}if(ye>>>=Fe,we-=Fe,Y.back+=Fe,64&Ae){se.msg="invalid distance code",Y.mode=30;break}Y.offset=Ue,Y.extra=15&Ae,Y.mode=24;case 24:if(Y.extra){for(Qe=Y.extra;we>>=Y.extra,we-=Y.extra,Y.back+=Y.extra}if(Y.offset>Y.dmax){se.msg="invalid distance too far back",Y.mode=30;break}Y.mode=25;case 25:if(be===0)break e;if(_e=Ke-be,Y.offset>_e){if((_e=Y.offset-_e)>Y.whave&&Y.sane){se.msg="invalid distance too far back",Y.mode=30;break}Me=_e>Y.wnext?(_e-=Y.wnext,Y.wsize-_e):Y.wnext-_e,_e>Y.length&&(_e=Y.length),Te=Y.window}else Te=ie,Me=le-Y.offset,_e=Y.length;for(be<_e&&(_e=be),be-=_e,Y.length-=_e;ie[le++]=Te[Me++],--_e;);Y.length===0&&(Y.mode=21);break;case 26:if(be===0)break e;ie[le++]=Y.length,be--,Y.mode=21;break;case 27:if(Y.wrap){for(;we<32;){if(pe===0)break e;pe--,ye|=de[ae++]<$?(U=Me[Te+w[te]],we[Ne+w[te]]):(U=96,0),C=1<>le)+(A-=C)]=q<<24|U<<16|V|0,A!==0;);for(C=1<>=1;if(C!==0?(ye&=C-1,ye+=C):ye=0,te++,--Ke[se]==0){if(se===de)break;se=g[v+w[te]]}if(ie>>7)]}function Ne(ke,ot){ke.pending_buf[ke.pending++]=255&ot,ke.pending_buf[ke.pending++]=ot>>>8&255}function Ke(ke,ot,qe){ke.bi_valid>N-qe?(ke.bi_buf|=ot<>N-ke.bi_valid,ke.bi_valid+=qe-N):(ke.bi_buf|=ot<>>=1,qe<<=1,0<--ot;);return qe>>>1}function Te(ke,ot,qe){var lt,We,Ye=new Array(w+1),mt=0;for(lt=1;lt<=w;lt++)Ye[lt]=mt=mt+qe[lt-1]<<1;for(We=0;We<=ot;We++){var Ze=ke[2*We+1];Ze!==0&&(ke[2*We]=Me(Ye[Ze]++,Ze))}}function Fe(ke){var ot;for(ot=0;ot>1;1<=qe;qe--)ut(ke,Ye,qe);for(We=He;qe=ke.heap[1],ke.heap[1]=ke.heap[ke.heap_len--],ut(ke,Ye,1),lt=ke.heap[1],ke.heap[--ke.heap_max]=qe,ke.heap[--ke.heap_max]=lt,Ye[2*We]=Ye[2*qe]+Ye[2*lt],ke.depth[We]=(ke.depth[qe]>=ke.depth[lt]?ke.depth[qe]:ke.depth[lt])+1,Ye[2*qe+1]=Ye[2*lt+1]=We,ke.heap[1]=We++,ut(ke,Ye,1),2<=ke.heap_len;);ke.heap[--ke.heap_max]=ke.heap[1],function(Rt,qt){var ls,Kt,Qt,fs,dr,bt,ks=qt.dyn_tree,ir=qt.max_code,Rr=qt.stat_desc.static_tree,ca=qt.stat_desc.has_stree,ii=qt.stat_desc.extra_bits,lo=qt.stat_desc.extra_base,Oa=qt.stat_desc.max_length,yn=0;for(fs=0;fs<=w;fs++)Rt.bl_count[fs]=0;for(ks[2*Rt.heap[Rt.heap_max]+1]=0,ls=Rt.heap_max+1;ls>=7;We<_;We++)for(pe[We]=Ye<<7,ot=0;ot<1<>>=1)if(1&et&&Ze.dyn_ltree[2*He]!==0)return l;if(Ze.dyn_ltree[18]!==0||Ze.dyn_ltree[20]!==0||Ze.dyn_ltree[26]!==0)return i;for(He=32;He>>3,(Ye=ke.static_len+3+7>>>3)<=We&&(We=Ye)):We=Ye=qe+5,qe+4<=We&&ot!==-1?Qe(ke,ot,qe,lt):ke.strategy===4||Ye===We?(Ke(ke,2+(lt?1:0),3),De(ke,X,se)):(Ke(ke,4+(lt?1:0),3),function(Ze,He,et,Rt){var qt;for(Ke(Ze,He-257,5),Ke(Ze,et-1,5),Ke(Ze,Rt-4,4),qt=0;qt>>8&255,ke.pending_buf[ke.d_buf+2*ke.last_lit+1]=255&ot,ke.pending_buf[ke.l_buf+ke.last_lit]=255&qe,ke.last_lit++,ot===0?ke.dyn_ltree[2*qe]++:(ke.matches++,ot--,ke.dyn_ltree[2*(Y[qe]+g+1)]++,ke.dyn_dtree[2*we(ot)]++),ke.last_lit===ke.lit_bufsize-1},a._tr_align=function(ke){Ke(ke,2,3),_e(ke,A,X),function(ot){ot.bi_valid===16?(Ne(ot,ot.bi_buf),ot.bi_buf=0,ot.bi_valid=0):8<=ot.bi_valid&&(ot.pending_buf[ot.pending++]=255&ot.bi_buf,ot.bi_buf>>=8,ot.bi_valid-=8)}(ke)}},{"../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,g,v=1,_={},b=!1,j=l.document,w=Object.getPrototypeOf&&Object.getPrototypeOf(l);w=w&&w.setTimeout?w:l,d={}.toString.call(l.process)==="[object process]"?function(I){process.nextTick(function(){C(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}}()?(g="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",A,!1):l.attachEvent("onmessage",A),function(I){l.postMessage(g+I,"*")}):l.MessageChannel?((p=new MessageChannel).port1.onmessage=function(I){C(I.data)},function(I){p.port2.postMessage(I)}):j&&"onreadystatechange"in j.createElement("script")?(u=j.documentElement,function(I){var L=j.createElement("script");L.onreadystatechange=function(){C(I),L.onreadystatechange=null,u.removeChild(L),L=null},u.appendChild(L)}):function(I){setTimeout(C,0,I)},w.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 m0<"u"?m0:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(nKe);var JOt=nKe.exports;const e8t=_o(JOt);function Fme(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 t8t=()=>{const{isAdmin:t}=Gs(),[s,r]=S.useState(null),[n,a]=S.useState(null),[o,l]=S.useState("all"),[i,d]=S.useState(new Set),[u,p]=S.useState(!1),[g,v]=S.useState(!1),[_,b]=S.useState("images"),[j,w]=S.useState(null),{data:N=[],isLoading:C}=Ct({queryKey:["social-swag-2"],queryFn:async()=>{const{data:pe,error:be}=await G.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(be)throw be;return pe}}),{data:A=[]}=Ct({queryKey:["social-swag-2-months"],queryFn:async()=>{const{data:pe,error:be}=await G.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(be)throw be;return pe}}),{data:I=[]}=Ct({queryKey:["social-swag-2-reels"],queryFn:async()=>{const{data:pe,error:be}=await G.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(be)throw be;return pe}}),{data:L=[]}=Ct({queryKey:["my-social-accounts-count"],queryFn:async()=>{const{data:pe,error:be}=await G.from("social_accounts").select("id, platform").eq("is_active",!0);if(be)throw be;return pe||[]}}),R=L.length>0,$=S.useMemo(()=>o==="all"?null:I.find(pe=>pe.month===o)||null,[o,I]),q=S.useMemo(()=>[...new Set(N.map(be=>be.month))].sort((be,ye)=>ye.localeCompare(be)),[N]);S.useEffect(()=>{q.length>0&&o==="all"&&l(q[0])},[q,o]);const U=pe=>{try{const be=J1e(pe,"yyyy-MM",new Date);return ws(be,"MMMM yyyy")}catch{return pe}},V=S.useMemo(()=>o==="all"?N:N.filter(pe=>pe.month===o),[o,N]),X=S.useMemo(()=>{var pe;return o==="all"?null:((pe=A.find(be=>be.month===o))==null?void 0:pe.canva_link)||null},[o,A]),se=async pe=>{try{await navigator.clipboard.writeText(pe),fe.success("Caption copied to clipboard!")}catch{fe.error("Failed to copy caption")}},te=async(pe,be)=>{try{const we=await(await fetch(pe)).blob(),Ne=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),Ke=navigator.canShare&&navigator.canShare({files:[new File([we],"test.jpg",{type:"image/jpeg"})]});if(Ne&&Ke){const _e=new File([we],`social-swag-${be}.jpg`,{type:"image/jpeg"});await navigator.share({files:[_e],title:"Social Swag Image"}),fe.success("Image ready to save!")}else{const _e=window.URL.createObjectURL(we),Me=document.createElement("a");Me.href=_e,Me.download=`social-swag-${be}.jpg`,document.body.appendChild(Me),Me.click(),document.body.removeChild(Me),window.URL.revokeObjectURL(_e),fe.success("Image downloaded!")}}catch(ye){ye.name!=="AbortError"&&fe.error("Failed to download image")}},Y=pe=>{d(be=>{const ye=new Set(be);return ye.has(pe)?ye.delete(pe):ye.add(pe),ye})},de=()=>{d(new Set(V.map(pe=>pe.id)))},ie=()=>{d(new Set),p(!1)},ae=async()=>{const pe=V.filter(be=>i.has(be.id));if(pe.length===0){fe.error("No images selected");return}v(!0),fe.info(`Preparing ${pe.length} images for download...`);try{const be=new e8t,ye=[...pe].sort((Me,Te)=>Me.sort_order-Te.sort_order);for(let Me=0;Me{u?Y(pe.id):r(pe)};return e.jsx(Ms,{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(at,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(mn,{className:"h-3 w-3 mr-1"}),"New content monthly"]}),e.jsxs(at,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(Jo,{className:"h-3 w-3 mr-1"}),N.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(ja,{defaultValue:"gallery",className:"space-y-6",children:[e.jsxs(va,{className:"grid w-full max-w-md grid-cols-2",children:[e.jsxs(Ns,{value:"gallery",className:"gap-2",children:[e.jsx(Jo,{className:"h-4 w-4"}),"Gallery"]}),e.jsxs(Ns,{value:"scheduled",className:"gap-2",children:[e.jsx(kc,{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(Ud,{className:"h-5 w-5 text-blue-600"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Vd,{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(Ho,{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(In,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Ud,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Vd,{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(at,{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(pe=>e.jsx("button",{onClick:()=>l(pe),className:Et("px-4 py-2 rounded-full text-sm font-medium transition-all",o===pe?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:U(pe)},pe))}),o!=="all"&&(X?e.jsxs("a",{href:X,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"),ie()},className:Et("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"),ie()},className:Et("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(au,{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 (",V.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,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:g,className:"gap-2",children:[e.jsx(gi,{className:"h-4 w-4"}),g?"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(fa,{className:"h-4 w-4"}),"Select Images"]})})]}),C&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!C&&_==="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:V.map(pe=>{const be=i.has(pe.id);return e.jsx(Ee,{className:Et("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(pe),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:Fme(pe.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"}),pe.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:ws(new Date(pe.post_date+"T00:00:00"),"MMM d")})}),u&&e.jsx("div",{className:Et("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(fa,{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"})})]})},pe.id)})}),V.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."})]})]}),!C&&_==="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:Fme($.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(at,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(au,{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(au,{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(vs,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(ys,{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:Fme(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"}),ws(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 ",ws(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:()=>{w({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(Ta,{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(gi,{className:"h-4 w-4"}),"Download"]})]})]})]})]})})})}),e.jsx(vs,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(ys,{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(au,{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(rn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})}),e.jsx(XOt,{open:!!j,onOpenChange:pe=>!pe&&w(null),imageUrl:(j==null?void 0:j.imageUrl)||"",imageId:(j==null?void 0:j.imageId)||"",defaultCaption:(j==null?void 0:j.caption)||"",swagItemId:j==null?void 0:j.imageId})]}),e.jsx(zs,{value:"scheduled",children:e.jsx(QOt,{})})]}):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(In,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Ud,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Vd,{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(at,{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(pe=>e.jsx("button",{onClick:()=>l(pe),className:Et("px-4 py-2 rounded-full text-sm font-medium transition-all",o===pe?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:U(pe)},pe))}),o!=="all"&&(X?e.jsxs("a",{href:X,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"),ie()},className:Et("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"),ie()},className:Et("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(au,{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 (",V.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,className:"gap-2",children:[e.jsx(Ur,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs(K,{size:"sm",onClick:ae,disabled:g,className:"gap-2",children:[e.jsx(gi,{className:"h-4 w-4"}),g?"Downloading...":`Download ${i.size} Selected`]})]}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[e.jsx(fa,{className:"h-4 w-4"}),"Select Images"]})})]}),C&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!C&&_==="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:V.map(pe=>{const be=i.has(pe.id);return e.jsx(Ee,{className:Et("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(pe),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:pe.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:Et("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(fa,{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"})})]})},pe.id)})}),V.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."})]})]}),!C&&_==="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(at,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(au,{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(au,{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(vs,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(ys,{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"}),ws(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(gi,{className:"h-4 w-4"}),"Download"]})]})]})]})})})}),e.jsx(vs,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(ys,{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(au,{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(rn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})})]})]})})},s8t=()=>{const{swagId:t}=Co(),{user:s}=Gs(),{toast:r}=Ea(),n=ns(),{trackEngagement:a}=RL(),[o,l]=S.useState(""),{data:i,isLoading:d}=Ct({queryKey:["social-swag-detail",t],queryFn:async()=>{const{data:N,error:C}=await G.from("social_swag").select("*").eq("id",t).single();if(C)throw C;const{data:A}=await G.from("social_swag_links").select("*").eq("swag_id",t).order("sort_order");return{...N,links:A||[]}},enabled:!!t});S.useEffect(()=>{i&&a("social_swag",i.id,i.title,"view")},[i==null?void 0:i.id]);const{data:u=[]}=Ct({queryKey:["social-swag-likes",t],queryFn:async()=>{const{data:N,error:C}=await G.from("social_swag_likes").select("*").eq("swag_id",t);if(C)throw C;return N},enabled:!!t}),{data:p=[]}=Ct({queryKey:["social-swag-comments",t],queryFn:async()=>{const{data:N,error:C}=await G.from("social_swag_comments").select("*").eq("swag_id",t).order("created_at",{ascending:!1});if(C)throw C;const A=[...new Set(N.map(R=>R.user_id))],{data:I}=await G.from("profiles").select("id, name").in("id",A),L=new Map((I==null?void 0:I.map(R=>[R.id,R.name]))||[]);return N.map(R=>({...R,user_name:L.get(R.user_id)||"Unknown User"}))},enabled:!!t}),g=Ot({mutationFn:async N=>{const{error:C}=await G.from("social_swag_comments").insert({swag_id:t,user_id:s.id,content:N});if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),l(""),r({title:"Comment added!"})},onError:N=>{r({title:"Error adding comment",description:N.message,variant:"destructive"})}}),v=Ot({mutationFn:async N=>{const{error:C}=await G.from("social_swag_comments").delete().eq("id",N);if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),r({title:"Comment deleted"})}}),_=Ot({mutationFn:async()=>{const N=u.find(C=>C.user_id===(s==null?void 0:s.id));if(N){const{error:C}=await G.from("social_swag_likes").delete().eq("id",N.id);if(C)throw C}else{const{error:C}=await G.from("social_swag_likes").insert({swag_id:t,user_id:s.id});if(C)throw C}},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-likes",t]})}}),b=u.some(N=>N.user_id===(s==null?void 0:s.id)),j=N=>N.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),w=N=>{N.preventDefault(),!(!o.trim()||!s)&&g.mutate(o.trim())};return d?e.jsx(Ms,{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(Ms,{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(Ka,{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(kM,{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(hu,{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(Io,{className:"h-4 w-4"}),i.links.length===1?"Canva Link":"Canva Links"]}),e.jsx("div",{className:"grid gap-2",children:i.links.map(N=>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(N.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:N.title}),e.jsx(rn,{className:"h-4 w-4 text-muted-foreground"})]},N.id))})]})}),e.jsx(sc,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(pc,{className:"h-5 w-5"}),"Comments (",p.length,")"]}),s?e.jsxs("form",{onSubmit:w,className:"flex gap-2",children:[e.jsx(Tr,{placeholder:"Add a comment...",value:o,onChange:N=>l(N.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()||g.isPending,children:e.jsx(Ta,{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(N=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(fn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(gn,{className:"text-sm",children:j(N.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:N.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Sd(new Date(N.created_at),{addSuffix:!0})}),N.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>v.mutate(N.id),children:e.jsx(jr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:N.content})]})]})})},N.id))})]})]})}):e.jsx(Ms,{title:"Social Swag",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Io,{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"})})]})})},r8t=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=S.useState(!0),[i,d]=S.useState(!0),[u,p]=S.useState(!0),g=v=>v.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(c5,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsxs(mf,{open:o,onOpenChange:l,children:[e.jsx(pf,{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(Vo,{className:"h-4 w-4"}):e.jsx(qa,{className:"h-4 w-4"})]})}),e.jsx(ff,{className:"space-y-1 pl-2",children:t.map(v=>e.jsxs(K,{variant:r===v.id?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(v.id),children:[e.jsx("span",{className:"mr-2",children:v.icon||"📂"}),e.jsx("span",{className:"truncate",children:v.name})]},v.id))})]}),s.length>0&&e.jsxs(mf,{open:i,onOpenChange:d,children:[e.jsx(pf,{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(Fu,{className:"h-3 w-3"}),"Your Groups"]}),i?e.jsx(Vo,{className:"h-4 w-4"}):e.jsx(qa,{className:"h-4 w-4"})]})}),e.jsx(ff,{className:"space-y-1 pl-2",children:s.map(v=>e.jsxs(K,{variant:r===`group:${v.id}`?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(`group:${v.id}`),children:[e.jsx("span",{className:"mr-2",children:v.icon||"🔒"}),e.jsx("span",{className:"truncate",children:v.name})]},v.id))})]}),e.jsxs(mf,{open:u,onOpenChange:p,children:[e.jsx(pf,{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(Vo,{className:"h-4 w-4"}):e.jsx(qa,{className:"h-4 w-4"})]})}),e.jsx(ff,{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(v=>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(fn,{className:"h-7 w-7",children:[e.jsx(Ma,{src:v.avatarUrl}),e.jsx(gn,{className:"text-xs",children:g(v.name)})]}),e.jsx(Wc,{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:v.name})]},v.id))})]})]})})})},n8t=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=S.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:",""),g=s.find(v=>v.id===p);return g?`🔒 ${g.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(yu,{children:[e.jsx(vu,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"flex-1 justify-between",children:[e.jsx("span",{className:"truncate",children:d()}),e.jsx(Vo,{className:"h-4 w-4 ml-2 shrink-0"})]})}),e.jsxs(Wd,{className:"w-56 bg-background border",children:[e.jsxs(Da,{onClick:()=>n("all"),children:[e.jsx(c5,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsx(k_,{}),e.jsx(wge,{className:"text-xs text-muted-foreground",children:"Categories"}),t.map(u=>e.jsxs(Da,{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(k_,{}),e.jsxs(wge,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Fu,{className:"h-3 w-3"}),"Your Groups"]}),s.map(u=>e.jsxs(Da,{onClick:()=>n(`group:${u.id}`),children:[e.jsx("span",{className:"mr-2",children:u.icon||"🔒"}),u.name]},u.id))]})]})]}),e.jsxs(fM,{open:o,onOpenChange:l,children:[e.jsx(s_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(tS,{children:[e.jsx(gM,{children:e.jsxs(xM,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Online Now (",a.length,")"]})}),e.jsx(Fi,{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(fn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:u.avatarUrl}),e.jsx(gn,{children:i(u.name)})]}),e.jsx(Wc,{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 zme,yle="HoverCard",[aKe]=Tc(yle,[dy]),vle=dy(),[a8t,awe]=aKe(yle),iKe=t=>{const{__scopeHoverCard:s,children:r,open:n,defaultOpen:a,onOpenChange:o,openDelay:l=700,closeDelay:i=300}=t,d=vle(s),u=S.useRef(0),p=S.useRef(0),g=S.useRef(!1),v=S.useRef(!1),[_,b]=fu({prop:n,defaultProp:a??!1,onChange:o,caller:yle}),j=S.useCallback(()=>{clearTimeout(p.current),u.current=window.setTimeout(()=>b(!0),l)},[l,b]),w=S.useCallback(()=>{clearTimeout(u.current),!g.current&&!v.current&&(p.current=window.setTimeout(()=>b(!1),i))},[i,b]),N=S.useCallback(()=>b(!1),[b]);return S.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(p.current)},[]),e.jsx(a8t,{scope:s,open:_,onOpenChange:b,onOpen:j,onClose:w,onDismiss:N,hasSelectionRef:g,isPointerDownOnContentRef:v,children:e.jsx(uL,{...d,children:r})})};iKe.displayName=yle;var oKe="HoverCardTrigger",lKe=S.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=awe(oKe,r),o=vle(r);return e.jsx(iM,{asChild:!0,...o,children:e.jsx(Qr.a,{"data-state":a.open?"open":"closed",...n,ref:s,onPointerEnter:Mr(t.onPointerEnter,Nae(a.onOpen)),onPointerLeave:Mr(t.onPointerLeave,Nae(a.onClose)),onFocus:Mr(t.onFocus,a.onOpen),onBlur:Mr(t.onBlur,a.onClose),onTouchStart:Mr(t.onTouchStart,l=>l.preventDefault())})})});lKe.displayName=oKe;var i8t="HoverCardPortal",[z1s,o8t]=aKe(i8t,{forceMount:void 0}),kae="HoverCardContent",cKe=S.forwardRef((t,s)=>{const r=o8t(kae,t.__scopeHoverCard),{forceMount:n=r.forceMount,...a}=t,o=awe(kae,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,Nae(o.onOpen)),onPointerLeave:Mr(t.onPointerLeave,Nae(o.onClose)),ref:s})})});cKe.displayName=kae;var l8t=S.forwardRef((t,s)=>{const{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,...i}=t,d=awe(kae,r),u=vle(r),p=S.useRef(null),g=Aa(s,p),[v,_]=S.useState(!1);return S.useEffect(()=>{if(v){const b=document.body;return zme=b.style.userSelect||b.style.webkitUserSelect,b.style.userSelect="none",b.style.webkitUserSelect="none",()=>{b.style.userSelect=zme,b.style.webkitUserSelect=zme}}},[v]),S.useEffect(()=>{if(p.current){const b=()=>{_(!1),d.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var w;((w=document.getSelection())==null?void 0:w.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]),S.useEffect(()=>{p.current&&u8t(p.current).forEach(j=>j.setAttribute("tabindex","-1"))}),e.jsx(D_,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:Mr(o,b=>{b.preventDefault()}),onDismiss:d.onDismiss,children:e.jsx(hL,{...u,...i,onPointerDown:Mr(i.onPointerDown,b=>{b.currentTarget.contains(b.target)&&_(!0),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!0}),ref:g,style:{...i.style,userSelect:v?"text":void 0,WebkitUserSelect:v?"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)"}})})}),c8t="HoverCardArrow",d8t=S.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=vle(r);return e.jsx(mL,{...a,...n,ref:s})});d8t.displayName=c8t;function Nae(t){return s=>s.pointerType==="touch"?void 0:t()}function u8t(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 h8t=iKe,m8t=lKe,dKe=cKe;const p8t=h8t,f8t=m8t,uKe=S.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(dKe,{ref:a,align:s,sideOffset:r,className:Et("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}));uKe.displayName=dKe.displayName;const g8t=[{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"}],x8t=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2),hKe=({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(p8t,{openDelay:200,closeDelay:100,children:[e.jsx(f8t,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:s})}),e.jsx(uKe,{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=g8t.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(fn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:l.user_avatar||void 0}),e.jsx(gn,{className:"text-[10px]",children:x8t(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 y8t({images:t,initialIndex:s=0,open:r,onOpenChange:n}){const[a,o]=S.useState(s),[l,i]=S.useState(!1);S.useEffect(()=>{r&&(o(s),i(!1))},[r,s]);const d=()=>{o(v=>v>0?v-1:t.length-1),i(!1)},u=()=>{o(v=>v{r&&(v.key==="ArrowLeft"&&d(),v.key==="ArrowRight"&&u(),v.key==="Escape"&&n(!1))},[r,t.length]);S.useEffect(()=>(window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)),[p]);const g=t[a];return e.jsx(vs,{open:r,onOpenChange:n,children:e.jsxs(ys,{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(Ol,{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(qa,{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]}),(g==null?void 0:g.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(j5,{className:"h-5 w-5"}):e.jsx(o_,{className:"h-5 w-5"})}),e.jsx("div",{className:Et("flex items-center justify-center w-full h-full min-h-[50vh] p-4",l?"cursor-zoom-out overflow-auto":"cursor-zoom-in"),onClick:()=>(g==null?void 0:g.type)==="image"&&i(!l),children:(g==null?void 0:g.type)==="video"?e.jsx("video",{src:g.url,controls:!0,autoPlay:!0,className:"max-w-full max-h-[85vh] object-contain",onClick:v=>v.stopPropagation()}):e.jsx("img",{src:g==null?void 0:g.url,alt:"",className:Et("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((v,_)=>e.jsx("button",{onClick:()=>{o(_),i(!1)},className:Et("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:v.type==="video"?e.jsx("video",{src:v.url,className:"w-full h-full object-cover"}):e.jsx("img",{src:v.url,alt:"",className:"w-full h-full object-cover"})},_))})]})})}const sR=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"}],v8t=({commentId:t,reactions:s,currentUserId:r})=>{var u,p;const n=ns(),[a,o]=S.useState(!1),l=s.find(g=>g.user_id===r),i=Ot({mutationFn:async g=>{l?l.reaction_type===g?await G.from("community_comment_reactions").delete().eq("id",l.id):await G.from("community_comment_reactions").update({reaction_type:g}).eq("id",l.id):await G.from("community_comment_reactions").insert({comment_id:t,user_id:r,reaction_type:g})},onSuccess:()=>{n.invalidateQueries({queryKey:["community-posts"]}),o(!1)}}),d={};return s.forEach(g=>{d[g.reaction_type]=(d[g.reaction_type]||0)+1}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.length>0&&e.jsx(hKe,{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(g=>{var v;return e.jsx("span",{className:"text-sm",children:(v=sR.find(_=>_.type===g))==null?void 0:v.emoji},g)})}),e.jsx("span",{children:s.length})]})}),r&&e.jsxs(No,{open:a,onOpenChange:o,children:[e.jsx(So,{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=sR.find(g=>g.type===l.reaction_type))==null?void 0:u.emoji," ",(p=sR.find(g=>g.type===l.reaction_type))==null?void 0:p.label]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ni,{className:"h-3 w-3"}),"Like"]})})}),e.jsx(jo,{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:sR.map(g=>e.jsx("button",{onClick:()=>i.mutate(g.type),className:"text-xl hover:scale-125 transition-transform p-1",title:g.label,children:g.emoji},g.type))})})]})]})};function iwe({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:Et("font-medium hover:underline",p?"text-white bg-[#2a4c64] px-1.5 py-0.5 rounded":"text-primary"),onClick:g=>g.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 g=new URL(d);p=g.hostname+(g.pathname!=="/"?g.pathname.slice(0,20)+(g.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:g=>g.stopPropagation(),children:p},`url-${l++}`)),u&&n.push(u)}a=o.index+o[0].length}return ae.jsx(S.Fragment,{children:i},d))})}function Sae({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=S.useRef(null),g=S.useRef(null),[v,_]=S.useState(!1),[b,j]=S.useState("user"),[w,N]=S.useState(""),[C,A]=S.useState(null),[I,L]=S.useState(0),[R,$]=S.useState({top:0,left:0,width:0}),q=S.useRef(new Map),U=S.useRef(new Map),V=we=>{if(d==="plain"){const Me=[];return q.current.forEach((Fe,Ae)=>{we.includes(`@${Ae}`)&&Me.push(Fe)}),[...new Set(Me)]}const Ne=/@\[([^\]]+)\]\(([^)]+)\)/g,Ke=[];let _e;for(;(_e=Ne.exec(we))!==null;)Ke.push(_e[2]);return[...new Set(Ke)]},X=we=>{if(d==="plain"){const Me=[];return U.current.forEach((Fe,Ae)=>{we.includes(`#${Ae}`)&&Me.push(Fe)}),[...new Set(Me)]}const Ne=/#\[([^\]]+)\]\(([^)]+)\)/g,Ke=[];let _e;for(;(_e=Ne.exec(we))!==null;)Ke.push(_e[2]);return[...new Set(Ke)]};S.useEffect(()=>{if(o){const we=V(t);o(we)}if(l){const we=X(t);l(we)}},[t,o,l,d]);const{data:se=[],isLoading:te}=Ct({queryKey:["mention-users",w],queryFn:async()=>{const we=G.from("profiles").select("id, name").limit(8),Ne=w.length>=1?we.ilike("name",`%${w}%`):we.order("name"),{data:Ke,error:_e}=await Ne;if(_e)throw _e;const Me=Ke.map(Fe=>Fe.id),Te=await W9e(Me);return Ke.map(Fe=>({id:Fe.id,name:Fe.name||"Unknown",avatar_url:Te.get(Fe.id)}))},enabled:v&&b==="user",staleTime:3e4}),{data:Y=[],isLoading:de}=Ct({queryKey:["mention-templates",w],queryFn:async()=>{let we=G.from("canva_templates").select("id, name, preview_image_url").lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(8);w.length>=1&&(we=we.ilike("name",`%${w}%`));const{data:Ne,error:Ke}=await we;if(Ke)throw Ke;return Ne||[]},enabled:v&&b==="template"&&u,staleTime:3e4}),ie=b==="user"?te:de,ae=b==="user"?se:Y,le=we=>we.split(" ").map(Ne=>Ne[0]).join("").toUpperCase().slice(0,2),pe=we=>{const Ne=we.target.value,Ke=we.target.selectionStart;s(Ne);const _e=Ne.substring(0,Ke),Me=_e.lastIndexOf("@"),Te=u?_e.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=_e.substring(Fe+1),ut=Ue.includes(" "),De=Ue.includes(` `);if(!ut&&!De&&Ue.length<=30){A(Fe),N(Ue),j(Ae),_(!0),L(0);return}}_(!1),A(null)},be=we=>{if(C===null)return;const Ne=t.substring(0,C),Ke=t.substring(C+w.length+1),_e=b==="user"?"@":"#",Me=d==="plain"?`${_e}${we.name} `:`${_e}[${we.name}](${we.id}) `;d==="plain"&&(b==="user"?q.current.set(we.name,we.id):U.current.set(we.name,we.id));const Te=Ne+Me+Ke;s(Te),_(!1),A(null),N(""),setTimeout(()=>{if(p.current){const Fe=Ne.length+Me.length;p.current.focus(),p.current.setSelectionRange(Fe,Fe)}},0)},ye=we=>{if(!(!v||ae.length===0))switch(we.key){case"ArrowDown":we.preventDefault(),L(Ne=>(Ne+1)%ae.length);break;case"ArrowUp":we.preventDefault(),L(Ne=>(Ne-1+ae.length)%ae.length);break;case"Enter":ae[I]&&(we.preventDefault(),be(ae[I]));break;case"Escape":we.preventDefault(),_(!1);break;case"Tab":ae[I]&&(we.preventDefault(),be(ae[I]));break}};return S.useEffect(()=>{const we=Ne=>{g.current&&!g.current.contains(Ne.target)&&p.current&&!p.current.contains(Ne.target)&&_(!1)};return document.addEventListener("mousedown",we),()=>document.removeEventListener("mousedown",we)},[]),S.useEffect(()=>{if(!v)return;const we=()=>{const Ne=p.current;if(!Ne)return;const Ke=Ne.getBoundingClientRect();$({top:Ke.bottom+4,left:Ke.left,width:Ke.width})};return we(),window.addEventListener("resize",we),window.addEventListener("scroll",we,!0),()=>{window.removeEventListener("resize",we),window.removeEventListener("scroll",we,!0)}},[v,t]),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Tr,{ref:p,value:t,onChange:pe,onKeyDown:we=>{ye(we),we.defaultPrevented||i==null||i(we)},placeholder:r,className:Et("resize-none",n),style:{minHeight:a}}),v&&_m.createPortal(e.jsxs("div",{ref:g,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"}),ie?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:w.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((we,Ne)=>e.jsx("li",{className:Et("flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors",Ne===I?"bg-accent":"hover:bg-accent/50"),onClick:()=>be(we),onMouseEnter:()=>L(Ne),children:b==="user"?e.jsxs(e.Fragment,{children:[e.jsxs(fn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:we.avatar_url}),e.jsx(gn,{className:"text-xs",children:le(we.name)})]}),e.jsx("span",{className:"text-sm font-medium truncate",children:we.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:we.preview_image_url?e.jsx("img",{src:we.preview_image_url,alt:"",className:"w-full h-full object-cover"}):e.jsx(Rl,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate",children:we.name})]})},we.id))})]}),document.body)]})}function _8t(t){const s=/#\[([^\]]+)\]\(([^)]+)\)/g,r=[];let n;for(;(n=s.exec(t))!==null;)r.push(n[2]);return[...new Set(r)]}const LAe=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2);function mKe({comment:t,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l=0}){const i=ns(),[d,u]=S.useState(!1),[p,g]=S.useState(""),[v,_]=S.useState([]),b=Ot({mutationFn:async({content:C,parentCommentId:A})=>{const{data:I,error:L}=await G.from("community_comments").insert({post_id:s,user_id:r,content:C,parent_comment_id:A}).select("id").single();if(L)throw L;const R=v;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"]}),g(""),_([]),u(!1)}}),j=Ot({mutationFn:async C=>{const{error:A}=await G.from("community_comments").delete().eq("id",C);if(A)throw A},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),w=()=>{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(fn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ma,{src:t.user_avatar||void 0}),e.jsx(gn,{className:"text-xs",children:LAe(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(iwe,{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(v8t,{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(wP,{className:"h-3 w-3"}),"Reply"]}),(t.user_id===r||o)&&e.jsx("button",{onClick:()=>j.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(fn,{className:"h-6 w-6 shrink-0 mt-1",children:[e.jsx(Ma,{src:n||void 0}),e.jsx(gn,{className:"text-xs",children:LAe((a==null?void 0:a.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2 items-start",children:[e.jsx(Sae,{placeholder:`Reply to ${t.user_name}...`,value:p,onChange:g,onMentionsChange:_,mentionFormat:"plain",className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:w,disabled:!p.trim()||b.isPending,className:"h-8 px-2 mt-0.5",children:e.jsx(Ta,{className:"h-3 w-3"})})]})]})]})]}),t.replies&&t.replies.length>0&&e.jsx("div",{className:"mt-2 space-y-2",children:t.replies.map(C=>e.jsx(mKe,{comment:C,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l+1},C.id))})]})}const rR=[{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"}],b8t=()=>{const{user:t,isBrokerageManager:s,managedBrokerages:r,isAdmin:n}=Gs(),{avatarUrl:a}=H9e(t==null?void 0:t.id),{onlineUsers:o}=iqe(),{toast:l}=Ea(),i=ns(),d=S.useRef(null),[u,p]=S.useState("all"),[g,v]=S.useState(""),[_,b]=S.useState(""),[j,w]=S.useState(""),[N,C]=S.useState([]),[A,I]=S.useState([]),[L,R]=S.useState(""),[$,q]=S.useState(!1),[U,V]=S.useState(null),[X,se]=S.useState(""),[te,Y]=S.useState(new Set),[de,ie]=S.useState({}),[ae,le]=S.useState({}),[pe,be]=S.useState([]),[ye,we]=S.useState([]),[Ne,Ke]=S.useState({open:!1,images:[],index:0});S.useEffect(()=>{if(u.startsWith("group:")){const et=u.replace("group:","");w(et),b("")}else u!=="all"?(b(u),w("")):(b(""),w(""))},[u]);const{data:_e=[]}=Ct({queryKey:["community-categories"],queryFn:async()=>{const{data:et,error:Rt}=await G.from("community_categories").select("*").order("sort_order");if(Rt)throw Rt;return et}}),{data:Me=[]}=Ct({queryKey:["community-private-groups"],queryFn:async()=>{const{data:et,error:Rt}=await G.from("community_private_groups").select("id, name, description, icon, brokerage_id, sort_order").order("sort_order");if(Rt)throw Rt;return et}}),Te=20,{data:Fe,isLoading:Ae,hasNextPage:Ue,fetchNextPage:ut,isFetchingNextPage:De}=dut({queryKey:["community-posts",u],initialPageParam:0,queryFn:async({pageParam:et})=>{var ze;const Rt=et*Te,qt=Rt+Te;let ls=G.from("community_posts").select("*").order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(Rt,qt);if(u.startsWith("group:")){const st=u.replace("group:","");ls=ls.eq("private_group_id",st)}else u==="all"||(ls=ls.eq("category_id",u).is("private_group_id",null));const{data:Kt,error:Qt}=await ls;if(Qt)throw Qt;const fs=((Kt==null?void 0:Kt.length)||0)>Te,dr=(Kt||[]).slice(0,Te);if(dr.length===0)return{posts:[],hasMore:!1,nextPage:et+1};const bt=dr.map(st=>st.id),ks=[...new Set(dr.filter(st=>st.category_id).map(st=>st.category_id))].filter(Boolean),[ir,Rr,ca,ii,lo]=await Promise.all([ks.length?G.from("community_categories").select("*").in("id",ks):Promise.resolve({data:[]}),G.from("community_post_media").select("*").in("post_id",bt).order("sort_order"),G.from("community_reactions").select("*").in("post_id",bt),G.from("community_comments").select("*").in("post_id",bt).order("created_at",{ascending:!0}),G.from("community_post_resources").select("*").in("post_id",bt)]),Oa=ir==null?void 0:ir.data,yn=Rr==null?void 0:Rr.data,ta=ca==null?void 0:ca.data,Zt=ii==null?void 0:ii.data,vr=lo==null?void 0:lo.data,Gr=(Zt||[]).map(st=>st.id),[Rn,rs]=await Promise.all([Gr.length?G.from("community_comment_reactions").select("*").in("comment_id",Gr):Promise.resolve({data:[]}),(()=>{const st=(vr||[]).filter(Tt=>Tt.resource_type==="template").map(Tt=>Tt.resource_id);return st.length===0?Promise.resolve({data:[]}):G.from("canva_templates").select("id, name, preview_image_url").in("id",st)})()]),Ln=(Rn==null?void 0:Rn.data)||[],da=(rs==null?void 0:rs.data)||[],Va=new Map(da.map(st=>[st.id,{name:st.name,preview_image_url:st.preview_image_url}])),Jr=Array.from(new Set([...dr.map(st=>st.user_id),...(ta||[]).map(st=>st.user_id),...(Zt||[]).map(st=>st.user_id),...Ln.map(st=>st.user_id)])),[Za,$l]=await Promise.all([Jr.length?G.from("profiles").select("id, name").in("id",Jr):Promise.resolve({data:[]}),W9e(Jr)]),Do=new Map(((ze=Za==null?void 0:Za.data)==null?void 0:ze.map(st=>[st.id,st.name]))||[]),Yc=new Map((Oa||[]).map(st=>[st.id,st])),ct=st=>{const Tt=new Map,Nt=[];return st.forEach(Bt=>{Tt.set(Bt.id,{...Bt,user_name:Do.get(Bt.user_id)||"Unknown User",user_avatar:$l.get(Bt.user_id),reactions:Ln.filter(Yt=>Yt.comment_id===Bt.id).map(Yt=>({...Yt,user_name:Do.get(Yt.user_id)||"Unknown User",user_avatar:$l.get(Yt.user_id)})),replies:[]})}),st.forEach(Bt=>{const Yt=Tt.get(Bt.id);if(Bt.parent_comment_id&&Tt.has(Bt.parent_comment_id)){const Ut=Tt.get(Bt.parent_comment_id);Ut.replies=Ut.replies||[],Ut.replies.push(Yt)}else Nt.push(Yt)}),Nt};return{posts:dr.map(st=>{const Tt=(vr||[]).filter(Nt=>Nt.post_id===st.id).map(Nt=>{let Bt="",Yt=null;if(Nt.resource_type==="template"){const Ut=Va.get(Nt.resource_id);Bt=(Ut==null?void 0:Ut.name)||"Unknown Template",Yt=(Ut==null?void 0:Ut.preview_image_url)||null}return{id:Nt.id,resource_type:Nt.resource_type,resource_id:Nt.resource_id,resource_name:Bt,resource_preview_url:Yt}});return{...st,user_name:Do.get(st.user_id)||"Unknown User",user_avatar:$l.get(st.user_id),category:st.category_id?Yc.get(st.category_id):null,media:(yn||[]).filter(Nt=>Nt.post_id===st.id),reactions:((ta||[]).filter(Nt=>Nt.post_id===st.id)||[]).map(Nt=>({...Nt,user_name:Do.get(Nt.user_id)||"Unknown User",user_avatar:$l.get(Nt.user_id)})),comments:ct((Zt||[]).filter(Nt=>Nt.post_id===st.id)),resources:Tt}}),hasMore:fs,nextPage:et+1}},getNextPageParam:et=>et.hasMore?et.nextPage:void 0}),Dt=S.useMemo(()=>(Fe==null?void 0:Fe.pages.flatMap(et=>et.posts))??[],[Fe]),he=Ot({mutationFn:async()=>{q(!0);const{data:et,error:Rt}=await G.from("community_posts").insert({user_id:t.id,category_id:j?null:_||null,private_group_id:j||null,content:g,link_url:L||null}).select().single();if(Rt)throw Rt;for(let ls=0;ls0){const ls=pe.filter(Kt=>Kt!==t.id).map(Kt=>({post_id:et.id,mentioned_user_id:Kt,mentioned_by_user_id:t.id}));ls.length>0&&await G.from("community_post_mentions").insert(ls)}const qt=_8t(g);if(qt.length>0){const ls=qt.map(Kt=>({post_id:et.id,resource_type:"template",resource_id:Kt}));await G.from("community_post_resources").insert(ls)}return et},onSuccess:async et=>{var Rt;i.invalidateQueries({queryKey:["community-posts"]}),v(""),be([]),we([]),b(""),w(""),C([]),I([]),R(""),l({title:"Post created!"});try{const qt=((Rt=t==null?void 0:t.user_metadata)==null?void 0:Rt.name)||"Someone",ls=g.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),Kt=ls.length>50?ls.substring(0,50)+"...":ls;await G.functions.invoke("send-push-notification",{body:{title:"New Community Post",body:`${qt}: ${Kt}`,url:"/community"}})}catch(qt){console.error("Failed to send push notification:",qt)}},onError:et=>{l({title:"Error creating post",description:et.message,variant:"destructive"})},onSettled:()=>q(!1)}),Ve=Ot({mutationFn:async({postId:et,content:Rt})=>{const{error:qt}=await G.from("community_posts").update({content:Rt}).eq("id",et);if(qt)throw qt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),V(null),se(""),l({title:"Post updated!"})}}),nt=Ot({mutationFn:async et=>{const{error:Rt}=await G.from("community_posts").delete().eq("id",et);if(Rt)throw Rt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:"Post deleted"})}}),Qe=Ot({mutationFn:async({postId:et,isPinned:Rt})=>{const{error:qt}=await G.from("community_posts").update({is_pinned:!Rt,pinned_at:Rt?null:new Date().toISOString(),pinned_by:Rt?null:t==null?void 0:t.id}).eq("id",et);if(qt)throw qt},onSuccess:(et,{isPinned:Rt})=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:Rt?"Post unpinned":"Post pinned to top"})}}),ke=Ot({mutationFn:async({postId:et,reactionType:Rt})=>{var ls;const qt=(ls=Dt.find(Kt=>Kt.id===et))==null?void 0:ls.reactions.find(Kt=>Kt.user_id===(t==null?void 0:t.id));qt?qt.reaction_type===Rt?await G.from("community_reactions").delete().eq("id",qt.id):await G.from("community_reactions").update({reaction_type:Rt}).eq("id",qt.id):await G.from("community_reactions").insert({post_id:et,user_id:t.id,reaction_type:Rt})},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),ot=Ot({mutationFn:async({postId:et,content:Rt})=>{const{data:qt,error:ls}=await G.from("community_comments").insert({post_id:et,user_id:t.id,content:Rt}).select("id").single();if(ls)throw ls;const Kt=ae[et]||[];if(Kt.length>0&&qt){const Qt=Kt.filter(fs=>fs!==t.id).map(fs=>({comment_id:qt.id,mentioned_user_id:fs,mentioned_by_user_id:t.id}));Qt.length>0&&await G.from("community_comment_mentions").insert(Qt)}},onSuccess:(et,{postId:Rt})=>{i.invalidateQueries({queryKey:["community-posts"]}),ie(qt=>({...qt,[Rt]:""})),le(qt=>({...qt,[Rt]:[]}))}});Ot({mutationFn:async et=>{const{error:Rt}=await G.from("community_comments").delete().eq("id",et);if(Rt)throw Rt},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})});const qe=et=>{const Rt=Array.from(et.target.files||[]);if(Rt.length+N.length>10){l({title:"Maximum 10 files allowed",variant:"destructive"});return}C(qt=>[...qt,...Rt]),Rt.forEach(qt=>{const ls=new FileReader;ls.onloadend=()=>{I(Kt=>[...Kt,ls.result])},ls.readAsDataURL(qt)})},lt=et=>{C(Rt=>Rt.filter((qt,ls)=>ls!==et)),I(Rt=>Rt.filter((qt,ls)=>ls!==et))},We=et=>et.split(" ").map(Rt=>Rt[0]).join("").toUpperCase().slice(0,2),Ye=et=>{const Rt={};return et.forEach(qt=>{Rt[qt.reaction_type]=(Rt[qt.reaction_type]||0)+1}),Rt},mt=et=>{var Rt;return(Rt=et.find(qt=>qt.user_id===(t==null?void 0:t.id)))==null?void 0:Rt.reaction_type},Ze=et=>et.reduce((Rt,qt)=>Rt+1+(qt.replies?Ze(qt.replies):0),0),He=et=>{if(n)return!0;if(!s||!et.private_group_id)return!1;const Rt=Me.find(qt=>qt.id===et.private_group_id);return Rt!=null&&Rt.brokerage_id?r.some(qt=>qt.id===Rt.brokerage_id):!1};return e.jsx(Ms,{title:"Community",children:e.jsxs("div",{className:"flex gap-6 w-full isolate z-0",children:[e.jsx(r8t,{categories:_e,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(n8t,{categories:_e,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(fn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:a||void 0}),e.jsx(gn,{children:t!=null&&t.email?We(t.email.split("@")[0]):"U"})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(Sae,{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:g,onChange:v,onMentionsChange:be,onTemplatesChange:we,mentionFormat:"encoded",minHeight:"80px",enableTemplateMentions:n}),A.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:A.map((et,Rt)=>{var qt;return e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[(qt=N[Rt])!=null&&qt.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:()=>lt(Rt),children:e.jsx(Ur,{className:"h-3 w-3"})})]},Rt)})}),L&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Io,{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:qe,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(Io,{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(tr,{value:j||_||"none",onValueChange:et=>{et==="none"?(b(""),w("")):et.startsWith("group:")?(w(et.replace("group:","")),b("")):(b(et),w(""))},children:[e.jsx(Js,{className:"w-[130px] sm:w-[160px] h-8 text-xs sm:text-sm",children:e.jsx(sr,{placeholder:"Select..."})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No category"}),_e.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(tr,{value:_,onValueChange:b,children:[e.jsx(Js,{className:"w-[110px] sm:w-[140px] h-8 text-xs sm:text-sm",children:e.jsx(sr,{placeholder:"Category"})}),e.jsx(er,{children:_e.map(et=>e.jsxs(At,{value:et.id,children:[et.icon," ",et.name]},et.id))})]}),e.jsxs(K,{size:"sm",onClick:()=>he.mutate(),disabled:!g.trim()||$,children:[e.jsx(Ta,{className:"h-4 w-4 mr-1"}),"Post"]})]})]})]})]})})}),Ae?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((et,Rt)=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(gs,{className:"h-10 w-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(gs,{className:"h-4 w-32"}),e.jsx(gs,{className:"h-4 w-full"}),e.jsx(gs,{className:"h-4 w-3/4"})]})]})})},Rt))}):Dt.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(pc,{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:[Dt.map(et=>{var Rt,qt,ls,Kt;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(fn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:et.user_avatar||void 0}),e.jsx(gn,{children:We(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(at,{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(yu,{children:[e.jsx(vu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(ef,{className:"h-4 w-4"})})}),e.jsxs(Wd,{align:"end",children:[He(et)&&et.private_group_id&&e.jsx(Da,{onClick:()=>Qe.mutate({postId:et.id,isPinned:et.is_pinned}),children:et.is_pinned?e.jsxs(e.Fragment,{children:[e.jsx(xP,{className:"h-4 w-4 mr-2"}),"Unpin Post"]}):e.jsxs(e.Fragment,{children:[e.jsx(r_,{className:"h-4 w-4 mr-2"}),"Pin to Top"]})}),et.user_id===(t==null?void 0:t.id)&&e.jsxs(Da,{onClick:()=>{V(et),se(et.content)},children:[e.jsx(Ua,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Da,{className:"text-destructive",onClick:()=>nt.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(r_,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Pinned"})]}),e.jsx("div",{className:"mb-3",children:e.jsx(iwe,{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((Qt,fs)=>{const dr=fs===3&&et.media.length>4,bt=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:()=>Ke({open:!0,images:et.media.map(ks=>({url:ks.media_url,type:ks.media_type==="video"?"video":"image"})),index:fs}),children:[Qt.media_type==="video"?e.jsx("video",{src:Qt.media_url,className:"w-full h-full object-cover transition-transform group-hover:scale-105"}):e.jsx("img",{src:Qt.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"})})})}),dr&&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:["+",bt]})})]},Qt.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:Qt=>{Qt.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(Io,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:et.link_url})]})})]}),et.reactions.length>0&&e.jsx(hKe,{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(Ye(et.reactions)).slice(0,3).map(([Qt])=>{var fs;return e.jsx("span",{className:"text-base",children:(fs=rR.find(dr=>dr.type===Qt))==null?void 0:fs.emoji},Qt)})}),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(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",children:[mt(et.reactions)?e.jsx("span",{className:"mr-1",children:(Rt=rR.find(Qt=>Qt.type===mt(et.reactions)))==null?void 0:Rt.emoji}):e.jsx(hu,{className:"h-4 w-4 mr-1"}),mt(et.reactions)?(qt=rR.find(Qt=>Qt.type===mt(et.reactions)))==null?void 0:qt.label:"Like"]})}),e.jsx(jo,{className:"w-auto p-2",side:"top",children:e.jsx("div",{className:"flex gap-1",children:rR.map(Qt=>e.jsx("button",{onClick:()=>ke.mutate({postId:et.id,reactionType:Qt.type}),className:"text-2xl hover:scale-125 transition-transform p-1",title:Qt.label,children:Qt.emoji},Qt.type))})})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",onClick:()=>Y(Qt=>{const fs=new Set(Qt);return fs.has(et.id)?fs.delete(et.id):fs.add(et.id),fs}),children:[e.jsx(pc,{className:"h-4 w-4 mr-1"}),(()=>{const Qt=Ze(et.comments);return Qt>0?`Comment (${Qt})`:"Comment"})()]})]}),te.has(et.id)&&e.jsxs("div",{className:"space-y-3 mt-3",children:[et.comments.map(Qt=>e.jsx(mKe,{comment:Qt,postId:et.id,currentUserId:t==null?void 0:t.id,currentUserAvatar:a,currentUserEmail:t==null?void 0:t.email,canModerate:He(et)},Qt.id)),t&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(fn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:a||void 0}),e.jsx(gn,{className:"text-xs",children:We(((ls=t.email)==null?void 0:ls.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(Sae,{placeholder:"Write a comment... (use @ to mention)",value:de[et.id]||"",onChange:Qt=>ie(fs=>({...fs,[et.id]:Qt})),onMentionsChange:Qt=>le(fs=>({...fs,[et.id]:Qt})),mentionFormat:"plain",onKeyDown:Qt=>{var fs;Qt.defaultPrevented||Qt.key==="Enter"&&!Qt.shiftKey&&((fs=de[et.id])!=null&&fs.trim())&&(Qt.preventDefault(),ot.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 Qt;(Qt=de[et.id])!=null&&Qt.trim()&&ot.mutate({postId:et.id,content:de[et.id]})},disabled:!((Kt=de[et.id])!=null&&Kt.trim()),className:"h-8 px-2 mt-0.5",children:e.jsx(Ta,{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(vs,{open:!!U,onOpenChange:()=>V(null),children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Edit Post"})}),e.jsx(Tr,{value:X,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:()=>V(null),children:"Cancel"}),e.jsx(K,{onClick:()=>{U&&Ve.mutate({postId:U.id,content:X})},disabled:!X.trim(),children:"Save Changes"})]})]})}),e.jsx(y8t,{images:Ne.images,initialIndex:Ne.index,open:Ne.open,onOpenChange:et=>Ke(Rt=>({...Rt,open:et}))})]})]})})},o4={open:{label:"Open",icon:In,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:pc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:fi,color:"bg-green-500"},closed:{label:"Closed",icon:wc,color:"bg-muted-foreground"}},DAe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function w8t(){const{user:t}=Gs(),s=ns(),[r,n]=S.useState(null),[a,o]=S.useState(""),{data:l=[],isLoading:i}=Ct({queryKey:["support-tickets"],queryFn:async()=>{const{data:g,error:v}=await G.from("support_tickets").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});if(v)throw v;return g},enabled:!!t}),{data:d=[]}=Ct({queryKey:["ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:g,error:v}=await G.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(v)throw v;return g},enabled:!!r}),u=Ot({mutationFn:async g=>{if(!r||!t)throw new Error("Missing data");const{error:v}=await G.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:g,is_admin_reply:!1});if(v)throw v},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 g=o4[r.status].icon;return e.jsx(Ms,{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(Ka,{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(at,{variant:"secondary",children:DAe[r.category]}),e.jsxs(at,{className:o4[r.status].color,children:[e.jsx(g,{className:"h-3 w-3 mr-1"}),o4[r.status].label]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(yr,{children:["Created on ",ws(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(Lt,{children:e.jsx(zt,{className:"text-lg",children:"Conversation"})}),e.jsxs(Oe,{children:[e.jsx(Fi,{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(v=>{var _;return e.jsxs("div",{className:`p-4 rounded-lg ${v.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:v.is_admin_reply?"Support Team":((_=v.profiles)==null?void 0:_.name)||"You"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ws(new Date(v.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:v.content})]},v.id)})})}),r.status!=="closed"&&e.jsxs(e.Fragment,{children:[e.jsx(sc,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Tr,{placeholder:"Type your reply...",value:a,onChange:v=>o(v.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:p,disabled:!a.trim()||u.isPending,className:"self-end",children:e.jsx(Ta,{className:"h-4 w-4"})})]})]})]})]})]})})}return e.jsx(Ms,{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(n0,{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($ge,{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(Zn,{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($ge,{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(pc,{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(g=>{const v=o4[g.status].icon;return e.jsx(Ee,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(g),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:g.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(at,{variant:"outline",className:"text-xs",children:DAe[g.category]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ws(new Date(g.created_at),"MMM d, yyyy")})]})]}),e.jsxs(at,{className:o4[g.status].color,children:[e.jsx(v,{className:"h-3 w-3 mr-1"}),o4[g.status].label]})]})})},g.id)})})]})})}function j8t({open:t,onOpenChange:s}){return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Cs,{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(Ss,{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 k8t({open:t,onOpenChange:s}){const{brokerageId:r}=Gs(),[n,a]=S.useState(""),[o,l]=S.useState([]),[i,d]=S.useState(!1),{data:u,isLoading:p}=Ct({queryKey:["brokerage-agents-for-onboarding",r],queryFn:async()=>{if(!r)return[];const{data:j,error:w}=await G.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name",{ascending:!0});if(w)throw w;return j},enabled:t&&!!r}),g=u==null?void 0:u.filter(j=>j.name.toLowerCase().includes(n.toLowerCase())||j.email.toLowerCase().includes(n.toLowerCase())),v=j=>{l(w=>w.includes(j)?w.filter(N=>N!==j):[...w,j])},_=async()=>{if(o.length===0){fe.error("Please select at least one agent");return}d(!0);try{const{data:j,error:w}=await G.functions.invoke("send-onboarding-link",{body:{agentIds:o}});if(w)throw w;fe.success(`Onboarding link sent to ${o.length} agent${o.length>1?"s":""}`),l([]),s(!1)}catch(j){console.error("Error sending onboarding link:",j),fe.error(j.message||"Failed to send onboarding link")}finally{d(!1)}},b=j=>{j||(l([]),a("")),s(j)};return e.jsx(vs,{open:t,onOpenChange:b,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Cs,{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(Ta,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ss,{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(xn,{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:j=>a(j.target.value),className:"pl-10"})]}),p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):(g==null?void 0:g.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(Fi,{className:"h-[300px] border rounded-lg",children:e.jsx("div",{className:"p-2 space-y-1",children:g==null?void 0:g.map(j=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted cursor-pointer",onClick:()=>v(j.id),children:[e.jsx(zo,{checked:o.includes(j.id),onCheckedChange:()=>v(j.id)}),e.jsx(fn,{className:"h-8 w-8",children:e.jsx(gn,{className:"text-xs",children:j.name.split(" ").map(w=>w[0]).join("").toUpperCase()})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:j.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:j.email})]})]},j.id))})}),o.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.length," agent",o.length>1?"s":""," selected"]})]}),e.jsxs(On,{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(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Send Link"]})})]})]})})}function N8t(){const[t,s]=S.useState(!1),[r,n]=S.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"mb-8",children:[e.jsx(Lt,{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(zt,{children:"Agent Onboarding"}),e.jsx(yr,{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(Ta,{className:"h-4 w-4"}),"Send New Agent Onboarding Link"]})]})})]}),e.jsx(j8t,{open:t,onOpenChange:s}),e.jsx(k8t,{open:r,onOpenChange:n})]})}function S8t({open:t,onOpenChange:s}){return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Cs,{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(Hx,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ss,{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 C8t(){const[t,s]=S.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"mb-8",children:[e.jsx(Lt,{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(Hx,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{children:"Launch or ReLaunch Meeting"}),e.jsx(yr,{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(Hx,{className:"h-4 w-4"}),"Schedule Launch Meeting"]})})]}),e.jsx(S8t,{open:t,onOpenChange:s})]})}function M8t(){const t=Lr(),[s,r]=S.useState(""),[n,a]=S.useState(null),{data:o,isLoading:l}=Ct({queryKey:["brokerage-resources-published"],queryFn:async()=>{const{data:j,error:w}=await G.from("brokerage_resources").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(w)throw w;return j}}),{data:i}=Ct({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:j,error:w}=await G.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(w)throw w;return j}}),{data:d}=Ct({queryKey:["brokerage-resource-pdfs-all"],queryFn:async()=>{const{data:j,error:w}=await G.from("brokerage_resource_pdfs").select("resource_id");if(w)throw w;return j}}),{data:u}=Ct({queryKey:["brokerage-resource-videos-all"],queryFn:async()=>{const{data:j,error:w}=await G.from("brokerage_resource_videos").select("resource_id");if(w)throw w;return j}}),{data:p}=Ct({queryKey:["brokerage-resource-links-all"],queryFn:async()=>{const{data:j,error:w}=await G.from("brokerage_resource_links").select("resource_id");if(w)throw w;return j}}),g=o==null?void 0:o.filter(j=>{var C;const w=j.title.toLowerCase().includes(s.toLowerCase())||((C=j.description)==null?void 0:C.toLowerCase().includes(s.toLowerCase())),N=!n||j.category_id===n;return w&&N}),v=i==null?void 0:i.filter(j=>o==null?void 0:o.some(w=>w.category_id===j.id)),_=j=>{const w=(d==null?void 0:d.filter(A=>A.resource_id===j).length)||0,N=(u==null?void 0:u.filter(A=>A.resource_id===j).length)||0,C=(p==null?void 0:p.filter(A=>A.resource_id===j).length)||0;return{pdfCount:w,videoCount:N,linkCount:C}},b=j=>{t(`/brokerage-resources/${j}`)};return e.jsx(Ms,{title:"Brokerage Resources",description:"Access exclusive resources for brokerage managers",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(N8t,{}),e.jsx(C8t,{}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(xn,{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:j=>r(j.target.value),className:"pl-10"})]}),v&&v.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(at,{variant:n===null?"default":"outline",className:"cursor-pointer",onClick:()=>a(null),children:"All"}),v.map(j=>e.jsx(at,{variant:n===j.id?"default":"outline",className:"cursor-pointer",onClick:()=>a(j.id),children:j.name},j.id))]}),!l&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(g==null?void 0:g.length)||0," resource",(g==null?void 0:g.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((j,w)=>e.jsxs(Ee,{children:[e.jsx(gs,{className:"h-40 w-full"}),e.jsx(Lt,{children:e.jsx(gs,{className:"h-5 w-3/4"})}),e.jsxs(Oe,{children:[e.jsx(gs,{className:"h-4 w-full mb-2"}),e.jsx(gs,{className:"h-4 w-2/3"})]})]},w))}):(g==null?void 0:g.length)===0?e.jsxs(Ee,{className:"p-12 text-center",children:[e.jsx(eh,{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:g==null?void 0:g.map(j=>{const{pdfCount:w,videoCount:N,linkCount:C}=_(j.id),A=i==null?void 0:i.find(I=>I.id===j.category_id);return e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>b(j.id),children:[j.preview_image_url?e.jsx("img",{src:j.preview_image_url,alt:j.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(eh,{className:"h-16 w-16 text-muted-foreground"})}),e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(zt,{className:"text-lg line-clamp-1",children:j.title}),A&&e.jsx(at,{variant:"secondary",className:"shrink-0 text-xs",children:A.name})]})}),e.jsxs(Oe,{children:[j.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:j.description}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[w>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-4 w-4"}),w]}),N>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Nn,{className:"h-4 w-4"}),N]}),C>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Io,{className:"h-4 w-4"}),C]})]})]})]},j.id)})})]})})}const T8t=()=>{const{resourceId:t}=Co(),{data:s,isLoading:r}=Ct({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(Ms,{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(Ms,{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(Ka,{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(Sn,{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(Sn,{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(gi,{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(rn,{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(rn,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"font-medium text-sm",children:a.title})]}),e.jsx(rn,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})})]})}):e.jsx(Ms,{title:"Brokerage Resources",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(eh,{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 A8t(){const{onlineUsers:t,totalOnline:s}=iqe();return e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Online Now"]}),e.jsxs(at,{variant:"secondary",className:"bg-green-100 text-green-700",children:[e.jsx(Wc,{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(Fi,{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(fn,{className:"h-9 w-9",children:[e.jsx(Ma,{src:r.avatarUrl,alt:r.name}),e.jsx(gn,{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 OAe={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:PP,path:"/admin/invite-codes",color:"bg-amber-500/10 text-amber-600"},{title:"Subscriptions",description:"Track and manage user subscriptions",icon:mp,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:eP,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:Im,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:Uh,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:fc,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:Rl,path:"/admin/templates",color:"bg-pink-500/10 text-pink-600"},{title:"Manage Academy",description:"Upload videos and training content",icon:th,path:"/admin/academy",color:"bg-indigo-500/10 text-indigo-600"},{title:"Manage Toolbox",description:"Create and manage resource kits",icon:Kx,path:"/admin/toolbox",color:"bg-orange-500/10 text-orange-600"},{title:"Social Swag",description:"Manage social media content and links",icon:mn,path:"/admin/social-swag",color:"bg-fuchsia-500/10 text-fuchsia-600"},{title:"Social Swag 2.0",description:"New monthly social media images",icon:mn,path:"/admin/social-swag-2",color:"bg-cyan-500/10 text-cyan-600"},{title:"Newsletters",description:"Manage monthly newsletter templates",icon:E0,path:"/admin/newsletters",color:"bg-violet-500/10 text-violet-600"},{title:"Manage Events",description:"Create and publish events with Zoom integration",icon:kc,path:"/admin/events",color:"bg-green-500/10 text-green-600"},{title:"Additional Services",description:"Manage additional service offerings",icon:eh,path:"/admin/additional-services",color:"bg-lime-500/10 text-lime-600"},{title:"Brokerage Resources",description:"Manage resources for brokerage managers",icon:eh,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:sN,path:"/admin/dashboard-management",color:"bg-teal-500/10 text-teal-600"},{title:"Manage Apps",description:"Configure app tiles and access requirements",icon:ep,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:Fg,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:i5,path:"/admin/onboarding-checklist",color:"bg-emerald-500/10 text-emerald-600"},{title:"Marketplace",description:"Manage store categories, products, and orders",icon:Wx,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:ao,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:Gi,path:"/admin/agent-points",color:"bg-amber-500/10 text-amber-600"},{title:"Integrations",description:"Connect Canva, Facebook & Instagram for platform-level features",icon:Ho,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:Fg,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:m5,path:"/admin/support-tickets",color:"bg-rose-500/10 text-rose-600"},{title:"Wishlist",description:"Review and manage community feature requests",icon:e_,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:Xo,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:cu,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:th,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:Ni,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:Vn,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:uf,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:cu,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:"Send physical postcards via Lob — manage templates, orders, and agent credits",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:J1,path:"/admin/beta/homereel",color:"bg-gradient-to-br from-violet-500/20 to-indigo-500/10 text-violet-600"}]}};function E8t(){const t=Lr();return e.jsx(Ms,{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(A8t,{})})]}),e.jsxs(ja,{defaultValue:"users",className:"w-full",children:[e.jsx(va,{className:"w-full justify-start flex-wrap h-auto gap-1 bg-muted/50 p-1 overflow-x-auto",children:Object.entries(OAe).map(([s,r])=>e.jsx(Ns,{value:s,className:"data-[state=active]:bg-background",children:r.label},s))}),Object.entries(OAe).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(Lt,{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(zt,{className:"text-base",children:n.title})]}),e.jsx(Oe,{className:"pt-0",children:e.jsx(yr,{className:"text-sm",children:n.description})})]},n.path))})},s))]})]})})}const Tn=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:Et("w-full caption-bottom text-sm",t),...s})}));Tn.displayName="Table";const An=S.forwardRef(({className:t,...s},r)=>e.jsx("thead",{ref:r,className:Et("[&_tr]:border-b",t),...s}));An.displayName="TableHeader";const En=S.forwardRef(({className:t,...s},r)=>e.jsx("tbody",{ref:r,className:Et("[&_tr:last-child]:border-0",t),...s}));En.displayName="TableBody";const P8t=S.forwardRef(({className:t,...s},r)=>e.jsx("tfoot",{ref:r,className:Et("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));P8t.displayName="TableFooter";const js=S.forwardRef(({className:t,...s},r)=>e.jsx("tr",{ref:r,className:Et("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",t),...s}));js.displayName="TableRow";const jt=S.forwardRef(({className:t,...s},r)=>e.jsx("th",{ref:r,className:Et("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));jt.displayName="TableHead";const it=S.forwardRef(({className:t,...s},r)=>e.jsx("td",{ref:r,className:Et("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s}));it.displayName="TableCell";const I8t=S.forwardRef(({className:t,...s},r)=>e.jsx("caption",{ref:r,className:Et("mt-4 text-sm text-muted-foreground",t),...s}));I8t.displayName="TableCaption";const L8t=()=>{const{isAdmin:t}=Gs(),s=Lr(),[r,n]=S.useState([]),[a,o]=S.useState(!0),[l,i]=S.useState(!1),[d,u]=S.useState(null);S.useEffect(()=>{if(!t){s("/dashboard");return}p()},[t]);const p=async()=>{try{const{data:j,error:w}=await G.from("app_tiles").select("*").order("name");if(w)throw w;n(j||[])}catch(j){console.error("Error loading apps:",j),fe.error("Failed to load apps")}finally{o(!1)}},g=async j=>{j.preventDefault();const w=new FormData(j.currentTarget),N={name:w.get("name"),description:w.get("description"),icon:w.get("icon"),app_id:w.get("app_id"),target_url:w.get("target_url"),required_tags:w.get("required_tags").split(",").map(C=>C.trim()).filter(Boolean)};try{if(d){const{error:C}=await G.from("app_tiles").update(N).eq("id",d.id);if(C)throw C;fe.success("App updated successfully")}else{const{error:C}=await G.from("app_tiles").insert([N]);if(C)throw C;fe.success("App created successfully")}i(!1),u(null),p()}catch(C){console.error("Error saving app:",C),fe.error("Failed to save app")}},v=async j=>{if(confirm("Are you sure you want to delete this app?"))try{const{error:w}=await G.from("app_tiles").delete().eq("id",j);if(w)throw w;fe.success("App deleted successfully"),p()}catch(w){console.error("Error deleting app:",w),fe.error("Failed to delete app")}},_=j=>{u(j),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(Ka,{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(vs,{open:l,onOpenChange:i,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{onClick:b,children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Add App"]})}),e.jsxs(ys,{className:"max-w-2xl",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:d?"Edit App":"Create New App"}),e.jsx(Kr,{children:"Configure the application tile settings"})]}),e.jsxs("form",{onSubmit:g,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(Tr,{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(Lt,{children:[e.jsx(zt,{children:"Application Tiles"}),e.jsx(yr,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Icon"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"App ID"}),e.jsx(jt,{children:"Target URL"}),e.jsx(jt,{children:"Tags"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:r.map(j=>e.jsxs(js,{children:[e.jsx(it,{className:"text-2xl",children:j.icon}),e.jsx(it,{className:"font-medium",children:j.name}),e.jsx(it,{className:"font-mono text-sm",children:j.app_id}),e.jsx(it,{className:"text-sm text-muted-foreground max-w-xs truncate",children:j.target_url}),e.jsx(it,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:j.required_tags.map(w=>e.jsx("span",{className:"text-xs bg-secondary text-secondary-foreground px-2 py-1 rounded",children:w},w))})}),e.jsx(it,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>_(j),children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>v(j.id),children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},j.id))})]})})]})})]})};function _u({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(Ka,{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 RAe=({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(at,{variant:"destructive",className:Et("gap-1",s),children:[e.jsx(Mh,{className:"h-3 w-3"}),"Trial Expired"]}):a<=1?e.jsxs(at,{variant:"destructive",className:Et("gap-1",s),children:[e.jsx(In,{className:"h-3 w-3"}),"Trial: <1 day left"]}):a<=3?e.jsxs(at,{className:Et("gap-1 bg-amber-500 hover:bg-amber-600",s),children:[e.jsx(In,{className:"h-3 w-3"}),"Trial: ",a," days left"]}):e.jsxs(at,{variant:"secondary",className:Et("gap-1",s),children:[e.jsx(In,{className:"h-3 w-3"}),"Trial: ",a," days left"]})},pKe=({open:t,onOpenChange:s,brokerages:r,fixedBrokerageId:n,onSuccess:a})=>{const{toast:o}=Ea(),l=S.useRef(null),[i,d]=S.useState([]),[u,p]=S.useState(""),[g,v]=S.useState(!1),[_,b]=S.useState("upload"),[j,w]=S.useState(null),N=()=>{d([]),p(""),b("upload"),w(null),l.current&&(l.current.value="")},C=()=>{N(),s(!1)},A=q=>{const U=q.split(` `).map(Y=>Y.trim()).filter(Y=>Y);if(U.length===0)return[];const V=U[0].toLowerCase(),se=V.includes("first")||V.includes("last")||V.includes("email")||V.includes("name")||V.includes("phone")||V.includes("sms")||V.includes("consent")?U.slice(1):U,te=[];for(const Y of se){const ie=(Y.includes(" ")?Y.split(" "):Y.split(",")).map(ae=>ae.trim().replace(/^["']|["']$/g,""));if(ie.length>=2){let ae="",le="",pe="",be="",ye;if(ie.length===2){const Ke=ie[0].split(" ");ae=Ke[0]||"",le=Ke.slice(1).join(" ")||"",pe=ie[1]}else if(ie.length===3)ae=ie[0],le=ie[1],pe=ie[2];else if(ie.length===4)ae=ie[0],le=ie[1],pe=ie[2],be=ie[3];else if(ie.length>=5){ae=ie[0],le=ie[1],pe=ie[2],be=ie[3];const Ke=ie[4].toLowerCase();ye=Ke==="true"||Ke==="yes"||Ke==="1"||Ke==="y"}const Ne=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(pe);te.push({firstName:ae.trim(),lastName:le.trim(),email:pe.trim().toLowerCase(),phone:be.trim()||void 0,smsConsent:ye,isValid:Ne&&ae.trim().length>0,error:Ne?ae.trim()?void 0:"Missing name":"Invalid email"})}}return te},I=q=>{var X;const U=(X=q.target.files)==null?void 0:X[0];if(!U)return;const V=new FileReader;V.onload=se=>{var de;const te=(de=se.target)==null?void 0:de.result,Y=A(te);if(Y.length===0){o({title:"No data found",description:"The CSV file appears to be empty or in an unsupported format.",variant:"destructive"});return}d(Y),b("preview")},V.readAsText(U)},L=async()=>{const q=i.filter(V=>V.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;v(!0);try{const{data:{session:V}}=await G.auth.getSession(),X=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/bulk-create-users",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${V==null?void 0:V.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 X.json();if(!X.ok)throw new Error(se.error||"Failed to import users");w(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(V){console.error("Import error:",V),o({title:"Import Failed",description:V.message||"Failed to import users",variant:"destructive"})}finally{v(!1)}},R=i.filter(q=>q.isValid).length,$=i.filter(q=>!q.isValid).length;return e.jsx(vs,{open:t,onOpenChange:C,children:e.jsxs(ys,{className:"max-w-2xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(N0,{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(Xa,{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(tr,{value:u||"none",onValueChange:q=>p(q==="none"?"":q),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select a brokerage..."})}),e.jsxs(er,{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(la,{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(Qo,{className:"h-4 w-4"}),e.jsxs("span",{children:[$," invalid"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{className:"bg-muted/30",children:[e.jsx(jt,{children:"First Name"}),e.jsx(jt,{children:"Last Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Phone"}),e.jsx(jt,{children:"SMS"}),e.jsx(jt,{children:"Status"})]})}),e.jsx(En,{children:i.slice(0,100).map((q,U)=>e.jsxs(js,{children:[e.jsx(it,{children:q.firstName}),e.jsx(it,{children:q.lastName}),e.jsx(it,{children:q.email}),e.jsx(it,{className:"text-muted-foreground",children:q.phone||"-"}),e.jsx(it,{className:"text-muted-foreground",children:q.smsConsent===!0?"✓":q.smsConsent===!1?"✗":"-"}),e.jsx(it,{children:q.isValid?e.jsx(at,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):e.jsx(at,{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"&&j&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(la,{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:[j.created," agent(s) created and invited"]}),j.failed>0&&e.jsxs("p",{className:"text-destructive mt-1",children:[j.failed," failed to create"]})]}),j.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:[j.errors.slice(0,10).map((q,U)=>e.jsxs("li",{children:["• ",q]},U)),j.errors.length>10&&e.jsxs("li",{children:["...and ",j.errors.length-10," more"]})]})]})]}),e.jsxs(On,{children:[_==="upload"&&e.jsx(K,{variant:"outline",onClick:C,children:"Cancel"}),_==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:N,children:"Back"}),e.jsx(K,{onClick:L,disabled:g||R===0,children:g?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${R} Agent${R!==1?"s":""}`})]}),_==="result"&&e.jsx(K,{onClick:C,children:"Done"})]})]})})};function el({sortKey:t,currentSortKey:s,currentDirection:r,onSort:n,children:a,className:o,...l}){const i=s===t;return e.jsx(jt,{className:Et("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(qd,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Ju,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Vc,{className:"h-3.5 w-3.5 shrink-0 opacity-40"})]})})}function qL(t=null,s=null){const[r,n]=S.useState(t),[a,o]=S.useState(s),l=S.useCallback(d=>{r===d?a==="asc"?o("desc"):a==="desc"?(n(null),o(null)):o("asc"):(n(d),o("asc"))},[r,a]),i=S.useCallback((d,u)=>{if(!r||!a||!u[r])return d;const p=u[r];return[...d].sort((g,v)=>{const _=p(g),b=p(v);if(_==null&&b==null)return 0;if(_==null)return 1;if(b==null)return-1;let j;return typeof _=="string"&&typeof b=="string"?j=_.localeCompare(b,void 0,{sensitivity:"base"}):j=_-b,a==="asc"?j:-j})},[r,a]);return{sortKey:r,sortDirection:a,handleSort:l,sortData:i}}const D8t=[{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:Gi},{type:"custom",title:"Congratulations!",message:"You earned this celebration!",icon:Nd}];function fKe({open:t,onOpenChange:s,userId:r,userName:n}){const[a,o]=S.useState("custom"),[l,i]=S.useState(""),[d,u]=S.useState(""),p=Qxt(),g=_=>{o(_.type),i(_.title),u(_.message)},v=async _=>{if(_.preventDefault(),!l.trim()){an({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}),an({title:"Celebration sent! 🎉",description:`${n} will see confetti on their next visit!`}),s(!1),i(""),u(""),o("custom")}catch{an({title:"Error",description:"Failed to send celebration",variant:"destructive"})}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Nd,{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:D8t.map((_,b)=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>g(_),className:"text-xs",children:[e.jsx(_.icon,{className:"h-3 w-3 mr-1"}),_.title]},b))})]}),e.jsxs("form",{onSubmit:v,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"type",children:"Celebration Type"}),e.jsxs(tr,{value:a,onValueChange:_=>o(_),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{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(Gi,{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(Vn,{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(Gc,{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(Tr,{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(Nd,{className:"h-4 w-4 mr-2"}),p.isPending?"Sending...":"Send Celebration"]})]})]})]})})}const Bme={points_earned:{label:"Points Earned",icon:Gi,color:"bg-yellow-500"},listing_created:{label:"Listing Created",icon:Vn,color:"bg-blue-500"},deal_closed:{label:"Deal Closed",icon:Gc,color:"bg-green-500"},custom:{label:"Custom",icon:mn,color:"bg-purple-500"}};function O8t(){const[t,s]=S.useState(""),[r,n]=S.useState("all"),[a,o]=S.useState("all"),{data:l=[],isLoading:i}=Ct({queryKey:["admin-celebrations"],queryFn:async()=>{const{data:p,error:g}=await G.from("celebration_queue").select("*").order("created_at",{ascending:!1}).limit(500);if(g)throw g;const v=[...new Set([...p.map(j=>j.user_id),...p.map(j=>j.created_by).filter(Boolean)])],{data:_}=await G.from("profiles").select("id, name, email").in("id",v),b=new Map((_==null?void 0:_.map(j=>[j.id,j]))||[]);return p.map(j=>{var w,N,C;return{...j,user_name:((w=b.get(j.user_id))==null?void 0:w.name)||"Unknown",user_email:((N=b.get(j.user_id))==null?void 0:N.email)||"",creator_name:j.created_by?((C=b.get(j.created_by))==null?void 0:C.name)||"System":"Auto-triggered"}})}}),d=l.filter(p=>{var b,j;const g=((b=p.user_name)==null?void 0:b.toLowerCase().includes(t.toLowerCase()))||((j=p.user_email)==null?void 0:j.toLowerCase().includes(t.toLowerCase()))||p.title.toLowerCase().includes(t.toLowerCase()),v=r==="all"||p.celebration_type===r,_=a==="all"||a==="seen"&&p.seen_at||a==="unseen"&&!p.seen_at;return g&&v&&_}),u={total:l.length,seen:l.filter(p=>p.seen_at).length,unseen:l.filter(p=>!p.seen_at).length,byType:Object.keys(Bme).reduce((p,g)=>(p[g]=l.filter(v=>v.celebration_type===g).length,p),{})};return i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(As,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Nd,{className:"h-5 w-5"}),"Celebration History"]}),e.jsx(yr,{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(xn,{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(tr,{value:r,onValueChange:n,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{placeholder:"Filter by type"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Types"}),Object.entries(Bme).map(([p,g])=>e.jsx(At,{value:p,children:g.label},p))]})]}),e.jsxs(tr,{value:a,onValueChange:o,children:[e.jsx(Js,{className:"w-[140px]",children:e.jsx(sr,{placeholder:"Status"})}),e.jsxs(er,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Points"}),e.jsx(jt,{children:"Created By"}),e.jsx(jt,{children:"Created"}),e.jsx(jt,{children:"Status"})]})}),e.jsx(En,{children:d.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No celebrations found"})}):d.map(p=>{const g=Bme[p.celebration_type],v=g.icon;return e.jsxs(js,{children:[e.jsx(it,{children:e.jsxs(at,{variant:"outline",className:"gap-1",children:[e.jsx(v,{className:"h-3 w-3"}),g.label]})}),e.jsx(it,{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(it,{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(it,{children:p.points_amount?e.jsxs(at,{variant:"secondary",children:["+",p.points_amount]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(it,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:p.creator_name})}),e.jsx(it,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ws(new Date(p.created_at),"MMM d, yyyy h:mm a")})}),e.jsx(it,{children:p.seen_at?e.jsx(at,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:"Seen"}):e.jsx(at,{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 R8t=()=>{const{user:t}=Gs(),{toast:s}=Ea(),[r,n]=S.useState([]),[a,o]=S.useState(!0),[l,i]=S.useState(!1),[d,u]=S.useState("all"),[p,g]=S.useState("all"),[v,_]=S.useState("new"),[b,j]=S.useState(new Set),w=S.useCallback(async()=>{try{o(!0);const{data:te,error:Y}=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(Y)throw Y;const{data:de,error:ie}=await G.from("trial_email_exports").select("user_id");if(ie)throw ie;const ae=new Set((de||[]).map(pe=>pe.user_id)),le=(te||[]).map(pe=>({...pe,converted_from_trial_at:pe.converted_from_trial_at??null,already_exported:ae.has(pe.id)}));le.sort((pe,be)=>new Date(be.created_at).getTime()-new Date(pe.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]);S.useEffect(()=>{w()},[w]);const N=te=>te.trial_started_at?"ghl":"stripe",C=te=>te.trial_expires_at?te.trial_expires_at:te.subscription_end_date?te.subscription_end_date:null,A=te=>te.converted_from_trial_at!==null,I=te=>{if(A(te))return!1;const Y=C(te);return Y?new Date(Y).getTime()<=Date.now():!1},L=r.filter(te=>!(d!=="all"&&N(te)!==d||p==="active"&&(I(te)||A(te))||p==="expired"&&!I(te)||p==="converted"&&!A(te)||v==="new"&&te.already_exported||v==="exported"&&!te.already_exported)),R=()=>{b.size===L.length?j(new Set):j(new Set(L.map(te=>te.id)))},$=te=>{const Y=new Set(b);Y.has(te)?Y.delete(te):Y.add(te),j(Y)},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(ye=>b.has(ye.id)),Y="First Name,Last Name,Email,Phone,Trial Type,Status,Signup Date,Expiry Date",de=te.map(ye=>{const we=(ye.name||"").split(" "),Ne=we[0]||"",Ke=we.slice(1).join(" ")||"",_e=N(ye)==="stripe"?"Credit Card Trial":"Free Trial (No CC)",Me=A(ye)?"Converted":I(ye)?"Expired":"Active",Te=ye.created_at?new Date(ye.created_at).toLocaleDateString():"",Fe=C(ye)?new Date(C(ye)).toLocaleDateString():"";return`"${Ne}","${Ke}","${ye.email}","${ye.phone||""}","${_e}","${Me}","${Te}","${Fe}"`}),ie=[Y,...de].join(` `),ae=new Blob([ie],{type:"text/csv"}),le=URL.createObjectURL(ae),pe=document.createElement("a");pe.href=le,pe.download=`trial-users-${new Date().toISOString().split("T")[0]}.csv`,pe.click(),URL.revokeObjectURL(le);const be=te.filter(ye=>!ye.already_exported).map(ye=>({user_id:ye.id,exported_by:t.id}));if(be.length>0){const{error:ye}=await G.from("trial_email_exports").upsert(be,{onConflict:"user_id"});ye&&console.error("Error marking exports:",ye)}s({title:"Export complete",description:`Downloaded ${te.length} trial user(s). ${be.length} newly marked as exported.`}),j(new Set),w()}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,V=r.filter(te=>te.already_exported).length,X=r.filter(te=>A(te)).length,se=r.filter(te=>!I(te)&&!A(te)).length;return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(As,{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(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"Total"}),e.jsx(zt,{className:"text-2xl",children:r.length})]})}),e.jsx(Ee,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"New (Not Exported)"}),e.jsx(zt,{className:"text-2xl text-green-600",children:U})]})}),e.jsx(Ee,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"Active Trials"}),e.jsx(zt,{className:"text-2xl",children:se})]})}),e.jsx(Ee,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"Converted 🎉"}),e.jsx(zt,{className:"text-2xl text-primary",children:X})]})}),e.jsx(Ee,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"Already Exported"}),e.jsx(zt,{className:"text-2xl text-muted-foreground",children:V})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(tr,{value:v,onValueChange:te=>_(te),children:[e.jsx(Js,{className:"w-[160px]",children:e.jsx(sr,{})}),e.jsxs(er,{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(tr,{value:d,onValueChange:te=>u(te),children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{})}),e.jsxs(er,{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(tr,{value:p,onValueChange:te=>g(te),children:[e.jsx(Js,{className:"w-[160px]",children:e.jsx(sr,{})}),e.jsxs(er,{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(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Export Selected (",b.size,")"]})})]}),e.jsx("div",{className:"border rounded-lg",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(jt,{className:"w-[40px]",children:e.jsx(zo,{checked:L.length>0&&b.size===L.length,onCheckedChange:R})}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Trial Type"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Signup Date"}),e.jsx(jt,{children:"Expires / Renews"}),e.jsx(jt,{children:"Exported"})]})}),e.jsx(En,{children:L.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No trial users match the current filters"})}):L.map(te=>{const Y=N(te),de=A(te),ie=I(te),ae=C(te);return e.jsxs(js,{className:`hover:bg-muted/30 ${de?"bg-primary/5":""}`,children:[e.jsx(it,{children:e.jsx(zo,{checked:b.has(te.id),onCheckedChange:()=>$(te.id)})}),e.jsx(it,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[te.name,de&&e.jsx(Sc,{className:"h-3.5 w-3.5 text-primary"})]})}),e.jsx(it,{className:"text-muted-foreground",children:te.email}),e.jsx(it,{children:Y==="stripe"?e.jsxs(at,{variant:"outline",className:"gap-1",children:[e.jsx(mp,{className:"h-3 w-3"}),"Credit Card"]}):e.jsxs(at,{variant:"secondary",className:"gap-1",children:[e.jsx(br,{className:"h-3 w-3"}),"Free (No CC)"]})}),e.jsx(it,{children:de?e.jsxs(at,{className:"bg-primary/10 text-primary hover:bg-primary/20 gap-1",children:[e.jsx(Sc,{className:"h-3 w-3"}),"Converted"]}):ie?e.jsx(at,{variant:"destructive",children:"Expired"}):e.jsx(at,{className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active Trial"})}),e.jsx(it,{className:"text-sm",children:te.created_at?new Date(te.created_at).toLocaleDateString():"—"}),e.jsx(it,{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(it,{children:te.already_exported?e.jsx(la,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(at,{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 · ",X," converted to paid"]})]})},F8t=()=>{const[t,s]=S.useState([]),[r,n]=S.useState(!0);return S.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(As,{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(Lt,{children:e.jsx(zt,{className:"text-lg",children:"User Deletion History"})}),e.jsx(Oe,{children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Date"}),e.jsx(jt,{children:"User"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Brokerage"}),e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Deleted By"})]})}),e.jsx(En,{children:t.map(a=>e.jsxs(js,{children:[e.jsx(it,{className:"whitespace-nowrap text-sm",children:ws(new Date(a.created_at),"MMM d, yyyy h:mm a")}),e.jsx(it,{className:"font-medium",children:a.deleted_user_name||"—"}),e.jsx(it,{className:"text-sm text-muted-foreground",children:a.deleted_user_email||"—"}),e.jsx(it,{children:a.brokerage_name||"—"}),e.jsx(it,{children:e.jsx(at,{variant:a.deletion_type==="deleted"?"destructive":"secondary",children:a.deletion_type==="deleted"?"Account Deleted":"Removed"})}),e.jsx(it,{className:"text-sm",children:a.deleted_by_name||a.deleted_by_email||"—"})]},a.id))})]})})]})},rS=t=>{const{user:s}=Gs(),r=ns(),n=Ct({queryKey:["teams",t],queryFn:async()=>{let g=G.from("teams").select("*").order("created_at",{ascending:!1});t&&(g=g.eq("brokerage_id",t));const{data:v,error:_}=await g;if(_)throw _;return v||[]},enabled:!!s}),a=g=>Ct({queryKey:["team-members",g],queryFn:async()=>{const{data:v,error:_}=await G.from("team_members").select("*").eq("team_id",g).order("role",{ascending:!0});if(_)throw _;const b=(v||[]).map(N=>N.user_id),{data:j}=await G.from("profiles").select("id, name, email, avatar_url").in("id",b),w=new Map((j||[]).map(N=>[N.id,N]));return(v||[]).map(N=>({...N,profile:w.get(N.user_id)||null}))},enabled:!!g}),o=Ot({mutationFn:async g=>{const v={name:g.name,created_by:s.id,description:g.description,contact_visibility:g.contact_visibility,lead_pond_enabled:g.lead_pond_enabled,shared_assets_enabled:g.shared_assets_enabled};g.brokerage_id&&(v.brokerage_id=g.brokerage_id);const{data:_,error:b}=await G.from("teams").insert(v).select().single();if(b)throw b;return _},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),fe.success("Team created!")},onError:g=>{fe.error("Failed to create team: "+g.message)}}),l=Ot({mutationFn:async({id:g,...v})=>{const{data:_,error:b}=await G.from("teams").update(v).eq("id",g).select().single();if(b)throw b;return _},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),fe.success("Team updated")},onError:g=>{fe.error("Failed to update team: "+g.message)}}),i=Ot({mutationFn:async g=>{const{error:v}=await G.from("teams").delete().eq("id",g);if(v)throw v},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),fe.success("Team deleted")},onError:g=>{fe.error("Failed to delete team: "+g.message)}}),d=Ot({mutationFn:async g=>{const{data:v,error:_}=await G.from("team_members").insert({team_id:g.team_id,user_id:g.user_id,role:g.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 v},onSuccess:(g,v)=>{r.invalidateQueries({queryKey:["team-members",v.team_id]}),fe.success("Member added to team")},onError:g=>{fe.error(g.message)}}),u=Ot({mutationFn:async g=>{const{error:v}=await G.from("team_members").delete().eq("id",g.member_id);if(v)throw v},onSuccess:(g,v)=>{r.invalidateQueries({queryKey:["team-members",v.team_id]}),fe.success("Member removed from team")},onError:g=>{fe.error("Failed to remove member: "+g.message)}}),p=Ot({mutationFn:async g=>{const{error:v}=await G.from("team_members").update({role:g.role}).eq("id",g.member_id);if(v)throw v},onSuccess:(g,v)=>{r.invalidateQueries({queryKey:["team-members",v.team_id]}),fe.success("Member role updated")},onError:g=>{fe.error("Failed to update role: "+g.message)}});return{teams:n.data||[],isLoading:n.isLoading,createTeam:o,updateTeam:l,deleteTeam:i,addMember:d,removeMember:u,updateMemberRole:p,useTeamMembers:a}},z8t=()=>{const{user:t}=Gs();return Ct({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})},gKe=t=>{const{user:s}=Gs(),r=ns(),n=Ct({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(N=>N.contact_id),p=[...new Set(i.map(N=>N.added_by))],g=i.filter(N=>N.claimed_by).map(N=>N.claimed_by),v=[...new Set([...p,...g])],[_,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",v)]),j=new Map((_.data||[]).map(N=>[N.id,N])),w=new Map((b.data||[]).map(N=>[N.id,N]));return i.map(N=>({...N,status:N.claimed_by?"claimed":"available",contact:j.get(N.contact_id)||null,contributor:w.get(N.added_by)||null,claimer:N.claimed_by&&w.get(N.claimed_by)||null}))},enabled:!!t&&!!s}),a=Ot({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=Ot({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=Ot({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}},B8t=()=>{const t=ns();return Ot({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 xKe({open:t,onOpenChange:s,contactIds:r,contactNames:n=[],onComplete:a}){var L;const{user:o}=Gs(),{data:l}=Mf(),{useTeamMembers:i}=rS(),{data:d=[]}=i((l==null?void 0:l.teamId)||""),u=B8t(),[p,g]=S.useState(null),[v,_]=S.useState(""),[b,j]=S.useState(!1),w=d.filter(R=>R.user_id!==(o==null?void 0:o.id)),N=async()=>{if(p){j(!0);try{for(const R of r)await u.mutateAsync({contactId:R,toUserId:p,notes:v||void 0});s(!1),g(null),_(""),a==null||a()}catch{}finally{j(!1)}}},C=w.find(R=>R.user_id===p),A=r.length>1,I=n.length>0?A?`${n.length} contacts`:n[0]:A?`${r.length} contacts`:"this contact";return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(w0,{className:"h-5 w-5"}),"Transfer ",I]}),e.jsxs(Kr,{children:["Select a team member to transfer ",A?"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:w.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No other team members available"}):w.map(R=>{var $,q,U;return e.jsxs("button",{onClick:()=>g(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(fn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:(($=R.profile)==null?void 0:$.avatar_url)||""}),e.jsx(gn,{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(Tr,{id:"transfer-notes",value:v,onChange:R=>_(R.target.value),placeholder:"Reason for transfer...",className:"mt-1",rows:2})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:N,disabled:!p||b,children:[b?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(w0,{className:"h-4 w-4 mr-2"}),"Transfer",C?` to ${(L=C.profile)==null?void 0:L.name}`:""]})]})]})})}const owe=()=>{const t=Lr(),{data:s,isLoading:r}=z8t(),{data:n}=Mf(),[a,o]=S.useState(""),[l,i]=S.useState("all"),[d,u]=S.useState(null),[p,g]=S.useState(""),v=(n==null?void 0:n.role)==="team_leader",_=S.useMemo(()=>{if(!s)return[];const j=new Map;return s.forEach(w=>{j.has(w.owner_user_id)||j.set(w.owner_user_id,{id:w.owner_user_id,name:w.owner_name||"Unknown",avatar:w.owner_avatar_url})}),Array.from(j.values())},[s]),b=S.useMemo(()=>{if(!s)return[];let j=s;if(l!=="all"&&(j=j.filter(w=>w.owner_user_id===l)),a.trim()){const w=a.toLowerCase();j=j.filter(N=>{var C,A,I;return(N.first_name+" "+(N.last_name||"")).toLowerCase().includes(w)||((C=N.email)==null?void 0:C.toLowerCase().includes(w))||((A=N.phone)==null?void 0:A.includes(w))||((I=N.owner_name)==null?void 0:I.toLowerCase().includes(w))})}return j},[s,a,l]);return r?e.jsxs("div",{className:"space-y-4",children:[e.jsx(gs,{className:"h-10 w-full"}),e.jsx(gs,{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(xn,{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:j=>o(j.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:l,onValueChange:i,children:[e.jsx(Js,{className:"w-[200px]",children:e.jsx(sr,{placeholder:"Filter by agent"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Team Members"}),_.map(j=>e.jsx(At,{value:j.id,children:j.name},j.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(Tn,{className:"min-w-[800px]",children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Contact Info"}),e.jsx(jt,{children:"Address"}),e.jsx(jt,{children:"Lead Source"}),e.jsx(jt,{children:"Date Added"}),v&&e.jsx(jt,{className:"w-[80px]",children:"Actions"})]})}),e.jsx(En,{children:b.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:v?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(j=>e.jsxs(js,{className:`hover:bg-accent/50 ${v?"cursor-pointer":""}`,onClick:v?()=>t(`/mission-control/contacts/${j.id}`):void 0,children:[e.jsx(it,{className:"font-medium",children:e.jsxs("span",{className:v?"hover:text-primary hover:underline transition-colors":"",children:[j.first_name," ",j.last_name||""]})}),e.jsx(it,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(fn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:j.owner_avatar_url||""}),e.jsx(gn,{className:"text-[10px]",children:(j.owner_name||"?").charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:j.owner_name||"Unknown"})]})}),e.jsx(it,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[j.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:j.email})]}),j.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Zn,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:j.phone})]}),!j.email&&!j.phone&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No contact info"})]})}),e.jsx(it,{children:j.address?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(Ti,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:j.address})]}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(it,{children:j.lead_source?e.jsx(at,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:j.lead_source}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(it,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ws(new Date(j.created_at),"MMM d, yyyy")})}),v&&e.jsx(it,{children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:w=>{w.stopPropagation(),u(j.id),g(`${j.first_name} ${j.last_name||""}`.trim())},title:"Transfer to team member",children:e.jsx(w0,{className:"h-4 w-4"})})})]},j.id))})]})})}),e.jsx(xKe,{open:!!d,onOpenChange:j=>{j||u(null)},contactIds:d?[d]:[],contactNames:p?[p]:[],onComplete:()=>u(null)})]})},lwe=({teamId:t})=>{const{user:s}=Gs(),{leadPondItems:r,isLoading:n,claimLead:a,returnLead:o}=gKe(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(gs,{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(qx,{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,g,v,_,b,j;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:[((g=d.contact)==null?void 0:g.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]}),((v=d.contact)==null?void 0:v.phone)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Zn,{className:"h-3 w-3"})," ",d.contact.phone]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs(fn,{className:"h-4 w-4",children:[e.jsx(Ma,{src:((_=d.contributor)==null?void 0:_.avatar_url)||""}),e.jsx(gn,{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 ",((j=d.contributor)==null?void 0:j.name)||"Unknown"]})]})]}),e.jsxs(K,{size:"sm",onClick:()=>a.mutate(d.id),disabled:a.isPending,children:[e.jsx(sP,{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,g;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(at,{variant:"secondary",className:"text-xs",children:["Claimed by ",((g=d.claimer)==null?void 0:g.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(I0,{className:"mr-1 h-3 w-3"}),"Return"]})]})},d.id)})})]})]})},yKe=({teamId:t})=>{const{useTeamMembers:s}=rS(),{data:r=[]}=s(t),n=r.map(_=>_.user_id),a=new Map(r.map(_=>[_.user_id,_.profile])),{data:o=[],isLoading:l}=Ct({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}=Ct({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}=Ct({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(gs,{className:"h-20 w-full"},_))});const v=_=>{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(uf,{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(Vn,{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(ja,{defaultValue:"presentations",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsxs(Ns,{value:"presentations",children:["Presentations (",o.length,")"]}),e.jsxs(Ns,{value:"guest-books",children:["Guest Books (",i.length,")"]}),e.jsxs(Ns,{value:"videos",children:["Videos (",u.length,")"]})]}),e.jsx(zs,{value:"presentations",className:"space-y-2",children:o.length===0?e.jsx($me,{icon:e.jsx(uf,{className:"h-10 w-10"}),label:"No presentations yet"}):o.map(_=>{const b=v(_.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(fn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ma,{src:b.avatar}),e.jsx(gn,{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," · ",ws(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(at,{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(ya,{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($me,{icon:e.jsx(Vn,{className:"h-10 w-10"}),label:"No guest books yet"}):i.map(_=>{const b=v(_.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(fn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ma,{src:b.avatar}),e.jsx(gn,{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," · ",ws(new Date(_.event_date),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[_.is_active?e.jsx(at,{className:"text-xs",children:"Active"}):e.jsx(at,{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($me,{icon:e.jsx(Nn,{className:"h-10 w-10"}),label:"No videos yet"}):u.map(_=>{const b=v(_.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(fn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ma,{src:b.avatar}),e.jsx(gn,{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," · ",ws(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(at,{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(ya,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})})]})]})},$me=({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})]})}),vKe=({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}=rS(),{data:g=[],isLoading:v}=p(t.id),[_,b]=S.useState(!1),[j,w]=S.useState(""),[N,C]=S.useState("team_member"),{data:A}=Ct({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),V=new Map;return(U||[]).forEach(X=>{var se;V.set(X.user_id,((se=X.teams)==null?void 0:se.name)||"another team")}),V}}),I=new Set(g.map(U=>U.user_id)),L=s.filter(U=>!I.has(U.id)),R=async()=>{j&&(await a(j,N),w(""),C("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(ja,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsx(Ns,{value:"members",children:"Members"}),e.jsxs(Ns,{value:"contacts",children:[e.jsx(Jk,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),t.lead_pond_enabled&&e.jsxs(Ns,{value:"lead-pond",children:[e.jsx(qx,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),t.shared_assets_enabled&&e.jsxs(Ns,{value:"shared-assets",children:[e.jsx($h,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]}),e.jsx(Ns,{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(vs,{open:_,onOpenChange:b,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(fc,{className:"mr-2 h-4 w-4"}),"Add Member"]})}),e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[j&&((($=L.find(U=>U.id===j))==null?void 0:$.name)||((q=L.find(U=>U.id===j))==null?void 0:q.email))||"Select an agent",e.jsx(df,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search agents..."}),e.jsxs(kf,{children:[e.jsx(Nf,{children:"No agents found."}),e.jsx(Sf,{children:L.map(U=>{const V=A==null?void 0:A.get(U.id);return e.jsxs(jm,{value:U.name||U.email||U.id,disabled:!!V,onSelect:()=>w(U.id),children:[e.jsx(fa,{className:Et("mr-2 h-4 w-4",j===U.id?"opacity-100":"opacity-0")}),U.name||U.email,V&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(on ",V,")"]})]},U.id)})})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Role"}),e.jsxs(tr,{value:N,onValueChange:C,children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"team_leader",children:"Team Leader"}),e.jsx(At,{value:"team_member",children:"Team Member"})]})]})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(K,{onClick:R,disabled:!j||u,children:u?"Adding...":"Add to Team"})]})]})]})]}),v?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(U=>e.jsx(gs,{className:"h-16 w-full"},U))}):g.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:g.map(U=>{var V,X,se,te,Y;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(fn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:((V=U.profile)==null?void 0:V.avatar_url)||""}),e.jsx(gn,{children:(((X=U.profile)==null?void 0:X.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(at,{className:"bg-[hsl(var(--chart-4)/0.1)] text-[hsl(var(--chart-4))] border-[hsl(var(--chart-4))]",children:[e.jsx(zh,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(at,{variant:"secondary",children:"Member"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(tr,{value:U.role,onValueChange:de=>l(U.id,de),children:[e.jsx(Js,{className:"w-[140px]",children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"team_leader",children:"Team Leader"}),e.jsx(At,{value:"team_member",children:"Team Member"})]})]}),e.jsxs(tc,{children:[e.jsx(Ih,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",children:e.jsx(DP,{className:"h-4 w-4"})})}),e.jsxs(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Remove Member?"}),e.jsxs(Il,{children:["Remove ",((Y=U.profile)==null?void 0:Y.name)||"this member"," from ",t.name,"?"]})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{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(owe,{})}),t.lead_pond_enabled&&e.jsx(zs,{value:"lead-pond",className:"space-y-4",children:e.jsx(lwe,{teamId:t.id})}),t.shared_assets_enabled&&e.jsx(zs,{value:"shared-assets",className:"space-y-4",children:e.jsx(yKe,{teamId:t.id})}),e.jsxs(zs,{value:"settings",className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{className:"text-lg",children:"Team Settings"}),e.jsx(yr,{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(Tr,{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(tr,{defaultValue:t.contact_visibility,onValueChange:U=>n({contact_visibility:U}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{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(tc,{children:[e.jsx(Ih,{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(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Delete Team?"}),e.jsxs(Il,{children:['This will permanently delete "',t.name,'" and remove all team members. This cannot be undone.']})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:()=>{i(),r()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Team"})]})]})]})]})]})]})},_Ke=({open:t,onOpenChange:s,onCreateTeam:r,isCreating:n,brokerageAgents:a,isAdmin:o,allBrokerages:l,activeBrokerageId:i})=>{const[d,u]=S.useState(1),[p,g]=S.useState(""),[v,_]=S.useState(""),[b,j]=S.useState(""),[w,N]=S.useState(""),[C,A]=S.useState([]),I=()=>{u(1),g(""),_(""),j(""),N(""),A([])},L=U=>{U||I(),s(U)},R=async()=>{const U=b&&b!=="none"?b:i||null;await r({name:p.trim(),description:v.trim()||void 0,brokerage_id:U,leaderId:w||void 0,memberIds:C.length>0?C:void 0}),I()},$=U=>{U!==w&&A(V=>V.includes(U)?V.filter(X=>X!==U):[...V,U])},q=a.filter(U=>U.id!==w);return e.jsx(vs,{open:t,onOpenChange:L,children:e.jsxs(ys,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:Et("h-1.5 flex-1 rounded-full transition-colors","bg-primary")}),e.jsx("div",{className:Et("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=>g(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(Tr,{id:"team-desc",value:v,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(tr,{value:b,onValueChange:j,children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"No brokerage (independent team)"})}),e.jsxs(er,{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(zh,{className:"h-3.5 w-3.5 text-[hsl(var(--chart-4))]"}),"Team Leader"]}),e.jsxs(tr,{value:w,onValueChange:U=>{N(U),A(V=>V.filter(X=>X!==U))},children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select a team leader (optional)"})}),e.jsxs(er,{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(fc,{className:"h-3.5 w-3.5"}),"Initial Members",C.length>0&&e.jsxs(at,{variant:"secondary",className:"ml-1 text-xs",children:[C.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 V=C.includes(U.id);return e.jsxs("button",{type:"button",className:Et("w-full flex items-center gap-3 p-3 text-left transition-colors hover:bg-accent/50",V&&"bg-primary/5"),onClick:()=>$(U.id),children:[e.jsxs(fn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:U.avatar_url||""}),e.jsx(gn,{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:Et("h-5 w-5 rounded-full border-2 flex items-center justify-center transition-colors shrink-0",V?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30"),children:V&&e.jsx(fa,{className:"h-3 w-3"})})]},U.id)})})]})]})}),e.jsx(On,{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(Ui,{className:"ml-2 h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>u(1),children:[e.jsx(Ka,{className:"mr-2 h-4 w-4"}),"Back"]}),e.jsx(K,{onClick:R,disabled:n,children:n?"Creating…":"Create Team"})]})})]})})},$8t=()=>{const{teams:t,isLoading:s,createTeam:r,updateTeam:n,deleteTeam:a,addMember:o,removeMember:l,updateMemberRole:i}=rS(),[d,u]=S.useState(!1),[p,g]=S.useState(null),[v,_]=S.useState(""),{data:b}=Ct({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:j}=Ct({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(V=>V.id));if(!L)return{};const R=L.filter(V=>V.role==="team_leader").map(V=>V.user_id);let $={};if(R.length>0){const{data:V}=await G.from("profiles").select("id, name").in("id",R);V&&($=Object.fromEntries(V.map(X=>[X.id,{name:X.name}])))}const q={};for(const V of t){const X=L.filter(te=>te.team_id===V.id),se=X.find(te=>te.role==="team_leader");q[V.id]={count:X.length,leaderName:se&&((U=$[se.user_id])==null?void 0:U.name)||null}}return q},enabled:t.length>0}),w=(p==null?void 0:p.brokerage_id)||null,{data:N}=Ct({queryKey:["brokerage-agents-for-teams",w],queryFn:async()=>{let L=G.from("profiles").select("id, name, email, avatar_url").order("name");w&&(L=L.eq("brokerage_id",w));const{data:R,error:$}=await L;if($)throw $;return R||[]},enabled:!!p}),C=Object.fromEntries((b||[]).map(L=>[L.id,L.name])),A=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(vKe,{team:p,brokerageAgents:N||[],onBack:()=>g(null),onUpdate:L=>n.mutateAsync({id:p.id,...L}).then(R=>g(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),g(null)},isUpdating:n.isPending,isAddingMember:o.isPending});const I=t.filter(L=>L.name.toLowerCase().includes(v.toLowerCase())||(L.description||"").toLowerCase().includes(v.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(xn,{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:v,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(_Ke,{open:d,onOpenChange:u,onCreateTeam:A,isCreating:r.isPending,brokerageAgents:[],isAdmin:!0,allBrokerages:b,activeBrokerageId:null}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(jt,{className:"font-semibold",children:"Team Name"}),e.jsx(jt,{className:"font-semibold",children:"Brokerage"}),e.jsx(jt,{className:"font-semibold",children:"Leader"}),e.jsx(jt,{className:"font-semibold",children:"Members"}),e.jsx(jt,{className:"font-semibold",children:"Visibility"}),e.jsx(jt,{className:"w-[100px]"})]})}),e.jsx(En,{children:s?e.jsx(e.Fragment,{children:[1,2,3].map(L=>e.jsxs(js,{children:[e.jsx(it,{children:e.jsx(gs,{className:"h-4 w-32"})}),e.jsx(it,{children:e.jsx(gs,{className:"h-4 w-24"})}),e.jsx(it,{children:e.jsx(gs,{className:"h-4 w-28"})}),e.jsx(it,{children:e.jsx(gs,{className:"h-4 w-12"})}),e.jsx(it,{children:e.jsx(gs,{className:"h-4 w-20"})}),e.jsx(it,{children:e.jsx(gs,{className:"h-4 w-16"})})]},L))}):I.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:6,className:"text-center py-12 text-muted-foreground",children:v?"No teams match your search":"No teams found. Create one to get started."})}):I.map(L=>{const R=j==null?void 0:j[L.id];return e.jsxs(js,{className:"hover:bg-muted/30",children:[e.jsxs(it,{children:[e.jsx("button",{onClick:()=>g(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(it,{children:L.brokerage_id?e.jsx("span",{className:"text-sm",children:C[L.brokerage_id]||"—"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Independent"})}),e.jsx(it,{children:R!=null&&R.leaderName?e.jsxs("span",{className:"text-sm flex items-center gap-1",children:[e.jsx(zh,{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(it,{children:e.jsxs(at,{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(it,{children:e.jsxs("span",{className:"text-xs text-muted-foreground capitalize flex items-center gap-1",children:[e.jsx(sh,{className:"h-3 w-3"}),L.contact_visibility.replace("_"," ")]})}),e.jsx(it,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>g(L),title:"Edit team",children:e.jsx(Ua,{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)})})]})})]})},q8t=()=>{const t=Lr(),{user:s,isAdmin:r}=Gs(),{startImpersonation:n,isLoading:a}=C1e(),{toast:o}=Ea(),[l,i]=S.useState([]),[d,u]=S.useState([]),[p,g]=S.useState([]),[v,_]=S.useState({}),[b,j]=S.useState(!0),[w,N]=S.useState({}),[C,A]=S.useState(!1),[I,L]=S.useState({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),[R,$]=S.useState(!1),[q,U]=S.useState(""),[V,X]=S.useState(1),[se,te]=S.useState(50),[Y,de]=S.useState("all"),[ie,ae]=S.useState("all"),[le,pe]=S.useState("all"),[be,ye]=S.useState("all"),[we,Ne]=S.useState(!1),[Ke,_e]=S.useState(!1),[Me,Te]=S.useState(null),[Fe,Ae]=S.useState(null),[Ue,ut]=S.useState(!1),[De,Dt]=S.useState({name:"",email:"",brokerage_id:"",phone:""}),[he,Ve]=S.useState(null),[nt,Qe]=S.useState(!1),[ke,ot]=S.useState(""),[qe,lt]=S.useState(!1),[We,Ye]=S.useState(!1),[mt,Ze]=S.useState(null),[He,et]=S.useState(""),[Rt,qt]=S.useState(!1),[ls,Kt]=S.useState(!1),[Qt,fs]=S.useState(null),[dr,bt]=S.useState(!1),[ks,ir]=S.useState(!1),[Rr,ca]=S.useState(null),[ii,lo]=S.useState(""),[Oa,yn]=S.useState(!1),[ta,Zt]=S.useState({email:"",name:"",password:"",phone:""}),[vr,Gr]=S.useState(!1),[Rn,rs]=S.useState(!1),[Ln,da]=S.useState(""),[Va,Jr]=S.useState(!1),[Za,$l]=S.useState(!1),[Do,Yc]=S.useState(""),[ct,Se]=S.useState(new Set),[ze,st]=S.useState(!1),[Tt,Nt]=S.useState(!1),[Bt,Yt]=S.useState(null),[Ut,Jt]=S.useState(!1),[Is,xs]=S.useState(null),[pr,$r]=S.useState([]),[cr,Cn]=S.useState([]),[Mn,wn]=S.useState(!1),[ua,co]=S.useState({});S.useEffect(()=>{!s||!r||(Ha(),Wo())},[s,r]);const $o=async()=>{try{const{data:yt,error:Ts}=await G.from("brokerage_manager_assignments").select("user_id, brokerage_id");if(Ts)throw Ts;const Ws={};for(const ln of yt??[])Ws[ln.brokerage_id]||(Ws[ln.brokerage_id]=[]),Ws[ln.brokerage_id].push(ln.user_id);_(Ws)}catch(yt){console.error("Error loading brokerage manager assignments:",yt)}},Ha=async()=>{try{j(!0);const{data:yt,error:Ts}=await G.functions.invoke("get-user-details");if(Ts)throw Ts;const Ws=yt.users||[];i(Ws),g(yt.brokerages||[]),await $o();const ln=Ws.filter(cn=>cn.roles.includes("assistant"));if(ln.length>0){const cn=ln.map(Fr=>Fr.id),{data:ea}=await G.from("agent_assistant_assignments").select("agent_id, assistant_id").in("assistant_id",cn);if(ea&&ea.length>0){const Fr=[...new Set(ea.map($m=>$m.agent_id))],{data:eo}=await G.from("profiles").select("id, name, email").in("id",Fr),Rf={};for(const $m of ea){const Vr=eo==null?void 0:eo.find(by=>by.id===$m.agent_id);Vr&&(Rf[$m.assistant_id]={agent_name:Vr.name||"",agent_email:Vr.email||""})}co(Rf)}}}catch(yt){console.error("Error loading members:",yt),o({title:"Error",description:"Failed to load members",variant:"destructive"})}finally{j(!1)}},Wo=async()=>{try{const{data:yt,error:Ts}=await G.from("app_tiles").select("id, name, icon, app_id, required_tags").order("name");if(Ts)throw Ts;u(yt||[])}catch(yt){console.error("Error loading apps:",yt),o({title:"Error",description:"Failed to load apps",variant:"destructive"})}},Xi=async yt=>{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:Ws}=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",yt);if(Ws)throw Ws;o({title:"Success",description:"Member details updated successfully"}),Te(null),Ha()}catch(Ws){console.error("Error updating member:",Ws),o({title:"Error",description:Ws.message||"Failed to update member",variant:"destructive"})}},_a=async yt=>{try{const{data:{session:Ts}}=await G.auth.getSession(),Ws=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ts==null?void 0:Ts.access_token}`},body:JSON.stringify({userId:yt})}),ln=await Ws.json();if(!Ws.ok)throw new Error(ln.error||"Failed to resend welcome email");o({title:"Success",description:"Welcome email sent successfully"})}catch(Ts){console.error("Error resending welcome email:",Ts),o({title:"Error",description:Ts.message||"Failed to resend welcome email",variant:"destructive"})}},Qi=async(yt,Ts)=>{try{const{error:Ws}=await G.functions.invoke("send-password-reset",{body:{email:yt,redirectTo:window.location.origin}});if(Ws)throw Ws;o({title:"Password Reset Sent",description:`Password reset email sent to ${Ts}`})}catch(Ws){console.error("Error sending password reset:",Ws),o({title:"Error",description:Ws.message||"Failed to send password reset email",variant:"destructive"})}},xi=async(yt,Ts)=>{if(confirm(`Are you sure you want to delete ${Ts}? This action cannot be undone.`))try{const{data:{session:Ws}}=await G.auth.getSession(),ln=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ws==null?void 0:Ws.access_token}`},body:JSON.stringify({userId:yt})}),cn=await ln.json();if(!ln.ok)throw new Error(cn.error||"Failed to delete user");o({title:"Success",description:"User deleted successfully"}),Ha()}catch(Ws){console.error("Error deleting user:",Ws),o({title:"Error",description:Ws.message||"Failed to delete user",variant:"destructive"})}},sa=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}A(!0);try{const{data:{session:yt}}=await G.auth.getSession(),Ts=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${yt==null?void 0:yt.access_token}`},body:JSON.stringify(I)}),Ws=await Ts.json();if(!Ts.ok)throw new Error(Ws.error||"Failed to create user");if(I.role&&I.role!=="user"&&Ws.userId){const ln=I.role==="brokerage_manager"?I.brokerage_id:void 0;await Ji(Ws.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),Ha()}catch(yt){console.error("Error creating user:",yt),o({title:"Error",description:yt.message||"Failed to create user",variant:"destructive"})}finally{A(!1)}},Ji=async(yt,Ts,Ws,ln)=>{try{const{data:{session:cn}}=await G.auth.getSession(),ea={userId:yt,role:Ts,action:Ws};if(Ts==="brokerage_manager"){if(!ln){o({title:"Error",description:"Please choose a brokerage for this manager assignment",variant:"destructive"});return}ea.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(ea)}),eo=await Fr.json();if(!Fr.ok)throw new Error(eo.error||"Failed to manage user role");o({title:"Success",description:`Role ${Ws==="add"?"added":"removed"} successfully`}),Ha()}catch(cn){console.error("Error managing user role:",cn),o({title:"Error",description:cn.message||"Failed to manage user role",variant:"destructive"})}},rc=(yt,Ts)=>Ts.length===0?!0:Ts.some(Ws=>yt.includes(Ws)),gc=async(yt,Ts,Ws)=>{const ln=`${yt}-${Ts.id}`;Ve(ln);try{if(Ws){const cn=l.find(Fr=>Fr.id===yt),ea=Ts.required_tags.filter(Fr=>cn==null?void 0:cn.tags.includes(Fr));for(const Fr of ea){const{error:eo}=await G.from("user_tags").delete().eq("user_id",yt).eq("tag",Fr);if(eo)throw eo}o({title:"Access Removed",description:`Removed access to ${Ts.name}`})}else if(Ts.required_tags.length>0){const{error:cn}=await G.from("user_tags").insert({user_id:yt,tag:Ts.required_tags[0]});if(cn)throw cn;o({title:"Access Granted",description:`Granted access to ${Ts.name}`})}await Ha()}catch(cn){console.error("Error toggling access:",cn),o({title:"Error",description:cn.message||"Failed to update access",variant:"destructive"})}finally{Ve(null)}},Md=async()=>{const yt=ke.trim();if(!yt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(yt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}if(p.find(Ws=>Ws.name.toLowerCase()===yt.toLowerCase())){o({title:"Error",description:"A brokerage with this name already exists",variant:"destructive"});return}lt(!0);try{const{error:Ws}=await G.from("brokerages").insert({name:yt});if(Ws)throw Ws;o({title:"Success",description:`Brokerage "${yt}" created successfully`}),ot(""),Qe(!1),Ha()}catch(Ws){console.error("Error creating brokerage:",Ws),o({title:"Error",description:Ws.message||"Failed to create brokerage",variant:"destructive"})}finally{lt(!1)}},Np=yt=>{Ze(yt),et(yt.name),Ye(!0)},xl=()=>{Ze(null),et(""),Ye(!1)},wu=async()=>{if(!mt)return;const yt=He.trim();if(!yt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(yt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}qt(!0);try{const{error:Ts}=await G.from("brokerages").update({name:yt}).eq("id",mt.id);if(Ts)throw Ts;o({title:"Success",description:"Brokerage updated successfully"}),xl(),Ha()}catch(Ts){console.error("Error updating brokerage:",Ts),o({title:"Error",description:Ts.message||"Failed to update brokerage",variant:"destructive"})}finally{qt(!1)}},Xc=async(yt,Ts)=>{var Ws;if(!Ts||typeof Ts!="string"){o({title:"Error",description:"Please select a brokerage first",variant:"destructive"});return}try{const ln={userId:yt,role:"brokerage_manager",action:"add",brokerageId:Ts};console.debug("[assignManagerToBrokerage] payload",ln);const{data:{session:cn}}=await G.auth.getSession(),ea=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 ea.json();if(!ea.ok&&!((Ws=Fr.error)!=null&&Ws.includes("duplicate")))throw new Error(Fr.error||"Failed to add role");o({title:"Success",description:"Manager assigned to brokerage"}),await Ha()}catch(ln){console.error("Error assigning manager:",ln),o({title:"Error",description:ln.message||"Failed to assign manager",variant:"destructive"})}},Qh=yt=>{fs(yt),Kt(!0)},yl=async()=>{if(Qt){bt(!0);try{const yt=l.filter(ln=>ln.brokerage_id===Qt.id),{data:{session:Ts}}=await G.auth.getSession();for(const ln of yt){const cn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ts==null?void 0:Ts.access_token}`},body:JSON.stringify({userId:ln.id})});if(!cn.ok){const ea=await cn.json();console.error(`Failed to delete user ${ln.email}:`,ea.error)}}const{error:Ws}=await G.from("brokerages").delete().eq("id",Qt.id);if(Ws)throw Ws;o({title:"Success",description:`Brokerage "${Qt.name}" and ${yt.length} member(s) deleted`}),Kt(!1),fs(null),Ha()}catch(yt){console.error("Error deleting brokerage:",yt),o({title:"Error",description:yt.message||"Failed to delete brokerage",variant:"destructive"})}finally{bt(!1)}}},Lf=yt=>{ca(yt),lo(""),ir(!0)},Xg=()=>{ca(null),lo(""),ir(!1)},iv=async yt=>{try{const{error:Ts}=await G.from("profiles").update({brokerage_id:null}).eq("id",yt);if(Ts)throw Ts;o({title:"Success",description:"User removed from brokerage"}),Ha()}catch(Ts){console.error("Error removing user from brokerage:",Ts),o({title:"Error",description:Ts.message||"Failed to remove user",variant:"destructive"})}},ov=async(yt,Ts)=>{try{const{error:Ws}=await G.from("profiles").update({brokerage_id:Ts}).eq("id",yt);if(Ws)throw Ws;o({title:"Success",description:"User added to brokerage"}),Ha()}catch(Ws){console.error("Error adding user to brokerage:",Ws),o({title:"Error",description:Ws.message||"Failed to add user",variant:"destructive"})}},lv=async()=>{if(!Rr||!ta.email||!ta.name||!ta.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}Gr(!0);try{const{data:{session:yt}}=await G.auth.getSession(),Ts=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${yt==null?void 0:yt.access_token}`},body:JSON.stringify({...ta,brokerage_id:Rr.id,role:"user"})}),Ws=await Ts.json();if(!Ts.ok)throw new Error(Ws.error||"Failed to create agent");o({title:"Success",description:`Agent ${ta.email} created successfully`}),Zt({email:"",name:"",password:"",phone:""}),yn(!1),Ha()}catch(yt){console.error("Error creating agent:",yt),o({title:"Error",description:yt.message||"Failed to create agent",variant:"destructive"})}finally{Gr(!1)}},Bm=yt=>l.filter(Ts=>Ts.brokerage_id===yt),uh=yt=>{const Ts=Bm(yt);if(!ii)return Ts;const Ws=ii.toLowerCase();return Ts.filter(ln=>ln.name.toLowerCase().includes(Ws)||ln.email.toLowerCase().includes(Ws))},Td=yt=>l.filter(Ts=>Ts.brokerage_id!==yt),hh=l.filter(yt=>{var Ws;if(q){const ln=q.toLowerCase();if(!(yt.name.toLowerCase().includes(ln)||yt.email.toLowerCase().includes(ln)||((Ws=yt.brokerage_name)==null?void 0:Ws.toLowerCase().includes(ln))))return!1}if(Y==="claimed"&&!yt.claimed||Y==="unclaimed"&&yt.claimed||ie!=="all"&&!yt.roles.includes(ie))return!1;const Ts=yt.is_trial||yt.subscription_status==="trialing";return!(le==="trial"&&!Ts||le==="non-trial"&&Ts||be==="none"&&yt.brokerage_id||be!=="all"&&be!=="none"&&yt.brokerage_id!==be)}),{sortKey:hd,sortDirection:Qc,handleSort:Ad,sortData:Sp}=qL("created_at","desc"),Cp=Sp(hh,{name:yt=>{var Ts;return((Ts=yt.name)==null?void 0:Ts.toLowerCase())||""},brokerage:yt=>{var Ts;return((Ts=yt.brokerage_name)==null?void 0:Ts.toLowerCase())||""},status:yt=>yt.claimed?"active":"pending",role:yt=>yt.roles[0]||"",last_login:yt=>yt.last_sign_in_at?new Date(yt.last_sign_in_at).getTime():null,created_at:yt=>yt.created_at?new Date(yt.created_at).getTime():null}),Jh=Cp.length,em=se===0,Jc=em?1:Math.ceil(Jh/se),xy=em?0:(V-1)*se,Df=em?Jh:xy+se,ul=Cp.slice(xy,Df),cv=yt=>{U(yt),X(1)},Of=yt=>{te(yt),X(1)},qu=(yt,Ts)=>{yt(Ts),X(1)},eb=async(yt,Ts)=>{Ne(!0);try{const Ws=l.find(Fr=>Fr.id===yt);if(!Ws)return;const ln=Ws.trial_expires_at?new Date(Ws.trial_expires_at):new Date,cn=new Date(ln.getTime()+Ts*24*60*60*1e3),{error:ea}=await G.from("profiles").update({trial_expires_at:cn.toISOString()}).eq("id",yt);if(ea)throw ea;o({title:"Trial Extended",description:`Trial extended by ${Ts} days`}),Ha()}catch(Ws){console.error("Error extending trial:",Ws),o({title:"Error",description:Ws.message||"Failed to extend trial",variant:"destructive"})}finally{Ne(!1)}},dS=async yt=>{_e(!0);try{const{error:Ts}=await G.from("profiles").update({is_trial:!1,trial_expires_at:null,trial_started_at:null,trial_claimed_at:null}).eq("id",yt);if(Ts)throw Ts;o({title:"Account Converted",description:"User has been converted to a full account"}),Ha(),Qg()}catch(Ts){console.error("Error converting trial:",Ts),o({title:"Error",description:Ts.message||"Failed to convert account",variant:"destructive"})}finally{_e(!1)}},yy=async yt=>{wn(!0);try{const{data:Ts}=await G.from("agent_assistant_assignments").select("id, assistant_id, permissions").eq("agent_id",yt);if(Ts&&Ts.length>0){const ln=Ts.map(ea=>ea.assistant_id),{data:cn}=await G.from("profiles").select("id, name, email").in("id",ln);$r(Ts.map(ea=>{const Fr=cn==null?void 0:cn.find(eo=>eo.id===ea.assistant_id);return{id:ea.id,assistant_id:ea.assistant_id,assistant_name:(Fr==null?void 0:Fr.name)||"Unknown",assistant_email:(Fr==null?void 0:Fr.email)||"",permissions:ea.permissions||{}}}))}else $r([]);const{data:Ws}=await G.from("agent_assistant_assignments").select("id, agent_id, permissions").eq("assistant_id",yt);if(Ws&&Ws.length>0){const ln=Ws.map(ea=>ea.agent_id),{data:cn}=await G.from("profiles").select("id, name, email").in("id",ln);Cn(Ws.map(ea=>{const Fr=cn==null?void 0:cn.find(eo=>eo.id===ea.agent_id);return{id:ea.id,agent_id:ea.agent_id,agent_name:(Fr==null?void 0:Fr.name)||"Unknown",agent_email:(Fr==null?void 0:Fr.email)||"",permissions:ea.permissions||{}}}))}else Cn([])}catch(Ts){console.error("Error loading assistant data:",Ts)}finally{wn(!1)}},ba=yt=>{Ae(yt),Dt({name:yt.name,email:yt.email,brokerage_id:yt.brokerage_id||"",phone:yt.phone||""}),ut(!0),yy(yt.id)},Qg=()=>{Ae(null),ut(!1),Dt({name:"",email:"",brokerage_id:"",phone:""})},tb=async()=>{Fe&&(await Xi(Fe.id),Qg())},uS=yt=>{Se(Ts=>{const Ws=new Set(Ts);return Ws.has(yt)?Ws.delete(yt):Ws.add(yt),Ws})},hS=()=>{if(ct.size===ul.length&&ul.every(yt=>ct.has(yt.id))){const yt=new Set(ct);ul.forEach(Ts=>yt.delete(Ts.id)),Se(yt)}else{const yt=new Set(ct);ul.forEach(Ts=>yt.add(Ts.id)),Se(yt)}},mh=()=>{Se(new Set)},vy=async()=>{if(ct.size===0)return;st(!0);let yt=0,Ts=0;try{const{data:{session:Ws}}=await G.auth.getSession();for(const ln of ct)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ws==null?void 0:Ws.access_token}`},body:JSON.stringify({userId:ln})})).ok?yt++:Ts++}catch{Ts++}o({title:"Bulk Email Complete",description:`Sent ${yt} emails${Ts>0?`, ${Ts} failed`:""}`}),mh()}catch(Ws){o({title:"Error",description:Ws.message||"Failed to send emails",variant:"destructive"})}finally{st(!1)}},_y=async()=>{if(ct.size===0)return;st(!0);let yt=0,Ts=0;try{const{data:{session:Ws}}=await G.auth.getSession();for(const ln of ct)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-password-reset",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ws==null?void 0:Ws.access_token}`},body:JSON.stringify({userId:ln})})).ok?yt++:Ts++}catch{Ts++}o({title:"Bulk Password Reset Complete",description:`Sent ${yt} reset emails${Ts>0?`, ${Ts} failed`:""}`}),mh()}catch(Ws){o({title:"Error",description:Ws.message||"Failed to send password reset emails",variant:"destructive"})}finally{st(!1)}},sb=async()=>{if(ct.size===0)return;const yt=l.filter(cn=>ct.has(cn.id)).map(cn=>cn.name).slice(0,5).join(", "),Ts=ct.size>5?` and ${ct.size-5} more`:"";if(!confirm(`Are you sure you want to delete ${ct.size} users (${yt}${Ts})? This action cannot be undone.`))return;st(!0);let Ws=0,ln=0;try{const{data:{session:cn}}=await G.auth.getSession();for(const ea of ct)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:ea})})).ok?Ws++:ln++}catch{ln++}o({title:"Bulk Delete Complete",description:`Deleted ${Ws} users${ln>0?`, ${ln} failed`:""}`}),mh(),Ha()}catch(cn){o({title:"Error",description:cn.message||"Failed to delete users",variant:"destructive"})}finally{st(!1)}},dv=async()=>{Nt(!0);try{const{data:{session:yt}}=await G.auth.getSession(),Ts=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-phone-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${yt==null?void 0:yt.access_token}`}});if(!Ts.ok){const ln=await Ts.json();throw new Error(ln.error||"Failed to sync phones")}const Ws=await Ts.json();o({title:"Phone Sync Complete",description:`Pulled ${Ws.summary.pulledFromGHL} from GHL, pushed ${Ws.summary.pushedToGHL} to GHL, ${Ws.summary.alreadySynced} already synced`}),Ha()}catch(yt){o({title:"Error",description:yt.message||"Failed to sync phones with GHL",variant:"destructive"})}finally{Nt(!1)}},tm=async(yt,Ts)=>{Yt(yt);try{const{data:{session:Ws}}=await G.auth.getSession(),{data:ln}=await G.from("profiles").select("phone").eq("id",yt).single(),cn=(ln==null?void 0:ln.phone)||"",ea=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-tag-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ws==null?void 0:Ws.access_token}`},body:JSON.stringify({email:Ts,action:"update",phone:cn||void 0})});if(!ea.ok){const eo=await ea.json();throw new Error(eo.error||"Failed to sync with GHL")}const Fr=await fetch(`https://services.leadconnectorhq.com/contacts/lookup?locationId=&email=${encodeURIComponent(Ts)}`,{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"}),Ha()}catch(Ws){o({title:"Error",description:Ws.message||"Failed to sync phone",variant:"destructive"})}finally{Yt(null)}},Jg=async yt=>{await n(yt)},rb=()=>{if(ct.size===0){o({title:"No members selected",description:"Please select members to export",variant:"destructive"});return}const yt=l.filter(eo=>ct.has(eo.id)),Ts=["Name","Email","Phone","Brokerage","Roles","Status","Created At"],Ws=yt.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=[Ts.join(","),...Ws.map(eo=>eo.map(Rf=>`"${(Rf||"").replace(/"/g,'""')}"`).join(","))].join(` `),cn=new Blob([ln],{type:"text/csv"}),ea=URL.createObjectURL(cn),Fr=document.createElement("a");Fr.href=ea,Fr.download=`members-export-${new Date().toISOString().split("T")[0]}.csv`,Fr.click(),URL.revokeObjectURL(ea),o({title:"Export complete",description:`Exported ${yt.length} member(s)`})};return b?e.jsx(Ms,{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(Ms,{title:"Members",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{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:dv,disabled:Tt,children:[Tt?e.jsx(As,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Zn,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:Tt?"Syncing...":"Sync Phones with GHL"}),e.jsx("span",{className:"sm:hidden",children:Tt?"Syncing...":"Sync GHL"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>rs(!0),children:[e.jsx(N0,{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(vs,{open:R,onOpenChange:$,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(fc,{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(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:yt=>L({...I,name:yt.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:yt=>L({...I,email:yt.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:yt=>L({...I,password:yt.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:yt=>L({...I,phone:yt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"brokerage",children:["Brokerage",I.role==="brokerage_manager"?" (required)":""]}),e.jsxs(tr,{value:I.brokerage_id||"none",onValueChange:yt=>L({...I,brokerage_id:yt==="none"?"":yt}),children:[e.jsx(Js,{id:"brokerage",children:e.jsx(sr,{placeholder:I.role==="brokerage_manager"?"Select brokerage":"Select brokerage (optional)"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"None"}),p.map(yt=>e.jsx(At,{value:yt.id,children:yt.name},yt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"role",children:"Role"}),e.jsxs(tr,{value:I.role,onValueChange:yt=>L({...I,role:yt}),children:[e.jsx(Js,{id:"role",children:e.jsx(sr,{placeholder:"Select role"})}),e.jsxs(er,{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(tr,{value:I.trial_days||"none",onValueChange:yt=>L({...I,trial_days:yt==="none"?"":yt}),children:[e.jsx(Js,{id:"trial_days",children:e.jsx(sr,{placeholder:"No trial (full access)"})}),e.jsxs(er,{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(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),e.jsx(K,{onClick:sa,disabled:C,children:C?"Creating...":"Create User"})]})]})]})]})]}),e.jsxs(ja,{defaultValue:new URLSearchParams(window.location.search).get("tab")||"members",className:"space-y-6",children:[e.jsxs(va,{children:[e.jsx(Ns,{value:"members",children:"Members"}),e.jsx(Ns,{value:"brokerages",children:"Brokerages"}),e.jsx(Ns,{value:"teams",children:"Teams"}),e.jsx(Ns,{value:"trials",children:"Trial Users"}),e.jsx(Ns,{value:"access",children:"Access Matrix"}),e.jsx(Ns,{value:"celebrations",children:"Celebrations"}),e.jsx(Ns,{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(xn,{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:yt=>cv(yt.target.value),className:"pl-10 h-9"})]}),e.jsxs(tr,{value:Y,onValueChange:yt=>qu(de,yt),children:[e.jsx(Js,{className:"w-[130px] h-9",children:e.jsx(sr,{})}),e.jsxs(er,{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(tr,{value:ie,onValueChange:yt=>qu(ae,yt),children:[e.jsx(Js,{className:"w-[130px] h-9",children:e.jsx(sr,{})}),e.jsxs(er,{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(tr,{value:le,onValueChange:yt=>qu(pe,yt),children:[e.jsx(Js,{className:"w-[130px] h-9",children:e.jsx(sr,{})}),e.jsxs(er,{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(tr,{value:be,onValueChange:yt=>qu(ye,yt),children:[e.jsx(Js,{className:"w-[150px] h-9",children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Brokerages"}),e.jsx(At,{value:"none",children:"No Brokerage"}),p.map(yt=>e.jsx(At,{value:yt.id,children:yt.name},yt.id))]})]}),(q||Y!=="all"||ie!=="all"||le!=="all"||be!=="all")&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-9",onClick:()=>{U(""),de("all"),ae("all"),pe("all"),ye("all"),X(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:em?`Showing all ${Jh} members`:`Showing ${xy+1}-${Math.min(Df,Jh)} of ${Jh} members`}),e.jsxs(tr,{value:se.toString(),onValueChange:yt=>Of(Number(yt)),children:[e.jsx(Js,{className:"h-9 w-[110px]",children:e.jsx(sr,{})}),e.jsxs(er,{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"})]})]})]})]}),ct.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(l0,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm font-medium",children:[ct.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:vy,disabled:ze,children:[ze?e.jsx(As,{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:_y,disabled:ze,children:[ze?e.jsx(As,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Em,{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:rb,children:[e.jsx(gi,{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:sb,disabled:ze,children:[ze?e.jsx(As,{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:mh,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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(jt,{className:"w-[50px]",children:e.jsx(zo,{checked:ul.length>0&&ul.every(yt=>ct.has(yt.id)),onCheckedChange:hS,"aria-label":"Select all on page"})}),e.jsx(el,{sortKey:"name",currentSortKey:hd,currentDirection:Qc,onSort:Ad,children:"Name"}),e.jsx(el,{sortKey:"brokerage",currentSortKey:hd,currentDirection:Qc,onSort:Ad,children:"Brokerage"}),e.jsx(el,{sortKey:"status",currentSortKey:hd,currentDirection:Qc,onSort:Ad,children:"Status"}),e.jsx(el,{sortKey:"role",currentSortKey:hd,currentDirection:Qc,onSort:Ad,children:"Role"}),e.jsx(el,{sortKey:"last_login",currentSortKey:hd,currentDirection:Qc,onSort:Ad,children:"Last Login"}),e.jsx(el,{sortKey:"created_at",currentSortKey:hd,currentDirection:Qc,onSort:Ad,children:"Member Since"}),e.jsx(jt,{className:"w-[100px]"})]})}),e.jsx(En,{children:ul.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:8,className:"text-center py-12 text-muted-foreground",children:"No members found"})}):ul.map(yt=>e.jsxs(js,{className:`hover:bg-muted/30 ${ct.has(yt.id)?"bg-primary/5":""}`,children:[e.jsx(it,{children:e.jsx(zo,{checked:ct.has(yt.id),onCheckedChange:()=>uS(yt.id),"aria-label":`Select ${yt.name}`})}),e.jsx(it,{children:e.jsxs("div",{children:[e.jsx("button",{onClick:()=>ba(yt),className:"text-primary hover:underline font-medium text-left",children:yt.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:yt.email})]})}),e.jsx(it,{className:"text-muted-foreground",children:yt.brokerage_name||"—"}),e.jsx(it,{children:e.jsx("div",{className:"flex flex-col",children:(()=>{const Ts=yt.is_trial&&yt.trial_expires_at||!yt.is_trial&&yt.subscription_status==="trialing"&&yt.subscription_end_date,Ws=yt.trial_expires_at||yt.subscription_end_date;if(Ts&&Ws){const ln=Math.ceil((new Date(Ws).getTime()-Date.now())/864e5),cn=ln<=0,ea=ln<=3;return e.jsx(at,{variant:"outline",className:Et("w-fit",cn?"border-destructive text-destructive":ea?"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(at,{variant:yt.claimed?"default":"secondary",className:yt.claimed?"bg-primary text-primary-foreground w-fit":"w-fit",children:yt.claimed?"Active":"Pending"})})()})}),e.jsx(it,{children:e.jsxs("div",{className:"flex flex-col",children:[yt.roles.length>0?e.jsx("span",{className:"text-sm capitalize",children:yt.roles[0]}):e.jsx("span",{className:"text-muted-foreground",children:"—"}),yt.roles.includes("assistant")&&ua[yt.id]&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",ua[yt.id].agent_name||ua[yt.id].agent_email]})]})}),e.jsx(it,{className:"text-muted-foreground",children:yt.last_sign_in_at?new Date(yt.last_sign_in_at).toLocaleDateString():"—"}),e.jsx(it,{className:"text-muted-foreground",children:yt.created_at?new Date(yt.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—"}),e.jsx(it,{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:()=>{xs(yt),Jt(!0)},title:"Send celebration",children:e.jsx(Nd,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>ba(yt),title:"Edit member",children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>tm(yt.id,yt.email),disabled:Bt===yt.id,title:"Sync phone with GHL",children:Bt===yt.id?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(Zn,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>_a(yt.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(yt.email,yt.name),title:"Send password reset",children:e.jsx(tN,{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:()=>Jg(yt.id),disabled:a||yt.id===(s==null?void 0:s.id),title:yt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${yt.name}`,children:a?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(p5,{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:()=>xi(yt.id,yt.name),title:"Delete user",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},yt.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 ",V," of ",Jc]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>X(1),disabled:V===1,children:"First"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(yt=>Math.max(1,yt-1)),disabled:V===1,children:e.jsx(Ol,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,Jc)},(yt,Ts)=>{let Ws;return Jc<=5||V<=3?Ws=Ts+1:V>=Jc-2?Ws=Jc-4+Ts:Ws=V-2+Ts,e.jsx(K,{variant:V===Ws?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>X(Ws),children:Ws},Ws)})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(yt=>Math.min(Jc,yt+1)),disabled:V===Jc,children:e.jsx(qa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>X(Jc),disabled:V===Jc,children:"Last"})]})]})]}),e.jsx(vs,{open:Ue,onOpenChange:ut,children:e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:yt=>Dt({...De,name:yt.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:yt=>Dt({...De,email:yt.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:yt=>Dt({...De,phone:yt.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"edit-brokerage",children:"Brokerage"}),e.jsxs(tr,{value:De.brokerage_id||"none",onValueChange:yt=>Dt({...De,brokerage_id:yt==="none"?"":yt}),children:[e.jsx(Js,{id:"edit-brokerage",children:e.jsx(sr,{placeholder:"Select brokerage"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"None"}),p.map(yt=>e.jsx(At,{value:yt.id,children:yt.name},yt.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(yt=>e.jsxs(at,{variant:"default",className:"gap-1",children:[e.jsx(sh,{className:"h-3 w-3"}),yt,yt==="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,yt,"remove"),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove role",children:e.jsx(Ur,{className:"h-3 w-3"})})]},yt)),Fe.roles.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"No roles assigned"})]}),e.jsxs(tr,{onValueChange:yt=>Ji(Fe.id,yt,"add"),children:[e.jsx(Js,{className:"w-[200px]",children:e.jsx(sr,{placeholder:"Add role..."})}),e.jsxs(er,{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"})]}),(pr.length>0||cr.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(As,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):e.jsxs("div",{className:"space-y-3",children:[pr.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:"}),pr.map(yt=>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:yt.assistant_name}),e.jsx(at,{variant:"outline",className:"text-xs",children:"Assistant"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:yt.assistant_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(yt.permissions).filter(([,Ts])=>Ts).map(([Ts])=>e.jsx(at,{variant:"secondary",className:"text-[10px] capitalize",children:Ts},Ts))})]},yt.id))]}),cr.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:"}),cr.map(yt=>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:yt.agent_name}),e.jsx(at,{variant:"outline",className:"text-xs",children:"Agent"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:yt.agent_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(yt.permissions).filter(([,Ts])=>Ts).map(([Ts])=>e.jsx(at,{variant:"secondary",className:"text-[10px] capitalize",children:Ts},Ts))})]},yt.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(yt=>{const Ts=rc(Fe.tags,yt.required_tags),Ws=`${Fe.id}-${yt.id}`,ln=he===Ws,cn=yt.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:yt.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:yt.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(As,{className:"h-4 w-4 animate-spin text-muted-foreground"}):cn?e.jsx(at,{variant:"secondary",className:"text-xs",children:"Always On"}):e.jsx(Br,{checked:Ts,onCheckedChange:()=>gc(Fe.id,yt,Ts)})})]},yt.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(In,{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(RAe,{expiresAt:Fe.trial_expires_at}),!Fe.trial_expires_at&&Fe.subscription_status==="trialing"&&Fe.subscription_end_date&&e.jsx(RAe,{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:()=>eb(Fe.id,7),disabled:we,children:[e.jsx(Y1,{className:"h-4 w-4 mr-1"}),"+7 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>eb(Fe.id,14),disabled:we,children:[e.jsx(Y1,{className:"h-4 w-4 mr-1"}),"+14 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>eb(Fe.id,30),disabled:we,children:[e.jsx(Y1,{className:"h-4 w-4 mr-1"}),"+30 Days"]}),e.jsxs(K,{size:"sm",variant:"default",onClick:()=>dS(Fe.id),disabled:Ke,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(i_,{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(On,{children:[e.jsx(K,{variant:"outline",onClick:Qg,children:"Cancel"}),e.jsx(K,{onClick:tb,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(Lt,{children:[e.jsx(zt,{children:"Member Access Matrix"}),e.jsx(yr,{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(yt=>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:yt.icon}),e.jsx("span",{className:"text-sm",children:yt.name})]})},yt.id))]})}),e.jsxs("tbody",{children:[ul.map(yt=>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:yt.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:yt.email})]})}),d.map(Ts=>{const Ws=rc(yt.tags,Ts.required_tags),ln=`${yt.id}-${Ts.id}`,cn=he===ln;return e.jsx("td",{className:"p-4 text-center",children:e.jsx("div",{className:"flex items-center justify-center",children:cn?e.jsx(As,{className:"h-5 w-5 animate-spin text-muted-foreground"}):e.jsx(Br,{checked:Ws,onCheckedChange:()=>gc(yt.id,Ts,Ws),disabled:Ts.required_tags.length===0})})},Ts.id)})]},yt.id)),ul.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 ",xy+1,"-",Math.min(Df,Jh)," of ",Jh," • Page ",V," 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:()=>X(yt=>Math.max(1,yt-1)),disabled:V===1,children:e.jsx(Ol,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(yt=>Math.min(Jc,yt+1)),disabled:V===Jc,children:e.jsx(qa,{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(xn,{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:Ln,onChange:yt=>da(yt.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[p.filter(yt=>yt.name.toLowerCase().includes(Ln.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 yt=[];for(const Fr of p){const eo=v[Fr.id]??[];for(const Rf of eo){const $m=l.find(Vr=>Vr.id===Rf);if($m){const Vr=($m.name||"").trim().split(/\s+/),by=Vr[0]||"",wy=Vr.slice(1).join(" ")||"";yt.push({firstName:by,lastName:wy,email:$m.email,brokerageName:Fr.name})}}}if(yt.length===0){o({title:"No managers found to export"});return}const Ws=[["First Name","Last Name","Email","Brokerage Name"].join(","),...yt.map(Fr=>[Fr.firstName,Fr.lastName,Fr.email,Fr.brokerageName].map(eo=>`"${(eo||"").replace(/"/g,'""')}"`).join(","))].join(` `),ln=new Blob([Ws],{type:"text/csv"}),cn=URL.createObjectURL(ln),ea=document.createElement("a");ea.href=cn,ea.download=`brokerage-managers-${new Date().toISOString().slice(0,10)}.csv`,ea.click(),URL.revokeObjectURL(cn),o({title:`Exported ${yt.length} managers`})},children:[e.jsx(gi,{className:"mr-2 h-4 w-4"}),"Export Managers"]}),e.jsxs(vs,{open:nt,onOpenChange:Qe,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Ca,{className:"mr-2 h-4 w-4"}),"Add Brokerage"]})}),e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:ke,onChange:yt=>ot(yt.target.value),maxLength:100})]})}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>Qe(!1),children:"Cancel"}),e.jsx(K,{onClick:Md,disabled:qe,children:qe?"Creating...":"Create Brokerage"})]})]})]})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(jt,{className:"font-semibold",children:"Brokerage Name"}),e.jsx(jt,{className:"font-semibold",children:"Manager(s)"}),e.jsx(jt,{className:"font-semibold",children:"Agents"}),e.jsx(jt,{className:"w-[150px]"})]})}),e.jsx(En,{children:(()=>{const yt=p.filter(Ts=>Ts.name.toLowerCase().includes(Ln.toLowerCase()));return yt.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:4,className:"text-center py-12 text-muted-foreground",children:Ln?"No brokerages match your search":"No brokerages found"})}):yt.map(Ts=>{const Ws=l.filter(Fr=>Fr.brokerage_id===Ts.id),cn=(v[Ts.id]??[]).map(Fr=>l.find(eo=>eo.id===Fr)).filter(Boolean),ea=Ws.length;return e.jsxs(js,{className:"hover:bg-muted/30",children:[e.jsx(it,{children:e.jsx("button",{onClick:()=>Np(Ts),className:"text-primary hover:underline font-medium",children:Ts.name})}),e.jsx(it,{children:cn.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:cn.map(Fr=>e.jsx(at,{variant:"secondary",className:"text-xs",children:Fr.name},Fr.id))}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"No manager"})}),e.jsxs(it,{children:[ea," member",ea!==1?"s":""]}),e.jsx(it,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"h-8",onClick:()=>Lf(Ts),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:()=>Np(Ts),title:"Edit brokerage",children:e.jsx(Ua,{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:()=>Qh(Ts),title:"Delete brokerage",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},Ts.id)})})()})]})}),e.jsx(vs,{open:We,onOpenChange:Ye,children:e.jsxs(ys,{className:"max-w-lg",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Edit Brokerage"}),e.jsx(Kr,{children:"Update brokerage details and manage managers"})]}),mt&&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:yt=>et(yt.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 Ts=(v[mt.id]??[]).map(Ws=>l.find(ln=>ln.id===Ws)).filter(Boolean);return Ts.length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No managers assigned"}):Ts.map(Ws=>e.jsxs(at,{variant:"default",className:"gap-1",children:[e.jsx(sh,{className:"h-3 w-3"}),Ws.name,e.jsx("button",{onClick:()=>Ji(Ws.id,"brokerage_manager","remove",mt.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"})})]},Ws.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(No,{open:Va,onOpenChange:Jr,children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":Va,className:"w-full justify-between",children:["Search for a member...",e.jsx(xn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-full p-0",align:"start",children:e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search by name or email..."}),e.jsxs(kf,{className:"max-h-[200px]",children:[e.jsx(Nf,{children:"No members found."}),e.jsx(Sf,{children:(()=>{const yt=new Set(v[mt.id]??[]);return l.filter(Ts=>!yt.has(Ts.id)&&(r||Ts.brokerage_id===mt.id)).map(Ts=>e.jsxs(jm,{value:`${Ts.name} ${Ts.email}`,onSelect:()=>{Xc(Ts.id,mt.id),Jr(!1)},children:[Ts.name," (",Ts.email,")"]},Ts.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(yt=>yt.brokerage_id===mt.id).length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No members"}):l.filter(yt=>yt.brokerage_id===mt.id).map(yt=>e.jsxs("div",{className:"text-sm py-1 flex items-center justify-between",children:[e.jsx("span",{children:yt.name}),yt.roles.includes("brokerage_manager")&&e.jsx(at,{variant:"outline",className:"text-xs",children:"Manager"})]},yt.id))})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:xl,children:"Cancel"}),e.jsx(K,{onClick:wu,disabled:Rt,children:Rt?"Saving...":"Save Changes"})]})]})}),e.jsx(vs,{open:ls,onOpenChange:Kt,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{className:"text-destructive",children:"Delete Brokerage"}),e.jsxs(Kr,{children:['Are you sure you want to delete "',Qt==null?void 0:Qt.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 "',Qt==null?void 0:Qt.name,'"']}),e.jsxs("li",{children:["All ",l.filter(yt=>yt.brokerage_id===(Qt==null?void 0:Qt.id)).length," member(s) assigned to this brokerage"]}),e.jsx("li",{children:"All their data, roles, and access"})]})]})}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>Kt(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:yl,disabled:dr,children:dr?"Deleting...":"Yes, Delete Brokerage"})]})]})}),e.jsx(vs,{open:ks,onOpenChange:ir,children:e.jsxs(ys,{className:"max-w-4xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Ca,{className:"h-5 w-5"}),"Manage ",Rr==null?void 0:Rr.name]}),e.jsx(Kr,{children:"Add, remove, or manage users in this brokerage"})]}),Rr&&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(xn,{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:yt=>lo(yt.target.value),className:"pl-10 h-9"})]}),e.jsxs(vs,{open:Oa,onOpenChange:yn,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(fc,{className:"h-4 w-4 mr-1"}),"Add New Agent"]})}),e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Add New Agent"}),e.jsxs(Kr,{children:["Create a new agent for ",Rr.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:ta.name,onChange:yt=>Zt({...ta,name:yt.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:ta.email,onChange:yt=>Zt({...ta,email:yt.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:ta.password,onChange:yt=>Zt({...ta,password:yt.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:ta.phone,onChange:yt=>Zt({...ta,phone:yt.target.value})})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>yn(!1),children:"Cancel"}),e.jsx(K,{onClick:lv,disabled:vr,children:vr?"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(No,{open:Za,onOpenChange:$l,children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":Za,className:"w-[300px] justify-between",children:["Select a user to add...",e.jsx(xn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-[300px] p-0",align:"start",children:e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search users...",value:Do,onValueChange:Yc}),e.jsxs(kf,{children:[e.jsx(Nf,{children:"No users found."}),e.jsx(Sf,{children:Td(Rr.id).filter(yt=>Do===""||yt.name.toLowerCase().includes(Do.toLowerCase())||yt.email.toLowerCase().includes(Do.toLowerCase())).map(yt=>e.jsxs(jm,{value:`${yt.name} ${yt.email}`,onSelect:()=>{ov(yt.id,Rr.id),$l(!1),Yc("")},children:[yt.name," (",yt.email,")"]},yt.id))})]})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto border rounded-lg",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(jt,{className:"font-semibold",children:"Name"}),e.jsx(jt,{className:"font-semibold",children:"Email"}),e.jsx(jt,{className:"font-semibold",children:"Status"}),e.jsx(jt,{className:"font-semibold",children:"Role"}),e.jsx(jt,{className:"w-[120px]"})]})}),e.jsx(En,{children:uh(Rr.id).length===0?e.jsx(js,{children:e.jsx(it,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:ii?"No matching members found":"No members in this brokerage"})}):uh(Rr.id).map(yt=>e.jsxs(js,{className:"hover:bg-muted/30",children:[e.jsx(it,{className:"font-medium",children:yt.name}),e.jsx(it,{className:"text-muted-foreground",children:yt.email}),e.jsx(it,{children:yt.claimed?e.jsx(at,{variant:"default",className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active"}):e.jsx(at,{variant:"secondary",children:"Pending"})}),e.jsx(it,{children:yt.roles.includes("brokerage_manager")?e.jsxs(at,{variant:"outline",className:"gap-1",children:[e.jsx(sh,{className:"h-3 w-3"}),"Manager"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Agent"})}),e.jsx(it,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[!yt.claimed&&e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>_a(yt.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:()=>iv(yt.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:()=>Jg(yt.id),disabled:a||yt.id===(s==null?void 0:s.id),title:yt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${yt.name}`,children:a?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(p5,{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:()=>xi(yt.id,yt.name),title:"Delete user",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},yt.id))})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Bm(Rr.id).length," total member",Bm(Rr.id).length!==1?"s":""," •",Bm(Rr.id).filter(yt=>yt.roles.includes("brokerage_manager")).length," manager",Bm(Rr.id).filter(yt=>yt.roles.includes("brokerage_manager")).length!==1?"s":""]})]}),e.jsx(On,{children:e.jsx(K,{variant:"outline",onClick:Xg,children:"Close"})})]})})]}),e.jsx(zs,{value:"teams",children:e.jsx($8t,{})}),e.jsx(zs,{value:"trials",children:e.jsx(R8t,{})}),e.jsx(zs,{value:"celebrations",children:e.jsx(O8t,{})}),e.jsx(zs,{value:"deletions",children:e.jsx(F8t,{})})]})]}),e.jsx(pKe,{open:Rn,onOpenChange:rs,brokerages:p,onSuccess:Ha}),Is&&e.jsx(fKe,{open:Ut,onOpenChange:yt=>{Jt(yt),yt||xs(null)},userId:Is.id,userName:Is.name})]})},U8t=()=>{const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(!1),[l,i]=S.useState(""),[d,u]=S.useState(""),[p,g]=S.useState(""),[v,_]=S.useState("");S.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)},j=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:v?parseInt(v):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(""),g(""),_(""),b()),o(!1)},w=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))},N=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)))},C="https://dashboard.relevelup.com",A=L=>{const R=`${C}/join?code=${L}`;navigator.clipboard.writeText(R),fe.success("Link copied to clipboard")},I=`${C}/join`;return e.jsx(Ms,{title:"Invite Codes",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{title:"Invite Codes",description:"Manage signup invite codes"}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Create New Code"}),e.jsxs(yr,{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:j,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=>g(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:v,onChange:L=>_(L.target.value),className:"w-28"})]}),e.jsxs(K,{type:"submit",disabled:a,children:[a?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create"]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Active Codes"})}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(As,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Code"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{children:"Uses"}),e.jsx(jt,{children:"Trial"}),e.jsx(jt,{children:"Created"}),e.jsx(jt,{children:"Active"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(En,{children:t.map(L=>e.jsxs(js,{children:[e.jsx(it,{className:"font-mono font-medium",children:L.code}),e.jsx(it,{className:"text-muted-foreground",children:L.description||"—"}),e.jsxs(it,{children:[L.uses_count,L.max_uses&&` / ${L.max_uses}`]}),e.jsx(it,{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(it,{className:"text-muted-foreground",children:ws(new Date(L.created_at),"MMM d, yyyy")}),e.jsx(it,{children:e.jsx(Br,{checked:L.is_active,onCheckedChange:()=>w(L.id,L.is_active)})}),e.jsx(it,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>A(L.code),title:"Copy invite link",children:e.jsx(ai,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>N(L.id),className:"text-destructive hover:text-destructive",title:"Delete code",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},L.id))})]})})]})]})})},UL=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}},NM=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}}},V8t=async(t,s)=>await UL("new_templates")?NM({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}),H8t=async(t,s)=>NM({title:"New Academy Video",body:`New video added: ${t}`,url:`/academy/${s}`}),W8t=async(t,s)=>await UL("new_events")?NM({title:"New Event",body:`New event: ${t}`,url:`/events/${s}`}):(console.log("New event notifications are disabled"),{success:!1,skipped:!0}),G8t=async(t,s)=>await UL("new_toolbox")?NM({title:"New Resource Kit",body:`New resource kit available: ${t}`,url:`/toolbox/${s}`}):(console.log("New toolbox notifications are disabled"),{success:!1,skipped:!0}),sye=async(t,s)=>await UL("new_social_swag")?NM({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}),K8t=async(t,s)=>await UL("new_newsletters")?NM({title:"New Newsletter",body:`New newsletter available: ${t}`,url:`/newsletters/${s}`}):(console.log("New newsletter notifications are disabled"),{success:!1,skipped:!0}),nR={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 Z8t(){const t=Lr(),s=ns(),[r,n]=S.useState(!1),[a,o]=S.useState(null),[l,i]=S.useState(nR),[d,u]=S.useState(null),[p,g]=S.useState(null),[v,_]=S.useState(!1),b=S.useRef(null),[j,w]=S.useState(!1),[N,C]=S.useState(null),[A,I]=S.useState(!1),[L,R]=S.useState(null),[$,q]=S.useState(null),[U,V]=S.useState(!0),[X,se]=S.useState(""),{data:te,isLoading:Y}=Ct({queryKey:["admin-events"],queryFn:async()=>{const{data:ke,error:ot}=await G.from("events").select("*").order("event_date",{ascending:!0});if(ot)throw ot;return ke}}),{data:de}=Ct({queryKey:["event-registrations-count"],queryFn:async()=>{const{data:ke,error:ot}=await G.from("event_registrations").select("event_id");if(ot)throw ot;const qe={};return ke.forEach(lt=>{qe[lt.event_id]=(qe[lt.event_id]||0)+1}),qe}}),{data:ie,isLoading:ae}=Ct({queryKey:["event-registrations-details",N==null?void 0:N.id],queryFn:async()=>{if(!N)return[];const{data:ke,error:ot}=await G.from("event_registrations").select("id, user_id, registered_at, zoom_join_url, zoom_name, zoom_email").eq("event_id",N.id).order("registered_at",{ascending:!1});if(ot)throw ot;if(!ke||ke.length===0)return[];const qe=ke.map(Ye=>Ye.user_id).filter(Boolean);let lt=[];if(qe.length>0){const{data:Ye,error:mt}=await G.from("profiles").select("id, name, email").in("id",qe);if(mt)throw mt;lt=Ye||[]}const We=new Map((lt==null?void 0:lt.map(Ye=>[Ye.id,Ye]))||[]);return ke.map(Ye=>({...Ye,profiles:Ye.user_id&&We.get(Ye.user_id)||null}))},enabled:!!N}),{data:le,isLoading:pe}=Ct({queryKey:["event-attendees-details",N==null?void 0:N.id],queryFn:async()=>{if(!N)return[];const{data:ke,error:ot}=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",N.id).order("created_at",{ascending:!1});if(ot)throw ot;if(!ke||ke.length===0)return[];const qe=ke.map(Ze=>Ze.user_id).filter(Boolean);let lt=[];if(qe.length>0){const{data:Ze,error:He}=await G.from("profiles").select("id, name, email").in("id",qe);if(He)throw He;lt=Ze||[]}const{data:We}=await G.from("agent_points").select("user_id").eq("event_id",N.id),Ye=new Set((We==null?void 0:We.map(Ze=>Ze.user_id))||[]),mt=new Map((lt==null?void 0:lt.map(Ze=>[Ze.id,Ze]))||[]);return ke.map(Ze=>({...Ze,profiles:Ze.user_id&&mt.get(Ze.user_id)||null,points_awarded:Ze.user_id?Ye.has(Ze.user_id):!1}))},enabled:!!N}),be=ke=>{C(ke),w(!0)},ye=Ot({mutationFn:async ke=>{const{data:{session:ot}}=await G.auth.getSession();if(!ot)throw new Error("Not authenticated");const qe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-registrations",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ot.access_token}`},body:JSON.stringify({event_id:ke})}),lt=await qe.json();if(!qe.ok)throw new Error(lt.error||"Failed to sync");return lt},onSuccess:ke=>{s.invalidateQueries({queryKey:["event-registrations-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-registrations-count"]}),fe.success(ke.message)},onError:ke=>{fe.error("Failed to sync: "+ke.message)}}),we=Ot({mutationFn:async ke=>{const{data:{session:ot}}=await G.auth.getSession();if(!ot)throw new Error("Not authenticated");const qe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-attendees",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ot.access_token}`},body:JSON.stringify({event_id:ke})}),lt=await qe.json();if(!qe.ok)throw new Error(lt.error||"Failed to sync attendees");return lt},onSuccess:ke=>{s.invalidateQueries({queryKey:["event-attendees-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]}),ke!=null&&ke.message?fe.success(ke.message):fe.success(`Synced ${ke.synced||0} attendees. ${ke.points_awarded||0} points awarded!`)},onError:ke=>{fe.error("Failed to sync attendees: "+ke.message)}}),Ne=Ot({mutationFn:async({eventId:ke,testMode:ot})=>{const{data:{session:qe}}=await G.auth.getSession();if(!qe)throw new Error("Not authenticated");const lt=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-event-reminder",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${qe.access_token}`},body:JSON.stringify({event_id:ke,test_mode:ot})}),We=await lt.json();if(!lt.ok)throw new Error(We.error||"Failed to send reminders");return We},onSuccess:ke=>{ke.test?fe.success(ke.message||"Test email sent!"):fe.success(ke.message||`Reminder emails sent to ${ke.sent} registrants!`)},onError:ke=>{fe.error("Failed to send reminders: "+ke.message)}}),{data:Ke}=Ct({queryKey:["all-profiles-for-linking"],queryFn:async()=>{let ke=[],ot=0;const qe=1e3;for(;;){const{data:lt,error:We}=await G.from("profiles").select("id, name, email").order("name",{ascending:!0}).range(ot,ot+qe-1);if(We)throw We;if(!lt||lt.length===0||(ke=[...ke,...lt],lt.length{const{error:We}=await G.from("event_attendees").update({user_id:ot}).eq("id",ke);if(We)throw We;if(lt&&qe){const{error:mt}=await G.from("zoom_email_aliases").upsert({user_id:ot,zoom_email:qe.toLowerCase()},{onConflict:"zoom_email"});mt&&console.error("Failed to save alias:",mt)}const Ye=N==null?void 0:N.id;if(Ye){const{data:mt}=await G.from("user_roles").select("id").eq("user_id",ot).eq("role","admin").single();if(!mt){const{data:Ze}=await G.from("agent_points").select("id").eq("user_id",ot).eq("event_id",Ye).single();Ze||(await G.rpc("award_attendance_points",{p_user_id:ot,p_event_id:Ye,p_points:10,p_reason:"Event Attendance (Manual Link)"}),await G.rpc("check_and_award_badges",{p_user_id:ot}))}}return{userId:ot,zoomEmail:qe,shouldSaveAlias:lt}},onSuccess:ke=>{s.invalidateQueries({queryKey:["event-attendees-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]});let ot="Attendee linked and points awarded!";ke.shouldSaveAlias&&ke.zoomEmail&&(ot+=` Email "${ke.zoomEmail}" will be auto-matched in the future.`),fe.success(ot),I(!1),R(null),q(null),se("")},onError:ke=>{fe.error("Failed to link attendee: "+ke.message)}}),Me=ke=>{R(ke),q(null),V(!0),se(""),I(!0)},Te=()=>{!L||!$||_e.mutate({attendeeId:L.id,userId:$,zoomEmail:L.zoom_email,shouldSaveAlias:U})},Fe=(Ke==null?void 0:Ke.filter(ke=>{var qe,lt;if(!X)return!0;const ot=X.toLowerCase();return((qe=ke.name)==null?void 0:qe.toLowerCase().includes(ot))||((lt=ke.email)==null?void 0:lt.toLowerCase().includes(ot))}))||[],Ae=async ke=>{const ot=ke.name.split(".").pop(),lt=`${`${crypto.randomUUID()}.${ot}`}`,{error:We}=await G.storage.from("event-images").upload(lt,ke);if(We)throw We;const{data:{publicUrl:Ye}}=G.storage.from("event-images").getPublicUrl(lt);return Ye},Ue=ke=>{var qe;const ot=(qe=ke.target.files)==null?void 0:qe[0];if(ot){if(ot.size>5*1024*1024){fe.error("Image must be less than 5MB");return}u(ot),g(URL.createObjectURL(ot))}},ut=()=>{u(null),g(null),i({...l,image_url:""}),b.current&&(b.current.value="")},De=Ot({mutationFn:async ke=>{_(!0);let ot=ke.image_url;d&&(ot=await Ae(d)||"");const qe=new Date(ke.event_date),[lt,We]=ke.event_time.split(":");qe.setHours(parseInt(lt),parseInt(We));const Ye=[new Date(qe)];if(ke.is_recurring&&ke.recurrence_end_date){let et=new Date(qe);for(;ke.recurrence_pattern==="weekly"?et=Nk(et,1):ke.recurrence_pattern==="biweekly"?et=Nk(et,2):et=Vh(et,1),!(et>ke.recurrence_end_date);)Ye.push(new Date(et))}const mt=Ye.map(et=>({title:ke.title,description:ke.description||null,image_url:ot||null,video_url:ke.video_url||null,event_date:et.toISOString(),zoom_link:ke.zoom_link,zoom_meeting_id:ke.zoom_meeting_id||null,capacity:ke.capacity?parseInt(ke.capacity):null,is_published:ke.is_published})),{data:Ze,error:He}=await G.from("events").insert(mt).select();if(He)throw He;return Ze&&Ze.length>0&&W8t(ke.title,Ze[0].id),Ye.length},onSuccess:ke=>{s.invalidateQueries({queryKey:["admin-events"]}),fe.success(ke>1?`${ke} recurring events created successfully`:"Event created successfully"),n(!1),i(nR),u(null),g(null),_(!1)},onError:ke=>{fe.error("Failed to create event: "+ke.message),_(!1)}}),Dt=Ot({mutationFn:async({id:ke,data:ot})=>{_(!0);let qe=ot.image_url;d&&(qe=await Ae(d)||"");const lt=new Date(ot.event_date),[We,Ye]=ot.event_time.split(":");lt.setHours(parseInt(We),parseInt(Ye));const{error:mt}=await G.from("events").update({title:ot.title,description:ot.description||null,image_url:qe||null,video_url:ot.video_url||null,event_date:lt.toISOString(),zoom_link:ot.zoom_link,zoom_meeting_id:ot.zoom_meeting_id||null,capacity:ot.capacity?parseInt(ot.capacity):null,is_published:ot.is_published}).eq("id",ke);if(mt)throw mt},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),fe.success("Event updated successfully"),n(!1),o(null),i(nR),u(null),g(null),_(!1)},onError:ke=>{fe.error("Failed to update event: "+ke.message),_(!1)}}),he=Ot({mutationFn:async ke=>{const{error:ot}=await G.from("events").delete().eq("id",ke);if(ot)throw ot},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),fe.success("Event deleted successfully")},onError:ke=>{fe.error("Failed to delete event: "+ke.message)}}),Ve=ke=>{var qe;const ot=new Date(ke.event_date);o(ke),i({title:ke.title,description:ke.description||"",image_url:ke.image_url||"",video_url:ke.video_url||"",event_date:ot,event_time:ws(ot,"HH:mm"),zoom_link:ke.zoom_link,zoom_meeting_id:ke.zoom_meeting_id||"",capacity:((qe=ke.capacity)==null?void 0:qe.toString())||"",is_published:ke.is_published,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0}),g(ke.image_url||null),u(null),n(!0)},nt=ke=>{if(ke.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?Dt.mutate({id:a.id,data:l}):De.mutate(l)},Qe=()=>{n(!1),o(null),i(nR),u(null),g(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(Ka,{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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{children:"All Events"}),e.jsxs(vs,{open:r,onOpenChange:ke=>!ke&&Qe(),children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Event"]})}),e.jsxs(ys,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:a?"Edit Event":"Create New Event"})}),e.jsxs("form",{onSubmit:nt,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:ke=>i({...l,title:ke.target.value}),placeholder:"Event title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Zg,{content:l.description,onChange:ke=>i({...l,description:ke}),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 ke;return(ke=b.current)==null?void 0:ke.click()},children:[e.jsx(Xa,{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(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Et("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?ws(l.event_date,"PPP"):"Pick a date"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(vp,{mode:"single",selected:l.event_date,onSelect:ke=>i({...l,event_date:ke}),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:ke=>i({...l,event_time:ke.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:ke=>i({...l,zoom_link:ke.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:ke=>i({...l,zoom_meeting_id:ke.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:ke=>i({...l,video_url:ke.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:ke=>i({...l,capacity:ke.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(bP,{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:ke=>i({...l,is_recurring:ke})})]}),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(tr,{value:l.recurrence_pattern,onValueChange:ke=>i({...l,recurrence_pattern:ke}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{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(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Et("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?ws(l.recurrence_end_date,"PPP"):"Pick end date"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(vp,{mode:"single",selected:l.recurrence_end_date,onSelect:ke=>i({...l,recurrence_end_date:ke}),disabled:ke=>ke<(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 ke=1,ot=new Date(l.event_date);for(;ot=l.recurrence_pattern==="weekly"?Nk(ot,1):l.recurrence_pattern==="biweekly"?Nk(ot,2):Vh(ot,1),!(ot>l.recurrence_end_date);)ke++;return ke})()," 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:ke=>i({...l,is_published:ke})})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:Qe,className:"flex-1",children:"Cancel"}),e.jsx(K,{type:"submit",className:"flex-1",disabled:De.isPending||Dt.isPending||v,children:v?"Uploading...":a?"Update Event":l.is_recurring&&l.event_date&&l.recurrence_end_date?"Create Recurring Events":"Create Event"})]})]})]})]})]}),e.jsx(Oe,{children:Y?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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Date & Time"}),e.jsx(jt,{children:"Registrations"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:te==null?void 0:te.map(ke=>e.jsxs(js,{children:[e.jsx(it,{className:"font-medium",children:ke.title}),e.jsx(it,{children:ws(new Date(ke.event_date),"PPP p")}),e.jsx(it,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>be(ke),children:[e.jsx(hr,{className:"h-4 w-4"}),(de==null?void 0:de[ke.id])||0,ke.capacity&&` / ${ke.capacity}`]})}),e.jsx(it,{children:e.jsx("span",{className:Et("px-2 py-1 rounded-full text-xs font-medium",ke.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:ke.is_published?"Published":"Draft"})}),e.jsx(it,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(ke.zoom_link,"_blank"),title:"Open Zoom Link",children:e.jsx(rn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ve(ke),children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this event?")&&he.mutate(ke.id)},children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},ke.id))})]})})]}),e.jsx(vs,{open:j,onOpenChange:w,children:e.jsxs(ys,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),N==null?void 0:N.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:N.id,testMode:!0}),disabled:Ne.isPending,children:[e.jsx(br,{className:Et("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:N.id}),disabled:Ne.isPending||!(ie!=null&&ie.length),children:[e.jsx(br,{className:Et("h-4 w-4 mr-2",Ne.isPending&&"animate-spin")}),Ne.isPending?"Sending...":"Send Reminder to All"]}),(N==null?void 0:N.zoom_meeting_id)&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ye.mutate(N.id),disabled:ye.isPending,children:[e.jsx(Eo,{className:Et("h-4 w-4 mr-2",ye.isPending&&"animate-spin")}),ye.isPending?"Syncing...":"Sync Registrations"]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>we.mutate(N.id),disabled:we.isPending,children:[e.jsx(Gi,{className:Et("h-4 w-4 mr-2",we.isPending&&"animate-spin")}),we.isPending?"Syncing...":"Sync Attendees & Award Points"]})]})]}),e.jsxs(ja,{defaultValue:"registrations",className:"w-full",children:[e.jsxs(va,{className:"grid w-full grid-cols-2",children:[e.jsxs(Ns,{value:"registrations",className:"gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Registrations (",(ie==null?void 0:ie.length)||0,")"]}),e.jsxs(Ns,{value:"attendees",className:"gap-2",children:[e.jsx(la,{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..."}):(ie==null?void 0:ie.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No registrations yet for this event."}),(N==null?void 0:N.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Registrations" to import from Zoom.'})]}):e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Registered"}),e.jsx(jt,{children:"Status"})]})}),e.jsx(En,{children:ie==null?void 0:ie.map(ke=>{var We,Ye;const ot=((We=ke.profiles)==null?void 0:We.name)||ke.zoom_name||"Unknown",qe=((Ye=ke.profiles)==null?void 0:Ye.email)||ke.zoom_email||null,lt=!ke.user_id;return e.jsxs(js,{children:[e.jsx(it,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ot,lt&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"External"})]})}),e.jsx(it,{children:qe?e.jsxs("a",{href:`mailto:${qe}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(br,{className:"h-3 w-3"}),qe]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(it,{className:"text-muted-foreground text-sm",children:ws(new Date(ke.registered_at),"MMM d, yyyy h:mm a")}),e.jsx(it,{children:ke.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"})})]},ke.id)})})]})}),e.jsx(zs,{value:"attendees",className:"mt-4",children:pe?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."}),(N==null?void 0:N.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(ke=>!ke.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(Qo,{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(ke=>!ke.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(ke=>!ke.user_id).map(ke=>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:ke.zoom_name||"Unknown"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ke.zoom_email||"No email"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Me(ke),className:"gap-1",children:[e.jsx(Ho,{className:"h-3 w-3"}),"Link to Profile"]})]},ke.id))})]}),e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Duration"}),e.jsx(jt,{children:"Points"})]})}),e.jsx(En,{children:le==null?void 0:le.filter(ke=>ke.user_id).map(ke=>{var lt,We;const ot=((lt=ke.profiles)==null?void 0:lt.name)||ke.zoom_name||"Unknown",qe=((We=ke.profiles)==null?void 0:We.email)||ke.zoom_email||null;return e.jsxs(js,{children:[e.jsx(it,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ot,ke.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(it,{children:qe?e.jsxs("a",{href:`mailto:${qe}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(br,{className:"h-3 w-3"}),qe]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(it,{children:ke.duration_minutes?e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-sm",children:[e.jsx(In,{className:"h-3 w-3"}),ke.duration_minutes," min"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(it,{children:ke.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(Gi,{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"})})]},ke.id)})})]})]})})]})]})}),e.jsx(vs,{open:A,onOpenChange:I,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Ho,{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(xn,{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:X,onChange:ke=>se(ke.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(ke=>e.jsxs("button",{type:"button",onClick:()=>q(ke.id),className:Et("w-full p-3 text-left hover:bg-muted/50 transition-colors",$===ke.id&&"bg-primary/10 border-l-2 border-primary"),children:[e.jsx("p",{className:"text-sm font-medium",children:ke.name||"Unnamed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ke.email})]},ke.id))})}),L.zoom_email&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(zo,{id:"save-alias",checked:U,onCheckedChange:ke=>V(ke)}),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:!$||_e.isPending,children:_e.isPending?"Linking...":"Link & Award Points"})]})]})]})})]})})}function Y8t({selectedKitIds:t,onChange:s}){const[r,n]=S.useState(""),[a,o]=S.useState(!1),{data:l=[]}=Ct({queryKey:["all-resource-kits-picker"],queryFn:async()=>{const{data:g,error:v}=await G.from("resource_kits").select("id, name, featured_image_url").eq("is_published",!0).order("name");if(v)throw v;return g}}),i=l.filter(g=>t.includes(g.id)),d=l.filter(g=>!t.includes(g.id)&&g.name.toLowerCase().includes(r.toLowerCase())),u=g=>{s([...t,g])},p=g=>{s(t.filter(v=>v!==g))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(cl,{className:"h-4 w-4"}),"Linked Toolkits"]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(g=>e.jsxs(at,{variant:"secondary",className:"gap-1 pr-1",children:[g.name,e.jsx("button",{type:"button",onClick:()=>p(g.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Ur,{className:"h-3 w-3"})})]},g.id))}),e.jsxs(No,{open:a,onOpenChange:o,children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(cl,{className:"h-3.5 w-3.5"}),"Add Toolkit"]})}),e.jsxs(jo,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(xn,{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:g=>n(g.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(g=>e.jsxs("button",{type:"button",onClick:()=>{u(g.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:[g.featured_image_url?e.jsx("img",{src:g.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(cl,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("span",{className:"truncate",children:g.name})]},g.id))})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link toolkits that agents can download alongside this template."})]})}const X8t=()=>{const{user:t}=Gs(),{toast:s}=Ea(),r=ns(),[n,a]=Ac(),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.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:""}),[g,v]=S.useState(null),[_,b]=S.useState(0),[j,w]=S.useState(!1),[N,C]=S.useState(null),[A,I]=S.useState(""),[L,R]=S.useState([]),[$,q]=S.useState(""),[U,V]=S.useState(""),[X,se]=S.useState(!1),[te,Y]=S.useState(!1),{data:de=[]}=Ct({queryKey:["template-categories"],queryFn:async()=>{const{data:Ve,error:nt}=await G.from("template_categories").select("*").order("name");if(nt)throw nt;return Ve}}),{data:ie=[]}=Ct({queryKey:["template-types"],queryFn:async()=>{const{data:Ve,error:nt}=await G.from("template_types").select("*").order("name");if(nt)throw nt;return Ve}}),{data:ae=[],isLoading:le}=Ct({queryKey:["canva-templates-admin"],queryFn:async()=>{const{data:Ve,error:nt}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(nt)throw nt;const{data:Qe,error:ke}=await G.from("template_links").select("*").order("sort_order");if(ke)throw ke;const{data:ot,error:qe}=await G.from("template_guides").select("*").order("sort_order");if(qe)throw qe;return Ve.map(We=>({...We,links:(Qe==null?void 0:Qe.filter(Ye=>Ye.template_id===We.id))||[],guides:(ot==null?void 0:ot.filter(Ye=>Ye.template_id===We.id))||[]}))}});S.useEffect(()=>{const Ve=n.get("edit");if(Ve&&ae.length>0){const nt=ae.find(Qe=>Qe.id===Ve);nt&&(Ke(nt),a({},{replace:!0}))}},[ae,n]);const pe=Ot({mutationFn:async Ve=>{const{data:nt,error:Qe}=await G.from("template_categories").insert({name:Ve}).select().single();if(Qe)throw Qe;return nt},onSuccess:Ve=>{r.invalidateQueries({queryKey:["template-categories"]}),p({...u,category_id:Ve.id}),q(""),se(!1),s({title:"Category added"})},onError:Ve=>{s({title:"Error adding category",description:Ve.message,variant:"destructive"})}}),be=Ot({mutationFn:async Ve=>{const{data:nt,error:Qe}=await G.from("template_types").insert({name:Ve}).select().single();if(Qe)throw Qe;return nt},onSuccess:Ve=>{r.invalidateQueries({queryKey:["template-types"]}),p({...u,type_id:Ve.id}),V(""),Y(!1),s({title:"Type added"})},onError:Ve=>{s({title:"Error adding type",description:Ve.message,variant:"destructive"})}}),ye=Ot({mutationFn:async Ve=>{var qe;let nt=Ve.existingImageUrl;if(Ve.image){const lt=Ve.image.name.split(".").pop(),We=`${Date.now()}-${Math.random().toString(36).substring(7)}.${lt}`,{error:Ye}=await G.storage.from("template-previews").upload(We,Ve.image);if(Ye)throw Ye;const{data:mt}=G.storage.from("template-previews").getPublicUrl(We);nt=mt.publicUrl}const Qe={name:Ve.template.name,description:Ve.template.description||null,category_id:Ve.template.category_id||null,type_id:Ve.template.type_id||null,preview_image_url:nt,video_url:Ve.videoUrl||null,publish_date:Ve.template.publish_date?new Date(Ve.template.publish_date).toISOString():new Date().toISOString(),created_by:t==null?void 0:t.id};let ke=Ve.templateId;if(ke){const{error:lt}=await G.from("canva_templates").update(Qe).eq("id",ke);if(lt)throw lt;const{error:We}=await G.from("template_links").delete().eq("template_id",ke);if(We)throw We;const Ye=((qe=Ve.existingGuides)==null?void 0:qe.map(He=>He.id).filter(Boolean))||[],mt=Ve.template.guides.map(He=>He.id).filter(Boolean),Ze=Ye.filter(He=>!mt.includes(He));Ze.length>0&&await G.from("template_guides").delete().in("id",Ze)}else{const{data:lt,error:We}=await G.from("canva_templates").insert(Qe).select().single();if(We)throw We;ke=lt.id,V8t(Ve.template.name,lt.id)}const ot=Ve.template.links.filter(lt=>lt.title.trim()&<.canva_share_link.trim());if(ot.length>0){const lt=ot.map((Ye,mt)=>({template_id:ke,title:Ye.title.trim(),canva_share_link:Ye.canva_share_link.trim(),sort_order:mt})),{error:We}=await G.from("template_links").insert(lt);if(We)throw We}for(let lt=0;lt0)){const{error:lt}=await G.from("resource_kit_templates").insert(Ve.linkedKitIds.map(We=>({template_id:ke,kit_id:We})));if(lt)throw lt}},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),Ne(),l(!1),s({title:i?"Template updated":"Template created"})},onError:Ve=>{s({title:"Error saving template",description:Ve.message,variant:"destructive"})}}),we=Ot({mutationFn:async Ve=>{const{error:nt}=await G.from("canva_templates").delete().eq("id",Ve);if(nt)throw nt},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),s({title:"Template deleted"})},onError:Ve=>{s({title:"Error deleting template",description:Ve.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:""}),C(null),I(""),d(null),se(!1),Y(!1),q(""),V(""),v(null),b(0),w(!1),R([])},Ke=async Ve=>{var Qe;d(Ve),p({name:Ve.name,description:Ve.description||"",category_id:Ve.category_id||"",type_id:Ve.type_id||"",publish_date:Ve.publish_date?new Date(Ve.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],links:Ve.links&&Ve.links.length>0?Ve.links.map(ke=>({id:ke.id,title:ke.title,canva_share_link:ke.canva_share_link,sort_order:ke.sort_order})):[{title:"",canva_share_link:"",sort_order:0}],guides:((Qe=Ve.guides)==null?void 0:Qe.map(ke=>({id:ke.id,name:ke.name,file_url:ke.file_url,file_type:ke.file_type,file_size:ke.file_size,sort_order:ke.sort_order})))||[],video_url:Ve.video_url||""}),I(Ve.preview_image_url||""),v(null);const{data:nt}=await G.from("resource_kit_templates").select("kit_id").eq("template_id",Ve.id);R((nt||[]).map(ke=>ke.kit_id)),l(!0)},_e=Ve=>{var Qe;const nt=(Qe=Ve.target.files)==null?void 0:Qe[0];nt&&(C(nt),I(URL.createObjectURL(nt)))},Me=()=>{p({...u,links:[...u.links,{title:"",canva_share_link:"",sort_order:u.links.length}]})},Te=Ve=>{if(u.links.length<=1)return;const nt=u.links.filter((Qe,ke)=>ke!==Ve);p({...u,links:nt})},Fe=(Ve,nt,Qe)=>{const ke=[...u.links];ke[Ve]={...ke[Ve],[nt]:Qe},p({...u,links:ke})},Ae=Ve=>{const nt=Ve.target.files;if(!nt)return;const Qe=Array.from(nt).map((ke,ot)=>({name:ke.name.replace(/\.[^/.]+$/,""),file_url:"",file_type:ke.type,file_size:ke.size,sort_order:u.guides.length+ot,file:ke}));p({...u,guides:[...u.guides,...Qe]}),Ve.target.value=""},Ue=Ve=>{const nt=u.guides.filter((Qe,ke)=>ke!==Ve);p({...u,guides:nt})},ut=(Ve,nt)=>{const Qe=[...u.guides];Qe[Ve]={...Qe[Ve],name:nt},p({...u,guides:Qe})},De=async()=>{if(!g)return null;w(!0),b(0);try{const{data:Ve,error:nt}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:u.name||g.name}});if(nt)throw new Error(nt.message);const{videoId:Qe,libraryId:ke}=Ve,{data:ot,error:qe}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Qe}});if(qe)throw new Error(qe.message);const lt=new XMLHttpRequest;return await new Promise((Ye,mt)=>{lt.upload.addEventListener("progress",Ze=>{if(Ze.lengthComputable){const He=Math.round(Ze.loaded/Ze.total*100);b(He)}}),lt.addEventListener("load",()=>{lt.status>=200&<.status<300?Ye():mt(new Error(`Upload failed with status ${lt.status}`))}),lt.addEventListener("error",()=>mt(new Error("Upload failed"))),lt.open("PUT",ot.uploadUrl),lt.setRequestHeader("AccessKey",ot.apiKey),lt.send(g)}),`https://player.mediadelivery.net/embed/${ke}/${Qe}`}catch(Ve){return console.error("Bunny upload error:",Ve),s({title:"Video upload failed",description:Ve instanceof Error?Ve.message:"Unknown error",variant:"destructive"}),null}finally{w(!1)}},Dt=Ve=>{var Qe;const nt=(Qe=Ve.target.files)==null?void 0:Qe[0];nt&&v(nt),Ve.target.value=""},he=async Ve=>{if(Ve.preventDefault(),!u.name.trim()){s({title:"Please enter a template name",variant:"destructive"});return}if(u.links.filter(ke=>ke.title.trim()&&ke.canva_share_link.trim()).length===0){s({title:"Please add at least one Canva link",variant:"destructive"});return}let Qe=u.video_url;if(g){const ke=await De();if(!ke)return;Qe=ke}ye.mutate({template:u,image:N,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:Qe,linkedKitIds:L})};return e.jsx(Ms,{title:"Manage Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Template Types"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ie.length})})]})]}),e.jsxs(vs,{open:o,onOpenChange:Ve=>{l(Ve),Ve||Ne()},children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Template"]})}),e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:i?"Edit Template":"Add New Template"})}),e.jsxs("form",{onSubmit:he,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:Ve=>p({...u,name:Ve.target.value}),placeholder:"Template name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Zg,{content:u.description,onChange:Ve=>p({...u,description:Ve}),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((Ve,nt)=>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:Ve.title,onChange:Qe=>Fe(nt,"title",Qe.target.value),placeholder:"Link title (e.g., Instagram Post, Story)"}),e.jsx(Re,{value:Ve.canva_share_link,onChange:Qe=>Fe(nt,"canva_share_link",Qe.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(nt),children:e.jsx(Ur,{className:"h-4 w-4"})})]},nt))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Category"}),X?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:$,onChange:Ve=>q(Ve.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>$.trim()&&pe.mutate($.trim()),disabled:pe.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(tr,{value:u.category_id,onValueChange:Ve=>p({...u,category_id:Ve}),children:[e.jsx(Js,{className:"flex-1",children:e.jsx(sr,{placeholder:"Select category"})}),e.jsx(er,{children:de.map(Ve=>e.jsx(At,{value:Ve.id,children:Ve.name},Ve.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:Ve=>V(Ve.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:()=>{Y(!1),V("")},children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(tr,{value:u.type_id,onValueChange:Ve=>p({...u,type_id:Ve}),children:[e.jsx(Js,{className:"flex-1",children:e.jsx(sr,{placeholder:"Select type"})}),e.jsx(er,{children:ie.map(Ve=>e.jsx(At,{value:Ve.id,children:Ve.name},Ve.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>Y(!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:Ve=>p({...u,publish_date:Ve.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:[A?e.jsxs("div",{className:"relative w-32 h-24 rounded-lg overflow-hidden border bg-muted",children:[e.jsx("img",{src:A,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:()=>{C(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:_e,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&&!g?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})})]}):j?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(As,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm",children:["Uploading video... ",_,"%"]})]}),e.jsx(Mi,{value:_,className:"h-2"})]}):g?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:g.name}),e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(g.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:()=>v(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:Dt,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(Xa,{className:"h-3 w-3"}),"Add Files"]})})]})]}),u.guides.length>0?e.jsx("div",{className:"space-y-2",children:u.guides.map((Ve,nt)=>e.jsxs("div",{className:"flex gap-2 items-center p-3 border rounded-lg bg-muted/30",children:[e.jsx(Sn,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx(Re,{value:Ve.name,onChange:Qe=>ut(nt,Qe.target.value),placeholder:"Guide name",className:"flex-1"}),Ve.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(Ve.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(nt),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Ve.id||nt))}):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(Y8t,{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:ye.isPending,children:ye.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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Preview"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Links"}),e.jsx(jt,{children:"Category"}),e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:ae.map(Ve=>{var nt,Qe,ke,ot,qe;return e.jsxs(js,{children:[e.jsx(it,{children:e.jsx("div",{className:"w-16 h-12 rounded overflow-hidden bg-muted",children:Ve.preview_image_url?e.jsx("img",{src:Ve.preview_image_url,alt:Ve.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(it,{className:"font-medium",children:Ve.name}),e.jsx(it,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs(at,{variant:"secondary",children:[((nt=Ve.links)==null?void 0:nt.length)||0," link",(((Qe=Ve.links)==null?void 0:Qe.length)||0)!==1?"s":""]}),(((ke=Ve.guides)==null?void 0:ke.length)||0)>0&&e.jsxs(at,{variant:"outline",className:"gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"}),(ot=Ve.guides)==null?void 0:ot.length," guide",(((qe=Ve.guides)==null?void 0:qe.length)||0)!==1?"s":""]})]})}),e.jsx(it,{children:Ve.category?e.jsx(at,{variant:"secondary",children:Ve.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(it,{children:Ve.type?e.jsx(at,{variant:"outline",children:Ve.type.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(it,{className:"text-muted-foreground",children:new Date(Ve.publish_date).toLocaleDateString()}),e.jsx(it,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"icon",variant:"ghost",onClick:()=>Ke(Ve),children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&we.mutate(Ve.id)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},Ve.id)})})]})})})]})})};function bKe({selectedTemplateIds:t,onChange:s}){const[r,n]=S.useState(""),[a,o]=S.useState(!1),{data:l=[]}=Ct({queryKey:["all-canva-templates-picker"],queryFn:async()=>{const{data:g,error:v}=await G.from("canva_templates").select("id, name, preview_image_url").order("name");if(v)throw v;return g}}),i=l.filter(g=>t.includes(g.id)),d=l.filter(g=>!t.includes(g.id)&&g.name.toLowerCase().includes(r.toLowerCase())),u=g=>{s([...t,g])},p=g=>{s(t.filter(v=>v!==g))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{className:"flex items-center gap-2",children:[e.jsx(rN,{className:"h-4 w-4"}),"Linked Templates"]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(g=>e.jsxs(at,{variant:"secondary",className:"gap-1 pr-1",children:[g.name,e.jsx("button",{type:"button",onClick:()=>p(g.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Ur,{className:"h-3 w-3"})})]},g.id))}),e.jsxs(No,{open:a,onOpenChange:o,children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(rN,{className:"h-3.5 w-3.5"}),"Add Template"]})}),e.jsxs(jo,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(xn,{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:g=>n(g.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(g=>e.jsxs("button",{type:"button",onClick:()=>{u(g.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:[g.preview_image_url?e.jsx("img",{src:g.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(rN,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("span",{className:"truncate",children:g.name})]},g.id))})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link templates that agents can use alongside this content."})]})}const Q8t=[{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"}],J8t=()=>{const{user:t}=Gs(),[s,r]=Ac(),{toast:n}=Ea(),a=ns(),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState({title:"",description:"",video_url:"",video_type:"youtube",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[g,v]=S.useState(null),[_,b]=S.useState(""),[j,w]=S.useState([]),[N,C]=S.useState([]),[A,I]=S.useState([]),[L,R]=S.useState([]),[$,q]=S.useState(""),[U,V]=S.useState(!1),[X,se]=S.useState(null),[te,Y]=S.useState(0),[de,ie]=S.useState(!1),[ae,le]=S.useState(null),{data:pe=[]}=Ct({queryKey:["academy-categories"],queryFn:async()=>{const{data:he,error:Ve}=await G.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(Ve)throw Ve;return he}}),{data:be=[],isLoading:ye}=Ct({queryKey:["academy-videos-admin"],queryFn:async()=>{const{data:he,error:Ve}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).order("publish_date",{ascending:!1});if(Ve)throw Ve;const{data:nt,error:Qe}=await G.from("academy_resources").select("*").order("sort_order");if(Qe)throw Qe;return he.map(ot=>({...ot,resources:(nt==null?void 0:nt.filter(qe=>qe.video_id===ot.id))||[]}))}});S.useEffect(()=>{const he=s.get("edit");if(he&&be.length>0){const Ve=be.find(nt=>nt.id===he);Ve&&(Te(Ve),r({},{replace:!0}))}},[be,s]);const we=Ot({mutationFn:async he=>{const{data:Ve,error:nt}=await G.from("academy_categories").insert({name:he,sort_order:pe.length}).select().single();if(nt)throw nt;return Ve},onSuccess:he=>{a.invalidateQueries({queryKey:["academy-categories"]}),p({...u,category_id:he.id}),q(""),V(!1),n({title:"Category added"})},onError:he=>{n({title:"Error adding category",description:he.message,variant:"destructive"})}}),Ne=Ot({mutationFn:async he=>{let Ve=he.existingThumbnailUrl;if(he.thumbnail){const ke=he.thumbnail.name.split(".").pop(),ot=`thumbnails/${Date.now()}-${Math.random().toString(36).substring(7)}.${ke}`,{error:qe}=await G.storage.from("academy-resources").upload(ot,he.thumbnail);if(qe)throw qe;const{data:lt}=G.storage.from("academy-resources").getPublicUrl(ot);Ve=lt.publicUrl}const nt={title:he.video.title,description:he.video.description||null,video_url:he.video.video_url,video_type:he.video.video_type,duration:he.video.duration||null,thumbnail_url:Ve,category_id:he.video.category_id||null,publish_date:he.video.publish_date?new Date(he.video.publish_date).toISOString():new Date().toISOString(),is_published:he.video.is_published,created_by:t==null?void 0:t.id};let Qe=he.videoId;if(Qe){const{error:ke}=await G.from("academy_videos").update(nt).eq("id",Qe);if(ke)throw ke}else{const{data:ke,error:ot}=await G.from("academy_videos").insert(nt).select().single();if(ot)throw ot;Qe=ke.id,H8t(he.video.title,ke.id)}if(he.resourcesToDelete.length>0){const{error:ke}=await G.from("academy_resources").delete().in("id",he.resourcesToDelete);if(ke)throw ke}for(let ke=0;ke0){const{error:ke}=await G.from("academy_video_templates").insert(L.map(ot=>({video_id:Qe,template_id:ot})));if(ke)throw ke}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),Me(),l(!1),n({title:i?"Video updated":"Video created"})},onError:he=>{n({title:"Error saving video",description:he.message,variant:"destructive"})}}),Ke=Ot({mutationFn:async he=>{const{error:Ve}=await G.from("academy_videos").delete().eq("id",he);if(Ve)throw Ve},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),n({title:"Video deleted"})},onError:he=>{n({title:"Error deleting video",description:he.message,variant:"destructive"})}}),_e=Ot({mutationFn:async({id:he,is_published:Ve})=>{const{error:nt}=await G.from("academy_videos").update({is_published:Ve}).eq("id",he);if(nt)throw nt},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]})},onError:he=>{n({title:"Error updating video",description:he.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}),v(null),b(""),w([]),C([]),I([]),d(null),R([]),q(""),se(null),Y(0),ie(!1),le(null)},Te=async he=>{d(he),p({title:he.title,description:he.description||"",video_url:he.video_url,video_type:he.video_type,duration:he.duration||"",category_id:he.category_id||"",publish_date:he.publish_date?new Date(he.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:he.is_published}),b(he.thumbnail_url||""),C(he.resources||[]),w([]),I([]);const{data:Ve}=await G.from("academy_video_templates").select("template_id").eq("video_id",he.id);R((Ve||[]).map(nt=>nt.template_id)),l(!0)},Fe=he=>{var nt;const Ve=(nt=he.target.files)==null?void 0:nt[0];Ve&&(v(Ve),b(URL.createObjectURL(Ve)))},Ae=he=>{const Ve=he.target.files;if(Ve){const nt=Array.from(Ve).map(Qe=>({file:Qe,title:Qe.name.replace(/\.[^/.]+$/,"")}));w([...j,...nt])}he.target.value=""},Ue=he=>{w(j.filter((Ve,nt)=>nt!==he))},ut=he=>{I([...A,he]),C(N.filter(Ve=>Ve.id!==he))},De=async()=>{if(!X)return null;ie(!0),Y(0);try{const{data:he,error:Ve}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:u.title||X.name}});if(Ve)throw new Error(Ve.message);const{videoId:nt,libraryId:Qe}=he;le(nt);const{data:ke,error:ot}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:nt}});if(ot)throw new Error(ot.message);const qe=new XMLHttpRequest;return await new Promise((We,Ye)=>{qe.upload.addEventListener("progress",mt=>{if(mt.lengthComputable){const Ze=Math.round(mt.loaded/mt.total*100);Y(Ze)}}),qe.addEventListener("load",()=>{qe.status>=200&&qe.status<300?We():Ye(new Error(`Upload failed with status ${qe.status}`))}),qe.addEventListener("error",()=>Ye(new Error("Upload failed"))),qe.open("PUT",ke.uploadUrl),qe.setRequestHeader("AccessKey",ke.apiKey),qe.send(X)}),`https://player.mediadelivery.net/embed/${Qe}/${nt}`}catch(he){return console.error("Bunny upload error:",he),n({title:"Video upload failed",description:he instanceof Error?he.message:"Unknown error",variant:"destructive"}),null}finally{ie(!1)}},Dt=async he=>{if(he.preventDefault(),!u.title.trim()){n({title:"Please enter a video title",variant:"destructive"});return}let Ve=u.video_url;if(u.video_type==="bunny_stream"&&X&&!i){const nt=await De();if(!nt)return;Ve=nt}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"&&!X&&!u.video_url&&!i){n({title:"Please select a video file to upload",variant:"destructive"});return}Ne.mutate({video:{...u,video_url:Ve},thumbnail:g,existingThumbnailUrl:(i==null?void 0:i.thumbnail_url)||null,videoId:i==null?void 0:i.id,newResources:j,resourcesToDelete:A})};return e.jsx(Ms,{title:"Manage Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(he=>he.is_published).length})})]})]}),e.jsxs(vs,{open:o,onOpenChange:he=>{l(he),he||Me()},children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Video"]})}),e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:i?"Edit Video":"Add New Video"})}),e.jsxs("form",{onSubmit:Dt,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:he=>p({...u,title:he.target.value}),placeholder:"Video title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Zg,{content:u.description,onChange:he=>p({...u,description:he}),placeholder:"Brief description of the video",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Video Type"}),e.jsxs(tr,{value:u.video_type,onValueChange:he=>{p({...u,video_type:he,video_url:""}),se(null)},disabled:de,children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:Q8t.map(he=>e.jsx(At,{value:he.value,children:he.label},he.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:he=>{var nt;const Ve=(nt=he.target.files)==null?void 0:nt[0];Ve&&se(Ve)},disabled:de}),X&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Nn,{className:"h-4 w-4"}),X.name," (",(X.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(As,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Uploading to Bunny.net..."})]}),e.jsx(Mi,{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:he=>p({...u,video_url:he.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:he=>p({...u,duration:he.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:he=>p({...u,publish_date:he.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:he=>q(he.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>$.trim()&&we.mutate($.trim()),disabled:we.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{V(!1),q("")},children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(tr,{value:u.category_id,onValueChange:he=>p({...u,category_id:he}),children:[e.jsx(Js,{className:"flex-1",children:e.jsx(sr,{placeholder:"Select category"})}),e.jsx(er,{children:pe.map(he=>e.jsx(At,{value:he.id,children:he.name},he.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>V(!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(Xa,{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"})]})})]}),(N.length>0||j.length>0)&&e.jsxs("div",{className:"space-y-2 mt-2",children:[N.map(he=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm truncate",children:he.title}),e.jsx(at,{variant:"outline",className:"text-xs",children:he.file_type}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>ut(he.id),className:"text-destructive hover:text-destructive",children:e.jsx(Ur,{className:"h-4 w-4"})})]},he.id)),j.map((he,Ve)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Re,{value:he.title,onChange:nt=>{const Qe=[...j];Qe[Ve].title=nt.target.value,w(Qe)},className:"flex-1 h-8",placeholder:"Resource title"}),e.jsx(at,{variant:"secondary",className:"text-xs",children:"New"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>Ue(Ve),className:"text-destructive hover:text-destructive",children:e.jsx(Ur,{className:"h-4 w-4"})})]},Ve))]}),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:he=>p({...u,is_published:he})}),e.jsx(ve,{htmlFor:"is_published",children:"Published"})]}),e.jsxs(On,{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(As,{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:ye?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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Category"}),e.jsx(jt,{children:"Duration"}),e.jsx(jt,{children:"Resources"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-[120px]",children:"Actions"})]})}),e.jsx(En,{children:be.map(he=>e.jsxs(js,{children:[e.jsx(it,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[he.thumbnail_url?e.jsx("img",{src:he.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:he.title}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:he.video_type.replace("_"," ")})]})]})}),e.jsx(it,{children:he.category?e.jsx(at,{variant:"outline",children:he.category.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(it,{children:he.duration||"-"}),e.jsx(it,{children:he.resources&&he.resources.length>0?e.jsxs(at,{variant:"secondary",children:[he.resources.length," file(s)"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(it,{children:new Date(he.publish_date).toLocaleDateString()}),e.jsx(it,{children:e.jsx(Br,{checked:he.is_published,onCheckedChange:Ve=>_e.mutate({id:he.id,is_published:Ve})})}),e.jsx(it,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Te(he),children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Ke.mutate(he.id),className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},he.id))})]})})})]})})};function eRt(){var Ne,Ke,_e;const t=ns(),[s,r]=Ac(),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=S.useState(null),[g,v]=S.useState(""),[_,b]=S.useState([]),[j,w]=S.useState([]),[N,C]=S.useState([]),[A,I]=S.useState(null),{data:L,isLoading:R}=Ct({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:$}=Ct({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}=Ct({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}});S.useEffect(()=>{const Me=s.get("edit");if(Me&&L&&L.length>0&&$&&q){const Te=L.find(Fe=>Fe.id===Me);Te&&(V(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),v(""),b([]),w([]),C([]),l(null)},V=async Me=>{l(Me),d({name:Me.name,description:Me.description||"",publish_date:Me.publish_date.split("T")[0],is_published:Me.is_published}),v(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))||[];w(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);C((Ae||[]).map(Ue=>Ue.template_id)),a(!0)},X=Me=>{var Fe;const Te=(Fe=Me.target.files)==null?void 0:Fe[0];Te&&(p(Te),v(URL.createObjectURL(Te)))},se=()=>{b([..._,{name:"",file_url:"",sort_order:_.length}])},te=Me=>{b(_.filter((Te,Fe)=>Fe!==Me))},Y=(Me,Te,Fe)=>{const Ae=[..._];Ae[Me]={...Ae[Me],[Te]:Fe},b(Ae)},de=()=>{w([...j,{title:"",canva_share_link:"",sort_order:j.length}])},ie=Me=>{w(j.filter((Te,Fe)=>Fe!==Me))},ae=(Me,Te,Fe)=>{const Ae=[...j];Ae[Me]={...Ae[Me],[Te]:Fe},w(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)}},pe=Ot({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:Dt}=await G.storage.from("resource-kits").upload(`featured/${De}`,u);if(Dt)throw Dt;const{data:he}=G.storage.from("resource-kits").getPublicUrl(`featured/${De}`);Me=he.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(ke=>ke.kit_id===o.id).map(ke=>ke.id))||[],Dt=_.filter(ke=>ke.id).map(ke=>ke.id),he=De.filter(ke=>!Dt.includes(ke));he.length>0&&await G.from("resource_kit_files").delete().in("id",he);const Ve=(q==null?void 0:q.filter(ke=>ke.kit_id===o.id).map(ke=>ke.id))||[],nt=j.filter(ke=>ke.id).map(ke=>ke.id),Qe=Ve.filter(ke=>!nt.includes(ke));Qe.length>0&&await G.from("resource_kit_links").delete().in("id",Qe)}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 Dt=De.file_url;if(De.file){const he=De.file.name.split(".").pop(),Ve=`${Date.now()}-${ut}.${he}`,{error:nt}=await G.storage.from("resource-kits").upload(`files/${Ve}`,De.file);if(nt)throw nt;const{data:Qe}=G.storage.from("resource-kits").getPublicUrl(`files/${Ve}`);Dt=Qe.publicUrl}De.id?await G.from("resource_kit_files").update({name:De.name,file_url:Dt,file_type:De.file_type,file_size:De.file_size,sort_order:ut}).eq("id",De.id):Dt&&De.name&&await G.from("resource_kit_files").insert({kit_id:Fe,name:De.name,file_url:Dt,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(N.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)&&G8t(Me.kitName,Me.kitId),a(!1),U()},onError:Me=>{fe.error("Failed to save resource kit: "+Me.message)}}),be=Ot({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)}}),ye=Me=>{if(Me.preventDefault(),!i.name){fe.error("Please enter a name");return}pe.mutate()},we=Me=>($==null?void 0:$.filter(Te=>Te.kit_id===Me).length)||0;return e.jsx(Ms,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Files"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:R?e.jsx(js,{children:e.jsx(it,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):(L==null?void 0:L.length)===0?e.jsx(js,{children:e.jsx(it,{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(js,{children:[e.jsx(it,{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(cl,{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(it,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),we(Me.id)]})}),e.jsx(it,{children:ws(new Date(Me.publish_date),"MMM d, yyyy")}),e.jsx(it,{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(it,{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(ya,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>V(Me),children:e.jsx(Ua,{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(vs,{open:n,onOpenChange:a,children:e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:o?"Edit Resource Kit":"Add Resource Kit"})}),e.jsxs("form",{onSubmit:ye,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:[g?e.jsx("img",{src:g,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(cl,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(Re,{type:"file",accept:"image/*",onChange:X})]})]}),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(Zg,{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=>Y(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"]})]}),j.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:j.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:()=>ie(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:N,onChange:C}),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:pe.isPending,children:pe.isPending?"Saving...":o?"Update":"Create"})]})]})]})}),e.jsx(vs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(ys,{className:"max-w-lg",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:A==null?void 0:A.name})}),e.jsxs("div",{className:"space-y-4",children:[(A==null?void 0:A.featured_image_url)&&e.jsx("img",{src:A.featured_image_url,alt:A.name,className:"w-full h-48 object-cover rounded-lg"}),(A==null?void 0:A.description)&&e.jsx("p",{className:"text-muted-foreground",children:A.description}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Resource Files (",((Ne=A==null?void 0:A.files)==null?void 0:Ne.length)||0,")"]}),((Ke=A==null?void 0:A.files)==null?void 0:Ke.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:(_e=A==null?void 0:A.files)==null?void 0:_e.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(Sn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Me.name})]},Me.id))})]}),(A==null?void 0:A.links)&&A.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Canva Links (",A.links.length,")"]}),e.jsx("div",{className:"space-y-2",children:A.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(Io,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Me.title})]},Me.id))})]})]})]})})]})})}const tRt=()=>{const{user:t}=Gs(),{toast:s}=Ea(),r=ns(),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),[u,p]=S.useState(null),[g,v]=S.useState(""),{data:_=[],isLoading:b}=Ct({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:V,error:X}=await G.from("social_swag_links").select("*").order("sort_order");if(X)throw X;return q.map(te=>({...te,links:(V==null?void 0:V.filter(Y=>Y.swag_id===te.id))||[]}))}}),j=Ot({mutationFn:async q=>{let U=q.existingImageUrl;if(q.image){const de=q.image.name.split(".").pop(),ie=`${Date.now()}-${Math.random().toString(36).substring(7)}.${de}`,{error:ae}=await G.storage.from("template-previews").upload(ie,q.image);if(ae)throw ae;const{data:le}=G.storage.from("template-previews").getPublicUrl(ie);U=le.publicUrl}const V={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 X=q.itemId;const se=!X,te=(o==null?void 0:o.is_published)||!1;if(X){const{error:de}=await G.from("social_swag").update(V).eq("id",X);if(de)throw de;await G.from("social_swag_links").delete().eq("swag_id",X)}else{const{data:de,error:ie}=await G.from("social_swag").insert(V).select().single();if(ie)throw ie;X=de.id}const Y=q.item.links.filter(de=>de.title.trim()&&de.canva_share_link.trim());if(Y.length>0){const de=Y.map((ae,le)=>({swag_id:X,title:ae.title.trim(),canva_share_link:ae.canva_share_link.trim(),sort_order:le})),{error:ie}=await G.from("social_swag_links").insert(de);if(ie)throw ie}return{itemId:X,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)&&sye(q.itemTitle,q.itemId),a(!1),N()},onError:q=>{s({title:"Error saving item",description:q.message,variant:"destructive"})}}),w=Ot({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"})}}),N=()=>{d({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),p(null),v(""),l(null)},C=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}]}),v(q.preview_image_url||""),a(!0)},A=q=>{var V;const U=(V=q.target.files)==null?void 0:V[0];U&&(p(U),v(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((V,X)=>X!==q);d({...i,links:U})},R=(q,U,V)=>{const X=[...i.links];X[q]={...X[q],[U]:V},d({...i,links:X})},$=q=>{if(q.preventDefault(),!i.title.trim()){s({title:"Title is required",variant:"destructive"});return}j.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(Ms,{title:"Manage Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(vs,{open:n,onOpenChange:q=>{a(q),q||N()},children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Item"]})}),e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(Zg,{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"}),g?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:g,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),v("")},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:A,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:V=>R(U,"title",V.target.value)}),e.jsx(Re,{placeholder:"Canva share link",value:q.canva_share_link,onChange:V=>R(U,"canva_share_link",V.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:j.isPending,children:j.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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-16",children:"Preview"}),e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Links"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:_.map(q=>{var U;return e.jsxs(js,{children:[e.jsx(it,{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(it,{className:"font-medium",children:q.title}),e.jsxs(it,{children:[((U=q.links)==null?void 0:U.length)||0," links"]}),e.jsx(it,{children:new Date(q.publish_date).toLocaleDateString()}),e.jsx(it,{children:e.jsx(at,{variant:q.is_published?"default":"secondary",children:q.is_published?"Published":"Draft"})}),e.jsx(it,{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(ya,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>C(q),children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this item?")&&w.mutate(q.id)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},q.id)})})]})})})]})})};function sRt(){for(var t=arguments.length,s=new Array(t),r=0;rn=>{s.forEach(a=>a(n))},s)}const _le=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function SM(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function cwe(t){return"nodeType"in t}function Fm(t){var s,r;return t?SM(t)?t:cwe(t)&&(s=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function dwe(t){const{Document:s}=Fm(t);return t instanceof s}function VL(t){return SM(t)?!1:t instanceof Fm(t).HTMLElement}function wKe(t){return t instanceof Fm(t).SVGElement}function CM(t){return t?SM(t)?t.document:cwe(t)?dwe(t)?t:VL(t)||wKe(t)?t.ownerDocument:document:document:document}const oy=_le?S.useLayoutEffect:S.useEffect;function uwe(t){const s=S.useRef(t);return oy(()=>{s.current=t}),S.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a{t.current=setInterval(n,a)},[]),r=S.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,r]}function p6(t,s){s===void 0&&(s=[t]);const r=S.useRef(t);return oy(()=>{r.current!==t&&(r.current=t)},s),r}function HL(t,s){const r=S.useRef();return S.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...s])}function Cae(t){const s=uwe(t),r=S.useRef(null),n=S.useCallback(a=>{a!==r.current&&(s==null||s(a,r.current)),r.current=a},[]);return[r,n]}function rye(t){const s=S.useRef();return S.useEffect(()=>{s.current=t},[t]),s.current}let qme={};function WL(t,s){return S.useMemo(()=>{if(s)return s;const r=qme[t]==null?0:qme[t]+1;return qme[t]=r,t+"-"+r},[t,s])}function jKe(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 D5=jKe(1),f6=jKe(-1);function nRt(t){return"clientX"in t&&"clientY"in t}function hwe(t){if(!t)return!1;const{KeyboardEvent:s}=Fm(t.target);return s&&t instanceof s}function aRt(t){if(!t)return!1;const{TouchEvent:s}=Fm(t.target);return s&&t instanceof s}function nye(t){if(aRt(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 nRt(t)?{x:t.clientX,y:t.clientY}:null}const S3=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[S3.Translate.toString(t),S3.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:r,easing:n}=t;return s+" "+r+"ms "+n}}}),FAe="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function iRt(t){return t.matches(FAe)?t:t.querySelector(FAe)}const oRt={display:"none"};function lRt(t){let{id:s,value:r}=t;return ht.createElement("div",{id:s,style:oRt},r)}function cRt(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 dRt(){const[t,s]=S.useState("");return{announce:S.useCallback(n=>{n!=null&&s(n)},[]),announcement:t}}const kKe=S.createContext(null);function uRt(t){const s=S.useContext(kKe);S.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of ");return s(t)},[t,s])}function hRt(){const[t]=S.useState(()=>new Set),s=S.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[S.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 mRt={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. `},pRt={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 fRt(t){let{announcements:s=pRt,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=mRt}=t;const{announce:o,announcement:l}=dRt(),i=WL("DndLiveRegion"),[d,u]=S.useState(!1);if(S.useEffect(()=>{u(!0)},[]),uRt(S.useMemo(()=>({onDragStart(g){let{active:v}=g;o(s.onDragStart({active:v}))},onDragMove(g){let{active:v,over:_}=g;s.onDragMove&&o(s.onDragMove({active:v,over:_}))},onDragOver(g){let{active:v,over:_}=g;o(s.onDragOver({active:v,over:_}))},onDragEnd(g){let{active:v,over:_}=g;o(s.onDragEnd({active:v,over:_}))},onDragCancel(g){let{active:v,over:_}=g;o(s.onDragCancel({active:v,over:_}))}}),[o,s])),!d)return null;const p=ht.createElement(ht.Fragment,null,ht.createElement(lRt,{id:n,value:a.draggable}),ht.createElement(cRt,{id:i,announcement:l}));return r?_m.createPortal(p,r):p}var Rd;(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"})(Rd||(Rd={}));function Mae(){}function aye(t,s){return S.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function NKe(){for(var t=arguments.length,s=new Array(t),r=0;r[...s].filter(n=>n!=null),[...s])}const Wg=Object.freeze({x:0,y:0});function SKe(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function CKe(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return r-n}function gRt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return n-r}function zAe(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 MKe(t,s){if(!t||t.length===0)return null;const[r]=t;return r[s]}function BAe(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 TKe=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=BAe(s,s.left,s.top),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const u=SKe(BAe(d),a);o.push({id:i,data:{droppableContainer:l,value:u}})}}return o.sort(CKe)},xRt=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=zAe(s),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const u=zAe(d),p=a.reduce((v,_,b)=>v+SKe(u[b],_),0),g=Number((p/4).toFixed(4));o.push({id:i,data:{droppableContainer:l,value:g}})}}return o.sort(CKe)};function yRt(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=yRt(i,s);d>0&&a.push({id:l,data:{droppableContainer:o,value:d}})}}return a.sort(gRt)};function _Rt(t,s,r){return{...t,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function AKe(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:Wg}function bRt(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 wRt=bRt(1);function jRt(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 kRt(t,s,r){const n=jRt(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,g=o?t.height/o:t.height;return{width:p,height:g,top:u,right:d+p,bottom:u+g,left:d}}const NRt={ignoreTransform:!1};function MM(t,s){s===void 0&&(s=NRt);let r=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:p}=Fm(t).getComputedStyle(t);u&&(r=kRt(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 $Ae(t){return MM(t,{ignoreTransform:!0})}function SRt(t){const s=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function CRt(t,s){return s===void 0&&(s=Fm(t).getComputedStyle(t)),s.position==="fixed"}function MRt(t,s){s===void 0&&(s=Fm(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 ble(t,s){const r=[];function n(a){if(s!=null&&r.length>=s||!a)return r;if(dwe(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!VL(a)||wKe(a)||r.includes(a))return r;const o=Fm(t).getComputedStyle(a);return a!==t&&MRt(a,o)&&r.push(a),CRt(a,o)?r:n(a.parentNode)}return t?n(t):r}function EKe(t){const[s]=ble(t,1);return s??null}function Ume(t){return!_le||!t?null:SM(t)?t:cwe(t)?dwe(t)||t===CM(t).scrollingElement?window:VL(t)?t:null:null}function PKe(t){return SM(t)?t.scrollX:t.scrollLeft}function IKe(t){return SM(t)?t.scrollY:t.scrollTop}function iye(t){return{x:PKe(t),y:IKe(t)}}var iu;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(iu||(iu={}));function LKe(t){return!_le||!t?!1:t===document.scrollingElement}function DKe(t){const s={x:0,y:0},r=LKe(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 TRt={x:.2,y:.2};function ARt(t,s,r,n,a){let{top:o,left:l,right:i,bottom:d}=r;n===void 0&&(n=10),a===void 0&&(a=TRt);const{isTop:u,isBottom:p,isLeft:g,isRight:v}=DKe(t),_={x:0,y:0},b={x:0,y:0},j={height:s.height*a.y,width:s.width*a.x};return!u&&o<=s.top+j.height?(_.y=iu.Backward,b.y=n*Math.abs((s.top+j.height-o)/j.height)):!p&&d>=s.bottom-j.height&&(_.y=iu.Forward,b.y=n*Math.abs((s.bottom-j.height-d)/j.height)),!v&&i>=s.right-j.width?(_.x=iu.Forward,b.x=n*Math.abs((s.right-j.width-i)/j.width)):!g&&l<=s.left+j.width&&(_.x=iu.Backward,b.x=n*Math.abs((s.left+j.width-l)/j.width)),{direction:_,speed:b}}function ERt(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 OKe(t){return t.reduce((s,r)=>D5(s,iye(r)),Wg)}function PRt(t){return t.reduce((s,r)=>s+PKe(r),0)}function IRt(t){return t.reduce((s,r)=>s+IKe(r),0)}function LRt(t,s){if(s===void 0&&(s=MM),!t)return;const{top:r,left:n,bottom:a,right:o}=s(t);EKe(t)&&(a<=0||o<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const DRt=[["x",["left","right"],PRt],["y",["top","bottom"],IRt]];class mwe{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=ble(r),a=OKe(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,l,i]of DRt)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 lI{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 ORt(t){const{EventTarget:s}=Fm(t);return t instanceof s?t:CM(t)}function Vme(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 Yp;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Yp||(Yp={}));function qAe(t){t.preventDefault()}function RRt(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 RKe={start:[yo.Space,yo.Enter],cancel:[yo.Esc],end:[yo.Space,yo.Enter,yo.Tab]},FRt=(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 pwe{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 lI(CM(r)),this.windowListeners=new lI(Fm(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Yp.Resize,this.handleCancel),this.windowListeners.add(Yp.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Yp.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&LRt(n),r(Wg)}handleKeyDown(s){if(hwe(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:o=RKe,coordinateGetter:l=FRt,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}:Wg;this.referenceCoordinates||(this.referenceCoordinates=p);const g=l(s,{active:r,context:n.current,currentCoordinates:p});if(g){const v=f6(g,p),_={x:0,y:0},{scrollableAncestors:b}=n.current;for(const j of b){const w=s.code,{isTop:N,isRight:C,isLeft:A,isBottom:I,maxScroll:L,minScroll:R}=DKe(j),$=ERt(j),q={x:Math.min(w===yo.Right?$.right-$.width/2:$.right,Math.max(w===yo.Right?$.left:$.left+$.width/2,g.x)),y:Math.min(w===yo.Down?$.bottom-$.height/2:$.bottom,Math.max(w===yo.Down?$.top:$.top+$.height/2,g.y))},U=w===yo.Right&&!C||w===yo.Left&&!A,V=w===yo.Down&&!I||w===yo.Up&&!N;if(U&&q.x!==g.x){const X=j.scrollLeft+v.x,se=w===yo.Right&&X<=L.x||w===yo.Left&&X>=R.x;if(se&&!v.y){j.scrollTo({left:X,behavior:i});return}se?_.x=j.scrollLeft-X:_.x=w===yo.Right?j.scrollLeft-L.x:j.scrollLeft-R.x,_.x&&j.scrollBy({left:-_.x,behavior:i});break}else if(V&&q.y!==g.y){const X=j.scrollTop+v.y,se=w===yo.Down&&X<=L.y||w===yo.Up&&X>=R.y;if(se&&!v.x){j.scrollTo({top:X,behavior:i});return}se?_.y=j.scrollTop-X:_.y=w===yo.Down?j.scrollTop-L.y:j.scrollTop-R.y,_.y&&j.scrollBy({top:-_.y,behavior:i});break}}this.handleMove(s,D5(f6(g,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()}}pwe.activators=[{eventName:"onKeyDown",handler:(t,s,r)=>{let{keyboardCodes:n=RKe,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 UAe(t){return!!(t&&"distance"in t)}function VAe(t){return!!(t&&"delay"in t)}class fwe{constructor(s,r,n){var a;n===void 0&&(n=ORt(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=CM(l),this.documentListeners=new lI(this.document),this.listeners=new lI(n),this.windowListeners=new lI(Fm(l)),this.initialCoordinates=(a=nye(o))!=null?a:Wg,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(Yp.Resize,this.handleCancel),this.windowListeners.add(Yp.DragStart,qAe),this.windowListeners.add(Yp.VisibilityChange,this.handleCancel),this.windowListeners.add(Yp.ContextMenu,qAe),this.documentListeners.add(Yp.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(VAe(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(UAe(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(Yp.Click,RRt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Yp.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=nye(s))!=null?r:Wg,u=f6(a,d);if(!n&&i){if(UAe(i)){if(i.tolerance!=null&&Vme(u,i.tolerance))return this.handleCancel();if(Vme(u,i.distance))return this.handleStart()}if(VAe(i)&&Vme(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 zRt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class wle extends fwe{constructor(s){const{event:r}=s,n=CM(r.target);super(s,zRt,n)}}wle.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 BRt={move:{name:"mousemove"},end:{name:"mouseup"}};var oye;(function(t){t[t.RightClick=2]="RightClick"})(oye||(oye={}));class $Rt extends fwe{constructor(s){super(s,BRt,CM(s.event.target))}}$Rt.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return r.button===oye.RightClick?!1:(n==null||n({event:r}),!0)}}];const Hme={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class qRt extends fwe{constructor(s){super(s,Hme)}static setup(){return window.addEventListener(Hme.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Hme.move.name,s)};function s(){}}}qRt.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 cI;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(cI||(cI={}));var Tae;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Tae||(Tae={}));function URt(t){let{acceleration:s,activator:r=cI.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:i=Tae.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:p,delta:g,threshold:v}=t;const _=HRt({delta:g,disabled:!o}),[b,j]=rRt(),w=S.useRef({x:0,y:0}),N=S.useRef({x:0,y:0}),C=S.useMemo(()=>{switch(r){case cI.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case cI.DraggableRect:return a}},[r,a,d]),A=S.useRef(null),I=S.useCallback(()=>{const R=A.current;if(!R)return;const $=w.current.x*N.current.x,q=w.current.y*N.current.y;R.scrollBy($,q)},[]),L=S.useMemo(()=>i===Tae.TreeOrder?[...u].reverse():u,[i,u]);S.useEffect(()=>{if(!o||!u.length||!C){j();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:V}=ARt(R,q,C,s,v);for(const X of["x","y"])_[X][U[X]]||(V[X]=0,U[X]=0);if(V.x>0||V.y>0){j(),A.current=R,b(I,l),w.current=V,N.current=U;return}}w.current={x:0,y:0},N.current={x:0,y:0},j()},[s,I,n,j,o,l,JSON.stringify(C),JSON.stringify(_),b,u,L,p,JSON.stringify(v)])}const VRt={x:{[iu.Backward]:!1,[iu.Forward]:!1},y:{[iu.Backward]:!1,[iu.Forward]:!1}};function HRt(t){let{delta:s,disabled:r}=t;const n=rye(s);return HL(a=>{if(r||!n||!a)return VRt;const o={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[iu.Backward]:a.x[iu.Backward]||o.x===-1,[iu.Forward]:a.x[iu.Forward]||o.x===1},y:{[iu.Backward]:a.y[iu.Backward]||o.y===-1,[iu.Forward]:a.y[iu.Forward]||o.y===1}}},[r,s,n])}function WRt(t,s){const r=s!=null?t.get(s):void 0,n=r?r.node.current:null;return HL(a=>{var o;return s==null?null:(o=n??a)!=null?o:null},[n,s])}function GRt(t,s){return S.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 g6;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(g6||(g6={}));var lye;(function(t){t.Optimized="optimized"})(lye||(lye={}));const HAe=new Map;function KRt(t,s){let{dragging:r,dependencies:n,config:a}=s;const[o,l]=S.useState(null),{frequency:i,measure:d,strategy:u}=a,p=S.useRef(t),g=w(),v=p6(g),_=S.useCallback(function(N){N===void 0&&(N=[]),!v.current&&l(C=>C===null?N:C.concat(N.filter(A=>!C.includes(A))))},[v]),b=S.useRef(null),j=HL(N=>{if(g&&!r)return HAe;if(!N||N===HAe||p.current!==t||o!=null){const C=new Map;for(let A of t){if(!A)continue;if(o&&o.length>0&&!o.includes(A.id)&&A.rect.current){C.set(A.id,A.rect.current);continue}const I=A.node.current,L=I?new mwe(d(I),I):null;A.rect.current=L,L&&C.set(A.id,L)}return C}return N},[t,o,r,g,d]);return S.useEffect(()=>{p.current=t},[t]),S.useEffect(()=>{g||_()},[r,g]),S.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),S.useEffect(()=>{g||typeof i!="number"||b.current!==null||(b.current=setTimeout(()=>{_(),b.current=null},i))},[i,g,_,...n]),{droppableRects:j,measureDroppableContainers:_,measuringScheduled:o!=null};function w(){switch(u){case g6.Always:return!1;case g6.BeforeDragging:return r;default:return!r}}}function FKe(t,s){return HL(r=>t?r||(typeof s=="function"?s(t):t):null,[s,t])}function ZRt(t,s){return FKe(t,s)}function YRt(t){let{callback:s,disabled:r}=t;const n=uwe(s),a=S.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,r]);return S.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function jle(t){let{callback:s,disabled:r}=t;const n=uwe(s),a=S.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[r]);return S.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function XRt(t){return new mwe(MM(t),t)}function WAe(t,s,r){s===void 0&&(s=XRt);const[n,a]=S.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=YRt({callback(d){if(t)for(const u of d){const{type:p,target:g}=u;if(p==="childList"&&g instanceof HTMLElement&&g.contains(t)){o();break}}}}),i=jle({callback:o});return oy(()=>{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 QRt(t){const s=FKe(t);return AKe(t,s)}const GAe=[];function JRt(t){const s=S.useRef(t),r=HL(n=>t?n&&n!==GAe&&t&&s.current&&t.parentNode===s.current.parentNode?n:ble(t):GAe,[t]);return S.useEffect(()=>{s.current=t},[t]),r}function eFt(t){const[s,r]=S.useState(null),n=S.useRef(t),a=S.useCallback(o=>{const l=Ume(o.target);l&&r(i=>i?(i.set(l,iye(l)),new Map(i)):null)},[]);return S.useEffect(()=>{const o=n.current;if(t!==o){l(o);const i=t.map(d=>{const u=Ume(d);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,iye(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=Ume(d);u==null||u.removeEventListener("scroll",a)})}},[a,t]),S.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,l)=>D5(o,l),Wg):OKe(t):Wg,[t,s])}function KAe(t,s){s===void 0&&(s=[]);const r=S.useRef(null);return S.useEffect(()=>{r.current=null},s),S.useEffect(()=>{const n=t!==Wg;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?f6(t,r.current):Wg}function tFt(t){S.useEffect(()=>{if(!_le)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 sFt(t,s){return S.useMemo(()=>t.reduce((r,n)=>{let{eventName:a,handler:o}=n;return r[a]=l=>{o(l,s)},r},{}),[t,s])}function zKe(t){return S.useMemo(()=>t?SRt(t):null,[t])}const ZAe=[];function rFt(t,s){s===void 0&&(s=MM);const[r]=t,n=zKe(r?Fm(r):null),[a,o]=S.useState(ZAe);function l(){o(()=>t.length?t.map(d=>LKe(d)?n:new mwe(s(d),d)):ZAe)}const i=jle({callback:l});return oy(()=>{i==null||i.disconnect(),l(),t.forEach(d=>i==null?void 0:i.observe(d))},[t]),a}function nFt(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return VL(s)?s:t}function aFt(t){let{measure:s}=t;const[r,n]=S.useState(null),a=S.useCallback(u=>{for(const{target:p}of u)if(VL(p)){n(g=>{const v=s(p);return g?{...g,width:v.width,height:v.height}:v});break}},[s]),o=jle({callback:a}),l=S.useCallback(u=>{const p=nFt(u);o==null||o.disconnect(),p&&(o==null||o.observe(p)),n(p?s(p):null)},[s,o]),[i,d]=Cae(l);return S.useMemo(()=>({nodeRef:i,rect:r,setRef:d}),[r,i,d])}const iFt=[{sensor:wle,options:{}},{sensor:pwe,options:{}}],oFt={current:{}},_re={draggable:{measure:$Ae},droppable:{measure:$Ae,strategy:g6.WhileDragging,frequency:lye.Optimized},dragOverlay:{measure:MM}};class dI 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 dI,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Mae},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:_re,measureDroppableContainers:Mae,windowRect:null,measuringScheduled:!1},cFt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Mae,draggableNodes:new Map,over:null,measureDroppableContainers:Mae},kle=S.createContext(cFt),BKe=S.createContext(lFt);function dFt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new dI}}}function uFt(t,s){switch(s.type){case Rd.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case Rd.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 Rd.DragEnd:case Rd.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Rd.RegisterDroppable:{const{element:r}=s,{id:n}=r,a=new dI(t.droppable.containers);return a.set(n,r),{...t,droppable:{...t.droppable,containers:a}}}case Rd.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 dI(t.droppable.containers);return l.set(r,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:l}}}case Rd.UnregisterDroppable:{const{id:r,key:n}=s,a=t.droppable.containers.get(r);if(!a||n!==a.key)return t;const o=new dI(t.droppable.containers);return o.delete(r),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function hFt(t){let{disabled:s}=t;const{active:r,activatorEvent:n,draggableNodes:a}=S.useContext(kle),o=rye(n),l=rye(r==null?void 0:r.id);return S.useEffect(()=>{if(!s&&!n&&o&&l!=null){if(!hwe(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 g=iRt(p);if(g){g.focus();break}}})}},[n,s,a,l,o]),null}function mFt(t,s){let{transform:r,...n}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...n}),r):r}function pFt(t){return S.useMemo(()=>({draggable:{..._re.draggable,...t==null?void 0:t.draggable},droppable:{..._re.droppable,...t==null?void 0:t.droppable},dragOverlay:{..._re.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 fFt(t){let{activeNode:s,measure:r,initialRect:n,config:a=!0}=t;const o=S.useRef(!1),{x:l,y:i}=typeof a=="boolean"?{x:a,y:a}:a;oy(()=>{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),g=AKe(p,n);if(l||(g.x=0),i||(g.y=0),o.current=!0,Math.abs(g.x)>0||Math.abs(g.y)>0){const v=EKe(u);v&&v.scrollBy({top:g.y,left:g.x})}},[s,l,i,n,r])}const $Ke=S.createContext({...Wg,scaleX:1,scaleY:1});var u1;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(u1||(u1={}));const qKe=S.memo(function(s){var r,n,a,o;let{id:l,accessibility:i,autoScroll:d=!0,children:u,sensors:p=iFt,collisionDetection:g=vRt,measuring:v,modifiers:_,...b}=s;const j=S.useReducer(uFt,void 0,dFt),[w,N]=j,[C,A]=hRt(),[I,L]=S.useState(u1.Uninitialized),R=I===u1.Initialized,{draggable:{active:$,nodes:q,translate:U},droppable:{containers:V}}=w,X=$!=null?q.get($):null,se=S.useRef({initial:null,translated:null}),te=S.useMemo(()=>{var Oa;return $!=null?{id:$,data:(Oa=X==null?void 0:X.data)!=null?Oa:oFt,rect:se}:null},[$,X]),Y=S.useRef(null),[de,ie]=S.useState(null),[ae,le]=S.useState(null),pe=p6(b,Object.values(b)),be=WL("DndDescribedBy",l),ye=S.useMemo(()=>V.getEnabled(),[V]),we=pFt(v),{droppableRects:Ne,measureDroppableContainers:Ke,measuringScheduled:_e}=KRt(ye,{dragging:R,dependencies:[U.x,U.y],config:we.droppable}),Me=WRt(q,$),Te=S.useMemo(()=>ae?nye(ae):null,[ae]),Fe=lo(),Ae=ZRt(Me,we.draggable.measure);fFt({activeNode:$!=null?q.get($):null,config:Fe.layoutShiftCompensation,initialRect:Ae,measure:we.draggable.measure});const Ue=WAe(Me,we.draggable.measure,Ae),ut=WAe(Me?Me.parentElement:null),De=S.useRef({activatorEvent:null,active:null,activeNode:Me,collisionRect:null,collisions:null,droppableRects:Ne,draggableNodes:q,draggingNode:null,draggingNodeRect:null,droppableContainers:V,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Dt=V.getNodeFor((r=De.current.over)==null?void 0:r.id),he=aFt({measure:we.dragOverlay.measure}),Ve=(n=he.nodeRef.current)!=null?n:Me,nt=R?(a=he.rect)!=null?a:Ue:null,Qe=!!(he.nodeRef.current&&he.rect),ke=QRt(Qe?null:Ue),ot=zKe(Ve?Fm(Ve):null),qe=JRt(R?Dt??Me:null),lt=rFt(qe),We=mFt(_,{transform:{x:U.x-ke.x,y:U.y-ke.y,scaleX:1,scaleY:1},activatorEvent:ae,active:te,activeNodeRect:Ue,containerNodeRect:ut,draggingNodeRect:nt,over:De.current.over,overlayNodeRect:he.rect,scrollableAncestors:qe,scrollableAncestorRects:lt,windowRect:ot}),Ye=Te?D5(Te,U):null,mt=eFt(qe),Ze=KAe(mt),He=KAe(mt,[Ue]),et=D5(We,Ze),Rt=nt?wRt(nt,We):null,qt=te&&Rt?g({active:te,collisionRect:Rt,droppableRects:Ne,droppableContainers:ye,pointerCoordinates:Ye}):null,ls=MKe(qt,"id"),[Kt,Qt]=S.useState(null),fs=Qe?We:D5(We,He),dr=_Rt(fs,(o=Kt==null?void 0:Kt.rect)!=null?o:null,Ue),bt=S.useRef(null),ks=S.useCallback((Oa,yn)=>{let{sensor:ta,options:Zt}=yn;if(Y.current==null)return;const vr=q.get(Y.current);if(!vr)return;const Gr=Oa.nativeEvent,Rn=new ta({active:Y.current,activeNode:vr,event:Gr,options:Zt,context:De,onAbort(Ln){if(!q.get(Ln))return;const{onDragAbort:Va}=pe.current,Jr={id:Ln};Va==null||Va(Jr),C({type:"onDragAbort",event:Jr})},onPending(Ln,da,Va,Jr){if(!q.get(Ln))return;const{onDragPending:$l}=pe.current,Do={id:Ln,constraint:da,initialCoordinates:Va,offset:Jr};$l==null||$l(Do),C({type:"onDragPending",event:Do})},onStart(Ln){const da=Y.current;if(da==null)return;const Va=q.get(da);if(!Va)return;const{onDragStart:Jr}=pe.current,Za={activatorEvent:Gr,active:{id:da,data:Va.data,rect:se}};_m.unstable_batchedUpdates(()=>{Jr==null||Jr(Za),L(u1.Initializing),N({type:Rd.DragStart,initialCoordinates:Ln,active:da}),C({type:"onDragStart",event:Za}),ie(bt.current),le(Gr)})},onMove(Ln){N({type:Rd.DragMove,coordinates:Ln})},onEnd:rs(Rd.DragEnd),onCancel:rs(Rd.DragCancel)});bt.current=Rn;function rs(Ln){return async function(){const{active:Va,collisions:Jr,over:Za,scrollAdjustedTranslate:$l}=De.current;let Do=null;if(Va&&$l){const{cancelDrop:Yc}=pe.current;Do={activatorEvent:Gr,active:Va,collisions:Jr,delta:$l,over:Za},Ln===Rd.DragEnd&&typeof Yc=="function"&&await Promise.resolve(Yc(Do))&&(Ln=Rd.DragCancel)}Y.current=null,_m.unstable_batchedUpdates(()=>{N({type:Ln}),L(u1.Uninitialized),Qt(null),ie(null),le(null),bt.current=null;const Yc=Ln===Rd.DragEnd?"onDragEnd":"onDragCancel";if(Do){const ct=pe.current[Yc];ct==null||ct(Do),C({type:Yc,event:Do})}})}}},[q]),ir=S.useCallback((Oa,yn)=>(ta,Zt)=>{const vr=ta.nativeEvent,Gr=q.get(Zt);if(Y.current!==null||!Gr||vr.dndKit||vr.defaultPrevented)return;const Rn={active:Gr};Oa(ta,yn.options,Rn)===!0&&(vr.dndKit={capturedBy:yn.sensor},Y.current=Zt,ks(ta,yn))},[q,ks]),Rr=GRt(p,ir);tFt(p),oy(()=>{Ue&&I===u1.Initializing&&L(u1.Initialized)},[Ue,I]),S.useEffect(()=>{const{onDragMove:Oa}=pe.current,{active:yn,activatorEvent:ta,collisions:Zt,over:vr}=De.current;if(!yn||!ta)return;const Gr={active:yn,activatorEvent:ta,collisions:Zt,delta:{x:et.x,y:et.y},over:vr};_m.unstable_batchedUpdates(()=>{Oa==null||Oa(Gr),C({type:"onDragMove",event:Gr})})},[et.x,et.y]),S.useEffect(()=>{const{active:Oa,activatorEvent:yn,collisions:ta,droppableContainers:Zt,scrollAdjustedTranslate:vr}=De.current;if(!Oa||Y.current==null||!yn||!vr)return;const{onDragOver:Gr}=pe.current,Rn=Zt.get(ls),rs=Rn&&Rn.rect.current?{id:Rn.id,rect:Rn.rect.current,data:Rn.data,disabled:Rn.disabled}:null,Ln={active:Oa,activatorEvent:yn,collisions:ta,delta:{x:vr.x,y:vr.y},over:rs};_m.unstable_batchedUpdates(()=>{Qt(rs),Gr==null||Gr(Ln),C({type:"onDragOver",event:Ln})})},[ls]),oy(()=>{De.current={activatorEvent:ae,active:te,activeNode:Me,collisionRect:Rt,collisions:qt,droppableRects:Ne,draggableNodes:q,draggingNode:Ve,draggingNodeRect:nt,droppableContainers:V,over:Kt,scrollableAncestors:qe,scrollAdjustedTranslate:et},se.current={initial:nt,translated:Rt}},[te,Me,qt,Rt,q,Ve,nt,Ne,V,Kt,qe,et]),URt({...Fe,delta:U,draggingRect:Rt,pointerCoordinates:Ye,scrollableAncestors:qe,scrollableAncestorRects:lt});const ca=S.useMemo(()=>({active:te,activeNode:Me,activeNodeRect:Ue,activatorEvent:ae,collisions:qt,containerNodeRect:ut,dragOverlay:he,draggableNodes:q,droppableContainers:V,droppableRects:Ne,over:Kt,measureDroppableContainers:Ke,scrollableAncestors:qe,scrollableAncestorRects:lt,measuringConfiguration:we,measuringScheduled:_e,windowRect:ot}),[te,Me,Ue,ae,qt,ut,he,q,V,Ne,Kt,Ke,qe,lt,we,_e,ot]),ii=S.useMemo(()=>({activatorEvent:ae,activators:Rr,active:te,activeNodeRect:Ue,ariaDescribedById:{draggable:be},dispatch:N,draggableNodes:q,over:Kt,measureDroppableContainers:Ke}),[ae,Rr,te,Ue,N,be,q,Kt,Ke]);return ht.createElement(kKe.Provider,{value:A},ht.createElement(kle.Provider,{value:ii},ht.createElement(BKe.Provider,{value:ca},ht.createElement($Ke.Provider,{value:dr},u)),ht.createElement(hFt,{disabled:(i==null?void 0:i.restoreFocus)===!1})),ht.createElement(fRt,{...i,hiddenTextDescribedById:be}));function lo(){const Oa=(de==null?void 0:de.autoScrollEnabled)===!1,yn=typeof d=="object"?d.enabled===!1:d===!1,ta=R&&!Oa&&!yn;return typeof d=="object"?{...d,enabled:ta}:{enabled:ta}}}),gFt=S.createContext(null),YAe="button",xFt="Draggable";function yFt(t){let{id:s,data:r,disabled:n=!1,attributes:a}=t;const o=WL(xFt),{activators:l,activatorEvent:i,active:d,activeNodeRect:u,ariaDescribedById:p,draggableNodes:g,over:v}=S.useContext(kle),{role:_=YAe,roleDescription:b="draggable",tabIndex:j=0}=a??{},w=(d==null?void 0:d.id)===s,N=S.useContext(w?$Ke:gFt),[C,A]=Cae(),[I,L]=Cae(),R=sFt(l,s),$=p6(r);oy(()=>(g.set(s,{id:s,key:o,node:C,activatorNode:I,data:$}),()=>{const U=g.get(s);U&&U.key===o&&g.delete(s)}),[g,s]);const q=S.useMemo(()=>({role:_,tabIndex:j,"aria-disabled":n,"aria-pressed":w&&_===YAe?!0:void 0,"aria-roledescription":b,"aria-describedby":p.draggable}),[n,_,j,w,b,p.draggable]);return{active:d,activatorEvent:i,activeNodeRect:u,attributes:q,isDragging:w,listeners:n?void 0:R,node:C,over:v,setNodeRef:A,setActivatorNodeRef:L,transform:N}}function vFt(){return S.useContext(BKe)}const _Ft="Droppable",bFt={timeout:25};function wFt(t){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=t;const o=WL(_Ft),{active:l,dispatch:i,over:d,measureDroppableContainers:u}=S.useContext(kle),p=S.useRef({disabled:r}),g=S.useRef(!1),v=S.useRef(null),_=S.useRef(null),{disabled:b,updateMeasurementsFor:j,timeout:w}={...bFt,...a},N=p6(j??n),C=S.useCallback(()=>{if(!g.current){g.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{u(Array.isArray(N.current)?N.current:[N.current]),_.current=null},w)},[w]),A=jle({callback:C,disabled:b||!l}),I=S.useCallback((q,U)=>{A&&(U&&(A.unobserve(U),g.current=!1),q&&A.observe(q))},[A]),[L,R]=Cae(I),$=p6(s);return S.useEffect(()=>{!A||!L.current||(A.disconnect(),g.current=!1,A.observe(L.current))},[L,A]),S.useEffect(()=>(i({type:Rd.RegisterDroppable,element:{id:n,key:o,disabled:r,node:L,rect:v,data:$}}),()=>i({type:Rd.UnregisterDroppable,key:o,id:n})),[n]),S.useEffect(()=>{r!==p.current.disabled&&(i({type:Rd.SetDroppableDisabled,id:n,key:o,disabled:r}),p.current.disabled=r)},[n,o,r,i]),{active:l,rect:v,isOver:(d==null?void 0:d.id)===n,node:L,over:d,setNodeRef:R}}function gwe(t,s,r){const n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(s,1)[0]),n}function jFt(t,s){return t.reduce((r,n,a)=>{const o=s.get(n);return o&&(r[a]=o),r},Array(t.length))}function aR(t){return t!==null&&t>=0}function kFt(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=SFt(r,l,a);if(l===a){const u=r[o];return u?{x:aa&&l<=o?{x:-i.width-d,y:0,...iR}:l=o?{x:i.width+d,y:0,...iR}:{x:0,y:0,...iR}};function SFt(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=gwe(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}},UKe="Sortable",VKe=ht.createContext({activeIndex:-1,containerId:UKe,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Nle,disabled:{draggable:!1,droppable:!1}});function HKe(t){let{children:s,id:r,items:n,strategy:a=Nle,disabled:o=!1}=t;const{active:l,dragOverlay:i,droppableRects:d,over:u,measureDroppableContainers:p}=vFt(),g=WL(UKe,r),v=i.rect!==null,_=S.useMemo(()=>n.map(R=>typeof R=="object"&&"id"in R?R.id:R),[n]),b=l!=null,j=l?_.indexOf(l.id):-1,w=u?_.indexOf(u.id):-1,N=S.useRef(_),C=!kFt(_,N.current),A=w!==-1&&j===-1||C,I=NFt(o);oy(()=>{C&&b&&p(_)},[C,_,b,p]),S.useEffect(()=>{N.current=_},[_]);const L=S.useMemo(()=>({activeIndex:j,containerId:g,disabled:I,disableTransforms:A,items:_,overIndex:w,useDragOverlay:v,sortedRects:jFt(_,d),strategy:a}),[j,g,I.draggable,I.droppable,A,_,w,d,v,a]);return ht.createElement(VKe.Provider,{value:L},s)}const CFt=t=>{let{id:s,items:r,activeIndex:n,overIndex:a}=t;return gwe(r,n,a).indexOf(s)},MFt=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},TFt={duration:200,easing:"ease"},WKe="transform",AFt=S3.Transition.toString({property:WKe,duration:0,easing:"linear"}),EFt={roleDescription:"sortable"};function PFt(t){let{disabled:s,index:r,node:n,rect:a}=t;const[o,l]=S.useState(null),i=S.useRef(r);return oy(()=>{if(!s&&r!==i.current&&n.current){const d=a.current;if(d){const u=MM(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]),S.useEffect(()=>{o&&l(null)},[o]),o}function GKe(t){let{animateLayoutChanges:s=MFt,attributes:r,disabled:n,data:a,getNewIndex:o=CFt,id:l,strategy:i,resizeObserverConfig:d,transition:u=TFt}=t;const{items:p,containerId:g,activeIndex:v,disabled:_,disableTransforms:b,sortedRects:j,overIndex:w,useDragOverlay:N,strategy:C}=S.useContext(VKe),A=IFt(n,_),I=p.indexOf(l),L=S.useMemo(()=>({sortable:{containerId:g,index:I,items:p},...a}),[g,a,I,p]),R=S.useMemo(()=>p.slice(p.indexOf(l)),[p,l]),{rect:$,node:q,isOver:U,setNodeRef:V}=wFt({id:l,data:L,disabled:A.droppable,resizeObserverConfig:{updateMeasurementsFor:R,...d}}),{active:X,activatorEvent:se,activeNodeRect:te,attributes:Y,setNodeRef:de,listeners:ie,isDragging:ae,over:le,setActivatorNodeRef:pe,transform:be}=yFt({id:l,data:L,attributes:{...EFt,...r},disabled:A.draggable}),ye=sRt(V,de),we=!!X,Ne=we&&!b&&aR(v)&&aR(w),Ke=!N&&ae,_e=Ke&&Ne?be:null,Te=Ne?_e??(i??C)({rects:j,activeNodeRect:te,activeIndex:v,overIndex:w,index:I}):null,Fe=aR(v)&&aR(w)?o({id:l,items:p,activeIndex:v,overIndex:w}):I,Ae=X==null?void 0:X.id,Ue=S.useRef({activeId:Ae,items:p,newIndex:Fe,containerId:g}),ut=p!==Ue.current.items,De=s({active:X,containerId:g,isDragging:ae,isSorting:we,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}),Dt=PFt({disabled:!De,index:I,node:q,rect:$});return S.useEffect(()=>{we&&Ue.current.newIndex!==Fe&&(Ue.current.newIndex=Fe),g!==Ue.current.containerId&&(Ue.current.containerId=g),p!==Ue.current.items&&(Ue.current.items=p)},[we,Fe,g,p]),S.useEffect(()=>{if(Ae===Ue.current.activeId)return;if(Ae!=null&&Ue.current.activeId==null){Ue.current.activeId=Ae;return}const Ve=setTimeout(()=>{Ue.current.activeId=Ae},50);return()=>clearTimeout(Ve)},[Ae]),{active:X,activeIndex:v,attributes:Y,data:L,rect:$,index:I,newIndex:Fe,items:p,isOver:U,isSorting:we,isDragging:ae,listeners:ie,node:q,overIndex:w,over:le,setNodeRef:ye,setActivatorNodeRef:pe,setDroppableNodeRef:V,setDraggableNodeRef:de,transform:Dt??Te,transition:he()};function he(){if(Dt||ut&&Ue.current.newIndex===I)return AFt;if(!(Ke&&!hwe(se)||!u)&&(we||De))return S3.Transition.toString({...u,property:WKe})}}function IFt(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 Aae(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 LFt=[yo.Down,yo.Right,yo.Up,yo.Left],DFt=(t,s)=>{let{context:{active:r,collisionRect:n,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=s;if(LFt.includes(t.code)){if(t.preventDefault(),!r||!n)return;const d=[];o.getEnabled().forEach(g=>{if(!g||g!=null&&g.disabled)return;const v=a.get(g.id);if(v)switch(t.code){case yo.Down:n.topv.top&&d.push(g);break;case yo.Left:n.left>v.left&&d.push(g);break;case yo.Right:n.left1&&(p=u[1].id),p!=null){const g=o.get(r.id),v=o.get(p),_=v?a.get(v.id):null,b=v==null?void 0:v.node.current;if(b&&_&&g&&v){const w=ble(b).some((R,$)=>i[$]!==R),N=KKe(g,v),C=OFt(g,v),A=w||!N?{x:0,y:0}:{x:C?n.width-_.width:0,y:C?n.height-_.height:0},I={x:_.left,y:_.top};return A.x&&A.y?I:f6(I,A)}}}};function KKe(t,s){return!Aae(t)||!Aae(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function OFt(t,s){return!Aae(t)||!Aae(s)||!KKe(t,s)?!1:t.data.current.sortable.indexs(t),children:e.jsx(Ua,{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(at,{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"}),ws(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(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:Et("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?ws(new Date(t.post_date+"T00:00:00"),"MMM d, yyyy"):"Set post date"]})}),e.jsxs(jo,{className:"w-auto p-0",align:"start",children:[e.jsx(vp,{mode:"single",selected:t.post_date?new Date(t.post_date+"T00:00:00"):void 0,onSelect:g=>n(t.id,g?ws(g,"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 FFt=()=>{const t=ns(),[s,r]=S.useState("all"),[n,a]=S.useState(!1),[o,l]=S.useState(ws(new Date,"yyyy-MM")),[i,d]=S.useState([]),[u,p]=S.useState(!1),[g,v]=S.useState(null),[_,b]=S.useState(null),[j,w]=S.useState(""),[N,C]=S.useState(null),[A,I]=S.useState(!1),[L,R]=S.useState(!1),[$,q]=S.useState(ws(new Date,"yyyy-MM")),[U,V]=S.useState(null),[X,se]=S.useState(""),[te,Y]=S.useState(""),[de,ie]=S.useState(""),[ae,le]=S.useState(!1),pe=NKe(aye(wle,{activationConstraint:{distance:5}}),aye(pwe,{coordinateGetter:DFt})),{data:be=[],isLoading:ye}=Ct({queryKey:["admin-social-swag-2"],queryFn:async()=>{const{data:Ye,error:mt}=await G.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(mt)throw mt;return Ye}}),{data:we=[]}=Ct({queryKey:["admin-social-swag-2-months"],queryFn:async()=>{const{data:Ye,error:mt}=await G.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(mt)throw mt;return Ye}}),{data:Ne=[]}=Ct({queryKey:["admin-social-swag-2-reels"],queryFn:async()=>{const{data:Ye,error:mt}=await G.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(mt)throw mt;return Ye}}),Ke=[...new Set(be.map(Ye=>Ye.month))].sort((Ye,mt)=>mt.localeCompare(Ye)),_e=s==="all"?be:be.filter(Ye=>Ye.month===s),Me=Ye=>{const mt=J1e(Ye,"yyyy-MM",new Date);return ws(mt,"MMMM yyyy")},Te=Ye=>{b(Ye),w(Ye.caption),C(Ye.post_date)},Fe=async()=>{if(_){I(!0);try{const{error:Ye}=await G.from("social_swag_2").update({caption:j,post_date:N}).eq("id",_.id);if(Ye)throw Ye;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 Ye=>{const{active:mt,over:Ze}=Ye;if(!Ze||mt.id===Ze.id)return;const He=_e,et=He.findIndex(ls=>ls.id===mt.id),Rt=He.findIndex(ls=>ls.id===Ze.id);if(et===-1||Rt===-1)return;const qt=gwe(He,et,Rt);t.setQueryData(["admin-social-swag-2"],ls=>{if(!ls)return ls;const Kt={};return qt.forEach((Qt,fs)=>{Kt[Qt.id]=fs}),ls.map(Qt=>Kt[Qt.id]!==void 0?{...Qt,sort_order:Kt[Qt.id]}:Qt).sort((Qt,fs)=>Qt.month!==fs.month?fs.month.localeCompare(Qt.month):Qt.sort_order-fs.sort_order)});try{await Promise.all(qt.map((ls,Kt)=>G.from("social_swag_2").update({sort_order:Kt}).eq("id",ls.id)))}catch{fe.error("Failed to save order"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})}},Ue=Ye=>{const Ze=Array.from(Ye.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,...Ze].slice(0,16))},ut=Ye=>{d(mt=>{const Ze=[...mt];return URL.revokeObjectURL(Ze[Ye].preview),Ze.splice(Ye,1),Ze})},De=(Ye,mt)=>{d(Ze=>{const He=[...Ze];return He[Ye]={...He[Ye],caption:mt},He})},Dt=async()=>{var mt;if(i.length===0){fe.error("Please add at least one image");return}if(i.filter(Ze=>!Ze.caption.trim()).length>0){fe.error("Please add captions to all images");return}p(!0);try{const{data:Ze}=await G.from("social_swag_2").select("sort_order").eq("month",o).order("sort_order",{ascending:!1}).limit(1),He=(((mt=Ze==null?void 0:Ze[0])==null?void 0:mt.sort_order)??-1)+1;for(let et=0;et{const mt=Ye.image_url.split("/social-swag-2/");mt[1]&&await G.storage.from("social-swag-2").remove([mt[1]]);const{error:Ze}=await G.from("social_swag_2").delete().eq("id",Ye.id);if(Ze)throw Ze},onSuccess:()=>{fe.success("Image deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})},onError:()=>fe.error("Failed to delete image")}),Ve=Ot({mutationFn:async({id:Ye,postDate:mt})=>{const{error:Ze}=await G.from("social_swag_2").update({post_date:mt}).eq("id",Ye);if(Ze)throw Ze},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")}),nt=Ot({mutationFn:async({month:Ye,link:mt})=>{const{error:Ze}=await G.from("social_swag_2_months").upsert({month:Ye,canva_link:mt||null},{onConflict:"month"});if(Ze)throw Ze},onSuccess:()=>{fe.success("Canva link updated"),v(null),t.invalidateQueries({queryKey:["admin-social-swag-2-months"]})},onError:()=>fe.error("Failed to update Canva link")}),Qe=Ye=>{var mt;return((mt=we.find(Ze=>Ze.month===Ye))==null?void 0:mt.canva_link)||""},ke=Ye=>Ne.find(mt=>mt.month===Ye)||null,ot=Ye=>{var Ze;const mt=(Ze=Ye.target.files)==null?void 0:Ze[0];mt&&(V(mt),se(URL.createObjectURL(mt)))},qe=()=>{X&&URL.revokeObjectURL(X),V(null),se(""),Y(""),ie("")},lt=async()=>{if(!U){fe.error("Please select an image");return}le(!0);try{const Ye=U.name.split(".").pop(),mt=`reels/${$}-${Date.now()}.${Ye}`,{error:Ze}=await G.storage.from("social-swag-2").upload(mt,U);if(Ze)throw Ze;const{data:{publicUrl:He}}=G.storage.from("social-swag-2").getPublicUrl(mt),{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!"),sye(`${Me($)} Reel`,"social-swag-2"),qe(),R(!1),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})}catch(Ye){console.error("Reel upload error:",Ye),fe.error("Failed to upload reel")}finally{le(!1)}},We=Ot({mutationFn:async Ye=>{const mt=Ye.image_url.split("/social-swag-2/");mt[1]&&await G.storage.from("social-swag-2").remove([mt[1]]);const{error:Ze}=await G.from("social_swag_2_reels").delete().eq("id",Ye.id);if(Ze)throw Ze},onSuccess:()=>{fe.success("Reel deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})},onError:()=>fe.error("Failed to delete reel")});return e.jsxs(Ms,{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(vs,{open:n,onOpenChange:a,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Upload Images"]})}),e.jsxs(ys,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{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:Ye=>l(Ye.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(Xa,{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((Ye,mt)=>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:Ye.preview,alt:`Upload ${mt+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(mt),children:e.jsx(Ur,{className:"h-3 w-3"})})]}),e.jsx(Tr,{placeholder:"Caption...",value:Ye.caption,onChange:Ze=>De(mt,Ze.target.value),className:"text-xs h-20"})]},mt))}),e.jsx(K,{onClick:Dt,disabled:u||i.length===0,className:"w-full gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Xa,{className:"h-4 w-4"}),"Upload ",i.length," Images"]})})]})]})]}),e.jsxs(vs,{open:L,onOpenChange:Ye=>{R(Ye),Ye||qe()},children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(au,{className:"h-4 w-4"}),"Upload Reel"]})}),e.jsxs(ys,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{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:Ye=>q(Ye.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Reel Preview Image"}),X?e.jsxs("div",{className:"relative aspect-[9/16] max-w-[120px] mx-auto rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:X,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(X),V(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:ot,className:"hidden",id:"reel-upload"}),e.jsxs("label",{htmlFor:"reel-upload",className:"cursor-pointer",children:[e.jsx(au,{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:Ye=>ie(Ye.target.value),placeholder:"https://www.canva.com/..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Caption"}),e.jsx(Tr,{value:te,onChange:Ye=>Y(Ye.target.value),placeholder:"Enter caption for this reel...",className:"h-24"})]}),e.jsx(K,{onClick:lt,disabled:ae||!U,className:"w-full gap-2",children:ae?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Xa,{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:Ke.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Months"})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ja,{value:s,onValueChange:r,children:e.jsxs(va,{children:[e.jsx(Ns,{value:"all",children:"All"}),Ke.map(Ye=>e.jsx(Ns,{value:Ye,children:Me(Ye)},Ye))]})}),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(Io,{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)]}),(g==null?void 0:g.month)===s?e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(Re,{value:g.link,onChange:Ye=>v({...g,link:Ye.target.value}),placeholder:"https://www.canva.com/..."}),e.jsx(K,{size:"sm",onClick:()=>nt.mutate(g),children:"Save"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>v(null),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-sm",children:Qe(s)||"No link set"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>v({month:s,link:Qe(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(au,{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 Ye=ke(s);return Ye?e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[e.jsx("img",{src:Ye.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:Ye.caption||"No caption"}),Ye.canva_link&&e.jsx("a",{href:Ye.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:()=>We.mutate(Ye),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"})})()]})]})})})]}),ye?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}):_e.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(qKe,{sensors:pe,collisionDetection:TKe,onDragEnd:Ae,children:e.jsx(HKe,{items:_e.map(Ye=>Ye.id),strategy:Nle,children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:_e.map(Ye=>e.jsx(RFt,{item:Ye,onEdit:Te,onDelete:mt=>he.mutate(mt),onDateChange:(mt,Ze)=>Ve.mutate({id:mt,postDate:Ze})},Ye.id))})})})]}),e.jsx(vs,{open:!!_,onOpenChange:Ye=>{Ye||b(null)},children:e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(Tr,{value:j,onChange:Ye=>w(Ye.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(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Et("flex-1 justify-start gap-2 font-normal",!N&&"text-muted-foreground"),children:[e.jsx(on,{className:"h-4 w-4"}),N?ws(new Date(N+"T00:00:00"),"MMM d, yyyy"):"Pick a date"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(vp,{mode:"single",selected:N?new Date(N+"T00:00:00"):void 0,onSelect:Ye=>C(Ye?ws(Ye,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"})})]}),N&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>C(null),children:e.jsx(Ur,{className:"h-4 w-4"})})]})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(null),children:"Cancel"}),e.jsx(K,{onClick:Fe,disabled:A,className:"gap-2",children:A?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})]})},zFt=()=>{const{toast:t}=Ea(),s=ns(),[r,n]=S.useState("categories"),[a,o]=S.useState(!1),[l,i]=S.useState(null),[d,u]=S.useState({name:"",description:"",icon:""}),[p,g]=S.useState(!1),[v,_]=S.useState(null),[b,j]=S.useState({name:"",description:"",icon:""}),[w,N]=S.useState(!1),[C,A]=S.useState(null),[I,L]=S.useState(""),{data:R=[],isLoading:$}=Ct({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}=Ct({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:V=[]}=Ct({queryKey:["admin-group-members",C==null?void 0:C.id],queryFn:async()=>{if(!C)return[];const{data:Ae,error:Ue}=await G.from("community_private_group_members").select("*").eq("group_id",C.id);if(Ue)throw Ue;return Ae},enabled:!!C}),{data:X=[]}=Ct({queryKey:["admin-all-profiles"],queryFn:async()=>{let Ue=[],ut=0,De=!0;for(;De;){const{data:Dt,error:he}=await G.from("profiles").select("id, name, email, brokerage_id").order("name").range(ut,ut+1e3-1);if(he)throw he;Dt&&Dt.length>0?(Ue=[...Ue,...Dt],ut+=1e3,De=Dt.length===1e3):De=!1}return Ue}}),{data:se=[]}=Ct({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=Ot({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"})}}),Y=Ot({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=Ot({mutationFn:async({id:Ae,direction:Ue})=>{const ut=R.findIndex(De=>De.id===Ae);if(Ue==="up"&&ut>0){const De=R[ut-1],Dt=R[ut];await G.from("community_categories").update({sort_order:Dt.sort_order}).eq("id",De.id),await G.from("community_categories").update({sort_order:De.sort_order}).eq("id",Dt.id)}else if(Ue==="down"&&uts.invalidateQueries({queryKey:["admin-community-categories"]})}),ie=Ot({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"]}),g(!1),_(null),j({name:"",description:"",icon:""}),t({title:v?"Private group updated!":"Private group created!"})},onError:Ae=>{t({title:"Error",description:Ae.message,variant:"destructive"})}}),ae=Ot({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=Ot({mutationFn:async({id:Ae,direction:Ue})=>{const ut=q.findIndex(De=>De.id===Ae);if(Ue==="up"&&ut>0){const De=q[ut-1],Dt=q[ut];await G.from("community_private_groups").update({sort_order:Dt.sort_order}).eq("id",De.id),await G.from("community_private_groups").update({sort_order:De.sort_order}).eq("id",Dt.id)}else if(Ue==="down"&&uts.invalidateQueries({queryKey:["admin-private-groups"]})}),pe=Ot({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",C==null?void 0:C.id]})}}),be=Ot({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",C==null?void 0:C.id]})}}),ye=Ae=>{i(Ae),u({name:Ae.name,description:Ae.description||"",icon:Ae.icon||""}),o(!0)},we=()=>{i(null),u({name:"",description:"",icon:""}),o(!0)},Ne=Ae=>{_(Ae),j({name:Ae.name,description:Ae.description||"",icon:Ae.icon||""}),g(!0)},Ke=()=>{_(null),j({name:"",description:"",icon:""}),g(!0)},_e=Ae=>{A(Ae),L(""),N(!0)},Me=Ae=>V.some(Ue=>Ue.user_id===Ae),Te=Ae=>V.some(Ue=>Ue.brokerage_id===Ae),Fe=X.filter(Ae=>Ae.name.toLowerCase().includes(I.toLowerCase())||Ae.email.toLowerCase().includes(I.toLowerCase()));return e.jsx(Ms,{title:"Community Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{title:"Community Management",description:"Manage categories and private groups for community discussions"}),e.jsxs(ja,{value:r,onValueChange:n,children:[e.jsxs(va,{children:[e.jsx(Ns,{value:"categories",children:"Public Categories"}),e.jsxs(Ns,{value:"private-groups",children:[e.jsx(Fu,{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:we,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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-[50px]",children:"Order"}),e.jsx(jt,{className:"w-[80px]",children:"Icon"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(En,{children:$?e.jsx(js,{children:e.jsx(it,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):R.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"})}):R.map((Ae,Ue)=>e.jsxs(js,{children:[e.jsx(it,{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(it,{className:"text-2xl",children:Ae.icon||"📁"}),e.jsx(it,{className:"font-medium",children:Ae.name}),e.jsx(it,{className:"text-muted-foreground",children:Ae.description||"—"}),e.jsx(it,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ye(Ae),children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this category? Posts will be uncategorized.")&&Y.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(Ca,{className:"h-3 w-3"}),"Brokerage groups are created automatically and sync with brokerage names"]})]}),e.jsxs(K,{onClick:Ke,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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-[50px]",children:"Order"}),e.jsx(jt,{className:"w-[80px]",children:"Icon"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{className:"w-[120px]",children:"Members"}),e.jsx(jt,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(En,{children:U?e.jsx(js,{children:e.jsx(it,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):q.length===0?e.jsx(js,{children:e.jsx(it,{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(js,{children:[e.jsx(it,{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(it,{className:"text-2xl",children:Ae.icon||"🔒"}),e.jsx(it,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Ae.name,Ae.brokerage_id?e.jsxs(at,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(Ca,{className:"h-3 w-3 mr-1"}),"Auto-managed"]}):e.jsxs(at,{variant:"secondary",className:"text-xs",children:[e.jsx(Fu,{className:"h-3 w-3 mr-1"}),"Private"]})]})}),e.jsx(it,{className:"text-muted-foreground",children:Ae.description||"—"}),e.jsx(it,{children:e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>_e(Ae),children:[e.jsx(hr,{className:"h-4 w-4 mr-1"}),"Manage"]})}),e.jsx(it,{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(Ua,{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(vs,{open:a,onOpenChange:o,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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(Tr,{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(vs,{open:p,onOpenChange:g,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:v?"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=>j(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=>j(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(Tr,{value:b.description,onChange:Ae=>j(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:()=>g(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>ie.mutate({...b,id:v==null?void 0:v.id}),disabled:!b.name.trim(),children:v?"Save Changes":"Create Private Group"})]})]})]})}),e.jsx(vs,{open:w,onOpenChange:N,children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:["Manage Members: ",C==null?void 0:C.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ja,{defaultValue:"brokerages",children:[e.jsxs(va,{className:"w-full",children:[e.jsx(Ns,{value:"brokerages",className:"flex-1",children:"By Brokerage"}),e.jsx(Ns,{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(Fi,{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(zo,{checked:Te(Ae.id),onCheckedChange:()=>{C&&be.mutate({groupId:C.id,brokerageId:Ae.id,isMember:Te(Ae.id)})}}),e.jsx("span",{className:"font-medium",children:Ae.name})]}),e.jsxs(at,{variant:"secondary",children:[X.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(xn,{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(Fi,{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(zo,{checked:Me(Ae.id),onCheckedChange:()=>{C&&pe.mutate({groupId:C.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:()=>N(!1),children:"Done"})})]})]})})]})})},XAe=t=>{switch(t){case"academy_video":return e.jsx(dl,{className:"h-3 w-3"});case"template":return e.jsx(Sn,{className:"h-3 w-3"});case"toolbox":return e.jsx(cl,{className:"h-3 w-3"});case"newsletter":return e.jsx(E0,{className:"h-3 w-3"});case"social_swag":return e.jsx(mn,{className:"h-3 w-3"});default:return e.jsx(rn,{className:"h-3 w-3"})}},BFt=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}},$Ft=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}},qFt=()=>{const{toast:t}=Ea(),[s,r]=S.useState([]),[n,a]=S.useState([]),[o,l]=S.useState([]),[i,d]=S.useState(!0),[u,p]=S.useState(""),[g,v]=S.useState(null),[_,b]=S.useState([]),[j,w]=S.useState([]);S.useEffect(()=>{N()},[]);const N=async()=>{try{d(!0);const{data:V,error:X}=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(X)throw X;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 Y=[...new Set((se==null?void 0:se.map(ye=>ye.user_id))||[])],{data:de}=await G.from("profiles").select(` id, name, email, brokerages ( name ) `).in("id",Y),ie=new Map((de==null?void 0:de.map(ye=>[ye.id,ye]))||[]),ae=(V==null?void 0:V.map(ye=>{var we,Ne,Ke,_e;return{id:ye.id,user_id:ye.user_id,app_name:ye.app_name,launched_at:ye.launched_at,user_name:((we=ye.profiles)==null?void 0:we.name)||"Unknown",user_email:((Ne=ye.profiles)==null?void 0:Ne.email)||"Unknown",brokerage_name:((_e=(Ke=ye.profiles)==null?void 0:Ke.brokerages)==null?void 0:_e.name)||null}}))||[],le=(se==null?void 0:se.map(ye=>{var Ne;const we=ie.get(ye.user_id);return{id:ye.id,user_id:ye.user_id,resource_type:ye.resource_type,resource_id:ye.resource_id,resource_title:ye.resource_title,action_type:ye.action_type,created_at:ye.created_at,user_name:(we==null?void 0:we.name)||"Unknown",user_email:(we==null?void 0:we.email)||"Unknown",brokerage_name:((Ne=we==null?void 0:we.brokerages)==null?void 0:Ne.name)||null}}))||[];r(ae),a(le);const pe=new Map;ae.forEach(ye=>{if(!pe.has(ye.user_id))pe.set(ye.user_id,{user_id:ye.user_id,user_name:ye.user_name,user_email:ye.user_email,brokerage_name:ye.brokerage_name,last_activity_type:"app",last_activity_name:ye.app_name,last_activity_at:ye.launched_at,total_app_launches:1,total_content_views:0});else{const we=pe.get(ye.user_id);we.total_app_launches++,new Date(ye.launched_at)>new Date(we.last_activity_at)&&(we.last_activity_type="app",we.last_activity_name=ye.app_name,we.last_activity_at=ye.launched_at)}}),le.forEach(ye=>{if(!pe.has(ye.user_id))pe.set(ye.user_id,{user_id:ye.user_id,user_name:ye.user_name,user_email:ye.user_email,brokerage_name:ye.brokerage_name,last_activity_type:ye.resource_type,last_activity_name:ye.resource_title,last_activity_at:ye.created_at,total_app_launches:0,total_content_views:1});else{const we=pe.get(ye.user_id);we.total_content_views++,new Date(ye.created_at)>new Date(we.last_activity_at)&&(we.last_activity_type=ye.resource_type,we.last_activity_name=ye.resource_title,we.last_activity_at=ye.created_at)}});const be=Array.from(pe.values()).sort((ye,we)=>new Date(we.last_activity_at).getTime()-new Date(ye.last_activity_at).getTime());l(be)}catch(V){console.error("Error loading activity:",V),t({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{d(!1)}},C=V=>{v({id:V.user_id,name:V.user_name,email:V.user_email});const X=s.filter(te=>te.user_id===V.user_id),se=n.filter(te=>te.user_id===V.user_id);b(X),w(se)},A=()=>{v(null),b([]),w([])},{sortKey:I,sortDirection:L,handleSort:R,sortData:$}=qL("last_activity_at","desc"),q=o.filter(V=>{var se;if(!u)return!0;const X=u.toLowerCase();return V.user_name.toLowerCase().includes(X)||V.user_email.toLowerCase().includes(X)||((se=V.brokerage_name)==null?void 0:se.toLowerCase().includes(X))}),U=$(q,{user:V=>{var X;return((X=V.user_name)==null?void 0:X.toLowerCase())||""},brokerage:V=>{var X;return((X=V.brokerage_name)==null?void 0:X.toLowerCase())||""},last_activity_at:V=>new Date(V.last_activity_at).getTime(),apps:V=>V.total_app_launches,content:V=>V.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(Lt,{children:[e.jsx(zt,{children:"User Activity"}),e.jsx(yr,{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(xn,{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:V=>p(V.target.value),className:"pl-9"})]})}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{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(jt,{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(En,{children:U.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:6,className:"text-center text-muted-foreground",children:"No activity found"})}):U.map(V=>e.jsxs(js,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>C(V),children:[e.jsx(it,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:V.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:V.user_email})]})}),e.jsx(it,{children:V.brokerage_name?e.jsx(at,{variant:"outline",children:V.brokerage_name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(it,{children:e.jsx("div",{className:"flex items-center gap-2",children:V.last_activity_type==="app"?e.jsxs(at,{variant:"secondary",children:[e.jsx(rn,{className:"h-3 w-3 mr-1"}),V.last_activity_name]}):e.jsxs(at,{variant:"outline",className:"flex items-center gap-1",children:[XAe(V.last_activity_type),e.jsx("span",{className:"max-w-32 truncate",children:V.last_activity_name})]})})}),e.jsx(it,{className:"text-sm text-muted-foreground",children:Sd(new Date(V.last_activity_at),{addSuffix:!0})}),e.jsx(it,{className:"text-right",children:e.jsx(at,{variant:"outline",children:V.total_app_launches})}),e.jsx(it,{className:"text-right",children:e.jsx(at,{variant:"outline",children:V.total_content_views})})]},V.user_id))})]})})]})]}),e.jsx(vs,{open:!!g,onOpenChange:V=>!V&&A(),children:e.jsxs(ys,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{children:[g==null?void 0:g.name,"'s Activity"]}),e.jsx(Kr,{children:g==null?void 0:g.email})]}),e.jsxs(ja,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(va,{className:"grid w-full grid-cols-2",children:[e.jsxs(Ns,{value:"content",children:["Content (",j.length,")"]}),e.jsxs(Ns,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Resource"}),e.jsx(jt,{children:"Action"}),e.jsx(jt,{children:"Time"})]})}),e.jsx(En,{children:j.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement"})}):j.map(V=>e.jsxs(js,{children:[e.jsx(it,{children:e.jsxs(at,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[XAe(V.resource_type),BFt(V.resource_type)]})}),e.jsx(it,{className:"max-w-48",children:e.jsx("span",{className:"truncate block",children:V.resource_title})}),e.jsx(it,{children:e.jsx(at,{variant:"secondary",children:$Ft(V.action_type)})}),e.jsx(it,{className:"text-sm text-muted-foreground",children:Sd(new Date(V.created_at),{addSuffix:!0})})]},V.id))})]})})}),e.jsx(zs,{value:"apps",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"App"}),e.jsx(jt,{children:"Time"})]})}),e.jsx(En,{children:_.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches"})}):_.map(V=>e.jsxs(js,{children:[e.jsx(it,{children:e.jsx(at,{variant:"secondary",children:V.app_name})}),e.jsx(it,{className:"text-sm text-muted-foreground",children:Sd(new Date(V.launched_at),{addSuffix:!0})})]},V.id))})]})})})]})]})})]})},UFt=()=>{const{toast:t}=Ea(),[s,r]=S.useState({totalUsers:0,activeUsers:0,pendingUsers:0,totalBrokerages:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0,uniqueActiveThisWeek:0}),[n,a]=S.useState(!0);S.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}),g=new Date;g.setDate(g.getDate()-7);const{count:v}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",g.toISOString()),_=new Date;_.setMonth(_.getMonth()-1);const{count:b}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",_.toISOString()),{data:j}=await G.from("activity_logs").select("user_id").gte("launched_at",g.toISOString()),w=new Set(j==null?void 0:j.map(N=>N.user_id)).size;r({totalUsers:l||0,activeUsers:i||0,pendingUsers:d,totalBrokerages:u||0,totalLaunches:p||0,launchesThisWeek:v||0,launchesThisMonth:b||0,uniqueActiveThisWeek:w})}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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Active Users"}),e.jsx(fi,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(In,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Brokerages"}),e.jsx(Ca,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(Mm,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Launches This Week"}),e.jsx(Mm,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Launches This Month"}),e.jsx(Mm,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Active This Week"}),e.jsx(Sc,{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"})]})]})]})},QAe={event:"Event",template:"Template",academy_video:"Academy Video",resource_kit:"Resource Kit",newsletter:"Newsletter",social_swag:"Social Swag"},JAe={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 ZKe({brokerageOnly:t=!1,brokerageId:s}){const[r,n]=S.useState([]),[a,o]=S.useState(!0),[l,i]=S.useState(""),[d,u]=S.useState("all");S.useEffect(()=>{p()},[s]);const p=async()=>{o(!0);try{let R=[];if(t&&s){const{data:Y}=await G.from("profiles").select("id").eq("brokerage_id",s);if(R=(Y==null?void 0:Y.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 V=new Set;q==null||q.forEach(Y=>{V.add(Y.sender_id),V.add(Y.recipient_id)});const{data:X}=await G.from("profiles").select("id, name, email").in("id",Array.from(V)),se=new Map((X==null?void 0:X.map(Y=>[Y.id,Y]))||[]),te=(q==null?void 0:q.map(Y=>({...Y,sender:se.get(Y.sender_id),recipient:se.get(Y.recipient_id)})))||[];n(te)}catch(R){console.error("Error loading shares:",R)}finally{o(!1)}},{sortKey:g,sortDirection:v,handleSort:_,sortData:b}=qL("created_at","desc"),j=r.filter(R=>{var U,V;const $=l===""||R.resource_title.toLowerCase().includes(l.toLowerCase())||((U=R.sender)==null?void 0:U.name.toLowerCase().includes(l.toLowerCase()))||((V=R.recipient)==null?void 0:V.name.toLowerCase().includes(l.toLowerCase())),q=d==="all"||R.resource_type===d;return $&&q}),w=b(j,{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()}),N=r.length,C=new Set(r.map(R=>R.sender_id)).size,A=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(Lt,{className:"pb-2",children:e.jsx(gs,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(gs,{className:"h-8 w-16"})})]},$))}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6",children:e.jsx(gs,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{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:N})})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{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:C})})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Recipients Reached"}),e.jsx(Sc,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:A})})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Read Rate"}),e.jsx(Sn,{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(Lt,{children:e.jsx(zt,{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(at,{variant:"secondary",className:JAe[R],children:[QAe[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(Lt,{children:[e.jsx(zt,{children:"Share History"}),e.jsxs(yr,{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(xn,{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(tr,{value:d,onValueChange:u,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{placeholder:"Resource type"})}),e.jsxs(er,{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(Fi,{className:"h-[400px]",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(el,{sortKey:"resource",currentSortKey:g,currentDirection:v,onSort:_,children:"Resource"}),e.jsx(el,{sortKey:"type",currentSortKey:g,currentDirection:v,onSort:_,children:"Type"}),e.jsx(el,{sortKey:"sender",currentSortKey:g,currentDirection:v,onSort:_,children:"Sender"}),e.jsx(el,{sortKey:"recipient",currentSortKey:g,currentDirection:v,onSort:_,children:"Recipient"}),e.jsx(el,{sortKey:"status",currentSortKey:g,currentDirection:v,onSort:_,children:"Status"}),e.jsx(el,{sortKey:"created_at",currentSortKey:g,currentDirection:v,onSort:_,children:"Date"})]})}),e.jsx(En,{children:w.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No shares found"})}):w.map(R=>{var $,q;return e.jsxs(js,{children:[e.jsx(it,{className:"font-medium max-w-[200px] truncate",children:R.resource_title}),e.jsx(it,{children:e.jsx(at,{variant:"secondary",className:JAe[R.resource_type],children:QAe[R.resource_type]})}),e.jsx(it,{children:(($=R.sender)==null?void 0:$.name)||"Unknown"}),e.jsx(it,{children:((q=R.recipient)==null?void 0:q.name)||"Unknown"}),e.jsx(it,{children:e.jsx(at,{variant:R.is_read?"default":"outline",children:R.is_read?"Read":"Unread"})}),e.jsx(it,{className:"text-muted-foreground",children:ws(new Date(R.created_at),"MMM d, yyyy")})]},R.id)})})]})})]})]})]})}const Wme={academy_video:{label:"Academy Videos",icon:Nn,color:"bg-purple-100 text-purple-800",actionLabel:"Watched",actionIcon:ya},template:{label:"Templates",icon:i0,color:"bg-blue-100 text-blue-800",actionLabel:"Accessed",actionIcon:bm},toolbox:{label:"Toolkit",icon:Kx,color:"bg-amber-100 text-amber-800",actionLabel:"Downloaded",actionIcon:gi},newsletter:{label:"Newsletters",icon:br,color:"bg-emerald-100 text-emerald-800",actionLabel:"Clicked",actionIcon:bm},social_swag:{label:"Social Swag",icon:Rl,color:"bg-pink-100 text-pink-800",actionLabel:"Accessed",actionIcon:bm},event:{label:"Events",icon:on,color:"bg-cyan-100 text-cyan-800",actionLabel:"Registered",actionIcon:bm}};function eEe(t){return t.resource_type==="toolbox"?t.total_downloads:t.total_clicks}function VFt(t,s){return t==="toolbox"?s.downloads:s.clicks}function HFt(){var R;const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(null),l=S.useRef(null),{sortKey:i,sortDirection:d,handleSort:u,sortData:p}=qL("total_views","desc");S.useEffect(()=>{g()},[]);const g=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)}},v=$=>{o(q=>{const U=q===$?null:$;return requestAnimationFrame(()=>{var V;(V=l.current)==null||V.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(Lt,{className:"pb-2",children:e.jsx(gs,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(gs,{className:"h-8 w-16"})})]},q))}),e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8",children:e.jsx(gs,{className:"h-64 w-full"})})})]});const _=t.reduce(($,q)=>$+q.total_views,0),b=t.reduce(($,q)=>$+q.total_clicks,0),j=t.reduce(($,q)=>$+q.total_downloads,0),w=t.length,N=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,$),{}),C=a?t.filter($=>$.resource_type===a):t,A=p(C,{asset:$=>{var q;return((q=$.resource_title)==null?void 0:q.toLowerCase())||""},type:$=>$.resource_type,views:$=>$.total_views,actions:$=>eEe($),unique_users:$=>$.unique_users,last_activity:$=>$.last_engaged_at?new Date($.last_engaged_at).getTime():0}),I=a?Wme[a]||{label:a,icon:ya,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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Views"}),e.jsx(ya,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Clicks"}),e.jsx(bm,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Downloads"}),e.jsx(gi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PDF downloads"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Assets Tracked"}),e.jsx(Sc,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:w}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique content items"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(bm,{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+j)/_*100):0,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Of views → actions"})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{className:"text-sm font-medium",children:"Engagement by Content Type"}),e.jsx(yr,{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(N).map(([$,q])=>{const U=Wme[$]||{label:$,icon:ya,color:"bg-muted text-muted-foreground",actionIcon:bm},V=U.icon,X=a===$;return e.jsxs("button",{type:"button",onClick:()=>v($),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors cursor-pointer ${X?"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(V,{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(ya,{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"})," ",VFt($,q)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hr,{className:"h-3 w-3"})," ",q.uniqueUsers]})]})]}),e.jsxs(at,{variant:"secondary",className:"text-[10px]",children:[q.assets," items"]})]},$)})})})]}),e.jsx("div",{ref:l,children:e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{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(yr,{children:a?`${C.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(Ka,{className:"h-3.5 w-3.5"}),"Show All"]})]})}),e.jsx(Oe,{children:C.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(Fi,{className:"h-[400px]",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{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(En,{children:A.map(($,q)=>{const U=Wme[$.resource_type]||{label:$.resource_type,color:"bg-muted text-muted-foreground"};return e.jsxs(js,{children:[e.jsx(it,{className:"text-muted-foreground text-xs",children:q+1}),e.jsx(it,{children:e.jsx("p",{className:"font-medium text-sm truncate max-w-[250px]",children:$.resource_title})}),!a&&e.jsx(it,{children:e.jsx(at,{className:`text-[10px] ${U.color}`,children:U.label})}),e.jsx(it,{className:"text-right font-medium",children:$.total_views}),e.jsx(it,{className:"text-right font-medium",children:eEe($)}),e.jsx(it,{className:"text-right",children:$.unique_users}),e.jsx(it,{className:"text-xs text-muted-foreground",children:$.last_engaged_at?Sd(new Date($.last_engaged_at),{addSuffix:!0}):"—"})]},`${$.resource_type}-${$.resource_id}`)})})]})})})]})})]})}const WFt=()=>e.jsx(Ms,{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(ja,{defaultValue:"analytics",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsx(Ns,{value:"analytics",children:"Analytics"}),e.jsx(Ns,{value:"content",children:"Content"}),e.jsx(Ns,{value:"activity",children:"Activity"}),e.jsx(Ns,{value:"shares",children:"Shares"})]}),e.jsx(zs,{value:"analytics",className:"space-y-4",children:e.jsx(UFt,{})}),e.jsx(zs,{value:"content",className:"space-y-4",children:e.jsx(HFt,{})}),e.jsx(zs,{value:"activity",className:"space-y-4",children:e.jsx(qFt,{})}),e.jsx(zs,{value:"shares",className:"space-y-4",children:e.jsx(ZKe,{})})]})]})});function GFt(){const t=ns(),[s,r]=S.useState(!1),[n,a]=S.useState(null),[o,l]=S.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),[i,d]=S.useState(null),[u,p]=S.useState(""),[g,v]=S.useState([]),[_,b]=S.useState([]),[j,w]=S.useState([]),[N,C]=S.useState(!1),[A,I]=S.useState(null),[L,R]=S.useState(""),{data:$,isLoading:q}=Ct({queryKey:["brokerage-resources"],queryFn:async()=>{const{data:De,error:Dt}=await G.from("brokerage_resources").select("*").order("publish_date",{ascending:!1});if(Dt)throw Dt;return De}}),{data:U}=Ct({queryKey:["brokerage-resource-pdfs"],queryFn:async()=>{const{data:De,error:Dt}=await G.from("brokerage_resource_pdfs").select("*").order("sort_order",{ascending:!0});if(Dt)throw Dt;return De}}),{data:V}=Ct({queryKey:["brokerage-resource-videos"],queryFn:async()=>{const{data:De,error:Dt}=await G.from("brokerage_resource_videos").select("*").order("sort_order",{ascending:!0});if(Dt)throw Dt;return De}}),{data:X}=Ct({queryKey:["brokerage-resource-links"],queryFn:async()=>{const{data:De,error:Dt}=await G.from("brokerage_resource_links").select("*").order("sort_order",{ascending:!0});if(Dt)throw Dt;return De}}),{data:se,isLoading:te}=Ct({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:De,error:Dt}=await G.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(Dt)throw Dt;return De}}),Y=()=>{l({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),d(null),p(""),v([]),b([]),w([]),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 Dt=(U==null?void 0:U.filter(nt=>nt.resource_id===De.id))||[];v(Dt.map(nt=>({id:nt.id,name:nt.name,file_url:nt.file_url,file_size:nt.file_size,sort_order:nt.sort_order})));const he=(V==null?void 0:V.filter(nt=>nt.resource_id===De.id))||[];b(he.map(nt=>({id:nt.id,title:nt.title,video_url:nt.video_url,sort_order:nt.sort_order})));const Ve=(X==null?void 0:X.filter(nt=>nt.resource_id===De.id))||[];w(Ve.map(nt=>({id:nt.id,title:nt.title,canva_share_link:nt.canva_share_link,sort_order:nt.sort_order}))),r(!0)},ie=De=>{var he;const Dt=(he=De.target.files)==null?void 0:he[0];Dt&&(d(Dt),p(URL.createObjectURL(Dt)))},ae=()=>{v([...g,{name:"",file_url:"",sort_order:g.length}])},le=De=>{v(g.filter((Dt,he)=>he!==De))},pe=(De,Dt,he)=>{const Ve=[...g];if(Dt==="file"&&he instanceof File){const nt=he.name.replace(/\.[^/.]+$/,"");Ve[De]={...Ve[De],file:he,file_size:he.size,name:Ve[De].name||nt}}else Ve[De]={...Ve[De],[Dt]:he};v(Ve)},be=()=>{b([..._,{title:"",video_url:"",sort_order:_.length}])},ye=De=>{b(_.filter((Dt,he)=>he!==De))},we=(De,Dt,he)=>{const Ve=[..._];Dt==="file"&&he instanceof File?Ve[De]={...Ve[De],file:he}:Ve[De]={...Ve[De],[Dt]:he},b(Ve)},Ne=()=>{w([...j,{title:"",canva_share_link:"",sort_order:j.length}])},Ke=De=>{w(j.filter((Dt,he)=>he!==De))},_e=(De,Dt,he)=>{const Ve=[...j];Ve[De]={...Ve[De],[Dt]:he},w(Ve)},Me=async(De,Dt)=>{try{const he=await G.functions.invoke("bunny-upload",{body:{action:"create",title:De.name}});if(he.error)throw he.error;const{videoId:Ve,uploadUrl:nt,libraryId:Qe}=he.data,ke=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Ve,libraryId:Qe}});if(ke.error)throw ke.error;const{uploadUrl:ot,apiKey:qe}=ke.data,lt=new XMLHttpRequest;return lt.open("PUT",ot,!0),lt.setRequestHeader("AccessKey",qe),lt.upload.onprogress=We=>{if(We.lengthComputable){const Ye=Math.round(We.loaded/We.total*100),mt=[..._];mt[Dt]={...mt[Dt],uploadProgress:Ye},b(mt)}},await new Promise((We,Ye)=>{lt.onload=()=>lt.status>=200&<.status<300?We():Ye(new Error("Upload failed")),lt.onerror=()=>Ye(new Error("Upload failed")),lt.send(De)}),`https://iframe.mediadelivery.net/embed/${Qe}/${Ve}`}catch(he){throw console.error("Bunny upload error:",he),he}},Te=Ot({mutationFn:async De=>{const{data:Dt,error:he}=await G.from("brokerage_resource_categories").insert({name:De,sort_order:(se==null?void 0:se.length)||0}).select().single();if(he)throw he;return Dt},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=Ot({mutationFn:async()=>{C(!0);let De=(n==null?void 0:n.preview_image_url)||null;if(i){const Ve=i.name.split(".").pop(),nt=`${Date.now()}.${Ve}`,{error:Qe}=await G.storage.from("brokerage-resources").upload(`previews/${nt}`,i);if(Qe)throw Qe;const{data:ke}=G.storage.from("brokerage-resources").getPublicUrl(`previews/${nt}`);De=ke.publicUrl}const Dt={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 he;if(n){const{error:Ve}=await G.from("brokerage_resources").update(Dt).eq("id",n.id);if(Ve)throw Ve;he=n.id;const nt=(U==null?void 0:U.filter(Ze=>Ze.resource_id===n.id).map(Ze=>Ze.id))||[],Qe=g.filter(Ze=>Ze.id).map(Ze=>Ze.id),ke=nt.filter(Ze=>!Qe.includes(Ze));ke.length>0&&await G.from("brokerage_resource_pdfs").delete().in("id",ke);const ot=(V==null?void 0:V.filter(Ze=>Ze.resource_id===n.id).map(Ze=>Ze.id))||[],qe=_.filter(Ze=>Ze.id).map(Ze=>Ze.id),lt=ot.filter(Ze=>!qe.includes(Ze));lt.length>0&&await G.from("brokerage_resource_videos").delete().in("id",lt);const We=(X==null?void 0:X.filter(Ze=>Ze.resource_id===n.id).map(Ze=>Ze.id))||[],Ye=j.filter(Ze=>Ze.id).map(Ze=>Ze.id),mt=We.filter(Ze=>!Ye.includes(Ze));mt.length>0&&await G.from("brokerage_resource_links").delete().in("id",mt)}else{const{data:Ve,error:nt}=await G.from("brokerage_resources").insert(Dt).select().single();if(nt)throw nt;he=Ve.id}for(let Ve=0;Ve{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),Y(),C(!1)},onError:De=>{fe.error("Failed to save resource: "+De.message),C(!1)}}),Ae=Ot({mutationFn:async De=>{const{error:Dt}=await G.from("brokerage_resources").delete().eq("id",De);if(Dt)throw Dt},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 Dt=(U==null?void 0:U.filter(nt=>nt.resource_id===De).length)||0,he=(V==null?void 0:V.filter(nt=>nt.resource_id===De).length)||0,Ve=(X==null?void 0:X.filter(nt=>nt.resource_id===De).length)||0;return{pdfCount:Dt,videoCount:he,linkCount:Ve}};return e.jsx(Ms,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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:()=>{Y(),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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Category"}),e.jsx(jt,{children:"Content"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:q?e.jsx(js,{children:e.jsx(it,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):($==null?void 0:$.length)===0?e.jsx(js,{children:e.jsx(it,{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:Dt,videoCount:he,linkCount:Ve}=ut(De.id),nt=se==null?void 0:se.find(Qe=>Qe.id===De.category_id);return e.jsxs(js,{children:[e.jsx(it,{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(eh,{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(it,{children:nt?e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-muted",children:nt.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(it,{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(Sn,{className:"h-3.5 w-3.5"}),Dt]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Nn,{className:"h-3.5 w-3.5"}),he]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Io,{className:"h-3.5 w-3.5"}),Ve]})]})}),e.jsx(it,{children:ws(new Date(De.publish_date),"MMM d, yyyy")}),e.jsx(it,{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(it,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{const Qe=(U==null?void 0:U.filter(qe=>qe.resource_id===De.id))||[],ke=(V==null?void 0:V.filter(qe=>qe.resource_id===De.id))||[],ot=(X==null?void 0:X.filter(qe=>qe.resource_id===De.id))||[];I({...De,pdfs:Qe,videos:ke,links:ot})},children:e.jsx(ya,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>de(De),children:e.jsx(Ua,{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(vs,{open:s,onOpenChange:r,children:e.jsxs(ys,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(eh,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(Re,{type:"file",accept:"image/*",onChange:ie})]})]}),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(Im,{className:"h-4 w-4"}),"Category"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(tr,{value:o.category_id,onValueChange:De=>l({...o,category_id:De}),children:[e.jsx(Js,{className:"flex-1",children:e.jsx(sr,{placeholder:"Select a category"})}),e.jsx(er,{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(Zg,{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(Sn,{className:"h-4 w-4"}),"PDF Documents (",g.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"]})]}),g.map((De,Dt)=>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:he=>pe(Dt,"name",he.target.value),className:"flex-1"}),e.jsx(Re,{type:"file",accept:".pdf",onChange:he=>{var nt;const Ve=(nt=he.target.files)==null?void 0:nt[0];Ve&&pe(Dt,"file",Ve)},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(Dt),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Dt))]}),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,Dt)=>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:he=>we(Dt,"title",he.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>ye(Dt),children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsx(Re,{type:"file",accept:"video/*",onChange:he=>{var nt;const Ve=(nt=he.target.files)==null?void 0:nt[0];Ve&&we(Dt,"file",Ve)}}),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"})]},Dt))]}),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(Io,{className:"h-4 w-4"}),"Canva Links (",j.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"]})]}),j.map((De,Dt)=>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:he=>_e(Dt,"title",he.target.value),className:"flex-1"}),e.jsx(Re,{placeholder:"Canva Share Link",value:De.canva_share_link,onChange:he=>_e(Dt,"canva_share_link",he.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>Ke(Dt),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Dt))]}),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||N,children:Fe.isPending||N?"Saving...":n?"Update":"Create"})]})]})]})}),e.jsx(vs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:A==null?void 0:A.title})}),A&&e.jsxs("div",{className:"space-y-4",children:[A.preview_image_url&&e.jsx("img",{src:A.preview_image_url,alt:A.title,className:"w-full h-48 object-cover rounded-lg"}),A.description&&e.jsx("p",{className:"text-muted-foreground",children:A.description}),A.pdfs&&A.pdfs.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Sn,{className:"h-4 w-4"}),"PDF Documents (",A.pdfs.length,")"]}),e.jsx("div",{className:"space-y-1",children:A.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))})]}),A.videos&&A.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 (",A.videos.length,")"]}),e.jsx("div",{className:"space-y-2",children:A.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))})]}),A.links&&A.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Io,{className:"h-4 w-4"}),"Canva Links (",A.links.length,")"]}),e.jsx("div",{className:"space-y-1",children:A.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 YKe=[{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 KFt(){const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(!1),[l,i]=S.useState(!1),[d,u]=S.useState(null),[p,g]=S.useState(!1),[v,_]=S.useState(!1),[b,j]=S.useState(""),[w,N]=S.useState(""),[C,A]=S.useState(""),[I,L]=S.useState(""),[R,$]=S.useState("Learn More"),[q,U]=S.useState("top"),[V,X]=S.useState(""),[se,te]=S.useState(!0),[Y,de]=S.useState(""),[ie,ae]=S.useState("");S.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)}},pe=()=>{j(""),N(""),A(""),L(""),$("Learn More"),U("top"),X(""),te(!0),de(""),ae(""),u(null)},be=Te=>{u(Te),j(Te.title),N(Te.description||""),A(Te.image_url),L(Te.link_url||""),$(Te.link_text||"Learn More"),U(Te.placement),X(Te.section_after||""),te(Te.is_active),de(Te.start_date?ws(new Date(Te.start_date),"yyyy-MM-dd'T'HH:mm"):""),ae(Te.end_date?ws(new Date(Te.end_date),"yyyy-MM-dd'T'HH:mm"):""),o(!0)},ye=async Te=>{var Ae;const Fe=(Ae=Te.target.files)==null?void 0:Ae[0];if(Fe){g(!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:Dt}}=G.storage.from("banner-images").getPublicUrl(ut);A(Dt),fe.success("Image uploaded successfully")}catch(Ue){fe.error("Failed to upload image: "+Ue.message)}finally{g(!1)}}},we=async()=>{if(!b.trim()||!C){fe.error("Please fill in required fields (title and image)");return}_(!0);try{const Te={title:b.trim(),description:w.trim()||null,image_url:C,link_url:I.trim()||null,link_text:R.trim()||"Learn More",placement:q,section_after:q==="between"?V:null,is_active:se,start_date:Y?new Date(Y).toISOString():null,end_date:ie?new Date(ie).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),pe(),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)}},Ke=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)}},_e=t.filter(Te=>Te.placement==="top"),Me=t.filter(Te=>Te.placement==="between");return r?e.jsx(Ms,{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(Ms,{title:"Dashboard Management",description:"Configure dashboard modules and banners",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Jo,{className:"h-5 w-5"}),"Hero Banners (Top of Dashboard)"]}),e.jsx(yr,{children:"These banners appear in a rotating carousel at the top of the dashboard"})]}),e.jsxs(vs,{open:a&&q==="top",onOpenChange:Te=>{Te||pe(),o(Te),Te&&U("top")},children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{onClick:()=>{pe(),U("top")},children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Add Hero Banner"]})}),e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{children:[d?"Edit":"Create"," Banner"]}),e.jsx(Kr,{children:"Configure the banner's content and display settings"})]}),e.jsx(tEe,{title:b,setTitle:j,description:w,setDescription:N,imageUrl:C,linkUrl:I,setLinkUrl:L,linkText:R,setLinkText:$,placement:q,setPlacement:U,sectionAfter:V,setSectionAfter:X,isActive:se,setIsActive:te,startDate:Y,setStartDate:de,endDate:ie,setEndDate:ae,handleImageUpload:ye,uploading:p,showPlacementOptions:!1}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),pe()},children:"Cancel"}),e.jsx(K,{onClick:we,disabled:v,children:v?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Oe,{children:_e.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:_e.map(Te=>e.jsx(sEe,{banner:Te,onEdit:()=>be(Te),onDelete:()=>{u(Te),i(!0)},onToggleActive:()=>Ke(Te)},Te.id))})})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Jo,{className:"h-5 w-5"}),"Section Banners"]}),e.jsx(yr,{children:"These banners appear between dashboard content sections"})]}),e.jsxs(vs,{open:a&&q==="between",onOpenChange:Te=>{Te||pe(),o(Te),Te&&U("between")},children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{onClick:()=>{pe(),U("between")},children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Add Section Banner"]})}),e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{children:[d?"Edit":"Create"," Section Banner"]}),e.jsx(Kr,{children:"Configure where this banner appears between sections"})]}),e.jsx(tEe,{title:b,setTitle:j,description:w,setDescription:N,imageUrl:C,linkUrl:I,setLinkUrl:L,linkText:R,setLinkText:$,placement:q,setPlacement:U,sectionAfter:V,setSectionAfter:X,isActive:se,setIsActive:te,startDate:Y,setStartDate:de,endDate:ie,setEndDate:ae,handleImageUpload:ye,uploading:p,showPlacementOptions:!0}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),pe()},children:"Cancel"}),e.jsx(K,{onClick:we,disabled:v,children:v?"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(sEe,{banner:Te,onEdit:()=>be(Te),onDelete:()=>{u(Te),i(!0)},onToggleActive:()=>Ke(Te),showSection:!0},Te.id))})})]})]}),e.jsx(vs,{open:l,onOpenChange:i,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Ne,children:"Delete"})]})]})})]})}function tEe({title:t,setTitle:s,description:r,setDescription:n,imageUrl:a,linkUrl:o,setLinkUrl:l,linkText:i,setLinkText:d,placement:u,setPlacement:p,sectionAfter:g,setSectionAfter:v,isActive:_,setIsActive:b,startDate:j,setStartDate:w,endDate:N,setEndDate:C,handleImageUpload:A,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(Tr,{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:A,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(tr,{value:g,onValueChange:v,children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select section placement..."})}),e.jsx(er,{children:YKe.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:j,onChange:R=>w(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:N,onChange:R=>C(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 sEe({banner:t,onEdit:s,onDelete:r,onToggleActive:n,showSection:a=!1}){var l;const o=(l=YKe.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(Ru,{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(at,{variant:"secondary",children:"Inactive"}),t.start_date&&new Date(t.start_date)>new Date&&e.jsx(at,{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(rn,{className:"h-4 w-4"})})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:n,children:t.is_active?e.jsx(ya,{className:"h-4 w-4"}):e.jsx(Tm,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:s,children:e.jsx(Ua,{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 oR={open:{label:"Open",icon:In,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:pc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:fi,color:"bg-green-500"},closed:{label:"Closed",icon:wc,color:"bg-muted-foreground"}},rEe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function ZFt(){var R,$;const{user:t}=Gs(),s=ns(),[r,n]=S.useState(null),[a,o]=S.useState(""),[l,i]=S.useState("all"),[d,u]=S.useState("all"),[p,g]=S.useState(!1),{data:v=[],isLoading:_}=Ct({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:V}=await q;if(V)throw V;return U}}),{data:b=[]}=Ct({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 V=q.map(ie=>ie.user_id),{data:X,error:se}=await G.from("profiles").select("id, name, email").in("id",V);if(se)throw se;const{data:te,error:Y}=await G.from("support_notification_settings").select("user_id, receive_notifications");if(Y)throw Y;const de=new Map((te==null?void 0:te.map(ie=>[ie.user_id,ie.receive_notifications]))||[]);return X.map(ie=>({...ie,receives_notifications:de.get(ie.id)||!1}))}}),{data:j=[]}=Ct({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}),w=Ot({mutationFn:async({userId:q,enabled:U})=>{const{data:V}=await G.from("support_notification_settings").select("id").eq("user_id",q).maybeSingle();if(V){const{error:X}=await G.from("support_notification_settings").update({receive_notifications:U}).eq("user_id",q);if(X)throw X}else{const{error:X}=await G.from("support_notification_settings").insert({user_id:q,receive_notifications:U});if(X)throw X}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-users-notifications"]}),fe.success("Notification settings updated")},onError:()=>{fe.error("Failed to update settings")}}),N=Ot({mutationFn:async({ticketId:q,status:U})=>{const{error:V}=await G.from("support_tickets").update({status:U}).eq("id",q);if(V)throw V},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),r&&n({...r,status:r.status}),fe.success("Status updated")},onError:()=>{fe.error("Failed to update status")}}),C=Ot({mutationFn:async({ticketId:q,assignedTo:U})=>{const{error:V}=await G.from("support_tickets").update({assigned_to:U}).eq("id",q);if(V)throw V},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),fe.success("Ticket assigned")},onError:()=>{fe.error("Failed to assign ticket")}}),A=Ot({mutationFn:async q=>{var V,X;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:(V=r.profiles)==null?void 0:V.email,userName:(X=r.profiles)==null?void 0:X.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()&&A.mutate(a)};S.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=v.filter(q=>q.status==="open").length;return r?(oR[r.status].icon,e.jsx(Ms,{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(Ka,{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(at,{variant:"secondary",children:rEe[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(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm",children:"Status"})}),e.jsx(Oe,{children:e.jsxs(tr,{value:r.status,onValueChange:q=>{N.mutate({ticketId:r.id,status:q}),n({...r,status:q})},children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{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(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm",children:"Assigned To"})}),e.jsx(Oe,{children:e.jsxs(tr,{value:r.assigned_to||"unassigned",onValueChange:q=>{const U=q==="unassigned"?null:q;C.mutate({ticketId:r.id,assignedTo:U}),n({...r,assigned_to:U})},children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Unassigned"})}),e.jsxs(er,{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(Lt,{children:e.jsxs(yr,{children:["Created on ",ws(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(Lt,{children:e.jsx(zt,{className:"text-lg",children:"Conversation"})}),e.jsxs(Oe,{children:[e.jsx(Fi,{className:"h-[300px] pr-4",children:j.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:j.map(q=>{var U,V;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)`:((V=q.profiles)==null?void 0:V.name)||"User"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ws(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(sc,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Tr,{placeholder:"Type your reply...",value:a,onChange:q=>o(q.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:I,disabled:!a.trim()||A.isPending,className:"self-end",children:e.jsx(Ta,{className:"h-4 w-4"})})]})]})]})]})})):e.jsx(Ms,{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(at,{variant:"destructive",className:"ml-2",children:[L," open"]})]})]}),e.jsxs(vs,{open:p,onOpenChange:g,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(Fl,{className:"h-4 w-4 mr-2"}),"Notification Settings"]})}),e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(cf,{className:"h-4 w-4 text-primary"}):e.jsx(Z1,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Br,{checked:q.receives_notifications,onCheckedChange:U=>w.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(ja,{value:l,onValueChange:i,className:"w-auto",children:e.jsxs(va,{children:[e.jsx(Ns,{value:"all",children:"All"}),e.jsx(Ns,{value:"open",children:"Open"}),e.jsx(Ns,{value:"in_progress",children:"In Progress"}),e.jsx(Ns,{value:"resolved",children:"Resolved"}),e.jsx(Ns,{value:"closed",children:"Closed"})]})}),e.jsxs(tr,{value:d,onValueChange:u,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{placeholder:"All Categories"})}),e.jsxs(er,{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..."}):v.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"text-center py-12",children:[e.jsx(pc,{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:v.map(q=>{var V,X;const U=oR[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(at,{variant:"outline",className:"text-xs",children:rEe[q.category]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(V=q.profiles)==null?void 0:V.name," • ",ws(new Date(q.created_at),"MMM d, yyyy")]}),q.assigned_to&&e.jsxs(at,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Yi,{className:"h-3 w-3"}),((X=b.find(se=>se.id===q.assigned_to))==null?void 0:X.name)||"Assigned"]})]})]}),e.jsxs(at,{className:oR[q.status].color,children:[e.jsx(U,{className:"h-3 w-3 mr-1"}),oR[q.status].label]})]})})},q.id)})})})]})]})})}const YFt=$u.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 XFt({content:t,onChange:s,variables:r}){const n=AWe({extensions:[OWe,WWe.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),GWe.configure({types:["heading","paragraph"]}),KWe,YFt],content:t,onUpdate:({editor:l})=>{s(l.getHTML())}});S.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(n5,{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(u5,{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(qh,{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(M0,{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(t5,{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(e5,{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(s5,{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(Io,{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(Xk,{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(w5,{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(_5,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),r.length>0&&e.jsxs(yu,{children:[e.jsx(vu,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(OP,{className:"h-4 w-4"}),"Insert Variable"]})}),e.jsx(Wd,{align:"end",className:"w-64",children:r.map(l=>e.jsxs(Da,{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(MWe,{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(at,{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 QFt(){const t=ns(),[s,r]=S.useState(null),[n,a]=S.useState(null),[o,l]=S.useState(""),[i,d]=S.useState(""),[u,p]=S.useState(""),[g,v]=S.useState(!0),[_,b]=S.useState("visual"),{data:j,isLoading:w}=Ct({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||[]}))}}),N=Ot({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)}}),C=L=>{r(L),l(L.subject),d(L.body_html),p(L.description||""),v(L.is_active),b("visual")},A=()=>{s&&N.mutate({id:s.id,subject:o,body_html:i,description:u,is_active:g})},I=(L,R)=>{let $=L;return R.forEach(q=>{const U=`{{${q.key}}}`,V=`[${q.label}]`;$=$.replace(new RegExp(U.replace(/[{}]/g,"\\$&"),"g"),V)}),$};return s?e.jsxs(Ms,{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(Ka,{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(ya,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{onClick:A,disabled:N.isPending,children:[e.jsx(zu,{className:"h-4 w-4 mr-2"}),N.isPending?"Saving...":"Save Changes"]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),s.name]}),e.jsxs(yr,{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:g,onCheckedChange:v})]})]})}),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(Tr,{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(ja,{value:_,onValueChange:L=>b(L),children:e.jsxs(va,{className:"h-8",children:[e.jsxs(Ns,{value:"visual",className:"text-xs px-3 h-6",children:[e.jsx(nN,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(Ns,{value:"html",className:"text-xs px-3 h-6",children:[e.jsx(Xk,{className:"h-3 w-3 mr-1"}),"HTML"]})]})})]}),_==="visual"?e.jsx(XFt,{content:i,onChange:d,variables:s.available_variables}):e.jsx(Tr,{value:i,onChange:L=>d(L.target.value),className:"font-mono text-sm min-h-[400px]",placeholder:"HTML email body"})]})]})]})]}),e.jsx(vs,{open:!!n,onOpenChange:()=>a(null),children:e.jsxs(ys,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(Ms,{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"})]}),w?e.jsx("div",{className:"grid gap-4",children:[...Array(4)].map((L,R)=>e.jsx(Ee,{children:e.jsxs(Lt,{children:[e.jsx(gs,{className:"h-5 w-48"}),e.jsx(gs,{className:"h-4 w-96"})]})},R))}):e.jsx("div",{className:"grid gap-4",children:j==null?void 0:j.map(L=>e.jsxs(Ee,{className:"hover:shadow-md transition-shadow",children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(zt,{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(at,{variant:"secondary",children:"Inactive"})]}),e.jsx(yr,{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(ya,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{size:"sm",onClick:()=>C(L),children:[e.jsx(Dc,{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(at,{variant:"outline",className:"font-mono text-xs",children:`{{${R.key}}}`},R.key))})]})]})})]},L.id))}),e.jsx(vs,{open:!!n&&!s,onOpenChange:()=>a(null),children:e.jsxs(ys,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{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 JFt(){const t=ns(),[s,r]=S.useState("templates"),[n,a]=S.useState(null),[o,l]=S.useState(null),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[g,v]=S.useState({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),[_,b]=S.useState({name:"",description:"",icon:"📧"}),{data:j=[]}=Ct({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:V,error:X}=await G.from("email_template_categories").select("*").order("sort_order");if(X)throw X;return V}}),{data:w=[],isLoading:N}=Ct({queryKey:["agent-email-templates-admin"],queryFn:async()=>{const{data:V,error:X}=await G.from("agent_email_templates").select("*, category:email_template_categories(*)").order("sort_order");if(X)throw X;return V}}),C=Ot({mutationFn:async V=>{const X={title:V.title,subject:V.subject,body:V.body,description:V.description||null,tone:V.tone||null,category_id:V.category_id||null,is_active:V.is_active};if(V.id){const{error:se}=await G.from("agent_email_templates").update(X).eq("id",V.id);if(se)throw se}else{const{error:se}=await G.from("agent_email_templates").insert(X);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")}),A=Ot({mutationFn:async V=>{const{error:X}=await G.from("agent_email_templates").delete().eq("id",V);if(X)throw X},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),fe.success("Template deleted")}}),I=Ot({mutationFn:async V=>{const X={name:V.name,description:V.description||null,icon:V.icon};if(V.id){const{error:se}=await G.from("email_template_categories").update(X).eq("id",V.id);if(se)throw se}else{const se=j.length>0?Math.max(...j.map(Y=>Y.sort_order))+1:0,{error:te}=await G.from("email_template_categories").insert({...X,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=Ot({mutationFn:async V=>{const{error:X}=await G.from("email_template_categories").delete().eq("id",V);if(X)throw X},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),fe.success("Category deleted")}}),R=()=>{a(null),v({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),d(!0)},$=V=>{a(V),v({title:V.title,subject:V.subject,body:V.body,description:V.description||"",tone:V.tone||"",category_id:V.category_id||"",is_active:V.is_active}),d(!0)},q=()=>{l(null),b({name:"",description:"",icon:"📧"}),p(!0)},U=V=>{l(V),b({name:V.name,description:V.description||"",icon:V.icon}),p(!0)};return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(_u,{title:"Agent Email Templates",description:"Manage email templates that agents use when composing emails from Mission Control."}),e.jsxs(ja,{value:s,onValueChange:r,children:[e.jsxs(va,{children:[e.jsxs(Ns,{value:"templates",className:"gap-2",children:[e.jsx(br,{className:"h-4 w-4"})," Templates"]}),e.jsxs(Ns,{value:"categories",className:"gap-2",children:[e.jsx($h,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Template"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Category"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Tone"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:N?e.jsx(js,{children:e.jsx(it,{colSpan:5,className:"text-center py-8",children:e.jsx(As,{className:"h-6 w-6 animate-spin mx-auto"})})}):w.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No templates yet. Create your first one!"})}):w.map(V=>e.jsxs(js,{children:[e.jsx(it,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:V.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[300px]",children:V.subject})]})}),e.jsx(it,{className:"hidden md:table-cell",children:V.category?e.jsxs(at,{variant:"outline",className:"gap-1",children:[V.category.icon," ",V.category.name]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(it,{className:"hidden md:table-cell",children:V.tone?e.jsx(at,{variant:"secondary",children:V.tone}):"—"}),e.jsx(it,{children:e.jsx(at,{variant:V.is_active?"default":"secondary",children:V.is_active?"Active":"Inactive"})}),e.jsx(it,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>$(V),children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&A.mutate(V.id)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},V.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:j.map(V=>e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:V.icon})," ",V.name]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>U(V),children:e.jsx(Ua,{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(V.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:V.description||"No description"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[w.filter(X=>X.category_id===V.id).length," templates"]})]})]},V.id))})]})]}),e.jsx(vs,{open:i,onOpenChange:d,children:e.jsxs(ys,{className:"sm:max-w-[700px] max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{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:g.title,onChange:V=>v(X=>({...X,title:V.target.value})),placeholder:"e.g. Quick Check-in"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Category"}),e.jsxs(tr,{value:g.category_id,onValueChange:V=>v(X=>({...X,category_id:V})),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select category"})}),e.jsx(er,{children:j.map(V=>e.jsxs(At,{value:V.id,children:[V.icon," ",V.name]},V.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Subject Line"}),e.jsx(Re,{value:g.subject,onChange:V=>v(X=>({...X,subject:V.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(Tr,{value:g.body,onChange:V=>v(X=>({...X,body:V.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:g.description,onChange:V=>v(X=>({...X,description:V.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:g.tone,onChange:V=>v(X=>({...X,tone:V.target.value})),placeholder:"e.g. Warm & Casual"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{checked:g.is_active,onCheckedChange:V=>v(X=>({...X,is_active:V}))}),e.jsx(ve,{children:"Active"})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>C.mutate({...g,id:n==null?void 0:n.id}),disabled:C.isPending||!g.title||!g.subject||!g.body,children:[C.isPending&&e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),n?"Save Changes":"Create Template"]})]})]})}),e.jsx(vs,{open:u,onOpenChange:p,children:e.jsxs(ys,{className:"sm:max-w-[450px]",children:[e.jsx(Cs,{children:e.jsx(Ss,{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:V=>b(X=>({...X,icon:V.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:V=>b(X=>({...X,name:V.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:V=>b(X=>({...X,description:V.target.value})),placeholder:"Brief description of this category"})]})]}),e.jsxs(On,{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(As,{className:"h-4 w-4 mr-2 animate-spin"}),o?"Save Changes":"Create Category"]})]})]})})]})})}const ezt=({brokerageId:t})=>{var Do,Yc;const{toast:s}=Ea(),[r,n]=S.useState([]),[a,o]=S.useState(!0),[l,i]=S.useState(""),[d,u]=S.useState("all"),[p,g]=S.useState(new Set),[v,_]=S.useState(!1),[b,j]=S.useState({}),[w,N]=S.useState(!1),[C,A]=S.useState(!1),[I,L]=S.useState({email:"",name:"",password:"",phone:""}),[R,$]=S.useState(!1),[q,U]=S.useState(null),[V,X]=S.useState(!1),[se,te]=S.useState(!1),[Y,de]=S.useState(!1),[ie,ae]=S.useState(""),[le,pe]=S.useState(!1),[be,ye]=S.useState([]),[we,Ne]=S.useState(!1),[Ke,_e]=S.useState(!1),[Me,Te]=S.useState(null),[Fe,Ae]=S.useState({name:"",phone:"",email:""}),[Ue,ut]=S.useState(!1),[De,Dt]=S.useState(!1),[he,Ve]=S.useState(null),[nt,Qe]=S.useState("asc"),[ke,ot]=S.useState(!1),[qe,lt]=S.useState(null),[We,Ye]=S.useState(!1),[mt,Ze]=S.useState(null),[He,et]=S.useState(""),[Rt,qt]=S.useState(!1),[ls,Kt]=S.useState(null);S.useEffect(()=>{fs(),Qt()},[t]);const Qt=async()=>{try{const{data:ct,error:Se}=await G.from("brokerage_manager_assignments").select("user_id").eq("brokerage_id",t);if(Se)throw Se;ye((ct==null?void 0:ct.map(ze=>ze.user_id))||[])}catch(ct){console.error("Error loading brokerage managers:",ct)}},fs=async()=>{try{o(!0);const{data:ct,error:Se}=await G.functions.invoke("get-brokerage-agents",{body:{brokerageId:t}});if(Se)throw Se;const ze=ct.agents||[];if(n(ze),ze.length>0){const st=ze.map(Nt=>Nt.id),{data:Tt}=await G.from("agent_assistant_assignments").select("agent_id, assistant_id").in("agent_id",st);if(Tt&&Tt.length>0){const Nt=Tt.map(Ut=>Ut.assistant_id),{data:Bt}=await G.from("profiles").select("id, name, email").in("id",Nt),Yt={};for(const Ut of Tt){const Jt=Bt==null?void 0:Bt.find(Is=>Is.id===Ut.assistant_id);Jt&&(Yt[Ut.agent_id]={name:Jt.name||"",email:Jt.email||""})}j(Yt)}else j({})}}catch(ct){console.error("Error loading agents:",ct),s({title:"Error",description:"Failed to load agents",variant:"destructive"})}finally{o(!1)}},dr=async()=>{if(!I.email||!I.name||!I.password){s({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}A(!0);try{const{data:{session:ct}}=await G.auth.getSession(),Se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ct==null?void 0:ct.access_token}`},body:JSON.stringify({...I,brokerageId:t})}),ze=await Se.json();if(!Se.ok)throw new Error(ze.error||"Failed to create agent");s({title:"Success",description:`Agent ${I.email} created successfully`}),L({email:"",name:"",password:"",phone:""}),N(!1),fs()}catch(ct){console.error("Error creating agent:",ct),s({title:"Error",description:ct.message||"Failed to create agent",variant:"destructive"})}finally{A(!1)}},bt=async ct=>{try{const{data:{session:Se}}=await G.auth.getSession(),ze=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({userId:ct})}),st=await ze.json();if(!ze.ok)throw new Error(st.error||"Failed to resend welcome email");s({title:"Success",description:"Welcome email sent successfully"})}catch(Se){console.error("Error resending welcome email:",Se),s({title:"Error",description:Se.message||"Failed to resend welcome email",variant:"destructive"})}},ks=async(ct,Se)=>{try{const{error:ze}=await G.functions.invoke("send-password-reset",{body:{email:ct,redirectTo:window.location.origin}});if(ze)throw ze;s({title:"Password Reset Sent",description:`Password reset email sent to ${Se}`})}catch(ze){console.error("Error sending password reset:",ze),s({title:"Error",description:ze.message||"Failed to send password reset email",variant:"destructive"})}},ir=ct=>{U(ct),$(!0)},Rr=ct=>{Te(ct),Ae({name:ct.name,phone:ct.phone||"",email:ct.email}),_e(!0)},ca=async()=>{if(!Me)return;if(!Fe.name.trim()){s({title:"Error",description:"Name is required",variant:"destructive"});return}const ct=Fe.email.trim().toLowerCase()!==Me.email.toLowerCase();ut(!0);try{if(ct){if(!Fe.email.trim())throw new Error("Email is required");Dt(!0);const{data:{session:ze}}=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 ${ze==null?void 0:ze.access_token}`},body:JSON.stringify({agentId:Me.id,newEmail:Fe.email.trim(),brokerageId:t})}),Tt=await st.json();if(Dt(!1),!st.ok)throw new Error(Tt.error||"Failed to update email")}const{error:Se}=await G.from("profiles").update({name:Fe.name.trim(),phone:Fe.phone.trim()||null}).eq("id",Me.id);if(Se)throw Se;s({title:"Success",description:"Agent profile updated successfully"}),_e(!1),Te(null),fs()}catch(Se){console.error("Error updating agent:",Se),s({title:"Error",description:Se.message||"Failed to update agent",variant:"destructive"})}finally{ut(!1),Dt(!1)}},ii=async()=>{if(!ie){s({title:"Error",description:"Please select an agent to promote",variant:"destructive"});return}pe(!0);try{const{data:{session:ct}}=await G.auth.getSession(),Se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ct==null?void 0:ct.access_token}`},body:JSON.stringify({userId:ie,role:"brokerage_manager",action:"add",brokerageId:t})}),ze=await Se.json();if(!Se.ok)throw new Error(ze.error||"Failed to add brokerage manager");s({title:"Success",description:"Brokerage manager added successfully"}),de(!1),ae(""),Qt()}catch(ct){console.error("Error adding brokerage manager:",ct),s({title:"Error",description:ct.message||"Failed to add brokerage manager",variant:"destructive"})}finally{pe(!1)}},lo=async ct=>{try{const{data:{session:Se}}=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 ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({userId:ct,role:"brokerage_manager",action:"remove",brokerageId:t})}),st=await ze.json();if(!ze.ok)throw new Error(st.error||"Failed to remove brokerage manager");s({title:"Success",description:"Brokerage manager role removed"}),Qt()}catch(Se){console.error("Error removing brokerage manager:",Se),s({title:"Error",description:Se.message||"Failed to remove brokerage manager",variant:"destructive"})}},Oa=ct=>be.includes(ct),yn=ct=>{Ze(ct),et(""),Ye(!0)},ta=async()=>{if(!(!mt||!He)){if(He.length<6){s({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}qt(!0);try{const{data:{session:ct}}=await G.auth.getSession(),Se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ct==null?void 0:ct.access_token}`},body:JSON.stringify({agentId:mt.id,brokerageId:t,action:"set_password",newPassword:He})}),ze=await Se.json();if(!Se.ok)throw new Error(ze.error||"Failed to set password");s({title:"Success",description:`Password set for ${mt.name}`}),Ye(!1),Ze(null),et("")}catch(ct){console.error("Error setting password:",ct),s({title:"Error",description:ct.message||"Failed to set password",variant:"destructive"})}finally{qt(!1)}}},Zt=async ct=>{Kt(ct.id);try{const{data:{session:Se}}=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 ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({agentId:ct.id,brokerageId:t,action:"claim_account"})}),st=await ze.json();if(!ze.ok)throw new Error(st.error||"Failed to claim account");s({title:"Success",description:`Account claimed for ${ct.name}`}),fs()}catch(Se){console.error("Error claiming account:",Se),s({title:"Error",description:Se.message||"Failed to claim account",variant:"destructive"})}finally{Kt(null)}},vr=async()=>{if(q){X(!0);try{const{data:{session:ct}}=await G.auth.getSession(),Se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/remove-agent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ct==null?void 0:ct.access_token}`},body:JSON.stringify({userId:q.id,brokerageId:t})}),ze=await Se.json();if(!Se.ok)throw new Error(ze.error||"Failed to remove agent");s({title:"Success",description:`${q.name} has been removed from your brokerage`}),$(!1),U(null),fs()}catch(ct){console.error("Error removing agent:",ct),s({title:"Error",description:ct.message||"Failed to remove agent",variant:"destructive"})}finally{X(!1)}}},Gr=ct=>{const Se=ct.trim().split(" ");return Se.length>1?Se[Se.length-1].toLowerCase():ct.toLowerCase()},Rn=ct=>{he===ct?Qe(nt==="asc"?"desc":"asc"):(Ve(ct),Qe("asc"))},rs=ct=>he!==ct?e.jsx(Vc,{className:"ml-1 h-4 w-4"}):nt==="asc"?e.jsx(qd,{className:"ml-1 h-4 w-4"}):e.jsx(Ju,{className:"ml-1 h-4 w-4"}),Ln=r.filter(ct=>{if(d==="active"&&!ct.claimed||d==="pending"&&ct.claimed)return!1;if(!l)return!0;const Se=l.toLowerCase();return ct.name.toLowerCase().includes(Se)||ct.email.toLowerCase().includes(Se)}),da=[...Ln].sort((ct,Se)=>{if(!he)return 0;let ze=0;return he==="name"?ze=Gr(ct.name).localeCompare(Gr(Se.name)):he==="status"&&(ze=ct.claimed===Se.claimed?0:ct.claimed?-1:1),nt==="asc"?ze:-ze});Ln.filter(ct=>ct.claimed&&!Oa(ct.id));const Va=ct=>{g(Se=>{const ze=new Set(Se);return ze.has(ct)?ze.delete(ct):ze.add(ct),ze})},Jr=()=>{p.size===da.length?g(new Set):g(new Set(da.map(ct=>ct.id)))},Za=()=>{g(new Set)},$l=async()=>{const ct=Array.from(p);if(ct.length===0)return;_(!0);let Se=0,ze=0;try{const{data:{session:st}}=await G.auth.getSession();for(const Tt of ct)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:Tt})})).ok?Se++:ze++}catch{ze++}Se>0?s({title:"Success",description:`Welcome emails sent to ${Se} agent${Se>1?"s":""}${ze>0?` (${ze} failed)`:""}`}):s({title:"Error",description:"Failed to send welcome emails",variant:"destructive"}),Za()}catch(st){console.error("Error bulk sending welcome emails:",st),s({title:"Error",description:st.message||"Failed to send welcome emails",variant:"destructive"})}finally{_(!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(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Agents"}),e.jsx(yr,{children:"Manage your brokerage's agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>de(!0),children:[e.jsx(sh,{className:"mr-2 h-4 w-4"}),"Add Brokerage Manager"]}),e.jsxs(K,{variant:"outline",onClick:()=>te(!0),children:[e.jsx(N0,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),e.jsxs(K,{onClick:()=>N(!0),children:[e.jsx(fc,{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(xn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search agents...",value:l,onChange:ct=>i(ct.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:d,onValueChange:ct=>u(ct),children:[e.jsx(Js,{className:"w-[160px]",children:e.jsx(sr,{placeholder:"Filter by status"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Agents"}),e.jsx(At,{value:"active",children:"Active"}),e.jsx(At,{value:"pending",children:"Pending"})]})]})]}),p.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:[p.size," agent",p.size>1?"s":""," selected"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:$l,disabled:v,children:[e.jsx(br,{className:"mr-2 h-4 w-4"}),v?"Sending...":"Resend Welcome Email"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:Za,children:"Clear"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-[40px]",children:e.jsx(zo,{checked:da.length>0&&p.size===da.length,onCheckedChange:Jr,"aria-label":"Select all"})}),e.jsx(jt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>Rn("name"),children:["Name (Last)",rs("name")]})}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>Rn("status"),children:["Status",rs("status")]})}),e.jsx(jt,{children:"Actions"})]})}),e.jsx(En,{children:da.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:5,className:"text-center text-muted-foreground",children:"No agents found"})}):da.map(ct=>e.jsxs(js,{children:[e.jsx(it,{children:e.jsx(zo,{checked:p.has(ct.id),onCheckedChange:()=>Va(ct.id),"aria-label":`Select ${ct.name}`})}),e.jsx(it,{className:"font-medium",children:ct.name}),e.jsx(it,{children:ct.email}),e.jsx(it,{children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[ct.claimed?e.jsx(at,{variant:"default",children:"Active"}):e.jsx(at,{variant:"secondary",children:"Pending"}),Oa(ct.id)&&e.jsxs(at,{variant:"outline",className:"border-primary text-primary",children:[e.jsx(MP,{className:"mr-1 h-3 w-3"}),"Manager"]}),b[ct.id]&&e.jsxs(at,{variant:"outline",className:"text-xs",children:[e.jsx(hr,{className:"mr-1 h-3 w-3"}),"Asst: ",b[ct.id].name||b[ct.id].email]})]})}),e.jsx(it,{children:e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{lt(ct),ot(!0)},title:"Send celebration",className:"text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",children:e.jsx(Nd,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Rr(ct),title:"Edit agent",children:e.jsx(Ua,{className:"h-4 w-4"})}),!ct.claimed&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>bt(ct.id),title:"Resend welcome email",children:e.jsx(br,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Zt(ct),title:"Claim account for agent",disabled:ls===ct.id,className:"text-green-600 hover:text-green-700 hover:bg-green-50",children:e.jsx(i_,{className:"h-4 w-4"})})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>yn(ct),title:"Set password",className:"text-blue-600 hover:text-blue-700 hover:bg-blue-50",children:e.jsx(Fu,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>ks(ct.email,ct.name),title:"Send password reset email",children:e.jsx(tN,{className:"h-4 w-4"})}),Oa(ct.id)&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>lo(ct.id),title:"Remove manager role",className:"text-orange-500 hover:text-orange-600",children:e.jsx(sh,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>ir(ct),className:"text-destructive hover:text-destructive",title:"Remove agent",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},ct.id))})]})})]})]}),e.jsx(vs,{open:w,onOpenChange:N,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:I.name,onChange:ct=>L({...I,name:ct.target.value}),placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",value:I.email,onChange:ct=>L({...I,email:ct.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:I.phone,onChange:ct=>L({...I,phone:ct.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:I.password,onChange:ct=>L({...I,password:ct.target.value}),placeholder:"Temporary password"})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>N(!1),children:"Cancel"}),e.jsx(K,{onClick:dr,disabled:C,children:C?"Creating...":"Create Agent"})]})]})}),e.jsx(vs,{open:R,onOpenChange:$,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Remove Agent"}),e.jsxs(Kr,{children:["Are you sure you want to remove ",e.jsx("strong",{children:q==null?void 0:q.name})," from your brokerage? This will revoke their access to the dashboard."]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:vr,disabled:V,children:V?"Removing...":"Remove Agent"})]})]})}),e.jsx(pKe,{open:se,onOpenChange:te,fixedBrokerageId:t,onSuccess:fs}),e.jsx(vs,{open:Y,onOpenChange:de,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(No,{open:we,onOpenChange:Ne,children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":we,className:"w-full justify-between",children:[ie?((Do=r.find(ct=>ct.id===ie))==null?void 0:Do.name)+" ("+((Yc=r.find(ct=>ct.id===ie))==null?void 0:Yc.email)+")":"Select an agent to promote...",e.jsx(df,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-full p-0",align:"start",children:e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search by name or email..."}),e.jsxs(kf,{className:"max-h-[200px]",children:[e.jsx(Nf,{children:"No eligible agents found."}),e.jsx(Sf,{children:r.filter(ct=>!Oa(ct.id)).map(ct=>e.jsxs(jm,{value:`${ct.name} ${ct.email}`,onSelect:()=>{ae(ct.id),Ne(!1)},children:[e.jsx(fa,{className:`mr-2 h-4 w-4 ${ie===ct.id?"opacity-100":"opacity-0"}`}),ct.name," (",ct.email,")"]},ct.id))})]})]})})]}),r.filter(ct=>!Oa(ct.id)).length===0&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"All agents are already brokerage managers."})]})}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>de(!1),children:"Cancel"}),e.jsx(K,{onClick:ii,disabled:le||!ie,children:le?"Adding...":"Add as Manager"})]})]})}),e.jsx(vs,{open:Ke,onOpenChange:_e,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Edit Agent"}),e.jsxs(Kr,{children:["Update profile information for ",Me==null?void 0:Me.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:Fe.name,onChange:ct=>Ae({...Fe,name:ct.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:Fe.email,onChange:ct=>Ae({...Fe,email:ct.target.value}),placeholder:"agent@example.com"}),Fe.email.trim().toLowerCase()!==(Me==null?void 0:Me.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:Fe.phone,onChange:ct=>Ae({...Fe,phone:ct.target.value}),placeholder:"555-123-4567"})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>_e(!1),children:"Cancel"}),e.jsx(K,{onClick:ca,disabled:Ue||De,children:De?"Updating email...":Ue?"Saving...":"Save Changes"})]})]})}),qe&&e.jsx(fKe,{open:ke,onOpenChange:ct=>{ot(ct),ct||lt(null)},userId:qe.id,userName:qe.name}),e.jsx(vs,{open:We,onOpenChange:Ye,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Set Password"}),e.jsxs(Kr,{children:["Set a new password for ",mt==null?void 0:mt.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:He,onChange:ct=>et(ct.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(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>Ye(!1),children:"Cancel"}),e.jsx(K,{onClick:ta,disabled:Rt||!He||He.length<6,children:Rt?"Setting...":"Set Password"})]})]})})]})},tzt={academy_video:"Academy Video",template:"Template",toolbox:"Toolbox Resource",newsletter:"Newsletter",social_swag:"Social Swag",event:"Event"},szt={view:"Viewed",click_canva:"Opened Canva",click_pdf:"Downloaded PDF",click_video:"Watched Video",click_link:"Clicked Link",register:"Registered"},rzt=t=>{switch(t){case"academy_video":return e.jsx(Nn,{className:"h-4 w-4"});case"template":return e.jsx(Sn,{className:"h-4 w-4"});case"toolbox":return e.jsx(Sn,{className:"h-4 w-4"});case"newsletter":return e.jsx(E0,{className:"h-4 w-4"});case"social_swag":return e.jsx(mn,{className:"h-4 w-4"});case"event":return e.jsx(on,{className:"h-4 w-4"});default:return e.jsx(rn,{className:"h-4 w-4"})}},nzt=({brokerageId:t})=>{const{toast:s}=Ea(),[r,n]=S.useState([]),[a,o]=S.useState([]),[l,i]=S.useState([]),[d,u]=S.useState(!0),[p,g]=S.useState(null);S.useEffect(()=>{v()},[t]);const v=async()=>{try{u(!0);const{data:j,error:w}=await G.from("profiles").select("id, name, email").eq("brokerage_id",t);if(w)throw w;const N=j.map(X=>X.id),C=new Map(j.map(X=>[X.id,X]));if(N.length===0){n([]),o([]),i([]);return}const{data:A,error:I}=await G.from("activity_logs").select("*").in("user_id",N).order("launched_at",{ascending:!1});if(I)throw I;const L=A.map(X=>{var se,te;return{id:X.id,user_id:X.user_id,app_name:X.app_name,launched_at:X.launched_at,user_name:((se=C.get(X.user_id))==null?void 0:se.name)||"Unknown",user_email:((te=C.get(X.user_id))==null?void 0:te.email)||"Unknown"}});n(L);const{data:R,error:$}=await G.from("content_engagement_logs").select("*").in("user_id",N).order("created_at",{ascending:!1});if($)throw $;const q=(R||[]).map(X=>{var se,te;return{id:X.id,user_id:X.user_id,resource_type:X.resource_type,resource_id:X.resource_id,resource_title:X.resource_title,action_type:X.action_type,created_at:X.created_at,user_name:((se=C.get(X.user_id))==null?void 0:se.name)||"Unknown",user_email:((te=C.get(X.user_id))==null?void 0:te.email)||"Unknown"}});o(q);const U=new Map;j.forEach(X=>{U.set(X.id,{user_id:X.id,user_name:X.name,user_email:X.email,app_launches:0,content_views:0,last_activity:""})}),L.forEach(X=>{const se=U.get(X.user_id);se&&(se.app_launches++,(!se.last_activity||new Date(X.launched_at)>new Date(se.last_activity))&&(se.last_activity=X.launched_at))}),q.forEach(X=>{const se=U.get(X.user_id);se&&(se.content_views++,(!se.last_activity||new Date(X.created_at)>new Date(se.last_activity))&&(se.last_activity=X.created_at))});const V=Array.from(U.values()).filter(X=>X.app_launches>0||X.content_views>0).sort((X,se)=>new Date(se.last_activity).getTime()-new Date(X.last_activity).getTime());i(V)}catch(j){console.error("Error loading activity:",j),s({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{u(!1)}},_=j=>r.filter(w=>w.user_id===j),b=j=>a.filter(w=>w.user_id===j);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(Lt,{children:[e.jsx(zt,{children:"Agent Activity"}),e.jsx(yr,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Agent"}),e.jsx(jt,{className:"text-center",children:"App Launches"}),e.jsx(jt,{className:"text-center",children:"Content Views"}),e.jsx(jt,{children:"Last Active"})]})}),e.jsx(En,{children:l.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:4,className:"text-center text-muted-foreground",children:"No activity yet"})}):l.map(j=>e.jsxs(js,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>g({id:j.user_id,name:j.user_name,email:j.user_email}),children:[e.jsx(it,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:j.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:j.user_email})]})}),e.jsx(it,{className:"text-center",children:e.jsxs(at,{variant:"outline",className:"gap-1",children:[e.jsx(dl,{className:"h-3 w-3"}),j.app_launches]})}),e.jsx(it,{className:"text-center",children:e.jsxs(at,{variant:"secondary",className:"gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"}),j.content_views]})}),e.jsx(it,{className:"text-sm text-muted-foreground",children:j.last_activity&&Sd(new Date(j.last_activity),{addSuffix:!0})})]},j.user_id))})]})})})]}),e.jsx(vs,{open:!!p,onOpenChange:j=>!j&&g(null),children:e.jsxs(ys,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{children:[p==null?void 0:p.name,"'s Activity"]}),e.jsx(Kr,{children:p==null?void 0:p.email})]}),e.jsxs(ja,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(va,{className:"grid w-full grid-cols-2",children:[e.jsx(Ns,{value:"content",children:"Content Engagement"}),e.jsx(Ns,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Resource"}),e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Action"}),e.jsx(jt,{children:"Time"})]})}),e.jsx(En,{children:p&&b(p.id).length===0?e.jsx(js,{children:e.jsx(it,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement yet"})}):p&&b(p.id).map(j=>e.jsxs(js,{children:[e.jsx(it,{className:"max-w-[200px] truncate font-medium",children:j.resource_title}),e.jsx(it,{children:e.jsxs(at,{variant:"outline",className:"gap-1",children:[rzt(j.resource_type),tzt[j.resource_type]||j.resource_type]})}),e.jsx(it,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:szt[j.action_type]||j.action_type})}),e.jsx(it,{className:"text-sm text-muted-foreground",children:Sd(new Date(j.created_at),{addSuffix:!0})})]},j.id))})]})})}),e.jsx(zs,{value:"apps",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"App"}),e.jsx(jt,{children:"Time"})]})}),e.jsx(En,{children:p&&_(p.id).length===0?e.jsx(js,{children:e.jsx(it,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches yet"})}):p&&_(p.id).map(j=>e.jsxs(js,{children:[e.jsx(it,{children:e.jsx(at,{variant:"outline",children:j.app_name})}),e.jsx(it,{className:"text-sm text-muted-foreground",children:Sd(new Date(j.launched_at),{addSuffix:!0})})]},j.id))})]})})})]})]})})]})},azt=({brokerageId:t})=>{const{toast:s}=Ea(),[r,n]=S.useState({totalAgents:0,activeAgents:0,pendingAgents:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0}),[a,o]=S.useState(!0);S.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:g,error:v}=await G.from("profiles").select("id, email").in("id",u);if(v)throw v;const{count:_}=await G.from("profiles").select("*",{count:"exact",head:!0}).eq("brokerage_id",t).not("last_login","is",null),b=_||0,j=p-b,{count:w}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u),N=new Date;N.setDate(N.getDate()-7);const{count:C}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",N.toISOString()),A=new Date;A.setMonth(A.getMonth()-1);const{count:I}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",A.toISOString());n({totalAgents:p,activeAgents:b,pendingAgents:j,totalLaunches:w||0,launchesThisWeek:C||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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Active Agents"}),e.jsx(fi,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(In,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(Mm,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"This Week"}),e.jsx(Mm,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"This Month"}),e.jsx(Mm,{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"})]})]})]})},izt=({brokerageId:t})=>{const[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState({description:"",maxUses:""});S.useEffect(()=>{g()},[t]);const g=async()=>{try{const{data:N,error:C}=await G.from("invite_codes").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(C)throw C;r(N||[])}catch(N){console.error("Error loading invite codes:",N),fe.error("Failed to load invite links")}finally{a(!1)}},v=()=>Math.random().toString(36).substring(2,8).toUpperCase(),_=async()=>{l(!0);try{const N=v(),{error:C}=await G.from("invite_codes").insert({code:N,description:u.description||null,max_uses:u.maxUses?parseInt(u.maxUses):null,brokerage_id:t,is_active:!0});if(C)throw C;fe.success("Invite link created!"),d(!1),p({description:"",maxUses:""}),g()}catch(N){console.error("Error creating invite code:",N),fe.error("Failed to create invite link")}finally{l(!1)}},b=async N=>{try{const{error:C}=await G.from("invite_codes").delete().eq("id",N);if(C)throw C;fe.success("Invite link deleted"),r(s.filter(A=>A.id!==N))}catch(C){console.error("Error deleting invite code:",C),fe.error("Failed to delete invite link")}},j=async(N,C)=>{try{const{error:A}=await G.from("invite_codes").update({is_active:!C}).eq("id",N);if(A)throw A;r(s.map(I=>I.id===N?{...I,is_active:!C}:I)),fe.success(`Invite link ${C?"deactivated":"activated"}`)}catch(A){console.error("Error toggling invite code:",A),fe.error("Failed to update invite link")}},w=N=>{const C=`${window.location.origin}/join?code=${N}`;navigator.clipboard.writeText(C),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(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Io,{className:"h-5 w-5"}),"Agent Invite Links"]}),e.jsx(yr,{children:"Create shareable links for agents to join your brokerage"})]}),e.jsxs(vs,{open:i,onOpenChange:d,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Link"]})}),e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:N=>p({...u,description:N.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:N=>p({...u,maxUses:N.target.value})})]}),e.jsx(K,{onClick:_,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(As,{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(Io,{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(N=>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:N.code}),e.jsx(at,{variant:N.is_active?"default":"secondary",children:N.is_active?"Active":"Inactive"})]}),N.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:N.description}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[N.uses_count," uses",N.max_uses&&` / ${N.max_uses} max`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(N.code),title:"Copy link",children:e.jsx(ai,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>j(N.id,N.is_active),title:N.is_active?"Deactivate":"Activate",children:N.is_active?"Disable":"Enable"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(N.id),className:"text-destructive hover:text-destructive",title:"Delete",children:e.jsx(jr,{className:"h-4 w-4"})})]})]},N.id))})})]})},ozt=({open:t,onOpenChange:s,referralCode:r,brokerageId:n,senderName:a,brokerageName:o,onInvitesSent:l})=>{const[i,d]=S.useState(""),[u,p]=S.useState([]),[g,v]=S.useState(""),[_,b]=S.useState(!1),j=I=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I),w=()=>{const I=i.trim().toLowerCase();if(I&&j(I)&&!u.includes(I)){if(u.length>=10){fe.error("Maximum 10 emails per invite");return}p([...u,I]),d("")}else I&&!j(I)?fe.error("Please enter a valid email address"):u.includes(I)&&fe.error("Email already added")},N=I=>{p(u.filter(L=>L!==I))},C=I=>{(I.key==="Enter"||I.key===",")&&(I.preventDefault(),w())},A=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:g.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([]),v(""),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(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-[550px]",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{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(ao,{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:C,onBlur:w}),e.jsx(K,{type:"button",variant:"secondary",onClick:w,children:"Add"})]}),u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:u.map(I=>e.jsxs(at,{variant:"secondary",className:"flex items-center gap-1 pr-1",children:[I,e.jsx("button",{type:"button",onClick:()=>N(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(Tr,{id:"message",placeholder:"Add a personal note that will appear at the top of the email...",value:g,onChange:I=>v(I.target.value),rows:3,maxLength:500}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[g.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(mn,{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:A,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(Ta,{className:"h-4 w-4 mr-2"}),"Send ",u.length>0&&`(${u.length})`," Invite",u.length!==1?"s":""]})})]})]})})},lzt=({brokerageId:t,refreshTrigger:s})=>{const[r,n]=S.useState([]),[a,o]=S.useState(!0);S.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(at,{className:"bg-green-100 text-green-800 gap-1",children:[e.jsx(fi,{className:"h-3 w-3"}),"Signed Up"]});case"expired":return e.jsxs(at,{variant:"outline",className:"text-muted-foreground gap-1",children:[e.jsx(wc,{className:"h-3 w-3"}),"Expired"]});default:return e.jsxs(at,{variant:"secondary",className:"gap-1",children:[e.jsx(In,{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 ",ws(new Date(d.sent_at),"MMM d, yyyy")]})]}),i(d.status)]},d.id))]})},czt=()=>{const{brokerageId:t,user:s}=Gs(),[r,n]=S.useState(null),[a,o]=S.useState(""),[l,i]=S.useState(""),[d,u]=S.useState([]),[p,g]=S.useState(!0),[v,_]=S.useState(!1),[b,j]=S.useState(0);S.useEffect(()=>{t&&w()},[t]);const w=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 V=`REF${t==null?void 0:t.slice(0,8).toUpperCase()}`;await G.from("referral_codes").insert({brokerage_id:t,code:V}),n(V)}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{g(!1)}},N=()=>{const R=`https://dashboard.relevelup.com/?ref=${r}`;navigator.clipboard.writeText(R),fe.success("Referral link copied to clipboard!")},C=d.filter(R=>R.status==="qualified").length,A=d.filter(R=>R.status==="pending").length,I=C*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(ao,{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(fi,{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(mn,{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:N,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(Gc,{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:C}),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(In,{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:A}),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(lzt,{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(at,{variant:R.status==="qualified"?"default":R.status==="pending"?"secondary":"destructive",className:R.status==="qualified"?"bg-green-600":"",children:[R.status==="qualified"&&e.jsx(fi,{className:"h-3 w-3 mr-1"}),R.status]})]},R.id)})]})]})]}),e.jsx(ozt,{open:v,onOpenChange:_,referralCode:r||"",brokerageId:t||"",senderName:l||"A LevelUp Member",brokerageName:a,onInvitesSent:()=>j(R=>R+1)})]})},dzt=({brokerageId:t})=>{const s=Lr(),{teams:r,isLoading:n}=rS(t),{data:a,isLoading:o}=Ct({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:g}=await G.from("team_members").select("team_id, user_id, role").in("team_id",p);if(!g||g.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 v=g.map(R=>R.user_id),_=g.filter(R=>R.role==="team_leader").map(R=>R.user_id),{data:b}=await G.from("profiles").select("id, name, avatar_url").in("id",_),j=new Map((b||[]).map(R=>[R.id,R])),{data:w}=await G.from("innercircle_contacts").select("owner_user_id").in("owner_user_id",v),{data:N}=await G.from("deal_pipeline").select("owner_user_id").in("owner_user_id",v),{data:C}=await G.from("agent_videos").select("owner_user_id").in("owner_user_id",v).eq("is_deleted",!1),A=new Map;(w||[]).forEach(R=>{A.set(R.owner_user_id,(A.get(R.owner_user_id)||0)+1)});const I=new Map;(N||[]).forEach(R=>{I.set(R.owner_user_id,(I.get(R.owner_user_id)||0)+1)});const L=new Map;return(C||[]).forEach(R=>{L.set(R.owner_user_id,(L.get(R.owner_user_id)||0)+1)}),r.map(R=>{const $=g.filter(Y=>Y.team_id===R.id),q=$.find(Y=>Y.role==="team_leader"),U=q?j.get(q.user_id):null,V=$.map(Y=>Y.user_id),X=V.reduce((Y,de)=>Y+(A.get(de)||0),0),se=V.reduce((Y,de)=>Y+(I.get(de)||0),0),te=V.reduce((Y,de)=>Y+(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:X,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(Lt,{children:e.jsx(gs,{className:"h-5 w-32"})}),e.jsx(Oe,{children:e.jsx(gs,{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,g)=>p+g.member_count,0),d=(a||[]).reduce((p,g)=>p+g.total_contacts,0),u=(a||[]).reduce((p,g)=>p+g.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(Jk,{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(eh,{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(Lt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{className:"text-lg",children:p.team_name}),e.jsxs(at,{variant:"secondary",children:[p.member_count," members"]})]}),p.leader_name&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsxs(fn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:p.leader_avatar||""}),e.jsx(gn,{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(zh,{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 →"})})]})},uzt=()=>{const{user:t,isBrokerageManager:s,brokerageId:r,isAdmin:n,managedBrokerages:a,selectedBrokerageId:o,setSelectedBrokerageId:l}=Gs(),i=Lr(),{toast:d}=Ea(),[u,p]=S.useState(""),[g,v]=S.useState(!0),_=o||(a.length>0?a[0].id:r);S.useEffect(()=>{if(!t||!s&&!n){i("/dashboard");return}!o&&a.length>0&&l(a[0].id),_?b():a.length===0&&!r&&v(!1)},[t,s,n,_,i,a,o]);const b=async()=>{if(!_){v(!1);return}try{const{data:j,error:w}=await G.from("brokerages").select("name").eq("id",_).single();if(w)throw w;p(j.name)}catch(j){console.error("Error loading brokerage info:",j),d({title:"Error",description:"Failed to load brokerage information",variant:"destructive"})}finally{v(!1)}};return g?e.jsx(Ms,{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(Ms,{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(tr,{value:o||"",onValueChange:l,children:[e.jsxs(Js,{className:"w-[280px]",children:[e.jsx(Ca,{className:"mr-2 h-4 w-4"}),e.jsx(sr,{placeholder:"Select brokerage"})]}),e.jsx(er,{children:a.map(j=>e.jsx(At,{value:j.id,children:j.name},j.id))})]})]}),e.jsxs(ja,{defaultValue:"agents",className:"space-y-4",children:[e.jsxs(va,{className:"grid w-full grid-cols-4 md:grid-cols-8",children:[e.jsx(Ns,{value:"agents",children:"Agents"}),e.jsx(Ns,{value:"teams",children:"Teams"}),e.jsx(Ns,{value:"invite",children:"Invite Links"}),e.jsx(Ns,{value:"referrals",children:"Referrals"}),e.jsx(Ns,{value:"leaderboard",children:"Leaderboard"}),e.jsx(Ns,{value:"activity",children:"Activity"}),e.jsx(Ns,{value:"analytics",children:"Analytics"}),e.jsx(Ns,{value:"shares",children:"Shares"})]}),e.jsx(zs,{value:"agents",className:"space-y-4",children:e.jsx(ezt,{brokerageId:_})}),e.jsx(zs,{value:"teams",className:"space-y-4",children:e.jsx(dzt,{brokerageId:_})}),e.jsx(zs,{value:"invite",className:"space-y-4",children:e.jsx(izt,{brokerageId:_})}),e.jsx(zs,{value:"referrals",className:"space-y-4",children:e.jsx(czt,{})}),e.jsx(zs,{value:"leaderboard",className:"space-y-4",children:e.jsx(IGe,{brokerageId:_,title:`${u} Event Leaderboard`,showUserStats:!1})}),e.jsx(zs,{value:"activity",className:"space-y-4",children:e.jsx(nzt,{brokerageId:_})}),e.jsx(zs,{value:"analytics",className:"space-y-4",children:e.jsx(azt,{brokerageId:_})}),e.jsx(zs,{value:"shares",className:"space-y-4",children:e.jsx(ZKe,{brokerageOnly:!0,brokerageId:_})})]})]})}):e.jsx(Ms,{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(Ca,{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 hzt({brokerageId:t,canManage:s}){const{user:r}=Gs(),[n,a]=S.useState([]),[o,l]=S.useState(!0),[i,d]=S.useState(!1),[u,p]=S.useState(null),[g,v]=S.useState(null),[_,b]=S.useState(!1),[j,w]=S.useState(""),[N,C]=S.useState(""),[A,I]=S.useState(!1),L=async()=>{try{const{data:V,error:X}=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(X)throw X;const se=V;if(se&&se.length>0){const te=[...new Set(se.map(ae=>ae.created_by))],{data:Y}=await G.from("profiles").select("id, name, avatar_url").in("id",te),de=new Map((Y==null?void 0:Y.map(ae=>[ae.id,ae]))||[]),ie=se.map(ae=>({...ae,author:de.get(ae.created_by)||{name:"Unknown",avatar_url:null}}));a(ie)}else a([])}catch(V){console.error("Error fetching announcements:",V)}finally{l(!1)}};S.useEffect(()=>{L()},[t]);const R=()=>{w(""),C(""),I(!1),p(null)},$=V=>{V?(p(V),w(V.title),C(V.content),I(V.is_pinned)):R(),d(!0)},q=async()=>{if(!j.trim()||!N.trim()){fe.error("Please fill in all fields");return}b(!0);try{if(u){const{error:V}=await G.from("brokerage_announcements").update({title:j.trim(),content:N.trim(),is_pinned:A,pinned_at:A?new Date().toISOString():null}).eq("id",u.id);if(V)throw V;fe.success("Announcement updated")}else{const{error:V}=await G.from("brokerage_announcements").insert({brokerage_id:t,created_by:r==null?void 0:r.id,title:j.trim(),content:N.trim(),is_pinned:A,pinned_at:A?new Date().toISOString():null});if(V)throw V;fe.success("Announcement created")}d(!1),R(),L()}catch(V){console.error("Error saving announcement:",V),fe.error("Failed to save announcement")}finally{b(!1)}},U=async()=>{if(g)try{const{error:V}=await G.from("brokerage_announcements").delete().eq("id",g);if(V)throw V;fe.success("Announcement deleted"),L()}catch(V){console.error("Error deleting announcement:",V),fe.error("Failed to delete announcement")}finally{v(null)}};return o?e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Fg,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Fg,{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(V=>{var X,se,te,Y;return e.jsx("div",{className:`p-4 rounded-lg border ${V.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:[V.is_pinned&&e.jsx(r_,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold truncate",children:V.title})]}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:V.content}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-muted-foreground",children:[e.jsxs(fn,{className:"h-5 w-5",children:[e.jsx(Ma,{src:((X=V.author)==null?void 0:X.avatar_url)||void 0}),e.jsx(gn,{className:"text-[10px]",children:((te=(se=V.author)==null?void 0:se.name)==null?void 0:te.charAt(0))||"?"})]}),e.jsx("span",{children:(Y=V.author)==null?void 0:Y.name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:ws(new Date(V.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:()=>$(V),children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>v(V.id),children:e.jsx(jr,{className:"h-4 w-4"})})]})]})},V.id)})})})]}),e.jsx(vs,{open:i,onOpenChange:d,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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:j,onChange:V=>w(V.target.value),placeholder:"Announcement title..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"content",children:"Content"}),e.jsx(Tr,{id:"content",value:N,onChange:V=>C(V.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:A,onCheckedChange:I}),e.jsxs(ve,{htmlFor:"pinned",className:"flex items-center gap-1 cursor-pointer",children:[e.jsx(r_,{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(tc,{open:!!g,onOpenChange:()=>v(null),children:e.jsxs(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Delete Announcement"}),e.jsx(Il,{children:"Are you sure you want to delete this announcement? This action cannot be undone."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:U,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function mzt({brokerageId:t}){const[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(""),[i,d]=S.useState(new Set);S.useEffect(()=>{(async()=>{try{const{data:g,error:v}=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(v)throw v;if(r(g||[]),g&&g.length>0){const _=g.map(j=>j.id),{data:b}=await G.from("agent_assistant_assignments").select("agent_id").in("agent_id",_);b&&d(new Set(b.map(j=>j.agent_id)))}}catch(g){console.error("Error fetching agents:",g)}finally{a(!1)}})()},[t]);const u=s.filter(p=>{var g,v;return p.name.toLowerCase().includes(o.toLowerCase())||p.email.toLowerCase().includes(o.toLowerCase())||((g=p.title)==null?void 0:g.toLowerCase().includes(o.toLowerCase()))||((v=p.areas_served)==null?void 0:v.toLowerCase().includes(o.toLowerCase()))});return n?e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{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(Lt,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs(zt,{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(xn,{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(pzt,{agent:p,hasAssistant:i.has(p.id)},p.id))})})]})}function pzt({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(fn,{className:"h-20 w-20 mb-3 ring-2 ring-background shadow-md",children:[e.jsx(Ma,{src:t.avatar_url||void 0,alt:t.name}),e.jsx(gn,{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(at,{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(Ti,{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(Zn,{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(Pm,{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(Vd,{className:"h-4 w-4"})})})]})]})}function fzt({brokerageId:t}){const[s,r]=S.useState([]),[n,a]=S.useState(!0);if(S.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(j=>j.id),{data:g,error:v}=await G.from("agent_attendance_stats").select("user_id, total_points").in("user_id",p).order("total_points",{ascending:!1});if(v)throw v;const _=new Map(d.map(j=>[j.id,j])),b=(g||[]).filter(j=>j.total_points>0).map(j=>{const w=_.get(j.user_id);return{user_id:j.user_id,total_points:j.total_points,name:(w==null?void 0:w.name)||"Unknown",avatar_url:(w==null?void 0:w.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(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Gi,{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(T0,{className:Et("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(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Gi,{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(g=>g[0]).join("").toUpperCase().slice(0,2),p=d+1;return e.jsxs("div",{className:Et("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(fn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:i.avatar_url||void 0}),e.jsx(gn,{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 gzt({brokerageId:t}){const s=Lr(),[r,n]=S.useState([]),[a,o]=S.useState(!0);S.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(j=>j.id),g=new Map(d.map(j=>[j.id,j])),{data:v,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=(v||[]).map(j=>({id:j.id,slug:j.slug,property_address:j.property_address,city:j.city,price:j.price,property_type:j.property_type,agent_id:j.agent_id,agent:g.get(j.agent_id)||null,photos:j.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(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Vn,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Vn,{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(Vn,{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(Vn,{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(rn,{className:"h-3 w-3 ml-1"})]})]})]})}function xzt(){const{user:t,isAdmin:s,isBrokerageManager:r}=Gs(),n=Lr(),[a,o]=S.useState(!0),[l,i]=S.useState(null),[d,u]=S.useState(""),[p,g]=S.useState(0),[v,_]=S.useState(!1),[b,j]=S.useState(!1);return S.useEffect(()=>{(async()=>{if(t)try{const{data:N}=await G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(N!=null&&N.brokerage_id)){o(!1);return}i(N.brokerage_id);const{data:C}=await G.from("brokerages").select("name").eq("id",N.brokerage_id).maybeSingle();C&&u(C.name);const{count:A}=await G.from("profiles").select("id",{count:"exact",head:!0}).eq("brokerage_id",N.brokerage_id);if(g(A||0),s)_(!0),j(!0);else if(r){const{data:I}=await G.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",N.brokerage_id).maybeSingle();_(!!I),j(!!I)}}catch(N){console.error("Error fetching brokerage info:",N)}finally{o(!1)}})()},[t,s,r]),a?e.jsx(Ms,{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(Ms,{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(cu,{className:"h-4 w-4 mr-2"}),"Brokerage Content"]}),e.jsxs(K,{onClick:()=>n(`/mission-control/listings/new?brokerage=${l}`),children:[e.jsx(Vn,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})]}),e.jsx(hzt,{brokerageId:l,canManage:v}),e.jsx(mzt,{brokerageId:l}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsx(fzt,{brokerageId:l}),e.jsx(gzt,{brokerageId:l})]})]})}):e.jsx(Ms,{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(Ca,{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 yzt(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 vzt(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 nEe={video:{icon:dl,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:Sn,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:Ho,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:Rl,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function _zt({item:t,canManage:s}){const[r,n]=S.useState(!1),[a,o]=S.useState(null),l=c5t(),i=Lr(),d=nEe[t.content_type]||nEe.link,u=d.icon,p=S.useMemo(()=>t.thumbnail_url?t.thumbnail_url:t.content_type==="graphic"&&t.file_url?t.file_url:t.content_type==="video"?yzt(t.url):null,[t]);S.useEffect(()=>{p||!t.url||t.content_type!=="video"||!vzt(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 g=p||a,v=()=>{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:v,children:[g?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:g,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(at,{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(at,{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:["📅 ",ws(new Date(t.event_date),"MMM d, yyyy · h:mm a")]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-2",children:["Added ",ws(new Date(t.created_at),"MMM d, yyyy")]})]}),s&&e.jsxs(yu,{children:[e.jsx(vu,{asChild:!0,onClick:b=>b.stopPropagation(),children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(Jp,{className:"h-4 w-4"})})}),e.jsx(Wd,{align:"end",children:e.jsxs(Da,{onClick:b=>{b.stopPropagation(),n(!0)},className:"text-destructive",children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]})})]}),e.jsx(tc,{open:r,onOpenChange:n,children:e.jsxs(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Delete Content"}),e.jsxs(Il,{children:['Are you sure you want to delete "',t.title,'"? This cannot be undone.']})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:_,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function bzt(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 aEe=[{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 wzt({brokerageId:t,categories:s}){var we;const{user:r}=Gs(),[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState(""),[u,p]=S.useState("📁"),[g,v]=S.useState(!1);S.useRef(null);const[_,b]=S.useState("video"),[j,w]=S.useState(""),[N,C]=S.useState(""),[A,I]=S.useState(""),[L,R]=S.useState(""),[$,q]=S.useState(""),[U,V]=S.useState(""),[X,se]=S.useState(""),te=l5t(),Y=d5t(t),de=u5t(),ie=h5t(t),ae=()=>{b("video"),w(""),C(""),I(""),R(""),q(""),V(""),se("")},le=async(Ne,Ke)=>{var Me;const _e=(Me=Ne.target.files)==null?void 0:Me[0];if(_e){v(!0);try{const Te=_e.name.split(".").pop(),Fe=`${t}/${Date.now()}-${Math.random().toString(36).slice(2)}.${Te}`,{error:Ae}=await G.storage.from("brokerage-content").upload(Fe,_e);if(Ae)throw Ae;const{data:{publicUrl:Ue}}=G.storage.from("brokerage-content").getPublicUrl(Fe);Ke==="file"?(R(Ue),_==="graphic"&&!$&&q(Ue)):q(Ue),fe.success("File uploaded")}catch(Te){fe.error(Te.message||"Upload failed")}finally{v(!1)}}},pe=async()=>{if(!j.trim()){fe.error("Title is required");return}if(r)try{await te.mutateAsync({brokerage_id:t,category_id:X||null,content_type:_,title:j.trim(),description:N.trim()||null,url:A.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 Y.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")}},ye=async()=>{try{await ie.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(vs,{open:n,onOpenChange:a,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Content"]})}),e.jsxs(ys,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(tr,{value:_,onValueChange:b,children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:aEe.map(Ne=>e.jsx(At,{value:Ne.value,children:Ne.label},Ne.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(we=aEe.find(Ne=>Ne.value===_))==null?void 0:we.hint})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Category"}),e.jsxs(tr,{value:X,onValueChange:se,children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select category (optional)"})}),e.jsx(er,{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:j,onChange:Ne=>w(Ne.target.value),placeholder:"Content title"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Description"}),e.jsx(Tr,{value:N,onChange:Ne=>C(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:A,onChange:Ne=>{const Ke=Ne.target.value;if(I(Ke),_==="video"&&!$){const _e=bzt(Ke);_e&&q(_e)}},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:g}),g&&e.jsx(As,{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:g}),$&&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=>V(Ne.target.value)})]}),e.jsxs(K,{onClick:pe,disabled:te.isPending||!j.trim(),className:"w-full",children:[te.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Content"]})]})]})]}),e.jsxs(vs,{open:o,onOpenChange:l,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",children:[e.jsx(Fl,{className:"h-4 w-4 mr-2"}),"Categories"]})}),e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{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:ye,disabled:ie.isPending,children:[ie.isPending?e.jsx(As,{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 jzt(){const{user:t,isAdmin:s,isBrokerageManager:r}=Gs(),[n,a]=S.useState(!0),[o,l]=S.useState(null),[i,d]=S.useState(""),[u,p]=S.useState(!1),[g,v]=S.useState(null),[_,b]=S.useState("");S.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:j=[]}=a5t(o),{data:w=[],isLoading:N}=i5t(o,g),C=S.useMemo(()=>{if(!_.trim())return w;const A=_.toLowerCase();return w.filter(I=>{var L;return I.title.toLowerCase().includes(A)||((L=I.description)==null?void 0:L.toLowerCase().includes(A))||I.content_type.toLowerCase().includes(A)})},[w,_]);return n?e.jsx(Ms,{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(Ms,{title:`${i} Content`,description:"Brokerage Content Hub",children:e.jsxs("div",{className:"space-y-6",children:[u&&o&&e.jsx(wzt,{brokerageId:o,categories:j}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(xn,{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:A=>b(A.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(K,{variant:g===null?"default":"outline",size:"sm",onClick:()=>v(null),children:"All"}),j.map(A=>e.jsxs(K,{variant:g===A.id?"default":"outline",size:"sm",onClick:()=>v(A.id),children:[e.jsx("span",{className:"mr-1",children:A.icon}),A.name]},A.id))]})]}),N?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"})}):C.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($h,{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:C.map(A=>e.jsx(_zt,{item:A,canManage:u},A.id))})]})}):e.jsx(Ms,{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(Ca,{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 iEe={video:{icon:dl,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:Sn,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:Ho,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:Rl,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function kzt(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 Nzt(t){try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function Szt(t){try{return new URL(t).hostname.includes("vimeo.com")}catch{return!1}}function Czt(t){try{const s=t.match(/vimeo\.com\/(\d+)/);if(s)return`https://player.vimeo.com/video/${s[1]}`}catch{}return null}function Mzt(){const{contentId:t}=Co(),{data:s,isLoading:r}=Ct({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(Ms,{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(Ms,{title:"Brokerage Content",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ca,{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=iEe[s.content_type]||iEe.link,a=n.icon,o=s.url||s.file_url,l=o&&Nzt(o)?kzt(o):null,i=o&&Szt(o)?Czt(o):null,d=l||i;return e.jsx(Ms,{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(Ka,{className:"h-4 w-4"}),"Back to Content"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(at,{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(at,{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 ",ws(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:ws(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(gi,{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(rn,{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 Tzt(){const t=Lr(),[s,r]=S.useState(""),[n,a]=S.useState("grid"),{data:o,isLoading:l}=Ct({queryKey:["newsletters"],queryFn:async()=>{const{data:A,error:I}=await G.from("newsletter_content").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(I)throw I;return A}}),{data:i}=Ct({queryKey:["newsletter-likes-all"],queryFn:async()=>{const{data:A}=await G.from("newsletter_likes").select("newsletter_id");return A||[]}}),{data:d}=Ct({queryKey:["newsletter-comments-all"],queryFn:async()=>{const{data:A}=await G.from("newsletter_comments").select("newsletter_id");return A||[]}}),{data:u}=Ct({queryKey:["newsletter-resource-counts"],queryFn:async()=>{const[A,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:A.data||[],pdfs:I.data||[],videos:L.data||[],drives:R.data||[]}}}),p=A=>(i==null?void 0:i.filter(I=>I.newsletter_id===A).length)||0,g=A=>(d==null?void 0:d.filter(I=>I.newsletter_id===A).length)||0,v=A=>{var I;return((I=u==null?void 0:u.canva)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},_=A=>{var I;return((I=u==null?void 0:u.pdfs)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},b=A=>{var I;return((I=u==null?void 0:u.videos)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},j=A=>{var I;return((I=u==null?void 0:u.drives)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},w=A=>v(A)+_(A)+b(A)+j(A),N=o==null?void 0:o.filter(A=>{var I;return A.title.toLowerCase().includes(s.toLowerCase())||((I=A.description)==null?void 0:I.toLowerCase().includes(s.toLowerCase()))}),C=A=>{t(`/newsletters/${A}`)};return e.jsx(Ms,{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(xn,{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:A=>r(A.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(pp,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(qh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[(N==null?void 0:N.length)||0," item",(N==null?void 0:N.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((A,I)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-0",children:[e.jsx(gs,{className:"aspect-[3/2] w-full"}),e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsx(gs,{className:"h-5 w-3/4"}),e.jsx(gs,{className:"h-4 w-full"})]})]})},I))}),!l&&(N==null?void 0:N.length)===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Sn,{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&&N&&N.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:N.map(A=>{const I=w(A.id),L=v(A.id),R=_(A.id),$=b(A.id);return n==="grid"?e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer border-border/50",onClick:()=>C(A.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:A.preview_image_url?e.jsx("img",{src:A.preview_image_url,alt:A.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(Sn,{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:A.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"}),ws(new Date(A.publish_date),"MMM d, yyyy")]})]}),A.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:A.description.replace(/<[^>]*>/g,"")}),I>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[L>0&&e.jsxs(at,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(Rl,{className:"h-3 w-3"})," ",L," Template",L>1?"s":""]}),R>0&&e.jsxs(at,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(gi,{className:"h-3 w-3"})," ",R," PDF",R>1?"s":""]}),$>0&&e.jsxs(at,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(dl,{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(hu,{className:"h-3 w-3"})," ",p(A.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pc,{className:"h-3 w-3"})," ",g(A.id)]})]})]})]},A.id):e.jsx(Ee,{className:"group overflow-hidden hover:shadow-md transition-all duration-200 cursor-pointer border-border/50",onClick:()=>C(A.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:A.preview_image_url?e.jsx("img",{src:A.preview_image_url,alt:A.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(Sn,{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:A.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"}),ws(new Date(A.publish_date),"MMM d, yyyy")]})]}),A.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:A.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(hu,{className:"h-3 w-3"})," ",p(A.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pc,{className:"h-3 w-3"})," ",g(A.id)]})]})]})]})},A.id)})})]})})}function Azt({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 Ezt(){const{id:t}=Co(),s=Lr(),{user:r}=Gs(),{toast:n}=Ea(),a=ns(),{trackEngagement:o}=RL(),[l,i]=S.useState(""),{data:d,isLoading:u}=Ct({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});S.useEffect(()=>{d&&o("newsletter",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:p}=Ct({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:g}=Ct({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:v}=Ct({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:_}=Ct({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}=Ct({queryKey:["newsletter-likes",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_likes").select("*").eq("newsletter_id",t);return L||[]},enabled:!!t}),{data:j}=Ct({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}),w=b==null?void 0:b.some(L=>L.user_id===(r==null?void 0:r.id)),N=Ot({mutationFn:async()=>{w?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]})}}),C=Ot({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"})}}),A=Ot({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(dl,{className:"h-4 w-4"})," Watch Video"]})};return u?e.jsx(Ms,{title:"",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{className:"h-8 w-32"}),e.jsx(gs,{className:"h-64 w-full"}),e.jsx(gs,{className:"h-32 w-full"})]})}):d?e.jsx(Ms,{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(Ka,{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:ws(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(Azt,{rows:d.content_blocks||[]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(kM,{resourceType:"newsletter",resourceId:d.id,resourceTitle:d.title}),e.jsxs(K,{variant:w?"default":"outline",size:"sm",onClick:()=>N.mutate(),children:[e.jsx(Ni,{className:`h-4 w-4 mr-1 ${w?"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(Lt,{children:e.jsx(zt,{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(Rl,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"font-medium",children:L.title}),e.jsx(rn,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},L.id))})]}),p&&p.length>0&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(rn,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:L.title})]},L.id))})]}),g&&g.length>0&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-lg",children:"PDF Downloads"})}),e.jsx(Oe,{className:"space-y-2",children:g.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(Sn,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"font-medium flex-1",children:L.name}),e.jsx(gi,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]}),v&&v.length>0&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-lg",children:"Videos"})}),e.jsx(Oe,{className:"space-y-6",children:v.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(Lt,{children:e.jsxs(zt,{className:"text-lg",children:["Comments (",(j==null?void 0:j.length)||0,")"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Tr,{placeholder:"Write a comment...",value:l,onChange:L=>i(L.target.value),className:"flex-1"}),e.jsx(K,{onClick:()=>l.trim()&&C.mutate(l),disabled:!l.trim()||C.isPending,children:e.jsx(Ta,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-4",children:j==null?void 0:j.map(L=>{var R,$,q;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx(fn,{className:"h-8 w-8",children:e.jsx(gn,{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:ws(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:()=>A.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(Ms,{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 Pzt({rows:t,onChange:s}){const[r,n]=S.useState(null),a=()=>{s([...t,{columns:[{title:"",description:""},{title:"",description:""},{title:"",description:""}]}])},o=u=>{s(t.filter((p,g)=>g!==u))},l=(u,p,g,v)=>{const _=[...t];_[u]={..._[u],columns:_[u].columns.map((b,j)=>j===p?{...b,[g]:v}:b)},s(_)},i=async(u,p,g)=>{var b;const v=(b=g.target.files)==null?void 0:b[0];if(!v)return;const _=`${u}-${p}`;n(_);try{const j=`content-blocks/${Date.now()}-${v.name}`,{error:w}=await G.storage.from("newsletter-content").upload(j,v);if(!w){const{data:N}=G.storage.from("newsletter-content").getPublicUrl(j);l(u,p,"image_url",N.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(Ru,{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((g,v)=>{const _=`${p}-${v}`;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 ",v+1]}),g.image_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:g.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,v),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,v,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:g.title,onChange:b=>l(p,v,"title",b.target.value),className:"h-8 text-sm"}),e.jsx(Tr,{placeholder:"Description",value:g.description,onChange:b=>l(p,v,"description",b.target.value),className:"text-sm min-h-[60px] resize-none"})]},v)})})]})]},p))]})}function Izt(){const{toast:t}=Ea(),s=ns(),[r,n]=S.useState(!1),[a,o]=S.useState(null),[l,i]=S.useState({title:"",description:"",publish_date:ws(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),[d,u]=S.useState(null),[p,g]=S.useState(null),[v,_]=S.useState([]),[b,j]=S.useState([]),[w,N]=S.useState([]),[C,A]=S.useState([]),[I,L]=S.useState([]),[R,$]=S.useState([]),[q,U]=S.useState(!1),{data:V,isLoading:X}=Ct({queryKey:["admin-newsletters"],queryFn:async()=>{const{data:_e,error:Me}=await G.from("newsletter_content").select("*").order("publish_date",{ascending:!1});if(Me)throw Me;return _e}}),se=Ot({mutationFn:async _e=>{const{data:Me,error:Te}=await G.from("newsletter_content").insert({title:_e.title,description:_e.description||null,preview_image_url:_e.preview_image_url,publish_date:_e.publish_date,is_published:_e.is_published,content_blocks:_e.content_blocks}).select().single();if(Te)throw Te;return Me},onSuccess:async _e=>{await de(_e.id),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter created successfully"}),_e.is_published&&K8t(_e.title,_e.id),le()},onError:_e=>{t({title:"Error creating newsletter",description:_e.message,variant:"destructive"})}}),te=Ot({mutationFn:async _e=>{const{error:Me}=await G.from("newsletter_content").update({title:_e.title,description:_e.description||null,preview_image_url:_e.preview_image_url,publish_date:_e.publish_date,is_published:_e.is_published,content_blocks:_e.content_blocks}).eq("id",_e.id);if(Me)throw Me;return _e.id},onSuccess:async _e=>{await de(_e),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter updated successfully"}),le()},onError:_e=>{t({title:"Error updating newsletter",description:_e.message,variant:"destructive"})}}),Y=Ot({mutationFn:async _e=>{const{error:Me}=await G.from("newsletter_content").delete().eq("id",_e);if(Me)throw Me},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter deleted successfully"})},onError:_e=>{t({title:"Error deleting newsletter",description:_e.message,variant:"destructive"})}}),de=async _e=>{await G.from("newsletter_drive_links").delete().eq("newsletter_id",_e),await G.from("newsletter_pdfs").delete().eq("newsletter_id",_e),await G.from("newsletter_videos").delete().eq("newsletter_id",_e),await G.from("newsletter_canva_links").delete().eq("newsletter_id",_e);for(const Me of R){const Te=`${_e}/${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})}}v.length>0&&await G.from("newsletter_drive_links").insert(v.map((Me,Te)=>({newsletter_id:_e,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:_e,name:Me.name,file_url:Me.file_url,file_size:Me.file_size||null,sort_order:Te}))),w.length>0&&await G.from("newsletter_videos").insert(w.map((Me,Te)=>({newsletter_id:_e,title:Me.title,video_url:Me.video_url,sort_order:Te}))),C.length>0&&await G.from("newsletter_canva_links").insert(C.map((Me,Te)=>({newsletter_id:_e,title:Me.title,canva_share_link:Me.canva_share_link,sort_order:Te})))},ie=async _e=>{o(_e),i({title:_e.title,description:_e.description||"",publish_date:ws(new Date(_e.publish_date),"yyyy-MM-dd'T'HH:mm"),is_published:_e.is_published}),g(_e.preview_image_url),L(_e.content_blocks||[]);const[Me,Te,Fe,Ae]=await Promise.all([G.from("newsletter_drive_links").select("*").eq("newsletter_id",_e.id).order("sort_order"),G.from("newsletter_pdfs").select("*").eq("newsletter_id",_e.id).order("sort_order"),G.from("newsletter_videos").select("*").eq("newsletter_id",_e.id).order("sort_order"),G.from("newsletter_canva_links").select("*").eq("newsletter_id",_e.id).order("sort_order")]);_(Me.data||[]),j(Te.data||[]),N(Fe.data||[]),A(Ae.data||[]),$([]),n(!0)},ae=async _e=>{const[Me,Te,Fe,Ae]=await Promise.all([G.from("newsletter_drive_links").select("*").eq("newsletter_id",_e.id).order("sort_order"),G.from("newsletter_pdfs").select("*").eq("newsletter_id",_e.id).order("sort_order"),G.from("newsletter_videos").select("*").eq("newsletter_id",_e.id).order("sort_order"),G.from("newsletter_canva_links").select("*").eq("newsletter_id",_e.id).order("sort_order")]);o(null),i({title:`${_e.title} (Copy)`,description:_e.description||"",publish_date:ws(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),g(_e.preview_image_url),L(_e.content_blocks||[]),_((Me.data||[]).map(({id:Ue,...ut})=>ut)),j((Te.data||[]).map(({id:Ue,...ut})=>ut)),N((Fe.data||[]).map(({id:Ue,...ut})=>ut)),A((Ae.data||[]).map(({id:Ue,...ut})=>ut)),$([]),n(!0)},le=()=>{n(!1),o(null),i({title:"",description:"",publish_date:ws(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),u(null),g(null),_([]),j([]),N([]),A([]),L([]),$([])},pe=async _e=>{var Te;const Me=(Te=_e.target.files)==null?void 0:Te[0];Me&&(u(Me),g(URL.createObjectURL(Me)))},be=async()=>{if(!l.title){t({title:"Title is required",variant:"destructive"});return}U(!0);let _e=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);_e=Fe.publicUrl}}a?te.mutate({id:a.id,...l,preview_image_url:_e,content_blocks:I}):se.mutate({...l,preview_image_url:_e,content_blocks:I}),U(!1)},ye=()=>_([...v,{title:"",drive_url:"",sort_order:v.length}]),we=()=>N([...w,{title:"",video_url:"",sort_order:w.length}]),Ne=()=>A([...C,{title:"",canva_share_link:"",sort_order:C.length}]),Ke=_e=>{const Me=_e.target.files;if(!Me)return;const Te=Array.from(Me).map(Fe=>({file:Fe,name:Fe.name.replace(/\.[^/.]+$/,"")}));$([...R,...Te])};return e.jsx(Ms,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{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(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.filter(_e=>_e.is_published).length)||0})})]})]}),e.jsxs(vs,{open:r,onOpenChange:_e=>!_e&&le(),children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"})," Add Newsletter"]})}),e.jsxs(ys,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{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:_e=>i({...l,title:_e.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:_e=>i({...l,publish_date:_e.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Zg,{content:l.description,onChange:_e=>i({...l,description:_e}),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),g(null)},children:e.jsx(Ur,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:[e.jsx(Re,{type:"file",accept:"image/*",onChange:pe,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(Xa,{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:_e=>i({...l,is_published:_e})}),e.jsx(ve,{children:"Published"})]}),e.jsx(Pzt,{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"]})]}),C.map((_e,Me)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Re,{placeholder:"Link title",value:_e.title,onChange:Te=>{const Fe=[...C];Fe[Me].title=Te.target.value,A(Fe)},className:"w-1/3"}),e.jsx(Re,{placeholder:"Canva share link",value:_e.canva_share_link,onChange:Te=>{const Fe=[...C];Fe[Me].canva_share_link=Te.target.value,A(Fe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>A(C.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:ye,children:[e.jsx(Zs,{className:"mr-1 h-3 w-3"})," Add Link"]})]}),v.map((_e,Me)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Re,{placeholder:"Link title",value:_e.title,onChange:Te=>{const Fe=[...v];Fe[Me].title=Te.target.value,_(Fe)},className:"w-1/3"}),e.jsx(Re,{placeholder:"Google Drive URL",value:_e.drive_url,onChange:Te=>{const Fe=[...v];Fe[Me].drive_url=Te.target.value,_(Fe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>_(v.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:Ke,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(Xa,{className:"mr-1 h-3 w-3"})," Upload PDF"]})})]})]}),b.map((_e,Me)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm",children:_e.name}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>j(b.filter((Te,Fe)=>Fe!==Me)),children:e.jsx(Ur,{className:"h-4 w-4"})})]},`existing-${Me}`)),R.map((_e,Me)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Re,{value:_e.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:we,children:[e.jsx(Zs,{className:"mr-1 h-3 w-3"})," Add Video"]})]}),w.map((_e,Me)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Re,{placeholder:"Video title",value:_e.title,onChange:Te=>{const Fe=[...w];Fe[Me].title=Te.target.value,N(Fe)},className:"w-1/3"}),e.jsx(Re,{placeholder:"Video URL",value:_e.video_url,onChange:Te=>{const Fe=[...w];Fe[Me].video_url=Te.target.value,N(Fe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>N(w.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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:X?e.jsx(js,{children:e.jsx(it,{colSpan:4,className:"text-center py-8",children:"Loading..."})}):(V==null?void 0:V.length)===0?e.jsx(js,{children:e.jsx(it,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"No newsletters yet. Create your first one!"})}):V==null?void 0:V.map(_e=>e.jsxs(js,{children:[e.jsx(it,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[_e.preview_image_url?e.jsx("img",{src:_e.preview_image_url,alt:_e.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(Sn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:_e.title}),_e.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:_e.description.replace(/<[^>]*>/g,"")})]})]})}),e.jsx(it,{children:ws(new Date(_e.publish_date),"MMM d, yyyy")}),e.jsx(it,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${_e.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:_e.is_published?"Published":"Draft"})}),e.jsx(it,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ie(_e),title:"Edit",children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ae(_e),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?")&&Y.mutate(_e.id)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},_e.id))})]})})})]})})}const oEe={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 Lzt(){const{user:t}=Gs(),{toast:s}=Ea(),r=Lr(),n=ns(),[a,o]=S.useState(""),[l,i]=S.useState("popular"),[d,u]=S.useState(!1),[p,g]=S.useState(""),[v,_]=S.useState(""),[b,j]=S.useState(!1),{data:w=[],isLoading:N}=Ct({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(ie=>ie.user_id))||[])],{data:V}=await G.from("profiles").select("id, name").in("id",U),X=new Map((V==null?void 0:V.map(ie=>[ie.id,ie]))||[]);let se=[];if(t){const{data:ie}=await G.from("wishlist_votes").select("item_id").eq("user_id",t.id);se=(ie==null?void 0:ie.map(ae=>ae.item_id))||[]}const te=($==null?void 0:$.map(ie=>ie.id))||[],{data:Y}=await G.from("wishlist_comments").select("item_id").in("item_id",te),de=new Map;return Y==null||Y.forEach(ie=>{de.set(ie.item_id,(de.get(ie.item_id)||0)+1)}),$==null?void 0:$.map(ie=>{const ae=X.get(ie.user_id),le=(ae==null?void 0:ae.name)||"Unknown";return{...ie,user_name:le,user_initials:le.split(" ").map(pe=>pe[0]).join("").toUpperCase().slice(0,2),has_voted:se.includes(ie.id),comment_count:de.get(ie.id)||0}})}}),C=Ot({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),g(""),_(""),s({title:"Idea submitted!",description:"Your idea has been added to the wishlist."})},onError:R=>{s({title:"Error",description:R.message,variant:"destructive"})}}),A=Ot({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 $=w.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=w.filter(R=>R.title.toLowerCase().includes(a.toLowerCase())||R.description.toLowerCase().includes(a.toLowerCase())),L=()=>{if(!p.trim()||!v.trim()){s({title:"Error",description:"Please fill in both title and description.",variant:"destructive"});return}C.mutate({title:p.trim(),description:v.trim()})};return e.jsx(Ms,{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(e_,{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(vs,{open:d,onOpenChange:u,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Idea"]})}),e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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=>g(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Tr,{id:"description",placeholder:"Describe your idea in detail. What problem does it solve? How would it help agents?",value:v,onChange:R=>_(R.target.value),rows:4})]}),e.jsx(K,{onClick:L,className:"w-full",disabled:C.isPending,children:C.isPending?e.jsxs(e.Fragment,{children:[e.jsx(As,{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(xn,{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(ja,{value:l,onValueChange:R=>i(R),children:e.jsxs(va,{children:[e.jsx(Ns,{value:"popular",children:"Most Popular"}),e.jsx(Ns,{value:"latest",children:"Latest"}),e.jsx(Ns,{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:()=>j(!b),children:b?"Show All Ideas":"My Ideas"})}),N?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(As,{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(e_,{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(),A.mutate({itemId:R.id,hasVoted:R.has_voted||!1})},className:Et("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(qd,{className:Et("h-4 w-4",R.has_voted&&"fill-current")}),e.jsx("span",{className:"text-sm font-semibold",children:R.vote_count})]}),e.jsx(fn,{className:"h-10 w-10 bg-primary/20",children:e.jsx(gn,{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(at,{className:Et("text-xs",oEe[R.status].color),children:oEe[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 lEe={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 Dzt(){const{itemId:t}=Co(),s=Lr(),{user:r}=Gs(),{toast:n}=Ea(),a=ns(),[o,l]=S.useState(""),{data:i=!1}=Ct({queryKey:["user-is-admin",r==null?void 0:r.id],queryFn:async()=>{if(!r)return!1;const{data:w,error:N}=await G.from("user_roles").select("role").eq("user_id",r.id).eq("role","admin").maybeSingle();return!N&&!!w},enabled:!!r}),{data:d,isLoading:u}=Ct({queryKey:["wishlist-item",t],queryFn:async()=>{const{data:w,error:N}=await G.from("wishlist_items").select("*").eq("id",t).single();if(N)throw N;const{data:C}=await G.from("profiles").select("name").eq("id",w.user_id).single();let A=!1;if(r){const{data:I}=await G.from("wishlist_votes").select("id").eq("item_id",t).eq("user_id",r.id).maybeSingle();A=!!I}return{...w,user_name:(C==null?void 0:C.name)||"Unknown",user_initials:((C==null?void 0:C.name)||"U").split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),has_voted:A}}}),{data:p=[],isLoading:g}=Ct({queryKey:["wishlist-comments",t],queryFn:async()=>{const{data:w,error:N}=await G.from("wishlist_comments").select("*").eq("item_id",t).order("created_at",{ascending:!0});if(N)throw N;const C=[...new Set((w==null?void 0:w.map(L=>L.user_id))||[])],{data:A}=await G.from("profiles").select("id, name").in("id",C),I=new Map((A==null?void 0:A.map(L=>[L.id,L]))||[]);return w==null?void 0:w.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)}})}}),v=Ot({mutationFn:async w=>{if(w){const{error:N}=await G.from("wishlist_votes").delete().eq("item_id",t).eq("user_id",r.id);if(N)throw N;return{wasAdded:!1}}else{const{error:N}=await G.from("wishlist_votes").insert({item_id:t,user_id:r.id});if(N)throw N;return{wasAdded:!0}}},onSuccess:async w=>{if(a.invalidateQueries({queryKey:["wishlist-item",t]}),a.invalidateQueries({queryKey:["wishlist-items"]}),w!=null&&w.wasAdded&&d){const N=(d.vote_count||0)+1;G.functions.invoke("wishlist-notify",{body:{itemId:t,voteCount:N}}).catch(console.error)}},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),_=Ot({mutationFn:async w=>{const{error:N}=await G.from("wishlist_comments").insert({item_id:t,user_id:r.id,content:w});if(N)throw N},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),l(""),n({title:"Comment added!"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),b=Ot({mutationFn:async w=>{const{error:N}=await G.from("wishlist_comments").delete().eq("id",w);if(N)throw N},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),n({title:"Comment deleted"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),j=()=>{o.trim()&&_.mutate(o.trim())};return u?e.jsx(Ms,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx(gs,{className:"h-8 w-32 mb-6"}),e.jsx(gs,{className:"h-48 w-full mb-6"}),e.jsx(gs,{className:"h-32 w-full"})]})}):d?e.jsx(Ms,{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(Ka,{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:()=>v.mutate(d.has_voted),className:Et("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(qd,{className:Et("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(at,{className:Et("text-xs",lEe[d.status].color),children:lEe[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(fn,{className:"h-6 w-6",children:e.jsx(gn,{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(Sae,{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:j,disabled:!o.trim()||_.isPending,size:"icon",className:"h-auto",children:_.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(Ta,{className:"h-4 w-4"})})]}),g?e.jsx("div",{className:"space-y-4",children:[1,2].map(w=>e.jsx(gs,{className:"h-20 w-full"},w))}):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(w=>e.jsxs("div",{className:"flex gap-3 p-3 bg-muted/30 rounded-lg",children:[e.jsx(fn,{className:"h-8 w-8",children:e.jsx(gn,{className:"bg-primary/20 text-primary text-xs",children:w.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:w.user_name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(w.created_at).toLocaleDateString()})]}),e.jsx(iwe,{content:w.content,className:"text-sm text-foreground"})]}),(r==null?void 0:r.id)===w.user_id&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>b.mutate(w.id),children:e.jsx(jr,{className:"h-4 w-4"})})]},w.id))})]})]})}):e.jsx(Ms,{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 cEe={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"}},dEe=["open","under_review","planned","in_progress","launched","declined"];function Ozt(){const{toast:t}=Ea(),s=Lr(),r=ns(),[n,a]=S.useState(""),[o,l]=S.useState("all"),[i,d]=S.useState(!1),[u,p]=S.useState(null),{data:g=[],isLoading:v}=Ct({queryKey:["admin-wishlist-items"],queryFn:async()=>{const{data:N,error:C}=await G.from("wishlist_items").select("*").order("vote_count",{ascending:!1});if(C)throw C;const A=[...new Set((N==null?void 0:N.map(U=>U.user_id))||[])],{data:I}=await G.from("profiles").select("id, name, email").in("id",A),L=new Map((I==null?void 0:I.map(U=>[U.id,U]))||[]),R=(N==null?void 0:N.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)}),N==null?void 0:N.map(U=>{const V=L.get(U.user_id);return{...U,user_name:(V==null?void 0:V.name)||"Unknown",user_email:(V==null?void 0:V.email)||"",comment_count:q.get(U.id)||0}})}}),_=Ot({mutationFn:async({itemId:N,status:C})=>{const{error:A}=await G.from("wishlist_items").update({status:C}).eq("id",N);if(A)throw A},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),t({title:"Status updated!"})},onError:N=>{t({title:"Error",description:N.message,variant:"destructive"})}}),b=Ot({mutationFn:async N=>{const{error:C}=await G.from("wishlist_items").delete().eq("id",N);if(C)throw C},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),d(!1),p(null),t({title:"Item deleted!"})},onError:N=>{t({title:"Error",description:N.message,variant:"destructive"})}}),j=g.filter(N=>{const C=N.title.toLowerCase().includes(n.toLowerCase())||N.description.toLowerCase().includes(n.toLowerCase())||N.user_name.toLowerCase().includes(n.toLowerCase()),A=o==="all"||N.status===o;return C&&A}),w={total:g.length,open:g.filter(N=>N.status==="open").length,inProgress:g.filter(N=>N.status==="in_progress").length,launched:g.filter(N=>N.status==="launched").length,highVotes:g.filter(N=>N.vote_count>=10).length};return e.jsx(Ms,{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(Ka,{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:w.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:w.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:w.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:w.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:w.highVotes})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{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:N=>a(N.target.value),className:"pl-10"})]}),e.jsxs(tr,{value:o,onValueChange:N=>l(N),children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{placeholder:"Filter by status"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Statuses"}),dEe.map(N=>e.jsx(At,{value:N,children:cEe[N].label},N))]})]})]}),v?e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(N=>e.jsx(gs,{className:"h-16 w-full"},N))}):e.jsx("div",{className:"bg-card border rounded-lg overflow-hidden",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-[60px]",children:"Votes"}),e.jsx(jt,{children:"Title"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Submitted By"}),e.jsx(jt,{className:"hidden sm:table-cell",children:"Comments"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(En,{children:j.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No items found"})}):j.map(N=>e.jsxs(js,{className:Et(N.vote_count>=10&&"bg-primary/5"),children:[e.jsx(it,{children:e.jsx(at,{variant:N.vote_count>=10?"default":"secondary",children:N.vote_count})}),e.jsx(it,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium line-clamp-1",children:N.title}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:N.description})]})}),e.jsx(it,{className:"hidden md:table-cell",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:N.user_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:N.user_email})]})}),e.jsx(it,{className:"hidden sm:table-cell",children:N.comment_count}),e.jsx(it,{children:e.jsxs(tr,{value:N.status,onValueChange:C=>_.mutate({itemId:N.id,status:C}),children:[e.jsx(Js,{className:"w-[140px] h-8",children:e.jsx(sr,{})}),e.jsx(er,{children:dEe.map(C=>e.jsx(At,{value:C,children:cEe[C].label},C))})]})}),e.jsx(it,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(`/wishlist/${N.id}`,"_blank"),children:e.jsx(rn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{p(N.id),d(!0)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},N.id))})]})}),e.jsx(vs,{open:i,onOpenChange:d,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})})}function Rzt(){const{user:t}=Gs(),[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState(!1),[g,v]=S.useState(null),[_,b]=S.useState(""),[j,w]=S.useState(""),[N,C]=S.useState(""),[A,I]=S.useState(""),[L,R]=S.useState(""),[$,q]=S.useState(!1),[U,V]=S.useState(""),[X,se]=S.useState("once"),[te,Y]=S.useState([]),[de,ie]=S.useState([]),[ae,le]=S.useState(!1),[pe,be]=S.useState(!1),[ye,we]=S.useState([]),[Ne,Ke]=S.useState({total:0,dismissed:0});S.useEffect(()=>{_e()},[]);const _e=async()=>{const{data:Ye,error:mt}=await G.from("levelup_briefs").select("*").order("created_at",{ascending:!1});mt?(fe.error("Failed to fetch briefs"),console.error(mt)):r(Ye||[]),a(!1)},Me=()=>{b(""),w(""),C(""),I(""),R(""),q(!1),V(new Date().toISOString().slice(0,16)),se("once"),Y([]),ie([]),d(null)},Te=()=>{Me(),l(!0)},Fe=async Ye=>{d(Ye),b(Ye.title),w(Ye.description||""),C(Ye.video_url||""),I(Ye.graphic_url||""),R(Ye.graphic_link_url||""),q(Ye.is_published),V(Ye.publish_date.slice(0,16)),se(Ye.show_frequency);const{data:mt}=await G.from("levelup_brief_links").select("*").eq("brief_id",Ye.id).order("sort_order");Y((mt==null?void 0:mt.map(He=>({title:He.title,url:He.url})))||[]);const{data:Ze}=await G.from("levelup_brief_polls").select("*").eq("brief_id",Ye.id).order("sort_order");if(Ze){const He=[];for(const et of Ze){const{data:Rt}=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:(Rt==null?void 0:Rt.map(qt=>qt.option_text))||[]})}ie(He)}l(!0)},Ae=async Ye=>{var Ze;const mt=(Ze=Ye.target.files)==null?void 0:Ze[0];if(mt){le(!0);try{const He=await G.functions.invoke("bunny-upload",{body:{action:"create",title:mt.name.replace(/\.[^/.]+$/,"")}});if(He.error)throw He.error;const{videoId:et,libraryId:Rt}=He.data,qt=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:et}});if(qt.error)throw qt.error;const{uploadUrl:ls,apiKey:Kt}=qt.data,Qt=new XMLHttpRequest;await new Promise((dr,bt)=>{Qt.upload.addEventListener("progress",ks=>{if(ks.lengthComputable){const ir=Math.round(ks.loaded/ks.total*100);console.log("Upload progress:",ir)}}),Qt.addEventListener("load",()=>{Qt.status>=200&&Qt.status<300?dr():bt(new Error(`Upload failed with status ${Qt.status}`))}),Qt.addEventListener("error",()=>bt(new Error("Upload failed"))),Qt.open("PUT",ls),Qt.setRequestHeader("AccessKey",Kt),Qt.send(mt)});const fs=`https://player.mediadelivery.net/embed/${Rt}/${et}`;C(fs),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 Ye;if(i){const{error:mt}=await G.from("levelup_briefs").update({title:_,description:j||null,video_url:N||null,graphic_url:A||null,graphic_link_url:L||null,is_published:$,publish_date:U,show_frequency:X}).eq("id",i.id);if(mt)throw mt;Ye=i.id,await G.from("levelup_brief_links").delete().eq("brief_id",Ye);const{data:Ze}=await G.from("levelup_brief_polls").select("id").eq("brief_id",Ye);if(Ze)for(const He of Ze)await G.from("levelup_brief_poll_options").delete().eq("poll_id",He.id);await G.from("levelup_brief_polls").delete().eq("brief_id",Ye)}else{const{data:mt,error:Ze}=await G.from("levelup_briefs").insert({title:_,description:j||null,video_url:N||null,graphic_url:A||null,graphic_link_url:L||null,is_published:$,publish_date:U,show_frequency:X,created_by:t==null?void 0:t.id}).select().single();if(Ze)throw Ze;Ye=mt.id}if(te.length>0){const mt=te.map((Ze,He)=>({brief_id:Ye,title:Ze.title,url:Ze.url,sort_order:He}));await G.from("levelup_brief_links").insert(mt)}for(let mt=0;mt0){const Rt=Ze.options.map((qt,ls)=>({poll_id:He.id,option_text:qt,sort_order:ls}));await G.from("levelup_brief_poll_options").insert(Rt)}}fe.success(i?"Brief updated":"Brief created"),l(!1),Me(),_e()}catch(Ye){console.error("Error saving brief:",Ye),fe.error("Failed to save brief")}},ut=async Ye=>{if(confirm("Are you sure you want to delete this brief?"))try{const{error:mt}=await G.from("levelup_briefs").delete().eq("id",Ye);if(mt)throw mt;fe.success("Brief deleted"),_e()}catch(mt){console.error("Error deleting brief:",mt),fe.error("Failed to delete brief")}},De=async Ye=>{v(Ye);const{count:mt}=await G.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ye.id),{count:Ze}=await G.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ye.id).not("dismissed_at","is",null);Ke({total:mt||0,dismissed:Ze||0});const{data:He}=await G.from("levelup_brief_polls").select("*").eq("brief_id",Ye.id).order("sort_order");if(He){const et=[];for(const Rt of He){const{data:qt}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",Rt.id).order("sort_order"),{data:ls}=await G.from("levelup_brief_poll_responses").select("option_id, user_id").eq("poll_id",Rt.id),Kt=[...new Set((ls==null?void 0:ls.map(ks=>ks.user_id))||[])];let Qt={};if(Kt.length>0){const{data:ks}=await G.from("profiles").select("id, name, email").in("id",Kt);ks&&ks.forEach(ir=>{Qt[ir.id]=ir.name||ir.email||"Unknown"})}const fs=(ls||[]).map(ks=>({optionId:ks.option_id,userName:Qt[ks.user_id]||"Unknown",userId:ks.user_id})),dr={};let bt=0;qt&&qt.forEach(ks=>{const ir=(ls==null?void 0:ls.filter(Rr=>Rr.option_id===ks.id).length)||0;dr[ks.id]=ir,bt+=ir}),et.push({...Rt,options:qt||[],results:dr,respondents:fs,totalResponses:Rt.poll_type==="single"?new Set(ls==null?void 0:ls.map(ks=>ks.user_id)).size:bt})}we(et)}p(!0)},Dt=()=>{Y([...te,{title:"",url:""}])},he=(Ye,mt,Ze)=>{const He=[...te];He[Ye][mt]=Ze,Y(He)},Ve=Ye=>{Y(te.filter((mt,Ze)=>Ze!==Ye))},nt=()=>{ie([...de,{question:"",poll_type:"single",options:["",""]}])},Qe=(Ye,mt)=>{const Ze=[...de];Ze[Ye].question=mt,ie(Ze)},ke=(Ye,mt)=>{const Ze=[...de];Ze[Ye].poll_type=mt,ie(Ze)},ot=Ye=>{const mt=[...de];mt[Ye].options.push(""),ie(mt)},qe=(Ye,mt,Ze)=>{const He=[...de];He[Ye].options[mt]=Ze,ie(He)},lt=(Ye,mt)=>{const Ze=[...de];Ze[Ye].options=Ze[Ye].options.filter((He,et)=>et!==mt),ie(Ze)},We=Ye=>{ie(de.filter((mt,Ze)=>Ze!==Ye))};return e.jsxs(Ms,{title:"The LevelUp Brief",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Frequency"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:n?e.jsx(js,{children:e.jsx(it,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):s.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No briefs created yet"})}):s.map(Ye=>e.jsxs(js,{children:[e.jsx(it,{className:"font-medium",children:Ye.title}),e.jsx(it,{children:e.jsx(at,{variant:Ye.is_published?"default":"secondary",children:Ye.is_published?"Published":"Draft"})}),e.jsx(it,{className:"capitalize",children:Ye.show_frequency.replace("_"," ")}),e.jsx(it,{children:ws(new Date(Ye.publish_date),"MMM d, yyyy h:mm a")}),e.jsx(it,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>De(Ye),children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Fe(Ye),children:e.jsx(Dc,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ut(Ye.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},Ye.id))})]})})})]}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:i?"Edit Brief":"Create New Brief"})}),e.jsxs(ja,{defaultValue:"content",className:"w-full",children:[e.jsxs(va,{className:"grid w-full grid-cols-4",children:[e.jsx(Ns,{value:"content",children:"Content"}),e.jsx(Ns,{value:"media",children:"Media"}),e.jsx(Ns,{value:"links",children:"Links"}),e.jsx(Ns,{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:Ye=>b(Ye.target.value),placeholder:"What's happening at LevelUp..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Zg,{content:j,onChange:Ye=>w(Ye),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:Ye=>V(Ye.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Show Frequency"}),e.jsxs(tr,{value:X,onValueChange:se,children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{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:N,onChange:Ye=>C(Ye.target.value),placeholder:"https://iframe.mediadelivery.net/embed/..."})]}),N&&e.jsx("div",{className:"aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:N,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 Ye=>{var Ze;const mt=(Ze=Ye.target.files)==null?void 0:Ze[0];if(mt){be(!0);try{const He=mt.name.split(".").pop(),et=`brief-graphics/${Date.now()}.${He}`,{error:Rt}=await G.storage.from("banner-images").upload(et,mt,{upsert:!0});if(Rt)throw Rt;const{data:qt}=G.storage.from("banner-images").getPublicUrl(et);I(qt.publicUrl),fe.success("Image uploaded!")}catch(He){console.error(He),fe.error("Failed to upload image")}finally{be(!1)}}},disabled:pe})}),pe&&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:A,onChange:Ye=>I(Ye.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:Ye=>R(Ye.target.value),placeholder:"https://example.com/landing-page"})]}),A&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted border",children:e.jsx("img",{src:A,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:Dt,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),te.map((Ye,mt)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(Re,{value:Ye.title,onChange:Ze=>he(mt,"title",Ze.target.value),placeholder:"Link title",className:"flex-1"}),e.jsx(Re,{value:Ye.url,onChange:Ze=>he(mt,"url",Ze.target.value),placeholder:"https://...",className:"flex-[2]"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ve(mt),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]},mt)),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:nt,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Poll"]})]}),de.map((Ye,mt)=>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:Ye.question,onChange:Ze=>Qe(mt,Ze.target.value),placeholder:"Poll question...",className:"flex-1 mr-2"}),e.jsxs(tr,{value:Ye.poll_type,onValueChange:Ze=>ke(mt,Ze),children:[e.jsx(Js,{className:"w-32",children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"single",children:"Single"}),e.jsx(At,{value:"multi",children:"Multi-select"})]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>We(mt),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"space-y-2 pl-4",children:[Ye.options.map((Ze,He)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:Ze,onChange:et=>qe(mt,He,et.target.value),placeholder:`Option ${He+1}`}),Ye.options.length>2&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>lt(mt,He),children:e.jsx(jr,{className:"h-4 w-4 text-muted-foreground"})})]},He)),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>ot(mt),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Option"]})]})]})},mt)),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(vs,{open:u,onOpenChange:p,children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:["Results: ",g==null?void 0:g.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(Lt,{className:"pb-2",children:e.jsx(zt,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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})})]})]}),ye.length>0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold",children:"Poll Results"}),ye.map(Ye=>e.jsxs(Ee,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:Ye.question}),e.jsx("div",{className:"space-y-2",children:Ye.options.map(mt=>{const Ze=Ye.results[mt.id]||0,He=Ye.totalResponses>0?Math.round(Ze/Ye.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:mt.option_text}),e.jsxs("span",{className:"text-muted-foreground",children:[Ze," (",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}%`}})}),Ze>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:(Ye.respondents||[]).filter(et=>et.optionId===mt.id).map((et,Rt)=>e.jsx(at,{variant:"secondary",className:"text-xs font-normal",children:et.userName},Rt))})]},mt.id)})})]},Ye.id))]}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls in this brief"})]})]})})]})}const Fzt=()=>{const{user:t}=Gs(),{toast:s}=Ea(),r=ns(),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=S.useState(null),[g,v]=S.useState(""),{data:_=[],isLoading:b}=Ct({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}}),j=Ot({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:V}=await G.storage.from("service-images").upload(U,L.image);if(V)throw V;const{data:X}=G.storage.from("service-images").getPublicUrl(U);R=X.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),N()},onError:L=>{s({title:"Error saving service",description:L.message,variant:"destructive"})}}),w=Ot({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"})}}),N=()=>{d({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),v(""),l(null)},C=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}),v(L.preview_image_url||""),a(!0)},A=L=>{var $;const R=($=L.target.files)==null?void 0:$[0];R&&(p(R),v(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}j.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(Ms,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(vs,{open:n,onOpenChange:L=>{a(L),L||N()},children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Service"]})}),e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(Zg,{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"}),g?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:g,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),v("")},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:A,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:j.isPending,children:j.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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-16",children:"Preview"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Signup Link"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:_.map(L=>e.jsxs(js,{children:[e.jsx(it,{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(it,{className:"font-medium",children:L.name}),e.jsx(it,{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(rn,{className:"h-3 w-3"}),"Link"]})}),e.jsx(it,{children:new Date(L.publish_date).toLocaleDateString()}),e.jsx(it,{children:e.jsx(at,{variant:L.is_published?"default":"secondary",children:L.is_published?"Published":"Draft"})}),e.jsx(it,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>C(L),children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this service?")&&w.mutate(L.id)},children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},L.id))})]})})})]})})};function zzt(){const{toast:t}=Ea(),[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""});S.useEffect(()=>{g()},[]);const g=async()=>{try{const{data:w,error:N}=await G.functions.invoke("stripe-manage-coupons",{body:{action:"list"}});if(N)throw N;r(w.coupons||[])}catch(w){console.error("Error fetching coupons:",w),t({title:"Error",description:"Failed to load coupons",variant:"destructive"})}finally{a(!1)}},v=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 w={action:"create",name:u.name,duration:u.duration,promotion_code:u.promotionCode.trim()||void 0};u.discountType==="percent"?w.percent_off=parseFloat(u.percentOff):(w.amount_off=Math.round(parseFloat(u.amountOff)*100),w.currency="usd"),u.duration==="repeating"&&(w.duration_in_months=parseInt(u.durationInMonths));const{data:N,error:C}=await G.functions.invoke("stripe-manage-coupons",{body:w});if(C)throw C;t({title:"Success",description:"Coupon created successfully"}),d(!1),p({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""}),g()}catch(w){console.error("Error creating coupon:",w),t({title:"Error",description:w.message||"Failed to create coupon",variant:"destructive"})}finally{l(!1)}},_=async w=>{if(confirm("Are you sure you want to delete this coupon?"))try{const{error:N}=await G.functions.invoke("stripe-manage-coupons",{body:{action:"delete",couponId:w}});if(N)throw N;t({title:"Success",description:"Coupon deleted successfully"}),g()}catch(N){console.error("Error deleting coupon:",N),t({title:"Error",description:N.message||"Failed to delete coupon",variant:"destructive"})}},b=w=>w.percent_off?`${w.percent_off}% off`:w.amount_off?`$${(w.amount_off/100).toFixed(2)} off`:"N/A",j=w=>{switch(w.duration){case"once":return"Once";case"forever":return"Forever";case"repeating":return`${w.duration_in_months} months`;default:return w.duration}};return e.jsx(Ms,{title:"Subscription Discounts",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{title:"Subscription Discounts",description:"Create and manage discount coupons for subscriptions",children:e.jsxs(vs,{open:i,onOpenChange:d,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Coupon"]})}),e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:w=>p({...u,promotionCode:w.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:w=>p({...u,name:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Discount Type"}),e.jsxs(tr,{value:u.discountType,onValueChange:w=>{const N=w==="amount"&&u.duration==="forever"?"once":u.duration;p({...u,discountType:w,duration:N})},children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"percent",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(y5,{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(Gc,{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:w=>p({...u,percentOff:w.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:w=>p({...u,amountOff:w.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Duration"}),e.jsxs(tr,{value:u.duration,onValueChange:w=>p({...u,duration:w}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{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:w=>p({...u,durationInMonths:w.target.value})})]}),e.jsx(K,{onClick:v,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Coupon"})]})]})]})}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Active Coupons"}),e.jsx(yr,{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(As,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Promo Code"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Discount"}),e.jsx(jt,{children:"Duration"}),e.jsx(jt,{children:"Redemptions"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:s.map(w=>{var N;return e.jsxs(js,{children:[e.jsx(it,{className:"font-mono font-medium",children:((N=w.promotion_codes)==null?void 0:N.length)>0?w.promotion_codes.join(", "):e.jsx("span",{className:"text-muted-foreground text-xs",children:"No promo code"})}),e.jsx(it,{children:w.name||"-"}),e.jsx(it,{children:b(w)}),e.jsx(it,{children:j(w)}),e.jsx(it,{children:w.times_redeemed}),e.jsx(it,{children:e.jsx(at,{variant:w.valid?"default":"secondary",children:w.valid?"Active":"Inactive"})}),e.jsx(it,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>_(w.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})})]},w.id)})})]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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 Gme={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 Bzt(){const[t,s]=S.useState(""),[r,n]=S.useState("all"),[a,o]=S.useState(null),{data:l,isLoading:i,refetch:d}=Ct({queryKey:["admin-subscriptions"],queryFn:async()=>{const{data:b,error:j}=await G.from("profiles").select(` *, brokerages:brokerage_id (id, name) `).order("created_at",{ascending:!1});if(j)throw j;return b}}),{data:u}=Ct({queryKey:["admin-brokerages-subscriptions"],queryFn:async()=>{const{data:b,error:j}=await G.from("brokerages").select("*").order("name");if(j)throw j;return await Promise.all((b||[]).map(async N=>{const{data:C}=await G.from("profiles").select("id, name, email, subscription_status, subscription_product_id").eq("brokerage_id",N.id),{data:A}=await G.from("user_roles").select("user_id").eq("role","brokerage_manager"),I=(A==null?void 0:A.map($=>$.user_id))||[],L=(C==null?void 0:C.filter($=>I.includes($.id)))||[],R=(C==null?void 0:C.length)||0;return{...N,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 j=Gme[b.subscription_product_id];return{status:(j==null?void 0:j.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"}},g=l==null?void 0:l.filter(b=>{var w,N;if(!(((w=b.name)==null?void 0:w.toLowerCase().includes(t.toLowerCase()))||((N=b.email)==null?void 0:N.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}}),v={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(Ms,{title:"Subscription Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{title:"Subscription Management",description:"Track and manage all subscriptions",children:e.jsxs(K,{onClick:()=>d(),variant:"outline",size:"sm",children:[e.jsx(Eo,{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:v.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(mp,{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:v.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(In,{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:v.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(zh,{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:v.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(Ca,{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:v.brokerageMembers})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i_,{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:v.individualSubscribers})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ca,{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:v.brokerageSubscribers})]})})]}),e.jsxs(ja,{defaultValue:"users",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsx(Ns,{value:"users",children:"All Users"}),e.jsx(Ns,{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(xn,{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(tr,{value:r,onValueChange:b=>n(b),children:[e.jsx(Js,{className:"w-[200px]",children:e.jsx(sr,{placeholder:"Filter by status"})}),e.jsxs(er,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"User"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Plan"}),e.jsx(jt,{children:"Brokerage"}),e.jsx(jt,{children:"End Date"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:i?e.jsx(js,{children:e.jsx(it,{colSpan:6,className:"text-center py-8",children:"Loading subscriptions..."})}):(g==null?void 0:g.length)===0?e.jsx(js,{children:e.jsx(it,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No users found"})}):g==null?void 0:g.map(b=>{var N,C;const j=p(b),w=Gme[b.subscription_product_id];return e.jsxs(js,{children:[e.jsx(it,{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(it,{children:e.jsx(at,{variant:j.variant,children:j.badge})}),e.jsx(it,{children:e.jsx("span",{className:"text-sm",children:b.is_grandfathered?"Legacy Access":b.brokerage_id&&!b.subscription_product_id?"Brokerage Subscription":(w==null?void 0:w.name)||j.status})}),e.jsx(it,{children:(N=b.brokerages)!=null&&N.name?e.jsx("span",{className:"text-sm",children:b.brokerages.name}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(it,{children:b.subscription_end_date?e.jsx("span",{className:"text-sm",children:ws(new Date(b.subscription_end_date),"MMM d, yyyy")}):b.trial_expires_at?e.jsxs("span",{className:"text-sm text-blue-600",children:["Trial: ",ws(new Date(b.trial_expires_at),"MMM d, yyyy")]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(it,{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(rn,{className:"h-4 w-4"})}),e.jsxs(vs,{children:[e.jsx(Ai,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",onClick:()=>o(b),children:"Details"})}),e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(at,{variant:j.variant,className:"mt-1",children:j.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":(w==null?void 0:w.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:((C=b.brokerages)==null?void 0:C.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:ws(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:ws(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(rn,{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 w,N;const j=(w=b.managers)==null?void 0:w.some(C=>C.subscription_status==="active"&&(C.subscription_product_id==="prod_Tc08MupgoVySDG"||C.subscription_product_id==="prod_Tc09N1tJ4RrAFn"));return e.jsxs(Ee,{children:[e.jsx(Lt,{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(Ca,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:b.name}),e.jsxs(yr,{children:[b.agentCount," agents"]})]})]}),e.jsx(at,{variant:j?"default":"outline",children:j?"Active Subscription":"No Active Subscription"})]})}),e.jsx(Oe,{children:((N=b.managers)==null?void 0:N.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(C=>{const A=Gme[C.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:C.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:C.email})]}),e.jsx("div",{className:"text-right",children:A?e.jsxs("div",{children:[e.jsx(at,{variant:"default",children:A.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:A.price})]}):e.jsx(at,{variant:"outline",children:"No Subscription"})})]},C.id)})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No managers assigned"})})]},b.id)})})})]})]})})}function $zt(){const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(""),[l,i]=S.useState("all"),[d,u]=S.useState({total:0,qualified:0,pending:0,cancelled:0,totalDiscounts:0});S.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:b,error:j}=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(j)throw j;s(b||[]);const w=(b==null?void 0:b.filter(A=>A.status==="qualified").length)||0,N=(b==null?void 0:b.filter(A=>A.status==="pending").length)||0,C=(b==null?void 0:b.filter(A=>A.status==="cancelled").length)||0;u({total:(b==null?void 0:b.length)||0,qualified:w,pending:N,cancelled:C,totalDiscounts:w*25})}catch(b){console.error("Error fetching referrals:",b),fe.error("Failed to load referrals")}finally{n(!1)}},g=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")}},v=t.filter(b=>{var N,C,A,I,L,R;const j=((C=(N=b.referrer_brokerage)==null?void 0:N.name)==null?void 0:C.toLowerCase().includes(a.toLowerCase()))||((I=(A=b.referred_brokerage)==null?void 0:A.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())),w=l==="all"||b.status===l;return j&&w}),_=b=>{switch(b){case"qualified":return e.jsxs(at,{className:"bg-green-100 text-green-800",children:[e.jsx(fi,{className:"h-3 w-3 mr-1"}),"Qualified"]});case"pending":return e.jsxs(at,{variant:"secondary",children:[e.jsx(In,{className:"h-3 w-3 mr-1"}),"Pending"]});case"cancelled":return e.jsxs(at,{variant:"destructive",children:[e.jsx(wc,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return e.jsx(at,{children:b})}};return e.jsx(Ms,{title:"Referral Program",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{title:"Referral Program",description:"Track and manage brokerage referrals",children:e.jsxs(K,{onClick:g,variant:"outline",children:[e.jsx(Eo,{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(fi,{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(In,{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(wc,{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(Gc,{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(Lt,{children:[e.jsx(zt,{children:"All Referrals"}),e.jsx(yr,{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(xn,{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(tr,{value:l,onValueChange:i,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{placeholder:"Filter by status"})}),e.jsxs(er,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Referrer"}),e.jsx(jt,{children:"Referred"}),e.jsx(jt,{children:"Signup Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Qualified Date"}),e.jsx(jt,{children:"Discount"})]})}),e.jsx(En,{children:v.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No referrals found"})}):v.map(b=>{var j,w,N,C;return e.jsxs(js,{children:[e.jsx(it,{className:"font-medium",children:((j=b.referrer_brokerage)==null?void 0:j.name)||"Unknown"}),e.jsx(it,{children:e.jsxs("div",{children:[e.jsx("p",{children:((w=b.referred_brokerage)==null?void 0:w.name)||((N=b.referred_user)==null?void 0:N.name)||"Pending setup"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(C=b.referred_user)==null?void 0:C.email})]})}),e.jsx(it,{children:ws(new Date(b.signup_date),"MMM d, yyyy")}),e.jsx(it,{children:_(b.status)}),e.jsx(it,{children:b.qualified_date?ws(new Date(b.qualified_date),"MMM d, yyyy"):"-"}),e.jsx(it,{children:b.discount_applied?e.jsx(at,{variant:"outline",className:"text-green-600",children:"$25/mo applied"}):e.jsx("span",{className:"text-muted-foreground",children:"-"})})]},b.id)})})]})]})]})]})})}const Kme=[{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"}],qzt=[{value:"brokerage_manager",label:"Brokerage Manager"},{value:"agent",label:"Agent"}];function Uzt(){const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(!1),[l,i]=S.useState(null),[d,u]=S.useState({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0});S.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:C,error:A}=await G.from("onboarding_checklist_items").select("*").order("target_role").order("sort_order");if(A)throw A;s(C||[])}catch(C){console.error("Error fetching checklist items:",C),fe.error("Failed to load checklist items")}finally{n(!1)}},g=()=>{i(null),u({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0}),o(!0)},v=C=>{i(C),u({title:C.title,description:C.description||"",action_type:C.action_type,target_role:C.target_role,is_active:C.is_active}),o(!0)},_=async()=>{if(!d.title.trim()){fe.error("Title is required");return}try{if(l){const{error:C}=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(C)throw C;fe.success("Checklist item updated")}else{const C=t.filter(I=>I.target_role===d.target_role).reduce((I,L)=>Math.max(I,L.sort_order),-1),{error:A}=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:C+1});if(A)throw A;fe.success("Checklist item created")}o(!1),p()}catch(C){console.error("Error saving checklist item:",C),fe.error("Failed to save checklist item")}},b=async C=>{if(confirm("Are you sure you want to delete this checklist item?"))try{const{error:A}=await G.from("onboarding_checklist_items").delete().eq("id",C);if(A)throw A;fe.success("Checklist item deleted"),p()}catch(A){console.error("Error deleting checklist item:",A),fe.error("Failed to delete checklist item")}},j=async C=>{try{const{error:A}=await G.from("onboarding_checklist_items").update({is_active:!C.is_active}).eq("id",C.id);if(A)throw A;fe.success(C.is_active?"Item deactivated":"Item activated"),p()}catch(A){console.error("Error toggling item:",A),fe.error("Failed to update item")}},w=t.filter(C=>C.target_role==="brokerage_manager"),N=t.filter(C=>C.target_role==="agent");return e.jsxs(Ms,{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:g,className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Item"]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(at,{variant:"secondary",children:"Brokerage Manager"}),"Checklist Items"]})}),e.jsx(Oe,{children:w.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for brokerage managers"}):e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-12",children:"#"}),e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Action Type"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:w.map((C,A)=>{var I;return e.jsxs(js,{children:[e.jsx(it,{className:"text-muted-foreground",children:A+1}),e.jsx(it,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:C.title}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:C.description})]})}),e.jsx(it,{children:e.jsx(at,{variant:"outline",children:((I=Kme.find(L=>L.value===C.action_type))==null?void 0:I.label)||C.action_type})}),e.jsx(it,{children:e.jsx(Br,{checked:C.is_active,onCheckedChange:()=>j(C)})}),e.jsx(it,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>v(C),children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(C.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},C.id)})})]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(at,{variant:"secondary",children:"Agent"}),"Checklist Items"]})}),e.jsx(Oe,{children:N.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for agents"}):e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-12",children:"#"}),e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Action Type"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:N.map((C,A)=>{var I;return e.jsxs(js,{children:[e.jsx(it,{className:"text-muted-foreground",children:A+1}),e.jsx(it,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:C.title}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:C.description})]})}),e.jsx(it,{children:e.jsx(at,{variant:"outline",children:((I=Kme.find(L=>L.value===C.action_type))==null?void 0:I.label)||C.action_type})}),e.jsx(it,{children:e.jsx(Br,{checked:C.is_active,onCheckedChange:()=>j(C)})}),e.jsx(it,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>v(C),children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(C.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},C.id)})})]})})]})]}),e.jsx(vs,{open:a,onOpenChange:o,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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:C=>u({...d,title:C.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(Tr,{id:"description",value:d.description,onChange:C=>u({...d,description:C.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(tr,{value:d.target_role,onValueChange:C=>u({...d,target_role:C}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:qzt.map(C=>e.jsx(At,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Action Type"}),e.jsxs(tr,{value:d.action_type,onValueChange:C=>u({...d,action_type:C}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:Kme.map(C=>e.jsx(At,{value:C.value,children:C.label},C.value))})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"is_active",checked:d.is_active,onCheckedChange:C=>u({...d,is_active:C})}),e.jsx(ve,{htmlFor:"is_active",children:"Active"})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{onClick:_,children:l?"Save Changes":"Create Item"})]})]})})]})}function Vzt(){const[t,s]=S.useState(""),[r,n]=S.useState("all"),[a,o]=S.useState("name"),[l,i]=S.useState("asc"),[d,u]=S.useState(""),[p,g]=S.useState(""),[v,_]=S.useState(""),[b,j]=S.useState(""),{data:w}=Ct({queryKey:["admin-brokerages"],queryFn:async()=>{const{data:V,error:X}=await G.from("brokerages").select("id, name").order("name");if(X)throw X;return V}}),N=async V=>{let se=[],te=0,Y=!0;for(;Y;){const{data:de,error:ie}=await V(te,te+1e3-1);if(ie)throw ie;de&&de.length>0?(se=[...se,...de],te+=1e3,Y=de.length===1e3):Y=!1}return se},{data:C,isLoading:A}=Ct({queryKey:["admin-agent-os-user-stats"],queryFn:async()=>{const V=await N((Fe,Ae)=>G.from("profiles").select("id, name, email, brokerage_id, created_at").range(Fe,Ae)),{data:X}=await G.from("brokerages").select("id, name"),se=new Map((X==null?void 0:X.map(Fe=>[Fe.id,Fe.name]))||[]),[{data:te},{data:Y},{data:de},{data:ie},{data:ae},{data:le},{data:pe}]=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 ye=new Map;Y==null||Y.forEach(Fe=>ye.set(Fe.owner_user_id,Fe.video_count));const we=new Map;de==null||de.forEach(Fe=>we.set(Fe.owner_user_id,Fe.popby_count));const Ne=new Map;ie==null||ie.forEach(Fe=>Ne.set(Fe.agent_id,Fe.listing_count));const Ke=new Map;ae==null||ae.forEach(Fe=>Ke.set(Fe.owner_user_id,Fe.deal_count));const _e=new Map;le==null||le.forEach(Fe=>_e.set(Fe.owner_user_id,{total:Fe.portal_count,active:Fe.active_portal_count}));const Me=new Map;return pe==null||pe.forEach(Fe=>Me.set(Fe.owner_user_id,{total:Fe.card_count,sent:Fe.sent_card_count,views:Fe.total_card_views})),V.map(Fe=>{const Ae=_e.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:ye.get(Fe.id)||0,popby_count:we.get(Fe.id)||0,listing_count:Ne.get(Fe.id)||0,deal_count:Ke.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=S.useMemo(()=>{if(!C)return[];let V=C.filter(X=>{const se=t.toLowerCase(),te=!t||X.name.toLowerCase().includes(se)||X.email.toLowerCase().includes(se),Y=r==="all"||r==="none"&&!X.brokerage_id||X.brokerage_id===r,de=parseInt(d)||0,ie=parseInt(p)||0,ae=parseInt(v)||0,le=parseInt(b)||0,pe=X.contact_count>=de&&X.video_count>=ie&&X.popby_count>=ae&&X.listing_count>=le;return te&&Y&&pe});return V.sort((X,se)=>{let te=0;return a==="name"?te=X.name.localeCompare(se.name):te=X[a]-se[a],l==="asc"?te:-te}),V},[C,t,r,a,l,d,p,v,b]),L=V=>{a===V?i(l==="asc"?"desc":"asc"):(o(V),i("desc"))},R=()=>{const V=["Name","Email","Brokerage","Contacts","Videos","Popbys","Listings","Deals","Portals (Active)","Cards Created","Cards Sent","Card Views"],X=I.map(ie=>[ie.name,ie.email,ie.brokerage_name||"None",ie.contact_count,ie.video_count,ie.popby_count,ie.listing_count,ie.deal_count,`${ie.portal_count} (${ie.active_portal_count})`,ie.card_count,ie.sent_card_count,ie.total_card_views]),se=[V.join(","),...X.map(ie=>ie.map(ae=>`"${ae}"`).join(","))].join(` `),te=new Blob([se],{type:"text/csv"}),Y=URL.createObjectURL(te),de=document.createElement("a");de.href=Y,de.download=`agent-os-user-stats-${new Date().toISOString().split("T")[0]}.csv`,de.click(),URL.revokeObjectURL(Y)},$=S.useMemo(()=>I.length?I.reduce((V,X)=>({contacts:V.contacts+X.contact_count,videos:V.videos+X.video_count,popbys:V.popbys+X.popby_count,listings:V.listings+X.listing_count,deals:V.deals+X.deal_count,portals:V.portals+X.portal_count,activePortals:V.activePortals+X.active_portal_count,cards:V.cards+X.card_count,sentCards:V.sentCards+X.sent_card_count,cardViews:V.cardViews+X.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=S.useMemo(()=>I.length?{portals:I.filter(V=>V.portal_count>0).length,cards:I.filter(V=>V.card_count>0).length}:{portals:0,cards:0},[I]),U=({field:V,children:X})=>e.jsx(jt,{className:"cursor-pointer hover:bg-muted/50 select-none",onClick:()=>L(V),children:e.jsxs("div",{className:"flex items-center gap-1",children:[X,e.jsx(Vc,{className:`h-3 w-3 ${a===V?"text-primary":"text-muted-foreground"}`})]})});return e.jsx(YN,{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(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(k0,{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(Lt,{className:"pb-2",children:e.jsxs(zt,{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(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"User Activity Analytics"]}),e.jsx(yr,{children:"View all users and their Agent OS usage metrics"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:R,children:[e.jsx(gi,{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(xn,{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:V=>s(V.target.value),className:"pl-9"})]})}),e.jsx("div",{children:e.jsxs(tr,{value:r,onValueChange:n,children:[e.jsxs(Js,{children:[e.jsx(Ca,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(sr,{placeholder:"Brokerage"})]}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Brokerages"}),e.jsx(At,{value:"none",children:"No Brokerage"}),w==null?void 0:w.map(V=>e.jsx(At,{value:V.id,children:V.name},V.id))]})]})}),e.jsx("div",{children:e.jsx(Re,{type:"number",placeholder:"Min contacts",value:d,onChange:V=>u(V.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(Re,{type:"number",placeholder:"Min videos",value:p,onChange:V=>g(V.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(Re,{type:"number",placeholder:"Min popbys",value:v,onChange:V=>_(V.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"})]})]}),A?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(As,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(U,{field:"name",children:"Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{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(k0,{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(En,{children:I.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No users found matching your filters"})}):I.map(V=>e.jsxs(js,{children:[e.jsx(it,{className:"font-medium",children:V.name}),e.jsx(it,{className:"text-muted-foreground",children:V.email}),e.jsx(it,{children:V.brokerage_name?e.jsx(at,{variant:"secondary",children:V.brokerage_name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(it,{children:e.jsx(at,{variant:V.contact_count>0?"default":"outline",children:V.contact_count})}),e.jsx(it,{children:e.jsx(at,{variant:V.video_count>0?"default":"outline",children:V.video_count})}),e.jsx(it,{children:e.jsx(at,{variant:V.popby_count>0?"default":"outline",children:V.popby_count})}),e.jsx(it,{children:e.jsx(at,{variant:V.listing_count>0?"default":"outline",children:V.listing_count})}),e.jsx(it,{children:e.jsx(at,{variant:V.deal_count>0?"default":"outline",children:V.deal_count})}),e.jsx(it,{children:V.portal_count>0?e.jsxs(nd,{children:[e.jsx(ad,{children:e.jsxs(at,{variant:"default",className:"bg-blue-600 hover:bg-blue-700",children:[V.portal_count,V.active_portal_count>0&&e.jsxs("span",{className:"ml-1 opacity-75",children:["(",V.active_portal_count," active)"]})]})}),e.jsxs(Hc,{children:[e.jsxs("p",{children:[V.portal_count," total portals"]}),e.jsxs("p",{children:[V.active_portal_count," currently active"]})]})]}):e.jsx(at,{variant:"outline",children:"0"})}),e.jsx(it,{children:V.card_count>0?e.jsxs(nd,{children:[e.jsx(ad,{children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(at,{variant:"default",className:"bg-violet-600 hover:bg-violet-700",children:V.card_count}),V.sent_card_count>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-emerald-600",children:[e.jsx(Ta,{className:"h-3 w-3"}),V.sent_card_count]}),V.total_card_views>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[e.jsx(ya,{className:"h-3 w-3"}),V.total_card_views]})]})}),e.jsxs(Hc,{children:[e.jsxs("p",{children:[V.card_count," cards created"]}),e.jsxs("p",{children:[V.sent_card_count," sent"]}),e.jsxs("p",{children:[V.total_card_views," total views"]})]})]}):e.jsx(at,{variant:"outline",children:"0"})})]},V.id))})]})})]})]})]})})}function Hzt(){Ea(),ns();const[t,s]=S.useState("user-analytics"),{data:r}=Ct({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}=Ct({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}=Ct({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}=Ct({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}=Ct({queryKey:["admin-touchpoint-plans"],queryFn:async()=>{const{data:_,error:b}=await G.from("touchpoint_plans").select("*").order("name");if(b)throw b;return _}}),{data:g,isLoading:v}=Ct({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(Ms,{title:"Agent OS Control Center",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{title:"Agent OS Control Center",description:"Manage InnerCircle settings, scripts, and touchpoint plans"}),e.jsxs(ja,{value:t,onValueChange:s,children:[e.jsxs(va,{className:"grid w-full grid-cols-9",children:[e.jsxs(Ns,{value:"user-analytics",className:"gap-2",children:[e.jsx(Xo,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Users"})]}),e.jsxs(Ns,{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(Ns,{value:"action-types",className:"gap-2",children:[e.jsx(Zn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Actions"})]}),e.jsxs(Ns,{value:"scripts",className:"gap-2",children:[e.jsx(Sn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Scripts"})]}),e.jsxs(Ns,{value:"video-scripts",className:"gap-2",children:[e.jsx(au,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Video Scripts"})]}),e.jsxs(Ns,{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(Ns,{value:"popbys",className:"gap-2",children:[e.jsx(ao,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Popbys"})]}),e.jsxs(Ns,{value:"settings",className:"gap-2",children:[e.jsx(Fl,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Settings"})]}),e.jsxs(Ns,{value:"feature-flags",className:"gap-2",children:[e.jsx(S0,{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(Vzt,{})}),e.jsx(zs,{value:"relationship-types",className:"mt-6",children:e.jsx(Wzt,{types:n||[],isLoading:a})}),e.jsx(zs,{value:"action-types",className:"mt-6",children:e.jsx(Gzt,{types:o||[],isLoading:l})}),e.jsx(zs,{value:"scripts",className:"mt-6",children:e.jsx(Kzt,{scripts:i||[],actionTypes:o||[],isLoading:d})}),e.jsx(zs,{value:"video-scripts",className:"mt-6",children:e.jsx(Qzt,{})}),e.jsx(zs,{value:"plans",className:"mt-6",children:e.jsx(Zzt,{plans:u||[],actionTypes:o||[],scripts:i||[],isLoading:p})}),e.jsx(zs,{value:"popbys",className:"mt-6",children:e.jsx(Xzt,{items:g||[],isLoading:v})}),e.jsx(zs,{value:"settings",className:"mt-6",children:e.jsx(Jzt,{})}),e.jsx(zs,{value:"feature-flags",className:"mt-6",children:e.jsx(Yzt,{flags:r||[]})})]})]})})}function Wzt({types:t,isLoading:s}){const{toast:r}=Ea(),n=ns(),[a,o]=S.useState(null),[l,i]=S.useState(!1),d=Ot({mutationFn:async p=>{if(p.id){const{error:g}=await G.from("relationship_types").update({name:p.name,description:p.description,icon:p.icon}).eq("id",p.id);if(g)throw g}else{const{error:g}=await G.from("relationship_types").insert([{name:p.name,description:p.description,icon:p.icon,sort_order:t.length}]);if(g)throw g}},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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Relationship Types"}),e.jsx(yr,{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(As,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-12"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(En,{children:t.map(p=>e.jsxs(js,{children:[e.jsx(it,{children:e.jsx(Ru,{className:"h-4 w-4 text-muted-foreground cursor-grab"})}),e.jsx(it,{className:"font-medium",children:p.name}),e.jsx(it,{className:"text-muted-foreground",children:p.description}),e.jsx(it,{children:e.jsx(Br,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(it,{children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:e.jsx(Ua,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(vs,{open:l,onOpenChange:i,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:[a?"Edit":"Add"," Relationship Type"]})}),e.jsxs("form",{onSubmit:p=>{p.preventDefault();const g=new FormData(p.currentTarget);d.mutate({id:a==null?void 0:a.id,name:g.get("name"),description:g.get("description"),icon:g.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(Tr,{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(On,{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(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Gzt({types:t,isLoading:s}){const{toast:r}=Ea(),n=ns(),[a,o]=S.useState(null),[l,i]=S.useState(!1),d=Ot({mutationFn:async p=>{if(p.id){const{error:g}=await G.from("action_types").update({name:p.name,description:p.description,icon:p.icon,color:p.color}).eq("id",p.id);if(g)throw g}else{const{error:g}=await G.from("action_types").insert([{name:p.name,description:p.description,icon:p.icon,color:p.color,sort_order:t.length}]);if(g)throw g}},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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Action Types"}),e.jsx(yr,{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(As,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{children:"Color"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(En,{children:t.map(p=>e.jsxs(js,{children:[e.jsx(it,{className:"font-medium",children:p.name}),e.jsx(it,{className:"text-muted-foreground",children:p.description}),e.jsx(it,{children:p.color&&e.jsx("div",{className:"w-6 h-6 rounded",style:{backgroundColor:p.color}})}),e.jsx(it,{children:e.jsx(Br,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(it,{children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:e.jsx(Ua,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(vs,{open:l,onOpenChange:i,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:[a?"Edit":"Add"," Action Type"]})}),e.jsxs("form",{onSubmit:p=>{p.preventDefault();const g=new FormData(p.currentTarget);d.mutate({id:a==null?void 0:a.id,name:g.get("name"),description:g.get("description"),icon:g.get("icon"),color:g.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(Tr,{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(On,{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(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Kzt({scripts:t,actionTypes:s,isLoading:r}){const{toast:n}=Ea(),a=ns(),[o,l]=S.useState(null),[i,d]=S.useState(!1),u=Ot({mutationFn:async g=>{if(g.id){const{error:v}=await G.from("action_scripts").update({title:g.title,action_type_id:g.action_type_id,tone:g.tone,script_body:g.script_body,active:g.active}).eq("id",g.id);if(v)throw v}else{const{error:v}=await G.from("action_scripts").insert([{title:g.title,action_type_id:g.action_type_id,tone:g.tone,script_body:g.script_body,active:!0}]);if(v)throw v}},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),d(!1),l(null),n({title:"Saved successfully"})},onError:g=>{n({title:"Error",description:g.message,variant:"destructive"})}}),p=Ot({mutationFn:async g=>{const{error:v}=await G.from("action_scripts").delete().eq("id",g);if(v)throw v},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),n({title:"Deleted successfully"})}});return e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Script Library"}),e.jsx(yr,{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(As,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Action Type"}),e.jsx(jt,{children:"Tone"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(En,{children:t.map(g=>{var v;return e.jsxs(js,{children:[e.jsx(it,{className:"font-medium",children:g.title}),e.jsx(it,{children:e.jsx(at,{variant:"outline",children:((v=g.action_type)==null?void 0:v.name)||"Unknown"})}),e.jsx(it,{className:"text-muted-foreground",children:g.tone}),e.jsx(it,{children:e.jsx(at,{variant:g.active?"default":"secondary",children:g.active?"Active":"Inactive"})}),e.jsxs(it,{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{l(g),d(!0)},children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutate(g.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})]},g.id)})})]})}),e.jsx(vs,{open:i,onOpenChange:d,children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:[o?"Edit":"Add"," Script"]})}),e.jsxs("form",{onSubmit:g=>{g.preventDefault();const v=new FormData(g.currentTarget);u.mutate({id:o==null?void 0:o.id,title:v.get("title"),action_type_id:v.get("action_type_id"),tone:v.get("tone"),script_body:v.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(tr,{name:"action_type_id",defaultValue:o==null?void 0:o.action_type_id,children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select action type"})}),e.jsx(er,{children:s.map(g=>e.jsx(At,{value:g.id,children:g.name},g.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(Tr,{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(On,{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(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Zzt({plans:t,actionTypes:s,scripts:r,isLoading:n}){const{toast:a}=Ea(),o=ns(),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,g]=S.useState(null),[v,_]=S.useState(!1),[b,j]=S.useState(null),[w,N]=S.useState(null),{data:C}=Ct({queryKey:["plan-items",p],queryFn:async()=>{if(!p)return[];const{data:U,error:V}=await G.from("touchpoint_plan_items").select("*").eq("plan_id",p).order("month_number");if(V)throw V;return U},enabled:!!p}),A=Ot({mutationFn:async U=>{if(U.id){const{error:V}=await G.from("touchpoint_plans").update({name:U.name,description:U.description,active:U.active}).eq("id",U.id);if(V)throw V}else{const{error:V}=await G.from("touchpoint_plans").insert([{name:U.name,description:U.description,active:!0}]);if(V)throw V}},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=Ot({mutationFn:async U=>{if(U.id){const{error:V}=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(V)throw V}else{const{error:V}=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(V)throw V}},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]}),a({title:"Item saved"})}}),L=Ot({mutationFn:async U=>{const{error:V}=await G.from("touchpoint_plan_items").delete().eq("id",U);if(V)throw V},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]})}}),R=Ot({mutationFn:async U=>{const{data:V,error:X}=await G.from("action_scripts").insert([{...U,active:!0}]).select().single();if(X)throw X;return V},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),j(null),a({title:"Script created and assigned"})},onError:U=>{a({title:"Error",description:U.message,variant:"destructive"})}}),$=(U,V,X)=>{j({month:U,actionTypeId:V,itemId:X}),_(!0)},q=U=>r.find(V=>V.id===U);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Touchpoint Plans"}),e.jsx(yr,{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(As,{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:()=>g(U.id),children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{className:"text-base",children:U.name}),e.jsx(K,{variant:"ghost",size:"icon",onClick:V=>{V.stopPropagation(),i(U),u(!0)},children:e.jsx(Ua,{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(at,{variant:U.active?"default":"secondary",className:"mt-2",children:U.active?"Active":"Inactive"})]})]},U.id))})})]}),p&&e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Plan Schedule"}),e.jsx(yr,{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,V)=>V+1).map(U=>{const V=C==null?void 0:C.find(te=>te.month_number===U),X=V!=null&&V.default_script_id?q(V.default_script_id):null,se=r.filter(te=>te.action_type_id===(V==null?void 0:V.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(tr,{value:(V==null?void 0:V.action_type_id)||"none",onValueChange:te=>{te==="none"&&V?L.mutate(V.id):te!=="none"&&I.mutate({id:V==null?void 0:V.id,plan_id:p,month_number:U,action_type_id:te,default_script_id:null})},children:[e.jsx(Js,{className:"w-40",children:e.jsx(sr,{placeholder:"No action"})}),e.jsxs(er,{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))]})]}),V&&e.jsxs(e.Fragment,{children:[e.jsxs(tr,{value:V.default_script_id||"none",onValueChange:te=>{N(null),I.mutate({id:V.id,default_script_id:te==="none"?null:te})},children:[e.jsx(Js,{className:"w-56",children:e.jsx(sr,{placeholder:"Select script"})}),e.jsxs(er,{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,V.action_type_id,V.id),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"}),"New Script"]}),X&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N((w==null?void 0:w.id)===X.id?null:X),children:(w==null?void 0:w.id)===X.id?"Hide":"Preview"})]})]}),w&&(V==null?void 0:V.default_script_id)===w.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(at,{variant:"outline",children:w.title}),w.tone&&e.jsx(at,{variant:"secondary",children:w.tone})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:w.script_body})]})]},U)})})})]}),e.jsx(vs,{open:d,onOpenChange:u,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:[l?"Edit":"Add"," Touchpoint Plan"]})}),e.jsxs("form",{onSubmit:U=>{U.preventDefault();const V=new FormData(U.currentTarget);A.mutate({id:l==null?void 0:l.id,name:V.get("name"),description:V.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(Tr,{id:"description",name:"description",defaultValue:(l==null?void 0:l.description)||"",rows:3})]})]}),e.jsxs(On,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:A.isPending,children:[A.isPending&&e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})}),e.jsx(vs,{open:v,onOpenChange:_,children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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 V=new FormData(U.currentTarget);R.mutate({title:V.get("title"),action_type_id:b.actionTypeId,tone:V.get("tone"),script_body:V.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(Tr,{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(On,{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(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Create & Assign"]})]})]})]})})]})}function Yzt({flags:t}){const{toast:s}=Ea(),r=ns(),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(Lt,{children:[e.jsx(zt,{children:"Feature Flags"}),e.jsx(yr,{children:"Control which features are enabled for members"})]}),e.jsx(Oe,{children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Flag"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Notes"}),e.jsx(jt,{children:"Last Updated"})]})}),e.jsx(En,{children:t.map(a=>e.jsxs(js,{children:[e.jsx(it,{className:"font-mono text-sm",children:a.key}),e.jsx(it,{children:e.jsx(Br,{checked:a.enabled,onCheckedChange:o=>n(a,{enabled:o})})}),e.jsx(it,{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(it,{className:"text-muted-foreground text-sm",children:new Date(a.updated_at).toLocaleDateString()})]},a.id))})]})})]})}function Xzt({items:t,isLoading:s}){const{toast:r}=Ea(),n=ns(),[a,o]=S.useState(null),[l,i]=S.useState(!1),d=Ot({mutationFn:async g=>{if(g.id){const{error:v}=await G.from("popby_items").update({name:g.name,description:g.description}).eq("id",g.id);if(v)throw v}else{const{error:v}=await G.from("popby_items").insert([{name:g.name,description:g.description,owner_user_id:null}]);if(v)throw v}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:g=>{r({title:"Error",description:g.message,variant:"destructive"})}}),u=async g=>{await G.from("popby_items").update({is_active:!g.is_active}).eq("id",g.id),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]})},p=async g=>{await G.from("popby_items").delete().eq("id",g),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),r({title:"Deleted successfully"})};return e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Popby Ideas"}),e.jsx(yr,{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(As,{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(ao,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(En,{children:t.map(g=>e.jsxs(js,{children:[e.jsx(it,{className:"font-medium",children:g.name}),e.jsx(it,{className:"text-muted-foreground",children:g.description}),e.jsx(it,{children:e.jsx(Br,{checked:g.is_active,onCheckedChange:()=>u(g)})}),e.jsx(it,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(g),i(!0)},children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p(g.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},g.id))})]})}),e.jsx(vs,{open:l,onOpenChange:i,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:[a?"Edit":"Add"," Popby Idea"]})}),e.jsxs("form",{onSubmit:g=>{g.preventDefault();const v=new FormData(g.currentTarget);d.mutate({id:a==null?void 0:a.id,name:v.get("name"),description:v.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(Tr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||"",placeholder:"Brief description of the popby idea..."})]})]}),e.jsxs(On,{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(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Qzt(){var _;const{toast:t}=Ea(),s=ns(),[r,n]=S.useState(null),[a,o]=S.useState(!1),{data:l,isLoading:i}=Ct({queryKey:["admin-video-script-categories"],queryFn:async()=>{const{data:b,error:j}=await G.from("video_script_categories").select("*").order("sort_order");if(j)throw j;return b}}),{data:d,isLoading:u}=Ct({queryKey:["admin-video-scripts"],queryFn:async()=>{const{data:b,error:j}=await G.from("video_scripts").select("*, category:video_script_categories(*)").order("title");if(j)throw j;return b}}),p=Ot({mutationFn:async b=>{var j,w;if(b.id){const{error:N}=await G.from("video_scripts").update({title:b.title,script_text:b.script_text,category_id:b.category_id,tags:((j=b.tags)==null?void 0:j.split(",").map(C=>C.trim()).filter(Boolean))||[]}).eq("id",b.id);if(N)throw N}else{const{error:N}=await G.from("video_scripts").insert([{title:b.title,script_text:b.script_text,category_id:b.category_id||null,tags:((w=b.tags)==null?void 0:w.split(",").map(C=>C.trim()).filter(Boolean))||[]}]);if(N)throw N}},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"})}),g=async b=>{await G.from("video_scripts").update({is_active:!b.is_active}).eq("id",b.id),s.invalidateQueries({queryKey:["admin-video-scripts"]})},v=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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Video Scripts"}),e.jsx(yr,{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(As,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Category"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(En,{children:d==null?void 0:d.map(b=>{var j;return e.jsxs(js,{children:[e.jsx(it,{className:"font-medium",children:b.title}),e.jsx(it,{className:"text-muted-foreground",children:((j=b.category)==null?void 0:j.name)||"Uncategorized"}),e.jsx(it,{children:e.jsx(Br,{checked:b.is_active,onCheckedChange:()=>g(b)})}),e.jsxs(it,{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{n(b),o(!0)},children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>v(b.id),children:e.jsx(jr,{className:"h-4 w-4"})})]})]},b.id)})})]})}),e.jsx(vs,{open:a,onOpenChange:o,children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:[r?"Edit":"Add"," Video Script"]})}),e.jsxs("form",{onSubmit:b=>{b.preventDefault();const j=new FormData(b.currentTarget);p.mutate({id:r==null?void 0:r.id,title:j.get("title"),script_text:j.get("script_text"),category_id:j.get("category_id")||null,tags:j.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(tr,{name:"category_id",defaultValue:(r==null?void 0:r.category_id)||"",children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select category"})}),e.jsx(er,{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(Tr,{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(On,{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(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Jzt(){const{toast:t}=Ea(),[s,r]=S.useState(""),[n,a]=S.useState(!0),[o,l]=S.useState(!1);S.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(As,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):e.jsx("div",{className:"space-y-6",children:e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Ti,{className:"h-5 w-5"}),"Popby Map Settings"]}),e.jsx(yr,{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(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Token"]}),s&&e.jsx(at,{variant:"secondary",className:"ml-2",children:"Token configured"})]})]})})}const e7t=()=>{const[t,s]=S.useState(""),[r,n]=S.useState("grid"),a=Lr(),{data:o=[],isLoading:l}=Ct({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(Ms,{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(xn,{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(pp,{className:"h-4 w-4"})}),e.jsx(K,{variant:r==="list"?"secondary":"outline",size:"icon",onClick:()=>n("list"),className:"rounded-full",children:e.jsx(qh,{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(gs,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(gs,{className:"h-5 w-3/4 mb-2"}),e.jsx(gs,{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(mn,{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:Xie(d.description)})]})]},d.id))})]})})},t7t=()=>{const{serviceId:t}=Co(),s=Lr(),{data:r,isLoading:n}=Ct({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(Ms,{title:"Loading...",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsx(gs,{className:"h-8 w-48"}),e.jsx(gs,{className:"h-64 w-full rounded-lg"}),e.jsx(gs,{className:"h-24 w-full"})]})}):r?e.jsx(Ms,{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(Ka,{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(mn,{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 ",ws(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(rn,{className:"h-5 w-5"}),"Sign Up Now"]})})]})})]})}):e.jsx(Ms,{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(Ka,{className:"h-4 w-4 mr-2"}),"Back to Services"]})]})})},nE=[{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 s7t(){const[t,s]=S.useState(nE[0].id),r=nE.find(n=>n.id===t)||nE[0];return e.jsx(Ms,{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(a5,{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(tr,{value:t,onValueChange:s,children:[e.jsx(Js,{className:"w-full",children:e.jsx(sr,{placeholder:"Select a tool"})}),e.jsx(er,{children:nE.map(n=>e.jsx(At,{value:n.id,children:n.name},n.id))})]})}),e.jsx("div",{className:"hidden md:block",children:e.jsx(ja,{value:t,onValueChange:s,className:"w-full",children:e.jsx(va,{className:"w-full flex-wrap h-auto gap-1 bg-muted p-1",children:nE.map(n=>e.jsx(Ns,{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 uEe="agent-os-onboarding-completed",lR=[{icon:Hx,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:Lm,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:kc,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:ao,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:Xo,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"]}],r7t=()=>{const[t,s]=S.useState(!1),[r,n]=S.useState(0),[a,o]=S.useState(!1);S.useEffect(()=>{if(!localStorage.getItem(uEe)){const b=setTimeout(()=>s(!0),500);return()=>clearTimeout(b)}},[]);const l=()=>{r{n(r+1),o(!1)},150)):d()},i=()=>{d()},d=()=>{localStorage.setItem(uEe,"true"),s(!1)},u=lR[r],p=u.icon,g=r===lR.length-1,v=_=>{_||d(),s(_)};return e.jsx(vs,{open:t,onOpenChange:v,children:e.jsxs(ys,{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(mn,{className:"h-3 w-3"}),"Beta"]})]}),e.jsxs("div",{className:"p-6 pt-4",children:[e.jsxs(Cs,{className:"text-center sm:text-center pb-2",children:[e.jsx(Ss,{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(fa,{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:lR.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}=Gs();return Ct({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})},a7t=()=>{const t=ns(),{user:s}=Gs();return Ot({mutationFn:async({contactId:r,days:n})=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const a=hl(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"]}),an({title:"Touch snoozed!",description:"Contact has been snoozed."})},onError:r=>{an({title:"Error snoozing contact",description:r.message,variant:"destructive"})}})},i7t=()=>{const t=ns();return Ot({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"]}),an({title:"Snooze cancelled"})},onError:s=>{an({title:"Error cancelling snooze",description:s.message,variant:"destructive"})}})},o7t=[{label:"1 week",days:7},{label:"2 weeks",days:14},{label:"1 month",days:30}];function Sle({open:t,onOpenChange:s,contactId:r,contactName:n}){const[a,o]=S.useState(null),l=a7t(),i=async()=>{a&&(await l.mutateAsync({contactId:r,days:a}),o(null),s(!1))},d=u=>ws(hl(new Date,u),"MMM d, yyyy");return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(In,{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:o7t.map(u=>e.jsxs("button",{type:"button",onClick:()=>o(u.days),className:Et("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 l7t={Crown:zh,FileText:Sn,Users:hr,Globe:Am,Star:Gn,Phone:Zn,MessageSquare:io,PenTool:s_,Video:Nn,Gift:ao};function c7t({actions:t,onMarkComplete:s,onViewScript:r,isLoading:n,buildSmsLink:a,buildEmailLink:o,onGmailCompose:l}){const i=Lr(),[d,u]=S.useState("name"),[p,g]=S.useState("asc"),[v,_]=S.useState(null),[b,j]=S.useState(""),w=L=>{d===L?g(R=>R==="asc"?"desc":"asc"):(u(L),g("asc"))},N=S.useMemo(()=>[...t].sort((L,R)=>{var q,U;let $=0;switch(d){case"name":{const V=`${L.contact.first_name} ${L.contact.last_name||""}`.toLowerCase(),X=`${R.contact.first_name} ${R.contact.last_name||""}`.toLowerCase();$=V.localeCompare(X);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]),C=L=>l7t[L||"Phone"]||Zn,A=({field:L,children:R})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>w(L),children:[R,d===L?p==="asc"?e.jsx(qd,{className:"ml-2 h-4 w-4"}):e.jsx(Ju,{className:"ml-2 h-4 w-4"}):e.jsx(Vc,{className:"ml-2 h-4 w-4 opacity-50"})]}),I=(L,R,$)=>{_(L),j(`${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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{className:"bg-muted/50",children:[e.jsx(jt,{className:"w-[180px]",children:e.jsx(A,{field:"name",children:"Contact"})}),e.jsx(jt,{className:"w-[130px]",children:e.jsx(A,{field:"relationship_type",children:"Type"})}),e.jsx(jt,{className:"w-[120px]",children:e.jsx(A,{field:"action_type",children:"Action"})}),e.jsx(jt,{className:"w-[130px]",children:"Phone"}),e.jsx(jt,{className:"w-[200px]",children:"Quick Actions"})]})}),e.jsx(En,{children:N.map((L,R)=>{var se,te,Y,de,ie,ae;const $=L.isSpecialDate,q=L.specialDateType,U=$?q==="birthday"?Ou:Vn:C(((se=L.actionType)==null?void 0:se.icon)||null),V=L.contact.phone,X=L.contact.email;return e.jsxs(js,{className:Et("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(it,{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(it,{children:L.relationshipTypeName?e.jsx(at,{variant:"secondary",className:"text-xs",children:L.relationshipTypeName}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(it,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:$?e.jsx(at,{className:Et("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(Ou,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(Vn,{className:"h-3 w-3"})," Anniversary"]})}):e.jsxs(at,{variant:"outline",className:"gap-1",children:[e.jsx(U,{className:"h-3 w-3"}),(te=L.actionType)==null?void 0:te.name]})})}),e.jsx(it,{children:V?e.jsx("span",{className:"text-sm font-mono",children:L.contact.phone}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(it,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[V&&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(Zn,{className:"h-3.5 w-3.5"})}),V&&e.jsx("a",{href:a(L.contact.phone,(Y=L.script)==null?void 0:Y.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"})}),X&&(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,(ie=L.script)==null?void 0:ie.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:""}`,pe=q==="birthday"?"birthday":"home_anniversary",be=new URLSearchParams({cardType:pe,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:Et("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(fp,{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(la,{className:"h-3.5 w-3.5 mr-1"}),"Done"]})]})})]},`${L.contact.id}-${R}`)})})]})}),e.jsx(Sle,{open:!!v,onOpenChange:L=>!L&&_(null),contactId:v||"",contactName:b})]})}function py(){const{data:t,isLoading:s}=Ct({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 d7t({onSelect:t}){const[s,r]=S.useState(null),{data:n=[],isLoading:a}=Ct({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}=Ct({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(As,{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(Ol,{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(As,{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(Fi,{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(at,{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(qa,{className:"h-4 w-4 text-muted-foreground shrink-0"})]},d.id))})]})}const u7t=5*1024*1024,Ky=50,h7t=["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 m7t(t){return t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function p7t(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 l4(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 TM({open:t,onOpenChange:s,contact:r,bulkContacts:n,defaultSubject:a="",defaultBody:o="",gmailEmail:l,onSendComplete:i}){const{user:d}=Gs(),u=ns(),p=!!n&&n.length>0,g=p?n:r?[r]:[],v=g[0],_=p?Math.ceil(g.length/Ky):1,b=p&&g.length>Ky,[j,w]=S.useState((v==null?void 0:v.email)||""),[N,C]=S.useState(a),[A,I]=S.useState(o),[L,R]=S.useState(!1),[$,q]=S.useState(!1),[U,V]=S.useState([]),[X,se]=S.useState("composing"),[te,Y]=S.useState(0),[de,ie]=S.useState(0),[ae,le]=S.useState(0),[pe,be]=S.useState(0),ye=S.useRef(!1);S.useEffect(()=>{t&&(w((v==null?void 0:v.email)||""),C(l4(a,v||{first_name:""})),I(l4(o,v||{first_name:""})),q(!a&&!o),V([]),se("composing"),Y(0),ie(0),le(0),be(0),ye.current=!1)},[t,v,a,o]);const we=async Ve=>{const nt=Ve.target.files;if(!nt)return;const Qe=U.reduce((ot,qe)=>ot+qe.size,0),ke=[];for(const ot of Array.from(nt)){if(!h7t.includes(ot.type)){fe.error(`${ot.name}: Unsupported file type`);continue}if(Qe+ot.size>u7t){fe.error("Total attachments exceed 5MB limit");break}try{const qe=await p7t(ot);ke.push({name:ot.name,type:ot.type,size:ot.size,data:qe})}catch{fe.error(`Failed to read ${ot.name}`)}}V(ot=>[...ot,...ke]),Ve.target.value=""},Ne=Ve=>{V(nt=>nt.filter((Qe,ke)=>ke!==Ve))},Ke=Ve=>{C(l4(Ve.subject,v||{first_name:""})),I(l4(Ve.body,v||{first_name:""})),q(!1)},_e=Ve=>Ve.split(/\n\n+/).map(nt=>`

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

`).join(""),Me=async Ve=>{const nt=l4(N,Ve),Qe=l4(A,Ve),ke=_e(Qe);try{const{data:ot,error:qe}=await G.functions.invoke("gmail-send",{body:{to:Ve.email,subject:nt,body:ke,contactId:Ve.id,attachments:U.map(({name:lt,type:We,data:Ye})=>({name:lt,type:We,data:Ye}))}});if(qe)throw qe;if(!(ot!=null&&ot.success))throw new Error((ot==null?void 0:ot.error)||"Failed to send");return d&&await G.from("bulk_email_sends").insert({user_id:d.id,contact_id:Ve.id,contact_email:Ve.email,subject:nt,source:"sphere_gaps"}),!0}catch(ot){return console.error("Gmail send error:",ot),fe.error("Failed to send to "+Ve.first_name+": "+(ot instanceof Error?ot.message:"Unknown error")),!1}},Te=()=>{const Ve=te*Ky;return g.slice(Ve,Ve+Ky)},Fe=async()=>{if(!N||!A){fe.error("Please fill in subject and message");return}const Ve=Te();R(!0),se("sending");let nt=0,Qe=0;for(let ot=0;otsetTimeout(lt,150));ie(ot=>ot+nt),le(ot=>ot+Qe),R(!1),u.invalidateQueries({queryKey:["bulk-email-sends"]}),te>=_-1||ye.current?se("all_done"):se("batch_complete")},Ae=async()=>{if(!N||!A){fe.error("Please fill in subject and message");return}if(!p){R(!0);const Ve=await Me(v);R(!1),Ve&&(u.invalidateQueries({queryKey:["bulk-email-sends"]}),fe.success("Email sent successfully!"),s(!1),i==null||i());return}await Fe()},Ue=async()=>{Y(Ve=>Ve+1),be(0),await new Promise(Ve=>setTimeout(Ve,50)),await Fe()};S.useEffect(()=>{},[te]);const ut=()=>{if(L){ye.current=!0;return}s(!1),i==null||i()},De=te*Ky,Dt=Math.min(De+Ky,g.length),he=p&&g.length>0?Math.round((de+ae)/g.length*100):0;return e.jsx(vs,{open:t,onOpenChange:ut,children:e.jsxs(ys,{className:"sm:max-w-[600px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5 text-red-500"}),p?`Send to ${g.length} Contacts`:"Compose Email"]}),l&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sending from ",e.jsx("span",{className:"font-medium",children:l})]}),p&&X==="composing"&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-xs text-primary bg-primary/10 rounded-md px-2.5 py-1.5 mt-1",children:["✉️ Each contact will receive their own ",e.jsx("span",{className:"font-semibold",children:"separate, personalized email"})," with their unique update link — not a group email."]}),b&&e.jsxs("p",{className:"text-xs text-amber-600 bg-amber-500/10 rounded-md px-2.5 py-1.5",children:["📦 ",g.length," contacts will be sent in ",_," batches of up to ",Ky,". You'll confirm before each batch."]})]})]}),X==="sending"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(As,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsxs("p",{className:"font-medium",children:["Sending batch ",te+1," of ",_,"..."]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[pe," of ",Te().length," in this batch"]})]}),e.jsx(Mi,{value:pe/Te().length*100,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Overall: ",de+ae," / ",g.length]}),e.jsxs("span",{children:[de," sent • ",ae," failed"]})]}),e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{ye.current=!0},children:"Stop Sending"})]}),X==="batch_complete"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(la,{className:"h-8 w-8 text-emerald-500 mx-auto"}),e.jsxs("p",{className:"font-medium",children:["Batch ",te+1," Complete!"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[de," sent, ",ae," failed so far"]})]}),e.jsx(Mi,{value:he,className:"h-2"}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[g.length-de-ae," contacts remaining (",_-te-1," batches left)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:ut,children:"Done for Now"}),e.jsxs(K,{className:"flex-1 gap-2",onClick:Ue,children:[e.jsx(Ta,{className:"h-4 w-4"}),"Send Next ",Math.min(Ky,g.length-Dt)," Contacts"]})]})]}),X==="all_done"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(la,{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:[de," emails sent successfully",ae>0&&e.jsxs("span",{className:"text-destructive",children:[" • ",ae," failed"]})]})]}),e.jsx(K,{className:"w-full",onClick:ut,children:"Close"})]}),X==="composing"&&e.jsxs("div",{className:"space-y-4",children:[$?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(Sn,{className:"h-4 w-4"})," Choose a Template"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>q(!1),className:"h-7 px-2 text-xs",children:[e.jsx(Ur,{className:"h-3 w-3 mr-1"})," Write from scratch"]})]}),e.jsx(d7t,{onSelect:Ke})]}):e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>q(!0),children:[e.jsx(Sn,{className:"h-4 w-4"}),"Browse Templates"]}),e.jsx(sc,{}),e.jsx("div",{className:"space-y-1.5",children:p?e.jsxs(e.Fragment,{children:[e.jsxs(ve,{children:["Recipients (",g.length,")"]}),e.jsx("div",{className:"bg-muted p-3 rounded-md space-y-1 max-h-24 overflow-y-auto text-muted-foreground",children:g.map(Ve=>e.jsxs("div",{className:"text-sm",children:[Ve.first_name," ",Ve.last_name," — ",Ve.email]},Ve.id))})]}):e.jsxs(e.Fragment,{children:[e.jsx(ve,{htmlFor:"gmail-to",children:"To"}),e.jsx(Re,{id:"gmail-to",value:j,onChange:Ve=>w(Ve.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:N,onChange:Ve=>C(Ve.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(at,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>I(Ve=>Ve+"{{first_name}}"),children:"{{first_name}}"}),e.jsx(at,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>I(Ve=>Ve+"{{last_name}}"),children:"{{last_name}}"})]})]}),e.jsx(Tr,{id:"gmail-body",value:A,onChange:Ve=>I(Ve.target.value),placeholder:"Write your message...",rows:10,className:"resize-y"})]}),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 Ve;return(Ve=document.getElementById("gmail-attachments"))==null?void 0:Ve.click()},disabled:L,children:[e.jsx(aN,{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:we})]}),U.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:U.map((Ve,nt)=>e.jsxs(at,{variant:"secondary",className:"gap-1.5 pl-2 pr-1 py-1",children:[e.jsx(aN,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-[140px] truncate text-xs",children:Ve.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["(",m7t(Ve.size),")"]}),e.jsx("button",{type:"button",onClick:()=>Ne(nt),className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Ur,{className:"h-3 w-3"})})]},nt))})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),disabled:L,children:"Cancel"}),e.jsxs(K,{onClick:Ae,disabled:L||!N||!A,className:"gap-2",children:[L?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(Ta,{className:"h-4 w-4"}),L?"Sending...":p?b?`Send First ${Ky}`:`Send to ${g.length}`:"Send Email"]})]})]})]})})}function f7t(){const t=Lr(),{data:s}=Xh(),{data:r}=EL(),n=sbe(),{isGmailConnected:a,gmailEmail:o}=py(),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,g]=S.useState(new Set),v=Hh(new Date),_=hl(v,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(v.getFullYear(),R,$)},j=S.useMemo(()=>{if(!s)return[];const I=[];for(const L of s){if(L.birthday){const R=b(L.birthday);R&&(ll(R,v)||AN(R,v)&&EN(R,_))&&I.push({contact:L,type:"birthday",date:R,daysUntil:up(R,v),dateStr:L.birthday})}if(L.home_anniversary){const R=b(L.home_anniversary);R&&(ll(R,v)||AN(R,v)&&EN(R,_))&&I.push({contact:L,type:"anniversary",date:R,daysUntil:up(R,v),dateStr:L.home_anniversary})}}return I.sort((L,R)=>L.daysUntil-R.daysUntil),I},[s]),w=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`}),g(R=>new Set(R).add(`${I.contact.id}-${I.type}`)),an({title:"Touch logged!",description:`Logged outreach for ${I.contact.first_name}`})}catch{an({title:"Error",description:"Failed to log touch",variant:"destructive"})}},N=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()}`)},C=I=>I===0?"Today!":I===1?"Tomorrow":`${I} days`,A=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(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(kc,{className:"h-5 w-5 text-primary"}),"Upcoming Milestones",e.jsx(at,{variant:"secondary",className:"text-xs font-normal",children:"Next 30 days"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[j.length," event",j.length!==1?"s":""]})]})}),e.jsxs(Oe,{className:"space-y-2",children:[j.length===0&&e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ou,{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."})]}),j.map((I,L)=>{var U,V;const R=`${I.contact.id}-${I.type}`,$=p.has(R),q=`${((U=I.contact.first_name)==null?void 0:U[0])||""}${((V=I.contact.last_name)==null?void 0:V[0])||""}`.toUpperCase();return e.jsxs("div",{className:Et("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(fn,{className:Et("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(gn,{className:Et("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(at,{variant:"outline",className:Et("text-[10px] shrink-0 whitespace-nowrap",A(I.daysUntil)),children:C(I.daysUntil)})]}),e.jsxs("div",{className:Et("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(Ou,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(Vn,{className:"h-3 w-3"})," Home Anniversary"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:ws(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(Zn,{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:Et("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:()=>N(I),children:[e.jsx(mn,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Card"})]}),e.jsx(K,{variant:"ghost",size:"icon",className:Et("h-7 w-7",$&&"text-green-600"),title:"Log a touch",disabled:$||n.isPending,onClick:()=>w(I),children:e.jsx(la,{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(ya,{className:"h-3.5 w-3.5"})})]})]},`${R}-${L}`)})]})]}),a&&l&&e.jsx(TM,{open:d,onOpenChange:u,contact:l,gmailEmail:o})]})}const hEe={Crown:zh,FileText:Sn,Users:hr,Globe:Am,Star:Gn,Phone:Zn,MessageSquare:io,PenTool:s_,Video:Nn,Gift:ao},g7t={"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 x7t(){var qe,lt,We,Ye,mt,Ze;const t=Lr(),{user:s}=Gs(),{data:r}=Ef(),{data:n}=JUe(),{data:a}=Xh(),{data:o}=EL(),{data:l}=nVe(),i=r5t(),d=rbe(),u=t5t(90),p=sbe(),[g,v]=S.useState(null),[_,b]=S.useState(null),[j,w]=S.useState(!1),[N,C]=S.useState(""),[A,I]=S.useState(!1),[L,R]=S.useState(""),[$,q]=S.useState(Dne()),[U,V]=S.useState("cards"),[X,se]=S.useState(!1),[te,Y]=S.useState(null),[de,ie]=S.useState(null),[ae,le]=S.useState(""),{isGmailConnected:pe,gmailEmail:be}=py(),ye=()=>{const He=parseInt(L,10);if(isNaN(He)||He<1){an({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}q(He),rVe(He),I(!1),an({title:"Goal updated",description:`Weekly touch goal set to ${He}`})},we=()=>{R($.toString()),I(!0)};S.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&&C(et.name.split(" ")[0])})()},[s==null?void 0:s.id]),S.useEffect(()=>{i.mutate()},[]);const Ne=Hh(new Date),Ke=hl(Ne,7),_e=He=>{if(!He)return null;const et=He.split(/[-/T]/);if(et.length<3)return null;const Rt=parseInt(et[1],10)-1,qt=parseInt(et[2],10);return isNaN(Rt)||isNaN(qt)?null:new Date(Ne.getFullYear(),Rt,qt)},Me=(a==null?void 0:a.filter(He=>{const et=_e(He.birthday),Rt=_e(He.home_anniversary);return et&&ll(et,Ne)||Rt&&ll(Rt,Ne)}))||[];a!=null&&a.filter(He=>{if(!He.birthday&&!He.home_anniversary)return!1;const et=Rt=>{if(!Rt)return!1;const qt=_e(Rt);return qt?AN(qt,Ne)&&EN(qt,Ke):!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=_e(He.birthday),Rt=_e(He.home_anniversary),qt=et&&ll(et,Ne),ls=Rt&&ll(Rt,Ne);qt&&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:((We=(lt=(qe=He.tags)==null?void 0:qe[0])==null?void 0:lt.relationship_type)==null?void 0:We.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"birthday"}),ls&&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:((Ze=(mt=(Ye=He.tags)==null?void 0:Ye[0])==null?void 0:mt.relationship_type)==null?void 0:Ze.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 qt,ls,Kt;const Rt=o==null?void 0:o[et%((o==null?void 0:o.length)||1)];return Rt?{contact:He,actionType:Rt,planName:"Quick Touch",relationshipTypeName:((Kt=(ls=(qt=He.tags)==null?void 0:qt[0])==null?void 0:ls.relationship_type)==null?void 0:Kt.name)||"",monthNumber:0}:null}).filter(Boolean))||[],ut=[...Te,...Ue],De=async(He,et,Rt)=>{await p.mutateAsync({contactId:He,actionTypeId:et,scriptUsedId:Rt}),w(!1),b(null)},Dt=He=>{He.script?(b(He),w(!0)):De(He.contact.id,He.actionType.id)},he=He=>hEe[He||"Phone"]||Zn,Ve=He=>hEe[He||"Users"]||hr,nt=(He,et)=>He.replace(/\{\{FirstName\}\}/g,et.first_name).replace(/\{\{LastName\}\}/g,et.last_name||"").replace(/\{\{AgentName\}\}/g,N||"there"),Qe=(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}!`,ke=(He,et,Rt)=>{const qt=`sms:${He}`;if(et&&Rt){const ls=nt(et,Rt);return`${qt}?body=${encodeURIComponent(ls)}`}return qt},ot=(He,et,Rt,qt,ls)=>{const Kt=`mailto:${He}`,Qt=[];if(ls){const fs=Rt||Qe(qt||"Email",ls.first_name);if(Qt.push(`subject=${encodeURIComponent(fs)}`),et){const dr=nt(et,ls);Qt.push(`body=${encodeURIComponent(dr)}`)}}return Qt.length>0?`${Kt}?${Qt.join("&")}`:Kt};return e.jsxs(e.Fragment,{children:[e.jsxs(Ms,{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=Ve(He.icon),Rt=(n==null?void 0:n[He.id])||0,qt=g===He.id,ls=g7t[He.name]||"bg-secondary text-secondary-foreground";return e.jsxs("button",{onClick:()=>{qt?(v(null),t("/mission-control/contacts")):(v(He.id),t(`/mission-control/contacts?type=${He.id}`))},className:` flex items-center gap-2 px-4 py-3 rounded-lg border transition-all ${qt?ls:"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 ${qt?"opacity-90":"text-muted-foreground"}`,children:[Rt," 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(au,{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(qa,{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(at,{variant:"outline",className:"gap-1",children:[e.jsx(mn,{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:()=>V("cards"),title:"Card view",children:e.jsx(pp,{className:"h-4 w-4"})}),e.jsx(K,{variant:U==="table"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>V("table"),title:"Table view",children:e.jsx(qh,{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(c7t,{actions:ut,onMarkComplete:De,onViewScript:Dt,isLoading:p.isPending,buildSmsLink:ke,buildEmailLink:ot,onGmailCompose:pe?He=>{Y(He),se(!0)}:void 0}):e.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[ut.map((He,et)=>{var bt,ks,ir,Rr,ca,ii,lo;const Rt=He.isSpecialDate,qt=He.specialDateType,ls=Rt?qt==="birthday"?Ou:Vn:he(((bt=He.actionType)==null?void 0:bt.icon)||null),Kt=He.contact.phone,Qt=He.contact.email,fs=Rt?qt==="birthday"?"#EC4899":"#8B5CF6":((ks=He.actionType)==null?void 0:ks.color)||"#3B82F6",dr=Rt?qt==="birthday"?"🎂 Birthday Today!":"🏠 Home Anniversary!":(ir=He.actionType)==null?void 0:ir.name;return e.jsxs("div",{className:`flex-shrink-0 w-[260px] border rounded-lg overflow-hidden ${Rt?"ring-2 ring-offset-2":""}`,style:Rt?{"--tw-ring-color":fs}:void 0,children:[e.jsxs("div",{className:"p-3 text-white flex items-center gap-2",style:{backgroundColor:fs},children:[e.jsx(ls,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:dr})]}),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:[Kt&&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(Zn,{className:"h-3 w-3"}),"Call"]}),e.jsxs("a",{href:ke(He.contact.phone,(Rr=He.script)==null?void 0:Rr.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"]})]}),Qt&&(pe?e.jsxs("button",{onClick:()=>{Y({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:ot(He.contact.email,(ca=He.script)==null?void 0:ca.script_body,(ii=He.script)==null?void 0:ii.email_subject,(lo=He.actionType)==null?void 0:lo.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"]}))]}),Rt&&e.jsxs("button",{onClick:()=>{const Oa=`${He.contact.first_name}${He.contact.last_name?" "+He.contact.last_name:""}`,yn=qt==="birthday"?"birthday":"home_anniversary",ta=new URLSearchParams({cardType:yn,contactId:He.contact.id,name:Oa,...He.contact.address?{address:He.contact.address}:{},...qt==="anniversary"&&He.contact.home_anniversary?{date:He.contact.home_anniversary}:{}});t(`/mission-control/card-studio?${ta.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 ",qt==="birthday"?"Birthday":"Anniversary"," Card"]}),!Kt&&!Qt&&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(at,{variant:"secondary",className:"text-xs",children:He.relationshipTypeName}),He.monthNumber>0&&e.jsxs(at,{variant:"outline",className:"text-xs",children:["Month ",He.monthNumber]})]}),He.script&&e.jsx(K,{size:"sm",variant:"outline",className:"w-full",onClick:()=>Dt(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:()=>{ie(He.contact.id),le(`${He.contact.first_name} ${He.contact.last_name||""}`.trim())},children:[e.jsx(fp,{className:"h-3.5 w-3.5"}),"Snooze"]}),e.jsx(K,{size:"sm",className:"flex-1",onClick:()=>{var Oa;return De(He.contact.id,He.actionType.id,(Oa=He.script)==null?void 0:Oa.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(yu,{children:[e.jsx(vu,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"h-full w-full",children:[e.jsx(ef,{className:"h-5 w-5 mr-2"}),"More"]})}),e.jsx(Wd,{children:e.jsx(Da,{onClick:()=>t("/mission-control/contacts"),children:"View all contacts"})})]})})]})})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zt,{className:"text-lg",children:"Momentum"}),e.jsxs(vs,{open:A,onOpenChange:I,children:[e.jsx(Ai,{asChild:!0,children:e.jsx("button",{onClick:we,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(Fl,{className:"h-4 w-4 text-muted-foreground hover:text-primary"})})}),e.jsxs(ys,{className:"sm:max-w-[360px]",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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"&&ye()}})]}),e.jsx(K,{onClick:ye,className:"w-full",children:"Save Goal"})]})]})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Mi,{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(Bh,{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(In,{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(qa,{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(_Ve,{}),e.jsx(f7t,{})]})]}),e.jsx(vs,{open:j,onOpenChange:w,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{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:nt(_.script.script_body,_.contact)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>w(!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(r7t,{})]}),pe&&te&&e.jsx(TM,{open:X,onOpenChange:se,contact:te,gmailEmail:be}),e.jsx(Sle,{open:!!de,onOpenChange:He=>!He&&ie(null),contactId:de||"",contactName:ae})]})}var XKe="Toggle",xwe=S.forwardRef((t,s)=>{const{pressed:r,defaultPressed:n,onPressedChange:a,...o}=t,[l,i]=fu({prop:r,onChange:a,defaultProp:n??!1,caller:XKe});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)})})});xwe.displayName=XKe;var QKe=xwe,Z_="ToggleGroup",[JKe]=Tc(Z_,[B_]),eZe=B_(),ywe=ht.forwardRef((t,s)=>{const{type:r,...n}=t;if(r==="single"){const a=n;return e.jsx(y7t,{...a,ref:s})}if(r==="multiple"){const a=n;return e.jsx(v7t,{...a,ref:s})}throw new Error(`Missing prop \`type\` expected on \`${Z_}\``)});ywe.displayName=Z_;var[tZe,sZe]=JKe(Z_),y7t=ht.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=fu({prop:r,defaultProp:n??"",onChange:a,caller:Z_});return e.jsx(tZe,{scope:t.__scopeToggleGroup,type:"single",value:ht.useMemo(()=>l?[l]:[],[l]),onItemActivate:i,onItemDeactivate:ht.useCallback(()=>i(""),[i]),children:e.jsx(rZe,{...o,ref:s})})}),v7t=ht.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=fu({prop:r,defaultProp:n??[],onChange:a,caller:Z_}),d=ht.useCallback(p=>i((g=[])=>[...g,p]),[i]),u=ht.useCallback(p=>i((g=[])=>g.filter(v=>v!==p)),[i]);return e.jsx(tZe,{scope:t.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:d,onItemDeactivate:u,children:e.jsx(rZe,{...o,ref:s})})});ywe.displayName=Z_;var[_7t,b7t]=JKe(Z_),rZe=ht.forwardRef((t,s)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:o,dir:l,loop:i=!0,...d}=t,u=eZe(r),p=z_(l),g={role:"group",dir:p,...d};return e.jsx(_7t,{scope:r,rovingFocus:a,disabled:n,children:a?e.jsx(loe,{asChild:!0,...u,orientation:o,dir:p,loop:i,children:e.jsx(Qr.div,{...g,ref:s})}):e.jsx(Qr.div,{...g,ref:s})})}),Eae="ToggleGroupItem",nZe=ht.forwardRef((t,s)=>{const r=sZe(Eae,t.__scopeToggleGroup),n=b7t(Eae,t.__scopeToggleGroup),a=eZe(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(coe,{asChild:!0,...a,focusable:!l,active:o,ref:d,children:e.jsx(mEe,{...i,ref:s})}):e.jsx(mEe,{...i,ref:s})});nZe.displayName=Eae;var mEe=ht.forwardRef((t,s)=>{const{__scopeToggleGroup:r,value:n,...a}=t,o=sZe(Eae,r),l={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},i=o.type==="single"?l:void 0;return e.jsx(xwe,{...i,...a,ref:s,onPressedChange:d=>{d?o.onItemActivate(n):o.onItemDeactivate(n)}})}),aZe=ywe,iZe=nZe;const oZe=ZN("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"}}),w7t=S.forwardRef(({className:t,variant:s,size:r,...n},a)=>e.jsx(QKe,{ref:a,className:Et(oZe({variant:s,size:r,className:t})),...n}));w7t.displayName=QKe.displayName;const lZe=S.createContext({size:"default",variant:"default"}),cZe=S.forwardRef(({className:t,variant:s,size:r,children:n,...a},o)=>e.jsx(aZe,{ref:o,className:Et("flex items-center justify-center gap-1",t),...a,children:e.jsx(lZe.Provider,{value:{variant:s,size:r},children:n})}));cZe.displayName=aZe.displayName;const dZe=S.forwardRef(({className:t,children:s,variant:r,size:n,...a},o)=>{const l=S.useContext(lZe);return e.jsx(iZe,{ref:o,className:Et(oZe({variant:l.variant||r,size:l.size||n}),t),...a,children:s})});dZe.displayName=iZe.displayName;const j7t=[{value:"bidirectional",label:"Two-Way",icon:Vc,tooltip:"Sync contacts in both directions"},{value:"push_only",label:"Push Only",icon:qd,tooltip:"Only push Agent OS → BoldTrail"},{value:"pull_only",label:"Pull Only",icon:Ju,tooltip:"Only pull BoldTrail → Agent OS"}];function cye({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(cZe,{type:"single",value:t,onValueChange:a=>{a&&s(a)},className:"justify-start",children:j7t.map(a=>e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsxs(dZe,{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(Hc,{children:a.tooltip})]},a.value))})]})}function k7t(){const t=ns(),[s,r]=S.useState(!1),[n,a]=S.useState(null),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(null),[g,v]=S.useState(null),[_,b]=S.useState(0),j=S.useRef(!1),{data:w}=Ct({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:$,error:q}=await G.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(q)throw q;return $}}),N=(w==null?void 0:w.sync_direction)||"bidirectional",C=u??N,A=Ot({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=Ot({mutationFn:async()=>{j.current=!1,v("Initializing sync..."),b(5);const{data:$,error:q}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:C}});if(q)throw q;if($!=null&&$.error)throw new Error($.error);const U=$;let V=U.sync_log_id,X=U.next_phase,se=U.next_offset;const te=U.push_total||0,Y=U.pull_total||0,de=te+Y;let ie=0,ae=0;for(;X!=="finalize"&&!j.current;){X==="push"?(v(`Pushing contacts to BoldTrail... (${ie}/${te})`),b(de>0?ie/de*100:0)):X==="pull"&&(v(`Pulling contacts from BoldTrail... (${ae}/${Y})`),b(de>0?(te+ae)/de*100:0));const{data:be,error:ye}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:X,offset:se,sync_log_id:V,sync_direction:C}});if(ye)throw ye;if(be!=null&&be.error)throw new Error(be.error);const we=be;ie+=we.chunk_pushed||0,ae+=we.chunk_pulled||0,we.progress&&v(we.progress),X==="pull"&&Y>0?b(Math.min(95,ae/Y*100)):X==="push"&&te>0&&b(Math.min(95,ie/te*100)),X=we.next_phase,se=we.next_offset}v("Finalizing sync..."),b(95);const{data:le,error:pe}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:V,sync_direction:C}});if(pe)throw pe;return b(100),le},onSuccess:$=>{v(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:$=>{v(null),b(0),fe.error($.message||"Sync failed")}});if(!(w!=null&&w.connected))return null;const L=C==="pull_only"?0:(n==null?void 0:n.to_push)??0,R=C==="push_only"?0:(n==null?void 0:n.to_pull)??0;return e.jsxs(e.Fragment,{children:[e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"icon",onClick:()=>A.mutate(),disabled:A.isPending,className:"shrink-0",children:A.isPending?e.jsx(Eo,{className:"h-4 w-4 animate-spin"}):e.jsx(Vc,{className:"h-4 w-4 text-emerald-600"})})}),e.jsx(Hc,{children:"Sync with BoldTrail"})]}),e.jsx(vs,{open:s,onOpenChange:$=>{I.isPending||r($)},children:e.jsxs(ys,{className:"sm:max-w-lg",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Vc,{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(cye,{value:C,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 ${C==="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(qd,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${C==="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(Ju,{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(mf,{open:o,onOpenChange:l,children:[e.jsx(pf,{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(qd,{className:"h-3 w-3 text-emerald-600"}),L," contacts to push to BoldTrail"]}),e.jsx(Vo,{className:`h-3 w-3 transition-transform ${o?"rotate-180":""}`})]})}),e.jsx(ff,{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(mf,{open:i,onOpenChange:d,children:[e.jsx(pf,{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(Ju,{className:"h-3 w-3 text-blue-600"}),R," contacts to pull from BoldTrail"]}),e.jsx(Vo,{className:`h-3 w-3 transition-transform ${i?"rotate-180":""}`})]})}),e.jsx(ff,{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(Mi,{value:_||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:g||"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(Eo,{className:"h-4 w-4 animate-spin"}):e.jsx(Vc,{className:"h-4 w-4"}),I.isPending?"Syncing...":"Sync Now"]})]})]})]})})]})}const uZe=()=>{const{user:t}=Gs();return Ct({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})},Cle=t=>{const{user:s}=Gs();return Ct({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})},vwe=()=>{const{user:t}=Gs();return Ct({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})},hZe=()=>{const{user:t}=Gs();return Ct({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})},mZe=()=>{const{data:t}=Xh(),{data:s}=Ef(),{data:r}=Cle(),{data:n}=hZe(),{data:a}=vwe(),o=new Map;r==null||r.forEach(p=>{const g=o.get(p.contact_id);(!g||new Date(p.completed_at)>new Date(g))&&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=Hh(new Date);return(t||[]).map(p=>{let g=90;if(i.has(p.id))g=i.get(p.id);else if(p.tags&&p.tags.length>0){const w=p.tags.map(N=>l.get(N.relationship_type_id)).filter(N=>N!==void 0);w.length>0&&(g=Math.min(...w))}const v=o.get(p.id)||null,_=v?Vg(d,Hh(new Date(v))):null,b=_===null||_>=g,j=b&&_!==null?_-g:0;return{...p,lastPopby:v,daysSinceLastPopby:_,frequencyDays:g,isDue:b,daysOverdue:j}}).sort((p,g)=>g.daysOverdue-p.daysOverdue)},pZe=()=>mZe().filter(s=>s.isDue),N7t=()=>{const t=ns(),{user:s}=Gs();return Ot({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"]}),an({title:"Popby item created!"})},onError:r=>{an({title:"Error creating popby item",description:r.message,variant:"destructive"})}})},fZe=()=>{const t=ns(),{user:s}=Gs();return Ot({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"]}),an({title:"Popby logged!"})},onError:r=>{an({title:"Error logging popby",description:r.message,variant:"destructive"})}})},S7t=()=>{const t=ns(),{user:s}=Gs();return Ot({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"]}),an({title:"Frequency updated!"})},onError:r=>{an({title:"Error updating frequency",description:r.message,variant:"destructive"})}})},C7t=()=>{const{data:t}=Cle(30),s=pZe(),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 M7t(){const{user:t}=Gs();return Ct({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 gZe(t){const{data:s}=M7t(),{data:r}=hZe(),{data:n}=vwe(),{data:a}=n7t();return S.useMemo(()=>{const o=a==null?void 0:a.find(w=>w.contact_id===t.id),l=o?new Date(o.snoozed_until):null,i=Hh(new Date);if(l&&!EN(l,i))return{nextTouchDate:l,daysUntil:Vg(l,i),status:"snoozed",frequencyDays:90,lastTouchDate:null,snoozedUntil:l};const u=((s==null?void 0:s.filter(w=>w.contact_id===t.id))||[]).sort((w,N)=>new Date(N.completed_at).getTime()-new Date(w.completed_at).getTime())[0],p=u?new Date(u.completed_at):null;let g=90;const v=r==null?void 0:r.find(w=>w.contact_id===t.id&&w.is_active);if(v)g=v.frequency_days;else if(t.tags&&t.tags.length>0){const w=t.tags.map(N=>{const C=n==null?void 0:n.find(A=>A.relationship_type_id===N.relationship_type_id);return C==null?void 0:C.frequency_days}).filter(N=>N!==void 0);w.length>0&&(g=Math.min(...w))}if(!p)return{nextTouchDate:null,daysUntil:null,status:"never-touched",frequencyDays:g,lastTouchDate:null,snoozedUntil:null};const _=hl(Hh(p),g),b=Vg(_,i);let j;return b<0?j="overdue":b<=7?j="due-soon":j="on-track",{nextTouchDate:_,daysUntil:b,status:j,frequencyDays:g,lastTouchDate:p,snoozedUntil:null}},[t,s,r,n,a])}function dye({contact:t}){const s=gZe(t),n=(()=>{switch(s.status){case"overdue":return{variant:"destructive",icon:Qo,text:`${Math.abs(s.daysUntil)} days overdue`,className:""};case"due-soon":return{variant:"secondary",icon:In,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:la,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:fp,text:`Snoozed until ${ws(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(at,{variant:n.variant,className:Et("gap-1",n.className),children:[e.jsx(a,{className:"h-3 w-3"}),n.text]})}function T7t({contact:t,onLogTouch:s,onSnooze:r}){const n=gZe(t),a=i7t(),[o,l]=S.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(Qo,{className:"h-5 w-5 text-destructive"});case"due-soon":return e.jsx(In,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"});case"on-track":return e.jsx(la,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"});case"snoozed":return e.jsx(fp,{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(Lt,{className:"pb-2",children:e.jsxs(zt,{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:Et("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:"})," ",ws(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:"})," ",ws(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:"})," ",ws(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(fp,{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(Sle,{open:o,onOpenChange:l,contactId:t.id,contactName:`${t.first_name} ${t.last_name||""}`.trim()})]})}const Zme=768;function AM(){const[t,s]=S.useState(void 0);return S.useEffect(()=>{const r=window.matchMedia(`(max-width: ${Zme-1}px)`),n=()=>{s(window.innerWidthr.removeEventListener("change",n)},[]),!!t}const A7t={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"}},E7t={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 uI({score:t,showScore:s=!1,showTooltip:r=!0,size:n="sm",className:a}){const o=A7t[t.status],l=E7t[n],i=e.jsxs("div",{className:Et("inline-flex items-center rounded-full font-medium",o.bgLightClass,o.textClass,l.badge,l.text,a),children:[e.jsx("span",{className:Et("rounded-full",o.bgClass,l.dot)}),s?e.jsx("span",{children:t.score}):e.jsx("span",{children:o.label})]});return r?e.jsx(YN,{children:e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:i}),e.jsx(Hc,{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:Et("font-bold",o.textClass),children:[t.score,"/100"]})]}),e.jsx(Mi,{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 P7t=[{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}],cR=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]},I7t=({open:t,onOpenChange:s,relationshipTypes:r,onSuccess:n})=>{const{user:a}=Gs(),{toast:o}=Ea(),l=S.useRef(null),[i,d]=S.useState("upload"),[u,p]=S.useState([]),[g,v]=S.useState([]),[_,b]=S.useState({}),[j,w]=S.useState([]),[N,C]=S.useState([]),[A,I]=S.useState(!1),[L,R]=S.useState(null),$=()=>{d("upload"),p([]),v([]),b({}),w([]),C([]),R(null),l.current&&(l.current.value="")},q=()=>{$(),s(!1)},U=be=>{const ye=be.split(` `).map(_e=>_e.trim()).filter(_e=>_e);if(ye.length===0)return{headers:[],data:[]};const we=_e=>{const Me=[];let Te="",Fe=!1;for(let Ae=0;Ae<_e.length;Ae++){const Ue=_e[Ae];Ue==='"'?Fe=!Fe:(Ue===","||Ue===" ")&&!Fe?(Me.push(Te.trim()),Te=""):Te+=Ue}return Me.push(Te.trim()),Me},Ne=we(ye[0]),Ke=ye.slice(1).map(we);return{headers:Ne,data:Ke}},V=be=>{var Ne;const ye=(Ne=be.target.files)==null?void 0:Ne[0];if(!ye)return;const we=new FileReader;we.onload=Ke=>{var Ae;const _e=(Ae=Ke.target)==null?void 0:Ae.result,{headers:Me,data:Te}=U(_e);if(Me.length===0){o({title:"No data found",description:"The CSV file appears to be empty.",variant:"destructive"});return}p(Me),v(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")},we.readAsText(ye)},X=(be,ye)=>{b(we=>{if(ye==="none"){const{[be]:Ne,...Ke}=we;return Ke}return{...we,[be]:ye}})},se=be=>{w(ye=>ye.includes(be)?ye.filter(we=>we!==be):[...ye,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),ye=new Set((be||[]).filter(Ke=>Ke.email).map(Ke=>Ke.email.toLowerCase())),we=new Set((be||[]).filter(Ke=>Ke.phone).map(Ke=>Ke.phone.replace(/[^0-9]/g,""))),Ne=g.map(Ke=>{const _e=ut=>{const De=_[ut];if(!De)return"";const Dt=u.indexOf(De);return Dt>=0?(Ke[Dt]||"").trim():""},Me=_e("first_name"),Te=_e("email"),Fe=_e("phone"),Ae=Me.length>0,Ue=!!(Te&&ye.has(Te.toLowerCase())||Fe&&we.has(Fe.replace(/[^0-9]/g,"")));return{first_name:Me,last_name:_e("last_name"),email:Te,phone:Fe,address:_e("address"),city:_e("city"),state:_e("state"),zip:_e("zip"),spouse_name:_e("spouse_name"),spouse_email:_e("spouse_email"),company_name:_e("company_name"),job_title:_e("job_title"),birthday:_e("birthday"),home_anniversary:_e("home_anniversary"),notes:_e("notes"),isValid:Ae,isDuplicate:Ue,error:Ae?void 0:"First name is required"}});C(Ne),d("preview")},Y=be=>{const ye=be.trim().split(/\s+/);return{first_name:ye[0],last_name:ye.length>1?ye.slice(1).join(" "):null}},de=async()=>{if(!(a!=null&&a.id))return;const be=N.filter(Ke=>Ke.isValid);if(be.length===0){o({title:"No valid contacts",description:"There are no valid contacts to import.",variant:"destructive"});return}I(!0);let ye=0,we=0,Ne=0;try{for(const Ke of be)try{let _e=null;if(Ke.email){const{data:Fe}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Ke.email).maybeSingle();_e=Fe}if(!_e&&Ke.phone){const Fe=Ke.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&&(_e={id:Ue.id})}}const Me={owner_user_id:a.id,first_name:Ke.first_name,last_name:Ke.last_name||null,email:Ke.email||null,phone:Ke.phone||null,address:Ke.address||null,city:Ke.city||null,state:Ke.state||null,zip:Ke.zip||null,spouse_name:Ke.spouse_name||null,spouse_email:Ke.spouse_email||null,company_name:Ke.company_name||null,job_title:Ke.job_title||null,birthday:cR(Ke.birthday),home_anniversary:cR(Ke.home_anniversary),notes:Ke.notes||null};let Te=null;if(_e){const{data:Fe}=await G.from("innercircle_contacts").select("*").eq("id",_e.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],Dt=Me[ut];(!De||De==="")&&Dt&&(Ae[ut]=Dt)}Object.keys(Ae).length>0&&await G.from("innercircle_contacts").update(Ae).eq("id",_e.id)}Te=_e.id,we++}else{const{data:Fe,error:Ae}=await G.from("innercircle_contacts").insert(Me).select("id").single();Ae?(console.error("Insert error for contact:",Ke.first_name,Ae),Ne++):Fe?(Te=Fe.id,j.length>0&&await G.from("innercircle_contact_tags").insert(j.map(Ue=>({contact_id:Fe.id,relationship_type_id:Ue}))),ye++):Ne++}if(Te&&Ke.spouse_name){const Fe=Y(Ke.spouse_name);let Ae=null;if(Ke.spouse_email){const{data:ut}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Ke.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||Ke.last_name||"").maybeSingle();Ae=ut}let Ue=null;if(Ae){Ue=Ae.id;const ut=cR(Ke.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||Ke.last_name||null,email:Ke.spouse_email||null,address:Ke.address||null,city:Ke.city||null,state:Ke.state||null,zip:Ke.zip||null,home_anniversary:cR(Ke.home_anniversary),spouse_name:`${Ke.first_name}${Ke.last_name?" "+Ke.last_name:""}`,spouse_email:Ke.email||null,notes:`Spouse of ${Ke.first_name} ${Ke.last_name||""} (imported via CSV)`.trim()}).select("id").single();ut&&(Ue=ut.id,ye++)}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(_e){console.error("Error importing contact:",_e),Ne++}R({created:ye,updated:we,failed:Ne}),d("result"),(ye>0||we>0)&&n(),o({title:"Import Complete",description:`${ye} created, ${we} updated${Ne>0?`, ${Ne} failed`:""}.`})}catch(Ke){console.error("Import error:",Ke),o({title:"Import Failed",description:Ke.message||"Failed to import contacts",variant:"destructive"})}finally{I(!1)}},ie=N.filter(be=>be.isValid).length,ae=N.filter(be=>!be.isValid).length,le=N.filter(be=>be.isValid&&be.isDuplicate).length,pe=ie-le;return e.jsx(vs,{open:t,onOpenChange:q,children:e.jsxs(ys,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(N0,{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:V,className:"hidden"}),e.jsx(Xa,{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`,ye=new Blob([be],{type:"text/csv"}),we=URL.createObjectURL(ye),Ne=document.createElement("a");Ne.href=we,Ne.download="contact_import_template.csv",Ne.click(),URL.revokeObjectURL(we)},children:[e.jsx(gi,{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:P7t.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(tr,{value:_[be.key]||"none",onValueChange:ye=>X(be.key,ye),children:[e.jsx(Js,{className:"w-48",children:e.jsx(sr,{placeholder:"Select column..."})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"-- Not mapped --"}),u.map(ye=>e.jsx(At,{value:ye,children:ye},ye))]})]})]},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(at,{variant:j.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: ",g.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(la,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{children:[pe," new"]})]}),le>0&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Qo,{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(Qo,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{className:"bg-muted/30",children:[e.jsx(jt,{children:"First Name"}),e.jsx(jt,{children:"Last Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Phone"}),e.jsx(jt,{children:"Status"})]})}),e.jsx(En,{children:N.slice(0,100).map((be,ye)=>e.jsxs(js,{children:[e.jsx(it,{children:be.first_name}),e.jsx(it,{children:be.last_name}),e.jsx(it,{children:be.email}),e.jsx(it,{children:be.phone}),e.jsx(it,{children:be.isValid?be.isDuplicate?e.jsx(at,{variant:"outline",className:"bg-accent text-accent-foreground",children:"Merge"}):e.jsx(at,{variant:"secondary",className:"bg-primary/10 text-primary",children:"New"}):e.jsx(at,{variant:"destructive",children:be.error||"Invalid"})})]},ye))})]}),N.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",N.length," contacts"]})]})]}),i==="result"&&L&&e.jsxs("div",{className:"space-y-4 py-4 text-center",children:[e.jsx(la,{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(On,{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:A||ie===0,children:A?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${ie} Contact${ie!==1?"s":""}`})]}),i==="result"&&e.jsx(K,{onClick:q,children:"Done"})]})]})})};function L7t(){return"contacts"in navigator&&"ContactsManager"in window}function D7t(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 g=p.replace(/^\s+/,"");if(g.startsWith("N:")||g.startsWith("N;")){const _=g.substring(g.indexOf(":")+1).split(";");l=(_[0]||"").trim(),o=(_[1]||"").trim()}if((g.startsWith("FN:")||g.startsWith("FN;"))&&!o){const _=g.substring(g.indexOf(":")+1).trim().split(" ");o=_[0]||"",l=_.slice(1).join(" ")}(g.startsWith("EMAIL")||g.match(/^item\d+\.EMAIL/i))&&!i&&(i=g.substring(g.indexOf(":")+1).trim()),(g.startsWith("TEL")||g.match(/^item\d+\.TEL/i))&&!d&&(d=g.substring(g.indexOf(":")+1).trim()),(g.startsWith("ADR")||g.match(/^item\d+\.ADR/i))&&!u&&(u=g.substring(g.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 O7t({open:t,onOpenChange:s,onComplete:r}){const{user:n}=Gs(),{data:a}=Xh(),o=Zoe(),l=S.useRef(null),[i,d]=S.useState("choose"),[u,p]=S.useState([]),[g,v]=S.useState(new Set),[_,b]=S.useState(0),[j,w]=S.useState(0),N=L7t(),C=S.useCallback(X=>{if(!a)return X;const se=new Set(a.filter(Y=>Y.email).map(Y=>Y.email.toLowerCase())),te=new Set(a.filter(Y=>Y.phone).map(Y=>Y.phone.replace(/\D/g,"")));return X.map(Y=>{var ae,le;const de=(ae=Y.email)==null?void 0:ae.toLowerCase(),ie=(le=Y.phone)==null?void 0:le.replace(/\D/g,"");return de&&se.has(de)?{...Y,isDuplicate:!0,duplicateField:"email"}:ie&&ie.length>=7&&te.has(ie)?{...Y,isDuplicate:!0,duplicateField:"phone"}:Y})},[a]),A=async()=>{try{const X=["name","email","tel","address"],se=await navigator.contacts.select(X,{multiple:!0});if(!se||se.length===0)return;const te=se.map(ie=>{var pe,be,ye,we;const le=(((pe=ie.name)==null?void 0:pe[0])||"").split(" ");return{first_name:le[0]||"",last_name:le.slice(1).join(" "),email:((be=ie.email)==null?void 0:be[0])||"",phone:((ye=ie.tel)==null?void 0:ye[0])||"",address:(we=ie.address)!=null&&we[0]?[ie.address[0].streetAddress,ie.address[0].city,ie.address[0].region,ie.address[0].postalCode].filter(Boolean).join(", "):""}}),Y=C(te);p(Y);const de=new Set;Y.forEach((ie,ae)=>{ie.isDuplicate||de.add(ae)}),v(de),d("preview")}catch(X){console.error("Contact Picker error:",X),an({title:"Could not access contacts",description:"Please try the file upload option instead.",variant:"destructive"})}},I=X=>{var Y;const se=(Y=X.target.files)==null?void 0:Y[0];if(!se)return;const te=new FileReader;te.onload=de=>{var be;const ie=(be=de.target)==null?void 0:be.result,ae=D7t(ie);if(ae.length===0){an({title:"No contacts found",description:"The file didn't contain any valid contacts.",variant:"destructive"});return}const le=C(ae);p(le);const pe=new Set;le.forEach((ye,we)=>{ye.isDuplicate||pe.add(we)}),v(pe),d("preview")},te.readAsText(se),l.current&&(l.current.value="")},L=async()=>{const X=u.filter((te,Y)=>g.has(Y));if(X.length===0)return;d("importing");let se=0;for(const te of X)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++,w(Math.round(se/X.length*100))}catch(Y){console.error(`Failed to import ${te.first_name} ${te.last_name}:`,Y)}b(se),d("done")},R=X=>{v(se=>{const te=new Set(se);return te.has(X)?te.delete(X):te.add(X),te})},$=()=>{g.size===u.length?v(new Set):v(new Set(u.map((X,se)=>se)))},q=X=>{X||(d("choose"),p([]),v(new Set),b(0),w(0),i==="done"&&r()),s(X)},U=u.filter(X=>X.isDuplicate).length,V=g.size;return e.jsx(vs,{open:t,onOpenChange:q,children:e.jsxs(ys,{className:"sm:max-w-lg max-h-[90vh]",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(L0,{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:[N&&e.jsxs(K,{onClick:A,className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(L0,{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:[N&&e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),N&&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:N?"outline":"default",onClick:()=>{var X;return(X=l.current)==null?void 0:X.click()},className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(Xa,{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:N?"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"}),!N&&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:g.size===u.length?"Deselect All":"Select All"})]}),e.jsx(Fi,{className:"h-[350px] rounded-md border",children:e.jsx("div",{className:"divide-y",children:u.map((X,se)=>e.jsxs("div",{className:`flex items-start gap-3 p-3 cursor-pointer hover:bg-accent/50 transition-colors ${X.isDuplicate?"opacity-60":""}`,onClick:()=>R(se),children:[e.jsx(zo,{checked:g.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:[X.first_name," ",X.last_name]}),X.isDuplicate&&e.jsxs(at,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600 border-amber-200",children:["Exists (",X.duplicateField,")"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5 mt-0.5",children:[X.phone&&e.jsx("div",{children:X.phone}),X.email&&e.jsx("div",{className:"truncate",children:X.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:V===0,children:["Import ",V," Contact",V!==1?"s":""]})]})]}),i==="importing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(As,{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:[j,"% 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:`${j}%`}})})]}),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(fa,{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 Mle(){const t=si();return Ct({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 R7t(t){return Ct({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 _we(){const t=ns(),s=si();return Ot({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 F7t(){const t=ns();return Ot({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 z7t(){const t=ns();return Ot({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 xZe(){const t=ns();return Ot({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 B7t(){const t=ns();return Ot({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 $7t(){const t=si();return Ct({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 q7t({selectedIds:t,contacts:s,onClearSelection:r,onSendToLeadPond:n,showLeadPondAction:a,onTransfer:o,showTransferAction:l}){const{data:i}=Ef(),d=tbe(),u=ns(),{isGmailConnected:p}=py(),{data:g}=Mle(),v=_we(),_=xZe(),[b,j]=S.useState(!1),[w,N]=S.useState(!1),[C,A]=S.useState(!1),[I,L]=S.useState(""),R=t.size;if(R===0)return null;const $=async Y=>{j(!0);try{const ie=Array.from(t).map(le=>({contact_id:le,relationship_type_id:Y})),{error:ae}=await G.from("innercircle_contact_tags").upsert(ie,{onConflict:"contact_id,relationship_type_id",ignoreDuplicates:!0});if(ae)throw ae;u.invalidateQueries({queryKey:["innercircle-contacts"]}),u.invalidateQueries({queryKey:["innercircle-contact-counts"]}),an({title:`Assigned type to ${R} contacts`}),r()}catch(de){an({title:"Error assigning type",description:de.message,variant:"destructive"})}finally{j(!1)}},q=async Y=>{j(!0);try{const de=Array.from(t);for(const ie of de)try{await _.mutateAsync({contactId:ie,tagId:Y})}catch{}u.invalidateQueries({queryKey:["all-contact-custom-tags"]}),an({title:`Tagged ${R} contacts`}),A(!1),L("")}catch(de){an({title:"Error adding tags",description:de.message,variant:"destructive"})}finally{j(!1)}},U=async()=>{if(I.trim()){j(!0);try{const Y=await v.mutateAsync({name:I.trim()});await q(Y.id)}catch(Y){an({title:"Error creating tag",description:Y.message,variant:"destructive"}),j(!1)}}},V=(g==null?void 0:g.filter(Y=>Y.name.toLowerCase().includes(I.toLowerCase())))||[],X=g==null?void 0:g.find(Y=>Y.name.toLowerCase()===I.trim().toLowerCase()),se=()=>{const Y=s.filter(ye=>t.has(ye.id)),de=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Notes","Relationship Types"],ie=Y.map(ye=>{var we;return[ye.first_name,ye.last_name||"",ye.email||"",ye.phone||"",ye.address||"",ye.birthday||"",ye.home_anniversary||"",ye.notes||"",((we=ye.tags)==null?void 0:we.map(Ne=>{var Ke;return(Ke=Ne.relationship_type)==null?void 0:Ke.name}).join("; "))||""]}),ae=[de.join(","),...ie.map(ye=>ye.map(we=>`"${(we||"").replace(/"/g,'""')}"`).join(","))].join(` `),le=new Blob([ae],{type:"text/csv"}),pe=URL.createObjectURL(le),be=document.createElement("a");be.href=pe,be.download=`contacts-export-${new Date().toISOString().slice(0,10)}.csv`,be.click(),URL.revokeObjectURL(pe),an({title:`Exported ${R} contacts`})},te=async()=>{if(confirm(`Are you sure you want to delete ${R} contacts? This cannot be undone.`)){j(!0);try{const Y=Array.from(t);for(const de of Y)await d.mutateAsync(de);r()}catch(Y){an({title:"Error deleting contacts",description:Y.message,variant:"destructive"})}finally{j(!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(at,{variant:"secondary",className:"font-semibold",children:[R," selected"]}),e.jsxs(tr,{onValueChange:$,disabled:b,children:[e.jsx(Js,{className:"w-[180px] h-8",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Im,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm",children:"Assign Type"})]})}),e.jsx(er,{children:i==null?void 0:i.filter(Y=>Y.active).map(Y=>e.jsx(At,{value:Y.id,children:Y.name},Y.id))})]}),e.jsxs(No,{open:C,onOpenChange:A,children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",disabled:b,children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"}),"Add Tag"]})}),e.jsxs(jo,{className:"w-56 p-2",align:"start",children:[e.jsx(Re,{placeholder:"Search or create tag...",value:I,onChange:Y=>L(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&I.trim()&&!X?(Y.preventDefault(),U()):Y.key==="Enter"&&X&&(Y.preventDefault(),q(X.id))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[V.map(Y=>e.jsxs("button",{onClick:()=>q(Y.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:Y.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:Y.name})]},Y.id)),I.trim()&&!X&&e.jsxs("button",{onClick:U,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 "',I.trim(),'"']}),V.length===0&&!I.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create a tag"})]})]})]}),p&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>N(!0),disabled:b,children:[e.jsx(br,{className:"h-3.5 w-3.5 mr-1"}),"Email"]}),a&&n&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>n(Array.from(t)),disabled:b,children:[e.jsx(qx,{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:b,children:[e.jsx(w0,{className:"h-3.5 w-3.5 mr-1"}),"Transfer"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:se,disabled:b,children:[e.jsx(gi,{className:"h-3.5 w-3.5 mr-1"}),"Export"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:te,disabled:b,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(TM,{open:w,onOpenChange:N,bulkContacts:Array.from(t).map(Y=>{const de=s.find(ie=>ie.id===Y);return de?{id:de.id,first_name:de.first_name,last_name:de.last_name,email:de.email||""}:null}).filter(Y=>Y!==null&&Y.email!==""),onSendComplete:()=>{N(!1),r()}})]})}function pEe({contact:t,onEdit:s,onDelete:r,onSnooze:n,onSendToLeadPond:a,showLeadPondAction:o,onTransfer:l,showTransferAction:i}){const d=Lr(),u=`${t.first_name} ${t.last_name||""}`.trim();return e.jsxs(yu,{children:[e.jsx(vu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:p=>p.stopPropagation(),children:e.jsx(ef,{className:"h-4 w-4"})})}),e.jsxs(Wd,{align:"end",onClick:p=>p.stopPropagation(),children:[e.jsxs(Da,{onClick:()=>d(`/mission-control/contacts/${t.id}?tab=activity&action=log`),children:[e.jsx(Zn,{className:"h-4 w-4 mr-2"}),"Log Touch"]}),e.jsxs(Da,{onClick:()=>d(`/mission-control/video?contactId=${t.id}`),children:[e.jsx(Nn,{className:"h-4 w-4 mr-2"}),"Send Video"]}),e.jsxs(Da,{onClick:()=>d(`/mission-control/popbys?contactId=${t.id}`),children:[e.jsx(Ti,{className:"h-4 w-4 mr-2"}),"Schedule Pop-by"]}),e.jsxs(Da,{onClick:()=>n(t.id,u),children:[e.jsx(fp,{className:"h-4 w-4 mr-2"}),"Snooze"]}),o&&a&&e.jsxs(Da,{onClick:()=>a(t.id),children:[e.jsx(qx,{className:"h-4 w-4 mr-2"}),"Send to Lead Pond"]}),i&&l&&e.jsxs(Da,{onClick:()=>l(t.id),children:[e.jsx(w0,{className:"h-4 w-4 mr-2"}),"Transfer to Team Member"]}),e.jsxs(Da,{onClick:()=>s(t),children:[e.jsx(Ua,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Da,{onClick:()=>r(t.id),className:"text-destructive focus:text-destructive",children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}function U7t(){const{user:t}=Gs();return Ct({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 V7t(){const t=ns(),{user:s}=Gs();return Ot({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"]}),an({title:"Smart filter saved"})},onError:r=>{an({title:"Error saving smart filter",description:r.message,variant:"destructive"})}})}function H7t(){const t=ns();return Ot({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"]}),an({title:"Smart filter deleted"})}})}function W7t({currentFilters:t,currentSortBy:s,onApplySmartList:r}){const{data:n}=U7t(),a=V7t(),o=H7t(),[l,i]=S.useState(!1),[d,u]=S.useState(""),p=t.search||t.type&&t.type!=="all"||t.status&&t.status!=="all",g=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(yu,{children:[e.jsx(vu,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(Ux,{className:"h-3.5 w-3.5"}),"Smart Filters",n&&n.length>0&&e.jsx(at,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:n.length}),e.jsx(Vo,{className:"h-3.5 w-3.5"})]})}),e.jsxs(Wd,{align:"start",className:"w-56",children:[n&&n.length>0?e.jsxs(e.Fragment,{children:[n.map(v=>e.jsxs(Da,{className:"flex items-center justify-between group",children:[e.jsx("span",{className:"flex-1 cursor-pointer",onClick:()=>r(v.filters,v.sort_by),children:v.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(v.id)},children:e.jsx(jr,{className:"h-3 w-3 text-destructive"})})]},v.id)),e.jsx(k_,{})]}):e.jsx(Da,{disabled:!0,className:"text-muted-foreground text-xs",children:"No saved filters yet"}),p&&e.jsxs(Da,{onClick:()=>i(!0),children:[e.jsx(YE,{className:"h-4 w-4 mr-2"}),"Save Current Filter"]})]})]}),e.jsx(vs,{open:l,onOpenChange:i,children:e.jsxs(ys,{className:"max-w-sm",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Save Smart Filter"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Re,{placeholder:"e.g. Buyers in 40205",value:d,onChange:v=>u(v.target.value),onKeyDown:v=>v.key==="Enter"&&g(),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:g,disabled:!d.trim()||a.isPending,children:"Save"})]})]})]})})]})}function PE(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 gEe({birthday:t,homeAnniversary:s,className:r,contactId:n,contactName:a,contactAddress:o}){const l=Lr(),i=fEe(t,"birthday",7),d=fEe(s,"anniversary",7);if(!i&&!d)return null;const u=(p,g)=>{g.stopPropagation();const v=new URLSearchParams;n&&v.set("contactId",n),a&&v.set("name",a),o&&v.set("address",o),p==="home_anniversary"&&s&&v.set("date",s),v.set("cardType",p),l(`/mission-control/card-studio?${v.toString()}`)};return e.jsxs("div",{className:Et("flex flex-wrap gap-1",r),children:[i&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(at,{variant:"secondary",className:Et("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(at,{variant:"secondary",className:Et("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 xEe({deal:t}){if(!t||!t.stage)return null;const{stage:s}=t;return e.jsxs(at,{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 G7t(){const t=si();return Ct({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 K7t({contactId:t,compact:s=!1}){const{data:r}=Mle(),{data:n}=R7t(t),a=_we(),o=xZe(),l=B7t(),[i,d]=S.useState(!1),[u,p]=S.useState(""),g=S.useRef(null),v=new Set((n==null?void 0:n.map(N=>N.tag_id))||[]),_=(r==null?void 0:r.filter(N=>N.name.toLowerCase().includes(u.toLowerCase())))||[],b=r==null?void 0:r.find(N=>N.name.toLowerCase()===u.trim().toLowerCase()),j=async N=>{v.has(N.id)?await l.mutateAsync({contactId:t,tagId:N.id}):await o.mutateAsync({contactId:t,tagId:N.id})},w=async()=>{if(!(!u.trim()||b))try{const N=await a.mutateAsync({name:u.trim()});await o.mutateAsync({contactId:t,tagId:N.id}),p("")}catch{}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n==null?void 0:n.map(N=>{var C,A,I;return e.jsxs(at,{variant:"outline",className:"text-xs gap-1 pr-1",style:{borderColor:((C=N.tag)==null?void 0:C.color)||"#6366F1",color:((A=N.tag)==null?void 0:A.color)||"#6366F1"},children:[e.jsx(Im,{className:"h-2.5 w-2.5"}),(I=N.tag)==null?void 0:I.name,e.jsx("button",{onClick:L=>{L.stopPropagation(),l.mutate({contactId:t,tagId:N.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"})})]},N.id)}),e.jsxs(No,{open:i,onOpenChange:d,children:[e.jsx(So,{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:N=>N.stopPropagation(),children:[e.jsx(Zs,{className:"h-3 w-3"}),!s&&e.jsx("span",{className:"ml-1",children:"Tag"})]})}),e.jsxs(jo,{className:"w-56 p-2",align:"start",onClick:N=>N.stopPropagation(),children:[e.jsx(Re,{ref:g,placeholder:"Search or create tag...",value:u,onChange:N=>p(N.target.value),onKeyDown:N=>{N.key==="Enter"&&u.trim()&&!b?(N.preventDefault(),w()):N.key==="Enter"&&b&&!v.has(b.id)&&(N.preventDefault(),j(b))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[_.map(N=>e.jsxs("button",{onClick:()=>j(N),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:N.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:N.name}),v.has(N.id)&&e.jsx(fa,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},N.id)),u.trim()&&!b&&e.jsxs("button",{onClick:w,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 yEe({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(at,{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 dR=["#6366F1","#8B5CF6","#EC4899","#EF4444","#F97316","#F59E0B","#10B981","#14B8A6","#06B6D4","#3B82F6","#6B7280","#1F2937"];function Z7t({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Mle(),a=_we(),o=z7t(),l=F7t(),[i,d]=S.useState(""),[u,p]=S.useState(dR[0]),[g,v]=S.useState(null),[_,b]=S.useState(""),[j,w]=S.useState(""),N=async()=>{if(i.trim())try{await a.mutateAsync({name:i.trim(),color:u}),d(""),p(dR[0]),an({title:"Tag created"})}catch(L){an({title:"Error",description:L.message,variant:"destructive"})}},C=async L=>{if(_.trim())try{await o.mutateAsync({id:L,name:_.trim(),color:j}),v(null),an({title:"Tag updated"})}catch(R){an({title:"Error",description:R.message,variant:"destructive"})}},A=async(L,R)=>{if(confirm(`Delete tag "${R}"? It will be removed from all contacts.`))try{await l.mutateAsync(L),an({title:"Tag deleted"})}catch($){an({title:"Error",description:$.message,variant:"destructive"})}},I=L=>{v(L.id),b(L.name),w(L.color)};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{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"&&N(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:N,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:dR.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:g===L.id?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:dR.map(R=>e.jsx("button",{onClick:()=>w(R),className:`h-5 w-5 rounded-full border-2 ${j===R?"border-foreground":"border-transparent"}`,style:{backgroundColor:R}},R))}),e.jsx(Re,{value:_,onChange:R=>b(R.target.value),onKeyDown:R=>R.key==="Enter"&&C(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:()=>C(L.id),children:e.jsx(fa,{className:"h-4 w-4 text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>v(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(Ua,{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:()=>A(L.id,L.name),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})},L.id))]})]})})}function yZe({value:t,onChange:s,label:r="Lead Source"}){const{data:n}=IL(),a=xVe(),[o,l]=S.useState(!1),[i,d]=S.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(tr,{value:t||"_none",onValueChange:p=>s(p==="_none"?"":p),children:[e.jsx(Js,{className:"flex-1",children:e.jsx(sr,{placeholder:"Select lead source"})}),e.jsxs(er,{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 uye({contactId:t,currentSpouseContactId:s,currentSpouseName:r,currentSpouseEmail:n,onLink:a,onUnlink:o,isEditing:l}){const i=Lr(),[d,u]=S.useState(!1),[p,g]=S.useState(""),{data:v}=Ct({queryKey:["innercircle-contact-spouse",s],queryFn:async()=>{const{data:b,error:j}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone, birthday").eq("id",s).maybeSingle();if(j)throw j;return b},enabled:!!s}),{data:_}=Ct({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:j,error:w}=await b;if(w)throw w;return j},enabled:d});if(s&&v){const b=`${v.first_name} ${v.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/${v.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:[v.phone,v.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(cN,{className:"h-3.5 w-3.5 mr-1"}),"Unlink"]}),!l&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>i(`/mission-control/contacts/${v.id}`),className:"shrink-0 h-7 px-2",children:e.jsx(Ui,{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(No,{open:d,onOpenChange:u,children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"shrink-0 h-7 px-2",children:[e.jsx(Ho,{className:"h-3.5 w-3.5 mr-1"}),"Link Contact"]})}),e.jsx(jo,{className:"w-72 p-2",align:"end",children:e.jsx(vEe,{search:p,setSearch:g,results:_,onSelect:b=>{a(b),u(!1),g("")}})})]})]})]}):l?e.jsxs("div",{className:"space-y-1",children:[e.jsx(ve,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs(No,{open:d,onOpenChange:u,children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full justify-start text-muted-foreground font-normal h-10",children:[e.jsx(Ho,{className:"h-4 w-4 mr-2"}),"Link an existing contact as spouse..."]})}),e.jsx(jo,{className:"w-72 p-2",align:"start",children:e.jsx(vEe,{search:p,setSearch:g,results:_,onSelect:b=>{a(b),u(!1),g("")}})})]})]}):null}function vEe({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(xn,{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(Fi,{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 Y7t(){var ta;const t=Lr(),[s]=Ac(),{user:r}=Gs(),n=AM(),a=ns(),o=s.get("type"),l=s.get("filter")??s.get("status"),i=s.get("new")==="true",{contactsWithScores:d,isLoading:u}=Qoe(),{data:p}=Ef(),{data:g}=G7t(),{data:v}=Mle(),{data:_}=$7t(),[b,j]=S.useState(new Set),[w,N]=S.useState("any"),C=Zoe(),A=ebe(),I=tbe(),L=eVe(),[R,$]=S.useState(""),[q,U]=S.useState(o||"all"),[V,X]=S.useState(l||"all"),[se,te]=S.useState("date-added"),[Y,de]=S.useState(i),[ie,ae]=S.useState(null),[le,pe]=S.useState(!1),[be,ye]=S.useState(!1),[we,Ne]=S.useState(null),[Ke,_e]=S.useState(""),[Me,Te]=S.useState(new Set),[Fe,Ae]=S.useState(!1),[Ue,ut]=S.useState(1),[De,Dt]=S.useState(50),[he,Ve]=S.useState("my"),[nt,Qe]=S.useState(!1),{data:ke}=Mf(),{addToLeadPond:ot}=gKe(ke==null?void 0:ke.teamId),qe=!!((ta=ke==null?void 0:ke.team)!=null&&ta.lead_pond_enabled&&(ke!=null&&ke.teamId)),lt=!!(ke!=null&&ke.teamId),[We,Ye]=S.useState([]),[mt,Ze]=S.useState(!1),He=Zt=>{Ye([Zt]),Ze(!0)},et=Zt=>{Ye(Zt),Ze(!0)},Rt=Zt=>{ke!=null&&ke.teamId&&ot.mutate({contact_id:Zt,team_id:ke.teamId})},qt=Zt=>{ke!=null&&ke.teamId&&Zt.forEach(vr=>{ot.mutate({contact_id:vr,team_id:ke.teamId})})},ls=S.useCallback(Zt=>{Ae(!1),Te(vr=>{const Gr=new Set(vr);return Gr.has(Zt)?Gr.delete(Zt):Gr.add(Zt),Gr})},[]);S.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]),S.useEffect(()=>{l&&X(l)},[l]);const[Kt,Qt]=S.useState({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]});S.useEffect(()=>{i&&de(!0)},[i]),S.useEffect(()=>{var Zt;ie&&Qt({first_name:ie.first_name||"",last_name:ie.last_name||"",email:ie.email||"",phone:ie.phone||"",address:ie.address||"",city:ie.city||"",state:ie.state||"",zip_code:ie.zip_code||"",birthday:ie.birthday||"",home_anniversary:ie.home_anniversary||"",spouse_name:ie.spouse_name||"",spouse_email:ie.spouse_email||"",lead_source_id:ie.lead_source_id||"",notes:ie.notes||"",tagIds:((Zt=ie.tags)==null?void 0:Zt.map(vr=>vr.relationship_type_id))||[]})},[ie]);const fs=S.useMemo(()=>{if(!d)return[];let Zt=d.filter(vr=>{var Ln,da,Va;const Gr=R===""||`${vr.first_name} ${vr.last_name}`.toLowerCase().includes(R.toLowerCase())||((Ln=vr.email)==null?void 0:Ln.toLowerCase().includes(R.toLowerCase()))||((da=vr.phone)==null?void 0:da.includes(R)),Rn=q==="all"||((Va=vr.tags)==null?void 0:Va.some(Jr=>Jr.relationship_type_id===q)),rs=b.size===0||(()=>{const Jr=(_==null?void 0:_.filter(Za=>Za.contact_id===vr.id).map(Za=>Za.tag_id))||[];return w==="any"?Jr.some(Za=>b.has(Za)):Array.from(b).every(Za=>Jr.includes(Za))})();return Gr&&Rn&&rs});return V==="not-touched-90"?Zt=Zt.filter(vr=>{const Gr=vr.relationshipScore.daysSinceTouch;return Gr===null||Gr>90}):V==="at-risk"?Zt=Zt.filter(vr=>vr.relationshipScore.status==="at-risk"):V==="cooling"?Zt=Zt.filter(vr=>vr.relationshipScore.status==="cooling"):V==="warm"?Zt=Zt.filter(vr=>vr.relationshipScore.status==="warm"):V==="has-deal"?Zt=Zt.filter(vr=>g&&g[vr.id]):V==="no-deal"?Zt=Zt.filter(vr=>!g||!g[vr.id]):V==="open-house"&&(Zt=Zt.filter(vr=>{var Rn;return(((Rn=vr.lead_source_ref)==null?void 0:Rn.name)||vr.lead_source)==="Open House"})),Zt=[...Zt].sort((vr,Gr)=>{switch(se){case"important-dates":{const Rn=PE(vr.birthday),rs=PE(Gr.birthday),Ln=PE(vr.home_anniversary),da=PE(Gr.home_anniversary),Va=[Rn,Ln].filter(Za=>Za!==null).sort((Za,$l)=>(Za??1/0)-($l??1/0))[0]??1/0,Jr=[rs,da].filter(Za=>Za!==null).sort((Za,$l)=>(Za??1/0)-($l??1/0))[0]??1/0;return Va-Jr}case"last-touched":{const Rn=vr.relationshipScore.lastTouchDate,rs=Gr.relationshipScore.lastTouchDate;return!Rn&&!rs?0:Rn?rs?new Date(Rn).getTime()-new Date(rs).getTime():1:-1}case"next-touch":{const Rn=vr.relationshipScore.daysSinceTouch,rs=Gr.relationshipScore.daysSinceTouch;return Rn===null&&rs===null?0:Rn===null?-1:rs===null?1:rs-Rn}case"score":return vr.relationshipScore.score-Gr.relationshipScore.score;case"date-added":{const Rn=vr.created_at,rs=Gr.created_at;return!Rn&&!rs?0:Rn?rs?new Date(rs).getTime()-new Date(Rn).getTime():-1:1}case"name":default:{const Rn=`${vr.first_name||""} ${vr.last_name||""}`.toLowerCase(),rs=`${Gr.first_name||""} ${Gr.last_name||""}`.toLowerCase();return Rn.localeCompare(rs)}}}),Zt},[d,R,q,b,w,V,se,g,_]),dr=fs.length,bt=Math.max(1,Math.ceil(dr/De)),ks=Math.min(Ue,bt),ir=S.useMemo(()=>{const Zt=(ks-1)*De;return fs.slice(Zt,Zt+De)},[fs,ks,De]);S.useEffect(()=>{ut(1)},[R,q,b,w,V,se]);const Rr=S.useCallback(()=>{Ae(!1),Te(Zt=>Zt.size>0?new Set:new Set(ir.map(vr=>vr.id)))},[ir]),ca=S.useCallback(()=>{Ae(!0),Te(new Set(fs.map(Zt=>Zt.id)))},[fs]),ii=S.useCallback((Zt,vr)=>{$(Zt.search||""),U(Zt.type||"all"),X(Zt.status||"all"),te(vr||"name")},[]),lo=()=>{Qt({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]})},Oa=async Zt=>{Zt.preventDefault();const vr={...Kt,lead_source_id:Kt.lead_source_id||null};ie?(await A.mutateAsync({id:ie.id,...vr}),ae(null)):(await C.mutateAsync(vr),de(!1)),lo()},yn=async Zt=>{confirm("Are you sure you want to delete this contact?")&&await I.mutateAsync(Zt)};return e.jsx(Ms,{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"})]}),ke&&e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsx("button",{onClick:()=>Ve("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${he==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Contacts"}),(ke.team.contact_visibility==="full_team"||ke.team.contact_visibility==="leader_only"&&ke.role==="team_leader")&&e.jsxs("button",{onClick:()=>Ve("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${he==="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"]}),ke.team.lead_pond_enabled&&e.jsxs("button",{onClick:()=>Ve("lead-pond"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${he==="lead-pond"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(qx,{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(Ol,{className:"h-4 w-4 mr-1"}),"Back"]})}),he==="team"?e.jsx(owe,{}):he==="lead-pond"&&ke?e.jsx(lwe,{teamId:ke.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:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 min-w-0",children:[e.jsx(xn,{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(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:()=>pe(!0),className:"shrink-0",children:[e.jsx(Xa,{className:"h-4 w-4 mr-1"}),"Import CSV"]}),e.jsxs(K,{variant:"outline",onClick:()=>ye(!0),className:"shrink-0",children:[e.jsx(L0,{className:"h-4 w-4 mr-1"}),"Import from Phone"]}),e.jsx(k7t,{})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(tr,{value:q,onValueChange:U,children:[e.jsx(Js,{className:"w-[145px] h-9 text-sm",children:e.jsx(sr,{placeholder:"Filter by type"})}),e.jsxs(er,{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))]})]}),v&&v.length>0&&e.jsxs(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"h-9 justify-start text-sm",children:[e.jsx(Im,{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(jo,{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:()=>N("any"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${w==="any"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"Any"}),e.jsx("button",{onClick:()=>N("all"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${w==="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:v.map(Zt=>{const vr=b.has(Zt.id);return e.jsxs("button",{onClick:()=>{j(Gr=>{const Rn=new Set(Gr);return Rn.has(Zt.id)?Rn.delete(Zt.id):Rn.add(Zt.id),Rn})},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(zo,{checked:vr,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:()=>j(new Set),children:"Clear tags"})]})})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",onClick:()=>Qe(!0),title:"Manage Tags",children:e.jsx(Fl,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs(tr,{value:V,onValueChange:X,children:[e.jsx(Js,{className:"w-[145px] h-9 text-sm",children:e.jsx(sr,{placeholder:"Filter by status"})}),e.jsxs(er,{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(tr,{value:se,onValueChange:te,children:[e.jsx(Js,{className:"w-[165px] h-9 text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vc,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(sr,{placeholder:"Sort by"})]})}),e.jsxs(er,{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(W7t,{currentFilters:{search:R,type:q,status:V},currentSortBy:se,onApplySmartList:ii})]})]})})}),e.jsx(q7t,{selectedIds:Me,contacts:fs,onClearSelection:()=>{Te(new Set),Ae(!1)},showLeadPondAction:qe,onSendToLeadPond:qt,showTransferAction:lt,onTransfer:et}),Me.size>0&&Me.size===ir.length&&!Fe&&dr>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 ",ir.length," contacts on this page are selected."]}),e.jsxs(K,{variant:"link",size:"sm",className:"h-auto p-0 font-semibold",onClick:ca,children:["Select all ",dr.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 ",dr.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..."}):fs.length===0?e.jsx(Ee,{className:"p-6 text-center text-muted-foreground",children:R||q!=="all"||V!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"}):ir.map(Zt=>{var Gr,Rn,rs;const{relationshipScore:vr}=Zt;return e.jsx(Ee,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{const Ln=new URLSearchParams;R&&Ln.set("search",R),q!=="all"&&Ln.set("type",q),V!=="all"&&Ln.set("filter",V);const da=Ln.toString();t(`/mission-control/contacts/${Zt.id}${da?`?${da}`:""}`)},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(qa,{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(Zn,{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(uI,{score:vr,size:"sm"}),e.jsx(dye,{contact:Zt}),(((Gr=Zt.lead_source_ref)==null?void 0:Gr.name)||Zt.lead_source)&&e.jsx(at,{variant:"outline",className:"text-xs gap-1 border-primary/30 text-primary",children:((Rn=Zt.lead_source_ref)==null?void 0:Rn.name)||Zt.lead_source}),(rs=Zt.tags)==null?void 0:rs.map(Ln=>{var da;return e.jsx(at,{variant:"secondary",className:"text-xs",children:(da=Ln.relationship_type)==null?void 0:da.name},Ln.id)}),e.jsx(yEe,{contactId:Zt.id,tags:_==null?void 0:_.filter(Ln=>Ln.contact_id===Zt.id)}),e.jsx(xEe,{deal:g==null?void 0:g[Zt.id]})]}),e.jsx(gEe,{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:[vr.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-3 w-3"}),ws(new Date(vr.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"}),ws(new Date(Zt.birthday),"MMM d")]}),Zt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Vn,{className:"h-3 w-3"}),ws(new Date(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 ",ws(new Date(Zt.created_at),"MMM d, yyyy")]})]})]}),e.jsx("div",{className:"ml-2",onClick:Ln=>Ln.stopPropagation(),children:e.jsx(pEe,{contact:Zt,onEdit:ae,onDelete:yn,onSnooze:(Ln,da)=>{Ne(Ln),_e(da)},showLeadPondAction:qe,onSendToLeadPond:Rt,showTransferAction:lt,onTransfer:He})})]})})},Zt.id)})}):e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0 overflow-x-auto",children:e.jsxs(Tn,{className:"min-w-[800px]",children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-[40px]",children:e.jsx(zo,{checked:ir.length>0&&ir.every(Zt=>Me.has(Zt.id)),onCheckedChange:()=>Rr()})}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Score"}),e.jsx(jt,{children:"Contact Info"}),e.jsx(jt,{children:"Types / Pipeline"}),e.jsx(jt,{children:"Last Contact"}),e.jsx(jt,{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(Vc,{className:"h-3 w-3"})]})}),e.jsx(jt,{children:"Important Dates"}),e.jsx(jt,{className:"w-[50px]",children:"Actions"})]})}),e.jsx(En,{children:u?e.jsx(js,{children:e.jsx(it,{colSpan:10,className:"text-center py-8",children:"Loading contacts..."})}):fs.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:R||q!=="all"||V!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"})}):ir.map(Zt=>{var Rn,rs,Ln;const{relationshipScore:vr}=Zt,Gr=g==null?void 0:g[Zt.id];return e.jsxs(js,{className:`cursor-pointer hover:bg-accent/50 ${Me.has(Zt.id)?"bg-accent/30":""}`,onClick:()=>{const da=new URLSearchParams;R&&da.set("search",R),q!=="all"&&da.set("type",q),V!=="all"&&da.set("status",V);const Va=da.toString();t(`/mission-control/contacts/${Zt.id}${Va?`?${Va}`:""}`)},children:[e.jsx(it,{onClick:da=>da.stopPropagation(),children:e.jsx(zo,{checked:Me.has(Zt.id),onCheckedChange:()=>ls(Zt.id)})}),e.jsxs(it,{className:"font-medium",children:[Zt.first_name," ",Zt.last_name]}),e.jsx(it,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(uI,{score:vr,size:"sm"}),e.jsx(dye,{contact:Zt})]})}),e.jsx(it,{children:e.jsx(uI,{score:vr,size:"sm",showScore:!0})}),e.jsx(it,{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(Zn,{className:"h-3 w-3"}),Zt.phone]})]})}),e.jsx(it,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(((Rn=Zt.lead_source_ref)==null?void 0:Rn.name)||Zt.lead_source)&&e.jsx(at,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((rs=Zt.lead_source_ref)==null?void 0:rs.name)||Zt.lead_source}),(Ln=Zt.tags)==null?void 0:Ln.map(da=>{var Va;return e.jsx(at,{variant:"secondary",className:"text-xs",children:(Va=da.relationship_type)==null?void 0:Va.name},da.id)}),e.jsx(yEe,{contactId:Zt.id,tags:_==null?void 0:_.filter(da=>da.contact_id===Zt.id)}),e.jsx(xEe,{deal:Gr})]})}),e.jsx(it,{children:e.jsx("div",{className:"text-sm",children:vr.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(In,{className:"h-3 w-3"}),ws(new Date(vr.lastTouchDate),"MMM d, yyyy")]}):e.jsx("span",{className:"text-muted-foreground text-xs italic",children:"Never contacted"})})}),e.jsx(it,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:Zt.created_at?ws(new Date(Zt.created_at),"MMM d, yyyy"):"—"})}),e.jsx(it,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(gEe,{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"}),ws(new Date(Zt.birthday),"MMM d")]}),Zt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Vn,{className:"h-3 w-3"}),ws(new Date(Zt.home_anniversary),"MMM d")]})]})]})}),e.jsx(it,{children:e.jsx(pEe,{contact:Zt,onEdit:ae,onDelete:yn,onSnooze:(da,Va)=>{Ne(da),_e(Va)},showLeadPondAction:qe,onSendToLeadPond:Rt,showTransferAction:lt,onTransfer:He})})]},Zt.id)})})]})})}),dr>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 ",(ks-1)*De+1,"–",Math.min(ks*De,dr)," of ",dr.toLocaleString()," contacts"]}),e.jsxs(tr,{value:String(De),onValueChange:Zt=>{Dt(Number(Zt)),ut(1)},children:[e.jsx(Js,{className:"w-[80px] h-8",children:e.jsx(sr,{})}),e.jsxs(er,{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:ks<=1,onClick:()=>ut(1),children:"First"}),e.jsx(K,{variant:"outline",size:"sm",disabled:ks<=1,onClick:()=>ut(Zt=>Zt-1),children:e.jsx(Ol,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",ks," of ",bt]}),e.jsx(K,{variant:"outline",size:"sm",disabled:ks>=bt,onClick:()=>ut(Zt=>Zt+1),children:e.jsx(qa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",disabled:ks>=bt,onClick:()=>ut(bt),children:"Last"})]})]}),e.jsx(vs,{open:Y||!!ie,onOpenChange:Zt=>{Zt||(de(!1),ae(null),lo())},children:e.jsxs(ys,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:ie?"Edit Contact":"Add Contact"})}),e.jsxs("form",{onSubmit:Oa,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:Kt.first_name,onChange:Zt=>Qt({...Kt,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:Kt.last_name,onChange:Zt=>Qt({...Kt,last_name:Zt.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",value:Kt.email,onChange:Zt=>Qt({...Kt,email:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone"}),e.jsx(Re,{id:"phone",value:Kt.phone,onChange:Zt=>Qt({...Kt,phone:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"address",children:"Address"}),e.jsx(Re,{id:"address",value:Kt.address,onChange:Zt=>Qt({...Kt,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:Kt.city,onChange:Zt=>Qt({...Kt,city:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"state",children:"State"}),e.jsx(Re,{id:"state",value:Kt.state,onChange:Zt=>Qt({...Kt,state:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"zip_code",children:"Zip"}),e.jsx(Re,{id:"zip_code",value:Kt.zip_code,onChange:Zt=>Qt({...Kt,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:Kt.birthday,onChange:Zt=>Qt({...Kt,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:Kt.home_anniversary,onChange:Zt=>Qt({...Kt,home_anniversary:Zt.target.value})})]})]}),ie&&e.jsx(uye,{contactId:ie.id,currentSpouseContactId:(ie==null?void 0:ie.spouse_contact_id)||null,currentSpouseName:(ie==null?void 0:ie.spouse_name)||null,currentSpouseEmail:(ie==null?void 0:ie.spouse_email)||null,onLink:Zt=>L.mutate({contactId:ie.id,spouseContactId:Zt}),onUnlink:()=>L.mutate({contactId:ie.id,spouseContactId:null}),isEditing:!0}),e.jsx(yZe,{value:Kt.lead_source_id,onChange:Zt=>Qt({...Kt,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(zo,{checked:Kt.tagIds.includes(Zt.id),onCheckedChange:vr=>{Qt(vr?{...Kt,tagIds:[...Kt.tagIds,Zt.id]}:{...Kt,tagIds:Kt.tagIds.filter(Gr=>Gr!==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(Tr,{id:"notes",value:Kt.notes,onChange:Zt=>Qt({...Kt,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),lo()},children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:C.isPending||A.isPending,children:[ie?"Update":"Create"," Contact"]})]})]})]})}),e.jsx(I7t,{open:le,onOpenChange:pe,relationshipTypes:(p==null?void 0:p.filter(Zt=>Zt.active))||[],onSuccess:()=>{pe(!1)}}),e.jsx(O7t,{open:be,onOpenChange:ye,onComplete:()=>ye(!1)}),e.jsx(Sle,{open:!!we,onOpenChange:Zt=>{Zt||Ne(null)},contactId:we||"",contactName:Ke}),e.jsx(Z7t,{open:nt,onOpenChange:Qe}),e.jsx(xKe,{open:mt,onOpenChange:Ze,contactIds:We,contactNames:We.map(Zt=>{const vr=fs.find(Gr=>Gr.id===Zt);return vr?`${vr.first_name} ${vr.last_name||""}`.trim():""}),onComplete:()=>{Ye([]),Te(new Set),Ae(!1)}})]})]})})}function X7t(){return Ct({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 Q7t(t){return Ct({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 J7t(){const{user:t}=Gs();return Ct({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 eBt(){const{user:t}=Gs(),s=ns();return Ot({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 tBt(t){const{user:s}=Gs();return Ct({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 sBt(t){return Ct({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 nS(){const{user:t}=Gs(),s=ns();return Ot({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 rBt(){const t=ns();return Ot({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 nBt(){const t=ns();return Ot({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 Tle(){const{user:t}=Gs();return Ct({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 vZe(){const{data:t,isLoading:s}=Tle(),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 GL(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 KL(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 C3(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 aBt(){const{user:t}=Gs(),s=ns();return Ot({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 iBt(t){return Ct({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 oBt(t){return Ct({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 bwe(){const t=si(),s=ns();return Ot({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 ZL(){const t=ns();return Ot({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 lBt(){const t=ns();return Ot({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 cBt(){const t=ns();return Ot({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 dBt(){const t=ns();return Ot({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 _Ze(){const t=ns();return Ot({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 uBt(){const t=si();return Ct({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 hBt(){const t=si(),s=ns();return Ot({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 mBt(){const t=ns();return Ot({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 pBt(){const t=ns();return Ot({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 R0(t){const s=window.location.hostname;return s==="localhost"||s.includes("lovable.app")?`${window.location.origin}/portal/${t}`:`https://clients.relevelup.com/${t}`}function fBt({contactId:t}){const s=Lr(),r=ns(),[n,a]=S.useState(null),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(""),[g,v]=S.useState(""),[_,b]=S.useState(null),j=ZL(),w=_Ze(),{data:N,isLoading:C}=Ct({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 V=q.map(te=>te.id),{data:X,error:se}=await G.from("client_portals").select("*").in("deal_id",V).is("archived_at",null);if(se)throw se;return(X||[]).map(te=>({...te,deal:q.find(Y=>Y.id===te.deal_id)}))},enabled:!!t}),A=(N==null?void 0:N.map(q=>q.id))||[],{data:I}=Ct({queryKey:["contact-portal-updates",A],queryFn:async()=>{if(A.length===0)return{};const{data:q,error:U}=await G.from("portal_updates").select("*").in("portal_id",A).order("created_at",{ascending:!1});if(U)throw U;const V={};return(q||[]).forEach(X=>{V[X.portal_id]||(V[X.portal_id]=X)}),V},enabled:A.length>0}),L=q=>{navigator.clipboard.writeText(R0(q)),a(q),fe.success("Portal link copied!"),setTimeout(()=>a(null),2e3)},R=async q=>{u.trim()&&(await w.mutateAsync({portal_id:q,title:u,content:g||void 0}),d(!1),p(""),v(""),r.invalidateQueries({queryKey:["contact-portal-updates"]}),fe.success("Portal update posted!"))},$=async()=>{_&&(await j.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 C||!N||N.length===0?null:e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Am,{className:"h-4 w-4"}),"Client Portal"]})}),e.jsx(Oe,{className:"space-y-3",children:N.map(q=>{var se,te,Y;const U=((se=q.stage_mapping)==null?void 0:se.length)>0?q.stage_mapping:t_e(((te=q.deal)==null?void 0:te.deal_type)||"buyer"),V=U==null?void 0:U[q.current_stage_index??0],X=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:((Y=q.deal)==null?void 0:Y.deal_name)||"Portal"}),V&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Stage: ",V.label||V.name]})]}),e.jsx(at,{variant:q.is_enabled?"default":"secondary",className:"text-[10px] flex-shrink-0",children:q.is_enabled?"Active":"Disabled"})]}),X&&e.jsxs("div",{className:"bg-muted/50 rounded-md p-2",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:X.title}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:ws(new Date(X.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(fa,{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(R0(q.slug),"_blank"),children:[e.jsx(rn,{className:"h-3 w-3 mr-1"}),"View"]}),e.jsxs(vs,{open:i,onOpenChange:d,children:[e.jsx(Ai,{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(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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(Tr,{value:g,onChange:de=>v(de.target.value),placeholder:"Add more details...",rows:3})]}),e.jsxs(K,{onClick:()=>R(q.id),disabled:!u.trim()||w.isPending,className:"w-full",children:[e.jsx(Ta,{className:"h-4 w-4 mr-1"}),"Post Update"]})]})]})]}),e.jsxs(vs,{open:o,onOpenChange:l,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{b({...q}),l(!0)},children:[e.jsx(Fl,{className:"h-3 w-3 mr-1"}),"Settings"]})}),e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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(Tr,{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(sc,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:$,disabled:j.isPending,className:"flex-1",children:"Save Settings"}),e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/pipeline?deal=${q.deal_id}`),children:[e.jsx(Ui,{className:"h-4 w-4 mr-1"}),"Full Settings"]})]})]})]})]})]}),N.length>1&&e.jsx(sc,{})]},q.id)})})]})}function gBt({videoId:t}){var l;const{data:s,isLoading:r,error:n}=sBt(t);if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(gs,{className:"w-full aspect-video rounded-lg"}),e.jsx(gs,{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(Mh,{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 xBt({contactId:t}){const s=Lr(),[r,n]=S.useState(!1),{data:a,isLoading:o}=Ct({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:g,error:v}=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(v)throw v;return g},enabled:!!t}),l=async(g,v)=>{const _=v==="done"?"todo":"done";await G.from("deal_tasks").update({status:_,completed_at:_==="done"?new Date().toISOString():null}).eq("id",g),window.dispatchEvent(new CustomEvent("refetch-contact-tasks"))},{refetch:i}=Ct({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:g,error:v}=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(v)throw v;return g},enabled:!!t}),d={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"},u=(a==null?void 0:a.filter(g=>g.status!=="done"))||[],p=(a==null?void 0:a.filter(g=>g.status==="done"))||[];return e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(fa,{className:"h-4 w-4"}),"Tasks",u.length>0&&e.jsx(at,{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(gs,{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(g=>e.jsxs("button",{onClick:async()=>{await l(g.id,g.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[g.priority]," ",g.title]}),g.due_date&&e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ws(new Date(g.due_date),"MMM d")})]},g.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(yBt,{contactId:t,open:r,onOpenChange:g=>{n(g),g||i()}})]})}function yBt({contactId:t,open:s,onOpenChange:r}){const[n,a]=S.useState(""),[o,l]=S.useState("medium"),[i,d]=S.useState(),{data:u}=Ct({queryKey:["session"],queryFn:async()=>{const{data:g}=await G.auth.getSession();return g.session}}),p=async()=>{var v;if(!n.trim()||!((v=u==null?void 0:u.user)!=null&&v.id))return;const{error:g}=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?ws(i,"yyyy-MM-dd"):null}]);if(g){console.error("Task create error:",g);return}r(!1)};return e.jsx(vs,{open:s,onOpenChange:r,children:e.jsxs(ys,{className:"sm:max-w-[400px]",children:[e.jsx(Cs,{children:e.jsx(Ss,{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:g=>a(g.target.value),placeholder:"Task title...",onKeyDown:g=>g.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:g=>l(g.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?ws(i,"yyyy-MM-dd"):"",onChange:g=>d(g.target.value?new Date(g.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 vBt({contactId:t}){const s=Lr(),{data:r,isLoading:n}=Ct({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(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(eh,{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(at,{variant:"outline",className:"text-[10px] capitalize",children:a.deal_type}),o&&e.jsxs(at,{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(Ui,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors flex-shrink-0"})]})},a.id)})})]})}function _Bt(){var qe,lt,We,Ye,mt;const{contactId:t}=Co(),s=Lr(),[r]=Ac(),n=r.get("search")||"",a=r.get("type")||"all",o=r.get("status")||"all",{data:l,isLoading:i}=V4t(t||""),{data:d}=Ef(),{data:u}=EL(),{data:p}=PL(365),{data:g}=Cle(365),{data:v}=iBt(t),{contactsWithScores:_}=Qoe(),b=ebe(),j=tbe(),w=sbe(),N=eVe(),[C,A]=S.useState(!1),[I,L]=S.useState({}),[R,$]=S.useState(!1),[q,U]=S.useState(null),[V,X]=S.useState(""),[se,te]=S.useState(void 0),[Y,de]=S.useState(""),[ie,ae]=S.useState(null),[le,pe]=S.useState(!1),[be,ye]=S.useState(null),{isGmailConnected:we,gmailEmail:Ne}=py(),{data:Ke}=Ct({queryKey:["gmail-sent-emails",t],queryFn:async()=>{const{data:Ze,error:He}=await G.from("gmail_sent_emails").select("*").eq("contact_id",t).order("sent_at",{ascending:!1});if(He)throw He;return Ze},enabled:!!t}),_e=Ze=>{if(!Ze)return null;const He=Ze.match(/Video ID:\s*([a-f0-9-]+)/i);return He?He[1]:null},Me=S.useMemo(()=>{if(!_)return[];let Ze=_.filter(He=>{var qt,ls,Kt;const et=n===""||`${He.first_name} ${He.last_name}`.toLowerCase().includes(n.toLowerCase())||((qt=He.email)==null?void 0:qt.toLowerCase().includes(n.toLowerCase()))||((ls=He.phone)==null?void 0:ls.includes(n)),Rt=a==="all"||((Kt=He.tags)==null?void 0:Kt.some(Qt=>Qt.relationship_type_id===a));return et&&Rt});return o==="not-touched-90"?Ze=Ze.filter(He=>{const et=He.relationshipScore.daysSinceTouch;return et===null||et>90}):o==="at-risk"?Ze=Ze.filter(He=>He.relationshipScore.status==="at-risk"):o==="cooling"?Ze=Ze.filter(He=>He.relationshipScore.status==="cooling"):o==="warm"&&(Ze=Ze.filter(He=>He.relationshipScore.status==="warm")),Ze.map(He=>He.id)},[_,n,a,o]),Te=Me.indexOf(t||""),Fe=Te>0?Me[Te-1]:null,Ae=Te1&&Te!==-1,ut=Ze=>{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/${Ze}${et?`?${et}`:""}`},De=S.useMemo(()=>{const Ze=((p==null?void 0:p.filter(et=>et.contact_id===t))||[]).map(et=>{var Kt,Qt,fs;const Rt=_e(et.notes);let qt=((Kt=et.action_type)==null?void 0:Kt.name)||"Touch",ls=et.notes;if(qt==="Other"&&((Qt=et.notes)!=null&&Qt.startsWith("["))){const dr=et.notes.indexOf("]");dr>0&&(qt=et.notes.substring(1,dr),ls=et.notes.substring(dr+1).replace(/^\s*—\s*/,"").trim()||null)}return{id:et.id,type:"touch",completed_at:et.completed_at,name:qt,color:((fs=et.action_type)==null?void 0:fs.color)||"#3B82F6",notes:ls,videoId:Rt}}),He=((g==null?void 0:g.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[...Ze,...He].sort((et,Rt)=>new Date(Rt.completed_at).getTime()-new Date(et.completed_at).getTime())},[p,g,t]),Dt=()=>{var Ze;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:((Ze=l.tags)==null?void 0:Ze.map(He=>He.relationship_type_id))||[]}),A(!0))},he=async()=>{await b.mutateAsync({id:t,...I,lead_source_id:I.lead_source_id||null}),A(!1)},Ve=async()=>{confirm("Are you sure you want to delete this contact?")&&(await j.mutateAsync(t),s("/mission-control/contacts"))},Qe=((qe=u==null?void 0:u.find(Ze=>Ze.id===q))==null?void 0:qe.name)==="Other",ke=async()=>{if(!q||Qe&&!Y.trim())return;const Ze=se?new Date(se.getFullYear(),se.getMonth(),se.getDate(),12,0,0).toISOString():void 0,He=Qe?`[${Y.trim()}]${V?" — "+V:""}`:V;await w.mutateAsync({contactId:t,actionTypeId:q,notes:He,completedAt:Ze}),$(!1),U(null),X(""),te(void 0),de("")},ot=(Ze,He)=>{we&&l?(ye({email:Ze,name:He||`${l.first_name} ${l.last_name||""}`.trim()}),pe(!0)):window.location.href=`mailto:${Ze}`};return i?e.jsx(Ms,{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(Ms,{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(Ol,{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(Ol,{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(qa,{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:()=>ot(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(vs,{open:R,onOpenChange:$,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Log Action"]})}),e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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(Ze=>Ze.active).map(Ze=>e.jsxs("button",{onClick:()=>U(Ze.id),className:` p-3 rounded-lg border text-left transition-all ${q===Ze.id?"border-primary bg-primary/10":"hover:bg-accent"} `,children:[e.jsx("div",{className:"font-medium",children:Ze.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:Ze.description})]},Ze.id))}),Qe&&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:Y,onChange:Ze=>de(Ze.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(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Et("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?ws(se,"PPP"):"Today (default)"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(vp,{mode:"single",selected:se,onSelect:te,disabled:Ze=>Ze>new Date,initialFocus:!0,className:Et("p-3 pointer-events-auto")})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"action-notes",children:"Notes (optional)"}),e.jsx(Tr,{id:"action-notes",value:V,onChange:Ze=>X(Ze.target.value),placeholder:"Add any notes about this interaction...",rows:3})]}),e.jsxs(K,{onClick:ke,disabled:!q||Qe&&!Y.trim()||w.isPending,className:"w-full",children:[e.jsx(fa,{className:"h-4 w-4 mr-1"}),"Complete Action"]})]})]})]}),e.jsxs(K,{variant:"outline",onClick:Dt,children:[e.jsx(Dc,{className:"h-4 w-4 mr-1"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:Ve,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||""]}),(((lt=l.lead_source_ref)==null?void 0:lt.name)||l.lead_source)&&e.jsx(at,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((We=l.lead_source_ref)==null?void 0:We.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:()=>ot(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(Zn,{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(dye,{contact:l}),(Ye=l.tags)==null?void 0:Ye.map(Ze=>{const He=d==null?void 0:d.find(et=>et.id===Ze.relationship_type_id);return He?e.jsx(at,{variant:"secondary",className:"text-xs",children:He.name},Ze.id):null})]}),e.jsx("div",{className:"mt-2",children:e.jsx(K7t,{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(Lt,{children:e.jsx(zt,{children:"Contact Information"})}),e.jsx(Oe,{children:C?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:Ze=>L({...I,first_name:Ze.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:Ze=>L({...I,last_name:Ze.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"email",children:"Email"}),e.jsx(Re,{id:"email",type:"email",value:I.email,onChange:Ze=>L({...I,email:Ze.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"phone",children:"Phone"}),e.jsx(Re,{id:"phone",value:I.phone,onChange:Ze=>L({...I,phone:Ze.target.value})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"address",children:"Street Address"}),e.jsx(Re,{id:"address",value:I.address,onChange:Ze=>L({...I,address:Ze.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:Ze=>L({...I,city:Ze.target.value}),placeholder:"City"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"state",children:"State"}),e.jsx(Re,{id:"state",value:I.state,onChange:Ze=>L({...I,state:Ze.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:Ze=>L({...I,zip_code:Ze.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:Ze=>L({...I,birthday:Ze.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:Ze=>L({...I,home_anniversary:Ze.target.value})})]})]}),e.jsx(sc,{}),e.jsx(uye,{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:Ze=>N.mutate({contactId:t,spouseContactId:Ze}),onUnlink:()=>N.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:Ze=>L({...I,company_name:Ze.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:Ze=>L({...I,job_title:Ze.target.value}),placeholder:"Enter job title"})]})]}),e.jsx(yZe,{value:I.lead_source_id||"",onChange:Ze=>L({...I,lead_source_id:Ze})}),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(Ze=>Ze.active).map(Ze=>{var He;return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(zo,{checked:(He=I.tagIds)==null?void 0:He.includes(Ze.id),onCheckedChange:et=>{var Rt;L(et?{...I,tagIds:[...I.tagIds||[],Ze.id]}:{...I,tagIds:(Rt=I.tagIds)==null?void 0:Rt.filter(qt=>qt!==Ze.id)})}}),e.jsx("span",{className:"text-sm",children:Ze.name})]},Ze.id)})})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"notes",children:"Notes"}),e.jsx(Tr,{id:"notes",value:I.notes,onChange:Ze=>L({...I,notes:Ze.target.value}),rows:4})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:he,disabled:b.isPending,children:"Save Changes"}),e.jsx(K,{variant:"outline",onClick:()=>A(!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:"})," ",ws(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:()=>ot(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(Zn,{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(Ti,{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: ",ws(new Date(l.birthday),"MMMM d")]})]}),l.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Home Anniversary: ",ws(new Date(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: ",ws(new Date(l.created_at),"MMMM d, yyyy")]})]})]}),e.jsx(sc,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(uye,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:l.spouse_name||null,currentSpouseEmail:l.spouse_email||null,onLink:Ze=>N.mutate({contactId:t,spouseContactId:Ze}),onUnlink:()=>N.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(Ca,{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(sc,{}),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:(mt=l.tags)!=null&&mt.length?l.tags.map(Ze=>{var He;return e.jsx(at,{variant:"secondary",children:(He=Ze.relationship_type)==null?void 0:He.name},Ze.id)}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No relationship types assigned"})})]}),l.notes&&e.jsxs(e.Fragment,{children:[e.jsx(sc,{}),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(T7t,{contact:l,onLogTouch:()=>$(!0)}),e.jsx(vBt,{contactId:t}),e.jsx(fBt,{contactId:t}),e.jsx(xBt,{contactId:t}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Activity Log"})}),e.jsx(Oe,{children:De.length>0?e.jsx("div",{className:"space-y-4",children:De.map(Ze=>{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:Ze.color},children:Ze.type==="popby"?e.jsx(ao,{className:"h-4 w-4"}):(He=Ze.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:Ze.name}),Ze.videoId&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>ae(Ze.videoId),children:[e.jsx(dl,{className:"h-3 w-3 mr-1"}),"Preview"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ws(new Date(Ze.completed_at),"MMM d, yyyy h:mm a")}),Ze.notes&&!Ze.videoId&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Ze.notes})]})]},Ze.id)})}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"})})]}),v&&v.length>0&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{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:v.map(Ze=>{var He,et;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[(He=Ze.video)!=null&&He.thumbnail_url?e.jsx("img",{src:Ze.video.thumbnail_url,alt:Ze.video.title||"Video",className:"h-12 w-16 object-cover rounded cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>ae(Ze.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(Ze.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=Ze.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(Ze.video_id),children:[e.jsx(dl,{className:"h-3 w-3 mr-1"}),"Watch"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ws(new Date(Ze.created_at),"MMM d, yyyy h:mm a")}),Ze.message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:['"',Ze.message,'"']})]})]},Ze.id)})})})]}),Ke&&Ke.length>0&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-5 w-5 text-sky-500"}),"Sent Emails"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:Ke.map(Ze=>e.jsxs(vs,{children:[e.jsx(Ai,{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:Ze.subject}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["To: ",Ze.to_email," · ",ws(new Date(Ze.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx(qa,{className:"h-4 w-4 text-muted-foreground mt-1 flex-shrink-0"})]})}),e.jsxs(ys,{className:"max-w-2xl max-h-[85vh] flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5 text-sky-500"}),Ze.subject]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["To: ",Ze.to_email," · ",ws(new Date(Ze.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:Ze.body,className:"w-full h-[400px] border-0",sandbox:"",title:`Email: ${Ze.subject}`})})]})]},Ze.id))})})]})]}),e.jsx(vs,{open:!!ie,onOpenChange:Ze=>!Ze&&ae(null),children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Video Preview"})}),ie&&e.jsx(gBt,{videoId:ie})]})})]})]})}),we&&l&&be&&e.jsx(TM,{open:le,onOpenChange:pe,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:be.email},gmailEmail:Ne})]}):e.jsx(Ms,{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 _Ee={Crown:zh,FileText:Sn,Users:hr,Globe:Am,Star:Gn,Phone:Zn,MessageSquare:io,PenTool:s_,Video:Nn,Gift:ao},Yme=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function bBt(){var mt,Ze;const t=Lr(),{user:s}=Gs(),{data:r}=Ef(),{data:n}=W4t(),{data:a}=J4t(),{data:o}=JUe(),{data:l}=EL(),{data:i}=H4t(),d=e5t(),u=G4t(),p=Z4t(),g=Y4t(),v=X4t(),_=Q4t(),b=K4t(),[j,w]=S.useState(null),[N,C]=S.useState(!1),[A,I]=S.useState(null),[L,R]=S.useState(""),[$,q]=S.useState(""),[U,V]=S.useState([]),[X,se]=S.useState(null),[te,Y]=S.useState(null),[de,ie]=S.useState(!1),[ae,le]=S.useState(""),[pe,be]=S.useState(""),[ye,we]=S.useState(""),[Ne,Ke]=S.useState(""),_e=(He,et)=>a==null?void 0:a.some(Rt=>Rt.plan_id===He&&Rt.relationship_type_id===et&&Rt.active),Me=He=>a==null?void 0:a.find(et=>et.relationship_type_id===He&&et.active),Te=async(He,et)=>{const Rt=_e(He,et);await d.mutateAsync({planId:He,relationshipTypeId:et,active:!Rt})},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===j),ut=j?Me(j):null,De=n==null?void 0:n.find(He=>He.id===(ut==null?void 0:ut.plan_id)),Dt=async()=>{if(!L.trim())return;const He=await u.mutateAsync({name:L,description:$});He&&U.length>0&&await v.mutateAsync({planId:He.id,items:U}),nt()},he=async()=>{!L.trim()||!A||(await p.mutateAsync({id:A,name:L,description:$}),await v.mutateAsync({planId:A,items:U}),nt())},Ve=He=>{var et;I(He.id),R(He.name),q(He.description||""),V(((et=He.items)==null?void 0:et.map(Rt=>({month_number:Rt.month_number,action_type_id:Rt.action_type_id,default_script_id:Rt.default_script_id||void 0,notes:Rt.notes||void 0})))||[]),C(!0)},nt=()=>{C(!1),I(null),R(""),q(""),V([])},Qe=(He,et)=>{Y(et)},ke=(He,et,Rt)=>{V(qt=>[...qt.filter(Kt=>Kt.month_number!==He),{month_number:He,action_type_id:et,default_script_id:Rt}]),se(null),Y(null)},ot=He=>{V(et=>et.filter(Rt=>Rt.month_number!==He))},qe=async()=>{if(!ae.trim()||!pe.trim()||!te)return;const He=await _.mutateAsync({actionTypeId:te,title:ae,scriptBody:pe,emailSubject:ye||void 0,tone:Ne||void 0});He&&X!==null&&ke(X,te,He.id),ie(!1),le(""),be(""),we(""),Ke("")},lt=te?i==null?void 0:i.filter(He=>He.action_type_id===te&&He.active):[],We=He=>_Ee[He||"Phone"]||Zn,Ye=He=>_Ee[He||"Users"]||hr;return e.jsxs(Ms,{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(Ol,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs(K,{onClick:()=>C(!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=Ye(He.icon),Rt=(o==null?void 0:o[He.id])||0,qt=Me(He.id),ls=n==null?void 0:n.find(Qt=>Qt.id===(qt==null?void 0:qt.plan_id)),Kt=j===He.id;return e.jsxs("button",{onClick:()=>w(He.id),className:` w-full flex items-center gap-3 p-4 rounded-lg border text-left transition-all ${Kt?"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:[Rt," contacts"]})]}),ls?e.jsxs(at,{variant:"secondary",className:"text-xs",children:[e.jsx(fi,{className:"h-3 w-3 mr-1"}),ls.name.split(" ")[0]]}):e.jsx(at,{variant:"outline",className:"text-xs text-muted-foreground",children:"No plan"})]},He.id)})]}),e.jsx("div",{className:"lg:col-span-2",children:j&&Ue?e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[(()=>{const He=Ye(Ue.icon);return e.jsx(He,{className:"h-5 w-5"})})(),Ue.name," Touchpoint Plan"]}),e.jsxs(yr,{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(fi,{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,j),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:Yme.map((He,et)=>{var Kt,Qt;const Rt=((Kt=De.items)==null?void 0:Kt.filter(fs=>fs.month_number===et+1))||[],qt=(Qt=Rt[0])==null?void 0:Qt.action_type,ls=qt?We(qt.icon):null;return e.jsxs("div",{className:` p-2 rounded border text-center ${Rt.length>0?"bg-primary/10 border-primary":"bg-muted"} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:He}),ls&&e.jsx(ls,{className:"h-4 w-4 mx-auto mt-1",style:{color:(qt==null?void 0:qt.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 Rt;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:[((Rt=He.items)==null?void 0:Rt.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 qt=`${He.name} (Copy)`;b.mutate({sourcePlanId:He.id,newName:qt})},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,j),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 Rt;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:[((Rt=He.items)==null?void 0:Rt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Edit plan",onClick:()=>Ve(He),children:e.jsx(Ax,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",title:"Delete plan",onClick:()=>g.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,j),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(vs,{open:N,onOpenChange:He=>{He?C(!0):nt()},children:e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:A?"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(Tr,{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:Yme.map((He,et)=>{const Rt=et+1,qt=U.find(Qt=>Qt.month_number===Rt),ls=qt?l==null?void 0:l.find(Qt=>Qt.id===qt.action_type_id):null,Kt=ls?We(ls.icon):null;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>se(X===Rt?null:Rt),className:` w-full p-3 rounded-lg border text-center transition-all ${qt?"bg-primary/10 border-primary":"bg-muted hover:bg-accent"} ${X===Rt?"ring-2 ring-primary":""} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:He}),Kt?e.jsx(Kt,{className:"h-5 w-5 mx-auto mt-1",style:{color:(ls==null?void 0:ls.color)||"#3B82F6"}}):e.jsx(Zs,{className:"h-5 w-5 mx-auto mt-1 text-muted-foreground/50"})]}),qt&&e.jsx("button",{type:"button",onClick:Qt=>{Qt.stopPropagation(),ot(Rt)},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)})}),X!==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 ",Yme[X-1],":"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l==null?void 0:l.filter(He=>He.active).map(He=>{const et=We(He.icon);return e.jsxs("button",{type:"button",onClick:()=>Qe(X,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)})})]}),X!==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:()=>Y(null),children:[e.jsx(Ol,{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:()=>ke(X,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"})]})}),lt==null?void 0:lt.map(He=>e.jsx("button",{type:"button",onClick:()=>ke(X,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(at,{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:()=>ie(!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(On,{children:[e.jsx(K,{variant:"outline",onClick:nt,children:"Cancel"}),e.jsxs(K,{onClick:A?he:Dt,disabled:!L.trim()||u.isPending||p.isPending,children:[e.jsx(zu,{className:"h-4 w-4 mr-2"}),A?"Save Changes":"Create Plan"]})]})]})}),e.jsx(vs,{open:de,onOpenChange:ie,children:e.jsxs(ys,{className:"max-w-lg",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(tr,{value:Ne,onValueChange:Ke,children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select tone..."})}),e.jsxs(er,{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"})]})]})]}),((Ze=(mt=l==null?void 0:l.find(He=>He.id===te))==null?void 0:mt.name)==null?void 0:Ze.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:ye,onChange:He=>we(He.target.value),placeholder:"e.g., Quick Hello!"})]}),e.jsxs("div",{children:[e.jsx(ve,{htmlFor:"script-body",children:"Script Content"}),e.jsx(Tr,{id:"script-body",value:pe,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(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>ie(!1),children:"Cancel"}),e.jsxs(K,{onClick:qe,disabled:!ae.trim()||!pe.trim()||_.isPending,children:[e.jsx(zu,{className:"h-4 w-4 mr-2"}),"Create & Use Script"]})]})]})})]})}const wBt="0dde5abb-0005-4c8c-a471-30d0cbc9e280",jBt=[{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 kBt(){const t=Lr(),s=pZe(),{data:r}=uZe(),{data:n}=Ef(),{data:a}=vwe(),{data:o}=Cle(90),{data:l}=Xh(),i=C7t(),d=fZe(),u=N7t(),p=S7t(),{data:g=[],isLoading:v}=Ct({queryKey:["popby-templates"],queryFn:async()=>{const{data:de,error:ie}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("category_id",wBt).order("publish_date",{ascending:!1});if(ie)throw ie;const{data:ae}=await G.from("template_likes").select("template_id"),{data:le}=await G.from("template_comments").select("template_id"),pe=new Map;ae==null||ae.forEach(ye=>{pe.set(ye.template_id,(pe.get(ye.template_id)||0)+1)});const be=new Map;return le==null||le.forEach(ye=>{be.set(ye.template_id,(be.get(ye.template_id)||0)+1)}),(de||[]).map(ye=>({...ye,likesCount:pe.get(ye.id)||0,commentsCount:be.get(ye.id)||0}))}}),_=de=>{const ie=l==null?void 0:l.find(ae=>ae.id===de);return ie?`${ie.first_name} ${ie.last_name||""}`.trim():"Unknown"},b=de=>{if(!de)return null;const ie=r==null?void 0:r.find(ae=>ae.id===de);return(ie==null?void 0:ie.name)||null},[j,w]=S.useState(null),[N,C]=S.useState(!1),[A,I]=S.useState(!1),[L,R]=S.useState(!1),[$,q]=S.useState({popby_item_id:"",notes:""}),[U,V]=S.useState({name:"",description:""}),X=async()=>{j&&(await d.mutateAsync({contact_id:j.id,popby_item_id:$.popby_item_id||void 0,notes:$.notes||void 0}),C(!1),w(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),V({name:"",description:""}))},te=async(de,ie)=>{await p.mutateAsync({relationship_type_id:de,frequency_days:parseInt(ie)})},Y=de=>{var ae;const ie=a==null?void 0:a.find(le=>le.relationship_type_id===de);return((ae=ie==null?void 0:ie.frequency_days)==null?void 0:ae.toString())||"90"};return e.jsx(Ms,{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(Ti,{className:"h-4 w-4 mr-2"}),"View Map"]}),e.jsxs(K,{variant:"outline",onClick:()=>I(!0),children:[e.jsx(Fl,{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(ja,{defaultValue:"due",children:[e.jsxs(va,{children:[e.jsx(Ns,{value:"due",children:"Due for Popby"}),e.jsx(Ns,{value:"activity",children:"Recent Activity"}),e.jsx(Ns,{value:"library",children:"Popby Library"}),e.jsx(Ns,{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(ao,{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(at,{variant:"destructive",className:"text-xs",children:[de.daysOverdue,"+ days overdue"]}),de.daysSinceLastPopby===null&&e.jsx(at,{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(Ti,{className:"h-3 w-3"}),de.city||de.address]}),de.tags&&de.tags.length>0&&e.jsx("span",{children:de.tags.map(ie=>{var ae;return(ae=ie.relationship_type)==null?void 0:ae.name}).join(", ")})]}),de.lastPopby&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last popby: ",ws(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(Zn,{className:"h-4 w-4"})})}),e.jsxs(K,{size:"sm",onClick:()=>{w(de),C(!0)},children:[e.jsx(fi,{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(In,{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(Lt,{children:e.jsx(zt,{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(ao,{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(at,{variant:"secondary",className:"text-xs",children:b(de.popby_item_id)})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ws(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(ao,{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(at,{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:[g.length," template",g.length!==1?"s":""," found"]}),v&&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,ie)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(gs,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(gs,{className:"h-5 w-3/4 mb-2"}),e.jsx(gs,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(gs,{className:"h-5 w-16"}),e.jsx(gs,{className:"h-5 w-20"})]})]})},ie))}),!v&&g.length===0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(cl,{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."})]})}),!v&&g.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:g.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:Xie(de.description)}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:e.jsx(at,{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(hu,{className:"h-3.5 w-3.5"}),de.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pc,{className:"h-3.5 w-3.5"}),de.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:ie=>{ie.stopPropagation(),t(`/templates/${de.id}`)},children:[e.jsx(rn,{className:"h-4 w-4"}),"View Template"]})]})]},de.id))})]})]}),e.jsx(vs,{open:N,onOpenChange:C,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:["Log Popby for ",j==null?void 0:j.first_name," ",j==null?void 0:j.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(tr,{value:$.popby_item_id,onValueChange:de=>q(ie=>({...ie,popby_item_id:de})),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select a popby item..."})}),e.jsx(er,{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(Tr,{placeholder:"Any notes about this popby...",value:$.notes,onChange:de=>q(ie=>({...ie,notes:de.target.value}))})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(K,{onClick:X,disabled:d.isPending,children:"Log Popby"})]})]})}),e.jsx(vs,{open:A,onOpenChange:I,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{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(tr,{value:Y(de.id),onValueChange:ie=>te(de.id,ie),children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{})}),e.jsx(er,{children:jBt.map(ie=>e.jsx(At,{value:ie.value,children:ie.label},ie.value))})]})]},de.id))]}),e.jsx(On,{children:e.jsx(K,{onClick:()=>I(!1),children:"Done"})})]})}),e.jsx(vs,{open:L,onOpenChange:R,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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=>V(ie=>({...ie,name:de.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Description"}),e.jsx(Tr,{placeholder:"Optional description...",value:U.description,onChange:de=>V(ie=>({...ie,description:de.target.value}))})]})]}),e.jsxs(On,{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"})]})]})})]})})}function NBt(){const t=Lr(),{isAdmin:s}=Gs(),r=S.useRef(null),n=S.useRef(null),a=S.useRef([]),o=mZe(),{data:l}=uZe(),i=fZe(),[d,u]=S.useState(""),[p,g]=S.useState(""),[v,_]=S.useState(!0),[b,j]=S.useState(null),[w,N]=S.useState(null),[C,A]=S.useState(!1),[I,L]=S.useState({popby_item_id:"",notes:""}),R=o.filter(V=>V.address||V.city&&V.state);S.useEffect(()=>{(async()=>{_(!0);try{const{data:X}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();X!=null&&X.value&&u(X.value)}catch(X){console.error("Error fetching mapbox token:",X)}_(!1)})()},[]),S.useEffect(()=>{"geolocation"in navigator&&navigator.geolocation.getCurrentPosition(V=>{j([V.coords.longitude,V.coords.latitude])},V=>{console.log("Could not get location:",V)})},[]),S.useEffect(()=>{if(!(!r.current||!d||n.current))return $c.accessToken=d,n.current=new $c.Map({container:r.current,style:"mapbox://styles/mapbox/streets-v12",zoom:b?12:4,center:b||[-98.5795,39.8283]}),n.current.addControl(new $c.NavigationControl,"top-right"),()=>{var V;(V=n.current)==null||V.remove(),n.current=null}},[d,b]),S.useEffect(()=>{!n.current||!d||(a.current.forEach(V=>V.remove()),a.current=[],R.forEach(async V=>{var se;const X=[V.address,V.city,V.state,V.zip].filter(Boolean).join(", ");if(X)try{const Y=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(X)}.json?access_token=${d}`)).json();if(Y.features&&Y.features.length>0){const[de,ie]=Y.features[0].center,ae=document.createElement("div");ae.className="cursor-pointer",ae.innerHTML=`
${V.first_name[0]}${((se=V.last_name)==null?void 0:se[0])||""}
${V.isDue?'
':""}
`;const le=new $c.Marker(ae).setLngLat([de,ie]).addTo(n.current);ae.addEventListener("click",()=>{N(V)}),a.current.push(le)}}catch(te){console.error("Geocoding error for",V.first_name,te)}}))},[R,d]);const $=()=>{b&&n.current?n.current.flyTo({center:b,zoom:13}):an({title:"Location not available",description:"Please enable location services",variant:"destructive"})},q=async()=>{w&&(await i.mutateAsync({contact_id:w.id,popby_item_id:I.popby_item_id||void 0,notes:I.notes||void 0,latitude:b==null?void 0:b[1],longitude:b==null?void 0:b[0]}),A(!1),N(null),L({popby_item_id:"",notes:""}))},U=async()=>{if(p.trim())try{await G.from("settings").upsert({key:"mapbox_public_token",value:p.trim()}),u(p.trim()),an({title:"Mapbox token saved!"})}catch{an({title:"Error saving token",variant:"destructive"})}};return v?e.jsx(Ms,{title:"Popby Map",children:e.jsx("div",{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"})})}):d?e.jsx(Ms,{title:"Popby Map",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(K,{variant:"ghost",onClick:()=>t("/mission-control/popbys"),children:[e.jsx(Ka,{className:"h-4 w-4 mr-2"}),"Back to Popbys"]}),e.jsxs(K,{onClick:$,children:[e.jsx(lP,{className:"h-4 w-4 mr-2"}),"My Location"]})]}),e.jsxs("div",{className:"flex 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 bg-primary"}),e.jsx("span",{children:"Up to date"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full bg-amber-500"}),e.jsx("span",{children:"Due for popby"})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{ref:r,className:"w-full h-[60vh] rounded-lg shadow-lg"}),R.length===0&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 rounded-lg",children:e.jsxs("div",{className:"text-center p-6",children:[e.jsx(Qo,{className:"h-12 w-12 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"font-medium",children:"No contacts with addresses"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Add addresses to your contacts to see them on the map."})]})})]}),w&&e.jsx(Ee,{className:"fixed bottom-4 left-4 right-4 md:left-auto md:right-4 md:w-96 z-50 shadow-xl",children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold",children:[w.first_name," ",w.last_name]}),w.address&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[w.city,", ",w.state]})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>N(null),children:"×"})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[w.isDue?e.jsxs(at,{variant:"destructive",children:[w.daysOverdue,"+ days overdue"]}):e.jsx(at,{variant:"secondary",children:"Up to date"}),w.lastPopby&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last: ",ws(new Date(w.lastPopby),"MMM d")]})]}),e.jsxs("div",{className:"flex gap-2",children:[w.phone&&e.jsx(K,{size:"sm",variant:"outline",asChild:!0,className:"flex-1",children:e.jsxs("a",{href:`tel:${w.phone}`,children:[e.jsx(Zn,{className:"h-4 w-4 mr-1"}),"Call"]})}),w.address&&e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>{const V=[w.address,w.city,w.state,w.zip].filter(Boolean).join(", ");window.open(`https://maps.google.com/maps?daddr=${encodeURIComponent(V)}`,"_blank")},children:[e.jsx(gP,{className:"h-4 w-4 mr-1"}),"Navigate"]}),e.jsxs(K,{size:"sm",className:"flex-1",onClick:()=>A(!0),children:[e.jsx(ao,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})}),e.jsx(vs,{open:C,onOpenChange:A,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsxs(Ss,{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(tr,{value:I.popby_item_id,onValueChange:V=>L(X=>({...X,popby_item_id:V})),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select a popby item..."})}),e.jsx(er,{children:l==null?void 0:l.map(V=>e.jsx(At,{value:V.id,children:V.name},V.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Notes (optional)"}),e.jsx(Tr,{placeholder:"Any notes about this popby...",value:I.notes,onChange:V=>L(X=>({...X,notes:V.target.value}))})]}),b&&e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Ti,{className:"h-3 w-3"}),"Your current location will be recorded"]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),e.jsxs(K,{onClick:q,disabled:i.isPending,children:[e.jsx(fi,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})]})}):s?e.jsx(Ms,{title:"Popby Map",children:e.jsx("div",{className:"max-w-md mx-auto mt-8",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx(Ti,{className:"h-12 w-12 mx-auto text-muted-foreground mb-2"}),e.jsx("h2",{className:"text-lg font-semibold",children:"Setup Map"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter your Mapbox public token to enable the map feature."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Mapbox Public Token"}),e.jsx(Re,{placeholder:"pk.eyJ1I...",value:p,onChange:V=>g(V.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"})]})]}),e.jsx(K,{onClick:U,className:"w-full",children:"Save Token"}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:()=>t("/mission-control/popbys"),children:[e.jsx(Ka,{className:"h-4 w-4 mr-2"}),"Back to Popbys"]})]})})})}):e.jsx(Ms,{title:"Popby Map",children:e.jsx("div",{className:"max-w-md mx-auto mt-8",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(Qo,{className:"h-12 w-12 mx-auto text-muted-foreground mb-2"}),e.jsx("h2",{className:"text-lg font-semibold",children:"Map Not Available"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The map feature has not been configured yet. Please contact your administrator."})]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:()=>t("/mission-control/popbys"),children:[e.jsx(Ka,{className:"h-4 w-4 mr-2"}),"Back to Popbys"]})]})})})})}const SBt=eS({property_address:Yl().min(1,"Property address is required"),city:Yl().optional(),state:Yl().optional(),zip:Yl().optional(),transaction_type:$9e(["buyer","seller"]),close_date:Yl().min(1,"Close date is required"),sale_price:VP().min(0,"Sale price must be positive"),commission_amount:VP().optional(),lead_source_id:Yl().optional(),client_type_id:Yl().optional(),contact_id:Yl().optional(),notes:Yl().optional(),is_win:Y_t()});function bZe({open:t,onOpenChange:s,transaction:r}){const[n,a]=S.useState(!1),[o,l]=S.useState(""),[i,d]=S.useState(!1),[u,p]=S.useState(""),g=Yoe(),v=z5t(),{data:_}=IL(),{data:b}=Ef(),{data:j}=Xh(),w=Zoe(),N=xVe(),{data:C}=Xoe(),A=(C==null?void 0:C.show_commission)??!0,I=Ooe({resolver:Roe(SBt),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}});S.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 V={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 v.mutateAsync({id:r.id,...V}):await g.mutateAsync(V),s(!1)},R=async()=>{if(!o.trim())return;const[U,...V]=o.trim().split(" "),X=V.join(" ")||null,se=await w.mutateAsync({first_name:U,last_name:X,tagIds:[]});se&&(I.setValue("contact_id",se.id),l(""),d(!1),a(!1))},$=async()=>{if(!u.trim())return;const U=await N.mutateAsync(u.trim());U&&(I.setValue("lead_source_id",U.id),p(""))},q=j==null?void 0:j.find(U=>U.id===I.watch("contact_id"));return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-lg max-h-[90vh]",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:r?"Edit Transaction":"Add Transaction"})}),e.jsx(Fi,{className:"max-h-[70vh] pr-4",children:e.jsx(Foe,{...I,children:e.jsxs("form",{onSubmit:I.handleSubmit(L),className:"space-y-4",children:[e.jsx(vc,{control:I.control,name:"property_address",render:({field:U})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Property Address *"}),e.jsx(dc,{children:e.jsx(Re,{placeholder:"123 Main St",...U})}),e.jsx(Ah,{})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(vc,{control:I.control,name:"city",render:({field:U})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"City"}),e.jsx(dc,{children:e.jsx(Re,{placeholder:"City",...U})})]})}),e.jsx(vc,{control:I.control,name:"state",render:({field:U})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"State"}),e.jsx(dc,{children:e.jsx(Re,{placeholder:"TX",...U})})]})}),e.jsx(vc,{control:I.control,name:"zip",render:({field:U})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Zip"}),e.jsx(dc,{children:e.jsx(Re,{placeholder:"75001",...U})})]})})]}),e.jsx(vc,{control:I.control,name:"transaction_type",render:({field:U})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Transaction Type *"}),e.jsxs(tr,{onValueChange:U.onChange,value:U.value,children:[e.jsx(dc,{children:e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select type"})})}),e.jsxs(er,{children:[e.jsx(At,{value:"buyer",children:"Buyer"}),e.jsx(At,{value:"seller",children:"Seller"})]})]}),e.jsx(Ah,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(vc,{control:I.control,name:"close_date",render:({field:U})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Close Date *"}),e.jsx(dc,{children:e.jsx(Re,{type:"date",...U})}),e.jsx(Ah,{})]})}),e.jsx(vc,{control:I.control,name:"sale_price",render:({field:U})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Sale Price *"}),e.jsx(dc,{children:e.jsx(Re,{type:"number",placeholder:"0",...U,onChange:V=>U.onChange(Number(V.target.value))})}),e.jsx(Ah,{})]})})]}),A&&e.jsx(vc,{control:I.control,name:"commission_amount",render:({field:U})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Commission"}),e.jsx(dc,{children:e.jsx(Re,{type:"number",placeholder:"0",...U,value:U.value??"",onChange:V=>U.onChange(V.target.value?Number(V.target.value):void 0)})})]})}),e.jsx(vc,{control:I.control,name:"lead_source_id",render:({field:U})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Lead Source"}),e.jsxs(tr,{onValueChange:U.onChange,value:U.value||"",children:[e.jsx(dc,{children:e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select source"})})}),e.jsx(er,{children:_==null?void 0:_.map(V=>e.jsx(At,{value:V.id,children:V.name},V.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(vc,{control:I.control,name:"client_type_id",render:({field:U})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Client Type"}),e.jsxs(tr,{onValueChange:U.onChange,value:U.value||"",children:[e.jsx(dc,{children:e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select client type"})})}),e.jsx(er,{children:b==null?void 0:b.map(V=>e.jsx(At,{value:V.id,children:V.name},V.id))})]})]})}),e.jsx(vc,{control:I.control,name:"contact_id",render:({field:U})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Client Contact"}),e.jsxs(No,{open:n,onOpenChange:a,children:[e.jsx(So,{asChild:!0,children:e.jsx(dc,{children:e.jsxs(K,{variant:"outline",role:"combobox",className:Et("w-full justify-between",!U.value&&"text-muted-foreground"),children:[q?`${q.first_name} ${q.last_name||""}`.trim():"Select contact",e.jsx(df,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),e.jsxs(jo,{className:"w-full p-0",align:"start",children:[e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search contacts..."}),e.jsxs(kf,{children:[e.jsx(Nf,{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(Sf,{children:j==null?void 0:j.map(V=>e.jsxs(jm,{value:`${V.first_name} ${V.last_name||""}`,onSelect:()=>{U.onChange(V.id),a(!1)},children:[e.jsx(fa,{className:Et("mr-2 h-4 w-4",V.id===U.value?"opacity-100":"opacity-0")}),V.first_name," ",V.last_name||""]},V.id))})]})]}),i&&e.jsxs("div",{className:"p-2 border-t space-y-2",children:[e.jsx(Re,{placeholder:"Enter contact name...",value:o,onChange:V=>l(V.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",onClick:R,disabled:!o.trim()||w.isPending,children:"Add Contact"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{d(!1),l("")},children:"Cancel"})]})]})]})]})]})}),e.jsx(vc,{control:I.control,name:"notes",render:({field:U})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Notes"}),e.jsx(dc,{children:e.jsx(Tr,{placeholder:"Any notes about this transaction...",...U})})]})}),e.jsx(vc,{control:I.control,name:"is_win",render:({field:U})=>e.jsxs(lc,{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(cc,{children:"Mark as Win 🏆"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Highlight this as a notable success"})]}),e.jsx(dc,{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:g.isPending||v.isPending,children:[r?"Update":"Add"," Transaction"]})]})]})})})]})})}function wwe({transactions:t,showCommission:s,isLoading:r,agentNameMap:n,readOnly:a}){const[o,l]=S.useState(null),[i,d]=S.useState(null),[u,p]=S.useState(""),[g,v]=S.useState("all"),[_,b]=S.useState("all"),[j,w]=S.useState("all"),[N,C]=S.useState(!1),A=B5t(),I=Yoe(),{data:L}=IL(),{data:R}=Ef(),$=AM(),q=X=>{const{id:se,created_at:te,updated_at:Y,lead_source:de,client_type:ie,contact:ae,...le}=X;I.mutate(le)},U=()=>{i&&(A.mutate(i),d(null))},V=t.filter(X=>{var ae,le,pe,be;const se=u===""||X.property_address.toLowerCase().includes(u.toLowerCase())||((le=(ae=X.contact)==null?void 0:ae.first_name)==null?void 0:le.toLowerCase().includes(u.toLowerCase()))||((be=(pe=X.contact)==null?void 0:pe.last_name)==null?void 0:be.toLowerCase().includes(u.toLowerCase())),te=g==="all"||X.transaction_type===g,Y=_==="all"||X.lead_source_id===_,de=j==="all"||X.client_type_id===j,ie=!N||X.is_win;return se&&te&&Y&&de&&ie});return r?e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6 space-y-4",children:[1,2,3].map(X=>e.jsx(gs,{className:"h-16 w-full"},X))})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Lt,{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(zt,{children:["Transactions (",V.length,")"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(Re,{placeholder:"Search...",value:u,onChange:X=>p(X.target.value),className:"pl-8 w-[150px]"})]}),e.jsxs(tr,{value:g,onValueChange:v,children:[e.jsx(Js,{className:"w-[100px]",children:e.jsx(sr,{placeholder:"Type"})}),e.jsxs(er,{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(tr,{value:_,onValueChange:b,children:[e.jsx(Js,{className:"w-[130px]",children:e.jsx(sr,{placeholder:"Lead Source"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Sources"}),L==null?void 0:L.map(X=>e.jsx(At,{value:X.id,children:X.name},X.id))]})]}),e.jsxs(K,{variant:N?"default":"outline",size:"sm",onClick:()=>C(!N),children:[e.jsx(ec,{className:"h-4 w-4 mr-1"}),"Wins"]})]})]})}),e.jsx(Oe,{children:V.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:V.map(X=>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:X.property_address}),X.is_win&&e.jsx(ec,{className:"h-4 w-4 text-yellow-500 flex-shrink-0"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[X.city,X.state?`, ${X.state}`:""]})]}),e.jsx(at,{variant:X.transaction_type==="buyer"?"default":"secondary",children:X.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: "}),s4e(X.close_date)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Price: "}),Cl(X.sale_price)]}),s&&X.commission_amount&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Commission: "}),Cl(X.commission_amount)]}),X.lead_source&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Source: "}),X.lead_source.name]}),X.contact&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Client: "}),X.contact.first_name," ",X.contact.last_name]}),n&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Agent: "}),n[X.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(X),children:e.jsx(Dc,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>q(X),children:e.jsx(ai,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(X.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})]},X.id))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[n&&e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Property"}),e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Close Date"}),e.jsx(jt,{children:"Sale Price"}),s&&e.jsx(jt,{children:"Commission"}),e.jsx(jt,{children:"Lead Source"}),e.jsx(jt,{children:"Client"}),!a&&e.jsx(jt,{className:"w-[50px]"})]})}),e.jsx(En,{children:V.map(X=>{var se;return e.jsxs(js,{children:[n&&e.jsx(it,{className:"font-medium text-sm",children:n[X.owner_user_id]||"Unknown"}),e.jsx(it,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[X.is_win&&e.jsx(ec,{className:"h-4 w-4 text-yellow-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:X.property_address}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[X.city,X.state?`, ${X.state}`:""]})]})]})}),e.jsx(it,{children:e.jsx(at,{variant:X.transaction_type==="buyer"?"default":"secondary",children:X.transaction_type})}),e.jsx(it,{children:s4e(X.close_date)}),e.jsx(it,{children:Cl(X.sale_price)}),s&&e.jsx(it,{children:X.commission_amount?Cl(X.commission_amount):"-"}),e.jsx(it,{children:((se=X.lead_source)==null?void 0:se.name)||"-"}),e.jsx(it,{children:X.contact?`${X.contact.first_name} ${X.contact.last_name||""}`.trim():"-"}),!a&&e.jsx(it,{children:e.jsxs(yu,{children:[e.jsx(vu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(Jp,{className:"h-4 w-4"})})}),e.jsxs(Wd,{align:"end",children:[e.jsxs(Da,{onClick:()=>l(X),children:[e.jsx(Dc,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Da,{onClick:()=>q(X),children:[e.jsx(ai,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),e.jsxs(Da,{onClick:()=>d(X.id),className:"text-destructive",children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},X.id)})})]})})})]}),e.jsx(bZe,{open:!!o,onOpenChange:X=>!X&&l(null),transaction:o||void 0}),e.jsx(tc,{open:!!i,onOpenChange:X=>!X&&d(null),children:e.jsxs(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Delete Transaction?"}),e.jsx(Il,{children:"This action cannot be undone. This will permanently delete this transaction."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:U,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function wZe({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=(v,_)=>{if(!_||_===0)return null;const b=Math.min(v/_*100,100),j=Math.max(_-v,0),w=l>0?j/l:0,N=o/12*100,C=b>=N?"ahead":b>=N*.8?"on-track":"behind";return{percent:b,remaining:j,pace:w,status:C}},d=i(s.totalTransactions,t.transactions_goal),u=i(s.totalVolume,t.volume_goal),p=n?i(s.totalCommission,t.gci_goal):null,g=v=>{switch(v){case"ahead":return e.jsxs(at,{className:"bg-green-500 text-white",children:[e.jsx(Sc,{className:"h-3 w-3 mr-1"}),"Ahead"]});case"on-track":return e.jsxs(at,{variant:"secondary",children:[e.jsx(A0,{className:"h-3 w-3 mr-1"}),"On Track"]});case"behind":return e.jsxs(at,{variant:"destructive",children:[e.jsx(lN,{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(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Uh,{className:"h-5 w-5 text-primary"}),e.jsxs(zt,{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"}),g(d.status)]}),e.jsx(Mi,{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"}),g(u.status)]}),e.jsx(Mi,{value:u.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Cl(s.totalVolume,!0)," of ",Cl(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 ",Cl(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"}),g(p.status)]}),e.jsx(Mi,{value:p.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Cl(s.totalCommission,!0)," of ",Cl(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 ",Cl(p.pace,!0),"/month"]})]})]})})]})}var CBt=Array.isArray,zm=CBt,MBt=typeof m0=="object"&&m0&&m0.Object===Object&&m0,jZe=MBt,TBt=jZe,ABt=typeof self=="object"&&self&&self.Object===Object&&self,EBt=TBt||ABt||Function("return this")(),fy=EBt,PBt=fy,IBt=PBt.Symbol,YL=IBt,bEe=YL,kZe=Object.prototype,LBt=kZe.hasOwnProperty,DBt=kZe.toString,aE=bEe?bEe.toStringTag:void 0;function OBt(t){var s=LBt.call(t,aE),r=t[aE];try{t[aE]=void 0;var n=!0}catch{}var a=DBt.call(t);return n&&(s?t[aE]=r:delete t[aE]),a}var RBt=OBt,FBt=Object.prototype,zBt=FBt.toString;function BBt(t){return zBt.call(t)}var $Bt=BBt,wEe=YL,qBt=RBt,UBt=$Bt,VBt="[object Null]",HBt="[object Undefined]",jEe=wEe?wEe.toStringTag:void 0;function WBt(t){return t==null?t===void 0?HBt:VBt:jEe&&jEe in Object(t)?qBt(t):UBt(t)}var sv=WBt;function GBt(t){return t!=null&&typeof t=="object"}var rv=GBt,KBt=sv,ZBt=rv,YBt="[object Symbol]";function XBt(t){return typeof t=="symbol"||ZBt(t)&&KBt(t)==YBt}var EM=XBt,QBt=zm,JBt=EM,e9t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,t9t=/^\w*$/;function s9t(t,s){if(QBt(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||JBt(t)?!0:t9t.test(t)||!e9t.test(t)||s!=null&&t in Object(s)}var jwe=s9t;function r9t(t){var s=typeof t;return t!=null&&(s=="object"||s=="function")}var Y_=r9t;const PM=_o(Y_);var n9t=sv,a9t=Y_,i9t="[object AsyncFunction]",o9t="[object Function]",l9t="[object GeneratorFunction]",c9t="[object Proxy]";function d9t(t){if(!a9t(t))return!1;var s=n9t(t);return s==o9t||s==l9t||s==i9t||s==c9t}var kwe=d9t;const _i=_o(kwe);var u9t=fy,h9t=u9t["__core-js_shared__"],m9t=h9t,Xme=m9t,kEe=function(){var t=/[^.]+$/.exec(Xme&&Xme.keys&&Xme.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function p9t(t){return!!kEe&&kEe in t}var f9t=p9t,g9t=Function.prototype,x9t=g9t.toString;function y9t(t){if(t!=null){try{return x9t.call(t)}catch{}try{return t+""}catch{}}return""}var NZe=y9t,v9t=kwe,_9t=f9t,b9t=Y_,w9t=NZe,j9t=/[\\^$.*+?()[\]{}|]/g,k9t=/^\[object .+?Constructor\]$/,N9t=Function.prototype,S9t=Object.prototype,C9t=N9t.toString,M9t=S9t.hasOwnProperty,T9t=RegExp("^"+C9t.call(M9t).replace(j9t,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function A9t(t){if(!b9t(t)||_9t(t))return!1;var s=v9t(t)?T9t:k9t;return s.test(w9t(t))}var E9t=A9t;function P9t(t,s){return t==null?void 0:t[s]}var I9t=P9t,L9t=E9t,D9t=I9t;function O9t(t,s){var r=D9t(t,s);return L9t(r)?r:void 0}var aS=O9t,R9t=aS,F9t=R9t(Object,"create"),Ale=F9t,NEe=Ale;function z9t(){this.__data__=NEe?NEe(null):{},this.size=0}var B9t=z9t;function $9t(t){var s=this.has(t)&&delete this.__data__[t];return this.size-=s?1:0,s}var q9t=$9t,U9t=Ale,V9t="__lodash_hash_undefined__",H9t=Object.prototype,W9t=H9t.hasOwnProperty;function G9t(t){var s=this.__data__;if(U9t){var r=s[t];return r===V9t?void 0:r}return W9t.call(s,t)?s[t]:void 0}var K9t=G9t,Z9t=Ale,Y9t=Object.prototype,X9t=Y9t.hasOwnProperty;function Q9t(t){var s=this.__data__;return Z9t?s[t]!==void 0:X9t.call(s,t)}var J9t=Q9t,e$t=Ale,t$t="__lodash_hash_undefined__";function s$t(t,s){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=e$t&&s===void 0?t$t:s,this}var r$t=s$t,n$t=B9t,a$t=q9t,i$t=K9t,o$t=J9t,l$t=r$t;function IM(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s-1}var N$t=k$t,S$t=Ele;function C$t(t,s){var r=this.__data__,n=S$t(r,t);return n<0?(++this.size,r.push([t,s])):r[n][1]=s,this}var M$t=C$t,T$t=u$t,A$t=v$t,E$t=w$t,P$t=N$t,I$t=M$t;function LM(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s0?1:-1},Lk=function(s){return BN(s)&&s.indexOf("%")===s.length-1},sn=function(s){return Jqt(s)&&!XL(s)},rUt=function(s){return Zi(s)},$d=function(s){return sn(s)||BN(s)},nUt=0,QL=function(s){var r=++nUt;return"".concat(s||"").concat(r)},Oh=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(!sn(s)&&!BN(s))return n;var o;if(Lk(s)){var l=s.indexOf("%");o=r*parseFloat(s.slice(0,l))/100}else o=+s;return XL(o)&&(o=n),a&&o>r&&(o=r),o},_1=function(s){if(!s)return null;var r=Object.keys(s);return r&&r.length?s[r[0]]:null},aUt=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 hUt(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 PEe={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"},F0=function(s){return typeof s=="string"?s:s?s.displayName||s.name||"Component":""},IEe=null,Jme=null,Lwe=function t(s){if(s===IEe&&Array.isArray(Jme))return Jme;var r=[];return S.Children.forEach(s,function(n){Zi(n)||(Kqt.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),Jme=r,IEe=s,r};function vf(t,s){var r=[],n=[];return Array.isArray(s)?n=s.map(function(a){return F0(a)}):n=[F0(s)],Lwe(t).forEach(function(a){var o=_p(a,"type.displayName")||_p(a,"type.name");n.indexOf(o)!==-1&&r.push(a)}),r}function sp(t,s){var r=vf(t,s);return r&&r[0]}var LEe=function(s){if(!s||!s.props)return!1;var r=s.props,n=r.width,a=r.height;return!(!sn(n)||n<=0||!sn(a)||a<=0)},mUt=["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"],pUt=function(s){return s&&s.type&&BN(s.type)&&mUt.indexOf(s.type)>=0},fUt=function(s,r,n,a){var o,l=(o=Qme==null?void 0:Qme[a])!==null&&o!==void 0?o:[];return r.startsWith("data-")||!_i(s)&&(a&&l.includes(r)||lUt.includes(r))||n&&Iwe.includes(r)},hi=function(s,r,n){if(!s||typeof s=="function"||typeof s=="boolean")return null;var a=s;if(S.isValidElement(s)&&(a=s.props),!PM(a))return null;var o={};return Object.keys(a).forEach(function(l){var i;fUt((i=a)===null||i===void 0?void 0:i[l],l,r,n)&&(o[l]=a[l])}),o},pye=function t(s,r){if(s===r)return!0;var n=S.Children.count(s);if(n!==S.Children.count(r))return!1;if(n===0)return!0;if(n===1)return DEe(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 _Ut(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 gye(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=vUt(t,yUt),p=a||{width:r,height:n,x:0,y:0},g=Ri("recharts-surface",o);return ht.createElement("svg",fye({},hi(u,!0,"svg"),{className:g,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 bUt=["children","className"];function xye(){return xye=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 jUt(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 tl=ht.forwardRef(function(t,s){var r=t.children,n=t.className,a=wUt(t,bUt),o=Ri("recharts-layer",n);return ht.createElement("g",xye({className:o},hi(a,!0),{ref:s}),r)}),Bg=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:SUt(t,s,r)}var MUt=CUt,TUt="\\ud800-\\udfff",AUt="\\u0300-\\u036f",EUt="\\ufe20-\\ufe2f",PUt="\\u20d0-\\u20ff",IUt=AUt+EUt+PUt,LUt="\\ufe0e\\ufe0f",DUt="\\u200d",OUt=RegExp("["+DUt+TUt+IUt+LUt+"]");function RUt(t){return OUt.test(t)}var DZe=RUt;function FUt(t){return t.split("")}var zUt=FUt,OZe="\\ud800-\\udfff",BUt="\\u0300-\\u036f",$Ut="\\ufe20-\\ufe2f",qUt="\\u20d0-\\u20ff",UUt=BUt+$Ut+qUt,VUt="\\ufe0e\\ufe0f",HUt="["+OZe+"]",yye="["+UUt+"]",vye="\\ud83c[\\udffb-\\udfff]",WUt="(?:"+yye+"|"+vye+")",RZe="[^"+OZe+"]",FZe="(?:\\ud83c[\\udde6-\\uddff]){2}",zZe="[\\ud800-\\udbff][\\udc00-\\udfff]",GUt="\\u200d",BZe=WUt+"?",$Ze="["+VUt+"]?",KUt="(?:"+GUt+"(?:"+[RZe,FZe,zZe].join("|")+")"+$Ze+BZe+")*",ZUt=$Ze+BZe+KUt,YUt="(?:"+[RZe+yye+"?",yye,FZe,zZe,HUt].join("|")+")",XUt=RegExp(vye+"(?="+vye+")|"+YUt+ZUt,"g");function QUt(t){return t.match(XUt)||[]}var JUt=QUt,eVt=zUt,tVt=DZe,sVt=JUt;function rVt(t){return tVt(t)?sVt(t):eVt(t)}var nVt=rVt,aVt=MUt,iVt=DZe,oVt=nVt,lVt=TZe;function cVt(t){return function(s){s=lVt(s);var r=iVt(s)?oVt(s):void 0,n=r?r[0]:s.charAt(0),a=r?aVt(r,1).join(""):s.slice(1);return n[t]()+a}}var dVt=cVt,uVt=dVt,hVt=uVt("toUpperCase"),mVt=hVt;const Hle=_o(mVt);function Sl(t){return function(){return t}}const qZe=Math.cos,Iae=Math.sin,Yg=Math.sqrt,Lae=Math.PI,Wle=2*Lae,_ye=Math.PI,bye=2*_ye,mk=1e-6,pVt=bye-mk;function UZe(t){this._+=t[0];for(let s=1,r=t.length;s=0))throw new Error(`invalid digits: ${t}`);if(s>15)return UZe;const r=10**s;return function(n){this._+=n[0];for(let a=1,o=n.length;amk)if(!(Math.abs(g*d-u*p)>mk)||!o)this._append`L${this._x1=s},${this._y1=r}`;else{let _=n-l,b=a-i,j=d*d+u*u,w=_*_+b*b,N=Math.sqrt(j),C=Math.sqrt(v),A=o*Math.tan((_ye-Math.acos((j+v-w)/(2*N*C)))/2),I=A/C,L=A/N;Math.abs(I-1)>mk&&this._append`L${s+I*p},${r+I*g}`,this._append`A${o},${o},0,0,${+(g*_>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,g=1^l,v=l?a-o:o-a;this._x1===null?this._append`M${u},${p}`:(Math.abs(this._x1-u)>mk||Math.abs(this._y1-p)>mk)&&this._append`L${u},${p}`,n&&(v<0&&(v=v%bye+bye),v>pVt?this._append`A${n},${n},0,1,${g},${s-i},${r-d}A${n},${n},0,1,${g},${this._x1=u},${this._y1=p}`:v>mk&&this._append`A${n},${n},0,${+(v>=_ye)},${g},${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 Dwe(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 gVt(s)}function Owe(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function VZe(t){this._context=t}VZe.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 Gle(t){return new VZe(t)}function HZe(t){return t[0]}function WZe(t){return t[1]}function GZe(t,s){var r=Sl(!0),n=null,a=Gle,o=null,l=Dwe(i);t=typeof t=="function"?t:t===void 0?HZe:Sl(t),s=typeof s=="function"?s:s===void 0?WZe:Sl(s);function i(d){var u,p=(d=Owe(d)).length,g,v=!1,_;for(n==null&&(o=a(_=l())),u=0;u<=p;++u)!(u=_;--b)i.point(A[b],I[b]);i.lineEnd(),i.areaEnd()}N&&(A[v]=+t(w,v,g),I[v]=+s(w,v,g),i.point(n?+n(w,v,g):A[v],r?+r(w,v,g):I[v]))}if(C)return i=null,C+""||null}function p(){return GZe().defined(a).curve(l).context(o)}return u.x=function(g){return arguments.length?(t=typeof g=="function"?g:Sl(+g),n=null,u):t},u.x0=function(g){return arguments.length?(t=typeof g=="function"?g:Sl(+g),u):t},u.x1=function(g){return arguments.length?(n=g==null?null:typeof g=="function"?g:Sl(+g),u):n},u.y=function(g){return arguments.length?(s=typeof g=="function"?g:Sl(+g),r=null,u):s},u.y0=function(g){return arguments.length?(s=typeof g=="function"?g:Sl(+g),u):s},u.y1=function(g){return arguments.length?(r=g==null?null:typeof g=="function"?g:Sl(+g),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(g){return arguments.length?(a=typeof g=="function"?g:Sl(!!g),u):a},u.curve=function(g){return arguments.length?(l=g,o!=null&&(i=l(o)),u):l},u.context=function(g){return arguments.length?(g==null?o=i=null:i=l(o=g),u):o},u}class KZe{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 xVt(t){return new KZe(t,!0)}function yVt(t){return new KZe(t,!1)}const Rwe={draw(t,s){const r=Yg(s/Lae);t.moveTo(r,0),t.arc(0,0,r,0,Wle)}},vVt={draw(t,s){const r=Yg(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()}},ZZe=Yg(1/3),_Vt=ZZe*2,bVt={draw(t,s){const r=Yg(s/_Vt),n=r*ZZe;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},wVt={draw(t,s){const r=Yg(s),n=-r/2;t.rect(n,n,r,r)}},jVt=.8908130915292852,YZe=Iae(Lae/10)/Iae(7*Lae/10),kVt=Iae(Wle/10)*YZe,NVt=-qZe(Wle/10)*YZe,SVt={draw(t,s){const r=Yg(s*jVt),n=kVt*r,a=NVt*r;t.moveTo(0,-r),t.lineTo(n,a);for(let o=1;o<5;++o){const l=Wle*o/5,i=qZe(l),d=Iae(l);t.lineTo(d*r,-i*r),t.lineTo(i*n-d*a,d*n+i*a)}t.closePath()}},epe=Yg(3),CVt={draw(t,s){const r=-Yg(s/(epe*3));t.moveTo(0,r*2),t.lineTo(-epe*r,-r),t.lineTo(epe*r,-r),t.closePath()}},$p=-.5,qp=Yg(3)/2,wye=1/Yg(12),MVt=(wye/2+1)*3,TVt={draw(t,s){const r=Yg(s/MVt),n=r/2,a=r*wye,o=n,l=r*wye+r,i=-o,d=l;t.moveTo(n,a),t.lineTo(o,l),t.lineTo(i,d),t.lineTo($p*n-qp*a,qp*n+$p*a),t.lineTo($p*o-qp*l,qp*o+$p*l),t.lineTo($p*i-qp*d,qp*i+$p*d),t.lineTo($p*n+qp*a,$p*a-qp*n),t.lineTo($p*o+qp*l,$p*l-qp*o),t.lineTo($p*i+qp*d,$p*d-qp*i),t.closePath()}};function AVt(t,s){let r=null,n=Dwe(a);t=typeof t=="function"?t:Sl(t||Rwe),s=typeof s=="function"?s:Sl(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:Sl(o),a):t},a.size=function(o){return arguments.length?(s=typeof o=="function"?o:Sl(+o),a):s},a.context=function(o){return arguments.length?(r=o??null,a):r},a}function Dae(){}function Oae(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 XZe(t){this._context=t}XZe.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:Oae(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:Oae(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function EVt(t){return new XZe(t)}function QZe(t){this._context=t}QZe.prototype={areaStart:Dae,areaEnd:Dae,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:Oae(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function PVt(t){return new QZe(t)}function JZe(t){this._context=t}JZe.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:Oae(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function IVt(t){return new JZe(t)}function eYe(t){this._context=t}eYe.prototype={areaStart:Dae,areaEnd:Dae,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 LVt(t){return new eYe(t)}function REe(t){return t<0?-1:1}function FEe(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(REe(o)+REe(l))*Math.min(Math.abs(o),Math.abs(l),.5*Math.abs(i))||0}function zEe(t,s){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-s)/2:s}function tpe(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 Rae(t){this._context=t}Rae.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:tpe(this,this._t0,zEe(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,tpe(this,zEe(this,r=FEe(this,t,s)),r);break;default:tpe(this,this._t0,r=FEe(this,t,s));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s,this._t0=r}}};function tYe(t){this._context=new sYe(t)}(tYe.prototype=Object.create(Rae.prototype)).point=function(t,s){Rae.prototype.point.call(this,s,t)};function sYe(t){this._context=t}sYe.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 DVt(t){return new Rae(t)}function OVt(t){return new tYe(t)}function rYe(t){this._context=t}rYe.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=BEe(t),a=BEe(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 FVt(t){return new Kle(t,.5)}function zVt(t){return new Kle(t,0)}function BVt(t){return new Kle(t,1)}function M3(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 $Vt(t,s){return t[s]}function qVt(t){const s=[];return s.key=t,s}function UVt(){var t=Sl([]),s=jye,r=M3,n=$Vt;function a(o){var l=Array.from(t.apply(this,arguments),qVt),i,d=l.length,u=-1,p;for(const g 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 QVt(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 nYe={symbolCircle:Rwe,symbolCross:vVt,symbolDiamond:bVt,symbolSquare:wVt,symbolStar:SVt,symbolTriangle:CVt,symbolWye:TVt},JVt=Math.PI/180,eHt=function(s){var r="symbol".concat(Hle(s));return nYe[r]||Rwe},tHt=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*JVt;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}},sHt=function(s,r){nYe["symbol".concat(Hle(s))]=r},Fwe=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=XVt(s,GVt),u=qEe(qEe({},d),{},{type:n,size:o,sizeType:i}),p=function(){var w=eHt(n),N=AVt().type(w).size(tHt(o,i,n));return N()},g=u.className,v=u.cx,_=u.cy,b=hi(u,!0);return v===+v&&_===+_&&o===+o?ht.createElement("path",kye({},b,{className:Ri("recharts-symbols",g),transform:"translate(".concat(v,", ").concat(_,")"),d:p()})):null};Fwe.registerSymbol=sHt;function T3(t){"@babel/helpers - typeof";return T3=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},T3(t)}function Nye(){return Nye=Object.assign?Object.assign.bind():function(t){for(var s=1;s`);var C=_.inactive?u:_.color;return ht.createElement("li",Nye({className:w,style:g,key:"legend-item-".concat(b)},$N(n.props,_,b)),ht.createElement(gye,{width:l,height:l,viewBox:p,style:v},n.renderIcon(_)),ht.createElement("span",{className:"recharts-legend-item-text",style:{color:C}},j?j(N,_,b):N))})}},{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())}}])}(S.PureComponent);y6(zwe,"displayName","Legend");y6(zwe,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var hHt=Ple;function mHt(){this.__data__=new hHt,this.size=0}var pHt=mHt;function fHt(t){var s=this.__data__,r=s.delete(t);return this.size=s.size,r}var gHt=fHt;function xHt(t){return this.__data__.get(t)}var yHt=xHt;function vHt(t){return this.__data__.has(t)}var _Ht=vHt,bHt=Ple,wHt=Swe,jHt=Cwe,kHt=200;function NHt(t,s){var r=this.__data__;if(r instanceof bHt){var n=r.__data__;if(!wHt||n.lengthi))return!1;var u=o.get(t),p=o.get(s);if(u&&p)return u==s&&p==t;var g=-1,v=!0,_=r&GHt?new UHt:void 0;for(o.set(t,s),o.set(s,t);++g-1&&t%1==0&&t-1&&t%1==0&&t<=XWt}var Uwe=QWt,JWt=sv,eGt=Uwe,tGt=rv,sGt="[object Arguments]",rGt="[object Array]",nGt="[object Boolean]",aGt="[object Date]",iGt="[object Error]",oGt="[object Function]",lGt="[object Map]",cGt="[object Number]",dGt="[object Object]",uGt="[object RegExp]",hGt="[object Set]",mGt="[object String]",pGt="[object WeakMap]",fGt="[object ArrayBuffer]",gGt="[object DataView]",xGt="[object Float32Array]",yGt="[object Float64Array]",vGt="[object Int8Array]",_Gt="[object Int16Array]",bGt="[object Int32Array]",wGt="[object Uint8Array]",jGt="[object Uint8ClampedArray]",kGt="[object Uint16Array]",NGt="[object Uint32Array]",Kl={};Kl[xGt]=Kl[yGt]=Kl[vGt]=Kl[_Gt]=Kl[bGt]=Kl[wGt]=Kl[jGt]=Kl[kGt]=Kl[NGt]=!0;Kl[sGt]=Kl[rGt]=Kl[fGt]=Kl[nGt]=Kl[gGt]=Kl[aGt]=Kl[iGt]=Kl[oGt]=Kl[lGt]=Kl[cGt]=Kl[dGt]=Kl[uGt]=Kl[hGt]=Kl[mGt]=Kl[pGt]=!1;function SGt(t){return tGt(t)&&eGt(t.length)&&!!Kl[JWt(t)]}var CGt=SGt;function MGt(t){return function(s){return t(s)}}var fYe=MGt,$ae={exports:{}};$ae.exports;(function(t,s){var r=jZe,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})($ae,$ae.exports);var TGt=$ae.exports,AGt=CGt,EGt=fYe,ZEe=TGt,YEe=ZEe&&ZEe.isTypedArray,PGt=YEe?EGt(YEe):AGt,gYe=PGt,IGt=OWt,LGt=$we,DGt=zm,OGt=pYe,RGt=qwe,FGt=gYe,zGt=Object.prototype,BGt=zGt.hasOwnProperty;function $Gt(t,s){var r=DGt(t),n=!r&&LGt(t),a=!r&&!n&&OGt(t),o=!r&&!n&&!a&&FGt(t),l=r||n||a||o,i=l?IGt(t.length,String):[],d=i.length;for(var u in t)(s||BGt.call(t,u))&&!(l&&(u=="length"||a&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||RGt(u,d)))&&i.push(u);return i}var qGt=$Gt,UGt=Object.prototype;function VGt(t){var s=t&&t.constructor,r=typeof s=="function"&&s.prototype||UGt;return t===r}var HGt=VGt;function WGt(t,s){return function(r){return t(s(r))}}var xYe=WGt,GGt=xYe,KGt=GGt(Object.keys,Object),ZGt=KGt,YGt=HGt,XGt=ZGt,QGt=Object.prototype,JGt=QGt.hasOwnProperty;function eKt(t){if(!YGt(t))return XGt(t);var s=[];for(var r in Object(t))JGt.call(t,r)&&r!="constructor"&&s.push(r);return s}var tKt=eKt,sKt=kwe,rKt=Uwe;function nKt(t){return t!=null&&rKt(t.length)&&!sKt(t)}var JL=nKt,aKt=qGt,iKt=tKt,oKt=JL;function lKt(t){return oKt(t)?aKt(t):iKt(t)}var Zle=lKt,cKt=kWt,dKt=LWt,uKt=Zle;function hKt(t){return cKt(t,uKt,dKt)}var mKt=hKt,XEe=mKt,pKt=1,fKt=Object.prototype,gKt=fKt.hasOwnProperty;function xKt(t,s,r,n,a,o){var l=r&pKt,i=XEe(t),d=i.length,u=XEe(s),p=u.length;if(d!=p&&!l)return!1;for(var g=d;g--;){var v=i[g];if(!(l?v in s:gKt.call(s,v)))return!1}var _=o.get(t),b=o.get(s);if(_&&b)return _==s&&b==t;var j=!0;o.set(t,s),o.set(s,t);for(var w=l;++g-1}var fYt=pYt;function gYt(t,s,r){for(var n=-1,a=t==null?0:t.length;++n=EYt){var u=s?null:TYt(t);if(u)return AYt(u);l=!1,a=MYt,d=new NYt}else d=s?[]:i;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function GYt(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 KYt(t){return t.value}function ZYt(t,s){if(ht.isValidElement(t))return ht.cloneElement(t,s);if(typeof t=="function")return ht.createElement(t,s);s.ref;var r=WYt(s,FYt);return ht.createElement(zwe,r)}var mPe=1,R5=function(t){function s(){var r;zYt(this,s);for(var n=arguments.length,a=new Array(n),o=0;omPe||Math.abs(a.height-this.lastBoundingBox.height)>mPe)&&(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?Zy({},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,g,v;if(!n||(n.left===void 0||n.left===null)&&(n.right===void 0||n.right===null))if(l==="center"&&o==="vertical"){var _=this.getBBoxSnapshot();g={left:((u||0)-_.width)/2}}else g=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();v={top:((p||0)-b.height)/2}}else v=i==="bottom"?{bottom:d&&d.bottom||0}:{top:d&&d.top||0};return Zy(Zy({},g),v)}},{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,g=Zy(Zy({position:"absolute",width:l||"auto",height:i||"auto"},this.getDefaultPosition(d)),d);return ht.createElement("div",{className:"recharts-legend-wrapper",style:g,ref:function(_){n.wrapperNode=_}},ZYt(o,Zy(Zy({},this.props),{},{payload:kYe(p,u,KYt)})))}}],[{key:"getWithHeight",value:function(n,a){var o=Zy(Zy({},this.defaultProps),n.props),l=o.layout;return l==="vertical"&&sn(n.props.height)?{height:n.props.height}:l==="horizontal"?{width:n.props.width||a}:null}}])}(S.PureComponent);Yle(R5,"displayName","Legend");Yle(R5,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var pPe=YL,YYt=$we,XYt=zm,fPe=pPe?pPe.isConcatSpreadable:void 0;function QYt(t){return XYt(t)||YYt(t)||!!(fPe&&t&&t[fPe])}var JYt=QYt,eXt=hYe,tXt=JYt;function CYe(t,s,r,n,a){var o=-1,l=t.length;for(r||(r=tXt),a||(a=[]);++o0&&r(i)?s>1?CYe(i,s-1,r,n,a):eXt(a,i):n||(a[a.length]=i)}return a}var MYe=CYe;function sXt(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 rXt=sXt,nXt=rXt,aXt=nXt(),iXt=aXt,oXt=iXt,lXt=Zle;function cXt(t,s){return t&&oXt(t,s,lXt)}var TYe=cXt,dXt=JL;function uXt(t,s){return function(r,n){if(r==null)return r;if(!dXt(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 NXt=kXt,ape=Twe,SXt=Awe,CXt=gy,MXt=AYe,TXt=_Xt,AXt=fYe,EXt=NXt,PXt=FM,IXt=zm;function LXt(t,s,r){s.length?s=ape(s,function(o){return IXt(o)?function(l){return SXt(l,o.length===1?o[0]:o)}:o}):s=[PXt];var n=-1;s=ape(s,AXt(CXt));var a=MXt(t,function(o,l,i){var d=ape(s,function(u){return u(o)});return{criteria:d,index:++n,value:o}});return TXt(a,function(o,l){return EXt(o,l,r)})}var DXt=LXt;function OXt(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 RXt=OXt,FXt=RXt,xPe=Math.max;function zXt(t,s,r){return s=xPe(s===void 0?t.length-1:s,0),function(){for(var n=arguments,a=-1,o=xPe(n.length-s,0),l=Array(o);++a0){if(++s>=ZXt)return arguments[0]}else s=0;return t.apply(void 0,arguments)}}var JXt=QXt,eQt=KXt,tQt=JXt,sQt=tQt(eQt),rQt=sQt,nQt=FM,aQt=BXt,iQt=rQt;function oQt(t,s){return iQt(aQt(t,s,nQt),t+"")}var lQt=oQt,cQt=Nwe,dQt=JL,uQt=qwe,hQt=Y_;function mQt(t,s,r){if(!hQt(r))return!1;var n=typeof s;return(n=="number"?dQt(r)&&uQt(s,r.length):n=="string"&&s in r)?cQt(r[s],t):!1}var Xle=mQt,pQt=MYe,fQt=DXt,gQt=lQt,vPe=Xle,xQt=gQt(function(t,s){if(t==null)return[];var r=s.length;return r>1&&vPe(t,s[0],s[1])?s=[]:r>2&&vPe(s[0],s[1],s[2])&&(s=[s[0]]),fQt(t,pQt(s,1),[])}),yQt=xQt;const Wwe=_o(yQt);function v6(t){"@babel/helpers - typeof";return v6=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},v6(t)}function Iye(){return Iye=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(iE,"-left"),sn(r)&&s&&sn(s.x)&&r=s.y),"".concat(iE,"-top"),sn(n)&&s&&sn(s.y)&&nj?Math.max(p,d[n]):Math.max(g,d[n])}function IQt(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 LQt(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,g;return l.height>0&&l.width>0&&r?(p=wPe({allowEscapeViewBox:s,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:d,viewBoxDimension:d.width}),g=wPe({allowEscapeViewBox:s,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:d,viewBoxDimension:d.height}),u=IQt({translateX:p,translateY:g,useTranslate3d:i})):u=EQt,{cssProperties:u,cssClasses:PQt({translateX:p,translateY:g,coordinate:r})}}function E3(t){"@babel/helpers - typeof";return E3=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},E3(t)}function jPe(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 kPe(t){for(var s=1;sNPe||Math.abs(n.height-this.state.lastBoundingBox.height)>NPe)&&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,g=a.hasPayload,v=a.isAnimationActive,_=a.offset,b=a.position,j=a.reverseDirection,w=a.useTranslate3d,N=a.viewBox,C=a.wrapperStyle,A=LQt({allowEscapeViewBox:l,coordinate:p,offsetTopLeft:_,position:b,reverseDirection:j,tooltipBox:this.state.lastBoundingBox,useTranslate3d:w,viewBox:N}),I=A.cssClasses,L=A.cssProperties,R=kPe(kPe({transition:v&&o?"transform ".concat(i,"ms ").concat(d):void 0},L),{},{pointerEvents:"none",visibility:!this.state.dismissed&&o&&g?"visible":"hidden",position:"absolute",top:0,left:0},C);return ht.createElement("div",{tabIndex:-1,className:I,style:R,ref:function(q){n.wrapperNode=q}},u)}}])}(S.PureComponent),VQt=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},zM={isSsr:VQt()};function P3(t){"@babel/helpers - typeof";return P3=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},P3(t)}function SPe(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 CPe(t){for(var s=1;s0;return ht.createElement(UQt,{allowEscapeViewBox:l,animationDuration:i,animationEasing:d,isAnimationActive:v,active:o,coordinate:p,hasPayload:R,offset:_,position:w,reverseDirection:N,useTranslate3d:C,viewBox:A,wrapperStyle:I},eJt(u,CPe(CPe({},this.props),{},{payload:L})))}}])}(S.PureComponent);Gwe(jg,"displayName","Tooltip");Gwe(jg,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!zM.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 tJt=fy,sJt=function(){return tJt.Date.now()},rJt=sJt,nJt=/\s/;function aJt(t){for(var s=t.length;s--&&nJt.test(t.charAt(s)););return s}var iJt=aJt,oJt=iJt,lJt=/^\s+/;function cJt(t){return t&&t.slice(0,oJt(t)+1).replace(lJt,"")}var dJt=cJt,uJt=dJt,MPe=Y_,hJt=EM,TPe=NaN,mJt=/^[-+]0x[0-9a-f]+$/i,pJt=/^0b[01]+$/i,fJt=/^0o[0-7]+$/i,gJt=parseInt;function xJt(t){if(typeof t=="number")return t;if(hJt(t))return TPe;if(MPe(t)){var s=typeof t.valueOf=="function"?t.valueOf():t;t=MPe(s)?s+"":s}if(typeof t!="string")return t===0?t:+t;t=uJt(t);var r=pJt.test(t);return r||fJt.test(t)?gJt(t.slice(2),r?2:8):mJt.test(t)?TPe:+t}var OYe=xJt,yJt=Y_,ope=rJt,APe=OYe,vJt="Expected a function",_Jt=Math.max,bJt=Math.min;function wJt(t,s,r){var n,a,o,l,i,d,u=0,p=!1,g=!1,v=!0;if(typeof t!="function")throw new TypeError(vJt);s=APe(s)||0,yJt(r)&&(p=!!r.leading,g="maxWait"in r,o=g?_Jt(APe(r.maxWait)||0,s):o,v="trailing"in r?!!r.trailing:v);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(N,s),p?_(R):l}function j(R){var $=R-d,q=R-u,U=s-$;return g?bJt(U,o-q):U}function w(R){var $=R-d,q=R-u;return d===void 0||$>=s||$<0||g&&q>=o}function N(){var R=ope();if(w(R))return C(R);i=setTimeout(N,j(R))}function C(R){return i=void 0,v&&n?_(R):(n=a=void 0,l)}function A(){i!==void 0&&clearTimeout(i),u=0,n=d=a=i=void 0}function I(){return i===void 0?l:C(ope())}function L(){var R=ope(),$=w(R);if(n=arguments,a=this,d=R,$){if(i===void 0)return b(d);if(g)return clearTimeout(i),i=setTimeout(N,s),_(d)}return i===void 0&&(i=setTimeout(N,s)),l}return L.cancel=A,L.flush=I,L}var jJt=wJt,kJt=jJt,NJt=Y_,SJt="Expected a function";function CJt(t,s,r){var n=!0,a=!0;if(typeof t!="function")throw new TypeError(SJt);return NJt(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),kJt(t,s,{leading:n,maxWait:s,trailing:a})}var MJt=CJt;const RYe=_o(MJt);function b6(t){"@babel/helpers - typeof";return b6=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},b6(t)}function EPe(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 pR(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&(te=RYe(te,j,{trailing:!0,leading:!1}));var Y=new ResizeObserver(te),de=L.current.getBoundingClientRect(),ie=de.width,ae=de.height;return X(ie,ae),Y.observe(L.current),function(){Y.disconnect()}},[X,j]);var se=S.useMemo(function(){var te=U.containerWidth,Y=U.containerHeight;if(te<0||Y<0)return null;Bg(Lk(l)||Lk(d),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,l,d),Bg(!r||r>0,"The aspect(%s) must be greater than zero.",r);var de=Lk(l)?te:l,ie=Lk(d)?Y:d;r&&r>0&&(de?ie=de/r:ie&&(de=ie*r),v&&ie>v&&(ie=v)),Bg(de>0||ie>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,ie,l,d,p,g,r);var ae=!Array.isArray(_)&&F0(_.type).endsWith("Chart");return ht.Children.map(_,function(le){return ht.isValidElement(le)?S.cloneElement(le,pR({width:de,height:ie},ae?{style:pR({height:"100%",width:"100%",maxHeight:ie,maxWidth:de},le.props.style)}:{})):le})},[r,_,d,v,g,p,U,l]);return ht.createElement("div",{id:w?"".concat(w):void 0,className:Ri("recharts-responsive-container",N),style:pR(pR({},I),{},{width:l,height:d,minWidth:p,minHeight:g,maxHeight:v}),ref:L},se)}),Qle=function(s){return null};Qle.displayName="Cell";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)}function IPe(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 Fye(t){for(var s=1;s1&&arguments[1]!==void 0?arguments[1]:{};if(s==null||zM.isSsr)return{width:0,height:0};var n=qJt(r),a=JSON.stringify({text:s,copyStyle:n});if(c4.widthCache[a])return c4.widthCache[a];try{var o=document.getElementById(LPe);o||(o=document.createElement("span"),o.setAttribute("id",LPe),o.setAttribute("aria-hidden","true"),document.body.appendChild(o));var l=Fye(Fye({},$Jt),n);Object.assign(o.style,l),o.textContent="".concat(s);var i=o.getBoundingClientRect(),d={width:i.width,height:i.height};return c4.widthCache[a]=d,++c4.cacheCount>BJt&&(c4.cacheCount=0,c4.widthCache={}),d}catch{return{width:0,height:0}}},UJt=function(s){return{top:s.top+window.scrollY-document.documentElement.clientTop,left:s.left+window.scrollX-document.documentElement.clientLeft}};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 Hae(t,s){return GJt(t)||WJt(t,s)||HJt(t,s)||VJt()}function VJt(){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 HJt(t,s){if(t){if(typeof t=="string")return DPe(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 DPe(t,s)}}function DPe(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 oes(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 $Pe(t,s){return ues(t)||des(t,s)||ces(t,s)||les()}function les(){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 ces(t,s){if(t){if(typeof t=="string")return qPe(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 qPe(t,s)}}function qPe(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(ie,ae){var le=ae.word,pe=ae.width,be=ie[ie.length-1];if(be&&(a==null||o||be.width+pe+nae.width?ie:ae})};if(!p)return _;for(var j="…",w=function(de){var ie=g.slice(0,de),ae=$Ye({breakAll:u,style:d,children:ie+j}).wordsWithComputedWidth,le=v(ae),pe=le.length>l||b(le).width>Number(a);return[pe,le]},N=0,C=g.length-1,A=0,I;N<=C&&A<=g.length-1;){var L=Math.floor((N+C)/2),R=L-1,$=w(R),q=$Pe($,2),U=q[0],V=q[1],X=w(L),se=$Pe(X,1),te=se[0];if(!U&&!te&&(N=L+1),U&&te&&(C=L-1),!U&&te){I=V;break}A++}return I||_},UPe=function(s){var r=Zi(s)?[]:s.toString().split(BYe);return[{words:r}]},mes=function(s){var r=s.width,n=s.scaleToFit,a=s.children,o=s.style,l=s.breakAll,i=s.maxLines;if((r||n)&&!zM.isSsr){var d,u,p=$Ye({breakAll:l,children:a,style:o});if(p){var g=p.wordsWithComputedWidth,v=p.spaceWidth;d=g,u=v}else return UPe(a);return hes({breakAll:l,children:a,maxLines:i,style:o},d,u,r,n)}return UPe(a)},VPe="#808080",qN=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,g=p===void 0?!1:p,v=s.textAnchor,_=v===void 0?"start":v,b=s.verticalAnchor,j=b===void 0?"end":b,w=s.fill,N=w===void 0?VPe:w,C=BPe(s,aes),A=S.useMemo(function(){return mes({breakAll:C.breakAll,children:C.children,maxLines:C.maxLines,scaleToFit:g,style:C.style,width:C.width})},[C.breakAll,C.children,C.maxLines,g,C.style,C.width]),I=C.dx,L=C.dy,R=C.angle,$=C.className,q=C.breakAll,U=BPe(C,ies);if(!$d(n)||!$d(o))return null;var V=n+(sn(I)?I:0),X=o+(sn(L)?L:0),se;switch(j){case"start":se=lpe("calc(".concat(u,")"));break;case"middle":se=lpe("calc(".concat((A.length-1)/2," * -").concat(i," + (").concat(u," / 2))"));break;default:se=lpe("calc(".concat(A.length-1," * -").concat(i,")"));break}var te=[];if(g){var Y=A[0].width,de=C.width;te.push("scale(".concat((sn(de)?de/Y:1)/Y,")"))}return R&&te.push("rotate(".concat(R,", ").concat(V,", ").concat(X,")")),te.length&&(U.transform=te.join(" ")),ht.createElement("text",zye({},hi(U,!0),{x:V,y:X,className:Ri("recharts-text",$),textAnchor:_,fill:N.includes("url")?VPe:N}),A.map(function(ie,ae){var le=ie.words.join(q?"":" ");return ht.createElement("tspan",{x:V,dy:ae===0?se:i,key:"".concat(le,"-").concat(ae)},le)}))};function g_(t,s){return t==null||s==null?NaN:ts?1:t>=s?0:NaN}function pes(t,s){return t==null||s==null?NaN:st?1:s>=t?0:NaN}function Kwe(t){let s,r,n;t.length!==2?(s=g_,r=(i,d)=>g_(t(i),d),n=(i,d)=>t(i)-d):(s=t===g_||t===pes?t:fes,r=t,n=t);function a(i,d,u=0,p=i.length){if(u>>1;r(i[g],d)<0?u=g+1:p=g}while(u>>1;r(i[g],d)<=0?u=g+1:p=g}while(uu&&n(i[g-1],d)>-n(i[g],d)?g-1:g}return{left:a,center:l,right:o}}function fes(){return 0}function qYe(t){return t===null?NaN:+t}function*ges(t,s){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const xes=Kwe(g_),eD=xes.right;Kwe(qYe).center;class HPe extends Map{constructor(s,r=_es){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(WPe(this,s))}has(s){return super.has(WPe(this,s))}set(s,r){return super.set(yes(this,s),r)}delete(s){return super.delete(ves(this,s))}}function WPe({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):r}function yes({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function ves({_intern:t,_key:s},r){const n=s(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function _es(t){return t!==null&&typeof t=="object"?t.valueOf():t}function bes(t=g_){if(t===g_)return UYe;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 UYe(t,s){return(t==null||!(t>=t))-(s==null||!(s>=s))||(ts?1:0)}const wes=Math.sqrt(50),jes=Math.sqrt(10),kes=Math.sqrt(2);function Wae(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>=wes?10:o>=jes?5:o>=kes?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 KPe(t,s){let r;for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function VYe(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?UYe:bes(a);n>r;){if(n-r>600){const d=n-r+1,u=s-r+1,p=Math.log(d),g=.5*Math.exp(2*p/3),v=.5*Math.sqrt(p*g*(d-g)/d)*(u-d/2<0?-1:1),_=Math.max(r,Math.floor(s-u*g/d+v)),b=Math.min(n,Math.floor(s+(d-u)*g/d+v));VYe(t,s,_,b,a)}const o=t[s];let l=r,i=n;for(oE(t,r,s),a(t[n],o)>0&&oE(t,r,n);l0;)--i}a(t[r],o)===0?oE(t,r,i):(++i,oE(t,i,n)),i<=s&&(r=i+1),s<=i&&(n=i-1)}return t}function oE(t,s,r){const n=t[s];t[s]=t[r],t[r]=n}function Nes(t,s,r){if(t=Float64Array.from(ges(t)),!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return KPe(t);if(s>=1)return GPe(t);var n,a=(n-1)*s,o=Math.floor(a),l=GPe(VYe(t,o).subarray(0,o+1)),i=KPe(t.subarray(o+1));return l+(i-l)*(a-o)}}function Ses(t,s,r=qYe){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 Ces(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?gR(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):r===4?gR(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=Tes.exec(t))?new km(s[1],s[2],s[3],1):(s=Aes.exec(t))?new km(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=Ees.exec(t))?gR(s[1],s[2],s[3],s[4]):(s=Pes.exec(t))?gR(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=Ies.exec(t))?tIe(s[1],s[2]/100,s[3]/100,1):(s=Les.exec(t))?tIe(s[1],s[2]/100,s[3]/100,s[4]):ZPe.hasOwnProperty(t)?QPe(ZPe[t]):t==="transparent"?new km(NaN,NaN,NaN,0):null}function QPe(t){return new km(t>>16&255,t>>8&255,t&255,1)}function gR(t,s,r,n){return n<=0&&(t=s=r=NaN),new km(t,s,r,n)}function Res(t){return t instanceof tD||(t=C6(t)),t?(t=t.rgb(),new km(t.r,t.g,t.b,t.opacity)):new km}function Vye(t,s,r,n){return arguments.length===1?Res(t):new km(t,s,r,n??1)}function km(t,s,r,n){this.r=+t,this.g=+s,this.b=+r,this.opacity=+n}Ywe(km,Vye,WYe(tD,{brighter(t){return t=t==null?Gae:Math.pow(Gae,t),new km(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?N6:Math.pow(N6,t),new km(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new km(xN(this.r),xN(this.g),xN(this.b),Kae(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:JPe,formatHex:JPe,formatHex8:Fes,formatRgb:eIe,toString:eIe}));function JPe(){return`#${Dk(this.r)}${Dk(this.g)}${Dk(this.b)}`}function Fes(){return`#${Dk(this.r)}${Dk(this.g)}${Dk(this.b)}${Dk((isNaN(this.opacity)?1:this.opacity)*255)}`}function eIe(){const t=Kae(this.opacity);return`${t===1?"rgb(":"rgba("}${xN(this.r)}, ${xN(this.g)}, ${xN(this.b)}${t===1?")":`, ${t})`}`}function Kae(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function xN(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Dk(t){return t=xN(t),(t<16?"0":"")+t.toString(16)}function tIe(t,s,r,n){return n<=0?t=s=r=NaN:r<=0||r>=1?t=s=NaN:s<=0&&(t=NaN),new Tg(t,s,r,n)}function GYe(t){if(t instanceof Tg)return new Tg(t.h,t.s,t.l,t.opacity);if(t instanceof tD||(t=C6(t)),!t)return new Tg;if(t instanceof Tg)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 Tg(l,i,d,t.opacity)}function zes(t,s,r,n){return arguments.length===1?GYe(t):new Tg(t,s,r,n??1)}function Tg(t,s,r,n){this.h=+t,this.s=+s,this.l=+r,this.opacity=+n}Ywe(Tg,zes,WYe(tD,{brighter(t){return t=t==null?Gae:Math.pow(Gae,t),new Tg(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?N6:Math.pow(N6,t),new Tg(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 km(cpe(t>=240?t-240:t+120,a,n),cpe(t,a,n),cpe(t<120?t+240:t-120,a,n),this.opacity)},clamp(){return new Tg(sIe(this.h),xR(this.s),xR(this.l),Kae(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=Kae(this.opacity);return`${t===1?"hsl(":"hsla("}${sIe(this.h)}, ${xR(this.s)*100}%, ${xR(this.l)*100}%${t===1?")":`, ${t})`}`}}));function sIe(t){return t=(t||0)%360,t<0?t+360:t}function xR(t){return Math.max(0,Math.min(1,t||0))}function cpe(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 Xwe=t=>()=>t;function Bes(t,s){return function(r){return t+r*s}}function $es(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 qes(t){return(t=+t)==1?KYe:function(s,r){return r-s?$es(s,r,t):Xwe(isNaN(s)?r:s)}}function KYe(t,s){var r=s-t;return r?Bes(t,r):Xwe(isNaN(t)?s:t)}const rIe=function t(s){var r=qes(s);function n(a,o){var l=r((a=Vye(a)).r,(o=Vye(o)).r),i=r(a.g,o.g),d=r(a.b,o.b),u=KYe(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 Ues(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:Zae(n,a)})),r=dpe.lastIndex;return rs&&(r=t,t=s,s=r),function(n){return Math.max(t,Math.min(s,n))}}function ets(t,s,r){var n=t[0],a=t[1],o=s[0],l=s[1];return a2?tts:ets,d=u=null,g}function g(v){return v==null||isNaN(v=+v)?o:(d||(d=i(t.map(n),s,r)))(n(l(v)))}return g.invert=function(v){return l(a((u||(u=i(s,t.map(n),Zae)))(v)))},g.domain=function(v){return arguments.length?(t=Array.from(v,Yae),p()):t.slice()},g.range=function(v){return arguments.length?(s=Array.from(v),p()):s.slice()},g.rangeRound=function(v){return s=Array.from(v),r=Qwe,p()},g.clamp=function(v){return arguments.length?(l=v?!0:Rh,p()):l!==Rh},g.interpolate=function(v){return arguments.length?(r=v,p()):r},g.unknown=function(v){return arguments.length?(o=v,g):o},function(v,_){return n=v,a=_,p()}}function Jwe(){return Jle()(Rh,Rh)}function sts(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Xae(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 I3(t){return t=Xae(Math.abs(t)),t?t[1]:NaN}function rts(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 nts(t){return function(s){return s.replace(/[0-9]/g,function(r){return t[+r]})}}var ats=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function M6(t){if(!(s=ats.exec(t)))throw new Error("invalid format: "+t);var s;return new e2e({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]})}M6.prototype=e2e.prototype;function e2e(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+""}e2e.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 its(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 ZYe;function ots(t,s){var r=Xae(t,s);if(!r)return t+"";var n=r[0],a=r[1],o=a-(ZYe=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")+Xae(t,Math.max(0,s+o-1))[0]}function aIe(t,s){var r=Xae(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 iIe={"%":(t,s)=>(t*100).toFixed(s),b:t=>Math.round(t).toString(2),c:t=>t+"",d:sts,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)=>aIe(t*100,s),r:aIe,s:ots,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function oIe(t){return t}var lIe=Array.prototype.map,cIe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function lts(t){var s=t.grouping===void 0||t.thousands===void 0?oIe:rts(lIe.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?oIe:nts(lIe.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(g){g=M6(g);var v=g.fill,_=g.align,b=g.sign,j=g.symbol,w=g.zero,N=g.width,C=g.comma,A=g.precision,I=g.trim,L=g.type;L==="n"?(C=!0,L="g"):iIe[L]||(A===void 0&&(A=12),I=!0,L="g"),(w||v==="0"&&_==="=")&&(w=!0,v="0",_="=");var R=j==="$"?r:j==="#"&&/[boxX]/.test(L)?"0"+L.toLowerCase():"",$=j==="$"?n:/[%p]/.test(L)?l:"",q=iIe[L],U=/[defgprs%]/.test(L);A=A===void 0?6:/[gprs]/.test(L)?Math.max(1,Math.min(21,A)):Math.max(0,Math.min(20,A));function V(X){var se=R,te=$,Y,de,ie;if(L==="c")te=q(X)+te,X="";else{X=+X;var ae=X<0||1/X<0;if(X=isNaN(X)?d:q(Math.abs(X),A),I&&(X=its(X)),ae&&+X==0&&b!=="+"&&(ae=!1),se=(ae?b==="("?b:i:b==="-"||b==="("?"":b)+se,te=(L==="s"?cIe[8+ZYe/3]:"")+te+(ae&&b==="("?")":""),U){for(Y=-1,de=X.length;++Yie||ie>57){te=(ie===46?a+X.slice(Y+1):X.slice(Y))+te,X=X.slice(0,Y);break}}}C&&!w&&(X=s(X,1/0));var le=se.length+X.length+te.length,pe=le>1)+se+X+te+pe.slice(le);break;default:X=pe+se+X+te;break}return o(X)}return V.toString=function(){return g+""},V}function p(g,v){var _=u((g=M6(g),g.type="f",g)),b=Math.max(-8,Math.min(8,Math.floor(I3(v)/3)))*3,j=Math.pow(10,-b),w=cIe[8+b/3];return function(N){return _(j*N)+w}}return{format:u,formatPrefix:p}}var yR,t2e,YYe;cts({thousands:",",grouping:[3],currency:["$",""]});function cts(t){return yR=lts(t),t2e=yR.format,YYe=yR.formatPrefix,yR}function dts(t){return Math.max(0,-I3(Math.abs(t)))}function uts(t,s){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(I3(s)/3)))*3-I3(Math.abs(t)))}function hts(t,s){return t=Math.abs(t),s=Math.abs(s)-t,Math.max(0,I3(s)-I3(t))+1}function XYe(t,s,r,n){var a=qye(t,s,r),o;switch(n=M6(n??",f"),n.type){case"s":{var l=Math.max(Math.abs(t),Math.abs(s));return n.precision==null&&!isNaN(o=uts(a,l))&&(n.precision=o),YYe(n,l)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=hts(a,Math.max(Math.abs(t),Math.abs(s))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=dts(a))&&(n.precision=o-(n.type==="%")*2);break}}return t2e(n)}function X_(t){var s=t.domain;return t.ticks=function(r){var n=s();return Bye(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var a=s();return XYe(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=$ye(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 Qae(){var t=Jwe();return t.copy=function(){return sD(t,Qae())},If.apply(t,arguments),X_(t)}function QYe(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,Yae),r):t.slice()},r.unknown=function(n){return arguments.length?(s=n,r):s},r.copy=function(){return QYe(t).unknown(s)},t=arguments.length?Array.from(t,Yae):[0,1],X_(r)}function JYe(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 xts(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 hIe(t){return(s,r)=>-t(-s,r)}function s2e(t){const s=t(dIe,uIe),r=s.domain;let n=10,a,o;function l(){return a=xts(n),o=gts(n),r()[0]<0?(a=hIe(a),o=hIe(o),t(mts,pts)):t(dIe,uIe),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 g=p0){for(;v<=_;++v)for(b=1;bp)break;N.push(j)}}else for(;v<=_;++v)for(b=n-1;b>=1;--b)if(j=v>0?b/o(-v):b*o(v),!(jp)break;N.push(j)}N.length*2{if(i==null&&(i=10),d==null&&(d=n===10?"s":","),typeof d!="function"&&(!(n%1)&&(d=M6(d)).precision==null&&(d.trim=!0),d=t2e(d)),i===1/0)return d;const u=Math.max(1,n*i/s.ticks().length);return p=>{let g=p/o(Math.round(a(p)));return g*nr(JYe(r(),{floor:i=>o(Math.floor(a(i))),ceil:i=>o(Math.ceil(a(i)))})),s}function eXe(){const t=s2e(Jle()).domain([1,10]);return t.copy=()=>sD(t,eXe()).base(t.base()),If.apply(t,arguments),t}function mIe(t){return function(s){return Math.sign(s)*Math.log1p(Math.abs(s/t))}}function pIe(t){return function(s){return Math.sign(s)*Math.expm1(Math.abs(s))*t}}function r2e(t){var s=1,r=t(mIe(s),pIe(s));return r.constant=function(n){return arguments.length?t(mIe(s=+n),pIe(s)):s},X_(r)}function tXe(){var t=r2e(Jle());return t.copy=function(){return sD(t,tXe()).constant(t.constant())},If.apply(t,arguments)}function fIe(t){return function(s){return s<0?-Math.pow(-s,t):Math.pow(s,t)}}function yts(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function vts(t){return t<0?-t*t:t*t}function n2e(t){var s=t(Rh,Rh),r=1;function n(){return r===1?t(Rh,Rh):r===.5?t(yts,vts):t(fIe(r),fIe(1/r))}return s.exponent=function(a){return arguments.length?(r=+a,n()):r},X_(s)}function a2e(){var t=n2e(Jle());return t.copy=function(){return sD(t,a2e()).exponent(t.exponent())},If.apply(t,arguments),t}function _ts(){return a2e.apply(null,arguments).exponent(.5)}function gIe(t){return Math.sign(t)*t*t}function bts(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function sXe(){var t=Jwe(),s=[0,1],r=!1,n;function a(o){var l=bts(t(o));return isNaN(l)?n:r?Math.round(l):l}return a.invert=function(o){return t.invert(gIe(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,Yae)).map(gIe)),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 sXe(t.domain(),s).round(r).clamp(t.clamp()).unknown(n)},If.apply(a,arguments),X_(a)}function rXe(){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 nXe().domain([t,s]).range(a).unknown(o)},If.apply(X_(l),arguments)}function aXe(){var t=[.5],s=[0,1],r,n=1;function a(o){return o!=null&&o<=o?s[eD(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 aXe().domain(t).range(s).unknown(r)},If.apply(a,arguments)}const upe=new Date,hpe=new Date;function Kd(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(uKd(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)=>(upe.setTime(+o),hpe.setTime(+l),t(upe),t(hpe),Math.floor(r(upe,hpe))),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 Jae=Kd(()=>{},(t,s)=>{t.setTime(+t+s)},(t,s)=>s-t);Jae.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Kd(s=>{s.setTime(Math.floor(s/t)*t)},(s,r)=>{s.setTime(+s+r*t)},(s,r)=>(r-s)/t):Jae);Jae.range;const y0=1e3,of=y0*60,v0=of*60,Z0=v0*24,i2e=Z0*7,xIe=Z0*30,mpe=Z0*365,Ok=Kd(t=>{t.setTime(t-t.getMilliseconds())},(t,s)=>{t.setTime(+t+s*y0)},(t,s)=>(s-t)/y0,t=>t.getUTCSeconds());Ok.range;const o2e=Kd(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*y0)},(t,s)=>{t.setTime(+t+s*of)},(t,s)=>(s-t)/of,t=>t.getMinutes());o2e.range;const l2e=Kd(t=>{t.setUTCSeconds(0,0)},(t,s)=>{t.setTime(+t+s*of)},(t,s)=>(s-t)/of,t=>t.getUTCMinutes());l2e.range;const c2e=Kd(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*y0-t.getMinutes()*of)},(t,s)=>{t.setTime(+t+s*v0)},(t,s)=>(s-t)/v0,t=>t.getHours());c2e.range;const d2e=Kd(t=>{t.setUTCMinutes(0,0,0)},(t,s)=>{t.setTime(+t+s*v0)},(t,s)=>(s-t)/v0,t=>t.getUTCHours());d2e.range;const rD=Kd(t=>t.setHours(0,0,0,0),(t,s)=>t.setDate(t.getDate()+s),(t,s)=>(s-t-(s.getTimezoneOffset()-t.getTimezoneOffset())*of)/Z0,t=>t.getDate()-1);rD.range;const ece=Kd(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/Z0,t=>t.getUTCDate()-1);ece.range;const iXe=Kd(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/Z0,t=>Math.floor(t/Z0));iXe.range;function iS(t){return Kd(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())*of)/i2e)}const tce=iS(0),eie=iS(1),wts=iS(2),jts=iS(3),L3=iS(4),kts=iS(5),Nts=iS(6);tce.range;eie.range;wts.range;jts.range;L3.range;kts.range;Nts.range;function oS(t){return Kd(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)/i2e)}const sce=oS(0),tie=oS(1),Sts=oS(2),Cts=oS(3),D3=oS(4),Mts=oS(5),Tts=oS(6);sce.range;tie.range;Sts.range;Cts.range;D3.range;Mts.range;Tts.range;const u2e=Kd(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());u2e.range;const h2e=Kd(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());h2e.range;const Y0=Kd(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());Y0.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Kd(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)});Y0.range;const X0=Kd(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());X0.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Kd(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)});X0.range;function oXe(t,s,r,n,a,o){const l=[[Ok,1,y0],[Ok,5,5*y0],[Ok,15,15*y0],[Ok,30,30*y0],[o,1,of],[o,5,5*of],[o,15,15*of],[o,30,30*of],[a,1,v0],[a,3,3*v0],[a,6,6*v0],[a,12,12*v0],[n,1,Z0],[n,2,2*Z0],[r,1,i2e],[s,1,xIe],[s,3,3*xIe],[t,1,mpe]];function i(u,p,g){const v=pw).right(l,v);if(_===l.length)return t.every(qye(u/mpe,p/mpe,g));if(_===0)return Jae.every(Math.max(qye(u,p,g),1));const[b,j]=l[v/l[_-1][2]53)return null;"w"in De||(De.w=1),"Z"in De?(he=fpe(lE(De.y,0,1)),Ve=he.getUTCDay(),he=Ve>4||Ve===0?tie.ceil(he):tie(he),he=ece.offset(he,(De.V-1)*7),De.y=he.getUTCFullYear(),De.m=he.getUTCMonth(),De.d=he.getUTCDate()+(De.w+6)%7):(he=ppe(lE(De.y,0,1)),Ve=he.getDay(),he=Ve>4||Ve===0?eie.ceil(he):eie(he),he=rD.offset(he,(De.V-1)*7),De.y=he.getFullYear(),De.m=he.getMonth(),De.d=he.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),Ve="Z"in De?fpe(lE(De.y,0,1)).getUTCDay():ppe(lE(De.y,0,1)).getDay(),De.m=0,De.d="W"in De?(De.w+6)%7+De.W*7-(Ve+5)%7:De.w+De.U*7-(Ve+6)%7);return"Z"in De?(De.H+=De.Z/100|0,De.M+=De.Z%100,fpe(De)):ppe(De)}}function q(Ae,Ue,ut,De){for(var Dt=0,he=Ue.length,Ve=ut.length,nt,Qe;Dt=Ve)return-1;if(nt=Ue.charCodeAt(Dt++),nt===37){if(nt=Ue.charAt(Dt++),Qe=L[nt in yIe?Ue.charAt(Dt++):nt],!Qe||(De=Qe(Ae,ut,De))<0)return-1}else if(nt!=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 V(Ae,Ue,ut){var De=_.exec(Ue.slice(ut));return De?(Ae.w=b.get(De[0].toLowerCase()),ut+De[0].length):-1}function X(Ae,Ue,ut){var De=g.exec(Ue.slice(ut));return De?(Ae.w=v.get(De[0].toLowerCase()),ut+De[0].length):-1}function se(Ae,Ue,ut){var De=N.exec(Ue.slice(ut));return De?(Ae.m=C.get(De[0].toLowerCase()),ut+De[0].length):-1}function te(Ae,Ue,ut){var De=j.exec(Ue.slice(ut));return De?(Ae.m=w.get(De[0].toLowerCase()),ut+De[0].length):-1}function Y(Ae,Ue,ut){return q(Ae,s,Ue,ut)}function de(Ae,Ue,ut){return q(Ae,r,Ue,ut)}function ie(Ae,Ue,ut){return q(Ae,n,Ue,ut)}function ae(Ae){return l[Ae.getDay()]}function le(Ae){return o[Ae.getDay()]}function pe(Ae){return d[Ae.getMonth()]}function be(Ae){return i[Ae.getMonth()]}function ye(Ae){return a[+(Ae.getHours()>=12)]}function we(Ae){return 1+~~(Ae.getMonth()/3)}function Ne(Ae){return l[Ae.getUTCDay()]}function Ke(Ae){return o[Ae.getUTCDay()]}function _e(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+="",A);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 yIe={"-":"",_:" ",0:"0"},bu=/^\s*\d+/,Dts=/^%/,Ots=/[\\^$*+?|[\]().{}]/g;function Lo(t,s,r){var n=t<0?"-":"",a=(n?-t:t)+"",o=a.length;return n+(o[s.toLowerCase(),r]))}function Fts(t,s,r){var n=bu.exec(s.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function zts(t,s,r){var n=bu.exec(s.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function Bts(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function $ts(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function qts(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function vIe(t,s,r){var n=bu.exec(s.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function _Ie(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function Uts(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 Vts(t,s,r){var n=bu.exec(s.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function Hts(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function bIe(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Wts(t,s,r){var n=bu.exec(s.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function wIe(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function Gts(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function Kts(t,s,r){var n=bu.exec(s.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function Zts(t,s,r){var n=bu.exec(s.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function Yts(t,s,r){var n=bu.exec(s.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function Xts(t,s,r){var n=Dts.exec(s.slice(r,r+1));return n?r+n[0].length:-1}function Qts(t,s,r){var n=bu.exec(s.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function Jts(t,s,r){var n=bu.exec(s.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function jIe(t,s){return Lo(t.getDate(),s,2)}function ess(t,s){return Lo(t.getHours(),s,2)}function tss(t,s){return Lo(t.getHours()%12||12,s,2)}function sss(t,s){return Lo(1+rD.count(Y0(t),t),s,3)}function lXe(t,s){return Lo(t.getMilliseconds(),s,3)}function rss(t,s){return lXe(t,s)+"000"}function nss(t,s){return Lo(t.getMonth()+1,s,2)}function ass(t,s){return Lo(t.getMinutes(),s,2)}function iss(t,s){return Lo(t.getSeconds(),s,2)}function oss(t){var s=t.getDay();return s===0?7:s}function lss(t,s){return Lo(tce.count(Y0(t)-1,t),s,2)}function cXe(t){var s=t.getDay();return s>=4||s===0?L3(t):L3.ceil(t)}function css(t,s){return t=cXe(t),Lo(L3.count(Y0(t),t)+(Y0(t).getDay()===4),s,2)}function dss(t){return t.getDay()}function uss(t,s){return Lo(eie.count(Y0(t)-1,t),s,2)}function hss(t,s){return Lo(t.getFullYear()%100,s,2)}function mss(t,s){return t=cXe(t),Lo(t.getFullYear()%100,s,2)}function pss(t,s){return Lo(t.getFullYear()%1e4,s,4)}function fss(t,s){var r=t.getDay();return t=r>=4||r===0?L3(t):L3.ceil(t),Lo(t.getFullYear()%1e4,s,4)}function gss(t){var s=t.getTimezoneOffset();return(s>0?"-":(s*=-1,"+"))+Lo(s/60|0,"0",2)+Lo(s%60,"0",2)}function kIe(t,s){return Lo(t.getUTCDate(),s,2)}function xss(t,s){return Lo(t.getUTCHours(),s,2)}function yss(t,s){return Lo(t.getUTCHours()%12||12,s,2)}function vss(t,s){return Lo(1+ece.count(X0(t),t),s,3)}function dXe(t,s){return Lo(t.getUTCMilliseconds(),s,3)}function _ss(t,s){return dXe(t,s)+"000"}function bss(t,s){return Lo(t.getUTCMonth()+1,s,2)}function wss(t,s){return Lo(t.getUTCMinutes(),s,2)}function jss(t,s){return Lo(t.getUTCSeconds(),s,2)}function kss(t){var s=t.getUTCDay();return s===0?7:s}function Nss(t,s){return Lo(sce.count(X0(t)-1,t),s,2)}function uXe(t){var s=t.getUTCDay();return s>=4||s===0?D3(t):D3.ceil(t)}function Sss(t,s){return t=uXe(t),Lo(D3.count(X0(t),t)+(X0(t).getUTCDay()===4),s,2)}function Css(t){return t.getUTCDay()}function Mss(t,s){return Lo(tie.count(X0(t)-1,t),s,2)}function Tss(t,s){return Lo(t.getUTCFullYear()%100,s,2)}function Ass(t,s){return t=uXe(t),Lo(t.getUTCFullYear()%100,s,2)}function Ess(t,s){return Lo(t.getUTCFullYear()%1e4,s,4)}function Pss(t,s){var r=t.getUTCDay();return t=r>=4||r===0?D3(t):D3.ceil(t),Lo(t.getUTCFullYear()%1e4,s,4)}function Iss(){return"+0000"}function NIe(){return"%"}function SIe(t){return+t}function CIe(t){return Math.floor(+t/1e3)}var d4,hXe,mXe;Lss({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 Lss(t){return d4=Lts(t),hXe=d4.format,d4.parse,mXe=d4.utcFormat,d4.utcParse,d4}function Dss(t){return new Date(t)}function Oss(t){return t instanceof Date?+t:+new Date(+t)}function m2e(t,s,r,n,a,o,l,i,d,u){var p=Jwe(),g=p.invert,v=p.domain,_=u(".%L"),b=u(":%S"),j=u("%I:%M"),w=u("%I %p"),N=u("%a %d"),C=u("%b %d"),A=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)=>Nes(t,o/n))},r.copy=function(){return xXe(s).domain(t)},nv.apply(r,arguments)}function nce(){var t=0,s=.5,r=1,n=1,a,o,l,i,d,u=Rh,p,g=!1,v;function _(j){return isNaN(j=+j)?v:(j=.5+((j=+p(j))-o)*(n*js}var bXe=Uss,Vss=ace,Hss=bXe,Wss=FM;function Gss(t){return t&&t.length?Vss(t,Wss,Hss):void 0}var Kss=Gss;const ice=_o(Kss);function Zss(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)*Xl;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 z0(this,new this.constructor(t))};Xn.dividedToIntegerBy=Xn.idiv=function(t){var s=this,r=s.constructor;return gl(z0(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(cp))throw Error(Cf+"NaN");if(r.s<1)throw Error(Cf+(r.s?"NaN":"-Infinity"));return r.eq(cp)?new n(0):(mc=!1,s=z0(T6(r,o),T6(t,o),o),mc=!0,gl(s,a))};Xn.minus=Xn.sub=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?SXe(s,t):kXe(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(Cf+"NaN");return r.s?(mc=!1,s=z0(r,t,0,1).times(t),mc=!0,r.minus(s)):gl(new n(r),a)};Xn.naturalExponential=Xn.exp=function(){return NXe(this)};Xn.naturalLogarithm=Xn.ln=function(){return T6(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?kXe(s,t):SXe(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(yN+t);if(s=Cd(a)+1,n=a.d.length-1,r=n*Xl+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(Cf+"NaN")}for(t=Cd(i),mc=!1,a=Math.sqrt(+i),a==0||a==1/0?(s=Fx(i.d),(s.length+t)%2==0&&(s+="0"),a=Math.sqrt(s),t=qM((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(z0(i,o,l+2)).times(.5),Fx(o.d).slice(0,l)===(s=Fx(n.d)).slice(0,l)){if(s=s.slice(l-3,l+1),a==l&&s=="4999"){if(gl(o,r+1,0),o.times(o).eq(i)){n=o;break}}else if(s!="9999")break;l+=4}return mc=!0,gl(n,r)};Xn.times=Xn.mul=function(t){var s,r,n,a,o,l,i,d,u,p=this,g=p.constructor,v=p.d,_=(t=new g(t)).d;if(!p.s||!t.s)return new g(0);for(t.s*=p.s,r=p.e+t.e,d=v.length,u=_.length,d=0;){for(s=0,a=d+n;a>n;)i=o[a]+_[n]*v[a-n-1]+s,o[a--]=i%ru|0,s=i/ru|0;o[a]=(o[a]+s)%ru|0}for(;!o[--l];)o.pop();return s?++r:o.shift(),t.d=o,t.e=r,mc?gl(t,g.precision):t};Xn.toDecimalPlaces=Xn.todp=function(t,s){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(ly(t,0,$M),s===void 0?s=n.rounding:ly(s,0,8),gl(r,t+Cd(r)+1,s))};Xn.toExponential=function(t,s){var r,n=this,a=n.constructor;return t===void 0?r=UN(n,!0):(ly(t,0,$M),s===void 0?s=a.rounding:ly(s,0,8),n=gl(new a(n),t+1,s),r=UN(n,!0,t+1)),r};Xn.toFixed=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?UN(a):(ly(t,0,$M),s===void 0?s=o.rounding:ly(s,0,8),n=gl(new o(a),t+Cd(a)+1,s),r=UN(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 gl(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(cp);if(i=new d(i),!i.s){if(t.s<1)throw Error(Cf+"Infinity");return i}if(i.eq(cp))return i;if(n=d.precision,t.eq(cp))return gl(i,n);if(s=t.e,r=t.d.length-1,l=s>=r,o=i.s,l){if((r=p<0?-p:p)<=jXe){for(a=new d(cp),s=Math.ceil(n/Xl+4),mc=!1;r%2&&(a=a.times(i),AIe(a.d,s)),r=qM(r/2),r!==0;)i=i.times(i),AIe(i.d,s);return mc=!0,t.s<0?new d(cp).div(a):gl(a,n)}}else if(o<0)throw Error(Cf+"NaN");return o=o<0&&t.d[Math.max(s,r)]&1?-1:1,i.s=1,mc=!1,a=t.times(T6(i,n+u)),mc=!0,a=NXe(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=UN(a,r<=o.toExpNeg||r>=o.toExpPos)):(ly(t,1,$M),s===void 0?s=o.rounding:ly(s,0,8),a=gl(new o(a),t,s),r=Cd(a),n=UN(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):(ly(t,1,$M),s===void 0?s=n.rounding:ly(s,0,8)),gl(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 UN(t,s<=r.toExpNeg||s>=r.toExpPos)};function kXe(t,s){var r,n,a,o,l,i,d,u,p=t.constructor,g=p.precision;if(!t.s||!s.s)return s.s||(s=new p(t)),mc?gl(s,g):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(g/Xl),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)/ru|0,d[o]%=ru;for(r&&(d.unshift(r),++a),i=d.length;d[--i]==0;)d.pop();return s.d=d,s.e=a,mc?gl(s,g):s}function ly(t,s,r){if(t!==~~t||tr)throw Error(yN+t)}function Fx(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,g,v,_,b,j,w,N,C,A,I,L,R,$,q,U=n.constructor,V=n.s==a.s?1:-1,X=n.d,se=a.d;if(!n.s)return new U(n);if(!a.s)throw Error(Cf+"Division by zero");for(d=n.e-a.e,$=se.length,L=X.length,_=new U(V),b=_.d=[],u=0;se[u]==(X[u]||0);)++u;if(se[u]>(X[u]||0)&&--d,o==null?C=o=U.precision:l?C=o+(Cd(n)-Cd(a))+1:C=o,C<0)return new U(0);if(C=C/Xl+2|0,u=0,$==1)for(p=0,se=se[0],C++;(u1&&(se=t(se,p),X=t(X,p),$=se.length,L=X.length),I=$,j=X.slice(0,$),w=j.length;w<$;)j[w++]=0;q=se.slice(),q.unshift(0),R=se[0],se[1]>=ru/2&&++R;do p=0,i=s(se,j,$,w),i<0?(N=j[0],$!=w&&(N=N*ru+(j[1]||0)),p=N/R|0,p>1?(p>=ru&&(p=ru-1),g=t(se,p),v=g.length,w=j.length,i=s(g,j,v,w),i==1&&(p--,r(g,$16)throw Error(g2e+Cd(t));if(!t.s)return new p(cp);for(mc=!1,i=g,l=new p(.03125);t.abs().gte(.1);)t=t.times(l),u+=5;for(n=Math.log(fk(2,u))/Math.LN10*2+5|0,i+=n,r=a=o=new p(cp),p.precision=i;;){if(a=gl(a.times(t),i),r=r.times(++d),l=o.plus(z0(a,r,i)),Fx(l.d).slice(0,i)===Fx(o.d).slice(0,i)){for(;u--;)o=gl(o.times(o),i);return p.precision=g,s==null?(mc=!0,gl(o,g)):o}o=l}}function Cd(t){for(var s=t.e*Xl,r=t.d[0];r>=10;r/=10)s++;return s}function gpe(t,s,r){if(s>t.LN10.sd())throw mc=!0,r&&(t.precision=r),Error(Cf+"LN10 precision limit exceeded");return gl(new t(t.LN10),s)}function m1(t){for(var s="";t--;)s+="0";return s}function T6(t,s){var r,n,a,o,l,i,d,u,p,g=1,v=10,_=t,b=_.d,j=_.constructor,w=j.precision;if(_.s<1)throw Error(Cf+(_.s?"NaN":"-Infinity"));if(_.eq(cp))return new j(0);if(s==null?(mc=!1,u=w):u=s,_.eq(10))return s==null&&(mc=!0),gpe(j,u);if(u+=v,j.precision=u,r=Fx(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=Fx(_.d),n=r.charAt(0),g++;o=Cd(_),n>1?(_=new j("0."+r),o++):_=new j(n+"."+r.slice(1))}else return d=gpe(j,u+2,w).times(o+""),_=T6(new j(n+"."+r.slice(1)),u-v).plus(d),j.precision=w,s==null?(mc=!0,gl(_,w)):_;for(i=l=_=z0(_.minus(cp),_.plus(cp),u),p=gl(_.times(_),u),a=3;;){if(l=gl(l.times(p),u),d=i.plus(z0(l,new j(a),u)),Fx(d.d).slice(0,u)===Fx(i.d).slice(0,u))return i=i.times(2),o!==0&&(i=i.plus(gpe(j,u+2,w).times(o+""))),i=z0(i,new j(g),u),j.precision=w,s==null?(mc=!0,gl(i,w)):i;i=d,a+=2}}function TIe(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=qM(r/Xl),t.d=[],n=(r+1)%Xl,r<0&&(n+=Xl),nsie||t.e<-sie))throw Error(g2e+r)}else t.s=0,t.e=0,t.d=[0];return t}function gl(t,s,r){var n,a,o,l,i,d,u,p,g=t.d;for(l=1,o=g[0];o>=10;o/=10)l++;if(n=s-l,n<0)n+=Xl,a=s,u=g[p=0];else{if(p=Math.ceil((n+1)/Xl),o=g.length,p>=o)return t;for(u=o=g[p],l=1;o>=10;o/=10)l++;n%=Xl,a=n-Xl+l}if(r!==void 0&&(o=fk(10,l-a-1),i=u/o%10|0,d=s<0||g[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/fk(10,l-a):0:g[p-1])%10&1||r==(t.s<0?8:7))),s<1||!g[0])return d?(o=Cd(t),g.length=1,s=s-o-1,g[0]=fk(10,(Xl-s%Xl)%Xl),t.e=qM(-s/Xl)||0):(g.length=1,g[0]=t.e=t.s=0),t;if(n==0?(g.length=p,o=1,p--):(g.length=p+1,o=fk(10,Xl-n),g[p]=a>0?(u/fk(10,l-a)%fk(10,a)|0)*o:0),d)for(;;)if(p==0){(g[0]+=o)==ru&&(g[0]=1,++t.e);break}else{if(g[p]+=o,g[p]!=ru)break;g[p--]=0,o=1}for(n=g.length;g[--n]===0;)g.pop();if(mc&&(t.e>sie||t.e<-sie))throw Error(g2e+Cd(t));return t}function SXe(t,s){var r,n,a,o,l,i,d,u,p,g,v=t.constructor,_=v.precision;if(!t.s||!s.s)return s.s?s.s=-s.s:s=new v(t),mc?gl(s,_):s;if(d=t.d,g=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=g.length):(r=g,n=u,i=d.length),a=Math.max(Math.ceil(_/Xl),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=g.length,p=a0;--a)d[i++]=0;for(a=g.length;a>l;){if(d[--a]0?o=o.charAt(0)+"."+o.slice(1)+m1(n):l>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(a<0?"e":"e+")+a):a<0?(o="0."+m1(-a-1)+o,r&&(n=r-l)>0&&(o+=m1(n))):a>=l?(o+=m1(a+1-l),r&&(n=r-a-1)>0&&(o=o+"."+m1(n))):((n=a+1)0&&(a+1===l&&(o+="."),o+=m1(n))),t.s<0?"-"+o:o}function AIe(t,s){if(t.length>s)return t.length=s,!0}function CXe(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(yN+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 TIe(l,o.toString())}else if(typeof o!="string")throw Error(yN+o);if(o.charCodeAt(0)===45?(o=o.slice(1),l.s=-1):l.s=1,grs.test(o))TIe(l,o);else throw Error(yN+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=CXe,a.config=a.set=xrs,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(yN+r+": "+n);if((n=t[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(yN+r+": "+n);return this}var x2e=CXe(frs);cp=new x2e(1);const ol=x2e;function yrs(t){return wrs(t)||brs(t)||_rs(t)||vrs()}function vrs(){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 _rs(t,s){if(t){if(typeof t=="string")return Gye(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 Gye(t,s)}}function brs(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function wrs(t){if(Array.isArray(t))return Gye(t)}function Gye(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,EIe(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 Rrs(t){if(Array.isArray(t))return t}function PXe(t){var s=A6(t,2),r=s[0],n=s[1],a=r,o=n;return r>n&&(a=n,o=r),[a,o]}function IXe(t,s,r){if(t.lte(0))return new ol(0);var n=dce.getDigitCount(t.toNumber()),a=new ol(10).pow(n),o=t.div(a),l=n!==1?.05:.1,i=new ol(Math.ceil(o.div(l).toNumber())).add(r).mul(l),d=i.mul(a);return s?d:new ol(Math.ceil(d))}function Frs(t,s,r){var n=1,a=new ol(t);if(!a.isint()&&r){var o=Math.abs(t);o<1?(n=new ol(10).pow(dce.getDigitCount(t)-1),a=new ol(Math.floor(a.div(n).toNumber())).mul(n)):o>1&&(a=new ol(Math.floor(t)))}else t===0?a=new ol(Math.floor((s-1)/2)):r||(a=new ol(Math.floor(t)));var l=Math.floor((s-1)/2),i=Srs(Nrs(function(d){return a.add(new ol(d-l).mul(n)).toNumber()}),Kye);return i(0,s)}function LXe(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 ol(0),tickMin:new ol(0),tickMax:new ol(0)};var o=IXe(new ol(s).sub(t).div(r-1),n,a),l;t<=0&&s>=0?l=new ol(0):(l=new ol(t).add(s).div(2),l=l.sub(new ol(l).mod(o)));var i=Math.ceil(l.sub(t).div(o).toNumber()),d=Math.ceil(new ol(s).sub(l).div(o).toNumber()),u=i+d+1;return u>r?LXe(t,s,r,n,a+1):(u0?d+(r-u):d,i=s>0?i:i+(r-u)),{step:o,tickMin:l.sub(new ol(i).mul(o)),tickMax:l.add(new ol(d).mul(o))})}function zrs(t){var s=A6(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=PXe([r,n]),d=A6(i,2),u=d[0],p=d[1];if(u===-1/0||p===1/0){var g=p===1/0?[u].concat(Yye(Kye(0,a-1).map(function(){return 1/0}))):[].concat(Yye(Kye(0,a-1).map(function(){return-1/0})),[p]);return r>n?Zye(g):g}if(u===p)return Frs(u,a,o);var v=LXe(u,p,l,o),_=v.step,b=v.tickMin,j=v.tickMax,w=dce.rangeStep(b,j.add(new ol(.1).mul(_)),_);return r>n?Zye(w):w}function Brs(t,s){var r=A6(t,2),n=r[0],a=r[1],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=PXe([n,a]),i=A6(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),g=IXe(new ol(u).sub(d).div(p-1),o,0),v=[].concat(Yye(dce.rangeStep(new ol(d),new ol(u).sub(new ol(.99).mul(g)),g)),[u]);return n>a?Zye(v):v}var $rs=AXe(zrs),qrs=AXe(Brs),Urs="Invariant failed";function VN(t,s){throw new Error(Urs)}var Vrs=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function O3(t){"@babel/helpers - typeof";return O3=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},O3(t)}function rie(){return rie=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 Xrs(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 Qrs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Jrs(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,g=a[u].coordinate,v=u>=i-1?a[0].coordinate:a[u+1].coordinate,_=void 0;if(Dh(g-p)!==Dh(v-g)){var b=[];if(Dh(v-g)===Dh(d[1]-d[0])){_=v;var j=g+d[1]-d[0];b[0]=Math.min(j,(j+p)/2),b[1]=Math.max(j,(j+p)/2)}else{_=p;var w=v+d[1]-d[0];b[0]=Math.min(g,(w+g)/2),b[1]=Math.max(g,(w+g)/2)}var N=[Math.min(g,(_+g)/2),Math.max(g,(_+g)/2)];if(s>N[0]&&s<=N[1]||s>=b[0]&&s<=b[1]){l=a[u].index;break}}else{var C=Math.min(p,v),A=Math.max(p,v);if(s>(C+g)/2&&s<=(A+g)/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},y2e=function(s){var r,n=s,a=n.type.displayName,o=(r=s.type)!==null&&r!==void 0&&r.defaultProps?Fc(Fc({},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},gns=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(N&&N.length){var C=N[0].type.defaultProps,A=C!==void 0?Fc(Fc({},C),N[0].props):N[0].props,I=A.barSize,L=A[w];l[L]||(l[L]=[]);var R=Zi(I)?r:I;l[L].push({item:N[0],stackList:N.slice(1),barSize:Zi(R)?void 0:Oh(R,n,0)})}}return l},xns=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=Oh(r,a,0,!0),p,g=[];if(l[0].barSize===+l[0].barSize){var v=!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&&(v=!0,_*=.9,b=d*_);var j=(a-b)/2>>0,w={offset:j-u,size:0};p=l.reduce(function(I,L){var R={item:L.item,position:{offset:w.offset+w.size+u,size:v?_:L.barSize}},$=[].concat(LIe(I),[R]);return w=$[$.length-1].position,L.stackList&&L.stackList.length&&L.stackList.forEach(function(q){$.push({item:q,position:w})}),$},g)}else{var N=Oh(n,a,0,!0);a-2*N-(d-1)*u<=0&&(u=0);var C=(a-2*N-(d-1)*u)/d;C>1&&(C>>=0);var A=i===+i?Math.min(C,i):C;p=l.reduce(function(I,L,R){var $=[].concat(LIe(I),[{item:L.item,position:{offset:N+(C+u)*R+(C-A)/2,size:A}}]);return L.stackList&&L.stackList.length&&L.stackList.forEach(function(q){$.push({item:q,position:$[$.length-1].position})}),$},g)}return p},yns=function(s,r,n,a){var o=n.children,l=n.width,i=n.margin,d=l-(i.left||0)-(i.right||0),u=FXe({children:o,legendWidth:d});if(u){var p=a||{},g=p.width,v=p.height,_=u.align,b=u.verticalAlign,j=u.layout;if((j==="vertical"||j==="horizontal"&&b==="middle")&&_!=="center"&&sn(s[_]))return Fc(Fc({},s),{},z5({},_,s[_]+(g||0)));if((j==="horizontal"||j==="vertical"&&_==="center")&&b!=="middle"&&sn(s[b]))return Fc(Fc({},s),{},z5({},b,s[b]+(v||0)))}return s},vns=function(s,r,n){return Zi(r)?!0:s==="horizontal"?r==="yAxis":s==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},zXe=function(s,r,n,a,o){var l=r.props.children,i=vf(l,uce).filter(function(u){return vns(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 g=Qu(p,n);if(Zi(g))return u;var v=Array.isArray(g)?[oce(g),ice(g)]:[g,g],_=d.reduce(function(b,j){var w=Qu(p,j,0),N=v[0]-Math.abs(Array.isArray(w)?w[0]:w),C=v[1]+Math.abs(Array.isArray(w)?w[1]:w);return[Math.min(N,b[0]),Math.max(C,b[1])]},[1/0,-1/0]);return[Math.min(_[0],u[0]),Math.max(_[1],u[1])]},[1/0,-1/0])}return null},_ns=function(s,r,n,a,o){var l=r.map(function(i){return zXe(s,i,n,o,a)}).filter(function(i){return!Zi(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},BXe=function(s,r,n,a,o){var l=r.map(function(d){var u=d.props.dataKey;return n==="number"&&u&&zXe(s,d,u,a)||pI(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,g=u.length;p=2?Dh(i[0]-i[1])*2*u:u,r&&(s.ticks||s.niceTicks)){var p=(s.ticks||s.niceTicks).map(function(g){var v=o?o.indexOf(g):g;return{coordinate:a(v)+u,value:g,offset:u}});return p.filter(function(g){return!XL(g.coordinate)})}return s.isCategorical&&s.categoricalDomain?s.categoricalDomain.map(function(g,v){return{coordinate:a(g)+u,value:g,index:v,offset:u}}):a.ticks&&!n?a.ticks(s.tickCount).map(function(g){return{coordinate:a(g)+u,value:g,offset:u}}):a.domain().map(function(g,v){return{coordinate:a(g)+u,value:o?o[g]:g,index:v,offset:u}})},xpe=new WeakMap,vR=function(s,r){if(typeof r!="function")return s;xpe.has(s)||xpe.set(s,new WeakMap);var n=xpe.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},UXe=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:k6(),realScaleType:"band"}:l==="radial"&&i==="angleAxis"?{scale:Qae(),realScaleType:"linear"}:o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:mI(),realScaleType:"point"}:o==="category"?{scale:k6(),realScaleType:"band"}:{scale:Qae(),realScaleType:"linear"};if(BN(a)){var d="scale".concat(Hle(a));return{scale:(MIe[d]||mI)(),realScaleType:MIe[d]?d:"point"}}return _i(a)?{scale:a}:{scale:mI(),realScaleType:"point"}},OIe=1e-4,VXe=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])-OIe,l=Math.max(a[0],a[1])+OIe,i=s(r[0]),d=s(r[n-1]);(il||dl)&&s.domain([r[0],r[n-1]])}},bns=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])}},kns=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)}},Nns={sign:jns,expand:VVt,none:M3,silhouette:HVt,wiggle:WVt,positive:kns},Sns=function(s,r,n){var a=r.map(function(i){return i.props.dataKey}),o=Nns[n],l=UVt().keys(a).value(function(i,d){return+Qu(i,d,0)}).order(jye).offset(o);return l(s)},Cns=function(s,r,n,a,o,l){if(!s)return null;var i=l?r.reverse():r,d={},u=i.reduce(function(g,v){var _,b=(_=v.type)!==null&&_!==void 0&&_.defaultProps?Fc(Fc({},v.type.defaultProps),v.props):v.props,j=b.stackId,w=b.hide;if(w)return g;var N=b[n],C=g[N]||{hasStack:!1,stackGroups:{}};if($d(j)){var A=C.stackGroups[j]||{numericAxisId:n,cateAxisId:a,items:[]};A.items.push(v),C.hasStack=!0,C.stackGroups[j]=A}else C.stackGroups[QL("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[v]};return Fc(Fc({},g),{},z5({},N,C))},d),p={};return Object.keys(u).reduce(function(g,v){var _=u[v];if(_.hasStack){var b={};_.stackGroups=Object.keys(_.stackGroups).reduce(function(j,w){var N=_.stackGroups[w];return Fc(Fc({},j),{},z5({},w,{numericAxisId:n,cateAxisId:a,items:N.items,stackedData:Sns(s,N.items,o)}))},b)}return Fc(Fc({},g),{},z5({},v,_))},p)},HXe=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=$rs(u,o,i);return s.domain([oce(p),ice(p)]),{niceTicks:p}}if(o&&a==="number"){var g=s.domain(),v=qrs(g,o,i);return{niceTicks:v}}return null},RIe=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=Qu(l,r.dataKey,r.domain[i]);return Zi(d)?null:r.scale(d)-o/2+a},Mns=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]},Tns=function(s,r){var n,a=(n=s.type)!==null&&n!==void 0&&n.defaultProps?Fc(Fc({},s.type.defaultProps),s.props):s.props,o=a.stackId;if($d(o)){var l=r[o];if(l){var i=l.items.indexOf(s);return i>=0?l.stackedData[i]:null}}return null},Ans=function(s){return s.reduce(function(r,n){return[oce(n.concat([r[0]]).filter(sn)),ice(n.concat([r[1]]).filter(sn))]},[1/0,-1/0])},WXe=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 g=Ans(p.slice(r,n+1));return[Math.min(u[0],g[0]),Math.max(u[1],g[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})},FIe=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,zIe=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,e0e=function(s,r,n){if(_i(s))return s(r,n);if(!Array.isArray(s))return r;var a=[];if(sn(s[0]))a[0]=n?s[0]:Math.min(s[0],r[0]);else if(FIe.test(s[0])){var o=+FIe.exec(s[0])[1];a[0]=r[0]-o}else _i(s[0])?a[0]=s[0](r[0]):a[0]=r[0];if(sn(s[1]))a[1]=n?s[1]:Math.max(s[1],r[1]);else if(zIe.test(s[1])){var l=+zIe.exec(s[1])[1];a[1]=r[1]+l}else _i(s[1])?a[1]=s[1](r[1]):a[1]=r[1];return a},aie=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=Wwe(r,function(g){return g.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},zns=function(s,r,n,a,o){var l=s.width,i=s.height,d=s.startAngle,u=s.endAngle,p=Oh(s.cx,l,l/2),g=Oh(s.cy,i,i/2),v=ZXe(l,i,n),_=Oh(s.innerRadius,v,0),b=Oh(s.outerRadius,v,v*.8),j=Object.keys(r);return j.reduce(function(w,N){var C=r[N],A=C.domain,I=C.reversed,L;if(Zi(C.range))a==="angleAxis"?L=[d,u]:a==="radiusAxis"&&(L=[_,b]),I&&(L=[L[1],L[0]]);else{L=C.range;var R=L,$=Ins(R,2);d=$[0],u=$[1]}var q=UXe(C,o),U=q.realScaleType,V=q.scale;V.domain(A).range(L),VXe(V);var X=HXe(V,s0(s0({},C),{},{realScaleType:U})),se=s0(s0(s0({},C),X),{},{range:L,radius:b,realScaleType:U,scale:V,cx:p,cy:g,innerRadius:_,outerRadius:b,startAngle:d,endAngle:u});return s0(s0({},w),{},KXe({},N,se))},{})},Bns=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))},$ns=function(s,r){var n=s.x,a=s.y,o=r.cx,l=r.cy,i=Bns({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:Fns(u),angleInRadian:u}},qns=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}},Uns=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},UIe=function(s,r){var n=s.x,a=s.y,o=$ns({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=qns(r),g=p.startAngle,v=p.endAngle,_=i,b;if(g<=v){for(;_>v;)_-=360;for(;_=g&&_<=v}else{for(;_>g;)_-=360;for(;_=v&&_<=g}return b?s0(s0({},r),{},{radius:l,angle:Uns(_,r)}):null},YXe=function(s){return!S.isValidElement(s)&&!_i(s)&&typeof s!="boolean"?s.className:""};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)}var Vns=["offset"];function Hns(t){return Zns(t)||Kns(t)||Gns(t)||Wns()}function Wns(){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 Gns(t,s){if(t){if(typeof t=="string")return t0e(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 t0e(t,s)}}function Kns(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Zns(t){if(Array.isArray(t))return t0e(t)}function t0e(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 Xns(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 VIe(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 Pd(t){for(var s=1;s=0?1:-1,A,I;a==="insideStart"?(A=_+C*l,I=j):a==="insideEnd"?(A=b-C*l,I=!j):a==="end"&&(A=b+C*l,I=j),I=N<=0?I:!I;var L=Dl(u,p,w,A),R=Dl(u,p,w,A+(I?1:-1)*359),$="M".concat(L.x,",").concat(L.y,` A`).concat(w,",").concat(w,",0,1,").concat(I?0:1,`, `).concat(R.x,",").concat(R.y),q=Zi(s.id)?QL("recharts-radial-line-"):s.id;return ht.createElement("text",D6({},n,{dominantBaseline:"central",className:Ri("recharts-radial-bar-label",i)}),ht.createElement("defs",null,ht.createElement("path",{id:q,d:$})),ht.createElement("textPath",{xlinkHref:"#".concat(q)},r))},nas=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,g=o.endAngle,v=(p+g)/2;if(a==="outside"){var _=Dl(l,i,u+n,v),b=_.x,j=_.y;return{x:b,y:j,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 w=(d+u)/2,N=Dl(l,i,w,v),C=N.x,A=N.y;return{x:C,y:A,textAnchor:"middle",verticalAnchor:"middle"}},aas=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,g=p>=0?1:-1,v=g*a,_=g>0?"end":"start",b=g>0?"start":"end",j=u>=0?1:-1,w=j*a,N=j>0?"end":"start",C=j>0?"start":"end";if(o==="top"){var A={x:i+u/2,y:d-g*a,textAnchor:"middle",verticalAnchor:_};return Pd(Pd({},A),n?{height:Math.max(d-n.y,0),width:u}:{})}if(o==="bottom"){var I={x:i+u/2,y:d+p+v,textAnchor:"middle",verticalAnchor:b};return Pd(Pd({},I),n?{height:Math.max(n.y+n.height-(d+p),0),width:u}:{})}if(o==="left"){var L={x:i-w,y:d+p/2,textAnchor:N,verticalAnchor:"middle"};return Pd(Pd({},L),n?{width:Math.max(L.x-n.x,0),height:p}:{})}if(o==="right"){var R={x:i+u+w,y:d+p/2,textAnchor:C,verticalAnchor:"middle"};return Pd(Pd({},R),n?{width:Math.max(n.x+n.width-R.x,0),height:p}:{})}var $=n?{width:u,height:p}:{};return o==="insideLeft"?Pd({x:i+w,y:d+p/2,textAnchor:C,verticalAnchor:"middle"},$):o==="insideRight"?Pd({x:i+u-w,y:d+p/2,textAnchor:N,verticalAnchor:"middle"},$):o==="insideTop"?Pd({x:i+u/2,y:d+v,textAnchor:"middle",verticalAnchor:b},$):o==="insideBottom"?Pd({x:i+u/2,y:d+p-v,textAnchor:"middle",verticalAnchor:_},$):o==="insideTopLeft"?Pd({x:i+w,y:d+v,textAnchor:C,verticalAnchor:b},$):o==="insideTopRight"?Pd({x:i+u-w,y:d+v,textAnchor:N,verticalAnchor:b},$):o==="insideBottomLeft"?Pd({x:i+w,y:d+p-v,textAnchor:C,verticalAnchor:_},$):o==="insideBottomRight"?Pd({x:i+u-w,y:d+p-v,textAnchor:N,verticalAnchor:_},$):PM(o)&&(sn(o.x)||Lk(o.x))&&(sn(o.y)||Lk(o.y))?Pd({x:i+Oh(o.x,u),y:d+Oh(o.y,p),textAnchor:"end",verticalAnchor:"end"},$):Pd({x:i+u/2,y:d+p/2,textAnchor:"middle",verticalAnchor:"middle"},$)},ias=function(s){return"cx"in s&&sn(s.cx)};function lu(t){var s=t.offset,r=s===void 0?5:s,n=Yns(t,Vns),a=Pd({offset:r},n),o=a.viewBox,l=a.position,i=a.value,d=a.children,u=a.content,p=a.className,g=p===void 0?"":p,v=a.textBreakAll;if(!o||Zi(i)&&Zi(d)&&!S.isValidElement(u)&&!_i(u))return null;if(S.isValidElement(u))return S.cloneElement(u,a);var _;if(_i(u)){if(_=S.createElement(u,a),S.isValidElement(_))return _}else _=tas(a);var b=ias(o),j=hi(a,!0);if(b&&(l==="insideStart"||l==="insideEnd"||l==="end"))return ras(a,_,j);var w=b?nas(a):aas(a);return ht.createElement(qN,D6({className:Ri("recharts-label",g)},j,w,{breakAll:v}),_)}lu.displayName="Label";var XXe=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,g=s.x,v=s.y,_=s.top,b=s.left,j=s.width,w=s.height,N=s.clockWise,C=s.labelViewBox;if(C)return C;if(sn(j)&&sn(w)){if(sn(g)&&sn(v))return{x:g,y:v,width:j,height:w};if(sn(_)&&sn(b))return{x:_,y:b,width:j,height:w}}return sn(g)&&sn(v)?{x:g,y:v,width:0,height:0}:sn(r)&&sn(n)?{cx:r,cy:n,startAngle:o||a||0,endAngle:l||a||0,innerRadius:u||0,outerRadius:p||d||i||0,clockWise:N}:s.viewBox?s.viewBox:{}},oas=function(s,r){return s?s===!0?ht.createElement(lu,{key:"label-implicit",viewBox:r}):$d(s)?ht.createElement(lu,{key:"label-implicit",viewBox:r,value:s}):S.isValidElement(s)?s.type===lu?S.cloneElement(s,{key:"label-implicit",viewBox:r}):ht.createElement(lu,{key:"label-implicit",content:s,viewBox:r}):_i(s)?ht.createElement(lu,{key:"label-implicit",content:s,viewBox:r}):PM(s)?ht.createElement(lu,D6({viewBox:r},s,{key:"label-implicit"})):null:null},las=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=XXe(s),l=vf(a,lu).map(function(d,u){return S.cloneElement(d,{viewBox:r||o,key:"label-".concat(u)})});if(!n)return l;var i=oas(s.label,r||o);return[i].concat(Hns(l))};lu.parseViewBox=XXe;lu.renderCallByParent=las;function cas(t){var s=t==null?0:t.length;return s?t[s-1]:void 0}var das=cas;const uas=_o(das);function O6(t){"@babel/helpers - typeof";return O6=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},O6(t)}var has=["valueAccessor"],mas=["data","dataKey","clockWise","id","textBreakAll"];function pas(t){return yas(t)||xas(t)||gas(t)||fas()}function fas(){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 gas(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 xas(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function yas(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=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function was(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 jas=function(s){return Array.isArray(s.value)?uas(s.value):s.value};function x_(t){var s=t.valueAccessor,r=s===void 0?jas:s,n=GIe(t,has),a=n.data,o=n.dataKey,l=n.clockWise,i=n.id,d=n.textBreakAll,u=GIe(n,mas);return!a||!a.length?null:ht.createElement(tl,{className:"recharts-label-list"},a.map(function(p,g){var v=Zi(o)?r(p,g):Qu(p&&p.payload,o),_=Zi(i)?{}:{id:"".concat(i,"-").concat(g)};return ht.createElement(lu,oie({},hi(p,!0),u,_,{parentViewBox:p.parentViewBox,value:v,textBreakAll:d,viewBox:lu.parseViewBox(Zi(l)?p:WIe(WIe({},p),{},{clockWise:l})),key:"label-".concat(g),index:g}))}))}x_.displayName="LabelList";function kas(t,s){return t?t===!0?ht.createElement(x_,{key:"labelList-implicit",data:s}):ht.isValidElement(t)||_i(t)?ht.createElement(x_,{key:"labelList-implicit",data:s,content:t}):PM(t)?ht.createElement(x_,oie({data:s},t,{key:"labelList-implicit"})):null:null}function Nas(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=vf(n,x_).map(function(l,i){return S.cloneElement(l,{data:s,key:"labelList-".concat(i)})});if(!r)return a;var o=kas(t.label,s);return[o].concat(pas(a))}x_.renderCallByParent=Nas;function R6(t){"@babel/helpers - typeof";return R6=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},R6(t)}function r0e(){return r0e=Object.assign?Object.assign.bind():function(t){for(var s=1;s180),",").concat(+(l>u),`, `).concat(g.x,",").concat(g.y,` `);if(a>0){var _=Dl(r,n,a,l),b=Dl(r,n,a,u);v+="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 v+="L ".concat(r,",").concat(n," Z");return v},Aas=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,g=Dh(p-u),v=_R({cx:r,cy:n,radius:o,angle:u,sign:g,cornerRadius:l,cornerIsExternal:d}),_=v.circleTangency,b=v.lineTangency,j=v.theta,w=_R({cx:r,cy:n,radius:o,angle:p,sign:-g,cornerRadius:l,cornerIsExternal:d}),N=w.circleTangency,C=w.lineTangency,A=w.theta,I=d?Math.abs(u-p):Math.abs(u-p)-j-A;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 `):QXe({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(+(g<0),",").concat(_.x,",").concat(_.y,` A`).concat(o,",").concat(o,",0,").concat(+(I>180),",").concat(+(g<0),",").concat(N.x,",").concat(N.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(g<0),",").concat(C.x,",").concat(C.y,` `);if(a>0){var R=_R({cx:r,cy:n,radius:a,angle:u,sign:g,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),$=R.circleTangency,q=R.lineTangency,U=R.theta,V=_R({cx:r,cy:n,radius:a,angle:p,sign:-g,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),X=V.circleTangency,se=V.lineTangency,te=V.theta,Y=d?Math.abs(u-p):Math.abs(u-p)-U-te;if(Y<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(+(g<0),",").concat(X.x,",").concat(X.y,` A`).concat(a,",").concat(a,",0,").concat(+(Y>180),",").concat(+(g>0),",").concat($.x,",").concat($.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(g<0),",").concat(q.x,",").concat(q.y,"Z")}else L+="L".concat(r,",").concat(n,"Z");return L},Eas={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},JXe=function(s){var r=ZIe(ZIe({},Eas),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,g=r.endAngle,v=r.className;if(l0&&Math.abs(p-g)<360?w=Aas({cx:n,cy:a,innerRadius:o,outerRadius:l,cornerRadius:Math.min(j,b/2),forceCornerRadius:d,cornerIsExternal:u,startAngle:p,endAngle:g}):w=QXe({cx:n,cy:a,innerRadius:o,outerRadius:l,startAngle:p,endAngle:g}),ht.createElement("path",r0e({},hi(r,!0),{className:_,d:w,role:"img"}))};function F6(t){"@babel/helpers - typeof";return F6=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},F6(t)}function n0e(){return n0e=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 Yas(t,s){return lS(t.getTime(),s.getTime())}function Xas(t,s){return t.name===s.name&&t.message===s.message&&t.cause===s.cause&&t.stack===s.stack}function Qas(t,s){return t===s}function r6e(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,g=0;(i=u.next())&&!i.done;){if(a[g]){g++;continue}var v=l.value,_=i.value;if(r.equals(v[0],_[0],d,g,t,s,r)&&r.equals(v[1],_[1],v[0],_[0],t,s,r)){p=a[g]=!0;break}g++}if(!p)return!1;d++}return!0}var Jas=lS;function eis(t,s,r){var n=s6e(t),a=n.length;if(s6e(s).length!==a)return!1;for(;a-- >0;)if(!rQe(t,s,r,n[a]))return!1;return!0}function mE(t,s,r){var n=e6e(t),a=n.length;if(e6e(s).length!==a)return!1;for(var o,l,i;a-- >0;)if(o=n[a],!rQe(t,s,r,o)||(l=t6e(t,o),i=t6e(s,o),(l||i)&&(!l||!i||l.configurable!==i.configurable||l.enumerable!==i.enumerable||l.writable!==i.writable)))return!1;return!0}function tis(t,s){return lS(t.valueOf(),s.valueOf())}function sis(t,s){return t.source===s.source&&t.flags===s.flags}function n6e(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 ris(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 nis(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 rQe(t,s,r,n){return(n===Kas||n===Gas||n===Was)&&(t.$$typeof||s.$$typeof)?!0:Has(s,n)&&r.equals(t[n],s[n],n,n,t,s,r)}var ais="[object Arguments]",iis="[object Boolean]",ois="[object Date]",lis="[object Error]",cis="[object Map]",dis="[object Number]",uis="[object Object]",his="[object RegExp]",mis="[object Set]",pis="[object String]",fis="[object URL]",gis=Array.isArray,a6e=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,i6e=Object.assign,xis=Object.prototype.toString.call.bind(Object.prototype.toString);function yis(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,g=t.areTypedArraysEqual,v=t.areUrlsEqual;return function(b,j,w){if(b===j)return!0;if(b==null||j==null)return!1;var N=typeof b;if(N!==typeof j)return!1;if(N!=="object")return N==="number"?l(b,j,w):N==="function"?a(b,j,w):!1;var C=b.constructor;if(C!==j.constructor)return!1;if(C===Object)return i(b,j,w);if(gis(b))return s(b,j,w);if(a6e!=null&&a6e(b))return g(b,j,w);if(C===Date)return r(b,j,w);if(C===RegExp)return u(b,j,w);if(C===Map)return o(b,j,w);if(C===Set)return p(b,j,w);var A=xis(b);return A===ois?r(b,j,w):A===his?u(b,j,w):A===cis?o(b,j,w):A===mis?p(b,j,w):A===uis?typeof b.then!="function"&&typeof j.then!="function"&&i(b,j,w):A===fis?v(b,j,w):A===lis?n(b,j,w):A===ais?i(b,j,w):A===iis||A===dis||A===pis?d(b,j,w):!1}}function vis(t){var s=t.circular,r=t.createCustomConfig,n=t.strict,a={areArraysEqual:n?mE:Zas,areDatesEqual:Yas,areErrorsEqual:Xas,areFunctionsEqual:Qas,areMapsEqual:n?JIe(r6e,mE):r6e,areNumbersEqual:Jas,areObjectsEqual:n?mE:eis,arePrimitiveWrappersEqual:tis,areRegExpsEqual:sis,areSetsEqual:n?JIe(n6e,mE):n6e,areTypedArraysEqual:n?mE:ris,areUrlsEqual:nis};if(r&&(a=i6e({},a,r(a))),s){var o=wR(a.areArraysEqual),l=wR(a.areMapsEqual),i=wR(a.areObjectsEqual),d=wR(a.areSetsEqual);a=i6e({},a,{areArraysEqual:o,areMapsEqual:l,areObjectsEqual:i,areSetsEqual:d})}return a}function _is(t){return function(s,r,n,a,o,l,i){return t(s,r,i)}}function bis(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(),g=p.cache,v=g===void 0?s?new WeakMap:void 0:g,_=p.meta;return r(d,u,{cache:v,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 wis=J_();J_({strict:!0});J_({circular:!0});J_({circular:!0,strict:!0});J_({createInternalComparator:function(){return lS}});J_({strict:!0,createInternalComparator:function(){return lS}});J_({circular:!0,createInternalComparator:function(){return lS}});J_({circular:!0,createInternalComparator:function(){return lS},strict:!0});function J_(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=vis(t),d=yis(i),u=n?n(d):_is(d);return bis({circular:r,comparator:d,createState:a,equals:u,strict:l})}function jis(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function o6e(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):jis(a)};requestAnimationFrame(n)}function i0e(t){"@babel/helpers - typeof";return i0e=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},i0e(t)}function kis(t){return Mis(t)||Cis(t)||Sis(t)||Nis()}function Nis(){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 Sis(t,s){if(t){if(typeof t=="string")return l6e(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 l6e(t,s)}}function l6e(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:N<0?0:N},j=function(N){for(var C=N>1?1:N,A=C,I=0;I<8;++I){var L=g(A)-C,R=_(A);if(Math.abs(L-C)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,g,v){var _=-(p-g)*n,b=v*o,j=v+(_-b)*i/1e3,w=v*i/1e3+p;return Math.abs(w-g)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 aos(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 ype(t){return cos(t)||los(t)||oos(t)||ios()}function ios(){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 oos(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 los(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function cos(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"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 die(t){return die=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},die(t)}var Q0=function(t){pos(r,t);var s=fos(r);function r(n,a){var o;dos(this,r),o=s.call(this,n,a);var l=o.props,i=l.isActive,d=l.attributeName,u=l.from,p=l.to,g=l.steps,v=l.children,_=l.duration;if(o.handleStyleChange=o.handleStyleChange.bind(p0e(o)),o.changeStyle=o.changeStyle.bind(p0e(o)),!i||_<=0)return o.state={style:{}},typeof v=="function"&&(o.state={style:p}),m0e(o);if(g&&g.length)o.state={style:g[0].style};else if(u){if(typeof v=="function")return o.state={style:u},m0e(o);o.state={style:d?IE({},d,u):u}}else o.state={style:{}};return o}return hos(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,g=o.from,v=this.state.style;if(i){if(!l){var _={style:d?IE({},d,p):p};this.state&&v&&(d&&v[d]!==p||!d&&v!==p)&&this.setState(_);return}if(!(wis(a.to,p)&&a.canBegin&&a.isActive)){var b=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var j=b||u?g:a.to;if(this.state&&v){var w={style:d?IE({},d,j):j};(d&&v[d]!==j||!d&&v!==j)&&this.setState(w)}this.runAnimation(dg(dg({},this.props),{},{from:j,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,g=a.onAnimationEnd,v=a.onAnimationStart,_=sos(l,i,His(u),d,this.changeStyle),b=function(){o.stopJSAnimation=_()};this.manager.start([v,p,b,d,g])}},{key:"runStepAnimation",value:function(a){var o=this,l=a.steps,i=a.begin,d=a.onAnimationStart,u=l[0],p=u.style,g=u.duration,v=g===void 0?0:g,_=function(j,w,N){if(N===0)return j;var C=w.duration,A=w.easing,I=A===void 0?"ease":A,L=w.style,R=w.properties,$=w.onAnimationEnd,q=N>0?l[N-1]:w,U=R||Object.keys(L);if(typeof I=="function"||I==="spring")return[].concat(ype(j),[o.runJSAnimation.bind(o,{from:q.style,to:L,duration:C,easing:I}),C]);var V=u6e(U,C,I),X=dg(dg(dg({},q.style),L),{},{transition:V});return[].concat(ype(j),[X,C,$]).filter(Iis)};return this.manager.start([d].concat(ype(l.reduce(_,[p,Math.max(v,i)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=Tis());var o=a.begin,l=a.duration,i=a.attributeName,d=a.to,u=a.easing,p=a.onAnimationStart,g=a.onAnimationEnd,v=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(v.length>1){this.runStepAnimation(a);return}var j=i?IE({},i,d):d,w=u6e(Object.keys(j),l,u);b.start([p,o,dg(dg({},j),{},{transition:w}),l,g])}},{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=nos(a,ros),u=S.Children.count(o),p=this.state.style;if(typeof o=="function")return o(p);if(!i||u===0||l<=0)return o;var g=function(_){var b=_.props,j=b.style,w=j===void 0?{}:j,N=b.className,C=S.cloneElement(_,dg(dg({},d),{},{style:dg(dg({},w),p),className:N}));return C};return u===1?g(S.Children.only(o)):ht.createElement("div",null,S.Children.map(o,function(v){return g(v)}))}}]),r}(S.PureComponent);Q0.displayName="Animate";Q0.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};Q0.propTypes={from:qo.oneOfType([qo.object,qo.string]),to:qo.oneOfType([qo.object,qo.string]),attributeName:qo.string,duration:qo.number,begin:qo.number,easing:qo.oneOfType([qo.string,qo.func]),steps:qo.arrayOf(qo.shape({duration:qo.number.isRequired,style:qo.object.isRequired,easing:qo.oneOfType([qo.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),qo.func]),properties:qo.arrayOf("string"),onAnimationEnd:qo.func})),children:qo.oneOfType([qo.node,qo.func]),isActive:qo.bool,canBegin:qo.bool,onAnimationEnd:qo.func,shouldReAnimate:qo.bool,onAnimationStart:qo.func,onAnimationReStart:qo.func};function $6(t){"@babel/helpers - typeof";return $6=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},$6(t)}function uie(){return uie=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 g=[0,0,0,0],v=0,_=4;v<_;v++)g[v]=o[v]>l?l:o[v];p="M".concat(s,",").concat(r+i*g[0]),g[0]>0&&(p+="A ".concat(g[0],",").concat(g[0],",0,0,").concat(u,",").concat(s+d*g[0],",").concat(r)),p+="L ".concat(s+n-d*g[1],",").concat(r),g[1]>0&&(p+="A ".concat(g[1],",").concat(g[1],",0,0,").concat(u,`, `).concat(s+n,",").concat(r+i*g[1])),p+="L ".concat(s+n,",").concat(r+a-i*g[2]),g[2]>0&&(p+="A ".concat(g[2],",").concat(g[2],",0,0,").concat(u,`, `).concat(s+n-d*g[2],",").concat(r+a)),p+="L ".concat(s+d*g[3],",").concat(r+a),g[3]>0&&(p+="A ".concat(g[3],",").concat(g[3],",0,0,").concat(u,`, `).concat(s,",").concat(r+a-i*g[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},Nos=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),g=Math.min(l,l+d),v=Math.max(l,l+d);return n>=u&&n<=p&&a>=g&&a<=v}return!1},Sos={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},v2e=function(s){var r=v6e(v6e({},Sos),s),n=S.useRef(),a=S.useState(-1),o=xos(a,2),l=o[0],i=o[1];S.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,g=r.height,v=r.radius,_=r.className,b=r.animationEasing,j=r.animationDuration,w=r.animationBegin,N=r.isAnimationActive,C=r.isUpdateAnimationActive;if(d!==+d||u!==+u||p!==+p||g!==+g||p===0||g===0)return null;var A=Ri("recharts-rectangle",_);return C?ht.createElement(Q0,{canBegin:l>0,from:{width:p,height:g,x:d,y:u},to:{width:p,height:g,x:d,y:u},duration:j,animationEasing:b,isActive:C},function(I){var L=I.width,R=I.height,$=I.x,q=I.y;return ht.createElement(Q0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:j,isActive:N,easing:b},ht.createElement("path",uie({},hi(r,!0),{className:A,d:_6e($,q,L,R,v),ref:n})))}):ht.createElement("path",uie({},hi(r,!0),{className:A,d:_6e(d,u,p,g,v)}))},Cos=["points","className","baseLinePoints","connectNulls"];function U4(){return U4=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 Tos(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 b6e(t){return Ios(t)||Pos(t)||Eos(t)||Aos()}function Aos(){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 Eos(t,s){if(t){if(typeof t=="string")return f0e(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 f0e(t,s)}}function Pos(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Ios(t){if(Array.isArray(t))return f0e(t)}function f0e(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){w6e(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),w6e(s[0])&&r[r.length-1].push(s[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},gI=function(s,r){var n=Los(s);r&&(n=[n.reduce(function(o,l){return[].concat(b6e(o),b6e(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},Dos=function(s,r,n){var a=gI(s,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(gI(r.reverse(),n).slice(1))},Oos=function(s){var r=s.points,n=s.className,a=s.baseLinePoints,o=s.connectNulls,l=Mos(s,Cos);if(!r||!r.length)return null;var i=Ri("recharts-polygon",n);if(a&&a.length){var d=l.stroke&&l.stroke!=="none",u=Dos(r,a,o);return ht.createElement("g",{className:i},ht.createElement("path",U4({},hi(l,!0),{fill:u.slice(-1)==="Z"?l.fill:"none",stroke:"none",d:u})),d?ht.createElement("path",U4({},hi(l,!0),{fill:"none",d:gI(r,o)})):null,d?ht.createElement("path",U4({},hi(l,!0),{fill:"none",d:gI(a,o)})):null)}var p=gI(r,o);return ht.createElement("path",U4({},hi(l,!0),{fill:p.slice(-1)==="Z"?l.fill:"none",className:i,d:p}))};function g0e(){return g0e=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 Uos(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 Vos=function(s,r,n,a,o,l){return"M".concat(s,",").concat(o,"v").concat(a,"M").concat(l,",").concat(r,"h").concat(n)},Hos=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,g=p===void 0?0:p,v=s.height,_=v===void 0?0:v,b=s.className,j=qos(s,Ros),w=Fos({x:n,y:o,top:i,left:u,width:g,height:_},j);return!sn(n)||!sn(o)||!sn(g)||!sn(_)||!sn(i)||!sn(u)?null:ht.createElement("path",x0e({},hi(w,!0),{className:Ri("recharts-cross",b),d:Vos(n,o,g,_,i,u)}))},Wos=ace,Gos=bXe,Kos=gy;function Zos(t,s){return t&&t.length?Wos(t,Kos(s),Gos):void 0}var Yos=Zos;const Xos=_o(Yos);var Qos=ace,Jos=gy,els=wXe;function tls(t,s){return t&&t.length?Qos(t,Jos(s),els):void 0}var sls=tls;const rls=_o(sls);var nls=["cx","cy","angle","ticks","axisLine"],als=["ticks","tick","angle","tickFormatter","stroke"];function F3(t){"@babel/helpers - typeof";return F3=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},F3(t)}function xI(){return xI=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 ils(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 ols(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function S6e(t,s){for(var r=0;rT6e?l=a==="outer"?"start":"end":o<-T6e?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=Xb(Xb({},hi(this.props,!1)),{},{fill:"none"},hi(i,!1));if(d==="circle")return ht.createElement(_2e,_k({className:"recharts-polar-angle-axis-line"},u,{cx:a,cy:o,r:l}));var p=this.props.ticks,g=p.map(function(v){return Dl(a,o,l,v.coordinate)});return ht.createElement(Oos,_k({className:"recharts-polar-angle-axis-line"},u,{points:g}))}},{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=hi(this.props,!1),g=hi(l,!1),v=Xb(Xb({},p),{},{fill:"none"},hi(i,!1)),_=o.map(function(b,j){var w=n.getTickLineCoord(b),N=n.getTickTextAnchor(b),C=Xb(Xb(Xb({textAnchor:N},p),{},{stroke:"none",fill:u},g),{},{index:j,payload:b,x:w.x2,y:w.y2});return ht.createElement(tl,_k({className:Ri("recharts-polar-angle-axis-tick",YXe(l)),key:"tick-".concat(b.coordinate)},$N(n.props,b,j)),i&&ht.createElement("line",_k({className:"recharts-polar-angle-axis-tick-line"},v,w)),l&&s.renderTickItem(l,C,d?d(b.value,j):b.value))});return ht.createElement(tl,{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(tl,{className:Ri("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):_i(n)?l=n(a):l=ht.createElement(qN,_k({},a,{className:"recharts-polar-angle-axis-tick-value"}),o),l}}])}(S.PureComponent);pce(fce,"displayName","PolarAngleAxis");pce(fce,"axisType","angleAxis");pce(fce,"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 wls=xYe,jls=wls(Object.getPrototypeOf,Object),kls=jls,Nls=sv,Sls=kls,Cls=rv,Mls="[object Object]",Tls=Function.prototype,Als=Object.prototype,pQe=Tls.toString,Els=Als.hasOwnProperty,Pls=pQe.call(Object);function Ils(t){if(!Cls(t)||Nls(t)!=Mls)return!1;var s=Sls(t);if(s===null)return!0;var r=Els.call(s,"constructor")&&s.constructor;return typeof r=="function"&&r instanceof r&&pQe.call(r)==Pls}var Lls=Ils;const Dls=_o(Lls);var Ols=sv,Rls=rv,Fls="[object Boolean]";function zls(t){return t===!0||t===!1||Rls(t)&&Ols(t)==Fls}var Bls=zls;const $ls=_o(Bls);function U6(t){"@babel/helpers - typeof";return U6=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},U6(t)}function pie(){return pie=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:v,x:d,y:u},to:{upperWidth:p,lowerWidth:g,height:v,x:d,y:u},duration:j,animationEasing:b,isActive:N},function(A){var I=A.upperWidth,L=A.lowerWidth,R=A.height,$=A.x,q=A.y;return ht.createElement(Q0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:j,easing:b},ht.createElement("path",pie({},hi(r,!0),{className:C,d:I6e($,q,I,L,R),ref:n})))}):ht.createElement("g",null,ht.createElement("path",pie({},hi(r,!0),{className:C,d:I6e(d,u,p,g,v)})))},Qls=["option","shapeType","propTransformer","activeClassName","isActive"];function V6(t){"@babel/helpers - typeof";return V6=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},V6(t)}function Jls(t,s){if(t==null)return{};var r=ecs(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 ecs(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 L6e(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 fie(t){for(var s=1;s0?_p(A,"paddingAngle",0):0;if(L){var $=h1(L.endAngle-L.startAngle,A.endAngle-A.startAngle),q=Nl(Nl({},A),{},{startAngle:C+R,endAngle:C+$(j)+R});w.push(q),C=q.endAngle}else{var U=A.endAngle,V=A.startAngle,X=h1(0,U-V),se=X(j),te=Nl(Nl({},A),{},{startAngle:C+R,endAngle:C+se+R});w.push(te),C=te.endAngle}}),ht.createElement(tl,null,n.renderSectorsStatically(w))})}},{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||!lce(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,g=a.innerRadius,v=a.outerRadius,_=a.isAnimationActive,b=this.state.isAnimationFinished;if(o||!l||!l.length||!sn(u)||!sn(p)||!sn(g)||!sn(v))return null;var j=Ri("recharts-pie",i);return ht.createElement(tl,{tabIndex:this.props.rootTabIndex,className:j,ref:function(N){n.pieRef=N}},this.renderSectors(),d&&this.renderLabels(l),lu.renderCallByParent(this.props,null,!1),(!_||b)&&x_.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?C:C-1)*d,I=w-C*_-A,L=a.reduce(function(q,U){var V=Qu(U,N,0);return q+(sn(V)?V:0)},0),R;if(L>0){var $;R=a.map(function(q,U){var V=Qu(q,N,0),X=Qu(q,p,U),se=(sn(V)?V:0)/L,te;U?te=$.endAngle+Dh(j)*d*(V!==0?1:0):te=l;var Y=te+Dh(j)*((V!==0?_:0)+se*I),de=(te+Y)/2,ie=(b.innerRadius+b.outerRadius)/2,ae=[{name:X,value:V,payload:q,dataKey:N,type:v}],le=Dl(b.cx,b.cy,ie,de);return $=Nl(Nl(Nl({percent:se,cornerRadius:o,name:X,tooltipPayload:ae,midAngle:de,middleRadius:ie,tooltipPosition:le},q),b),{},{value:Qu(q,N),startAngle:te,endAngle:Y,payload:q,paddingAngle:Dh(j)*d}),$})}return Nl(Nl({},b),{},{sectors:R,data:a})});var bcs=Math.ceil,wcs=Math.max;function jcs(t,s,r,n){for(var a=-1,o=wcs(bcs((s-t)/(r||1)),0),l=Array(o);o--;)l[n?o:++a]=t,t+=r;return l}var kcs=jcs,Ncs=OYe,F6e=1/0,Scs=17976931348623157e292;function Ccs(t){if(!t)return t===0?t:0;if(t=Ncs(t),t===F6e||t===-F6e){var s=t<0?-1:1;return s*Scs}return t===t?t:0}var yQe=Ccs,Mcs=kcs,Tcs=Xle,vpe=yQe;function Acs(t){return function(s,r,n){return n&&typeof n!="number"&&Tcs(s,r,n)&&(r=n=void 0),s=vpe(s),r===void 0?(r=s,s=0):r=vpe(r),n=n===void 0?s0&&n.handleDrag(a.changedTouches[0])}),Jm(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()}),Jm(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),Jm(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),Jm(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),Jm(n,"handleSlideDragStart",function(a){var o=U6e(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 Vcs(s,t),Bcs(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,g=Math.min(a,o),v=Math.max(a,o),_=s.getIndexInRange(l,g),b=s.getIndexInRange(l,v);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=Qu(o[n],i,n);return _i(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,g=d.travellerWidth,v=d.startIndex,_=d.endIndex,b=d.onChange,j=n.pageX-o;j>0?j=Math.min(j,u+p-g-i,u+p-g-l):j<0&&(j=Math.max(j,u-l,u-i));var w=this.getIndex({startX:l+j,endX:i+j});(w.startIndex!==v||w.endIndex!==_)&&b&&b(w),this.setState({startX:l+j,endX:i+j,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var o=U6e(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,g=p.x,v=p.width,_=p.travellerWidth,b=p.onChange,j=p.gap,w=p.data,N={startX:this.state.startX,endX:this.state.endX},C=n.pageX-o;C>0?C=Math.min(C,g+v-_-u):C<0&&(C=Math.max(C,g-u)),N[l]=u+C;var A=this.getIndex(N),I=A.startIndex,L=A.endIndex,R=function(){var q=w.length-1;return l==="startX"&&(i>d?I%j===0:L%j===0)||id?L%j===0:I%j===0)||i>d&&L===q};this.setState(Jm(Jm({},l,u+C),"brushMoveStartX",n.pageX),function(){b&&R()&&b(A)})}},{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],g=i.indexOf(p);if(g!==-1){var v=g+n;if(!(v===-1||v>=i.length)){var _=i[v];a==="startX"&&_>=u||a==="endX"&&_<=d||this.setState(Jm({},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,g=S.Children.only(u);return g?ht.cloneElement(g,{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,g=d.height,v=d.traveller,_=d.ariaLabel,b=d.data,j=d.startIndex,w=d.endIndex,N=Math.max(n,this.props.x),C=_pe(_pe({},hi(this.props,!1)),{},{x:N,y:u,width:p,height:g}),A=_||"Min value: ".concat((o=b[j])===null||o===void 0?void 0:o.name,", Max value: ").concat((l=b[w])===null||l===void 0?void 0:l.name);return ht.createElement(tl,{tabIndex:0,role:"slider","aria-label":A,"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(v,C))}},{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,g=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:g,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,g=p.startX,v=p.endX,_=5,b={pointerEvents:"none",fill:u};return ht.createElement(tl,{className:"recharts-brush-texts"},ht.createElement(qN,yie({textAnchor:"end",verticalAnchor:"middle",x:Math.min(g,v)-_,y:l+i/2},b),this.getTextOfTick(a)),ht.createElement(qN,yie({textAnchor:"start",verticalAnchor:"middle",x:Math.max(g,v)+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,g=n.alwaysShowText,v=this.state,_=v.startX,b=v.endX,j=v.isTextActive,w=v.isSlideMoving,N=v.isTravellerMoving,C=v.isTravellerFocused;if(!a||!a.length||!sn(i)||!sn(d)||!sn(u)||!sn(p)||u<=0||p<=0)return null;var A=Ri("recharts-brush",o),I=ht.Children.count(l)===1,L=Fcs("userSelect","none");return ht.createElement(tl,{className:A,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:L},this.renderBackground(),I&&this.renderPanorama(),this.renderSlide(_,b),this.renderTravellerLayer(_,"startX"),this.renderTravellerLayer(b,"endX"),(j||w||N||C||g)&&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):_i(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,g=n.endIndex;if(o!==a.prevData||u!==a.prevUpdateId)return _pe({prevData:o,prevTravellerWidth:d,prevUpdateId:u,prevX:i,prevWidth:l},o&&o.length?Wcs({data:o,width:l,x:i,travellerWidth:d,startIndex:p,endIndex:g}):{scale:null,scaleValues:null});if(a.scale&&(l!==a.prevWidth||i!==a.prevX||d!==a.prevTravellerWidth)){a.scale.range([i,i+l-d]);var v=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:v}}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}}])}(S.PureComponent);Jm(q3,"displayName","Brush");Jm(q3,"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 Gcs=Hwe;function Kcs(t,s){var r;return Gcs(t,function(n,a,o){return r=s(n,a,o),!r}),!!r}var Zcs=Kcs,Ycs=cYe,Xcs=gy,Qcs=Zcs,Jcs=zm,eds=Xle;function tds(t,s,r){var n=Jcs(t)?Ycs:Qcs;return r&&eds(t,s,r)&&(s=void 0),n(t,Xcs(s))}var sds=tds;const rds=_o(sds);var ey=function(s,r){var n=s.alwaysShow,a=s.ifOverflow;return n&&(a="extendDomain"),a===r},V6e=EYe;function nds(t,s,r){s=="__proto__"&&V6e?V6e(t,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[s]=r}var ads=nds,ids=ads,ods=TYe,lds=gy;function cds(t,s){var r={};return s=lds(s),ods(t,function(n,a,o){ids(r,a,s(n,a,o))}),r}var dds=cds;const uds=_o(dds);function hds(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 Tds(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 Ads(t,s){var r=t.x,n=t.y,a=Mds(t,kds),o="".concat(r),l=parseInt(o,10),i="".concat(n),d=parseInt(i,10),u="".concat(s.height||a.height),p=parseInt(u,10),g="".concat(s.width||a.width),v=parseInt(g,10);return pE(pE(pE(pE(pE({},s),a),l?{x:l}:{}),d?{y:d}:{}),{},{height:p,width:v,name:s.name,radius:s.radius})}function W6e(t){return ht.createElement(fQe,w0e({shapeType:"rectangle",propTransformer:Ads,activeClassName:"recharts-active-bar"},t))}var Eds=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=sn(n)||rUt(n);return o?s(n,a):(o||VN(),r)}},Pds=["value","background"],jQe;function U3(t){"@babel/helpers - typeof";return U3=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},U3(t)}function Ids(t,s){if(t==null)return{};var r=Lds(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 Lds(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 _ie(){return _ie=Object.assign?Object.assign.bind():function(t){for(var s=1;s0&&Math.abs(de)0&&Math.abs(Y)0&&(te=Math.min((Ke||0)-(Y[_e-1]||0),te))}),Number.isFinite(te)){var de=te/se,ie=j.layout==="vertical"?n.height:n.width;if(j.padding==="gap"&&($=de*ie/2),j.padding==="no-gap"){var ae=Oh(s.barCategoryGap,de*ie),le=de*ie/2;$=le-ae-(le-ae)/ie*ae}}}a==="xAxis"?q=[n.left+(A.left||0)+($||0),n.left+n.width-(A.right||0)-($||0)]:a==="yAxis"?q=d==="horizontal"?[n.top+n.height-(A.bottom||0),n.top+(A.top||0)]:[n.top+(A.top||0)+($||0),n.top+n.height-(A.bottom||0)-($||0)]:q=j.range,L&&(q=[q[1],q[0]]);var pe=UXe(j,o,v),be=pe.scale,ye=pe.realScaleType;be.domain(N).range(q),VXe(be);var we=HXe(be,kg(kg({},j),{},{realScaleType:ye}));a==="xAxis"?(X=w==="top"&&!I||w==="bottom"&&I,U=n.left,V=g[R]-X*j.height):a==="yAxis"&&(X=w==="left"&&!I||w==="right"&&I,U=g[R]-X*j.width,V=n.top);var Ne=kg(kg(kg({},j),we),{},{realScaleType:ye,x:U,y:V,scale:be,width:a==="xAxis"?n.width:j.width,height:a==="yAxis"?n.height:j.height});return Ne.bandSize=aie(Ne,we),!j.hide&&a==="xAxis"?g[R]+=(X?-1:1)*Ne.height:j.hide||(g[R]+=(X?-1:1)*Ne.width),kg(kg({},_),{},yce({},b,Ne))},{})},CQe=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)}},Wds=function(s){var r=s.x1,n=s.y1,a=s.x2,o=s.y2;return CQe({x:r,y:n},{x:a,y:o})},MQe=function(){function t(s){qds(this,t),this.scale=s}return Uds(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)}}])}();yce(MQe,"EPS",1e-4);var b2e=function(s){var r=Object.keys(s).reduce(function(n,a){return kg(kg({},n),{},yce({},a,MQe.create(s[a])))},{});return kg(kg({},r),{},{apply:function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=o.bandAware,i=o.position;return uds(a,function(d,u){return r[u].apply(d,{bandAware:l,position:i})})},isInRange:function(a){return wQe(a,function(o,l){return r[l].isInRange(o)})}})};function Gds(t){return(t%180+180)%180}var Kds=function(s){var r=s.width,n=s.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=Gds(a),l=o*Math.PI/180,i=Math.atan(n/r),d=l>i&&l-1?a[o?s[l]:l]:void 0}}var Jds=Qds,eus=yQe;function tus(t){var s=eus(t),r=s%1;return s===s?r?s-r:s:0}var sus=tus,rus=jYe,nus=gy,aus=sus,ius=Math.max;function ous(t,s,r){var n=t==null?0:t.length;if(!n)return-1;var a=r==null?0:aus(r);return a<0&&(a=ius(n+a,0)),rus(t,nus(s),a)}var lus=ous,cus=Jds,dus=lus,uus=cus(dus),hus=uus;const mus=_o(hus);var pus=cqt(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("")}),w2e=S.createContext(void 0),j2e=S.createContext(void 0),TQe=S.createContext(void 0),AQe=S.createContext({}),EQe=S.createContext(void 0),PQe=S.createContext(0),IQe=S.createContext(0),X6e=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=pus(o);return ht.createElement(w2e.Provider,{value:n},ht.createElement(j2e.Provider,{value:a},ht.createElement(AQe.Provider,{value:o},ht.createElement(TQe.Provider,{value:p},ht.createElement(EQe.Provider,{value:l},ht.createElement(PQe.Provider,{value:u},ht.createElement(IQe.Provider,{value:d},i)))))))},fus=function(){return S.useContext(EQe)},LQe=function(s){var r=S.useContext(w2e);r==null&&VN();var n=r[s];return n==null&&VN(),n},gus=function(){var s=S.useContext(w2e);return _1(s)},xus=function(){var s=S.useContext(j2e),r=mus(s,function(n){return wQe(n.domain,Number.isFinite)});return r||_1(s)},DQe=function(s){var r=S.useContext(j2e);r==null&&VN();var n=r[s];return n==null&&VN(),n},yus=function(){var s=S.useContext(TQe);return s},vus=function(){return S.useContext(AQe)},k2e=function(){return S.useContext(IQe)},N2e=function(){return S.useContext(PQe)};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 _us(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function bus(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 shs(t,s){return qQe(t,s+1)}function rhs(t,s,r,n,a){for(var o=(n||[]).slice(),l=s.start,i=s.end,d=0,u=1,p=l,g=function(){var b=n==null?void 0:n[d];if(b===void 0)return{v:qQe(n,u)};var j=d,w,N=function(){return w===void 0&&(w=r(b,j)),w},C=b.coordinate,A=d===0||Nie(t,C,N,p,i);A||(d=0,p=l,u+=1),A&&(p=C+t*(N()/2+a),d+=u)},v;u<=o.length;)if(v=g(),v)return v.v;return[]}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 aLe(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 Zu(t){for(var s=1;s0?_.coordinate-w*t:_.coordinate})}else o[v]=_=Zu(Zu({},_),{},{tickCoord:_.coordinate});var N=Nie(t,_.tickCoord,j,i,d);N&&(d=_.tickCoord-t*(j()/2+a),o[v]=Zu(Zu({},_),{},{isShow:!0}))},p=l-1;p>=0;p--)u(p);return o}function lhs(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],g=r(p,i-1),v=t*(p.coordinate+t*g/2-u);l[i-1]=p=Zu(Zu({},p),{},{tickCoord:v>0?p.coordinate-v*t:p.coordinate});var _=Nie(t,p.tickCoord,function(){return g},d,u);_&&(u=p.tickCoord-t*(g/2+a),l[i-1]=Zu(Zu({},p),{},{isShow:!0}))}for(var b=o?i-1:i,j=function(C){var A=l[C],I,L=function(){return I===void 0&&(I=r(A,C)),I};if(C===0){var R=t*(A.coordinate-t*L()/2-d);l[C]=A=Zu(Zu({},A),{},{tickCoord:R<0?A.coordinate-R*t:A.coordinate})}else l[C]=A=Zu(Zu({},A),{},{tickCoord:A.coordinate});var $=Nie(t,A.tickCoord,L,d,u);$&&(d=A.tickCoord+t*(L()/2+a),l[C]=Zu(Zu({},A),{},{isShow:!0}))},w=0;w=2?Dh(a[1].coordinate-a[0].coordinate):1,N=ths(o,w,_);return d==="equidistantPreserveStart"?rhs(w,N,j,a,l):(d==="preserveStart"||d==="preserveStartEnd"?v=lhs(w,N,j,a,l,d==="preserveStartEnd"):v=ohs(w,N,j,a,l),v.filter(function(C){return C.isShow}))}var chs=["viewBox"],dhs=["viewBox"],uhs=["ticks"];function G3(t){"@babel/helpers - typeof";return G3=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},G3(t)}function H4(){return H4=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 hhs(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 mhs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function oLe(t,s){for(var r=0;r0?d(this.props):d(_)),l<=0||i<=0||!b||!b.length?null:ht.createElement(tl,{className:Ri("recharts-cartesian-axis",u),ref:function(w){n.layerReference=w}},o&&this.renderAxisLine(),this.renderTicks(b,this.state.fontSize,this.state.letterSpacing),lu.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,o){var l,i=Ri(a.className,"recharts-cartesian-axis-tick-value");return ht.isValidElement(n)?l=ht.cloneElement(n,Ed(Ed({},a),{},{className:i})):_i(n)?l=n(Ed(Ed({},a),{},{className:i})):l=ht.createElement(qN,H4({},a,{className:"recharts-cartesian-axis-tick-value"}),o),l}}])}(S.Component);T2e(UM,"displayName","CartesianAxis");T2e(UM,"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 _hs=["x1","y1","x2","y2","key"],bhs=["offset"];function HN(t){"@babel/helpers - typeof";return HN=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},HN(t)}function lLe(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;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Nhs(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 Shs=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 HQe(t,s){var r;if(ht.isValidElement(t))r=ht.cloneElement(t,s);else if(_i(t))r=t(s);else{var n=s.x1,a=s.y1,o=s.x2,l=s.y2,i=s.key,d=cLe(s,_hs),u=hi(d,!1);u.offset;var p=cLe(u,bhs);r=ht.createElement("line",Rk({},p,{x1:n,y1:a,x2:o,y2:l,fill:"none",key:i}))}return r}function Chs(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=Xu(Xu({},t),{},{x1:s,y1:i,x2:s+r,y2:i,key:"line-".concat(d),index:d});return HQe(a,u)});return ht.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function Mhs(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=Xu(Xu({},t),{},{x1:i,y1:s,x2:i,y2:s+r,key:"line-".concat(d),index:d});return HQe(a,u)});return ht.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function Ths(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(v){return Math.round(v+a-a)}).sort(function(v,_){return v-_});a!==p[0]&&p.unshift(0);var g=p.map(function(v,_){var b=!p[_+1],j=b?a+l-v:p[_+1]-v;if(j<=0)return null;var w=_%s.length;return ht.createElement("rect",{key:"react-".concat(_),y:v,x:n,height:j,width:o,stroke:"none",fill:s[w],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return ht.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},g)}function Ahs(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(v){return Math.round(v+o-o)}).sort(function(v,_){return v-_});o!==p[0]&&p.unshift(0);var g=p.map(function(v,_){var b=!p[_+1],j=b?o+i-v:p[_+1]-v;if(j<=0)return null;var w=_%n.length;return ht.createElement("rect",{key:"react-".concat(_),x:v,y:l,width:j,height:d,stroke:"none",fill:n[w],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return ht.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},g)}var Ehs=function(s,r){var n=s.xAxis,a=s.width,o=s.height,l=s.offset;return qXe(M2e(Xu(Xu(Xu({},UM.defaultProps),n),{},{ticks:_0(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.left,l.left+l.width,r)},Phs=function(s,r){var n=s.yAxis,a=s.width,o=s.height,l=s.offset;return qXe(M2e(Xu(Xu(Xu({},UM.defaultProps),n),{},{ticks:_0(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.top,l.top+l.height,r)},u4={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function WQe(t){var s,r,n,a,o,l,i=k2e(),d=N2e(),u=vus(),p=Xu(Xu({},t),{},{stroke:(s=t.stroke)!==null&&s!==void 0?s:u4.stroke,fill:(r=t.fill)!==null&&r!==void 0?r:u4.fill,horizontal:(n=t.horizontal)!==null&&n!==void 0?n:u4.horizontal,horizontalFill:(a=t.horizontalFill)!==null&&a!==void 0?a:u4.horizontalFill,vertical:(o=t.vertical)!==null&&o!==void 0?o:u4.vertical,verticalFill:(l=t.verticalFill)!==null&&l!==void 0?l:u4.verticalFill,x:sn(t.x)?t.x:u.left,y:sn(t.y)?t.y:u.top,width:sn(t.width)?t.width:u.width,height:sn(t.height)?t.height:u.height}),g=p.x,v=p.y,_=p.width,b=p.height,j=p.syncWithTicks,w=p.horizontalValues,N=p.verticalValues,C=gus(),A=xus();if(!sn(_)||_<=0||!sn(b)||b<=0||!sn(g)||g!==+g||!sn(v)||v!==+v)return null;var I=p.verticalCoordinatesGenerator||Ehs,L=p.horizontalCoordinatesGenerator||Phs,R=p.horizontalPoints,$=p.verticalPoints;if((!R||!R.length)&&_i(L)){var q=w&&w.length,U=L({yAxis:A?Xu(Xu({},A),{},{ticks:q?w:A.ticks}):void 0,width:i,height:d,offset:u},q?!0:j);Bg(Array.isArray(U),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(HN(U),"]")),Array.isArray(U)&&(R=U)}if((!$||!$.length)&&_i(I)){var V=N&&N.length,X=I({xAxis:C?Xu(Xu({},C),{},{ticks:V?N:C.ticks}):void 0,width:i,height:d,offset:u},V?!0:j);Bg(Array.isArray(X),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(HN(X),"]")),Array.isArray(X)&&($=X)}return ht.createElement("g",{className:"recharts-cartesian-grid"},ht.createElement(Shs,{fill:p.fill,fillOpacity:p.fillOpacity,x:p.x,y:p.y,width:p.width,height:p.height,ry:p.ry}),ht.createElement(Chs,Rk({},p,{offset:u,horizontalPoints:R,xAxis:C,yAxis:A})),ht.createElement(Mhs,Rk({},p,{offset:u,verticalPoints:$,xAxis:C,yAxis:A})),ht.createElement(Ths,Rk({},p,{horizontalPoints:R})),ht.createElement(Ahs,Rk({},p,{verticalPoints:$})))}WQe.displayName="CartesianGrid";function K3(t){"@babel/helpers - typeof";return K3=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},K3(t)}function Ihs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Lhs(t,s){for(var r=0;rt.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 _ms(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 bms(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function wms(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r0?l:s&&s.length&&sn(a)&&sn(o)?s.slice(a,o+1):[]};function iJe(t){return t==="number"?[0,"auto"]:void 0}var z0e=function(s,r,n,a){var o=s.graphicalItems,l=s.tooltipAxis,i=Nce(r,s);return n<0||!o||!o.length||n>=i.length?null:o.reduce(function(d,u){var p,g=(p=u.props.data)!==null&&p!==void 0?p:r;g&&s.dataStartIndex+s.dataEndIndex!==0&&s.dataEndIndex-s.dataStartIndex>=n&&(g=g.slice(s.dataStartIndex,s.dataEndIndex+1));var v;if(l.dataKey&&!l.allowDuplicatedCategory){var _=g===void 0?i:g;v=hye(_,l.dataKey,a)}else v=g&&g[n]||i[n];return v?[].concat(X3(d),[GXe(u,v)]):d},[])},fLe=function(s,r,n,a){var o=a||{x:s.chartX,y:s.chartY},l=Lms(o,n),i=s.orderedTooltipTicks,d=s.tooltipAxis,u=s.tooltipTicks,p=fns(l,i,u,d);if(p>=0&&u){var g=u[p]&&u[p].value,v=z0e(s,r,p,g),_=Dms(n,i,p,o);return{activeTooltipIndex:p,activeLabel:g,activePayload:v,activeCoordinate:_}}return null},Oms=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,g=s.children,v=s.stackOffset,_=$Xe(p,o);return n.reduce(function(b,j){var w,N=j.type.defaultProps!==void 0?xr(xr({},j.type.defaultProps),j.props):j.props,C=N.type,A=N.dataKey,I=N.allowDataOverflow,L=N.allowDuplicatedCategory,R=N.scale,$=N.ticks,q=N.includeHidden,U=N[l];if(b[U])return b;var V=Nce(s.data,{graphicalItems:a.filter(function(we){var Ne,Ke=l in we.props?we.props[l]:(Ne=we.type.defaultProps)===null||Ne===void 0?void 0:Ne[l];return Ke===U}),dataStartIndex:d,dataEndIndex:u}),X=V.length,se,te,Y;lms(N.domain,I,C)&&(se=e0e(N.domain,null,I),_&&(C==="number"||R!=="auto")&&(Y=pI(V,A,"category")));var de=iJe(C);if(!se||se.length===0){var ie,ae=(ie=N.domain)!==null&&ie!==void 0?ie:de;if(A){if(se=pI(V,A,C),C==="category"&&_){var le=aUt(se);L&&le?(te=se,se=xie(0,X)):L||(se=BIe(ae,se,j).reduce(function(we,Ne){return we.indexOf(Ne)>=0?we:[].concat(X3(we),[Ne])},[]))}else if(C==="category")L?se=se.filter(function(we){return we!==""&&!Zi(we)}):se=BIe(ae,se,j).reduce(function(we,Ne){return we.indexOf(Ne)>=0||Ne===""||Zi(Ne)?we:[].concat(X3(we),[Ne])},[]);else if(C==="number"){var pe=_ns(V,a.filter(function(we){var Ne,Ke,_e=l in we.props?we.props[l]:(Ne=we.type.defaultProps)===null||Ne===void 0?void 0:Ne[l],Me="hide"in we.props?we.props.hide:(Ke=we.type.defaultProps)===null||Ke===void 0?void 0:Ke.hide;return _e===U&&(q||!Me)}),A,o,p);pe&&(se=pe)}_&&(C==="number"||R!=="auto")&&(Y=pI(V,A,"category"))}else _?se=xie(0,X):i&&i[U]&&i[U].hasStack&&C==="number"?se=v==="expand"?[0,1]:WXe(i[U].stackGroups,d,u):se=BXe(V,a.filter(function(we){var Ne=l in we.props?we.props[l]:we.type.defaultProps[l],Ke="hide"in we.props?we.props.hide:we.type.defaultProps.hide;return Ne===U&&(q||!Ke)}),C,p,!0);if(C==="number")se=O0e(g,se,U,o,$),ae&&(se=e0e(ae,se,I));else if(C==="category"&&ae){var be=ae,ye=se.every(function(we){return be.indexOf(we)>=0});ye&&(se=be)}}return xr(xr({},b),{},ti({},U,xr(xr({},N),{},{axisType:o,domain:se,categoricalDomain:Y,duplicateDomain:te,originalDomain:(w=N.domain)!==null&&w!==void 0?w:de,isCategorical:_,layout:p})))},{})},Rms=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,g=s.children,v=Nce(s.data,{graphicalItems:n,dataStartIndex:d,dataEndIndex:u}),_=v.length,b=$Xe(p,o),j=-1;return n.reduce(function(w,N){var C=N.type.defaultProps!==void 0?xr(xr({},N.type.defaultProps),N.props):N.props,A=C[l],I=iJe("number");if(!w[A]){j++;var L;return b?L=xie(0,_):i&&i[A]&&i[A].hasStack?(L=WXe(i[A].stackGroups,d,u),L=O0e(g,L,A,o)):(L=e0e(I,BXe(v,n.filter(function(R){var $,q,U=l in R.props?R.props[l]:($=R.type.defaultProps)===null||$===void 0?void 0:$[l],V="hide"in R.props?R.props.hide:(q=R.type.defaultProps)===null||q===void 0?void 0:q.hide;return U===A&&!V}),"number",p),a.defaultProps.allowDataOverflow),L=O0e(g,L,A,o)),xr(xr({},w),{},ti({},A,xr(xr({axisType:o},a.defaultProps),{},{hide:!0,orientation:_p(Pms,"".concat(o,".").concat(j%2),null),domain:L,originalDomain:I,isCategorical:b,layout:p})))}return w},{})},Fms=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,g="".concat(a,"Id"),v=vf(p,o),_={};return v&&v.length?_=Oms(s,{axes:v,graphicalItems:l,axisType:a,axisIdKey:g,stackGroups:i,dataStartIndex:d,dataEndIndex:u}):l&&l.length&&(_=Rms(s,{Axis:o,graphicalItems:l,axisType:a,axisIdKey:g,stackGroups:i,dataStartIndex:d,dataEndIndex:u})),_},zms=function(s){var r=_1(s),n=_0(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:Wwe(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:aie(r,n)}},gLe=function(s){var r=s.children,n=s.defaultShowTooltip,a=sp(r,q3),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}},Bms=function(s){return!s||!s.length?!1:s.some(function(r){var n=F0(r&&r.type);return n&&n.indexOf("Bar")>=0})},xLe=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"}},$ms=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,g=n.children,v=n.margin||{},_=sp(g,q3),b=sp(g,R5),j=Object.keys(d).reduce(function(L,R){var $=d[R],q=$.orientation;return!$.mirror&&!$.hide?xr(xr({},L),{},ti({},q,L[q]+$.width)):L},{left:v.left||0,right:v.right||0}),w=Object.keys(l).reduce(function(L,R){var $=l[R],q=$.orientation;return!$.mirror&&!$.hide?xr(xr({},L),{},ti({},q,_p(L,"".concat(q))+$.height)):L},{top:v.top||0,bottom:v.bottom||0}),N=xr(xr({},w),j),C=N.bottom;_&&(N.bottom+=_.props.height||q3.defaultProps.height),b&&r&&(N=yns(N,a,n,r));var A=u-N.left-N.right,I=p-N.top-N.bottom;return xr(xr({brushBottom:C},N),{},{width:Math.max(A,0),height:Math.max(I,0)})},qms=function(s,r){if(r==="xAxis")return s[r].width;if(r==="yAxis")return s[r].height},oJe=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,g=s.defaultProps,v=function(N,C){var A=C.graphicalItems,I=C.stackGroups,L=C.offset,R=C.updateId,$=C.dataStartIndex,q=C.dataEndIndex,U=N.barSize,V=N.layout,X=N.barGap,se=N.barCategoryGap,te=N.maxBarSize,Y=xLe(V),de=Y.numericAxisName,ie=Y.cateAxisName,ae=Bms(A),le=[];return A.forEach(function(pe,be){var ye=Nce(N.data,{graphicalItems:[pe],dataStartIndex:$,dataEndIndex:q}),we=pe.type.defaultProps!==void 0?xr(xr({},pe.type.defaultProps),pe.props):pe.props,Ne=we.dataKey,Ke=we.maxBarSize,_e=we["".concat(de,"Id")],Me=we["".concat(ie,"Id")],Te={},Fe=d.reduce(function(lt,We){var Ye=C["".concat(We.axisType,"Map")],mt=we["".concat(We.axisType,"Id")];Ye&&Ye[mt]||We.axisType==="zAxis"||VN();var Ze=Ye[mt];return xr(xr({},lt),{},ti(ti({},We.axisType,Ze),"".concat(We.axisType,"Ticks"),_0(Ze)))},Te),Ae=Fe[ie],Ue=Fe["".concat(ie,"Ticks")],ut=I&&I[_e]&&I[_e].hasStack&&Tns(pe,I[_e].stackGroups),De=F0(pe.type).indexOf("Bar")>=0,Dt=aie(Ae,Ue),he=[],Ve=ae&&gns({barSize:U,stackGroups:I,totalSize:qms(Fe,ie)});if(De){var nt,Qe,ke=Zi(Ke)?te:Ke,ot=(nt=(Qe=aie(Ae,Ue,!0))!==null&&Qe!==void 0?Qe:ke)!==null&&nt!==void 0?nt:0;he=xns({barGap:X,barCategoryGap:se,bandSize:ot!==Dt?ot:Dt,sizeList:Ve[Me],maxBarSize:ke}),ot!==Dt&&(he=he.map(function(lt){return xr(xr({},lt),{},{position:xr(xr({},lt.position),{},{offset:lt.position.offset-ot/2})})}))}var qe=pe&&pe.type&&pe.type.getComposedData;qe&&le.push({props:xr(xr({},qe(xr(xr({},Fe),{},{displayedData:ye,props:N,dataKey:Ne,item:pe,bandSize:Dt,barPosition:he,offset:L,stackedData:ut,layout:V,dataStartIndex:$,dataEndIndex:q}))),{},ti(ti(ti({key:pe.key||"item-".concat(be)},de,Fe[de]),ie,Fe[ie]),"animationId",R)),childIndex:xUt(pe,N.children),item:pe})}),le},_=function(N,C){var A=N.props,I=N.dataStartIndex,L=N.dataEndIndex,R=N.updateId;if(!LEe({props:A}))return null;var $=A.children,q=A.layout,U=A.stackOffset,V=A.data,X=A.reverseStackOrder,se=xLe(q),te=se.numericAxisName,Y=se.cateAxisName,de=vf($,n),ie=Cns(V,de,"".concat(te,"Id"),"".concat(Y,"Id"),U,X),ae=d.reduce(function(we,Ne){var Ke="".concat(Ne.axisType,"Map");return xr(xr({},we),{},ti({},Ke,Fms(A,xr(xr({},Ne),{},{graphicalItems:de,stackGroups:Ne.axisType===te&&ie,dataStartIndex:I,dataEndIndex:L}))))},{}),le=$ms(xr(xr({},ae),{},{props:A,graphicalItems:de}),C==null?void 0:C.legendBBox);Object.keys(ae).forEach(function(we){ae[we]=p(A,ae[we],le,we.replace("Map",""),r)});var pe=ae["".concat(Y,"Map")],be=zms(pe),ye=v(A,xr(xr({},ae),{},{dataStartIndex:I,dataEndIndex:L,updateId:R,graphicalItems:de,stackGroups:ie,offset:le}));return xr(xr({formattedGraphicalItems:ye,graphicalItems:de,offset:le,stackGroups:ie},be),ae)},b=function(w){function N(C){var A,I,L;return bms(this,N),L=kms(this,N,[C]),ti(L,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),ti(L,"accessibilityManager",new oms),ti(L,"handleLegendBBoxUpdate",function(R){if(R){var $=L.state,q=$.dataStartIndex,U=$.dataEndIndex,V=$.updateId;L.setState(xr({legendBBox:R},_({props:L.props,dataStartIndex:q,dataEndIndex:U,updateId:V},xr(xr({},L.state),{},{legendBBox:R}))))}}),ti(L,"handleReceiveSyncEvent",function(R,$,q){if(L.props.syncId===R){if(q===L.eventEmitterSymbol&&typeof L.props.syncMethod!="function")return;L.applySyncEvent($)}}),ti(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 xr({dataStartIndex:$,dataEndIndex:q},_({props:L.props,dataStartIndex:$,dataEndIndex:q,updateId:U},L.state))}),L.triggerSyncEvent({dataStartIndex:$,dataEndIndex:q})}}),ti(L,"handleMouseEnter",function(R){var $=L.getMouseInfo(R);if($){var q=xr(xr({},$),{},{isTooltipActive:!0});L.setState(q),L.triggerSyncEvent(q);var U=L.props.onMouseEnter;_i(U)&&U(q,R)}}),ti(L,"triggeredAfterMouseMove",function(R){var $=L.getMouseInfo(R),q=$?xr(xr({},$),{},{isTooltipActive:!0}):{isTooltipActive:!1};L.setState(q),L.triggerSyncEvent(q);var U=L.props.onMouseMove;_i(U)&&U(q,R)}),ti(L,"handleItemMouseEnter",function(R){L.setState(function(){return{isTooltipActive:!0,activeItem:R,activePayload:R.tooltipPayload,activeCoordinate:R.tooltipPosition||{x:R.cx,y:R.cy}}})}),ti(L,"handleItemMouseLeave",function(){L.setState(function(){return{isTooltipActive:!1}})}),ti(L,"handleMouseMove",function(R){R.persist(),L.throttleTriggeredAfterMouseMove(R)}),ti(L,"handleMouseLeave",function(R){L.throttleTriggeredAfterMouseMove.cancel();var $={isTooltipActive:!1};L.setState($),L.triggerSyncEvent($);var q=L.props.onMouseLeave;_i(q)&&q($,R)}),ti(L,"handleOuterEvent",function(R){var $=gUt(R),q=_p(L.props,"".concat($));if($&&_i(q)){var U,V;/.*touch.*/i.test($)?V=L.getMouseInfo(R.changedTouches[0]):V=L.getMouseInfo(R),q((U=V)!==null&&U!==void 0?U:{},R)}}),ti(L,"handleClick",function(R){var $=L.getMouseInfo(R);if($){var q=xr(xr({},$),{},{isTooltipActive:!0});L.setState(q),L.triggerSyncEvent(q);var U=L.props.onClick;_i(U)&&U(q,R)}}),ti(L,"handleMouseDown",function(R){var $=L.props.onMouseDown;if(_i($)){var q=L.getMouseInfo(R);$(q,R)}}),ti(L,"handleMouseUp",function(R){var $=L.props.onMouseUp;if(_i($)){var q=L.getMouseInfo(R);$(q,R)}}),ti(L,"handleTouchMove",function(R){R.changedTouches!=null&&R.changedTouches.length>0&&L.throttleTriggeredAfterMouseMove(R.changedTouches[0])}),ti(L,"handleTouchStart",function(R){R.changedTouches!=null&&R.changedTouches.length>0&&L.handleMouseDown(R.changedTouches[0])}),ti(L,"handleTouchEnd",function(R){R.changedTouches!=null&&R.changedTouches.length>0&&L.handleMouseUp(R.changedTouches[0])}),ti(L,"handleDoubleClick",function(R){var $=L.props.onDoubleClick;if(_i($)){var q=L.getMouseInfo(R);$(q,R)}}),ti(L,"handleContextMenu",function(R){var $=L.props.onContextMenu;if(_i($)){var q=L.getMouseInfo(R);$(q,R)}}),ti(L,"triggerSyncEvent",function(R){L.props.syncId!==void 0&&wpe.emit(jpe,L.props.syncId,R,L.eventEmitterSymbol)}),ti(L,"applySyncEvent",function(R){var $=L.props,q=$.layout,U=$.syncMethod,V=L.state.updateId,X=R.dataStartIndex,se=R.dataEndIndex;if(R.dataStartIndex!==void 0||R.dataEndIndex!==void 0)L.setState(xr({dataStartIndex:X,dataEndIndex:se},_({props:L.props,dataStartIndex:X,dataEndIndex:se,updateId:V},L.state)));else if(R.activeTooltipIndex!==void 0){var te=R.chartX,Y=R.chartY,de=R.activeTooltipIndex,ie=L.state,ae=ie.offset,le=ie.tooltipTicks;if(!ae)return;if(typeof U=="function")de=U(le,R);else if(U==="value"){de=-1;for(var pe=0;pe=0){var ut,De;if(te.dataKey&&!te.allowDuplicatedCategory){var Dt=typeof te.dataKey=="function"?Ue:"payload.".concat(te.dataKey.toString());ut=hye(pe,Dt,de),De=be&&ye&&hye(ye,Dt,de)}else ut=pe==null?void 0:pe[Y],De=be&&ye&&ye[Y];if(Me||_e){var he=R.props.activeIndex!==void 0?R.props.activeIndex:Y;return[S.cloneElement(R,xr(xr(xr({},U.props),Fe),{},{activeIndex:he})),null,null]}if(!Zi(ut))return[Ae].concat(X3(L.renderActivePoints({item:U,activePoint:ut,basePoint:De,childIndex:Y,isRange:be})))}else{var Ve,nt=(Ve=L.getItemByXY(L.state.activeCoordinate))!==null&&Ve!==void 0?Ve:{graphicalItem:Ae},Qe=nt.graphicalItem,ke=Qe.item,ot=ke===void 0?R:ke,qe=Qe.childIndex,lt=xr(xr(xr({},U.props),Fe),{},{activeIndex:qe});return[S.cloneElement(ot,lt),null,null]}return be?[Ae,null,null]:[Ae,null]}),ti(L,"renderCustomized",function(R,$,q){return S.cloneElement(R,xr(xr({key:"recharts-customized-".concat(q)},L.props),L.state))}),ti(L,"renderMap",{CartesianGrid:{handler:kR,once:!0},ReferenceArea:{handler:L.renderReferenceElement},ReferenceLine:{handler:kR},ReferenceDot:{handler:L.renderReferenceElement},XAxis:{handler:kR},YAxis:{handler:kR},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((A=C.id)!==null&&A!==void 0?A:QL("recharts"),"-clip"),L.throttleTriggeredAfterMouseMove=RYe(L.triggeredAfterMouseMove,(I=C.throttleDelay)!==null&&I!==void 0?I:1e3/60),L.state={},L}return Cms(N,w),jms(N,[{key:"componentDidMount",value:function(){var A,I;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(A=this.props.margin.left)!==null&&A!==void 0?A: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 A=this.props,I=A.children,L=A.data,R=A.height,$=A.layout,q=sp(I,jg);if(q){var U=q.props.defaultIndex;if(!(typeof U!="number"||U<0||U>this.state.tooltipTicks.length-1)){var V=this.state.tooltipTicks[U]&&this.state.tooltipTicks[U].value,X=z0e(this.state,L,U,V),se=this.state.tooltipTicks[U].coordinate,te=(this.state.offset.top+R)/2,Y=$==="horizontal",de=Y?{x:se,y:te}:{y:se,x:te},ie=this.state.formattedGraphicalItems.find(function(le){var pe=le.item;return pe.type.name==="Scatter"});ie&&(de=xr(xr({},de),ie.props.points[U].tooltipPosition),X=ie.props.points[U].tooltipPayload);var ae={activeTooltipIndex:U,isTooltipActive:!0,activeLabel:V,activePayload:X,activeCoordinate:de};this.setState(ae),this.renderCursor(q),this.accessibilityManager.setIndex(U)}}}},{key:"getSnapshotBeforeUpdate",value:function(A,I){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==I.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==A.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==A.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(A){pye([sp(A.children,jg)],[sp(this.props.children,jg)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var A=sp(this.props.children,jg);if(A&&typeof A.props.shared=="boolean"){var I=A.props.shared?"axis":"item";return i.indexOf(I)>=0?I:o}return o}},{key:"getMouseInfo",value:function(A){if(!this.container)return null;var I=this.container,L=I.getBoundingClientRect(),R=UJt(L),$={chartX:Math.round(A.pageX-R.left),chartY:Math.round(A.pageY-R.top)},q=L.width/I.offsetWidth||1,U=this.inRange($.chartX,$.chartY,q);if(!U)return null;var V=this.state,X=V.xAxisMap,se=V.yAxisMap,te=this.getTooltipEventType(),Y=fLe(this.state,this.props.data,this.props.layout,U);if(te!=="axis"&&X&&se){var de=_1(X).scale,ie=_1(se).scale,ae=de&&de.invert?de.invert($.chartX):null,le=ie&&ie.invert?ie.invert($.chartY):null;return xr(xr({},$),{},{xValue:ae,yValue:le},Y)}return Y?xr(xr({},$),Y):null}},{key:"inRange",value:function(A,I){var L=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,R=this.props.layout,$=A/L,q=I/L;if(R==="horizontal"||R==="vertical"){var U=this.state.offset,V=$>=U.left&&$<=U.left+U.width&&q>=U.top&&q<=U.top+U.height;return V?{x:$,y:q}:null}var X=this.state,se=X.angleAxisMap,te=X.radiusAxisMap;if(se&&te){var Y=_1(se);return UIe({x:$,y:q},Y)}return null}},{key:"parseEventsOfWrapper",value:function(){var A=this.props.children,I=this.getTooltipEventType(),L=sp(A,jg),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 $=Pae(this.props,this.handleOuterEvent);return xr(xr({},$),R)}},{key:"addListener",value:function(){wpe.on(jpe,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){wpe.removeListener(jpe,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(A,I,L){for(var R=this.state.formattedGraphicalItems,$=0,q=R.length;$");return t}const dJe=S.forwardRef(({id:t,className:s,children:r,config:n,...a},o)=>{const l=S.useId(),i=`chart-${t||l.replace(/:/g,"")}`;return e.jsx(lJe.Provider,{value:{config:n},children:e.jsxs("div",{"data-chart":i,ref:o,className:Et("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(Wms,{id:i,config:n}),e.jsx(Rye,{children:r})]})})});dJe.displayName="Chart";const Wms=({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(Hms).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},uJe=S.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:g,labelKey:v},_)=>{const{config:b}=cJe(),j=S.useMemo(()=>{var L;if(a||!(s!=null&&s.length))return null;const[N]=s,C=`${v||N.dataKey||N.name||"value"}`,A=B0e(b,N,C),I=!v&&typeof l=="string"?((L=b[l])==null?void 0:L.label)||l:A==null?void 0:A.label;return i?e.jsx("div",{className:Et("font-medium",d),children:i(I,s)}):I?e.jsx("div",{className:Et("font-medium",d),children:I}):null},[l,i,s,a,d,b,v]);if(!t||!(s!=null&&s.length))return null;const w=s.length===1&&n!=="dot";return e.jsxs("div",{ref:_,className:Et("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:[w?null:j,e.jsx("div",{className:"grid gap-1.5",children:s.map((N,C)=>{const A=`${g||N.name||N.dataKey||"value"}`,I=B0e(b,N,A),L=p||N.payload.fill||N.color;return e.jsx("div",{className:Et("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&&(N==null?void 0:N.value)!==void 0&&N.name?u(N.value,N.name,N,C,N.payload):e.jsxs(e.Fragment,{children:[I!=null&&I.icon?e.jsx(I.icon,{}):!o&&e.jsx("div",{className:Et("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":w&&n==="dashed"}),style:{"--color-bg":L,"--color-border":L}}),e.jsxs("div",{className:Et("flex flex-1 justify-between leading-none",w?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[w?j:null,e.jsx("span",{className:"text-muted-foreground",children:(I==null?void 0:I.label)||N.name})]}),N.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:N.value.toLocaleString()})]})]})},N.dataKey)})})]})});uJe.displayName="ChartTooltip";const Gms=S.forwardRef(({className:t,hideIcon:s=!1,payload:r,verticalAlign:n="bottom",nameKey:a},o)=>{const{config:l}=cJe();return r!=null&&r.length?e.jsx("div",{ref:o,className:Et("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=B0e(l,i,d);return e.jsxs("div",{className:Et("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});Gms.displayName="ChartLegend";function B0e(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 NR=["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 A2e({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(Lt,{children:e.jsx(zt,{className:"text-base",children:"Transactions by Month"})}),e.jsx(Oe,{className:"overflow-hidden",children:e.jsx(dJe,{config:{count:{label:"Transactions",color:"hsl(var(--primary))"}},className:"h-[250px]",children:e.jsx(Rye,{width:"100%",height:"100%",children:e.jsxs(Ums,{data:t.transactionsByMonth,margin:{top:5,right:10,left:0,bottom:5},children:[e.jsx(WQe,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(jce,{dataKey:"month",tick:{fontSize:11},className:"fill-muted-foreground",interval:0}),e.jsx(kce,{allowDecimals:!1,tick:{fontSize:12},className:"fill-muted-foreground",width:30}),e.jsx(jg,{content:e.jsx(uJe,{})}),e.jsx(cS,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0],name:"Transactions"})]})})})})]}),n&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Oe,{children:[e.jsx("div",{className:"h-[250px]",children:e.jsx(Rye,{width:"100%",height:"100%",children:e.jsxs(Vms,{children:[e.jsx(av,{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(Qle,{fill:NR[o%NR.length]},`cell-${o}`))}),e.jsx(jg,{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:NR[o%NR.length]}}),e.jsx("span",{className:"text-muted-foreground",children:a.name})]},a.name))})]})]})]})}function Kms(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=J1e(s,n,new Date);if(Tge(a))return ws(a,"yyyy-MM-dd")}catch{}try{const n=new Date(s);if(Tge(n))return ws(n,"yyyy-MM-dd")}catch{}return null}const Zms=["property_address","city","state","zip","transaction_type","close_date","sale_price","commission_amount","lead_source","client_type","is_win","notes"];function Yms({open:t,onOpenChange:s}){const[r,n]=S.useState([]),[a,o]=S.useState(!1),[l,i]=S.useState(0),{data:d}=IL(),{data:u}=Ef(),p=Yoe(),g=()=>{const N=Zms.join(","),C=["123 Main St","Dallas","TX","75001","buyer","2024-06-15","450000","13500","Referral","Past Client","yes","Great transaction!"].join(","),A=`${N} ${C}`,I=new Blob([A],{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)},v=N=>{const C=N.split(` `).filter(I=>I.trim());if(C.length<2)return[];const A=C[0].split(",").map(I=>I.trim().toLowerCase().replace(/['"]/g,""));return C.slice(1).map((I,L)=>{var ae,le,pe,be;const R=[];let $="",q=!1;for(const ye of I)ye==='"'?q=!q:ye===","&&!q?(R.push($.trim()),$=""):$+=ye;R.push($.trim());const U=ye=>{var Ne;const we=A.indexOf(ye);return we>=0?(Ne=R[we])==null?void 0:Ne.replace(/^["']|["']$/g,"").trim():""},V=(ae=U("transaction_type"))==null?void 0:ae.toLowerCase(),X=(le=U("sale_price"))==null?void 0:le.replace(/[$,]/g,""),se=(pe=U("commission_amount"))==null?void 0:pe.replace(/[$,]/g,""),te=(be=U("is_win"))==null?void 0:be.toLowerCase(),Y=U("close_date"),de=Kms(Y);let ie;return U("property_address")?["buyer","seller"].includes(V)?de?(!X||isNaN(Number(X)))&&(ie="Invalid sale price"):ie=`Invalid date format: "${Y}" - use MM/DD/YYYY or YYYY-MM-DD`:ie='Transaction type must be "buyer" or "seller"':ie="Missing property address",{property_address:U("property_address"),city:U("city"),state:U("state"),zip:U("zip"),transaction_type:V==="seller"?"seller":"buyer",close_date:de||"",sale_price:Number(X)||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:ie}})},_=N=>{var I;const C=(I=N.target.files)==null?void 0:I[0];if(!C)return;const A=new FileReader;A.onload=L=>{var q;const R=(q=L.target)==null?void 0:q.result,$=v(R);n($)},A.readAsText(C)},b=async()=>{const N=r.filter(I=>!I.error);if(N.length===0){fe.error("No valid transactions to import");return}o(!0),i(0);let C=0,A=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}),C++}catch(R){A++,console.error("Failed to import transaction:",R)}i(Math.round((I+1)/N.length*100))}o(!1),C>0&&fe.success(`Imported ${C} transaction${C>1?"s":""}`),A>0&&fe.error(`Failed to import ${A} transaction${A>1?"s":""}`),n([]),s(!1)},j=r.filter(N=>!N.error).length,w=r.filter(N=>N.error).length;return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-2xl max-h-[90vh]",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:g,children:[e.jsx(gi,{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(at,{variant:"outline",children:[r.length," rows found"]}),j>0&&e.jsxs(at,{className:"bg-green-500 text-white",children:[e.jsx(fa,{className:"h-3 w-3 mr-1"}),j," valid"]}),w>0&&e.jsxs(at,{variant:"destructive",children:[e.jsx(Qo,{className:"h-3 w-3 mr-1"}),w," errors"]})]}),e.jsx(Fi,{className:"h-[200px] border rounded-lg",children:e.jsxs("div",{className:"p-2 space-y-2",children:[r.slice(0,10).map((N,C)=>e.jsxs("div",{className:`p-2 rounded text-sm ${N.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:N.property_address||"(no address)"}),e.jsx(at,{variant:N.transaction_type==="buyer"?"default":"secondary",children:N.transaction_type})]}),e.jsxs("div",{className:"text-muted-foreground",children:[N.close_date," • $",N.sale_price.toLocaleString()]}),N.error&&e.jsx(rwe,{variant:"destructive",className:"mt-1 py-1",children:e.jsx(nwe,{className:"text-xs",children:N.error})})]},C)),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:j===0||a,children:[e.jsx(Xa,{className:"h-4 w-4 mr-2"}),"Import ",j," Transaction",j!==1?"s":""]})]})]})]})})}const Xms=eS({transactions_goal:VP().min(0).optional(),volume_goal:VP().min(0).optional(),gci_goal:VP().min(0).optional()});function Qms({open:t,onOpenChange:s,year:r,existingGoals:n}){const a=$5t(),{data:o}=Xoe(),l=(o==null?void 0:o.show_commission)??!0,i=Ooe({resolver:Roe(Xms),defaultValues:{transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0}});S.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(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{children:[r," Goals"]}),e.jsx(Kr,{children:"Set your annual targets to track your progress throughout the year."})]}),e.jsx(Foe,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(d),className:"space-y-4",children:[e.jsx(vc,{control:i.control,name:"transactions_goal",render:({field:u})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Transactions Goal"}),e.jsx(dc,{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(rre,{children:"Total number of deals you want to close"}),e.jsx(Ah,{})]})}),e.jsx(vc,{control:i.control,name:"volume_goal",render:({field:u})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"Volume Goal ($)"}),e.jsx(dc,{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(rre,{children:"Total sales volume you want to achieve"}),e.jsx(Ah,{})]})}),l&&e.jsx(vc,{control:i.control,name:"gci_goal",render:({field:u})=>e.jsxs(lc,{children:[e.jsx(cc,{children:"GCI Goal ($)"}),e.jsx(dc,{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(rre,{children:"Gross commission income target"}),e.jsx(Ah,{})]})}),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 E2e({transactions:t,isLoading:s}){const r=S.useRef(null),n=S.useRef(null),a=S.useRef([]),o=S.useRef(null),{isAdmin:l}=Gs(),[i,d]=S.useState(""),[u,p]=S.useState(!0),[g,v]=S.useState(0),[_,b]=S.useState(!1),j=t.filter(N=>N.latitude!=null&&N.longitude!=null),w=t.filter(N=>N.latitude==null||N.longitude==null);return S.useEffect(()=>{(async()=>{p(!0);try{const{data:C}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();C!=null&&C.value&&d(C.value)}catch(C){console.error("Error fetching mapbox token:",C)}p(!1)})()},[]),S.useEffect(()=>{if(!i||w.length===0||_)return;(async()=>{var A;b(!0);let C=0;for(const I of w){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((A=$.features)!=null&&A[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,C++}}catch(R){console.error("Geocode error:",R)}}v(C),b(!1)})()},[i,t]),S.useEffect(()=>{if(!r.current||!i||n.current)return;$c.accessToken=i;const N=t.filter(I=>I.latitude!=null&&I.longitude!=null);let C=[-98.5795,39.8283],A=4;if(N.length>0){const I=N.reduce((R,$)=>R+$.longitude,0)/N.length,L=N.reduce((R,$)=>R+$.latitude,0)/N.length;C=[I,L],A=N.length===1?12:10}return n.current=new $c.Map({container:r.current,style:"mapbox://styles/mapbox/light-v11",zoom:A,center:C}),n.current.addControl(new $c.NavigationControl,"top-right"),()=>{var I;(I=n.current)==null||I.remove(),n.current=null}},[i]),S.useEffect(()=>{var C;if(!n.current||!i)return;a.current.forEach(A=>A.remove()),a.current=[],(C=o.current)==null||C.remove();const N=t.filter(A=>A.latitude!=null&&A.longitude!=null);if(N.forEach(A=>{var U;const I=A.transaction_type==="buyer",L=I?"#3B82F6":"#10B981",R=document.createElement("div");R.className="cursor-pointer",R.innerHTML=`
${I?'':''}
`;const $=new $c.Popup({offset:25,closeButton:!0}).setHTML(`
${A.property_address}
${A.city?`
${A.city}${A.state?", "+A.state:""} ${A.zip||""}
`:""}
${I?"Buyer":"Seller"} $${Number(A.sale_price).toLocaleString()}
Closed: ${new Date(A.close_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} ${(U=A.lead_source)!=null&&U.name?" · "+A.lead_source.name:""}
${A.contact?`
Client: ${A.contact.first_name} ${A.contact.last_name||""}
`:""}
`),q=new $c.Marker(R).setLngLat([A.longitude,A.latitude]).setPopup($).addTo(n.current);a.current.push(q)}),N.length>1){const A=new $c.LngLatBounds;N.forEach(I=>A.extend([I.longitude,I.latitude])),n.current.fitBounds(A,{padding:60,maxZoom:13})}else N.length===1&&n.current.flyTo({center:[N[0].longitude,N[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(Ti,{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:[j.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(Qo,{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 hJe=()=>{const{data:t}=Mf();return Ct({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"})},Jms=t=>{const{data:s}=Mf(),{data:r}=hJe();return Ct({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 eps(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 tps(t,s){return t?t.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2):s[0].toUpperCase()}function sps({year:t}){var v;const{data:s,isLoading:r}=hJe(),{data:n,isLoading:a}=Jms(t),o=Lr(),l=r||a,{aggregate:i,memberStats:d,topPerformer:u,agentNameMap:p,teamChartStats:g}=S.useMemo(()=>{if(!s||!n)return{aggregate:null,memberStats:[],topPerformer:null,agentNameMap:{},teamChartStats:null};const _=s.map(V=>eps(V,n));_.sort((V,X)=>X.totalVolume-V.totalVolume);const b={};s.forEach(V=>{b[V.id]=V.name||V.email});const j=n.length,w=n.reduce((V,X)=>V+Number(X.sale_price),0),N=n.reduce((V,X)=>V+(Number(X.commission_amount)||0),0),C=n.filter(V=>V.transaction_type==="buyer").length,A=n.filter(V=>V.transaction_type==="seller").length,I={};n.forEach(V=>{var se;const X=((se=V.lead_source)==null?void 0:se.name)||"Unknown";I[X]=(I[X]||0)+1});const L=Object.entries(I).sort((V,X)=>X[1]-V[1])[0],R={};n.forEach(V=>{const X=new Date(V.close_date).toLocaleString("default",{month:"short"});R[X]=(R[X]||0)+1});const q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(V=>({month:V,count:R[V]||0})),U=Object.entries(I).map(([V,X])=>({name:V,count:X})).sort((V,X)=>X.count-V.count);return{aggregate:{totalTxns:j,buyerCount:C,sellerCount:A,totalVolume:w,avgPrice:j>0?w/j:0,totalGCI:N,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(gs,{className:"h-24"},_))}),e.jsx(gs,{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(Vn,{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(Gc,{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:Cl(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(Sc,{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:Cl(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(Gc,{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:Cl(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(ec,{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:((v=i.topSource)==null?void 0:v.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(Gi,{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:Cl(u.totalVolume,!0)})]})]})}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-lg",children:"Member Performance"})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Agent"}),e.jsx(jt,{className:"text-center",children:"Transactions"}),e.jsx(jt,{className:"text-center",children:"B / S"}),e.jsx(jt,{className:"text-right",children:"Volume"}),e.jsx(jt,{className:"text-right",children:"Avg Price"}),e.jsx(jt,{className:"text-right",children:"GCI"}),e.jsx(jt,{className:"text-right"})]})}),e.jsx(En,{children:d.map((_,b)=>e.jsxs(js,{children:[e.jsx(it,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[b===0&&_.totalTransactions>0&&e.jsx(Gi,{className:"absolute -top-2 -right-2 h-3.5 w-3.5 text-amber-500"}),e.jsxs(fn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:_.member.avatar_url||void 0}),e.jsx(gn,{className:"text-xs",children:tps(_.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(it,{className:"text-center font-semibold",children:_.totalTransactions}),e.jsxs(it,{className:"text-center text-sm",children:[_.buyerCount," / ",_.sellerCount]}),e.jsx(it,{className:"text-right font-medium",children:Cl(_.totalVolume,!0)}),e.jsx(it,{className:"text-right text-sm",children:Cl(_.averagePrice,!0)}),e.jsx(it,{className:"text-right font-medium",children:Cl(_.totalGCI,!0)}),e.jsx(it,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>o(`/mission-control/scorecard/${_.member.id}`),children:e.jsx(ya,{className:"h-4 w-4"})})})]},_.member.id))})]})})})]}),e.jsxs(ja,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsxs(Ns,{value:"transactions",children:[e.jsx(qh,{className:"h-4 w-4 mr-1"}),"All Transactions"]}),e.jsxs(Ns,{value:"charts",children:[e.jsx(Xo,{className:"h-4 w-4 mr-1"}),"Charts"]}),e.jsxs(Ns,{value:"map",children:[e.jsx(Ti,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(zs,{value:"transactions",children:e.jsx(wwe,{transactions:n||[],showCommission:!0,isLoading:a,agentNameMap:p,readOnly:!0})}),e.jsx(zs,{value:"charts",children:g&&e.jsx(A2e,{stats:g,year:t})}),e.jsx(zs,{value:"map",children:e.jsx(E2e,{transactions:n||[],isLoading:a})})]})]})}const mJe=new Date().getFullYear(),yLe=Array.from({length:10},(t,s)=>mJe-s);function rps(){var U;const[t,s]=S.useState(mJe),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(!1),[d,u]=S.useState(!1),[p,g]=S.useState("my"),{data:v}=Mf(),_=(v==null?void 0:v.role)==="team_leader",{data:b,isLoading:j}=nbe(t),{yearStats:w,lifetimeStats:N,showCommission:C}=vVe(t),{data:A,isLoading:I}=yVe(t),{data:L}=Xoe(),R=q5t(),$=()=>{if(!b||b.length===0)return;const V=["Property Address","City","State","Zip","Transaction Type","Close Date","Sale Price",...C?["Commission"]:[],"Lead Source","Client Type","Contact Name","Is Win","Notes"],X=b.map(ie=>{var ae,le;return[ie.property_address,ie.city||"",ie.state||"",ie.zip||"",ie.transaction_type,ie.close_date,ie.sale_price,...C?[ie.commission_amount||""]:[],((ae=ie.lead_source)==null?void 0:ae.name)||"",((le=ie.client_type)==null?void 0:le.name)||"",ie.contact?`${ie.contact.first_name} ${ie.contact.last_name||""}`.trim():"",ie.is_win?"Yes":"No",ie.notes||""]}),se=[V,...X].map(ie=>ie.map(ae=>`"${String(ae).replace(/"/g,'""')}"`).join(",")).join(` `),te=new Blob([se],{type:"text/csv"}),Y=URL.createObjectURL(te),de=document.createElement("a");de.href=Y,de.download=`transactions-${t}.csv`,de.click(),URL.revokeObjectURL(Y)},q=!b||b.length===0;return e.jsxs(Ms,{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:()=>g("my"),className:"h-8",children:"My Scorecard"}),e.jsxs(K,{variant:p==="team"?"default":"ghost",size:"sm",onClick:()=>g("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(tr,{value:String(t),onValueChange:V=>s(Number(V)),children:[e.jsx(Js,{className:"w-[120px]",children:e.jsx(sr,{})}),e.jsx(er,{children:yLe.map(V=>e.jsx(At,{value:String(V),children:V},V))})]})]}),e.jsx(sps,{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(tr,{value:String(t),onValueChange:V=>s(Number(V)),children:[e.jsx(Js,{className:"w-[120px]",children:e.jsx(sr,{})}),e.jsx(er,{children:yLe.map(V=>e.jsx(At,{value:String(V),children:V},V))})]}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(!d),children:e.jsx(Fl,{className:"h-4 w-4"})})]})]}),d&&e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(zt,{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:V=>R.mutate({show_commission:V})})]})})]}),q&&!j?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(Xo,{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(Xa,{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(gi,{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(Uh,{className:"h-4 w-4 mr-2"}),"Set Goals"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(Xa,{className:"h-4 w-4 mr-2"}),"Import"]}),e.jsxs(K,{variant:"outline",onClick:$,disabled:q,children:[e.jsx(gi,{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(gi,{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(Vn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:w.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[N.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:[w.buyerCount,"/",w.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(Gc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Cl(w.totalVolume,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Cl(N.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(Sc,{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:Cl(w.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(ec,{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=w.topLeadSource)==null?void 0:U.name)||"-"}),w.topLeadSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[w.topLeadSource.count," deals"]})]})}),C&&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(Gc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Cl(w.totalCommission,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Cl(N.totalCommission,!0)," lifetime"]})]})}),C&&w.totalNetToAgent>0&&w.totalNetToAgent!==w.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(Gc,{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:Cl(w.totalNetToAgent,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Cl(N.totalNetToAgent,!0)," lifetime"]})]})})]}),A&&e.jsx(wZe,{goals:A,stats:w,year:t,showCommission:C}),e.jsxs(ja,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsx(Ns,{value:"transactions",children:"Transactions"}),e.jsx(Ns,{value:"charts",children:"Charts"}),e.jsxs(Ns,{value:"map",children:[e.jsx(Ti,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(zs,{value:"transactions",children:e.jsx(wwe,{transactions:b||[],showCommission:C,isLoading:j})}),e.jsx(zs,{value:"charts",children:e.jsx(A2e,{stats:w,year:t})}),e.jsx(zs,{value:"map",children:e.jsx(E2e,{transactions:b||[],isLoading:j})})]})]})]})]}),e.jsx(bZe,{open:r,onOpenChange:n}),e.jsx(Yms,{open:a,onOpenChange:o}),e.jsx(Qms,{open:l,onOpenChange:i,year:t,existingGoals:A})]})}function pJe({open:t,onOpenChange:s,listingId:r,listingSlug:n,listingTitle:a}){const{user:o}=Gs(),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,g]=S.useState(!1);S.useEffect(()=>{(async()=>{if(!(!t||!o)){u(!0);try{const{data:w,error:N}=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(N)throw N;if(w&&w.share_token)i(w);else if(w&&!w.share_token){const{data:C,error:A}=await G.from("listing_shares").update({share_type:"referral_link"}).eq("id",w.id).select("id, share_token, click_count, lead_count").single();if(A)throw A;i(C)}else{const{data:C,error:A}=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(A)throw A;i(C)}}catch(w){console.error("Error creating share link:",w),fe.error("Failed to generate share link")}finally{u(!1)}}})()},[t,o,r]);const v=l!=null&&l.share_token?`https://listings.relevelup.com/${n||r}?ref=${l.share_token}`:"",_=async()=>{try{await navigator.clipboard.writeText(v),g(!0),fe.success("Link copied to clipboard!"),setTimeout(()=>g(!1),2e3)}catch{fe.error("Failed to copy link")}},b=j=>{const w=encodeURIComponent(v),N=encodeURIComponent(`Check out this listing: ${a}`);switch(j){case"email":window.open(`mailto:?subject=${N}&body=${w}`);break;case"text":window.open(`sms:?body=${N}%20${w}`);break;case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${w}`,"_blank");break}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(mn,{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...":v,readOnly:!0,className:"font-mono text-sm"}),e.jsx(K,{onClick:_,disabled:d||!v,variant:p?"default":"outline",children:p?e.jsx(fa,{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(Ud,{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(ya,{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 nps={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},aps={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},ips={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function SR({listing:t,onClick:s,onEdit:r,onDelete:n,showActions:a}){var j,w;const{user:o}=Gs(),{data:l}=uVe(t.id),i=dVe(),[d,u]=S.useState(!1),p=N=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(N),g=((j=t.photos)==null?void 0:j.find(N=>N.is_primary))||((w=t.photos)==null?void 0:w[0]),v=(o==null?void 0:o.id)===t.agent_id,_=async N=>{N.stopPropagation();try{const C=await i.mutateAsync(t.id);fe.success(C.saved?"Listing saved!":"Listing removed from saved")}catch{fe.error("Failed to save listing")}},b=N=>{if(N.stopPropagation(),o)u(!0);else{const C=`https://listings.relevelup.com/${t.slug||t.id}`;navigator.clipboard.writeText(C),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:[g?e.jsx("img",{src:g.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(Gx,{className:"h-12 w-12"})}),e.jsx(at,{className:`absolute top-2 left-2 ${nps[t.status]} text-white border-0`,children:aps[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(Ni,{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:v?"Copy link":"Share & earn leads",children:v?e.jsx(ld,{className:"h-4 w-4"}):e.jsx(mn,{className:"h-4 w-4 text-amber-500"})})]})]}),e.jsx(pJe,{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(at,{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(Ti,{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(j0,{className:"h-4 w-4"}),t.bedrooms," bd"]}),t.bathrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($x,{className:"h-4 w-4"}),t.bathrooms," ba"]}),t.square_footage&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gx,{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(at,{variant:"secondary",className:"text-xs",children:ips[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(ya,{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(Ni,{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:N=>{N.stopPropagation(),r()},children:[e.jsx(Dc,{className:"h-4 w-4 mr-2"}),"Edit"]}),n&&e.jsx(K,{variant:"destructive",size:"sm",onClick:N=>{N.stopPropagation(),n()},children:e.jsx(jr,{className:"h-4 w-4"})})]})]})]})}const ops=[{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"}],lps=[{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 cps({filters:t,onFiltersChange:s,onClose:r}){const n=()=>{s({sortBy:"newest"})};return e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between pb-3",children:[e.jsx(zt,{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(tr,{value:t.status||"all",onValueChange:a=>s({...t,status:a==="all"?void 0:a}),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"All statuses"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Statuses"}),ops.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(tr,{value:t.propertyType||"all",onValueChange:a=>s({...t,propertyType:a==="all"?void 0:a}),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"All types"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Types"}),lps.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 dps({leaderboard:t}){const s=n=>{switch(n){case 0:return e.jsx(Gi,{className:"h-5 w-5 text-amber-500"});case 1:return e.jsx(T0,{className:"h-5 w-5 text-gray-400"});case 2:return e.jsx(ec,{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(at,{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(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Gi,{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(Vn,{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(T0,{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(Gi,{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(Lt,{children:e.jsx(zt,{children:"Community Leaderboard"})}),e.jsx(Oe,{children:e.jsxs(ja,{defaultValue:"sharers",children:[e.jsxs(va,{className:"w-full",children:[e.jsxs(Ns,{value:"sharers",className:"flex-1",children:[e.jsx(ld,{className:"h-4 w-4 mr-2"}),"Top Sharers"]}),e.jsxs(Ns,{value:"listers",className:"flex-1",children:[e.jsx(Vn,{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 vLe={coming_soon:"#F59E0B",active:"#10B981",price_improvement:"#8B5CF6",under_contract:"#3B82F6",sold:"#A855F7"},_Le={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function ups(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function hps({listings:t,isLoading:s}){const r=Lr(),n=S.useRef(null),a=S.useRef(null),o=S.useRef([]),{isAdmin:l}=Gs(),[i,d]=S.useState(""),[u,p]=S.useState(!0),[g,v]=S.useState(!1),_=t.filter(j=>j.latitude!=null&&j.longitude!=null),b=t.filter(j=>(j.latitude==null||j.longitude==null)&&(j.property_address||j.city));return S.useEffect(()=>{(async()=>{p(!0);try{const{data:w}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();w!=null&&w.value&&d(w.value)}catch(w){console.error("Error fetching mapbox token:",w)}p(!1)})()},[]),S.useEffect(()=>{if(!i||b.length===0||g)return;(async()=>{var w;v(!0);for(const N of b){const C=[N.property_address,N.city,N.state].filter(Boolean).join(", ");if(C)try{const I=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(C)}.json?access_token=${i}&limit=1`)).json();if((w=I.features)!=null&&w[0]){const[L,R]=I.features[0].center;await G.from("listings").update({latitude:R,longitude:L}).eq("id",N.id),N.latitude=R,N.longitude=L}}catch(A){console.error("Geocode error:",A)}}v(!1)})()},[i,t]),S.useEffect(()=>{if(!n.current||!i||a.current)return;$c.accessToken=i;const j=t.filter(C=>C.latitude!=null&&C.longitude!=null);let w=[-98.5795,39.8283],N=4;if(j.length>0){const C=j.reduce((I,L)=>I+L.longitude,0)/j.length,A=j.reduce((I,L)=>I+L.latitude,0)/j.length;w=[C,A],N=j.length===1?12:10}return a.current=new $c.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:N,center:w}),a.current.addControl(new $c.NavigationControl,"top-right"),()=>{var C;(C=a.current)==null||C.remove(),a.current=null}},[i]),S.useEffect(()=>{if(!a.current||!i)return;o.current.forEach(w=>w.remove()),o.current=[];const j=t.filter(w=>w.latitude!=null&&w.longitude!=null);if(j.forEach(w=>{var R,$,q;const N=vLe[w.status]||"#10B981",C=((R=w.photos)==null?void 0:R.find(U=>U.is_primary))||(($=w.photos)==null?void 0:$[0]),A=document.createElement("div");A.className="cursor-pointer",A.innerHTML=`
`;const I=new $c.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${C!=null&&C.photo_url?``:""}
${ups(w.price)}
${w.property_address||""}
${w.city}, ${w.state}
${_Le[w.status]||w.status} ${w.bedrooms?`${w.bedrooms} bed`:""} ${w.bathrooms?`${w.bathrooms} bath`:""}
${(q=w.agent)!=null&&q.name?`
Listed by ${w.agent.name}
`:""}
Click to view details →
`),L=new $c.Marker(A).setLngLat([w.longitude,w.latitude]).setPopup(I).addTo(a.current);o.current.push(L)}),j.length>1){const w=new $c.LngLatBounds;j.forEach(N=>w.extend([N.longitude,N.latitude])),a.current.fitBounds(w,{padding:60,maxZoom:13})}else j.length===1&&a.current.flyTo({center:[j[0].longitude,j[0].latitude],zoom:12})},[t,i,g]),S.useEffect(()=>(window.__navigateToListing__=j=>{r(`/mission-control/listings/${j}`)},()=>{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(Ti,{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(vLe).map(([j,w])=>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:w}}),e.jsx("span",{className:"text-xs",children:_Le[j]})]},j)),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[_.length," of ",t.length," mapped",g&&" · 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(Qo,{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 mps(){var U,V,X,se,te,Y,de,ie;const t=Lr(),{brokerageId:s}=Gs(),{data:r,isLoading:n}=aVe(),[a,o]=S.useState("feed"),[l,i]=S.useState(!1),[d,u]=S.useState(""),[p,g]=S.useState({sortBy:"newest"}),{data:v,isLoading:_}=iVe({...p,city:d||p.city}),{data:b,isLoading:j}=S5t(),{data:w,isLoading:N}=oVe(),{data:C,isLoading:A}=A5t(),{data:I,isLoading:L}=I5t(),{data:R}=P5t(),$=cVe(),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(Ms,{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(Ms,{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(Vn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(v==null?void 0:v.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(Ni,{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(Yk,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(w==null?void 0:w.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=C==null?void 0:C.sent)==null?void 0:U.length)||0)+(((V=C==null?void 0:C.received)==null?void 0:V.length)||0)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Referrals"})]})]})})]}),e.jsxs(ja,{value:a,onValueChange:o,children:[e.jsxs(va,{className:"w-full justify-start overflow-x-auto",children:[e.jsx(Ns,{value:"feed",children:"Community Feed"}),s&&e.jsx(Ns,{value:"brokerage",children:"Brokerage"}),e.jsx(Ns,{value:"my-listings",children:"My Listings"}),e.jsx(Ns,{value:"saved",children:"Saved"}),e.jsx(Ns,{value:"referrals",children:"Referrals"}),e.jsx(Ns,{value:"map",children:"Map"}),e.jsx(Ns,{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(xn,{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(tr,{value:p.sortBy,onValueChange:ae=>g({...p,sortBy:ae}),children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{placeholder:"Sort by"})}),e.jsxs(er,{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(Ux,{className:"h-4 w-4 mr-2"}),"Filters"]})]}),l&&e.jsx(cps,{filters:p,onFiltersChange:g,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(gs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(gs,{className:"h-5 w-3/4"}),e.jsx(gs,{className:"h-4 w-1/2"}),e.jsx(gs,{className:"h-4 w-1/4"})]})]},le))}):(v==null?void 0:v.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Vn,{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:v==null?void 0:v.map(ae=>e.jsx(SR,{listing:ae,onClick:()=>t(`/mission-control/listings/${ae.id}`)},ae.id))})]}),e.jsx(zs,{value:"my-listings",className:"space-y-4",children:N?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(gs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(gs,{className:"h-5 w-3/4"}),e.jsx(gs,{className:"h-4 w-1/2"})]})]},le))}):(w==null?void 0:w.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Yk,{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:w==null?void 0:w.map(ae=>e.jsx(SR,{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:j?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(gs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(gs,{className:"h-5 w-3/4"}),e.jsx(gs,{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(Ni,{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(SR,{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 (",((X=C==null?void 0:C.sent)==null?void 0:X.length)||0,")"]}),((se=C==null?void 0:C.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=C==null?void 0:C.sent)==null?void 0:te.map(ae=>{var le,pe;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)||((pe=ae.listing)==null?void 0:pe.city)})]}),e.jsx(at,{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 (",((Y=C==null?void 0:C.received)==null?void 0:Y.length)||0,")"]}),((de=C==null?void 0:C.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:(ie=C==null?void 0:C.received)==null?void 0:ie.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(at,{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(gs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(gs,{className:"h-5 w-3/4"}),e.jsx(gs,{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(Yk,{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(SR,{listing:ae,onClick:()=>t(`/mission-control/listings/${ae.id}`)},ae.id))})}),e.jsx(zs,{value:"map",children:e.jsx(hps,{listings:v||[],isLoading:_})}),e.jsx(zs,{value:"leaderboard",children:e.jsx(dps,{leaderboard:R})})]})]})}):e.jsx(Ms,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Vn,{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 P2e(t){const s=t.expected_commission;if(!s)return null;let r=s;return t.brokerage_split_pct&&(r-=s*(t.brokerage_split_pct/100)),t.team_split_pct&&(r-=s*(t.team_split_pct/100)),t.franchise_fee_pct&&(r-=s*(t.franchise_fee_pct/100)),t.referral_fee_pct&&(r-=s*(t.referral_fee_pct/100)),t.transaction_fee&&(r-=t.transaction_fee),Math.max(0,r)}function Sce(){const t=si();return Ct({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 fJe(){const t=si(),s=ns();return Ot({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 Cce(){const t=si();return Ct({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 gJe(){const t=si(),s=ns();return Ot({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 xJe(){const t=ns();return Ot({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 pps(){const t=ns();return Ot({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 fps(){const t=ns();return Ot({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 gps(t){return Ct({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 xps(){const t=ns();return Ot({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 yps(t){return Ct({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 vps(){const t=ns();return Ot({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 _ps(){const t=ns();return Ot({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 bps(){const t=si();return Ct({queryKey:["deal-pipeline-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("deal_pipeline").select("expected_price, expected_commission, brokerage_split_pct, team_split_pct, franchise_fee_pct, referral_fee_pct, transaction_fee, stage_id, 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(o=>{var l,i,d;return!((l=o.deal_pipeline_stages)!=null&&l.is_won_stage)&&!((i=o.deal_pipeline_stages)!=null&&i.is_lost_stage)&&((d=o.deal_pipeline_stages)==null?void 0:d.name)!=="Cancelled"}))||[],a=(s==null?void 0:s.filter(o=>{var l;return(l=o.deal_pipeline_stages)==null?void 0:l.is_won_stage}))||[];return{totalDeals:(s==null?void 0:s.length)||0,activeDeals:n.length,wonDeals:a.length,pipelineValue:n.reduce((o,l)=>o+(l.expected_price||0),0),expectedCommission:n.reduce((o,l)=>o+(l.expected_commission||0),0),expectedNetToAgent:n.reduce((o,l)=>o+(P2e(l)||0),0),wonValue:a.reduce((o,l)=>o+(l.expected_price||0),0)}},enabled:!!t})}function wps(t){const s=si();return Ct({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 jps(){const t=ns();return Ot({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 kps(){const t=ns();return Ot({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 Nps({listing:t}){const s=Lr(),[r,n]=S.useState(""),[a,o]=S.useState(!1),{data:l,isLoading:i}=wps(t.id),{data:d,isLoading:u}=Sce(),{data:p,isLoading:g}=Cce(),v=fJe(),_=jps(),b=kps(),j=gJe(),w=(p==null?void 0:p.filter(L=>!L.listing_id))||[],N=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")}},C=async()=>{o(!0);try{d!=null&&d.length||await v.mutateAsync();const L=N(t.status);await j.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)}},A=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(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2 text-base",children:[e.jsx(Vx,{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(As,{className:"h-5 w-5 animate-spin text-muted-foreground"})})})]}):l?e.jsxs(Ee,{className:"border-primary/20 bg-primary/5",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"flex items-center gap-2 text-base",children:[e.jsx(Ho,{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(at,{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(Ui,{className:"h-3 w-3 ml-1"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:I,disabled:b.isPending,children:b.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(cN,{className:"h-4 w-4"})})]})]})]}):e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"flex items-center gap-2 text-base",children:[e.jsx(Vx,{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:C,disabled:a||j.isPending,className:"w-full",size:"sm",children:[a||j.isPending?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create New Deal"]}),w.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(tr,{value:r,onValueChange:n,children:[e.jsx(Js,{className:"flex-1 text-sm",children:e.jsx(sr,{placeholder:"Link to existing deal..."})}),e.jsx(er,{children:w.map(L=>e.jsx(At,{value:L.id,children:L.deal_name},L.id))})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:A,disabled:!r||_.isPending,children:_.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(Ho,{className:"h-4 w-4"})})]})]})]})]})}const Sps={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Cps={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 Mps(){var te,Y,de,ie,ae,le,pe,be,ye;const{listingId:t}=Co(),s=Lr(),{user:r}=Gs(),{data:n,isLoading:a}=lVe(t||""),{data:o}=uVe(t||""),{data:l}=M5t(t||""),i=dVe(),d=C5t(),u=T5t(),p=cVe(),g=E5t(),[v,_]=S.useState(!1),[b,j]=S.useState(!1),[w,N]=S.useState(!1),[C,A]=S.useState(null),[I,L]=S.useState({buyerName:"",buyerType:"",notes:""}),R=(r==null?void 0:r.id)===(n==null?void 0:n.agent_id),$=we=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(we),q=async we=>{const Ne=`https://listings.relevelup.com/${(n==null?void 0:n.slug)||(n==null?void 0:n.id)}`,Ke=`Check out this listing: ${(n==null?void 0:n.property_address)||(n==null?void 0:n.city)}`;u.mutate({listingId:n.id,shareType:we});try{switch(we){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(`${Ke} ${Ne}`)}`);break;case"email":window.open(`mailto:?subject=${encodeURIComponent(Ke)}&body=${encodeURIComponent(`Check out this listing: ${Ne}`)}`);break}}catch(_e){console.error("Share error:",_e),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")}},V=async()=>{if(!I.buyerName.trim()){fe.error("Please enter buyer name");return}try{await g.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!"),j(!1),L({buyerName:"",buyerType:"",notes:""})}catch{fe.error("Failed to send referral")}},X=we=>{var Ae,Ue;const Ne=(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`,Ke=$((n==null?void 0:n.price)||0),_e=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=[_e,Me,Te].filter(Boolean).join(" | ");switch(we){case"just_listed":return`🏡 JUST LISTED! ${Ne} ${Ke} ${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 ${Ke}! ${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(Ms,{title:"Listing",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{className:"h-10 w-32"}),e.jsx(gs,{className:"h-[400px] w-full"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsx(gs,{className:"h-48"}),e.jsx(gs,{className:"h-48"}),e.jsx(gs,{className:"h-48"})]})]})});if(!n)return e.jsx(Ms,{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(we=>we.is_primary))||((Y=n.photos)==null?void 0:Y[0]);return e.jsxs(Ms,{title:"",description:"",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/mission-control/listings"),children:[e.jsx(Ka,{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&&A(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((we,Ne)=>e.jsx("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>A(we.photo_url),children:e.jsx("img",{src:we.photo_url,alt:`Photo ${Ne+2}`,className:"w-full h-full object-cover"})},we.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(at,{className:`${Sps[n.status]} text-white border-0`,children:Cps[n.status]}),n.is_featured&&e.jsxs(at,{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(at,{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(Ti,{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(Ni,{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(Z1,{className:"h-4 w-4"}):e.jsx(cf,{className:"h-4 w-4"})}),!R&&e.jsxs(K,{variant:"outline",className:"border-amber-500 text-amber-600 hover:bg-amber-50",onClick:()=>N(!0),children:[e.jsx(mn,{className:"h-4 w-4 mr-2"}),"Share & Earn Leads"]}),e.jsxs(yu,{children:[e.jsx(vu,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(ld,{className:"h-4 w-4 mr-2"}),"Share"]})}),e.jsxs(Wd,{children:[e.jsxs(Da,{onClick:()=>q("copy"),children:[e.jsx(ai,{className:"h-4 w-4 mr-2"}),"Copy Link"]}),e.jsxs(Da,{onClick:()=>q("facebook"),children:[e.jsx(Ud,{className:"h-4 w-4 mr-2"}),"Facebook"]}),e.jsxs(Da,{onClick:()=>q("text"),children:[e.jsx(io,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(Da,{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(Dc,{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(j0,{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($x,{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(Gx,{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(at,{variant:"secondary",children:[e.jsx(Ca,{className:"h-3 w-3 mr-1"}),bLe[n.property_type]]}),n.lot_size&&e.jsxs(at,{variant:"secondary",children:["Lot: ",n.lot_size]}),n.has_hoa&&e.jsx(at,{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(rn,{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(ya,{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(Ni,{className:"h-4 w-4"}),n.save_count," saves"]})]})]})}),n.allow_sharing&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-lg",children:"Share Content"})}),e.jsx(Oe,{className:"space-y-4",children:["just_listed","price_improvement","teaser"].map(we=>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:[we.replace("_"," ")," Caption"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(X(we)),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:X(we)})]},we))})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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=(ie=n.agent)==null?void 0:ie.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=(pe=n.agent)==null?void 0:pe.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:((ye=n.agent)==null?void 0:ye.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(Nps,{listing:n}),!R&&n.open_to_referrals&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{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:()=>j(!0),children:"Send Referral"})]})]})]})]})]}),e.jsx(vs,{open:!!C,onOpenChange:()=>A(null),children:e.jsx(ys,{className:"max-w-4xl",children:e.jsx("img",{src:C||"",alt:"Full size",className:"w-full h-auto"})})}),e.jsx(vs,{open:v,onOpenChange:_,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Delete Listing"}),e.jsx(Kr,{children:"Are you sure you want to delete this listing? This action cannot be undone."})]}),e.jsxs(On,{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(vs,{open:b,onOpenChange:j,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:we=>L({...I,buyerName:we.target.value}),placeholder:"Enter buyer's name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Buyer Type"}),e.jsxs(tr,{value:I.buyerType,onValueChange:we=>L({...I,buyerType:we}),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select type"})}),e.jsxs(er,{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(Tr,{value:I.notes,onChange:we=>L({...I,notes:we.target.value}),placeholder:"Any additional information..."})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),e.jsx(K,{onClick:V,disabled:g.isPending,children:g.isPending?"Sending...":"Send Referral"})]})]})}),e.jsx(pJe,{open:w,onOpenChange:N,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 Tps({photo:t,onRemove:s,onSetPrimary:r}){const{attributes:n,listeners:a,setNodeRef:o,transform:l,transition:i,isDragging:d}=GKe({id:t.id}),u={transform:S3.Transform.toString(l),transition:i};return e.jsxs("div",{ref:o,style:u,className:Et("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(Ru,{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 Aps({photos:t,uploading:s,onUpload:r,onRemove:n,onReorder:a,onSetPrimary:o}){const l=NKe(aye(wle,{activationConstraint:{distance:5}})),i=[...t].sort((u,p)=>(u.sort_order??0)-(p.sort_order??0)),d=u=>{const{active:p,over:g}=u;if(!g||p.id===g.id)return;const v=i.findIndex(N=>N.id===p.id),_=i.findIndex(N=>N.id===g.id),b=[...i],[j]=b.splice(v,1);b.splice(_,0,j);const w=b.map((N,C)=>({...N,sort_order:C}));a(w)};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(qKe,{sensors:l,collisionDetection:TKe,onDragEnd:d,children:e.jsx(HKe,{items:i.map(u=>u.id),strategy:Nle,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[i.map(u=>e.jsx(Tps,{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(As,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Xa,{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 Eps({selectedVideoId:t,onVideoSelect:s,listingId:r}){const n=Lr(),{user:a}=Gs(),[o,l]=S.useState(!1),[i,d]=S.useState([]),[u,p]=S.useState(!1),[g,v]=S.useState(null),[_,b]=S.useState({});S.useEffect(()=>{t&&a?j():v(null)},[t,a]);const j=async()=>{if(!t)return;const{data:U,error:V}=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();!V&&U&&(v(U),w(U))},w=async U=>{try{const{data:V,error:X}=await G.functions.invoke("bunny-upload",{body:{action:"asset-urls",videoId:U.bunny_video_id,isAgentVideo:!0}});!X&&(V!=null&&V.thumbnailUrl)&&b(se=>({...se,[U.id]:{thumbnailUrl:V.thumbnailUrl}}))}catch(V){console.warn("Failed to get signed URL",V)}},N=async()=>{if(a){p(!0);try{const{data:U,error:V}=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(V)throw V;d(U||[]),U!=null&&U.length&&C(U)}catch(U){console.error("Error fetching videos:",U),fe.error("Failed to load videos")}finally{p(!1)}}},C=async U=>{var V;try{const X=U.map(ie=>ie.bunny_video_id),{data:se,error:te}=await G.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:X,isAgentVideo:!0}});if(te)throw te;const Y=(se==null?void 0:se.assets)||{},de={};for(const ie of U)(V=Y[ie.bunny_video_id])!=null&&V.thumbnailUrl&&(de[ie.id]={thumbnailUrl:Y[ie.bunny_video_id].thumbnailUrl});b(ie=>({...ie,...de}))}catch(X){console.warn("Failed to bulk-fetch signed URLs",X)}},A=()=>{l(!0),N()},I=U=>{s(U.id),v(U),l(!1),fe.success("Video selected")},L=()=>{s(null),v(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 V=Math.floor(U/60),X=U%60;return`${V}:${X.toString().padStart(2,"0")}`},q=U=>{var V;return((V=_[U.id])==null?void 0:V.thumbnailUrl)||U.thumbnail_url};return e.jsxs("div",{className:"space-y-3",children:[g?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(g)?e.jsx("img",{src:q(g),alt:g.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(dl,{className:"h-6 w-6 text-white fill-white"})}),g.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:$(g.duration_seconds)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:g.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:A,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:A,className:"gap-2",children:[e.jsx(h5,{className:"h-4 w-4"}),"Select from Library"]}),e.jsxs(K,{type:"button",variant:"outline",onClick:R,className:"gap-2",children:[e.jsx(Og,{className:"h-4 w-4"}),"Record New Video"]})]})]})})}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(Cs,{children:e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(h5,{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(As,{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(Og,{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(dl,{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(Og,{className:"h-4 w-4"}),"Record New Video"]}),e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})})]})}const Pps=[{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"}],Ips=[{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 wLe(){const{listingId:t}=Co(),[s]=Ac(),r=s.get("brokerage"),n=Lr(),{user:a}=Gs(),o=!!t&&t!=="new",l=!!r&&!o,{data:i,isLoading:d}=lVe(o?t:""),u=v5t(),p=_5t(),g=b5t(),v=w5t(),_=j5t(),b=k5t(),j=N5t(),{data:w=[]}=Ct({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}),[N,C]=S.useState(""),[A,I]=S.useState(!1),[L,R]=S.useState([]),[$,q]=S.useState([]),[U,V]=S.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});S.useEffect(()=>{var ae,le,pe,be,ye;i&&o&&V({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:((pe=i.bathrooms)==null?void 0:pe.toString())||"",square_footage:((be=i.square_footage)==null?void 0:be.toString())||"",lot_size:i.lot_size||"",year_built:((ye=i.year_built)==null?void 0:ye.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 X=ae=>{if(!ae)return;const le=Array.from(ae);R(be=>[...be,...le]);const pe=le.map(be=>URL.createObjectURL(be));q(be=>[...be,...pe])},se=ae=>{URL.revokeObjectURL($[ae]),R(le=>le.filter((pe,be)=>be!==ae)),q(le=>le.filter((pe,be)=>be!==ae))},te=async ae=>{var le;if(!(!ae||!i)){I(!0);try{for(const pe of Array.from(ae)){const be=pe.name.split(".").pop(),ye=`${a==null?void 0:a.id}/${i.id}/${Date.now()}.${be}`,{error:we}=await G.storage.from("listing-photos").upload(ye,pe);if(we)throw we;const{data:{publicUrl:Ne}}=G.storage.from("listing-photos").getPublicUrl(ye);await v.mutateAsync({listingId:i.id,photoUrl:Ne,isPrimary:!((le=i.photos)!=null&&le.length)})}fe.success("Photos uploaded!")}catch(pe){console.error("Upload error:",pe),fe.error("Failed to upload photos")}finally{I(!1)}}},Y=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")}},ie=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&&!N){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 g.mutateAsync({id:t,...le}),fe.success("Listing updated!"),n(`/mission-control/listings/${t}`);else{I(!0);let pe;if(l&&N?pe=await p.mutateAsync({agentId:N,...le}):pe=await u.mutateAsync(le),L.length>0)try{await Y(pe.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/${pe.id}`)}}catch(le){console.error("Save error:",le),fe.error("Failed to save listing"),I(!1)}};return o&&d?e.jsx(Ms,{title:"Loading...",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{className:"h-10 w-32"}),e.jsx(gs,{className:"h-[600px] w-full"})]})}):e.jsx(Ms,{title:o?"Edit Listing":l?"Add Listing for Agent":"Add Listing",description:"",children:e.jsxs("form",{onSubmit:ie,className:"space-y-6",children:[e.jsxs(K,{type:"button",variant:"ghost",onClick:()=>n(l?"/my-brokerage":"/mission-control/listings"),children:[e.jsx(Ka,{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(Lt,{children:e.jsx(zt,{children:"Assign to Agent *"})}),e.jsxs(Oe,{children:[e.jsxs(tr,{value:N,onValueChange:C,children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select an agent..."})}),e.jsx(er,{children:w.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(Lt,{children:e.jsx(zt,{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=>V({...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=>V({...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=>V({...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=>V({...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=>V({...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(tr,{value:U.property_type,onValueChange:ae=>V({...U,property_type:ae}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:Ips.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(tr,{value:U.status,onValueChange:ae=>V({...U,status:ae}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:Pps.map(ae=>e.jsx(At,{value:ae.value,children:ae.label},ae.value))})]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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=>V({...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=>V({...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=>V({...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=>V({...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=>V({...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=>V({...U,has_hoa:ae})}),e.jsx(ve,{children:"Has HOA"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(Tr,{value:U.description,onChange:ae=>V({...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(Tr,{value:U.agent_notes,onChange:ae=>V({...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=>V({...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=>V({...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=>V({...U,video_link:ae.target.value}),placeholder:"YouTube or Vimeo URL"})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Nn,{className:"h-5 w-5"}),"Property Video"]})}),e.jsx(Oe,{children:e.jsx(Eps,{selectedVideoId:U.video_id,onVideoSelect:ae=>V({...U,video_id:ae}),listingId:o?t:void 0})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Photos"})}),e.jsx(Oe,{children:o&&(i!=null&&i.photos)?e.jsx(Aps,{photos:i.photos,uploading:A,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&&j.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:[A?e.jsx(As,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Xa,{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=>X(ae.target.files),disabled:A})]})]}),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(Lt,{children:e.jsx(zt,{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=>V({...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=>V({...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=>V({...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=>V({...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=>V({...U,is_public:ae})})]})]})]}),e.jsx(K,{type:"submit",className:"w-full",size:"lg",disabled:u.isPending||g.isPending,children:u.isPending||g.isPending?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):o?"Update Listing":"Create Listing"})]})]})]})})}function Mce({maxDurationSeconds:t=30,onRecordingComplete:s,onError:r,onRecordingStateChange:n,className:a,teleprompterContent:o}){const l=S.useRef(null),i=S.useRef(null),d=S.useRef(null),u=S.useRef([]),p=S.useRef(null),g=S.useRef(null),v=S.useRef(null),_=S.useRef(null),b=AM(),[j,w]=S.useState(!0),[N,C]=S.useState(!0),[A,I]=S.useState(null),[L,R]=S.useState(!1),[$,q]=S.useState(!1),[U,V]=S.useState(null),[X,se]=S.useState(null),[te,Y]=S.useState(0),[de,ie]=S.useState("user"),[ae,le]=S.useState(0),[pe,be]=S.useState(!1),[ye,we]=S.useState(!0),[Ne,Ke]=S.useState(null),[_e,Me]=S.useState(!1),[Te,Fe]=S.useState(null),Ae=S.useRef(null),Ue=S.useRef(r);Ue.current=r;const ut=S.useCallback(He=>{w(He)},[]),De=S.useRef(j),Dt=S.useCallback(async()=>{var et,Rt;C(!0),Ke(null);const He=b&&j;console.log("[VideoRecorder] initCamera start",{isMobile:b,usePortraitMode:j,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(fs=>fs.stop()));const qt=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",qt);const ls=await navigator.mediaDevices.getUserMedia({video:qt,audio:{echoCancellation:!0,noiseSuppression:!0}});if(console.log("[VideoRecorder] getUserMedia success"),ls.getVideoTracks().length===0)throw new Error("Camera stream started but no video track was provided.");d.current=ls,I(!0);const Qt=ls.getVideoTracks()[0].getSettings();if(console.log("[VideoRecorder] Camera initialized with dimensions:",Qt.width,"x",Qt.height),l.current){const fs=l.current;fs.srcObject=ls,fs.muted=!0,fs.playsInline=!0,fs.autoplay=!0,fs.setAttribute("muted",""),fs.setAttribute("playsinline",""),fs.setAttribute("autoplay","");try{(et=fs.load)==null||et.call(fs)}catch(bt){console.warn("[VideoRecorder] videoEl.load failed",bt)}const dr=async()=>{try{return await fs.play(),console.log("[VideoRecorder] preview play ok"),Me(!1),setTimeout(()=>{console.debug("[VideoRecorder] preview metrics",{readyState:fs.readyState,videoWidth:fs.videoWidth,videoHeight:fs.videoHeight})},300),!0}catch(bt){return console.warn("[VideoRecorder] preview play blocked",bt),Me(!0),!1}};await new Promise(bt=>{let ks=!1;const ir=()=>{ks||(ks=!0,bt())},Rr=()=>{dr().finally(ir)};fs.onloadedmetadata=Rr,fs.onloadeddata=Rr,setTimeout(ir,1500)})}try{g.current=new AudioContext;const fs=g.current.createMediaStreamSource(ls);v.current=g.current.createAnalyser(),v.current.fftSize=256,fs.connect(v.current);const dr=()=>{if(v.current){const bt=new Uint8Array(v.current.frequencyBinCount);v.current.getByteFrequencyData(bt);const ks=bt.reduce((ir,Rr)=>ir+Rr)/bt.length;le(Math.min(100,ks/128*100))}_.current=requestAnimationFrame(dr)};dr()}catch(fs){console.warn("Audio context not available:",fs)}}catch(qt){console.error("Camera initialization error:",qt),I(!1);let ls="Failed to access camera or microphone.";qt.name==="NotAllowedError"?ls="Camera permission denied. Please allow camera access in your browser settings.":qt.name==="NotFoundError"?ls="No camera found. Please connect a camera and try again.":qt.name==="NotReadableError"?ls="Camera is in use by another application. Please close other apps using the camera.":qt.message&&(ls=qt.message),Ke(ls),(Rt=Ue.current)==null||Rt.call(Ue,ls)}finally{C(!1)}},[de,b,j]);S.useEffect(()=>{De.current!==j&&A&&!L&&!X&&(De.current=j,Dt())},[j,A,L,X,Dt]),S.useEffect(()=>(Dt(),()=>{d.current&&d.current.getTracks().forEach(He=>He.stop()),p.current&&clearInterval(p.current),_.current&&cancelAnimationFrame(_.current),g.current&&g.current.close(),Ae.current&&clearInterval(Ae.current),X&&URL.revokeObjectURL(X)}),[Dt,X]),S.useEffect(()=>{if(N||A!==!0||X)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(Rt=>{Me(!0),console.warn("Live preview play blocked on mount:",Rt)}))},[A,N,X]),S.useEffect(()=>{n==null||n(L)},[L,n]);const he=S.useCallback(async()=>{if(X)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)}},[X]),Ve=S.useCallback(()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),p.current&&(clearInterval(p.current),p.current=null),R(!1),q(!1)},[]),nt=S.useCallback(()=>{if(!d.current)return;he(),u.current=[],Y(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(qt=>MediaRecorder.isTypeSupported(qt)),Rt=new MediaRecorder(d.current,et?{mimeType:et,videoBitsPerSecond:25e5}:{videoBitsPerSecond:25e5});Rt.ondataavailable=qt=>{qt.data.size>0&&u.current.push(qt.data)},Rt.onstop=()=>{var Qt;const qt=Rt.mimeType||et||((Qt=u.current[0])==null?void 0:Qt.type)||"video/webm",ls=new Blob(u.current,{type:qt});V(ls);const Kt=URL.createObjectURL(ls);se(Kt)},i.current=Rt,Rt.start(100),R(!0),p.current=setInterval(()=>{Y(qt=>qt>=t-1?(Ve(),t):qt+1)},1e3)},[he,t,Ve]),Qe=S.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),nt()):Fe(He)},1e3)},[nt]),ke=S.useCallback(()=>{i.current&&i.current.state==="recording"&&(i.current.pause(),q(!0),p.current&&clearInterval(p.current))},[]),ot=S.useCallback(()=>{i.current&&i.current.state==="paused"&&(i.current.resume(),q(!1),p.current=setInterval(()=>{Y(He=>He>=t-1?(Ve(),t):He+1)},1e3))},[t,Ve]),qe=S.useCallback(()=>{X&&URL.revokeObjectURL(X),V(null),se(null),Y(0),be(!1),we(!0),l.current&&d.current&&(l.current.srcObject=d.current,l.current.muted=!0,he())},[he,X]),lt=S.useCallback(()=>{ie(He=>He==="user"?"environment":"user")},[]),We=S.useCallback(()=>{U&&s(U,te)},[U,te,s]),Ye=S.useCallback(()=>{l.current&&X&&(pe?l.current.pause():(we(!1),l.current.muted=!1,l.current.play()),be(!pe))},[X,pe]);S.useEffect(()=>{if(!X)return;const He=l.current;if(!He)return;we(!1),He.pause(),He.removeAttribute("src"),He.srcObject=null,He.load(),He.src=X,He.currentTime=0,He.playsInline=!0,He.muted=!1,He.onended=()=>be(!1);const et=()=>{var ls;const Rt=He.error,qt=Rt?`Recorded video failed to play (code ${Rt.code}). Likely unsupported format/codec in this browser.`:"Recorded video failed to play.";console.warn("[VideoRecorder] recorded playback error",Rt),(ls=Ue.current)==null||ls.call(Ue,qt)};return He.addEventListener("error",et),He.load(),()=>{He.removeEventListener("error",et)}},[X]);const mt=He=>{const et=Math.floor(He/60),Rt=He%60;return`${et}:${Rt.toString().padStart(2,"0")}`},Ze=b&&j?"aspect-[9/16]":"aspect-video";return N?e.jsx("div",{className:Et("flex items-center justify-center bg-black rounded-lg",Ze,a),children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(As,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),e.jsx("p",{children:"Initializing camera..."})]})}):A===!1?e.jsx("div",{className:Et("flex items-center justify-center bg-black rounded-lg",Ze,a),children:e.jsxs("div",{className:"text-center text-white p-8 max-w-md",children:[e.jsx(Qo,{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:()=>Dt(),variant:"secondary",className:"w-full",children:[e.jsx(Eo,{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:Et("flex flex-col gap-2",a),children:[b&&!L&&!X&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 bg-muted/50 rounded-lg",children:[e.jsx(nN,{className:Et("h-4 w-4",j?"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:j,onCheckedChange:ut}),e.jsx(ve,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Portrait"}),e.jsx(L0,{className:Et("h-4 w-4",j?"text-primary":"text-muted-foreground")})]}),e.jsxs("div",{className:Et("relative bg-black rounded-lg overflow-hidden"),onPointerDown:()=>{he()},children:[e.jsx("video",{ref:l,src:X??void 0,className:Et("w-full bg-black",j&&!X?"object-contain":"object-cover",Ze,de==="user"&&!X&&"scale-x-[-1]"),playsInline:!0,controls:!!X,muted:X?ye:!0,autoPlay:!X},X??"live"),!X&&_e&&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 he(),className:"bg-white/20 hover:bg-white/30 text-white",children:"Tap to enable preview"})}),o&&!X&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:o}),Te!==null&&!X&&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:Et("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:[mt(te)," / ",mt(t)]})]}),L&&e.jsx("div",{className:"absolute top-0 left-0 right-0",children:e.jsx(Mi,{value:te/t*100,className:"h-1 rounded-none"})}),!X&&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(fP,{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:X?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"secondary",size:"lg",className:"bg-white/20 hover:bg-white/30 text-white",onClick:qe,children:[e.jsx(Eo,{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:Ye,children:pe?e.jsx(fp,{className:"h-5 w-5"}):e.jsx(dl,{className:"h-5 w-5"})}),e.jsxs(K,{size:"lg",className:"bg-green-500 hover:bg-green-600 text-white",onClick:We,children:[e.jsx(fa,{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:lt,disabled:L||Te!==null,children:e.jsx(I0,{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:Qe,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:$?ot:ke,children:$?e.jsx(dl,{className:"h-5 w-5"}):e.jsx(fp,{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:Ve,children:e.jsx(Gx,{className:"h-6 w-6 fill-current"})})]}),e.jsx("div",{className:"h-12 w-12"})]})})]})]})}const yJe="teleprompter_settings",Npe={scrollSpeed:30,fontSize:24,lineHeight:1.6,opacity:.85,position:"top",isMirrored:!1};function Lps(){try{const t=localStorage.getItem(yJe);return t?{...Npe,...JSON.parse(t)}:Npe}catch{return Npe}}function Dps(t){try{localStorage.setItem(yJe,JSON.stringify(t))}catch{}}function vJe({text:t,isVisible:s,onToggleVisibility:r,isRecording:n=!1,startCountdown:a=!1,onCountdownComplete:o,className:l}){const i=S.useRef(null),d=S.useRef(null),u=S.useRef(0),p=S.useRef(0),[g,v]=S.useState(Lps),{scrollSpeed:_,fontSize:b,lineHeight:j,opacity:w,position:N,isMirrored:C}=g,A=S.useCallback((se,te)=>{v(Y=>{const de={...Y,[se]:te};return Dps(de),de})},[]),[I,L]=S.useState(!1),[R,$]=S.useState(null),q=S.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 Y=Math.floor(p.current);Y>0&&(i.current.scrollTop+=Y,p.current-=Y);const{scrollTop:de,scrollHeight:ie,clientHeight:ae}=i.current;if(de+ae>=ie){L(!1);return}d.current=requestAnimationFrame(q)},[_]);S.useEffect(()=>(I?(u.current=0,p.current=0,d.current=requestAnimationFrame(q)):d.current&&cancelAnimationFrame(d.current),()=>{d.current&&cancelAnimationFrame(d.current)}),[I,q]),S.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=S.useCallback(()=>{i.current&&(i.current.scrollTop=0),L(!1)},[]),V=S.useCallback(()=>{L(se=>!se)},[]);if(!s)return e.jsx("div",{className:Et("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(ya,{className:"h-4 w-4 mr-2"}),"Show Script"]})});const X={top:"top-0 pt-16",center:"top-1/2 -translate-y-1/2",bottom:"bottom-0 pb-24"};return e.jsxs("div",{className:Et("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:Et("absolute left-0 right-0 h-[60%] overflow-hidden pointer-events-auto",X[N],R!==null&&"opacity-30"),style:{opacity:R!==null?.3:w},children:e.jsxs("div",{ref:i,className:Et("mx-auto max-w-2xl px-6 overflow-y-auto scrollbar-hide h-full",C&&"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:j,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(No,{children:[e.jsx(So,{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(Fl,{className:"h-4 w-4"})})}),e.jsx(jo,{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(Pg,{value:[_],onValueChange:([se])=>A("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(Pg,{value:[b],onValueChange:([se])=>A("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:j.toFixed(1)})]}),e.jsx(Pg,{value:[j*10],onValueChange:([se])=>A("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(w*100),"%"]})]}),e.jsx(Pg,{value:[w*100],onValueChange:([se])=>A("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:N==="top"?"default":"outline",size:"sm",onClick:()=>A("position","top"),children:e.jsx(Rg,{className:"h-4 w-4"})}),e.jsx(K,{variant:N==="center"?"default":"outline",size:"sm",onClick:()=>A("position","center"),children:e.jsx(A0,{className:"h-4 w-4"})}),e.jsx(K,{variant:N==="bottom"?"default":"outline",size:"sm",onClick:()=>A("position","bottom"),children:e.jsx(Vo,{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:C,onCheckedChange:se=>A("isMirrored",se)})]})]})})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:V,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:I?e.jsx(fp,{className:"h-4 w-4"}):e.jsx(dl,{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(I0,{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(Tm,{className:"h-4 w-4 mr-2"}),"Hide"]})]})]})}function Ops({onSelectScript:t,onCreateNew:s,selectedScriptId:r,className:n}){const{toast:a}=Ea(),[o,l]=S.useState(""),[i,d]=S.useState(null),[u,p]=S.useState("levelup"),{data:g,isLoading:v}=X7t(),{data:_,isLoading:b}=Q7t(),{data:j,isLoading:w}=J7t(),N=eBt(),C=S.useMemo(()=>_?_.filter($=>{const q=!o||$.title.toLowerCase().includes(o.toLowerCase())||$.script_text.toLowerCase().includes(o.toLowerCase())||$.tags.some(V=>V.toLowerCase().includes(o.toLowerCase())),U=!i||$.category_id===i;return q&&U}):[],[_,o,i]),A=S.useMemo(()=>j?j.filter($=>!o||$.title.toLowerCase().includes(o.toLowerCase())||$.script_text.toLowerCase().includes(o.toLowerCase())):[],[j,o]),I=$=>{t({title:$.title,text:$.script_text})},L=async $=>{try{await N.mutateAsync($),a({title:"Script saved to My Scripts"})}catch{a({title:"Failed to save script",variant:"destructive"})}},R=v||b||w;return e.jsxs("div",{className:Et("flex flex-col h-full",n),children:[e.jsx("div",{className:"p-4 border-b",children:e.jsxs("div",{className:"relative",children:[e.jsx(xn,{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(ja,{value:u,onValueChange:$=>p($),className:"flex-1 flex flex-col",children:[e.jsxs(va,{className:"mx-4 mt-4 grid grid-cols-2",children:[e.jsxs(Ns,{value:"levelup",children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"LevelUp Scripts"]}),e.jsxs(Ns,{value:"my-scripts",children:[e.jsx(Dg,{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(at,{variant:i?"outline":"default",className:"cursor-pointer",onClick:()=>d(null),children:"All"}),g==null?void 0:g.map($=>e.jsx(at,{variant:i===$.id?"default":"outline",className:"cursor-pointer",onClick:()=>d($.id),children:$.name},$.id))]}),e.jsx(Fi,{className:"flex-1 max-h-[50vh]",children:R?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):C.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Sn,{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:C.map($=>e.jsxs(Ee,{className:Et("cursor-pointer hover:bg-accent/50 transition-colors",r===$.id&&"ring-2 ring-primary"),onClick:()=>I($),children:[e.jsx(Lt,{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(zt,{className:"text-sm font-medium truncate",children:$.title}),$.category&&e.jsx(at,{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(Dg,{className:"h-4 w-4"})}),e.jsx(qa,{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(Fi,{className:"flex-1 max-h-[50vh]",children:w?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):A.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Dg,{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:A.map($=>e.jsxs(Ee,{className:Et("cursor-pointer hover:bg-accent/50 transition-colors",r===$.id&&"ring-2 ring-primary"),onClick:()=>I($),children:[e.jsx(Lt,{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(zt,{className:"text-sm font-medium truncate",children:$.title}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:$.is_custom?e.jsx(at,{variant:"outline",className:"text-xs",children:"Custom"}):e.jsx(at,{variant:"secondary",className:"text-xs",children:"Saved"})})]}),e.jsx(qa,{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 Rps({selectedTemplate:t,onSelect:s,contactName:r,saving:n=!1}){const[a,o]=S.useState(()=>{const i=A5(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(As,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),e.jsx("div",{className:"space-y-3",children:kjt.map(i=>{const d=Njt(i.id),u=a.has(i.id),p=d.some(g=>g.id===t);return e.jsxs(mf,{open:u,onOpenChange:()=>l(i.id),children:[e.jsxs(pf,{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(Vo,{className:Et("h-4 w-4 text-muted-foreground transition-transform",u&&"rotate-180")})]}),e.jsx(ff,{className:"pt-2",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:d.map(g=>{const v=t===g.id;return e.jsxs("button",{type:"button",onClick:()=>s(g.id),disabled:n,className:Et("relative rounded-lg border-2 p-2.5 text-left transition-all hover:shadow-sm disabled:opacity-50 disabled:cursor-not-allowed",v?"border-primary ring-1 ring-primary/20 bg-primary/5":"border-muted hover:border-muted-foreground/30"),children:[v&&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(fa,{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:g.icon}),e.jsx("span",{className:"text-sm font-medium truncate",children:g.name})]})]},g.id)})})})]},i.id)})}),r&&t!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Will show: "',A5(t).headerText(r),'"']})]})}function _Je({open:t,onOpenChange:s,video:r,contactName:n,onTemplateUpdated:a}){const[o,l]=S.useState(r.page_template||"default"),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[g,v]=S.useState(r.page_template||"default"),[_,b]=S.useState([]),[j,w]=S.useState(r.contact_id&&n?{id:r.contact_id,name:n,email:null}:null),[N,C]=S.useState(!1),[A,I]=S.useState(!1),L=r.share_token?`https://video.relevelup.com/${r.share_token}`:"";S.useEffect(()=>{t&&_.length===0&&R()},[t]);const R=async()=>{I(!0);try{const{data:de,error:ie}=await G.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(ie)throw ie;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=>{w(de),C(!1),d(!0);try{const{error:ie}=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(ie)throw ie;fe.success(de?`Assigned to ${de.name}`:"Contact removed"),a==null||a()}catch(ie){console.error("Failed to update contact:",ie),fe.error("Failed to update contact")}finally{d(!1)}},q=async de=>{l(de),d(!0);try{const{error:ie}=await G.from("agent_videos").update({page_template:de}).eq("id",r.id);if(ie)throw ie;v(de),fe.success("Template saved!"),a==null||a()}catch(ie){console.error("Failed to save template:",ie),fe.error("Failed to save template"),l(g)}finally{d(!1)}},U=(j==null?void 0:j.name)||null,V=()=>{const de=r.title||"Video Message",ie=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:r.thumbnail_url||"";return``},X=async()=>{if(!r.thumbnail_url){fe.error("Video thumbnail not available yet");return}const de=V(),ie=`Watch: ${r.title||"Video Message"} ${L}`;try{const ae=new Blob([de],{type:"text/html"}),le=new Blob([ie],{type:"text/plain"}),pe=new ClipboardItem({"text/html":ae,"text/plain":le});await navigator.clipboard.write([pe]),fe.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(ie+` `+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 ie=A5(o).headerText(U),ae=o==="default"?`Check out this video: ${L}`:`${ie} Check out this special video: ${L}`;window.open(`sms:?body=${encodeURIComponent(ae)}`,"_self")},Y=()=>{const de=A5(o),ie=de.headerText(U),ae=o==="default"?r.title||"Video Message":ie,le=`${de.subText} Watch the video: ${L}`,pe=j!=null&&j.email?encodeURIComponent(j.email):"";window.open(`mailto:${pe}?subject=${encodeURIComponent(ae)}&body=${encodeURIComponent(le)}`,"_self")};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Io,{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(No,{open:N,onOpenChange:C,children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":N,className:"flex-1 justify-between",disabled:i,children:[j?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Yi,{className:"h-4 w-4 text-muted-foreground"}),j.name]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(df,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-[300px] p-0",align:"start",children:e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search contacts..."}),e.jsxs(kf,{children:[e.jsx(Nf,{children:A?"Loading...":"No contacts found."}),e.jsx(Sf,{children:_.map(de=>e.jsxs(jm,{value:de.name,onSelect:()=>$(de),children:[e.jsx(fa,{className:Et("mr-2 h-4 w-4",(j==null?void 0:j.id)===de.id?"opacity-100":"opacity-0")}),de.name]},de.id))})]})]})})]}),j&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>$(null),disabled:i,className:"shrink-0",children:e.jsx(Ur,{className:"h-4 w-4"})})]}),j&&o!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Page will show: "',A5(o).headerText(j.name),'"']})]}),e.jsx(Rps,{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(fa,{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:X,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:Y,children:[e.jsx(br,{className:"h-4 w-4"}),"Email"]})]})]})]}),e.jsx(On,{children:e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})}function Fps(){var Qe;const t=Lr(),[s]=Ac(),{toast:r}=Ea(),n=s.get("contact_id"),a=s.get("task_id"),{canRecord:o,remainingMb:l,usagePercent:i,isNearLimit:d}=vZe(),{data:u}=Xh(),p=nS(),g=aBt(),[v,_]=S.useState("record"),[b,j]=S.useState(""),[w,N]=S.useState(!1),[C,A]=S.useState(!1),[I,L]=S.useState(!1),[R,$]=S.useState(null),[q,U]=S.useState(0),[V,X]=S.useState(0),[se,te]=S.useState(null),[Y,de]=S.useState(null),[ie,ae]=S.useState(n||""),[le,pe]=S.useState(""),[be,ye]=S.useState(""),[we,Ne]=S.useState(null),[Ke,_e]=S.useState(null),[Me,Te]=S.useState(null),[Fe,Ae]=S.useState(!1),Ue=S.useCallback(async(ke,ot)=>{$(ke),_("uploading");try{const{videoId:qe,uploadUrl:lt}=await GL(le||"Quick Video Touch");te(qe);const{apiKey:We}=await KL(qe),Ye=new XMLHttpRequest;Ye.upload.onprogress=et=>{et.lengthComputable&&U(et.loaded/et.total*100)},await new Promise((et,Rt)=>{Ye.onload=()=>{Ye.status>=200&&Ye.status<300?et():Rt(new Error(`Upload failed: ${Ye.status}`))},Ye.onerror=()=>Rt(new Error("Upload failed")),Ye.open("PUT",lt),Ye.setRequestHeader("AccessKey",We),Ye.send(ke)}),_("processing");let mt=0;const Ze=Date.now(),He=90*1e3;for(;mt<4;){if(await new Promise(Rt=>setTimeout(Rt,3e3)),Date.now()-Ze>He){const Rt=ke.size/1048576,qt=`https://iframe.mediadelivery.net/play/${qe}/${qe}`;await p.mutateAsync({bunny_video_id:qe,playback_url:qt,file_size_mb:Rt,title:le||"Quick Video Touch",notes:be||void 0,contact_id:ie&&ie!=="none"?ie: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 C3(qe);if(mt=et.status,X(et.encodeProgress||0),mt===4)de({playbackUrl:et.directPlayUrl,thumbnailUrl:et.thumbnailUrl,previewUrl:et.previewUrl||null,duration:et.length||ot,fileSizeMb:(et.storageSize||ke.size)/(1024*1024)});else if(mt===5||mt===6)throw new Error("Video processing failed")}_("details")}catch(qe){console.error("Upload error:",qe),r({title:"Upload failed",description:"Please try recording again.",variant:"destructive"}),_("record")}},[le,r]),ut=async()=>{if(!(!se||!Y))try{const ke=ie&&ie!=="none"?ie:null,ot=await p.mutateAsync({bunny_video_id:se,contact_id:ke,playback_url:Y.playbackUrl,thumbnail_url:Y.thumbnailUrl,preview_url:Y.previewUrl,duration_seconds:Y.duration,file_size_mb:Y.fileSizeMb,title:le||"Quick Video Touch",notes:be,task_id:a||null,status:"ready"});Ne(ot.id),_e(ot.share_token||null),ke&&await g.mutateAsync({contactId:ke,videoId:ot.id,notes:be}),r({title:"Video saved successfully!"}),_("share")}catch(ke){console.error("Save video error:",ke),r({title:"Failed to save video",description:(ke==null?void 0:ke.message)||"Please try again.",variant:"destructive"})}},De=(ke,ot)=>{navigator.clipboard.writeText(ot),Te(ke),setTimeout(()=>Te(null),2e3),r({title:"Copied to clipboard!"})},Dt=()=>Ke?`https://video.relevelup.com/${Ke}`:(Y==null?void 0:Y.playbackUrl)||"",he=()=>{const ke=u==null?void 0:u.find(Ye=>Ye.id===ie),ot=ke?`${ke.first_name}`:"",qe=(ke==null?void 0:ke.phone)||"",lt=(ke==null?void 0:ke.email)||"",We=Dt();return{text:`Hey${ot?` ${ot}`:""}! I recorded a quick video for you: ${We}`,link:We,contactPhone:qe,contactEmail:lt}},Ve=()=>{const{text:ke,contactPhone:ot}=he(),qe=ot?`sms:${ot}?body=${encodeURIComponent(ke)}`:`sms:?body=${encodeURIComponent(ke)}`;window.open(qe,"_self")},nt=()=>{const{link:ke,contactEmail:ot}=he(),qe="Check out this video",lt=`I recorded a quick video for you: ${ke}`,We=ot?`mailto:${ot}?subject=${encodeURIComponent(qe)}&body=${encodeURIComponent(lt)}`:`mailto:?subject=${encodeURIComponent(qe)}&body=${encodeURIComponent(lt)}`;window.open(We,"_self")};return o?e.jsx(Ms,{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(Ka,{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"]})]})]}),v==="record"&&e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsx(Mce,{maxDurationSeconds:60,onRecordingComplete:Ue,onRecordingStateChange:L,className:"w-full",teleprompterContent:w&&b&&e.jsx(vJe,{text:b,isVisible:w,onToggleVisibility:()=>N(!1),isRecording:I,startCountdown:!0})}),!w&&b&&e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>N(!0),children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Show Teleprompter"]})]}),e.jsxs(Ee,{className:"lg:col-span-1",children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(zt,{className:"text-lg",children:"Teleprompter Script"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Tr,{placeholder:"Type or paste your script here...",value:b,onChange:ke=>j(ke.target.value),rows:6}),e.jsxs(fM,{open:C,onOpenChange:A,children:[e.jsx(s_e,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full",children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Browse Scripts"]})}),e.jsxs(tS,{side:"right",className:"w-[400px] sm:w-[540px] p-0",children:[e.jsx(gM,{className:"p-4 border-b",children:e.jsx(xM,{children:"Select a Script"})}),e.jsx(Ops,{onSelectScript:ke=>{j(ke.text),A(!1),N(!0)},className:"h-[calc(100vh-80px)]"})]})]}),b&&e.jsx(K,{className:"w-full",onClick:()=>N(!0),children:"Use Script"})]})]})]}),v==="uploading"&&e.jsx(Ee,{className:"max-w-md mx-auto",children:e.jsxs(Oe,{className:"pt-6 text-center",children:[e.jsx(Xa,{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(Mi,{value:q,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[q.toFixed(0),"%"]})]})}),v==="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(As,{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(Mi,{value:V,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[V.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.`})]})}),v==="details"&&e.jsxs(Ee,{className:"max-w-lg mx-auto",children:[e.jsx(Lt,{children:e.jsx(zt,{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:ke=>pe(ke.target.value),placeholder:"Quick Video Touch"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Attach to Contact (Optional)"}),e.jsxs(tr,{value:ie,onValueChange:ae,children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"No contact - use anywhere"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Io,{className:"h-4 w-4"}),"No contact - use anywhere"]})}),u==null?void 0:u.map(ke=>e.jsx(At,{value:ke.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yi,{className:"h-4 w-4"}),ke.first_name," ",ke.last_name]})},ke.id))]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Notes"}),e.jsx(Tr,{value:be,onChange:ke=>ye(ke.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(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Video"]})]})]}),v==="share"&&e.jsxs(Ee,{className:"max-w-lg mx-auto",children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(fa,{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:Ve,children:[e.jsx(io,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:nt,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",he().link),children:[e.jsx(Io,{className:"h-4 w-4 mr-2"}),"Copy Video Link",Me==="link"&&e.jsx(fa,{className:"h-4 w-4 ml-auto text-green-500"})]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>Ae(!0),children:[e.jsx(Rl,{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"})]})]})]}),we&&Ke&&e.jsx(_Je,{open:Fe,onOpenChange:Ae,video:{id:we,share_token:Ke,title:le||null,contact_id:ie||null,thumbnail_url:(Y==null?void 0:Y.thumbnailUrl)||null},contactName:((Qe=u==null?void 0:u.find(ke=>ke.id===ie))==null?void 0:Qe.first_name)||null})]})}):e.jsx(Ms,{title:"Quick Video Touch",children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center py-12",children:[e.jsx(Mh,{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 zps({open:t,onOpenChange:s}){const{data:r}=Xh(),{data:n}=Tle(),a=nS(),o=S.useRef(null),[l,i]=S.useState(null),[d,u]=S.useState(""),[p,g]=S.useState(""),[v,_]=S.useState(""),[b,j]=S.useState(!1),[w,N]=S.useState(0),[C,A]=S.useState("idle"),I=(n==null?void 0:n.total_storage_mb)||0,R=((n==null?void 0:n.max_storage_mb)||1024)-I,$=X=>{var Y;const se=(Y=X.target.files)==null?void 0:Y[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}j(!0),N(0),A("creating");try{const{data:X,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:Y}=X;A("uploading");const{data:de,error:ie}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:te,isAgentVideo:!0}});if(ie)throw new Error(ie.message);await new Promise((pe,be)=>{const ye=new XMLHttpRequest;ye.upload.addEventListener("progress",we=>{if(we.lengthComputable){const Ne=Math.round(we.loaded/we.total*100);N(Ne)}}),ye.addEventListener("load",()=>{ye.status>=200&&ye.status<300?pe():be(new Error(`Upload failed with status ${ye.status}`))}),ye.addEventListener("error",()=>be(new Error("Upload failed"))),ye.open("PUT",de.uploadUrl),ye.setRequestHeader("AccessKey",de.apiKey),ye.send(l)}),A("processing");const ae=l.size/(1024*1024),le=`https://iframe.mediadelivery.net/embed/${Y}/${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:v||void 0,status:"processing",touch_type:"video_upload"}),fe.success("Video uploaded successfully! Processing may take a few minutes."),U()}catch(X){console.error("Upload error:",X),fe.error(X instanceof Error?X.message:"Failed to upload video")}finally{j(!1),A("idle")}},U=()=>{b||(i(null),u(""),g(""),_(""),N(0),A("idle"),s(!1))},V=()=>{switch(C){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${w}%`;case"processing":return"Saving video...";default:return""}};return e.jsx(vs,{open:t,onOpenChange:U,children:e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:X=>{X.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 X;return(X=o.current)==null?void 0:X.click()},children:[e.jsx(Xa,{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:X=>u(X.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(tr,{value:v||"__none__",onValueChange:X=>_(X==="__none__"?"":X),disabled:b,children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select a contact"})}),e.jsxs(er,{children:[e.jsx(At,{value:"__none__",children:"No contact"}),r==null?void 0:r.map(X=>e.jsxs(At,{value:X.id,children:[X.first_name," ",X.last_name||""]},X.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"notes",children:"Notes (optional)"}),e.jsx(Tr,{id:"notes",value:p,onChange:X=>g(X.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(As,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:V()})]}),e.jsx(Mi,{value:C==="uploading"?w:C==="processing"?100:10})]})]}),e.jsxs(On,{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(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Xa,{className:"h-4 w-4 mr-2"}),"Upload Video"]})})]})]})})}function Bps(t){return Ct({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 $ps(){const{user:t}=Gs();return Ct({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 qps(){const{user:t}=Gs();return Ct({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 Ups(){const{user:t}=Gs(),s=ns();return Ot({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 Vps(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=open`}function Hps(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=click`}function Wps({open:t,onOpenChange:s,video:r,gmailEmail:n,signedThumbnailUrl:a,onSendComplete:o}){const[l,i]=S.useState([]),[d,u]=S.useState(null),[p,g]=S.useState(!1),[v,_]=S.useState(!1),[b,j]=S.useState(""),[w,N]=S.useState(""),[C,A]=S.useState(""),[I,L]=S.useState(!1),R=Ups(),$=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";S.useEffect(()=>{t&&l.length===0&&V()},[t]),S.useEffect(()=>{if(t&&(N(`I recorded a video for you — ${U}`),A("Hey! I recorded a quick video just for you. Click below to watch it:"),u(null),j(""),r.contact_id)){const ie=l.find(ae=>ae.id===r.contact_id);ie&&(u(ie),j(ie.email||""))}},[t,r.contact_id,l]);const V=async()=>{_(!0);try{const{data:ie,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(ie||[])}catch{console.error("Failed to fetch contacts")}finally{_(!1)}},X=ie=>{u(ie),g(!1),j(ie.email||""),A(`Hey ${ie.first_name}! I recorded a quick video just for you. Click below to watch it:`),N(`I recorded a video for you — ${U}`)},se=()=>{u(null),j(""),A("Hey! I recorded a quick video just for you. Click below to watch it:")},te=ie=>`${ie.first_name} ${ie.last_name||""}`.trim(),Y=ie=>{const ae=C.split(/\n\n+/).map(be=>`

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

`).join(""),le=ie?Hps(ie):$,pe=ie?``:"";return`
${ae}

▶ Watch Video

${pe}
`},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 ie;try{const be=d?te(d):b.split("@")[0];ie=(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=Y(ie),{data:le,error:pe}=await G.functions.invoke("gmail-send",{body:{to:b,subject:w,body:ae,contactId:(d==null?void 0:d.id)||null}});if(pe)throw pe;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(ie){console.error("Gmail send error:",ie),fe.error("Failed to send: "+(ie instanceof Error?ie.message:"Unknown error"))}finally{L(!1)}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-[560px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{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(No,{open:p,onOpenChange:g,children:[e.jsx(So,{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(df,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-[350px] p-0",align:"start",children:e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search contacts..."}),e.jsxs(kf,{children:[e.jsx(Nf,{children:v?"Loading...":"No contacts found."}),e.jsx(Sf,{children:l.filter(ie=>ie.email).map(ie=>e.jsxs(jm,{value:`${ie.first_name} ${ie.last_name||""} ${ie.email||""}`,onSelect:()=>X(ie),children:[e.jsx(fa,{className:Et("mr-2 h-4 w-4",(d==null?void 0:d.id)===ie.id?"opacity-100":"opacity-0")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:te(ie)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ie.email})]})]},ie.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:ie=>j(ie.target.value),placeholder:"recipient@example.com",type:"email"})]}),e.jsx(sc,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"video-subject",children:"Subject"}),e.jsx(Re,{id:"video-subject",value:w,onChange:ie=>N(ie.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{htmlFor:"video-message",children:"Personal Message"}),e.jsx(Tr,{id:"video-message",value:C,onChange:ie=>A(ie.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(dl,{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(dl,{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||!w,className:"gap-2",children:[I?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(Ta,{className:"h-4 w-4"}),I?"Sending...":"Send Video Email"]})]})]})]})})}const Gps=()=>{const{user:t}=Gs();return Ct({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 Kps({recipient:t}){return t.watched_at?e.jsxs(at,{className:"bg-emerald-100 text-emerald-800 text-[10px]",children:[e.jsx(dl,{className:"h-2.5 w-2.5 mr-0.5"}),"Watched"]}):t.clicked_at?e.jsxs(at,{className:"bg-blue-100 text-blue-800 text-[10px]",children:[e.jsx(bm,{className:"h-2.5 w-2.5 mr-0.5"}),"Clicked"]}):t.opened_at?e.jsxs(at,{className:"bg-amber-100 text-amber-800 text-[10px]",children:[e.jsx(ya,{className:"h-2.5 w-2.5 mr-0.5"}),"Opened"]}):e.jsxs(at,{variant:"outline",className:"text-[10px]",children:[e.jsx(Ta,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]})}function Zps({open:t,onOpenChange:s,videoId:r,videoTitle:n}){const{data:a=[],isLoading:o}=Bps(r);return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-2xl max-h-[80vh]",children:[e.jsx(Cs,{children:e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Xo,{className:"h-5 w-5"}),"Send Analytics: ",n]})}),o?e.jsx("div",{className:"space-y-2",children:[...Array(3)].map((l,i)=>e.jsx(gs,{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(Fi,{className:"h-[400px]",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Recipient"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Sent"}),e.jsx(jt,{children:"Last Activity"})]})}),e.jsx(En,{children:a.map(l=>e.jsxs(js,{children:[e.jsx(it,{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(it,{children:e.jsx(Kps,{recipient:l})}),e.jsx(it,{className:"text-xs text-muted-foreground",children:ws(new Date(l.sent_at),"MMM d, h:mm a")}),e.jsx(it,{className:"text-xs text-muted-foreground",children:l.last_activity_at?Sd(new Date(l.last_activity_at),{addSuffix:!0}):"—"})]},l.id))})]})})]})]})})}function Yps(){const{data:t,isLoading:s}=$ps(),{data:r=[],isLoading:n}=qps(),[a,o]=S.useState(null),l=s||n,i=r.reduce((d,u)=>{const p=u.agent_videos,g=(p==null?void 0:p.id)||u.video_id;return d[g]||(d[g]={videoId:g,title:(p==null?void 0:p.title)||"Untitled",thumbnailUrl:p==null?void 0:p.thumbnail_url,recipients:[]}),d[g].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(Lt,{className:"pb-2",children:e.jsx(gs,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(gs,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Sent"}),e.jsx(Ta,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Open Rate"}),e.jsx(ya,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(bm,{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(Lt,{children:[e.jsx(zt,{className:"text-sm font-medium",children:"Send History by Video"}),e.jsx(yr,{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(g=>g.opened_at).length,p=d.recipients.filter(g=>g.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:g=>{const v=g.currentTarget;v.style.display="none",v.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(Ta,{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(ya,{className:"h-3 w-3"})," ",u]}),e.jsxs("span",{className:"text-xs text-blue-600 flex items-center gap-1",children:[e.jsx(bm,{className:"h-3 w-3"})," ",p]})]})]}),e.jsx(Sc,{className:"h-4 w-4 text-muted-foreground"})]},d.videoId)})})})]}),e.jsx(Zps,{open:!!a,onOpenChange:d=>!d&&o(null),videoId:(a==null?void 0:a.id)||null,videoTitle:(a==null?void 0:a.title)||""})]})}function Xps({previewSrc:t,thumbnailSrc:s,alt:r,isHovered:n}){const[a,o]=S.useState(!1),[l,i]=S.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 Qps({video:t,previewSrc:s,thumbnailSrc:r,onOpen:n,onDelete:a,onRename:o,onNavigateToContact:l,onGetEmbedCode:i,onCopyEmailHtml:d,onEmbedToCrm:u,onShareWithTemplate:p,onSendViaGmail:g,isGmailConnected:v,getContactName:_,getShareUrl:b,copyToClipboard:j,formatDuration:w}){const[N,C]=S.useState(!1);return e.jsxs(Ee,{className:"overflow-hidden group cursor-pointer",onClick:n,onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),children:[e.jsxs("div",{className:"relative aspect-video bg-muted overflow-hidden",children:[e.jsx(Xps,{previewSrc:s,thumbnailSrc:r,alt:t.title||"Video preview",isHovered:N}),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(dl,{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:w(t.duration_seconds)}),t.status!=="ready"&&e.jsx(at,{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(In,{className:"h-3 w-3"}),e.jsx("span",{children:ws(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(ya,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]}),v&&t.share_token&&e.jsxs(K,{variant:"outline",size:"sm",className:"mt-2 gap-1.5 text-xs h-7",onClick:A=>{A.stopPropagation(),g==null||g()},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(In,{className:"h-3 w-3"}),e.jsx("span",{children:ws(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(ya,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]})]}),e.jsxs(yu,{children:[e.jsx(vu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:A=>A.stopPropagation(),children:e.jsx(Jp,{className:"h-4 w-4"})})}),e.jsxs(Wd,{align:"end",className:"bg-popover",children:[e.jsxs(Da,{onClick:A=>{A.stopPropagation(),n()},children:[e.jsx(ya,{className:"h-4 w-4 mr-2"}),"Watch"]}),e.jsx(k_,{}),e.jsxs(Da,{onClick:A=>{A.stopPropagation(),p()},children:[e.jsx(Rl,{className:"h-4 w-4 mr-2"}),"Share with Template"]}),e.jsxs(Da,{onClick:A=>{A.stopPropagation(),j(b(t),"Share link")},children:[e.jsx(Io,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(Da,{onClick:A=>{A.stopPropagation(),i()},children:[e.jsx(Xk,{className:"h-4 w-4 mr-2"}),"Get Embed Code"]}),e.jsxs(Da,{onClick:A=>{A.stopPropagation(),d()},children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(Da,{onClick:A=>{A.stopPropagation(),u()},children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),v&&t.share_token&&e.jsxs(Da,{onClick:A=>{A.stopPropagation(),g==null||g()},children:[e.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]}),e.jsxs(Da,{onClick:A=>{A.stopPropagation(),o()},children:[e.jsx(Ua,{className:"h-4 w-4 mr-2"}),"Rename"]}),e.jsx(k_,{}),t.contact_id&&e.jsxs(Da,{onClick:A=>{A.stopPropagation(),l()},children:[e.jsx(Yi,{className:"h-4 w-4 mr-2"}),"View Contact"]}),e.jsxs(Da,{onClick:A=>{A.stopPropagation(),a()},className:"text-destructive",children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]})}function Jps(){var et,Rt;const t=Lr(),{data:s,isLoading:r,refetch:n}=tBt(),{data:a}=Tle(),{data:o}=Xh(),l=nBt(),i=rBt(),{isGmailConnected:d,gmailEmail:u}=py(),{data:p}=Mf(),{data:g=[],isLoading:v}=Gps(),[_,b]=S.useState("my"),[j,w]=S.useState(""),[N,C]=S.useState(null),[A,I]=S.useState(!1),[L,R]=S.useState(!1),[$,q]=S.useState(!1),[U,V]=S.useState(!1),[X,se]=S.useState(!1),[te,Y]=S.useState(""),[de,ie]=S.useState(!1),[ae,le]=S.useState(!1),[pe,be]=S.useState(!1),[ye,we]=S.useState(!1),[Ne,Ke]=S.useState(""),[_e,Me]=S.useState({}),Te=qt=>{if(!qt)return"Unassigned";const ls=o==null?void 0:o.find(Kt=>Kt.id===qt);return ls?`${ls.first_name} ${ls.last_name||""}`.trim():"Unknown"},Fe=qt=>{if(!qt)return"0:00";const ls=Math.floor(qt/60),Kt=qt%60;return`${ls}:${Kt.toString().padStart(2,"0")}`},Ae=s==null?void 0:s.filter(qt=>{if(!j)return!0;const ls=Te(qt.contact_id).toLowerCase(),Kt=(qt.title||"").toLowerCase(),Qt=(qt.notes||"").toLowerCase();return ls.includes(j.toLowerCase())||Kt.includes(j.toLowerCase())||Qt.includes(j.toLowerCase())}),[Ue,ut]=S.useState(!1);S.useEffect(()=>{if(Ue)return;(async()=>{if(!(s!=null&&s.length))return;const ls=s.filter(Qt=>Qt.status==="processing"&&Qt.bunny_video_id);if(!ls.length)return;let Kt=!1;for(const Qt of ls)try{const{data:fs,error:dr}=await G.functions.invoke("bunny-upload",{body:{action:"status",videoId:Qt.bunny_video_id,isAgentVideo:!0}});if(dr||!fs)continue;fs.status===4&&(await G.from("agent_videos").update({status:"ready",playback_url:fs.directPlayUrl,thumbnail_url:fs.thumbnailUrl,preview_url:fs.previewUrl,duration_seconds:fs.length||Qt.duration_seconds,updated_at:new Date().toISOString()}).eq("id",Qt.id),Kt=!0)}catch(fs){console.warn("Reconcile check failed for video",Qt.id,fs)}ut(!0),Kt&&n()})()},[s,Ue,n]),S.useEffect(()=>{(async()=>{if(!(s!=null&&s.length))return;const ls=s.filter(bt=>(bt==null?void 0:bt.bunny_video_id)&&!_e[bt.id]);if(!ls.length)return;const Kt=ls.map(bt=>bt.bunny_video_id),{data:Qt,error:fs}=await G.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Kt,isAgentVideo:!0}});if(fs)throw fs;const dr=(Qt==null?void 0:Qt.assets)||{};Me(bt=>{const ks={...bt};for(const ir of ls)dr[ir.bunny_video_id]&&(ks[ir.id]={previewUrl:dr[ir.bunny_video_id].previewUrl,thumbnailUrl:dr[ir.bunny_video_id].thumbnailUrl});return ks})})().catch(ls=>console.warn("Failed to load signed Bunny asset URLs",ls))},[s,_e]);const De=(a==null?void 0:a.total_storage_mb)||0,Dt=(a==null?void 0:a.max_storage_mb)||1024,he=De/Dt*100,Ve=he>=80,nt=he>=100,Qe=async(qt,ls)=>{await navigator.clipboard.writeText(qt),fe.success(`${ls} copied to clipboard`)},ke=qt=>qt.share_token?`https://video.relevelup.com/${qt.share_token}`:qt.playback_url||"",ot=qt=>{const ls=ke(qt),Kt=o==null?void 0:o.find(ir=>ir.id===qt.contact_id),Qt=Te(qt.contact_id),fs=Qt!=="Unassigned"?Qt.split(" ")[0]:"",dr=(Kt==null?void 0:Kt.phone)||"",bt=`Hey${fs?` ${fs}`:""}! I recorded a quick video message for you. Check it out: ${ls}`,ks=dr?`sms:${dr}?body=${encodeURIComponent(bt)}`:`sms:?body=${encodeURIComponent(bt)}`;window.open(ks,"_self")},qe=qt=>{const ls=o==null?void 0:o.find(ks=>ks.id===qt.contact_id),Kt=(ls==null?void 0:ls.email)||"",Qt=ke(qt),fs="Check out this video",dr=`I recorded a quick video for you: ${Qt}`,bt=Kt?`mailto:${Kt}?subject=${encodeURIComponent(fs)}&body=${encodeURIComponent(dr)}`:`mailto:?subject=${encodeURIComponent(fs)}&body=${encodeURIComponent(dr)}`;window.open(bt,"_self")},lt=qt=>{var fs;const ls=ke(qt),Kt=qt.title||"Video Message",Qt=qt.share_token?`https://video.relevelup.com/thumb/${qt.share_token}`:((fs=_e[qt.id])==null?void 0:fs.thumbnailUrl)||qt.thumbnail_url||"";return``},We=async qt=>{if(!qt.thumbnail_url&&!qt.share_token){fe.error("Video thumbnail not available yet");return}const ls=lt(qt),Kt=ke(qt),Qt=`Watch: ${qt.title||"Video Message"} ${Kt}`;try{const fs=new Blob([ls],{type:"text/html"}),dr=new Blob([Qt],{type:"text/plain"}),bt=new ClipboardItem({"text/html":fs,"text/plain":dr});await navigator.clipboard.write([bt]),fe.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(Qt+` `+ls),fe.success("Copied! Paste into your email.")}},Ye=async qt=>{try{fe.loading("Preparing download...",{id:"download"});const{data:ls,error:Kt}=await G.functions.invoke("bunny-upload",{body:{action:"download-url",videoId:qt.bunny_video_id,isAgentVideo:!0}});if(Kt||!(ls!=null&&ls.downloadUrl))throw new Error((Kt==null?void 0:Kt.message)||"Failed to get download URL");const fs=`${((qt.title||"video").toString().trim()||"video").replace(/[\\/:*?"<>|]+/g,"-")}.mp4`,dr=await fetch(ls.downloadUrl);if(!dr.ok)throw new Error("Failed to fetch video file");const bt=await dr.blob(),ks=URL.createObjectURL(bt),ir=document.createElement("a");ir.href=ks,ir.download=fs,ir.rel="noreferrer",document.body.appendChild(ir),ir.click(),ir.remove(),URL.revokeObjectURL(ks),fe.success("Download started",{id:"download"})}catch(ls){console.error("Download error:",ls),fe.error("Could not force download (your browser may block it).",{id:"download"})}},mt=async qt=>{C(qt),ie(!0),Y(""),se(!0);try{const{data:ls,error:Kt}=await G.functions.invoke("bunny-upload",{body:{action:"crm-embed",videoId:qt.bunny_video_id,title:qt.title,isAgentVideo:!0,shareToken:qt.share_token}});if(Kt||!(ls!=null&&ls.html))throw new Error("Failed to generate CRM embed code");Y(ls.html)}catch(ls){console.error("CRM embed error:",ls),fe.error("Failed to generate CRM embed code"),se(!1)}finally{ie(!1)}},Ze=qt=>{C(qt),I(!0)},He=async()=>{if(N)try{await l.mutateAsync({id:N.id,bunnyVideoId:N.bunny_video_id,hardDelete:!0}),R(!1),C(null),fe.success("Video deleted successfully")}catch{fe.error("Failed to delete video")}};return e.jsx(Ms,{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(Xo,{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(Xa,{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(efs,{videos:g,isLoading:v,searchTerm:j,setSearchTerm:w}):_==="analytics"?e.jsx(Yps,{}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:Ve?"border-amber-500":nt?"border-destructive":"",children:e.jsxs(Oe,{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(nP,{className:`h-5 w-5 ${nt?"text-destructive":Ve?"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 / ",Dt>=1024?`${(Dt/1024).toFixed(0)} GB`:`${Dt} MB`]})]}),e.jsx(Mi,{value:Math.min(he,100),className:`h-2 ${nt?"[&>div]:bg-destructive":Ve?"[&>div]:bg-amber-500":""}`})]}),Ve&&!nt&&e.jsxs(at,{variant:"outline",className:"border-amber-500 text-amber-600",children:[e.jsx(Qo,{className:"h-3 w-3 mr-1"}),"Near Limit"]}),nt&&e.jsxs(at,{variant:"destructive",children:[e.jsx(Qo,{className:"h-3 w-3 mr-1"}),"At Limit"]})]}),nt&&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(xn,{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:j,onChange:qt=>w(qt.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(qt=>{var ls,Kt;return e.jsx(Qps,{video:qt,previewSrc:(ls=_e[qt.id])==null?void 0:ls.previewUrl,thumbnailSrc:(Kt=_e[qt.id])==null?void 0:Kt.thumbnailUrl,onOpen:()=>Ze(qt),onDelete:()=>{C(qt),R(!0)},onRename:()=>{C(qt),Ke(qt.title||""),we(!0)},onNavigateToContact:()=>t(`/mission-control/contacts/${qt.contact_id}`),onGetEmbedCode:()=>{C(qt),V(!0)},onCopyEmailHtml:()=>We(qt),onEmbedToCrm:()=>mt(qt),onShareWithTemplate:()=>{C(qt),le(!0)},onSendViaGmail:()=>{C(qt),be(!0)},isGmailConnected:d,getContactName:Te,getShareUrl:ke,copyToClipboard:Qe,formatDuration:Fe},qt.id)})}),e.jsx(vs,{open:A,onOpenChange:I,children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:(N==null?void 0:N.title)||"Video Preview"}),e.jsx(Kr,{children:(N==null?void 0:N.contact_id)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Yi,{className:"h-3 w-3"}),Te(N.contact_id)]})})]}),N&&e.jsxs("div",{className:"space-y-4",children:[N.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(As,{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(Eo,{className:"h-4 w-4 mr-2"}),"Refresh Library"]})]}):e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:N.playback_url?(()=>{let qt=N.playback_url;return qt.includes("iframe.mediadelivery.net/play/")&&(qt=qt.replace("/play/","/embed/"),qt+=(qt.includes("?")?"&":"?")+"autoplay=false&responsive=true"),qt.includes("iframe.mediadelivery.net")?e.jsx("iframe",{src:qt,title:N.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:N.playback_url,controls:!0,playsInline:!0,preload:"metadata",poster:N.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")},N.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:()=>ot(N),children:[e.jsx(io,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),!d&&e.jsxs(K,{variant:"outline",onClick:()=>qe(N),children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>Qe(ke(N),"Share link"),children:[e.jsx(ai,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(K,{variant:"outline",onClick:()=>We(N),children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(K,{variant:"outline",onClick:()=>Ye(N),children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Download Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),mt(N)},children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),le(!0)},children:[e.jsx(Rl,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]}),d&&(N==null?void 0:N.share_token)&&e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),be(!0)},children:[e.jsx(Ta,{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(vs,{open:L,onOpenChange:R,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Delete Video"}),e.jsx(Kr,{children:"Are you sure you want to delete this video? This action cannot be undone."})]}),e.jsxs(On,{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(zps,{open:$,onOpenChange:q}),e.jsx(vs,{open:U,onOpenChange:V,children:e.jsxs(ys,{className:"sm:max-w-lg",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Embed Video"}),e.jsx(Kr,{children:"Copy this code to embed the video on your website."})]}),N&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Embed Code"}),e.jsx(Tr,{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 qt=``;Qe(qt,"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."})]})]})}),N&&e.jsx(_Je,{open:ae,onOpenChange:le,video:N,contactName:Te(N.contact_id)}),N&&e.jsx(Wps,{open:pe,onOpenChange:be,video:N,gmailEmail:u,signedThumbnailUrl:(Rt=_e[N.id])==null?void 0:Rt.thumbnailUrl}),e.jsx(vs,{open:ye,onOpenChange:we,children:e.jsxs(ys,{className:"max-w-sm",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Rename Video"}),e.jsx(Kr,{children:"Enter a new title for this video."})]}),e.jsx(Re,{value:Ne,onChange:qt=>Ke(qt.target.value),placeholder:"Video title",autoFocus:!0,onKeyDown:qt=>{qt.key==="Enter"&&Ne.trim()&&i.mutate({id:N.id,title:Ne.trim()},{onSuccess:()=>{fe.success("Video renamed"),we(!1)}})}}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>we(!1),children:"Cancel"}),e.jsx(K,{disabled:!Ne.trim()||i.isPending,onClick:()=>{i.mutate({id:N.id,title:Ne.trim()},{onSuccess:()=>{fe.success("Video renamed"),we(!1)}})},children:i.isPending?"Saving...":"Save"})]})]})}),e.jsx(vs,{open:X,onOpenChange:se,children:e.jsxs(ys,{className:"sm:max-w-lg",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(rn,{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(As,{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(Tr,{readOnly:!0,rows:12,value:te,className:"font-mono text-xs"})]}),e.jsxs(K,{className:"w-full",onClick:()=>{Qe(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 efs({videos:t,isLoading:s,searchTerm:r,setSearchTerm:n}){const a=S.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=S.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(xn,{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(fn,{className:"h-7 w-7",children:[e.jsx(Ma,{src:d.avatar||""}),e.jsx(gn,{children:(d.name||"?").charAt(0).toUpperCase()})]}),e.jsx("h3",{className:"font-semibold text-sm",children:d.name}),e.jsx(at,{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(ya,{className:"h-3 w-3"}),u.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-3 w-3"}),ws(new Date(u.created_at),"MMM d")]})]})]})]},u.id))})]},i))})]})}const tfs=()=>{const{user:t}=Gs();return Ct({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})},jLe=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function sfs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=tfs(),[a,o]=S.useState(""),[l,i]=S.useState("all"),d=S.useMemo(()=>{if(!r)return new Map;const b=new Map;let j=0;return r.forEach(w=>{b.has(w.owner_user_id)||(b.set(w.owner_user_id,{name:w.owner_name||"Unknown",avatar:w.owner_avatar_url,color:jLe[j%jLe.length]}),j++)}),b},[r]),u=S.useMemo(()=>Array.from(d.entries()).map(([b,j])=>({id:b,...j})),[d]),p=S.useMemo(()=>{if(!r)return[];let b=r;if(l!=="all"&&(b=b.filter(j=>j.owner_user_id===l)),a.trim()){const j=a.toLowerCase();b=b.filter(w=>{var N,C,A,I;return w.deal_name.toLowerCase().includes(j)||((N=w.contact_name)==null?void 0:N.toLowerCase().includes(j))||((C=w.property_address)==null?void 0:C.toLowerCase().includes(j))||((A=w.city)==null?void 0:A.toLowerCase().includes(j))||((I=w.owner_name)==null?void 0:I.toLowerCase().includes(j))})}return b},[r,a,l]),g=S.useMemo(()=>{const b=new Map;return p.forEach(j=>{const w=j.stage_name||"Unknown";b.has(w)||b.set(w,{name:w,color:j.stage_color,icon:j.stage_icon,deals:[],totalValue:0});const N=b.get(w);N.deals.push(j),N.totalValue+=j.sale_price||0}),Array.from(b.values())},[p]),v=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(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-[95vw] w-full max-h-[90vh] flex flex-col",children:[e.jsx(Cs,{children:e.jsxs(Ss,{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(xn,{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(tr,{value:l,onValueChange:i,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{placeholder:"All Members"})}),e.jsxs(er,{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(gs,{className:"h-12 w-full mb-2 rounded-lg"}),e.jsx(gs,{className:"h-24 w-full mb-2 rounded-lg"}),e.jsx(gs,{className:"h-24 w-full rounded-lg"})]},b))}):g.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:g.map(b=>{const j=b.icon&&Yve[b.icon]||Wc;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(j,{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(at,{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:v(b.totalValue)})]}),e.jsx(Fi,{className:"flex-1 p-2",children:e.jsx("div",{className:"space-y-2",children:b.deals.map(w=>{const N=d.get(w.owner_user_id);return e.jsx(rfs,{deal:w,ownerColor:(N==null?void 0:N.color)||"#888",ownerName:(N==null?void 0:N.name)||"Unknown",ownerAvatar:(N==null?void 0:N.avatar)||null,formatPrice:_},w.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 ",g.length," stage",g.length!==1?"s":""," from ",u.length," member",u.length!==1?"s":""]})]})})}function rfs({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(fn,{className:"h-4 w-4",children:[e.jsx(Ma,{src:n||""}),e.jsx(gn,{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(at,{variant:"outline",className:Et("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(Vn,{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(Gc,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:a(t.sale_price)})]})]})}function nfs({members:t,enabledMembers:s,onToggleMember:r,isOpen:n,onToggleOpen:a}){const o=s.size;return e.jsxs("div",{className:Et("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(Ol,{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(Fi,{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:Et("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(fn,{className:"h-7 w-7",children:[e.jsx(Ma,{src:l.avatar_url||""}),e.jsx(gn,{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:Et("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(fn,{className:Et("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(Ma,{src:l.avatar_url||""}),e.jsx(gn,{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 kLe=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function afs(){const t=si(),{data:s}=Mf(),r=(s==null?void 0:s.role)==="team_leader",n=s==null?void 0:s.teamId,a=Ct({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,g)=>({id:p.id,name:p.name||"Unknown",avatar_url:p.avatar_url,color:kLe[g%kLe.length]}))},enabled:!!n&&!!t&&r,staleTime:5*60*1e3});return{isTeamLeader:r,teamMembers:a.data||[],isLoadingMembers:a.isLoading}}function ifs(t){return Ct({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 bJe({stages:t,currentStageId:s,onStageSelect:r,disabled:n}){const[a,o]=S.useState(!1),l=t.find(d=>d.id===s),i=d=>{d.id!==s&&r(d.id,d.name),o(!1)};return e.jsxs(yu,{open:a,onOpenChange:o,children:[e.jsx(vu,{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(qa,{className:"h-3 w-3 shrink-0"})]})}),e.jsx(Wd,{align:"end",className:"w-48 z-50 bg-popover",onClick:d=>d.stopPropagation(),children:t.map(d=>{const u=d.icon&&Yve[d.icon]||Wc,p=d.id===s;return e.jsxs(Da,{onClick:()=>i(d),className:Et("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(fa,{className:"h-4 w-4 text-primary"})]},d.id)})})]})}const ofs={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"}},lfs={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 wJe({deal:t,onClick:s,isDragging:r,stages:n,onStageChange:a,showStagePicker:o=!1,isWonStage:l=!1,ownerInfo:i=null}){var C,A;const d=AM(),u=ofs[t.deal_type],p=lfs[t.priority],g=S.useMemo(()=>t.target_close_date?Vg(new Date(t.target_close_date),new Date):null,[t.target_close_date]),v=g!==null&&g<0,_=g!==null&&g<=7&&g>=0,b=S.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?new Date(t.contract_date):new Date;return Vg(L,new Date(I))},[t]),j=l&&!t.scorecard_transaction_id,w=!!t.scorecard_transaction_id,N=I=>I?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I):null;return e.jsx(Ee,{className:Et("cursor-pointer transition-all duration-200 hover:shadow-md hover:border-primary/30 group overflow-hidden",r&&"opacity-50 rotate-2 shadow-xl",v&&"border-red-200 bg-red-50/30",j&&"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(fn,{className:"h-4 w-4",children:[e.jsx(Ma,{src:i.avatar_url||""}),e.jsx(gn,{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(at,{variant:"outline",className:Et("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(fn,{className:"h-5 w-5",children:e.jsxs(gn,{className:"text-[10px] bg-primary/10 text-primary",children:[(C=t.contact.first_name)==null?void 0:C[0],(A=t.contact.last_name)==null?void 0:A[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(Ho,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{className:"text-primary truncate",children:"Linked to Listing Exchange"})]}),j&&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(Gi,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-medium",children:"Add to Scorecard"})]}),w&&l&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx(la,{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(QE,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsxs("span",{className:Et("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(Vn,{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(Gc,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:N(t.expected_price)}),t.expected_commission&&e.jsxs("span",{className:"text-muted-foreground",children:["• ",N(t.expected_commission)," GCI"]}),(()=>{const I=P2e(t);return I!==null&&I!==t.expected_commission?e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:["• ",N(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:Et("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",p.color),children:[e.jsx("div",{className:Et("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(bJe,{stages:n,currentStageId:t.stage_id||"",onStageSelect:(I,L)=>a(t.id,I,L)}):t.target_close_date?e.jsxs("div",{className:Et("flex items-center gap-1 text-[10px]",v&&"text-red-600",_&&!v&&"text-amber-600",!v&&!_&&"text-muted-foreground"),children:[v?e.jsx(Qo,{className:"h-3 w-3"}):e.jsx(on,{className:"h-3 w-3"}),e.jsx("span",{children:v?`${Math.abs(g)}d overdue`:_?`${g}d left`:ws(new Date(t.target_close_date),"MMM d")})]}):null]})]})})}function cfs({stage:t,deals:s,onDealClick:r,onAddDeal:n,onDragStart:a,onDragOver:o,onDrop:l,isDragOver:i,isWonStage:d=!1,getOwnerInfo:u}){const p=S.useRef(null),g=s.reduce((w,N)=>w+(N.expected_price||0),0),v=s.reduce((w,N)=>w+(N.expected_commission||0),0),_=s.reduce((w,N)=>w+(P2e(N)||0),0),b=w=>w>=1e6?`$${(w/1e6).toFixed(1)}M`:w>=1e3?`$${(w/1e3).toFixed(0)}K`:`$${w.toFixed(0)}`,j=t.icon&&Yve[t.icon]||Wc;return e.jsxs("div",{ref:p,className:Et("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:w=>o(w,t.id),onDrop:w=>l(w,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(j,{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(at,{variant:"secondary",className:"text-xs font-medium px-2",children:s.length})]}),g>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(g)}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[b(v)," GCI"]}),_>0&&_!==v&&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(Fi,{className:"flex-1 p-2",children:e.jsxs("div",{className:"space-y-2",children:[s.map(w=>e.jsx("div",{draggable:!0,onDragStart:N=>{N.dataTransfer.effectAllowed="move",a(w.id,t.id)},children:e.jsx(wJe,{deal:w,onClick:()=>r(w),isWonStage:d,ownerInfo:(u==null?void 0:u(w))||null})},w.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 dfs({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:Uh,color:"text-blue-500",bgColor:"bg-blue-500/10"},{label:"Pipeline Value",value:r((t==null?void 0:t.pipelineValue)||0),icon:Xo,color:"text-purple-500",bgColor:"bg-purple-500/10"},{label:"Expected GCI",value:r((t==null?void 0:t.expectedCommission)||0),icon:Gc,color:"text-emerald-500",bgColor:"bg-emerald-500/10"},{label:"Net to Agent",value:r((t==null?void 0:t.expectedNetToAgent)||0),icon:RP,color:"text-teal-500",bgColor:"bg-teal-500/10"},{label:"Won Deals",value:(t==null?void 0:t.wonDeals)||0,icon:Gi,color:"text-amber-500",bgColor:"bg-amber-500/10"}];return s?e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[1,2,3,4].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("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:n.map(a=>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:Et("p-2 rounded-lg",a.bgColor),children:e.jsx(a.icon,{className:Et("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})]})]})})},a.label))})}function ufs({formData:t,onChange:s,isEditing:r}){const{isAdmin:n}=Gs(),[a,o]=S.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(mn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(at,{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(mf,{open:a,onOpenChange:o,children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs(pf,{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(mn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),t.portal_enabled&&e.jsx(at,{className:"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200",variant:"outline",children:"Enabled"})]}),e.jsx(Vo,{className:Et("h-4 w-4 text-muted-foreground transition-transform",a&&"rotate-180")})]}),e.jsx(ff,{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(b_e,{value:t.visibility,onValueChange:i=>l({visibility:i}),className:"grid grid-cols-2 gap-3",children:[e.jsxs("label",{className:Et("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(kne,{value:"private"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Fu,{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:Et("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(kne,{value:"public"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Am,{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(zo,{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(zo,{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(tr,{value:t.invite_method,onValueChange:i=>l({invite_method:i}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{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 hfs=[{value:"buyer",label:"Buyer"},{value:"seller",label:"Seller"},{value:"dual",label:"Dual Agency"},{value:"referral",label:"Referral"},{value:"lease",label:"Lease"}],mfs=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"urgent",label:"Urgent"}];function pfs({open:t,onOpenChange:s,deal:r,defaultStageId:n}){const{data:a}=Sce(),{data:o}=Xh(),{data:l}=oVe(),i=Zoe(),d=gJe(),u=xJe(),p=bwe(),[g,v]=S.useState({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"}),[_,b]=S.useState(""),[j,w]=S.useState(!1),[N,C]=S.useState(!1),[A,I]=S.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,$]=S.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:"",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""});S.useEffect(()=>{var te,Y,de,ie,ae,le,pe,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:((Y=r.commission_percentage)==null?void 0:Y.toString())||"3",brokerage_split_pct:((de=r.brokerage_split_pct)==null?void 0:de.toString())||"",team_split_pct:((ie=r.team_split_pct)==null?void 0:ie.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:((pe=r.transaction_fee)==null?void 0:pe.toString())||"",target_close_date:r.target_close_date?new Date(r.target_close_date):void 0,contract_date:r.contract_date?new Date(r.contract_date):void 0,listing_date:r.listing_date?new Date(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:"",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""}),b(""),v({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,ie,ae;const Y=_.toLowerCase();return((de=te.first_name)==null?void 0:de.toLowerCase().includes(Y))||((ie=te.last_name)==null?void 0:ie.toLowerCase().includes(Y))||((ae=te.email)==null?void 0:ae.toLowerCase().includes(Y))}).slice(0,5),U=()=>{const te=parseFloat(R.expected_price)||0,Y=parseFloat(R.commission_percentage)||0;return te*(Y/100)},V=()=>{const te=U();if(!te)return null;let Y=te;const de=parseFloat(R.brokerage_split_pct)||0,ie=parseFloat(R.team_split_pct)||0,ae=parseFloat(R.referral_fee_pct)||0,le=parseFloat(R.franchise_fee_pct)||0,pe=parseFloat(R.transaction_fee)||0;return de&&(Y=Y*((100-de)/100)),ie&&(Y=Y*((100-ie)/100)),ae&&(Y=Y-te*ae/100),le&&(Y=Y-te*le/100),pe&&(Y=Y-pe),Math.max(0,Y)},X=async te=>{var Y,de,ie;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,net_commission:V(),target_close_date:((Y=R.target_close_date)==null?void 0:Y.toISOString().split("T")[0])||null,contract_date:((de=R.contract_date)==null?void 0:de.toISOString().split("T")[0])||null,listing_date:((ie=R.listing_date)==null?void 0:ie.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"),g.portal_enabled&&(le!=null&&le.id))try{await p.mutateAsync({deal_id:le.id,visibility:g.visibility,require_onboarding:g.require_onboarding,allow_spouse:g.allow_spouse,client_name:g.client_name||null,client_email:g.client_email||null,client_phone:g.client_phone||null,invite_method:g.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(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:X,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=>$(Y=>({...Y,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(tr,{value:R.deal_type,onValueChange:te=>$(Y=>({...Y,deal_type:te})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:hfs.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(tr,{value:R.stage_id||"none",onValueChange:te=>$(Y=>({...Y,stage_id:te==="none"?"":te})),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select stage"})}),e.jsxs(er,{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(xn,{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),w(!0),C(!1),te.target.value||$(Y=>({...Y,contact_id:""}))},onFocus:()=>w(!0),placeholder:"Search contacts...",className:"pl-9"}),j&&_&&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:()=>{$(Y=>({...Y,contact_id:te.id})),b(`${te.first_name} ${te.last_name}`),w(!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:""}),C(!0),w(!1)},children:[e.jsx(fc,{className:"h-4 w-4"}),e.jsxs("span",{children:['Create new contact "',_.trim(),'"']})]})]})]}),N&&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(fc,{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:()=>C(!1),children:"Cancel"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Re,{placeholder:"First name *",value:A.first_name,onChange:te=>I(Y=>({...Y,first_name:te.target.value})),className:"h-8 text-sm"}),e.jsx(Re,{placeholder:"Last name",value:A.last_name,onChange:te=>I(Y=>({...Y,last_name:te.target.value})),className:"h-8 text-sm"}),e.jsx(Re,{placeholder:"Email",type:"email",value:A.email,onChange:te=>I(Y=>({...Y,email:te.target.value})),className:"h-8 text-sm"}),e.jsx(Re,{placeholder:"Phone",type:"tel",value:A.phone,onChange:te=>I(Y=>({...Y,phone:te.target.value})),className:"h-8 text-sm"})]}),e.jsx(K,{type:"button",size:"sm",className:"w-full h-8",disabled:!A.first_name.trim()||i.isPending,onClick:async()=>{try{const te=await i.mutateAsync({first_name:A.first_name.trim(),last_name:A.last_name.trim()||null,email:A.email.trim()||null,phone:A.phone.trim()||null});te&&($(Y=>({...Y,contact_id:te.id})),b(`${te.first_name} ${te.last_name||""}`.trim()),C(!1))}catch{}},children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-3.5 w-3.5 mr-1 animate-spin"})," Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(fc,{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(Ho,{className:"h-4 w-4"}),"Link to Listing Exchange"]}),e.jsxs(tr,{value:R.listing_id||"none",onValueChange:te=>{const Y=te==="none"?"":te,de=L.find(ie=>ie.id===Y);$(de?ie=>{var ae;return{...ie,listing_id:Y,deal_type:"seller",property_address:de.property_address||ie.property_address,city:de.city||ie.city,state:de.state||ie.state,expected_price:((ae=de.price)==null?void 0:ae.toString())||ie.expected_price}}:ie=>({...ie,listing_id:Y}))},children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select a listing to sync status..."})}),e.jsxs(er,{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=>$(Y=>({...Y,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=>$(Y=>({...Y,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=>$(Y=>({...Y,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=>$(Y=>({...Y,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=>$(Y=>({...Y,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=>$(Y=>({...Y,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:"grid grid-cols-2 gap-3 mt-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=>$(Y=>({...Y,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=>$(Y=>({...Y,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=>$(Y=>({...Y,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=>$(Y=>({...Y,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=>$(Y=>({...Y,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:V()?`$${Math.round(V()).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(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Et("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?ws(R.target_close_date,"PPP"):"Pick a date"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(vp,{mode:"single",selected:R.target_close_date,onSelect:te=>$(Y=>({...Y,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(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Et("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?ws(R.contract_date,"PPP"):"Pick a date"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(vp,{mode:"single",selected:R.contract_date,onSelect:te=>$(Y=>({...Y,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(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Et("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?ws(R.listing_date,"PPP"):"Pick a date"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(vp,{mode:"single",selected:R.listing_date,onSelect:te=>$(Y=>({...Y,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(tr,{value:R.priority,onValueChange:te=>$(Y=>({...Y,priority:te})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:mfs.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=>$(Y=>({...Y,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(Tr,{id:"notes",value:R.notes,onChange:te=>$(Y=>({...Y,notes:te.target.value})),placeholder:"Add any additional notes about this deal...",rows:3})]}),!r&&e.jsx(ufs,{formData:g,onChange:v}),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(As,{className:"h-4 w-4 mr-2 animate-spin"}),r?"Update Deal":"Create Deal"]})]})]})]})})}function ffs(t){return Ct({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 gfs(){const t=si(),s=ns();return Ot({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 xfs(){const t=ns();return Ot({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 yfs(){const t=ns();return Ot({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 vfs(t){const{data:s,error:r}=await G.storage.from("deal-files").createSignedUrl(t,3600);if(r)throw r;return s.signedUrl}const NLe={text:"Short Text",textarea:"Long Text",dropdown:"Dropdown",toggle:"Yes / No"};function _fs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=uBt(),a=hBt(),o=mBt(),l=pBt(),[i,d]=S.useState(!1),[u,p]=S.useState({question_text:"",field_type:"text",options:[],is_required:!1}),[g,v]=S.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}),v(""),d(!1),fe.success("Question added")}catch{fe.error("Failed to add question")}},b=async C=>{try{await l.mutateAsync(C),fe.success("Question removed")}catch{fe.error("Failed to remove question")}},j=async(C,A)=>{try{await o.mutateAsync({id:C,is_required:A})}catch{fe.error("Failed to update question")}},w=()=>{g.trim()&&(p(C=>({...C,options:[...C.options,g.trim()]})),v(""))},N=C=>{p(A=>({...A,options:A.options.filter((I,L)=>L!==C)}))};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-md max-h-[85vh] flex flex-col",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(Fi,{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(As,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),r==null?void 0:r.map(C=>{var A;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(Ru,{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:C.question_text}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(at,{variant:"secondary",className:"text-xs",children:NLe[C.field_type]||C.field_type}),C.is_required&&e.jsx(at,{variant:"outline",className:"text-xs",children:"Required"})]}),C.field_type==="dropdown"&&((A=C.options)==null?void 0:A.length)>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Options: ",C.options.join(", ")]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(Br,{checked:C.is_required,onCheckedChange:I=>j(C.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(C.id),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]})},C.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:C=>p(A=>({...A,question_text:C.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(NLe).map(([C,A])=>e.jsx("button",{type:"button",onClick:()=>p(I=>({...I,field_type:C,options:[]})),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${u.field_type===C?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:A},C))})]}),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((C,A)=>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:C}),e.jsx("button",{onClick:()=>N(A),className:"text-muted-foreground hover:text-destructive",children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]},A)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{value:g,onChange:C=>v(C.target.value),onKeyDown:C=>C.key==="Enter"&&(C.preventDefault(),w()),placeholder:"Add option...",className:"h-8 text-sm"}),e.jsx(K,{variant:"outline",size:"sm",onClick:w,disabled:!g.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:C=>p(A=>({...A,is_required:C}))}),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(As,{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 bfs({portalId:t,ownerId:s,clientEmail:r,linkedPortalId:n,onLink:a}){const[o,l]=S.useState(""),[i,d]=S.useState(!1),{data:u,isLoading:p}=Ct({queryKey:["all-owner-portals",s],queryFn:async()=>{const{data:b,error:j}=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(j)throw j;return b},enabled:i||!!n}),g=S.useMemo(()=>!n||!u?null:u.find(b=>b.id===n),[n,u]),v=S.useMemo(()=>!u||!r?[]:u.filter(b=>{var j;return((j=b.client_email)==null?void 0:j.toLowerCase())===r.toLowerCase()&&b.id!==t}),[u,r,t]),_=S.useMemo(()=>{if(!u||!o.trim())return[];const b=o.toLowerCase();return u.filter(j=>{var N,C,A,I;const w=j.deal_pipeline;return((N=j.client_name)==null?void 0:N.toLowerCase().includes(b))||((C=j.client_email)==null?void 0:C.toLowerCase().includes(b))||((A=w==null?void 0:w.deal_name)==null?void 0:A.toLowerCase().includes(b))||((I=w==null?void 0:w.property_address)==null?void 0:I.toLowerCase().includes(b))})},[u,o]);if(n){const b=g==null?void 0:g.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(Ho,{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:(g==null?void 0:g.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(cN,{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(Ho,{className:"h-3 w-3 mr-1"}),i?"Cancel":"Link"]})]}),!i&&v.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)"}),v.map(b=>{const j=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(at,{variant:"outline",className:"text-[10px] shrink-0 bg-amber-100 border-amber-300 text-amber-700",children:(j==null?void 0:j.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:(j==null?void 0:j.deal_name)||b.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:j==null?void 0:j.property_address})]}),e.jsx(Ho,{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(xn,{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(As,{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 j=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(at,{variant:"outline",className:"text-[10px] shrink-0",children:(j==null?void 0:j.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:(j==null?void 0:j.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 I2e({userId:t,onSelect:s,triggerLabel:r="Library",triggerSize:n="sm",triggerVariant:a="outline",triggerClassName:o}){const[l,i]=S.useState(!1),[d,u]=S.useState([]),[p,g]=S.useState(!1),[v,_]=S.useState("");S.useEffect(()=>{!l||!t||(g(!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:j})=>{u(j||[]),g(!1)}))},[l,t]);const b=d.filter(j=>!v||(j.title||j.recipient_name||"").toLowerCase().includes(v.toLowerCase()));return e.jsxs(vs,{open:l,onOpenChange:i,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{variant:a,size:n,className:o||"gap-1.5 shrink-0",children:[e.jsx(au,{className:"h-3.5 w-3.5"}),r]})}),e.jsxs(ys,{className:"max-w-lg max-h-[70vh] flex flex-col",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(xn,{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:v,onChange:j=>_(j.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(gs,{className:"h-16 w-full"}),e.jsx(gs,{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(j=>e.jsxs("button",{onClick:()=>{s(j.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:j.thumbnail_url?e.jsx("img",{src:j.thumbnail_url,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:w=>{const N=w.currentTarget.parentElement;if(N){w.currentTarget.remove();const C=document.createElement("span");C.innerHTML="🎬",C.className="text-lg",N.appendChild(C)}}}):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:j.title||j.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.duration_seconds?`${Math.round(j.duration_seconds)}s`:"",j.created_at?` · ${new Date(j.created_at).toLocaleDateString()}`:""]})]})]},j.id))})]})]})}function L2e({contactId:t,onVideoReady:s}){const[r,n]=S.useState(!1),[a,o]=S.useState("record"),[l,i]=S.useState(0),[d,u]=S.useState(0),p=nS(),g=()=>{o("record"),i(0),u(0)},v=b=>{!b&&(a==="uploading"||a==="processing")||(n(b),b||g())},_=S.useCallback(async(b,j)=>{o("uploading");try{const w="Card Video",{videoId:N,libraryId:C}=await GL(w),{uploadUrl:A,apiKey:I}=await KL(N),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",A),L.setRequestHeader("AccessKey",I),L.send(b)}),o("processing");let R=0;const $=Date.now(),q=9e4,U=`https://iframe.mediadelivery.net/embed/${C}/${N}`;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:N,playback_url:`https://iframe.mediadelivery.net/play/${C}/${N}`,file_size_mb:te,title:w,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),g()},1500);return}const se=await C3(N);if(R=se.status,u(se.encodeProgress||0),R===5||R===6)throw new Error("Video processing failed")}const V=await C3(N),X=(V.storageSize||b.size)/(1024*1024);await p.mutateAsync({bunny_video_id:N,contact_id:t||void 0,playback_url:V.directPlayUrl||U,thumbnail_url:V.thumbnailUrl,preview_url:V.previewUrl||null,duration_seconds:V.length||j,file_size_mb:X,title:w,status:"ready",touch_type:"video"}),s(U),fe.success("Video recorded & added to your library!"),o("done"),setTimeout(()=>{n(!1),g()},1500)}catch(w){console.error("Recording upload error:",w),fe.error("Failed to process video. Please try again."),o("record")}},[t,s,p]);return e.jsxs(vs,{open:r,onOpenChange:v,children:[e.jsx(Ai,{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(ys,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Record a Video for Your Card"})}),a==="record"&&e.jsx(Mce,{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(As,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Uploading video..."}),e.jsx(Mi,{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(As,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Processing video..."}),e.jsx(Mi,{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(fi,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium",children:"Video attached to your card!"})]})]})]})}function jJe({open:t,onOpenChange:s,portal:r,dealOwnerId:n}){const a=ZL(),[o,l]=S.useState(!1),[i,d]=S.useState(r.next_step_text||""),[u,p]=S.useState(r.next_step_video_url||""),[g,v]=S.useState(r.inspection_date||""),[_,b]=S.useState(r.appraisal_date||""),[j,w]=S.useState(r.welcome_message||""),[N,C]=S.useState(r.review_url||""),[A,I]=S.useState(r.show_post_close_tips),[L,R]=S.useState(r.notify_client),[$,q]=S.useState(r.require_onboarding),[U,V]=S.useState(r.allow_spouse),[X,se]=S.useState(r.visibility),[te,Y]=S.useState(r.stage_mapping||[]),[de,ie]=S.useState(null),[ae,le]=S.useState(r.linked_portal_id||null),{data:pe}=Ct({queryKey:["pipeline-stages-for-portal",n],queryFn:async()=>{const{data:_e,error:Me}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",n).order("sort_order",{ascending:!0});if(Me)throw Me;return _e},enabled:t});S.useEffect(()=>{d(r.next_step_text||""),p(r.next_step_video_url||""),v(r.inspection_date||""),b(r.appraisal_date||""),w(r.welcome_message||""),C(r.review_url||""),I(r.show_post_close_tips),R(r.notify_client),q(r.require_onboarding),V(r.allow_spouse),se(r.visibility),Y(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:g||null,appraisal_date:_||null,welcome_message:j||null,review_url:N||null,show_post_close_tips:A,notify_client:L,require_onboarding:$,allow_spouse:U,visibility:X,stage_mapping:te.length>0?te:null,linked_portal_id:ae});const _e=r.linked_portal_id;ae&&ae!==_e&&await G.from("client_portals").update({linked_portal_id:r.id}).eq("id",ae),!ae&&_e&&await G.from("client_portals").update({linked_portal_id:null}).eq("id",_e),fe.success("Portal settings saved"),s(!1)}catch{fe.error("Failed to save settings")}},ye=()=>{Y([...te,{label:""}])},we=_e=>{Y(te.filter((Me,Te)=>Te!==_e)),de===_e&&ie(null)},Ne=(_e,Me,Te)=>{const Fe=[...te];Fe[_e]={...Fe[_e],[Me]:Te},Y(Fe)},Ke=()=>{const Me=t_e(null).map(Te=>({label:Te.label,description:Te.description,stageId:void 0}));Y(Me)};return e.jsxs(e.Fragment,{children:[e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-lg max-h-[85vh] flex flex-col",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Portal Settings"})}),e.jsxs(ja,{defaultValue:"general",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(va,{className:"grid grid-cols-3 shrink-0",children:[e.jsx(Ns,{value:"general",children:"General"}),e.jsx(Ns,{value:"timeline",children:"Timeline"}),e.jsx(Ns,{value:"content",children:"Content"})]}),e.jsxs(Fi,{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(_e=>e.jsx("button",{onClick:()=>se(_e),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${X===_e?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:_e.charAt(0).toUpperCase()+_e.slice(1)},_e))})]}),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:V})]}),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:A,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(bfs,{portalId:r.id,ownerId:n,clientEmail:r.client_email,linkedPortalId:ae,onLink:le})}),e.jsx("div",{children:e.jsx(Re,{type:"date",value:g,onChange:_e=>v(_e.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:_e=>b(_e.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:Ke,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:Ke,children:"Customize journey labels"})]}),e.jsx("div",{className:"space-y-2 mt-2",children:te.map((_e,Me)=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ru,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"}),e.jsx(Re,{value:_e.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:()=>ie(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:()=>we(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:_e.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"}),_e.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:_e.video_url.length>40?_e.video_url.slice(0,40)+"...":_e.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(L2e,{onVideoReady:Te=>Ne(Me,"video_url",Te)}),e.jsx(I2e,{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(Io,{className:"h-3 w-3"}),"Paste URL"]})]})]})]})]},Me))}),te.length>0&&e.jsxs(K,{variant:"outline",size:"sm",onClick:ye,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:j,onChange:_e=>w(_e.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:_e=>d(_e.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:_e=>p(_e.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:N,onChange:_e=>C(_e.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(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(zu,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})}),e.jsx(_fs,{open:o,onOpenChange:l})]})}function kJe({open:t,onOpenChange:s,portalId:r,portalSlug:n,notifyClient:a}){const[o,l]=S.useState(""),[i,d]=S.useState(""),[u,p]=S.useState(""),[g,v]=S.useState(!1),[_,b]=S.useState(a??!1),j=_Ze(),w=async()=>{if(o.trim())try{if(await j.mutateAsync({portal_id:r,title:o.trim(),content:i.trim()||void 0,video_url:u.trim()||void 0,is_stage_change:g}),_&&n)try{const N=R0(n);await G.functions.invoke("send-portal-notification",{body:{portal_id:r,update_title:o.trim(),update_content:i.trim()||null,portal_url:N}}),fe.success("Update posted & client notified")}catch(N){console.error("Notification failed:",N),fe.success("Update posted (notification failed to send)")}else fe.success("Update posted to portal");l(""),d(""),p(""),v(!1),s(!1)}catch{fe.error("Failed to post update")}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{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:N=>l(N.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:N=>d(N.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:N=>p(N.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:()=>v(!g),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${g?"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(cf,{className:"h-3 w-3"}):e.jsx(Z1,{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:w,disabled:!o.trim()||j.isPending,children:[j.isPending?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Post Update"]})]})]})})}function NJe({open:t,onOpenChange:s,portal:r,dealName:n}){const a=ZL(),{isGmailConnected:o,gmailEmail:l}=py(),[i,d]=S.useState(r.client_name||""),[u,p]=S.useState(r.client_email||""),[g,v]=S.useState(!1),[_,b]=S.useState(!1),j=R0(r.slug),w=i.split(" ")[0]||"there",N=`Your Transaction Portal – ${n}`,C=`Hi ${w}, I've set up a dedicated portal where you can track the progress of your transaction in real-time. Here's your link: ${j} You can view your timeline, key dates, documents, and any updates I post along the way. Let me know if you have any questions!`,A=()=>{navigator.clipboard.writeText(j),b(!0),setTimeout(()=>b(!1),2e3),fe.success("Portal link copied!")},I=async()=>{if(!u.trim()){fe.error("Please enter the client email");return}v(!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:N,body:C.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{v(!1)}},L=()=>{const R=encodeURIComponent(N),$=encodeURIComponent(C);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(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{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:j})}),e.jsx(K,{variant:"outline",size:"icon",onClick:A,className:"shrink-0",children:_?e.jsx(fa,{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:g||!u.trim(),className:"w-full",children:[g?e.jsx(As,{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(rn,{className:"h-4 w-4 mr-2"}),"Open in Email App"]}),e.jsxs(K,{variant:"ghost",onClick:A,className:"w-full text-muted-foreground",children:[e.jsx(ai,{className:"h-4 w-4 mr-2"}),"Just Copy Link"]})]})]})]})})}function wfs({deal:t}){const{isAdmin:s,user:r}=Gs(),{data:n,isLoading:a}=oBt(t.id),o=bwe(),l=ZL(),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[g,v]=S.useState(!1),[_,b]=S.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(mn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(As,{className:"h-3 w-3 animate-spin ml-auto"})]})});const j=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)}},w=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")}},N=()=>{if(!n)return;const L=R0(n.slug);navigator.clipboard.writeText(L),fe.success("Portal link copied!")},C=()=>{if(!n)return;const L=R0(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(mn,{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:j,disabled:i,size:"sm",className:"w-full",children:[i?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(mn,{className:"h-4 w-4 mr-2"}),"Enable Client Portal"]})]});const A=R0(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(mn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(at,{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:w})]}),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(at,{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:A})}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:N,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:C,className:"text-xs flex-1 min-w-0",children:[e.jsx(rn,{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(Ta,{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:()=>v(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(x5,{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(Fl,{className:"h-3 w-3 mr-1 shrink-0"}),"Settings"]})]})]}),e.jsx(jJe,{open:u,onOpenChange:p,portal:n,dealOwnerId:I}),e.jsx(kJe,{open:g,onOpenChange:v,portalId:n.id,portalSlug:n.slug,notifyClient:n.notify_client}),e.jsx(NJe,{open:_,onOpenChange:b,portal:n,dealName:t.deal_name})]})}const jfs=["Client","Co-Buyer","Co-Seller","Spouse","Lender","Title Company","Inspector","Appraiser","Attorney","Contractor","Other"];function kfs(t){return Ct({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 Nfs(){const t=ns();return Ot({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 Sfs(){const t=ns();return Ot({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 Cfs({dealId:t,primaryContactId:s}){const r=Lr(),{data:n,isLoading:a}=kfs(t),{data:o}=Xh(),l=Nfs(),i=Sfs(),[d,u]=S.useState(!1),[p,g]=S.useState(""),[v,_]=S.useState("Client"),b=new Set((n==null?void 0:n.map(A=>A.contact_id))||[]);s&&b.add(s);const j=o==null?void 0:o.filter(A=>{var L,R,$;if(b.has(A.id))return!1;if(!p.trim())return!0;const I=p.toLowerCase();return((L=A.first_name)==null?void 0:L.toLowerCase().includes(I))||((R=A.last_name)==null?void 0:R.toLowerCase().includes(I))||(($=A.email)==null?void 0:$.toLowerCase().includes(I))}).slice(0,8),w=A=>{l.mutate({dealId:t,contactId:A,role:v}),u(!1),g("")},N=A=>{i.mutate({id:A,dealId:t})},C={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(No,{open:d,onOpenChange:u,children:[e.jsx(So,{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(jo,{className:"w-80 p-3",align:"start",children:e.jsx(SLe,{search:p,setSearch:g,selectedRole:v,setSelectedRole:_,filteredContacts:j,onAdd:w})})]})]}):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(at,{variant:"secondary",className:"text-[10px] px-1.5",children:n.length})]}),e.jsxs(No,{open:d,onOpenChange:u,children:[e.jsx(So,{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(jo,{className:"w-80 p-3",align:"end",children:e.jsx(SLe,{search:p,setSearch:g,selectedRole:v,setSelectedRole:_,filteredContacts:j,onAdd:w})})]})]}),e.jsx("div",{className:"space-y-1.5",children:n==null?void 0:n.map(A=>{var I,L,R,$,q,U,V,X;return e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-muted/40 group",children:[e.jsx(fn,{className:"h-7 w-7",children:e.jsxs(gn,{className:"text-[10px] bg-primary/10 text-primary",children:[(L=(I=A.contact)==null?void 0:I.first_name)==null?void 0:L[0],($=(R=A.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/${A.contact_id}`),className:"text-sm font-medium hover:underline text-primary truncate block",children:[(q=A.contact)==null?void 0:q.first_name," ",(U=A.contact)==null?void 0:U.last_name]})}),e.jsx(at,{variant:"outline",className:`text-[10px] px-1.5 py-0 shrink-0 ${C[A.role]||C.Other}`,children:A.role}),e.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[((V=A.contact)==null?void 0:V.phone)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`tel:${A.contact.phone}`,children:e.jsx(Zn,{className:"h-3 w-3"})})}),((X=A.contact)==null?void 0:X.email)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`mailto:${A.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:()=>N(A.id),children:e.jsx(jr,{className:"h-3 w-3"})})]})]},A.id)})})]})}function SLe({search:t,setSearch:s,selectedRole:r,setSelectedRole:n,filteredContacts:a,onAdd:o}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs(tr,{value:r,onValueChange:n,children:[e.jsx(Js,{className:"h-8 text-sm",children:e.jsx(sr,{placeholder:"Role"})}),e.jsx(er,{children:jfs.map(l=>e.jsx(At,{value:l,children:l},l))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(xn,{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(Fi,{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 Mfs={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"}},Tfs={note:io,call:Zn,email:br,meeting:on,stage_change:rn,task_completed:la,document:Vn,system:In};function Afs({deal:t,open:s,onOpenChange:r,onEdit:n,onAddToScorecard:a,isWonStage:o}){var Te,Fe;const{data:l,isLoading:i}=gps((t==null?void 0:t.id)||""),{data:d,isLoading:u}=yps((t==null?void 0:t.id)||""),p=xps(),g=_ps(),v=vps(),_=fps(),{data:b,isLoading:j}=ffs((t==null?void 0:t.id)||""),w=gfs(),N=xfs(),C=yfs(),A=S.useRef(null),[I,L]=S.useState(""),[R,$]=S.useState(""),[q,U]=S.useState(!1),[V,X]=S.useState(!1);if(!t)return null;const se=Mfs[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?new Date(t.contract_date):new Date;return Vg(Ue,new Date(Ae))})(),Y=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")}},ie=async()=>{if(R.trim())try{await g.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 v.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")}},pe=(d==null?void 0:d.filter(Ae=>Ae.is_completed).length)||0,be=(d==null?void 0:d.length)||0,ye=(b==null?void 0:b.length)||0,we=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")?Sn:l5:l5,Ke=async Ae=>{const Ue=Ae.target.files;if(!(!Ue||!t)){X(!0);try{for(const ut of Array.from(Ue)){if(ut.size>20*1024*1024){fe.error(`${ut.name} exceeds 20MB limit`);continue}await w.mutateAsync({dealId:t.id,file:ut})}fe.success("File(s) uploaded")}catch{fe.error("Failed to upload file")}finally{X(!1),A.current&&(A.current.value="")}}},_e=async(Ae,Ue)=>{if(t)try{await N.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 vfs(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(fM,{open:s,onOpenChange:r,children:e.jsxs(tS,{className:"w-full sm:max-w-xl p-0 flex flex-col",children:[e.jsx(gM,{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(at,{variant:"outline",className:Et("text-xs",se.color),children:se.label}),e.jsxs(at,{variant:"secondary",className:"text-xs capitalize",children:[t.priority," priority"]})]}),e.jsx(xM,{className:"text-xl",children:t.deal_name})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>n(t),children:e.jsx(Dc,{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(Fi,{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(fn,{className:"h-10 w-10",children:e.jsxs(gn,{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(Zn,{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(Cfs,{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(Vn,{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:Y(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:Y(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?` (${Y(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:Y(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:Y(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(Gi,{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(la,{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:Et("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: ",ws(new Date(t.target_close_date),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Gc,{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(wfs,{deal:t}),e.jsxs(ja,{defaultValue:"tasks",className:"w-full",children:[e.jsxs(va,{className:"w-full grid grid-cols-3",children:[e.jsxs(Ns,{value:"tasks",className:"gap-1",children:[e.jsx(la,{className:"h-4 w-4"}),"Tasks ",be>0&&`(${pe}/${be})`]}),e.jsxs(Ns,{value:"files",className:"gap-1",children:[e.jsx(aN,{className:"h-4 w-4"}),"Files ",ye>0&&`(${ye})`]}),e.jsxs(Ns,{value:"activity",className:"gap-1",children:[e.jsx(In,{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"&&ie()}),e.jsx(K,{onClick:ie,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:Et("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(zo,{checked:Ae.is_completed,onCheckedChange:Ue=>ae(Ae.id,!!Ue)}),e.jsx("span",{className:Et("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:ws(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:A,className:"hidden",multiple:!0,onChange:Ke,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=A.current)==null?void 0:Ae.click()},disabled:V,children:[V?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Xa,{className:"h-4 w-4 mr-2"}),V?"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:[we(Ae.file_size)," · ",ws(new Date(Ae.created_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(YN,{children:e.jsxs(nd,{children:[e.jsx(ad,{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:()=>C.mutate({fileId:Ae.id,visible:!Ae.visible_on_portal,dealId:t.id}),children:Ae.visible_on_portal?e.jsx(ya,{className:"h-4 w-4"}):e.jsx(Tm,{className:"h-4 w-4"})})}),e.jsx(Hc,{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(gi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>_e(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(Tr,{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(Ta,{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=Tfs[Ae.activity_type]||In;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(tc,{open:q,onOpenChange:U,children:e.jsxs(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Delete Deal?"}),e.jsxs(Il,{children:['This will permanently delete "',t.deal_name,'" and all associated data. This action cannot be undone.']})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:le,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function Efs({open:t,onOpenChange:s,deal:r,onComplete:n}){const a=Yoe(),o=xJe(),{data:l}=IL(),{data:i}=Ef(),[d,u]=S.useState({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:ws(new Date,"yyyy-MM-dd"),sale_price:0,commission_amount:0,lead_source_id:"",client_type_id:"",notes:""});S.useEffect(()=>{if(r&&t){const v=r.deal_type==="seller"?"seller":"buyer",_=r.expected_price||0,b=r.commission_percentage||3,j=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:v,close_date:r.actual_close_date||r.target_close_date||ws(new Date,"yyyy-MM-dd"),sale_price:_,commission_amount:j,lead_source_id:"",client_type_id:"",notes:r.notes||""})}},[r,t]);const p=async v=>{if(v.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")}},g=v=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(v);return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-[550px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{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(Gi,{className:"h-6 w-6 text-green-600 dark:text-green-400"})}),e.jsx(Ss,{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(Vn,{className:"h-4 w-4 text-muted-foreground"}),"Property Address *"]}),e.jsx(Re,{id:"property_address",value:d.property_address,onChange:v=>u(_=>({..._,property_address:v.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:v=>u(_=>({..._,city:v.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:v=>u(_=>({..._,state:v.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:v=>u(_=>({..._,zip:v.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(tr,{value:d.transaction_type,onValueChange:v=>u(_=>({..._,transaction_type:v})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{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:v=>u(_=>({..._,close_date:v.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(Gc,{className:"h-4 w-4 text-muted-foreground"}),"Sale Price *"]}),e.jsx(Re,{id:"sale_price",type:"number",value:d.sale_price||"",onChange:v=>u(_=>({..._,sale_price:Number(v.target.value)})),placeholder:"450000",required:!0,min:0}),d.sale_price>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:g(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(y5,{className:"h-4 w-4 text-muted-foreground"}),"GCI (Commission)"]}),e.jsx(Re,{id:"commission_amount",type:"number",value:d.commission_amount||"",onChange:v=>u(_=>({..._,commission_amount:Number(v.target.value)})),placeholder:"13500",min:0}),d.commission_amount>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:g(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(tr,{value:d.lead_source_id,onValueChange:v=>u(_=>({..._,lead_source_id:v})),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select source"})}),e.jsx(er,{children:l==null?void 0:l.map(v=>e.jsx(At,{value:v.id,children:v.name},v.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Client Type"}),e.jsxs(tr,{value:d.client_type_id,onValueChange:v=>u(_=>({..._,client_type_id:v})),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select type"})}),e.jsx(er,{children:i==null?void 0:i.map(v=>e.jsx(At,{value:v.id,children:v.name},v.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"notes",children:"Notes"}),e.jsx(Tr,{id:"notes",value:d.notes,onChange:v=>u(_=>({..._,notes:v.target.value})),placeholder:"Any additional notes about this transaction...",rows:2})]}),e.jsxs(On,{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(Ui,{className:"ml-2 h-4 w-4"})]})})]})]})]})})}const Pfs={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"}},CLe={urgent:0,high:1,medium:2,low:3};function Ifs({deals:t,stages:s,onDealClick:r,onStageChange:n}){const[a,o]=S.useState("target_close_date"),[l,i]=S.useState("asc"),d=_=>{a===_?i(b=>b==="asc"?"desc":"asc"):(o(_),i("asc"))},u=S.useMemo(()=>[...t].sort((_,b)=>{var w,N;let j=0;switch(a){case"deal_name":j=_.deal_name.localeCompare(b.deal_name);break;case"stage":{const C=((w=s.find(I=>I.id===_.stage_id))==null?void 0:w.sort_order)||0,A=((N=s.find(I=>I.id===b.stage_id))==null?void 0:N.sort_order)||0;j=C-A;break}case"expected_price":j=(_.expected_price||0)-(b.expected_price||0);break;case"expected_commission":j=(_.expected_commission||0)-(b.expected_commission||0);break;case"target_close_date":{const C=_.target_close_date?new Date(_.target_close_date).getTime():1/0,A=b.target_close_date?new Date(b.target_close_date).getTime():1/0;j=C-A;break}case"priority":j=CLe[_.priority]-CLe[b.priority];break}return l==="asc"?j:-j}),[t,s,a,l]),p=_=>_?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(_):"—",g=_=>_?s.find(b=>b.id===_):null,v=({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(qd,{className:"ml-2 h-4 w-4"}):e.jsx(Ju,{className:"ml-2 h-4 w-4"}):e.jsx(Vc,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{className:"bg-muted/50",children:[e.jsx(jt,{className:"w-[250px]",children:e.jsx(v,{field:"deal_name",children:"Deal Name"})}),e.jsx(jt,{className:"w-[150px]",children:e.jsx(v,{field:"stage",children:"Stage"})}),e.jsx(jt,{className:"w-[100px]",children:"Type"}),e.jsx(jt,{className:"w-[120px]",children:e.jsx(v,{field:"expected_price",children:"Price"})}),e.jsx(jt,{className:"w-[120px]",children:e.jsx(v,{field:"expected_commission",children:"GCI"})}),e.jsx(jt,{className:"w-[130px]",children:e.jsx(v,{field:"target_close_date",children:"Close Date"})}),e.jsx(jt,{className:"w-[100px]",children:e.jsx(v,{field:"priority",children:"Priority"})})]})}),e.jsx(En,{children:u.map(_=>{g(_.stage_id);const b=Pfs[_.deal_type],j=_.target_close_date?Vg(new Date(_.target_close_date),new Date):null,w=j!==null&&j<0,N=j!==null&&j<=7&&j>=0;return e.jsxs(js,{className:Et("cursor-pointer hover:bg-muted/50 transition-colors",w&&"bg-red-50/50"),onClick:()=>r(_),children:[e.jsx(it,{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(it,{onClick:C=>C.stopPropagation(),children:e.jsx(bJe,{stages:s,currentStageId:_.stage_id||"",onStageSelect:(C,A)=>n(_.id,C,A)})}),e.jsx(it,{children:e.jsx(at,{variant:"outline",className:Et("text-xs",b.color),children:b.label})}),e.jsx(it,{children:e.jsx("span",{className:"font-medium",children:p(_.expected_price)})}),e.jsx(it,{children:e.jsx("span",{className:"text-emerald-600",children:p(_.expected_commission)})}),e.jsx(it,{children:_.target_close_date?e.jsxs("div",{className:Et("flex items-center gap-1 text-sm",w&&"text-red-600",N&&!w&&"text-amber-600"),children:[w&&e.jsx(Qo,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:ws(new Date(_.target_close_date),"MMM d, yyyy")})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(it,{children:e.jsx(at,{variant:"outline",className:Et("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 Lfs(){const t=si();return Ct({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 Dfs(t){const s=si();return Ct({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 Ofs(){const t=si(),s=ns();return Ot({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 Rfs(){const t=ns();return Ot({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 Ffs(){const t=ns();return Ot({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 D2e(){const t=ns();return Ot({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 zfs(){const t=ns();return Ot({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 Bfs(t){const s=si();return Ct({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 $fs(){const t=si(),s=ns();return Ot({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 qfs(){const t=ns();return Ot({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 Ufs(){const t=si(),s=ns();return Ot({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(g=>g.title)),d=a.filter(g=>!i.has(g.title)).map((g,v)=>({owner_user_id:t,deal_id:r,stage_id:n,title:g.title,description:g.description,priority:g.priority,due_date:g.default_due_offset_days?new Date(Date.now()+g.default_due_offset_days*864e5).toISOString().split("T")[0]:null,sort_order:v,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 Vfs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Hfs({open:t,onOpenChange:s,dealId:r,dealName:n,fromStageName:a,toStageName:o,toStageId:l,onConfirm:i}){const{data:d,isLoading:u}=Dfs(t?r:void 0),p=zfs(),g=Ufs(),[v,_]=S.useState(new Set),[b,j]=S.useState(!1),w=(d||[]).filter(I=>I.status!=="done");S.useEffect(()=>{w.length>0&&_(new Set(w.map(I=>I.id)))},[d]);const N=I=>{_(L=>{const R=new Set(L);return R.has(I)?R.delete(I):R.add(I),R})},C=async()=>{j(!0);try{const I=Array.from(v);I.length>0&&await p.mutateAsync(I),await i(),await g.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{j(!1)}},A=async()=>{j(!0);try{await i(),await g.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{j(!1)}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-[480px]",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(at,{variant:"outline",className:"text-sm",children:a}),e.jsx(Ui,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(at,{className:"text-sm bg-primary",children:o})]}),u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(As,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):w.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:w.length})," incomplete task",w.length!==1?"s":"",". Select which to mark as done:"]}),e.jsx(Fi,{className:"max-h-[250px]",children:e.jsx("div",{className:"space-y-1",children:w.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(zo,{checked:v.has(I.id),onCheckedChange:()=>N(I.id)}),e.jsxs("span",{className:"text-sm flex-1",children:[Vfs[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:()=>{v.size===w.length?_(new Set):_(new Set(w.map(I=>I.id)))},children:v.size===w.length?"Deselect All":"Select All"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:A,disabled:b,children:"Skip"}),e.jsxs(K,{size:"sm",onClick:C,disabled:b,children:[b&&e.jsx(As,{className:"h-4 w-4 mr-1 animate-spin"}),v.size>0?`Complete ${v.size} & Move`:"Move Deal"]})]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"text-center py-4",children:[e.jsx(la,{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:C,disabled:b,children:[b&&e.jsx(As,{className:"h-4 w-4 mr-1 animate-spin"}),"Move to ",o]})]})]})]})})}function Wfs(){const t=si();return Ct({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 Gfs({dealId:t,dealName:s,contactName:r,portal:n,onSettingsOpen:a,onComposerOpen:o,onInviteOpen:l,onDeleteConfirm:i}){const d=bwe(),u=ZL(),p=lBt(),g=cBt(),[v,_]=S.useState(!1),b=!!(n!=null&&n.archived_at),j=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)}},w=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")}},N=()=>{n&&(navigator.clipboard.writeText(R0(n.slug)),fe.success("Link copied!"))},C=()=>{n&&window.open(R0(n.slug),"_blank")},A=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 g.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(at,{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(WE,{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(at,{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:N,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:C,title:"Preview",children:e.jsx(rn,{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(Ta,{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(x5,{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(Fl,{className:"h-3.5 w-3.5"})}),e.jsxs(yu,{children:[e.jsx(vu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(ef,{className:"h-3.5 w-3.5"})})}),e.jsx(Wd,{align:"end",children:e.jsxs(Da,{onClick:A,children:[e.jsx(r5,{className:"h-4 w-4 mr-2"}),"Archive Portal"]})})]}),e.jsx(Br,{checked:n.is_enabled,onCheckedChange:w,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:j,disabled:v,className:"shrink-0 ml-4",children:[v?e.jsx(As,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx(mn,{className:"h-3 w-3 mr-1"}),"Enable Portal"]})]})}function Kfs(){const{data:t,isLoading:s}=Cce(),{data:r,isLoading:n}=Wfs(),[a,o]=S.useState(""),[l,i]=S.useState("all"),d=dBt(),[u,p]=S.useState(null),[g,v]=S.useState(null),[_,b]=S.useState(null),[j,w]=S.useState(null),N=si(),C=s||n,A=new Map;r==null||r.forEach(V=>A.set(V.deal_id,V));const L=[...(t||[]).filter(V=>{var de,ie,ae,le,pe;const X=A.get(V.id),se=a.toLowerCase(),te=!se||V.deal_name.toLowerCase().includes(se)||((ie=(de=V.contact)==null?void 0:de.first_name)==null?void 0:ie.toLowerCase().includes(se))||((le=(ae=V.contact)==null?void 0:ae.last_name)==null?void 0:le.toLowerCase().includes(se))||((pe=X==null?void 0:X.client_name)==null?void 0:pe.toLowerCase().includes(se));let Y=!0;return l==="active"?Y=!!(X!=null&&X.is_enabled)&&!(X!=null&&X.archived_at):l==="disabled"?Y=!!X&&!X.is_enabled&&!X.archived_at:l==="archived"?Y=!!(X!=null&&X.archived_at):l==="none"?Y=!X:l==="all"&&(Y=!(X!=null&&X.archived_at)||!X),te&&Y})].sort((V,X)=>{const se=A.get(V.id),te=A.get(X.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(V=>!V.archived_at).length)||0,$=(r==null?void 0:r.filter(V=>V.is_enabled&&!V.archived_at).length)||0,q=(r==null?void 0:r.filter(V=>V.archived_at).length)||0,U=async()=>{if(j)try{await d.mutateAsync({id:j.id,dealId:j.deal_id}),fe.success("Portal permanently deleted"),w(null)}catch{fe.error("Failed to delete portal")}};return C?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(As,{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(mn,{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(xn,{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:V=>o(V.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(V=>e.jsx(K,{variant:l===V?"secondary":"ghost",size:"sm",onClick:()=>i(V),className:"text-xs px-3 capitalize",children:V==="none"?"No Portal":V},V))})]}),e.jsx(Fi,{className:"h-[calc(100vh-22rem)]",children:e.jsxs("div",{className:"space-y-2 pb-4",children:[L.map(V=>{const X=A.get(V.id)||null,se=V.contact?`${V.contact.first_name||""} ${V.contact.last_name||""}`.trim():"";return e.jsx(Gfs,{dealId:V.id,dealName:V.deal_name,contactName:se,portal:X,onSettingsOpen:p,onComposerOpen:te=>v(te),onInviteOpen:(te,Y)=>b({portal:te,dealName:Y}),onDeleteConfirm:w},V.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(mn,{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(jJe,{open:!!u,onOpenChange:V=>!V&&p(null),portal:u,dealOwnerId:N||""}),g&&e.jsx(kJe,{open:!!g,onOpenChange:V=>!V&&v(null),portalId:g.id,portalSlug:g.slug,notifyClient:g.notify_client}),_&&e.jsx(NJe,{open:!!_,onOpenChange:V=>!V&&b(null),portal:_.portal,dealName:_.dealName}),e.jsx(tc,{open:!!j,onOpenChange:V=>!V&&w(null),children:e.jsxs(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Permanently delete this portal?"}),e.jsx(Il,{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(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:U,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Permanently"})]})]})})]})}class Zfs extends S.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(Ms,{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 Yfs(){var ls;const t=AM(),{data:s,isLoading:r}=Sce(),{data:n,isLoading:a,refetch:o}=Cce(),{data:l,isLoading:i}=bps(),d=fJe(),u=pps(),[p,g]=S.useState("board"),[v,_]=S.useState(!1),[b,j]=S.useState(!1),[w,N]=S.useState(null),[C,A]=S.useState(null),[I,L]=S.useState(null),[R,$]=S.useState(null),[q,U]=S.useState(!1),[V,X]=S.useState(null),[se,te]=S.useState(""),[Y,de]=S.useState("all"),[ie,ae]=S.useState(!1),[le,pe]=S.useState(!1),[be,ye]=S.useState(new Set),[we,Ne]=S.useState(null),{data:Ke}=Mf(),{isTeamLeader:_e,teamMembers:Me}=afs(),Te=S.useMemo(()=>Array.from(be),[be]),{data:Fe}=ifs(Te),Ae=S.useMemo(()=>{const Kt=new Map;return Me.forEach(Qt=>Kt.set(Qt.id,{name:Qt.name,avatar_url:Qt.avatar_url,color:Qt.color})),Kt},[Me]),Ue=S.useCallback(Kt=>Kt.owner_user_id&&Ae.get(Kt.owner_user_id)||null,[Ae]),ut=S.useCallback(Kt=>{ye(Qt=>{const fs=new Set(Qt);return fs.has(Kt)?fs.delete(Kt):fs.add(Kt),fs})},[]);S.useEffect(()=>{!r&&s&&s.length===0&&d.mutate()},[r,s]);const[De,Dt]=Ac(),he=S.useRef(!1);S.useEffect(()=>{const Kt=De.get("deal");if(Kt&&n&&n.length>0&&!he.current){const Qt=n.find(fs=>fs.id===Kt);Qt&&(he.current=!0,N(Qt),j(!0),De.delete("deal"),Dt(De,{replace:!0}))}},[n,De]);const Ve=S.useMemo(()=>{if(!Fe||!s)return[];const Kt=new Map(s.map(Qt=>[Qt.name,Qt.id]));return Fe.map(Qt=>{const fs=Qt._stage_name&&Kt.get(Qt._stage_name)||null;return{...Qt,stage_id:fs||Qt.stage_id}})},[Fe,s]),nt=S.useMemo(()=>[...n||[],...Ve],[n,Ve]),Qe=nt.filter(Kt=>{var bt,ks,ir,Rr,ca,ii;const Qt=se.toLowerCase(),fs=!Qt||Kt.deal_name.toLowerCase().includes(Qt)||((ks=(bt=Kt.contact)==null?void 0:bt.first_name)==null?void 0:ks.toLowerCase().includes(Qt))||((Rr=(ir=Kt.contact)==null?void 0:ir.last_name)==null?void 0:Rr.toLowerCase().includes(Qt))||((ca=Kt.property_address)==null?void 0:ca.toLowerCase().includes(Qt))||((ii=Kt.city)==null?void 0:ii.toLowerCase().includes(Qt)),dr=Y==="all"||Kt.deal_type===Y;return fs&&dr}),ke=S.useMemo(()=>{if(!s)return l||null;const Kt=new Set(s.filter(bt=>bt.is_won_stage).map(bt=>bt.id)),Qt=new Set(s.filter(bt=>bt.is_lost_stage).map(bt=>bt.id)),fs=nt.filter(bt=>!Kt.has(bt.stage_id)&&!Qt.has(bt.stage_id)),dr=nt.filter(bt=>Kt.has(bt.stage_id));return{totalDeals:nt.length,activeDeals:fs.length,wonDeals:dr.length,pipelineValue:fs.reduce((bt,ks)=>bt+(ks.expected_price||0),0),expectedCommission:fs.reduce((bt,ks)=>bt+(ks.expected_commission||0),0),expectedNetToAgent:fs.reduce((bt,ks)=>{const ir=ks.expected_commission||0;if(!ir)return bt;let Rr=ir;return ks.brokerage_split_pct&&(Rr-=ir*(ks.brokerage_split_pct/100)),ks.team_split_pct&&(Rr-=ir*(ks.team_split_pct/100)),ks.franchise_fee_pct&&(Rr-=ir*(ks.franchise_fee_pct/100)),ks.referral_fee_pct&&(Rr-=ir*(ks.referral_fee_pct/100)),ks.transaction_fee&&(Rr-=ks.transaction_fee),bt+Math.max(0,Rr)},0),wonValue:dr.reduce((bt,ks)=>bt+(ks.expected_price||0),0)}},[nt,s,l]),ot=Kt=>{N(Kt),j(!0)},qe=Kt=>{A(Kt||null),N(null),_(!0)},lt=Kt=>{N(Kt),j(!1),_(!0)},We=(Kt,Qt)=>{L(Kt)},Ye=(Kt,Qt)=>{Kt.preventDefault(),Kt.dataTransfer.dropEffect="move",$(Qt)},mt=async(Kt,Qt)=>{if(Kt.preventDefault(),$(null),!I)return;const fs=n==null?void 0:n.find(ks=>ks.id===I),dr=s==null?void 0:s.find(ks=>ks.id===Qt),bt=s==null?void 0:s.find(ks=>ks.id===(fs==null?void 0:fs.stage_id));if(!fs||!dr||fs.stage_id===Qt){L(null);return}Ne({dealId:I,dealName:fs.deal_name,fromStageName:(bt==null?void 0:bt.name)||"Unknown",toStageName:dr.name,toStageId:Qt,isWonStage:dr.is_won_stage,deal:fs}),L(null)},Ze=async()=>{if(!we)return;const{dealId:Kt,toStageId:Qt,toStageName:fs,isWonStage:dr,deal:bt}=we;if(await u.mutateAsync({dealId:Kt,stageId:Qt,stageName:fs}),fe.success(`Moved to ${fs}`),dr&&!bt.scorecard_transaction_id){const ks={...bt,stage_id:Qt};X(ks),U(!0)}},He=S.useCallback(async(Kt,Qt,fs)=>{const dr=n==null?void 0:n.find(ir=>ir.id===Kt),bt=s==null?void 0:s.find(ir=>ir.id===Qt),ks=s==null?void 0:s.find(ir=>ir.id===(dr==null?void 0:dr.stage_id));!dr||!bt||dr.stage_id===Qt||Ne({dealId:Kt,dealName:dr.deal_name,fromStageName:(ks==null?void 0:ks.name)||"Unknown",toStageName:fs,toStageId:Qt,isWonStage:bt.is_won_stage,deal:dr})},[n,s]),et=Kt=>Qe.filter(Qt=>Qt.stage_id===Kt),Rt=r||a,qt=t?"list":p;return e.jsxs(Ms,{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(Eo,{className:"h-4 w-4"})}),!t&&e.jsx(YN,{children:e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsxs(K,{variant:p==="board"?"secondary":"ghost",size:"sm",onClick:()=>g("board"),className:"px-3 gap-1.5",children:[e.jsx(pp,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Board"})]})}),e.jsx(Hc,{children:"Kanban board view"})]}),e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsxs(K,{variant:p==="list"?"secondary":"ghost",size:"sm",onClick:()=>g("list"),className:"px-3 gap-1.5",children:[e.jsx(qh,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"List"})]})}),e.jsx(Hc,{children:"Grouped list view"})]}),e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsxs(K,{variant:p==="table"?"secondary":"ghost",size:"sm",onClick:()=>g("table"),className:"px-3 gap-1.5",children:[e.jsx(b5,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Table"})]})}),e.jsx(Hc,{children:"Sortable table view"})]}),e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsxs(K,{variant:p==="portals"?"secondary":"ghost",size:"sm",onClick:()=>g("portals"),className:"px-3 gap-1.5",children:[e.jsx(mn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Portals"})]})}),e.jsx(Hc,{children:"Client portal management"})]})]})}),Ke&&!_e&&e.jsxs(K,{variant:"outline",onClick:()=>ae(!0),children:[e.jsx(hr,{className:"h-4 w-4 mr-2"}),"Team"]}),e.jsxs(K,{onClick:()=>qe(),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})]})]}),qt!=="portals"&&e.jsx(dfs,{stats:ke,isLoading:i}),qt!=="portals"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(xn,{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:Kt=>te(Kt.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(tr,{value:Y,onValueChange:de,children:[e.jsx(Js,{className:"w-[140px]",children:e.jsx(sr,{placeholder:"All Types"})}),e.jsxs(er,{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||Y!=="all")&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[Qe.length," of ",(n==null?void 0:n.length)||0," deals"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[_e&&!t&&Me.length>0&&e.jsx(nfs,{members:Me,enabledMembers:be,onToggleMember:ut,isOpen:le,onToggleOpen:()=>pe(Kt=>!Kt)}),e.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-4 md:p-6 pt-4",children:Rt?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(Kt=>e.jsx("div",{className:"min-w-[280px] max-w-[320px] flex-shrink-0",children:e.jsx(gs,{className:"h-full rounded-xl"})},Kt))}):qt==="board"?e.jsxs(Fi,{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(Kt=>e.jsx(cfs,{stage:Kt,deals:et(Kt.id),onDealClick:ot,onAddDeal:qe,onDragStart:We,onDragOver:Ye,onDrop:mt,isDragOver:R===Kt.id,isWonStage:Kt.is_won_stage,getOwnerInfo:Ue},Kt.id))}),e.jsx(Poe,{orientation:"horizontal"})]}):qt==="table"?e.jsx(Fi,{className:"h-full",children:e.jsx(Ifs,{deals:Qe,stages:s||[],onDealClick:ot,onStageChange:He})}):qt==="portals"?e.jsx(Kfs,{}):e.jsx(Fi,{className:"h-full",children:e.jsxs("div",{className:"space-y-6",children:[s==null?void 0:s.map(Kt=>{const Qt=et(Kt.id);return Qt.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:Kt.color}}),e.jsx("h3",{className:"font-semibold",children:Kt.name}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",Qt.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:Qt.map(fs=>e.jsx(wJe,{deal:fs,onClick:()=>ot(fs),stages:s,onStageChange:He,showStagePicker:!0,isWonStage:Kt.is_won_stage,ownerInfo:Ue(fs)},fs.id))})]},Kt.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(pp,{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:()=>qe(),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Your First Deal"]})]}),((n==null?void 0:n.length)||0)>0&&Qe.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(xn,{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(pfs,{open:v,onOpenChange:_,deal:w,defaultStageId:C}),e.jsx(Afs,{deal:w,open:b,onOpenChange:j,onEdit:lt,isWonStage:w?(ls=s==null?void 0:s.find(Kt=>Kt.id===w.stage_id))==null?void 0:ls.is_won_stage:!1,onAddToScorecard:Kt=>{X(Kt),U(!0),j(!1)}}),e.jsx(Efs,{open:q,onOpenChange:U,deal:V,onComplete:()=>{o(),X(null)}}),we&&e.jsx(Hfs,{open:!!we,onOpenChange:Kt=>{Kt||Ne(null)},dealId:we.dealId,dealName:we.dealName,fromStageName:we.fromStageName,toStageName:we.toStageName,toStageId:we.toStageId,onConfirm:Ze}),e.jsx(sfs,{open:ie,onOpenChange:ae})]})}function Xfs(){return e.jsx(Zfs,{children:e.jsx(Yfs,{})})}function SJe({open:t,onOpenChange:s,editTask:r,defaultDealId:n,defaultStageId:a}){var te;const o=Ofs(),l=Rfs(),{data:i}=Cce(),d=si(),{data:u}=Ct({queryKey:["contacts-for-tasks",d],queryFn:async()=>{if(!d)return[];const{data:Y,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 Y},enabled:!!d&&t}),[p,g]=S.useState(""),[v,_]=S.useState(""),[b,j]=S.useState("none"),[w,N]=S.useState("none"),[C,A]=S.useState("medium"),[I,L]=S.useState("todo"),[R,$]=S.useState(),[q,U]=S.useState(!1),[V,X]=S.useState(!1);S.useEffect(()=>{r?(g(r.title),_(r.description||""),j(r.deal_id||"none"),N(r.contact_id||"none"),A(r.priority),L(r.status),$(r.due_date?Th(r.due_date):void 0)):(g(""),_(""),j(n||"none"),N("none"),A("medium"),L("todo"),$(void 0))},[r,t,n]);const se=async()=>{if(!p.trim()){fe.error("Task title is required");return}try{const Y={title:p.trim(),description:v.trim()||null,deal_id:b==="none"?null:b,contact_id:w==="none"?null:w,stage_id:a||null,priority:C,status:I,due_date:R?ws(R,"yyyy-MM-dd"):null};r?(await l.mutateAsync({id:r.id,...Y}),fe.success("Task updated")):(await o.mutateAsync(Y),fe.success("Task created")),s(!1)}catch{fe.error("Failed to save task")}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-[480px]",children:[e.jsx(Cs,{children:e.jsx(Ss,{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:Y=>g(Y.target.value),placeholder:"e.g., Send inspection report"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Tr,{value:v,onChange:Y=>_(Y.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(tr,{value:C,onValueChange:Y=>A(Y),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{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(tr,{value:I,onValueChange:Y=>L(Y),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{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(No,{children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Et("w-full justify-start text-left font-normal",!R&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),R?ws(R,"PPP"):"Pick a date"]})}),e.jsx(jo,{className:"w-auto p-0",align:"start",children:e.jsx(vp,{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(No,{open:q,onOpenChange:U,children:[e.jsx(So,{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(Ca,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),b!=="none"?((te=i==null?void 0:i.find(Y=>Y.id===b))==null?void 0:te.deal_name)||"Select deal":"No Deal"]}),e.jsx(df,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search deals..."}),e.jsxs(kf,{children:[e.jsx(Nf,{children:"No deals found."}),e.jsxs(Sf,{children:[e.jsxs(jm,{value:"no-deal",onSelect:()=>{j("none"),U(!1)},children:[e.jsx(fa,{className:Et("mr-2 h-4 w-4",b==="none"?"opacity-100":"opacity-0")}),"No Deal"]}),i==null?void 0:i.map(Y=>e.jsxs(jm,{value:Y.deal_name,onSelect:()=>{j(Y.id),U(!1)},children:[e.jsx(fa,{className:Et("mr-2 h-4 w-4",b===Y.id?"opacity-100":"opacity-0")}),Y.deal_name]},Y.id))]})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Link to Contact"}),e.jsxs(No,{open:V,onOpenChange:X,children:[e.jsx(So,{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"}),w!=="none"?(()=>{const Y=u==null?void 0:u.find(de=>de.id===w);return Y?`${Y.first_name} ${Y.last_name}`:"Select contact"})():"No Contact"]}),e.jsx(df,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(wf,{children:[e.jsx(jf,{placeholder:"Search contacts..."}),e.jsxs(kf,{children:[e.jsx(Nf,{children:"No contacts found."}),e.jsxs(Sf,{children:[e.jsxs(jm,{value:"no-contact",onSelect:()=>{N("none"),X(!1)},children:[e.jsx(fa,{className:Et("mr-2 h-4 w-4",w==="none"?"opacity-100":"opacity-0")}),"No Contact"]}),u==null?void 0:u.map(Y=>e.jsxs(jm,{value:`${Y.first_name} ${Y.last_name}`,onSelect:()=>{N(Y.id),X(!1)},children:[e.jsx(fa,{className:Et("mr-2 h-4 w-4",w===Y.id?"opacity-100":"opacity-0")}),Y.first_name," ",Y.last_name]},Y.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 Qfs={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 Jfs({tasks:t}){const s=D2e(),r=Ffs(),n=Lr(),[a,o]=S.useState(null),l=async p=>{const g=p.status==="done"?"todo":"done";try{await s.mutateAsync({id:p.id,status:g})}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(la,{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 g=d.get(p.deal.id)||{dealName:p.deal.deal_name,tasks:[]};g.tasks.push(p),d.set(p.deal.id,g)}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(MLe,{task:p,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:g=>n(`/mission-control/pipeline?deal=${g}`)},p.id))]}),Array.from(d.entries()).map(([p,g])=>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(Ca,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("h3",{className:"font-medium text-sm",children:g.dealName}),e.jsxs(at,{variant:"secondary",className:"ml-auto text-xs",children:[g.tasks.filter(v=>v.status==="done").length,"/",g.tasks.length]}),e.jsx(qa,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),g.tasks.map(v=>e.jsx(MLe,{task:v,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:_=>n(`/mission-control/pipeline?deal=${_}`)},v.id))]},p)),a&&e.jsx(SJe,{open:!!a,onOpenChange:()=>o(null),editTask:a})]})}function MLe({task:t,onToggle:s,onDelete:r,onEdit:n,onNavigateDeal:a}){const o=t.status==="done",l=!o&&t.due_date&&Yx(Th(t.due_date))&&!zd(Th(t.due_date)),i=!o&&t.due_date&&zd(Th(t.due_date)),d=Qfs[t.priority];return e.jsxs("div",{className:Et("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(la,{className:"h-5 w-5 text-emerald-500"}):e.jsx(Wc,{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:Et("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(at,{variant:"outline",className:Et("text-[10px] shrink-0",d.color),children:[d.dot," ",d.label]}),t.due_date&&e.jsxs("span",{className:Et("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(In,{className:"h-3 w-3"}),ws(Th(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(Dc,{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 egs=[{status:"todo",label:"To Do",icon:Wc,color:"border-t-slate-400"},{status:"in_progress",label:"In Progress",icon:gm,color:"border-t-blue-500"},{status:"done",label:"Done",icon:la,color:"border-t-emerald-500"}],tgs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function sgs({tasks:t}){const s=D2e(),r=S.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:egs.map(o=>e.jsxs("div",{className:Et("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(at,{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(rgs,{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 rgs({task:t,onDragStart:s}){const r=t.status==="done",n=!r&&t.due_date&&Yx(Th(t.due_date))&&!zd(Th(t.due_date)),a=!r&&t.due_date&&zd(Th(t.due_date));return e.jsx("div",{draggable:!0,onDragStart:o=>s(o,t.id),className:Et("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:tgs[t.priority]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:Et("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(Ca,{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:Et("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(In,{className:"h-2.5 w-2.5"}),n?"Overdue — ":a?"Due today — ":"",ws(Th(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 TLe={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function ngs({tasks:t}){const[s,r]=S.useState(new Date),n=D2e(),a=uc(s),o=Kp(s),l=ah(a),i=Coe(o),d=hvt({start:l,end:i}),u=S.useMemo(()=>{const v=new Map;return t.forEach(_=>{if(!_.due_date)return;const b=_.due_date,j=v.get(b)||[];j.push(_),v.set(b,j)}),v},[t]),p=S.useMemo(()=>t.filter(v=>!v.due_date),[t]),g=async v=>{const _=v.status==="done"?"todo":"done";try{await n.mutateAsync({id:v.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(Sk(s,1)),children:e.jsx(Ol,{className:"h-4 w-4"})}),e.jsx("h3",{className:"font-semibold",children:ws(s,"MMMM yyyy")}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>r(Vh(s,1)),children:e.jsx(qa,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"grid grid-cols-7 text-center",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(v=>e.jsx("div",{className:"text-xs font-medium text-muted-foreground py-2",children:v},v))}),e.jsx("div",{className:"grid grid-cols-7 border-l border-t",children:d.map(v=>{const _=ws(v,"yyyy-MM-dd"),b=u.get(_)||[],j=Toe(v,s),w=zd(v);return e.jsxs("div",{className:Et("border-r border-b min-h-[100px] p-1",!j&&"bg-muted/30",w&&"bg-primary/5"),children:[e.jsx("div",{className:Et("text-xs font-medium mb-1 text-right px-1",!j&&"text-muted-foreground/40",w&&"text-primary font-bold"),children:ws(v,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[b.slice(0,3).map(N=>e.jsxs("button",{onClick:()=>g(N),className:Et("w-full text-left text-[10px] px-1 py-0.5 rounded truncate flex items-center gap-0.5 hover:bg-muted transition-colors",N.status==="done"?"text-muted-foreground line-through":"text-foreground"),children:[N.status==="done"?e.jsx(la,{className:"h-2.5 w-2.5 text-emerald-500 shrink-0"}):e.jsx(Wc,{className:"h-2.5 w-2.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[TLe[N.priority]," ",N.title]})]},N.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(v=>e.jsxs("button",{onClick:()=>g(v),className:Et("w-full text-left text-xs px-2 py-1.5 rounded flex items-center gap-2 hover:bg-muted transition-colors",v.status==="done"&&"opacity-50 line-through"),children:[v.status==="done"?e.jsx(la,{className:"h-3.5 w-3.5 text-emerald-500 shrink-0"}):e.jsx(Wc,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[TLe[v.priority]," ",v.title]}),v.deal&&e.jsxs("span",{className:"text-muted-foreground ml-auto shrink-0",children:["• ",v.deal.deal_name]})]},v.id))})]})]})}const ags={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function igs({open:t,onOpenChange:s,stages:r}){var N;const[n,a]=S.useState(((N=r[0])==null?void 0:N.id)||""),{data:o,isLoading:l}=Bfs(n||void 0),i=$fs(),d=qfs(),[u,p]=S.useState(""),[g,v]=S.useState("medium"),[_,b]=S.useState(""),j=async()=>{if(!(!u.trim()||!n))try{await i.mutateAsync({stage_id:n,title:u.trim(),priority:g,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")}},w=async C=>{try{await d.mutateAsync(C),fe.success("Template deleted")}catch{fe.error("Failed to delete template")}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-[560px]",children:[e.jsx(Cs,{children:e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(tP,{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(C=>!C.is_won_stage&&!C.is_lost_stage).map(C=>e.jsx("button",{onClick:()=>a(C.id),className:Et("px-3 py-1.5 rounded-full text-xs font-medium border transition-colors",n===C.id?"border-primary bg-primary/10 text-primary":"border-border hover:bg-muted"),children:C.name},C.id))})]}),e.jsx(Fi,{className:"max-h-[250px]",children:e.jsxs("div",{className:"space-y-1.5",children:[o==null?void 0:o.map((C,A)=>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:ags[C.priority]}),e.jsx("span",{className:"text-sm flex-1 truncate",children:C.title}),C.default_due_offset_days&&e.jsxs(at,{variant:"outline",className:"text-[10px]",children:["+",C.default_due_offset_days,"d"]}),e.jsx("button",{onClick:()=>w(C.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"})})]},C.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:C=>p(C.target.value),className:"flex-1",onKeyDown:C=>C.key==="Enter"&&j()}),e.jsxs(tr,{value:g,onValueChange:C=>v(C),children:[e.jsx(Js,{className:"w-[100px]",children:e.jsx(sr,{})}),e.jsxs(er,{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:C=>b(C.target.value)})]}),e.jsxs(K,{onClick:j,disabled:!u.trim()||i.isPending,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})})}function ogs(){const{data:t,isLoading:s}=Lfs(),{data:r}=Sce(),[n,a]=S.useState("list"),[o,l]=S.useState(""),[i,d]=S.useState("active"),[u,p]=S.useState("all"),[g,v]=S.useState("all"),[_,b]=S.useState(!1),[j,w]=S.useState(!1),N=S.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]),C=S.useMemo(()=>t?t.filter(I=>{var V,X,se,te;const L=o.toLowerCase(),R=!L||I.title.toLowerCase().includes(L)||((X=(V=I.deal)==null?void 0:V.deal_name)==null?void 0:X.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&&Yx(Th(I.due_date))&&!zd(Th(I.due_date)),q=u==="all"||I.priority===u,U=g==="all"||g==="no_deal"&&!I.deal_id||I.deal_id===g;return R&&$&&q&&U}):[],[t,o,i,u,g]),A=S.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&&Yx(Th(L.due_date))&&!zd(Th(L.due_date))).length,dueToday:I.filter(L=>L.due_date&&zd(Th(L.due_date))).length,dueThisWeek:I.filter(L=>L.due_date&&l_t(Th(L.due_date))).length,completed:t.filter(L=>L.status==="done").length}},[t]);return e.jsx(Ms,{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:()=>w(!0),children:[e.jsx(Ux,{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(qh,{className:"h-3.5 w-3.5"}),"Active"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:A.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(Mh,{className:"h-3.5 w-3.5"}),"Overdue"]}),e.jsx("p",{className:"text-xl font-bold mt-1 text-destructive",children:A.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(In,{className:"h-3.5 w-3.5"}),"Due Today"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:A.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(kc,{className:"h-3.5 w-3.5"}),"This Week"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:A.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(la,{className:"h-3.5 w-3.5"}),"Completed"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:A.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(xn,{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(tr,{value:u,onValueChange:p,children:[e.jsx(Js,{className:"w-[130px]",children:e.jsx(sr,{placeholder:"Priority"})}),e.jsxs(er,{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(tr,{value:g,onValueChange:v,children:[e.jsx(Js,{className:"w-[160px]",children:e.jsx(sr,{placeholder:"Deal"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Deals"}),e.jsx(At,{value:"no_deal",children:"No Deal"}),N.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(qh,{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(Vx,{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(kc,{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(Jfs,{tasks:C}),n==="kanban"&&e.jsx(sgs,{tasks:C}),n==="calendar"&&e.jsx(ngs,{tasks:C})]}),e.jsx(SJe,{open:_,onOpenChange:b}),e.jsx(igs,{open:j,onOpenChange:w,stages:r||[]})]})})}const $0e=[{value:"video_intro",label:"Video Intro",icon:Nn,description:"Add an intro video"},{value:"testimonials",label:"Testimonials",icon:pP,description:"Client testimonials carousel"},{value:"specialties",label:"Specialties",icon:Im,description:"Tags for your specialties"},{value:"custom_links",label:"Custom Links",icon:Ho,description:"Custom CTA buttons"},{value:"social_media",label:"Social Media",icon:ld,description:"Links to your social profiles"}],lgs=["First-Time Buyers","Luxury Homes","Investment Properties","Relocation","New Construction","Condos & Townhomes","Waterfront","Commercial","Land & Lots","Senior Living","Military/VA","Short Sales & Foreclosures"],cgs={video_intro:{video_url:""},testimonials:{testimonials:[{name:"",quote:"",role:""}]},specialties:{tags:[]},custom_links:{links:[{label:"",url:""}]},social_media:{platforms:[]}};function CJe({cardId:t}){const{data:s,isLoading:r}=o0t(t),n=l0t(),a=c0t(),o=d0t(),[l,i]=S.useState(!1),[d,u]=S.useState(""),[p,g]=S.useState(null);if(r)return e.jsxs("div",{className:"space-y-3",children:[e.jsx(gs,{className:"h-16 w-full"}),e.jsx(gs,{className:"h-16 w-full"})]});const v=()=>{d&&n.mutate({card_id:t,block_type:d,sort_order:(s==null?void 0:s.length)||0,config:cgs[d]||{}},{onSuccess:()=>{i(!1),u("")}})},_=C=>{a.mutate({id:C.id,is_visible:!C.is_visible})},b=(C,A)=>{if(!s)return;const I=s.findIndex($=>$.id===C.id),L=A==="up"?I-1:I+1;if(L<0||L>=s.length)return;const R=s[L];a.mutate({id:C.id,sort_order:R.sort_order}),a.mutate({id:R.id,sort_order:C.sort_order})},j=C=>{confirm("Remove this block from this card?")&&o.mutate(C.id)},w=(C,A)=>{a.mutate({id:C.id,config:A},{onSuccess:()=>g(null)})},N=C=>$0e.find(A=>A.value===C);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((C,A)=>{const I=N(C.block_type),L=(I==null?void 0:I.icon)||Im;return e.jsx(Ee,{className:C.is_visible?"":"opacity-50",children:e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ru,{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)||C.block_type}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:dgs(C)})]}),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(C,"up"),disabled:A===0,children:e.jsx(qd,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(C,"down"),disabled:A===s.length-1,children:e.jsx(Ju,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(C),children:C.is_visible?e.jsx(ya,{className:"h-3 w-3"}):e.jsx(Tm,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>g(C),children:"Edit"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>j(C),children:e.jsx(jr,{className:"h-3 w-3"})})]})]})})},C.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(vs,{open:l,onOpenChange:i,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Add Block"})}),e.jsx("div",{className:"grid gap-3",children:$0e.map(C=>{const A=C.icon;return e.jsxs("button",{onClick:()=>u(C.value),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors ${d===C.value?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[e.jsx(A,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:C.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.description})]})]},C.value)})}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{onClick:v,disabled:!d||n.isPending,children:"Add Block"})]})]})}),p&&e.jsx(ugs,{block:p,onSave:C=>w(p,C),onClose:()=>g(null)})]})}function dgs(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 ugs({block:t,onSave:s,onClose:r}){const[n,a]=S.useState(t.config),o=$0e.find(l=>l.value===t.block_type);return e.jsx(vs,{open:!0,onOpenChange:r,children:e.jsxs(ys,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:["Edit ",o==null?void 0:o.label]})}),t.block_type==="video_intro"&&e.jsx(hgs,{config:n,onChange:a,cardId:t.card_id}),t.block_type==="testimonials"&&e.jsx(mgs,{config:n,onChange:a}),t.block_type==="specialties"&&e.jsx(pgs,{config:n,onChange:a}),t.block_type==="custom_links"&&e.jsx(fgs,{config:n,onChange:a}),t.block_type==="social_media"&&e.jsx(ggs,{config:n,onChange:a}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(K,{onClick:()=>s(n),children:"Save"})]})]})})}function hgs({config:t,onChange:s,cardId:r}){var _,b;const[n,a]=S.useState(""),[o,l]=S.useState((_=t.video_url)!=null&&_.includes("youtube")||(b=t.video_url)!=null&&b.includes("youtu.be")?"youtube":"library"),{data:i}=Ct({queryKey:["card-owner",r],queryFn:async()=>{const{data:j}=await G.from("agent_cards").select("user_id").eq("id",r).single();return j==null?void 0:j.user_id},enabled:!!r}),{data:d,isLoading:u}=Ct({queryKey:["agent-videos-library",i],queryFn:async()=>{const{data:j,error:w}=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(w)throw w;return j||[]},enabled:!!i}),p=(d==null?void 0:d.filter(j=>!n||(j.title||"").toLowerCase().includes(n.toLowerCase())))||[],g=t.bunny_video_id,v=j=>{var A;const w=(A=j.playback_url)==null?void 0:A.match(/\/(?:play|embed)\/(\d+)\//),C=`https://iframe.mediadelivery.net/embed/${w?w[1]:"570924"}/${j.bunny_video_id}?autoplay=false&responsive=true`;s({...t,video_url:C,bunny_video_id:j.bunny_video_id,video_source:"library"})};return e.jsx("div",{className:"space-y-4",children:e.jsxs(ja,{value:o,onValueChange:l,children:[e.jsxs(va,{className:"w-full",children:[e.jsx(Ns,{value:"library",className:"flex-1",children:"Video Library"}),e.jsx(Ns,{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(xn,{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:j=>a(j.target.value),className:"pl-9"})]}),e.jsx(Fi,{className:"h-[240px]",children:u?e.jsxs("div",{className:"space-y-2",children:[e.jsx(gs,{className:"h-14 w-full"}),e.jsx(gs,{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(j=>e.jsxs("button",{onClick:()=>v(j),className:`w-full flex items-center gap-3 p-2 rounded-lg border text-left transition-colors ${g===j.bunny_video_id?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[j.thumbnail_url?e.jsx("img",{src:j.thumbnail_url,alt:"",className:"h-10 w-16 rounded object-cover flex-shrink-0 bg-muted",onError:w=>{var N;w.currentTarget.style.display="none",(N=w.currentTarget.nextElementSibling)==null||N.classList.remove("hidden")}}):null,e.jsx("div",{className:`h-10 w-16 rounded bg-muted flex items-center justify-center flex-shrink-0 ${j.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:j.title||"Untitled Video"}),g===j.bunny_video_id&&e.jsx(fa,{className:"h-4 w-4 text-primary flex-shrink-0"})]},j.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:j=>s({...t,video_url:j.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 mgs({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 pgs({config:t,onChange:s}){const r=t.tags||[],[n,a]=S.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:lgs.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 fgs({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 ALe=[{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 ggs({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=ALe.filter(d=>!r.find(u=>u.platform===d.value)),i=d=>{const u=Mge[d],p=ALe.find(g=>g.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:g=>a(u,g.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=Mge[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 xgs=Object.defineProperty,Aie=Object.getOwnPropertySymbols,MJe=Object.prototype.hasOwnProperty,TJe=Object.prototype.propertyIsEnumerable,ELe=(t,s,r)=>s in t?xgs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,q0e=(t,s)=>{for(var r in s||(s={}))MJe.call(s,r)&&ELe(t,r,s[r]);if(Aie)for(var r of Aie(s))TJe.call(s,r)&&ELe(t,r,s[r]);return t},U0e=(t,s)=>{var r={};for(var n in t)MJe.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&Aie)for(var n of Aie(t))s.indexOf(n)<0&&TJe.call(t,n)&&(r[n]=t[n]);return r};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var WN;(t=>{const s=class ro{constructor(d,u,p,g){if(this.version=d,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],dro.MAX_VERSION)throw new RangeError("Version value out of range");if(g<-1||g>7)throw new RangeError("Mask value out of range");this.size=d*4+17;let v=[];for(let b=0;b7)throw new RangeError("Invalid value");let b,j;for(b=p;;b++){const A=ro.getNumDataCodewords(b,u)*8,I=l.getTotalBits(d,b);if(I<=A){j=I;break}if(b>=g)throw new RangeError("Data too long")}for(const A of[ro.Ecc.MEDIUM,ro.Ecc.QUARTILE,ro.Ecc.HIGH])_&&j<=ro.getNumDataCodewords(b,A)*8&&(u=A);let w=[];for(const A of d){r(A.mode.modeBits,4,w),r(A.numChars,A.mode.numCharCountBits(b),w);for(const I of A.getData())w.push(I)}a(w.length==j);const N=ro.getNumDataCodewords(b,u)*8;a(w.length<=N),r(0,Math.min(4,N-w.length),w),r(0,(8-w.length%8)%8,w),a(w.length%8==0);for(let A=236;w.lengthC[I>>>3]|=A<<7-(I&7)),new ro(b,u,C,v)}getModule(d,u){return 0<=d&&d>>9)*1335;const g=(u<<10|p)^21522;a(g>>>15==0);for(let v=0;v<=5;v++)this.setFunctionModule(8,v,n(g,v));this.setFunctionModule(8,7,n(g,6)),this.setFunctionModule(8,8,n(g,7)),this.setFunctionModule(7,8,n(g,8));for(let v=9;v<15;v++)this.setFunctionModule(14-v,8,n(g,v));for(let v=0;v<8;v++)this.setFunctionModule(this.size-1-v,8,n(g,v));for(let v=8;v<15;v++)this.setFunctionModule(8,this.size-15+v,n(g,v));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 g=n(u,p),v=this.size-11+p%3,_=Math.floor(p/3);this.setFunctionModule(v,_,g),this.setFunctionModule(_,v,g)}}drawFinderPattern(d,u){for(let p=-4;p<=4;p++)for(let g=-4;g<=4;g++){const v=Math.max(Math.abs(g),Math.abs(p)),_=d+g,b=u+p;0<=_&&_{(A!=j-v||L>=b)&&C.push(I[A])});return a(C.length==_),C}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 g=0;g>>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,j),_||(d+=this.finderPenaltyCountPatterns(j)*ro.PENALTY_N3),_=this.modules[v][w],b=1);d+=this.finderPenaltyTerminateAndCount(_,b,j)*ro.PENALTY_N3}for(let v=0;v5&&d++):(this.finderPenaltyAddHistory(b,j),_||(d+=this.finderPenaltyCountPatterns(j)*ro.PENALTY_N3),_=this.modules[w][v],b=1);d+=this.finderPenaltyTerminateAndCount(_,b,j)*ro.PENALTY_N3}for(let v=0;v_+(b?1:0),u);const p=this.size*this.size,g=Math.ceil(Math.abs(u*20-p*10)/p)-1;return a(0<=g&&g<=9),d+=g*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 g=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 g=0;g0);for(const g of d){const v=g^p.shift();p.push(0),u.forEach((_,b)=>p[b]^=ro.reedSolomonMultiply(_,v))}return p}static reedSolomonMultiply(d,u){if(d>>>8||u>>>8)throw new RangeError("Byte out of range");let p=0;for(let g=7;g>=0;g--)p=p<<1^(p>>>7)*285,p^=(u>>>g&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 Ic{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 Ic(Ic.Mode.BYTE,d.length,u)}static makeNumeric(d){if(!Ic.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={}))})(WN||(WN={}));(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={}))})(WN||(WN={}));var G4=WN;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var ygs={L:G4.QrCode.Ecc.LOW,M:G4.QrCode.Ecc.MEDIUM,Q:G4.QrCode.Ecc.QUARTILE,H:G4.QrCode.Ecc.HIGH},AJe=128,EJe="L",PJe="#FFFFFF",IJe="#000000",LJe=!1,DJe=1,vgs=4,_gs=0,bgs=.1;function OJe(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 RJe(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 wgs(t,s,r,n){if(n==null)return null;const a=t.length+r*2,o=Math.floor(s*bgs),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,g=n.opacity==null?1:n.opacity;let v=null;if(n.excavate){let b=Math.floor(u),j=Math.floor(p),w=Math.ceil(i+u-b),N=Math.ceil(d+p-j);v={x:b,y:j,w,h:N}}const _=n.crossOrigin;return{x:u,y:p,h:d,w:i,excavation:v,opacity:g,crossOrigin:_}}function jgs(t,s){return s!=null?Math.max(Math.floor(s),0):t?vgs:_gs}function FJe({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((j,w)=>(j.push(...G4.QrSegment.makeSegments(w)),j),[]);return G4.QrCode.encodeSegments(b,ygs[s],r,void 0,void 0,i)},[t,s,r,i]);const{cells:u,margin:p,numCells:g,calculatedImageSettings:v}=ht.useMemo(()=>{let _=d.getModules();const b=jgs(n,a),j=_.length+b*2,w=wgs(_,l,b,o);return{cells:_,margin:b,numCells:j,calculatedImageSettings:w}},[d,l,o,n,a]);return{qrcode:d,margin:p,cells:u,numCells:g,calculatedImageSettings:v}}var kgs=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Ngs=ht.forwardRef(function(s,r){const n=s,{value:a,size:o=AJe,level:l=EJe,bgColor:i=PJe,fgColor:d=IJe,includeMargin:u=LJe,minVersion:p=DJe,boostLevel:g,marginSize:v,imageSettings:_}=n,j=U0e(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:w}=j,N=U0e(j,["style"]),C=_==null?void 0:_.src,A=ht.useRef(null),I=ht.useRef(null),L=ht.useCallback(Y=>{A.current=Y,typeof r=="function"?r(Y):r&&(r.current=Y)},[r]),[R,$]=ht.useState(!1),{margin:q,cells:U,numCells:V,calculatedImageSettings:X}=FJe({value:a,level:l,minVersion:p,boostLevel:g,includeMargin:u,marginSize:v,imageSettings:_,size:o});ht.useEffect(()=>{if(A.current!=null){const Y=A.current,de=Y.getContext("2d");if(!de)return;let ie=U;const ae=I.current,le=X!=null&&ae!==null&&ae.complete&&ae.naturalHeight!==0&&ae.naturalWidth!==0;le&&X.excavation!=null&&(ie=RJe(U,X.excavation));const pe=window.devicePixelRatio||1;Y.height=Y.width=o*pe;const be=o/V*pe;de.scale(be,be),de.fillStyle=i,de.fillRect(0,0,V,V),de.fillStyle=d,kgs?de.fill(new Path2D(OJe(ie,q))):U.forEach(function(ye,we){ye.forEach(function(Ne,Ke){Ne&&de.fillRect(Ke+q,we+q,1,1)})}),X&&(de.globalAlpha=X.opacity),le&&de.drawImage(ae,X.x+q,X.y+q,X.w,X.h)}}),ht.useEffect(()=>{$(!1)},[C]);const se=q0e({height:o,width:o},w);let te=null;return C!=null&&(te=ht.createElement("img",{src:C,key:C,style:{display:"none"},onLoad:()=>{$(!0)},ref:I,crossOrigin:X==null?void 0:X.crossOrigin})),ht.createElement(ht.Fragment,null,ht.createElement("canvas",q0e({style:se,height:o,width:o,ref:L,role:"img"},N)),te)});Ngs.displayName="QRCodeCanvas";var nD=ht.forwardRef(function(s,r){const n=s,{value:a,size:o=AJe,level:l=EJe,bgColor:i=PJe,fgColor:d=IJe,includeMargin:u=LJe,minVersion:p=DJe,boostLevel:g,title:v,marginSize:_,imageSettings:b}=n,j=U0e(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:w,cells:N,numCells:C,calculatedImageSettings:A}=FJe({value:a,level:l,minVersion:p,boostLevel:g,includeMargin:u,marginSize:_,imageSettings:b,size:o});let I=N,L=null;b!=null&&A!=null&&(A.excavation!=null&&(I=RJe(N,A.excavation)),L=ht.createElement("image",{href:b.src,height:A.h,width:A.w,x:A.x+w,y:A.y+w,preserveAspectRatio:"none",opacity:A.opacity,crossOrigin:A.crossOrigin}));const R=OJe(I,w);return ht.createElement("svg",q0e({height:o,width:o,viewBox:`0 0 ${C} ${C}`,ref:r,role:"img"},j),!!v&&ht.createElement("title",null,v),ht.createElement("path",{fill:i,d:`M0,0 h${C}v${C}H0z`,shapeRendering:"crispEdges"}),ht.createElement("path",{fill:d,d:R,shapeRendering:"crispEdges"}),L)});nD.displayName="QRCodeSVG";function Sgs({slug:t,agentName:s}){const r=S.useRef(null),n=`https://cards.relevelup.com/${t}`,a=S.useCallback(()=>{var g;const o=(g=r.current)==null?void 0:g.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 v=document.createElement("a");v.download=`${t}-qr-code.png`,v.href=l.toDataURL("image/png"),v.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(nD,{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(gi,{className:"h-3.5 w-3.5"}),"Download PNG"]})]})]})]})}function Spe(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 Cgs(){const{user:t}=Gs(),{data:s,isLoading:r}=n0t(t==null?void 0:t.id),n=AM(),[a,o]=S.useState(null),l=S.useMemo(()=>a||(s?Spe(s):null),[a,s]);if(r)return e.jsx(Ms,{children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 space-y-4",children:[e.jsx(gs,{className:"h-8 w-48"}),e.jsx(gs,{className:"h-32 w-full"}),e.jsx(gs,{className:"h-32 w-full"})]})});if(!s)return e.jsx(Ms,{children:e.jsx(Tgs,{userId:t==null?void 0:t.id})});const i=l||Spe(s),d=u=>{o(p=>{const g=p||Spe(s);return typeof u=="function"?u(g):u})};return e.jsx(Ms,{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(Ags,{card:s}),e.jsx(Lgs,{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(nN,{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(Mgs,{card:s,form:i})})]})})]})})}function Mgs({card:t,form:s}){const{data:r}=Ct({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=S.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(V1e,{card:n})})}function Tgs({userId:t}){var d;const[s,r]=S.useState(""),n=h9e(),{data:a}=Ct({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:Am,title:"Shareable Link",desc:"One link that works everywhere"},{icon:Lm,title:"Lead Capture",desc:"Collect leads automatically"},{icon:sh,title:"Always Up-to-Date",desc:"Edit anytime, changes are instant"},{icon:Rl,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(mn,{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(Lt,{className:"text-center pb-2",children:[e.jsx(zt,{className:"text-xl",children:"Set Up Your Card"}),e.jsx(yr,{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(mn,{className:"h-4 w-4 mr-2"}),n.isPending?"Creating...":"Create My Card"]})]})]})]})}function Ags({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(at,{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(Am,{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(rn,{className:"h-3.5 w-3.5"})," Preview"]})})]})]})})}function Egs({userId:t}){const s=ns(),r=S.useRef(null),[n,a]=S.useState(!1),[o,l]=S.useState(""),{data:i,isLoading:d}=Ct({queryKey:["card-editor-profile",t],queryFn:async()=>{const{data:X}=await G.from("profiles").select("name, email, phone, avatar_url").eq("id",t).single();let se=(X==null?void 0:X.avatar_url)||null;if(!se){const{data:te}=await G.storage.from("avatars").list(`${t}`);if(te&&te.length>0){const{data:Y}=G.storage.from("avatars").getPublicUrl(`${t}/${te[0].name}`);se=`${Y.publicUrl}?t=${Date.now()}`,await G.from("profiles").update({avatar_url:se}).eq("id",t)}}return{...X,avatar_url:se}}}),[u,p]=S.useState(null),[g,v]=S.useState(null),[_,b]=S.useState(null),[j,w]=S.useState(!1),N=u??(i==null?void 0:i.name)??"",C=g??(i==null?void 0:i.phone)??"",A=_??(i==null?void 0:i.email)??"",I=i==null?void 0:i.avatar_url,L=((i==null?void 0:i.name)||"A").split(" ").map(X=>X[0]).join("").toUpperCase().slice(0,2),R=!(i!=null&&i.avatar_url)||!(i!=null&&i.phone),$=Ot({mutationFn:async X=>{const{error:se}=await G.from("profiles").update(X).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 X={};if(u!==null&&u!==(i==null?void 0:i.name)&&(X.name=u),g!==null&&g!==(i==null?void 0:i.phone)&&(X.phone=g||null),_!==null&&_!==(i==null?void 0:i.email)&&(X.email=_),Object.keys(X).length===0){fe.info("No changes to save");return}$.mutate(X)},U=X=>{var Y;const se=(Y=X.target.files)==null?void 0:Y[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),X.target.value=""},V=async X=>{w(!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:Y}=await G.storage.from("avatars").upload(te,X,{upsert:!0,contentType:"image/jpeg"});if(Y)throw Y;const{data:de}=G.storage.from("avatars").getPublicUrl(te),ie=de.publicUrl+"?t="+Date.now();await G.from("profiles").update({avatar_url:ie}).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{w(!1)}};return d?e.jsx(gs,{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(Qo,{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 X;return(X=r.current)==null?void 0:X.click()},children:[e.jsxs(fn,{className:"h-16 w-16 ring-2 ring-muted",children:[e.jsx(Ma,{src:I||void 0,alt:N}),e.jsx(gn,{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(Og,{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:j?"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:N,onChange:X=>p(X.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:C,onChange:X=>v(X.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:A,onChange:X=>b(X.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(Gbe,{open:n,onClose:()=>a(!1),imageSrc:o,onCropComplete:V,aspectRatio:1})]})}function Pgs({form:t,setForm:s,userId:r}){const[n,a]=S.useState(null),[o,l]=S.useState(t.brokerage_logo_url?"logo":"name"),[i,d]=S.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:""}))},g=async(_,b)=>{var w;const j=(w=_.target.files)==null?void 0:w[0];if(j){if(!j.type.startsWith("image/")){fe.error("Please select an image file");return}a(b);try{const N=j.name.split(".").pop()||"png",A=`${r}/${b==="brokerage_logo_url"?"brokerage-logo":"team-logo"}.${N}`,{error:I}=await G.storage.from("card-logos").upload(A,j,{upsert:!0});if(I)throw I;const{data:L}=G.storage.from("card-logos").getPublicUrl(A),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=""}}},v=_=>{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:()=>v("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(Og,{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:_=>g(_,"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(Pg,{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:()=>v("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(Og,{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:_=>g(_,"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(Pg,{value:[t.team_logo_size||56],onValueChange:([_])=>s(b=>({...b,team_logo_size:_})),min:24,max:120,step:4})]})]})]})]})})}function Igs({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(Rl,{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 g=p.target.value;/^#[0-9a-fA-F]{0,6}$/.test(g)&&a(i,g)},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 Lgs({card:t,form:s,setForm:r}){var j;const n=m9e(),a=ns(),{data:o}=p9e(t.id),[l,i]=S.useState(t.slug),[d,u]=S.useState(!1),[p,g]=S.useState("idle"),v=S.useRef(JSON.stringify(s)),_=S.useRef(null);S.useEffect(()=>{const w=JSON.stringify(s);if(w!==v.current)return _.current&&clearTimeout(_.current),_.current=setTimeout(()=>{g("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:()=>{v.current=w,g("saved"),setTimeout(()=>g("idle"),2e3)},onError:()=>g("idle")})},1500),()=>{_.current&&clearTimeout(_.current)}},[s]);const b=async()=>{const w=l.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!w){fe.error("Please enter a valid URL");return}if(w===t.slug){fe.info("No changes to save");return}u(!0);try{const{data:N}=await G.from("agent_cards").select("id").eq("slug",w).neq("id",t.id).maybeSingle();if(N){fe.error("This URL is already taken. Try another one.");return}const{error:C}=await G.from("agent_cards").update({slug:w}).eq("id",t.id);if(C)throw C;i(w),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(ja,{defaultValue:"content",children:[e.jsxs(va,{className:"w-full h-11 p-1",children:[e.jsxs(Ns,{value:"content",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(mp,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Content"]}),e.jsxs(Ns,{value:"sections",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(ya,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Sections"]}),e.jsxs(Ns,{value:"blocks",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Lm,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Blocks"]}),e.jsxs(Ns,{value:"qrcode",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(P0,{className:"h-3.5 w-3.5 hidden sm:inline"}),"QR Code"]}),e.jsxs(Ns,{value:"analytics",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(t_,{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(Egs,{userId:t.user_id}),e.jsx(Pgs,{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:w=>r(N=>({...N,is_published:w}))})]}),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:w=>i(w.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:w=>r(N=>({...N,display_email:w.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(tr,{value:s.theme,onValueChange:w=>r(N=>({...N,theme:w})),children:[e.jsx(Js,{className:"h-11",children:e.jsx(sr,{})}),e.jsxs(er,{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(Igs,{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:w=>r(N=>({...N,title:w.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:w=>r(N=>({...N,positioning_statement:w.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(Tr,{value:s.bio,onChange:w=>r(N=>({...N,bio:w.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:w=>r(N=>({...N,review_snippet:w.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:w=>r(N=>({...N,review_source_url:w.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:w=>r(N=>({...N,booking_url:w.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:w=>r(N=>({...N,custom_cta_label:w.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:w,label:N,desc:C})=>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:N}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C})]}),e.jsx(Br,{checked:s[w],onCheckedChange:A=>r(I=>({...I,[w]:A}))})]},w))})})}),e.jsx(zs,{value:"blocks",className:"mt-4",children:e.jsx(CJe,{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:ya,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:t_,color:"text-amber-600 bg-amber-100 dark:text-amber-400 dark:bg-amber-900/30"},{label:"Leads",value:((j=o==null?void 0:o.leads)==null?void 0:j.length)??0,icon:fc,color:"text-emerald-600 bg-emerald-100 dark:text-emerald-400 dark:bg-emerald-900/30"}].map(w=>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 ${w.color}`,children:e.jsx(w.icon,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:w.label})]}),e.jsx("div",{className:"text-2xl font-bold",children:w.value})]})},w.label))}),o&&o.leads.length>0&&e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(zt,{className:"text-base",children:"Recent Leads"})}),e.jsx(Oe,{className:"pt-0 space-y-2",children:o.leads.slice(0,5).map(w=>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:w.name}),w.phone&&e.jsx("span",{className:"text-muted-foreground ml-2",children:w.phone})]}),w.intent&&e.jsx(at,{variant:"secondary",className:"text-xs",children:w.intent})]},w.id))})]}),(!o||o.leads.length===0)&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center",children:[e.jsx(t_,{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(Sgs,{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 Dgs(){const t=ns(),[s,r]=S.useState(""),[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState(!1),[g,v]=S.useState(!1),[_,b]=S.useState(null),[j,w]=S.useState(null),[N,C]=S.useState(0),{data:A,isLoading:I}=Ct({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:te,error:Y}=await G.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(Y)throw Y;return te}}),L=Ot({mutationFn:async te=>{const{data:Y,error:de}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_token",api_token:te}});if(de)throw de;if(Y!=null&&Y.error)throw new Error(Y.error);return Y},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),r(""),fe.success("BoldTrail connected successfully!")},onError:te=>{fe.error(te.message||"Failed to connect BoldTrail")}}),R=Ot({mutationFn:async()=>{const{data:te,error:Y}=await G.functions.invoke("boldtrail-sync",{body:{action:"disconnect"}});if(Y)throw Y;return te},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),fe.success("BoldTrail disconnected")},onError:()=>fe.error("Failed to disconnect")}),$=Ot({mutationFn:async te=>{const{data:Y,error:de}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_direction",sync_direction:te}});if(de)throw de;if(Y!=null&&Y.error)throw new Error(Y.error);return Y},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),fe.success("Sync direction saved")},onError:te=>{fe.error(te.message||"Failed to save sync direction")}}),q=Ot({mutationFn:async()=>{const{data:te,error:Y}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(Y)throw Y;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=Ot({mutationFn:async()=>{w("Initializing sync..."),C(5);const{data:te,error:Y}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:se}});if(Y)throw Y;if(te!=null&&te.error)throw new Error(te.error);const de=te;let ie=de.sync_log_id,ae=de.next_phase,le=de.next_offset;const pe=de.push_total||0,be=de.pull_total||0,ye=pe+be;let we=0,Ne=0;for(;ae!=="finalize";){ae==="push"?(w(`Pushing contacts to BoldTrail... (${we}/${pe})`),C(ye>0?we/ye*100:0)):ae==="pull"&&(w(`Pulling contacts from BoldTrail... (${Ne}/${be})`),C(ye>0?(pe+Ne)/ye*100:0));const{data:Me,error:Te}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:ae,offset:le,sync_log_id:ie,sync_direction:se}});if(Te)throw Te;if(Me!=null&&Me.error)throw new Error(Me.error);const Fe=Me;we+=Fe.chunk_pushed||0,Ne+=Fe.chunk_pulled||0,Fe.progress&&w(Fe.progress),ae==="pull"&&be>0?C(Math.min(95,Ne/be*100)):ae==="push"&&pe>0&&C(Math.min(95,we/pe*100)),ae=Fe.next_phase,le=Fe.next_offset}w("Finalizing sync..."),C(95);const{data:Ke,error:_e}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:ie,sync_direction:se}});if(_e)throw _e;return C(100),Ke},onSuccess:te=>{w(null),C(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=>{w(null),C(0),fe.error(te.message||"Sync failed")}}),V=A==null?void 0:A.connected,X=(A==null?void 0:A.sync_direction)||"bidirectional",se=_??X;return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Lt,{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(Vc,{className:"h-5 w-5 text-emerald-600"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["BoldTrail",V&&e.jsx(at,{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(gm,{className:"h-3.5 w-3.5"}),"Learn More"]})]}),e.jsx(yr,{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(fi,{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(fi,{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(fi,{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"})]}),V?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"}),(A==null?void 0:A.last_sync_at)&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sync: ",new Date(A.last_sync_at).toLocaleString(),A.last_sync_status&&e.jsx(at,{variant:A.last_sync_status==="success"?"default":"secondary",className:"ml-2 text-[10px]",children:A.last_sync_status})]}),(A==null?void 0:A.boldtrail_contact_count)!=null&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[A.boldtrail_contact_count," contacts in BoldTrail"]}),(A==null?void 0:A.last_sync_message)&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:A.last_sync_message})]}),e.jsxs(tc,{children:[e.jsx(Ih,{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(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Disconnect BoldTrail?"}),e.jsx(Il,{children:"This will remove your API token. Previously synced contacts will remain in both systems."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{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(cye,{value:X,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(Eo,{className:"h-4 w-4 animate-spin"}):e.jsx(ya,{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(Eo,{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(vs,{open:n,onOpenChange:te=>{U.isPending||a(te)},children:e.jsxs(ys,{className:"sm:max-w-lg",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Vc,{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,Y=se==="push_only"?0:i.to_pull;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(cye,{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(qd,{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:Y}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Ju,{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(Mi,{value:N||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:j||"Sync in progress..."})]}),te>0&&e.jsxs(mf,{open:u,onOpenChange:p,children:[e.jsx(pf,{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(qd,{className:"h-3 w-3 text-emerald-600"}),te," contacts to push to BoldTrail"]}),e.jsx(Vo,{className:`h-3 w-3 transition-transform ${u?"rotate-180":""}`})]})}),e.jsx(ff,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.push_preview.map((de,ie)=>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})]},ie)),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"]})]})})]}),Y>0&&e.jsxs(mf,{open:g,onOpenChange:v,children:[e.jsx(pf,{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(Ju,{className:"h-3 w-3 text-blue-600"}),Y," contacts to pull from BoldTrail"]}),e.jsx(Vo,{className:`h-3 w-3 transition-transform ${g?"rotate-180":""}`})]})}),e.jsx(ff,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.pull_preview.map((de,ie)=>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})]},ie)),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&&Y===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&&Y===0,className:"gap-2",children:[U.isPending?e.jsx(Eo,{className:"h-4 w-4 animate-spin"}):e.jsx(Vc,{className:"h-4 w-4"}),U.isPending?"Syncing...":"Sync Now"]})]})]})})()]})}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{className:"sm:max-w-2xl p-0 overflow-hidden",children:[e.jsx(Cs,{className:"p-6 pb-0",children:e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Vc,{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 Ogs(){const{isAdmin:t}=Gs(),s=ns(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(!1),{data:d,isLoading:u}=Ct({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}=Ct({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}}),g=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)}},v=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=Ot({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")}}),j=Ot({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")}}),w=!!(d!=null&&d.is_active),N=(p==null?void 0:p.filter(I=>I.platform==="facebook"))||[],C=(p==null?void 0:p.filter(I=>I.platform==="instagram"))||[],A=(p==null?void 0:p.filter(I=>I.platform==="linkedin"))||[];return e.jsx(Ms,{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(Lt,{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(zt,{className:"text-lg flex items-center gap-2",children:["Gmail",w&&e.jsx(at,{variant:"default",className:"text-xs bg-green-600",children:"Connected"})]}),e.jsx(yr,{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(fi,{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(fi,{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(fi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Quick compose from any contact detail page"})]}),w?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(tc,{children:[e.jsx(Ih,{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(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Disconnect Gmail?"}),e.jsx(Il,{children:"This will remove your Gmail connection. You'll need to reconnect to send emails."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:()=>b.mutate(d.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}):e.jsxs(K,{className:"mt-4",onClick:g,disabled:r||u,children:[r?e.jsx(Eo,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(br,{className:"h-4 w-4 mr-2"}),"Connect Gmail",e.jsx(Ui,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(Lt,{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(Ud,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["Facebook",t?N.length>0?e.jsx(at,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(at,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Fu,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(yr,{children:"Connect Facebook Pages to post content and reach your audience."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[N.length>0&&e.jsx("div",{className:"space-y-2",children:N.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(fn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:I.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(Ud,{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(tc,{children:[e.jsx(Ih,{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(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Disconnect Facebook?"}),e.jsx(Il,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:()=>j.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(K,{onClick:v,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Eo,{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(Lt,{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(Vd,{className:"h-5 w-5 text-pink-600"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["Instagram",t?C.length>0?e.jsx(at,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(at,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Fu,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(yr,{children:"Connect Instagram Business accounts to schedule and publish posts."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[C.length>0&&e.jsx("div",{className:"space-y-2",children:C.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(fn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:I.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(Vd,{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(tc,{children:[e.jsx(Ih,{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(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Disconnect Instagram?"}),e.jsx(Il,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:()=>j.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(K,{onClick:v,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Eo,{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(Lt,{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(Pm,{className:"h-5 w-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["LinkedIn",t?A.length>0?e.jsx(at,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(at,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Fu,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(yr,{children:"Connect your LinkedIn profile to share content and grow your professional network."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[A.length>0&&e.jsx("div",{className:"space-y-2",children:A.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(fn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:I.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(Pm,{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(tc,{children:[e.jsx(Ih,{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(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Disconnect LinkedIn?"}),e.jsx(Il,{children:"This will remove your LinkedIn connection. You'll need to reconnect to post content."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:()=>j.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(Eo,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),"Connect LinkedIn"]})]})]}),e.jsx(Dgs,{})]})})}function Rgs(){const[t]=Ac(),s=Lr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Connecting your Gmail account...");return S.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:g,error:v}=await G.functions.invoke("gmail-oauth",{body:{action:"exchange_code",code:i,state:p}});if(v)throw v;if(g!=null&&g.success)n("success"),o(g.message||"Gmail connected successfully!"),fe.success("Gmail connected!");else throw new Error((g==null?void 0:g.error)||"Unknown error")}catch(g){console.error("Gmail OAuth callback error:",g),n("error"),o(g instanceof Error?g.message:"Failed to connect Gmail"),fe.error("Failed to connect: "+(g instanceof Error?g.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(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(As,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(fi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(wc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(zt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(yr,{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 Fgs(){const t=Lr();return S.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 zgs(){const[t]=Ac(),s=Lr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Processing your connection...");return S.useEffect(()=>{(async()=>{var g;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:v,error:_}=await G.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/mission-control/integrations/meta/callback"}});if(_)throw _;if(v!=null&&v.success)n("success"),o(`Successfully connected ${((g=v.accounts)==null?void 0:g.length)||0} account(s)!`),fe.success("Social accounts connected successfully!");else throw new Error((v==null?void 0:v.error)||"Unknown error")}catch(v){console.error("OAuth callback error:",v),n("error"),o(v instanceof Error?v.message:"Failed to connect accounts"),fe.error("Failed to connect: "+(v instanceof Error?v.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(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(As,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(fi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(wc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(zt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(yr,{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 zJe=new Date().getFullYear(),Bgs=Array.from({length:5},(t,s)=>zJe-s);function $gs(){const[t,s]=S.useState(zJe),r=Lr(),{data:n,isLoading:a}=U5t();return a?e.jsx(Ms,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(o=>e.jsx(gs,{className:"h-24"},o))}),e.jsx(gs,{className:"h-96"})]})}):e.jsx(Ms,{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(tr,{value:String(t),onValueChange:o=>s(Number(o)),children:[e.jsx(Js,{className:"w-[120px]",children:e.jsx(sr,{})}),e.jsx(er,{children:Bgs.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(Xo,{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(Lt,{children:[e.jsx(zt,{children:"Agents with Scorecards"}),e.jsx(yr,{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(Xo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents have added transactions yet"})]}):e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:n.map(o=>e.jsxs(js,{children:[e.jsx(it,{className:"font-medium",children:o.name}),e.jsx(it,{className:"text-muted-foreground",children:o.email}),e.jsx(it,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r(`/admin/scorecard/${o.id}`),children:[e.jsx(ya,{className:"h-4 w-4 mr-2"}),"View Scorecard"]})})]},o.id))})]})})]})]})})}const BJe=new Date().getFullYear(),qgs=Array.from({length:10},(t,s)=>BJe-s);function PLe(){var b;const{userId:t}=Co(),s=Lr(),n=xu().pathname.startsWith("/mission-control"),[a,o]=S.useState(BJe),{data:l,isLoading:i}=Ct({queryKey:["agent-profile",t],queryFn:async()=>{const{data:j,error:w}=await G.from("profiles").select("id, name, email").eq("id",t).single();if(w)throw w;return j},enabled:!!t}),{data:d,isLoading:u}=nbe(a,t),{yearStats:p,lifetimeStats:g,showCommission:v}=vVe(a,t),{data:_}=yVe(a,t);return i?e.jsx(Ms,{title:"Agent Scorecard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(j=>e.jsx(gs,{className:"h-24"},j))})]})}):e.jsx(Ms,{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(Ka,{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(tr,{value:String(a),onValueChange:j=>o(Number(j)),children:[e.jsx(Js,{className:"w-[120px]",children:e.jsx(sr,{})}),e.jsx(er,{children:qgs.map(j=>e.jsx(At,{value:String(j),children:j},j))})]})]}),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(Vn,{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:[g.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(Gc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Cl(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(Sc,{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:Cl(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(ec,{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(wZe,{goals:_,stats:p,year:a,showCommission:v}),e.jsxs(ja,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsx(Ns,{value:"transactions",children:"Transactions"}),e.jsx(Ns,{value:"charts",children:"Charts"}),e.jsxs(Ns,{value:"map",children:[e.jsx(Ti,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(zs,{value:"transactions",children:e.jsx(wwe,{transactions:d||[],showCommission:v,isLoading:u})}),e.jsx(zs,{value:"charts",children:e.jsx(A2e,{stats:p,year:a})}),e.jsx(zs,{value:"map",children:e.jsx(E2e,{transactions:d||[],isLoading:u})})]})]})})}function Ugs(){const t=ns(),[s,r]=S.useState(""),[n,a]=S.useState("all");G9e();const{data:o,refetch:l}=Ct({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}=Ct({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}=Ct({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:",$)}},g=Ot({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)}}),v=Ot({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")}}),_=Ot({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=Ot({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")}}),j=Ot({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")}}),w=o??!1,N=i==null?void 0:i.filter(I=>{var $,q,U,V;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()))||((V=I.property_address)==null?void 0:V.toLowerCase().includes(s.toLowerCase())),R=n==="all"||n==="pending"&&!I.is_approved||n==="approved"&&I.is_approved;return L&&R}),C=I=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I),A=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(Ms,{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:()=>g.mutate(),disabled:g.isPending,className:"gap-2",children:[g.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(Am,{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:w,onCheckedChange:I=>j.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(Ca,{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(Sc,{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(ya,{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(xn,{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(ja,{value:n,onValueChange:I=>a(I),children:e.jsxs(va,{children:[e.jsx(Ns,{value:"all",children:"All"}),e.jsx(Ns,{value:"pending",children:"Pending"}),e.jsx(Ns,{value:"approved",children:"Approved"})]})})]})})}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{children:["Listings (",(N==null?void 0:N.length)||0,")"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Property"}),e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Price"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-center",children:"Approved"}),e.jsx(jt,{className:"text-center",children:"Featured"}),e.jsx(jt,{children:"Views"}),e.jsx(jt,{children:"Shares"}),e.jsx(jt,{children:"Date"}),e.jsx(jt,{})]})}),e.jsx(En,{children:d?e.jsx(js,{children:e.jsx(it,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):(N==null?void 0:N.length)===0?e.jsx(js,{children:e.jsx(it,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No listings found"})}):N==null?void 0:N.map(I=>{var L,R,$,q,U;return e.jsxs(js,{children:[e.jsx(it,{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(Ca,{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(it,{children:e.jsx("p",{className:"text-sm",children:((q=I.agent)==null?void 0:q.name)||"Unknown"})}),e.jsx(it,{className:"font-medium",children:C(I.price)}),e.jsx(it,{children:e.jsx(at,{variant:"outline",className:A(I.status),children:(U=I.status)==null?void 0:U.replace("_"," ")})}),e.jsx(it,{className:"text-center",children:e.jsx(Br,{checked:I.is_approved??!1,onCheckedChange:V=>v.mutate({id:I.id,approved:V,slug:I.slug})})}),e.jsx(it,{className:"text-center",children:e.jsx(Br,{checked:I.is_featured??!1,onCheckedChange:V=>_.mutate({id:I.id,featured:V})})}),e.jsx(it,{children:I.view_count||0}),e.jsx(it,{children:I.share_count||0}),e.jsx(it,{className:"text-sm text-muted-foreground",children:ws(new Date(I.created_at),"MMM d, yyyy")}),e.jsx(it,{children:e.jsxs(yu,{children:[e.jsx(vu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(ef,{className:"h-4 w-4"})})}),e.jsxs(Wd,{align:"end",children:[e.jsxs(Da,{onClick:()=>window.open(`/mission-control/listings/${I.id}`,"_blank"),children:[e.jsx(ya,{className:"h-4 w-4 mr-2"}),"View Listing"]}),e.jsxs(Da,{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(Da,{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 Vgs=()=>{var g,v;const[t,s]=S.useState(""),[r,n]=S.useState(null),{data:a,isLoading:o}=Ct({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 j=(_==null?void 0:_.map(C=>C.user_id))||[],{data:w}=await G.from("profiles").select("id, name, email").in("id",j);return _==null?void 0:_.map(C=>({...C,profiles:(w==null?void 0:w.find(A=>A.id===C.user_id))||null}))}}),l=a==null?void 0:a.filter(_=>{var j,w,N,C,A;const b=t.toLowerCase();return((w=(j=_.profiles)==null?void 0:j.name)==null?void 0:w.toLowerCase().includes(b))||((C=(N=_.profiles)==null?void 0:N.email)==null?void 0:C.toLowerCase().includes(b))||((A=_.review_text)==null?void 0:A.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:Et("h-4 w-4",_>=b?"fill-yellow-400 text-yellow-400":"text-muted-foreground")},b))});return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{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(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"Total Reviews"}),e.jsx(zt,{className:"text-3xl",children:(a==null?void 0:a.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"Average Rating"}),e.jsxs(zt,{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(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"5-Star Reviews"}),e.jsx(zt,{className:"text-3xl",children:(d==null?void 0:d[5])||0})]})}),e.jsx(Ee,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(yr,{children:"Posted to Google"}),e.jsxs(zt,{className:"flex items-center gap-2 text-3xl",children:[u,e.jsx(rn,{className:"h-5 w-5 text-muted-foreground"})]})]})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(xn,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Member"}),e.jsx(jt,{children:"Rating"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Review"}),e.jsx(jt,{children:"Google"}),e.jsx(jt,{children:"Date"})]})}),e.jsx(En,{children:o?e.jsx(js,{children:e.jsx(it,{colSpan:5,className:"text-center py-8",children:"Loading reviews..."})}):(l==null?void 0:l.length)===0?e.jsx(js,{children:e.jsx(it,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No reviews found"})}):l==null?void 0:l.map(_=>{var b,j;return e.jsxs(js,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>n(_),children:[e.jsx(it,{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:(j=_.profiles)==null?void 0:j.email})]})}),e.jsx(it,{children:p(_.rating)}),e.jsx(it,{className:"hidden md:table-cell max-w-xs",children:e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:_.review_text||"-"})}),e.jsx(it,{children:_.posted_to_google?e.jsx(at,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Posted"}):e.jsx(at,{variant:"outline",children:"No"})}),e.jsx(it,{className:"text-sm text-muted-foreground",children:ws(new Date(_.created_at),"MMM d, yyyy")})]},_.id)})})]})})}),e.jsx(vs,{open:!!r,onOpenChange:()=>n(null),children:e.jsxs(ys,{className:"max-w-lg",children:[e.jsx(Cs,{children:e.jsx(Ss,{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:((g=r.profiles)==null?void 0:g.name)||"Unknown Member"}),((v=r.profiles)==null?void 0:v.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"}),ws(new Date(r.created_at),"MMMM d, yyyy 'at' h:mm a")]}),r.posted_to_google?e.jsxs(at,{variant:"secondary",className:"bg-green-100 text-green-800",children:[e.jsx(rn,{className:"h-3 w-3 mr-1"}),"Posted to Google"]}):e.jsx(at,{variant:"outline",children:"Not posted to Google"})]})]})]})})]})})},Hgs=[{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"}],Wgs=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 Ggs(){const t=ns(),{user:s}=Gs(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(!1),{data:d,isLoading:u}=Ct({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:g}=Ct({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:v}=Ct({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}=Ct({queryKey:["digest-queue-status"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const[U,V,X,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:V.count||0,sent:X.count||0,failed:se.count||0,total:(U.count||0)+(V.count||0)+(X.count||0)+(se.count||0)}},refetchInterval:5e3});S.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:j=0}=Ct({queryKey:["digest-today-failed-count"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const{count:U,error:V}=await G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",q.toISOString());if(V)throw V;return U||0}}),w=Ot({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)}}),N=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)}},C=async()=>{var q,U,V,X,se,te;if(!(s!=null&&s.email)){fe.error("No email found for your account");return}o(!0);try{const{data:Y,error:de}=await G.functions.invoke("send-weekly-digest",{body:{preview:!0,previewEmail:s.email}});if(de)throw de;const ie=Y==null?void 0:Y.resendId,ae=Y==null?void 0:Y.resendDetails,le=ae==null?void 0:ae.status,pe=((q=ae==null?void 0:ae.body)==null?void 0:q.status)||((V=(U=ae==null?void 0:ae.body)==null?void 0:U.data)==null?void 0:V.status),be=((se=(X=ae==null?void 0:ae.body)==null?void 0:X.error)==null?void 0:se.message)||((te=ae==null?void 0:ae.body)==null?void 0:te.message);fe.success(ie?`Preview accepted by email provider (id: ${ie})${le?`, status check: ${le}`:""}${pe?`, provider: ${pe}`:""}${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(Y){fe.error("Failed to send preview: "+Y.message)}finally{o(!1)}},A=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}=Ct({queryKey:["digest-delivery-stats"],queryFn:async()=>{var te,Y;const q=new Date;q.setUTCHours(0,0,0,0);const[U,V,X,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:V.count||0,agentOsEngaged:X.count||0,lastSent:((Y=(te=se.data)==null?void 0:te[0])==null?void 0:Y.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(Ms,{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(Ms,{title:"Weekly Digest",description:"Configure and manage automated weekly email digests for members",children:e.jsxs(ja,{defaultValue:"settings",className:"space-y-6",children:[e.jsxs(va,{children:[e.jsxs(Ns,{value:"settings",className:"flex items-center gap-2",children:[e.jsx(Fl,{className:"h-4 w-4"}),"Settings"]}),e.jsxs(Ns,{value:"stats",className:"flex items-center gap-2",children:[e.jsx(Xo,{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(As,{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(Mi,{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:v}),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(la,{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(wc,{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(In,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.lastSent?ws(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(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(In,{className:"h-5 w-5"}),"Schedule"]}),e.jsx(yr,{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=>w.mutate({is_enabled:q})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Cron Frequency"}),e.jsxs(tr,{value:(d==null?void 0:d.cron_frequency)||"daily",onValueChange:q=>w.mutate({cron_frequency:q}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{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(tr,{value:String(d==null?void 0:d.send_day),onValueChange:q=>w.mutate({send_day:parseInt(q)}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:Hgs.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(tr,{value:String(d==null?void 0:d.send_hour),onValueChange:q=>w.mutate({send_hour:parseInt(q)}),disabled:(d==null?void 0:d.cron_frequency)==="daily",children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:Wgs.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:C,disabled:a,variant:"outline",className:"flex-1",children:[e.jsx(ya,{className:"h-4 w-4 mr-2"}),a?"Sending...":"Send Preview to Me"]}),e.jsxs(K,{onClick:N,disabled:r,className:"flex-1",children:[e.jsx(Ta,{className:"h-4 w-4 mr-2"}),r?"Sending...":"Send to All"]})]}),j>0&&e.jsxs(K,{onClick:A,disabled:l,variant:"outline",className:"w-full",children:[e.jsx(Eo,{className:`h-4 w-4 mr-2 ${l?"animate-spin":""}`}),l?"Retrying...":`Retry ${j} Failed`]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-5 w-5"}),"Content Sections"]}),e.jsx(yr,{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(Sn,{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=>w.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=>w.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(Xo,{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=>w.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=>w.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(Uh,{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=>w.mutate({include_goals_progress:q})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Custom Introduction"}),e.jsx(yr,{children:"Personalize the intro message (optional)"})]}),e.jsx(Oe,{children:e.jsx(Tr,{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=>w.mutate({custom_intro_text:q.target.value||null}),rows:3})})]})]}),e.jsx(zs,{value:"stats",children:e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),"Delivery History"]}),e.jsx(yr,{children:"Recent digest emails sent to members"})]}),e.jsx(Oe,{children:g?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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Sent At"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Resources"}),e.jsx(jt,{children:"Agent OS"})]})}),e.jsx(En,{children:p.map(q=>e.jsxs(js,{children:[e.jsx(it,{className:"font-medium",children:q.email_sent_to}),e.jsx(it,{children:ws(new Date(q.sent_at),"MMM d, yyyy h:mm a")}),e.jsx(it,{children:e.jsx(at,{variant:q.delivery_status==="sent"?"default":"destructive",children:q.delivery_status})}),e.jsx(it,{children:q.resources_count}),e.jsx(it,{children:q.has_agent_os_activity?e.jsx(at,{variant:"secondary",children:"Active"}):e.jsx(at,{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 Kgs={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 Zgs(){var we,Ne,Ke;const t=ns(),[s,r]=S.useState(""),[n,a]=S.useState(null),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(""),[g,v]=S.useState(""),[_,b]=S.useState(!0),[j,w]=S.useState(!1),[N,C]=S.useState(""),[A,I]=S.useState(null),{data:L,isLoading:R}=Ct({queryKey:["admin-agent-points"],queryFn:async()=>{const{data:_e,error:Me}=await G.from("agent_attendance_stats").select("*").order("total_points",{ascending:!1});if(Me)throw Me;const Te=(_e==null?void 0:_e.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 _e==null?void 0:_e.map(Ue=>({...Ue,profile:Ae.get(Ue.user_id)||null}))}}),{data:$}=Ct({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(_e=>!(L!=null&&L.some(Me=>Me.user_id===_e.id))))||[]).filter(_e=>{var Te,Fe;if(!N)return!0;const Me=N.toLowerCase();return((Te=_e.name)==null?void 0:Te.toLowerCase().includes(Me))||((Fe=_e.email)==null?void 0:Fe.toLowerCase().includes(Me))}),{data:V,isLoading:X}=Ct({queryKey:["agent-point-history",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:_e,error:Me}=await G.from("agent_points").select("*").eq("user_id",n.user_id).order("created_at",{ascending:!1});if(Me)throw Me;return _e},enabled:!!(n!=null&&n.user_id)&&i}),{data:se}=Ct({queryKey:["agent-badges",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:_e,error:Me}=await G.from("agent_badges").select("*").eq("user_id",n.user_id).order("earned_at",{ascending:!1});if(Me)throw Me;return _e},enabled:!!(n!=null&&n.user_id)}),te=Ot({mutationFn:async({userId:_e,points:Me,reason:Te})=>{const{error:Fe}=await G.from("agent_points").insert({user_id:_e,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",_e).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:_e,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(""),v(""),fe.success(_?"Points awarded successfully!":"Points deducted successfully!")},onError:_e=>{console.error("Error modifying points:",_e),fe.error("Failed to modify points")}}),Y=()=>{if(!n||!u||!g){fe.error("Please fill in all fields");return}const _e=parseInt(u);if(isNaN(_e)||_e<=0){fe.error("Please enter a valid positive number");return}te.mutate({userId:n.user_id,points:_?_e:-_e,reason:g})},de=()=>{if(!A||!u||!g){fe.error("Please fill in all fields");return}const _e=parseInt(u);if(isNaN(_e)||_e<=0){fe.error("Please enter a valid positive number");return}te.mutate({userId:A.id,points:_e,reason:g},{onSuccess:()=>{w(!1),I(null),C("")}})},ie=(_e,Me)=>{a(_e),b(Me),l(!0)},ae=_e=>{a(_e),d(!0)},le=L==null?void 0:L.filter(_e=>{var Ae,Ue,ut,De;const Me=((Ue=(Ae=_e.profile)==null?void 0:Ae.name)==null?void 0:Ue.toLowerCase())||"",Te=((De=(ut=_e.profile)==null?void 0:ut.email)==null?void 0:De.toLowerCase())||"",Fe=s.toLowerCase();return Me.includes(Fe)||Te.includes(Fe)}),pe=(L==null?void 0:L.reduce((_e,Me)=>_e+Me.total_points,0))||0,be=(L==null?void 0:L.length)||0,ye=be>0?Math.round(pe/be):0;return R?e.jsx(Ms,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(_e=>e.jsx(gs,{className:"h-24"},_e))}),e.jsx(gs,{className:"h-96"})]})}):e.jsx(Ms,{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(Gi,{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:pe.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(Sc,{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:ye}),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(xn,{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:_e=>r(_e.target.value),className:"pl-10"})]}),e.jsxs(K,{onClick:()=>w(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Award Points to New Agent"]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Agent Leaderboard"}),e.jsx(yr,{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(Gi,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents with points yet"})]}):e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-12",children:"#"}),e.jsx(jt,{children:"Agent"}),e.jsx(jt,{className:"text-center",children:"Total Points"}),e.jsx(jt,{className:"text-center",children:"Spendable"}),e.jsx(jt,{className:"text-center",children:"Events"}),e.jsx(jt,{className:"text-center",children:"Streak"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:le.map((_e,Me)=>{var Te,Fe,Ae,Ue;return e.jsxs(js,{children:[e.jsx(it,{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(it,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fn,{className:"h-8 w-8",children:e.jsx(gn,{children:((Fe=(Te=_e.profile)==null?void 0:Te.name)==null?void 0:Fe.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Ae=_e.profile)==null?void 0:Ae.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(Ue=_e.profile)==null?void 0:Ue.email})]})]})}),e.jsx(it,{className:"text-center",children:e.jsxs(at,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),_e.total_points]})}),e.jsx(it,{className:"text-center",children:e.jsxs(at,{variant:"outline",className:"font-bold text-primary",children:[e.jsx(ao,{className:"h-3 w-3 mr-1"}),_e.spendable_points||0]})}),e.jsx(it,{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"}),_e.total_events_attended]})}),e.jsx(it,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Bh,{className:"h-3 w-3 text-orange-500"}),_e.current_streak]})}),e.jsx(it,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ie(_e,!0),title:"Award points",children:e.jsx(Zs,{className:"h-4 w-4 text-green-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ie(_e,!1),title:"Deduct points",children:e.jsx(A0,{className:"h-4 w-4 text-red-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ae(_e),title:"View history",children:e.jsx(d5,{className:"h-4 w-4"})})]})})]},_e.user_id)})})]})})]}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:_?"Award Points":"Deduct Points"}),e.jsxs(Kr,{children:[_?"Award":"Deduct"," points ",_?"to":"from"," ",((we=n==null?void 0:n.profile)==null?void 0:we.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:_e=>p(_e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"reason",children:"Reason"}),e.jsx(Tr,{id:"reason",placeholder:"Enter reason for this adjustment...",value:g,onChange:_e=>v(_e.target.value)})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:Y,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(vs,{open:i,onOpenChange:d,children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{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(ja,{defaultValue:"history",className:"w-full",children:[e.jsxs(va,{className:"grid w-full grid-cols-2",children:[e.jsx(Ns,{value:"history",children:"Point History"}),e.jsx(Ns,{value:"badges",children:"Badges"})]}),e.jsx(zs,{value:"history",className:"mt-4",children:X?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(_e=>e.jsx(gs,{className:"h-12"},_e))}):!V||V.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(d5,{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:V.map(_e=>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:_e.reason}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ws(new Date(_e.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(at,{variant:_e.points>=0?"default":"destructive",className:_e.points>=0?"bg-green-100 text-green-800":"",children:[_e.points>=0?"+":"",_e.points]})]},_e.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(ec,{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(_e=>e.jsxs("div",{className:`p-3 rounded-lg ${Kgs[_e.badge_type]||"bg-gray-100"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ec,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:_e.badge_name})]}),_e.badge_description&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:_e.badge_description}),e.jsxs("p",{className:"text-xs mt-1 opacity-60",children:["Earned ",ws(new Date(_e.earned_at),"MMM d, yyyy")]})]},_e.id))})})]})]})}),e.jsx(vs,{open:j,onOpenChange:_e=>{w(_e),_e||(I(null),C(""),p(""),v(""))},children:e.jsxs(ys,{className:"max-w-md",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(fn,{className:"h-10 w-10",children:e.jsx(gn,{children:((Ke=A.name)==null?void 0:Ke.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:A.name||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:A.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:_e=>p(_e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"new-reason",children:"Reason"}),e.jsx(Tr,{id:"new-reason",placeholder:"Enter reason for awarding points...",value:g,onChange:_e=>v(_e.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(xn,{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:N,onChange:_e=>C(_e.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:N?"No matching agents found":"All agents already have points"})]}):U.slice(0,20).map(_e=>{var Me;return e.jsxs("button",{onClick:()=>I(_e),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(fn,{className:"h-8 w-8",children:e.jsx(gn,{children:((Me=_e.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:_e.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:_e.email})]})]},_e.id)})})]})}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),A&&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 Ygs(){const{data:t,isLoading:s}=r0t(),[r,n]=S.useState(null),[a,o]=S.useState(!1),[l,i]=S.useState(""),[d,u]=S.useState("all"),[p,g]=S.useState("newest"),[v,_]=S.useState("table"),b=S.useMemo(()=>(t==null?void 0:t.map(A=>A.user_id))||[],[t]),j=S.useMemo(()=>(t==null?void 0:t.map(A=>A.id))||[],[t]),{data:w}=Ct({queryKey:["card-profiles-lookup",b],queryFn:async()=>{if(b.length===0)return{};const{data:A}=await G.from("profiles").select("id, name, email").in("id",b),I={};return A==null||A.forEach(L=>{I[L.id]={name:L.name||"",email:L.email||""}}),I},enabled:b.length>0}),{data:N}=Ct({queryKey:["card-stats-all",j],queryFn:async()=>{if(j.length===0)return{};const A={};j.forEach(R=>{A[R]={views:0,leads:0}});const{data:I}=await G.from("agent_card_interactions").select("card_id").in("card_id",j).eq("interaction_type","card_view");I==null||I.forEach(R=>{A[R.card_id]&&A[R.card_id].views++});const{data:L}=await G.from("agent_card_leads").select("card_id").in("card_id",j);return L==null||L.forEach(R=>{A[R.card_id]&&A[R.card_id].leads++}),A},enabled:j.length>0}),C=S.useMemo(()=>{if(!t)return[];let A=[...t];if(d==="live"?A=A.filter(I=>I.is_published):d==="draft"&&(A=A.filter(I=>!I.is_published)),l.trim()){const I=l.toLowerCase();A=A.filter(L=>{var $,q;const R=w==null?void 0:w[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"?A.sort((I,L)=>new Date(L.created_at).getTime()-new Date(I.created_at).getTime()):p==="oldest"?A.sort((I,L)=>new Date(I.created_at).getTime()-new Date(L.created_at).getTime()):p==="name"?A.sort((I,L)=>{var R,$;return(((R=w==null?void 0:w[I.user_id])==null?void 0:R.name)||"").localeCompare((($=w==null?void 0:w[L.user_id])==null?void 0:$.name)||"")}):p==="slug"?A.sort((I,L)=>I.slug.localeCompare(L.slug)):p==="views_desc"?A.sort((I,L)=>{var R,$;return(((R=N==null?void 0:N[L.id])==null?void 0:R.views)||0)-((($=N==null?void 0:N[I.id])==null?void 0:$.views)||0)}):p==="views_asc"?A.sort((I,L)=>{var R,$;return(((R=N==null?void 0:N[I.id])==null?void 0:R.views)||0)-((($=N==null?void 0:N[L.id])==null?void 0:$.views)||0)}):p==="leads_desc"?A.sort((I,L)=>{var R,$;return(((R=N==null?void 0:N[L.id])==null?void 0:R.leads)||0)-((($=N==null?void 0:N[I.id])==null?void 0:$.leads)||0)}):p==="leads_asc"&&A.sort((I,L)=>{var R,$;return(((R=N==null?void 0:N[I.id])==null?void 0:R.leads)||0)-((($=N==null?void 0:N[L.id])==null?void 0:$.leads)||0)}),A},[t,d,l,p,w]);return e.jsxs(Ms,{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(xn,{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:A=>i(A.target.value),className:"pl-9"})]}),e.jsxs(tr,{value:d,onValueChange:u,children:[e.jsx(Js,{className:"w-full sm:w-36",children:e.jsx(sr,{placeholder:"Status"})}),e.jsxs(er,{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(tr,{value:p,onValueChange:g,children:[e.jsx(Js,{className:"w-full sm:w-44",children:e.jsx(sr,{placeholder:"Sort by"})}),e.jsxs(er,{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:v==="table"?"default":"ghost",size:"sm",onClick:()=>_("table"),className:"rounded-r-none",children:e.jsx(b5,{className:"h-4 w-4"})}),e.jsx(K,{variant:v==="grid"?"default":"ghost",size:"sm",onClick:()=>_("grid"),className:"rounded-l-none",children:e.jsx(pp,{className:"h-4 w-4"})})]})]}),!s&&t&&t.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",C.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(A=>e.jsx(gs,{className:"h-48"},A))}):C.length>0?v==="table"?e.jsx(Xgs,{cards:C,cardProfiles:w,cardStats:N,onEdit:n,sortBy:p,setSortBy:g}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:C.map(A=>e.jsx(Qgs,{card:A,onEdit:()=>n(A),stats:N==null?void 0:N[A.id]},A.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(xn,{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(Jgs,{open:a,onOpenChange:o}),r&&e.jsx(exs,{card:r,open:!!r,onOpenChange:A=>!A&&n(null)})]})}function Xgs({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(Ju,{className:"h-3 w-3"}):a===`${d}_asc`?e.jsx(qd,{className:"h-3 w-3"}):e.jsx(Vc,{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(qd,{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],g=`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(at,{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(Ua,{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(g),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:g,target:"_blank",rel:"noopener noreferrer",children:e.jsx(rn,{className:"h-3.5 w-3.5"})})})]})})]},d.id)})})]})})})}function Qgs({card:t,onEdit:s,stats:r}){const[n,a]=S.useState(null);S.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:g}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${p[0].name}`);u=g.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(fn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:(n==null?void 0:n.avatar_url)||void 0}),e.jsx(gn,{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(at,{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(ya,{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(Ua,{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(rn,{className:"h-3 w-3"})})})]})]})})}function Jgs({open:t,onOpenChange:s}){const[r,n]=S.useState(""),[a,o]=S.useState(""),[l,i]=S.useState(""),[d,u]=S.useState(!1),p=h9e(),g=l.trim(),{data:v}=Ct({queryKey:["profiles-search-for-cards",g],queryFn:async()=>{let C=G.from("profiles").select("id, name, email").order("name").limit(50);g.length>=2&&(C=C.or(`name.ilike.%${g}%,email.ilike.%${g}%`));const{data:A}=await C;return A||[]},enabled:t}),[_,b]=S.useState(null),j=(v==null?void 0:v.find(C=>C.id===r))||_,w=()=>{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("")}})},N=C=>{var I;n(C),u(!1);const A=v==null?void 0:v.find(L=>L.id===C);A&&(b(A),o(((I=A.name)==null?void 0:I.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||""))};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(No,{open:d,onOpenChange:u,children:[e.jsx(So,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":d,className:"w-full justify-between font-normal",children:[j?`${j.name} (${j.email})`:"Search for an agent...",e.jsx(df,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(wf,{shouldFilter:!1,children:[e.jsx(jf,{placeholder:"Search by name or email...",value:l,onValueChange:i}),e.jsxs(kf,{children:[e.jsx(Nf,{children:"No agents found."}),e.jsx(Sf,{children:(v||[]).map(C=>e.jsxs(jm,{value:C.id,onSelect:N,children:[e.jsx(fa,{className:Et("mr-2 h-4 w-4",r===C.id?"opacity-100":"opacity-0")}),C.name," (",C.email,")"]},C.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:C=>o(C.target.value),placeholder:"john-doe"})]})]}),e.jsx(K,{onClick:w,disabled:p.isPending,className:"w-full",children:p.isPending?"Creating...":"Create Card"})]})]})})}function exs({card:t,open:s,onOpenChange:r}){const n=m9e(),{data:a}=p9e(t.id),o=ns(),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,g]=S.useState(!1),[v,_]=S.useState(""),[b,j]=S.useState(t.slug),[w,N]=S.useState(!1),[C,A]=S.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});S.useEffect(()=>{s&&(async()=>{try{const{data:V}=await G.storage.from("avatars").list(`${t.user_id}`);if(V&&V.length>0){const{data:X}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${V[0].name}`);i(`${X.publicUrl}?t=${Date.now()}`)}}catch{}})()},[t.user_id,s]);const I=U=>{var se;const V=(se=U.target.files)==null?void 0:se[0];if(!V)return;if(!V.type.startsWith("image/")){fe.error("Please select an image file");return}if(V.size>5*1024*1024){fe.error("Image must be under 5MB");return}const X=new FileReader;X.onloadend=()=>{_(X.result),g(!0)},X.readAsDataURL(V),U.target.value=""},L=async U=>{u(!0);try{const{data:V}=await G.storage.from("avatars").list(`${t.user_id}`);V&&V.length>0&&await G.storage.from("avatars").remove(V.map(de=>`${t.user_id}/${de.name}`));const X=`${t.user_id}/avatar.jpg`,{error:se}=await G.storage.from("avatars").upload(X,U,{upsert:!0,contentType:"image/jpeg"});if(se)throw se;const{data:te}=G.storage.from("avatars").getPublicUrl(X),Y=`${te.publicUrl}?t=${Date.now()}`;i(Y),await G.from("profiles").update({avatar_url:Y}).eq("id",t.user_id),o.invalidateQueries({queryKey:["agent-card-public"]}),fe.success("Photo updated!")}catch(V){fe.error(V.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}N(!0);try{const{data:V}=await G.from("agent_cards").select("id").eq("slug",U).neq("id",t.id).maybeSingle();if(V){fe.error("This URL is already taken. Try another one.");return}const{error:X}=await G.from("agent_cards").update({slug:U}).eq("id",t.id);if(X)throw X;j(U),o.invalidateQueries({queryKey:["agent-cards-admin"]}),fe.success("Card address updated!")}catch{fe.error("Failed to update card address")}finally{N(!1)}},$=async(U,V)=>{var se;const X=(se=U.target.files)==null?void 0:se[0];if(X){if(!X.type.startsWith("image/")){fe.error("Please select an image file");return}try{const te=X.name.split(".").pop()||"png",Y=V==="brokerage_logo_url"?"brokerage-logo":"team-logo",de=`${t.user_id}/${Y}.${te}`,{error:ie}=await G.storage.from("card-logos").upload(de,X,{upsert:!0});if(ie)throw ie;const{data:ae}=G.storage.from("card-logos").getPublicUrl(de),le=ae.publicUrl+"?t="+Date.now();A(V==="brokerage_logo_url"?pe=>({...pe,[V]:le,brokerage_display_name:""}):pe=>({...pe,[V]:le,team_name:""})),fe.success("Logo uploaded!")}catch{fe.error("Failed to upload logo")}finally{U.target.value=""}}},q=()=>{n.mutate({id:t.id,...C,title:C.title||null,positioning_statement:C.positioning_statement||null,bio:C.bio||null,review_snippet:C.review_snippet||null,review_source_url:C.review_source_url||null,booking_url:C.booking_url||null,custom_cta_label:C.custom_cta_label||null,custom_cta_url:C.custom_cta_url||null,brokerage_display_name:C.brokerage_display_name||null,brokerage_logo_url:C.brokerage_logo_url||null,brokerage_logo_size:C.brokerage_logo_size,team_name:C.team_name||null,team_logo_url:C.team_logo_url||null,team_logo_size:C.team_logo_size},{onSuccess:()=>r(!1)})};return e.jsxs(e.Fragment,{children:[e.jsx(vs,{open:s,onOpenChange:r,children:e.jsxs(ys,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Edit Agent Card"}),e.jsxs(Kr,{children:["/card/",t.slug]})]}),e.jsxs(ja,{defaultValue:"content",children:[e.jsxs(va,{className:"w-full",children:[e.jsx(Ns,{value:"content",className:"flex-1",children:"Content"}),e.jsx(Ns,{value:"sections",className:"flex-1",children:"Sections"}),e.jsx(Ns,{value:"blocks",className:"flex-1",children:"Blocks"}),e.jsx(Ns,{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:C.is_published,onCheckedChange:U=>A(V=>({...V,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(fn,{className:"h-16 w-16",children:[e.jsx(Ma,{src:l||void 0}),e.jsx(gn,{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(As,{className:"h-3 w-3 mr-1 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Xa,{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=>j(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:w||b===t.slug,className:"shrink-0",children:w?"Saving...":"Update"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Theme"}),e.jsxs(tr,{value:C.theme,onValueChange:U=>A(V=>({...V,theme:U})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{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:C.title,onChange:U=>A(V=>({...V,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:C.positioning_statement,onChange:U=>A(V=>({...V,positioning_statement:U.target.value})),placeholder:"Your home journey, handled with care."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Bio"}),e.jsx(Tr,{value:C.bio,onChange:U=>A(V=>({...V,bio:U.target.value})),placeholder:"Short about me...",rows:3})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Review Snippet"}),e.jsx(Re,{value:C.review_snippet,onChange:U=>A(V=>({...V,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:C.review_source_url,onChange:U=>A(V=>({...V,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:C.booking_url,onChange:U=>A(V=>({...V,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:C.custom_cta_label,onChange:U=>A(V=>({...V,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:C.custom_cta_url,onChange:U=>A(V=>({...V,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:C.brokerage_display_name,onChange:U=>A(V=>({...V,brokerage_display_name:U.target.value,brokerage_logo_url:""})),placeholder:"Brokerage name (or upload logo below)",disabled:!!C.brokerage_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[C.brokerage_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:C.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${C.brokerage_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>A(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(Xa,{className:"h-3.5 w-3.5"}),C.brokerage_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:U=>$(U,"brokerage_logo_url")})]})]}),C.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:[C.brokerage_logo_size||56,"px"]})]}),e.jsx(Pg,{value:[C.brokerage_logo_size||56],onValueChange:([U])=>A(V=>({...V,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:C.team_name,onChange:U=>A(V=>({...V,team_name:U.target.value,team_logo_url:""})),placeholder:"Team name (or upload logo below)",disabled:!!C.team_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[C.team_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:C.team_logo_url,alt:"Team logo",style:{height:`${C.team_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>A(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(Xa,{className:"h-3.5 w-3.5"}),C.team_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:U=>$(U,"team_logo_url")})]})]}),C.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:[C.team_logo_size||56,"px"]})]}),e.jsx(Pg,{value:[C.team_logo_size||56],onValueChange:([U])=>A(V=>({...V,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:V,hint:X})=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx(ve,{children:V}),X&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[X," ",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:C[U],onCheckedChange:se=>A(te=>({...te,[U]:se}))})]},U))}),e.jsx(zs,{value:"blocks",className:"mt-4",children:e.jsx(CJe,{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(at,{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(Gbe,{open:p,onClose:()=>g(!1),imageSrc:v,onCropComplete:L,aspectRatio:1})]})}const B5={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"},O2e={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 R2e(t=!0){return Ct({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 txs(){const t=ns();return Ot({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 sxs(){const t=ns();return Ot({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 rxs(){const t=ns();return Ot({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 $Je(t,s=!0){return Ct({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 nxs(t){return Ct({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 axs(){const t=ns();return Ot({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 ixs(){const t=ns();return Ot({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 oxs(){const t=ns();return Ot({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 lxs(){const t=ns();return Ot({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 cxs(){const t=ns();return Ot({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 dxs(){const t=ns();return Ot({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 uxs(){const t=ns();return Ot({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 hxs(){const t=ns();return Ot({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 mxs(){const t=ns();return Ot({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 pxs(t){const{isAdmin:s}=Gs();return Ct({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 fxs(){const{user:t}=Gs();return Ct({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 gxs(t){return Ct({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 xxs(){const t=ns(),{user:s}=Gs();return Ot({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(v){console.error("Failed to send notification email:",v)}},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 yxs(){const t=ns();return Ot({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 vxs(){const t=ns();return Ot({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 _xs(){const t=ns();return Ot({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 bxs(){const{data:t,isLoading:s}=R2e(!1),r=txs(),n=sxs(),a=rxs(),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),g=()=>{p({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),d(null)},v=j=>{d(j),p({name:j.name,description:j.description||"",image_url:j.image_url||"",sort_order:j.sort_order,is_active:j.is_active}),l(!0)},_=async j=>{j.preventDefault(),i?await n.mutateAsync({id:i.id,...u}):await r.mutateAsync(u),l(!1),g()},b=async j=>{confirm("Are you sure you want to delete this category?")&&await a.mutateAsync(j)};return s?e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(gs,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(j=>e.jsx(gs,{className:"h-12 w-full"},j))})})]}):e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{children:"Categories"}),e.jsxs(vs,{open:o,onOpenChange:j=>{l(j),j||g()},children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Category"]})}),e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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:j=>p({...u,name:j.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"description",children:"Description"}),e.jsx(Tr,{id:"description",value:u.description,onChange:j=>p({...u,description:j.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:j=>p({...u,image_url:j.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:j=>p({...u,sort_order:parseInt(j.target.value)||0})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"is_active",checked:u.is_active,onCheckedChange:j=>p({...u,is_active:j})}),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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{children:"Sort Order"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:t.map(j=>e.jsxs(js,{children:[e.jsx(it,{className:"font-medium",children:j.name}),e.jsx(it,{className:"max-w-xs truncate",children:j.description}),e.jsx(it,{children:j.sort_order}),e.jsx(it,{children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${j.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:j.is_active?"Active":"Inactive"})}),e.jsx(it,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>v(j),children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(j.id),disabled:a.isPending,children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},j.id))})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first category to get started."})})]})}function wxs(){var ye,we;const{data:t,isLoading:s}=$Je(void 0,!1),{data:r}=R2e(!1),n=axs(),a=ixs(),o=oxs(),l=lxs(),i=cxs(),d=dxs(),u=uxs(),p=hxs(),g=mxs(),[v,_]=S.useState(!1),[b,j]=S.useState(!1),[w,N]=S.useState(!1),[C,A]=S.useState(null),[I,L]=S.useState(null),[R,$]=S.useState(!1),[q,U]=S.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}),[V,X]=S.useState({name:"",price_adjustment:0}),[se,te]=S.useState(""),Y=()=>{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}),A(null)},de=Ne=>{A(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)},ie=async Ne=>{Ne.preventDefault();const Ke={...q,category_id:q.category_id||null};C?await a.mutateAsync({id:C.id,...Ke}):await n.mutateAsync(Ke),_(!1),Y()},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 Ke=Ne.target.files[0],_e=Ke.name.split(".").pop(),Me=`products/${I.id}/${Date.now()}.${_e}`;try{const{error:Te}=await G.storage.from("marketplace").upload(Me,Ke);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)}},pe=async Ne=>{Ne.preventDefault(),I&&(await u.mutateAsync({product_id:I.id,name:V.name,price_adjustment:V.price_adjustment}),X({name:"",price_adjustment:0}))},be=async()=>{!I||!se||(await g.mutateAsync({productId:I.id,videoUrl:se}),te(""))};return s?e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(gs,{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(gs,{className:"h-64 w-full"},Ne))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{children:"Products"}),e.jsxs(vs,{open:v,onOpenChange:Ne=>{_(Ne),Ne||Y()},children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Product"]})}),e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:C?"Edit Product":"Add Product"})}),e.jsxs("form",{onSubmit:ie,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(tr,{value:q.category_id,onValueChange:Ne=>U({...q,category_id:Ne}),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select category"})}),e.jsx(er,{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(Tr,{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:C?"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 Ke,_e;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:((Ke=Ne.images.find(Me=>Me.is_primary))==null?void 0:Ke.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(at,{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:((_e=Ne.category)==null?void 0:_e.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(at,{variant:"outline",className:"text-xs",children:"Artwork Upload"}),Ne.requires_proof_approval&&e.jsx(at,{variant:"outline",className:"text-xs",children:"Proof Required"}),Ne.variants&&Ne.variants.length>0&&e.jsxs(at,{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(Ua,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(Ne),j(!0)},children:[e.jsx(C0,{className:"h-3 w-3 mr-1"}),"Images"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(Ne),N(!0)},children:[e.jsx(Im,{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(vs,{open:b,onOpenChange:j,children:e.jsxs(ys,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ss,{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:(ye=I==null?void 0:I.images)==null?void 0:ye.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(at,{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 Ke;await d.mutateAsync({imageId:Ne.id,productId:I.id}),L({...I,images:(Ke=I.images)==null?void 0:Ke.map(_e=>({..._e,is_primary:_e.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 _e;await i.mutateAsync({id:Ne.id,productId:I.id});const Ke=t==null?void 0:t.find(Me=>Me.id===I.id);Ke&&L({...Ke,images:(_e=Ke.images)==null?void 0:_e.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(C0,{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(vs,{open:w,onOpenChange:N,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsxs(Ss,{children:["Manage Variants - ",I==null?void 0:I.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:pe,className:"flex gap-2",children:[e.jsx(Re,{placeholder:"Variant name (e.g., 500 count)",value:V.name,onChange:Ne=>X({...V,name:Ne.target.value}),required:!0}),e.jsx(Re,{type:"number",step:"0.01",placeholder:"Price adj.",value:V.price_adjustment,onChange:Ne=>X({...V,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:[(we=I==null?void 0:I.variants)==null?void 0:we.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 jxs=["pending_payment","order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed","cancelled","refunded"];function kxs(){var j,w,N;const{data:t,isLoading:s}=pxs(),r=xxs(),n=yxs(),[a,o]=S.useState(null),[l,i]=S.useState(!1),[d,u]=S.useState({status:"",notes:"",trackingNumber:"",trackingUrl:""}),[p,g]=S.useState(!1),v=C=>{o(C),u({status:C.status,notes:"",trackingNumber:C.tracking_number||"",trackingUrl:C.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(C,A)=>{if(!a||!C.target.files||C.target.files.length===0)return;g(!0);const I=C.target.files[0],L=I.name.split(".").pop(),R=`proofs/${a.id}/${A}/${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:A,proofUrl:q,orderId:a.id}),fe.success("Proof uploaded successfully")}catch($){fe.error("Failed to upload proof: "+$.message)}finally{g(!1)}};return s?e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(gs,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(C=>e.jsx(gs,{className:"h-16 w-full"},C))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Orders"})}),e.jsx(Oe,{children:t&&t.length>0?e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Order #"}),e.jsx(jt,{children:"Customer"}),e.jsx(jt,{children:"Date"}),e.jsx(jt,{children:"Total"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:t.map(C=>{var A,I;return e.jsxs(js,{children:[e.jsx(it,{className:"font-mono",children:C.order_number}),e.jsx(it,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((A=C.user)==null?void 0:A.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(I=C.user)==null?void 0:I.email})]})}),e.jsx(it,{children:ws(new Date(C.created_at),"MMM d, yyyy")}),e.jsxs(it,{className:"font-bold",children:["$",Number(C.total).toFixed(2)]}),e.jsx(it,{children:e.jsx(at,{className:O2e[C.status],children:B5[C.status]})}),e.jsx(it,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>v(C),children:[e.jsx(ya,{className:"h-4 w-4 mr-1"}),"View"]})})]},C.id)})})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No orders yet."})})]}),e.jsx(vs,{open:l,onOpenChange:i,children:e.jsxs(ys,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsxs(Ss,{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:(j=a.user)==null?void 0:j.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(w=a.user)==null?void 0:w.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:(N=a.items)==null?void 0:N.map(C=>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:C.product_name}),C.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.variant_name})]}),e.jsxs("p",{className:"font-bold",children:["$",Number(C.unit_price).toFixed(2)," x ",C.quantity]})]}),C.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:C.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(at,{variant:C.proof_status==="approved"?"default":"secondary",children:C.proof_status||"No proof yet"})]}),C.proof_url?e.jsx("a",{href:C.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:A=>b(A,C.id),className:"hidden",id:`proof-${C.id}`,disabled:p}),e.jsx("label",{htmlFor:`proof-${C.id}`,children:e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("span",{children:[e.jsx(Xa,{className:"h-4 w-4 mr-1"}),p?"Uploading...":"Upload Proof"]})})})]})]})})]},C.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(tr,{value:d.status,onValueChange:C=>u({...d,status:C}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:jxs.map(C=>e.jsx(At,{value:C,children:B5[C]},C))})]})]}),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:C=>u({...d,trackingNumber:C.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:C=>u({...d,trackingUrl:C.target.value}),placeholder:"https://..."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Notes (optional)"}),e.jsx(Tr,{value:d.notes,onChange:C=>u({...d,notes:C.target.value}),placeholder:"Add a note about this status change..."})]}),e.jsxs(K,{onClick:_,disabled:r.isPending,className:"w-full",children:[e.jsx(cl,{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(C=>e.jsxs("div",{className:"flex justify-between text-sm p-2 bg-muted rounded",children:[e.jsxs("div",{children:[e.jsx(at,{variant:"outline",children:B5[C.status]}),C.notes&&e.jsx("p",{className:"text-muted-foreground mt-1",children:C.notes})]}),e.jsx("span",{className:"text-muted-foreground",children:ws(new Date(C.created_at),"MMM d, h:mm a")})]},C.id))})]})]})]})})]})}function Nxs(){const[t,s]=S.useState("products"),r=Lr();return e.jsx(Ms,{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(rn,{className:"h-4 w-4 mr-2"}),"View Store"]})]}),e.jsxs(ja,{value:t,onValueChange:s,children:[e.jsxs(va,{className:"grid w-full grid-cols-3",children:[e.jsxs(Ns,{value:"products",className:"flex items-center gap-2",children:[e.jsx(cl,{className:"h-4 w-4"}),"Products"]}),e.jsxs(Ns,{value:"categories",className:"flex items-center gap-2",children:[e.jsx($h,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(Ns,{value:"orders",className:"flex items-center gap-2",children:[e.jsx(wm,{className:"h-4 w-4"}),"Orders"]})]}),e.jsx(zs,{value:"products",children:e.jsx(wxs,{})}),e.jsx(zs,{value:"categories",children:e.jsx(bxs,{})}),e.jsx(zs,{value:"orders",children:e.jsx(kxs,{})})]})]})})}function qJe(){return Ct({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 Sxs(t){return Ct({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 Cxs(t){return Ct({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 Mxs(t){return Ct({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 Txs(){return Ct({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 Axs(t){return Ct({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 Exs(){const t=ns();return Ot({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 Pxs(){const t=ns();return Ot({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 Ixs(){const t=ns();return Ot({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 Lxs(){const t=ns();return Ot({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 Dxs(){const t=ns();return Ot({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 Oxs(){const t=ns();return Ot({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 Rxs(){const t=ns();return Ot({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 Fxs(t){const s=t.match(/\/storage\/v1\/object\/public\/([^/]+)\/(.+)$/);return s?{bucket:s[1],path:s[2]}:null}async function Cpe(t,s){const r=Fxs(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 UJe(){return Ct({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 zxs(){const t=ns();return Ot({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 Bxs(){const{user:t}=Gs(),[s,r]=S.useState("items"),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState(""),[u,p]=S.useState(""),[g,v]=S.useState(""),[_,b]=S.useState(null),[j,w]=S.useState(!1),[N,C]=S.useState(null),[A,I]=S.useState(""),[L,R]=S.useState(""),[$,q]=S.useState(null),[U,V]=S.useState(""),[X,se]=S.useState("file"),[te,Y]=S.useState(""),[de,ie]=S.useState(""),[ae,le]=S.useState(""),[pe,be]=S.useState(!0),[ye,we]=S.useState(null),[Ne,Ke]=S.useState(!1),[_e,Me]=S.useState(!1),Te=S.useRef(null),Fe=S.useRef(null),{data:Ae,isLoading:Ue}=qJe(),{data:ut,isLoading:De}=Sxs(),{data:Dt,isLoading:he}=Txs(),{data:Ve,isLoading:nt}=UJe(),Qe=Pxs(),ke=Ixs(),ot=Lxs(),qe=Dxs(),lt=Oxs(),We=Rxs(),Ye=zxs(),[mt,Ze]=S.useState({}),He=bt=>{bt?(l(bt),d(bt.name),p(bt.description||""),v(bt.icon||"")):(l(null),d(""),p(""),v("")),a(!0)},et=async()=>{if(!i.trim()){fe.error("Please enter a category name");return}try{o?(await ke.mutateAsync({id:o.id,name:i,description:u||null,icon:g||null}),fe.success("Category updated successfully")):(await Qe.mutateAsync({name:i,description:u||null,icon:g||null,sort_order:((Ae==null?void 0:Ae.length)||0)+1}),fe.success("Category created successfully")),a(!1)}catch(bt){console.error("Error saving category:",bt),fe.error("Failed to save category")}},Rt=async()=>{if(_)try{await ot.mutateAsync(_),fe.success("Category deleted successfully"),b(null)}catch(bt){console.error("Error deleting category:",bt),fe.error("Failed to delete category")}},qt=bt=>{var ks;bt?(C(bt),I(bt.name),R(bt.description||""),q(bt.category_id),V(bt.points_cost.toString()),se(bt.item_type),Y(bt.file_url||""),ie(bt.preview_image_url||""),le(((ks=bt.max_quantity)==null?void 0:ks.toString())||""),be(bt.is_active)):(C(null),I(""),R(""),q(null),V(""),se("file"),Y(""),ie(""),le(""),be(!0)),w(!0)},ls=async(bt,ks)=>{ks==="file"?Ke(!0):Me(!0);try{const ir=bt.name.split(".").pop(),Rr=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ir}`,ca=`${ks==="file"?"items":"previews"}/${Rr}`,{error:ii}=await G.storage.from("reward-store").upload(ca,bt);if(ii)throw ii;const{data:{publicUrl:lo}}=G.storage.from("reward-store").getPublicUrl(ca);ks==="file"?Y(lo):ie(lo),fe.success("File uploaded successfully")}catch(ir){console.error("Error uploading file:",ir),fe.error("Failed to upload file")}finally{ks==="file"?Ke(!1):Me(!1)}},Kt=async()=>{if(!A.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 bt={name:A,description:L||null,category_id:$,points_cost:parseInt(U),item_type:X,file_url:te||null,preview_image_url:de||null,max_quantity:ae?parseInt(ae):null,current_quantity:ae?parseInt(ae):null,is_active:pe,created_by:t==null?void 0:t.id};N?(await lt.mutateAsync({id:N.id,...bt,current_quantity:N.max_quantity!==(ae?parseInt(ae):null)?ae?parseInt(ae):null:N.current_quantity}),fe.success("Item updated successfully")):(await qe.mutateAsync(bt),fe.success("Item created successfully")),w(!1)}catch(bt){console.error("Error saving item:",bt),fe.error("Failed to save item")}},Qt=async()=>{if(ye)try{await We.mutateAsync(ye),fe.success("Item deleted successfully"),we(null)}catch(bt){console.error("Error deleting item:",bt),fe.error("Failed to delete item")}},fs=async(bt,ks)=>{const ir=mt[bt];if(ir===void 0||ir===ks.toString())return;const Rr=parseInt(ir);if(isNaN(Rr)||Rr<0){fe.error("Please enter a valid positive number");return}try{await Ye.mutateAsync({id:bt,points:Rr}),fe.success("Points updated successfully"),Ze(ca=>{const ii={...ca};return delete ii[bt],ii})}catch(ca){console.error("Error updating points:",ca),fe.error("Failed to update points")}};return Ue||De||he||nt?e.jsx(Ms,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{className:"h-8 w-64"}),e.jsx(gs,{className:"h-96"})]})}):e.jsxs(Ms,{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(cl,{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(bt=>bt.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($h,{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((bt,ks)=>bt+ks.points_cost,0)/ut.length):0," pts"]})]})})]}),e.jsxs(ja,{value:s,onValueChange:r,children:[e.jsxs(va,{children:[e.jsx(Ns,{value:"items",children:"Items"}),e.jsx(Ns,{value:"categories",children:"Categories"}),e.jsx(Ns,{value:"purchases",children:"Purchases"}),e.jsx(Ns,{value:"point-settings",children:"Point Settings"})]}),e.jsx(zs,{value:"items",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Store Items"}),e.jsx(yr,{children:"Manage rewards that agents can purchase"})]}),e.jsxs(K,{onClick:()=>qt(),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(ao,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Item"}),e.jsx(jt,{children:"Category"}),e.jsx(jt,{className:"text-center",children:"Cost"}),e.jsx(jt,{className:"text-center",children:"Type"}),e.jsx(jt,{className:"text-center",children:"Quantity"}),e.jsx(jt,{className:"text-center",children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:ut.map(bt=>e.jsxs(js,{children:[e.jsx(it,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[bt.preview_image_url?e.jsx("img",{src:bt.preview_image_url,alt:bt.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(ao,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:bt.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:bt.description||"No description"})]})]})}),e.jsx(it,{children:bt.category?e.jsx(at,{variant:"outline",children:bt.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(it,{className:"text-center",children:e.jsxs(at,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),bt.points_cost]})}),e.jsx(it,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[bt.item_type==="file"?e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Io,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs capitalize",children:bt.item_type})]})}),e.jsx(it,{className:"text-center",children:bt.max_quantity!==null?e.jsxs("span",{className:bt.current_quantity===0?"text-red-500":"",children:[bt.current_quantity,"/",bt.max_quantity]}):e.jsx("span",{className:"text-muted-foreground",children:"Unlimited"})}),e.jsx(it,{className:"text-center",children:e.jsx(at,{variant:bt.is_active?"default":"secondary",children:bt.is_active?"Active":"Inactive"})}),e.jsx(it,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>qt(bt),children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>we(bt.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},bt.id))})]})})]})}),e.jsx(zs,{value:"categories",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Categories"}),e.jsx(yr,{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($h,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No categories yet. Add your first category!"})]}):e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{className:"text-center",children:"Items"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(En,{children:Ae.map(bt=>e.jsxs(js,{children:[e.jsxs(it,{className:"font-medium",children:[bt.icon&&e.jsx("span",{className:"mr-2",children:bt.icon}),bt.name]}),e.jsx(it,{className:"text-muted-foreground",children:bt.description||"—"}),e.jsx(it,{className:"text-center",children:(ut==null?void 0:ut.filter(ks=>ks.category_id===bt.id).length)||0}),e.jsx(it,{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(bt),children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(bt.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},bt.id))})]})})]})}),e.jsx(zs,{value:"purchases",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(wm,{className:"h-5 w-5"}),"Purchase History"]}),e.jsx(yr,{children:"View all reward redemptions by agents"})]}),e.jsx(Oe,{children:!Dt||Dt.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(wm,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No purchases yet."})]}):e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Date"}),e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Item"}),e.jsx(jt,{className:"text-center",children:"Points Spent"})]})}),e.jsx(En,{children:Dt.map(bt=>{var ks,ir,Rr,ca;return e.jsxs(js,{children:[e.jsx(it,{className:"text-muted-foreground",children:ws(new Date(bt.purchased_at),"MMM d, yyyy 'at' h:mm a")}),e.jsx(it,{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:((ks=bt.user)==null?void 0:ks.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:((ir=bt.user)==null?void 0:ir.email)||"—"})]})]})}),e.jsx(it,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(Rr=bt.item)!=null&&Rr.preview_image_url?e.jsx("img",{src:bt.item.preview_image_url,alt:bt.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(ao,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{children:((ca=bt.item)==null?void 0:ca.name)||"Deleted item"})]})}),e.jsx(it,{className:"text-center",children:e.jsxs(at,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),bt.points_spent]})})]},bt.id)})})]})})]})})]})]}),e.jsx(vs,{open:n,onOpenChange:a,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:bt=>d(bt.target.value),placeholder:"e.g., Templates, Resources"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"categoryDescription",children:"Description"}),e.jsx(Tr,{id:"categoryDescription",value:u,onChange:bt=>p(bt.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:g,onChange:bt=>v(bt.target.value),placeholder:"e.g., 📄, 🎁"})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{onClick:et,disabled:Qe.isPending||ke.isPending,children:Qe.isPending||ke.isPending?"Saving...":"Save"})]})]})}),e.jsx(vs,{open:j,onOpenChange:w,children:e.jsxs(ys,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:N?"Edit Item":"Add Item"}),e.jsx(Kr,{children:N?"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:A,onChange:bt=>I(bt.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(Tr,{id:"itemDescription",value:L,onChange:bt=>R(bt.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(tr,{value:$||"none",onValueChange:bt=>q(bt==="none"?null:bt),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select category"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No category"}),Ae==null?void 0:Ae.map(bt=>e.jsxs(At,{value:bt.id,children:[bt.icon&&`${bt.icon} `,bt.name]},bt.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:bt=>V(bt.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(tr,{value:X,onValueChange:se,children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{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:bt=>le(bt.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:bt=>Y(bt.target.value),placeholder:X==="file"?"Upload a file or paste URL":"Paste external link"}),X==="file"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var bt;return(bt=Te.current)==null?void 0:bt.click()},disabled:Ne,children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx("input",{ref:Te,type:"file",className:"hidden",onChange:bt=>{var ir;const ks=(ir=bt.target.files)==null?void 0:ir[0];ks&&ls(ks,"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:bt=>ie(bt.target.value),placeholder:"Upload an image or paste URL"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var bt;return(bt=Fe.current)==null?void 0:bt.click()},disabled:_e,children:e.jsx(Jo,{className:"h-4 w-4"})}),e.jsx("input",{ref:Fe,type:"file",accept:"image/*",className:"hidden",onChange:bt=>{var ir;const ks=(ir=bt.target.files)==null?void 0:ir[0];ks&&ls(ks,"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:pe,onCheckedChange:be}),e.jsx(ve,{htmlFor:"itemIsActive",children:"Active (visible to agents)"})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(K,{onClick:Kt,disabled:qe.isPending||lt.isPending,children:qe.isPending||lt.isPending?"Saving...":"Save"})]})]})}),e.jsx(tc,{open:!!_,onOpenChange:()=>b(null),children:e.jsxs(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Delete Category"}),e.jsx(Il,{children:"Are you sure you want to delete this category? Items in this category will become uncategorized."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:Rt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(tc,{open:!!ye,onOpenChange:()=>we(null),children:e.jsxs(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Delete Item"}),e.jsx(Il,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:Qt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s==="point-settings"&&e.jsxs(Ee,{className:"mt-4",children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fl,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx(zt,{children:"Point Reward Settings"}),e.jsx(yr,{children:"Configure how many points agents earn for various actions. Adjust these values to run double-points promotions."})]})]})}),e.jsx(Oe,{children:!Ve||Ve.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Fl,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No point settings configured."})]}):e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Action"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{className:"text-center w-32",children:"Points"}),e.jsx(jt,{className:"text-right w-24",children:"Save"})]})}),e.jsx(En,{children:Ve.map(bt=>e.jsxs(js,{children:[e.jsx(it,{children:e.jsx("p",{className:"font-medium",children:bt.action_name})}),e.jsx(it,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:bt.description})}),e.jsx(it,{className:"text-center",children:e.jsx(Re,{type:"number",min:"0",className:"w-20 mx-auto text-center",value:mt[bt.id]??bt.points.toString(),onChange:ks=>Ze(ir=>({...ir,[bt.id]:ks.target.value}))})}),e.jsx(it,{className:"text-right",children:e.jsx(K,{size:"sm",variant:"outline",disabled:mt[bt.id]===void 0||mt[bt.id]===bt.points.toString()||Ye.isPending,onClick:()=>fs(bt.id,bt.points),children:e.jsx(zu,{className:"h-4 w-4"})})})]},bt.id))})]})})]})]})}const ILe=()=>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"})]}),LLe=[{value:"template",label:"Templates"},{value:"brand",label:"Brand Assets"},{value:"listing",label:"Listing Assets"},{value:"social",label:"Social Media"},{value:"general",label:"General"}];function $xs(){const t=ns(),[s,r]=S.useState(!1),[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""}),{data:u,isLoading:p}=Ct({queryKey:["canva-integration"],queryFn:async()=>{const{data:C,error:A}=await G.from("canva_integration").select("*").eq("is_active",!0).maybeSingle();if(A)throw A;return C}}),{data:g}=Ct({queryKey:["brokerages-list"],queryFn:async()=>{const{data:C,error:A}=await G.from("brokerages").select("id, name").order("name");if(A)throw A;return C}}),{data:v}=Ct({queryKey:["canva-brokerage-folders"],queryFn:async()=>{const{data:C,error:A}=await G.from("canva_brokerage_folders").select("*, brokerages(name)").order("sort_order");if(A)throw A;return C}}),_=async()=>{var C;r(!0);try{const{data:A}=await G.auth.getSession(),I=(C=A==null?void 0:A.session)==null?void 0:C.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 V=se=>{var te,Y;se.origin===window.location.origin&&(((te=se.data)==null?void 0:te.type)==="canva-oauth-success"?(window.removeEventListener("message",V),fe.success("Canva connected successfully!"),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1)):((Y=se.data)==null?void 0:Y.type)==="canva-oauth-error"&&(window.removeEventListener("message",V),fe.error("Canva connection failed: "+(se.data.error||"Unknown error")),r(!1)))};window.addEventListener("message",V);const X=setInterval(()=>{U.closed&&(clearInterval(X),window.removeEventListener("message",V),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1))},500)}else throw new Error("Failed to get authorization URL")}catch(A){console.error("Canva connect error:",A);const I=(A==null?void 0:A.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=Ot({mutationFn:async C=>{var U;const{data:A}=await G.auth.getSession(),I=(U=A==null?void 0:A.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:C})}),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:C=>{fe.error(C.message||"Failed to disconnect Canva")}}),j=Ot({mutationFn:async C=>{const{error:A}=await G.from("canva_brokerage_folders").insert({brokerage_id:C.brokerage_id,folder_id:C.folder_id.trim(),folder_name:C.folder_name.trim(),folder_type:C.folder_type,description:C.description.trim()||null,sort_order:(v==null?void 0:v.length)||0});if(A)throw A},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")}),w=Ot({mutationFn:async C=>{const{error:A}=await G.from("canva_brokerage_folders").delete().eq("id",C);if(A)throw A},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),fe.success("Folder removed")},onError:()=>fe.error("Failed to remove folder")}),N=!!u;return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Lt,{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(ILe,{})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["Canva Connect",N&&e.jsx(at,{variant:"default",className:"text-xs",children:"Connected"}),e.jsx(at,{variant:"outline",className:"text-xs",children:"Admin Only"})]}),e.jsx(yr,{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(fi,{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(fi,{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(fi,{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"})]}),N?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(tc,{children:[e.jsx(Ih,{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(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Disconnect Canva?"}),e.jsx(Il,{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(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{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($h,{className:"h-4 w-4 text-primary"}),"Brokerage Folder Mappings",v&&v.length>0&&e.jsx(at,{variant:"secondary",className:"text-xs",children:v.length})]}),n?e.jsx(Rg,{className:"h-4 w-4"}):e.jsx(Vo,{className:"h-4 w-4"})]}),n&&e.jsxs("div",{className:"border-t p-3 space-y-2",children:[v&&v.length>0?v.map(C=>{var A,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:C.folder_name}),e.jsx(at,{variant:"outline",className:"text-xs shrink-0",children:((A=LLe.find(L=>L.value===C.folder_type))==null?void 0:A.label)||C.folder_type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(I=C.brokerages)==null?void 0:I.name," · ID: ",e.jsx("span",{className:"font-mono",children:C.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:()=>w.mutate(C.id),children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]},C.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(Eo,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx("div",{className:"mr-2",children:e.jsx(ILe,{})}),"Connect Canva",e.jsx(Ui,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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(tr,{value:i.brokerage_id,onValueChange:C=>d(A=>({...A,brokerage_id:C})),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select a brokerage…"})}),e.jsx(er,{children:g==null?void 0:g.map(C=>e.jsx(At,{value:C.id,children:C.name},C.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:C=>d(A=>({...A,folder_id:C.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:C=>d(A=>({...A,folder_name:C.target.value}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ve,{children:"Folder Type"}),e.jsxs(tr,{value:i.folder_type,onValueChange:C=>d(A=>({...A,folder_type:C})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:LLe.map(C=>e.jsx(At,{value:C.value,children:C.label},C.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:C=>d(A=>({...A,description:C.target.value}))})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>j.mutate(i),disabled:!i.brokerage_id||!i.folder_id||!i.folder_name||j.isPending,children:[j.isPending?e.jsx(Eo,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Add Folder"]})]})]})})]})}function qxs(){return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(_u,{title:"Integrations",description:"Manage platform-level service connections"}),e.jsx($xs,{})]})})}const Uxs={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 fE(t,s=18,r=10){return t.length<=s+r+3?t:`${t.slice(0,s)}…${t.slice(-r)}`}function Vxs(){var X,se,te,Y,de;const t=ns(),[s,r]=S.useState("Test Push"),[n,a]=S.useState("Testing web push notification"),[o,l]=S.useState("/community"),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[g,v]=S.useState({isSupported:typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window}),[_,b]=S.useState(null),[j,w]=S.useState(null),{data:N,isLoading:C}=Ct({queryKey:["push-notification-settings"],queryFn:async()=>{const{data:ie,error:ae}=await G.from("push_notification_settings").select("*").order("setting_key");if(ae)throw ae;return ie}}),{data:A,isLoading:I}=Ct({queryKey:["push-subscription-stats"],queryFn:async()=>{const{count:ie,error:ae}=await G.from("push_subscriptions").select("*",{count:"exact",head:!0});if(ae)throw ae;return{totalSubscriptions:ie||0}}}),L=Ot({mutationFn:async({settingKey:ie,isEnabled:ae})=>{const{error:le}=await G.from("push_notification_settings").update({is_enabled:ae}).eq("setting_key",ie);if(le)throw le},onSuccess:()=>{t.invalidateQueries({queryKey:["push-notification-settings"]}),fe.success("Notification setting updated")},onError:ie=>{fe.error("Failed to update setting: "+ie.message)}}),R=S.useMemo(()=>{var ie,ae;return g.isSupported?`perm=${g.permission??"unknown"} · controller=${g.controllerPresent?"yes":"no"} · sw=${((ie=g.serviceWorker)==null?void 0:ie.activeState)??"unknown"} · sub=${(ae=g.subscription)!=null&&ae.endpoint?"yes":"no"}`:"Push not supported in this browser."},[g]);S.useEffect(()=>{let ie=!0;const ae=async()=>{var ye,we,Ne,Ke,_e,Me,Te;const pe="serviceWorker"in navigator&&"PushManager"in window,be={isSupported:pe,permission:typeof Notification<"u"?Notification.permission:void 0,controllerPresent:!!((ye=navigator.serviceWorker)!=null&&ye.controller)};if(!pe){ie&&v(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 he,Ve,nt;return(((he=De.active)==null?void 0:he.scriptURL)||((Ve=De.waiting)==null?void 0:Ve.scriptURL)||((nt=De.installing)==null?void 0:nt.scriptURL)||"").includes("/sw.js")});if(ut){be.pushWorkerScriptUrl=((we=ut.active)==null?void 0:we.scriptURL)||((Ne=ut.waiting)==null?void 0:Ne.scriptURL)||((Ke=ut.installing)==null?void 0:Ke.scriptURL),be.serviceWorker={scope:ut.scope,activeState:(_e=ut.active)==null?void 0:_e.state};const De=await ut.pushManager.getSubscription();if(De){const Dt=De.toJSON();be.subscription={endpoint:Dt.endpoint,p256dh:(Me=Dt.keys)==null?void 0:Me.p256dh,auth:(Te=Dt.keys)==null?void 0:Te.auth}}}}catch(Fe){be.error=(Fe==null?void 0:Fe.message)||String(Fe)}ie&&v(be)};ae();const le=window.setInterval(ae,4e3);return()=>{ie=!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(ie){fe.error(`Local notification failed: ${(ie==null?void 0:ie.message)||String(ie)}`)}},q=async()=>{d(!0),b(null);try{const{data:ie,error:ae}=await G.functions.invoke("send-push-notification",{body:{title:s,body:n,url:o}});if(ae)throw ae;b({sent:ie==null?void 0:ie.sent,failed:ie==null?void 0:ie.failed,expiredCleaned:ie==null?void 0:ie.expiredCleaned,vapidPublicKey:ie==null?void 0:ie.vapidPublicKey}),(ie==null?void 0:ie.sent)>0?fe.success(`Test notification sent to ${ie.sent} subscriber(s)`):(ie==null?void 0:ie.failed)>0?fe.warning(`Notification failed for ${ie.failed} subscriber(s). ${ie.expired||0} expired subscriptions cleaned up.`):fe.info("No active subscriptions to send to")}catch(ie){console.error("Error sending test notification:",ie),b({error:(ie==null?void 0:ie.message)||String(ie)}),fe.error("Failed to send test notification: "+(ie.message||"Unknown error"))}finally{d(!1)}},U=async()=>{p(!0),w(null);try{const{data:ie,error:ae}=await G.functions.invoke("generate-vapid-keys",{body:{}});if(ae)throw ae;const le=ie==null?void 0:ie.publicKey,pe=ie==null?void 0:ie.privateKey;if(!le||!pe)throw new Error("generate-vapid-keys did not return keys");w({publicKey:le,privateKey:pe}),fe.success("Generated new VAPID keys. Update backend secrets, then clear + re-subscribe.")}catch(ie){console.error("Error generating VAPID keys:",ie),fe.error("Failed to generate VAPID keys: "+((ie==null?void 0:ie.message)||"Unknown error"))}finally{p(!1)}},V=Ot({mutationFn:async()=>{const{error:ie}=await G.from("push_subscriptions").delete().neq("id","00000000-0000-0000-0000-000000000000");if(ie)throw ie},onSuccess:()=>{fe.success("All subscriptions cleared. Users will need to re-enable notifications."),t.invalidateQueries({queryKey:["push-subscription-stats"]})},onError:ie=>{fe.error("Failed to clear subscriptions: "+ie.message)}});return e.jsx(Ms,{title:"Notification Settings",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{title:"Notification Settings",description:"Manage push notifications and test the notification system"}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Push Notification Subscribers"]}),e.jsx(yr,{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?"...":(A==null?void 0:A.totalSubscriptions)||0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"active subscriptions"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Fl,{className:"h-5 w-5"}),"Notification Types"]}),e.jsx(yr,{children:"Control which types of push notifications are sent to users"})]}),e.jsx(Oe,{children:C?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading settings..."}):e.jsx("div",{className:"space-y-4",children:N==null?void 0:N.map(ie=>{const ae=Uxs[ie.setting_key]||{label:ie.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:ie.description})]})]}),e.jsx(Br,{checked:ie.is_enabled,onCheckedChange:le=>L.mutate({settingKey:ie.setting_key,isEnabled:le}),disabled:L.isPending})]},ie.id)})})})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(cf,{className:"h-5 w-5"}),"Send Test Notification"]}),e.jsx(yr,{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}),g.error&&e.jsx("div",{className:"mt-2 text-destructive",children:g.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:g.vapidPublicKey?fE(g.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: ",(X=g.serviceWorker)!=null&&X.scope?fE(g.serviceWorker.scope,24,8):"none"]}),e.jsxs("div",{children:["active: ",((se=g.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=g.subscription)!=null&&te.endpoint?fE(g.subscription.endpoint,40,12):"none"]}),e.jsxs("div",{children:["p256dh: ",(Y=g.subscription)!=null&&Y.p256dh?fE(g.subscription.p256dh,22,10):"none"]}),e.jsxs("div",{children:["auth: ",(de=g.subscription)!=null&&de.auth?fE(g.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:ie=>r(ie.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(Tr,{id:"test-body",value:n,onChange:ie=>a(ie.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:ie=>l(ie.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(Ta,{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(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(jr,{className:"h-5 w-5"}),"Subscription Maintenance"]}),e.jsx(yr,{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:()=>V.mutate(),disabled:V.isPending,children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),V.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"})}),j&&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:j.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:j.privateKey})]})]})]})]})]})]})})}function Hxs(){const{toast:t}=Ea(),[s,r]=S.useState([]),[n,a]=S.useState({totalPresentations:0,totalViews:0,totalLeads:0,totalCtaClicks:0,agentsUsing:0}),[o,l]=S.useState(!0),{sortKey:i,sortDirection:d,handleSort:u,sortData:p}=qL("presentation_count","desc"),g=p(s,{name:b=>{var j;return((j=b.name)==null?void 0:j.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});S.useEffect(()=>{v()},[]);const v=async()=>{try{l(!0);const{data:b,error:j}=await G.rpc("get_admin_presentation_stats");if(j)throw j;if(!b||b.length===0){l(!1);return}const w=b.map(L=>L.owner_user_id),{data:N,error:C}=await G.from("profiles").select("id, name, email, avatar_url").in("id",w);if(C)throw C;const A=new Map((N==null?void 0:N.map(L=>[L.id,L]))||[]),I=b.map(L=>{const R=A.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:uf,color:"text-violet-600"},{label:"Total Views",value:n.totalViews,icon:ya,color:"text-emerald-600"},{label:"Total Leads",value:n.totalLeads,icon:fc,color:"text-amber-600"},{label:"CTA Clicks",value:n.totalCtaClicks,icon:t_,color:"text-rose-600"}];return e.jsx(Ms,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{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(gs,{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(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Sc,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Oe,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((b,j)=>e.jsx(gs,{className:"h-12 w-full"},j))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No presentations created yet."}):e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{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(En,{children:g.map(b=>{var w,N;const j=b.total_views>0?(b.total_leads/b.total_views*100).toFixed(1):"0.0";return e.jsxs(js,{children:[e.jsx(it,{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:((N=(w=b.name)==null?void 0:w.charAt(0))==null?void 0:N.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(it,{className:"text-center font-medium",children:b.presentation_count}),e.jsx(it,{className:"text-center",children:b.total_views.toLocaleString()}),e.jsx(it,{className:"text-center",children:b.total_leads>0?e.jsx(at,{variant:"secondary",children:b.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(it,{className:"text-center",children:b.total_cta_clicks}),e.jsx(it,{className:"text-center",children:e.jsxs("span",{className:Number(j)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[j,"%"]})})]},b.owner_user_id)})})]})})]})]})})}function Wxs(){const{toast:t}=Ea(),[s,r]=S.useState([]),[n,a]=S.useState({totalOpenHouses:0,totalVisitors:0,totalLeads:0,activeOpenHouses:0,agentsUsing:0}),[o,l]=S.useState(!0);S.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 g=u.map(w=>w.agent_id),{data:v,error:_}=await G.from("profiles").select("id, name, email, avatar_url").in("id",g);if(_)throw _;const b=new Map((v==null?void 0:v.map(w=>[w.id,w]))||[]),j=u.map(w=>{const N=b.get(w.agent_id);return{agent_id:w.agent_id,name:(N==null?void 0:N.name)||"Unknown",email:(N==null?void 0:N.email)||"",avatar_url:(N==null?void 0:N.avatar_url)||null,open_house_count:Number(w.open_house_count),total_visitors:Number(w.total_visitors),total_leads:Number(w.total_leads),active_count:Number(w.active_count)}});j.sort((w,N)=>N.total_visitors-w.total_visitors),r(j),a({totalOpenHouses:j.reduce((w,N)=>w+N.open_house_count,0),totalVisitors:j.reduce((w,N)=>w+N.total_visitors,0),totalLeads:j.reduce((w,N)=>w+N.total_leads,0),activeOpenHouses:j.reduce((w,N)=>w+N.active_count,0),agentsUsing:j.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:Vn,color:"text-violet-600"},{label:"Active Now",value:n.activeOpenHouses,icon:fi,color:"text-emerald-600"},{label:"Total Visitors",value:n.totalVisitors,icon:ya,color:"text-amber-600"},{label:"Leads Created",value:n.totalLeads,icon:fc,color:"text-rose-600"}];return e.jsx(Ms,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{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(gs,{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(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Sc,{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(gs,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Agent"}),e.jsx(jt,{className:"text-center",children:"Open Houses"}),e.jsx(jt,{className:"text-center",children:"Active"}),e.jsx(jt,{className:"text-center",children:"Visitors"}),e.jsx(jt,{className:"text-center",children:"Leads"}),e.jsx(jt,{className:"text-center",children:"Conversion"})]})}),e.jsx(En,{children:s.map(u=>{var g,v;const p=u.total_visitors>0?(u.total_leads/u.total_visitors*100).toFixed(1):"0.0";return e.jsxs(js,{children:[e.jsx(it,{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:((v=(g=u.name)==null?void 0:g.charAt(0))==null?void 0:v.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(it,{className:"text-center font-medium",children:u.open_house_count}),e.jsx(it,{className:"text-center",children:u.active_count>0?e.jsx(at,{variant:"secondary",className:"bg-emerald-100 text-emerald-700",children:u.active_count}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(it,{className:"text-center",children:u.total_visitors.toLocaleString()}),e.jsx(it,{className:"text-center",children:u.total_leads>0?e.jsx(at,{variant:"secondary",children:u.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(it,{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 Gxs(){const[t]=Ac(),s=Lr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Processing connection...");return S.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:g,error:v}=await G.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p}});if(v)throw v;if(g!=null&&g.success)n("success"),o(g.message||"Accounts connected successfully!"),fe.success(g.message||"Social accounts connected!");else throw new Error((g==null?void 0:g.error)||"Failed to connect accounts")}catch(g){console.error("Callback error:",g),n("error"),o(g.message||"Failed to complete connection"),fe.error(g.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(Lt,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4",children:[r==="loading"&&e.jsx(As,{className:"h-12 w-12 animate-spin text-primary"}),r==="success"&&e.jsx(fi,{className:"h-12 w-12 text-green-500"}),r==="error"&&e.jsx(wc,{className:"h-12 w-12 text-destructive"})]}),e.jsxs(zt,{children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(yr,{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 Kxs(){const t=ns(),[s,r]=S.useState(""),[n,a]=S.useState(""),[o,l]=S.useState([]),i=S.useRef(null),{data:d,isLoading:u}=Ct({queryKey:["prospect-emails"],queryFn:async()=>{const{data:w,error:N}=await G.from("prospect_emails").select("*").order("sent_at",{ascending:!1});if(N)throw N;return w}}),p={total:(d==null?void 0:d.length)||0,sent:(d==null?void 0:d.filter(w=>w.status==="sent").length)||0,converted:(d==null?void 0:d.filter(w=>w.status==="converted").length)||0,conversionRate:d!=null&&d.length?Math.round(d.filter(w=>w.status==="converted").length/d.length*100):0},g=Ot({mutationFn:async w=>{const{data:N,error:C}=await G.functions.invoke("send-prospect-email",{body:{emails:w}});if(C)throw C;return N},onSuccess:w=>{t.invalidateQueries({queryKey:["prospect-emails"]}),fe.success(`${w.sent} email${w.sent>1?"s":""} sent successfully!`),r(""),a(""),l([])},onError:w=>{fe.error("Failed to send: "+w.message)}}),v=Ot({mutationFn:async()=>{var A,I;const{data:{user:w}}=await G.auth.getUser();if(!(w!=null&&w.email))throw new Error("Could not get your email");const{data:N,error:C}=await G.functions.invoke("send-prospect-email",{body:{emails:[{email:w.email,first_name:(I=(A=w.user_metadata)==null?void 0:A.name)==null?void 0:I.split(" ")[0]}],test_mode:!0}});if(C)throw C;return N},onSuccess:()=>{fe.success("Test email sent to your inbox!")},onError:w=>{fe.error("Failed to send test: "+w.message)}}),_=()=>{if(!s.trim()){fe.error("Please enter an email address");return}if(d==null?void 0:d.find(N=>N.email.toLowerCase()===s.trim().toLowerCase())){fe.error("This email has already been prospected");return}g.mutate([{email:s.trim(),first_name:n.trim()||void 0}])},b=w=>{var A;const N=(A=w.target.files)==null?void 0:A[0];if(!N)return;const C=new FileReader;C.onload=I=>{var U,V;const R=((U=I.target)==null?void 0:U.result).split(` `).filter(X=>X.trim()),$=[],q=(V=R[0])!=null&&V.toLowerCase().includes("email")?1:0;for(let X=q;Xde.trim().replace(/"/g,"")),te=se[0],Y=se[1];te&&te.includes("@")&&$.push({email:te,first_name:Y||void 0})}l($),fe.success(`${$.length} entries loaded from CSV`)},C.readAsText(N),i.current&&(i.current.value="")},j=()=>{if(o.length===0){fe.error("No entries to send");return}const w=new Set((d==null?void 0:d.map(C=>C.email.toLowerCase()))||[]),N=o.filter(C=>!w.has(C.email.toLowerCase()));if(N.length===0){fe.error("All emails have already been prospected");return}N.lengthv.mutate(),disabled:v.isPending,className:"gap-2 ml-4 shrink-0",children:[v.isPending?e.jsx(As,{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(ja,{defaultValue:"single",children:[e.jsxs(va,{className:"mb-4",children:[e.jsxs(Ns,{value:"single",children:[e.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Single Send"]}),e.jsxs(Ns,{value:"bulk",children:[e.jsx(Xa,{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:w=>r(w.target.value),onKeyDown:w=>w.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:w=>a(w.target.value),onKeyDown:w=>w.key==="Enter"&&_()})]}),e.jsxs(K,{onClick:_,disabled:g.isPending,className:"gap-2",children:[g.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(Ta,{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 w;return(w=i.current)==null?void 0:w.click()},className:"gap-2",children:[e.jsx(Sn,{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(at,{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((w,N)=>e.jsxs("div",{className:"text-muted-foreground",children:[w.email,w.first_name?` — ${w.first_name}`:""]},N)),o.length>20&&e.jsxs("div",{className:"text-muted-foreground/60",children:["...and ",o.length-20," more"]})]}),e.jsxs(K,{onClick:j,disabled:g.isPending,className:"gap-2",children:[g.isPending?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(Ta,{className:"h-4 w-4"}),"Send ",o.length," Invites"]})]})]})})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),"Prospect Log"]}),e.jsx(yr,{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((w,N)=>e.jsx(gs,{className:"h-12 w-full"},N))}):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(w=>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:w.email}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:w.first_name||"—"}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:ws(new Date(w.sent_at),"MMM d, yyyy")}),e.jsx("td",{className:"py-3 px-4",children:w.status==="converted"?e.jsxs(at,{className:"bg-green-500/10 text-green-700 hover:bg-green-500/20 border-0",children:[e.jsx(la,{className:"h-3 w-3 mr-1"}),"Converted"]}):e.jsxs(at,{variant:"secondary",className:"gap-1",children:[e.jsx(In,{className:"h-3 w-3"}),"Sent"]})}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:w.converted_at?ws(new Date(w.converted_at),"MMM d, yyyy"):"—"})]},w.id))})]})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Uh,{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 Tce(t){const s=ns(),{toast:r}=Ea(),n=Ct({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=Ct({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=Ot({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:g,error:v}=await G.from("recruit_prospects").insert(p).select().single();if(v)throw v;return g},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]}),r({title:"Prospect added"})},onError:d=>r({title:"Error",description:d.message,variant:"destructive"})}),l=Ot({mutationFn:async({id:d,...u})=>{const{data:p,error:g}=await G.from("recruit_prospects").update({...u,updated_at:new Date().toISOString()}).eq("id",d).select().single();if(g)throw g;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]})},onError:d=>r({title:"Error",description:d.message,variant:"destructive"})}),i=Ot({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 Zxs(t){const s=ns(),{toast:r}=Ea(),n=Ct({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=Ot({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 DLe=(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 VJe({open:t,onOpenChange:s,stages:r,defaultStageId:n,onSubmit:a,isSubmitting:o}){const[l,i]=S.useState(DLe(n,r)),d=p=>g=>i(v=>({...v,[p]:g.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(DLe(n,r)),s(!1)};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Add Recruit Prospect"})}),e.jsxs("form",{onSubmit:u,className:"space-y-4",children:[e.jsxs(ja,{defaultValue:"basic",className:"w-full",children:[e.jsxs(va,{className:"grid w-full grid-cols-4",children:[e.jsx(Ns,{value:"basic",children:"Basic Info"}),e.jsx(Ns,{value:"production",children:"Production"}),e.jsx(Ns,{value:"social",children:"Social & Web"}),e.jsx(Ns,{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(tr,{value:l.stage_id,onValueChange:p=>i(g=>({...g,stage_id:p})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{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(Tr,{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 V0e=[{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 Yxs(t){return Ct({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 Xxs(t){return Ct({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 Qxs(){const t=ns(),{toast:s}=Ea();return Ot({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 HJe(){const t=ns();return Ot({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 WJe(t){return Ct({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 Jxs(){const t=ns(),{toast:s}=Ea();return Ot({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 eys(){const t=ns();return Ot({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 tys({prospectId:t,prospectName:s,brokerageId:r}){var U;const{data:n=[],isLoading:a}=Xxs(t),{data:o=[]}=WJe(r),l=Qxs(),i=nS(),d=HJe(),[u,p]=S.useState("idle"),[g,v]=S.useState(0),[_,b]=S.useState(0),[j,w]=S.useState(""),[N,C]=S.useState(""),[A,I]=S.useState(!1),L=((U=o.find(V=>V.id===j))==null?void 0:U.script_text)||"",R=()=>{p("idle"),v(0),b(0),w(""),C("")},$=S.useCallback(async(V,X)=>{p("uploading");try{const se=`Recruiting: ${s}`,{videoId:te,libraryId:Y}=await GL(se),{uploadUrl:de,apiKey:ie}=await KL(te),ae=new XMLHttpRequest;ae.upload.onprogress=_e=>{_e.lengthComputable&&v(_e.loaded/_e.total*100)},await new Promise((_e,Me)=>{ae.onload=()=>ae.status>=200&&ae.status<300?_e():Me(new Error("Upload failed")),ae.onerror=()=>Me(new Error("Upload failed")),ae.open("PUT",de),ae.setRequestHeader("AccessKey",ie),ae.send(V)}),p("processing");let le=0;const pe=Date.now(),be=9e4,ye=`https://iframe.mediadelivery.net/embed/${Y}/${te}`;for(;le<4&&(await new Promise(Me=>setTimeout(Me,3e3)),!(Date.now()-pe>be));){const _e=await C3(te);if(le=_e.status,b(_e.encodeProgress||0),le===5||le===6)throw new Error("Video processing failed")}const we=await C3(te),Ne=(we.storageSize||V.size)/(1024*1024),Ke=await i.mutateAsync({bunny_video_id:te,playback_url:we.directPlayUrl||ye,thumbnail_url:we.thumbnailUrl,preview_url:we.previewUrl||null,duration_seconds:we.length||X,file_size_mb:Ne,title:se,status:le>=4?"ready":"processing",touch_type:"recruiting"});await l.mutateAsync({prospect_id:t,video_id:Ke.id,brokerage_id:r,message:N||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,N,i,l]),q=V=>{V&&(navigator.clipboard.writeText(`${window.location.origin}/recruit-video/${V}`),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(vs,{open:A,onOpenChange:V=>{!V&&(u==="uploading"||u==="processing")||(I(V),V||R())},children:[e.jsx(Ai,{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(ys,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ss,{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(tr,{value:j,onValueChange:w,children:[e.jsx(Js,{className:"mt-1",children:e.jsx(sr,{placeholder:"No script — speak freely"})}),e.jsxs(er,{children:[e.jsx(At,{value:"none",children:"No script"}),o.map(V=>{var X;return e.jsx(At,{value:V.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[V.title,e.jsx(at,{variant:"outline",className:"text-[9px] ml-1",children:(X=V0e.find(se=>se.value===V.category))==null?void 0:X.label})]})},V.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(Tr,{value:N,onChange:V=>C(V.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(Mce,{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(Mi,{value:g,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(g),"%"]})]}),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(Mi,{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(dl,{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(V=>{var X,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:(X=V.video)!=null&&X.thumbnail_url?e.jsx("img",{src:V.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=V.video)==null?void 0:se.title)||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[V.view_count>0?e.jsxs(at,{variant:"secondary",className:"text-[9px] h-4",children:[e.jsx(ya,{className:"h-2.5 w-2.5 mr-0.5"}),V.view_count]}):V.sent_at?e.jsxs(at,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(Ta,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]}):e.jsxs(at,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(In,{className:"h-2.5 w-2.5 mr-0.5"}),"Draft"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ws(new Date(V.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(V.share_token),children:e.jsx(ai,{className:"h-3 w-3"})}),!V.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>d.mutate({id:V.id,sent_via:"email"}),children:e.jsx(Ta,{className:"h-3 w-3"})})]})]},V.id)})})]})}const OLe=[{value:"call",label:"Phone Call",icon:Zn},{value:"email",label:"Email",icon:br},{value:"text",label:"Text Message",icon:io},{value:"meeting",label:"Meeting",icon:on},{value:"note",label:"Note",icon:Sn}];function Xm({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 CR({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(rn,{className:"h-3 w-3 opacity-50"})]}):null}function Wl({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 GJe({prospect:t,stages:s,brokerageId:r,open:n,onOpenChange:a,onUpdate:o,onDelete:l}){const{activities:i,addActivity:d}=Zxs((t==null?void 0:t.id)||null),[u,p]=S.useState({type:"note",title:"",description:""}),[g,v]=S.useState(!1),[_,b]=S.useState(!1),[j,w]=S.useState({});if(!t)return null;const N=()=>{var X,se;w({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:((X=t.experience_years)==null?void 0:X.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)},C=()=>{const X={id:t.id};for(const[se,te]of Object.entries(j))se==="experience_years"||se==="last_year_transactions"?X[se]=te?parseInt(te):null:X[se]=te||null;o(X),b(!1)},A=()=>b(!1),I=X=>se=>w(te=>({...te,[X]: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:""}),v(!1))},R=s.find(X=>X.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,V=t.birthday||t.spouse_name||t.interests||t.referred_by;return e.jsx(fM,{open:n,onOpenChange:X=>{X||b(!1),a(X)},children:e.jsx(tS,{className:"w-full sm:max-w-lg p-0",children:e.jsx(Fi,{className:"h-full",children:e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsx(gM,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(xM,{className:"text-xl",children:[t.first_name," ",t.last_name]}),R&&e.jsx(at,{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:A,children:e.jsx(Ur,{className:"h-4 w-4"})}),e.jsx(K,{variant:"default",size:"icon",onClick:C,children:e.jsx(zu,{className:"h-4 w-4"})})]}):e.jsx(K,{variant:"ghost",size:"icon",onClick:N,title:"Edit prospect",children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsxs(tc,{children:[e.jsx(Ih,{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(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Delete prospect?"}),e.jsx(Il,{children:"This will permanently remove this prospect and all their activity history."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{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(Zn,{className:"h-3.5 w-3.5"})," ",t.phone]}),$&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Ti,{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(tr,{value:t.stage_id||"",onValueChange:X=>o({id:t.id,stage_id:X}),children:[e.jsx(Js,{className:"mt-1",children:e.jsx(sr,{})}),e.jsx(er,{children:s.map(X=>e.jsx(At,{value:X.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:X.color}}),X.name]})},X.id))})]})]}),e.jsxs(ja,{defaultValue:"details",className:"w-full",children:[e.jsxs(va,{className:"grid w-full grid-cols-4 h-8 text-xs",children:[e.jsx(Ns,{value:"details",className:"text-xs",children:"Details"}),e.jsx(Ns,{value:"production",className:"text-xs",children:"Production"}),e.jsx(Ns,{value:"social",className:"text-xs",children:"Social"}),e.jsx(Ns,{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(Wl,{label:"First Name",value:j.first_name,onChange:I("first_name")}),e.jsx(Wl,{label:"Last Name",value:j.last_name,onChange:I("last_name")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Wl,{label:"Email",value:j.email,onChange:I("email"),type:"email"}),e.jsx(Wl,{label:"Phone",value:j.phone,onChange:I("phone")})]}),e.jsx(Wl,{label:"Current Brokerage",value:j.current_brokerage,onChange:I("current_brokerage")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Wl,{label:"License #",value:j.license_number,onChange:I("license_number")}),e.jsx(Wl,{label:"Experience (years)",value:j.experience_years,onChange:I("experience_years"),type:"number"})]}),e.jsx(Wl,{label:"Address",value:j.address,onChange:I("address"),placeholder:"Street address"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(Wl,{label:"City",value:j.city,onChange:I("city")}),e.jsx(Wl,{label:"State",value:j.state,onChange:I("state")}),e.jsx(Wl,{label:"Zip",value:j.zip_code,onChange:I("zip_code")})]}),e.jsx(Wl,{label:"Source",value:j.source,onChange:I("source")}),e.jsx(Wl,{label:"Referred By",value:j.referred_by,onChange:I("referred_by")}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Notes"}),e.jsx(Tr,{value:j.notes,onChange:X=>w(se=>({...se,notes:X.target.value})),rows:3,className:"mt-1 text-sm"})]})]}),e.jsxs(zs,{value:"production",className:"mt-3 space-y-3",children:[e.jsx(Wl,{label:"Annual Production",value:j.annual_production,onChange:I("annual_production"),placeholder:"e.g. $5M"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Wl,{label:"Last Year Volume",value:j.last_year_volume,onChange:I("last_year_volume"),placeholder:"e.g. $8.2M"}),e.jsx(Wl,{label:"Last Year Transactions",value:j.last_year_transactions,onChange:I("last_year_transactions"),type:"number",placeholder:"e.g. 24"})]}),e.jsx(Wl,{label:"Avg Sale Price",value:j.avg_sale_price,onChange:I("avg_sale_price"),placeholder:"e.g. $350K"}),e.jsx(Wl,{label:"Specialties / Niche",value:j.specialties,onChange:I("specialties"),placeholder:"e.g. Luxury, Investment"})]}),e.jsxs(zs,{value:"social",className:"mt-3 space-y-3",children:[e.jsx(Wl,{label:"LinkedIn URL",value:j.linkedin_url,onChange:I("linkedin_url"),type:"url",placeholder:"https://linkedin.com/in/..."}),e.jsx(Wl,{label:"Website URL",value:j.website_url,onChange:I("website_url"),type:"url",placeholder:"https://..."}),e.jsx(Wl,{label:"Instagram Handle",value:j.instagram_handle,onChange:I("instagram_handle"),placeholder:"@handle"}),e.jsx(Wl,{label:"Facebook URL",value:j.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(Wl,{label:"Birthday",value:j.birthday,onChange:I("birthday"),type:"date"}),e.jsx(Wl,{label:"Spouse / Partner",value:j.spouse_name,onChange:I("spouse_name")}),e.jsx(Wl,{label:"Interests / Hobbies",value:j.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(Xm,{label:"Current Brokerage",value:t.current_brokerage}),e.jsx(Xm,{label:"License #",value:t.license_number}),e.jsx(Xm,{label:"Experience",value:t.experience_years!=null?`${t.experience_years} years`:null}),e.jsx(Xm,{label:"Referred By",value:t.referred_by}),e.jsx(Xm,{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(Xm,{label:"Annual Production",value:t.annual_production}),e.jsx(Xm,{label:"Last Year Volume",value:t.last_year_volume}),e.jsx(Xm,{label:"Last Year Transactions",value:t.last_year_transactions}),e.jsx(Xm,{label:"Avg Sale Price",value:t.avg_sale_price}),e.jsx(Xm,{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(CR,{label:"LinkedIn",url:t.linkedin_url,icon:Pm}),e.jsx(CR,{label:"Website",url:t.website_url,icon:Am}),t.instagram_handle&&e.jsx(CR,{label:t.instagram_handle,url:`https://instagram.com/${t.instagram_handle.replace("@","")}`,icon:Vd}),e.jsx(CR,{label:"Facebook",url:t.facebook_url,icon:Ud})]}):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:V?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Xm,{label:"Birthday",value:t.birthday?ws(new Date(t.birthday+"T00:00:00"),"MMMM d, yyyy"):null,icon:ao}),e.jsx(Xm,{label:"Spouse / Partner",value:t.spouse_name,icon:Ni}),e.jsx("div",{className:"col-span-2",children:e.jsx(Xm,{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(tys,{prospectId:t.id,prospectName:`${t.first_name} ${t.last_name||""}`,brokerageId:r}),e.jsx(sc,{}),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:()=>v(!g),children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Log Activity"]})]}),g&&e.jsxs("div",{className:"border rounded-lg p-3 mb-4 space-y-3 bg-muted/30",children:[e.jsxs(tr,{value:u.type,onValueChange:X=>p(se=>({...se,type:X})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:OLe.map(X=>e.jsx(At,{value:X.value,children:X.label},X.value))})]}),e.jsx(Re,{placeholder:"Subject / Title",value:u.title,onChange:X=>p(se=>({...se,title:X.target.value}))}),e.jsx(Tr,{placeholder:"Details (optional)",value:u.description,onChange:X=>p(se=>({...se,description:X.target.value})),rows:2}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>v(!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(X=>{const se=OLe.find(Y=>Y.value===X.activity_type),te=(se==null?void 0:se.icon)||Sn;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:X.title}),X.description&&e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:X.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ws(new Date(X.created_at),"MMM d, yyyy h:mm a")})]})]},X.id)})]})]})]})})})})}const RLe=["first_name","last_name","email","phone","current_brokerage","license_number","experience_years","annual_production","notes"];function KJe({open:t,onOpenChange:s,brokerageId:r,stages:n}){var V;const{toast:a}=Ea(),o=ns(),l=S.useRef(null),[i,d]=S.useState([]),[u,p]=S.useState([]),[g,v]=S.useState({}),[_,b]=S.useState(((V=n[0])==null?void 0:V.id)||""),[j,w]=S.useState(!1),[N,C]=S.useState("upload"),[A,I]=S.useState(0),L=()=>{d([]),p([]),v({}),C("upload"),I(0)},R=X=>{var Y;const se=(Y=X.target.files)==null?void 0:Y[0];if(!se)return;const te=new FileReader;te.onload=de=>{var ye;const ae=((ye=de.target)==null?void 0:ye.result).split(/\r?\n/).filter(we=>we.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 pe={};le.forEach((we,Ne)=>{const Ke=we.toLowerCase().replace(/[^a-z]/g,"_").replace(/_+/g,"_"),_e=RLe.find(Me=>Ke.includes(Me)||Me.includes(Ke)||Me==="first_name"&&(Ke.includes("first")||Ke==="name")||Me==="last_name"&&Ke.includes("last")||Me==="current_brokerage"&&(Ke.includes("brokerage")||Ke.includes("company"))||Me==="license_number"&&Ke.includes("license")||Me==="experience_years"&&(Ke.includes("experience")||Ke.includes("years"))||Me==="annual_production"&&(Ke.includes("production")||Ke.includes("volume")));_e&&(pe[String(Ne)]=_e)}),v(pe);const be=ae.slice(1).map(we=>{const Ne=$(we),Ke={};return le.forEach((_e,Me)=>{Ke[String(Me)]=Ne[Me]||""}),Ke});d(be),C("map")},te.readAsText(se)},$=X=>{const se=[];let te="",Y=!1;for(const de of X)de==='"'?Y=!Y:de===","&&!Y?(se.push(te.trim()),te=""):te+=de;return se.push(te.trim()),se},q=async()=>{w(!0);try{const{data:{user:X}}=await G.auth.getUser();if(!X)throw new Error("Not authenticated");const se=i.map(Y=>{const de={brokerage_id:r,created_by:X.id,stage_id:_,source:"csv_import",first_name:"Unknown"};return Object.entries(g).forEach(([ie,ae])=>{var pe;const le=(pe=Y[ie])==null?void 0:pe.trim();le&&(ae==="experience_years"?de[ae]=parseInt(le)||null:de[ae]=le)}),de});let te=0;for(let Y=0;Y{const X=`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([X],{type:"text/csv"}),te=URL.createObjectURL(se),Y=document.createElement("a");Y.href=te,Y.download="recruit-prospects-template.csv",Y.click(),URL.revokeObjectURL(te)};return e.jsx(vs,{open:t,onOpenChange:X=>{X||L(),s(X)},children:e.jsxs(ys,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Import Prospects from CSV"})}),N==="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(N0,{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 X;return(X=l.current)==null?void 0:X.click()},children:[e.jsx(Xa,{className:"h-4 w-4 mr-2"})," Choose File"]})]}),e.jsx(K,{variant:"link",className:"text-xs",onClick:U,children:"Download CSV template"})]}),N==="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(tr,{value:_,onValueChange:b,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{})}),e.jsx(er,{children:n.map(X=>e.jsx(At,{value:X.id,children:X.name},X.id))})]})]})]}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{className:"w-[140px]",children:"CSV Column"}),e.jsx(jt,{className:"w-[160px]",children:"Map To"}),e.jsx(jt,{children:"Preview"})]})}),e.jsx(En,{children:u.map((X,se)=>{var te;return e.jsxs(js,{children:[e.jsx(it,{className:"font-medium text-xs",children:X}),e.jsx(it,{children:e.jsxs(tr,{value:g[String(se)]||"skip",onValueChange:Y=>v(de=>({...de,[String(se)]:Y==="skip"?"":Y})),children:[e.jsx(Js,{className:"h-8 text-xs",children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"skip",children:"— Skip —"}),RLe.map(Y=>e.jsx(At,{value:Y,children:Y.replace(/_/g," ")},Y))]})]})}),e.jsx(it,{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:((te=i[0])==null?void 0:te[String(se)])||"—"})]},se)})})]})}),!Object.values(g).includes("first_name")&&e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-sm",children:[e.jsx(Qo,{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:j||!Object.values(g).includes("first_name"),children:j?"Importing...":`Import ${i.length} Prospects`})]})]}),N==="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(fa,{className:"h-6 w-6 text-green-600"})}),e.jsxs("p",{className:"font-semibold",children:[A," prospects imported successfully!"]}),e.jsx(K,{onClick:()=>{L(),s(!1)},children:"Close"})]})]})})}function sys({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=Tce(t),[i,d]=S.useState(!1),[u,p]=S.useState(),[g,v]=S.useState(null),[_,b]=S.useState(!1),[j,w]=S.useState(!1),[N,C]=S.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 A=U=>r.filter(V=>V.stage_id===U),I=(U,V)=>{C(V),U.dataTransfer.effectAllowed="move"},L=U=>{U.preventDefault(),U.dataTransfer.dropEffect="move"},R=(U,V)=>{U.preventDefault(),N&&(o.mutate({id:N,stage_id:V}),C(null))},$=U=>{p(U),d(!0)},q=U=>{v(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:()=>w(!0),children:[e.jsx(Xa,{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(Fi,{className:"w-full",children:[e.jsx("div",{className:"flex gap-4 pb-4",style:{minWidth:s.length*300},children:s.map(U=>{const V=A(U.id);return e.jsxs("div",{className:"w-[280px] flex-shrink-0 flex flex-col",onDragOver:L,onDrop:X=>R(X,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(at,{variant:"secondary",className:"text-xs h-5 px-1.5",children:V.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:V.map(X=>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,X.id),onClick:()=>q(X),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ru,{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:[X.first_name," ",X.last_name]})]}),X.current_brokerage&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Ca,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:X.current_brokerage})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[X.email&&e.jsx(br,{className:"h-3 w-3 text-muted-foreground"}),X.phone&&e.jsx(Zn,{className:"h-3 w-3 text-muted-foreground"}),X.experience_years!=null&&e.jsxs(at,{variant:"secondary",className:"text-[10px] h-4 px-1",children:[X.experience_years,"yr"]})]})]})]})},X.id))})]},U.id)})}),e.jsx(Poe,{orientation:"horizontal"})]}),e.jsx(VJe,{open:i,onOpenChange:d,stages:s,defaultStageId:u,onSubmit:U=>a.mutate(U),isSubmitting:a.isPending}),e.jsx(GJe,{prospect:g,stages:s,brokerageId:t,open:_,onOpenChange:b,onUpdate:U=>{o.mutate(U),v(V=>V?{...V,...U}:null)},onDelete:U=>l.mutate(U)}),e.jsx(KJe,{open:j,onOpenChange:w,brokerageId:t,stages:s})]})}function rys({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=Tce(t),[i,d]=S.useState(!1),[u,p]=S.useState(null),[g,v]=S.useState(!1),[_,b]=S.useState(!1),[j,w]=S.useState(""),[N,C]=S.useState("all"),[A,I]=S.useState(null),[L,R]=S.useState("asc"),$=X=>{A===X?R(se=>se==="asc"?"desc":"asc"):(I(X),R("asc"))},q=({column:X})=>A!==X?e.jsx(Vc,{className:"h-3.5 w-3.5 ml-1 text-muted-foreground/50"}):L==="asc"?e.jsx(qd,{className:"h-3.5 w-3.5 ml-1 text-primary"}):e.jsx(Ju,{className:"h-3.5 w-3.5 ml-1 text-primary"}),U=X=>s.find(se=>se.id===X),V=S.useMemo(()=>{let X=r.filter(se=>{var de,ie;const te=!j||`${se.first_name} ${se.last_name}`.toLowerCase().includes(j.toLowerCase())||((de=se.email)==null?void 0:de.toLowerCase().includes(j.toLowerCase()))||((ie=se.current_brokerage)==null?void 0:ie.toLowerCase().includes(j.toLowerCase())),Y=N==="all"||se.stage_id===N;return te&&Y});return A&&(X=[...X].sort((se,te)=>{var ae,le;let Y=null,de=null;switch(A){case"name":Y=`${se.first_name} ${se.last_name||""}`.toLowerCase(),de=`${te.first_name} ${te.last_name||""}`.toLowerCase();break;case"stage":Y=((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":Y=(se.current_brokerage||"").toLowerCase(),de=(te.current_brokerage||"").toLowerCase();break;case"experience":Y=se.experience_years??-1,de=te.experience_years??-1;break;case"production":Y=(se.annual_production||"").toLowerCase(),de=(te.annual_production||"").toLowerCase();break;case"source":Y=(se.source||"").toLowerCase(),de=(te.source||"").toLowerCase();break;default:return 0}if(Y===de)return 0;if(Y==null)return 1;if(de==null)return-1;const ie=Yw(X.target.value),className:"pl-8"})]}),e.jsxs(tr,{value:N,onValueChange:C,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{placeholder:"All stages"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All stages"}),s.map(X=>e.jsx(At,{value:X.id,children:X.name},X.id))]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>b(!0),children:[e.jsx(Xa,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{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(jt,{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(jt,{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(jt,{className:"hidden md:table-cell",children:"Contact"}),e.jsx(jt,{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(jt,{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(jt,{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(jt,{className:"w-[50px]"})]})}),e.jsx(En,{children:V.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:8,className:"text-center text-muted-foreground py-8",children:"No prospects found"})}):V.map(X=>{const se=U(X.stage_id);return e.jsxs(js,{className:"cursor-pointer",onClick:()=>{p(X),v(!0)},children:[e.jsxs(it,{className:"font-medium",children:[X.first_name," ",X.last_name]}),e.jsx(it,{children:se?e.jsxs(at,{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(it,{className:"hidden md:table-cell",children:X.current_brokerage?e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(Ca,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate max-w-[150px]",children:X.current_brokerage})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(it,{className:"hidden md:table-cell",children:e.jsxs("div",{className:"flex items-center gap-2",children:[X.email&&e.jsx(br,{className:"h-3.5 w-3.5 text-muted-foreground"}),X.phone&&e.jsx(Zn,{className:"h-3.5 w-3.5 text-muted-foreground"}),!X.email&&!X.phone&&e.jsx("span",{className:"text-muted-foreground",children:"—"})]})}),e.jsx(it,{className:"hidden lg:table-cell",children:X.experience_years!=null?`${X.experience_years} yr`:"—"}),e.jsx(it,{className:"hidden lg:table-cell",children:X.annual_production||"—"}),e.jsx(it,{className:"hidden lg:table-cell",children:X.source?e.jsx(at,{variant:"secondary",className:"text-xs",children:X.source}):"—"}),e.jsx(it,{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(X.id)},children:e.jsx(jr,{className:"h-3.5 w-3.5"})})})]},X.id)})})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[V.length," of ",r.length," prospects"]}),e.jsx(VJe,{open:i,onOpenChange:d,stages:s,onSubmit:X=>a.mutate(X),isSubmitting:a.isPending}),e.jsx(GJe,{prospect:u,stages:s,brokerageId:t,open:g,onOpenChange:v,onUpdate:X=>{o.mutate(X),p(se=>se?{...se,...X}:null)},onDelete:X=>l.mutate(X)}),e.jsx(KJe,{open:_,onOpenChange:b,brokerageId:t,stages:s})]})}function nys({brokerageId:t}){const{stages:s,prospects:r,isLoading:n}=Tce(t),a=S.useMemo(()=>{if(!s.length||!r.length)return null;const o=r.length,l=s.find(N=>N.name==="Signed"),i=s.find(N=>N.name==="Onboarded"),d=r.filter(N=>N.stage_id===(l==null?void 0:l.id)||N.stage_id===(i==null?void 0:i.id)).length,u=o>0?(d/o*100).toFixed(1):"0",p=new Date,g=o>0?Math.round(r.reduce((N,C)=>N+Vg(p,new Date(C.created_at)),0)/o):0,v=s.map(N=>({...N,count:r.filter(C=>C.stage_id===N.id).length})),_={};r.forEach(N=>{const C=N.source||"unknown";_[C]=(_[C]||0)+1});const b=Object.entries(_).sort((N,C)=>C[1]-N[1]),j=new Date;j.setDate(j.getDate()-30);const w=r.filter(N=>new Date(N.created_at)>=j).length;return{total:o,signed:d,conversionRate:u,avgDays:g,byStage:v,bySrc:b,recentCount:w}},[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(Sc,{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(In,{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(Uh,{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(Lt,{children:e.jsx(zt,{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(Lt,{children:e.jsx(zt,{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(at,{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 FLe=[{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 ays({brokerageId:t}){const{toast:s}=Ea(),[r,n]=S.useState(null),[a,o]=S.useState(null),l=(d,u)=>{navigator.clipboard.writeText(d),n(u),s({title:"Copied to clipboard!"}),setTimeout(()=>n(null),2e3)},i=[...new Set(FLe.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]}),FLe.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(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{className:"text-sm",children:u.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Subject: ",u.subject]})]}),e.jsx(at,{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(fa,{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(fa,{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 zLe={call:Zn,email:br,text:io,meeting:on,note:Sn};function iys({brokerageId:t}){const{data:s,isLoading:r}=Ct({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,_])),g=tre(new Date,30);return{recruiters:d.map(_=>{var C,A;const b=(l||[]).filter(I=>I.created_by===_),j=b.filter(I=>new Date(I.created_at)>=g),w={};j.forEach(I=>{w[I.activity_type]=(w[I.activity_type]||0)+1});const N=n.filter(I=>I.created_by===_).length;return{id:_,name:((C=p[_])==null?void 0:C.name)||"Unknown",email:((A=p[_])==null?void 0:A.email)||"",totalActivities:b.length,recentActivities:j.length,byType:w,prospectsCreated:N}}).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(Lt,{children:e.jsx(zt,{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=zLe[o]||Sn;return e.jsxs(at,{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(Lt,{children:e.jsx(zt,{className:"text-base",children:"Recent Activity"})}),e.jsx(Oe,{className:"space-y-3",children:s.recentActivities.map(n=>{const a=zLe[n.activity_type]||Sn;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:ws(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 oys({brokerageId:t}){const{toast:s}=Ea(),r=ns(),[n,a]=S.useState(!1),[o,l]=S.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),{data:i=[],isLoading:d}=Ct({queryKey:["recruit-referrals",t],queryFn:async()=>{const{data:w,error:N}=await G.from("recruit_referrals").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(N)throw N;return w}}),u=[...new Set(i.map(w=>w.referred_by))],{data:p=[]}=Ct({queryKey:["referral-profiles",u],queryFn:async()=>{if(!u.length)return[];const{data:w}=await G.from("profiles").select("id, name, email").in("id",u);return w||[]},enabled:u.length>0}),g=Object.fromEntries(p.map(w=>[w.id,w])),v=Ot({mutationFn:async w=>{const{data:{user:N}}=await G.auth.getUser();if(!N)throw new Error("Not authenticated");const{error:C}=await G.from("recruit_referrals").insert({brokerage_id:t,referred_by:N.id,referee_first_name:w.first_name,referee_last_name:w.last_name||null,referee_email:w.email||null,referee_phone:w.phone||null,referee_current_brokerage:w.current_brokerage||null,notes:w.notes||null});if(C)throw C},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-referrals",t]}),s({title:"Referral submitted!"}),l({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),a(!1)},onError:w=>s({title:"Error",description:w.message,variant:"destructive"})}),_=Ot({mutationFn:async({id:w,status:N,incentive_status:C})=>{const A={updated_at:new Date().toISOString()};N&&(A.status=N),C&&(A.incentive_status=C);const{error:I}=await G.from("recruit_referrals").update(A).eq("id",w);if(I)throw I},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-referrals",t]})}),b=w=>w==="approved"||w==="signed"?e.jsx(fa,{className:"h-3 w-3"}):w==="rejected"?e.jsx(wc,{className:"h-3 w-3"}):e.jsx(In,{className:"h-3 w-3"}),j=w=>w==="approved"||w==="signed"||w==="paid"?"bg-green-500/10 text-green-600 border-green-200":w==="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(fc,{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(w=>{var N;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:[w.referee_first_name," ",w.referee_last_name]}),e.jsxs(at,{variant:"outline",className:j(w.status),children:[b(w.status)," ",w.status]}),w.incentive_status&&e.jsxs(at,{variant:"outline",className:j(w.incentive_status),children:[e.jsx(ao,{className:"h-3 w-3 mr-1"})," ",w.incentive_status]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[w.referee_email&&e.jsx("p",{children:w.referee_email}),w.referee_phone&&e.jsx("p",{children:w.referee_phone}),w.referee_current_brokerage&&e.jsxs("p",{children:["Currently at: ",w.referee_current_brokerage]}),e.jsxs("p",{children:["Referred by: ",((N=g[w.referred_by])==null?void 0:N.name)||"Unknown"," • ",ws(new Date(w.created_at),"MMM d, yyyy")]})]}),w.notes&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 italic",children:w.notes})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(tr,{value:w.status,onValueChange:C=>_.mutate({id:w.id,status:C}),children:[e.jsx(Js,{className:"h-7 text-xs w-[110px]",children:e.jsx(sr,{})}),e.jsxs(er,{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(tr,{value:w.incentive_status||"pending",onValueChange:C=>_.mutate({id:w.id,incentive_status:C}),children:[e.jsx(Js,{className:"h-7 text-xs w-[100px]",children:e.jsx(sr,{})}),e.jsxs(er,{children:[e.jsx(At,{value:"pending",children:"Unpaid"}),e.jsx(At,{value:"paid",children:"Paid"}),e.jsx(At,{value:"n/a",children:"N/A"})]})]})]})]})},w.id)})}),e.jsx(vs,{open:n,onOpenChange:a,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Submit a Recruit Referral"})}),e.jsxs("form",{onSubmit:w=>{w.preventDefault(),v.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:w=>l(N=>({...N,first_name:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Last Name"}),e.jsx(Re,{value:o.last_name,onChange:w=>l(N=>({...N,last_name:w.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:w=>l(N=>({...N,email:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Phone"}),e.jsx(Re,{value:o.phone,onChange:w=>l(N=>({...N,phone:w.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Current Brokerage"}),e.jsx(Re,{value:o.current_brokerage,onChange:w=>l(N=>({...N,current_brokerage:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Notes"}),e.jsx(Tr,{value:o.notes,onChange:w=>l(N=>({...N,notes:w.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:v.isPending,children:"Submit"})]})]})]})})]})}function lys({brokerageId:t}){const{toast:s}=Ea(),r=ns(),[n,a]=S.useState(!1),{data:o}=Ct({queryKey:["brokerage-recruit-form",t],queryFn:async()=>{const{data:v,error:_}=await G.from("brokerages").select("id, name, recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(_)throw _;return v}}),{data:l=[]}=Ct({queryKey:["recruit-interest-submissions",t],queryFn:async()=>{const{data:v,error:_}=await G.from("recruit_interest_submissions").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(_)throw _;return v}}),i=Ot({mutationFn:async v=>{const{error:_}=await G.from("brokerages").update({recruit_form_enabled:v}).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=Ot({mutationFn:async({id:v,status:_})=>{const{error:b}=await G.from("recruit_interest_submissions").update({status:_}).eq("id",v);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)},g=v=>v==="contacted"||v==="converted"?"bg-green-500/10 text-green-600":v==="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(Lt,{children:e.jsx(zt,{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:v=>i.mutate(v)})]}),(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(fa,{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(rn,{className:"h-3.5 w-3.5"})})})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{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(fc,{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(v=>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:[v.first_name," ",v.last_name]}),e.jsx(at,{variant:"outline",className:g(v.status),children:v.status})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs text-muted-foreground",children:[v.email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(br,{className:"h-3 w-3"}),v.email]}),v.phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Zn,{className:"h-3 w-3"}),v.phone]}),v.current_brokerage&&e.jsxs("span",{children:["From: ",v.current_brokerage]}),v.experience_years&&e.jsxs("span",{children:[v.experience_years,"yr exp"]})]}),v.why_interested&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 italic",children:['"',v.why_interested,'"']}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:ws(new Date(v.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(tr,{value:v.status,onValueChange:_=>d.mutate({id:v.id,status:_}),children:[e.jsx(Js,{className:"h-7 text-xs w-[110px]",children:e.jsx(sr,{})}),e.jsxs(er,{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"})]})]})]},v.id))})})]})]})}function cys({brokerageId:t}){const{toast:s}=Ea(),r=ns(),[n,a]=S.useState(!1),[o,l]=S.useState({prospect_id:"",title:"",description:"",due_date:ws(hl(new Date,1),"yyyy-MM-dd'T'HH:mm")}),[i,d]=S.useState("pending"),{data:u=[]}=Ct({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:g}=Ct({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}),v=Object.fromEntries(u.map(L=>[L.id,L])),_=Ot({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:ws(hl(new Date,1),"yyyy-MM-dd'T'HH:mm")}),a(!1)},onError:L=>s({title:"Error",description:L.message,variant:"destructive"})}),b=Ot({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]})}),j=p.filter(L=>i==="pending"?!L.completed_at:i==="completed"?!!L.completed_at:!0),w=j.filter(L=>!L.completed_at&&Yx(new Date(L.due_date))&&!zd(new Date(L.due_date))),N=j.filter(L=>!L.completed_at&&zd(new Date(L.due_date))),C=j.filter(L=>!L.completed_at&&!Yx(new Date(L.due_date))&&!zd(new Date(L.due_date))),A=j.filter(L=>!!L.completed_at),I=L=>{const R=v[L.prospect_id],$=!L.completed_at&&Yx(new Date(L.due_date))&&!zd(new Date(L.due_date));return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(zo,{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(at,{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(Qo,{className:"h-3 w-3"}):e.jsx(on,{className:"h-3 w-3"}),ws(new Date(L.due_date),"MMM d, h:mm a")]}),L.is_automated&&e.jsx(at,{variant:"outline",className:"text-[10px]",children:"Auto"})]})]})]},L.id)};return g?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"&&w.length+N.length+C.length>0&&`(${w.length+N.length+C.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"&&w.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(Qo,{className:"h-3.5 w-3.5"})," Overdue (",w.length,")"]}),w.map(I)]}),i!=="completed"&&N.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(In,{className:"h-3.5 w-3.5"})," Today (",N.length,")"]}),N.map(I)]}),i!=="completed"&&C.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 (",C.length,")"]}),C.map(I)]}),i!=="pending"&&A.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(fa,{className:"h-3.5 w-3.5"})," Completed (",A.length,")"]}),A.map(I)]}),j.length===0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-8",children:["No follow-ups ",i!=="all"?`(${i})`:""]}),e.jsx(vs,{open:n,onOpenChange:a,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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(Tr,{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 dys=[{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 uys({brokerageId:t}){const{toast:s}=Ea(),r=ns(),[n,a]=S.useState(null),{data:o,isLoading:l}=Ct({queryKey:["recruit-landing-settings",t],queryFn:async()=>{const{data:w,error:N}=await G.from("recruit_landing_page_settings").select("*").eq("brokerage_id",t).maybeSingle();if(N)throw N;return w}}),[i,d]=S.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:dys,testimonials:[],gallery_images:[]});S.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=Ot({mutationFn:async()=>{const w={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:N}=await G.from("recruit_landing_page_settings").update(w).eq("id",i.id);if(N)throw N}else{const{error:N}=await G.from("recruit_landing_page_settings").insert(w);if(N)throw N}},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-landing-settings",t]}),s({title:"Landing page saved!"})},onError:w=>s({title:"Error",description:w.message,variant:"destructive"})}),p=async(w,N)=>{const C=w.name.split(".").pop(),A=`${t}/${N}-${Date.now()}.${C}`,{error:I}=await G.storage.from("recruit-landing").upload(A,w);if(I)throw I;const{data:{publicUrl:L}}=G.storage.from("recruit-landing").getPublicUrl(A);return L},g=async(w,N)=>{var A;const C=(A=w.target.files)==null?void 0:A[0];if(C){a(N);try{const I=await p(C,N);d(L=>({...L,[N]:I})),s({title:"Image uploaded!"})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},v=async w=>{var C;const N=(C=w.target.files)==null?void 0:C[0];if(N){a("gallery");try{const A=await p(N,"gallery");d(I=>({...I,gallery_images:[...I.gallery_images,A]})),s({title:"Gallery image added!"})}catch(A){s({title:"Upload failed",description:A.message,variant:"destructive"})}finally{a(null)}}},_=async(w,N)=>{var A;const C=(A=w.target.files)==null?void 0:A[0];if(C){a(`testimonial-${N}`);try{const I=await p(C,`testimonial-${N}`);d(L=>{const R=[...L.testimonials];return R[N]={...R[N],photo_url:I},{...L,testimonials:R}})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},{data:b}=Ct({queryKey:["brokerage-slug-for-landing",t],queryFn:async()=>{const{data:w,error:N}=await G.from("brokerages").select("recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(N)throw N;return w}}),j=`${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:j}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:j,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rn,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(Xa,{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:w=>g(w,"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:w=>d(N=>({...N,primary_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Re,{value:i.primary_color,onChange:w=>d(N=>({...N,primary_color:w.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:w=>d(N=>({...N,accent_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Re,{value:i.accent_color,onChange:w=>d(N=>({...N,accent_color:w.target.value})),className:"font-mono text-xs"})]})]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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:w=>d(N=>({...N,hero_headline:w.target.value})),placeholder:"Join Our Team"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Subtext"}),e.jsx(Tr,{value:i.hero_subtext,onChange:w=>d(N=>({...N,hero_subtext:w.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(Xa,{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:w=>g(w,"hero_image_url")})]}),i.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(w=>({...w,hero_image_url:null})),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{className:"text-base",children:"Benefits / Why Join Us"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>d(w=>({...w,benefits:[...w.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((w,N)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Ru,{className:"h-4 w-4 mt-2 text-muted-foreground"}),e.jsx(Re,{value:w.icon,onChange:C=>{const A=[...i.benefits];A[N]={...w,icon:C.target.value},d(I=>({...I,benefits:A}))},className:"w-14 text-center"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Re,{value:w.title,onChange:C=>{const A=[...i.benefits];A[N]={...w,title:C.target.value},d(I=>({...I,benefits:A}))},placeholder:"Benefit title"}),e.jsx(Re,{value:w.description,onChange:C=>{const A=[...i.benefits];A[N]={...w,description:C.target.value},d(I=>({...I,benefits:A}))},placeholder:"Short description"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(C=>({...C,benefits:C.benefits.filter((A,I)=>I!==N)})),children:e.jsx(jr,{className:"h-3.5 w-3.5 text-destructive"})})]},N)),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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{className:"text-base",children:"Testimonials"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>d(w=>({...w,testimonials:[...w.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((w,N)=>{var C;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:[w.photo_url?e.jsx("img",{src:w.photo_url,alt:w.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:((C=w.name)==null?void 0:C[0])||"?"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("span",{className:"text-[10px] text-primary hover:underline",children:n===`testimonial-${N}`?"...":"Photo"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:A=>_(A,N)})]})]}),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:w.name,onChange:A=>{const I=[...i.testimonials];I[N]={...w,name:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"Name"}),e.jsx(Re,{value:w.role,onChange:A=>{const I=[...i.testimonials];I[N]={...w,role:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"Role / Title"})]}),e.jsx(Tr,{value:w.quote,onChange:A=>{const I=[...i.testimonials];I[N]={...w,quote:A.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(A=>({...A,testimonials:A.testimonials.filter((I,L)=>L!==N)})),children:e.jsx(jr,{className:"h-3.5 w-3.5 text-destructive"})})]},N)}),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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{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:v})]})]}),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((w,N)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:w,alt:`Gallery ${N+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(C=>({...C,gallery_images:C.gallery_images.filter((A,I)=>I!==N)})),children:e.jsx(jr,{className:"h-3 w-3"})})]},N))}):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(zu,{className:"h-4 w-4 mr-2"}),u.isPending?"Saving...":"Save Landing Page"]})})]})}function hys(t){if(!t)return"—";const s=Math.floor(t/60),r=t%60;return s>0?`${s}m ${r}s`:`${r}s`}function mys({video:t}){return t.cta_clicked_at?e.jsx(at,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-200",children:"CTA Clicked"}):t.view_count>0?e.jsxs(at,{className:"bg-blue-500/10 text-blue-600 border-blue-200",children:[e.jsx(ya,{className:"h-3 w-3 mr-1"}),t.view_count," views"]}):t.sent_at?e.jsxs(at,{variant:"secondary",children:[e.jsx(Ta,{className:"h-3 w-3 mr-1"}),"Sent"]}):e.jsxs(at,{variant:"outline",children:[e.jsx(In,{className:"h-3 w-3 mr-1"}),"Draft"]})}function pys({brokerageId:t}){const{data:s=[],isLoading:r}=Yxs(t),{data:n=[]}=WJe(t),a=Jxs(),o=eys(),l=HJe(),[i,d]=S.useState(""),[u,p]=S.useState(!1),[g,v]=S.useState({title:"",script_text:"",category:"general"}),_=s.filter(C=>{var I,L,R,$;return i?`${((I=C.prospect)==null?void 0:I.first_name)||""} ${((L=C.prospect)==null?void 0:L.last_name)||""}`.toLowerCase().includes(i.toLowerCase())||(($=(R=C.video)==null?void 0:R.title)==null?void 0:$.toLowerCase().includes(i.toLowerCase())):!0}),b={total:s.length,sent:s.filter(C=>C.sent_at).length,viewed:s.filter(C=>C.view_count>0).length,ctaClicked:s.filter(C=>C.cta_clicked_at).length},j=S.useCallback(C=>{if(!C)return;const A=`${window.location.origin}/recruit-video/${C}`;navigator.clipboard.writeText(A),fe.success("Share link copied")},[]),w=S.useCallback((C,A)=>{l.mutate({id:C,sent_via:A})},[l]),N=()=>{!g.title.trim()||!g.script_text.trim()||a.mutate({brokerage_id:t,...g},{onSuccess:()=>{v({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:Ta,color:"text-blue-500"},{label:"Viewed",value:b.viewed,icon:ya,color:"text-amber-500"},{label:"CTA Clicked",value:b.ctaClicked,icon:la,color:"text-emerald-500"}].map(C=>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 ${C.color}`,children:e.jsx(C.icon,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:C.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.label})]})]})},C.label))}),e.jsxs(ja,{defaultValue:"videos",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsxs(Ns,{value:"videos",children:[e.jsx(Nn,{className:"h-4 w-4 mr-1.5"}),"All Videos"]}),e.jsxs(Ns,{value:"scripts",children:[e.jsx(Sn,{className:"h-4 w-4 mr-1.5"}),"Script Library"]}),e.jsxs(Ns,{value:"analytics",children:[e.jsx(Xo,{className:"h-4 w-4 mr-1.5"}),"Engagement"]})]}),e.jsx(zs,{value:"videos",children:e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{className:"text-lg",children:"Video Outreach"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(xn,{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:C=>d(C.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(C=>{var A,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:[(A=C.video)!=null&&A.thumbnail_url?e.jsx("img",{src:C.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:hys(((I=C.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=C.prospect)==null?void 0:L.first_name," ",(R=C.prospect)==null?void 0:R.last_name]}),e.jsx(mys,{video:C})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:(($=C.video)==null?void 0:$.title)||"Untitled video"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ws(new Date(C.created_at),"MMM d, yyyy"),((q=C.prospect)==null?void 0:q.current_brokerage)&&` · ${C.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:()=>j(C.share_token),title:"Copy share link",children:e.jsx(ai,{className:"h-4 w-4"})}),!C.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(C.id,"email"),title:"Mark as sent",children:e.jsx(Ta,{className:"h-4 w-4"})}),C.share_token&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>window.open(`/recruit-video/${C.share_token}`,"_blank"),title:"Preview landing page",children:e.jsx(rn,{className:"h-4 w-4"})})]})]},C.id)})})})]})}),e.jsx(zs,{value:"scripts",children:e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{className:"text-lg",children:"Recruiting Scripts"}),e.jsxs(vs,{open:u,onOpenChange:p,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1.5"}),"New Script"]})}),e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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:g.title,onChange:C=>v(A=>({...A,title:C.target.value})),placeholder:"e.g., Why Switch to Our Brokerage"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Category"}),e.jsxs(tr,{value:g.category,onValueChange:C=>v(A=>({...A,category:C})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:V0e.map(C=>e.jsx(At,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Script"}),e.jsx(Tr,{value:g.script_text,onChange:C=>v(A=>({...A,script_text:C.target.value})),placeholder:"Hi [Name], I noticed you've been doing great work at [Brokerage]...",rows:8})]}),e.jsx(K,{onClick:N,disabled:!g.title.trim()||!g.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(Sn,{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(C=>{var I;const A=((I=V0e.find(L=>L.value===C.category))==null?void 0:I.label)||C.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(at,{variant:"outline",className:"text-[10px] mb-2",children:A}),e.jsx("h4",{className:"font-medium text-sm",children:C.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(C.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:C.script_text}),C.is_global&&e.jsx(at,{variant:"secondary",className:"mt-2 text-[10px]",children:"Template"})]})},C.id)})})})]})}),e.jsx(zs,{value:"analytics",children:e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(C=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:C.label}),e.jsxs("span",{className:"font-medium",children:[C.count," (",C.pct,"%)"]})]}),e.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${C.color} rounded-full transition-all`,style:{width:`${C.pct}%`}})})]},C.label))}),s.filter(C=>C.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(C=>C.view_count>0).sort((C,A)=>A.view_count-C.view_count).slice(0,5).map(C=>{var A,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:[(A=C.prospect)==null?void 0:A.first_name," ",(I=C.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(ya,{className:"h-3.5 w-3.5"})," ",C.view_count]}),C.cta_clicked_at&&e.jsx(la,{className:"h-4 w-4 text-emerald-500"})]})]},C.id)})})]})]})]})})]})]})}function fys({brokerageId:t}){const{toast:s}=Ea(),r=ns(),{stages:n,prospects:a}=Tce(t),[o,l]=S.useState(!1),[i,d]=S.useState({title:"",target_count:"10",target_stage_id:"",period_start:ws(new Date,"yyyy-MM-dd"),period_end:ws(new Date(new Date().getFullYear(),new Date().getMonth()+3,0),"yyyy-MM-dd")}),{data:u=[],isLoading:p}=Ct({queryKey:["recruit-goals",t],queryFn:async()=>{const{data:b,error:j}=await G.from("recruit_goals").select("*").eq("brokerage_id",t).order("period_end",{ascending:!1});if(j)throw j;return b}}),g=Ot({mutationFn:async b=>{const{data:{user:j}}=await G.auth.getUser();if(!j)throw new Error("Not authenticated");const{error:w}=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:j.id});if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal created"}),l(!1)},onError:b=>s({title:"Error",description:b.message,variant:"destructive"})}),v=Ot({mutationFn:async b=>{const{error:j}=await G.from("recruit_goals").delete().eq("id",b);if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal removed"})}}),_=b=>{const j=n.find(N=>N.id===b.target_stage_id);return{count:a.filter(N=>wg(new Date(N.created_at),{start:new Date(b.period_start),end:new Date(b.period_end)})?b.target_stage_id?N.stage_id===b.target_stage_id:!0:!1).length,stage:j}};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(Uh,{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:j,stage:w}=_(b),N=Math.min(100,j/b.target_count*100),C=wg(new Date,{start:new Date(b.period_start),end:new Date(b.period_end)});return e.jsxs(Ee,{className:C?"":"opacity-60",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{className:"text-sm",children:b.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ws(new Date(b.period_start),"MMM d")," – ",ws(new Date(b.period_end),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[C?e.jsx(at,{className:"text-[10px]",children:"Active"}):e.jsx(at,{variant:"secondary",className:"text-[10px]",children:"Ended"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground",onClick:()=>v.mutate(b.id),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Oe,{className:"space-y-2",children:[w&&e.jsxs(at,{variant:"outline",className:"text-[10px]",style:{borderColor:w.color,color:w.color},children:["Stage: ",w.name]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"font-bold text-lg",children:j}),e.jsxs("span",{className:"text-muted-foreground",children:["/ ",b.target_count]})]}),e.jsx(Mi,{value:N,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[N.toFixed(0),"% complete"]})]})]},b.id)})}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"Create Recruiting Goal"})}),e.jsxs("form",{onSubmit:b=>{b.preventDefault(),g.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(j=>({...j,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(j=>({...j,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(j=>({...j,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(j=>({...j,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(j=>({...j,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:g.isPending,children:"Create Goal"})]})]})]})})]})}function gys(){var i;const[t,s]=S.useState(""),[r,n]=S.useState("board"),{data:a=[],isLoading:o}=Ct({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(Ms,{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(Ms,{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(tr,{value:l,onValueChange:s,children:[e.jsxs(Js,{className:"w-[280px]",children:[e.jsx(Ca,{className:"mr-2 h-4 w-4"}),e.jsx(sr,{placeholder:"Select brokerage"})]}),e.jsx(er,{children:a.map(d=>e.jsx(At,{value:d.id,children:d.name},d.id))})]})]}),l?e.jsxs(ja,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(va,{className:"flex-wrap h-auto gap-1",children:[e.jsx(Ns,{value:"pipeline",children:"Pipeline"}),e.jsxs(Ns,{value:"video-outreach",children:[e.jsx(Nn,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(Ns,{value:"follow-ups",children:"Follow-ups"}),e.jsx(Ns,{value:"referrals",children:"Referrals"}),e.jsx(Ns,{value:"interest",children:"Interest Form"}),e.jsx(Ns,{value:"landing-page",children:"Landing Page"}),e.jsx(Ns,{value:"goals",children:"Goals"}),e.jsx(Ns,{value:"metrics",children:"Metrics"}),e.jsx(Ns,{value:"templates",children:"Email Templates"}),e.jsx(Ns,{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(pp,{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(AP,{className:"h-3.5 w-3.5"})," Table"]})]})}),r==="board"?e.jsx(sys,{brokerageId:l}):e.jsx(rys,{brokerageId:l})]}),e.jsx(zs,{value:"video-outreach",children:e.jsx(pys,{brokerageId:l})}),e.jsx(zs,{value:"follow-ups",children:e.jsx(cys,{brokerageId:l})}),e.jsx(zs,{value:"referrals",children:e.jsx(oys,{brokerageId:l})}),e.jsx(zs,{value:"interest",children:e.jsx(lys,{brokerageId:l})}),e.jsx(zs,{value:"landing-page",children:e.jsx(uys,{brokerageId:l})}),e.jsx(zs,{value:"goals",children:e.jsx(fys,{brokerageId:l})}),e.jsx(zs,{value:"metrics",children:e.jsx(nys,{brokerageId:l})}),e.jsx(zs,{value:"templates",children:e.jsx(ays,{brokerageId:l})}),e.jsx(zs,{value:"activity",children:e.jsx(iys,{brokerageId:l})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Ca,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found. Create a brokerage first."})]})]})})}function xys(){const[t,s]=S.useState(""),{data:r,isLoading:n}=Ct({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||[],g=u||[],v=i.map(_=>{const b=p.filter(N=>N.brokerage_id===_.id),j=g.filter(N=>N.brokerage_id===_.id),w=b.length>0?b.reduce((N,C)=>C.created_at>N?C.created_at:N,b[0].created_at):null;return{brokerage_id:_.id,brokerage_name:_.name,total_items:b.length,videos:b.filter(N=>N.content_type==="video").length,pdfs:b.filter(N=>N.content_type==="pdf").length,links:b.filter(N=>N.content_type==="link"||N.content_type==="canva_link").length,events:b.filter(N=>N.content_type==="event").length,graphics:b.filter(N=>N.content_type==="graphic").length,latest_item_date:w,categories:j.length}});return v.sort((_,b)=>b.total_items-_.total_items),v}}),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(Ms,{title:"Brokerage Content Activity",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(_u,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(Lt,{className:"pb-2",children:e.jsx(zt,{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(xn,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Brokerage"}),e.jsx(jt,{className:"text-center",children:"Total"}),e.jsx(jt,{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(jt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"})," PDFs"]})}),e.jsx(jt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Ho,{className:"h-3 w-3"})," Links"]})}),e.jsx(jt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(kc,{className:"h-3 w-3"})," Events"]})}),e.jsx(jt,{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(jt,{className:"text-center",children:"Categories"}),e.jsx(jt,{children:"Last Upload"})]})}),e.jsx(En,{children:n?e.jsx(js,{children:e.jsx(it,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):a.length===0?e.jsx(js,{children:e.jsx(it,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"No brokerages found"})}):a.map(i=>e.jsxs(js,{className:i.total_items===0?"opacity-50":"",children:[e.jsx(it,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ca,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:i.brokerage_name})]})}),e.jsx(it,{className:"text-center",children:i.total_items>0?e.jsx(at,{variant:"secondary",className:"font-bold",children:i.total_items}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(it,{className:"text-center",children:i.videos||"–"}),e.jsx(it,{className:"text-center",children:i.pdfs||"–"}),e.jsx(it,{className:"text-center",children:i.links||"–"}),e.jsx(it,{className:"text-center",children:i.events||"–"}),e.jsx(it,{className:"text-center",children:i.graphics||"–"}),e.jsx(it,{className:"text-center",children:i.categories||"–"}),e.jsx(it,{children:i.latest_item_date?e.jsx("span",{className:"text-sm text-muted-foreground",children:ws(new Date(i.latest_item_date),"MMM d, yyyy")}):e.jsx("span",{className:"text-muted-foreground",children:"–"})})]},i.brokerage_id))})]})})})]})})}function yys(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 vys=(()=>{let t=0;const s=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${s()}${t}`)})();function y_(t){const s=[];for(let r=0,n=t.length;rQm||t.height>Qm)&&(t.width>Qm&&t.height>Qm?t.width>t.height?(t.height*=Qm/t.width,t.width=Qm):(t.width*=Qm/t.height,t.height=Qm):t.width>Qm?(t.height*=Qm/t.width,t.width=Qm):(t.width*=Qm/t.height,t.height=Qm))}function Pie(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 kys(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(s=>`data:image/svg+xml;charset=utf-8,${s}`)}async function Nys(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),kys(a)}const Om=(t,s)=>{if(t instanceof s)return!0;const r=Object.getPrototypeOf(t);return r===null?!1:r.constructor.name===s.name||Om(r,s)};function Sys(t){const s=t.getPropertyValue("content");return`${t.cssText} content: '${s.replace(/'|"/g,"")}';`}function Cys(t,s){return ZJe(s).map(r=>{const n=t.getPropertyValue(r),a=t.getPropertyPriority(r);return`${r}: ${n}${a?" !important":""};`}).join(" ")}function Mys(t,s,r,n){const a=`.${t}:${s}`,o=r.cssText?Sys(r):Cys(r,n);return document.createTextNode(`${a}{${o}}`)}function BLe(t,s,r,n){const a=window.getComputedStyle(t,r),o=a.getPropertyValue("content");if(o===""||o==="none")return;const l=vys();try{s.className=`${s.className} ${l}`}catch{return}const i=document.createElement("style");i.appendChild(Mys(l,r,a,n)),s.appendChild(i)}function Tys(t,s,r){BLe(t,s,":before",r),BLe(t,s,":after",r)}const $Le="application/font-woff",qLe="image/jpeg",Ays={woff:$Le,woff2:$Le,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:qLe,jpeg:qLe,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Eys(t){const s=/\.([^./]*?)$/g.exec(t);return s?s[1]:""}function F2e(t){const s=Eys(t).toLowerCase();return Ays[s]||""}function Pys(t){return t.split(/,/)[1]}function H0e(t){return t.search(/^(data:)/)!==-1}function Iys(t,s){return`data:${s};base64,${t}`}async function XJe(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 Mpe={};function Lys(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 z2e(t,s,r){const n=Lys(t,s,r.includeQueryParams);if(Mpe[n]!=null)return Mpe[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let a;try{const o=await XJe(t,r.fetchRequestInit,({res:l,result:i})=>(s||(s=l.headers.get("Content-Type")||""),Pys(i)));a=Iys(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 Mpe[n]=a,a}async function Dys(t){const s=t.toDataURL();return s==="data:,"?t.cloneNode(!1):Pie(s)}async function Oys(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 Pie(i)}const r=t.poster,n=F2e(r),a=await z2e(r,n,s);return Pie(a)}async function Rys(t,s){var r;try{if(!((r=t==null?void 0:t.contentDocument)===null||r===void 0)&&r.body)return await Ace(t.contentDocument.body,s,!0)}catch{}return t.cloneNode(!1)}async function Fys(t,s){return Om(t,HTMLCanvasElement)?Dys(t):Om(t,HTMLVideoElement)?Oys(t,s):Om(t,HTMLIFrameElement)?Rys(t,s):t.cloneNode(QJe(t))}const zys=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",QJe=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function Bys(t,s,r){var n,a;if(QJe(s))return s;let o=[];return zys(t)&&t.assignedNodes?o=y_(t.assignedNodes()):Om(t,HTMLIFrameElement)&&(!((n=t.contentDocument)===null||n===void 0)&&n.body)?o=y_(t.contentDocument.body.childNodes):o=y_(((a=t.shadowRoot)!==null&&a!==void 0?a:t).childNodes),o.length===0||Om(t,HTMLVideoElement)||await o.reduce((l,i)=>l.then(()=>Ace(i,r)).then(d=>{d&&s.appendChild(d)}),Promise.resolve()),s}function $ys(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):ZJe(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`),Om(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 qys(t,s){Om(t,HTMLTextAreaElement)&&(s.innerHTML=t.value),Om(t,HTMLInputElement)&&s.setAttribute("value",t.value)}function Uys(t,s){if(Om(t,HTMLSelectElement)){const r=s,n=Array.from(r.children).find(a=>t.value===a.getAttribute("value"));n&&n.setAttribute("selected","")}}function Vys(t,s,r){return Om(s,Element)&&($ys(t,s,r),Tys(t,s,r),qys(t,s),Uys(t,s)),s}async function Hys(t,s){const r=t.querySelectorAll?t.querySelectorAll("use"):[];if(r.length===0)return t;const n={};for(let o=0;oFys(n,s)).then(n=>Bys(t,n,s)).then(n=>Vys(t,n,s)).then(n=>Hys(n,s))}const JJe=/url\((['"]?)([^'"]+?)\1\)/g,Wys=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Gys=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Kys(t){const s=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${s})(['"]?\\))`,"g")}function Zys(t){const s=[];return t.replace(JJe,(r,n,a)=>(s.push(a),r)),s.filter(r=>!H0e(r))}async function Yys(t,s,r,n,a){try{const o=r?yys(s,r):s,l=F2e(s);let i;return a||(i=await z2e(o,l,n)),t.replace(Kys(s),`$1${i}$3`)}catch{}return t}function Xys(t,{preferredFontFormat:s}){return s?t.replace(Gys,r=>{for(;;){const[n,,a]=Wys.exec(r)||[];if(!a)return"";if(a===s)return`src: ${n};`}}):t}function eet(t){return t.search(JJe)!==-1}async function tet(t,s,r){if(!eet(t))return t;const n=Xys(t,r);return Zys(n).reduce((o,l)=>o.then(i=>Yys(i,l,s,r)),Promise.resolve(n))}async function m4(t,s,r){var n;const a=(n=s.style)===null||n===void 0?void 0:n.getPropertyValue(t);if(a){const o=await tet(a,null,r);return s.style.setProperty(t,o,s.style.getPropertyPriority(t)),!0}return!1}async function Qys(t,s){await m4("background",t,s)||await m4("background-image",t,s),await m4("mask",t,s)||await m4("-webkit-mask",t,s)||await m4("mask-image",t,s)||await m4("-webkit-mask-image",t,s)}async function Jys(t,s){const r=Om(t,HTMLImageElement);if(!(r&&!H0e(t.src))&&!(Om(t,SVGImageElement)&&!H0e(t.href.baseVal)))return;const n=r?t.src:t.href.baseVal,a=await z2e(n,F2e(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 e0s(t,s){const n=y_(t.childNodes).map(a=>set(a,s));await Promise.all(n).then(()=>t)}async function set(t,s){Om(t,Element)&&(await Qys(t,s),await Jys(t,s),await e0s(t,s))}function t0s(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 ULe={};async function VLe(t){let s=ULe[t];if(s!=null)return s;const n=await(await fetch(t)).text();return s={url:t,cssText:n},ULe[t]=s,s}async function HLe(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),XJe(i,s.fetchRequestInit,({result:d})=>(r=r.replace(l,`url(${d})`),[l,d]))});return Promise.all(o).then(()=>r)}function WLe(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 s0s(t,s){const r=[],n=[];return t.forEach(a=>{if("cssRules"in a)try{y_(a.cssRules||[]).forEach((o,l)=>{if(o.type===CSSRule.IMPORT_RULE){let i=l+1;const d=o.href,u=VLe(d).then(p=>HLe(p,s)).then(p=>WLe(p).forEach(g=>{try{a.insertRule(g,g.startsWith("@import")?i+=1:a.cssRules.length)}catch(v){console.error("Error inserting rule from remote css",{rule:g,error:v})}})).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(VLe(a.href).then(i=>HLe(i,s)).then(i=>WLe(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{y_(a.cssRules||[]).forEach(o=>{r.push(o)})}catch(o){console.error(`Error while reading CSS rules from ${a.href}`,o)}}),r))}function r0s(t){return t.filter(s=>s.type===CSSRule.FONT_FACE_RULE).filter(s=>eet(s.style.getPropertyValue("src")))}async function n0s(t,s){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=y_(t.ownerDocument.styleSheets),n=await s0s(r,s);return r0s(n)}function ret(t){return t.trim().replace(/["']/g,"")}function a0s(t){const s=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(o=>{s.add(ret(o))}),Array.from(n.children).forEach(o=>{o instanceof HTMLElement&&r(o)})}return r(t),s}async function i0s(t,s){const r=await n0s(t,s),n=a0s(t);return(await Promise.all(r.filter(o=>n.has(ret(o.style.fontFamily))).map(o=>{const l=o.parentStyleSheet?o.parentStyleSheet.href:null;return tet(o.cssText,l,s)}))).join(` `)}async function o0s(t,s){const r=s.fontEmbedCSS!=null?s.fontEmbedCSS:s.skipFonts?null:await i0s(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 l0s(t,s={}){const{width:r,height:n}=YJe(t,s),a=await Ace(t,s,!0);return await o0s(a,s),await set(a,s),t0s(a,s),await Nys(a,r,n)}async function c0s(t,s={}){const{width:r,height:n}=YJe(t,s),a=await l0s(t,s),o=await Pie(a),l=document.createElement("canvas"),i=l.getContext("2d"),d=s.pixelRatio||wys(),u=s.canvasWidth||r,p=s.canvasHeight||n;return l.width=u*d,l.height=p*d,s.skipAutoScale||jys(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 d0s(t,s={}){return(await c0s(t,s)).toDataURL()}const Q3=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),Ece={"just-listed":"JUST LISTED","just-sold":"JUST SOLD","open-house":"OPEN HOUSE","price-drop":"PRICE DROP"},MR={"instagram-square":{width:1080,height:1080},"instagram-story":{width:1080,height:1920},"facebook-post":{width:1200,height:630}},u0s=({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})]})]}),net=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var g;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=(g=t.photos)==null?void 0:g[a],u=Ece[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:Q3(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.028,color:"#C9A84C",marginBottom:l.w*.01},children:["Sold for ",Q3(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(u0s,{branding:n,dim:l})]})]})]})});net.displayName="LuxuryDarkTemplate";const h0s=({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})]})]}),aet=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=Ece[s],p=r==="instagram-story",g=r==="facebook-post",v=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:g?"row":"column"},children:[e.jsxs("div",{style:{width:g?"55%":"100%",height:g?"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:v,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*(g?.055:.065),fontWeight:800,lineHeight:1.1,color:v,marginBottom:l.w*.012},children:Q3(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:`${v}10`,border:`2px solid ${v}`,borderRadius:l.w*.01,padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.022,fontWeight:700,color:v,display:"inline-block",marginBottom:l.w*.015},children:"SAT & SUN • 1–4 PM"}),e.jsx(h0s,{branding:n,dim:l,accentColor:v})]})]})});aet.displayName="ModernCleanTemplate";const m0s=({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})]})]}),iet=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var v;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=(v=t.photos)==null?void 0:v[a],u=Ece[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)"},g=[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:Q3(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:g}),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(m0s,{branding:n,dim:l})]})]})]})});iet.displayName="BoldColorfulTemplate";const p0s=({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})]})]}),oet=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var g;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=(g=t.photos)==null?void 0:g[a],u=Ece[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:Q3(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.02,color:"#8B7355",marginBottom:l.w*.01},children:["Sold: ",Q3(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(p0s,{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"}})]})]})})});oet.displayName="EditorialTemplate";const f0s=[{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:"📉"}],GLe=[{value:"instagram-square",label:"Instagram Post",dimensions:"1080×1080",icon:e.jsx(Vd,{className:"h-4 w-4"})},{value:"instagram-story",label:"Instagram Story",dimensions:"1080×1920",icon:e.jsx(Vd,{className:"h-4 w-4"})},{value:"facebook-post",label:"Facebook Post",dimensions:"1200×630",icon:e.jsx(Ud,{className:"h-4 w-4"})}],g0s=[{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:"📰"}],KLe=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),ZLe={"luxury-dark":net,"modern-clean":aet,"bold-colorful":iet,editorial:oet};function x0s(){const[t,s]=S.useState(""),[r,n]=S.useState("address"),[a,o]=S.useState(!1),[l,i]=S.useState([]),[d,u]=S.useState(null),[p,g]=S.useState(0),[v,_]=S.useState("just-listed"),[b,j]=S.useState(["instagram-square"]),[w,N]=S.useState("luxury-dark"),[C,A]=S.useState(!1),[I,L]=S.useState(""),[R,$]=S.useState(""),[q,U]=S.useState(""),[V,X]=S.useState(!1),[se,te]=S.useState(!1),[Y,de]=S.useState([]),[ie,ae]=S.useState("search"),le=S.useRef({});S.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 pe=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),g(0),ae("customize"),Te.soldDate||(Fe=Te.status)!=null&&Fe.toLowerCase().includes("sold")?_("just-sold"):_("just-listed")},ye=Te=>{j(Fe=>Fe.includes(Te)?Fe.filter(Ae=>Ae!==Te):[...Fe,Te])},we=S.useCallback(async()=>{if(!(!d||b.length===0)){X(!0),de([]),ae("generate");try{await new Promise(Fe=>setTimeout(Fe,500));const Te=[];for(const Fe of b){const Ae=`${w}-${Fe}`,Ue=le.current[Ae];if(!Ue)continue;const ut=MR[Fe],De=await d0s(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{X(!1)}}},[d,b,w,p,C,I,R,q,v]),Ne=async()=>{if(!(!d||b.length===0)){X(!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:v,format:Ae,branding:C?{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{X(!1)}}},Ke=()=>se?Ne():we(),_e=(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"}-${v}-${Fe}.png`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae)},Me=d?{listing:d,postType:v,format:"instagram-square",branding:C?{enabled:!0,agentName:I,brokerage:R,agentPhotoUrl:q||void 0}:{enabled:!1},selectedPhotoIndex:p}:null;return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(_u,{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 ${ie==="search"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"}`,children:[e.jsx(xn,{className:"h-3.5 w-3.5"})," 1. Find Listing"]}),e.jsx(qa,{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 ${ie==="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(mn,{className:"h-3.5 w-3.5"})," 2. Customize"]}),e.jsx(qa,{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 ${ie==="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"]})]}),ie==="search"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(xn,{className:"h-5 w-5 text-primary"})," Search MLS Listings ",e.jsx(hVe,{})]}),e.jsx(yr,{children:"Find a listing by MLS number or property address using Repliers.io"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(ja,{value:r,onValueChange:Te=>n(Te),children:e.jsxs(va,{children:[e.jsxs(Ns,{value:"address",children:[e.jsx(Ti,{className:"h-4 w-4 mr-1.5"})," Address"]}),e.jsxs(Ns,{value:"mls",children:[e.jsx(Im,{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"&&pe()}),e.jsxs(K,{onClick:pe,disabled:a||!t.trim(),children:[a?e.jsx(As,{className:"h-4 w-4 animate-spin"}):e.jsx(xn,{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(Vn,{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:KLe(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(ZE,{className:"h-3 w-3"})," ",Te.bedrooms]}),Te.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx($x,{className:"h-3 w-3"})," ",Te.bathrooms]}),Te.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(dP,{className:"h-3 w-3"})," ",Te.sqft.toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(at,{variant:"outline",className:"text-[10px]",children:Te.mlsNumber}),e.jsx(at,{variant:"outline",className:"text-[10px]",children:Te.status})]})]})]})})},Te.mlsNumber||Fe)})})]})]}),ie==="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(Lt,{className:"pb-3",children:e.jsx(zt,{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:()=>g(Te=>Math.max(0,Te-1)),disabled:p===0,children:e.jsx(Ol,{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:()=>g(Te=>Math.min(d.photos.length-1,Te+1)),disabled:p===d.photos.length-1,children:e.jsx(qa,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-lg",children:KLe(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(I0,{className:"h-3.5 w-3.5 mr-1.5"})," Choose Different Listing"]})]})]}),e.jsxs(Ee,{className:"lg:col-span-2",children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(mn,{className:"h-5 w-5 text-primary"})," Customize Your Post"]}),e.jsx(yr,{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(Rl,{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(c0,{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(Rl,{className:"h-4 w-4"})," Template Style"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:g0s.map(Te=>e.jsxs("button",{onClick:()=>N(Te.value),className:`flex flex-col items-center gap-1 px-3 py-3 rounded-lg border-2 transition-all text-center ${w===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:f0s.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 ${v===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:GLe.map(Te=>e.jsxs("button",{onClick:()=>ye(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:C,onCheckedChange:A})]}),C&&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*(MR[b[0]||"instagram-square"].height/MR[b[0]||"instagram-square"].width)},children:(()=>{const Te=ZLe[w],Fe=b[0]||"instagram-square";return e.jsx(Te,{...Me,format:Fe})})()})})]}),e.jsx(K,{onClick:Ke,disabled:b.length===0||V,size:"lg",className:"w-full gap-2",children:V?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-5 w-5 animate-spin"})," Generating ",b.length," post",b.length>1?"s":"","..."]}):e.jsxs(e.Fragment,{children:[se?e.jsx(c0,{className:"h-5 w-5"}):e.jsx(mn,{className:"h-5 w-5"}),"Generate ",b.length," Social Post",b.length>1?"s":"",se&&e.jsx(at,{variant:"outline",className:"ml-2 text-[10px]",children:"Uses Credits"})]})})]})]})]}),ie==="generate"&&e.jsxs("div",{className:"space-y-4",children:[V&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(As,{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"})]})}),Y.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(I0,{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:Y.map((Te,Fe)=>{const Ae=GLe.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(at,{variant:"outline",className:"text-[10px]",children:Ae==null?void 0:Ae.dimensions})]}),e.jsxs(K,{size:"sm",className:"w-full gap-1.5",onClick:()=>_e(Te.imageUrl,Te.format),children:[e.jsx(gi,{className:"h-3.5 w-3.5"})," Download"]})]})]},Fe)})})]})]}),ie==="generate"&&!se&&d&&Me&&e.jsx("div",{style:{position:"absolute",left:"-9999px",top:0},"aria-hidden":!0,children:b.map(Te=>{const Fe=ZLe[w],Ae=MR[Te];return e.jsx("div",{style:{width:Ae.width,height:Ae.height},children:e.jsx(Fe,{ref:Ue=>{le.current[`${w}-${Te}`]=Ue},...Me,format:Te})},`${w}-${Te}`)})})]})})}function y0s(){return Ct({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 v0s(t){return Ct({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 _0s(){const t=ns();return Ot({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 cet(){const t=ns();return Ot({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 b0s(){const t=ns();return Ot({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 w0s(){const t=ns();return Ot({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 j0s(){const t=ns();return Ot({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 k0s(){const t=ns();return Ot({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 N0s(){const t=ns();return Ot({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 S0s(){const t=ns();return Ot({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 C0s(){const t=ns();return Ot({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 M0s(){return Ct({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 T0s(t){return Ct({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 det(t){return Ct({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 A0s(){const t=ns();return Ot({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 E0s(){const{user:t}=Gs(),s=Lr(),{data:r,isLoading:n}=y0s(),a=_0s(),o=cet(),l=b0s(),[i,d]=S.useState(!1),[u,p]=S.useState(""),[g,v]=S.useState(""),[_,b]=S.useState(!0),j=async()=>{if(!(!u.trim()||!t))try{const C=await a.mutateAsync({title:u.trim(),description:g.trim()||void 0,is_sequential:_,created_by:t.id});fe.success("Course created"),d(!1),p(""),v(""),b(!0),s(`/admin/lms/${C.id}`)}catch{fe.error("Failed to create course")}},w=async C=>{try{await o.mutateAsync({id:C.id,is_published:!C.is_published}),fe.success(C.is_published?"Course unpublished":"Course published")}catch{fe.error("Failed to update course")}},N=async C=>{if(confirm("Delete this course and all its modules? This cannot be undone."))try{await l.mutateAsync(C),fe.success("Course deleted")}catch{fe.error("Failed to delete")}};return e.jsxs(Ms,{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(th,{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(Xo,{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(C=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Lt,{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"})]})},C))}):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(C=>{var R,$;const A=(($=(R=C.modules)==null?void 0:R[0])==null?void 0:$.count)??0,I=C.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/${C.id}`),children:[e.jsx(Lt,{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(zt,{className:"text-base truncate",children:C.title}),C.description&&e.jsx(yr,{className:"mt-1 line-clamp-2",children:C.description})]}),e.jsx(at,{variant:C.is_published?"default":"secondary",className:"ml-2 shrink-0",children:C.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(cu,{className:"h-3.5 w-3.5"}),A," module",A!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[C.is_sequential?e.jsx(M0,{className:"h-3.5 w-3.5"}):e.jsx(oN,{className:"h-3.5 w-3.5"}),C.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(),w(C)},children:[C.is_published?e.jsx(Tm,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(ya,{className:"h-3.5 w-3.5 mr-1"}),C.is_published?"Unpublish":"Publish"]}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:q=>{q.stopPropagation(),N(C.id)},children:e.jsx(jr,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"flex-1"}),e.jsx(Ui,{className:"h-4 w-4 text-muted-foreground"})]})]})]},C.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(cu,{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(vs,{open:i,onOpenChange:d,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:C=>p(C.target.value),placeholder:"e.g. LevelUp Onboarding"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Tr,{value:g,onChange:C=>v(C.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(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{onClick:j,disabled:!u.trim()||a.isPending,children:a.isPending?"Creating...":"Create Course"})]})]})})]})}function P0s(){const{courseId:t}=Co(),s=Lr(),{data:r,isLoading:n}=v0s(t),a=cet(),o=w0s(),l=j0s(),i=k0s(),d=N0s(),u=S0s(),p=C0s(),{data:g}=Ct({queryKey:["all-brokerages"],queryFn:async()=>{const{data:We}=await G.from("brokerages").select("id, name").order("name");return We||[]}}),[v,_]=S.useState(null),[b,j]=S.useState(!1),[w,N]=S.useState({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),[C,A]=S.useState(null),[I,L]=S.useState({title:"",resource_type:"link",url:""}),[R,$]=S.useState(new Set),[q,U]=S.useState(null),[V,X]=S.useState(0),[se,te]=S.useState(!1),Y=S.useRef(null),de=S.useRef(null),[ie,ae]=S.useState(!1),[le,pe]=S.useState(""),[be,ye]=S.useState(""),[we,Ne]=S.useState(""),[Ke,_e]=S.useState(!1);if(n)return e.jsx(Ms,{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(Ms,{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(Ka,{className:"h-4 w-4 mr-2"})," Back to Courses"]})]})});const Me=r.modules||[],Te=r.access||[],Fe=Te.some(We=>We.access_type==="all"),Ae=Te.filter(We=>We.access_type==="brokerage").map(We=>We.brokerage_id),Ue=(g||[]).filter(We=>We.name.toLowerCase().includes(le.toLowerCase())),ut=We=>{const Ye=new Set(R);Ye.has(We)?Ye.delete(We):Ye.add(We),$(Ye)},De=async()=>{if(!q)return null;te(!0),X(0);try{const{data:We,error:Ye}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:q.name}});if(Ye)throw new Error(Ye.message);const{videoId:mt,libraryId:Ze}=We,{data:He,error:et}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:mt,libraryId:Ze}});if(et)throw new Error(et.message);const Rt=new XMLHttpRequest;return await new Promise((qt,ls)=>{Rt.upload.onprogress=Kt=>{Kt.lengthComputable&&X(Math.round(Kt.loaded/Kt.total*100))},Rt.onload=()=>Rt.status>=200&&Rt.status<300?qt():ls(new Error(`Upload failed: ${Rt.status}`)),Rt.onerror=()=>ls(new Error("Upload failed")),Rt.open("PUT",He.uploadUrl),Rt.setRequestHeader("AccessKey",He.apiKey),Rt.send(q)}),`https://iframe.mediadelivery.net/embed/${Ze}/${mt}`}catch(We){return console.error("Bunny upload error:",We),fe.error("Video upload failed"),null}finally{te(!1),X(0)}},Dt=async()=>{if(w.title.trim())try{let We=w.video_url.trim()||void 0;if(q){const Ye=await De();if(!Ye)return;We=Ye}await o.mutateAsync({course_id:r.id,title:w.title.trim(),description:w.description.trim()||void 0,video_url:We,text_content:w.text_content.trim()||void 0,duration_minutes:w.duration_minutes?parseInt(w.duration_minutes):void 0,sort_order:Me.length}),fe.success("Module added"),j(!1),N({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),U(null)}catch{fe.error("Failed to add module")}},he=async()=>{if(v)try{let We=w.video_url.trim()||null;if(q){const Ye=await De();if(!Ye)return;We=Ye}await l.mutateAsync({id:v.id,title:w.title.trim(),description:w.description.trim()||null,video_url:We,text_content:w.text_content.trim()||null,duration_minutes:w.duration_minutes?parseInt(w.duration_minutes):null}),fe.success("Module updated"),_(null),U(null)}catch{fe.error("Failed to update")}},Ve=async We=>{if(confirm("Delete this module?"))try{await i.mutateAsync(We),fe.success("Module deleted")}catch{fe.error("Failed to delete")}},nt=async We=>{if(I.title.trim())try{await d.mutateAsync({module_id:We,title:I.title.trim(),resource_type:I.resource_type,url:I.url.trim()||void 0}),fe.success("Resource added"),A(null),L({title:"",resource_type:"link",url:""})}catch{fe.error("Failed to add resource")}},Qe=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")}},ke=async We=>{const Ye=Te.filter(et=>et.access_type==="brokerage").map(et=>et.brokerage_id),mt=Ye.includes(We);let Ze;mt?Ze=Ye.filter(et=>et!==We):Ze=[...Ye,We];const He=Ze.map(et=>({access_type:"brokerage",brokerage_id:et}));try{await p.mutateAsync({courseId:r.id,accessRules:He}),fe.success(mt?"Brokerage removed":"Brokerage added")}catch{fe.error("Failed to update access")}},ot=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[]}),fe.success("Access cleared")}catch{fe.error("Failed")}},qe=async(We,Ye)=>{const mt=Ye==="up"?We-1:We+1;if(!(mt<0||mt>=Me.length))try{await Promise.all([l.mutateAsync({id:Me[We].id,sort_order:mt}),l.mutateAsync({id:Me[mt].id,sort_order:We})])}catch{fe.error("Failed to reorder")}},lt=async()=>{try{await a.mutateAsync({id:r.id,title:be,description:we||null}),fe.success("Course updated"),_e(!1)}catch{fe.error("Failed to update")}};return e.jsxs(Ms,{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(Ka,{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(at,{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(M0,{className:"h-3.5 w-3.5"}):e.jsx(oN,{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:()=>{ye(r.title),Ne(r.description||""),_e(!0)},children:[e.jsx(Ua,{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(Tm,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(ya,{className:"h-3.5 w-3.5 mr-1"}),r.is_published?"Unpublish":"Publish"]})]})]}),e.jsxs(ja,{defaultValue:"modules",className:"w-full",children:[e.jsxs(va,{children:[e.jsx(Ns,{value:"modules",children:"Modules"}),e.jsx(Ns,{value:"access",children:"Access & Permissions"}),e.jsx(Ns,{value:"settings",children:"Settings"})]}),e.jsxs(zs,{value:"modules",className:"mt-6 space-y-4",children:[Me.map((We,Ye)=>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(We.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:mt=>{mt.stopPropagation(),qe(Ye,"up")},disabled:Ye===0,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(Rg,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:mt=>{mt.stopPropagation(),qe(Ye,"down")},disabled:Ye===Me.length-1,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(Vo,{className:"h-3.5 w-3.5"})})]})}),e.jsx(at,{variant:"outline",className:"shrink-0 font-mono text-xs",children:Ye+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:We.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:[We.video_url&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Nn,{className:"h-3 w-3"})," Video"]}),We.text_content&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Sn,{className:"h-3 w-3"})," Text"]}),We.duration_minutes&&e.jsxs("span",{children:[We.duration_minutes," min"]}),We.resources&&We.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Ho,{className:"h-3 w-3"})," ",We.resources.length," resource(s)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:mt=>{var Ze;mt.stopPropagation(),_(We),N({title:We.title,description:We.description||"",video_url:We.video_url||"",text_content:We.text_content||"",duration_minutes:((Ze=We.duration_minutes)==null?void 0:Ze.toString())||""})},children:e.jsx(Ua,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:mt=>{mt.stopPropagation(),Ve(We.id)},children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]}),R.has(We.id)&&e.jsxs("div",{className:"border-t bg-muted/30 p-4 space-y-3",children:[We.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:We.description}),We.video_url&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Video: "}),e.jsx("a",{href:We.video_url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline break-all",children:We.video_url})]}),We.text_content&&e.jsx("div",{className:"text-sm bg-background rounded-md p-3 border max-h-40 overflow-auto whitespace-pre-wrap",children:We.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:()=>{A(We.id),L({title:"",resource_type:"link",url:""})},children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add Resource"]})]}),We.resources&&We.resources.length>0?e.jsx("div",{className:"space-y-1",children:We.resources.map(mt=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-background rounded p-2 border",children:[e.jsx(at,{variant:"outline",className:"text-[10px]",children:mt.resource_type}),e.jsx("span",{className:"flex-1 truncate",children:mt.title}),mt.url&&e.jsx("a",{href:mt.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(mt.id),children:e.jsx(Ur,{className:"h-3 w-3"})})]},mt.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No resources yet"})]})]})]},We.id)),e.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:()=>{j(!0),N({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(Lt,{children:e.jsx(zt,{className:"text-base",children:"Who can access this course?"})}),e.jsxs(Oe,{className:"space-y-5",children:[e.jsxs("div",{className:Et("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:Qe,children:[e.jsx("div",{className:Et("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(Am,{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:Qe})]}),!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:ot,children:"Clear all"})]}),e.jsx(Re,{placeholder:"Search brokerages...",value:le,onChange:We=>pe(We.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(We=>{const Ye=Ae.includes(We.id);return e.jsxs("div",{className:Et("flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors",Ye?"bg-primary/5":"hover:bg-muted/50"),onClick:()=>ke(We.id),children:[e.jsx("div",{className:Et("h-5 w-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors",Ye?"bg-primary border-primary":"border-muted-foreground/30"),children:Ye&&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(Ca,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:We.name}),Ye&&e.jsx(at,{variant:"secondary",className:"text-[10px] shrink-0",children:"Active"})]},We.id)})})]})]})]})}),e.jsxs(zs,{value:"settings",className:"mt-6 space-y-4",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(C0,{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 We=>{var mt;const Ye=(mt=We.target.files)==null?void 0:mt[0];if(!(!Ye||!r)){ae(!0);try{const Ze=Ye.name.split(".").pop(),He=`${r.id}/thumbnail.${Ze}`,{error:et}=await G.storage.from("lms-thumbnails").upload(He,Ye,{upsert:!0});if(et)throw et;const{data:Rt}=G.storage.from("lms-thumbnails").getPublicUrl(He),qt=`${Rt.publicUrl}?t=${Date.now()}`;await a.mutateAsync({id:r.id,thumbnail_url:qt}),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:ie,onClick:()=>{var We;return(We=de.current)==null?void 0:We.click()},children:[ie?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Xa,{className:"h-4 w-4 mr-2"}),ie?"Uploading...":"Upload Thumbnail"]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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:We=>a.mutateAsync({id:r.id,is_sequential:We}).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:We=>a.mutateAsync({id:r.id,is_published:We}).then(()=>fe.success("Updated"))})]})]})]})]})]})]}),e.jsx(vs,{open:b||!!v,onOpenChange:We=>{We||(j(!1),_(null))},children:e.jsxs(ys,{className:"max-w-lg",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:v?"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:w.title,onChange:We=>N(Ye=>({...Ye,title:We.target.value})),placeholder:"Module title"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Tr,{value:w.description,onChange:We=>N(Ye=>({...Ye,description:We.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:Et("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 We;return(We=Y.current)==null?void 0:We.click()},children:[e.jsx("input",{ref:Y,type:"file",accept:"video/*",className:"hidden",onChange:We=>{var mt;const Ye=(mt=We.target.files)==null?void 0:mt[0];Ye&&(U(Ye),N(Ze=>({...Ze,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:We=>{We.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(Xa,{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(As,{className:"h-3.5 w-3.5 animate-spin"}),e.jsxs("span",{children:["Uploading to Bunny.net... ",V,"%"]})]}),e.jsx(Mi,{value:V,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:w.video_url,onChange:We=>N(Ye=>({...Ye,video_url:We.target.value})),placeholder:"YouTube, Vimeo, or Bunny.net URL"})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Text Content"}),e.jsx(Tr,{value:w.text_content,onChange:We=>N(Ye=>({...Ye,text_content:We.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:w.duration_minutes,onChange:We=>N(Ye=>({...Ye,duration_minutes:We.target.value})),placeholder:"e.g. 15"})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>{j(!1),_(null),U(null)},children:"Cancel"}),e.jsxs(K,{onClick:v?he:Dt,disabled:!w.title.trim()||se,children:[se?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(zu,{className:"h-4 w-4 mr-2"}),se?"Uploading...":v?"Save Changes":"Add Module"]})]})]})}),e.jsx(vs,{open:!!C,onOpenChange:We=>{We||A(null)},children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:We=>L(Ye=>({...Ye,title:We.target.value})),placeholder:"Resource title"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Type"}),e.jsxs(tr,{value:I.resource_type,onValueChange:We=>L(Ye=>({...Ye,resource_type:We})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{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:We=>L(Ye=>({...Ye,url:We.target.value})),placeholder:"https://..."})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>A(null),children:"Cancel"}),e.jsx(K,{onClick:()=>C&&nt(C),disabled:!I.title.trim(),children:"Add Resource"})]})]})}),e.jsx(vs,{open:Ke,onOpenChange:_e,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:We=>ye(We.target.value)})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Tr,{value:we,onChange:We=>Ne(We.target.value),rows:3})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>_e(!1),children:"Cancel"}),e.jsx(K,{onClick:lt,disabled:!be.trim(),children:"Save"})]})]})})]})}function I0s(){return Ct({queryKey:["lms-stats-overview"],queryFn:async()=>{const{data:t,error:s}=await G.rpc("get_lms_stats");if(s)throw s;return t}})}function L0s(){return Ct({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 D0s(t){return Ct({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 O0s(){const t=Lr(),{data:s,isLoading:r}=I0s(),{data:n,isLoading:a}=L0s(),[o,l]=S.useState(null),{data:i,isLoading:d}=D0s(o),[u,p]=S.useState(""),g=n==null?void 0:n.find(b=>b.course_id===o),v=i==null?void 0:i.filter(b=>{var j,w;return!u||((j=b.agent_name)==null?void 0:j.toLowerCase().includes(u.toLowerCase()))||((w=b.email)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))}),_=[{label:"Total Courses",value:(s==null?void 0:s.total_courses)??0,icon:cu,color:"text-primary"},{label:"Published",value:(s==null?void 0:s.published_courses)??0,icon:la,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:Gi,color:"text-amber-500"},{label:"Active (30d)",value:(s==null?void 0:s.active_learners)??0,icon:Sc,color:"text-violet-500"},{label:"Total Modules",value:(s==null?void 0:s.total_modules)??0,icon:Xo,color:"text-rose-500"}];return e.jsx(Ms,{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(Ka,{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(th,{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:Et("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:Et("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(Xo,{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 j=o===b.course_id;return e.jsx(Ee,{className:Et("cursor-pointer transition-all hover:shadow-md",j?"border-primary ring-1 ring-primary/30 shadow-md":"hover:border-primary/40"),onClick:()=>l(j?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(at,{variant:b.is_published?"default":"secondary",className:"shrink-0 text-[10px] px-1.5 py-0",children:b.is_published?"Live":"Draft"})]})}),e.jsx(qa,{className:Et("h-4 w-4 text-muted-foreground transition-transform shrink-0 ml-2",j&&"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(Mi,{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(i_,{className:"h-5 w-5 text-primary"}),g?`Agent Progress — ${g.course_title}`:"Agent Progress"]}),o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{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))}):v!=null&&v.length?e.jsx("div",{className:"space-y-2 max-h-[600px] overflow-y-auto pr-1",children:v.map((b,j)=>{const w=b.completion_pct>=100;return e.jsx(Ee,{className:Et("transition-all",w&&"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:Et("flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold shrink-0",j===0?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":j===1?"bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400":j===2?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-muted text-muted-foreground"),children:j+1}),e.jsxs(fn,{className:"h-9 w-9 shrink-0",children:[e.jsx(Ma,{src:b.avatar_url||void 0}),e.jsx(gn,{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}),w&&e.jsxs(at,{variant:"default",className:"text-[10px] px-1.5 py-0 bg-emerald-500 hover:bg-emerald-600 shrink-0",children:[e.jsx(la,{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(In,{className:"h-3 w-3"}),ws(new Date(b.last_activity),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"text-right shrink-0 w-20",children:[e.jsxs("p",{className:Et("text-sm font-bold",w?"text-emerald-600 dark:text-emerald-400":"text-foreground"),children:[b.completion_pct,"%"]}),e.jsx(Mi,{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 R0s(){const{user:t}=Gs(),s=Lr(),{data:r,isLoading:n}=M0s();return e.jsx(Ms,{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(th,{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(F0s,{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(cu,{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 F0s({course:t,userId:s,onClick:r}){var i;const n=((i=t.modules)==null?void 0:i.length)??0,{data:a}=det(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(th,{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(cu,{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(M0,{className:"h-3.5 w-3.5"}):e.jsx(oN,{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(Mi,{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(qa,{className:"h-3.5 w-3.5"})]})})]})]})}function z0s(){const{courseId:t}=Co(),s=Lr(),{user:r}=Gs(),{data:n,isLoading:a}=T0s(t),{data:o}=det(t),l=A0s(),[i,d]=S.useState(null),u=(n==null?void 0:n.modules)||[],p=new Set((o==null?void 0:o.filter(C=>C.completed).map(C=>C.module_id))||[]),g=p.size,v=u.length>0?Math.round(g/u.length*100):0;S.useEffect(()=>{if(u.length>0&&!i){const C=u.find(A=>!p.has(A.id));d((C==null?void 0:C.id)||u[0].id)}},[u,i,p]);const _=u.find(C=>C.id===i),b=u.findIndex(C=>C.id===i),j=(C,A)=>{if(!(n!=null&&n.is_sequential)||A===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 A=C.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(A)return`https://www.youtube.com/embed/${A[1]}`;const I=C.match(/vimeo\.com\/(\d+)/);if(I)return`https://player.vimeo.com/video/${I[1]}`;const L=C.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`:C};return a?e.jsx(Ms,{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(Ms,{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(Ka,{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:[g,"/",u.length," completed"]}),e.jsxs("span",{children:[v,"%"]})]})]}),e.jsx("div",{className:"w-32",children:e.jsx(Mi,{value:v,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(Fi,{className:"max-h-[calc(100vh-280px)]",children:e.jsx("div",{className:"p-1",children:u.map((C,A)=>{const I=j(C,A),L=p.has(C.id),R=C.id===i;return e.jsxs("button",{disabled:I,onClick:()=>!I&&d(C.id),className:Et("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(Fu,{className:"h-4 w-4 text-muted-foreground"}):L?e.jsx(la,{className:"h-4 w-4 text-green-500"}):e.jsx(Wc,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:Et("font-medium truncate",R&&"text-primary"),children:[A+1,". ",C.title]}),C.duration_minutes&&e.jsxs("span",{className:"text-[11px] text-muted-foreground flex items-center gap-0.5 mt-0.5",children:[e.jsx(In,{className:"h-3 w-3"})," ",C.duration_minutes," min"]})]})]},C.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:N(_.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(at,{className:"bg-green-500/15 text-green-600 border-green-500/30 shrink-0",children:[e.jsx(la,{className:"h-3.5 w-3.5 mr-1"})," Completed"]}):e.jsxs(K,{size:"sm",onClick:w,disabled:l.isPending,children:[e.jsx(la,{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(C=>e.jsxs("a",{href:C.url||C.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:[C.resource_type==="pdf"?e.jsx(Sn,{className:"h-4 w-4 text-red-500 shrink-0"}):C.resource_type==="template"?e.jsx(th,{className:"h-4 w-4 text-purple-500 shrink-0"}):e.jsx(Ho,{className:"h-4 w-4 text-blue-500 shrink-0"}),e.jsx("span",{className:"flex-1 truncate",children:C.title}),e.jsx(rn,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]},C.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(Ka,{className:"h-3.5 w-3.5 mr-1"})," Previous"]}),bd(u[b+1].id),children:["Next ",e.jsx(qa,{className:"h-3.5 w-3.5 ml-1"})]}):v===100&&e.jsx(at,{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(Ms,{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(Ka,{className:"h-4 w-4 mr-2"})," Back"]})]})})}function B0s(){const{slug:t}=Co(),{toast:s}=Ea(),[r,n]=S.useState(!1),[a,o]=S.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",experience_years:"",annual_production:"",license_number:"",why_interested:""}),{data:l,isLoading:i,error:d}=Ct({queryKey:["recruit-form-brokerage",t],queryFn:async()=>{const{data:A,error:I}=await G.from("brokerages").select("id, name, recruit_form_enabled").eq("recruit_form_slug",t).single();if(I)throw I;return A},enabled:!!t}),{data:u}=Ct({queryKey:["recruit-landing-public",l==null?void 0:l.id],queryFn:async()=>{const{data:A,error:I}=await G.from("recruit_landing_page_settings").select("*").eq("brokerage_id",l.id).single();if(I&&I.code!=="PGRST116")throw I;return A},enabled:!!(l!=null&&l.id)}),p=Ot({mutationFn:async()=>{const{error:A}=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(A)throw A},onSuccess:()=>n(!0),onError:A=>s({title:"Error",description:A.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(Ca,{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 g=u,v=(g==null?void 0:g.primary_color)||"#406E71",_=(g==null?void 0:g.accent_color)||"#2a4c64",b=(g==null?void 0:g.benefits)||[],j=(g==null?void 0:g.testimonials)||[],w=(g==null?void 0:g.gallery_images)||[],N=(g==null?void 0:g.hero_headline)||`Join ${l.name}`,C=(g==null?void 0:g.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, ${v}, ${_})`},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:`${v}20`},children:e.jsx(fa,{className:"h-8 w-8",style:{color:v}})}),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":v,"--recruit-accent":_},children:[e.jsxs("section",{className:"relative min-h-[70vh] flex items-center justify-center text-white overflow-hidden",style:{background:g!=null&&g.hero_image_url?`linear-gradient(135deg, ${v}dd, ${_}cc)`:`linear-gradient(135deg, ${v}, ${_})`},children:[(g==null?void 0:g.hero_image_url)&&e.jsx("div",{className:"absolute inset-0 bg-cover bg-center mix-blend-overlay opacity-40",style:{backgroundImage:`url(${g.hero_image_url})`}}),e.jsxs("div",{className:"relative z-10 text-center max-w-3xl mx-auto px-6 py-20",children:[(g==null?void 0:g.logo_url)&&e.jsx("img",{src:g.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:N}),e.jsx("p",{className:"text-lg md:text-xl opacity-90 mb-10 max-w-2xl mx-auto leading-relaxed",children:C}),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:v},children:["Apply Now ",e.jsx(Vo,{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((A,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:A.icon}),e.jsx("h3",{className:"text-xl font-bold mb-2",style:{color:_},children:A.title}),e.jsx("p",{className:"text-gray-600",children:A.description})]},I))})]})}),w.length>0&&e.jsx("section",{className:"py-20 px-6",style:{backgroundColor:`${v}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:v}}),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:w.map((A,I)=>e.jsx("img",{src:A,alt:`Team ${I+1}`,className:"w-full h-48 md:h-56 object-cover rounded-xl shadow-md hover:shadow-xl transition-shadow"},I))})]})}),j.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(v5,{className:"h-6 w-6",style:{color:v}}),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:j.map((A,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:['"',A.quote,'"']}),e.jsxs("div",{className:"flex items-center gap-3",children:[A.photo_url?e.jsx("img",{src:A.photo_url,alt:A.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:v},children:((L=A.name)==null?void 0:L[0])||"?"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",style:{color:_},children:A.name}),A.role&&e.jsx("p",{className:"text-xs text-gray-500",children:A.role})]})]})]},I)})})]})}),e.jsx("section",{id:"apply",className:"py-20 px-6",style:{backgroundColor:`${v}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:A=>{A.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:A=>o(I=>({...I,first_name:A.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-gray-700",children:"Last Name"}),e.jsx(Re,{value:a.last_name,onChange:A=>o(I=>({...I,last_name:A.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:A=>o(I=>({...I,email:A.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-gray-700",children:"Phone"}),e.jsx(Re,{value:a.phone,onChange:A=>o(I=>({...I,phone:A.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-gray-700",children:"Current Brokerage"}),e.jsx(Re,{value:a.current_brokerage,onChange:A=>o(I=>({...I,current_brokerage:A.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:A=>o(I=>({...I,license_number:A.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:A=>o(I=>({...I,experience_years:A.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:A=>o(I=>({...I,annual_production:A.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-gray-700",children:"Why are you interested?"}),e.jsx(Tr,{value:a.why_interested,onChange:A=>o(I=>({...I,why_interested:A.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:v},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 $0s(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 q0s(){var v,_,b,j;const{shareToken:t}=Co(),s=S.useRef(!1),{data:r,isLoading:n,error:a}=Ct({queryKey:["public-recruit-video",t],queryFn:async()=>{var L;if(!t)throw new Error("No token");const{data:w,error:N}=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(N)throw N;const{data:C}=await G.from("profiles").select("name, avatar_url, title").eq("id",(L=w.video)==null?void 0:L.owner_user_id).single(),{data:A}=await G.from("brokerages").select("name").eq("id",w.brokerage_id).single(),{data:I}=await G.from("recruit_landing_page_settings").select("logo_url, primary_color, accent_color, hero_headline").eq("brokerage_id",w.brokerage_id).maybeSingle();return{rv:w,profile:C,brokerage:A,settings:I}},enabled:!!t});if(S.useEffect(()=>{var w;!((w=r==null?void 0:r.rv)!=null&&w.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(()=>{}))},[(v=r==null?void 0:r.rv)==null?void 0:v.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",g=(b=o.video)!=null&&b.playback_url?$0s(o.video.playback_url):null;return e.jsxs(e.Fragment,{children:[e.jsx(nh,{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})]}),g&&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:g,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:((j=l==null?void 0:l.name)==null?void 0:j.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 U0s(){const t=Lr(),s=ns(),{isAdmin:r}=Gs(),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState(null),{data:u,isLoading:p}=Ct({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 $}}),g=Ot({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")}}),v=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)}},j=(u==null?void 0:u.filter(L=>L.platform==="facebook"))||[],w=(u==null?void 0:u.filter(L=>L.platform==="instagram"))||[],N=(u==null?void 0:u.filter(L=>L.platform==="linkedin"))||[],C=(u==null?void 0:u.filter(L=>L.platform==="google_business"))||[],A=((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(Ms,{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(at,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(mn,{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(Ka,{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(In,{className:"h-10 w-10 text-amber-600 dark:text-amber-400"})}),e.jsx(at,{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:[A&&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(fi,{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(Lt,{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(Ud,{className:"h-6 w-6 text-blue-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Facebook"}),e.jsx(yr,{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(Eo,{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(fn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:L.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(Ud,{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(at,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(tc,{children:[e.jsx(Ih,{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(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Disconnect Facebook?"}),e.jsx(Il,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:()=>g.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:v,disabled:n,className:"w-full gap-2",variant:j.length>0?"outline":"default",children:[n?e.jsx(Eo,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),j.length>0?"Connect Another Page":"Connect Facebook Page"]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{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(Vd,{className:"h-6 w-6 text-pink-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Instagram"}),e.jsx(yr,{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(Eo,{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(fn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:L.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(Vd,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["@",L.platform_username||"Instagram Account"]}),e.jsx(at,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(tc,{children:[e.jsx(Ih,{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(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Disconnect Instagram?"}),e.jsx(Il,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:()=>g.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:v,disabled:n,className:"w-full gap-2",variant:w.length>0?"outline":"default",children:[n?e.jsx(Eo,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),w.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(Lt,{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(Pm,{className:"h-6 w-6 text-blue-700"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"LinkedIn"}),e.jsx(yr,{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(Eo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):N.length>0?e.jsx("div",{className:"space-y-3",children:N.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(fn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:L.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(Pm,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.platform_username||"LinkedIn Account"}),e.jsx(at,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(tc,{children:[e.jsx(Ih,{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(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Disconnect LinkedIn?"}),e.jsx(Il,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:()=>g.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:N.length>0?"outline":"default",children:[n?e.jsx(Eo,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),N.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(at,{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(at,{variant:"secondary",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"Admin Testing"})}),e.jsx(Lt,{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(Ti,{className:"h-6 w-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Google Business"}),e.jsx(yr,{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(Eo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):C.length>0?e.jsx("div",{className:"space-y-3",children:C.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(fn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:L.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(Ti,{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(at,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(tc,{children:[e.jsx(Ih,{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(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Disconnect Google Business?"}),e.jsx(Il,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:()=>g.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:C.length>0?"outline":"default",children:[n?e.jsx(Eo,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),C.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&&(j.length>0||w.length>0)&&e.jsxs(Ee,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-900",children:[e.jsx(Lt,{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(J1,{className:"h-6 w-6 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Meta API Testing (Admin Only)"}),e.jsx(yr,{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:[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(Ud,{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(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(J1,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-fb-${L.id}`)),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(Vd,{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(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(J1,{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(la,{className:"h-4 w-4 text-green-600 mt-0.5 shrink-0"}):L.status==="pending"?e.jsx(As,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}):e.jsx(wc,{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(Lt,{children:e.jsx(zt,{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 V0s(){const[t]=Ac(),s=Lr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Processing your connection...");return S.useEffect(()=>{(async()=>{var g;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:v,error:_}=await G.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/social-connections/callback"}});if(_)throw _;if(v!=null&&v.success)n("success"),o(`Successfully connected ${((g=v.accounts)==null?void 0:g.length)||0} account(s)!`),fe.success("Social accounts connected successfully!");else throw new Error((v==null?void 0:v.error)||"Unknown error")}catch(v){console.error("OAuth callback error:",v),n("error"),o(v instanceof Error?v.message:"Failed to connect accounts"),fe.error("Failed to connect: "+(v instanceof Error?v.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(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(As,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(fi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(wc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(zt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(yr,{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 H0s(){const[t]=Ac(),s=Lr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Connecting your Google Business Profile...");return S.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:g,error:v}=await G.functions.invoke("google-business-oauth",{body:{action:"exchange_code",code:i,state:p}});if(v)throw v;if(g!=null&&g.success)n("success"),o(g.message||"Successfully connected Google Business Profile!"),fe.success("Google Business Profile connected!");else throw new Error((g==null?void 0:g.error)||"Unknown error")}catch(g){console.error("Google OAuth callback error:",g),n("error"),o(g instanceof Error?g.message:"Failed to connect Google Business Profile"),fe.error("Failed to connect: "+(g instanceof Error?g.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(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(As,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(fi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(wc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(zt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(yr,{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 W0s(){const[t]=Ac(),s=Lr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Connecting your LinkedIn account...");return S.useEffect(()=>{(async()=>{var g;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:v,error:_}=await G.functions.invoke("linkedin-oauth",{body:{action:"exchange_code",code:i,state:d,callbackPath:"/social-connections/linkedin-callback"}});if(_)throw _;if(v!=null&&v.success)n("success"),o(`Successfully connected ${((g=v.accounts)==null?void 0:g.length)||1} LinkedIn account`),fe.success("LinkedIn connected successfully!");else throw new Error((v==null?void 0:v.error)||"Failed to connect LinkedIn account")}catch(v){console.error("LinkedIn callback error:",v),n("error"),o(v instanceof Error?v.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(Lt,{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(As,{className:"h-8 w-8 animate-spin text-blue-600"}),r==="success"&&e.jsx(fi,{className:"h-8 w-8 text-green-600"}),r==="error"&&e.jsx(wc,{className:"h-8 w-8 text-red-600"})]}),e.jsxs(zt,{className:"flex items-center justify-center gap-2",children:[e.jsx(Pm,{className:"h-5 w-5 text-blue-600"}),r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(yr,{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 G0s(){const t=Lr(),[s,r]=S.useState(null),{data:n,isLoading:a}=$Je(s||void 0,!0),{data:o,isLoading:l}=R2e(!0),{cartItems:i}=Uoe(),d=i.reduce((p,g)=>p+g.quantity,0),u=p=>{t(`/marketplace/${p.id}`)};return a||l?e.jsx(Ms,{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(gs,{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(gs,{className:"h-72 w-full"},p))})]})}):e.jsx(Ms,{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(wm,{className:"h-4 w-4 mr-2"}),"Cart",d>0&&e.jsx(at,{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 g;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:((g=p.images.find(v=>v.is_primary))==null?void 0:g.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(cl,{className:"h-12 w-12 text-muted-foreground"})}),p.category&&e.jsx(at,{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(cl,{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 uet=S.forwardRef(({...t},s)=>e.jsx("nav",{ref:s,"aria-label":"breadcrumb",...t}));uet.displayName="Breadcrumb";const het=S.forwardRef(({className:t,...s},r)=>e.jsx("ol",{ref:r,className:Et("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...s}));het.displayName="BreadcrumbList";const wre=S.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:Et("inline-flex items-center gap-1.5",t),...s}));wre.displayName="BreadcrumbItem";const W0e=S.forwardRef(({asChild:t,className:s,...r},n)=>{const a=t?Hve:"a";return e.jsx(a,{ref:n,className:Et("transition-colors hover:text-foreground",s),...r})});W0e.displayName="BreadcrumbLink";const met=S.forwardRef(({className:t,...s},r)=>e.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:Et("font-normal text-foreground",t),...s}));met.displayName="BreadcrumbPage";const G0e=({children:t,className:s,...r})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Et("[&>svg]:size-3.5",s),...r,children:t??e.jsx(qa,{})});G0e.displayName="BreadcrumbSeparator";function K0s(){var te,Y;const{productId:t}=Co(),s=Lr(),{data:r,isLoading:n}=nxs(t||""),{addToCart:a,cartItems:o}=Uoe(),[l,i]=S.useState(null),[d,u]=S.useState(1),[p,g]=S.useState(0),[v,_]=S.useState(null),[b,j]=S.useState(!1),[w,N]=S.useState(!1),C=(te=r==null?void 0:r.variants)==null?void 0:te.find(de=>de.id===l),A=((Y=r==null?void 0:r.variants)==null?void 0:Y.filter(de=>de.is_active))||[],I=Number((r==null?void 0:r.base_price)||0),L=C?Number(C.price_adjustment):0,R=I+L,$=Number((r==null?void 0:r.shipping_fee)||0),q=o.reduce((de,ie)=>de+ie.quantity,0),U=async de=>{if(!de.target.files||de.target.files.length===0)return;j(!0);const ie=de.target.files[0],ae=ie.name.split(".").pop(),le=`artwork/${Date.now()}-${Math.random().toString(36).substring(7)}.${ae}`;try{const{error:pe}=await G.storage.from("marketplace").upload(le,ie);if(pe)throw pe;const{data:{publicUrl:be}}=G.storage.from("marketplace").getPublicUrl(le);_(be),fe.success("Artwork uploaded successfully")}catch(pe){fe.error("Failed to upload artwork: "+pe.message)}finally{j(!1)}},V=()=>{if(r){if(A.length>0&&!l){fe.error("Please select an option");return}a(r,C||void 0,d,v||void 0),N(!0),fe.success("Added to cart!"),setTimeout(()=>N(!1),2e3)}},X=()=>{r!=null&&r.images&&g(de=>(de+1)%r.images.length)},se=()=>{r!=null&&r.images&&g(de=>(de-1+r.images.length)%r.images.length)};return n?e.jsx(Ms,{title:"Product",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsx(gs,{className:"aspect-square w-full"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(gs,{className:"h-8 w-3/4"}),e.jsx(gs,{className:"h-6 w-1/4"}),e.jsx(gs,{className:"h-24 w-full"}),e.jsx(gs,{className:"h-12 w-full"})]})]})}):r?e.jsxs(Ms,{title:r.name,children:[e.jsx(uet,{className:"mb-6",children:e.jsxs(het,{children:[e.jsx(wre,{children:e.jsx(W0e,{asChild:!0,children:e.jsx(vo,{to:"/marketplace",children:"Marketplace"})})}),r.category&&e.jsxs(e.Fragment,{children:[e.jsx(G0e,{}),e.jsx(wre,{children:e.jsx(W0e,{asChild:!0,children:e.jsx(vo,{to:`/marketplace?category=${r.category.id}`,children:r.category.name})})})]}),e.jsx(G0e,{}),e.jsx(wre,{children:e.jsx(met,{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(Ol,{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:X,children:e.jsx(qa,{className:"h-6 w-6"})})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(cl,{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,ie)=>e.jsx("button",{onClick:()=>g(ie),className:`w-16 h-16 flex-shrink-0 rounded-md overflow-hidden border-2 ${ie===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(at,{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})}),A.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:A.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)"}),v?e.jsxs("div",{className:"relative inline-block",children:[e.jsx("img",{src:v,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(Xa,{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:V,disabled:w,children:w?e.jsxs(e.Fragment,{children:[e.jsx(fa,{className:"h-5 w-5 mr-2"}),"Added!"]}):e.jsxs(e.Fragment,{children:[e.jsx(wm,{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(wm,{className:"h-5 w-5"}),q>0&&e.jsx(at,{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(Ms,{title:"Product Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(cl,{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 Z0s(){const t=Lr(),{cartItems:s,removeFromCart:r,updateQuantity:n,getItemPrice:a,getSubtotal:o,getShippingTotal:l,getTotal:i,clearCart:d}=Uoe(),[u,p]=S.useState(!1),[g,v]=S.useState(""),_=async()=>{if(s.length===0){fe.error("Your cart is empty");return}p(!0);try{const{data:b,error:j}=await G.functions.invoke("marketplace-checkout",{body:{items:s.map(w=>{var N;return{product_id:w.product.id,variant_id:((N=w.variant)==null?void 0:N.id)||null,quantity:w.quantity,artwork_url:w.artworkUrl||null}}),notes:g.trim()||null}});if(j)throw j;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(Ms,{title:"Shopping Cart",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Wx,{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(Ms,{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 j,w;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:((j=b.product.images.find(N=>N.is_primary))==null?void 0:j.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(Wx,{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 N;return r(b.product.id,(N=b.variant)==null?void 0:N.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 N;return n(b.product.id,(N=b.variant)==null?void 0:N.id,b.quantity-1)},disabled:b.quantity<=1,children:e.jsx(A0,{className:"h-3 w-3"})}),e.jsx(Re,{type:"number",value:b.quantity,onChange:N=>{var C;return n(b.product.id,(C=b.variant)==null?void 0:C.id,parseInt(N.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 N;return n(b.product.id,(N=b.variant)==null?void 0:N.id,b.quantity+1)},children:e.jsx(Zs,{className:"h-3 w-3"})})]})]})]})})},`${b.product.id}-${((w=b.variant)==null?void 0:w.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(Lt,{children:e.jsx(zt,{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,j)=>b+j.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(sc,{}),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(sc,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{htmlFor:"orderNotes",children:"Order Notes (Optional)"}),e.jsx(Tr,{id:"orderNotes",placeholder:"Add any special instructions, design notes, or comments for your order...",value:g,onChange:b=>v(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(As,{className:"h-5 w-5 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:["Checkout",e.jsx(Ui,{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 Y0s(){const t=Lr(),{data:s,isLoading:r}=fxs();return r?e.jsx(Ms,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(n=>e.jsx(gs,{className:"h-32 w-full"},n))})}):!s||s.length===0?e.jsx(Ms,{title:"My Orders",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(cl,{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(Ms,{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:ws(new Date(n.created_at),"MMM d, yyyy")})]}),e.jsx(at,{className:O2e[n.status],children:B5[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(rn,{className:"h-4 w-4 mr-1"}),"Track"]}),e.jsx(qa,{className:"h-5 w-5 text-muted-foreground"})]})]})]})},n.id)})})})}const YLe=["order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed"];function X0s({currentStatus:t,statusHistory:s}){const r=YLe.indexOf(t);return e.jsx("div",{className:"space-y-3",children:YLe.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(la,{className:"h-4 w-4"}):i?e.jsx(In,{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:B5[n]}),o&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ws(new Date(o.created_at),"MMM d, yyyy h:mm a"),o.notes&&` — ${o.notes}`]})]})]},n)})})}function Q0s(){var N;const{orderId:t}=Co(),s=Lr(),{data:r,isLoading:n,refetch:a}=gxs(t||""),o=vxs(),l=_xs(),[i,d]=S.useState(!1),[u,p]=S.useState(null),[g,v]=S.useState(""),[_,b]=S.useState(null),j=async C=>{b(C);try{await o.mutateAsync({orderId:t,itemId:C}),fe.success("Proof approved!"),a()}catch{fe.error("Failed to approve proof")}finally{b(null)}},w=async()=>{if(u){b(u);try{await l.mutateAsync({orderId:t,itemId:u,reason:g}),fe.success("Revision requested"),d(!1),v(""),p(null),a()}catch{fe.error("Failed to request revision")}finally{b(null)}}};return n?e.jsx(Ms,{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(gs,{className:"h-64 w-full"}),e.jsx(gs,{className:"h-48 w-full"})]}),e.jsx(gs,{className:"h-96 w-full"})]})}):r?e.jsxs(Ms,{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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{children:"Order Status"}),e.jsx(at,{className:O2e[r.status],children:B5[r.status]})]}),e.jsx(Oe,{children:e.jsx(X0s,{currentStatus:r.status,statusHistory:r.status_history})})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Items"})}),e.jsx(Oe,{className:"space-y-4",children:(N=r.items)==null?void 0:N.map(C=>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:C.product_name}),C.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.variant_name}),e.jsxs("p",{className:"text-sm",children:["Qty: ",C.quantity," × $",Number(C.unit_price).toFixed(2)]})]}),e.jsxs("p",{className:"font-semibold",children:["$",(Number(C.unit_price)*C.quantity).toFixed(2)]})]}),C.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:C.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline",children:[e.jsx(Q1,{className:"h-4 w-4"}),"View Artwork",e.jsx(rn,{className:"h-3 w-3"})]})]}),C.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:C.proof_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline mb-3",children:[e.jsx(Q1,{className:"h-4 w-4"}),"View Proof",e.jsx(rn,{className:"h-3 w-3"})]}),C.proof_status==="pending"&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(K,{size:"sm",onClick:()=>j(C.id),disabled:_===C.id,children:[_===C.id?e.jsx(As,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(hu,{className:"h-4 w-4 mr-1"}),"Approve"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{p(C.id),d(!0)},disabled:_===C.id,children:[e.jsx(EP,{className:"h-4 w-4 mr-1"}),"Request Changes"]})]}),C.proof_status==="approved"&&e.jsxs(at,{className:"bg-green-100 text-green-800",children:[e.jsx(la,{className:"h-3 w-3 mr-1"}),"Proof Approved"]}),C.proof_status==="rejected"&&C.proof_notes&&e.jsxs("div",{className:"mt-2",children:[e.jsx(at,{variant:"destructive",className:"mb-2",children:"Revision Requested"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:C.proof_notes})]})]})]},C.id))})]}),r.shipping_name&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(IP,{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(rn,{className:"h-3 w-3 ml-1"})]})]})]})]})]}),e.jsx("div",{children:e.jsxs(Ee,{className:"sticky top-4",children:[e.jsx(Lt,{children:e.jsx(zt,{children:"Order Summary"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Placed on ",ws(new Date(r.created_at),"MMMM d, yyyy")]}),e.jsx(sc,{}),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(sc,{}),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(sc,{}),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(vs,{open:i,onOpenChange:d,children:e.jsxs(ys,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{children:"Request Changes"}),e.jsx(Kr,{children:"Please describe what changes you'd like made to the proof."})]}),e.jsx(Tr,{placeholder:"Describe the changes needed...",value:g,onChange:C=>v(C.target.value),rows:4}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(K,{onClick:w,disabled:!g.trim()||_!==null,children:[_?e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Submit Request"]})]})]})})]}):e.jsx(Ms,{title:"Order Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(cl,{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 J0s(){const t=Lr(),[s]=Ac();return s.get("session_id"),S.useEffect(()=>{localStorage.removeItem("marketplace-cart")},[]),e.jsx(Ms,{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(la,{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(cl,{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(Ui,{className:"h-4 w-4 ml-2"})]}),e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>t("/marketplace"),children:"Continue Shopping"})]})]})})})})}function evs(){const{user:t}=Gs(),[s,r]=S.useState("store"),[n,a]=S.useState(null),[o,l]=S.useState(null),[i,d]=S.useState(!1),[u,p]=S.useState(5),[g,v]=S.useState(""),[_,b]=S.useState(!1),[j,w]=S.useState(!1),[N,C]=S.useState(""),[A,I]=S.useState(null),[L,R]=S.useState(!1),{hasSubmittedReview:$,submitReview:q,markPostedToGoogle:U}=rqe(),{data:V}=UJe(),{data:X,isLoading:se}=qJe(),{data:te,isLoading:Y}=Cxs(n),{data:de,isLoading:ie}=Mxs(t==null?void 0:t.id),{data:ae=0}=Axs(t==null?void 0:t.id),le=Exs(),pe=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")}},ye=async()=>{if(!g.trim()){fe.error("Please write a review");return}b(!0);const Me=await q(u,g);b(!1),Me.success?(fe.success("Thank you for your review! You earned 25 points!"),C(g),w(!0),v(""),p(5)):fe.error(Me.error||"Failed to submit review")},we=()=>{navigator.clipboard.writeText(N),fe.success("Review copied to clipboard!")},Ne=()=>{U(),window.open("https://g.page/r/CT8bqTBTm7nJEBM/review","_blank")},Ke=()=>{w(!1),d(!1),C("")};return se||Y||ie?e.jsx(Ms,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{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(gs,{className:"h-64"},Me))})]})}):e.jsxs(Ms,{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(Gi,{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(Bh,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{children:"Streak bonuses add extra points!"})]})]})]})})}),e.jsx(mf,{open:L,onOpenChange:R,children:e.jsxs(Ee,{className:"border-primary/20",children:[e.jsx(pf,{asChild:!0,children:e.jsx(Lt,{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(Gi,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-base",children:"How to Earn Points"}),e.jsx(yr,{children:"See all the ways you can earn spendable points"})]})]}),L?e.jsx(Rg,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(Vo,{className:"h-5 w-5 text-muted-foreground"})]})})}),e.jsx(ff,{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:[V==null?void 0:V.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(Vn,{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(ao,{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(at,{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(Bh,{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(at,{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(ja,{value:s,onValueChange:r,children:[e.jsxs(va,{children:[e.jsxs(Ns,{value:"store",className:"flex items-center gap-2",children:[e.jsx(Wx,{className:"h-4 w-4"}),"Store"]}),e.jsxs(Ns,{value:"my-rewards",className:"flex items-center gap-2",children:[e.jsx(cl,{className:"h-4 w-4"}),"My Rewards",de&&de.length>0&&e.jsx(at,{variant:"secondary",className:"ml-1",children:de.length})]})]}),e.jsxs(zs,{value:"store",className:"mt-6",children:[X&&X.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"}),X.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(ao,{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=pe.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(at,{className:"bg-green-500 text-white",children:[e.jsx(la,{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(at,{variant:"destructive",children:"Sold Out"})})]}):e.jsxs("div",{className:"aspect-video bg-muted flex items-center justify-center relative",children:[e.jsx(ao,{className:"h-12 w-12 text-muted-foreground/50"}),Te&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(at,{className:"bg-green-500 text-white",children:[e.jsx(la,{className:"h-3 w-3 mr-1"}),"Owned"]})})]}),e.jsxs(Lt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(zt,{className:"text-lg",children:Me.name}),e.jsxs(at,{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(at,{variant:"outline",className:"w-fit",children:[Me.category.icon&&`${Me.category.icon} `,Me.category.name]})]}),e.jsxs(Oe,{children:[e.jsx(yr,{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&&Cpe(Me.file_url,Me.name)},disabled:!Me.file_url,children:Me.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(rn,{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(Wx,{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(cl,{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(ao,{className:"h-12 w-12 text-muted-foreground/50"})}),e.jsxs(Lt,{className:"pb-2",children:[e.jsx(zt,{className:"text-lg",children:((Ae=Me.item)==null?void 0:Ae.name)||"Unknown Item"}),e.jsxs(yr,{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,Dt;(De=Me.item)!=null&&De.file_url&&Cpe(Me.item.file_url,(Dt=Me.item)==null?void 0:Dt.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(gi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Access"]})})})]},Me.id)})})})]})]}),e.jsx(tc,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Confirm Purchase"}),e.jsxs(Il,{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(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:be,disabled:le.isPending,children:le.isPending?"Purchasing...":"Confirm Purchase"})]})]})}),e.jsx(vs,{open:i,onOpenChange:Me=>{!Me&&j?Ke():d(Me)},children:e.jsx(ys,{children:j?e.jsxs(e.Fragment,{children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(la,{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:['"',N,'"']})]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:we,children:[e.jsx(ai,{className:"h-4 w-4 mr-2"}),"Copy Review to Clipboard"]})]}),e.jsxs(On,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(K,{variant:"outline",onClick:Ke,children:"Maybe Later"}),e.jsxs(K,{onClick:Ne,className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Leave Google Review"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(Tr,{placeholder:"What do you love about LevelUp? How has it helped your business?",value:g,onChange:Me=>v(Me.target.value),rows:4})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{onClick:ye,disabled:_,className:"bg-yellow-600 hover:bg-yellow-700",children:_?"Submitting...":"Submit & Earn 25 Points"})]})]})})}),e.jsx(vs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(ys,{className:"max-w-lg",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[A==null?void 0:A.name,e.jsxs(at,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),A==null?void 0:A.points_cost]})]}),(A==null?void 0:A.category)&&e.jsxs(at,{variant:"outline",className:"w-fit",children:[A.category.icon&&`${A.category.icon} `,A.category.name]})]}),(A==null?void 0:A.preview_image_url)&&e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted rounded-lg",children:e.jsx("img",{src:A.preview_image_url,alt:A.name,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:(A==null?void 0:A.description)||"No description available"}),(A==null?void 0:A.max_quantity)!==null&&!pe.has((A==null?void 0:A.id)||"")&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[A==null?void 0:A.current_quantity," of ",A==null?void 0:A.max_quantity," remaining"]})]}),e.jsx(On,{children:A&&pe.has(A.id)?e.jsx(K,{className:"w-full",onClick:()=>{A.file_url&&Cpe(A.file_url,A.name)},disabled:!A.file_url,children:A.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Access"]})}):A&&e.jsx(K,{className:"w-full",onClick:()=>{I(null),l(A)},disabled:A.max_quantity!==null&&A.current_quantity===0||ae{const{user:t}=Gs(),s=ns(),r=Ct({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=Ct({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=Ot({mutationFn:async u=>{const{data:p,error:g}=await G.from("smart_presentations").insert({owner_user_id:t.id,...u}).select().single();if(g)throw g;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),o=Ot({mutationFn:async({id:u,...p})=>{const{data:g,error:v}=await G.from("smart_presentations").update(p).eq("id",u).select().single();if(v)throw v;return g},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),l=Ot({mutationFn:async u=>{const{data:p,error:g}=await G.from("smart_presentations").update({status:"published",published_at:new Date().toISOString()}).eq("id",u).select().single();if(g)throw g;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),fe.success("Presentation published!")}}),i=Ot({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=Ot({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}},tvs=()=>{const t=Lr(),{presentations:s,isLoading:r,archivePresentation:n,saveAsTemplate:a}=pet(),o=i=>i.status==="draft"?e.jsx(at,{variant:"outline",className:"text-xs",children:"Draft"}):i.view_count>1?e.jsx(at,{className:"text-xs bg-emerald-100 text-emerald-700 border-emerald-200",children:"Revisited"}):i.view_count===1?e.jsx(at,{className:"text-xs bg-blue-100 text-blue-700 border-blue-200",children:"Opened"}):e.jsx(at,{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(Ms,{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(gs,{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(uf,{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(Sn,{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 ",ws(new Date(i.created_at),"MMM d, yyyy")]}),i.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ya,{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(yu,{children:[e.jsx(vu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(Jp,{className:"h-4 w-4"})})}),e.jsxs(Wd,{align:"end",children:[i.status==="published"&&i.share_token&&e.jsxs(Da,{onClick:()=>window.open(`https://presentations.relevelup.com/${i.share_token}`,"_blank"),children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Preview Link"]}),e.jsxs(Da,{onClick:()=>a.mutate(i),children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Save as Template"]}),e.jsxs(Da,{onClick:()=>n.mutate(i.id),className:"text-destructive",children:[e.jsx(r5,{className:"h-4 w-4 mr-2"}),"Archive"]})]})]})]})]})})]})})},i.id))})]})})},XLe={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."}]},svs=[{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 rvs(t){const s=XLe[t];if(s)return s;const r=t.toLowerCase();for(const[n,a]of Object.entries(XLe))if(r.includes(n.toLowerCase())||n.toLowerCase().includes(r))return a;return svs}function nvs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=S.useState(!1),[o,l]=S.useState("script"),[i,d]=S.useState(0),[u,p]=S.useState(0),{canRecord:g}=vZe(),v=nS(),[_,b]=S.useState(""),[j,w]=S.useState(!1),[N,C]=S.useState(!0),[A,I]=S.useState(!1),[L,R]=S.useState(null),$=rvs(t),q=()=>{l("script"),d(0),p(0),b(""),w(!1),C(!0),I(!1),R(null)},U=Y=>{!Y&&(o==="uploading"||o==="processing")||(a(Y),Y||q())},V=Y=>{R(Y),b($[Y].text),w(!1)},X=()=>{l("record"),C(_.trim().length>0)},se=()=>{b(""),C(!1),l("record")},te=S.useCallback(async(Y,de)=>{l("uploading");try{const ie=t||"Presentation Video",{videoId:ae,uploadUrl:le,libraryId:pe}=await GL(ie),{apiKey:be}=await KL(ae),ye=new XMLHttpRequest;ye.upload.onprogress=Me=>{Me.lengthComputable&&d(Me.loaded/Me.total*100)},await new Promise((Me,Te)=>{ye.onload=()=>ye.status>=200&&ye.status<300?Me():Te(new Error("Upload failed")),ye.onerror=()=>Te(new Error("Upload failed")),ye.open("PUT",le),ye.setRequestHeader("AccessKey",be),ye.send(Y)}),l("processing");let we=0;const Ne=Date.now(),Ke=9e4;let _e=null;for(;we<4;){if(await new Promise(Te=>setTimeout(Te,3e3)),Date.now()-Ne>Ke){const Te=Y.size/1048576,Fe=`https://iframe.mediadelivery.net/embed/${pe}/${ae}?responsive=true`;await v.mutateAsync({bunny_video_id:ae,playback_url:Fe,file_size_mb:Te,title:ie,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 C3(ae);if(we=Me.status,p(Me.encodeProgress||0),we===4)_e={playbackUrl:Me.directPlayUrl,thumbnailUrl:Me.thumbnailUrl,previewUrl:Me.previewUrl||null,duration:Me.length||de,fileSizeMb:(Me.storageSize||Y.size)/(1024*1024)};else if(we===5||we===6)throw new Error("Video processing failed")}if(!_e)throw new Error("No video data");await v.mutateAsync({bunny_video_id:ae,contact_id:s||void 0,playback_url:_e.playbackUrl,thumbnail_url:_e.thumbnailUrl,preview_url:_e.previewUrl,duration_seconds:_e.duration,file_size_mb:_e.fileSizeMb,title:ie,status:"ready",touch_type:"presentation"}),r(_e.playbackUrl),fe.success("Video recorded, saved to library & attached!"),l("done"),setTimeout(()=>a(!1),1500)}catch(ie){console.error("Recording upload error:",ie),fe.error("Failed to process video. Please try again."),l("record")}},[t,s,r,v]);return e.jsxs(vs,{open:n,onOpenChange:U,children:[e.jsx(Ai,{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(ys,{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(Cs,{children:e.jsxs(Ss,{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((Y,de)=>e.jsxs("button",{onClick:()=>V(de),className:Et("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(Sn,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:Y.label})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 ml-5.5",children:Y.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"}),!j&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>w(!0),className:"h-7 text-xs gap-1",children:[e.jsx(Ua,{className:"h-3 w-3"}),"Edit"]})]}),j?e.jsx(Tr,{value:_,onChange:Y=>b(Y.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(Tr,{value:_,onChange:Y=>{b(Y.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:X,disabled:!1,children:_.trim()?"Continue with Script":"Continue Without Script"})]})]}),!g&&o==="record"?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-8 text-center",children:[e.jsx(Mh,{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:()=>C(!N),className:"h-7 text-xs gap-1",children:[N?e.jsx(Tm,{className:"h-3 w-3"}):e.jsx(ya,{className:"h-3 w-3"}),N?"Hide Script":"Show Script"]})]}),e.jsx(Mce,{maxDurationSeconds:60,onRecordingComplete:te,onRecordingStateChange:I,onError:Y=>fe.error(Y),teleprompterContent:_.trim()?e.jsx(vJe,{text:_,isVisible:N,onToggleVisibility:()=>C(!N),isRecording:A,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(As,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(Mi,{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(As,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(Mi,{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(fi,{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 avs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState("idle"),[u,p]=S.useState(0),g=S.useRef(null),v=nS(),{data:_}=Tle(),b=(_==null?void 0:_.total_storage_mb)||0,w=((_==null?void 0:_.max_storage_mb)||1024)-b,N=()=>{l(null),d("idle"),p(0)},C=$=>{!$&&i!=="idle"&&i!=="done"||(a($),$||N())},A=$=>{var V;const q=(V=$.target.files)==null?void 0:V[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>w){fe.error(`Not enough storage. You have ${w.toFixed(1)} MB remaining.`);return}l(q)},I=S.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:V,libraryId:X}=q;d("uploading");const{data:se,error:te}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:V,isAgentVideo:!0}});if(te)throw new Error(te.message);await new Promise((ie,ae)=>{const le=new XMLHttpRequest;le.upload.addEventListener("progress",pe=>{pe.lengthComputable&&p(Math.round(pe.loaded/pe.total*100))}),le.addEventListener("load",()=>le.status>=200&&le.status<300?ie():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 Y=o.size/(1024*1024),de=`https://iframe.mediadelivery.net/embed/${X}/${V}`;await v.mutateAsync({bunny_video_id:V,playback_url:de,file_size_mb:Y,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,v]),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(vs,{open:n,onOpenChange:C,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Upload a video file",children:[e.jsx(Xa,{className:"h-3.5 w-3.5"}),"Upload"]})}),e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsx(Cs,{children:e.jsxs(Ss,{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($=g.current)==null?void 0:$.click()},children:[e.jsx(Xa,{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:g,type:"file",accept:"video/*",className:"hidden",onChange:A,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(As,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:L()})]}),e.jsx(Mi,{value:i==="uploading"?u:i==="processing"?100:10})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>C(!1),disabled:R,children:"Cancel"}),e.jsx(K,{onClick:I,disabled:!o||R,children:R?e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Xa,{className:"h-4 w-4 mr-2"}),"Upload & Attach"]})})]})]})]})}const QLe=[{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"}],JLe=()=>{const t=Lr(),{id:s}=Co(),{user:r}=Gs(),{templates:n,templatesLoading:a,createPresentation:o,updatePresentation:l,publishPresentation:i}=pet(),{isGmailConnected:d,gmailEmail:u}=py(),[p,g]=S.useState(!1),[v,_]=S.useState("client"),[b,j]=S.useState(!1),[w,N]=S.useState(""),[C,A]=S.useState([]),[I,L]=S.useState(!1),[R,$]=S.useState(null),[q,U]=S.useState(!1),[V,X]=S.useState(""),[se,te]=S.useState(""),[Y,de]=S.useState(""),[ie,ae]=S.useState("buyer"),[le,pe]=S.useState(""),[be,ye]=S.useState(null),[we,Ne]=S.useState(""),[Ke,_e]=S.useState([]),[Me,Te]=S.useState("schedule_call"),[Fe,Ae]=S.useState("Schedule a Call"),[Ue,ut]=S.useState(""),[De,Dt]=S.useState(""),[he,Ve]=S.useState(null),[nt,Qe]=S.useState(s||null),[ke,ot]=S.useState(null),[qe,lt]=S.useState(!1),We=async(bt,ks)=>{if(!r)return;const ir=5*1024*1024;if(bt.size>ir){fe.error("Image must be under 5MB");return}if(!bt.type.startsWith("image/")){fe.error("Please upload an image file");return}Ve(ks);try{const Rr=bt.name.split(".").pop()||"jpg",ca=`${r.id}/${Date.now()}.${Rr}`,{error:ii}=await G.storage.from("listing-photos").upload(ca,bt);if(ii)throw ii;const{data:{publicUrl:lo}}=G.storage.from("listing-photos").getPublicUrl(ca);Rt(ks,{image_url:lo}),fe.success("Image uploaded")}catch{fe.error("Failed to upload image")}finally{Ve(null)}};S.useEffect(()=>{s&&Ye(s)},[s]);const Ye=async bt=>{const{data:ks,error:ir}=await G.from("smart_presentations").select("*").eq("id",bt).single();if(ir||!ks)return;const Rr=ks;if(j(!0),Ne(Rr.title),X(Rr.client_name||""),pe(Rr.property_address||""),_e(Rr.sections||[]),Te(Rr.cta_type||"schedule_call"),Ae(Rr.cta_label||"Schedule a Call"),ut(Rr.cta_url||""),Dt(Rr.heading||""),ot(Rr.share_token),lt(Rr.status==="published"),Qe(Rr.id),_("builder"),Rr.contact_id){const{data:ca}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").eq("id",Rr.contact_id).maybeSingle();ca&&($(ca),te(ca.email||""),de(ca.phone||""))}};S.useEffect(()=>{if(!r||w.length<1){A([]);return}const bt=setTimeout(async()=>{L(!0);const{data:ks}=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.%${w}%,last_name.ilike.%${w}%,email.ilike.%${w}%`).limit(10);A(ks||[]),L(!1)},300);return()=>clearTimeout(bt)},[w,r]);const mt=bt=>{$(bt),X(`${bt.first_name} ${bt.last_name||""}`.trim()),te(bt.email||""),de(bt.phone||""),U(!1)},Ze=async()=>{if(!V.trim()){fe.error("Client name is required");return}const bt=V.trim().split(" "),ks=bt[0],ir=bt.slice(1).join(" ")||null,{data:Rr,error:ca}=await G.from("innercircle_contacts").insert({owner_user_id:r.id,first_name:ks,last_name:ir,email:se||null,phone:Y||null,lead_source:"Smart Presentation"}).select().single();if(ca){fe.error("Failed to create client");return}$(Rr),fe.success("Client created & saved to Agent OS"),_("template")},He=bt=>{ye(bt);const ks=(bt.sections||[]).map(ir=>({...ir,is_visible:!0,video_url:"",text:""}));if(_e(ks),Ne(bt.name+(V?` for ${V}`:"")),bt.cta_config){const ir=bt.cta_config;Te(ir.type||"schedule_call"),Ae(ir.label||"Schedule a Call")}_("builder")},et=()=>{_e([{title:"Welcome",description:"A personal welcome",type:"video",icon:"👋",is_visible:!0}]),Ne(V?`Presentation for ${V}`:"New Presentation"),_("builder")},Rt=(bt,ks)=>{_e(ir=>ir.map((Rr,ca)=>ca===bt?{...Rr,...ks}:Rr))},qt=bt=>{Rt(bt,{is_visible:!Ke[bt].is_visible})},ls=()=>{_e(bt=>[...bt,{title:"New Section",description:"",type:"video",icon:"📝",is_visible:!0}])},Kt=bt=>{_e(ks=>ks.filter((ir,Rr)=>Rr!==bt))},Qt=async()=>{if(!we.trim()){fe.error("Title is required");return}try{if(nt){const bt=await l.mutateAsync({id:nt,title:we,sections:Ke,client_name:V,property_address:le||null,cta_type:Me,cta_label:Fe,cta_url:Ue||null,heading:De||null});fe.success("Saved")}else{const bt=await o.mutateAsync({title:we,contact_id:(R==null?void 0:R.id)||void 0,client_name:V,property_address:le||void 0,template_id:(be==null?void 0:be.id)||void 0,sections:Ke,cta_type:Me,cta_label:Fe,cta_url:Ue||void 0,heading:De||void 0});Qe(bt.id),ot(bt.share_token),fe.success("Presentation created!")}}catch(bt){console.error("Failed to save presentation:",bt);const ks=(bt==null?void 0:bt.message)||(bt==null?void 0:bt.toString())||"Unknown error";fe.error(`Failed to save: ${ks}`)}},fs=async()=>{try{await Qt();const bt=nt;if(bt){const ks=await i.mutateAsync(bt);ot(ks.share_token),lt(!0),_("share")}}catch(bt){console.error("Failed to publish presentation:",bt),fe.error(`Failed to publish: ${(bt==null?void 0:bt.message)||"Unknown error"}`)}},dr=ke?`https://presentations.relevelup.com/${ke}`:"";return e.jsx(Ms,{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(Ka,{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:[v==="client"&&"Who is this presentation for?",v==="template"&&"Choose a starting template",v==="builder"&&"Customize your presentation",v==="share"&&"Share with your client"]})]})]}),!b&&e.jsx("div",{className:"flex items-center gap-2",children:["client","template","builder","share"].map((bt,ks)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:Et("w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors",v===bt?"bg-primary text-primary-foreground":ks<["client","template","builder","share"].indexOf(v)?"bg-emerald-100 text-emerald-700":"bg-muted text-muted-foreground"),children:ks<["client","template","builder","share"].indexOf(v)?e.jsx(fa,{className:"h-4 w-4"}):ks+1}),e.jsx("span",{className:"text-sm font-medium capitalize hidden sm:inline",children:bt}),ks<3&&e.jsx("div",{className:"w-8 h-px bg-border"})]},bt))}),v==="client"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:()=>{$(null),X(""),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(Ta,{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(Ui,{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(Lt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(xn,{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(xn,{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:w,onChange:bt=>N(bt.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:[I&&e.jsx(gs,{className:"h-12 w-full"}),C.map(bt=>e.jsxs("button",{onClick:()=>mt(bt),className:Et("w-full text-left p-3 rounded-lg border transition-colors",(R==null?void 0:R.id)===bt.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsxs("p",{className:"font-medium text-sm",children:[bt.first_name," ",bt.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:bt.email||bt.phone||"No contact info"})]},bt.id)),!w&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"Start typing to search your contacts"}),w&&C.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(Ui,{className:"h-4 w-4"})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(fc,{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:V,onChange:bt=>{X(bt.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:bt=>te(bt.target.value),placeholder:"Optional",type:"email"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Phone"}),e.jsx(Re,{value:Y,onChange:bt=>de(bt.target.value),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Client Type"}),e.jsxs(tr,{value:ie,onValueChange:ae,children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsxs(er,{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:bt=>pe(bt.target.value),placeholder:"Optional"})]})]}),q&&V&&e.jsxs(K,{onClick:Ze,className:"w-full gap-2",children:["Create Client & Continue",e.jsx(Ui,{className:"h-4 w-4"})]})]})]})]})]}),v==="template"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs(ja,{defaultValue:"system",children:[e.jsxs(va,{children:[e.jsx(Ns,{value:"mine",children:"My Core Templates"}),e.jsx(Ns,{value:"system",children:"LevelUp Smart Templates"}),e.jsx(Ns,{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(bt=>e.jsx(gs,{className:"h-32"},bt))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(bt=>!bt.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(bt=>!bt.is_system).map(bt=>e.jsx(eDe,{template:bt,onSelect:He},bt.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(bt=>bt.is_system).map(bt=>e.jsx(eDe,{template:bt,onSelect:He},bt.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(Ka,{className:"h-4 w-4"}),"Back"]})]}),v==="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:we,onChange:bt=>Ne(bt.target.value)})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Page Heading"}),e.jsx(Re,{value:De,onChange:bt=>Dt(bt.target.value),placeholder:V?`Welcome, ${V}!`:"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:V,onChange:bt=>X(bt.target.value)})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Property Address"}),e.jsx(Re,{value:le,onChange:bt=>pe(bt.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:ls,children:"+ Add Section"})]}),e.jsx("div",{className:"space-y-3",children:Ke.map((bt,ks)=>e.jsx(Ee,{className:Et(!bt.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(Ru,{className:"h-4 w-4 text-muted-foreground cursor-grab"}),e.jsx("span",{className:"text-lg",children:bt.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:bt.title,onChange:ir=>Rt(ks,{title:ir.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:()=>qt(ks),children:bt.is_visible?e.jsx(ya,{className:"h-4 w-4"}):e.jsx(Tm,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Kt(ks),className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})]})]}),e.jsx(Re,{value:bt.description||"",onChange:ir=>Rt(ks,{description:ir.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:bt.video_url||"",onChange:ir=>Rt(ks,{video_url:ir.target.value}),placeholder:"Paste a YouTube or video URL...",className:"text-sm"})]}),e.jsx(nvs,{sectionTitle:bt.title,contactId:R==null?void 0:R.id,onVideoReady:ir=>Rt(ks,{video_url:ir})}),e.jsx(avs,{sectionTitle:bt.title,contactId:R==null?void 0:R.id,onVideoReady:ir=>Rt(ks,{video_url:ir})}),e.jsx(I2e,{userId:r==null?void 0:r.id,onSelect:ir=>Rt(ks,{video_url:ir})})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Image (optional — shown if no video is set)"}),bt.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:bt.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:()=>Rt(ks,{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:[he===ks?e.jsx(As,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(C0,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:he===ks?"Uploading...":"Click to upload an image"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:he===ks,onChange:ir=>{var ca;const Rr=(ca=ir.target.files)==null?void 0:ca[0];Rr&&We(Rr,ks),ir.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Text (optional)"}),e.jsx(Zg,{content:bt.text||"",onChange:ir=>Rt(ks,{text:ir}),placeholder:"Add supporting text...",minHeight:"80px",compact:!0})]})]})]})})},ks))})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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(tr,{value:Me,onValueChange:bt=>{Te(bt);const ks=QLe.find(ir=>ir.value===bt);ks&&Ae(ks.label)},children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:QLe.map(bt=>e.jsx(At,{value:bt.value,children:bt.label},bt.value))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Button Label"}),e.jsx(Re,{value:Fe,onChange:bt=>Ae(bt.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:bt=>ut(bt.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(Ka,{className:"h-4 w-4"}),"Back"]}),e.jsxs("div",{className:"flex gap-3 ml-auto",children:[e.jsx(K,{variant:"outline",onClick:Qt,disabled:o.isPending||l.isPending,children:"Save Draft"}),e.jsxs(K,{onClick:fs,disabled:i.isPending,className:"gap-2",children:[e.jsx(Ta,{className:"h-4 w-4"}),qe?"Update & Reshare":"Publish & Share"]})]})]})]}),v==="share"&&ke&&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(fa,{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 ",V||"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:dr,readOnly:!0,className:"text-center font-mono text-sm"}),e.jsx(K,{onClick:()=>{navigator.clipboard.writeText(dr),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 bt=`Hi ${V||""}! I put together something for you — check it out: ${dr}`;navigator.clipboard.writeText(bt),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?g(!0):window.open(`mailto:${se||""}?subject=${encodeURIComponent(we)}&body=${encodeURIComponent(`Hi ${(R==null?void 0:R.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${dr} Looking forward to connecting!`)}`)},children:[e.jsx(br,{className:"h-4 w-4"}),"Send Email"]})]}),d&&e.jsx(TM,{open:p,onOpenChange:g,contact:R?{id:R.id,first_name:R.first_name,last_name:R.last_name,email:se||R.email||""}:se?{id:"",first_name:(V==null?void 0:V.split(" ")[0])||"",last_name:(V==null?void 0:V.split(" ").slice(1).join(" "))||"",email:se}:void 0,defaultSubject:we,defaultBody:`Hi ${(R==null?void 0:R.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${dr} Looking forward to connecting!`,gmailEmail:u})]})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(K,{variant:"outline",onClick:()=>_("builder"),children:[e.jsx(Ka,{className:"h-4 w-4 mr-2"}),"Edit Presentation"]}),e.jsx(K,{onClick:()=>t("/mission-control/presentations"),children:"Done"})]})]})]})})},eDe=({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(at,{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"})]})}),ivs=()=>{var j;const{shareToken:t}=Co(),[s,r]=S.useState(null),[n,a]=S.useState(!0),[o,l]=S.useState(0),[i,d]=S.useState(!1);S.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]),S.useEffect(()=>{t&&u()},[t]);const u=async()=>{const{data:w,error:N}=await G.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(N||!w){d(!0),a(!1);return}const{data:C}=await G.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",w.owner_user_id).single();let A;if(C!=null&&C.brokerage_id){const{data:L}=await G.from("brokerages").select("name").eq("id",C.brokerage_id).single();A=(L==null?void 0:L.name)||void 0}let I=null;if(w.contact_id){const{data:L}=await G.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",w.contact_id).single();I=L}r({...w,owner_name:C==null?void 0:C.name,owner_email:C==null?void 0:C.email,owner_phone:C==null?void 0:C.phone,owner_avatar:C==null?void 0:C.avatar_url,owner_title:(C==null?void 0:C.title)||void 0,brokerage_name:A,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: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")}};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(gs,{className:"h-12 w-3/4 mx-auto"}),e.jsx(gs,{className:"h-64 w-full"}),e.jsx(gs,{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 g=s.sections.filter(w=>w.is_visible!==!1),v=g[o],_=w=>{const N=w.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(N)return`https://www.youtube.com/embed/${N[1]}?rel=0`;if(w.includes("iframe.mediadelivery.net/play/")){const I=w.replace("/play/","/embed/"),L=I.includes("?")?"&":"?";return`${I}${L}responsive=true`}if(w.includes("iframe.mediadelivery.net")){if(w.match(/\/embed\/(\d+)\/([a-f0-9-]+)/)){const L=w.includes("?")?"&":"?";return`${w}${L}responsive=true`}return""}const C=w.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(C)return`https://www.loom.com/embed/${C[1]}`;const A=w.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return A?`https://iframe.mediadelivery.net/embed/${A[1]}/${A[2]}?responsive=true`:w},b=!!((j=s.cta_url)!=null&&j.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:[v!=null&&v.video_url&&_(v.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:_(v.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"})}):v!=null&&v.image_url?e.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:e.jsx("img",{src:v.image_url,alt:v.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:v==null?void 0:v.icon}),e.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:v==null?void 0:v.title}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:v==null?void 0:v.description})]}),(v==null?void 0:v.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:v.text}})]}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:g.map((w,N)=>e.jsx("button",{onClick:()=>l(N),className:Et("w-full text-left p-4 rounded-xl border transition-all",o===N?"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(N+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})]})]})},N))})]}),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(rn,{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(f9e,{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 ovs({openHouseId:t,enableSurvey:s,onToggleSurvey:r}){const{data:n,isLoading:a}=z0t(t),o=U0t(),l=V0t(),i=H0t(),d=W0t(),[u,p]=S.useState(""),[g,v]=S.useState("rating"),_=async N=>{r(N),N&&(!n||n.length===0)&&await d.mutateAsync(t)},b=async()=>{if(!u.trim())return;const N=(n==null?void 0:n.reduce((C,A)=>Math.max(C,A.sort_order),0))??0;await o.mutateAsync({open_house_id:t,question_type:g,question_text:u.trim(),sort_order:N+1}),p("")},j=async N=>{await l.mutateAsync({id:N.id,open_house_id:t,is_active:!N.is_active})},w=async N=>{await i.mutateAsync({id:N.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(X1,{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(As,{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(N=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-muted/20",children:[e.jsx(Ru,{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:N.question_text}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:N.question_type.replace("_"," ")})]}),e.jsx(Br,{checked:N.is_active,onCheckedChange:()=>j(N),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>w(N),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]},N.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:N=>p(N.target.value),placeholder:"e.g. How did you hear about this listing?",className:"mt-1 h-9 text-sm",onKeyDown:N=>N.key==="Enter"&&b()})]}),e.jsxs(tr,{value:g,onValueChange:v,children:[e.jsx(Js,{className:"w-28 h-9 text-xs",children:e.jsx(sr,{})}),e.jsxs(er,{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 lvs({open:t,onOpenChange:s,openHouse:r}){const n=x9e(),{user:a}=Gs(),o=S.useRef(null),[l,i]=S.useState(r.auto_forward_to_card??!1),[d,u]=S.useState(r.disclosure_pdf_url??""),[p,g]=S.useState(r.enable_survey??!1),[v,_]=S.useState(!1),[b,j]=S.useState(!1),w=async A=>{var q;const I=(q=A.target.files)==null?void 0:q[0];if(!I||!a)return;if(I.size>20*1024*1024){an({title:"File must be under 20MB",variant:"destructive"});return}if(I.type!=="application/pdf"){an({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){an({title:"Upload failed",description:R.message,variant:"destructive"}),_(!1);return}const{data:$}=G.storage.from("open-house-photos").getPublicUrl(L);u($.publicUrl),_(!1),an({title:"PDF uploaded!"})},N=()=>{u(""),o.current&&(o.current.value="")},C=async()=>{j(!0);try{await n.mutateAsync({id:r.id,auto_forward_to_card:l,disclosure_pdf_url:d||null,enable_survey:p}),an({title:"Settings saved!"}),s(!1)}catch{an({title:"Failed to save",variant:"destructive"})}finally{j(!1)}};return e.jsx(vs,{open:t,onOpenChange:s,children:e.jsxs(ys,{className:"sm:max-w-md max-h-[85vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:w,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(Sn,{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:N,children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsx("button",{type:"button",onClick:()=>{var A;return(A=o.current)==null?void 0:A.click()},disabled:v,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:v?e.jsx(As,{className:"h-5 w-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Xa,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Upload PDF (max 20MB)"})]})})]}),e.jsx(ovs,{openHouseId:r.id,enableSurvey:p,onToggleSurvey:g}),e.jsx(K,{onClick:C,disabled:b,className:"w-full",children:b?"Saving...":"Save Settings"})]})]})})}const fet={5:"Excellent",4:"Good",3:"Neutral",2:"Bad",1:"Very Bad"};function cvs({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:fet[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 dvs({openHouseId:t}){const{data:s,isLoading:r}=q0t(t),{data:n}=g9e(t),a=S.useMemo(()=>{const g={};return n==null||n.forEach(v=>{g[v.id]=v}),g},[n]);if(r||!s)return null;const{questions:o,responses:l}=s;if(o.length===0)return null;const i=o.filter(g=>g.question_type==="rating"),d=o.filter(g=>g.question_type!=="rating"),u=[...new Set(l.map(g=>g.visitor_id))],p=u.length;return p===0?e.jsxs(Ee,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(X1,{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(Lt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(X1,{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(ja,{defaultValue:"summary",children:[e.jsxs(va,{className:"mb-4",children:[e.jsxs(Ns,{value:"summary",className:"text-xs gap-1",children:[e.jsx(Xo,{className:"h-3.5 w-3.5"})," Summary"]}),e.jsxs(Ns,{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(g=>e.jsx(cvs,{question:g,responses:l},g.id)),d.map(g=>{const v=l.filter(_=>_.question_id===g.id&&_.text_value);return v.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-sm font-medium",children:g.question_text}),e.jsx("div",{className:"space-y-1.5 max-h-40 overflow-y-auto",children:v.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)})})]},g.id)})]}),e.jsx(zs,{value:"individual",className:"space-y-4",children:u.map(g=>{const v=a[g],_=l.filter(b=>b.visitor_id===g);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:[v?`${v.first_name} ${v.last_name||""}`.trim():"Unknown Visitor",(v==null?void 0:v.email)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:v.email})]}),e.jsx("div",{className:"space-y-1",children:_.map(b=>{const j=o.find(w=>w.id===b.question_id);return j?e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:j.question_text}),e.jsx("span",{className:"font-medium",children:b.rating_value!=null?fet[b.rating_value]||b.rating_value:b.text_value})]},b.id):null})})]},g)})})]})})]})}const K0e="guestbook.relevelup.com";function uvs(){const{data:t,isLoading:s}=D0t(),r=O0t(),n=x9e(),a=R0t(),[o,l]=S.useState(!1),[i,d]=S.useState(null),{user:u}=Gs(),p=si(),[g,v]=S.useState(null),[_,b]=S.useState(null),[j,w]=S.useState(!1),N=S.useRef(null),[C,A]=S.useState({property_address:"",city:"",state:"",zip:"",event_date:ws(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 V;const U=(V=q.target.files)==null?void 0:V[0];if(U){if(U.size>5*1024*1024){an({title:"Photo must be under 5MB",variant:"destructive"});return}v(U),b(URL.createObjectURL(U))}},L=()=>{v(null),b(null),N.current&&(N.current.value="")},R=async()=>{if(!C.property_address){an({title:C.event_type==="community"?"Event name is required":"Address is required",variant:"destructive"});return}let q;if(g&&u){w(!0);const U=g.name.split(".").pop(),V=`${p}/${Date.now()}.${U}`,{error:X}=await G.storage.from("open-house-photos").upload(V,g,{upsert:!0});if(X){an({title:"Photo upload failed",description:X.message,variant:"destructive"}),w(!1);return}const{data:se}=G.storage.from("open-house-photos").getPublicUrl(V);q=se.publicUrl,w(!1)}await r.mutateAsync({...C,photo_url:q}),l(!1),A({property_address:"",city:"",state:"",zip:"",event_date:ws(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://${K0e}/${q}`),an({title:"Link copied!"})};return e.jsxs(Ms,{title:"Guest Book",children:[e.jsx(nh,{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(vs,{open:o,onOpenChange:l,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"New Open House"]})}),e.jsxs(ys,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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:()=>A(q=>({...q,event_type:"property"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${C.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:()=>A(q=>({...q,event_type:"community"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${C.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:C.event_type==="community"?"Event Name *":"Property Address *"}),e.jsx(Re,{value:C.property_address,onChange:q=>A(U=>({...U,property_address:q.target.value})),placeholder:C.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:C.city,onChange:q=>A(U=>({...U,city:q.target.value})),placeholder:"Austin"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"State"}),e.jsx(Re,{value:C.state,onChange:q=>A(U=>({...U,state:q.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"ZIP"}),e.jsx(Re,{value:C.zip,onChange:q=>A(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:C.event_date,onChange:q=>A(U=>({...U,event_date:q.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Start Time"}),e.jsx(Re,{type:"time",value:C.start_time,onChange:q=>A(U=>({...U,start_time:q.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"End Time"}),e.jsx(Re,{type:"time",value:C.end_time,onChange:q=>A(U=>({...U,end_time:q.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Welcome Message"}),e.jsx(Tr,{value:C.agent_greeting,onChange:q=>A(U=>({...U,agent_greeting:q.target.value})),placeholder:"Welcome! Please sign in below."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:C.event_type==="community"?"Event Photo":"Property Photo"}),e.jsx("input",{ref:N,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=N.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(C0,{className:"h-6 w-6"}),e.jsxs("span",{className:"text-sm",children:["Add a ",C.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||j,className:"w-full",children:j?"Uploading photo...":r.isPending?"Creating...":C.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(Lt,{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(hvs,{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(P0,{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 hvs({openHouse:t,isExpanded:s,onToggle:r,onCopyLink:n,onToggleActive:a,onDelete:o}){const{data:l}=g9e(s?t.id:void 0),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[g,v]=S.useState(!1),_=S.useRef(null),b=`https://${K0e}/${t.slug}`,j=I=>{if(!I)return"";const[L,R]=I.split(":"),$=parseInt(L),q=$>=12?"PM":"AM";return`${$>12?$-12:$||12}:${R} ${q}`},w=()=>{if(!(l!=null&&l.length))return;const I=["First Name","Last Name","Email","Phone","Intent","Wants Market Updates","Message","Signed In"],L=l.map(V=>[V.first_name,V.last_name||"",V.email||"",V.phone||"",V.visitor_intent||"",V.wants_market_updates?"Yes":"No",(V.message||"").replace(/"/g,'""'),ws(new Date(V.created_at),"MM/dd/yyyy h:mm a")]),R=[I,...L].map(V=>V.map(X=>`"${X}"`).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)},N=S.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]),C=S.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))),$=ws(new Date(t.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy"),q=t.start_time?`${j(t.start_time)}${t.end_time?" – "+j(t.end_time):""}`:"",U=[t.city,t.state].filter(Boolean).join(", "),V=t.agent_greeting||"Welcome! Please sign in below.",X=window.open("","_blank");X&&(X.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}
`:""}
${V}
QR Code
Scan to Sign In
Point your phone camera at the QR code
`),X.document.close(),setTimeout(()=>{X.focus(),X.print()},500))},[t,b]),A=async()=>{v(!0);try{const{error:I}=await G.functions.invoke("guestbook-email-link",{body:{openHouseId:t.id}});if(I)throw I;an({title:"Email sent!",description:"Check your inbox for the guest book link."})}catch(I){an({title:"Failed to send",description:I.message,variant:"destructive"})}finally{v(!1)}};return e.jsxs(Ee,{className:`transition-all ${t.is_active?"border-primary/30":"opacity-75"}`,children:[e.jsx(Lt,{className:"pb-3",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 flex-wrap",children:[e.jsx(zt,{className:"text-base truncate",children:t.property_address}),t.agent_name&&e.jsxs(at,{variant:"outline",className:"shrink-0 gap-1 text-xs 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(at,{variant:"outline",className:"shrink-0 gap-1",children:[e.jsx(Ca,{className:"h-3 w-3"}),"Community"]}),e.jsx(at,{variant:t.is_active?"default":"secondary",className:"shrink-0",children:t.is_active?"Active":"Inactive"})]}),e.jsxs(yr,{className:"flex flex-wrap items-center gap-3 text-xs",children:[t.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ti,{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"}),ws(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(In,{className:"h-3 w-3"}),j(t.start_time),t.end_time?` - ${j(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 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:n,title:"Copy link",children:e.jsx(ai,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>d(!0),title:"QR Code",children:e.jsx(P0,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p(!0),title:"Settings",children:e.jsx(Fl,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(b,"_blank"),title:"Preview",children:e.jsx(rn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:a,title:t.is_active?"Deactivate":"Activate",children:t.is_active?e.jsx(Tm,{className:"h-4 w-4"}):e.jsx(ya,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:o,title:"Delete",children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:s?e.jsx(Rg,{className:"h-4 w-4"}):e.jsx(Vo,{className:"h-4 w-4"})})]})]})}),s&&e.jsxs(Oe,{className:"pt-0",children:[e.jsx(sc,{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://",K0e,"/",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:w,className:"h-7 text-xs gap-1",children:[e.jsx(gi,{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(at,{variant:"outline",className:"text-xs capitalize",children:I.visitor_intent})}),e.jsx("td",{className:"p-2 text-xs text-muted-foreground",children:ws(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(dvs,{openHouseId:t.id})})]}),e.jsx(vs,{open:i,onOpenChange:d,children:e.jsxs(ys,{className:"sm:max-w-sm",children:[e.jsxs(Cs,{children:[e.jsx(Ss,{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(nD,{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:N,children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Download"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:C,children:[e.jsx(_P,{className:"h-4 w-4 mr-2"}),"Print Flyer"]})]}),e.jsxs(K,{variant:"default",className:"w-full",onClick:A,disabled:g,children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),g?"Sending...":"Email Link to Me"]})]})]})}),e.jsx(lvs,{open:u,onOpenChange:p,openHouse:t})]})}function mvs(){const{slug:t}=Co();return t?e.jsx(V9e,{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 get({photoUrl:t,videoUrl:s,onPhotoChange:r,onVideoChange:n,contactId:a}){const{user:o}=Gs(),l=nS(),i=S.useRef(null),d=S.useRef(null),[u,p]=S.useState(!1),[g,v]=S.useState(!1),[_,b]=S.useState(0),j=async N=>{if(o){p(!0);try{const C=N.name.split(".").pop()||"jpg",A=`${o.id}/card-${Date.now()}.${C}`,{error:I}=await G.storage.from("listing-photos").upload(A,N);if(I)throw I;const{data:{publicUrl:L}}=G.storage.from("listing-photos").getPublicUrl(A);r(L),fe.success("Photo uploaded")}catch(C){fe.error(C.message||"Failed to upload photo")}finally{p(!1)}}},w=async N=>{if(o){if(N.size>500*1024*1024){fe.error("Video must be under 500MB");return}v(!0),b(0);try{const{videoId:C,libraryId:A}=await GL(`Card Video - ${Date.now()}`),{uploadUrl:I,apiKey:L}=await KL(C);await new Promise((q,U)=>{const V=new XMLHttpRequest;V.upload.addEventListener("progress",X=>{X.lengthComputable&&b(Math.round(X.loaded/X.total*100))}),V.addEventListener("load",()=>{V.status>=200&&V.status<300?q():U(new Error("Upload failed"))}),V.addEventListener("error",()=>U(new Error("Upload failed"))),V.open("PUT",I),V.setRequestHeader("AccessKey",L),V.send(N)});const R=`https://iframe.mediadelivery.net/embed/${A}/${C}`;n(R);const $=parseFloat((N.size/(1024*1024)).toFixed(2));await l.mutateAsync({bunny_video_id:C,playback_url:`https://iframe.mediadelivery.net/play/${A}/${C}`,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(C){fe.error(C.message||"Failed to upload video")}finally{v(!1),b(0)}}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{children:"Media (optional)"}),e.jsxs(ja,{defaultValue:"photo",className:"w-full",children:[e.jsxs(va,{className:"grid w-full grid-cols-2",children:[e.jsxs(Ns,{value:"photo",className:"gap-1.5 text-xs",children:[e.jsx(Jo,{className:"h-3.5 w-3.5"}),"Photo"]}),e.jsxs(Ns,{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 N;return(N=i.current)==null?void 0:N.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(As,{className:"h-6 w-6 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Og,{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:N=>{var A;const C=(A=N.target.files)==null?void 0:A[0];C&&j(C),N.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 N;return(N=d.current)==null?void 0:N.click()},disabled:g,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:g?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(As,{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(Xa,{className:"h-6 w-6"}),e.jsx("span",{className:"text-xs",children:"Upload a video (max 500MB)"})]})}),!s&&!g&&e.jsx("div",{className:"mt-2",children:e.jsx(L2e,{contactId:a,onVideoReady:N=>n(N)})}),e.jsx("input",{ref:d,type:"file",accept:"video/*",className:"hidden",onChange:N=>{var A;const C=(A=N.target.files)==null?void 0:A[0];C&&w(C),N.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 pvs=[{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 fvs({onSelect:t}){return e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:pvs.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 VM={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 tDe({initialOpen:t,initialCardType:s,initialContactId:r,initialRecipientName:n,initialAddress:a,initialDate:o,onOpenChange:l}){const{user:i}=Gs(),d=ns(),[u,p]=S.useState(!1),[g,v]=S.useState("type"),[_,b]=S.useState(""),[j,w]=S.useState(null),[N,C]=S.useState(!1),[A,I]=S.useState("home_anniversary"),[L,R]=S.useState(""),[$,q]=S.useState(""),[U,V]=S.useState(""),[X,se]=S.useState(""),[te,Y]=S.useState("elegant"),[de,ie]=S.useState(null),[ae,le]=S.useState(null),pe=S.useState(!1);!pe[0]&&t&&s&&(pe[1](!0),p(!0),I(s),r&&w(r),n&&R(n),a&&q(a),o&&V(o),v(n?"details":"contact"));const{data:be}=Ct({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:ye}=Ct({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)}),we=Ue=>{w(Ue.id),R(`${Ue.first_name}${Ue.last_name?" "+Ue.last_name:""}`),q([Ue.address,Ue.city,Ue.state].filter(Boolean).join(", ")),V(Ue.home_anniversary||""),v("details")},Ne=Ue=>{I(Ue),v("contact")},Ke=async()=>{var Ue;if(!(!i||!ye)){C(!0);try{const ut={owner_user_id:i.id,contact_id:j,card_type:A,template:te,recipient_name:L,property_address:$||null,home_anniversary_date:U||null,custom_message:X||null,property_photo_url:de||null,video_url:ae||null,agent_name:ye.name||"Agent",agent_photo_url:ye.avatar_url,agent_phone:ye.phone,agent_email:ye.email,agent_brokerage:((Ue=ye.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"]}),_e()}catch(ut){fe.error(ut.message||"Failed to create card")}finally{C(!1)}}},_e=()=>{p(!1),v("type"),I("home_anniversary"),b(""),w(null),R(""),q(""),V(""),se(""),Y("elegant"),ie(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=VM[A],Fe=A==="home_anniversary",Ae=["home_anniversary","just_listed","just_sold"].includes(A);return e.jsxs(vs,{open:u,onOpenChange:Ue=>{Ue?p(!0):(_e(),l==null||l(!1))},children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Create Card"]})}),e.jsxs(ys,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:g==="type"?"What type of card?":g==="contact"?`${Me[A]} — Choose a Contact`:`${Me[A]} — Customize`})}),g==="type"&&e.jsx(fvs,{onSelect:Ne}),g==="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:()=>v("type"),children:[e.jsx(Ka,{className:"h-3.5 w-3.5"})," Back to card types"]}),e.jsxs("div",{className:"relative",children:[e.jsx(xn,{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:()=>we(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(Vn,{className:"h-3 w-3"}),Ue.address]})]}),Ue.home_anniversary&&A==="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:()=>{v("details")},children:"Skip — enter details manually"})})]}),g==="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:()=>v("contact"),children:[e.jsx(Ka,{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=>V(Ue.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Personal Message (optional)"}),e.jsx(Tr,{value:X,onChange:Ue=>se(Ue.target.value),placeholder:Te.defaultMessage,rows:3})]}),e.jsx(get,{photoUrl:de,videoUrl:ae,onPhotoChange:ie,onVideoChange:le,contactId:j}),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:()=>Y(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:()=>v("contact"),className:"flex-1",children:"Back"}),e.jsx(K,{onClick:Ke,disabled:!L||N,className:"flex-1 gap-2",children:N?"Creating...":"Create Card"})]})]})]})]})}const gvs={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 xvs({card:t}){const{user:s}=Gs(),{isGmailConnected:r}=py(),n=ns(),[a,o]=S.useState(!1),[l,i]=S.useState("");S.useEffect(()=>{a&&t.contact_id&&!l&&G.from("innercircle_contacts").select("email").eq("id",t.contact_id).maybeSingle().then(({data:j})=>{j!=null&&j.email&&i(j.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]=S.useState(d[t.card_type]||`A Special Card for ${t.recipient_name}!`),[g,v]=S.useState(""),_=`https://cardstudio.relevelup.com/c/${t.share_token}`,b=Ot({mutationFn:async()=>{var A;if(!l)throw new Error("Recipient email is required");const j=`
${g?`

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


`:""}

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

${t.property_address?`

${t.property_address}

`:""}
`,{data:w}=await G.auth.getSession(),N=(A=w==null?void 0:w.session)==null?void 0:A.access_token,C=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/gmail-send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify({to:l,subject:u,body:j,contactId:t.contact_id||void 0})});if(!C.ok){const I=await C.json();throw new Error(I.error||"Failed to send")}return C.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:j=>{fe.error(j.message||"Failed to send email")}});return r?e.jsxs(vs,{open:a,onOpenChange:o,children:[e.jsx(Ai,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Ta,{className:"h-3 w-3"})})}),e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ss,{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:j=>i(j.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:j=>p(j.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Personal Note (optional)"}),e.jsx(Tr,{value:g,onChange:j=>v(j.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(As,{className:"h-4 w-4 animate-spin"})," Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ta,{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(Ta,{className:"h-3 w-3"})})}function yvs({card:t}){const s=ns(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(t.recipient_name),[d,u]=S.useState(t.property_address||""),[p,g]=S.useState(t.home_anniversary_date||""),[v,_]=S.useState(t.custom_message||""),[b,j]=S.useState(t.template),[w,N]=S.useState(t.property_photo_url),[C,A]=S.useState(t.video_url||null),I=R=>{R&&(i(t.recipient_name),u(t.property_address||""),g(t.home_anniversary_date||""),_(t.custom_message||""),j(t.template),N(t.property_photo_url),A(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:v.trim()||null,template:b,property_photo_url:w||null,video_url:C||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(vs,{open:r,onOpenChange:I,children:[e.jsx(Ai,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Ua,{className:"h-3 w-3"})})}),e.jsxs(ys,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ss,{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=>g(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ve,{children:"Personal Message (optional)"}),e.jsx(Tr,{value:v,onChange:R=>_(R.target.value),placeholder:"Wishing you many more happy years in your beautiful home!",rows:3})]}),e.jsx(get,{photoUrl:w,videoUrl:C,onPhotoChange:N,onVideoChange:A,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:()=>j(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(As,{className:"h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})]})]})]})}function vvs(){const{user:t}=Gs(),s=ns(),[r,n]=S.useState(""),[a,o]=Ac(),l=a.get("cardType"),i=a.get("contactId"),d=a.get("name"),u=a.get("address"),p=a.get("date"),g=!!l,{data:v,isLoading:_}=Ct({queryKey:["sendable-cards",t==null?void 0:t.id],queryFn:async()=>{const{data:A,error:I}=await G.from("sendable_cards").select("*").eq("owner_user_id",t.id).order("created_at",{ascending:!1});if(I)throw I;return A},enabled:!!(t!=null&&t.id)}),b=Ot({mutationFn:async A=>{const{error:I}=await G.from("sendable_cards").delete().eq("id",A);if(I)throw I},onSuccess:()=>{s.invalidateQueries({queryKey:["sendable-cards"]}),fe.success("Card deleted")}}),j=A=>{const I=`https://cardstudio.relevelup.com/c/${A}`;navigator.clipboard.writeText(I),fe.success("Share link copied!")},w=v==null?void 0:v.filter(A=>{var I;return!r||A.recipient_name.toLowerCase().includes(r.toLowerCase())||((I=A.property_address)==null?void 0:I.toLowerCase().includes(r.toLowerCase()))}),N={elegant:"Elegant",bold:"Bold",warm:"Warm"},C={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(Ms,{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(tDe,{initialOpen:g,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(xn,{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:A=>n(A.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(A=>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"})]})},A))}):w!=null&&w.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:w.map(A=>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 ${A.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":A.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:[A.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"})]}),A.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%)]"})]}),A.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:A.card_type==="home_anniversary"?"🏡":A.card_type==="birthday"?"🎂":A.card_type==="just_sold"?"🎉":A.card_type==="just_listed"?"🏠":A.card_type==="thank_you"?"💐":A.card_type==="congratulations"?"🏆":A.card_type==="holiday"?"🎄":A.card_type==="thinking_of_you"?"💭":"✉️"}),e.jsx("p",{className:`text-[10px] uppercase tracking-[0.2em] mb-1 ${A.template==="bold"?"text-white/70":"text-muted-foreground"}`,children:C[A.card_type]||A.card_type}),e.jsx("p",{className:`font-semibold text-base ${A.template==="bold"?"text-white":"text-foreground"}`,children:A.recipient_name}),A.property_address&&e.jsx("p",{className:`text-xs mt-1 ${A.template==="bold"?"text-white/60":"text-muted-foreground"}`,children:A.property_address})]}),e.jsx("div",{className:"absolute top-2 right-2 z-10",children:e.jsx(at,{variant:A.template==="bold"?"outline":"secondary",className:`text-[10px] ${A.template==="bold"?"border-white/30 text-white/80":""}`,children:N[A.template]||A.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(ya,{className:"h-3 w-3"}),A.view_count," views"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Sd(new Date(A.created_at),{addSuffix:!0})})]}),A.sent_at&&e.jsxs("p",{className:"text-[10px] text-emerald-600 mb-2",children:["Sent ",ws(new Date(A.sent_at),"MMM d, yyyy")," via ",A.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:()=>j(A.share_token),children:[e.jsx(ai,{className:"h-3 w-3"}),"Copy Link"]}),e.jsx(yvs,{card:A}),e.jsx(xvs,{card:A}),e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>window.open(`https://cardstudio.relevelup.com/c/${A.share_token}`,"_blank"),children:e.jsx(rn,{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(A.id),children:e.jsx(jr,{className:"h-3 w-3"})})]})]})]},A.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(tDe,{initialOpen:g,initialCardType:l,initialContactId:i||void 0,initialRecipientName:d||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]})})]})})}function gE({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 _vs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:g,videoUrl:v}=t,_=VM[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(gE,{delay:0,x:"15%",y:"20%",size:8}),e.jsx(gE,{delay:1,x:"80%",y:"30%",size:6}),e.jsx(gE,{delay:2,x:"60%",y:"70%",size:10}),e.jsx(gE,{delay:.5,x:"25%",y:"80%",size:7}),e.jsx(gE,{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"}}),g&&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:g,alt:"Property",className:"w-full h-48 object-cover"})}),v&&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:`${v}?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(Zn,{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 Tpe({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 xE({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 sDe={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 bvs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:g,videoUrl:v}=t,_=VM[s],b=sDe[s]||sDe.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(Tpe,{delay:0,x:"10%",y:"10%",color:b.orbs[0],size:200}),e.jsx(Tpe,{delay:1,x:"70%",y:"60%",color:b.orbs[1],size:180}),e.jsx(Tpe,{delay:2,x:"50%",y:"20%",color:b.orbs[2],size:150}),e.jsx(xE,{delay:0,x:"20%",y:"25%"}),e.jsx(xE,{delay:.8,x:"75%",y:"15%"}),e.jsx(xE,{delay:1.6,x:"85%",y:"65%"}),e.jsx(xE,{delay:2.4,x:"10%",y:"75%"}),e.jsx(xE,{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(Vn,{className:"h-3.5 w-3.5"}),n]})]}),g&&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:g,alt:"Property",className:"w-full h-48 object-cover"})}),v&&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:`${v}?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(Zn,{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 wvs({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 rDe={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 jvs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:g,videoUrl:v}=t,_=VM[s],b=rDe[s]||rDe.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((j,w)=>e.jsx(wvs,{emoji:j,delay:w*1.2,x:`${15+w*14}%`,duration:5+w%3},w)),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(Ti,{className:"h-3 w-3"}),n]})]}),g&&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:g,alt:"Property",className:"w-full h-48 object-cover"})}),v&&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:`${v}?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(Zn,{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 TR({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 Ape({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 nDe={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 kvs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:g,videoUrl:v}=t,_=VM[s],b=nDe[s]||nDe.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(TR,{delay:0,x:"5%",y:"10%",size:300,color:b.mesh[0]}),e.jsx(TR,{delay:2,x:"60%",y:"50%",size:250,color:b.mesh[1]}),e.jsx(TR,{delay:4,x:"30%",y:"70%",size:200,color:b.mesh[2]}),e.jsx(TR,{delay:1,x:"80%",y:"15%",size:180,color:b.mesh[0]}),e.jsx(Ape,{delay:0,x:"15%",y:"20%",size:100}),e.jsx(Ape,{delay:3,x:"70%",y:"60%",size:140}),e.jsx(Ape,{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(Ti,{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"}}),g&&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:g,alt:"Property",className:"w-full h-48 object-cover"})}),v&&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:`${v}?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(Zn,{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 Epe({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 AR({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 aDe={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 Nvs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:g,videoUrl:v}=t,_=VM[s],b=aDe[s]||aDe.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(Epe,{delay:0,x:"20%",angle:15,color:b.stripe}),e.jsx(Epe,{delay:2,x:"75%",angle:-12,color:b.stripe}),e.jsx(Epe,{delay:4,x:"50%",angle:5,color:b.stripe}),e.jsx(AR,{delay:0,x:"30%"}),e.jsx(AR,{delay:1.5,x:"60%"}),e.jsx(AR,{delay:3,x:"45%"}),e.jsx(AR,{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(Ti,{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"}})]}),g&&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:g,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"})]}),v&&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:`${v}?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(Zn,{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 xet(){const{shareToken:t}=Co(),{data:s,isLoading:r,error:n}=Ct({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(S.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()-new Date(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(bvs,{...o});case"warm":return e.jsx(jvs,{...o});case"glass":return e.jsx(kvs,{...o});case"cinematic":return e.jsx(Nvs,{...o});case"elegant":default:return e.jsx(_vs,{...o})}}function Svs(){const t=si();return Ct({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 Cvs(){const t=si(),s=ns();return Ot({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 Mvs(){const t=Lr(),{isGmailConnected:s,gmailEmail:r}=py(),{data:n,isLoading:a}=Svs(),o=Cvs(),[l,i]=S.useState(!1),[d,u]=S.useState(!0),[p,g]=S.useState(!1);S.useEffect(()=>{n&&(i(n.is_globally_enabled),u(n.append_signature))},[n]);const v=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(vs,{open:p,onOpenChange:g,children:[e.jsx(Ai,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(Fl,{className:"h-3.5 w-3.5"}),"Settings"]})}),e.jsxs(ys,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ss,{className:"flex items-center gap-2",children:[e.jsx(Fl,{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(at,{variant:"outline",className:"gap-1 text-emerald-600 border-emerald-200 bg-emerald-500/10 text-[10px]",children:[e.jsx(la,{className:"h-3 w-3"}),"Active"]}):e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs gap-1",onClick:()=>{g(!1),t("/mission-control/integrations")},children:[e.jsx(rn,{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(sc,{}),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(vP,{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:v,disabled:a||o.isPending})]}),e.jsx(sc,{}),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(Ax,{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:()=>{g(!1),t("/profile")},children:[e.jsx(Ax,{className:"h-3 w-3 mr-1"}),"Edit your email signature in Profile settings"]})]})]})]})}function Tvs(){const t=si();return Ct({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 Avs(){const t=si();return Ct({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 Evs(){const t=si(),s=ns();return Ot({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 Pvs(){const t=ns();return Ot({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 Ivs(){const t=ns();return Ot({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 Lvs(){const t=si(),s=ns();return Ot({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 Dvs=[{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 Ovs(){const t=si(),{data:s,isLoading:r}=Tvs(),{data:n,isLoading:a}=Avs(),o=Evs(),l=Pvs(),i=Ivs(),d=Lvs(),[u,p]=S.useState(null),[g,v]=S.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))||[],j=L=>_.filter(R=>R.stage_id===L),w=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")}},N=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")}},C=async L=>{try{await i.mutateAsync(L),fe.success("Template deleted")}catch{fe.error("Failed to delete")}},A=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(Ms,{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(Lm,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Smart Drips"}),e.jsx(at,{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(Mvs,{})]}),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(oP,{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(ja,{defaultValue:"my-drips",children:[e.jsxs(va,{className:"grid grid-cols-2 w-full max-w-xs mb-6",children:[e.jsx(Ns,{value:"my-drips",children:"My Drips"}),e.jsxs(Ns,{value:"starters",children:["Starter Templates",b.length>0&&e.jsx(at,{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(gs,{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(Lm,{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=j(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(at,{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(Vo,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(qa,{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:()=>N(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(iDe,{template:U,isEditing:g===U.id,onToggleEdit:()=>v(g===U.id?null:U.id),onToggleEnabled:()=>w(U),onUpdate:V=>l.mutateAsync({id:U.id,...V}),onDelete:()=>C(U.id),userId:t||""},U.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>N(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=j(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(at,{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(Vo,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(qa,{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:()=>N(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(iDe,{template:U,isEditing:g===U.id,onToggleEdit:()=>v(g===U.id?null:U.id),onToggleEnabled:()=>w(U),onUpdate:V=>l.mutateAsync({id:U.id,...V}),onDelete:()=>C(U.id),userId:t||""},U.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>N(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(mn,{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(Rvs,{template:L,onCopy:()=>A(L.id),isCopying:d.isPending},L.id))})})]})]})})}function iDe({template:t,isEditing:s,onToggleEdit:r,onToggleEnabled:n,onUpdate:a,onDelete:o,userId:l}){const[i,d]=S.useState(t.title),[u,p]=S.useState(t.subject),[g,v]=S.useState(t.body),[_,b]=S.useState(t.video_url||""),[j,w]=S.useState(t.channel),[N,C]=S.useState(t.delay_type),[A,I]=S.useState(t.delay_minutes),[L,R]=S.useState(!1),$=async()=>{R(!0);try{await a({title:i,subject:u,body:g,video_url:_||null,channel:j,delay_type:N,delay_minutes:A}),fe.success("Drip saved"),r()}catch{fe.error("Failed to save")}finally{R(!1)}},q=U=>{v(V=>V+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:()=>w(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 ${j===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:()=>C("instant"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${N==="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:()=>C("scheduled"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${N==="scheduled"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[e.jsx(In,{className:"h-3 w-3 mr-1 inline"}),"Delay"]})]})]})]}),N==="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:A>=60?Math.round(A/60):A,onChange:U=>{const V=parseInt(U.target.value)||0;I(A>=60?V*60:V)},className:"h-8 w-20 text-sm"}),e.jsx("div",{className:"flex gap-1",children:[{label:"Minutes",mins:A<60?A:30},{label:"Hours",mins:A>=60?A:60},{label:"Days",mins:A>=1440?A:1440}].map(U=>e.jsx("button",{className:`px-2 py-1 rounded text-xs border transition-colors ${U.label==="Minutes"&&A<60||U.label==="Hours"&&A>=60&&A<1440||U.label==="Days"&&A>=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))})]})]}),j==="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:j==="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..."}),Dvs.map(U=>e.jsx("option",{value:U.key,children:U.label},U.key))]})]})]}),e.jsx("textarea",{value:g,onChange:U=>v(U.target.value),placeholder:j==="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(L2e,{onVideoReady:U=>b(U)}),e.jsx(I2e,{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(Io,{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 Rvs({template:t,onCopy:s,isCopying:r}){const[n,a]=S.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(at,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:l}),e.jsxs(at,{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(at,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(In,{className:"h-3 w-3"}),t.delay_type==="instant"?"Instant":i.replace("Sends ","")]}),n?e.jsx(Vo,{className:"h-4 w-4 text-muted-foreground ml-1"}):e.jsx(qa,{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(In,{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 yet=()=>{const t=xu();return S.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 Fvs(){return S.useEffect(()=>(document.body.classList.add("cardstudio-page"),()=>{document.body.classList.remove("cardstudio-page")}),[]),e.jsxs(kFe,{children:[e.jsx(Hs,{path:"/c/:shareToken",element:e.jsx(xet,{})}),e.jsx(Hs,{path:"*",element:e.jsx(yet,{})})]})}const Ppe={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function vet({slugOverride:t}){const s=Co(),r=t||s.slug,[n,a]=S.useState("types"),[o,l]=S.useState(null),[i,d]=S.useState(null),[u,p]=S.useState(null),[g,v]=S.useState(new Date),[_,b]=S.useState({name:"",email:"",phone:"",message:""}),[j,w]=S.useState(!1),{data:N,isLoading:C}=Ct({queryKey:["public-booking-settings",r],queryFn:async()=>{const{data:Y,error:de}=await G.from("agent_booking_settings").select("*").eq("slug",r).eq("is_active",!0).single();if(de)throw de;return Y},enabled:!!r}),{data:A}=Ct({queryKey:["public-booking-profile",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Y,error:de}=await G.from("profiles").select("name, avatar_url, email, phone, title, bio").eq("id",N.user_id).single();if(de)throw de;return Y},enabled:!!(N!=null&&N.user_id)}),{data:I=[]}=Ct({queryKey:["public-booking-types",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Y,error:de}=await G.from("agent_booking_types").select("id, name, description, duration_minutes, color, icon, qualification_enabled").eq("user_id",N.user_id).eq("is_active",!0).order("sort_order");if(de)throw de;return Y},enabled:!!(N!=null&&N.user_id)}),{data:L=[]}=Ct({queryKey:["public-availability",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Y,error:de}=await G.from("agent_availability_slots").select("day_of_week, start_time, end_time").eq("user_id",N.user_id).eq("is_active",!0);if(de)throw de;return Y},enabled:!!(N!=null&&N.user_id)}),{data:R=[]}=Ct({queryKey:["public-blocked-dates",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Y,error:de}=await G.from("agent_blocked_dates").select("blocked_date").eq("user_id",N.user_id);if(de)throw de;return Y.map(ie=>ie.blocked_date)},enabled:!!(N!=null&&N.user_id)}),{data:$=[]}=Ct({queryKey:["public-existing-bookings",N==null?void 0:N.user_id,i],queryFn:async()=>{if(!i)return[];const Y=ws(i,"yyyy-MM-dd"),{data:de,error:ie}=await G.from("bookings").select("start_time, end_time").eq("agent_user_id",N.user_id).eq("booking_date",Y).eq("status","confirmed");if(ie)throw ie;return de},enabled:!!(N!=null&&N.user_id)&&!!i}),q=S.useMemo(()=>[...new Set(L.map(Y=>Y.day_of_week))],[L]),U=Y=>{const de=Hh(new Date),ie=hl(de,(N==null?void 0:N.max_advance_days)||30),ae=hl(de,0);return EN(Y,ae)||AN(Y,ie)||R.includes(ws(Y,"yyyy-MM-dd"))?!1:q.includes(Y.getDay())},V=S.useMemo(()=>{if(!i||!o||!N)return[];const Y=L.filter(be=>be.day_of_week===i.getDay()),de=o.duration_minutes,ie=N.buffer_minutes||0,ae=[],le=new Date,pe=(N.min_notice_hours||2)*60*60*1e3;for(const be of Y){const[ye,we]=be.start_time.split(":").map(Number),[Ne,Ke]=be.end_time.split(":").map(Number);let _e=UP(qP(i,ye),we);const Me=UP(qP(i,Ne),Ke);for(;O4(_e,de)<=Me;){const Te=ws(_e,"HH:mm"),Fe=ws(O4(_e,de),"HH:mm");_e.getTime()-le.getTime()>=pe&&($.some(Ue=>{const ut=Ue.start_time.slice(0,5),De=Ue.end_time.slice(0,5);return Teut})||ae.push(Te)),_e=O4(_e,de+ie)}}return ae},[i,o,L,N,$]),X=S.useMemo(()=>{const Y=g.getFullYear(),de=g.getMonth(),ie=new Date(Y,de,1),ae=new Date(Y,de+1,0),le=ie.getDay(),pe=[];for(let be=0;be{if(!(!o||!i||!u||!_.name||!N)){w(!0);try{const Y=ws(O4(UP(qP(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:N.user_id,booking_type_id:o.id,booking_date:ws(i,"yyyy-MM-dd"),start_time:u,end_time:Y,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:N.user_id,guestName:_.name,guestEmail:_.email||null,guestPhone:_.phone||null,guestMessage:_.message||null,bookingTypeName:o.name,bookingDate:ws(i,"yyyy-MM-dd"),startTime:u,endTime:Y,durationMinutes:o.duration_minutes,meetingLink:N.meeting_link||null}}).catch(ie=>console.error("Booking notify error:",ie)),a("confirmed")}catch(Y){fe.error("Failed to book: "+Y.message)}finally{w(!1)}}},te=Y=>{const[de,ie]=Y.split(":").map(Number),ae=de>=12?"PM":"AM";return`${de%12||12}:${ie.toString().padStart(2,"0")} ${ae}`};return C?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..."})]})}):N?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:[A!=null&&A.avatar_url?e.jsx("img",{src:A.avatar_url,alt:(A==null?void 0:A.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:(A==null?void 0:A.name)||"Agent"}),(A==null?void 0:A.title)&&e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:A.title})]})]})}),e.jsxs("div",{className:"px-6 py-4 flex flex-wrap gap-2",children:[(A==null?void 0:A.phone)&&e.jsxs("a",{href:`tel:${A.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(Zn,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:A.phone}),e.jsx("span",{className:"sm:hidden",children:"Call"})]}),(A==null?void 0:A.email)&&e.jsxs("a",{href:`mailto:${A.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:A.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(Y=>e.jsx("button",{onClick:()=>{l(Y),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:Y.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:Ppe[Y.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:Y.name}),Y.description&&e.jsx("p",{className:"text-xs text-slate-500 mt-0.5 line-clamp-2",children:Y.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(In,{className:"h-3 w-3"}),Y.duration_minutes,"m"]})]})})},Y.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(Ka,{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:Ppe[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(In,{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:ws(g,"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:()=>v(new Date(g.getFullYear(),g.getMonth()-1)),children:e.jsx(Ol,{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:()=>v(new Date(g.getFullYear(),g.getMonth()+1)),children:e.jsx(qa,{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(Y=>e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-slate-400 font-semibold py-2",children:Y},Y)),X.map((Y,de)=>{if(!Y)return e.jsx("div",{},`pad-${de}`);const ie=U(Y),ae=i&&ll(Y,i),le=ll(Y,new Date);return e.jsx("button",{disabled:!ie,onClick:()=>{d(Y),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":ie?"hover:bg-[#406E71]/10 text-slate-700 hover:text-[#406E71]":"text-slate-200 cursor-not-allowed"} ${le&&!ae?"ring-1 ring-[#406E71]/40":""}`,children:Y.getDate()},Y.toISOString())})]})]}),i&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(kc,{className:"h-4 w-4 text-[#406E71]"}),e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:ws(i,"EEEE, MMMM d")})]}),V.length===0?e.jsxs("div",{className:"text-center py-8 space-y-2",children:[e.jsx(In,{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:V.map(Y=>{const de=u===Y;return e.jsx("button",{onClick:()=>p(Y),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(Y)},Y)})}),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(Ka,{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:Ppe[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(kc,{className:"h-3.5 w-3.5 text-[#406E71]"}),ws(i,"EEE, MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{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:Y=>b({..._,name:Y.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:Y=>b({..._,email:Y.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(Zn,{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:Y=>b({..._,phone:Y.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(Tr,{value:_.message,onChange:Y=>b({..._,message:Y.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||j,children:j?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(la,{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 ",(A==null?void 0:A.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&&ws(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."}),((A==null?void 0:A.phone)||(A==null?void 0:A.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:[(A==null?void 0:A.phone)&&e.jsxs("a",{href:`tel:${A.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(Zn,{className:"h-3.5 w-3.5"})," Call"]}),(A==null?void 0:A.email)&&e.jsxs("a",{href:`mailto:${A.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(kc,{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 zvs(){const s=xu().pathname.slice(1).split("/")[0];return S.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(vet,{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 Bvs(){const s=xu().pathname.slice(1);return S.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(GUe,{slugOverride:s})}function _et({slugOverride:t}){const{slug:s}=Co(),r=t||s,[n,a]=S.useState(!1),[o,l]=S.useState({}),[i,d]=S.useState(0),[u,p]=S.useState(!1),{data:g,isLoading:v}=Ct({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:_=[]}=Ct({queryKey:["public-landing-page-fields",g==null?void 0:g.id],queryFn:async()=>{const{data:$,error:q}=await G.from("landing_page_fields").select("*").eq("page_id",g.id).order("sort_order");if(q)throw q;return $},enabled:!!(g!=null&&g.id)});S.useEffect(()=>{g!=null&&g.id&&G.from("landing_pages").update({view_count:(g.view_count||0)+1}).eq("id",g.id).then(()=>{})},[g==null?void 0:g.id]);const b=Ot({mutationFn:async()=>{const $=_.find(X=>X.field_type==="text"&&X.label.toLowerCase().includes("name")),q=_.find(X=>X.field_type==="email"),U=_.find(X=>X.field_type==="phone"),{error:V}=await G.from("landing_page_submissions").insert([{page_id:g.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(V)throw V},onSuccess:()=>a(!0)}),j=$=>{$.preventDefault(),!(_.filter(U=>U.is_required&&!o[U.label]).length>0)&&b.mutate()};if(v)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(!g)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 w=g.primary_color||"#406E71",N=g.accent_color||"#2a4c64",C=g,A=g.page_type==="lead_magnet",I=g.page_type==="just_listed"||g.page_type==="just_sold",L=Array.isArray(C.property_photos)?C.property_photos:[],R=C.lead_magnet_file_url||C.lead_magnet_external_url;if(n)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{background:`linear-gradient(135deg, ${w}, ${N})`},children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl p-8 max-w-md mx-4 text-center",children:[e.jsx(la,{className:"h-16 w-16 mx-auto mb-4",style:{color:w}}),e.jsx("h2",{className:"text-2xl font-bold mb-2",children:A?"Your download is ready!":"Submitted!"}),e.jsx("p",{className:"text-gray-600",children:g.success_message}),A&&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:w},children:[e.jsx(gi,{className:"h-5 w-5"}),"Download ",C.lead_magnet_file_name||"Your File"]}),g.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:g.agent_name}),g.agent_phone&&e.jsxs("a",{href:`tel:${g.agent_phone}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:w},children:[e.jsx(Zn,{className:"h-3 w-3"})," ",g.agent_phone]}),g.agent_email&&e.jsxs("a",{href:`mailto:${g.agent_email}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:w},children:[e.jsx(br,{className:"h-3 w-3"})," ",g.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(Ol,{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(qa,{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:C.property_status==="just_sold"?"#e74c3c":w},children:C.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(o_,{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(o_,{className:"h-4 w-4"})," View all ",L.length," photos"]})]}),L.length===0&&e.jsx("div",{className:"relative py-16 px-4",style:{background:g.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${g.hero_image_url}) center/cover`:`linear-gradient(135deg, ${w}, ${N})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[g.logo_url&&e.jsx("img",{src:g.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:g.hero_headline}),g.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:g.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:[C.property_price&&e.jsx("p",{className:"text-3xl md:text-4xl font-bold mb-2",style:{color:w},children:$(C.property_price)}),C.property_address&&e.jsxs("p",{className:"text-gray-600 flex items-center gap-1.5 mb-5 text-lg",children:[e.jsx(Ti,{className:"h-5 w-5 shrink-0"})," ",C.property_address]}),e.jsxs("div",{className:"flex gap-6 mb-5 py-4 border-y border-gray-100",children:[C.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(j0,{className:"h-5 w-5",style:{color:w}})," ",C.property_beds]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bedrooms"})]}),C.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($x,{className:"h-5 w-5",style:{color:w}})," ",C.property_baths]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bathrooms"})]}),C.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(kP,{className:"h-5 w-5",style:{color:w}})," ",Number(C.property_sqft).toLocaleString()]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Sq Ft"})]})]}),C.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:C.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:w},children:C.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!"}),g.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-5 pb-4 border-b",children:[g.agent_photo_url&&e.jsx("img",{src:g.agent_photo_url,alt:g.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:g.agent_name}),e.jsxs("div",{className:"flex flex-col gap-0.5 text-xs text-gray-500",children:[g.agent_phone&&e.jsxs("a",{href:`tel:${g.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Zn,{className:"h-3 w-3"})," ",g.agent_phone]}),g.agent_email&&e.jsxs("a",{href:`mailto:${g.agent_email}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(br,{className:"h-3 w-3"})," ",g.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:j,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:"*"})]}),oDe(q,o,l)]},q.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:w},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:g.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${g.hero_image_url}) center/cover`:`linear-gradient(135deg, ${w}, ${N})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[g.logo_url&&e.jsx("img",{src:g.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:g.hero_headline}),g.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:g.hero_subtext}),A&&C.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(gi,{className:"h-4 w-4"}),"Free Download: ",C.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:[A&&e.jsx("p",{className:"text-sm text-gray-500 mb-4 text-center",children:"Fill out the form below to get your free download!"}),g.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-6 pb-4 border-b",children:[g.agent_photo_url&&e.jsx("img",{src:g.agent_photo_url,alt:g.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:g.agent_name}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-500",children:[g.agent_phone&&e.jsxs("a",{href:`tel:${g.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Zn,{className:"h-3 w-3"})," ",g.agent_phone]}),g.agent_email&&e.jsxs("a",{href:`mailto:${g.agent_email}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(br,{className:"h-3 w-3"})," ",g.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:j,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:"*"})]}),oDe($,o,l)]},$.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:w},disabled:b.isPending,children:b.isPending?"Submitting...":A?"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 oDe(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(Tr,{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(tr,{value:String(a),onValueChange:l=>r(i=>({...i,[t.label]:l})),children:[e.jsx(Js,{className:"mt-1",children:e.jsx(sr,{placeholder:"Select..."})}),e.jsx(er,{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(zo,{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 $vs(){const s=xu().pathname.slice(1).split("/")[0];return S.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(_et,{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 qvs=({team:t,onSelect:s})=>{const{data:r}=Ct({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(Lt,{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(zt,{className:"text-lg truncate",children:t.name}),t.description&&e.jsx(yr,{className:"mt-1 line-clamp-2",children:t.description})]}),e.jsxs(at,{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(fn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:r.leaderProfile.avatar_url||""}),e.jsx(gn,{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(zh,{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(sh,{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(at,{variant:"outline",className:"text-xs py-0",children:"Lead Pond"}),t.shared_assets_enabled&&e.jsx(at,{variant:"outline",className:"text-xs py-0",children:"Shared Assets"}),t.shared_videos_enabled&&e.jsx(at,{variant:"outline",className:"text-xs py-0",children:"Shared Videos"})]})]})]})},Uvs=()=>{const{user:t,isAdmin:s,isBrokerageManager:r,brokerageId:n,managedBrokerages:a,selectedBrokerageId:o}=Gs(),l=o||(a.length>0?a[0].id:n),i=s?void 0:l||void 0,{teams:d,isLoading:u,createTeam:p,updateTeam:g,deleteTeam:v,addMember:_,removeMember:b,updateMemberRole:j}=rS(i),[w,N]=S.useState(!1),[C,A]=S.useState(null),{data:I}=Ct({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}=Ct({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 V of $.memberIds)await _.mutateAsync({team_id:U.id,user_id:V,role:"team_member"});N(!1)};return!r&&!s?e.jsx(Ms,{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(Ms,{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:()=>N(!0),children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(_Ke,{open:w,onOpenChange:N,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(gs,{className:"h-5 w-32 mb-3"}),e.jsx(gs,{className:"h-4 w-48 mb-4"}),e.jsx(gs,{className:"h-8 w-full"})]})},$))}),!u&&d.length===0&&!C&&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:()=>N(!0),children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Your First Team"]})]})}),!u&&d.length>0&&!C&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:d.map($=>e.jsx(qvs,{team:$,onSelect:()=>A($)},$.id))}),C&&e.jsx(vKe,{team:C,brokerageAgents:L||[],onBack:()=>A(null),onUpdate:$=>g.mutateAsync({id:C.id,...$}).then(q=>A(q)),onAddMember:($,q)=>_.mutateAsync({team_id:C.id,user_id:$,role:q}),onRemoveMember:$=>b.mutateAsync({team_id:C.id,member_id:$}),onUpdateRole:($,q)=>j.mutateAsync({team_id:C.id,member_id:$,role:q}),onDeleteTeam:()=>v.mutate(C.id),isUpdating:g.isPending,isAddingMember:_.isPending})]})})},Vvs=()=>{const{data:t,isLoading:s}=Mf(),{useTeamMembers:r}=rS(),{data:n=[],isLoading:a}=r((t==null?void 0:t.teamId)||"");if(s)return e.jsx(Ms,{title:"My Team",description:"Your team",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(gs,{className:"h-8 w-48"}),e.jsx(gs,{className:"h-40 w-full"})]})});if(!t)return e.jsx(Ms,{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(Ms,{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(at,{variant:t.role==="team_leader"?"default":"secondary",className:"capitalize",children:t.role==="team_leader"?e.jsxs(e.Fragment,{children:[e.jsx(zh,{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(ja,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(va,{className:"flex-wrap",children:[e.jsx(Ns,{value:"members",children:"Members"}),o.contact_visibility!=="private"&&e.jsxs(Ns,{value:"contacts",children:[e.jsx(Jk,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),o.lead_pond_enabled&&e.jsxs(Ns,{value:"lead-pond",children:[e.jsx(qx,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),o.shared_assets_enabled&&e.jsxs(Ns,{value:"shared-assets",children:[e.jsx($h,{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(gs,{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(fn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:((i=l.profile)==null?void 0:i.avatar_url)||""}),e.jsx(gn,{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(at,{className:"ml-auto bg-amber-500/10 text-amber-600 border-amber-500",children:[e.jsx(zh,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(at,{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(owe,{})}),o.lead_pond_enabled&&e.jsx(zs,{value:"lead-pond",className:"space-y-4",children:e.jsx(lwe,{teamId:t.teamId})}),o.shared_assets_enabled&&e.jsx(zs,{value:"shared-assets",className:"space-y-4",children:e.jsx(yKe,{teamId:t.teamId})})]})]})})};function Hvs(){const{user:t}=Gs(),s=ns(),r=Ct({queryKey:["booking-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await G.from("agent_booking_settings").select("*").eq("user_id",t.id).maybeSingle();if(N)throw N;return w},enabled:!!t}),n=Ct({queryKey:["booking-types",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await G.from("agent_booking_types").select("*").eq("user_id",t.id).order("sort_order");if(N)throw N;return w},enabled:!!t}),a=Ct({queryKey:["availability-slots",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await G.from("agent_availability_slots").select("*").eq("user_id",t.id).order("day_of_week").order("start_time");if(N)throw N;return w},enabled:!!t}),o=Ct({queryKey:["blocked-dates",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await G.from("agent_blocked_dates").select("*").eq("user_id",t.id).order("blocked_date");if(N)throw N;return w},enabled:!!t}),l=Ct({queryKey:["bookings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await G.from("bookings").select("*, booking_type:agent_booking_types(*)").eq("agent_user_id",t.id).order("booking_date",{ascending:!1});if(N)throw N;return w},enabled:!!t}),i=Ot({mutationFn:async()=>{const{data:w,error:N}=await G.from("agent_booking_settings").insert({user_id:t.id,slug:""}).select().single();if(N)throw N;const C=[{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:A}=await G.from("agent_booking_types").insert(C.map(R=>({...R,user_id:t.id})));if(A)throw A;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 w},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),s.invalidateQueries({queryKey:["booking-types"]}),s.invalidateQueries({queryKey:["availability-slots"]}),fe.success("Scheduler set up successfully!")},onError:w=>fe.error(w.message)}),d=Ot({mutationFn:async w=>{const{error:N}=await G.from("agent_booking_settings").update(w).eq("user_id",t.id);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),fe.success("Settings updated")},onError:w=>fe.error(w.message)}),u=Ot({mutationFn:async w=>{const N={...w,user_id:t.id};if(w.id){const{error:C}=await G.from("agent_booking_types").update(N).eq("id",w.id);if(C)throw C}else{const{error:C}=await G.from("agent_booking_types").insert(N);if(C)throw C}},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),fe.success("Booking type saved")},onError:w=>fe.error(w.message)}),p=Ot({mutationFn:async w=>{const{error:N}=await G.from("agent_booking_types").delete().eq("id",w);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),fe.success("Booking type deleted")},onError:w=>fe.error(w.message)}),g=Ot({mutationFn:async w=>{const N={...w,user_id:t.id};if(w.id){const{error:C}=await G.from("agent_availability_slots").update(N).eq("id",w.id);if(C)throw C}else{const{error:C}=await G.from("agent_availability_slots").insert(N);if(C)throw C}},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>fe.error(w.message)}),v=Ot({mutationFn:async w=>{const{error:N}=await G.from("agent_availability_slots").delete().eq("id",w);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>fe.error(w.message)}),_=Ot({mutationFn:async w=>{const{error:N}=await G.from("agent_blocked_dates").insert({...w,user_id:t.id});if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]}),fe.success("Date blocked")},onError:w=>fe.error(w.message)}),b=Ot({mutationFn:async w=>{const{error:N}=await G.from("agent_blocked_dates").delete().eq("id",w);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]})},onError:w=>fe.error(w.message)}),j=Ot({mutationFn:async({id:w,reason:N})=>{const{error:C}=await G.from("bookings").update({status:"cancelled",cancelled_at:new Date().toISOString(),cancel_reason:N}).eq("id",w);if(C)throw C},onSuccess:()=>{s.invalidateQueries({queryKey:["bookings"]}),fe.success("Booking cancelled")},onError:w=>fe.error(w.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:g,deleteAvailability:v,addBlockedDate:_,removeBlockedDate:b,cancelBooking:j}}const lDe={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function Wvs({types:t,onSave:s,onDelete:r}){const[n,a]=S.useState(null),[o,l]=S.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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Booking Types"}),e.jsx(yr,{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:lDe[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(at,{variant:"secondary",className:"text-xs",children:"Inactive"}),p.qualification_enabled&&e.jsxs(at,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(mP,{className:"h-3 w-3"})," Qualifying"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(In,{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(Ua,{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(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsxs(Ss,{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(Tr,{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(lDe).map(([p,g])=>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:g},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(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:u,children:"Save"})]})]})})]})}const cDe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Gvs({slots:t,onSave:s,onDelete:r}){const[n,a]=S.useState(null),[o,l]=S.useState("09:00"),[i,d]=S.useState("17:00"),u=cDe.map((g,v)=>t.filter(_=>_.day_of_week===v)),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(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(In,{className:"h-5 w-5"}),"Weekly Availability"]}),e.jsx(yr,{children:"Set your available hours for each day"})]}),e.jsx(Oe,{className:"space-y-2",children:cDe.map((g,v)=>{const _=u[v];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:g})}),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 j,w;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(j=b.start_time)==null?void 0:j.slice(0,5),onBlur:N=>s({id:b.id,start_time:N.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:(w=b.end_time)==null?void 0:w.slice(0,5),onBlur:N=>s({id:b.id,end_time:N.target.value})}),e.jsx(Br,{checked:b.is_active,onCheckedChange:N=>s({id:b.id,is_active:N})}),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===v?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(v),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add hours"]})]})]},g)})})]})}const Kvs={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 Zvs({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(at,{className:`text-xs ${Kvs[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(kc,{className:"h-3.5 w-3.5"}),ws(new Date(o.booking_date+"T00:00:00"),"MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{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(Zn,{className:"h-3 w-3"}),o.guest_phone]})]}),o.booking_type&&e.jsx(at,{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(wc,{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(Lt,{children:[e.jsx(zt,{children:"Upcoming Bookings"}),e.jsxs(yr,{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(Lt,{children:e.jsx(zt,{children:"Past & Cancelled"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:n.slice(0,20).map(o=>a(o))})})]})]})}function Yvs({blockedDates:t,onAdd:s,onRemove:r}){const[n,a]=S.useState(!1),[o,l]=S.useState(""),[i,d]=S.useState(""),u=()=>{o&&(s({blocked_date:o,reason:i||void 0}),a(!1),l(""),d(""))};return e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(JE,{className:"h-5 w-5"}),"Blocked Dates"]}),e.jsx(yr,{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:ws(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 Xvs(){const{settings:t,bookingTypes:s,availability:r,blockedDates:n,bookings:a,isLoading:o,initializeSettings:l,updateSettings:i,upsertBookingType:d,deleteBookingType:u,upsertAvailability:p,deleteAvailability:g,addBlockedDate:v,removeBlockedDate:_,cancelBooking:b}=Hvs(),[j,w]=S.useState(""),[N,C]=S.useState(15);j||t!=null&&t.meeting_link;const A=t!=null&&t.slug?`https://booking.relevelup.com/${t.slug}`:null;return o?e.jsx(Ms,{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(Ms,{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(kc,{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:[A&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(A),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:A,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rn,{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(ja,{defaultValue:"types",className:"space-y-4",children:[e.jsxs(va,{children:[e.jsx(Ns,{value:"types",children:"Booking Types"}),e.jsx(Ns,{value:"availability",children:"Availability"}),e.jsx(Ns,{value:"settings",children:"Settings"}),e.jsxs(Ns,{value:"bookings",children:["Bookings",a.filter(I=>I.status==="confirmed").length>0&&e.jsx(at,{variant:"secondary",className:"ml-1.5 text-xs",children:a.filter(I=>I.status==="confirmed").length})]})]}),e.jsx(zs,{value:"types",children:e.jsx(Wvs,{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(Gvs,{slots:r,onSave:I=>p.mutate(I),onDelete:I=>g.mutate(I)}),e.jsx(Yvs,{blockedDates:n,onAdd:I=>v.mutate(I),onRemove:I=>_.mutate(I)})]})}),e.jsx(zs,{value:"settings",children:e.jsxs(Ee,{children:[e.jsxs(Lt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(SP,{className:"h-5 w-5"}),"General Settings"]}),e.jsx(yr,{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:()=>{A&&(navigator.clipboard.writeText(A),fe.success("Copied!"))},children:e.jsx(ai,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:A})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ve,{htmlFor:"meeting-link",children:[e.jsx(Ho,{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(Zvs,{bookings:a,onCancel:I=>b.mutate({id:I})})})]})]})}):e.jsx(Ms,{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(kc,{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(sc,{}),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(mn,{className:"h-4 w-4 mr-2"}),l.isPending?"Setting up...":"Activate Scheduler"]})]})})]})})}const dDe=[{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 Qvs(){const{user:t}=Gs(),s=si(),{toast:r}=Ea(),n=Lr(),a=ns(),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState(null),[g,v]=S.useState({title:"",description:"",page_type:"lead_capture"}),{data:_=[],isLoading:b}=Ct({queryKey:["landing-pages",s],queryFn:async()=>{const{data:C,error:A}=await G.from("landing_pages").select("*").eq("user_id",s).order("created_at",{ascending:!1});if(A)throw A;return C},enabled:!!s}),j=Ot({mutationFn:async()=>{const C=g.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"")+"-"+Date.now().toString(36),{data:A}=await G.from("profiles").select("name, phone, avatar_url, email").eq("id",s).single(),I=g.page_type==="just_listed"||g.page_type==="just_sold",{data:L,error:R}=await G.from("landing_pages").insert({user_id:s,title:g.title,description:g.description||null,page_type:g.page_type,slug:C,hero_headline:I?g.page_type==="just_listed"?"🏡 Just Listed":"🎉 Just Sold":g.page_type==="lead_magnet"?"📥 Free Download":g.title,agent_name:(A==null?void 0:A.name)||null,agent_phone:(A==null?void 0:A.phone)||null,agent_email:(A==null?void 0:A.email)||t.email||null,agent_photo_url:(A==null?void 0:A.avatar_url)||null,property_status:I?g.page_type.replace("just_",""):null}).select().single();if(R)throw R;const $=Jvs(g.page_type);if($.length>0){const{error:q}=await G.from("landing_page_fields").insert($.map((U,V)=>({...U,page_id:L.id,sort_order:V})));if(q)throw q}return L},onSuccess:C=>{a.invalidateQueries({queryKey:["landing-pages"]}),l(!1),v({title:"",description:"",page_type:"lead_capture"}),r({title:"Landing page created!"}),n(`/mission-control/landing-pages/${C.id}`)},onError:C=>r({title:"Error",description:C.message,variant:"destructive"})}),w=Ot({mutationFn:async C=>{const{error:A}=await G.from("landing_pages").delete().eq("id",C);if(A)throw A},onSuccess:()=>{a.invalidateQueries({queryKey:["landing-pages"]}),d(null),r({title:"Landing page deleted"})}}),N=C=>`https://pages.relevelup.com/${C}`;return e.jsxs(Ms,{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(Sn,{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(C=>{var A;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/${C.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold truncate",children:C.title}),e.jsx(at,{variant:C.is_published?"default":"secondary",className:"text-[10px]",children:C.is_published?"Published":"Draft"}),e.jsx(at,{variant:"outline",className:"text-[10px]",children:((A=dDe.find(I=>I.id===C.page_type))==null?void 0:A.label)||C.page_type})]}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:C.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(ya,{className:"h-3 w-3"})," ",C.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"})," ",C.submission_count," submissions"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[C.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>p(N(C.slug)),children:e.jsx(P0,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(N(C.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:N(C.slug),target:"_blank",rel:"noopener noreferrer",children:e.jsx(rn,{className:"h-3.5 w-3.5"})})})]}),e.jsxs(yu,{children:[e.jsx(vu,{asChild:!0,children:e.jsx(K,{size:"sm",variant:"ghost",children:e.jsx(Jp,{className:"h-4 w-4"})})}),e.jsxs(Wd,{align:"end",children:[e.jsxs(Da,{onClick:()=>n(`/mission-control/landing-pages/${C.id}`),children:[e.jsx(Ua,{className:"h-3.5 w-3.5 mr-2"})," Edit"]}),e.jsxs(Da,{onClick:()=>d(C.id),className:"text-destructive",children:[e.jsx(jr,{className:"h-3.5 w-3.5 mr-2"})," Delete"]})]})]})]})]})})},C.id)})})]}),e.jsx(vs,{open:o,onOpenChange:l,children:e.jsxs(ys,{children:[e.jsx(Cs,{children:e.jsx(Ss,{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:g.title,onChange:C=>v(A=>({...A,title:C.target.value})),placeholder:"e.g. Veterans Home & Land Expo"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description (optional)"}),e.jsx(Tr,{value:g.description,onChange:C=>v(A=>({...A,description:C.target.value})),placeholder:"Brief internal description...",rows:2})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Page Template"}),e.jsxs(tr,{value:g.page_type,onValueChange:C=>v(A=>({...A,page_type:C})),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:dDe.map(C=>e.jsx(At,{value:C.id,children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:C.label}),e.jsx("div",{className:"text-xs text-muted-foreground",children:C.description})]})},C.id))})]})]})]}),e.jsxs(On,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>j.mutate(),disabled:!g.title.trim()||j.isPending,children:j.isPending?"Creating...":"Create Page"})]})]})}),e.jsx(tc,{open:!!i,onOpenChange:()=>d(null),children:e.jsxs(Tl,{children:[e.jsxs(Al,{children:[e.jsx(Pl,{children:"Delete Landing Page?"}),e.jsx(Il,{children:"This will permanently delete this page and all its submissions."})]}),e.jsxs(El,{children:[e.jsx(Ll,{children:"Cancel"}),e.jsx(fl,{onClick:()=>i&&w.mutate(i),children:"Delete"})]})]})}),e.jsx(vs,{open:!!u,onOpenChange:()=>p(null),children:e.jsxs(ys,{className:"max-w-sm",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[u&&e.jsx(nD,{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 Jvs(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 e1s=[{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 t1s(){const{pageId:t}=Co(),s=Lr(),{user:r}=Gs(),n=si(),{toast:a}=Ea(),o=ns(),[l,i]=S.useState(null),[d,u]=S.useState(!1),{data:p,isLoading:g}=Ct({queryKey:["landing-page",t],queryFn:async()=>{const{data:ie,error:ae}=await G.from("landing_pages").select("*").eq("id",t).single();if(ae)throw ae;return ie},enabled:!!t}),{data:v=[],isLoading:_}=Ct({queryKey:["landing-page-fields",t],queryFn:async()=>{const{data:ie,error:ae}=await G.from("landing_page_fields").select("*").eq("page_id",t).order("sort_order");if(ae)throw ae;return ie},enabled:!!t}),{data:b=[]}=Ct({queryKey:["landing-page-submissions",t],queryFn:async()=>{const{data:ie,error:ae}=await G.from("landing_page_submissions").select("*").eq("page_id",t).order("created_at",{ascending:!1});if(ae)throw ae;return ie},enabled:!!t}),{data:j=[]}=Ct({queryKey:["my-listings-for-pages",n],queryFn:async()=>{const{data:ie,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 ie},enabled:!!r&&((p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold")}),[w,N]=S.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"}),[C,A]=S.useState([]);S.useEffect(()=>{p&&N({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]),S.useEffect(()=>{v.length>0&&A(v.map(ie=>({id:ie.id,field_type:ie.field_type,label:ie.label,placeholder:ie.placeholder,is_required:ie.is_required,options:typeof ie.options=="string"?ie.options:ie.options?JSON.stringify(ie.options):null,sort_order:ie.sort_order})))},[v]);const I=Ot({mutationFn:async()=>{const{error:ie}=await G.from("landing_pages").update({title:w.title,hero_headline:w.hero_headline,hero_subtext:w.hero_subtext||null,hero_image_url:w.hero_image_url,logo_url:w.logo_url,primary_color:w.primary_color,accent_color:w.accent_color,agent_name:w.agent_name||null,agent_phone:w.agent_phone||null,agent_email:w.agent_email||null,agent_photo_url:w.agent_photo_url,success_message:w.success_message,is_published:w.is_published,description:w.description||null,lead_magnet_file_url:w.lead_magnet_file_url,lead_magnet_file_name:w.lead_magnet_file_name,lead_magnet_external_url:w.lead_magnet_external_url,listing_id:w.listing_id,property_address:w.property_address||null,property_price:w.property_price||null,property_beds:w.property_beds||null,property_baths:w.property_baths||null,property_sqft:w.property_sqft||null,property_description:w.property_description||null,property_photos:w.property_photos,property_status:w.property_status,updated_at:new Date().toISOString()}).eq("id",t);if(ie)throw ie;if(await G.from("landing_page_fields").delete().eq("page_id",t),C.length>0){const{error:ae}=await G.from("landing_page_fields").insert(C.map((le,pe)=>({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:pe})));if(ae)throw ae}},onSuccess:()=>{o.invalidateQueries({queryKey:["landing-page",t]}),o.invalidateQueries({queryKey:["landing-page-fields",t]}),a({title:"Page saved!"})},onError:ie=>a({title:"Error",description:ie.message,variant:"destructive"})}),L=async(ie,ae)=>{const le=ie.name.split(".").pop(),pe=`landing-pages/${r.id}/${ae}-${Date.now()}.${le}`,{error:be}=await G.storage.from("recruit-landing").upload(pe,ie);if(be)throw be;const{data:{publicUrl:ye}}=G.storage.from("recruit-landing").getPublicUrl(pe);return ye},R=async(ie,ae)=>{var pe;const le=(pe=ie.target.files)==null?void 0:pe[0];if(le){i(ae);try{const be=await L(le,ae);N(ye=>({...ye,[ae]:be})),a({title:"Image uploaded!"})}catch(be){a({title:"Upload failed",description:be.message,variant:"destructive"})}finally{i(null)}}},$=async ie=>{var le;const ae=(le=ie.target.files)==null?void 0:le[0];if(ae){i("lead_magnet");try{const pe=await L(ae,"lead-magnet");N(be=>({...be,lead_magnet_file_url:pe,lead_magnet_file_name:ae.name})),a({title:"File uploaded!"})}catch(pe){a({title:"Upload failed",description:pe.message,variant:"destructive"})}finally{i(null)}}},q=async ie=>{const ae=ie.target.files;if(!(!ae||ae.length===0)){i("property_photos");try{const le=[];for(const pe of Array.from(ae)){const be=await L(pe,"property-photo");le.push(be)}N(pe=>({...pe,property_photos:[...pe.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 ie=>{const ae=j.find(pe=>pe.id===ie);if(!ae)return;const{data:le}=await G.from("listing_photos").select("photo_url").eq("listing_id",ie).order("sort_order");N(pe=>({...pe,listing_id:ie,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))||pe.property_photos})),a({title:"Listing data imported!"})},V=()=>{A(ie=>[...ie,{field_type:"text",label:"",placeholder:"",is_required:!1,options:null,sort_order:ie.length}])},X=(ie,ae)=>{A(le=>le.map((pe,be)=>be===ie?{...pe,...ae}:pe))},se=ie=>{A(ae=>ae.filter((le,pe)=>pe!==ie))},te=p?`https://pages.relevelup.com/${p.slug}`:"",Y=(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 g||_?e.jsx(Ms,{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(Ms,{title:w.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(Ka,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:w.title||"Untitled Page"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx(at,{variant:w.is_published?"default":"secondary",className:"text-[10px]",children:w.is_published?"Published":"Draft"}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(ya,{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:[w.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>u(!0),children:e.jsx(P0,{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(rn,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(K,{onClick:()=>I.mutate(),disabled:I.isPending,children:[e.jsx(zu,{className:"h-4 w-4 mr-2"}),I.isPending?"Saving...":"Save"]})]})]}),e.jsxs(ja,{defaultValue:"design",children:[e.jsxs(va,{children:[e.jsx(Ns,{value:"design",children:"Design"}),Y&&e.jsx(Ns,{value:"lead_magnet",children:"Lead Magnet"}),de&&e.jsx(Ns,{value:"property",children:"Property Details"}),e.jsxs(Ns,{value:"fields",children:["Form Fields (",C.length,")"]}),e.jsxs(Ns,{value:"submissions",children:["Submissions (",b.length,")"]}),e.jsx(Ns,{value:"settings",children:"Settings"})]}),e.jsxs(zs,{value:"design",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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:w.title,onChange:ie=>N(ae=>({...ae,title:ie.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description (internal)"}),e.jsx(Re,{value:w.description,onChange:ie=>N(ae=>({...ae,description:ie.target.value}))})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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:w.hero_headline,onChange:ie=>N(ae=>({...ae,hero_headline:ie.target.value})),placeholder:"Join us for..."})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Subtext"}),e.jsx(Tr,{value:w.hero_subtext,onChange:ie=>N(ae=>({...ae,hero_subtext:ie.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:[w.hero_image_url&&e.jsx("img",{src:w.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(Xa,{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:ie=>R(ie,"hero_image_url")})]}),w.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N(ie=>({...ie,hero_image_url:null})),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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:[w.logo_url&&e.jsx("img",{src:w.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(Xa,{className:"h-3.5 w-3.5 mr-1"}),l==="logo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ie=>R(ie,"logo_url")})]})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.agent_photo_url&&e.jsx("img",{src:w.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(Xa,{className:"h-3.5 w-3.5 mr-1"}),l==="agent_photo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ie=>R(ie,"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:w.primary_color,onChange:ie=>N(ae=>({...ae,primary_color:ie.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Re,{value:w.primary_color,onChange:ie=>N(ae=>({...ae,primary_color:ie.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:w.accent_color,onChange:ie=>N(ae=>({...ae,accent_color:ie.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Re,{value:w.accent_color,onChange:ie=>N(ae=>({...ae,accent_color:ie.target.value})),className:"font-mono text-xs"})]})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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:w.agent_name,onChange:ie=>N(ae=>({...ae,agent_name:ie.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Phone"}),e.jsx(Re,{value:w.agent_phone,onChange:ie=>N(ae=>({...ae,agent_phone:ie.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Email"}),e.jsx(Re,{value:w.agent_email,onChange:ie=>N(ae=>({...ae,agent_email:ie.target.value}))})]})]})})]})]}),Y&&e.jsx(zs,{value:"lead_magnet",className:"space-y-4 mt-4",children:e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(gi,{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:[w.lead_magnet_file_name&&e.jsxs(at,{variant:"outline",className:"gap-1",children:[e.jsx(gi,{className:"h-3 w-3"})," ",w.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(Xa,{className:"h-3.5 w-3.5 mr-1"}),l==="lead_magnet"?"Uploading...":"Upload File"]})}),e.jsx("input",{type:"file",className:"hidden",onChange:$})]}),w.lead_magnet_file_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N(ie=>({...ie,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(Ho,{className:"h-3.5 w-3.5"})," External URL"]}),e.jsx(Re,{value:w.lead_magnet_external_url||"",onChange:ie=>N(ae=>({...ae,lead_magnet_external_url:ie.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(Lt,{children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Vn,{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(tr,{value:w.listing_id||"",onValueChange:ie=>U(ie),children:[e.jsx(Js,{children:e.jsx(sr,{placeholder:"Select a listing to import..."})}),e.jsx(er,{children:j.map(ie=>{var ae;return e.jsxs(At,{value:ie.id,children:[ie.property_address||`${ie.city}, ${ie.state}`," — $",(ae=ie.price)==null?void 0:ae.toLocaleString()]},ie.id)})})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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:w.property_address,onChange:ie=>N(ae=>({...ae,property_address:ie.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:w.property_price,onChange:ie=>N(ae=>({...ae,property_price:ie.target.value})),placeholder:"$450,000"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Beds"}),e.jsx(Re,{value:w.property_beds,onChange:ie=>N(ae=>({...ae,property_beds:ie.target.value})),placeholder:"4"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Baths"}),e.jsx(Re,{value:w.property_baths,onChange:ie=>N(ae=>({...ae,property_baths:ie.target.value})),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Sq Ft"}),e.jsx(Re,{value:w.property_sqft,onChange:ie=>N(ae=>({...ae,property_sqft:ie.target.value})),placeholder:"2,400"})]})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Description"}),e.jsx(Tr,{value:w.property_description,onChange:ie=>N(ae=>({...ae,property_description:ie.target.value})),rows:3,placeholder:"Beautiful home in a great neighborhood..."})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{className:"text-base",children:"Property Photos"})}),e.jsxs(Oe,{className:"space-y-4",children:[w.property_photos.length>0&&e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:w.property_photos.map((ie,ae)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:ie,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:()=>N(le=>({...le,property_photos:le.property_photos.filter((pe,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(Xa,{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:V,children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Add Field"]})]}),C.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:C.map((ie,ae)=>e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ru,{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(tr,{value:ie.field_type,onValueChange:le=>X(ae,{field_type:le}),children:[e.jsx(Js,{children:e.jsx(sr,{})}),e.jsx(er,{children:e1s.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:ie.label,onChange:le=>X(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:ie.placeholder||"",onChange:le=>X(ae,{placeholder:le.target.value}),placeholder:"Optional hint text"})]})]}),(ie.field_type==="select"||ie.field_type==="multiselect")&&e.jsxs("div",{children:[e.jsx(ve,{className:"text-xs",children:"Options (comma-separated)"}),e.jsx(Re,{value:ie.options?(typeof ie.options=="string"?JSON.parse(ie.options):ie.options).join(", "):"",onChange:le=>X(ae,{options:JSON.stringify(le.target.value.split(",").map(pe=>pe.trim()).filter(Boolean))}),placeholder:"Option 1, Option 2, Option 3"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{checked:ie.is_required,onCheckedChange:le=>X(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(ie=>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:ie.contact_name||"Anonymous"}),ie.synced_to_crm&&e.jsx(at,{variant:"outline",className:"text-[10px]",children:"Synced"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground mt-0.5",children:[ie.contact_email&&e.jsx("span",{className:"mr-3",children:ie.contact_email}),ie.contact_phone&&e.jsx("span",{children:ie.contact_phone})]}),ie.answers&&typeof ie.answers=="object"&&e.jsx("div",{className:"mt-2 text-sm space-y-1",children:Object.entries(ie.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(ie.created_at).toLocaleDateString()})]})})},ie.id))})}),e.jsxs(zs,{value:"settings",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsx(zt,{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:w.is_published,onCheckedChange:ie=>N(ae=>({...ae,is_published:ie}))})]}),w.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(Lt,{children:e.jsx(zt,{className:"text-base",children:"Thank You Message"})}),e.jsx(Oe,{children:e.jsx(Tr,{value:w.success_message,onChange:ie=>N(ae=>({...ae,success_message:ie.target.value})),rows:2,placeholder:"Message shown after form submission"})})]})]})]})]}),e.jsx(vs,{open:d,onOpenChange:u,children:e.jsxs(ys,{className:"max-w-sm",children:[e.jsx(Cs,{children:e.jsx(Ss,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx(nD,{value:te,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:te})]})]})})]}):e.jsx(Ms,{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 uDe({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(KE,{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(GE,{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(A0,{className:"h-3 w-3"}),"0%"]})}const s1s={Phone:Zn,MessageSquare:io,Mail:br,Gift:ao,PenTool:s_,Video:Nn},hDe=["bg-primary","bg-emerald-500","bg-amber-500","bg-sky-500","bg-purple-500","bg-orange-500","bg-pink-500","bg-teal-500"];function r1s(){const t=Lr(),{contactsWithScores:s,stats:r}=Qoe(),{data:n}=PL(365),{data:a}=abe(),{data:o}=EL(),l=rbe(),i=S.useMemo(()=>{if(!n)return{touchesThisMonth:0,touchesLastMonth:0,touchTrend:0};const A=new Date,I=uc(A),L=Kp(A),R=uc(Sk(A,1)),$=Kp(Sk(A,1)),q=n.filter(X=>wg(new Date(X.completed_at),{start:I,end:L})).length,U=n.filter(X=>wg(new Date(X.completed_at),{start:R,end:$})).length,V=U>0?Math.round((q-U)/U*100):q>0?100:0;return{touchesThisMonth:q,touchesLastMonth:U,touchTrend:V}},[n]),d=S.useMemo(()=>{if(!n)return 0;const A=new Date,I=uc(A),L=Kp(A);return new Set(n.filter(R=>wg(new Date(R.completed_at),{start:I,end:L})).map(R=>R.contact_id)).size},[n]),u=S.useMemo(()=>{if(!a)return{closedThisMonth:0,totalGCI:0};const A=new Date,I=uc(A),L=Kp(A),R=a.filter($=>$.close_date&&wg(new Date($.close_date),{start:I,end:L}));return{closedThisMonth:R.length,totalGCI:R.reduce(($,q)=>$+(Number(q.commission_amount)||0),0)}},[a]),p=S.useMemo(()=>{if(!s.length)return{newThisMonth:0,newLastMonth:0,trend:0};const A=new Date,I=uc(A),L=uc(Sk(A,1)),R=Kp(Sk(A,1)),$=s.filter(V=>new Date(V.created_at)>=I).length,q=s.filter(V=>wg(new Date(V.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]),g=S.useMemo(()=>{if(!n||!o)return[];const A=new Date,I=uc(A),L=Kp(A),R=n.filter(U=>wg(new Date(U.completed_at),{start:I,end:L})),$={};R.forEach(U=>{const V=U.action_type_id;$[V]=($[V]||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,V)=>V.count-U.count)},[n,o]),v=S.useMemo(()=>[...s].filter(A=>A.relationshipScore.status==="at-risk"||A.relationshipScore.status==="cooling").sort((A,I)=>{const L=A.relationshipScore.daysSinceTouch??9999;return(I.relationshipScore.daysSinceTouch??9999)-L}).slice(0,5),[s]),_=S.useMemo(()=>{if(!n)return[];const A=new Date,I=uc(A),L=Kp(A),R=new Set(n.filter($=>wg(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=S.useMemo(()=>{if(!n)return{currentStreak:0,longestStreak:0};const A=new Set(n.map(V=>{const X=new Date(V.completed_at);return`${X.getFullYear()}-${X.getMonth()}-${X.getDate()}`})),I=new Date;I.setHours(0,0,0,0);let L=0,R=new Date(I);for(;A.has(`${R.getFullYear()}-${R.getMonth()}-${R.getDate()}`);)L++,R.setDate(R.getDate()-1);let $=0,q=0;if(Array.from(A).sort().length>0){const V=n.map(X=>{const se=new Date(X.completed_at);return se.setHours(0,0,0,0),se.getTime()}).filter((X,se,te)=>te.indexOf(X)===se).sort((X,se)=>X-se);q=1;for(let X=1;X[...s].sort((A,I)=>A.relationshipScore.score-I.relationshipScore.score),[s]),w=j.filter(A=>A.relationshipScore.status==="warm"),N=j.filter(A=>A.relationshipScore.status==="cooling"),C=j.filter(A=>A.relationshipScore.status==="at-risk");return e.jsx(Ms,{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:[ws(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(Bh,{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(Ni,{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(Mm,{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(uDe,{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(Sc,{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(uDe,{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(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Uh,{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(Mi,{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(Gi,{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(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Bh,{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(Lt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Mm,{className:"h-4 w-4"}),"How You're Reaching Out"]})}),e.jsx(Oe,{children:g.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:g.slice(0,5).map((A,I)=>{const L=s1s[A.icon||""]||Mm;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:A.name})]}),e.jsxs("span",{className:"text-muted-foreground",children:[A.count," (",A.percent,"%)"]})]}),e.jsx(Mi,{value:A.percent,className:Et("h-1.5 bg-muted [&>div]:",hDe[I%hDe.length])})]},A.id)})})})]})]}),v.length>0&&e.jsxs(Ee,{className:"border-l-4 border-l-primary",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Zn,{className:"h-5 w-5 text-primary"}),"Who to Reach Out to Today"]}),e.jsxs(at,{variant:"secondary",children:[v.length," contacts"]})]}),e.jsx(yr,{children:"These relationships need attention the most"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:v.map(A=>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/${A.id}`),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(uI,{score:A.relationshipScore,showScore:!0,size:"sm",showTooltip:!1}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[A.first_name," ",A.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:A.relationshipScore.daysSinceTouch===null?"Never contacted":`Last touch ${A.relationshipScore.daysSinceTouch}d ago`})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[A.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I=>{I.stopPropagation(),window.open(`tel:${A.phone}`)},children:e.jsx(Zn,{className:"h-4 w-4"})}),A.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I=>{I.stopPropagation(),window.open(`mailto:${A.email}`)},children:e.jsx(br,{className:"h-4 w-4"})}),e.jsx(qa,{className:"h-4 w-4 text-muted-foreground"})]})]},A.id))})})]}),_.length>0&&e.jsxs(Ee,{className:"border-l-4 border-l-emerald-500",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(ec,{className:"h-5 w-5 text-emerald-500"}),"Biggest Wins This Month"]}),e.jsx(yr,{children:"Relationships you've successfully warmed up"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:_.map(A=>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/${A.id}`),children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),e.jsxs("span",{className:"text-sm font-medium",children:[A.first_name," ",A.last_name]}),e.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400 font-bold",children:A.relationshipScore.score})]},A.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(Mi,{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(Mi,{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(Mi,{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(rP,{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(ja,{defaultValue:"at-risk",children:[e.jsxs(va,{children:[e.jsxs(Ns,{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(Ns,{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(Ns,{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:C},{key:"cooling",contacts:N},{key:"warm",contacts:w}].map(({key:A,contacts:I})=>e.jsx(zs,{value:A,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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Contact"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Last Touch"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Touches (12mo)"}),e.jsx(jt,{children:"Score"}),e.jsx(jt,{className:"w-10"})]})}),e.jsx(En,{children:I.slice(0,20).map(L=>e.jsxs(js,{className:"cursor-pointer",onClick:()=>t(`/mission-control/contacts/${L.id}`),children:[e.jsxs(it,{className:"font-medium",children:[L.first_name," ",L.last_name]}),e.jsx(it,{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(it,{className:"hidden md:table-cell",children:L.relationshipScore.touchCountLast12Months}),e.jsx(it,{children:e.jsx(uI,{score:L.relationshipScore,showScore:!0})}),e.jsx(it,{children:e.jsx(qa,{className:"h-4 w-4 text-muted-foreground"})})]},L.id))})]})})})},A))]})]})})}function bet(){const{user:t}=Gs(),s=ns(),{data:r,isLoading:n}=Ct({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=Ot({mutationFn:async u=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:p,error:g}=await G.from("contact_intake_pages").insert({user_id:t.id,slug:u.toLowerCase().replace(/[^a-z0-9-]/g,"-")}).select().single();if(g)throw g;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=Ot({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}=Ct({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=Ot({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page. Create your Connect page first.");const{data:p,error:g}=await G.from("contact_intake_tokens").insert({contact_id:u,intake_page_id:r.id}).select("token").single();if(g)throw g;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 n1s(){const{user:t}=Gs();return Ct({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 a1s(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 LE=[{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:Zn,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:Ti,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:Ou,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:Vn,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:Im,description:"Untagged — won't appear in filtered lists or plans",check:t=>!t.tags||t.tags.length===0,color:"text-slate-500"}];function j4(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 i1s({contact:t,onClose:s}){const r=ebe(),[n,a]=S.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=LE.filter(i=>i.fieldKey&&i.check(t));return e.jsx(fM,{open:!0,onOpenChange:()=>s(),children:e.jsxs(tS,{className:"sm:max-w-md overflow-y-auto",children:[e.jsxs(gM,{children:[e.jsxs(xM,{children:["Quick Edit — ",t.first_name," ",t.last_name]}),e.jsxs(Z9e,{children:["Fill in missing fields to improve this contact's completeness (",j4(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(at,{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:Et(!t.email&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(Zn,{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:Et(!t.phone&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(Ti,{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:Et(!t.address&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(Ou,{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:Et(!t.birthday&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ve,{className:"flex items-center gap-1.5",children:[e.jsx(Vn,{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:Et(!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(zu,{className:"h-4 w-4 mr-1.5"}),r.isPending?"Saving...":"Save Changes"]}),e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"})]})]})]})})}const Ipe="Quick favor — can you update your info? 🙏",mDe=`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 o1s(){const t=Lr(),{data:s,isLoading:r}=Xh(),{data:n}=Ef(),{intakePage:a}=bet(),{isGmailConnected:o,gmailEmail:l}=py(),{data:i}=n1s(),[d,u]=S.useState("blocked"),[p,g]=S.useState("all"),[v,_]=S.useState(null),[b,j]=S.useState(!1),[w,N]=S.useState(!1),[C,A]=S.useState(null),[I,L]=S.useState([]),[R,$]=S.useState(""),[q,U]=S.useState(""),V=S.useMemo(()=>s?p==="all"?s:s.filter(_e=>{var Me;return(Me=_e.tags)==null?void 0:Me.some(Te=>Te.relationship_type_id===p)}):[],[s,p]),X=S.useMemo(()=>V.filter(_e=>!_e.email&&!_e.phone),[V]),se=S.useMemo(()=>{if(!V.length)return{overallCompleteness:0,fullyComplete:0,contactsByGap:{}};const _e={};_e.blocked=X,LE.forEach(Ae=>{_e[Ae.key]=V.filter(Ae.check)});const Me=V.map(j4),Te=V.length>0?Math.round(Me.reduce((Ae,Ue)=>Ae+Ue,0)/V.length):0,Fe=Me.filter(Ae=>Ae===100).length;return{contactsByGap:_e,overallCompleteness:Te,fullyComplete:Fe}},[V,X]),te=S.useMemo(()=>{if(!s||s.length===0)return null;const _e=uc(Sk(new Date,1)),Me=s.filter(Ue=>new Date(Ue.created_at)<_e);if(Me.length===0)return null;const Te=Math.round(Me.map(j4).reduce((Ue,ut)=>Ue+ut,0)/Me.length),Fe=se.overallCompleteness,Ae=Fe-Te;return{oldCompleteness:Te,currentCompleteness:Fe,diff:Ae,oldCount:Me.length}},[s,se.overallCompleteness]),Y=V.length,de=S.useCallback(()=>{var Dt;const _e=se.contactsByGap[d];if(!(_e!=null&&_e.length))return;const Me=d==="blocked"?"Outreach Blocked":((Dt=LE.find(he=>he.key===d))==null?void 0:Dt.label)||d,Te=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Completeness %"],Fe=_e.map(he=>[he.first_name,he.last_name||"",he.email||"",he.phone||"",he.address||"",he.birthday||"",he.home_anniversary||"",j4(he).toString()]),Ae=[Te.join(","),...Fe.map(he=>he.map(Ve=>`"${Ve.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,"-")}-${ws(new Date,"yyyy-MM-dd")}.csv`,De.click(),URL.revokeObjectURL(ut),an({title:`Exported ${_e.length} contacts to CSV`})},[se.contactsByGap,d]),ie=S.useCallback(async _e=>{if(!a)return null;try{const{data:Me,error:Te}=await G.from("contact_intake_tokens").insert({contact_id:_e,intake_page_id:a.id}).select("token").single();if(Te)throw Te;return Me.token}catch{return null}},[a]),ae=S.useCallback(_e=>a?`https://contacts.relevelup.com/${a.slug}?t=${_e}`:"",[a]),le=S.useCallback(async _e=>{if(!a){fe.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const Me=await ie(_e);Me?(await navigator.clipboard.writeText(ae(Me)),fe.success("Update link copied!")):fe.error("Failed to generate link")},[a,ie,ae,t]),pe=S.useCallback(async _e=>{if(!a){fe.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}if(!_e.email){fe.error("This contact has no email address");return}const Me=await ie(_e.id);if(!Me){fe.error("Failed to generate link");return}const Te=ae(Me),Fe=mDe.replace("{{update_link}}",Te).replace(/\{\{first_name\}\}/g,_e.first_name).replace(/\{\{last_name\}\}/g,_e.last_name||""),Ae=Ipe.replace(/\{\{first_name\}\}/g,_e.first_name).replace(/\{\{last_name\}\}/g,_e.last_name||"");if(o)A({id:_e.id,first_name:_e.first_name,last_name:_e.last_name,email:_e.email}),L([]),$(Ae),U(Fe),N(!0);else{const Ue=encodeURIComponent(Ipe.replace("{{first_name}}",_e.first_name)),ut=encodeURIComponent(Fe.replace(/\{\{first_name\}\}/g,_e.first_name));window.location.href=`mailto:${_e.email}?subject=${Ue}&body=${ut}`}},[a,ie,ae,o,t]),be=S.useCallback(async _e=>{if(!a){fe.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const Me=_e.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}j(!0);try{const{data:Te,error:Fe}=await G.functions.invoke("process-intake-submissions",{body:{action:"generate_tokens",contact_ids:Me.map(he=>he.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(he=>(he==null?void 0:he.contact_id)&&(he==null?void 0:he.token)).map(he=>[he.contact_id,he.token]));if(ut.size===0&&(await Promise.all(Me.map(async Ve=>({contactId:Ve.id,token:await ie(Ve.id)})))).forEach(({contactId:Ve,token:nt})=>{nt&&ut.set(Ve,nt)}),ut.size===0){fe.error("Failed to generate update links. Please try again.");return}const De=Me.filter(he=>ut.has(he.id)).map(he=>({id:he.id,first_name:he.first_name,last_name:he.last_name,email:he.email,updateLink:ae(ut.get(he.id))})),Dt=mDe;A(null),L(De),$(Ipe),U(Dt),N(!0),fe.success(`Ready to email ${De.length} contacts`)}catch{fe.error("Failed to generate links")}finally{j(!1)}},[a,o,ae,ie,t]),we=[{key:"blocked",label:"Outreach Blocked",icon:a0,color:"text-destructive",description:"Missing BOTH email AND phone — completely unreachable"},...LE].find(_e=>_e.key===d),Ne=se.contactsByGap[d]||[],Ke=Ne.filter(_e=>_e.email).length;return e.jsxs(Ms,{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(Ux,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(tr,{value:p,onValueChange:g,children:[e.jsx(Js,{className:"w-[180px]",children:e.jsx(sr,{placeholder:"Filter by tag"})}),e.jsxs(er,{children:[e.jsx(At,{value:"all",children:"All Contacts"}),n==null?void 0:n.map(_e=>e.jsx(At,{value:_e.id,children:_e.name},_e.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:Et("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:["/ ",Y]})]})]})]}),e.jsx(Mi,{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."})]})}),X.length>0&&e.jsx(Ee,{className:Et("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(a0,{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:X.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:LE.map(_e=>{var Ue;const Me=((Ue=se.contactsByGap[_e.key])==null?void 0:Ue.length)||0,Te=Y>0?Math.round(Me/Y*100):0,Fe=_e.icon,Ae=d===_e.key;return e.jsx(Ee,{className:Et("cursor-pointer transition-all hover:shadow-md",Ae&&"ring-2 ring-primary"),onClick:()=>u(_e.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:Et("h-5 w-5",_e.color)}),e.jsx("span",{className:"text-sm font-medium",children:_e.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(Mi,{value:100-Te,className:"mt-2 h-1.5"})]})},_e.key)})}),e.jsxs(Ee,{children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg",children:[(we==null?void 0:we.label)||"Contacts"," — Contacts to Fix"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(at,{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(gi,{className:"h-3.5 w-3.5"}),"Export"]}),Ke>0&&a&&e.jsxs(K,{size:"sm",onClick:()=>be(Ne),disabled:b,className:"gap-1.5",children:[b?e.jsx(As,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ta,{className:"h-3.5 w-3.5"}),"Email ",Ke," Update Links"]})]})]})]}),e.jsx(yr,{children:we==null?void 0:we.description})]}),e.jsx(Oe,{className:"p-0",children:Ne.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(la,{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(Tn,{children:[e.jsx(An,{children:e.jsxs(js,{children:[e.jsx(jt,{children:"Contact"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Email"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Phone"}),e.jsx(jt,{children:"Completeness"}),e.jsx(jt,{className:"w-28",children:"Actions"})]})}),e.jsx(En,{children:Ne.map(_e=>{const Me=a1s(i,_e.id);return e.jsxs(js,{children:[e.jsx(it,{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/${_e.id}`),children:[_e.first_name," ",_e.last_name]}),!_e.email&&!_e.phone&&d!=="blocked"&&e.jsx(at,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"Blocked"}),Me&&e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsxs(at,{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(Hc,{children:["Last bulk emailed ",ws(new Date(Me),"MMM d, yyyy h:mm a")]})]})]})}),e.jsx(it,{className:"hidden md:table-cell text-muted-foreground",children:_e.email||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(it,{className:"hidden md:table-cell text-muted-foreground",children:_e.phone||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(it,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mi,{value:j4(_e),className:"h-2 w-16"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[j4(_e),"%"]})]})}),e.jsx(it,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>_(_e),children:e.jsx(o0,{className:"h-3.5 w-3.5"})})}),e.jsx(Hc,{children:"Quick edit"})]}),(_e.email||_e.phone)&&a&&e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>le(_e.id),children:e.jsx(ai,{className:"h-3.5 w-3.5"})})}),e.jsx(Hc,{children:"Copy update link"})]}),_e.email&&a&&e.jsxs(nd,{children:[e.jsx(ad,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>pe(_e),children:e.jsx(br,{className:"h-3.5 w-3.5"})})}),e.jsx(Hc,{children:"Email update link"})]})]})})]},_e.id)})})]})})]})]}),v&&e.jsx(i1s,{contact:v,onClose:()=>_(null)}),e.jsx(TM,{open:w,onOpenChange:N,contact:C||void 0,bulkContacts:I.length>0?I:void 0,defaultSubject:R,defaultBody:q,gmailEmail:l})]})}function l1s(){const{user:t}=Gs(),{intakePage:s,isLoading:r,createPage:n,updatePage:a,submissions:o,loadingSubmissions:l}=bet(),[i,d]=S.useState(""),[u,p]=S.useState(""),[g,v]=S.useState(!1);S.useEffect(()=>{s&&p(s.welcome_message||"")},[s]),S.useEffect(()=>{if(t!=null&&t.email&&!s){const A=t.email.split("@")[0];d(A.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(As,{className:"h-5 w-5 animate-spin text-muted-foreground"})})});if(!s)return e.jsxs(Ee,{children:[e.jsx(Lt,{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(Ho,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{children:"Connect Page"}),e.jsx(yr,{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:A=>d(A.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(As,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Connect Page"]})]})})]});const j=o.filter(A=>!A.is_processed),w=o.filter(A=>A.is_processed),N=j.length,C=(A,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:[A.first_name," ",A.last_name||""]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5",children:[A.email&&e.jsx("span",{children:A.email}),A.phone&&e.jsx("span",{children:A.phone})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[A.real_estate_interest&&A.real_estate_interest!=="not_now"&&e.jsx(at,{variant:"outline",className:"text-xs",children:A.real_estate_interest==="buying"?"🏠 Buying":A.real_estate_interest==="selling"?"📋 Selling":A.real_estate_interest==="both"?"🔄 Both":A.real_estate_interest}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(In,{className:"h-3 w-3"}),ws(new Date(A.created_at),"MMM d")]}),I&&e.jsx(la,{className:"h-4 w-4 text-emerald-500"})]})]},A.id);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Lt,{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(Ho,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{children:"Connect Page"}),e.jsx(yr,{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:A=>a.mutate({is_active:A})})]})]})}),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(rn,{className:"h-3.5 w-3.5"})})})]}),e.jsxs("div",{children:[e.jsx(ve,{children:"Welcome Message"}),g?e.jsxs("div",{className:"mt-1.5 space-y-2",children:[e.jsx("textarea",{value:u,onChange:A=>p(A.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}),v(!1)},children:"Save"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>v(!1),children:"Cancel"})]})]}):e.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground cursor-pointer hover:text-foreground transition-colors",onClick:()=>v(!0),children:s.welcome_message||"Click to set a welcome message..."})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Lt,{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(zt,{className:"text-base",children:"New Submissions"}),N>0&&e.jsxs(yr,{children:[N," awaiting sync"]})]})]}),N>0&&e.jsxs(K,{size:"sm",onClick:async()=>{try{const{data:A,error:I}=await G.functions.invoke("process-intake-submissions",{body:{action:"process_all"}});if(I)throw I;fe.success(`Synced ${A.processed} contacts to your CRM!`)}catch{fe.error("Failed to sync")}},className:"gap-1.5",children:["Sync ",N," to CRM"]})]})}),e.jsx(Oe,{children:l?e.jsx(As,{className:"h-5 w-5 animate-spin text-muted-foreground"}):j.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:j.map(A=>C(A,!1))})})]}),w.length>0&&e.jsxs(Ee,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(la,{className:"h-5 w-5 text-emerald-500"}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-base",children:"Synced to CRM"}),e.jsxs(yr,{children:[w.length," contacts already in your database"]})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[w.slice(0,10).map(A=>C(A,!0)),w.length>10&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-1",children:["+ ",w.length-10," more synced contacts"]})]})})]})]})}function c1s(){return e.jsx(Ms,{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(l1s,{})]})})}const d1s=S.lazy(()=>ev(()=>import("./PostcardManager-lNdBB4Ac.js"),[])),u1s=S.lazy(()=>ev(()=>import("./HomeReelManager-z3a9si1y.js"),[])),h1s=S.lazy(()=>ev(()=>import("./AdminCredits-b08N8yHA.js"),[])),m1s=new Kdt,p1s=()=>{const t=window.location.hostname;return t==="listings.relevelup.com"||t.startsWith("listings.")},f1s=()=>{const t=window.location.hostname;return t==="cards.relevelup.com"||t.startsWith("cards.")},g1s=()=>{const t=window.location.hostname;return t==="presentations.relevelup.com"||t.startsWith("presentations.")},x1s=()=>{const t=window.location.hostname;return t==="guestbook.relevelup.com"||t.startsWith("guestbook.")},y1s=()=>{const t=window.location.hostname;return t==="clients.relevelup.com"||t.startsWith("clients.")},v1s=()=>{const t=window.location.hostname;return t==="cardstudio.relevelup.com"||t.startsWith("cardstudio.")},_1s=()=>{const t=window.location.hostname;return t==="booking.relevelup.com"||t.startsWith("booking.")},b1s=()=>{const t=window.location.hostname;return t==="contacts.relevelup.com"||t.startsWith("contacts.")},w1s=()=>{const t=window.location.hostname;return t==="pages.relevelup.com"||t.startsWith("pages.")},j1s=()=>e.jsx(Jdt,{client:m1s,children:e.jsx(EFe,{children:e.jsxs(YN,{children:[e.jsx(plt,{}),e.jsx(Wlt,{}),e.jsx(uht,{children:e.jsx(pft,{children:e.jsx(fft,{children:e.jsxs(xft,{children:[e.jsx(gft,{}),e.jsx(Zxt,{}),e.jsx(uyt,{}),v1s()?e.jsx(Fvs,{}):f1s()?e.jsx(A0t,{}):p1s()?e.jsx(Qyt,{}):g1s()?e.jsx(I0t,{}):x1s()?e.jsx(sbt,{}):y1s()?e.jsx(vbt,{}):_1s()?e.jsx(zvs,{}):b1s()?e.jsx(Bvs,{}):w1s()?e.jsx($vs,{}):e.jsxs(kFe,{children:[e.jsx(Hs,{path:"/",element:e.jsx(Mbt,{})}),e.jsx(Hs,{path:"/privacy-policy",element:e.jsx(Tbt,{})}),e.jsx(Hs,{path:"/terms-of-service",element:e.jsx(Abt,{})}),e.jsx(Hs,{path:"/data-deletion",element:e.jsx(Ebt,{})}),e.jsx(Hs,{path:"/public/listings",element:e.jsx(l9e,{})}),e.jsx(Hs,{path:"/public/listing/:slugOrId",element:e.jsx(Ajt,{})}),e.jsx(Hs,{path:"/card/:slug",element:e.jsx(Ejt,{})}),e.jsx(Hs,{path:"/join-brokerage/:slug",element:e.jsx(B0s,{})}),e.jsx(Hs,{path:"/recruit-video/:shareToken",element:e.jsx(q0s,{})}),e.jsx(Hs,{path:"/connect/:slug",element:e.jsx(GUe,{})}),e.jsx(Hs,{path:"/auth",element:e.jsx(Ibt,{})}),e.jsx(Hs,{path:"/subscription-success",element:e.jsx(Lbt,{})}),e.jsx(Hs,{path:"/subscription",element:e.jsx(ur,{children:e.jsx(z2t,{})})}),e.jsxs(Hs,{path:"/share/video",element:e.jsx(Sjt,{}),children:[e.jsx(Hs,{path:":shareToken",element:e.jsx(j3e,{})}),e.jsx(Hs,{path:":shareToken/r/:recipientToken",element:e.jsx(j3e,{})})]}),e.jsx(Hs,{path:"/p/:shareToken",element:e.jsx(ivs,{})}),e.jsx(Hs,{path:"/portal/:slug",element:e.jsx(mvs,{})}),e.jsx(Hs,{path:"/og/video/:token",element:e.jsx(Cjt,{})}),e.jsx(Hs,{path:"/setup-brokerage",element:e.jsx(ur,{children:e.jsx(B2t,{})})}),e.jsx(Hs,{path:"/claim-account",element:e.jsx(_3e,{})}),e.jsx(Hs,{path:"/claim",element:e.jsx(_3e,{})}),e.jsx(Hs,{path:"/join",element:e.jsx($2t,{})}),e.jsx(Hs,{path:"/trial",element:e.jsx(Q2t,{})}),e.jsx(Hs,{path:"/trial/success",element:e.jsx(J2t,{})}),e.jsx(Hs,{path:"/dashboard",element:e.jsx(ur,{children:e.jsx(Z5t,{})})}),e.jsx(Hs,{path:"/profile",element:e.jsx(ur,{children:e.jsx(ILt,{})})}),e.jsx(Hs,{path:"/apps",element:e.jsx(ur,{children:e.jsx(WLt,{})})}),e.jsx(Hs,{path:"/admin",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(E8t,{})})}),e.jsx(Hs,{path:"/admin/apps",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(L8t,{})})}),e.jsx(Hs,{path:"/admin/members",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(q8t,{})})}),e.jsx(Hs,{path:"/admin/invite-codes",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(U8t,{})})}),e.jsx(Hs,{path:"/admin/events",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Z8t,{})})}),e.jsx(Hs,{path:"/events",element:e.jsx(ur,{children:e.jsx(ULt,{})})}),e.jsx(Hs,{path:"/events/:eventId",element:e.jsx(ur,{children:e.jsx(HLt,{})})}),e.jsx(Hs,{path:"/templates",element:e.jsx(ur,{children:e.jsx(GLt,{})})}),e.jsx(Hs,{path:"/templates/:templateId",element:e.jsx(ur,{children:e.jsx(XLt,{})})}),e.jsx(Hs,{path:"/admin/templates",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(X8t,{})})}),e.jsx(Hs,{path:"/academy",element:e.jsx(ur,{children:e.jsx(QLt,{})})}),e.jsx(Hs,{path:"/academy/:videoId",element:e.jsx(ur,{children:e.jsx(eDt,{})})}),e.jsx(Hs,{path:"/admin/academy",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(J8t,{})})}),e.jsx(Hs,{path:"/toolbox",element:e.jsx(ur,{children:e.jsx(tDt,{})})}),e.jsx(Hs,{path:"/toolbox/:kitId",element:e.jsx(ur,{children:e.jsx(sDt,{})})}),e.jsx(Hs,{path:"/admin/toolbox",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(eRt,{})})}),e.jsx(Hs,{path:"/social-swag",element:e.jsx(ur,{children:e.jsx(rDt,{})})}),e.jsx(Hs,{path:"/social-swag-2",element:e.jsx(ur,{children:e.jsx(t8t,{})})}),e.jsx(Hs,{path:"/social-swag/:swagId",element:e.jsx(ur,{children:e.jsx(s8t,{})})}),e.jsx(Hs,{path:"/social-connections",element:e.jsx(ur,{children:e.jsx(U0s,{})})}),e.jsx(Hs,{path:"/social-connections/callback",element:e.jsx(ur,{children:e.jsx(V0s,{})})}),e.jsx(Hs,{path:"/social-connections/linkedin-callback",element:e.jsx(ur,{children:e.jsx(W0s,{})})}),e.jsx(Hs,{path:"/social-connections/google-callback",element:e.jsx(ur,{children:e.jsx(H0s,{})})}),e.jsx(Hs,{path:"/admin/social-swag",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(tRt,{})})}),e.jsx(Hs,{path:"/admin/social-swag-2",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(FFt,{})})}),e.jsx(Hs,{path:"/community",element:e.jsx(ur,{children:e.jsx(b8t,{})})}),e.jsx(Hs,{path:"/support",element:e.jsx(ur,{children:e.jsx(w8t,{})})}),e.jsx(Hs,{path:"/admin/community",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(zFt,{})})}),e.jsx(Hs,{path:"/admin/support-tickets",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(ZFt,{})})}),e.jsx(Hs,{path:"/admin/email-templates",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(QFt,{})})}),e.jsx(Hs,{path:"/admin/agent-email-templates",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(JFt,{})})}),e.jsx(Hs,{path:"/admin/analytics",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(WFt,{})})}),e.jsx(Hs,{path:"/admin/brokerage-resources",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(GFt,{})})}),e.jsx(Hs,{path:"/admin/dashboard-management",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(KFt,{})})}),e.jsx(Hs,{path:"/brokerage/dashboard",element:e.jsx(ur,{requireBrokerageManager:!0,children:e.jsx(uzt,{})})}),e.jsx(Hs,{path:"/brokerage/teams",element:e.jsx(ur,{requireBrokerageManager:!0,children:e.jsx(Uvs,{})})}),e.jsx(Hs,{path:"/my-team",element:e.jsx(ur,{children:e.jsx(Vvs,{})})}),e.jsx(Hs,{path:"/my-brokerage",element:e.jsx(ur,{children:e.jsx(xzt,{})})}),e.jsx(Hs,{path:"/brokerage-content",element:e.jsx(ur,{children:e.jsx(jzt,{})})}),e.jsx(Hs,{path:"/brokerage-content/:contentId",element:e.jsx(ur,{children:e.jsx(Mzt,{})})}),e.jsx(Hs,{path:"/brokerage-resources",element:e.jsx(ur,{requireBrokerageManager:!0,children:e.jsx(M8t,{})})}),e.jsx(Hs,{path:"/brokerage-resources/:resourceId",element:e.jsx(ur,{requireBrokerageManager:!0,children:e.jsx(T8t,{})})}),e.jsx(Hs,{path:"/newsletters",element:e.jsx(ur,{children:e.jsx(Tzt,{})})}),e.jsx(Hs,{path:"/newsletters/:id",element:e.jsx(ur,{children:e.jsx(Ezt,{})})}),e.jsx(Hs,{path:"/wishlist",element:e.jsx(ur,{children:e.jsx(Lzt,{})})}),e.jsx(Hs,{path:"/wishlist/:itemId",element:e.jsx(ur,{children:e.jsx(Dzt,{})})}),e.jsx(Hs,{path:"/admin/wishlist",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Ozt,{})})}),e.jsx(Hs,{path:"/admin/levelup-brief",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Rzt,{})})}),e.jsx(Hs,{path:"/admin/newsletters",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Izt,{})})}),e.jsx(Hs,{path:"/admin/additional-services",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Fzt,{})})}),e.jsx(Hs,{path:"/admin/discounts",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(zzt,{})})}),e.jsx(Hs,{path:"/admin/subscriptions",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Bzt,{})})}),e.jsx(Hs,{path:"/admin/referrals",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx($zt,{})})}),e.jsx(Hs,{path:"/admin/prospector",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Kxs,{})})}),e.jsx(Hs,{path:"/admin/recruiting",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(gys,{})})}),e.jsx(Hs,{path:"/admin/beta/social-post-generator",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(x0s,{})})}),e.jsx(Hs,{path:"/admin/credits",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(h1s,{})})})}),e.jsx(Hs,{path:"/admin/beta/postcard-manager",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(d1s,{})})})}),e.jsx(Hs,{path:"/admin/beta/homereel",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(u1s,{})})})}),e.jsx(Hs,{path:"/admin/lms",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(E0s,{})})}),e.jsx(Hs,{path:"/admin/lms/stats",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(O0s,{})})}),e.jsx(Hs,{path:"/admin/lms/:courseId",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(P0s,{})})}),e.jsx(Hs,{path:"/levelup-u",element:e.jsx(ur,{children:e.jsx(R0s,{})})}),e.jsx(Hs,{path:"/levelup-u/:courseId",element:e.jsx(ur,{children:e.jsx(z0s,{})})}),e.jsx(Hs,{path:"/admin/brokerage-content-activity",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(xys,{})})}),e.jsx(Hs,{path:"/admin/onboarding-checklist",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Uzt,{})})}),e.jsx(Hs,{path:"/admin/marketplace",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Nxs,{})})}),e.jsx(Hs,{path:"/admin/agent-points",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Zgs,{})})}),e.jsx(Hs,{path:"/admin/reward-store",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Bxs,{})})}),e.jsx(Hs,{path:"/admin/integrations",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(qxs,{})})}),e.jsx(Hs,{path:"/admin/integrations/callback",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Gxs,{})})}),e.jsx(Hs,{path:"/reward-store",element:e.jsx(ur,{children:e.jsx(evs,{})})}),e.jsx(Hs,{path:"/additional-services",element:e.jsx(ur,{children:e.jsx(e7t,{})})}),e.jsx(Hs,{path:"/additional-services/:serviceId",element:e.jsx(ur,{children:e.jsx(t7t,{})})}),e.jsx(Hs,{path:"/ai-toolkit",element:e.jsx(ur,{children:e.jsx(s7t,{})})}),e.jsx(Hs,{path:"/mission-control",element:e.jsx(ur,{children:e.jsx(x7t,{})})}),e.jsx(Hs,{path:"/mission-control/contacts",element:e.jsx(ur,{children:e.jsx(Y7t,{})})}),e.jsx(Hs,{path:"/mission-control/contacts/:contactId",element:e.jsx(ur,{children:e.jsx(_Bt,{})})}),e.jsx(Hs,{path:"/mission-control/plans",element:e.jsx(ur,{children:e.jsx(bBt,{})})}),e.jsx(Hs,{path:"/mission-control/popbys",element:e.jsx(ur,{children:e.jsx(kBt,{})})}),e.jsx(Hs,{path:"/mission-control/popbys/map",element:e.jsx(ur,{children:e.jsx(NBt,{})})}),e.jsx(Hs,{path:"/admin/notification-settings",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Vxs,{})})}),e.jsx(Hs,{path:"/admin/agent-os",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Hzt,{})})}),e.jsx(Hs,{path:"/mission-control/listings",element:e.jsx(ur,{children:e.jsx(mps,{})})}),e.jsx(Hs,{path:"/mission-control/listings/new",element:e.jsx(ur,{children:e.jsx(wLe,{})})}),e.jsx(Hs,{path:"/mission-control/listings/:listingId",element:e.jsx(ur,{children:e.jsx(Mps,{})})}),e.jsx(Hs,{path:"/mission-control/listings/:listingId/edit",element:e.jsx(ur,{children:e.jsx(wLe,{})})}),e.jsx(Hs,{path:"/admin/listing-exchange",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Ugs,{})})}),e.jsx(Hs,{path:"/mission-control/pipeline",element:e.jsx(ur,{children:e.jsx(Xfs,{})})}),e.jsx(Hs,{path:"/mission-control/tasks",element:e.jsx(ur,{children:e.jsx(ogs,{})})}),e.jsx(Hs,{path:"/mission-control/my-card",element:e.jsx(ur,{children:e.jsx(Cgs,{})})}),e.jsx(Hs,{path:"/mission-control/integrations",element:e.jsx(ur,{children:e.jsx(Ogs,{})})}),e.jsx(Hs,{path:"/mission-control/integrations/gmail/callback",element:e.jsx(ur,{children:e.jsx(Rgs,{})})}),e.jsx(Hs,{path:"/mission-control/integrations/canva/callback",element:e.jsx(Fgs,{})}),e.jsx(Hs,{path:"/mission-control/integrations/meta/callback",element:e.jsx(ur,{children:e.jsx(zgs,{})})}),e.jsx(Hs,{path:"/mission-control/scorecard",element:e.jsx(ur,{children:e.jsx(rps,{})})}),e.jsx(Hs,{path:"/admin/scorecard",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx($gs,{})})}),e.jsx(Hs,{path:"/admin/scorecard/:userId",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(PLe,{})})}),e.jsx(Hs,{path:"/mission-control/scorecard/:userId",element:e.jsx(ur,{children:e.jsx(PLe,{})})}),e.jsx(Hs,{path:"/mission-control/relationship-scorecard",element:e.jsx(ur,{children:e.jsx(r1s,{})})}),e.jsx(Hs,{path:"/mission-control/sphere-gaps",element:e.jsx(ur,{children:e.jsx(o1s,{})})}),e.jsx(Hs,{path:"/mission-control/connect-page",element:e.jsx(ur,{children:e.jsx(c1s,{})})}),e.jsx(Hs,{path:"/admin/membership-reviews",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Vgs,{})})}),e.jsx(Hs,{path:"/admin/weekly-digest",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Ggs,{})})}),e.jsx(Hs,{path:"/mission-control/video/record",element:e.jsx(ur,{children:e.jsx(Fps,{})})}),e.jsx(Hs,{path:"/mission-control/video-library",element:e.jsx(ur,{children:e.jsx(Jps,{})})}),e.jsx(Hs,{path:"/marketplace",element:e.jsx(ur,{children:e.jsx(G0s,{})})}),e.jsx(Hs,{path:"/marketplace/:productId",element:e.jsx(ur,{children:e.jsx(K0s,{})})}),e.jsx(Hs,{path:"/marketplace/cart",element:e.jsx(ur,{children:e.jsx(Z0s,{})})}),e.jsx(Hs,{path:"/marketplace/orders",element:e.jsx(ur,{children:e.jsx(Y0s,{})})}),e.jsx(Hs,{path:"/marketplace/orders/:orderId",element:e.jsx(ur,{children:e.jsx(Q0s,{})})}),e.jsx(Hs,{path:"/marketplace/success",element:e.jsx(ur,{children:e.jsx(J0s,{})})}),e.jsx(Hs,{path:"/admin/agent-cards",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Ygs,{})})}),e.jsx(Hs,{path:"/admin/presentation-analytics",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Hxs,{})})}),e.jsx(Hs,{path:"/admin/guest-book-analytics",element:e.jsx(ur,{requireAdmin:!0,children:e.jsx(Wxs,{})})}),e.jsx(Hs,{path:"/mission-control/smart-drips",element:e.jsx(ur,{children:e.jsx(Ovs,{})})}),e.jsx(Hs,{path:"/mission-control/presentations",element:e.jsx(ur,{children:e.jsx(tvs,{})})}),e.jsx(Hs,{path:"/mission-control/presentations/new",element:e.jsx(ur,{children:e.jsx(JLe,{})})}),e.jsx(Hs,{path:"/mission-control/presentations/:id",element:e.jsx(ur,{children:e.jsx(JLe,{})})}),e.jsx(Hs,{path:"/mission-control/guest-book",element:e.jsx(ur,{children:e.jsx(uvs,{})})}),e.jsx(Hs,{path:"/guestbook/:slug",element:e.jsx(q9e,{})}),e.jsx(Hs,{path:"/mission-control/card-studio",element:e.jsx(ur,{children:e.jsx(vvs,{})})}),e.jsx(Hs,{path:"/mission-control/scheduler",element:e.jsx(ur,{children:e.jsx(Xvs,{})})}),e.jsx(Hs,{path:"/c/:shareToken",element:e.jsx(xet,{})}),e.jsx(Hs,{path:"/book/:slug",element:e.jsx(vet,{})}),e.jsx(Hs,{path:"/page/:slug",element:e.jsx(_et,{})}),e.jsx(Hs,{path:"/mission-control/landing-pages",element:e.jsx(ur,{children:e.jsx(Qvs,{})})}),e.jsx(Hs,{path:"/mission-control/landing-pages/:pageId",element:e.jsx(ur,{children:e.jsx(t1s,{})})}),e.jsx(Hs,{path:"*",element:e.jsx(yet,{})})]}),")"]})})})})]})})}),pDe=window.location.hostname,k1s=pDe.includes("lovable.app")||pDe.includes("lovableproject.com");k1s&&"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))}));F8e(document.getElementById("root")).render(e.jsx(j1s,{}));export{at as $,qd as A,K as B,Wc as C,sr as D,er as E,At as F,vs as G,Vn as H,Jo as I,ys as J,Cs as K,As as L,A0 as M,Ss as N,Ta as O,Kr as P,mp as Q,ht as R,Gx as S,YN as T,Xa as U,ja as V,va as W,Ns as X,Iee as Y,zs as Z,xn as _,ns as a,Gs as a$,Fi as a0,fa as a1,Ti as a2,zu as a3,rwe as a4,Mh as a5,nwe as a6,On as a7,j0 as a8,$x as a9,Tl as aA,Al as aB,Pl as aC,Il as aD,El as aE,Ll as aF,fl as aG,$z as aH,br as aI,mn as aJ,Lr as aK,Ac as aL,Ms as aM,Lt as aN,yr as aO,zt as aP,cl as aQ,wm as aR,Ai as aS,L1s as aT,Tn as aU,An as aV,js as aW,jt as aX,En as aY,it as aZ,ws as a_,kP as aa,zo as ab,Ka as ac,Ua as ad,j5 as ae,o_ as af,yu as ag,vu as ah,gi as ai,Wd as aj,Da as ak,LW as al,Sn as am,CV as an,Ee as ao,Oe as ap,ev as aq,Rl as ar,Zs as as,Sd as at,rN as au,Ui as av,c0 as aw,ya as ax,Ol as ay,tc as az,Ot as b,OZ as b0,Et as b1,fp as b2,dl as b3,pse as b4,Ur as b5,Mi as b6,h5 as b7,Eo as b8,au as b9,Qo as bA,AZ as bB,kZ as bC,YE as bD,_u as bE,A9 as bF,fn as bG,Ma as bH,gn as bI,d5 as bJ,m0 as bK,Nn as ba,L0 as bb,nN as bc,I2t as bd,NKe as be,aye as bf,bJ as bg,qKe as bh,TKe as bi,HKe as bj,B1s as bk,pwe as bl,wle as bm,GKe as bn,S3 as bo,Ru as bp,w0 as bq,AQ as br,Br as bs,Zn as bt,Ca as bu,No as bv,So as bw,jo as bx,eP as by,la as bz,Ent as c,fe as d,zte as e,nd as f,_o as g,ad as h,Hc as i,e as j,sc as k,Qw as l,Yi as m,ai as n,Ju as o,jr as p,ve as q,S as r,G as s,an as t,Ct as u,Re as v,Pg as w,Tr as x,tr as y,Js as z};